From 060002c5ae6e3fea8af884c70d175fd6c653d81a Mon Sep 17 00:00:00 2001 From: Jim Hall Date: Sat, 6 May 2000 19:34:20 +0000 Subject: [PATCH 001/671] Initial revision git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@2 6ac86273-5f31-0410-b378-82cca8765d1b --- bin/autoexec.bat | 2 + bin/config.sys | 3 + bin/copying | 339 +++++++ bin/install.bat | 49 + bin/mkboot.txt | 11 + boot/boot.asm | 598 ++++++++++++ boot/boot.mak | 59 ++ build.bat | 75 ++ clean.bat | 66 ++ clobber.bat | 60 ++ config.b | 1 + config.m | 63 ++ docs/bugs.txt | 6 + docs/build.txt | 78 ++ docs/contrib.txt | 17 + docs/copying | 339 +++++++ docs/history.txt | 543 +++++++++++ docs/intfns.txt | 209 +++++ docs/mkboot.txt | 11 + docs/readme.cvs | 15 + drivers/devend.asm | 78 ++ drivers/device.mak | 103 +++ drivers/floppy.asm | 331 +++++++ drivers/getvec.asm | 92 ++ drivers/rdatclk.asm | 117 +++ drivers/rdpcclk.asm | 82 ++ drivers/timer.asm | 159 ++++ drivers/wratclk.asm | 101 +++ drivers/wrpcclk.asm | 82 ++ fdkernel.lsm | 14 + hdr/cds.h | 112 +++ hdr/clock.h | 86 ++ hdr/date.h | 95 ++ hdr/dcb.h | 109 +++ hdr/device.h | 421 +++++++++ hdr/dirmatch.h | 117 +++ hdr/dosnames.h | 79 ++ hdr/error.h | 124 +++ hdr/exe.h | 93 ++ hdr/fat.h | 139 +++ hdr/fcb.h | 167 ++++ hdr/file.h | 76 ++ hdr/fnode.h | 115 +++ hdr/kbd.h | 83 ++ hdr/mcb.h | 102 +++ hdr/network.h | 87 ++ hdr/pcb.h | 177 ++++ hdr/portab.h | 201 ++++ hdr/process.h | 172 ++++ hdr/sft.h | 199 ++++ hdr/stacks.inc | 136 +++ hdr/tail.h | 83 ++ hdr/time.h | 91 ++ hdr/version.h | 46 + kernel/001-437.nls | 233 +++++ kernel/apisupt.asm | 169 ++++ kernel/asmsupt.asm | 195 ++++ kernel/blockio.c | 587 ++++++++++++ kernel/break.c | 84 ++ kernel/chario.c | 404 +++++++++ kernel/config.c | 925 +++++++++++++++++++ kernel/console.asm | 279 ++++++ kernel/dosfns.c | 1148 +++++++++++++++++++++++ kernel/dosidle.asm | 100 ++ kernel/dosnames.c | 481 ++++++++++ kernel/dsk.c | 671 ++++++++++++++ kernel/entry.asm | 633 +++++++++++++ kernel/error.c | 145 +++ kernel/execrh.asm | 129 +++ kernel/fatdir.c | 829 +++++++++++++++++ kernel/fatfs.c | 2117 +++++++++++++++++++++++++++++++++++++++++++ kernel/fattab.c | 378 ++++++++ kernel/fcbfns.c | 1169 ++++++++++++++++++++++++ kernel/globals.h | 713 +++++++++++++++ kernel/init-mod.h | 28 + kernel/initoem.c | 105 +++ kernel/int2f.asm | 232 +++++ kernel/inthndlr.c | 1702 ++++++++++++++++++++++++++++++++++ kernel/io.asm | 619 +++++++++++++ kernel/io.inc | 72 ++ kernel/ioctl.c | 356 ++++++++ kernel/irqstack.asm | 268 ++++++ kernel/kernel.asm | 606 +++++++++++++ kernel/kernel.cfg | 13 + kernel/kernel.mak | 415 +++++++++ kernel/main.c | 524 +++++++++++ kernel/memmgr.c | 572 ++++++++++++ kernel/misc.c | 140 +++ kernel/network.c | 209 +++++ kernel/newstuff.c | 326 +++++++ kernel/nls.c | 667 ++++++++++++++ kernel/nlssupt.asm | 103 +++ kernel/prf.c | 410 +++++++++ kernel/printer.asm | 201 ++++ kernel/procsupt.asm | 312 +++++++ kernel/proto.h | 452 +++++++++ kernel/segs.inc | 63 ++ kernel/serial.asm | 171 ++++ kernel/strings.c | 199 ++++ kernel/sysclk.c | 321 +++++++ kernel/syspack.c | 157 ++++ kernel/systime.c | 242 +++++ kernel/task.c | 914 +++++++++++++++++++ lib/libm.mak | 41 + readme.txt | 36 + sys/bin2c.c | 51 ++ sys/bin2c.mak | 55 ++ sys/sys.c | 666 ++++++++++++++ sys/sys.mak | 73 ++ utils/indent.ini | 17 + utils/proto.bat | 2 + 111 files changed, 29542 insertions(+) create mode 100644 bin/autoexec.bat create mode 100644 bin/config.sys create mode 100644 bin/copying create mode 100644 bin/install.bat create mode 100644 bin/mkboot.txt create mode 100644 boot/boot.asm create mode 100644 boot/boot.mak create mode 100644 build.bat create mode 100644 clean.bat create mode 100644 clobber.bat create mode 100644 config.b create mode 100644 config.m create mode 100644 docs/bugs.txt create mode 100644 docs/build.txt create mode 100644 docs/contrib.txt create mode 100644 docs/copying create mode 100644 docs/history.txt create mode 100644 docs/intfns.txt create mode 100644 docs/mkboot.txt create mode 100644 docs/readme.cvs create mode 100644 drivers/devend.asm create mode 100644 drivers/device.mak create mode 100644 drivers/floppy.asm create mode 100644 drivers/getvec.asm create mode 100644 drivers/rdatclk.asm create mode 100644 drivers/rdpcclk.asm create mode 100644 drivers/timer.asm create mode 100644 drivers/wratclk.asm create mode 100644 drivers/wrpcclk.asm create mode 100644 fdkernel.lsm create mode 100644 hdr/cds.h create mode 100644 hdr/clock.h create mode 100644 hdr/date.h create mode 100644 hdr/dcb.h create mode 100644 hdr/device.h create mode 100644 hdr/dirmatch.h create mode 100644 hdr/dosnames.h create mode 100644 hdr/error.h create mode 100644 hdr/exe.h create mode 100644 hdr/fat.h create mode 100644 hdr/fcb.h create mode 100644 hdr/file.h create mode 100644 hdr/fnode.h create mode 100644 hdr/kbd.h create mode 100644 hdr/mcb.h create mode 100644 hdr/network.h create mode 100644 hdr/pcb.h create mode 100644 hdr/portab.h create mode 100644 hdr/process.h create mode 100644 hdr/sft.h create mode 100644 hdr/stacks.inc create mode 100644 hdr/tail.h create mode 100644 hdr/time.h create mode 100644 hdr/version.h create mode 100644 kernel/001-437.nls create mode 100644 kernel/apisupt.asm create mode 100644 kernel/asmsupt.asm create mode 100644 kernel/blockio.c create mode 100644 kernel/break.c create mode 100644 kernel/chario.c create mode 100644 kernel/config.c create mode 100644 kernel/console.asm create mode 100644 kernel/dosfns.c create mode 100644 kernel/dosidle.asm create mode 100644 kernel/dosnames.c create mode 100644 kernel/dsk.c create mode 100644 kernel/entry.asm create mode 100644 kernel/error.c create mode 100644 kernel/execrh.asm create mode 100644 kernel/fatdir.c create mode 100644 kernel/fatfs.c create mode 100644 kernel/fattab.c create mode 100644 kernel/fcbfns.c create mode 100644 kernel/globals.h create mode 100644 kernel/init-mod.h create mode 100644 kernel/initoem.c create mode 100644 kernel/int2f.asm create mode 100644 kernel/inthndlr.c create mode 100644 kernel/io.asm create mode 100644 kernel/io.inc create mode 100644 kernel/ioctl.c create mode 100644 kernel/irqstack.asm create mode 100644 kernel/kernel.asm create mode 100644 kernel/kernel.cfg create mode 100644 kernel/kernel.mak create mode 100644 kernel/main.c create mode 100644 kernel/memmgr.c create mode 100644 kernel/misc.c create mode 100644 kernel/network.c create mode 100644 kernel/newstuff.c create mode 100644 kernel/nls.c create mode 100644 kernel/nlssupt.asm create mode 100644 kernel/prf.c create mode 100644 kernel/printer.asm create mode 100644 kernel/procsupt.asm create mode 100644 kernel/proto.h create mode 100644 kernel/segs.inc create mode 100644 kernel/serial.asm create mode 100644 kernel/strings.c create mode 100644 kernel/sysclk.c create mode 100644 kernel/syspack.c create mode 100644 kernel/systime.c create mode 100644 kernel/task.c create mode 100644 lib/libm.mak create mode 100644 readme.txt create mode 100644 sys/bin2c.c create mode 100644 sys/bin2c.mak create mode 100644 sys/sys.c create mode 100644 sys/sys.mak create mode 100644 utils/indent.ini create mode 100644 utils/proto.bat diff --git a/bin/autoexec.bat b/bin/autoexec.bat new file mode 100644 index 00000000..8ef39429 --- /dev/null +++ b/bin/autoexec.bat @@ -0,0 +1,2 @@ +@echo off +echo Welcome to FreeDOS (http://www.freedos.org)! diff --git a/bin/config.sys b/bin/config.sys new file mode 100644 index 00000000..b3c420cd --- /dev/null +++ b/bin/config.sys @@ -0,0 +1,3 @@ +files=20 +buffers=20 +rem screen=0x12 diff --git a/bin/copying b/bin/copying new file mode 100644 index 00000000..b8cf3a1a --- /dev/null +++ b/bin/copying @@ -0,0 +1,339 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 675 Mass Ave, Cambridge, MA 02139, USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + Appendix: How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) 19yy + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) 19yy name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Library General +Public License instead of this License. diff --git a/bin/install.bat b/bin/install.bat new file mode 100644 index 00000000..8562e5e5 --- /dev/null +++ b/bin/install.bat @@ -0,0 +1,49 @@ +@echo off +rem +rem Create a distribution floppy +rem +rem $Header$ +rem $Log$ +rem Revision 1.1 2000/05/06 19:34:23 jhall1 +rem Initial revision +rem +rem Revision 1.3 1999/08/25 03:15:33 jprice +rem ror4 patches to allow TC 2.01 compile. +rem +rem Revision 1.2 1999/04/01 07:22:58 jprice +rem no message +rem +rem Revision 1.1.1.1 1999/03/29 15:40:21 jprice +rem New version without IPL.SYS +rem +rem + +set D=A: +if "%1" == "b:" set D=B: +if "%1" == "B:" set D=B: +if "%1" == "b" set D=B: +if "%1" == "B" set D=B: + +echo This utility will create a distribution floppy on the disk in drive %D% +pause + +rem try to transfer system files -- abort if it cannot. +sys %D% +if errorlevel 1 goto out + +rem copy remaining files +echo copying remaining files... +echo copying autoexec.bat... +copy autoexec.bat %D% +echo copying config.sys.. +copy config.sys %D% +echo copying sys.com.. +copy sys.com %D% +label %D% freedos + +rem exit methods +goto done +:out +echo Floppy creation aborted +:done +set D= diff --git a/bin/mkboot.txt b/bin/mkboot.txt new file mode 100644 index 00000000..73be5d66 --- /dev/null +++ b/bin/mkboot.txt @@ -0,0 +1,11 @@ +To create a bootable floppy suitable for copying the system to +another drive: + +1. Change directory (if necessary) to where the FreeDOS Kernel BIN +directory. + +3. Enter the command "install" to transfer the system files to the +diskette in drive A. If you want to install on drive B, type +"install b:" + +4. Write protect this disk and use it to boot from. diff --git a/boot/boot.asm b/boot/boot.asm new file mode 100644 index 00000000..9fdcb9e7 --- /dev/null +++ b/boot/boot.asm @@ -0,0 +1,598 @@ +; +; File: +; boot.asm +; Description: +; DOS-C boot +; +; Copyright (c) 1997; +; Svante Frey +; All Rights Reserved +; +; This file is part of DOS-C. +; +; DOS-C is free software; you can redistribute it and/or +; modify it under the terms of the GNU General Public License +; as published by the Free Software Foundation; either version +; 2, or (at your option) any later version. +; +; DOS-C is distributed in the hope that it will be useful, but +; WITHOUT ANY WARRANTY; without even the implied warranty of +; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See +; the GNU General Public License for more details. +; +; You should have received a copy of the GNU General Public +; License along with DOS-C; see the file COPYING. If not, +; write to the Free Software Foundation, 675 Mass Ave, +; Cambridge, MA 02139, USA. +; + + +; $Log$ +; Revision 1.1 2000/05/06 19:34:38 jhall1 +; Initial revision +; +; Revision 1.12 1999/09/25 06:42:18 jprice +; Optimize boot loader. Documentation. +; +; Revision 1.11 1999/09/24 19:04:55 jprice +; Added changes recommended by Jens Horstmeier + +; to make their bootable CD work. +; +; Revision 1.10 1999/09/23 04:39:02 jprice +; *** empty log message *** +; +; Revision 1.7 1999/04/23 03:43:46 jprice +; Ported to NASM by ror4 +; +; Revision 1.6 1999/04/17 19:14:03 jprice +; Fixed multi-sector code +; +; Revision 1.5 1999/04/17 06:23:26 jprice +; Changed so multi-sector IO is optional. +; +; Revision 1.4 1999/04/13 15:52:22 jprice +; Moves boot sector to top of mem +; +; Revision 1.3 1999/04/06 22:53:36 jprice +; Put back code to read multiple sectors at a time. +; +; Revision 1.2 1999/04/01 07:23:20 jprice +; New boot loader +; +; Revision 1.1.1.1 1999/03/29 15:39:39 jprice +; New version without IPL.SYS +; +; Revision 1.3 1999/03/02 06:57:14 jprice +; Added entry address for more recent versions of TLINK +; +; Revision 1.2 1999/01/21 05:03:58 jprice +; Formating. +; +; Revision 1.1.1.1 1999/01/20 05:51:00 jprice +; Imported sources +; +; +; Rev 1.5 10 Jan 1997 4:58:06 patv +; Corrected copyright +; +; Rev 1.4 10 Jan 1997 4:52:50 patv +; Re-written to support C drive and eliminate restrictions on IPL.SYS +; +; Rev 1.3 29 Aug 1996 13:06:50 patv +; Bug fixes for v0.91b +; +; Rev 1.2 01 Sep 1995 17:56:44 patv +; First GPL release. +; +; Rev 1.1 30 Jul 1995 20:37:38 patv +; Initialized stack before use. +; +; Rev 1.0 02 Jul 1995 10:57:52 patv +; Initial revision. +; + +; +--------+ +; | | +; | | +; |--------| 4000:0000 +; | | +; | FAT | +; | | +; |--------| 2000:0000 +; |BOOT SEC| +; |RELOCATE| +; |--------| 1FE0:0000 +; | | +; | | +; | | +; | | +; |--------| +; |BOOT SEC| +; |ORIGIN | 07C0:0000 +; |--------| +; | | +; | | +; | | +; |--------| +; |KERNEL | +; |LOADED | +; |--------| 0060:0000 +; | | +; +--------+ + + +;%define ISFAT12 1 +;%define ISFAT16 1 +;%define CALCPARAMS 1 +;%define MULTI_SEC_READ 1 + + +segment .text + +%define BASE 0x7c00 + + org BASE + +Entry: jmp short real_start + nop + +; bp is initialized to 7c00h +%define bsOemName bp+0x03 ; OEM label +%define bsBytesPerSec bp+0x0b ; bytes/sector +%define bsSecPerClust bp+0x0d ; sectors/allocation unit +%define bsResSectors bp+0x0e ; # reserved sectors +%define bsFATs bp+0x10 ; # of fats +%define bsRootDirEnts bp+0x11 ; # of root dir entries +%define bsSectors bp+0x13 ; # sectors total in image +%define bsMedia bp+0x15 ; media descrip: fd=2side9sec, etc... +%define sectPerFat bp+0x16 ; # sectors in a fat +%define sectPerTrack bp+0x18 ; # sectors/track +%define nHeads bp+0x1a ; # heads +%define nHidden bp+0x1c ; # hidden sectors +%define nSectorHuge bp+0x20 ; # sectors if > 65536 +%define drive bp+0x24 ; drive number +%define extBoot bp+0x26 ; extended boot signature +%define volid bp+0x27 +%define vollabel bp+0x2b +%define filesys bp+0x36 + +%define LOADSEG 0x0060 + +%define FATBUF 0x2000 ; offset of temporary buffer for FAT + ; chain + +; Some extra variables + +;%define StoreSI bp+3h ;temp store + +; To save space, functions that are just called once are +; implemented as macros instead. Four bytes are saved by +; avoiding the call / ret instructions. + + +; GETDRIVEPARMS: Calculate start of some disk areas. +; + +%macro GETDRIVEPARMS 0 + mov si, word [nHidden] + mov di, word [nHidden+2] + add si, word [bsResSectors] + adc di, byte 0 ; DI:SI = first FAT sector + + mov word [fat_start], si + mov word [fat_start+2], di + + mov al, [bsFATs] + xor ah, ah + mul word [sectPerFat] ; DX:AX = total number of FAT sectors + + add si, ax + adc di, dx ; DI:SI = first root directory sector + mov word [root_dir_start], si + mov word [root_dir_start+2], di + + ; Calculate how many sectors the root directory occupies. + mov bx, [bsBytesPerSec] + mov cl, 5 ; divide BX by 32 + shr bx, cl ; BX = directory entries per sector + + mov ax, [bsRootDirEnts] + xor dx, dx + div bx + + mov word [RootDirSecs], ax ; AX = sectors per root directory + + add si, ax + adc di, byte 0 ; DI:SI = first data sector + + mov [data_start], si + mov [data_start+2], di +%endmacro + +;----------------------------------------------------------------------- + + times 0x3E-$+$$ db 0 + +%define tempbuf bp+0x3E + dw LOADSEG + +%ifdef CALCPARAMS +%define RootDirSecs bp+0x27 ; # of sectors root dir uses + +%define fat_start bp+0x29 ; first FAT sector + +%define root_dir_start bp+0x2D ; first root directory sector + +%define data_start bp+0x31 ; first data sector + +%else +%define RootDirSecs bp+0x40 ; # of sectors root dir uses + dw 0 + +%define fat_start bp+0x42 ; first FAT sector + dd 0 + +%define root_dir_start bp+0x46 ; first root directory sector + dd 0 + +%define data_start bp+0x4A ; first data sector + dd 0 +%endif + +;----------------------------------------------------------------------- +; ENTRY +;----------------------------------------------------------------------- + +real_start: cli + cld + xor ax, ax + mov ss, ax ; initialize stack + mov ds, ax + mov bp, 0x7c00 + lea sp, [bp-0x20] + sti + int 0x13 ; reset drive +; int 0x12 ; get memory available in AX +; mov ax, 0x01e0 +; mov cl, 6 ; move boot sector to higher memory +; shl ax, cl +; sub ax, 0x07e0 + + mov ax, 0x1FE0 + mov es, ax + mov si, bp + mov di, bp + mov cx, 0x0100 + rep movsw + push es + mov bx, cont + push bx + retf + +cont: mov ds, ax + mov ss, ax + mov [drive], dl ; BIOS passes drive number in DL + + call print + db "Loading FreeDOS...",13,10,"ROOT",0 + +%ifdef CALCPARAMS + GETDRIVEPARMS +%endif + + +; FINDFILE: Searches for the file in the root directory. +; +; Returns: +; AX = first cluster of file + + ; First, read the whole root directory + ; into the temporary buffer. + + mov ax, word [root_dir_start] + mov dx, word [root_dir_start+2] + mov di, word [RootDirSecs] + xor bx, bx + mov es, [tempbuf] + call readDisk + jc jmp_boot_error + + xor di, di + + ; Search for KERNEL.SYS file name, and find start cluster. + +next_entry: mov cx, 11 + mov si, filename + push di + repe cmpsb + pop di + mov ax, [es:di+0x1A]; get cluster number from directory entry + je ffDone + + add di, byte 0x20 ; go to next directory entry + cmp byte [es:di], 0 ; if the first byte of the name is 0, + jnz next_entry ; there is no more files in the directory + + jc boot_error ; fail if not found +ffDone: + push ax ; store first cluster number + + call print + db " FAT",0 + + + +; GETFATCHAIN: +; +; Reads the FAT chain and stores it in a temporary buffer in the first +; 64 kb. The FAT chain is stored an array of 16-bit cluster numbers, +; ending with 0. +; +; The file must fit in conventional memory, so it can't be larger than +; 640 kb. The sector size must be at least 512 bytes, so the FAT chain +; can't be larger than around 3 kb. +; +; Call with: AX = first cluster in chain + + ; Load the complete FAT into memory. The FAT can't be larger + ; than 128 kb, so it should fit in the temporary buffer. + + mov es, [tempbuf] + xor bx, bx + mov di, [sectPerFat] + mov ax, word [fat_start] + mov dx, word [fat_start+2] + call readDisk + pop ax ; restore first cluster number +jmp_boot_error: jc boot_error + + ; Set ES:DI to the temporary storage for the FAT chain. + push ds + push es + pop ds + pop es + mov di, FATBUF + +next_clust: stosw ; store cluster number + mov si, ax ; SI = cluster number + +%ifdef ISFAT12 + ; This is a FAT-12 disk. + +fat_12: add si, si ; multiply cluster number by 3... + add si, ax + shr si, 1 ; ...and divide by 2 + lodsw + + ; If the cluster number was even, the cluster value is now in + ; bits 0-11 of AX. If the cluster number was odd, the cluster + ; value is in bits 4-15, and must be shifted right 4 bits. If + ; the number was odd, CF was set in the last shift instruction. + + jnc fat_even + mov cl, 4 + shr ax, cl ; shift the cluster number + +fat_even: and ah, 0x0f ; mask off the highest 4 bits + cmp ax, 0x0fff ; check for EOF + jb next_clust ; continue if not EOF + +%endif +%ifdef ISFAT16 + ; This is a FAT-16 disk. The maximal size of a 16-bit FAT + ; is 128 kb, so it may not fit within a single 64 kb segment. + +fat_16: mov dx, [tempbuf] + add si, si ; multiply cluster number by two + jnc first_half ; if overflow... + add dh, 0x10 ; ...add 64 kb to segment value + +first_half: mov ds, dx ; DS:SI = pointer to next cluster + lodsw ; AX = next cluster + + cmp ax, 0xfff8 ; >= FFF8 = 16-bit EOF + jb next_clust ; continue if not EOF +%endif + +finished: ; Mark end of FAT chain with 0, so we have a single + ; EOF marker for both FAT-12 and FAT-16 systems. + + xor ax, ax + stosw + + push cs + pop ds + + call print + db " KERNEL",0 + +; loadFile: Loads the file into memory, one cluster at a time. + + mov es, [tempbuf] ; set ES:BX to load address + xor bx, bx + + mov si, FATBUF ; set DS:SI to the FAT chain + +cluster_next: lodsw ; AX = next cluster to read + or ax, ax ; if EOF... + je boot_success ; ...boot was successful + + dec ax ; cluster numbers start with 2 + dec ax + + mov di, word [bsSecPerClust] + and di, 0xff ; DI = sectors per cluster + mul di + add ax, [data_start] + adc dx, [data_start+2] ; DX:AX = first sector to read + call readDisk + jnc cluster_next + + +boot_error: call print + db 13,10,"BOOT error!",13,10,0 + + xor ah,ah + int 0x16 ; wait for a key + int 0x19 ; reboot the machine + +boot_success: call print + db " GO!",13,10,0 + mov bl, [drive] + jmp word LOADSEG:0 + + +; prints text after call to this function. + +print: pop si ; this is the first character + xor bx, bx ; video page 0 + mov ah, 0x0E ; else print it +print1: lodsb ; get token + cmp al, 0 ; end of string? + je print2 ; if so, exit + int 0x10 ; via TTY mode + jmp short print1 ; until done +print2: push si ; stack up return address + ret ; and jump to it + + +; readDisk: Reads a number of sectors into memory. +; +; Call with: DX:AX = 32-bit DOS sector number +; DI = number of sectors to read +; ES:BX = destination buffer +; ES must be 64k aligned (1000h, 2000h etc). +; +; Returns: CF set on error +; ES:BX points one byte after the last byte read. + +readDisk: push si +read_next: push dx + push ax + + ; + ; translate sector number to BIOS parameters + ; + + ; + ; abs = sector offset in track + ; + head * sectPerTrack offset in cylinder + ; + track * sectPerTrack * nHeads offset in platter + ; + ; t1 = abs / sectPerTrack (ax has t1) + ; sector = abs mod sectPerTrack (cx has sector) + ; + div word [sectPerTrack] + mov cx, dx + + ; + ; t1 = head + track * nHeads + ; + ; track = t1 / nHeads (ax has track) + ; head = t1 mod nHeads (dl has head) + ; + xor dx, dx + div word [nHeads] + + ; the following manipulations are necessary in order to + ; properly place parameters into registers. + ; ch = cylinder number low 8 bits + ; cl = 7-6: cylinder high two bits + ; 5-0: sector + mov dh, dl ; save head into dh for bios + ror ah, 1 ; move track high bits into + ror ah, 1 ; bits 7-6 (assumes top = 0) + xchg al, ah ; swap for later + mov dl, byte [sectPerTrack] + sub dl, cl + inc cl ; sector offset from 1 + or cx, ax ; merge cylinder into sector + mov al, dl ; al has # of sectors left + +%ifdef MULTI_SEC_READ + ; Calculate how many sectors can be transfered in this read + ; due to dma boundary conditions. + push dx + + mov si, di ; temp register save + ; this computes remaining bytes because of modulo 65536 + ; nature of dma boundary condition + mov ax, bx ; get offset pointer + neg ax ; and convert to bytes + jz ax_min_1 ; started at seg:0, skip ahead + + xor dx, dx ; convert to sectors + div word [bsBytesPerSec] + + cmp ax, di ; check remainder vs. asked + jb ax_min_1 ; less, skip ahead + mov si, ax ; transfer only what we can + +ax_min_1: pop dx + + ; Check that request sectors do not exceed track boundary + mov si, [sectPerTrack] + inc si + mov ax, cx ; get the sector/cyl byte + and ax, 0x3f ; and mask out sector + sub si, ax ; si has how many we can read + mov ax, di + cmp si, di ; see if asked <= available + jge ax_min_2 + mov ax, si ; get what can be xfered + +ax_min_2: push ax + mov ah, 2 + mov dl, [drive] + int 0x13 + pop ax +%else + mov ax, 0x0201 + mov dl, [drive] + int 0x13 +%endif + jnc read_ok ; jump if no error + xor ah, ah ; else, reset floppy + int 0x13 + pop ax + pop dx ; and... + jmp short read_next ; read the same sector again + +read_ok: +%ifdef MULTI_SEC_READ + mul word [bsBytesPerSec] ; add number of bytes read to BX + add bx, ax +%else + add bx, word [bsBytesPerSec] +%endif + jnc no_incr_es ; if overflow... + + mov ax, es + add ah, 0x10 ; ...add 1000h to ES + mov es, ax + +no_incr_es: pop ax + pop dx ; DX:AX = last sector number + +%ifdef MULTI_SEC_READ + add ax, si + adc dx, byte 0 ; DX:AX = next sector to read + sub di,si ; if there is anything left to read, + jg read_next ; continue +%else + add ax, 1 + adc dx, byte 0 ; DX:AX = next sector to read + dec di ; if there is anything left to read, + jnz read_next ; continue +%endif + + clc + pop si + ret + +filename db "KERNEL SYS" + + times 0x01fe-$+$$ db 0 + +sign dw 0xAA55 diff --git a/boot/boot.mak b/boot/boot.mak new file mode 100644 index 00000000..b35efb2b --- /dev/null +++ b/boot/boot.mak @@ -0,0 +1,59 @@ +# +# makefile for DOS-C boot +# +# $Id$ +# + +# $Log$ +# Revision 1.1 2000/05/06 19:34:38 jhall1 +# Initial revision +# +# Revision 1.3 1999/04/23 03:44:17 jprice +# Ported to NASM by ror4. Improvements +# +# Revision 1.2 1999/04/01 07:23:20 jprice +# New boot loader +# +# Revision 1.1.1.1 1999/03/29 15:39:39 jprice +# New version without IPL.SYS +# +# Revision 1.3 1999/02/09 04:49:17 jprice +# Make makefile use common config.mak file +# +# Revision 1.2 1999/01/21 05:03:58 jprice +# Formating. +# +# Revision 1.1.1.1 1999/01/20 05:51:00 jprice +# Imported sources +# +# +# Rev 1.3 10 Jan 1997 4:51:54 patv +#Changed to use FreeDOS exe2bin and support new boot code +# +# Rev 1.2 17 Dec 1996 12:52:32 patv +#Converted to FreeDOS exe2bin. +# +# Rev 1.1 29 Aug 1996 13:06:50 patv +#Bug fixes for v0.91b +# +# Rev 1.0 02 Jul 1995 9:11:26 patv +#Initial revision. +# + +!include "..\config.mak" + +production: b_fat12.bin b_fat16.bin + +b_fat12.bin: boot.asm + $(NASM) -dISFAT12 boot.asm -ob_fat12.bin + +b_fat16.bin: boot.asm + $(NASM) -dISFAT16 boot.asm -ob_fat16.bin + +clobber: clean + $(RM) b_fat12.bin b_fat16.bin status.me + +clean: + $(RM) *.lst *.map *.bak *.obj + + diff --git a/build.bat b/build.bat new file mode 100644 index 00000000..e5d752ef --- /dev/null +++ b/build.bat @@ -0,0 +1,75 @@ +@echo off + +rem batch file to build everything + +rem $Id$ + +rem $Log$ +rem Revision 1.1 2000/05/06 19:34:02 jhall1 +rem Initial revision +rem +rem Revision 1.5 1999/08/25 03:59:14 jprice +rem New build batch files. +rem +rem Revision 1.4 1999/08/25 03:38:16 jprice +rem New build config +rem +rem Revision 1.3 1999/04/23 03:46:02 jprice +rem Improved by jprice +rem +rem Revision 1.2 1999/04/17 19:13:29 jprice +rem ror4 patches +rem +rem Revision 1.1.1.1 1999/03/29 15:39:13 jprice +rem New version without IPL.SYS +rem +rem Revision 1.5 1999/02/09 04:47:54 jprice +rem Make makefile use common config.mak file +rem +rem Revision 1.4 1999/01/30 08:29:10 jprice +rem Clean up +rem +rem Revision 1.3 1999/01/30 07:49:16 jprice +rem Clean up +rem + +if not exist config.bat goto noconfigbat +if not exist config.mak goto noconfigmak +goto start + +:noconfigbat +echo You must copy CONFIG.B to CONFIG.BAT and edit it to reflect your setup! +goto end + +:noconfigmak +echo You must copy CONFIG.M to CONFIG.MAK and edit it to reflect your setup! +goto end + +:start +call config.bat + +cd lib +%MAKE% -flibm.mak +if errorlevel 1 goto abort + +cd ..\drivers +%MAKE% -fdevice.mak production +if errorlevel 1 goto abort + +cd ..\boot +%MAKE% -fboot.mak production +if errorlevel 1 goto abort + +cd ..\sys +%MAKE% -fbin2c.mak production +if errorlevel 1 goto abort +%MAKE% -fsys.mak production +if errorlevel 1 goto abort + +cd ..\kernel +%MAKE% -fkernel.mak production + +:abort +cd .. +:end +set MAKE= diff --git a/clean.bat b/clean.bat new file mode 100644 index 00000000..5515f4ec --- /dev/null +++ b/clean.bat @@ -0,0 +1,66 @@ +@echo off + +rem batch file to clean everything + +rem $Id$ + +rem $Log$ +rem Revision 1.1 2000/05/06 19:34:02 jhall1 +rem Initial revision +rem +rem Revision 1.3 1999/08/25 03:59:14 jprice +rem New build batch files. +rem +rem Revision 1.2 1999/04/23 03:46:02 jprice +rem Improved by jprice +rem +rem Revision 1.1.1.1 1999/03/29 15:39:15 jprice +rem New version without IPL.SYS +rem +rem Revision 1.4 1999/02/09 04:47:54 jprice +rem Make makefile use common config.mak file +rem +rem Revision 1.3 1999/01/30 08:29:10 jprice +rem Clean up +rem + +if not exist config.bat goto noconfigbat +if not exist config.mak goto noconfigmak +goto start + +:noconfigbat +echo You must copy CONFIG.B to CONFIG.BAT and edit it to reflect your setup! +goto end + +:noconfigmak +echo You must copy CONFIG.M to CONFIG.MAK and edit it to reflect your setup! +goto end + +:start +call config.bat + +cd lib +%MAKE% -flibm.mak clean + +cd ..\drivers +%MAKE% -fdevice.mak clean + +cd ..\boot +%MAKE% -fboot.mak clean + +cd ..\sys +%MAKE% -fbin2c.mak clean +%MAKE% -fsys.mak clean + +cd ..\kernel +%MAKE% -fkernel.mak clean + +cd ..\hdr +del *.bak + +cd .. + +del *.bak + +:end +set MAKE= diff --git a/clobber.bat b/clobber.bat new file mode 100644 index 00000000..8105e741 --- /dev/null +++ b/clobber.bat @@ -0,0 +1,60 @@ +@echo off +rem batch file to clobber everything + +rem $Id$ + +rem $Log$ +rem Revision 1.1 2000/05/06 19:34:02 jhall1 +rem Initial revision +rem +rem Revision 1.3 1999/08/25 03:59:14 jprice +rem New build batch files. +rem +rem Revision 1.2 1999/08/10 18:34:06 jprice +rem case +rem +rem Revision 1.1 1999/04/23 03:47:19 jprice +rem Initial include +rem + +if not exist config.bat goto noconfigbat +if not exist config.mak goto noconfigmak +goto start + +:noconfigbat +echo You must copy CONFIG.B to CONFIG.BAT and edit it to reflect your setup! +goto end + +:noconfigmak +echo You must copy CONFIG.M to CONFIG.MAK and edit it to reflect your setup! +goto end + +:start +call config.bat + +cd lib +%MAKE% -flibm.mak clobber + +cd ..\drivers +%MAKE% -fdevice.mak clobber + +cd ..\boot +%MAKE% -fboot.mak clobber + +cd ..\sys +%MAKE% -fbin2c.mak clobber +%MAKE% -fsys.mak clobber + +cd ..\kernel +%MAKE% -fkernel.mak clobber + +cd ..\hdr +del *.bak + +cd .. + +del *.bak +del status.me + +:end +set MAKE= diff --git a/config.b b/config.b new file mode 100644 index 00000000..3f5bf681 --- /dev/null +++ b/config.b @@ -0,0 +1 @@ +set MAKE=c:\tc201\make diff --git a/config.m b/config.m new file mode 100644 index 00000000..7769c8db --- /dev/null +++ b/config.m @@ -0,0 +1,63 @@ +# +# makefile that is included in all other makefiles for configuration +# + +################################################################ +# NOTICE! You must edit and rename this file to CONFIG.MAK! # +################################################################ + +# These are generic definitions +RM=..\utils\rm -f +NASM=nasm + + +# Use these for Turbo C 2.01 +#COMPILER=TC2 +#COMPILERPATH=c:\tc201 +#CC=$(COMPILERPATH)\tcc +#LINK=$(COMPILERPATH)\tlink +#LIBUTIL=$(COMPILERPATH)\tlib +#LIBPATH=$(COMPILERPATH)\lib +#CLIB=$(COMPILERPATH)\lib\cs.lib +#INCLUDEPATH=$(COMPILERPATH)\include + + +# Use these for Turbo C 3.0 +#COMPILER=TC3 +#COMPILERPATH=c:\tc +#CC=$(COMPILERPATH)\bin\tcc +#LINK=$(COMPILERPATH)\bin\tlink +#LIBUTIL=$(COMPILERPATH)\bin\tlib +#LIBPATH=$(COMPILERPATH)\lib +#CLIB=$(COMPILERPATH)\lib\cs.lib +#INCLUDEPATH=$(COMPILERPATH)\include + + +# Use these for Borland C++ +#COMPILER=BC5 +#COMPILERPATH=c:\bc5 +#CC=$(COMPILERPATH)\bin\tcc +#LINK=$(COMPILERPATH)\bin\tlink +#LIBUTIL=$(COMPILERPATH)\bin\tlib +#LIBPATH=$(COMPILERPATH)\lib +#CLIB=$(COMPILERPATH)\lib\cs.lib +#INCLUDEPATH=$(COMPILERPATH)\include + + +# +# $Id$ +# +# $Log$ +# Revision 1.1 2000/05/06 19:34:02 jhall1 +# Initial revision +# +# Revision 1.3 1999/09/13 20:40:17 jprice +# Added COMPILER variable +# +# Revision 1.2 1999/08/25 03:59:14 jprice +# New build batch files. +# +# Revision 1.1 1999/08/25 03:20:39 jprice +# ror4 patches to allow TC 2.01 compile. +# +# diff --git a/docs/bugs.txt b/docs/bugs.txt new file mode 100644 index 00000000..c44f37e7 --- /dev/null +++ b/docs/bugs.txt @@ -0,0 +1,6 @@ +The current bug database is available on the web at + +http://www.gcfl.net/bugs/kernel + +Send bug reports to kernel-bugs@gcfl.net. + diff --git a/docs/build.txt b/docs/build.txt new file mode 100644 index 00000000..837b534a --- /dev/null +++ b/docs/build.txt @@ -0,0 +1,78 @@ +To build the operating system, a batch file (BUILD.BAT) is included +to make life easier. This file is in the FDKERNEL directory of the +distribution. In addition, there is a corresponding batch file +(CLEAN.BAT) to clean up the source directories. + +There is a CONFIG.M file that specifies all the paths and names of +the compiler, assembler, etc. that you want to use. You MUST copy +it to CONFIG.MAK first, then edit it to reflect your setup. + +Likewise, there is a CONFIG.B file that should be copied to +CONFIG.BAT, and then edited to reflect your setup. + +The reason for this copying of files is that when new releases of the +kernel come out, you can extract them over your previous source, and +not have to worry about resetting up your configuration because your +CONFIG.BAT and CONFIG.MAK files will not get replaced! + +You will also need to download the latest version of NASM (a mirror +is at ftp://ftp.gcfl.net/freedos/nasm) and Turbo C 2.01 (a mirror is +at ftp://ftp.gcfl.net/freedos/tools/borland/tc201.zip). Install +Turbo C and NASM somewhere (it doesn't really matter where) and then +be sure to edit the CONFIG.MAK file to reflect where you put the +tools. + +This program will now compile with Turbo C 2.01 (now freely +available!), Turbo C 3.0, Borland C 4.51 & 5.01. It should work with +other Borland compilers as well. + +If you feel hardy, read on to understand the directory structure. A +more complete description of the build environment is contained in a +companion book, "The FreeDOS Kernel" (ISBN: 0-87930-436-7) published +by R&D Books, an imprint of Miller Freeman of Lawrence, Kansas (USA) +and distributed in the USA and Canada by Publishers Group West. See +the file README.TXT for more details. + + +Directory Structure +------------------- + +fdkernel root directory + +-----bin holds image of distribution disk + +-----boot boot.bin (boot sector) + +-----docs documentation directory + +-----drivers DEVICE.LIB + +-----hdr common *.h files + +-----kernel The kernel itself + +-----lib LIBM.LIB and DEVICE.LIB + +-----sys SYS.COM and supporting programs + +-----utils Miscellaneous utilities + + +Organization in a nutshell +-------------------------- +Each component or group of utilities is segregated into its own +directory. In order to build that component or utility, a makefile +exists in the directory that bears the component's or utility's +basename. + +Each makefile has at least two targets, production and clean. The +target production builds the expected component or utility and the +component clean cleans up the directory for distribution. The +makefile may have at least one additional target that builds the +component. Study the makefile to better understand this. + +--------------------------------------------------------------------- + +$Id$ + +$Log$ +Revision 1.1 2000/05/06 19:34:38 jhall1 +Initial revision + +Revision 1.2 1999/08/25 04:12:31 jprice +update + +Revision 1.1 1999/08/25 03:46:41 jprice +New build config + diff --git a/docs/contrib.txt b/docs/contrib.txt new file mode 100644 index 00000000..fa35655e --- /dev/null +++ b/docs/contrib.txt @@ -0,0 +1,17 @@ +These are the know contributors of the FreeDOS kernel. If you have +contributed in any way to the kernel, but are not on this list, +please email me at linux-guru@gcfl.net so I can add you to the list! + +Thanx to all the following for contributing to the FreeDOS kernel: + +ror4 (ror4@angelfire.com) +Steffen Kaiser (Steffen.Kaiser@fh-rhein-sieg.de) +Charles Dye (raster@highfiber.com) +John Price (linux-guru@gcfl.net) +Steve Miller (SMiller@dsfx.com) +Jens Horstmeier (Jens.Horstmeier@Abg1.SIEMENS.DE) +James Tabor (jimtabor@infohwy.com) + +And last, but not least, a big thanx to Pasquale J. Villani +(patv@iop.com), who was the original author of DOS-C, in which the +FreeDOS kernel was based. diff --git a/docs/copying b/docs/copying new file mode 100644 index 00000000..b8cf3a1a --- /dev/null +++ b/docs/copying @@ -0,0 +1,339 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 675 Mass Ave, Cambridge, MA 02139, USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + Appendix: How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) 19yy + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) 19yy name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Library General +Public License instead of this License. diff --git a/docs/history.txt b/docs/history.txt new file mode 100644 index 00000000..ab82ce1f --- /dev/null +++ b/docs/history.txt @@ -0,0 +1,543 @@ +2000 Mar 09 - Build 2018 +-------- James Tabor (jimtabor@infohwy.com) +Added CDS and made FD CDS based. Changes encompass all of the + code for FD. +Fixed Task.c, rewritten code from FINODE to SFT function calls. + Unable to execute from CD. Main.c and Config.c has small + changes. +Fixed Device drivers are unable to write to con. Rewritten code to + relocate DOS_PSP pointer to 050:0000. Removed references to + DOS_PSP in DosFns.c. +Added Network and Redirection function calls in Inthndlr.c and + network.c. + +I have a note in FatFs.c line 313, describing functions not yet +supported for networking. I don't understand Pats thoughts on SFT to +FINODE. IMHO it would have been easier to stay with SFT all through +the code. + +I tested MS-Dos 6.22 Command and found it unable to do Find First or +Next. This too could explain why MSCDEX does the same thing. I only +test this with the current FDCommand at the time, so this could have +changed. + +1999 Sep 24 - Build 2017 +-------- John Price (linux-guru@gcfl.net) +* Per Jens Horstmeier's email, changed boot sector code to make + Siemens CDROM's bootable. The changes should be OK for all other + machines too (in theory). + +1999 Sep 22 - Build 2016 +-------- John Price (linux-guru@gcfl.net) +* Turned off debug output from the kernel. It does not seem to be + necessary at this time. +* Changed boot sector to do single-sector reads instead of + multi-sector reads. Appearantly this was part of the reason the + kernel would not boot from a 720K, or other format floppies. Thanx + to Charles Dye for the info. + +1999 Sep 16 - Build 2016 +-------- James Tabor (jimtabor@infohwy.com) +* Added Networking and Server Call +* Added Dos Idle call +* fixed Console.asm ConInStat + +1999 Sep 13 - Build 2014 +-------- John Price (linux-guru@gcfl.net) +* Deleted some files from the drivers directory that were not being + used. +* Changed the LIB.MAK file so it would work for TC2 or TC3 or higher. +* Changed SYS.COM so that it creates a sys.log file with more debug + information to help debug problems with making boot disks. + +1999 Sep 13 - Build 2014 +-------- James Tabor (jimtabor@infohwy.com) +* Submitted changes to CONSOLE.ASM & INTHNDLR.ASM to fix the INT21 + func 0B bug. + +1999 Sep 13 - Build 2014 +-------- Helmut Fritsch (helmut.fritsch@gcd-hs.de) +* Submitted changes to CONSOLE.ASM to fix the INT21 func 0B bug. + +1999 Sep 10 - Build 2014 +-------- ror4 (f2xm1@crosswinds.net) +* At the suggestion of Mr John Price, modified the int 0x25 and int + 0x26 so that they no longer update the disk buffers (int 0x26 only + invalidates the buffers for the specified drive). This is to avoid + inconsistent disk buffers from appearing in the buffer chain due to + interactions between int 0x25/0x26 and file read/write operations. + +1999 Aug 24 - Build 2013 +-------- John Price (linux-guru@gcfl.net) +* With ideas from ror4, I redid the build batch file so you can + specify where what make to use. +* Also created CONFIG.M and CONFIG.B which should be copied to + CONFIG.MAK and CONFIG.BAT, respecively, and edited to reflect the + users configuration. This keeps new versions from replacing the + configuration files so the user does not have to keep reseting + their configutation. + +1999 Aug 15 - Build 2013 +-------- ror4 (ror4@angelfire.com) +* Patched the source so that it can be compiled with Turbo C 2.01. + (`asm' statements were rewritten into very ugly equivalents... they + probably need more work. :( ) +* Modified the `dmatch' structure in `hdr/dirmatch.h' so that the + `dm_dirstart' field is in the right place, and also to make it + compile under TC 2.01, which doesn't allow bit fields of any types + other than signed or unsigned int. +* Fixed a few minor bugs in error code returning in `kernel/fatfs.c'. + +1999 Jul 16 - Build 2012 +-------- ror4 (ror4@iname.com) +* Finally ported all the assembly modules to `nasm'. *phew* +* Undid plonee's patches to `kernel/fatfs.c' (sorry). They were + causing the resulting findfirst/findnext DTA structures to be + incompatible with MSDOS's. +* Also rewrote all the pattern copying code in `dos_findfirst' in + `kernel/fatdir.c' to prevent a bad buffer overflow problem. +* Modified the disk buffer handling code, so that logical sector + numbers in disk buffers are now 0-based instead of 1-based. +* int 0x25 and int 0x26 now do multi-sector reads/writes. + +1999 Jul 14 - Build 2012 +-------- ror4 (ror4@iname.com) +* Ported the modules in the `drivers/' branch to `nasm'. + +1999 May 04 - Build 2011 +-------- ror4 (ror4@cryogen.com) +* Fixed the code for converting day numbers into Julian calendar + dates: the first and last days of each month are now returned + correctly. +* Undid a change to the code to get the day of the week. + +1999 May 02 - Build 2011 +-------- John Price (linux-guru@gcfl.net) +* blockio.c: changed getblock and getbuf so that they leave at least + 3 FAT type buffers valid. This helps because the FAT is accessed + very often compared to other sectors. +* fatfs.c: Fixed a bug in map_cluster so it will optimize FAT reads + on disks that have more than one sector per cluster. This + sigificantly improved disk access of big files on hard drives. + +1999 May 02 - Build 2011 +-------- ror4 (ror4@cryogen.com) +* Corrected the `struct buffer' definition in `kernel/globals.h' so + that it corresponds exactly to Ralf Brown's description of a DOS 3.x + buffer. +* Also fixed the problem with FATs > 255 sectors, by making use of an + originally unused field in the buffer structure. + +1999 May 01 - Build 2011 +-------- ror4 (ror4@cryogen.com) +* Fixed a problem which caused disk corruption on partitions with + FATs larger than 127 sectors. (However, FATs larger than 255 + sectors may still experience problems -- this is due to a + limitation of the DOS 3.x buffering scheme.) +* Fixed a bug in the handling of the `stacks=' command in + `(fd)config.sys' which caused the system to behave strangely. + +1999 Apr 22 - Build 2011 +-------- Steffen Kaiser (Steffen.Kaiser@fh-rhein-sieg.de) +bugfix: memmgr.c: Invalid returned largest size in MemLargest() +fix: memmgr.c: DosMemLargest: change prototype to match its useage +bugfix: inthdlr.c: 0x49: ES is decremented +fix: inthdlr.c: 0x00: DosMemCheck() does nothing --> added panic() +fix: inthdlr.c: 0x4c: DosMemCheck() does nothing --> added panic() +fix: inthdlr.c: 0x00: changed to make it the same as DOS-4C-00 + Both actions differed e.g. in ErrorMode +chg: memmgr.c: the 'name' field of the MCB is never initialized by + DOS-48, DOS-49 or DOS-4A. Leave this to the program loading function. +bugfix: memmgr.c: adjust_far() / add_far(): + Both function together (and the way they are used) don't make sense: + adjust_far() normalizes a far pointer, add_far() generates a linear + address. Usually both are used this way: + far_poi = adjust_far(far_poi); + while(...) { + ... + far_poi = add_far(far_poi, uword); + ... + } + First one makes sure that 'far_poi' is normalized, then far_poi + becomes a linear address, which makes it very difficult to use + it, because the possibility to get a segment warp gets very high. + --> + Change: add_far() also returns a normalized real mode pointer + as adjust_far() does. + Probably in DOS-C supporting various architecures thee functions + served other duties, but the current useage is highly dangerous. +bugfix: task.c: ChildEnv(): nEnvSize didn't counted the last '\0' +bugfix: task.c: ChildEnv(): Allocation: maximum absolute filename to + short and forgot the word counter +bugfix: task.c: ChildEnv(): for very corrupt environments, the + copy function failed. +bugfix: task.c: DosExeLoader(): If exe_size > allocated_size or + DosMemLargest() failes, the environment is not deallocated +bugfix: task.c: DosExeLoader(): Calculating the exe_size to be + allocated. At both places (+ header.exMinAlloc & ...MaxAlloc) + sizeof(psp) is added to exe_size. Why? image_size already + contains sizeof(psp). +chg: task.c: DosExeLoader()/DosComLoader(): MCB patching and command + line copying is no outside of those functions +chg: asmsupt.asm: _fbcopy: re-use parts of _bcopy +add: asmsupt.asm: fmemset, fmemclr, fmemclra {Replace the explicit + for() loops} + +1999 Apr 22 - Build 2011 +-------- ror4 (ror4@cryogen.com) +* Ported boot.asm to NASM. The plan is to port all assembly to NASM + over time. + +1999 Apr 19 - Build 2010 +-------- John Price (linux-guru@gcfl.net) +* Undid the change I made to getblock below because it DID NOT speed +anything up, and in fact slowed access down. + +1999 Apr 18 - Build 2009 +-------- John Price (linux-guru@gcfl.net) +* change getblock so that it flushes all buffers for a drive when it + has to flush one of them to make room. This should speed disk + access slightly. +* Change the boot sector so there is a compile-time option to use + multi-sector IO or single-sector IO. The default is multi since + ror4 seemed to have fixed the problem we had before. + +1999 Apr 18 - Build 2009 +-------- ror4 (ror4@cryogen.com) +* The boot sector can now load the kernel properly from a hard disk. +* Other minor changes. + +1999 Apr 16 - Build 2008 +-------- ror4 (ror4@cryogen.com) +* Modified the block device driver to prepare it for multi-sector I/O + support. Among other things, the driver can now handle transfer + buffers which cross DMA boundaries. +* Some other minor changes. + +1999 Apr 15 - Build 2008 +-------- John Price (linux-guru@gcfl.net) +* Changed mainly the map_cluster function in fatfs.c so that instead + of starting at the beginning of the FAT chain every time, it will + be smart about it, and start at the last FAT location that it was + before if it can. This speeds up disk access considerably + especially on slower machines. + +1999 Apr 15 - Build 2008 +-------- Steffen Kaiser (Steffen.Kaiser@fh-rhein-sieg.de) +bugfix: ^Break handler according cmt1.txt +bugfix: DosCreat(): Detection for Devices and extension: + the semi-colon behind if(*froot) is definitely wrong, whether + one wants CON.EXT to be interpreted as CON or not. +bugfix: DosOpen(): dito + +* Re-implementation of ^Break handler -- 1999/03/27 ska + + Warning: The handle_break() function assumes that the InDOS flag + was incremented (except if ErrorMode is true). Never call + handle_break() unless the InDOS flag has been incremented within + this reentrant call of DOS. + + + ^Break is detected and handled at certain places within the + kernel only: a) within the CON: device when reading or writing a + character, and b) when entering the INT-21 service (if extended + break checking is enabled). At these places the process flow can + be modified to: either a) redo the interrupted function or b) abort + the currently running process. + + + Both actions are performed by switching back to the user stack + and enter INT-21 handler again. If to terminate the program, AX is + modified into 4C00h. + + + By default, if the user has no ^Break handler installed, the + program is terminated. + + + Heavy change: The original implementation installed an unique + INT-23 handler that directly called the actions performed + DOS-4C-XX. In fact, this was identically with when the user had an + own handler installed and returned the Carry flag set, except that + it was somewhat quicker, because the kernel need not decode the + 4C00h command. Now the Carry flag is set prior the call of INT-23, + so the default action is to terminate the program. + + + Note: INT-23 is called with all registers as they are passed to + the INT-21 entry. When they are modified, they are passed + _modified_ to the API interpreter. This also allows the DOS1-style + termination by to load register AH with 0 (zero). + + + RBIL says: + "any DOS call may safely be made within the INT 23 handler, + although the handler must check for a recursive invocation if it + does call DOS" + This can be interpreted so or so, the problem is that the user can + call DOS again, what would overwrite the saved _usr_stack pointer + with a different value and, therefore, cannot be used to check if + INT-23 was returned by RETF or RETF2/IRET. + + Because a recursive invokation of INT-23 is to prevented by the + user, the kernel could internally save SP to somewhere else. + However: + a) where? + b) is it reliable that the user ever returns from INT-23 at all? + + The implemented method uses the same mechanism as fail-safe intr() + function is implemented: A little piece of code is constructed + within the stack, which contains the value of SP as an operand of + an immediate MOV instruction. + + +1999 Apr 13 - Build 2007 +-------- ror4 (ror4@cryogen.com) +* The boot sector now moves itself to the last 512 bytes of + conventional memory instead of a lower memory location. +* The kernel startup code has also been modified so that it works + with the new boot sector. + +1999 Apr 12 - Build 2007 +-------- ror4 (ror4@cryogen.com) +* The directory scanning functions (`findfirst'/`findnext') now also + recognize more flavours of the volume label attribute byte (namely + 0x09, 0x28 and 0x29). +* Subdirectories are now no longer assumed to have the same size as + the root directory. +* `device/device.lib' is now included as a dependency in the kernel + makefile. +* Removed several unused assembler modules from the `device/' branch + (see `device/device.mak'). + +1999 Apr 11 - Build 2007 +-------- ror4 (ror4@cryogen.com) +* The kernel now reads times from the system clock (0x40:0x6c) + instead of the RTC. The RTC is only used during startup to + initialize the system clock. (As a side effect of this, + `ReadATClock' has been moved from `_TEXT' to `INIT_TEXT'.) +* Checking for leap years is now improved -- year numbers which are + divisible by 100 but not by 400 are not counted as leap years. (Not + that it matters for year 2000, though.) +* The scaling factor used to convert the system time count to a + second count has been changed from 18.2 to the more accurate (?) + 19663/1080. +* Day numbers used by `clock$' are now 0-based (as in MSDOS) instead + of 1-based. Thus 1 Jan 1980 is now day number 0. + +1999 Apr 10 - Build 2007 +-------- ror4 (ror4@cryogen.com) +* Added code to prevent the kernel from returning path names + containing double backslashes. + +1999 Apr 9 - Build 2007 +-------- ror4 (ror4@usa.net) +* File handles are now cloned properly when a child process is spawned. +* The `DosClose' function now also frees SFT entries corresponding to + devices, not only those entries corresponding to files. +* Removed a (minor) memory corruption bug in the code for int 0x21, + ah = 0x09. + +1999 Apr 6 - Build 2007 +-------- ror4 (ror4@cryogen.com) +* Functions ax = 0x5700 and 0x5701 (get/set file date and time) now + return the right values at the right times. (They used to return + success when there's an error, and return error when there's a + success.) +* Removed the `/k' switch to the linker in `sys/sys.mak'. + +1999 Apr 4 - Build 2006 +-------- John Price (linux-guru@gcfl.net) +* added "version=" directive so that you can change the version that + the kernel reports. Usage: version=. (i.e. + version=6.22) + +1999 Apr 4 - Build 2006 +-------- ror4 (ror4@usa.net) +* Fixed the file name parsing function (`ParseDosNames') so that it + handles single-character path names correctly. +* Also modified the functions which call `ParseDosNames' to check its + return value instead of assuming that it is always successful. + (This is not currentl useful, but it will be when error checking is + introduced into `ParseDosNames'. In other words, there'll be more + changes to `ParseDosNames' in the near future...) + +* After wondering for a long time why the kernel text segment was + always getting corrupted when I ran DJGPP `bash' 1.14.7, I finally + decided to examine the code occurring before the handler for int + 0x21, ah = 0x60, and I found out why... :) +* Fixed the problem of int 0x21, ax = 0x5d06 causing memory + corruption. +* Corrected the types of `internal_data', `swap_always' and + `swap_indos' in `kernel/globals.h'. + +* Improved checking for invalid file names in `ParseDosName' + (although I'm still not sure whether the check is water-tight or + not). +* Changed the default path setting from `PATH=' to `PATH=.'. + +* Output from character I/O functions now goes to standard output as + it should, instead of the console. Also, there's now a clear + distinction between console input/output and standard input/output. +* Tabs are now expanded during writes to the console device. +* Removed a hard-wired limit on the number of entries in a JFT. + (Although I'm not sure whether this is really correct...) +* Many other changes to the file descriptor handling code. + +1999 Mar 29 - Build 2006 +-------- John Price (linux-guru@gcfl.net) +* Changed boot loader so it prints some feedback info while booting. + Removed code to handle FAT12 and FAT16, and code to calculate the + start of the fat, rootdir, and data. Moved these functions into + the sys command. Now there are two versions of the boot loader + created, one to handle FAT16, and one for FAT12. These are + hard-coded into the sys command, so the need for the boot.bin file + is obsolete. +* created a new program (bin2c) to convert the boot loader binary + file into a header file that can be included in the sys program as + an array of bytes. + +1999 Mar 29 - Build 2006 +-------- ror4 (ror4@usa.net) +* Changed the class of `_BSSEND' from "STACK" to "BSS" in the + `drivers/' branch (which I forgot about in my last patch). +* Removed all traces of the `CONST' segment, since it was causing + `IGROUP' to be assimilated into `DGROUP', which shouldn't happen. +* Added a `(void)' cast to the `setvec' macro in `kernel/globals.h' + (`setvec' no longer returns the original ISR vector). +* Changed an incorrect error message in `sys/sys.c'. +* Removed `drivers/setvec.asm', since it's no longer needed. +* Also removed `kernel/krnstart'. +* The name field in a process's MCB is now filled in the same manner + as in MSDOS -- instead of being padded to the right with spaces, it + is now terminated with '\0'. Also, if the original file name + doesn't have an extension, the code will stop copying the file name + at '\0' instead of continuing to look for a '.'. +* Fixed the problem of the `switchar' syscall (int 0x21, ax = 0x3700) not + returning the correct value. + + +1999 Mar 28 - Build 2005 +-------- ror4 (ror4@usa.net) +* Removed the need for `ipl.sys'. (!) The kernel makefile now + statically relocates `kernel.exe' to 0x60:0 and outputs the + resulting binary to `kernel.sys', and the boot sector has also been + modified to load `kernel.sys' at 0x60:0 instead of `ipl.sys' at + 0x2000:0. (I chose 0x60:0 because it's the first 512-byte boundary + occurring after the BIOS data area, 0x40:0.) Finally, `sys.com' has + also been updated. + +* Also changed the boot sector code in some other ways. In + particular, because `kernel.sys' is rather large, I had to add some + code to move the boot sector away from 0:0x7c00 to somewhere + higher. (For 640K systems the boot sector will be shifted to + 0x6000:0x7c00. However, there may be problems on systems with very + little conventional memory -- I'll probably look into this later.) + +* Made some minor changes to the assembler source files so that they + can compile on `masm'. (JP: The code still compiles fine with tasm + too). + +* Also changed several incorrect label references in the assembler + sources. (JP: These changes fixed the "Fixup" errors we been + talking about in the list) + +* Eliminated redundant re-makes of files in the various makefiles. + For one thing, `*.cfg' files are no longer generated from the + makefiles, but are independent from them. (I didn't like the idea + of having to compile an entire branch each time I edit a + makefile...) Also, intermediate files are now retained instead of + deleted. + +* Also made some changes to `build.bat' (you'll know them when you + see them). + +* Added a file `lib/libm.mak' + +* Added a file `kernel/krnstart + +* The code required to initialize the kernel (or rather most of it) + is no longer retained in memory after the initialization process is + done. I accomplished this by moving most of the initialization code + from `_TEXT' to a new segment named `INIT_TEXT'. Of course, I also + had to introduce lots of other changes in order for everything to + compile and run properly: + - Added code to `kernel/src/kernel/kernel.asm' to move the contents + of `INIT_TEXT' to the top of conventional memory and continue + from there. Control is only transferred back to `_TEXT' when the + kernel calls `p_0'. + - Many functions are called from both `_TEXT' and `INIT_TEXT'. To + fix this, I created far wrappers for these functions which can + then be called from `INIT_TEXT'. (E.g. for `execrh' there's a + corresponding far function named `init_call_execrh' which simply + calls `execrh' with its own parameters.) One exception to this is + `printf' -- instead of creating a far wrapper for a near + `printf', I created a near wrapper for a far `printf' (now called + `init_call_printf'), because it was easier that way. :) + - Most functions which are required only during initialization time + were shifted into `INIT_TEXT'. (There are still some functions + which should rightfully go into `INIT_TEXT', but are retained in + `_TEXT' as far functions, because I found it too difficult to + move them out. :( ) Because Turbo C only allows at most one code + segment to be defined for each module, I had to shift some + functions around within the source tree -- the file + `kernel/src/kernel/proto.h' says it all. + - A cosmetic change mentioned here for completeness: all functions + defined in `INIT_TEXT' are now marked with the word `INIT' (in + fact a null macro) so that the reader can easily distinguish them + from functions defined in `_TEXT'. + +* Replaced `exit' calls with `for (;;);'. + +* Changed `strcpy' into a macro which calls `scopy'. + +* Also redefined `setvec' to be a macro (I didn't want to waste time + writing a far wrapper for it). + +* Removed the `break_key' function in `kernel/src/kernel/kernel.asm'. + +* `low_int25_handler' and `low_int26_handler' are now of type + `void interrupt far()' instead of `void near()'. (I hope I updated + `entry.asm' correctly -- I never tested `int 0x25' and `int 0x26'...) + +* Changed the class of `_BSSEND' from "STACK" to "BSS" -- "STACK" is + now used for a separate stack segment (`_STACK'). + +* Assembler modules now include `segs.inc' instead of having their + own long list of segment definitions. (Some day I'll update the + makefile dependencies to reflect this.) + +* Also made a few minor changes to the assembler modules so that + `masm' won't complain. + +* Changed the `-X' switch in `kernel.cfg' to `-X-', so that I don't + have to worry about C module dependencies. + +* Removed the definition of `CFLAGS' from the makefile -- everything + is now in `kernel.cfg'. + +* Created a file `kernel/src/kernel/init-mod.h' which is included by + modules whose code is supposed to go into `INIT_TEXT' instead of + `TEXT'. + +* This diff solves the problem of the MCB of a process not having a + correct value in its name field (bug report #6). + (The definition of the `toupper' macro is because I shifted the + `toupper' function into `INIT_TEXT' a while ago, and therefore + can't be called from `_TEXT' now...) + + +-------- John Price (linux-guru@gcfl.net) +* Made changes so you can create a directory with the same name as a + volume label, but you still can't rename or delete it! + +* Fix findfirst and findnext functions so that act as they should. + (i.e. If the attrib has only the volume label set, then it returns + the volume label entry in the root directory, else it returns the + files/directories that are specified with the attrib, ignoring the + read-only and archive bits (these are always returned). + +* reorginize the source tree. Removed IPL directory, and command. + Moved all the file system C files into the kernel directory. + Modifed build.bat, clean.bat, and all the make files to reflect the + new tree. + +* changed so that kernel will look for a "fdconfig.sys" file, and use + it INSTEAD of config.sys. If it does not find it, it will look + for, and read config.sys, if it exists. + +* Fixed so that if you call an INT 21 function with AH containing a + unsupported function, the carry flag is set. diff --git a/docs/intfns.txt b/docs/intfns.txt new file mode 100644 index 00000000..579e3f32 --- /dev/null +++ b/docs/intfns.txt @@ -0,0 +1,209 @@ + Technical Data + DOS-C Systems Calls + +The following table represents the industry standard kernel DOS calls +currently supported by DOS-C. This list is for Release 1.1, build +2003 as issued on Feb 28, 1999. + +int 20: Terminated Current Process + Supported + +int 21: DOS System Call + Supported. See table below. + +int 21 Description State Ver Status +--------------------------------------------------------------------------- +00h Terminate Program superseded 1.00 supported +01h Read Keyboard with Echo superseded 1.00 supported +02h Display Character superseded 1.00 supported +03h Auxilliary Input superseded 1.00 Note 1 +04h Auxilliary Output superseded 1.00 Note 1 +05h Print Character superseded 1.00 Note 1 +06h Direct Console I/O active 1.00 supported +07h Direct Console Input active 1.00 supported +08h Read Keyboard Without Echo active 1.00 supported +09h Display String superseded 1.00 supported +0ah Buffered Keyboard Input superseded 1.00 supported +0bh Check Keyboard Status active 1.00 supported +0ch Flush Buffer, Read Keyboard active 1.00 supported +0dh Reset Drive active 1.00 supported +0eh Set Default Drive active 1.00 supported +0fh Open File with FCB superseded 1.00 supported +10h Close File with FCB superseded 1.00 supported +11h Find First File with FCB superseded 1.00 supported +12h Find Next File with FCB superseded 1.00 supported +13h Delete File with FCB superseded 1.00 supported +14h Sequential Read superseded 1.00 supported +15h Sequential Write superseded 1.00 supported +16h Create File with FCB superseded 1.00 supported +17h Rename File with FCB superseded 1.00 supported +18h CP/M compatibility obsolete 1.00 supported +19h Get Default Drive active 1.00 supported +1ah Set Disk Transfer Address active 1.00 supported +1bh Get Default Drive Data superseded 2.00 supported +1ch Get Drive Data superseded 2.00 supported +1dh CP/M compatibility obsolete 1.00 supported +1eh CP/M compatibility obsolete 1.00 supported +1fh Get Default DPB active 5.00 Note 2 +20h CP/M compatibility obsolete 1.00 supported +21h Random Read superseded 1.00 supported +22h Random Write superseded 1.00 supported +23h Get File Size superseded 1.00 supported +24h Set Random Record Number superseded 1.00 supported +25h Set Interrupt Vector active 1.00 supported +26h Create New PSP superseded 1.00 supported +27h Random Block Read superseded 1.00 supported +28h Random Block Write superseded 1.00 supported +29h Parse Filename active 1.00 supported +2ah Get Date active 1.00 supported +2bh Set Date active 1.00 supported +2ch Get Time active 1.00 supported +2dh Set Time active 1.00 supported +2eh Set/Reset Verify Flag active 1.00 supported +2fh Get DTA active 2.00 supported +30h Get Version Number active 2.00 supported +31h Keep Program active 2.00 supported +32h Get DPB active 5.00 Note 2 +3300h Get CTRL+C Check Flag active 2.00 supported +3301h Set CTRL+C Check Flag active 2.00 supported +3305h Get Startup Drive active 2.00 supported +3306h Get MS-DOS Version active 5.00 supported +33ffh Get DOS-C Release superset supported +34h Get InDOS Flag Address active 2.00 supported +35h Get Interrupt Vector active 2.00 supported +36h Get Disk Free Space active 2.00 supported +37h Get/Set Switchar undocumented 2.00 supported +38h Get/Set Country Information active 2.00 supported +39h Create Directory active 2.00 supported +3ah Remove Directory active 2.00 supported +3bh Change Current Directory active 2.00 supported +3ch Create File with Handle active 2.00 supported +3dh Open File with Handle active 2.00 supported +3eh Close File with Handle active 2.00 supported +3fh Read File or Device active 2.00 supported +40h Write File or Device active 2.00 supported +41h Delete File active 2.00 supported +42h Move File Pointer active 2.00 supported +4300h Get File Attributes active 2.00 supported +4301h Set File Attributes active 2.00 supported +44h Ioctl entry active 2.00 supported +45h Duplicate File Handle active 2.00 supported +46h Force Duplicate File Handle active 2.00 supported +47h Get Current Directory active 2.00 supported +48h Allocate Memory active 2.00 supported +49h Free Allocated Memory active 2.00 supported +4ah Set Memory Block Size active 2.00 supported +4b00h Load and Execute Program active 2.00 supported +4b01h Load Program active 5.00 supported +4b03h Load Overlay active 2.00 supported +4b05h Set Execution State active 5.00 planned +4ch End Program active 2.00 supported +4dh Get Child-Program Return Value active 2.00 supported +4eh Find First File active 2.00 supported +4fh Find Next File active 2.00 supported +50h Set PSP Address active 2.00 supported +51h Get PSP Address active 2.00 supported +52h Get List of Lists undocumented 2.00 supported +53h undocumented not supported +54h Get Verify State active 2.00 supported +55h Create New Psp undocumented 2.00 supported +56h Rename File active 2.00 supported +5700h Get File Date and Time active 2.00 supported +5701h Set File Date and Time active 2.00 supported +5800h Get Allocation Strategy active 3.00 supported +5801h Set Allocation Strategy active 3.00 supported +5802h Get Upper-Memory Link active 5.00 planned +5803h Set Upper-Memory Link active 5.00 planned +59h Get Extended Error active 3.00 planned +5ah Create Temporary File active 3.00 +5bh Create New File active 3.00 +5ch Lock/Unlock File active 3.10 planned +5d00h Server Function Call active 3.10 planned +5d01h Commit All Files active 3.10 planned +5d02h Close File by Name active 3.10 planned +5d03h Close All Files for Computer active 3.10 planned +5d04h Close All Files for Process active 3.10 planned +5d05h Get Open File List active 3.10 planned +5d06h Get Multiple SDA active 4.00 supported +5d07h Get Redirected Printer Mode active 3.10 planned +5d08h Set Redirected Printer Mode active 4.00 planned +5d09h Flush Redirected Printer Output active 4.00 planned +5d0ah Set Extended Error active 4.00 planned +5eh Generic Network Functions #1 active 3.10 planned +5fh Generic Network Functions #2 active 3.10 planned +60h Truename function undocumented 3.00 supported +61h UNUSED obsolete supported +62h Get current PSP active 3.00 supported +63h Multibyte char ops undocumented 3.20 Note 4 +64h ? undocumented returns error +65h NLS Functions active 3.30 supported +66h Code Page Functions active 3.30 supported +67h Set Maximum Handle Count active 3.30 supported +68h Commit File active 3.30 dummy func +69h GET/SET DISK SERIAL NUMBER active 4.00 not supported +6ah COMMIT FILE (same as 68h) active 4.00 not supported +6bh NULL FUNCTION active 5.00 not supported +6ch Extended Open/Create active 4.00 not supported +71h LONG FILENAME FUNCTIONS active 7.00 not supported + +int 22: Program Termination Address. + Supported. + +int 23: Ctrl-C/Ctrl_Break Handler. + Supported. + +int 24: Critical Error Handler + Dummy routine default. + +int 25: Absolute Disk Read + Supported. + +int 26: Absolute Disk Write + Supported. + +int 27: TSR + Supported. + +int 28: DOS Idle. + Note 5. + +int 29: Fast Console Output. + Supported. + +int 2F: DOS Multiplex. + Supported. + +Notes: +Note 1 - Although this system call is supported, there are no device +drivers to support these devices in this release. + +Note 2 - Returns error code because internal data structures differ. + +Note 3 - Only sub-functions 0 and 1 are currently supported. + +Note 4 - Returns error code. + +Note 5 - Vector supported but performs no action. + +License +------- +See COPYING in DOS-C root directory for license. + + +--------------------------------------------------------------------- + +$Id$ + +$Log$ +Revision 1.1 2000/05/06 19:34:43 jhall1 +Initial revision + +Revision 1.1 1999/08/25 03:46:42 jprice +New build config + +Revision 1.1.1.1 1999/03/29 15:39:16 jprice +New version without IPL.SYS + +Revision 1.2 1999/03/02 06:55:51 jprice +Updated interrupt list + diff --git a/docs/mkboot.txt b/docs/mkboot.txt new file mode 100644 index 00000000..73be5d66 --- /dev/null +++ b/docs/mkboot.txt @@ -0,0 +1,11 @@ +To create a bootable floppy suitable for copying the system to +another drive: + +1. Change directory (if necessary) to where the FreeDOS Kernel BIN +directory. + +3. Enter the command "install" to transfer the system files to the +diskette in drive A. If you want to install on drive B, type +"install b:" + +4. Write protect this disk and use it to boot from. diff --git a/docs/readme.cvs b/docs/readme.cvs new file mode 100644 index 00000000..de51b310 --- /dev/null +++ b/docs/readme.cvs @@ -0,0 +1,15 @@ +You can check out the latest code (from a UNIX type machine) using +CVS as follows: + +cvs -d :pserver:guest@gcfl.net:/home/cvsroot login +Password: guest + +Then, to get the kernel code: +cvs -d :pserver:guest@gcfl.net:/home/cvsroot checkout fdkernel + +To get the FreeCom code: +cvs -d :pserver:guest@gcfl.net:/home/cvsroot checkout FreeCom + + +You can also view the CVS code from the web at +http://www.gcfl.net/cgi-bin/cvsweb diff --git a/drivers/devend.asm b/drivers/devend.asm new file mode 100644 index 00000000..0b890ed7 --- /dev/null +++ b/drivers/devend.asm @@ -0,0 +1,78 @@ +; +; File: +; devend.asm +; Description: +; get end of device driver primitive +; +; Copyright (c) 1995 +; Pasquale J. Villani +; All Rights Reserved +; +; This file is part of DOS-C. +; +; DOS-C is free software; you can redistribute it and/or +; modify it under the terms of the GNU General Public License +; as published by the Free Software Foundation; either version +; 2, or (at your option) any later version. +; +; DOS-C is distributed in the hope that it will be useful, but +; WITHOUT ANY WARRANTY; without even the implied warranty of +; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See +; the GNU General Public License for more details. +; +; You should have received a copy of the GNU General Public +; License along with DOS-C; see the file COPYING. If not, +; write to the Free Software Foundation, 675 Mass Ave, +; Cambridge, MA 02139, USA. +; +; $Logfile: C:/dos-c/src/drivers/devend.asv $ +; +; $Header$ +; +; $Log$ +; Revision 1.1 2000/05/06 19:34:43 jhall1 +; Initial revision +; +; Revision 1.3 1999/08/10 17:21:08 jprice +; ror4 2011-01 patch +; +; Revision 1.2 1999/03/29 17:08:31 jprice +; ror4 changes +; +; Revision 1.1.1.1 1999/03/29 15:40:22 jprice +; New version without IPL.SYS +; +; Revision 1.2 1999/01/22 04:16:39 jprice +; Formating +; +; Revision 1.1.1.1 1999/01/20 05:51:00 jprice +; Imported sources +; +; +; Rev 1.2 29 Aug 1996 13:07:14 patv +;Bug fixes for v0.91b +; +; Rev 1.1 01 Sep 1995 18:50:34 patv +;Initial GPL release. +; +; Rev 1.0 02 Jul 1995 7:56:50 patv +;Initial revision. +; + +group TGROUP _TEXT +group DGROUP _DATA + +segment _DATA align=2 class=DATA + extern last:wrt DGROUP + +segment _TEXT class=CODE + + global _device_end + +_device_end: + push bp + mov bp,sp + mov ax,last + mov dx,DGROUP + pop bp + ret diff --git a/drivers/device.mak b/drivers/device.mak new file mode 100644 index 00000000..0448248c --- /dev/null +++ b/drivers/device.mak @@ -0,0 +1,103 @@ +# +# makefile for device.lib +# +# $Id$ +# + +# $Log$ +# Revision 1.1 2000/05/06 19:34:43 jhall1 +# Initial revision +# +# Revision 1.6 1999/08/25 03:16:36 jprice +# ror4 patches to allow TC 2.01 compile. +# +# Revision 1.5 1999/08/10 17:21:08 jprice +# ror4 2011-01 patch +# +# Revision 1.4 1999/04/23 03:44:52 jprice +# Improved by jprice +# +# Revision 1.3 1999/04/13 15:47:07 jprice +# no message +# +# Revision 1.2 1999/03/29 17:08:31 jprice +# ror4 changes +# +# Revision 1.1.1.1 1999/03/29 15:40:23 jprice +# New version without IPL.SYS +# +# Revision 1.3 1999/02/09 04:49:25 jprice +# Make makefile use common config.mak file +# +# Revision 1.2 1999/01/22 04:16:39 jprice +# Formating +# +# Revision 1.1.1.1 1999/01/20 05:51:00 jprice +# Imported sources +# +# +# Rev 1.2 29 Aug 1996 13:07:12 patv +#Bug fixes for v0.91b +# +# Rev 1.1 19 Feb 1996 3:19:26 patv +#Added NLS, int2f and config.sys processing +# +# Rev 1.0 02 Jul 1995 7:54:52 patv +#Initial revision. +# + +!include "..\config.mak" + + +# MICROSOFT C +# ----------- +#MODEL = s +#CFLAGS = /c /Gs /A$(MODEL) +#AFLAGS = /Mx /Dmem$(MODEL)=1 +#TERM = ; + +# BORLAND C +# ----------- +MODEL = s +CFLAGS = -c -m$(MODEL) +AFLAGS = /Mx /Dmem$(MODEL)=1 +LIBFLAGS = /c +TERM = + +OBJS = devend.obj floppy.obj getvec.obj timer.obj rdpcclk.obj rdatclk.obj \ +wrpcclk.obj wratclk.obj + +LIBOBJS= +devend +floppy +getvec +timer +rdpcclk +rdatclk +wrpcclk +wratclk + + + +# Build the LIBRARY +# ----------------- +all: production + +production: ..\lib\device.lib + +..\lib\device.lib: device.lib + copy device.lib ..\lib + +clobber: clean + $(RM) device.lib status.me ..\lib\device.lib + +clean: + $(RM) *.obj *.bak *.crf *.xrf *.map *.lst + +device.lib : $(OBJS) + del device.lib + $(LIBUTIL) $(LIBFLAGS) device $(LIBOBJS) $(TERM) + + + +# RULES (DEPENDENCIES) +# ---------------- +.c.obj : + $(CC) $(CFLAGS) $< + +.asm.obj : + $(NASM) -f obj $< + + diff --git a/drivers/floppy.asm b/drivers/floppy.asm new file mode 100644 index 00000000..d4ea2aac --- /dev/null +++ b/drivers/floppy.asm @@ -0,0 +1,331 @@ +; +; File: +; floppy.asm +; Description: +; floppy disk driver primitives +; +; Copyright (c) 1995 +; Pasquale J. Villani +; All Rights Reserved +; +; This file is part of DOS-C. +; +; DOS-C is free software; you can redistribute it and/or +; modify it under the terms of the GNU General Public License +; as published by the Free Software Foundation; either version +; 2, or (at your option) any later version. +; +; DOS-C is distributed in the hope that it will be useful, but +; WITHOUT ANY WARRANTY; without even the implied warranty of +; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See +; the GNU General Public License for more details. +; +; You should have received a copy of the GNU General Public +; License along with DOS-C; see the file COPYING. If not, +; write to the Free Software Foundation, 675 Mass Ave, +; Cambridge, MA 02139, USA. +; +; $Logfile: C:/usr/patv/dos-c/src/drivers/floppy.asv $ +; +; $Id$ +; +; $Log$ +; Revision 1.1 2000/05/06 19:34:45 jhall1 +; Initial revision +; +; Revision 1.4 1999/08/10 17:21:08 jprice +; ror4 2011-01 patch +; +; Revision 1.3 1999/04/16 21:29:17 jprice +; ror4 multi-sector IO +; +; Revision 1.2 1999/03/29 17:08:31 jprice +; ror4 changes +; +; Revision 1.1.1.1 1999/03/29 15:40:24 jprice +; New version without IPL.SYS +; +; Revision 1.4 1999/02/14 04:25:16 jprice +; Added functions to check if a floppy disk has been changed. +; +; Revision 1.3 1999/02/08 05:49:47 jprice +; Added Pat's 1937 kernel patches +; +; Revision 1.2 1999/01/22 04:16:39 jprice +; Formating +; +; Revision 1.1.1.1 1999/01/20 05:51:00 jprice +; Imported sources +; +; Rev 1.3 06 Dec 1998 8:43:00 patv +;New floppy support functions. +; +; Rev 1.2 29 Aug 1996 13:07:14 patv +;Bug fixes for v0.91b +; +; Rev 1.1 01 Sep 1995 18:50:34 patv +;Initial GPL release. +; +; Rev 1.0 02 Jul 1995 7:57:02 patv +;Initial revision. +; + +group TGROUP _TEXT + +segment _TEXT class=CODE + +; +; +; Reset both the diskette and hard disk system +; +; BOOL fl_reset(WORD drive) +; +; returns TRUE if successful +; + + global _fl_reset +_fl_reset: + mov bx,sp + mov ah,0 ; BIOS reset disketter & fixed disk + mov dl,[bx+2] + int 13h + + jc fl_rst1 ; cy==1 is error + mov ax,1 ; TRUE on success + ret + +fl_rst1: xor ax,ax ; FALSE on error + ret + + +; +; +; Read DASD Type +; +; COUNT fl_readdasd(WORD drive) +; +; returns 0-3 if successful, 0xFF if error +; +; Code Meaning +; 0 The drive is not present +; 1 Drive present, cannot detect disk change +; 2 Drive present, can detect disk change +; 3 Fixed disk +; + + global _fl_readdasd +_fl_readdasd: + push bp + mov bp,sp + + mov dl,[bp+4] ; get the drive number + mov ah,15h ; read DASD type + int 13h + + jc fl_rdasd1 ; cy==1 is error + mov al,ah ; for the return code + xor ah,ah + pop bp ; C exit + ret + +fl_rdasd1: mov ah,0 ; BIOS reset disketter & fixed disk + int 13h + mov ax,0FFh ; 0xFF on error + pop bp ; C exit + ret + + +; +; +; Read disk change line status +; +; COUNT fl_diskchanged(WORD drive) +; +; returns 1 if disk has changed, 0 if not, 0xFF if error +; + + global _fl_diskchanged +_fl_diskchanged: + push bp ; C entry + mov bp,sp + + mov dl,[bp+4] ; get the drive number + mov ah,16h ; read change status type + int 13h + + jc fl_dchanged1 ; cy==1 is error or disk has changed + xor ax,ax ; disk has not changed + pop bp ; C exit + ret + +fl_dchanged1: cmp ah,6 + jne fl_dc_error + mov ax,1 + pop bp ; C exit + ret + +fl_dc_error: mov ax,0FFh ; 0xFF on error + pop bp ; C exit + ret + + +; +; Read the disk system status +; +; COUNT fl_rd_status(WORD drive) +; +; Returns error codes +; +; See Phoenix Bios Book for error code meanings +; + + global _fl_rd_status +_fl_rd_status: + push bp ; C entry + mov bp,sp + + mov dl,[bp+4] ; get the drive number + mov ah,1 ; read status + int 13h + + mov al,ah ; for the return code + xor ah,ah + + pop bp ; C exit + ret + + +; +; Read Sectors +; +; COUNT fl_read(WORD drive, WORD head, WORD track, WORD sector, WORD count, BYTE FAR *buffer); +; +; Reads one or more sectors. +; +; Returns 0 if successful, error code otherwise. +; + global _fl_read +_fl_read: + push bp ; C entry + mov bp,sp + + mov dl,[bp+4] ; get the drive (if or'ed 80h its + ; hard drive. + mov dh,[bp+6] ; get the head number + mov ch,[bp+8] ; cylinder number (lo only if hard) + mov al,[bp+9h] ; get the top of cylinder + xor ah,ah + mov cl,6 ; form top of cylinder for sector + shl ax,cl + mov cl,[bp+0Ah] ; sector number + and cl,03fh ; mask to sector field bits 5-0 + or cl,al ; or in bits 7-6 + mov al,[bp+0Ch] + les bx,[bp+0Eh] ; Load 32 bit buffer ptr + + mov ah,2 + int 13h ; read sectors to memory es:bx + + mov al,ah + jc fl_rd1 ; error, return error code + xor al,al ; Zero transfer count +fl_rd1: + xor ah,ah ; force into < 255 count + pop bp + ret + + +; +; Write Sectors +; +; COUNT fl_write(WORD drive, WORD head, WORD track, WORD sector, WORD count, BYTE FAR *buffer); +; +; Writes one or more sectors. +; +; Returns 0 if successful, error code otherwise. +; + global _fl_write +_fl_write: + push bp ; C entry + mov bp,sp + + mov dl,[bp+4] ; get the drive (if or'ed 80h its + ; hard drive. + mov dh,[bp+6] ; get the head number + mov ch,[bp+8] ; cylinder number (lo only if hard) + mov al,[bp+9h] ; get the top of cylinder + xor ah,ah + mov cl,6 ; form top of cylinder for sector + shl ax,cl + mov cl,[bp+0Ah] ; sector number + and cl,03fh ; mask to sector field bits 5-0 + or cl,al ; or in bits 7-6 + mov al,[bp+0Ch] + les bx,[bp+0Eh] ; Load 32 bit buffer ptr + + mov ah,3 + int 13h ; write sectors from mem es:bx + + mov al,ah + jc fl_wr1 ; error, return error code + xor al,al ; Zero transfer count +fl_wr1: + xor ah,ah ; force into < 255 count + pop bp + ret + + +; +; SUBROUTINE +; + + global _fl_verify +_fl_verify: + push bp + mov bp,sp + mov dl,[bp+4] + mov dh,[bp+6] + mov ch,[bp+8] + mov cl,[bp+0Ah] + mov al,[bp+0Ch] + mov ah,4 + int 13h ; Disk dl=drive a: ah=func 04h + ; verify sectors with mem es:bx + mov al,ah + jc fl_ver1 ; Jump if carry Set + xor al,al ; Zero register +fl_ver1: + xor ah,ah ; Zero register + pop bp + ret + + + global _fl_format +_fl_format: + + xor ax,ax + ret + + +; +; +; Get number of disks +; +; COUNT fl_nrdrives(VOID) +; +; returns AX = number of harddisks +; + + global _fl_nrdrives +_fl_nrdrives: + push di ; di reserved by C-code ??? + + mov ah,8 ; DISK, get drive parameters + mov dl,80h + int 13h + mov ax,0 ; fake 0 drives on error + jc fl_nrd1 + mov al,dl +fl_nrd1: + pop di + ret diff --git a/drivers/getvec.asm b/drivers/getvec.asm new file mode 100644 index 00000000..7270f38f --- /dev/null +++ b/drivers/getvec.asm @@ -0,0 +1,92 @@ +; +; File: +; getvec.asm +; Description: +; get an interrupt vector - simple version +; +; Copyright (c) 1995 +; Pasquale J. Villani +; All Rights Reserved +; +; This file is part of DOS-C. +; +; DOS-C is free software; you can redistribute it and/or +; modify it under the terms of the GNU General Public License +; as published by the Free Software Foundation; either version +; 2, or (at your option) any later version. +; +; DOS-C is distributed in the hope that it will be useful, but +; WITHOUT ANY WARRANTY; without even the implied warranty of +; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See +; the GNU General Public License for more details. +; +; You should have received a copy of the GNU General Public +; License along with DOS-C; see the file COPYING. If not, +; write to the Free Software Foundation, 675 Mass Ave, +; Cambridge, MA 02139, USA. +; +; $Logfile: C:/dos-c/src/drivers/getvec.asv $ +; +; $Header$ +; +; $Log$ +; Revision 1.1 2000/05/06 19:34:45 jhall1 +; Initial revision +; +; Revision 1.3 1999/08/10 17:21:08 jprice +; ror4 2011-01 patch +; +; Revision 1.2 1999/03/29 17:08:31 jprice +; ror4 changes +; +; Revision 1.1.1.1 1999/03/29 15:40:27 jprice +; New version without IPL.SYS +; +; Revision 1.2 1999/01/22 04:16:39 jprice +; Formating +; +; Revision 1.1.1.1 1999/01/20 05:51:00 jprice +; Imported sources +; +; +; Rev 1.2 29 Aug 1996 13:07:10 patv +;Bug fixes for v0.91b +; +; Rev 1.1 01 Sep 1995 18:50:40 patv +;Initial GPL release. +; +; Rev 1.0 02 Jul 1995 8:00:36 patv +;Initial revision. +; + +group TGROUP _TEXT + +segment _TEXT class=CODE + + global _getvec +_getvec: + push bp + mov bp,sp + mov ax,[bp+4] + call getvec + pop bp + ret + +; +; assembler version - ax = vector number +; returns vector in dx:ax +; + + global getvec +getvec: + shl ax,1 ; Multiply by 4 + shl ax,1 + xor dx,dx ; and set segment to 0 + mov es,dx + mov bx,ax + pushf ; Push flags + cli ; Disable interrupts + mov ax,[es:bx] + mov dx,[es:bx+2] + popf ; Pop flags + ret diff --git a/drivers/rdatclk.asm b/drivers/rdatclk.asm new file mode 100644 index 00000000..9f9b04d9 --- /dev/null +++ b/drivers/rdatclk.asm @@ -0,0 +1,117 @@ +; +; File: +; rdatclk.asm +; Description: +; read the AT style clock from bios +; +; Copyright (c) 1995 +; Pasquale J. Villani +; All Rights Reserved +; +; This file is part of DOS-C. +; +; DOS-C is free software; you can redistribute it and/or +; modify it under the terms of the GNU General Public License +; as published by the Free Software Foundation; either version +; 2, or (at your option) any later version. +; +; DOS-C is distributed in the hope that it will be useful, but +; WITHOUT ANY WARRANTY; without even the implied warranty of +; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See +; the GNU General Public License for more details. +; +; You should have received a copy of the GNU General Public +; License along with DOS-C; see the file COPYING. If not, +; write to the Free Software Foundation, 675 Mass Ave, +; Cambridge, MA 02139, USA. +; +; @Logfile: C:/dos-c/src/drivers/rdatclk.asv @ +; +; @Header: /home/cvsroot/fdkernel/DRIVERS/RDATCLK.ASM,v 1.3 1999/04/12 03:19:44 jprice Exp @ +; +; @Log: RDATCLK.ASM,v @ +; Revision 1.3 1999/04/12 03:19:44 jprice +; more ror4 patches +; +; Revision 1.2 1999/03/29 17:08:31 jprice +; ror4 changes +; +; Revision 1.1.1.1 1999/03/29 15:40:31 jprice +; New version without IPL.SYS +; +; Revision 1.2 1999/01/22 04:16:39 jprice +; Formating +; +; Revision 1.1.1.1 1999/01/20 05:51:00 jprice +; Imported sources +; +; +; Rev 1.2 29 Aug 1996 13:07:10 patv +;Bug fixes for v0.91b +; +; Rev 1.1 01 Sep 1995 18:50:40 patv +;Initial GPL release. +; +; Rev 1.0 02 Jul 1995 8:00:16 patv +;Initial revision. +; + +group IGROUP INIT_TEXT + +segment INIT_TEXT class=INIT + +; +;COUNT ReadATClock(bcdDays, bcdHours, bcdMinutes, bcdSeconds) +;BYTE *bcdDays; +;BYTE *bcdHours; +;BYTE *bcdMinutes; +;BYTE *bcdSeconds; +; + global _ReadATClock +_ReadATClock: + push bp + mov bp,sp + sub sp,byte 10 +; Days = -6 +; Hours = -2 +; Minutes = -8 +; Seconds = -10 +; bcdSeconds = 10 +; bcdMinutes = 8 +; bcdHours = 6 +; bcdDays = 4 + mov ah,2 + int 26 + jnc @RdAT1140 + sbb ax,ax + mov sp,bp + pop bp + ret + nop +@RdAT1140: + mov byte [bp-2],ch ;Hours + mov byte [bp-8],cl ;Minutes + mov byte [bp-10],dh ;Seconds + mov ah,4 + int 26 + mov word [bp-6],dx ;Days + mov word [bp-4],cx + mov ax,word [bp-6] ;Days + mov dx,word [bp-4] + mov bx,word [bp+4] ;bcdDays + mov word [bx],ax + mov word [bx+2],dx + mov al,byte [bp-2] ;Hours + mov bx,word [bp+6] ;bcdHours + mov byte [bx],al + mov al,byte [bp-8] ;Minutes + mov bx,word [bp+8] ;bcdMinutes + mov byte [bx],al + mov al,byte [bp-10] ;Seconds + mov bx,word [bp+10] ;bcdSeconds + mov byte [bx],al + sub ax,ax + mov sp,bp + pop bp + ret + nop diff --git a/drivers/rdpcclk.asm b/drivers/rdpcclk.asm new file mode 100644 index 00000000..3456c5d9 --- /dev/null +++ b/drivers/rdpcclk.asm @@ -0,0 +1,82 @@ +; +; File: +; rdpcclk.asm +; Description: +; read the PC style clock from bios +; +; Copyright (c) 1995 +; Pasquale J. Villani +; All Rights Reserved +; +; This file is part of DOS-C. +; +; DOS-C is free software; you can redistribute it and/or +; modify it under the terms of the GNU General Public License +; as published by the Free Software Foundation; either version +; 2, or (at your option) any later version. +; +; DOS-C is distributed in the hope that it will be useful, but +; WITHOUT ANY WARRANTY; without even the implied warranty of +; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See +; the GNU General Public License for more details. +; +; You should have received a copy of the GNU General Public +; License along with DOS-C; see the file COPYING. If not, +; write to the Free Software Foundation, 675 Mass Ave, +; Cambridge, MA 02139, USA. +; +; $Logfile: C:/dos-c/src/drivers/rdpcclk.asv $ +; +; $Header$ +; +; $Log$ +; Revision 1.1 2000/05/06 19:34:45 jhall1 +; Initial revision +; +; Revision 1.4 1999/08/10 17:21:08 jprice +; ror4 2011-01 patch +; +; Revision 1.3 1999/04/12 03:19:44 jprice +; more ror4 patches +; +; Revision 1.2 1999/03/29 17:08:31 jprice +; ror4 changes +; +; Revision 1.1.1.1 1999/03/29 15:40:32 jprice +; New version without IPL.SYS +; +; Revision 1.2 1999/01/22 04:16:39 jprice +; Formating +; +; Revision 1.1.1.1 1999/01/20 05:51:00 jprice +; Imported sources +; +; +; Rev 1.2 29 Aug 1996 13:07:10 patv +;Bug fixes for v0.91b +; +; Rev 1.1 01 Sep 1995 18:50:40 patv +;Initial GPL release. +; +; Rev 1.0 02 Jul 1995 8:00:26 patv +;Initial revision. +; + +group TGROUP _TEXT + +segment _TEXT class=CODE + +; +; BOOL ReadPCClock(Ticks) +; ULONG *Ticks; +; + global _ReadPCClock +_ReadPCClock: + xor ah,ah + int 26 + mov bx,sp + mov bx,[bx+2] + mov [bx],dx + mov [bx+2],cx + cbw + ret diff --git a/drivers/timer.asm b/drivers/timer.asm new file mode 100644 index 00000000..d5db3376 --- /dev/null +++ b/drivers/timer.asm @@ -0,0 +1,159 @@ +; +; File: +; timer.asm +; Description: +; Set a single timer and check when expired +; +; Copyright (c) 1995 +; Pasquale J. Villani +; All Rights Reserved +; +; This file is part of DOS-C. +; +; DOS-C is free software; you can redistribute it and/or +; modify it under the terms of the GNU General Public License +; as published by the Free Software Foundation; either version +; 2, or (at your option) any later version. +; +; DOS-C is distributed in the hope that it will be useful, but +; WITHOUT ANY WARRANTY; without even the implied warranty of +; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See +; the GNU General Public License for more details. +; +; You should have received a copy of the GNU General Public +; License along with DOS-C; see the file COPYING. If not, +; write to the Free Software Foundation, 675 Mass Ave, +; Cambridge, MA 02139, USA. +; +; $Logfile: C:/dos-c/src/drivers/timer.asv $ +; +; $Header$ +; +; $Log$ +; Revision 1.1 2000/05/06 19:34:45 jhall1 +; Initial revision +; +; Revision 1.3 1999/08/10 17:21:08 jprice +; ror4 2011-01 patch +; +; Revision 1.2 1999/03/29 17:08:31 jprice +; ror4 changes +; +; Revision 1.1.1.1 1999/03/29 15:40:34 jprice +; New version without IPL.SYS +; +; Revision 1.2 1999/01/22 04:16:39 jprice +; Formating +; +; Revision 1.1.1.1 1999/01/20 05:51:00 jprice +; Imported sources +; +; +; Rev 1.2 29 Aug 1996 13:07:12 patv +;Bug fixes for v0.91b +; +; Rev 1.1 01 Sep 1995 18:50:42 patv +;Initial GPL release. +; +; Rev 1.0 02 Jul 1995 8:01:04 patv +;Initial revision. +; + +group TGROUP _TEXT +group DGROUP _BSS + +segment _TEXT class=CODE + +; +; void tmark() +; + global _tmark +_tmark: + push bp + mov bp,sp + xor ah,ah + int 01aH ; get current time in ticks + xor ah,ah + mov word [LastTime],dx ; and store it + mov word [LastTime+2],cx + pop bp + ret + + +; +; int tdelay(Ticks) +; + global _tdelay +_tdelay: + push bp + mov bp,sp + sub sp,byte 4 + xor ah,ah + int 01aH ; get current time in ticks + xor ah,ah + mov word [bp-4],dx ; and save it to a local variable + mov word [bp-2],cx ; "Ticks" +; +; Do a c equivalent of: +; +; return Now >= (LastTime + Ticks); +; + mov ax,word [LastTime+2] + mov dx,word [LastTime] + add dx,word [bp+4] + adc ax,word [bp+6] + cmp ax,word [bp-2] + ja short tdel_1 + jne short tdel_2 + cmp dx,word [bp-4] + ja short tdel_1 +tdel_2: + mov ax,1 ; True return + jmp short tdel_3 +tdel_1: + xor ax,ax ; False return +tdel_3: + mov sp,bp + pop bp + ret + + +; +; void twait(Ticks) +; + global _twait +_twait: + push bp + mov bp,sp + sub sp,byte 4 + call _tmark ; mark a start +; +; c equivalent +; do +; GetNowTime(&Now); +; while((LastTime + Ticks) < Now); +twait_1: + xor ah,ah + int 01aH + xor ah,ah ; do GetNowTime + mov word [bp-4],dx ; and save it to "Now" + mov word [bp-2],cx +; +; do comparison +; + mov ax,word [LastTime+2] + mov dx,word [LastTime] + add dx,word [bp+4] + adc ax,word [bp+6] + cmp ax,word [bp-2] + jb short twait_1 + jne short twait_2 + cmp dx,word [bp-4] + jb short twait_1 +twait_2: + mov sp,bp + pop bp + ret + +segment _BSS align=2 class=BSS +LastTime: resd 1 diff --git a/drivers/wratclk.asm b/drivers/wratclk.asm new file mode 100644 index 00000000..27fa1223 --- /dev/null +++ b/drivers/wratclk.asm @@ -0,0 +1,101 @@ +; +; File: +; wratclk.asm +; Description: +; WriteATClock - sysclock support +; +; Copyright (c) 1995 +; Pasquale J. Villani +; All Rights Reserved +; +; This file is part of DOS-C. +; +; DOS-C is free software; you can redistribute it and/or +; modify it under the terms of the GNU General Public License +; as published by the Free Software Foundation; either version +; 2, or (at your option) any later version. +; +; DOS-C is distributed in the hope that it will be useful, but +; WITHOUT ANY WARRANTY; without even the implied warranty of +; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See +; the GNU General Public License for more details. +; +; You should have received a copy of the GNU General Public +; License along with DOS-C; see the file COPYING. If not, +; write to the Free Software Foundation, 675 Mass Ave, +; Cambridge, MA 02139, USA. +; +; $Logfile: C:/dos-c/src/drivers/wratclk.asv $ +; +; $Header$ +; +; $Log$ +; Revision 1.1 2000/05/06 19:34:45 jhall1 +; Initial revision +; +; Revision 1.3 1999/08/10 17:21:08 jprice +; ror4 2011-01 patch +; +; Revision 1.2 1999/03/29 17:08:31 jprice +; ror4 changes +; +; Revision 1.1.1.1 1999/03/29 15:40:34 jprice +; New version without IPL.SYS +; +; Revision 1.2 1999/01/22 04:16:40 jprice +; Formating +; +; Revision 1.1.1.1 1999/01/20 05:51:00 jprice +; Imported sources +; +; +; Rev 1.2 29 Aug 1996 13:07:12 patv +;Bug fixes for v0.91b +; +; Rev 1.1 01 Sep 1995 18:50:42 patv +;Initial GPL release. +; +; Rev 1.0 02 Jul 1995 8:01:18 patv +;Initial revision. +; + +group TGROUP _TEXT + +segment _TEXT class=CODE + +; +; VOID WriteATClock(bcdDays, bcdHours, bcdMinutes, bcdSeconds) +; BYTE *bcdDays; +; BYTE bcdHours; +; BYTE bcdMinutes; +; BYTE bcdSeconds; +; + global _WriteATClock +_WriteATClock: + push bp + mov bp,sp + sub sp,byte 4 +; LocalCopy = -4 +; bcdSeconds = 10 +; bcdMinutes = 8 +; bcdHours = 6 +; bcdDays = 4 + mov bx,word [bp+4] ;bcdDays + mov ax,word [bx] + mov dx,word [bx+2] + mov word [bp-4],ax ;LocalCopy + mov word [bp-2],dx + mov ch,byte [bp+6] ;bcdHours + mov cl,byte [bp+8] ;bcdMinutes + mov dh,byte [bp+10] ;bcdSeconds + mov dl,0 + mov ah,3 + int 26 + mov cx,word [bp-2] + mov dx,word [bp-4] ;LocalCopy + mov ah,5 + int 26 + mov sp,bp + pop bp + ret + nop diff --git a/drivers/wrpcclk.asm b/drivers/wrpcclk.asm new file mode 100644 index 00000000..bd9e6331 --- /dev/null +++ b/drivers/wrpcclk.asm @@ -0,0 +1,82 @@ +; +; File: +; wrpcclk.asm +; Description: +; WritePCClock - sysclock support +; +; Copyright (c) 1995 +; Pasquale J. Villani +; All Rights Reserved +; +; This file is part of DOS-C. +; +; DOS-C is free software; you can redistribute it and/or +; modify it under the terms of the GNU General Public License +; as published by the Free Software Foundation; either version +; 2, or (at your option) any later version. +; +; DOS-C is distributed in the hope that it will be useful, but +; WITHOUT ANY WARRANTY; without even the implied warranty of +; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See +; the GNU General Public License for more details. +; +; You should have received a copy of the GNU General Public +; License along with DOS-C; see the file COPYING. If not, +; write to the Free Software Foundation, 675 Mass Ave, +; Cambridge, MA 02139, USA. +; +; $Logfile: C:/dos-c/src/drivers/wrpcclk.asv $ +; +; $Header$ +; +; $Log$ +; Revision 1.1 2000/05/06 19:34:45 jhall1 +; Initial revision +; +; Revision 1.3 1999/08/10 17:21:08 jprice +; ror4 2011-01 patch +; +; Revision 1.2 1999/03/29 17:08:31 jprice +; ror4 changes +; +; Revision 1.1.1.1 1999/03/29 15:40:35 jprice +; New version without IPL.SYS +; +; Revision 1.2 1999/01/22 04:16:40 jprice +; Formating +; +; Revision 1.1.1.1 1999/01/20 05:51:00 jprice +; Imported sources +; +; +; Rev 1.2 29 Aug 1996 13:07:12 patv +;Bug fixes for v0.91b +; +; Rev 1.1 01 Sep 1995 18:50:42 patv +;Initial GPL release. +; +; Rev 1.0 02 Jul 1995 8:01:30 patv +;Initial revision. +; + +group TGROUP _TEXT + +segment _TEXT class=CODE + +; +; VOID WritePCClock(Ticks) +; ULONG Ticks; +; + global _WritePCClock +_WritePCClock: + push bp + mov bp,sp +; Ticks = 4 + mov cx,word [bp+6] + mov dx,word [bp+4] ;Ticks + mov ah,1 + int 26 + mov sp,bp + pop bp + ret + nop diff --git a/fdkernel.lsm b/fdkernel.lsm new file mode 100644 index 00000000..2da0a9f9 --- /dev/null +++ b/fdkernel.lsm @@ -0,0 +1,14 @@ +Begin3 +Title: The FreeDOS Kernel +Version: 1.1.18 +Entered-date: 9 March 2000 +Description: The FreeDOS Kernel +Keywords: kernel freedos dos msdos +Author: kernel@gcfl.net (developers) +Maintained-by: linux-guru@gcfl.net +Primary-site: http://www.gcfl.net/pub/FreeDOS/kernel +Alternate-site: www.freedos.org +Original-site: http://www.gcfl.net/pub/FreeDOS/kernel +Platforms: dos dosemu +Copying-policy: GPL +End diff --git a/hdr/cds.h b/hdr/cds.h new file mode 100644 index 00000000..bc4abbfe --- /dev/null +++ b/hdr/cds.h @@ -0,0 +1,112 @@ +/****************************************************************/ +/* */ +/* cds.h */ +/* */ +/* Current Directory structures */ +/* */ +/* Copyright (c) 1995 */ +/* Pasquale J. Villani */ +/* All Rights Reserved */ +/* */ +/* This file is part of DOS-C. */ +/* */ +/* DOS-C is free software; you can redistribute it and/or */ +/* modify it under the terms of the GNU General Public License */ +/* as published by the Free Software Foundation; either version */ +/* 2, or (at your option) any later version. */ +/* */ +/* DOS-C is distributed in the hope that it will be useful, but */ +/* WITHOUT ANY WARRANTY; without even the implied warranty of */ +/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See */ +/* the GNU General Public License for more details. */ +/* */ +/* You should have received a copy of the GNU General Public */ +/* License along with DOS-C; see the file COPYING. If not, */ +/* write to the Free Software Foundation, 675 Mass Ave, */ +/* Cambridge, MA 02139, USA. */ +/****************************************************************/ + +#ifdef MAIN +#ifdef VERSION_STRINGS +static BYTE *Cds_hRcsId = "$Id$"; +#endif +#endif + +/* + * $Log$ + * Revision 1.1 2000/05/06 19:34:47 jhall1 + * Initial revision + * + * Revision 1.2 2000/03/09 06:06:38 kernel + * 2017f updates by James Tabor + * + * Revision 1.1.1.1 1999/03/29 15:39:22 jprice + * New version without IPL.SYS + * + * Revision 1.4 1999/02/01 01:40:06 jprice + * Clean up + * + * Revision 1.3 1999/01/30 08:21:43 jprice + * Clean up + * + * Revision 1.2 1999/01/22 04:17:40 jprice + * Formating + * + * Revision 1.1.1.1 1999/01/20 05:51:01 jprice + * Imported sources + * + + Rev 1.1 04 Jan 1998 23:14:18 patv + Changed Log for strip utility + + Rev 1.0 19 Feb 1996 3:15:52 patv + Added NLS, int2f and config.sys processing + */ + +#define MAX_CDSPATH 67 + +struct cds +{ + BYTE cdsCurrentPath[MAX_CDSPATH]; + UWORD cdsFlags; + struct dpb FAR *cdsDpb; + + union + { + BYTE FAR * + _cdsRedirRec; + struct + { + WORD _cdsStrtClst; + UWORD _cdsParam; + } + _cdsRedir; + } + _cdsUnion; + + WORD cdsStoreUData; + + WORD cdsJoinOffset; + + BYTE cdsNetFlag1; + BYTE FAR *cdsIfs; + UWORD cdsNetFlags2; + +}; + +#define cdsStrtClst _cdsUnion._cdsRedir._cdsStrtClst +#define cdsRedirRec _cdsUnion._cdsRedirRec +#define cdsParam _cdsUnion._cdsRedir._cdsParam + +typedef struct _cdstbl +{ + struct cds cds_table[26]; +} +cdstbl; + +/* Bits for cdsFlags */ +#define CDSNETWDRV 0x8000 +#define CDSPHYSDRV 0x4000 +#define CDSJOINED 0x2000 +#define CDSSUBST 0x1000 + diff --git a/hdr/clock.h b/hdr/clock.h new file mode 100644 index 00000000..9fbff301 --- /dev/null +++ b/hdr/clock.h @@ -0,0 +1,86 @@ +/****************************************************************/ +/* */ +/* clock.h */ +/* */ +/* Clock Driver data structures & declarations */ +/* */ +/* November 26, 1991 */ +/* */ +/* Adapted to DOS/NT June 12, 1993 */ +/* */ +/* Copyright (c) 1995 */ +/* Pasquale J. Villani */ +/* All Rights Reserved */ +/* */ +/* This file is part of DOS-C. */ +/* */ +/* DOS-C is free software; you can redistribute it and/or */ +/* modify it under the terms of the GNU General Public License */ +/* as published by the Free Software Foundation; either version */ +/* 2, or (at your option) any later version. */ +/* */ +/* DOS-C is distributed in the hope that it will be useful, but */ +/* WITHOUT ANY WARRANTY; without even the implied warranty of */ +/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See */ +/* the GNU General Public License for more details. */ +/* */ +/* You should have received a copy of the GNU General Public */ +/* License along with DOS-C; see the file COPYING. If not, */ +/* write to the Free Software Foundation, 675 Mass Ave, */ +/* Cambridge, MA 02139, USA. */ +/****************************************************************/ + +#ifdef MAIN +#ifdef VERSION_STRINGS +static BYTE *clock_hRcsId = "$Id$"; +#endif +#endif + +/* + * $Log$ + * Revision 1.1 2000/05/06 19:34:47 jhall1 + * Initial revision + * + * Revision 1.1.1.1 1999/03/29 15:39:22 jprice + * New version without IPL.SYS + * + * Revision 1.4 1999/02/01 01:40:06 jprice + * Clean up + * + * Revision 1.3 1999/01/30 08:21:43 jprice + * Clean up + * + * Revision 1.2 1999/01/22 04:17:40 jprice + * Formating + * + * Revision 1.1.1.1 1999/01/20 05:51:01 jprice + * Imported sources + * + * + * Rev 1.5 04 Jan 1998 23:14:18 patv + * Changed Log for strip utility + * + * Rev 1.4 29 May 1996 21:25:20 patv + * bug fixes for v0.91a + * + * Rev 1.3 19 Feb 1996 3:15:30 patv + * Added NLS, int2f and config.sys processing + * + * Rev 1.2 01 Sep 1995 17:35:38 patv + * First GPL release. + * + * Rev 1.1 30 Jul 1995 20:43:46 patv + * Eliminated version strings in ipl + * + * Rev 1.0 02 Jul 1995 10:39:26 patv + * Initial revision. + */ + +struct ClockRecord +{ + UWORD clkDays; /* days since Jan 1, 1980. */ + UBYTE clkMinutes; /* residual minutes. */ + UBYTE clkHours; /* residual hours. */ + UBYTE clkHundredths; /* residual hundredths of a second. */ + UBYTE clkSeconds; /* residual seconds. */ +}; diff --git a/hdr/date.h b/hdr/date.h new file mode 100644 index 00000000..affc58b6 --- /dev/null +++ b/hdr/date.h @@ -0,0 +1,95 @@ +/****************************************************************/ +/* */ +/* date.h */ +/* */ +/* DOS General Date Structure */ +/* */ +/* Copyright (c) 1995 */ +/* Pasquale J. Villani */ +/* All Rights Reserved */ +/* */ +/* This file is part of DOS-C. */ +/* */ +/* DOS-C is free software; you can redistribute it and/or */ +/* modify it under the terms of the GNU General Public License */ +/* as published by the Free Software Foundation; either version */ +/* 2, or (at your option) any later version. */ +/* */ +/* DOS-C is distributed in the hope that it will be useful, but */ +/* WITHOUT ANY WARRANTY; without even the implied warranty of */ +/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See */ +/* the GNU General Public License for more details. */ +/* */ +/* You should have received a copy of the GNU General Public */ +/* License along with DOS-C; see the file COPYING. If not, */ +/* write to the Free Software Foundation, 675 Mass Ave, */ +/* Cambridge, MA 02139, USA. */ +/****************************************************************/ + +/* TC 2.01 complains if `date' is defined twice. -- ror4 */ +#ifndef DOSC_DATE_H +#define DOSC_DATE_H + +#ifdef MAIN +#ifdef VERSION_STRINGS +static BYTE *date_hRcsId = "$Id$"; +#endif +#endif + +/* + * $Log$ + * Revision 1.1 2000/05/06 19:34:47 jhall1 + * Initial revision + * + * Revision 1.2 1999/08/25 03:17:11 jprice + * ror4 patches to allow TC 2.01 compile. + * + * Revision 1.1.1.1 1999/03/29 15:39:23 jprice + * New version without IPL.SYS + * + * Revision 1.3 1999/02/01 01:40:06 jprice + * Clean up + * + * Revision 1.2 1999/01/22 04:17:40 jprice + * Formating + * + * Revision 1.1.1.1 1999/01/20 05:51:01 jprice + * Imported sources + * + * + * Rev 1.5 04 Jan 1998 23:14:18 patv + * Changed Log for strip utility + * + * Rev 1.4 29 May 1996 21:25:20 patv + * bug fixes for v0.91a + * + * Rev 1.3 19 Feb 1996 3:15:30 patv + * Added NLS, int2f and config.sys processing + * + * Rev 1.2 01 Sep 1995 17:35:40 patv + * First GPL release. + * + * Rev 1.1 30 Jul 1995 20:43:48 patv + * Eliminated version strings in ipl + * + * Rev 1.0 02 Jul 1995 10:39:28 patv + * Initial revision. + */ + +/* FAT file date - takes the form of yyyy yyym mmmd dddd where physical */ +/* year=1980+yyyyyy */ + +#define DT_YEAR(d) (((d)>>9)&0x7f) +#define DT_MONTH(d) (((d)>>5)&0x0f) +#define DT_DAY(d) ((d)&0x1f) + +#define DT_ENCODE(m,d,y) ((((m)&0x0f)<<5)|((d)&0x1f)|(((y)&0x7f)<<9)) + +#define EPOCH_WEEKDAY 2 /* Tuesday (i. e.- 0 == Sunday) */ +#define EPOCH_MONTH 1 /* January */ +#define EPOCH_DAY 1 /* 1 for January 1 */ +#define EPOCH_YEAR 1980 /* for Tues 1-1-80 epoch */ + +typedef UWORD date; + +#endif diff --git a/hdr/dcb.h b/hdr/dcb.h new file mode 100644 index 00000000..35c8e5cd --- /dev/null +++ b/hdr/dcb.h @@ -0,0 +1,109 @@ +/****************************************************************/ +/* */ +/* dcb.h */ +/* */ +/* DOS Device Control Block Structure */ +/* */ +/* November 20, 1991 */ +/* */ +/* Copyright (c) 1995 */ +/* Pasquale J. Villani */ +/* All Rights Reserved */ +/* */ +/* This file is part of DOS-C. */ +/* */ +/* DOS-C is free software; you can redistribute it and/or */ +/* modify it under the terms of the GNU General Public License */ +/* as published by the Free Software Foundation; either version */ +/* 2, or (at your option) any later version. */ +/* */ +/* DOS-C is distributed in the hope that it will be useful, but */ +/* WITHOUT ANY WARRANTY; without even the implied warranty of */ +/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See */ +/* the GNU General Public License for more details. */ +/* */ +/* You should have received a copy of the GNU General Public */ +/* License along with DOS-C; see the file COPYING. If not, */ +/* write to the Free Software Foundation, 675 Mass Ave, */ +/* Cambridge, MA 02139, USA. */ +/****************************************************************/ + +#ifdef MAIN +#ifdef VERSION_STRINGS +static BYTE *clock_hRcsId = "$Id$"; +#endif +#endif + +/* + * $Log$ + * Revision 1.1 2000/05/06 19:34:47 jhall1 + * Initial revision + * + * Revision 1.3 2000/03/09 06:06:38 kernel + * 2017f updates by James Tabor + * + * Revision 1.2 1999/04/16 00:52:09 jprice + * Optimized FAT handling + * + * Revision 1.1.1.1 1999/03/29 15:39:23 jprice + * New version without IPL.SYS + * + * Revision 1.3 1999/02/01 01:40:06 jprice + * Clean up + * + * Revision 1.2 1999/01/22 04:17:40 jprice + * Formating + * + * Revision 1.1.1.1 1999/01/20 05:51:01 jprice + * Imported sources + * + * + * Rev 1.5 04 Jan 1998 23:14:18 patv + * Changed Log for strip utility + * + * Rev 1.4 29 May 1996 21:25:20 patv + * bug fixes for v0.91a + * + * Rev 1.3 19 Feb 1996 3:15:30 patv + * Added NLS, int2f and config.sys processing + * + * Rev 1.2 01 Sep 1995 17:35:40 patv + * First GPL release. + * + * Rev 1.1 30 Jul 1995 20:43:48 patv + * Eliminated version strings in ipl + * + * Rev 1.0 02 Jul 1995 10:39:30 patv + * Initial revision. + */ + +/* Internal drive parameter block */ +struct dpb +{ + BYTE dpb_unit; /* unit for error reporting */ + BYTE dpb_subunit; /* the sub-unit for driver */ + UWORD dpb_secsize; /* sector size */ + UBYTE dpb_clsmask; /* mask (sectors/cluster-1) */ + UBYTE dpb_shftcnt; /* log base 2 of cluster size */ + UWORD dpb_fatstrt; /* FAT start sector */ + UBYTE dpb_fats; /* # of FAT copies */ + UWORD dpb_dirents; /* # of dir entries */ + UWORD dpb_data; /* start of data area */ + UWORD dpb_size; /* # of clusters+1 on media */ + UWORD dpb_fatsize; /* # of sectors / FAT */ + UWORD dpb_dirstrt; /* start sec. of root dir */ + struct dhdr FAR * /* pointer to device header */ + dpb_device; + UBYTE dpb_mdb; /* media descr. byte */ + BYTE dpb_flags; /* -1 = force MEDIA CHK */ + struct dpb FAR * /* next dpb in chain */ + dpb_next; /* -1 = end */ + UWORD dpb_cluster; /* cluster # of first free */ + /* -1 if not known */ + UWORD dpb_nfreeclst; /* number of free clusters */ + /* -1 if not known */ + +}; + +#define UNKNCLUSTER 0xffff /* 0xffff = unknown for DOS */ + diff --git a/hdr/device.h b/hdr/device.h new file mode 100644 index 00000000..daecb335 --- /dev/null +++ b/hdr/device.h @@ -0,0 +1,421 @@ +/****************************************************************/ +/* */ +/* device.h */ +/* Device Driver Header File */ +/* */ +/* November 20, 1991 */ +/* */ +/* Copyright (c) 1995 */ +/* Pasquale J. Villani */ +/* All Rights Reserved */ +/* */ +/* This file is part of DOS-C. */ +/* */ +/* DOS-C is free software; you can redistribute it and/or */ +/* modify it under the terms of the GNU General Public License */ +/* as published by the Free Software Foundation; either version */ +/* 2, or (at your option) any later version. */ +/* */ +/* DOS-C is distributed in the hope that it will be useful, but */ +/* WITHOUT ANY WARRANTY; without even the implied warranty of */ +/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See */ +/* the GNU General Public License for more details. */ +/* */ +/* You should have received a copy of the GNU General Public */ +/* License along with DOS-C; see the file COPYING. If not, */ +/* write to the Free Software Foundation, 675 Mass Ave, */ +/* Cambridge, MA 02139, USA. */ +/****************************************************************/ + +#ifdef MAIN +#ifdef VERSION_STRINGS +static BYTE *device_hRcsId = "$Id$"; +#endif +#endif + +/* + * $Log$ + * Revision 1.1 2000/05/06 19:34:46 jhall1 + * Initial revision + * + * Revision 1.3 2000/03/09 06:06:38 kernel + * 2017f updates by James Tabor + * + * Revision 1.2 1999/04/04 18:50:14 jprice + * no message + * + * Revision 1.1.1.1 1999/03/29 15:39:26 jprice + * New version without IPL.SYS + * + * Revision 1.5 1999/02/08 05:58:24 jprice + * Added Pat's 1937 kernel patches + * + * Revision 1.4 1999/02/04 03:08:47 jprice + * no message + * + * Revision 1.3 1999/02/01 01:40:06 jprice + * Clean up + * + * Revision 1.2 1999/01/22 04:17:40 jprice + * Formating + * + * Revision 1.1.1.1 1999/01/20 05:51:01 jprice + * Imported sources + * + * + * Rev 1.8 06 Dec 1998 8:41:30 patv + * Changed for new I/O subsystem + * + * Rev 1.7 11 Jan 1998 2:05:54 patv + * Added functionality to ioctl. + * + * Rev 1.6 04 Jan 1998 23:14:20 patv + * Changed Log for strip utility + * + * Rev 1.5 16 Jan 1997 12:46:06 patv + * pre-Release 0.92 feature additions + * + * Rev 1.4 29 May 1996 21:25:12 patv + * bug fixes for v0.91a + * + * Rev 1.3 19 Feb 1996 3:15:30 patv + * Added NLS, int2f and config.sys processing + * + * Rev 1.2 01 Sep 1995 17:35:40 patv + * First GPL release. + * + * Rev 1.1 30 Jul 1995 20:43:48 patv + * Eliminated version strings in ipl + * + * Rev 1.0 02 Jul 1995 10:39:30 patv + * Initial revision. + */ + +/* + * Status Word Bits + */ + +#define S_ERROR 0x8000 /* Error bit */ +#define S_BUSY 0x0200 /* Device busy bit */ +#define S_DONE 0x0100 /* Device operation completed */ +#define S_MASK 0x00ff /* Mask to extract error code */ + +/* + * MEDIA Descriptor Byte Bits + */ + +#define MD_2SIDE 1 /* MEDIA is two sided */ +#define MD_8SECTOR 2 /* MEDIA is eight sectored */ +#define MD_REMOVABLE 4 /* MEDIA is removable (floppy) */ + +/* + * Media Return Codes + */ +#define M_CHANGED -1 /* MEDIA was changed */ +#define M_DONT_KNOW 0 /* MEDIA state unkown */ +#define M_NOT_CHANGED 1 /* MEDIA was not changed */ + +/* + * Error Return Codes + */ + +#define E_WRPRT 0 /* Write Protect */ +#define E_UNIT 1 /* Unknown Unit */ +#define E_NOTRDY 2 /* Device Not Ready */ +#define E_CMD 3 /* Unknown Command */ +#define E_CRC 4 /* Crc Error */ +#define E_LENGTH 5 /* Bad Length */ +#define E_SEEK 6 /* Seek Error */ +#define E_MEDIA 7 /* Unknown MEDIA */ +#define E_NOTFND 8 /* Sector Not Found */ +#define E_PAPER 9 /* No Paper */ +#define E_WRITE 10 /* Write Fault */ +#define E_READ 11 /* Read Fault */ +#define E_FAILURE 12 /* General Failure */ + +/* + * Command codes + */ + +#define C_INIT 0x00 /* Initialize */ +#define C_MEDIACHK 0x01 /* MEDIA Check */ +#define C_BLDBPB 0x02 /* Build BPB */ +#define C_IOCTLIN 0x03 /* Ioctl In */ +#define C_INPUT 0x04 /* Input (Read) */ +#define C_NDREAD 0x05 /* Non-destructive Read */ +#define C_ISTAT 0x06 /* Input Status */ +#define C_IFLUSH 0x07 /* Input Flush */ +#define C_OUTPUT 0x08 /* Output (Write) */ +#define C_OUTVFY 0x09 /* Output with verify */ +#define C_OSTAT 0x0a /* Output */ +#define C_OFLUSH 0x0b /* Output Flush */ +#define C_IOCTLOUT 0x0c /* Ioctl Out */ +#define C_OPEN 0x0d /* Device Open */ +#define C_CLOSE 0x0e /* Device Close */ +#define C_REMMEDIA 0x0f /* Removable MEDIA */ +#define C_OUB 0x10 /* Output till busy */ +#define C_GENIOCTL 0x13 /* Generic Ioctl */ +#define C_GETLDEV 0x17 /* Get Logical Device */ +#define C_SETLDEV 0x18 /* Set Logical Device */ +#define C_IOCTLQRY 0x19 /* Ioctl Query */ + +/* + * Convienence macros + */ +#define failure(x) (S_ERROR+S_DONE+x) +#ifndef TRUE +#define TRUE 1 +#endif +#ifndef FALSE +#define FALSE 0 +#endif +#define mk_offset(far_ptr) ((UWORD)(far_ptr)) +#define mk_segment(far_ptr) ((UWORD)((ULONG)(far_ptr) >> 16)) +#define far_ptr(seg, off) ((VOID FAR *)(((ULONG)(off))+((ULONG)(seg) << 16))) + +/* + * structures + */ + +/* Device header */ + +struct dhdr +{ + struct dhdr + FAR *dh_next; + UWORD dh_attr; + VOID(*dh_strategy) (); + VOID(*dh_interrupt) (); + BYTE dh_name[8]; +}; + +#define ATTR_CHAR 0x8000 +#define ATTR_IOCTL 0x4000 +#define ATTR_BLDFAT 0x2000 +#define ATTR_EXCALLS 0x0800 +#define ATTR_QRYIOCTL 0x0080 +#define ATTR_GENIOCTL 0x0040 +#define ATTR_RAW 0x0400 +#define ATTR_FASTCON 0x0010 +#define ATTR_CLOCK 0x0008 +#define ATTR_NULL 0x0004 +#define ATTR_CONOUT 0x0002 +#define ATTR_HUGE 0x0002 +#define ATTR_CONIN 0x0001 + +/* */ +/* Bios Parameter Block structure */ +/* */ +/* The following offsets are computed as byte offsets and are based on */ +/* the struct below. The struct itself cannot be used because on some */ +/* compilers, structure alignement may be forced, throwing following */ +/* fields off (e.g. - BYTE, followed by a WORD may have a byte of fill */ +/* inserted in between; the WORD would then be at offset 2, not 1). */ +/* */ +#define BPB_NBYTE 0 +#define BPB_NSECTOR 2 +#define BPB_NRESERVED 3 +#define BPB_NFAT 5 +#define BPB_NDIRENT 6 +#define BPB_NSIZE 8 +#define BPB_MDESC 10 +#define BPB_NFSECT 11 +#define BPB_NSECS 13 +#define BPB_NHEADS 15 +#define BPB_HIDDEN 17 +#define BPB_HUGE 21 +#define BPB_SIZEOF 25 + +typedef struct +{ + UWORD bpb_nbyte; /* Bytes per Sector */ + UBYTE bpb_nsector; /* Sectors per Allocation Unit */ + UWORD bpb_nreserved; /* # Reserved Sectors */ + UBYTE bpb_nfat; /* # FAT's */ + UWORD bpb_ndirent; /* # Root Directory entries */ + UWORD bpb_nsize; /* Size in sectors */ + UBYTE bpb_mdesc; /* MEDIA Descriptor Byte */ + UWORD bpb_nfsect; /* FAT size in sectors */ + UWORD bpb_nsecs; /* Sectors per track */ + UWORD bpb_nheads; /* Number of heads */ + ULONG bpb_hidden; /* Hidden sectors */ + ULONG bpb_huge; /* Size in sectors if */ + /* bpb_nsize== 0 */ +} +bpb; + +/* */ +/* Boot Block (Super Block) */ +/* */ +/* See BPB comments for the offsets below */ +/* */ +#define BT_JUMP 0 +#define BT_OEM 3 +#define BT_BPB 11 +#define BT_SIZEOF 36 + +typedef struct +{ + BYTE bt_jump[3]; /* Boot Jump opcodes */ + BYTE bt_oem[8]; /* OEM Name */ + bpb bt_bpb; /* BPB for this media/device */ + WORD bt_nsecs; /* # Sectors per Track */ + WORD bt_nheads; /* # Heads */ + WORD bt_hidden; /* # Hidden sectors */ + LONG bt_huge; /* use if nsecs == 0 */ +} +boot; + +typedef boot super; /* Alias for boot structure */ + +typedef struct +{ + BYTE r_length; /* Request Header length */ + BYTE r_unit; /* Unit Code */ + BYTE r_command; /* Command Code */ + WORD r_status; /* Status */ + BYTE r_reserved[8]; /* DOS Reserved Area */ + union + { + struct + { + BYTE _r_nunits; /* number of units */ + BYTE FAR *_r_endaddr; /* Ending Address */ + bpb *FAR * _r_bpbptr; /* ptr to BPB array */ + BYTE _r_firstunit; + } + _r_init; + struct + { + BYTE _r_meddesc; /* MEDIA Descriptor */ + BYTE _r_retcode; /* Return Code */ + BYTE FAR + * _r_vid; /* volume id */ + } + _r_media; + struct + { + BYTE _r_meddesc; /* MEDIA Descriptor */ + boot FAR + * _r_fat; /* boot sector pointer */ + bpb FAR + * _r_bpbpt; /* ptr to BPB table */ + } + _r_bpb; + struct + { + BYTE _r_meddesc; /* MEDIA Descriptor */ + BYTE FAR + * _r_trans; /* Transfer Address */ + UWORD _r_count; /* Byte/Sector Count */ + UWORD _r_start; /* Starting Sector No. */ + BYTE FAR + * _r_vid; /* Pointer to volume id */ + LONG _r_huge; /* for > 32Mb drives */ + } + _r_rw; + struct + { + BYTE _r_ndbyte; /* Byte Read From Device */ + } + _r_nd; + } + _r_x; +} +request; + +#define HUGECOUNT 0xffff +#define MAXSHORT 0xffffl + +/* + * Macros to assist request structure legibility + */ + +/* Init packet macros */ +#define r_nunits _r_x._r_init._r_nunits +#define r_endaddr _r_x._r_init._r_endaddr +#define r_bpbptr _r_x._r_init._r_bpbptr +#define r_firstunit _r_x._r_init._r_firstunit + +/* MEDIA Check packet macros */ +#define r_mcmdesc _r_x._r_media._r_meddesc +#define r_mcretcode _r_x._r_media._r_retcode +#define r_mcvid _r_x._r_media._r_vid + +/* Build BPB packet macros */ +#define r_bpmdesc _r_x._r_bpb._r_meddesc +#define r_bpfat _r_x._r_bpb._r_fat +#define r_bpptr _r_x._r_bpb._r_bpbpt + +/* rw packet macros */ +#define r_meddesc _r_x._r_rw._r_meddesc +#define r_trans _r_x._r_rw._r_trans +#define r_count _r_x._r_rw._r_count +#define r_start _r_x._r_rw._r_start +#define r_rwvid _r_x._r_rw._r_vid +#define r_huge _r_x._r_rw._r_huge + +/* ndread packet macros */ +#define r_ndbyte _r_x._r_nd._r_ndbyte + +/* + *interrupt support (spl & splx) support - IBM style + */ + +#define I_NONE 0 /* Initial value */ + +/* predefined interrupt levels - 8259 support */ +#define IRQ0 0x01 /* Level 0 - highest */ +#define IRQ1 0x02 +#define IRQ2 0x04 +#define IRQ3 0x08 +#define IRQ4 0x10 +#define IRQ5 0x20 +#define IRQ6 0x40 +#define IRQ7 0x80 /* Level 7 - lowest */ + +/* standard hardware configuration */ +#define I_RTC IRQ0 /* Timer */ +#define I_KBD IRQ1 /* Keyboard */ +#define I_COM2 IRQ3 /* COM1: */ +#define I_COM1 IRQ4 /* COM2: */ +#define I_HDC IRQ5 /* Fixed disk */ +#define I_FDC IRQ6 /* Diskette */ +#define I_PRT IRQ7 /* Printer */ + +/* standard hardware vectors - 8259 defined */ +#define V_RTC 0x08 /* Timer */ +#define V_KBD 0x09 /* Keyboard */ +#define V_LEV2 0x0a /* Level 2 - uncomitted */ +#define V_COM2 0x0b /* COM1: */ +#define V_COM1 0x0c /* COM2: */ +#define V_HDC 0x0d /* Fixed disk */ +#define V_FDC 0x0e /* Diskette */ +#define V_PRT 0x0f /* Printer */ + +#define V_LEV0 0x08 /* Level 0 - highest */ +#define V_LEV1 0x09 +#define V_LEV2 0x0a /* Level 2 - uncomitted */ +#define V_LEV3 0x0b +#define V_LEV4 0x0c +#define V_LEV5 0x0d +#define V_LEV6 0x0e +#define V_LEV7 0x0f /* Level 7 - lowest */ + +/* + */ +typedef request FAR *rqptr; +typedef bpb FAR *bpbptr; +typedef BYTE FAR *byteptr; +typedef struct dhdr FAR *dhdrptr; + +/* + * externals + */ + +extern BYTE FAR *device_end(); + +/* + * end of device.h + */ + diff --git a/hdr/dirmatch.h b/hdr/dirmatch.h new file mode 100644 index 00000000..dcf14e32 --- /dev/null +++ b/hdr/dirmatch.h @@ -0,0 +1,117 @@ +/****************************************************************/ +/* */ +/* dirmatch.h */ +/* */ +/* FAT File System Match Data Structure */ +/* */ +/* January 4, 1992 */ +/* */ +/* Copyright (c) 1995 */ +/* Pasquale J. Villani */ +/* All Rights Reserved */ +/* */ +/* This file is part of DOS-C. */ +/* */ +/* DOS-C is free software; you can redistribute it and/or */ +/* modify it under the terms of the GNU General Public License */ +/* as published by the Free Software Foundation; either version */ +/* 2, or (at your option) any later version. */ +/* */ +/* DOS-C is distributed in the hope that it will be useful, but */ +/* WITHOUT ANY WARRANTY; without even the implied warranty of */ +/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See */ +/* the GNU General Public License for more details. */ +/* */ +/* You should have received a copy of the GNU General Public */ +/* License along with DOS-C; see the file COPYING. If not, */ +/* write to the Free Software Foundation, 675 Mass Ave, */ +/* Cambridge, MA 02139, USA. */ +/****************************************************************/ + +#ifdef MAIN +#ifdef VERSION_STRINGS +static BYTE *dirmatch_hRcsId = "$Id$"; +#endif +#endif + +/* + * $Log$ + * Revision 1.1 2000/05/06 19:34:47 jhall1 + * Initial revision + * + * Revision 1.3 2000/03/09 06:06:38 kernel + * 2017f updates by James Tabor + * + * Revision 1.2 1999/08/25 03:17:11 jprice + * ror4 patches to allow TC 2.01 compile. + * + * Revision 1.1.1.1 1999/03/29 15:39:21 jprice + * New version without IPL.SYS + * + * Revision 1.3 1999/02/01 01:40:06 jprice + * Clean up + * + * Revision 1.2 1999/01/22 04:17:40 jprice + * Formating + * + * Revision 1.1.1.1 1999/01/20 05:51:01 jprice + * Imported sources + * + * + * Rev 1.5 04 Jan 1998 23:14:16 patv + * Changed Log for strip utility + * + * Rev 1.4 29 May 1996 21:25:18 patv + * bug fixes for v0.91a + * + * Rev 1.3 19 Feb 1996 3:15:34 patv + * Added NLS, int2f and config.sys processing + * + * Rev 1.2 01 Sep 1995 17:35:40 patv + * First GPL release. + * + * Rev 1.1 30 Jul 1995 20:43:48 patv + * Eliminated version strings in ipl + * + * Rev 1.0 02 Jul 1995 10:39:34 patv + * Initial revision. + * + * Rev 1.0 25 May 1993 23:30:26 patv + * Initial revision. + * + */ + +typedef struct +{ + BYTE dm_drive; + BYTE dm_name_pat[FNAME_SIZE + FEXT_SIZE]; + BYTE dm_attr_srch; + UWORD dm_entry; + UWORD dm_cluster; + + struct + { + UWORD /* directory has been modified */ + f_dmod:1; + UWORD /* directory is the root */ + f_droot:1; + UWORD /* fnode is new and needs fill */ + f_dnew:1; + UWORD /* fnode is assigned to dir */ + f_ddir:1; + UWORD /* directory is full */ + f_dfull:1; + UWORD /* filler to avoid a bad bug (feature?) in */ + f_filler:11; /* TC 2.01 */ + } + dm_flags; /* file flags */ + UWORD dm_dirstart; + + BYTE dm_attr_fnd; /* found file attribute */ + time dm_time; /* file time */ + date dm_date; /* file date */ + LONG dm_size; /* file size */ + BYTE dm_name[FNAME_SIZE + FEXT_SIZE + 2]; /* file name */ +} +dmatch; + diff --git a/hdr/dosnames.h b/hdr/dosnames.h new file mode 100644 index 00000000..e9410601 --- /dev/null +++ b/hdr/dosnames.h @@ -0,0 +1,79 @@ +/****************************************************************/ +/* */ +/* dosnames.h */ +/* */ +/* FAT File System Name Parse Structure */ +/* */ +/* March 5, 1995 */ +/* */ +/* Copyright (c) 1995 */ +/* Pasquale J. Villani */ +/* All Rights Reserved */ +/* */ +/* This file is part of DOS-C. */ +/* */ +/* DOS-C is free software; you can redistribute it and/or */ +/* modify it under the terms of the GNU General Public License */ +/* as published by the Free Software Foundation; either version */ +/* 2, or (at your option) any later version. */ +/* */ +/* DOS-C is distributed in the hope that it will be useful, but */ +/* WITHOUT ANY WARRANTY; without even the implied warranty of */ +/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See */ +/* the GNU General Public License for more details. */ +/* */ +/* You should have received a copy of the GNU General Public */ +/* License along with DOS-C; see the file COPYING. If not, */ +/* write to the Free Software Foundation, 675 Mass Ave, */ +/* Cambridge, MA 02139, USA. */ +/****************************************************************/ + +#ifdef MAIN +#ifdef VERSION_STRINGS +static BYTE *dosnames_hRcsId = "$Id$"; +#endif +#endif + +/* + * $Log$ + * Revision 1.1 2000/05/06 19:34:47 jhall1 + * Initial revision + * + * Revision 1.1.1.1 1999/03/29 15:39:27 jprice + * New version without IPL.SYS + * + * Revision 1.3 1999/02/01 01:40:06 jprice + * Clean up + * + * Revision 1.2 1999/01/22 04:17:40 jprice + * Formating + * + * Revision 1.1.1.1 1999/01/20 05:51:01 jprice + * Imported sources + * + * + * Rev 1.4 29 May 1996 21:25:14 patv + * bug fixes for v0.91a + * + * Rev 1.3 19 Feb 1996 3:15:30 patv + * Added NLS, int2f and config.sys processing + * + * Rev 1.2 01 Sep 1995 17:35:40 patv + * First GPL release. + * + * Rev 1.1 30 Jul 1995 20:43:48 patv + * Eliminated version strings in ipl + * + * Rev 1.0 02 Jul 1995 10:39:34 patv + * Initial revision. + */ + +#define PARSE_MAX 64 + +struct dosnames +{ + UBYTE dn_drive; /* the drive that was parsed */ + UBYTE dn_network[PARSE_MAX]; /* specified network */ + UBYTE dn_path[PARSE_MAX]; /* the path */ + UBYTE dn_name[FNAME_SIZE + FEXT_SIZE + 1]; /* the file name */ +}; diff --git a/hdr/error.h b/hdr/error.h new file mode 100644 index 00000000..36325849 --- /dev/null +++ b/hdr/error.h @@ -0,0 +1,124 @@ +/****************************************************************/ +/* */ +/* error.h */ +/* */ +/* DOS-C error return codes */ +/* */ +/* December 1, 1991 */ +/* */ +/* Copyright (c) 1995 */ +/* Pasquale J. Villani */ +/* All Rights Reserved */ +/* */ +/* This file is part of DOS-C. */ +/* */ +/* DOS-C is free software; you can redistribute it and/or */ +/* modify it under the terms of the GNU General Public License */ +/* as published by the Free Software Foundation; either version */ +/* 2, or (at your option) any later version. */ +/* */ +/* DOS-C is distributed in the hope that it will be useful, but */ +/* WITHOUT ANY WARRANTY; without even the implied warranty of */ +/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See */ +/* the GNU General Public License for more details. */ +/* */ +/* You should have received a copy of the GNU General Public */ +/* License along with DOS-C; see the file COPYING. If not, */ +/* write to the Free Software Foundation, 675 Mass Ave, */ +/* Cambridge, MA 02139, USA. */ +/****************************************************************/ + +#ifdef MAIN +#ifdef VERSION_STRINGS +static BYTE *error_hRcsId = "$Id$"; +#endif +#endif + +/* + * $Log$ + * Revision 1.1 2000/05/06 19:34:47 jhall1 + * Initial revision + * + * Revision 1.1.1.1 1999/03/29 15:39:27 jprice + * New version without IPL.SYS + * + * Revision 1.5 1999/02/08 05:58:24 jprice + * Added Pat's 1937 kernel patches + * + * Revision 1.4 1999/02/01 01:40:06 jprice + * Clean up + * + * Revision 1.3 1999/01/30 08:21:43 jprice + * Clean up + * + * Revision 1.2 1999/01/22 04:17:40 jprice + * Formating + * + * Revision 1.1.1.1 1999/01/20 05:51:01 jprice + * Imported sources + * + * + * Rev 1.6 06 Dec 1998 8:41:00 patv + * Added new errors for new I/O subsystem. + * + * Rev 1.5 04 Jan 1998 23:14:16 patv + * Changed Log for strip utility + * + * Rev 1.4 29 May 1996 21:25:18 patv + * bug fixes for v0.91a + * + * Rev 1.3 19 Feb 1996 3:15:28 patv + * Added NLS, int2f and config.sys processing + * + * Rev 1.2 01 Sep 1995 17:35:38 patv + * First GPL release. + * + * Rev 1.1 30 Jul 1995 20:42:28 patv + * fixed ipl + * + * Rev 1.0 02 Jul 1995 10:39:36 patv + * Initial revision. + */ + +/* Internal system error returns */ +#define SUCCESS 0 /* Function was successful */ +#define DE_INVLDFUNC -1 /* Invalid function number */ +#define DE_FILENOTFND -2 /* File not found */ +#define DE_PATHNOTFND -3 /* Path not found */ +#define DE_TOOMANY -4 /* Too many open files */ +#define DE_ACCESS -5 /* Access denied */ +#define DE_INVLDHNDL -6 /* Invalid handle */ +#define DE_MCBDESTRY -7 /* Memory control blocks shot */ +#define DE_NOMEM -8 /* Insufficient memory */ +#define DE_INVLDMCB -9 /* Invalid memory control block */ +#define DE_INVLDENV -10 /* Invalid enviornement */ +#define DE_INVLDFMT -11 /* Invalid format */ +#define DE_INVLDACC -12 /* Invalid access */ +#define DE_INVLDDATA -13 /* Inavalid data */ +#define DE_INVLDDRV -15 /* Invalid drive */ +#define DE_RMVCUDIR -16 /* Attempt remove current dir */ +#define DE_DEVICE -17 /* Not same device */ +#define DE_NFILES -18 /* No more files */ +#define DE_WRTPRTCT -19 /* No more files */ +#define DE_BLKINVLD -20 /* invalid block */ +#define DE_SEEK -25 /* error on file seek */ +#define DE_HNDLDSKFULL -39 /* handle disk full (?) */ + +/* Critical error flags */ +#define EFLG_READ 0x00 /* Read error */ +#define EFLG_WRITE 0x01 /* Write error */ +#define EFLG_RSVRD 0x00 /* Error in rserved area */ +#define EFLG_FAT 0x02 /* Error in FAT area */ +#define EFLG_DIR 0x04 /* Error in dir area */ +#define EFLG_DATA 0x06 /* Error in data area */ +#define EFLG_ABORT 0x08 /* Handler can abort */ +#define EFLG_RETRY 0x10 /* Handler can retry */ +#define EFLG_IGNORE 0x20 /* Handler can ignore */ +#define EFLG_CHAR 0x80 /* Error in char or FAT image */ + +/* error results returned after asking user */ +/* MS-DOS compatible -- returned by CriticalError */ +#define CONTINUE 0 +#define RETRY 1 +#define ABORT 2 +#define FAIL 3 diff --git a/hdr/exe.h b/hdr/exe.h new file mode 100644 index 00000000..653a5960 --- /dev/null +++ b/hdr/exe.h @@ -0,0 +1,93 @@ +/****************************************************************/ +/* */ +/* exe.h */ +/* */ +/* DOS EXE Header Data Structure */ +/* */ +/* December 1, 1991 */ +/* */ +/* Copyright (c) 1995 */ +/* Pasquale J. Villani */ +/* All Rights Reserved */ +/* */ +/* This file is part of DOS-C. */ +/* */ +/* DOS-C is free software; you can redistribute it and/or */ +/* modify it under the terms of the GNU General Public License */ +/* as published by the Free Software Foundation; either version */ +/* 2, or (at your option) any later version. */ +/* */ +/* DOS-C is distributed in the hope that it will be useful, but */ +/* WITHOUT ANY WARRANTY; without even the implied warranty of */ +/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See */ +/* the GNU General Public License for more details. */ +/* */ +/* You should have received a copy of the GNU General Public */ +/* License along with DOS-C; see the file COPYING. If not, */ +/* write to the Free Software Foundation, 675 Mass Ave, */ +/* Cambridge, MA 02139, USA. */ +/****************************************************************/ + +#ifdef MAIN +#ifdef VERSION_STRINGS +static BYTE *exe_hRcsId = "$Id$"; +#endif +#endif + +/* + * $Log$ + * Revision 1.1 2000/05/06 19:34:47 jhall1 + * Initial revision + * + * Revision 1.1.1.1 1999/03/29 15:39:28 jprice + * New version without IPL.SYS + * + * Revision 1.3 1999/02/01 01:40:06 jprice + * Clean up + * + * Revision 1.2 1999/01/22 04:17:40 jprice + * Formating + * + * Revision 1.1.1.1 1999/01/20 05:51:01 jprice + * Imported sources + * + * + * Rev 1.5 04 Jan 1998 23:14:16 patv + * Changed Log for strip utility + * + * Rev 1.4 29 May 1996 21:25:18 patv + * bug fixes for v0.91a + * + * Rev 1.3 19 Feb 1996 3:15:34 patv + * Added NLS, int2f and config.sys processing + * + * Rev 1.2 01 Sep 1995 17:35:38 patv + * First GPL release. + * + * Rev 1.1 30 Jul 1995 20:41:56 patv + * Fixed ipl + * + * Rev 1.0 02 Jul 1995 10:39:38 patv + * Initial revision. + */ + +typedef struct +{ + UWORD exSignature; + UWORD exExtraBytes; + UWORD exPages; + UWORD exRelocItems; + UWORD exHeaderSize; + UWORD exMinAlloc; + UWORD exMaxAlloc; + UWORD exInitSS; + UWORD exInitSP; + UWORD exCheckSum; + UWORD exInitIP; + UWORD exInitCS; + UWORD exRelocTable; + UWORD exOverlay; +} +exe_header; + +#define MAGIC 0x5a4d diff --git a/hdr/fat.h b/hdr/fat.h new file mode 100644 index 00000000..55dfaf63 --- /dev/null +++ b/hdr/fat.h @@ -0,0 +1,139 @@ +/****************************************************************/ +/* */ +/* fat.h */ +/* */ +/* FAT File System data structures & declarations */ +/* */ +/* November 26, 1991 */ +/* */ +/* Copyright (c) 1995 */ +/* Pasquale J. Villani */ +/* All Rights Reserved */ +/* */ +/* This file is part of DOS-C. */ +/* */ +/* DOS-C is free software; you can redistribute it and/or */ +/* modify it under the terms of the GNU General Public License */ +/* as published by the Free Software Foundation; either version */ +/* 2, or (at your option) any later version. */ +/* */ +/* DOS-C is distributed in the hope that it will be useful, but */ +/* WITHOUT ANY WARRANTY; without even the implied warranty of */ +/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See */ +/* the GNU General Public License for more details. */ +/* */ +/* You should have received a copy of the GNU General Public */ +/* License along with DOS-C; see the file COPYING. If not, */ +/* write to the Free Software Foundation, 675 Mass Ave, */ +/* Cambridge, MA 02139, USA. */ +/****************************************************************/ + +#ifdef MAIN +#ifdef VERSION_STRINGS +static BYTE *fat_hRcsId = "$Id$"; +#endif +#endif + +/* + * $Log$ + * Revision 1.1 2000/05/06 19:34:48 jhall1 + * Initial revision + * + * Revision 1.2 1999/05/03 06:28:00 jprice + * Changed some variables from signed to unsigned. + * + * Revision 1.1.1.1 1999/03/29 15:39:28 jprice + * New version without IPL.SYS + * + * Revision 1.4 1999/02/01 01:40:06 jprice + * Clean up + * + * Revision 1.3 1999/01/30 08:21:43 jprice + * Clean up + * + * Revision 1.2 1999/01/22 04:17:40 jprice + * Formating + * + * Revision 1.1.1.1 1999/01/20 05:51:01 jprice + * Imported sources + * + * + * Rev 1.5 04 Jan 1998 23:14:18 patv + * Changed Log for strip utility + * + * Rev 1.4 29 May 1996 21:25:14 patv + * bug fixes for v0.91a + * + * Rev 1.3 19 Feb 1996 3:15:30 patv + * Added NLS, int2f and config.sys processing + * + * Rev 1.2 01 Sep 1995 17:35:42 patv + * First GPL release. + * + * Rev 1.1 30 Jul 1995 20:43:48 patv + * Eliminated version strings in ipl + * + * Rev 1.0 02 Jul 1995 10:39:40 patv + * Initial revision. + */ + +/* FAT file system attribute bits */ +#define D_NORMAL 0 /* normal */ +#define D_RDONLY 0x01 /* read-only file */ +#define D_HIDDEN 0x02 /* hidden */ +#define D_SYSTEM 0x04 /* system */ +#define D_VOLID 0x08 /* volume id */ +#define D_DIR 0x10 /* subdir */ +#define D_ARCHIVE 0x20 /* archive bit */ + +/* FAT file name constants */ +#define FNAME_SIZE 8 +#define FEXT_SIZE 3 + +/* FAT deleted flag */ +#define DELETED 0xe5 /* if first char, delete file */ + +/* FAT cluster to physical conversion macros */ +#define clus_add(cl_no) ((ULONG) (((ULONG) cl_no - 2L) \ + * (ULONG) cluster_size \ + + (ULONG) data_start)) + +#define clus2phys(cl_no,cl_size,d_st) ((ULONG) (((ULONG) cl_no - 2L) \ + * (ULONG) cl_size \ + + (ULONG) d_st)) + +/* Test for 16 bit or 12 bit FAT */ +#define SIZEOF_CLST16 2 +#define FAT_MAGIC 4086 + +#define ISFAT16(dpbp) (((dpbp)->dpb_size)>FAT_MAGIC) +#define ISFAT12(dpbp) (((dpbp)->dpb_size)<=FAT_MAGIC) + +/* FAT file system directory entry */ +struct dirent +{ + UBYTE dir_name[FNAME_SIZE]; /* Filename */ + UBYTE dir_ext[FEXT_SIZE]; /* Filename extension */ + UBYTE dir_attrib; /* File Attribute */ + BYTE dir_reserved[10]; /* reserved */ + time dir_time; /* Time file created/updated */ + date dir_date; /* Date file created/updated */ + UWORD dir_start; /* Starting cluster */ + /* 1st available = 2 */ + ULONG dir_size; /* File size in bytes */ +}; + +/* */ +/* filesystem sizeof(dirent) - may be different from core */ +/* */ + +#define DIR_NAME 0 +#define DIR_EXT FNAME_SIZE +#define DIR_ATTRIB FNAME_SIZE+FEXT_SIZE +#define DIR_RESERVED FNAME_SIZE+FEXT_SIZE+1 +#define DIR_TIME FNAME_SIZE+FEXT_SIZE+11 +#define DIR_DATE FNAME_SIZE+FEXT_SIZE+13 +#define DIR_START FNAME_SIZE+FEXT_SIZE+15 +#define DIR_SIZE FNAME_SIZE+FEXT_SIZE+17 + +#define DIRENT_SIZE 32 diff --git a/hdr/fcb.h b/hdr/fcb.h new file mode 100644 index 00000000..810e137f --- /dev/null +++ b/hdr/fcb.h @@ -0,0 +1,167 @@ +/****************************************************************/ +/* */ +/* fcb.h */ +/* */ +/* FAT FCB and extended FCB data structures & declarations */ +/* */ +/* November 23, 1991 */ +/* */ +/* Copyright (c) 1995 */ +/* Pasquale J. Villani */ +/* All Rights Reserved */ +/* */ +/* This file is part of DOS-C. */ +/* */ +/* DOS-C is free software; you can redistribute it and/or */ +/* modify it under the terms of the GNU General Public License */ +/* as published by the Free Software Foundation; either version */ +/* 2, or (at your option) any later version. */ +/* */ +/* DOS-C is distributed in the hope that it will be useful, but */ +/* WITHOUT ANY WARRANTY; without even the implied warranty of */ +/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See */ +/* the GNU General Public License for more details. */ +/* */ +/* You should have received a copy of the GNU General Public */ +/* License along with DOS-C; see the file COPYING. If not, */ +/* write to the Free Software Foundation, 675 Mass Ave, */ +/* Cambridge, MA 02139, USA. */ +/****************************************************************/ + +#ifdef MAIN +#ifdef VERSION_STRINGS +static BYTE *fcb_hRcsId = "$Id$"; +#endif +#endif + +/* + * $Log$ + * Revision 1.1 2000/05/06 19:34:48 jhall1 + * Initial revision + * + * Revision 1.2 1999/09/20 21:24:54 jprice + * *** empty log message *** + * + * Revision 1.1.1.1 1999/03/29 15:39:29 jprice + * New version without IPL.SYS + * + * Revision 1.3 1999/02/01 01:40:06 jprice + * Clean up + * + * Revision 1.2 1999/01/22 04:17:40 jprice + * Formating + * + * Revision 1.1.1.1 1999/01/20 05:51:01 jprice + * Imported sources + * + * + * Rev 1.6 04 Jan 1998 23:14:16 patv + * Changed Log for strip utility + * + * Rev 1.5 16 Jan 1997 12:46:06 patv + * pre-Release 0.92 feature additions + * + * Rev 1.4 29 May 1996 21:25:14 patv + * bug fixes for v0.91a + * + * Rev 1.3 19 Feb 1996 3:15:32 patv + * Added NLS, int2f and config.sys processing + * + * Rev 1.2 01 Sep 1995 17:35:42 patv + * First GPL release. + * + * Rev 1.1 30 Jul 1995 20:43:48 patv + * Eliminated version strings in ipl + * + * Rev 1.0 02 Jul 1995 10:39:40 patv + * Initial revision. + */ + +/* fcb convience defines */ +/* block device info */ +#define FID_CHARDEV 0x80 /* 1 defines character device */ + /* 0 defines block file */ +#define FID_NOWRITE 0x40 /* 0 file dirty (write occured) */ + /* 1 file has no changes */ +#define FID_MASK 0x3f /* file # */ +/* char device info */ +#define FID_EOF 0x40 /* 1 = no eof detected */ + /* 0 = end of file on input */ +#define FID_BINARY 0x20 /* 1 = binary (raw) mode device */ + /* 0 = ascii (cooked) mode device */ +#define FID_CLOCK 0x08 /* Clock device */ +#define FID_NULL 0x04 /* Null device */ +#define FID_CONOUT 0x02 /* Console output device */ +#define FID_CONIN 0x01 /* Console input device */ + +#ifndef FNAME_SIZE +#define FNAME_SIZE 8 /* limit on file name */ +#endif + +#ifndef FEXT_SIZE +#define FEXT_SIZE 3 /* limit on extension */ +#endif + +#ifndef FDFLT_DRIVE +#define FDFLT_DRIVE 0 /* default drive */ +#endif + +#define PARSE_SEP_STOP 0x01 +#define PARSE_DFLT_DRIVE 0x02 +#define PARSE_BLNK_FNAME 0x04 +#define PARSE_BLNK_FEXT 0x08 + +#define PARSE_RET_NOWILD 0 +#define PARSE_RET_WILD 1 +#define PARSE_RET_BADDRIVE 0xff + +#define FCB_READ 0 +#define FCB_WRITE 1 + +/* File Control Block (FCB) */ +typedef struct +{ + BYTE fcb_drive; /* Drive number 0=default, 1=A, etc */ + BYTE fcb_fname[FNAME_SIZE]; /* File name */ + BYTE fcb_fext[FEXT_SIZE]; /* File name Extension */ + UWORD fcb_cublock; /* Current block number of */ + /* 128 records/block, for seq. r/w */ + UWORD fcb_recsiz; /* Logical record size in bytes, */ + /* default = 128 */ + ULONG fcb_fsize; /* File size in bytes */ + date fcb_date; /* Date file created */ + time fcb_time; /* Time of last write */ + /* the following are reserved by system */ + BYTE fcb_sftno; /* Device ID */ + BYTE fcb_attrib_hi; /* share info, dev attrib word hi */ + BYTE fcb_attrib_lo; /* dev attrib word lo, open mode */ + UWORD fcb_strtclst; /* file starting cluster */ + UWORD fcb_dirclst; /* cluster of the dir entry */ + UBYTE fcb_diroff; /* offset of the dir entry */ + /* end reserved */ + UBYTE fcb_curec; /* Current block number of */ + ULONG fcb_rndm; /* Current relative record number */ +} +fcb; + +/* FAT extended fcb */ +typedef struct +{ + UBYTE xfcb_flag; /* 0xff indicates Extended FCB */ + BYTE xfcb_resvrd[5]; /* Reserved */ + UBYTE xfcb_attrib; /* Attribute */ + fcb xfcb_fcb; +} +xfcb; + +typedef struct +{ + UBYTE renDriveID; /* drive no. */ + BYTE renOldName[8]; /* Old Filename */ + BYTE renOldExtent[3]; /* Old File Extension */ + BYTE renReserved1[5]; + BYTE renNewName[8]; /* New Filename */ + BYTE renNewExtent[3]; /* New FileExtension */ + BYTE renReserved2[9]; +} +rfcb; diff --git a/hdr/file.h b/hdr/file.h new file mode 100644 index 00000000..75990ff4 --- /dev/null +++ b/hdr/file.h @@ -0,0 +1,76 @@ +/****************************************************************/ +/* */ +/* file.h */ +/* */ +/* DOS File mode flags */ +/* */ +/* December 1, 1991 */ +/* */ +/* Copyright (c) 1995 */ +/* Pasquale J. Villani */ +/* All Rights Reserved */ +/* */ +/* This file is part of DOS-C. */ +/* */ +/* DOS-C is free software; you can redistribute it and/or */ +/* modify it under the terms of the GNU General Public License */ +/* as published by the Free Software Foundation; either version */ +/* 2, or (at your option) any later version. */ +/* */ +/* DOS-C is distributed in the hope that it will be useful, but */ +/* WITHOUT ANY WARRANTY; without even the implied warranty of */ +/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See */ +/* the GNU General Public License for more details. */ +/* */ +/* You should have received a copy of the GNU General Public */ +/* License along with DOS-C; see the file COPYING. If not, */ +/* write to the Free Software Foundation, 675 Mass Ave, */ +/* Cambridge, MA 02139, USA. */ +/****************************************************************/ + +#ifdef MAIN +#ifdef VERSION_STRINGS +static BYTE *file_hRcsId = "$Id$"; +#endif +#endif + +/* + * $Log$ + * Revision 1.1 2000/05/06 19:34:48 jhall1 + * Initial revision + * + * Revision 1.1.1.1 1999/03/29 15:39:30 jprice + * New version without IPL.SYS + * + * Revision 1.3 1999/02/01 01:40:06 jprice + * Clean up + * + * Revision 1.2 1999/01/22 04:17:40 jprice + * Formating + * + * Revision 1.1.1.1 1999/01/20 05:51:01 jprice + * Imported sources + * + * + * Rev 1.5 04 Jan 1998 23:14:18 patv + * Changed Log for strip utility + * + * Rev 1.4 29 May 1996 21:25:14 patv + * bug fixes for v0.91a + * + * Rev 1.3 19 Feb 1996 3:15:32 patv + * Added NLS, int2f and config.sys processing + * + * Rev 1.2 01 Sep 1995 17:35:42 patv + * First GPL release. + * + * Rev 1.1 30 Jul 1995 20:43:48 patv + * Eliminated version strings in ipl + * + * Rev 1.0 02 Jul 1995 10:39:42 patv + * Initial revision. + */ + +#define O_RDONLY SFT_MREAD +#define O_WRONLY SFT_MWRITE +#define O_RDWR SFT_MRDWR diff --git a/hdr/fnode.h b/hdr/fnode.h new file mode 100644 index 00000000..d9415a64 --- /dev/null +++ b/hdr/fnode.h @@ -0,0 +1,115 @@ +/****************************************************************/ +/* */ +/* fnode.h */ +/* */ +/* Internal File Node for FAT File System */ +/* */ +/* January 4, 1992 */ +/* */ +/* Copyright (c) 1995 */ +/* Pasquale J. Villani */ +/* All Rights Reserved */ +/* */ +/* This file is part of DOS-C. */ +/* */ +/* DOS-C is free software; you can redistribute it and/or */ +/* modify it under the terms of the GNU General Public License */ +/* as published by the Free Software Foundation; either version */ +/* 2, or (at your option) any later version. */ +/* */ +/* DOS-C is distributed in the hope that it will be useful, but */ +/* WITHOUT ANY WARRANTY; without even the implied warranty of */ +/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See */ +/* the GNU General Public License for more details. */ +/* */ +/* You should have received a copy of the GNU General Public */ +/* License along with DOS-C; see the file COPYING. If not, */ +/* write to the Free Software Foundation, 675 Mass Ave, */ +/* Cambridge, MA 02139, USA. */ +/****************************************************************/ + +#ifdef MAIN +#ifdef VERSION_STRINGS +static BYTE *fnode_hRcsId = "$Id$"; +#endif +#endif + +/* + * $Log$ + * Revision 1.1 2000/05/06 19:34:48 jhall1 + * Initial revision + * + * Revision 1.3 2000/03/09 06:06:38 kernel + * 2017f updates by James Tabor + * + * Revision 1.2 1999/04/16 00:52:10 jprice + * Optimized FAT handling + * + * Revision 1.1.1.1 1999/03/29 15:39:30 jprice + * New version without IPL.SYS + * + * Revision 1.4 1999/02/01 01:40:06 jprice + * Clean up + * + * Revision 1.3 1999/01/30 08:21:43 jprice + * Clean up + * + * Revision 1.2 1999/01/22 04:17:40 jprice + * Formating + * + * Revision 1.1.1.1 1999/01/20 05:51:01 jprice + * Imported sources + * + * + * Rev 1.5 04 Jan 1998 23:14:18 patv + * Changed Log for strip utility + * + * Rev 1.4 29 May 1996 21:25:16 patv + * bug fixes for v0.91a + * + * Rev 1.3 19 Feb 1996 3:15:32 patv + * Added NLS, int2f and config.sys processing + * + * Rev 1.2 01 Sep 1995 17:35:42 patv + * First GPL release. + * + * Rev 1.1 30 Jul 1995 20:43:48 patv + * Eliminated version strings in ipl + * + * Rev 1.0 02 Jul 1995 10:39:44 patv + * Initial revision. + */ + +struct f_node +{ + UWORD f_count; /* number of uses of this file */ + COUNT f_mode; /* read, write, read-write, etc */ + + struct + { + BOOL f_dmod:1; /* directory has been modified */ + BOOL f_droot:1; /* directory is the root */ + BOOL f_dnew:1; /* fnode is new and needs fill */ + BOOL f_ddir:1; /* fnode is assigned to dir */ + BOOL f_dfull:1; /* directory is full */ + BOOL f_dremote:1; /* Remote Fake FNode */ + } + f_flags; /* file flags */ + + struct dirent f_dir; /* this file's dir entry image */ + + ULONG f_diroff; /* offset of the dir entry */ + UWORD f_dirstart; /* the starting cluster of dir */ + /* when dir is not root */ + struct dpb *f_dpb; /* the block device for file */ + + ULONG f_dsize; /* file size (for directories) */ + ULONG f_offset; /* byte offset for next op */ + ULONG f_highwater; /* the largest offset ever */ + UWORD f_back; /* the cluster we were at */ + ULONG f_cluster_offset; /* byte offset that the next 3 point to */ + UWORD f_cluster; /* the cluster we are at */ + UWORD f_sector; /* the sector in the cluster */ + UWORD f_boff; /* the byte in the cluster */ +}; + diff --git a/hdr/kbd.h b/hdr/kbd.h new file mode 100644 index 00000000..adac73df --- /dev/null +++ b/hdr/kbd.h @@ -0,0 +1,83 @@ +/****************************************************************/ +/* */ +/* kbd.h */ +/* */ +/* Buffered Keyboard Input data structures & declarations */ +/* */ +/* July 5, 1993 */ +/* */ +/* Copyright (c) 1995 */ +/* Pasquale J. Villani */ +/* All Rights Reserved */ +/* */ +/* This file is part of DOS-C. */ +/* */ +/* DOS-C is free software; you can redistribute it and/or */ +/* modify it under the terms of the GNU General Public License */ +/* as published by the Free Software Foundation; either version */ +/* 2, or (at your option) any later version. */ +/* */ +/* DOS-C is distributed in the hope that it will be useful, but */ +/* WITHOUT ANY WARRANTY; without even the implied warranty of */ +/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See */ +/* the GNU General Public License for more details. */ +/* */ +/* You should have received a copy of the GNU General Public */ +/* License along with DOS-C; see the file COPYING. If not, */ +/* write to the Free Software Foundation, 675 Mass Ave, */ +/* Cambridge, MA 02139, USA. */ +/****************************************************************/ + +#ifdef MAIN +#ifdef VERSION_STRINGS +static BYTE *kbd_hRcsId = "$Id$"; +#endif +#endif + +/* + * $Log$ + * Revision 1.1 2000/05/06 19:34:48 jhall1 + * Initial revision + * + * Revision 1.1.1.1 1999/03/29 15:39:31 jprice + * New version without IPL.SYS + * + * Revision 1.3 1999/02/01 01:40:06 jprice + * Clean up + * + * Revision 1.2 1999/01/22 04:17:40 jprice + * Formating + * + * Revision 1.1.1.1 1999/01/20 05:51:01 jprice + * Imported sources + * + * + * Rev 1.5 04 Jan 1998 23:14:18 patv + * Changed Log for strip utility + * + * Rev 1.4 29 May 1996 21:25:20 patv + * bug fixes for v0.91a + * + * Rev 1.3 19 Feb 1996 3:15:28 patv + * Added NLS, int2f and config.sys processing + * + * Rev 1.2 01 Sep 1995 17:35:38 patv + * First GPL release. + * + * Rev 1.1 30 Jul 1995 20:42:22 patv + * fixed ipl + * + * Rev 1.0 02 Jul 1995 10:39:46 patv + * Initial revision. + */ + +#define KBD_MAXLENGTH 256 + +/* Keyboard buffer */ +typedef struct +{ + UBYTE kb_size; /* size of buffer in bytes */ + UBYTE kb_count; /* number of bytes returned */ + BYTE kb_buf[KBD_MAXLENGTH]; /* the buffer itself */ +} +keyboard; diff --git a/hdr/mcb.h b/hdr/mcb.h new file mode 100644 index 00000000..9a428f6d --- /dev/null +++ b/hdr/mcb.h @@ -0,0 +1,102 @@ +/****************************************************************/ +/* */ +/* mcb.h */ +/* */ +/* Memory Control Block data structures and declarations */ +/* */ +/* November 23, 1991 */ +/* */ +/* Copyright (c) 1995 */ +/* Pasquale J. Villani */ +/* All Rights Reserved */ +/* */ +/* This file is part of DOS-C. */ +/* */ +/* DOS-C is free software; you can redistribute it and/or */ +/* modify it under the terms of the GNU General Public License */ +/* as published by the Free Software Foundation; either version */ +/* 2, or (at your option) any later version. */ +/* */ +/* DOS-C is distributed in the hope that it will be useful, but */ +/* WITHOUT ANY WARRANTY; without even the implied warranty of */ +/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See */ +/* the GNU General Public License for more details. */ +/* */ +/* You should have received a copy of the GNU General Public */ +/* License along with DOS-C; see the file COPYING. If not, */ +/* write to the Free Software Foundation, 675 Mass Ave, */ +/* Cambridge, MA 02139, USA. */ +/****************************************************************/ + +#ifdef MAIN +#ifdef VERSION_STRINGS +static BYTE *mcb_hRcsId = "$Id$"; +#endif +#endif + +/* + * $Log$ + * Revision 1.1 2000/05/06 19:34:48 jhall1 + * Initial revision + * + * Revision 1.2 2000/03/09 06:06:38 kernel + * 2017f updates by James Tabor + * + * Revision 1.1.1.1 1999/03/29 15:39:31 jprice + * New version without IPL.SYS + * + * Revision 1.3 1999/02/01 01:40:06 jprice + * Clean up + * + * Revision 1.2 1999/01/22 04:17:40 jprice + * Formating + * + * Revision 1.1.1.1 1999/01/20 05:51:01 jprice + * Imported sources + * + * + * Rev 1.5 04 Jan 1998 23:14:18 patv + * Changed Log for strip utility + * + * Rev 1.4 29 May 1996 21:25:16 patv + * bug fixes for v0.91a + * + * Rev 1.3 19 Feb 1996 3:15:32 patv + * Added NLS, int2f and config.sys processing + * + * Rev 1.2 01 Sep 1995 17:35:42 patv + * First GPL release. + * + * Rev 1.1 30 Jul 1995 20:43:50 patv + * Eliminated version strings in ipl + * + * Rev 1.0 02 Jul 1995 10:39:46 patv + * Initial revision. + */ + +#define LARGEST -1 +#define FIRST_FIT 0 +#define BEST_FIT 1 +#define LAST_FIT 2 + +#define MCB_NORMAL 0x4d +#define MCB_LAST 0x5a + +#define DOS_PSP 0x0050 /* 0x0008 What? seg 8 =0:0080 */ +#define FREE_PSP 0 + +#define MCB_SIZE(x) ((((LONG)(x))<<4)+sizeof(mcb)) + +typedef UWORD seg; +typedef UWORD offset; + +typedef struct +{ + BYTE m_type; /* mcb type - chain or end */ + UWORD m_psp; /* owner id via psp segment */ + UWORD m_size; /* size of segment in paragraphs */ + BYTE m_fill[3]; + BYTE m_name[8]; /* owner name limited to 8 bytes */ +} +mcb; + diff --git a/hdr/network.h b/hdr/network.h new file mode 100644 index 00000000..137e62c6 --- /dev/null +++ b/hdr/network.h @@ -0,0 +1,87 @@ +/****************************************************************/ +/* */ +/* network.h */ +/* */ +/* DOS Networking */ +/* */ +/* October 10, 1999 */ +/* */ +/* Copyright (c) 1999 */ +/* James Tabor */ +/* All Rights Reserved */ +/* */ +/* This file is part of DOS-C. */ +/* */ +/* DOS-C is free software; you can redistribute it and/or */ +/* modify it under the terms of the GNU General Public License */ +/* as published by the Free Software Foundation; either version */ +/* 2, or (at your option) any later version. */ +/* */ +/* DOS-C is distributed in the hope that it will be useful, but */ +/* WITHOUT ANY WARRANTY; without even the implied warranty of */ +/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See */ +/* the GNU General Public License for more details. */ +/* */ +/* You should have received a copy of the GNU General Public */ +/* License along with DOS-C; see the file COPYING. If not, */ +/* write to the Free Software Foundation, 675 Mass Ave, */ +/* Cambridge, MA 02139, USA. */ +/****************************************************************/ + +/* Defines for remote access functions */ +#define REM_RMDIR 0x1101 +#define REM_MKDIR 0x1103 +#define REM_CHDIR 0x1105 +#define REM_CLOSE 0x1106 +#define REM_FLUSH 0x1107 +#define REM_READ 0x1108 +#define REM_WRITE 0x1109 +#define REM_LOCK 0x110a +#define REM_UNLOCK 0x110b +#define REM_GETSPACE 0x110c +#define REM_SETATTR 0x110e +#define REM_GETATTRZ 0x110f +#define REM_RENAME 0x1111 +#define REM_DELETE 0x1113 +#define REM_OPEN 0x1116 +#define REM_CREATE 0x1117 +#define REM_CRTRWOCDS 0x1118 +#define REM_FND1WOCDS 0x1119 +#define REM_FINDFIRST 0x111B +#define REM_FINDNEXT 0x111C +#define REM_CLOSEALL 0x111d +#define REM_DOREDIRECT 0x111e +#define REM_PRINTSET 0x111f +#define REM_FLUSHALL 0x1120 +#define REM_LSEEK 0x1121 +#define REM_FILENAME 0x1123 +#define REM_PRINTREDIR 0x1125 +#define REM_EXTOC 0x112e + +struct rgds +{ + UWORD r_spc; + UWORD r_navc; + UWORD r_bps; + UWORD r_nc; +}; + +struct remote_fileattrib +{ + UWORD rfa_file; /* File Attributes */ + union + { + ULONG rfa_filesize; /* file size */ + struct + { + UWORD rfa_filesize_lo; /* DI Low */ + UWORD rfa_filesize_hi; /* BX High */ + } + _split_rfa_fz; + } + rfa_fz_union; + UWORD rfa_time; + UWORD rfa_date; +}; + + diff --git a/hdr/pcb.h b/hdr/pcb.h new file mode 100644 index 00000000..f8fd97d3 --- /dev/null +++ b/hdr/pcb.h @@ -0,0 +1,177 @@ +/****************************************************************/ +/* */ +/* pcb.h */ +/* */ +/* Process Control and Interrupt data structures */ +/* */ +/* November 26, 1991 */ +/* */ +/* Copyright (c) 1995 */ +/* Pasquale J. Villani */ +/* All Rights Reserved */ +/* */ +/* This file is part of DOS-C. */ +/* */ +/* DOS-C is free software; you can redistribute it and/or */ +/* modify it under the terms of the GNU General Public License */ +/* as published by the Free Software Foundation; either version */ +/* 2, or (at your option) any later version. */ +/* */ +/* DOS-C is distributed in the hope that it will be useful, but */ +/* WITHOUT ANY WARRANTY; without even the implied warranty of */ +/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See */ +/* the GNU General Public License for more details. */ +/* */ +/* You should have received a copy of the GNU General Public */ +/* License along with DOS-C; see the file COPYING. If not, */ +/* write to the Free Software Foundation, 675 Mass Ave, */ +/* Cambridge, MA 02139, USA. */ +/****************************************************************/ + +#ifdef MAIN +#ifdef VERSION_STRINGS +static BYTE *pcb_hRcsId = "$Id$"; +#endif +#endif + +/* + * $Log$ + * Revision 1.1 2000/05/06 19:34:49 jhall1 + * Initial revision + * + * Revision 1.1.1.1 1999/03/29 15:39:32 jprice + * New version without IPL.SYS + * + * Revision 1.3 1999/02/01 01:40:06 jprice + * Clean up + * + * Revision 1.2 1999/01/22 04:17:40 jprice + * Formating + * + * Revision 1.1.1.1 1999/01/20 05:51:01 jprice + * Imported sources + * + * + * Rev 1.6 07 Feb 1998 20:47:40 patv + * Modified stack frame to match DOS standard + * + * Rev 1.5 04 Jan 1998 23:14:18 patv + * Changed Log for strip utility + * + * Rev 1.4 29 May 1996 21:25:16 patv + * bug fixes for v0.91a + * + * Rev 1.3 19 Feb 1996 3:15:32 patv + * Added NLS, int2f and config.sys processing + * + * Rev 1.2 01 Sep 1995 17:35:44 patv + * First GPL release. + * + * Rev 1.1 30 Jul 1995 20:43:50 patv + * Eliminated version strings in ipl + * + * Rev 1.0 02 Jul 1995 10:39:48 patv + * Initial revision. + */ + +/* */ +/* interrupt handler structure definition */ +/* */ +typedef union +{ + UWORD x; /* access mode for ax, bx, etc. */ + struct + { + UBYTE l; /* access mode for al, bl, etc. */ + UBYTE h; /* access mode for ah, bh, etc. */ + } + b; +} +xreg; + +/* maps MS-DOS unique stacking order */ +typedef struct +{ + xreg a, + b, + c, + d; + UWORD si, + di, + bp, + ds, + es; + UWORD ip, + cs, + flags; +} +iregs; + +/* Process control block for task switching */ +typedef struct +{ + UWORD pc_ss; + UWORD pc_sp; + iregs pc_regs; +} +pcb; + +/* For MSC, the following offsets must match the assembly process */ +/* support offsets */ +/* NOTE: Alignemnts must be set to 1 (-Zp1) */ +/* ss: 0 */ +/* sp: 2 */ +/* es: 4 */ +/* ds: 6 */ +/* di: 8 */ +/* si: 10 */ +/* bp: 12 */ +/* sp: 14 NOTE: not used in this structure */ +/* bx: 16 */ +/* dx: 18 */ +/* cx: 20 */ +/* ax: 22 */ +/* ip: 24 */ +/* cs: 26 */ +/* flags: 28 */ +/* */ +/* For Borland C, the following offsets must match the assembly process */ +/* support offsets */ +/* ss: 0 */ +/* sp: 2 */ +/* bp: 4 */ +/* di: 6 */ +/* si: 8 */ +/* ds: 10 */ +/* es: 12 */ +/* dx: 14 */ +/* cx: 16 */ +/* bx: 18 */ +/* ax: 20 */ +/* ip: 22 */ +/* cs: 24 */ +/* flags: 26 */ + +#define BP bp +#define DI di +#define SI si +#define DS ds +#define ES es +#define DX d.x +#define CX c.x +#define BX b.x +#define AX a.x +#define DH d.b.h +#define CH c.b.h +#define BH b.b.h +#define AH a.b.h +#define DL d.b.l +#define CL c.b.l +#define BL b.b.l +#define AL a.b.l +#define IP ip +#define CS cs +#define FLAGS flags + +#define FLG_ZERO 0x0040 +#define FLG_CARRY 0x0001 diff --git a/hdr/portab.h b/hdr/portab.h new file mode 100644 index 00000000..f51b82c0 --- /dev/null +++ b/hdr/portab.h @@ -0,0 +1,201 @@ +/****************************************************************/ +/* */ +/* portab.h */ +/* */ +/* DOS-C portability typedefs, etc. */ +/* */ +/* May 1, 1995 */ +/* */ +/* Copyright (c) 1995 */ +/* Pasquale J. Villani */ +/* All Rights Reserved */ +/* */ +/* This file is part of DOS-C. */ +/* */ +/* DOS-C is free software; you can redistribute it and/or */ +/* modify it under the terms of the GNU General Public License */ +/* as published by the Free Software Foundation; either version */ +/* 2, or (at your option) any later version. */ +/* */ +/* DOS-C is distributed in the hope that it will be useful, but */ +/* WITHOUT ANY WARRANTY; without even the implied warranty of */ +/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See */ +/* the GNU General Public License for more details. */ +/* */ +/* You should have received a copy of the GNU General Public */ +/* License along with DOS-C; see the file COPYING. If not, */ +/* write to the Free Software Foundation, 675 Mass Ave, */ +/* Cambridge, MA 02139, USA. */ +/****************************************************************/ + +#ifdef MAIN +#ifdef VERSION_STRINGS +static char *portab_hRcsId = "$Id$"; +#endif +#endif + +/* + * $Log$ + * Revision 1.1 2000/05/06 19:34:49 jhall1 + * Initial revision + * + * Revision 1.2 1999/08/25 03:17:11 jprice + * ror4 patches to allow TC 2.01 compile. + * + * Revision 1.1.1.1 1999/03/29 15:39:33 jprice + * New version without IPL.SYS + * + * Revision 1.3 1999/02/01 01:40:06 jprice + * Clean up + * + * Revision 1.2 1999/01/22 04:17:40 jprice + * Formating + * + * Revision 1.1.1.1 1999/01/20 05:51:01 jprice + * Imported sources + * + * + * Rev 1.5 04 Jan 1998 23:14:16 patv + * Changed Log for strip utility + * + * Rev 1.4 29 May 1996 21:25:16 patv + * bug fixes for v0.91a + * + * Rev 1.3 19 Feb 1996 3:15:32 patv + * Added NLS, int2f and config.sys processing + * + * Rev 1.2 01 Sep 1995 17:35:44 patv + * First GPL release. + * + * Rev 1.1 30 Jul 1995 20:43:50 patv + * Eliminated version strings in ipl + * + * Rev 1.0 02 Jul 1995 10:39:50 patv + * Initial revision. + */ + +/****************************************************************/ +/* */ +/* Machine dependant portable types. Note that this section is */ +/* used primarily for segmented architectures. Common types and */ +/* types used relating to segmented operations are found here. */ +/* */ +/* Be aware that segmented architectures impose on linear */ +/* architectures because they require special types to be used */ +/* throught the code that must be reduced to empty preprocessor */ +/* replacements in the linear machine. */ +/* */ +/* #ifdef */ +/* # define FAR far */ +/* # define NEAR near */ +/* #endif */ +/* */ +/* #ifdef */ +/* # define FAR */ +/* # define NEAR */ +/* #endif */ +/* */ +/****************************************************************/ + +#ifdef MC68K + +#define far /* No far type */ +#define interrupt /* No interrupt type */ + +#define VOID void +#define FAR /* linear architecture */ +#define NEAR /* " " */ +#define INRPT interrupt + +#define CONST +#define REG register + +#define API int /* linear architecture */ +#define NONNATIVE + +#define PARASIZE 4096 /* "paragraph" size */ +#endif + +#ifdef I86 + +#define VOID void +#define FAR far /* segment architecture */ +#define NEAR near /* " " */ +#define INRPT interrupt + +#define CONST const +#define REG register + +#define API int far pascal /* segment architecture */ +#define NATIVE + +#define PARASIZE 16 /* "paragraph" size */ +#endif + +/* */ +/* Boolean type & definitions of TRUE and FALSE boolean values */ +/* */ +typedef int BOOL; +#define FALSE (1==0) +#define TRUE (1==1) + +/* */ +/* Common pointer types */ +/* */ +#ifndef NULL +#define NULL 0 +#endif + +/* */ +/* Convienence defines */ +/* */ +#define FOREVER while(TRUE) +#ifndef max +#define max(a,b) (((a) > (b)) ? (a) : (b)) +#endif +#ifndef min +#define min(a,b) (((a) < (b)) ? (a) : (b)) +#endif + +/* */ +/* Common byte, 16 bit and 32 bit types */ +/* */ +typedef char BYTE; +typedef short WORD; +typedef long DWORD; + +typedef unsigned char UBYTE; +typedef unsigned short UWORD; + +typedef short SHORT; + +typedef unsigned int BITS; /* for use in bit fields(!) */ + +typedef int COUNT; +typedef unsigned int UCOUNT; +typedef unsigned long ULONG; + +#ifdef UNIX +typedef char FAR *ADDRESS; +#else +typedef void FAR *ADDRESS; +#endif + +#ifdef STRICT +typedef signed long LONG; +#else +#define LONG long +#endif + +/* General far pointer macros */ +#ifdef I86 +#define MK_FP(seg,ofs) ((VOID far *)(((LONG)(seg)<<16)|(UWORD)(ofs))) +#define FP_SEG(fp) ((UWORD)((LONG)(VOID FAR *)(fp)>>16)) +#define FP_OFF(fp) ((UWORD)(fp)) +#endif + +#ifdef MC68K +#define MK_FP(seg,ofs) ((VOID *)(&(((BYTE *)(seg))[(ofs)]))) +#define FP_SEG(fp) (0) +#define FP_OFF(fp) (fp) +#endif diff --git a/hdr/process.h b/hdr/process.h new file mode 100644 index 00000000..830c4cb4 --- /dev/null +++ b/hdr/process.h @@ -0,0 +1,172 @@ +/****************************************************************/ +/* */ +/* process.h */ +/* */ +/* DOS exec data structures & declarations */ +/* */ +/* November 23, 1991 */ +/* */ +/* Copyright (c) 1995 */ +/* Pasquale J. Villani */ +/* All Rights Reserved */ +/* */ +/* This file is part of DOS-C. */ +/* */ +/* DOS-C is free software; you can redistribute it and/or */ +/* modify it under the terms of the GNU General Public License */ +/* as published by the Free Software Foundation; either version */ +/* 2, or (at your option) any later version. */ +/* */ +/* DOS-C is distributed in the hope that it will be useful, but */ +/* WITHOUT ANY WARRANTY; without even the implied warranty of */ +/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See */ +/* the GNU General Public License for more details. */ +/* */ +/* You should have received a copy of the GNU General Public */ +/* License along with DOS-C; see the file COPYING. If not, */ +/* write to the Free Software Foundation, 675 Mass Ave, */ +/* Cambridge, MA 02139, USA. */ +/****************************************************************/ + +#ifdef MAIN +#ifdef VERSION_STRINGS +static BYTE *process_hRcsId = "$Id$"; +#endif +#endif + +/* + * $Log$ + * Revision 1.1 2000/05/06 19:34:49 jhall1 + * Initial revision + * + * Revision 1.1.1.1 1999/03/29 15:39:34 jprice + * New version without IPL.SYS + * + * Revision 1.3 1999/02/01 01:40:06 jprice + * Clean up + * + * Revision 1.2 1999/01/22 04:17:40 jprice + * Formating + * + * Revision 1.1.1.1 1999/01/20 05:51:01 jprice + * Imported sources + * + * + * Rev 1.7 22 Jan 1998 22:13:00 patv + * Had to change ps_prevps to VOID FAR * due to BC++ error. + * + * Rev 1.6 22 Jan 1998 22:05:22 patv + * Corrected ps_prevpsp declaration. + * + * Rev 1.5 04 Jan 1998 23:14:16 patv + * Changed Log for strip utility + * + * Rev 1.4 29 May 1996 21:25:16 patv + * bug fixes for v0.91a + * + * Rev 1.3 19 Feb 1996 3:15:32 patv + * Added NLS, int2f and config.sys processing + * + * Rev 1.2 01 Sep 1995 17:35:44 patv + * First GPL release. + * + * Rev 1.1 30 Jul 1995 20:43:50 patv + * Eliminated version strings in ipl + * + * Rev 1.0 02 Jul 1995 10:39:52 patv + * Initial revision. + */ + +/* Modes available as first argument to the spawnxx functions. */ + +#define P_WAIT 0 /* child runs separately, parent waits until exit */ +#define P_NOWAIT 1 /* both concurrent -- not implemented */ +#define P_OVERLAY 2 /* child replaces parent, parent no longer exists */ + +typedef struct +{ + union + { + struct + { + UWORD load_seg; + UWORD reloc; + } + _load; + struct + { + UWORD env_seg; + CommandTail FAR *cmd_line; + BYTE FAR *fcb_1; + BYTE FAR *fcb_2; + BYTE FAR *stack; + BYTE FAR *start_addr; + } + _exec; + } + ldata; +} +exec_blk; + +#define exec ldata._exec +#define load ldata._load + +typedef struct +{ + UWORD ps_exit; /* CP/M-like exit poimt */ + UWORD ps_size; /* memory size in paragraphs */ + BYTE ps_fill1; /* single char fill */ + + /* CP/M-like entry point */ + BYTE ps_farcall; /* far call opcode */ + VOID(FAR * ps_reentry) (); /* re-entry point */ + VOID(interrupt FAR * ps_isv22) (), /* terminate address */ + (interrupt FAR * ps_isv23) (), /* break address */ + (interrupt FAR * ps_isv24) (); /* critical error address */ + UWORD ps_parent; /* parent psp segment */ + UBYTE ps_files[20]; /* file table - 0xff is unused */ + UWORD ps_environ; /* environment paragraph */ + BYTE FAR *ps_stack; /* user stack pointer - int 21 */ + WORD ps_maxfiles; /* maximum open files */ + UBYTE FAR *ps_filetab; /* open file table pointer */ + VOID FAR *ps_prevpsp; /* previous psp pointer */ + BYTE FAR *ps_dta; /* process dta address */ + BYTE ps_fill2[16]; + BYTE ps_unix[3]; /* unix style call - 0xcd 0x21 0xcb */ + BYTE ps_fill3[9]; + union + { + struct + { + fcb + _ps_fcb1; /* first command line argument */ + } + _u1; + struct + { + BYTE + fill4[16]; + fcb + _ps_fcb2; /* second command line argument */ + } + _u2; + struct + { + BYTE fill5[36]; + struct + { + BYTE _ps_cmd_count; + BYTE _ps_cmd[127]; /* command tail */ + } + _u4; + } + _u3; + } + _u; +} +psp; + +#define ps_fcb1 _u._u1._ps_fcb1 +#define ps_fcb2 _u._u2._ps_fcb2 +#define ps_cmd _u._u3._u4._ps_cmd +#define ps_cmd_count _u._u3._u4._ps_cmd_count diff --git a/hdr/sft.h b/hdr/sft.h new file mode 100644 index 00000000..7314e305 --- /dev/null +++ b/hdr/sft.h @@ -0,0 +1,199 @@ +/****************************************************************/ +/* */ +/* sft.h */ +/* DOS-C */ +/* */ +/* DOS System File Table Structure */ +/* */ +/* Copyright (c) 1995, 1996 */ +/* Pasquale J. Villani */ +/* All Rights Reserved */ +/* */ +/* This file is part of DOS-C. */ +/* */ +/* DOS-C is free software; you can redistribute it and/or */ +/* modify it under the terms of the GNU General Public License */ +/* as published by the Free Software Foundation; either version */ +/* 2, or (at your option) any later version. */ +/* */ +/* DOS-C is distributed in the hope that it will be useful, but */ +/* WITHOUT ANY WARRANTY; without even the implied warranty of */ +/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See */ +/* the GNU General Public License for more details. */ +/* */ +/* You should have received a copy of the GNU General Public */ +/* License along with DOS-C; see the file COPYING. If not, */ +/* write to the Free Software Foundation, 675 Mass Ave, */ +/* Cambridge, MA 02139, USA. */ +/****************************************************************/ + +#ifdef MAIN +#ifdef VERSION_STRINGS +static BYTE *sft_hRcsId = "$Id$"; +#endif +#endif + +/* + * $Log$ + * Revision 1.1 2000/05/06 19:34:50 jhall1 + * Initial revision + * + * Revision 1.3 2000/03/09 06:06:38 kernel + * 2017f updates by James Tabor + * + * Revision 1.2 1999/04/04 18:50:25 jprice + * no message + * + * Revision 1.1.1.1 1999/03/29 15:39:35 jprice + * New version without IPL.SYS + * + * Revision 1.3 1999/02/01 01:40:06 jprice + * Clean up + * + * Revision 1.2 1999/01/22 04:17:40 jprice + * Formating + * + * Revision 1.1.1.1 1999/01/20 05:51:01 jprice + * Imported sources + * + * + * Rev 1.6 04 Jan 1998 23:14:18 patv + * Changed Log for strip utility + * + * Rev 1.5 16 Jan 1997 12:46:04 patv + * pre-Release 0.92 feature additions + * + * Rev 1.4 29 May 1996 21:25:18 patv + * bug fixes for v0.91a + * + * Rev 1.3 19 Feb 1996 3:15:34 patv + * Added NLS, int2f and config.sys processing + * + * Rev 1.2 01 Sep 1995 17:35:44 patv + * First GPL release. + * + * Rev 1.1 30 Jul 1995 20:43:50 patv + * Eliminated version strings in ipl + * + * Rev 1.0 02 Jul 1995 10:39:52 patv + * Initial revision. + */ + +#define SFTMAX 128 + +/* Handle Definition entry */ +typedef struct +{ + WORD sft_count; /* reference count */ + WORD sft_mode; /* open mode - see below */ + BYTE sft_attrib; /* file attribute - dir style */ + + union + { + WORD _sft_flags; + struct + { + BYTE _sft_flags_lo; + BYTE _sft_flags_hi; + } + _split_sft_flags; + } + sft_flags_union; + + union + { + struct dpb FAR * + _sft_dcb; /* The device control block */ + struct dhdr FAR * + _sft_dev; /* device driver for char dev */ + } + sft_dcb_or_dev; + WORD sft_stclust; /* Starting cluster */ + time sft_time; /* File time */ + date sft_date; /* File date */ + LONG sft_size; /* File size */ + LONG sft_posit; /* Current file position */ + WORD sft_relclust; /* File relative cluster */ + WORD sft_cuclust; /* File current cluster */ + WORD sft_dirdlust; /* Sector containing cluster */ + BYTE sft_diridx; /* directory index */ + BYTE sft_name[11]; /* dir style file name */ + BYTE FAR * + sft_bshare; /* backward link of file sharing sft */ + WORD sft_mach; /* machine number - network apps */ + WORD sft_psp; /* owner psp */ + WORD sft_shroff; /* Sharing offset */ + WORD sft_status; /* this sft status */ +} +sft; + +/* SFT Table header definition */ +typedef struct _sftheader +{ + struct _sfttbl FAR * /* link to next table in list */ + sftt_next; + WORD sftt_count; /* # of handle definition */ + /* entries, this table */ +} +sftheader; + +/* System File Definition List */ +typedef struct _sfttbl +{ + struct _sfttbl FAR * /* link to next table in list */ + sftt_next; + WORD sftt_count; /* # of handle definition */ + /* entries, this table */ + sft sftt_table[SFTMAX]; /* The array of sft for block */ +} +sfttbl; + +/* defines for sft use */ +#define SFT_MASK 0x0060 /* splits device data */ + +/* mode bits */ +#define SFT_MFCB 0x8000 /* entry is for fcb */ +#define SFT_MDENYNONE 0x0040 /* sharing bits */ +#define SFT_MDENYREAD 0x0030 /* " " */ +#define SFT_MDENYWRITE 0x0020 /* " " */ +#define SFT_MEXCLUSIVE 0x0010 /* " " */ +#define SFT_NOINHERIT 0x0080 /* inhibit inherting of file */ +#define SFT_NETFCB 0x0070 /* networked fcb */ +#define SFT_MSHAREMASK 0x0070 /* mask to isolate shared bits */ +#define SFT_MRDWR 0x0002 /* read/write bit */ +#define SFT_MWRITE 0x0001 /* write bit */ +#define SFT_MREAD 0x0000 /* ~ write bit */ +#define SFT_OMASK 0x00f3 /* valid open mask */ + +/* flag bits */ + +/* the following bit is for redirection */ +#define SFT_FSHARED 0x8000 /* Networked access */ + +/* the following entry differntiates char & block access */ +#define SFT_FDEVICE 0x0080 /* device entry */ + +/* the following bits are file (block) unique */ +#define SFT_FDATE 0x4000 /* File date set */ +#define SFT_FDIRTY 0x0040 /* File has been written to */ +#define SFT_FDMASK 0x003f /* File mask for drive no */ + +/* the following bits are device (char) unique */ +#define SFT_FIOCTL 0x4000 /* IOCTL support - device */ +#define SFT_FEOF 0x0040 /* device eof */ +#define SFT_FBINARY 0x0020 /* device binary mode */ +#define SFT_FSPECIAL 0x0010 /* int 29 support */ +#define SFT_FCLOCK 0x0008 /* device is clock */ +#define SFT_FNUL 0x0004 /* device is nul */ +#define SFT_FCONOUT 0x0002 /* device is console output */ +#define SFT_FCONIN 0x0001 /* device is console input */ + +/* Covienence defines */ +#define sft_dcb sft_dcb_or_dev._sft_dcb +#define sft_dev sft_dcb_or_dev._sft_dev + +#define sft_flags sft_flags_union._sft_flags +#define sft_flags_hi sft_flags_union._split_sft_flags._sft_flags_hi +#define sft_flags_lo sft_flags_union._split_sft_flags._sft_flags_lo + + diff --git a/hdr/stacks.inc b/hdr/stacks.inc new file mode 100644 index 00000000..25503f71 --- /dev/null +++ b/hdr/stacks.inc @@ -0,0 +1,136 @@ +; +; File: +; stacks.inc +; Description: +; Macro support for register stack frame +; +; Copyright (c) 1998 +; Pasquale J. Villani +; All Rights Reserved +; +; This file is part of DOS-C. +; +; DOS-C is free software; you can redistribute it and/or +; modify it under the terms of the GNU General Public License +; as published by the Free Software Foundation; either version +; 2, or (at your option) any later version. +; +; DOS-C is distributed in the hope that it will be useful, but +; WITHOUT ANY WARRANTY; without even the implied warranty of +; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See +; the GNU General Public License for more details. +; +; You should have received a copy of the GNU General Public +; License along with DOS-C; see the file COPYING. If not, +; write to the Free Software Foundation, 675 Mass Ave, +; Cambridge, MA 02139, USA. +; +; $Logfile: C:/dos-c/hdr/stacks.inv $ +; +; $Id$ +; +; $Log$ +; Revision 1.1 2000/05/06 19:34:50 jhall1 +; Initial revision +; +; Revision 1.3 2000/03/09 06:06:38 kernel +; 2017f updates by James Tabor +; +; Revision 1.2 1999/08/10 17:56:26 jprice +; ror4 2011-02 patch +; +; Revision 1.1.1.1 1999/03/29 15:39:35 jprice +; New version without IPL.SYS +; +; Revision 1.3 1999/02/01 01:40:06 jprice +; Clean up +; +; Revision 1.2 1999/01/22 04:17:40 jprice +; Formating +; +; Revision 1.1.1.1 1999/01/20 05:51:01 jprice +; Imported sources +; +; +; Rev 1.0 07 Feb 1998 20:59:16 patv +;Modified stack frame to match DOS standard +; $EndLog$ + + +; +; Standard stack frame used throughout DOS-C +; +; MS-DOS specific +; +; +---------------+ +; | irp hi | 26 +; +---------------+ +; | irp low | 24 +; +---------------+ +; | flags | 22 +; +---------------+ +; | cs | 20 +; +---------------+ +; | ip | 18 +; +---------------+ +; | es | 16 +; +---------------+ +; | ds | 14 +; +---------------+ +; | bp | 12 +; +---------------+ +; | di | 10 +; +---------------+ +; | si | 8 +; +---------------+ +; | dx | 6 +; +---------------+ +; | cx | 4 +; +---------------+ +; | bx | 2 +; +---------------+ +; | ax | 0 +; +---------------+ +; + +; Don't use `struc RegFrame' etc. here because it interferes with segment +; definitions. +reg_ax equ 0 +reg_bx equ 2 +reg_cx equ 4 +reg_dx equ 6 +reg_si equ 8 +reg_di equ 10 +reg_bp equ 12 +reg_ds equ 14 +reg_es equ 16 +reg_ip equ 18 +reg_cs equ 20 +reg_flags equ 22 +irp_low equ 24 +irp_hi equ 26 + +%macro PUSH$ALL 0 + push es + push ds + push bp + push di + push si + push dx + push cx + push bx + push ax +%endmacro + +%macro POP$ALL 0 + pop ax + pop bx + pop cx + pop dx + pop si + pop di + pop bp + pop ds + pop es +%endmacro + diff --git a/hdr/tail.h b/hdr/tail.h new file mode 100644 index 00000000..7e507777 --- /dev/null +++ b/hdr/tail.h @@ -0,0 +1,83 @@ +/****************************************************************/ +/* */ +/* tail.h */ +/* */ +/* Command tail data structures */ +/* */ +/* July 1, 1993 */ +/* */ +/* Copyright (c) 1995 */ +/* Pasquale J. Villani */ +/* All Rights Reserved */ +/* */ +/* This file is part of DOS-C. */ +/* */ +/* DOS-C is free software; you can redistribute it and/or */ +/* modify it under the terms of the GNU General Public License */ +/* as published by the Free Software Foundation; either version */ +/* 2, or (at your option) any later version. */ +/* */ +/* DOS-C is distributed in the hope that it will be useful, but */ +/* WITHOUT ANY WARRANTY; without even the implied warranty of */ +/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See */ +/* the GNU General Public License for more details. */ +/* */ +/* You should have received a copy of the GNU General Public */ +/* License along with DOS-C; see the file COPYING. If not, */ +/* write to the Free Software Foundation, 675 Mass Ave, */ +/* Cambridge, MA 02139, USA. */ +/****************************************************************/ + +#ifdef MAIN +#ifdef VERSION_STRINGS +static BYTE *tail_hRcsId = "$Id$"; +#endif +#endif + +/* + * $Log$ + * Revision 1.1 2000/05/06 19:34:50 jhall1 + * Initial revision + * + * Revision 1.1.1.1 1999/03/29 15:39:36 jprice + * New version without IPL.SYS + * + * Revision 1.3 1999/02/01 01:40:06 jprice + * Clean up + * + * Revision 1.2 1999/01/22 04:17:40 jprice + * Formating + * + * Revision 1.1.1.1 1999/01/20 05:51:01 jprice + * Imported sources + * + * + * Rev 1.5 04 Jan 1998 23:14:16 patv + * Changed Log for strip utility + * + * Rev 1.4 29 May 1996 21:25:18 patv + * bug fixes for v0.91a + * + * Rev 1.3 19 Feb 1996 3:15:34 patv + * Added NLS, int2f and config.sys processing + * + * Rev 1.2 01 Sep 1995 17:35:44 patv + * First GPL release. + * + * Rev 1.1 30 Jul 1995 20:43:50 patv + * Eliminated version strings in ipl + * + * Rev 1.0 02 Jul 1995 10:39:54 patv + * Initial revision. + */ + +#ifndef LINESIZE +#define LINESIZE 127 +#endif + +typedef struct +{ + UBYTE ctCount; /* number of bytes returned */ + BYTE ctBuffer[LINESIZE]; /* the buffer itself */ +} +CommandTail; diff --git a/hdr/time.h b/hdr/time.h new file mode 100644 index 00000000..b945a37c --- /dev/null +++ b/hdr/time.h @@ -0,0 +1,91 @@ +/****************************************************************/ +/* */ +/* time.h */ +/* */ +/* DOS General Time Structure */ +/* */ +/* January 21, 1993 */ +/* */ +/* Copyright (c) 1995 */ +/* Pasquale J. Villani */ +/* All Rights Reserved */ +/* */ +/* This file is part of DOS-C. */ +/* */ +/* DOS-C is free software; you can redistribute it and/or */ +/* modify it under the terms of the GNU General Public License */ +/* as published by the Free Software Foundation; either version */ +/* 2, or (at your option) any later version. */ +/* */ +/* DOS-C is distributed in the hope that it will be useful, but */ +/* WITHOUT ANY WARRANTY; without even the implied warranty of */ +/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See */ +/* the GNU General Public License for more details. */ +/* */ +/* You should have received a copy of the GNU General Public */ +/* License along with DOS-C; see the file COPYING. If not, */ +/* write to the Free Software Foundation, 675 Mass Ave, */ +/* Cambridge, MA 02139, USA. */ +/****************************************************************/ + +/* TC 2.01 complains if `time' is defined twice. -- ror4 */ +#ifndef DOSC_TIME_H +#define DOSC_TIME_H + +#ifdef MAIN +#ifdef VERSION_STRINGS +static BYTE *time_hRcsId = "$Id$"; +#endif +#endif + +/* + * $Log$ + * Revision 1.1 2000/05/06 19:34:50 jhall1 + * Initial revision + * + * Revision 1.2 1999/08/25 03:17:11 jprice + * ror4 patches to allow TC 2.01 compile. + * + * Revision 1.1.1.1 1999/03/29 15:39:36 jprice + * New version without IPL.SYS + * + * Revision 1.3 1999/02/01 01:40:06 jprice + * Clean up + * + * Revision 1.2 1999/01/22 04:17:40 jprice + * Formating + * + * Revision 1.1.1.1 1999/01/20 05:51:01 jprice + * Imported sources + * + * + * Rev 1.5 04 Jan 1998 23:14:16 patv + * Changed Log for strip utility + * + * Rev 1.4 29 May 1996 21:25:18 patv + * bug fixes for v0.91a + * + * Rev 1.3 19 Feb 1996 3:15:34 patv + * Added NLS, int2f and config.sys processing + * + * Rev 1.2 01 Sep 1995 17:35:46 patv + * First GPL release. + * + * Rev 1.1 30 Jul 1995 20:43:50 patv + * Eliminated version strings in ipl + * + * Rev 1.0 02 Jul 1995 10:39:56 patv + * Initial revision. + */ + +/* FAT Time notation in the form of hhhh hmmm mmmd dddd */ + +#define TM_HOUR(t) (((t)>>11)&0x1f) +#define TM_MIN(t) (((t)>>5)&0x3f) +#define TM_DEC(t) ((t)&0x1f) + +#define TM_ENCODE(h,m,d) ((((h&0x1f))<<11)|(((m)&0x3f)<<5)|((d)&0x1f)) + +typedef UWORD time; + +#endif diff --git a/hdr/version.h b/hdr/version.h new file mode 100644 index 00000000..f3033073 --- /dev/null +++ b/hdr/version.h @@ -0,0 +1,46 @@ +/****************************************************************/ +/* */ +/* version.h */ +/* */ +/* Common version information */ +/* */ +/* Copyright (c) 1997 */ +/* Pasquale J. Villani */ +/* All Rights Reserved */ +/* */ +/* This file is part of DOS-C. */ +/* */ +/* DOS-C is free software; you can redistribute it and/or */ +/* modify it under the terms of the GNU General Public License */ +/* as published by the Free Software Foundation; either version */ +/* 2, or (at your option) any later version. */ +/* */ +/* DOS-C is distributed in the hope that it will be useful, but */ +/* WITHOUT ANY WARRANTY; without even the implied warranty of */ +/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See */ +/* the GNU General Public License for more details. */ +/* */ +/* You should have received a copy of the GNU General Public */ +/* License along with DOS-C; see the file COPYING. If not, */ +/* write to the Free Software Foundation, 675 Mass Ave, */ +/* Cambridge, MA 02139, USA. */ +/****************************************************************/ + +#ifdef MAIN +#ifdef VERSION_STRINGS +static BYTE *date_hRcsId = "$Id$"; +#endif +#endif + +/* This Kernel is at a min Dos Ver. 4.00 */ + +#define MAJOR_RELEASE 4 +#define MINOR_RELEASE 00 + +#define REV_NUMBER 0 +#define OEM_ID 0xfd /* FreeDos version */ + +#define REVISION_MAJOR 1 +#define REVISION_MINOR 1 +#define REVISION_SEQ 18 +#define BUILD 2018 diff --git a/kernel/001-437.nls b/kernel/001-437.nls new file mode 100644 index 00000000..780c9c53 --- /dev/null +++ b/kernel/001-437.nls @@ -0,0 +1,233 @@ + +/****************************************************************/ +/* */ +/* 001-437.nls */ +/* DOS-C */ +/* */ +/* National Languge Support USA Code Page */ +/* */ +/* Copyright (c) 1996 */ +/* Pasquale J. Villani */ +/* All Rights Reserved */ +/* */ +/* Copyright (c) 1996 */ +/* Steffen Kaiser */ +/* All Rights Reserved */ +/* */ +/* This file is part of DOS-C. */ +/* */ +/* DOS-C is free software; you can redistribute it and/or */ +/* modify it under the terms of the GNU General Public License */ +/* as published by the Free Software Foundation; either version */ +/* 2, or (at your option) any later version. */ +/* */ +/* DOS-C is distributed in the hope that it will be useful, but */ +/* WITHOUT ANY WARRANTY; without even the implied warranty of */ +/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See */ +/* the GNU General Public License for more details. */ +/* */ +/* You should have received a copy of the GNU General Public */ +/* License along with DOS-C; see the file COPYING. If not, */ +/* write to the Free Software Foundation, 675 Mass Ave, */ +/* Cambridge, MA 02139, USA. */ +/****************************************************************/ + +/* $Logfile: D:/dos-c/src/kernel/001-437.nlv $ */ +#ifdef VERSION_STRINGS +static BYTE *RcsId = "$Header$"; +#endif + +/* + * $Log$ + * Revision 1.1 2000/05/06 19:34:52 jhall1 + * Initial revision + * + * Revision 1.2 2000/03/09 06:07:10 kernel + * 2017f updates by James Tabor + * + * Revision 1.1.1.1 1999/03/29 15:40:36 jprice + * New version without IPL.SYS + * + * Revision 1.2 1999/01/22 04:13:25 jprice + * Formating + * + * Revision 1.1.1.1 1999/01/20 05:51:01 jprice + * Imported sources + * + * + * Rev 1.2 29 May 1996 21:03:46 patv + * bug fixes for v0.91a + * + * Rev 1.1 19 Feb 1996 4:34:48 patv + * Corrected typo + * + * Rev 1.0 19 Feb 1996 3:37:48 patv + * Initial revision. + */ + +/* This initialization segment is included into the file where needed. */ +/* It's cuurently included in the following file: nls.c. */ +{ + { + { + 0, 0, 0, 0, 0, 0, 0, 0 + } + , + "\\COUNTRY.SYS", + 437, + 6, + { + { + (VOID FAR *) & nlsInfo.upNCsize, 2 + } + , + { + (VOID FAR *) & nlsInfo.upFCsize, 4 + } + , + { + (VOID FAR *) & nlsInfo.nlsFn, 5 + } + , + { + (VOID FAR *) & nlsInfo.collSize, 6 + } + , + { + (VOID FAR *) & nlsInfo.nlsExtCtryInfo.countryCode, 1 + } + , + { + (VOID FAR *) & nlsInfo.dbcSize, 7 + } + } + , + + 1, /* country code */ + 437, /* code page */ + { + 0, /* date format */ + { + /* currency string */ + '$', '\x00', '\x00', '\x00', '\x00', /* 0 - 4 */ + } + , + { /* thousand separator */ + ',', '\x00' /* 0 - 1 */ + } + , + { /* decimal point */ + '.', '\x00' /* 0 - 1 */ + } + , + { /* date separator */ + '-', '\x00' /* 0 - 1 */ + } + , + { /* time separator */ + ':', '\x00' /* 0 - 1 */ + } + , + 0, /* currency format */ + 2, /* currency prescision */ + 0, /* time format */ + CharMapSrvc, /* upcase function */ + { /* data separator */ + ',', '\x00' /* 0 - 1 */ + } + } + } + , + 'Y', 'N', /* Yes/No prompt characters */ + 128, /* upcase table */ + { + '\x80', '\x9a', 'E', 'A', '\x8e', 'A', '\x8f', '\x80' /* 0 - 7 */ + ,'E', 'E', 'E', 'I', 'I', 'I', '\x8e', '\x8f' /* 8 - 15 */ + ,'\x90', '\x92', '\x92', 'O', '\x99', 'O', 'U', 'U' /* 16 - 23 */ + ,'Y', '\x99', '\x9a', '\x9b', '\x9c', '\x9d', '\x9e', '\x9f' /* 24 - 31 */ + ,'A', 'I', 'O', 'U', '\xa5', '\xa5', '\xa6', '\xa7' /* 32 - 39 */ + ,'\xa8', '\xa9', '\xaa', '\xab', '\xac', '\xad', '\xae', '\xaf' /* 40 - 47 */ + ,'\xb0', '\xb1', '\xb2', '\xb3', '\xb4', '\xb5', '\xb6', '\xb7' /* 48 - 55 */ + ,'\xb8', '\xb9', '\xba', '\xbb', '\xbc', '\xbd', '\xbe', '\xbf' /* 56 - 63 */ + ,'\xc0', '\xc1', '\xc2', '\xc3', '\xc4', '\xc5', '\xc6', '\xc7' /* 64 - 71 */ + ,'\xc8', '\xc9', '\xca', '\xcb', '\xcc', '\xcd', '\xce', '\xcf' /* 72 - 79 */ + ,'\xd0', '\xd1', '\xd2', '\xd3', '\xd4', '\xd5', '\xd6', '\xd7' /* 80 - 87 */ + ,'\xd8', '\xd9', '\xda', '\xdb', '\xdc', '\xdd', '\xde', '\xdf' /* 88 - 95 */ + ,'\xe0', '\xe1', '\xe2', '\xe3', '\xe4', '\xe5', '\xe6', '\xe7' /* 96 - 103 */ + ,'\xe8', '\xe9', '\xea', '\xeb', '\xec', '\xed', '\xee', '\xef' /* 104 - 111 */ + ,'\xf0', '\xf1', '\xf2', '\xf3', '\xf4', '\xf5', '\xf6', '\xf7' /* 112 - 119 */ + ,'\xf8', '\xf9', '\xfa', '\xfb', '\xfc', '\xfd', '\xfe', '\xff' /* 120 - 127 */ + } + , + 128, /* file name upcase table */ + { + '\x80', '\x9a', 'E', 'A', '\x8e', 'A', '\x8f', '\x80' /* 0 - 7 */ + ,'E', 'E', 'E', 'I', 'I', 'I', '\x8e', '\x8f' /* 8 - 15 */ + ,'\x90', '\x92', '\x92', 'O', '\x99', 'O', 'U', 'U' /* 16 - 23 */ + ,'Y', '\x99', '\x9a', '\x9b', '\x9c', '\x9d', '\x9e', '\x9f' /* 24 - 31 */ + ,'A', 'I', 'O', 'U', '\xa5', '\xa5', '\xa6', '\xa7' /* 32 - 39 */ + ,'\xa8', '\xa9', '\xaa', '\xab', '\xac', '\xad', '\xae', '\xaf' /* 40 - 47 */ + ,'\xb0', '\xb1', '\xb2', '\xb3', '\xb4', '\xb5', '\xb6', '\xb7' /* 48 - 55 */ + ,'\xb8', '\xb9', '\xba', '\xbb', '\xbc', '\xbd', '\xbe', '\xbf' /* 56 - 63 */ + ,'\xc0', '\xc1', '\xc2', '\xc3', '\xc4', '\xc5', '\xc6', '\xc7' /* 64 - 71 */ + ,'\xc8', '\xc9', '\xca', '\xcb', '\xcc', '\xcd', '\xce', '\xcf' /* 72 - 79 */ + ,'\xd0', '\xd1', '\xd2', '\xd3', '\xd4', '\xd5', '\xd6', '\xd7' /* 80 - 87 */ + ,'\xd8', '\xd9', '\xda', '\xdb', '\xdc', '\xdd', '\xde', '\xdf' /* 88 - 95 */ + ,'\xe0', '\xe1', '\xe2', '\xe3', '\xe4', '\xe5', '\xe6', '\xe7' /* 96 - 103 */ + ,'\xe8', '\xe9', '\xea', '\xeb', '\xec', '\xed', '\xee', '\xef' /* 104 - 111 */ + ,'\xf0', '\xf1', '\xf2', '\xf3', '\xf4', '\xf5', '\xf6', '\xf7' /* 112 - 119 */ + ,'\xf8', '\xf9', '\xfa', '\xfb', '\xfc', '\xfd', '\xfe', '\xff' /* 120 - 127 */ + } + , + 256, /* collating sequence table */ + { + '\x00', '\x01', '\x02', '\x03', '\x04', '\x05', '\x06', '\x07' /* 0 - 7 */ + ,'\x08', '\x09', '\x0a', '\x0b', '\x0c', '\x0d', '\x0e', '\x0f' /* 8 - 15 */ + ,'\x10', '\x11', '\x12', '\x13', '\x14', '\x15', '\x16', '\x17' /* 16 - 23 */ + ,'\x18', '\x19', '\x1a', '\x1b', '\x1c', '\x1d', '\x1e', '\x1f' /* 24 - 31 */ + ,' ', '!', '"', '#', '$', '%', '&', '\'' /* 32 - 39 */ + ,'(', ')', '*', '+', ',', '-', '.', '/' /* 40 - 47 */ + ,'0', '1', '2', '3', '4', '5', '6', '7' /* 48 - 55 */ + ,'8', '9', ':', ';', '<', '=', '>', '?' /* 56 - 63 */ + ,'@', 'A', 'B', 'C', 'D', 'E', 'F', 'G' /* 64 - 71 */ + ,'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O' /* 72 - 79 */ + ,'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W' /* 80 - 87 */ + ,'X', 'Y', 'Z', '[', '\\', ']', '^', '_' /* 88 - 95 */ + ,'`', 'A', 'B', 'C', 'D', 'E', 'F', 'G' /* 96 - 103 */ + ,'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O' /* 104 - 111 */ + ,'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W' /* 112 - 119 */ + ,'X', 'Y', 'Z', '{', '|', '}', '~', '\x7f' /* 120 - 127 */ + ,'C', 'U', 'E', 'A', 'A', 'A', 'A', 'C' /* 128 - 135 */ + ,'E', 'E', 'E', 'I', 'I', 'I', 'A', 'A' /* 136 - 143 */ + ,'E', 'A', 'A', 'O', 'O', 'O', 'U', 'U' /* 144 - 151 */ + ,'Y', 'O', 'U', '$', '$', '$', '$', '$' /* 152 - 159 */ + ,'A', 'I', 'O', 'U', 'N', 'N', '\xa6', '\xa7' /* 160 - 167 */ + ,'?', '\xa9', '\xaa', '\xab', '\xac', '!', '"', '"' /* 168 - 175 */ + ,'\xb0', '\xb1', '\xb2', '\xb3', '\xb4', '\xb5', '\xb6', '\xb7' /* 176 - 183 */ + ,'\xb8', '\xb9', '\xba', '\xbb', '\xbc', '\xbd', '\xbe', '\xbf' /* 184 - 191 */ + ,'\xc0', '\xc1', '\xc2', '\xc3', '\xc4', '\xc5', '\xc6', '\xc7' /* 192 - 199 */ + ,'\xc8', '\xc9', '\xca', '\xcb', '\xcc', '\xcd', '\xce', '\xcf' /* 200 - 207 */ + ,'\xd0', '\xd1', '\xd2', '\xd3', '\xd4', '\xd5', '\xd6', '\xd7' /* 208 - 215 */ + ,'\xd8', '\xd9', '\xda', '\xdb', '\xdc', '\xdd', '\xde', '\xdf' /* 216 - 223 */ + ,'\xe0', 'S', '\xe2', '\xe3', '\xe4', '\xe5', '\xe6', '\xe7' /* 224 - 231 */ + ,'\xe8', '\xe9', '\xea', '\xeb', '\xec', '\xed', '\xee', '\xef' /* 232 - 239 */ + ,'\xf0', '\xf1', '\xf2', '\xf3', '\xf4', '\xf5', '\xf6', '\xf7' /* 240 - 247 */ + ,'\xf8', '\xf9', '\xfa', '\xfb', '\xfc', '\xfd', '\xfe', '\xff' /* 248 - 255 */ + } + , + 0, /* no DBC support */ + 0, /* DBC end marker */ + { + 22, /* size of permittable character structure */ + 1, /* reserved */ + '\x00', '\xff', /* first/last permittable character */ + 0, /* reserved */ + '\x00', ' ', /* first/last excluded character */ + 2, /* reserved */ + 14, /* number of separators */ + { /* separators */ + '.', '"', '/', '\\', '[', ']', ':', '|', /* 0 - 7 */ + '<', '>', '+', '=', ';', ',' /* 8 - 13 */ + } + } +} diff --git a/kernel/apisupt.asm b/kernel/apisupt.asm new file mode 100644 index 00000000..efbd2b00 --- /dev/null +++ b/kernel/apisupt.asm @@ -0,0 +1,169 @@ +; File: +; apisupt.asm +; Description: +; Assembly support routines for stack manipulation, etc. +; +; Copyright (c) 1995, 1998 +; Pasquale J. Villani +; All Rights Reserved +; +; This file is part of DOS-C. +; +; DOS-C is free software; you can redistribute it and/or +; modify it under the terms of the GNU General Public License +; as published by the Free Software Foundation; either version +; 2, or (at your option) any later version. +; +; DOS-C is distributed in the hope that it will be useful, but +; WITHOUT ANY WARRANTY; without even the implied warranty of +; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See +; the GNU General Public License for more details. +; +; You should have received a copy of the GNU General Public +; License along with DOS-C; see the file COPYING. If not, +; write to the Free Software Foundation, 675 Mass Ave, +; Cambridge, MA 02139, USA. +; +; $Id$ +; +; $Log$ +; Revision 1.1 2000/05/06 19:34:52 jhall1 +; Initial revision +; +; Revision 1.2 1999/08/10 17:57:12 jprice +; ror4 2011-02 patch +; +; Revision 1.1.1.1 1999/03/29 15:40:38 jprice +; New version without IPL.SYS +; +; Revision 1.4 1999/02/08 05:55:57 jprice +; Added Pat's 1937 kernel patches +; +; Revision 1.3 1999/02/01 01:48:41 jprice +; Clean up; Now you can use hex numbers in config.sys. added config.sys screen function to change screen mode (28 or 43/50 lines) +; +; Revision 1.2 1999/01/22 04:13:25 jprice +; Formating +; +; Revision 1.1.1.1 1999/01/20 05:51:01 jprice +; Imported sources +; +; Rev 1.4 06 Dec 1998 8:47:02 patv +;Expanded due to new I/O subsystem. +; +; Rev 1.3 16 Jan 1997 12:46:44 patv +;pre-Release 0.92 feature additions +; +; Rev 1.2 29 May 1996 21:03:38 patv +;bug fixes for v0.91a +; +; Rev 1.1 01 Sep 1995 17:54:26 patv +;First GPL release. +; +; Rev 1.0 02 Jul 1995 9:04:50 patv +;Initial revision. +; $EndLog$ +; + + %include "segs.inc" + + extern _api_sp:wrt DGROUP ; api stacks - for context + extern _api_ss:wrt DGROUP ; switching + extern _usr_sp:wrt DGROUP ; user stacks + extern _usr_ss:wrt DGROUP + +segment _TEXT + global _set_stack +; +; void far set_stack(void) - +; save current stack and setup our local stack +; +_set_stack: + + ; save foreground stack + + ; we need to get the return values from the stack + ; since the current stack will change + pop ax ;get return offset + pop bx ;get return segment + + ; Save the flags so that we can restore correct interrupt + ; state later. We need to disable interrupts so that we + ; don't trash memory with new sp-old ss combination + pushf + pop dx + cli + + ; save bp + push bp + + mov cx, sp + neg cx + + ; save away foreground process' stack + push word [_usr_ss] + push word [_usr_sp] + + mov word [_usr_ss],ss + mov word [_usr_sp],sp + + ; setup our local stack + mov ss,word [_api_ss] + mov sp,word [_api_sp] + + add cx, sp + add bp, cx + + ; setup for ret + push bx + push ax + + ; now restore interrupt state + push dx + popf + + retf + +; +; void far restore_stack(void) - +; restore foreground stack, throw ours away +; + global _restore_stack +_restore_stack: + + ; we need to get the return values from the stack + ; since the current stack will change + pop cx ;get return offset + pop bx ;get return segment + + ; Save the flags so that we can restore correct interrupt + ; state later. We need to disable interrupts so that we + ; don't trash memory with new sp-old ss combination + pushf + pop dx + cli + + ; save background stack + mov word [_api_ss],ss + mov word [_api_sp],sp + + ; restore foreground stack here + mov ss,word [_usr_ss] + mov sp,word [_usr_sp] + + pop word [_usr_sp] + pop word [_usr_ss] + + ; make bp relative to our stack frame + pop bp + ;mov bp,sp + + ; setup for ret + push bx + push cx + + ; now restore interrupt state + push dx + popf + + retf diff --git a/kernel/asmsupt.asm b/kernel/asmsupt.asm new file mode 100644 index 00000000..32194d77 --- /dev/null +++ b/kernel/asmsupt.asm @@ -0,0 +1,195 @@ +; File: +; asmsupt.asm +; Description: +; Assembly support routines for miscellaneous functions +; +; Copyright (c) 1995, 1998 +; Pasquale J. Villani +; All Rights Reserved +; +; This file is part of DOS-C. +; +; DOS-C is free software; you can redistribute it and/or +; modify it under the terms of the GNU General Public License +; as published by the Free Software Foundation; either version +; 2, or (at your option) any later version. +; +; DOS-C is distributed in the hope that it will be useful, but +; WITHOUT ANY WARRANTY; without even the implied warranty of +; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See +; the GNU General Public License for more details. +; +; You should have received a copy of the GNU General Public +; License along with DOS-C; see the file COPYING. If not, +; write to the Free Software Foundation, 675 Mass Ave, +; Cambridge, MA 02139, USA. +; +; $Id$ +; +; $Log$ +; Revision 1.1 2000/05/06 19:34:52 jhall1 +; Initial revision +; +; Revision 1.3 1999/08/10 17:57:12 jprice +; ror4 2011-02 patch +; +; Revision 1.2 1999/04/23 04:24:39 jprice +; Memory manager changes made by ska +; +; Revision 1.1.1.1 1999/03/29 15:40:41 jprice +; New version without IPL.SYS +; +; Revision 1.4 1999/02/08 05:55:57 jprice +; Added Pat's 1937 kernel patches +; +; Revision 1.3 1999/02/01 01:48:41 jprice +; Clean up; Now you can use hex numbers in config.sys. added config.sys screen function to change screen mode (28 or 43/50 lines) +; +; Revision 1.2 1999/01/22 04:13:25 jprice +; Formating +; +; Revision 1.1.1.1 1999/01/20 05:51:01 jprice +; Imported sources +; +; Rev 1.4 06 Dec 1998 8:46:50 patv +; Bug fixes. +; +; Rev 1.3 03 Jan 1998 8:36:44 patv +; Converted data area to SDA format +; +; Rev 1.2 29 May 1996 21:03:38 patv +; bug fixes for v0.91a +; +; Rev 1.1 01 Sep 1995 17:54:26 patv +; First GPL release. +; +; Rev 1.0 05 Jul 1995 11:38:42 patv +; Initial revision. +; $EndLog$ +; + + %include "segs.inc" + +segment _TEXT +; +; VOID bcopy(s, d, n) +; REG BYTE *s, *d; +; REG COUNT n; +; +; + global _bcopy +_bcopy: + push bp ; Standard C entry + mov bp,sp + push si + push di + push ds + push es + + ; Get the repitition count, n + mov cx,[bp+8] + jcxz bcopy_exit + + ; Set both ds and es to same segment (for near copy) + mov ax,ds + mov es,ax + + ; Get the source pointer, ss + mov si,[bp+4] + + ; and the destination pointer, d + mov di,[bp+6] + +?doIt: + ; Set direction to autoincrement + cld + + ; And do the built-in byte copy, but do a 16-bit transfer + ; whenever possible. + mov al, cl + and al,1 ; test for odd count + jz b_even + movsb +b_even: shr cx,1 + rep movsw + + ; Finally do a C exit to return +fbcopy_exit: +bcopy_exit: pop es + pop ds + pop di + pop si + pop bp + ret + + +; +; VOID fbcopy(s, d, n) +; +; REG VOID FAR *s, FAR *d; +; REG COUNT n; + global _fbcopy +_fbcopy: + push bp ; Standard C entry + mov bp,sp + push si + push di + + ; Save ds, since we won't necessarily be within our + ; small/tiny environment + push ds + push es + + ; Get the repititon count, n + mov cx,[bp+12] + jcxz fbcopy_exit + + ; Get the far source pointer, s + lds si,[bp+4] + + ; Get the far destination pointer d + les di,[bp+8] + + jmp short ?doIt + +; +; VOID fmemset(s, ch, n) +; +; REG VOID FAR *s +; REG int ch +; REG COUNT n; + global _fmemset +_fmemset: + push bp ; Standard C entry + mov bp,sp + push di + + ; Save ds, since we won't necessarily be within our + ; small/tiny environment + push es + + ; Get the repititon count, n + mov cx,[bp+10] + jcxz fmemset_exit + + ; Get the far source pointer, s + les di,[bp+4] + + ; Test if odd or even + mov al, cl + and al, 1 + + ; Get the far destination pointer ch + mov al,[bp+8] + mov ah, al + + jz m_even + stosb +m_even: shr cx,1 + rep stosw + + +fmemset_exit: pop es + pop di + pop bp + ret diff --git a/kernel/blockio.c b/kernel/blockio.c new file mode 100644 index 00000000..b5eb8747 --- /dev/null +++ b/kernel/blockio.c @@ -0,0 +1,587 @@ +/****************************************************************/ +/* */ +/* blockio.c */ +/* DOS-C */ +/* */ +/* Block cache functions and device driver interface */ +/* */ +/* Copyright (c) 1995 */ +/* Pasquale J. Villani */ +/* All Rights Reserved */ +/* */ +/* This file is part of DOS-C. */ +/* */ +/* DOS-C is free software; you can redistribute it and/or */ +/* modify it under the terms of the GNU General Public License */ +/* as published by the Free Software Foundation; either version */ +/* 2, or (at your option) any later version. */ +/* */ +/* DOS-C is distributed in the hope that it will be useful, but */ +/* WITHOUT ANY WARRANTY; without even the implied warranty of */ +/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See */ +/* the GNU General Public License for more details. */ +/* */ +/* You should have received a copy of the GNU General Public */ +/* License along with DOS-C; see the file COPYING. If not, */ +/* write to the Free Software Foundation, 675 Mass Ave, */ +/* Cambridge, MA 02139, USA. */ +/* */ +/****************************************************************/ + +#include "portab.h" +#include "globals.h" + +#ifdef VERSION_STRINGS +static BYTE *blockioRcsId = "$Id$"; +#endif + +/* + * $Log$ + * Revision 1.1 2000/05/06 19:34:53 jhall1 + * Initial revision + * + * Revision 1.14 2000/03/09 06:07:10 kernel + * 2017f updates by James Tabor + * + * Revision 1.13 1999/08/25 03:18:07 jprice + * ror4 patches to allow TC 2.01 compile. + * + * Revision 1.12 1999/08/10 18:03:39 jprice + * ror4 2011-03 patch + * + * Revision 1.11 1999/05/03 06:25:45 jprice + * Patches from ror4 and many changed of signed to unsigned variables. + * + * Revision 1.10 1999/05/03 04:55:35 jprice + * Changed getblock & getbuf so that they leave at least 3 buffer for FAT data. + * + * Revision 1.9 1999/04/21 01:44:40 jprice + * no message + * + * Revision 1.8 1999/04/18 05:28:39 jprice + * no message + * + * Revision 1.7 1999/04/16 21:43:40 jprice + * ror4 multi-sector IO + * + * Revision 1.6 1999/04/16 00:53:32 jprice + * Optimized FAT handling + * + * Revision 1.5 1999/04/12 23:41:53 jprice + * Using getbuf to write data instead of getblock + * using getblock made it read the block before it wrote it + * + * Revision 1.4 1999/04/11 05:28:10 jprice + * Working on multi-block IO + * + * Revision 1.3 1999/04/11 04:33:38 jprice + * ror4 patches + * + * Revision 1.1.1.1 1999/03/29 15:41:43 jprice + * New version without IPL.SYS + * + * Revision 1.5 1999/02/09 02:54:23 jprice + * Added Pat's 1937 kernel patches + * + * Revision 1.4 1999/02/01 01:43:27 jprice + * Fixed findfirst function to find volume label with Windows long filenames + * + * Revision 1.3 1999/01/30 08:25:34 jprice + * Clean up; Fixed bug with set attribute function. If you tried to + * change the attributes of a directory, it would erase it. + * + * Revision 1.2 1999/01/22 04:15:28 jprice + * Formating + * + * Revision 1.1.1.1 1999/01/20 05:51:00 jprice + * Imported sources + * + * + * Rev 1.8 06 Dec 1998 8:43:16 patv + * Changes in block I/O because of new I/O subsystem. + * + * Rev 1.7 22 Jan 1998 4:09:00 patv + * Fixed pointer problems affecting SDA + * + * Rev 1.6 04 Jan 1998 23:14:36 patv + * Changed Log for strip utility + * + * Rev 1.5 03 Jan 1998 8:36:02 patv + * Converted data area to SDA format + * + * Rev 1.4 16 Jan 1997 12:46:34 patv + * pre-Release 0.92 feature additions + * + * Rev 1.3 29 May 1996 21:15:10 patv + * bug fixes for v0.91a + * + * Rev 1.2 01 Sep 1995 17:48:46 patv + * First GPL release. + * + * Rev 1.1 30 Jul 1995 20:50:28 patv + * Eliminated version strings in ipl + * + * Rev 1.0 02 Jul 1995 8:04:06 patv + * Initial revision. + */ + +/************************************************************************/ +/* */ +/* block cache routines */ +/* */ +/************************************************************************/ + +/* */ +/* Initialize the buffer structure */ +/* */ +/* XXX: This should go into `INIT_TEXT'. -- ror4 */ +VOID FAR init_buffers(void) +{ + REG WORD i; + REG WORD count; + + for (i = 0; i < Config.cfgBuffers; ++i) + { + buffers[i].b_unit = 0; + buffers[i].b_flag = 0; + buffers[i].b_blkno = 0; + buffers[i].b_copies = 0; + buffers[i].b_offset_lo = 0; + buffers[i].b_offset_hi = 0; + if (i < (Config.cfgBuffers - 1)) + buffers[i].b_next = &buffers[i + 1]; + else + buffers[i].b_next = NULL; + } + firstbuf = &buffers[0]; + lastbuf = &buffers[Config.cfgBuffers - 1]; +} + +/* Extract the block number from a buffer structure. */ +ULONG getblkno(struct buffer FAR * bp) +{ + if (bp->b_blkno == 0xffffu) + return bp->b_huge_blkno; + else + return bp->b_blkno; +} + +/* Set the block number of a buffer structure. (The caller should */ +/* set the unit number before calling this function.) */ +VOID setblkno(struct buffer FAR * bp, ULONG blkno) +{ + if (blkno >= 0xffffu) + { + bp->b_blkno = 0xffffu; + bp->b_huge_blkno = blkno; + } + else + { + bp->b_blkno = blkno; + bp->b_dpbp = &blk_devices[bp->b_unit]; + } +} + +/* */ +/* Return the address of a buffer structure containing the */ +/* requested block. */ +/* */ +/* returns: */ +/* requested block with data */ +/* failure: */ +/* returns NULL */ +/* */ +struct buffer FAR *getblock(ULONG blkno, COUNT dsk) +{ + REG struct buffer FAR *bp; + REG struct buffer FAR *lbp; + REG struct buffer FAR *mbp; + REG BYTE fat_count = 0; + + /* Search through buffers to see if the required block */ + /* is already in a buffer */ + +#ifdef DISPLAY_GETBLOCK + printf("[getblock %d, blk %ld, buf ", dsk, blkno); +#endif + bp = firstbuf; + lbp = NULL; + mbp = NULL; + while (bp != NULL) + { + if ((bp->b_flag & BFR_VALID) && (bp->b_unit == dsk) + && (getblkno(bp) == blkno)) + { + /* found it -- rearrange LRU links */ + if (lbp != NULL) + { + lbp->b_next = bp->b_next; + bp->b_next = firstbuf; + firstbuf = bp; + } +#ifdef DISPLAY_GETBLOCK + printf("HIT]\n"); +#endif + return (bp); + } + else + { + if (bp->b_flag & BFR_FAT) + fat_count++; + mbp = lbp; /* move along to next buffer */ + lbp = bp; + bp = bp->b_next; + } + } + /* The block we need is not in a buffer, we must make a buffer */ + /* available, and fill it with the desired block */ + + /* detach lru buffer */ +#ifdef DISPLAY_GETBLOCK + printf("MISS]\n"); +#endif + + /* make sure we keep at least 3 buffers for the FAT. If this is not a */ + /* FAT buffer, or there are at least 3 already, then we can use this */ + /* buffer. */ + /* otherwise, search again, and find the last non-FAT buffer. */ + if ((lbp->b_flag & BFR_FAT) && (fat_count < 3)) + { + bp = firstbuf; + lbp = NULL; + mbp = NULL; + while ((bp != NULL) && (bp->b_flag & BFR_FAT)) + { + /* if this is a FAT buffer, then move to the next one, else we found */ + /* the one we want. */ + mbp = lbp; /* move along to next buffer */ + lbp = bp; + bp = bp->b_next; + } + /* if we get to the end of the list here, then we must only have 3 */ + /* buffers, which is not suppose to happen, but if it does, then we */ + /* end up using the last buffer (even though it is FAT). */ + + if (bp == NULL) + { + /* put lbp at the top of the chain. */ + if (mbp != NULL) + mbp->b_next = NULL; + lbp->b_next = firstbuf; + firstbuf = bp = lbp; + } + else if (lbp != NULL) + { + lbp->b_next = bp->b_next; + bp->b_next = firstbuf; + firstbuf = bp; + } + lbp = bp; + } + else + { + /* put lbp at the top of the chain. */ + if (mbp != NULL) + mbp->b_next = NULL; + lbp->b_next = firstbuf; + firstbuf = lbp; + } + + /* take the buffer than lbp points to and flush it, then read new block. */ + if (flush1(lbp) && fill(lbp, blkno, dsk)) /* success */ + mbp = lbp; + else + mbp = NULL; /* failure */ + return (mbp); +} + +/* + Return the address of a buffer structure for the + requested block. This is for writing new data to a block, so + we really don't care what is in the buffer now. + + returns: + TRUE = buffer available, flushed if necessary + parameter is filled with pointer to buffer + FALSE = there was an error flushing the buffer. + parameter is set to NULL + */ +BOOL getbuf(struct buffer FAR ** pbp, ULONG blkno, COUNT dsk) +{ + REG struct buffer FAR *bp; + REG struct buffer FAR *lbp; + REG struct buffer FAR *mbp; + REG BYTE fat_count = 0; + + /* Search through buffers to see if the required block */ + /* is already in a buffer */ + +#ifdef DISPLAY_GETBLOCK + printf("[getbuf %d, blk %ld, buf ", dsk, blkno); +#endif + bp = firstbuf; + lbp = NULL; + mbp = NULL; + while (bp != NULL) + { + if ((bp->b_flag & BFR_VALID) && (bp->b_unit == dsk) + && (getblkno(bp) == blkno)) + { + /* found it -- rearrange LRU links */ + if (lbp != NULL) + { + lbp->b_next = bp->b_next; + bp->b_next = firstbuf; + firstbuf = bp; + } + *pbp = bp; +#ifdef DISPLAY_GETBLOCK + printf("HIT]\n"); +#endif + return TRUE; + } + else + { + if (bp->b_flag & BFR_FAT) + fat_count++; + mbp = lbp; /* move along to next buffer */ + lbp = bp; + bp = bp->b_next; + } + } + /* The block we need is not in a buffer, we must make a buffer */ + /* available. */ + +#ifdef DISPLAY_GETBLOCK + printf("MISS]\n"); +#endif + + /* make sure we keep at least 3 buffers for the FAT. If this is not a */ + /* FAT buffer, or there are at least 3 already, then we can use this */ + /* buffer. */ + /* otherwise, search again, and find the last non-FAT buffer. */ + if ((lbp->b_flag & BFR_FAT) && (fat_count < 3)) + { + bp = firstbuf; + lbp = NULL; + mbp = NULL; + while ((bp != NULL) && (bp->b_flag & BFR_FAT)) + { + /* if this is a FAT buffer, then move to the next one, else we found */ + /* the one we want. */ + mbp = lbp; /* move along to next buffer */ + lbp = bp; + bp = bp->b_next; + } + /* if we get to the end of the list here, then we must only have 3 */ + /* buffers, which is not suppose to happen, but if it does, then we */ + /* end up using the last buffer (even though it is FAT). */ + + if (bp == NULL) + { + /* put lbp at the top of the chain. */ + if (mbp != NULL) + mbp->b_next = NULL; + lbp->b_next = firstbuf; + firstbuf = bp = lbp; + } + else if (lbp != NULL) + { + lbp->b_next = bp->b_next; + bp->b_next = firstbuf; + firstbuf = bp; + } + lbp = bp; + } + else + { + /* put lbp at the top of the chain. */ + if (mbp != NULL) + mbp->b_next = NULL; + lbp->b_next = firstbuf; + firstbuf = lbp; + } + + /* take the buffer than lbp points to and flush it, then make it available. */ + if (flush1(lbp)) /* success */ + { + lbp->b_flag = 0; + lbp->b_unit = dsk; + setblkno(lbp, blkno); + *pbp = lbp; + return TRUE; + } + else + /* failure */ + { + *pbp = NULL; + return FALSE; + } +} + +/* */ +/* Mark all buffers for a disk as not valid */ +/* */ +VOID setinvld(REG COUNT dsk) +{ + REG struct buffer FAR *bp; + + bp = firstbuf; + while (bp) + { + if (bp->b_unit == dsk) + bp->b_flag = 0; + bp = bp->b_next; + } +} + +/* */ +/* Flush all buffers for a disk */ +/* */ +/* returns: */ +/* TRUE on success */ +/* */ +BOOL flush_buffers(REG COUNT dsk) +{ + REG struct buffer FAR *bp; + REG BOOL ok = TRUE; + + bp = firstbuf; + while (bp) + { + if (bp->b_unit == dsk) + if (!flush1(bp)) + ok = FALSE; + bp = bp->b_next; + } + return ok; +} + +/* */ +/* Write one disk buffer */ +/* */ +BOOL flush1(struct buffer FAR * bp) +{ + REG WORD ok; + + if ((bp->b_flag & BFR_VALID) && (bp->b_flag & BFR_DIRTY)) + { + ok = dskxfer(bp->b_unit, getblkno(bp), + (VOID FAR *) bp->b_buffer, 1, DSKWRITE); + if (bp->b_flag & BFR_FAT) + { + int i = bp->b_copies; + LONG blkno = getblkno(bp); + UWORD offset = ((UWORD) bp->b_offset_hi << 8) | bp->b_offset_lo; + + while (--i > 0) + { + blkno += offset; + ok &= dskxfer(bp->b_unit, blkno, + (VOID FAR *) bp->b_buffer, 1, DSKWRITE); + } + } + } + else + ok = TRUE; + bp->b_flag &= ~BFR_DIRTY; /* even if error, mark not dirty */ + if (!ok) /* otherwise system has trouble */ + bp->b_flag &= ~BFR_VALID; /* continuing. */ + return (ok); +} + +/* */ +/* Write all disk buffers */ +/* */ +BOOL flush(void) +{ + REG struct buffer FAR *bp; + REG BOOL ok; + + ok = TRUE; + bp = firstbuf; + while (bp) + { + if (!flush1(bp)) + ok = FALSE; + bp->b_flag &= ~BFR_VALID; + bp = bp->b_next; + } + + int2f_Remote_call(REM_FLUSHALL, 0, 0, 0, 0, 0, 0); + + return (ok); +} + +/* */ +/* Fill the indicated disk buffer with the current track and sector */ +/* */ +/* This function assumes that the buffer is ready for use and that the + sector is not already in the buffer ring */ +BOOL fill(REG struct buffer FAR * bp, ULONG blkno, COUNT dsk) +{ + REG WORD ok; + + ok = dskxfer(dsk, blkno, (VOID FAR *) bp->b_buffer, 1, DSKREAD); + bp->b_flag = BFR_VALID | BFR_DATA; + bp->b_unit = dsk; + setblkno(bp, blkno); + return (ok); +} + +/************************************************************************/ +/* */ +/* Device Driver Interface Functions */ +/* */ +/************************************************************************/ +/* */ +/* Transfer one or more blocks to/from disk */ +/* */ +BOOL dskxfer(COUNT dsk, ULONG blkno, VOID FAR * buf, UWORD numblocks, COUNT mode) +{ + REG struct dpb *dpbp = &blk_devices[dsk]; + + for (;;) + { + IoReqHdr.r_length = sizeof(request); + IoReqHdr.r_unit = dpbp->dpb_subunit; + IoReqHdr.r_command = + mode == DSKWRITE ? + (verify_ena ? C_OUTVFY : C_OUTPUT) + : C_INPUT; + IoReqHdr.r_status = 0; + IoReqHdr.r_meddesc = dpbp->dpb_mdb; + IoReqHdr.r_trans = (BYTE FAR *) buf; + IoReqHdr.r_count = numblocks; + if (blkno >= MAXSHORT) + { + IoReqHdr.r_start = HUGECOUNT; + IoReqHdr.r_huge = blkno; + } + else + IoReqHdr.r_start = blkno; + execrh((request FAR *) & IoReqHdr, dpbp->dpb_device); + if (!(IoReqHdr.r_status & S_ERROR) && (IoReqHdr.r_status & S_DONE)) + break; + else + { + loop: + switch (block_error(&IoReqHdr, dpbp->dpb_unit, dpbp->dpb_device)) + { + case ABORT: + case FAIL: + return FALSE; + + case RETRY: + continue; + + case CONTINUE: + break; + + default: + goto loop; + } + } + } + return TRUE; +} diff --git a/kernel/break.c b/kernel/break.c new file mode 100644 index 00000000..fe84ebf9 --- /dev/null +++ b/kernel/break.c @@ -0,0 +1,84 @@ +/****************************************************************/ +/* */ +/* break.c */ +/* FreeDOS */ +/* */ +/* Control Break detection and handling */ +/* */ +/* Copyright (c) 1999 */ +/* Steffen Kaiser */ +/* All Rights Reserved */ +/* */ +/* This file is part of DOS-C. */ +/* */ +/* DOS-C is free software; you can redistribute it and/or */ +/* modify it under the terms of the GNU General Public License */ +/* as published by the Free Software Foundation; either version */ +/* 2, or (at your option) any later version. */ +/* */ +/* DOS-C is distributed in the hope that it will be useful, but */ +/* WITHOUT ANY WARRANTY; without even the implied warranty of */ +/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See */ +/* the GNU General Public License for more details. */ +/* */ +/* You should have received a copy of the GNU General Public */ +/* License along with DOS-C; see the file COPYING. If not, */ +/* write to the Free Software Foundation, 675 Mass Ave, */ +/* Cambridge, MA 02139, USA. */ +/****************************************************************/ + +#include "portab.h" +#include "globals.h" + +extern void spawn_int23(void); + +#ifdef VERSION_STRINGS +static BYTE *RcsId = "$Id$"; +#endif + +/* + * $Log$ + * Revision 1.1 2000/05/06 19:34:54 jhall1 + * Initial revision + * + * Revision 1.2 2000/03/09 06:07:10 kernel + * 2017f updates by James Tabor + * + * Revision 1.1 1999/04/16 21:18:17 jprice + * Steffen contributed. + * + */ + +#define CB_FLG *(UBYTE FAR*)MK_FP(0x40, 0x71) +#define CB_MSK 0x80 + +/* Check for ^Break. + + * Two sources are available: + * 1) flag at 40:71 bit 7 + * 2) STDIN str‘am via con_break() + */ +int control_break(void) +{ + return (CB_FLG & CB_MSK) || con_break(); +} + +/* + * Handles a ^Break state + * + * Actions: + * 1) clear the ^Break flag + * 2) clear the STDIN stream + * 3) decrease the InDOS flag as the kernel drops back to user space + * 4) invoke INT-23 and never come back + */ +void handle_break(void) +{ + CB_FLG &= ~CB_MSK; /* reset the ^Break flag */ + KbdFlush(); /* Er, this is con_flush() */ + if (!ErrorMode) /* within int21_handler, InDOS is not incremented */ + if (InDOS) + --InDOS; /* fail-safe */ + + spawn_int23(); /* invoke user INT-23 and never come back */ +} diff --git a/kernel/chario.c b/kernel/chario.c new file mode 100644 index 00000000..77b9e67e --- /dev/null +++ b/kernel/chario.c @@ -0,0 +1,404 @@ +/****************************************************************/ +/* */ +/* chario.c */ +/* DOS-C */ +/* */ +/* Character device functions and device driver interface */ +/* */ +/* Copyright (c) 1994 */ +/* Pasquale J. Villani */ +/* All Rights Reserved */ +/* */ +/* This file is part of DOS-C. */ +/* */ +/* DOS-C is free software; you can redistribute it and/or */ +/* modify it under the terms of the GNU General Public License */ +/* as published by the Free Software Foundation; either version */ +/* 2, or (at your option) any later version. */ +/* */ +/* DOS-C is distributed in the hope that it will be useful, but */ +/* WITHOUT ANY WARRANTY; without even the implied warranty of */ +/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See */ +/* the GNU General Public License for more details. */ +/* */ +/* You should have received a copy of the GNU General Public */ +/* License along with DOS-C; see the file COPYING. If not, */ +/* write to the Free Software Foundation, 675 Mass Ave, */ +/* Cambridge, MA 02139, USA. */ +/* */ +/****************************************************************/ + +#include "portab.h" + +#ifdef VERSION_STRINGS +static BYTE *charioRcsId = "$Id$"; +#endif + +/* + * $Log$ + * Revision 1.1 2000/05/06 19:34:54 jhall1 + * Initial revision + * + * Revision 1.7 2000/03/09 06:07:10 kernel + * 2017f updates by James Tabor + * + * Revision 1.6 1999/09/23 04:40:45 jprice + * *** empty log message *** + * + * Revision 1.4 1999/08/25 03:18:07 jprice + * ror4 patches to allow TC 2.01 compile. + * + * Revision 1.3 1999/04/16 12:21:21 jprice + * Steffen c-break handler changes + * + * Revision 1.2 1999/04/04 18:51:42 jprice + * no message + * + * Revision 1.1.1.1 1999/03/29 15:41:45 jprice + * New version without IPL.SYS + * + * Revision 1.5 1999/02/09 02:54:23 jprice + * Added Pat's 1937 kernel patches + * + * Revision 1.4 1999/02/04 03:18:37 jprice + * Formating. Added comments. + * + * Revision 1.3 1999/02/01 01:43:28 jprice + * Fixed findfirst function to find volume label with Windows long filenames + * + * Revision 1.2 1999/01/22 04:15:28 jprice + * Formating + * + * Revision 1.1.1.1 1999/01/20 05:51:00 jprice + * Imported sources + * + * + * Rev 1.9 06 Dec 1998 8:43:36 patv + * changes in character I/O because of new I/O subsystem. + * + * Rev 1.8 11 Jan 1998 2:06:08 patv + * Added functionality to ioctl. + * + * Rev 1.7 08 Jan 1998 21:36:40 patv + * Changed automatic requestic packets to static to save stack space. + * + * Rev 1.6 04 Jan 1998 23:14:38 patv + * Changed Log for strip utility + * + * Rev 1.5 30 Dec 1997 4:00:20 patv + * Modified to support SDA + * + * Rev 1.4 16 Jan 1997 12:46:36 patv + * pre-Release 0.92 feature additions + * + * Rev 1.3 29 May 1996 21:15:12 patv + * bug fixes for v0.91a + * + * Rev 1.2 01 Sep 1995 17:48:42 patv + * First GPL release. + * + * Rev 1.1 30 Jul 1995 20:50:26 patv + * Eliminated version strings in ipl + * + * Rev 1.0 02 Jul 1995 8:05:44 patv + * Initial revision. + * + */ + +#include "globals.h" + +static BYTE *con_name = "CON"; + +#ifdef PROTO +VOID kbfill(keyboard FAR *, UCOUNT, BOOL, UWORD *); +struct dhdr FAR *finddev(UWORD attr_mask); + +#else +VOID kbfill(); +struct dhdr FAR *finddev(); +#endif + +/* Return a pointer to the first driver in the chain that + * matches the attributes. + */ + +struct dhdr FAR *finddev(UWORD attr_mask) +{ + struct dhdr far *dh; + + for (dh = nul_dev.dh_next; FP_OFF(dh) != 0xFFFF; dh = dh->dh_next) + { + if (dh->dh_attr & attr_mask) + return dh; + } + + /* return dev/null if no matching driver found */ + return &nul_dev; +} +/* + VOID cso(COUNT c) + { + BYTE buf = c; + struct dhdr FAR *lpDevice; + + CharReqHdr.r_length = sizeof(request); + CharReqHdr.r_command = C_OUTPUT; + CharReqHdr.r_count = 1; + CharReqHdr.r_trans = (BYTE FAR *) (&buf); + CharReqHdr.r_status = 0; + execrh((request FAR *) & CharReqHdr, + lpDevice = (struct dhdr FAR *)finddev(ATTR_CONOUT)); + if (CharReqHdr.r_status & S_ERROR) + char_error(&CharReqHdr, lpDevice); + } + */ + +VOID sto(COUNT c) +{ + static COUNT scratch; /* make this static to save stack space */ + + DosWrite(STDOUT, 1, (BYTE FAR *) & c, (COUNT FAR *) scratch); +} + +VOID mod_sto(REG UCOUNT c) +{ + if (c < ' ' && c != HT) + { + sto('^'); + sto(c + '@'); + } + else + sto(c); +} + +VOID destr_bs(void) +{ + sto(BS); + sto(' '); + sto(BS); +} + +VOID Do_DosIdle_loop(void) +{ + FOREVER + { + if (StdinBusy()) + return; + else + { + DosIdle_int(); + continue; + } + } +} + +UCOUNT _sti(void) +{ + static COUNT scratch; + UBYTE c; + /* + * XXX: If there's a read error, this will just keep retrying the read until + * the error disappears. Maybe it should do something else instead. -- ror4 + */ + while (GenericRead(STDIN, 1, (BYTE FAR *) & c, (COUNT FAR *) & scratch, TRUE) + != 1) ; + return c; +} + +BOOL con_break(void) +{ + CharReqHdr.r_unit = 0; + CharReqHdr.r_status = 0; + CharReqHdr.r_command = C_NDREAD; + CharReqHdr.r_length = sizeof(request); + execrh((request FAR *) & CharReqHdr, (struct dhdr FAR *)finddev(ATTR_CONIN)); + if (CharReqHdr.r_status & S_BUSY) + return FALSE; + if (CharReqHdr.r_ndbyte == CTL_C) + { + _sti(); + return TRUE; + } + else + return FALSE; +} + +BOOL StdinBusy(void) +{ + sft FAR *s; + + if ((s = get_sft(STDIN)) == (sft FAR *) - 1) + return FALSE; /* XXX */ + if (s->sft_count == 0 || (s->sft_mode & SFT_MWRITE)) + return FALSE; /* XXX */ + if (s->sft_flags & SFT_FDEVICE) + { + CharReqHdr.r_unit = 0; + CharReqHdr.r_status = 0; + CharReqHdr.r_command = C_ISTAT; + CharReqHdr.r_length = sizeof(request); + execrh((request FAR *) & CharReqHdr, s->sft_dev); + if (CharReqHdr.r_status & S_BUSY) + return TRUE; + else + return FALSE; + } + else + return FALSE; /* XXX */ +} + +VOID KbdFlush(void) +{ + CharReqHdr.r_unit = 0; + CharReqHdr.r_status = 0; + CharReqHdr.r_command = C_IFLUSH; + CharReqHdr.r_length = sizeof(request); + execrh((request FAR *) & CharReqHdr, (struct dhdr FAR *)finddev(ATTR_CONIN)); +} + +static VOID kbfill(keyboard FAR * kp, UCOUNT c, BOOL ctlf, UWORD * vp) +{ + if (kp->kb_count > kp->kb_size) + { + sto(BELL); + return; + } + kp->kb_buf[kp->kb_count++] = c; + if (!ctlf) + { + mod_sto(c); + *vp += 2; + } + else + { + sto(c); + if (c != HT) + ++ * vp; + else + *vp = (*vp + 8) & -8; + } +} + +VOID sti(keyboard FAR * kp) +{ + REG UWORD c, + cu_pos = scr_pos; + UWORD + virt_pos = scr_pos; + WORD init_count = kp->kb_count; +#ifndef NOSPCL + static BYTE local_buffer[LINESIZE]; +#endif + + if (kp->kb_size == 0) + return; + if (kp->kb_size <= kp->kb_count || kp->kb_buf[kp->kb_count] != CR) + kp->kb_count = 0; + FOREVER + { + + Do_DosIdle_loop(); + + switch (c = _sti()) + { + case CTL_C: + handle_break(); + case CTL_F: + continue; + +#ifndef NOSPCL + case SPCL: + switch (c = _sti()) + { + case LEFT: + goto backspace; + + case F3: + { + REG COUNT i; + + for (i = kp->kb_count; local_buffer[i] != '\0'; i++) + { + c = local_buffer[kp->kb_count]; + if (c == '\r' || c == '\n') + break; + kbfill(kp, c, FALSE, &virt_pos); + } + break; + } + + case RIGHT: + c = local_buffer[kp->kb_count]; + if (c == '\r' || c == '\n') + break; + kbfill(kp, c, FALSE, &virt_pos); + break; + } + break; +#endif + + case CTL_BS: + case BS: + backspace: + if (kp->kb_count > 0) + { + if (kp->kb_buf[kp->kb_count - 1] >= ' ') + { + destr_bs(); + --virt_pos; + } + else if ((kp->kb_buf[kp->kb_count - 1] < ' ') + && (kp->kb_buf[kp->kb_count - 1] != HT)) + { + destr_bs(); + destr_bs(); + virt_pos -= 2; + } + else if (kp->kb_buf[kp->kb_count - 1] == HT) + { + do + { + destr_bs(); + --virt_pos; + } + while ((virt_pos > cu_pos) && (virt_pos & 7)); + } + --kp->kb_count; + } + break; + + case CR: + kbfill(kp, CR, TRUE, &virt_pos); + kbfill(kp, LF, TRUE, &virt_pos); +#ifndef NOSPCL + fbcopy((BYTE FAR *) kp->kb_buf, + (BYTE FAR *) local_buffer, (COUNT) kp->kb_count); + local_buffer[kp->kb_count] = '\0'; +#endif + return; + + case LF: + sto(CR); + sto(LF); + break; + + case ESC: + sto('\\'); + sto(CR); + sto(LF); + for (c = 0; c < cu_pos; c++) + sto(' '); + kp->kb_count = init_count; + break; + + default: + kbfill(kp, c, FALSE, &virt_pos); + break; + } + } +} + +VOID FAR init_call_sti(keyboard FAR * kp) +{ + sti(kp); +} diff --git a/kernel/config.c b/kernel/config.c new file mode 100644 index 00000000..338cca8f --- /dev/null +++ b/kernel/config.c @@ -0,0 +1,925 @@ +/****************************************************************/ +/* */ +/* config.c */ +/* DOS-C */ +/* */ +/* config.sys Processing Functions */ +/* */ +/* Copyright (c) 1996 */ +/* Pasquale J. Villani */ +/* All Rights Reserved */ +/* */ +/* This file is part of DOS-C. */ +/* */ +/* DOS-C is free software; you can redistribute it and/or */ +/* modify it under the terms of the GNU General Public License */ +/* as published by the Free Software Foundation; either version */ +/* 2, or (at your option) any later version. */ +/* */ +/* DOS-C is distributed in the hope that it will be useful, but */ +/* WITHOUT ANY WARRANTY; without even the implied warranty of */ +/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See */ +/* the GNU General Public License for more details. */ +/* */ +/* You should have received a copy of the GNU General Public */ +/* License along with DOS-C; see the file COPYING. If not, */ +/* write to the Free Software Foundation, 675 Mass Ave, */ +/* Cambridge, MA 02139, USA. */ +/****************************************************************/ + +#include "init-mod.h" + +#include "portab.h" +#include "globals.h" + +#ifdef VERSION_STRINGS +static BYTE *RcsId = "$Id$"; +#endif + +/* + * $Log$ + * Revision 1.1 2000/05/06 19:34:56 jhall1 + * Initial revision + * + * Revision 1.13 2000/03/09 06:07:10 kernel + * 2017f updates by James Tabor + * + * Revision 1.12 1999/09/23 04:40:46 jprice + * *** empty log message *** + * + * Revision 1.10 1999/08/25 03:18:07 jprice + * ror4 patches to allow TC 2.01 compile. + * + * Revision 1.9 1999/05/03 06:25:45 jprice + * Patches from ror4 and many changed of signed to unsigned variables. + * + * Revision 1.8 1999/04/16 21:43:40 jprice + * ror4 multi-sector IO + * + * Revision 1.7 1999/04/16 12:21:21 jprice + * Steffen c-break handler changes + * + * Revision 1.6 1999/04/16 00:53:32 jprice + * Optimized FAT handling + * + * Revision 1.5 1999/04/12 03:21:17 jprice + * more ror4 patches. Changes for multi-block IO + * + * Revision 1.4 1999/04/11 04:33:38 jprice + * ror4 patches + * + * Revision 1.2 1999/04/04 22:57:47 jprice + * no message + * + * Revision 1.1.1.1 1999/03/29 15:40:46 jprice + * New version without IPL.SYS + * + * Revision 1.6 1999/03/23 23:38:15 jprice + * Now checks for a reads fdconfig.sys file, if exists + * + * Revision 1.5 1999/02/08 05:55:57 jprice + * Added Pat's 1937 kernel patches + * + * Revision 1.4 1999/02/01 01:48:41 jprice + * Clean up; Now you can use hex numbers in config.sys. added config.sys screen function to change screen mode (28 or 43/50 lines) + * + * Revision 1.3 1999/01/30 08:28:11 jprice + * Clean up; Fixed bug with set attribute function. + * + * Revision 1.2 1999/01/22 04:13:25 jprice + * Formating + * + * Revision 1.1.1.1 1999/01/20 05:51:01 jprice + * Imported sources + * + * + * Rev 1.6 22 Jan 1998 4:09:24 patv + * Fixed pointer problems affecting SDA + * + * Rev 1.5 04 Jan 1998 23:15:18 patv + * Changed Log for strip utility + * + * Rev 1.4 04 Jan 1998 17:26:14 patv + * Corrected subdirectory bug + * + * Rev 1.3 16 Jan 1997 12:46:50 patv + * pre-Release 0.92 feature additions + * + * Rev 1.1 29 May 1996 21:03:44 patv + * bug fixes for v0.91a + * + * Rev 1.0 19 Feb 1996 3:22:16 patv + * Added NLS, int2f and config.sys processing + */ + +#ifdef __TURBOC__ +void __int__(int); /* TC 2.01 requires this. :( -- ror4 */ +#endif + +#ifdef KDB +#include + +#define KernelAlloc(x) adjust_far((void far *)malloc((unsigned long)(x))) +#endif + +BYTE FAR *lpBase; +static BYTE FAR *lpOldLast; +static COUNT nCfgLine; +static COUNT nPass; +static BYTE szLine[256]; +static BYTE szBuf[256]; + +int singleStep = 0; + +INIT VOID Buffers(BYTE * pLine); +INIT VOID sysScreenMode(BYTE * pLine); +INIT VOID sysVersion(BYTE * pLine); +INIT VOID Break(BYTE * pLine); +INIT VOID Device(BYTE * pLine); +INIT VOID Files(BYTE * pLine); +INIT VOID Fcbs(BYTE * pLine); +INIT VOID Lastdrive(BYTE * pLine); +INIT VOID Country(BYTE * pLine); +INIT VOID InitPgm(BYTE * pLine); +INIT VOID Switchar(BYTE * pLine); +INIT VOID CfgFailure(BYTE * pLine); +INIT VOID Stacks(BYTE * pLine); +INIT BYTE *GetNumArg(BYTE * pLine, COUNT * pnArg); +INIT BYTE *GetStringArg(BYTE * pLine, BYTE * pszString); +INIT struct dhdr FAR *linkdev(struct dhdr FAR * dhp); +INIT UWORD initdev(struct dhdr FAR * dhp, BYTE FAR * cmdTail); +INIT int SkipLine(char *pLine); + +INIT static VOID FAR *AlignParagraph(VOID FAR * lpPtr); +#ifndef I86 +#define AlignParagraph(x) (x) +#endif + +#define EOF 0x1a + +INIT struct table *LookUp(struct table *p, BYTE * token); + +struct table +{ + BYTE *entry; + BYTE pass; + VOID(*func) (BYTE * pLine); +}; + +static struct table commands[] = +{ + {"break", 1, Break}, + {"buffers", 1, Buffers}, + {"command", 1, InitPgm}, + {"country", 1, Country}, + {"device", 2, Device}, + {"fcbs", 1, Fcbs}, + {"files", 1, Files}, + {"lastdrive", 1, Lastdrive}, + /* rem is never executed by locking out pass */ + {"rem", 0, CfgFailure}, + {"shell", 1, InitPgm}, + {"stacks", 1, Stacks}, + {"switchar", 1, Switchar}, + {"screen", 1, sysScreenMode}, /* JPP */ + {"version", 1, sysVersion}, /* JPP */ + /* default action */ + {"", -1, CfgFailure} +}; + +#ifndef KDB +INIT BYTE FAR *KernelAlloc(WORD nBytes); +INIT BYTE FAR *KernelAllocDma(WORD); +#endif + +BYTE *pLineStart; + +/* Do first time initialization. Store last so that we can reset it */ +/* later. */ +INIT void PreConfig(void) +{ + /* Set pass number */ + nPass = 0; + + /* Initialize the base memory pointers */ + lpOldLast = lpBase = AlignParagraph((BYTE FAR *) & last); + + /* Begin by initializing our system buffers */ + dma_scratch = (BYTE FAR *) KernelAllocDma(BUFFERSIZE); +#ifdef DEBUG + printf("Preliminary DMA scratchpad allocated at 0x%04x:0x%04x\n", + FP_SEG(dma_scratch), FP_OFF(dma_scratch)); +#endif + buffers = (struct buffer FAR *) + KernelAlloc(Config.cfgBuffers * sizeof(struct buffer)); +#ifdef DEBUG + printf("Preliminary %d buffers allocated at 0x%04x:0x%04x\n", Config.cfgBuffers, + FP_SEG(buffers), FP_OFF(buffers)); +#endif + + /* Initialize the file table */ + f_nodes = (struct f_node FAR *) + KernelAlloc(Config.cfgFiles * sizeof(struct f_node)); + /* sfthead = (sfttbl FAR *)&basesft; */ + /* FCBp = (sfttbl FAR *)&FcbSft; */ + FCBp = (sfttbl FAR *) + KernelAlloc(sizeof(sftheader) + + Config.cfgFiles * sizeof(sft)); + sfthead = (sfttbl FAR *) + KernelAlloc(sizeof(sftheader) + + Config.cfgFiles * sizeof(sft)); + + CDSp = (cdstbl FAR *) + KernelAlloc(0x58 * lastdrive + 1); + +#ifdef DEBUG + + printf("Preliminary f_node allocated at 0x%04x:0x%04x\n", + FP_SEG(f_nodes), FP_OFF(f_nodes)); + printf("Preliminary FCB table allocated at 0x%04x:0x%04x\n", + FP_SEG(FCBp), FP_OFF(FCBp)); + printf("Preliminary sft table allocated at 0x%04x:0x%04x\n", + FP_SEG(sfthead), FP_OFF(sfthead)); + printf("Preliminary CDS table allocated at 0x%04x:0x%04x\n", + FP_SEG(CDSp), FP_OFF(CDSp)); +#endif + + /* Done. Now initialize the MCB structure */ + /* This next line is 8086 and 80x86 real mode specific */ +#ifdef DEBUG + printf("Preliminary allocation completed: top at 0x%04x:0x%04x\n", + FP_SEG(lpBase), FP_OFF(lpBase)); +#endif + +#ifdef KDB + lpBase = malloc(4096); + first_mcb = FP_SEG(lpBase) + ((FP_OFF(lpBase) + 0x0f) >> 4); +#else + first_mcb = FP_SEG(lpBase) + ((FP_OFF(lpBase) + 0x0f) >> 4); +#endif + + /* We expect ram_top as Kbytes, so convert to paragraphs */ + mcb_init((mcb FAR *) (MK_FP(first_mcb, 0)), + (ram_top << 6) - first_mcb - 1); + nPass = 1; +} + +/* Do second pass initialization. */ +/* Also, run config.sys to load drivers. */ +INIT void PostConfig(void) +{ + /* Set pass number */ + nPass = 2; + + /* Initialize the base memory pointers from last time. */ + lpBase = AlignParagraph(lpOldLast); + + /* Begin by initializing our system buffers */ + dma_scratch = (BYTE FAR *) KernelAllocDma(BUFFERSIZE); +#ifdef DEBUG + printf("DMA scratchpad allocated at 0x%04x:0x%04x\n", FP_SEG(dma_scratch), + FP_OFF(dma_scratch)); +#endif + buffers = (struct buffer FAR *) + KernelAlloc(Config.cfgBuffers * sizeof(struct buffer)); +#ifdef DEBUG + printf("%d buffers allocated at 0x%04x:0x%04x\n", Config.cfgBuffers, + FP_SEG(buffers), FP_OFF(buffers)); +#endif + + /* Initialize the file table */ + f_nodes = (struct f_node FAR *) + KernelAlloc(Config.cfgFiles * sizeof(struct f_node)); + /* sfthead = (sfttbl FAR *)&basesft; */ + /* FCBp = (sfttbl FAR *)&FcbSft; */ + FCBp = (sfttbl FAR *) + KernelAlloc(sizeof(sftheader) + + Config.cfgFiles * sizeof(sft)); + sfthead = (sfttbl FAR *) + KernelAlloc(sizeof(sftheader) + + Config.cfgFiles * sizeof(sft)); + + CDSp = (cdstbl FAR *) + KernelAlloc(0x58 * lastdrive + 1); + +#ifdef DEBUG + + printf("f_node allocated at 0x%04x:0x%04x\n", + FP_SEG(f_nodes), FP_OFF(f_nodes)); + printf("FCB table allocated at 0x%04x:0x%04x\n", + FP_SEG(FCBp), FP_OFF(FCBp)); + printf("sft table allocated at 0x%04x:0x%04x\n", + FP_SEG(sfthead), FP_OFF(sfthead)); + printf("CDS table allocated at 0x%04x:0x%04x\n", + FP_SEG(CDSp), FP_OFF(CDSp)); +#endif + if (Config.cfgStacks) + { + VOID FAR *stackBase = KernelAlloc(Config.cfgStacks * Config.cfgStackSize); + init_stacks(stackBase, Config.cfgStacks, Config.cfgStackSize); + +#ifdef DEBUG + printf("Stacks allocated at %04x:%04x\n", + FP_SEG(stackBase), FP_OFF(stackBase)); +#endif + } +#ifdef DEBUG + printf("Allocation completed: top at 0x%04x:0x%04x\n", + FP_SEG(lpBase), FP_OFF(lpBase)); +#endif +} + +/* This code must be executed after device drivers has been loaded */ +INIT VOID configDone(VOID) +{ + COUNT i; + + first_mcb = FP_SEG(lpBase) + ((FP_OFF(lpBase) + 0x0f) >> 4); + + /* We expect ram_top as Kbytes, so convert to paragraphs */ + mcb_init((mcb FAR *) (MK_FP(first_mcb, 0)), + (ram_top << 6) - first_mcb - 1); + + /* The standard handles should be reopened here, because + we may have loaded new console or printer drivers in CONFIG.SYS */ +} + +INIT VOID DoConfig(VOID) +{ + COUNT nFileDesc; + COUNT nRetCode; + BYTE *pLine, + *pTmp; + BOOL bEof; + + /* Check to see if we have a config.sys file. If not, just */ + /* exit since we don't force the user to have one. */ + if ((nFileDesc = dos_open((BYTE FAR *) "fdconfig.sys", 0)) < 0) + { +#ifdef DEBUG + printf("FDCONFIG.SYS not found\n"); +#endif + if ((nFileDesc = dos_open((BYTE FAR *) "config.sys", 0)) < 0) + { +#ifdef DEBUG + printf("CONFIG.SYS not found\n"); +#endif + return; + } +#ifdef DEBUG + else + printf("Reading CONFIG.SYS...\n"); +#endif + } +#ifdef DEBUG + else + printf("Reading FDCONFIG.SYS...\n"); +#endif + + /* Have one -- initialize. */ + nCfgLine = 0; + bEof = 0; + pLine = szLine; + + /* Read each line into the buffer and then parse the line, */ + /* do the table lookup and execute the handler for that */ + /* function. */ + while (!bEof) + { + struct table *pEntry; + UWORD bytesLeft = 0; + + if (pLine > szLine) + bytesLeft = LINESIZE - (pLine - szLine); + + if (bytesLeft) + { + fbcopy(pLine, szLine, LINESIZE - bytesLeft); + pLine = szLine + bytesLeft; + } + + /* Read a line from config */ + /* Interrupt processing if read error or no bytes read */ + if ((nRetCode = dos_read(nFileDesc, pLine, LINESIZE - bytesLeft)) <= 0) + break; + + /* If the buffer was not filled completely, append a + CTRL-Z character to mark where the file ends */ + + if (nRetCode + bytesLeft < LINESIZE) + szLine[nRetCode + bytesLeft] = EOF; + + /* Process the buffer, line by line */ + pLine = szLine; + + while (!bEof && *pLine != EOF) + { + for (pTmp = pLine; pTmp - szLine < LINESIZE; pTmp++) + { + if (*pTmp == '\r' || *pTmp == EOF) + break; + } + + if (pTmp - szLine >= LINESIZE) + break; + + if (*pTmp == EOF) + bEof = TRUE; + + *pTmp = '\0'; + pLineStart = pLine; + + /* Skip leading white space and get verb. */ + pLine = scan(pLine, szBuf); + + /* Translate the verb to lower case ... */ + for (pTmp = szBuf; *pTmp != '\0'; pTmp++) + *pTmp = tolower(*pTmp); + + /* If the line was blank, skip it. Otherwise, look up */ + /* the verb and execute the appropriate function. */ + if (*szBuf != '\0') + { + pEntry = LookUp(commands, szBuf); + + if (pEntry->pass < 0 || pEntry->pass == nPass) + { + if (!singleStep || !SkipLine(pLineStart)) + { + skipwh(pLine); + + if ('=' != *pLine) + CfgFailure(pLine); + else + (*(pEntry->func)) (++pLine); + } + } + } + skipLine:nCfgLine++; + pLine += strlen(pLine) + 1; + } + } + dos_close(nFileDesc); +} + +INIT struct table *LookUp(struct table *p, BYTE * token) +{ + while (*(p->entry) != '\0') + { + if (strcmp(p->entry, token) == 0) + break; + else + ++p; + } + return p; +} + +INIT BOOL SkipLine(char *pLine) +{ + char kbdbuf[16]; + keyboard *kp = (keyboard *) kbdbuf; + char *pKbd = &kp->kb_buf[0]; + + kp->kb_size = 12; + kp->kb_count = 0; + + printf("%s [Y,N]?", pLine); + sti(kp); + + pKbd = skipwh(pKbd); + + if (*pKbd == 'n' || *pKbd == 'N') + return TRUE; + + return FALSE; +} + +INIT BYTE *GetNumArg(BYTE * pLine, COUNT * pnArg) +{ + /* look for NUMBER */ + pLine = skipwh(pLine); + if (!isnum(pLine)) + { + CfgFailure(pLine); + return (BYTE *) 0; + } + return GetNumber(pLine, pnArg); +} + +INIT BYTE *GetStringArg(BYTE * pLine, BYTE * pszString) +{ + /* look for STRING */ + pLine = skipwh(pLine); + + /* just return whatever string is there, including null */ + return scan(pLine, pszString); +} + +INIT static VOID Buffers(BYTE * pLine) +{ + COUNT nBuffers; + + /* Get the argument */ + if (GetNumArg(pLine, &nBuffers) == (BYTE *) 0) + return; + + /* Got the value, assign either default or new value */ + Config.cfgBuffers = max(Config.cfgBuffers, nBuffers); +} + +INIT static VOID sysScreenMode(BYTE * pLine) +{ + COUNT nMode; + + /* Get the argument */ + if (GetNumArg(pLine, &nMode) == (BYTE *) 0) + return; + + if ((nMode != 0x11) && (nMode != 0x12) && (nMode != 0x14)) + return; + +/* Modes + 0x11 (17) 28 lines + 0x12 (18) 43/50 lines + 0x14 (20) 25 lines + */ + _AX = (0x11 << 8) + nMode; + _BL = 0; + __int__(0x10); +} + +INIT static VOID sysVersion(BYTE * pLine) +{ + COUNT major, + minor; + char *p; + + p = pLine; + while (*p && *p != '.') + p++; + + if (*p++ == '\0') + return; + + /* Get major number */ + if (GetNumArg(pLine, &major) == (BYTE *) 0) + return; + + /* Get minor number */ + if (GetNumArg(p, &minor) == (BYTE *) 0) + return; + + printf("Changing reported version to %d.%d\n", major, minor); + + os_major = major; + os_minor = minor; +} + +INIT static VOID Files(BYTE * pLine) +{ + COUNT nFiles; + + /* Get the argument */ + if (GetNumArg(pLine, &nFiles) == (BYTE *) 0) + return; + + /* Got the value, assign either default or new value */ + Config.cfgFiles = max(Config.cfgFiles, nFiles); +} + +INIT static VOID Lastdrive(BYTE * pLine) +{ + /* Format: LASTDRIVE = letter */ + COUNT nFiles; + BYTE drv; + + pLine = skipwh(pLine); + drv = *pLine & ~0x20; + + if (drv < 'A' || drv > 'Z') + { + CfgFailure(pLine); + return; + } + drv -= 'A'; + Config.cfgLastdrive = max(Config.cfgLastdrive, drv); +} + +INIT static VOID Switchar(BYTE * pLine) +{ + /* Format: SWITCHAR = character */ + + GetStringArg(pLine, szBuf); + switchar = *szBuf; +} + +INIT static VOID Fcbs(BYTE * pLine) +{ + /* Format: FCBS = totalFcbs [,protectedFcbs] */ + COUNT fcbs; + + if ((pLine = GetNumArg(pLine, &fcbs)) == 0) + return; + Config.cfgFcbs = fcbs; + + pLine = skipwh(pLine); + + if (*pLine == ',') + { + GetNumArg(++pLine, &fcbs); + Config.cfgProtFcbs = fcbs; + } + + if (Config.cfgProtFcbs > Config.cfgFcbs) + Config.cfgProtFcbs = Config.cfgFcbs; +} + +INIT static VOID Country(BYTE * pLine) +{ + /* Format: COUNTRY = countryCode, [codePage], filename */ + COUNT ctryCode; + COUNT codePage; + + if ((pLine = GetNumArg(pLine, &ctryCode)) == 0) + return; + + pLine = skipwh(pLine); + if (*pLine == ',') + { + pLine = skipwh(pLine); + + if (*pLine == ',') + { + codePage = 0; + ++pLine; + } + else + { + if ((pLine = GetNumArg(pLine, &codePage)) == 0) + return; + } + + pLine = skipwh(pLine); + if (*pLine == ',') + { + GetStringArg(++pLine, szBuf); + + if (LoadCountryInfo(szBuf, ctryCode, codePage)) + return; + } + } + CfgFailure(pLine); +} + +INIT static VOID Stacks(BYTE * pLine) +{ + COUNT stacks; + + /* Format: STACKS = stacks [, stackSize] */ + pLine = GetNumArg(pLine, &stacks); + Config.cfgStacks = stacks; + + pLine = skipwh(pLine); + + if (*pLine == ',') + { + GetNumArg(++pLine, &stacks); + Config.cfgStackSize = stacks; + } + + if (Config.cfgStacks) + { + if (Config.cfgStackSize < 32) + Config.cfgStackSize = 32; + if (Config.cfgStackSize > 512) + Config.cfgStackSize = 512; + if (Config.cfgStacks > 64) + Config.cfgStacks = 64; + } +} + +INIT static VOID InitPgm(BYTE * pLine) +{ + /* Get the string argument that represents the new init pgm */ + pLine = GetStringArg(pLine, Config.cfgInit); + + /* Now take whatever tail is left and add it on as a single */ + /* string. */ + strcpy(Config.cfgInitTail, pLine); + + /* and add a DOS new line just to be safe */ + strcat(Config.cfgInitTail, "\r\n"); +} + +INIT static VOID Break(BYTE * pLine) +{ + /* Format: BREAK = (ON | OFF) */ + BYTE *pTmp; + + GetStringArg(pLine, szBuf); + break_ena = strcmp(szBuf, "OFF") ? 1 : 0; +} + +INIT static VOID Device(BYTE * pLine) +{ + VOID FAR *driver_ptr; + BYTE *pTmp; + exec_blk eb; + struct dhdr FAR *dhp; + struct dhdr FAR *next_dhp; + UWORD dev_seg = (((ULONG) FP_SEG(lpBase) << 4) + FP_OFF(lpBase) + 0xf) >> 4; + + /* Get the device driver name */ + GetStringArg(pLine, szBuf); + + /* The driver is loaded at the top of allocated memory. */ + /* The device driver is paragraph aligned. */ + eb.load.reloc = eb.load.load_seg = dev_seg; + dhp = MK_FP(dev_seg, 0); + +#ifdef DEBUG + printf("Loading device driver %s at segment %04x\n", + szBuf, dev_seg); +#endif + + if (DosExec(3, &eb, szBuf) == SUCCESS) + { + while (FP_OFF(dhp) != 0xFFFF) + { + next_dhp = MK_FP(FP_SEG(dhp), FP_OFF(dhp->dh_next)); + dhp->dh_next = nul_dev.dh_next; + link_dhdr(&nul_dev, dhp, pLine); + dhp = next_dhp; + } + } + else + CfgFailure(pLine); +} + +INIT static VOID CfgFailure(BYTE * pLine) +{ + BYTE *pTmp = pLineStart; + + printf("CONFIG.SYS error in line %d\n", nCfgLine); + printf(">>>%s\n", pTmp); + while (++pTmp != pLine) + printf(" "); + printf("^\n"); +} + +#ifndef KDB +INIT static BYTE FAR *KernelAlloc(WORD nBytes) +{ + BYTE FAR *lpAllocated; + + lpBase = AlignParagraph(lpBase); + lpAllocated = lpBase; + + if (0x10000 - FP_OFF(lpBase) <= nBytes) + { + UWORD newOffs = (FP_OFF(lpBase) + nBytes) & 0xFFFF; + UWORD newSeg = FP_SEG(lpBase) + 0x1000; + + lpBase = MK_FP(newSeg, newOffs); + } + else + lpBase += nBytes; + + return lpAllocated; +} +#endif + +#ifdef I86 +INIT static BYTE FAR *KernelAllocDma(WORD bytes) +{ + BYTE FAR *allocated; + + lpBase = AlignParagraph(lpBase); + if ((FP_SEG(lpBase) & 0x0fff) + (bytes >> 4) > 0x1000) + lpBase = MK_FP((FP_SEG(lpBase) + 0x0fff) & 0xf000, 0); + allocated = lpBase; + lpBase += bytes; + return allocated; +} + +INIT static VOID FAR *AlignParagraph(VOID FAR * lpPtr) +{ + ULONG lTemp; + UWORD uSegVal; + + /* First, convert the segmented pointer to linear address */ + lTemp = FP_SEG(lpPtr); + lTemp = (lTemp << 4) + FP_OFF(lpPtr); + + /* Next, round up the linear address to a paragraph boundary. */ + lTemp += 0x0f; + lTemp &= 0xfffffff0l; + + /* Break it into segments. */ + uSegVal = (UWORD) (lTemp >> 4); + + /* and return an adddress adjusted to the nearest paragraph */ + /* boundary. */ + return MK_FP(uSegVal, 0); +} +#endif + +INIT BYTE * + skipwh(BYTE * s) +{ + while (*s && (*s == 0x0d || *s == 0x0a || *s == ' ' || *s == '\t')) + ++s; + return s; +} + +INIT BYTE * + scan(BYTE * s, BYTE * d) +{ + s = skipwh(s); + while (*s && + !(*s == 0x0d + || *s == 0x0a + || *s == ' ' + || *s == '\t' + || *s == '=')) + *d++ = *s++; + *d = '\0'; + return s; +} + +INIT BYTE *scan_seperator(BYTE * s, BYTE * d) +{ + s = skipwh(s); + if (*s) + *d++ = *s++; + *d = '\0'; + return s; +} + +INIT BOOL isnum(BYTE * pLine) +{ + return (*pLine >= '0' && *pLine <= '9'); +} + +/* JPP - changed so will accept hex number. */ +INIT BYTE *GetNumber(REG BYTE * pszString, REG COUNT * pnNum) +{ + BYTE Base = 10; + + *pnNum = 0; + while (isnum(pszString) || toupper(*pszString) == 'X') + { + if (toupper(*pszString) == 'X') + { + Base = 16; + pszString++; + } + else + *pnNum = *pnNum * Base + (*pszString++ - '0'); + } + return pszString; +} + +/* Yet another change for true portability (WDL) */ +INIT COUNT tolower(COUNT c) +{ + if (c >= 'A' && c <= 'Z') + return (c + ('a' - 'A')); + else + return c; +} + +/* Yet another change for true portability (PJV) */ +INIT COUNT toupper(COUNT c) +{ + if (c >= 'a' && c <= 'z') + return (c - ('a' - 'A')); + else + return c; +} + +/* The following code is 8086 dependant */ + +#ifdef KERNEL +INIT VOID + mcb_init(mcb FAR * mcbp, UWORD size) +{ + COUNT i; + + mcbp->m_type = MCB_LAST; + mcbp->m_psp = FREE_PSP; + mcbp->m_size = size; + for (i = 0; i < 8; i++) + mcbp->m_name[i] = '\0'; + mem_access_mode = FIRST_FIT; +} +#endif + +INIT VOID + strcat(REG BYTE * d, REG BYTE * s) +{ + while (*d != 0) + ++d; + strcpy(d, s); +} + diff --git a/kernel/console.asm b/kernel/console.asm new file mode 100644 index 00000000..9dadbfb9 --- /dev/null +++ b/kernel/console.asm @@ -0,0 +1,279 @@ +; +; File: +; console.asm +; Description: +; Console device driver +; +; Copyright (c) 1998 +; Pasquale J. Villani +; All Rights Reserved +; +; This file is part of DOS-C. +; +; DOS-C is free software; you can redistribute it and/or +; modify it under the terms of the GNU General Public License +; as published by the Free Software Foundation; either version +; 2, or (at your option) any later version. +; +; DOS-C is distributed in the hope that it will be useful, but +; WITHOUT ANY WARRANTY; without even the implied warranty of +; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See +; the GNU General Public License for more details. +; +; You should have received a copy of the GNU General Public +; License along with DOS-C; see the file COPYING. If not, +; write to the Free Software Foundation, 675 Mass Ave, +; Cambridge, MA 02139, USA. +; +; $Header$ +; +; $Log$ +; Revision 1.1 2000/05/06 19:34:56 jhall1 +; Initial revision +; +; Revision 1.8 2000/03/09 06:07:10 kernel +; 2017f updates by James Tabor +; +; Revision 1.7 1999/09/23 04:40:46 jprice +; *** empty log message *** +; +; Revision 1.5 1999/09/14 16:31:38 jprice +; no message +; +; Revision 1.4 1999/09/13 22:16:14 jprice +; Fix 210B function +; +; Revision 1.3 1999/09/13 21:00:19 jprice +; Changes from Helmut Fritsch to fix INT21 func B +; +; Revision 1.2 1999/08/10 17:57:12 jprice +; ror4 2011-02 patch +; +; Revision 1.1.1.1 1999/03/29 15:40:47 jprice +; New version without IPL.SYS +; +; Revision 1.1 1999/02/08 05:55:57 jprice +; Added Pat's 1937 kernel patches +; +; $EndLog$ +; + + %include "io.inc" + + +segment _IO_FIXED_DATA + + global ConTable +ConTable db 0Ah + dw _IOExit + dw _IOExit + dw _IOExit + dw _IOCommandError + dw ConRead + dw CommonNdRdExit + dw ConInStat + dw ConInpFlush + dw ConWrite + dw ConWrite + dw _IOExit + +PRT_SCREEN equ 7200h +CTL_P equ 10h + +segment _IO_TEXT + +uScanCode db 0 ; Scan code for con: device + +; +; Name: +; ConRead +; +; Function: +; Read to address in es:di characters from the keyboard. Cx contains +; a count of how many characters are to be transferred. +; +; Description: +; Calls KbdRdChar to read the characters. Destroys ax. +; + global ConRead +ConRead: + jcxz ConRead2 ; Exit if read of zero + +ConRead1: + call KbdRdChar ; Get a char from kbd in al + stosb ; Store al to es:[di] + loop ConRead1 ; Loop until all are read + +ConRead2: + jmp _IOExit + + +; +; Name: +; KbdRdChar +; +; Function: +; Read a character from the keyboard. +; +; Description: +; This subroutine reads a character fromthe keyboard. It also handles +; a couple of special functions. It converts the print screen key to +; a control-P. It also accounts for extended scan codes by saving off +; the high byte of the return and returning it if it was non-zero on +; the previous read. +; + global KbdRdChar +KbdRdChar: + xor ax,ax ; Zero the scratch register + xchg [cs:uScanCode],al ; and swap with scan code + or al,al ; Test to see if it was set + jnz KbdRdRtn ; Exit if it was, returning it + int 16h ; get keybd char in al, ah=scan + or ax,ax ; Zero ? + jz KbdRdChar ; Loop if it is + cmp ax,PRT_SCREEN ; Print screen? + jne KbdRd1 ; Nope, keep going + mov al,CTL_P ; Yep, make it ^P +KbdRd1: + or al,al ; Extended key? + jnz KbdRdRtn ; Nope, just exit + mov [cs:uScanCode],ah ; Yep, save the scan code +KbdRdRtn: + retn + + + + global CommonNdRdExit +CommonNdRdExit: + mov al,[cs:uScanCode] ; Test for last scan code + or al,al ; Was it zero ? + jnz ConNdRd2 ; Jump if there's a char waiting + mov ah,1 + int 16h ; Get status, if zf=0 al=char + jz ConNdRd4 ; Jump if chrar available + or ax,ax ; Zero ? + jnz ConNdRd1 ; Jump if not zero + int 16h ; get status, if zf=0 al=char + jmp short CommonNdRdExit + +ConNdRd1: + cmp ax,PRT_SCREEN ; Was print screen key pressed? + jne ConNdRd2 ; Jump if not + mov al,CTL_P + +ConNdRd2: + lds bx,[_ReqPktPtr] ; Set the status + mov [bx+0Dh],al + +ConNdRd3: + jmp _IOExit + +ConNdRd4: + jmp _IODone + + + + global ConInpFlush +ConInpFlush: + call KbdInpChar + jmp _IOExit + + + +KbdInpChar: + mov byte [cs:uScanCode],0 +KbdInpCh1: + mov ah,1 + int 16h ; get status, if zf=0 al=char + jz KbdInpRtn ; Jump if zero + xor ah,ah ; Zero register + int 16h ; get keybd char in al, ah=scan + jmp short KbdInpCh1 +KbdInpRtn: + retn + + + global ConWrite +ConWrite: + jcxz ConNdRd3 ; Exit if nothing to write +ConWr1: + mov al,[es:di] + inc di + int 29h ; Do fast output call + loop ConWr1 ; Loop if more to output + jmp _IOExit + +CBreak: + mov byte [cs:uScanCode],3 ; Put a ^C into the buffer +IntRetn: + iret + + + global _cso +_cso + push bp + mov bp,sp + push ax + mov ax,[bp+4] + int 29h + pop ax + pop bp + retn + + global _int29_handler +_int29_handler: + push ax + push si + push di + push bp + push bx + mov ah,0Eh + mov bh,0 + mov bl,7 + int 10h ; write char al, teletype mode + pop bx + pop bp + pop di + pop si + pop ax + iret + + +; +; Name: +; ConInStat +; +; Function: +; Checks the keybord input buffer. +; +; Description: +; Calls int 16 (get status). Sets Busy-Flag in status field. Destroys ax. +; + global ConInStat +ConInStat: + mov al,[cs:uScanCode] ; Test for last scan code + or al,al ; Was it zero ? + jnz ConCharReady ; Jump if there's a char waiting + mov ah,1 + int 16h ; get status, if zf=0 al=char + jz ConNoChar ; Jump if zero + + or ax,ax ; Zero ? + jnz ConIS1 ; Jump if not zero + int 16h ; get status, if zf=0 al=char + jmp short ConInStat + +ConIS1: + cmp ax,PRT_SCREEN ; Was print screen key pressed? + jne ConIS2 ; Jump if not + mov al,CTL_P + +ConIS2: + lds bx,[_ReqPktPtr] ; Set the status + mov [bx+0Dh],al +ConCharReady: + jmp _IODone ; key ready (busy=1) +ConNoChar: + jmp _IOExit ; no key ready (busy=0) + + diff --git a/kernel/dosfns.c b/kernel/dosfns.c new file mode 100644 index 00000000..536a0d63 --- /dev/null +++ b/kernel/dosfns.c @@ -0,0 +1,1148 @@ +/****************************************************************/ +/* */ +/* dosfns.c */ +/* */ +/* DOS functions */ +/* */ +/* Copyright (c) 1995 */ +/* Pasquale J. Villani */ +/* All Rights Reserved */ +/* */ +/* This file is part of DOS-C. */ +/* */ +/* DOS-C is free software; you can redistribute it and/or */ +/* modify it under the terms of the GNU General Public License */ +/* as published by the Free Software Foundation; either version */ +/* 2, or (at your option) any later version. */ +/* */ +/* DOS-C is distributed in the hope that it will be useful, but */ +/* WITHOUT ANY WARRANTY; without even the implied warranty of */ +/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See */ +/* the GNU General Public License for more details. */ +/* */ +/* You should have received a copy of the GNU General Public */ +/* License along with DOS-C; see the file COPYING. If not, */ +/* write to the Free Software Foundation, 675 Mass Ave, */ +/* Cambridge, MA 02139, USA. */ +/****************************************************************/ + +#include "portab.h" + +#ifdef VERSION_STRINGS +static BYTE *dosfnsRcsId = "$Id$"; +#endif + +/* + * $Log$ + * Revision 1.1 2000/05/06 19:34:59 jhall1 + * Initial revision + * + * Revision 1.11 2000/03/09 06:07:11 kernel + * 2017f updates by James Tabor + * + * Revision 1.10 1999/09/23 04:40:46 jprice + * *** empty log message *** + * + * Revision 1.8 1999/09/14 01:01:53 jprice + * Fixed bug where you could write over directories. + * + * Revision 1.7 1999/08/25 03:18:07 jprice + * ror4 patches to allow TC 2.01 compile. + * + * Revision 1.6 1999/05/03 06:25:45 jprice + * Patches from ror4 and many changed of signed to unsigned variables. + * + * Revision 1.5 1999/04/16 12:21:22 jprice + * Steffen c-break handler changes + * + * Revision 1.4 1999/04/12 03:21:17 jprice + * more ror4 patches. Changes for multi-block IO + * + * Revision 1.3 1999/04/11 04:33:38 jprice + * ror4 patches + * + * Revision 1.2 1999/04/04 18:51:43 jprice + * no message + * + * Revision 1.1.1.1 1999/03/29 15:41:52 jprice + * New version without IPL.SYS + * + * Revision 1.4 1999/02/09 02:54:23 jprice + * Added Pat's 1937 kernel patches + * + * Revision 1.3 1999/02/01 01:43:28 jprice + * Fixed findfirst function to find volume label with Windows long filenames + * + * Revision 1.2 1999/01/22 04:15:28 jprice + * Formating + * + * Revision 1.1.1.1 1999/01/20 05:51:00 jprice + * Imported sources + * + * Rev 1.10 06 Dec 1998 8:44:42 patv + * Expanded dos functions due to new I/O subsystem. + * + * Rev 1.9 04 Jan 1998 23:14:38 patv + * Changed Log for strip utility + * + * Rev 1.8 03 Jan 1998 8:36:04 patv + * Converted data area to SDA format + * + * Rev 1.7 22 Jan 1997 12:59:56 patv + * pre-0.92 bug fixes + * + * Rev 1.6 16 Jan 1997 12:46:32 patv + * pre-Release 0.92 feature additions + * + * Rev 1.5 29 May 1996 21:15:20 patv + * bug fixes for v0.91a + * + * Rev 1.4 19 Feb 1996 3:20:08 patv + * Added NLS, int2f and config.sys processing + * + * Rev 1.2 01 Sep 1995 17:48:48 patv + * First GPL release. + * + * Rev 1.1 30 Jul 1995 20:50:24 patv + * Eliminated version strings in ipl + * + * Rev 1.0 02 Jul 1995 8:04:20 patv + * Initial revision. + */ + +#include "globals.h" + +sft FAR *get_sft(COUNT); +WORD get_free_hndl(VOID); +sft FAR *get_free_sft(WORD FAR *); +BYTE FAR *get_root(BYTE FAR *); +BOOL cmatch(COUNT, COUNT, COUNT); +BOOL fnmatch(BYTE FAR *, BYTE FAR *, COUNT, COUNT); + +struct f_node FAR *xlt_fd(COUNT); + +static VOID DosGetFile(BYTE FAR * lpszPath, BYTE FAR * lpszDosFileName) +{ + BYTE szLclName[FNAME_SIZE + 1]; + BYTE szLclExt[FEXT_SIZE + 1]; + + ParseDosName(lpszPath, (COUNT *) 0, (BYTE *) 0, + szLclName, szLclExt, FALSE); + SpacePad(szLclName, FNAME_SIZE); + SpacePad(szLclExt, FEXT_SIZE); + fbcopy((BYTE FAR *) szLclName, lpszDosFileName, FNAME_SIZE); + fbcopy((BYTE FAR *) szLclExt, &lpszDosFileName[FNAME_SIZE], FEXT_SIZE); +} + +sft FAR *get_sft(COUNT hndl) +{ + psp FAR *p = MK_FP(cu_psp, 0); + WORD sys_idx; + sfttbl FAR *sp; + + if (hndl >= p->ps_maxfiles) + return (sft FAR *) - 1; + + /* Get the SFT block that contains the SFT */ + if (p->ps_filetab[hndl] == 0xff) + return (sft FAR *) - 1; + + sys_idx = p->ps_filetab[hndl]; + for (sp = sfthead; sp != (sfttbl FAR *) - 1; sp = sp->sftt_next) + { + if (sys_idx < sp->sftt_count) + break; + else + sys_idx -= sp->sftt_count; + } + + /* If not found, return an error */ + if (sp == (sfttbl FAR *) - 1) + return (sft FAR *) - 1; + + /* finally, point to the right entry */ + return (sft FAR *) & (sp->sftt_table[sys_idx]); +} + +/* + * The `force_binary' parameter is a hack to allow functions 0x01, 0x06, 0x07, + * and function 0x40 to use the same code for performing reads, even though the + * two classes of functions behave quite differently: 0x01 etc. always do + * binary reads, while for 0x40 the type of read (binary/text) depends on what + * the SFT says. -- ror4 + */ +UCOUNT GenericRead(COUNT hndl, UCOUNT n, BYTE FAR * bp, COUNT FAR * err, + BOOL force_binary) +{ + sft FAR *s; + WORD sys_idx; + sfttbl FAR *sp; + UCOUNT ReadCount; + + /* Test that the handle is valid */ + if (hndl < 0) + { + *err = DE_INVLDHNDL; + return 0; + } + + /* Get the SFT block that contains the SFT */ + if ((s = get_sft(hndl)) == (sft FAR *) - 1) + { + *err = DE_INVLDHNDL; + return 0; + } + + /* If not open or write permission - exit */ + if (s->sft_count == 0 || (s->sft_mode & SFT_MWRITE)) + { + *err = DE_INVLDACC; + return 0; + } + +/* + * Do remote first or return error. + * must have been opened from remote. + */ + if (s->sft_flags & SFT_FSHARED) + { + ReadCount = Remote_RW(REM_READ, n, bp, s, err); + if (err) + { + *err = SUCCESS; + return ReadCount; + } + else + return 0; + } + /* Do a device read if device */ + if (s->sft_flags & SFT_FDEVICE) + { + request rq; + + /* First test for eof and exit */ + /* immediately if it is */ + if (!(s->sft_flags & SFT_FEOF) || (s->sft_flags & SFT_FNUL)) + { + s->sft_flags &= ~SFT_FEOF; + *err = SUCCESS; + return 0; + } + + /* Now handle raw and cooked modes */ + if (force_binary || (s->sft_flags & SFT_FBINARY)) + { + rq.r_length = sizeof(request); + rq.r_command = C_INPUT; + rq.r_count = n; + rq.r_trans = (BYTE FAR *) bp; + rq.r_status = 0; + execrh((request FAR *) & rq, s->sft_dev); + if (rq.r_status & S_ERROR) + { + char_error(&rq, s->sft_dev); + } + else + { + *err = SUCCESS; + return rq.r_count; + } + } + else if (s->sft_flags & SFT_FCONIN) + { + kb_buf.kb_size = LINESIZE - 1; + kb_buf.kb_count = 0; + sti((keyboard FAR *) & kb_buf); + fbcopy((BYTE FAR *) kb_buf.kb_buf, bp, kb_buf.kb_count); + *err = SUCCESS; + return kb_buf.kb_count; + } + else + { + *bp = _sti(); + *err = SUCCESS; + return 1; + } + } + else + /* a block read */ + { + COUNT rc; + + ReadCount = readblock(s->sft_status, bp, n, &rc); + if (rc != SUCCESS) + { + *err = rc; + return 0; + } + else + { + *err = SUCCESS; + return ReadCount; + } + } + *err = SUCCESS; + return 0; +} + +UCOUNT DosRead(COUNT hndl, UCOUNT n, BYTE FAR * bp, COUNT FAR * err) +{ + return GenericRead(hndl, n, bp, err, FALSE); +} + +UCOUNT DosWrite(COUNT hndl, UCOUNT n, BYTE FAR * bp, COUNT FAR * err) +{ + sft FAR *s; + WORD sys_idx; + sfttbl FAR *sp; + UCOUNT ReadCount; + + /* Test that the handle is valid */ + if (hndl < 0) + { + *err = DE_INVLDHNDL; + return 0; + } + + /* Get the SFT block that contains the SFT */ + if ((s = get_sft(hndl)) == (sft FAR *) - 1) + { + *err = DE_INVLDHNDL; + return 0; + } + + /* If this is not opened and it's not a write */ + /* another error */ + if (s->sft_count == 0 || + (!(s->sft_mode & SFT_MWRITE) && !(s->sft_mode & SFT_MRDWR))) + { + *err = DE_ACCESS; + return 0; + } + if (s->sft_flags & SFT_FSHARED) + { + ReadCount = Remote_RW(REM_WRITE, n, bp, s, err); + if (err) + { + return ReadCount; + } + else + return 0; + } + + /* Do a device write if device */ + if (s->sft_flags & SFT_FDEVICE) + { + request rq; + + /* set to no EOF */ + s->sft_flags &= ~SFT_FEOF; + + /* if null just report full transfer */ + if (s->sft_flags & SFT_FNUL) + { + *err = SUCCESS; + return n; + } + + /* Now handle raw and cooked modes */ + if (s->sft_flags & SFT_FBINARY) + { + rq.r_length = sizeof(request); + rq.r_command = C_OUTPUT; + rq.r_count = n; + rq.r_trans = (BYTE FAR *) bp; + rq.r_status = 0; + execrh((request FAR *) & rq, s->sft_dev); + if (rq.r_status & S_ERROR) + { + char_error(&rq, s->sft_dev); + } + else + { + if (s->sft_flags & SFT_FCONOUT) + { + WORD cnt = rq.r_count; + while (cnt--) + { + switch (*bp++) + { + case CR: + scr_pos = 0; + break; + case LF: + case BELL: + break; + case BS: + --scr_pos; + break; + default: + ++scr_pos; + } + } + } + *err = SUCCESS; + return rq.r_count; + } + } + else + { + REG WORD c, + cnt = n, + spaces_left = 0, + next_pos, + xfer = 0; + static BYTE space = ' '; + + start: + if (cnt-- == 0) + goto end; + if (*bp == CTL_Z) + goto end; + if (s->sft_flags & SFT_FCONOUT) + { + switch (*bp) + { + case CR: + next_pos = 0; + break; + case LF: + case BELL: + next_pos = scr_pos; + break; + case BS: + next_pos = scr_pos ? scr_pos - 1 : 0; + break; + case HT: + spaces_left = 8 - (scr_pos & 7); + next_pos = scr_pos + spaces_left; + goto output_space; + default: + next_pos = scr_pos + 1; + } + } + rq.r_length = sizeof(request); + rq.r_command = C_OUTPUT; + rq.r_count = 1; + rq.r_trans = bp; + rq.r_status = 0; + execrh((request FAR *) & rq, s->sft_dev); + if (rq.r_status & S_ERROR) + char_error(&rq, s->sft_dev); + goto post; + output_space: + rq.r_length = sizeof(request); + rq.r_command = C_OUTPUT; + rq.r_count = 1; + rq.r_trans = &space; + rq.r_status = 0; + execrh((request FAR *) & rq, s->sft_dev); + if (rq.r_status & S_ERROR) + char_error(&rq, s->sft_dev); + --spaces_left; + post: + if (spaces_left) + goto output_space; + ++bp; + ++xfer; + if (s->sft_flags & SFT_FCONOUT) + scr_pos = next_pos; + if (break_ena && control_break()) + { + handle_break(); + goto end; + } + goto start; + end: + *err = SUCCESS; + return xfer; + } + } + else + /* a block write */ + { + COUNT rc; + + ReadCount = writeblock(s->sft_status, bp, n, &rc); + if (rc < SUCCESS) + { + *err = rc; + return 0; + } + else + { + *err = SUCCESS; + return ReadCount; + } + } + *err = SUCCESS; + return 0; +} + +COUNT DosSeek(COUNT hndl, LONG new_pos, COUNT mode, ULONG * set_pos) +{ + sft FAR *s; + ULONG lrx; + + /* Test for invalid mode */ + if (mode < 0 || mode > 2) + return DE_INVLDFUNC; + + /* Test that the handle is valid */ + if (hndl < 0) + return DE_INVLDHNDL; + + /* Get the SFT block that contains the SFT */ + if ((s = get_sft(hndl)) == (sft FAR *) - 1) + return DE_INVLDHNDL; + + lpCurSft = (sfttbl FAR *) s; + + if (s->sft_flags & SFT_FSHARED) + { + if (mode == 2) + { /* seek from end of file */ + int2f_Remote_call(REM_LSEEK, 0, (UWORD) FP_SEG(new_pos), (UWORD) FP_OFF(new_pos), (VOID FAR *) s, 0, 0); + *set_pos = s->sft_posit; + return SUCCESS; + } + if (mode == 0) + { + s->sft_posit = new_pos; + *set_pos = new_pos; + return SUCCESS; + } + if (mode == 1) + { + s->sft_posit += new_pos; + *set_pos = s->sft_posit; + return SUCCESS; + } + return DE_INVLDFUNC; + } + + /* Do special return for character devices */ + if (s->sft_flags & SFT_FDEVICE) + { + *set_pos = 0l; + return SUCCESS; + } + else + { + *set_pos = dos_lseek(s->sft_status, new_pos, mode); + if ((LONG) * set_pos < 0) + return (int)*set_pos; + else + return SUCCESS; + } +} + +static WORD get_free_hndl(void) +{ + psp FAR *p = MK_FP(cu_psp, 0); + WORD hndl; + + for (hndl = 0; hndl < p->ps_maxfiles; hndl++) + { + if (p->ps_filetab[hndl] == 0xff) + return hndl; + } + return 0xff; +} + +static sft FAR *get_free_sft(WORD FAR * sft_idx) +{ + WORD sys_idx = 0; + sfttbl FAR *sp; + + /* Get the SFT block that contains the SFT */ + for (sp = sfthead; sp != (sfttbl FAR *) - 1; sp = sp->sftt_next) + { + REG WORD i; + + for (i = 0; i < sp->sftt_count; i++) + { + if (sp->sftt_table[i].sft_count == 0) + { + *sft_idx = sys_idx + i; + return (sft FAR *) & sp->sftt_table[sys_idx + i]; + } + } + sys_idx += i; + } + /* If not found, return an error */ + return (sft FAR *) - 1; +} + +static BYTE FAR *get_root(BYTE FAR * fname) +{ + BYTE FAR *froot; + REG WORD length; + + /* find the end */ + for (length = 0, froot = fname; *froot != '\0'; ++froot) + ++length; + /* now back up to first path seperator or start */ + for (--froot; length > 0 && !(*froot == '/' || *froot == '\\'); --froot) + --length; + return ++froot; +} + +/* Ascii only file name match routines */ +static BOOL cmatch(COUNT s, COUNT d, COUNT mode) +{ + if (s >= 'a' && s <= 'z') + s -= 'a' - 'A'; + if (d >= 'a' && d <= 'z') + d -= 'a' - 'A'; + if (mode && s == '?' && (d >= 'A' && s <= 'Z')) + return TRUE; + return s == d; +} + +static BOOL fnmatch(BYTE FAR * s, BYTE FAR * d, COUNT n, COUNT mode) +{ + while (n--) + { + if (!cmatch(*s++, *d++, mode)) + return FALSE; + } + return TRUE; +} + +COUNT DosCreat(BYTE FAR * fname, COUNT attrib) +{ + psp FAR *p = MK_FP(cu_psp, 0); + WORD hndl, + sft_idx; + sft FAR *sftp; + struct dhdr FAR *dhp; + BYTE FAR *froot; + WORD i; + + /* get a free handle */ + if ((hndl = get_free_hndl()) == 0xff) + return DE_TOOMANY; + + /* now get a free system file table entry */ + if ((sftp = get_free_sft((WORD FAR *) & sft_idx)) == (sft FAR *) - 1) + return DE_TOOMANY; + + /* check for a device */ + froot = get_root(fname); + for (i = 0; i < FNAME_SIZE; i++) + { + if (*froot != '\0' && *froot != '.') + PriPathName[i] = *froot++; + else + break; + } + + for (; i < FNAME_SIZE; i++) + PriPathName[i] = ' '; + + /* if we have an extension, can't be a device */ + if (*froot != '.') + { + for (dhp = (struct dhdr FAR *)&nul_dev; dhp != (struct dhdr FAR *)-1; dhp = dhp->dh_next) + { + if (fnmatch((BYTE FAR *) PriPathName, (BYTE FAR *) dhp->dh_name, FNAME_SIZE, FALSE)) + { + sftp->sft_count += 1; + sftp->sft_mode = SFT_MRDWR; + sftp->sft_attrib = attrib; + sftp->sft_flags = + ((dhp->dh_attr & ~SFT_MASK) & ~SFT_FSHARED) | SFT_FDEVICE | SFT_FEOF; + sftp->sft_psp = cu_psp; + fbcopy((BYTE FAR *) PriPathName, sftp->sft_name, FNAME_SIZE + FEXT_SIZE); + sftp->sft_dev = dhp; + p->ps_filetab[hndl] = sft_idx; + return hndl; + } + } + } + + if (Remote_OCT(REM_CREATE, fname, attrib, sftp) == 0) + { + if (sftp->sft_flags & SFT_FSHARED) + { + sftp->sft_count += 1; + p->ps_filetab[hndl] = sft_idx; + return hndl; + } + } + + sftp->sft_status = dos_creat(fname, attrib); + if (sftp->sft_status >= 0) + { + p->ps_filetab[hndl] = sft_idx; + sftp->sft_count += 1; + sftp->sft_mode = SFT_MRDWR; + sftp->sft_attrib = attrib; + sftp->sft_flags = 0; + sftp->sft_psp = cu_psp; + DosGetFile(fname, sftp->sft_name); + return hndl; + } + else + return sftp->sft_status; +} + +COUNT CloneHandle(COUNT hndl) +{ + sft FAR *sftp; + + /* now get the system file table entry */ + if ((sftp = get_sft(hndl)) == (sft FAR *) - 1) + return DE_INVLDHNDL; + + /* now that we have the system file table entry, get the fnode */ + /* index, and increment the count, so that we've effectively */ + /* cloned the file. */ + sftp->sft_count += 1; + return SUCCESS; +} + +COUNT DosDup(COUNT Handle) +{ + psp FAR *p = MK_FP(cu_psp, 0); + COUNT NewHandle; + sft FAR *Sftp; + + /* Get the SFT block that contains the SFT */ + if ((Sftp = get_sft(Handle)) == (sft FAR *) - 1) + return DE_INVLDHNDL; + + /* If not open - exit */ + if (Sftp->sft_count <= 0) + return DE_INVLDHNDL; + + /* now get a free handle */ + if ((NewHandle = get_free_hndl()) == 0xff) + return DE_TOOMANY; + + /* If everything looks ok, bump it up. */ + if ((Sftp->sft_flags & SFT_FDEVICE) || (Sftp->sft_status >= 0)) + { + p->ps_filetab[NewHandle] = p->ps_filetab[Handle]; + Sftp->sft_count += 1; + return NewHandle; + } + else + return DE_INVLDHNDL; +} + +COUNT DosForceDup(COUNT OldHandle, COUNT NewHandle) +{ + psp FAR *p = MK_FP(cu_psp, 0); + sft FAR *Sftp; + + /* Get the SFT block that contains the SFT */ + if ((Sftp = get_sft(OldHandle)) == (sft FAR *) - 1) + return DE_INVLDHNDL; + + /* If not open - exit */ + if (Sftp->sft_count <= 0) + return DE_INVLDHNDL; + + /* now close the new handle if it's open */ + if ((UBYTE) p->ps_filetab[NewHandle] != 0xff) + { + COUNT ret; + + if ((ret = DosClose(NewHandle)) != SUCCESS) + return ret; + } + + /* If everything looks ok, bump it up. */ + if ((Sftp->sft_flags & SFT_FDEVICE) || (Sftp->sft_status >= 0)) + { + p->ps_filetab[NewHandle] = p->ps_filetab[OldHandle]; + + Sftp->sft_count += 1; + return NewHandle; + } + else + return DE_INVLDHNDL; +} + +COUNT DosOpen(BYTE FAR * fname, COUNT mode) +{ + psp FAR *p = MK_FP(cu_psp, 0); + WORD hndl; + WORD sft_idx; + sft FAR *sftp; + struct dhdr FAR *dhp; + BYTE FAR *froot; + WORD i; + + /* test if mode is in range */ + if ((mode & ~SFT_OMASK) != 0) + return DE_INVLDACC; + + mode &= 3; + /* get a free handle */ + if ((hndl = get_free_hndl()) == 0xff) + return DE_TOOMANY; + + OpenMode = (BYTE) mode; + + /* now get a free system file table entry */ + if ((sftp = get_free_sft((WORD FAR *) & sft_idx)) == (sft FAR *) - 1) + return DE_TOOMANY; + + /* check for a device */ + froot = get_root(fname); + for (i = 0; i < FNAME_SIZE; i++) + { + if (*froot != '\0' && *froot != '.') + PriPathName[i] = *froot++; + else + break; + } + + for (; i < FNAME_SIZE; i++) + PriPathName[i] = ' '; + + /* if we have an extension, can't be a device */ + if (*froot != '.') + { + for (dhp = (struct dhdr FAR *)&nul_dev; dhp != (struct dhdr FAR *)-1; dhp = dhp->dh_next) + { + if (fnmatch((BYTE FAR *) PriPathName, (BYTE FAR *) dhp->dh_name, FNAME_SIZE, FALSE)) + { + sftp->sft_count += 1; + sftp->sft_mode = mode; + sftp->sft_attrib = 0; + sftp->sft_flags = + ((dhp->dh_attr & ~SFT_MASK) & ~SFT_FSHARED) | SFT_FDEVICE | SFT_FEOF; + sftp->sft_psp = cu_psp; + fbcopy((BYTE FAR *) PriPathName, sftp->sft_name, FNAME_SIZE + FEXT_SIZE); + sftp->sft_dev = dhp; + sftp->sft_date = dos_getdate(); + sftp->sft_time = dos_gettime(); + + p->ps_filetab[hndl] = sft_idx; + return hndl; + } + } + } + + if (Remote_OCT(REM_OPEN, fname, mode, sftp) == 0) + { + if (sftp->sft_flags & SFT_FSHARED) + { + sftp->sft_count += 1; + p->ps_filetab[hndl] = sft_idx; + return hndl; + } + } + + sftp->sft_status = dos_open(fname, mode); + + if (sftp->sft_status >= 0) + { + struct f_node FAR *fnp = xlt_fd(sftp->sft_status); + + sftp->sft_attrib = fnp->f_dir.dir_attrib; + + /* Check permissions. -- JPP */ + if ((sftp->sft_attrib & (D_DIR | D_VOLID)) || + ((sftp->sft_attrib & D_RDONLY) && (mode != O_RDONLY))) + { + return DE_ACCESS; + } + p->ps_filetab[hndl] = sft_idx; + + sftp->sft_count += 1; + sftp->sft_mode = mode; + sftp->sft_attrib = 0; + sftp->sft_flags = 0; + sftp->sft_psp = cu_psp; + DosGetFile(fname, sftp->sft_name); + return hndl; + } + else + return sftp->sft_status; +} + +COUNT DosClose(COUNT hndl) +{ + psp FAR *p = MK_FP(cu_psp, 0); + sft FAR *s; + + /* Test that the handle is valid */ + if (hndl < 0) + return DE_INVLDHNDL; + + /* Get the SFT block that contains the SFT */ + if ((s = get_sft(hndl)) == (sft FAR *) - 1) + return DE_INVLDHNDL; + + /* If this is not opened another error */ + if (s->sft_count == 0) + return DE_ACCESS; + + lpCurSft = (sfttbl FAR *) s; +/* + remote sub sft_count. + */ + if (s->sft_flags & SFT_FSHARED) + { + int2f_Remote_call(REM_CLOSE, 0, 0, 0, (VOID FAR *) s, 0, 0); + p->ps_filetab[hndl] = 0xff; + s->sft_flags = 0; + return SUCCESS; + } + + /* now just drop the count if a device, else */ + /* call file system handler */ + if (s->sft_flags & SFT_FDEVICE) + { + p->ps_filetab[hndl] = 0xff; + s->sft_count -= 1; + return SUCCESS; + } + else + { + p->ps_filetab[hndl] = 0xff; + s->sft_count -= 1; + if (s->sft_count > 0) + return SUCCESS; + else + return dos_close(s->sft_status); + } +} + +VOID DosGetFree(COUNT drive, COUNT FAR * spc, COUNT FAR * navc, COUNT FAR * bps, COUNT FAR * nc) +{ + struct dpb *dpbp; + struct cds FAR *cdsp; + static char rg[8]; + + /* next - "log" in the drive */ + drive = (drive == 0 ? default_drive : drive - 1); + + cdsp = &CDSp->cds_table[drive]; + if (cdsp->cdsFlags & 0x8000) + { + int2f_Remote_call(REM_GETSPACE, 0, 0, 0, cdsp, 0, &rg); + + *spc = (COUNT) rg[0]; + *navc = (COUNT) rg[2]; + *bps = (COUNT) rg[4]; + *nc = (COUNT) rg[6]; + return; + } + + /* first check for valid drive */ + if (drive < 0 || drive > lastdrive) + { + *spc = -1; + return; + } + + dpbp = (struct dpb *)CDSp->cds_table[drive].cdsDpb; + if (dpbp == 0) + { + *spc = -1; + return; + } + + if ((media_check(dpbp) < 0)) + { + *spc = -1; + return; + } + + /* get the data vailable from dpb */ + *nc = dpbp->dpb_size; + *spc = dpbp->dpb_clsmask + 1; + *bps = dpbp->dpb_secsize; + + /* now tell fs to give us free cluster */ + /* count */ + *navc = dos_free(dpbp); +} + +COUNT DosGetCuDir(COUNT drive, BYTE FAR * s) +{ + REG struct cds FAR *cdsp; + + /* next - "log" in the drive */ + drive = (drive == 0 ? default_drive : drive - 1); + + cdsp = &CDSp->cds_table[drive]; + + current_ldt = cdsp; + + if (cdsp->cdsFlags & 0x8000) + { + dos_pwd(cdsp, s); + return SUCCESS; + } + + /* first check for valid drive */ + + if (cdsp->cdsDpb == 0) + return DE_INVLDDRV; + +/* if (drive < 0 || drive > nblkdev) + return DE_INVLDDRV; + */ + dos_pwd(cdsp, s); + return SUCCESS; +} + +COUNT DosChangeDir(BYTE FAR * s) +{ + REG struct dpb *dpbp; + REG struct cds FAR *cdsp; + REG COUNT drive; + struct f_node FAR *fp; + COUNT ret; + /* Parse and extract drive */ + if (*(s + 1) == ':') + { + drive = *s - '@'; + if (drive > 26) + drive -= 'a' - 'A'; + } + else + drive = 0; + + /* next - "log" in the drive */ + drive = (drive == 0 ? default_drive : drive - 1); + + cdsp = &CDSp->cds_table[drive]; + + current_ldt = cdsp; + + if (cdsp->cdsFlags & 0x8000) + { + ret = dos_cd(cdsp, s); + return ret; + } + + /* first check for valid drive */ + if (cdsp->cdsDpb == 0) + return DE_INVLDDRV; + + /* test for path existance from fs */ + if ((fp = dir_open((BYTE FAR *) s)) == (struct f_node FAR *)0) + return DE_PATHNOTFND; + else + dir_close(fp); + +/* if (drive < 0 || drive > nblkdev) + return DE_INVLDDRV; */ + + dpbp = (struct dpb *)cdsp->cdsDpb; + if ((media_check(dpbp) < 0)) + return DE_INVLDDRV; + /* now get fs to change to new */ + /* directory */ + ret = dos_cd(cdsp, s); + return ret; +} + +COUNT DosFindFirst(UCOUNT attr, BYTE FAR * name) +{ + SAttr = (BYTE) attr; + return dos_findfirst(attr, name); +} + +COUNT DosFindNext(void) +{ + return dos_findnext(); +} + +COUNT DosGetFtime(COUNT hndl, date FAR * dp, time FAR * tp) +{ + sft FAR *s; + sfttbl FAR *sp; + + /* Test that the handle is valid */ + if (hndl < 0) + return DE_INVLDHNDL; + + /* Get the SFT block that contains the SFT */ + if ((s = get_sft(hndl)) == (sft FAR *) - 1) + return DE_INVLDHNDL; + + /* If this is not opened another error */ + if (s->sft_count == 0) + return DE_ACCESS; + + /* If SFT entry refers to a device, return the date and time of opening */ + if (s->sft_flags & (SFT_FDEVICE | SFT_FSHARED)) + { + *dp = s->sft_date; + *tp = s->sft_time; + return SUCCESS; + } + + /* call file system handler */ + return dos_getftime(s->sft_status, dp, tp); +} + +COUNT DosSetFtime(COUNT hndl, date FAR * dp, time FAR * tp) +{ + sft FAR *s; + sfttbl FAR *sp; + + /* Test that the handle is valid */ + if (hndl < 0) + return DE_INVLDHNDL; + + /* Get the SFT block that contains the SFT */ + if ((s = get_sft(hndl)) == (sft FAR *) - 1) + return DE_INVLDHNDL; + + /* If this is not opened another error */ + if (s->sft_count == 0) + return DE_ACCESS; + + /* If SFT entry refers to a device, do nothing */ + if (s->sft_flags & SFT_FDEVICE) + return SUCCESS; + + if (s->sft_flags & SFT_FSHARED) + { + s->sft_date = *dp; + s->sft_time = *tp; + return SUCCESS; + } + + /* call file system handler */ + return dos_setftime(s->sft_status, dp, tp); +} + +COUNT DosGetFattr(BYTE FAR * name, UWORD FAR * attrp) +{ + + if (Remote_GSattr(REM_GETATTRZ, name, attrp) == 0) + return SUCCESS; + + return dos_getfattr(name, attrp); + +} + +COUNT DosSetFattr(BYTE FAR * name, UWORD FAR * attrp) +{ + if (Remote_GSattr(REM_SETATTR, name, attrp) == 0) + return SUCCESS; + + return dos_setfattr(name, attrp); +} + +BYTE DosSelectDrv(BYTE drv) +{ + if (CDSp->cds_table[drv].cdsFlags & 0xf000) + { + current_ldt = &CDSp->cds_table[drv]; + default_drive = drv; + } + return lastdrive; +} + diff --git a/kernel/dosidle.asm b/kernel/dosidle.asm new file mode 100644 index 00000000..7ef33293 --- /dev/null +++ b/kernel/dosidle.asm @@ -0,0 +1,100 @@ +; File: +; DosIdle.asm +; Description: +; Dos Idle Interrupt Call +; +; DOS-C +; Copyright (c) 1995, 1999 +; Pasquale J. Villani +; All Rights Reserved +; +; This file is part of DOS-C. +; +; DOS-C is free software; you can redistribute it and/or +; modify it under the terms of the GNU General Public License +; as published by the Free Software Foundation; either version +; 2, or (at your option) any later version. +; +; DOS-C is distributed in the hope that it will be useful, but +; WITHOUT ANY WARRANTY; without even the implied warranty of +; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See +; the GNU General Public License for more details. +; +; You should have received a copy of the GNU General Public +; License along with DOS-C; see the file COPYING. If not, +; write to the Free Software Foundation, 675 Mass Ave, +; Cambridge, MA 02139, USA. +; +; + %include "segs.inc" + +PSP_USERSP equ 2eh +PSP_USERSS equ 30h + +segment _TEXT + + global _DosIdle_int + + + extern _InDOS:wrt DGROUP + extern _cu_psp:wrt DGROUP + extern _MachineId:wrt DGROUP + extern critical_sp:wrt DGROUP + extern _lpUserStack:wrt DGROUP + extern _user_r:wrt DGROUP + extern _api_sp:wrt DGROUP ; api stacks - for context + extern _api_ss:wrt DGROUP ; switching + extern _usr_sp:wrt DGROUP ; user stacks + extern _usr_ss:wrt DGROUP + extern _dosidle_flag:wrt DGROUP +; +; +_DosIdle_int: + push ds + push ax + mov ax,DGROUP + mov ds,ax + pop ax + cmp byte [_dosidle_flag],0 + jnz DosId1 + call Do_DosI +DosId1: + pop ds + retn + +Do_DosI: + inc byte [_dosidle_flag] + push ax + push es + push word [_MachineId] + push word [_user_r] + push word [_user_r+2] + push word [_lpUserStack] + push word [_lpUserStack+2] + push word [_api_sp] + push word [_api_ss] + push word [_usr_sp] + push word [_usr_ss] + mov es,word [_cu_psp] + push word [es:PSP_USERSS] + push word [es:PSP_USERSP] + + int 28h + + mov es,word [_cu_psp] + pop word [es:PSP_USERSP] + pop word [es:PSP_USERSS] + pop word [_usr_ss] + pop word [_usr_sp] + pop word [_api_ss] + pop word [_api_sp] + pop word [_lpUserStack+2] + pop word [_lpUserStack] + pop word [_user_r+2] + pop word [_user_r] + pop word [_MachineId] + pop es + pop ax + dec byte [_dosidle_flag] + ret + diff --git a/kernel/dosnames.c b/kernel/dosnames.c new file mode 100644 index 00000000..ce06c87c --- /dev/null +++ b/kernel/dosnames.c @@ -0,0 +1,481 @@ +/****************************************************************/ +/* */ +/* dosnames.c */ +/* DOS-C */ +/* */ +/* Generic parsing functions for file name specifications */ +/* */ +/* Copyright (c) 1994 */ +/* Pasquale J. Villani */ +/* All Rights Reserved */ +/* */ +/* This file is part of DOS-C. */ +/* */ +/* DOS-C is free software; you can redistribute it and/or */ +/* modify it under the terms of the GNU General Public License */ +/* as published by the Free Software Foundation; either version */ +/* 2, or (at your option) any later version. */ +/* */ +/* DOS-C is distributed in the hope that it will be useful, but */ +/* WITHOUT ANY WARRANTY; without even the implied warranty of */ +/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See */ +/* the GNU General Public License for more details. */ +/* */ +/* You should have received a copy of the GNU General Public */ +/* License along with DOS-C; see the file COPYING. If not, */ +/* write to the Free Software Foundation, 675 Mass Ave, */ +/* Cambridge, MA 02139, USA. */ +/* */ +/****************************************************************/ + +#include "portab.h" + +#ifdef VERSION_STRINGS +static BYTE *dosnamesRcsId = "$Id$"; +#endif + +/* + * $Log$ + * Revision 1.1 2000/05/06 19:35:00 jhall1 + * Initial revision + * + * Revision 1.3 2000/03/09 06:07:11 kernel + * 2017f updates by James Tabor + * + * Revision 1.2 1999/04/04 18:51:43 jprice + * no message + * + * Revision 1.1.1.1 1999/03/29 15:41:54 jprice + * New version without IPL.SYS + * + * Revision 1.4 1999/02/02 04:40:49 jprice + * Steve Miller fixed a bug with doing "cd ." would lock the machine. + * + * Revision 1.3 1999/02/01 01:43:28 jprice + * Fixed findfirst function to find volume label with Windows long filenames + * + * Revision 1.2 1999/01/22 04:15:28 jprice + * Formating + * + * Revision 1.1.1.1 1999/01/20 05:51:00 jprice + * Imported sources + * + * + * Rev 1.8 22 Jan 1998 4:09:00 patv + * Fixed pointer problems affecting SDA + * + * Rev 1.7 04 Jan 1998 23:14:38 patv + * Changed Log for strip utility + * + * Rev 1.6 03 Jan 1998 8:36:04 patv + * Converted data area to SDA format + * + * Rev 1.5 16 Jan 1997 12:46:36 patv + * pre-Release 0.92 feature additions + * + * Rev 1.4 29 May 1996 21:15:12 patv + * bug fixes for v0.91a + * + * Rev 1.3 19 Feb 1996 3:20:08 patv + * Added NLS, int2f and config.sys processing + * + * Rev 1.2 01 Sep 1995 17:48:44 patv + * First GPL release. + * + * Rev 1.1 30 Jul 1995 20:50:26 patv + * Eliminated version strings in ipl + * + * Rev 1.0 02 Jul 1995 8:05:56 patv + * Initial revision. + * + */ + +#include "globals.h" + +#define PathSep(c) ((c)=='/'||(c)=='\\') +#define DriveChar(c) (((c)>='A'&&(c)<='Z')||((c)>='a'&&(c)<='z')) +#define DirChar(c) (!strchr("\"[]:|<>+=;,", (c))) +#define NameChar(c) (!strchr(".\"/\\[]:|<>+=;,*?", (c))) +#define WildChar(c) (!strchr(".\"/\\[]:|<>+=;,", (c))) + +VOID XlateLcase(BYTE * szFname, COUNT nChars); +VOID DosTrimPath(BYTE FAR * lpszPathNamep); + +/* Should be converted to a portable version after v1.0 is released. */ +VOID XlateLcase(BYTE * szFname, COUNT nChars) +{ + while (nChars--) + { + if (*szFname >= 'a' && *szFname <= 'z') + *szFname -= ('a' - 'A'); + ++szFname; + } +} + +VOID SpacePad(BYTE * szString, COUNT nChars) +{ + REG COUNT i; + + for (i = strlen(szString); i < nChars; i++) + szString[i] = ' '; +} + +COUNT ParseDosName(BYTE FAR * lpszFileName, + COUNT * pnDrive, + BYTE * pszDir, + BYTE * pszFile, + BYTE * pszExt, + BOOL bAllowWildcards) +{ + COUNT nDirCnt, + nFileCnt, + nExtCnt; + BYTE FAR *lpszLclDir, + FAR * lpszLclFile, + FAR * lpszLclExt; + + /* Initialize the users data fields */ + if (pszDir) + *pszDir = '\0'; + if (pszFile) + *pszFile = '\0'; + if (pszExt) + *pszExt = '\0'; + lpszLclFile = lpszLclExt = lpszLclDir = 0; + nDirCnt = nFileCnt = nExtCnt = 0; + + /* Start by cheking for a drive specifier ... */ + if (DriveChar(*lpszFileName) && ':' == lpszFileName[1]) + { + /* found a drive, fetch it and bump pointer past drive */ + /* NB: this code assumes ASCII */ + if (pnDrive) + { + *pnDrive = *lpszFileName - 'A'; + if (*pnDrive > 26) + *pnDrive -= ('a' - 'A'); + } + lpszFileName += 2; + } + else + { + if (pnDrive) + { + *pnDrive = -1; + } + } + if (!pszDir && !pszFile && !pszExt) + return SUCCESS; + + /* Now see how long a directory component we have. */ + lpszLclDir = lpszLclFile = lpszFileName; + while (DirChar(*lpszFileName)) + { + if (PathSep(*lpszFileName)) + lpszLclFile = lpszFileName + 1; + ++lpszFileName; + } + nDirCnt = lpszLclFile - lpszLclDir; + + /* Parse out the file name portion. */ + lpszFileName = lpszLclFile; + while (bAllowWildcards ? WildChar(*lpszFileName) : NameChar(*lpszFileName)) + { + ++nFileCnt; + ++lpszFileName; + } + if (nFileCnt == 0) + return DE_FILENOTFND; + + /* Now we have pointers set to the directory portion and the */ + /* file portion. Now determine the existance of an extension. */ + lpszLclExt = lpszFileName; + if ('.' == *lpszFileName) + { + lpszLclExt = ++lpszFileName; + while (*lpszFileName) + { + if (bAllowWildcards ? WildChar(*lpszFileName) : NameChar(*lpszFileName)) + { + ++nExtCnt; + ++lpszFileName; + } + else + return DE_FILENOTFND; + } + } + else if (*lpszFileName) + return DE_FILENOTFND; + + /* Fix lengths to maximums allowed by MS-DOS. */ + if (nDirCnt > PARSE_MAX) + nDirCnt = PARSE_MAX; + if (nFileCnt > FNAME_SIZE) + nFileCnt = FNAME_SIZE; + if (nExtCnt > FEXT_SIZE) + nExtCnt = FEXT_SIZE; + + /* Finally copy whatever the user wants extracted to the user's */ + /* buffers. */ + if (pszDir) + { + fbcopy(lpszLclDir, (BYTE FAR *) pszDir, nDirCnt); + pszDir[nDirCnt] = '\0'; + } + if (pszFile) + { + fbcopy(lpszLclFile, (BYTE FAR *) pszFile, nFileCnt); + pszFile[nFileCnt] = '\0'; + } + if (pszExt) + { + fbcopy(lpszLclExt, (BYTE FAR *) pszExt, nExtCnt); + pszExt[nExtCnt] = '\0'; + } + + /* Clean up before leaving */ + if (pszDir) + DosTrimPath(pszDir); + + return SUCCESS; +} + +COUNT ParseDosPath(BYTE FAR * lpszFileName, + COUNT * pnDrive, + BYTE * pszDir, + BYTE FAR * pszCurPath) +{ + COUNT nDirCnt, + nPathCnt; + BYTE FAR *lpszLclDir, + *pszBase = pszDir; + + /* Initialize the users data fields */ + *pszDir = '\0'; + lpszLclDir = 0; + nDirCnt = nPathCnt = 0; + + /* Start by cheking for a drive specifier ... */ + if (DriveChar(*lpszFileName) && ':' == lpszFileName[1]) + { + /* found a drive, fetch it and bump pointer past drive */ + /* NB: this code assumes ASCII */ + if (pnDrive) + { + *pnDrive = *lpszFileName - 'A'; + if (*pnDrive > 26) + *pnDrive -= ('a' - 'A'); + } + lpszFileName += 2; + } + else + { + if (pnDrive) + { + *pnDrive = -1; + } + } + + lpszLclDir = lpszFileName; + if (!PathSep(*lpszLclDir)) + { + fstrncpy(pszDir, pszCurPath, PARSE_MAX); + nPathCnt = fstrlen(pszCurPath); + if (!PathSep(pszDir[nPathCnt - 1]) && nPathCnt < PARSE_MAX) + pszDir[nPathCnt++] = '\\'; + if (nPathCnt > PARSE_MAX) + nPathCnt = PARSE_MAX; + pszDir += nPathCnt; + } + + /* Now see how long a directory component we have. */ + while (NameChar(*lpszFileName) + || PathSep(*lpszFileName) + || '.' == *lpszFileName) + { + ++nDirCnt; + ++lpszFileName; + } + + /* Fix lengths to maximums allowed by MS-DOS. */ + if ((nDirCnt + nPathCnt) > PARSE_MAX) + nDirCnt = PARSE_MAX - nPathCnt; + + /* Finally copy whatever the user wants extracted to the user's */ + /* buffers. */ + if (pszDir) + { + fbcopy(lpszLclDir, (BYTE FAR *) pszDir, nDirCnt); + pszDir[nDirCnt] = '\0'; + } + + /* Clean up before leaving */ + DosTrimPath((BYTE FAR *) pszBase); + + /* Before returning to the user, eliminate any useless */ + /* trailing "\\." since the path prior to this is sufficient. */ + nPathCnt = strlen(pszBase); + if (2 == nPathCnt) /* Special case, root */ + { + if (!strcmp(pszBase, "\\.")) + pszBase[1] = '\0'; + } + else if (2 < nPathCnt) + { + if (!strcmp(&pszBase[nPathCnt - 2], "\\.")) + pszBase[nPathCnt - 2] = '\0'; + } + + return SUCCESS; +} + +BOOL IsDevice(BYTE * pszFileName) +{ + REG struct dhdr FAR *dhp = (struct dhdr FAR *)&nul_dev; + BYTE szName[FNAME_SIZE]; + + /* break up the name first */ + if (ParseDosName((BYTE FAR *) pszFileName, + (COUNT *) 0, TempBuffer, szName, (BYTE *) 0, FALSE) + != SUCCESS) + return FALSE; + SpacePad(szName, FNAME_SIZE); + + /* Test 1 - does it start with a \dev or /dev */ + if ((strcmp(szName, "/dev") == 0) + || (strcmp(szName, "\\dev") == 0)) + return TRUE; + + /* Test 2 - is it on the device chain? */ + for (; -1l != (LONG) dhp; dhp = dhp->dh_next) + { + COUNT nIdx; + + /* Skip if not char device */ + if (!(dhp->dh_attr & ATTR_CHAR)) + continue; + + /* now compare */ + for (nIdx = 0; nIdx < FNAME_SIZE; ++nIdx) + { + if (dhp->dh_name[nIdx] != szName[nIdx]) + break; + } + if (nIdx >= FNAME_SIZE) + return TRUE; + } + + return FALSE; +} + +VOID DosTrimPath(BYTE FAR * lpszPathNamep) +{ + BYTE FAR *lpszLast, + FAR * lpszNext, + FAR * lpszRoot = (BYTE FAR *) 0; + COUNT nChars, + flDotDot; + + /* First, convert all '/' to '\'. Look for root as we scan */ + if (*lpszPathNamep == '\\') + lpszRoot = lpszPathNamep; + for (lpszNext = lpszPathNamep; *lpszNext; ++lpszNext) + { + if (*lpszNext == '/') + *lpszNext = '\\'; + if (!lpszRoot && + *lpszNext == ':' && *(lpszNext + 1) == '\\') + lpszRoot = lpszNext + 1; + } + + for (lpszLast = lpszNext = lpszPathNamep, nChars = 0; + *lpszNext != '\0' && nChars < NAMEMAX;) + { + /* Initialize flag for loop. */ + flDotDot = FALSE; + + /* If we are at a path seperator, check for extra path */ + /* seperator, '.' and '..' to reduce. */ + if (*lpszNext == '\\') + { + /* If it's '\', just move everything down one. */ + if (*(lpszNext + 1) == '\\') + fstrncpy(lpszNext, lpszNext + 1, NAMEMAX); + /* also check for '.' and '..' and move down */ + /* as appropriate. */ + else if (*(lpszNext + 1) == '.') + { + if (*(lpszNext + 2) == '.' + && !(*(lpszNext + 3))) + { + /* At the end, just truncate */ + /* and exit. */ + if (lpszLast == lpszRoot) + *(lpszLast + 1) = '\0'; + else + *lpszLast = '\0'; + return; + } + + if (*(lpszNext + 2) == '.' + && *(lpszNext + 3) == '\\') + { + fstrncpy(lpszLast, lpszNext + 3, NAMEMAX); + /* bump back to the last */ + /* seperator. */ + lpszNext = lpszLast; + /* set lpszLast to the last one */ + if (lpszLast <= lpszPathNamep) + continue; + do + { + --lpszLast; + } + while (lpszLast != lpszPathNamep + && *lpszLast != '\\'); + flDotDot = TRUE; + } + /* Note: we skip strange stuff that */ + /* starts with '.' */ + else if (*(lpszNext + 2) == '\\') + { + fstrncpy(lpszNext, lpszNext + 2, NAMEMAX); + } + /* If we're at the end of a string, */ + /* just exit. */ + else if (*(lpszNext + 2) == NULL) + { + return; + } + /* + Added this "else" because otherwise we might not pass + any of the foregoing tests, as in the case where the + incoming string refers to a suffix only, like ".bat" + + -SRM + */ + else + { + lpszLast = lpszNext++; + } + } + else + { + /* No '.' or '\' so mark it and bump */ + /* past */ + lpszLast = lpszNext++; + continue; + } + + /* Done. Now set last to next to mark this */ + /* instance of path seperator. */ + if (!flDotDot) + lpszLast = lpszNext; + } + else + /* For all other cases, bump lpszNext for the */ + /* next check */ + ++lpszNext; + } +} + diff --git a/kernel/dsk.c b/kernel/dsk.c new file mode 100644 index 00000000..9e88d10f --- /dev/null +++ b/kernel/dsk.c @@ -0,0 +1,671 @@ +/****************************************************************/ +/* */ +/* dsk.c */ +/* */ +/* Copyright (c) 1995 */ +/* Pasquale J. Villani */ +/* All Rights Reserved */ +/* */ +/* This file is part of DOS-C. */ +/* */ +/* DOS-C is free software; you can redistribute it and/or */ +/* modify it under the terms of the GNU General Public License */ +/* as published by the Free Software Foundation; either version */ +/* 2, or (at your option) any later version. */ +/* */ +/* DOS-C is distributed in the hope that it will be useful, but */ +/* WITHOUT ANY WARRANTY; without even the implied warranty of */ +/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See */ +/* the GNU General Public License for more details. */ +/* */ +/* You should have received a copy of the GNU General Public */ +/* License along with DOS-C; see the file COPYING. If not, */ +/* write to the Free Software Foundation, 675 Mass Ave, */ +/* Cambridge, MA 02139, USA. */ +/****************************************************************/ + +#include "portab.h" +#include "globals.h" + +#ifdef VERSION_STRINGS +static BYTE *dskRcsId = "$Id$"; +#endif + +/* + * $Log$ + * Revision 1.1 2000/05/06 19:35:01 jhall1 + * Initial revision + * + * Revision 1.5 2000/03/09 06:07:11 kernel + * 2017f updates by James Tabor + * + * Revision 1.4 1999/08/10 18:07:57 jprice + * ror4 2011-04 patch + * + * Revision 1.3 1999/04/16 21:43:40 jprice + * ror4 multi-sector IO + * + * Revision 1.2 1999/04/16 00:53:32 jprice + * Optimized FAT handling + * + * Revision 1.1.1.1 1999/03/29 15:40:51 jprice + * New version without IPL.SYS + * + * Revision 1.5 1999/02/14 04:26:46 jprice + * Changed check media so that it checks if a floppy disk has been changed. + * + * Revision 1.4 1999/02/08 05:55:57 jprice + * Added Pat's 1937 kernel patches + * + * Revision 1.3 1999/02/01 01:48:41 jprice + * Clean up; Now you can use hex numbers in config.sys. added config.sys screen function to change screen mode (28 or 43/50 lines) + * + * Revision 1.2 1999/01/22 04:13:25 jprice + * Formating + * + * Revision 1.1.1.1 1999/01/20 05:51:01 jprice + * Imported sources + * + * + * Rev 1.7 06 Dec 1998 8:45:18 patv + * Changed due to new I/O subsystem. + * + * Rev 1.6 04 Jan 1998 23:15:16 patv + * Changed Log for strip utility + * + * Rev 1.5 10 Jan 1997 5:41:48 patv + * Modified for extended partition support + * + * Rev 1.4 29 May 1996 21:03:32 patv + * bug fixes for v0.91a + * + * Rev 1.3 19 Feb 1996 3:21:36 patv + * Added NLS, int2f and config.sys processing + * + * Rev 1.2 01 Sep 1995 17:54:18 patv + * First GPL release. + * + * Rev 1.1 30 Jul 1995 20:52:00 patv + * Eliminated version strings in ipl + * + * Rev 1.0 02 Jul 1995 8:32:42 patv + * Initial revision. + */ + +#ifdef PROTO +BOOL fl_reset(WORD); +COUNT fl_readdasd(WORD); +COUNT fl_diskchanged(WORD); +COUNT fl_rd_status(WORD); +COUNT fl_read(WORD, WORD, WORD, WORD, WORD, BYTE FAR *); +COUNT fl_write(WORD, WORD, WORD, WORD, WORD, BYTE FAR *); +COUNT fl_verify(WORD, WORD, WORD, WORD, WORD, BYTE FAR *); +BOOL fl_format(WORD, BYTE FAR *); +#else +BOOL fl_reset(); +COUNT fl_readdasd(); +COUNT fl_diskchanged(); +COUNT fl_rd_status(); +COUNT fl_read(); +COUNT fl_write(); +COUNT fl_verify(); +BOOL fl_format(); +#endif + +#define NDEV 8 /* only one for demo */ +#define SEC_SIZE 512 /* size of sector in bytes */ +#define N_RETRY 5 /* number of retries permitted */ +#define NENTRY 25 /* total size of dispatch table */ + +union +{ + BYTE bytes[2 * SEC_SIZE]; + boot boot_sector; +} +buffer; + +static struct media_info +{ + ULONG mi_size; /* physical sector count */ + UWORD mi_heads; /* number of heads (sides) */ + UWORD mi_cyls; /* number of cyl/drive */ + UWORD mi_sectors; /* number of sectors/cyl */ + ULONG mi_offset; /* relative partition offset */ + BYTE mi_drive; /* BIOS drive number */ + COUNT mi_partidx; /* Index to partition array */ +}; + +static struct media_info miarray[NDEV]; /* Internal media info structs */ +static bpb bpbarray[NDEV]; /* BIOS parameter blocks */ +static bpb *bpbptrs[NDEV]; /* pointers to bpbs */ + +#define N_PART 4 /* number of partitions per + table partition */ + +static WORD head, + track, + sector, + ret; /* globals for blockio */ +static WORD count; +static COUNT nUnits; /* number of returned units */ +static COUNT nPartitions; /* number of DOS partitions */ + +#define PARTOFF 0x1be + +static struct +{ + BYTE peDrive; /* BIOS drive number */ + BYTE peBootable; + BYTE peBeginHead; + BYTE peBeginSector; + UWORD peBeginCylinder; + BYTE peFileSystem; + BYTE peEndHead; + BYTE peEndSector; + UWORD peEndCylinder; + LONG peStartSector; + LONG peSectors; + LONG peAbsStart; /* Absolute sector start */ +} +dos_partition[NDEV - 2]; + +#ifdef PROTO +WORD init(rqptr), + mediachk(rqptr), + bldbpb(rqptr), + blockio(rqptr), + blk_error(rqptr); +COUNT ltop(WORD *, WORD *, WORD *, COUNT, COUNT, LONG, byteptr); +WORD dskerr(COUNT); +COUNT processtable(COUNT ptDrive, BYTE ptHead, UWORD ptCylinder, BYTE ptSector, LONG ptAccuOff); +#else +WORD init(), + mediachk(), + bldbpb(), + blockio(), + blk_error(); +WORD dskerr(); +COUNT processtable(); +#endif + +/* */ +/* the function dispatch table */ +/* */ + +#ifdef PROTO +static WORD(*dispatch[NENTRY]) (rqptr) = +#else +static WORD(*dispatch[NENTRY]) () = +#endif +{ + init, /* Initialize */ + mediachk, /* Media Check */ + bldbpb, /* Build BPB */ + blk_error, /* Ioctl In */ + blockio, /* Input (Read) */ + blk_error, /* Non-destructive Read */ + blk_error, /* Input Status */ + blk_error, /* Input Flush */ + blockio, /* Output (Write) */ + blockio, /* Output with verify */ + blk_error, /* Output Status */ + blk_error, /* Output Flush */ + blk_error, /* Ioctl Out */ + blk_error, /* Device Open */ + blk_error, /* Device Close */ + blk_error, /* Removable Media */ + blk_error, /* Output till busy */ + blk_error, /* undefined */ + blk_error, /* undefined */ + blk_error, /* Generic Ioctl */ + blk_error, /* undefined */ + blk_error, /* undefined */ + blk_error, /* undefined */ + blk_error, /* Get Logical Device */ + blk_error /* Set Logical Device */ +}; + +#define SIZEOF_PARTENT 16 + +#define FAT12 0x01 +#define FAT16SMALL 0x04 +#define EXTENDED 0x05 +#define FAT16LARGE 0x06 + +#define hd(x) ((x) & 0x80) + +COUNT processtable(COUNT ptDrive, BYTE ptHead, UWORD ptCylinder, + BYTE ptSector, LONG ptAccuOff) +{ + struct /* Temporary partition table */ + { + BYTE peBootable; + BYTE peBeginHead; + BYTE peBeginSector; + UWORD peBeginCylinder; + BYTE peFileSystem; + BYTE peEndHead; + BYTE peEndSector; + UWORD peEndCylinder; + LONG peStartSector; + LONG peSectors; + } + temp_part[N_PART]; + + REG retry = N_RETRY; + UBYTE packed_byte, + pb1; + COUNT Part; + + /* Read partition table */ + do + { + ret = fl_read((WORD) ptDrive, (WORD) ptHead, (WORD) ptCylinder, + (WORD) ptSector, (WORD) 1, (byteptr) & buffer); + } + while (ret != 0 && --retry > 0); + if (ret != 0) + return FALSE; + + /* Read each partition into temporary array */ + for (Part = 0; Part < N_PART; Part++) + { + REG BYTE *p = + (BYTE *) & buffer.bytes[PARTOFF + (Part * SIZEOF_PARTENT)]; + + getbyte((VOID *) p, &temp_part[Part].peBootable); + ++p; + getbyte((VOID *) p, &temp_part[Part].peBeginHead); + ++p; + getbyte((VOID *) p, &packed_byte); + temp_part[Part].peBeginSector = packed_byte & 0x3f; + ++p; + getbyte((VOID *) p, &pb1); + ++p; + temp_part[Part].peBeginCylinder = pb1 + ((UWORD) (0xc0 & packed_byte) << 2); + getbyte((VOID *) p, &temp_part[Part].peFileSystem); + ++p; + getbyte((VOID *) p, &temp_part[Part].peEndHead); + ++p; + getbyte((VOID *) p, &packed_byte); + temp_part[Part].peEndSector = packed_byte & 0x3f; + ++p; + getbyte((VOID *) p, &pb1); + ++p; + temp_part[Part].peEndCylinder = pb1 + ((UWORD) (0xc0 & packed_byte) << 2); + getlong((VOID *) p, &temp_part[Part].peStartSector); + p += sizeof(LONG); + getlong((VOID *) p, &temp_part[Part].peSectors); + }; + + /* Walk through the table, add DOS partitions to global + array and process extended partitions */ + for (Part = 0; Part < N_PART && nUnits < NDEV; Part++) + { + if (temp_part[Part].peFileSystem == FAT12 || + temp_part[Part].peFileSystem == FAT16SMALL || + temp_part[Part].peFileSystem == FAT16LARGE) + { + miarray[nUnits].mi_offset = + temp_part[Part].peStartSector + ptAccuOff; + miarray[nUnits].mi_drive = ptDrive; + miarray[nUnits].mi_partidx = nPartitions; + nUnits++; + + dos_partition[nPartitions].peDrive = ptDrive; + dos_partition[nPartitions].peBootable = + temp_part[Part].peBootable; + dos_partition[nPartitions].peBeginHead = + temp_part[Part].peBeginHead; + dos_partition[nPartitions].peBeginSector = + temp_part[Part].peBeginSector; + dos_partition[nPartitions].peBeginCylinder = + temp_part[Part].peBeginCylinder; + dos_partition[nPartitions].peFileSystem = + temp_part[Part].peFileSystem; + dos_partition[nPartitions].peEndHead = + temp_part[Part].peEndHead; + dos_partition[nPartitions].peEndSector = + temp_part[Part].peEndSector; + dos_partition[nPartitions].peEndCylinder = + temp_part[Part].peEndCylinder; + dos_partition[nPartitions].peStartSector = + temp_part[Part].peStartSector; + dos_partition[nPartitions].peSectors = + temp_part[Part].peSectors; + dos_partition[nPartitions].peAbsStart = + temp_part[Part].peStartSector + ptAccuOff; + nPartitions++; + } + else if (temp_part[Part].peFileSystem == EXTENDED) + { + /* call again to process extended part table */ + processtable(ptDrive, + temp_part[Part].peBeginHead, + temp_part[Part].peBeginCylinder, + temp_part[Part].peBeginSector, + temp_part[Part].peStartSector + ptAccuOff); + }; + }; + return TRUE; +} + +COUNT blk_driver(rqptr rp) +{ + if (rp->r_unit >= nUnits && rp->r_command != C_INIT) + return failure(E_UNIT); + if (rp->r_command > NENTRY) + { + return failure(E_FAILURE); /* general failure */ + } + else + return ((*dispatch[rp->r_command]) (rp)); +} + +static WORD init(rqptr rp) +{ + extern COUNT fl_nrdrives(VOID); + COUNT HardDrive, + nHardDisk, + Unit; + + /* Reset the drives */ + fl_reset(0x80); + + /* Initial number of disk units */ + nUnits = 2; + /* Initial number of DOS partitions */ + nPartitions = 0; + + /* Setup media info and BPBs arrays */ + for (Unit = 0; Unit < NDEV; Unit++) + { + miarray[Unit].mi_size = 720l; + miarray[Unit].mi_heads = 2; + miarray[Unit].mi_cyls = 40; + miarray[Unit].mi_sectors = 9; + miarray[Unit].mi_offset = 0l; + miarray[Unit].mi_drive = Unit; + + bpbarray[Unit].bpb_nbyte = SEC_SIZE; + bpbarray[Unit].bpb_nsector = 2; + bpbarray[Unit].bpb_nreserved = 1; + bpbarray[Unit].bpb_nfat = 2; + bpbarray[Unit].bpb_ndirent = 112; + bpbarray[Unit].bpb_nsize = 720l; + bpbarray[Unit].bpb_mdesc = 0xfd; + bpbarray[Unit].bpb_nfsect = 2; + + bpbptrs[Unit] = &bpbarray[Unit]; + }; + + nHardDisk = fl_nrdrives(); + for (HardDrive = 0; HardDrive < nHardDisk; HardDrive++) + { + /* Process primary partition table */ + if (!processtable((HardDrive | 0x80), 0, 0l, 1, 0l)) + /* Exit if no hard drive */ + break; + }; + + rp->r_nunits = nUnits; + rp->r_bpbptr = bpbptrs; + rp->r_endaddr = device_end(); + return S_DONE; +} + +static WORD mediachk(rqptr rp) +{ + COUNT drive = miarray[rp->r_unit].mi_drive; + COUNT result; + + /* if it's a hard drive, media never changes */ + if (hd(drive)) + rp->r_mcretcode = M_NOT_CHANGED; + else + /* else, check floppy status */ + { + if ((result = fl_readdasd(drive)) == 2) /* if we can detect a change ... */ + { + if ((result = fl_diskchanged(drive)) == 1) /* check if it has changed... */ + rp->r_mcretcode = M_CHANGED; + else if (result == 0) + rp->r_mcretcode = M_NOT_CHANGED; + else + rp->r_mcretcode = tdelay((LONG) 37) ? M_DONT_KNOW : M_NOT_CHANGED; + } + else if (result == 3) /* if it's a fixed disk, then no change */ + rp->r_mcretcode = M_NOT_CHANGED; + else /* can not detect or error... */ + rp->r_mcretcode = tdelay((LONG) 37) ? M_DONT_KNOW : M_NOT_CHANGED; + } + + return S_DONE; +} + +static WORD bldbpb(rqptr rp) +{ + REG retry = N_RETRY; + ULONG count; + byteptr trans; + WORD local_word; + + if (hd(miarray[rp->r_unit].mi_drive)) + { + COUNT partidx = miarray[rp->r_unit].mi_partidx; + head = dos_partition[partidx].peBeginHead; + sector = dos_partition[partidx].peBeginSector; + track = dos_partition[partidx].peBeginCylinder; + } + else + { + head = 0; + sector = 1; + track = 0; + } + + do + { + ret = fl_read((WORD) miarray[rp->r_unit].mi_drive, + (WORD) head, (WORD) track, (WORD) sector, (WORD) 1, (byteptr) & buffer); + } + while (ret != 0 && --retry > 0); + if (ret != 0) + return (dskerr(ret)); + + getword(&((((BYTE *) & buffer.bytes[BT_BPB]))[BPB_NBYTE]), &bpbarray[rp->r_unit].bpb_nbyte); + getbyte(&((((BYTE *) & buffer.bytes[BT_BPB]))[BPB_NSECTOR]), &bpbarray[rp->r_unit].bpb_nsector); + getword(&((((BYTE *) & buffer.bytes[BT_BPB]))[BPB_NRESERVED]), &bpbarray[rp->r_unit].bpb_nreserved); + getbyte(&((((BYTE *) & buffer.bytes[BT_BPB]))[BPB_NFAT]), &bpbarray[rp->r_unit].bpb_nfat); + getword(&((((BYTE *) & buffer.bytes[BT_BPB]))[BPB_NDIRENT]), &bpbarray[rp->r_unit].bpb_ndirent); + getword(&((((BYTE *) & buffer.bytes[BT_BPB]))[BPB_NSIZE]), &bpbarray[rp->r_unit].bpb_nsize); + getword(&((((BYTE *) & buffer.bytes[BT_BPB]))[BPB_NSIZE]), &bpbarray[rp->r_unit].bpb_nsize); + getbyte(&((((BYTE *) & buffer.bytes[BT_BPB]))[BPB_MDESC]), &bpbarray[rp->r_unit].bpb_mdesc); + getword(&((((BYTE *) & buffer.bytes[BT_BPB]))[BPB_NFSECT]), &bpbarray[rp->r_unit].bpb_nfsect); + getword(&((((BYTE *) & buffer.bytes[BT_BPB]))[BPB_NSECS]), &bpbarray[rp->r_unit].bpb_nsecs); + getword(&((((BYTE *) & buffer.bytes[BT_BPB]))[BPB_NHEADS]), &bpbarray[rp->r_unit].bpb_nheads); + getlong(&((((BYTE *) & buffer.bytes[BT_BPB])[BPB_HIDDEN])), &bpbarray[rp->r_unit].bpb_hidden); + getlong(&((((BYTE *) & buffer.bytes[BT_BPB])[BPB_HUGE])), &bpbarray[rp->r_unit].bpb_huge); +#ifdef DSK_DEBUG + printf("BPB_NBYTE = %04x\n", bpbarray[rp->r_unit].bpb_nbyte); + printf("BPB_NSECTOR = %02x\n", bpbarray[rp->r_unit].bpb_nsector); + printf("BPB_NRESERVED = %04x\n", bpbarray[rp->r_unit].bpb_nreserved); + printf("BPB_NFAT = %02x\n", bpbarray[rp->r_unit].bpb_nfat); + printf("BPB_NDIRENT = %04x\n", bpbarray[rp->r_unit].bpb_ndirent); + printf("BPB_NSIZE = %04x\n", bpbarray[rp->r_unit].bpb_nsize); + printf("BPB_MDESC = %02x\n", bpbarray[rp->r_unit].bpb_mdesc); + printf("BPB_NFSECT = %04x\n", bpbarray[rp->r_unit].bpb_nfsect); +#endif + rp->r_bpptr = &bpbarray[rp->r_unit]; + count = miarray[rp->r_unit].mi_size = + bpbarray[rp->r_unit].bpb_nsize == 0 ? + bpbarray[rp->r_unit].bpb_huge : + bpbarray[rp->r_unit].bpb_nsize; + getword((&(((BYTE *) & buffer.bytes[BT_BPB])[BPB_NHEADS])), &miarray[rp->r_unit].mi_heads); + head = miarray[rp->r_unit].mi_heads; + getword((&(((BYTE *) & buffer.bytes[BT_BPB])[BPB_NSECS])), &miarray[rp->r_unit].mi_sectors); + if (miarray[rp->r_unit].mi_size == 0) + getlong(&((((BYTE *) & buffer.bytes[BT_BPB])[BPB_HUGE])), &miarray[rp->r_unit].mi_size); + sector = miarray[rp->r_unit].mi_sectors; + if (head == 0 || sector == 0) + { + tmark(); + return failure(E_FAILURE); + } + miarray[rp->r_unit].mi_cyls = count / (head * sector); + tmark(); +#ifdef DSK_DEBUG + printf("BPB_NSECS = %04x\n", sector); + printf("BPB_NHEADS = %04x\n", head); + printf("BPB_HIDDEN = %08lx\n", bpbarray[rp->r_unit].bpb_hidden); + printf("BPB_HUGE = %08lx\n", bpbarray[rp->r_unit].bpb_huge); +#endif + return S_DONE; +} + +static COUNT write_and_verify(WORD drive, WORD head, WORD track, WORD sector, + WORD count, BYTE FAR * buffer) +{ + REG COUNT ret; + + ret = fl_write(drive, head, track, sector, count, buffer); + if (ret != 0) + return ret; + return fl_verify(drive, head, track, sector, count, buffer); +} + +static WORD blockio(rqptr rp) +{ + REG retry = N_RETRY, + remaining; + UWORD cmd, + total; + ULONG start; + byteptr trans; + COUNT(*action) (WORD, WORD, WORD, WORD, WORD, BYTE FAR *); + + cmd = rp->r_command; + total = 0; + trans = rp->r_trans; + tmark(); + for ( + remaining = rp->r_count, + start = (rp->r_start != HUGECOUNT ? rp->r_start : rp->r_huge) + + miarray[rp->r_unit].mi_offset; + remaining > 0; + remaining -= count, trans += count * SEC_SIZE, start += count + ) + { + count = ltop(&track, §or, &head, rp->r_unit, remaining, start, trans); + do + { + switch (cmd) + { + case C_INPUT: + action = fl_read; + break; + case C_OUTPUT: + action = fl_write; + break; + case C_OUTVFY: + action = write_and_verify; + break; + default: + return failure(E_FAILURE); + } + if (count) + ret = action((WORD) miarray[rp->r_unit].mi_drive, head, track, sector, + count, trans); + else + { + count = 1; + /* buffer crosses DMA boundary, use scratchpad */ + if (cmd != C_INPUT) + fbcopy(trans, dma_scratch, SEC_SIZE); + ret = action((WORD) miarray[rp->r_unit].mi_drive, head, track, sector, + 1, dma_scratch); + if (cmd == C_INPUT) + fbcopy(dma_scratch, trans, SEC_SIZE); + } + if (ret != 0) + fl_reset((WORD) miarray[rp->r_unit].mi_drive); + } + while (ret != 0 && --retry > 0); + if (ret != 0) + { + rp->r_count = total; + return dskerr(ret); + } + total += count; + } + rp->r_count = total; + return S_DONE; +} + +static WORD blk_error(rqptr rp) +{ + rp->r_count = 0; + return failure(E_FAILURE); /* general failure */ +} + +static WORD dskerr(COUNT code) +{ +/* printf("diskette error:\nhead = %d\ntrack = %d\nsector = %d\ncount = %d\n", + head, track, sector, count); */ + switch (code & 0x03) + { + case 1: /* invalid command - general failure */ + if (code & 0x08) + return (E_FAILURE); + else + return failure(E_CMD); + + case 2: /* address mark not found - general failure */ + return failure(E_FAILURE); + + case 3: /* write protect */ + return failure(E_WRPRT); + + default: + if (code & 0x80) /* time-out */ + return failure(E_NOTRDY); + else if (code & 0x40) /* seek error */ + return failure(E_SEEK); + else if (code & 0x10) /* CRC error */ + return failure(E_CRC); + else if (code & 0x04) + return failure(E_NOTFND); + else + return failure(E_FAILURE); + } +} + +/* */ +/* Do logical block number to physical head/track/sector mapping */ +/* */ +static COUNT ltop(WORD * trackp, WORD * sectorp, WORD * headp, REG COUNT unit, COUNT count, LONG strt_sect, byteptr strt_addr) +{ +#ifdef I86 + ULONG ltemp; +#endif + REG ls, + ps; + +#ifdef I86 + /* Adjust for segmented architecture */ + ltemp = (((ULONG) mk_segment(strt_addr) << 4) + mk_offset(strt_addr)) & 0xffff; + /* Test for 64K boundary crossing and return count large */ + /* enough not to exceed the threshold. */ + count = (((ltemp + SEC_SIZE * count) & 0xffff0000l) != 0l) + ? (0xffffl - ltemp) / SEC_SIZE + : count; +#endif + + *trackp = strt_sect / (miarray[unit].mi_heads * miarray[unit].mi_sectors); + *sectorp = strt_sect % miarray[unit].mi_sectors + 1; + *headp = (strt_sect % (miarray[unit].mi_sectors * miarray[unit].mi_heads)) + / miarray[unit].mi_sectors; + if (*sectorp + count > miarray[unit].mi_sectors + 1) + count = miarray[unit].mi_sectors + 1 - *sectorp; + return count; +} diff --git a/kernel/entry.asm b/kernel/entry.asm new file mode 100644 index 00000000..daf1b2d7 --- /dev/null +++ b/kernel/entry.asm @@ -0,0 +1,633 @@ +; +; File: +; entry.asm +; Description: +; System call entry code +; +; Copyright (c) 1998 +; Pasquale J. Villani +; All Rights Reserved +; +; This file is part of DOS-C. +; +; DOS-C is free software; you can redistribute it and/or +; modify it under the terms of the GNU General Public License +; as published by the Free Software Foundation; either version +; 2, or (at your option) any later version. +; +; DOS-C is distributed in the hope that it will be useful, but +; WITHOUT ANY WARRANTY; without even the implied warranty of +; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See +; the GNU General Public License for more details. +; +; You should have received a copy of the GNU General Public +; License along with DOS-C; see the file COPYING. If not, +; write to the Free Software Foundation, 675 Mass Ave, +; Cambridge, MA 02139, USA. +; +; $Id$ +; +; $Log$ +; Revision 1.1 2000/05/06 19:35:03 jhall1 +; Initial revision +; +; Revision 1.4 1999/09/23 04:40:46 jprice +; *** empty log message *** +; +; Revision 1.2 1999/08/10 17:57:12 jprice +; ror4 2011-02 patch +; +; Revision 1.1.1.1 1999/03/29 15:40:53 jprice +; New version without IPL.SYS +; +; Revision 1.4 1999/02/08 05:55:57 jprice +; Added Pat's 1937 kernel patches +; +; Revision 1.3 1999/02/01 01:48:41 jprice +; Clean up; Now you can use hex numbers in config.sys. added config.sys screen function to change screen mode (28 or 43/50 lines) +; +; Revision 1.2 1999/01/22 04:13:25 jprice +; Formating +; +; Revision 1.1.1.1 1999/01/20 05:51:01 jprice +; Imported sources +; +; Rev 1.1 06 Dec 1998 8:48:40 patv +; New int 21h handler code. +; +; Rev 1.0 07 Feb 1998 20:42:08 patv +; Modified stack frame to match DOS standard +; $EndLog$ + + %include "segs.inc" + %include "stacks.inc" + +segment _TEXT + extern _int21_syscall:wrt TGROUP + extern _int25_handler:wrt TGROUP + extern _int26_handler:wrt TGROUP + extern _set_stack:wrt TGROUP + extern _restore_stack:wrt TGROUP + extern _error_tos:wrt DGROUP + extern _char_api_tos:wrt DGROUP + extern _disk_api_tos:wrt DGROUP + extern _lpUserStack:wrt DGROUP + extern _user_r:wrt DGROUP + extern _ErrorMode:wrt DGROUP + extern _InDOS:wrt DGROUP + extern _cu_psp:wrt DGROUP + extern _MachineId:wrt DGROUP + extern critical_sp:wrt DGROUP + + extern _api_sp:wrt DGROUP ; api stacks - for context + extern _api_ss:wrt DGROUP ; switching + extern _usr_sp:wrt DGROUP ; user stacks + extern _usr_ss:wrt DGROUP + extern int21regs_seg:wrt DGROUP + extern int21regs_off:wrt DGROUP + + extern _dosidle_flag:wrt DGROUP + extern _Int21AX:wrt DGROUP + + + global _cpm_entry + global _int20_handler + global _int21_handler + global _low_int25_handler + global _low_int26_handler + global _int27_handler + + +; +; MS-DOS CP/M style entry point +; +; VOID FAR +; cpm_entry(iregs UserRegs) +; +; This one is a strange one. The call is to psp:0005h but it returns to the +; function after the call. What we do is convert it to a normal call and +; fudge the stack to look like an int 21h call. +; +_cpm_entry: + ; Stack is: + ; return offset + ; psp seg + ; 000ah + ; + push bp ; trash old return address + mov bp,sp + xchg bp,[2+bp] + pop bp + pushf ; start setting up int 21h stack + ; + ; now stack is + ; return offset + ; psp seg + ; flags + ; + push bp + mov bp,sp ; set up reference frame + ; + ; reference frame stack is + ; return offset bp + 6 + ; psp seg bp + 4 + ; flags bp + 2 + ; bp <--- bp + ; + push ax + mov ax,[2+bp] ; get the flags + xchg ax,[6+bp] ; swap with return address + mov [2+bp],ax + pop ax ; restore working registers + pop bp + ; + ; Done. Stack is + ; flags + ; psp seg (alias .COM cs) + ; return offset + ; + cmp cl,024h + jbe cpm_error + mov ah,cl ; get the call # from cl to ah + jmp short _int21_handler ; do the system call +cpm_error: mov al,0 + iret + +; +; Restart the int 21h system call. Call never returns. +; +; VOID +; RestartSysCall(VOID); +; +; NOTE: On exit, DS must point to kernel stack, SS:SP user stack after +; PUSH$ALL and BP == SP. +; +_RestartSysCall: + cli ; no interrupts + mov bp,word [_lpUserStack+2] ;Get frame + mov ss,bp + mov bp,word [_lpUserStack] + mov sp,bp + sti + POP$ALL ; get the original regs + jmp short int21_reentry ; restart the system call + + +; +; Terminate the current process +; +; VOID INRPT far +; int20_handler(iregs UserRegs) +; +_int20_handler: + mov ah,0 ; terminate through int 21h + + +; +; MS-DOS system call entry point +; +; VOID INRPT far +; int21_handler(iregs UserRegs) +; +_int21_handler: + ; + ; Create the stack frame for C call. This is done to + ; preserve machine state and provide a C structure for + ; access to registers. + ; + ; Since this is an interrupt routine, CS, IP and flags were + ; pushed onto the stack by the processor, completing the + ; stack frame. + ; + ; NB: stack frame is MS-DOS dependent and not compatible + ; with compiler interrupt stack frames. + ; + PUSH$ALL + + ; + ; Create kernel refernce frame. + ; + ; NB: At this point, SS != DS and won't be set that way + ; until later when which stack to run on is determined. + ; + mov bp,DGROUP + mov ds,bp + + ; + ; Now DS is set, let's save our stack for rentry + ; + mov bp,ss + mov word [_lpUserStack+2],bp + mov word [_user_r+2],bp + mov bp,sp + mov word [_lpUserStack],bp ; store and init + mov word [_user_r],bp ; store and init + + ; + ; Decide which stack to run on. + ; + ; Unlike previous versions of DOS-C, we need to do this here + ; to guarantee the user stack for critical error handling. + ; We need to do the int 24h from this stack location. + ; + ; There are actually four stacks to run on. The first is the + ; user stack which is determined by system call number in + ; AH. The next is the error stack determined by _ErrorMode. + ; Then there's the character stack also determined by system + ; call number. Finally, all others run on the disk stack. + ; They are evaluated in that order. + +int21_reentry: + cmp ah,33h + je int21_user + cmp ah,50h + je int21_user + cmp ah,51h + je int21_user + cmp ah,62h + jne int21_1 + +int21_user: push word [_user_r+2] + push word [_user_r] + call _int21_syscall + pop cx + pop cx + jmp int21_ret + +int21_1: sti + cmp byte [_ErrorMode],0 + je int21_2 + mov bp,ds + mov ss,bp + mov bp,_error_tos + mov sp,bp + cli + push word [_user_r+2] + push word [_user_r] + call _int21_syscall + jmp short int21_exit + +int21_2: inc byte [_InDOS] + cmp ah,0ch + jg int21_3 +; +; Make FreeDOS better than the others! +; + cmp byte [_dosidle_flag],0 + jne int21_user + + mov bp,ds + mov ss,bp + mov bp,_char_api_tos + mov sp,bp + cli + push word [_user_r+2] + push word [_user_r] + call _int21_syscall + jmp short int21_exit + +int21_3: + call dos_crit_sect + + mov bp,ds + mov ss,bp + mov bp,_disk_api_tos + mov sp,bp + cli + ; + ; Push the far pointer to the register frame for + ; int21_syscall and remainder of kernel. + ; + push word [_user_r+2] + push word [_user_r] + call _int21_syscall + + ; + ; Recover registers from system call. Registers and flags + ; were modified by the system call. + ; +int21_exit: sti + mov bp,word [_user_r+2] + mov ss,bp + mov bp,word [_user_r] ; store and init + mov sp,bp + dec byte [_InDOS] + cli +int21_ret: POP$ALL + + ; + ; ... and return. + ; + iret +; +; end Dos Critical Section 0 thur 7 +; +; +dos_crit_sect: + mov [_Int21AX],ax ; needed! + push ax ; This must be here!!! + mov ah,82h ; re-enrty sake before disk stack + int 2ah ; Calling Server Hook! + pop ax + ret + +; +; Terminate the current process +; +; VOID INRPT far +; int27_handler(iregs UserRegs) +; +_int27_handler: + ; + ; First convert the memory to paragraphs + ; + add dx,byte 0fh ; round up + rcr dx,1 + shr dx,1 + shr dx,1 + shr dx,1 + ; + ; ... then use the standard system call + ; + mov ax,3100h + jmp _int21_handler ; terminate through int 21h + +; +; I really do need to get rid of this because it's the only thing stopping +; us from being ROMABLE. +; +stkframe dd 0 + +_low_int25_handler: + sti + pushf + push ax + push cx + push dx + push bx + push sp + push bp + push si + push di + push ds + push es + + mov word [cs:stkframe], sp ; save stack frame + mov word [cs:stkframe+2], ss + + cld + mov ax, DGROUP + mov ds, ax + + mov word [_api_sp], _disk_api_tos + mov word [_api_ss], ds + + call far _set_stack + + push word [cs:stkframe+2] + push word [cs:stkframe] + call _int25_handler + add sp, byte 4 + + call far _restore_stack + + pop es + pop ds + pop di + pop si + pop bp + pop bx ; pop off sp value + pop bx + pop dx + pop cx + pop ax + popf + retf ; Bug-compatiblity with MS-DOS. + ; This function is supposed to leave the original + ; flag image on the stack. + + +_low_int26_handler: + sti + pushf + push ax + push cx + push dx + push bx + push sp + push bp + push si + push di + push ds + push es + + mov word [cs:stkframe], sp ; save stack frame + mov word [cs:stkframe+2], ss + + cld + mov ax, DGROUP + mov ds, ax + + mov word [_api_sp], _disk_api_tos + mov word [_api_ss], ds + + call far _set_stack + + push word [cs:stkframe+2] + push word [cs:stkframe] + call _int26_handler + add sp, 4 + + call far _restore_stack + + pop es + pop ds + pop di + pop si + pop bp + pop bx ; pop off sp value + pop bx + pop dx + pop cx + pop ax + popf + retf + + +CONTINUE equ 00h +RETRY equ 01h +ABORT equ 02h +FAIL equ 03h + +OK_IGNORE equ 20h +OK_RETRY equ 10h +OK_FAIL equ 08h + +PSP_PARENT equ 16h +PSP_USERSP equ 2eh +PSP_USERSS equ 30h + + +; +; Default Int 24h handler -- always returns fail +; + global _int24_handler +_int24_handler: mov al,FAIL + iret + +; +; COUNT +; CriticalError(COUNT nFlag, COUNT nDrive, COUNT nError, struct dhdr FAR *lpDevice); +; + global _CriticalError +_CriticalError: + ; + ; Skip critical error routine if handler is active + ; + cmp byte [_ErrorMode],0 + je CritErr05 ; Jump if equal + + mov ax,FAIL + retn + ; + ; Do local error processing + ; +CritErr05: + ; + ; C Entry + ; + push bp + mov bp,sp + push si + push di + ; + ; Get parameters + ; + mov ah,byte [bp+4] ; nFlags + mov al,byte [bp+6] ; nDrive + mov di,word [bp+8] ; nError + ; + ; make bp:si point to dev header + ; + mov si,word [bp+10] ; lpDevice Offset + mov bp,word [bp+12] ; lpDevice segment + ; + ; Now save real ss:sp and retry info in internal stack + ; + cli + mov es,[_cu_psp] + push word [es:PSP_USERSS] + push word [es:PSP_USERSP] + push word [_MachineId] + push word [int21regs_seg] + push word [int21regs_off] + push word [_api_sp] + push word [_api_ss] + push word [_usr_sp] + push word [_usr_ss] + push word [_user_r+2] + push word [_user_r] + mov [critical_sp],sp + ; + ; do some clean up because user may never return + ; + inc byte [_ErrorMode] + dec byte [_InDOS] + ; + ; switch to user's stack + ; + mov ss,[es:PSP_USERSS] + mov sp,[es:PSP_USERSP] + ; + ; and call critical error handler + ; + int 24h ; DOS Critical error handler + + ; + ; recover context + ; + cld + cli + mov bp, DGROUP + mov ds,bp + mov ss,bp + mov sp,[critical_sp] + pop word [_user_r] + pop word [_user_r+2] + pop word [_usr_ss] + pop word [_usr_sp] + pop word [_api_ss] + pop word [_api_sp] + pop word [int21regs_off] + pop word [int21regs_seg] + pop word [_MachineId] + mov es,[_cu_psp] + pop word [es:PSP_USERSP] + pop word [es:PSP_USERSS] + sti ; Enable interrupts + ; + ; clear flags + ; + mov byte [_ErrorMode],0 + inc byte [_InDOS] + ; + ; Check for ignore and force fail if not ok + cmp al,CONTINUE + jne CritErr10 ; not ignore, keep testing + test bh,OK_IGNORE + jnz CritErr10 + mov al,FAIL + ; + ; Check for retry and force fail if not ok + ; +CritErr10: + cmp al,RETRY + jne CritErr20 ; not retry, keep testing + test bh,OK_RETRY + jnz CritErr20 + mov al,FAIL + ; + ; You know the drill, but now it's different. + ; check for fail and force abort if not ok + ; +CritErr20: + cmp al,FAIL + jne CritErr30 ; not fail, do exit processing + test bh,OK_FAIL + jnz CritErr30 + mov al,ABORT + ; + ; OK, if it's abort we do extra processing. Otherwise just + ; exit. + ; +CritErr30: + cmp al,ABORT + je CritErrAbort ; process abort + +CritErrExit: + xor ah,ah ; clear out top for return + pop di + pop si + pop bp + ret + + ; + ; Abort processing. + ; +CritErrAbort: + mov ax,[_cu_psp] + mov es,ax + cmp ax,[es:PSP_PARENT] + mov al,FAIL + jz CritErrExit + cli + mov bp,word [_user_r+2] ;Get frame + mov ss,bp + mov es,bp + mov bp,word [_user_r] + mov sp,bp + mov byte [_ErrorMode],1 ; flag abort + mov ax,4C00h + mov [es:reg_ax],ax + sti + jmp int21_reentry ; restart the system call diff --git a/kernel/error.c b/kernel/error.c new file mode 100644 index 00000000..50c95b90 --- /dev/null +++ b/kernel/error.c @@ -0,0 +1,145 @@ +/****************************************************************/ +/* */ +/* error.c */ +/* */ +/* Main Kernel Error Handler Functions */ +/* */ +/* Copyright (c) 1995 */ +/* Pasquale J. Villani */ +/* All Rights Reserved */ +/* */ +/* This file is part of DOS-C. */ +/* */ +/* DOS-C is free software; you can redistribute it and/or */ +/* modify it under the terms of the GNU General Public License */ +/* as published by the Free Software Foundation; either version */ +/* 2, or (at your option) any later version. */ +/* */ +/* DOS-C is distributed in the hope that it will be useful, but */ +/* WITHOUT ANY WARRANTY; without even the implied warranty of */ +/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See */ +/* the GNU General Public License for more details. */ +/* */ +/* You should have received a copy of the GNU General Public */ +/* License along with DOS-C; see the file COPYING. If not, */ +/* write to the Free Software Foundation, 675 Mass Ave, */ +/* Cambridge, MA 02139, USA. */ +/****************************************************************/ + +#include "portab.h" + +#ifdef VERSION_STRINGS +static BYTE *errorRcsId = "$Id$"; +#endif + +/* + * $Log$ + * Revision 1.1 2000/05/06 19:35:03 jhall1 + * Initial revision + * + * Revision 1.2 2000/03/09 06:07:11 kernel + * 2017f updates by James Tabor + * + * Revision 1.1.1.1 1999/03/29 15:41:55 jprice + * New version without IPL.SYS + * + * Revision 1.4 1999/02/09 02:54:23 jprice + * Added Pat's 1937 kernel patches + * + * Revision 1.3 1999/02/01 01:43:28 jprice + * Fixed findfirst function to find volume label with Windows long filenames + * + * Revision 1.2 1999/01/22 04:15:28 jprice + * Formating + * + * Revision 1.1.1.1 1999/01/20 05:51:00 jprice + * Imported sources + * + * + * Rev 1.5 06 Dec 1998 8:43:54 patv + * Now handles errors like MS-DOS. + * + * Rev 1.4 04 Jan 1998 23:14:36 patv + * Changed Log for strip utility + * + * Rev 1.3 29 May 1996 21:15:10 patv + * bug fixes for v0.91a + * + * Rev 1.2 01 Sep 1995 17:48:46 patv + * First GPL release. + * + * Rev 1.1 30 Jul 1995 20:50:26 patv + * Eliminated version strings in ipl + * + * Rev 1.0 02 Jul 1995 8:06:14 patv + * Initial revision. + */ + +#include "globals.h" + +/* error registers */ +VOID dump(void) +{ + printf("Register Dump [AH = %02x CS:IP = %04x:%04x]\n", + error_regs.AH, + error_regs.CS, + error_regs.IP); + printf("AX:%04x BX:%04x CX:%04x DX:%04x\n", + error_regs.AX, + error_regs.BX, + error_regs.CX, + error_regs.DX); + printf("SI:%04x DI:%04x DS:%04x ES:%04x\n", + error_regs.SI, + error_regs.DI, + error_regs.DS, + error_regs.ES); +} + +/* issue a panic message for corrupted data structures */ +VOID panic(BYTE * s) +{ + printf("\nPANIC: %s\nSystem halted\n", s); + for (;;) ; +} + +#ifdef IPL +/* issue an internal error message */ +VOID fatal(BYTE * err_msg) +{ + printf("\nInternal IPL error - %s\nSystem halted\n", err_msg); + exit(-1); +} +#else +/* issue an internal error message */ +VOID fatal(BYTE * err_msg) +{ + printf("\nInternal kernel error - %s\nSystem halted\n", err_msg); + for (;;) ; +} + +VOID FAR init_call_fatal(BYTE * err_msg) +{ + fatal(err_msg); +} +#endif + +/* Abort, retry or fail for character devices */ +COUNT char_error(request * rq, struct dhdr FAR * lpDevice) +{ + return CriticalError( + EFLG_CHAR | EFLG_ABORT | EFLG_RETRY | EFLG_IGNORE, + 0, + rq->r_status & S_MASK, + lpDevice); +} + +/* Abort, retry or fail for block devices */ +COUNT block_error(request * rq, COUNT nDrive, struct dhdr FAR * lpDevice) +{ + return CriticalError( + EFLG_ABORT | EFLG_RETRY | EFLG_IGNORE, + nDrive, + rq->r_status & S_MASK, + lpDevice); +} diff --git a/kernel/execrh.asm b/kernel/execrh.asm new file mode 100644 index 00000000..138a79ca --- /dev/null +++ b/kernel/execrh.asm @@ -0,0 +1,129 @@ +; +; File: +; execrh.asm +; Description: +; request handler for calling device drivers +; +; Copyright (c) 1995, 1998 +; Pasquale J. Villani +; All Rights Reserved +; +; This file is part of DOS-C. +; +; DOS-C is free software; you can redistribute it and/or +; modify it under the terms of the GNU General Public License +; as published by the Free Software Foundation; either version +; 2, or (at your option) any later version. +; +; DOS-C is distributed in the hope that it will be useful, but +; WITHOUT ANY WARRANTY; without even the implied warranty of +; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See +; the GNU General Public License for more details. +; +; You should have received a copy of the GNU General Public +; License along with DOS-C; see the file COPYING. If not, +; write to the Free Software Foundation, 675 Mass Ave, +; Cambridge, MA 02139, USA. +; +; $Logfile: C:/usr/patv/dos-c/src/kernel/execrh.asv $ +; +; $Id$ +; +; $Log$ +; Revision 1.1 2000/05/06 19:35:03 jhall1 +; Initial revision +; +; Revision 1.3 2000/03/09 06:07:11 kernel +; 2017f updates by James Tabor +; +; Revision 1.2 1999/08/10 17:57:12 jprice +; ror4 2011-02 patch +; +; Revision 1.1.1.1 1999/03/29 15:40:54 jprice +; New version without IPL.SYS +; +; Revision 1.4 1999/02/08 05:55:57 jprice +; Added Pat's 1937 kernel patches +; +; Revision 1.3 1999/02/01 01:48:41 jprice +; Clean up; Now you can use hex numbers in config.sys. added config.sys screen function to change screen mode (28 or 43/50 lines) +; +; Revision 1.2 1999/01/22 04:13:25 jprice +; Formating +; +; Revision 1.1.1.1 1999/01/20 05:51:01 jprice +; Imported sources +; +; +; Rev 1.3 06 Dec 1998 8:45:06 patv +;Bug fixes. +; +; Rev 1.2 29 May 1996 21:03:30 patv +;bug fixes for v0.91a +; +; Rev 1.1 01 Sep 1995 17:54:22 patv +;First GPL release. +; +; Rev 1.0 02 Jul 1995 9:05:34 patv +;Initial revision. +; $EndLog$ +; + + %include "segs.inc" + +segment _TEXT + ; _execrh + ; Execute Device Request + ; + ; execrh(rhp, dhp) + ; request far *rhp; + ; struct dhdr far *dhp; + ; +; +; The stack is very critical in here. +; + global _execrh +_execrh: + push bp ; perform c entry + mov bp,sp + push bp ; it will get destroyed + push bx ; random char on display + push si + push es ; sometimes it get lost + push ds + + lds si,[bp+8] ; ds:si = device header + les bx,[bp+4] ; es:bx = request header + + push cs ; do this, the right way! + push word exit_execrh ; like 68k code + push ds + push word [ds:si+8] ; interrupt + push ds + push word [ds:si+6] ; strategy + retf +exit_execrh: sti ; damm driver turn off ints + cld ; has gone backwards + pop ds + pop es + pop si + pop bx + pop bp + mov sp,bp + pop bp + ret + + global _init_call_execrh + +_init_call_execrh: + push bp + mov bp,sp + push word [bp+12] + push word [bp+10] + push word [bp+8] + push word [bp+6] + call _execrh + mov sp,bp + pop bp + retf + diff --git a/kernel/fatdir.c b/kernel/fatdir.c new file mode 100644 index 00000000..1c2d8238 --- /dev/null +++ b/kernel/fatdir.c @@ -0,0 +1,829 @@ +/****************************************************************/ +/* */ +/* fatdir.c */ +/* DOS-C */ +/* */ +/* FAT File System dir Functions */ +/* */ +/* Copyright (c) 1995 */ +/* Pasquale J. Villani */ +/* All Rights Reserved */ +/* */ +/* This file is part of DOS-C. */ +/* */ +/* DOS-C is free software; you can redistribute it and/or */ +/* modify it under the terms of the GNU General Public License */ +/* as published by the Free Software Foundation; either version */ +/* 2, or (at your option) any later version. */ +/* */ +/* DOS-C is distributed in the hope that it will be useful, but */ +/* WITHOUT ANY WARRANTY; without even the implied warranty of */ +/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See */ +/* the GNU General Public License for more details. */ +/* */ +/* You should have received a copy of the GNU General Public */ +/* License along with DOS-C; see the file COPYING. If not, */ +/* write to the Free Software Foundation, 675 Mass Ave, */ +/* Cambridge, MA 02139, USA. */ +/****************************************************************/ + +#include "portab.h" +#include "globals.h" + +#ifdef VERSION_STRINGS +static BYTE *fatdirRcsId = "$Id$"; +#endif + +/* + * $Log$ + * Revision 1.1 2000/05/06 19:35:05 jhall1 + * Initial revision + * + * Revision 1.10 2000/03/09 06:07:11 kernel + * 2017f updates by James Tabor + * + * Revision 1.9 1999/08/25 03:18:07 jprice + * ror4 patches to allow TC 2.01 compile. + * + * Revision 1.8 1999/08/10 17:57:12 jprice + * ror4 2011-02 patch + * + * Revision 1.7 1999/05/03 06:25:45 jprice + * Patches from ror4 and many changed of signed to unsigned variables. + * + * Revision 1.6 1999/04/16 00:53:32 jprice + * Optimized FAT handling + * + * Revision 1.5 1999/04/13 15:48:20 jprice + * no message + * + * Revision 1.4 1999/04/11 04:33:38 jprice + * ror4 patches + * + * Revision 1.2 1999/04/04 18:51:43 jprice + * no message + * + * Revision 1.1.1.1 1999/03/29 15:41:58 jprice + * New version without IPL.SYS + * + * Revision 1.7 1999/03/25 05:06:57 jprice + * Fixed findfirst & findnext functions to treat the attributes like MSDOS does. + * + * Revision 1.6 1999/02/14 04:27:09 jprice + * Changed check media so that it checks if a floppy disk has been changed. + * + * Revision 1.5 1999/02/09 02:54:23 jprice + * Added Pat's 1937 kernel patches + * + * Revision 1.4 1999/02/01 01:43:28 jprice + * Fixed findfirst function to find volume label with Windows long filenames + * + * Revision 1.3 1999/01/30 08:25:34 jprice + * Clean up; Fixed bug with set attribute function. If you tried to + * change the attributres of a directory, it would erase it. + * + * Revision 1.2 1999/01/22 04:15:28 jprice + * Formating + * + * Revision 1.1.1.1 1999/01/20 05:51:00 jprice + * Imported sources + * + * + * Rev 1.10 06 Dec 1998 8:44:36 patv + * Bug fixes. + * + * Rev 1.9 22 Jan 1998 4:09:00 patv + * Fixed pointer problems affecting SDA + * + * Rev 1.8 04 Jan 1998 23:14:36 patv + * Changed Log for strip utility + * + * Rev 1.7 03 Jan 1998 8:36:02 patv + * Converted data area to SDA format + * + * Rev 1.6 16 Jan 1997 12:46:30 patv + * pre-Release 0.92 feature additions + * + * Rev 1.5 29 May 1996 21:15:18 patv + * bug fixes for v0.91a + * + * Rev 1.4 19 Feb 1996 3:20:12 patv + * Added NLS, int2f and config.sys processing + * + * Rev 1.2 01 Sep 1995 17:48:38 patv + * First GPL release. + * + * Rev 1.1 30 Jul 1995 20:50:24 patv + * Eliminated version strings in ipl + * + * Rev 1.0 02 Jul 1995 8:04:34 patv + * Initial revision. + */ + +VOID pop_dmp(dmatch FAR *, struct f_node FAR *); + +struct f_node FAR *dir_open(BYTE FAR * dirname) +{ + struct f_node FAR *fnp; + COUNT drive; + BYTE *p; + WORD i, + x; + BYTE *s; + struct cds FAR *cdsp; + BYTE *pszPath = &TempCDS.cdsCurrentPath[2]; + + /* Allocate an fnode if possible - error return (0) if not. */ + if ((fnp = get_f_node()) == (struct f_node FAR *)0) + { + return (struct f_node FAR *)NULL; + } + + /* Force the fnode into read-write mode */ + fnp->f_mode = RDWR; + + /* and initialize temporary CDS */ + TempCDS.cdsFlags = 0; + /* determine what drive we are using... */ + dirname = adjust_far(dirname); + if (ParseDosName(dirname, &drive, (BYTE *) 0, (BYTE *) 0, (BYTE *) 0, FALSE) + != SUCCESS) + { + release_f_node(fnp); + return NULL; + } + + /* If the drive was specified, drive is non-negative and */ + /* corresponds to the one passed in, i.e., 0 = A, 1 = B, etc. */ + /* We use that and skip the "D:" part of the string. */ + /* Otherwise, just use the default drive */ + if (drive >= 0) + { + dirname += 2; /* Assume FAT style drive */ + TempCDS.cdsDpb = CDSp->cds_table[drive].cdsDpb; + } + else + { + drive = default_drive; + TempCDS.cdsDpb = CDSp->cds_table[drive].cdsDpb; + + } + + cdsp = &CDSp->cds_table[drive]; + + TempCDS.cdsCurrentPath[0] = 'A' + drive; + TempCDS.cdsCurrentPath[1] = ':'; + TempCDS.cdsJoinOffset = 2; + + x = cdsp->cdsJoinOffset; + + /* Generate full path name */ + ParseDosPath(dirname, (COUNT *) 0, pszPath, (BYTE FAR *) & cdsp->cdsCurrentPath[x]); + + if ((cdsp->cdsFlags & 0x8000)) + { + printf("FailSafe %x \n", Int21AX); + return fnp; + } + + if (TempCDS.cdsDpb == 0) + { + release_f_node(fnp); + return NULL; + } + +/* if (drive >= lastdrive) + { + release_f_node(fnp); + return NULL; + } + */ + fnp->f_dpb = (struct dpb *)TempCDS.cdsDpb; + + /* Perform all directory common handling after all special */ + /* handling has been performed. */ + + if (media_check((struct dpb *)TempCDS.cdsDpb) < 0) + { + release_f_node(fnp); + return (struct f_node FAR *)0; + } + + fnp->f_dsize = DIRENT_SIZE * TempCDS.cdsDpb->dpb_dirents; + + fnp->f_diroff = 0l; + fnp->f_flags.f_dmod = FALSE; /* a brand new fnode */ + fnp->f_flags.f_dnew = TRUE; + fnp->f_flags.f_dremote = FALSE; + + fnp->f_dirstart = 0; + + /* Walk the directory tree to find the starting cluster */ + /* */ + /* Set the root flags since we always start from the root */ + + fnp->f_flags.f_droot = TRUE; + for (p = pszPath; *p != '\0';) + { + /* skip all path seperators */ + while (*p == '\\') + ++p; + /* don't continue if we're at the end */ + if (*p == '\0') + break; + + /* Convert the name into an absolute name for */ + /* comparison... */ + /* first the file name with trailing spaces... */ + for (i = 0; i < FNAME_SIZE; i++) + { + if (*p != '\0' && *p != '.' && *p != '/' && *p != '\\') + TempBuffer[i] = *p++; + else + break; + } + + for (; i < FNAME_SIZE; i++) + TempBuffer[i] = ' '; + + /* and the extension (don't forget to */ + /* add trailing spaces)... */ + if (*p == '.') + ++p; + for (i = 0; i < FEXT_SIZE; i++) + { + if (*p != '\0' && *p != '.' && *p != '/' && *p != '\\') + TempBuffer[i + FNAME_SIZE] = *p++; + else + break; + } + for (; i < FEXT_SIZE; i++) + TempBuffer[i + FNAME_SIZE] = ' '; + + /* Now search through the directory to */ + /* find the entry... */ + i = FALSE; + + upMem((BYTE FAR *) TempBuffer, FNAME_SIZE + FEXT_SIZE); + + while (dir_read(fnp) == DIRENT_SIZE) + { + if (fnp->f_dir.dir_name[0] != '\0' && fnp->f_dir.dir_name[0] != DELETED) + { + if (fcmp((BYTE FAR *) TempBuffer, (BYTE FAR *) fnp->f_dir.dir_name, FNAME_SIZE + FEXT_SIZE)) + { + i = TRUE; + break; + } + } + } + + if (!i || !(fnp->f_dir.dir_attrib & D_DIR)) + { + + release_f_node(fnp); + return (struct f_node FAR *)0; + } + else + { + /* make certain we've moved off */ + /* root */ + fnp->f_flags.f_droot = FALSE; + fnp->f_flags.f_ddir = TRUE; + /* set up for file read/write */ + fnp->f_offset = 0l; + fnp->f_cluster_offset = 0l; /*JPP */ + fnp->f_highwater = 0l; + fnp->f_cluster = fnp->f_dir.dir_start; + fnp->f_dirstart = fnp->f_dir.dir_start; + /* reset the directory flags */ + fnp->f_diroff = 0l; + fnp->f_flags.f_dmod = FALSE; + fnp->f_flags.f_dnew = TRUE; + fnp->f_dsize = DIRENT_SIZE * TempCDS.cdsDpb->dpb_dirents; + + } + } + return fnp; +} + +COUNT dir_read(REG struct f_node FAR * fnp) +{ + REG i; + REG j; + struct buffer FAR *bp; + + /* Directories need to point to their current offset, not for */ + /* next op. Therefore, if it is anything other than the first */ + /* directory entry, we will update the offset on entry rather */ + /* than wait until exit. If it was new, clear the special new */ + /* flag. */ + if (fnp->f_flags.f_dnew) + fnp->f_flags.f_dnew = FALSE; + else + fnp->f_diroff += DIRENT_SIZE; + + /* Determine if we hit the end of the directory. If we have, */ + /* bump the offset back to the end and exit. If not, fill the */ + /* dirent portion of the fnode, clear the f_dmod bit and leave, */ + /* but only for root directories */ + if (fnp->f_flags.f_droot && fnp->f_diroff >= fnp->f_dsize) + { + fnp->f_diroff -= DIRENT_SIZE; + return 0; + } + else + { + if (fnp->f_flags.f_droot) + { + if ((fnp->f_diroff / fnp->f_dpb->dpb_secsize + + fnp->f_dpb->dpb_dirstrt) + >= fnp->f_dpb->dpb_data) + { + fnp->f_flags.f_dfull = TRUE; + return 0; + } + + bp = getblock((ULONG) (fnp->f_diroff / fnp->f_dpb->dpb_secsize + + fnp->f_dpb->dpb_dirstrt), + fnp->f_dpb->dpb_unit); + bp->b_flag &= ~(BFR_DATA | BFR_FAT); + bp->b_flag |= BFR_DIR; +#ifdef DISPLAY_GETBLOCK + printf("DIR (dir_read)\n"); +#endif + } + else + { + REG UWORD secsize = fnp->f_dpb->dpb_secsize; + + /* Do a "seek" to the directory position */ + fnp->f_offset = fnp->f_diroff; + + /* Search through the FAT to find the block */ + /* that this entry is in. */ +#ifdef DISPLAY_GETBLOCK + printf("dir_read: "); +#endif + if (map_cluster(fnp, XFR_READ) != SUCCESS) + { + fnp->f_flags.f_dfull = TRUE; + return 0; + } + + /* If the returned cluster is FREE, return zero */ + /* bytes read. */ + if (fnp->f_cluster == FREE) + return 0; + + /* If the returned cluster is LAST_CLUSTER or */ + /* LONG_LAST_CLUSTER, return zero bytes read */ + /* and set the directory as full. */ + + if (last_link(fnp)) + { + fnp->f_diroff -= DIRENT_SIZE; + fnp->f_flags.f_dfull = TRUE; + return 0; + } + + /* Compute the block within the cluster and the */ + /* offset within the block. */ + fnp->f_sector = (fnp->f_offset / secsize) & fnp->f_dpb->dpb_clsmask; + fnp->f_boff = fnp->f_offset % secsize; + + /* Get the block we need from cache */ + bp = getblock((ULONG) clus2phys(fnp->f_cluster, + (fnp->f_dpb->dpb_clsmask + 1), + fnp->f_dpb->dpb_data) + + fnp->f_sector, + fnp->f_dpb->dpb_unit); + bp->b_flag &= ~(BFR_DATA | BFR_FAT); + bp->b_flag |= BFR_DIR; +#ifdef DISPLAY_GETBLOCK + printf("DIR (dir_read)\n"); +#endif + } + + /* Now that we have the block for our entry, get the */ + /* directory entry. */ + if (bp != NULL) + getdirent((BYTE FAR *) & bp->b_buffer[fnp->f_diroff % fnp->f_dpb->dpb_secsize], + (struct dirent FAR *)&fnp->f_dir); + else + { + fnp->f_flags.f_dfull = TRUE; + return 0; + } + + /* Update the fnode's directory info */ + fnp->f_flags.f_dfull = FALSE; + fnp->f_flags.f_dmod = FALSE; + + /* and for efficiency, stop when we hit the first */ + /* unused entry. */ + if (fnp->f_dir.dir_name[0] == '\0') + return 0; + else + return DIRENT_SIZE; + } +} + +#ifndef IPL +COUNT dir_write(REG struct f_node FAR * fnp) +{ + struct buffer FAR *bp; + + /* Update the entry if it was modified by a write or create... */ + if (fnp->f_flags.f_dmod) + { + /* Root is a consecutive set of blocks, so handling is */ + /* simple. */ + if (fnp->f_flags.f_droot) + { + bp = getblock( + (ULONG) (fnp->f_diroff / fnp->f_dpb->dpb_secsize + + fnp->f_dpb->dpb_dirstrt), + fnp->f_dpb->dpb_unit); + bp->b_flag &= ~(BFR_DATA | BFR_FAT); + bp->b_flag |= BFR_DIR; +#ifdef DISPLAY_GETBLOCK + printf("DIR (dir_write)\n"); +#endif + } + + /* All other directories are just files. The only */ + /* special handling is resetting the offset so that we */ + /* can continually update the same directory entry. */ + else + { + REG UWORD secsize = fnp->f_dpb->dpb_secsize; + + /* Do a "seek" to the directory position */ + /* and convert the fnode to a directory fnode. */ + fnp->f_offset = fnp->f_diroff; + fnp->f_back = LONG_LAST_CLUSTER; + fnp->f_cluster = fnp->f_dirstart; + fnp->f_cluster_offset = 0l; /*JPP */ + + /* Search through the FAT to find the block */ + /* that this entry is in. */ +#ifdef DISPLAY_GETBLOCK + printf("dir_write: "); +#endif + if (map_cluster(fnp, XFR_READ) != SUCCESS) + { + fnp->f_flags.f_dfull = TRUE; + release_f_node(fnp); + return 0; + } + + /* If the returned cluster is FREE, return zero */ + /* bytes read. */ + if (fnp->f_cluster == FREE) + { + release_f_node(fnp); + return 0; + } + + /* Compute the block within the cluster and the */ + /* offset within the block. */ + fnp->f_sector = (fnp->f_offset / secsize) & fnp->f_dpb->dpb_clsmask; + fnp->f_boff = fnp->f_offset % secsize; + + /* Get the block we need from cache */ + bp = getblock((ULONG) clus2phys(fnp->f_cluster, + (fnp->f_dpb->dpb_clsmask + 1), + fnp->f_dpb->dpb_data) + + fnp->f_sector, + fnp->f_dpb->dpb_unit); + bp->b_flag &= ~(BFR_DATA | BFR_FAT); + bp->b_flag |= BFR_DIR; +#ifdef DISPLAY_GETBLOCK + printf("DIR (dir_write)\n"); +#endif + } + + /* Now that we have a block, transfer the diectory */ + /* entry into the block. */ + if (bp == NULL) + { + release_f_node(fnp); + return 0; + } + putdirent((struct dirent FAR *)&fnp->f_dir, + (VOID FAR *) & bp->b_buffer[fnp->f_diroff % fnp->f_dpb->dpb_secsize]); + bp->b_flag |= BFR_DIRTY; + } + return DIRENT_SIZE; +} +#endif + +VOID dir_close(REG struct f_node FAR * fnp) +{ + REG COUNT disk = fnp->f_dpb->dpb_unit; + + /* Test for invalid f_nodes */ + if (fnp == NULL) + return; + +#ifndef IPL + /* Write out the entry */ + dir_write(fnp); + +#endif + /* Clear buffers after release */ + flush_buffers(disk); + + /* and release this instance of the fnode */ + release_f_node(fnp); +} + +#ifndef IPL +COUNT dos_findfirst(UCOUNT attr, BYTE FAR * name) +{ + REG struct f_node FAR *fnp; + REG dmatch FAR *dmp = (dmatch FAR *) dta; + REG COUNT i; + COUNT nDrive; + BYTE *p; + struct cds FAR *cdsp; + + static BYTE local_name[FNAME_SIZE + 1], + local_ext[FEXT_SIZE + 1]; + + /* The findfirst/findnext calls are probably the worst of the */ + /* DOS calls. They must work somewhat on the fly (i.e. - open */ + /* but never close). Since we don't want to lose fnodes every */ + /* time a directory is searched, we will initialize the DOS */ + /* dirmatch structure and then for every find, we will open the */ + /* current directory, do a seek and read, then close the fnode. */ + + /* Start out by initializing the dirmatch structure. */ + dmp->dm_drive = default_drive; + dmp->dm_entry = 0; + dmp->dm_cluster = 0; + + dmp->dm_attr_srch = attr | D_RDONLY | D_ARCHIVE; + + /* Parse out the drive, file name and file extension. */ + i = ParseDosName(name, &nDrive, &LocalPath[2], local_name, local_ext, TRUE); + if (i != SUCCESS) + return i; + + if (nDrive >= 0) + { + dmp->dm_drive = nDrive; + } + else + nDrive = default_drive; + + cdsp = &CDSp->cds_table[nDrive]; + + if (cdsp->cdsFlags & 0x8000) + { + if (Remote_find(REM_FINDFIRST, attr, name, dmp) != 0) + return DE_FILENOTFND; + return SUCCESS; + } + + /* Now build a directory. */ + if (!LocalPath[2]) + strcpy(&LocalPath[2], "."); + + /* Build the match pattern out of the passed string */ + /* copy the part of the pattern which belongs to the filename and is fixed */ + for (p = local_name, i = 0; i < FNAME_SIZE && *p && *p != '*'; ++p, ++i) + SearchDir.dir_name[i] = *p; + if (*p == '*') + { + for (; i < FNAME_SIZE; ++i) + SearchDir.dir_name[i] = '?'; + while (*++p) ; + } + else + for (; i < FNAME_SIZE; i++) + SearchDir.dir_name[i] = ' '; + + /* and the extension (don't forget to add trailing spaces)... */ + for (p = local_ext, i = 0; i < FEXT_SIZE && *p && *p != '*'; ++p, ++i) + SearchDir.dir_ext[i] = *p; + if (*p == '*') + { + for (; i < FEXT_SIZE; ++i) + SearchDir.dir_ext[i] = '?'; + while (*++p) ; + } + else + for (; i < FEXT_SIZE; i++) + SearchDir.dir_ext[i] = ' '; + + /* Convert everything to uppercase. */ + upMem(SearchDir.dir_name, FNAME_SIZE + FEXT_SIZE); + + /* Copy the raw pattern from our data segment to the DTA. */ + fbcopy((BYTE FAR *) SearchDir.dir_name, dmp->dm_name_pat, + FNAME_SIZE + FEXT_SIZE); + + /* Now search through the directory to find the entry... */ + /* Special handling - the volume id is only in the root */ + /* directory and only searched for once. So we need to open */ + /* the root and return only the first entry that contains the */ + /* volume id bit set. */ + if ((attr & ~(D_RDONLY | D_ARCHIVE)) == D_VOLID) + { + /* Now open this directory so that we can read the */ + /* fnode entry and do a match on it. */ + if ((fnp = dir_open((BYTE FAR *) "\\")) == NULL) + return DE_PATHNOTFND; + + /* Now do the search */ + while (dir_read(fnp) == DIRENT_SIZE) + { + /* Test the attribute and return first found */ + if ((fnp->f_dir.dir_attrib & ~(D_RDONLY | D_ARCHIVE)) == D_VOLID) + { + pop_dmp(dmp, fnp); + dir_close(fnp); + return SUCCESS; + } + } + + /* Now that we've done our failed search, close it and */ + /* return an error. */ + dir_close(fnp); + return DE_FILENOTFND; + } + + /* Otherwise just do a normal find next */ + else + { + /* Complete building the directory from the passed in */ + /* name */ + if (nDrive >= 0) + LocalPath[0] = 'A' + nDrive; + else + LocalPath[0] = 'A' + default_drive; + LocalPath[1] = ':'; + + /* Now open this directory so that we can read the */ + /* fnode entry and do a match on it. */ + if ((fnp = dir_open((BYTE FAR *) LocalPath)) == NULL) + return DE_PATHNOTFND; + + pop_dmp(dmp, fnp); + dmp->dm_entry = 0; + if (!fnp->f_flags.f_droot) + { + dmp->dm_cluster = fnp->f_dirstart; + dmp->dm_dirstart = fnp->f_dirstart; + } + else + { + dmp->dm_cluster = 0; + dmp->dm_dirstart = 0; + } + dir_close(fnp); + return dos_findnext(); + } +} + +COUNT dos_findnext(void) +{ + REG dmatch FAR *dmp = (dmatch FAR *) dta; + REG struct f_node FAR *fnp; + BOOL found = FALSE; + BYTE FAR *p; + BYTE FAR *q; + COUNT nDrive; + struct cds FAR *cdsp; + + /* assign our match parameters pointer. */ + dmp = (dmatch FAR *) dta; + + nDrive = dmp->dm_drive; + + cdsp = &CDSp->cds_table[nDrive]; + if (cdsp->cdsFlags & 0x8000) + { + if (Remote_find(REM_FINDNEXT, 0, 0, dmp) != 0) + return DE_FILENOTFND; + return SUCCESS; + } + + /* Allocate an fnode if possible - error return (0) if not. */ + if ((fnp = get_f_node()) == (struct f_node FAR *)0) + { + return DE_FILENOTFND; + } + + /* Force the fnode into read-write mode */ + fnp->f_mode = RDWR; + + /* Select the default to help non-drive specified path */ + /* searches... */ + fnp->f_dpb = (struct dpb *)CDSp->cds_table[dmp->dm_drive].cdsDpb; + if (media_check(fnp->f_dpb) < 0) + { + release_f_node(fnp); + return DE_FILENOTFND; + } + + fnp->f_dsize = DIRENT_SIZE * (fnp->f_dpb)->dpb_dirents; + + /* Search through the directory to find the entry, but do a */ + /* seek first. */ + if (dmp->dm_entry > 0) + fnp->f_diroff = (dmp->dm_entry - 1) * DIRENT_SIZE; + + fnp->f_offset = fnp->f_highwater = fnp->f_diroff; + fnp->f_cluster = dmp->dm_cluster; + fnp->f_cluster_offset = 0l; /*JPP */ + fnp->f_flags.f_dmod = dmp->dm_flags.f_dmod; + fnp->f_flags.f_droot = dmp->dm_flags.f_droot; + fnp->f_flags.f_dnew = dmp->dm_flags.f_dnew; + fnp->f_flags.f_ddir = dmp->dm_flags.f_ddir; + fnp->f_flags.f_dfull = dmp->dm_flags.f_dfull; + + fnp->f_dirstart = dmp->dm_dirstart; + + /* Loop through the directory */ + while (dir_read(fnp) == DIRENT_SIZE) + { + ++dmp->dm_entry; + if (fnp->f_dir.dir_name[0] != '\0' && fnp->f_dir.dir_name[0] != DELETED) + { + if (fcmp_wild((BYTE FAR *) (dmp->dm_name_pat), (BYTE FAR *) fnp->f_dir.dir_name, FNAME_SIZE + FEXT_SIZE)) + { + /* Test the attribute as the final step */ + if (!(~dmp->dm_attr_srch & fnp->f_dir.dir_attrib)) + { + found = TRUE; + break; + } + else + continue; + } + } + } + + /* If found, transfer it to the dmatch structure */ + if (found) + pop_dmp(dmp, fnp); + + /* return the result */ + release_f_node(fnp); + + return found ? SUCCESS : DE_FILENOTFND; +} + +static VOID pop_dmp(dmatch FAR * dmp, struct f_node FAR * fnp) +{ + COUNT idx; + BYTE FAR *p; + BYTE FAR *q; + + dmp->dm_attr_fnd = fnp->f_dir.dir_attrib; + dmp->dm_time = fnp->f_dir.dir_time; + dmp->dm_date = fnp->f_dir.dir_date; + dmp->dm_size = fnp->f_dir.dir_size; +/* dmp -> dm_cluster = fnp -> f_cluster; /* */ + dmp->dm_flags.f_droot = fnp->f_flags.f_droot; + dmp->dm_flags.f_ddir = fnp->f_flags.f_ddir; + dmp->dm_flags.f_dmod = fnp->f_flags.f_dmod; + dmp->dm_flags.f_dnew = fnp->f_flags.f_dnew; + p = dmp->dm_name; + if (fnp->f_dir.dir_name[0] == '.') + { + for (idx = 0, q = (BYTE FAR *) fnp->f_dir.dir_name; + idx < FNAME_SIZE; idx++) + { + if (*q == ' ') + break; + *p++ = *q++; + } + } + else + { + for (idx = 0, q = (BYTE FAR *) fnp->f_dir.dir_name; + idx < FNAME_SIZE; idx++) + { + if (*q == ' ') + break; + *p++ = *q++; + } + if (fnp->f_dir.dir_ext[0] != ' ') + { + *p++ = '.'; + for (idx = 0, q = (BYTE FAR *) fnp->f_dir.dir_ext; idx < FEXT_SIZE; idx++) + { + if (*q == ' ') + break; + *p++ = *q++; + } + } + } + *p++ = NULL; +} +#endif + diff --git a/kernel/fatfs.c b/kernel/fatfs.c new file mode 100644 index 00000000..e938f022 --- /dev/null +++ b/kernel/fatfs.c @@ -0,0 +1,2117 @@ +/****************************************************************/ +/* */ +/* fatfs.c */ +/* DOS-C */ +/* */ +/* FAT File System I/O Functions */ +/* */ +/* Copyright (c) 1995,1998 */ +/* Pasquale J. Villani */ +/* All Rights Reserved */ +/* */ +/* This file is part of DOS-C. */ +/* */ +/* DOS-C is free software; you can redistribute it and/or */ +/* modify it under the terms of the GNU General Public License */ +/* as published by the Free Software Foundation; either version */ +/* 2, or (at your option) any later version. */ +/* */ +/* DOS-C is distributed in the hope that it will be useful, but */ +/* WITHOUT ANY WARRANTY; without even the implied warranty of */ +/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See */ +/* the GNU General Public License for more details. */ +/* */ +/* You should have received a copy of the GNU General Public */ +/* License along with DOS-C; see the file COPYING. If not, */ +/* write to the Free Software Foundation, 675 Mass Ave, */ +/* Cambridge, MA 02139, USA. */ +/****************************************************************/ + +#include "portab.h" +#include "globals.h" + +#ifdef VERSION_STRINGS +BYTE *RcsId = "$Id$"; +#endif + +/* + * $Log$ + * Revision 1.1 2000/05/06 19:35:09 jhall1 + * Initial revision + * + * Revision 1.16 2000/03/09 06:07:11 kernel + * 2017f updates by James Tabor + * + * Revision 1.15 1999/09/23 04:40:46 jprice + * *** empty log message *** + * + * Revision 1.12 1999/09/14 01:01:54 jprice + * Fixed bug where you could write over directories. + * + * Revision 1.11 1999/08/25 03:18:08 jprice + * ror4 patches to allow TC 2.01 compile. + * + * Revision 1.10 1999/08/10 18:03:42 jprice + * ror4 2011-03 patch + * + * Revision 1.9 1999/05/03 06:25:45 jprice + * Patches from ror4 and many changed of signed to unsigned variables. + * + * Revision 1.8 1999/05/03 05:00:24 jprice + * Fixed bug in map_cluster function + * + * Revision 1.7 1999/04/16 00:53:33 jprice + * Optimized FAT handling + * + * Revision 1.6 1999/04/12 23:41:54 jprice + * Using getbuf to write data instead of getblock + * using getblock made it read the block before it wrote it + * + * Revision 1.5 1999/04/12 03:21:17 jprice + * more ror4 patches. Changes for multi-block IO + * + * Revision 1.4 1999/04/11 04:33:38 jprice + * ror4 patches + * + * Revision 1.2 1999/04/04 18:51:43 jprice + * no message + * + * Revision 1.1.1.1 1999/03/29 15:42:07 jprice + * New version without IPL.SYS + * + * Revision 1.8 1999/03/23 23:37:39 jprice + * Fixed mkdir DOS function so it will create a directory with same name as the volument label + * + * Revision 1.7 1999/03/02 07:00:51 jprice + * Fixed bugs with dos set attribute function. Now returns correct + * error code, and errors if user tries to set bits 6 & 7. + * + * Revision 1.6 1999/02/09 02:54:23 jprice + * Added Pat's 1937 kernel patches + * + * Revision 1.5 1999/02/04 03:18:37 jprice + * Formating. Added comments. + * + * Revision 1.4 1999/02/01 01:43:28 jprice + * Fixed findfirst function to find volume label with Windows long filenames + * + * Revision 1.3 1999/01/30 08:25:34 jprice + * Clean up; Fixed bug with set attribute function. If you tried to + * change the attributes of a directory, it would erase it. + * + * Revision 1.2 1999/01/22 04:15:28 jprice + * Formating + * + * Revision 1.1.1.1 1999/01/20 05:51:00 jprice + * Imported sources + * + * + * Rev 1.14 06 Dec 1998 8:44:26 patv + * Bug fixes. + * + * Rev 1.13 09 Feb 1998 5:43:30 patv + * Eliminated FAT12 EOF and error useage. + * + * Rev 1.12 03 Feb 1998 11:28:04 patv + * Fixed lseek bug. + * + * Rev 1.11 22 Jan 1998 5:38:08 patv + * Corrected remaining file name and extension copies that did not + * account for far file nodes due to allocated FILES= spec. + * + * Rev 1.10 22 Jan 1998 4:09:00 patv + * Fixed pointer problems affecting SDA + * + * Rev 1.9 04 Jan 1998 23:14:40 patv + * Changed Log for strip utility + * + * Rev 1.8 04 Jan 1998 17:24:14 patv + * Corrected subdirectory bug + * + * Rev 1.7 03 Jan 1998 8:36:04 patv + * Converted data area to SDA format + * + * Rev 1.6 22 Jan 1997 13:00:30 patv + * pre-0.92 bug fixes + * + * Rev 1.5 16 Jan 1997 12:46:24 patv + * pre-Release 0.92 feature additions + * + * Rev 1.4 29 May 1996 21:15:16 patv + * bug fixes for v0.91a + * + * Rev 1.3 19 Feb 1996 3:20:10 patv + * Added NLS, int2f and config.sys processing + * + * Rev 1.2 01 Sep 1995 17:48:40 patv + * First GPL release. + * + * Rev 1.1 30 Jul 1995 20:50:24 patv + * Eliminated version strings in ipl + * + * Rev 1.0 02 Jul 1995 8:04:46 patv + * Initial revision. + */ + +/* */ +/* function prototypes */ +/* */ +struct f_node FAR *xlt_fd(COUNT); +COUNT xlt_fnp(struct f_node FAR *); +struct f_node FAR *split_path(BYTE FAR *, BYTE *, BYTE *, BYTE *); +BOOL find_fname(struct f_node FAR *, BYTE *, BYTE *); +date dos_getdate(VOID); +time dos_gettime(VOID); +BOOL find_free(struct f_node FAR *); +UWORD find_fat_free(struct f_node FAR *); +VOID wipe_out(struct f_node FAR *); +BOOL last_link(struct f_node FAR *); +BOOL extend(struct f_node FAR *); +COUNT extend_dir(struct f_node FAR *); +BOOL first_fat(struct f_node FAR *); +COUNT map_cluster(struct f_node FAR *, COUNT); + +/************************************************************************/ +/* */ +/* Internal file handlers - open, create, read, write, close, etc. */ +/* */ +/************************************************************************/ + +/* Open a file given the path. Flags is 0 for read, 1 for write and 2 */ +/* for update. */ +/* Returns an integer file desriptor or a negative error code */ + +COUNT dos_open(BYTE FAR * path, COUNT flag) +{ + REG struct f_node FAR *fnp; + COUNT i; + BYTE FAR *fnamep; + + /* First test the flag to see if the user has passed a valid */ + /* file mode... */ + if (flag < 0 || flag > 2) + return DE_INVLDACC; + + /* first split the passed dir into comopnents (i.e. - path to */ + /* new directory and name of new directory. */ + if ((fnp = split_path(path, szDirName, szFileName, szFileExt)) == NULL) + { + dir_close(fnp); + return DE_PATHNOTFND; + } + + /* Look for the file. If we can't find it, just return a not */ + /* found error. */ + if (!find_fname(fnp, szFileName, szFileExt)) + { + dir_close(fnp); + return DE_FILENOTFND; + } + + /* Set the fnode to the desired mode */ + fnp->f_mode = flag; + + /* Initialize the rest of the fnode. */ + fnp->f_offset = 0l; + fnp->f_highwater = fnp->f_dir.dir_size; + + fnp->f_back = LONG_LAST_CLUSTER; + fnp->f_cluster = fnp->f_dir.dir_start; + fnp->f_cluster_offset = 0l; /*JPP */ + + fnp->f_flags.f_dmod = FALSE; + fnp->f_flags.f_dnew = FALSE; + fnp->f_flags.f_ddir = FALSE; + + return xlt_fnp(fnp); +} + +COUNT FAR init_call_dos_open(BYTE FAR * path, COUNT flag) +{ + return dos_open(path, flag); +} + +BOOL fcmp(BYTE FAR * s1, BYTE FAR * s2, COUNT n) +{ + while (n--) + if (*s1++ != *s2++) + return FALSE; + return TRUE; +} + +BOOL fcmp_wild(BYTE FAR * s1, BYTE FAR * s2, COUNT n) +{ + while (n--) + { + if (*s1 == '?') + { + ++s1, ++s2; + continue; + } + if (*s1++ != *s2++) + return FALSE; + } + return TRUE; +} + +COUNT dos_close(COUNT fd) +{ + struct f_node FAR *fnp; + + /* Translate the fd into a useful pointer */ + fnp = xlt_fd(fd); + + /* If the fd was invalid because it was out of range or the */ + /* requested file was not open, tell the caller and exit */ + /* note: an invalid fd is indicated by a 0 return */ + if (fnp == (struct f_node FAR *)0 || fnp->f_count <= 0) + return DE_INVLDHNDL; + + if (fnp->f_mode != RDONLY) + { + fnp->f_dir.dir_size = fnp->f_highwater; + fnp->f_flags.f_dmod = TRUE; + } + fnp->f_flags.f_ddir = TRUE; + + dir_close(fnp); + return SUCCESS; +} + +COUNT FAR init_call_dos_close(COUNT fd) +{ + return dos_close(fd); +} + +/* */ +/* split a path into it's component directory and file name */ +/* */ +static struct f_node FAR * + split_path(BYTE FAR * path, BYTE * dname, BYTE * fname, BYTE * fext) +{ + REG struct f_node FAR *fnp; + COUNT nDrive; + struct cds FAR *cdsp; + + /* Start off by parsing out the components. */ + if (ParseDosName(adjust_far(path), &nDrive, &dname[2], fname, fext, FALSE) + != SUCCESS) + return (struct f_node FAR *)0; + if (nDrive < 0) + nDrive = default_drive; + + dname[0] = 'A' + nDrive; + dname[1] = ':'; + + /* Add trailing spaces to the file name and extension */ + SpacePad(fname, FNAME_SIZE); + SpacePad(fext, FEXT_SIZE); + + cdsp = &CDSp->cds_table[nDrive]; + + /* If the path is null, we to default to the current */ + /* directory... */ + if (!dname[2]) + { + fsncopy(cdsp->cdsCurrentPath, (BYTE FAR *) dname, PARSE_MAX); + } + +/* 11/29/99 jt + * Networking and Cdroms. You can put in here a return. + * Maybe a return of 0xDEADBEEF or something for Split or Dir_open. + * Just to let upper level Fdos know its a sft, CDS function. + * Right now for Networking there is no support for Rename, MkDir + * RmDir & Delete. + + + + */ + + /* Translate the path into a useful pointer */ + fnp = dir_open((BYTE FAR *) dname); + + /* If the fd was invalid because it was out of range or the */ + /* requested file was not open, tell the caller and exit... */ + /* note: an invalid fd is indicated by a 0 return */ + if (fnp == (struct f_node FAR *)0 || fnp->f_count <= 0) + { + dir_close(fnp); + return (struct f_node FAR *)0; + } + + /* Convert the name into an absolute name for comparison... */ + upMem((BYTE FAR *) dname, strlen(dname)); + upMem((BYTE FAR *) fname, FNAME_SIZE); + upMem((BYTE FAR *) fext, FEXT_SIZE); + + return fnp; +} + +static BOOL find_fname(struct f_node FAR * fnp, BYTE * fname, BYTE * fext) +{ + BOOL found = FALSE; + + while (dir_read(fnp) == DIRENT_SIZE) + { + if (fnp->f_dir.dir_name[0] != '\0') + { + if (fnp->f_dir.dir_name[0] == DELETED) + continue; + + if (fcmp((BYTE FAR *) fname, (BYTE FAR *) fnp->f_dir.dir_name, FNAME_SIZE) + && fcmp((BYTE FAR *) fext, (BYTE FAR *) fnp->f_dir.dir_ext, FEXT_SIZE) + && ((fnp->f_dir.dir_attrib & D_VOLID) == 0)) + { + found = TRUE; + break; + } + } + } + return found; +} + +COUNT dos_creat(BYTE FAR * path, COUNT attrib) +{ + REG struct f_node FAR *fnp; + + /* first split the passed dir into comopnents (i.e. - */ + /* path to new directory and name of new directory */ + if ((fnp = split_path(path, szDirName, szFileName, szFileExt)) == NULL) + { + dir_close(fnp); + return DE_PATHNOTFND; + } + + /* Check that we don't have a duplicate name, so if we */ + /* find one, truncate it. */ + if (find_fname(fnp, szFileName, szFileExt)) + { + /* The only permissable attribute is archive, */ + /* check for any other bit set. If it is, give */ + /* an access error. */ + if ((fnp->f_dir.dir_attrib & (D_RDONLY | D_DIR | D_VOLID)) + || (fnp->f_dir.dir_attrib & ~D_ARCHIVE & ~attrib)) + { + dir_close(fnp); + return DE_ACCESS; + } + + /* Release the existing files FAT and set the */ + /* length to zero, effectively truncating the */ + /* file to zero. */ + wipe_out(fnp); + } + else + { + BOOL is_free; + REG COUNT idx; + struct buffer FAR *bp; + BYTE FAR *p; + + /* Reset the directory by a close followed by */ + /* an open */ + fnp->f_flags.f_dmod = FALSE; + dir_close(fnp); + fnp = dir_open((BYTE FAR *) szDirName); + + /* Get a free f_node pointer so that we can use */ + /* it in building the new file. */ + /* Note that if we're in the root and we don't */ + /* find an empty slot, we need to abort. */ + if (!(is_free = find_free(fnp)) && (fnp->f_flags.f_droot)) + { + fnp->f_flags.f_dmod = FALSE; + dir_close(fnp); + return DE_TOOMANY; + } + + /* Otherwise just expand the directory */ + else if (!is_free && !(fnp->f_flags.f_droot)) + { + COUNT ret; + + if ((ret = extend_dir(fnp)) != SUCCESS) + return ret; + } + + /* put the fnode's name into the directory. */ + fbcopy((BYTE FAR *) szFileName, + (BYTE FAR *) fnp->f_dir.dir_name, FNAME_SIZE); + fbcopy((BYTE FAR *) szFileExt, + (BYTE FAR *) fnp->f_dir.dir_ext, FEXT_SIZE); + } + /* Set the fnode to the desired mode */ + /* Updating the directory entry first. */ + fnp->f_mode = RDWR; + + fnp->f_dir.dir_size = 0l; + fnp->f_dir.dir_start = FREE; + fnp->f_dir.dir_attrib = attrib | D_ARCHIVE; + fnp->f_dir.dir_time = dos_gettime(); + fnp->f_dir.dir_date = dos_getdate(); + + fnp->f_flags.f_dmod = TRUE; + fnp->f_flags.f_dnew = FALSE; + fnp->f_flags.f_ddir = TRUE; + if (dir_write(fnp) != DIRENT_SIZE) + { + release_f_node(fnp); + return DE_ACCESS; + } + + /* Now change to file */ + fnp->f_offset = 0l; + fnp->f_highwater = 0l; + + fnp->f_back = LONG_LAST_CLUSTER; + fnp->f_cluster = fnp->f_dir.dir_start = FREE; + fnp->f_cluster_offset = 0l; /*JPP */ + fnp->f_flags.f_dmod = TRUE; + fnp->f_flags.f_dnew = FALSE; + fnp->f_flags.f_ddir = FALSE; + + return xlt_fnp(fnp); +} + +COUNT dos_delete(BYTE FAR * path) +{ + REG struct f_node FAR *fnp; + + /* first split the passed dir into components (i.e. - */ + /* path to new directory and name of new directory */ + if ((fnp = split_path(path, szDirName, szFileName, szFileExt)) == NULL) + { + dir_close(fnp); + return DE_PATHNOTFND; + } + + /* Check that we don't have a duplicate name, so if we */ + /* find one, it's an error. */ + if (find_fname(fnp, szFileName, szFileExt)) + { + /* The only permissable attribute is archive, */ + /* check for any other bit set. If it is, give */ + /* an access error. */ + if (fnp->f_dir.dir_attrib & ~D_ARCHIVE) + { + dir_close(fnp); + return DE_ACCESS; + } + + /* Ok, so we can delete. Start out by */ + /* clobbering all FAT entries for this file */ + /* (or, in English, truncate the FAT). */ + wipe_out(fnp); + fnp->f_dir.dir_size = 0l; + *(fnp->f_dir.dir_name) = DELETED; + + /* The directory has been modified, so set the */ + /* bit before closing it, allowing it to be */ + /* updated */ + fnp->f_flags.f_dmod = TRUE; + dir_close(fnp); + + /* SUCCESSful completion, return it */ + return SUCCESS; + } + else + { + /* No such file, return the error */ + dir_close(fnp); + return DE_FILENOTFND; + } +} + +COUNT dos_rmdir(BYTE FAR * path) +{ + REG struct f_node FAR *fnp; + REG struct f_node FAR *fnp1; + BOOL found; + + /* first split the passed dir into comopnents (i.e. - */ + /* path to new directory and name of new directory */ + if ((fnp = split_path(path, szDirName, szFileName, szFileExt)) == NULL) + { + dir_close(fnp); + return DE_PATHNOTFND; + } + + /* Check that we're not trying to remove the root! */ + if ((path[0] == '\\') && (path[1] == NULL)) + { + dir_close(fnp); + return DE_ACCESS; + } + + /* Check that we don't have a duplicate name, so if we */ + /* find one, it's an error. */ + if (find_fname(fnp, szFileName, szFileExt)) + { + /* The only permissable attribute is directory, */ + /* check for any other bit set. If it is, give */ + /* an access error. */ + if (fnp->f_dir.dir_attrib & ~D_DIR) + { + dir_close(fnp); + return DE_ACCESS; + } + + /* Check that the directory is empty. Only the */ + /* "." and ".." are permissable. */ + fnp->f_flags.f_dmod = FALSE; + fnp1 = dir_open((BYTE FAR *) path); + dir_read(fnp1); + if (fnp1->f_dir.dir_name[0] != '.') + { + dir_close(fnp); + return DE_ACCESS; + } + + dir_read(fnp1); + if (fnp1->f_dir.dir_name[0] != '.') + { + dir_close(fnp); + return DE_ACCESS; + } + + /* Now search through the directory and make certain */ + /* that there are no entries. */ + found = FALSE; + while (dir_read(fnp1) == DIRENT_SIZE) + { + if (fnp1->f_dir.dir_name[0] == '\0') + break; + if (fnp1->f_dir.dir_name[0] == DELETED) + continue; + else + { + found = TRUE; + break; + } + } + + dir_close(fnp1); + /* If anything was found, exit with an error. */ + if (found) + { + dir_close(fnp); + return DE_ACCESS; + } + + /* Ok, so we can delete. Start out by */ + /* clobbering all FAT entries for this file */ + /* (or, in English, truncate the FAT). */ + wipe_out(fnp); + fnp->f_dir.dir_size = 0l; + *(fnp->f_dir.dir_name) = DELETED; + + /* The directory has been modified, so set the */ + /* bit before closing it, allowing it to be */ + /* updated */ + fnp->f_flags.f_dmod = TRUE; + dir_close(fnp); + + /* SUCCESSful completion, return it */ + return SUCCESS; + } + else + { + /* No such file, return the error */ + dir_close(fnp); + return DE_FILENOTFND; + } +} + +COUNT dos_rename(BYTE FAR * path1, BYTE FAR * path2) +{ + REG struct f_node FAR *fnp1; + REG struct f_node FAR *fnp2; + BOOL is_free; + + /* first split the passed target into compnents (i.e. - path to */ + /* new file name and name of new file name */ + if ((fnp2 = split_path(path2, szSecDirName, szSecFileName, szSecFileExt)) == NULL) + { + dir_close(fnp2); + return DE_PATHNOTFND; + } + + /* Check that we don't have a duplicate name, so if we find */ + /* one, it's an error. */ + if (find_fname(fnp2, szSecFileName, szSecFileExt)) + { + dir_close(fnp2); + return DE_ACCESS; + } + + /* next split the passed source into compnents (i.e. - path to */ + /* old file name and name of old file name */ + if ((fnp1 = split_path(path1, szPriDirName, szPriFileName, szPriFileExt)) == NULL) + { + dir_close(fnp1); + dir_close(fnp2); + return DE_PATHNOTFND; + } + + /* Reset the directory by a close followed by an open */ + fnp2->f_flags.f_dmod = FALSE; + dir_close(fnp2); + fnp2 = dir_open((BYTE FAR *) szSecDirName); + + /* Now find a free slot to put the file into. */ + /* If it's the root and we don't have room, return an error. */ + if (!(is_free = find_free(fnp2)) && (fnp2->f_flags.f_droot)) + { + fnp2->f_flags.f_dmod = FALSE; + dir_close(fnp1); + dir_close(fnp2); + return DE_TOOMANY; + } + + /* Otherwise just expand the directory */ + else if (!is_free && !(fnp2->f_flags.f_droot)) + { + COUNT ret; + + if ((ret = extend_dir(fnp2)) != SUCCESS) + return ret; + } + + if (!find_fname(fnp1, szPriFileName, szPriFileExt)) + { + /* No such file, return the error */ + dir_close(fnp1); + dir_close(fnp2); + return DE_FILENOTFND; + } + + /* put the fnode's name into the directory. */ + fbcopy((BYTE FAR *) szSecFileName, + (BYTE FAR *) fnp2->f_dir.dir_name, FNAME_SIZE); + fbcopy((BYTE FAR *) szSecFileExt, + (BYTE FAR *) fnp2->f_dir.dir_ext, FEXT_SIZE); + + /* Set the fnode to the desired mode */ + fnp2->f_dir.dir_size = fnp1->f_dir.dir_size; + fnp2->f_dir.dir_start = fnp1->f_dir.dir_start; + fnp2->f_dir.dir_attrib = fnp1->f_dir.dir_attrib; + fnp2->f_dir.dir_time = fnp1->f_dir.dir_time; + fnp2->f_dir.dir_date = fnp1->f_dir.dir_date; + + /* The directory has been modified, so set the bit before */ + /* closing it, allowing it to be updated. */ + fnp1->f_flags.f_dmod = fnp2->f_flags.f_dmod = TRUE; + fnp1->f_flags.f_dnew = fnp2->f_flags.f_dnew = FALSE; + fnp1->f_flags.f_ddir = fnp2->f_flags.f_ddir = TRUE; + + fnp2->f_highwater = fnp2->f_offset = fnp1->f_dir.dir_size; + + /* Ok, so we can delete this one. Save the file info. */ + fnp1->f_dir.dir_size = 0l; + *(fnp1->f_dir.dir_name) = DELETED; + + dir_close(fnp1); + dir_close(fnp2); + + /* SUCCESSful completion, return it */ + return SUCCESS; +} + +/* */ +/* wipe out all FAT entries for create, delete, etc. */ +/* */ +static VOID wipe_out(struct f_node FAR * fnp) +{ + REG UWORD st, + next; + struct dpb *dpbp = fnp->f_dpb; + + /* if already free or not valid file, just exit */ + if ((fnp == NULL) || (fnp->f_dir.dir_start == FREE)) + return; + + /* if there are no FAT entries, just exit */ + if (fnp->f_dir.dir_start == FREE) + return; + + /* Loop from start until either a FREE entry is */ + /* encountered (due to a fractured file system) of the */ + /* last cluster is encountered. */ + for (st = fnp->f_dir.dir_start; + st != LONG_LAST_CLUSTER;) + { + /* get the next cluster pointed to */ + next = next_cluster(dpbp, st); + + /* just exit if a damaged file system exists */ + if (next == FREE) + return; + + /* zap the FAT pointed to */ + link_fat(dpbp, st, FREE); + + /* and the start of free space pointer */ + if ((dpbp->dpb_cluster == UNKNCLUSTER) + || (dpbp->dpb_cluster > st)) + dpbp->dpb_cluster = st; + + /* and just follow the linked list */ + st = next; + } +} + +static BOOL find_free(struct f_node FAR * fnp) +{ + while (dir_read(fnp) == DIRENT_SIZE) + { + if (fnp->f_dir.dir_name[0] == '\0' + || fnp->f_dir.dir_name[0] == DELETED) + { + return TRUE; + } + } + return !fnp->f_flags.f_dfull; +} + +/* */ +/* dos_getdate for the file date */ +/* */ +date dos_getdate() +{ +#ifndef NOTIME + BYTE WeekDay, + Month, + MonthDay; + COUNT Year; + date Date; + + /* First - get the system date set by either the user */ + /* on start-up or the CMOS clock */ + DosGetDate((BYTE FAR *) & WeekDay, + (BYTE FAR *) & Month, + (BYTE FAR *) & MonthDay, + (COUNT FAR *) & Year); + Date = DT_ENCODE(Month, MonthDay, Year - EPOCH_YEAR); + return Date; + +#else + + return 0; + +#endif +} + +date FAR init_call_dos_getdate() +{ + return dos_getdate(); +} + +/* */ +/* dos_gettime for the file time */ +/* */ +time dos_gettime() +{ +#ifndef NOTIME + BYTE Hour, + Minute, + Second, + Hundredth; + time Time; + BYTE h; + + /* First - get the system time set by either the user */ + /* on start-up or the CMOS clock */ + DosGetTime((BYTE FAR *) & Hour, + (BYTE FAR *) & Minute, + (BYTE FAR *) & Second, + (BYTE FAR *) & Hundredth); + h = Second * 10 + ((Hundredth + 5) / 10); + Time = TM_ENCODE(Hour, Minute, h); + return Time; +#else + return 0; +#endif +} + +time FAR init_call_dos_gettime() +{ + return dos_gettime(); +} + +/* */ +/* dos_getftime for the file time */ +/* */ +COUNT dos_getftime(COUNT fd, date FAR * dp, time FAR * tp) +{ + struct f_node FAR *fnp; + + /* Translate the fd into an fnode pointer, since all internal */ + /* operations are achieved through fnodes. */ + fnp = xlt_fd(fd); + + /* If the fd was invalid because it was out of range or the */ + /* requested file was not open, tell the caller and exit */ + /* note: an invalid fd is indicated by a 0 return */ + if (fnp == (struct f_node FAR *)0 || fnp->f_count <= 0) + return DE_INVLDHNDL; + + /* Get the date and time from the fnode and return */ + *dp = fnp->f_dir.dir_date; + *tp = fnp->f_dir.dir_time; + + return SUCCESS; +} + +/* */ +/* dos_setftime for the file time */ +/* */ +COUNT dos_setftime(COUNT fd, date FAR * dp, time FAR * tp) +{ + struct f_node FAR *fnp; + + /* Translate the fd into an fnode pointer, since all internal */ + /* operations are achieved through fnodes. */ + fnp = xlt_fd(fd); + + /* If the fd was invalid because it was out of range or the */ + /* requested file was not open, tell the caller and exit */ + /* note: an invalid fd is indicated by a 0 return */ + if (fnp == (struct f_node FAR *)0 || fnp->f_count <= 0) + return DE_INVLDHNDL; + + /* Set the date and time from the fnode and return */ + fnp->f_dir.dir_date = *dp; + fnp->f_dir.dir_time = *tp; + + return SUCCESS; +} + +/* */ +/* dos_getfsize for the file time */ +/* */ +LONG dos_getcufsize(COUNT fd) +{ + struct f_node FAR *fnp; + + /* Translate the fd into an fnode pointer, since all internal */ + /* operations are achieved through fnodes. */ + fnp = xlt_fd(fd); + + /* If the fd was invalid because it was out of range or the */ + /* requested file was not open, tell the caller and exit */ + /* note: an invalid fd is indicated by a 0 return */ + if (fnp == (struct f_node FAR *)0 || fnp->f_count <= 0) + return -1l; + + /* Return the file size */ + return fnp->f_highwater; +} + +/* */ +/* dos_getfsize for the file time */ +/* */ +LONG dos_getfsize(COUNT fd) +{ + struct f_node FAR *fnp; + + /* Translate the fd into an fnode pointer, since all internal */ + /* operations are achieved through fnodes. */ + fnp = xlt_fd(fd); + + /* If the fd was invalid because it was out of range or the */ + /* requested file was not open, tell the caller and exit */ + /* note: an invalid fd is indicated by a 0 return */ + if (fnp == (struct f_node FAR *)0 || fnp->f_count <= 0) + return -1l; + + /* Return the file size */ + return fnp->f_dir.dir_size; +} + +/* */ +/* dos_setfsize for the file time */ +/* */ +BOOL dos_setfsize(COUNT fd, LONG size) +{ + struct f_node FAR *fnp; + + /* Translate the fd into an fnode pointer, since all internal */ + /* operations are achieved through fnodes. */ + fnp = xlt_fd(fd); + + /* If the fd was invalid because it was out of range or the */ + /* requested file was not open, tell the caller and exit */ + /* note: an invalid fd is indicated by a 0 return */ + if (fnp == (struct f_node FAR *)0 || fnp->f_count <= 0) + return FALSE; + + /* Change the file size */ + fnp->f_dir.dir_size = size; + fnp->f_highwater = size; + return TRUE; +} + +/* */ +/* Find free cluster in disk FAT table */ +/* */ +static UWORD find_fat_free(struct f_node FAR * fnp) +{ + REG UWORD idx; + +#ifdef DISPLAY_GETBLOCK + printf("[find_fat_free]\n"); +#endif + /* Start from optimized lookup point for start of FAT */ + if (fnp->f_dpb->dpb_cluster != UNKNCLUSTER) + idx = fnp->f_dpb->dpb_cluster; + else + idx = 2; + + /* Search the FAT table looking for the first free */ + /* entry. */ + for (; idx < fnp->f_dpb->dpb_size; idx++) + { + if (next_cluster(fnp->f_dpb, idx) == FREE) + break; + } + + /* No empty clusters, disk is FULL! */ + if (idx >= fnp->f_dpb->dpb_size) + { + fnp->f_dpb->dpb_cluster = UNKNCLUSTER; + dir_close(fnp); + return LONG_LAST_CLUSTER; + } + + /* return the free entry */ + fnp->f_dpb->dpb_cluster = idx; + return idx; +} + +/* */ +/* crate a directory - returns success or a negative error */ +/* number */ +/* */ +COUNT dos_mkdir(BYTE FAR * dir) +{ + REG struct f_node FAR *fnp; + REG COUNT idx; + struct buffer FAR *bp; + BYTE FAR *p; + UWORD free_fat; + UWORD parent; + + /* first split the passed dir into comopnents (i.e. - */ + /* path to new directory and name of new directory */ + if ((fnp = split_path(dir, szDirName, szFileName, szFileExt)) == NULL) + { + dir_close(fnp); + return DE_PATHNOTFND; + } + + /* Check that we don't have a duplicate name, so if we */ + /* find one, it's an error. */ + if (find_fname(fnp, szFileName, szFileExt)) + { + dir_close(fnp); + return DE_ACCESS; + } + else + { + BOOL is_free; + + /* Reset the directory by a close followed by */ + /* an open */ + fnp->f_flags.f_dmod = FALSE; + parent = fnp->f_dirstart; + dir_close(fnp); + fnp = dir_open((BYTE FAR *) szDirName); + + /* Get a free f_node pointer so that we can use */ + /* it in building the new file. */ + /* Note that if we're in the root and we don't */ + /* find an empty slot, we need to abort. */ + if (!(is_free = find_free(fnp)) && (fnp->f_flags.f_droot)) + { + fnp->f_flags.f_dmod = FALSE; + dir_close(fnp); + return DE_TOOMANY; + } + + /* Otherwise just expand the directory */ + else if (!is_free && !(fnp->f_flags.f_droot)) + { + COUNT ret; + + if ((ret = extend_dir(fnp)) != SUCCESS) + return ret; + } + + /* put the fnode's name into the directory. */ + fbcopy((BYTE FAR *) szFileName, + (BYTE FAR *) fnp->f_dir.dir_name, FNAME_SIZE); + fbcopy((BYTE FAR *) szFileExt, + (BYTE FAR *) fnp->f_dir.dir_ext, FEXT_SIZE); + + /* Set the fnode to the desired mode */ + fnp->f_mode = WRONLY; + fnp->f_back = LONG_LAST_CLUSTER; + + fnp->f_dir.dir_size = 0l; + fnp->f_dir.dir_start = FREE; + fnp->f_dir.dir_attrib = D_DIR; + fnp->f_dir.dir_time = dos_gettime(); + fnp->f_dir.dir_date = dos_getdate(); + + fnp->f_flags.f_dmod = TRUE; + fnp->f_flags.f_dnew = FALSE; + fnp->f_flags.f_ddir = TRUE; + + fnp->f_highwater = 0l; + fnp->f_offset = 0l; + } + + /* get an empty cluster, so that we make it into a */ + /* directory. */ + free_fat = find_fat_free(fnp); + + /* No empty clusters, disk is FULL! Translate into a */ + /* useful error message. */ + if (free_fat == LONG_LAST_CLUSTER) + { + dir_close(fnp); + return DE_HNDLDSKFULL; + } + + /* Mark the cluster in the FAT as used */ + fnp->f_dir.dir_start = fnp->f_cluster = free_fat; + link_fat(fnp->f_dpb, (UCOUNT) free_fat, LONG_LAST_CLUSTER); + + /* Craft the new directory. Note that if we're in a new */ + /* directory just under the root, ".." pointer is 0. */ + bp = getblock((ULONG) clus2phys(free_fat, + (fnp->f_dpb->dpb_clsmask + 1), + fnp->f_dpb->dpb_data), + fnp->f_dpb->dpb_unit); +#ifdef DISPLAY_GETBLOCK + printf("FAT (dos_mkdir)\n"); +#endif + if (bp == NULL) + { + dir_close(fnp); + return DE_BLKINVLD; + } + + /* Create the "." entry */ + bcopy(". ", (BYTE *) DirEntBuffer.dir_name, FNAME_SIZE); + bcopy(" ", (BYTE *) DirEntBuffer.dir_ext, FEXT_SIZE); + DirEntBuffer.dir_attrib = D_DIR; + DirEntBuffer.dir_time = dos_gettime(); + DirEntBuffer.dir_date = dos_getdate(); + DirEntBuffer.dir_start = free_fat; + DirEntBuffer.dir_size = 0l; + + /* And put it out */ + putdirent((struct dirent FAR *)&DirEntBuffer, (BYTE FAR *) bp->b_buffer); + + /* create the ".." entry */ + bcopy(".. ", (BYTE *) DirEntBuffer.dir_name, FNAME_SIZE); + DirEntBuffer.dir_start = parent; + + /* and put it out */ + putdirent((struct dirent FAR *)&DirEntBuffer, (BYTE FAR *) & bp->b_buffer[DIRENT_SIZE]); + + /* fill the rest of the block with zeros */ + for (p = (BYTE FAR *) & bp->b_buffer[2 * DIRENT_SIZE]; + p < &bp->b_buffer[BUFFERSIZE];) + *p++ = NULL; + + /* Mark the block to be written out */ + bp->b_flag |= BFR_DIRTY; + + /* clear out the rest of the blocks in the cluster */ + for (idx = 1; idx < (fnp->f_dpb->dpb_clsmask + 1); idx++) + { + REG COUNT i; + + bp = getblock((ULONG) clus2phys(fnp->f_dir.dir_start, + (fnp->f_dpb->dpb_clsmask + 1), + fnp->f_dpb->dpb_data) + idx, + fnp->f_dpb->dpb_unit); +#ifdef DISPLAY_GETBLOCK + printf("DIR (dos_mkdir)\n"); +#endif + if (bp == NULL) + { + dir_close(fnp); + return DE_BLKINVLD; + } + for (i = 0, p = (BYTE FAR *) bp->b_buffer; i < BUFFERSIZE; i++) + *p++ = NULL; + bp->b_flag |= BFR_DIRTY; + } + + /* flush the drive buffers so that all info is written */ + flush_buffers((COUNT) (fnp->f_dpb->dpb_unit)); + + /* Close the directory so that the entry is updated */ + fnp->f_flags.f_dmod = TRUE; + dir_close(fnp); + + return SUCCESS; +} + +BOOL last_link(struct f_node FAR * fnp) +{ + return (((UWORD) fnp->f_cluster == (UWORD) LONG_LAST_CLUSTER)); +} + +static BOOL extend(struct f_node FAR * fnp) +{ + UWORD free_fat; + +#ifdef DISPLAY_GETBLOCK + printf("extend\n"); +#endif + /* get an empty cluster, so that we use it to extend the file. */ + free_fat = find_fat_free(fnp); + + /* No empty clusters, disk is FULL! Translate into a useful */ + /* error message. */ + if (free_fat == LONG_LAST_CLUSTER) + return FALSE; + + /* Now that we've found a free FAT entry, mark it as the last */ + /* entry and save. */ + link_fat(fnp->f_dpb, (UCOUNT) fnp->f_back, free_fat); + fnp->f_cluster = free_fat; + link_fat(fnp->f_dpb, (UCOUNT) free_fat, LONG_LAST_CLUSTER); + + /* Mark the directory so that the entry is updated */ + fnp->f_flags.f_dmod = TRUE; + return TRUE; +} + +static COUNT extend_dir(struct f_node FAR * fnp) +{ + REG COUNT idx; + + if (!extend(fnp)) + { + dir_close(fnp); + return DE_HNDLDSKFULL; + } + + /* clear out the rest of the blocks in the cluster */ + for (idx = 0; idx < (fnp->f_dpb->dpb_clsmask + 1); idx++) + { + REG COUNT i; + REG BYTE FAR *p; + REG struct buffer FAR *bp; + + bp = getblock((ULONG) clus2phys(fnp->f_cluster, + (fnp->f_dpb->dpb_clsmask + 1), + fnp->f_dpb->dpb_data) + idx, + fnp->f_dpb->dpb_unit); +#ifdef DISPLAY_GETBLOCK + printf("DIR (extend_dir)\n"); +#endif + if (bp == NULL) + { + dir_close(fnp); + return DE_BLKINVLD; + } + for (i = 0, p = (BYTE FAR *) bp->b_buffer; i < BUFFERSIZE; i++) + *p++ = NULL; + bp->b_flag |= BFR_DIRTY; + } + + if (!find_free(fnp)) + { + dir_close(fnp); + return DE_HNDLDSKFULL; + } + + /* flush the drive buffers so that all info is written */ + flush_buffers((COUNT) (fnp->f_dpb->dpb_unit)); + + return SUCCESS; + +} + +/* JPP: finds the next free cluster in the FAT */ +static BOOL first_fat(struct f_node FAR * fnp) +{ + UWORD free_fat; + + /* get an empty cluster, so that we make it into a file. */ + free_fat = find_fat_free(fnp); + + /* No empty clusters, disk is FULL! Translate into a useful */ + /* error message. */ + if (free_fat == LONG_LAST_CLUSTER) + return FALSE; + + /* Now that we've found a free FAT entry, mark it as the last */ + /* entry and save it. */ + fnp->f_dir.dir_start = free_fat; + link_fat(fnp->f_dpb, (UCOUNT) free_fat, LONG_LAST_CLUSTER); + + /* Mark the directory so that the entry is updated */ + fnp->f_flags.f_dmod = TRUE; + return TRUE; +} + +/* JPP: I think this starts at the beginning of a file, and follows + the fat chain to find the cluster that contains the data for the + file at f_offset. */ + +/* JPP: new map_cluster. If we are moving forward, then use the offset + that we are at now (f_cluster_offset) to start, instead of starting + at the beginning. */ +COUNT map_cluster(REG struct f_node FAR * fnp, COUNT mode) +{ + ULONG idx; + UWORD clssize; + UWORD secsize; + +#ifdef DISPLAY_GETBLOCK + printf("map_cluster: current %lu, offset %lu, diff=%lu ", + fnp->f_cluster_offset, fnp->f_offset, + fnp->f_offset - fnp->f_cluster_offset); +#endif + /* The variable clssize will be used later. */ + secsize = fnp->f_dpb->dpb_secsize; + clssize = secsize * (fnp->f_dpb->dpb_clsmask + 1); + + /* If someone did a seek, but no writes have occured, we will */ + /* need to initialize the fnode. */ + if ((mode == XFR_WRITE) && (fnp->f_dir.dir_start == FREE)) + { + /* If there are no more free fat entries, then we are full! */ + if (!first_fat(fnp)) + return DE_HNDLDSKFULL; + } + + if (fnp->f_offset >= fnp->f_cluster_offset) /*JPP */ + { + /* Set internal index and cluster size. */ + idx = fnp->f_offset - fnp->f_cluster_offset; + } + else + { + /* Set internal index and cluster size. */ + idx = fnp->f_offset; + + fnp->f_cluster = fnp->f_flags.f_ddir ? fnp->f_dirstart : + fnp->f_dir.dir_start; + fnp->f_cluster_offset = 0; + } + + /* Now begin the linear search. The relative cluster is */ + /* maintained as part of the set of physical indices. It is */ + /* also the highest order index and is mapped directly into */ + /* physical cluster. Our search is performed by pacing an index */ + /* up to the relative cluster position where the index falls */ + /* within the cluster. */ + /* */ + /* NOTE: make sure your compiler does not optimize for loop */ + /* tests to the loop exit. We need to fall out immediately for */ + /* files whose length < cluster size. */ + for (; idx >= clssize; idx -= clssize) + { + /* If this is a read and the next is a LAST_CLUSTER, */ + /* then we are going to read past EOF, return zero read */ + if ((mode == XFR_READ) && last_link(fnp)) + return DE_SEEK; +/* expand the list if we're going to write and have run into */ +/* the last cluster marker. */ + else if ((mode == XFR_WRITE) && last_link(fnp)) + { + + if (!extend(fnp)) + { + dir_close(fnp); + return DE_HNDLDSKFULL; + } + } + fnp->f_back = fnp->f_cluster; + + /* get next cluster in the chain */ + fnp->f_cluster = next_cluster(fnp->f_dpb, fnp->f_cluster); + fnp->f_cluster_offset += clssize; + } +#ifdef DISPLAY_GETBLOCK + printf("done.\n"); +#endif + + return SUCCESS; +} + +/* Read block from disk */ +UCOUNT readblock(COUNT fd, VOID FAR * buffer, UCOUNT count, COUNT * err) +{ + REG struct f_node FAR *fnp; + REG struct buffer FAR *bp; + UCOUNT xfr_cnt = 0; + UCOUNT ret_cnt = 0; + ULONG idx; + UWORD secsize; + UCOUNT to_xfer = count; + +#ifdef DEBUG + if (bDumpRdWrParms) + { + printf("readblock:\n"); + printf(" fd buffer count\n -- ------ -----\n"); + printf(" %02d %04x:%04x %d\n", + fd, (COUNT) FP_SEG(buffer), (COUNT) FP_OFF(buffer), count); + } +#endif + /* Translate the fd into an fnode pointer, since all internal */ + /* operations are achieved through fnodes. */ + fnp = xlt_fd(fd); + + /* If the fd was invalid because it was out of range or the */ + /* requested file was not open, tell the caller and exit */ + /* note: an invalid fd is indicated by a 0 return */ + if (fnp == (struct f_node FAR *)0 || fnp->f_count <= 0) + { + *err = DE_INVLDHNDL; + return 0; + } + + /* Test that we are really about to do a data transfer. If the + count is zero, just exit. (Any read with a count of zero is a nop). */ + + /* NOTE: doing this up front saves a lot of headaches later. */ + if (count == 0) + { + *err = SUCCESS; + return 0; + } + + /* Another test is to check for a seek past EOF */ + if (!fnp->f_flags.f_ddir && (fnp->f_offset >= fnp->f_dir.dir_size)) + { + *err = SUCCESS; + return 0; + } + + /* test that we have a valid mode for this fnode */ + if (fnp->f_mode != RDONLY && fnp->f_mode != RDWR) + { + *err = DE_INVLDACC; + return 0; + } + + /* The variable secsize will be used later. */ + secsize = fnp->f_dpb->dpb_secsize; + + /* Adjust the far pointer from user space to supervisor space */ + buffer = adjust_far((VOID FAR *) buffer); + + /* Do the data transfer. Use block transfer methods so that we */ + /* can utilize memory management in future DOS-C versions. */ + while (ret_cnt < count) + { + /* Position the file to the fnode's pointer position. This is */ + /* done by updating the fnode's cluster, block (sector) and */ + /* byte offset so that read becomes a simple data move */ + /* out of the block data buffer. */ + if (fnp->f_offset == 0l) + { + /* complete the common operations of */ + /* initializing to the starting cluster and */ + /* setting all offsets to zero. */ + fnp->f_cluster = fnp->f_flags.f_ddir ? fnp->f_dirstart : + fnp->f_dir.dir_start; + + fnp->f_cluster_offset = 0l; + fnp->f_back = LONG_LAST_CLUSTER; + fnp->f_sector = 0; + fnp->f_boff = 0; + } + /* The more difficult scenario is the (more common) */ + /* file offset case. Here, we need to take the fnode's */ + /* offset pointer (f_offset) and translate it into a */ + /* relative cluster position, cluster block (sector) */ + /* offset (f_sector) and byte offset (f_boff). Once we */ + /* have this information, we need to translate the */ + /* relative cluster position into an absolute cluster */ + /* position (f_cluster). This is unfortunate because it */ + /* requires a linear search through the file's FAT */ + /* entries. It made sense when DOS was originally */ + /* designed as a simple floppy disk operating system */ + /* where the FAT was contained in core, but now */ + /* requires a search through the FAT blocks. */ + /* */ + /* The algorithm in this function takes advantage of */ + /* the blockio block buffering scheme to simplify the */ + /* task. */ + else + { +#ifdef DISPLAY_GETBLOCK + printf("readblock: "); +#endif + switch (map_cluster(fnp, XFR_READ)) + { + case DE_SEEK: + *err = DE_SEEK; + dir_close(fnp); + return ret_cnt; + + default: + dir_close(fnp); + *err = DE_HNDLDSKFULL; + return ret_cnt; + + case SUCCESS: + break; + } + } + + /* Compute the block within the cluster and the offset */ + /* within the block. */ + fnp->f_sector = (fnp->f_offset / secsize) & fnp->f_dpb->dpb_clsmask; + fnp->f_boff = fnp->f_offset & (secsize - 1); + +#ifdef DSK_DEBUG + printf("read %d links; dir offset %ld, cluster %d\n", + fnp->f_count, + fnp->f_diroff, + fnp->f_cluster); +#endif + /* Do an EOF test and return whatever was transferred */ + /* but only for regular files. */ + if (!(fnp->f_flags.f_ddir) + && (fnp->f_offset >= fnp->f_dir.dir_size)) + { + *err = SUCCESS; + return ret_cnt; + } + + /* Get the block we need from cache */ + bp = getblock((ULONG) clus2phys(fnp->f_cluster, + (fnp->f_dpb->dpb_clsmask + 1), + fnp->f_dpb->dpb_data) + fnp->f_sector, + fnp->f_dpb->dpb_unit); + +#ifdef DISPLAY_GETBLOCK + printf("DATA (readblock)\n"); +#endif + if (bp == (struct buffer *)0) + { + *err = DE_BLKINVLD; + return ret_cnt; + } + + /* transfer a block */ + /* Transfer size as either a full block size, or the */ + /* requested transfer size, whichever is smaller. */ + /* Then compare to what is left, since we can transfer */ + /* a maximum of what is left. */ + if (fnp->f_flags.f_ddir) + xfr_cnt = min(to_xfer, secsize - fnp->f_boff); + else + xfr_cnt = min(min(to_xfer, secsize - fnp->f_boff), + fnp->f_dir.dir_size - fnp->f_offset); + + fbcopy((BYTE FAR *) & bp->b_buffer[fnp->f_boff], buffer, xfr_cnt); + + /* update pointers and counters */ + ret_cnt += xfr_cnt; + to_xfer -= xfr_cnt; + fnp->f_offset += xfr_cnt; + buffer = add_far((VOID FAR *) buffer, (ULONG) xfr_cnt); + } + *err = SUCCESS; + return ret_cnt; +} + +/* Write block to disk */ +UCOUNT writeblock(COUNT fd, VOID FAR * buffer, UCOUNT count, COUNT * err) +{ + REG struct f_node FAR *fnp; + struct buffer FAR *bp; + UCOUNT xfr_cnt = 0; + UCOUNT ret_cnt = 0; + ULONG idx; + UWORD secsize; + UCOUNT to_xfer = count; + +#ifdef DEBUG + if (bDumpRdWrParms) + { + printf("writeblock:\n"); + printf(" fd buffer count\n -- ------ -----\n"); + printf(" %02d %04x:%04x %d\n", + fd, (COUNT) FP_SEG(buffer), (COUNT) FP_OFF(buffer), count); + } +#endif + /* Translate the fd into an fnode pointer, since all internal */ + /* operations are achieved through fnodes. */ + fnp = xlt_fd(fd); + + /* If the fd was invalid because it was out of range or the */ + /* requested file was not open, tell the caller and exit */ + /* note: an invalid fd is indicated by a 0 return */ + if (fnp == (struct f_node FAR *)0 || fnp->f_count <= 0) + { + *err = DE_INVLDHNDL; + return 0; + } + + /* Test that we are really about to do a data transfer. If the */ + /* count is zero and the mode is XFR_READ, just exit. (Any */ + /* read with a count of zero is a nop). */ + /* */ + /* A write (mode is XFR_WRITE) is a special case. It sets the */ + /* file length to the current length (truncates it). */ + /* */ + /* NOTE: doing this up front saves a lot of headaches later. */ + if (count == 0) + { + fnp->f_highwater = fnp->f_offset; + + *err = SUCCESS; + return 0; + } + + /* test that we have a valid mode for this fnode */ + if (fnp->f_mode != WRONLY && fnp->f_mode != RDWR) + { + *err = DE_INVLDACC; + return 0; + } + + /* The variable secsize will be used later. */ + secsize = fnp->f_dpb->dpb_secsize; + + /* Adjust the far pointer from user space to supervisor space */ + buffer = adjust_far((VOID FAR *) buffer); + + /* Do the data transfer. Use block transfer methods so that we */ + /* can utilize memory management in future DOS-C versions. */ + while (ret_cnt < count) + { + /* Position the file to the fnode's pointer position. This is */ + /* done by updating the fnode's cluster, block (sector) and */ + /* byte offset so that read or write becomes a simple data move */ + /* into or out of the block data buffer. */ + if (fnp->f_offset == 0l) + { + /* For the write case, a newly created file */ + /* will have a start cluster of FREE. If we're */ + /* doing a write and this is the first time */ + /* through, allocate a new cluster to the file. */ + if (fnp->f_dir.dir_start == FREE) + if (!first_fat(fnp)) /* get a free cluster */ + { /* error means disk full */ + dir_close(fnp); + *err = DE_HNDLDSKFULL; + return ret_cnt; + } + /* complete the common operations of */ + /* initializing to the starting cluster and */ + /* setting all offsets to zero. */ + fnp->f_cluster = fnp->f_flags.f_ddir ? fnp->f_dirstart : + fnp->f_dir.dir_start; + + fnp->f_cluster_offset = 0l; + fnp->f_back = LONG_LAST_CLUSTER; + fnp->f_sector = 0; + fnp->f_boff = 0; + } + + /* The more difficult scenario is the (more common) */ + /* file offset case. Here, we need to take the fnode's */ + /* offset pointer (f_offset) and translate it into a */ + /* relative cluster position, cluster block (sector) */ + /* offset (f_sector) and byte offset (f_boff). Once we */ + /* have this information, we need to translate the */ + /* relative cluster position into an absolute cluster */ + /* position (f_cluster). This is unfortunate because it */ + /* requires a linear search through the file's FAT */ + /* entries. It made sense when DOS was originally */ + /* designed as a simple floppy disk operating system */ + /* where the FAT was contained in core, but now */ + /* requires a search through the FAT blocks. */ + /* */ + /* The algorithm in this function takes advantage of */ + /* the blockio block buffering scheme to simplify the */ + /* task. */ + else + { +#ifdef DISPLAY_GETBLOCK + printf("writeblock: "); +#endif + switch (map_cluster(fnp, XFR_WRITE)) + { + case DE_SEEK: + *err = DE_SEEK; + dir_close(fnp); + return ret_cnt; + + default: + dir_close(fnp); + *err = DE_HNDLDSKFULL; + return ret_cnt; + + case SUCCESS: + break; + } + } + + /* XFR_WRITE case only - if we're at the end, the next */ + /* FAT is an EOF marker, so just extend the file length */ + if (last_link(fnp)) + if (!extend(fnp)) + { + dir_close(fnp); + *err = DE_HNDLDSKFULL; + return ret_cnt; + } + + /* Compute the block within the cluster and the offset */ + /* within the block. */ + fnp->f_sector = + (fnp->f_offset / secsize) & fnp->f_dpb->dpb_clsmask; + fnp->f_boff = fnp->f_offset & (secsize - 1); + +#ifdef DSK_DEBUG + printf("write %d links; dir offset %ld, cluster %d\n", + fnp->f_count, + fnp->f_diroff, + fnp->f_cluster); +#endif + + /* get a buffer to store the block in */ + if (!getbuf(&bp, (ULONG) clus2phys(fnp->f_cluster, + (fnp->f_dpb->dpb_clsmask + 1), + fnp->f_dpb->dpb_data) + fnp->f_sector, + fnp->f_dpb->dpb_unit)) + { + *err = DE_BLKINVLD; + return ret_cnt; + } + + /* transfer a block */ + /* Transfer size as either a full block size, or the */ + /* requested transfer size, whichever is smaller. */ + /* Then compare to what is left, since we can transfer */ + /* a maximum of what is left. */ + xfr_cnt = min(to_xfer, secsize - fnp->f_boff); + fbcopy(buffer, (BYTE FAR *) & bp->b_buffer[fnp->f_boff], xfr_cnt); + bp->b_flag |= BFR_DIRTY | BFR_VALID; + + /* update pointers and counters */ + ret_cnt += xfr_cnt; + to_xfer -= xfr_cnt; + fnp->f_offset += xfr_cnt; + buffer = add_far((VOID FAR *) buffer, (ULONG) xfr_cnt); + if (fnp->f_offset > fnp->f_highwater) + { + fnp->f_highwater = fnp->f_offset; + fnp->f_dir.dir_size = fnp->f_highwater; + } + } + *err = SUCCESS; + return ret_cnt; +} + +COUNT dos_read(COUNT fd, VOID FAR * buffer, UCOUNT count) +{ + COUNT err; + UCOUNT xfr; + + xfr = readblock(fd, buffer, count, &err); + return err != SUCCESS ? err : xfr; +} + +COUNT FAR init_call_dos_read(COUNT fd, VOID FAR * buffer, UCOUNT count) +{ + return dos_read(fd, buffer, count); +} + +#ifndef IPL +COUNT dos_write(COUNT fd, VOID FAR * buffer, UCOUNT count) +{ + REG struct f_node FAR *fnp; + COUNT err, + xfr; + + /* First test if we need to fill to new EOF. */ + + /* Translate the fd into an fnode pointer, since all internal */ + /* operations are achieved through fnodes. */ + fnp = xlt_fd(fd); + + /* If the fd was invalid because it was out of range or the */ + /* requested file was not open, tell the caller and exit */ + /* note: an invalid fd is indicated by a 0 return */ + if (fnp == (struct f_node FAR *)0 || fnp->f_count <= 0) + { + return DE_INVLDHNDL; + } + + /* Future note: for security purposes, this should be set to */ + /* blocks of 0. This satisfies spec and guarantees no secure */ + /* info is written to disk. */ + /* Also, with real memory management, this may cause a page */ + /* fault. */ + if (fnp->f_offset > fnp->f_highwater) + { + ULONG lCount = fnp->f_offset - fnp->f_highwater; + + while (lCount > 0) + { + writeblock(fd, buffer, + lCount > 512l ? 512 : (UCOUNT) lCount, + &err); + lCount -= 512; + } + } + + xfr = writeblock(fd, buffer, count, &err); + return err != SUCCESS ? err : xfr; +} +#endif + +/* Position the file pointer to the desired offset */ +/* Returns a long current offset or a negative error code */ +LONG dos_lseek(COUNT fd, LONG foffset, COUNT origin) +{ + REG struct f_node FAR *fnp; + + /* Translate the fd into a useful pointer */ + + fnp = xlt_fd(fd); + + /* If the fd was invalid because it was out of range or the */ + /* requested file was not open, tell the caller and exit */ + /* note: an invalid fd is indicated by a 0 return */ + + if (fnp == (struct f_node FAR *)0 || fnp->f_count <= 0) + return (LONG) DE_INVLDHNDL; + + /* now do the actual lseek adjustment to the file poitner */ + + switch (origin) + { + /* offset from beginning of file */ + case 0: + return fnp->f_offset = (ULONG) foffset; + + /* offset from current location */ + case 1: + return fnp->f_offset += foffset; + + /* offset from eof */ + case 2: + return fnp->f_offset = fnp->f_highwater + foffset; + + /* default to an invalid function */ + default: + return (LONG) DE_INVLDFUNC; + } +} + +/* returns the number of unused clusters */ +UWORD dos_free(struct dpb * dpbp) +{ + /* There's an unwritten rule here. All fs */ + /* cluster start at 2 and run to max_cluster+2 */ + REG UWORD i; + REG UWORD cnt = 0; + UWORD max_cluster = ((ULONG) dpbp->dpb_size + * (ULONG) (dpbp->dpb_clsmask + 1) - dpbp->dpb_data + 1) + / (dpbp->dpb_clsmask + 1) + 2; + + if (dpbp->dpb_nfreeclst != UNKNCLUSTER) + return dpbp->dpb_nfreeclst; + else + { + for (i = 2; i < max_cluster; i++) + { + if (next_cluster(dpbp, i) == 0) + ++cnt; + } + dpbp->dpb_nfreeclst = cnt; + return cnt; + } +} + +VOID dos_pwd(struct cds FAR * cdsp, BYTE FAR * s) +{ + WORD x = 1 + cdsp->cdsJoinOffset; + fsncopy((BYTE FAR *) & cdsp->cdsCurrentPath[x], s, 64); +} + +#ifndef IPL +COUNT dos_cd(struct cds FAR * cdsp, BYTE FAR * s) +{ + BYTE FAR *p; + struct f_node FAR *fnp; + COUNT x; + + /* Get the current directory so that we initialize all access */ + /* relative to root. */ + truename(s, PriPathName, FALSE); + + if (cdsp->cdsFlags & 0x8000) + { + if ((int2f_Remote_call(REM_CHDIR, 0, 0, 0, PriPathName, 0, 0)) != 0) + return DE_PATHNOTFND; + fscopy(&PriPathName[0], cdsp->cdsCurrentPath); + if (PriPathName[7] == 0) + cdsp->cdsCurrentPath[8] = 0; + return SUCCESS; + } + + /* now test for its existance. If it doesn't, return an error. */ + /* If it does, copy the path to the current directory */ + /* structure. */ + if ((fnp = dir_open((BYTE FAR *) PriPathName)) == NULL) + return DE_PATHNOTFND; + cdsp->cdsStrtClst = fnp->f_dirstart; + dir_close(fnp); + fscopy(&PriPathName[0], cdsp->cdsCurrentPath); + return SUCCESS; +} +#endif + +/* Try to allocate an f_node from the available files array */ + +struct f_node FAR *get_f_node(void) +{ + REG i; + + for (i = 0; i < NFILES; i++) + { + if (f_nodes[i].f_count == 0) + { + ++f_nodes[i].f_count; + return &f_nodes[i]; + } + } + return (struct f_node FAR *)0; +} + +VOID release_f_node(struct f_node FAR * fnp) +{ + if (fnp->f_count > 0) + --fnp->f_count; + else + fnp->f_count = 0; +} + +#ifndef IPL +VOID dos_setdta(BYTE FAR * newdta) +{ + dta = newdta; +} + +COUNT dos_getfattr(BYTE FAR * name, UWORD FAR * attrp) +{ + struct f_node FAR *fnp; + COUNT fd; + + /* Translate the fd into an fnode pointer, since all internal */ + /* operations are achieved through fnodes. */ + if ((fd = dos_open(name, O_RDONLY)) < SUCCESS) + return DE_FILENOTFND; + + /* note: an invalid fd is indicated by a 0 return */ + if ((fnp = xlt_fd(fd)) == (struct f_node FAR *)0) + return DE_TOOMANY; + + /* If the fd was invalid because it was out of range or the */ + /* requested file was not open, tell the caller and exit */ + if (fnp->f_count <= 0) + { + dos_close(fd); + return DE_FILENOTFND; + } + + /* Get the attribute from the fnode and return */ + *attrp = fnp->f_dir.dir_attrib; + dos_close(fd); + return SUCCESS; +} + +COUNT dos_setfattr(BYTE FAR * name, UWORD FAR * attrp) +{ + struct f_node FAR *fnp; + COUNT fd; + + /* Translate the fd into an fnode pointer, since all internal */ + /* operations are achieved through fnodes. */ + if ((fd = dos_open(name, O_RDONLY)) < SUCCESS) + return DE_FILENOTFND; + + /* note: an invalid fd is indicated by a 0 return */ + if ((fnp = xlt_fd(fd)) == (struct f_node FAR *)0) + return DE_TOOMANY; + + /* If the fd was invalid because it was out of range or the */ + /* requested file was not open, tell the caller and exit */ + if (fnp->f_count <= 0) + { + dos_close(fd); + return DE_FILENOTFND; + } + /* JPP-If user tries to set VOLID or DIR bits, return error */ + if ((*attrp & (D_VOLID | D_DIR | 0xC0)) != 0) + { + dos_close(fd); + return DE_ACCESS; + } + + /* Set the attribute from the fnode and return */ + /* clear all attributes but DIR and VOLID */ + fnp->f_dir.dir_attrib &= (D_VOLID | D_DIR); /* JPP */ + + /* set attributes that user requested */ + fnp->f_dir.dir_attrib |= *attrp; /* JPP */ + fnp->f_flags.f_dmod = TRUE; + dos_close(fd); + return SUCCESS; +} +#endif + +COUNT media_check(REG struct dpb * dpbp) +{ + bpb FAR *bpbp; + ULONG size; + REG COUNT i; + /* First test if anyone has changed the removable media */ + FOREVER + { + MediaReqHdr.r_length = sizeof(request); + MediaReqHdr.r_unit = dpbp->dpb_subunit; + MediaReqHdr.r_command = C_MEDIACHK; + MediaReqHdr.r_mcmdesc = dpbp->dpb_mdb; + MediaReqHdr.r_status = 0; + execrh((request FAR *) & MediaReqHdr, dpbp->dpb_device); + if (!(MediaReqHdr.r_status & S_ERROR) && (MediaReqHdr.r_status & S_DONE)) + break; + else + { + loop1: + switch (block_error(&MediaReqHdr, dpbp->dpb_unit, dpbp->dpb_device)) + { + case ABORT: + case FAIL: + return DE_INVLDDRV; + + case RETRY: + continue; + + case CONTINUE: + break; + + default: + goto loop1; + } + } + } + + switch (MediaReqHdr.r_mcretcode | dpbp->dpb_flags) + { + case M_NOT_CHANGED: + /* It was definitely not changed, so ignore it */ + return SUCCESS; + + /* If it is forced or the media may have changed, */ + /* rebuild the bpb */ + case M_DONT_KNOW: + flush_buffers(dpbp->dpb_unit); + + /* If it definitely changed, don't know (falls through) */ + /* or has been changed, rebuild the bpb. */ + case M_CHANGED: + default: + setinvld(dpbp->dpb_unit); + FOREVER + { + MediaReqHdr.r_length = sizeof(request); + MediaReqHdr.r_unit = dpbp->dpb_subunit; + MediaReqHdr.r_command = C_BLDBPB; + MediaReqHdr.r_mcmdesc = dpbp->dpb_mdb; + MediaReqHdr.r_status = 0; + execrh((request FAR *) & MediaReqHdr, dpbp->dpb_device); + if (!(MediaReqHdr.r_status & S_ERROR) && (MediaReqHdr.r_status & S_DONE)) + break; + else + { + loop2: + switch (block_error(&MediaReqHdr, dpbp->dpb_unit, dpbp->dpb_device)) + { + case ABORT: + case FAIL: + return DE_INVLDDRV; + + case RETRY: + continue; + + case CONTINUE: + break; + + default: + goto loop2; + } + } + } + bpbp = MediaReqHdr.r_bpptr; + dpbp->dpb_mdb = bpbp->bpb_mdesc; + dpbp->dpb_secsize = bpbp->bpb_nbyte; + dpbp->dpb_clsmask = bpbp->bpb_nsector - 1; + dpbp->dpb_fatstrt = bpbp->bpb_nreserved; + dpbp->dpb_fats = bpbp->bpb_nfat; + dpbp->dpb_dirents = bpbp->bpb_ndirent; + size = bpbp->bpb_nsize == 0 ? + bpbp->bpb_huge : + (ULONG) bpbp->bpb_nsize; + dpbp->dpb_size = size / ((ULONG) bpbp->bpb_nsector); + dpbp->dpb_fatsize = bpbp->bpb_nfsect; + dpbp->dpb_dirstrt = dpbp->dpb_fatstrt + + dpbp->dpb_fats * dpbp->dpb_fatsize; + dpbp->dpb_data = dpbp->dpb_dirstrt + + ((DIRENT_SIZE * dpbp->dpb_dirents + + (dpbp->dpb_secsize - 1)) + / dpbp->dpb_secsize); + dpbp->dpb_flags = 0; + dpbp->dpb_next = (struct dpb FAR *)-1; + dpbp->dpb_cluster = UNKNCLUSTER; + dpbp->dpb_nfreeclst = UNKNCLUSTER; /* number of free clusters */ + for (i = 1, dpbp->dpb_shftcnt = 0; + i < (sizeof(dpbp->dpb_shftcnt) * 8); /* 8 bit bytes in C */ + dpbp->dpb_shftcnt++, i <<= 1) + { + if (i >= bpbp->bpb_nsector) + break; + } + return SUCCESS; + } +} + +/* translate the fd into an f_node pointer */ +struct f_node FAR *xlt_fd(COUNT fd) +{ + return fd >= NFILES ? (struct f_node FAR *)0 : &f_nodes[fd]; +} + +/* translate the f_node pointer into an fd */ +COUNT xlt_fnp(struct f_node FAR * fnp) +{ + return fnp - f_nodes; +} + +struct dhdr FAR *select_unit(COUNT drive) +{ + /* Just get the header from the dhdr array */ + return blk_devices[drive].dpb_device; +} + diff --git a/kernel/fattab.c b/kernel/fattab.c new file mode 100644 index 00000000..8869c38d --- /dev/null +++ b/kernel/fattab.c @@ -0,0 +1,378 @@ +/****************************************************************/ +/* */ +/* fattab.c */ +/* */ +/* FAT File System Table Functions */ +/* */ +/* Copyright (c) 1995 */ +/* Pasquale J. Villani */ +/* All Rights Reserved */ +/* */ +/* This file is part of DOS-C. */ +/* */ +/* DOS-C is free software; you can redistribute it and/or */ +/* modify it under the terms of the GNU General Public License */ +/* as published by the Free Software Foundation; either version */ +/* 2, or (at your option) any later version. */ +/* */ +/* DOS-C is distributed in the hope that it will be useful, but */ +/* WITHOUT ANY WARRANTY; without even the implied warranty of */ +/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See */ +/* the GNU General Public License for more details. */ +/* */ +/* You should have received a copy of the GNU General Public */ +/* License along with DOS-C; see the file COPYING. If not, */ +/* write to the Free Software Foundation, 675 Mass Ave, */ +/* Cambridge, MA 02139, USA. */ +/****************************************************************/ + +#include "portab.h" +#include "globals.h" + +#ifdef VERSION_STRINGS +static BYTE *RcsId = "$Id$"; +#endif + +/* + * $Log$ + * Revision 1.1 2000/05/06 19:35:09 jhall1 + * Initial revision + * + * Revision 1.6 1999/08/10 18:03:42 jprice + * ror4 2011-03 patch + * + * Revision 1.5 1999/05/03 06:25:45 jprice + * Patches from ror4 and many changed of signed to unsigned variables. + * + * Revision 1.4 1999/04/16 00:53:33 jprice + * Optimized FAT handling + * + * Revision 1.3 1999/04/11 04:33:38 jprice + * ror4 patches + * + * Revision 1.1.1.1 1999/03/29 15:42:09 jprice + * New version without IPL.SYS + * + * Revision 1.4 1999/02/09 02:54:23 jprice + * Added Pat's 1937 kernel patches + * + * Revision 1.3 1999/02/01 01:43:28 jprice + * Fixed findfirst function to find volume label with Windows long filenames + * + * Revision 1.2 1999/01/22 04:15:28 jprice + * Formating + * + * Revision 1.1.1.1 1999/01/20 05:51:00 jprice + * Imported sources + * + * + * Rev 1.7 09 Feb 1998 5:41:08 patv + * Eliminated FAT12 EOF and error returns. + * + * Rev 1.6 04 Jan 1998 23:14:38 patv + * Changed Log for strip utility + * + * Rev 1.5 16 Jan 1997 12:46:22 patv + * pre-Release 0.92 feature additions + * + * Rev 1.4 29 May 1996 21:15:14 patv + * bug fixes for v0.91a + * + * Rev 1.3 19 Feb 1996 3:20:08 patv + * Added NLS, int2f and config.sys processing + * + * Rev 1.2 01 Sep 1995 17:48:42 patv + * First GPL release. + * + * Rev 1.1 30 Jul 1995 20:50:26 patv + * Eliminated version strings in ipl + * + * Rev 1.0 02 Jul 1995 8:04:56 patv + * Initial revision. + */ + +#ifdef PROTO +UCOUNT link_fat12(struct dpb *, UCOUNT, UCOUNT); +UCOUNT link_fat16(struct dpb *, UCOUNT, UCOUNT); +UWORD next_cl12(struct dpb *, UCOUNT); +UWORD next_cl16(struct dpb *, UCOUNT); +#else +UCOUNT link_fat12(); +UCOUNT link_fat16(); +UWORD next_cl12(); +UWORD next_cl16(); +#endif + +/************************************************************************/ +/* */ +/* cluster/sector routines */ +/* */ +/************************************************************************/ + +/* */ +/* The FAT file system is difficult to trace through FAT table. */ +/* There are two kinds of FAT's, 12 bit and 16 bit. The 16 bit */ +/* FAT is the easiest, since it is noting more than a series of */ +/* UWORD's. The 12 bit FAT is difficult, because it packs 3 FAT */ +/* entries into two BYTE's. The are packed as follows: */ +/* */ +/* 0x0003 0x0004 0x0005 0x0006 0x0007 0x0008 0x0009 ... */ +/* */ +/* are packed as */ +/* */ +/* 0x03 0x40 0x00 0x05 0x60 0x00 0x07 0x80 0x00 0x09 ... */ +/* */ +/* 12 bytes are compressed to 9 bytes */ +/* */ + +UCOUNT link_fat(struct dpb *dpbp, UCOUNT Cluster1, REG UCOUNT Cluster2) +{ + if (ISFAT12(dpbp)) + return link_fat12(dpbp, Cluster1, Cluster2); + else if (ISFAT16(dpbp)) + return link_fat16(dpbp, Cluster1, Cluster2); + else + return DE_BLKINVLD; +} + +UCOUNT link_fat16(struct dpb * dpbp, UCOUNT Cluster1, UCOUNT Cluster2) +{ + UCOUNT idx; + struct buffer FAR *bp; + UWORD Cl2 = Cluster2; + + /* Get the block that this cluster is in */ + bp = getblock((ULONG) (((ULONG) Cluster1) * SIZEOF_CLST16) / dpbp->dpb_secsize + dpbp->dpb_fatstrt, + dpbp->dpb_unit); +#ifdef DISPLAY_GETBLOCK + printf("FAT (link_fat16)\n"); +#endif + if (bp == NULL) + return DE_BLKINVLD; + bp->b_flag &= ~(BFR_DATA | BFR_DIR); + bp->b_flag |= BFR_FAT; + bp->b_copies = dpbp->dpb_fats; + bp->b_offset_lo = dpbp->dpb_fatsize; + bp->b_offset_hi = dpbp->dpb_fatsize >> 8; + + /* form an index so that we can read the block as a */ + /* byte array */ + idx = (((LONG) Cluster1) * SIZEOF_CLST16) % dpbp->dpb_secsize; + + /* Finally, put the word into the buffer and mark the */ + /* buffer as dirty. */ + fputword((WORD FAR *) & Cl2, (VOID FAR *) & (bp->b_buffer[idx])); + bp->b_flag |= BFR_DIRTY; + + /* Return successful. */ + /* update the free space count */ + if (Cluster2 == FREE) + { + /* update the free space count for returned */ + /* cluster */ + if (dpbp->dpb_nfreeclst != UNKNCLUSTER) + ++dpbp->dpb_nfreeclst; + } + else + { + /* update the free space count for removed */ + /* cluster */ + if (dpbp->dpb_nfreeclst != UNKNCLUSTER) + --dpbp->dpb_nfreeclst; + } + + return SUCCESS; +} + +UCOUNT link_fat12(struct dpb * dpbp, UCOUNT Cluster1, UCOUNT Cluster2) +{ + REG UBYTE FAR *fbp0, + FAR * fbp1; + UCOUNT idx; + struct buffer FAR *bp, + FAR * bp1; + + /* Get the block that this cluster is in */ + bp = getblock((ULONG) ((((Cluster1 << 1) + Cluster1) >> 1) / dpbp->dpb_secsize + dpbp->dpb_fatstrt), + dpbp->dpb_unit); +#ifdef DISPLAY_GETBLOCK + printf("FAT (link_fat12)\n"); +#endif + if (bp == NULL) + return DE_BLKINVLD; + bp->b_flag &= ~(BFR_DATA | BFR_DIR); + bp->b_flag |= BFR_FAT; + bp->b_copies = dpbp->dpb_fats; + bp->b_offset_lo = dpbp->dpb_fatsize; + bp->b_offset_hi = dpbp->dpb_fatsize >> 8; + + /* form an index so that we can read the block as a */ + /* byte array */ + idx = (((Cluster1 << 1) + Cluster1) >> 1) % dpbp->dpb_secsize; + + /* Test to see if the cluster straddles the block. If */ + /* it does, get the next block and use both to form the */ + /* the FAT word. Otherwise, just point to the next */ + /* block. */ + if (idx >= dpbp->dpb_secsize - 1) + { + bp1 = getblock((ULONG) (dpbp->dpb_fatstrt + + ((((Cluster1 << 1) + Cluster1) >> 1) / dpbp->dpb_secsize)) + + 1, + dpbp->dpb_unit); +#ifdef DISPLAY_GETBLOCK + printf("FAT (link_fat12)\n"); +#endif + if (bp1 == (struct buffer *)0) + return DE_BLKINVLD; + bp1->b_flag &= ~(BFR_DATA | BFR_DIR); + bp1->b_flag |= BFR_FAT | BFR_DIRTY; + bp1->b_copies = dpbp->dpb_fats; + bp1->b_offset_lo = dpbp->dpb_fatsize; + bp1->b_offset_hi = dpbp->dpb_fatsize >> 8; + fbp1 = (UBYTE FAR *) & (bp1->b_buffer[0]); + } + else + fbp1 = (UBYTE FAR *) & (bp->b_buffer[idx + 1]); + fbp0 = (UBYTE FAR *) & (bp->b_buffer[idx]); + bp->b_flag |= BFR_DIRTY; + + /* Now pack the value in */ + if (Cluster1 & 0x01) + { + *fbp0 = (*fbp0 & 0x0f) | ((Cluster2 & 0x0f) << 4); + *fbp1 = (Cluster2 >> 4) & 0xff; + } + else + { + *fbp0 = Cluster2 & 0xff; + *fbp1 = (*fbp1 & 0xf0) | (Cluster2 >> 8) & 0x0f; + } + + /* update the free space count */ + if (Cluster2 == FREE) + { + /* update the free space count for returned */ + /* cluster */ + if (dpbp->dpb_nfreeclst != UNKNCLUSTER) + ++dpbp->dpb_nfreeclst; + } + else + { + /* update the free space count for removed */ + /* cluster */ + if (dpbp->dpb_nfreeclst != UNKNCLUSTER) + --dpbp->dpb_nfreeclst; + } + + return SUCCESS; +} + +/* Given the disk parameters, and a cluster number, this function + looks at the FAT, and returns the next cluster in the clain. */ +UWORD next_cluster(struct dpb * dpbp, REG UCOUNT ClusterNum) +{ + if (ISFAT12(dpbp)) + return next_cl12(dpbp, ClusterNum); + else if (ISFAT16(dpbp)) + return next_cl16(dpbp, ClusterNum); + else + return LONG_LAST_CLUSTER; +} + +UWORD next_cl16(struct dpb * dpbp, REG UCOUNT ClusterNum) +{ + UCOUNT idx; + struct buffer FAR *bp; + UWORD RetCluster; + + /* Get the block that this cluster is in */ + bp = getblock((ULONG) (((ULONG) ClusterNum) * SIZEOF_CLST16) / dpbp->dpb_secsize + dpbp->dpb_fatstrt, + dpbp->dpb_unit); +#ifdef DISPLAY_GETBLOCK + printf("FAT (next_cl16)\n"); +#endif + if (bp == NULL) + return DE_BLKINVLD; + bp->b_flag &= ~(BFR_DATA | BFR_DIR); + bp->b_flag |= BFR_FAT; + bp->b_copies = dpbp->dpb_fats; + bp->b_offset_lo = dpbp->dpb_fatsize; + bp->b_offset_hi = dpbp->dpb_fatsize >> 8; + + /* form an index so that we can read the block as a */ + /* byte array */ + idx = (((LONG) ClusterNum) * SIZEOF_CLST16) % dpbp->dpb_secsize; + + /* Get the cluster number, */ + fgetword((VOID FAR *) & (bp->b_buffer[idx]), (WORD FAR *) & RetCluster); + + /* and return successful. */ + return RetCluster; +} + +UWORD next_cl12(struct dpb * dpbp, REG UCOUNT ClusterNum) +{ + REG UBYTE FAR *fbp0, + FAR * fbp1; + UCOUNT idx; + struct buffer FAR *bp, + FAR * bp1; + + /* Get the block that this cluster is in */ + bp = getblock((ULONG) ((((ClusterNum << 1) + ClusterNum) >> 1) / dpbp->dpb_secsize + dpbp->dpb_fatstrt), + dpbp->dpb_unit); +#ifdef DISPLAY_GETBLOCK + printf("FAT (next_cl12)\n"); +#endif + if (bp == NULL) + return LONG_BAD; + bp->b_flag &= ~(BFR_DATA | BFR_DIR); + bp->b_flag |= BFR_FAT; + bp->b_copies = dpbp->dpb_fats; + bp->b_offset_lo = dpbp->dpb_fatsize; + bp->b_offset_hi = dpbp->dpb_fatsize >> 8; + + /* form an index so that we can read the block as a */ + /* byte array */ + idx = (((ClusterNum << 1) + ClusterNum) >> 1) % dpbp->dpb_secsize; + + /* Test to see if the cluster straddles the block. If it */ + /* does, get the next block and use both to form the */ + /* the FAT word. Otherwise, just point to the next */ + /* block. */ + if (idx >= dpbp->dpb_secsize - 1) + { + bp1 = getblock((ULONG) (dpbp->dpb_fatstrt + + ((((ClusterNum << 1) + ClusterNum) >> 1) / dpbp->dpb_secsize)) + + 1, + dpbp->dpb_unit); +#ifdef DISPLAY_GETBLOCK + printf("FAT (next_cl12)\n"); +#endif + if (bp1 == (struct buffer *)0) + return LONG_BAD; + bp1->b_flag &= ~(BFR_DATA | BFR_DIR); + bp1->b_flag |= BFR_FAT; + bp1->b_copies = dpbp->dpb_fats; + bp1->b_offset_lo = dpbp->dpb_fatsize; + bp1->b_offset_hi = dpbp->dpb_fatsize >> 8; + fbp1 = (UBYTE FAR *) & (bp1->b_buffer[0]); + } + else + fbp1 = (UBYTE FAR *) & (bp->b_buffer[idx + 1]); + fbp0 = (UBYTE FAR *) & (bp->b_buffer[idx]); + + /* Now to unpack the contents of the FAT entry. Odd and */ + /* even bytes are packed differently. */ + if (ClusterNum & 0x01) + ClusterNum = ((*fbp0 & 0xf0) >> 4) | *fbp1 << 4; + else + ClusterNum = *fbp0 | ((*fbp1 & 0x0f) << 8); + + if ((ClusterNum & MASK) == MASK) + ClusterNum = LONG_LAST_CLUSTER; + else if ((ClusterNum & BAD) == BAD) + ClusterNum = LONG_BAD; + return ClusterNum; +} diff --git a/kernel/fcbfns.c b/kernel/fcbfns.c new file mode 100644 index 00000000..d3bce15f --- /dev/null +++ b/kernel/fcbfns.c @@ -0,0 +1,1169 @@ +/****************************************************************/ +/* */ +/* fcbfns.c */ +/* */ +/* Old CP/M Style Function Handlers for Kernel */ +/* */ +/* Copyright (c) 1995 */ +/* Pasquale J. Villani */ +/* All Rights Reserved */ +/* */ +/* This file is part of DOS-C. */ +/* */ +/* DOS-C is free software; you can redistribute it and/or */ +/* modify it under the terms of the GNU General Public License */ +/* as published by the Free Software Foundation; either version */ +/* 2, or (at your option) any later version. */ +/* */ +/* DOS-C is distributed in the hope that it will be useful, but */ +/* WITHOUT ANY WARRANTY; without even the implied warranty of */ +/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See */ +/* the GNU General Public License for more details. */ +/* */ +/* You should have received a copy of the GNU General Public */ +/* License along with DOS-C; see the file COPYING. If not, */ +/* write to the Free Software Foundation, 675 Mass Ave, */ +/* Cambridge, MA 02139, USA. */ +/****************************************************************/ + +#include "portab.h" +#include "globals.h" + +#ifdef VERSION_STRINGS +static BYTE *RcsId = "$Id$"; +#endif + +/* + * $Log$ + * Revision 1.1 2000/05/06 19:35:12 jhall1 + * Initial revision + * + * Revision 1.5 2000/03/09 06:07:11 kernel + * 2017f updates by James Tabor + * + * Revision 1.4 1999/09/23 04:40:46 jprice + * *** empty log message *** + * + * Revision 1.2 1999/04/04 18:51:43 jprice + * no message + * + * Revision 1.1.1.1 1999/03/29 15:42:15 jprice + * New version without IPL.SYS + * + * Revision 1.5 1999/02/09 02:54:23 jprice + * Added Pat's 1937 kernel patches + * + * Revision 1.4 1999/02/04 03:18:37 jprice + * Formating. Added comments. + * + * Revision 1.3 1999/02/01 01:43:28 jprice + * Fixed findfirst function to find volume label with Windows long filenames + * + * Revision 1.2 1999/01/22 04:15:28 jprice + * Formating + * + * Revision 1.1.1.1 1999/01/20 05:51:00 jprice + * Imported sources + * + * + * Rev 1.7 06 Dec 1998 8:44:10 patv + * Expanded fcb functions for new I/O subsystem. + * + * Rev 1.6 04 Jan 1998 23:14:38 patv + * Changed Log for strip utility + * + * Rev 1.5 03 Jan 1998 8:36:02 patv + * Converted data area to SDA format + * + * Rev 1.4 16 Jan 1997 12:46:38 patv + * pre-Release 0.92 feature additions + * + * Rev 1.3 29 May 1996 21:15:14 patv + * bug fixes for v0.91a + * + * Rev 1.2 01 Sep 1995 17:48:44 patv + * First GPL release. + * + * Rev 1.1 30 Jul 1995 20:50:26 patv + * Eliminated version strings in ipl + * + * Rev 1.0 02 Jul 1995 8:06:06 patv + * Initial revision. + */ + +#define FCB_SUCCESS 0 +#define FCB_ERR_NODATA 1 +#define FCB_ERR_EOF 3 +#define FCB_ERR_WRITE 1 +#define D_ALL D_NORMAL | D_RDONLY | D_HIDDEN | D_SYSTEM | D_DIR | D_ARCHIVE + +#ifdef PROTO +fcb FAR *ExtFcbToFcb(xfcb FAR * lpExtFcb); +fcb FAR *CommonFcbInit(xfcb FAR * lpExtFcb, BYTE * pszBuffer, COUNT * pCurDrive); +void FcbNameInit(fcb FAR * lpFcb, BYTE * pszBuffer, COUNT * pCurDrive); +sft FAR *FcbGetSft(COUNT SftIndex); +VOID FcbNextRecord(fcb FAR * lpFcb); +sft FAR *FcbGetFreeSft(WORD FAR * sft_idx); +BOOL FcbFnameMatch(BYTE FAR * s, BYTE FAR * d, COUNT n, COUNT mode); +BOOL FcbCharMatch(COUNT s, COUNT d, COUNT mode); +BOOL FcbCalcRec(xfcb FAR * lpXfcb); +VOID MoveDirInfo(dmatch FAR * lpDmatch, struct dirent FAR * lpDir); +#else +fcb FAR *ExtFcbToFcb(); +fcb FAR *CommonFcbInit(); +void FcbNameInit(); +sft FAR *FcbGetSft(); +VOID FcbNextRecord(); +sft FAR *FcbGetFreeSft(); +BOOL FcbFnameMatch(); +BOOL FcbCharMatch(); +BOOL FcbCalcRec(); +VOID MoveDirInfo(); +#endif + +static dmatch Dmatch; + +VOID FatGetDrvData(COUNT drive, COUNT FAR * spc, COUNT FAR * bps, + COUNT FAR * nc, BYTE FAR ** mdp) +{ + struct dpb *dpbp; + + printf("FGDD\n"); + + /* first check for valid drive */ + if (drive < 0 || drive > NDEVS) + { + *spc = -1; + return; + } + + /* next - "log" in the drive */ + drive = (drive == 0 ? default_drive : drive - 1); + dpbp = (struct dpb *)CDSp->cds_table[drive].cdsDpb; + dpbp->dpb_flags = -1; + if ((media_check(dpbp) < 0)) + { + *spc = -1; + return; + } + + /* get the data vailable from dpb */ + *nc = dpbp->dpb_size; + *spc = dpbp->dpb_clsmask + 1; + *bps = dpbp->dpb_secsize; + + /* Point to the media desctriptor fotr this drive */ + *mdp = &(dpbp->dpb_mdb); +} + +#define PARSE_SEP_STOP 0x01 +#define PARSE_DFLT_DRIVE 0x02 +#define PARSE_BLNK_FNAME 0x04 +#define PARSE_BLNK_FEXT 0x08 + +#define PARSE_RET_NOWILD 0 +#define PARSE_RET_WILD 1 +#define PARSE_RET_BADDRIVE 0xff + +#ifndef IPL +WORD FcbParseFname(int wTestMode, BYTE FAR ** lpFileName, fcb FAR * lpFcb) +{ + COUNT nIndex; + WORD wRetCode = PARSE_RET_NOWILD; + + /* pjv -- ExtFcbToFcb? */ + /* Start out with some simple stuff first. Check if we are */ + /* going to use a default drive specificaton. */ + if (!(wTestMode & PARSE_DFLT_DRIVE)) + lpFcb->fcb_drive = FDFLT_DRIVE; + if (!(wTestMode & PARSE_BLNK_FNAME)) + { + for (nIndex = 0; nIndex < FNAME_SIZE; ++nIndex) + lpFcb->fcb_fname[nIndex] = ' '; + } + if (!(wTestMode & PARSE_BLNK_FEXT)) + { + for (nIndex = 0; nIndex < FEXT_SIZE; ++nIndex) + lpFcb->fcb_fext[nIndex] = ' '; + } + + /* Undocumented behavior, set record number & record size to 0 */ + lpFcb->fcb_cublock = lpFcb->fcb_recsiz = 0; + + if (!(wTestMode & PARSE_SEP_STOP)) + { + *lpFileName = ParseSkipWh(*lpFileName); + if (TestCmnSeps(*lpFileName)) + ++ * lpFileName; + } + + /* Undocumented "feature," we skip white space anyway */ + *lpFileName = ParseSkipWh(*lpFileName); + + /* Now check for drive specification */ + if (*(*lpFileName + 1) == ':') + { + REG BYTE Drive = upChar(**lpFileName); + + /* non-portable construct to be changed */ + if (Drive < 'A' || Drive > 'Z') + return PARSE_RET_BADDRIVE; + Drive -= ('A' - 1); + if (Drive > lastdrive) + return PARSE_RET_BADDRIVE; + else + lpFcb->fcb_drive = Drive; + *lpFileName += 2; + } + + /* Now to format the file name into the string */ + *lpFileName = GetNameField(*lpFileName, (BYTE FAR *) lpFcb->fcb_fname, FNAME_SIZE, (BOOL *) & wRetCode); + + /* Do we have an extension? If do, format it else return */ + if (**lpFileName == '.') + *lpFileName = GetNameField(++*lpFileName, (BYTE FAR *) lpFcb->fcb_fext, FEXT_SIZE, (BOOL *) & wRetCode); + + return wRetCode ? PARSE_RET_WILD : PARSE_RET_NOWILD; +} + +BYTE FAR *ParseSkipWh(BYTE FAR * lpFileName) +{ + while (*lpFileName == ' ' || *lpFileName == '\t') + ++lpFileName; + return lpFileName; +} + +BOOL TestCmnSeps(BYTE FAR * lpFileName) +{ + BYTE *pszTest, + *pszCmnSeps = ":<|>+=,"; + + for (pszTest = pszCmnSeps; *pszTest != '\0'; ++pszTest) + if (*lpFileName == *pszTest) + return TRUE; + return FALSE; +} + +BOOL TestFieldSeps(BYTE FAR * lpFileName) +{ + BYTE *pszTest, + *pszCmnSeps = "/\"[]<>|."; + + /* Another non-portable construct */ + if (*lpFileName <= ' ') + return TRUE; + + for (pszTest = pszCmnSeps; *pszTest != '\0'; ++pszTest) + if (*lpFileName == *pszTest) + return TRUE; + return FALSE; +} + +BYTE FAR *GetNameField(BYTE FAR * lpFileName, BYTE FAR * lpDestField, + COUNT nFieldSize, BOOL * pbWildCard) +{ + COUNT nIndex = 0; + BYTE cFill = ' '; + + *pbWildCard = FALSE; + while (*lpFileName != '\0' && !TestFieldSeps(lpFileName) && nIndex < nFieldSize) + { + if (*lpFileName == ' ') + break; + if (*lpFileName == '*') + { + *pbWildCard = TRUE; + cFill = '?'; + ++lpFileName; + break; + } + if (*lpFileName == '?') + *pbWildCard = TRUE; + *lpDestField++ = upChar(*lpFileName++); + ++nIndex; + } + + /* Blank out remainder of field on exit */ + for (; nIndex < nFieldSize; ++nIndex) + *lpDestField++ = cFill; + return lpFileName; +} + +static sft FAR *FcbGetSft(COUNT SftIndex) +{ + /* Get the SFT block that contains the SFT */ + for (lpCurSft = sfthead; lpCurSft != (sfttbl FAR *) - 1; + lpCurSft = lpCurSft->sftt_next) + { + if (SftIndex < lpCurSft->sftt_count) + break; + else + SftIndex -= lpCurSft->sftt_count; + } + + /* If not found, return an error */ + if (lpCurSft == (sfttbl FAR *) - 1) + return (sft FAR *) - 1; + + /* finally, point to the right entry */ + return (sft FAR *) & (lpCurSft->sftt_table[SftIndex]); +} + +static VOID FcbNextRecord(fcb FAR * lpFcb) +{ + if (++lpFcb->fcb_curec > 128) + { + lpFcb->fcb_curec = 0; + ++lpFcb->fcb_cublock; + } +} + +BOOL FcbRead(xfcb FAR * lpXfcb, COUNT * nErrorCode) +{ + sft FAR *s; + LONG lPosit; + COUNT nRead; + psp FAR *p = MK_FP(cu_psp, 0); + + /* Convert to fcb if necessary */ + lpFcb = ExtFcbToFcb(lpXfcb); + + /* Get the SFT block that contains the SFT */ + if ((s = FcbGetSft(lpFcb->fcb_sftno)) == (sft FAR *) - 1) + return FALSE; + + /* If this is not opened another error */ + if (s->sft_count == 0) + return FALSE; + + /* Now update the fcb and compute where we need to position */ + /* to. */ + lPosit = ((lpFcb->fcb_cublock * 128) + lpFcb->fcb_curec) + * lpFcb->fcb_recsiz; + if (dos_lseek(s->sft_status, lPosit, 0) < 0) + { + *nErrorCode = FCB_ERR_EOF; + return FALSE; + } + + if (s->sft_flags & SFT_FSHARED) + { + nRead = Remote_RW(REM_READ, lpFcb->fcb_recsiz, p->ps_dta, s, nErrorCode); + } + else + { + + /* Do the read */ + nRead = dos_read(s->sft_status, p->ps_dta, lpFcb->fcb_recsiz); + } + + /* Now find out how we will return and do it. */ + if (nRead == lpFcb->fcb_recsiz) + { + *nErrorCode = FCB_SUCCESS; + FcbNextRecord(lpFcb); + return TRUE; + } + else if (nRead < 0) + { + *nErrorCode = FCB_ERR_EOF; + return TRUE; + } + else if (nRead == 0) + { + *nErrorCode = FCB_ERR_NODATA; + return FALSE; + } + else + { + COUNT nIdx, + nCount; + BYTE FAR *lpDta; + + nCount = lpFcb->fcb_recsiz - nRead; + lpDta = (BYTE FAR *) & (p->ps_dta[nRead]); + for (nIdx = 0; nIdx < nCount; nIdx++) + *lpDta++ = 0; + *nErrorCode = FCB_ERR_EOF; + FcbNextRecord(lpFcb); + return FALSE; + } +} + +BOOL FcbWrite(xfcb FAR * lpXfcb, COUNT * nErrorCode) +{ + sft FAR *s; + LONG lPosit; + COUNT nWritten; + psp FAR *p = MK_FP(cu_psp, 0); + + /* Convert to fcb if necessary */ + lpFcb = ExtFcbToFcb(lpXfcb); + + /* Get the SFT block that contains the SFT */ + if ((s = FcbGetSft(lpFcb->fcb_sftno)) == (sft FAR *) - 1) + return FALSE; + + /* If this is not opened another error */ + if (s->sft_count == 0) + return FALSE; + + /* Now update the fcb and compute where we need to position */ + /* to. */ + lPosit = ((lpFcb->fcb_cublock * 128) + lpFcb->fcb_curec) + * lpFcb->fcb_recsiz; + if (dos_lseek(s->sft_status, lPosit, 0) < 0) + { + *nErrorCode = FCB_ERR_EOF; + return FALSE; + } + + if (s->sft_flags & SFT_FSHARED) + { + nWritten = Remote_RW(REM_WRITE, lpFcb->fcb_recsiz, p->ps_dta, s, nErrorCode); + } + else + { + + /* Do the read */ + nWritten = dos_write(s->sft_status, p->ps_dta, lpFcb->fcb_recsiz); + } + + /* Now find out how we will return and do it. */ + if (nWritten == lpFcb->fcb_recsiz) + { + lpFcb->fcb_fsize = dos_getcufsize(s->sft_status); + FcbNextRecord(lpFcb); + *nErrorCode = FCB_SUCCESS; + return TRUE; + } + else if (nWritten <= 0) + { + *nErrorCode = FCB_ERR_WRITE; + return TRUE; + } + *nErrorCode = FCB_ERR_WRITE; + return FALSE; +} + +BOOL FcbGetFileSize(xfcb FAR * lpXfcb) +{ + COUNT FcbDrive, + FileNum; + + /* Build a traditional DOS file name */ + lpFcb = CommonFcbInit(lpXfcb, PriPathName, &FcbDrive); + + /* check for a device */ + /* if we have an extension, can't be a device */ + if (IsDevice(PriPathName) || (lpFcb->fcb_recsiz == 0)) + { + return FALSE; + } + FileNum = dos_open(PriPathName, O_RDONLY); + if (FileNum >= 0) + { + LONG fsize; + + /* Get the size */ + fsize = dos_getfsize(FileNum); + + /* compute the size and update the fcb */ + lpFcb->fcb_rndm = fsize / lpFcb->fcb_recsiz; + if ((fsize % lpFcb->fcb_recsiz) != 0) + ++lpFcb->fcb_rndm; + + /* close the file and leave */ + return dos_close(FileNum) == SUCCESS; + } + else + return FALSE; +} + +BOOL FcbSetRandom(xfcb FAR * lpXfcb) +{ + LONG lPosit; + + /* Convert to fcb if necessary */ + lpFcb = ExtFcbToFcb(lpXfcb); + + /* Now update the fcb and compute where we need to position */ + /* to. */ + lpFcb->fcb_rndm = (lpFcb->fcb_cublock * 128) + + lpFcb->fcb_curec; + + return TRUE; +} + +BOOL FcbCalcRec(xfcb FAR * lpXfcb) +{ + LONG lPosit; + + /* Convert to fcb if necessary */ + lpFcb = ExtFcbToFcb(lpXfcb); + + /* Now update the fcb and compute where we need to position */ + /* to. */ + lpFcb->fcb_cublock = lpFcb->fcb_rndm / 128; + lpFcb->fcb_curec = lpFcb->fcb_rndm % 128; + + return TRUE; +} + +BOOL FcbRandomBlockRead(xfcb FAR * lpXfcb, COUNT nRecords, COUNT * nErrorCode) +{ + FcbCalcRec(lpXfcb); + + /* Convert to fcb if necessary */ + lpFcb = ExtFcbToFcb(lpXfcb); + + do + FcbRead(lpXfcb, nErrorCode); + while ((--nRecords > 0) && (*nErrorCode == 0)); + + /* Now update the fcb */ + lpFcb->fcb_rndm = lpFcb->fcb_cublock * 128 + lpFcb->fcb_curec; + + return TRUE; +} + +BOOL FcbRandomBlockWrite(xfcb FAR * lpXfcb, COUNT nRecords, COUNT * nErrorCode) +{ + FcbCalcRec(lpXfcb); + + /* Convert to fcb if necessary */ + lpFcb = ExtFcbToFcb(lpXfcb); + + do + FcbWrite(lpXfcb, nErrorCode); + while ((--nRecords > 0) && (*nErrorCode == 0)); + + /* Now update the fcb */ + lpFcb->fcb_rndm = lpFcb->fcb_cublock * 128 + lpFcb->fcb_curec; + + return TRUE; +} + +BOOL FcbRandomRead(xfcb FAR * lpXfcb, COUNT * nErrorCode) +{ + UWORD uwCurrentBlock; + UBYTE ucCurrentRecord; + + FcbCalcRec(lpXfcb); + + /* Convert to fcb if necessary */ + lpFcb = ExtFcbToFcb(lpXfcb); + + uwCurrentBlock = lpFcb->fcb_cublock; + ucCurrentRecord = lpFcb->fcb_curec; + + FcbRead(lpXfcb, nErrorCode); + + lpFcb->fcb_cublock = uwCurrentBlock; + lpFcb->fcb_curec = ucCurrentRecord; + return TRUE; +} + +BOOL FcbRandomWrite(xfcb FAR * lpXfcb, COUNT * nErrorCode) +{ + UWORD uwCurrentBlock; + UBYTE ucCurrentRecord; + + FcbCalcRec(lpXfcb); + + /* Convert to fcb if necessary */ + lpFcb = ExtFcbToFcb(lpXfcb); + + uwCurrentBlock = lpFcb->fcb_cublock; + ucCurrentRecord = lpFcb->fcb_curec; + + FcbWrite(lpXfcb, nErrorCode); + + lpFcb->fcb_cublock = uwCurrentBlock; + lpFcb->fcb_curec = ucCurrentRecord; + return TRUE; +} + +static sft FAR *FcbGetFreeSft(WORD FAR * sft_idx) +{ + WORD sys_idx = 0; + sfttbl FAR *sp; + + /* Get the SFT block that contains the SFT */ + for (sp = sfthead; sp != (sfttbl FAR *) - 1; sp = sp->sftt_next) + { + REG WORD i; + + for (i = 0; i < sp->sftt_count; i++) + { + if (sp->sftt_table[i].sft_count == 0) + { + *sft_idx = sys_idx + i; + return (sft FAR *) & sp->sftt_table[sys_idx + i]; + } + } + sys_idx += i; + } + + /* If not found, return an error */ + return (sft FAR *) - 1; +} + +BOOL FcbCreate(xfcb FAR * lpXfcb) +{ + WORD sft_idx; + sft FAR *sftp; + struct dhdr FAR *dhp; + COUNT FcbDrive; + + /* get a free system file table entry */ + if ((sftp = FcbGetFreeSft((WORD FAR *) & sft_idx)) == (sft FAR *) - 1) + return DE_TOOMANY; + + /* Build a traditional DOS file name */ + lpFcb = CommonFcbInit(lpXfcb, PriPathName, &FcbDrive); + + /* check for a device */ + /* if we have an extension, can't be a device */ + if (IsDevice(PriPathName)) + { + for (dhp = (struct dhdr FAR *)&nul_dev; dhp != (struct dhdr FAR *)-1; dhp = dhp->dh_next) + { + if (FcbFnameMatch((BYTE FAR *) PriPathName, (BYTE FAR *) dhp->dh_name, FNAME_SIZE, FALSE)) + { + sftp->sft_count += 1; + sftp->sft_mode = O_RDWR; + sftp->sft_attrib = 0; + sftp->sft_flags = + (dhp->dh_attr & ~SFT_MASK) | SFT_FDEVICE | SFT_FEOF; + sftp->sft_psp = cu_psp; + fbcopy(lpFcb->fcb_fname, sftp->sft_name, FNAME_SIZE + FEXT_SIZE); + sftp->sft_dev = dhp; + lpFcb->fcb_sftno = sft_idx; + lpFcb->fcb_curec = 0; + lpFcb->fcb_recsiz = 0; + lpFcb->fcb_fsize = 0; + lpFcb->fcb_date = dos_getdate(); + lpFcb->fcb_time = dos_gettime(); + lpFcb->fcb_rndm = 0; + return TRUE; + } + } + } + sftp->sft_status = dos_creat(PriPathName, 0); + if (sftp->sft_status >= 0) + { + lpFcb->fcb_drive = FcbDrive; + lpFcb->fcb_sftno = sft_idx; + lpFcb->fcb_curec = 0; + lpFcb->fcb_recsiz = 128; + lpFcb->fcb_fsize = 0; + lpFcb->fcb_date = dos_getdate(); + lpFcb->fcb_time = dos_gettime(); + lpFcb->fcb_rndm = 0; + sftp->sft_count += 1; + sftp->sft_mode = O_RDWR; + sftp->sft_attrib = 0; + sftp->sft_flags = 0; + sftp->sft_psp = cu_psp; + fbcopy((BYTE FAR *) & lpFcb->fcb_fname, (BYTE FAR *) & sftp->sft_name, FNAME_SIZE + FEXT_SIZE); + return TRUE; + } + else + return FALSE; +} + +static fcb FAR *ExtFcbToFcb(xfcb FAR * lpExtFcb) +{ + if (*((UBYTE FAR *) lpExtFcb) == 0xff) + return &lpExtFcb->xfcb_fcb; + else + return (fcb FAR *) lpExtFcb; +} + +static fcb FAR *CommonFcbInit(xfcb FAR * lpExtFcb, BYTE * pszBuffer, + COUNT * pCurDrive) +{ + BYTE FAR *lpszFcbFname, + *lpszFcbFext; + COUNT nDrvIdx, + nFnameIdx, + nFextIdx; + fcb FAR *lpFcb; + + /* convert to fcb if needed first */ + lpFcb = ExtFcbToFcb(lpExtFcb); + + /* Build a traditional DOS file name */ + FcbNameInit(lpFcb, pszBuffer, pCurDrive); + + /* and return the fcb pointer */ + return lpFcb; +} + +void FcbNameInit(fcb FAR * lpFcb, BYTE * pszBuffer, COUNT * pCurDrive) +{ + BYTE FAR *lpszFcbFname, + FAR * lpszFcbFext; + COUNT nDrvIdx, + nFnameIdx, + nFextIdx; + + /* Build a traditional DOS file name */ + lpszFcbFname = (BYTE FAR *) lpFcb->fcb_fname; + if (lpFcb->fcb_drive != 0) + { + *pCurDrive = lpFcb->fcb_drive; + pszBuffer[0] = 'A' + lpFcb->fcb_drive - 1; + pszBuffer[1] = ':'; + nDrvIdx = 2; + } + else + { + *pCurDrive = default_drive + 1; + nDrvIdx = 0; + } + + for (nFnameIdx = 0; nFnameIdx < FNAME_SIZE; nFnameIdx++) + { + if (*lpszFcbFname != ' ') + pszBuffer[nDrvIdx + nFnameIdx] = *lpszFcbFname++; + else + break; + } + + lpszFcbFext = (BYTE FAR *) lpFcb->fcb_fext; + if (*lpszFcbFext != ' ') + { + pszBuffer[nDrvIdx + nFnameIdx++] = '.'; + for (nFextIdx = 0; nFextIdx < FEXT_SIZE; nFextIdx++) + { + if (*lpszFcbFext != ' ') + pszBuffer[nDrvIdx + nFnameIdx + nFextIdx] = + *lpszFcbFext++; + else + break; + } + } + else + nFextIdx = 0; + pszBuffer[nDrvIdx + nFnameIdx + nFextIdx] = '\0'; +} + +/* Ascii only file name match routines */ +static BOOL FcbCharMatch(COUNT s, COUNT d, COUNT mode) +{ + if (s >= 'a' && s <= 'z') + s -= 'a' - 'A'; + if (d >= 'a' && d <= 'z') + d -= 'a' - 'A'; + if (mode && s == '?' && (d >= 'A' && s <= 'Z')) + return TRUE; + return s == d; +} + +static BOOL FcbFnameMatch(BYTE FAR * s, BYTE FAR * d, COUNT n, COUNT mode) +{ + while (n--) + { + if (!FcbCharMatch(*s++, *d++, mode)) + return FALSE; + } + return TRUE; +} + +BOOL FcbOpen(xfcb FAR * lpXfcb) +{ + WORD sft_idx; + sft FAR *sftp; + struct dhdr FAR *dhp; + COUNT FcbDrive; + + /* get a free system file table entry */ + if ((sftp = FcbGetFreeSft((WORD FAR *) & sft_idx)) == (sft FAR *) - 1) + return DE_TOOMANY; + + /* Build a traditional DOS file name */ + lpFcb = CommonFcbInit(lpXfcb, PriPathName, &FcbDrive); + + /* check for a device */ + /* if we have an extension, can't be a device */ + if (IsDevice(PriPathName)) + { + for (dhp = (struct dhdr FAR *)&nul_dev; dhp != (struct dhdr FAR *)-1; dhp = dhp->dh_next) + { + if (FcbFnameMatch((BYTE FAR *) PriPathName, (BYTE FAR *) dhp->dh_name, FNAME_SIZE, FALSE)) + { + sftp->sft_count += 1; + sftp->sft_mode = O_RDWR; + sftp->sft_attrib = 0; + sftp->sft_flags = + (dhp->dh_attr & ~SFT_MASK) | SFT_FDEVICE | SFT_FEOF; + sftp->sft_psp = cu_psp; + fbcopy(lpFcb->fcb_fname, sftp->sft_name, FNAME_SIZE + FEXT_SIZE); + sftp->sft_dev = dhp; + lpFcb->fcb_sftno = sft_idx; + lpFcb->fcb_curec = 0; + lpFcb->fcb_recsiz = 0; + lpFcb->fcb_fsize = 0; + lpFcb->fcb_date = dos_getdate(); + lpFcb->fcb_time = dos_gettime(); + lpFcb->fcb_rndm = 0; + return TRUE; + } + } + } + sftp->sft_status = dos_open(PriPathName, O_RDWR); + if (sftp->sft_status >= 0) + { + lpFcb->fcb_drive = FcbDrive; + lpFcb->fcb_sftno = sft_idx; + lpFcb->fcb_curec = 0; + lpFcb->fcb_recsiz = 128; + lpFcb->fcb_fsize = dos_getfsize(sftp->sft_status); + dos_getftime(sftp->sft_status, + (date FAR *) & lpFcb->fcb_date, + (time FAR *) & lpFcb->fcb_time); + lpFcb->fcb_rndm = 0; + sftp->sft_count += 1; + sftp->sft_mode = O_RDWR; + sftp->sft_attrib = 0; + sftp->sft_flags = 0; + sftp->sft_psp = cu_psp; + fbcopy((BYTE FAR *) & lpFcb->fcb_fname, (BYTE FAR *) & sftp->sft_name, FNAME_SIZE + FEXT_SIZE); + return TRUE; + } + else + return FALSE; +} + +BOOL FcbDelete(xfcb FAR * lpXfcb) +{ + COUNT FcbDrive; + + /* Build a traditional DOS file name */ + CommonFcbInit(lpXfcb, PriPathName, &FcbDrive); + + /* check for a device */ + /* if we have an extension, can't be a device */ + if (IsDevice(PriPathName)) + { + return FALSE; + } + else + { + BYTE FAR *lpOldDta = dta; + dmatch Dmatch; + + dta = (BYTE FAR *) & Dmatch; + if (dos_findfirst(D_ALL, PriPathName[1] == ':' ? &PriPathName[2] : PriPathName) != SUCCESS) + { + dta = lpOldDta; + return FALSE; + } + do + { + if (dos_delete(Dmatch.dm_name) != SUCCESS) + { + dta = lpOldDta; + return FALSE; + } + } + while (dos_findnext() == SUCCESS); + dta = lpOldDta; + return TRUE; + } +} + +BOOL FcbRename(xfcb FAR * lpXfcb) +{ + rfcb FAR *lpRenameFcb; + COUNT FcbDrive; + + /* Build a traditional DOS file name */ + lpRenameFcb = (rfcb FAR *) CommonFcbInit(lpXfcb, PriPathName, &FcbDrive); + + /* check for a device */ + /* if we have an extension, can't be a device */ + if (IsDevice(PriPathName)) + { + return FALSE; + } + else + { + BYTE FAR *lpOldDta = dta; + dmatch Dmatch; + + dta = (BYTE FAR *) & Dmatch; + if (dos_findfirst(D_ALL, PriPathName[1] == ':' ? &PriPathName[2] : PriPathName) != SUCCESS) + { + dta = lpOldDta; + return FALSE; + } + + do + { + fcb LocalFcb; + BYTE *pToName, + *pszFrom; + BYTE FAR *pFromPattern; + COUNT nIndex; + + /* First, expand the find match into fcb style */ + /* file name entry */ + /* Fill with blanks first */ + for (pToName = LocalFcb.fcb_fname, nIndex = 0; + nIndex < FNAME_SIZE; nIndex++) + { + *pToName++ = ' '; + } + for (pToName = LocalFcb.fcb_fext, nIndex = 0; + nIndex < FEXT_SIZE; nIndex++) + { + *pToName++ = ' '; + } + + /* next move in the file name while overwriting */ + /* the filler blanks */ + pszFrom = Dmatch.dm_name; + pToName = LocalFcb.fcb_fname; + for (nIndex = 0; nIndex < FNAME_SIZE; nIndex++) + { + if (*pszFrom != 0 && *pszFrom != '.') + *pToName++ = *pszFrom++; + else if (*pszFrom == '.') + { + ++pszFrom; + break; + } + else + break; + } + + if (*pszFrom != '\0') + { + pToName = LocalFcb.fcb_fext; + for (nIndex = 0; nIndex < FEXT_SIZE; nIndex++) + { + if (*pszFrom != '\0') + *pToName++ = *pszFrom++; + else + break; + } + } + + /* Overlay the pattern, skipping '?' */ + /* I'm cheating because this assumes that the */ + /* struct alignments are on byte boundaries */ + pToName = LocalFcb.fcb_fname; + for (pFromPattern = lpRenameFcb->renNewName, + nIndex = 0; nIndex < FNAME_SIZE + FEXT_SIZE; nIndex++) + { + if (*pFromPattern != '?') + *pToName++ = *pFromPattern++; + else + ++pFromPattern; + } + + /* now to build a dos name again */ + LocalFcb.fcb_drive = 0; + FcbNameInit((fcb FAR *) & LocalFcb, PriPathName, &FcbDrive); + + if (dos_rename(Dmatch.dm_name, + PriPathName[1] == ':' ? &PriPathName[2] : PriPathName) != SUCCESS) + { + dta = lpOldDta; + return FALSE; + } + } + while (dos_findnext() == SUCCESS); + dta = lpOldDta; + return TRUE; + } +} + +void MoveDirInfo(dmatch FAR * lpDmatch, struct dirent FAR * lpDir) +{ + BYTE FAR *lpToName, + FAR * lpszFrom; + COUNT nIndex; + + /* First, expand the find match into dir style */ + /* file name entry */ + /* Fill with blanks first */ + for (lpToName = lpDir->dir_name, nIndex = 0; + nIndex < FNAME_SIZE; nIndex++) + { + *lpToName++ = ' '; + } + for (lpToName = lpDir->dir_ext, nIndex = 0; + nIndex < FEXT_SIZE; nIndex++) + { + *lpToName++ = ' '; + } + + /* next move in the file name while overwriting */ + /* the filler blanks */ + lpszFrom = lpDmatch->dm_name; + lpToName = lpDir->dir_name; + for (nIndex = 0; nIndex < FNAME_SIZE; nIndex++) + { + if (*lpszFrom != 0 && *lpszFrom != '.') + *lpToName++ = *lpszFrom++; + else + break; + } + + if (*lpszFrom != '\0') + { + if (*lpszFrom == '.') + ++lpszFrom; + lpToName = lpDir->dir_ext; + for (nIndex = 0; nIndex < FEXT_SIZE; nIndex++) + { + if (*lpszFrom != '\0') + *lpToName++ = *lpszFrom++; + else + break; + } + } + for (nIndex = 0; nIndex < 10; nIndex++) + lpDir->dir_reserved[nIndex] = 0; + lpDir->dir_attrib = lpDmatch->dm_attr_fnd; + lpDir->dir_time = lpDmatch->dm_time; + lpDir->dir_date = lpDmatch->dm_date; + lpDir->dir_start = lpDmatch->dm_cluster; + lpDir->dir_size = lpDmatch->dm_size; +} + +BOOL FcbClose(xfcb FAR * lpXfcb) +{ + sft FAR *s; + + /* Convert to fcb if necessary */ + lpFcb = ExtFcbToFcb(lpXfcb); + + /* Get the SFT block that contains the SFT */ + if ((s = FcbGetSft(lpFcb->fcb_sftno)) == (sft FAR *) - 1) + return FALSE; + + /* If this is not opened another error */ + if (s->sft_count == 0) + return FALSE; + + if (s->sft_flags & SFT_FSHARED) + { + int2f_Remote_call(REM_CLOSE, 0, 0, 0, (VOID FAR *) s, 0, 0); + } + + /* now just drop the count if a device, else */ + /* call file system handler */ + if (s->sft_flags & SFT_FDEVICE) + { + s->sft_count -= 1; + return TRUE; + } + else + { + s->sft_count -= 1; + if (s->sft_count > 0) + return SUCCESS; + else + { + /* change time and set file size */ + dos_setftime(s->sft_status, + (date FAR *) & lpFcb->fcb_date, + (time FAR *) & lpFcb->fcb_time); + dos_setfsize(s->sft_status, + lpFcb->fcb_fsize); + return dos_close(s->sft_status) == SUCCESS; + } + } +} + +BOOL FcbFindFirst(xfcb FAR * lpXfcb) +{ + BYTE FAR *lpOldDta; + BYTE FAR *lpDir; + COUNT nIdx, + FcbDrive; + psp FAR *lpPsp = MK_FP(cu_psp, 0); + + /* First, move the dta to a local and change it around to match */ + /* our functions. */ + lpDir = (BYTE FAR *) dta; + dta = (BYTE FAR *) & Dmatch; + + /* Next initialze local variables by moving them from the fcb */ + lpFcb = CommonFcbInit(lpXfcb, PriPathName, &FcbDrive); + if (lpXfcb->xfcb_flag == 0xff) + { + wAttr = lpXfcb->xfcb_attrib; + fbcopy(lpXfcb, lpDir, 7); + lpDir += 7; + } + else + wAttr = D_ALL; + + *lpDir++ = PriPathName[0] - 'A'; + if (dos_findfirst(wAttr, PriPathName) != SUCCESS) + { + dta = lpPsp->ps_dta; + return FALSE; + } + + MoveDirInfo((dmatch FAR *) & Dmatch, (struct dirent FAR *)lpDir); + lpFcb->fcb_dirclst = Dmatch.dm_cluster; + lpFcb->fcb_diroff = Dmatch.dm_entry; + dta = lpPsp->ps_dta; + return TRUE; +} + +BOOL FcbFindNext(xfcb FAR * lpXfcb) +{ + BYTE FAR *lpOldDta; + BYTE FAR *lpDir; + COUNT nIdx, + FcbDrive; + psp FAR *lpPsp = MK_FP(cu_psp, 0); + + /* First, move the dta to a local and change it around to match */ + /* our functions. */ + lpDir = (BYTE FAR *) dta; + dta = (BYTE FAR *) & Dmatch; + + /* Next initialze local variables by moving them from the fcb */ + lpFcb = CommonFcbInit(lpXfcb, PriPathName, &FcbDrive); + if ((xfcb FAR *) lpFcb != lpXfcb) + { + wAttr = lpXfcb->xfcb_attrib; + fbcopy(lpXfcb, lpDir, 7); + lpDir += 7; + } + else + wAttr = D_ALL; + + /* Reconstrct the dirmatch structure from the fcb */ + *lpDir++ = FcbDrive; + Dmatch.dm_drive = FcbDrive ? FcbDrive - 1 : default_drive; + + fbcopy(lpFcb->fcb_fname, (BYTE FAR *) Dmatch.dm_name_pat, FNAME_SIZE + FEXT_SIZE); + upMem((BYTE FAR *) Dmatch.dm_name_pat, FNAME_SIZE + FEXT_SIZE); + Dmatch.dm_attr_srch = wAttr; + Dmatch.dm_entry = lpFcb->fcb_diroff; + Dmatch.dm_cluster = lpFcb->fcb_dirclst; + + if (dos_findnext() != SUCCESS) + { + dta = lpPsp->ps_dta; + return FALSE; + } + + MoveDirInfo((dmatch FAR *) & Dmatch, (struct dirent FAR *)lpDir); + lpFcb->fcb_dirclst = Dmatch.dm_cluster; + lpFcb->fcb_diroff = Dmatch.dm_entry; + dta = lpPsp->ps_dta; + return TRUE; +} +#endif + diff --git a/kernel/globals.h b/kernel/globals.h new file mode 100644 index 00000000..195226f8 --- /dev/null +++ b/kernel/globals.h @@ -0,0 +1,713 @@ +/****************************************************************/ +/* */ +/* globals.h */ +/* DOS-C */ +/* */ +/* Global data structures and declarations */ +/* */ +/* Copyright (c) 1995, 1996 */ +/* Pasquale J. Villani */ +/* All Rights Reserved */ +/* */ +/* This file is part of DOS-C. */ +/* */ +/* DOS-C is free software; you can redistribute it and/or */ +/* modify it under the terms of the GNU General Public License */ +/* as published by the Free Software Foundation; either version */ +/* 2, or (at your option) any later version. */ +/* */ +/* DOS-C is distributed in the hope that it will be useful, but */ +/* WITHOUT ANY WARRANTY; without even the implied warranty of */ +/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See */ +/* the GNU General Public License for more details. */ +/* */ +/* You should have received a copy of the GNU General Public */ +/* License along with DOS-C; see the file COPYING. If not, */ +/* write to the Free Software Foundation, 675 Mass Ave, */ +/* Cambridge, MA 02139, USA. */ +/****************************************************************/ + +/* $Logfile: C:/usr/patv/dos-c/src/kernel/globals.h_v $ */ +#ifdef VERSION_STRINGS +#ifdef MAIN +static BYTE *Globals_hRcsId = "$Id$"; +#endif +#endif + +/* + * $Log$ + * Revision 1.1 2000/05/06 19:35:18 jhall1 + * Initial revision + * + * Revision 1.16 2000/03/09 06:07:11 kernel + * 2017f updates by James Tabor + * + * Revision 1.15 1999/09/23 04:40:47 jprice + * *** empty log message *** + * + * Revision 1.13 1999/08/25 03:18:08 jprice + * ror4 patches to allow TC 2.01 compile. + * + * Revision 1.12 1999/08/10 18:03:43 jprice + * ror4 2011-03 patch + * + * Revision 1.11 1999/05/03 06:25:45 jprice + * Patches from ror4 and many changed of signed to unsigned variables. + * + * Revision 1.10 1999/04/16 21:43:40 jprice + * ror4 multi-sector IO + * + * Revision 1.9 1999/04/16 12:21:22 jprice + * Steffen c-break handler changes + * + * Revision 1.8 1999/04/16 00:53:33 jprice + * Optimized FAT handling + * + * Revision 1.7 1999/04/12 03:21:17 jprice + * more ror4 patches. Changes for multi-block IO + * + * Revision 1.6 1999/04/11 04:33:39 jprice + * ror4 patches + * + * Revision 1.4 1999/04/04 22:57:47 jprice + * no message + * + * Revision 1.3 1999/04/04 18:51:43 jprice + * no message + * + * Revision 1.2 1999/03/29 17:05:09 jprice + * ror4 changes + * + * Revision 1.1.1.1 1999/03/29 15:40:58 jprice + * New version without IPL.SYS + * + * Revision 1.5 1999/02/08 05:55:57 jprice + * Added Pat's 1937 kernel patches + * + * Revision 1.4 1999/02/01 01:48:41 jprice + * Clean up; Now you can use hex numbers in config.sys. added config.sys screen function to change screen mode (28 or 43/50 lines) + * + * Revision 1.3 1999/01/30 08:26:46 jprice + * Clean up; commented out copyright messages while we debug. + * + * Revision 1.2 1999/01/22 04:13:26 jprice + * Formating + * + * Revision 1.1.1.1 1999/01/20 05:51:01 jprice + * Imported sources + * + + Rev 1.16 06 Dec 1998 8:45:56 patv + Expanded due to new I/O subsystem. + + Rev 1.15 07 Feb 1998 20:38:00 patv + Modified stack fram to match DOS standard + + Rev 1.14 02 Feb 1998 22:33:46 patv + Fixed size of default_drive. Caused failures when break_ena was not zero. + + Rev 1.13 22 Jan 1998 4:09:24 patv + Fixed pointer problems affecting SDA + + Rev 1.12 04 Jan 1998 23:16:22 patv + Changed Log for strip utility + + Rev 1.11 03 Jan 1998 8:36:50 patv + Converted data area to SDA format + + Rev 1.10 06 Feb 1997 21:57:04 patv + Changed version format string + + Rev 1.9 06 Feb 1997 21:35:08 patv + Modified to support new version format + + Rev 1.8 22 Jan 1997 13:17:14 patv + Changed to support version.h and pre-0.92 Svante Frey bug fixes. + + Rev 1.6 16 Jan 1997 12:47:00 patv + pre-Release 0.92 feature additions + + Rev 1.5 13 Sep 1996 19:26:32 patv + Fixed boot for hard drive + + Rev 1.4 29 Aug 1996 13:07:22 patv + Bug fixes for v0.91b + + Rev 1.3 29 May 1996 21:03:34 patv + bug fixes for v0.91a + + Rev 1.2 19 Feb 1996 3:23:04 patv + Added NLS, int2f and config.sys processing + + Rev 1.1 01 Sep 1995 17:54:16 patv + First GPL release. + + Rev 1.0 02 Jul 1995 8:31:00 patv + Initial revision. + */ + +#include "device.h" +#include "mcb.h" +#include "pcb.h" +#include "date.h" +#include "time.h" +#include "fat.h" +#include "fcb.h" +#include "tail.h" +#include "process.h" +#include "dcb.h" +#include "sft.h" +#include "cds.h" +#include "exe.h" +#include "fnode.h" +#include "dirmatch.h" +#include "file.h" +#include "clock.h" +#include "kbd.h" +#include "error.h" +#include "version.h" +#include "network.h" + +/* JPP: for testing/debuging disk IO */ +/*#define DISPLAY_GETBLOCK */ + +/* */ +/* Convience switch for maintaining variables in a single location */ +/* */ +#ifdef MAIN +#define GLOBAL +#else +#define GLOBAL extern +#endif + +/* */ +/* Convience definitions of TRUE and FALSE */ +/* */ +#ifndef TRUE +#define TRUE (1) +#endif +#ifndef FALSE +#define FALSE (0) +#endif + +/* */ +/* Constants and macros */ +/* */ +/* Defaults and limits - System wide */ +#define PARSE_MAX 67 /* maximum # of bytes in path */ +#define NFILES 16 /* number of files in table */ +#define NFCBS 16 /* number of fcbs */ +#define NDEVS 8 /* number of supported devices */ +#define NSTACKS 8 /* number of stacks */ +#define NLAST 2 /* last drive */ +#define NAMEMAX PARSE_MAX /* Maximum path for CDS */ +#define NUMBUFF 6 /* Number of track buffers */ + /* -- must be at least 3 */ + +/* 0 = CON, standard input, can be redirected */ +/* 1 = CON, standard output, can be redirected */ +/* 2 = CON, standard error */ +/* 3 = AUX, auxiliary */ +/* 4 = PRN, list device */ +/* 5 = 1st user file ... */ +#define STDIN 0 +#define STDOUT 1 +#define STDERR 2 +#define STDAUX 3 +#define STDPRN 4 + +/* internal error from failure or aborted operation */ +#define ERROR -1 +#define OK 0 + +/* internal transfer direction flags */ +#define XFR_READ 1 +#define XFR_WRITE 2 + +#define RDONLY 0 +#define WRONLY 1 +#define RDWR 2 + +/* special ascii code equates */ +#define SPCL 0x00 +#define CTL_C 0x03 +#define CTL_F 0x06 +#define BELL 0x07 +#define BS 0x08 +#define HT 0x09 +#define LF 0x0a +#define CR 0x0d +#define CTL_Q 0x11 +#define CTL_S 0x13 +#define CTL_Z 0x1a +#define ESC 0x1b +#define CTL_BS 0x7f + +#define F3 0x3d +#define LEFT 0x4b +#define RIGHT 0x4d + +/* Blockio constants */ +#define DSKWRITE 1 /* dskxfr function parameters */ +#define DSKREAD 2 + +/* FAT cluster special flags */ +#define FREE 0x000 + +#define LONG_LAST_CLUSTER 0xFFFF +#define LONG_MASK 0xFFF8 +#define LONG_BAD 0xFFF0 +#define LAST_CLUSTER 0x0FFF +#define MASK 0xFF8 +#define BAD 0xFF0 + +/* Keyboard buffer maximum size */ +#ifdef LINESIZE +#undef LINESIZE +#endif +#define LINESIZE 256 + +/* */ +/* Data structures and unions */ +/* */ +/* Sector buffer structure */ +#define BUFFERSIZE 512 +struct buffer +{ + struct buffer + FAR *b_next; /* form linked list for LRU */ + BYTE b_unit; /* disk for this buffer */ + BYTE b_flag; /* buffer flags */ + UWORD b_blkno; /* block for this buffer */ + /* DOS-C: 0xffff for huge block numbers */ + BYTE b_copies; /* number of copies to write */ + UBYTE b_offset_lo; /* span between copies (low) */ + union + { + struct dpb FAR *_b_dpbp; /* pointer to DPB */ + LONG _b_huge_blkno; /* DOS-C: actual block number if >= 0xffff */ + } + _b; + UBYTE b_offset_hi; /* DOS-C: span between copies (high) */ + UBYTE b_unused; + BYTE b_buffer[BUFFERSIZE]; /* 512 byte sectors for now */ +}; + +#define b_dpbp _b._b_dpbp +#define b_huge_blkno _b._b_huge_blkno + +#define BFR_DIRTY 0x40 /* buffer modified */ +#define BFR_VALID 0x20 /* buffer contains valid data */ +#define BFR_DATA 0x08 /* buffer is from data area */ +#define BFR_DIR 0x04 /* buffer is from dir area */ +#define BFR_FAT 0x02 /* buffer is from fat area */ +#define BFR_BOOT 0x01 /* buffer is boot disk */ + +/* NLS character table type */ +typedef BYTE *UPMAP; + +/* */ +/* External Assembly variables */ +/* */ +extern struct dhdr +FAR clk_dev, /* Clock device driver */ + FAR con_dev, /* Console device driver */ + FAR prn_dev, /* Generic printer device driver */ + FAR aux_dev, /* Generic aux device driver */ + FAR blk_dev; /* Block device (Disk) driver */ +extern UWORD + ram_top, /* How much ram in Kbytes */ +#ifdef I86 + + api_sp, /* api stacks - for context */ +#endif + + api_ss, /* switching */ + usr_sp, /* user stack */ + usr_ss; +extern COUNT * +#ifdef MC68K + api_sp, /* api stacks - for context */ +#endif + + error_tos, /* error stack */ + disk_api_tos, /* API handler stack - disk fns */ + char_api_tos; /* API handler stack - char fns */ +extern BYTE + FAR last; /* first available byte of ram */ +extern struct ClockRecord + ClkRecord; + +/* */ +/* Global variables */ +/* */ +GLOBAL +seg master_env; /* Master environment segment */ + +GLOBAL BYTE + os_major, /* major version number */ + os_minor, /* minor version number */ + + rev_number /* minor version number */ +#ifdef MAIN += REV_NUMBER, +#else + , +#endif + + version_flags; /* minor version number */ +#ifdef DEBUG +GLOBAL WORD bDumpRegs +#ifdef MAIN += FALSE; +#else + ; +#endif +GLOBAL WORD bDumpRdWrParms +#ifdef MAIN += FALSE; +#else + ; +#endif +#endif + +GLOBAL BYTE *copyright +#if 0 += "(C) Copyright 1995, 1996, 1997, 1998\nPasquale J. Villani\nAll Rights Reserved\n"; +#else + ; +#endif + +GLOBAL BYTE *os_release +#ifdef MAIN +#if 0 += "DOS-C version %d.%d Beta %d [FreeDOS Release] (Build %d).\n\ +\n\ +DOS-C is free software; you can redistribute it and/or modify it under the\n\ +terms of the GNU General Public License as published by the Free Software\n\ +Foundation; either version 2, or (at your option) any later version.\n\n\ +For technical information and description of the DOS-C operating system\n\ +consult \"FreeDOS Kernel\" by Pat Villani, published by Miller\n\ +Freeman Publishing, Lawrence KS, USA (ISBN 0-87930-436-7).\n\ +\n"; +#else += "FreeDOS kernel version %d.%d.%d (Build %d) [" __DATE__ " " __TIME__ "]\n\n"; +#endif +#else + ; +#endif + +/* Globally referenced variables - WARNING: ORDER IS DEFINED IN */ +/* KERNAL.ASM AND MUST NOT BE CHANGED. DO NOT CHANGE ORDER BECAUSE THEY */ +/* ARE DOCUMENTED AS UNDOCUMENTED (?) AND HAVE MANY PROGRAMS AND TSR'S */ +/* ACCESSING THEM */ + +extern UWORD NetBios; +extern BYTE *net_name; +extern BYTE net_set_count; +extern BYTE NetDelay, + NetRetry; + +extern UWORD + first_mcb; /* Start of user memory */ +extern struct dpb +FAR *DPBp; /* First drive Parameter Block */ +extern sfttbl + FAR * sfthead; /* System File Table head */ +extern struct dhdr +FAR *clock, /* CLOCK$ device */ + FAR * syscon; /* console device */ +extern WORD + maxbksize; /* Number of Drives in system */ +extern struct buffer +FAR *firstbuf; /* head of buffers linked list */ +extern cdstbl + FAR * CDSp; /* Current Directory Structure */ +extern +struct cds FAR *current_ldt; +extern sfttbl + FAR * FCBp; /* FCB table pointer */ +extern WORD + nprotfcb; /* number of protected fcbs */ +extern BYTE + nblkdev, /* number of block devices */ + lastdrive; /* value of last drive */ +extern struct dhdr + nul_dev; +extern BYTE + LocalPath[PARSE_MAX + 3], /* Room for drive spec */ + mem_access_mode, /* memory allocation scheme */ + ErrorMode, /* Critical error flag */ + InDOS, /* In DOS critical section */ + OpenMode, /* File Open Attributes */ + SAttr, /* Attrib Mask for Dir Search */ + dosidle_flag, + njoined; /* number of joined devices */ + +extern UWORD Int21AX; + +extern struct dirent + SearchDir; + +extern struct +{ + COUNT nDrive; + BYTE szName[FNAME_SIZE + 1]; + BYTE szExt[FEXT_SIZE + 1]; +} +FcbSearchBuffer; + +extern union /* Path name parsing buffer */ +{ + BYTE _PriPathName[128]; + struct + { + BYTE _dname[NAMEMAX]; + BYTE _fname[FNAME_SIZE]; + BYTE _fext[FEXT_SIZE]; + } + _f; +} +_PriPathBuffer; +#define PriPathName _PriPathBuffer._PriPathName +#define szDirName _PriPathBuffer._f._dname +#define szFileName _PriPathBuffer._f._fname +#define szFileExt _PriPathBuffer._f._fext +#define szPriDirName _PriPathBuffer._f._dname +#define szPriFileName _PriPathBuffer._f._fname +#define szPriFileExt _PriPathBuffer._f._fext + +extern union /* Alternate path name parsing buffer */ +{ + BYTE _SecPathName[128]; + struct + { + BYTE _dname[NAMEMAX]; + BYTE _fname[FNAME_SIZE]; + BYTE _fext[FEXT_SIZE]; + } + _f; +} +_SecPathBuffer; +#define SecPathName _SecPathBuffer._SecPathName +#define szSecDirName _SecPathBuffer._f._dname +#define szSecFileName _SecPathBuffer._f._fname +#define szSecFileExt _SecPathBuffer._f._fext + +extern UWORD + wAttr; + +extern BYTE + default_drive; /* default drive for dos */ + +extern BYTE + TempBuffer[], /* Temporary general purpose buffer */ + FAR internal_data[], /* sda areas */ + FAR swap_always[], /* " " */ + FAR swap_indos[], /* " " */ + tsr, /* true if program is TSR */ + break_flg, /* true if break was detected */ + break_ena, /* break enabled flag */ + FAR * dta; /* Disk transfer area (kludge) */ +extern seg + cu_psp; /* current psp segment */ +extern iregs + FAR * user_r; /* User registers for int 21h call */ + +extern struct dirent /* Temporary directory entry */ + DirEntBuffer; + +extern request /* I/O Request packets */ + CharReqHdr, + IoReqHdr, + MediaReqHdr; + +extern fcb + FAR * lpFcb; /* Pointer to users fcb */ + +extern sfttbl + FAR * lpCurSft; + +extern BYTE + verify_ena, /* verify enabled flag */ + switchar, /* switch char */ + return_mode, /* Process termination rets */ + return_code; /* " " " */ + +extern BYTE + scr_pos; /* screen position for bs, ht, etc */ +extern WORD + BootDrive, /* Drive we came up from */ + NumFloppies; /* How many floppies we have */ + +extern keyboard + kb_buf; + +extern struct cds + TempCDS; + +/* start of uncontrolled variables */ +GLOBAL seg + RootPsp; /* Root process -- do not abort */ + +GLOBAL struct f_node + *pDirFileNode; + +GLOBAL iregs error_regs; /* registers for dump */ + +GLOBAL WORD + dump_regs; /* dump registers of bad call */ + +GLOBAL struct dpb + blk_devices[NDEVS]; + +GLOBAL struct f_node FAR +* f_nodes; /* pointer to the array */ + +GLOBAL struct buffer +FAR *lastbuf, /* tail of ditto */ + FAR * buffers; /* pointer to array of track buffers */ + +GLOBAL BYTE /* scratchpad used for working around */ + FAR * dma_scratch; /* DMA transfers during disk I/O */ + +GLOBAL iregs + FAR * ustackp, /* user stack */ + FAR * kstackp; /* kernel stack */ + +/* Start of configuration variables */ +GLOBAL struct config +{ + UBYTE cfgBuffers; /* number of buffers in the system */ + UBYTE cfgFiles; /* number of available files */ + UBYTE cfgFcbs; /* number of available FCBs */ + UBYTE cfgProtFcbs; /* number of protected FCBs */ + BYTE cfgInit[NAMEMAX]; /* init of command.com */ + BYTE cfgInitTail[NAMEMAX]; /* command.com's tail */ + BYTE cfgLastdrive; /* last drive */ + BYTE cfgStacks; /* number of stacks */ + UWORD cfgStackSize; /* stacks size for each stack */ +} +Config +#ifdef MAIN += +{ + NUMBUFF, + NFILES, + NFCBS, + 0, + "command.com", + " /P\r\n", + NLAST, + NSTACKS, + 128 +}; +#else +; +#endif + +/* */ +/* Function prototypes - automatically generated */ +/* */ +#include "proto.h" + +/* Process related functions - not under automatic generation. */ +/* Typically, these are in ".asm" files. */ +VOID +FAR cpm_entry(VOID), +INRPT FAR re_entry(VOID) /*, + INRPT FAR handle_break(VOID) */ ; +VOID +enable(VOID), +disable(VOID); +COUNT +CriticalError( + COUNT nFlag, COUNT nDrive, COUNT nError, struct dhdr FAR * lpDevice); + +#ifdef PROTO +VOID FAR CharMapSrvc(VOID); +VOID FAR set_stack(VOID); +VOID FAR restore_stack(VOID); +#ifndef IN_INIT_MOD +VOID execrh(request FAR *, struct dhdr FAR *); +#endif +VOID FAR init_call_execrh(request FAR *, struct dhdr FAR *); +VOID exit(COUNT); +/*VOID INRPT FAR handle_break(VOID); */ +VOID tmark(VOID); +BOOL tdelay(LONG); +BYTE FAR *device_end(VOID); +COUNT kb_data(VOID); +COUNT kb_input(VOID); +COUNT kb_init(VOID); +VOID setvec(UWORD, VOID(INRPT FAR *) ()); +BYTE FAR *getvec(UWORD); +COUNT con(COUNT); +VOID getdirent(BYTE FAR *, struct dirent FAR *); +VOID putdirent(struct dirent FAR *, BYTE FAR *); +#else +VOID FAR CharMapSrvc(); +VOID FAR set_stack(); +VOID FAR restore_stack(); +VOID execrh(); +VOID exit(); +/*VOID INRPT FAR handle_break(); */ +VOID tmark(); +BOOL tdelay(); +BYTE FAR *device_end(); +COUNT kb_data(); +COUNT kb_input(); +COUNT kb_init(); +VOID setvec(); +BYTE FAR *getvec(); +COUNT con(); +VOID getdirent(); +VOID putdirent(); +#endif + +/* */ +/* special word packing prototypes */ +/* */ +#ifdef NATIVE +#define getlong(vp, lp) (*(LONG *)(lp)=*(LONG *)(vp)) +#define getword(vp, wp) (*(WORD *)(wp)=*(WORD *)(vp)) +#define getbyte(vp, bp) (*(BYTE *)(bp)=*(BYTE *)(vp)) +#define fgetlong(vp, lp) (*(LONG FAR *)(lp)=*(LONG FAR *)(vp)) +#define fgetword(vp, wp) (*(WORD FAR *)(wp)=*(WORD FAR *)(vp)) +#define fgetbyte(vp, bp) (*(BYTE FAR *)(bp)=*(BYTE FAR *)(vp)) +#define fputlong(lp, vp) (*(LONG FAR *)(vp)=*(LONG FAR *)(lp)) +#define fputword(wp, vp) (*(WORD FAR *)(vp)=*(WORD FAR *)(wp)) +#define fputbyte(bp, vp) (*(BYTE FAR *)(vp)=*(BYTE FAR *)(bp)) +#else +#ifdef PROTO +VOID getword(VOID *, WORD *); +VOID getbyte(VOID *, BYTE *); +VOID fgetlong(VOID FAR *, LONG FAR *); +VOID fgetword(VOID FAR *, WORD FAR *); +VOID fgetbyte(VOID FAR *, BYTE FAR *); +VOID fputlong(LONG FAR *, VOID FAR *); +VOID fputword(WORD FAR *, VOID FAR *); +VOID fputbyte(BYTE FAR *, VOID FAR *); +#else +VOID getword(); +VOID getbyte(); +VOID fgetlong(); +VOID fgetword(); +VOID fgetbyte(); +VOID fputlong(); +VOID fputword(); +VOID fputbyte(); +#endif +#endif + +#ifdef I86 +#define setvec(n, isr) (void)(*(VOID (INRPT FAR * FAR *)())(4 * (n)) = (isr)) +#endif +#define is_leap_year(y) ((y) & 3 ? 0 : (y) % 100 ? 1 : (y) % 400 ? 1 : 0) + +/* ^Break handling */ +void spawn_int23(void); /* procsupt.asm */ +int control_break(void); /* break.c */ +void handle_break(void); /* break.c */ + + diff --git a/kernel/init-mod.h b/kernel/init-mod.h new file mode 100644 index 00000000..29f0411a --- /dev/null +++ b/kernel/init-mod.h @@ -0,0 +1,28 @@ +/* Used by `proto.h'. */ +#define IN_INIT_MOD +/* + * The null macro `INIT' can be used to allow the reader to differentiate + * between functions defined in `INIT_TEXT' and those defined in `_TEXT'. + */ +#define INIT +/* + * Functions in `INIT_TEXT' may need to call functions in `_TEXT'. The entry + * calls for the latter functions therefore need to be wrapped up with far + * entry points. + */ +#define DosExec init_call_DosExec +#define DosMemAlloc init_call_DosMemAlloc +#define dos_close init_call_dos_close +#define dos_getdate init_call_dos_getdate +#define dos_gettime init_call_dos_gettime +#define dos_open init_call_dos_open +#define dos_read init_call_dos_read +#define execrh init_call_execrh +#define fatal init_call_fatal +#define fbcopy init_call_fbcopy +#define printf init_call_printf +#define scopy init_call_scopy +#define sti init_call_sti +#define strcmp init_call_strcmp +#define strlen init_call_strlen +#define WritePCClock init_call_WritePCClock diff --git a/kernel/initoem.c b/kernel/initoem.c new file mode 100644 index 00000000..f16e1dd8 --- /dev/null +++ b/kernel/initoem.c @@ -0,0 +1,105 @@ +/****************************************************************/ +/* */ +/* initoem.c */ +/* */ +/* OEM Initializattion Functions */ +/* */ +/* Copyright (c) 1995 */ +/* Pasquale J. Villani */ +/* All Rights Reserved */ +/* */ +/* This file is part of DOS-C. */ +/* */ +/* DOS-C is free software; you can redistribute it and/or */ +/* modify it under the terms of the GNU General Public License */ +/* as published by the Free Software Foundation; either version */ +/* 2, or (at your option) any later version. */ +/* */ +/* DOS-C is distributed in the hope that it will be useful, but */ +/* WITHOUT ANY WARRANTY; without even the implied warranty of */ +/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See */ +/* the GNU General Public License for more details. */ +/* */ +/* You should have received a copy of the GNU General Public */ +/* License along with DOS-C; see the file COPYING. If not, */ +/* write to the Free Software Foundation, 675 Mass Ave, */ +/* Cambridge, MA 02139, USA. */ +/* */ +/****************************************************************/ + +#include "init-mod.h" + +#include "portab.h" +#include "globals.h" + +#ifdef VERSION_STRINGS +static BYTE *RcsId = "$Id$"; +#endif + +/* + * $Log$ + * Revision 1.1 2000/05/06 19:35:18 jhall1 + * Initial revision + * + * Revision 1.3 2000/03/09 06:07:11 kernel + * 2017f updates by James Tabor + * + * Revision 1.2 1999/08/25 03:18:08 jprice + * ror4 patches to allow TC 2.01 compile. + * + * Revision 1.1.1.1 1999/03/29 15:40:58 jprice + * New version without IPL.SYS + * + * Revision 1.5 1999/02/08 05:55:57 jprice + * Added Pat's 1937 kernel patches + * + * Revision 1.4 1999/02/01 01:48:41 jprice + * Clean up; Now you can use hex numbers in config.sys. added config.sys screen function to change screen mode (28 or 43/50 lines) + * + * Revision 1.3 1999/01/30 08:28:11 jprice + * Clean up; Fixed bug with set attribute function. + * + * Revision 1.2 1999/01/22 04:13:26 jprice + * Formating + * + * Revision 1.1.1.1 1999/01/20 05:51:01 jprice + * Imported sources + * + * + * Rev 1.4 04 Jan 1998 23:15:16 patv + * Changed Log for strip utility + * + * Rev 1.3 29 May 1996 21:03:48 patv + * bug fixes for v0.91a + * + * Rev 1.2 19 Feb 1996 3:21:34 patv + * Added NLS, int2f and config.sys processing + * + * Rev 1.1 01 Sep 1995 17:54:16 patv + * First GPL release. + * + * Rev 1.0 02 Jul 1995 8:31:54 patv + * Initial revision. + */ + +#ifdef __TURBOC__ +void __int__(int); /* TC 2.01 requires this. :( -- ror4 */ +#endif + +UWORD init_oem(void) +{ + UWORD top_k; + +#ifndef __TURBOC__ + _asm + { + int 12 h + mov top_k, + ax + } +#else + __int__(0x12); + top_k = _AX; +#endif + return top_k; +} diff --git a/kernel/int2f.asm b/kernel/int2f.asm new file mode 100644 index 00000000..4b7806f8 --- /dev/null +++ b/kernel/int2f.asm @@ -0,0 +1,232 @@ +; +; File: +; int2f.asm +; Description: +; multiplex interrupt support code +; +; Copyright (c) 1996, 1998 +; Pasquale J. Villani +; All Rights Reserved +; +; This file is part of DOS-C. +; +; DOS-C is free software; you can redistribute it and/or +; modify it under the terms of the GNU General Public License +; as published by the Free Software Foundation; either version +; 2, or (at your option) any later version. +; +; DOS-C is distributed in the hope that it will be useful, but +; WITHOUT ANY WARRANTY; without even the implied warranty of +; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See +; the GNU General Public License for more details. +; +; You should have received a copy of the GNU General Public +; License along with DOS-C; see the file COPYING. If not, +; write to the Free Software Foundation, 675 Mass Ave, +; Cambridge, MA 02139, USA. +; +; $Logfile: D:/dos-c/src/kernel/int2f.asv $ +; +; $Id$ +; +; $Log$ +; Revision 1.1 2000/05/06 19:35:18 jhall1 +; Initial revision +; +; Revision 1.3 2000/03/09 06:07:11 kernel +; 2017f updates by James Tabor +; +; Revision 1.2 1999/08/10 17:57:12 jprice +; ror4 2011-02 patch +; +; Revision 1.1.1.1 1999/03/29 15:40:59 jprice +; New version without IPL.SYS +; +; Revision 1.4 1999/02/08 05:55:57 jprice +; Added Pat's 1937 kernel patches +; +; Revision 1.3 1999/02/01 01:48:41 jprice +; Clean up; Now you can use hex numbers in config.sys. added config.sys screen function to change screen mode (28 or 43/50 lines) +; +; Revision 1.2 1999/01/22 04:13:26 jprice +; Formating +; +; Revision 1.1.1.1 1999/01/20 05:51:01 jprice +; Imported sources +; +; +; Rev 1.2 06 Dec 1998 8:48:12 patv +; Bug fixes. +; +; Rev 1.1 29 May 1996 21:03:46 patv +; bug fixes for v0.91a +; +; Rev 1.0 19 Feb 1996 3:34:38 patv +; Initial revision. +; $EndLog$ +; + + %include "segs.inc" + +segment _TEXT + extern _nul_dev:wrt DGROUP + + global _int2f_handler +_int2f_handler: + sti ; Enable interrupts + cmp ah,11h ; Network interrupt? + jne Int2f3 ; No, continue +Int2f1: + or al,al ; Installation check? + jz FarTabRetn ; yes, just return +Int2f2: + stc +FarTabRetn: + retf 2 ; Return far +Int2f3: + cmp ah,16h + je FarTabRetn ; Win Hook return fast + cmp ah,12h + je IntDosCal ; Dos Internal calls + cmp ah,10h ; SHARE.EXE interrupt? + je Int2f1 ; yes, do installation check + cmp ah,14h ; NLSFUNC.EXE interrupt? + je Int2f1 ; yes, do installation check + iret ; Default, interrupt return + +; +; added by James Tabor For Zip Drives +;Return Null Device Pointer +IntDosCal: + cmp al,02ch + jne Int2f2 + mov ax,_nul_dev + mov bx,seg _nul_dev + clc + jmp FarTabRetn + +; Int 2F Multipurpose Remote System Calls +; +; added by James Tabor jimtabor@infohwy.com +; +; int_2f_Remote_call(ax,bx,cx,dx,[es:di],si, return data * ptr) +; assume ss == ds after setup of stack in entry +; sumtimes return data *ptr is the push stack word +; + global _int2f_Remote_call +_int2f_Remote_call: + push bp + mov bp,sp + push es + push ds + push si + push di + push dx + push cx + push bx + + push ss ; hay, did I say assume + pop ds + + mov si,[bp+16] + les di,[bp+12] + mov dx,[bp+10] + mov cx,[bp+8] + mov bx,[bp+6] + mov ax,[bp+4] + + cmp al,08h ; R/W Remote File + je short int2f_r_1 + cmp al,09h + jne short int2f_r_2 +int2f_r_1: + call int2f_call + jc int2f_rfner + les di,[bp+18] ; do return data stuff + mov [es:di],cx + jmp short int2f_rfner +int2f_r_2: + cmp al,0ch ; Get Remote DPB + jne short int2f_r_3 + call int2f_call + jc int2f_rfner + les di,[bp+18] + mov [es:di+0],ax + mov [es:di+2],bx + mov [es:di+4],cx + mov [es:di+6],dx + jmp short int2f_rfner +int2f_r_3: + cmp al,0fh ; Get Remote File Attrib + jne short int2f_r_4 + call int2f_call + jc short int2f_rfner + mov si,di + les di,[bp+18] ; pointer to struct + mov [es:di+0],ax + mov [es:di+2],si ; lo + mov [es:di+4],bx ; high + mov [es:di+6],cx + mov [es:di+8],dx + mov ax,0000h + jmp short int2f_rfner +int2f_r_4: + cmp al,01eh + je short int2f_r_5 + cmp al,01fh + jne short int2f_r_6 +int2f_r_5: + push ds + push word [bp+20] + pop ds + call int2f_call + pop ds + jmp short int2f_rfner +int2f_r_6: +; +; everything else goes through here. +; + call int2f_call +int2f_rfner: + pop bx + pop cx + pop dx + pop di + pop si + pop ds + pop es + pop bp + ret +; +; Pull this one out of the Chain. +; + global _QRemote_Fn +_QRemote_Fn + push bp + mov bp,sp + push es + push ds + push si + push di + mov ax,1123h + lds si,[bp+4] + les di,[bp+8] + stc + int 2fh + pop di + pop si + pop ds + pop es + pop bp + ret + + +int2f_call: + push bp + push word [bp+18] ; very fakey, HaHa ;) + stc ; set to fail + int 2fh + pop bp + pop bp + ret + diff --git a/kernel/inthndlr.c b/kernel/inthndlr.c new file mode 100644 index 00000000..af5b30b4 --- /dev/null +++ b/kernel/inthndlr.c @@ -0,0 +1,1702 @@ +/****************************************************************/ +/* */ +/* inthndlr.c */ +/* */ +/* Interrupt Handler and Function dispatcher for Kernel */ +/* */ +/* Copyright (c) 1995 */ +/* Pasquale J. Villani */ +/* All Rights Reserved */ +/* */ +/* This file is part of DOS-C. */ +/* */ +/* DOS-C is free software; you can redistribute it and/or */ +/* modify it under the terms of the GNU General Public License */ +/* as published by the Free Software Foundation; either version */ +/* 2, or (at your option) any later version. */ +/* */ +/* DOS-C is distributed in the hope that it will be useful, but */ +/* WITHOUT ANY WARRANTY; without even the implied warranty of */ +/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See */ +/* the GNU General Public License for more details. */ +/* */ +/* You should have received a copy of the GNU General Public */ +/* License along with DOS-C; see the file COPYING. If not, */ +/* write to the Free Software Foundation, 675 Mass Ave, */ +/* Cambridge, MA 02139, USA. */ +/* */ +/****************************************************************/ + +#include "portab.h" +#include "globals.h" + +#ifdef VERSION_STRINGS +BYTE *RcsId = "$Id$"; +#endif + +/* + * $Log$ + * Revision 1.1 2000/05/06 19:35:19 jhall1 + * Initial revision + * + * Revision 1.19 2000/03/09 06:07:11 kernel + * 2017f updates by James Tabor + * + * Revision 1.18 1999/09/23 04:40:47 jprice + * *** empty log message *** + * + * Revision 1.13 1999/09/14 01:18:36 jprice + * ror4: fix int25 & 26 are not cached. + * + * Revision 1.12 1999/09/13 22:16:47 jprice + * Fix 210B function + * + * Revision 1.11 1999/08/25 03:18:08 jprice + * ror4 patches to allow TC 2.01 compile. + * + * Revision 1.10 1999/08/10 18:07:57 jprice + * ror4 2011-04 patch + * + * Revision 1.9 1999/08/10 18:03:43 jprice + * ror4 2011-03 patch + * + * Revision 1.8 1999/05/03 06:25:45 jprice + * Patches from ror4 and many changed of signed to unsigned variables. + * + * Revision 1.7 1999/04/23 04:24:39 jprice + * Memory manager changes made by ska + * + * Revision 1.6 1999/04/16 12:21:22 jprice + * Steffen c-break handler changes + * + * Revision 1.5 1999/04/11 04:33:39 jprice + * ror4 patches + * + * Revision 1.3 1999/04/04 22:57:47 jprice + * no message + * + * Revision 1.2 1999/04/04 18:51:43 jprice + * no message + * + * Revision 1.1.1.1 1999/03/29 15:41:04 jprice + * New version without IPL.SYS + * + * Revision 1.9 1999/03/23 23:38:49 jprice + * Now sets carry when we don't support a function + * + * Revision 1.8 1999/03/02 07:02:55 jprice + * Added some comments. Fixed some minor bugs. + * + * Revision 1.7 1999/03/01 05:45:08 jprice + * Added some DEBUG ifdef's so that it will compile without DEBUG defined. + * + * Revision 1.6 1999/02/08 05:55:57 jprice + * Added Pat's 1937 kernel patches + * + * Revision 1.5 1999/02/04 03:11:07 jprice + * Formating + * + * Revision 1.4 1999/02/01 01:48:41 jprice + * Clean up; Now you can use hex numbers in config.sys. added config.sys screen function to change screen mode (28 or 43/50 lines) + * + * Revision 1.3 1999/01/30 08:28:11 jprice + * Clean up; Fixed bug with set attribute function. + * + * Revision 1.2 1999/01/22 04:13:26 jprice + * Formating + * + * Revision 1.1.1.1 1999/01/20 05:51:00 jprice + * Imported sources + * + * + * Rev 1.14 06 Dec 1998 8:47:38 patv + * Expanded due to improved int 21h handler code. + * + * Rev 1.13 07 Feb 1998 20:38:46 patv + * Modified stack fram to match DOS standard + * + * Rev 1.12 22 Jan 1998 4:09:26 patv + * Fixed pointer problems affecting SDA + * + * Rev 1.11 06 Jan 1998 20:13:18 patv + * Broke apart int21_system from int21_handler. + * + * Rev 1.10 04 Jan 1998 23:15:22 patv + * Changed Log for strip utility + * + * Rev 1.9 04 Jan 1998 17:26:16 patv + * Corrected subdirectory bug + * + * Rev 1.8 03 Jan 1998 8:36:48 patv + * Converted data area to SDA format + * + * Rev 1.7 01 Aug 1997 2:00:10 patv + * COMPATIBILITY: Added return '$' in AL for function int 21h fn 09h + * + * Rev 1.6 06 Feb 1997 19:05:54 patv + * Added hooks for tsc command + * + * Rev 1.5 22 Jan 1997 13:18:32 patv + * pre-0.92 Svante Frey bug fixes. + * + * Rev 1.4 16 Jan 1997 12:46:46 patv + * pre-Release 0.92 feature additions + * + * Rev 1.3 29 May 1996 21:03:40 patv + * bug fixes for v0.91a + * + * Rev 1.2 19 Feb 1996 3:21:48 patv + * Added NLS, int2f and config.sys processing + * + * Rev 1.1 01 Sep 1995 17:54:20 patv + * First GPL release. + * + * Rev 1.0 02 Jul 1995 8:33:34 patv + * Initial revision. + */ + +#ifdef TSC +static VOID StartTrace(VOID); +static bTraceNext = FALSE; +#endif + +/* Special entry for far call into the kernel */ +#pragma argsused +VOID FAR int21_entry(iregs UserRegs) +{ + int21_handler(UserRegs); +} + +/* Normal entry. This minimizes user stack usage by avoiding local */ +/* variables needed for the rest of the handler. */ +VOID int21_syscall(iregs FAR * irp) +{ + Int21AX = irp->AX; + + switch (irp->AH) + { + /* DosVars - get/set dos variables */ + case 0x33: + switch (irp->AL) + { + /* Get Ctrl-C flag */ + case 0x00: + irp->DL = break_ena ? TRUE : FALSE; + break; + + /* Set Ctrl-C flag */ + case 0x01: + break_ena = irp->DL ? TRUE : FALSE; + break; + + /* Get Boot Drive */ + case 0x05: + irp->DL = BootDrive; + break; + + /* Get DOS-C version */ + case 0x06: + irp->BL = os_major; + irp->BH = os_minor; + irp->DL = rev_number; + irp->DH = version_flags; + break; + + default: + irp->AX = -DE_INVLDFUNC; + irp->FLAGS |= FLG_CARRY; + break; + + /* Toggle DOS-C rdwrblock trace dump */ + case 0xfd: +#ifdef DEBUG + bDumpRdWrParms = !bDumpRdWrParms; +#endif + break; + + /* Toggle DOS-C syscall trace dump */ + case 0xfe: +#ifdef DEBUG + bDumpRegs = !bDumpRegs; +#endif + break; + + /* Get DOS-C release string pointer */ + case 0xff: + irp->DX = FP_SEG(os_release); + irp->AX = FP_OFF(os_release); + break; + } + break; + + /* Set PSP */ + case 0x50: + cu_psp = irp->BX; + break; + + /* Get PSP */ + case 0x51: + irp->BX = cu_psp; + break; + + /* UNDOCUMENTED: return current psp */ + case 0x62: + irp->BX = cu_psp; + break; + + /* Normal DOS function - switch stacks */ + default: + int21_service(user_r); + break; + } +} + +VOID int21_service(iregs FAR * r) +{ + COUNT rc, + rc1; + ULONG lrc; + psp FAR *p = MK_FP(cu_psp, 0); + + p->ps_stack = (BYTE FAR *) r; + +#ifdef DEBUG + if (bDumpRegs) + { + fbcopy((VOID FAR *) user_r, (VOID FAR *) & error_regs, sizeof(iregs)); + printf("System call (21h): %02x\n", user_r->AX); + dump_regs = TRUE; + dump(); + } +#endif + +dispatch: + + /* Check for Ctrl-Break */ + switch (r->AH) + { + default: + if (!break_ena) + break; + case 0x01: + case 0x02: + case 0x03: + case 0x04: + case 0x05: + case 0x08: + case 0x09: + case 0x0a: + case 0x0b: + if (control_break()) + handle_break(); + } + + /* The dispatch handler */ + switch (r->AH) + { + /* int 21h common error handler */ + case 0x64: + case 0x6b: + default: + error_invalid: + r->AX = -DE_INVLDFUNC; + goto error_out; + error_exit: + r->AX = -rc; + error_out: + r->FLAGS |= FLG_CARRY; + break; + +#if 0 + /* Moved to simulate a 0x4c00 -- 1999/04/21 ska */ + /* Terminate Program */ + case 0x00: + if (cu_psp == RootPsp) + break; + else if (((psp FAR *) (MK_FP(cu_psp, 0)))->ps_parent == cu_psp) + break; + tsr = FALSE; + return_mode = break_flg ? 1 : 0; + return_code = r->AL; + if (DosMemCheck() != SUCCESS) + panic("MCB chain corrupted"); +#ifdef TSC + StartTrace(); +#endif + return_user(); + break; +#endif + + /* Read Keyboard with Echo */ + case 0x01: + Do_DosIdle_loop(); + r->AL = _sti(); + sto(r->AL); + break; + + /* Display Character */ + case 0x02: + sto(r->DL); + break; + + /* Auxiliary Input */ + case 0x03: + r->AL = _sti(); + break; + + /* Auxiliary Output */ + case 0x04: + sto(r->DL); + break; + + /* Print Character */ + case 0x05: + sto(r->DL); + break; + + /* Direct Cosole I/O */ + case 0x06: + if (r->DL != 0xff) + sto(r->DL); + else if (StdinBusy()) + { + r->AL = 0x00; + r->FLAGS |= FLG_ZERO; + } + else + { + r->FLAGS &= ~FLG_ZERO; + r->AL = _sti(); + } + break; + + /* Direct Console Input */ + case 0x07: + /* Read Keyboard Without Echo */ + case 0x08: + Do_DosIdle_loop(); + r->AL = _sti(); + break; + + /* Display String */ + case 0x09: + { + static COUNT scratch; + BYTE FAR *p = MK_FP(r->DS, r->DX), + FAR * q; + q = p; + while (*q != '$') + ++q; + DosWrite(STDOUT, q - p, p, (COUNT FAR *) & scratch); + } + r->AL = '$'; + break; + + /* Buffered Keyboard Input */ + case 0x0a: + ((keyboard FAR *) MK_FP(r->DS, r->DX))->kb_count = 0; + sti((keyboard FAR *) MK_FP(r->DS, r->DX)); + ((keyboard FAR *) MK_FP(r->DS, r->DX))->kb_count -= 2; + break; + + /* Check Stdin Status */ + case 0x0b: + if (StdinBusy()) + r->AL = 0xFF; + else + r->AL = 0x00; + break; + + /* Flush Buffer, Read Keayboard */ + case 0x0c: + KbdFlush(); + switch (r->AL) + { + case 0x01: + case 0x06: + case 0x07: + case 0x08: + case 0x0a: + r->AH = r->AL; + goto dispatch; + + default: + r->AL = 0x00; + break; + } + break; + + /* Reset Drive */ + case 0x0d: + flush(); + break; + + /* Set Default Drive */ + case 0x0e: + r->AL = DosSelectDrv(r->DL); + break; + + case 0x0f: + if (FcbOpen(MK_FP(r->DS, r->DX))) + r->AL = 0; + else + r->AL = 0xff; + break; + + case 0x10: + if (FcbClose(MK_FP(r->DS, r->DX))) + r->AL = 0; + else + r->AL = 0xff; + break; + + case 0x11: + if (FcbFindFirst(MK_FP(r->DS, r->DX))) + r->AL = 0; + else + r->AL = 0xff; + break; + + case 0x12: + if (FcbFindNext(MK_FP(r->DS, r->DX))) + r->AL = 0; + else + r->AL = 0xff; + break; + + case 0x13: + if (FcbDelete(MK_FP(r->DS, r->DX))) + r->AL = 0; + else + r->AL = 0xff; + break; + + case 0x14: + { + COUNT nErrorCode; + + if (FcbRead(MK_FP(r->DS, r->DX), &nErrorCode)) + r->AL = 0; + else + r->AL = nErrorCode; + break; + } + + case 0x15: + { + COUNT nErrorCode; + + if (FcbWrite(MK_FP(r->DS, r->DX), &nErrorCode)) + r->AL = 0; + else + r->AL = nErrorCode; + break; + } + + case 0x16: + if (FcbCreate(MK_FP(r->DS, r->DX))) + r->AL = 0; + else + r->AL = 0xff; + break; + + case 0x17: + if (FcbRename(MK_FP(r->DS, r->DX))) + r->AL = 0; + else + r->AL = 0xff; + break; + + /* CP/M compatibility functions */ + case 0x18: + case 0x1d: + case 0x1e: + case 0x20: +#ifndef TSC + case 0x61: +#endif + r->AL = 0; + break; + + /* Get Default Drive */ + case 0x19: + r->AL = default_drive; + break; + + /* Set DTA */ + case 0x1a: + { + psp FAR *p = MK_FP(cu_psp, 0); + + p->ps_dta = MK_FP(r->DS, r->DX); + dos_setdta(p->ps_dta); + } + break; + + /* Get Default Drive Data */ + case 0x1b: + { + BYTE FAR *p; + + FatGetDrvData(0, + (COUNT FAR *) & r->AX, + (COUNT FAR *) & r->CX, + (COUNT FAR *) & r->DX, + (BYTE FAR **) & p); + r->DS = FP_SEG(p); + r->BX = FP_OFF(p); + } + break; + + /* Get Drive Data */ + case 0x1c: + { + BYTE FAR *p; + + FatGetDrvData(r->DL, + (COUNT FAR *) & r->AX, + (COUNT FAR *) & r->CX, + (COUNT FAR *) & r->DX, + (BYTE FAR **) & p); + r->DS = FP_SEG(p); + r->BX = FP_OFF(p); + } + break; + + /* Get default DPB */ + case 0x1f: + if (default_drive < lastdrive) + { + struct dpb FAR *dpb = (struct dpb FAR *)CDSp->cds_table[default_drive].cdsDpb; + if (dpb == 0) + { + r->AL = 0xff; + break; + } + + r->DS = FP_SEG(dpb); + r->BX = FP_OFF(dpb); + r->AL = 0; + } + else + r->AL = 0xff; + break; + + /* Random read using FCB */ + case 0x21: + { + COUNT nErrorCode; + + if (FcbRandomRead(MK_FP(r->DS, r->DX), &nErrorCode)) + r->AL = 0; + else + r->AL = nErrorCode; + break; + } + + /* Random write using FCB */ + case 0x22: + { + COUNT nErrorCode; + + if (FcbRandomWrite(MK_FP(r->DS, r->DX), &nErrorCode)) + r->AL = 0; + else + r->AL = nErrorCode; + break; + } + + /* Get file size in records using FCB */ + case 0x23: + if (FcbGetFileSize(MK_FP(r->DS, r->DX))) + r->AL = 0; + else + r->AL = 0xff; + break; + + /* Set random record field in FCB */ + case 0x24: + FcbSetRandom(MK_FP(r->DS, r->DX)); + break; + + /* Set Interrupt Vector */ + case 0x25: + { + VOID(INRPT FAR * p) () = MK_FP(r->DS, r->DX); + + setvec(r->AL, p); + } + break; + + /* Dos Create New Psp */ + case 0x26: + { + psp FAR *p = MK_FP(cu_psp, 0); + + new_psp((psp FAR *) MK_FP(r->DX, 0), p->ps_size); + } + break; + + /* Read random record(s) using FCB */ + case 0x27: + { + COUNT nErrorCode; + + if (FcbRandomBlockRead(MK_FP(r->DS, r->DX), r->CX, &nErrorCode)) + r->AL = 0; + else + r->AL = nErrorCode; + break; + } + + /* Write random record(s) using FCB */ + case 0x28: + { + COUNT nErrorCode; + + if (FcbRandomBlockWrite(MK_FP(r->DS, r->DX), r->CX, &nErrorCode)) + r->AL = 0; + else + r->AL = nErrorCode; + break; + } + + /* Parse File Name */ + case 0x29: + { + BYTE FAR *lpFileName; + + lpFileName = MK_FP(r->DS, r->SI); + r->AL = FcbParseFname(r->AL, + &lpFileName, + MK_FP(r->ES, r->DI)); + r->DS = FP_SEG(lpFileName); + r->SI = FP_OFF(lpFileName); + } + break; + + /* Get Date */ + case 0x2a: + DosGetDate( + (BYTE FAR *) & (r->AL), /* WeekDay */ + (BYTE FAR *) & (r->DH), /* Month */ + (BYTE FAR *) & (r->DL), /* MonthDay */ + (COUNT FAR *) & (r->CX)); /* Year */ + break; + + /* Set Date */ + case 0x2b: + rc = DosSetDate( + (BYTE FAR *) & (r->DH), /* Month */ + (BYTE FAR *) & (r->DL), /* MonthDay */ + (COUNT FAR *) & (r->CX)); /* Year */ + if (rc != SUCCESS) + r->AL = 0xff; + else + r->AL = 0; + break; + + /* Get Time */ + case 0x2c: + DosGetTime( + (BYTE FAR *) & (r->CH), /* Hour */ + (BYTE FAR *) & (r->CL), /* Minutes */ + (BYTE FAR *) & (r->DH), /* Seconds */ + (BYTE FAR *) & (r->DL)); /* Hundredths */ + break; + + /* Set Date */ + case 0x2d: + rc = DosSetTime( + (BYTE FAR *) & (r->CH), /* Hour */ + (BYTE FAR *) & (r->CL), /* Minutes */ + (BYTE FAR *) & (r->DH), /* Seconds */ + (BYTE FAR *) & (r->DL)); /* Hundredths */ + if (rc != SUCCESS) + r->AL = 0xff; + else + r->AL = 0; + break; + + /* Set verify flag */ + case 0x2e: + verify_ena = (r->AL ? TRUE : FALSE); + break; + + /* Get DTA */ + case 0x2f: + r->ES = FP_SEG(dta); + r->BX = FP_OFF(dta); + break; + + /* Get DOS Version */ + case 0x30: + r->AL = os_major; + r->AH = os_minor; + r->BH = OEM_ID; + r->CH = REVISION_MAJOR; /* JPP */ + r->CL = REVISION_MINOR; + r->BL = REVISION_SEQ; + break; + + /* Keep Program (Terminate and stay resident) */ + case 0x31: + DosMemChange(cu_psp, r->DX < 6 ? 6 : r->DX, 0); + return_mode = 3; + return_code = r->AL; + tsr = TRUE; + return_user(); + break; + + /* Get DPB */ + case 0x32: + if (r->DL < lastdrive) + { + struct dpb FAR *dpb = CDSp->cds_table[r->DL].cdsDpb; + if (dpb == 0) + { + r->AL = 0xff; + break; + } + r->DS = FP_SEG(dpb); + r->BX = FP_OFF(dpb); + r->AL = 0; + } + else + r->AL = 0xFF; + break; + + /* Get InDOS flag */ + case 0x34: + { + BYTE FAR *p; + + p = (BYTE FAR *) ((BYTE *) & InDOS); + r->ES = FP_SEG(p); + r->BX = FP_OFF(p); + } + break; + + /* Get Interrupt Vector */ + case 0x35: + { + BYTE FAR *p; + + p = getvec((COUNT) r->AL); + r->ES = FP_SEG(p); + r->BX = FP_OFF(p); + } + break; + + /* Dos Get Disk Free Space */ + case 0x36: + DosGetFree( + (COUNT) r->DL, + (COUNT FAR *) & r->AX, + (COUNT FAR *) & r->BX, + (COUNT FAR *) & r->CX, + (COUNT FAR *) & r->DX); + break; + + /* Undocumented Get/Set Switchar */ + case 0x37: + switch (r->AL) + { + /* Get switch character */ + case 0x00: + r->DL = switchar; + r->AL = 0x00; + break; + + /* Set switch character */ + case 0x01: + switchar = r->DL; + r->AL = 0x00; + break; + + default: + goto error_invalid; + } + break; + + /* Get/Set Country Info */ + case 0x38: + { + BYTE FAR *lpTable + = (BYTE FAR *) MK_FP(r->DS, r->DX); + BYTE nRetCode; + + if (0xffff == r->DX) + { + r->BX = SetCtryInfo( + (UBYTE FAR *) & (r->AL), + (UWORD FAR *) & (r->BX), + (BYTE FAR *) & lpTable, + (UBYTE *) & nRetCode); + + if (nRetCode != 0) + { + r->AX = 0xff; + r->FLAGS |= FLG_CARRY; + } + else + { + r->AX = nRetCode; + r->FLAGS &= ~FLG_CARRY; + } + } + else + { + r->BX = GetCtryInfo(&(r->AL), &(r->BX), lpTable); + r->FLAGS &= ~FLG_CARRY; + } + } + break; + + /* Dos Create Directory */ + case 0x39: + rc = dos_mkdir((BYTE FAR *) MK_FP(r->DS, r->DX)); + if (rc != SUCCESS) + goto error_exit; + else + { + r->FLAGS &= ~FLG_CARRY; + } + break; + + /* Dos Remove Directory */ + case 0x3a: + rc = dos_rmdir((BYTE FAR *) MK_FP(r->DS, r->DX)); + if (rc != SUCCESS) + goto error_exit; + else + { + r->FLAGS &= ~FLG_CARRY; + } + break; + + /* Dos Change Directory */ + case 0x3b: + if ((rc = DosChangeDir((BYTE FAR *) MK_FP(r->DS, r->DX))) < 0) + goto error_exit; + else + { + r->FLAGS &= ~FLG_CARRY; + } + break; + + /* Dos Create File */ + case 0x3c: + if ((rc = DosCreat(MK_FP(r->DS, r->DX), r->CX)) < 0) + goto error_exit; + else + { + r->AX = rc; + r->FLAGS &= ~FLG_CARRY; + } + break; + + /* Dos Open */ + case 0x3d: + if ((rc = DosOpen(MK_FP(r->DS, r->DX), r->AL)) < 0) + goto error_exit; + else + { + r->AX = rc; + r->FLAGS &= ~FLG_CARRY; + } + break; + + /* Dos Close */ + case 0x3e: + if ((rc = DosClose(r->BX)) < 0) + goto error_exit; + else + r->FLAGS &= ~FLG_CARRY; + break; + + /* Dos Read */ + case 0x3f: + rc = DosRead(r->BX, r->CX, MK_FP(r->DS, r->DX), (COUNT FAR *) & rc1); + + if (rc1 != SUCCESS) + { + r->FLAGS |= FLG_CARRY; + r->AX = -rc1; + } + else + { + r->FLAGS &= ~FLG_CARRY; + r->AX = rc; + } + break; + + /* Dos Write */ + case 0x40: + rc = DosWrite(r->BX, r->CX, MK_FP(r->DS, r->DX), (COUNT FAR *) & rc1); + if (rc1 != SUCCESS) + { + r->FLAGS |= FLG_CARRY; + r->AX = -rc1; + } + else + { + r->FLAGS &= ~FLG_CARRY; + r->AX = rc; + } + break; + + /* Dos Delete File */ + case 0x41: + rc = dos_delete((BYTE FAR *) MK_FP(r->DS, r->DX)); + if (rc < 0) + { + r->FLAGS |= FLG_CARRY; + r->AX = -rc1; + } + else + r->FLAGS &= ~FLG_CARRY; + break; + + /* Dos Seek */ + case 0x42: + if ((rc = DosSeek(r->BX, (LONG) ((((LONG) (r->CX)) << 16) + r->DX), r->AL, &lrc)) < 0) + goto error_exit; + else + { + r->DX = (lrc >> 16); + r->AX = lrc & 0xffff; + r->FLAGS &= ~FLG_CARRY; + } + break; + + /* Get/Set File Attributes */ + case 0x43: + switch (r->AL) + { + case 0x00: + rc = DosGetFattr((BYTE FAR *) MK_FP(r->DS, r->DX), (UWORD FAR *) & r->CX); + if (rc < SUCCESS) + goto error_exit; + else + { + r->FLAGS &= ~FLG_CARRY; + } + break; + + case 0x01: + rc = DosSetFattr((BYTE FAR *) MK_FP(r->DS, r->DX), (UWORD FAR *) & r->CX); + if (rc != SUCCESS) + goto error_exit; + else + r->FLAGS &= ~FLG_CARRY; + break; + + default: + goto error_invalid; + } + break; + + /* Device I/O Control */ + case 0x44: + { + rc = DosDevIOctl(r, (COUNT FAR *) & rc1); + + if (rc1 != SUCCESS) + { + r->FLAGS |= FLG_CARRY; + r->AX = -rc1; + } + else + { + r->FLAGS &= ~FLG_CARRY; + } + } + break; + + /* Duplicate File Handle */ + case 0x45: + rc = DosDup(r->BX); + if (rc < SUCCESS) + goto error_exit; + else + { + r->FLAGS &= ~FLG_CARRY; + r->AX = rc; + } + break; + + /* Force Duplicate File Handle */ + case 0x46: + rc = DosForceDup(r->BX, r->CX); + if (rc < SUCCESS) + goto error_exit; + else + r->FLAGS &= ~FLG_CARRY; + break; + + /* Get Current Directory */ + case 0x47: + if ((rc = DosGetCuDir(r->DL, MK_FP(r->DS, r->SI))) < 0) + goto error_exit; + else + { + r->FLAGS &= ~FLG_CARRY; + r->AX = 0x0100; /*jpp: from interrupt list */ + } + break; + + /* Allocate memory */ + case 0x48: + if ((rc = DosMemAlloc(r->BX, mem_access_mode, &(r->AX), &(r->BX))) < 0) + { + DosMemLargest(&(r->BX)); + goto error_exit; + } + else + { + ++(r->AX); /* DosMemAlloc() returns seg of MCB rather than data */ + r->FLAGS &= ~FLG_CARRY; + } + break; + + /* Free memory */ + case 0x49: + if ((rc = DosMemFree((r->ES) - 1)) < 0) + goto error_exit; + else + r->FLAGS &= ~FLG_CARRY; + break; + + /* Set memory block size */ + case 0x4a: + { + UWORD maxSize; + + if ((rc = DosMemChange(r->ES, r->BX, &maxSize)) < 0) + { + if (rc == DE_NOMEM) + r->BX = maxSize; + +#if 0 + if (cu_psp == r->ES) + { + + psp FAR *p; + + p = MK_FP(cu_psp, 0); + p->ps_size = r->BX + cu_psp; + } +#endif + goto error_exit; + } + else + r->FLAGS &= ~FLG_CARRY; + + break; + } + + /* Load and Execute Program */ + case 0x4b: + break_flg = FALSE; + + if ((rc = DosExec(r->AL, MK_FP(r->ES, r->BX), MK_FP(r->DS, r->DX))) + != SUCCESS) + goto error_exit; + else + r->FLAGS &= ~FLG_CARRY; + break; + + /* Terminate Program */ + case 0x00: + r->AX = 0x4c00; + + /* End Program */ + case 0x4c: + if (cu_psp == RootPsp + || ((psp FAR *) (MK_FP(cu_psp, 0)))->ps_parent == cu_psp) + break; + tsr = FALSE; +/* int2f_Remote_call(0x1122, 0, 0, 0, 0, 0, 0); + int2f_Remote_call(REM_CLOSEALL, 0, 0, 0, 0, 0, 0); + */ + if (ErrorMode) + { + ErrorMode = FALSE; + return_mode = 2; + } + else if (break_flg) + { + break_flg = FALSE; + return_mode = 1; + } + else + { + return_mode = 0; + } + return_code = r->AL; + if (DosMemCheck() != SUCCESS) + panic("MCB chain corrupted"); +#ifdef TSC + StartTrace(); +#endif + return_user(); + break; + + /* Get Child-program Return Value */ + case 0x4d: + r->AL = return_code; + r->AH = return_mode; + break; + + /* Dos Find First */ + case 0x4e: + { + /* dta for this call is set on entry. This */ + /* needs to be changed for new versions. */ + if ((rc = DosFindFirst((UCOUNT) r->CX, (BYTE FAR *) MK_FP(r->DS, r->DX))) < 0) + goto error_exit; + else + { + r->AX = 0; + r->FLAGS &= ~FLG_CARRY; + } + } + break; + + /* Dos Find Next */ + case 0x4f: + { + /* dta for this call is set on entry. This */ + /* needs to be changed for new versions. */ + if ((rc = DosFindNext()) < 0) + { + r->AX = -rc; + + if (r->AX == 2) + r->AX = 18; + + r->FLAGS |= FLG_CARRY; + } + else + { + r->FLAGS &= ~FLG_CARRY; + } + } + break; + + /* ************UNDOCUMENTED************************************* */ + /* Get List of Lists */ + case 0x52: + { + BYTE FAR *p; + + p = (BYTE FAR *) & DPBp; + r->ES = FP_SEG(p); + r->BX = FP_OFF(p); + } + break; + + /* Get verify state */ + case 0x54: + r->AL = (verify_ena ? TRUE : FALSE); + break; + + /* ************UNDOCUMENTED************************************* */ + /* Dos Create New Psp & set p_size */ + case 0x55: + new_psp((psp FAR *) MK_FP(r->DX, 0), r->SI); + break; + + /* Dos Rename */ + case 0x56: + rc = dos_rename( + (BYTE FAR *) MK_FP(r->DS, r->DX), /* OldName */ + (BYTE FAR *) MK_FP(r->ES, r->DI)); /* NewName */ + if (rc < SUCCESS) + goto error_exit; + else + { + r->FLAGS &= ~FLG_CARRY; + } + break; + + /* Get/Set File Date and Time */ + case 0x57: + switch (r->AL) + { + case 0x00: + rc = DosGetFtime( + (COUNT) r->BX, /* Handle */ + (date FAR *) & r->DX, /* FileDate */ + (time FAR *) & r->CX); /* FileTime */ + if (rc < SUCCESS) + goto error_exit; + else + r->FLAGS &= ~FLG_CARRY; + break; + + case 0x01: + rc = DosSetFtime( + (COUNT) r->BX, /* Handle */ + (date FAR *) & r->DX, /* FileDate */ + (time FAR *) & r->CX); /* FileTime */ + if (rc < SUCCESS) + goto error_exit; + else + r->FLAGS &= ~FLG_CARRY; + break; + + default: + goto error_invalid; + } + break; + + /* Get/Set Allocation Strategy */ + case 0x58: + switch (r->AL) + { + case 0x00: + r->AX = mem_access_mode; + break; + + case 0x01: + if (((COUNT) r->BX) < 0 || r->BX > 2) + goto error_invalid; + else + { + mem_access_mode = r->BX; + r->FLAGS &= ~FLG_CARRY; + } + break; + + default: + goto error_invalid; +#ifdef DEBUG + case 0xff: + show_chain(); + break; +#endif + } + break; + + /* Create Temporary File */ + case 0x5a: + if ((rc = DosMkTmp(MK_FP(r->DS, r->DX), r->CX)) < 0) + goto error_exit; + else + { + r->AX = rc; + r->FLAGS &= ~FLG_CARRY; + } + break; + + /* Create New File */ + case 0x5b: + if ((rc = DosOpen(MK_FP(r->DS, r->DX), 0)) >= 0) + { + DosClose(rc); + r->AX = 80; + r->FLAGS |= FLG_CARRY; + } + else + { + if ((rc = DosCreat(MK_FP(r->DS, r->DX), r->CX)) < 0) + goto error_exit; + else + { + r->AX = rc; + r->FLAGS &= ~FLG_CARRY; + } + } + break; + + /* UNDOCUMENTED: server, share.exe and sda function */ + case 0x5d: + switch (r->AL) + { + /* Remote Server Call */ + case 0x00: + { + UWORD FAR *x = MK_FP(r->DS, r->DX); + r->AX = x[0]; + r->BX = x[1]; + r->CX = x[2]; + r->DX = x[3]; + r->SI = x[4]; + r->DI = x[5]; + r->DS = x[6]; + r->ES = x[7]; + } + goto dispatch; + + case 0x06: + r->DS = FP_SEG(internal_data); + r->SI = FP_OFF(internal_data); + r->CX = swap_always - internal_data; + r->DX = swap_indos - internal_data; + r->FLAGS &= ~FLG_CARRY; + break; + + case 0x07: + case 0x08: + case 0x09: + int2f_Remote_call(REM_PRINTREDIR, 0, 0, r->DX, 0, 0, (MK_FP(0, Int21AX))); + break; + + default: + goto error_invalid; + } + break; + + case 0x5e: + switch (r->AL) + { + case 0x00: + r->CX = get_machine_name(MK_FP(r->DS, r->DX)); + break; + + case 0x01: + set_machine_name(MK_FP(r->DS, r->DX), r->CX); + break; + + default: + int2f_Remote_call(REM_PRINTSET, r->BX, r->CX, r->DX, (MK_FP(r->ES, r->DI)), r->SI, (MK_FP(r->DS, Int21AX))); + break; + } + break; + + case 0x5f: + switch (r->AL) + { + case 0x07: + CDSp->cds_table[r->DL].cdsFlags |= 0x100; + break; + + case 0x08: + CDSp->cds_table[r->DL].cdsFlags &= ~0x100; + break; + + default: + int2f_Remote_call(REM_DOREDIRECT, r->BX, r->CX, r->DX, (MK_FP(r->ES, r->DI)), r->SI, (MK_FP(r->DS, Int21AX))); + break; + } + break; + + case 0x60: /* TRUENAME */ + if ((rc = truename(MK_FP(r->DS, r->SI), + adjust_far(MK_FP(r->ES, r->DI)), TRUE)) != SUCCESS) + goto error_exit; + else + { + r->FLAGS &= ~FLG_CARRY; + } + break; + +#ifdef TSC + /* UNDOCUMENTED: no-op */ + /* */ + /* DOS-C: tsc support */ + case 0x61: +#ifdef DEBUG + switch (r->AL) + { + case 0x01: + bTraceNext = TRUE; + break; + + case 0x02: + bDumpRegs = FALSE; + break; + } +#endif + r->AL = 0x00; + break; +#endif + + /* UNDOCUMENTED: return current psp */ + case 0x62: + r->BX = cu_psp; + break; + + /* UNDOCUMENTED: Double byte and korean tables */ + case 0x63: + { +#ifdef DBLBYTE + static char dbcsTable[2] = + { + 0, 0 + }; + void FAR *dp = &dbcsTable; + + r->DS = FP_SEG(dp); + r->SI = FP_OFF(dp); + r->AL = 0; +#else + /* not really supported, but will pass. */ + r->AL = 0x00; /*jpp: according to interrupt list */ +#endif + break; + } + + /* Extended country info */ + case 0x65: + if (r->AL <= 0x7) + { + if (ExtCtryInfo( + r->AL, + r->BX, + r->CX, + MK_FP(r->ES, r->DI))) + r->FLAGS &= ~FLG_CARRY; + else + goto error_invalid; + } + else if ((r->AL >= 0x20) && (r->AL <= 0x22)) + { + switch (r->AL) + { + case 0x20: + r->DL = upChar(r->DL); + goto okay; + + case 0x21: + upMem( + MK_FP(r->DS, r->DX), + r->CX); + goto okay; + + case 0x22: + upString(MK_FP(r->DS, r->DX)); + okay: + r->FLAGS &= ~FLG_CARRY; + break; + + case 0x23: + r->AX = yesNo(r->DL); + goto okay; + + default: + goto error_invalid; + } + } + else + r->FLAGS |= FLG_CARRY; + break; + + /* Code Page functions */ + case 0x66: + switch (r->AL) + { + case 1: + GetGlblCodePage( + (UWORD FAR *) & (r->BX), + (UWORD FAR *) & (r->DX)); + goto okay_66; + + case 2: + SetGlblCodePage( + (UWORD FAR *) & (r->BX), + (UWORD FAR *) & (r->DX)); + okay_66: + r->FLAGS &= ~FLG_CARRY; + break; + + default: + goto error_invalid; + } + break; + + /* Set Max file handle count */ + case 0x67: + if ((rc = SetJFTSize(r->BX)) != SUCCESS) + goto error_exit; + else + { + r->FLAGS &= ~FLG_CARRY; + } + break; + + /* Flush file buffer -- dummy function right now. */ + case 0x68: + r->FLAGS &= ~FLG_CARRY; + break; + } + +#ifdef DEBUG + if (bDumpRegs) + { + fbcopy((VOID FAR *) user_r, (VOID FAR *) & error_regs, + sizeof(iregs)); + dump_regs = TRUE; + dump(); + } +#endif +} + +/* terminate handler */ +VOID INRPT FAR int22_handler(void) +{ +} + +#if 0 + /* No kernel INT-23 handler required no longer -- 1999/04/15 ska */ +/* ctrl-Break handler */ +#pragma argsused +VOID INRPT FAR int23_handler(int es, int ds, int di, int si, int bp, int sp, int bx, int dx, int cx, int ax, int ip, int cs, int flags) +{ + tsr = FALSE; + return_mode = 1; + return_code = -1; + mod_sto(CTL_C); + DosMemCheck(); +#ifdef TSC + StartTrace(); +#endif + return_user(); +} +#endif + +/* Structures needed for int 25 / int 26 */ +struct HugeSectorBlock +{ + ULONG blkno; + WORD nblks; + BYTE FAR *buf; +}; + +struct int25regs +{ + UWORD es, + ds; + UWORD di, + si, + bp, + sp; + UWORD bx, + dx, + cx, + ax; + UWORD flags, + ip, + cs; +}; + +/* this function is called from an assembler wrapper function */ +VOID int25_handler(struct int25regs FAR * r) +{ + ULONG blkno; + UWORD nblks; + BYTE FAR *buf; + UBYTE drv = r->ax & 0xFF; + + InDOS++; + + if (r->cx == 0xFFFF) + { + struct HugeSectorBlock FAR *lb = MK_FP(r->ds, r->bx); + blkno = lb->blkno; + nblks = lb->nblks; + buf = lb->buf; + } + else + { + nblks = r->cx; + blkno = r->dx; + buf = MK_FP(r->ds, r->bx); + } + + if (drv >= nblkdev) + { + r->ax = 0x202; + r->flags |= FLG_CARRY; + return; + } + + if (!dskxfer(drv, blkno, buf, nblks, DSKREAD)) + { + /* XXX: should tell the user exactly what the error was */ + r->ax = 0x202; + r->flags |= FLG_CARRY; + return; + } + + r->ax = 0; + r->flags &= ~FLG_CARRY; + --InDOS; +} + +VOID int26_handler(struct int25regs FAR * r) +{ + ULONG blkno; + UWORD nblks; + BYTE FAR *buf; + UBYTE drv = r->ax & 0xFF; + + InDOS++; + + if (r->cx == 0xFFFF) + { + struct HugeSectorBlock FAR *lb = MK_FP(r->ds, r->bx); + blkno = lb->blkno; + nblks = lb->nblks; + buf = lb->buf; + } + else + { + nblks = r->cx; + blkno = r->dx; + buf = MK_FP(r->ds, r->bx); + } + + if (drv >= nblkdev) + { + r->ax = 0x202; + r->flags |= FLG_CARRY; + return; + } + + if (!dskxfer(drv, blkno, buf, nblks, DSKWRITE)) + { + /* XXX: should tell the user exactly what the error was */ + r->ax = 0x202; + r->flags |= FLG_CARRY; + return; + } + + setinvld(drv); + + r->ax = 0; + r->flags &= ~FLG_CARRY; + --InDOS; +} + +VOID INRPT FAR int28_handler(void) +{ +} + +VOID INRPT FAR int2a_handler(void) +{ +} + +VOID INRPT FAR empty_handler(void) +{ +} + +#ifdef TSC +static VOID StartTrace(VOID) +{ + if (bTraceNext) + { +#ifdef DEBUG + bDumpRegs = TRUE; +#endif + bTraceNext = FALSE; + } +#ifdef DEBUG + else + bDumpRegs = FALSE; +#endif +} +#endif + diff --git a/kernel/io.asm b/kernel/io.asm new file mode 100644 index 00000000..bec1d6ef --- /dev/null +++ b/kernel/io.asm @@ -0,0 +1,619 @@ +; +; File: +; io.asm +; Description: +; DOS-C I/O Subsystem +; +; Copyright (c) 1998 +; Pasquale J. Villani +; All Rights Reserved +; +; This file is part of DOS-C. +; +; DOS-C is free software; you can redistribute it and/or +; modify it under the terms of the GNU General Public License +; as published by the Free Software Foundation; either version +; 2, or (at your option) any later version. +; +; DOS-C is distributed in the hope that it will be useful, but +; WITHOUT ANY WARRANTY; without even the implied warranty of +; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See +; the GNU General Public License for more details. +; +; You should have received a copy of the GNU General Public +; License along with DOS-C; see the file COPYING. If not, +; write to the Free Software Foundation, 675 Mass Ave, +; Cambridge, MA 02139, USA. +; +; $Header$ +; +; $Log$ +; Revision 1.1 2000/05/06 19:35:20 jhall1 +; Initial revision +; +; Revision 1.3 2000/03/09 06:07:11 kernel +; 2017f updates by James Tabor +; +; Revision 1.2 1999/08/10 17:57:12 jprice +; ror4 2011-02 patch +; +; Revision 1.1.1.1 1999/03/29 15:41:07 jprice +; New version without IPL.SYS +; +; Revision 1.1 1999/02/08 05:55:57 jprice +; Added Pat's 1937 kernel patches +; +; $EndLog$ +; + + %include "segs.inc" + + extern ConTable:wrt TGROUP + extern LptTable:wrt TGROUP + extern ComTable:wrt TGROUP + extern uPrtNo:wrt TGROUP + extern CommonNdRdExit:wrt TGROUP + extern _NumFloppies:wrt DGROUP + extern blk_stk_top:wrt DGROUP + extern clk_stk_top:wrt DGROUP + extern _blk_driver:wrt TGROUP + extern _clk_driver:wrt TGROUP + +;--------------------------------------------------- +; +; Device entry points +; +; This really should be a struct and go into a request.inc file +; +cmdlen equ 0 ; Length of this command +unit equ 1 ; Subunit Specified +cmd equ 2 ; Command Code +status equ 3 ; Status +media equ 13 ; Media Descriptor +trans equ 14 ; Transfer Address +count equ 18 ; Count of blocks or characters +start equ 20 ; First block to transfer +vid equ 22 ; Volume id pointer +huge equ 26 ; First block (32-bit) to transfer + +; +; The following is the "array" of device driver headers for the internal +; devices. There is one header per device including special aux: and prn: +; pseudo devices. These psuedo devices are necessary for printer +; redirection, i.e., serial or parallel ports, and com port aux selection. +; +; The devices are linked into each other and terminate with a -1 next +; pointer. This saves some time on boot up and also allows us to throw all +; device initialization into a single io_init function that may be placed +; into a discardable code segmemnt. +; +segment _IO_FIXED_DATA + + ; + ; The "CON" device + ; + ; This device is the standard console device used by + ; DOS-C and kernel + ; + global _con_dev +_con_dev equ $ + dw _prn_dev,TGROUP + dw 8013h ; con device (stdin & stdout) + dw GenStrategy + dw ConIntr + db 'CON ' + + ; + ; Generic prn device that can be redirected via mode + ; + global _prn_dev +_prn_dev dw _aux_dev,TGROUP + dw 0A040h + dw GenStrategy + dw PrnIntr + db 'PRN ' + + ; + ; Generic aux device that can be redirected via mode + ; + global _aux_dev +_aux_dev dw _Lpt1Dev,TGROUP + dw 8000h + dw GenStrategy + dw AuxIntr + db 'AUX ' + + ; + ; Printer device drivers + ; +_Lpt1Dev dw _Lpt2Dev,TGROUP + dw 0A040h + dw GenStrategy + dw Lpt1Intr + db 'LPT1 ' +_Lpt2Dev dw _Lpt3Dev,TGROUP + dw 0A040h + dw GenStrategy + dw Lpt2Intr + db 'LPT2 ' +_Lpt3Dev dw _Com1Dev,TGROUP + dw 0A040h + dw GenStrategy + dw Lpt3Intr + db 'LPT3 ' + + ; + ; Com device drivers + ; +_Com1Dev dw _Com2Dev,TGROUP + dw 8000h + dw GenStrategy + dw AuxIntr + db 'COM1 ' +_Com2Dev dw _Com3Dev,TGROUP + dw 8000h + dw GenStrategy + dw Com2Intr + db 'COM2 ' +_Com3Dev dw _Com4Dev,TGROUP + dw 8000h + dw GenStrategy + dw Com3Intr + db 'COM3 ' +_Com4Dev dw _clk_dev,TGROUP + dw 8000h + dw GenStrategy + dw Com4Intr + db 'COM4 ' + + ; + ; Header for clock device + ; + global _clk_dev +_clk_dev equ $ + dw _blk_dev,TGROUP + dw 8004h ; clock device + dw GenStrategy + dw clk_entry + db 'CLOCK$ ' + + ; + ; Header for device + ; + global _blk_dev +_blk_dev equ $ + dd -1 + dw 0000h ; block device + dw GenStrategy + dw blk_entry + global _nblk_rel +_nblk_rel db 4 + db 0,0,0,0,0,0,0 + + +; +; Temporary table until next release +; +segment _IO_FIXED_DATA +DiskTable db 0 + + +; +; Local storage +; + +segment _BSS +blk_dos_stk resw 1 +blk_dos_seg resw 1 +clk_dos_stk resw 1 +clk_dos_seg resw 1 + +segment _IO_TEXT + + global _ReqPktPtr +_ReqPktPtr dd 0 +uUnitNumber dw 0 + +; +; Name: +; GenStrategy +; +; Function: +; Store the pointer to the request packet passed in es:bx +; +; Description: +; Generic strategy routine. Unlike the original multitasking versions, +; this version assumes that no more thank one device driver is active +; at any time. The request is stored into memory in the one and only +; location available for that purpose. +; +GenStrategy: + mov word [cs:_ReqPktPtr],bx + mov word [cs:_ReqPktPtr+2],es + retf + + +; +; Name: +; XXXXIntr +; +; Function: +; Individual Interrupt routines for each device driver +; +; Description: +; This is actually a single routine with entry points for each device. +; The name used for the entry point is the device name with Intr +; appended to it. +; +; Funtionally, each device driver has an entry and an associated +; table. The table is a structure that consists of a control byte +; followed by an array of pointers to C functions or assembly +; subroutines that implement the individual device driver functions. +; This allows the usage of common error dummy filler code to be used. +; It also allows standardization of the calling procedure for these +; internal device driver functions. +; +; Assembler call/return convention: +; Each driver function is entered by a jump into the function and +; exits by a jump to the appropriate success or error exit routine. +; This speeds up the call and return and helps to minimize the stack +; useage. The contents of the request packet are passed to each +; routine in registers as follows: +; +; Register Function Description +; -------- -------- ----------- +; al unit Subunit Specified +; ah media Media Descriptor +; cx count Count of blocks or characters +; dx start First block to transfer +; es:di trans Transfer Address +; ds:bx reqptr Request pointer +; cs kernel code segment +; ds kernel data segment +; +; The exit routines generally set the status based on the individual +; routine. For example, _IOSuccess will clear the count where +; _IOErrCnt will subtract the remaining amount in cx from the original +; count. See each utility routine for expectations. +; +; C call/return convention: +; The C calling convention simply sets up the C stack and passes the +; request packet pointer as a far pointer to the function. Although +; the utility routine names are such that they are accesible from the +; C name space, they are cannot used. Instead, the common interrupt +; code expects a return status to set in the request packet. It is up +; to the device driver function to set the appropriate fields such as +; count when an error occurs. +; +; How to differntiate between the two calling conventions: +; This code is entirely table driven. The table is a structure that +; is generally in the _IO_FIXED_DATA segment. It consists of a flag +; byte followed by short pointers to the driver functions. Selecting +; a driver type is accomplished by setting the type bit in the flag +; (see below). +; +; 7 6 5 4 3 2 1 0 +; +---+---+---+---+---+---+---+---+ +; | | | | | | | | | +; +---+---+---+---+---+---+---+---+ +; | | | |--- Number of table entries +; | | +-------------------+ +; | | |----------------------- Reserved +; | +-------+ +; +--------------------------------- type bit (1 == C / 0 == asm) +; +ConIntr: + push si + mov si,ConTable + jmp short CharIntrEntry + +PrnIntr: + push si + push ax + xor ax,ax + jmp short LptCmnIntr + +Lpt1Intr: + push si + push ax + xor al,al + mov ah,1 + jmp short LptCmnIntr + +Lpt2Intr: + push si + push ax + mov al,1 + mov ah,2 + jmp short LptCmnIntr + +Lpt3Intr: + push si + push ax + mov al,2 + mov ah,3 + +LptCmnIntr: + mov si,LptTable + mov [cs:uPrtNo],ah + jmp short DiskIntrEntry + + +AuxIntr: + push si + push ax + xor al,al + jmp short ComCmnIntr + +Com2Intr: + push si + push ax + mov al,1 + jmp short ComCmnIntr + +Com3Intr: + push si + push ax + mov al,2 + jmp short ComCmnIntr + +Com4Intr: + push si + push ax + mov al,3 + jmp short ComCmnIntr + +ComCmnIntr: + mov si,ComTable + jmp short DiskIntrEntry + + +DskIntr: + push si + mov si,DiskTable +CharIntrEntry: + push ax +DiskIntrEntry: + push cx + push dx + push di + push bp + push ds + push es + push bx + mov byte [cs:uUnitNumber],al + lds bx,[cs:_ReqPktPtr] + test byte [cs:si],80h + je AsmType + + mov al,[bx+cmd] + cmp al,[cs:si] + ja _IOCommandError + cbw + shl ax,1 + add si,ax + xchg di,ax + + push ds + push bx + mov bp,sp + mov ax,DGROUP + mov ds,ax + cld + call word [cs:si+1] + pop cx + pop cx + jmp short StoreStatus + +AsmType: mov al,[bx+unit] + mov ah,[bx+media] + mov cx,[bx+count] + mov dx,[bx+start] + xchg di,ax + mov al,[bx+cmd] + cmp al,[cs:si] + ja _IOCommandError + cbw + shl ax,1 + add si,ax + xchg di,ax + + les di,[bx+trans] + push ax + mov ax,DGROUP + mov ds,ax + pop ax + cld + jmp word [cs:si+1] + +; +; Name: +; _IOXXXXXXX +; +; Function: +; Exit routines for internal device drivers. +; +; Description: +; These routines are the exit for internal device drivers. _IOSuccess +; is for read/write functions and correctly returns for a successful +; read/write operation by setting the remainng count to zero. _IOExit +; simply sets success bit and returns. _IODone returns complete and +; busy status. _IOCommandError returns and error status for invalid +; commands. _IOErrCnt corrects the remaining bytes for errors that +; occurred during partial read/write operation. _IOErrorExit is a +; generic error exit that sets done and error. +; + global _IOSuccess +_IOSuccess: + lds bx,[cs:_ReqPktPtr] + xor ax,ax + mov [bx+count],ax + + global _IOExit +_IOExit: + mov ah,1 + +StoreStatus: + lds bx,[cs:_ReqPktPtr] + mov [bx+status],ax + pop bx + pop es + pop ds + pop bp + pop di + pop dx + pop cx + pop ax + pop si + retf + + + global _IODone +_IODone: + mov ah,3 + jmp short StoreStatus + + global _IOCommandError +_IOCommandError: + mov al,3 + + global _IOErrCnt +_IOErrCnt: + lds bx,[cs:_ReqPktPtr] + sub [bx+count],cx + global _IOErrorExit +_IOErrorExit: + mov ah,81h + jmp short StoreStatus + +; +; Name: +; GetUnitNum +; +; Function: +; Return the internally set unit number. +; +; Description: +; Simply return the contents of uUnitNumber. This version relies on +; no segment registers and makes a safe call regardless of driver +; state. +; + global GetUnitNum +GetUnitNum: + mov dx,[cs:uUnitNumber] + ret + + ; + ; These are still old style DOS-C drivers. I'll replace + ; them in the next release + ; + + + ; + ; block device interrupt + ; + ; NOTE: This code is not standard device driver handlers + ; It is written for sperate code and data space. + ; +blk_entry: + pushf + push ax + push bx + push cx + push dx + push bp + push si + push di + push ds + push es + + ; small model + mov ax,DGROUP ; correct for segments + mov ds,ax ; ax to carry segment + mov word [blk_dos_stk],sp ; use internal stack + mov word [blk_dos_seg],ss + pushf ; put flags in bx + pop bx + cli ; no interrupts + mov ss,ax + mov sp,blk_stk_top + push bx + popf ; restore interrupt flag + mov bp,sp ; make a c frame + push word [cs:_ReqPktPtr+2] + push word [cs:_ReqPktPtr] + call _blk_driver + pop cx + pop cx + les bx,[cs:_ReqPktPtr] ; now return completion code + mov word [es:bx+status],ax ; mark operation complete + cli ; no interrupts + mov sp,[blk_dos_stk] ; use dos stack + mov ss,[blk_dos_seg] + pop es + pop ds + pop di + pop si + pop bp + pop dx + pop cx + pop bx + pop ax + popf + retf + + + + ; + ; clock device interrupt + ; + ; NOTE: This code is not standard device driver handlers + ; It is written for sperate code and data space. + ; +clk_entry: + pushf + push ax + push bx + push cx + push dx + push bp + push si + push di + push ds + push es + + ; small model + mov ax,DGROUP ; correct for segments + mov ds,ax ; ax to carry segment + mov word [clk_dos_stk],sp ; use internal stack + mov word [clk_dos_seg],ss + pushf ; put flags in bx + pop bx + cli ; no interrupts + mov ss,ax + mov sp,clk_stk_top + push bx + popf ; restore interrupt flag + mov bp,sp ; make a c frame + push word [cs:_ReqPktPtr+2] + push word [cs:_ReqPktPtr] + call _clk_driver + pop cx + pop cx + les bx,[cs:_ReqPktPtr] ; now return completion code + mov word [es:bx+status],ax ; mark operation complete + cli ; no interrupts + mov sp,[clk_dos_stk] ; use dos stack + mov ss,[clk_dos_seg] + pop es + pop ds + pop di + pop si + pop bp + pop dx + pop cx + pop bx + pop ax + popf + retf + diff --git a/kernel/io.inc b/kernel/io.inc new file mode 100644 index 00000000..46421292 --- /dev/null +++ b/kernel/io.inc @@ -0,0 +1,72 @@ +; +; File: +; io.inc +; Description: +; Segments and external common routines used by various device drivers +; +; Copyright (c) 1998 +; Pasquale J. Villani +; All Rights Reserved +; +; This file is part of DOS-C. +; +; DOS-C is free software; you can redistribute it and/or +; modify it under the terms of the GNU General Public License +; as published by the Free Software Foundation; either version +; 2, or (at your option) any later version. +; +; DOS-C is distributed in the hope that it will be useful, but +; WITHOUT ANY WARRANTY; without even the implied warranty of +; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See +; the GNU General Public License for more details. +; +; You should have received a copy of the GNU General Public +; License along with DOS-C; see the file COPYING. If not, +; write to the Free Software Foundation, 675 Mass Ave, +; Cambridge, MA 02139, USA. +; +; $Logfile: C:/usr/patv/dos-c/src/kernel/io.inv $ +; +; $Header$ +; +; $Log$ +; Revision 1.1 2000/05/06 19:35:20 jhall1 +; Initial revision +; +; Revision 1.3 1999/08/10 17:57:12 jprice +; ror4 2011-02 patch +; +; Revision 1.2 1999/03/29 17:05:09 jprice +; ror4 changes +; +; Revision 1.1.1.1 1999/03/29 15:41:08 jprice +; New version without IPL.SYS +; +; Revision 1.1 1999/02/08 05:55:57 jprice +; Added Pat's 1937 kernel patches +; +; +; Rev 1.0 06 Dec 1998 8:13:02 patv +; Initial revision. +; $EndLog$ +; + +group TGROUP _TEXT _IO_TEXT _IO_FIXED_DATA +group DGROUP _FIXED_DATA _DATA _BSS _BSSEND + +segment _TEXT class=CODE +segment _IO_TEXT class=CODE +segment _IO_FIXED_DATA class=CODE align=2 +segment _FIXED_DATA class=DATA align=16 +segment _DATA class=DATA align=2 +segment _BSS class=BSS align=2 +segment _BSSEND class=BSS + + extern _IOExit:wrt TGROUP + extern _IOSuccess:wrt TGROUP + extern _IOErrorExit:wrt TGROUP + extern _IOErrCnt:wrt TGROUP + extern _IODone:wrt TGROUP + extern _IOCommandError:wrt TGROUP + extern GetUnitNum:wrt TGROUP + extern _ReqPktPtr:wrt TGROUP diff --git a/kernel/ioctl.c b/kernel/ioctl.c new file mode 100644 index 00000000..c6304955 --- /dev/null +++ b/kernel/ioctl.c @@ -0,0 +1,356 @@ +/****************************************************************/ +/* */ +/* ioctl.c */ +/* */ +/* DOS-C ioctl system call */ +/* */ +/* Copyright (c) 1995,1998 */ +/* Pasquale J. Villani */ +/* All Rights Reserved */ +/* */ +/* This file is part of DOS-C. */ +/* */ +/* DOS-C is free software; you can redistribute it and/or */ +/* modify it under the terms of the GNU General Public License */ +/* as published by the Free Software Foundation; either version */ +/* 2, or (at your option) any later version. */ +/* */ +/* DOS-C is distributed in the hope that it will be useful, but */ +/* WITHOUT ANY WARRANTY; without even the implied warranty of */ +/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See */ +/* the GNU General Public License for more details. */ +/* */ +/* You should have received a copy of the GNU General Public */ +/* License along with DOS-C; see the file COPYING. If not, */ +/* write to the Free Software Foundation, 675 Mass Ave, */ +/* Cambridge, MA 02139, USA. */ +/****************************************************************/ + +#include "portab.h" +#include "globals.h" + +#ifdef VERSION_STRINGS +static BYTE *RcsId = "$Id$"; +#endif + +/* + * $Log$ + * Revision 1.1 2000/05/06 19:35:20 jhall1 + * Initial revision + * + * Revision 1.3 2000/03/09 06:07:11 kernel + * 2017f updates by James Tabor + * + * Revision 1.2 1999/04/04 18:51:43 jprice + * no message + * + * Revision 1.1.1.1 1999/03/29 15:41:09 jprice + * New version without IPL.SYS + * + * Revision 1.4 1999/02/08 05:55:57 jprice + * Added Pat's 1937 kernel patches + * + * Revision 1.3 1999/02/01 01:48:41 jprice + * Clean up; Now you can use hex numbers in config.sys. added config.sys screen function to change screen mode (28 or 43/50 lines) + * + * Revision 1.2 1999/01/22 04:13:26 jprice + * Formating + * + * Revision 1.1.1.1 1999/01/20 05:51:01 jprice + * Imported sources + * + * + * Rev 1.7 06 Dec 1998 8:48:22 patv + * Expanded due to new I/O subsystem. + * + * Rev 1.6 11 Jan 1998 2:06:22 patv + * Added functionality to ioctl. + * + * Rev 1.5 04 Jan 1998 23:15:18 patv + * Changed Log for strip utility + * + * Rev 1.4 16 Jan 1997 12:46:54 patv + * pre-Release 0.92 feature additions + * + * Rev 1.3 29 May 1996 21:03:30 patv + * bug fixes for v0.91a + * + * Rev 1.2 19 Feb 1996 3:21:34 patv + * Added NLS, int2f and config.sys processing + * + * Rev 1.1 01 Sep 1995 17:54:16 patv + * First GPL release. + * + * Rev 1.0 02 Jul 1995 8:32:04 patv + * Initial revision. + */ + +#ifdef PROTO +sft FAR *get_sft(COUNT); +#else +sft FAR *get_sft(); +#endif + +/* + * WARNING: this code is non-portable (8086 specific). + */ + +COUNT DosDevIOctl(iregs FAR * r, COUNT FAR * err) +{ + sft FAR *s; + struct dpb FAR *dpbp; + BYTE FAR *pBuffer = MK_FP(r->DS, r->DX); + COUNT nMode; + + /* Test that the handle is valid */ + switch (r->AL) + { + case 0x00: + case 0x01: + case 0x02: + case 0x03: + case 0x06: + case 0x07: + case 0x0a: + case 0x0c: + + /* Get the SFT block that contains the SFT */ + if ((s = get_sft(r->BX)) == (sft FAR *) - 1) + { + *err = DE_INVLDHNDL; + return 0; + } + break; + + case 0x04: + case 0x05: + case 0x08: + case 0x09: + case 0x0d: + case 0x0e: + case 0x0f: + case 0x10: + case 0x11: + if (r->BL > nblkdev) + { + *err = DE_INVLDDRV; + return 0; + } + else + { +/* + This line previously returned the deviceheader at r->bl. But, + DOS numbers its drives starting at 1, not 0. A=1, B=2, and so + on. Changed this line so it is now zero-based. + + -SRM + */ +/* JPP - changed to use default drive if drive=0 */ + if (r->BL == 0) + dpbp = &blk_devices[default_drive]; + else + dpbp = &blk_devices[r->BL - 1]; + } + break; + + case 0x0b: + /* skip, it's a special case. */ + + NetDelay = r->CX; + if (!r->DX) + NetRetry = r->DX; + break; + + default: + *err = DE_INVLDFUNC; + return 0; + } + + switch (r->AL) + { + case 0x00: + /* Get the flags from the SFT */ + r->DX = r->AX = s->sft_flags; + + /* Test for file and network SFT. These return a 0 in */ + /* the AH register. */ + if ((s->sft_flags & SFT_FSHARED) + || !(s->sft_flags & SFT_FDEVICE)) + { + r->AH = 0; + } + break; + + case 0x01: + /* sft_flags is a file, return an error because you */ + /* can't set the status of a file. */ + if (!(s->sft_flags & SFT_FDEVICE)) + { + *err = DE_INVLDFUNC; + return 0; + } + + /* Set it to what we got in the DL register from the */ + /* user. */ + r->AL = s->sft_flags_lo = SFT_FDEVICE | r->DL; + break; + + case 0x0c: + nMode = C_GENIOCTL; + goto IoCharCommon; + case 0x02: + nMode = C_IOCTLIN; + goto IoCharCommon; + case 0x10: + nMode = C_IOCTLQRY; + goto IoCharCommon; + case 0x03: + nMode = C_IOCTLOUT; + IoCharCommon: + + if ((s->sft_flags & SFT_FDEVICE) + || ((r->AL == 0x10) && !(s->sft_dev->dh_attr & ATTR_QRYIOCTL)) + || ((r->AL == 0x0c) && !(s->sft_dev->dh_attr & ATTR_GENIOCTL))) + { + if (s->sft_dev->dh_attr & SFT_FIOCTL) + { + CharReqHdr.r_unit = 0; + CharReqHdr.r_length = sizeof(request); + CharReqHdr.r_command = nMode; + CharReqHdr.r_count = r->CX; + CharReqHdr.r_trans = pBuffer; + CharReqHdr.r_status = 0; + execrh((request FAR *) & CharReqHdr, s->sft_dev); + + if (CharReqHdr.r_status & S_ERROR) + return char_error(&CharReqHdr, s->sft_dev); + if (r->AL == 0x07) + { + r->AL = + CharReqHdr.r_status & S_BUSY ? + 00 : 0xff; + } + break; + } + } + *err = DE_INVLDFUNC; + return 0; + + case 0x0d: + nMode = C_GENIOCTL; + goto IoBlockCommon; + case 0x04: + nMode = C_IOCTLIN; + goto IoBlockCommon; + case 0x11: + nMode = C_IOCTLQRY; + goto IoBlockCommon; + case 0x05: + nMode = C_IOCTLOUT; + IoBlockCommon: + if ((dpbp->dpb_device->dh_attr & ATTR_IOCTL) + || ((r->AL == 0x11) && !(dpbp->dpb_device->dh_attr & ATTR_QRYIOCTL)) + || ((r->AL == 0x0d) && !(dpbp->dpb_device->dh_attr & ATTR_GENIOCTL))) + { + *err = DE_INVLDFUNC; + return 0; + } + + CharReqHdr.r_unit = r->BL; + CharReqHdr.r_length = sizeof(request); + CharReqHdr.r_command = nMode; + CharReqHdr.r_count = r->CX; + CharReqHdr.r_trans = pBuffer; + CharReqHdr.r_status = 0; + execrh((request FAR *) & CharReqHdr, + dpbp->dpb_device); + if (r->AL == 0x08) + { + if (CharReqHdr.r_status & S_ERROR) + { + *err = DE_DEVICE; + return 0; + } + r->AX = (CharReqHdr.r_status & S_BUSY) ? 1 : 0; + } + else + { + if (CharReqHdr.r_status & S_ERROR) + { + *err = DE_DEVICE; + return 0; + } + } + break; + + case 0x06: + if (s->sft_flags & SFT_FDEVICE) + { + r->AL = s->sft_flags & SFT_FEOF ? 0 : 0xFF; + } + else + r->AL = s->sft_posit >= s->sft_size ? 0xFF : 0; + break; + + case 0x07: + if (s->sft_flags & SFT_FDEVICE) + { + goto IoCharCommon; + } + r->AL = 0; + break; + + case 0x08: + if (dpbp->dpb_device->dh_attr & ATTR_EXCALLS) + { + nMode = C_REMMEDIA; + goto IoBlockCommon; + } + *err = DE_INVLDFUNC; + return 0; + + case 0x09: + r->DX = dpbp->dpb_device->dh_attr; + break; + + case 0x0a: + r->DX = s->sft_dcb->dpb_device->dh_attr; + break; + + case 0x0e: + nMode = C_GETLDEV; + goto IoLogCommon; + case 0x0f: + nMode = C_SETLDEV; + IoLogCommon: + if ((dpbp->dpb_device->dh_attr & ATTR_GENIOCTL)) + { + if (r->BL == 0) + r->BL = default_drive; + + CharReqHdr.r_unit = r->BL; + CharReqHdr.r_length = sizeof(request); + CharReqHdr.r_command = nMode; + CharReqHdr.r_count = r->CX; + CharReqHdr.r_trans = pBuffer; + CharReqHdr.r_status = 0; + execrh((request FAR *) & CharReqHdr, + dpbp->dpb_device); + + if (CharReqHdr.r_status & S_ERROR) + *err = DE_ACCESS; + else + *err = SUCCESS; + return 0; + } + *err = DE_INVLDFUNC; + return 0; + + default: + *err = DE_INVLDFUNC; + return 0; + } + *err = SUCCESS; + return 0; +} + diff --git a/kernel/irqstack.asm b/kernel/irqstack.asm new file mode 100644 index 00000000..c3ae41d2 --- /dev/null +++ b/kernel/irqstack.asm @@ -0,0 +1,268 @@ +; File: +; irqstack.asm +; Description: +; Assembly support routines for hardware stack support +; +; Copyright (c) 1997, 1998 +; Svante Frey +; All Rights Reserved +; +; This file is part of DOS-C. +; +; DOS-C is free software; you can redistribute it and/or +; modify it under the terms of the GNU General Public License +; as published by the Free Software Foundation; either version +; 2, or (at your option) any later version. +; +; DOS-C is distributed in the hope that it will be useful, but +; WITHOUT ANY WARRANTY; without even the implied warranty of +; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See +; the GNU General Public License for more details. +; +; You should have received a copy of the GNU General Public +; License along with DOS-C; see the file COPYING. If not, +; write to the Free Software Foundation, 675 Mass Ave, +; Cambridge, MA 02139, USA. +; +; $Logfile: C:/dos-c/src/kernel/irqstack.asv $ +; +; $Id$ +; +; $Log$ +; Revision 1.1 2000/05/06 19:35:21 jhall1 +; Initial revision +; +; Revision 1.3 1999/08/10 17:57:13 jprice +; ror4 2011-02 patch +; +; Revision 1.2 1999/04/16 12:21:22 jprice +; Steffen c-break handler changes +; +; Revision 1.1.1.1 1999/03/29 15:41:10 jprice +; New version without IPL.SYS +; +; Revision 1.4 1999/02/08 05:55:57 jprice +; Added Pat's 1937 kernel patches +; +; Revision 1.3 1999/02/01 01:48:41 jprice +; Clean up; Now you can use hex numbers in config.sys. added config.sys screen function to change screen mode (28 or 43/50 lines) +; +; Revision 1.2 1999/01/22 04:13:26 jprice +; Formating +; +; Revision 1.1.1.1 1999/01/20 05:51:01 jprice +; Imported sources +; +; +; Rev 1.2 06 Dec 1998 8:49:08 patv +; Bug fixes. +; +; Rev 1.1 22 Jan 1997 13:15:34 patv +; pre-0.92 Svante Frey bug fixes +; +; Rev 1.0 16 Jan 1997 21:43:44 patv +; Initial revision. +; $EndLog$ +; + + +; Code for stack switching during hardware interrupts. + +group TGROUP _TEXT + +segment _TEXT class=CODE + +old_vectors times 16 dd 0 +stack_size dw 0 +stack_top dw 0 +stack_offs dw 0 +stack_seg dw 0 + +irq_0: push bx + mov bx, 0 * 4 + jmp short general_irq_service + +irq_1: push bx + mov bx, 1 * 4 + jmp short general_irq_service + +irq_2: push bx + mov bx, 2 * 4 + jmp short general_irq_service + +irq_3: push bx + mov bx, 3 * 4 + jmp short general_irq_service + +irq_4: push bx + mov bx, 4 * 4 + jmp short general_irq_service + +irq_5: push bx + mov bx, 5 * 4 + jmp short general_irq_service + +irq_6: push bx + mov bx, 6 * 4 + jmp short general_irq_service + +irq_7: push bx + mov bx, 7 * 4 + jmp short general_irq_service + +irq_08: push bx + mov bx, 8 * 4 + jmp short general_irq_service + +irq_09: push bx + mov bx, 9 * 4 + jmp short general_irq_service + +irq_0a: push bx + mov bx, 0ah * 4 + jmp short general_irq_service + +irq_0b: push bx + mov bx, 0bh * 4 + jmp short general_irq_service + +irq_0c: push bx + mov bx, 0ch * 4 + jmp short general_irq_service + +irq_0d: push bx + mov bx, 0dh * 4 + jmp short general_irq_service + +irq_0e: push bx + mov bx, 0eh * 4 + jmp short general_irq_service + +irq_0f: push bx + mov bx, 0fh * 4 +; jmp short general_irq_service + +general_irq_service: + push dx + push ax + push ds + + mov ax, cs + mov ds, ax + + mov ax, [stack_top] + cmp ax, [stack_offs] + jbe dont_switch + + mov dx, ss + mov ax, sp + + mov ss, [stack_seg] + mov sp, [stack_top] + + push dx ; save old SS:SP on new stack + push ax + + mov ax, [stack_size] + sub [stack_top], ax + + pushf + call far word [old_vectors+bx] + + cli + add [stack_top], ax + + pop ax ; get stored SS:SP + pop dx + + mov ss, dx ; switch back to old stack + mov sp, ax + + pop ds ; restore registers and return + pop ax + pop dx + pop bx + iret + +dont_switch: pushf + call far word [old_vectors+bx] + pop ds + pop ax + pop dx + pop bx + iret + + +segment INIT_TEXT class=INIT + +global _init_stacks +; VOID init_stacks(VOID FAR *stack_base, COUNT nStacks, WORD stackSize); + +_init_stacks: + push bp + mov bp, sp + push ds + push di + push si + + + mov ax,_TEXT + mov ds,ax + + mov bx, [bp+4] + mov dx, [bp+6] + mov ax, [bp+8] + mov cx, [bp+0ah] + + mov [stack_size], cx + mov [stack_offs], bx + mov [stack_seg], dx + + mul cx + add ax, bx + mov [stack_top], ax + + xor ax, ax + mov ds, ax + + mov ax, _TEXT + mov es, ax + + mov di, old_vectors + mov si, 8 * 4 + mov cx, 10h + rep movsw + + mov si, 70h * 4 + mov cx, 10h + rep movsw + + push ds + pop es + + mov di, 8 * 4 + mov dx, irq_0 + call set_vect + + mov di, 70h * 4 + call set_vect + + pop si + pop di + pop ds + pop bp + ret + +set_vect: + mov cx, 8 + +set_next: mov ax, dx + cli + stosw + mov ax, _TEXT + stosw + sti + add dx, irq_1 - irq_0 + loop set_next + + ret diff --git a/kernel/kernel.asm b/kernel/kernel.asm new file mode 100644 index 00000000..96848ebc --- /dev/null +++ b/kernel/kernel.asm @@ -0,0 +1,606 @@ +; +; File: +; kernel.asm +; Description: +; kernel start-up code +; +; Copyright (c) 1995, 1996 +; Pasquale J. Villani +; All Rights Reserved +; +; This file is part of DOS-C. +; +; DOS-C is free software; you can redistribute it and/or +; modify it under the terms of the GNU General Public License +; as published by the Free Software Foundation; either version +; 2, or (at your option) any later version. +; +; DOS-C is distributed in the hope that it will be useful, but +; WITHOUT ANY WARRANTY; without even the implied warranty of +; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See +; the GNU General Public License for more details. +; +; You should have received a copy of the GNU General Public +; License along with DOS-C; see the file COPYING. If not, +; write to the Free Software Foundation, 675 Mass Ave, +; Cambridge, MA 02139, USA. +; +; $Id$ +; +; $Log$ +; Revision 1.1 2000/05/06 19:35:22 jhall1 +; Initial revision +; +; Revision 1.6 2000/03/09 06:07:11 kernel +; 2017f updates by James Tabor +; +; Revision 1.5 1999/09/23 04:40:47 jprice +; *** empty log message *** +; +; Revision 1.3 1999/08/10 17:57:13 jprice +; ror4 2011-02 patch +; +; Revision 1.2 1999/04/13 15:52:57 jprice +; changes for boot loader +; +; Revision 1.1.1.1 1999/03/29 15:41:14 jprice +; New version without IPL.SYS +; +; Revision 1.4 1999/02/08 05:55:57 jprice +; Added Pat's 1937 kernel patches +; +; Revision 1.3 1999/02/01 01:48:41 jprice +; Clean up; Now you can use hex numbers in config.sys. added config.sys screen function to change screen mode (28 or 43/50 lines) +; +; Revision 1.2 1999/01/22 04:13:26 jprice +; Formating +; +; Revision 1.1.1.1 1999/01/20 05:51:01 jprice +; Imported sources +; +; Rev 1.11 06 Dec 1998 8:48:04 patv +;Bug fixes. +; +; Rev 1.10 03 Feb 1998 23:30:08 patv +;Added a start-up stack for loadable device drivers. Need the separate +;stack so that all int 21h functions can be called. +; +; Rev 1.9 22 Jan 1998 4:09:24 patv +;Fixed pointer problems affecting SDA +; +; Rev 1.8 06 Jan 1998 20:12:32 patv +;Reduced device driver stack sizes. +; +; Rev 1.7 04 Jan 1998 17:26:18 patv +;Corrected subdirectory bug +; +; Rev 1.6 03 Jan 1998 8:36:50 patv +;Converted data area to SDA format +; +; Rev 1.5 06 Feb 1997 22:43:18 patv +;Reduced stack sizes for block and clock devices. +; +; Rev 1.4 06 Feb 1997 19:05:48 patv +;Added hooks for tsc command +; +; Rev 1.3 29 May 1996 21:03:44 patv +;bug fixes for v0.91a +; +; Rev 1.2 19 Feb 1996 3:24:06 patv +;Added NLS, int2f and config.sys processing +; +; Rev 1.1 01 Sep 1995 17:54:24 patv +;First GPL release. +; +; Rev 1.0 02 Jul 1995 9:05:44 patv +;Initial revision. +; +; $EndLog$ +; + + %include "segs.inc" + + +segment _TEXT + + extern _ReqPktPtr:wrt TGROUP + +STACK_SIZE equ 384/2 ; stack allocated in words + +..start: +entry: jmp far kernel_start + +segment INIT_TEXT + + extern _main:wrt IGROUP + + ; + ; kernel start-up + ; +kernel_start: + mov ax,DGROUP + cli + mov ss,ax + mov sp,tos + int 12h ; move the init code to higher memory + mov cl,6 + shl ax,cl + mov dx,init_end+15 + mov cl,4 + shr dx,cl + sub ax,dx + mov es,ax + mov ax,cs + mov ds,ax + xor si,si + xor di,di + mov cx,init_end+1 + shr cx,1 + cld + rep movsw + push es + mov ax,cont + push ax + retf +cont: ; inititalize api stacks for high water tests + mov di,seg apistk_bottom + mov es,di + mov di,apistk_bottom + mov ax,apistk_top + sub ax,di + sar ax,1 + mov cx,ax + mov ax,09090h + cld + rep stosw + ; Now set up call frame + mov ax,ss + mov ds,ax + mov es,ax + mov bp,sp ; and set up stack frame for c + sti ; now enable them + inc bl + jns floppy + add bl,3-1-128 +floppy: mov byte [_BootDrive],bl ; tell where we came from + int 11h + mov cl,6 + shr al,cl + inc al + mov byte [_NumFloppies],al ; and how many + + mov ax,ds + mov es,ax + jmp _main + +segment INIT_TEXT_END +init_end: + +segment _TEXT + + ; + ; NUL device strategy + ; + global _nul_strtgy +_nul_strtgy: + mov word [cs:_ReqPktPtr],bx ;save rq headr + mov word [cs:_ReqPktPtr+2],es + retf + + ; + ; NUL device interrupt + ; + global _nul_intr +_nul_intr: + push es + push bx + les bx,[cs:_ReqPktPtr] ;es:bx--> rqheadr + or word [es:bx+3],100h ;set "done" flag + pop bx + pop es + retf + + extern _init_call_printf:wrt TGROUP + + global _printf + +_printf: + pop ax + push cs + push ax + jmp _init_call_printf + + +segment _FIXED_DATA + +; Because of the following bytes of data, THIS MODULE MUST BE THE FIRST +; IN THE LINK SEQUENCE. THE BYTE AT DS:0004 determines the SDA format in +; use. A 0 indicates MS-DOS 3.X style, a 1 indicates MS-DOS 4.0-6.X style. + global DATASTART +DATASTART: +dos_data db 0 + dw kernel_start + db 0 ; padding + dw 1 ; Hardcoded MS-DOS 4.0+ style + + times (0eh - ($ - DATASTART)) db 0 + global _NetBios +_NetBios db 0 ; NetBios Number + global _Num_Name +_Num_Name db 0 + + times (26h - 0ch - ($ - DATASTART)) db 0 + +; Globally referenced variables - WARNING: DO NOT CHANGE ORDER +; BECAUSE THEY ARE DOCUMENTED AS UNDOCUMENTED (?) AND HAVE +; MANY MULTIPLEX PROGRAMS AND TSR'S ACCESSING THEM + global _NetRetry +_NetRetry dw 3 ;-000c network retry count + global _NetDelay +_NetDelay dw 1 ;-000a network delay count + global _DskBuffer +_DskBuffer dd -1 ;-0008 current dos disk buffer + dw 0 ;-0004 Unread con input + global _first_mcb +_first_mcb dw 0 ;-0002 Start of user memory + global _DPBp + global MARK0026H +; A reference seems to indicate that this should start at offset 26h. +MARK0026H equ $ +_DPBp dd 0 ; 0000 First drive Parameter Block + global _sfthead +_sfthead dd 0 ; 0004 System File Table head + global _clock +_clock dd 0 ; 0008 CLOCK$ device + global _syscon +_syscon dd 0 ; 000c console device + global _maxbksize +_maxbksize dw 0 ; 0010 Number of Drives in system + global _firstbuf; +_firstbuf dd 0 ; 0012 head of buffers linked list + global _CDSp +_CDSp dd 0 ; 0016 Current Directory Structure + global _FCBp +_FCBp dd 0 ; 001a FCB table pointer + global _nprotfcb +_nprotfcb dw 0 ; 001e number of protected fcbs + global _nblkdev +_nblkdev db 0 ; 0020 number of block devices + global _lastdrive +_lastdrive db 0 ; 0021 value of last drive + global _nul_dev +_nul_dev: ; 0022 device chain root + dd -1 + dw 8004h ; attributes = char device, NUL bit set + dw _nul_strtgy + dw _nul_intr + db 'NUL ' + global _njoined +_njoined db 0 ; 0034 number of joined devices + dw 0 ; 0035 DOS 4 pointer to special names (always zero in DOS 5) +setverPtr dw 0,0 ; 0037 setver list + dw 0 ; 003B cs offset for fix a20 + dw 0 ; 003D psp of last umb exec + dw 1 ; 003F number of buffers + dw 1 ; 0041 size of pre-read buffer + global _BootDrive +_BootDrive dw 0 ; 0043 drive we booted from + db 0 ; 0044 cpu type (1 if >=386) + dw 0 ; 0045 Extended memory in KBytes +buf_info dd 0 ; 0047 disk buffer chain + dw 0 ; 004B 0 (DOS 4 = # hashing chains) + dd 0 ; 004D pre-read buffer + dw 0 ; 0051 # of sectors + db 0 ; 0053 00=conv 01=HMA + dw 0 ; 0054 deblock buf in conv +deblock_seg dw 0 ; 0056 (offset always zero) + times 3 db 0 ; 0058 unknown + dw 0 ; 005B unknown + db 0, 0FFh, 0 ; 005D unknown + db 0 ; 0060 unknown + dw 0 ; 0061 unknown +dmd_upper_link db 0 ; 0063 upper memory link flag + dw 0 ; 0064 unknown +dmd_upper_root dw 0FFFFh ; 0066 dmd_upper_root + dw 0 ; 0068 para of last mem search +SysVarEnd: + + +; Some references seem to indicate that this data should start at 01fbh in +; order to maintain 100% MS-DOS compatibility. + times (01fbh - (SysVarEnd - DATASTART)) db 0 + + global MARK01FBH +MARK01FBH equ $ + times 128 db 0 + global _kb_buf +_kb_buf db 129,0 ; initialise buffer to empty + times 128+1 db 0 ; room for 128 byte readline + LF +; +; Variables that follow are documented as part of the DOS 4.0-6.X swappable +; data area in Ralf Browns Interrupt List #56 +; +; this byte is used for ^P support + global _PrinterEcho +_PrinterEcho db 0 ;-34 - 0 = no printer echo, ~0 echo + global _verify_ena +_verify_ena db 0 ; ~0, write with verify + +; this byte is used for TAB's + global _scr_pos +_scr_pos db 0 ; Current Cursor Column + global _switchar +_switchar db '/' ;-31 - switch char + global _mem_access_mode +_mem_access_mode db 0 ;-30 - memory allocation strategy + global sharing_flag +sharing_flag db 0 ; 00 = sharing module not loaded + ; 01 = sharing module loaded, but + ; open/close for block devices + ; disabled + ; FF = sharing module loaded, + ; open/close for block devices + ; enabled (not implemented) + global _net_set_count +_net_set_count db 1 ;-28 - count the name below was set + global _net_name +_net_name db ' ' ;-27 - 15 Character Network Name + db 00 ; Terminating 0 byte + + +; +; Variables contained the the "STATE_DATA" segment contain +; information about the STATE of the current DOS Process. These +; variables must be preserved regardless of the state of the INDOS +; flag. +; +; All variables that appear in "STATE_DATA" **MUST** be declared +; in this file as the offsets from the INTERNAL_DATA variable are +; critical to the DOS applications that modify this data area. +; +; + global _ErrorMode, _InDOS + global _CritErrLocus, _CritErrCode + global _CritErrAction, _CritErrClass + global _CritErrDev, _CritErrDrive + global _dta + global _cu_psp, _default_drive + global _break_ena + global _return_code, _return_mode + global _internal_data + + global _CritPatch +_CritPatch dw 0d0ch ;-11 zero list of patched critical + dw 0d0ch ; section variables + dw 0d0ch + dw 0d0ch + dw 0d0ch + db 0 ;-01 - unknown +_internal_data: ; <-- Address returned by INT21/5D06 +_ErrorMode db 0 ; 00 - Critical Error Flag +_InDOS db 0 ; 01 - Indos Flag +_CritErrDrive db 0 ; 02 - Drive on write protect error +_CritErrLocus db 0 ; 03 - Error Locus +_CritErrCode dw 0 ; 04 - DOS format error Code +_CritErrAction db 0 ; 06 - Error Action Code +_CritErrClass db 0 ; 07 - Error Class +_CritErrDev dd 0 ; 08 - Failing Device Address +_dta dd 0 ; 0C - current DTA +_cu_psp dw 0 ; 10 - Current PSP +break_sp dw 0 ; 12 - used in int 23 +_return_code db 0 ; 14 - return code from process +_return_mode db 0 ; 15 - reason for process terminate +_default_drive db 0 ; 16 - Current Drive +_break_ena db 0 ; 17 - Break Flag + db 0 ; 18 - flag, code page switching + db 0 ; 19 - flag, copy of 18 on int 24h abort + + global _swap_always, _swap_indos +_swap_always: + + global _Int21AX +_Int21AX dw 0 ; 1A - AX from last Int 21 + + global owning_psp, _MachineId +owning_psp dw 0 ; 1C - owning psp +_MachineId dw 0 ; 1E - remote machine ID + dw 0 ; 20 - First usable mcb + dw 0 ; 22 - Best usable mcb + dw 0 ; 24 - Last usable mcb + dw 0 ; 26 - memory size in paragraphs + dw 0 ; 28 - unknown + db 0 ; 2A - unknown + db 0 ; 2B - unknown + db 0 ; 2C - unknown + global _break_flg +_break_flg db 0 ; 2D - Program aborted by ^C + db 0 ; 2E - unknown + db 0 ; 2F - not referenced + global _DayOfMonth +_DayOfMonth db 1 ; 30 - day of month + global _Month +_Month db 1 ; 31 - month + global _YearsSince1980 +_YearsSince1980 dw 0 ; 32 - year since 1980 +daysSince1980 dw 0FFFFh ; 34 - number of days since epoch + ; force rebuild on first clock read + global _DayOfWeek +_DayOfWeek db 2 ; 36 - day of week + global _Year +_Year dw 1980 ; 37 - year + global _dosidle_flag +_dosidle_flag db 0 ; 39 - unknown *no more* + global _CharReqHdr +_CharReqHdr: + global _ClkReqHdr +_ClkReqHdr times 30 db 0 ; 3A - Device driver request header + dd 0 ; 58 - pointer to driver entry + global _MediaReqHdr +_MediaReqHdr times 22 db 0 ; 5C - Device driver request header + global _IoReqHdr +_IoReqHdr times 30 db 0 ; 72 - Device driver request header + times 6 db 0 ; 90 - unknown + global _ClkRecord +_ClkRecord times 6 db 0 ; 96 - CLOCK$ transfer record + dw 0 ; 9C - unknown + global __PriPathBuffer +__PriPathBuffer times 80h db 0 ; 9E - buffer for file name + global __SecPathBuffer +__SecPathBuffer times 80h db 0 ;11E - buffer for file name + global _TempBuffer +_TempBuffer times 21 db 0 ;19E - 21 byte srch state + global _SearchDir +_SearchDir times 32 db 0 ;1B3 - 32 byte dir entry + global _TempCDS +_TempCDS times 88 db 0 ;1D3 - TemporaryCDS buffer + global _DirEntBuffer +_DirEntBuffer times 32 db 0 ;22B - space enough for 1 dir entry + global _wAttr +_wAttr dw 0 ;24B - extended FCB file attribute + + + global _SAttr +_SAttr db 0 ;24D - Attribute Mask for Dir Search + global _OpenMode +_OpenMode db 0 ;24E - File Open Attribute + +; times 3 db 0 +; global _Server_Call +;_Server_Call db 0 ;252 - Server call Func 5D sub 0 + + + ; Pad to 0570h + times (250h - ($ - _internal_data)) db 0 + global _lpUserStack +_lpUserStack dd 0 ;250 - pointer to user stack frame + + ; Pad to 057Ch + times (25ch - ($ - _internal_data)) db 0 + + global _tsr ; used by break and critical error +_tsr db 0 ;25C - handlers during termination + db 0 ;25D - padding + global term_psp +term_psp dw 0 ;25E - 0?? + global int24_esbp +int24_esbp times 2 dw 0 ;260 - pointer to criticalerr DPB + global _user_r, int21regs_off, int21regs_seg +_user_r: +int21regs_off dw 0 ;264 - pointer to int21h stack frame +int21regs_seg dw 0 + global critical_sp +critical_sp dw 0 ;268 - critical error internal stack + global current_ddsc +current_ddsc times 2 dw 0 + + ; Pad to 059ah + times (27ah - ($ - _internal_data)) db 0 + global current_device +current_device times 2 dw 0 ;27A - 0?? + global _lpCurSft +_lpCurSft times 2 dw 0 ;27e - Current SFT + global _current_ldt +_current_ldt times 2 dw 0 ;282 - Current CDS + global _lpFcb +_lpFcb times 2 dw 0 ;286 - pointer to callers FCB + global current_ifn +current_ifn dw 0 ;28A - SFT index for next open + + ; Pad to 05ceh + times (2aeh - ($ - _internal_data)) db 0 + global current_filepos +current_filepos times 2 dw 0 ;2AE - current offset in file + + ; Pad to 05f0h + times (2d0h - ($ - _internal_data)) db 0 + global _prev_user_r + global prev_int21regs_off + global prev_int21regs_seg +_prev_user_r: +prev_int21regs_off dw 0 ;2D0 - pointer to prev int 21 frame +prev_int21regs_seg dw 0 + + ; Pad to 0620h + times (300h - ($ - _internal_data)) db 0 + + global _FcbSearchBuffer ; during FCB search 1st/next use bottom +_FcbSearchBuffer: ; of error stack as scratch buffer +; times 43 db 0 ; - only used during int 21 call + global _LocalPath +_LocalPath: +; times 67 db 0 + ; stacks are made to initialize to no-ops so that high-water + ; tesing can be performed +apistk_bottom: + times STACK_SIZE dw 0 ;300 - Error Processing Stack + global _error_tos +_error_tos: + times STACK_SIZE dw 0 ;480 - Disk Function Stack + global _disk_api_tos +_disk_api_tos: + times STACK_SIZE dw 0 ;600 - Char Function Stack + global _char_api_tos +_char_api_tos: +apistk_top: + +_VolChange db 0 ;781 - volume change +_VirtOpen db 0 ;782 - virtual open flag + + ; controlled variables end at offset 78Ch so pad to end + times (78ch - ($ - _internal_data)) db 0 +_swap_indos: +; +; end of controlled variables +; + +segment _BSS + global _NumFloppies +_NumFloppies resw 1 +intr_dos_stk resw 1 +intr_dos_seg resw 1 + + + global _api_sp +_api_sp dw 0 ; api stacks - for context + global _api_ss +_api_ss dw 0 ; switching + global _usr_sp +_usr_sp dw 0 ; user stacks + global _usr_ss +_usr_ss dw 0 + global _ram_top +_ram_top dw 0 + + + + +segment _BSSEND +; blockdev private stack + global blk_stk_top + times 256 dw 0 +blk_stk_top: + +; clockdev private stack + global clk_stk_top + times 256 dw 0 +clk_stk_top: + +; interrupt stack + times 256 dw 0 +intr_stk_top: + +; kernel startup stack + times 128 dw 0 +tos: + + global last +last: ; must always be end of stack area + global _last +_last: ; and c version + + +; The default stack (_TEXT:0) will overwrite the data area, so I create a dummy +; stack here to ease debugging. -- ror4 + +segment _STACK class=STACK stack + diff --git a/kernel/kernel.cfg b/kernel/kernel.cfg new file mode 100644 index 00000000..c92038f6 --- /dev/null +++ b/kernel/kernel.cfg @@ -0,0 +1,13 @@ +-1- +-f- +-ff- +-O +-Z +-d +-k- +-vi- +-wpro +-weas +-wpre +-I..\hdr +-v -X- -I. -D__STDC__=0 -DTSC -DDEBUG -DKERNEL -DI86 -DPROTO -DSHWR -DASMSUPT diff --git a/kernel/kernel.mak b/kernel/kernel.mak new file mode 100644 index 00000000..8482f069 --- /dev/null +++ b/kernel/kernel.mak @@ -0,0 +1,415 @@ +# +# Makefile for Borland C++ 3.1 for kernel.sys +# +# $Id$ +# + +# $Log$ +# Revision 1.1 2000/05/06 19:35:23 jhall1 +# Initial revision +# +# Revision 1.12 2000/03/09 06:07:11 kernel +# 2017f updates by James Tabor +# +# Revision 1.11 1999/09/23 04:40:47 jprice +# *** empty log message *** +# +# Revision 1.8 1999/09/13 20:41:41 jprice +# Some clean up. +# +# Revision 1.7 1999/08/25 03:18:09 jprice +# ror4 patches to allow TC 2.01 compile. +# +# Revision 1.6 1999/08/10 17:57:13 jprice +# ror4 2011-02 patch +# +# Revision 1.5 1999/04/23 04:25:15 jprice +# no message +# +# Revision 1.4 1999/04/23 03:45:11 jprice +# Improved by jprice +# +# Revision 1.3 1999/04/16 12:21:22 jprice +# Steffen c-break handler changes +# +# Revision 1.2 1999/04/13 15:48:21 jprice +# no message +# +# Revision 1.1.1.1 1999/03/29 15:41:15 jprice +# New version without IPL.SYS +# +# Revision 1.7 1999/03/01 06:04:37 jprice +# Fixed so it'll work with config.mak +# +# Revision 1.6 1999/03/01 05:46:43 jprice +# Turned off DEBUG define. +# +# Revision 1.5 1999/02/09 04:49:43 jprice +# Make makefile use common config.mak file +# +# Revision 1.4 1999/02/08 05:55:57 jprice +# Added Pat's 1937 kernel patches +# +# Revision 1.3 1999/02/04 03:09:59 jprice +# Added option to share constants (-d). +# +# Revision 1.2 1999/01/22 04:13:26 jprice +# Formating +# +# Revision 1.1.1.1 1999/01/20 05:51:01 jprice +# Imported sources +# +# +# Rev 1.8.1 10 Jan 1999 SRM +#Took out "/P-" from TLINK +#Changed "bcc" to "tcc" +# +# Rev 1.9 06 Dec 1998 8:45:40 patv +#Added new files for I/O subsystem. +# +# Rev 1.8 22 Jan 1998 14:50:06 patv +#Outdated stacks.asm. +# +# Rev 1.6 03 Jan 1998 8:36:50 patv +#Converted data area to SDA format +# +# Rev 1.5 30 Jan 1997 7:55:54 patv +#Added TSC flag for trace support. +# +# Rev 1.4 16 Jan 1997 12:46:42 patv +#pre-Release 0.92 feature additions +# +# Rev 1.3 29 Aug 1996 13:07:34 patv +#Bug fixes for v0.91b +# +# Rev 1.2 29 May 1996 21:03:32 patv +#bug fixes for v0.91a +# +# Rev 1.1 19 Feb 1996 3:35:38 patv +#Added NLS, int2f and config.sys processing +# +# Rev 1.0 02 Jul 1995 8:30:22 patv +#Initial revision. +# +# $EndLog$ +# + +!include "..\config.mak" + +RELEASE = 1.00 + +# +# Compiler and Options for Borland C++ +# ------------------------------------ +LIBPATH = . +INCLUDEPATH = ..\HDR +#AFLAGS = /Mx /DSTANDALONE=1 /I..\HDR +NASMFLAGS = -i../hdr/ +LIBS =..\LIB\DEVICE.LIB ..\LIB\LIBM.LIB +CFLAGS = -1- -O -Z -d -I..\hdr -I. \ + -D__STDC__=0;DEBUG;KERNEL;I86;PROTO;ASMSUPT +#CFLAGS = -1- -O -Z -d -I..\hdr -I. \ +# -D__STDC__=0;KERNEL;I86;PROTO;ASMSUPT +INITCFLAGS = $(CFLAGS) -zAINIT -zCINIT_TEXT -zPIGROUP +HDR=../hdr/ + +# *Implicit Rules* +.c.obj: + $(CC) $(CFLAGS) -c $< + +.cpp.obj: + $(CC) $(CFLAGS) -c $< + +.asm.obj: + $(NASM) $(NASMFLAGS) -f obj $< + +# *List Macros* + + +EXE_dependencies = \ + apisupt.obj \ + asmsupt.obj \ + blockio.obj \ + break.obj \ + chario.obj \ + config.obj \ + console.obj \ + dosidle.obj \ + dosfns.obj \ + dosnames.obj \ + dsk.obj \ + entry.obj \ + error.obj \ + execrh.obj \ + fatdir.obj \ + fatfs.obj \ + fattab.obj \ + fcbfns.obj \ + initoem.obj \ + int2f.obj \ + inthndlr.obj \ + io.obj \ + ioctl.obj \ + irqstack.obj \ + kernel.obj \ + main.obj \ + memmgr.obj \ + misc.obj \ + newstuff.obj \ + network.obj \ + nls.obj \ + nlssupt.obj \ + prf.obj \ + printer.obj \ + procsupt.obj \ + serial.obj \ + strings.obj \ + sysclk.obj \ + syspack.obj \ + systime.obj \ + task.obj + +# *Explicit Rules* + +production: ..\bin\kernel.sys + +..\bin\kernel.sys: kernel.sys + copy kernel.sys ..\bin + +kernel.sys: kernel.exe + ..\utils\exeflat kernel.exe kernel.sys 0x60 + +clobber: clean + $(RM) kernel.exe kernel.sys status.me + +clean: + $(RM) *.obj *.bak *.crf *.xrf *.map *.lst + +# XXX: This is a very ugly way of linking the kernel, forced upon us by the +# inability of Turbo `make' 2.0 to perform command line redirection. -- ror4 +kernel.exe: $(EXE_dependencies) $(LIBS) + del kernel.lib + $(LIBUTIL) kernel +entry +io +blockio +chario +dosfns +console + $(LIBUTIL) kernel +printer +serial +dsk +error +fatdir +fatfs + $(LIBUTIL) kernel +fattab +fcbfns +initoem +inthndlr +ioctl + $(LIBUTIL) kernel +main +config +memmgr +misc +newstuff +nls + $(LIBUTIL) kernel +dosnames +prf +strings +network +sysclk +syspack + $(LIBUTIL) kernel +systime +task +int2f +irqstack +apisupt + $(LIBUTIL) kernel +asmsupt +execrh +nlssupt +procsupt +break + $(LIBUTIL) kernel +dosidle + del kernel.bak + $(LINK) /m/c/L$(LIBPATH) kernel,kernel,kernel,kernel+$(LIBS); + del kernel.lib + +# *Individual File Dependencies* +kernel.obj: kernel.asm segs.inc + +console.obj: console.asm io.inc + +printer.obj: printer.asm io.inc + +serial.obj: serial.asm io.inc + +entry.obj: entry.asm segs.inc $(HDR)stacks.inc + +apisupt.obj: apisupt.asm segs.inc + +asmsupt.obj: asmsupt.asm segs.inc + +execrh.obj: execrh.asm segs.inc + +int2f.obj: int2f.asm segs.inc + +io.obj: io.asm segs.inc + +irqstack.obj: irqstack.asm + +nlssupt.obj: nlssupt.asm segs.inc + +procsupt.obj: procsupt.asm segs.inc $(HDR)stacks.inc + +dosidle.obj: dosidle.asm segs.inc + +# XXX: Special handling for initialization modules -- this is required because +# TC 2.01 cannot handle `#pragma option' like TC 3 can. -- ror4 +config.obj: config.c init-mod.h $(HDR)portab.h globals.h \ + $(HDR)device.h $(HDR)mcb.h $(HDR)pcb.h $(HDR)date.h $(HDR)time.h \ + $(HDR)fat.h $(HDR)fcb.h $(HDR)tail.h $(HDR)process.h $(HDR)dcb.h \ + $(HDR)sft.h $(HDR)cds.h $(HDR)exe.h $(HDR)fnode.h \ + $(HDR)dirmatch.h $(HDR)file.h $(HDR)clock.h $(HDR)kbd.h \ + $(HDR)error.h $(HDR)version.h proto.h + $(CC) $(INITCFLAGS) -c config.c + +initoem.obj: initoem.c init-mod.h $(HDR)portab.h globals.h \ + $(HDR)device.h $(HDR)mcb.h $(HDR)pcb.h $(HDR)date.h $(HDR)time.h \ + $(HDR)fat.h $(HDR)fcb.h $(HDR)tail.h $(HDR)process.h $(HDR)dcb.h \ + $(HDR)sft.h $(HDR)cds.h $(HDR)exe.h $(HDR)fnode.h \ + $(HDR)dirmatch.h $(HDR)file.h $(HDR)clock.h $(HDR)kbd.h \ + $(HDR)error.h $(HDR)version.h proto.h + $(CC) $(INITCFLAGS) -c initoem.c + +main.obj: main.c init-mod.h $(HDR)portab.h globals.h $(HDR)device.h \ + $(HDR)mcb.h $(HDR)pcb.h $(HDR)date.h $(HDR)time.h $(HDR)fat.h \ + $(HDR)fcb.h $(HDR)tail.h $(HDR)process.h $(HDR)dcb.h $(HDR)sft.h \ + $(HDR)cds.h $(HDR)exe.h $(HDR)fnode.h $(HDR)dirmatch.h \ + $(HDR)file.h $(HDR)clock.h $(HDR)kbd.h $(HDR)error.h \ + $(HDR)version.h proto.h + $(CC) $(INITCFLAGS) -c main.c + +# XXX: I generated these using `gcc -MM' and `sed', so they may not be +# completely correct... -- ror4 +blockio.obj: blockio.c $(HDR)portab.h globals.h $(HDR)device.h \ + $(HDR)mcb.h $(HDR)pcb.h $(HDR)date.h $(HDR)time.h $(HDR)fat.h \ + $(HDR)fcb.h $(HDR)tail.h $(HDR)process.h $(HDR)dcb.h $(HDR)sft.h \ + $(HDR)cds.h $(HDR)exe.h $(HDR)fnode.h $(HDR)dirmatch.h \ + $(HDR)file.h $(HDR)clock.h $(HDR)kbd.h $(HDR)error.h \ + $(HDR)version.h proto.h + +break.obj: break.c $(HDR)portab.h globals.h $(HDR)device.h \ + $(HDR)mcb.h $(HDR)pcb.h $(HDR)date.h $(HDR)time.h $(HDR)fat.h \ + $(HDR)fcb.h $(HDR)tail.h $(HDR)process.h $(HDR)dcb.h $(HDR)sft.h \ + $(HDR)cds.h $(HDR)exe.h $(HDR)fnode.h $(HDR)dirmatch.h \ + $(HDR)file.h $(HDR)clock.h $(HDR)kbd.h $(HDR)error.h \ + $(HDR)version.h proto.h + +chario.obj: chario.c $(HDR)portab.h globals.h $(HDR)device.h \ + $(HDR)mcb.h $(HDR)pcb.h $(HDR)date.h $(HDR)time.h $(HDR)fat.h \ + $(HDR)fcb.h $(HDR)tail.h $(HDR)process.h $(HDR)dcb.h $(HDR)sft.h \ + $(HDR)cds.h $(HDR)exe.h $(HDR)fnode.h $(HDR)dirmatch.h \ + $(HDR)file.h $(HDR)clock.h $(HDR)kbd.h $(HDR)error.h \ + $(HDR)version.h proto.h + +dosfns.obj: dosfns.c $(HDR)portab.h globals.h $(HDR)device.h \ + $(HDR)mcb.h $(HDR)pcb.h $(HDR)date.h $(HDR)time.h $(HDR)fat.h \ + $(HDR)fcb.h $(HDR)tail.h $(HDR)process.h $(HDR)dcb.h $(HDR)sft.h \ + $(HDR)cds.h $(HDR)exe.h $(HDR)fnode.h $(HDR)dirmatch.h \ + $(HDR)file.h $(HDR)clock.h $(HDR)kbd.h $(HDR)error.h \ + $(HDR)version.h proto.h + +dosnames.obj: dosnames.c $(HDR)portab.h globals.h $(HDR)device.h \ + $(HDR)mcb.h $(HDR)pcb.h $(HDR)date.h $(HDR)time.h $(HDR)fat.h \ + $(HDR)fcb.h $(HDR)tail.h $(HDR)process.h $(HDR)dcb.h $(HDR)sft.h \ + $(HDR)cds.h $(HDR)exe.h $(HDR)fnode.h $(HDR)dirmatch.h \ + $(HDR)file.h $(HDR)clock.h $(HDR)kbd.h $(HDR)error.h \ + $(HDR)version.h proto.h + +dsk.obj: dsk.c $(HDR)portab.h globals.h $(HDR)device.h $(HDR)mcb.h \ + $(HDR)pcb.h $(HDR)date.h $(HDR)time.h $(HDR)fat.h $(HDR)fcb.h \ + $(HDR)tail.h $(HDR)process.h $(HDR)dcb.h $(HDR)sft.h $(HDR)cds.h \ + $(HDR)exe.h $(HDR)fnode.h $(HDR)dirmatch.h $(HDR)file.h \ + $(HDR)clock.h $(HDR)kbd.h $(HDR)error.h $(HDR)version.h proto.h + +error.obj: error.c $(HDR)portab.h globals.h $(HDR)device.h \ + $(HDR)mcb.h $(HDR)pcb.h $(HDR)date.h $(HDR)time.h $(HDR)fat.h \ + $(HDR)fcb.h $(HDR)tail.h $(HDR)process.h $(HDR)dcb.h $(HDR)sft.h \ + $(HDR)cds.h $(HDR)exe.h $(HDR)fnode.h $(HDR)dirmatch.h \ + $(HDR)file.h $(HDR)clock.h $(HDR)kbd.h $(HDR)error.h \ + $(HDR)version.h proto.h + +fatdir.obj: fatdir.c $(HDR)portab.h globals.h $(HDR)device.h \ + $(HDR)mcb.h $(HDR)pcb.h $(HDR)date.h $(HDR)time.h $(HDR)fat.h \ + $(HDR)fcb.h $(HDR)tail.h $(HDR)process.h $(HDR)dcb.h $(HDR)sft.h \ + $(HDR)cds.h $(HDR)exe.h $(HDR)fnode.h $(HDR)dirmatch.h \ + $(HDR)file.h $(HDR)clock.h $(HDR)kbd.h $(HDR)error.h \ + $(HDR)version.h proto.h + +fatfs.obj: fatfs.c $(HDR)portab.h globals.h $(HDR)device.h \ + $(HDR)mcb.h $(HDR)pcb.h $(HDR)date.h $(HDR)time.h $(HDR)fat.h \ + $(HDR)fcb.h $(HDR)tail.h $(HDR)process.h $(HDR)dcb.h $(HDR)sft.h \ + $(HDR)cds.h $(HDR)exe.h $(HDR)fnode.h $(HDR)dirmatch.h \ + $(HDR)file.h $(HDR)clock.h $(HDR)kbd.h $(HDR)error.h \ + $(HDR)version.h proto.h + +fattab.obj: fattab.c $(HDR)portab.h globals.h $(HDR)device.h \ + $(HDR)mcb.h $(HDR)pcb.h $(HDR)date.h $(HDR)time.h $(HDR)fat.h \ + $(HDR)fcb.h $(HDR)tail.h $(HDR)process.h $(HDR)dcb.h $(HDR)sft.h \ + $(HDR)cds.h $(HDR)exe.h $(HDR)fnode.h $(HDR)dirmatch.h \ + $(HDR)file.h $(HDR)clock.h $(HDR)kbd.h $(HDR)error.h \ + $(HDR)version.h proto.h + +fcbfns.obj: fcbfns.c $(HDR)portab.h globals.h $(HDR)device.h \ + $(HDR)mcb.h $(HDR)pcb.h $(HDR)date.h $(HDR)time.h $(HDR)fat.h \ + $(HDR)fcb.h $(HDR)tail.h $(HDR)process.h $(HDR)dcb.h $(HDR)sft.h \ + $(HDR)cds.h $(HDR)exe.h $(HDR)fnode.h $(HDR)dirmatch.h \ + $(HDR)file.h $(HDR)clock.h $(HDR)kbd.h $(HDR)error.h \ + $(HDR)version.h proto.h + +inthndlr.obj: inthndlr.c $(HDR)portab.h globals.h $(HDR)device.h \ + $(HDR)mcb.h $(HDR)pcb.h $(HDR)date.h $(HDR)time.h $(HDR)fat.h \ + $(HDR)fcb.h $(HDR)tail.h $(HDR)process.h $(HDR)dcb.h $(HDR)sft.h \ + $(HDR)cds.h $(HDR)exe.h $(HDR)fnode.h $(HDR)dirmatch.h \ + $(HDR)file.h $(HDR)clock.h $(HDR)kbd.h $(HDR)error.h \ + $(HDR)version.h proto.h + +ioctl.obj: ioctl.c $(HDR)portab.h globals.h $(HDR)device.h \ + $(HDR)mcb.h $(HDR)pcb.h $(HDR)date.h $(HDR)time.h $(HDR)fat.h \ + $(HDR)fcb.h $(HDR)tail.h $(HDR)process.h $(HDR)dcb.h $(HDR)sft.h \ + $(HDR)cds.h $(HDR)exe.h $(HDR)fnode.h $(HDR)dirmatch.h \ + $(HDR)file.h $(HDR)clock.h $(HDR)kbd.h $(HDR)error.h \ + $(HDR)version.h proto.h + +memmgr.obj: memmgr.c $(HDR)portab.h globals.h $(HDR)device.h \ + $(HDR)mcb.h $(HDR)pcb.h $(HDR)date.h $(HDR)time.h $(HDR)fat.h \ + $(HDR)fcb.h $(HDR)tail.h $(HDR)process.h $(HDR)dcb.h $(HDR)sft.h \ + $(HDR)cds.h $(HDR)exe.h $(HDR)fnode.h $(HDR)dirmatch.h \ + $(HDR)file.h $(HDR)clock.h $(HDR)kbd.h $(HDR)error.h \ + $(HDR)version.h proto.h + +misc.obj: misc.c $(HDR)portab.h globals.h $(HDR)device.h $(HDR)mcb.h \ + $(HDR)pcb.h $(HDR)date.h $(HDR)time.h $(HDR)fat.h $(HDR)fcb.h \ + $(HDR)tail.h $(HDR)process.h $(HDR)dcb.h $(HDR)sft.h $(HDR)cds.h \ + $(HDR)exe.h $(HDR)fnode.h $(HDR)dirmatch.h $(HDR)file.h \ + $(HDR)clock.h $(HDR)kbd.h $(HDR)error.h $(HDR)version.h proto.h + +newstuff.obj: newstuff.c $(HDR)portab.h globals.h $(HDR)device.h \ + $(HDR)mcb.h $(HDR)pcb.h $(HDR)date.h $(HDR)time.h $(HDR)fat.h \ + $(HDR)fcb.h $(HDR)tail.h $(HDR)process.h $(HDR)dcb.h $(HDR)sft.h \ + $(HDR)cds.h $(HDR)exe.h $(HDR)fnode.h $(HDR)dirmatch.h \ + $(HDR)file.h $(HDR)clock.h $(HDR)kbd.h $(HDR)error.h \ + $(HDR)version.h proto.h + +network.obj: network.c $(HDR)portab.h globals.h $(HDR)device.h \ + $(HDR)mcb.h $(HDR)pcb.h $(HDR)date.h $(HDR)time.h $(HDR)fat.h \ + $(HDR)fcb.h $(HDR)tail.h $(HDR)process.h $(HDR)dcb.h $(HDR)sft.h \ + $(HDR)cds.h $(HDR)exe.h $(HDR)fnode.h $(HDR)dirmatch.h \ + $(HDR)file.h $(HDR)clock.h $(HDR)kbd.h $(HDR)error.h \ + $(HDR)version.h proto.h + +nls.obj: nls.c $(HDR)portab.h globals.h $(HDR)device.h $(HDR)mcb.h \ + $(HDR)pcb.h $(HDR)date.h $(HDR)time.h $(HDR)fat.h $(HDR)fcb.h \ + $(HDR)tail.h $(HDR)process.h $(HDR)dcb.h $(HDR)sft.h $(HDR)cds.h \ + $(HDR)exe.h $(HDR)fnode.h $(HDR)dirmatch.h $(HDR)file.h \ + $(HDR)clock.h $(HDR)kbd.h $(HDR)error.h $(HDR)version.h proto.h \ + 001-437.nls + +prf.obj: prf.c $(HDR)portab.h + +strings.obj: strings.c $(HDR)portab.h + +sysclk.obj: sysclk.c $(HDR)portab.h globals.h $(HDR)device.h \ + $(HDR)mcb.h $(HDR)pcb.h $(HDR)date.h $(HDR)time.h $(HDR)fat.h \ + $(HDR)fcb.h $(HDR)tail.h $(HDR)process.h $(HDR)dcb.h $(HDR)sft.h \ + $(HDR)cds.h $(HDR)exe.h $(HDR)fnode.h $(HDR)dirmatch.h \ + $(HDR)file.h $(HDR)clock.h $(HDR)kbd.h $(HDR)error.h \ + $(HDR)version.h proto.h + +syspack.obj: syspack.c $(HDR)portab.h globals.h $(HDR)device.h \ + $(HDR)mcb.h $(HDR)pcb.h $(HDR)date.h $(HDR)time.h $(HDR)fat.h \ + $(HDR)fcb.h $(HDR)tail.h $(HDR)process.h $(HDR)dcb.h $(HDR)sft.h \ + $(HDR)cds.h $(HDR)exe.h $(HDR)fnode.h $(HDR)dirmatch.h \ + $(HDR)file.h $(HDR)clock.h $(HDR)kbd.h $(HDR)error.h \ + $(HDR)version.h proto.h + +systime.obj: systime.c $(HDR)portab.h $(HDR)time.h $(HDR)date.h \ + globals.h $(HDR)device.h $(HDR)mcb.h $(HDR)pcb.h $(HDR)fat.h \ + $(HDR)fcb.h $(HDR)tail.h $(HDR)process.h $(HDR)dcb.h $(HDR)sft.h \ + $(HDR)cds.h $(HDR)exe.h $(HDR)fnode.h $(HDR)dirmatch.h \ + $(HDR)file.h $(HDR)clock.h $(HDR)kbd.h $(HDR)error.h \ + $(HDR)version.h proto.h + +task.obj: task.c $(HDR)portab.h globals.h $(HDR)device.h $(HDR)mcb.h \ + $(HDR)pcb.h $(HDR)date.h $(HDR)time.h $(HDR)fat.h $(HDR)fcb.h \ + $(HDR)tail.h $(HDR)process.h $(HDR)dcb.h $(HDR)sft.h $(HDR)cds.h \ + $(HDR)exe.h $(HDR)fnode.h $(HDR)dirmatch.h $(HDR)file.h \ + $(HDR)clock.h $(HDR)kbd.h $(HDR)error.h $(HDR)version.h proto.h + diff --git a/kernel/main.c b/kernel/main.c new file mode 100644 index 00000000..c5a37a6a --- /dev/null +++ b/kernel/main.c @@ -0,0 +1,524 @@ +/****************************************************************/ +/* */ +/* main.c */ +/* DOS-C */ +/* */ +/* Main Kernel Functions */ +/* */ +/* Copyright (c) 1995, 1996 */ +/* Pasquale J. Villani */ +/* All Rights Reserved */ +/* */ +/* This file is part of DOS-C. */ +/* */ +/* DOS-C is free software; you can redistribute it and/or */ +/* modify it under the terms of the GNU General Public License */ +/* as published by the Free Software Foundation; either version */ +/* 2, or (at your option) any later version. */ +/* */ +/* DOS-C is distributed in the hope that it will be useful, but */ +/* WITHOUT ANY WARRANTY; without even the implied warranty of */ +/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See */ +/* the GNU General Public License for more details. */ +/* */ +/* You should have received a copy of the GNU General Public */ +/* License along with DOS-C; see the file COPYING. If not, */ +/* write to the Free Software Foundation, 675 Mass Ave, */ +/* Cambridge, MA 02139, USA. */ +/****************************************************************/ + +#include "init-mod.h" + +#define MAIN +#include "portab.h" +#include "globals.h" + +#ifdef VERSION_STRINGS +static BYTE *mainRcsId = "$Id$"; +#endif + +/* + * $Log$ + * Revision 1.1 2000/05/06 19:35:25 jhall1 + * Initial revision + * + * Revision 1.13 2000/03/09 06:07:11 kernel + * 2017f updates by James Tabor + * + * Revision 1.12 1999/09/23 04:40:48 jprice + * *** empty log message *** + * + * Revision 1.10 1999/08/25 03:18:09 jprice + * ror4 patches to allow TC 2.01 compile. + * + * Revision 1.9 1999/04/16 21:43:40 jprice + * ror4 multi-sector IO + * + * Revision 1.8 1999/04/16 12:21:22 jprice + * Steffen c-break handler changes + * + * Revision 1.7 1999/04/16 00:53:33 jprice + * Optimized FAT handling + * + * Revision 1.6 1999/04/12 03:21:17 jprice + * more ror4 patches. Changes for multi-block IO + * + * Revision 1.5 1999/04/11 04:33:39 jprice + * ror4 patches + * + * Revision 1.3 1999/04/04 22:57:47 jprice + * no message + * + * Revision 1.2 1999/04/04 18:51:43 jprice + * no message + * + * Revision 1.1.1.1 1999/03/29 15:41:18 jprice + * New version without IPL.SYS + * + * Revision 1.5 1999/02/08 05:55:57 jprice + * Added Pat's 1937 kernel patches + * + * Revision 1.4 1999/02/01 01:48:41 jprice + * Clean up; Now you can use hex numbers in config.sys. added config.sys screen function to change screen mode (28 or 43/50 lines) + * + * Revision 1.3 1999/01/30 08:28:12 jprice + * Clean up; Fixed bug with set attribute function. + * + * Revision 1.2 1999/01/22 04:13:26 jprice + * Formating + * + * Revision 1.1.1.1 1999/01/20 05:51:01 jprice + * Imported sources + * + * + * Rev 1.12 06 Dec 1998 8:45:30 patv + * Changed due to new I/O subsystem. + * + * Rev 1.11 22 Jan 1998 4:09:24 patv + * Fixed pointer problems affecting SDA + * + * Rev 1.10 04 Jan 1998 23:15:20 patv + * Changed Log for strip utility + * + * Rev 1.9 04 Jan 1998 17:26:16 patv + * Corrected subdirectory bug + * + * Rev 1.8 03 Jan 1998 8:36:48 patv + * Converted data area to SDA format + * + * Rev 1.7 06 Feb 1997 21:35:46 patv + * Modified to support new version format and changed debug message to + * output drive letter instead of number. + * + * Rev 1.6 22 Jan 1997 13:05:02 patv + * Now does correct default drive initialization. + * + * Rev 1.5 16 Jan 1997 12:47:00 patv + * pre-Release 0.92 feature additions + * + * Rev 1.3 29 May 1996 21:03:32 patv + * bug fixes for v0.91a + * + * Rev 1.2 19 Feb 1996 3:21:36 patv + * Added NLS, int2f and config.sys processing + * + * Rev 1.1 01 Sep 1995 17:54:18 patv + * First GPL release. + * + * Rev 1.0 02 Jul 1995 8:33:18 patv + * Initial revision. + */ + +extern UWORD DaysSinceEpoch; +extern WORD days[2][13]; + +INIT BOOL ReadATClock(BYTE *, BYTE *, BYTE *, BYTE *); +VOID FAR init_call_WritePCClock(ULONG); + +INIT VOID configDone(VOID); +INIT static void InitIO(void); +INIT static COUNT BcdToByte(COUNT); +INIT static COUNT BcdToDay(BYTE *); + +INIT static VOID init_kernel(VOID); +INIT static VOID signon(VOID); +INIT VOID kernel(VOID); +INIT VOID FsConfig(VOID); + +INIT VOID main(void) +{ +#ifdef KDB + BootDrive = 1; +#endif + init_kernel(); +#ifdef DEBUG + /* Non-portable message kludge alert! */ + printf("KERNEL: Boot drive = %c\n", 'A' + BootDrive - 1); +#endif + signon(); + kernel(); +} + +INIT static VOID init_kernel(void) +{ + COUNT i; + os_major = MAJOR_RELEASE; + os_minor = MINOR_RELEASE; + cu_psp = DOS_PSP; + nblkdev = 0; + maxbksize = 0x200; + switchar = '/'; + dosidle_flag = 1; + + /* Init oem hook - returns memory size in KB */ + ram_top = init_oem(); + +#ifndef KDB + for (i = 0x20; i <= 0x3f; i++) + setvec(i, empty_handler); +#endif + + /* Initialize IO subsystem */ + InitIO(); + syscon = (struct dhdr FAR *)&con_dev; + clock = (struct dhdr FAR *)&clk_dev; + +#ifndef KDB + /* set interrupt vectors */ + setvec(0x1b, got_cbreak); + setvec(0x20, int20_handler); + setvec(0x21, int21_handler); + setvec(0x22, int22_handler); + setvec(0x23, empty_handler); + setvec(0x24, int24_handler); + setvec(0x25, low_int25_handler); + setvec(0x26, low_int26_handler); + setvec(0x27, int27_handler); + setvec(0x28, int28_handler); + setvec(0x2a, int2a_handler); + setvec(0x2f, int2f_handler); +#endif + + /* Initialize the screen handler for backspaces */ + scr_pos = 0; + break_ena = TRUE; + + /* Do first initialization of system variable buffers so that */ + /* we can read config.sys later. */ + lastdrive = Config.cfgLastdrive; + PreConfig(); + + /* Now config the temporary file system */ + FsConfig(); + +#ifndef KDB + /* Now process CONFIG.SYS */ + DoConfig(); + + lastdrive = Config.cfgLastdrive; + if (lastdrive < nblkdev) + lastdrive = nblkdev; + + /* and do final buffer allocation. */ + PostConfig(); + + /* Now config the final file system */ + FsConfig(); + + /* and process CONFIG.SYS one last time to load device drivers. */ + DoConfig(); + configDone(); +#endif + /* Now to initialize all special flags, etc. */ + mem_access_mode = FIRST_FIT; + verify_ena = FALSE; + InDOS = 0; + version_flags = 0; + pDirFileNode = 0; + dosidle_flag = 0; +} + +INIT VOID FsConfig(VOID) +{ + REG COUNT i; + date Date; + time Time; + BYTE x; + + /* Get the start-up date and time */ + Date = dos_getdate(); + Time = dos_gettime(); + + /* Initialize the file tables */ + for (i = 0; i < Config.cfgFiles; i++) + f_nodes[i].f_count = 0; + + /* The system file tables need special handling and are "hand */ + /* built. Included is the stdin, stdout, stdaux and atdprn. */ + sfthead->sftt_next = (sfttbl FAR *) - 1; + sfthead->sftt_count = Config.cfgFiles; + for (i = 0; i < sfthead->sftt_count; i++) + { + sfthead->sftt_table[i].sft_count = 0; + sfthead->sftt_table[i].sft_status = -1; + } + /* 0 is /dev/con (stdin) */ + sfthead->sftt_table[0].sft_count = 1; + sfthead->sftt_table[0].sft_mode = SFT_MREAD; + sfthead->sftt_table[0].sft_attrib = 0; + sfthead->sftt_table[0].sft_flags = + ((con_dev.dh_attr & ~SFT_MASK) & ~SFT_FSHARED) | SFT_FDEVICE | SFT_FEOF | SFT_FCONIN | SFT_FCONOUT; + sfthead->sftt_table[0].sft_psp = DOS_PSP; + sfthead->sftt_table[0].sft_date = Date; + sfthead->sftt_table[0].sft_time = Time; + fbcopy( + (VOID FAR *) "CON ", + (VOID FAR *) sfthead->sftt_table[0].sft_name, 11); + sfthead->sftt_table[0].sft_dev = (struct dhdr FAR *)&con_dev; + + /* 1 is /dev/con (stdout) */ + sfthead->sftt_table[1].sft_count = 1; + sfthead->sftt_table[1].sft_mode = SFT_MWRITE; + sfthead->sftt_table[1].sft_attrib = 0; + sfthead->sftt_table[1].sft_flags = + ((con_dev.dh_attr & ~SFT_MASK) & ~SFT_FSHARED) | SFT_FDEVICE | SFT_FEOF | SFT_FCONIN | SFT_FCONOUT; + sfthead->sftt_table[1].sft_psp = DOS_PSP; + sfthead->sftt_table[1].sft_date = Date; + sfthead->sftt_table[1].sft_time = Time; + fbcopy( + (VOID FAR *) "CON ", + (VOID FAR *) sfthead->sftt_table[1].sft_name, 11); + sfthead->sftt_table[1].sft_dev = (struct dhdr FAR *)&con_dev; + + /* 2 is /dev/con (stderr) */ + sfthead->sftt_table[2].sft_count = 1; + sfthead->sftt_table[2].sft_mode = SFT_MWRITE; + sfthead->sftt_table[2].sft_attrib = 0; + sfthead->sftt_table[2].sft_flags = + ((con_dev.dh_attr & ~SFT_MASK) & ~SFT_FSHARED) | SFT_FDEVICE | SFT_FEOF | SFT_FCONIN | SFT_FCONOUT; + sfthead->sftt_table[2].sft_psp = DOS_PSP; + sfthead->sftt_table[2].sft_date = Date; + sfthead->sftt_table[2].sft_time = Time; + fbcopy( + (VOID FAR *) "CON ", + (VOID FAR *) sfthead->sftt_table[2].sft_name, 11); + sfthead->sftt_table[2].sft_dev = (struct dhdr FAR *)&con_dev; + + /* 3 is /dev/aux */ + sfthead->sftt_table[3].sft_count = 1; + sfthead->sftt_table[3].sft_mode = SFT_MRDWR; + sfthead->sftt_table[3].sft_attrib = 0; + sfthead->sftt_table[3].sft_flags = + ((aux_dev.dh_attr & ~SFT_MASK) & ~SFT_FSHARED) | SFT_FDEVICE; + sfthead->sftt_table[3].sft_psp = DOS_PSP; + sfthead->sftt_table[3].sft_date = Date; + sfthead->sftt_table[3].sft_time = Time; + fbcopy( + (VOID FAR *) "AUX ", + (VOID FAR *) sfthead->sftt_table[3].sft_name, 11); + sfthead->sftt_table[3].sft_dev = (struct dhdr FAR *)&aux_dev; + + /* 4 is /dev/prn */ + sfthead->sftt_table[4].sft_count = 1; + sfthead->sftt_table[4].sft_mode = SFT_MWRITE; + sfthead->sftt_table[4].sft_attrib = 0; + sfthead->sftt_table[4].sft_flags = + ((prn_dev.dh_attr & ~SFT_MASK) & ~SFT_FSHARED) | SFT_FDEVICE; + sfthead->sftt_table[4].sft_psp = DOS_PSP; + sfthead->sftt_table[4].sft_date = Date; + sfthead->sftt_table[4].sft_time = Time; + fbcopy( + (VOID FAR *) "PRN ", + (VOID FAR *) sfthead->sftt_table[4].sft_name, 11); + sfthead->sftt_table[4].sft_dev = (struct dhdr FAR *)&prn_dev; + + /* Log-in the default drive. */ + /* Get the boot drive from the ipl and use it for default. */ + default_drive = BootDrive - 1; + + /* Initialzie the current directory structures */ + for (i = 0; i < lastdrive + 1; i++) + { + + fbcopy((VOID FAR *) "A:\\\0", + (VOID FAR *) CDSp->cds_table[i].cdsCurrentPath, 4); + CDSp->cds_table[i].cdsCurrentPath[0] += i; + + if (i < nblkdev) + { + CDSp->cds_table[i].cdsDpb = &blk_devices[i]; + CDSp->cds_table[i].cdsFlags = 0x4000; + } + else + { + CDSp->cds_table[i].cdsFlags = 0; + } + CDSp->cds_table[i].cdsStrtClst = 0xffff; + CDSp->cds_table[i].cdsParam = 0xffff; + CDSp->cds_table[i].cdsStoreUData = 0xffff; + CDSp->cds_table[i].cdsJoinOffset = 2; + } + + /* Initialze the disk buffer management functions */ + init_buffers(); +} + +INIT static VOID signon() +{ + printf("\nFreeDOS Kernel compatibility %d.%d\n%s\n", + os_major, os_minor, copyright); + printf(os_release, + REVISION_MAJOR, REVISION_MINOR, REVISION_SEQ, + BUILD); +} + +INIT static VOID kernel() +{ + seg asize; + BYTE FAR *ep, + *sp; + COUNT ret_code; +#ifndef KDB + static BYTE *path = "PATH=."; +#endif + +#ifdef KDB + kdb(); +#else + /* create the master environment area */ + if (DosMemAlloc(0x20, FIRST_FIT, (seg FAR *) & master_env, (seg FAR *) & asize) < 0) + fatal("cannot allocate master environment space"); + + /* populate it with the minimum environment */ + ++master_env; + ep = MK_FP(master_env, 0); + + for (sp = path; *sp != 0;) + *ep++ = *sp++; + + *ep++ = '\0'; + *ep++ = '\0'; + *((int FAR *)ep) = 0; + ep += sizeof(int); +#endif + RootPsp = ~0; + p_0(); +} + +extern BYTE FAR *lpBase; + +/* If cmdLine is NULL, this is an internal driver */ + +VOID init_device(struct dhdr FAR * dhp, BYTE FAR * cmdLine) +{ + request rq; + ULONG memtop = ((ULONG) ram_top) << 10; + ULONG maxmem = memtop - ((ULONG) FP_SEG(dhp) << 4); + + if (maxmem >= 0x10000) + maxmem = 0xFFFF; + + rq.r_unit = 0; + rq.r_status = 0; + rq.r_command = C_INIT; + rq.r_length = sizeof(request); + rq.r_endaddr = MK_FP(FP_SEG(dhp), maxmem); + rq.r_bpbptr = (void FAR *)(cmdLine ? cmdLine : "\n"); + rq.r_firstunit = nblkdev; + + execrh((request FAR *) & rq, dhp); + + if (cmdLine) + lpBase = rq.r_endaddr; + + /* check for a block device and update device control block */ + if (!(dhp->dh_attr & ATTR_CHAR) && (rq.r_nunits != 0)) + { + REG COUNT Index; + + for (Index = 0; Index < rq.r_nunits; Index++) + { + if (nblkdev) + blk_devices[nblkdev - 1].dpb_next = &blk_devices[nblkdev]; + + blk_devices[nblkdev].dpb_next = (void FAR *)0xFFFFFFFF; + blk_devices[nblkdev].dpb_unit = nblkdev; + blk_devices[nblkdev].dpb_subunit = Index; + blk_devices[nblkdev].dpb_device = dhp; + blk_devices[nblkdev].dpb_flags = M_CHANGED; + if ((CDSp) != 0) + { + CDSp->cds_table[nblkdev].cdsDpb = &blk_devices[nblkdev]; + CDSp->cds_table[nblkdev].cdsFlags = 0x4000; + } + ++nblkdev; + } + } + DPBp = &blk_devices[0]; +} + +struct dhdr FAR *link_dhdr(struct dhdr FAR * lp, struct dhdr FAR * dhp, BYTE FAR * cmdLine) +{ + lp->dh_next = dhp; + init_device(dhp, cmdLine); + return dhp; +} + +INIT static void InitIO(void) +{ + BYTE bcd_days[4], + bcd_minutes, + bcd_hours, + bcd_seconds; + ULONG ticks; + + /* Initialize driver chain */ + nul_dev.dh_next = (struct dhdr FAR *)&con_dev; + setvec(0x29, int29_handler); /* Requires Fast Con Driver */ + init_device((struct dhdr FAR *)&con_dev, NULL); + init_device((struct dhdr FAR *)&clk_dev, NULL); + init_device((struct dhdr FAR *)&blk_dev, NULL); + /* If AT clock exists, copy AT clock time to system clock */ + if (!ReadATClock(bcd_days, &bcd_hours, &bcd_minutes, &bcd_seconds)) + { + DaysSinceEpoch = BcdToDay(bcd_days); + /* + * This is a rather tricky calculation. The number of timer ticks per + * second is not exactly 18.2, but rather 0x1800b0 / 86400 = 19663 / 1080 + * (the timer interrupt updates the midnight flag when the tick count + * reaches 0x1800b0). Fortunately, 86400 * 19663 = 1698883200 < ULONG_MAX, + * so we can simply multiply the number of seconds by 19663 without + * worrying about overflow. :) -- ror4 + */ + ticks = (3600ul * BcdToByte(bcd_hours) + + 60ul * BcdToByte(bcd_minutes) + + BcdToByte(bcd_seconds)) * 19663ul / 1080ul; + WritePCClock(ticks); + } +} + +INIT static COUNT BcdToByte(COUNT x) +{ + return ((((x) >> 4) & 0xf) * 10 + ((x) & 0xf)); +} + +INIT static COUNT BcdToDay(BYTE * x) +{ + UWORD mon, + day, + yr; + + mon = BcdToByte(x[1]) - 1; + day = BcdToByte(x[0]) - 1; + yr = 100 * BcdToByte(x[3]) + BcdToByte(x[2]); + if (yr < 1980) + return 0; + else + { + day += days[is_leap_year(yr)][mon]; + while (--yr >= 1980) + day += is_leap_year(yr) ? 366 : 365; + return day; + } +} + diff --git a/kernel/memmgr.c b/kernel/memmgr.c new file mode 100644 index 00000000..8f6a6659 --- /dev/null +++ b/kernel/memmgr.c @@ -0,0 +1,572 @@ +/****************************************************************/ +/* */ +/* memmgr.c */ +/* */ +/* Memory Manager for Core Allocation */ +/* */ +/* Copyright (c) 1995 */ +/* Pasquale J. Villani */ +/* All Rights Reserved */ +/* */ +/* This file is part of DOS-C. */ +/* */ +/* DOS-C is free software; you can redistribute it and/or */ +/* modify it under the terms of the GNU General Public License */ +/* as published by the Free Software Foundation; either version */ +/* 2, or (at your option) any later version. */ +/* */ +/* DOS-C is distributed in the hope that it will be useful, but */ +/* WITHOUT ANY WARRANTY; without even the implied warranty of */ +/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See */ +/* the GNU General Public License for more details. */ +/* */ +/* You should have received a copy of the GNU General Public */ +/* License along with DOS-C; see the file COPYING. If not, */ +/* write to the Free Software Foundation, 675 Mass Ave, */ +/* Cambridge, MA 02139, USA. */ +/****************************************************************/ + +#include "portab.h" +#include "globals.h" + +#ifdef VERSION_STRING +static BYTE *memmgrRcsId = "$Id$"; +#endif + +/* + * $Log$ + * Revision 1.1 2000/05/06 19:35:26 jhall1 + * Initial revision + * + * Revision 1.4 2000/03/09 06:07:11 kernel + * 2017f updates by James Tabor + * + * Revision 1.3 1999/08/25 03:18:09 jprice + * ror4 patches to allow TC 2.01 compile. + * + * Revision 1.2 1999/04/23 04:24:39 jprice + * Memory manager changes made by ska + * + * Revision 1.1.1.1 1999/03/29 15:41:20 jprice + * New version without IPL.SYS + * + * Revision 1.4 1999/02/08 05:55:57 jprice + * Added Pat's 1937 kernel patches + * + * Revision 1.3 1999/02/01 01:48:41 jprice + * Clean up; Now you can use hex numbers in config.sys. added config.sys screen function to change screen mode (28 or 43/50 lines) + * + * Revision 1.2 1999/01/22 04:13:26 jprice + * Formating + * + * Revision 1.1.1.1 1999/01/20 05:51:01 jprice + * Imported sources + * + * + * Rev 1.6 04 Jan 1998 23:15:18 patv + * Changed Log for strip utility + * + * Rev 1.5 16 Jan 1997 12:47:00 patv + * pre-Release 0.92 feature additions + * + * Rev 1.4 29 May 1996 21:03:34 patv + * bug fixes for v0.91a + * + * Rev 1.3 19 Feb 1996 3:21:36 patv + * Added NLS, int2f and config.sys processing + * + * Rev 1.2 01 Sep 1995 17:54:20 patv + * First GPL release. + * + * Rev 1.1 30 Jul 1995 20:51:58 patv + * Eliminated version strings in ipl + * + * Rev 1.0 02 Jul 1995 8:33:08 patv + * Initial revision. + */ + +VOID mcb_init(); +VOID mcb_print(); +VOID show_chain(); + +#define nxtMCBsize(mcb,size) \ + MK_FP(far2para((VOID FAR *) (mcb)) + (size) + 1, 0) +#define nxtMCB(mcb) nxtMCBsize((mcb), (mcb)->m_size) + +#define mcbFree(mcb) ((mcb)->m_psp == FREE_PSP) +#define mcbValid(mcb) \ + ((mcb)->m_type == MCB_NORMAL || (mcb)->m_type == MCB_LAST) + +#define para2far(seg) (mcb FAR *)MK_FP((seg) , 0) + +/* + * Join any following unused MCBs to MCB 'p'. + * Return: + * SUCCESS: on success + * else: error number <> + */ +static COUNT joinMCBs(mcb FAR * p) +{ + mcb FAR *q; + + /* loop as long as the current MCB is not the last one in the chain + and the next MCB is unused */ + while (p->m_type == MCB_NORMAL && mcbFree(q = nxtMCB(p))) + { + if (!mcbValid(q)) + return DE_MCBDESTRY; + /* join both MCBs */ + p->m_type = q->m_type; /* possibly the next MCB is the last one */ + p->m_size += q->m_size + 1; /* one for q's MCB itself */ + q->m_type = 'K'; /* Invalidate the magic number */ + } + + return SUCCESS; +} + +seg far2para(VOID FAR * p) +{ + return FP_SEG(p) + (FP_OFF(p) >> 4); +} + +seg long2para(LONG size) +{ + return ((size + 0x0f) >> 4); +} + +/* + * Add a displacement to a far pointer and return the result normalized. + */ +VOID FAR *add_far(VOID FAR * fp, ULONG off) +{ + off += FP_OFF(fp); + + return MK_FP(FP_SEG(fp) + (UWORD) (off >> 4), (UWORD) off & 0xf); +} + +/* + * Return a normalized far pointer + */ +VOID FAR *adjust_far(VOID FAR * fp) +{ + /* and return an adddress adjusted to the nearest paragraph */ + /* boundary. */ + return MK_FP(FP_SEG(fp) + (FP_OFF(fp) >> 4), FP_OFF(fp) & 0xf); +} + +#undef REG +#define REG + +#ifdef KERNEL +/* Allocate a new memory area. *para is assigned to the segment of the + MCB rather then the segment of the data portion */ +/* If mode == LARGEST, asize MUST be != NULL and will always recieve the + largest available block, which is allocated. + If mode != LARGEST, asize maybe NULL, but if not, it is assigned to the + size of the largest available block only on failure. + size is the minimum size of the block to search for, + even if mode == LARGEST. + */ +COUNT DosMemAlloc(UWORD size, COUNT mode, seg FAR * para, UWORD FAR * asize) +{ + REG mcb FAR *p; + mcb FAR *foundSeg; + mcb FAR *biggestSeg; + + /* Initialize */ + p = para2far(first_mcb); + biggestSeg = foundSeg = NULL; + + /* Search through memory blocks */ + FOREVER + { + /* check for corruption */ + if (!mcbValid(p)) + return DE_MCBDESTRY; + + if (mcbFree(p)) + { /* unused block, check if it applies to the rule */ + if (joinMCBs(p) != SUCCESS) /* join following unused blocks */ + return DE_MCBDESTRY; /* error */ + + if (!biggestSeg || biggestSeg->m_size < p->m_size) + biggestSeg = p; + + if (p->m_size >= size) + { /* if the block is too small, ignore */ + /* this block has a "match" size, try the rule set */ + switch (mode) + { + case LAST_FIT: /* search for last possible */ + default: + foundSeg = p; + break; + + case LARGEST: /* grab the biggest block */ + /* it is calculated when the MCB chain + was completely checked */ + break; + + case BEST_FIT: /* first, but smallest block */ + if (!foundSeg || foundSeg->m_size > p->m_size) + /* better match found */ + foundSeg = p; + break; + + case FIRST_FIT: /* first possible */ + foundSeg = p; + goto stopIt; /* OK, rest of chain can be ignored */ + } + } + } + + if (p->m_type == MCB_LAST) + break; /* end of chain reached */ + + p = nxtMCB(p); /* advance to next MCB */ + } + + if (mode == LARGEST && biggestSeg && biggestSeg->m_size >= size) + *asize = (foundSeg = biggestSeg)->m_size; + + if (!foundSeg || !foundSeg->m_size) + { /* no block to fullfill the request */ + if (asize) + *asize = biggestSeg ? biggestSeg->m_size : 0; + return DE_NOMEM; + } + +stopIt: /* reached from FIRST_FIT on match */ + + if (mode != LARGEST && size != foundSeg->m_size) + { + /* Split the found buffer because it is larger than requested */ + /* foundSeg := pointer to allocated block + p := pointer to MCB that will form the rest of the block + */ + if (mode == LAST_FIT) + { + /* allocate the block from the end of the found block */ + p = foundSeg; + p->m_size -= size + 1; /* size+1 paragraphes are allocated by + the new segment (+1 for MCB itself) */ + foundSeg = nxtMCB(p); + + /* initialize stuff because foundSeg > p */ + foundSeg->m_type = p->m_type; + p->m_type = MCB_NORMAL; + } + else + { /* all other modes allocate from the beginning */ + p = nxtMCBsize(foundSeg, size); + p->m_size = foundSeg->m_size - size - 1; + + /* initialize stuff because p > foundSeg */ + p->m_type = foundSeg->m_type; + foundSeg->m_type = MCB_NORMAL; + } + + /* Already initialized: + p->m_size, ->m_type, foundSeg->m_type + */ + p->m_psp = FREE_PSP; /* unused */ + + foundSeg->m_size = size; + } + + /* Already initialized: + foundSeg->m_size, ->m_type + */ + foundSeg->m_psp = cu_psp; /* the new block is for current process */ + foundSeg->m_name[0] = '\0'; + + *para = far2para((VOID FAR *) (BYTE FAR *) foundSeg); + return SUCCESS; +} + +COUNT FAR init_call_DosMemAlloc(UWORD size, COUNT mode, seg FAR * para, UWORD FAR * asize) +{ + return DosMemAlloc(size, mode, para, asize); +} + +/* + * Unlike the name and the original prototype could suggest, this function + * is used to return the _size_ of the largest available block rather than + * the block itself. + * + * Known bug: a memory area with a size of the data area of 0 (zero) is + * not considered a "largest" block. <> + */ +COUNT DosMemLargest(UWORD FAR * size) +{ + REG mcb FAR *p; + mcb FAR *q; + COUNT found; + + /* Initialize */ + p = para2far(first_mcb); + + /* Cycle through the whole MCB chain to find the largest unused + area. Join all unused areas together. */ + *size = 0; /* nothing found */ + FOREVER + { + if (!mcbValid(p)) /* corrupted MCB chain */ + return DE_MCBDESTRY; + + if (mcbFree(p)) + { /* test if this is the largest block */ + /* first join this unused block with all following unused + blocks */ + if (joinMCBs(p) != SUCCESS) + return DE_MCBDESTRY; + + /* Now test */ + if (*size < p->m_size) + *size = p->m_size; + } + + if (p->m_type == MCB_LAST) /* that was last one in chain */ + break; + p = nxtMCB(p); + } + + /* If *size is still zero, aka nothing had changed, either no unused + block was found at all or a zero-length block only. + Both is considered as a failure */ + return *size ? SUCCESS : DE_NOMEM; +} + +/* + * Deallocate a memory block. para is the segment of the MCB itself + * This function can be called with para == 0, which eases other parts + * of the kernel. + */ +COUNT DosMemFree(UWORD para) +{ + REG mcb FAR *p; + COUNT i; + + if (!para) /* let esp. the kernel call this fct with para==0 */ + return DE_INVLDMCB; + + /* Initialize */ + p = para2far(para); + + /* check for corruption */ + if (!mcbValid(p)) + return DE_INVLDMCB; + + /* Mark the mcb as free so that we can later */ + /* merge with other surrounding free mcb's */ + p->m_psp = FREE_PSP; + for (i = 0; i < 8; i++) + p->m_name[i] = '\0'; + +#if 0 + /* Moved into allocating functions -- 1999/04/21 ska */ + /* Now merge free blocks */ + for (p = (mcb FAR *) (MK_FP(first_mcb, 0)); p->m_type != MCB_LAST; p = q) + { + /* make q a pointer to the next block */ + q = nxtMCB(p); + /* and test for corruption */ + if (q->m_type != MCB_NORMAL && q->m_type != MCB_LAST) + return DE_MCBDESTRY; + if (p->m_psp != FREE_PSP) + continue; + + /* test if next is free - if so merge */ + if (q->m_psp == FREE_PSP) + { + /* Always flow type down on free */ + p->m_type = q->m_type; + p->m_size += q->m_size + 1; + /* and make pointers the same */ + /* since the next free is now */ + /* this block */ + q = p; + } + } +#endif + return SUCCESS; +} + +/* + * Resize an allocated memory block. + * para is the segment of the data portion of the block rather than + * the segment of the MCB itself. + * + * If the block shall grow, it is resized to the maximal size less than + * or equal to size. This is the way MS DOS is reported to work. + */ +COUNT DosMemChange(UWORD para, UWORD size, UWORD * maxSize) +{ + REG mcb FAR *p, + FAR * q; + REG COUNT i; + + /* Initialize */ + p = para2far(para - 1); /* pointer to MCB */ + + /* check for corruption */ + if (!mcbValid(p)) + return DE_MCBDESTRY; + + /* check if to grow the block */ + if (size > p->m_size) + { + /* first try to make the MCB larger by joining with any following + unused blocks */ + if (joinMCBs(p) != SUCCESS) + return DE_MCBDESTRY; + + if (size > p->m_size) + { /* block is still too small */ + if (maxSize) + *maxSize = p->m_size; + return DE_NOMEM; + } + } + + /* shrink it down */ + /* From here on, nothing can fail */ + if (size < p->m_size) + { + /* make q a pointer to the new next block */ + q = nxtMCBsize(p, size); + /* reduce the size of p and add difference to q */ + q->m_type = p->m_type; + q->m_size = p->m_size - size - 1; + + p->m_size = size; + + /* Make certian the old psp is not last (if it was) */ + p->m_type = MCB_NORMAL; + + /* Mark the mcb as free so that we can later */ + /* merge with other surrounding free mcb's */ + q->m_psp = FREE_PSP; + for (i = 0; i < 8; i++) + q->m_name[i] = '\0'; + } + return SUCCESS; +} + +/* + * Check the MCB chain for allocation corruption + */ +COUNT DosMemCheck(void) +{ + REG mcb FAR *p; + + /* Initialize */ + p = para2far(first_mcb); + + /* Search through memory blocks */ + while (p->m_type != MCB_LAST) /* not all MCBs touched */ + { + /* check for corruption */ + if (p->m_type != MCB_NORMAL) + return DE_MCBDESTRY; + + /* not corrupted - but not end, bump the pointer */ + p = nxtMCB(p); + } + + return SUCCESS; +} + +COUNT FreeProcessMem(UWORD ps) +{ + mcb FAR *p; + + /* Initialize */ + p = para2far(first_mcb); + + /* Search through memory blocks */ + while (mcbValid(p)) /* check for corruption */ + { + if (p->m_psp == ps) + DosMemFree(FP_SEG(p)); + + /* not corrupted - if last we're OK! */ + if (p->m_type == MCB_LAST) + return SUCCESS; + + p = nxtMCB(p); + } + + return DE_MCBDESTRY; +} + +#if 0 + /* seems to be superceeded by DosMemLargest + -- 1999/04/21 ska */ +COUNT DosGetLargestBlock(UWORD FAR * block) +{ + UWORD sz = 0; + mcb FAR *p; + *block = sz; + + /* Initialize */ + p = (mcb FAR *) (MK_FP(first_mcb, 0)); + + /* Search through memory blocks */ + for (;;) + { + /* check for corruption */ + if (p->m_type != MCB_NORMAL && p->m_type != MCB_LAST) + return DE_MCBDESTRY; + + if (p->m_psp == FREE_PSP && p->m_size > sz) + sz = p->m_size; + + /* not corrupted - if last we're OK! */ + if (p->m_type == MCB_LAST) + break; + p = nxtMCB(p); + + } + *block = sz; + return SUCCESS; +} +#endif + +VOID show_chain(void) +{ + mcb FAR *p = para2far(first_mcb); + + for (;;) + { + mcb_print(p); + if (p->m_type == MCB_LAST || p->m_type != MCB_NORMAL) + return; + else + p = nxtMCB(p); + } +} + +VOID mcb_print(mcb FAR * mcbp) +{ + static BYTE buff[9]; + VOID _fmemcpy(); + + _fmemcpy((BYTE FAR *) buff, (BYTE FAR *) (mcbp->m_name), 8); + buff[8] = '\0'; + printf("%04x:%04x -> |%s| m_type = 0x%02x '%c'; m_psp = 0x%04x; m_size = 0x%04x\n", + FP_SEG(mcbp), + FP_OFF(mcbp), + *buff == '\0' ? "*NO-ID*" : buff, + mcbp->m_type, mcbp->m_type > ' ' ? mcbp->m_type : ' ', + mcbp->m_psp, + mcbp->m_size); +} + +VOID _fmemcpy(BYTE FAR * d, BYTE FAR * s, REG COUNT n) +{ + while (n--) + *d++ = *s++; + +} +#endif diff --git a/kernel/misc.c b/kernel/misc.c new file mode 100644 index 00000000..0fe55814 --- /dev/null +++ b/kernel/misc.c @@ -0,0 +1,140 @@ +/****************************************************************/ +/* */ +/* misc.c */ +/* */ +/* Miscellaneous Kernel Functions */ +/* */ +/* Copyright (c) 1993 */ +/* Pasquale J. Villani */ +/* All Rights Reserved */ +/* */ +/* This file is part of DOS-C. */ +/* */ +/* DOS-C is free software; you can redistribute it and/or */ +/* modify it under the terms of the GNU General Public License */ +/* as published by the Free Software Foundation; either version */ +/* 2, or (at your option) any later version. */ +/* */ +/* DOS-C is distributed in the hope that it will be useful, but */ +/* WITHOUT ANY WARRANTY; without even the implied warranty of */ +/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See */ +/* the GNU General Public License for more details. */ +/* */ +/* You should have received a copy of the GNU General Public */ +/* License along with DOS-C; see the file COPYING. If not, */ +/* write to the Free Software Foundation, 675 Mass Ave, */ +/* Cambridge, MA 02139, USA. */ +/****************************************************************/ + +#include "portab.h" + +#ifdef VERSION_STRINGS +static BYTE *miscRcsId = "$Id$"; +#endif + +/* + * $Log$ + * Revision 1.1 2000/05/06 19:35:27 jhall1 + * Initial revision + * + * Revision 1.4 2000/03/09 06:07:11 kernel + * 2017f updates by James Tabor + * + * Revision 1.3 1999/05/03 06:25:45 jprice + * Patches from ror4 and many changed of signed to unsigned variables. + * + * Revision 1.2 1999/04/23 04:24:39 jprice + * Memory manager changes made by ska + * + * Revision 1.1.1.1 1999/03/29 15:42:19 jprice + * New version without IPL.SYS + * + * Revision 1.3 1999/02/01 01:43:28 jprice + * Fixed findfirst function to find volume label with Windows long filenames + * + * Revision 1.2 1999/01/22 04:15:28 jprice + * Formating + * + * Revision 1.1.1.1 1999/01/20 05:51:00 jprice + * Imported sources + * + * + * Rev 1.5 04 Jan 1998 23:14:36 patv + * Changed Log for strip utility + * + * Rev 1.4 29 May 1996 21:15:18 patv + * bug fixes for v0.91a + * + * Rev 1.3 19 Feb 1996 3:20:12 patv + * Added NLS, int2f and config.sys processing + * + * Rev 1.2 01 Sep 1995 17:48:46 patv + * First GPL release. + * + * Rev 1.1 30 Jul 1995 20:50:28 patv + * Eliminated version strings in ipl + * + * Rev 1.0 02 Jul 1995 8:06:28 patv + * Initial revision. + */ + +#include "globals.h" + +VOID scopy(REG BYTE * s, REG BYTE * d) +{ + while (*s) + *d++ = *s++; + *d = '\0'; +} + +VOID FAR init_call_scopy(REG BYTE * s, REG BYTE * d) +{ + scopy(s, d); +} + +VOID fscopy(REG BYTE FAR * s, REG BYTE FAR * d) +{ + while (*s) + *d++ = *s++; + *d = '\0'; +} + +VOID fsncopy(BYTE FAR * s, BYTE FAR * d, REG COUNT n) +{ + while (*s && n--) + *d++ = *s++; + *d = '\0'; +} + +#ifndef ASMSUPT +VOID bcopy(REG BYTE * s, REG BYTE * d, REG COUNT n) +{ + while (n--) + *d++ = *s++; +} + +VOID fbcopy(REG VOID FAR * s, REG VOID FAR * d, REG COUNT n) +{ + while (n--) + *((BYTE FAR *) d)++ = *((BYTE FAR *) s)++; +} + +VOID fmemset(REG VOID FAR * s, REG int ch, REG COUNT n) +{ + while (n--) + *((BYTE FAR *) s)++ = ch; +} + +#endif + +VOID FAR init_call_fbcopy(REG VOID FAR * s, REG VOID FAR * d, REG COUNT n) +{ + fbcopy(s, d, n); +} + +VOID fmemset(VOID FAR *, int, COUNT); + +VOID FAR init_call_fmemset(REG VOID FAR * s, REG int ch, REG COUNT n) +{ + fmemset(s, ch, n); +} diff --git a/kernel/network.c b/kernel/network.c new file mode 100644 index 00000000..f627d607 --- /dev/null +++ b/kernel/network.c @@ -0,0 +1,209 @@ +/****************************************************************/ +/* */ +/* network.c */ +/* DOS-C */ +/* */ +/* Networking Support functions */ +/* */ +/* Copyright (c) 1995, 1999 */ +/* James Tabor */ +/* All Rights Reserved */ +/* */ +/* This file is part of DOS-C. */ +/* */ +/* DOS-C is free software; you can redistribute it and/or */ +/* modify it under the terms of the GNU General Public License */ +/* as published by the Free Software Foundation; either version */ +/* 2, or (at your option) any later version. */ +/* */ +/* DOS-C is distributed in the hope that it will be useful, but */ +/* WITHOUT ANY WARRANTY; without even the implied warranty of */ +/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See */ +/* the GNU General Public License for more details. */ +/* */ +/* You should have received a copy of the GNU General Public */ +/* License along with DOS-C; see the file COPYING. If not, */ +/* write to the Free Software Foundation, 675 Mass Ave, */ +/* Cambridge, MA 02139, USA. */ +/****************************************************************/ + +#include "portab.h" +#include "globals.h" + +#ifdef VERSION_STRINGS +static BYTE *RcsId = "$Id$"; +#endif + +/* + * $Log$ + * Revision 1.1 2000/05/06 19:35:27 jhall1 + * Initial revision + * + * Revision 1.3 2000/03/09 06:07:11 kernel + * 2017f updates by James Tabor + * + * Revision 1.2 1999/09/23 04:40:48 jprice + * *** empty log message *** + * + */ + +UWORD get_machine_name(BYTE FAR * netname) +{ + BYTE FAR *xn; + + xn = MK_FP(net_name, 0); + fbcopy((BYTE FAR *) netname, xn, 15); + return (NetBios); + +} + +VOID set_machine_name(BYTE FAR * netname, UWORD name_num) +{ + BYTE FAR *xn; + + xn = MK_FP(net_name, 0); + NetBios = name_num; + fbcopy(xn, (BYTE FAR *) netname, 15); + net_set_count++; + +} + +/* + * Read/Write from/to remote file. + * SFT gets updated with the amount of bytes r/w. + * + */ +UCOUNT Remote_RW(UWORD func, UCOUNT n, BYTE FAR * bp, sft FAR * s, COUNT FAR * err) +{ + + BYTE FAR *save_dta; + UWORD rc, + rx; + + save_dta = dta; + lpCurSft = (sfttbl FAR *) s; + dta = bp; + rx = int2f_Remote_call(func, 0, n, 0, (VOID FAR *) s, 0, (VOID FAR *) & rc); + dta = save_dta; + *err = rx; + return ((UCOUNT) rc); +} + +/* + + */ +COUNT Remote_find(UWORD func, UWORD attrib, BYTE FAR * name, REG dmatch FAR * dmp) +{ + COUNT i, + x; + BYTE FAR *p, + *q; + struct dirent FAR *SDp = (struct dirent FAR *)&SearchDir; + + if (func == REM_FINDFIRST) + { + truename(name, PriPathName, FALSE); + SAttr = (BYTE) attrib; + } + fsncopy(dta, (BYTE FAR *) & TempBuffer, 21); + p = dta; + dta = (BYTE FAR *) & TempBuffer; + i = int2f_Remote_call(func, 0, 0, 0, 0, 0, 0); + dta = p; + fsncopy((BYTE FAR *) & TempBuffer[1], &dta[1], 20); + + if (i != 0) + return i; + + dmp->dm_attr_fnd = (BYTE) SDp->dir_attrib; + dmp->dm_time = SDp->dir_time; + dmp->dm_date = SDp->dir_date; + dmp->dm_size = (LONG) SDp->dir_size; + +/* + Needed Code Rep-off.;) + */ + p = dmp->dm_name; + if (SDp->dir_name[0] == '.') + { + for (x = 0, q = (BYTE FAR *) SDp->dir_name; x < FNAME_SIZE; x++) + { + if (*q == ' ') + break; + *p++ = *q++; + } + } + else + { + for (x = 0, q = (BYTE FAR *) SDp->dir_name; x < FNAME_SIZE; x++) + { + if (*q == ' ') + break; + *p++ = *q++; + } + if (SDp->dir_ext[0] != ' ') + { + *p++ = '.'; + for (x = 0, q = (BYTE FAR *) SDp->dir_ext; x < FEXT_SIZE; x++) + { + if (*q == ' ') + break; + *p++ = *q++; + } + } + } + *p++ = NULL; + + return i; +} + +/* + * Open Existing Remote File, SDA First FN ptr -> Fully qualified name. + * open func 3d + * Create/Truncate w/o CDS Remote File + * Extended Open/Create File + */ +UWORD Remote_OCT(UWORD func, BYTE FAR * name, UWORD pw, sft FAR * s) +{ + truename(name, PriPathName, FALSE); + lpCurSft = (sfttbl FAR *) s; + return (int2f_Remote_call(func, 0, 0, 0, (VOID FAR *) s, 0, MK_FP(0, pw))); +} + +COUNT Remote_GSattr(UWORD func, BYTE FAR * name, UWORD FAR * attrp) +{ + static char srfa[10]; + COUNT drive; + struct cds FAR *p; + + truename(name, PriPathName, TRUE); + drive = PriPathName[0]; + drive -= 'A'; + truename(name, PriPathName, FALSE); + + if (CDSp->cds_table[drive].cdsFlags & 0x8000) + { + p = current_ldt; + current_ldt = &CDSp->cds_table[drive]; + if (func == REM_GETATTRZ) + { + + if (int2f_Remote_call(func, 0, 0, 0, 0, 0, (VOID FAR *) srfa) != 0) + { + current_ldt = p; + goto AEXIT; + } + *attrp = (UWORD) srfa[0]; + goto GEXIT; + } + int2f_Remote_call(func, 0, 0, 0, 0, 0, MK_FP(0, attrp)); + GEXIT: + current_ldt = p; + return (COUNT) 0; + } +AEXIT: + return (COUNT) 1; + +} + + diff --git a/kernel/newstuff.c b/kernel/newstuff.c new file mode 100644 index 00000000..f4d0e99e --- /dev/null +++ b/kernel/newstuff.c @@ -0,0 +1,326 @@ +/****************************************************************/ +/* */ +/* newstuff.c */ +/* DOS-C */ +/* */ +/* Copyright (c) 1996 */ +/* Svante Frey */ +/* All Rights Reserved */ +/* */ +/* This file is part of DOS-C. */ +/* */ +/* DOS-C is free software; you can redistribute it and/or */ +/* modify it under the terms of the GNU General Public License */ +/* as published by the Free Software Foundation; either version */ +/* 2, or (at your option) any later version. */ +/* */ +/* DOS-C is distributed in the hope that it will be useful, but */ +/* WITHOUT ANY WARRANTY; without even the implied warranty of */ +/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See */ +/* the GNU General Public License for more details. */ +/* */ +/* You should have received a copy of the GNU General Public */ +/* License along with DOS-C; see the file COPYING. If not, */ +/* write to the Free Software Foundation, 675 Mass Ave, */ +/* Cambridge, MA 02139, USA. */ +/****************************************************************/ + +#ifdef VERSION_STRINGS +static BYTE *mainRcsId = "$Id$"; +#endif + +/* + * $Log$ + * Revision 1.1 2000/05/06 19:35:27 jhall1 + * Initial revision + * + * Revision 1.5 2000/03/09 06:07:11 kernel + * 2017f updates by James Tabor + * + * Revision 1.4 1999/08/25 03:18:09 jprice + * ror4 patches to allow TC 2.01 compile. + * + * Revision 1.3 1999/04/11 04:33:39 jprice + * ror4 patches + * + * Revision 1.2 1999/04/04 18:51:43 jprice + * no message + * + * Revision 1.1.1.1 1999/03/29 15:41:22 jprice + * New version without IPL.SYS + * + * Revision 1.4 1999/02/08 05:55:57 jprice + * Added Pat's 1937 kernel patches + * + * Revision 1.3 1999/02/01 01:48:41 jprice + * Clean up; Now you can use hex numbers in config.sys. added config.sys screen function to change screen mode (28 or 43/50 lines) + * + * Revision 1.2 1999/01/22 04:13:26 jprice + * Formating + * + * Revision 1.1.1.1 1999/01/20 05:51:01 jprice + * Imported sources + * + * + * Rev 1.4 06 Dec 1998 8:49:02 patv + * Bug fixes. + * + * Rev 1.3 04 Jan 1998 23:15:22 patv + * Changed Log for strip utility + * + * Rev 1.2 04 Jan 1998 17:26:14 patv + * Corrected subdirectory bug + * + * Rev 1.1 22 Jan 1997 13:21:22 patv + * pre-0.92 Svante Frey bug fixes. + */ + +#include "portab.h" +#include "globals.h" +#include "proto.h" + +int SetJFTSize(UWORD nHandles) +{ + UWORD block, + maxBlock; + psp FAR *ppsp = MK_FP(cu_psp, 0); + UBYTE FAR *newtab; + COUNT i; + + if (nHandles <= ppsp->ps_maxfiles) + { + ppsp->ps_maxfiles = nHandles; + return SUCCESS; + } + + if ((DosMemAlloc((nHandles + 0xf) >> 4, mem_access_mode, &block, &maxBlock)) < 0) + return DE_NOMEM; + + ++block; + newtab = MK_FP(block, 0); + + for (i = 0; i < ppsp->ps_maxfiles; i++) + newtab[i] = ppsp->ps_filetab[i]; + + for (; i < nHandles; i++) + newtab[i] = 0xff; + + ppsp->ps_maxfiles = nHandles; + ppsp->ps_filetab = newtab; + + return SUCCESS; +} + +int DosMkTmp(BYTE FAR * pathname, UWORD attr) +{ + /* create filename from current date and time */ + static const char tokens[] = "0123456789ABCDEF"; + char FAR *ptmp = pathname; + BYTE wd, + month, + day; + BYTE h, + m, + s, + hund; + WORD sh; + WORD year; + int rc; + + while (*ptmp) + ptmp++; + + if (ptmp == pathname || (ptmp[-1] != '\\' && ptmp[-1] != '/')) + *ptmp++ = '\\'; + + DosGetDate(&wd, &month, &day, (COUNT FAR *) & year); + DosGetTime(&h, &m, &s, &hund); + + sh = s * 100 + hund; + + ptmp[0] = tokens[year & 0xf]; + ptmp[1] = tokens[month]; + ptmp[2] = tokens[day & 0xf]; + ptmp[3] = tokens[h & 0xf]; + ptmp[4] = tokens[m & 0xf]; + ptmp[5] = tokens[(sh >> 8) & 0xf]; + ptmp[6] = tokens[(sh >> 4) & 0xf]; + ptmp[7] = tokens[sh & 0xf]; + ptmp[8] = '.'; + ptmp[9] = 'A'; + ptmp[10] = 'A'; + ptmp[11] = 'A'; + ptmp[12] = 0; + + while ((rc = DosOpen(pathname, 0)) >= 0) + { + DosClose(rc); + + if (++ptmp[11] > 'Z') + { + if (++ptmp[10] > 'Z') + { + if (++ptmp[9] > 'Z') + return DE_TOOMANY; + + ptmp[10] = 'A'; + } + ptmp[11] = 'A'; + } + } + + if (rc == DE_FILENOTFND) + { + rc = DosCreat(pathname, attr); + } + return rc; +} +/* + * Added support for external and internal calls. + * Clean buffer before use. Make the true path and expand file names. + * Example: *.* -> ????????.??? as in the currect way. + */ +int truename(char FAR * src, char FAR * dest, COUNT t) +{ + static char buf[128] = "A:\\"; + char *bufp = buf + 3; + COUNT i, + n; + BYTE far *test; + REG struct cds FAR *cdsp; + + fbcopy((VOID FAR *) "A:\\\0\0\0\0\0\0\0", (VOID FAR *) buf, 10); + + /* First, adjust the source pointer */ + src = adjust_far(src); + + /* Do we have a drive? */ + if (src[1] == ':') + { + buf[0] = (src[0] | 0x20) + 'A' - 'a'; + + if (buf[0] >= lastdrive + 'A') + return DE_PATHNOTFND; + + src += 2; + } + else + buf[0] = default_drive + 'A'; + + i = buf[0] - '@'; + + cdsp = &CDSp->cds_table[i - 1]; + + if (cdsp->cdsFlags & 0x8000) + { + QRemote_Fn(src, dest); + if (t == FALSE) + { + bufp += 4; + fsncopy((BYTE FAR *) & cdsp->cdsCurrentPath[0], (BYTE FAR *) & buf[0], cdsp->cdsJoinOffset); + *bufp++ = '\\'; + } + } + + if (*src != '\\' && *src != '/') /* append current dir */ + { + DosGetCuDir(i, bufp); + if (*bufp) + { + while (*bufp) + bufp++; + *bufp++ = '\\'; + } + } + else + src++; + + /* convert all forward slashes to backslashes, and uppercase all characters */ + while (*src) + { + char c; + + switch ((c = *src++)) + { +/* added *.*, *., * support. + */ + case '*': + if (*src == '.') + { + n = 8; + while (n--) + *bufp++ = '?'; + break; + } + else + { + if (src[-2] == '.') + { + n = 3; + while (n--) + *bufp++ = '?'; + break; + } + else + { + n = 8; + while (n--) + *bufp++ = '?'; + break; + } + } + + case '/': /* convert to backslash */ + case '\\': + + if (bufp[-1] != '\\') + *bufp++ = '\\'; + break; + + /* look for '.' and '..' dir entries */ + case '.': + if (bufp[-1] == '\\') + { + if (*src == '.' && (src[1] == '/' || src[1] == '\\' || !src[1])) + { + /* '..' dir entry: rewind bufp to last backslash */ + + for (bufp -= 2; *bufp != '\\'; bufp--) + { + if (bufp < buf + 2) /* '..' illegal in root dir */ + return DE_PATHNOTFND; + } + src++; + if (bufp[-1] == ':') + bufp++; + } + else if (*src == '/' || *src == '\\' || *src == 0) + --bufp; + } + else + *bufp++ = c; + break; + + default: + *bufp++ = c; + break; + } + } + /* remove trailing backslashes */ + while (bufp[-1] == '\\') + --bufp; + + if (bufp == buf + 2) + ++bufp; + + *bufp++ = 0; + + /* finally, uppercase everything */ + upString(buf); + + /* copy to user's buffer */ + fbcopy(buf, dest, bufp - buf); + + return SUCCESS; +} + diff --git a/kernel/nls.c b/kernel/nls.c new file mode 100644 index 00000000..582998fe --- /dev/null +++ b/kernel/nls.c @@ -0,0 +1,667 @@ +/****************************************************************/ +/* */ +/* nls.c */ +/* DOS-C */ +/* */ +/* National Languge Support functions and data structures */ +/* */ +/* Copyright (c) 1995, 1996 */ +/* Pasquale J. Villani */ +/* All Rights Reserved */ +/* */ +/* Copyright (c) 1995, 1996 */ +/* Steffen Kaiser */ +/* All Rights Reserved */ +/* */ +/* This file is part of DOS-C. */ +/* */ +/* DOS-C is free software; you can redistribute it and/or */ +/* modify it under the terms of the GNU General Public License */ +/* as published by the Free Software Foundation; either version */ +/* 2, or (at your option) any later version. */ +/* */ +/* DOS-C is distributed in the hope that it will be useful, but */ +/* WITHOUT ANY WARRANTY; without even the implied warranty of */ +/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See */ +/* the GNU General Public License for more details. */ +/* */ +/* You should have received a copy of the GNU General Public */ +/* License along with DOS-C; see the file COPYING. If not, */ +/* write to the Free Software Foundation, 675 Mass Ave, */ +/* Cambridge, MA 02139, USA. */ +/****************************************************************/ + +#include "portab.h" +#include "globals.h" + +#ifdef VERSION_STRINGS +static BYTE *RcsId = "$Id$"; +#endif + +/* + * $Log$ + * Revision 1.1 2000/05/06 19:35:29 jhall1 + * Initial revision + * + * Revision 1.7 2000/03/09 06:07:11 kernel + * 2017f updates by James Tabor + * + * Revision 1.6 1999/09/23 04:40:48 jprice + * *** empty log message *** + * + * Revision 1.4 1999/08/25 03:18:09 jprice + * ror4 patches to allow TC 2.01 compile. + * + * Revision 1.3 1999/05/03 06:25:45 jprice + * Patches from ror4 and many changed of signed to unsigned variables. + * + * Revision 1.2 1999/04/16 00:53:33 jprice + * Optimized FAT handling + * + * Revision 1.1.1.1 1999/03/29 15:41:24 jprice + * New version without IPL.SYS + * + * Revision 1.6 1999/02/08 05:55:57 jprice + * Added Pat's 1937 kernel patches + * + * Revision 1.5 1999/02/04 03:12:08 jprice + * Removed extra text. Made .exe smaller. + * + * Revision 1.4 1999/02/01 01:48:41 jprice + * Clean up; Now you can use hex numbers in config.sys. added config.sys screen function to change screen mode (28 or 43/50 lines) + * + * Revision 1.3 1999/01/30 08:28:12 jprice + * Clean up; Fixed bug with set attribute function. + * + * Revision 1.2 1999/01/22 04:13:26 jprice + * Formating + * + * Revision 1.1.1.1 1999/01/20 05:51:01 jprice + * Imported sources + * + * + * Rev 1.4 04 Jan 1998 23:15:16 patv + * Changed Log for strip utility + * + * Rev 1.3 16 Jan 1997 12:46:54 patv + * pre-Release 0.92 feature additions + * + * Rev 1.2 29 May 1996 21:03:46 patv + * bug fixes for v0.91a + * + * Rev 1.1 19 Feb 1996 4:34:46 patv + * Corrected typo + * + * Rev 1.0 19 Feb 1996 3:21:46 patv + * Added NLS, int2f and config.sys processing + */ + +extern UWORD internalUpcase(UWORD c); + +#ifdef __TURBOC__ +/* TC 2.01 require these. :( -- ror4 */ +void __int__(int); +void __emit__(); +#endif + +/* one byte alignment */ + +#if defined(_MSC_VER) +#define asm __asm +#pragma pack(1) +#elif defined(_QC) || defined(__WATCOM__) +#pragma pack(1) +#elif defined(__ZTC__) +#pragma ZTC align 1 +#elif defined(__TURBOC__) && (__TURBOC__ > 0x202) +#pragma option -a- +#endif + +struct ctryInfo +{ /* Country Information DOS-38 */ + WORD dateFmt; /* 0: USA, 1: Europe, 2: Japan */ + char curr[5]; /* ASCIZ of currency string */ + char thSep[2]; /* ASCIZ of thousand's separator */ + char point[2]; /* ASCIZ of decimal point */ + char dateSep[2]; /* ASCIZ of date separator */ + char timeSep[2]; /* ASCIZ of time separator */ + BYTE currFmt; /* format of currency: + bit 0: currency string is placed 0: before, 1: behind number + bit 1: currency string and number are separated by a space; 0: No, 1: Yes + */ + BYTE prescision; /* */ + BYTE timeFmt; /* time format: 0: 12 hours; 1: 24 houres */ + VOID(FAR * upCaseFct) (VOID); /* far call to a function mapping character in register AL */ + char dataSep[2]; /* ASCIZ of separator in data records */ +}; + +struct _VectorTable +{ + VOID FAR *Table; + BYTE FnCode; +}; + +struct _NlsInfo +{ + struct extCtryInfo + { + BYTE reserved[8]; + BYTE countryFname[64]; + WORD sysCodePage; + WORD nFnEntries; + struct _VectorTable VectorTable[6]; + + /* Extended Country Information DOS-65-01 */ + WORD countryCode; /* current COUNTRY= code */ + WORD codePage; /* current code page (CP) */ + + struct ctryInfo nlsCtryInfo; + } + nlsExtCtryInfo; + +/* characters of Yes/No prompt for DOS-65-23 */ + char yesCharacter; + char noCharacter; + +/* upcased characters for ECS-ASCII > 0x7f for DOS-65-02 */ + WORD upNCsize; /* number of entries in the following array */ + char upNormCh[128]; + +/* upcased characters for ECS-ASCII > 0x7f for file names for DOS-65-04 */ + WORD upFCsize; /* number of entries in the following array */ + char upFileCh[128]; + +/* collating sequence for ECS-ASCII 0..0xff for DOS-65-06 */ + WORD collSize; /* number of entries in the following array */ + char collSeq[256]; + +/* DBC support for DOS-65-07 */ + WORD dbcSize; /* number of entries in the following array */ + /* char dbcTable[1024]; no DBC support */ + WORD dbcEndMarker; /* contains always 0 */ + +/* in file names permittable characters for DOS-65-05 */ + struct chFileNames + { + WORD fnSize; /* size of this structure */ + BYTE dummy1; + char firstCh, + lastCh; /* first, last permittable character */ + BYTE dummy2; + char firstExcl, + lastExcl; /* first, last excluded character */ + BYTE dummy3; + BYTE numSep; /* number of file name separators */ + char fnSeparators[14]; + } + nlsFn; +} +nlsInfo +#ifdef INIT_NLS_049 += /* let's initialize it with values for Germany */ +#include "049-437.nls" +#else += /* let's initialize it with default values (USA) */ +#include "001-437.nls" +#endif + ; + +#define normalCh nlsInfo.upNormCh +#define fileCh nlsInfo.upFileCh +#define yesChar nlsInfo.yesCharacter +#define noChar nlsInfo.noCharacter + +#define PathSep(c) ((c)=='/'||(c)=='\\') +#define DriveChar(c) (((c)>='A'&&(c)<='Z')||((c)>='a'&&(c)<='z')) + +/* COUNTRY.SYS structures */ +struct CpiHeader +{ + BYTE name[8]; /* signature */ + BYTE reserved[8]; + WORD nPointers; /* size of following array */ + + struct + { + BYTE pointerType; /* always 1 */ + DWORD offset; /* offset to data */ + } + pointer[1]; +}; + +struct CountryRecord +{ + WORD length; /* size of record */ + WORD country; /* country code */ + WORD codePage; /* code page */ + WORD reserved[2]; + DWORD subCountryOffset; /* offset to data record */ +}; + +struct CountryTableDescr +{ + WORD length; /* size of structure */ + WORD id; /* table type id */ + DWORD offset; /* offset to table data */ +}; + +/* standard alignment */ + +#if defined (_MSC_VER) || defined(_QC) || defined(__WATCOMC__) +#pragma pack() +#elif defined (__ZTC__) +#pragma ZTC align +#elif defined(__TURBOC__) && (__TURBOC__ > 0x202) +#pragma option -a. +#endif + +COUNT NlsFuncInst(VOID) +{ + BYTE cNlsRet; + +#ifndef __TURBOC__ + asm + { + xor bx, + bx + mov ax, + 0x1400 + int 0x2F + mov cNlsRet, + al + } +#else + _BX = 0; + _AX = 0x1400; + __int__(0x2f); + cNlsRet = _AL; +#endif + + /* Return the al register as sign extended: */ + /* 0 == not installed, ok to install */ + /* 1 == not installed, not ok to install */ + /* -1 == installed */ + return cNlsRet; +} + +BOOL +GetGlblCodePage(UWORD FAR * ActvCodePage, UWORD FAR * SysCodePage) +{ + *ActvCodePage = nlsInfo.nlsExtCtryInfo.codePage; + *SysCodePage = nlsInfo.nlsExtCtryInfo.sysCodePage; + return TRUE; +} + +BOOL +SetGlblCodePage(UWORD FAR * ActvCodePage, UWORD FAR * SysCodePage) +{ + nlsInfo.nlsExtCtryInfo.codePage = *ActvCodePage; + nlsInfo.nlsExtCtryInfo.sysCodePage = *SysCodePage; + return TRUE; +} + +UWORD SetCtryInfo(UBYTE FAR * lpShrtCode, UWORD FAR * lpLongCode, + BYTE FAR * lpTable, UBYTE * nRetCode) +{ + UWORD CntryCode; + UBYTE nNlsEntry; + UWORD uSegTable, + uOffTable; + UBYTE nLclRet; + + /* Get the Country Code according to the DOS silly rules. */ + if (0xff != *lpShrtCode) + CntryCode = *lpShrtCode; + else + CntryCode = *lpLongCode; + + /* If it's the same country code as what's installed, just */ + /* return because there's nothing to do. */ + if (CntryCode == nlsInfo.nlsExtCtryInfo.countryCode) + { + *nRetCode = 0; + return CntryCode; + } + + /* Check if nlsfunc is installed */ + if (NlsFuncInst() >= 0) + { + *nRetCode = 0xff; + return 0xffff; + } + + /* Get the country information from nlsfunc */ + uSegTable = FP_SEG(lpTable); + uOffTable = FP_OFF(lpTable); + +#ifndef __TURBOC__ + asm + { + push ds + mov bx, + CntryCode + mov ax, + uSegTable + mov dx, + uOffTable + mov ds, + ax + mov ax, + 0x1404 + int 0x2F + pop ds + mov CntryCode, + bx + mov nLclRet, + al + } +#else + /* XXX: this is ugly... but needed on `tcc' 2.01 without `tasm'. -- ror4 */ + __emit__(0x1e); /* push ds */ + _BX = CntryCode; + _AX = uSegTable; + _DX = uOffTable; + _DS = _AX; + _AX = 0x1404; + __int__(0x2f); + __emit__(0x1f); /* pop ds */ + CntryCode = _BX; + nLclRet = _AL; +#endif + *nRetCode = nLclRet; + return CntryCode; +} + +UWORD GetCtryInfo(UBYTE FAR * lpShrtCode, UWORD FAR * lpLongCode, + BYTE FAR * lpTable) +{ + fbcopy((BYTE FAR *) & nlsInfo.nlsExtCtryInfo.nlsCtryInfo, + lpTable, sizeof(struct ctryInfo)); + return nlsInfo.nlsExtCtryInfo.countryCode; +} + +BOOL ExtCtryInfo(UBYTE nOpCode, UWORD CodePageID, UWORD InfoSize, VOID FAR * Information) +{ + VOID FAR *lpSource; + COUNT nIdx; + + if (0xffff != CodePageID) + { + UBYTE nNlsEntry; + + if (NlsFuncInst() >= 0) + return FALSE; + +#ifndef __TURBOC__ + asm + { + mov bp, + word ptr nOpCode + mov bx, + CodePageID + mov si, + word ptr Information + 2 + mov ds, + si + mov si, + word ptr Information + mov ax, + 0x1402 + int 0x2F + cmp al, + 0 + mov nNlsEntry, + al + } +#else + /* XXX: again, this is ugly... -- ror4 */ + __emit__(0x1e, 0x55, 0x56); /* push ds; push bp; push si */ + _BX = CodePageID; + _SI = ((WORD *) & Information)[1]; + _DS = _SI; + _SI = *(WORD *) & Information; + _BP = *(WORD *) & nOpCode; + _BP &= 0x00ff; + _AX = 0x1402; + __int__(0x2f); + nNlsEntry = _AL; + __emit__(0x5e, 0x5d, 0x1f); /* pop si; pop bp; pop ds */ +#endif + + if (0 != nNlsEntry) + return FALSE; + + return TRUE; + } + + CodePageID = nlsInfo.nlsExtCtryInfo.codePage; + + for (nIdx = 0; nIdx < nlsInfo.nlsExtCtryInfo.nFnEntries; nIdx++) + { + if (nlsInfo.nlsExtCtryInfo.VectorTable[nIdx].FnCode == nOpCode) + { + BYTE FAR *bp = Information; + lpSource = nlsInfo.nlsExtCtryInfo.VectorTable[nIdx].Table; + + if (nOpCode == 1) + { + bp++; /* first byte unused */ + + *bp = (BYTE) (sizeof(struct ctryInfo) + 4); + bp += 2; + + fbcopy(lpSource, bp, InfoSize > 3 ? InfoSize - 3 : 0); + } + else + { + *bp++ = nOpCode; + *((VOID FAR **) bp) = lpSource; + } + return TRUE; + } + } + + return FALSE; +} + +UWORD internalUpcase(UWORD c) +{ + if (!(c & 0x80)) + return c; + + return (c & 0xff00) | (nlsInfo.upNormCh[c & 0x7f] & 0xff); +} + +char upMChar(UPMAP map, char ch) +/* upcase character ch according to the map */ +{ + return (ch >= 'a' && ch <= 'z') ? ch + 'A' - 'a' : + ((unsigned)ch > 0x7f ? map[ch & 0x7f] : ch); +} + +VOID upMMem(UPMAP map, char FAR * str, unsigned len) +{ + REG unsigned c; + + if (len) + do + { + if ((c = *str) >= 'a' && c <= 'z') + *str += 'A' - 'a'; + else if (c > 0x7f) + *str = map[c & 0x7f]; + ++str; + } + while (--len); +} + +BYTE yesNo(char ch) /* returns: 0: ch == "No", 1: ch == "Yes", 2: ch crap */ +{ + ch = upMChar(normalCh, ch); + if (ch == noChar) + return 0; + if (ch == yesChar) + return 1; + return 2; +} + +char upChar(char ch) /* upcase a single character */ +{ + return upMChar(normalCh, ch); +} + +VOID upString(char FAR * str) /* upcase a string */ +{ + upMMem(normalCh, str, fstrlen(str)); +} + +VOID upMem(char FAR * str, unsigned len) /* upcase a memory area */ +{ + upMMem(normalCh, str, len); +} + +char upFChar(char ch) /* upcase a single character for file names */ +{ + return upMChar(fileCh, ch); +} + +VOID upFString(char FAR * str) /* upcase a string for file names */ +{ + upMMem(fileCh, str, fstrlen(str)); +} + +VOID upFMem(char FAR * str, unsigned len) /* upcase a memory area for file names */ +{ + upMMem(fileCh, str, len); +} + +/* ReadCountryTable(): + + * Loads a country information table. + */ + +static BOOL ReadCountryTable(COUNT file, WORD id, ULONG offset) +{ + VOID *buf; /* where to load the information */ + UWORD maxSize; /* max number of bytes to read */ + UWORD length; /* length of table in file */ + BOOL rc = TRUE; + + switch (id) + { + case 1: /* extended country information */ + buf = &nlsInfo.nlsExtCtryInfo.countryCode; + maxSize = sizeof(struct ctryInfo) + sizeof(WORD) * 2; + break; + + case 2: /* uppercase table */ + buf = &normalCh[0]; + maxSize = sizeof normalCh; + break; + + case 4: /* filename uppercase table */ + buf = &fileCh[0]; + maxSize = sizeof fileCh; + break; + + case 5: /* filename terminator table */ + buf = &nlsInfo.nlsFn.dummy1; + maxSize = sizeof(struct chFileNames) - sizeof(WORD); + break; + + case 6: /* collating sequence table */ + buf = &nlsInfo.collSeq[0]; + maxSize = sizeof nlsInfo.collSeq; + break; + + default: /* unknown or unsupported table - ignore */ + buf = 0; + break; + } + + if (buf) + { + dos_lseek(file, offset, 0); + dos_read(file, &length, sizeof(length)); + + if (length > maxSize) + length = maxSize; + + if (dos_read(file, buf, length) != length) + rc = FALSE; + + if (id == 1) + nlsInfo.nlsExtCtryInfo.nlsCtryInfo.upCaseFct = CharMapSrvc; + } + + return rc; +} + +/* LoadCountryInfo(): + + * Searches a file in the COUNTRY.SYS format for an entry + * matching the specified code page and country code, and loads + * the corresponding information into memory. If code page is 0, + * the default code page for the country will be used. + * + * Returns TRUE if successful, FALSE if not. + */ + +/* XXX: This function should be placed in `INIT_TEXT'. -- ror4 */ +BOOL FAR LoadCountryInfo(char FAR * filename, WORD ctryCode, WORD codePage) +{ + struct CpiHeader hdr; + struct CountryRecord ctry; + struct CountryTableDescr ct; + COUNT i, + nCountries, + nSubEntries; + ULONG currpos; + int rc = FALSE; + COUNT file; + + if ((file = dos_open(filename, 0)) < 0) + return rc; + + if (dos_read(file, &hdr, sizeof(hdr)) == sizeof(hdr)) + { + /* check signature */ + if (!fstrncmp(hdr.name, "\377COUNTRY", 8)) + { + dos_lseek(file, hdr.pointer[0].offset, 0); + dos_read(file, &nCountries, sizeof(nCountries)); + + /* search for matching country record */ + for (i = 0; i < nCountries; i++) + { + if (dos_read(file, &ctry, sizeof(ctry)) != sizeof(ctry)) + break; + + if (ctry.country == ctryCode && (!codePage || ctry.codePage == codePage)) + { + /* found country - now load the tables */ + dos_lseek(file, ctry.subCountryOffset, 0); + dos_read(file, &nSubEntries, sizeof(nSubEntries)); + currpos = ctry.subCountryOffset + sizeof(nSubEntries); + + for (i = 0; i < nSubEntries; i++) + { + dos_lseek(file, currpos, 0); + if (dos_read(file, &ct, sizeof(ct)) != sizeof(ct)) + break; + + currpos += ct.length + sizeof(ct.length); + ReadCountryTable(file, ct.id, ct.offset + 8); + } + + if (i == nSubEntries) + rc = TRUE; + + break; + } + } + } + } + dos_close(file); + return rc; +} diff --git a/kernel/nlssupt.asm b/kernel/nlssupt.asm new file mode 100644 index 00000000..1de71faa --- /dev/null +++ b/kernel/nlssupt.asm @@ -0,0 +1,103 @@ +; File: +; nls.asm +; Description: +; Assembly support routines for nls functions. +; +; Copyright (c) 1995, 1998 +; Pasquale J. Villani +; All Rights Reserved +; +; This file is part of DOS-C. +; +; DOS-C is free software; you can redistribute it and/or +; modify it under the terms of the GNU General Public License +; as published by the Free Software Foundation; either version +; 2, or (at your option) any later version. +; +; DOS-C is distributed in the hope that it will be useful, but +; WITHOUT ANY WARRANTY; without even the implied warranty of +; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See +; the GNU General Public License for more details. +; +; You should have received a copy of the GNU General Public +; License along with DOS-C; see the file COPYING. If not, +; write to the Free Software Foundation, 675 Mass Ave, +; Cambridge, MA 02139, USA. +; +; $Logfile: C:/dos-c/src/kernel/nlssupt.asv $ +; +; $Id$ +; +; $Log$ +; Revision 1.1 2000/05/06 19:35:29 jhall1 +; Initial revision +; +; Revision 1.2 1999/08/10 17:57:13 jprice +; ror4 2011-02 patch +; +; Revision 1.1.1.1 1999/03/29 15:41:25 jprice +; New version without IPL.SYS +; +; Revision 1.4 1999/02/08 05:55:57 jprice +; Added Pat's 1937 kernel patches +; +; Revision 1.3 1999/02/01 01:48:41 jprice +; Clean up; Now you can use hex numbers in config.sys. added config.sys screen function to change screen mode (28 or 43/50 lines) +; +; Revision 1.2 1999/01/22 04:13:26 jprice +; Formating +; +; Revision 1.1.1.1 1999/01/20 05:51:01 jprice +; Imported sources +; +; Rev 1.3 06 Dec 1998 8:46:56 patv +; Bug fixes. +; +; Rev 1.2 16 Jan 1997 12:46:44 patv +; pre-Release 0.92 feature additions +; +; Rev 1.1 29 May 1996 21:03:38 patv +; bug fixes for v0.91a +; +; Rev 1.0 19 Feb 1996 3:24:04 patv +; Added NLS, int2f and config.sys processing +; $EndLog$ +; + + + %include "segs.inc" + +segment _TEXT + global _CharMapSrvc + extern _internalUpcase:wrt TGROUP +; +; CharMapSrvc: +; User callable character mapping service. +; Part of Function 38h +; +_CharMapSrvc: + push ds + push es + push bp + push si + push di + push dx + push cx + push bx + + mov dx, DGROUP + mov ds, dx + + push ax + call _internalUpcase + add sp, byte 2 + + pop bx + pop cx + pop dx + pop di + pop si + pop bp + pop es + pop ds + retf ; Return far diff --git a/kernel/prf.c b/kernel/prf.c new file mode 100644 index 00000000..c0eff709 --- /dev/null +++ b/kernel/prf.c @@ -0,0 +1,410 @@ +/****************************************************************/ +/* */ +/* prf.c */ +/* */ +/* Abbreviated printf Function */ +/* */ +/* Copyright (c) 1995 */ +/* Pasquale J. Villani */ +/* All Rights Reserved */ +/* */ +/* This file is part of DOS-C. */ +/* */ +/* DOS-C is free software; you can redistribute it and/or */ +/* modify it under the terms of the GNU General Public License */ +/* as published by the Free Software Foundation; either version */ +/* 2, or (at your option) any later version. */ +/* */ +/* DOS-C is distributed in the hope that it will be useful, but */ +/* WITHOUT ANY WARRANTY; without even the implied warranty of */ +/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See */ +/* the GNU General Public License for more details. */ +/* */ +/* You should have received a copy of the GNU General Public */ +/* License along with DOS-C; see the file COPYING. If not, */ +/* write to the Free Software Foundation, 675 Mass Ave, */ +/* Cambridge, MA 02139, USA. */ +/****************************************************************/ + +#include "portab.h" + +#ifdef VERSION_STRINGS +static BYTE *prfRcsId = "$Id$"; +#endif + +/* + * $Log$ + * Revision 1.1 2000/05/06 19:35:29 jhall1 + * Initial revision + * + * Revision 1.3 2000/03/09 06:07:11 kernel + * 2017f updates by James Tabor + * + * Revision 1.2 1999/04/04 18:51:43 jprice + * no message + * + * Revision 1.1.1.1 1999/03/29 15:42:20 jprice + * New version without IPL.SYS + * + * Revision 1.3 1999/02/01 01:43:28 jprice + * Fixed findfirst function to find volume label with Windows long filenames + * + * Revision 1.2 1999/01/22 04:15:28 jprice + * Formating + * + * Revision 1.1.1.1 1999/01/20 05:51:00 jprice + * Imported sources + * + * + * Rev 1.4 04 Jan 1998 23:14:38 patv + * Changed Log for strip utility + * + * Rev 1.3 29 May 1996 21:15:10 patv + * bug fixes for v0.91a + * + * Rev 1.2 01 Sep 1995 17:48:42 patv + * First GPL release. + * + * Rev 1.1 30 Jul 1995 20:50:26 patv + * Eliminated version strings in ipl + * + * Rev 1.0 02 Jul 1995 8:05:10 patv + * Initial revision. + */ + +static BYTE *charp; + +#ifdef PROTO +VOID handle_char(COUNT); +VOID put_console(COUNT); +BYTE *ltob(LONG, BYTE *, COUNT); +static BYTE *itob(COUNT, BYTE *, COUNT); +COUNT do_printf(CONST BYTE *, REG BYTE **); +#else +VOID handle_char(); +VOID put_console(); +BYTE *ltob(); +static BYTE *itob(); +COUNT do_printf(); +#endif + +/* The following is user supplied and must match the following prototype */ +#ifdef PROTO +VOID cso(COUNT); +#else +VOID cso(); +#endif + +/* special console output routine */ +VOID +put_console(COUNT c) +{ + if (c == '\n') + cso('\r'); + cso(c); +} + +/* special handler to switch between sprintf and printf */ +static VOID + handle_char(COUNT c) +{ + if (charp == 0) + put_console(c); + else + *charp++ = c; +} + +/* ltob -- convert an long integer to a string in any base (2-16) */ +static BYTE * + ltob(LONG n, BYTE * s, COUNT base) +{ + ULONG u; + REG BYTE *p, + *q; + REG negative, + c; + + if (n < 0 && base == -10) + { + negative = 1; + u = -n; + } + else + { + negative = 0; + u = n; + } + if (base == -10) /* signals signed conversion */ + base = 10; + p = q = s; + do + { /* generate digits in reverse order */ + *p++ = "0123456789abcdef"[u % base]; + } + while ((u /= base) > 0); + if (negative) + *p++ = '-'; + *p = '\0'; /* terminate the string */ + while (q < --p) + { /* reverse the digits */ + c = *q; + *q++ = *p; + *p = c; + } + return s; +} + +/* itob -- convert an long integer to a string in any base (2-16) */ +static BYTE * + itob(COUNT n, BYTE * s, COUNT base) +{ + UWORD u; + REG BYTE *p, + *q; + REG negative, + c; + + if (n < 0 && base == -10) + { + negative = 1; + u = -n; + } + else + { + negative = 0; + u = n; + } + if (base == -10) /* signals signed conversion */ + base = 10; + p = q = s; + do + { /* generate digits in reverse order */ + *p++ = "0123456789abcdef"[u % base]; + } + while ((u /= base) > 0); + if (negative) + *p++ = '-'; + *p = '\0'; /* terminate the string */ + while (q < --p) + { /* reverse the digits */ + c = *q; + *q++ = *p; + *p = c; + } + return s; +} + +#define NONE 0 +#define LEFT 1 +#define RIGHT 2 + +/* printf -- short version of printf to conserve space */ +WORD FAR + init_call_printf(CONST BYTE * fmt, BYTE * args) +{ + charp = 0; + return do_printf(fmt, &args); +} + +WORD +sprintf(BYTE * buff, CONST BYTE * fmt, BYTE * args) +{ + WORD ret; + + charp = buff; + ret = do_printf(fmt, &args); + handle_char(NULL); + return ret; +} + +static COUNT + do_printf(CONST BYTE * fmt, REG BYTE ** arg) +{ + REG base; + BYTE s[11], + *p, + *ltob(); + BYTE c, + slen, + flag, + size, + fill; + + flag = NONE; + size = 0; + while ((c = *fmt++) != '\0') + { + if (size == 0 && flag == NONE && c != '%') + { + handle_char(c); + continue; + } + if (flag == NONE && *fmt == '0') + { + flag = RIGHT; + fill = '0'; + } + switch (*fmt) + { + case '-': + flag = RIGHT; + fill = *(fmt + 1) == '0' ? '0' : ' '; + continue; + + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + if (flag == NONE) + flag = LEFT; + size = *fmt++ - '0'; + while ((c = *fmt++) != '\0') + { + switch (c) + { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + size = size * 10 + (c - '0'); + continue; + + default: + --fmt; + break; + } + break; + } + break; + } + switch (c = *fmt++) + { + case 'c': + handle_char(*(COUNT *) arg++); + continue; + + case 'd': + base = -10; + goto prt; + + case 'o': + base = 8; + goto prt; + + case 'u': + base = 10; + goto prt; + + case 'x': + base = 16; + + prt: + itob(*((COUNT *) arg)++, s, base); + if (flag == RIGHT || flag == LEFT) + { + for (slen = 0, p = s; *p != '\0'; p++) + ++slen; + } + if (flag == RIGHT && slen < size) + { + WORD i; + + for (i = size - slen; i > 0; i--) + handle_char(fill); + } + for (p = s; *p != '\0'; p++) + handle_char(*p); + if (flag == LEFT) + { + WORD i; + BYTE sp = ' '; + + for (i = size - slen; i > 0; i--) + handle_char(sp); + } + size = 0; + flag = NONE; + continue; + + case 'l': + switch (c = *fmt++) + { + case 'd': + base = -10; + goto lprt; + + case 'o': + base = 8; + goto lprt; + + case 'u': + base = 10; + goto lprt; + + case 'x': + base = 16; + + lprt: + ltob(*((LONG *) arg)++, s, base); + if (flag == RIGHT || flag == LEFT) + { + for (slen = 0, p = s; *p != '\0'; p++) + ++slen; + } + if (flag == RIGHT && slen < size) + { + WORD i; + + for (i = size - slen; i > 0; i--) + handle_char(fill); + } + for (p = s; *p != '\0'; p++) + handle_char(*p); + if (flag == LEFT) + { + WORD i; + BYTE sp = ' '; + + for (i = size - slen; i > 0; i--) + handle_char(sp); + } + size = 0; + flag = NONE; + continue; + + default: + handle_char(c); + } + + case 's': + for (p = *arg; *p != '\0'; p++) + { + --size; + handle_char(*p); + } + for (; size > 0; size--) + handle_char(' '); + ++arg; + size = 0; + flag = NONE; + continue; + + default: + handle_char(c); + continue; + } + } + return 0; +} diff --git a/kernel/printer.asm b/kernel/printer.asm new file mode 100644 index 00000000..d9834f61 --- /dev/null +++ b/kernel/printer.asm @@ -0,0 +1,201 @@ +; +; File: +; printer.asm +; Description: +; Printer device driver +; +; Copyright (c) 1998 +; Pasquale J. Villani +; All Rights Reserved +; +; This file is part of DOS-C. +; +; DOS-C is free software; you can redistribute it and/or +; modify it under the terms of the GNU General Public License +; as published by the Free Software Foundation; either version +; 2, or (at your option) any later version. +; +; DOS-C is distributed in the hope that it will be useful, but +; WITHOUT ANY WARRANTY; without even the implied warranty of +; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See +; the GNU General Public License for more details. +; +; You should have received a copy of the GNU General Public +; License along with DOS-C; see the file COPYING. If not, +; write to the Free Software Foundation, 675 Mass Ave, +; Cambridge, MA 02139, USA. +; +; $Header$ +; +; $Log$ +; Revision 1.1 2000/05/06 19:35:30 jhall1 +; Initial revision +; +; Revision 1.2 1999/08/10 17:57:13 jprice +; ror4 2011-02 patch +; +; Revision 1.1.1.1 1999/03/29 15:41:26 jprice +; New version without IPL.SYS +; +; Revision 1.1 1999/02/08 05:55:57 jprice +; Added Pat's 1937 kernel patches +; +; $EndLog$ +; + + %include "io.inc" + +segment _IO_FIXED_DATA + + global LptTable +LptTable db 18h + dw _IOExit + dw _IOExit + dw _IOExit + dw _IOCommandError + dw _IOSuccess + dw _IODone + dw _IOExit + dw _IOExit + dw PrtWrite + dw PrtWrite + dw PrtOutStat + dw _IOExit + dw _IOExit + dw _IOExit + dw _IOExit + dw _IOExit + dw PrtOutBsy + dw _IOExit + dw _IOExit + dw PrtGenIoctl + dw _IOExit + dw _IOExit + dw _IOExit + dw _IOCommandError + dw _IOCommandError + + +segment _IO_TEXT + global uPrtNo +uPrtNo db 0 +uPrtQuantum dw 50h + dw 50h, 50h + db 50h, 00h + +PrtWrite: + jcxz PrtWr3 ; Exit if nothing to write +PrtWr1: + mov bx,2 +PrtWr2: + mov al,[es:di] + inc di + xor ah,ah ; Zero register + call PrtIOCall ; (0800) + jnz PrtWr4 ; Exit if done + loop PrtWr1 ; otherwise loop +PrtWr3: + jmp _IOExit +PrtWr4: + dec di + dec bx + jnz PrtWr2 +PrtWr5: + jmp _IOErrCnt + + + +PrtOutStat: + call GetPrtStat + jnz PrtWr5 + mov al,9 + test ah,20h + jnz PrtWr5 + test ah,80h + jnz PrtWr3 + jmp _IODone + + + +GetPrtStat: + mov ah,2 + +PrtIOCall: + call GetUnitNum + int 17h ; print char al, get status ah + test ah,8 + jz PrtIOCal2 + mov al,9 + test ah,20h + jnz PrtIOCal1 + inc al +PrtIOCal1: + retn +PrtIOCal2: + mov al,2 + test ah,1 + retn + + + +PrtOutBsy: + push ds + push es + pop ds + mov si,di +PrtOtBsy1: + push cx + push bx + xor bx,bx + mov bl,[cs:uPrtNo] + shl bx,1 + mov cx,[cs:uPrtQuantum+bx] + pop bx +PrtOtBsy2: + call GetPrtStat + jnz PrtOtBsy3 + test ah,80h + loopz PrtOtBsy2 + pop cx + jz PrtOtBsy4 + lodsb + xor ah,ah + call PrtIOCall + jnz PrtOtBsy4 + loop PrtOtBsy1 + pop ds + lds bx,[cs:_ReqPktPtr] + sub [bx+12h],cx + jmp _IOExit +PrtOtBsy3: + pop cx +PrtOtBsy4: + pop ds + lds bx,[cs:_ReqPktPtr] + sub [bx+12h],cx + jmp _IOErrorExit + + + +PrtGenIoctl: + les di,[cs:_ReqPktPtr] + cmp byte [es:di+0Dh],5 + je PrtGnIoctl2 +PrtGnIoctl1: + jmp _IOCommandError +PrtGnIoctl2: + mov al,[es:di+0Eh] + les di,[es:di+13h] + xor bx,bx + mov bl,[cs:uPrtNo] + shl bx,1 + mov cx,[cs:uPrtQuantum+bx] + cmp al,65h + je PrtGnIoctl3 + cmp al,45h + jne PrtGnIoctl1 + mov cx,[es:di] +PrtGnIoctl3: + mov [cs:uPrtQuantum+bx],cx + mov [es:di],cx + jmp _IOExit diff --git a/kernel/procsupt.asm b/kernel/procsupt.asm new file mode 100644 index 00000000..b1a9cbbe --- /dev/null +++ b/kernel/procsupt.asm @@ -0,0 +1,312 @@ +; +; File: +; procsupt.asm +; Description: +; Assembly support routines for process handling, etc. +; +; Copyright (c) 1995,1998 +; Pasquale J. Villani +; All Rights Reserved +; +; This file is part of DOS-C. +; +; DOS-C is free software; you can redistribute it and/or +; modify it under the terms of the GNU General Public License +; as published by the Free Software Foundation; either version +; 2, or (at your option) any later version. +; +; DOS-C is distributed in the hope that it will be useful, but +; WITHOUT ANY WARRANTY; without even the implied warranty of +; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See +; the GNU General Public License for more details. +; +; You should have received a copy of the GNU General Public +; License along with DOS-C; see the file COPYING. If not, +; write to the Free Software Foundation, 675 Mass Ave, +; Cambridge, MA 02139, USA. +; +; $Logfile: C:/usr/patv/dos-c/src/kernel/procsupt.asv $ +; +; $Id$ +; +; $Log$ +; Revision 1.1 2000/05/06 19:35:30 jhall1 +; Initial revision +; +; Revision 1.4 1999/08/10 17:57:13 jprice +; ror4 2011-02 patch +; +; Revision 1.3 1999/04/23 22:38:36 jprice +; Fixed got_cbreak function. +; +; Revision 1.2 1999/04/16 12:21:22 jprice +; Steffen c-break handler changes +; +; Revision 1.1.1.1 1999/03/29 15:41:27 jprice +; New version without IPL.SYS +; +; Revision 1.4 1999/02/08 05:55:57 jprice +; Added Pat's 1937 kernel patches +; +; Revision 1.3 1999/02/01 01:48:41 jprice +; Clean up; Now you can use hex numbers in config.sys. added config.sys screen function to change screen mode (28 or 43/50 lines) +; +; Revision 1.2 1999/01/22 04:13:27 jprice +; Formating +; +; Revision 1.1.1.1 1999/01/20 05:51:01 jprice +; Imported sources +; +; Rev 1.4 06 Dec 1998 8:46:44 patv +;Bug fixes. +; +; Rev 1.3 07 Feb 1998 20:42:08 patv +;Modified stack fram to match DOS standard +; +; Rev 1.2 29 May 1996 21:03:36 patv +;bug fixes for v0.91a +; +; Rev 1.1 01 Sep 1995 17:54:24 patv +;First GPL release. +; +; Rev 1.0 02 Jul 1995 9:05:58 patv +;Initial revision. +; $EndLog$ +; + + + %include "segs.inc" + + extern _api_sp:wrt DGROUP ; api stacks - for context + extern _api_ss:wrt DGROUP ; switching + extern _usr_sp:wrt DGROUP ; user stacks + extern _usr_ss:wrt DGROUP + + extern _kstackp:wrt TGROUP ; kernel stack + extern _ustackp:wrt TGROUP ; new task stack + + extern _break_flg:wrt DGROUP ; break detected flag + extern _int21_handler:wrt TGROUP ; far call system services + + %include "stacks.inc" + +segment _TEXT + +; +; Special call for switching processes +; +; void interrupt far exec_user(irp) +; iregs far *irp; +; + global _exec_user +_exec_user: + + PUSH$ALL + mov ax,DGROUP + mov ds,ax + mov bp,sp + cld + cli +; +; +; + mov ax,word [bp+irp_low] ; irp (user ss:sp) + mov dx,word [bp+irp_hi] + mov sp,ax ; set-up user stack + mov ss,dx + sti +; + POP$ALL + iret + + + + +;; Called whenever the BIOS detects a ^Break state + global _got_cbreak +_got_cbreak: + push ds + push ax + mov ax, 40h + mov ds, ax + or byte [71h], 80h ;; set the ^Break flag + pop ax + pop ds + iret + + +; +; Special call for switching processes during break handling +; +; void interrupt far spawn_int23() +; +; +; +---------------+ +; | flags | 22 +; +---------------+ +; | cs | 20 +; +---------------+ +; | ip | 18 +; +---------------+ +; | es | 16 +; +---------------+ +; | ds | 14 +; +---------------+ +; | bp | 12 +; +---------------+ +; | di | 10 +; +---------------+ +; | si | 8 +; +---------------+ +; | dx | 6 +; +---------------+ +; | cx | 4 +; +---------------+ +; | bx | 2 +; +---------------+ +; | ax | 0 <--- bp & sp after mov bp,sp +; +---------------+ +; + global _spawn_int23 +_spawn_int23: + +;; 1999/03/27 ska - comments: see cmt1.txt + mov ax, DGROUP ;; Make sure DS is OK + mov ds, ax + + ; restore to user stack + cli ;; Pre-8086 don't disable INT autom. + mov ss,[_usr_ss] + mov sp,[_usr_sp] + sti + + ; get all the user registers back + POP$ALL + + ;; Construct the piece of code into the stack + + ;; stack frame: during generation of code piece + ;; + ;; BP | SP | Meaning + ;; 7 | 11 | offset CALL FAR will push onto stack + ;; 5 | 9 | CALL FAR segment + ;; 3 | 7 | CALL FAR offset + ;; 2 | 6 | CALL FAR ??regain_control_int23 | instruction byte + ;; 0 | 4 | INT 23 <> + ;; -2 | 2 | segment of address of INT-23 \ To jump to INT 23 + ;; -4 | 0 | offset of address of INT-23 / via RETF + ;; Upon return from INT-23 the CALL FAR pushes the address of + ;; the byte immediately following the CALL FAR onto the stack. + ;; This value POPed and decremented by 7 is the value SP must + ;; contain, if the INT-23 was returned with RETF2/IRET. + + sub sp, byte 8 ;; code piece needs 7 bytes --> 4 words + push ss ;; prepare jump to INT-23 via RETF + push bp ;; will be offset / temp: saved BP + mov bp, sp + add bp, byte 4 ;; position BP onto INT-23 + mov word [bp], 23cdh ;; INT 23h + mov byte [bp+2], 9ah ;; CALL FAR immediate + mov word [bp+3], ??regain_control_int23 + mov word [bp+5], cs + + ;; complete the jump to INT-23 via RETF and restore BP + xchg word [bp-4], bp + + stc ;; set default action --> terminate + ; invoke the int 23 handler its address has been constructed + ;; on the stack + retf + +??regain_control_int23: + + ;; stack frame: constructed on entry to INT-23 + ;; + ; BP | SP | Meaning + ;; 7 | 11 | offset CALL FAR will push onto stack + ;; 5 | 9 | CALL FAR segment + ;; 3 | 7 | CALL FAR offset + ;; 2 | 6 | CALL FAR ??regain_control_int23 | instruction byte + ;; 0 | 4 | INT 23 <> + ;; -2 | 2 | segment of address of INT-23 \ To jump to INT 23 + ;; -4 | 0 | offset of address of INT-23 / via RETF + ;; Upon return from INT-23 the CALL FAR pushes the address of + ;; the byte immediately following the CALL FAR onto the stack. + ;; This value POPed and decremented by 7 is the value SP must + ;; contain, if the INT-23 was returned with RETF2/IRET. + + ;; stack frame: used during recovering from INT-23 + ;; + ;; BP | Meaning + ;; 1 | <> + ;; 0 | <> + ;; -1 | saved BP + ;; -3 | saved AX + ;; -7 | INT 23 <> + + ;; Somewhere on stack: + ;; SP | Meaning + ;; 4 | segment of return address of CALL FAR + ;; 2 | offset of return address of CALL FAR + ;; 0 | saved BP + + push bp + mov bp, sp + mov bp, [bp+2] ;; get should-be address + 7 + mov word [bp-3], ax ;; save AX + pop ax ;; old BP + mov word [bp-1], ax ;; preserve saved BP + mov ax, bp + dec ax ;; last used word of stack + dec ax ;; Don't use SUB to keep Carry flag + dec ax + xchg ax, sp ;; AX := current stack; SP corrected + ;; Currently: BP - 7 == address of INT-23 + ;; should be AX + 4 --> IRET or RETF 2 + ;; ==> Test if BP - 7 == AX + 4 + ;; ==> Test if AX + 4 - BP + 7 == 0 + pushf ;; preserve Carry flag + add ax, byte 4 + 7 + sub ax, bp ;; AX := SP + 4 + pop ax ;; saved Carry flag + jz ??int23_ign_carry ;; equal -> IRET --> ignore Carry + ;; Carry is already cleared + push ax + popf ;; restore Carry flag + +??int23_ign_carry: + pop ax ;; Restore the original register + jnc ??int23_respawn + ;; The user returned via RETF 0, Carry is set + ;; --> terminate program + ;; This is done by set the _break_flg and modify the + ;; AH value, which is passed to the _respawn_ call + ;; into 0, which is "Terminate program". + push ds ;; we need DGROUP + mov bp, DGROUP + mov ds, bp + inc byte [_break_flg] + pop ds + + xor ah, ah ;; clear ah --> perform DOS-00 --> terminate + +??int23_respawn: + pop bp ;; Restore the original register + jmp _int21_handler + + +; +; interrupt enable and disable routines +; +; public _enable +;_enable proc near +; sti +; ret +;_enable endp +; +; public _disable +;_disable proc near +; cli +; ret +;_disable endp + diff --git a/kernel/proto.h b/kernel/proto.h new file mode 100644 index 00000000..b60c5b71 --- /dev/null +++ b/kernel/proto.h @@ -0,0 +1,452 @@ +/****************************************************************/ +/* */ +/* proto.h */ +/* */ +/* Global Function Prototypes */ +/* */ +/* Copyright (c) 1995, 1996 */ +/* Pasquale J. Villani */ +/* All Rights Reserved */ +/* */ +/* This file is part of DOS-C. */ +/* */ +/* DOS-C is free software; you can redistribute it and/or */ +/* modify it under the terms of the GNU General Public License */ +/* as published by the Free Software Foundation; either version */ +/* 2, or (at your option) any later version. */ +/* */ +/* DOS-C is distributed in the hope that it will be useful, but */ +/* WITHOUT ANY WARRANTY; without even the implied warranty of */ +/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See */ +/* the GNU General Public License for more details. */ +/* */ +/* You should have received a copy of the GNU General Public */ +/* License along with DOS-C; see the file COPYING. If not, */ +/* write to the Free Software Foundation, 675 Mass Ave, */ +/* Cambridge, MA 02139, USA. */ +/****************************************************************/ + +#ifdef MAIN +#ifdef VERSION_STRINGS +static BYTE *Proto_hRcsId = "$Id$"; +#endif +#endif + +/* + * $Log$ + * Revision 1.1 2000/05/06 19:35:32 jhall1 + * Initial revision + * + * Revision 1.15 2000/03/09 06:07:11 kernel + * 2017f updates by James Tabor + * + * Revision 1.14 1999/09/23 04:40:48 jprice + * *** empty log message *** + * + * Revision 1.10 1999/08/25 03:18:09 jprice + * ror4 patches to allow TC 2.01 compile. + * + * Revision 1.9 1999/05/03 06:25:45 jprice + * Patches from ror4 and many changed of signed to unsigned variables. + * + * Revision 1.8 1999/04/23 04:24:39 jprice + * Memory manager changes made by ska + * + * Revision 1.7 1999/04/16 21:43:40 jprice + * ror4 multi-sector IO + * + * Revision 1.6 1999/04/16 12:21:22 jprice + * Steffen c-break handler changes + * + * Revision 1.5 1999/04/12 03:21:17 jprice + * more ror4 patches. Changes for multi-block IO + * + * Revision 1.4 1999/04/11 04:33:39 jprice + * ror4 patches + * + * Revision 1.2 1999/04/04 18:51:43 jprice + * no message + * + * Revision 1.1.1.1 1999/03/29 15:41:30 jprice + * New version without IPL.SYS + * + * Revision 1.4 1999/02/08 05:55:57 jprice + * Added Pat's 1937 kernel patches + * + * Revision 1.3 1999/02/01 01:48:41 jprice + * Clean up; Now you can use hex numbers in config.sys. added config.sys screen function to change screen mode (28 or 43/50 lines) + * + * Revision 1.2 1999/01/22 04:13:27 jprice + * Formating + * + * Revision 1.1.1.1 1999/01/20 05:51:01 jprice + * Imported sources + * + * + * Rev 1.11 06 Dec 1998 8:47:18 patv + *Expanded due to new I/O subsystem. + * + * Rev 1.10 07 Feb 1998 20:38:00 patv + *Modified stack fram to match DOS standard + * + * Rev 1.9 22 Jan 1998 4:09:26 patv + *Fixed pointer problems affecting SDA + * + * Rev 1.8 11 Jan 1998 2:06:22 patv + *Added functionality to ioctl. + * + * Rev 1.7 04 Jan 1998 23:16:22 patv + *Changed Log for strip utility + * + * Rev 1.6 03 Jan 1998 8:36:48 patv + *Converted data area to SDA format + * + * Rev 1.5 16 Jan 1997 12:46:44 patv + *pre-Release 0.92 feature additions + * + * Rev 1.4 29 May 1996 21:03:40 patv + *bug fixes for v0.91a + * + * Rev 1.3 19 Feb 1996 3:23:06 patv + *Added NLS, int2f and config.sys processing + * + * Rev 1.2 01 Sep 1995 17:54:26 patv + *First GPL release. + * + * Rev 1.1 30 Jul 1995 20:51:58 patv + *Eliminated version strings in ipl + * + * Rev 1.0 05 Jul 1995 11:32:16 patv + *Initial revision. + */ + +#define INIT + +#ifdef IN_INIT_MOD +#define __FAR_WRAPPER(ret, name, proto) \ + ret FAR name proto; /* will be expanded to `init_call_' */ +#else +#define __FAR_WRAPPER(ret, name, proto) \ + ret name proto; \ + ret FAR init_call_##name proto; +#endif + +/* blockio.c */ +VOID FAR init_buffers(void); +ULONG getblkno(struct buffer FAR *); +VOID setblkno(struct buffer FAR *, ULONG); +struct buffer FAR *getblock(ULONG blkno, COUNT dsk); +BOOL getbuf(struct buffer FAR ** pbp, ULONG blkno, COUNT dsk); +VOID setinvld(REG COUNT dsk); +BOOL flush_buffers(REG COUNT dsk); +BOOL flush1(struct buffer FAR * bp); +BOOL flush(void); +BOOL fill(REG struct buffer FAR * bp, ULONG blkno, COUNT dsk); +BOOL dskxfer(COUNT dsk, ULONG blkno, VOID FAR * buf, UWORD numblocks, COUNT mode); + +/* chario.c */ +VOID cso(COUNT c); +VOID sto(COUNT c); +VOID mod_sto(REG UCOUNT c); +VOID destr_bs(void); +UCOUNT _sti(void); +VOID con_hold(void); +BOOL con_break(void); +BOOL StdinBusy(void); +VOID KbdFlush(void); +VOID Do_DosIdle_loop(void); +__FAR_WRAPPER(VOID, sti, (keyboard FAR * kp)) + +sft FAR *get_sft(COUNT); + +/* config.c */ +INIT VOID PreConfig(VOID); +INIT VOID DoConfig(VOID); +INIT VOID PostConfig(VOID); +INIT BYTE *skipwh(BYTE * s); +INIT BYTE *scan(BYTE * s, BYTE * d); +INIT BOOL isnum(BYTE * pszString); +INIT BYTE *GetNumber(REG BYTE * pszString, REG COUNT * pnNum); +INIT COUNT tolower(COUNT c); +INIT COUNT toupper(COUNT c); +INIT VOID mcb_init(mcb FAR * mcbp, UWORD size); +INIT VOID strcat(REG BYTE * d, REG BYTE * s); + +/* dosfns.c */ +BOOL check_break(void); +UCOUNT GenericRead(COUNT hndl, UCOUNT n, BYTE FAR * bp, COUNT FAR * err, + BOOL force_binary); +UCOUNT DosRead(COUNT hndl, UCOUNT n, BYTE FAR * bp, COUNT FAR * err); +UCOUNT DosWrite(COUNT hndl, UCOUNT n, BYTE FAR * bp, COUNT FAR * err); +COUNT DosSeek(COUNT hndl, LONG new_pos, COUNT mode, ULONG * set_pos); +COUNT DosCreat(BYTE FAR * fname, COUNT attrib); +COUNT CloneHandle(COUNT hndl); +COUNT DosDup(COUNT Handle); +COUNT DosForceDup(COUNT OldHandle, COUNT NewHandle); +COUNT DosOpen(BYTE FAR * fname, COUNT mode); +COUNT DosClose(COUNT hndl); +VOID DosGetFree(COUNT drive, COUNT FAR * spc, COUNT FAR * navc, COUNT FAR * bps, COUNT FAR * nc); +COUNT DosGetCuDir(COUNT drive, BYTE FAR * s); +COUNT DosChangeDir(BYTE FAR * s); +COUNT DosFindFirst(UCOUNT attr, BYTE FAR * name); +COUNT DosFindNext(void); +COUNT DosGetFtime(COUNT hndl, date FAR * dp, time FAR * tp); +COUNT DosSetFtime(COUNT hndl, date FAR * dp, time FAR * tp); +COUNT DosGetFattr(BYTE FAR * name, UWORD FAR * attrp); +COUNT DosSetFattr(BYTE FAR * name, UWORD FAR * attrp); +BYTE DosSelectDrv(BYTE drv); + +/*dosidle.asm */ +VOID DosIdle_int(void); + +/* dosnames.c */ +VOID SpacePad(BYTE *, COUNT); +COUNT ParseDosName(BYTE FAR *, COUNT *, BYTE *, BYTE *, BYTE *, BOOL); +COUNT ParseDosPath(BYTE FAR *, COUNT *, BYTE *, BYTE FAR *); +BOOL IsDevice(BYTE * FileName); + +/* dsk.c */ +COUNT blk_driver(rqptr rp); + +/* error.c */ +VOID dump(void); +VOID panic(BYTE * s); +__FAR_WRAPPER(VOID, fatal, (BYTE * err_msg)) +COUNT char_error(request * rq, struct dhdr FAR * lpDevice); +COUNT block_error(request * rq, COUNT nDrive, struct dhdr FAR * lpDevice); + +/* fatdir.c */ +struct f_node FAR *dir_open(BYTE FAR * dirname); +COUNT dir_read(REG struct f_node FAR * fnp); +COUNT dir_write(REG struct f_node FAR * fnp); +VOID dir_close(REG struct f_node FAR * fnp); +COUNT dos_findfirst(UCOUNT attr, BYTE FAR * name); +COUNT dos_findnext(void); + +/* fatfs.c */ +__FAR_WRAPPER(COUNT, dos_open, (BYTE FAR * path, COUNT flag)) +BOOL fcmp(BYTE FAR * s1, BYTE FAR * s2, COUNT n); +BOOL fcmp_wild(BYTE FAR * s1, BYTE FAR * s2, COUNT n); +VOID touc(BYTE FAR * s, COUNT n); +__FAR_WRAPPER(COUNT, dos_close, (COUNT fd)) +COUNT dos_creat(BYTE FAR * path, COUNT attrib); +COUNT dos_delete(BYTE FAR * path); +COUNT dos_rmdir(BYTE FAR * path); +COUNT dos_rename(BYTE FAR * path1, BYTE FAR * path2); +__FAR_WRAPPER(date, dos_getdate, (void)) +__FAR_WRAPPER(time, dos_gettime, (void)) +COUNT dos_getftime(COUNT fd, date FAR * dp, time FAR * tp); +COUNT dos_setftime(COUNT fd, date FAR * dp, time FAR * tp); +LONG dos_getcufsize(COUNT fd); +LONG dos_getfsize(COUNT fd); +BOOL dos_setfsize(COUNT fd, LONG size); +COUNT dos_mkdir(BYTE FAR * dir); +BOOL last_link(struct f_node FAR * fnp); +COUNT map_cluster(REG struct f_node FAR * fnp, COUNT mode); +UCOUNT readblock(COUNT fd, VOID FAR * buffer, UCOUNT count, COUNT * err); +UCOUNT writeblock(COUNT fd, VOID FAR * buffer, UCOUNT count, COUNT * err); +__FAR_WRAPPER(COUNT, dos_read, (COUNT fd, VOID FAR * buffer, UCOUNT count)) +COUNT dos_write(COUNT fd, VOID FAR * buffer, UCOUNT count); +LONG dos_lseek(COUNT fd, LONG foffset, COUNT origin); +UWORD dos_free(struct dpb *dpbp); + +VOID dos_pwd(struct cds FAR * cdsp, BYTE FAR * s); + +VOID trim_path(BYTE FAR * s); + +COUNT dos_cd(struct cds FAR * cdsp, BYTE FAR * s); + +struct f_node FAR *get_f_node(void); +VOID release_f_node(struct f_node FAR * fnp); +VOID dos_setdta(BYTE FAR * newdta); +COUNT dos_getfattr(BYTE FAR * name, UWORD FAR * attrp); +COUNT dos_setfattr(BYTE FAR * name, UWORD FAR * attrp); +COUNT media_check(REG struct dpb *dpbp); +struct f_node FAR *xlt_fd(COUNT fd); +COUNT xlt_fnp(struct f_node FAR * fnp); +struct dhdr FAR *select_unit(COUNT drive); + +/* fattab.c */ +UCOUNT link_fat(struct dpb *dpbp, UCOUNT Cluster1, REG UCOUNT Cluster2); +UCOUNT link_fat16(struct dpb *dpbp, UCOUNT Cluster1, UCOUNT Cluster2); +UCOUNT link_fat12(struct dpb *dpbp, UCOUNT Cluster1, UCOUNT Cluster2); +UWORD next_cluster(struct dpb *dpbp, REG UCOUNT ClusterNum); +UWORD next_cl16(struct dpb *dpbp, REG UCOUNT ClusterNum); +UWORD next_cl12(struct dpb *dpbp, REG UCOUNT ClusterNum); + +/* fcbfns.c */ +VOID DosOutputString(BYTE FAR * s); +int DosCharInputEcho(VOID); +int DosCharInput(VOID); +VOID DosDirectConsoleIO(iregs FAR * r); +VOID DosCharOutput(COUNT c); +VOID DosDisplayOutput(COUNT c); +VOID FatGetDrvData(COUNT drive, COUNT FAR * spc, COUNT FAR * bps, COUNT FAR * nc, BYTE FAR ** mdp); +WORD FcbParseFname(int wTestMode, BYTE FAR ** lpFileName, fcb FAR * lpFcb); +BYTE FAR *ParseSkipWh(BYTE FAR * lpFileName); +BOOL TestCmnSeps(BYTE FAR * lpFileName); +BOOL TestFieldSeps(BYTE FAR * lpFileName); +BYTE FAR *GetNameField(BYTE FAR * lpFileName, BYTE FAR * lpDestField, COUNT nFieldSize, BOOL * pbWildCard); +BOOL FcbRead(xfcb FAR * lpXfcb, COUNT * nErrorCode); +BOOL FcbWrite(xfcb FAR * lpXfcb, COUNT * nErrorCode); +BOOL FcbGetFileSize(xfcb FAR * lpXfcb); +BOOL FcbSetRandom(xfcb FAR * lpXfcb); +BOOL FcbCalcRec(xfcb FAR * lpXfcb); +BOOL FcbRandomBlockRead(xfcb FAR * lpXfcb, COUNT nRecords, COUNT * nErrorCode); +BOOL FcbRandomBlockWrite(xfcb FAR * lpXfcb, COUNT nRecords, COUNT * nErrorCode); +BOOL FcbRandomRead(xfcb FAR * lpXfcb, COUNT * nErrorCode); +BOOL FcbRandomWrite(xfcb FAR * lpXfcb, COUNT * nErrorCode); +BOOL FcbCreate(xfcb FAR * lpXfcb); +void FcbNameInit(fcb FAR * lpFcb, BYTE * pszBuffer, COUNT * pCurDrive); +BOOL FcbOpen(xfcb FAR * lpXfcb); +BOOL FcbDelete(xfcb FAR * lpXfcb); +BOOL FcbRename(xfcb FAR * lpXfcb); +void MoveDirInfo(dmatch FAR * lpDmatch, struct dirent FAR * lpDir); +BOOL FcbClose(xfcb FAR * lpXfcb); +BOOL FcbFindFirst(xfcb FAR * lpXfcb); +BOOL FcbFindNext(xfcb FAR * lpXfcb); + +/* initoem.c */ +UWORD init_oem(void); + +/* inthndlr.c */ +VOID INRPT far got_cbreak(void); /* procsupt.asm */ +VOID INRPT far int20_handler(iregs UserRegs); +VOID INRPT far int21_handler(iregs UserRegs); +VOID far int21_entry(iregs UserRegs); +VOID int21_service(iregs far * r); +VOID INRPT FAR int22_handler(void); +VOID INRPT FAR int23_handler(int es, int ds, int di, int si, int bp, int sp, int bx, int dx, int cx, int ax, int ip, int cs, int flags); +VOID INRPT FAR int24_handler(void); +VOID INRPT FAR low_int25_handler(void); +VOID INRPT FAR low_int26_handler(void); +VOID int25_handler(); +VOID int26_handler(); +VOID INRPT FAR int27_handler(int es, int ds, int di, int si, int bp, int sp, int bx, int dx, int cx, int ax, int ip, int cs, int flags); +VOID INRPT FAR int28_handler(void); +VOID INRPT FAR int2a_handler(void); +VOID INRPT FAR int2f_handler(void); +VOID INRPT FAR empty_handler(void); + +/* ioctl.c */ +COUNT DosDevIOctl(iregs FAR * r, COUNT FAR * err); + +/* main.c */ +INIT VOID main(void); +INIT VOID init_device(struct dhdr FAR * dhp, BYTE FAR * cmdLine); +INIT struct dhdr FAR *link_dhdr(struct dhdr FAR * lp, struct dhdr FAR * dhp, BYTE FAR * cmdLine); + +/* memmgr.c */ +seg far2para(VOID FAR * p); +seg long2para(LONG size); +VOID FAR *add_far(VOID FAR * fp, ULONG off); +VOID FAR *adjust_far(VOID FAR * fp); +__FAR_WRAPPER(COUNT, DosMemAlloc, + (UWORD size, COUNT mode, seg FAR * para, UWORD FAR * asize)) +COUNT DosMemLargest(UWORD FAR * size); +COUNT DosMemFree(UWORD para); +COUNT DosMemChange(UWORD para, UWORD size, UWORD * maxSize); +COUNT DosMemCheck(void); +COUNT FreeProcessMem(UWORD ps); +COUNT DosGetLargestBlock(UWORD FAR * block); +VOID show_chain(void); +VOID mcb_print(mcb FAR * mcbp); +VOID _fmemcpy(BYTE FAR * d, BYTE FAR * s, REG COUNT n); + +/* misc.c */ +__FAR_WRAPPER(VOID, scopy, (REG BYTE * s, REG BYTE * d)) +VOID fscopy(REG BYTE FAR * s, REG BYTE FAR * d); +VOID fsncopy(BYTE FAR * s, BYTE FAR * d, REG COUNT n); +VOID bcopy(REG BYTE * s, REG BYTE * d, REG COUNT n); +__FAR_WRAPPER(VOID, fbcopy, (REG VOID FAR * s, REG VOID FAR * d, REG COUNT n)) + +/* nls.c */ +UWORD GetCtryInfo(UBYTE FAR * lpShrtCode, UWORD FAR * lpLongCode, BYTE FAR * lpTable); +UWORD SetCtryInfo(UBYTE FAR * lpShrtCode, UWORD FAR * lpLongCode, BYTE FAR * lpTable, UBYTE * nRetCode); +UWORD internalUpcase(UWORD c); +BOOL GetGlblCodePage(UWORD FAR * ActvCodePage, UWORD FAR * SysCodePage); +BOOL SetGlblCodePage(UWORD FAR * ActvCodePage, UWORD FAR * SysCodePage); +BOOL ExtCtryInfo(UBYTE nOpCode, UWORD CodePageID, UWORD InfoSize, VOID FAR * Information); +char upMChar(UPMAP map, char ch); +VOID upMMem(UPMAP map, char FAR * str, unsigned len); +BYTE yesNo(char ch); +char upChar(char ch); +VOID upString(char FAR * str); +VOID upMem(char FAR * str, unsigned len); +char upFChar(char ch); +VOID upFString(char FAR * str); +VOID upFMem(char FAR * str, unsigned len); +BOOL FAR LoadCountryInfo(char FAR * filename, WORD ctryCode, WORD codePage); + +/* prf.c */ +VOID put_console(COUNT c); +__FAR_WRAPPER(WORD, printf, (CONST BYTE * fmt,...)) +WORD sprintf(BYTE * buff, CONST BYTE * fmt,...); + +/* strings.c */ +__FAR_WRAPPER(COUNT, strlen, (REG BYTE * s)) +COUNT fstrlen(REG BYTE FAR * s); +VOID _fstrcpy(REG BYTE FAR * d, REG BYTE FAR * s); +VOID strncpy(REG BYTE * d, REG BYTE * s, COUNT l); +__FAR_WRAPPER(COUNT, strcmp, (REG BYTE * d, REG BYTE * s)) +COUNT fstrcmp(REG BYTE FAR * d, REG BYTE FAR * s); +COUNT fstrncmp(REG BYTE FAR * d, REG BYTE FAR * s, COUNT l); +COUNT strncmp(REG BYTE * d, REG BYTE * s, COUNT l); +VOID fstrncpy(REG BYTE FAR * d, REG BYTE FAR * s, COUNT l); +BYTE *strchr(BYTE * s, BYTE c); + +/* sysclk.c */ +WORD clk_driver(rqptr rp); +COUNT BcdToByte(COUNT x); +COUNT BcdToWord(BYTE * x, UWORD * mon, UWORD * day, UWORD * yr); +COUNT ByteToBcd(COUNT x); +LONG WordToBcd(BYTE * x, UWORD * mon, UWORD * day, UWORD * yr); + +/* syscon.c */ +WORD con_driver(rqptr rp); +VOID break_handler(void); +VOID INRPT FAR int29_handler(int es, int ds, int di, int si, int bp, int sp, int bx, int dx, int cx, int ax, int ip, int cs, int flags); + +/* syspack.c */ +VOID getdirent(BYTE FAR * vp, struct dirent FAR * dp); +VOID putdirent(struct dirent FAR * dp, BYTE FAR * vp); + +/* systime.c */ +VOID DosGetTime(BYTE FAR * hp, BYTE FAR * mp, BYTE FAR * sp, BYTE FAR * hdp); +COUNT DosSetTime(BYTE FAR * hp, BYTE FAR * mp, BYTE FAR * sp, BYTE FAR * hdp); +VOID DosGetDate(BYTE FAR * wdp, BYTE FAR * mp, BYTE FAR * mdp, COUNT FAR * yp); +COUNT DosSetDate(BYTE FAR * mp, BYTE FAR * mdp, COUNT FAR * yp); + +/* task.c */ +COUNT ChildEnv(exec_blk FAR * exp, UWORD * pChildEnvSeg, char far * pathname); +VOID new_psp(psp FAR * p, int psize); +VOID return_user(void); +__FAR_WRAPPER(COUNT, DosExec, (COUNT mode, exec_blk FAR * ep, BYTE FAR * lp)) +__FAR_WRAPPER(VOID, InitPSP, (VOID)) + +VOID FAR p_0(void); + +/* irqstack.asm */ +VOID init_stacks(VOID FAR * stack_base, COUNT nStacks, WORD stackSize); + +/* newstuff.c */ +int SetJFTSize(UWORD nHandles); +int DosMkTmp(BYTE FAR * pathname, UWORD attr); +int truename(char FAR * src, char FAR * dest, COUNT t); + +/* network.c */ +COUNT int2f_Remote_call(UWORD func, UWORD b, UCOUNT n, UWORD d, VOID FAR * s, UWORD i, VOID FAR * data); +COUNT QRemote_Fn(char FAR * s, char FAR * d); + +UWORD get_machine_name(BYTE FAR * netname); +VOID set_machine_name(BYTE FAR * netname, UWORD name_num); +UWORD Remote_OCT(UWORD func, BYTE FAR * name, UWORD pw, sft FAR * s); +UCOUNT Remote_RW(UWORD func, UCOUNT n, BYTE FAR * bp, sft FAR * s, COUNT FAR * err); +COUNT Remote_find(UWORD func, UWORD attrib, BYTE FAR * name, REG dmatch FAR * dmp); +COUNT Remote_GSattr(UWORD func, BYTE FAR * name, UWORD FAR * attrp); + +/* procsupt.asm */ +VOID INRPT FAR exec_user(iregs FAR * irp); + +#define strcpy(d, s) scopy(s, d) + diff --git a/kernel/segs.inc b/kernel/segs.inc new file mode 100644 index 00000000..e2e78c56 --- /dev/null +++ b/kernel/segs.inc @@ -0,0 +1,63 @@ +; File: +; segs.inc +; Description: +; Segment definitions for the kernel +; +; Copyright (c) 1998 +; Pasquale J. Villani +; All Rights Reserved +; +; This file is part of DOS-C. +; +; DOS-C is free software; you can redistribute it and/or +; modify it under the terms of the GNU General Public License +; as published by the Free Software Foundation; either version +; 2, or (at your option) any later version. +; +; DOS-C is distributed in the hope that it will be useful, but +; WITHOUT ANY WARRANTY; without even the implied warranty of +; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See +; the GNU General Public License for more details. +; +; You should have received a copy of the GNU General Public +; License along with DOS-C; see the file COPYING. If not, +; write to the Free Software Foundation, 675 Mass Ave, +; Cambridge, MA 02139, USA. +; +; $Logfile: C:/usr/patv/dos-c/src/kernel/segs.inv $ +; +; $Header$ +; +; $Log$ +; Revision 1.1 2000/05/06 19:35:32 jhall1 +; Initial revision +; +; Revision 1.2 1999/08/10 17:57:13 jprice +; ror4 2011-02 patch +; +; Revision 1.1.1.1 1999/03/29 15:41:30 jprice +; New version without IPL.SYS +; +; Revision 1.1 1999/02/08 05:55:57 jprice +; Added Pat's 1937 kernel patches +; +; +; Rev 1.0 06 Dec 1998 8:12:36 patv +; Initial revision. +; $EndLog +; + +group TGROUP _TEXT _IO_TEXT _IO_FIXED_DATA +group DGROUP _FIXED_DATA _DATA _BSS _BSSEND +group IGROUP INIT_TEXT_START INIT_TEXT INIT_TEXT_END + +segment _TEXT class=CODE +segment _IO_TEXT class=CODE +segment _IO_FIXED_DATA class=CODE align=2 +segment _FIXED_DATA class=DATA align=16 +segment _DATA class=DATA align=2 +segment _BSS class=BSS align=2 +segment _BSSEND class=BSS +segment INIT_TEXT_START class=INIT align=16 +segment INIT_TEXT class=INIT +segment INIT_TEXT_END class=INIT diff --git a/kernel/serial.asm b/kernel/serial.asm new file mode 100644 index 00000000..f7698197 --- /dev/null +++ b/kernel/serial.asm @@ -0,0 +1,171 @@ +; +; File: +; serial.asm +; Description: +; Serial device driver +; +; Copyright (c) 1998 +; Pasquale J. Villani +; All Rights Reserved +; +; This file is part of DOS-C. +; +; DOS-C is free software; you can redistribute it and/or +; modify it under the terms of the GNU General Public License +; as published by the Free Software Foundation; either version +; 2, or (at your option) any later version. +; +; DOS-C is distributed in the hope that it will be useful, but +; WITHOUT ANY WARRANTY; without even the implied warranty of +; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See +; the GNU General Public License for more details. +; +; You should have received a copy of the GNU General Public +; License along with DOS-C; see the file COPYING. If not, +; write to the Free Software Foundation, 675 Mass Ave, +; Cambridge, MA 02139, USA. +; +; $Header$ +; +; $Log$ +; Revision 1.1 2000/05/06 19:35:33 jhall1 +; Initial revision +; +; Revision 1.2 1999/08/10 17:57:13 jprice +; ror4 2011-02 patch +; +; Revision 1.1.1.1 1999/03/29 15:41:31 jprice +; New version without IPL.SYS +; +; Revision 1.1 1999/02/08 05:55:57 jprice +; Added Pat's 1937 kernel patches +; +; $EndLog$ +; + + %include "io.inc" + +segment _IO_FIXED_DATA + + global ComTable +ComTable db 0Ah + dw _IOExit + dw _IOExit + dw _IOExit + dw _IOCommandError + dw ComRead + dw ComNdRead + dw _IOExit + dw ComInpFlush + dw ComWrite + dw ComWrite + dw ComOutStat + + + +segment _IO_TEXT + + extern CommonNdRdExit:wrt TGROUP + +ComRead: + jcxz ComRd3 + call GetComStat + xor ax,ax + xchg [bx],al + or al,al + jnz ComRd2 +ComRd1: + call BiosRdCom +ComRd2: + stosb + loop ComRd1 + +ComRd3: + jmp _IOExit + + +BiosRdCom: + mov ah,2 + call ComIOCall + test ah,0Eh + jz BiosRdRetn + add sp,byte 2 + xor al,al + or al,0B0h + jmp _IOErrCnt +BiosRdRetn: + retn + + + +ComNdRead: + call GetComStat + mov al,[bx] + or al,al + jnz ComNdRd1 + call ComRdStatus + test ah,1 + jz ComNdRtn + test al,20h + jz ComNdRtn + call BiosRdCom + call GetComStat + mov [bx],al +ComNdRd1: + jmp CommonNdRdExit +ComNdRtn: + jmp _IODone + + +ComOutStat: + call ComRdStatus + test al,20h + jz ComNdRtn + test ah,20h + jz ComNdRtn + jmp _IOExit + + +ComRdStatus: + mov ah,3 + call ComIOCall + retn + + +ComIOCall: + call GetUnitNum + int 14h ; RS-232 get char al, ah=return status + retn + + +ComInpFlush: + call GetComStat + mov byte [bx],0 + jmp _IOExit + + +ComWrite: + jcxz ComRd3 +ComWr1: + mov al,[es:di] + inc di + mov ah,1 + call ComIOCall + test ah,80h + jz ComWr2 + mov al,0Ah + jmp _IOErrCnt +ComWr2: + loop ComWr1 + jmp _IOExit + + +GetComStat: + call GetUnitNum + mov bx,dx + add bx,ComStatArray + retn + +segment _DATA + +ComStatArray db 0, 0, 0, 0 diff --git a/kernel/strings.c b/kernel/strings.c new file mode 100644 index 00000000..70605ae2 --- /dev/null +++ b/kernel/strings.c @@ -0,0 +1,199 @@ +/****************************************************************/ +/* */ +/* strings.c */ +/* */ +/* Global String Handling Functions */ +/* */ +/* Copyright (c) 1995 */ +/* Pasquale J. Villani */ +/* All Rights Reserved */ +/* */ +/* This file is part of DOS-C. */ +/* */ +/* DOS-C is free software; you can redistribute it and/or */ +/* modify it under the terms of the GNU General Public License */ +/* as published by the Free Software Foundation; either version */ +/* 2, or (at your option) any later version. */ +/* */ +/* DOS-C is distributed in the hope that it will be useful, but */ +/* WITHOUT ANY WARRANTY; without even the implied warranty of */ +/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See */ +/* the GNU General Public License for more details. */ +/* */ +/* You should have received a copy of the GNU General Public */ +/* License along with DOS-C; see the file COPYING. If not, */ +/* write to the Free Software Foundation, 675 Mass Ave, */ +/* Cambridge, MA 02139, USA. */ +/****************************************************************/ + +#include "portab.h" + +#ifdef VERSION_STRINGS +static BYTE *stringsRcsId = "$Id$"; +#endif + +/* + * $Log$ + * Revision 1.1 2000/05/06 19:35:33 jhall1 + * Initial revision + * + * Revision 1.4 2000/03/09 06:07:11 kernel + * 2017f updates by James Tabor + * + * Revision 1.3 1999/08/25 03:18:09 jprice + * ror4 patches to allow TC 2.01 compile. + * + * Revision 1.2 1999/04/04 18:51:43 jprice + * no message + * + * Revision 1.1.1.1 1999/03/29 15:41:32 jprice + * New version without IPL.SYS + * + * Revision 1.4 1999/02/04 03:14:07 jprice + * Formating. Added comments. + * + * Revision 1.3 1999/02/01 01:48:41 jprice + * Clean up; Now you can use hex numbers in config.sys. added config.sys screen function to change screen mode (28 or 43/50 lines) + * + * Revision 1.2 1999/01/22 04:13:27 jprice + * Formating + * + * Revision 1.1.1.1 1999/01/20 05:51:01 jprice + * Imported sources + * + * + * Rev 1.6 04 Jan 1998 23:15:16 patv + * Changed Log for strip utility + * + * Rev 1.5 31 Dec 1997 3:59:30 patv + * Added new far string functions. + * + * Rev 1.4 29 May 1996 21:03:30 patv + * bug fixes for v0.91a + * + * Rev 1.3 19 Feb 1996 3:21:36 patv + * Added NLS, int2f and config.sys processing + * + * Rev 1.2 01 Sep 1995 17:54:22 patv + * First GPL release. + * + * Rev 1.1 30 Jul 1995 20:51:58 patv + * Eliminated version strings in ipl + * + * Rev 1.0 02 Jul 1995 8:33:46 patv + * Initial revision. + */ + +COUNT strlen(REG BYTE * s) +{ + REG WORD cnt = 0; + + while (*s++ != 0) + ++cnt; + return cnt; +} + +COUNT FAR init_call_strlen(REG BYTE * s) +{ + return strlen(s); +} + +COUNT fstrlen(REG BYTE FAR * s) +{ + REG WORD cnt = 0; + + while (*s++ != 0) + ++cnt; + return cnt; +} + +VOID _fstrcpy(REG BYTE FAR * d, REG BYTE FAR * s) +{ + while (*s != 0) + *d++ = *s++; + *d = 0; +} + +VOID strncpy(REG BYTE * d, REG BYTE * s, COUNT l) +{ + COUNT idx = 1; + while (*s != 0 && idx++ <= l) + *d++ = *s++; + *d = 0; +} + +COUNT strcmp(REG BYTE * d, REG BYTE * s) +{ + while (*s != '\0' && *d != '\0') + { + if (*d == *s) + ++s, ++d; + else + return *d - *s; + } + return *d - *s; +} + +COUNT FAR init_call_strcmp(REG BYTE * d, REG BYTE * s) +{ + return strcmp(d, s); +} + +COUNT fstrcmp(REG BYTE FAR * d, REG BYTE FAR * s) +{ + while (*s != '\0' && *d != '\0') + { + if (*d == *s) + ++s, ++d; + else + return *d - *s; + } + return *d - *s; +} + +COUNT strncmp(REG BYTE * d, REG BYTE * s, COUNT l) +{ + COUNT index = 1; + while (*s != '\0' && *d != '\0' && index++ <= l) + { + if (*d == *s) + ++s, ++d; + else + return *d - *s; + } + return *d - *s; +} + +COUNT fstrncmp(REG BYTE FAR * d, REG BYTE FAR * s, COUNT l) +{ + COUNT index = 1; + while (*s != '\0' && *d != '\0' && index++ <= l) + { + if (*d == *s) + ++s, ++d; + else + return *d - *s; + } + return *d - *s; +} + +VOID fstrncpy(REG BYTE FAR * d, REG BYTE FAR * s, COUNT l) +{ + COUNT idx = 1; + while (*s != 0 && idx++ <= l) + *d++ = *s++; + *d = 0; +} + +BYTE *strchr(BYTE * s, BYTE c) +{ + REG BYTE *p; + p = s - 1; + do + { + if (*++p == c) + return p; + } + while (*p); + return 0; +} diff --git a/kernel/sysclk.c b/kernel/sysclk.c new file mode 100644 index 00000000..ddcc9876 --- /dev/null +++ b/kernel/sysclk.c @@ -0,0 +1,321 @@ +/****************************************************************/ +/* */ +/* sysclk.c */ +/* */ +/* System Clock Driver */ +/* */ +/* Copyright (c) 1995 */ +/* Pasquale J. Villani */ +/* All Rights Reserved */ +/* */ +/* This file is part of DOS-C. */ +/* */ +/* DOS-C is free software; you can redistribute it and/or */ +/* modify it under the terms of the GNU General Public License */ +/* as published by the Free Software Foundation; either version */ +/* 2, or (at your option) any later version. */ +/* */ +/* DOS-C is distributed in the hope that it will be useful, but */ +/* WITHOUT ANY WARRANTY; without even the implied warranty of */ +/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See */ +/* the GNU General Public License for more details. */ +/* */ +/* You should have received a copy of the GNU General Public */ +/* License along with DOS-C; see the file COPYING. If not, */ +/* write to the Free Software Foundation, 675 Mass Ave, */ +/* Cambridge, MA 02139, USA. */ +/****************************************************************/ + +#include "portab.h" +#include "globals.h" + +#ifdef VERSION_STRINGS +static BYTE *RcsId = "$Id$"; +#endif + +/* + * $Log$ + * Revision 1.1 2000/05/06 19:35:33 jhall1 + * Initial revision + * + * Revision 1.3 2000/03/09 06:07:11 kernel + * 2017f updates by James Tabor + * + * Revision 1.2 1999/04/12 03:21:17 jprice + * more ror4 patches. Changes for multi-block IO + * + * Revision 1.1.1.1 1999/03/29 15:41:33 jprice + * New version without IPL.SYS + * + * Revision 1.5 1999/02/08 05:55:58 jprice + * Added Pat's 1937 kernel patches + * + * Revision 1.4 1999/02/04 03:14:07 jprice + * Formating. Added comments. + * + * Revision 1.3 1999/02/01 01:48:41 jprice + * Clean up; Now you can use hex numbers in config.sys. added config.sys screen function to change screen mode (28 or 43/50 lines) + * + * Revision 1.2 1999/01/22 04:13:27 jprice + * Formating + * + * Revision 1.1.1.1 1999/01/20 05:51:01 jprice + * Imported sources + * + * + * Rev 1.4 04 Jan 1998 23:15:16 patv + * Changed Log for strip utility + * + * Rev 1.3 29 May 1996 21:03:48 patv + * bug fixes for v0.91a + * + * Rev 1.2 19 Feb 1996 3:21:34 patv + * Added NLS, int2f and config.sys processing + * + * Rev 1.1 01 Sep 1995 17:54:18 patv + * First GPL release. + * + * Rev 1.0 02 Jul 1995 8:32:30 patv + * Initial revision. + */ + +#ifdef PROTO +BOOL ReadPCClock(ULONG *); +VOID WriteATClock(BYTE *, BYTE, BYTE, BYTE); +VOID WritePCClock(ULONG); +COUNT BcdToByte(COUNT); +COUNT BcdToWord(BYTE *, UWORD *, UWORD *, UWORD *); +COUNT ByteToBcd(COUNT); +VOID DayToBcd(BYTE *, UWORD *, UWORD *, UWORD *); +#else +BOOL ReadPCClock(); +VOID WriteATClock(); +VOID WritePCClock(); +COUNT BcdToByte(); +COUNT BcdToWord(); +COUNT ByteToBcd(); +VOID DayToBcd(); +#endif + +/* */ +/* WARNING - THIS DRIVER IS NON-PORTABLE!!!! */ +/* */ + +WORD days[2][13] = +{ + {0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365}, + {0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366} +}; + +static struct ClockRecord clk; + +static BYTE bcdDays[4]; +static UWORD Month, + Day, + Year; +static BYTE bcdMinutes; +static BYTE bcdHours; +static BYTE bcdHundredths; +static BYTE bcdSeconds; + +static ULONG Ticks; +UWORD DaysSinceEpoch = 0; + +WORD clk_driver(rqptr rp) +{ + REG COUNT count, + c; + BYTE FAR *cp; + + switch (rp->r_command) + { + case C_INIT: + rp->r_endaddr = device_end(); + rp->r_nunits = 0; + return S_DONE; + + case C_INPUT: + count = rp->r_count; + if (count > sizeof(struct ClockRecord)) + count = sizeof(struct ClockRecord); + { + ULONG remainder, + hs; + if (ReadPCClock(&Ticks)) + ++DaysSinceEpoch; + clk.clkDays = DaysSinceEpoch; + /* + * Another tricky calculation (after the one in `main.c'). This time + * we do have a problem with overflow, because we need to extract the + * 1/100s portion too. The scaling factor is now + * (100 x 86400) / 0x1800b0 = 108000 / 19663. -- ror4 + */ + hs = 0; + if (Ticks >= 64 * 19663ul) + { + hs += 64 * 108000ul; + Ticks -= 64 * 19663ul; + } + if (Ticks >= 32 * 19663ul) + { + hs += 32 * 108000ul; + Ticks -= 32 * 19663ul; + } + if (Ticks >= 16 * 19663ul) + { + hs += 16 * 108000ul; + Ticks -= 16 * 19663ul; + } + if (Ticks >= 8 * 19663ul) + { + hs += 8 * 108000ul; + Ticks -= 8 * 19663ul; + } + if (Ticks >= 4 * 19663ul) + { + hs += 4 * 108000ul; + Ticks -= 4 * 19663ul; + } + if (Ticks >= 2 * 19663ul) + { + hs += 2 * 108000ul; + Ticks -= 2 * 19663ul; + } + if (Ticks >= 19663ul) + { + hs += 108000ul; + Ticks -= 19663ul; + } + /* + * Now Ticks < 19663, so Ticks * 108000 < 2123604000 < ULONG_MAX. + * *phew* -- ror4 + */ + hs += Ticks * 108000ul / 19663ul; + clk.clkHours = hs / 360000ul; + remainder = hs % 360000ul; + clk.clkMinutes = remainder / 6000ul; + remainder %= 6000ul; + clk.clkSeconds = remainder / 100ul; + clk.clkHundredths = remainder % 100ul; + } + fbcopy((BYTE FAR *) & clk, rp->r_trans, count); + return S_DONE; + + case C_OUTPUT: + count = rp->r_count; + if (count > sizeof(struct ClockRecord)) + count = sizeof(struct ClockRecord); + rp->r_count = count; + fbcopy(rp->r_trans, (BYTE FAR *) & clk, count); + + /* Set PC Clock first */ + DaysSinceEpoch = clk.clkDays; + { + ULONG hs; + hs = 360000ul * clk.clkHours + + 6000ul * clk.clkMinutes + + 100ul * clk.clkSeconds + + clk.clkHundredths; + Ticks = 0; + if (hs >= 64 * 108000ul) + { + Ticks += 64 * 19663ul; + hs -= 64 * 108000ul; + } + if (hs >= 32 * 108000ul) + { + Ticks += 32 * 19663ul; + hs -= 32 * 108000ul; + } + if (hs >= 16 * 108000ul) + { + Ticks += 16 * 19663ul; + hs -= 16 * 108000ul; + } + if (hs >= 8 * 108000ul) + { + Ticks += 8 * 19663ul; + hs -= 8 * 108000ul; + } + if (hs >= 4 * 108000ul) + { + Ticks += 4 * 19663ul; + hs -= 4 * 108000ul; + } + if (hs >= 2 * 108000ul) + { + Ticks += 2 * 19663ul; + hs -= 2 * 108000ul; + } + if (hs >= 108000ul) + { + Ticks += 19663ul; + hs -= 108000ul; + } + Ticks += hs * 19663ul / 108000ul; + } + WritePCClock(Ticks); + + /* Now set AT clock */ + /* Fix year by looping through each year, subtracting */ + /* the appropriate number of days for that year. */ + for (Year = 1980, c = clk.clkDays; c > 0;) + { + count = is_leap_year(Year) ? 366 : 365; + if (c >= count) + { + ++Year; + c -= count; + } + else + break; + } + + /* c contains the days left and count the number of */ + /* days for that year. Use this to index the table. */ + for (Month = 1; Month < 13; ++Month) + { + if (days[count == 366][Month] > c) + { + Day = c - days[count == 366][Month - 1] + 1; + break; + } + } + DayToBcd((BYTE *) bcdDays, &Month, &Day, &Year); + bcdMinutes = ByteToBcd(clk.clkMinutes); + bcdHours = ByteToBcd(clk.clkHours); + bcdSeconds = ByteToBcd(clk.clkSeconds); + WriteATClock(bcdDays, bcdHours, bcdMinutes, bcdSeconds); + return S_DONE; + + case C_OFLUSH: + case C_IFLUSH: + return S_DONE; + + case C_OUB: + case C_NDREAD: + case C_OSTAT: + case C_ISTAT: + default: + return failure(E_FAILURE); /* general failure */ + } +} + +COUNT ByteToBcd(COUNT x) +{ + return ((x / 10) << 4) | (x % 10); +} + +VOID DayToBcd(BYTE * x, UWORD * mon, UWORD * day, UWORD * yr) +{ + x[1] = ByteToBcd(*mon); + x[0] = ByteToBcd(*day); + x[3] = ByteToBcd(*yr / 100); + x[2] = ByteToBcd(*yr % 100); +} + +/* Used by `main.c'. */ +VOID FAR init_call_WritePCClock(ULONG ticks) +{ + WritePCClock(ticks); +} diff --git a/kernel/syspack.c b/kernel/syspack.c new file mode 100644 index 00000000..c221675c --- /dev/null +++ b/kernel/syspack.c @@ -0,0 +1,157 @@ +/****************************************************************/ +/* */ +/* syspack.c */ +/* */ +/* System Disk Byte Order Packing Functions */ +/* */ +/* Copyright (c) 1995 */ +/* Pasquale J. Villani */ +/* All Rights Reserved */ +/* */ +/* This file is part of DOS-C. */ +/* */ +/* DOS-C is free software; you can redistribute it and/or */ +/* modify it under the terms of the GNU General Public License */ +/* as published by the Free Software Foundation; either version */ +/* 2, or (at your option) any later version. */ +/* */ +/* DOS-C is distributed in the hope that it will be useful, but */ +/* WITHOUT ANY WARRANTY; without even the implied warranty of */ +/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See */ +/* the GNU General Public License for more details. */ +/* */ +/* You should have received a copy of the GNU General Public */ +/* License along with DOS-C; see the file COPYING. If not, */ +/* write to the Free Software Foundation, 675 Mass Ave, */ +/* Cambridge, MA 02139, USA. */ +/* */ +/****************************************************************/ + +#include "portab.h" +#include "globals.h" + +#ifdef VERSION_STRINGS +static BYTE *syspackRcsId = "$Id$"; +#endif + +/* + * $Log$ + * Revision 1.1 2000/05/06 19:35:34 jhall1 + * Initial revision + * + * Revision 1.1.1.1 1999/03/29 15:42:21 jprice + * New version without IPL.SYS + * + * Revision 1.3 1999/02/01 01:43:28 jprice + * Fixed findfirst function to find volume label with Windows long filenames + * + * Revision 1.2 1999/01/22 04:15:28 jprice + * Formating + * + * Revision 1.1.1.1 1999/01/20 05:51:00 jprice + * Imported sources + * + * + * Rev 1.4 04 Jan 1998 23:14:38 patv + * Changed Log for strip utility + * + * Rev 1.3 29 May 1996 21:15:12 patv + * bug fixes for v0.91a + * + * Rev 1.2 01 Sep 1995 17:48:42 patv + * First GPL release. + * + * Rev 1.1 30 Jul 1995 20:50:26 patv + * Eliminated version strings in ipl + * + * Rev 1.0 02 Jul 1995 8:05:34 patv + * Initial revision. + */ + +#ifdef NONNATIVE +VOID getlong(REG VOID * vp, LONG * lp) +{ + *lp = (((BYTE *) vp)[0] & 0xff) + + ((((BYTE *) vp)[1] & 0xff) << 8) + + ((((BYTE *) vp)[2] & 0xff) << 16) + + ((((BYTE *) vp)[3] & 0xff) << 24); +} + +VOID getword(REG VOID * vp, WORD * wp) +{ + *wp = (((BYTE *) vp)[0] & 0xff) + ((((BYTE *) vp)[1] & 0xff) << 8); +} + +VOID getbyte(VOID * vp, BYTE * bp) +{ + *bp = *((BYTE *) vp); +} + +VOID fgetword(REG VOID FAR * vp, WORD FAR * wp) +{ + *wp = (((BYTE FAR *) vp)[0] & 0xff) + ((((BYTE FAR *) vp)[1] & 0xff) << 8); +} + +VOID fgetlong(REG VOID FAR * vp, LONG FAR * lp) +{ + *lp = (((BYTE *) vp)[0] & 0xff) + + ((((BYTE *) vp)[1] & 0xff) << 8) + + ((((BYTE *) vp)[2] & 0xff) << 16) + + ((((BYTE *) vp)[3] & 0xff) << 24); +} + +VOID fgetbyte(VOID FAR * vp, BYTE FAR * bp) +{ + *bp = *((BYTE FAR *) vp); +} + +VOID fputlong(LONG FAR * lp, VOID FAR * vp) +{ + REG BYTE FAR *bp = (BYTE FAR *) vp; + + bp[0] = *lp & 0xff; + bp[1] = (*lp >> 8) & 0xff; + bp[2] = (*lp >> 16) & 0xff; + bp[3] = (*lp >> 24) & 0xff; +} + +VOID fputword(WORD FAR * wp, VOID FAR * vp) +{ + REG BYTE FAR *bp = (BYTE FAR *) vp; + + bp[0] = *wp & 0xff; + bp[1] = (*wp >> 8) & 0xff; +} + +VOID fputbyte(BYTE FAR * bp, VOID FAR * vp) +{ + *(BYTE FAR *) vp = *bp; +} +#endif + +VOID getdirent(BYTE FAR * vp, struct dirent FAR * dp) +{ + fbcopy(&vp[DIR_NAME], dp->dir_name, FNAME_SIZE); + fbcopy(&vp[DIR_EXT], dp->dir_ext, FEXT_SIZE); + fgetbyte(&vp[DIR_ATTRIB], (BYTE FAR *) & dp->dir_attrib); + fgetword(&vp[DIR_TIME], (WORD FAR *) & dp->dir_time); + fgetword(&vp[DIR_DATE], (WORD FAR *) & dp->dir_date); + fgetword(&vp[DIR_START], (WORD FAR *) & dp->dir_start); + fgetlong(&vp[DIR_SIZE], (LONG FAR *) & dp->dir_size); +} + +VOID putdirent(struct dirent FAR * dp, BYTE FAR * vp) +{ + REG COUNT i; + REG BYTE FAR *p; + + fbcopy(dp->dir_name, &vp[DIR_NAME], FNAME_SIZE); + fbcopy(dp->dir_ext, &vp[DIR_EXT], FEXT_SIZE); + fputbyte((BYTE FAR *) & dp->dir_attrib, &vp[DIR_ATTRIB]); + fputword((WORD FAR *) & dp->dir_time, &vp[DIR_TIME]); + fputword((WORD FAR *) & dp->dir_date, &vp[DIR_DATE]); + fputword((WORD FAR *) & dp->dir_start, &vp[DIR_START]); + fputlong((LONG FAR *) & dp->dir_size, &vp[DIR_SIZE]); + for (i = 0, p = (BYTE FAR *) & vp[DIR_RESERVED]; i < 10; i++) + *p++ = NULL; +} diff --git a/kernel/systime.c b/kernel/systime.c new file mode 100644 index 00000000..d4799ab3 --- /dev/null +++ b/kernel/systime.c @@ -0,0 +1,242 @@ +/****************************************************************/ +/* */ +/* systime.c */ +/* */ +/* DOS/C Date/Time Functions */ +/* */ +/* Copyright (c) 1998 */ +/* Pasquale J. Villani */ +/* All Rights Reserved */ +/* */ +/* This file is part of DOS-C. */ +/* */ +/* DOS-C is free software; you can redistribute it and/or */ +/* modify it under the terms of the GNU General Public License */ +/* as published by the Free Software Foundation; either version */ +/* 2, or (at your option) any later version. */ +/* */ +/* DOS-C is distributed in the hope that it will be useful, but */ +/* WITHOUT ANY WARRANTY; without even the implied warranty of */ +/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See */ +/* the GNU General Public License for more details. */ +/* */ +/* You should have received a copy of the GNU General Public */ +/* License along with DOS-C; see the file COPYING. If not, */ +/* write to the Free Software Foundation, 675 Mass Ave, */ +/* Cambridge, MA 02139, USA. */ +/****************************************************************/ + +#include "portab.h" +#include "time.h" +#include "date.h" +#include "globals.h" + +#ifdef VERSION_STRINGS +static BYTE *RcsId = "$Id$"; +#endif + +/* + * $Log$ + * Revision 1.1 2000/05/06 19:35:34 jhall1 + * Initial revision + * + * Revision 1.3 1999/05/04 16:40:30 jprice + * ror4 date fix + * + * Revision 1.2 1999/04/12 03:21:18 jprice + * more ror4 patches. Changes for multi-block IO + * + * Revision 1.1.1.1 1999/03/29 15:41:34 jprice + * New version without IPL.SYS + * + * Revision 1.5 1999/02/08 05:55:58 jprice + * Added Pat's 1937 kernel patches + * + * Revision 1.4 1999/02/04 03:14:07 jprice + * Formating. Added comments. + * + * Revision 1.3 1999/02/01 01:48:41 jprice + * Clean up; Now you can use hex numbers in config.sys. added config.sys screen function to change screen mode (28 or 43/50 lines) + * + * Revision 1.2 1999/01/22 04:13:27 jprice + * Formating + * + * Revision 1.1.1.1 1999/01/20 05:51:01 jprice + * Imported sources + * + * + * Rev 1.6 06 Dec 1998 8:47:30 patv + * Bug fixes. + * + * Rev 1.5 04 Jan 1998 23:15:22 patv + * Changed Log for strip utility + * + * Rev 1.4 03 Jan 1998 8:36:50 patv + * Converted data area to SDA format + * + * Rev 1.3 29 May 1996 21:03:40 patv + * bug fixes for v0.91a + * + * Rev 1.2 19 Feb 1996 3:21:34 patv + * Added NLS, int2f and config.sys processing + * + * Rev 1.1 01 Sep 1995 17:54:16 patv + * First GPL release. + * + * Rev 1.0 02 Jul 1995 8:32:20 patv + * Initial revision. + */ + +static WORD days[2][13] = +{ + {0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365}, + {0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366} +}; + +static WORD ndays[2][13] = +{ + /* 1 2 3 4 5 6 7 8 9 10 11 12 */ + {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}, + {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}, +}; + +extern BYTE + Month, + DayOfMonth, + DayOfWeek; + +extern COUNT + Year, + YearsSince1980; + +extern request + ClkReqHdr; + +VOID DosGetTime(BYTE FAR * hp, BYTE FAR * mp, BYTE FAR * sp, BYTE FAR * hdp) +{ + ClkReqHdr.r_length = sizeof(request); + ClkReqHdr.r_command = C_INPUT; + ClkReqHdr.r_count = sizeof(struct ClockRecord); + ClkReqHdr.r_trans = (BYTE FAR *) (&ClkRecord); + ClkReqHdr.r_status = 0; + execrh((request FAR *) & ClkReqHdr, (struct dhdr FAR *)clock); + if (ClkReqHdr.r_status & S_ERROR) + return; + + *hp = ClkRecord.clkHours; + *mp = ClkRecord.clkMinutes; + *sp = ClkRecord.clkSeconds; + *hdp = ClkRecord.clkHundredths; +} + +COUNT DosSetTime(BYTE FAR * hp, BYTE FAR * mp, BYTE FAR * sp, BYTE FAR * hdp) +{ + DosGetDate((BYTE FAR *) & DayOfWeek, (BYTE FAR *) & Month, + (BYTE FAR *) & DayOfMonth, (COUNT FAR *) & Year); + + ClkRecord.clkHours = *hp; + ClkRecord.clkMinutes = *mp; + ClkRecord.clkSeconds = *sp; + ClkRecord.clkHundredths = *hdp; + + YearsSince1980 = Year - 1980; + ClkRecord.clkDays = DayOfMonth - 1 + + days[is_leap_year(Year)][Month - 1] + + ((YearsSince1980) * 365) + + ((YearsSince1980 + 3) / 4); + + ClkReqHdr.r_length = sizeof(request); + ClkReqHdr.r_command = C_OUTPUT; + ClkReqHdr.r_count = sizeof(struct ClockRecord); + ClkReqHdr.r_trans = (BYTE FAR *) (&ClkRecord); + ClkReqHdr.r_status = 0; + execrh((request FAR *) & ClkReqHdr, (struct dhdr FAR *)clock); + if (ClkReqHdr.r_status & S_ERROR) + return char_error(&ClkReqHdr, (struct dhdr FAR *)clock); + return SUCCESS; +} + +VOID DosGetDate(wdp, mp, mdp, yp) +BYTE FAR *wdp, + FAR * mp, + FAR * mdp; +COUNT FAR *yp; +{ + COUNT count, + c; + + ClkReqHdr.r_length = sizeof(request); + ClkReqHdr.r_command = C_INPUT; + ClkReqHdr.r_count = sizeof(struct ClockRecord); + ClkReqHdr.r_trans = (BYTE FAR *) (&ClkRecord); + ClkReqHdr.r_status = 0; + execrh((request FAR *) & ClkReqHdr, (struct dhdr FAR *)clock); + if (ClkReqHdr.r_status & S_ERROR) + return; + + for (Year = 1980, c = ClkRecord.clkDays; c > 0;) + { + count = is_leap_year(Year) ? 366 : 365; + if (c >= count) + { + ++Year; + c -= count; + } + else + break; + } + + /* c contains the days left and count the number of days for */ + /* that year. Use this to index the table. */ + Month = 1; + while (c >= ndays[count == 366][Month]) + { + c -= ndays[count == 366][Month]; + ++Month; + } + + *mp = Month; + *mdp = c + 1; + *yp = Year; + + /* Day of week is simple. Take mod 7, add 2 (for Tuesday */ + /* 1-1-80) and take mod again */ + + DayOfWeek = (ClkRecord.clkDays % 7 + 2) % 7; + *wdp = DayOfWeek; +} + +COUNT DosSetDate(mp, mdp, yp) +BYTE FAR *mp, + FAR * mdp; +COUNT FAR *yp; +{ + Month = *mp; + DayOfMonth = *mdp; + Year = *yp; + if (Year < 1980 || Year > 2099 + || Month < 1 || Month > 12 + || DayOfMonth < 1 || DayOfMonth > ndays[is_leap_year(Year)][Month]) + return DE_INVLDDATA; + + DosGetTime((BYTE FAR *) & ClkRecord.clkHours, + (BYTE FAR *) & ClkRecord.clkMinutes, + (BYTE FAR *) & ClkRecord.clkSeconds, + (BYTE FAR *) & ClkRecord.clkHundredths); + + YearsSince1980 = Year - 1980; + ClkRecord.clkDays = DayOfMonth - 1 + + days[is_leap_year(Year)][Month - 1] + + ((YearsSince1980) * 365) + + ((YearsSince1980 + 3) / 4); + + ClkReqHdr.r_length = sizeof(request); + ClkReqHdr.r_command = C_OUTPUT; + ClkReqHdr.r_count = sizeof(struct ClockRecord); + ClkReqHdr.r_trans = (BYTE FAR *) (&ClkRecord); + ClkReqHdr.r_status = 0; + execrh((request FAR *) & ClkReqHdr, (struct dhdr FAR *)clock); + if (ClkReqHdr.r_status & S_ERROR) + return char_error(&ClkReqHdr, (struct dhdr FAR *)clock); + return SUCCESS; +} diff --git a/kernel/task.c b/kernel/task.c new file mode 100644 index 00000000..9c9928f9 --- /dev/null +++ b/kernel/task.c @@ -0,0 +1,914 @@ +/****************************************************************/ +/* */ +/* task.c */ +/* */ +/* Task Manager for DOS Processes */ +/* */ +/* Copyright (c) 1995 */ +/* Pasquale J. Villani */ +/* All Rights Reserved */ +/* */ +/* This file is part of DOS-C. */ +/* */ +/* DOS-C is free software; you can redistribute it and/or */ +/* modify it under the terms of the GNU General Public License */ +/* as published by the Free Software Foundation; either version */ +/* 2, or (at your option) any later version. */ +/* */ +/* DOS-C is distributed in the hope that it will be useful, but */ +/* WITHOUT ANY WARRANTY; without even the implied warranty of */ +/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See */ +/* the GNU General Public License for more details. */ +/* */ +/* You should have received a copy of the GNU General Public */ +/* License along with DOS-C; see the file COPYING. If not, */ +/* write to the Free Software Foundation, 675 Mass Ave, */ +/* Cambridge, MA 02139, USA. */ +/****************************************************************/ + +#include "portab.h" +#include "globals.h" + +#ifdef VERSION_STRINGS +static BYTE *RcsId = "$Id$"; +#endif + +/* + * $Log$ + * Revision 1.1 2000/05/06 19:35:36 jhall1 + * Initial revision + * + * Revision 1.7 2000/03/09 06:07:11 kernel + * 2017f updates by James Tabor + * + * Revision 1.6 1999/08/25 03:18:10 jprice + * ror4 patches to allow TC 2.01 compile. + * + * Revision 1.5 1999/04/23 04:24:39 jprice + * Memory manager changes made by ska + * + * Revision 1.4 1999/04/16 00:53:33 jprice + * Optimized FAT handling + * + * Revision 1.3 1999/04/11 04:33:39 jprice + * ror4 patches + * + * Revision 1.2 1999/03/29 17:05:09 jprice + * ror4 changes + * + * Revision 1.1.1.1 1999/03/29 15:41:41 jprice + * New version without IPL.SYS + * + * Revision 1.5 1999/02/08 05:55:58 jprice + * Added Pat's 1937 kernel patches + * + * Revision 1.4 1999/02/04 03:14:07 jprice + * Formating. Added comments. + * + * Revision 1.3 1999/02/01 01:48:41 jprice + * Clean up; Now you can use hex numbers in config.sys. added config.sys screen function to change screen mode (28 or 43/50 lines) + * + * Revision 1.2 1999/01/22 04:13:27 jprice + * Formating + * + * Revision 1.1.1.1 1999/01/20 05:51:01 jprice + * Imported sources + * + * + * Rev 1.15 06 Dec 1998 8:46:28 patv + * Bug fixes. + * + * Rev 1.14 07 Feb 1998 20:38:32 patv + * Modified stack fram to match DOS standard + * + * Rev 1.13 31 Jan 1998 14:39:20 patv + * Corrected type in load high code. + * + * Rev 1.12 31 Jan 1998 14:02:52 patv + * Added load high in memory option in DosExeLoader. + * + * Rev 1.11 22 Jan 1998 22:17:14 patv + * Eliminated warnings. + * + * Rev 1.10 22 Jan 1998 21:31:36 patv + * Corrected short .COM problem. + * + * Rev 1.9 04 Jan 1998 23:15:16 patv + * Changed Log for strip utility + * + * Rev 1.8 22 Jan 1997 13:18:14 patv + * pre-0.92 Svante Frey bug fixes. + * + * Rev 1.7 16 Jan 1997 12:46:56 patv + * pre-Release 0.92 feature additions + * + * Rev 1.5 29 Aug 1996 13:07:22 patv + * Bug fixes for v0.91b + * + * Rev 1.4 29 May 1996 21:03:36 patv + * bug fixes for v0.91a + * + * Rev 1.3 19 Feb 1996 3:21:48 patv + * Added NLS, int2f and config.sys processing + * + * Rev 1.2 01 Sep 1995 17:54:22 patv + * First GPL release. + * + * Rev 1.1 30 Jul 1995 20:51:58 patv + * Eliminated version strings in ipl + * + * Rev 1.0 02 Jul 1995 8:34:06 patv + * Initial revision. + */ + +#define toupper(c) ((c) >= 'a' && (c) <= 'z' ? (c) + ('A' - 'a') : (c)) + +#define LOADNGO 0 +#define LOAD 1 +#define OVERLAY 3 + +static exe_header header; + +#define CHUNK 32256 +#define MAXENV 32768 +#define ENV_KEEPFREE 83 /* keep unallocated by environment variables */ + /* The '65' added to nEnvSize does not cover the additional stuff: + + 2 bytes: number of strings + + 80 bytes: maximum absolute filename + + 1 byte: '\0' + -- 1999/04/21 ska */ + +#ifndef PROTO +COUNT ChildEnv(exec_blk FAR *, UWORD *, char far *); +#else +COUNT ChildEnv(); +#endif + +LONG doslseek(COUNT fd, LONG foffset, COUNT origin) +{ + LONG set_pos; + DosSeek(fd, foffset, origin, (ULONG *) & set_pos); + return set_pos; +} + +LONG DosGetFsize(COUNT hndl) +{ + sft FAR *s; + sfttbl FAR *sp; + + /* Test that the handle is valid */ + if (hndl < 0) + return DE_INVLDHNDL; + + /* Get the SFT block that contains the SFT */ + if ((s = get_sft(hndl)) == (sft FAR *) - 1) + return DE_INVLDHNDL; + + /* If this is not opened another error */ + if (s->sft_count == 0) + return DE_ACCESS; + + /* If SFT entry refers to a device, return the date and time of opening */ + if (s->sft_flags & (SFT_FDEVICE | SFT_FSHARED)) + { + return s->sft_size; + } + + /* call file system handler */ + return dos_getfsize(s->sft_status); +} + +COUNT ChildEnv(exec_blk FAR * exp, UWORD * pChildEnvSeg, char far * pathname) +{ + BYTE FAR *pSrc; + BYTE FAR *pDest; + UWORD nEnvSize; + COUNT RetCode; +/* UWORD MaxEnvSize; not used -- 1999/04/21 ska */ + psp FAR *ppsp = MK_FP(cu_psp, 0); + + /* create a new environment for the process */ + /* copy parent's environment if exec.env_seg == 0 */ + + pDest = pSrc = exp->exec.env_seg ? + MK_FP(exp->exec.env_seg, 0) : + MK_FP(ppsp->ps_environ, 0); + +#if 0 + /* Every process requires an environment because of argv[0] + -- 1999/04/21 ska */ + */ + if (!pSrc) /* no environment to copy */ + { + *pChildEnvSeg = 0; + return SUCCESS; + } +#endif + + nEnvSize = 1; + /* This loop had not counted the very last '\0' + -- 1999/04/21 ska */ + if (pSrc) + { /* if no environment is available, one byte is required */ + while (*pSrc != '\0') + { + while (*pSrc != '\0' && pSrc < pDest + MAXENV - ENV_KEEPFREE) + { + ++pSrc; + ++nEnvSize; + } + /* account for terminating null */ + ++nEnvSize; + ++pSrc; + } + pSrc = pDest; + } + + /* Test env size and abort if greater than max */ + if (nEnvSize >= MAXENV) + return DE_INVLDENV; + + /* allocate enough space for env + path */ + if ((RetCode = DosMemAlloc(long2para(nEnvSize + ENV_KEEPFREE), + FIRST_FIT, (seg FAR *) pChildEnvSeg, + NULL /*(UWORD FAR *) MaxEnvSize ska */ )) < 0) + return RetCode; + pDest = MK_FP(*pChildEnvSeg + 1, 0); + + /* fill the new env and inform the process of its */ + /* location throught the psp */ + + /* copy the environment */ + if (pSrc) + { + fbcopy(pSrc, pDest, nEnvSize); + pDest += nEnvSize; + } + else + *pDest++ = '\0'; /* create an empty environment */ + +#if 0 + /* The size is already known, use a quicker copy function + -- 1999/04/21 ska */ + for (; *pSrc != '\0';) + { + while (*pSrc) + { + *pDest++ = *pSrc++; + } + pSrc++; + *pDest++ = 0; + } + *pDest++ = 0; +#endif + /* initialize 'extra strings' count */ + *((UWORD FAR *) pDest)++ = 1; + + /* copy complete pathname */ + truename(pathname, pDest, TRUE); + + /* Theoretically one could either: + + resize the already allocated block to best-fit behind the pathname, or + + generate the filename into a temporary buffer to allocate only the + minimum required environment -- 1999/04/21 ska */ + + return SUCCESS; +} + +/* The following code is 8086 dependant */ +VOID new_psp(psp FAR * p, int psize) +{ + REG COUNT i; + BYTE FAR *lpPspBuffer; + psp FAR *q = MK_FP(cu_psp, 0); + + /* Clear out new psp first */ + for (lpPspBuffer = (BYTE FAR *) p, i = 0; i < sizeof(psp); ++i) + *lpPspBuffer = 0; + + /* initialize all entries and exits */ + /* CP/M-like exit point */ + p->ps_exit = 0x20cd; + + /* CP/M-like entry point - jump to special entry */ + p->ps_farcall = 0xea; + p->ps_reentry = cpm_entry; + /* unix style call - 0xcd 0x21 0xcb (int 21, retf) */ + p->ps_unix[0] = 0xcd; + p->ps_unix[1] = 0x21; + p->ps_unix[2] = 0xcb; + + /* Now for parent-child relationships */ + /* parent psp segment */ + p->ps_parent = cu_psp; + /* previous psp pointer */ + p->ps_prevpsp = q; + + /* Environment and memory useage parameters */ + /* memory size in paragraphs */ + p->ps_size = psize; + /* environment paragraph */ + p->ps_environ = 0; + /* process dta */ + p->ps_dta = (BYTE FAR *) (&p->ps_cmd_count); + + /* terminate address */ + p->ps_isv22 = (VOID(interrupt FAR *) (void))getvec(0x22); + /* break address */ + p->ps_isv23 = (VOID(interrupt FAR *) (void))getvec(0x23); + /* critical error address */ + p->ps_isv24 = (VOID(interrupt FAR *) (void))getvec(0x24); + + /* File System parameters */ + /* user stack pointer - int 21 */ + p->ps_stack = (BYTE FAR *) - 1; + /* file table - 0xff is unused */ + for (i = 0; i < 20; i++) + p->ps_files[i] = 0xff; + + /* maximum open files */ + p->ps_maxfiles = 20; + /* open file table pointer */ + p->ps_filetab = p->ps_files; + + /* clone the file table */ + if (InDOS > 0) + { + REG COUNT i; + + for (i = 0; i < 20; i++) + { + if (q->ps_filetab[i] != 0xff && CloneHandle(i) >= 0) + p->ps_filetab[i] = q->ps_filetab[i]; + else + p->ps_filetab[i] = 0xff; + } + } + else + { + /* initialize stdin, stdout, etc */ + p->ps_files[STDIN] = 0; /* stdin */ + p->ps_files[STDOUT] = 1; /* stdout */ + p->ps_files[STDERR] = 2; /* stderr */ + p->ps_files[STDAUX] = 3; /* stdaux */ + p->ps_files[STDPRN] = 4; /* stdprn */ + } + + /* first command line argument */ + p->ps_fcb1.fcb_drive = 0; + /* second command line argument */ + p->ps_fcb2.fcb_drive = 0; + + /* local command line */ + p->ps_cmd_count = 0; /* command tail */ + p->ps_cmd[0] = 0; /* command tail */ + if (RootPsp == (seg) ~ 0) + RootPsp = FP_SEG(p); +} + +static VOID patchPSP(UWORD pspseg, UWORD envseg, CommandTail FAR * cmdline + ,BYTE FAR * fnam) +{ + psp FAR *psp; + mcb FAR *pspmcb; + int i; + BYTE FAR *np; + + pspmcb = MK_FP(pspseg, 0); + ++pspseg; + psp = MK_FP(pspseg, 0); + + /* complete the psp by adding the command line */ + fbcopy(cmdline->ctBuffer, psp->ps_cmd, 127); + psp->ps_cmd_count = cmdline->ctCount; + + /* identify the mcb as this functions' */ + pspmcb->m_psp = pspseg; + /* Patch in environment segment, if present, also adjust its MCB */ + if (envseg) + { + psp->ps_environ = envseg + 1; + ((mcb FAR *) MK_FP(envseg, 0))->m_psp = pspseg; + } + else + psp->ps_environ = 0; + + /* use the file name less extension - left adjusted and */ + np = fnam; + for (;;) + { + switch (*fnam++) + { + case '\0': + goto set_name; + case ':': + case '/': + case '\\': + np = fnam; + } + } +set_name: + for (i = 0; i < 8 && np[i] != '.' && np[i] != '\0'; i++) + { + pspmcb->m_name[i] = toupper(np[i]); + } + if (i < 8) + pspmcb->m_name[i] = '\0'; + +} + +static COUNT DosComLoader(BYTE FAR * namep, exec_blk FAR * exp, COUNT mode) +{ + COUNT rc, + err, + env_size; + COUNT nread; + UWORD mem; + UWORD env, + asize; + BYTE FAR *sp; + psp FAR *p; + psp FAR *q = MK_FP(cu_psp, 0); + iregs FAR *irp; + LONG com_size; + + if (mode != OVERLAY) + { + + if ((rc = ChildEnv(exp, &env, namep)) != SUCCESS) + { + return rc; + } + /* Allocate our memory and pass back any errors */ + if ((rc = DosMemAlloc(0, LARGEST, (seg FAR *) & mem, (UWORD FAR *) & asize)) < 0) + { + DosMemFree(env); /* env may be 0 */ + return rc; + } + ++mem; + } + else + mem = exp->load.load_seg; + + /* Now load the executable */ + /* If file not found - error */ + /* NOTE - this is fatal because we lost it in transit */ + /* from DosExec! */ + if ((rc = DosOpen(namep, 0)) < 0) + fatal("(DosComLoader) com file lost in transit"); + + /* do it in 32K chunks */ + if ((com_size = DosGetFsize(rc)) != 0) + { + if (mode == OVERLAY) /* memory already allocated */ + sp = MK_FP(mem, 0); + else + { /* test the filesize against the allocated memory */ + sp = MK_FP(mem, sizeof(psp)); + + /* This is a potential problem, what to do with .COM files larger than + the allocated memory? + MS DOS always only loads the very first 64KB - sizeof(psp) bytes. + -- 1999/04/21 ska */ + if (com_size > (LONG) asize << 4) /* less memory than the .COM file has */ + com_size = (LONG) asize << 4; + } + do + { + nread = DosRead(rc, CHUNK, sp, &err); + sp = add_far((VOID FAR *) sp, (ULONG) nread); + } + while ((com_size -= nread) > 0 && nread == CHUNK); + } + DosClose(rc); + + if (mode == OVERLAY) + return SUCCESS; + + /* point to the PSP so we can build it */ + p = MK_FP(mem, 0); + setvec(0x22, (VOID(INRPT FAR *) (VOID)) MK_FP(user_r->CS, user_r->IP)); + new_psp(p, mem + asize); + + patchPSP(mem - 1, env, exp->exec.cmd_line, namep); + + /* build the user area on the stack */ + *((UWORD FAR *) MK_FP(mem, 0xfffe)) = (UWORD) 0; + irp = MK_FP(mem, (0xfffe - sizeof(iregs))); + + /* start allocating REGs */ + irp->ES = irp->DS = mem; + irp->CS = mem; + irp->IP = 0x100; + irp->AX = 0xffff; /* for now, until fcb code is in */ + irp->BX = + irp->CX = + irp->DX = + irp->SI = + irp->DI = + irp->BP = 0; + irp->FLAGS = 0x200; + + /* Transfer control to the executable */ + p->ps_parent = cu_psp; + p->ps_prevpsp = (BYTE FAR *) MK_FP(cu_psp, 0); + q->ps_stack = (BYTE FAR *) user_r; + user_r->FLAGS &= ~FLG_CARRY; + + switch (mode) + { + case LOADNGO: + { + cu_psp = mem; + dta = p->ps_dta; + if (InDOS) + --InDOS; + exec_user(irp); + + /* We should never be here */ + fatal("KERNEL RETURNED!!!"); + break; + } + case LOAD: + cu_psp = mem; + exp->exec.stack = (BYTE FAR *) irp; + exp->exec.start_addr = MK_FP(irp->CS, irp->IP); + return SUCCESS; + } + + return DE_INVLDFMT; +} + +VOID return_user(void) +{ + psp FAR *p, + FAR * q; + REG COUNT i; + iregs FAR *irp; + long j; + + /* restore parent */ + p = MK_FP(cu_psp, 0); + + /* When process returns - restore the isv */ + setvec(0x22, p->ps_isv22); + setvec(0x23, p->ps_isv23); + setvec(0x24, p->ps_isv24); + + /* And free all process memory if not a TSR return */ + if (!tsr) + { + for (i = 0; i < p->ps_maxfiles; i++) + { + DosClose(i); + } + FreeProcessMem(cu_psp); + } + + cu_psp = p->ps_parent; + q = MK_FP(cu_psp, 0); + dta = q->ps_dta; + + irp = (iregs FAR *) q->ps_stack; + + irp->CS = FP_SEG(p->ps_isv22); + irp->IP = FP_OFF(p->ps_isv22); + + if (InDOS) + --InDOS; + exec_user((iregs FAR *) q->ps_stack); +} + +static COUNT DosExeLoader(BYTE FAR * namep, exec_blk FAR * exp, COUNT mode) +{ + COUNT rc, + err, + env_size, + i; + COUNT nBytesRead; + UWORD mem, + env, + asize, + start_seg; + ULONG image_size; + ULONG image_offset; + BYTE FAR *sp; + psp FAR *p; + psp FAR *q = MK_FP(cu_psp, 0); + mcb FAR *mp; + iregs FAR *irp; + UWORD reloc[2]; + seg FAR *spot; + LONG exe_size; + + /* Clone the environement and create a memory arena */ + if (mode != OVERLAY) + { + if ((rc = ChildEnv(exp, &env, namep)) != SUCCESS) + return rc; + } + else + mem = exp->load.load_seg; + + /* compute image offset from the header */ + image_offset = (ULONG) header.exHeaderSize * 16l; + + /* compute image size by removing the offset from the */ + /* number pages scaled to bytes plus the remainder and */ + /* the psp */ + /* First scale the size */ + image_size = (ULONG) (header.exPages) * 512l; + /* remove the offset */ + image_size -= image_offset; + + /* and finally add in the psp size */ + if (mode != OVERLAY) + image_size += (ULONG) long2para((LONG) sizeof(psp)); + + if (mode != OVERLAY) + { + /* Now find out how many paragraphs are available */ + if ((rc = DosMemLargest((seg FAR *) & asize)) != SUCCESS) + { + DosMemFree(env); + return rc; + } + + exe_size = (LONG) long2para(image_size) + header.exMinAlloc; + /* + long2para((LONG) sizeof(psp)); ?? see above + image_size += sizeof(psp) -- 1999/04/21 ska */ + if (exe_size > asize) + { + DosMemFree(env); + return DE_NOMEM; + } + exe_size = (LONG) long2para(image_size) + header.exMaxAlloc; + /* + long2para((LONG) sizeof(psp)); ?? -- 1999/04/21 ska */ + if (exe_size > asize) + exe_size = asize; + } + + /* Allocate our memory and pass back any errors */ + /* We can still get an error on first fit if the above */ + /* returned size was a bet fit case */ + if ((rc = DosMemAlloc((seg) exe_size, FIRST_FIT, (seg FAR *) & mem + ,(UWORD FAR *) & asize)) < 0) + { + if (rc == DE_NOMEM) + { + if ((rc = DosMemAlloc(0, LARGEST, (seg FAR *) & mem + ,(UWORD FAR *) & asize)) < 0) + { + DosMemFree(env); + return rc; + } + /* This should never happen, but ... */ + if (asize < exe_size) + { + DosMemFree(mem); + DosMemFree(env); + return rc; + } + } + else + { + DosMemFree(env); + return rc; + } + } + else + /* with no error, we got exactly what we asked for */ + asize = exe_size; + if (mode != OVERLAY) + { + /* memory found large enough - continue processing */ + mp = MK_FP(mem, 0); + ++mem; + } + else + mem = exp->load.load_seg; + + /* create the start seg for later computations */ + if (mode == OVERLAY) + start_seg = mem; + else + { + start_seg = mem + long2para((LONG) sizeof(psp)); + } + + /* Now load the executable */ + /* If file not found - error */ + /* NOTE - this is fatal because we lost it in transit */ + /* from DosExec! */ + if ((rc = DosOpen(namep, 0)) < 0) + { + fatal("(DosExeLoader) exe file lost in transit"); + } + /* offset to start of image */ + if (doslseek(rc, image_offset, 0) != image_offset) + { + if (mode != OVERLAY) + { + DosMemFree(--mem); + DosMemFree(env); + } + return DE_INVLDDATA; + } + + /* read in the image in 32K chunks */ + if (mode != OVERLAY) + { + exe_size = image_size - long2para((LONG) sizeof(psp)); + } + else + exe_size = image_size; + + if (exe_size > 0) + { + sp = MK_FP(start_seg, 0x0); + + if (mode != OVERLAY) + { + if ((header.exMinAlloc == 0) && (header.exMaxAlloc == 0)) + { + sp = MK_FP(start_seg + mp->m_size + - (image_size + 15) / 16, 0); + } + } + + do + { + nBytesRead = DosRead((COUNT) rc, (COUNT) (exe_size < CHUNK ? exe_size : CHUNK), (VOID FAR *) sp, &err); + sp = add_far((VOID FAR *) sp, (ULONG) nBytesRead); + exe_size -= nBytesRead; + } + while (nBytesRead && exe_size > 0); + } + + /* relocate the image for new segment */ + doslseek(rc, (LONG) header.exRelocTable, 0); + for (i = 0; i < header.exRelocItems; i++) + { + if (DosRead(rc, sizeof(reloc), (VOID FAR *) & reloc[0], &err) != sizeof(reloc)) + { + return DE_INVLDDATA; + } + if (mode == OVERLAY) + { + spot = MK_FP(reloc[1] + mem, reloc[0]); + *spot += exp->load.reloc; + } + else + { + /* spot = MK_FP(reloc[1] + mem + 0x10, reloc[0]); */ + spot = MK_FP(reloc[1] + start_seg, reloc[0]); + *spot += start_seg; + } + } + + /* and finally close the file */ + DosClose(rc); + + /* exit here for overlay */ + if (mode == OVERLAY) + return SUCCESS; + + /* point to the PSP so we can build it */ + p = MK_FP(mem, 0); + setvec(0x22, (VOID(INRPT FAR *) (VOID)) MK_FP(user_r->CS, user_r->IP)); + new_psp(p, mem + asize); + + patchPSP(mem - 1, env, exp->exec.cmd_line, namep); + + /* build the user area on the stack */ + irp = MK_FP(header.exInitSS + start_seg, + ((header.exInitSP - sizeof(iregs)) & 0xffff)); + + /* start allocating REGs */ + /* Note: must match es & ds memory segment */ + irp->ES = irp->DS = mem; + irp->CS = header.exInitCS + start_seg; + irp->IP = header.exInitIP; + irp->AX = 0xffff; /* for now, until fcb code is in */ + irp->BX = + irp->CX = + irp->DX = + irp->SI = + irp->DI = + irp->BP = 0; + irp->FLAGS = 0x200; + + /* Transfer control to the executable */ + p->ps_parent = cu_psp; + p->ps_prevpsp = (BYTE FAR *) MK_FP(cu_psp, 0); + q->ps_stack = (BYTE FAR *) user_r; + user_r->FLAGS &= ~FLG_CARRY; + + switch (mode) + { + case LOADNGO: + cu_psp = mem; + dta = p->ps_dta; + if (InDOS) + --InDOS; + exec_user(irp); + /* We should never be here */ + fatal("KERNEL RETURNED!!!"); + break; + + case LOAD: + cu_psp = mem; + exp->exec.stack = (BYTE FAR *) irp; + exp->exec.start_addr = MK_FP(irp->CS, irp->IP); + return SUCCESS; + } + return DE_INVLDFMT; +} + +/* mode = LOAD or EXECUTE + ep = EXE block + lp = filename to load (string) + + leb = local copy of exe block + */ +COUNT DosExec(COUNT mode, exec_blk FAR * ep, BYTE FAR * lp) +{ + COUNT rc, + err; + exec_blk leb = *ep; + BYTE FAR *cp; + BOOL bIsCom = FALSE; + + /* If file not found - free ram and return error */ + + if (cu_psp == DOS_PSP) + InitPSP(); + + if ((rc = DosOpen(lp, 0)) < 0) + { + return DE_FILENOTFND; + } + + if (DosRead(rc, sizeof(exe_header), (VOID FAR *) & header, &err) + != sizeof(exe_header)) + { + bIsCom = TRUE; + } + DosClose(rc); + + if (bIsCom || header.exSignature != MAGIC) + { + rc = DosComLoader(lp, &leb, mode); + } + else + { + rc = DosExeLoader(lp, &leb, mode); + } + if (mode == LOAD && rc == SUCCESS) + *ep = leb; + + return rc; +} + +COUNT FAR init_call_DosExec(COUNT mode, exec_blk FAR * ep, BYTE FAR * lp) +{ + return DosExec(mode, ep, lp); +} + +VOID InitPSP(VOID) +{ + psp FAR *p = MK_FP(DOS_PSP, 0); + new_psp(p, 0); +} + +/* process 0 */ +VOID FAR p_0(VOID) +{ + exec_blk exb; + CommandTail Cmd; + BYTE FAR *szfInitialPrgm = (BYTE FAR *) Config.cfgInit; + int rc; +/* init a fake psp file at seg 50:0000 */ + psp FAR *p = MK_FP(cu_psp, 0); + new_psp(p, 0); + + /* Execute command.com /P from the drive we just booted from */ + exb.exec.env_seg = master_env; + strcpy(Cmd.ctBuffer, Config.cfgInitTail); + + for (Cmd.ctCount = 0; Cmd.ctCount < 127; Cmd.ctCount++) + if (Cmd.ctBuffer[Cmd.ctCount] == '\r') + break; + + exb.exec.cmd_line = (CommandTail FAR *) & Cmd; + exb.exec.fcb_1 = exb.exec.fcb_2 = (fcb FAR *) 0; +#ifdef DEBUG + printf("Process 0 starting: %s\n\n", (BYTE *) szfInitialPrgm); +#endif + if ((rc = DosExec(0, (exec_blk FAR *) & exb, szfInitialPrgm)) != SUCCESS) + printf("\nBad or missing Command Interpreter: %d\n", rc); + else + printf("\nSystem shutdown complete\nReboot now.\n"); + for (;;) ; +} + diff --git a/lib/libm.mak b/lib/libm.mak new file mode 100644 index 00000000..b043ed75 --- /dev/null +++ b/lib/libm.mak @@ -0,0 +1,41 @@ +# +# makefile for libm.lib +# +# $Id$ +# + +# $Log$ +# Revision 1.1 2000/05/06 19:35:36 jhall1 +# Initial revision +# +# Revision 1.6 1999/09/14 17:32:20 jprice +# no message +# +# Revision 1.5 1999/09/13 20:13:15 jprice +# Added !if so we can use TC2 or TC3 to compile. +# +# Revision 1.4 1999/08/25 03:19:22 jprice +# ror4 patches to allow TC 2.01 compile. +# +# Revision 1.3 1999/04/23 03:45:18 jprice +# Improved by jprice +# + +!include "..\config.mak" + + +libm.lib: $(CLIB) +# use these for Turbo 2 + $(LIBUTIL) $(CLIB) *LDIV *LLSH *LURSH *LXMUL *LRSH *SPUSH *SCOPY + $(LIBUTIL) libm +LDIV +LLSH +LURSH +LXMUL +LRSH +SPUSH +SCOPY +# use these for Turbo 3 or better +# $(LIBUTIL) $(CLIB) *H_LDIV *H_LLSH *H_LURSH *N_LXMUL *F_LXMUL *H_LRSH *H_SPUSH *N_SCOPY +# $(LIBUTIL) libm +H_LDIV +H_LLSH +H_LURSH +N_LXMUL +F_LXMUL +H_LRSH +H_SPUSH +N_SCOPY + del *.OBJ + + +clobber: clean + $(RM) libm.lib status.me + +clean: + $(RM) *.obj *.bak diff --git a/readme.txt b/readme.txt new file mode 100644 index 00000000..2be5bebe --- /dev/null +++ b/readme.txt @@ -0,0 +1,36 @@ +INTRODUCTION +------------ +This archive contains FreeDOS Kernel version 1.1.18, build 2018, also +known as DOS-C, originally written by Pasquale J. Villani. + +The FreeDOS Kernel is available by anonymous ftp at +ftp://ftp.gcfl.net/freedos/kernel. It's also available from +http://www.dosemu.org (somewhere on there). + +The FreeDOS Kernel is also available through the FreeDOS project. An +ftp site is available for downloading Free-DOS at +ftp://metalab.unc.edu/pub/micro/pc-stuff/freedos. + +See the DOCS directory for more documentation and information about +the FreeDOS Kernel. + + +AGREEMENT +--------- +All users of the FreeDOS kernel must accept the disclaimer of +warranty and license terms contained in the file "COPYING" in order +to use it. You may not, under any circumstance, use this operating +system or any component without first reading and agreeing to the +terms of the license. + +BUG REPORTS +----------- +If you have found a bug, think you have found a bug, or would just +like to make a suggestion, go to the bug tracking web page at +http://www.gcfl.net/bugs/kernel or send email to +kernel-bugs@gcfl.net. + +Copyright +--------- +DOS-C is (c) Copyright 1995, 1996 by Pasquale J. Villani +All Rights Reserved. diff --git a/sys/bin2c.c b/sys/bin2c.c new file mode 100644 index 00000000..f53b3a74 --- /dev/null +++ b/sys/bin2c.c @@ -0,0 +1,51 @@ +#include + +int main(int argc, char **argv) +{ + FILE *in, *out; + int col; + int c; + + if (argc < 4) + { + fprintf(stderr, "Usage: bin2c \n"); + return 1; + } + + if ((in = fopen(argv[1], "rb")) == NULL) + { + fprintf(stderr, "Cannot open input file (%s).\n", argv[1]); + return 1; + } + + if ((out = fopen(argv[2], "wt")) == NULL) + { + fprintf(stderr, "Cannot open output file (%s).\n", argv[2]); + return 1; + } + + col = 0; + + fprintf(out, "unsigned char %s[] = {\n ", argv[3]); + + while ((c = fgetc(in)) != EOF) + { + if (col) + { + fprintf(out, ", "); + } + if (col >= 8) + { + fprintf(out, "\n "); + col = 0; + } + fprintf(out, "0x%02X", c); + col++; + } + + fprintf(out, "\n};\n"); + fclose(in); + fclose(out); + + return 0; +} diff --git a/sys/bin2c.mak b/sys/bin2c.mak new file mode 100644 index 00000000..aba8f415 --- /dev/null +++ b/sys/bin2c.mak @@ -0,0 +1,55 @@ +# +# makefile for bin2c.com +# +# $Id$ +# + +# $Log$ +# Revision 1.1 2000/05/06 19:35:36 jhall1 +# Initial revision +# +# Revision 1.6 1999/09/20 18:34:40 jprice +# *** empty log message *** +# +# Revision 1.5 1999/08/25 03:19:51 jprice +# ror4 patches to allow TC 2.01 compile. +# +# Revision 1.4 1999/05/03 05:01:38 jprice +# no message +# +# Revision 1.3 1999/04/23 03:45:33 jprice +# Improved by jprice +# + +!include "..\config.mak" + +CFLAGS = -mt -1- -v -vi- -k- -f- -ff- -O -Z -d -I$(INCLUDEPATH) -L$(LIBPATH) + +# *Implicit Rules* +.c.obj: + $(CC) $(CFLAGS) -c $< + +.cpp.obj: + $(CC) $(CFLAGS) -c $< + +# *List Macros* + +EXE_dependencies = \ + bin2c.obj + +# *Explicit Rules* +production: bin2c.com + +bin2c.com: $(EXE_dependencies) + $(LINK) /m/t/c $(LIBPATH)\c0t.obj+bin2c.obj,bin2c,,\ + $(LIBS)+$(CLIB); + + +clobber: clean + $(RM) bin2c.com + +clean: + ..\utils\rm -f *.obj *.bak *.crf *.xrf *.map *.lst *.las status.me + +# *Individual File Dependencies* +bin2c.obj: bin2c.c diff --git a/sys/sys.c b/sys/sys.c new file mode 100644 index 00000000..fa0900c3 --- /dev/null +++ b/sys/sys.c @@ -0,0 +1,666 @@ +/*************************************************************** + + sys.c + DOS-C + + sys utility for DOS-C + + Copyright (c) 1991 + Pasquale J. Villani + All Rights Reserved + + This file is part of DOS-C. + + DOS-C is free software; you can redistribute it and/or modify it under the + terms of the GNU General Public License as published by the Free Software + Foundation; either version 2, or (at your option) any later version. + + DOS-C is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + details. + + You should have received a copy of the GNU General Public License along with + DOS-C; see the file COPYING. If not, write to the Free Software Foundation, + 675 Mass Ave, Cambridge, MA 02139, USA. + +***************************************************************/ + +/* $Log$ + * Revision 1.1 2000/05/06 19:35:37 jhall1 + * Initial revision + * +/* Revision 1.9 1999/09/20 18:34:40 jprice +/* *** empty log message *** +/* +/* Revision 1.8 1999/09/20 18:27:19 jprice +/* Changed open/creat to fopen to make TC2 happy. +/* +/* Revision 1.7 1999/09/15 05:39:02 jprice +/* Changed boot sector writing code so easier to read. +/* +/* Revision 1.6 1999/09/14 17:30:44 jprice +/* Added debug log creation to sys.com. +/* +/* Revision 1.5 1999/08/25 03:19:51 jprice +/* ror4 patches to allow TC 2.01 compile. +/* +/* Revision 1.4 1999/04/17 19:14:44 jprice +/* Fixed multi-sector code +/* +/* Revision 1.3 1999/04/01 07:24:05 jprice +/* SYS modified for new boot loader +/* +/* Revision 1.2 1999/03/29 16:24:48 jprice +/* Fixed error message +/* +/* Revision 1.1.1.1 1999/03/29 15:43:15 jprice +/* New version without IPL.SYS +/* Revision 1.3 1999/01/21 04:35:21 jprice Fixed comments. + Added indent program + +Revision 1.2 1999/01/21 04:13:52 jprice Added messages to sys. Also made + it create a .COM file. + +*/ + +#define STORE_BOOT_INFO + +#include +#include +#include +/*#include */ +#include +#include +#include +#include +#include "portab.h" +#include "device.h" + +#include "b_fat12.h" +#include "b_fat16.h" + +BYTE *pgm = "sys"; + +BOOL fl_reset(WORD); +COUNT fl_rd_status(WORD); +COUNT fl_read(WORD, WORD, WORD, WORD, WORD, BYTE FAR *); +COUNT fl_write(WORD, WORD, WORD, WORD, WORD, BYTE FAR *); +BOOL fl_verify(WORD, WORD, WORD, WORD, WORD, BYTE FAR *); +BOOL fl_format(WORD, BYTE FAR *); +VOID get_boot(COUNT); +VOID put_boot(COUNT); +BOOL check_space(COUNT, BYTE *); +COUNT ltop(WORD *, WORD *, WORD *, COUNT, COUNT, LONG, byteptr); +BOOL copy(COUNT, BYTE *); +BOOL DiskReset(COUNT); +COUNT DiskRead(WORD, WORD, WORD, WORD, WORD, BYTE FAR *); +COUNT DiskWrite(WORD, WORD, WORD, WORD, WORD, BYTE FAR *); + +/* special word packing prototypes */ + +#ifdef NATIVE +#define getlong(vp, lp) (*(LONG *)(lp)=*(LONG *)(vp)) +#define getword(vp, wp) (*(WORD *)(wp)=*(WORD *)(vp)) +#define getbyte(vp, bp) (*(BYTE *)(bp)=*(BYTE *)(vp)) +#define fgetlong(vp, lp) (*(LONG FAR *)(lp)=*(LONG FAR *)(vp)) +#define fgetword(vp, wp) (*(WORD FAR *)(wp)=*(WORD FAR *)(vp)) +#define fgetbyte(vp, bp) (*(BYTE FAR *)(bp)=*(BYTE FAR *)(vp)) +#define fputlong(lp, vp) (*(LONG FAR *)(vp)=*(LONG FAR *)(lp)) +#define fputword(wp, vp) (*(WORD FAR *)(vp)=*(WORD FAR *)(wp)) +#define fputbyte(bp, vp) (*(BYTE FAR *)(vp)=*(BYTE FAR *)(bp)) +#else +VOID getword(VOID *, WORD *); +VOID getbyte(VOID *, BYTE *); +VOID fgetlong(VOID FAR *, LONG FAR *); +VOID fgetword(VOID FAR *, WORD FAR *); +VOID fgetbyte(VOID FAR *, BYTE FAR *); +VOID fputlong(LONG FAR *, VOID FAR *); +VOID fputword(WORD FAR *, VOID FAR *); +VOID fputbyte(BYTE FAR *, VOID FAR *); +#endif + +#define SEC_SIZE 512 +#define NDEV 4 +#define COPY_SIZE 32768 +#define NRETRY 5 + +static struct media_info +{ + ULONG mi_size; /* physical sector size */ + UWORD mi_heads; /* number of heads (sides) */ + UWORD mi_cyls; /* number of cyl/drive */ + UWORD mi_sectors; /* number of sectors/cyl */ + ULONG mi_offset; /* relative partition offset */ +}; + +union +{ + BYTE bytes[2 * SEC_SIZE]; + boot boot_sector; +} + + buffer; + +static struct media_info miarray[NDEV] = +{ + {720l, 2, 40, 9, 0l}, + {720l, 2, 40, 9, 0l}, + {720l, 2, 40, 9, 0l}, + {720l, 2, 40, 9, 0l} +}; + +#define PARTOFF 0x1be +#define N_PART 4 + +static struct +{ + BYTE peBootable; + BYTE peBeginHead; + BYTE peBeginSector; + UWORD peBeginCylinder; + BYTE peFileSystem; + BYTE peEndHead; + BYTE peEndSector; + UWORD peEndCylinder; + LONG peStartSector; + LONG peSectors; +} partition[N_PART]; + +struct bootsectortype +{ + UBYTE bsJump[3]; + char OemName[8]; + UWORD bsBytesPerSec; + UBYTE bsSecPerClust; + UWORD bsResSectors; + UBYTE bsFATs; + UWORD bsRootDirEnts; + UWORD bsSectors; + UBYTE bsMedia; + UWORD bsFATsecs; + UWORD bsSecPerTrack; + UWORD bsHeads; + ULONG bsHiddenSecs; + ULONG bsHugeSectors; + UBYTE bsDriveNumber; + UBYTE bsReserved1; + UBYTE bsBootSignature; + ULONG bsVolumeID; + char bsVolumeLabel[11]; + char bsFileSysType[8]; + char unused[2]; + UWORD sysRootDirSecs; /* of sectors root dir uses */ + ULONG sysFatStart; /* first FAT sector */ + ULONG sysRootDirStart; /* first root directory sector */ + ULONG sysDataStart; /* first data sector */ +}; + + +static int DrvMap[4] = +{0, 1, 0x80, 0x81}; + +COUNT drive, active; +UBYTE newboot[SEC_SIZE], oldboot[SEC_SIZE]; + +#ifdef DEBUG +FILE *log; +#endif + +#define SBSIZE 51 +#define SBOFFSET 11 + +#define SIZEOF_PARTENT 16 + +#define FAT12 0x01 +#define FAT16SMALL 0x04 +#define EXTENDED 0x05 +#define FAT16LARGE 0x06 + +#define N_RETRY 5 + +COUNT get_part(COUNT drive, COUNT idx) +{ + REG retry = N_RETRY; + REG BYTE *p = (BYTE *) & buffer.bytes[PARTOFF + (idx * SIZEOF_PARTENT)]; + REG ret; + BYTE packed_byte, pb1; + + do + { + ret = fl_read((WORD) DrvMap[drive], (WORD) 0, (WORD) 0, (WORD) 1, (WORD) 1, (byteptr) & buffer); + } + while (ret != 0 && --retry > 0); + if (ret != 0) + return FALSE; + getbyte((VOID *) p, &partition[idx].peBootable); + ++p; + getbyte((VOID *) p, &partition[idx].peBeginHead); + ++p; + getbyte((VOID *) p, &packed_byte); + partition[idx].peBeginSector = packed_byte & 0x3f; + ++p; + getbyte((VOID *) p, &pb1); + ++p; + partition[idx].peBeginCylinder = pb1 + ((0xc0 & packed_byte) << 2); + getbyte((VOID *) p, &partition[idx].peFileSystem); + ++p; + getbyte((VOID *) p, &partition[idx].peEndHead); + ++p; + getbyte((VOID *) p, &packed_byte); + partition[idx].peEndSector = packed_byte & 0x3f; + ++p; + getbyte((VOID *) p, &pb1); + ++p; + partition[idx].peEndCylinder = pb1 + ((0xc0 & packed_byte) << 2); + getlong((VOID *) p, &partition[idx].peStartSector); + p += sizeof(LONG); + getlong((VOID *) p, &partition[idx].peSectors); + return TRUE; +} + +VOID main(COUNT argc, char **argv) +{ + if (argc != 2) + { + fprintf(stderr, "Usage: %s drive\n drive = A,B,etc.\n", pgm); + exit(1); + } + + drive = *argv[1] - (islower(*argv[1]) ? 'a' : 'A'); + if (drive < 0 || drive >= NDEV) + { + fprintf(stderr, "%s: drive out of range\n", pgm); + exit(1); + } + + if (!DiskReset(drive)) + { + fprintf(stderr, "%s: cannot reset drive %c:", + drive, 'A' + drive); + exit(1); + } + + get_boot(drive); + + if (!check_space(drive, oldboot)) + { + fprintf(stderr, "%s: Not enough space to transfer system files\n", pgm); + exit(1); + } + +#ifdef DEBUG + if ((log = fopen("sys.log", "w")) == NULL) + { + printf("Can't write log file.\n"); + log = NULL; + } +#endif + + printf("Writing boot sector...\n"); + put_boot(drive); + + printf("\nCopying KERNEL.SYS..."); + if (!copy(drive, "kernel.sys")) + { + fprintf(stderr, "\n%s: cannot copy \"KERNEL.SYS\"\n", pgm); +#ifdef DEBUG + fclose(log); +#endif + exit(1); + } + + printf("\nCopying COMMAND.COM..."); + if (!copy(drive, "command.com")) + { + fprintf(stderr, "\n%s: cannot copy \"COMMAND.COM\"\n", pgm); +#ifdef DEBUG + fclose(log); +#endif + exit(1); + } + printf("\nSystem transfered.\n"); +#ifdef DEBUG + fclose(log); +#endif + exit(0); +} + +#ifdef DEBUG +VOID dump_sector(unsigned char far * sec) +{ + if (log) + { + COUNT x, y; + char c; + + for (x = 0; x < 32; x++) + { + fprintf(log, "%03X ", x * 16); + for (y = 0; y < 16; y++) + { + fprintf(log, "%02X ", sec[x * 16 + y]); + } + for (y = 0; y < 16; y++) + { + c = oldboot[x * 16 + y]; + if (isprint(c)) + fprintf(log, "%c", c); + else + fprintf(log, "."); + } + fprintf(log, "\n"); + } + fprintf(log, "\n"); + } +} + +#endif + + +VOID put_boot(COUNT drive) +{ + COUNT i, z; + WORD head, track, sector, ret; + WORD count; + ULONG temp; + struct bootsectortype *bs; + + if (drive >= 2) + { + head = partition[active].peBeginHead; + sector = partition[active].peBeginSector; + track = partition[active].peBeginCylinder; + } + else + { + head = 0; + sector = 1; + track = 0; + } + + /* Read current boot sector */ + if ((i = DiskRead(DrvMap[drive], head, track, sector, 1, (BYTE far *) oldboot)) != 0) + { + fprintf(stderr, "%s: disk read error (code = 0x%02x)\n", pgm, i & 0xff); + exit(1); + } + +#ifdef DEBUG + fprintf(log, "Old Boot Sector:\n"); + dump_sector(oldboot); +#endif + + bs = (struct bootsectortype *) & oldboot; + if ((bs->bsFileSysType[4] == '6') && (bs->bsBootSignature == 0x29)) + { + memcpy(newboot, b_fat16, SEC_SIZE); /* copy FAT16 boot sector */ + printf("FAT type: FAT16\n"); +#ifdef DEBUG + fprintf(log, "FAT type: FAT16\n"); +#endif + } + else + { + memcpy(newboot, b_fat12, SEC_SIZE); /* copy FAT12 boot sector */ + printf("FAT type: FAT12\n"); +#ifdef DEBUG + fprintf(log, "FAT type: FAT12\n"); +#endif + } + + /* Copy disk parameter from old sector to new sector */ + memcpy(&newboot[SBOFFSET], &oldboot[SBOFFSET], SBSIZE); + + bs = (struct bootsectortype *) & newboot; + /* root directory sectors */ +#ifdef STORE_BOOT_INFO + bs->sysRootDirSecs = bs->bsRootDirEnts / 16; +#endif +#ifdef DEBUG + fprintf(log, "root dir entries = %u\n", bs->bsRootDirEnts); + fprintf(log, "root dir sectors = %u\n", bs->sysRootDirSecs); +#endif + + /* sector FAT starts on */ + temp = bs->bsHiddenSecs + bs->bsResSectors; +#ifdef STORE_BOOT_INFO + bs->sysFatStart = temp; +#endif +#ifdef DEBUG + fprintf(log, "FAT starts at sector %lu = (%lu + %u)\n", temp, + bs->bsHiddenSecs, bs->bsResSectors); +#endif + + /* sector root directory starts on */ + temp = temp + bs->bsFATsecs * bs->bsFATs; +#ifdef STORE_BOOT_INFO + bs->sysRootDirStart = temp; +#endif +#ifdef DEBUG + fprintf(log, "Root directory starts at sector %lu = (PREVIOUS + %u * %u)\n", + temp, bs->bsFATsecs, bs->bsFATs); +#endif + + /* sector data starts on */ + temp = temp + bs->sysRootDirSecs; +#ifdef STORE_BOOT_INFO + bs->sysDataStart = temp; +#endif +#ifdef DEBUG + fprintf(log, "DATA starts at sector %lu = (PREVIOUS + %u)\n", temp, + bs->sysRootDirSecs); +#endif + + +#ifdef DEBUG + fprintf(log, "\nNew Boot Sector:\n"); + dump_sector(newboot); +#endif + + if ((i = DiskWrite(DrvMap[drive], head, track, sector, 1, (BYTE far *) newboot)) != 0) + { + fprintf(stderr, "%s: disk write error (code = 0x%02x)\n", pgm, i & 0xff); + exit(1); + } +} + +VOID get_boot(COUNT drive) +{ + COUNT i; + COUNT ifd; + WORD head, track, sector, ret; + WORD count; + + if (drive >= 2) + { + head = partition[active].peBeginHead; + sector = partition[active].peBeginSector; + track = partition[active].peBeginCylinder; + } + else + { + head = 0; + sector = 1; + track = 0; + } + + if ((i = DiskRead(DrvMap[drive], head, track, sector, 1, (BYTE far *) oldboot)) != 0) + { + fprintf(stderr, "%s: disk read error (code = 0x%02x)\n", pgm, i & 0xff); + exit(1); + } +} + +BOOL check_space(COUNT drive, BYTE * BlkBuffer) +{ + BYTE *bpbp; + BYTE nfat; + UWORD nfsect; + ULONG hidden; + ULONG count; + ULONG block; + UBYTE nreserved; + UCOUNT i; + WORD track, head, sector; + UBYTE buffer[SEC_SIZE]; + ULONG bpb_huge; + UWORD bpb_nsize; + + /* get local information */ + getbyte((VOID *) & BlkBuffer[BT_BPB + BPB_NFAT], &nfat); + getword((VOID *) & BlkBuffer[BT_BPB + BPB_NFSECT], &nfsect); + getlong((VOID *) & BlkBuffer[BT_BPB + BPB_HIDDEN], &hidden); + getbyte((VOID *) & BlkBuffer[BT_BPB + BPB_NRESERVED], &nreserved); + + getlong((VOID *) & BlkBuffer[BT_BPB + BPB_HUGE], &bpb_huge); + getword((VOID *) & BlkBuffer[BT_BPB + BPB_NSIZE], &bpb_nsize); + + count = miarray[drive].mi_size = bpb_nsize == 0 ? + bpb_huge : bpb_nsize; + + /* Fix media information for disk */ + getword((&(((BYTE *) & BlkBuffer[BT_BPB])[BPB_NHEADS])), &miarray[drive].mi_heads); + head = miarray[drive].mi_heads; + getword((&(((BYTE *) & BlkBuffer[BT_BPB])[BPB_NSECS])), &miarray[drive].mi_sectors); + if (miarray[drive].mi_size == 0) + getlong(&((((BYTE *) & BlkBuffer[BT_BPB])[BPB_HUGE])), &miarray[drive].mi_size); + sector = miarray[drive].mi_sectors; + if (head == 0 || sector == 0) + { + fprintf(stderr, "Drive initialization failure.\n"); + exit(1); + } + miarray[drive].mi_cyls = count / (head * sector); + + return 1; +} + +/* */ +/* Do logical block number to physical head/track/sector mapping */ +/* */ +static COUNT ltop(trackp, sectorp, headp, unit, count, strt_sect, strt_addr) +WORD *trackp, *sectorp, *headp; +REG COUNT unit; +LONG strt_sect; +COUNT count; +byteptr strt_addr; +{ +#ifdef I86 + ULONG ltemp; +#endif + REG ls, ps; + +#ifdef I86 + /* Adjust for segmented architecture */ + ltemp = (((ULONG) mk_segment(strt_addr) << 4) + mk_offset(strt_addr)) & 0xffff; + /* Test for 64K boundary crossing and return count large */ + /* enough not to exceed the threshold. */ + count = (((ltemp + SEC_SIZE * count) & 0xffff0000l) != 0l) + ? (0xffffl - ltemp) / SEC_SIZE + : count; +#endif + + *trackp = strt_sect / (miarray[unit].mi_heads * miarray[unit].mi_sectors); + *sectorp = strt_sect % miarray[unit].mi_sectors + 1; + *headp = (strt_sect % (miarray[unit].mi_sectors * miarray[unit].mi_heads)) + / miarray[unit].mi_sectors; + if (((ls = *headp * miarray[unit].mi_sectors + *sectorp - 1) + count) > + (ps = miarray[unit].mi_heads * miarray[unit].mi_sectors)) + count = ps - ls; + return count; +} + +BOOL copy(COUNT drive, BYTE * file) +{ + BYTE dest[64]; + COUNT ifd, ofd, ret; + FILE *s, *d; + BYTE buffer[COPY_SIZE]; + struct ftime ftime; + + sprintf(dest, "%c:\\%s", 'A' + drive, file); + if ((s = fopen(file, "rb")) == NULL) + { + fprintf(stderr, "%s: \"%s\" not found\n", pgm, file); + return FALSE; + } + _fmode = O_BINARY; + if ((d = fopen(dest, "wb")) == NULL) + { + fclose(s); + fprintf(stderr, "%s: can't create\"%s\"\n", pgm, dest); + return FALSE; + } + + while ((ret = fread(buffer, 1, COPY_SIZE, s)) != 0) + fwrite(buffer, 1, ret, d); + + getftime(fileno(s), &ftime); + setftime(fileno(d), &ftime); + + fclose(s); + fclose(d); + + return TRUE; +} + +BOOL DiskReset(COUNT Drive) +{ + REG COUNT idx; + + /* Reset the drives */ + fl_reset(DrvMap[drive]); + + if (Drive >= 2 && Drive < NDEV) + { + COUNT RetCode; + + /* Retrieve all the partition information */ + for (RetCode = TRUE, idx = 0; RetCode && (idx < N_PART); idx++) + RetCode = get_part(Drive, idx); + if (!RetCode) + return FALSE; + + /* Search for the first DOS partition and start */ + /* building the map for the hard drive */ + for (idx = 0; idx < N_PART; idx++) + { + if (partition[idx].peFileSystem == FAT12 + || partition[idx].peFileSystem == FAT16SMALL + || partition[idx].peFileSystem == FAT16LARGE) + { + miarray[Drive].mi_offset + = partition[idx].peStartSector; + active = idx; + break; + } + } + } + + return TRUE; +} + +COUNT DiskRead(WORD drive, WORD head, WORD track, WORD sector, WORD count, BYTE FAR * buffer) +{ + int nRetriesLeft; + + for (nRetriesLeft = NRETRY; nRetriesLeft > 0; --nRetriesLeft) + { + if (fl_read(drive, head, track, sector, count, buffer) == count) + return count; + } + return 0; +} + +COUNT DiskWrite(WORD drive, WORD head, WORD track, WORD sector, WORD count, BYTE FAR * buffer) +{ + int nRetriesLeft; + + for (nRetriesLeft = NRETRY; nRetriesLeft > 0; --nRetriesLeft) + { + if (fl_write(drive, head, track, sector, count, buffer) == count) + return count; + } + return 0; +} diff --git a/sys/sys.mak b/sys/sys.mak new file mode 100644 index 00000000..1ebe5751 --- /dev/null +++ b/sys/sys.mak @@ -0,0 +1,73 @@ +# +# makefile for sys.com +# +# $Id$ +# + +# $Log$ +# Revision 1.1 2000/05/06 19:35:37 jhall1 +# Initial revision +# +# Revision 1.10 1999/09/23 04:41:43 jprice +# *** empty log message *** +# +# Revision 1.9 1999/09/14 17:30:44 jprice +# Added debug log creation to sys.com. +# +# Revision 1.8 1999/08/25 03:19:51 jprice +# ror4 patches to allow TC 2.01 compile. +# +# Revision 1.7 1999/05/03 05:01:54 jprice +# no message +# +# Revision 1.6 1999/04/23 03:45:33 jprice +# Improved by jprice +# + + +!include "..\config.mak" + +#CFLAGS = -mt -1- -v -vi- -k- -f- -ff- -O -Z -d -I$(INCLUDEPATH);..\hdr \ +# -L$(LIBPATH) -DI86;PROTO;DEBUG +CFLAGS = -mt -1- -v -vi- -k- -f- -ff- -O -Z -d -I$(INCLUDEPATH);..\hdr \ + -L$(LIBPATH) -DI86;PROTO + +# *Implicit Rules* +.c.obj: + $(CC) $(CFLAGS) -c $< + +.cpp.obj: + $(CC) $(CFLAGS) -c $< + +# *List Macros* + +LIBS = ..\lib\device.lib + +EXE_dependencies = \ + sys.obj \ + $(LIBS) + +# *Explicit Rules* +production: ..\bin\sys.com + +..\bin\sys.com: sys.com + copy sys.com ..\bin + +b_fat12.h: ..\boot\b_fat12.bin bin2c.com + bin2c ..\boot\b_fat12.bin b_fat12.h b_fat12 + +b_fat16.h: ..\boot\b_fat16.bin bin2c.com + bin2c ..\boot\b_fat16.bin b_fat16.h b_fat16 + +sys.com: $(EXE_dependencies) + $(LINK) /m/t/c $(LIBPATH)\c0t.obj+sys.obj,sys,,\ + $(LIBS)+$(CLIB); + +clobber: clean + $(RM) sys.com b_fat12.h b_fat16.h + +clean: + $(RM) *.obj *.bak *.crf *.xrf *.map *.lst *.las status.me + +# *Individual File Dependencies* +sys.obj: sys.c ..\hdr\portab.h ..\hdr\device.h b_fat12.h b_fat16.h diff --git a/utils/indent.ini b/utils/indent.ini new file mode 100644 index 00000000..3f253c22 --- /dev/null +++ b/utils/indent.ini @@ -0,0 +1,17 @@ +-kr +-di2 +-nbc +-nfca +-bl +-bli0 +-ss +-npcs +-ncs +-nbs +-i2 +-ci4 +-nce +-sob +-ts80 +-nbad +-cli2 diff --git a/utils/proto.bat b/utils/proto.bat new file mode 100644 index 00000000..472b76f1 --- /dev/null +++ b/utils/proto.bat @@ -0,0 +1,2 @@ +for %%f in ( %1 %2 %3 %4 %5 %6 %7 %8 %9 ) do mkptypes %%f >>proto.h + From 8a8df7fba8029ed8addb1a8230ec74ed861a7aee Mon Sep 17 00:00:00 2001 From: Jim Hall Date: Mon, 8 May 2000 03:49:18 +0000 Subject: [PATCH 002/671] updated the README to include correct URLs for SourceForge and the FreeDOS Project, and the bug tracking database. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@6 6ac86273-5f31-0410-b378-82cca8765d1b --- readme.txt | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/readme.txt b/readme.txt index 2be5bebe..42bde4ae 100644 --- a/readme.txt +++ b/readme.txt @@ -3,13 +3,11 @@ INTRODUCTION This archive contains FreeDOS Kernel version 1.1.18, build 2018, also known as DOS-C, originally written by Pasquale J. Villani. -The FreeDOS Kernel is available by anonymous ftp at -ftp://ftp.gcfl.net/freedos/kernel. It's also available from -http://www.dosemu.org (somewhere on there). +The FreeDOS Kernel is available from http://freedos.sourceforge.net. +It's also available from http://www.dosemu.org (somewhere on there). -The FreeDOS Kernel is also available through the FreeDOS project. An -ftp site is available for downloading Free-DOS at -ftp://metalab.unc.edu/pub/micro/pc-stuff/freedos. +The FreeDOS Kernel is also available through the FreeDOS Project at +http://www.freedos.org. See the DOCS directory for more documentation and information about the FreeDOS Kernel. @@ -27,8 +25,7 @@ BUG REPORTS ----------- If you have found a bug, think you have found a bug, or would just like to make a suggestion, go to the bug tracking web page at -http://www.gcfl.net/bugs/kernel or send email to -kernel-bugs@gcfl.net. +http://www.freedos.org/bugs/ Copyright --------- From b857858f48e109c826fd48476296f881b4248f39 Mon Sep 17 00:00:00 2001 From: Jim Tabor Date: Mon, 8 May 2000 04:30:00 +0000 Subject: [PATCH 003/671] Update CVS to 2020 git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@7 6ac86273-5f31-0410-b378-82cca8765d1b --- docs/build.txt | 4 +- docs/contrib.txt | 1 + docs/copying | 10 +- docs/history.txt | 68 ++++ docs/intfns.txt | 25 +- hdr/cds.h | 4 +- hdr/clock.h | 4 +- hdr/date.h | 4 +- hdr/dcb.h | 4 +- hdr/device.h | 38 +- hdr/dirmatch.h | 4 +- hdr/dosnames.h | 4 +- hdr/error.h | 4 +- hdr/exe.h | 4 +- hdr/fat.h | 4 +- hdr/fcb.h | 4 +- hdr/file.h | 4 +- hdr/fnode.h | 4 +- hdr/kbd.h | 4 +- hdr/mcb.h | 4 +- hdr/network.h | 1 + hdr/pcb.h | 4 +- hdr/portab.h | 4 +- hdr/process.h | 4 +- hdr/sft.h | 4 +- hdr/stacks.inc | 4 +- hdr/tail.h | 4 +- hdr/time.h | 4 +- hdr/version.h | 4 +- kernel/001-437.nls | 4 +- kernel/apisupt.asm | 4 +- kernel/asmsupt.asm | 4 +- kernel/blockio.c | 46 ++- kernel/break.c | 4 +- kernel/chario.c | 4 +- kernel/config.c | 55 ++- kernel/console.asm | 4 +- kernel/dosfns.c | 436 ++++++++++++++++------- kernel/dosidle.asm | 2 +- kernel/dosnames.c | 11 +- kernel/dsk.c | 39 ++- kernel/entry.asm | 11 +- kernel/error.c | 4 +- kernel/execrh.asm | 4 +- kernel/fatdir.c | 46 ++- kernel/fatfs.c | 95 +++-- kernel/fattab.c | 4 +- kernel/fcbfns.c | 60 +++- kernel/globals.h | 9 +- kernel/initoem.c | 4 +- kernel/int2f.asm | 16 +- kernel/inthndlr.c | 272 +++++++++----- kernel/io.asm | 4 +- kernel/io.inc | 4 +- kernel/ioctl.c | 61 ++-- kernel/irqstack.asm | 4 +- kernel/kernel.asm | 4 +- kernel/kernel.mak | 35 +- kernel/main.c | 23 +- kernel/memmgr.c | 4 +- kernel/misc.c | 4 +- kernel/network.c | 83 ++--- kernel/newstuff.c | 74 +++- kernel/nls.c | 838 +++++++++++++++----------------------------- kernel/nlssupt.asm | 16 +- kernel/prf.c | 4 +- kernel/printer.asm | 4 +- kernel/procsupt.asm | 4 +- kernel/proto.h | 55 +-- kernel/segs.inc | 4 +- kernel/serial.asm | 4 +- kernel/strings.c | 4 +- kernel/sysclk.c | 4 +- kernel/syspack.c | 4 +- kernel/systime.c | 4 +- kernel/task.c | 11 +- 76 files changed, 1490 insertions(+), 1139 deletions(-) diff --git a/docs/build.txt b/docs/build.txt index 837b534a..45c20513 100644 --- a/docs/build.txt +++ b/docs/build.txt @@ -67,8 +67,8 @@ component. Study the makefile to better understand this. $Id$ $Log$ -Revision 1.1 2000/05/06 19:34:38 jhall1 -Initial revision +Revision 1.2 2000/05/08 04:27:48 jimtabor +Update CVS to 2020 Revision 1.2 1999/08/25 04:12:31 jprice update diff --git a/docs/contrib.txt b/docs/contrib.txt index fa35655e..7244a993 100644 --- a/docs/contrib.txt +++ b/docs/contrib.txt @@ -11,6 +11,7 @@ John Price (linux-guru@gcfl.net) Steve Miller (SMiller@dsfx.com) Jens Horstmeier (Jens.Horstmeier@Abg1.SIEMENS.DE) James Tabor (jimtabor@infohwy.com) +Eric Biederman (ebiederm+eric@ccr.net) And last, but not least, a big thanx to Pasquale J. Villani (patv@iop.com), who was the original author of DOS-C, in which the diff --git a/docs/copying b/docs/copying index b8cf3a1a..a43ea212 100644 --- a/docs/copying +++ b/docs/copying @@ -55,7 +55,7 @@ patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. - + GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION @@ -110,7 +110,7 @@ above, provided that you also meet all of these conditions: License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) - + These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in @@ -168,7 +168,7 @@ access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. - + 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is @@ -225,7 +225,7 @@ impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. - + 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License @@ -278,7 +278,7 @@ PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS - + Appendix: How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest diff --git a/docs/history.txt b/docs/history.txt index ab82ce1f..88df13ed 100644 --- a/docs/history.txt +++ b/docs/history.txt @@ -1,3 +1,71 @@ +2000 Apr 28 - Build 2020 +-------- James Tabor (jimtabor@infohwy.com) ++ Added Dos Function calls 0x69, and 0x6C. IOCTL support in disk driver. + New funtions not yet fully implemented. + Clean up DSK.C, IOCTL.C and FCBFNS.C. Removed old blk_device + pointers. + +2000 Apr 03 - Build 2020 +-------- James Tabor (jimtabor@infohwy.com) ++ Fixed All DPB chains were linking to -1. + +2000 Apr 02 - Build 2020 +-------- James Tabor (jimtabor@infohwy.com) ++ Fixed Dos_Free returned wrong due to MaxCluster Calc. + Media_Check MaxCluster count wrong, needed +1. + +2000 Apr 01 - Build 2020 +-------- James Tabor (jimtabor@infohwy.com) ++ fixed Unable to cd back out of cdrom directories. + +2000 Mar 31 - Build 2019 +-------- James Tabor (jimtabor@infohwy.com) ++ added Eric W. Biederman patches via CVS. + ++ 2000 Mar 25 ++ -------- Eric Biederman ++ Fixed Lastdrive handling ++ Fixed Not enough drives for number present devices ++ Added Working (though not perfect network redirector) + Note: Error codes internal to freedos are negative + Error codes external to freedos are postive. + The network redirector is external to freedos... + Note: Running the nonredirected functions on a redirected + drive is dangerous. My patch is very careful + not to. Except in truename. Where (a) it is safe + and (b) I think it is required, and (c) it is needed + by dosemu. + +2000 Mar 19 - Build 2019 +-------- James Tabor (jimtabor@infohwy.com) +* Jean-Francois email noting + the set/clear interrupt was reverse in order. + +2000 Mar 17 - Build 2019 +-------- Steffen Kaiser (Steffen.Kaiser@fh-rhein-sieg.de) ++ Fixed Config.c COUNTRY= statement ++ Fixed *.c to call upFMem() when upcasing filenames +- Removed everything to load NLS into memory += Redesigned hardcoded NLS information + +--> The kernel will now return the proper information for the + hardcoded NLS (U.S.A. / CP437), it would return the correct + information for other NLS, too, if there would be a NLSFUNC + available, which is not at this time. + +NOTE: The way the external NLSFUNC is called does not look well, +therfore expect a change soon. + +2000 Mar 15 - Build 2019 +-------- James Tabor (jimtabor@infohwy.com) +* Dennis Newbold and Massimo De Munari email kernel bug reports + with changes to Globals.h and Inthndlr.c. Fix to leap year and + Delete file return code. +* Michal Meller found a bug in media_check. It return the wrong + value of sector count. Change in FATFS.C. +* Fixed Func 0x32 based on information from Marty . + Func 0x32 Get Drive Parameter BLK did not work. + 2000 Mar 09 - Build 2018 -------- James Tabor (jimtabor@infohwy.com) Added CDS and made FD CDS based. Changes encompass all of the diff --git a/docs/intfns.txt b/docs/intfns.txt index 579e3f32..de04dc0e 100644 --- a/docs/intfns.txt +++ b/docs/intfns.txt @@ -44,7 +44,7 @@ int 21 Description State Ver Status 1ch Get Drive Data superseded 2.00 supported 1dh CP/M compatibility obsolete 1.00 supported 1eh CP/M compatibility obsolete 1.00 supported -1fh Get Default DPB active 5.00 Note 2 +1fh Get Default DPB active 5.00 supported 20h CP/M compatibility obsolete 1.00 supported 21h Random Read superseded 1.00 supported 22h Random Write superseded 1.00 supported @@ -63,7 +63,7 @@ int 21 Description State Ver Status 2fh Get DTA active 2.00 supported 30h Get Version Number active 2.00 supported 31h Keep Program active 2.00 supported -32h Get DPB active 5.00 Note 2 +32h Get DPB active 5.00 supported 3300h Get CTRL+C Check Flag active 2.00 supported 3301h Set CTRL+C Check Flag active 2.00 supported 3305h Get Startup Drive active 2.00 supported @@ -118,19 +118,19 @@ int 21 Description State Ver Status 5ah Create Temporary File active 3.00 5bh Create New File active 3.00 5ch Lock/Unlock File active 3.10 planned -5d00h Server Function Call active 3.10 planned +5d00h Server Function Call active 3.10 supported 5d01h Commit All Files active 3.10 planned 5d02h Close File by Name active 3.10 planned 5d03h Close All Files for Computer active 3.10 planned 5d04h Close All Files for Process active 3.10 planned 5d05h Get Open File List active 3.10 planned 5d06h Get Multiple SDA active 4.00 supported -5d07h Get Redirected Printer Mode active 3.10 planned -5d08h Set Redirected Printer Mode active 4.00 planned -5d09h Flush Redirected Printer Output active 4.00 planned +5d07h Get Redirected Printer Mode active 3.10 supported +5d08h Set Redirected Printer Mode active 4.00 supported +5d09h Flush Redirected Printer Output active 4.00 supported 5d0ah Set Extended Error active 4.00 planned -5eh Generic Network Functions #1 active 3.10 planned -5fh Generic Network Functions #2 active 3.10 planned +5eh Generic Network Functions #1 active 3.10 supported +5fh Generic Network Functions #2 active 3.10 supported 60h Truename function undocumented 3.00 supported 61h UNUSED obsolete supported 62h Get current PSP active 3.00 supported @@ -165,7 +165,7 @@ int 27: TSR Supported. int 28: DOS Idle. - Note 5. + Supported. int 29: Fast Console Output. Supported. @@ -195,8 +195,11 @@ See COPYING in DOS-C root directory for license. $Id$ $Log$ -Revision 1.1 2000/05/06 19:34:43 jhall1 -Initial revision +Revision 1.2 2000/05/08 04:27:48 jimtabor +Update CVS to 2020 + +Revision 1.2 2000/03/18 05:51:55 kernel +changes in supported functions Revision 1.1 1999/08/25 03:46:42 jprice New build config diff --git a/hdr/cds.h b/hdr/cds.h index bc4abbfe..449a594a 100644 --- a/hdr/cds.h +++ b/hdr/cds.h @@ -34,8 +34,8 @@ static BYTE *Cds_hRcsId = "$Id$"; /* * $Log$ - * Revision 1.1 2000/05/06 19:34:47 jhall1 - * Initial revision + * Revision 1.2 2000/05/08 04:28:22 jimtabor + * Update CVS to 2020 * * Revision 1.2 2000/03/09 06:06:38 kernel * 2017f updates by James Tabor diff --git a/hdr/clock.h b/hdr/clock.h index 9fbff301..e6a14c57 100644 --- a/hdr/clock.h +++ b/hdr/clock.h @@ -38,8 +38,8 @@ static BYTE *clock_hRcsId = "$Id$"; /* * $Log$ - * Revision 1.1 2000/05/06 19:34:47 jhall1 - * Initial revision + * Revision 1.2 2000/05/08 04:28:22 jimtabor + * Update CVS to 2020 * * Revision 1.1.1.1 1999/03/29 15:39:22 jprice * New version without IPL.SYS diff --git a/hdr/date.h b/hdr/date.h index affc58b6..f252e77c 100644 --- a/hdr/date.h +++ b/hdr/date.h @@ -38,8 +38,8 @@ static BYTE *date_hRcsId = "$Id$"; /* * $Log$ - * Revision 1.1 2000/05/06 19:34:47 jhall1 - * Initial revision + * Revision 1.2 2000/05/08 04:28:22 jimtabor + * Update CVS to 2020 * * Revision 1.2 1999/08/25 03:17:11 jprice * ror4 patches to allow TC 2.01 compile. diff --git a/hdr/dcb.h b/hdr/dcb.h index 35c8e5cd..79bb5794 100644 --- a/hdr/dcb.h +++ b/hdr/dcb.h @@ -36,8 +36,8 @@ static BYTE *clock_hRcsId = "$Id$"; /* * $Log$ - * Revision 1.1 2000/05/06 19:34:47 jhall1 - * Initial revision + * Revision 1.2 2000/05/08 04:28:22 jimtabor + * Update CVS to 2020 * * Revision 1.3 2000/03/09 06:06:38 kernel * 2017f updates by James Tabor diff --git a/hdr/device.h b/hdr/device.h index daecb335..d2f8fc5f 100644 --- a/hdr/device.h +++ b/hdr/device.h @@ -35,8 +35,11 @@ static BYTE *device_hRcsId = "$Id$"; /* * $Log$ - * Revision 1.1 2000/05/06 19:34:46 jhall1 - * Initial revision + * Revision 1.2 2000/05/08 04:28:22 jimtabor + * Update CVS to 2020 + * + * Revision 1.4 2000/04/29 05:13:16 jtabor + * Added new functions and clean up code * * Revision 1.3 2000/03/09 06:06:38 kernel * 2017f updates by James Tabor @@ -244,6 +247,17 @@ typedef struct } bpb; +struct gblkio +{ + UBYTE gbio_spcfunbit; + UBYTE gbio_devtype; + UWORD gbio_devattrib; + UWORD gbio_ncyl; + UBYTE gbio_media; + bpb gbio_bpb; + UWORD gbio_nsecs; +}; + /* */ /* Boot Block (Super Block) */ /* */ @@ -256,13 +270,19 @@ bpb; typedef struct { - BYTE bt_jump[3]; /* Boot Jump opcodes */ - BYTE bt_oem[8]; /* OEM Name */ - bpb bt_bpb; /* BPB for this media/device */ - WORD bt_nsecs; /* # Sectors per Track */ - WORD bt_nheads; /* # Heads */ - WORD bt_hidden; /* # Hidden sectors */ - LONG bt_huge; /* use if nsecs == 0 */ + BYTE bt_jump[3]; /* Boot Jump opcodes */ + BYTE bt_oem[8]; /* OEM Name */ + bpb bt_bpb; /* BPB for this media/device */ + WORD bt_nsecs; /* # Sectors per Track */ + WORD bt_nheads; /* # Heads */ + WORD bt_hidden; /* # Hidden sectors */ + LONG bt_huge; /* use if nsecs == 0 */ + BYTE bt_drvno; + BYTE bt_reserv; + BYTE bt_btid; + ULONG bt_serialno; + BYTE bt_volume[11]; + BYTE bt_fstype[8]; } boot; diff --git a/hdr/dirmatch.h b/hdr/dirmatch.h index dcf14e32..1a751293 100644 --- a/hdr/dirmatch.h +++ b/hdr/dirmatch.h @@ -36,8 +36,8 @@ static BYTE *dirmatch_hRcsId = "$Id$"; /* * $Log$ - * Revision 1.1 2000/05/06 19:34:47 jhall1 - * Initial revision + * Revision 1.2 2000/05/08 04:28:22 jimtabor + * Update CVS to 2020 * * Revision 1.3 2000/03/09 06:06:38 kernel * 2017f updates by James Tabor diff --git a/hdr/dosnames.h b/hdr/dosnames.h index e9410601..56daa7f9 100644 --- a/hdr/dosnames.h +++ b/hdr/dosnames.h @@ -36,8 +36,8 @@ static BYTE *dosnames_hRcsId = "$Id$"; /* * $Log$ - * Revision 1.1 2000/05/06 19:34:47 jhall1 - * Initial revision + * Revision 1.2 2000/05/08 04:28:22 jimtabor + * Update CVS to 2020 * * Revision 1.1.1.1 1999/03/29 15:39:27 jprice * New version without IPL.SYS diff --git a/hdr/error.h b/hdr/error.h index 36325849..2a9e420d 100644 --- a/hdr/error.h +++ b/hdr/error.h @@ -36,8 +36,8 @@ static BYTE *error_hRcsId = "$Id$"; /* * $Log$ - * Revision 1.1 2000/05/06 19:34:47 jhall1 - * Initial revision + * Revision 1.2 2000/05/08 04:28:22 jimtabor + * Update CVS to 2020 * * Revision 1.1.1.1 1999/03/29 15:39:27 jprice * New version without IPL.SYS diff --git a/hdr/exe.h b/hdr/exe.h index 653a5960..627a660a 100644 --- a/hdr/exe.h +++ b/hdr/exe.h @@ -36,8 +36,8 @@ static BYTE *exe_hRcsId = "$Id$"; /* * $Log$ - * Revision 1.1 2000/05/06 19:34:47 jhall1 - * Initial revision + * Revision 1.2 2000/05/08 04:28:22 jimtabor + * Update CVS to 2020 * * Revision 1.1.1.1 1999/03/29 15:39:28 jprice * New version without IPL.SYS diff --git a/hdr/fat.h b/hdr/fat.h index 55dfaf63..38b79042 100644 --- a/hdr/fat.h +++ b/hdr/fat.h @@ -36,8 +36,8 @@ static BYTE *fat_hRcsId = "$Id$"; /* * $Log$ - * Revision 1.1 2000/05/06 19:34:48 jhall1 - * Initial revision + * Revision 1.2 2000/05/08 04:28:22 jimtabor + * Update CVS to 2020 * * Revision 1.2 1999/05/03 06:28:00 jprice * Changed some variables from signed to unsigned. diff --git a/hdr/fcb.h b/hdr/fcb.h index 810e137f..016f3a70 100644 --- a/hdr/fcb.h +++ b/hdr/fcb.h @@ -36,8 +36,8 @@ static BYTE *fcb_hRcsId = "$Id$"; /* * $Log$ - * Revision 1.1 2000/05/06 19:34:48 jhall1 - * Initial revision + * Revision 1.2 2000/05/08 04:28:22 jimtabor + * Update CVS to 2020 * * Revision 1.2 1999/09/20 21:24:54 jprice * *** empty log message *** diff --git a/hdr/file.h b/hdr/file.h index 75990ff4..17776635 100644 --- a/hdr/file.h +++ b/hdr/file.h @@ -36,8 +36,8 @@ static BYTE *file_hRcsId = "$Id$"; /* * $Log$ - * Revision 1.1 2000/05/06 19:34:48 jhall1 - * Initial revision + * Revision 1.2 2000/05/08 04:28:22 jimtabor + * Update CVS to 2020 * * Revision 1.1.1.1 1999/03/29 15:39:30 jprice * New version without IPL.SYS diff --git a/hdr/fnode.h b/hdr/fnode.h index d9415a64..a1209dc6 100644 --- a/hdr/fnode.h +++ b/hdr/fnode.h @@ -36,8 +36,8 @@ static BYTE *fnode_hRcsId = "$Id$"; /* * $Log$ - * Revision 1.1 2000/05/06 19:34:48 jhall1 - * Initial revision + * Revision 1.2 2000/05/08 04:28:22 jimtabor + * Update CVS to 2020 * * Revision 1.3 2000/03/09 06:06:38 kernel * 2017f updates by James Tabor diff --git a/hdr/kbd.h b/hdr/kbd.h index adac73df..8887375e 100644 --- a/hdr/kbd.h +++ b/hdr/kbd.h @@ -36,8 +36,8 @@ static BYTE *kbd_hRcsId = "$Id$"; /* * $Log$ - * Revision 1.1 2000/05/06 19:34:48 jhall1 - * Initial revision + * Revision 1.2 2000/05/08 04:28:22 jimtabor + * Update CVS to 2020 * * Revision 1.1.1.1 1999/03/29 15:39:31 jprice * New version without IPL.SYS diff --git a/hdr/mcb.h b/hdr/mcb.h index 9a428f6d..f5ca2e29 100644 --- a/hdr/mcb.h +++ b/hdr/mcb.h @@ -36,8 +36,8 @@ static BYTE *mcb_hRcsId = "$Id$"; /* * $Log$ - * Revision 1.1 2000/05/06 19:34:48 jhall1 - * Initial revision + * Revision 1.2 2000/05/08 04:28:22 jimtabor + * Update CVS to 2020 * * Revision 1.2 2000/03/09 06:06:38 kernel * 2017f updates by James Tabor diff --git a/hdr/network.h b/hdr/network.h index 137e62c6..a9fddd8d 100644 --- a/hdr/network.h +++ b/hdr/network.h @@ -54,6 +54,7 @@ #define REM_PRINTSET 0x111f #define REM_FLUSHALL 0x1120 #define REM_LSEEK 0x1121 +#define REM_PROCESS_END 0x1122 #define REM_FILENAME 0x1123 #define REM_PRINTREDIR 0x1125 #define REM_EXTOC 0x112e diff --git a/hdr/pcb.h b/hdr/pcb.h index f8fd97d3..e51aa055 100644 --- a/hdr/pcb.h +++ b/hdr/pcb.h @@ -36,8 +36,8 @@ static BYTE *pcb_hRcsId = "$Id$"; /* * $Log$ - * Revision 1.1 2000/05/06 19:34:49 jhall1 - * Initial revision + * Revision 1.2 2000/05/08 04:28:22 jimtabor + * Update CVS to 2020 * * Revision 1.1.1.1 1999/03/29 15:39:32 jprice * New version without IPL.SYS diff --git a/hdr/portab.h b/hdr/portab.h index f51b82c0..0db73d9d 100644 --- a/hdr/portab.h +++ b/hdr/portab.h @@ -36,8 +36,8 @@ static char *portab_hRcsId = "$Id$"; /* * $Log$ - * Revision 1.1 2000/05/06 19:34:49 jhall1 - * Initial revision + * Revision 1.2 2000/05/08 04:28:22 jimtabor + * Update CVS to 2020 * * Revision 1.2 1999/08/25 03:17:11 jprice * ror4 patches to allow TC 2.01 compile. diff --git a/hdr/process.h b/hdr/process.h index 830c4cb4..da9ae0cd 100644 --- a/hdr/process.h +++ b/hdr/process.h @@ -36,8 +36,8 @@ static BYTE *process_hRcsId = "$Id$"; /* * $Log$ - * Revision 1.1 2000/05/06 19:34:49 jhall1 - * Initial revision + * Revision 1.2 2000/05/08 04:28:22 jimtabor + * Update CVS to 2020 * * Revision 1.1.1.1 1999/03/29 15:39:34 jprice * New version without IPL.SYS diff --git a/hdr/sft.h b/hdr/sft.h index 7314e305..c4940742 100644 --- a/hdr/sft.h +++ b/hdr/sft.h @@ -35,8 +35,8 @@ static BYTE *sft_hRcsId = "$Id$"; /* * $Log$ - * Revision 1.1 2000/05/06 19:34:50 jhall1 - * Initial revision + * Revision 1.2 2000/05/08 04:28:22 jimtabor + * Update CVS to 2020 * * Revision 1.3 2000/03/09 06:06:38 kernel * 2017f updates by James Tabor diff --git a/hdr/stacks.inc b/hdr/stacks.inc index 25503f71..363eb241 100644 --- a/hdr/stacks.inc +++ b/hdr/stacks.inc @@ -30,8 +30,8 @@ ; $Id$ ; ; $Log$ -; Revision 1.1 2000/05/06 19:34:50 jhall1 -; Initial revision +; Revision 1.2 2000/05/08 04:28:22 jimtabor +; Update CVS to 2020 ; ; Revision 1.3 2000/03/09 06:06:38 kernel ; 2017f updates by James Tabor diff --git a/hdr/tail.h b/hdr/tail.h index 7e507777..b865f233 100644 --- a/hdr/tail.h +++ b/hdr/tail.h @@ -36,8 +36,8 @@ static BYTE *tail_hRcsId = "$Id$"; /* * $Log$ - * Revision 1.1 2000/05/06 19:34:50 jhall1 - * Initial revision + * Revision 1.2 2000/05/08 04:28:22 jimtabor + * Update CVS to 2020 * * Revision 1.1.1.1 1999/03/29 15:39:36 jprice * New version without IPL.SYS diff --git a/hdr/time.h b/hdr/time.h index b945a37c..ccb201cb 100644 --- a/hdr/time.h +++ b/hdr/time.h @@ -40,8 +40,8 @@ static BYTE *time_hRcsId = "$Id$"; /* * $Log$ - * Revision 1.1 2000/05/06 19:34:50 jhall1 - * Initial revision + * Revision 1.2 2000/05/08 04:28:22 jimtabor + * Update CVS to 2020 * * Revision 1.2 1999/08/25 03:17:11 jprice * ror4 patches to allow TC 2.01 compile. diff --git a/hdr/version.h b/hdr/version.h index f3033073..132ad8f2 100644 --- a/hdr/version.h +++ b/hdr/version.h @@ -42,5 +42,5 @@ static BYTE *date_hRcsId = "$Id$"; #define REVISION_MAJOR 1 #define REVISION_MINOR 1 -#define REVISION_SEQ 18 -#define BUILD 2018 +#define REVISION_SEQ 20 +#define BUILD 2020 diff --git a/kernel/001-437.nls b/kernel/001-437.nls index 780c9c53..417d05d8 100644 --- a/kernel/001-437.nls +++ b/kernel/001-437.nls @@ -39,8 +39,8 @@ static BYTE *RcsId = "$Header$"; /* * $Log$ - * Revision 1.1 2000/05/06 19:34:52 jhall1 - * Initial revision + * Revision 1.2 2000/05/08 04:29:59 jimtabor + * Update CVS to 2020 * * Revision 1.2 2000/03/09 06:07:10 kernel * 2017f updates by James Tabor diff --git a/kernel/apisupt.asm b/kernel/apisupt.asm index efbd2b00..3089911f 100644 --- a/kernel/apisupt.asm +++ b/kernel/apisupt.asm @@ -27,8 +27,8 @@ ; $Id$ ; ; $Log$ -; Revision 1.1 2000/05/06 19:34:52 jhall1 -; Initial revision +; Revision 1.2 2000/05/08 04:29:59 jimtabor +; Update CVS to 2020 ; ; Revision 1.2 1999/08/10 17:57:12 jprice ; ror4 2011-02 patch diff --git a/kernel/asmsupt.asm b/kernel/asmsupt.asm index 32194d77..5230ed7b 100644 --- a/kernel/asmsupt.asm +++ b/kernel/asmsupt.asm @@ -27,8 +27,8 @@ ; $Id$ ; ; $Log$ -; Revision 1.1 2000/05/06 19:34:52 jhall1 -; Initial revision +; Revision 1.2 2000/05/08 04:29:59 jimtabor +; Update CVS to 2020 ; ; Revision 1.3 1999/08/10 17:57:12 jprice ; ror4 2011-02 patch diff --git a/kernel/blockio.c b/kernel/blockio.c index b5eb8747..e3e0020d 100644 --- a/kernel/blockio.c +++ b/kernel/blockio.c @@ -37,8 +37,11 @@ static BYTE *blockioRcsId = "$Id$"; /* * $Log$ - * Revision 1.1 2000/05/06 19:34:53 jhall1 - * Initial revision + * Revision 1.2 2000/05/08 04:29:59 jimtabor + * Update CVS to 2020 + * + * Revision 1.15 2000/04/29 05:13:16 jtabor + * Added new functions and clean up code * * Revision 1.14 2000/03/09 06:07:10 kernel * 2017f updates by James Tabor @@ -157,7 +160,7 @@ VOID FAR init_buffers(void) lastbuf = &buffers[Config.cfgBuffers - 1]; } -/* Extract the block number from a buffer structure. */ +/* Extract the block number from a buffer structure. */ ULONG getblkno(struct buffer FAR * bp) { if (bp->b_blkno == 0xffffu) @@ -166,8 +169,8 @@ ULONG getblkno(struct buffer FAR * bp) return bp->b_blkno; } -/* Set the block number of a buffer structure. (The caller should */ -/* set the unit number before calling this function.) */ +/* Set the block number of a buffer structure. (The caller should */ +/* set the unit number before calling this function.) */ VOID setblkno(struct buffer FAR * bp, ULONG blkno) { if (blkno >= 0xffffu) @@ -178,7 +181,10 @@ VOID setblkno(struct buffer FAR * bp, ULONG blkno) else { bp->b_blkno = blkno; - bp->b_dpbp = &blk_devices[bp->b_unit]; +/* bp->b_dpbp = &blk_devices[bp->b_unit]; */ + + bp->b_dpbp = CDSp->cds_table[bp->b_unit].cdsDpb; + } } @@ -242,9 +248,9 @@ struct buffer FAR *getblock(ULONG blkno, COUNT dsk) #endif /* make sure we keep at least 3 buffers for the FAT. If this is not a */ - /* FAT buffer, or there are at least 3 already, then we can use this */ - /* buffer. */ - /* otherwise, search again, and find the last non-FAT buffer. */ + /* FAT buffer, or there are at least 3 already, then we can use this */ + /* buffer. */ + /* otherwise, search again, and find the last non-FAT buffer. */ if ((lbp->b_flag & BFR_FAT) && (fat_count < 3)) { bp = firstbuf; @@ -253,12 +259,12 @@ struct buffer FAR *getblock(ULONG blkno, COUNT dsk) while ((bp != NULL) && (bp->b_flag & BFR_FAT)) { /* if this is a FAT buffer, then move to the next one, else we found */ - /* the one we want. */ + /* the one we want. */ mbp = lbp; /* move along to next buffer */ lbp = bp; bp = bp->b_next; } - /* if we get to the end of the list here, then we must only have 3 */ + /* if we get to the end of the list here, then we must only have 3 */ /* buffers, which is not suppose to happen, but if it does, then we */ /* end up using the last buffer (even though it is FAT). */ @@ -357,9 +363,9 @@ BOOL getbuf(struct buffer FAR ** pbp, ULONG blkno, COUNT dsk) #endif /* make sure we keep at least 3 buffers for the FAT. If this is not a */ - /* FAT buffer, or there are at least 3 already, then we can use this */ - /* buffer. */ - /* otherwise, search again, and find the last non-FAT buffer. */ + /* FAT buffer, or there are at least 3 already, then we can use this */ + /* buffer. */ + /* otherwise, search again, and find the last non-FAT buffer. */ if ((lbp->b_flag & BFR_FAT) && (fat_count < 3)) { bp = firstbuf; @@ -368,14 +374,14 @@ BOOL getbuf(struct buffer FAR ** pbp, ULONG blkno, COUNT dsk) while ((bp != NULL) && (bp->b_flag & BFR_FAT)) { /* if this is a FAT buffer, then move to the next one, else we found */ - /* the one we want. */ + /* the one we want. */ mbp = lbp; /* move along to next buffer */ lbp = bp; bp = bp->b_next; } - /* if we get to the end of the list here, then we must only have 3 */ - /* buffers, which is not suppose to happen, but if it does, then we */ - /* end up using the last buffer (even though it is FAT). */ + /* if we get to the end of the list here, then we must only have 3 */ + /* buffers, which is not suppose to happen, but if it does, then we */ + /* end up using the last buffer (even though it is FAT). */ if (bp == NULL) { @@ -539,7 +545,9 @@ BOOL fill(REG struct buffer FAR * bp, ULONG blkno, COUNT dsk) /* */ BOOL dskxfer(COUNT dsk, ULONG blkno, VOID FAR * buf, UWORD numblocks, COUNT mode) { - REG struct dpb *dpbp = &blk_devices[dsk]; +/* REG struct dpb *dpbp = &blk_devices[dsk]; */ + + REG struct dpb *dpbp = CDSp->cds_table[dsk].cdsDpb; for (;;) { diff --git a/kernel/break.c b/kernel/break.c index fe84ebf9..671244da 100644 --- a/kernel/break.c +++ b/kernel/break.c @@ -38,8 +38,8 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ - * Revision 1.1 2000/05/06 19:34:54 jhall1 - * Initial revision + * Revision 1.2 2000/05/08 04:29:59 jimtabor + * Update CVS to 2020 * * Revision 1.2 2000/03/09 06:07:10 kernel * 2017f updates by James Tabor diff --git a/kernel/chario.c b/kernel/chario.c index 77b9e67e..b7b80796 100644 --- a/kernel/chario.c +++ b/kernel/chario.c @@ -36,8 +36,8 @@ static BYTE *charioRcsId = "$Id$"; /* * $Log$ - * Revision 1.1 2000/05/06 19:34:54 jhall1 - * Initial revision + * Revision 1.2 2000/05/08 04:29:59 jimtabor + * Update CVS to 2020 * * Revision 1.7 2000/03/09 06:07:10 kernel * 2017f updates by James Tabor diff --git a/kernel/config.c b/kernel/config.c index 338cca8f..3cb0ea65 100644 --- a/kernel/config.c +++ b/kernel/config.c @@ -31,6 +31,7 @@ #include "portab.h" #include "globals.h" +#include "nls.h" #ifdef VERSION_STRINGS static BYTE *RcsId = "$Id$"; @@ -38,8 +39,14 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ - * Revision 1.1 2000/05/06 19:34:56 jhall1 - * Initial revision + * Revision 1.2 2000/05/08 04:29:59 jimtabor + * Update CVS to 2020 + * + * Revision 1.15 2000/03/31 05:40:09 jtabor + * Added Eric W. Biederman Patches + * + * Revision 1.14 2000/03/17 22:59:04 kernel + * Steffen Kaiser's NLS changes * * Revision 1.13 2000/03/09 06:07:10 kernel * 2017f updates by James Tabor @@ -204,6 +211,10 @@ INIT void PreConfig(void) /* Initialize the base memory pointers */ lpOldLast = lpBase = AlignParagraph((BYTE FAR *) & last); +#ifdef DEBUG + printf("SDA located at 0x%04x:0x%04x\n", + FP_SEG(internal_data), FP_OFF(internal_data)); +#endif /* Begin by initializing our system buffers */ dma_scratch = (BYTE FAR *) KernelAllocDma(BUFFERSIZE); #ifdef DEBUG @@ -230,7 +241,7 @@ INIT void PreConfig(void) + Config.cfgFiles * sizeof(sft)); CDSp = (cdstbl FAR *) - KernelAlloc(0x58 * lastdrive + 1); + KernelAlloc(0x58 * (lastdrive + 1)); #ifdef DEBUG @@ -271,6 +282,11 @@ INIT void PostConfig(void) /* Set pass number */ nPass = 2; + /* compute lastdrive ... */ + lastdrive = Config.cfgLastdrive; + if (lastdrive < nblkdev -1) + lastdrive = nblkdev -1; + /* Initialize the base memory pointers from last time. */ lpBase = AlignParagraph(lpOldLast); @@ -300,7 +316,7 @@ INIT void PostConfig(void) + Config.cfgFiles * sizeof(sft)); CDSp = (cdstbl FAR *) - KernelAlloc(0x58 * lastdrive + 1); + KernelAlloc(0x58 * (lastdrive + 1)); #ifdef DEBUG @@ -334,6 +350,14 @@ INIT VOID configDone(VOID) { COUNT i; + if (lastdrive < nblkdev -1) { +#ifdef DEBUG + printf("lastdrive %c too small upping it to: %c\n", lastdrive + 'A', nblkdev + 'A' -1); +#endif /* DEBUG */ + lastdrive = nblkdev -1; + CDSp = (cdstbl FAR *) + KernelAlloc(0x58 * (lastdrive +1)); + } first_mcb = FP_SEG(lpBase) + ((FP_OFF(lpBase) + 0x0f) >> 4); /* We expect ram_top as Kbytes, so convert to paragraphs */ @@ -634,6 +658,22 @@ INIT static VOID Fcbs(BYTE * pLine) Config.cfgProtFcbs = Config.cfgFcbs; } +/* LoadCountryInfo(): + * Searches a file in the COUNTRY.SYS format for an entry + * matching the specified code page and country code, and loads + * the corresponding information into memory. If code page is 0, + * the default code page for the country will be used. + * + * Returns TRUE if successful, FALSE if not. + */ + +static INIT BOOL LoadCountryInfo(char *filename, UWORD ctryCode, UWORD codePage) +{ +/* printf("cntry: %u, CP%u, file=\"%s\"\n", ctryCode, codePage, filename); */ + printf("Sorry, the COUNTRY= statement has been temporarily disabled\n"); + return FALSE; +} + INIT static VOID Country(BYTE * pLine) { /* Format: COUNTRY = countryCode, [codePage], filename */ @@ -646,12 +686,11 @@ INIT static VOID Country(BYTE * pLine) pLine = skipwh(pLine); if (*pLine == ',') { - pLine = skipwh(pLine); + pLine = skipwh(pLine + 1); if (*pLine == ',') { - codePage = 0; - ++pLine; + codePage = NLS_DEFAULT; } else { @@ -761,7 +800,7 @@ INIT static VOID CfgFailure(BYTE * pLine) BYTE *pTmp = pLineStart; printf("CONFIG.SYS error in line %d\n", nCfgLine); - printf(">>>%s\n", pTmp); + printf(">>>%s\n ", pTmp); while (++pTmp != pLine) printf(" "); printf("^\n"); diff --git a/kernel/console.asm b/kernel/console.asm index 9dadbfb9..327fb04d 100644 --- a/kernel/console.asm +++ b/kernel/console.asm @@ -28,8 +28,8 @@ ; $Header$ ; ; $Log$ -; Revision 1.1 2000/05/06 19:34:56 jhall1 -; Initial revision +; Revision 1.2 2000/05/08 04:29:59 jimtabor +; Update CVS to 2020 ; ; Revision 1.8 2000/03/09 06:07:10 kernel ; 2017f updates by James Tabor diff --git a/kernel/dosfns.c b/kernel/dosfns.c index 536a0d63..08e3465a 100644 --- a/kernel/dosfns.c +++ b/kernel/dosfns.c @@ -34,8 +34,17 @@ static BYTE *dosfnsRcsId = "$Id$"; /* * $Log$ - * Revision 1.1 2000/05/06 19:34:59 jhall1 - * Initial revision + * Revision 1.2 2000/05/08 04:29:59 jimtabor + * Update CVS to 2020 + * + * Revision 1.14 2000/04/02 05:01:08 jtabor + * Replaced ChgDir Code + * + * Revision 1.13 2000/04/02 04:53:56 jtabor + * Fix to DosChgDir + * + * Revision 1.12 2000/03/31 05:40:09 jtabor + * Added Eric W. Biederman Patches * * Revision 1.11 2000/03/09 06:07:11 kernel * 2017f updates by James Tabor @@ -295,7 +304,7 @@ UCOUNT DosWrite(COUNT hndl, UCOUNT n, BYTE FAR * bp, COUNT FAR * err) sft FAR *s; WORD sys_idx; sfttbl FAR *sp; - UCOUNT ReadCount; + UCOUNT WriteCount; /* Test that the handle is valid */ if (hndl < 0) @@ -321,10 +330,10 @@ UCOUNT DosWrite(COUNT hndl, UCOUNT n, BYTE FAR * bp, COUNT FAR * err) } if (s->sft_flags & SFT_FSHARED) { - ReadCount = Remote_RW(REM_WRITE, n, bp, s, err); + WriteCount = Remote_RW(REM_WRITE, n, bp, s, err); if (err) { - return ReadCount; + return WriteCount; } else return 0; @@ -463,7 +472,7 @@ UCOUNT DosWrite(COUNT hndl, UCOUNT n, BYTE FAR * bp, COUNT FAR * err) { COUNT rc; - ReadCount = writeblock(s->sft_status, bp, n, &rc); + WriteCount = writeblock(s->sft_status, bp, n, &rc); if (rc < SUCCESS) { *err = rc; @@ -472,50 +481,34 @@ UCOUNT DosWrite(COUNT hndl, UCOUNT n, BYTE FAR * bp, COUNT FAR * err) else { *err = SUCCESS; - return ReadCount; + return WriteCount; } } *err = SUCCESS; return 0; } -COUNT DosSeek(COUNT hndl, LONG new_pos, COUNT mode, ULONG * set_pos) +COUNT SftSeek(sft FAR *s, LONG new_pos, COUNT mode) { - sft FAR *s; - ULONG lrx; - /* Test for invalid mode */ if (mode < 0 || mode > 2) return DE_INVLDFUNC; - /* Test that the handle is valid */ - if (hndl < 0) - return DE_INVLDHNDL; - - /* Get the SFT block that contains the SFT */ - if ((s = get_sft(hndl)) == (sft FAR *) - 1) - return DE_INVLDHNDL; - lpCurSft = (sfttbl FAR *) s; if (s->sft_flags & SFT_FSHARED) { - if (mode == 2) - { /* seek from end of file */ + if (mode == 2) { + /* seek from end of file */ int2f_Remote_call(REM_LSEEK, 0, (UWORD) FP_SEG(new_pos), (UWORD) FP_OFF(new_pos), (VOID FAR *) s, 0, 0); - *set_pos = s->sft_posit; return SUCCESS; } - if (mode == 0) - { + if (mode == 0) { s->sft_posit = new_pos; - *set_pos = new_pos; return SUCCESS; } - if (mode == 1) - { + if (mode == 1) { s->sft_posit += new_pos; - *set_pos = s->sft_posit; return SUCCESS; } return DE_INVLDFUNC; @@ -524,17 +517,39 @@ COUNT DosSeek(COUNT hndl, LONG new_pos, COUNT mode, ULONG * set_pos) /* Do special return for character devices */ if (s->sft_flags & SFT_FDEVICE) { - *set_pos = 0l; + s->sft_posit = 0l; return SUCCESS; } else { - *set_pos = dos_lseek(s->sft_status, new_pos, mode); - if ((LONG) * set_pos < 0) - return (int)*set_pos; - else + LONG result = dos_lseek(s->sft_status, new_pos, mode); + if (result < 0l) + return (int)result; + else { + s->sft_posit = result; return SUCCESS; } + } +} + +COUNT DosSeek(COUNT hndl, LONG new_pos, COUNT mode, ULONG * set_pos) +{ + sft FAR *s; + COUNT result; + + /* Test that the handle is valid */ + if (hndl < 0) + return DE_INVLDHNDL; + + /* Get the SFT block that contains the SFT */ + if ((s = get_sft(hndl)) == (sft FAR *) - 1) + return DE_INVLDHNDL; + + result = SftSeek(s, new_pos, mode); + if (result == SUCCESS) { + *set_pos = s->sft_posit; + } + return result; } static WORD get_free_hndl(void) @@ -613,12 +628,12 @@ static BOOL fnmatch(BYTE FAR * s, BYTE FAR * d, COUNT n, COUNT mode) COUNT DosCreat(BYTE FAR * fname, COUNT attrib) { psp FAR *p = MK_FP(cu_psp, 0); - WORD hndl, - sft_idx; + WORD hndl, sft_idx; sft FAR *sftp; struct dhdr FAR *dhp; BYTE FAR *froot; WORD i; + COUNT result, drive; /* get a free handle */ if ((hndl = get_free_hndl()) == 0xff) @@ -662,14 +677,26 @@ COUNT DosCreat(BYTE FAR * fname, COUNT attrib) } } - if (Remote_OCT(REM_CREATE, fname, attrib, sftp) == 0) - { - if (sftp->sft_flags & SFT_FSHARED) - { + drive = get_verify_drive(fname); + if(drive < 0) { + return drive; + } + + result = truename(fname, PriPathName, FALSE); + if (result != SUCCESS) { + return result; + } + + if (CDSp->cds_table[drive].cdsFlags & CDSNETWDRV) { + lpCurSft = (sfttbl FAR *)sftp; + result = int2f_Remote_call(REM_CREATE, 0, 0, 0, (VOID FAR *) sftp, 0, MK_FP(0, attrib)); + result = -result; + if (result == SUCCESS) { sftp->sft_count += 1; p->ps_filetab[hndl] = sft_idx; return hndl; } + return result; } sftp->sft_status = dos_creat(fname, attrib); @@ -775,6 +802,7 @@ COUNT DosOpen(BYTE FAR * fname, COUNT mode) struct dhdr FAR *dhp; BYTE FAR *froot; WORD i; + COUNT drive, result; /* test if mode is in range */ if ((mode & ~SFT_OMASK) != 0) @@ -828,16 +856,27 @@ COUNT DosOpen(BYTE FAR * fname, COUNT mode) } } - if (Remote_OCT(REM_OPEN, fname, mode, sftp) == 0) - { - if (sftp->sft_flags & SFT_FSHARED) - { + drive = get_verify_drive(fname); + if (drive < 0) { + return drive; + } + + result = truename(fname, PriPathName, FALSE); + if (result != SUCCESS) { + return result; + } + + if (CDSp->cds_table[drive].cdsFlags & CDSNETWDRV) { + lpCurSft = (sfttbl FAR *)sftp; + result = int2f_Remote_call(REM_OPEN, 0, 0, 0, (VOID FAR *) sftp, 0, MK_FP(0, mode)); + result = -result; + if (result == SUCCESS) { sftp->sft_count += 1; p->ps_filetab[hndl] = sft_idx; return hndl; } + return result; } - sftp->sft_status = dos_open(fname, mode); if (sftp->sft_status >= 0) @@ -918,27 +957,27 @@ VOID DosGetFree(COUNT drive, COUNT FAR * spc, COUNT FAR * navc, COUNT FAR * bps, { struct dpb *dpbp; struct cds FAR *cdsp; - static char rg[8]; + static COUNT rg[4]; /* next - "log" in the drive */ drive = (drive == 0 ? default_drive : drive - 1); - cdsp = &CDSp->cds_table[drive]; - if (cdsp->cdsFlags & 0x8000) + /* first check for valid drive */ + if (drive < 0 || drive > lastdrive) { - int2f_Remote_call(REM_GETSPACE, 0, 0, 0, cdsp, 0, &rg); - - *spc = (COUNT) rg[0]; - *navc = (COUNT) rg[2]; - *bps = (COUNT) rg[4]; - *nc = (COUNT) rg[6]; + *spc = -1; return; } - /* first check for valid drive */ - if (drive < 0 || drive > lastdrive) + cdsp = &CDSp->cds_table[drive]; + if (cdsp->cdsFlags & CDSNETWDRV) { - *spc = -1; + int2f_Remote_call(REM_GETSPACE, 0, 0, 0, cdsp, 0, &rg); + + *spc = (COUNT) rg[0]; + *nc = (COUNT) rg[1]; + *bps = (COUNT) rg[2]; + *navc = (COUNT) rg[3]; return; } @@ -968,82 +1007,86 @@ VOID DosGetFree(COUNT drive, COUNT FAR * spc, COUNT FAR * navc, COUNT FAR * bps, COUNT DosGetCuDir(COUNT drive, BYTE FAR * s) { REG struct cds FAR *cdsp; + REG WORD x; /* next - "log" in the drive */ drive = (drive == 0 ? default_drive : drive - 1); - cdsp = &CDSp->cds_table[drive]; + /* first check for valid drive */ + if (drive < 0 || drive > lastdrive) { + return DE_INVLDDRV; + } + cdsp = &CDSp->cds_table[drive]; current_ldt = cdsp; - if (cdsp->cdsFlags & 0x8000) - { - dos_pwd(cdsp, s); - return SUCCESS; + if (!(cdsp->cdsFlags & CDSNETWDRV) && (cdsp->cdsDpb == 0)) { + return DE_INVLDDRV; } - /* first check for valid drive */ - - if (cdsp->cdsDpb == 0) - return DE_INVLDDRV; + x = 1 + cdsp->cdsJoinOffset; + fsncopy((BYTE FAR *) & cdsp->cdsCurrentPath[x], s, 64); -/* if (drive < 0 || drive > nblkdev) - return DE_INVLDDRV; - */ - dos_pwd(cdsp, s); return SUCCESS; } +#undef CHDIR_DEBUG COUNT DosChangeDir(BYTE FAR * s) { - REG struct dpb *dpbp; REG struct cds FAR *cdsp; REG COUNT drive; - struct f_node FAR *fp; - COUNT ret; - /* Parse and extract drive */ - if (*(s + 1) == ':') - { - drive = *s - '@'; - if (drive > 26) - drive -= 'a' - 'A'; - } - else - drive = 0; + COUNT result; + BYTE FAR *p; - /* next - "log" in the drive */ - drive = (drive == 0 ? default_drive : drive - 1); + drive = get_verify_drive(s); + if (drive < 0 ) { + return drive; + } - cdsp = &CDSp->cds_table[drive]; + result = truename(s, PriPathName, FALSE); + if (result != SUCCESS) { + return result; + } + cdsp = &CDSp->cds_table[drive]; current_ldt = cdsp; - if (cdsp->cdsFlags & 0x8000) + if (cdsp->cdsFlags & CDSNETWDRV) { - ret = dos_cd(cdsp, s); - return ret; - } - - /* first check for valid drive */ - if (cdsp->cdsDpb == 0) - return DE_INVLDDRV; - - /* test for path existance from fs */ - if ((fp = dir_open((BYTE FAR *) s)) == (struct f_node FAR *)0) - return DE_PATHNOTFND; - else - dir_close(fp); - -/* if (drive < 0 || drive > nblkdev) - return DE_INVLDDRV; */ - - dpbp = (struct dpb *)cdsp->cdsDpb; - if ((media_check(dpbp) < 0)) - return DE_INVLDDRV; +#if defined(CHDIR_DEBUG) + printf("Remote Chdir: n='"); + p = s; while(*p) print("%c", *p++); + printf("' p='"); + p = PriPathName; while(*p) printf("%c", *p++); + printf("'\n"); +#endif + result = int2f_Remote_call(REM_CHDIR, 0, 0, 0, PriPathName, 0, 0); +#if defined(CHDIR_DEBUG) + printf("status = %04x, new_path='", result); + p = cdsd->cdsCurrentPath; while(p) printf("%c", *p++) + print("'\n"); +#endif + result = -result; + if (result != SUCCESS) { + return DE_PATHNOTFND; + } +/* + Some redirectors do not write back to the CDS. + SHSUCdX needs this. jt +*/ + fscopy(&PriPathName[0], cdsp->cdsCurrentPath); + if (PriPathName[7] == 0) + cdsp->cdsCurrentPath[8] = 0; /* Need two Zeros at the end */ + + } else { /* now get fs to change to new */ /* directory */ - ret = dos_cd(cdsp, s); - return ret; + result = dos_cd(cdsp, PriPathName); + } + if (result == SUCCESS) { + fscopy(&PriPathName[0], cdsp->cdsCurrentPath); + } + return result; } COUNT DosFindFirst(UCOUNT attr, BYTE FAR * name) @@ -1120,25 +1163,79 @@ COUNT DosSetFtime(COUNT hndl, date FAR * dp, time FAR * tp) COUNT DosGetFattr(BYTE FAR * name, UWORD FAR * attrp) { + static UWORD srfa[5]; + COUNT result, drive; + struct cds FAR *last_cds; + BYTE FAR * p; + +#if 0 + if (IsDevice(name)) { + return DE_PATHNOTFND; + } +#endif - if (Remote_GSattr(REM_GETATTRZ, name, attrp) == 0) - return SUCCESS; - - return dos_getfattr(name, attrp); - + drive = get_verify_drive(name); + if (drive < 0) { + return drive; + } + + result = truename(name, PriPathName, FALSE); + if (result != SUCCESS) { + return result; + } + + if (CDSp->cds_table[drive].cdsFlags & CDSNETWDRV) + { + last_cds = current_ldt; + current_ldt = &CDSp->cds_table[drive]; + result = int2f_Remote_call(REM_GETATTRZ, 0, 0, 0, 0, 0, (VOID FAR *) srfa); + result = -result; + current_ldt = last_cds; + *attrp = srfa[0]; + } + else { + result = dos_getfattr(name, attrp); + } } COUNT DosSetFattr(BYTE FAR * name, UWORD FAR * attrp) { - if (Remote_GSattr(REM_SETATTR, name, attrp) == 0) - return SUCCESS; - - return dos_setfattr(name, attrp); + COUNT result, drive; + struct cds FAR *last_cds; + BYTE FAR *p; + +#if 0 + if (IsDevice(name)) { + return DE_PATHNOTFND; + } +#endif + drive = get_verify_drive(name); + if (drive < 0) { + return drive; + } + + result = truename(name, PriPathName, FALSE); + if (result != SUCCESS) { + return result; + } + + if (CDSp->cds_table[drive].cdsFlags & CDSNETWDRV) + { + last_cds = current_ldt; + current_ldt = &CDSp->cds_table[drive]; + result = int2f_Remote_call(REM_SETATTR, 0, 0, 0, 0, 0, MK_FP(0, attrp)); + result = -result; + current_ldt = last_cds; + } + else { + result = dos_setfattr(name, attrp); + } + return result; } BYTE DosSelectDrv(BYTE drv) { - if (CDSp->cds_table[drv].cdsFlags & 0xf000) + if ((drv <= lastdrive) && (CDSp->cds_table[drv].cdsFlags & 0xf000)) { current_ldt = &CDSp->cds_table[drv]; default_drive = drv; @@ -1146,3 +1243,108 @@ BYTE DosSelectDrv(BYTE drv) return lastdrive; } +COUNT DosDelete(BYTE FAR *path) +{ + COUNT result, drive; + + if (IsDevice(path)) { + return DE_PATHNOTFND; + } + + drive = get_verify_drive(path); + if (drive < 0) { + return drive; + } + + result = truename(path, PriPathName, FALSE); + if (result != SUCCESS) { + return result; + } + current_ldt = &CDSp->cds_table[drive]; + if (CDSp->cds_table[drive].cdsFlags & CDSNETWDRV) { + result = int2f_Remote_call(REM_DELETE, 0, 0, 0, 0, 0, 0); + result = -result; + } else { + result = dos_delete(path); + } + return result; +} + +COUNT DosRename(BYTE FAR * path1, BYTE FAR * path2) +{ + COUNT result, drive1, drive2; + if (IsDevice(path1) || IsDevice(path2)) { + return DE_PATHNOTFND; + } + drive1 = get_verify_drive(path1); + result = truename(path1, PriPathName, FALSE); + if (result != SUCCESS) { + return result; + } + drive2 = get_verify_drive(path2); + result = truename(path2, SecPathName, FALSE); + if (result != SUCCESS) { + return result; + } + if ((drive1 != drive2) || (drive1 < 0)) { + return DE_INVLDDRV; + } + current_ldt = &CDSp->cds_table[drive1]; + if (CDSp->cds_table[drive1].cdsFlags & CDSNETWDRV) { + result = int2f_Remote_call(REM_RENAME, 0, 0, 0, 0, 0, 0); + result = -result; + } else { + result = dos_rename(path1, path2); + } + return result; +} + +COUNT DosMkdir(BYTE FAR * dir) +{ + COUNT result, drive; + + if (IsDevice(dir)) { + return DE_PATHNOTFND; + } + drive = get_verify_drive(dir); + if (drive < 0) { + return drive; + } + result = truename(dir, PriPathName, FALSE); + if (result != SUCCESS) { + return result; + } + current_ldt = &CDSp->cds_table[drive]; + if (CDSp->cds_table[drive].cdsFlags & CDSNETWDRV) { + result = int2f_Remote_call(REM_MKDIR, 0, 0, 0, 0, 0, 0); + result = -result; + } else { + result = dos_mkdir(dir); + } + return result; +} + +COUNT DosRmdir(BYTE FAR * dir) +{ + COUNT result, drive; + + if (IsDevice(dir)) { + return DE_PATHNOTFND; + } + drive = get_verify_drive(dir); + if (drive < 0) { + return drive; + } + result = truename(dir, PriPathName, FALSE); + if (result != SUCCESS) { + return result; + } + current_ldt = &CDSp->cds_table[drive]; + if (CDSp->cds_table[drive].cdsFlags & CDSNETWDRV) { + result = int2f_Remote_call(REM_RMDIR, 0, 0, 0, 0, 0, 0); + result = -result; + } else { + result = dos_rmdir(dir); + } + return result; +} diff --git a/kernel/dosidle.asm b/kernel/dosidle.asm index 7ef33293..ade3a77a 100644 --- a/kernel/dosidle.asm +++ b/kernel/dosidle.asm @@ -5,7 +5,7 @@ ; ; DOS-C ; Copyright (c) 1995, 1999 -; Pasquale J. Villani +; James B. Tabor ; All Rights Reserved ; ; This file is part of DOS-C. diff --git a/kernel/dosnames.c b/kernel/dosnames.c index ce06c87c..61b1f841 100644 --- a/kernel/dosnames.c +++ b/kernel/dosnames.c @@ -36,8 +36,11 @@ static BYTE *dosnamesRcsId = "$Id$"; /* * $Log$ - * Revision 1.1 2000/05/06 19:35:00 jhall1 - * Initial revision + * Revision 1.2 2000/05/08 04:29:59 jimtabor + * Update CVS to 2020 + * + * Revision 1.4 2000/03/31 05:40:09 jtabor + * Added Eric W. Biederman Patches * * Revision 1.3 2000/03/09 06:07:11 kernel * 2017f updates by James Tabor @@ -329,13 +332,13 @@ COUNT ParseDosPath(BYTE FAR * lpszFileName, return SUCCESS; } -BOOL IsDevice(BYTE * pszFileName) +BOOL IsDevice(BYTE FAR * pszFileName) { REG struct dhdr FAR *dhp = (struct dhdr FAR *)&nul_dev; BYTE szName[FNAME_SIZE]; /* break up the name first */ - if (ParseDosName((BYTE FAR *) pszFileName, + if (ParseDosName(pszFileName, (COUNT *) 0, TempBuffer, szName, (BYTE *) 0, FALSE) != SUCCESS) return FALSE; diff --git a/kernel/dsk.c b/kernel/dsk.c index 9e88d10f..2d70d897 100644 --- a/kernel/dsk.c +++ b/kernel/dsk.c @@ -33,8 +33,11 @@ static BYTE *dskRcsId = "$Id$"; /* * $Log$ - * Revision 1.1 2000/05/06 19:35:01 jhall1 - * Initial revision + * Revision 1.2 2000/05/08 04:29:59 jimtabor + * Update CVS to 2020 + * + * Revision 1.6 2000/04/29 05:13:16 jtabor + * Added new functions and clean up code * * Revision 1.5 2000/03/09 06:07:11 kernel * 2017f updates by James Tabor @@ -174,6 +177,7 @@ WORD init(rqptr), mediachk(rqptr), bldbpb(rqptr), blockio(rqptr), + Genblkdev(rqptr), blk_error(rqptr); COUNT ltop(WORD *, WORD *, WORD *, COUNT, COUNT, LONG, byteptr); WORD dskerr(COUNT); @@ -217,7 +221,7 @@ static WORD(*dispatch[NENTRY]) () = blk_error, /* Output till busy */ blk_error, /* undefined */ blk_error, /* undefined */ - blk_error, /* Generic Ioctl */ + Genblkdev, /* Generic Ioctl */ blk_error, /* undefined */ blk_error, /* undefined */ blk_error, /* undefined */ @@ -534,6 +538,35 @@ static COUNT write_and_verify(WORD drive, WORD head, WORD track, WORD sector, return fl_verify(drive, head, track, sector, count, buffer); } +static WORD Genblkdev(rqptr rp) +{ + UWORD cmd = rp->r_count; + + + switch(cmd){ + case 0x0860: + { + struct gblkio FAR * gblp = rp->r_trans; + + gblp->gbio_devtype = 0x05; + gblp->gbio_devattrib = 0x01; + gblp->gbio_ncyl = miarray[rp->r_unit].mi_cyls; + gblp->gbio_media = 0; + gblp->gbio_bpb = bpbarray[rp->r_unit]; + gblp->gbio_nsecs = bpbarray[rp->r_unit].bpb_nsector; + + printf("GenBlkIO = %08lx\n", rp->r_trans); + printf("GenBlkIO = %08lx\n", gblp); + break; + } + case 0x0866: + + + break; + } + + return S_DONE; +} static WORD blockio(rqptr rp) { REG retry = N_RETRY, diff --git a/kernel/entry.asm b/kernel/entry.asm index daf1b2d7..44e59fa0 100644 --- a/kernel/entry.asm +++ b/kernel/entry.asm @@ -28,8 +28,11 @@ ; $Id$ ; ; $Log$ -; Revision 1.1 2000/05/06 19:35:03 jhall1 -; Initial revision +; Revision 1.2 2000/05/08 04:29:59 jimtabor +; Update CVS to 2020 +; +; Revision 1.5 2000/03/20 03:15:49 kernel +; Change in Entry.asm ; ; Revision 1.4 1999/09/23 04:40:46 jprice ; *** empty log message *** @@ -306,13 +309,13 @@ int21_3: ; Recover registers from system call. Registers and flags ; were modified by the system call. ; -int21_exit: sti +int21_exit: cli mov bp,word [_user_r+2] mov ss,bp mov bp,word [_user_r] ; store and init mov sp,bp dec byte [_InDOS] - cli + sti int21_ret: POP$ALL ; diff --git a/kernel/error.c b/kernel/error.c index 50c95b90..6f230694 100644 --- a/kernel/error.c +++ b/kernel/error.c @@ -34,8 +34,8 @@ static BYTE *errorRcsId = "$Id$"; /* * $Log$ - * Revision 1.1 2000/05/06 19:35:03 jhall1 - * Initial revision + * Revision 1.2 2000/05/08 04:30:00 jimtabor + * Update CVS to 2020 * * Revision 1.2 2000/03/09 06:07:11 kernel * 2017f updates by James Tabor diff --git a/kernel/execrh.asm b/kernel/execrh.asm index 138a79ca..24e47a97 100644 --- a/kernel/execrh.asm +++ b/kernel/execrh.asm @@ -30,8 +30,8 @@ ; $Id$ ; ; $Log$ -; Revision 1.1 2000/05/06 19:35:03 jhall1 -; Initial revision +; Revision 1.2 2000/05/08 04:30:00 jimtabor +; Update CVS to 2020 ; ; Revision 1.3 2000/03/09 06:07:11 kernel ; 2017f updates by James Tabor diff --git a/kernel/fatdir.c b/kernel/fatdir.c index 1c2d8238..c84b5873 100644 --- a/kernel/fatdir.c +++ b/kernel/fatdir.c @@ -36,8 +36,14 @@ static BYTE *fatdirRcsId = "$Id$"; /* * $Log$ - * Revision 1.1 2000/05/06 19:35:05 jhall1 - * Initial revision + * Revision 1.2 2000/05/08 04:30:00 jimtabor + * Update CVS to 2020 + * + * Revision 1.12 2000/03/31 05:40:09 jtabor + * Added Eric W. Biederman Patches + * + * Revision 1.11 2000/03/17 22:59:04 kernel + * Steffen Kaiser's NLS changes * * Revision 1.10 2000/03/09 06:07:11 kernel * 2017f updates by James Tabor @@ -160,14 +166,16 @@ struct f_node FAR *dir_open(BYTE FAR * dirname) if (drive >= 0) { dirname += 2; /* Assume FAT style drive */ - TempCDS.cdsDpb = CDSp->cds_table[drive].cdsDpb; } else { drive = default_drive; - TempCDS.cdsDpb = CDSp->cds_table[drive].cdsDpb; - } + if (drive > lastdrive) { + release_f_node(fnp); + return NULL; + } + TempCDS.cdsDpb = CDSp->cds_table[drive].cdsDpb; cdsp = &CDSp->cds_table[drive]; @@ -180,7 +188,7 @@ struct f_node FAR *dir_open(BYTE FAR * dirname) /* Generate full path name */ ParseDosPath(dirname, (COUNT *) 0, pszPath, (BYTE FAR *) & cdsp->cdsCurrentPath[x]); - if ((cdsp->cdsFlags & 0x8000)) + if ((cdsp->cdsFlags & CDSNETWDRV)) { printf("FailSafe %x \n", Int21AX); return fnp; @@ -192,7 +200,7 @@ struct f_node FAR *dir_open(BYTE FAR * dirname) return NULL; } -/* if (drive >= lastdrive) +/* if (drive > lastdrive) { release_f_node(fnp); return NULL; @@ -264,7 +272,7 @@ struct f_node FAR *dir_open(BYTE FAR * dirname) /* find the entry... */ i = FALSE; - upMem((BYTE FAR *) TempBuffer, FNAME_SIZE + FEXT_SIZE); + upFMem((BYTE FAR *) TempBuffer, FNAME_SIZE + FEXT_SIZE); while (dir_read(fnp) == DIRENT_SIZE) { @@ -548,6 +556,7 @@ COUNT dos_findfirst(UCOUNT attr, BYTE FAR * name) COUNT nDrive; BYTE *p; struct cds FAR *cdsp; + BYTE FAR *ptr; static BYTE local_name[FNAME_SIZE + 1], local_ext[FEXT_SIZE + 1]; @@ -578,9 +587,12 @@ COUNT dos_findfirst(UCOUNT attr, BYTE FAR * name) else nDrive = default_drive; + if (nDrive > lastdrive) { + return DE_INVLDDRV; + } cdsp = &CDSp->cds_table[nDrive]; - if (cdsp->cdsFlags & 0x8000) + if (cdsp->cdsFlags & CDSNETWDRV) { if (Remote_find(REM_FINDFIRST, attr, name, dmp) != 0) return DE_FILENOTFND; @@ -619,7 +631,7 @@ COUNT dos_findfirst(UCOUNT attr, BYTE FAR * name) SearchDir.dir_ext[i] = ' '; /* Convert everything to uppercase. */ - upMem(SearchDir.dir_name, FNAME_SIZE + FEXT_SIZE); + upFMem(SearchDir.dir_name, FNAME_SIZE + FEXT_SIZE); /* Copy the raw pattern from our data segment to the DTA. */ fbcopy((BYTE FAR *) SearchDir.dir_name, dmp->dm_name_pat, @@ -703,8 +715,17 @@ COUNT dos_findnext(void) nDrive = dmp->dm_drive; + if (nDrive > lastdrive) { + return DE_INVLDDRV; + } cdsp = &CDSp->cds_table[nDrive]; - if (cdsp->cdsFlags & 0x8000) + +#if 0 + printf("findnext: %c %s\n", + nDrive + 'A', (cdsp->cdsFlags & CDSNETWDRV)?"remote":"local"); +#endif + + if (cdsp->cdsFlags & CDSNETWDRV) { if (Remote_find(REM_FINDNEXT, 0, 0, dmp) != 0) return DE_FILENOTFND; @@ -720,6 +741,9 @@ COUNT dos_findnext(void) /* Force the fnode into read-write mode */ fnp->f_mode = RDWR; + if (dmp->dm_drive > lastdrive) { + return DE_INVLDDRV; + } /* Select the default to help non-drive specified path */ /* searches... */ fnp->f_dpb = (struct dpb *)CDSp->cds_table[dmp->dm_drive].cdsDpb; diff --git a/kernel/fatfs.c b/kernel/fatfs.c index e938f022..3f8eb527 100644 --- a/kernel/fatfs.c +++ b/kernel/fatfs.c @@ -36,8 +36,20 @@ BYTE *RcsId = "$Id$"; /* * $Log$ - * Revision 1.1 2000/05/06 19:35:09 jhall1 - * Initial revision + * Revision 1.2 2000/05/08 04:30:00 jimtabor + * Update CVS to 2020 + * + * Revision 1.23 2000/04/29 05:13:16 jtabor + * Added new functions and clean up code + * + * Revision 1.19 2000/03/17 22:59:04 kernel + * Steffen Kaiser's NLS changes + * + * Revision 1.18 2000/03/17 04:13:12 kernel + * Added Change for media_check + * + * Revision 1.17 2000/03/17 04:01:20 kernel + * Added Change for media_check * * Revision 1.16 2000/03/09 06:07:11 kernel * 2017f updates by James Tabor @@ -307,6 +319,9 @@ static struct f_node FAR * SpacePad(fname, FNAME_SIZE); SpacePad(fext, FEXT_SIZE); + if (nDrive > lastdrive) { + return (struct f_node FAR *)0; + } cdsp = &CDSp->cds_table[nDrive]; /* If the path is null, we to default to the current */ @@ -327,6 +342,14 @@ static struct f_node FAR * Do the redirection in Network.c> */ +#ifdef DEBUG + if (cdsp->cdsFlags & CDSNETWDRV) { + BYTE FAR *p; + printf("split path called for redirected file: `%s.%s'\n", + fname, fext); + return (struct f_node FAR *)0; + } +#endif /* Translate the path into a useful pointer */ fnp = dir_open((BYTE FAR *) dname); @@ -341,9 +364,9 @@ static struct f_node FAR * } /* Convert the name into an absolute name for comparison... */ - upMem((BYTE FAR *) dname, strlen(dname)); - upMem((BYTE FAR *) fname, FNAME_SIZE); - upMem((BYTE FAR *) fext, FEXT_SIZE); + upFMem((BYTE FAR *) dname, strlen(dname)); + upFMem((BYTE FAR *) fname, FNAME_SIZE); + upFMem((BYTE FAR *) fext, FEXT_SIZE); return fnp; } @@ -419,7 +442,7 @@ COUNT dos_creat(BYTE FAR * path, COUNT attrib) /* it in building the new file. */ /* Note that if we're in the root and we don't */ /* find an empty slot, we need to abort. */ - if (!(is_free = find_free(fnp)) && (fnp->f_flags.f_droot)) + if (((is_free = find_free(fnp)) == 0) && (fnp->f_flags.f_droot)) { fnp->f_flags.f_dmod = FALSE; dir_close(fnp); @@ -661,7 +684,7 @@ COUNT dos_rename(BYTE FAR * path1, BYTE FAR * path2) /* Now find a free slot to put the file into. */ /* If it's the root and we don't have room, return an error. */ - if (!(is_free = find_free(fnp2)) && (fnp2->f_flags.f_droot)) + if (((is_free = find_free(fnp2)) == 0) && (fnp2->f_flags.f_droot)) { fnp2->f_flags.f_dmod = FALSE; dir_close(fnp1); @@ -1032,7 +1055,7 @@ COUNT dos_mkdir(BYTE FAR * dir) /* it in building the new file. */ /* Note that if we're in the root and we don't */ /* find an empty slot, we need to abort. */ - if (!(is_free = find_free(fnp)) && (fnp->f_flags.f_droot)) + if (((is_free = find_free(fnp)) == 0) && (fnp->f_flags.f_droot)) { fnp->f_flags.f_dmod = FALSE; dir_close(fnp); @@ -1825,9 +1848,12 @@ UWORD dos_free(struct dpb * dpbp) /* cluster start at 2 and run to max_cluster+2 */ REG UWORD i; REG UWORD cnt = 0; - UWORD max_cluster = ((ULONG) dpbp->dpb_size - * (ULONG) (dpbp->dpb_clsmask + 1) - dpbp->dpb_data + 1) - / (dpbp->dpb_clsmask + 1) + 2; +/* UWORD max_cluster = ( ((ULONG) dpbp->dpb_size + * * (ULONG) (dpbp->dpb_clsmask + 1) - (dpbp->dpb_data + 1) ) + * / (dpbp->dpb_clsmask + 1) ) + 2; + */ + UWORD max_cluster = ( ((ULONG) dpbp->dpb_size * (ULONG) (dpbp->dpb_clsmask + 1)) + / (dpbp->dpb_clsmask + 1) ) + 1; if (dpbp->dpb_nfreeclst != UNKNCLUSTER) return dpbp->dpb_nfreeclst; @@ -1843,41 +1869,34 @@ UWORD dos_free(struct dpb * dpbp) } } -VOID dos_pwd(struct cds FAR * cdsp, BYTE FAR * s) -{ - WORD x = 1 + cdsp->cdsJoinOffset; - fsncopy((BYTE FAR *) & cdsp->cdsCurrentPath[x], s, 64); -} + #ifndef IPL -COUNT dos_cd(struct cds FAR * cdsp, BYTE FAR * s) +COUNT dos_cd(struct cds FAR * cdsp, BYTE FAR *PathName) { BYTE FAR *p; struct f_node FAR *fnp; + REG struct dpb *dpbp; COUNT x; - /* Get the current directory so that we initialize all access */ - /* relative to root. */ - truename(s, PriPathName, FALSE); + /* first check for valid drive */ + if (cdsp->cdsDpb == 0) + return DE_INVLDDRV; - if (cdsp->cdsFlags & 0x8000) - { - if ((int2f_Remote_call(REM_CHDIR, 0, 0, 0, PriPathName, 0, 0)) != 0) - return DE_PATHNOTFND; - fscopy(&PriPathName[0], cdsp->cdsCurrentPath); - if (PriPathName[7] == 0) - cdsp->cdsCurrentPath[8] = 0; - return SUCCESS; - } + + dpbp = (struct dpb *)cdsp->cdsDpb; + if ((media_check(dpbp) < 0)) + return DE_INVLDDRV; /* now test for its existance. If it doesn't, return an error. */ /* If it does, copy the path to the current directory */ /* structure. */ - if ((fnp = dir_open((BYTE FAR *) PriPathName)) == NULL) + if ((fnp = dir_open(PathName)) == NULL) return DE_PATHNOTFND; + cdsp->cdsStrtClst = fnp->f_dirstart; dir_close(fnp); - fscopy(&PriPathName[0], cdsp->cdsCurrentPath); + fscopy(&PathName[0], cdsp->cdsCurrentPath); return SUCCESS; } #endif @@ -2074,7 +2093,9 @@ COUNT media_check(REG struct dpb * dpbp) size = bpbp->bpb_nsize == 0 ? bpbp->bpb_huge : (ULONG) bpbp->bpb_nsize; +/* patch point dpbp->dpb_size = size / ((ULONG) bpbp->bpb_nsector); +*/ dpbp->dpb_fatsize = bpbp->bpb_nfsect; dpbp->dpb_dirstrt = dpbp->dpb_fatstrt + dpbp->dpb_fats * dpbp->dpb_fatsize; @@ -2082,8 +2103,13 @@ COUNT media_check(REG struct dpb * dpbp) + ((DIRENT_SIZE * dpbp->dpb_dirents + (dpbp->dpb_secsize - 1)) / dpbp->dpb_secsize); +/* + Michal Meller patch to jimtabor +*/ + dpbp->dpb_size = ((size - dpbp->dpb_data) / ((ULONG) bpbp->bpb_nsector) + 1); + dpbp->dpb_flags = 0; - dpbp->dpb_next = (struct dpb FAR *)-1; +/* dpbp->dpb_next = (struct dpb FAR *)-1;*/ dpbp->dpb_cluster = UNKNCLUSTER; dpbp->dpb_nfreeclst = UNKNCLUSTER; /* number of free clusters */ for (i = 1, dpbp->dpb_shftcnt = 0; @@ -2112,6 +2138,9 @@ COUNT xlt_fnp(struct f_node FAR * fnp) struct dhdr FAR *select_unit(COUNT drive) { /* Just get the header from the dhdr array */ - return blk_devices[drive].dpb_device; +/* return blk_devices[drive].dpb_device; */ + + return CDSp->cds_table[drive].cdsDpb; + } diff --git a/kernel/fattab.c b/kernel/fattab.c index 8869c38d..9a21424f 100644 --- a/kernel/fattab.c +++ b/kernel/fattab.c @@ -35,8 +35,8 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ - * Revision 1.1 2000/05/06 19:35:09 jhall1 - * Initial revision + * Revision 1.2 2000/05/08 04:30:00 jimtabor + * Update CVS to 2020 * * Revision 1.6 1999/08/10 18:03:42 jprice * ror4 2011-03 patch diff --git a/kernel/fcbfns.c b/kernel/fcbfns.c index d3bce15f..6086577c 100644 --- a/kernel/fcbfns.c +++ b/kernel/fcbfns.c @@ -35,8 +35,14 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ - * Revision 1.1 2000/05/06 19:35:12 jhall1 - * Initial revision + * Revision 1.2 2000/05/08 04:30:00 jimtabor + * Update CVS to 2020 + * + * Revision 1.7 2000/03/31 05:40:09 jtabor + * Added Eric W. Biederman Patches + * + * Revision 1.6 2000/03/17 22:59:04 kernel + * Steffen Kaiser's NLS changes * * Revision 1.5 2000/03/09 06:07:11 kernel * 2017f updates by James Tabor @@ -131,7 +137,7 @@ VOID FatGetDrvData(COUNT drive, COUNT FAR * spc, COUNT FAR * bps, printf("FGDD\n"); /* first check for valid drive */ - if (drive < 0 || drive > NDEVS) + if ((drive < 0) || (drive > lastdrive) || (drive > NDEVS)) { *spc = -1; return; @@ -139,6 +145,11 @@ VOID FatGetDrvData(COUNT drive, COUNT FAR * spc, COUNT FAR * bps, /* next - "log" in the drive */ drive = (drive == 0 ? default_drive : drive - 1); + if (CDSp->cds_table[drive].cdsFlags & CDSNETWDRV) { + printf("FatGetDrvData not yet supported over network drives\n"); + *spc = -1; + return; + } dpbp = (struct dpb *)CDSp->cds_table[drive].cdsDpb; dpbp->dpb_flags = -1; if ((media_check(dpbp) < 0)) @@ -340,7 +351,7 @@ BOOL FcbRead(xfcb FAR * lpXfcb, COUNT * nErrorCode) /* to. */ lPosit = ((lpFcb->fcb_cublock * 128) + lpFcb->fcb_curec) * lpFcb->fcb_recsiz; - if (dos_lseek(s->sft_status, lPosit, 0) < 0) + if (SftSeek(s, lPosit, 0) != SUCCESS) { *nErrorCode = FCB_ERR_EOF; return FALSE; @@ -412,7 +423,7 @@ BOOL FcbWrite(xfcb FAR * lpXfcb, COUNT * nErrorCode) /* to. */ lPosit = ((lpFcb->fcb_cublock * 128) + lpFcb->fcb_curec) * lpFcb->fcb_recsiz; - if (dos_lseek(s->sft_status, lPosit, 0) < 0) + if (SftSeek(s, lPosit, 0) != SUCCESS) { *nErrorCode = FCB_ERR_EOF; return FALSE; @@ -427,12 +438,13 @@ BOOL FcbWrite(xfcb FAR * lpXfcb, COUNT * nErrorCode) /* Do the read */ nWritten = dos_write(s->sft_status, p->ps_dta, lpFcb->fcb_recsiz); + s->sft_size = dos_getcufsize(s->sft_status); } /* Now find out how we will return and do it. */ if (nWritten == lpFcb->fcb_recsiz) { - lpFcb->fcb_fsize = dos_getcufsize(s->sft_status); + lpFcb->fcb_fsize = s->sft_size; FcbNextRecord(lpFcb); *nErrorCode = FCB_SUCCESS; return TRUE; @@ -813,24 +825,40 @@ BOOL FcbOpen(xfcb FAR * lpXfcb) } } } + fbcopy((BYTE FAR *) & lpFcb->fcb_fname, (BYTE FAR *) & sftp->sft_name, FNAME_SIZE + FEXT_SIZE); + if ((FcbDrive < 0) || (FcbDrive > lastdrive)) { + return DE_INVLDDRV; + } + if (CDSp->cds_table[FcbDrive].cdsFlags & CDSNETWDRV) { + COUNT result; + lpCurSft = (sfttbl FAR *)sftp; + result = int2f_Remote_call(REM_OPEN, 0, 0, 0, (VOID FAR *) sftp, 0, MK_FP(0, O_RDWR)); + result = -result; + sftp->sft_status = result; + } + else { sftp->sft_status = dos_open(PriPathName, O_RDWR); + sftp->sft_size = dos_getfsize(sftp->sft_status); + dos_getftime(sftp->sft_status, + (date FAR *) & sftp->sft_date, + (time FAR *) & sftp->sft_time); + + } if (sftp->sft_status >= 0) { lpFcb->fcb_drive = FcbDrive; lpFcb->fcb_sftno = sft_idx; lpFcb->fcb_curec = 0; lpFcb->fcb_recsiz = 128; - lpFcb->fcb_fsize = dos_getfsize(sftp->sft_status); - dos_getftime(sftp->sft_status, - (date FAR *) & lpFcb->fcb_date, - (time FAR *) & lpFcb->fcb_time); + lpFcb->fcb_fsize = sftp->sft_size; + lpFcb->fcb_date = sftp->sft_date; + lpFcb->fcb_time = sftp->sft_time; lpFcb->fcb_rndm = 0; sftp->sft_count += 1; sftp->sft_mode = O_RDWR; sftp->sft_attrib = 0; sftp->sft_flags = 0; sftp->sft_psp = cu_psp; - fbcopy((BYTE FAR *) & lpFcb->fcb_fname, (BYTE FAR *) & sftp->sft_name, FNAME_SIZE + FEXT_SIZE); return TRUE; } else @@ -844,6 +872,14 @@ BOOL FcbDelete(xfcb FAR * lpXfcb) /* Build a traditional DOS file name */ CommonFcbInit(lpXfcb, PriPathName, &FcbDrive); + if ((FcbDrive < 0) || (FcbDrive > lastdrive)) { + return DE_INVLDDRV; + } + current_ldt = &CDSp->cds_table[FcbDrive]; + if (CDSp->cds_table[FcbDrive].cdsFlags & CDSNETWDRV) { + return -int2f_Remote_call(REM_DELETE, 0, 0, 0, 0, 0, 0); + } + /* check for a device */ /* if we have an extension, can't be a device */ if (IsDevice(PriPathName)) @@ -1148,7 +1184,7 @@ BOOL FcbFindNext(xfcb FAR * lpXfcb) Dmatch.dm_drive = FcbDrive ? FcbDrive - 1 : default_drive; fbcopy(lpFcb->fcb_fname, (BYTE FAR *) Dmatch.dm_name_pat, FNAME_SIZE + FEXT_SIZE); - upMem((BYTE FAR *) Dmatch.dm_name_pat, FNAME_SIZE + FEXT_SIZE); + upFMem((BYTE FAR *) Dmatch.dm_name_pat, FNAME_SIZE + FEXT_SIZE); Dmatch.dm_attr_srch = wAttr; Dmatch.dm_entry = lpFcb->fcb_diroff; Dmatch.dm_cluster = lpFcb->fcb_dirclst; diff --git a/kernel/globals.h b/kernel/globals.h index 195226f8..11ce1b09 100644 --- a/kernel/globals.h +++ b/kernel/globals.h @@ -36,8 +36,11 @@ static BYTE *Globals_hRcsId = "$Id$"; /* * $Log$ - * Revision 1.1 2000/05/06 19:35:18 jhall1 - * Initial revision + * Revision 1.2 2000/05/08 04:30:00 jimtabor + * Update CVS to 2020 + * + * Revision 1.17 2000/03/16 03:28:49 kernel + * *** empty log message *** * * Revision 1.16 2000/03/09 06:07:11 kernel * 2017f updates by James Tabor @@ -703,7 +706,7 @@ VOID fputbyte(); #ifdef I86 #define setvec(n, isr) (void)(*(VOID (INRPT FAR * FAR *)())(4 * (n)) = (isr)) #endif -#define is_leap_year(y) ((y) & 3 ? 0 : (y) % 100 ? 1 : (y) % 400 ? 1 : 0) +#define is_leap_year(y) ((y) & 3 ? 0 : (y) % 100 ? 1 : (y) % 400 ? 0 : 1) /* ^Break handling */ void spawn_int23(void); /* procsupt.asm */ diff --git a/kernel/initoem.c b/kernel/initoem.c index f16e1dd8..c6b72544 100644 --- a/kernel/initoem.c +++ b/kernel/initoem.c @@ -38,8 +38,8 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ - * Revision 1.1 2000/05/06 19:35:18 jhall1 - * Initial revision + * Revision 1.2 2000/05/08 04:30:00 jimtabor + * Update CVS to 2020 * * Revision 1.3 2000/03/09 06:07:11 kernel * 2017f updates by James Tabor diff --git a/kernel/int2f.asm b/kernel/int2f.asm index 4b7806f8..89df2c53 100644 --- a/kernel/int2f.asm +++ b/kernel/int2f.asm @@ -30,8 +30,11 @@ ; $Id$ ; ; $Log$ -; Revision 1.1 2000/05/06 19:35:18 jhall1 -; Initial revision +; Revision 1.2 2000/05/08 04:30:00 jimtabor +; Update CVS to 2020 +; +; Revision 1.4 2000/03/31 05:40:09 jtabor +; Added Eric W. Biederman Patches ; ; Revision 1.3 2000/03/09 06:07:11 kernel ; 2017f updates by James Tabor @@ -181,12 +184,16 @@ int2f_r_5: pop ds call int2f_call pop ds + jc short int2f_rfner + xor ax,ax jmp short int2f_rfner int2f_r_6: ; ; everything else goes through here. ; call int2f_call + jc int2f_rfner + xor ax,ax int2f_rfner: pop bx pop cx @@ -213,6 +220,10 @@ _QRemote_Fn les di,[bp+8] stc int 2fh + mov ax,0xffff + jnc QRemote_Fn_out + xor ax,ax +QRemote_Fn_out: pop di pop si pop ds @@ -229,4 +240,3 @@ int2f_call: pop bp pop bp ret - diff --git a/kernel/inthndlr.c b/kernel/inthndlr.c index af5b30b4..f25b309c 100644 --- a/kernel/inthndlr.c +++ b/kernel/inthndlr.c @@ -36,8 +36,26 @@ BYTE *RcsId = "$Id$"; /* * $Log$ - * Revision 1.1 2000/05/06 19:35:19 jhall1 - * Initial revision + * Revision 1.2 2000/05/08 04:30:00 jimtabor + * Update CVS to 2020 + * + * Revision 1.25 2000/04/29 05:31:47 jtabor + * fix history + * + * Revision 1.24 2000/04/29 05:13:16 jtabor + * Added new functions and clean up code + * + * Revision 1.23 2000/03/31 05:40:09 jtabor + * Added Eric W. Biederman Patches + * + * Revision 1.22 2000/03/17 22:59:04 kernel + * Steffen Kaiser's NLS changes + * + * Revision 1.21 2000/03/17 05:00:11 kernel + * Fixed Func 0x32 + * + * Revision 1.20 2000/03/16 03:28:49 kernel + * *** empty log message *** * * Revision 1.19 2000/03/09 06:07:11 kernel * 2017f updates by James Tabor @@ -253,8 +271,8 @@ VOID int21_syscall(iregs FAR * irp) VOID int21_service(iregs FAR * r) { - COUNT rc, - rc1; + COUNT rc = 0, + rc1; ULONG lrc; psp FAR *p = MK_FP(cu_psp, 0); @@ -565,7 +583,7 @@ VOID int21_service(iregs FAR * r) /* Get default DPB */ case 0x1f: - if (default_drive < lastdrive) + if (default_drive <= lastdrive) { struct dpb FAR *dpb = (struct dpb FAR *)CDSp->cds_table[default_drive].cdsDpb; if (dpb == 0) @@ -750,7 +768,8 @@ VOID int21_service(iregs FAR * r) /* Get DPB */ case 0x32: - if (r->DL < lastdrive) + r->DL = ( r->DL == 0 ? default_drive : r->DL - 1); + if (r->DL <= lastdrive) { struct dpb FAR *dpb = CDSp->cds_table[r->DL].cdsDpb; if (dpb == 0) @@ -822,40 +841,30 @@ VOID int21_service(iregs FAR * r) /* Get/Set Country Info */ case 0x38: { - BYTE FAR *lpTable - = (BYTE FAR *) MK_FP(r->DS, r->DX); - BYTE nRetCode; - - if (0xffff == r->DX) - { - r->BX = SetCtryInfo( - (UBYTE FAR *) & (r->AL), - (UWORD FAR *) & (r->BX), - (BYTE FAR *) & lpTable, - (UBYTE *) & nRetCode); - - if (nRetCode != 0) - { - r->AX = 0xff; - r->FLAGS |= FLG_CARRY; - } - else - { - r->AX = nRetCode; - r->FLAGS &= ~FLG_CARRY; - } - } - else - { - r->BX = GetCtryInfo(&(r->AL), &(r->BX), lpTable); - r->FLAGS &= ~FLG_CARRY; + UWORD cntry = r->AL; + + if(cntry == 0) + cntry = (UWORD)-1; + else if(cntry == 0xff) + cntry = r->BX; + + if (0xffff == r->DX) { + /* Set Country Code */ + if((rc = setCountryCode(cntry)) < 0) + goto error_invalid; + } else { + /* Get Country Information */ + if((rc = getCountryInformation(cntry, MK_FP(r->DS, r->DX))) < 0) + goto error_invalid; + r->AX = r->BX = cntry; } + r->FLAGS &= ~FLG_CARRY; } break; /* Dos Create Directory */ case 0x39: - rc = dos_mkdir((BYTE FAR *) MK_FP(r->DS, r->DX)); + rc = DosMkdir((BYTE FAR *) MK_FP(r->DS, r->DX)); if (rc != SUCCESS) goto error_exit; else @@ -866,7 +875,7 @@ VOID int21_service(iregs FAR * r) /* Dos Remove Directory */ case 0x3a: - rc = dos_rmdir((BYTE FAR *) MK_FP(r->DS, r->DX)); + rc = DosRmdir((BYTE FAR *) MK_FP(r->DS, r->DX)); if (rc != SUCCESS) goto error_exit; else @@ -948,11 +957,11 @@ VOID int21_service(iregs FAR * r) /* Dos Delete File */ case 0x41: - rc = dos_delete((BYTE FAR *) MK_FP(r->DS, r->DX)); + rc = DosDelete((BYTE FAR *) MK_FP(r->DS, r->DX)); if (rc < 0) { r->FLAGS |= FLG_CARRY; - r->AX = -rc1; + r->AX = -rc; } else r->FLAGS &= ~FLG_CARRY; @@ -976,7 +985,7 @@ VOID int21_service(iregs FAR * r) { case 0x00: rc = DosGetFattr((BYTE FAR *) MK_FP(r->DS, r->DX), (UWORD FAR *) & r->CX); - if (rc < SUCCESS) + if (rc != SUCCESS) goto error_exit; else { @@ -1009,6 +1018,10 @@ VOID int21_service(iregs FAR * r) } else { + + if(r->AL == 0x02) + r->AX = r->CX; + r->FLAGS &= ~FLG_CARRY; } } @@ -1117,9 +1130,8 @@ VOID int21_service(iregs FAR * r) || ((psp FAR *) (MK_FP(cu_psp, 0)))->ps_parent == cu_psp) break; tsr = FALSE; -/* int2f_Remote_call(0x1122, 0, 0, 0, 0, 0, 0); + int2f_Remote_call(REM_PROCESS_END, 0, 0, 0, 0, 0, 0); int2f_Remote_call(REM_CLOSEALL, 0, 0, 0, 0, 0, 0); - */ if (ErrorMode) { ErrorMode = FALSE; @@ -1210,7 +1222,7 @@ VOID int21_service(iregs FAR * r) /* Dos Rename */ case 0x56: - rc = dos_rename( + rc = DosRename( (BYTE FAR *) MK_FP(r->DS, r->DX), /* OldName */ (BYTE FAR *) MK_FP(r->ES, r->DI)); /* NewName */ if (rc < SUCCESS) @@ -1341,9 +1353,17 @@ VOID int21_service(iregs FAR * r) case 0x07: case 0x08: case 0x09: - int2f_Remote_call(REM_PRINTREDIR, 0, 0, r->DX, 0, 0, (MK_FP(0, Int21AX))); + { + COUNT result; + result = int2f_Remote_call(REM_PRINTREDIR, 0, 0, r->DX, 0, 0, (MK_FP(0, Int21AX))); + r->AX = result; + if (result != SUCCESS) { + r->FLAGS |= FLG_CARRY; + } else { + r->FLAGS &= ~FLG_CARRY; + } break; - + } default: goto error_invalid; } @@ -1361,25 +1381,47 @@ VOID int21_service(iregs FAR * r) break; default: - int2f_Remote_call(REM_PRINTSET, r->BX, r->CX, r->DX, (MK_FP(r->ES, r->DI)), r->SI, (MK_FP(r->DS, Int21AX))); + { + COUNT result; + result = int2f_Remote_call(REM_PRINTSET, r->BX, r->CX, r->DX, (MK_FP(r->ES, r->DI)), r->SI, (MK_FP(r->DS, Int21AX))); + r->AX = result; + if (result != SUCCESS) { + r->FLAGS |= FLG_CARRY; + } else { + r->FLAGS &= ~FLG_CARRY; + } break; } + } break; case 0x5f: switch (r->AL) { case 0x07: + if (r->DL <= lastdrive) { CDSp->cds_table[r->DL].cdsFlags |= 0x100; + } break; case 0x08: + if (r->DL <= lastdrive) { CDSp->cds_table[r->DL].cdsFlags &= ~0x100; + } break; default: - int2f_Remote_call(REM_DOREDIRECT, r->BX, r->CX, r->DX, (MK_FP(r->ES, r->DI)), r->SI, (MK_FP(r->DS, Int21AX))); + { + COUNT result; + result = int2f_Remote_call(REM_DOREDIRECT, r->BX, r->CX, r->DX, (MK_FP(r->ES, r->DI)), r->SI, (MK_FP(r->DS, Int21AX))); + r->AX = result; + if (result != SUCCESS) { + r->FLAGS |= FLG_CARRY; + } else { + r->FLAGS &= ~FLG_CARRY; + } break; + } } break; @@ -1441,71 +1483,58 @@ VOID int21_service(iregs FAR * r) /* Extended country info */ case 0x65: - if (r->AL <= 0x7) - { - if (ExtCtryInfo( - r->AL, - r->BX, - r->CX, - MK_FP(r->ES, r->DI))) - r->FLAGS &= ~FLG_CARRY; - else - goto error_invalid; - } - else if ((r->AL >= 0x20) && (r->AL <= 0x22)) - { - switch (r->AL) - { - case 0x20: + switch(r->AL) { + case 0x20: /* upcase single character */ r->DL = upChar(r->DL); - goto okay; - - case 0x21: - upMem( - MK_FP(r->DS, r->DX), - r->CX); - goto okay; - - case 0x22: + break; + case 0x21: /* upcase memory area */ + upMem(MK_FP(r->DS, r->DX), r->CX); + break; + case 0x22: /* upcase ASCIZ */ upString(MK_FP(r->DS, r->DX)); - okay: - r->FLAGS &= ~FLG_CARRY; break; - - case 0x23: + case 0xA0: /* upcase single character of filenames */ + r->DL = upFChar(r->DL); + break; + case 0xA1: /* upcase memory area of filenames */ + upFMem(MK_FP(r->DS, r->DX), r->CX); + break; + case 0xA2: /* upcase ASCIZ of filenames */ + upFString(MK_FP(r->DS, r->DX)); + break; + case 0x23: /* check Yes/No response */ r->AX = yesNo(r->DL); - goto okay; - - default: - goto error_invalid; - } - } - else - r->FLAGS |= FLG_CARRY; + break; + default: + if ((rc = extCtryInfo( + r->AL, r->BX, r->DX, r->CX, + MK_FP(r->ES, r->DI))) < 0) + goto error_exit; + break; + } + r->FLAGS &= ~FLG_CARRY; break; /* Code Page functions */ - case 0x66: + case 0x66: { + int rc; switch (r->AL) { case 1: - GetGlblCodePage( - (UWORD FAR *) & (r->BX), - (UWORD FAR *) & (r->DX)); - goto okay_66; - + rc = getCodePage(&r->BX, &r->DX); + break; case 2: - SetGlblCodePage( - (UWORD FAR *) & (r->BX), - (UWORD FAR *) & (r->DX)); - okay_66: - r->FLAGS &= ~FLG_CARRY; + rc = setCodePage(r->BX, r->DX); break; default: goto error_invalid; } + if(rc != SUCCESS) + goto error_exit; + r->FLAGS &= ~FLG_CARRY; break; + } /* Set Max file handle count */ case 0x67: @@ -1521,6 +1550,63 @@ VOID int21_service(iregs FAR * r) case 0x68: r->FLAGS &= ~FLG_CARRY; break; + + /* Get/Set Serial Number */ + case 0x69: + r->BL = ( r->BL == 0 ? default_drive : r->BL - 1); + if (r->BL <= lastdrive) + { + if (CDSp->cds_table[r->BL].cdsFlags & CDSNETWDRV) { + r->AX = 0x01; + goto error_out; + } + switch(r->AL){ + case 0x00: + r->CX = 0x0866; + rc = DosDevIOctl(r, (COUNT FAR *) & rc1); + break; + + case 0x01: + r->CX = 0x0846; + rc = DosDevIOctl(r, (COUNT FAR *) & rc1); + break; + } + r->FLAGS &= ~FLG_CARRY; + break; + } + else + r->AL = 0xFF; + break; + + + /* Extended Open-Creat, not fully functional.*/ + case 0x6c: + switch(r->DL) { + case 0x01: + if ((rc = DosCreat(MK_FP(r->DS, r->SI), r->CX )) < 0 ) + goto error_exit; + else + { + r->CX = 0x02; + r->AX = rc; + r->FLAGS &= ~FLG_CARRY; + } + break; + + case 0x10: + if ((rc = DosOpen(MK_FP(r->DS, r->SI), r->BL )) < 0 ) + goto error_exit; + else + { + r->CX = 0x01; + r->AX = rc; + r->FLAGS &= ~FLG_CARRY; + } + break; + + default: + goto error_invalid; + } } #ifdef DEBUG diff --git a/kernel/io.asm b/kernel/io.asm index bec1d6ef..a5fe8dd3 100644 --- a/kernel/io.asm +++ b/kernel/io.asm @@ -28,8 +28,8 @@ ; $Header$ ; ; $Log$ -; Revision 1.1 2000/05/06 19:35:20 jhall1 -; Initial revision +; Revision 1.2 2000/05/08 04:30:00 jimtabor +; Update CVS to 2020 ; ; Revision 1.3 2000/03/09 06:07:11 kernel ; 2017f updates by James Tabor diff --git a/kernel/io.inc b/kernel/io.inc index 46421292..37ded371 100644 --- a/kernel/io.inc +++ b/kernel/io.inc @@ -30,8 +30,8 @@ ; $Header$ ; ; $Log$ -; Revision 1.1 2000/05/06 19:35:20 jhall1 -; Initial revision +; Revision 1.2 2000/05/08 04:30:00 jimtabor +; Update CVS to 2020 ; ; Revision 1.3 1999/08/10 17:57:12 jprice ; ror4 2011-02 patch diff --git a/kernel/ioctl.c b/kernel/ioctl.c index c6304955..afb94b56 100644 --- a/kernel/ioctl.c +++ b/kernel/ioctl.c @@ -35,8 +35,11 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ - * Revision 1.1 2000/05/06 19:35:20 jhall1 - * Initial revision + * Revision 1.2 2000/05/08 04:30:00 jimtabor + * Update CVS to 2020 + * + * Revision 1.4 2000/04/29 05:13:16 jtabor + * Added new functions and clean up code * * Revision 1.3 2000/03/09 06:07:11 kernel * 2017f updates by James Tabor @@ -99,6 +102,7 @@ COUNT DosDevIOctl(iregs FAR * r, COUNT FAR * err) { sft FAR *s; struct dpb FAR *dpbp; + struct cds FAR *cdsp; BYTE FAR *pBuffer = MK_FP(r->DS, r->DX); COUNT nMode; @@ -131,13 +135,7 @@ COUNT DosDevIOctl(iregs FAR * r, COUNT FAR * err) case 0x0f: case 0x10: case 0x11: - if (r->BL > nblkdev) - { - *err = DE_INVLDDRV; - return 0; - } - else - { + /* This line previously returned the deviceheader at r->bl. But, DOS numbers its drives starting at 1, not 0. A=1, B=2, and so @@ -146,11 +144,20 @@ COUNT DosDevIOctl(iregs FAR * r, COUNT FAR * err) -SRM */ /* JPP - changed to use default drive if drive=0 */ - if (r->BL == 0) - dpbp = &blk_devices[default_drive]; - else - dpbp = &blk_devices[r->BL - 1]; +/* JT Fixed it */ + + r->BL = ( r->BL == 0 ? default_drive : r->BL - 1); + if (r->BL > lastdrive) + { + *err = DE_INVLDDRV; + return 0; } + else + { + cdsp = &CDSp->cds_table[r->BL]; + dpbp = cdsp->cdsDpb; + } + break; case 0x0b: @@ -172,19 +179,14 @@ COUNT DosDevIOctl(iregs FAR * r, COUNT FAR * err) /* Get the flags from the SFT */ r->DX = r->AX = s->sft_flags; - /* Test for file and network SFT. These return a 0 in */ - /* the AH register. */ - if ((s->sft_flags & SFT_FSHARED) - || !(s->sft_flags & SFT_FDEVICE)) - { - r->AH = 0; - } +/* r->DX = r->AX = s->sft_dev->dh_attr;*/ + break; case 0x01: /* sft_flags is a file, return an error because you */ /* can't set the status of a file. */ - if (!(s->sft_flags & SFT_FDEVICE)) + if ((s->sft_flags & SFT_FDEVICE)) /* !*/ { *err = DE_INVLDFUNC; return 0; @@ -209,8 +211,9 @@ COUNT DosDevIOctl(iregs FAR * r, COUNT FAR * err) IoCharCommon: if ((s->sft_flags & SFT_FDEVICE) - || ((r->AL == 0x10) && !(s->sft_dev->dh_attr & ATTR_QRYIOCTL)) - || ((r->AL == 0x0c) && !(s->sft_dev->dh_attr & ATTR_GENIOCTL))) + || ((r->AL == 0x10) && (s->sft_dev->dh_attr & ATTR_QRYIOCTL)) + || ((r->AL == 0x0c) && (s->sft_dev->dh_attr & ATTR_GENIOCTL))) + /* ! ! */ { if (s->sft_dev->dh_attr & SFT_FIOCTL) { @@ -249,8 +252,9 @@ COUNT DosDevIOctl(iregs FAR * r, COUNT FAR * err) nMode = C_IOCTLOUT; IoBlockCommon: if ((dpbp->dpb_device->dh_attr & ATTR_IOCTL) - || ((r->AL == 0x11) && !(dpbp->dpb_device->dh_attr & ATTR_QRYIOCTL)) - || ((r->AL == 0x0d) && !(dpbp->dpb_device->dh_attr & ATTR_GENIOCTL))) + || ((r->AL == 0x11) && (dpbp->dpb_device->dh_attr & ATTR_QRYIOCTL)) + || ((r->AL == 0x0d) && (dpbp->dpb_device->dh_attr & ATTR_GENIOCTL))) + /* ! ! */ { *err = DE_INVLDFUNC; return 0; @@ -310,11 +314,14 @@ COUNT DosDevIOctl(iregs FAR * r, COUNT FAR * err) return 0; case 0x09: - r->DX = dpbp->dpb_device->dh_attr; + if(cdsp->cdsFlags & CDSNETWDRV) + r->DX = 0x1000; + else + r->DX = dpbp->dpb_device->dh_attr; break; case 0x0a: - r->DX = s->sft_dcb->dpb_device->dh_attr; + r->DX = s->sft_flags & SFT_FSHARED; break; case 0x0e: diff --git a/kernel/irqstack.asm b/kernel/irqstack.asm index c3ae41d2..53d6bb3e 100644 --- a/kernel/irqstack.asm +++ b/kernel/irqstack.asm @@ -29,8 +29,8 @@ ; $Id$ ; ; $Log$ -; Revision 1.1 2000/05/06 19:35:21 jhall1 -; Initial revision +; Revision 1.2 2000/05/08 04:30:00 jimtabor +; Update CVS to 2020 ; ; Revision 1.3 1999/08/10 17:57:13 jprice ; ror4 2011-02 patch diff --git a/kernel/kernel.asm b/kernel/kernel.asm index 96848ebc..6109a7bb 100644 --- a/kernel/kernel.asm +++ b/kernel/kernel.asm @@ -28,8 +28,8 @@ ; $Id$ ; ; $Log$ -; Revision 1.1 2000/05/06 19:35:22 jhall1 -; Initial revision +; Revision 1.2 2000/05/08 04:30:00 jimtabor +; Update CVS to 2020 ; ; Revision 1.6 2000/03/09 06:07:11 kernel ; 2017f updates by James Tabor diff --git a/kernel/kernel.mak b/kernel/kernel.mak index 8482f069..53a9fe17 100644 --- a/kernel/kernel.mak +++ b/kernel/kernel.mak @@ -5,8 +5,14 @@ # # $Log$ -# Revision 1.1 2000/05/06 19:35:23 jhall1 -# Initial revision +# Revision 1.2 2000/05/08 04:30:00 jimtabor +# Update CVS to 2020 +# +# Revision 1.14 2000/03/31 05:40:09 jtabor +# Added Eric W. Biederman Patches +# +# Revision 1.13 2000/03/17 22:59:04 kernel +# Steffen Kaiser's NLS changes # # Revision 1.12 2000/03/09 06:07:11 kernel # 2017f updates by James Tabor @@ -117,6 +123,9 @@ HDR=../hdr/ .c.obj: $(CC) $(CFLAGS) -c $< +.c.asm: + $(CC) $(CFLAGS) -S $< + .cpp.obj: $(CC) $(CFLAGS) -c $< @@ -149,6 +158,7 @@ EXE_dependencies = \ int2f.obj \ inthndlr.obj \ io.obj \ + intr.obj \ ioctl.obj \ irqstack.obj \ kernel.obj \ @@ -158,6 +168,7 @@ EXE_dependencies = \ newstuff.obj \ network.obj \ nls.obj \ + nls_hc.obj \ nlssupt.obj \ prf.obj \ printer.obj \ @@ -189,16 +200,16 @@ clean: # inability of Turbo `make' 2.0 to perform command line redirection. -- ror4 kernel.exe: $(EXE_dependencies) $(LIBS) del kernel.lib - $(LIBUTIL) kernel +entry +io +blockio +chario +dosfns +console - $(LIBUTIL) kernel +printer +serial +dsk +error +fatdir +fatfs - $(LIBUTIL) kernel +fattab +fcbfns +initoem +inthndlr +ioctl - $(LIBUTIL) kernel +main +config +memmgr +misc +newstuff +nls + $(LIBUTIL) kernel +entry +io +blockio +chario +dosfns +console + $(LIBUTIL) kernel +printer +serial +dsk +error +fatdir +fatfs + $(LIBUTIL) kernel +fattab +fcbfns +initoem +inthndlr +ioctl +nls_hc + $(LIBUTIL) kernel +main +config +memmgr +misc +newstuff +nls +intr $(LIBUTIL) kernel +dosnames +prf +strings +network +sysclk +syspack - $(LIBUTIL) kernel +systime +task +int2f +irqstack +apisupt - $(LIBUTIL) kernel +asmsupt +execrh +nlssupt +procsupt +break + $(LIBUTIL) kernel +systime +task +int2f +irqstack +apisupt + $(LIBUTIL) kernel +asmsupt +execrh +nlssupt +procsupt +break $(LIBUTIL) kernel +dosidle - del kernel.bak - $(LINK) /m/c/L$(LIBPATH) kernel,kernel,kernel,kernel+$(LIBS); + del kernel.bak + $(LINK) /m/c/L$(LIBPATH) kernel,kernel,kernel,kernel+$(LIBS); del kernel.lib # *Individual File Dependencies* @@ -220,6 +231,8 @@ execrh.obj: execrh.asm segs.inc int2f.obj: int2f.asm segs.inc +intr.obj: intr.asm segs.inc intr.h + io.obj: io.asm segs.inc irqstack.obj: irqstack.asm @@ -382,6 +395,8 @@ nls.obj: nls.c $(HDR)portab.h globals.h $(HDR)device.h $(HDR)mcb.h \ $(HDR)clock.h $(HDR)kbd.h $(HDR)error.h $(HDR)version.h proto.h \ 001-437.nls +nls_hc.obj: nls_hc.c globals.h $(HDR)portab.h $(HDR)nls.h + prf.obj: prf.c $(HDR)portab.h strings.obj: strings.c $(HDR)portab.h diff --git a/kernel/main.c b/kernel/main.c index c5a37a6a..6feae5d4 100644 --- a/kernel/main.c +++ b/kernel/main.c @@ -39,8 +39,11 @@ static BYTE *mainRcsId = "$Id$"; /* * $Log$ - * Revision 1.1 2000/05/06 19:35:25 jhall1 - * Initial revision + * Revision 1.2 2000/05/08 04:30:00 jimtabor + * Update CVS to 2020 + * + * Revision 1.14 2000/03/31 05:40:09 jtabor + * Added Eric W. Biederman Patches * * Revision 1.13 2000/03/09 06:07:11 kernel * 2017f updates by James Tabor @@ -215,19 +218,19 @@ INIT static VOID init_kernel(void) /* Now process CONFIG.SYS */ DoConfig(); - lastdrive = Config.cfgLastdrive; - if (lastdrive < nblkdev) - lastdrive = nblkdev; - /* and do final buffer allocation. */ PostConfig(); - /* Now config the final file system */ + /* Init the file system on emore time */ FsConfig(); /* and process CONFIG.SYS one last time to load device drivers. */ DoConfig(); configDone(); + + /* Now config the final file system */ + FsConfig(); + #endif /* Now to initialize all special flags, etc. */ mem_access_mode = FIRST_FIT; @@ -347,7 +350,7 @@ INIT VOID FsConfig(VOID) if (i < nblkdev) { CDSp->cds_table[i].cdsDpb = &blk_devices[i]; - CDSp->cds_table[i].cdsFlags = 0x4000; + CDSp->cds_table[i].cdsFlags = CDSPHYSDRV; } else { @@ -446,10 +449,10 @@ VOID init_device(struct dhdr FAR * dhp, BYTE FAR * cmdLine) blk_devices[nblkdev].dpb_subunit = Index; blk_devices[nblkdev].dpb_device = dhp; blk_devices[nblkdev].dpb_flags = M_CHANGED; - if ((CDSp) != 0) + if ((CDSp != 0) && (nblkdev <= lastdrive)) { CDSp->cds_table[nblkdev].cdsDpb = &blk_devices[nblkdev]; - CDSp->cds_table[nblkdev].cdsFlags = 0x4000; + CDSp->cds_table[nblkdev].cdsFlags = CDSPHYSDRV; } ++nblkdev; } diff --git a/kernel/memmgr.c b/kernel/memmgr.c index 8f6a6659..1bc0474c 100644 --- a/kernel/memmgr.c +++ b/kernel/memmgr.c @@ -35,8 +35,8 @@ static BYTE *memmgrRcsId = "$Id$"; /* * $Log$ - * Revision 1.1 2000/05/06 19:35:26 jhall1 - * Initial revision + * Revision 1.2 2000/05/08 04:30:00 jimtabor + * Update CVS to 2020 * * Revision 1.4 2000/03/09 06:07:11 kernel * 2017f updates by James Tabor diff --git a/kernel/misc.c b/kernel/misc.c index 0fe55814..509946eb 100644 --- a/kernel/misc.c +++ b/kernel/misc.c @@ -34,8 +34,8 @@ static BYTE *miscRcsId = "$Id$"; /* * $Log$ - * Revision 1.1 2000/05/06 19:35:27 jhall1 - * Initial revision + * Revision 1.2 2000/05/08 04:30:00 jimtabor + * Update CVS to 2020 * * Revision 1.4 2000/03/09 06:07:11 kernel * 2017f updates by James Tabor diff --git a/kernel/network.c b/kernel/network.c index f627d607..9bc42ce9 100644 --- a/kernel/network.c +++ b/kernel/network.c @@ -36,8 +36,14 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ - * Revision 1.1 2000/05/06 19:35:27 jhall1 - * Initial revision + * Revision 1.2 2000/05/08 04:30:00 jimtabor + * Update CVS to 2020 + * + * Revision 1.5 2000/03/31 05:40:09 jtabor + * Added Eric W. Biederman Patches + * + * Revision 1.4 2000/03/17 22:59:04 kernel + * Steffen Kaiser's NLS changes * * Revision 1.3 2000/03/09 06:07:11 kernel * 2017f updates by James Tabor @@ -85,10 +91,11 @@ UCOUNT Remote_RW(UWORD func, UCOUNT n, BYTE FAR * bp, sft FAR * s, COUNT FAR * e dta = bp; rx = int2f_Remote_call(func, 0, n, 0, (VOID FAR *) s, 0, (VOID FAR *) & rc); dta = save_dta; - *err = rx; + *err = -rx; return ((UCOUNT) rc); } +#undef FIND_DEBUG /* */ @@ -96,21 +103,31 @@ COUNT Remote_find(UWORD func, UWORD attrib, BYTE FAR * name, REG dmatch FAR * dm { COUNT i, x; - BYTE FAR *p, + char FAR *p, *q; - struct dirent FAR *SDp = (struct dirent FAR *)&SearchDir; + struct dirent FAR *SDp = (struct dirent FAR *) &SearchDir; if (func == REM_FINDFIRST) { - truename(name, PriPathName, FALSE); SAttr = (BYTE) attrib; + i = truename(name, PriPathName, FALSE); + if (i != SUCCESS) { + return i; + } +#if defined(FIND_DEBUG) + printf("Remote Find: n='"); + p = name; while(*p) printf("%c", *p++); + printf("' p='"); + p = PriPathName; while(*p) printf("%c", *p++); + printf("'\n"); +#endif } - fsncopy(dta, (BYTE FAR *) & TempBuffer, 21); + fsncopy(dta, (BYTE FAR *) &TempBuffer, 21); p = dta; - dta = (BYTE FAR *) & TempBuffer; + dta = (BYTE FAR *) &TempBuffer; i = int2f_Remote_call(func, 0, 0, 0, 0, 0, 0); dta = p; - fsncopy((BYTE FAR *) & TempBuffer[1], &dta[1], 20); + fsncopy((BYTE FAR *) &TempBuffer[1], &dta[1], 20); if (i != 0) return i; @@ -157,53 +174,5 @@ COUNT Remote_find(UWORD func, UWORD attrib, BYTE FAR * name, REG dmatch FAR * dm return i; } -/* - * Open Existing Remote File, SDA First FN ptr -> Fully qualified name. - * open func 3d - * Create/Truncate w/o CDS Remote File - * Extended Open/Create File - */ -UWORD Remote_OCT(UWORD func, BYTE FAR * name, UWORD pw, sft FAR * s) -{ - truename(name, PriPathName, FALSE); - lpCurSft = (sfttbl FAR *) s; - return (int2f_Remote_call(func, 0, 0, 0, (VOID FAR *) s, 0, MK_FP(0, pw))); -} - -COUNT Remote_GSattr(UWORD func, BYTE FAR * name, UWORD FAR * attrp) -{ - static char srfa[10]; - COUNT drive; - struct cds FAR *p; - - truename(name, PriPathName, TRUE); - drive = PriPathName[0]; - drive -= 'A'; - truename(name, PriPathName, FALSE); - - if (CDSp->cds_table[drive].cdsFlags & 0x8000) - { - p = current_ldt; - current_ldt = &CDSp->cds_table[drive]; - if (func == REM_GETATTRZ) - { - - if (int2f_Remote_call(func, 0, 0, 0, 0, 0, (VOID FAR *) srfa) != 0) - { - current_ldt = p; - goto AEXIT; - } - *attrp = (UWORD) srfa[0]; - goto GEXIT; - } - int2f_Remote_call(func, 0, 0, 0, 0, 0, MK_FP(0, attrp)); - GEXIT: - current_ldt = p; - return (COUNT) 0; - } -AEXIT: - return (COUNT) 1; - -} diff --git a/kernel/newstuff.c b/kernel/newstuff.c index f4d0e99e..74b87afa 100644 --- a/kernel/newstuff.c +++ b/kernel/newstuff.c @@ -31,8 +31,17 @@ static BYTE *mainRcsId = "$Id$"; /* * $Log$ - * Revision 1.1 2000/05/06 19:35:27 jhall1 - * Initial revision + * Revision 1.2 2000/05/08 04:30:00 jimtabor + * Update CVS to 2020 + * + * Revision 1.8 2000/04/02 06:11:35 jtabor + * Fix ChgDir Code + * + * Revision 1.7 2000/04/02 05:30:48 jtabor + * Fix ChgDir Code + * + * Revision 1.6 2000/03/31 05:40:09 jtabor + * Added Eric W. Biederman Patches * * Revision 1.5 2000/03/09 06:07:11 kernel * 2017f updates by James Tabor @@ -175,21 +184,41 @@ int DosMkTmp(BYTE FAR * pathname, UWORD attr) } return rc; } + +COUNT get_verify_drive(char FAR *src) +{ + COUNT drive; + /* First, adjust the source pointer */ + src = adjust_far(src); + + /* Do we have a drive? */ + if (src[1] == ':') + { + drive = (src[0] | 0x20) - 'a'; + } + else + drive = default_drive; + if ((drive < 0) || (drive > lastdrive)) { + drive = DE_INVLDDRV; + } + return drive; +} + /* * Added support for external and internal calls. * Clean buffer before use. Make the true path and expand file names. * Example: *.* -> ????????.??? as in the currect way. */ -int truename(char FAR * src, char FAR * dest, COUNT t) +COUNT truename(char FAR * src, char FAR * dest, COUNT t) { static char buf[128] = "A:\\"; char *bufp = buf + 3; - COUNT i, - n; + COUNT i, n, x = 2; BYTE far *test; REG struct cds FAR *cdsp; fbcopy((VOID FAR *) "A:\\\0\0\0\0\0\0\0", (VOID FAR *) buf, 10); + dest[0] = '\0'; /* First, adjust the source pointer */ src = adjust_far(src); @@ -199,7 +228,7 @@ int truename(char FAR * src, char FAR * dest, COUNT t) { buf[0] = (src[0] | 0x20) + 'A' - 'a'; - if (buf[0] >= lastdrive + 'A') + if (buf[0] > lastdrive + 'A') return DE_PATHNOTFND; src += 2; @@ -207,24 +236,29 @@ int truename(char FAR * src, char FAR * dest, COUNT t) else buf[0] = default_drive + 'A'; - i = buf[0] - '@'; + i = buf[0] - 'A'; - cdsp = &CDSp->cds_table[i - 1]; + cdsp = &CDSp->cds_table[i]; + current_ldt = cdsp; - if (cdsp->cdsFlags & 0x8000) - { - QRemote_Fn(src, dest); + /* Always give the redirector a chance to rewrite the filename */ + fsncopy((BYTE FAR *) src, bufp -1, sizeof(buf) - (bufp - buf)); + if ((QRemote_Fn(buf, dest) == SUCCESS) && (dest[0] != '\0')) { + return SUCCESS; + } else { + bufp[-1] = '\\'; + } if (t == FALSE) { - bufp += 4; fsncopy((BYTE FAR *) & cdsp->cdsCurrentPath[0], (BYTE FAR *) & buf[0], cdsp->cdsJoinOffset); + bufp = buf + cdsp->cdsJoinOffset; + x = cdsp->cdsJoinOffset; *bufp++ = '\\'; } - } if (*src != '\\' && *src != '/') /* append current dir */ { - DosGetCuDir(i, bufp); + DosGetCuDir(i+1, bufp); if (*bufp) { while (*bufp) @@ -239,11 +273,15 @@ int truename(char FAR * src, char FAR * dest, COUNT t) while (*src) { char c; - - switch ((c = *src++)) + c = *src++; + switch (c) { /* added *.*, *., * support. */ +/* This doesn't expand cases like: foo*.* corrrectly + * disable it for now. + */ +#if 1 case '*': if (*src == '.') { @@ -269,7 +307,7 @@ int truename(char FAR * src, char FAR * dest, COUNT t) break; } } - +#endif case '/': /* convert to backslash */ case '\\': @@ -287,7 +325,7 @@ int truename(char FAR * src, char FAR * dest, COUNT t) for (bufp -= 2; *bufp != '\\'; bufp--) { - if (bufp < buf + 2) /* '..' illegal in root dir */ + if (bufp < buf + x) /* '..' illegal in root dir */ return DE_PATHNOTFND; } src++; diff --git a/kernel/nls.c b/kernel/nls.c index 582998fe..01e7d9fe 100644 --- a/kernel/nls.c +++ b/kernel/nls.c @@ -1,19 +1,15 @@ /****************************************************************/ /* */ /* nls.c */ -/* DOS-C */ +/* FreeDOS */ /* */ /* National Languge Support functions and data structures */ /* */ -/* Copyright (c) 1995, 1996 */ -/* Pasquale J. Villani */ -/* All Rights Reserved */ -/* */ -/* Copyright (c) 1995, 1996 */ +/* Copyright (c) 1995, 1996, 2000 */ /* Steffen Kaiser */ /* All Rights Reserved */ /* */ -/* This file is part of DOS-C. */ +/* This file is part of FreeDOS. */ /* */ /* DOS-C is free software; you can redistribute it and/or */ /* modify it under the terms of the GNU General Public License */ @@ -33,6 +29,8 @@ #include "portab.h" #include "globals.h" +#include "intr.h" +#include "nls.h" #ifdef VERSION_STRINGS static BYTE *RcsId = "$Id$"; @@ -40,446 +38,283 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ - * Revision 1.1 2000/05/06 19:35:29 jhall1 - * Initial revision - * - * Revision 1.7 2000/03/09 06:07:11 kernel - * 2017f updates by James Tabor - * - * Revision 1.6 1999/09/23 04:40:48 jprice - * *** empty log message *** - * - * Revision 1.4 1999/08/25 03:18:09 jprice - * ror4 patches to allow TC 2.01 compile. - * - * Revision 1.3 1999/05/03 06:25:45 jprice - * Patches from ror4 and many changed of signed to unsigned variables. - * - * Revision 1.2 1999/04/16 00:53:33 jprice - * Optimized FAT handling - * - * Revision 1.1.1.1 1999/03/29 15:41:24 jprice - * New version without IPL.SYS - * - * Revision 1.6 1999/02/08 05:55:57 jprice - * Added Pat's 1937 kernel patches - * - * Revision 1.5 1999/02/04 03:12:08 jprice - * Removed extra text. Made .exe smaller. - * - * Revision 1.4 1999/02/01 01:48:41 jprice - * Clean up; Now you can use hex numbers in config.sys. added config.sys screen function to change screen mode (28 or 43/50 lines) - * - * Revision 1.3 1999/01/30 08:28:12 jprice - * Clean up; Fixed bug with set attribute function. - * - * Revision 1.2 1999/01/22 04:13:26 jprice - * Formating + * Revision 1.2 2000/05/08 04:30:00 jimtabor + * Update CVS to 2020 * - * Revision 1.1.1.1 1999/01/20 05:51:01 jprice - * Imported sources + * Revision 1.8 2000/03/17 22:59:04 kernel + * Steffen Kaiser's NLS changes * - * - * Rev 1.4 04 Jan 1998 23:15:16 patv - * Changed Log for strip utility - * - * Rev 1.3 16 Jan 1997 12:46:54 patv - * pre-Release 0.92 feature additions - * - * Rev 1.2 29 May 1996 21:03:46 patv - * bug fixes for v0.91a - * - * Rev 1.1 19 Feb 1996 4:34:46 patv - * Corrected typo - * - * Rev 1.0 19 Feb 1996 3:21:46 patv - * Added NLS, int2f and config.sys processing */ -extern UWORD internalUpcase(UWORD c); - -#ifdef __TURBOC__ -/* TC 2.01 require these. :( -- ror4 */ -void __int__(int); -void __emit__(); -#endif - -/* one byte alignment */ - -#if defined(_MSC_VER) -#define asm __asm -#pragma pack(1) -#elif defined(_QC) || defined(__WATCOM__) -#pragma pack(1) -#elif defined(__ZTC__) -#pragma ZTC align 1 -#elif defined(__TURBOC__) && (__TURBOC__ > 0x202) -#pragma option -a- +#ifdef NLS_REORDER_POINTERS +#define getTable2 (&nlsInfo.actPkg->nlsPointer[0].pointer) +#define getTable4 (&nlsInfo.actPkg->nlsPointer[1].pointer) +#else +#define getTable2 getTable(2) +#define getTable4 getTable(4) +#define NEED_GET_TABLE #endif -struct ctryInfo -{ /* Country Information DOS-38 */ - WORD dateFmt; /* 0: USA, 1: Europe, 2: Japan */ - char curr[5]; /* ASCIZ of currency string */ - char thSep[2]; /* ASCIZ of thousand's separator */ - char point[2]; /* ASCIZ of decimal point */ - char dateSep[2]; /* ASCIZ of date separator */ - char timeSep[2]; /* ASCIZ of time separator */ - BYTE currFmt; /* format of currency: - bit 0: currency string is placed 0: before, 1: behind number - bit 1: currency string and number are separated by a space; 0: No, 1: Yes - */ - BYTE prescision; /* */ - BYTE timeFmt; /* time format: 0: 12 hours; 1: 24 houres */ - VOID(FAR * upCaseFct) (VOID); /* far call to a function mapping character in register AL */ - char dataSep[2]; /* ASCIZ of separator in data records */ -}; - -struct _VectorTable -{ - VOID FAR *Table; - BYTE FnCode; -}; - -struct _NlsInfo -{ - struct extCtryInfo - { - BYTE reserved[8]; - BYTE countryFname[64]; - WORD sysCodePage; - WORD nFnEntries; - struct _VectorTable VectorTable[6]; - - /* Extended Country Information DOS-65-01 */ - WORD countryCode; /* current COUNTRY= code */ - WORD codePage; /* current code page (CP) */ - - struct ctryInfo nlsCtryInfo; - } - nlsExtCtryInfo; - -/* characters of Yes/No prompt for DOS-65-23 */ - char yesCharacter; - char noCharacter; - -/* upcased characters for ECS-ASCII > 0x7f for DOS-65-02 */ - WORD upNCsize; /* number of entries in the following array */ - char upNormCh[128]; - -/* upcased characters for ECS-ASCII > 0x7f for file names for DOS-65-04 */ - WORD upFCsize; /* number of entries in the following array */ - char upFileCh[128]; - -/* collating sequence for ECS-ASCII 0..0xff for DOS-65-06 */ - WORD collSize; /* number of entries in the following array */ - char collSeq[256]; - -/* DBC support for DOS-65-07 */ - WORD dbcSize; /* number of entries in the following array */ - /* char dbcTable[1024]; no DBC support */ - WORD dbcEndMarker; /* contains always 0 */ - -/* in file names permittable characters for DOS-65-05 */ - struct chFileNames - { - WORD fnSize; /* size of this structure */ - BYTE dummy1; - char firstCh, - lastCh; /* first, last permittable character */ - BYTE dummy2; - char firstExcl, - lastExcl; /* first, last excluded character */ - BYTE dummy3; - BYTE numSep; /* number of file name separators */ - char fnSeparators[14]; - } - nlsFn; -} -nlsInfo -#ifdef INIT_NLS_049 -= /* let's initialize it with values for Germany */ -#include "049-437.nls" +#ifdef NLS_CACHE_POINTERS +#define normalCh nlsInfo.upTable +#define fileCh nlsInfo.fnamUpTable #else -= /* let's initialize it with default values (USA) */ -#include "001-437.nls" +#define normalCh getTable2 +#define fileCh getTable4 #endif - ; +#define yesChar nlsInfo.actPkg->yeschar +#define noChar nlsInfo.actPkg->nochar -#define normalCh nlsInfo.upNormCh -#define fileCh nlsInfo.upFileCh -#define yesChar nlsInfo.yesCharacter -#define noChar nlsInfo.noCharacter -#define PathSep(c) ((c)=='/'||(c)=='\\') -#define DriveChar(c) (((c)>='A'&&(c)<='Z')||((c)>='a'&&(c)<='z')) +#define NLS_MUX_COUNTRY_INFO(nls) ((nls)->muxCallingFlags & NLS_FLAG_INFO) +#define NLS_MUX_POINTERS(nls) ((nls)->muxCallingFlags & NLS_FLAG_POINTERS) +#define NLS_MUX_YESNO(nls) ((nls)->muxCallingFlags & NLS_FLAG_YESNO) +#define NLS_MUX_EXTERNAL_UP(nls) ((nls)->muxCallingFlags & NLS_FLAG_UP) +#define NLS_MUX_EXTERNAL_FUP(nls) ((nls)->muxCallingFlags & NLS_FLAG_FUP) -/* COUNTRY.SYS structures */ -struct CpiHeader -{ - BYTE name[8]; /* signature */ - BYTE reserved[8]; - WORD nPointers; /* size of following array */ - - struct - { - BYTE pointerType; /* always 1 */ - DWORD offset; /* offset to data */ - } - pointer[1]; -}; - -struct CountryRecord -{ - WORD length; /* size of record */ - WORD country; /* country code */ - WORD codePage; /* code page */ - WORD reserved[2]; - DWORD subCountryOffset; /* offset to data record */ -}; - -struct CountryTableDescr -{ - WORD length; /* size of structure */ - WORD id; /* table type id */ - DWORD offset; /* offset to table data */ -}; - -/* standard alignment */ - -#if defined (_MSC_VER) || defined(_QC) || defined(__WATCOMC__) -#pragma pack() -#elif defined (__ZTC__) -#pragma ZTC align -#elif defined(__TURBOC__) && (__TURBOC__ > 0x202) -#pragma option -a. -#endif -COUNT NlsFuncInst(VOID) -{ - BYTE cNlsRet; - -#ifndef __TURBOC__ - asm - { - xor bx, - bx - mov ax, - 0x1400 - int 0x2F - mov cNlsRet, - al - } -#else - _BX = 0; - _AX = 0x1400; - __int__(0x2f); - cNlsRet = _AL; -#endif - /* Return the al register as sign extended: */ - /* 0 == not installed, ok to install */ - /* 1 == not installed, not ok to install */ - /* -1 == installed */ - return cNlsRet; +static COUNT muxGo(int subfct, struct REGPACK *rp) +{ rp->r_si = FP_OFF(&nlsInfo); + rp->r_ds = FP_SEG(&nlsInfo); + rp->r_ax = 0x1400 | subfct; + intr(0x2f, rp); + return rp->r_ax; } -BOOL -GetGlblCodePage(UWORD FAR * ActvCodePage, UWORD FAR * SysCodePage) -{ - *ActvCodePage = nlsInfo.nlsExtCtryInfo.codePage; - *SysCodePage = nlsInfo.nlsExtCtryInfo.sysCodePage; - return TRUE; +/* + * Call NLSFUNC to load the NLS package + */ +COUNT muxLoadPkg(UWORD cp, UWORD cntry) +{ struct REGPACK r; + + /* Return the al register as sign extended: */ + /* 0x1400 == not installed, ok to install */ + /* 0x1401 == not installed, not ok to install */ + /* 0x14FF == installed */ + + r.r_bx = 0; /* make sure the NLSFUNC ID is updated */ + if(muxGo(0, &r) != 0x14ff) + return DE_FILENOTFND; /* No NLSFUNC --> no load */ + if(r.r_bx != NLS_FREEDOS_NLSFUNC_ID) + return DE_INVLDACC; + + /* OK, the correct NLSFUNC is available --> load pkg */ + r.r_dx = cntry; + r.r_bx = cp; + return muxGo(NLS_NLSFUNC_LOAD_PKG, &r); } -BOOL -SetGlblCodePage(UWORD FAR * ActvCodePage, UWORD FAR * SysCodePage) -{ - nlsInfo.nlsExtCtryInfo.codePage = *ActvCodePage; - nlsInfo.nlsExtCtryInfo.sysCodePage = *SysCodePage; - return TRUE; +static int muxBufGo(int subfct, int bp, UWORD cp, UWORD cntry, UWORD bufsize + , BYTE FAR *buf) +{ struct REGPACK r; + + r.r_bx = cntry; + r.r_dx = cp; + r.r_es = FP_SEG(*buf); + r.r_di = FP_OFF(*buf); + r.r_cx = bufsize; + r.r_bp = bp; + return muxGo(subfct, &r); } -UWORD SetCtryInfo(UBYTE FAR * lpShrtCode, UWORD FAR * lpLongCode, - BYTE FAR * lpTable, UBYTE * nRetCode) -{ - UWORD CntryCode; - UBYTE nNlsEntry; - UWORD uSegTable, - uOffTable; - UBYTE nLclRet; - - /* Get the Country Code according to the DOS silly rules. */ - if (0xff != *lpShrtCode) - CntryCode = *lpShrtCode; - else - CntryCode = *lpLongCode; - - /* If it's the same country code as what's installed, just */ - /* return because there's nothing to do. */ - if (CntryCode == nlsInfo.nlsExtCtryInfo.countryCode) - { - *nRetCode = 0; - return CntryCode; - } - - /* Check if nlsfunc is installed */ - if (NlsFuncInst() >= 0) - { - *nRetCode = 0xff; - return 0xffff; - } - - /* Get the country information from nlsfunc */ - uSegTable = FP_SEG(lpTable); - uOffTable = FP_OFF(lpTable); - -#ifndef __TURBOC__ - asm - { - push ds - mov bx, - CntryCode - mov ax, - uSegTable - mov dx, - uOffTable - mov ds, - ax - mov ax, - 0x1404 - int 0x2F - pop ds - mov CntryCode, - bx - mov nLclRet, - al - } -#else - /* XXX: this is ugly... but needed on `tcc' 2.01 without `tasm'. -- ror4 */ - __emit__(0x1e); /* push ds */ - _BX = CntryCode; - _AX = uSegTable; - _DX = uOffTable; - _DS = _AX; - _AX = 0x1404; - __int__(0x2f); - __emit__(0x1f); /* pop ds */ - CntryCode = _BX; - nLclRet = _AL; -#endif - *nRetCode = nLclRet; - return CntryCode; -} +#define mux38(cp,cc,bs,b) muxBufGo(4, 0, (cp), (cc), (bs), (b)) +#define mux65(s,cp,cc,bs,b) muxBufGo(2, (s), (cp), (cc), (bs), (b)) +#define muxUpMem(s,l,f) muxBufGo((f), 0, NLS_DEFAULT, NLS_DEFAULT, l, s) -UWORD GetCtryInfo(UBYTE FAR * lpShrtCode, UWORD FAR * lpLongCode, - BYTE FAR * lpTable) -{ - fbcopy((BYTE FAR *) & nlsInfo.nlsExtCtryInfo.nlsCtryInfo, - lpTable, sizeof(struct ctryInfo)); - return nlsInfo.nlsExtCtryInfo.countryCode; +static int muxYesNo(int ch) +{ struct REGPACK r; + + r.r_cx = ch; + return muxGo(NLS_NLSFUNC_YESNO, &r); } -BOOL ExtCtryInfo(UBYTE nOpCode, UWORD CodePageID, UWORD InfoSize, VOID FAR * Information) -{ - VOID FAR *lpSource; - COUNT nIdx; - if (0xffff != CodePageID) - { - UBYTE nNlsEntry; +/* + * Search the NLS package within the chain + * Also resolves the default values (-1) into the current + * active codepage/country code. + */ +struct nlsPackage FAR *searchPackage(UWORD *cp, UWORD *cntry) +{ struct nlsPackage FAR *nls; - if (NlsFuncInst() >= 0) - return FALSE; + if(*cp == NLS_DEFAULT) + *cp = nlsInfo.actPkg->cntryInfo.codePage; + if(*cntry == NLS_DEFAULT) + *cntry = nlsInfo.actPkg->cntryInfo.countryCode; -#ifndef __TURBOC__ - asm - { - mov bp, - word ptr nOpCode - mov bx, - CodePageID - mov si, - word ptr Information + 2 - mov ds, - si - mov si, - word ptr Information - mov ax, - 0x1402 - int 0x2F - cmp al, - 0 - mov nNlsEntry, - al - } -#else - /* XXX: again, this is ugly... -- ror4 */ - __emit__(0x1e, 0x55, 0x56); /* push ds; push bp; push si */ - _BX = CodePageID; - _SI = ((WORD *) & Information)[1]; - _DS = _SI; - _SI = *(WORD *) & Information; - _BP = *(WORD *) & nOpCode; - _BP &= 0x00ff; - _AX = 0x1402; - __int__(0x2f); - nNlsEntry = _AL; - __emit__(0x5e, 0x5d, 0x1f); /* pop si; pop bp; pop ds */ -#endif + nls = &nlsInfo.chain; + while((nls->cntryInfo.codePage != *cp + || nls->cntryInfo.countryCode != *cntry) + && (nls = nls->nxt) != NULL); - if (0 != nNlsEntry) - return FALSE; + return nls; +} - return TRUE; - } +struct nlsPointerInf FAR *locateSubfct(struct nlsPackage FAR *nls + , UBYTE subfct) +{ int cnt; + struct nlsPointerInf FAR *p; - CodePageID = nlsInfo.nlsExtCtryInfo.codePage; + for(cnt = nls->numSubfct, p = &nls->nlsPointer[0] + ; cnt--; ++p) + if(p->subfct == subfct) + return p; - for (nIdx = 0; nIdx < nlsInfo.nlsExtCtryInfo.nFnEntries; nIdx++) - { - if (nlsInfo.nlsExtCtryInfo.VectorTable[nIdx].FnCode == nOpCode) - { - BYTE FAR *bp = Information; - lpSource = nlsInfo.nlsExtCtryInfo.VectorTable[nIdx].Table; - - if (nOpCode == 1) - { - bp++; /* first byte unused */ - - *bp = (BYTE) (sizeof(struct ctryInfo) + 4); - bp += 2; - - fbcopy(lpSource, bp, InfoSize > 3 ? InfoSize - 3 : 0); - } - else - { - *bp++ = nOpCode; - *((VOID FAR **) bp) = lpSource; - } - return TRUE; - } - } + return NULL; +} - return FALSE; +#ifdef NEED_GET_TABLE +/* search the table (from a subfct) from the active package */ +struct nlsPointerInf FAR *getTable(UBYTE subfct) +{ struct nlsPointerInf FAR *poi; + + if((poi = locateSubfct(nlsInfo.actPkg, subfct)) != NULL) + return poi; + + /* Failed --> return the hardcoded table */ + switch(subfct) { + case 2: return &nlsUpHardcodedTable; + case 4: return &nlsFnameUpHardcodedTable; + case 5: return &nlsFnameTermHardcodedTable; + case 6: return &nlsCollHardcodedTable; + } } +#endif -UWORD internalUpcase(UWORD c) +/* + * Copy a buffer and test the size of the buffer + * Returns SUCCESS on success; DE_INVLDFUNC on failure + */ +static COUNT cpyBuf(UBYTE FAR *dst, UBYTE FAR *src + , UWORD srclen, UWORD dstlen) { - if (!(c & 0x80)) - return c; + if(srclen <= dstlen) { + _fmemcpy((BYTE FAR*)dst, (BYTE FAR*)src, srclen); + return SUCCESS; + } + return DE_INVLDFUNC; /* buffer too small */ +} - return (c & 0xff00) | (nlsInfo.upNormCh[c & 0x7f] & 0xff); +/* + * Called for all subfunctions other than 0x20-0x23,& 0xA0-0xA2 + * of DOS-65 + */ +COUNT extCtryInfo(int subfct, UWORD codepage + , UWORD cntry, UWORD bufsize, UBYTE FAR * buf) +{ struct nlsPackage FAR*nls; /* NLS package to use to return the info from */ + int rc; + int muxOnCntryInfo, muxOnPointer; + struct nlsPointerInf FAR *poi; + + if(!buf) + return DE_INVLDDATA; + if(subfct == 0) /* Currently not supported */ + return DE_INVLDFUNC; + + /* nls := NLS package of cntry/codepage */ + if((nls = searchPackage(&codepage, &cntry)) == NULL) + /* requested NLS package is not loaded --> + pass the request to NLSFUNC */ + muxOnCntryInfo = muxOnPointer = TRUE; + else { + muxOnCntryInfo = NLS_MUX_COUNTRY_INFO(nls); + muxOnPointer = NLS_MUX_POINTERS(nls); + } + + if(subfct == 1) { /* return Extended Country Information */ + if(muxOnCntryInfo) + return mux65(1, codepage, cntry, bufsize, buf); + return cpyBuf(buf, (BYTE FAR*)&nls->cntryInfo + , nls->cntryInfo.size + 3, bufsize); + } + if(subfct == NLS_DOS_38) { /* return Country Information */ + if(muxOnCntryInfo) + return mux38(codepage, cntry, bufsize, buf); + return cpyBuf(buf, (BYTE FAR*)&nls->cntryInfo.dateFmt + , nls->cntryInfo.size - 4, bufsize); + } + + if(muxOnPointer) + return mux65(subfct, codepage, cntry, bufsize, buf); + + /* any other subfunction returns a pointer to any sort + of data; the pointer is located within the nlsPointers + array */ + if((poi = locateSubfct(nls, subfct)) != NULL) + return cpyBuf(buf, (UBYTE FAR *)poi + , sizeof(struct nlsPointerInf), bufsize); + + return DE_INVLDFUNC; } -char upMChar(UPMAP map, char ch) -/* upcase character ch according to the map */ -{ - return (ch >= 'a' && ch <= 'z') ? ch + 'A' - 'a' : - ((unsigned)ch > 0x7f ? map[ch & 0x7f] : ch); +/* + * Changes the current active codepage or cntry + */ +static COUNT setPackage(UWORD cp, UWORD cntry) +{ struct nlsPackage FAR*nls; /* NLS package to use to return the info from */ + int rc; + + /* nls := NLS package of cntry/codepage */ + if((nls = searchPackage(&cp, &cntry)) == NULL) { + /* not loaded --> invoke NLSFUNC to load it */ + if((rc = muxLoadPkg(cp, cntry)) != SUCCESS) + return rc; + if((nls = searchPackage(&cp, &cntry)) == NULL) + /* something went wrong */ + return DE_INVLDFUNC; + } + + nlsInfo.actPkg = nls; +#ifdef NLS_CACHE_POINTERS + /* Fill the quick-access pointers */ + nlsInfo.fnamUpTable = getTable4->pointer - 0x80; + nlsInfo.upTable = getTable2->pointer - 0x80; +#endif + return SUCCESS; } -VOID upMMem(UPMAP map, char FAR * str, unsigned len) +/* + * Called for DOS-38 get info + * + * Note: DOS-38 does not receive the size of the buffer; therefore + * it is assumed the buffer is large enough as described in RBIL, + * which is 34 bytes _hardcoded_. + */ +COUNT getCountryInformation(UWORD cntry, BYTE FAR *buf) +{ return extCtryInfo(NLS_DOS_38, NLS_DEFAULT, cntry, 34, buf); +} + +/* + * Called for DOS-38 set country code + */ +COUNT setCountryCode(UWORD cntry) +{ return setPackage(NLS_DEFAULT, cntry); +} + +/* + * Called for DOS-66-01 get CP + */ +COUNT getCodePage(UWORD FAR* actCP, UWORD FAR*sysCP) +{ *sysCP = nlsInfo.sysCodePage; + *actCP = nlsInfo.actPkg->cntryInfo.codePage; + return SUCCESS; +} +/* + * Called for DOS-66-02 set CP + * Note: One cannot change the system CP. Why it is necessary + * to specify it, is lost to me. (2000/02/13 ska) + */ +COUNT setCodePage(UWORD actCP, UWORD sysCP) +{ if(sysCP == NLS_DEFAULT || sysCP == nlsInfo.sysCodePage) + return setPackage(actCP, NLS_DEFAULT); + return DE_INVLDDATA; +} + + + +static VOID upMMem(unsigned char FAR *map, unsigned char FAR * str + , unsigned len) { REG unsigned c; @@ -495,9 +330,14 @@ VOID upMMem(UPMAP map, char FAR * str, unsigned len) while (--len); } -BYTE yesNo(char ch) /* returns: 0: ch == "No", 1: ch == "Yes", 2: ch crap */ + +BYTE yesNo(unsigned char ch) +/* returns: 0: ch == "No", 1: ch == "Yes", 2: ch crap */ { - ch = upMChar(normalCh, ch); + if(NLS_MUX_YESNO(nlsInfo.actPkg)) + return muxYesNo(ch); + + ch = upChar(ch); if (ch == noChar) return 0; if (ch == yesChar) @@ -505,163 +345,57 @@ BYTE yesNo(char ch) /* returns: 0: ch == "No", 1: ch == "Yes", 2: ch return 2; } -char upChar(char ch) /* upcase a single character */ -{ - return upMChar(normalCh, ch); -} - -VOID upString(char FAR * str) /* upcase a string */ -{ - upMMem(normalCh, str, fstrlen(str)); -} - -VOID upMem(char FAR * str, unsigned len) /* upcase a memory area */ +VOID upMem(unsigned char FAR * str, unsigned len) +/* upcase a memory area */ { +#ifndef NLS_CACHE_POINTERS + if(NLS_MUX_EXTERNAL_UP(nlsInfo.actPkg)) { + muxUpMem(str, len, NLS_NLSFUNC_UP); + return; + } +#endif upMMem(normalCh, str, len); } -char upFChar(char ch) /* upcase a single character for file names */ -{ - return upMChar(fileCh, ch); +unsigned char upChar(unsigned char ch) + /* upcase a single character */ +{ unsigned char buf[1]; + *buf = ch; + upMem((BYTE FAR*)buf, 1); + return *buf; } -VOID upFString(char FAR * str) /* upcase a string for file names */ +VOID upString(unsigned char FAR * str) +/* upcase a string */ { - upMMem(fileCh, str, fstrlen(str)); + upMem(str, fstrlen(str)); } -VOID upFMem(char FAR * str, unsigned len) /* upcase a memory area for file names */ +VOID upFMem(unsigned char FAR * str, unsigned len) +/* upcase a memory area for file names */ { +#ifndef NLS_CACHE_POINTERS + if(NLS_MUX_EXTERNAL_FUP(nlsInfo.actPkg)) { + muxUpMem(str, len, NLS_NLSFUNC_FUP); + return; + } +#endif upMMem(fileCh, str, len); } -/* ReadCountryTable(): +unsigned char upFChar(unsigned char ch) + /* upcase a single character for file names */ +{ unsigned char buf[1]; - * Loads a country information table. - */ + *buf = ch; + upFMem((BYTE FAR*)buf, 1); + return *buf; +} -static BOOL ReadCountryTable(COUNT file, WORD id, ULONG offset) +VOID upFString(unsigned char FAR * str) +/* upcase a string for file names */ { - VOID *buf; /* where to load the information */ - UWORD maxSize; /* max number of bytes to read */ - UWORD length; /* length of table in file */ - BOOL rc = TRUE; - - switch (id) - { - case 1: /* extended country information */ - buf = &nlsInfo.nlsExtCtryInfo.countryCode; - maxSize = sizeof(struct ctryInfo) + sizeof(WORD) * 2; - break; - - case 2: /* uppercase table */ - buf = &normalCh[0]; - maxSize = sizeof normalCh; - break; - - case 4: /* filename uppercase table */ - buf = &fileCh[0]; - maxSize = sizeof fileCh; - break; - - case 5: /* filename terminator table */ - buf = &nlsInfo.nlsFn.dummy1; - maxSize = sizeof(struct chFileNames) - sizeof(WORD); - break; - - case 6: /* collating sequence table */ - buf = &nlsInfo.collSeq[0]; - maxSize = sizeof nlsInfo.collSeq; - break; - - default: /* unknown or unsupported table - ignore */ - buf = 0; - break; - } - - if (buf) - { - dos_lseek(file, offset, 0); - dos_read(file, &length, sizeof(length)); - - if (length > maxSize) - length = maxSize; - - if (dos_read(file, buf, length) != length) - rc = FALSE; - - if (id == 1) - nlsInfo.nlsExtCtryInfo.nlsCtryInfo.upCaseFct = CharMapSrvc; - } - - return rc; + upFMem(str, fstrlen(str)); } -/* LoadCountryInfo(): - - * Searches a file in the COUNTRY.SYS format for an entry - * matching the specified code page and country code, and loads - * the corresponding information into memory. If code page is 0, - * the default code page for the country will be used. - * - * Returns TRUE if successful, FALSE if not. - */ -/* XXX: This function should be placed in `INIT_TEXT'. -- ror4 */ -BOOL FAR LoadCountryInfo(char FAR * filename, WORD ctryCode, WORD codePage) -{ - struct CpiHeader hdr; - struct CountryRecord ctry; - struct CountryTableDescr ct; - COUNT i, - nCountries, - nSubEntries; - ULONG currpos; - int rc = FALSE; - COUNT file; - - if ((file = dos_open(filename, 0)) < 0) - return rc; - - if (dos_read(file, &hdr, sizeof(hdr)) == sizeof(hdr)) - { - /* check signature */ - if (!fstrncmp(hdr.name, "\377COUNTRY", 8)) - { - dos_lseek(file, hdr.pointer[0].offset, 0); - dos_read(file, &nCountries, sizeof(nCountries)); - - /* search for matching country record */ - for (i = 0; i < nCountries; i++) - { - if (dos_read(file, &ctry, sizeof(ctry)) != sizeof(ctry)) - break; - - if (ctry.country == ctryCode && (!codePage || ctry.codePage == codePage)) - { - /* found country - now load the tables */ - dos_lseek(file, ctry.subCountryOffset, 0); - dos_read(file, &nSubEntries, sizeof(nSubEntries)); - currpos = ctry.subCountryOffset + sizeof(nSubEntries); - - for (i = 0; i < nSubEntries; i++) - { - dos_lseek(file, currpos, 0); - if (dos_read(file, &ct, sizeof(ct)) != sizeof(ct)) - break; - - currpos += ct.length + sizeof(ct.length); - ReadCountryTable(file, ct.id, ct.offset + 8); - } - - if (i == nSubEntries) - rc = TRUE; - - break; - } - } - } - } - dos_close(file); - return rc; -} diff --git a/kernel/nlssupt.asm b/kernel/nlssupt.asm index 1de71faa..c5474f6e 100644 --- a/kernel/nlssupt.asm +++ b/kernel/nlssupt.asm @@ -29,8 +29,11 @@ ; $Id$ ; ; $Log$ -; Revision 1.1 2000/05/06 19:35:29 jhall1 -; Initial revision +; Revision 1.2 2000/05/08 04:30:00 jimtabor +; Update CVS to 2020 +; +; Revision 1.3 2000/03/17 22:59:04 kernel +; Steffen Kaiser's NLS changes ; ; Revision 1.2 1999/08/10 17:57:13 jprice ; ror4 2011-02 patch @@ -69,7 +72,7 @@ segment _TEXT global _CharMapSrvc - extern _internalUpcase:wrt TGROUP + extern _upChar:wrt TGROUP ; ; CharMapSrvc: ; User callable character mapping service. @@ -89,8 +92,11 @@ _CharMapSrvc: mov ds, dx push ax - call _internalUpcase - add sp, byte 2 + call _upChar + ;add sp, byte 2 // next POP retrieves orig AX + + pop bx + mov ah, bh ; keep hibyte untouched pop bx pop cx diff --git a/kernel/prf.c b/kernel/prf.c index c0eff709..8cae78a8 100644 --- a/kernel/prf.c +++ b/kernel/prf.c @@ -34,8 +34,8 @@ static BYTE *prfRcsId = "$Id$"; /* * $Log$ - * Revision 1.1 2000/05/06 19:35:29 jhall1 - * Initial revision + * Revision 1.2 2000/05/08 04:30:00 jimtabor + * Update CVS to 2020 * * Revision 1.3 2000/03/09 06:07:11 kernel * 2017f updates by James Tabor diff --git a/kernel/printer.asm b/kernel/printer.asm index d9834f61..e380f6c6 100644 --- a/kernel/printer.asm +++ b/kernel/printer.asm @@ -28,8 +28,8 @@ ; $Header$ ; ; $Log$ -; Revision 1.1 2000/05/06 19:35:30 jhall1 -; Initial revision +; Revision 1.2 2000/05/08 04:30:00 jimtabor +; Update CVS to 2020 ; ; Revision 1.2 1999/08/10 17:57:13 jprice ; ror4 2011-02 patch diff --git a/kernel/procsupt.asm b/kernel/procsupt.asm index b1a9cbbe..5a185db8 100644 --- a/kernel/procsupt.asm +++ b/kernel/procsupt.asm @@ -30,8 +30,8 @@ ; $Id$ ; ; $Log$ -; Revision 1.1 2000/05/06 19:35:30 jhall1 -; Initial revision +; Revision 1.2 2000/05/08 04:30:00 jimtabor +; Update CVS to 2020 ; ; Revision 1.4 1999/08/10 17:57:13 jprice ; ror4 2011-02 patch diff --git a/kernel/proto.h b/kernel/proto.h index b60c5b71..23dd1419 100644 --- a/kernel/proto.h +++ b/kernel/proto.h @@ -34,8 +34,14 @@ static BYTE *Proto_hRcsId = "$Id$"; /* * $Log$ - * Revision 1.1 2000/05/06 19:35:32 jhall1 - * Initial revision + * Revision 1.2 2000/05/08 04:30:00 jimtabor + * Update CVS to 2020 + * + * Revision 1.17 2000/03/31 05:40:09 jtabor + * Added Eric W. Biederman Patches + * + * Revision 1.16 2000/03/17 22:59:04 kernel + * Steffen Kaiser's NLS changes * * Revision 1.15 2000/03/09 06:07:11 kernel * 2017f updates by James Tabor @@ -176,6 +182,7 @@ INIT VOID strcat(REG BYTE * d, REG BYTE * s); BOOL check_break(void); UCOUNT GenericRead(COUNT hndl, UCOUNT n, BYTE FAR * bp, COUNT FAR * err, BOOL force_binary); +COUNT SftSeek(sft FAR *sftp, LONG new_pos, COUNT mode); UCOUNT DosRead(COUNT hndl, UCOUNT n, BYTE FAR * bp, COUNT FAR * err); UCOUNT DosWrite(COUNT hndl, UCOUNT n, BYTE FAR * bp, COUNT FAR * err); COUNT DosSeek(COUNT hndl, LONG new_pos, COUNT mode, ULONG * set_pos); @@ -195,6 +202,10 @@ COUNT DosSetFtime(COUNT hndl, date FAR * dp, time FAR * tp); COUNT DosGetFattr(BYTE FAR * name, UWORD FAR * attrp); COUNT DosSetFattr(BYTE FAR * name, UWORD FAR * attrp); BYTE DosSelectDrv(BYTE drv); +COUNT DosDelete(BYTE FAR *path); +COUNT DosRename(BYTE FAR * path1, BYTE FAR * path2); +COUNT DosMkdir(BYTE FAR * dir); +COUNT DosRmdir(BYTE FAR * dir); /*dosidle.asm */ VOID DosIdle_int(void); @@ -203,7 +214,7 @@ VOID DosIdle_int(void); VOID SpacePad(BYTE *, COUNT); COUNT ParseDosName(BYTE FAR *, COUNT *, BYTE *, BYTE *, BYTE *, BOOL); COUNT ParseDosPath(BYTE FAR *, COUNT *, BYTE *, BYTE FAR *); -BOOL IsDevice(BYTE * FileName); +BOOL IsDevice(BYTE FAR * FileName); /* dsk.c */ COUNT blk_driver(rqptr rp); @@ -250,11 +261,9 @@ COUNT dos_write(COUNT fd, VOID FAR * buffer, UCOUNT count); LONG dos_lseek(COUNT fd, LONG foffset, COUNT origin); UWORD dos_free(struct dpb *dpbp); -VOID dos_pwd(struct cds FAR * cdsp, BYTE FAR * s); - VOID trim_path(BYTE FAR * s); -COUNT dos_cd(struct cds FAR * cdsp, BYTE FAR * s); +COUNT dos_cd(struct cds FAR * cdsp, BYTE FAR * PathName); struct f_node FAR *get_f_node(void); VOID release_f_node(struct f_node FAR * fnp); @@ -361,22 +370,19 @@ VOID bcopy(REG BYTE * s, REG BYTE * d, REG COUNT n); __FAR_WRAPPER(VOID, fbcopy, (REG VOID FAR * s, REG VOID FAR * d, REG COUNT n)) /* nls.c */ -UWORD GetCtryInfo(UBYTE FAR * lpShrtCode, UWORD FAR * lpLongCode, BYTE FAR * lpTable); -UWORD SetCtryInfo(UBYTE FAR * lpShrtCode, UWORD FAR * lpLongCode, BYTE FAR * lpTable, UBYTE * nRetCode); -UWORD internalUpcase(UWORD c); -BOOL GetGlblCodePage(UWORD FAR * ActvCodePage, UWORD FAR * SysCodePage); -BOOL SetGlblCodePage(UWORD FAR * ActvCodePage, UWORD FAR * SysCodePage); -BOOL ExtCtryInfo(UBYTE nOpCode, UWORD CodePageID, UWORD InfoSize, VOID FAR * Information); -char upMChar(UPMAP map, char ch); -VOID upMMem(UPMAP map, char FAR * str, unsigned len); -BYTE yesNo(char ch); -char upChar(char ch); -VOID upString(char FAR * str); -VOID upMem(char FAR * str, unsigned len); -char upFChar(char ch); -VOID upFString(char FAR * str); -VOID upFMem(char FAR * str, unsigned len); -BOOL FAR LoadCountryInfo(char FAR * filename, WORD ctryCode, WORD codePage); +COUNT extCtryInfo(int subfct, UWORD codepage, + UWORD cntry, UWORD bufsize, UBYTE FAR * buf); +BYTE yesNo(unsigned char ch); +unsigned char upChar(unsigned char ch); +VOID upString(unsigned char FAR * str); +VOID upMem(unsigned char FAR * str, unsigned len); +unsigned char upFChar(unsigned char ch); +VOID upFString(unsigned char FAR * str); +VOID upFMem(unsigned char FAR * str, unsigned len); +COUNT setCountryCode(UWORD cntry); +COUNT getCountryInformation(UWORD cntry, BYTE FAR *buf); +COUNT getCodePage(UWORD FAR* actCP, UWORD FAR*sysCP); +COUNT setCodePage(UWORD actCP, UWORD sysCP); /* prf.c */ VOID put_console(COUNT c); @@ -432,7 +438,8 @@ VOID init_stacks(VOID FAR * stack_base, COUNT nStacks, WORD stackSize); /* newstuff.c */ int SetJFTSize(UWORD nHandles); int DosMkTmp(BYTE FAR * pathname, UWORD attr); -int truename(char FAR * src, char FAR * dest, COUNT t); +COUNT get_verify_drive(char FAR * src); +COUNT truename(char FAR * src, char FAR * dest, COUNT t); /* network.c */ COUNT int2f_Remote_call(UWORD func, UWORD b, UCOUNT n, UWORD d, VOID FAR * s, UWORD i, VOID FAR * data); @@ -440,10 +447,8 @@ COUNT QRemote_Fn(char FAR * s, char FAR * d); UWORD get_machine_name(BYTE FAR * netname); VOID set_machine_name(BYTE FAR * netname, UWORD name_num); -UWORD Remote_OCT(UWORD func, BYTE FAR * name, UWORD pw, sft FAR * s); UCOUNT Remote_RW(UWORD func, UCOUNT n, BYTE FAR * bp, sft FAR * s, COUNT FAR * err); COUNT Remote_find(UWORD func, UWORD attrib, BYTE FAR * name, REG dmatch FAR * dmp); -COUNT Remote_GSattr(UWORD func, BYTE FAR * name, UWORD FAR * attrp); /* procsupt.asm */ VOID INRPT FAR exec_user(iregs FAR * irp); diff --git a/kernel/segs.inc b/kernel/segs.inc index e2e78c56..271c27d1 100644 --- a/kernel/segs.inc +++ b/kernel/segs.inc @@ -29,8 +29,8 @@ ; $Header$ ; ; $Log$ -; Revision 1.1 2000/05/06 19:35:32 jhall1 -; Initial revision +; Revision 1.2 2000/05/08 04:30:00 jimtabor +; Update CVS to 2020 ; ; Revision 1.2 1999/08/10 17:57:13 jprice ; ror4 2011-02 patch diff --git a/kernel/serial.asm b/kernel/serial.asm index f7698197..660a1b68 100644 --- a/kernel/serial.asm +++ b/kernel/serial.asm @@ -28,8 +28,8 @@ ; $Header$ ; ; $Log$ -; Revision 1.1 2000/05/06 19:35:33 jhall1 -; Initial revision +; Revision 1.2 2000/05/08 04:30:00 jimtabor +; Update CVS to 2020 ; ; Revision 1.2 1999/08/10 17:57:13 jprice ; ror4 2011-02 patch diff --git a/kernel/strings.c b/kernel/strings.c index 70605ae2..47baf4e2 100644 --- a/kernel/strings.c +++ b/kernel/strings.c @@ -34,8 +34,8 @@ static BYTE *stringsRcsId = "$Id$"; /* * $Log$ - * Revision 1.1 2000/05/06 19:35:33 jhall1 - * Initial revision + * Revision 1.2 2000/05/08 04:30:00 jimtabor + * Update CVS to 2020 * * Revision 1.4 2000/03/09 06:07:11 kernel * 2017f updates by James Tabor diff --git a/kernel/sysclk.c b/kernel/sysclk.c index ddcc9876..4787e109 100644 --- a/kernel/sysclk.c +++ b/kernel/sysclk.c @@ -35,8 +35,8 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ - * Revision 1.1 2000/05/06 19:35:33 jhall1 - * Initial revision + * Revision 1.2 2000/05/08 04:30:00 jimtabor + * Update CVS to 2020 * * Revision 1.3 2000/03/09 06:07:11 kernel * 2017f updates by James Tabor diff --git a/kernel/syspack.c b/kernel/syspack.c index c221675c..7126f064 100644 --- a/kernel/syspack.c +++ b/kernel/syspack.c @@ -36,8 +36,8 @@ static BYTE *syspackRcsId = "$Id$"; /* * $Log$ - * Revision 1.1 2000/05/06 19:35:34 jhall1 - * Initial revision + * Revision 1.2 2000/05/08 04:30:00 jimtabor + * Update CVS to 2020 * * Revision 1.1.1.1 1999/03/29 15:42:21 jprice * New version without IPL.SYS diff --git a/kernel/systime.c b/kernel/systime.c index d4799ab3..5e8b1e9f 100644 --- a/kernel/systime.c +++ b/kernel/systime.c @@ -37,8 +37,8 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ - * Revision 1.1 2000/05/06 19:35:34 jhall1 - * Initial revision + * Revision 1.2 2000/05/08 04:30:00 jimtabor + * Update CVS to 2020 * * Revision 1.3 1999/05/04 16:40:30 jprice * ror4 date fix diff --git a/kernel/task.c b/kernel/task.c index 9c9928f9..fd15ae19 100644 --- a/kernel/task.c +++ b/kernel/task.c @@ -35,8 +35,11 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ - * Revision 1.1 2000/05/06 19:35:36 jhall1 - * Initial revision + * Revision 1.2 2000/05/08 04:30:00 jimtabor + * Update CVS to 2020 + * + * Revision 1.8 2000/03/31 05:40:09 jtabor + * Added Eric W. Biederman Patches * * Revision 1.7 2000/03/09 06:07:11 kernel * 2017f updates by James Tabor @@ -265,7 +268,9 @@ COUNT ChildEnv(exec_blk FAR * exp, UWORD * pChildEnvSeg, char far * pathname) *((UWORD FAR *) pDest)++ = 1; /* copy complete pathname */ - truename(pathname, pDest, TRUE); + if ((RetCode = truename(pathname, pDest, TRUE)) != SUCCESS) { + return RetCode; + } /* Theoretically one could either: + resize the already allocated block to best-fit behind the pathname, or From d7060f0ace8e6a6d28c0e05237a9aa4f229982d0 Mon Sep 17 00:00:00 2001 From: Jim Tabor Date: Mon, 8 May 2000 23:01:16 +0000 Subject: [PATCH 004/671] Update CVS to 2020 git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@8 6ac86273-5f31-0410-b378-82cca8765d1b --- hdr/nls.h | 370 ++++++++++++++++++++++++++++++++++++++++++++++++ kernel/intr.asm | 92 ++++++++++++ kernel/intr.h | 9 ++ kernel/nls_hc.c | 194 +++++++++++++++++++++++++ 4 files changed, 665 insertions(+) create mode 100644 hdr/nls.h create mode 100644 kernel/intr.asm create mode 100644 kernel/intr.h create mode 100644 kernel/nls_hc.c diff --git a/hdr/nls.h b/hdr/nls.h new file mode 100644 index 00000000..56391d65 --- /dev/null +++ b/hdr/nls.h @@ -0,0 +1,370 @@ +/****************************************************************/ +/* */ +/* NLS.H */ +/* FreeDOS */ +/* */ +/* National Language Support data structures */ +/* */ +/* Copyright (c) 1995, 1996, 2000 */ +/* Steffen Kaiser */ +/* All Rights Reserved */ +/* */ +/* This file is part of FreeDOS. */ +/* */ +/* DOS-C is free software; you can redistribute it and/or */ +/* modify it under the terms of the GNU General Public License */ +/* as published by the Free Software Foundation; either version */ +/* 2, or (at your option) any later version. */ +/* */ +/* DOS-C is distributed in the hope that it will be useful, but */ +/* WITHOUT ANY WARRANTY; without even the implied warranty of */ +/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See */ +/* the GNU General Public License for more details. */ +/* */ +/* You should have received a copy of the GNU General Public */ +/* License along with DOS-C; see the file COPYING. If not, */ +/* write to the Free Software Foundation, 675 Mass Ave, */ +/* Cambridge, MA 02139, USA. */ +/****************************************************************/ + +/* one byte alignment */ + +#if defined(_MSC_VER) +#define asm __asm +#pragma pack(1) +#elif defined(_QC) || defined(__WATCOM__) +#pragma pack(1) +#elif defined(__ZTC__) +#pragma ZTC align 1 +#elif defined(__TURBOC__) && (__TURBOC__ > 0x202) +#pragma option -a- +#endif + +/* + * Description of the organization of NLS information -- 2000/02/13 ska + * + * Glossar: + * NLS package -- NLS information incl. any code required to access or + * correctly interprete this particular information + * + * Abbreviation: + * (NLS) pkg -- NLS package + * + * The code included into the kernel does "only" support NLS packages + * structurally compatible with the one of the U.S.A. / CP437. + * I guess that most NLS packages has been tweaked to be compatible + * so that this is not a real limitation, but for all other packages + * the external NLSFUNC can supply every piece of code necessary. + * To allow this the interface between the kernel and NLSFUNC has been + * extended; at same time the interface has been reduced, because some + * of the API functions do not seem to offer any functionality required + * for now. This, however, may be a misinterpretation because of + * lack of understanding. + * + * The supported structure consists of the following assumptions: + * 1) The pkg must contain the tables 2 (Upcase character), 4 + * (Upcase filename character) and 5 (filename termination + * characters); because they are internally used. + * 2) The tables 2 and 4 must contain exactly 128 (0x80) characters. + * The character at index 0 corresponses to character 128 (0x80). + * The characters in the range of 0..0x7f are constructed out of + * the 7-bit US-ASCII (+ control characters) character set and are + * upcased not through the table, but by the expression: + * (ch >= 'a' && ch <= 'z')? ch - 'a' + 'A': ch + * with: 'a' == 97; 'z' == 122; 'A' == 65 + * + * It seems that pure DOS can internally maintain two NLS pkgs: + * NLS#1: The hardcoded pkg of U.S.A. on CP437, and + * NLS#2: the pkg loaded via COUNTRY= from within CONFIG.SYS. + * I do interprete this behaviour as follows: + * CONFIG.SYS is read in more passes; before COUTRY= can be evaluated, + * many actions must be performed, e.g. to load kernel at all, open + * CONFIG.SYS and begin reading. The kernel requires at least one + * NLS information _before_ COUNTRY= has been evaluated - the upcase + * table. To not implement the same function multiple times, e.g. + * to upcase with and without table, the kernel uses the default + * NLS pkg until a more appropriate can be loaded and hopes that + * the BIOS (and the user) can live with its outcome. + * Though, theoretically, the hardcoded NLS pkg could be purged + * or overwritten once the COUNTRY= statement has been evaluated. + * It would be possible that this NLS pkg internally performs different + * purposes, for now this behaviour will be kept. + * + * The current implementation extendeds the above "two maintained + * NLS pkgs" into that the kernel chains all NLS pkgs loaded in + * memory into one single linked list. When the user does neither + * wants to load other NLS pkgs without executing NLSFUNC and the + * loaded NLS pkgs do not contain code themselves, no other code is + * required, but some memory to store the NLS pkgs into. + * + * Furthermore, because the kernel needs to include the code for the + * hardcoded NLS pkg anyway, every NLS pkg can use it; so only + * NLS pkgs that structurally differ from U.S.A./CP437 actually need + * to add any code and residently install the MUX handler for NLSFUNC. + * This technique reduces the overhead calling the MUX handler, when + * it is not needed. + * + * The kernel can be instructed to pass any subfunction of DOS-65 to + * MUX-14-02, including the character upcase subfunctions 0x20-0x22 and + * 0xA0-0xA2 as well as 0x23 (yes/no response). That way upcase table can + * be supported (by reducing performance) that do not contain exactly 128 + * characters or where the lower portion is not constructed from the 7-bit + * US-ASCII character set. + * To do so, each NLS pkg contains some flags specifying if to pass a + * set of subfunctions to MUX-14-02, the sets include: + * set#1: filename character upcase 0xA0-0xA2 + * set#2: character upcase 0x20-0x22 + * set#3: yes/no response 0x23 + * set#4: Extended Country Information (Includes DOS-38) + * set#5: Anything else (usually picks a pointer from an array) + * + * Win9x supports to change the individual portions of a NLS pkg + * through DOS-65-00; also there are no references what happens when + * a program changes the areas addressed by returned pointers. The + * current implementation does _not_ support changes of the NLS pkg + * except by invoking DOS-38 (Set Country Code) or DOS-66 (Set Codepage). + * Future implementations might offer this ability; to reduce the + * overhead introduced by this feature, the macro NLS_MODIFYABLE_DATA + * enables the appropriate code. + * NLS_MODIFYABLE_DATA is *disabled* by default. + * + * The tables 2 and 4 (upcase tables) are relatively accessed often, + * but theoretically these tables could be loacted at any position + * of the pointer array. If the macro NLS_REORDER_POINTERS is enabled, + * both NLSFUNC and the internal loader will reorder the pointers + * array so that mandatory tables are located at predictable indexes. + * This removes that the kernel must search for the table when + * one of the DOS-65-[2A]x function is called or a filename has been + * passed in (which must be uppercased to be suitable for internal + * purpose). However, when some program try to tweak the internal + * tables this assumption could be wrong. + * NLS_REORDER_POINTERS is *enabled* by default. + * + * A second performance boost can be achieved, if the kernel shall + * support *only* NLS pkgs that apply to the structure mentioned above, + * thus, contain only characters 0x80-0xFF and the range 0x00-0x7F + * is upcased as 7-bit US-ASCII. In this case when upcasing the + * NLS pkg is bypassed at all, but cached pointers are used, which + * point directly to the upcased characters. Because I don't know + * existing NLS pkgs, this feature may be not very trustworthy; also + * when the NLS pkg is switched bypassing DOS, the cached pointers + * won't be updated, also by enabling this macro the MUX-flags are + * ignored for the sub-functions DOS-65-[2A][0-2], therefore: + * NLS_CACHE_POINTERS is *disabled* by default. + */ + +/* Define if some user program possibly modifies the value of the internal + tables or the DOS-65-00 (Set Country Information) API function + is to be supported. */ +/* Currently unimplemented! -- 2000/02/13 ska*/ +/* #define NLS_MODIFYABLE_DATA */ + +/* Define if the pointer array shall be reordered to allow a quick + access to often used and mandatoryly present tables. */ +#define NLS_REORDER_POINTERS + +/* Define if the kernel is to cache the time-consuming search results. + Doing so could lead to imporper functionality, if the active + codepage or country ID is changed bypassing the DOS API. */ +/* #define NLS_CACHE_POINTERS */ + + +/* + * How the kernel and NLSFUNC communicate with each other + */ + /* Must be returned by NLSFUNC upon MUX-14-00 */ +#define NLS_FREEDOS_NLSFUNC_ID 0x534b + /* MUX-14 subfunction called by the kernel to load a specific + NLS package */ +#define NLS_NLSFUNC_LOAD_PKG 0x4b + /* MUX-14 subfunction called when to externally upcase */ +#define NLS_NLSFUNC_UP 0x61 + /* MUX-14 subfunction called when to externally upcase filenames */ +#define NLS_NLSFUNC_FUP 0x69 + /* Internally used to represent DOS-38 */ +#define NLS_DOS_38 0x7365 + /* MUX-14 subfunction called when to check yes/nochar */ +#define NLS_NLSFUNC_YESNO 0x72 + + /* Flags for the communication with NLSFUNC */ +#define NLS_FLAG_INFO 0x001 +#define NLS_FLAG_POINTERS 0x002 +#define NLS_FLAG_YESNO 0x004 +#define NLS_FLAG_UP 0x008 +#define NLS_FLAG_FUP 0x010 + +/* To ease the maintainance this header file is included to + a) define the "normal" structures, where all the non-fixed size + arrays are noted with length "1", and + b) define the hardcoded NLS package for U.S.A. -- CP437 + If the macro NLS_HARDCODED is defined, the structures are modifed + to result into structures with the correct length. + + When NLS_NO_VARS is defined, no prototypes of the global + variables are included, useful in sources defining the hardcoded + information, but require the normal types, too. +*/ +#ifndef NLS_HARDCODED + /* Use the default of length == 1 */ +#define NLS_POINTERS 1 +#define NLS_FNAMSEPS 1 +#define NLS_DBCSENTR 1 +#define __join(a,b) a +#define mkName(a) a + +#else + +#define __join(a,b) a##b +#define mkName(a) __join(a,NLS_HARDCODED) + +#endif + + /* No codepage / country code given */ +#define NLS_DEFAULT ((UWORD)-1) + +#ifndef NLS_HARDCODED +/* + * This is the data in the exact order returned by DOS-65-01 + */ +struct nlsExtCtryInfo +{ + UBYTE subfct; /* always 1 */ + WORD size; /* size of this structure + without this WORD itself */ + WORD countryCode; /* current country code */ + WORD codePage; /* current code page (CP) */ + + /* + * This is the data in the exact order as to return on + * DOS-38; it is also the most (important) part of DOS-65-01 + */ + /* Note: The ASCIZ strings might become + a totally different understanding with + DBCS (Double Byte Character Support) */ + WORD dateFmt; /* order of portions of date + 0: mm/dd/yyyy (USA) + 1: dd/mm/yyyy (Europe) + 2: yyyy/mm/dd (Japan) + */ + char curr[5]; /* ASCIZ of currency string */ + char thSep[2]; /* ASCIZ of thousand's separator */ + char point[2]; /* ASCIZ of decimal point */ + char dateSep[2]; /* ASCIZ of date separator */ + char timeSep[2]; /* ASCIZ of time separator */ + BYTE currFmt; /* format of currency: + bit 0: currency string is placed + 0: before number + 1: behind number + bit 1: currency string and number are + separated by a space + 0: No + 1: Yes + bit 2: currency string replaces decimal + sign + 0: No + 1: Yes + */ + BYTE prescision; /* of monetary numbers */ + BYTE timeFmt; /* time format: + 0: 12 hours (append AM/PM) + 1: 24 houres + */ + VOID(FAR * upCaseFct) (VOID); /* far call to a function mapping the + character in register AL */ + char dataSep[2]; /* ASCIZ of separator in data records */ +}; + +struct nlsPointerInf { /* Information of DOS-65-0X is usually addressed + by a pointer */ + UBYTE subfct; /* number of the subfunction */ + VOID FAR *pointer; /* the pointer to be returned when the subfunction + of DOS-65 is called (Note: won't work for + subfunctions 0, 1, 0x20, 0x21, 0x22, 0x23, + 0xA0, 0xA1,& 0xA2 */ +}; +#endif + +struct mkName(nlsPackage) { /* the contents of one chain item of the + list of NLS packages */ + struct nlsPackage FAR *nxt; /* next item in chain */ + unsigned muxCallingFlags; /* combination of NLS_FLAGS-* */ + struct nlsExtCtryInfo cntryInfo; + char yeschar, nochar; /* yes / no character DOS-65-23 */ + unsigned numSubfct; /* number of supported sub-functions */ + struct nlsPointerInf nlsPointer[NLS_POINTERS]; /* grows dynamically */ +}; + +struct mkName(nlsDBCS) { + UWORD numEntries; + UWORD dbcsTbl[NLS_DBCSENTR]; +}; + +#ifndef NLS_HARDCODED +struct nlsCharTbl { + /* table containing a list of characters */ + WORD numEntries; /* number of entries of this table. + If <= 0x80, the first element of + the table corresponse to character 0x80 */ + unsigned char tbl[1]; /* grows dynamically */ +}; +struct nlsCharTbl128{ + WORD numEntries; + unsigned char tbl[128]; +}; +struct nlsCharTbl256{ + WORD numEntries; + unsigned char tbl[256]; +}; +#endif + +/* in file names permittable characters for DOS-65-05 */ +struct mkName(nlsFnamTerm) { + WORD size; /* size of this structure */ + BYTE dummy1; + char firstCh, + lastCh; /* first, last permittable character */ + BYTE dummy2; + char firstExcl, + lastExcl; /* first, last excluded character */ + BYTE dummy3; + BYTE numSep; /* number of file name separators */ + char separators[NLS_FNAMSEPS]; /* grows dynamically */ +}; + +#ifndef NLS_NO_VARS +struct mkName(nlsInfoBlock) { /* This block contains all information + shared by the kernel and the external NLSFUNC program */ + char FAR *fname; /* filename from COUNTRY= */ + UWORD sysCodePage; /* system code page */ + struct nlsPackage FAR *actPkg; /* current NLS package */ +#ifdef NLS_CACHE_POINTERS + unsigned char FAR *fnamUpTable; /* upcase table for filenames */ + unsigned char FAR *upTable; /* normal upcase table */ +#endif + struct mkName(nlsPackage) chain; /* first item of info chain -- + hardcoded U.S.A. */ +}; + +extern struct mkName(nlsInfoBlock) nlsInfo; +extern struct mkName(nlsFnamTerm) nlsFnameTermHardcodedTable; +extern struct mkName(nlsDBCS) nlsDBCSHardcodedTable; +extern struct __join(nlsCharTbl,128) nlsUpHardcodedTable; +extern struct __join(nlsCharTbl,128) nlsFnameUpHardcodedTable; +extern struct __join(nlsCharTbl,256) nlsCollHardcodedTable; +#endif + +#undef NLS_POINTERS +#undef NLS_FNAMSEPS +#undef NLS_DBCSENTR +#undef __join(a,b) +#undef mkName(a) + +/* standard alignment */ + +#if defined (_MSC_VER) || defined(_QC) || defined(__WATCOMC__) +#pragma pack() +#elif defined (__ZTC__) +#pragma ZTC align +#elif defined(__TURBOC__) && (__TURBOC__ > 0x202) +#pragma option -a. +#endif diff --git a/kernel/intr.asm b/kernel/intr.asm new file mode 100644 index 00000000..5704729e --- /dev/null +++ b/kernel/intr.asm @@ -0,0 +1,92 @@ +; File: +; intr.asm +; Description: +; Assembly implementation of calling an interrupt +; +; Copyright (c) 2000 +; Steffen Kaiser +; All Rights Reserved +; +; This file is part of FreeDOS. +; +; FreeDOS is free software; you can redistribute it and/or +; modify it under the terms of the GNU General Public License +; as published by the Free Software Foundation; either version +; 2, or (at your option) any later version. +; +; DOS-C is distributed in the hope that it will be useful, but +; WITHOUT ANY WARRANTY; without even the implied warranty of +; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See +; the GNU General Public License for more details. +; +; You should have received a copy of the GNU General Public +; License along with DOS-C; see the file COPYING. If not, +; write to the Free Software Foundation, 675 Mass Ave, +; Cambridge, MA 02139, USA. +; + + + %include "segs.inc" + +segment _TEXT +; +; void intr(nr, rp) +; REG int nr +; REG struct REGPACK *rp +; +; + global _intr +_intr: + push bp ; Standard C entry + mov bp,sp + push si + push di + push ds + push es + + mov ax, [bp+4] ; interrupt number + mov [CS:intr?1-1], al + jmp short intr?2 ; flush the instruction cache +intr?2 mov bx, [bp+6] ; regpack structure + mov ax, [bx] + mov cx, [bx+4] + mov dx, [bx+6] + mov bp, [bx+8] + mov di, [bx+10] + mov si, [bx+12] + push Word [bx+14] ; ds + mov es, [bx+16] + mov bx, [bx+2] + pop ds + + int 0 +intr?1: + + pushf + push ds + push bx + mov bx, sp + mov ds, [SS:bx+8] + mov bx, [ss:bx+20] ; address of REGPACK + mov [bx], ax + pop ax + mov [bx+2], ax + mov [bx+4], cx + mov [bx+6], dx + mov [bx+8], bp + mov [bx+10], di + mov [bx+12], si + pop ax + mov [bx+14], ax + mov [bx+16], es + pop ax + mov [bx+18], ax + + pop es + pop ds + pop di + pop si + pop bp + ret + + diff --git a/kernel/intr.h b/kernel/intr.h new file mode 100644 index 00000000..be03c575 --- /dev/null +++ b/kernel/intr.h @@ -0,0 +1,9 @@ +/* +*/ + +struct REGPACK { + unsigned r_ax, r_bx, r_cx, r_dx; + unsigned r_bp, r_di, r_si, r_ds, r_es, r_flags; +}; + +extern void intr(int intrnr, struct REGPACK *rp); diff --git a/kernel/nls_hc.c b/kernel/nls_hc.c new file mode 100644 index 00000000..1d20071e --- /dev/null +++ b/kernel/nls_hc.c @@ -0,0 +1,194 @@ +/****************************************************************/ +/* */ +/* nls_hc.c */ +/* FreeDOS */ +/* */ +/* National Languge Support hardcoded NLS package */ +/* */ +/* Copyright (c) 2000 */ +/* Steffen Kaiser */ +/* All Rights Reserved */ +/* */ +/* This file is part of DOS-C. */ +/* */ +/* DOS-C is free software; you can redistribute it and/or */ +/* modify it under the terms of the GNU General Public License */ +/* as published by the Free Software Foundation; either version */ +/* 2, or (at your option) any later version. */ +/* */ +/* DOS-C is distributed in the hope that it will be useful, but */ +/* WITHOUT ANY WARRANTY; without even the implied warranty of */ +/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See */ +/* the GNU General Public License for more details. */ +/* */ +/* You should have received a copy of the GNU General Public */ +/* License along with DOS-C; see the file COPYING. If not, */ +/* write to the Free Software Foundation, 675 Mass Ave, */ +/* Cambridge, MA 02139, USA. */ +/****************************************************************/ + +#include "portab.h" +#include "globals.h" +#define NLS_NO_VARS +#include "nls.h" + +#undef NLS_NO_VARS +#define NLS_HARDCODED US +#define NLS_POINTERS 5 +#define NLS_FNAMSEPS 14 +#define NLS_DBCSENTR 1 +#include "nls.h" + + +/* + * Hardcoded NLS package for U.S.A. CP437 + */ +struct nlsCharTbl128 nlsUpHardcodedTable = { + 128, /* upcase table */ + { + '\x80' ,'\x9a' ,'E' ,'A' ,'\x8e' ,'A' ,'\x8f' ,'\x80' /* 0 - 7 */ + ,'E' ,'E' ,'E' ,'I' ,'I' ,'I' ,'\x8e' ,'\x8f' /* 8 - 15 */ + ,'\x90' ,'\x92' ,'\x92' ,'O' ,'\x99' ,'O' ,'U' ,'U' /* 16 - 23 */ + ,'Y' ,'\x99' ,'\x9a' ,'\x9b' ,'\x9c' ,'\x9d' ,'\x9e' ,'\x9f' /* 24 - 31 */ + ,'A' ,'I' ,'O' ,'U' ,'\xa5' ,'\xa5' ,'\xa6' ,'\xa7' /* 32 - 39 */ + ,'\xa8' ,'\xa9' ,'\xaa' ,'\xab' ,'\xac' ,'\xad' ,'\xae' ,'\xaf' /* 40 - 47 */ + ,'\xb0' ,'\xb1' ,'\xb2' ,'\xb3' ,'\xb4' ,'\xb5' ,'\xb6' ,'\xb7' /* 48 - 55 */ + ,'\xb8' ,'\xb9' ,'\xba' ,'\xbb' ,'\xbc' ,'\xbd' ,'\xbe' ,'\xbf' /* 56 - 63 */ + ,'\xc0' ,'\xc1' ,'\xc2' ,'\xc3' ,'\xc4' ,'\xc5' ,'\xc6' ,'\xc7' /* 64 - 71 */ + ,'\xc8' ,'\xc9' ,'\xca' ,'\xcb' ,'\xcc' ,'\xcd' ,'\xce' ,'\xcf' /* 72 - 79 */ + ,'\xd0' ,'\xd1' ,'\xd2' ,'\xd3' ,'\xd4' ,'\xd5' ,'\xd6' ,'\xd7' /* 80 - 87 */ + ,'\xd8' ,'\xd9' ,'\xda' ,'\xdb' ,'\xdc' ,'\xdd' ,'\xde' ,'\xdf' /* 88 - 95 */ + ,'\xe0' ,'\xe1' ,'\xe2' ,'\xe3' ,'\xe4' ,'\xe5' ,'\xe6' ,'\xe7' /* 96 - 103 */ + ,'\xe8' ,'\xe9' ,'\xea' ,'\xeb' ,'\xec' ,'\xed' ,'\xee' ,'\xef' /* 104 - 111 */ + ,'\xf0' ,'\xf1' ,'\xf2' ,'\xf3' ,'\xf4' ,'\xf5' ,'\xf6' ,'\xf7' /* 112 - 119 */ + ,'\xf8' ,'\xf9' ,'\xfa' ,'\xfb' ,'\xfc' ,'\xfd' ,'\xfe' ,'\xff' /* 120 - 127 */ + } +}; +struct nlsCharTbl128 nlsFnameUpHardcodedTable = { + 128, /* file name upcase table */ + { + '\x80' ,'\x9a' ,'E' ,'A' ,'\x8e' ,'A' ,'\x8f' ,'\x80' /* 0 - 7 */ + ,'E' ,'E' ,'E' ,'I' ,'I' ,'I' ,'\x8e' ,'\x8f' /* 8 - 15 */ + ,'\x90' ,'\x92' ,'\x92' ,'O' ,'\x99' ,'O' ,'U' ,'U' /* 16 - 23 */ + ,'Y' ,'\x99' ,'\x9a' ,'\x9b' ,'\x9c' ,'\x9d' ,'\x9e' ,'\x9f' /* 24 - 31 */ + ,'A' ,'I' ,'O' ,'U' ,'\xa5' ,'\xa5' ,'\xa6' ,'\xa7' /* 32 - 39 */ + ,'\xa8' ,'\xa9' ,'\xaa' ,'\xab' ,'\xac' ,'\xad' ,'\xae' ,'\xaf' /* 40 - 47 */ + ,'\xb0' ,'\xb1' ,'\xb2' ,'\xb3' ,'\xb4' ,'\xb5' ,'\xb6' ,'\xb7' /* 48 - 55 */ + ,'\xb8' ,'\xb9' ,'\xba' ,'\xbb' ,'\xbc' ,'\xbd' ,'\xbe' ,'\xbf' /* 56 - 63 */ + ,'\xc0' ,'\xc1' ,'\xc2' ,'\xc3' ,'\xc4' ,'\xc5' ,'\xc6' ,'\xc7' /* 64 - 71 */ + ,'\xc8' ,'\xc9' ,'\xca' ,'\xcb' ,'\xcc' ,'\xcd' ,'\xce' ,'\xcf' /* 72 - 79 */ + ,'\xd0' ,'\xd1' ,'\xd2' ,'\xd3' ,'\xd4' ,'\xd5' ,'\xd6' ,'\xd7' /* 80 - 87 */ + ,'\xd8' ,'\xd9' ,'\xda' ,'\xdb' ,'\xdc' ,'\xdd' ,'\xde' ,'\xdf' /* 88 - 95 */ + ,'\xe0' ,'\xe1' ,'\xe2' ,'\xe3' ,'\xe4' ,'\xe5' ,'\xe6' ,'\xe7' /* 96 - 103 */ + ,'\xe8' ,'\xe9' ,'\xea' ,'\xeb' ,'\xec' ,'\xed' ,'\xee' ,'\xef' /* 104 - 111 */ + ,'\xf0' ,'\xf1' ,'\xf2' ,'\xf3' ,'\xf4' ,'\xf5' ,'\xf6' ,'\xf7' /* 112 - 119 */ + ,'\xf8' ,'\xf9' ,'\xfa' ,'\xfb' ,'\xfc' ,'\xfd' ,'\xfe' ,'\xff' /* 120 - 127 */ + } +}; +struct nlsFnamTermUS nlsFnameTermHardcodedTable = { + 22, /* size of permittable character structure */ + 1, /* reserved */ + '\x00' ,'\xff', /* first/last permittable character */ + 0, /* reserved */ + '\x00' ,' ', /* first/last excluded character */ + 2, /* reserved */ + 14, /* number of separators */ + { /* separators */ + '.' ,'"' ,'/' ,'\\','[' ,']' ,':' ,'|', /* 0 - 7 */ + '<' ,'>' ,'+' ,'=' ,';' ,',' /* 8 - 13 */ + } +}; +struct nlsCharTbl256 nlsCollHardcodedTable = { + 256, /* collating sequence table */ + { + '\x00' ,'\x01' ,'\x02' ,'\x03' ,'\x04' ,'\x05' ,'\x06' ,'\x07' /* 0 - 7 */ + ,'\x08' ,'\x09' ,'\x0a' ,'\x0b' ,'\x0c' ,'\x0d' ,'\x0e' ,'\x0f' /* 8 - 15 */ + ,'\x10' ,'\x11' ,'\x12' ,'\x13' ,'\x14' ,'\x15' ,'\x16' ,'\x17' /* 16 - 23 */ + ,'\x18' ,'\x19' ,'\x1a' ,'\x1b' ,'\x1c' ,'\x1d' ,'\x1e' ,'\x1f' /* 24 - 31 */ + ,' ' ,'!' ,'"' ,'#' ,'$' ,'%' ,'&' ,'\'' /* 32 - 39 */ + ,'(' ,')' ,'*' ,'+' ,',' ,'-' ,'.' ,'/' /* 40 - 47 */ + ,'0' ,'1' ,'2' ,'3' ,'4' ,'5' ,'6' ,'7' /* 48 - 55 */ + ,'8' ,'9' ,':' ,';' ,'<' ,'=' ,'>' ,'?' /* 56 - 63 */ + ,'@' ,'A' ,'B' ,'C' ,'D' ,'E' ,'F' ,'G' /* 64 - 71 */ + ,'H' ,'I' ,'J' ,'K' ,'L' ,'M' ,'N' ,'O' /* 72 - 79 */ + ,'P' ,'Q' ,'R' ,'S' ,'T' ,'U' ,'V' ,'W' /* 80 - 87 */ + ,'X' ,'Y' ,'Z' ,'[' ,'\\',']' ,'^' ,'_' /* 88 - 95 */ + ,'`' ,'A' ,'B' ,'C' ,'D' ,'E' ,'F' ,'G' /* 96 - 103 */ + ,'H' ,'I' ,'J' ,'K' ,'L' ,'M' ,'N' ,'O' /* 104 - 111 */ + ,'P' ,'Q' ,'R' ,'S' ,'T' ,'U' ,'V' ,'W' /* 112 - 119 */ + ,'X' ,'Y' ,'Z' ,'{' ,'|' ,'}' ,'~' ,'\x7f' /* 120 - 127 */ + ,'C' ,'U' ,'E' ,'A' ,'A' ,'A' ,'A' ,'C' /* 128 - 135 */ + ,'E' ,'E' ,'E' ,'I' ,'I' ,'I' ,'A' ,'A' /* 136 - 143 */ + ,'E' ,'A' ,'A' ,'O' ,'O' ,'O' ,'U' ,'U' /* 144 - 151 */ + ,'Y' ,'O' ,'U' ,'$' ,'$' ,'$' ,'$' ,'$' /* 152 - 159 */ + ,'A' ,'I' ,'O' ,'U' ,'N' ,'N' ,'\xa6' ,'\xa7' /* 160 - 167 */ + ,'?' ,'\xa9' ,'\xaa' ,'\xab' ,'\xac' ,'!' ,'"' ,'"' /* 168 - 175 */ + ,'\xb0' ,'\xb1' ,'\xb2' ,'\xb3' ,'\xb4' ,'\xb5' ,'\xb6' ,'\xb7' /* 176 - 183 */ + ,'\xb8' ,'\xb9' ,'\xba' ,'\xbb' ,'\xbc' ,'\xbd' ,'\xbe' ,'\xbf' /* 184 - 191 */ + ,'\xc0' ,'\xc1' ,'\xc2' ,'\xc3' ,'\xc4' ,'\xc5' ,'\xc6' ,'\xc7' /* 192 - 199 */ + ,'\xc8' ,'\xc9' ,'\xca' ,'\xcb' ,'\xcc' ,'\xcd' ,'\xce' ,'\xcf' /* 200 - 207 */ + ,'\xd0' ,'\xd1' ,'\xd2' ,'\xd3' ,'\xd4' ,'\xd5' ,'\xd6' ,'\xd7' /* 208 - 215 */ + ,'\xd8' ,'\xd9' ,'\xda' ,'\xdb' ,'\xdc' ,'\xdd' ,'\xde' ,'\xdf' /* 216 - 223 */ + ,'\xe0' ,'S' ,'\xe2' ,'\xe3' ,'\xe4' ,'\xe5' ,'\xe6' ,'\xe7' /* 224 - 231 */ + ,'\xe8' ,'\xe9' ,'\xea' ,'\xeb' ,'\xec' ,'\xed' ,'\xee' ,'\xef' /* 232 - 239 */ + ,'\xf0' ,'\xf1' ,'\xf2' ,'\xf3' ,'\xf4' ,'\xf5' ,'\xf6' ,'\xf7' /* 240 - 247 */ + ,'\xf8' ,'\xf9' ,'\xfa' ,'\xfb' ,'\xfc' ,'\xfd' ,'\xfe' ,'\xff' /* 248 - 255 */ + } +}; +struct nlsDBCSUS nlsDBCSHardcodedTable = { + 0, /* no DBC support */ + 0, /* DBC end marker */ +}; + +struct nlsInfoBlockUS nlsInfo = { + (char FAR*)NULL /*fname*/ + ,437 /*sysCodePage*/ + ,(struct nlsPackage FAR*)&nlsInfo.chain /* actPkg */ +#ifdef NLS_CACHE_DATA + ,(struct nlsCharTbl FAR*)&nlsFnameUpHardcodedTable + ,(struct nlsCharTbl FAR*)&nlsUpHardcodedTable +#endif + , /* hardcoded nlsPackageUS */ { + (struct nlsPackage FAR*)NULL /* nxt */ + ,0 /* MUX calling flags */ + , /* Extended Country Information */ { + 1, /* subfct */ + 0x26, /* size */ + 1, /* country code */ + 437, /* code page */ + 0, /* date format */ + { + /* currency string */ + '$','\x00','\x00','\x00','\x00', /* 0 - 4 */ + }, + { /* thousand separator */ + ',' ,'\x00' /* 0 - 1 */ + }, + { /* decimal point */ + '.' ,'\x00' /* 0 - 1 */ + }, + { /* date separator */ + '-' ,'\x00' /* 0 - 1 */ + }, + { /* time separator */ + ':' ,'\x00' /* 0 - 1 */ + }, + 0, /* currency format */ + 2, /* currency prescision */ + 0, /* time format */ + CharMapSrvc, /* upcase function */ + { /* data separator */ + ',','\x00' /* 0 - 1 */ + } + } + , 'Y', 'N' /* yes / no */ + , 5 /* num of subfunctions */ + , /* subfunctions */ { + { 2, (VOID FAR*)&nlsUpHardcodedTable } /* #0 */ + , { 4, (VOID FAR*)&nlsFnameUpHardcodedTable } /* #1 */ + , { 5, (VOID FAR*)&nlsFnameTermHardcodedTable } /* #2 */ + , { 6, (VOID FAR*)&nlsCollHardcodedTable } /* #3 */ + , { 7, (VOID FAR*)&nlsDBCSHardcodedTable } /* #4 */ + } + } +}; From c80712f0885d0c99d00a1084cf322dc297c51d4f Mon Sep 17 00:00:00 2001 From: Jim Tabor Date: Tue, 9 May 2000 00:30:11 +0000 Subject: [PATCH 005/671] Clean up and Release git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@9 6ac86273-5f31-0410-b378-82cca8765d1b --- docs/intfns.txt | 7 +++++-- docs/readme.cvs | 13 ++++++------- kernel/inthndlr.c | 6 +++++- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/docs/intfns.txt b/docs/intfns.txt index de04dc0e..ccc2396d 100644 --- a/docs/intfns.txt +++ b/docs/intfns.txt @@ -140,10 +140,10 @@ int 21 Description State Ver Status 66h Code Page Functions active 3.30 supported 67h Set Maximum Handle Count active 3.30 supported 68h Commit File active 3.30 dummy func -69h GET/SET DISK SERIAL NUMBER active 4.00 not supported +69h GET/SET DISK SERIAL NUMBER active 4.00 supported 6ah COMMIT FILE (same as 68h) active 4.00 not supported 6bh NULL FUNCTION active 5.00 not supported -6ch Extended Open/Create active 4.00 not supported +6ch Extended Open/Create active 4.00 supported 71h LONG FILENAME FUNCTIONS active 7.00 not supported int 22: Program Termination Address. @@ -195,6 +195,9 @@ See COPYING in DOS-C root directory for license. $Id$ $Log$ +Revision 1.3 2000/05/09 00:29:50 jimtabor +Clean up and Release + Revision 1.2 2000/05/08 04:27:48 jimtabor Update CVS to 2020 diff --git a/docs/readme.cvs b/docs/readme.cvs index de51b310..c275bb07 100644 --- a/docs/readme.cvs +++ b/docs/readme.cvs @@ -1,15 +1,14 @@ You can check out the latest code (from a UNIX type machine) using CVS as follows: -cvs -d :pserver:guest@gcfl.net:/home/cvsroot login -Password: guest +cvs -z3 -d:pserver:anonymous@cvs.freedos.sourceforge.net:/home/cvsroot login +Password: Press the Enter key. Then, to get the kernel code: -cvs -d :pserver:guest@gcfl.net:/home/cvsroot checkout fdkernel - -To get the FreeCom code: -cvs -d :pserver:guest@gcfl.net:/home/cvsroot checkout FreeCom +cvs -z3 -d:pserver:anonymous@cvs.freedos.sourceforge.net:/home/cvsroot checkout +kernel You can also view the CVS code from the web at -http://www.gcfl.net/cgi-bin/cvsweb +http://freedos.sourceforge.net/ +Go to the CVS page. diff --git a/kernel/inthndlr.c b/kernel/inthndlr.c index f25b309c..6797c617 100644 --- a/kernel/inthndlr.c +++ b/kernel/inthndlr.c @@ -36,6 +36,9 @@ BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.3 2000/05/09 00:30:11 jimtabor + * Clean up and Release + * * Revision 1.2 2000/05/08 04:30:00 jimtabor * Update CVS to 2020 * @@ -1578,6 +1581,7 @@ VOID int21_service(iregs FAR * r) r->AL = 0xFF; break; +#if 0 /* Extended Open-Creat, not fully functional.*/ case 0x6c: @@ -1603,7 +1607,7 @@ VOID int21_service(iregs FAR * r) r->FLAGS &= ~FLG_CARRY; } break; - +#endif default: goto error_invalid; } From 97c632c033a76ba191fcb28d8788aeef29b3fdeb Mon Sep 17 00:00:00 2001 From: Jim Tabor Date: Tue, 9 May 2000 00:37:13 +0000 Subject: [PATCH 006/671] Clean up and Release git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@10 6ac86273-5f31-0410-b378-82cca8765d1b --- docs/readme.cvs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/readme.cvs b/docs/readme.cvs index c275bb07..e58ac431 100644 --- a/docs/readme.cvs +++ b/docs/readme.cvs @@ -1,12 +1,12 @@ You can check out the latest code (from a UNIX type machine) using CVS as follows: -cvs -z3 -d:pserver:anonymous@cvs.freedos.sourceforge.net:/home/cvsroot login +cvs -z3 -d:pserver:anonymous@cvs.freedos.sourceforge.net:/cvsroot/freedos login Password: Press the Enter key. Then, to get the kernel code: -cvs -z3 -d:pserver:anonymous@cvs.freedos.sourceforge.net:/home/cvsroot checkout -kernel +cvs -z3 -d:pserver:anonymous@cvs.freedos.sourceforge.net:/cvsroot/freedos +checkout kernel You can also view the CVS code from the web at From b7590bbfc0ddc0ce245c1a57920ac38c299cb050 Mon Sep 17 00:00:00 2001 From: Jim Tabor Date: Thu, 11 May 2000 03:57:10 +0000 Subject: [PATCH 007/671] Clean up and Release git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@11 6ac86273-5f31-0410-b378-82cca8765d1b --- bin/copying | 10 +++++----- bin/install.bat | 4 ++-- boot/boot.asm | 4 ++-- boot/boot.mak | 4 ++-- drivers/devend.asm | 4 ++-- drivers/device.mak | 4 ++-- drivers/floppy.asm | 4 ++-- drivers/getvec.asm | 4 ++-- drivers/rdpcclk.asm | 4 ++-- drivers/timer.asm | 4 ++-- drivers/wratclk.asm | 4 ++-- drivers/wrpcclk.asm | 4 ++-- lib/libm.mak | 4 ++-- 13 files changed, 29 insertions(+), 29 deletions(-) diff --git a/bin/copying b/bin/copying index b8cf3a1a..a43ea212 100644 --- a/bin/copying +++ b/bin/copying @@ -55,7 +55,7 @@ patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. - + GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION @@ -110,7 +110,7 @@ above, provided that you also meet all of these conditions: License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) - + These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in @@ -168,7 +168,7 @@ access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. - + 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is @@ -225,7 +225,7 @@ impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. - + 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License @@ -278,7 +278,7 @@ PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS - + Appendix: How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest diff --git a/bin/install.bat b/bin/install.bat index 8562e5e5..c000e62e 100644 --- a/bin/install.bat +++ b/bin/install.bat @@ -4,8 +4,8 @@ rem Create a distribution floppy rem rem $Header$ rem $Log$ -rem Revision 1.1 2000/05/06 19:34:23 jhall1 -rem Initial revision +rem Revision 1.2 2000/05/11 03:51:37 jimtabor +rem Clean up and Release rem rem Revision 1.3 1999/08/25 03:15:33 jprice rem ror4 patches to allow TC 2.01 compile. diff --git a/boot/boot.asm b/boot/boot.asm index 9fdcb9e7..aa7f55fd 100644 --- a/boot/boot.asm +++ b/boot/boot.asm @@ -28,8 +28,8 @@ ; $Log$ -; Revision 1.1 2000/05/06 19:34:38 jhall1 -; Initial revision +; Revision 1.2 2000/05/11 03:56:42 jimtabor +; Clean up and Release ; ; Revision 1.12 1999/09/25 06:42:18 jprice ; Optimize boot loader. Documentation. diff --git a/boot/boot.mak b/boot/boot.mak index b35efb2b..6dd3c105 100644 --- a/boot/boot.mak +++ b/boot/boot.mak @@ -5,8 +5,8 @@ # # $Log$ -# Revision 1.1 2000/05/06 19:34:38 jhall1 -# Initial revision +# Revision 1.2 2000/05/11 03:56:42 jimtabor +# Clean up and Release # # Revision 1.3 1999/04/23 03:44:17 jprice # Ported to NASM by ror4. Improvements diff --git a/drivers/devend.asm b/drivers/devend.asm index 0b890ed7..4433ed3c 100644 --- a/drivers/devend.asm +++ b/drivers/devend.asm @@ -30,8 +30,8 @@ ; $Header$ ; ; $Log$ -; Revision 1.1 2000/05/06 19:34:43 jhall1 -; Initial revision +; Revision 1.2 2000/05/11 03:56:20 jimtabor +; Clean up and Release ; ; Revision 1.3 1999/08/10 17:21:08 jprice ; ror4 2011-01 patch diff --git a/drivers/device.mak b/drivers/device.mak index 0448248c..62ed8e0e 100644 --- a/drivers/device.mak +++ b/drivers/device.mak @@ -5,8 +5,8 @@ # # $Log$ -# Revision 1.1 2000/05/06 19:34:43 jhall1 -# Initial revision +# Revision 1.2 2000/05/11 03:56:20 jimtabor +# Clean up and Release # # Revision 1.6 1999/08/25 03:16:36 jprice # ror4 patches to allow TC 2.01 compile. diff --git a/drivers/floppy.asm b/drivers/floppy.asm index d4ea2aac..9359c71d 100644 --- a/drivers/floppy.asm +++ b/drivers/floppy.asm @@ -30,8 +30,8 @@ ; $Id$ ; ; $Log$ -; Revision 1.1 2000/05/06 19:34:45 jhall1 -; Initial revision +; Revision 1.2 2000/05/11 03:56:20 jimtabor +; Clean up and Release ; ; Revision 1.4 1999/08/10 17:21:08 jprice ; ror4 2011-01 patch diff --git a/drivers/getvec.asm b/drivers/getvec.asm index 7270f38f..c8d044c6 100644 --- a/drivers/getvec.asm +++ b/drivers/getvec.asm @@ -30,8 +30,8 @@ ; $Header$ ; ; $Log$ -; Revision 1.1 2000/05/06 19:34:45 jhall1 -; Initial revision +; Revision 1.2 2000/05/11 03:56:20 jimtabor +; Clean up and Release ; ; Revision 1.3 1999/08/10 17:21:08 jprice ; ror4 2011-01 patch diff --git a/drivers/rdpcclk.asm b/drivers/rdpcclk.asm index 3456c5d9..cd0b8340 100644 --- a/drivers/rdpcclk.asm +++ b/drivers/rdpcclk.asm @@ -30,8 +30,8 @@ ; $Header$ ; ; $Log$ -; Revision 1.1 2000/05/06 19:34:45 jhall1 -; Initial revision +; Revision 1.2 2000/05/11 03:56:20 jimtabor +; Clean up and Release ; ; Revision 1.4 1999/08/10 17:21:08 jprice ; ror4 2011-01 patch diff --git a/drivers/timer.asm b/drivers/timer.asm index d5db3376..67972064 100644 --- a/drivers/timer.asm +++ b/drivers/timer.asm @@ -30,8 +30,8 @@ ; $Header$ ; ; $Log$ -; Revision 1.1 2000/05/06 19:34:45 jhall1 -; Initial revision +; Revision 1.2 2000/05/11 03:56:20 jimtabor +; Clean up and Release ; ; Revision 1.3 1999/08/10 17:21:08 jprice ; ror4 2011-01 patch diff --git a/drivers/wratclk.asm b/drivers/wratclk.asm index 27fa1223..41f21af7 100644 --- a/drivers/wratclk.asm +++ b/drivers/wratclk.asm @@ -30,8 +30,8 @@ ; $Header$ ; ; $Log$ -; Revision 1.1 2000/05/06 19:34:45 jhall1 -; Initial revision +; Revision 1.2 2000/05/11 03:56:20 jimtabor +; Clean up and Release ; ; Revision 1.3 1999/08/10 17:21:08 jprice ; ror4 2011-01 patch diff --git a/drivers/wrpcclk.asm b/drivers/wrpcclk.asm index bd9e6331..a6c8ab76 100644 --- a/drivers/wrpcclk.asm +++ b/drivers/wrpcclk.asm @@ -30,8 +30,8 @@ ; $Header$ ; ; $Log$ -; Revision 1.1 2000/05/06 19:34:45 jhall1 -; Initial revision +; Revision 1.2 2000/05/11 03:56:20 jimtabor +; Clean up and Release ; ; Revision 1.3 1999/08/10 17:21:08 jprice ; ror4 2011-01 patch diff --git a/lib/libm.mak b/lib/libm.mak index b043ed75..8086e21b 100644 --- a/lib/libm.mak +++ b/lib/libm.mak @@ -5,8 +5,8 @@ # # $Log$ -# Revision 1.1 2000/05/06 19:35:36 jhall1 -# Initial revision +# Revision 1.2 2000/05/11 03:57:10 jimtabor +# Clean up and Release # # Revision 1.6 1999/09/14 17:32:20 jprice # no message From c0a44e269f150d5483d26322576dad19461f1e41 Mon Sep 17 00:00:00 2001 From: Jim Tabor Date: Thu, 11 May 2000 04:24:51 +0000 Subject: [PATCH 008/671] Added Boot blk structs git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@12 6ac86273-5f31-0410-b378-82cca8765d1b --- hdr/device.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/hdr/device.h b/hdr/device.h index d2f8fc5f..9a37dc28 100644 --- a/hdr/device.h +++ b/hdr/device.h @@ -35,9 +35,16 @@ static BYTE *device_hRcsId = "$Id$"; /* * $Log$ + * Revision 1.3 2000/05/11 04:24:51 jimtabor + * Added Boot blk structs + * * Revision 1.2 2000/05/08 04:28:22 jimtabor * Update CVS to 2020 * + * $Log$ + * Revision 1.3 2000/05/11 04:24:51 jimtabor + * Added Boot blk structs + * * Revision 1.4 2000/04/29 05:13:16 jtabor * Added new functions and clean up code * @@ -195,6 +202,7 @@ struct dhdr #define ATTR_CHAR 0x8000 #define ATTR_IOCTL 0x4000 #define ATTR_BLDFAT 0x2000 +#define ATTR_REMOTE 0x1000 #define ATTR_EXCALLS 0x0800 #define ATTR_QRYIOCTL 0x0080 #define ATTR_GENIOCTL 0x0040 @@ -258,6 +266,14 @@ struct gblkio UWORD gbio_nsecs; }; +struct Gioc_media +{ + WORD ioc_level; + ULONG ioc_serialno; + BYTE ioc_volume[11]; + BYTE ioc_fstype[8]; +}; + /* */ /* Boot Block (Super Block) */ /* */ From e4835de11ed38f08665b2bd340895640ac1ba469 Mon Sep 17 00:00:00 2001 From: Jim Tabor Date: Thu, 11 May 2000 04:26:26 +0000 Subject: [PATCH 009/671] Added code for DOS FN 69 & 6C git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@13 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/blockio.c | 9 +++- kernel/dsk.c | 117 +++++++++++++++++++++++++++++++++++++++------- kernel/fatfs.c | 9 +++- kernel/inthndlr.c | 107 ++++++++++++++++++++++++++++++++++-------- kernel/ioctl.c | 38 ++++++++------- 5 files changed, 224 insertions(+), 56 deletions(-) diff --git a/kernel/blockio.c b/kernel/blockio.c index e3e0020d..a66ce742 100644 --- a/kernel/blockio.c +++ b/kernel/blockio.c @@ -37,9 +37,16 @@ static BYTE *blockioRcsId = "$Id$"; /* * $Log$ + * Revision 1.3 2000/05/11 04:26:26 jimtabor + * Added code for DOS FN 69 & 6C + * * Revision 1.2 2000/05/08 04:29:59 jimtabor * Update CVS to 2020 * + * $Log$ + * Revision 1.3 2000/05/11 04:26:26 jimtabor + * Added code for DOS FN 69 & 6C + * * Revision 1.15 2000/04/29 05:13:16 jtabor * Added new functions and clean up code * @@ -547,7 +554,7 @@ BOOL dskxfer(COUNT dsk, ULONG blkno, VOID FAR * buf, UWORD numblocks, COUNT mode { /* REG struct dpb *dpbp = &blk_devices[dsk]; */ - REG struct dpb *dpbp = CDSp->cds_table[dsk].cdsDpb; + REG struct dpb *dpbp = (struct dpb *)CDSp->cds_table[dsk].cdsDpb; for (;;) { diff --git a/kernel/dsk.c b/kernel/dsk.c index 2d70d897..120526f9 100644 --- a/kernel/dsk.c +++ b/kernel/dsk.c @@ -33,9 +33,16 @@ static BYTE *dskRcsId = "$Id$"; /* * $Log$ + * Revision 1.3 2000/05/11 04:26:26 jimtabor + * Added code for DOS FN 69 & 6C + * * Revision 1.2 2000/05/08 04:29:59 jimtabor * Update CVS to 2020 * + * $Log$ + * Revision 1.3 2000/05/11 04:26:26 jimtabor + * Added code for DOS FN 69 & 6C + * * Revision 1.6 2000/04/29 05:13:16 jtabor * Added new functions and clean up code * @@ -118,7 +125,9 @@ BOOL fl_format(); #define NDEV 8 /* only one for demo */ #define SEC_SIZE 512 /* size of sector in bytes */ #define N_RETRY 5 /* number of retries permitted */ -#define NENTRY 25 /* total size of dispatch table */ +#define NENTRY 26 /* total size of dispatch table */ + +extern BYTE FAR nblk_rel; union { @@ -138,7 +147,15 @@ static struct media_info COUNT mi_partidx; /* Index to partition array */ }; -static struct media_info miarray[NDEV]; /* Internal media info structs */ +static struct FS_info +{ + ULONG fs_serialno; + BYTE fs_volume[11]; + BYTE fs_fstype[8]; +}; + +static struct media_info miarray[NDEV]; /* Internal media info structs */ +static struct FS_info fsarray[NDEV]; static bpb bpbarray[NDEV]; /* BIOS parameter blocks */ static bpb *bpbptrs[NDEV]; /* pointers to bpbs */ @@ -177,6 +194,7 @@ WORD init(rqptr), mediachk(rqptr), bldbpb(rqptr), blockio(rqptr), + IoctlQueblk(rqptr), Genblkdev(rqptr), blk_error(rqptr); COUNT ltop(WORD *, WORD *, WORD *, COUNT, COUNT, LONG, byteptr); @@ -221,12 +239,13 @@ static WORD(*dispatch[NENTRY]) () = blk_error, /* Output till busy */ blk_error, /* undefined */ blk_error, /* undefined */ - Genblkdev, /* Generic Ioctl */ + Genblkdev, /* Generic Ioctl Call */ blk_error, /* undefined */ blk_error, /* undefined */ blk_error, /* undefined */ blk_error, /* Get Logical Device */ - blk_error /* Set Logical Device */ + blk_error, /* Set Logical Device */ + IoctlQueblk /* Ioctl Query */ }; #define SIZEOF_PARTENT 16 @@ -391,6 +410,9 @@ static WORD init(rqptr rp) miarray[Unit].mi_offset = 0l; miarray[Unit].mi_drive = Unit; + fsarray[Unit].fs_serialno = 0x12345678; + + bpbarray[Unit].bpb_nbyte = SEC_SIZE; bpbarray[Unit].bpb_nsector = 2; bpbarray[Unit].bpb_nreserved = 1; @@ -415,6 +437,7 @@ static WORD init(rqptr rp) rp->r_nunits = nUnits; rp->r_bpbptr = bpbptrs; rp->r_endaddr = device_end(); + nblk_rel = nUnits; /* make device header reflect units */ return S_DONE; } @@ -490,6 +513,10 @@ static WORD bldbpb(rqptr rp) getword(&((((BYTE *) & buffer.bytes[BT_BPB]))[BPB_NHEADS]), &bpbarray[rp->r_unit].bpb_nheads); getlong(&((((BYTE *) & buffer.bytes[BT_BPB])[BPB_HIDDEN])), &bpbarray[rp->r_unit].bpb_hidden); getlong(&((((BYTE *) & buffer.bytes[BT_BPB])[BPB_HUGE])), &bpbarray[rp->r_unit].bpb_huge); + + + getlong(&((((BYTE *) & buffer.bytes[0x27])[0])), &fsarray[rp->r_unit].fs_serialno); + #ifdef DSK_DEBUG printf("BPB_NBYTE = %04x\n", bpbarray[rp->r_unit].bpb_nbyte); printf("BPB_NSECTOR = %02x\n", bpbarray[rp->r_unit].bpb_nsector); @@ -511,6 +538,7 @@ static WORD bldbpb(rqptr rp) if (miarray[rp->r_unit].mi_size == 0) getlong(&((((BYTE *) & buffer.bytes[BT_BPB])[BPB_HUGE])), &miarray[rp->r_unit].mi_size); sector = miarray[rp->r_unit].mi_sectors; + if (head == 0 || sector == 0) { tmark(); @@ -518,6 +546,7 @@ static WORD bldbpb(rqptr rp) } miarray[rp->r_unit].mi_cyls = count / (head * sector); tmark(); + #ifdef DSK_DEBUG printf("BPB_NSECS = %04x\n", sector); printf("BPB_NHEADS = %04x\n", head); @@ -538,35 +567,87 @@ static COUNT write_and_verify(WORD drive, WORD head, WORD track, WORD sector, return fl_verify(drive, head, track, sector, count, buffer); } -static WORD Genblkdev(rqptr rp) +static WORD IoctlQueblk(rqptr rp) { - UWORD cmd = rp->r_count; + switch(rp->r_count){ + case 0x0860: + case 0x0866: + break; + default: + return S_ERROR; + } + return S_DONE; +} - switch(cmd){ - case 0x0860: +static WORD Genblkdev(rqptr rp) +{ + switch(rp->r_count){ + case 0x0860: /* get device parameters */ { - struct gblkio FAR * gblp = rp->r_trans; - - gblp->gbio_devtype = 0x05; - gblp->gbio_devattrib = 0x01; + struct gblkio FAR * gblp = (struct gblkio FAR *) rp->r_trans; + REG COUNT x = 5,y = 1,z = 0; + + if (!hd(miarray[rp->r_unit].mi_drive)){ + y = 2; + switch(miarray[rp->r_unit].mi_size) + { + case 640l: + case 720l: /* 320-360 */ + x = 0; + z = 1; + break; + case 1440l: /* 720 */ + x = 2; + break; + case 2400l: /* 1.2 */ + x = 1; + break; + case 2880l: /* 1.44 */ + x = 7; + break; + case 5760l: /* 2.88 almost forgot this one*/ + x = 9; + break; + default: + x = 8; /* any odd ball drives return this */ + } + } + gblp->gbio_devtype = (UBYTE) x; + gblp->gbio_devattrib = (UWORD) y; + gblp->gbio_media = (UBYTE) z; gblp->gbio_ncyl = miarray[rp->r_unit].mi_cyls; - gblp->gbio_media = 0; gblp->gbio_bpb = bpbarray[rp->r_unit]; gblp->gbio_nsecs = bpbarray[rp->r_unit].bpb_nsector; - - printf("GenBlkIO = %08lx\n", rp->r_trans); - printf("GenBlkIO = %08lx\n", gblp); break; } - case 0x0866: + case 0x0866: /* get volume serial number */ + { + REG COUNT i; + struct Gioc_media FAR * gioc = (struct Gioc_media FAR *) rp->r_trans; + struct FS_info FAR * fs = &fsarray[rp->r_unit]; + + gioc->ioc_serialno = fs->fs_serialno; + for(i = 0; i < 12 ;i++ ) + gioc->ioc_volume[i] = fs->fs_volume[i]; + for(i = 0; i < 9; i++ ) + gioc->ioc_fstype[i] = fs->fs_fstype[i]; + printf("DSK_IOCTL SN %lx \n" , &fs->fs_serialno); + printf("DSK_IOCTL SN %lx \n" , &fs->fs_volume); + printf("DSK_IOCTL SN %lx \n" , &gioc->ioc_serialno); + printf("DSK_IOCTL SN %lx \n" , &gioc->ioc_volume); + + } break; + default: + return S_ERROR; } - return S_DONE; } + + static WORD blockio(rqptr rp) { REG retry = N_RETRY, diff --git a/kernel/fatfs.c b/kernel/fatfs.c index 3f8eb527..f4ff6a83 100644 --- a/kernel/fatfs.c +++ b/kernel/fatfs.c @@ -36,9 +36,16 @@ BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.3 2000/05/11 04:26:26 jimtabor + * Added code for DOS FN 69 & 6C + * * Revision 1.2 2000/05/08 04:30:00 jimtabor * Update CVS to 2020 * + * $Log$ + * Revision 1.3 2000/05/11 04:26:26 jimtabor + * Added code for DOS FN 69 & 6C + * * Revision 1.23 2000/04/29 05:13:16 jtabor * Added new functions and clean up code * @@ -2140,7 +2147,7 @@ struct dhdr FAR *select_unit(COUNT drive) /* Just get the header from the dhdr array */ /* return blk_devices[drive].dpb_device; */ - return CDSp->cds_table[drive].cdsDpb; + return (struct dhdr FAR *)CDSp->cds_table[drive].cdsDpb; } diff --git a/kernel/inthndlr.c b/kernel/inthndlr.c index 6797c617..3b373394 100644 --- a/kernel/inthndlr.c +++ b/kernel/inthndlr.c @@ -36,21 +36,22 @@ BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.4 2000/05/11 04:26:26 jimtabor + * Added code for DOS FN 69 & 6C + * * Revision 1.3 2000/05/09 00:30:11 jimtabor * Clean up and Release * * Revision 1.2 2000/05/08 04:30:00 jimtabor * Update CVS to 2020 * - * Revision 1.25 2000/04/29 05:31:47 jtabor - * fix history + * $Log$ + * Revision 1.4 2000/05/11 04:26:26 jimtabor + * Added code for DOS FN 69 & 6C * * Revision 1.24 2000/04/29 05:13:16 jtabor * Added new functions and clean up code * - * Revision 1.23 2000/03/31 05:40:09 jtabor - * Added Eric W. Biederman Patches - * * Revision 1.22 2000/03/17 22:59:04 kernel * Steffen Kaiser's NLS changes * @@ -1021,11 +1022,9 @@ VOID int21_service(iregs FAR * r) } else { - - if(r->AL == 0x02) + if((r->AL == 0x02) || (r->AL == 0x03) || (r->AL == 0x04) || (r->AL == 0x05)) r->AX = r->CX; - - r->FLAGS &= ~FLG_CARRY; + r->FLAGS &= ~FLG_CARRY; } } break; @@ -1133,8 +1132,8 @@ VOID int21_service(iregs FAR * r) || ((psp FAR *) (MK_FP(cu_psp, 0)))->ps_parent == cu_psp) break; tsr = FALSE; - int2f_Remote_call(REM_PROCESS_END, 0, 0, 0, 0, 0, 0); - int2f_Remote_call(REM_CLOSEALL, 0, 0, 0, 0, 0, 0); + int2f_Remote_call(REM_PROCESS_END, 0, 0, 0, 0, 0, 0); + int2f_Remote_call(REM_CLOSEALL, 0, 0, 0, 0, 0, 0); if (ErrorMode) { ErrorMode = FALSE; @@ -1556,25 +1555,34 @@ VOID int21_service(iregs FAR * r) /* Get/Set Serial Number */ case 0x69: - r->BL = ( r->BL == 0 ? default_drive : r->BL - 1); - if (r->BL <= lastdrive) + rc = ( r->BL == 0 ? default_drive : r->BL - 1); + if (rc <= lastdrive) { - if (CDSp->cds_table[r->BL].cdsFlags & CDSNETWDRV) { - r->AX = 0x01; - goto error_out; + if (CDSp->cds_table[rc].cdsFlags & CDSNETWDRV) { + goto error_invalid; } switch(r->AL){ case 0x00: + r->AL = 0x0d; r->CX = 0x0866; rc = DosDevIOctl(r, (COUNT FAR *) & rc1); break; case 0x01: + r->AL = 0x0d; r->CX = 0x0846; rc = DosDevIOctl(r, (COUNT FAR *) & rc1); break; } - r->FLAGS &= ~FLG_CARRY; + if (rc1 != SUCCESS) + { + r->FLAGS |= FLG_CARRY; + r->AX = -rc1; + } + else + { + r->FLAGS &= ~FLG_CARRY; + } break; } else @@ -1582,11 +1590,37 @@ VOID int21_service(iregs FAR * r) break; #if 0 - /* Extended Open-Creat, not fully functional.*/ case 0x6c: switch(r->DL) { - case 0x01: + case 0x12: + { + COUNT x = 0; + if ((rc = DosOpen(MK_FP(r->DS, r->SI), 0)) >= 0) + { + DosClose(rc); + x = 1; + } + if ((rc = DosCreat(MK_FP(r->DS, r->SI), r->CX )) < 0 ) + goto error_exit; + else + { + x += 2; + r->CX = x; + r->AX = rc; + r->FLAGS &= ~FLG_CARRY; + } + } + break; + case 0x10: + if ((rc = DosOpen(MK_FP(r->DS, r->SI), 0)) >= 0) + { + DosClose(rc); + r->AX = 80; + r->FLAGS |= FLG_CARRY; + } + else + { if ((rc = DosCreat(MK_FP(r->DS, r->SI), r->CX )) < 0 ) goto error_exit; else @@ -1595,9 +1629,42 @@ VOID int21_service(iregs FAR * r) r->AX = rc; r->FLAGS &= ~FLG_CARRY; } + } + break; + case 0x02: + if ((rc = DosOpen(MK_FP(r->DS, r->SI), 0)) < 0) + goto error_exit; + DosClose(rc); + if ((rc = DosCreat(MK_FP(r->DS, r->SI), r->CX )) < 0 ) + goto error_exit; + else + { + r->CX = 0x03; + r->AX = rc; + r->FLAGS &= ~FLG_CARRY; + } break; - case 0x10: + case 0x11: + if ((rc = DosOpen(MK_FP(r->DS, r->SI), 0)) >= 0) + { + r->CX = 0x01; + r->AX = rc; + r->FLAGS &= ~FLG_CARRY; + } + else{ + if ((rc = DosCreat(MK_FP(r->DS, r->SI), r->CX )) < 0 ) + goto error_exit; + else + { + r->CX = 0x02; + r->AX = rc; + r->FLAGS &= ~FLG_CARRY; + } + } + break; + + case 0x01: if ((rc = DosOpen(MK_FP(r->DS, r->SI), r->BL )) < 0 ) goto error_exit; else diff --git a/kernel/ioctl.c b/kernel/ioctl.c index afb94b56..3d541773 100644 --- a/kernel/ioctl.c +++ b/kernel/ioctl.c @@ -35,9 +35,16 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.3 2000/05/11 04:26:26 jimtabor + * Added code for DOS FN 69 & 6C + * * Revision 1.2 2000/05/08 04:30:00 jimtabor * Update CVS to 2020 * + * $Log$ + * Revision 1.3 2000/05/11 04:26:26 jimtabor + * Added code for DOS FN 69 & 6C + * * Revision 1.4 2000/04/29 05:13:16 jtabor * Added new functions and clean up code * @@ -147,17 +154,19 @@ COUNT DosDevIOctl(iregs FAR * r, COUNT FAR * err) /* JT Fixed it */ r->BL = ( r->BL == 0 ? default_drive : r->BL - 1); + + printf("IOCTL bl = %04x\n", r->BL); + if (r->BL > lastdrive) { *err = DE_INVLDDRV; return 0; } else - { + { cdsp = &CDSp->cds_table[r->BL]; dpbp = cdsp->cdsDpb; - } - + } break; case 0x0b: @@ -186,7 +195,7 @@ COUNT DosDevIOctl(iregs FAR * r, COUNT FAR * err) case 0x01: /* sft_flags is a file, return an error because you */ /* can't set the status of a file. */ - if ((s->sft_flags & SFT_FDEVICE)) /* !*/ + if (!(s->sft_flags & SFT_FDEVICE)) { *err = DE_INVLDFUNC; return 0; @@ -209,14 +218,12 @@ COUNT DosDevIOctl(iregs FAR * r, COUNT FAR * err) case 0x03: nMode = C_IOCTLOUT; IoCharCommon: - if ((s->sft_flags & SFT_FDEVICE) - || ((r->AL == 0x10) && (s->sft_dev->dh_attr & ATTR_QRYIOCTL)) - || ((r->AL == 0x0c) && (s->sft_dev->dh_attr & ATTR_GENIOCTL))) - /* ! ! */ + || ((r->AL == 0x02 ) && (s->sft_dev->dh_attr & SFT_FIOCTL)) + || ((r->AL == 0x03 ) && (s->sft_dev->dh_attr & SFT_FIOCTL)) + || ((r->AL == 0x10) && (s->sft_dev->dh_attr & ATTR_QRYIOCTL)) + || ((r->AL == 0x0c) && (s->sft_dev->dh_attr & ATTR_GENIOCTL))) { - if (s->sft_dev->dh_attr & SFT_FIOCTL) - { CharReqHdr.r_unit = 0; CharReqHdr.r_length = sizeof(request); CharReqHdr.r_command = nMode; @@ -234,7 +241,6 @@ COUNT DosDevIOctl(iregs FAR * r, COUNT FAR * err) 00 : 0xff; } break; - } } *err = DE_INVLDFUNC; return 0; @@ -251,10 +257,10 @@ COUNT DosDevIOctl(iregs FAR * r, COUNT FAR * err) case 0x05: nMode = C_IOCTLOUT; IoBlockCommon: - if ((dpbp->dpb_device->dh_attr & ATTR_IOCTL) - || ((r->AL == 0x11) && (dpbp->dpb_device->dh_attr & ATTR_QRYIOCTL)) - || ((r->AL == 0x0d) && (dpbp->dpb_device->dh_attr & ATTR_GENIOCTL))) - /* ! ! */ + if ( ((r->AL == 0x04 ) && !(dpbp->dpb_device->dh_attr & ATTR_IOCTL)) + || ((r->AL == 0x05 ) && !(dpbp->dpb_device->dh_attr & ATTR_IOCTL)) + || ((r->AL == 0x11) && !(dpbp->dpb_device->dh_attr & ATTR_QRYIOCTL)) + || ((r->AL == 0x0d) && !(dpbp->dpb_device->dh_attr & ATTR_GENIOCTL))) { *err = DE_INVLDFUNC; return 0; @@ -315,7 +321,7 @@ COUNT DosDevIOctl(iregs FAR * r, COUNT FAR * err) case 0x09: if(cdsp->cdsFlags & CDSNETWDRV) - r->DX = 0x1000; + r->DX = ATTR_REMOTE; else r->DX = dpbp->dpb_device->dh_attr; break; From 771c10aa1465f0060f64b14a5342582df00dc58d Mon Sep 17 00:00:00 2001 From: Jim Tabor Date: Thu, 11 May 2000 06:14:45 +0000 Subject: [PATCH 010/671] Removed #if statement git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@14 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/inthndlr.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/kernel/inthndlr.c b/kernel/inthndlr.c index 3b373394..fa4d7178 100644 --- a/kernel/inthndlr.c +++ b/kernel/inthndlr.c @@ -36,6 +36,9 @@ BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.5 2000/05/11 06:14:45 jimtabor + * Removed #if statement + * * Revision 1.4 2000/05/11 04:26:26 jimtabor * Added code for DOS FN 69 & 6C * @@ -46,6 +49,9 @@ BYTE *RcsId = "$Id$"; * Update CVS to 2020 * * $Log$ + * Revision 1.5 2000/05/11 06:14:45 jimtabor + * Removed #if statement + * * Revision 1.4 2000/05/11 04:26:26 jimtabor * Added code for DOS FN 69 & 6C * @@ -1589,7 +1595,7 @@ VOID int21_service(iregs FAR * r) r->AL = 0xFF; break; -#if 0 + /* Extended Open-Creat, not fully functional.*/ case 0x6c: switch(r->DL) { @@ -1674,9 +1680,10 @@ VOID int21_service(iregs FAR * r) r->FLAGS &= ~FLG_CARRY; } break; -#endif + default: goto error_invalid; + } } From 7aa281e6c8dfff64bee09f745d6152f5174d256c Mon Sep 17 00:00:00 2001 From: Jim Tabor Date: Sun, 14 May 2000 17:07:52 +0000 Subject: [PATCH 011/671] Cleanup CRs git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@15 6ac86273-5f31-0410-b378-82cca8765d1b --- build.bat | 4 ++-- clean.bat | 4 ++-- clobber.bat | 4 ++-- config.m | 4 ++-- fdkernel.lsm | 6 +++--- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/build.bat b/build.bat index e5d752ef..894b1cab 100644 --- a/build.bat +++ b/build.bat @@ -5,8 +5,8 @@ rem batch file to build everything rem $Id$ rem $Log$ -rem Revision 1.1 2000/05/06 19:34:02 jhall1 -rem Initial revision +rem Revision 1.2 2000/05/14 17:05:39 jimtabor +rem Cleanup CRs rem rem Revision 1.5 1999/08/25 03:59:14 jprice rem New build batch files. diff --git a/clean.bat b/clean.bat index 5515f4ec..5c4f7e2e 100644 --- a/clean.bat +++ b/clean.bat @@ -5,8 +5,8 @@ rem batch file to clean everything rem $Id$ rem $Log$ -rem Revision 1.1 2000/05/06 19:34:02 jhall1 -rem Initial revision +rem Revision 1.2 2000/05/14 17:05:58 jimtabor +rem Cleanup CRs rem rem Revision 1.3 1999/08/25 03:59:14 jprice rem New build batch files. diff --git a/clobber.bat b/clobber.bat index 8105e741..b02d1b86 100644 --- a/clobber.bat +++ b/clobber.bat @@ -4,8 +4,8 @@ rem batch file to clobber everything rem $Id$ rem $Log$ -rem Revision 1.1 2000/05/06 19:34:02 jhall1 -rem Initial revision +rem Revision 1.2 2000/05/14 17:06:17 jimtabor +rem Cleanup CRs rem rem Revision 1.3 1999/08/25 03:59:14 jprice rem New build batch files. diff --git a/config.m b/config.m index 7769c8db..9ee0b349 100644 --- a/config.m +++ b/config.m @@ -48,8 +48,8 @@ # $Id$ # # $Log$ -# Revision 1.1 2000/05/06 19:34:02 jhall1 -# Initial revision +# Revision 1.2 2000/05/14 17:07:07 jimtabor +# Cleanup CRs # # Revision 1.3 1999/09/13 20:40:17 jprice # Added COMPILER variable diff --git a/fdkernel.lsm b/fdkernel.lsm index 2da0a9f9..2b35d73b 100644 --- a/fdkernel.lsm +++ b/fdkernel.lsm @@ -1,8 +1,8 @@ Begin3 Title: The FreeDOS Kernel -Version: 1.1.18 -Entered-date: 9 March 2000 -Description: The FreeDOS Kernel +Version: 1.1.20 +Entered-date: 5 May 2000 +Description: The FreeDOS Kernel. Keywords: kernel freedos dos msdos Author: kernel@gcfl.net (developers) Maintained-by: linux-guru@gcfl.net From 0de1924329446cc44cd2d9455d5416a4d072af79 Mon Sep 17 00:00:00 2001 From: Jim Tabor Date: Mon, 15 May 2000 05:28:09 +0000 Subject: [PATCH 012/671] Cleanup CRs git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@16 6ac86273-5f31-0410-b378-82cca8765d1b --- sys/bin2c.mak | 4 ++-- sys/sys.c | 11 ++++++++--- sys/sys.mak | 4 ++-- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/sys/bin2c.mak b/sys/bin2c.mak index aba8f415..fe19f8cb 100644 --- a/sys/bin2c.mak +++ b/sys/bin2c.mak @@ -5,8 +5,8 @@ # # $Log$ -# Revision 1.1 2000/05/06 19:35:36 jhall1 -# Initial revision +# Revision 1.2 2000/05/15 05:28:09 jimtabor +# Cleanup CRs # # Revision 1.6 1999/09/20 18:34:40 jprice # *** empty log message *** diff --git a/sys/sys.c b/sys/sys.c index fa0900c3..bf271d90 100644 --- a/sys/sys.c +++ b/sys/sys.c @@ -27,9 +27,12 @@ ***************************************************************/ /* $Log$ - * Revision 1.1 2000/05/06 19:35:37 jhall1 - * Initial revision + * Revision 1.2 2000/05/15 05:28:09 jimtabor + * Cleanup CRs * +/* Revision 1.10 2000/03/31 06:59:10 jprice +/* Added discription of program. +/* /* Revision 1.9 1999/09/20 18:34:40 jprice /* *** empty log message *** /* @@ -261,7 +264,9 @@ COUNT get_part(COUNT drive, COUNT idx) VOID main(COUNT argc, char **argv) { - if (argc != 2) + printf("FreeDOS System Installer v1.0\n\n"); + + if (argc != 2) { fprintf(stderr, "Usage: %s drive\n drive = A,B,etc.\n", pgm); exit(1); diff --git a/sys/sys.mak b/sys/sys.mak index 1ebe5751..307b0d6d 100644 --- a/sys/sys.mak +++ b/sys/sys.mak @@ -5,8 +5,8 @@ # # $Log$ -# Revision 1.1 2000/05/06 19:35:37 jhall1 -# Initial revision +# Revision 1.2 2000/05/15 05:28:09 jimtabor +# Cleanup CRs # # Revision 1.10 1999/09/23 04:41:43 jprice # *** empty log message *** From 0359f6e0aa01f49e138bc1df730245c8beece846 Mon Sep 17 00:00:00 2001 From: Jim Tabor Date: Mon, 15 May 2000 06:08:12 +0000 Subject: [PATCH 013/671] Ser Path git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@17 6ac86273-5f31-0410-b378-82cca8765d1b --- bin/autoexec.bat | 1 + 1 file changed, 1 insertion(+) diff --git a/bin/autoexec.bat b/bin/autoexec.bat index 8ef39429..54f3e645 100644 --- a/bin/autoexec.bat +++ b/bin/autoexec.bat @@ -1,2 +1,3 @@ @echo off echo Welcome to FreeDOS (http://www.freedos.org)! +path=a:\ From 504c1b3c02f3051c1d5c419140b126505a6c1db7 Mon Sep 17 00:00:00 2001 From: Jim Tabor Date: Wed, 17 May 2000 19:15:12 +0000 Subject: [PATCH 014/671] Cleanup, add and fix source. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@18 6ac86273-5f31-0410-b378-82cca8765d1b --- docs/history.txt | 20 ++++++++++++++ fdkernel.lsm | 6 ++-- kernel/dosfns.c | 62 ++++++++++++++++++++++++----------------- kernel/dsk.c | 70 +++++++++++++++++++++++++++++++++++++---------- kernel/fatdir.c | 19 ++++++++++++- kernel/int2f.asm | 25 +++++++++++++++-- kernel/inthndlr.c | 20 ++++++-------- kernel/ioctl.c | 8 ++++-- kernel/main.c | 10 +++++++ kernel/network.c | 10 ++++++- kernel/newstuff.c | 61 ++++++++++++++++++++++++++--------------- 11 files changed, 228 insertions(+), 83 deletions(-) diff --git a/docs/history.txt b/docs/history.txt index 88df13ed..6f7825de 100644 --- a/docs/history.txt +++ b/docs/history.txt @@ -1,3 +1,23 @@ +2000 May 17 - Build 2020 +-------- James Tabor (jimtabor@infohwy.com) ++ Fixed Delete, Rename, Mkdir, and Rmdir. Comment out isDevice. There is + a serious bug in isDevice. ++ Added Finished adding function code for disk serial number support. ++ Clean Cleaned up source and removed duplicate functions. + +2000 May 14 - Build 2020 +-------- James Tabor (jimtabor@infohwy.com) ++ Clean Cleaned out the remaining CR's. + +2000 May 08 - Build 2020 +-------- James Tabor (jimtabor@infohwy.com) ++ Update Started Update to the New CVS at Sourceforge.net. Seting source + from 2018 to 2020. + +2000 May 06 +-------- Jim Hall (jhall1.isd.net) ++ Import Jim Hall imported the CVS from gcfl.net to Sourceforge.net. + 2000 Apr 28 - Build 2020 -------- James Tabor (jimtabor@infohwy.com) + Added Dos Function calls 0x69, and 0x6C. IOCTL support in disk driver. diff --git a/fdkernel.lsm b/fdkernel.lsm index 2b35d73b..54c2c33f 100644 --- a/fdkernel.lsm +++ b/fdkernel.lsm @@ -4,9 +4,9 @@ Version: 1.1.20 Entered-date: 5 May 2000 Description: The FreeDOS Kernel. Keywords: kernel freedos dos msdos -Author: kernel@gcfl.net (developers) -Maintained-by: linux-guru@gcfl.net -Primary-site: http://www.gcfl.net/pub/FreeDOS/kernel +Author: (developers) +Maintained-by: jimtabor@infohwy.com +Primary-site: http://freedos.sourceforge.net Alternate-site: www.freedos.org Original-site: http://www.gcfl.net/pub/FreeDOS/kernel Platforms: dos dosemu diff --git a/kernel/dosfns.c b/kernel/dosfns.c index 08e3465a..cfdf42d2 100644 --- a/kernel/dosfns.c +++ b/kernel/dosfns.c @@ -34,9 +34,16 @@ static BYTE *dosfnsRcsId = "$Id$"; /* * $Log$ + * Revision 1.3 2000/05/17 19:15:12 jimtabor + * Cleanup, add and fix source. + * * Revision 1.2 2000/05/08 04:29:59 jimtabor * Update CVS to 2020 * + * $Log$ + * Revision 1.3 2000/05/17 19:15:12 jimtabor + * Cleanup, add and fix source. + * * Revision 1.14 2000/04/02 05:01:08 jtabor * Replaced ChgDir Code * @@ -490,6 +497,8 @@ UCOUNT DosWrite(COUNT hndl, UCOUNT n, BYTE FAR * bp, COUNT FAR * err) COUNT SftSeek(sft FAR *s, LONG new_pos, COUNT mode) { + ULONG data; + /* Test for invalid mode */ if (mode < 0 || mode > 2) return DE_INVLDFUNC; @@ -500,7 +509,9 @@ COUNT SftSeek(sft FAR *s, LONG new_pos, COUNT mode) { if (mode == 2) { /* seek from end of file */ - int2f_Remote_call(REM_LSEEK, 0, (UWORD) FP_SEG(new_pos), (UWORD) FP_OFF(new_pos), (VOID FAR *) s, 0, 0); + int2f_Remote_call(REM_LSEEK, 0, (UWORD) FP_SEG(new_pos), (UWORD) FP_OFF(new_pos), (VOID FAR *) s, 0, (VOID FAR *)&data); + s->sft_posit = data; + return SUCCESS; } if (mode == 0) { @@ -1007,7 +1018,6 @@ VOID DosGetFree(COUNT drive, COUNT FAR * spc, COUNT FAR * navc, COUNT FAR * bps, COUNT DosGetCuDir(COUNT drive, BYTE FAR * s) { REG struct cds FAR *cdsp; - REG WORD x; /* next - "log" in the drive */ drive = (drive == 0 ? default_drive : drive - 1); @@ -1024,8 +1034,7 @@ COUNT DosGetCuDir(COUNT drive, BYTE FAR * s) return DE_INVLDDRV; } - x = 1 + cdsp->cdsJoinOffset; - fsncopy((BYTE FAR *) & cdsp->cdsCurrentPath[x], s, 64); + fsncopy((BYTE FAR *) & cdsp->cdsCurrentPath[1 + cdsp->cdsJoinOffset], s, 64); return SUCCESS; } @@ -1246,21 +1255,20 @@ BYTE DosSelectDrv(BYTE drv) COUNT DosDelete(BYTE FAR *path) { COUNT result, drive; - +/* if (IsDevice(path)) { return DE_PATHNOTFND; } - - drive = get_verify_drive(path); + */ + drive = get_verify_drive(path); if (drive < 0) { return drive; } - - result = truename(path, PriPathName, FALSE); - if (result != SUCCESS) { + result = truename(path, PriPathName, FALSE); + if (result != SUCCESS) { return result; } - current_ldt = &CDSp->cds_table[drive]; + current_ldt = &CDSp->cds_table[drive]; if (CDSp->cds_table[drive].cdsFlags & CDSNETWDRV) { result = int2f_Remote_call(REM_DELETE, 0, 0, 0, 0, 0, 0); result = -result; @@ -1273,20 +1281,22 @@ COUNT DosDelete(BYTE FAR *path) COUNT DosRename(BYTE FAR * path1, BYTE FAR * path2) { COUNT result, drive1, drive2; - if (IsDevice(path1) || IsDevice(path2)) { +/* + if (IsDevice(path1) || IsDevice(path2)) { return DE_PATHNOTFND; } - drive1 = get_verify_drive(path1); - result = truename(path1, PriPathName, FALSE); + */ + drive1 = get_verify_drive(path1); + result = truename(path1, PriPathName, FALSE); if (result != SUCCESS) { return result; } - drive2 = get_verify_drive(path2); - result = truename(path2, SecPathName, FALSE); - if (result != SUCCESS) { + drive2 = get_verify_drive(path2); + result = truename(path2, SecPathName, FALSE); + if (result != SUCCESS) { return result; } - if ((drive1 != drive2) || (drive1 < 0)) { + if ((drive1 != drive2) || (drive1 < 0)) { return DE_INVLDDRV; } current_ldt = &CDSp->cds_table[drive1]; @@ -1294,7 +1304,7 @@ COUNT DosRename(BYTE FAR * path1, BYTE FAR * path2) result = int2f_Remote_call(REM_RENAME, 0, 0, 0, 0, 0, 0); result = -result; } else { - result = dos_rename(path1, path2); + result = dos_rename(path1, path2); } return result; } @@ -1302,11 +1312,12 @@ COUNT DosRename(BYTE FAR * path1, BYTE FAR * path2) COUNT DosMkdir(BYTE FAR * dir) { COUNT result, drive; - +/* if (IsDevice(dir)) { return DE_PATHNOTFND; } - drive = get_verify_drive(dir); + */ + drive = get_verify_drive(dir); if (drive < 0) { return drive; } @@ -1314,7 +1325,7 @@ COUNT DosMkdir(BYTE FAR * dir) if (result != SUCCESS) { return result; } - current_ldt = &CDSp->cds_table[drive]; + current_ldt = &CDSp->cds_table[drive]; if (CDSp->cds_table[drive].cdsFlags & CDSNETWDRV) { result = int2f_Remote_call(REM_MKDIR, 0, 0, 0, 0, 0, 0); result = -result; @@ -1327,11 +1338,12 @@ COUNT DosMkdir(BYTE FAR * dir) COUNT DosRmdir(BYTE FAR * dir) { COUNT result, drive; - +/* if (IsDevice(dir)) { return DE_PATHNOTFND; } - drive = get_verify_drive(dir); + */ + drive = get_verify_drive(dir); if (drive < 0) { return drive; } @@ -1339,7 +1351,7 @@ COUNT DosRmdir(BYTE FAR * dir) if (result != SUCCESS) { return result; } - current_ldt = &CDSp->cds_table[drive]; + current_ldt = &CDSp->cds_table[drive]; if (CDSp->cds_table[drive].cdsFlags & CDSNETWDRV) { result = int2f_Remote_call(REM_RMDIR, 0, 0, 0, 0, 0, 0); result = -result; diff --git a/kernel/dsk.c b/kernel/dsk.c index 120526f9..2d4da08b 100644 --- a/kernel/dsk.c +++ b/kernel/dsk.c @@ -33,6 +33,9 @@ static BYTE *dskRcsId = "$Id$"; /* * $Log$ + * Revision 1.4 2000/05/17 19:15:12 jimtabor + * Cleanup, add and fix source. + * * Revision 1.3 2000/05/11 04:26:26 jimtabor * Added code for DOS FN 69 & 6C * @@ -40,8 +43,8 @@ static BYTE *dskRcsId = "$Id$"; * Update CVS to 2020 * * $Log$ - * Revision 1.3 2000/05/11 04:26:26 jimtabor - * Added code for DOS FN 69 & 6C + * Revision 1.4 2000/05/17 19:15:12 jimtabor + * Cleanup, add and fix source. * * Revision 1.6 2000/04/29 05:13:16 jtabor * Added new functions and clean up code @@ -454,7 +457,7 @@ static WORD mediachk(rqptr rp) { if ((result = fl_readdasd(drive)) == 2) /* if we can detect a change ... */ { - if ((result = fl_diskchanged(drive)) == 1) /* check if it has changed... */ + if ((result = fl_diskchanged(drive)) == 1) /* check if it has changed... */ rp->r_mcretcode = M_CHANGED; else if (result == 0) rp->r_mcretcode = M_NOT_CHANGED; @@ -470,12 +473,12 @@ static WORD mediachk(rqptr rp) return S_DONE; } -static WORD bldbpb(rqptr rp) +/* + * Read Write Sector Zero or Hard Drive Dos Bpb + */ +static WORD RWzero(rqptr rp, WORD t) { REG retry = N_RETRY; - ULONG count; - byteptr trans; - WORD local_word; if (hd(miarray[rp->r_unit].mi_drive)) { @@ -493,10 +496,29 @@ static WORD bldbpb(rqptr rp) do { + if (!t) /* 0 == Read */ + { ret = fl_read((WORD) miarray[rp->r_unit].mi_drive, (WORD) head, (WORD) track, (WORD) sector, (WORD) 1, (byteptr) & buffer); + } + else + { + ret = fl_write((WORD) miarray[rp->r_unit].mi_drive, + (WORD) head, (WORD) track, (WORD) sector, (WORD) 1, (byteptr) & buffer); + } } while (ret != 0 && --retry > 0); + return ret; +} + +static WORD bldbpb(rqptr rp) +{ + ULONG count, i; + byteptr trans; + WORD local_word; + + ret = RWzero( rp, 0); + if (ret != 0) return (dskerr(ret)); @@ -514,8 +536,15 @@ static WORD bldbpb(rqptr rp) getlong(&((((BYTE *) & buffer.bytes[BT_BPB])[BPB_HIDDEN])), &bpbarray[rp->r_unit].bpb_hidden); getlong(&((((BYTE *) & buffer.bytes[BT_BPB])[BPB_HUGE])), &bpbarray[rp->r_unit].bpb_huge); +/* Needs fat32 offset code */ getlong(&((((BYTE *) & buffer.bytes[0x27])[0])), &fsarray[rp->r_unit].fs_serialno); + for(i = 0; i < 11 ;i++ ) + fsarray[rp->r_unit].fs_volume[i] = buffer.bytes[0x2B + i]; + for(i = 0; i < 8; i++ ) + fsarray[rp->r_unit].fs_fstype[i] = buffer.bytes[0x36 + i]; + + #ifdef DSK_DEBUG printf("BPB_NBYTE = %04x\n", bpbarray[rp->r_unit].bpb_nbyte); @@ -570,6 +599,7 @@ static COUNT write_and_verify(WORD drive, WORD head, WORD track, WORD sector, static WORD IoctlQueblk(rqptr rp) { switch(rp->r_count){ + case 0x0846: case 0x0860: case 0x0866: break; @@ -628,17 +658,29 @@ static WORD Genblkdev(rqptr rp) struct FS_info FAR * fs = &fsarray[rp->r_unit]; gioc->ioc_serialno = fs->fs_serialno; - - for(i = 0; i < 12 ;i++ ) + for(i = 0; i < 11 ;i++ ) gioc->ioc_volume[i] = fs->fs_volume[i]; - for(i = 0; i < 9; i++ ) + for(i = 0; i < 8; i++ ) gioc->ioc_fstype[i] = fs->fs_fstype[i]; + } + break; + + + case 0x0846: /* set volume serial number */ + { + struct Gioc_media FAR * gioc = (struct Gioc_media FAR *) rp->r_trans; + struct FS_info FAR * fs = (struct FS_info FAR *) &buffer.bytes[0x27]; + + ret = RWzero( rp, 0); + if (ret != 0) + return (dskerr(ret)); - printf("DSK_IOCTL SN %lx \n" , &fs->fs_serialno); - printf("DSK_IOCTL SN %lx \n" , &fs->fs_volume); - printf("DSK_IOCTL SN %lx \n" , &gioc->ioc_serialno); - printf("DSK_IOCTL SN %lx \n" , &gioc->ioc_volume); + fs->fs_serialno = gioc->ioc_serialno; + fsarray[rp->r_unit].fs_serialno = fs->fs_serialno; + ret = RWzero( rp, 1); + if (ret != 0) + return (dskerr(ret)); } break; default: diff --git a/kernel/fatdir.c b/kernel/fatdir.c index c84b5873..11e09289 100644 --- a/kernel/fatdir.c +++ b/kernel/fatdir.c @@ -36,9 +36,16 @@ static BYTE *fatdirRcsId = "$Id$"; /* * $Log$ + * Revision 1.3 2000/05/17 19:15:12 jimtabor + * Cleanup, add and fix source. + * * Revision 1.2 2000/05/08 04:30:00 jimtabor * Update CVS to 2020 * + * $Log$ + * Revision 1.3 2000/05/17 19:15:12 jimtabor + * Cleanup, add and fix source. + * * Revision 1.12 2000/03/31 05:40:09 jtabor * Added Eric W. Biederman Patches * @@ -713,7 +720,17 @@ COUNT dos_findnext(void) /* assign our match parameters pointer. */ dmp = (dmatch FAR *) dta; - nDrive = dmp->dm_drive; +/* + * The new version of SHSUCDX 1.0 looks at the dm_drive byte to + * test 40h. I used RamView to see location MSD 116:04be and + * FD f61:04be, the byte set with 0xc4 = Remote/Network drive 4. + * Ralf Brown docs for dos 4eh say bit 7 set == remote so what is + * bit 6 for? SHSUCDX Mod info say "test redir not network bit". + * + * So, assume bit 6 is redirector and bit 7 is network. + * jt + */ + nDrive = dmp->dm_drive & 0x3f; if (nDrive > lastdrive) { return DE_INVLDDRV; diff --git a/kernel/int2f.asm b/kernel/int2f.asm index 89df2c53..43561850 100644 --- a/kernel/int2f.asm +++ b/kernel/int2f.asm @@ -30,9 +30,16 @@ ; $Id$ ; ; $Log$ +; Revision 1.3 2000/05/17 19:15:12 jimtabor +; Cleanup, add and fix source. +; ; Revision 1.2 2000/05/08 04:30:00 jimtabor ; Update CVS to 2020 ; +; $Log$ +; Revision 1.3 2000/05/17 19:15:12 jimtabor +; Cleanup, add and fix source. +; ; Revision 1.4 2000/03/31 05:40:09 jtabor ; Added Eric W. Biederman Patches ; @@ -144,7 +151,9 @@ _int2f_Remote_call: jne short int2f_r_2 int2f_r_1: call int2f_call - jc int2f_rfner + jnc short int2f_skip1 + jmp int2f_rfner +int2f_skip1: les di,[bp+18] ; do return data stuff mov [es:di],cx jmp short int2f_rfner @@ -184,10 +193,20 @@ int2f_r_5: pop ds call int2f_call pop ds - jc short int2f_rfner - xor ax,ax + jc short int2f_rfner + xor ax,ax jmp short int2f_rfner int2f_r_6: + cmp al,021h ; Lseek from eof + jne short int2f_r_7 + call int2f_call + jc short int2f_rfner + les di,[bp+18] + mov [es:di],ax + mov [es:di+2],dx + xor ax,ax + jmp short int2f_rfner +int2f_r_7: ; ; everything else goes through here. ; diff --git a/kernel/inthndlr.c b/kernel/inthndlr.c index fa4d7178..9ac07d15 100644 --- a/kernel/inthndlr.c +++ b/kernel/inthndlr.c @@ -36,6 +36,9 @@ BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.6 2000/05/17 19:15:12 jimtabor + * Cleanup, add and fix source. + * * Revision 1.5 2000/05/11 06:14:45 jimtabor * Removed #if statement * @@ -49,11 +52,8 @@ BYTE *RcsId = "$Id$"; * Update CVS to 2020 * * $Log$ - * Revision 1.5 2000/05/11 06:14:45 jimtabor - * Removed #if statement - * - * Revision 1.4 2000/05/11 04:26:26 jimtabor - * Added code for DOS FN 69 & 6C + * Revision 1.6 2000/05/17 19:15:12 jimtabor + * Cleanup, add and fix source. * * Revision 1.24 2000/04/29 05:13:16 jtabor * Added new functions and clean up code @@ -1230,9 +1230,7 @@ VOID int21_service(iregs FAR * r) /* Dos Rename */ case 0x56: - rc = DosRename( - (BYTE FAR *) MK_FP(r->DS, r->DX), /* OldName */ - (BYTE FAR *) MK_FP(r->ES, r->DI)); /* NewName */ + rc = DosRename((BYTE FAR *) MK_FP(r->DS, r->DX), (BYTE FAR *) MK_FP(r->ES, r->DI)); if (rc < SUCCESS) goto error_exit; else @@ -1595,7 +1593,7 @@ VOID int21_service(iregs FAR * r) r->AL = 0xFF; break; - +#if 0 /* Extended Open-Creat, not fully functional.*/ case 0x6c: switch(r->DL) { @@ -1683,8 +1681,8 @@ VOID int21_service(iregs FAR * r) default: goto error_invalid; - - } + } +#endif } #ifdef DEBUG diff --git a/kernel/ioctl.c b/kernel/ioctl.c index 3d541773..0ced4c91 100644 --- a/kernel/ioctl.c +++ b/kernel/ioctl.c @@ -35,6 +35,9 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.4 2000/05/17 19:15:12 jimtabor + * Cleanup, add and fix source. + * * Revision 1.3 2000/05/11 04:26:26 jimtabor * Added code for DOS FN 69 & 6C * @@ -42,8 +45,8 @@ static BYTE *RcsId = "$Id$"; * Update CVS to 2020 * * $Log$ - * Revision 1.3 2000/05/11 04:26:26 jimtabor - * Added code for DOS FN 69 & 6C + * Revision 1.4 2000/05/17 19:15:12 jimtabor + * Cleanup, add and fix source. * * Revision 1.4 2000/04/29 05:13:16 jtabor * Added new functions and clean up code @@ -155,7 +158,6 @@ COUNT DosDevIOctl(iregs FAR * r, COUNT FAR * err) r->BL = ( r->BL == 0 ? default_drive : r->BL - 1); - printf("IOCTL bl = %04x\n", r->BL); if (r->BL > lastdrive) { diff --git a/kernel/main.c b/kernel/main.c index 6feae5d4..6bfdcb4f 100644 --- a/kernel/main.c +++ b/kernel/main.c @@ -39,9 +39,16 @@ static BYTE *mainRcsId = "$Id$"; /* * $Log$ + * Revision 1.3 2000/05/17 19:15:12 jimtabor + * Cleanup, add and fix source. + * * Revision 1.2 2000/05/08 04:30:00 jimtabor * Update CVS to 2020 * + * $Log$ + * Revision 1.3 2000/05/17 19:15:12 jimtabor + * Cleanup, add and fix source. + * * Revision 1.14 2000/03/31 05:40:09 jtabor * Added Eric W. Biederman Patches * @@ -176,6 +183,9 @@ INIT static VOID init_kernel(void) /* Init oem hook - returns memory size in KB */ ram_top = init_oem(); +/* Fake int 21h stack frame */ + user_r = (iregs FAR *) DOS_PSP + 0xD0; + #ifndef KDB for (i = 0x20; i <= 0x3f; i++) setvec(i, empty_handler); diff --git a/kernel/network.c b/kernel/network.c index 9bc42ce9..abb6162b 100644 --- a/kernel/network.c +++ b/kernel/network.c @@ -36,9 +36,16 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.3 2000/05/17 19:15:12 jimtabor + * Cleanup, add and fix source. + * * Revision 1.2 2000/05/08 04:30:00 jimtabor * Update CVS to 2020 * + * $Log$ + * Revision 1.3 2000/05/17 19:15:12 jimtabor + * Cleanup, add and fix source. + * * Revision 1.5 2000/03/31 05:40:09 jtabor * Added Eric W. Biederman Patches * @@ -122,12 +129,13 @@ COUNT Remote_find(UWORD func, UWORD attrib, BYTE FAR * name, REG dmatch FAR * dm printf("'\n"); #endif } + fsncopy(dta, (BYTE FAR *) &TempBuffer, 21); p = dta; dta = (BYTE FAR *) &TempBuffer; i = int2f_Remote_call(func, 0, 0, 0, 0, 0, 0); dta = p; - fsncopy((BYTE FAR *) &TempBuffer[1], &dta[1], 20); + fsncopy((BYTE FAR *) &TempBuffer[0], &dta[0], 21); if (i != 0) return i; diff --git a/kernel/newstuff.c b/kernel/newstuff.c index 74b87afa..71eeea5a 100644 --- a/kernel/newstuff.c +++ b/kernel/newstuff.c @@ -31,9 +31,16 @@ static BYTE *mainRcsId = "$Id$"; /* * $Log$ + * Revision 1.3 2000/05/17 19:15:12 jimtabor + * Cleanup, add and fix source. + * * Revision 1.2 2000/05/08 04:30:00 jimtabor * Update CVS to 2020 * + * $Log$ + * Revision 1.3 2000/05/17 19:15:12 jimtabor + * Cleanup, add and fix source. + * * Revision 1.8 2000/04/02 06:11:35 jtabor * Fix ChgDir Code * @@ -208,22 +215,22 @@ COUNT get_verify_drive(char FAR *src) * Added support for external and internal calls. * Clean buffer before use. Make the true path and expand file names. * Example: *.* -> ????????.??? as in the currect way. + * MSD returns \\D.\A.\????????.??? with SHSUCDX. So, this code is not + * compatible MSD Func 60h. */ COUNT truename(char FAR * src, char FAR * dest, COUNT t) { - static char buf[128] = "A:\\"; + static char buf[128] = "A:\\\0\0\0\0\0\0\0\0\0"; char *bufp = buf + 3; COUNT i, n, x = 2; - BYTE far *test; - REG struct cds FAR *cdsp; + struct cds FAR *cdsp; - fbcopy((VOID FAR *) "A:\\\0\0\0\0\0\0\0", (VOID FAR *) buf, 10); dest[0] = '\0'; - /* First, adjust the source pointer */ + /* First, adjust the source pointer */ src = adjust_far(src); - /* Do we have a drive? */ + /* Do we have a drive? */ if (src[1] == ':') { buf[0] = (src[0] | 0x20) + 'A' - 'a'; @@ -268,24 +275,25 @@ COUNT truename(char FAR * src, char FAR * dest, COUNT t) } else src++; - +/* + * The code here is brain dead. It works long as the calling + * function are operating with in normal parms. + * jt + */ + n = 9; /* convert all forward slashes to backslashes, and uppercase all characters */ while (*src) { char c; c = *src++; + if(!n) + return DE_PATHNOTFND; /* do this for now */ + n--; switch (c) { -/* added *.*, *., * support. - */ -/* This doesn't expand cases like: foo*.* corrrectly - * disable it for now. - */ -#if 1 case '*': if (*src == '.') { - n = 8; while (n--) *bufp++ = '?'; break; @@ -294,25 +302,24 @@ COUNT truename(char FAR * src, char FAR * dest, COUNT t) { if (src[-2] == '.') { - n = 3; while (n--) *bufp++ = '?'; break; } else { - n = 8; while (n--) *bufp++ = '?'; break; } } -#endif case '/': /* convert to backslash */ case '\\': - if (bufp[-1] != '\\') - *bufp++ = '\\'; + if (bufp[-1] != '\\'){ + *bufp++ = '\\'; + n = 9; + } break; /* look for '.' and '..' dir entries */ @@ -333,10 +340,20 @@ COUNT truename(char FAR * src, char FAR * dest, COUNT t) bufp++; } else if (*src == '/' || *src == '\\' || *src == 0) - --bufp; + break; + /* --bufp;*/ + else + return DE_PATHNOTFND; } - else - *bufp++ = c; + else if ( *src == '/' || *src == '\\' || *src == 0) + { + break; + } + else + { + n = 4; + *bufp++ = c; + } break; default: From 775e754bdfcc8733dbb34a48e05566449d512e1d Mon Sep 17 00:00:00 2001 From: Jim Tabor Date: Tue, 23 May 2000 02:02:58 +0000 Subject: [PATCH 015/671] Removed CRs Again git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@25 6ac86273-5f31-0410-b378-82cca8765d1b From 21bb3f6923a3b0504fdd7952cf13be5c24709879 Mon Sep 17 00:00:00 2001 From: Jim Tabor Date: Thu, 25 May 2000 20:56:23 +0000 Subject: [PATCH 016/671] Fixed project history git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@26 6ac86273-5f31-0410-b378-82cca8765d1b --- boot/boot.asm | 10 ++++-- boot/boot.mak | 7 ++++ build.bat | 7 ++++ clean.bat | 7 ++++ clobber.bat | 7 ++++ config.m | 7 ++++ docs/history.txt | 4 +++ drivers/devend.asm | 7 ++++ drivers/device.mak | 7 ++++ drivers/floppy.asm | 7 ++++ drivers/getvec.asm | 7 ++++ drivers/rdatclk.asm | 6 +++- drivers/rdpcclk.asm | 7 ++++ drivers/timer.asm | 7 ++++ drivers/wratclk.asm | 7 ++++ drivers/wrpcclk.asm | 7 ++++ hdr/cds.h | 7 ++++ hdr/clock.h | 7 ++++ hdr/date.h | 7 ++++ hdr/dcb.h | 7 ++++ hdr/device.h | 9 ++++-- hdr/dirmatch.h | 7 ++++ hdr/error.h | 7 ++++ hdr/exe.h | 7 ++++ hdr/fat.h | 7 ++++ hdr/fcb.h | 7 ++++ hdr/file.h | 7 ++++ hdr/fnode.h | 7 ++++ hdr/kbd.h | 7 ++++ hdr/mcb.h | 7 ++++ hdr/pcb.h | 7 ++++ hdr/portab.h | 7 ++++ hdr/process.h | 7 ++++ hdr/sft.h | 7 ++++ hdr/stacks.inc | 7 ++++ hdr/tail.h | 7 ++++ hdr/time.h | 7 ++++ kernel/001-437.nls | 7 ++++ kernel/apisupt.asm | 7 ++++ kernel/asmsupt.asm | 7 ++++ kernel/blockio.c | 9 ++++-- kernel/break.c | 7 ++++ kernel/chario.c | 7 ++++ kernel/config.c | 7 ++++ kernel/console.asm | 7 ++++ kernel/dosfns.c | 9 ++++-- kernel/dosnames.c | 7 ++++ kernel/dsk.c | 9 ++++-- kernel/entry.asm | 7 ++++ kernel/error.c | 7 ++++ kernel/execrh.asm | 7 ++++ kernel/fatdir.c | 9 ++++-- kernel/fatfs.c | 9 ++++-- kernel/fattab.c | 7 ++++ kernel/fcbfns.c | 7 ++++ kernel/globals.h | 7 ++++ kernel/initoem.c | 7 ++++ kernel/int2f.asm | 9 ++++-- kernel/inthndlr.c | 9 ++++-- kernel/io.asm | 7 ++++ kernel/io.inc | 7 ++++ kernel/ioctl.c | 9 ++++-- kernel/irqstack.asm | 7 ++++ kernel/kernel.asm | 7 ++++ kernel/kernel.mak | 7 ++++ kernel/main.c | 9 ++++-- kernel/memmgr.c | 7 ++++ kernel/misc.c | 7 ++++ kernel/network.c | 9 ++++-- kernel/newstuff.c | 9 ++++-- kernel/nls.c | 7 ++++ kernel/nlssupt.asm | 7 ++++ kernel/prf.c | 7 ++++ kernel/printer.asm | 7 ++++ kernel/procsupt.asm | 7 ++++ kernel/proto.h | 7 ++++ kernel/segs.inc | 7 ++++ kernel/serial.asm | 7 ++++ kernel/strings.c | 7 ++++ kernel/sysclk.c | 7 ++++ kernel/syspack.c | 7 ++++ kernel/systime.c | 7 ++++ kernel/task.c | 7 ++++ lib/libm.mak | 7 ++++ sys/bin2c.mak | 8 ++++- sys/sys.c | 79 ++++++++++++++++++++++++--------------------- sys/sys.mak | 8 ++++- 87 files changed, 629 insertions(+), 77 deletions(-) diff --git a/boot/boot.asm b/boot/boot.asm index aa7f55fd..df24137d 100644 --- a/boot/boot.asm +++ b/boot/boot.asm @@ -25,12 +25,18 @@ ; write to the Free Software Foundation, 675 Mass Ave, ; Cambridge, MA 02139, USA. ; - - +; ; $Log$ +; Revision 1.3 2000/05/25 20:56:19 jimtabor +; Fixed project history +; ; Revision 1.2 2000/05/11 03:56:42 jimtabor ; Clean up and Release ; +; Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 +; The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with +; MS-DOS. Distributed under the GNU GPL. +; ; Revision 1.12 1999/09/25 06:42:18 jprice ; Optimize boot loader. Documentation. ; diff --git a/boot/boot.mak b/boot/boot.mak index 6dd3c105..47c515c7 100644 --- a/boot/boot.mak +++ b/boot/boot.mak @@ -5,9 +5,16 @@ # # $Log$ +# Revision 1.3 2000/05/25 20:56:19 jimtabor +# Fixed project history +# # Revision 1.2 2000/05/11 03:56:42 jimtabor # Clean up and Release # +# Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 +# The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with +# MS-DOS. Distributed under the GNU GPL. +# # Revision 1.3 1999/04/23 03:44:17 jprice # Ported to NASM by ror4. Improvements # diff --git a/build.bat b/build.bat index 894b1cab..8d5f15b5 100644 --- a/build.bat +++ b/build.bat @@ -5,9 +5,16 @@ rem batch file to build everything rem $Id$ rem $Log$ +rem Revision 1.3 2000/05/25 20:56:19 jimtabor +rem Fixed project history +rem rem Revision 1.2 2000/05/14 17:05:39 jimtabor rem Cleanup CRs rem +rem Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 +rem The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with +rem MS-DOS. Distributed under the GNU GPL. +rem rem Revision 1.5 1999/08/25 03:59:14 jprice rem New build batch files. rem diff --git a/clean.bat b/clean.bat index 5c4f7e2e..ff080229 100644 --- a/clean.bat +++ b/clean.bat @@ -5,9 +5,16 @@ rem batch file to clean everything rem $Id$ rem $Log$ +rem Revision 1.3 2000/05/25 20:56:19 jimtabor +rem Fixed project history +rem rem Revision 1.2 2000/05/14 17:05:58 jimtabor rem Cleanup CRs rem +rem Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 +rem The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with +rem MS-DOS. Distributed under the GNU GPL. +rem rem Revision 1.3 1999/08/25 03:59:14 jprice rem New build batch files. rem diff --git a/clobber.bat b/clobber.bat index b02d1b86..600badde 100644 --- a/clobber.bat +++ b/clobber.bat @@ -4,9 +4,16 @@ rem batch file to clobber everything rem $Id$ rem $Log$ +rem Revision 1.3 2000/05/25 20:56:19 jimtabor +rem Fixed project history +rem rem Revision 1.2 2000/05/14 17:06:17 jimtabor rem Cleanup CRs rem +rem Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 +rem The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with +rem MS-DOS. Distributed under the GNU GPL. +rem rem Revision 1.3 1999/08/25 03:59:14 jprice rem New build batch files. rem diff --git a/config.m b/config.m index 9ee0b349..840eb450 100644 --- a/config.m +++ b/config.m @@ -48,9 +48,16 @@ # $Id$ # # $Log$ +# Revision 1.3 2000/05/25 20:56:19 jimtabor +# Fixed project history +# # Revision 1.2 2000/05/14 17:07:07 jimtabor # Cleanup CRs # +# Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 +# The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with +# MS-DOS. Distributed under the GNU GPL. +# # Revision 1.3 1999/09/13 20:40:17 jprice # Added COMPILER variable # diff --git a/docs/history.txt b/docs/history.txt index 6f7825de..b1565a49 100644 --- a/docs/history.txt +++ b/docs/history.txt @@ -1,3 +1,7 @@ +2000 May 25 - Build 2020 +-------- James Tabor (jimtabor@infohwy.com) ++ Fixed Project history. + 2000 May 17 - Build 2020 -------- James Tabor (jimtabor@infohwy.com) + Fixed Delete, Rename, Mkdir, and Rmdir. Comment out isDevice. There is diff --git a/drivers/devend.asm b/drivers/devend.asm index 4433ed3c..a15c2500 100644 --- a/drivers/devend.asm +++ b/drivers/devend.asm @@ -30,9 +30,16 @@ ; $Header$ ; ; $Log$ +; Revision 1.3 2000/05/25 20:56:19 jimtabor +; Fixed project history +; ; Revision 1.2 2000/05/11 03:56:20 jimtabor ; Clean up and Release ; +; Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 +; The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with +; MS-DOS. Distributed under the GNU GPL. +; ; Revision 1.3 1999/08/10 17:21:08 jprice ; ror4 2011-01 patch ; diff --git a/drivers/device.mak b/drivers/device.mak index 62ed8e0e..1efaefc7 100644 --- a/drivers/device.mak +++ b/drivers/device.mak @@ -5,9 +5,16 @@ # # $Log$ +# Revision 1.3 2000/05/25 20:56:19 jimtabor +# Fixed project history +# # Revision 1.2 2000/05/11 03:56:20 jimtabor # Clean up and Release # +# Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 +# The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with +# MS-DOS. Distributed under the GNU GPL. +# # Revision 1.6 1999/08/25 03:16:36 jprice # ror4 patches to allow TC 2.01 compile. # diff --git a/drivers/floppy.asm b/drivers/floppy.asm index 9359c71d..728beabf 100644 --- a/drivers/floppy.asm +++ b/drivers/floppy.asm @@ -30,9 +30,16 @@ ; $Id$ ; ; $Log$ +; Revision 1.3 2000/05/25 20:56:19 jimtabor +; Fixed project history +; ; Revision 1.2 2000/05/11 03:56:20 jimtabor ; Clean up and Release ; +; Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 +; The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with +; MS-DOS. Distributed under the GNU GPL. +; ; Revision 1.4 1999/08/10 17:21:08 jprice ; ror4 2011-01 patch ; diff --git a/drivers/getvec.asm b/drivers/getvec.asm index c8d044c6..3c1c24aa 100644 --- a/drivers/getvec.asm +++ b/drivers/getvec.asm @@ -30,9 +30,16 @@ ; $Header$ ; ; $Log$ +; Revision 1.3 2000/05/25 20:56:19 jimtabor +; Fixed project history +; ; Revision 1.2 2000/05/11 03:56:20 jimtabor ; Clean up and Release ; +; Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 +; The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with +; MS-DOS. Distributed under the GNU GPL. +; ; Revision 1.3 1999/08/10 17:21:08 jprice ; ror4 2011-01 patch ; diff --git a/drivers/rdatclk.asm b/drivers/rdatclk.asm index 9f9b04d9..8f66e6d4 100644 --- a/drivers/rdatclk.asm +++ b/drivers/rdatclk.asm @@ -29,7 +29,11 @@ ; ; @Header: /home/cvsroot/fdkernel/DRIVERS/RDATCLK.ASM,v 1.3 1999/04/12 03:19:44 jprice Exp @ ; -; @Log: RDATCLK.ASM,v @ +; @Log: rdatclk.asm,v @ +; Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 +; The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with +; MS-DOS. Distributed under the GNU GPL. +; ; Revision 1.3 1999/04/12 03:19:44 jprice ; more ror4 patches ; diff --git a/drivers/rdpcclk.asm b/drivers/rdpcclk.asm index cd0b8340..e7734808 100644 --- a/drivers/rdpcclk.asm +++ b/drivers/rdpcclk.asm @@ -30,9 +30,16 @@ ; $Header$ ; ; $Log$ +; Revision 1.3 2000/05/25 20:56:19 jimtabor +; Fixed project history +; ; Revision 1.2 2000/05/11 03:56:20 jimtabor ; Clean up and Release ; +; Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 +; The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with +; MS-DOS. Distributed under the GNU GPL. +; ; Revision 1.4 1999/08/10 17:21:08 jprice ; ror4 2011-01 patch ; diff --git a/drivers/timer.asm b/drivers/timer.asm index 67972064..3ea1b562 100644 --- a/drivers/timer.asm +++ b/drivers/timer.asm @@ -30,9 +30,16 @@ ; $Header$ ; ; $Log$ +; Revision 1.3 2000/05/25 20:56:19 jimtabor +; Fixed project history +; ; Revision 1.2 2000/05/11 03:56:20 jimtabor ; Clean up and Release ; +; Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 +; The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with +; MS-DOS. Distributed under the GNU GPL. +; ; Revision 1.3 1999/08/10 17:21:08 jprice ; ror4 2011-01 patch ; diff --git a/drivers/wratclk.asm b/drivers/wratclk.asm index 41f21af7..c2990c2f 100644 --- a/drivers/wratclk.asm +++ b/drivers/wratclk.asm @@ -30,9 +30,16 @@ ; $Header$ ; ; $Log$ +; Revision 1.3 2000/05/25 20:56:19 jimtabor +; Fixed project history +; ; Revision 1.2 2000/05/11 03:56:20 jimtabor ; Clean up and Release ; +; Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 +; The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with +; MS-DOS. Distributed under the GNU GPL. +; ; Revision 1.3 1999/08/10 17:21:08 jprice ; ror4 2011-01 patch ; diff --git a/drivers/wrpcclk.asm b/drivers/wrpcclk.asm index a6c8ab76..ccdf1bce 100644 --- a/drivers/wrpcclk.asm +++ b/drivers/wrpcclk.asm @@ -30,9 +30,16 @@ ; $Header$ ; ; $Log$ +; Revision 1.3 2000/05/25 20:56:19 jimtabor +; Fixed project history +; ; Revision 1.2 2000/05/11 03:56:20 jimtabor ; Clean up and Release ; +; Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 +; The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with +; MS-DOS. Distributed under the GNU GPL. +; ; Revision 1.3 1999/08/10 17:21:08 jprice ; ror4 2011-01 patch ; diff --git a/hdr/cds.h b/hdr/cds.h index 449a594a..2e42adf9 100644 --- a/hdr/cds.h +++ b/hdr/cds.h @@ -34,9 +34,16 @@ static BYTE *Cds_hRcsId = "$Id$"; /* * $Log$ + * Revision 1.3 2000/05/25 20:56:19 jimtabor + * Fixed project history + * * Revision 1.2 2000/05/08 04:28:22 jimtabor * Update CVS to 2020 * + * Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 + * The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with + * MS-DOS. Distributed under the GNU GPL. + * * Revision 1.2 2000/03/09 06:06:38 kernel * 2017f updates by James Tabor * diff --git a/hdr/clock.h b/hdr/clock.h index e6a14c57..dec444f5 100644 --- a/hdr/clock.h +++ b/hdr/clock.h @@ -38,9 +38,16 @@ static BYTE *clock_hRcsId = "$Id$"; /* * $Log$ + * Revision 1.3 2000/05/25 20:56:19 jimtabor + * Fixed project history + * * Revision 1.2 2000/05/08 04:28:22 jimtabor * Update CVS to 2020 * + * Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 + * The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with + * MS-DOS. Distributed under the GNU GPL. + * * Revision 1.1.1.1 1999/03/29 15:39:22 jprice * New version without IPL.SYS * diff --git a/hdr/date.h b/hdr/date.h index f252e77c..557a7fb0 100644 --- a/hdr/date.h +++ b/hdr/date.h @@ -38,9 +38,16 @@ static BYTE *date_hRcsId = "$Id$"; /* * $Log$ + * Revision 1.3 2000/05/25 20:56:19 jimtabor + * Fixed project history + * * Revision 1.2 2000/05/08 04:28:22 jimtabor * Update CVS to 2020 * + * Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 + * The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with + * MS-DOS. Distributed under the GNU GPL. + * * Revision 1.2 1999/08/25 03:17:11 jprice * ror4 patches to allow TC 2.01 compile. * diff --git a/hdr/dcb.h b/hdr/dcb.h index 79bb5794..662aa112 100644 --- a/hdr/dcb.h +++ b/hdr/dcb.h @@ -36,9 +36,16 @@ static BYTE *clock_hRcsId = "$Id$"; /* * $Log$ + * Revision 1.3 2000/05/25 20:56:19 jimtabor + * Fixed project history + * * Revision 1.2 2000/05/08 04:28:22 jimtabor * Update CVS to 2020 * + * Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 + * The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with + * MS-DOS. Distributed under the GNU GPL. + * * Revision 1.3 2000/03/09 06:06:38 kernel * 2017f updates by James Tabor * diff --git a/hdr/device.h b/hdr/device.h index 9a37dc28..8f1e0cd7 100644 --- a/hdr/device.h +++ b/hdr/device.h @@ -35,15 +35,18 @@ static BYTE *device_hRcsId = "$Id$"; /* * $Log$ + * Revision 1.4 2000/05/25 20:56:19 jimtabor + * Fixed project history + * * Revision 1.3 2000/05/11 04:24:51 jimtabor * Added Boot blk structs * * Revision 1.2 2000/05/08 04:28:22 jimtabor * Update CVS to 2020 * - * $Log$ - * Revision 1.3 2000/05/11 04:24:51 jimtabor - * Added Boot blk structs + * Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 + * The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with + * MS-DOS. Distributed under the GNU GPL. * * Revision 1.4 2000/04/29 05:13:16 jtabor * Added new functions and clean up code diff --git a/hdr/dirmatch.h b/hdr/dirmatch.h index 1a751293..5001ec9f 100644 --- a/hdr/dirmatch.h +++ b/hdr/dirmatch.h @@ -36,9 +36,16 @@ static BYTE *dirmatch_hRcsId = "$Id$"; /* * $Log$ + * Revision 1.3 2000/05/25 20:56:19 jimtabor + * Fixed project history + * * Revision 1.2 2000/05/08 04:28:22 jimtabor * Update CVS to 2020 * + * Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 + * The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with + * MS-DOS. Distributed under the GNU GPL. + * * Revision 1.3 2000/03/09 06:06:38 kernel * 2017f updates by James Tabor * diff --git a/hdr/error.h b/hdr/error.h index 2a9e420d..939b1790 100644 --- a/hdr/error.h +++ b/hdr/error.h @@ -36,9 +36,16 @@ static BYTE *error_hRcsId = "$Id$"; /* * $Log$ + * Revision 1.3 2000/05/25 20:56:19 jimtabor + * Fixed project history + * * Revision 1.2 2000/05/08 04:28:22 jimtabor * Update CVS to 2020 * + * Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 + * The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with + * MS-DOS. Distributed under the GNU GPL. + * * Revision 1.1.1.1 1999/03/29 15:39:27 jprice * New version without IPL.SYS * diff --git a/hdr/exe.h b/hdr/exe.h index 627a660a..0bbbf5fb 100644 --- a/hdr/exe.h +++ b/hdr/exe.h @@ -36,9 +36,16 @@ static BYTE *exe_hRcsId = "$Id$"; /* * $Log$ + * Revision 1.3 2000/05/25 20:56:19 jimtabor + * Fixed project history + * * Revision 1.2 2000/05/08 04:28:22 jimtabor * Update CVS to 2020 * + * Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 + * The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with + * MS-DOS. Distributed under the GNU GPL. + * * Revision 1.1.1.1 1999/03/29 15:39:28 jprice * New version without IPL.SYS * diff --git a/hdr/fat.h b/hdr/fat.h index 38b79042..bc52089a 100644 --- a/hdr/fat.h +++ b/hdr/fat.h @@ -36,9 +36,16 @@ static BYTE *fat_hRcsId = "$Id$"; /* * $Log$ + * Revision 1.3 2000/05/25 20:56:19 jimtabor + * Fixed project history + * * Revision 1.2 2000/05/08 04:28:22 jimtabor * Update CVS to 2020 * + * Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 + * The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with + * MS-DOS. Distributed under the GNU GPL. + * * Revision 1.2 1999/05/03 06:28:00 jprice * Changed some variables from signed to unsigned. * diff --git a/hdr/fcb.h b/hdr/fcb.h index 016f3a70..ac63ca9d 100644 --- a/hdr/fcb.h +++ b/hdr/fcb.h @@ -36,9 +36,16 @@ static BYTE *fcb_hRcsId = "$Id$"; /* * $Log$ + * Revision 1.3 2000/05/25 20:56:19 jimtabor + * Fixed project history + * * Revision 1.2 2000/05/08 04:28:22 jimtabor * Update CVS to 2020 * + * Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 + * The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with + * MS-DOS. Distributed under the GNU GPL. + * * Revision 1.2 1999/09/20 21:24:54 jprice * *** empty log message *** * diff --git a/hdr/file.h b/hdr/file.h index 17776635..3326677e 100644 --- a/hdr/file.h +++ b/hdr/file.h @@ -36,9 +36,16 @@ static BYTE *file_hRcsId = "$Id$"; /* * $Log$ + * Revision 1.3 2000/05/25 20:56:19 jimtabor + * Fixed project history + * * Revision 1.2 2000/05/08 04:28:22 jimtabor * Update CVS to 2020 * + * Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 + * The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with + * MS-DOS. Distributed under the GNU GPL. + * * Revision 1.1.1.1 1999/03/29 15:39:30 jprice * New version without IPL.SYS * diff --git a/hdr/fnode.h b/hdr/fnode.h index a1209dc6..349706e8 100644 --- a/hdr/fnode.h +++ b/hdr/fnode.h @@ -36,9 +36,16 @@ static BYTE *fnode_hRcsId = "$Id$"; /* * $Log$ + * Revision 1.3 2000/05/25 20:56:19 jimtabor + * Fixed project history + * * Revision 1.2 2000/05/08 04:28:22 jimtabor * Update CVS to 2020 * + * Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 + * The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with + * MS-DOS. Distributed under the GNU GPL. + * * Revision 1.3 2000/03/09 06:06:38 kernel * 2017f updates by James Tabor * diff --git a/hdr/kbd.h b/hdr/kbd.h index 8887375e..8f229536 100644 --- a/hdr/kbd.h +++ b/hdr/kbd.h @@ -36,9 +36,16 @@ static BYTE *kbd_hRcsId = "$Id$"; /* * $Log$ + * Revision 1.3 2000/05/25 20:56:19 jimtabor + * Fixed project history + * * Revision 1.2 2000/05/08 04:28:22 jimtabor * Update CVS to 2020 * + * Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 + * The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with + * MS-DOS. Distributed under the GNU GPL. + * * Revision 1.1.1.1 1999/03/29 15:39:31 jprice * New version without IPL.SYS * diff --git a/hdr/mcb.h b/hdr/mcb.h index f5ca2e29..70d4adf5 100644 --- a/hdr/mcb.h +++ b/hdr/mcb.h @@ -36,9 +36,16 @@ static BYTE *mcb_hRcsId = "$Id$"; /* * $Log$ + * Revision 1.3 2000/05/25 20:56:19 jimtabor + * Fixed project history + * * Revision 1.2 2000/05/08 04:28:22 jimtabor * Update CVS to 2020 * + * Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 + * The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with + * MS-DOS. Distributed under the GNU GPL. + * * Revision 1.2 2000/03/09 06:06:38 kernel * 2017f updates by James Tabor * diff --git a/hdr/pcb.h b/hdr/pcb.h index e51aa055..f2b2337b 100644 --- a/hdr/pcb.h +++ b/hdr/pcb.h @@ -36,9 +36,16 @@ static BYTE *pcb_hRcsId = "$Id$"; /* * $Log$ + * Revision 1.3 2000/05/25 20:56:19 jimtabor + * Fixed project history + * * Revision 1.2 2000/05/08 04:28:22 jimtabor * Update CVS to 2020 * + * Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 + * The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with + * MS-DOS. Distributed under the GNU GPL. + * * Revision 1.1.1.1 1999/03/29 15:39:32 jprice * New version without IPL.SYS * diff --git a/hdr/portab.h b/hdr/portab.h index 0db73d9d..7ea1ab34 100644 --- a/hdr/portab.h +++ b/hdr/portab.h @@ -36,9 +36,16 @@ static char *portab_hRcsId = "$Id$"; /* * $Log$ + * Revision 1.3 2000/05/25 20:56:19 jimtabor + * Fixed project history + * * Revision 1.2 2000/05/08 04:28:22 jimtabor * Update CVS to 2020 * + * Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 + * The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with + * MS-DOS. Distributed under the GNU GPL. + * * Revision 1.2 1999/08/25 03:17:11 jprice * ror4 patches to allow TC 2.01 compile. * diff --git a/hdr/process.h b/hdr/process.h index da9ae0cd..6402820d 100644 --- a/hdr/process.h +++ b/hdr/process.h @@ -36,9 +36,16 @@ static BYTE *process_hRcsId = "$Id$"; /* * $Log$ + * Revision 1.3 2000/05/25 20:56:19 jimtabor + * Fixed project history + * * Revision 1.2 2000/05/08 04:28:22 jimtabor * Update CVS to 2020 * + * Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 + * The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with + * MS-DOS. Distributed under the GNU GPL. + * * Revision 1.1.1.1 1999/03/29 15:39:34 jprice * New version without IPL.SYS * diff --git a/hdr/sft.h b/hdr/sft.h index c4940742..7decb20f 100644 --- a/hdr/sft.h +++ b/hdr/sft.h @@ -35,9 +35,16 @@ static BYTE *sft_hRcsId = "$Id$"; /* * $Log$ + * Revision 1.3 2000/05/25 20:56:19 jimtabor + * Fixed project history + * * Revision 1.2 2000/05/08 04:28:22 jimtabor * Update CVS to 2020 * + * Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 + * The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with + * MS-DOS. Distributed under the GNU GPL. + * * Revision 1.3 2000/03/09 06:06:38 kernel * 2017f updates by James Tabor * diff --git a/hdr/stacks.inc b/hdr/stacks.inc index 363eb241..3125fd9d 100644 --- a/hdr/stacks.inc +++ b/hdr/stacks.inc @@ -30,8 +30,15 @@ ; $Id$ ; ; $Log$ +; Revision 1.3 2000/05/25 20:56:19 jimtabor +; Fixed project history +; ; Revision 1.2 2000/05/08 04:28:22 jimtabor ; Update CVS to 2020 +: +: Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 +: The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with +: MS-DOS. Distributed under the GNU GPL. ; ; Revision 1.3 2000/03/09 06:06:38 kernel ; 2017f updates by James Tabor diff --git a/hdr/tail.h b/hdr/tail.h index b865f233..80fd8c7f 100644 --- a/hdr/tail.h +++ b/hdr/tail.h @@ -36,9 +36,16 @@ static BYTE *tail_hRcsId = "$Id$"; /* * $Log$ + * Revision 1.3 2000/05/25 20:56:19 jimtabor + * Fixed project history + * * Revision 1.2 2000/05/08 04:28:22 jimtabor * Update CVS to 2020 * + * Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 + * The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with + * MS-DOS. Distributed under the GNU GPL. + * * Revision 1.1.1.1 1999/03/29 15:39:36 jprice * New version without IPL.SYS * diff --git a/hdr/time.h b/hdr/time.h index ccb201cb..4c2591bb 100644 --- a/hdr/time.h +++ b/hdr/time.h @@ -40,9 +40,16 @@ static BYTE *time_hRcsId = "$Id$"; /* * $Log$ + * Revision 1.3 2000/05/25 20:56:19 jimtabor + * Fixed project history + * * Revision 1.2 2000/05/08 04:28:22 jimtabor * Update CVS to 2020 * + * Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 + * The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with + * MS-DOS. Distributed under the GNU GPL. + * * Revision 1.2 1999/08/25 03:17:11 jprice * ror4 patches to allow TC 2.01 compile. * diff --git a/kernel/001-437.nls b/kernel/001-437.nls index 417d05d8..dbfa77f3 100644 --- a/kernel/001-437.nls +++ b/kernel/001-437.nls @@ -39,9 +39,16 @@ static BYTE *RcsId = "$Header$"; /* * $Log$ + * Revision 1.3 2000/05/25 20:56:20 jimtabor + * Fixed project history + * * Revision 1.2 2000/05/08 04:29:59 jimtabor * Update CVS to 2020 * + * Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 + * The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with + * MS-DOS. Distributed under the GNU GPL. + * * Revision 1.2 2000/03/09 06:07:10 kernel * 2017f updates by James Tabor * diff --git a/kernel/apisupt.asm b/kernel/apisupt.asm index 3089911f..dfe0fb05 100644 --- a/kernel/apisupt.asm +++ b/kernel/apisupt.asm @@ -27,9 +27,16 @@ ; $Id$ ; ; $Log$ +; Revision 1.3 2000/05/25 20:56:21 jimtabor +; Fixed project history +; ; Revision 1.2 2000/05/08 04:29:59 jimtabor ; Update CVS to 2020 ; +; Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 +; The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with +; MS-DOS. Distributed under the GNU GPL. +; ; Revision 1.2 1999/08/10 17:57:12 jprice ; ror4 2011-02 patch ; diff --git a/kernel/asmsupt.asm b/kernel/asmsupt.asm index 5230ed7b..7ceb4f25 100644 --- a/kernel/asmsupt.asm +++ b/kernel/asmsupt.asm @@ -27,9 +27,16 @@ ; $Id$ ; ; $Log$ +; Revision 1.3 2000/05/25 20:56:21 jimtabor +; Fixed project history +; ; Revision 1.2 2000/05/08 04:29:59 jimtabor ; Update CVS to 2020 ; +; Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 +; The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with +; MS-DOS. Distributed under the GNU GPL. +; ; Revision 1.3 1999/08/10 17:57:12 jprice ; ror4 2011-02 patch ; diff --git a/kernel/blockio.c b/kernel/blockio.c index a66ce742..09748a49 100644 --- a/kernel/blockio.c +++ b/kernel/blockio.c @@ -37,15 +37,18 @@ static BYTE *blockioRcsId = "$Id$"; /* * $Log$ + * Revision 1.4 2000/05/25 20:56:21 jimtabor + * Fixed project history + * * Revision 1.3 2000/05/11 04:26:26 jimtabor * Added code for DOS FN 69 & 6C * * Revision 1.2 2000/05/08 04:29:59 jimtabor * Update CVS to 2020 * - * $Log$ - * Revision 1.3 2000/05/11 04:26:26 jimtabor - * Added code for DOS FN 69 & 6C + * Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 + * The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with + * MS-DOS. Distributed under the GNU GPL. * * Revision 1.15 2000/04/29 05:13:16 jtabor * Added new functions and clean up code diff --git a/kernel/break.c b/kernel/break.c index 671244da..00a10d4e 100644 --- a/kernel/break.c +++ b/kernel/break.c @@ -38,9 +38,16 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.3 2000/05/25 20:56:21 jimtabor + * Fixed project history + * * Revision 1.2 2000/05/08 04:29:59 jimtabor * Update CVS to 2020 * + * Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 + * The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with + * MS-DOS. Distributed under the GNU GPL. + * * Revision 1.2 2000/03/09 06:07:10 kernel * 2017f updates by James Tabor * diff --git a/kernel/chario.c b/kernel/chario.c index b7b80796..75083e2a 100644 --- a/kernel/chario.c +++ b/kernel/chario.c @@ -36,9 +36,16 @@ static BYTE *charioRcsId = "$Id$"; /* * $Log$ + * Revision 1.3 2000/05/25 20:56:21 jimtabor + * Fixed project history + * * Revision 1.2 2000/05/08 04:29:59 jimtabor * Update CVS to 2020 * + * Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 + * The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with + * MS-DOS. Distributed under the GNU GPL. + * * Revision 1.7 2000/03/09 06:07:10 kernel * 2017f updates by James Tabor * diff --git a/kernel/config.c b/kernel/config.c index 3cb0ea65..23a385a7 100644 --- a/kernel/config.c +++ b/kernel/config.c @@ -39,9 +39,16 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.3 2000/05/25 20:56:21 jimtabor + * Fixed project history + * * Revision 1.2 2000/05/08 04:29:59 jimtabor * Update CVS to 2020 * + * Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 + * The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with + * MS-DOS. Distributed under the GNU GPL. + * * Revision 1.15 2000/03/31 05:40:09 jtabor * Added Eric W. Biederman Patches * diff --git a/kernel/console.asm b/kernel/console.asm index 327fb04d..bc2a6eb3 100644 --- a/kernel/console.asm +++ b/kernel/console.asm @@ -28,9 +28,16 @@ ; $Header$ ; ; $Log$ +; Revision 1.3 2000/05/25 20:56:21 jimtabor +; Fixed project history +; ; Revision 1.2 2000/05/08 04:29:59 jimtabor ; Update CVS to 2020 ; +; Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 +; The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with +; MS-DOS. Distributed under the GNU GPL. +; ; Revision 1.8 2000/03/09 06:07:10 kernel ; 2017f updates by James Tabor ; diff --git a/kernel/dosfns.c b/kernel/dosfns.c index cfdf42d2..17ddd019 100644 --- a/kernel/dosfns.c +++ b/kernel/dosfns.c @@ -34,15 +34,18 @@ static BYTE *dosfnsRcsId = "$Id$"; /* * $Log$ + * Revision 1.4 2000/05/25 20:56:21 jimtabor + * Fixed project history + * * Revision 1.3 2000/05/17 19:15:12 jimtabor * Cleanup, add and fix source. * * Revision 1.2 2000/05/08 04:29:59 jimtabor * Update CVS to 2020 * - * $Log$ - * Revision 1.3 2000/05/17 19:15:12 jimtabor - * Cleanup, add and fix source. + * Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 + * The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with + * MS-DOS. Distributed under the GNU GPL. * * Revision 1.14 2000/04/02 05:01:08 jtabor * Replaced ChgDir Code diff --git a/kernel/dosnames.c b/kernel/dosnames.c index 61b1f841..d34551d6 100644 --- a/kernel/dosnames.c +++ b/kernel/dosnames.c @@ -36,9 +36,16 @@ static BYTE *dosnamesRcsId = "$Id$"; /* * $Log$ + * Revision 1.3 2000/05/25 20:56:21 jimtabor + * Fixed project history + * * Revision 1.2 2000/05/08 04:29:59 jimtabor * Update CVS to 2020 * + * Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 + * The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with + * MS-DOS. Distributed under the GNU GPL. + * * Revision 1.4 2000/03/31 05:40:09 jtabor * Added Eric W. Biederman Patches * diff --git a/kernel/dsk.c b/kernel/dsk.c index 2d4da08b..e6123c02 100644 --- a/kernel/dsk.c +++ b/kernel/dsk.c @@ -33,6 +33,9 @@ static BYTE *dskRcsId = "$Id$"; /* * $Log$ + * Revision 1.5 2000/05/25 20:56:21 jimtabor + * Fixed project history + * * Revision 1.4 2000/05/17 19:15:12 jimtabor * Cleanup, add and fix source. * @@ -42,9 +45,9 @@ static BYTE *dskRcsId = "$Id$"; * Revision 1.2 2000/05/08 04:29:59 jimtabor * Update CVS to 2020 * - * $Log$ - * Revision 1.4 2000/05/17 19:15:12 jimtabor - * Cleanup, add and fix source. + * Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 + * The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with + * MS-DOS. Distributed under the GNU GPL. * * Revision 1.6 2000/04/29 05:13:16 jtabor * Added new functions and clean up code diff --git a/kernel/entry.asm b/kernel/entry.asm index 44e59fa0..b9f2c2fa 100644 --- a/kernel/entry.asm +++ b/kernel/entry.asm @@ -28,9 +28,16 @@ ; $Id$ ; ; $Log$ +; Revision 1.3 2000/05/25 20:56:21 jimtabor +; Fixed project history +; ; Revision 1.2 2000/05/08 04:29:59 jimtabor ; Update CVS to 2020 ; +; Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 +; The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with +; MS-DOS. Distributed under the GNU GPL. +; ; Revision 1.5 2000/03/20 03:15:49 kernel ; Change in Entry.asm ; diff --git a/kernel/error.c b/kernel/error.c index 6f230694..2f3b65ad 100644 --- a/kernel/error.c +++ b/kernel/error.c @@ -34,9 +34,16 @@ static BYTE *errorRcsId = "$Id$"; /* * $Log$ + * Revision 1.3 2000/05/25 20:56:21 jimtabor + * Fixed project history + * * Revision 1.2 2000/05/08 04:30:00 jimtabor * Update CVS to 2020 * + * Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 + * The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with + * MS-DOS. Distributed under the GNU GPL. + * * Revision 1.2 2000/03/09 06:07:11 kernel * 2017f updates by James Tabor * diff --git a/kernel/execrh.asm b/kernel/execrh.asm index 24e47a97..a67a5e9d 100644 --- a/kernel/execrh.asm +++ b/kernel/execrh.asm @@ -30,9 +30,16 @@ ; $Id$ ; ; $Log$ +; Revision 1.3 2000/05/25 20:56:21 jimtabor +; Fixed project history +; ; Revision 1.2 2000/05/08 04:30:00 jimtabor ; Update CVS to 2020 ; +; Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 +; The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with +; MS-DOS. Distributed under the GNU GPL. +; ; Revision 1.3 2000/03/09 06:07:11 kernel ; 2017f updates by James Tabor ; diff --git a/kernel/fatdir.c b/kernel/fatdir.c index 11e09289..22e90e1b 100644 --- a/kernel/fatdir.c +++ b/kernel/fatdir.c @@ -36,15 +36,18 @@ static BYTE *fatdirRcsId = "$Id$"; /* * $Log$ + * Revision 1.4 2000/05/25 20:56:21 jimtabor + * Fixed project history + * * Revision 1.3 2000/05/17 19:15:12 jimtabor * Cleanup, add and fix source. * * Revision 1.2 2000/05/08 04:30:00 jimtabor * Update CVS to 2020 * - * $Log$ - * Revision 1.3 2000/05/17 19:15:12 jimtabor - * Cleanup, add and fix source. + * Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 + * The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with + * MS-DOS. Distributed under the GNU GPL. * * Revision 1.12 2000/03/31 05:40:09 jtabor * Added Eric W. Biederman Patches diff --git a/kernel/fatfs.c b/kernel/fatfs.c index f4ff6a83..ce2d95a7 100644 --- a/kernel/fatfs.c +++ b/kernel/fatfs.c @@ -36,15 +36,18 @@ BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.4 2000/05/25 20:56:21 jimtabor + * Fixed project history + * * Revision 1.3 2000/05/11 04:26:26 jimtabor * Added code for DOS FN 69 & 6C * * Revision 1.2 2000/05/08 04:30:00 jimtabor * Update CVS to 2020 * - * $Log$ - * Revision 1.3 2000/05/11 04:26:26 jimtabor - * Added code for DOS FN 69 & 6C + * Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 + * The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with + * MS-DOS. Distributed under the GNU GPL. * * Revision 1.23 2000/04/29 05:13:16 jtabor * Added new functions and clean up code diff --git a/kernel/fattab.c b/kernel/fattab.c index 9a21424f..671b5a42 100644 --- a/kernel/fattab.c +++ b/kernel/fattab.c @@ -35,9 +35,16 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.3 2000/05/25 20:56:21 jimtabor + * Fixed project history + * * Revision 1.2 2000/05/08 04:30:00 jimtabor * Update CVS to 2020 * + * Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 + * The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with + * MS-DOS. Distributed under the GNU GPL. + * * Revision 1.6 1999/08/10 18:03:42 jprice * ror4 2011-03 patch * diff --git a/kernel/fcbfns.c b/kernel/fcbfns.c index 6086577c..5d7f630c 100644 --- a/kernel/fcbfns.c +++ b/kernel/fcbfns.c @@ -35,9 +35,16 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.3 2000/05/25 20:56:21 jimtabor + * Fixed project history + * * Revision 1.2 2000/05/08 04:30:00 jimtabor * Update CVS to 2020 * + * Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 + * The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with + * MS-DOS. Distributed under the GNU GPL. + * * Revision 1.7 2000/03/31 05:40:09 jtabor * Added Eric W. Biederman Patches * diff --git a/kernel/globals.h b/kernel/globals.h index 11ce1b09..b38af576 100644 --- a/kernel/globals.h +++ b/kernel/globals.h @@ -36,9 +36,16 @@ static BYTE *Globals_hRcsId = "$Id$"; /* * $Log$ + * Revision 1.3 2000/05/25 20:56:21 jimtabor + * Fixed project history + * * Revision 1.2 2000/05/08 04:30:00 jimtabor * Update CVS to 2020 * + * Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 + * The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with + * MS-DOS. Distributed under the GNU GPL. + * * Revision 1.17 2000/03/16 03:28:49 kernel * *** empty log message *** * diff --git a/kernel/initoem.c b/kernel/initoem.c index c6b72544..c43529be 100644 --- a/kernel/initoem.c +++ b/kernel/initoem.c @@ -38,9 +38,16 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.3 2000/05/25 20:56:21 jimtabor + * Fixed project history + * * Revision 1.2 2000/05/08 04:30:00 jimtabor * Update CVS to 2020 * + * Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 + * The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with + * MS-DOS. Distributed under the GNU GPL. + * * Revision 1.3 2000/03/09 06:07:11 kernel * 2017f updates by James Tabor * diff --git a/kernel/int2f.asm b/kernel/int2f.asm index 43561850..e2a1a823 100644 --- a/kernel/int2f.asm +++ b/kernel/int2f.asm @@ -30,15 +30,18 @@ ; $Id$ ; ; $Log$ +; Revision 1.4 2000/05/25 20:56:21 jimtabor +; Fixed project history +; ; Revision 1.3 2000/05/17 19:15:12 jimtabor ; Cleanup, add and fix source. ; ; Revision 1.2 2000/05/08 04:30:00 jimtabor ; Update CVS to 2020 ; -; $Log$ -; Revision 1.3 2000/05/17 19:15:12 jimtabor -; Cleanup, add and fix source. +; Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 +; The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with +; MS-DOS. Distributed under the GNU GPL. ; ; Revision 1.4 2000/03/31 05:40:09 jtabor ; Added Eric W. Biederman Patches diff --git a/kernel/inthndlr.c b/kernel/inthndlr.c index 9ac07d15..933ccbb7 100644 --- a/kernel/inthndlr.c +++ b/kernel/inthndlr.c @@ -36,6 +36,9 @@ BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.7 2000/05/25 20:56:21 jimtabor + * Fixed project history + * * Revision 1.6 2000/05/17 19:15:12 jimtabor * Cleanup, add and fix source. * @@ -51,9 +54,9 @@ BYTE *RcsId = "$Id$"; * Revision 1.2 2000/05/08 04:30:00 jimtabor * Update CVS to 2020 * - * $Log$ - * Revision 1.6 2000/05/17 19:15:12 jimtabor - * Cleanup, add and fix source. + * Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 + * The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with + * MS-DOS. Distributed under the GNU GPL. * * Revision 1.24 2000/04/29 05:13:16 jtabor * Added new functions and clean up code diff --git a/kernel/io.asm b/kernel/io.asm index a5fe8dd3..6a84f06d 100644 --- a/kernel/io.asm +++ b/kernel/io.asm @@ -28,9 +28,16 @@ ; $Header$ ; ; $Log$ +; Revision 1.3 2000/05/25 20:56:21 jimtabor +; Fixed project history +; ; Revision 1.2 2000/05/08 04:30:00 jimtabor ; Update CVS to 2020 ; +; Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 +; The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with +; MS-DOS. Distributed under the GNU GPL. +; ; Revision 1.3 2000/03/09 06:07:11 kernel ; 2017f updates by James Tabor ; diff --git a/kernel/io.inc b/kernel/io.inc index 37ded371..6a7d223b 100644 --- a/kernel/io.inc +++ b/kernel/io.inc @@ -30,9 +30,16 @@ ; $Header$ ; ; $Log$ +; Revision 1.3 2000/05/25 20:56:21 jimtabor +; Fixed project history +; ; Revision 1.2 2000/05/08 04:30:00 jimtabor ; Update CVS to 2020 ; +; Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 +; The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with +; MS-DOS. Distributed under the GNU GPL. +; ; Revision 1.3 1999/08/10 17:57:12 jprice ; ror4 2011-02 patch ; diff --git a/kernel/ioctl.c b/kernel/ioctl.c index 0ced4c91..4c354ecd 100644 --- a/kernel/ioctl.c +++ b/kernel/ioctl.c @@ -35,6 +35,9 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.5 2000/05/25 20:56:21 jimtabor + * Fixed project history + * * Revision 1.4 2000/05/17 19:15:12 jimtabor * Cleanup, add and fix source. * @@ -44,9 +47,9 @@ static BYTE *RcsId = "$Id$"; * Revision 1.2 2000/05/08 04:30:00 jimtabor * Update CVS to 2020 * - * $Log$ - * Revision 1.4 2000/05/17 19:15:12 jimtabor - * Cleanup, add and fix source. + * Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 + * The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with + * MS-DOS. Distributed under the GNU GPL. * * Revision 1.4 2000/04/29 05:13:16 jtabor * Added new functions and clean up code diff --git a/kernel/irqstack.asm b/kernel/irqstack.asm index 53d6bb3e..38262ff9 100644 --- a/kernel/irqstack.asm +++ b/kernel/irqstack.asm @@ -29,9 +29,16 @@ ; $Id$ ; ; $Log$ +; Revision 1.3 2000/05/25 20:56:21 jimtabor +; Fixed project history +; ; Revision 1.2 2000/05/08 04:30:00 jimtabor ; Update CVS to 2020 ; +; Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 +; The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with +; MS-DOS. Distributed under the GNU GPL. +; ; Revision 1.3 1999/08/10 17:57:13 jprice ; ror4 2011-02 patch ; diff --git a/kernel/kernel.asm b/kernel/kernel.asm index 6109a7bb..055c8ea4 100644 --- a/kernel/kernel.asm +++ b/kernel/kernel.asm @@ -28,9 +28,16 @@ ; $Id$ ; ; $Log$ +; Revision 1.3 2000/05/25 20:56:21 jimtabor +; Fixed project history +; ; Revision 1.2 2000/05/08 04:30:00 jimtabor ; Update CVS to 2020 ; +; Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 +; The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with +; MS-DOS. Distributed under the GNU GPL. +; ; Revision 1.6 2000/03/09 06:07:11 kernel ; 2017f updates by James Tabor ; diff --git a/kernel/kernel.mak b/kernel/kernel.mak index 53a9fe17..75f49960 100644 --- a/kernel/kernel.mak +++ b/kernel/kernel.mak @@ -5,9 +5,16 @@ # # $Log$ +# Revision 1.3 2000/05/25 20:56:21 jimtabor +# Fixed project history +# # Revision 1.2 2000/05/08 04:30:00 jimtabor # Update CVS to 2020 # +# Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 +# The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with +# MS-DOS. Distributed under the GNU GPL. +# # Revision 1.14 2000/03/31 05:40:09 jtabor # Added Eric W. Biederman Patches # diff --git a/kernel/main.c b/kernel/main.c index 6bfdcb4f..9f585db0 100644 --- a/kernel/main.c +++ b/kernel/main.c @@ -39,15 +39,18 @@ static BYTE *mainRcsId = "$Id$"; /* * $Log$ + * Revision 1.4 2000/05/25 20:56:21 jimtabor + * Fixed project history + * * Revision 1.3 2000/05/17 19:15:12 jimtabor * Cleanup, add and fix source. * * Revision 1.2 2000/05/08 04:30:00 jimtabor * Update CVS to 2020 * - * $Log$ - * Revision 1.3 2000/05/17 19:15:12 jimtabor - * Cleanup, add and fix source. + * Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 + * The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with + * MS-DOS. Distributed under the GNU GPL. * * Revision 1.14 2000/03/31 05:40:09 jtabor * Added Eric W. Biederman Patches diff --git a/kernel/memmgr.c b/kernel/memmgr.c index 1bc0474c..f5b26645 100644 --- a/kernel/memmgr.c +++ b/kernel/memmgr.c @@ -35,9 +35,16 @@ static BYTE *memmgrRcsId = "$Id$"; /* * $Log$ + * Revision 1.3 2000/05/25 20:56:21 jimtabor + * Fixed project history + * * Revision 1.2 2000/05/08 04:30:00 jimtabor * Update CVS to 2020 * + * Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 + * The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with + * MS-DOS. Distributed under the GNU GPL. + * * Revision 1.4 2000/03/09 06:07:11 kernel * 2017f updates by James Tabor * diff --git a/kernel/misc.c b/kernel/misc.c index 509946eb..bdfb5870 100644 --- a/kernel/misc.c +++ b/kernel/misc.c @@ -34,9 +34,16 @@ static BYTE *miscRcsId = "$Id$"; /* * $Log$ + * Revision 1.3 2000/05/25 20:56:21 jimtabor + * Fixed project history + * * Revision 1.2 2000/05/08 04:30:00 jimtabor * Update CVS to 2020 * + * Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 + * The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with + * MS-DOS. Distributed under the GNU GPL. + * * Revision 1.4 2000/03/09 06:07:11 kernel * 2017f updates by James Tabor * diff --git a/kernel/network.c b/kernel/network.c index abb6162b..3d1e2678 100644 --- a/kernel/network.c +++ b/kernel/network.c @@ -36,15 +36,18 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.4 2000/05/25 20:56:21 jimtabor + * Fixed project history + * * Revision 1.3 2000/05/17 19:15:12 jimtabor * Cleanup, add and fix source. * * Revision 1.2 2000/05/08 04:30:00 jimtabor * Update CVS to 2020 * - * $Log$ - * Revision 1.3 2000/05/17 19:15:12 jimtabor - * Cleanup, add and fix source. + * Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 + * The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with + * MS-DOS. Distributed under the GNU GPL. * * Revision 1.5 2000/03/31 05:40:09 jtabor * Added Eric W. Biederman Patches diff --git a/kernel/newstuff.c b/kernel/newstuff.c index 71eeea5a..0b450d31 100644 --- a/kernel/newstuff.c +++ b/kernel/newstuff.c @@ -31,15 +31,18 @@ static BYTE *mainRcsId = "$Id$"; /* * $Log$ + * Revision 1.4 2000/05/25 20:56:21 jimtabor + * Fixed project history + * * Revision 1.3 2000/05/17 19:15:12 jimtabor * Cleanup, add and fix source. * * Revision 1.2 2000/05/08 04:30:00 jimtabor * Update CVS to 2020 * - * $Log$ - * Revision 1.3 2000/05/17 19:15:12 jimtabor - * Cleanup, add and fix source. + * Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 + * The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with + * MS-DOS. Distributed under the GNU GPL. * * Revision 1.8 2000/04/02 06:11:35 jtabor * Fix ChgDir Code diff --git a/kernel/nls.c b/kernel/nls.c index 01e7d9fe..a909c78e 100644 --- a/kernel/nls.c +++ b/kernel/nls.c @@ -38,9 +38,16 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.3 2000/05/25 20:56:21 jimtabor + * Fixed project history + * * Revision 1.2 2000/05/08 04:30:00 jimtabor * Update CVS to 2020 * + * Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 + * The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with + * MS-DOS. Distributed under the GNU GPL. + * * Revision 1.8 2000/03/17 22:59:04 kernel * Steffen Kaiser's NLS changes * diff --git a/kernel/nlssupt.asm b/kernel/nlssupt.asm index c5474f6e..6c9d9c41 100644 --- a/kernel/nlssupt.asm +++ b/kernel/nlssupt.asm @@ -29,9 +29,16 @@ ; $Id$ ; ; $Log$ +; Revision 1.3 2000/05/25 20:56:21 jimtabor +; Fixed project history +; ; Revision 1.2 2000/05/08 04:30:00 jimtabor ; Update CVS to 2020 ; +; Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 +; The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with +; MS-DOS. Distributed under the GNU GPL. +; ; Revision 1.3 2000/03/17 22:59:04 kernel ; Steffen Kaiser's NLS changes ; diff --git a/kernel/prf.c b/kernel/prf.c index 8cae78a8..919ebf21 100644 --- a/kernel/prf.c +++ b/kernel/prf.c @@ -34,9 +34,16 @@ static BYTE *prfRcsId = "$Id$"; /* * $Log$ + * Revision 1.3 2000/05/25 20:56:21 jimtabor + * Fixed project history + * * Revision 1.2 2000/05/08 04:30:00 jimtabor * Update CVS to 2020 * + * Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 + * The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with + * MS-DOS. Distributed under the GNU GPL. + * * Revision 1.3 2000/03/09 06:07:11 kernel * 2017f updates by James Tabor * diff --git a/kernel/printer.asm b/kernel/printer.asm index e380f6c6..a3718a88 100644 --- a/kernel/printer.asm +++ b/kernel/printer.asm @@ -28,9 +28,16 @@ ; $Header$ ; ; $Log$ +; Revision 1.3 2000/05/25 20:56:21 jimtabor +; Fixed project history +; ; Revision 1.2 2000/05/08 04:30:00 jimtabor ; Update CVS to 2020 ; +; Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 +; The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with +; MS-DOS. Distributed under the GNU GPL. +; ; Revision 1.2 1999/08/10 17:57:13 jprice ; ror4 2011-02 patch ; diff --git a/kernel/procsupt.asm b/kernel/procsupt.asm index 5a185db8..ed2bede7 100644 --- a/kernel/procsupt.asm +++ b/kernel/procsupt.asm @@ -30,9 +30,16 @@ ; $Id$ ; ; $Log$ +; Revision 1.3 2000/05/25 20:56:21 jimtabor +; Fixed project history +; ; Revision 1.2 2000/05/08 04:30:00 jimtabor ; Update CVS to 2020 ; +; Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 +; The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with +; MS-DOS. Distributed under the GNU GPL. +; ; Revision 1.4 1999/08/10 17:57:13 jprice ; ror4 2011-02 patch ; diff --git a/kernel/proto.h b/kernel/proto.h index 23dd1419..565616e9 100644 --- a/kernel/proto.h +++ b/kernel/proto.h @@ -34,9 +34,16 @@ static BYTE *Proto_hRcsId = "$Id$"; /* * $Log$ + * Revision 1.3 2000/05/25 20:56:21 jimtabor + * Fixed project history + * * Revision 1.2 2000/05/08 04:30:00 jimtabor * Update CVS to 2020 * + * Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 + * The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with + * MS-DOS. Distributed under the GNU GPL. + * * Revision 1.17 2000/03/31 05:40:09 jtabor * Added Eric W. Biederman Patches * diff --git a/kernel/segs.inc b/kernel/segs.inc index 271c27d1..11d3c452 100644 --- a/kernel/segs.inc +++ b/kernel/segs.inc @@ -29,9 +29,16 @@ ; $Header$ ; ; $Log$ +; Revision 1.3 2000/05/25 20:56:21 jimtabor +; Fixed project history +; ; Revision 1.2 2000/05/08 04:30:00 jimtabor ; Update CVS to 2020 ; +; Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 +; The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with +; MS-DOS. Distributed under the GNU GPL. +; ; Revision 1.2 1999/08/10 17:57:13 jprice ; ror4 2011-02 patch ; diff --git a/kernel/serial.asm b/kernel/serial.asm index 660a1b68..5dc886d6 100644 --- a/kernel/serial.asm +++ b/kernel/serial.asm @@ -28,9 +28,16 @@ ; $Header$ ; ; $Log$ +; Revision 1.3 2000/05/25 20:56:21 jimtabor +; Fixed project history +; ; Revision 1.2 2000/05/08 04:30:00 jimtabor ; Update CVS to 2020 ; +; Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 +; The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with +; MS-DOS. Distributed under the GNU GPL. +; ; Revision 1.2 1999/08/10 17:57:13 jprice ; ror4 2011-02 patch ; diff --git a/kernel/strings.c b/kernel/strings.c index 47baf4e2..93c1dff7 100644 --- a/kernel/strings.c +++ b/kernel/strings.c @@ -34,9 +34,16 @@ static BYTE *stringsRcsId = "$Id$"; /* * $Log$ + * Revision 1.3 2000/05/25 20:56:21 jimtabor + * Fixed project history + * * Revision 1.2 2000/05/08 04:30:00 jimtabor * Update CVS to 2020 * + * Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 + * The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with + * MS-DOS. Distributed under the GNU GPL. + * * Revision 1.4 2000/03/09 06:07:11 kernel * 2017f updates by James Tabor * diff --git a/kernel/sysclk.c b/kernel/sysclk.c index 4787e109..7e00f753 100644 --- a/kernel/sysclk.c +++ b/kernel/sysclk.c @@ -35,9 +35,16 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.3 2000/05/25 20:56:21 jimtabor + * Fixed project history + * * Revision 1.2 2000/05/08 04:30:00 jimtabor * Update CVS to 2020 * + * Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 + * The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with + * MS-DOS. Distributed under the GNU GPL. + * * Revision 1.3 2000/03/09 06:07:11 kernel * 2017f updates by James Tabor * diff --git a/kernel/syspack.c b/kernel/syspack.c index 7126f064..3e7d1ee7 100644 --- a/kernel/syspack.c +++ b/kernel/syspack.c @@ -36,9 +36,16 @@ static BYTE *syspackRcsId = "$Id$"; /* * $Log$ + * Revision 1.3 2000/05/25 20:56:21 jimtabor + * Fixed project history + * * Revision 1.2 2000/05/08 04:30:00 jimtabor * Update CVS to 2020 * + * Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 + * The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with + * MS-DOS. Distributed under the GNU GPL. + * * Revision 1.1.1.1 1999/03/29 15:42:21 jprice * New version without IPL.SYS * diff --git a/kernel/systime.c b/kernel/systime.c index 5e8b1e9f..d2376180 100644 --- a/kernel/systime.c +++ b/kernel/systime.c @@ -37,9 +37,16 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.3 2000/05/25 20:56:21 jimtabor + * Fixed project history + * * Revision 1.2 2000/05/08 04:30:00 jimtabor * Update CVS to 2020 * + * Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 + * The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with + * MS-DOS. Distributed under the GNU GPL. + * * Revision 1.3 1999/05/04 16:40:30 jprice * ror4 date fix * diff --git a/kernel/task.c b/kernel/task.c index fd15ae19..976ddfa6 100644 --- a/kernel/task.c +++ b/kernel/task.c @@ -35,9 +35,16 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.3 2000/05/25 20:56:21 jimtabor + * Fixed project history + * * Revision 1.2 2000/05/08 04:30:00 jimtabor * Update CVS to 2020 * + * Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 + * The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with + * MS-DOS. Distributed under the GNU GPL. + * * Revision 1.8 2000/03/31 05:40:09 jtabor * Added Eric W. Biederman Patches * diff --git a/lib/libm.mak b/lib/libm.mak index 8086e21b..55763177 100644 --- a/lib/libm.mak +++ b/lib/libm.mak @@ -5,9 +5,16 @@ # # $Log$ +# Revision 1.3 2000/05/25 20:56:22 jimtabor +# Fixed project history +# # Revision 1.2 2000/05/11 03:57:10 jimtabor # Clean up and Release # +# Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 +# The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with +# MS-DOS. Distributed under the GNU GPL. +# # Revision 1.6 1999/09/14 17:32:20 jprice # no message # diff --git a/sys/bin2c.mak b/sys/bin2c.mak index fe19f8cb..ae4a92c5 100644 --- a/sys/bin2c.mak +++ b/sys/bin2c.mak @@ -3,11 +3,17 @@ # # $Id$ # - # $Log$ +# Revision 1.3 2000/05/25 20:56:23 jimtabor +# Fixed project history +# # Revision 1.2 2000/05/15 05:28:09 jimtabor # Cleanup CRs # +# Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 +# The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with +# MS-DOS. Distributed under the GNU GPL. +# # Revision 1.6 1999/09/20 18:34:40 jprice # *** empty log message *** # diff --git a/sys/sys.c b/sys/sys.c index bf271d90..8cd699d6 100644 --- a/sys/sys.c +++ b/sys/sys.c @@ -27,45 +27,52 @@ ***************************************************************/ /* $Log$ + * Revision 1.3 2000/05/25 20:56:23 jimtabor + * Fixed project history + * * Revision 1.2 2000/05/15 05:28:09 jimtabor * Cleanup CRs * -/* Revision 1.10 2000/03/31 06:59:10 jprice -/* Added discription of program. -/* -/* Revision 1.9 1999/09/20 18:34:40 jprice -/* *** empty log message *** -/* -/* Revision 1.8 1999/09/20 18:27:19 jprice -/* Changed open/creat to fopen to make TC2 happy. -/* -/* Revision 1.7 1999/09/15 05:39:02 jprice -/* Changed boot sector writing code so easier to read. -/* -/* Revision 1.6 1999/09/14 17:30:44 jprice -/* Added debug log creation to sys.com. -/* -/* Revision 1.5 1999/08/25 03:19:51 jprice -/* ror4 patches to allow TC 2.01 compile. -/* -/* Revision 1.4 1999/04/17 19:14:44 jprice -/* Fixed multi-sector code -/* -/* Revision 1.3 1999/04/01 07:24:05 jprice -/* SYS modified for new boot loader -/* -/* Revision 1.2 1999/03/29 16:24:48 jprice -/* Fixed error message -/* -/* Revision 1.1.1.1 1999/03/29 15:43:15 jprice -/* New version without IPL.SYS -/* Revision 1.3 1999/01/21 04:35:21 jprice Fixed comments. - Added indent program - -Revision 1.2 1999/01/21 04:13:52 jprice Added messages to sys. Also made - it create a .COM file. - -*/ + * Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 + * The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with + * MS-DOS. Distributed under the GNU GPL. + * + * Revision 1.10 2000/03/31 06:59:10 jprice + * Added discription of program. + * + * Revision 1.9 1999/09/20 18:34:40 jprice + * *** empty log message *** + * + * Revision 1.8 1999/09/20 18:27:19 jprice + * Changed open/creat to fopen to make TC2 happy. + * + * Revision 1.7 1999/09/15 05:39:02 jprice + * Changed boot sector writing code so easier to read. + * + * Revision 1.6 1999/09/14 17:30:44 jprice + * Added debug log creation to sys.com. + * + * Revision 1.5 1999/08/25 03:19:51 jprice + * ror4 patches to allow TC 2.01 compile. + * + * Revision 1.4 1999/04/17 19:14:44 jprice + * Fixed multi-sector code + * + * Revision 1.3 1999/04/01 07:24:05 jprice + * SYS modified for new boot loader + * + * Revision 1.2 1999/03/29 16:24:48 jprice + * Fixed error message + * + * Revision 1.1.1.1 1999/03/29 15:43:15 jprice + * New version without IPL.SYS + * Revision 1.3 1999/01/21 04:35:21 jprice Fixed comments. + * Added indent program + * + * Revision 1.2 1999/01/21 04:13:52 jprice Added messages to sys. Also made + * it create a .COM file. + * + */ #define STORE_BOOT_INFO diff --git a/sys/sys.mak b/sys/sys.mak index 307b0d6d..3c99efa7 100644 --- a/sys/sys.mak +++ b/sys/sys.mak @@ -3,11 +3,17 @@ # # $Id$ # - # $Log$ +# Revision 1.3 2000/05/25 20:56:23 jimtabor +# Fixed project history +# # Revision 1.2 2000/05/15 05:28:09 jimtabor # Cleanup CRs # +# Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 +# The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with +# MS-DOS. Distributed under the GNU GPL. +# # Revision 1.10 1999/09/23 04:41:43 jprice # *** empty log message *** # From edf98624fbe105eb45da3c67798dba04ae5bd679 Mon Sep 17 00:00:00 2001 From: Jim Tabor Date: Fri, 26 May 2000 19:25:19 +0000 Subject: [PATCH 017/671] Read History file for Change info git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@27 6ac86273-5f31-0410-b378-82cca8765d1b --- docs/history.txt | 29 ++++++ kernel/chario.c | 15 +-- kernel/config.c | 15 +-- kernel/console.asm | 23 +++-- kernel/dosfns.c | 222 ++++++++++++++++++++++++--------------------- kernel/dosnames.c | 44 ++------- kernel/dsk.c | 21 ++++- kernel/fatdir.c | 28 +++--- kernel/fcbfns.c | 47 ++-------- kernel/io.asm | 5 +- kernel/main.c | 20 ++-- kernel/network.c | 18 ++-- kernel/newstuff.c | 42 +++++++++ kernel/proto.h | 10 +- kernel/task.c | 10 +- 15 files changed, 312 insertions(+), 237 deletions(-) diff --git a/docs/history.txt b/docs/history.txt index b1565a49..8b30a471 100644 --- a/docs/history.txt +++ b/docs/history.txt @@ -1,3 +1,32 @@ +2000 May 26 - Build 2020 +-------- James Tabor (jimtabor@infohwy.com) + Code Clean up and Now the Release. + +2000 May 26 - Build 2020 +-------- James Tabor (jimtabor@infohwy.com) ++ Fixed IsDevice is used in FcbFns.c and DosFns.c. I removed IsDevice + from DosNames.c an placed it in DosFns.c. FcbFns had dup code + and it was removed. This fixed all the functions using IsDevice. + + Truename works now. I consider it dangerous and brain damaged. + Note: + truename X:\DIR\con -> X:/CON, note the '/'. + truename foo*.* -> X:\DIR\FOO?????.??? + truename *.*\*.*\*.* -> ????????.???\????????.???\????????.??? + truename *.*\*.**\*.* -> endless Loop + I will fix this later ;^) + + Found InitPSP running 3 time. On the 2'nd run the standard handles + were closed with out DosClose. Now Device Drivers can Print out + there startup info. + ++ Added New IOCTL code in Dsk.c. + +2000 May 26 - Build 2020 +-------- James Tabor (jimtabor@infohwy.com) ++ Fix Kolyan Ksenev (7207@mx.csd.tsu.ru) (nik0la@acm.org) + found Major bugs in Task.c and chario.c. + 2000 May 25 - Build 2020 -------- James Tabor (jimtabor@infohwy.com) + Fixed Project history. diff --git a/kernel/chario.c b/kernel/chario.c index 75083e2a..45aa2bef 100644 --- a/kernel/chario.c +++ b/kernel/chario.c @@ -36,6 +36,9 @@ static BYTE *charioRcsId = "$Id$"; /* * $Log$ + * Revision 1.4 2000/05/26 19:25:19 jimtabor + * Read History file for Change info + * * Revision 1.3 2000/05/25 20:56:21 jimtabor * Fixed project history * @@ -142,9 +145,9 @@ struct dhdr FAR *finddev(UWORD attr_mask) /* return dev/null if no matching driver found */ return &nul_dev; } -/* - VOID cso(COUNT c) - { + +VOID cso(COUNT c) +{ BYTE buf = c; struct dhdr FAR *lpDevice; @@ -157,14 +160,14 @@ struct dhdr FAR *finddev(UWORD attr_mask) lpDevice = (struct dhdr FAR *)finddev(ATTR_CONOUT)); if (CharReqHdr.r_status & S_ERROR) char_error(&CharReqHdr, lpDevice); - } - */ +} + VOID sto(COUNT c) { static COUNT scratch; /* make this static to save stack space */ - DosWrite(STDOUT, 1, (BYTE FAR *) & c, (COUNT FAR *) scratch); + DosWrite(STDOUT, 1, (BYTE FAR *) & c, (COUNT FAR *) &scratch); } VOID mod_sto(REG UCOUNT c) diff --git a/kernel/config.c b/kernel/config.c index 23a385a7..f8dfae49 100644 --- a/kernel/config.c +++ b/kernel/config.c @@ -39,6 +39,9 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.4 2000/05/26 19:25:19 jimtabor + * Read History file for Change info + * * Revision 1.3 2000/05/25 20:56:21 jimtabor * Fixed project history * @@ -790,12 +793,12 @@ INIT static VOID Device(BYTE * pLine) if (DosExec(3, &eb, szBuf) == SUCCESS) { - while (FP_OFF(dhp) != 0xFFFF) - { - next_dhp = MK_FP(FP_SEG(dhp), FP_OFF(dhp->dh_next)); - dhp->dh_next = nul_dev.dh_next; - link_dhdr(&nul_dev, dhp, pLine); - dhp = next_dhp; + /* Link in device driver and save nul_dev pointer to next */ + next_dhp = dhp->dh_next = nul_dev.dh_next; + nul_dev.dh_next = dhp; + + if(init_device(dhp, pLine)){ + nul_dev.dh_next = next_dhp; /* return orig pointer if error */ } } else diff --git a/kernel/console.asm b/kernel/console.asm index bc2a6eb3..9673def1 100644 --- a/kernel/console.asm +++ b/kernel/console.asm @@ -28,6 +28,9 @@ ; $Header$ ; ; $Log$ +; Revision 1.4 2000/05/26 19:25:19 jimtabor +; Read History file for Change info +; ; Revision 1.3 2000/05/25 20:56:21 jimtabor ; Fixed project history ; @@ -216,16 +219,16 @@ IntRetn: iret - global _cso -_cso - push bp - mov bp,sp - push ax - mov ax,[bp+4] - int 29h - pop ax - pop bp - retn +; global _cso +;_cso +; push bp +; mov bp,sp +; push ax +; mov ax,[bp+4] +; int 29h +; pop ax +; pop bp +; retn global _int29_handler _int29_handler: diff --git a/kernel/dosfns.c b/kernel/dosfns.c index 17ddd019..2987e6a1 100644 --- a/kernel/dosfns.c +++ b/kernel/dosfns.c @@ -34,6 +34,9 @@ static BYTE *dosfnsRcsId = "$Id$"; /* * $Log$ + * Revision 1.5 2000/05/26 19:25:19 jimtabor + * Read History file for Change info + * * Revision 1.4 2000/05/25 20:56:21 jimtabor * Fixed project history * @@ -134,9 +137,7 @@ static BYTE *dosfnsRcsId = "$Id$"; sft FAR *get_sft(COUNT); WORD get_free_hndl(VOID); sft FAR *get_free_sft(WORD FAR *); -BYTE FAR *get_root(BYTE FAR *); BOOL cmatch(COUNT, COUNT, COUNT); -BOOL fnmatch(BYTE FAR *, BYTE FAR *, COUNT, COUNT); struct f_node FAR *xlt_fd(COUNT); @@ -220,8 +221,8 @@ UCOUNT GenericRead(COUNT hndl, UCOUNT n, BYTE FAR * bp, COUNT FAR * err, } /* - * Do remote first or return error. - * must have been opened from remote. + * Do remote first or return error. + * must have been opened from remote. */ if (s->sft_flags & SFT_FSHARED) { @@ -338,6 +339,7 @@ UCOUNT DosWrite(COUNT hndl, UCOUNT n, BYTE FAR * bp, COUNT FAR * err) *err = DE_ACCESS; return 0; } + if (s->sft_flags & SFT_FSHARED) { WriteCount = Remote_RW(REM_WRITE, n, bp, s, err); @@ -510,40 +512,57 @@ COUNT SftSeek(sft FAR *s, LONG new_pos, COUNT mode) if (s->sft_flags & SFT_FSHARED) { - if (mode == 2) { - /* seek from end of file */ - int2f_Remote_call(REM_LSEEK, 0, (UWORD) FP_SEG(new_pos), (UWORD) FP_OFF(new_pos), (VOID FAR *) s, 0, (VOID FAR *)&data); - s->sft_posit = data; - - return SUCCESS; + /* seek from end of file */ + if (mode == 2) { +/* + * RB list has it as Note: + * this function is called by the DOS 3.1+ kernel, but only when seeking + * from the end of a file opened with sharing modes set in such a manner + * that another process is able to change the size of the file while it + * is already open + * Tested this with Shsucdx ver 0.06 and 1.0. Both now work. + * Lredir via mfs.c from DosEMU works when writing appended files. + * Mfs.c looks for these mode bits set, so here is my best guess.;^) + */ + if ((s->sft_mode & SFT_MDENYREAD) || (s->sft_mode & SFT_MDENYNONE)) + { + int2f_Remote_call(REM_LSEEK, 0, (UWORD) FP_SEG(new_pos), (UWORD) FP_OFF(new_pos), (VOID FAR *) s, 0, (VOID FAR *)&data); + s->sft_posit = data; + return SUCCESS; + } + else + { + s->sft_posit = s->sft_size - new_pos; + return SUCCESS; + } } - if (mode == 0) { - s->sft_posit = new_pos; - return SUCCESS; + if (mode == 0) { + s->sft_posit = new_pos; + return SUCCESS; } - if (mode == 1) { - s->sft_posit += new_pos; - return SUCCESS; + if (mode == 1) { + s->sft_posit += new_pos; + return SUCCESS; } return DE_INVLDFUNC; - } + } - /* Do special return for character devices */ - if (s->sft_flags & SFT_FDEVICE) - { + /* Do special return for character devices */ + if (s->sft_flags & SFT_FDEVICE) + { s->sft_posit = 0l; - return SUCCESS; - } - else - { + return SUCCESS; + } + else + { LONG result = dos_lseek(s->sft_status, new_pos, mode); if (result < 0l) return (int)result; else { s->sft_posit = result; - return SUCCESS; - } - } + return SUCCESS; + } + } } COUNT DosSeek(COUNT hndl, LONG new_pos, COUNT mode, ULONG * set_pos) @@ -603,7 +622,7 @@ static sft FAR *get_free_sft(WORD FAR * sft_idx) return (sft FAR *) - 1; } -static BYTE FAR *get_root(BYTE FAR * fname) +BYTE FAR *get_root(BYTE FAR * fname) { BYTE FAR *froot; REG WORD length; @@ -629,7 +648,7 @@ static BOOL cmatch(COUNT s, COUNT d, COUNT mode) return s == d; } -static BOOL fnmatch(BYTE FAR * s, BYTE FAR * d, COUNT n, COUNT mode) +BOOL fnmatch(BYTE FAR * s, BYTE FAR * d, COUNT n, COUNT mode) { while (n--) { @@ -649,7 +668,7 @@ COUNT DosCreat(BYTE FAR * fname, COUNT attrib) WORD i; COUNT result, drive; - /* get a free handle */ + /* get a free handle */ if ((hndl = get_free_hndl()) == 0xff) return DE_TOOMANY; @@ -657,25 +676,9 @@ COUNT DosCreat(BYTE FAR * fname, COUNT attrib) if ((sftp = get_free_sft((WORD FAR *) & sft_idx)) == (sft FAR *) - 1) return DE_TOOMANY; - /* check for a device */ - froot = get_root(fname); - for (i = 0; i < FNAME_SIZE; i++) - { - if (*froot != '\0' && *froot != '.') - PriPathName[i] = *froot++; - else - break; - } - - for (; i < FNAME_SIZE; i++) - PriPathName[i] = ' '; - - /* if we have an extension, can't be a device */ - if (*froot != '.') - { - for (dhp = (struct dhdr FAR *)&nul_dev; dhp != (struct dhdr FAR *)-1; dhp = dhp->dh_next) - { - if (fnmatch((BYTE FAR *) PriPathName, (BYTE FAR *) dhp->dh_name, FNAME_SIZE, FALSE)) + /* check for a device */ + dhp = IsDevice(fname); + if ( dhp ) { sftp->sft_count += 1; sftp->sft_mode = SFT_MRDWR; @@ -683,13 +686,11 @@ COUNT DosCreat(BYTE FAR * fname, COUNT attrib) sftp->sft_flags = ((dhp->dh_attr & ~SFT_MASK) & ~SFT_FSHARED) | SFT_FDEVICE | SFT_FEOF; sftp->sft_psp = cu_psp; - fbcopy((BYTE FAR *) PriPathName, sftp->sft_name, FNAME_SIZE + FEXT_SIZE); + fbcopy((BYTE FAR *) SecPathName, sftp->sft_name, FNAME_SIZE + FEXT_SIZE); sftp->sft_dev = dhp; p->ps_filetab[hndl] = sft_idx; return hndl; } - } - } drive = get_verify_drive(fname); if(drive < 0) { @@ -834,24 +835,8 @@ COUNT DosOpen(BYTE FAR * fname, COUNT mode) return DE_TOOMANY; /* check for a device */ - froot = get_root(fname); - for (i = 0; i < FNAME_SIZE; i++) - { - if (*froot != '\0' && *froot != '.') - PriPathName[i] = *froot++; - else - break; - } - - for (; i < FNAME_SIZE; i++) - PriPathName[i] = ' '; - - /* if we have an extension, can't be a device */ - if (*froot != '.') - { - for (dhp = (struct dhdr FAR *)&nul_dev; dhp != (struct dhdr FAR *)-1; dhp = dhp->dh_next) - { - if (fnmatch((BYTE FAR *) PriPathName, (BYTE FAR *) dhp->dh_name, FNAME_SIZE, FALSE)) + dhp = IsDevice(fname); + if ( dhp ) { sftp->sft_count += 1; sftp->sft_mode = mode; @@ -859,18 +844,15 @@ COUNT DosOpen(BYTE FAR * fname, COUNT mode) sftp->sft_flags = ((dhp->dh_attr & ~SFT_MASK) & ~SFT_FSHARED) | SFT_FDEVICE | SFT_FEOF; sftp->sft_psp = cu_psp; - fbcopy((BYTE FAR *) PriPathName, sftp->sft_name, FNAME_SIZE + FEXT_SIZE); + fbcopy((BYTE FAR *) SecPathName, sftp->sft_name, FNAME_SIZE + FEXT_SIZE); sftp->sft_dev = dhp; sftp->sft_date = dos_getdate(); sftp->sft_time = dos_gettime(); - p->ps_filetab[hndl] = sft_idx; return hndl; } - } - } - drive = get_verify_drive(fname); + drive = get_verify_drive(fname); if (drive < 0) { return drive; } @@ -988,9 +970,9 @@ VOID DosGetFree(COUNT drive, COUNT FAR * spc, COUNT FAR * navc, COUNT FAR * bps, { int2f_Remote_call(REM_GETSPACE, 0, 0, 0, cdsp, 0, &rg); - *spc = (COUNT) rg[0]; - *nc = (COUNT) rg[1]; - *bps = (COUNT) rg[2]; + *spc = (COUNT) rg[0]; + *nc = (COUNT) rg[1]; + *bps = (COUNT) rg[2]; *navc = (COUNT) rg[3]; return; } @@ -1031,7 +1013,7 @@ COUNT DosGetCuDir(COUNT drive, BYTE FAR * s) } cdsp = &CDSp->cds_table[drive]; - current_ldt = cdsp; + current_ldt = cdsp; if (!(cdsp->cdsFlags & CDSNETWDRV) && (cdsp->cdsDpb == 0)) { return DE_INVLDDRV; @@ -1067,7 +1049,7 @@ COUNT DosChangeDir(BYTE FAR * s) { #if defined(CHDIR_DEBUG) printf("Remote Chdir: n='"); - p = s; while(*p) print("%c", *p++); + p = s; while(*p) printf("%c", *p++); printf("' p='"); p = PriPathName; while(*p) printf("%c", *p++); printf("'\n"); @@ -1076,7 +1058,7 @@ COUNT DosChangeDir(BYTE FAR * s) #if defined(CHDIR_DEBUG) printf("status = %04x, new_path='", result); p = cdsd->cdsCurrentPath; while(p) printf("%c", *p++) - print("'\n"); + printf("'\n"); #endif result = -result; if (result != SUCCESS) { @@ -1103,7 +1085,6 @@ COUNT DosChangeDir(BYTE FAR * s) COUNT DosFindFirst(UCOUNT attr, BYTE FAR * name) { - SAttr = (BYTE) attr; return dos_findfirst(attr, name); } @@ -1180,13 +1161,11 @@ COUNT DosGetFattr(BYTE FAR * name, UWORD FAR * attrp) struct cds FAR *last_cds; BYTE FAR * p; -#if 0 - if (IsDevice(name)) { + if (IsDevice(name)) { return DE_PATHNOTFND; } -#endif - drive = get_verify_drive(name); + drive = get_verify_drive(name); if (drive < 0) { return drive; } @@ -1216,12 +1195,12 @@ COUNT DosSetFattr(BYTE FAR * name, UWORD FAR * attrp) struct cds FAR *last_cds; BYTE FAR *p; -#if 0 - if (IsDevice(name)) { + if (IsDevice(name) ) { + printf("SetAtt\n"); return DE_PATHNOTFND; } -#endif - drive = get_verify_drive(name); + + drive = get_verify_drive(name); if (drive < 0) { return drive; } @@ -1258,11 +1237,11 @@ BYTE DosSelectDrv(BYTE drv) COUNT DosDelete(BYTE FAR *path) { COUNT result, drive; -/* - if (IsDevice(path)) { + + if (IsDevice(path)) { return DE_PATHNOTFND; } - */ + drive = get_verify_drive(path); if (drive < 0) { return drive; @@ -1284,11 +1263,11 @@ COUNT DosDelete(BYTE FAR *path) COUNT DosRename(BYTE FAR * path1, BYTE FAR * path2) { COUNT result, drive1, drive2; -/* + if (IsDevice(path1) || IsDevice(path2)) { - return DE_PATHNOTFND; + return DE_PATHNOTFND; } - */ + drive1 = get_verify_drive(path1); result = truename(path1, PriPathName, FALSE); if (result != SUCCESS) { @@ -1315,11 +1294,11 @@ COUNT DosRename(BYTE FAR * path1, BYTE FAR * path2) COUNT DosMkdir(BYTE FAR * dir) { COUNT result, drive; -/* - if (IsDevice(dir)) { + + if (IsDevice(dir)) { return DE_PATHNOTFND; } - */ + drive = get_verify_drive(dir); if (drive < 0) { return drive; @@ -1341,11 +1320,11 @@ COUNT DosMkdir(BYTE FAR * dir) COUNT DosRmdir(BYTE FAR * dir) { COUNT result, drive; -/* - if (IsDevice(dir)) { + + if (IsDevice(dir)) { return DE_PATHNOTFND; } - */ + drive = get_verify_drive(dir); if (drive < 0) { return drive; @@ -1363,3 +1342,42 @@ COUNT DosRmdir(BYTE FAR * dir) } return result; } + +/* + * This seems to work well. + */ + +struct dhdr FAR * IsDevice(BYTE FAR * fname) +{ + struct dhdr FAR *dhp; + BYTE FAR *froot; + WORD i; + + /* check for a device */ + froot = get_root(fname); + for (i = 0; i < FNAME_SIZE; i++) + { + if (*froot != '\0' && *froot != '.') + SecPathName[i] = *froot++; + else + break; + } + + for (; i < FNAME_SIZE; i++) + SecPathName[i] = ' '; + + SecPathName[i] = 0; + /* if we have an extension, can't be a device */ + if (*froot != '.') + { + for (dhp = (struct dhdr FAR *)&nul_dev; dhp != (struct dhdr FAR *)-1; dhp = dhp->dh_next) + { + if (fnmatch((BYTE FAR *) SecPathName, (BYTE FAR *) dhp->dh_name, FNAME_SIZE, FALSE)) + { + return dhp; + } + } + } + return (struct dhdr FAR *)0; +} + diff --git a/kernel/dosnames.c b/kernel/dosnames.c index d34551d6..9daf82ff 100644 --- a/kernel/dosnames.c +++ b/kernel/dosnames.c @@ -36,6 +36,9 @@ static BYTE *dosnamesRcsId = "$Id$"; /* * $Log$ + * Revision 1.4 2000/05/26 19:25:19 jimtabor + * Read History file for Change info + * * Revision 1.3 2000/05/25 20:56:21 jimtabor * Fixed project history * @@ -46,6 +49,9 @@ static BYTE *dosnamesRcsId = "$Id$"; * The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with * MS-DOS. Distributed under the GNU GPL. * + * Revision 1.2 2000/05/08 04:29:59 jimtabor + * Update CVS to 2020 + * * Revision 1.4 2000/03/31 05:40:09 jtabor * Added Eric W. Biederman Patches * @@ -339,44 +345,6 @@ COUNT ParseDosPath(BYTE FAR * lpszFileName, return SUCCESS; } -BOOL IsDevice(BYTE FAR * pszFileName) -{ - REG struct dhdr FAR *dhp = (struct dhdr FAR *)&nul_dev; - BYTE szName[FNAME_SIZE]; - - /* break up the name first */ - if (ParseDosName(pszFileName, - (COUNT *) 0, TempBuffer, szName, (BYTE *) 0, FALSE) - != SUCCESS) - return FALSE; - SpacePad(szName, FNAME_SIZE); - - /* Test 1 - does it start with a \dev or /dev */ - if ((strcmp(szName, "/dev") == 0) - || (strcmp(szName, "\\dev") == 0)) - return TRUE; - - /* Test 2 - is it on the device chain? */ - for (; -1l != (LONG) dhp; dhp = dhp->dh_next) - { - COUNT nIdx; - - /* Skip if not char device */ - if (!(dhp->dh_attr & ATTR_CHAR)) - continue; - - /* now compare */ - for (nIdx = 0; nIdx < FNAME_SIZE; ++nIdx) - { - if (dhp->dh_name[nIdx] != szName[nIdx]) - break; - } - if (nIdx >= FNAME_SIZE) - return TRUE; - } - - return FALSE; -} VOID DosTrimPath(BYTE FAR * lpszPathNamep) { diff --git a/kernel/dsk.c b/kernel/dsk.c index e6123c02..a4d0c92d 100644 --- a/kernel/dsk.c +++ b/kernel/dsk.c @@ -33,6 +33,9 @@ static BYTE *dskRcsId = "$Id$"; /* * $Log$ + * Revision 1.6 2000/05/26 19:25:19 jimtabor + * Read History file for Change info + * * Revision 1.5 2000/05/25 20:56:21 jimtabor * Fixed project history * @@ -160,6 +163,12 @@ static struct FS_info BYTE fs_fstype[8]; }; +static struct Access_info +{ + BYTE AI_spec; + BYTE AI_Flag; +}; + static struct media_info miarray[NDEV]; /* Internal media info structs */ static struct FS_info fsarray[NDEV]; static bpb bpbarray[NDEV]; /* BIOS parameter blocks */ @@ -603,8 +612,10 @@ static WORD IoctlQueblk(rqptr rp) { switch(rp->r_count){ case 0x0846: + case 0x0847: case 0x0860: case 0x0866: + case 0x0867: break; default: return S_ERROR; @@ -667,8 +678,6 @@ static WORD Genblkdev(rqptr rp) gioc->ioc_fstype[i] = fs->fs_fstype[i]; } break; - - case 0x0846: /* set volume serial number */ { struct Gioc_media FAR * gioc = (struct Gioc_media FAR *) rp->r_trans; @@ -686,6 +695,14 @@ static WORD Genblkdev(rqptr rp) return (dskerr(ret)); } break; + case 0x0867: /* get access flag, always on*/ + { + struct Access_info FAR * ai = (struct Access_info FAR *) rp->r_trans; + ai->AI_Flag = 1; + } + break; + case 0x0847: /* set access flag, no real use*/ + break; default: return S_ERROR; } diff --git a/kernel/fatdir.c b/kernel/fatdir.c index 22e90e1b..431bff78 100644 --- a/kernel/fatdir.c +++ b/kernel/fatdir.c @@ -36,6 +36,9 @@ static BYTE *fatdirRcsId = "$Id$"; /* * $Log$ + * Revision 1.5 2000/05/26 19:25:19 jimtabor + * Read History file for Change info + * * Revision 1.4 2000/05/25 20:56:21 jimtabor * Fixed project history * @@ -198,11 +201,14 @@ struct f_node FAR *dir_open(BYTE FAR * dirname) /* Generate full path name */ ParseDosPath(dirname, (COUNT *) 0, pszPath, (BYTE FAR *) & cdsp->cdsCurrentPath[x]); +/* for testing only for now */ +#if 0 if ((cdsp->cdsFlags & CDSNETWDRV)) { printf("FailSafe %x \n", Int21AX); return fnp; } +#endif if (TempCDS.cdsDpb == 0) { @@ -210,12 +216,6 @@ struct f_node FAR *dir_open(BYTE FAR * dirname) return NULL; } -/* if (drive > lastdrive) - { - release_f_node(fnp); - return NULL; - } - */ fnp->f_dpb = (struct dpb *)TempCDS.cdsDpb; /* Perform all directory common handling after all special */ @@ -565,7 +565,6 @@ COUNT dos_findfirst(UCOUNT attr, BYTE FAR * name) REG COUNT i; COUNT nDrive; BYTE *p; - struct cds FAR *cdsp; BYTE FAR *ptr; static BYTE local_name[FNAME_SIZE + 1], @@ -600,9 +599,10 @@ COUNT dos_findfirst(UCOUNT attr, BYTE FAR * name) if (nDrive > lastdrive) { return DE_INVLDDRV; } - cdsp = &CDSp->cds_table[nDrive]; + current_ldt = &CDSp->cds_table[nDrive]; + SAttr = (BYTE) attr; - if (cdsp->cdsFlags & CDSNETWDRV) + if (current_ldt->cdsFlags & CDSNETWDRV) { if (Remote_find(REM_FINDFIRST, attr, name, dmp) != 0) return DE_FILENOTFND; @@ -718,7 +718,6 @@ COUNT dos_findnext(void) BYTE FAR *p; BYTE FAR *q; COUNT nDrive; - struct cds FAR *cdsp; /* assign our match parameters pointer. */ dmp = (dmatch FAR *) dta; @@ -726,26 +725,27 @@ COUNT dos_findnext(void) /* * The new version of SHSUCDX 1.0 looks at the dm_drive byte to * test 40h. I used RamView to see location MSD 116:04be and - * FD f61:04be, the byte set with 0xc4 = Remote/Network drive 4. + * FD f??:04be, the byte set with 0xc4 = Remote/Network drive 4. * Ralf Brown docs for dos 4eh say bit 7 set == remote so what is * bit 6 for? SHSUCDX Mod info say "test redir not network bit". + * Just to confuse the rest, MSCDEX sets bit 5 too. * * So, assume bit 6 is redirector and bit 7 is network. * jt */ - nDrive = dmp->dm_drive & 0x3f; + nDrive = dmp->dm_drive & 0x1f; if (nDrive > lastdrive) { return DE_INVLDDRV; } - cdsp = &CDSp->cds_table[nDrive]; + current_ldt = &CDSp->cds_table[nDrive]; #if 0 printf("findnext: %c %s\n", nDrive + 'A', (cdsp->cdsFlags & CDSNETWDRV)?"remote":"local"); #endif - if (cdsp->cdsFlags & CDSNETWDRV) + if (current_ldt->cdsFlags & CDSNETWDRV) { if (Remote_find(REM_FINDNEXT, 0, 0, dmp) != 0) return DE_FILENOTFND; diff --git a/kernel/fcbfns.c b/kernel/fcbfns.c index 5d7f630c..c728a3c0 100644 --- a/kernel/fcbfns.c +++ b/kernel/fcbfns.c @@ -35,6 +35,9 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.4 2000/05/26 19:25:19 jimtabor + * Read History file for Change info + * * Revision 1.3 2000/05/25 20:56:21 jimtabor * Fixed project history * @@ -117,8 +120,6 @@ void FcbNameInit(fcb FAR * lpFcb, BYTE * pszBuffer, COUNT * pCurDrive); sft FAR *FcbGetSft(COUNT SftIndex); VOID FcbNextRecord(fcb FAR * lpFcb); sft FAR *FcbGetFreeSft(WORD FAR * sft_idx); -BOOL FcbFnameMatch(BYTE FAR * s, BYTE FAR * d, COUNT n, COUNT mode); -BOOL FcbCharMatch(COUNT s, COUNT d, COUNT mode); BOOL FcbCalcRec(xfcb FAR * lpXfcb); VOID MoveDirInfo(dmatch FAR * lpDmatch, struct dirent FAR * lpDir); #else @@ -128,8 +129,6 @@ void FcbNameInit(); sft FAR *FcbGetSft(); VOID FcbNextRecord(); sft FAR *FcbGetFreeSft(); -BOOL FcbFnameMatch(); -BOOL FcbCharMatch(); BOOL FcbCalcRec(); VOID MoveDirInfo(); #endif @@ -644,12 +643,9 @@ BOOL FcbCreate(xfcb FAR * lpXfcb) /* check for a device */ /* if we have an extension, can't be a device */ - if (IsDevice(PriPathName)) + dhp = IsDevice(PriPathName); + if (dhp) { - for (dhp = (struct dhdr FAR *)&nul_dev; dhp != (struct dhdr FAR *)-1; dhp = dhp->dh_next) - { - if (FcbFnameMatch((BYTE FAR *) PriPathName, (BYTE FAR *) dhp->dh_name, FNAME_SIZE, FALSE)) - { sftp->sft_count += 1; sftp->sft_mode = O_RDWR; sftp->sft_attrib = 0; @@ -666,8 +662,6 @@ BOOL FcbCreate(xfcb FAR * lpXfcb) lpFcb->fcb_time = dos_gettime(); lpFcb->fcb_rndm = 0; return TRUE; - } - } } sftp->sft_status = dos_creat(PriPathName, 0); if (sftp->sft_status >= 0) @@ -769,28 +763,6 @@ void FcbNameInit(fcb FAR * lpFcb, BYTE * pszBuffer, COUNT * pCurDrive) pszBuffer[nDrvIdx + nFnameIdx + nFextIdx] = '\0'; } -/* Ascii only file name match routines */ -static BOOL FcbCharMatch(COUNT s, COUNT d, COUNT mode) -{ - if (s >= 'a' && s <= 'z') - s -= 'a' - 'A'; - if (d >= 'a' && d <= 'z') - d -= 'a' - 'A'; - if (mode && s == '?' && (d >= 'A' && s <= 'Z')) - return TRUE; - return s == d; -} - -static BOOL FcbFnameMatch(BYTE FAR * s, BYTE FAR * d, COUNT n, COUNT mode) -{ - while (n--) - { - if (!FcbCharMatch(*s++, *d++, mode)) - return FALSE; - } - return TRUE; -} - BOOL FcbOpen(xfcb FAR * lpXfcb) { WORD sft_idx; @@ -807,12 +779,9 @@ BOOL FcbOpen(xfcb FAR * lpXfcb) /* check for a device */ /* if we have an extension, can't be a device */ - if (IsDevice(PriPathName)) + dhp = IsDevice(PriPathName); + if (dhp ) { - for (dhp = (struct dhdr FAR *)&nul_dev; dhp != (struct dhdr FAR *)-1; dhp = dhp->dh_next) - { - if (FcbFnameMatch((BYTE FAR *) PriPathName, (BYTE FAR *) dhp->dh_name, FNAME_SIZE, FALSE)) - { sftp->sft_count += 1; sftp->sft_mode = O_RDWR; sftp->sft_attrib = 0; @@ -829,8 +798,6 @@ BOOL FcbOpen(xfcb FAR * lpXfcb) lpFcb->fcb_time = dos_gettime(); lpFcb->fcb_rndm = 0; return TRUE; - } - } } fbcopy((BYTE FAR *) & lpFcb->fcb_fname, (BYTE FAR *) & sftp->sft_name, FNAME_SIZE + FEXT_SIZE); if ((FcbDrive < 0) || (FcbDrive > lastdrive)) { diff --git a/kernel/io.asm b/kernel/io.asm index 6a84f06d..b725b047 100644 --- a/kernel/io.asm +++ b/kernel/io.asm @@ -28,6 +28,9 @@ ; $Header$ ; ; $Log$ +; Revision 1.4 2000/05/26 19:25:19 jimtabor +; Read History file for Change info +; ; Revision 1.3 2000/05/25 20:56:21 jimtabor ; Fixed project history ; @@ -190,7 +193,7 @@ _clk_dev equ $ global _blk_dev _blk_dev equ $ dd -1 - dw 0000h ; block device + dw 00c2h ; block device with ioctl dw GenStrategy dw blk_entry global _nblk_rel diff --git a/kernel/main.c b/kernel/main.c index 9f585db0..573b3c23 100644 --- a/kernel/main.c +++ b/kernel/main.c @@ -39,6 +39,9 @@ static BYTE *mainRcsId = "$Id$"; /* * $Log$ + * Revision 1.5 2000/05/26 19:25:19 jimtabor + * Read History file for Change info + * * Revision 1.4 2000/05/25 20:56:21 jimtabor * Fixed project history * @@ -189,6 +192,9 @@ INIT static VOID init_kernel(void) /* Fake int 21h stack frame */ user_r = (iregs FAR *) DOS_PSP + 0xD0; +/* Set Init DTA to Tempbuffer */ + dta = (BYTE FAR *) &TempBuffer; + #ifndef KDB for (i = 0x20; i <= 0x3f; i++) setvec(i, empty_handler); @@ -425,7 +431,7 @@ extern BYTE FAR *lpBase; /* If cmdLine is NULL, this is an internal driver */ -VOID init_device(struct dhdr FAR * dhp, BYTE FAR * cmdLine) +BOOL init_device(struct dhdr FAR * dhp, BYTE FAR * cmdLine) { request rq; ULONG memtop = ((ULONG) ram_top) << 10; @@ -443,6 +449,11 @@ VOID init_device(struct dhdr FAR * dhp, BYTE FAR * cmdLine) rq.r_firstunit = nblkdev; execrh((request FAR *) & rq, dhp); +/* + * Added needed Error handle + */ + if (rq.r_status & S_ERROR) + return TRUE; if (cmdLine) lpBase = rq.r_endaddr; @@ -471,14 +482,9 @@ VOID init_device(struct dhdr FAR * dhp, BYTE FAR * cmdLine) } } DPBp = &blk_devices[0]; + return FALSE; } -struct dhdr FAR *link_dhdr(struct dhdr FAR * lp, struct dhdr FAR * dhp, BYTE FAR * cmdLine) -{ - lp->dh_next = dhp; - init_device(dhp, cmdLine); - return dhp; -} INIT static void InitIO(void) { diff --git a/kernel/network.c b/kernel/network.c index 3d1e2678..6bfaa09e 100644 --- a/kernel/network.c +++ b/kernel/network.c @@ -36,6 +36,9 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.5 2000/05/26 19:25:19 jimtabor + * Read History file for Change info + * * Revision 1.4 2000/05/25 20:56:21 jimtabor * Fixed project history * @@ -109,17 +112,16 @@ UCOUNT Remote_RW(UWORD func, UCOUNT n, BYTE FAR * bp, sft FAR * s, COUNT FAR * e /* */ -COUNT Remote_find(UWORD func, UWORD attrib, BYTE FAR * name, REG dmatch FAR * dmp) +COUNT Remote_find(UWORD func, UWORD attrib, BYTE FAR * name, REG dmatch FAR * dmp ) { - COUNT i, - x; - char FAR *p, - *q; + COUNT i, x; + char FAR *p, *q; + VOID FAR * test; struct dirent FAR *SDp = (struct dirent FAR *) &SearchDir; if (func == REM_FINDFIRST) { - SAttr = (BYTE) attrib; + test = (VOID FAR *) current_ldt; i = truename(name, PriPathName, FALSE); if (i != SUCCESS) { return i; @@ -132,11 +134,13 @@ COUNT Remote_find(UWORD func, UWORD attrib, BYTE FAR * name, REG dmatch FAR * dm printf("'\n"); #endif } + else + test = (VOID FAR *) &TempBuffer; fsncopy(dta, (BYTE FAR *) &TempBuffer, 21); p = dta; dta = (BYTE FAR *) &TempBuffer; - i = int2f_Remote_call(func, 0, 0, 0, 0, 0, 0); + i = int2f_Remote_call(func, 0, 0, 0, test, 0, 0); dta = p; fsncopy((BYTE FAR *) &TempBuffer[0], &dta[0], 21); diff --git a/kernel/newstuff.c b/kernel/newstuff.c index 0b450d31..af9ede02 100644 --- a/kernel/newstuff.c +++ b/kernel/newstuff.c @@ -31,6 +31,9 @@ static BYTE *mainRcsId = "$Id$"; /* * $Log$ + * Revision 1.5 2000/05/26 19:25:19 jimtabor + * Read History file for Change info + * * Revision 1.4 2000/05/25 20:56:21 jimtabor * Fixed project history * @@ -224,9 +227,13 @@ COUNT get_verify_drive(char FAR *src) COUNT truename(char FAR * src, char FAR * dest, COUNT t) { static char buf[128] = "A:\\\0\0\0\0\0\0\0\0\0"; + static char Name[8] = " "; char *bufp = buf + 3; COUNT i, n, x = 2; struct cds FAR *cdsp; + struct dhdr FAR *dhp; + BYTE FAR *froot; + WORD d; dest[0] = '\0'; @@ -247,6 +254,37 @@ COUNT truename(char FAR * src, char FAR * dest, COUNT t) buf[0] = default_drive + 'A'; i = buf[0] - 'A'; +/* + Code repoff from dosfns.c + MSD returns X:/CON for truename con. Not X:\CON +*/ + /* check for a device */ + froot = get_root(src); + for (d = 0; d < FNAME_SIZE; d++) + { + if (*froot != '\0' && *froot != '.') + Name[d] = *froot++; + else + break; + } + + for (; d < FNAME_SIZE; d++) + Name[d] = ' '; + + /* if we have an extension, can't be a device */ + if (*froot != '.') + { + for (dhp = (struct dhdr FAR *)&nul_dev; dhp != (struct dhdr FAR *)-1; dhp = dhp->dh_next) + { + if (fnmatch((BYTE FAR *) &Name, (BYTE FAR *) dhp->dh_name, FNAME_SIZE, FALSE)) + { + buf[2] ='/'; + for (d = 0; d < FNAME_SIZE || Name[d] == ' '; d++) + *bufp++ = Name[d]; + goto exit_tn; + } + } + } cdsp = &CDSp->cds_table[i]; current_ldt = cdsp; @@ -278,6 +316,8 @@ COUNT truename(char FAR * src, char FAR * dest, COUNT t) } else src++; + +move_name: /* * The code here is brain dead. It works long as the calling * function are operating with in normal parms. @@ -371,6 +411,8 @@ COUNT truename(char FAR * src, char FAR * dest, COUNT t) if (bufp == buf + 2) ++bufp; +exit_tn: + *bufp++ = 0; /* finally, uppercase everything */ diff --git a/kernel/proto.h b/kernel/proto.h index 565616e9..c5b9193c 100644 --- a/kernel/proto.h +++ b/kernel/proto.h @@ -34,6 +34,9 @@ static BYTE *Proto_hRcsId = "$Id$"; /* * $Log$ + * Revision 1.4 2000/05/26 19:25:19 jimtabor + * Read History file for Change info + * * Revision 1.3 2000/05/25 20:56:21 jimtabor * Fixed project history * @@ -186,6 +189,8 @@ INIT VOID mcb_init(mcb FAR * mcbp, UWORD size); INIT VOID strcat(REG BYTE * d, REG BYTE * s); /* dosfns.c */ +BYTE FAR *get_root(BYTE FAR *); +BOOL fnmatch(BYTE FAR *, BYTE FAR *, COUNT, COUNT); BOOL check_break(void); UCOUNT GenericRead(COUNT hndl, UCOUNT n, BYTE FAR * bp, COUNT FAR * err, BOOL force_binary); @@ -213,6 +218,7 @@ COUNT DosDelete(BYTE FAR *path); COUNT DosRename(BYTE FAR * path1, BYTE FAR * path2); COUNT DosMkdir(BYTE FAR * dir); COUNT DosRmdir(BYTE FAR * dir); +struct dhdr FAR * IsDevice(BYTE FAR * FileName); /*dosidle.asm */ VOID DosIdle_int(void); @@ -221,7 +227,6 @@ VOID DosIdle_int(void); VOID SpacePad(BYTE *, COUNT); COUNT ParseDosName(BYTE FAR *, COUNT *, BYTE *, BYTE *, BYTE *, BOOL); COUNT ParseDosPath(BYTE FAR *, COUNT *, BYTE *, BYTE FAR *); -BOOL IsDevice(BYTE FAR * FileName); /* dsk.c */ COUNT blk_driver(rqptr rp); @@ -349,8 +354,7 @@ COUNT DosDevIOctl(iregs FAR * r, COUNT FAR * err); /* main.c */ INIT VOID main(void); -INIT VOID init_device(struct dhdr FAR * dhp, BYTE FAR * cmdLine); -INIT struct dhdr FAR *link_dhdr(struct dhdr FAR * lp, struct dhdr FAR * dhp, BYTE FAR * cmdLine); +INIT BOOL init_device(struct dhdr FAR * dhp, BYTE FAR * cmdLine); /* memmgr.c */ seg far2para(VOID FAR * p); diff --git a/kernel/task.c b/kernel/task.c index 976ddfa6..671e6b4a 100644 --- a/kernel/task.c +++ b/kernel/task.c @@ -35,6 +35,9 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.4 2000/05/26 19:25:19 jimtabor + * Read History file for Change info + * * Revision 1.3 2000/05/25 20:56:21 jimtabor * Fixed project history * @@ -475,7 +478,7 @@ static COUNT DosComLoader(BYTE FAR * namep, exec_blk FAR * exp, COUNT mode) if (mode == OVERLAY) /* memory already allocated */ sp = MK_FP(mem, 0); else - { /* test the filesize against the allocated memory */ + { /* test the filesize against the allocated memory */ sp = MK_FP(mem, sizeof(psp)); /* This is a potential problem, what to do with .COM files larger than @@ -890,6 +893,11 @@ COUNT FAR init_call_DosExec(COUNT mode, exec_blk FAR * ep, BYTE FAR * lp) VOID InitPSP(VOID) { psp FAR *p = MK_FP(DOS_PSP, 0); +/* + Fixed Device Driver Print output. + */ + if(p->ps_exit == 0x000020cd) + return; new_psp(p, 0); } From c54d6d8988a86565e1ed0697e5a2ca6a7aec23ad Mon Sep 17 00:00:00 2001 From: Jim Tabor Date: Fri, 26 May 2000 19:46:52 +0000 Subject: [PATCH 018/671] Read History file for Change info git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@28 6ac86273-5f31-0410-b378-82cca8765d1b --- hdr/stacks.inc | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/hdr/stacks.inc b/hdr/stacks.inc index 3125fd9d..081b59a2 100644 --- a/hdr/stacks.inc +++ b/hdr/stacks.inc @@ -30,15 +30,18 @@ ; $Id$ ; ; $Log$ +; Revision 1.4 2000/05/26 19:46:52 jimtabor +; Read History file for Change info +; ; Revision 1.3 2000/05/25 20:56:19 jimtabor ; Fixed project history ; ; Revision 1.2 2000/05/08 04:28:22 jimtabor ; Update CVS to 2020 -: -: Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 -: The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with -: MS-DOS. Distributed under the GNU GPL. +; +; Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 +; The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with +; MS-DOS. Distributed under the GNU GPL. ; ; Revision 1.3 2000/03/09 06:06:38 kernel ; 2017f updates by James Tabor From a6fa91605410fd0b95371fa7bc4354265a68f658 Mon Sep 17 00:00:00 2001 From: Jim Tabor Date: Thu, 1 Jun 2000 06:37:38 +0000 Subject: [PATCH 019/671] Read History for Changes git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@29 6ac86273-5f31-0410-b378-82cca8765d1b --- docs/history.txt | 19 +++++++++++++++++-- hdr/version.h | 2 +- kernel/dosfns.c | 4 +++- kernel/dosnames.c | 41 ++++++++++++++++++++++++++++++++++++++++- kernel/dsk.c | 40 +++++++++++++++++++++++++++++++++++++--- kernel/fatdir.c | 29 ++++++++++++++++++++--------- kernel/io.asm | 5 ++++- kernel/newstuff.c | 8 +++++++- 8 files changed, 129 insertions(+), 19 deletions(-) diff --git a/docs/history.txt b/docs/history.txt index 8b30a471..e313cc7d 100644 --- a/docs/history.txt +++ b/docs/history.txt @@ -1,3 +1,18 @@ +2000 Jun 01 - Build 2021 +-------- James Tabor (jimtabor@infohwy.com) ++ Clean Removed test prinf statements in source. +* Thanks to Lixing Yuan for pointing out an copy to root error. + +2000 May 31 - Build 2021 +-------- James Tabor (jimtabor@infohwy.com) ++ Patch Lixing Yuan (yuanlixg@china.com) Patch for parsing bug in + FindFirst with wildcards -> ParseDosName (dosnames.c). + +2000 May 28 - Build 2021 +-------- James Tabor (jimtabor@infohwy.com) ++ Added Open/Close/Media check to dsk.c and io.asm. ++ Fixed Device checking in truename. Truename needs to be rewriten. + 2000 May 26 - Build 2020 -------- James Tabor (jimtabor@infohwy.com) Code Clean up and Now the Release. @@ -44,7 +59,7 @@ 2000 May 08 - Build 2020 -------- James Tabor (jimtabor@infohwy.com) -+ Update Started Update to the New CVS at Sourceforge.net. Seting source ++ Update Started Update to the New CVS at Sourceforge.net. Setting source from 2018 to 2020. 2000 May 06 @@ -54,7 +69,7 @@ 2000 Apr 28 - Build 2020 -------- James Tabor (jimtabor@infohwy.com) + Added Dos Function calls 0x69, and 0x6C. IOCTL support in disk driver. - New funtions not yet fully implemented. + New functions not yet fully implemented. Clean up DSK.C, IOCTL.C and FCBFNS.C. Removed old blk_device pointers. diff --git a/hdr/version.h b/hdr/version.h index 132ad8f2..4dd0e095 100644 --- a/hdr/version.h +++ b/hdr/version.h @@ -43,4 +43,4 @@ static BYTE *date_hRcsId = "$Id$"; #define REVISION_MAJOR 1 #define REVISION_MINOR 1 #define REVISION_SEQ 20 -#define BUILD 2020 +#define BUILD 2021 diff --git a/kernel/dosfns.c b/kernel/dosfns.c index 2987e6a1..85e26111 100644 --- a/kernel/dosfns.c +++ b/kernel/dosfns.c @@ -34,6 +34,9 @@ static BYTE *dosfnsRcsId = "$Id$"; /* * $Log$ + * Revision 1.6 2000/06/01 06:37:38 jimtabor + * Read History for Changes + * * Revision 1.5 2000/05/26 19:25:19 jimtabor * Read History file for Change info * @@ -1196,7 +1199,6 @@ COUNT DosSetFattr(BYTE FAR * name, UWORD FAR * attrp) BYTE FAR *p; if (IsDevice(name) ) { - printf("SetAtt\n"); return DE_PATHNOTFND; } diff --git a/kernel/dosnames.c b/kernel/dosnames.c index 9daf82ff..6210baf5 100644 --- a/kernel/dosnames.c +++ b/kernel/dosnames.c @@ -36,6 +36,9 @@ static BYTE *dosnamesRcsId = "$Id$"; /* * $Log$ + * Revision 1.5 2000/06/01 06:37:38 jimtabor + * Read History for Changes + * * Revision 1.4 2000/05/26 19:25:19 jimtabor * Read History file for Change info * @@ -192,7 +195,6 @@ COUNT ParseDosName(BYTE FAR * lpszFileName, ++lpszFileName; } nDirCnt = lpszLclFile - lpszLclDir; - /* Parse out the file name portion. */ lpszFileName = lpszLclFile; while (bAllowWildcards ? WildChar(*lpszFileName) : NameChar(*lpszFileName)) @@ -200,9 +202,45 @@ COUNT ParseDosName(BYTE FAR * lpszFileName, ++nFileCnt; ++lpszFileName; } + if (nFileCnt == 0) +/* Lixing Yuan Patch */ + if (bAllowWildcards) /* for find first */ + { + if (*lpszFileName == '.') + lpszFileName++; + if (*lpszFileName == '.') + lpszFileName++; + if (*lpszFileName != '\0') + return DE_FILENOTFND; + if (pszDir) + { + if ((lpszFileName - lpszLclFile) == 2) /* for tail DotDot */ + nDirCnt += 2; + if (nDirCnt > PARSE_MAX) + nDirCnt = PARSE_MAX; + fbcopy(lpszLclDir, (BYTE FAR *) pszDir, nDirCnt); + if (((lpszFileName - lpszLclFile) == 2) && (nDirCnt < PARSE_MAX)) + pszDir[nDirCnt++] = '\\'; /* make DosTrimPath() enjoy, for tail DotDot */ + pszDir[nDirCnt] = '\0'; + DosTrimPath(pszDir); + } + if (pszFile) + { + *pszFile++ = '*'; + *pszFile = '\0'; + } + if (pszExt) + { + *pszExt++ = '*'; + *pszExt = '\0'; + } + return SUCCESS; + } + else return DE_FILENOTFND; + /* Now we have pointers set to the directory portion and the */ /* file portion. Now determine the existance of an extension. */ lpszLclExt = lpszFileName; @@ -253,6 +291,7 @@ COUNT ParseDosName(BYTE FAR * lpszFileName, if (pszDir) DosTrimPath(pszDir); + return SUCCESS; } diff --git a/kernel/dsk.c b/kernel/dsk.c index a4d0c92d..fcc68aad 100644 --- a/kernel/dsk.c +++ b/kernel/dsk.c @@ -33,6 +33,9 @@ static BYTE *dskRcsId = "$Id$"; /* * $Log$ + * Revision 1.7 2000/06/01 06:37:38 jimtabor + * Read History for Changes + * * Revision 1.6 2000/05/26 19:25:19 jimtabor * Read History file for Change info * @@ -154,6 +157,7 @@ static struct media_info ULONG mi_offset; /* relative partition offset */ BYTE mi_drive; /* BIOS drive number */ COUNT mi_partidx; /* Index to partition array */ + ULONG mi_FileOC; /* Count of Open files on Drv */ }; static struct FS_info @@ -211,6 +215,9 @@ WORD init(rqptr), blockio(rqptr), IoctlQueblk(rqptr), Genblkdev(rqptr), + blk_Open(rqptr), + blk_Close(rqptr), + blk_Media(rqptr), blk_error(rqptr); COUNT ltop(WORD *, WORD *, WORD *, COUNT, COUNT, LONG, byteptr); WORD dskerr(COUNT); @@ -220,6 +227,11 @@ WORD init(), mediachk(), bldbpb(), blockio(), + IoctlQueblk(), + Genblkdev(), + blk_Open(), + blk_Close(), + blk_Media(), blk_error(); WORD dskerr(); COUNT processtable(); @@ -248,9 +260,9 @@ static WORD(*dispatch[NENTRY]) () = blk_error, /* Output Status */ blk_error, /* Output Flush */ blk_error, /* Ioctl Out */ - blk_error, /* Device Open */ - blk_error, /* Device Close */ - blk_error, /* Removable Media */ + blk_Open, /* Device Open */ + blk_Close, /* Device Close */ + blk_Media, /* Removable Media */ blk_error, /* Output till busy */ blk_error, /* undefined */ blk_error, /* undefined */ @@ -523,6 +535,28 @@ static WORD RWzero(rqptr rp, WORD t) return ret; } +static WORD blk_Open(rqptr rp) +{ + miarray[rp->r_unit].mi_FileOC++; + return S_DONE; +} + +static WORD blk_Close(rqptr rp) +{ + miarray[rp->r_unit].mi_FileOC--; + return S_DONE; +} + +static WORD blk_Media(rqptr rp) +{ + COUNT drive = miarray[rp->r_unit].mi_drive; + + if (hd(drive)) + return S_BUSY|S_DONE; /* Hard Drive */ + else + return S_DONE; /* Floppy */ +} + static WORD bldbpb(rqptr rp) { ULONG count, i; diff --git a/kernel/fatdir.c b/kernel/fatdir.c index 431bff78..17638be1 100644 --- a/kernel/fatdir.c +++ b/kernel/fatdir.c @@ -36,6 +36,9 @@ static BYTE *fatdirRcsId = "$Id$"; /* * $Log$ + * Revision 1.6 2000/06/01 06:37:38 jimtabor + * Read History for Changes + * * Revision 1.5 2000/05/26 19:25:19 jimtabor * Read History file for Change info * @@ -568,7 +571,11 @@ COUNT dos_findfirst(UCOUNT attr, BYTE FAR * name) BYTE FAR *ptr; static BYTE local_name[FNAME_SIZE + 1], - local_ext[FEXT_SIZE + 1]; + local_ext[FEXT_SIZE + 1], + Tname[65]; + + fscopy(name, (BYTE FAR *)&Tname); + printf("ff %s", Tname); /* The findfirst/findnext calls are probably the worst of the */ /* DOS calls. They must work somewhat on the fly (i.e. - open */ @@ -585,10 +592,13 @@ COUNT dos_findfirst(UCOUNT attr, BYTE FAR * name) dmp->dm_attr_srch = attr | D_RDONLY | D_ARCHIVE; /* Parse out the drive, file name and file extension. */ - i = ParseDosName(name, &nDrive, &LocalPath[2], local_name, local_ext, TRUE); + i = ParseDosName((BYTE FAR *)&Tname, &nDrive, &LocalPath[2], local_name, local_ext, TRUE); if (i != SUCCESS) return i; + printf("\nff %s", Tname); + printf("ff %s", local_name); + printf("ff %s\n", local_ext); if (nDrive >= 0) { dmp->dm_drive = nDrive; @@ -602,13 +612,6 @@ COUNT dos_findfirst(UCOUNT attr, BYTE FAR * name) current_ldt = &CDSp->cds_table[nDrive]; SAttr = (BYTE) attr; - if (current_ldt->cdsFlags & CDSNETWDRV) - { - if (Remote_find(REM_FINDFIRST, attr, name, dmp) != 0) - return DE_FILENOTFND; - return SUCCESS; - } - /* Now build a directory. */ if (!LocalPath[2]) strcpy(&LocalPath[2], "."); @@ -647,6 +650,14 @@ COUNT dos_findfirst(UCOUNT attr, BYTE FAR * name) fbcopy((BYTE FAR *) SearchDir.dir_name, dmp->dm_name_pat, FNAME_SIZE + FEXT_SIZE); + + if (current_ldt->cdsFlags & CDSNETWDRV) + { + if (Remote_find(REM_FINDFIRST, attr, name, dmp) != 0) + return DE_FILENOTFND; + return SUCCESS; + } + /* Now search through the directory to find the entry... */ /* Special handling - the volume id is only in the root */ /* directory and only searched for once. So we need to open */ diff --git a/kernel/io.asm b/kernel/io.asm index b725b047..67940c98 100644 --- a/kernel/io.asm +++ b/kernel/io.asm @@ -28,6 +28,9 @@ ; $Header$ ; ; $Log$ +; Revision 1.5 2000/06/01 06:37:38 jimtabor +; Read History for Changes +; ; Revision 1.4 2000/05/26 19:25:19 jimtabor ; Read History file for Change info ; @@ -193,7 +196,7 @@ _clk_dev equ $ global _blk_dev _blk_dev equ $ dd -1 - dw 00c2h ; block device with ioctl + dw 08c2h ; block device with ioctl dw GenStrategy dw blk_entry global _nblk_rel diff --git a/kernel/newstuff.c b/kernel/newstuff.c index af9ede02..24543594 100644 --- a/kernel/newstuff.c +++ b/kernel/newstuff.c @@ -31,6 +31,9 @@ static BYTE *mainRcsId = "$Id$"; /* * $Log$ + * Revision 1.6 2000/06/01 06:37:38 jimtabor + * Read History for Changes + * * Revision 1.5 2000/05/26 19:25:19 jimtabor * Read History file for Change info * @@ -279,8 +282,11 @@ COUNT truename(char FAR * src, char FAR * dest, COUNT t) if (fnmatch((BYTE FAR *) &Name, (BYTE FAR *) dhp->dh_name, FNAME_SIZE, FALSE)) { buf[2] ='/'; - for (d = 0; d < FNAME_SIZE || Name[d] == ' '; d++) + for (d = 0; d < FNAME_SIZE; d++){ + if(Name[d] == 0x20) + goto exit_tn; *bufp++ = Name[d]; + } goto exit_tn; } } From befddcad33b4339a581ac13776d62b8c9e244b4c Mon Sep 17 00:00:00 2001 From: Jim Tabor Date: Thu, 1 Jun 2000 06:46:57 +0000 Subject: [PATCH 020/671] Removed Debug printf git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@30 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/fatdir.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/kernel/fatdir.c b/kernel/fatdir.c index 17638be1..58552914 100644 --- a/kernel/fatdir.c +++ b/kernel/fatdir.c @@ -36,6 +36,9 @@ static BYTE *fatdirRcsId = "$Id$"; /* * $Log$ + * Revision 1.7 2000/06/01 06:46:57 jimtabor + * Removed Debug printf + * * Revision 1.6 2000/06/01 06:37:38 jimtabor * Read History for Changes * @@ -575,8 +578,9 @@ COUNT dos_findfirst(UCOUNT attr, BYTE FAR * name) Tname[65]; fscopy(name, (BYTE FAR *)&Tname); +/* printf("ff %s", Tname); - +*/ /* The findfirst/findnext calls are probably the worst of the */ /* DOS calls. They must work somewhat on the fly (i.e. - open */ /* but never close). Since we don't want to lose fnodes every */ @@ -595,10 +599,11 @@ COUNT dos_findfirst(UCOUNT attr, BYTE FAR * name) i = ParseDosName((BYTE FAR *)&Tname, &nDrive, &LocalPath[2], local_name, local_ext, TRUE); if (i != SUCCESS) return i; - +/* printf("\nff %s", Tname); printf("ff %s", local_name); printf("ff %s\n", local_ext); +*/ if (nDrive >= 0) { dmp->dm_drive = nDrive; From b8a19f9da0634bc1f1eb6537da3b3f5f3be95fad Mon Sep 17 00:00:00 2001 From: Jim Tabor Date: Wed, 21 Jun 2000 18:16:46 +0000 Subject: [PATCH 021/671] Add UMB code, patch, and code fixes git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@32 6ac86273-5f31-0410-b378-82cca8765d1b --- hdr/fat.h | 8 +++- hdr/mcb.h | 9 ++++ kernel/config.c | 119 ++++++++++++++++++++++++++++++++++++++++++---- kernel/dosfns.c | 25 ++++------ kernel/dosnames.c | 12 ++++- kernel/dsk.c | 72 +++++++++++++++++++++------- kernel/fatdir.c | 23 ++++++--- kernel/fatfs.c | 5 +- kernel/fcbfns.c | 33 ++++++++++--- kernel/globals.h | 22 +++++++-- kernel/int2f.asm | 37 +++++++++++--- kernel/inthndlr.c | 118 +++++++++++++++++++++++++-------------------- kernel/io.asm | 7 ++- kernel/ioctl.c | 119 ++++++++++++++++++++++++++++++++-------------- kernel/kernel.asm | 31 ++++++------ kernel/main.c | 32 ++++++++----- kernel/memmgr.c | 43 +++++++++-------- kernel/network.c | 7 ++- kernel/newstuff.c | 7 ++- kernel/proto.h | 8 +++- 20 files changed, 528 insertions(+), 209 deletions(-) diff --git a/hdr/fat.h b/hdr/fat.h index bc52089a..e27a7683 100644 --- a/hdr/fat.h +++ b/hdr/fat.h @@ -36,6 +36,9 @@ static BYTE *fat_hRcsId = "$Id$"; /* * $Log$ + * Revision 1.4 2000/06/21 18:16:46 jimtabor + * Add UMB code, patch, and code fixes + * * Revision 1.3 2000/05/25 20:56:19 jimtabor * Fixed project history * @@ -112,8 +115,11 @@ static BYTE *fat_hRcsId = "$Id$"; /* Test for 16 bit or 12 bit FAT */ #define SIZEOF_CLST16 2 #define FAT_MAGIC 4086 +#define FAT_MAGIC16 65526 +#define FAT_MAGIC32 268435456 -#define ISFAT16(dpbp) (((dpbp)->dpb_size)>FAT_MAGIC) +#define ISFAT32(dpbp) (((dpbp)->dpb_size)>FAT_MAGIC16 || ((dpbp)->dpb_size)<=FAT_MAGIC32 ) +#define ISFAT16(dpbp) (((dpbp)->dpb_size)>FAT_MAGIC || ((dpbp)->dpb_size)<=FAT_MAGIC16 ) #define ISFAT12(dpbp) (((dpbp)->dpb_size)<=FAT_MAGIC) /* FAT file system directory entry */ diff --git a/hdr/mcb.h b/hdr/mcb.h index 70d4adf5..c34c03a1 100644 --- a/hdr/mcb.h +++ b/hdr/mcb.h @@ -36,6 +36,9 @@ static BYTE *mcb_hRcsId = "$Id$"; /* * $Log$ + * Revision 1.4 2000/06/21 18:16:46 jimtabor + * Add UMB code, patch, and code fixes + * * Revision 1.3 2000/05/25 20:56:19 jimtabor * Fixed project history * @@ -85,6 +88,12 @@ static BYTE *mcb_hRcsId = "$Id$"; #define FIRST_FIT 0 #define BEST_FIT 1 #define LAST_FIT 2 +#define FIRST_FIT_UO 0x40 +#define BEST_FIT_UO 0x41 +#define LAST_FIT_UO 0x42 +#define FIRST_FIT_U 0x80 +#define BEST_FIT_U 0x81 +#define LAST_FIT_U 0x82 #define MCB_NORMAL 0x4d #define MCB_LAST 0x5a diff --git a/kernel/config.c b/kernel/config.c index f8dfae49..2a57f1ef 100644 --- a/kernel/config.c +++ b/kernel/config.c @@ -39,6 +39,9 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.5 2000/06/21 18:16:46 jimtabor + * Add UMB code, patch, and code fixes + * * Revision 1.4 2000/05/26 19:25:19 jimtabor * Read History file for Change info * @@ -140,7 +143,9 @@ void __int__(int); /* TC 2.01 requires this. :( -- ror4 */ #endif BYTE FAR *lpBase; +BYTE FAR *upBase; static BYTE FAR *lpOldLast; +static BYTE FAR *upOldLast; static COUNT nCfgLine; static COUNT nPass; static BYTE szLine[256]; @@ -148,14 +153,19 @@ static BYTE szBuf[256]; int singleStep = 0; +INIT VOID zumcb_init(mcb FAR * mcbp, UWORD size); + INIT VOID Buffers(BYTE * pLine); INIT VOID sysScreenMode(BYTE * pLine); INIT VOID sysVersion(BYTE * pLine); INIT VOID Break(BYTE * pLine); INIT VOID Device(BYTE * pLine); +INIT VOID DeviceHigh(BYTE * pLine); INIT VOID Files(BYTE * pLine); INIT VOID Fcbs(BYTE * pLine); INIT VOID Lastdrive(BYTE * pLine); +INIT VOID LoadDevice(BYTE * pLine, COUNT top, COUNT mode); +INIT VOID Dosmem(BYTE * pLine); INIT VOID Country(BYTE * pLine); INIT VOID InitPgm(BYTE * pLine); INIT VOID Switchar(BYTE * pLine); @@ -190,6 +200,8 @@ static struct table commands[] = {"command", 1, InitPgm}, {"country", 1, Country}, {"device", 2, Device}, + {"devicehigh", 2, DeviceHigh}, + {"dos", 1, Dosmem}, {"fcbs", 1, Fcbs}, {"files", 1, Files}, {"lastdrive", 1, Lastdrive}, @@ -251,7 +263,7 @@ INIT void PreConfig(void) + Config.cfgFiles * sizeof(sft)); CDSp = (cdstbl FAR *) - KernelAlloc(0x58 * (lastdrive + 1)); + KernelAlloc(0x58 * (lastdrive)); #ifdef DEBUG @@ -289,13 +301,15 @@ INIT void PreConfig(void) /* Also, run config.sys to load drivers. */ INIT void PostConfig(void) { + + COUNT tmp = 0xc000; + /* Set pass number */ nPass = 2; - /* compute lastdrive ... */ lastdrive = Config.cfgLastdrive; - if (lastdrive < nblkdev -1) - lastdrive = nblkdev -1; + if (lastdrive < nblkdev ) + lastdrive = nblkdev ; /* Initialize the base memory pointers from last time. */ lpBase = AlignParagraph(lpOldLast); @@ -326,7 +340,7 @@ INIT void PostConfig(void) + Config.cfgFiles * sizeof(sft)); CDSp = (cdstbl FAR *) - KernelAlloc(0x58 * (lastdrive + 1)); + KernelAlloc(0x58 * (lastdrive)); #ifdef DEBUG @@ -353,6 +367,21 @@ INIT void PostConfig(void) printf("Allocation completed: top at 0x%04x:0x%04x\n", FP_SEG(lpBase), FP_OFF(lpBase)); #endif + + if(uppermem_link) + { + upBase = MK_FP(tmp , 0); + uppermem_root = FP_SEG(upBase) + ((FP_OFF(upBase) + 0x0f) >> 4); + umcb_init((mcb FAR *) (MK_FP(uppermem_root, 0)), 0 ); + + upBase += 16; + +#ifdef DEBUG + printf("UMB Allocation completed: top at 0x%04x:0x%04x\n", + FP_SEG(upBase), FP_OFF(upBase)); +#endif + } + } /* This code must be executed after device drivers has been loaded */ @@ -360,13 +389,13 @@ INIT VOID configDone(VOID) { COUNT i; - if (lastdrive < nblkdev -1) { + if (lastdrive < nblkdev) { #ifdef DEBUG printf("lastdrive %c too small upping it to: %c\n", lastdrive + 'A', nblkdev + 'A' -1); #endif /* DEBUG */ - lastdrive = nblkdev -1; + lastdrive = nblkdev; CDSp = (cdstbl FAR *) - KernelAlloc(0x58 * (lastdrive +1)); + KernelAlloc(0x58 * (lastdrive )); } first_mcb = FP_SEG(lpBase) + ((FP_OFF(lpBase) + 0x0f) >> 4); @@ -374,6 +403,13 @@ INIT VOID configDone(VOID) mcb_init((mcb FAR *) (MK_FP(first_mcb, 0)), (ram_top << 6) - first_mcb - 1); + if(uppermem_link) + { + uppermem_root = FP_SEG(upBase) + ((FP_OFF(upBase) + 0x0f) >> 4); + zumcb_init((mcb FAR *) (MK_FP(uppermem_root, 0)), + (UMB_top << 6) - uppermem_root - 1); + } + /* The standard handles should be reopened here, because we may have loaded new console or printer drivers in CONFIG.SYS */ } @@ -636,9 +672,29 @@ INIT static VOID Lastdrive(BYTE * pLine) return; } drv -= 'A'; + drv++; /* Make real number*/ Config.cfgLastdrive = max(Config.cfgLastdrive, drv); } +INIT static VOID Dosmem(BYTE * pLine) +{ + COUNT tmp; + COUNT FAR * u = MK_FP(0xc000, 0); + + GetStringArg(pLine, szBuf); + uppermem_link = strcmp(szBuf, "UMB") ? 1 : 0; + + if(uppermem_link) + { + tmp = *u; + *u = 0x1234; + if(*u == 0x1234) + *u = tmp; + else + uppermem_link = 0; + } +} + INIT static VOID Switchar(BYTE * pLine) { /* Format: SWITCHAR = character */ @@ -769,14 +825,37 @@ INIT static VOID Break(BYTE * pLine) break_ena = strcmp(szBuf, "OFF") ? 1 : 0; } +INIT static VOID DeviceHigh(BYTE * pLine) +{ + if(uppermem_link) + { + LoadDevice(pLine, UMB_top, TRUE); + } + else + { + printf("UMB's unavalable!\n"); + LoadDevice(pLine, ram_top, FALSE); + } +} + INIT static VOID Device(BYTE * pLine) +{ + LoadDevice(pLine, ram_top, FALSE); +} + +INIT static VOID LoadDevice(BYTE * pLine, COUNT top, COUNT mode) { VOID FAR *driver_ptr; BYTE *pTmp; exec_blk eb; struct dhdr FAR *dhp; struct dhdr FAR *next_dhp; - UWORD dev_seg = (((ULONG) FP_SEG(lpBase) << 4) + FP_OFF(lpBase) + 0xf) >> 4; + UWORD dev_seg; + + if(mode) + dev_seg = (((ULONG) FP_SEG(upBase) << 4) + FP_OFF(upBase) + 0xf) >> 4; + else + dev_seg = (((ULONG) FP_SEG(lpBase) << 4) + FP_OFF(lpBase) + 0xf) >> 4; /* Get the device driver name */ GetStringArg(pLine, szBuf); @@ -797,7 +876,7 @@ INIT static VOID Device(BYTE * pLine) next_dhp = dhp->dh_next = nul_dev.dh_next; nul_dev.dh_next = dhp; - if(init_device(dhp, pLine)){ + if(init_device(dhp, pLine, mode, top)){ nul_dev.dh_next = next_dhp; /* return orig pointer if error */ } } @@ -962,6 +1041,26 @@ INIT VOID mcbp->m_name[i] = '\0'; mem_access_mode = FIRST_FIT; } +INIT VOID + umcb_init(mcb FAR * mcbp, UWORD size) +{ + COUNT i; + static char name[8] = "UMB "; + + mcbp->m_type = 0x4d; + mcbp->m_psp = 0x08; + mcbp->m_size = size; + for (i = 0; i < 8; i++) + mcbp->m_name[i] = name[i]; +} +INIT VOID + zumcb_init(mcb FAR * mcbp, UWORD size) +{ + COUNT i; + mcbp->m_type = MCB_LAST; + mcbp->m_psp = FREE_PSP; + mcbp->m_size = size; +} #endif INIT VOID diff --git a/kernel/dosfns.c b/kernel/dosfns.c index 85e26111..ce3727ab 100644 --- a/kernel/dosfns.c +++ b/kernel/dosfns.c @@ -34,6 +34,9 @@ static BYTE *dosfnsRcsId = "$Id$"; /* * $Log$ + * Revision 1.7 2000/06/21 18:16:46 jimtabor + * Add UMB code, patch, and code fixes + * * Revision 1.6 2000/06/01 06:37:38 jimtabor * Read History for Changes * @@ -230,13 +233,7 @@ UCOUNT GenericRead(COUNT hndl, UCOUNT n, BYTE FAR * bp, COUNT FAR * err, if (s->sft_flags & SFT_FSHARED) { ReadCount = Remote_RW(REM_READ, n, bp, s, err); - if (err) - { - *err = SUCCESS; - return ReadCount; - } - else - return 0; + return *err == SUCCESS ? ReadCount : 0; } /* Do a device read if device */ if (s->sft_flags & SFT_FDEVICE) @@ -346,12 +343,7 @@ UCOUNT DosWrite(COUNT hndl, UCOUNT n, BYTE FAR * bp, COUNT FAR * err) if (s->sft_flags & SFT_FSHARED) { WriteCount = Remote_RW(REM_WRITE, n, bp, s, err); - if (err) - { - return WriteCount; - } - else - return 0; + return *err == SUCCESS ? WriteCount : 0; } /* Do a device write if device */ @@ -962,7 +954,7 @@ VOID DosGetFree(COUNT drive, COUNT FAR * spc, COUNT FAR * navc, COUNT FAR * bps, drive = (drive == 0 ? default_drive : drive - 1); /* first check for valid drive */ - if (drive < 0 || drive > lastdrive) + if (drive < 0 || drive > (lastdrive - 1)) { *spc = -1; return; @@ -1011,7 +1003,7 @@ COUNT DosGetCuDir(COUNT drive, BYTE FAR * s) drive = (drive == 0 ? default_drive : drive - 1); /* first check for valid drive */ - if (drive < 0 || drive > lastdrive) { + if (drive < 0 || drive > (lastdrive - 1)) { return DE_INVLDDRV; } @@ -1190,6 +1182,7 @@ COUNT DosGetFattr(BYTE FAR * name, UWORD FAR * attrp) else { result = dos_getfattr(name, attrp); } + return result; } COUNT DosSetFattr(BYTE FAR * name, UWORD FAR * attrp) @@ -1228,7 +1221,7 @@ COUNT DosSetFattr(BYTE FAR * name, UWORD FAR * attrp) BYTE DosSelectDrv(BYTE drv) { - if ((drv <= lastdrive) && (CDSp->cds_table[drv].cdsFlags & 0xf000)) + if ((drv <= (lastdrive -1 )) && (CDSp->cds_table[drv].cdsFlags & 0xf000)) { current_ldt = &CDSp->cds_table[drv]; default_drive = drv; diff --git a/kernel/dosnames.c b/kernel/dosnames.c index 6210baf5..e82488ce 100644 --- a/kernel/dosnames.c +++ b/kernel/dosnames.c @@ -36,6 +36,9 @@ static BYTE *dosnamesRcsId = "$Id$"; /* * $Log$ + * Revision 1.6 2000/06/21 18:16:46 jimtabor + * Add UMB code, patch, and code fixes + * * Revision 1.5 2000/06/01 06:37:38 jimtabor * Read History for Changes * @@ -138,7 +141,13 @@ VOID SpacePad(BYTE * szString, COUNT nChars) for (i = strlen(szString); i < nChars; i++) szString[i] = ' '; } +/* + MSD durring an FindFirst search string looks like this; + (*), & (.) == Current directory *.* + (\) == Root directory *.* + (..) == Back one directory *.* + */ COUNT ParseDosName(BYTE FAR * lpszFileName, COUNT * pnDrive, BYTE * pszDir, @@ -254,8 +263,9 @@ COUNT ParseDosName(BYTE FAR * lpszFileName, ++nExtCnt; ++lpszFileName; } - else + else{ return DE_FILENOTFND; + } } } else if (*lpszFileName) diff --git a/kernel/dsk.c b/kernel/dsk.c index fcc68aad..9a5b3d30 100644 --- a/kernel/dsk.c +++ b/kernel/dsk.c @@ -33,6 +33,9 @@ static BYTE *dskRcsId = "$Id$"; /* * $Log$ + * Revision 1.8 2000/06/21 18:16:46 jimtabor + * Add UMB code, patch, and code fixes + * * Revision 1.7 2000/06/01 06:37:38 jimtabor * Read History for Changes * @@ -215,9 +218,13 @@ WORD init(rqptr), blockio(rqptr), IoctlQueblk(rqptr), Genblkdev(rqptr), + Getlogdev(rqptr), + Setlogdev(rqptr), blk_Open(rqptr), blk_Close(rqptr), blk_Media(rqptr), + blk_noerr(rqptr), + blk_nondr(rqptr), blk_error(rqptr); COUNT ltop(WORD *, WORD *, WORD *, COUNT, COUNT, LONG, byteptr); WORD dskerr(COUNT); @@ -229,9 +236,13 @@ WORD init(), blockio(), IoctlQueblk(), Genblkdev(), + Getlogdev(), + Setlogdev(), blk_Open(), blk_Close(), blk_Media(), + blk_noerr(), + blk_nondr(), blk_error(); WORD dskerr(); COUNT processtable(); @@ -247,31 +258,31 @@ static WORD(*dispatch[NENTRY]) (rqptr) = static WORD(*dispatch[NENTRY]) () = #endif { - init, /* Initialize */ + init, /* Initialize */ mediachk, /* Media Check */ bldbpb, /* Build BPB */ blk_error, /* Ioctl In */ blockio, /* Input (Read) */ - blk_error, /* Non-destructive Read */ - blk_error, /* Input Status */ - blk_error, /* Input Flush */ + blk_nondr, /* Non-destructive Read */ + blk_noerr, /* Input Status */ + blk_noerr, /* Input Flush */ blockio, /* Output (Write) */ blockio, /* Output with verify */ - blk_error, /* Output Status */ - blk_error, /* Output Flush */ + blk_noerr, /* Output Status */ + blk_noerr, /* Output Flush */ blk_error, /* Ioctl Out */ blk_Open, /* Device Open */ blk_Close, /* Device Close */ blk_Media, /* Removable Media */ - blk_error, /* Output till busy */ + blk_noerr, /* Output till busy */ blk_error, /* undefined */ blk_error, /* undefined */ Genblkdev, /* Generic Ioctl Call */ blk_error, /* undefined */ blk_error, /* undefined */ blk_error, /* undefined */ - blk_error, /* Get Logical Device */ - blk_error, /* Set Logical Device */ + Getlogdev, /* Get Logical Device */ + Setlogdev, /* Set Logical Device */ IoctlQueblk /* Ioctl Query */ }; @@ -535,10 +546,30 @@ static WORD RWzero(rqptr rp, WORD t) return ret; } +/* + 0 if not set, 1 = a, 2 = b, etc, assume set. + page 424 MS Programmer's Ref. + */ +static WORD Getlogdev(rqptr rp) +{ + BYTE x = rp->r_unit; + x++; + if( x > nblk_rel ) + return failure(E_UNIT); + + rp->r_unit = x; + return S_DONE; +} + +static WORD Setlogdev(rqptr rp) +{ + return S_DONE; +} + static WORD blk_Open(rqptr rp) { - miarray[rp->r_unit].mi_FileOC++; - return S_DONE; + miarray[rp->r_unit].mi_FileOC++; + return S_DONE; } static WORD blk_Close(rqptr rp) @@ -547,11 +578,14 @@ static WORD blk_Close(rqptr rp) return S_DONE; } -static WORD blk_Media(rqptr rp) +static WORD blk_nondr(rqptr rp) { - COUNT drive = miarray[rp->r_unit].mi_drive; + return S_BUSY|S_DONE; +} - if (hd(drive)) +static WORD blk_Media(rqptr rp) +{ + if (hd( miarray[rp->r_unit].mi_drive)) return S_BUSY|S_DONE; /* Hard Drive */ else return S_DONE; /* Floppy */ @@ -652,7 +686,7 @@ static WORD IoctlQueblk(rqptr rp) case 0x0867: break; default: - return S_ERROR; + return failure(E_CMD); } return S_DONE; @@ -738,7 +772,7 @@ static WORD Genblkdev(rqptr rp) case 0x0847: /* set access flag, no real use*/ break; default: - return S_ERROR; + return failure(E_CMD); } return S_DONE; } @@ -818,6 +852,12 @@ static WORD blk_error(rqptr rp) return failure(E_FAILURE); /* general failure */ } + +static WORD blk_noerr(rqptr rp) +{ + return S_DONE; +} + static WORD dskerr(COUNT code) { /* printf("diskette error:\nhead = %d\ntrack = %d\nsector = %d\ncount = %d\n", diff --git a/kernel/fatdir.c b/kernel/fatdir.c index 58552914..760d3434 100644 --- a/kernel/fatdir.c +++ b/kernel/fatdir.c @@ -36,6 +36,9 @@ static BYTE *fatdirRcsId = "$Id$"; /* * $Log$ + * Revision 1.8 2000/06/21 18:16:46 jimtabor + * Add UMB code, patch, and code fixes + * * Revision 1.7 2000/06/01 06:46:57 jimtabor * Removed Debug printf * @@ -190,7 +193,7 @@ struct f_node FAR *dir_open(BYTE FAR * dirname) { drive = default_drive; } - if (drive > lastdrive) { + if (drive > (lastdrive-1)) { release_f_node(fnp); return NULL; } @@ -580,7 +583,7 @@ COUNT dos_findfirst(UCOUNT attr, BYTE FAR * name) fscopy(name, (BYTE FAR *)&Tname); /* printf("ff %s", Tname); -*/ + */ /* The findfirst/findnext calls are probably the worst of the */ /* DOS calls. They must work somewhat on the fly (i.e. - open */ /* but never close). Since we don't want to lose fnodes every */ @@ -611,7 +614,7 @@ COUNT dos_findfirst(UCOUNT attr, BYTE FAR * name) else nDrive = default_drive; - if (nDrive > lastdrive) { + if (nDrive > (lastdrive -1)) { return DE_INVLDDRV; } current_ldt = &CDSp->cds_table[nDrive]; @@ -658,7 +661,7 @@ COUNT dos_findfirst(UCOUNT attr, BYTE FAR * name) if (current_ldt->cdsFlags & CDSNETWDRV) { - if (Remote_find(REM_FINDFIRST, attr, name, dmp) != 0) + if (Remote_find(REM_FINDFIRST, name, dmp) != 0) return DE_FILENOTFND; return SUCCESS; } @@ -751,7 +754,7 @@ COUNT dos_findnext(void) */ nDrive = dmp->dm_drive & 0x1f; - if (nDrive > lastdrive) { + if (nDrive > (lastdrive -1)) { return DE_INVLDDRV; } current_ldt = &CDSp->cds_table[nDrive]; @@ -763,7 +766,7 @@ COUNT dos_findnext(void) if (current_ldt->cdsFlags & CDSNETWDRV) { - if (Remote_find(REM_FINDNEXT, 0, 0, dmp) != 0) + if (Remote_find(REM_FINDNEXT, 0, dmp) != 0) return DE_FILENOTFND; return SUCCESS; } @@ -777,7 +780,7 @@ COUNT dos_findnext(void) /* Force the fnode into read-write mode */ fnp->f_mode = RDWR; - if (dmp->dm_drive > lastdrive) { + if (dmp->dm_drive > (lastdrive -1)) { return DE_INVLDDRV; } /* Select the default to help non-drive specified path */ @@ -815,6 +818,12 @@ COUNT dos_findnext(void) { if (fcmp_wild((BYTE FAR *) (dmp->dm_name_pat), (BYTE FAR *) fnp->f_dir.dir_name, FNAME_SIZE + FEXT_SIZE)) { + /* + MSD Command.com uses FCB FN 11 & 12 with attrib set to 0x16. + Bits 0x21 seem to get set some where in MSD so Rd and Arc + files are returned. FD assumes the user knows what they need + to see. + */ /* Test the attribute as the final step */ if (!(~dmp->dm_attr_srch & fnp->f_dir.dir_attrib)) { diff --git a/kernel/fatfs.c b/kernel/fatfs.c index ce2d95a7..2d25f773 100644 --- a/kernel/fatfs.c +++ b/kernel/fatfs.c @@ -36,6 +36,9 @@ BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.5 2000/06/21 18:16:46 jimtabor + * Add UMB code, patch, and code fixes + * * Revision 1.4 2000/05/25 20:56:21 jimtabor * Fixed project history * @@ -329,7 +332,7 @@ static struct f_node FAR * SpacePad(fname, FNAME_SIZE); SpacePad(fext, FEXT_SIZE); - if (nDrive > lastdrive) { + if (nDrive > (lastdrive -1)) { return (struct f_node FAR *)0; } cdsp = &CDSp->cds_table[nDrive]; diff --git a/kernel/fcbfns.c b/kernel/fcbfns.c index c728a3c0..7e91cd12 100644 --- a/kernel/fcbfns.c +++ b/kernel/fcbfns.c @@ -35,6 +35,9 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.5 2000/06/21 18:16:46 jimtabor + * Add UMB code, patch, and code fixes + * * Revision 1.4 2000/05/26 19:25:19 jimtabor * Read History file for Change info * @@ -143,7 +146,7 @@ VOID FatGetDrvData(COUNT drive, COUNT FAR * spc, COUNT FAR * bps, printf("FGDD\n"); /* first check for valid drive */ - if ((drive < 0) || (drive > lastdrive) || (drive > NDEVS)) + if ((drive < 0) || (drive > (lastdrive -1)) || (drive > NDEVS)) { *spc = -1; return; @@ -226,7 +229,7 @@ WORD FcbParseFname(int wTestMode, BYTE FAR ** lpFileName, fcb FAR * lpFcb) if (Drive < 'A' || Drive > 'Z') return PARSE_RET_BADDRIVE; Drive -= ('A' - 1); - if (Drive > lastdrive) + if (Drive > (lastdrive -1)) return PARSE_RET_BADDRIVE; else lpFcb->fcb_drive = Drive; @@ -650,7 +653,7 @@ BOOL FcbCreate(xfcb FAR * lpXfcb) sftp->sft_mode = O_RDWR; sftp->sft_attrib = 0; sftp->sft_flags = - (dhp->dh_attr & ~SFT_MASK) | SFT_FDEVICE | SFT_FEOF; + ((dhp->dh_attr & ~SFT_MASK) & ~SFT_FSHARED) | SFT_FDEVICE | SFT_FEOF; sftp->sft_psp = cu_psp; fbcopy(lpFcb->fcb_fname, sftp->sft_name, FNAME_SIZE + FEXT_SIZE); sftp->sft_dev = dhp; @@ -786,7 +789,7 @@ BOOL FcbOpen(xfcb FAR * lpXfcb) sftp->sft_mode = O_RDWR; sftp->sft_attrib = 0; sftp->sft_flags = - (dhp->dh_attr & ~SFT_MASK) | SFT_FDEVICE | SFT_FEOF; + ((dhp->dh_attr & ~SFT_MASK) & ~SFT_FSHARED) | SFT_FDEVICE | SFT_FEOF; sftp->sft_psp = cu_psp; fbcopy(lpFcb->fcb_fname, sftp->sft_name, FNAME_SIZE + FEXT_SIZE); sftp->sft_dev = dhp; @@ -800,7 +803,7 @@ BOOL FcbOpen(xfcb FAR * lpXfcb) return TRUE; } fbcopy((BYTE FAR *) & lpFcb->fcb_fname, (BYTE FAR *) & sftp->sft_name, FNAME_SIZE + FEXT_SIZE); - if ((FcbDrive < 0) || (FcbDrive > lastdrive)) { + if ((FcbDrive < 0) || (FcbDrive > (lastdrive -1))) { return DE_INVLDDRV; } if (CDSp->cds_table[FcbDrive].cdsFlags & CDSNETWDRV) { @@ -846,7 +849,7 @@ BOOL FcbDelete(xfcb FAR * lpXfcb) /* Build a traditional DOS file name */ CommonFcbInit(lpXfcb, PriPathName, &FcbDrive); - if ((FcbDrive < 0) || (FcbDrive > lastdrive)) { + if ((FcbDrive < 0) || (FcbDrive > (lastdrive -1))) { return DE_INVLDDRV; } current_ldt = &CDSp->cds_table[FcbDrive]; @@ -1123,8 +1126,19 @@ BOOL FcbFindFirst(xfcb FAR * lpXfcb) } MoveDirInfo((dmatch FAR *) & Dmatch, (struct dirent FAR *)lpDir); + lpFcb->fcb_dirclst = Dmatch.dm_cluster; lpFcb->fcb_diroff = Dmatch.dm_entry; +/* + This is undocumented and seen using Pcwatch. + The First byte is the current directory count and the second seems + to be the attribute byte. + */ +#if 0 + lpFcb->fcb_cublock = Dmatch.dm_entry; + lpFcb->fcb_cublock *= 0x100; + lpFcb->fcb_cublock += wAttr; +#endif dta = lpPsp->ps_dta; return TRUE; } @@ -1159,6 +1173,7 @@ BOOL FcbFindNext(xfcb FAR * lpXfcb) fbcopy(lpFcb->fcb_fname, (BYTE FAR *) Dmatch.dm_name_pat, FNAME_SIZE + FEXT_SIZE); upFMem((BYTE FAR *) Dmatch.dm_name_pat, FNAME_SIZE + FEXT_SIZE); + Dmatch.dm_attr_srch = wAttr; Dmatch.dm_entry = lpFcb->fcb_diroff; Dmatch.dm_cluster = lpFcb->fcb_dirclst; @@ -1166,6 +1181,7 @@ BOOL FcbFindNext(xfcb FAR * lpXfcb) if (dos_findnext() != SUCCESS) { dta = lpPsp->ps_dta; + CritErrCode = 0x12; return FALSE; } @@ -1173,6 +1189,11 @@ BOOL FcbFindNext(xfcb FAR * lpXfcb) lpFcb->fcb_dirclst = Dmatch.dm_cluster; lpFcb->fcb_diroff = Dmatch.dm_entry; dta = lpPsp->ps_dta; +#if 0 + lpFcb->fcb_cublock = Dmatch.dm_entry; + lpFcb->fcb_cublock *= 0x100; + lpFcb->fcb_cublock += wAttr; +#endif return TRUE; } #endif diff --git a/kernel/globals.h b/kernel/globals.h index b38af576..7f4126de 100644 --- a/kernel/globals.h +++ b/kernel/globals.h @@ -36,6 +36,9 @@ static BYTE *Globals_hRcsId = "$Id$"; /* * $Log$ + * Revision 1.4 2000/06/21 18:16:46 jimtabor + * Add UMB code, patch, and code fixes + * * Revision 1.3 2000/05/25 20:56:21 jimtabor * Fixed project history * @@ -419,7 +422,9 @@ extern BYTE NetDelay, NetRetry; extern UWORD - first_mcb; /* Start of user memory */ + first_mcb, /* Start of user memory */ + UMB_top, + uppermem_root; /* Start of umb chain ? */ extern struct dpb FAR *DPBp; /* First drive Parameter Block */ extern sfttbl @@ -441,7 +446,8 @@ extern WORD nprotfcb; /* number of protected fcbs */ extern BYTE nblkdev, /* number of block devices */ - lastdrive; /* value of last drive */ + lastdrive, /* value of last drive */ + uppermem_link; /* UMB Link flag */ extern struct dhdr nul_dev; extern BYTE @@ -452,9 +458,15 @@ extern BYTE OpenMode, /* File Open Attributes */ SAttr, /* Attrib Mask for Dir Search */ dosidle_flag, + Server_Call, + CritErrLocus, + CritErrAction, + CritErrClass, njoined; /* number of joined devices */ extern UWORD Int21AX; +extern COUNT CritErrCode; +extern BYTE FAR * CritErrDev; extern struct dirent SearchDir; @@ -545,9 +557,9 @@ extern BYTE return_code; /* " " " */ extern BYTE + BootDrive, /* Drive we came up from */ scr_pos; /* screen position for bs, ht, etc */ extern WORD - BootDrive, /* Drive we came up from */ NumFloppies; /* How many floppies we have */ extern keyboard @@ -639,7 +651,7 @@ VOID FAR CharMapSrvc(VOID); VOID FAR set_stack(VOID); VOID FAR restore_stack(VOID); #ifndef IN_INIT_MOD -VOID execrh(request FAR *, struct dhdr FAR *); +WORD execrh(request FAR *, struct dhdr FAR *); #endif VOID FAR init_call_execrh(request FAR *, struct dhdr FAR *); VOID exit(COUNT); @@ -659,7 +671,7 @@ VOID putdirent(struct dirent FAR *, BYTE FAR *); VOID FAR CharMapSrvc(); VOID FAR set_stack(); VOID FAR restore_stack(); -VOID execrh(); +WORD execrh(); VOID exit(); /*VOID INRPT FAR handle_break(); */ VOID tmark(); diff --git a/kernel/int2f.asm b/kernel/int2f.asm index e2a1a823..273d5537 100644 --- a/kernel/int2f.asm +++ b/kernel/int2f.asm @@ -30,6 +30,9 @@ ; $Id$ ; ; $Log$ +; Revision 1.5 2000/06/21 18:16:46 jimtabor +; Add UMB code, patch, and code fixes +; ; Revision 1.4 2000/05/25 20:56:21 jimtabor ; Fixed project history ; @@ -108,9 +111,27 @@ Int2f3: iret ; Default, interrupt return ; +;return dos data seg. +IntDosCal: + cmp al,03 + jne IntDosCal_1 + push ax + mov ax, seg _nul_dev + mov ds,ax + pop ax + clc + jmp FarTabRetn +; +;Set FastOpen but does nothing. +IntDosCal_1: + cmp al,02ah + jne IntDosCal_2 + clc + jmp FarTabRetn +; ; added by James Tabor For Zip Drives ;Return Null Device Pointer -IntDosCal: +IntDosCal_2: cmp al,02ch jne Int2f2 mov ax,_nul_dev @@ -157,6 +178,7 @@ int2f_r_1: jnc short int2f_skip1 jmp int2f_rfner int2f_skip1: + xor ax,ax les di,[bp+18] ; do return data stuff mov [es:di],cx jmp short int2f_rfner @@ -170,6 +192,7 @@ int2f_r_2: mov [es:di+2],bx mov [es:di+4],cx mov [es:di+6],dx + xor ax,ax jmp short int2f_rfner int2f_r_3: cmp al,0fh ; Get Remote File Attrib @@ -183,7 +206,7 @@ int2f_r_3: mov [es:di+4],bx ; high mov [es:di+6],cx mov [es:di+8],dx - mov ax,0000h + xor ax,ax jmp short int2f_rfner int2f_r_4: cmp al,01eh @@ -214,8 +237,8 @@ int2f_r_7: ; everything else goes through here. ; call int2f_call - jc int2f_rfner - xor ax,ax + jc int2f_rfner + xor ax,ax int2f_rfner: pop bx pop cx @@ -242,9 +265,9 @@ _QRemote_Fn les di,[bp+8] stc int 2fh - mov ax,0xffff - jnc QRemote_Fn_out - xor ax,ax + mov ax,0xffff + jnc QRemote_Fn_out + xor ax,ax QRemote_Fn_out: pop di pop si diff --git a/kernel/inthndlr.c b/kernel/inthndlr.c index 933ccbb7..3bf0bc48 100644 --- a/kernel/inthndlr.c +++ b/kernel/inthndlr.c @@ -36,6 +36,9 @@ BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.8 2000/06/21 18:16:46 jimtabor + * Add UMB code, patch, and code fixes + * * Revision 1.7 2000/05/25 20:56:21 jimtabor * Fixed project history * @@ -335,6 +338,7 @@ VOID int21_service(iregs FAR * r) error_exit: r->AX = -rc; error_out: + CritErrCode = r->AX; /* Maybe set */ r->FLAGS |= FLG_CARRY; break; @@ -504,23 +508,19 @@ VOID int21_service(iregs FAR * r) case 0x14: { - COUNT nErrorCode; - - if (FcbRead(MK_FP(r->DS, r->DX), &nErrorCode)) + if (FcbRead(MK_FP(r->DS, r->DX), &CritErrCode)) r->AL = 0; else - r->AL = nErrorCode; + r->AL = CritErrCode; break; } case 0x15: { - COUNT nErrorCode; - - if (FcbWrite(MK_FP(r->DS, r->DX), &nErrorCode)) + if (FcbWrite(MK_FP(r->DS, r->DX), &CritErrCode)) r->AL = 0; else - r->AL = nErrorCode; + r->AL = CritErrCode; break; } @@ -596,12 +596,13 @@ VOID int21_service(iregs FAR * r) /* Get default DPB */ case 0x1f: - if (default_drive <= lastdrive) + if (default_drive <= (lastdrive -1)) { struct dpb FAR *dpb = (struct dpb FAR *)CDSp->cds_table[default_drive].cdsDpb; if (dpb == 0) { r->AL = 0xff; + CritErrCode = 0x0f; break; } @@ -609,31 +610,29 @@ VOID int21_service(iregs FAR * r) r->BX = FP_OFF(dpb); r->AL = 0; } - else + else{ r->AL = 0xff; + CritErrCode = 0x0f; + } break; /* Random read using FCB */ case 0x21: { - COUNT nErrorCode; - - if (FcbRandomRead(MK_FP(r->DS, r->DX), &nErrorCode)) + if (FcbRandomRead(MK_FP(r->DS, r->DX), &CritErrCode)) r->AL = 0; else - r->AL = nErrorCode; + r->AL = CritErrCode; break; } /* Random write using FCB */ case 0x22: { - COUNT nErrorCode; - - if (FcbRandomWrite(MK_FP(r->DS, r->DX), &nErrorCode)) + if (FcbRandomWrite(MK_FP(r->DS, r->DX), &CritErrCode)) r->AL = 0; else - r->AL = nErrorCode; + r->AL = CritErrCode; break; } @@ -671,24 +670,20 @@ VOID int21_service(iregs FAR * r) /* Read random record(s) using FCB */ case 0x27: { - COUNT nErrorCode; - - if (FcbRandomBlockRead(MK_FP(r->DS, r->DX), r->CX, &nErrorCode)) + if (FcbRandomBlockRead(MK_FP(r->DS, r->DX), r->CX, &CritErrCode)) r->AL = 0; else - r->AL = nErrorCode; + r->AL = CritErrCode; break; } /* Write random record(s) using FCB */ case 0x28: { - COUNT nErrorCode; - - if (FcbRandomBlockWrite(MK_FP(r->DS, r->DX), r->CX, &nErrorCode)) + if (FcbRandomBlockWrite(MK_FP(r->DS, r->DX), r->CX, &CritErrCode)) r->AL = 0; else - r->AL = nErrorCode; + r->AL = CritErrCode; break; } @@ -782,20 +777,24 @@ VOID int21_service(iregs FAR * r) /* Get DPB */ case 0x32: r->DL = ( r->DL == 0 ? default_drive : r->DL - 1); - if (r->DL <= lastdrive) + if (r->DL <= (lastdrive - 1)) { struct dpb FAR *dpb = CDSp->cds_table[r->DL].cdsDpb; if (dpb == 0) { r->AL = 0xff; + CritErrCode = 0x0f; break; } r->DS = FP_SEG(dpb); r->BX = FP_OFF(dpb); r->AL = 0; } - else + else { r->AL = 0xFF; + CritErrCode = 0x0f; + + } break; /* Get InDOS flag */ @@ -943,8 +942,8 @@ VOID int21_service(iregs FAR * r) if (rc1 != SUCCESS) { - r->FLAGS |= FLG_CARRY; r->AX = -rc1; + goto error_out; } else { @@ -958,8 +957,8 @@ VOID int21_service(iregs FAR * r) rc = DosWrite(r->BX, r->CX, MK_FP(r->DS, r->DX), (COUNT FAR *) & rc1); if (rc1 != SUCCESS) { - r->FLAGS |= FLG_CARRY; r->AX = -rc1; + goto error_out; } else { @@ -973,8 +972,8 @@ VOID int21_service(iregs FAR * r) rc = DosDelete((BYTE FAR *) MK_FP(r->DS, r->DX)); if (rc < 0) { - r->FLAGS |= FLG_CARRY; r->AX = -rc; + goto error_out; } else r->FLAGS &= ~FLG_CARRY; @@ -1026,13 +1025,10 @@ VOID int21_service(iregs FAR * r) if (rc1 != SUCCESS) { - r->FLAGS |= FLG_CARRY; r->AX = -rc1; + goto error_out; } - else - { - if((r->AL == 0x02) || (r->AL == 0x03) || (r->AL == 0x04) || (r->AL == 0x05)) - r->AX = r->CX; + else{ r->FLAGS &= ~FLG_CARRY; } } @@ -1198,8 +1194,7 @@ VOID int21_service(iregs FAR * r) if (r->AX == 2) r->AX = 18; - - r->FLAGS |= FLG_CARRY; + goto error_out; } else { @@ -1282,15 +1277,25 @@ VOID int21_service(iregs FAR * r) break; case 0x01: - if (((COUNT) r->BX) < 0 || r->BX > 2) +/* if (((COUNT) r->BX) < 0 || r->BX > 2) goto error_invalid; else - { + { */ + mem_access_mode = r->BX; r->FLAGS &= ~FLG_CARRY; - } + +/* }*/ break; + case 0x02: + r->AL = uppermem_link; + break; + + case 0x03: + uppermem_link = r->BL; + break; + default: goto error_invalid; #ifdef DEBUG @@ -1301,6 +1306,17 @@ VOID int21_service(iregs FAR * r) } break; + /* Get Extended Error */ + case 0x59: + r->AX = CritErrCode; + r->ES = FP_SEG(CritErrDev); + r->DI = FP_OFF(CritErrDev); + r->CH = CritErrLocus; + r->BH = CritErrClass; + r->BL = CritErrAction; + r->FLAGS &= ~FLG_CARRY; + break; + /* Create Temporary File */ case 0x5a: if ((rc = DosMkTmp(MK_FP(r->DS, r->DX), r->CX)) < 0) @@ -1318,7 +1334,7 @@ VOID int21_service(iregs FAR * r) { DosClose(rc); r->AX = 80; - r->FLAGS |= FLG_CARRY; + goto error_out; } else { @@ -1367,7 +1383,7 @@ VOID int21_service(iregs FAR * r) result = int2f_Remote_call(REM_PRINTREDIR, 0, 0, r->DX, 0, 0, (MK_FP(0, Int21AX))); r->AX = result; if (result != SUCCESS) { - r->FLAGS |= FLG_CARRY; + goto error_out; } else { r->FLAGS &= ~FLG_CARRY; } @@ -1395,7 +1411,7 @@ VOID int21_service(iregs FAR * r) result = int2f_Remote_call(REM_PRINTSET, r->BX, r->CX, r->DX, (MK_FP(r->ES, r->DI)), r->SI, (MK_FP(r->DS, Int21AX))); r->AX = result; if (result != SUCCESS) { - r->FLAGS |= FLG_CARRY; + goto error_out; } else { r->FLAGS &= ~FLG_CARRY; } @@ -1408,13 +1424,13 @@ VOID int21_service(iregs FAR * r) switch (r->AL) { case 0x07: - if (r->DL <= lastdrive) { + if (r->DL <= (lastdrive -1)) { CDSp->cds_table[r->DL].cdsFlags |= 0x100; } break; case 0x08: - if (r->DL <= lastdrive) { + if (r->DL <= (lastdrive -1)) { CDSp->cds_table[r->DL].cdsFlags &= ~0x100; } break; @@ -1425,7 +1441,7 @@ VOID int21_service(iregs FAR * r) result = int2f_Remote_call(REM_DOREDIRECT, r->BX, r->CX, r->DX, (MK_FP(r->ES, r->DI)), r->SI, (MK_FP(r->DS, Int21AX))); r->AX = result; if (result != SUCCESS) { - r->FLAGS |= FLG_CARRY; + goto error_out; } else { r->FLAGS &= ~FLG_CARRY; } @@ -1563,7 +1579,7 @@ VOID int21_service(iregs FAR * r) /* Get/Set Serial Number */ case 0x69: rc = ( r->BL == 0 ? default_drive : r->BL - 1); - if (rc <= lastdrive) + if (rc <= (lastdrive -1)) { if (CDSp->cds_table[rc].cdsFlags & CDSNETWDRV) { goto error_invalid; @@ -1583,8 +1599,8 @@ VOID int21_service(iregs FAR * r) } if (rc1 != SUCCESS) { - r->FLAGS |= FLG_CARRY; r->AX = -rc1; + goto error_out; } else { @@ -1771,7 +1787,7 @@ VOID int25_handler(struct int25regs FAR * r) buf = MK_FP(r->ds, r->bx); } - if (drv >= nblkdev) + if (drv >= (lastdrive - 1)) { r->ax = 0x202; r->flags |= FLG_CARRY; @@ -1814,7 +1830,7 @@ VOID int26_handler(struct int25regs FAR * r) buf = MK_FP(r->ds, r->bx); } - if (drv >= nblkdev) + if (drv >= (lastdrive -1)) { r->ax = 0x202; r->flags |= FLG_CARRY; diff --git a/kernel/io.asm b/kernel/io.asm index 67940c98..1adff0f6 100644 --- a/kernel/io.asm +++ b/kernel/io.asm @@ -28,6 +28,9 @@ ; $Header$ ; ; $Log$ +; Revision 1.6 2000/06/21 18:16:46 jimtabor +; Add UMB code, patch, and code fixes +; ; Revision 1.5 2000/06/01 06:37:38 jimtabor ; Read History for Changes ; @@ -559,8 +562,8 @@ blk_entry: pop cx pop cx les bx,[cs:_ReqPktPtr] ; now return completion code - mov word [es:bx+status],ax ; mark operation complete - cli ; no interrupts + mov word [es:bx+status],ax ; mark operation complete + cli ; no interrupts mov sp,[blk_dos_stk] ; use dos stack mov ss,[blk_dos_seg] pop es diff --git a/kernel/ioctl.c b/kernel/ioctl.c index 4c354ecd..e53998b1 100644 --- a/kernel/ioctl.c +++ b/kernel/ioctl.c @@ -35,6 +35,9 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.6 2000/06/21 18:16:46 jimtabor + * Add UMB code, patch, and code fixes + * * Revision 1.5 2000/05/25 20:56:21 jimtabor * Fixed project history * @@ -117,7 +120,7 @@ COUNT DosDevIOctl(iregs FAR * r, COUNT FAR * err) struct dpb FAR *dpbp; struct cds FAR *cdsp; BYTE FAR *pBuffer = MK_FP(r->DS, r->DX); - COUNT nMode; + COUNT nMode , dev; /* Test that the handle is valid */ switch (r->AL) @@ -159,17 +162,16 @@ COUNT DosDevIOctl(iregs FAR * r, COUNT FAR * err) /* JPP - changed to use default drive if drive=0 */ /* JT Fixed it */ - r->BL = ( r->BL == 0 ? default_drive : r->BL - 1); - + dev = ( r->BL == 0 ? default_drive : r->BL - 1); - if (r->BL > lastdrive) + if (dev > (lastdrive -1)) { *err = DE_INVLDDRV; return 0; } else { - cdsp = &CDSp->cds_table[r->BL]; + cdsp = &CDSp->cds_table[dev]; dpbp = cdsp->cdsDpb; } break; @@ -191,10 +193,10 @@ COUNT DosDevIOctl(iregs FAR * r, COUNT FAR * err) { case 0x00: /* Get the flags from the SFT */ - r->DX = r->AX = s->sft_flags; - -/* r->DX = r->AX = s->sft_dev->dh_attr;*/ - + r->AX = s->sft_dev->dh_attr; + r->DH = r->AH; +/* Undocumented result, Ax = Dx seen using Pcwatch */ + r->DL = r->AL = s->sft_flags; break; case 0x01: @@ -238,12 +240,23 @@ COUNT DosDevIOctl(iregs FAR * r, COUNT FAR * err) execrh((request FAR *) & CharReqHdr, s->sft_dev); if (CharReqHdr.r_status & S_ERROR) - return char_error(&CharReqHdr, s->sft_dev); + { + *err = DE_DEVICE; + return 0; + } if (r->AL == 0x07) { - r->AL = - CharReqHdr.r_status & S_BUSY ? - 00 : 0xff; + r->AL = CharReqHdr.r_status & S_BUSY ? 00 : 0xff; + + } + if (r->AL == 0x02 || r->AL == 0x03) + { + r->AX = CharReqHdr.r_count; + } + + if (r->AL == 0x0c || r->AL == 0x10) + { + r->AX = CharReqHdr.r_status; } break; } @@ -262,6 +275,11 @@ COUNT DosDevIOctl(iregs FAR * r, COUNT FAR * err) case 0x05: nMode = C_IOCTLOUT; IoBlockCommon: + if(!dpbp) + { + *err = DE_INVLDDRV; + return 0; + } if ( ((r->AL == 0x04 ) && !(dpbp->dpb_device->dh_attr & ATTR_IOCTL)) || ((r->AL == 0x05 ) && !(dpbp->dpb_device->dh_attr & ATTR_IOCTL)) || ((r->AL == 0x11) && !(dpbp->dpb_device->dh_attr & ATTR_QRYIOCTL)) @@ -271,7 +289,8 @@ COUNT DosDevIOctl(iregs FAR * r, COUNT FAR * err) return 0; } - CharReqHdr.r_unit = r->BL; + + CharReqHdr.r_unit = dev; CharReqHdr.r_length = sizeof(request); CharReqHdr.r_command = nMode; CharReqHdr.r_count = r->CX; @@ -279,24 +298,28 @@ COUNT DosDevIOctl(iregs FAR * r, COUNT FAR * err) CharReqHdr.r_status = 0; execrh((request FAR *) & CharReqHdr, dpbp->dpb_device); - if (r->AL == 0x08) - { + if (CharReqHdr.r_status & S_ERROR) { - *err = DE_DEVICE; - return 0; + *err = DE_DEVICE; + return 0; } - r->AX = (CharReqHdr.r_status & S_BUSY) ? 1 : 0; - } - else - { - if (CharReqHdr.r_status & S_ERROR) + if (r->AL == 0x08) { - *err = DE_DEVICE; - return 0; + r->AX = (CharReqHdr.r_status & S_BUSY) ? 1 : 0; + } - } - break; + + if (r->AL == 0x04 || r->AL == 0x05) + { + r->AX = CharReqHdr.r_count; + + } + if (r->AL == 0x0d || r->AL == 0x11) + { + r->AX = CharReqHdr.r_status; + } + break; case 0x06: if (s->sft_flags & SFT_FDEVICE) @@ -310,12 +333,18 @@ COUNT DosDevIOctl(iregs FAR * r, COUNT FAR * err) case 0x07: if (s->sft_flags & SFT_FDEVICE) { + nMode = C_OSTAT; goto IoCharCommon; } r->AL = 0; break; case 0x08: + if(!dpbp) + { + *err = DE_INVLDDRV; + return 0; + } if (dpbp->dpb_device->dh_attr & ATTR_EXCALLS) { nMode = C_REMMEDIA; @@ -326,13 +355,26 @@ COUNT DosDevIOctl(iregs FAR * r, COUNT FAR * err) case 0x09: if(cdsp->cdsFlags & CDSNETWDRV) - r->DX = ATTR_REMOTE; - else - r->DX = dpbp->dpb_device->dh_attr; + { + r->DX = ATTR_REMOTE ; + r->AX = S_DONE|S_BUSY; + } + else + { + if(!dpbp) + { + *err = DE_INVLDDRV; + return 0; + } +/* Need to add subst bit 15 */ + r->DX = dpbp->dpb_device->dh_attr; + r->AX = S_DONE|S_BUSY; + } break; case 0x0a: - r->DX = s->sft_flags & SFT_FSHARED; + r->DX = s->sft_flags; + r->AX = 0; break; case 0x0e: @@ -341,12 +383,16 @@ COUNT DosDevIOctl(iregs FAR * r, COUNT FAR * err) case 0x0f: nMode = C_SETLDEV; IoLogCommon: + if(!dpbp) + { + *err = DE_INVLDDRV; + return 0; + } if ((dpbp->dpb_device->dh_attr & ATTR_GENIOCTL)) { - if (r->BL == 0) - r->BL = default_drive; - CharReqHdr.r_unit = r->BL; + + CharReqHdr.r_unit = dev; CharReqHdr.r_length = sizeof(request); CharReqHdr.r_command = nMode; CharReqHdr.r_count = r->CX; @@ -358,7 +404,10 @@ COUNT DosDevIOctl(iregs FAR * r, COUNT FAR * err) if (CharReqHdr.r_status & S_ERROR) *err = DE_ACCESS; else - *err = SUCCESS; + { + r->AL = CharReqHdr.r_unit; + *err = SUCCESS; + } return 0; } *err = DE_INVLDFUNC; diff --git a/kernel/kernel.asm b/kernel/kernel.asm index 055c8ea4..63eec195 100644 --- a/kernel/kernel.asm +++ b/kernel/kernel.asm @@ -28,6 +28,9 @@ ; $Id$ ; ; $Log$ +; Revision 1.4 2000/06/21 18:16:46 jimtabor +; Add UMB code, patch, and code fixes +; ; Revision 1.3 2000/05/25 20:56:21 jimtabor ; Fixed project history ; @@ -178,7 +181,7 @@ floppy: mov byte [_BootDrive],bl ; tell where we came from mov ax,ds mov es,ax - jmp _main + jmp _main segment INIT_TEXT_END init_end: @@ -291,7 +294,7 @@ setverPtr dw 0,0 ; 0037 setver list dw 1 ; 003F number of buffers dw 1 ; 0041 size of pre-read buffer global _BootDrive -_BootDrive dw 0 ; 0043 drive we booted from +_BootDrive db 0 ; 0043 drive we booted from db 0 ; 0044 cpu type (1 if >=386) dw 0 ; 0045 Extended memory in KBytes buf_info dd 0 ; 0047 disk buffer chain @@ -301,14 +304,17 @@ buf_info dd 0 ; 0047 disk buffer chain db 0 ; 0053 00=conv 01=HMA dw 0 ; 0054 deblock buf in conv deblock_seg dw 0 ; 0056 (offset always zero) - times 3 db 0 ; 0058 unknown + times 3 db 0 ; 0058 unknown dw 0 ; 005B unknown db 0, 0FFh, 0 ; 005D unknown db 0 ; 0060 unknown dw 0 ; 0061 unknown -dmd_upper_link db 0 ; 0063 upper memory link flag - dw 0 ; 0064 unknown -dmd_upper_root dw 0FFFFh ; 0066 dmd_upper_root + global _uppermem_link +_uppermem_link db 0 ; 0063 upper memory link flag + global _UMB_top +_UMB_top dw 0 ; 0064 unknown UMB_top will do for now + global _uppermem_root +_uppermem_root dw 0FFFFh ; 0066 dmd_upper_root dw 0 ; 0068 para of last mem search SysVarEnd: @@ -471,15 +477,12 @@ _SAttr db 0 ;24D - Attribute Mask for Dir Search global _OpenMode _OpenMode db 0 ;24E - File Open Attribute -; times 3 db 0 -; global _Server_Call -;_Server_Call db 0 ;252 - Server call Func 5D sub 0 - - - ; Pad to 0570h - times (250h - ($ - _internal_data)) db 0 + times 3 db 0 + global _Server_Call +_Server_Call db 0 ;252 - Server call Func 5D sub 0 + db 0 global _lpUserStack -_lpUserStack dd 0 ;250 - pointer to user stack frame +_lpUserStack dd 0 ;254 - pointer to user stack frame ; Pad to 057Ch times (25ch - ($ - _internal_data)) db 0 diff --git a/kernel/main.c b/kernel/main.c index 573b3c23..c23bc6db 100644 --- a/kernel/main.c +++ b/kernel/main.c @@ -39,6 +39,9 @@ static BYTE *mainRcsId = "$Id$"; /* * $Log$ + * Revision 1.6 2000/06/21 18:16:46 jimtabor + * Add UMB code, patch, and code fixes + * * Revision 1.5 2000/05/26 19:25:19 jimtabor * Read History file for Change info * @@ -147,6 +150,8 @@ static BYTE *mainRcsId = "$Id$"; extern UWORD DaysSinceEpoch; extern WORD days[2][13]; +extern BYTE FAR * lpBase; +extern BYTE FAR * upBase; INIT BOOL ReadATClock(BYTE *, BYTE *, BYTE *, BYTE *); VOID FAR init_call_WritePCClock(ULONG); @@ -189,6 +194,8 @@ INIT static VOID init_kernel(void) /* Init oem hook - returns memory size in KB */ ram_top = init_oem(); + UMB_top = 3; /* testing for now* + /* Fake int 21h stack frame */ user_r = (iregs FAR *) DOS_PSP + 0xD0; @@ -359,7 +366,7 @@ INIT VOID FsConfig(VOID) default_drive = BootDrive - 1; /* Initialzie the current directory structures */ - for (i = 0; i < lastdrive + 1; i++) + for (i = 0; i < lastdrive ; i++) { fbcopy((VOID FAR *) "A:\\\0", @@ -427,14 +434,13 @@ INIT static VOID kernel() p_0(); } -extern BYTE FAR *lpBase; - /* If cmdLine is NULL, this is an internal driver */ -BOOL init_device(struct dhdr FAR * dhp, BYTE FAR * cmdLine) +BOOL init_device(struct dhdr FAR * dhp, BYTE FAR * cmdLine, COUNT mode, COUNT r_top) { request rq; - ULONG memtop = ((ULONG) ram_top) << 10; + + ULONG memtop = ((ULONG) r_top) << 10; ULONG maxmem = memtop - ((ULONG) FP_SEG(dhp) << 4); if (maxmem >= 0x10000) @@ -455,10 +461,14 @@ BOOL init_device(struct dhdr FAR * dhp, BYTE FAR * cmdLine) if (rq.r_status & S_ERROR) return TRUE; - if (cmdLine) - lpBase = rq.r_endaddr; + if(cmdLine){ + if (mode) + upBase = rq.r_endaddr; + else + lpBase = rq.r_endaddr; + } - /* check for a block device and update device control block */ +/* check for a block device and update device control block */ if (!(dhp->dh_attr & ATTR_CHAR) && (rq.r_nunits != 0)) { REG COUNT Index; @@ -497,9 +507,9 @@ INIT static void InitIO(void) /* Initialize driver chain */ nul_dev.dh_next = (struct dhdr FAR *)&con_dev; setvec(0x29, int29_handler); /* Requires Fast Con Driver */ - init_device((struct dhdr FAR *)&con_dev, NULL); - init_device((struct dhdr FAR *)&clk_dev, NULL); - init_device((struct dhdr FAR *)&blk_dev, NULL); + init_device((struct dhdr FAR *)&con_dev, NULL, NULL, ram_top); + init_device((struct dhdr FAR *)&clk_dev, NULL, NULL, ram_top); + init_device((struct dhdr FAR *)&blk_dev, NULL, NULL, ram_top); /* If AT clock exists, copy AT clock time to system clock */ if (!ReadATClock(bcd_days, &bcd_hours, &bcd_minutes, &bcd_seconds)) { diff --git a/kernel/memmgr.c b/kernel/memmgr.c index f5b26645..f80e8dc1 100644 --- a/kernel/memmgr.c +++ b/kernel/memmgr.c @@ -35,6 +35,9 @@ static BYTE *memmgrRcsId = "$Id$"; /* * $Log$ + * Revision 1.4 2000/06/21 18:16:46 jimtabor + * Add UMB code, patch, and code fixes + * * Revision 1.3 2000/05/25 20:56:21 jimtabor * Fixed project history * @@ -107,10 +110,10 @@ VOID show_chain(); #define para2far(seg) (mcb FAR *)MK_FP((seg) , 0) /* - * Join any following unused MCBs to MCB 'p'. - * Return: - * SUCCESS: on success - * else: error number <> + * Join any following unused MCBs to MCB 'p'. + * Return: + * SUCCESS: on success + * else: error number <> */ static COUNT joinMCBs(mcb FAR * p) { @@ -142,7 +145,7 @@ seg long2para(LONG size) } /* - * Add a displacement to a far pointer and return the result normalized. + * Add a displacement to a far pointer and return the result normalized. */ VOID FAR *add_far(VOID FAR * fp, ULONG off) { @@ -152,7 +155,7 @@ VOID FAR *add_far(VOID FAR * fp, ULONG off) } /* - * Return a normalized far pointer + * Return a normalized far pointer */ VOID FAR *adjust_far(VOID FAR * fp) { @@ -297,12 +300,12 @@ COUNT FAR init_call_DosMemAlloc(UWORD size, COUNT mode, seg FAR * para, UWORD FA } /* - * Unlike the name and the original prototype could suggest, this function - * is used to return the _size_ of the largest available block rather than - * the block itself. + * Unlike the name and the original prototype could suggest, this function + * is used to return the _size_ of the largest available block rather than + * the block itself. * - * Known bug: a memory area with a size of the data area of 0 (zero) is - * not considered a "largest" block. <> + * Known bug: a memory area with a size of the data area of 0 (zero) is + * not considered a "largest" block. <> */ COUNT DosMemLargest(UWORD FAR * size) { @@ -345,9 +348,9 @@ COUNT DosMemLargest(UWORD FAR * size) } /* - * Deallocate a memory block. para is the segment of the MCB itself - * This function can be called with para == 0, which eases other parts - * of the kernel. + * Deallocate a memory block. para is the segment of the MCB itself + * This function can be called with para == 0, which eases other parts + * of the kernel. */ COUNT DosMemFree(UWORD para) { @@ -400,12 +403,12 @@ COUNT DosMemFree(UWORD para) } /* - * Resize an allocated memory block. - * para is the segment of the data portion of the block rather than - * the segment of the MCB itself. + * Resize an allocated memory block. + * para is the segment of the data portion of the block rather than + * the segment of the MCB itself. * - * If the block shall grow, it is resized to the maximal size less than - * or equal to size. This is the way MS DOS is reported to work. + * If the block shall grow, it is resized to the maximal size less than + * or equal to size. This is the way MS DOS is reported to work. */ COUNT DosMemChange(UWORD para, UWORD size, UWORD * maxSize) { @@ -461,7 +464,7 @@ COUNT DosMemChange(UWORD para, UWORD size, UWORD * maxSize) } /* - * Check the MCB chain for allocation corruption + * Check the MCB chain for allocation corruption */ COUNT DosMemCheck(void) { diff --git a/kernel/network.c b/kernel/network.c index 6bfaa09e..3a433e9b 100644 --- a/kernel/network.c +++ b/kernel/network.c @@ -36,6 +36,9 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.6 2000/06/21 18:16:46 jimtabor + * Add UMB code, patch, and code fixes + * * Revision 1.5 2000/05/26 19:25:19 jimtabor * Read History file for Change info * @@ -112,7 +115,7 @@ UCOUNT Remote_RW(UWORD func, UCOUNT n, BYTE FAR * bp, sft FAR * s, COUNT FAR * e /* */ -COUNT Remote_find(UWORD func, UWORD attrib, BYTE FAR * name, REG dmatch FAR * dmp ) +COUNT Remote_find(UWORD func, BYTE FAR * name, REG dmatch FAR * dmp ) { COUNT i, x; char FAR *p, *q; @@ -142,7 +145,7 @@ COUNT Remote_find(UWORD func, UWORD attrib, BYTE FAR * name, REG dmatch FAR * dm dta = (BYTE FAR *) &TempBuffer; i = int2f_Remote_call(func, 0, 0, 0, test, 0, 0); dta = p; - fsncopy((BYTE FAR *) &TempBuffer[0], &dta[0], 21); + fsncopy((BYTE FAR *) &TempBuffer, dta, 21); if (i != 0) return i; diff --git a/kernel/newstuff.c b/kernel/newstuff.c index 24543594..c5e2bd77 100644 --- a/kernel/newstuff.c +++ b/kernel/newstuff.c @@ -31,6 +31,9 @@ static BYTE *mainRcsId = "$Id$"; /* * $Log$ + * Revision 1.7 2000/06/21 18:16:46 jimtabor + * Add UMB code, patch, and code fixes + * * Revision 1.6 2000/06/01 06:37:38 jimtabor * Read History for Changes * @@ -214,7 +217,7 @@ COUNT get_verify_drive(char FAR *src) } else drive = default_drive; - if ((drive < 0) || (drive > lastdrive)) { + if ((drive < 0) || (drive > (lastdrive - 1))) { drive = DE_INVLDDRV; } return drive; @@ -248,7 +251,7 @@ COUNT truename(char FAR * src, char FAR * dest, COUNT t) { buf[0] = (src[0] | 0x20) + 'A' - 'a'; - if (buf[0] > lastdrive + 'A') + if (buf[0] > (lastdrive - 1) + 'A') return DE_PATHNOTFND; src += 2; diff --git a/kernel/proto.h b/kernel/proto.h index c5b9193c..cb3b9fda 100644 --- a/kernel/proto.h +++ b/kernel/proto.h @@ -34,6 +34,9 @@ static BYTE *Proto_hRcsId = "$Id$"; /* * $Log$ + * Revision 1.5 2000/06/21 18:16:46 jimtabor + * Add UMB code, patch, and code fixes + * * Revision 1.4 2000/05/26 19:25:19 jimtabor * Read History file for Change info * @@ -186,6 +189,7 @@ INIT BYTE *GetNumber(REG BYTE * pszString, REG COUNT * pnNum); INIT COUNT tolower(COUNT c); INIT COUNT toupper(COUNT c); INIT VOID mcb_init(mcb FAR * mcbp, UWORD size); +INIT VOID umcb_init(mcb FAR * mcbp, UWORD size); INIT VOID strcat(REG BYTE * d, REG BYTE * s); /* dosfns.c */ @@ -354,7 +358,7 @@ COUNT DosDevIOctl(iregs FAR * r, COUNT FAR * err); /* main.c */ INIT VOID main(void); -INIT BOOL init_device(struct dhdr FAR * dhp, BYTE FAR * cmdLine); +INIT BOOL init_device(struct dhdr FAR * dhp, BYTE FAR * cmdLine, COUNT mode, COUNT top); /* memmgr.c */ seg far2para(VOID FAR * p); @@ -459,7 +463,7 @@ COUNT QRemote_Fn(char FAR * s, char FAR * d); UWORD get_machine_name(BYTE FAR * netname); VOID set_machine_name(BYTE FAR * netname, UWORD name_num); UCOUNT Remote_RW(UWORD func, UCOUNT n, BYTE FAR * bp, sft FAR * s, COUNT FAR * err); -COUNT Remote_find(UWORD func, UWORD attrib, BYTE FAR * name, REG dmatch FAR * dmp); +COUNT Remote_find(UWORD func, BYTE FAR * name, REG dmatch FAR * dmp); /* procsupt.asm */ VOID INRPT FAR exec_user(iregs FAR * irp); From b6355f4e8bc8187fed6d134d3b9707955b7388d6 Mon Sep 17 00:00:00 2001 From: Jim Tabor Date: Fri, 23 Jun 2000 03:17:29 +0000 Subject: [PATCH 022/671] Add UMB code, patch, and code fixes git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@33 6ac86273-5f31-0410-b378-82cca8765d1b --- docs/history.txt | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/docs/history.txt b/docs/history.txt index e313cc7d..054f0616 100644 --- a/docs/history.txt +++ b/docs/history.txt @@ -1,3 +1,31 @@ +2000 Jun 20 - Build 2021 +-------- James Tabor (jimtabor@infohwy.com) ++ Fix Bart Oldeman (Bart.Oldeman@bristol.ac.uk) found bugs with copy + command using Dosemu Lredir. Fixed Dosfns return for ReadCount, + WriteCount and DosGetFattr. Fixed the return in int2f.asm for + Read/Write Remote. By adding xor ax,ax. + I found some more return bugs in int2f.asm after adding Barts + patch. + +2000 Jun 08 - Build 2021 +-------- James Tabor (jimtabor@infohwy.com) ++ Add Started the UMB code. Devicehigh and dos=umb only works with + Dosemu for now. + +2000 Jun 07 - Build 2021 +-------- James Tabor (jimtabor@infohwy.com) ++ Add Int2f added code for Fastopen call. + Now MSD Scandisk works! + +2000 Jun 06 - Build 2021 +-------- James Tabor (jimtabor@infohwy.com) ++ Add Dos Func 0x59 and found a redirector bug in fncfns.c. + +2000 Jun 01 - Build 2021 +-------- James Tabor (jimtabor@infohwy.com) ++ Fix Lastdrive is a real number 1 thru 26 not 0 thru 25. ++ Fix Ioctl and Dsk did not return the currect AX for Ioctl calls. + 2000 Jun 01 - Build 2021 -------- James Tabor (jimtabor@infohwy.com) + Clean Removed test prinf statements in source. From c0df6767f2ced74f1f7c0cd1b37c5f77bb48064e Mon Sep 17 00:00:00 2001 From: Jim Tabor Date: Sun, 6 Aug 2000 04:14:05 +0000 Subject: [PATCH 023/671] Add new nls patch git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@56 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/nls/001-437.hc | 109 ++++++++++++++++++++++++++++++++++ kernel/nls/001-437.unf | 130 +++++++++++++++++++++++++++++++++++++++++ kernel/nls/001-437.up | Bin 0 -> 254 bytes kernel/nls/049-850.hc | 109 ++++++++++++++++++++++++++++++++++ kernel/nls/049-850.unf | 130 +++++++++++++++++++++++++++++++++++++++++ kernel/nls/049-850.up | Bin 0 -> 254 bytes kernel/nls/files | 20 +++++++ 7 files changed, 498 insertions(+) create mode 100644 kernel/nls/001-437.hc create mode 100644 kernel/nls/001-437.unf create mode 100644 kernel/nls/001-437.up create mode 100644 kernel/nls/049-850.hc create mode 100644 kernel/nls/049-850.unf create mode 100644 kernel/nls/049-850.up create mode 100644 kernel/nls/files diff --git a/kernel/nls/001-437.hc b/kernel/nls/001-437.hc new file mode 100644 index 00000000..087c9e73 --- /dev/null +++ b/kernel/nls/001-437.hc @@ -0,0 +1,109 @@ +; Hardcoded DOS-NLS information for country = 1, codepage = 437 +; This is an automatically generated file! +; Any modifications will be lost! + +; Prerequisites: +;; ==> Assuming that data of tables remains constant all the time +;; ==> Reordering tables 1, 2, 4 and 5 + + %include "segs.inc" +segment _DATA + + GLOBAL _nlsPackageHardcoded +_nlsPackageHardcoded: + DB 000h, 000h, 000h, 000h, 001h, 000h, 0b5h, 001h + DB 00fh, 000h, 059h, 04eh, 006h, 000h + DB 002h + DW ?table2, SEG ?table2 + DB 004h + DW ?table4, SEG ?table4 + DB 005h + DW ?table5, SEG ?table5 + DB 006h + DW ?table6, SEG ?table6 + DB 007h + DW ?table7, SEG ?table7 + GLOBAL _nlsCountryInfoHardcoded +_nlsCountryInfoHardcoded: + DB 001h +?table1: + DB 01ch, 000h, 001h, 000h, 0b5h, 001h, 000h, 000h + DB 024h, 000h, 000h, 000h, 000h, 02ch, 000h, 02eh + DB 000h, 02dh, 000h, 03ah, 000h, 000h, 002h, 000h + DB 0e8h, 058h, 000h, 000h, 02ch, 000h + GLOBAL _hcTablesStart +_hcTablesStart: + GLOBAL _nlsFUpcaseHardcoded +_nlsFUpcaseHardcoded: +?table4: + GLOBAL _nlsUpcaseHardcoded +_nlsUpcaseHardcoded: +?table2: + DB 080h, 000h, 080h, 09ah, 045h, 041h, 08eh, 041h + DB 08fh, 080h, 045h, 045h, 045h, 049h, 049h, 049h + DB 08eh, 08fh, 090h, 092h, 092h, 04fh, 099h, 04fh + DB 055h, 055h, 059h, 099h, 09ah, 09bh, 09ch, 09dh + DB 09eh, 09fh, 041h, 049h, 04fh, 055h, 0a5h, 0a5h + DB 0a6h, 0a7h, 0a8h, 0a9h, 0aah, 0abh, 0ach, 0adh + DB 0aeh, 0afh, 0b0h, 0b1h, 0b2h, 0b3h, 0b4h, 0b5h + DB 0b6h, 0b7h, 0b8h, 0b9h, 0bah, 0bbh, 0bch, 0bdh + DB 0beh, 0bfh, 0c0h, 0c1h, 0c2h, 0c3h, 0c4h, 0c5h + DB 0c6h, 0c7h, 0c8h, 0c9h, 0cah, 0cbh, 0cch, 0cdh + DB 0ceh, 0cfh, 0d0h, 0d1h, 0d2h, 0d3h, 0d4h, 0d5h + DB 0d6h, 0d7h, 0d8h, 0d9h, 0dah, 0dbh, 0dch, 0ddh + DB 0deh, 0dfh, 0e0h, 0e1h, 0e2h, 0e3h, 0e4h, 0e5h + DB 0e6h, 0e7h, 0e8h, 0e9h, 0eah, 0ebh, 0ech, 0edh + DB 0eeh, 0efh, 0f0h, 0f1h, 0f2h, 0f3h, 0f4h, 0f5h + DB 0f6h, 0f7h, 0f8h, 0f9h, 0fah, 0fbh, 0fch, 0fdh + DB 0feh, 0ffh + GLOBAL _nlsFnameTermHardcoded +_nlsFnameTermHardcoded: +?table5: + DB 016h, 000h, 08eh, 000h, 0ffh, 041h, 000h, 020h + DB 0eeh, 00eh, 02eh, 022h, 02fh, 05ch, 05bh, 05dh + DB 03ah, 07ch, 03ch, 03eh, 02bh, 03dh, 03bh, 02ch + GLOBAL _nlsCollHardcoded +_nlsCollHardcoded: +?table6: + DB 000h, 001h, 000h, 001h, 002h, 003h, 004h, 005h + DB 006h, 007h, 008h, 009h, 00ah, 00bh, 00ch, 00dh + DB 00eh, 00fh, 010h, 011h, 012h, 013h, 014h, 015h + DB 016h, 017h, 018h, 019h, 01ah, 01bh, 01ch, 01dh + DB 01eh, 01fh, 020h, 021h, 022h, 023h, 024h, 025h + DB 026h, 027h, 028h, 029h, 02ah, 02bh, 02ch, 02dh + DB 02eh, 02fh, 030h, 031h, 032h, 033h, 034h, 035h + DB 036h, 037h, 038h, 039h, 03ah, 03bh, 03ch, 03dh + DB 03eh, 03fh, 040h, 041h, 042h, 043h, 044h, 045h + DB 046h, 047h, 048h, 049h, 04ah, 04bh, 04ch, 04dh + DB 04eh, 04fh, 050h, 051h, 052h, 053h, 054h, 055h + DB 056h, 057h, 058h, 059h, 05ah, 05bh, 05ch, 05dh + DB 05eh, 05fh, 060h, 041h, 042h, 043h, 044h, 045h + DB 046h, 047h, 048h, 049h, 04ah, 04bh, 04ch, 04dh + DB 04eh, 04fh, 050h, 051h, 052h, 053h, 054h, 055h + DB 056h, 057h, 058h, 059h, 05ah, 07bh, 07ch, 07dh + DB 07eh, 07fh, 043h, 055h, 045h, 041h, 041h, 041h + DB 041h, 043h, 045h, 045h, 045h, 049h, 049h, 049h + DB 041h, 041h, 045h, 041h, 041h, 04fh, 04fh, 04fh + DB 055h, 055h, 059h, 04fh, 055h, 024h, 024h, 024h + DB 024h, 024h, 041h, 049h, 04fh, 055h, 04eh, 04eh + DB 0a6h, 0a7h, 03fh, 0a9h, 0aah, 0abh, 0ach, 021h + DB 022h, 022h, 0b0h, 0b1h, 0b2h, 0b3h, 0b4h, 0b5h + DB 0b6h, 0b7h, 0b8h, 0b9h, 0bah, 0bbh, 0bch, 0bdh + DB 0beh, 0bfh, 0c0h, 0c1h, 0c2h, 0c3h, 0c4h, 0c5h + DB 0c6h, 0c7h, 0c8h, 0c9h, 0cah, 0cbh, 0cch, 0cdh + DB 0ceh, 0cfh, 0d0h, 0d1h, 0d2h, 0d3h, 0d4h, 0d5h + DB 0d6h, 0d7h, 0d8h, 0d9h, 0dah, 0dbh, 0dch, 0ddh + DB 0deh, 0dfh, 0e0h, 053h, 0e2h, 0e3h, 0e4h, 0e5h + DB 0e6h, 0e7h, 0e8h, 0e9h, 0eah, 0ebh, 0ech, 0edh + DB 0eeh, 0efh, 0f0h, 0f1h, 0f2h, 0f3h, 0f4h, 0f5h + DB 0f6h, 0f7h, 0f8h, 0f9h, 0fah, 0fbh, 0fch, 0fdh + DB 0feh, 0ffh + GLOBAL _nlsDBCSHardcoded +_nlsDBCSHardcoded: +?table7: + DB 000h, 000h, 000h, 000h + GLOBAL _hcTablesEnd +_hcTablesEnd: + + +END diff --git a/kernel/nls/001-437.unf b/kernel/nls/001-437.unf new file mode 100644 index 00000000..881dcfe0 --- /dev/null +++ b/kernel/nls/001-437.unf @@ -0,0 +1,130 @@ +## Universal NLS data Format file: 001-437.unf +$country 1 +$codepage 437 + +# Global options +$radix 10 + + +[table 1] # Extended Country Information DOS-65-01 / DOS-38 +$make_size + = W1 W437 # Country ID & Codepage + = W0 # Date format: 0/1/2: U.S.A./Europe/Japan + = 36 0 0 0 0 # $.... # Currency string + = 44 0 # ,. # Thousand's separator + = 46 0 # .. # Decimal point + = 45 0 # -. # Date separator + = 58 0 # :. # Time separator + = 0 # Currency format (bit array) + = 2 # Currency precision + = 0 # time format: 0/1: 12/24 houres +$go_forward 4 # Far address of upcase function (to be calc at runtime) + = 44 0 # ,. # Data separator + + +[table 2] # normal character uppercase table +$make_size + + = 128 154 69 65 142 65 143 128 # €šEAŽA€ @ 0 + = 69 69 69 73 73 73 142 143 # EEEIIIŽ @ 8 + = 144 146 146 79 153 79 85 85 # ’’O™OUU @ 16 + = 89 153 154 155 156 157 158 159 # Y™š›œžŸ @ 24 + = 65 73 79 85 165 165 166 167 # AIOU¥¥¦§ @ 32 + = 168 169 170 171 172 173 174 175 # ¨©ª«¬­®¯ @ 40 + = 176 177 178 179 180 181 182 183 # °±²³´µ¶· @ 48 + = 184 185 186 187 188 189 190 191 # ¸¹º»¼½¾¿ @ 56 + = 192 193 194 195 196 197 198 199 # ÀÁÂÃÄÅÆÇ @ 64 + = 200 201 202 203 204 205 206 207 # ÈÉÊËÌÍÎÏ @ 72 + = 208 209 210 211 212 213 214 215 # ÐÑÒÓÔÕÖ× @ 80 + = 216 217 218 219 220 221 222 223 # ØÙÚÛÜÝÞß @ 88 + = 224 225 226 227 228 229 230 231 # àáâãäåæç @ 96 + = 232 233 234 235 236 237 238 239 # èéêëìíîï @ 104 + = 240 241 242 243 244 245 246 247 # ðñòóôõö÷ @ 112 + = 248 249 250 251 252 253 254 255 # øùúûüýþÿ @ 120 +$is_offset 128 + + +[table 4] # filename character uppercase table +$make_size + + = 128 154 69 65 142 65 143 128 # €šEAŽA€ @ 0 + = 69 69 69 73 73 73 142 143 # EEEIIIŽ @ 8 + = 144 146 146 79 153 79 85 85 # ’’O™OUU @ 16 + = 89 153 154 155 156 157 158 159 # Y™š›œžŸ @ 24 + = 65 73 79 85 165 165 166 167 # AIOU¥¥¦§ @ 32 + = 168 169 170 171 172 173 174 175 # ¨©ª«¬­®¯ @ 40 + = 176 177 178 179 180 181 182 183 # °±²³´µ¶· @ 48 + = 184 185 186 187 188 189 190 191 # ¸¹º»¼½¾¿ @ 56 + = 192 193 194 195 196 197 198 199 # ÀÁÂÃÄÅÆÇ @ 64 + = 200 201 202 203 204 205 206 207 # ÈÉÊËÌÍÎÏ @ 72 + = 208 209 210 211 212 213 214 215 # ÐÑÒÓÔÕÖ× @ 80 + = 216 217 218 219 220 221 222 223 # ØÙÚÛÜÝÞß @ 88 + = 224 225 226 227 228 229 230 231 # àáâãäåæç @ 96 + = 232 233 234 235 236 237 238 239 # èéêëìíîï @ 104 + = 240 241 242 243 244 245 246 247 # ðñòóôõö÷ @ 112 + = 248 249 250 251 252 253 254 255 # øùúûüýþÿ @ 120 +$is_offset 128 + + +[table 5] # Filename Termination Characters +$make_size +$go_forward 1 # skip one dummy byte + = 0 255 # Permittable characters +$go_forward 1 # skip one dummy byte + = 0 32 # Excluded characters (from above range) +$go_forward 1 # skip one dummy byte + = 14 # Number of enumerated excluded characters + + = 46 34 47 92 91 93 58 124 # ."/\[]:| @ 0 + = 60 62 43 61 59 44 # <>+=;, @ 8 +$is_offset 22 + + +[table 6] # collating sequence table +$make_size + + = 0 1 2 3 4 5 6 7 # ........ @ 0 + = 8 9 10 11 12 13 14 15 # ........ @ 8 + = 16 17 18 19 20 21 22 23 # ........ @ 16 + = 24 25 26 27 28 29 30 31 # ........ @ 24 + = 32 33 34 35 36 37 38 39 # !"#$%&' @ 32 + = 40 41 42 43 44 45 46 47 # ()*+,-./ @ 40 + = 48 49 50 51 52 53 54 55 # 01234567 @ 48 + = 56 57 58 59 60 61 62 63 # 89:;<=>? @ 56 + = 64 65 66 67 68 69 70 71 # @ABCDEFG @ 64 + = 72 73 74 75 76 77 78 79 # HIJKLMNO @ 72 + = 80 81 82 83 84 85 86 87 # PQRSTUVW @ 80 + = 88 89 90 91 92 93 94 95 # XYZ[\]^_ @ 88 + = 96 65 66 67 68 69 70 71 # `ABCDEFG @ 96 + = 72 73 74 75 76 77 78 79 # HIJKLMNO @ 104 + = 80 81 82 83 84 85 86 87 # PQRSTUVW @ 112 + = 88 89 90 123 124 125 126 127 # XYZ{|}~. @ 120 + = 67 85 69 65 65 65 65 67 # CUEAAAAC @ 128 + = 69 69 69 73 73 73 65 65 # EEEIIIAA @ 136 + = 69 65 65 79 79 79 85 85 # EAAOOOUU @ 144 + = 89 79 85 36 36 36 36 36 # YOU$$$$$ @ 152 + = 65 73 79 85 78 78 166 167 # AIOUNN¦§ @ 160 + = 63 169 170 171 172 33 34 34 # ?©ª«¬!"" @ 168 + = 176 177 178 179 180 181 182 183 # °±²³´µ¶· @ 176 + = 184 185 186 187 188 189 190 191 # ¸¹º»¼½¾¿ @ 184 + = 192 193 194 195 196 197 198 199 # ÀÁÂÃÄÅÆÇ @ 192 + = 200 201 202 203 204 205 206 207 # ÈÉÊËÌÍÎÏ @ 200 + = 208 209 210 211 212 213 214 215 # ÐÑÒÓÔÕÖ× @ 208 + = 216 217 218 219 220 221 222 223 # ØÙÚÛÜÝÞß @ 216 + = 224 83 226 227 228 229 230 231 # àSâãäåæç @ 224 + = 232 233 234 235 236 237 238 239 # èéêëìíîï @ 232 + = 240 241 242 243 244 245 246 247 # ðñòóôõö÷ @ 240 + = 248 249 250 251 252 253 254 255 # øùúûüýþÿ @ 248 +$is_offset 256 + + +[table 7] # Double Byte Character Support (DBCS) +$make_size +$stop_size + = W0 # DBCS end marker (mandotary) + + +[table 35] # Extended Country Information DOS-65-23 + = 89 78 # YN # Yes & No character + + diff --git a/kernel/nls/001-437.up b/kernel/nls/001-437.up new file mode 100644 index 0000000000000000000000000000000000000000..8981596bb741b6d2413c2aa81e49868016956edd GIT binary patch literal 254 zcmZQzWMXDvWn<^y zVdJLFTefc7zGLUE-Fx=#+kfETp~FXx9y@;GWe&gn?+js8X qyZ_+fqsLF4K70P+<*V0k-oAVP;p3;zU%r0({^RGb-+%u8`wsx0&UZ=x literal 0 HcmV?d00001 diff --git a/kernel/nls/049-850.hc b/kernel/nls/049-850.hc new file mode 100644 index 00000000..aa4a6f9a --- /dev/null +++ b/kernel/nls/049-850.hc @@ -0,0 +1,109 @@ +; Hardcoded DOS-NLS information for country = 49, codepage = 850 +; This is an automatically generated file! +; Any modifications will be lost! + +; Prerequisites: +;; ==> Assuming that data of tables remains constant all the time +;; ==> Reordering tables 1, 2, 4 and 5 + + %include "segs.inc" +segment _DATA + + GLOBAL _nlsPackageHardcoded +_nlsPackageHardcoded: + DB 000h, 000h, 000h, 000h, 031h, 000h, 052h, 003h + DB 00fh, 000h, 04ah, 04eh, 006h, 000h + DB 002h + DW ?table2, SEG ?table2 + DB 004h + DW ?table4, SEG ?table4 + DB 005h + DW ?table5, SEG ?table5 + DB 006h + DW ?table6, SEG ?table6 + DB 007h + DW ?table7, SEG ?table7 + GLOBAL _nlsCountryInfoHardcoded +_nlsCountryInfoHardcoded: + DB 001h +?table1: + DB 01ch, 000h, 031h, 000h, 052h, 003h, 001h, 000h + DB 044h, 04dh, 000h, 000h, 000h, 02eh, 000h, 02ch + DB 000h, 02eh, 000h, 03ah, 000h, 003h, 002h, 001h + DB 0e8h, 058h, 000h, 003h, 03bh, 000h + GLOBAL _hcTablesStart +_hcTablesStart: + GLOBAL _nlsFUpcaseHardcoded +_nlsFUpcaseHardcoded: +?table4: + GLOBAL _nlsUpcaseHardcoded +_nlsUpcaseHardcoded: +?table2: + DB 080h, 000h, 080h, 09ah, 090h, 0b6h, 08eh, 0b7h + DB 08fh, 080h, 0d2h, 0d3h, 0d4h, 0d8h, 0d7h, 0deh + DB 08eh, 08fh, 090h, 092h, 092h, 0e2h, 099h, 0e3h + DB 0eah, 0ebh, 05fh, 099h, 09ah, 09dh, 09ch, 09dh + DB 09eh, 09fh, 0b5h, 0d6h, 0e0h, 0e9h, 0a5h, 0a5h + DB 0a6h, 0a7h, 0a8h, 0a9h, 0aah, 0abh, 0ach, 0adh + DB 0aeh, 0afh, 0b0h, 0b1h, 0b2h, 0b3h, 0b4h, 0b5h + DB 0b6h, 0b7h, 0b8h, 0b9h, 0bah, 0bbh, 0bch, 0bdh + DB 0beh, 0bfh, 0c0h, 0c1h, 0c2h, 0c3h, 0c4h, 0c5h + DB 0c7h, 0c7h, 0c8h, 0c9h, 0cah, 0cbh, 0cch, 0cdh + DB 0ceh, 0cfh, 0d1h, 0d1h, 0d2h, 0d3h, 0d4h, 049h + DB 0d6h, 0d7h, 0d8h, 0d9h, 0dah, 0dbh, 0dch, 0ddh + DB 0deh, 0dfh, 0e0h, 0e1h, 0e2h, 0e3h, 0e5h, 0e5h + DB 0e6h, 0e8h, 0e8h, 0e9h, 0eah, 0ebh, 0edh, 0edh + DB 0eeh, 0efh, 0f0h, 0f1h, 0f2h, 0f3h, 0f4h, 0f5h + DB 0f6h, 0f7h, 0f8h, 0f9h, 0fah, 0fbh, 0fch, 0fdh + DB 0feh, 0ffh + GLOBAL _nlsFnameTermHardcoded +_nlsFnameTermHardcoded: +?table5: + DB 016h, 000h, 08eh, 000h, 0ffh, 0b6h, 000h, 020h + DB 0eeh, 00eh, 02eh, 022h, 02fh, 05ch, 05bh, 05dh + DB 03ah, 07ch, 03ch, 03eh, 02bh, 03dh, 03bh, 02ch + GLOBAL _nlsCollHardcoded +_nlsCollHardcoded: +?table6: + DB 000h, 001h, 000h, 001h, 002h, 003h, 004h, 005h + DB 006h, 007h, 008h, 009h, 00ah, 00bh, 00ch, 00dh + DB 00eh, 00fh, 010h, 011h, 012h, 013h, 014h, 015h + DB 016h, 017h, 018h, 019h, 01ah, 01bh, 01ch, 01dh + DB 01eh, 01fh, 020h, 021h, 022h, 023h, 024h, 025h + DB 026h, 027h, 028h, 029h, 02ah, 02bh, 02ch, 02dh + DB 02eh, 02fh, 030h, 031h, 032h, 033h, 034h, 035h + DB 036h, 037h, 038h, 039h, 03ah, 03bh, 03ch, 03dh + DB 03eh, 03fh, 040h, 041h, 042h, 043h, 044h, 045h + DB 046h, 047h, 048h, 049h, 04ah, 04bh, 04ch, 04dh + DB 04eh, 04fh, 050h, 051h, 052h, 053h, 054h, 055h + DB 056h, 057h, 058h, 059h, 05ah, 05bh, 05ch, 05dh + DB 05eh, 05fh, 060h, 041h, 042h, 043h, 044h, 045h + DB 046h, 047h, 048h, 049h, 04ah, 04bh, 04ch, 04dh + DB 04eh, 04fh, 050h, 051h, 052h, 053h, 054h, 055h + DB 056h, 057h, 058h, 059h, 05ah, 07bh, 07ch, 07dh + DB 07eh, 07fh, 043h, 055h, 045h, 041h, 041h, 041h + DB 041h, 043h, 045h, 045h, 045h, 049h, 049h, 049h + DB 041h, 041h, 045h, 041h, 041h, 04fh, 04fh, 04fh + DB 055h, 055h, 059h, 04fh, 055h, 04fh, 024h, 04fh + DB 09eh, 024h, 041h, 049h, 04fh, 055h, 04eh, 04eh + DB 0a6h, 0a7h, 03fh, 0a9h, 0aah, 0abh, 0ach, 021h + DB 022h, 022h, 0b0h, 0b1h, 0b2h, 0b3h, 0b4h, 041h + DB 041h, 041h, 0b8h, 0b9h, 0bah, 0bbh, 0bch, 024h + DB 024h, 0bfh, 0c0h, 0c1h, 0c2h, 0c3h, 0c4h, 0c5h + DB 041h, 041h, 0c8h, 0c9h, 0cah, 0cbh, 0cch, 0cdh + DB 0ceh, 024h, 044h, 044h, 045h, 045h, 045h, 049h + DB 049h, 049h, 049h, 0d9h, 0dah, 0dbh, 0dch, 0ddh + DB 049h, 0dfh, 04fh, 053h, 04fh, 04fh, 04fh, 04fh + DB 0e6h, 0e8h, 0e8h, 055h, 055h, 055h, 059h, 059h + DB 0eeh, 0efh, 0f0h, 0f1h, 0f2h, 0f3h, 0f4h, 0f5h + DB 0f6h, 0f7h, 0f8h, 0f9h, 0fah, 0fbh, 0fch, 0fdh + DB 0feh, 0ffh + GLOBAL _nlsDBCSHardcoded +_nlsDBCSHardcoded: +?table7: + DB 000h, 000h, 000h, 000h + GLOBAL _hcTablesEnd +_hcTablesEnd: + + +END diff --git a/kernel/nls/049-850.unf b/kernel/nls/049-850.unf new file mode 100644 index 00000000..fd44a35a --- /dev/null +++ b/kernel/nls/049-850.unf @@ -0,0 +1,130 @@ +## Universal NLS data Format file: 049-850.unf +$country 49 +$codepage 850 + +# Global options +$radix 10 + + +[table 1] # Extended Country Information DOS-65-01 / DOS-38 +$make_size + = W49 W850 # Country ID & Codepage + = W1 # Date format: 0/1/2: U.S.A./Europe/Japan + = 68 77 0 0 0 # DM... # Currency string + = 46 0 # .. # Thousand's separator + = 44 0 # ,. # Decimal point + = 46 0 # .. # Date separator + = 58 0 # :. # Time separator + = 3 # Currency format (bit array) + = 2 # Currency precision + = 1 # time format: 0/1: 12/24 houres +$go_forward 4 # Far address of upcase function (to be calc at runtime) + = 59 0 # ;. # Data separator + + +[table 2] # normal character uppercase table +$make_size + + = 128 154 144 182 142 183 143 128 # €š¶Ž·€ @ 0 + = 210 211 212 216 215 222 142 143 # ÒÓÔØ×ÞŽ @ 8 + = 144 146 146 226 153 227 234 235 # ’’â™ãêë @ 16 + = 95 153 154 157 156 157 158 159 # _™šœžŸ @ 24 + = 181 214 224 233 165 165 166 167 # µÖà饥¦§ @ 32 + = 168 169 170 171 172 173 174 175 # ¨©ª«¬­®¯ @ 40 + = 176 177 178 179 180 181 182 183 # °±²³´µ¶· @ 48 + = 184 185 186 187 188 189 190 191 # ¸¹º»¼½¾¿ @ 56 + = 192 193 194 195 196 197 199 199 # ÀÁÂÃÄÅÇÇ @ 64 + = 200 201 202 203 204 205 206 207 # ÈÉÊËÌÍÎÏ @ 72 + = 209 209 210 211 212 73 214 215 # ÑÑÒÓÔIÖ× @ 80 + = 216 217 218 219 220 221 222 223 # ØÙÚÛÜÝÞß @ 88 + = 224 225 226 227 229 229 230 232 # àáâãååæè @ 96 + = 232 233 234 235 237 237 238 239 # èéêëííîï @ 104 + = 240 241 242 243 244 245 246 247 # ðñòóôõö÷ @ 112 + = 248 249 250 251 252 253 254 255 # øùúûüýþÿ @ 120 +$is_offset 128 + + +[table 4] # filename character uppercase table +$make_size + + = 128 154 144 182 142 183 143 128 # €š¶Ž·€ @ 0 + = 210 211 212 216 215 222 142 143 # ÒÓÔØ×ÞŽ @ 8 + = 144 146 146 226 153 227 234 235 # ’’â™ãêë @ 16 + = 95 153 154 157 156 157 158 159 # _™šœžŸ @ 24 + = 181 214 224 233 165 165 166 167 # µÖà饥¦§ @ 32 + = 168 169 170 171 172 173 174 175 # ¨©ª«¬­®¯ @ 40 + = 176 177 178 179 180 181 182 183 # °±²³´µ¶· @ 48 + = 184 185 186 187 188 189 190 191 # ¸¹º»¼½¾¿ @ 56 + = 192 193 194 195 196 197 199 199 # ÀÁÂÃÄÅÇÇ @ 64 + = 200 201 202 203 204 205 206 207 # ÈÉÊËÌÍÎÏ @ 72 + = 209 209 210 211 212 73 214 215 # ÑÑÒÓÔIÖ× @ 80 + = 216 217 218 219 220 221 222 223 # ØÙÚÛÜÝÞß @ 88 + = 224 225 226 227 229 229 230 232 # àáâãååæè @ 96 + = 232 233 234 235 237 237 238 239 # èéêëííîï @ 104 + = 240 241 242 243 244 245 246 247 # ðñòóôõö÷ @ 112 + = 248 249 250 251 252 253 254 255 # øùúûüýþÿ @ 120 +$is_offset 128 + + +[table 5] # Filename Termination Characters +$make_size +$go_forward 1 # skip one dummy byte + = 0 255 # Permittable characters +$go_forward 1 # skip one dummy byte + = 0 32 # Excluded characters (from above range) +$go_forward 1 # skip one dummy byte + = 14 # Number of enumerated excluded characters + + = 46 34 47 92 91 93 58 124 # ."/\[]:| @ 0 + = 60 62 43 61 59 44 # <>+=;, @ 8 +$is_offset 22 + + +[table 6] # collating sequence table +$make_size + + = 0 1 2 3 4 5 6 7 # ........ @ 0 + = 8 9 10 11 12 13 14 15 # ........ @ 8 + = 16 17 18 19 20 21 22 23 # ........ @ 16 + = 24 25 26 27 28 29 30 31 # ........ @ 24 + = 32 33 34 35 36 37 38 39 # !"#$%&' @ 32 + = 40 41 42 43 44 45 46 47 # ()*+,-./ @ 40 + = 48 49 50 51 52 53 54 55 # 01234567 @ 48 + = 56 57 58 59 60 61 62 63 # 89:;<=>? @ 56 + = 64 65 66 67 68 69 70 71 # @ABCDEFG @ 64 + = 72 73 74 75 76 77 78 79 # HIJKLMNO @ 72 + = 80 81 82 83 84 85 86 87 # PQRSTUVW @ 80 + = 88 89 90 91 92 93 94 95 # XYZ[\]^_ @ 88 + = 96 65 66 67 68 69 70 71 # `ABCDEFG @ 96 + = 72 73 74 75 76 77 78 79 # HIJKLMNO @ 104 + = 80 81 82 83 84 85 86 87 # PQRSTUVW @ 112 + = 88 89 90 123 124 125 126 127 # XYZ{|}~. @ 120 + = 67 85 69 65 65 65 65 67 # CUEAAAAC @ 128 + = 69 69 69 73 73 73 65 65 # EEEIIIAA @ 136 + = 69 65 65 79 79 79 85 85 # EAAOOOUU @ 144 + = 89 79 85 79 36 79 158 36 # YOUO$Ož$ @ 152 + = 65 73 79 85 78 78 166 167 # AIOUNN¦§ @ 160 + = 63 169 170 171 172 33 34 34 # ?©ª«¬!"" @ 168 + = 176 177 178 179 180 65 65 65 # °±²³´AAA @ 176 + = 184 185 186 187 188 36 36 191 # ¸¹º»¼$$¿ @ 184 + = 192 193 194 195 196 197 65 65 # ÀÁÂÃÄÅAA @ 192 + = 200 201 202 203 204 205 206 36 # ÈÉÊËÌÍÎ$ @ 200 + = 68 68 69 69 69 73 73 73 # DDEEEIII @ 208 + = 73 217 218 219 220 221 73 223 # IÙÚÛÜÝIß @ 216 + = 79 83 79 79 79 79 230 232 # OSOOOOæè @ 224 + = 232 85 85 85 89 89 238 239 # èUUUYYîï @ 232 + = 240 241 242 243 244 245 246 247 # ðñòóôõö÷ @ 240 + = 248 249 250 251 252 253 254 255 # øùúûüýþÿ @ 248 +$is_offset 256 + + +[table 7] # Double Byte Character Support (DBCS) +$make_size +$stop_size + = W0 # DBCS end marker (mandotary) + + +[table 35] # Extended Country Information DOS-65-23 + = 74 78 # JN # Yes & No character + + diff --git a/kernel/nls/049-850.up b/kernel/nls/049-850.up new file mode 100644 index 0000000000000000000000000000000000000000..7a51fe8f14b1bf60bb989f04f0779d55bf083879 GIT binary patch literal 254 zcmZQzWMXDvWn<^y$L|jmo8nle8tLDtJkbu zw|>LMO`ErD-L`$l&Rx6r?A^Ejz`;X@j~qRI{KUyqr_Y={cmCo-L?y r_wGM<_~`M|r_Wxzc=_t}+qduDfB5+6^OvvRzW@07>-V3(|Na92a8`fS literal 0 HcmV?d00001 diff --git a/kernel/nls/files b/kernel/nls/files new file mode 100644 index 00000000..3a662d5f --- /dev/null +++ b/kernel/nls/files @@ -0,0 +1,20 @@ +NLS files + +Filenames are encoded as: +CCC-PPP + CCC: country code + PPP: codepage ID + both are zero-padded three digits numbers; one number may + use four digits. + +Extensions: +UNF: Uniform NLS file Format + plain text representation of NLS package (7bit US-ASCII) + may be used to validate GRAB_UNF output + see UNF toolset for more information +UP : NLSUPTST data file + used to validate DOS API normal character upcase functions DOS-65-2[0-2] +HC : Hardcoded NLS file to be included into the kernel + produced by UNF2HC + copy to ..\NLS_HC.ASM in order to use this NLS package as the hardcoded one + kernel must be re-compiled From 214dfed06b5e124dfbfcacd2b12daff58e3aa7c8 Mon Sep 17 00:00:00 2001 From: Jim Tabor Date: Sun, 6 Aug 2000 04:18:21 +0000 Subject: [PATCH 024/671] See history.txt git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@57 6ac86273-5f31-0410-b378-82cca8765d1b --- hdr/fat.h | 6 +- hdr/mcb.h | 4 +- hdr/nls.h | 488 ++++++++++++++++++++++++++++++++++--------------- hdr/pcb.h | 58 ++++++ hdr/portab.h | 6 + hdr/process.h | 7 +- hdr/stacks.inc | 8 + 7 files changed, 420 insertions(+), 157 deletions(-) diff --git a/hdr/fat.h b/hdr/fat.h index e27a7683..145b9a3c 100644 --- a/hdr/fat.h +++ b/hdr/fat.h @@ -36,8 +36,8 @@ static BYTE *fat_hRcsId = "$Id$"; /* * $Log$ - * Revision 1.4 2000/06/21 18:16:46 jimtabor - * Add UMB code, patch, and code fixes + * Revision 1.5 2000/08/06 04:18:21 jimtabor + * See history.txt * * Revision 1.3 2000/05/25 20:56:19 jimtabor * Fixed project history @@ -95,6 +95,8 @@ static BYTE *fat_hRcsId = "$Id$"; #define D_VOLID 0x08 /* volume id */ #define D_DIR 0x10 /* subdir */ #define D_ARCHIVE 0x20 /* archive bit */ + /* /// Added D_DEVICE bit. - Ron Cemer */ +#define D_DEVICE 0x40 /* device bit */ /* FAT file name constants */ #define FNAME_SIZE 8 diff --git a/hdr/mcb.h b/hdr/mcb.h index c34c03a1..11f9ebc2 100644 --- a/hdr/mcb.h +++ b/hdr/mcb.h @@ -36,8 +36,8 @@ static BYTE *mcb_hRcsId = "$Id$"; /* * $Log$ - * Revision 1.4 2000/06/21 18:16:46 jimtabor - * Add UMB code, patch, and code fixes + * Revision 1.5 2000/08/06 04:18:21 jimtabor + * See history.txt * * Revision 1.3 2000/05/25 20:56:19 jimtabor * Fixed project history diff --git a/hdr/nls.h b/hdr/nls.h index 56391d65..072d8173 100644 --- a/hdr/nls.h +++ b/hdr/nls.h @@ -5,7 +5,7 @@ /* */ /* National Language Support data structures */ /* */ -/* Copyright (c) 1995, 1996, 2000 */ +/* Copyright (c) 2000 */ /* Steffen Kaiser */ /* All Rights Reserved */ /* */ @@ -28,17 +28,7 @@ /****************************************************************/ /* one byte alignment */ - -#if defined(_MSC_VER) -#define asm __asm -#pragma pack(1) -#elif defined(_QC) || defined(__WATCOM__) -#pragma pack(1) -#elif defined(__ZTC__) -#pragma ZTC align 1 -#elif defined(__TURBOC__) && (__TURBOC__ > 0x202) -#pragma option -a- -#endif +#include /* * Description of the organization of NLS information -- 2000/02/13 ska @@ -52,19 +42,19 @@ * * The code included into the kernel does "only" support NLS packages * structurally compatible with the one of the U.S.A. / CP437. - * I guess that most NLS packages has been tweaked to be compatible + * I guess that most NLS packages has been tweaked to be compatible, * so that this is not a real limitation, but for all other packages * the external NLSFUNC can supply every piece of code necessary. * To allow this the interface between the kernel and NLSFUNC has been - * extended; at same time the interface has been reduced, because some + * extended; at the same time the interface has been reduced, because some * of the API functions do not seem to offer any functionality required * for now. This, however, may be a misinterpretation because of * lack of understanding. - * + * * The supported structure consists of the following assumptions: * 1) The pkg must contain the tables 2 (Upcase character), 4 * (Upcase filename character) and 5 (filename termination - * characters); because they are internally used. + * characters); because they are used internally. * 2) The tables 2 and 4 must contain exactly 128 (0x80) characters. * The character at index 0 corresponses to character 128 (0x80). * The characters in the range of 0..0x7f are constructed out of @@ -72,6 +62,12 @@ * upcased not through the table, but by the expression: * (ch >= 'a' && ch <= 'z')? ch - 'a' + 'A': ch * with: 'a' == 97; 'z' == 122; 'A' == 65 + * 3) The data to be returned by DOS-65 is enlisted in the + * nlsPointer[] array of the nlsPackage structure, including + * the DOS-65-01 data, which always must be last entry of the + * array. + * 4) DOS-38 returns the 34 bytes beginning with the byte at offset + * 4 behind the size field of DOS-65-01. * * It seems that pure DOS can internally maintain two NLS pkgs: * NLS#1: The hardcoded pkg of U.S.A. on CP437, and @@ -79,18 +75,18 @@ * I do interprete this behaviour as follows: * CONFIG.SYS is read in more passes; before COUTRY= can be evaluated, * many actions must be performed, e.g. to load kernel at all, open - * CONFIG.SYS and begin reading. The kernel requires at least one - * NLS information _before_ COUNTRY= has been evaluated - the upcase - * table. To not implement the same function multiple times, e.g. + * CONFIG.SYS and begin reading. The kernel requires at least two + * NLS information _before_ COUNTRY= has been evaluated - both upcase + * tables. To not implement the same function multiple times, e.g. * to upcase with and without table, the kernel uses the default - * NLS pkg until a more appropriate can be loaded and hopes that + * NLS pkg until a more appropriate one can be loaded and hopes that * the BIOS (and the user) can live with its outcome. * Though, theoretically, the hardcoded NLS pkg could be purged * or overwritten once the COUNTRY= statement has been evaluated. * It would be possible that this NLS pkg internally performs different * purposes, for now this behaviour will be kept. * - * The current implementation extendeds the above "two maintained + * The current implementation extends the above "two maintained * NLS pkgs" into that the kernel chains all NLS pkgs loaded in * memory into one single linked list. When the user does neither * wants to load other NLS pkgs without executing NLSFUNC and the @@ -103,20 +99,151 @@ * to add any code and residently install the MUX handler for NLSFUNC. * This technique reduces the overhead calling the MUX handler, when * it is not needed. - * - * The kernel can be instructed to pass any subfunction of DOS-65 to - * MUX-14-02, including the character upcase subfunctions 0x20-0x22 and - * 0xA0-0xA2 as well as 0x23 (yes/no response). That way upcase table can - * be supported (by reducing performance) that do not contain exactly 128 - * characters or where the lower portion is not constructed from the 7-bit - * US-ASCII character set. - * To do so, each NLS pkg contains some flags specifying if to pass a - * set of subfunctions to MUX-14-02, the sets include: - * set#1: filename character upcase 0xA0-0xA2 - * set#2: character upcase 0x20-0x22 - * set#3: yes/no response 0x23 - * set#4: Extended Country Information (Includes DOS-38) - * set#5: Anything else (usually picks a pointer from an array) + * However, NLSFUNC is always required if the user wants to return + * information about NLS pkgs _not_ loaded into memory. + * + *=== Attention: Because the nlsInfoBlock structure differs from the + *=== the "traditional" (aka MS) implementation, the MUX-14 interface + *=== is _not_ MS-compatible, although all the registers etc. + *=== do conform. -- 2000/02/26 ska + * + * Previous failed attempts to implement NLS handling and a full- + * featured MUX-14 supporting any-structured NLS pkgs suggest + * to keep the implement as simple as possible and keep the + * optimization direction off balance and to tend toward either + * an optimization for speed or size. + * + * The most problem is that the MUX interrupt chain is considered + * highly overcrowded, so if the kernels invokes it itself, the + * performance might decrease dramatically; on the other side, the + * more complex the interface between kernel and a _probably_ installed + * external NLSFUNC becomes the more difficult all the stuff is becoming + * and, most importantly, the size grows unnecessarily, because many + * people don't use NLSFUNC at all. + * + * The kernel uses the NLS pkg itself for two operations: + * 1) DOS-65-2x and DOS-65-Ax: Upcase character, string, memory area, & + * 2) whenever a filename is passed into the kernel, its components + * must be identified, invalid characters must be detected + * and, finally, all letters must be uppercased. + * I do not consider operation 1) an action critical for performance, + * because traditional DOS programming praxis says: Do it Yourself; so + * one can consider oneself lucky that a program aquires the upcase + * table once in its life time (I mean: lucky the program calls NLS at all). + * Operation 2), in opposite, might dramatically reduce performance, if + * it lacks proper implementations. + * + * Straight forward implementation: + * The basic implementation of the NLS channels all requests of DOS-65, + * DOS-66, and DOS-38 through MUX-14. Hereby, any external program, such + * as NLSFUNC, may (or may not) install a piece of code to filter + * one, few, or all requests in order to perform them itself, by default + * all requests will end within the root of the MUX interrupt, which is + * located within the kernel itself. An access path could look like this: + * 1. Call to DOS-65-XX, DOS-66-XX, or DOS-38. + * 2. The kernel is enterred through the usual INT-21 API handler. + * 3. The request is decoded and one of the NLS.C function is called. + * 4. This function packs a new request and calls MUX-14. + * 5. Every TSR/driver hooking INT-2F will check, if the request is + * directed for itself; + * 5.1. If not, the request is passed on to the next item of the MUX + * interrupt chain; + * 5.2. If so, the TSR, e.g. NLSFUNC, tests if the request is to be + * performed internally; + * 5.2.1. If so, the request is performed and the MUX-14 call is + * terminated (goto step 8.) + * 5.2.2. If not, the request is passed on (see step 5.1.) + * 6. If all TSRs had their chance to filter requests, but none decided + * to perform the request itself, the kernel is (re-)enterred + * through its INT-2F (MUX) API handler. + * 7. Here the request is decoded again and performed with the kernel- + * internal code; then the MUX-14 call is terminated. + * 8. When the MUX-14 call returns, it has setup all return parameters + * already, so the INT-21 call is terminated as well. + * + * Note: The traditional MUX-14 is NOT supported to offer functionality + * to the kernel at the first place, but to let the kernel access and + * return any values they must be loaded into memory, but the user may + * request information through the DOS-65 interface of NLS pkgs _not_ + * already loaded. Theoretically, NLSFUNC needs not allocate any internal + * buffer to load the data into, because the user already supplied one; + * also if the kernel would instruct NLSFUNC to load the requested + * NLS pkg, more memory than necessary would be allocated. However, all + * except subfunction 1 return a _pointer_ to the data rather than the + * data itself; that means that NLSFUNC must cache the requested data + * somewhere, but how long? + * + * Performance tweaks: + * When the system -- This word applies to the combination of kernel and + * any loaded MUX-14 extension   la NLSFUNC here. -- uppercases + * _filenames_, it must perform a DOS-65-A2 internally. In the basic + * implementation this request would be channeled through MUX-14, even + * if there is no external NLSFUNC at all. Also, when a NLS pkg had + * been loaded by the kernel itself, it complies to above mentioned + * rules and it is very unlikely that it is necessary to probe if + * a MUX-14 TSR might want to perform the request itself. Therefore + * each NLS pkg contains some flags that allow the kernel to bypass + * the MUX-14 request and invoke the proper function directly. Both + * default NLS pkgs will have those flags enabled, because they are + * already loaded into memory and must comply to the rules. + * + * Note: Those flags do not alter the way the request is actually + * performed, but the MUX-14 call is omitted only (steps 4. through 6.). + * + * ======= Description of the API + * + * There are three APIs to be supported by NLS: + * 1) DOS API: DOS-38, DOS-65, DOS-66; + * 2) MUX-14, and + * 3) internal: upcasing filenames. + * + * 1) and 2) address the used NLS pkg by the country code / codepage pair. + * 3) uses the currently active NLS pkg only; furthermore, these functions + * more or less match DOS-64-A*. Therefore, the NLS system merges the + * interfaces 1) and 3) and offers function suitable for both ones. + * + * Both 1) and 3) must channel the request through the MUX chain, if + * appropriate, whereas 2) is the back-end and does natively process the + * request totally on its own. + * + * The API of 1) and 3) consists of: + * + DosUpChar(), DosUpString(), and DosUpMem(): to upcase an object + * (DOS-65-2[0-2]); + * + DosYesNo(): to check a character, if it is the yes or no prompt + * (DOS-65-23); + * + DosUpFChar(), DosUpFString(), and DosUpFMem(): to upcase an object + * for filenames (DOS-65-A[0-2]); + * + DosGetData(): to retreive certain information (DOS-38, all the + * other DOS-65-** subfunctions); + * + DosSetCountry(): to change the currently active country code + * (DOS-38); + * + DosSetCodepage(): to change the currently active codepage (DOS-66). + * + * The API of 2) consists of: + * + syscall_MUX14(). + * This function is invoked for all MUX-14 requests and recieves the + * registers of the particular INT-2F call, it will then decode the + * registers and pass the request forth to a NLS-internal interface + * consisting of the following "static" functions: + * + nlsUpMem(): called for DosUp*(), + * + nlsUpFMem(): called for DosUpF*(), + * + nlsYesNo(): called for DosYesNo(), + * + nlsGetData(): called for DosGetData(),& + * + nlsSetPackage(): called for DosSetCountry() and DosSetCodepage(). + * In opposite of the APIs 1) through 3) the NLS-internal functions address + * the NLS pkg to operate upon by a (struct nlsInfoBlock *) pointer. + * + * This designs supports to easily implement to bypass the MUX chain to + * speed up especially the internal API to upcase filenames, because + * the Dos*() functions can decide do not pass the request through MUX, + * but directly call the nls*() function instead. This way it is ensured + * that the performed actions are the same in both cases and, with repect + * to the functions that operate with the currently active NLS pkg, the + * performance is rather high, because one can use the globally available + * pointer to the current NLS pkg and need not search for a country code/ + * codepage pair. + * + * ======== Compile-time options * * Win9x supports to change the individual portions of a NLS pkg * through DOS-65-00; also there are no references what happens when @@ -128,29 +255,20 @@ * enables the appropriate code. * NLS_MODIFYABLE_DATA is *disabled* by default. * - * The tables 2 and 4 (upcase tables) are relatively accessed often, - * but theoretically these tables could be loacted at any position + * The tables 2 and 4 (upcase tables) are accessed relatively often, + * but theoretically these tables could be located at any position * of the pointer array. If the macro NLS_REORDER_POINTERS is enabled, * both NLSFUNC and the internal loader will reorder the pointers * array so that mandatory tables are located at predictable indexes. * This removes that the kernel must search for the table when - * one of the DOS-65-[2A]x function is called or a filename has been + * one of the DOS-65-[2A]x functions is called or a filename has been * passed in (which must be uppercased to be suitable for internal * purpose). However, when some program try to tweak the internal * tables this assumption could be wrong. + * This setting has any effect only, if the kernel tries to access + * information itself; it is ignored when the user calls DOS-65-0x + * to return such pointer. * NLS_REORDER_POINTERS is *enabled* by default. - * - * A second performance boost can be achieved, if the kernel shall - * support *only* NLS pkgs that apply to the structure mentioned above, - * thus, contain only characters 0x80-0xFF and the range 0x00-0x7F - * is upcased as 7-bit US-ASCII. In this case when upcasing the - * NLS pkg is bypassed at all, but cached pointers are used, which - * point directly to the upcased characters. Because I don't know - * existing NLS pkgs, this feature may be not very trustworthy; also - * when the NLS pkg is switched bypassing DOS, the cached pointers - * won't be updated, also by enabling this macro the MUX-flags are - * ignored for the sub-functions DOS-65-[2A][0-2], therefore: - * NLS_CACHE_POINTERS is *disabled* by default. */ /* Define if some user program possibly modifies the value of the internal @@ -163,73 +281,65 @@ access to often used and mandatoryly present tables. */ #define NLS_REORDER_POINTERS -/* Define if the kernel is to cache the time-consuming search results. - Doing so could lead to imporper functionality, if the active - codepage or country ID is changed bypassing the DOS API. */ -/* #define NLS_CACHE_POINTERS */ - /* * How the kernel and NLSFUNC communicate with each other */ /* Must be returned by NLSFUNC upon MUX-14-00 */ #define NLS_FREEDOS_NLSFUNC_ID 0x534b - /* MUX-14 subfunction called by the kernel to load a specific - NLS package */ -#define NLS_NLSFUNC_LOAD_PKG 0x4b - /* MUX-14 subfunction called when to externally upcase */ -#define NLS_NLSFUNC_UP 0x61 - /* MUX-14 subfunction called when to externally upcase filenames */ -#define NLS_NLSFUNC_FUP 0x69 - /* Internally used to represent DOS-38 */ -#define NLS_DOS_38 0x7365 - /* MUX-14 subfunction called when to check yes/nochar */ -#define NLS_NLSFUNC_YESNO 0x72 - - /* Flags for the communication with NLSFUNC */ -#define NLS_FLAG_INFO 0x001 -#define NLS_FLAG_POINTERS 0x002 -#define NLS_FLAG_YESNO 0x004 -#define NLS_FLAG_UP 0x008 -#define NLS_FLAG_FUP 0x010 - -/* To ease the maintainance this header file is included to - a) define the "normal" structures, where all the non-fixed size - arrays are noted with length "1", and - b) define the hardcoded NLS package for U.S.A. -- CP437 - If the macro NLS_HARDCODED is defined, the structures are modifed - to result into structures with the correct length. - - When NLS_NO_VARS is defined, no prototypes of the global - variables are included, useful in sources defining the hardcoded - information, but require the normal types, too. -*/ -#ifndef NLS_HARDCODED - /* Use the default of length == 1 */ -#define NLS_POINTERS 1 -#define NLS_FNAMSEPS 1 -#define NLS_DBCSENTR 1 -#define __join(a,b) a -#define mkName(a) a + /* Represents a call to DOS-38 within DOS-65 handlers. + Current implementation relys on 0x101! */ +#define NLS_DOS_38 0x101 + /* NLSFUNC may return NLS_REDO to instruct the kernel to + try to perform the same action another time. This is most + useful if the kernel only loads the NLS pkg into memory so + the kernel will find it and will process the request internally + now. */ +#define NLS_REDO 353 -#else +/* Codes of the subfunctions of external NLSFUNC */ +#define NLSFUNC_INSTALL_CHECK 0 +#define NLSFUNC_DOS38 4 +#define NLSFUNC_GETDATA 2 +#define NLSFUNC_DRDOS_GETDATA 0xfe +#define NLSFUNC_LOAD_PKG 3 +#define NLSFUNC_LOAD_PKG2 1 +#define NLSFUNC_UPMEM 0x22 +#define NLSFUNC_YESNO 0x23 +#define NLSFUNC_FILE_UPMEM 0xa2 -#define __join(a,b) a##b -#define mkName(a) __join(a,NLS_HARDCODED) +/* The NLS implementation flags encode what feature is in effect; + a "1" in the bitfield means that the feature is active. + All currently non-defined bits are to be zero to allow future + useage. */ +#define NLS_CODE_MODIFYABLE_DATA 0x0001 +#define NLS_CODE_REORDER_POINTERS 0x0002 -#endif +/* NLS package useage flags encode what feature is in effect for this + particular package: + a "1" in the bitfield means that the feature is active/enabled. + All currently non-defined bits are to be zero to allow future + useage. */ +#define NLS_FLAG_DIRECT_UPCASE 0x0001 /* DOS-65-2[012], */ +#define NLS_FLAG_DIRECT_FUPCASE 0x0002 /* DOS-65-A[012], internal */ +#define NLS_FLAG_DIRECT_YESNO 0x0004 /* DOS-65-23 */ +#define NLS_FLAG_DIRECT_GETDATA 0x0008 /* DOS-65-XX, DOS-38 */ + +#define NLS_FLAG_HARDCODED NLS_FLAG_DIRECT_UPCASE \ + | NLS_FLAG_DIRECT_FUPCASE \ + | NLS_FLAG_DIRECT_YESNO \ + | NLS_FLAG_DIRECT_GETDATA /* No codepage / country code given */ #define NLS_DEFAULT ((UWORD)-1) -#ifndef NLS_HARDCODED /* * This is the data in the exact order returned by DOS-65-01 */ -struct nlsExtCtryInfo +struct nlsExtCntryInfo { UBYTE subfct; /* always 1 */ - WORD size; /* size of this structure + WORD size; /* size of this structure without this WORD itself */ WORD countryCode; /* current country code */ WORD codePage; /* current code page (CP) */ @@ -269,12 +379,12 @@ struct nlsExtCtryInfo 0: 12 hours (append AM/PM) 1: 24 houres */ - VOID(FAR * upCaseFct) (VOID); /* far call to a function mapping the + VOID(FAR * upCaseFct) (VOID); /* far call to a function upcasing the character in register AL */ char dataSep[2]; /* ASCIZ of separator in data records */ }; -struct nlsPointerInf { /* Information of DOS-65-0X is usually addressed +struct nlsPointer { /* Information of DOS-65-0X is addressed by a pointer */ UBYTE subfct; /* number of the subfunction */ VOID FAR *pointer; /* the pointer to be returned when the subfunction @@ -282,43 +392,45 @@ struct nlsPointerInf { /* Information of DOS-65-0X is usually addressed subfunctions 0, 1, 0x20, 0x21, 0x22, 0x23, 0xA0, 0xA1,& 0xA2 */ }; -#endif -struct mkName(nlsPackage) { /* the contents of one chain item of the + +struct nlsPackage { /* the contents of one chain item of the list of NLS packages */ struct nlsPackage FAR *nxt; /* next item in chain */ - unsigned muxCallingFlags; /* combination of NLS_FLAGS-* */ - struct nlsExtCtryInfo cntryInfo; - char yeschar, nochar; /* yes / no character DOS-65-23 */ + UWORD cntry, cp; /* country ID / codepage of this NLS pkg */ + int flags; /* direct access and other flags */ + /* Note: Depending on the flags above all remaining + portions may be omitted, if the external NLSFUNC-like + MUX-14 processor does not require them and performs + all actions itself, so that the kernel never tries to + fetch this information itself. */ + UBYTE yeschar; /* yes / no character DOS-65-23 */ + UBYTE nochar; unsigned numSubfct; /* number of supported sub-functions */ - struct nlsPointerInf nlsPointer[NLS_POINTERS]; /* grows dynamically */ + struct nlsPointer nlsPointers[1]; /* grows dynamically */ }; -struct mkName(nlsDBCS) { +struct nlsDBCS { /* The internal structure is unknown to me */ UWORD numEntries; - UWORD dbcsTbl[NLS_DBCSENTR]; + UWORD dbcsTbl[1]; }; -#ifndef NLS_HARDCODED struct nlsCharTbl { /* table containing a list of characters */ - WORD numEntries; /* number of entries of this table. + UWORD numEntries; /* number of entries of this table. If <= 0x80, the first element of the table corresponse to character 0x80 */ unsigned char tbl[1]; /* grows dynamically */ }; -struct nlsCharTbl128{ - WORD numEntries; - unsigned char tbl[128]; -}; -struct nlsCharTbl256{ - WORD numEntries; - unsigned char tbl[256]; -}; -#endif +#define nlsChBuf(len) struct nlsCharTbl##len { \ + UWORD numEntries; \ + unsigned char tbl[len]; \ + } +nlsChBuf(128); +nlsChBuf(256); /* in file names permittable characters for DOS-65-05 */ -struct mkName(nlsFnamTerm) { +struct nlsFnamTerm { WORD size; /* size of this structure */ BYTE dummy1; char firstCh, @@ -328,43 +440,117 @@ struct mkName(nlsFnamTerm) { lastExcl; /* first, last excluded character */ BYTE dummy3; BYTE numSep; /* number of file name separators */ - char separators[NLS_FNAMSEPS]; /* grows dynamically */ + char separators[1]; /* grows dynamically */ }; -#ifndef NLS_NO_VARS -struct mkName(nlsInfoBlock) { /* This block contains all information +struct nlsInfoBlock { /* This block contains all information shared by the kernel and the external NLSFUNC program */ - char FAR *fname; /* filename from COUNTRY= */ + char FAR *fname; /* filename from COUNTRY=; + maybe tweaked by NLSFUNC */ UWORD sysCodePage; /* system code page */ + unsigned flags; /* implementation flags */ struct nlsPackage FAR *actPkg; /* current NLS package */ -#ifdef NLS_CACHE_POINTERS - unsigned char FAR *fnamUpTable; /* upcase table for filenames */ - unsigned char FAR *upTable; /* normal upcase table */ -#endif - struct mkName(nlsPackage) chain; /* first item of info chain -- - hardcoded U.S.A. */ + struct nlsPackage FAR *chain; /* first item of info chain -- + hardcoded U.S.A./CP437 */ }; -extern struct mkName(nlsInfoBlock) nlsInfo; -extern struct mkName(nlsFnamTerm) nlsFnameTermHardcodedTable; -extern struct mkName(nlsDBCS) nlsDBCSHardcodedTable; -extern struct __join(nlsCharTbl,128) nlsUpHardcodedTable; -extern struct __join(nlsCharTbl,128) nlsFnameUpHardcodedTable; -extern struct __join(nlsCharTbl,256) nlsCollHardcodedTable; -#endif +extern struct nlsInfoBlock nlsInfo; +extern struct nlsPackage nlsPackageHardcoded; + /* These are the "must have" tables within the hard coded NLS pkg */ +extern struct nlsFnamTerm nlsFnameTermHardcoded; +extern struct nlsDBCS nlsDBCSHardcoded; +extern struct nlsCharTbl nlsUpcaseHardcoded; +extern struct nlsCharTbl nlsFUpcaseHardcoded; +extern struct nlsCharTbl nlsCollHardcoded; +extern struct nlsExtCntryInfo nlsCntryInfoHardcoded; +extern BYTE FAR hcTablesStart[], hcTablesEnd[]; -#undef NLS_POINTERS -#undef NLS_FNAMSEPS -#undef NLS_DBCSENTR -#undef __join(a,b) -#undef mkName(a) +/*********************************************************************** + ***** Definitions & Declarations for COUNTRY.SYS ********************** + ***********************************************************************/ -/* standard alignment */ +/* Note: These definitions are shared among all tools accessing the + COUNTRY.SYS file as well -- 2000/06/11 ska*/ + +/* File structure: + S0: Base (Primary) structure -- file header + Offset Size Meaning + 0 array ID string "FreeDOS COUNTRY.SYS v1.0\r\n" + 26 array Copyright etc. (plain 7bit ASCII text) + 26+N 2byte \x1a\0 + 26+N+2 array padded with \0 upto next offset + 128 word number of country/codepage pairs (N1) + 130 8byte country code / codepage entries (S1) + 130+8*N1 end of array + === + S1: structure of country/codepage pair + Offset Size Meaning + 0 dword relative position of table definition (S2) + 4 word codepage ID + 6 word country code + 8 end of structure + === + S2: table definition of one country/codepage pair + Offset Size Meaning + 0 word number of function entries (N2) + 2 8byte function definition (S3) + 2+8*N2 end of array + === + S3: function definition + Offset Size Meaning + 0 dword relative position of function data (see S4) + 4 word number of bytes of data + 6 byte function ID (same as passed to DOS-65-XX) + 7 byte reserved for future use (currently 0 (zero)) + 8 end of structure + === + S4: function data + In opposite of the structures and arrays, the function data + is just a structure-less stream of bytes, which is used as it is. + Currently no validation check is performed over this data. + That means, for instance, that a definition of function 2 (upcase + table) has length 130 and the data consists of a word value with + the length (128) and 128 bytes individual information. + That way the DBCS is implemented exactly the same way as all the + other tables; the only exception is pseudo-table 0x23. + === + "relative position" means this DWord specifies the amount of bytes + between end of the current structure and the data the pointer is + referring to. This shall enable future implementations to embed + COUNTRY.SYS into other files. +*/ + +#define CSYS_FD_IDSTRING "FreeDOS COUNTRY.SYS v1.0\r\n" + +struct nlsCSys_function { /* S3: function definition */ + UDWORD csys_rpos; /* relative position to actual data */ + UWORD csys_length; + UBYTE csys_fctID; /* As passed to DOS-65-XX */ + UBYTE csys_reserved1; /* always 0, reserved for future use */ +}; -#if defined (_MSC_VER) || defined(_QC) || defined(__WATCOMC__) -#pragma pack() -#elif defined (__ZTC__) -#pragma ZTC align -#elif defined(__TURBOC__) && (__TURBOC__ > 0x202) -#pragma option -a. -#endif +struct nlsCSys_ccDefinition { /* S1: country/codepage reference */ + UDWORD csys_rpos; /* moving the 4byte value to the front + can increase performance */ + UWORD csys_cp; + UWORD csys_cntry; +}; + +struct nlsCSys_numEntries { /* helper structure for "number of entries" */ + UWORD csys_numEntries; +}; + +/* Actually, this structure is never really used */ +struct nlsCSys_fileHeader { /* S0: primary structure */ + unsigned char csys_idstring[sizeof(CSYS_FD_IDSTRING) - 1]; + /* decrement by 1 to cut off \0 from IDString -- ska*/ +}; + +struct nlsCSys_completeFileHeader { /* as S0, but full 128 bytes */ + unsigned char csys_idstring[sizeof(CSYS_FD_IDSTRING) - 1]; + unsigned char csys_padbytes[128 - (sizeof(CSYS_FD_IDSTRING) - 1)]; +}; + + +/* standard alignment */ +#include diff --git a/hdr/pcb.h b/hdr/pcb.h index f2b2337b..292f39a9 100644 --- a/hdr/pcb.h +++ b/hdr/pcb.h @@ -28,6 +28,27 @@ /* Cambridge, MA 02139, USA. */ /****************************************************************/ +/*************************************************************** + 2000/03/22 ska + There is a newly documented (though used previously) side effect + of the definitions and assumptions made herein: + The assembly sources may use a macro named "PUSH$ALL" to push + all processor registers onto the stack, see example below: + PUSH$ALL + mov ax, sp + ... + push ax + call _c_function + pop cx + The stack pointer immediately after the PUSH$ALL macro shall point to + a structure used as an "iregs" structure within the C language. + Therefore the internal of the structure "iregs" _must_ always + match the implementation of the macro "PUSH$ALL". +*/ + +#ifndef __PCB_H +#define __PCB_H + #ifdef MAIN #ifdef VERSION_STRINGS static BYTE *pcb_hRcsId = "$Id$"; @@ -36,6 +57,9 @@ static BYTE *pcb_hRcsId = "$Id$"; /* * $Log$ + * Revision 1.4 2000/08/06 04:18:21 jimtabor + * See history.txt + * * Revision 1.3 2000/05/25 20:56:19 jimtabor * Fixed project history * @@ -81,6 +105,8 @@ static BYTE *pcb_hRcsId = "$Id$"; * Initial revision. */ + /* Force one-byte alignment for all the internal structures, see above */ +#include /* */ /* interrupt handler structure definition */ /* */ @@ -96,6 +122,11 @@ typedef union } xreg; +/* The structure assumes that: + 1) An interrupt was invoked, & + 2) the PUSH$ALL macro was invoked immediately after that. + Furthermore, the PUSH$ALL macro must push ES first and AX last. + -- 2000/03/22 ska*/ /* maps MS-DOS unique stacking order */ typedef struct { @@ -114,6 +145,16 @@ typedef struct } iregs; + /* Registers directly passed to syscall; + must be the same order as iregs! + Is used to define parameters. */ +#define DIRECT_IREGS \ + xreg a, xreg b, xreg c, xreg d, \ + UWORD si, UWORD di, UWORD bp, UWORD ds, UWORD es, \ + UWORD ip, UWORD cs, UWORD flags + + + /* Process control block for task switching */ typedef struct { @@ -123,6 +164,9 @@ typedef struct } pcb; +/* Note: The following figure is not made by myself and I assume that + the order of "ES" through "AX" are misinterpreted?! -- 2000/03/22 ska*/ + /* For MSC, the following offsets must match the assembly process */ /* support offsets */ /* NOTE: Alignemnts must be set to 1 (-Zp1) */ @@ -182,3 +226,17 @@ pcb; #define FLG_ZERO 0x0040 #define FLG_CARRY 0x0001 + + /* Allow default alignment from now on */ +#include + +/* + * Invoke interrupt "intnr" with all registers from *pr loaded + * into the processor registers (except: SS, SP,& flags) + * On return, all processor registers are stored into *pr (including + * flags). + */ +void intr(int intnr, iregs * const pr); + +#endif + diff --git a/hdr/portab.h b/hdr/portab.h index 7ea1ab34..08f2783d 100644 --- a/hdr/portab.h +++ b/hdr/portab.h @@ -36,6 +36,9 @@ static char *portab_hRcsId = "$Id$"; /* * $Log$ + * Revision 1.4 2000/08/06 04:18:21 jimtabor + * See history.txt + * * Revision 1.3 2000/05/25 20:56:19 jimtabor * Fixed project history * @@ -173,6 +176,7 @@ typedef long DWORD; typedef unsigned char UBYTE; typedef unsigned short UWORD; +typedef unsigned long UDWORD; typedef short SHORT; @@ -196,10 +200,12 @@ typedef signed long LONG; /* General far pointer macros */ #ifdef I86 +#ifndef MK_FP #define MK_FP(seg,ofs) ((VOID far *)(((LONG)(seg)<<16)|(UWORD)(ofs))) #define FP_SEG(fp) ((UWORD)((LONG)(VOID FAR *)(fp)>>16)) #define FP_OFF(fp) ((UWORD)(fp)) #endif +#endif #ifdef MC68K #define MK_FP(seg,ofs) ((VOID *)(&(((BYTE *)(seg))[(ofs)]))) diff --git a/hdr/process.h b/hdr/process.h index 6402820d..70dc6fdf 100644 --- a/hdr/process.h +++ b/hdr/process.h @@ -36,6 +36,9 @@ static BYTE *process_hRcsId = "$Id$"; /* * $Log$ + * Revision 1.4 2000/08/06 04:18:21 jimtabor + * See history.txt + * * Revision 1.3 2000/05/25 20:56:19 jimtabor * Fixed project history * @@ -104,8 +107,8 @@ typedef struct { UWORD env_seg; CommandTail FAR *cmd_line; - BYTE FAR *fcb_1; - BYTE FAR *fcb_2; + fcb FAR *fcb_1; + fcb FAR *fcb_2; BYTE FAR *stack; BYTE FAR *start_addr; } diff --git a/hdr/stacks.inc b/hdr/stacks.inc index 081b59a2..9b87dc95 100644 --- a/hdr/stacks.inc +++ b/hdr/stacks.inc @@ -30,6 +30,9 @@ ; $Id$ ; ; $Log$ +; Revision 1.5 2000/08/06 04:18:21 jimtabor +; See history.txt +; ; Revision 1.4 2000/05/26 19:46:52 jimtabor ; Read History file for Change info ; @@ -103,6 +106,11 @@ ; +---------------+ ; +;; Note: The order of the pushed registers _must_ match with the definition +;; of the "iregs" structure within PCB.H, because a pointer to the last +;; pushed register is used as a pointer to a "iregs" structure within the +;; called C sources! -- 2000/03/22 ska + ; Don't use `struc RegFrame' etc. here because it interferes with segment ; definitions. reg_ax equ 0 From 6aace6ea7c9b7d960f73aca71159543c1e058566 Mon Sep 17 00:00:00 2001 From: Jim Tabor Date: Sun, 6 Aug 2000 04:27:07 +0000 Subject: [PATCH 025/671] See history.txt git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@58 6ac86273-5f31-0410-b378-82cca8765d1b --- hdr/mcb.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/hdr/mcb.h b/hdr/mcb.h index 11f9ebc2..4e8e1178 100644 --- a/hdr/mcb.h +++ b/hdr/mcb.h @@ -36,9 +36,15 @@ static BYTE *mcb_hRcsId = "$Id$"; /* * $Log$ + * Revision 1.6 2000/08/06 04:27:07 jimtabor + * See history.txt + * * Revision 1.5 2000/08/06 04:18:21 jimtabor * See history.txt * + * Revision 1.4 2000/06/21 18:16:46 jimtabor + * Add UMB code, patch, and code fixes + * * Revision 1.3 2000/05/25 20:56:19 jimtabor * Fixed project history * From 96c18e84b68943747e7a76027d5320ace10abcbe Mon Sep 17 00:00:00 2001 From: Jim Tabor Date: Sun, 6 Aug 2000 04:42:32 +0000 Subject: [PATCH 026/671] Update git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@59 6ac86273-5f31-0410-b378-82cca8765d1b --- docs/history.txt | 17 +++++ docs/nls.txt | 191 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 208 insertions(+) create mode 100644 docs/nls.txt diff --git a/docs/history.txt b/docs/history.txt index 054f0616..23f8da9c 100644 --- a/docs/history.txt +++ b/docs/history.txt @@ -1,3 +1,20 @@ +2000 Aug 05 - Build 2021 +-------- James Tabor (jimtabor@infohwy.com) + Clean up and finish umb code to get 2021 out. + +2000 Jul 26 - Build 2021 +-------- James Tabor (jimtabor@infohwy.com) ++ Fix New patch from Ron IsDevice and truename fix. + +2000 Jul 14 - Build 2021 +-------- James Tabor (jimtabor@infohwy.com) ++ Add Added NLS patches from Steffen Kaiser and patch from Ron + (roncemer@gte.net). + +2000 Jun 25 - Build 2021 +-------- James Tabor (jimtabor@infohwy.com) ++ Add Add and Fix support for UMB's. + 2000 Jun 20 - Build 2021 -------- James Tabor (jimtabor@infohwy.com) + Fix Bart Oldeman (Bart.Oldeman@bristol.ac.uk) found bugs with copy diff --git a/docs/nls.txt b/docs/nls.txt new file mode 100644 index 00000000..3875b54b --- /dev/null +++ b/docs/nls.txt @@ -0,0 +1,191 @@ +Current version: $Id$ + +This document describes all aspects of the implementation +of NLS in the FreeDOS kernel -- 2000/06/16 ska + +Note: + At this time this document contains only an overall description + of how the FreeDOS NLS works; detailed implementation details are + found in HDR\NLS.H and KERNEL\NLS_LOAD.C. When the FreeDOS developers + finally adopted the current scheme, the larger comments of both + files will be merged into a single document -> this file. + += TOC + += Capabilites of the current implementation. + +Tested is: ++ DOS-38 - Get Country Information ++ DOS-65-[2A][0-2] - upcase normal/filename characters ++ DOS-65-23 - YesNo prompt character ++ DOS-65-01 - Get Extended Country Information ++ DOS-65-0[24] - Get pointer to normal/filename upcase table ++ DOS-65-05 - Get pointer to filename terminator table ++ DOS-65-06 - Get pointer to collating sequence table ++ DOS-65-07 - Get pointer to DBCS table + Note: Because I don't know how this used, only an empty table + has been verified to work properly. ++ DOS-66-01 - Get active codepage ++ MUX-14-00 - Installation check ++ MUX-14-02 - Get extended country information ++ MUX-14-04 - Get country information ++ MUX-14-FE - DRDOS get extended country information ++ MUX-14-23 - validate Yes/No prompt (FreeDOS extension) ++ MUX-14-22 - upcase normal character area (FreeDOS extension) ++ MUX-14-A2 - upcase filename character area (FreeDOS extension) + +Not implemented is: ++ DOS-65-00 - Change DOS-65-XX information ++ DOS-66-02 - Set active codepage + Note: The rough interface is available, but no code to actually + to change the codepage. ++ external TSR "NLSFUNC" ++ MUX-14-FF - DRDOS prepare codepage + +Not validated is: ++ DOS-38 - Set Country code, because: + 1) it relies on DOS-66-02 (Set active code page) and + 2) requires external NLSFUNC. ++ COUNTRY= statement in CONFIG.SYS (code avilable, but not tested at all) ++ MUX-14-01 - change codepage & MUX-14-03 - Set codepage, because + the meaning of them is not intentional to me. Both function perform + the same request currently, to change the current codepage or country + code or both (though, see DOS-66-02). + + += Supported NLS packages + +A NLS package may contain data only or data and code. + +If the NLS package shall not contain any code, it must conform to the +code already included within the kernel; otherwise an external TSR, +usually NLSFUNC, must provide all code by hooking and intercepting +the MUX-14-XX API. + +In order to support the external NLSFUNC, all requests for DOS-XX are +re-routed through MUX-14; but because the NLS API must work, even if no +NLSFUNC has been loaded, the kernel implements a MUX-14 interface of its +own and performs all MUX-14 requests. + +However, because the channeling of each request through the MUX chain +is considered a very heavy operation (aka time-consuming), flags are +introduced when to _bypass_ the MUX chain and directly call the +function, which would be activated, if the request would reach the +MUX-14 interface of the kernel. + +Because the kernel can only load NLS packages structurally identical to +U.S.A./CP437 per definition, the kernel automatically sets those flags, +thus, retreives all information from them without to channel the request +through the MUX interrupt chain. + +The term "structurally identical" is explained in NLS.H. + += Using NLS functions from within the kernel + +There are functions to: ++ upcase normal characters: DosUpMem(), DosUpString(), DosUpChar() ++ upcase filename characters: DosUpFMem(), DosUpFString(), DosUpFChar() ++ verify yes/no prompt characters: DosYesNo() ++ retreive data (country informaion): DosGetData() [DOS-65-XX], + DosGetCountryInformation() [DOS-38] + +They implement the usual DOS interface and refer to the country code and +codepage by the usual UWORD numbers; NLS_DEFAULT can be used to specify +"current country/codepage". The "Up*()" functions always use the currently +active NLS package. + +These functions are also called by the INT-21 handler. + +Because of the MUX chain support these functions more or less wrap the +real functions only and check the flags whether to call the internal +function directly or re-route the request through MUX. + +Therefore NLS data must not be accessed directly from outside the NLS +implementation, but through these functions only. + +CAUTION: The DOS NLS differs between "normal" characters and "filename" +characters, that's why one must call DosUpFString() to upcase a +filename rather than DosUpString()! + +Note: The NLS subsystem is robust against any type of characters, +that means DosUpFMem() can be called with any type of junk, except +the pointer to the buffer must not be NULL. + += NLS and fileformats (UNF) + +The current implementation does not implemented everything MS-DOS like, +this includes the internal NLS information block and the fileformat of +COUNTRY.SYS. Both structures shall be updated to increase performance, +rather than require the kernel to simulate old and obsolated interfaces. +To overcome the traditional problem with ever-changing structures +a toolset is provided to represent the NLS package in an implementation- +independed way and read/write/manipulate etc. pp. this data. + +In the final state NLSFUNC will automatically detect the structures +and transform them into the structure required by the kernel. + +To minimize the complexity of these data transformation processes +an independed fileformat called UNF (Uniform NLS file Format) has been +founded, which is totally plain text (except comments) and somewhat +human-readable. Tools will be provided to convert any or particular binary +forms of NLS packages into UNF and back. + +Currently available tools: +GRAB_UNF: Extracts all information from the current NLS API and dumps it + into an UNF file. Supports standard information and DOS-65-03 (lowercase). +UNF2HC: Transforms an UNF file into the format of the hardcoded NLS package + ready to be used when the kernel is make'ed. + + += Testing / Verifying NLS + +Above mentioned UNF toolset includes: +GRAB_UNF: Dump NLS package into UNF file and +NLSUPTST: Test upcase API (DOS-65-2[0-2]). + +Testing steps: +1) Generate an UpCase test verifaction file by running "NLSUPTST /c" on + a DOS computer that is entitled to run a good NLS. + Alternatively download an UP file corresponding to your locale, + that means -.UP (without the angle brackets). + Note: The numerical country code and codepage must match the settings + of your testee system! +2) Do the same an generate an sample UNF of a good NLS, by running + "GRAB_UNF.EXE" or download one from the internet. the filename is: + -.UNF + Note: If you manually edit the file, run "READ_UNF " to + check the file for errors and dump it in the very same format as + GRAB_UNF will. +3) Copy GRAB_UNF.EXE, NLSUPTST.EXE and the UP file onto the testee, e.g. + floppy. Make sure no .UNF file is located there. +4) Create the CONFIG.SYS with only the minimum settings, more than + a COUNTRY= and a SHELL= are usually NOT required. +5) Create an AUTOEXEC.BAT with this contents (strip leading tabs): + GRAB_UNF.EXE + NLSUPTST.EXE + Note: If you have NLS_DEBUG enabled, a lot of noise will be displayed! +6) Reboot the testee +7) The GRAB_UNF.EXE will display its success by: + "NLS info file for - has been created sucessfully" + In this case an UNF file has been created <-> the only way to see this + success status, if NLS_DEBUG is enabled within the kernel. +8) At some point you should see an error message or the good news: + "NLS passed all DOS-65-2[0-2] tests" + This means that NLSUPTST was successful, because there is no other + way to detect this, NLSUPTST must be placed last. +9) Compare the -.UNF file form the directory you + run GRAB_UNF.EXE in with the _equally_ named sample file. + Both must be 100% identical, even the number of spaces are. + +If COMMAND.COM fails to run AUTOEXEC.BAT, change the SHELL= line within +CONFIG.SYS into: + SHELL=GRAB_UNF.EXE +-and- + SHELL=NLSUPTST.EXE +and boot the testee once with each line. + +What do these tests miss? ++ None of these tests try to change neither country code nor code page. ++ By default, these tests cannot override the internal performance flags + and so either the direct-calling or the MUX-re-routing mechanism + is tested, but never both. From 52ba7200633ba9578891acdf6c72310e5c965da2 Mon Sep 17 00:00:00 2001 From: Jim Tabor Date: Sun, 6 Aug 2000 04:44:42 +0000 Subject: [PATCH 027/671] New Version 2021 git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@60 6ac86273-5f31-0410-b378-82cca8765d1b --- hdr/version.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hdr/version.h b/hdr/version.h index 4dd0e095..4dcd3aff 100644 --- a/hdr/version.h +++ b/hdr/version.h @@ -42,5 +42,5 @@ static BYTE *date_hRcsId = "$Id$"; #define REVISION_MAJOR 1 #define REVISION_MINOR 1 -#define REVISION_SEQ 20 +#define REVISION_SEQ 21 #define BUILD 2021 From 0fddf1f8481d68b2fd95a126e64f9ee8ea23a6e1 Mon Sep 17 00:00:00 2001 From: Jim Tabor Date: Sun, 6 Aug 2000 05:50:17 +0000 Subject: [PATCH 028/671] Add new files and update cvs with patches and changes git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@61 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/001-437.nls | 240 --------------- kernel/config.c | 135 ++++++--- kernel/config.h | 38 +++ kernel/dosfns.c | 61 +++- kernel/fatdir.c | 68 ++++- kernel/fatfs.c | 9 +- kernel/fcbfns.c | 37 ++- kernel/globals.h | 26 +- kernel/int2f.asm | 126 +++++++- kernel/inthndlr.c | 94 +++--- kernel/kernel.asm | 9 +- kernel/kernel.mak | 17 +- kernel/main.c | 7 +- kernel/memmgr.c | 88 +++++- kernel/network.c | 5 +- kernel/newstuff.c | 180 +++++++++++- kernel/nls.c | 713 ++++++++++++++++++++++++++++++--------------- kernel/nls_hc.asm | 109 +++++++ kernel/nls_hc.c | 194 ------------ kernel/nls_load.c | 388 ++++++++++++++++++++++++ kernel/nlssupt.asm | 9 +- kernel/proto.h | 45 ++- kernel/task.c | 25 +- sys/sys.c | 3 + 24 files changed, 1790 insertions(+), 836 deletions(-) delete mode 100644 kernel/001-437.nls create mode 100644 kernel/config.h create mode 100644 kernel/nls_hc.asm delete mode 100644 kernel/nls_hc.c create mode 100644 kernel/nls_load.c diff --git a/kernel/001-437.nls b/kernel/001-437.nls deleted file mode 100644 index dbfa77f3..00000000 --- a/kernel/001-437.nls +++ /dev/null @@ -1,240 +0,0 @@ - -/****************************************************************/ -/* */ -/* 001-437.nls */ -/* DOS-C */ -/* */ -/* National Languge Support USA Code Page */ -/* */ -/* Copyright (c) 1996 */ -/* Pasquale J. Villani */ -/* All Rights Reserved */ -/* */ -/* Copyright (c) 1996 */ -/* Steffen Kaiser */ -/* All Rights Reserved */ -/* */ -/* This file is part of DOS-C. */ -/* */ -/* DOS-C is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU General Public License */ -/* as published by the Free Software Foundation; either version */ -/* 2, or (at your option) any later version. */ -/* */ -/* DOS-C is distributed in the hope that it will be useful, but */ -/* WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See */ -/* the GNU General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU General Public */ -/* License along with DOS-C; see the file COPYING. If not, */ -/* write to the Free Software Foundation, 675 Mass Ave, */ -/* Cambridge, MA 02139, USA. */ -/****************************************************************/ - -/* $Logfile: D:/dos-c/src/kernel/001-437.nlv $ */ -#ifdef VERSION_STRINGS -static BYTE *RcsId = "$Header$"; -#endif - -/* - * $Log$ - * Revision 1.3 2000/05/25 20:56:20 jimtabor - * Fixed project history - * - * Revision 1.2 2000/05/08 04:29:59 jimtabor - * Update CVS to 2020 - * - * Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 - * The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with - * MS-DOS. Distributed under the GNU GPL. - * - * Revision 1.2 2000/03/09 06:07:10 kernel - * 2017f updates by James Tabor - * - * Revision 1.1.1.1 1999/03/29 15:40:36 jprice - * New version without IPL.SYS - * - * Revision 1.2 1999/01/22 04:13:25 jprice - * Formating - * - * Revision 1.1.1.1 1999/01/20 05:51:01 jprice - * Imported sources - * - * - * Rev 1.2 29 May 1996 21:03:46 patv - * bug fixes for v0.91a - * - * Rev 1.1 19 Feb 1996 4:34:48 patv - * Corrected typo - * - * Rev 1.0 19 Feb 1996 3:37:48 patv - * Initial revision. - */ - -/* This initialization segment is included into the file where needed. */ -/* It's cuurently included in the following file: nls.c. */ -{ - { - { - 0, 0, 0, 0, 0, 0, 0, 0 - } - , - "\\COUNTRY.SYS", - 437, - 6, - { - { - (VOID FAR *) & nlsInfo.upNCsize, 2 - } - , - { - (VOID FAR *) & nlsInfo.upFCsize, 4 - } - , - { - (VOID FAR *) & nlsInfo.nlsFn, 5 - } - , - { - (VOID FAR *) & nlsInfo.collSize, 6 - } - , - { - (VOID FAR *) & nlsInfo.nlsExtCtryInfo.countryCode, 1 - } - , - { - (VOID FAR *) & nlsInfo.dbcSize, 7 - } - } - , - - 1, /* country code */ - 437, /* code page */ - { - 0, /* date format */ - { - /* currency string */ - '$', '\x00', '\x00', '\x00', '\x00', /* 0 - 4 */ - } - , - { /* thousand separator */ - ',', '\x00' /* 0 - 1 */ - } - , - { /* decimal point */ - '.', '\x00' /* 0 - 1 */ - } - , - { /* date separator */ - '-', '\x00' /* 0 - 1 */ - } - , - { /* time separator */ - ':', '\x00' /* 0 - 1 */ - } - , - 0, /* currency format */ - 2, /* currency prescision */ - 0, /* time format */ - CharMapSrvc, /* upcase function */ - { /* data separator */ - ',', '\x00' /* 0 - 1 */ - } - } - } - , - 'Y', 'N', /* Yes/No prompt characters */ - 128, /* upcase table */ - { - '\x80', '\x9a', 'E', 'A', '\x8e', 'A', '\x8f', '\x80' /* 0 - 7 */ - ,'E', 'E', 'E', 'I', 'I', 'I', '\x8e', '\x8f' /* 8 - 15 */ - ,'\x90', '\x92', '\x92', 'O', '\x99', 'O', 'U', 'U' /* 16 - 23 */ - ,'Y', '\x99', '\x9a', '\x9b', '\x9c', '\x9d', '\x9e', '\x9f' /* 24 - 31 */ - ,'A', 'I', 'O', 'U', '\xa5', '\xa5', '\xa6', '\xa7' /* 32 - 39 */ - ,'\xa8', '\xa9', '\xaa', '\xab', '\xac', '\xad', '\xae', '\xaf' /* 40 - 47 */ - ,'\xb0', '\xb1', '\xb2', '\xb3', '\xb4', '\xb5', '\xb6', '\xb7' /* 48 - 55 */ - ,'\xb8', '\xb9', '\xba', '\xbb', '\xbc', '\xbd', '\xbe', '\xbf' /* 56 - 63 */ - ,'\xc0', '\xc1', '\xc2', '\xc3', '\xc4', '\xc5', '\xc6', '\xc7' /* 64 - 71 */ - ,'\xc8', '\xc9', '\xca', '\xcb', '\xcc', '\xcd', '\xce', '\xcf' /* 72 - 79 */ - ,'\xd0', '\xd1', '\xd2', '\xd3', '\xd4', '\xd5', '\xd6', '\xd7' /* 80 - 87 */ - ,'\xd8', '\xd9', '\xda', '\xdb', '\xdc', '\xdd', '\xde', '\xdf' /* 88 - 95 */ - ,'\xe0', '\xe1', '\xe2', '\xe3', '\xe4', '\xe5', '\xe6', '\xe7' /* 96 - 103 */ - ,'\xe8', '\xe9', '\xea', '\xeb', '\xec', '\xed', '\xee', '\xef' /* 104 - 111 */ - ,'\xf0', '\xf1', '\xf2', '\xf3', '\xf4', '\xf5', '\xf6', '\xf7' /* 112 - 119 */ - ,'\xf8', '\xf9', '\xfa', '\xfb', '\xfc', '\xfd', '\xfe', '\xff' /* 120 - 127 */ - } - , - 128, /* file name upcase table */ - { - '\x80', '\x9a', 'E', 'A', '\x8e', 'A', '\x8f', '\x80' /* 0 - 7 */ - ,'E', 'E', 'E', 'I', 'I', 'I', '\x8e', '\x8f' /* 8 - 15 */ - ,'\x90', '\x92', '\x92', 'O', '\x99', 'O', 'U', 'U' /* 16 - 23 */ - ,'Y', '\x99', '\x9a', '\x9b', '\x9c', '\x9d', '\x9e', '\x9f' /* 24 - 31 */ - ,'A', 'I', 'O', 'U', '\xa5', '\xa5', '\xa6', '\xa7' /* 32 - 39 */ - ,'\xa8', '\xa9', '\xaa', '\xab', '\xac', '\xad', '\xae', '\xaf' /* 40 - 47 */ - ,'\xb0', '\xb1', '\xb2', '\xb3', '\xb4', '\xb5', '\xb6', '\xb7' /* 48 - 55 */ - ,'\xb8', '\xb9', '\xba', '\xbb', '\xbc', '\xbd', '\xbe', '\xbf' /* 56 - 63 */ - ,'\xc0', '\xc1', '\xc2', '\xc3', '\xc4', '\xc5', '\xc6', '\xc7' /* 64 - 71 */ - ,'\xc8', '\xc9', '\xca', '\xcb', '\xcc', '\xcd', '\xce', '\xcf' /* 72 - 79 */ - ,'\xd0', '\xd1', '\xd2', '\xd3', '\xd4', '\xd5', '\xd6', '\xd7' /* 80 - 87 */ - ,'\xd8', '\xd9', '\xda', '\xdb', '\xdc', '\xdd', '\xde', '\xdf' /* 88 - 95 */ - ,'\xe0', '\xe1', '\xe2', '\xe3', '\xe4', '\xe5', '\xe6', '\xe7' /* 96 - 103 */ - ,'\xe8', '\xe9', '\xea', '\xeb', '\xec', '\xed', '\xee', '\xef' /* 104 - 111 */ - ,'\xf0', '\xf1', '\xf2', '\xf3', '\xf4', '\xf5', '\xf6', '\xf7' /* 112 - 119 */ - ,'\xf8', '\xf9', '\xfa', '\xfb', '\xfc', '\xfd', '\xfe', '\xff' /* 120 - 127 */ - } - , - 256, /* collating sequence table */ - { - '\x00', '\x01', '\x02', '\x03', '\x04', '\x05', '\x06', '\x07' /* 0 - 7 */ - ,'\x08', '\x09', '\x0a', '\x0b', '\x0c', '\x0d', '\x0e', '\x0f' /* 8 - 15 */ - ,'\x10', '\x11', '\x12', '\x13', '\x14', '\x15', '\x16', '\x17' /* 16 - 23 */ - ,'\x18', '\x19', '\x1a', '\x1b', '\x1c', '\x1d', '\x1e', '\x1f' /* 24 - 31 */ - ,' ', '!', '"', '#', '$', '%', '&', '\'' /* 32 - 39 */ - ,'(', ')', '*', '+', ',', '-', '.', '/' /* 40 - 47 */ - ,'0', '1', '2', '3', '4', '5', '6', '7' /* 48 - 55 */ - ,'8', '9', ':', ';', '<', '=', '>', '?' /* 56 - 63 */ - ,'@', 'A', 'B', 'C', 'D', 'E', 'F', 'G' /* 64 - 71 */ - ,'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O' /* 72 - 79 */ - ,'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W' /* 80 - 87 */ - ,'X', 'Y', 'Z', '[', '\\', ']', '^', '_' /* 88 - 95 */ - ,'`', 'A', 'B', 'C', 'D', 'E', 'F', 'G' /* 96 - 103 */ - ,'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O' /* 104 - 111 */ - ,'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W' /* 112 - 119 */ - ,'X', 'Y', 'Z', '{', '|', '}', '~', '\x7f' /* 120 - 127 */ - ,'C', 'U', 'E', 'A', 'A', 'A', 'A', 'C' /* 128 - 135 */ - ,'E', 'E', 'E', 'I', 'I', 'I', 'A', 'A' /* 136 - 143 */ - ,'E', 'A', 'A', 'O', 'O', 'O', 'U', 'U' /* 144 - 151 */ - ,'Y', 'O', 'U', '$', '$', '$', '$', '$' /* 152 - 159 */ - ,'A', 'I', 'O', 'U', 'N', 'N', '\xa6', '\xa7' /* 160 - 167 */ - ,'?', '\xa9', '\xaa', '\xab', '\xac', '!', '"', '"' /* 168 - 175 */ - ,'\xb0', '\xb1', '\xb2', '\xb3', '\xb4', '\xb5', '\xb6', '\xb7' /* 176 - 183 */ - ,'\xb8', '\xb9', '\xba', '\xbb', '\xbc', '\xbd', '\xbe', '\xbf' /* 184 - 191 */ - ,'\xc0', '\xc1', '\xc2', '\xc3', '\xc4', '\xc5', '\xc6', '\xc7' /* 192 - 199 */ - ,'\xc8', '\xc9', '\xca', '\xcb', '\xcc', '\xcd', '\xce', '\xcf' /* 200 - 207 */ - ,'\xd0', '\xd1', '\xd2', '\xd3', '\xd4', '\xd5', '\xd6', '\xd7' /* 208 - 215 */ - ,'\xd8', '\xd9', '\xda', '\xdb', '\xdc', '\xdd', '\xde', '\xdf' /* 216 - 223 */ - ,'\xe0', 'S', '\xe2', '\xe3', '\xe4', '\xe5', '\xe6', '\xe7' /* 224 - 231 */ - ,'\xe8', '\xe9', '\xea', '\xeb', '\xec', '\xed', '\xee', '\xef' /* 232 - 239 */ - ,'\xf0', '\xf1', '\xf2', '\xf3', '\xf4', '\xf5', '\xf6', '\xf7' /* 240 - 247 */ - ,'\xf8', '\xf9', '\xfa', '\xfb', '\xfc', '\xfd', '\xfe', '\xff' /* 248 - 255 */ - } - , - 0, /* no DBC support */ - 0, /* DBC end marker */ - { - 22, /* size of permittable character structure */ - 1, /* reserved */ - '\x00', '\xff', /* first/last permittable character */ - 0, /* reserved */ - '\x00', ' ', /* first/last excluded character */ - 2, /* reserved */ - 14, /* number of separators */ - { /* separators */ - '.', '"', '/', '\\', '[', ']', ':', '|', /* 0 - 7 */ - '<', '>', '+', '=', ';', ',' /* 8 - 13 */ - } - } -} diff --git a/kernel/config.c b/kernel/config.c index 2a57f1ef..9596cb13 100644 --- a/kernel/config.c +++ b/kernel/config.c @@ -39,6 +39,9 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.6 2000/08/06 05:50:17 jimtabor + * Add new files and update cvs with patches and changes + * * Revision 1.5 2000/06/21 18:16:46 jimtabor * Add UMB code, patch, and code fixes * @@ -148,12 +151,14 @@ static BYTE FAR *lpOldLast; static BYTE FAR *upOldLast; static COUNT nCfgLine; static COUNT nPass; +static COUNT UmbState; static BYTE szLine[256]; static BYTE szBuf[256]; int singleStep = 0; INIT VOID zumcb_init(mcb FAR * mcbp, UWORD size); +INIT VOID mumcb_init(mcb FAR * mcbp, UWORD size); INIT VOID Buffers(BYTE * pLine); INIT VOID sysScreenMode(BYTE * pLine); @@ -201,7 +206,7 @@ static struct table commands[] = {"country", 1, Country}, {"device", 2, Device}, {"devicehigh", 2, DeviceHigh}, - {"dos", 1, Dosmem}, + {"dos", 2, Dosmem}, {"fcbs", 1, Fcbs}, {"files", 1, Files}, {"lastdrive", 1, Lastdrive}, @@ -229,6 +234,8 @@ INIT void PreConfig(void) { /* Set pass number */ nPass = 0; + VgaSet = 0; + UmbState = 0; /* Initialize the base memory pointers */ lpOldLast = lpBase = AlignParagraph((BYTE FAR *) & last); @@ -301,9 +308,6 @@ INIT void PreConfig(void) /* Also, run config.sys to load drivers. */ INIT void PostConfig(void) { - - COUNT tmp = 0xc000; - /* Set pass number */ nPass = 2; /* compute lastdrive ... */ @@ -368,19 +372,6 @@ INIT void PostConfig(void) FP_SEG(lpBase), FP_OFF(lpBase)); #endif - if(uppermem_link) - { - upBase = MK_FP(tmp , 0); - uppermem_root = FP_SEG(upBase) + ((FP_OFF(upBase) + 0x0f) >> 4); - umcb_init((mcb FAR *) (MK_FP(uppermem_root, 0)), 0 ); - - upBase += 16; - -#ifdef DEBUG - printf("UMB Allocation completed: top at 0x%04x:0x%04x\n", - FP_SEG(upBase), FP_OFF(upBase)); -#endif - } } @@ -403,15 +394,34 @@ INIT VOID configDone(VOID) mcb_init((mcb FAR *) (MK_FP(first_mcb, 0)), (ram_top << 6) - first_mcb - 1); - if(uppermem_link) + if(UmbState == 1) { - uppermem_root = FP_SEG(upBase) + ((FP_OFF(upBase) + 0x0f) >> 4); - zumcb_init((mcb FAR *) (MK_FP(uppermem_root, 0)), - (UMB_top << 6) - uppermem_root - 1); + + mumcb_init((mcb FAR *) (MK_FP(0x9fff, 0)), + umb_start - 0x9fff); + +/* make last end of mem block normal with SC */ + + mumcb_init((mcb FAR *) (MK_FP(uppermem_root, 0)), + (FP_SEG(upBase) + ((FP_OFF(upBase) + 0x0f) >> 4)) - uppermem_root - 1); + + uppermem_root = FP_SEG(upBase) + ((FP_OFF(upBase) + 0x0f) >> 4); + + zumcb_init((mcb FAR *) (MK_FP(uppermem_root, 0)), + (umb_start + UMB_top ) - uppermem_root - 1); + upBase += 16; + } +#ifdef DEBUG + printf("UMB Allocation completed: top at 0x%04x:0x%04x\n", + FP_SEG(upBase), FP_OFF(upBase)); +#endif + /* The standard handles should be reopened here, because we may have loaded new console or printer drivers in CONFIG.SYS */ + + } INIT VOID DoConfig(VOID) @@ -484,6 +494,37 @@ INIT VOID DoConfig(VOID) while (!bEof && *pLine != EOF) { +/* + Do it here in the loop. +*/ + if(UmbState == 2){ + if(!Umb_Test()){ + UmbState = 1; + upBase = MK_FP(umb_start , 0); + uppermem_root = umb_start; + +/* master sig for umb region with full size */ + + umcb_init((mcb FAR *) upBase, UMB_top ); + upBase += 16; + +/* reset root */ + + uppermem_root = FP_SEG(upBase) + ((FP_OFF(upBase) + 0x0f) >> 4); + +/* setup the real mcb for the devicehigh block */ + + zumcb_init((mcb FAR *) (MK_FP(uppermem_root, 0)), UMB_top - 1); + upBase += 16; + +#ifdef DEBUG + printf("UMB Allocation completed: top at 0x%04x:0x%04x\n", + FP_SEG(upBase), FP_OFF(upBase)); +#endif + } + } + + for (pTmp = pLine; pTmp - szLine < LINESIZE; pTmp++) { if (*pTmp == '\r' || *pTmp == EOF) @@ -676,22 +717,17 @@ INIT static VOID Lastdrive(BYTE * pLine) Config.cfgLastdrive = max(Config.cfgLastdrive, drv); } +/* + UmbState of confidence, 1 is sure, 2 maybe, 4 unknown and 0 no way. +*/ + INIT static VOID Dosmem(BYTE * pLine) { - COUNT tmp; - COUNT FAR * u = MK_FP(0xc000, 0); - + if(UmbState == 0){ + uppermem_link = 0; + uppermem_root = 0; GetStringArg(pLine, szBuf); - uppermem_link = strcmp(szBuf, "UMB") ? 1 : 0; - - if(uppermem_link) - { - tmp = *u; - *u = 0x1234; - if(*u == 0x1234) - *u = tmp; - else - uppermem_link = 0; + UmbState = strcmp(szBuf, "UMB") ? 2 : 0; } } @@ -827,7 +863,7 @@ INIT static VOID Break(BYTE * pLine) INIT static VOID DeviceHigh(BYTE * pLine) { - if(uppermem_link) + if(UmbState == 1) { LoadDevice(pLine, UMB_top, TRUE); } @@ -1036,23 +1072,34 @@ INIT VOID mcbp->m_type = MCB_LAST; mcbp->m_psp = FREE_PSP; + +/* if(UmbState == 1)*/ + + mcbp->m_size = (size - 1); +/* mcbp->m_size = size; +*/ for (i = 0; i < 8; i++) mcbp->m_name[i] = '\0'; mem_access_mode = FIRST_FIT; } + +/* master umb sig */ + INIT VOID umcb_init(mcb FAR * mcbp, UWORD size) { COUNT i; static char name[8] = "UMB "; - mcbp->m_type = 0x4d; - mcbp->m_psp = 0x08; + mcbp->m_type = MCB_LAST; + mcbp->m_psp = (UWORD) FP_SEG( mcbp ); + mcbp->m_psp++; mcbp->m_size = size; for (i = 0; i < 8; i++) mcbp->m_name[i] = name[i]; } + INIT VOID zumcb_init(mcb FAR * mcbp, UWORD size) { @@ -1061,6 +1108,19 @@ INIT VOID mcbp->m_psp = FREE_PSP; mcbp->m_size = size; } + +INIT VOID + mumcb_init(mcb FAR * mcbp, UWORD size) +{ + COUNT i; + static char name[8] = "SC\0\0\0\0\0\0"; + + mcbp->m_type = MCB_NORMAL; + mcbp->m_psp = 8; + mcbp->m_size = size; + for (i = 0; i < 8; i++) + mcbp->m_name[i] = name[i]; +} #endif INIT VOID @@ -1071,3 +1131,4 @@ INIT VOID strcpy(d, s); } + diff --git a/kernel/config.h b/kernel/config.h new file mode 100644 index 00000000..0a800fa8 --- /dev/null +++ b/kernel/config.h @@ -0,0 +1,38 @@ +/****************************************************************/ +/* */ +/* config.h */ +/* DOS-C */ +/* */ +/* Global data structures and declarations */ +/* */ +/* Copyright (c) 2000 */ +/* Steffen Kaiser */ +/* All Rights Reserved */ +/* */ +/* This file is part of DOS-C. */ +/* */ +/* DOS-C is free software; you can redistribute it and/or */ +/* modify it under the terms of the GNU General Public License */ +/* as published by the Free Software Foundation; either version */ +/* 2, or (at your option) any later version. */ +/* */ +/* DOS-C is distributed in the hope that it will be useful, but */ +/* WITHOUT ANY WARRANTY; without even the implied warranty of */ +/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See */ +/* the GNU General Public License for more details. */ +/* */ +/* You should have received a copy of the GNU General Public */ +/* License along with DOS-C; see the file COPYING. If not, */ +/* write to the Free Software Foundation, 675 Mass Ave, */ +/* Cambridge, MA 02139, USA. */ +/****************************************************************/ + + +#ifdef DEBUG + /* Enable debugging of NLS part */ + + /* Caution: Enabling NLS debugging usually generates + _a_lot_ of noise. */ +/*& #define NLS_DEBUG */ + +#endif diff --git a/kernel/dosfns.c b/kernel/dosfns.c index ce3727ab..38c23b8e 100644 --- a/kernel/dosfns.c +++ b/kernel/dosfns.c @@ -34,6 +34,9 @@ static BYTE *dosfnsRcsId = "$Id$"; /* * $Log$ + * Revision 1.8 2000/08/06 05:50:17 jimtabor + * Add new files and update cvs with patches and changes + * * Revision 1.7 2000/06/21 18:16:46 jimtabor * Add UMB code, patch, and code fixes * @@ -814,6 +817,15 @@ COUNT DosOpen(BYTE FAR * fname, COUNT mode) WORD i; COUNT drive, result; +/* /// Added to adjust for filenames which begin with ".\" + The problem was manifesting itself in the inability + to run an program whose filename (without the extension) + was longer than six characters and the PATH variable + contained ".", unless you explicitly specified the full + path to the executable file. + Jun 11, 2000 - rbc */ + if ( (fname[0] == '.') && (fname[1] == '\\') ) fname += 2; + /* test if mode is in range */ if ((mode & ~SFT_OMASK) != 0) return DE_INVLDACC; @@ -1170,7 +1182,17 @@ COUNT DosGetFattr(BYTE FAR * name, UWORD FAR * attrp) return result; } - if (CDSp->cds_table[drive].cdsFlags & CDSNETWDRV) +/* /// Added check for "d:\", which returns 0x10 (subdirectory) under DOS. + - Ron Cemer */ + if ( (PriPathName[0] != '\0') + && (PriPathName[1] == ':') + && ( (PriPathName[2] == '/') || (PriPathName[2] == '\\') ) + && (PriPathName[3] == '\0') ) { + *attrp = 0x10; + return SUCCESS; + } + + if (CDSp->cds_table[drive].cdsFlags & CDSNETWDRV) { last_cds = current_ldt; current_ldt = &CDSp->cds_table[drive]; @@ -1180,8 +1202,21 @@ COUNT DosGetFattr(BYTE FAR * name, UWORD FAR * attrp) *attrp = srfa[0]; } else { - result = dos_getfattr(name, attrp); +/* /// Use truename()'s result, which we already have in PriPathName. + I copy it to tmp_name because PriPathName is global and seems + to get trashed somewhere in transit. + The reason for using truename()'s result is that dos_?etfattr() + are very low-level functions and don't handle full path expansion + or cleanup, such as converting "c:\a\b\.\c\.." to "C:\A\B". + - Ron Cemer +*/ + BYTE tmp_name[128]; + int i; + for (i = 0; PriPathName[i] != '\0'; i++) tmp_name[i] = PriPathName[i]; + tmp_name[i] = '\0'; + result = dos_getfattr(tmp_name, attrp); } +/* Sorry Ron someone else found this, see history.txt */ return result; } @@ -1214,7 +1249,16 @@ COUNT DosSetFattr(BYTE FAR * name, UWORD FAR * attrp) current_ldt = last_cds; } else { - result = dos_setfattr(name, attrp); +/* /// Use truename()'s result, which we already have in PriPathName. + I copy it to tmp_name because PriPathName is global and seems + to get trashed somewhere in transit. + - Ron Cemer +*/ + BYTE tmp_name[128]; + int i; + for (i = 0; PriPathName[i] != '\0'; i++) tmp_name[i] = PriPathName[i]; + tmp_name[i] = '\0'; + result = dos_setfattr(name, attrp); } return result; } @@ -1362,9 +1406,16 @@ struct dhdr FAR * IsDevice(BYTE FAR * fname) SecPathName[i] = ' '; SecPathName[i] = 0; - /* if we have an extension, can't be a device */ + +/* /// BUG!!! This is absolutely wrong. A filename of "NUL.LST" must be + treated EXACTLY the same as a filename of "NUL". The existence or + content of the extension is irrelevent in determining whether a + filename refers to a device. + - Ron Cemer + // if we have an extension, can't be a device <--- WRONG. if (*froot != '.') { +*/ for (dhp = (struct dhdr FAR *)&nul_dev; dhp != (struct dhdr FAR *)-1; dhp = dhp->dh_next) { if (fnmatch((BYTE FAR *) SecPathName, (BYTE FAR *) dhp->dh_name, FNAME_SIZE, FALSE)) @@ -1372,7 +1423,7 @@ struct dhdr FAR * IsDevice(BYTE FAR * fname) return dhp; } } - } + return (struct dhdr FAR *)0; } diff --git a/kernel/fatdir.c b/kernel/fatdir.c index 760d3434..d005fbab 100644 --- a/kernel/fatdir.c +++ b/kernel/fatdir.c @@ -36,6 +36,9 @@ static BYTE *fatdirRcsId = "$Id$"; /* * $Log$ + * Revision 1.9 2000/08/06 05:50:17 jimtabor + * Add new files and update cvs with patches and changes + * * Revision 1.8 2000/06/21 18:16:46 jimtabor * Add UMB code, patch, and code fixes * @@ -291,7 +294,7 @@ struct f_node FAR *dir_open(BYTE FAR * dirname) /* find the entry... */ i = FALSE; - upFMem((BYTE FAR *) TempBuffer, FNAME_SIZE + FEXT_SIZE); + DosUpFMem((BYTE FAR *) TempBuffer, FNAME_SIZE + FEXT_SIZE); while (dir_read(fnp) == DIRENT_SIZE) { @@ -592,7 +595,7 @@ COUNT dos_findfirst(UCOUNT attr, BYTE FAR * name) /* current directory, do a seek and read, then close the fnode. */ /* Start out by initializing the dirmatch structure. */ - dmp->dm_drive = default_drive; + dmp->dm_drive = default_drive ; dmp->dm_entry = 0; dmp->dm_cluster = 0; @@ -609,7 +612,7 @@ COUNT dos_findfirst(UCOUNT attr, BYTE FAR * name) */ if (nDrive >= 0) { - dmp->dm_drive = nDrive; + dmp->dm_drive = nDrive ; } else nDrive = default_drive; @@ -652,7 +655,7 @@ COUNT dos_findfirst(UCOUNT attr, BYTE FAR * name) SearchDir.dir_ext[i] = ' '; /* Convert everything to uppercase. */ - upFMem(SearchDir.dir_name, FNAME_SIZE + FEXT_SIZE); + DosUpFMem(SearchDir.dir_name, FNAME_SIZE + FEXT_SIZE); /* Copy the raw pattern from our data segment to the DTA. */ fbcopy((BYTE FAR *) SearchDir.dir_name, dmp->dm_name_pat, @@ -666,6 +669,56 @@ COUNT dos_findfirst(UCOUNT attr, BYTE FAR * name) return SUCCESS; } + /* /// Added code here to do matching against device names. + DOS findfirst will match exact device names if the + filename portion (excluding the extension) contains + a valid device name. + Credits: some of this code was ripped off from truename() + in newstuff.c. + - Ron Cemer */ + if (!(attr & D_VOLID)) { + char Name[FNAME_SIZE]; + int d, wild = 0; + for (d = 0; d < FNAME_SIZE; d++) { + if ((Name[d] = SearchDir.dir_name[d]) == '?') { + wild = 1; + break; + } + } + if (!wild) { + struct dhdr FAR *dhp; + for (dhp = (struct dhdr FAR *)&nul_dev; + dhp != (struct dhdr FAR *)-1; + dhp = dhp->dh_next) { + if (fnmatch + ((BYTE FAR *)&Name, + (BYTE FAR *)dhp->dh_name, + FNAME_SIZE, + FALSE)) { + /* Found a matching device. */ + dmp->dm_entry = 0; + dmp->dm_cluster = 0; + dmp->dm_flags.f_dmod = 0; + dmp->dm_flags.f_droot = 0; + dmp->dm_flags.f_dnew = 0; + dmp->dm_flags.f_ddir = 0; + dmp->dm_flags.f_dfull = 0; + dmp->dm_dirstart = 0; + dmp->dm_attr_fnd = D_DEVICE; + dmp->dm_time = dos_gettime(); + dmp->dm_date = dos_getdate(); + dmp->dm_size = 0L; + for (d = 0; ( (d < FNAME_SIZE) && (Name[d] != ' ') ); d++) + dmp->dm_name[d] = Name[d]; + dmp->dm_name[d] = '\0'; + return SUCCESS; + } + } + } + } + /* /// End of additions. - Ron Cemer */ + + /* Now search through the directory to find the entry... */ /* Special handling - the volume id is only in the root */ /* directory and only searched for once. So we need to open */ @@ -741,6 +794,9 @@ COUNT dos_findnext(void) /* assign our match parameters pointer. */ dmp = (dmatch FAR *) dta; + /* /// findnext will always fail on a device name. - Ron Cemer */ + if (dmp->dm_attr_fnd == D_DEVICE) return DE_FILENOTFND; + /* * The new version of SHSUCDX 1.0 looks at the dm_drive byte to * test 40h. I used RamView to see location MSD 116:04be and @@ -752,7 +808,7 @@ COUNT dos_findnext(void) * So, assume bit 6 is redirector and bit 7 is network. * jt */ - nDrive = dmp->dm_drive & 0x1f; + nDrive = dmp->dm_drive & 0x1f; if (nDrive > (lastdrive -1)) { return DE_INVLDDRV; @@ -780,7 +836,7 @@ COUNT dos_findnext(void) /* Force the fnode into read-write mode */ fnp->f_mode = RDWR; - if (dmp->dm_drive > (lastdrive -1)) { + if (dmp->dm_drive > (lastdrive)) { return DE_INVLDDRV; } /* Select the default to help non-drive specified path */ diff --git a/kernel/fatfs.c b/kernel/fatfs.c index 2d25f773..e6a9241e 100644 --- a/kernel/fatfs.c +++ b/kernel/fatfs.c @@ -36,6 +36,9 @@ BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.6 2000/08/06 05:50:17 jimtabor + * Add new files and update cvs with patches and changes + * * Revision 1.5 2000/06/21 18:16:46 jimtabor * Add UMB code, patch, and code fixes * @@ -377,9 +380,9 @@ static struct f_node FAR * } /* Convert the name into an absolute name for comparison... */ - upFMem((BYTE FAR *) dname, strlen(dname)); - upFMem((BYTE FAR *) fname, FNAME_SIZE); - upFMem((BYTE FAR *) fext, FEXT_SIZE); + DosUpFString((BYTE FAR *) dname); + DosUpFMem((BYTE FAR *) fname, FNAME_SIZE); + DosUpFMem((BYTE FAR *) fext, FEXT_SIZE); return fnp; } diff --git a/kernel/fcbfns.c b/kernel/fcbfns.c index 7e91cd12..9d474a85 100644 --- a/kernel/fcbfns.c +++ b/kernel/fcbfns.c @@ -35,6 +35,9 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.6 2000/08/06 05:50:17 jimtabor + * Add new files and update cvs with patches and changes + * * Revision 1.5 2000/06/21 18:16:46 jimtabor * Add UMB code, patch, and code fixes * @@ -223,7 +226,7 @@ WORD FcbParseFname(int wTestMode, BYTE FAR ** lpFileName, fcb FAR * lpFcb) /* Now check for drive specification */ if (*(*lpFileName + 1) == ':') { - REG BYTE Drive = upChar(**lpFileName); + REG BYTE Drive = DosUpFChar(**lpFileName); /* non-portable construct to be changed */ if (Drive < 'A' || Drive > 'Z') @@ -299,7 +302,7 @@ BYTE FAR *GetNameField(BYTE FAR * lpFileName, BYTE FAR * lpDestField, } if (*lpFileName == '?') *pbWildCard = TRUE; - *lpDestField++ = upChar(*lpFileName++); + *lpDestField++ = DosUpFChar(*lpFileName++); ++nIndex; } @@ -476,7 +479,6 @@ BOOL FcbGetFileSize(xfcb FAR * lpXfcb) lpFcb = CommonFcbInit(lpXfcb, PriPathName, &FcbDrive); /* check for a device */ - /* if we have an extension, can't be a device */ if (IsDevice(PriPathName) || (lpFcb->fcb_recsiz == 0)) { return FALSE; @@ -645,7 +647,6 @@ BOOL FcbCreate(xfcb FAR * lpXfcb) lpFcb = CommonFcbInit(lpXfcb, PriPathName, &FcbDrive); /* check for a device */ - /* if we have an extension, can't be a device */ dhp = IsDevice(PriPathName); if (dhp) { @@ -781,7 +782,6 @@ BOOL FcbOpen(xfcb FAR * lpXfcb) lpFcb = CommonFcbInit(lpXfcb, PriPathName, &FcbDrive); /* check for a device */ - /* if we have an extension, can't be a device */ dhp = IsDevice(PriPathName); if (dhp ) { @@ -858,7 +858,6 @@ BOOL FcbDelete(xfcb FAR * lpXfcb) } /* check for a device */ - /* if we have an extension, can't be a device */ if (IsDevice(PriPathName)) { return FALSE; @@ -897,7 +896,6 @@ BOOL FcbRename(xfcb FAR * lpXfcb) lpRenameFcb = (rfcb FAR *) CommonFcbInit(lpXfcb, PriPathName, &FcbDrive); /* check for a device */ - /* if we have an extension, can't be a device */ if (IsDevice(PriPathName)) { return FALSE; @@ -1108,7 +1106,7 @@ BOOL FcbFindFirst(xfcb FAR * lpXfcb) dta = (BYTE FAR *) & Dmatch; /* Next initialze local variables by moving them from the fcb */ - lpFcb = CommonFcbInit(lpXfcb, PriPathName, &FcbDrive); + lpFcb = CommonFcbInit(lpXfcb, SecPathName, &FcbDrive); if (lpXfcb->xfcb_flag == 0xff) { wAttr = lpXfcb->xfcb_attrib; @@ -1118,8 +1116,10 @@ BOOL FcbFindFirst(xfcb FAR * lpXfcb) else wAttr = D_ALL; - *lpDir++ = PriPathName[0] - 'A'; - if (dos_findfirst(wAttr, PriPathName) != SUCCESS) + *lpDir++ = FcbDrive; + + + if (dos_findfirst(wAttr, SecPathName) != SUCCESS) { dta = lpPsp->ps_dta; return FALSE; @@ -1129,16 +1129,19 @@ BOOL FcbFindFirst(xfcb FAR * lpXfcb) lpFcb->fcb_dirclst = Dmatch.dm_cluster; lpFcb->fcb_diroff = Dmatch.dm_entry; + /* - This is undocumented and seen using Pcwatch. + This is undocumented and seen using Pcwatch and Ramview. The First byte is the current directory count and the second seems to be the attribute byte. */ + lpFcb->fcb_sftno = Dmatch.dm_drive; /* MSD seems to save this @ fcb_date.*/ #if 0 lpFcb->fcb_cublock = Dmatch.dm_entry; lpFcb->fcb_cublock *= 0x100; lpFcb->fcb_cublock += wAttr; #endif + dta = lpPsp->ps_dta; return TRUE; } @@ -1157,7 +1160,7 @@ BOOL FcbFindNext(xfcb FAR * lpXfcb) dta = (BYTE FAR *) & Dmatch; /* Next initialze local variables by moving them from the fcb */ - lpFcb = CommonFcbInit(lpXfcb, PriPathName, &FcbDrive); + lpFcb = CommonFcbInit(lpXfcb, SecPathName, &FcbDrive); if ((xfcb FAR *) lpFcb != lpXfcb) { wAttr = lpXfcb->xfcb_attrib; @@ -1169,10 +1172,10 @@ BOOL FcbFindNext(xfcb FAR * lpXfcb) /* Reconstrct the dirmatch structure from the fcb */ *lpDir++ = FcbDrive; - Dmatch.dm_drive = FcbDrive ? FcbDrive - 1 : default_drive; + Dmatch.dm_drive = lpFcb->fcb_sftno; fbcopy(lpFcb->fcb_fname, (BYTE FAR *) Dmatch.dm_name_pat, FNAME_SIZE + FEXT_SIZE); - upFMem((BYTE FAR *) Dmatch.dm_name_pat, FNAME_SIZE + FEXT_SIZE); + DosUpFMem((BYTE FAR *) Dmatch.dm_name_pat, FNAME_SIZE + FEXT_SIZE); Dmatch.dm_attr_srch = wAttr; Dmatch.dm_entry = lpFcb->fcb_diroff; @@ -1188,13 +1191,17 @@ BOOL FcbFindNext(xfcb FAR * lpXfcb) MoveDirInfo((dmatch FAR *) & Dmatch, (struct dirent FAR *)lpDir); lpFcb->fcb_dirclst = Dmatch.dm_cluster; lpFcb->fcb_diroff = Dmatch.dm_entry; - dta = lpPsp->ps_dta; + + lpFcb->fcb_sftno = Dmatch.dm_drive; #if 0 lpFcb->fcb_cublock = Dmatch.dm_entry; lpFcb->fcb_cublock *= 0x100; lpFcb->fcb_cublock += wAttr; #endif + + dta = lpPsp->ps_dta; return TRUE; } #endif + diff --git a/kernel/globals.h b/kernel/globals.h index 7f4126de..5c1dbdda 100644 --- a/kernel/globals.h +++ b/kernel/globals.h @@ -36,8 +36,8 @@ static BYTE *Globals_hRcsId = "$Id$"; /* * $Log$ - * Revision 1.4 2000/06/21 18:16:46 jimtabor - * Add UMB code, patch, and code fixes + * Revision 1.5 2000/08/06 05:50:17 jimtabor + * Add new files and update cvs with patches and changes * * Revision 1.3 2000/05/25 20:56:21 jimtabor * Fixed project history @@ -180,6 +180,7 @@ static BYTE *Globals_hRcsId = "$Id$"; #include "error.h" #include "version.h" #include "network.h" +#include "config.h" /* JPP: for testing/debuging disk IO */ /*#define DISPLAY_GETBLOCK */ @@ -424,6 +425,7 @@ extern BYTE NetDelay, extern UWORD first_mcb, /* Start of user memory */ UMB_top, + umb_start, uppermem_root; /* Start of umb chain ? */ extern struct dpb FAR *DPBp; /* First drive Parameter Block */ @@ -462,6 +464,7 @@ extern BYTE CritErrLocus, CritErrAction, CritErrClass, + VgaSet, njoined; /* number of joined devices */ extern UWORD Int21AX; @@ -609,8 +612,17 @@ GLOBAL struct config BYTE cfgLastdrive; /* last drive */ BYTE cfgStacks; /* number of stacks */ UWORD cfgStackSize; /* stacks size for each stack */ -} -Config + /* COUNTRY= + In Pass #1 these information is collected and in PostConfig() + the NLS package is loaded into memory. + -- 2000/06/11 ska*/ + WORD cfgCSYS_cntry; /* country ID to be loaded */ + WORD cfgCSYS_cp; /* requested codepage; NLS_DEFAULT if default */ + BYTE cfgCSYS_fnam[NAMEMAX]; /* filename of COUNTRY= */ + WORD cfgCSYS_memory; /* number of bytes required for the NLS pkg; + 0 if none */ + VOID FAR *cfgCSYS_data; /* where the loaded data is for PostConfig() */ +} Config #ifdef MAIN = { @@ -623,6 +635,12 @@ Config NLAST, NSTACKS, 128 + /* COUNTRY= is initialized within DoConfig() */ + ,0 /* country ID */ + ,0 /* codepage */ + ,"" /* filename */ + ,0 /* amount required memory */ + ,0 /* pointer to loaded data */ }; #else ; diff --git a/kernel/int2f.asm b/kernel/int2f.asm index 273d5537..64b55e95 100644 --- a/kernel/int2f.asm +++ b/kernel/int2f.asm @@ -30,6 +30,9 @@ ; $Id$ ; ; $Log$ +; Revision 1.6 2000/08/06 05:50:17 jimtabor +; Add new files and update cvs with patches and changes +; ; Revision 1.5 2000/06/21 18:16:46 jimtabor ; Add UMB code, patch, and code fixes ; @@ -83,9 +86,13 @@ ; %include "segs.inc" + %include "stacks.inc" segment _TEXT - extern _nul_dev:wrt DGROUP + extern _nul_dev:wrt DGROUP + extern _umb_start:wrt DGROUP + extern _UMB_top:wrt DGROUP + extern _syscall_MUX14:wrt _TEXT global _int2f_handler _int2f_handler: @@ -107,8 +114,27 @@ Int2f3: cmp ah,10h ; SHARE.EXE interrupt? je Int2f1 ; yes, do installation check cmp ah,14h ; NLSFUNC.EXE interrupt? - je Int2f1 ; yes, do installation check - iret ; Default, interrupt return + jne Int2f?iret ; yes, do installation check +Int2f?14: ;; MUX-14 -- NLSFUNC API + ;; all functions are passed to syscall_MUX14 + push bp ; Preserve BP later on + PUSH$ALL + call _syscall_MUX14 + pop bp ; Discard incoming AX + push ax ; Correct stack for POP$ALL + POP$ALL + mov bp, sp + or ax, ax + jnz Int2f?14?1 ; must return set carry + ;; -6 == -2 (CS), -2 (IP), -2 (flags) + ;; current SP = on old_BP + and BYTE [bp-6], 0feh ; clear carry as no error condition + pop bp + iret +Int2f?14?1: or BYTE [bp-6], 1 + pop bp +Int2f?iret: + iret ; ;return dos data seg. @@ -285,3 +311,97 @@ int2f_call: pop bp pop bp ret +; +; Test to see if a umb driver has been loaded. +; +; From RB list and Dosemu xms.c. +; +; Call the XMS driver "Request upper memory block" function with: +; AH = 10h +; DX = size of block in paragraphs +; Return: AX = status +; 0001h success +; BX = segment address of UMB +; DX = actual size of block +; 0000h failure +; BL = error code (80h,B0h,B1h) (see #02775) +; DX = largest available block +; +; (Table 02775) +; Values for XMS error code returned in BL: +; 00h successful +; 80h function not implemented +; B0h only a smaller UMB is available +; B1h no UMB's are available +; B2h UMB segment number is invalid +; +; + global _Umb_Test +_Umb_Test + push bp + mov bp,sp + push es + push ds + push dx + push bx + + mov ax,DGROUP + mov ds,ax + + mov ax,4300h ; is there a xms driver installed? + int 2fh + cmp al,80h + jne umbt_error + + mov ax,4310h + int 2fh + + push es ; save driver entry point + push bx + + mov dx,0xffff ; go for broke! + mov ax,1000h ; get the umb's + push cs ; setup far return + push word umbt1 + push es ; push the driver entry point + push bx + retf ; Call the driver +umbt1: +; +; bl = 0xB0 and ax = 0 so do it again. +; + cmp bl,0xb0 ; fail safe + je umbtb + add sp,4 + jmp umbt_error +umbtb: + and dx,dx ; if it returns a size of zero. + jne umbtc + add sp,4 + jmp umbt_error + +umbtc: + pop bx ; restore driver entry + pop es + + mov ax,1000h ; dx set with largest size + push cs + push word umbt2 + push es + push bx + retf +umbt2: + cmp ax,1 + jne umbt_error + + mov word [_umb_start], bx ; save the segment + mov word [_UMB_top], dx ; and the true size + +umbt_error: dec ax + + pop bx + pop dx + pop ds + pop es + pop bp + retf ; this was called FAR. diff --git a/kernel/inthndlr.c b/kernel/inthndlr.c index 3bf0bc48..55b8930f 100644 --- a/kernel/inthndlr.c +++ b/kernel/inthndlr.c @@ -36,6 +36,9 @@ BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.9 2000/08/06 05:50:17 jimtabor + * Add new files and update cvs with patches and changes + * * Revision 1.8 2000/06/21 18:16:46 jimtabor * Add UMB code, patch, and code fixes * @@ -194,12 +197,15 @@ static VOID StartTrace(VOID); static bTraceNext = FALSE; #endif +#if 0 /* Very suspicious, passing structure by value?? + Deactivated -- 2000/06/16 ska*/ /* Special entry for far call into the kernel */ #pragma argsused VOID FAR int21_entry(iregs UserRegs) { int21_handler(UserRegs); } +#endif /* Normal entry. This minimizes user stack usage by avoiding local */ /* variables needed for the rest of the handler. */ @@ -342,25 +348,7 @@ VOID int21_service(iregs FAR * r) r->FLAGS |= FLG_CARRY; break; -#if 0 - /* Moved to simulate a 0x4c00 -- 1999/04/21 ska */ - /* Terminate Program */ - case 0x00: - if (cu_psp == RootPsp) - break; - else if (((psp FAR *) (MK_FP(cu_psp, 0)))->ps_parent == cu_psp) - break; - tsr = FALSE; - return_mode = break_flg ? 1 : 0; - return_code = r->AL; - if (DosMemCheck() != SUCCESS) - panic("MCB chain corrupted"); -#ifdef TSC - StartTrace(); -#endif - return_user(); - break; -#endif + /* case 0x00: --> Simulate a DOS-4C-00 */ /* Read Keyboard with Echo */ case 0x01: @@ -862,11 +850,11 @@ VOID int21_service(iregs FAR * r) if (0xffff == r->DX) { /* Set Country Code */ - if((rc = setCountryCode(cntry)) < 0) + if((rc = DosSetCountry(cntry)) < 0) goto error_invalid; } else { /* Get Country Information */ - if((rc = getCountryInformation(cntry, MK_FP(r->DS, r->DX))) < 0) + if((rc = DosGetCountryInformation(cntry, MK_FP(r->DS, r->DX))) < 0) goto error_invalid; r->AX = r->BX = cntry; } @@ -1277,23 +1265,35 @@ VOID int21_service(iregs FAR * r) break; case 0x01: -/* if (((COUNT) r->BX) < 0 || r->BX > 2) - goto error_invalid; - else - { */ - - mem_access_mode = r->BX; + { + switch (r->BX) + { + case LAST_FIT: + case LAST_FIT_U: + case LAST_FIT_UO: + case LARGEST: + case BEST_FIT: + case BEST_FIT_U: + case BEST_FIT_UO: + case FIRST_FIT: + case FIRST_FIT_U: + case FIRST_FIT_UO: + mem_access_mode = r->BX; + break; + + default: + goto error_invalid; + } + } r->FLAGS &= ~FLG_CARRY; - -/* }*/ - break; + break; case 0x02: r->AL = uppermem_link; break; case 0x03: - uppermem_link = r->BL; + DosUmbLink(r->BL); break; default: @@ -1510,31 +1510,39 @@ VOID int21_service(iregs FAR * r) case 0x65: switch(r->AL) { case 0x20: /* upcase single character */ - r->DL = upChar(r->DL); + r->DL = DosUpChar(r->DL); break; case 0x21: /* upcase memory area */ - upMem(MK_FP(r->DS, r->DX), r->CX); + DosUpMem(MK_FP(r->DS, r->DX), r->CX); break; case 0x22: /* upcase ASCIZ */ - upString(MK_FP(r->DS, r->DX)); + DosUpString(MK_FP(r->DS, r->DX)); break; case 0xA0: /* upcase single character of filenames */ - r->DL = upFChar(r->DL); + r->DL = DosUpFChar(r->DL); break; case 0xA1: /* upcase memory area of filenames */ - upFMem(MK_FP(r->DS, r->DX), r->CX); + DosUpFMem(MK_FP(r->DS, r->DX), r->CX); break; case 0xA2: /* upcase ASCIZ of filenames */ - upFString(MK_FP(r->DS, r->DX)); + DosUpFString(MK_FP(r->DS, r->DX)); break; case 0x23: /* check Yes/No response */ - r->AX = yesNo(r->DL); + r->AX = DosYesNo(r->DL); break; default: - if ((rc = extCtryInfo( + if ((rc = DosGetData( r->AL, r->BX, r->DX, r->CX, - MK_FP(r->ES, r->DI))) < 0) - goto error_exit; + MK_FP(r->ES, r->DI))) < 0) { +#ifdef NLS_DEBUG + printf("DosGetData() := %d\n", rc); +#endif + goto error_exit; + } +#ifdef NLS_DEBUG + printf("DosGetData() returned successfully\n", rc); +#endif + break; } r->FLAGS &= ~FLG_CARRY; @@ -1546,10 +1554,10 @@ VOID int21_service(iregs FAR * r) switch (r->AL) { case 1: - rc = getCodePage(&r->BX, &r->DX); + rc = DosGetCodepage(&r->BX, &r->DX); break; case 2: - rc = setCodePage(r->BX, r->DX); + rc = DosSetCodepage(r->BX, r->DX); break; default: diff --git a/kernel/kernel.asm b/kernel/kernel.asm index 63eec195..9cfba57b 100644 --- a/kernel/kernel.asm +++ b/kernel/kernel.asm @@ -28,6 +28,9 @@ ; $Id$ ; ; $Log$ +; Revision 1.5 2000/08/06 05:50:17 jimtabor +; Add new files and update cvs with patches and changes +; ; Revision 1.4 2000/06/21 18:16:46 jimtabor ; Add UMB code, patch, and code fixes ; @@ -307,7 +310,8 @@ deblock_seg dw 0 ; 0056 (offset always zero) times 3 db 0 ; 0058 unknown dw 0 ; 005B unknown db 0, 0FFh, 0 ; 005D unknown - db 0 ; 0060 unknown + global _VgaSet +_VgaSet db 0 ; 0060 unknown dw 0 ; 0061 unknown global _uppermem_link _uppermem_link db 0 ; 0063 upper memory link flag @@ -315,7 +319,8 @@ _uppermem_link db 0 ; 0063 upper memory link flag _UMB_top dw 0 ; 0064 unknown UMB_top will do for now global _uppermem_root _uppermem_root dw 0FFFFh ; 0066 dmd_upper_root - dw 0 ; 0068 para of last mem search + global _umb_start +_umb_start dw 0 ; 0068 para of last mem search SysVarEnd: diff --git a/kernel/kernel.mak b/kernel/kernel.mak index 75f49960..10988f6b 100644 --- a/kernel/kernel.mak +++ b/kernel/kernel.mak @@ -5,6 +5,9 @@ # # $Log$ +# Revision 1.4 2000/08/06 05:50:17 jimtabor +# Add new files and update cvs with patches and changes +# # Revision 1.3 2000/05/25 20:56:21 jimtabor # Fixed project history # @@ -119,10 +122,10 @@ INCLUDEPATH = ..\HDR #AFLAGS = /Mx /DSTANDALONE=1 /I..\HDR NASMFLAGS = -i../hdr/ LIBS =..\LIB\DEVICE.LIB ..\LIB\LIBM.LIB -CFLAGS = -1- -O -Z -d -I..\hdr -I. \ - -D__STDC__=0;DEBUG;KERNEL;I86;PROTO;ASMSUPT #CFLAGS = -1- -O -Z -d -I..\hdr -I. \ -# -D__STDC__=0;KERNEL;I86;PROTO;ASMSUPT +# -D__STDC__=0;DEBUG;KERNEL;I86;PROTO;ASMSUPT +CFLAGS = -1- -O -Z -d -I..\hdr -I. \ + -D__STDC__=0;KERNEL;I86;PROTO;ASMSUPT INITCFLAGS = $(CFLAGS) -zAINIT -zCINIT_TEXT -zPIGROUP HDR=../hdr/ @@ -244,6 +247,8 @@ io.obj: io.asm segs.inc irqstack.obj: irqstack.asm +nls_hc.obj: nls_hc.asm segs.inc + nlssupt.obj: nlssupt.asm segs.inc procsupt.obj: procsupt.asm segs.inc $(HDR)stacks.inc @@ -399,10 +404,10 @@ nls.obj: nls.c $(HDR)portab.h globals.h $(HDR)device.h $(HDR)mcb.h \ $(HDR)pcb.h $(HDR)date.h $(HDR)time.h $(HDR)fat.h $(HDR)fcb.h \ $(HDR)tail.h $(HDR)process.h $(HDR)dcb.h $(HDR)sft.h $(HDR)cds.h \ $(HDR)exe.h $(HDR)fnode.h $(HDR)dirmatch.h $(HDR)file.h \ - $(HDR)clock.h $(HDR)kbd.h $(HDR)error.h $(HDR)version.h proto.h \ - 001-437.nls + $(HDR)clock.h $(HDR)kbd.h $(HDR)error.h $(HDR)version.h proto.h -nls_hc.obj: nls_hc.c globals.h $(HDR)portab.h $(HDR)nls.h +# \ +# 001-437.nls prf.obj: prf.c $(HDR)portab.h diff --git a/kernel/main.c b/kernel/main.c index c23bc6db..026012bc 100644 --- a/kernel/main.c +++ b/kernel/main.c @@ -39,6 +39,9 @@ static BYTE *mainRcsId = "$Id$"; /* * $Log$ + * Revision 1.7 2000/08/06 05:50:17 jimtabor + * Add new files and update cvs with patches and changes + * * Revision 1.6 2000/06/21 18:16:46 jimtabor * Add UMB code, patch, and code fixes * @@ -193,8 +196,8 @@ INIT static VOID init_kernel(void) /* Init oem hook - returns memory size in KB */ ram_top = init_oem(); - - UMB_top = 3; /* testing for now* + UMB_top = 0; + umb_start = 0; /* Fake int 21h stack frame */ user_r = (iregs FAR *) DOS_PSP + 0xD0; diff --git a/kernel/memmgr.c b/kernel/memmgr.c index f80e8dc1..49942736 100644 --- a/kernel/memmgr.c +++ b/kernel/memmgr.c @@ -35,6 +35,9 @@ static BYTE *memmgrRcsId = "$Id$"; /* * $Log$ + * Revision 1.5 2000/08/06 05:50:17 jimtabor + * Add new files and update cvs with patches and changes + * * Revision 1.4 2000/06/21 18:16:46 jimtabor * Add UMB code, patch, and code fixes * @@ -185,8 +188,15 @@ COUNT DosMemAlloc(UWORD size, COUNT mode, seg FAR * para, UWORD FAR * asize) /* Initialize */ p = para2far(first_mcb); + biggestSeg = foundSeg = NULL; + if((mode & (FIRST_FIT_UO | FIRST_FIT_U)) && uppermem_link) { + if(uppermem_root) + p = para2far(uppermem_root); + + } + /* Search through memory blocks */ FOREVER { @@ -196,7 +206,7 @@ COUNT DosMemAlloc(UWORD size, COUNT mode, seg FAR * para, UWORD FAR * asize) if (mcbFree(p)) { /* unused block, check if it applies to the rule */ - if (joinMCBs(p) != SUCCESS) /* join following unused blocks */ + if (joinMCBs(p) != SUCCESS) /* join following unused blocks */ return DE_MCBDESTRY; /* error */ if (!biggestSeg || biggestSeg->m_size < p->m_size) @@ -208,6 +218,8 @@ COUNT DosMemAlloc(UWORD size, COUNT mode, seg FAR * para, UWORD FAR * asize) switch (mode) { case LAST_FIT: /* search for last possible */ + case LAST_FIT_U: + case LAST_FIT_UO: default: foundSeg = p; break; @@ -218,14 +230,19 @@ COUNT DosMemAlloc(UWORD size, COUNT mode, seg FAR * para, UWORD FAR * asize) break; case BEST_FIT: /* first, but smallest block */ + case BEST_FIT_U: + case BEST_FIT_UO: if (!foundSeg || foundSeg->m_size > p->m_size) /* better match found */ foundSeg = p; break; - case FIRST_FIT: /* first possible */ + case FIRST_FIT: /* first possible */ + case FIRST_FIT_U: + case FIRST_FIT_UO: foundSeg = p; goto stopIt; /* OK, rest of chain can be ignored */ + } } } @@ -254,7 +271,8 @@ COUNT DosMemAlloc(UWORD size, COUNT mode, seg FAR * para, UWORD FAR * asize) /* foundSeg := pointer to allocated block p := pointer to MCB that will form the rest of the block */ - if (mode == LAST_FIT) + if ( + (mode == LAST_FIT)||(mode == LAST_FIT_UO)||(mode == LAST_FIT_U)) { /* allocate the block from the end of the found block */ p = foundSeg; @@ -310,7 +328,6 @@ COUNT FAR init_call_DosMemAlloc(UWORD size, COUNT mode, seg FAR * para, UWORD FA COUNT DosMemLargest(UWORD FAR * size) { REG mcb FAR *p; - mcb FAR *q; COUNT found; /* Initialize */ @@ -376,6 +393,7 @@ COUNT DosMemFree(UWORD para) #if 0 /* Moved into allocating functions -- 1999/04/21 ska */ /* Now merge free blocks */ + for (p = (mcb FAR *) (MK_FP(first_mcb, 0)); p->m_type != MCB_LAST; p = q) { /* make q a pointer to the next block */ @@ -469,6 +487,7 @@ COUNT DosMemChange(UWORD para, UWORD size, UWORD * maxSize) COUNT DosMemCheck(void) { REG mcb FAR *p; + REG mcb FAR *u; /* Initialize */ p = para2far(first_mcb); @@ -483,13 +502,13 @@ COUNT DosMemCheck(void) /* not corrupted - but not end, bump the pointer */ p = nxtMCB(p); } - return SUCCESS; } COUNT FreeProcessMem(UWORD ps) { - mcb FAR *p; + mcb FAR *p, FAR *u; + COUNT x = 0; /* Initialize */ p = para2far(first_mcb); @@ -501,12 +520,14 @@ COUNT FreeProcessMem(UWORD ps) DosMemFree(FP_SEG(p)); /* not corrupted - if last we're OK! */ - if (p->m_type == MCB_LAST) - return SUCCESS; + if (p->m_type == MCB_LAST){ + if(x) + return DE_MCBDESTRY; + return SUCCESS; + } p = nxtMCB(p); } - return DE_MCBDESTRY; } @@ -536,7 +557,6 @@ COUNT DosGetLargestBlock(UWORD FAR * block) if (p->m_type == MCB_LAST) break; p = nxtMCB(p); - } *block = sz; return SUCCESS; @@ -545,7 +565,8 @@ COUNT DosGetLargestBlock(UWORD FAR * block) VOID show_chain(void) { - mcb FAR *p = para2far(first_mcb); + mcb FAR *p, FAR *u; + p = para2far(first_mcb); for (;;) { @@ -579,4 +600,49 @@ VOID _fmemcpy(BYTE FAR * d, BYTE FAR * s, REG COUNT n) *d++ = *s++; } + +VOID DosUmbLink(BYTE n) +{ + REG mcb FAR *p; + REG mcb FAR *q; + + if(uppermem_root){ + + q = p = para2far(first_mcb); + + if(uppermem_link){ + + while ( p != (mcb FAR *) para2far(0x9fff) ) + { + + if (!mcbValid(p)) + goto DUL_exit; + q = p; + p = nxtMCB(p); + } + + printf("M end at 0x%04x:0x%04x\n", FP_SEG(q), FP_OFF(q)); + + if(q->m_type == MCB_NORMAL) + q->m_type = MCB_LAST; + } + else + { + while( q->m_type != MCB_LAST) + { + if (!mcbValid(q)) + goto DUL_exit; + q = nxtMCB(q); + } + + printf("Z end at 0x%04x:0x%04x\n", FP_SEG(q), FP_OFF(q)); + + if(q->m_type == MCB_LAST) + q->m_type = MCB_NORMAL; + } + uppermem_link = n; + } +DUL_exit: + return; +} #endif diff --git a/kernel/network.c b/kernel/network.c index 3a433e9b..55d79c20 100644 --- a/kernel/network.c +++ b/kernel/network.c @@ -36,6 +36,9 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.7 2000/08/06 05:50:17 jimtabor + * Add new files and update cvs with patches and changes + * * Revision 1.6 2000/06/21 18:16:46 jimtabor * Add UMB code, patch, and code fixes * @@ -118,7 +121,7 @@ UCOUNT Remote_RW(UWORD func, UCOUNT n, BYTE FAR * bp, sft FAR * s, COUNT FAR * e COUNT Remote_find(UWORD func, BYTE FAR * name, REG dmatch FAR * dmp ) { COUNT i, x; - char FAR *p, *q; + char FAR *p, FAR *q; VOID FAR * test; struct dirent FAR *SDp = (struct dirent FAR *) &SearchDir; diff --git a/kernel/newstuff.c b/kernel/newstuff.c index c5e2bd77..459d3f84 100644 --- a/kernel/newstuff.c +++ b/kernel/newstuff.c @@ -31,6 +31,9 @@ static BYTE *mainRcsId = "$Id$"; /* * $Log$ + * Revision 1.8 2000/08/06 05:50:17 jimtabor + * Add new files and update cvs with patches and changes + * * Revision 1.7 2000/06/21 18:16:46 jimtabor * Add UMB code, patch, and code fixes * @@ -217,7 +220,7 @@ COUNT get_verify_drive(char FAR *src) } else drive = default_drive; - if ((drive < 0) || (drive > (lastdrive - 1))) { + if ((drive < 0) || (drive > lastdrive)) { drive = DE_INVLDDRV; } return drive; @@ -233,9 +236,10 @@ COUNT get_verify_drive(char FAR *src) COUNT truename(char FAR * src, char FAR * dest, COUNT t) { static char buf[128] = "A:\\\0\0\0\0\0\0\0\0\0"; - static char Name[8] = " "; + /* /// Changed to FNAME_SIZE from 8 for cleanliness. - Ron Cemer */ + static char Name[FNAME_SIZE]; char *bufp = buf + 3; - COUNT i, n, x = 2; + COUNT i, n, rootEndPos = 2; /* renamed x to rootEndPos - Ron Cemer */ struct cds FAR *cdsp; struct dhdr FAR *dhp; BYTE FAR *froot; @@ -251,7 +255,7 @@ COUNT truename(char FAR * src, char FAR * dest, COUNT t) { buf[0] = (src[0] | 0x20) + 'A' - 'a'; - if (buf[0] > (lastdrive - 1) + 'A') + if (buf[0] > lastdrive + 'A') return DE_PATHNOTFND; src += 2; @@ -259,6 +263,16 @@ COUNT truename(char FAR * src, char FAR * dest, COUNT t) else buf[0] = default_drive + 'A'; +/* /// Added to adjust for filenames which begin with ".\" + The problem was manifesting itself in the inability + to run an program whose filename (without the extension) + was longer than six characters and the PATH variable + contained ".", unless you explicitly specified the full + path to the executable file. + Jun 11, 2000 - rbc */ +/* /// Changed to "while" from "if". - Ron Cemer */ + while ( (src[0] == '.') && (src[1] == '\\') ) src += 2; + i = buf[0] - 'A'; /* Code repoff from dosfns.c @@ -277,23 +291,50 @@ COUNT truename(char FAR * src, char FAR * dest, COUNT t) for (; d < FNAME_SIZE; d++) Name[d] = ' '; + /* /// Bugfix: NUL.LST is the same as NUL. This is true for all + devices. On a device name, the extension is irrelevant + as long as the name matches. + - Ron Cemer */ +#if (0) /* if we have an extension, can't be a device */ if (*froot != '.') { +#endif for (dhp = (struct dhdr FAR *)&nul_dev; dhp != (struct dhdr FAR *)-1; dhp = dhp->dh_next) { if (fnmatch((BYTE FAR *) &Name, (BYTE FAR *) dhp->dh_name, FNAME_SIZE, FALSE)) { buf[2] ='/'; - for (d = 0; d < FNAME_SIZE; d++){ - if(Name[d] == 0x20) - goto exit_tn; + /* /// Bug: should be only copying up to first space. + - Ron Cemer + for (d = 0; d < FNAME_SIZE || Name[d] == ' '; d++) */ + for (d = 0; ( (d < FNAME_SIZE) && (Name[d] != ' ') ); d++) *bufp++ = Name[d]; + /* /// DOS will return C:/NUL.LST if you pass NUL.LST in. + DOS will also return C:/NUL.??? if you pass NUL.* in. + Code added here to support this. + - Ron Cemer */ + while ( (*froot != '.') && (*froot != '\0') ) froot++; + if (*froot) froot++; + if (*froot) { + *bufp++ = '.'; + for (i = 0; i < FEXT_SIZE; i++) { + if ( (*froot == '\0') || (*froot == '.') ) + break; + if (*froot == '*') { + for (; i < FEXT_SIZE; i++) *bufp++ = '?'; + break; + } + *bufp++ = *froot++; + } } + /* /// End of code additions. - Ron Cemer */ goto exit_tn; } } +#if (0) } +#endif cdsp = &CDSp->cds_table[i]; current_ldt = cdsp; @@ -309,7 +350,7 @@ COUNT truename(char FAR * src, char FAR * dest, COUNT t) { fsncopy((BYTE FAR *) & cdsp->cdsCurrentPath[0], (BYTE FAR *) & buf[0], cdsp->cdsJoinOffset); bufp = buf + cdsp->cdsJoinOffset; - x = cdsp->cdsJoinOffset; + rootEndPos = cdsp->cdsJoinOffset; /* renamed x to rootEndPos - Ron Cemer */ *bufp++ = '\\'; } @@ -327,6 +368,19 @@ COUNT truename(char FAR * src, char FAR * dest, COUNT t) src++; move_name: + + /* /// The block inside the "#if (0) ... #endif" is + seriously broken. New code added below to replace it. + This eliminates many serious bugs, specifically + with FreeCOM where truename is required to work + according to the DOS specification in order for + the COPY and other file-related commands to work + properly. + This should be a major improvement to all apps which + use truename. + - Ron Cemer */ + +#if (0) /* * The code here is brain dead. It works long as the calling * function are operating with in normal parms. @@ -384,7 +438,7 @@ COUNT truename(char FAR * src, char FAR * dest, COUNT t) for (bufp -= 2; *bufp != '\\'; bufp--) { - if (bufp < buf + x) /* '..' illegal in root dir */ + if (bufp < buf + rootEndPos) /* '..' illegal in root dir */ return DE_PATHNOTFND; } src++; @@ -413,9 +467,115 @@ COUNT truename(char FAR * src, char FAR * dest, COUNT t) break; } } + /* remove trailing backslashes */ while (bufp[-1] == '\\') --bufp; +#endif + +/* /// Beginning of new code. - Ron Cemer */ + bufp--; + { + char c, *bufend = buf+(sizeof(buf)-1); + int gotAnyWildcards = 0; + int seglen, copylen, state; + while ( (*src) && (bufp < bufend) ) { + /* Skip duplicated slashes. */ + while ( (*src == '/') || (*src == '\\') ) src++; + if (!(*src)) break; + /* Find the end of this segment in the source string. */ + for (seglen = 0; ; seglen++) { + c = src[seglen]; + if ( (c == '\0') || (c == '/') || (c == '\\') ) + break; + } + if (seglen > 0) { + /* Ignore all ".\" or "\." path segments. */ + if ( (seglen != 1) || (*src != '.') ) { + /* Apply ".." to the path by removing + last path segment from buf. */ + if ( (seglen==2) && (src[0] == '.') && (src[1] == '.') ) { + if (bufp > (buf+rootEndPos)) { + bufp--; + while ( (bufp > (buf+rootEndPos)) + && (*bufp != '/') + && (*bufp != '\\') ) + bufp--; + } + } else { + /* New segment. If any wildcards in previous + segment(s), this is an invalid path. */ + if (gotAnyWildcards) return DE_PATHNOTFND; + /* Append current path segment to result. */ + *(bufp++) = '\\'; + if (bufp >= bufend) break; + copylen = state = 0; + for (i=0; ( (i < seglen) && (bufp < bufend) ); i++) { + c = src[i]; + gotAnyWildcards |= ( (c == '?') || (c == '*') ); + switch (state) { + case 0: /* Copying filename (excl. extension) */ + if (c == '*') { + while (copylen < FNAME_SIZE) { + *(bufp++) = '?'; + if (bufp >= bufend) break; + copylen++; + } + copylen = 0; + state = 1; /* Go wait for dot */ + break; + } + if (c == '.') { + *(bufp++) = '.'; + copylen = 0; + state = 2; /* Copy extension next */ + break; + } + *(bufp++) = c; + copylen++; + if (copylen >= FNAME_SIZE) { + copylen = 0; + state = 1; /* Go wait for dot */ + break; + } + break; + case 1: /* Looking for dot so we can copy exten */ + if (src[i] == '.') { + *(bufp++) = '.'; + state = 2; + } + break; + case 2: /* Copying extension */ + if (c == '*') { + while (copylen < FEXT_SIZE) { + *(bufp++) = '?'; + if (bufp >= bufend) break; + copylen++; + } + i = seglen; /* Done with segment */ + break; + } + if (c == '.') { + i = seglen; /* Done with segment */ + break; + } + *(bufp++) = c; + copylen++; + if (copylen >= FEXT_SIZE) { + i = seglen; /* Done with segment */ + break; + } + break; + } + } + } + } + } /* if (seglen > 0) */ + src += seglen; + if (*src) src++; + } /* while ( (*src) && (bufp < bufend) ) */ + } +/* /// End of new code. - Ron Cemer */ if (bufp == buf + 2) ++bufp; @@ -425,7 +585,7 @@ COUNT truename(char FAR * src, char FAR * dest, COUNT t) *bufp++ = 0; /* finally, uppercase everything */ - upString(buf); + DosUpString(buf); /* copy to user's buffer */ fbcopy(buf, dest, bufp - buf); diff --git a/kernel/nls.c b/kernel/nls.c index a909c78e..a8b21a35 100644 --- a/kernel/nls.c +++ b/kernel/nls.c @@ -5,7 +5,7 @@ /* */ /* National Languge Support functions and data structures */ /* */ -/* Copyright (c) 1995, 1996, 2000 */ +/* Copyright (c) 2000 */ /* Steffen Kaiser */ /* All Rights Reserved */ /* */ @@ -27,10 +27,16 @@ /* Cambridge, MA 02139, USA. */ /****************************************************************/ +/* + * Note 1: Some code assume certains prerequisites to be matched, + * e.g. character tables exactly 128 bytes long; I try to keep\ + * track of these conditions within comments marked with: + * ==ska*/ + #include "portab.h" #include "globals.h" -#include "intr.h" -#include "nls.h" +#include "pcb.h" +#include #ifdef VERSION_STRINGS static BYTE *RcsId = "$Id$"; @@ -38,134 +44,173 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ - * Revision 1.3 2000/05/25 20:56:21 jimtabor - * Fixed project history - * - * Revision 1.2 2000/05/08 04:30:00 jimtabor - * Update CVS to 2020 + * Revision 1.4 2000/08/06 05:50:17 jimtabor + * Add new files and update cvs with patches and changes * - * Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 - * The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with - * MS-DOS. Distributed under the GNU GPL. - * - * Revision 1.8 2000/03/17 22:59:04 kernel - * Steffen Kaiser's NLS changes + * Revision 1.1 2000/03/23 02:44:21 ska + * Initial revision * */ -#ifdef NLS_REORDER_POINTERS -#define getTable2 (&nlsInfo.actPkg->nlsPointer[0].pointer) -#define getTable4 (&nlsInfo.actPkg->nlsPointer[1].pointer) +/* + * assertDSeqSS() - test if DS == SS + * Otherwise pointers to local variables (that ones on the stack) will + * be referenced via DS, which will cause to use wrong values. + */ +#ifdef NLS_DEBUG +#define assertDSeqSS() if(_DS != _SS) assertDSneSS(); +void assertDSneSS(void) +{ panic("DS unequal to SS"); +} +#define log(a) printf a +#define log1(a) printf a #else -#define getTable2 getTable(2) -#define getTable4 getTable(4) -#define NEED_GET_TABLE +#define assertDSeqSS() +#define log(a) +#ifdef NDEBUG +#define log1(a) +#else +#define log1(a) printf a +#endif #endif -#ifdef NLS_CACHE_POINTERS -#define normalCh nlsInfo.upTable -#define fileCh nlsInfo.fnamUpTable -#else -#define normalCh getTable2 -#define fileCh getTable4 + +struct nlsInfoBlock nlsInfo = { + (char FAR *)0 /* filename to COUNTRY.SYS */ + ,437 /* system code page */ + /* Implementation flags */ + ,0 +#ifdef NLS_MODIFYABLE_DATA + | NLS_CODE_MODIFYABLE_DATA +#endif +#ifdef NLS_REORDER_POINTERS + | NLS_CODE_REORDER_POINTERS #endif -#define yesChar nlsInfo.actPkg->yeschar -#define noChar nlsInfo.actPkg->nochar + ,&nlsPackageHardcoded /* hardcoded first package */ + ,&nlsPackageHardcoded /* first item in chain */ +}; -#define NLS_MUX_COUNTRY_INFO(nls) ((nls)->muxCallingFlags & NLS_FLAG_INFO) -#define NLS_MUX_POINTERS(nls) ((nls)->muxCallingFlags & NLS_FLAG_POINTERS) -#define NLS_MUX_YESNO(nls) ((nls)->muxCallingFlags & NLS_FLAG_YESNO) -#define NLS_MUX_EXTERNAL_UP(nls) ((nls)->muxCallingFlags & NLS_FLAG_UP) -#define NLS_MUX_EXTERNAL_FUP(nls) ((nls)->muxCallingFlags & NLS_FLAG_FUP) + /* getTableX return the pointer to the X'th table; X==subfct */ + /* subfct 2: normal upcase table; 4: filename upcase table */ +#ifdef NLS_REORDER_POINTERS +#define getTable2(nls) ((nls)->nlsPointers[0].pointer) +#define getTable4(nls) ((nls)->nlsPointers[1].pointer) +#else +#define getTable2(nls) getTable(2, (nls)) +#define getTable4(nls) getTable(4, (nls)) +#define NEED_GET_TABLE +#endif + /*== both chartables must be 128 bytes long and lower range is + identical to 7bit-US-ASCII ==ska*/ +#define getCharTbl2(nls) \ + (((struct nlsCharTbl FAR*)getTable2(nls))->tbl - 0x80) +#define getCharTbl4(nls) \ + (((struct nlsCharTbl FAR*)getTable4(nls))->tbl - 0x80) +/******************************************************************** + ***** MUX calling functions **************************************** + ********************************************************************/ -static COUNT muxGo(int subfct, struct REGPACK *rp) -{ rp->r_si = FP_OFF(&nlsInfo); - rp->r_ds = FP_SEG(&nlsInfo); - rp->r_ax = 0x1400 | subfct; +/*== DS:SI _always_ points to global NLS info structure <-> no + * subfct can use these registers for anything different. ==ska*/ +static COUNT muxGo(int subfct, iregs *rp) +{ +log( ("NLS: muxGo(): subfct=%x, cntry=%u, cp=%u, ES:DI=%04x:%04x\n", subfct + , rp->DX, rp->BX, rp->ES, rp->DI) ); + rp->SI = FP_OFF(&nlsInfo); + rp->DS = FP_SEG(&nlsInfo); + rp->AX = 0x1400 | subfct; intr(0x2f, rp); - return rp->r_ax; +log( ("NLS: muxGo(): return value = %d\n", rp->AX) ); + return rp->AX; } /* * Call NLSFUNC to load the NLS package */ COUNT muxLoadPkg(UWORD cp, UWORD cntry) -{ struct REGPACK r; +{ iregs r; + + assertDSeqSS(); /* because "&r" */ - /* Return the al register as sign extended: */ /* 0x1400 == not installed, ok to install */ /* 0x1401 == not installed, not ok to install */ /* 0x14FF == installed */ - r.r_bx = 0; /* make sure the NLSFUNC ID is updated */ + r.BX = 0; /* make sure the NLSFUNC ID is updated */ if(muxGo(0, &r) != 0x14ff) return DE_FILENOTFND; /* No NLSFUNC --> no load */ - if(r.r_bx != NLS_FREEDOS_NLSFUNC_ID) - return DE_INVLDACC; + if(r.BX != NLS_FREEDOS_NLSFUNC_ID) /* FreeDOS NLSFUNC will return */ + return DE_INVLDACC; /* This magic number */ /* OK, the correct NLSFUNC is available --> load pkg */ - r.r_dx = cntry; - r.r_bx = cp; - return muxGo(NLS_NLSFUNC_LOAD_PKG, &r); + /* If BX == -1 on entry, NLSFUNC updates BX to the codepage loaded + into memory. The system must then change to this one later */ + r.DX = cntry; + r.BX = cp; + return muxGo(NLSFUNC_LOAD_PKG, &r); } static int muxBufGo(int subfct, int bp, UWORD cp, UWORD cntry, UWORD bufsize - , BYTE FAR *buf) -{ struct REGPACK r; - - r.r_bx = cntry; - r.r_dx = cp; - r.r_es = FP_SEG(*buf); - r.r_di = FP_OFF(*buf); - r.r_cx = bufsize; - r.r_bp = bp; + , VOID FAR *buf) +{ iregs r; + + assertDSeqSS(); /* because "&r" */ + +log( ("NLS: muxBufGo(): subfct=%x, BP=%u, cp=%u, cntry=%u, len=%u, buf=%04x:%04x\n", + subfct, bp, cp, cntry, bufsize, FP_SEG(buf), FP_OFF(buf)) ); + + r.DX = cntry; + r.BX = cp; + r.ES = FP_SEG(buf); + r.DI = FP_OFF(buf); + r.CX = bufsize; + r.BP = bp; return muxGo(subfct, &r); } -#define mux38(cp,cc,bs,b) muxBufGo(4, 0, (cp), (cc), (bs), (b)) #define mux65(s,cp,cc,bs,b) muxBufGo(2, (s), (cp), (cc), (bs), (b)) -#define muxUpMem(s,l,f) muxBufGo((f), 0, NLS_DEFAULT, NLS_DEFAULT, l, s) - -static int muxYesNo(int ch) -{ struct REGPACK r; +#define mux38(cp,cc,bs,b) muxBufGo(4, 0, (cp), (cc), (bs), (b)) +#define muxYesNo(ch) muxBufGo(NLSFUNC_YESNO,0, NLS_DEFAULT, NLS_DEFAULT, (ch), 0) +#define muxUpMem(s,b,bs) muxBufGo((s),0, NLS_DEFAULT,NLS_DEFAULT, (bs), (b)) - r.r_cx = ch; - return muxGo(NLS_NLSFUNC_YESNO, &r); -} +/******************************************************************** + ***** Helper functions********************************************** + ********************************************************************/ /* - * Search the NLS package within the chain - * Also resolves the default values (-1) into the current + * Search for the NLS package within the chain + * Also resolves the default values (-1) into the currently * active codepage/country code. */ -struct nlsPackage FAR *searchPackage(UWORD *cp, UWORD *cntry) +static struct nlsPackage FAR *searchPackage(UWORD cp, UWORD cntry) { struct nlsPackage FAR *nls; - if(*cp == NLS_DEFAULT) - *cp = nlsInfo.actPkg->cntryInfo.codePage; - if(*cntry == NLS_DEFAULT) - *cntry = nlsInfo.actPkg->cntryInfo.countryCode; + if(cp == NLS_DEFAULT) + cp = nlsInfo.actPkg->cp; + if(cntry == NLS_DEFAULT) + cntry = nlsInfo.actPkg->cntry; - nls = &nlsInfo.chain; - while((nls->cntryInfo.codePage != *cp - || nls->cntryInfo.countryCode != *cntry) + nls = nlsInfo.chain; + while((nls->cp != cp || nls->cntry != cntry) && (nls = nls->nxt) != NULL); return nls; } -struct nlsPointerInf FAR *locateSubfct(struct nlsPackage FAR *nls - , UBYTE subfct) +/* For various robustnesses reasons and to simplify the implementation + at other places, locateSubfct() returns NULL (== "not found"), + if nls == NULL on entry. */ +static VOID FAR *locateSubfct(struct nlsPackage FAR *nls, int subfct) { int cnt; - struct nlsPointerInf FAR *p; + struct nlsPointer FAR *p; - for(cnt = nls->numSubfct, p = &nls->nlsPointer[0] + if(nls) for(cnt = nls->numSubfct, p = &nls->nlsPointers[0] ; cnt--; ++p) - if(p->subfct == subfct) + if(p->subfct == (UBYTE)subfct) return p; return NULL; @@ -173,18 +218,23 @@ struct nlsPointerInf FAR *locateSubfct(struct nlsPackage FAR *nls #ifdef NEED_GET_TABLE /* search the table (from a subfct) from the active package */ -struct nlsPointerInf FAR *getTable(UBYTE subfct) -{ struct nlsPointerInf FAR *poi; +/* Note: Because this table returns the pointers for stuff of + *internal* purpose, it seems to be more comfortable that this + function is guaranteed to return valid pointers, rather than + to let the user (some kernel function) deal with non-existing + tables -- 2000/02/26 ska*/ +static VOID FAR *getTable(UBYTE subfct, struct nlsPackage FAR *nls) +{ struct nlsPointer FAR *poi; - if((poi = locateSubfct(nlsInfo.actPkg, subfct)) != NULL) + if((poi = locateSubfct(nls, subfct)) != NULL) return poi; /* Failed --> return the hardcoded table */ switch(subfct) { case 2: return &nlsUpHardcodedTable; case 4: return &nlsFnameUpHardcodedTable; - case 5: return &nlsFnameTermHardcodedTable; - case 6: return &nlsCollHardcodedTable; + /* case 5: return &nlsFnameTermHardcodedTable; */ + /* case 6: return &nlsCollHardcodedTable; */ } } #endif @@ -192,217 +242,414 @@ struct nlsPointerInf FAR *getTable(UBYTE subfct) /* * Copy a buffer and test the size of the buffer * Returns SUCCESS on success; DE_INVLDFUNC on failure + * + * Efficiency note: This function is used as: + * return cpyBuf(buf, bufsize, ...) + * three times. If the code optimizer is some good, it can re-use + * the code to push bufsize, buf, call cpyBuf() and return its result. + * The parameter were ordered to allow this code optimization. */ -static COUNT cpyBuf(UBYTE FAR *dst, UBYTE FAR *src - , UWORD srclen, UWORD dstlen) +static COUNT cpyBuf(VOID FAR *dst, UWORD dstlen + , VOID FAR *src, UWORD srclen) { if(srclen <= dstlen) { - _fmemcpy((BYTE FAR*)dst, (BYTE FAR*)src, srclen); + _fmemcpy(dst, src, srclen); return SUCCESS; } return DE_INVLDFUNC; /* buffer too small */ } -/* - * Called for all subfunctions other than 0x20-0x23,& 0xA0-0xA2 - * of DOS-65 - */ -COUNT extCtryInfo(int subfct, UWORD codepage - , UWORD cntry, UWORD bufsize, UBYTE FAR * buf) -{ struct nlsPackage FAR*nls; /* NLS package to use to return the info from */ - int rc; - int muxOnCntryInfo, muxOnPointer; - struct nlsPointerInf FAR *poi; - if(!buf) - return DE_INVLDDATA; - if(subfct == 0) /* Currently not supported */ - return DE_INVLDFUNC; - /* nls := NLS package of cntry/codepage */ - if((nls = searchPackage(&codepage, &cntry)) == NULL) - /* requested NLS package is not loaded --> - pass the request to NLSFUNC */ - muxOnCntryInfo = muxOnPointer = TRUE; - else { - muxOnCntryInfo = NLS_MUX_COUNTRY_INFO(nls); - muxOnPointer = NLS_MUX_POINTERS(nls); - } +/* + * This function assumes that 'map' is adjusted such that + * map[0x80] is the uppercase of character 0x80. + *== 128 byte chartables, lower range conform to 7bit-US-ASCII ==ska*/ +static VOID upMMem(UBYTE FAR *map, UBYTE FAR * str, unsigned len) +{ + REG unsigned c; - if(subfct == 1) { /* return Extended Country Information */ - if(muxOnCntryInfo) - return mux65(1, codepage, cntry, bufsize, buf); - return cpyBuf(buf, (BYTE FAR*)&nls->cntryInfo - , nls->cntryInfo.size + 3, bufsize); - } - if(subfct == NLS_DOS_38) { /* return Country Information */ - if(muxOnCntryInfo) - return mux38(codepage, cntry, bufsize, buf); - return cpyBuf(buf, (BYTE FAR*)&nls->cntryInfo.dateFmt - , nls->cntryInfo.size - 4, bufsize); - } +#ifdef NLS_DEBUG + UBYTE FAR *oldStr; + unsigned oldLen; - if(muxOnPointer) - return mux65(subfct, codepage, cntry, bufsize, buf); + oldStr = str; + oldLen = len; +log( ("NLS: upMMem(): len=%u, %04x:%04x=\"", len, FP_SEG(str), FP_OFF(str)) ); + for(c = 0; c < len; ++c) + printf("%c", str[c] > 32? str[c]: '.'); + printf("\"\n"); +#endif + if (len) + do + { + if ((c = *str) >= 'a' && c <= 'z') + *str += 'A' - 'a'; + else if (c > 0x7f) + *str = map[c]; + ++str; + } + while (--len); +#ifdef NLS_DEBUG +printf("NLS: upMMem(): result=\""); + for(c = 0; c < oldLen; ++c) + printf("%c", oldStr[c] > 32? oldStr[c]: '.'); + printf("\"\n"); +#endif +} - /* any other subfunction returns a pointer to any sort - of data; the pointer is located within the nlsPointers - array */ - if((poi = locateSubfct(nls, subfct)) != NULL) - return cpyBuf(buf, (UBYTE FAR *)poi - , sizeof(struct nlsPointerInf), bufsize); +/******************************************************************** + ***** Lowlevel interface ******************************************* + ********************************************************************/ + +/* GetData function used by both the MUX-callback function and + the direct-access interface. + subfct == NLS_DOS_38 is a value > 0xff in order to not clash + with subfunctions valid to be passed as DOS-65-XX. */ +static int nlsGetData(struct nlsPackage FAR *nls, int subfct, UBYTE FAR *buf + , unsigned bufsize) +{ VOID FAR *poi; + +log( ("NLS: nlsGetData(): subfct=%x, bufsize=%u, cp=%u, cntry=%u\n", + subfct, bufsize, nls->cp, nls->cntry) ); + + /* Theoretically tables 1 and, if NLS_REORDER_POINTERS is enabled, + 2 and 4 could be hard-coded, because their + data is located at predictable (calculatable) locations. + However, 1 and subfct NLS_DOS_38 are to handle the same + data and the "locateSubfct()" call has to be implemented anyway, + in order to handle all subfunctions. + Also, NLS is often NOT used in any case, so this code is more + size than speed optimized. */ + if((poi = locateSubfct(nls, subfct)) != NULL) { +log( ("NLS: nlsGetData(): subfunction found\n") ); + switch(subfct) { + case 1: /* Extended Country Information */ + return cpyBuf(buf, bufsize, poi + , ((struct nlsExtCntryInfo FAR*)poi)->size + 3); + case NLS_DOS_38: /* Normal Country Information */ + return cpyBuf(buf, bufsize + , &(((struct nlsExtCntryInfo FAR*)poi)->dateFmt) + , 34); /* standard cinfo has no more 34 _used_ bytes */ + default: + /* All other subfunctions just return the found nlsPoinerInf + structure */ + return cpyBuf(buf, bufsize, poi, sizeof(struct nlsPointer)); + } + } + + /* The requested subfunction could not been located within the + NLS pkg --> error. Because the data corresponds to the subfunction + number passed to the API, the failure is the same as that a wrong + API function has been called. */ +log( ("NLS: nlsGetData(): Subfunction not found\n") ); return DE_INVLDFUNC; } +VOID nlsCPchange(UWORD cp) +{ printf("\7\nSorry, to change the codepage is not implemented, yet.\n\ +Hope it's OK to proceed ignoring this call.\n-- 2000/02/26 ska\n"); +} + /* - * Changes the current active codepage or cntry + * Changes the current active codepage or cntry + * + * Note: Usually any call sees a value of -1 (0xFFFF) as "the current + * country/CP". When a new NLS pkg is loaded, there is however a little + * difference, because one could mean that when switching to country XY + * the system may change to any codepage required. + * Example: + * MODE has prepared codepages 437 and 850. + * The user loaded a 2nd NLS pkg via CONFIG.SYS with: + * COUNTRY=49,850,C:\COUNTRY.SYS + * By default, the kernel maintains the hardcoded 001,437 (U.S.A./CP437) + * After the Country statement the system switches to codepage 850. + * But when the user invokes DOS-38-01/DX=FFFF (Set Country ID to 1) + * the system _must_ switch to codepage 437, because this is the only + * NLS pkg loaded. + * Therefore, setPackage() will substitute the current country ID, if + * cntry==-1, but leaves cp==-1 in order to let NLSFUNC choose the most + * appropriate codepage on its own. */ -static COUNT setPackage(UWORD cp, UWORD cntry) -{ struct nlsPackage FAR*nls; /* NLS package to use to return the info from */ - int rc; - /* nls := NLS package of cntry/codepage */ - if((nls = searchPackage(&cp, &cntry)) == NULL) { - /* not loaded --> invoke NLSFUNC to load it */ - if((rc = muxLoadPkg(cp, cntry)) != SUCCESS) - return rc; - if((nls = searchPackage(&cp, &cntry)) == NULL) - /* something went wrong */ - return DE_INVLDFUNC; - } +static COUNT nlsSetPackage(struct nlsPackage FAR *nls) +{ + if(nls->cp != nlsInfo.actPkg->cp) /* Codepage gets changed --> + inform all character drivers thereabout. + If this fails, it would be possible that the old + NLS pkg had been removed from memory by NLSFUNC. */ + nlsCPchange(nls->cp); nlsInfo.actPkg = nls; -#ifdef NLS_CACHE_POINTERS - /* Fill the quick-access pointers */ - nlsInfo.fnamUpTable = getTable4->pointer - 0x80; - nlsInfo.upTable = getTable2->pointer - 0x80; -#endif + return SUCCESS; } +static COUNT DosSetPackage(UWORD cp, UWORD cntry) +{ struct nlsPackage FAR*nls; /* NLS package to use to return the info from */ -/* - * Called for DOS-38 get info - * - * Note: DOS-38 does not receive the size of the buffer; therefore - * it is assumed the buffer is large enough as described in RBIL, - * which is 34 bytes _hardcoded_. - */ -COUNT getCountryInformation(UWORD cntry, BYTE FAR *buf) -{ return extCtryInfo(NLS_DOS_38, NLS_DEFAULT, cntry, 34, buf); -} + /* nls := NLS package of cntry/codepage */ + if((nls = searchPackage(cp, cntry)) != NULL) + /* OK the NLS pkg is loaded --> activate it */ + return nlsSetPackage(nls); -/* - * Called for DOS-38 set country code - */ -COUNT setCountryCode(UWORD cntry) -{ return setPackage(NLS_DEFAULT, cntry); + /* not loaded --> invoke NLSFUNC to load it */ + return muxLoadPkg(cp, cntry); } -/* - * Called for DOS-66-01 get CP - */ -COUNT getCodePage(UWORD FAR* actCP, UWORD FAR*sysCP) -{ *sysCP = nlsInfo.sysCodePage; - *actCP = nlsInfo.actPkg->cntryInfo.codePage; - return SUCCESS; +static void nlsUpMem(struct nlsPackage FAR *nls, VOID FAR *str, int len) +{ +log( ("NLS: nlsUpMem()\n") ); + upMMem(getCharTbl2(nls), (UBYTE FAR*)str, len); } -/* - * Called for DOS-66-02 set CP - * Note: One cannot change the system CP. Why it is necessary - * to specify it, is lost to me. (2000/02/13 ska) - */ -COUNT setCodePage(UWORD actCP, UWORD sysCP) -{ if(sysCP == NLS_DEFAULT || sysCP == nlsInfo.sysCodePage) - return setPackage(actCP, NLS_DEFAULT); - return DE_INVLDDATA; +static void nlsFUpMem(struct nlsPackage FAR *nls, VOID FAR *str, int len) +{ +log( ("NLS: nlsFUpMem()\n") ); + upMMem(getCharTbl4(nls), (UBYTE FAR*)str, len); } +static VOID xUpMem(struct nlsPackage FAR *nls, VOID FAR * str, unsigned len) +/* upcase a memory area */ +{ +log( ("NLS: xUpMem(): cp=%u, cntry=%u\n", nls->cp, nls->cntry) ); + if(nls->flags & NLS_FLAG_DIRECT_UPCASE) + nlsUpMem(nls, str, len); + else + muxBufGo(NLSFUNC_UPMEM, 0, nls->cp, nls->cntry, len, str); +} -static VOID upMMem(unsigned char FAR *map, unsigned char FAR * str - , unsigned len) +static int nlsYesNo(struct nlsPackage FAR *nls, unsigned char ch) { - REG unsigned c; - - if (len) - do - { - if ((c = *str) >= 'a' && c <= 'z') - *str += 'A' - 'a'; - else if (c > 0x7f) - *str = map[c & 0x7f]; - ++str; - } - while (--len); + assertDSeqSS(); /* because "&ch" */ + +log( ("NLS: nlsYesNo(): in ch=%u (%c)\n", ch, ch>32? ch: ' ') ); + + xUpMem(nls, &ch, 1); /* Upcase character */ + /* Cannot use DosUpChar(), because + maybe: nls != current NLS pkg + However: Upcase character within lowlevel + function to allow a yesNo() function + catched by external MUX-14 handler, which + does NOT upcase character. */ +log( ("NLS: nlsYesNo(): upcased ch=%u (%c)\n", ch, ch>32? ch: ' ') ); + if(ch == nls->yeschar) + return 1; + if(ch == nls->nochar) + return 0; + return 2; } -BYTE yesNo(unsigned char ch) +/******************************************************************** + ***** DOS API ****************************************************** + ********************************************************************/ + +BYTE DosYesNo(unsigned char ch) /* returns: 0: ch == "No", 1: ch == "Yes", 2: ch crap */ { - if(NLS_MUX_YESNO(nlsInfo.actPkg)) + if(nlsInfo.actPkg->flags & NLS_FLAG_DIRECT_YESNO) + return nlsYesNo(nlsInfo.actPkg, ch); + else return muxYesNo(ch); - - ch = upChar(ch); - if (ch == noChar) - return 0; - if (ch == yesChar) - return 1; - return 2; } -VOID upMem(unsigned char FAR * str, unsigned len) -/* upcase a memory area */ -{ -#ifndef NLS_CACHE_POINTERS - if(NLS_MUX_EXTERNAL_UP(nlsInfo.actPkg)) { - muxUpMem(str, len, NLS_NLSFUNC_UP); - return; - } -#endif - upMMem(normalCh, str, len); + +#ifndef DosUpMem +VOID DosUpMem(VOID FAR * str, unsigned len) +{ xUpMem(nlsInfo.actPkg, str, len); } +#endif -unsigned char upChar(unsigned char ch) +/* + * This function is also called by the backdoor entry specified by + * the "upCaseFct" member of the Country Information structure. Therefore + * the HiByte of the first argument must remain unchanged. + * See NLSSUPT.ASM -- 2000/03/30 ska + */ +unsigned char DosUpChar(unsigned char ch) /* upcase a single character */ -{ unsigned char buf[1]; - *buf = ch; - upMem((BYTE FAR*)buf, 1); - return *buf; +{ + assertDSeqSS(); /* because "&ch" */ +log( ("NLS: DosUpChar(): in ch=%u (%c)\n", ch, ch>32? ch: ' ') ); + DosUpMem((UBYTE FAR*)&ch, 1); +log( ("NLS: DosUpChar(): upcased ch=%u (%c)\n", ch, ch>32? ch: ' ') ); + return ch; } -VOID upString(unsigned char FAR * str) +VOID DosUpString(char FAR *str) /* upcase a string */ { - upMem(str, fstrlen(str)); + DosUpMem(str, fstrlen(str)); } -VOID upFMem(unsigned char FAR * str, unsigned len) +VOID DosUpFMem(VOID FAR *str, unsigned len) /* upcase a memory area for file names */ { -#ifndef NLS_CACHE_POINTERS - if(NLS_MUX_EXTERNAL_FUP(nlsInfo.actPkg)) { - muxUpMem(str, len, NLS_NLSFUNC_FUP); - return; - } +#ifdef NLS_DEBUG + unsigned c; +log( ("NLS: DosUpFMem(): len=%u, %04x:%04x=\"", len, FP_SEG(str), FP_OFF(str)) ); + for(c = 0; c < len; ++c) + printf("%c", str[c] > 32? str[c]: '.'); + printf("\"\n"); #endif - upMMem(fileCh, str, len); + if(nlsInfo.actPkg->flags & NLS_FLAG_DIRECT_FUPCASE) + nlsFUpMem(nlsInfo.actPkg, str, len); + else + muxUpMem(NLSFUNC_FILE_UPMEM, str, len); } -unsigned char upFChar(unsigned char ch) +unsigned char DosUpFChar(unsigned char ch) /* upcase a single character for file names */ -{ unsigned char buf[1]; - - *buf = ch; - upFMem((BYTE FAR*)buf, 1); - return *buf; +{ + assertDSeqSS(); /* because "&ch" */ + DosUpFMem((UBYTE FAR*)&ch, 1); + return ch; } -VOID upFString(unsigned char FAR * str) +VOID DosUpFString(char FAR *str) /* upcase a string for file names */ { - upFMem(str, fstrlen(str)); + DosUpFMem(str, fstrlen(str)); +} + +/* + * Called for all subfunctions other than 0x20-0x23,& 0xA0-0xA2 + * of DOS-65 + * + * If the requested NLS pkg specified via cntry and cp is _not_ + * loaded, MUX-14 is invoked; otherwise the pkg's NLS_Fct_buf + * function is invoked. + */ +COUNT DosGetData(int subfct, UWORD cp, UWORD cntry + , UWORD bufsize, VOID FAR * buf) +{ struct nlsPackage FAR*nls; /* NLS package to use to return the info from */ + +log( ("NLS: GetData(): subfct=%x, cp=%u, cntry=%u, bufsize=%u\n", + subfct, cp, cntry, bufsize) ); + + if(!buf || !bufsize) + return DE_INVLDDATA; + if(subfct == 0) /* Currently not supported */ + return DE_INVLDFUNC; + + /* nls := NLS package of cntry/codepage */ + if((nls = searchPackage(cp, cntry)) == NULL + || (nls->flags & NLS_FLAG_DIRECT_GETDATA) == 0) { + /* If the NLS pkg is not loaded into memory or the + direct-access flag is disabled, the request must + be passed through MUX */ + return (subfct == NLS_DOS_38) + ? mux38(nls->cp, nls->cntry, bufsize, buf) + : mux65(subfct, nls->cp, nls->cntry, bufsize, buf); + } + + /* Direct access to the data */ + return nlsGetData(nls, subfct, buf, bufsize); } +/* + * Called for DOS-38 get info + * + * Note: DOS-38 does not receive the size of the buffer; therefore + * it is assumed the buffer is large enough as described in RBIL, + * which is 34 bytes _hardcoded_. + */ +#ifndef DosGetCountryInformation +COUNT DosGetCountryInformation(UWORD cntry, VOID FAR *buf) +{ return DosGetData(NLS_DOS_38, NLS_DEFAULT, cntry, 34, buf); +} +#endif + +/* + * Called for DOS-38 set country code + */ +#ifndef DosSetCountry +COUNT DosSetCountry(UWORD cntry) +{ return DosSetPackage(NLS_DEFAULT, cntry); +} +#endif + +/* + * Called for DOS-66-01 get CP + */ +COUNT DosGetCodepage(UWORD FAR* actCP, UWORD FAR* sysCP) +{ *sysCP = nlsInfo.sysCodePage; + *actCP = nlsInfo.actPkg->cp; + return SUCCESS; +} + +/* + * Called for DOS-66-02 set CP + * Note: One cannot change the system CP. Why it is necessary + * to specify it, is lost to me. (2000/02/13 ska) + */ +COUNT DosSetCodepage(UWORD actCP, UWORD sysCP) +{ if(sysCP == NLS_DEFAULT || sysCP == nlsInfo.sysCodePage) + return DosSetPackage(actCP, NLS_DEFAULT); + return DE_INVLDDATA; +} + +/******************************************************************** + ***** MUX-14 API *************************************************** + ********************************************************************/ + +/* Registers: + AH == 14 + AL == subfunction + BX == codepage + DX == country code + DS:SI == internal global nlsInfo + ES:DI == user block + + Return value: AL register to be returned + if AL == 0, Carry must be cleared, otherwise set +*/ +#pragma argsused +UWORD syscall_MUX14(DIRECT_IREGS) +{ struct nlsPackage FAR*nls; /* addressed NLS package */ + +log( ("NLS: MUX14(): subfct=%x, cp=%u, cntry=%u\n", + AL, BX, DX) ); + + if((nls = searchPackage(BX, DX)) == NULL) + return DE_INVLDFUNC; /* no such package */ + +log( ("NLS: MUX14(): NLS pkg found\n") ); + + switch(AL) { + case NLSFUNC_INSTALL_CHECK: + BX = NLS_FREEDOS_NLSFUNC_ID; + return SUCCESS; /* kernel just simulates default functions */ + case NLSFUNC_DOS38: + return nlsGetData(nls, NLS_DOS_38, MK_FP(ES, DI), 34); + case NLSFUNC_GETDATA: + return nlsGetData(nls, BP, MK_FP(ES, DI), CX); + case NLSFUNC_DRDOS_GETDATA: + /* Does not pass buffer length */ + return nlsGetData(nls, CL, MK_FP(ES, DI), 512); + case NLSFUNC_LOAD_PKG: + case NLSFUNC_LOAD_PKG2: + return nlsSetPackage(nls); + case NLSFUNC_YESNO: + return nlsYesNo(nls, CL); + case NLSFUNC_UPMEM: + nlsUpMem(nls, MK_FP(ES, DI), CX); + return SUCCESS; + case NLSFUNC_FILE_UPMEM: +#ifdef NLS_DEBUG +{ unsigned j; + BYTE FAR *p; +log( ("NLS: MUX14(FILE_UPMEM): len=%u, %04x:%04x=\"", CX, ES, DI) ); + for(j = 0, p = MK_FP(ES, DI); j < CX; ++j) + printf("%c", p[j] > 32? p[j]: '.'); + printf("\"\n"); +} +#endif + nlsFUpMem(nls, MK_FP(ES, DI), CX); + return SUCCESS; + } +log( ("NLS: MUX14(): Invalid function %x\n", AL) ); + return DE_INVLDFUNC; /* no such function */ +} diff --git a/kernel/nls_hc.asm b/kernel/nls_hc.asm new file mode 100644 index 00000000..087c9e73 --- /dev/null +++ b/kernel/nls_hc.asm @@ -0,0 +1,109 @@ +; Hardcoded DOS-NLS information for country = 1, codepage = 437 +; This is an automatically generated file! +; Any modifications will be lost! + +; Prerequisites: +;; ==> Assuming that data of tables remains constant all the time +;; ==> Reordering tables 1, 2, 4 and 5 + + %include "segs.inc" +segment _DATA + + GLOBAL _nlsPackageHardcoded +_nlsPackageHardcoded: + DB 000h, 000h, 000h, 000h, 001h, 000h, 0b5h, 001h + DB 00fh, 000h, 059h, 04eh, 006h, 000h + DB 002h + DW ?table2, SEG ?table2 + DB 004h + DW ?table4, SEG ?table4 + DB 005h + DW ?table5, SEG ?table5 + DB 006h + DW ?table6, SEG ?table6 + DB 007h + DW ?table7, SEG ?table7 + GLOBAL _nlsCountryInfoHardcoded +_nlsCountryInfoHardcoded: + DB 001h +?table1: + DB 01ch, 000h, 001h, 000h, 0b5h, 001h, 000h, 000h + DB 024h, 000h, 000h, 000h, 000h, 02ch, 000h, 02eh + DB 000h, 02dh, 000h, 03ah, 000h, 000h, 002h, 000h + DB 0e8h, 058h, 000h, 000h, 02ch, 000h + GLOBAL _hcTablesStart +_hcTablesStart: + GLOBAL _nlsFUpcaseHardcoded +_nlsFUpcaseHardcoded: +?table4: + GLOBAL _nlsUpcaseHardcoded +_nlsUpcaseHardcoded: +?table2: + DB 080h, 000h, 080h, 09ah, 045h, 041h, 08eh, 041h + DB 08fh, 080h, 045h, 045h, 045h, 049h, 049h, 049h + DB 08eh, 08fh, 090h, 092h, 092h, 04fh, 099h, 04fh + DB 055h, 055h, 059h, 099h, 09ah, 09bh, 09ch, 09dh + DB 09eh, 09fh, 041h, 049h, 04fh, 055h, 0a5h, 0a5h + DB 0a6h, 0a7h, 0a8h, 0a9h, 0aah, 0abh, 0ach, 0adh + DB 0aeh, 0afh, 0b0h, 0b1h, 0b2h, 0b3h, 0b4h, 0b5h + DB 0b6h, 0b7h, 0b8h, 0b9h, 0bah, 0bbh, 0bch, 0bdh + DB 0beh, 0bfh, 0c0h, 0c1h, 0c2h, 0c3h, 0c4h, 0c5h + DB 0c6h, 0c7h, 0c8h, 0c9h, 0cah, 0cbh, 0cch, 0cdh + DB 0ceh, 0cfh, 0d0h, 0d1h, 0d2h, 0d3h, 0d4h, 0d5h + DB 0d6h, 0d7h, 0d8h, 0d9h, 0dah, 0dbh, 0dch, 0ddh + DB 0deh, 0dfh, 0e0h, 0e1h, 0e2h, 0e3h, 0e4h, 0e5h + DB 0e6h, 0e7h, 0e8h, 0e9h, 0eah, 0ebh, 0ech, 0edh + DB 0eeh, 0efh, 0f0h, 0f1h, 0f2h, 0f3h, 0f4h, 0f5h + DB 0f6h, 0f7h, 0f8h, 0f9h, 0fah, 0fbh, 0fch, 0fdh + DB 0feh, 0ffh + GLOBAL _nlsFnameTermHardcoded +_nlsFnameTermHardcoded: +?table5: + DB 016h, 000h, 08eh, 000h, 0ffh, 041h, 000h, 020h + DB 0eeh, 00eh, 02eh, 022h, 02fh, 05ch, 05bh, 05dh + DB 03ah, 07ch, 03ch, 03eh, 02bh, 03dh, 03bh, 02ch + GLOBAL _nlsCollHardcoded +_nlsCollHardcoded: +?table6: + DB 000h, 001h, 000h, 001h, 002h, 003h, 004h, 005h + DB 006h, 007h, 008h, 009h, 00ah, 00bh, 00ch, 00dh + DB 00eh, 00fh, 010h, 011h, 012h, 013h, 014h, 015h + DB 016h, 017h, 018h, 019h, 01ah, 01bh, 01ch, 01dh + DB 01eh, 01fh, 020h, 021h, 022h, 023h, 024h, 025h + DB 026h, 027h, 028h, 029h, 02ah, 02bh, 02ch, 02dh + DB 02eh, 02fh, 030h, 031h, 032h, 033h, 034h, 035h + DB 036h, 037h, 038h, 039h, 03ah, 03bh, 03ch, 03dh + DB 03eh, 03fh, 040h, 041h, 042h, 043h, 044h, 045h + DB 046h, 047h, 048h, 049h, 04ah, 04bh, 04ch, 04dh + DB 04eh, 04fh, 050h, 051h, 052h, 053h, 054h, 055h + DB 056h, 057h, 058h, 059h, 05ah, 05bh, 05ch, 05dh + DB 05eh, 05fh, 060h, 041h, 042h, 043h, 044h, 045h + DB 046h, 047h, 048h, 049h, 04ah, 04bh, 04ch, 04dh + DB 04eh, 04fh, 050h, 051h, 052h, 053h, 054h, 055h + DB 056h, 057h, 058h, 059h, 05ah, 07bh, 07ch, 07dh + DB 07eh, 07fh, 043h, 055h, 045h, 041h, 041h, 041h + DB 041h, 043h, 045h, 045h, 045h, 049h, 049h, 049h + DB 041h, 041h, 045h, 041h, 041h, 04fh, 04fh, 04fh + DB 055h, 055h, 059h, 04fh, 055h, 024h, 024h, 024h + DB 024h, 024h, 041h, 049h, 04fh, 055h, 04eh, 04eh + DB 0a6h, 0a7h, 03fh, 0a9h, 0aah, 0abh, 0ach, 021h + DB 022h, 022h, 0b0h, 0b1h, 0b2h, 0b3h, 0b4h, 0b5h + DB 0b6h, 0b7h, 0b8h, 0b9h, 0bah, 0bbh, 0bch, 0bdh + DB 0beh, 0bfh, 0c0h, 0c1h, 0c2h, 0c3h, 0c4h, 0c5h + DB 0c6h, 0c7h, 0c8h, 0c9h, 0cah, 0cbh, 0cch, 0cdh + DB 0ceh, 0cfh, 0d0h, 0d1h, 0d2h, 0d3h, 0d4h, 0d5h + DB 0d6h, 0d7h, 0d8h, 0d9h, 0dah, 0dbh, 0dch, 0ddh + DB 0deh, 0dfh, 0e0h, 053h, 0e2h, 0e3h, 0e4h, 0e5h + DB 0e6h, 0e7h, 0e8h, 0e9h, 0eah, 0ebh, 0ech, 0edh + DB 0eeh, 0efh, 0f0h, 0f1h, 0f2h, 0f3h, 0f4h, 0f5h + DB 0f6h, 0f7h, 0f8h, 0f9h, 0fah, 0fbh, 0fch, 0fdh + DB 0feh, 0ffh + GLOBAL _nlsDBCSHardcoded +_nlsDBCSHardcoded: +?table7: + DB 000h, 000h, 000h, 000h + GLOBAL _hcTablesEnd +_hcTablesEnd: + + +END diff --git a/kernel/nls_hc.c b/kernel/nls_hc.c deleted file mode 100644 index 1d20071e..00000000 --- a/kernel/nls_hc.c +++ /dev/null @@ -1,194 +0,0 @@ -/****************************************************************/ -/* */ -/* nls_hc.c */ -/* FreeDOS */ -/* */ -/* National Languge Support hardcoded NLS package */ -/* */ -/* Copyright (c) 2000 */ -/* Steffen Kaiser */ -/* All Rights Reserved */ -/* */ -/* This file is part of DOS-C. */ -/* */ -/* DOS-C is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU General Public License */ -/* as published by the Free Software Foundation; either version */ -/* 2, or (at your option) any later version. */ -/* */ -/* DOS-C is distributed in the hope that it will be useful, but */ -/* WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See */ -/* the GNU General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU General Public */ -/* License along with DOS-C; see the file COPYING. If not, */ -/* write to the Free Software Foundation, 675 Mass Ave, */ -/* Cambridge, MA 02139, USA. */ -/****************************************************************/ - -#include "portab.h" -#include "globals.h" -#define NLS_NO_VARS -#include "nls.h" - -#undef NLS_NO_VARS -#define NLS_HARDCODED US -#define NLS_POINTERS 5 -#define NLS_FNAMSEPS 14 -#define NLS_DBCSENTR 1 -#include "nls.h" - - -/* - * Hardcoded NLS package for U.S.A. CP437 - */ -struct nlsCharTbl128 nlsUpHardcodedTable = { - 128, /* upcase table */ - { - '\x80' ,'\x9a' ,'E' ,'A' ,'\x8e' ,'A' ,'\x8f' ,'\x80' /* 0 - 7 */ - ,'E' ,'E' ,'E' ,'I' ,'I' ,'I' ,'\x8e' ,'\x8f' /* 8 - 15 */ - ,'\x90' ,'\x92' ,'\x92' ,'O' ,'\x99' ,'O' ,'U' ,'U' /* 16 - 23 */ - ,'Y' ,'\x99' ,'\x9a' ,'\x9b' ,'\x9c' ,'\x9d' ,'\x9e' ,'\x9f' /* 24 - 31 */ - ,'A' ,'I' ,'O' ,'U' ,'\xa5' ,'\xa5' ,'\xa6' ,'\xa7' /* 32 - 39 */ - ,'\xa8' ,'\xa9' ,'\xaa' ,'\xab' ,'\xac' ,'\xad' ,'\xae' ,'\xaf' /* 40 - 47 */ - ,'\xb0' ,'\xb1' ,'\xb2' ,'\xb3' ,'\xb4' ,'\xb5' ,'\xb6' ,'\xb7' /* 48 - 55 */ - ,'\xb8' ,'\xb9' ,'\xba' ,'\xbb' ,'\xbc' ,'\xbd' ,'\xbe' ,'\xbf' /* 56 - 63 */ - ,'\xc0' ,'\xc1' ,'\xc2' ,'\xc3' ,'\xc4' ,'\xc5' ,'\xc6' ,'\xc7' /* 64 - 71 */ - ,'\xc8' ,'\xc9' ,'\xca' ,'\xcb' ,'\xcc' ,'\xcd' ,'\xce' ,'\xcf' /* 72 - 79 */ - ,'\xd0' ,'\xd1' ,'\xd2' ,'\xd3' ,'\xd4' ,'\xd5' ,'\xd6' ,'\xd7' /* 80 - 87 */ - ,'\xd8' ,'\xd9' ,'\xda' ,'\xdb' ,'\xdc' ,'\xdd' ,'\xde' ,'\xdf' /* 88 - 95 */ - ,'\xe0' ,'\xe1' ,'\xe2' ,'\xe3' ,'\xe4' ,'\xe5' ,'\xe6' ,'\xe7' /* 96 - 103 */ - ,'\xe8' ,'\xe9' ,'\xea' ,'\xeb' ,'\xec' ,'\xed' ,'\xee' ,'\xef' /* 104 - 111 */ - ,'\xf0' ,'\xf1' ,'\xf2' ,'\xf3' ,'\xf4' ,'\xf5' ,'\xf6' ,'\xf7' /* 112 - 119 */ - ,'\xf8' ,'\xf9' ,'\xfa' ,'\xfb' ,'\xfc' ,'\xfd' ,'\xfe' ,'\xff' /* 120 - 127 */ - } -}; -struct nlsCharTbl128 nlsFnameUpHardcodedTable = { - 128, /* file name upcase table */ - { - '\x80' ,'\x9a' ,'E' ,'A' ,'\x8e' ,'A' ,'\x8f' ,'\x80' /* 0 - 7 */ - ,'E' ,'E' ,'E' ,'I' ,'I' ,'I' ,'\x8e' ,'\x8f' /* 8 - 15 */ - ,'\x90' ,'\x92' ,'\x92' ,'O' ,'\x99' ,'O' ,'U' ,'U' /* 16 - 23 */ - ,'Y' ,'\x99' ,'\x9a' ,'\x9b' ,'\x9c' ,'\x9d' ,'\x9e' ,'\x9f' /* 24 - 31 */ - ,'A' ,'I' ,'O' ,'U' ,'\xa5' ,'\xa5' ,'\xa6' ,'\xa7' /* 32 - 39 */ - ,'\xa8' ,'\xa9' ,'\xaa' ,'\xab' ,'\xac' ,'\xad' ,'\xae' ,'\xaf' /* 40 - 47 */ - ,'\xb0' ,'\xb1' ,'\xb2' ,'\xb3' ,'\xb4' ,'\xb5' ,'\xb6' ,'\xb7' /* 48 - 55 */ - ,'\xb8' ,'\xb9' ,'\xba' ,'\xbb' ,'\xbc' ,'\xbd' ,'\xbe' ,'\xbf' /* 56 - 63 */ - ,'\xc0' ,'\xc1' ,'\xc2' ,'\xc3' ,'\xc4' ,'\xc5' ,'\xc6' ,'\xc7' /* 64 - 71 */ - ,'\xc8' ,'\xc9' ,'\xca' ,'\xcb' ,'\xcc' ,'\xcd' ,'\xce' ,'\xcf' /* 72 - 79 */ - ,'\xd0' ,'\xd1' ,'\xd2' ,'\xd3' ,'\xd4' ,'\xd5' ,'\xd6' ,'\xd7' /* 80 - 87 */ - ,'\xd8' ,'\xd9' ,'\xda' ,'\xdb' ,'\xdc' ,'\xdd' ,'\xde' ,'\xdf' /* 88 - 95 */ - ,'\xe0' ,'\xe1' ,'\xe2' ,'\xe3' ,'\xe4' ,'\xe5' ,'\xe6' ,'\xe7' /* 96 - 103 */ - ,'\xe8' ,'\xe9' ,'\xea' ,'\xeb' ,'\xec' ,'\xed' ,'\xee' ,'\xef' /* 104 - 111 */ - ,'\xf0' ,'\xf1' ,'\xf2' ,'\xf3' ,'\xf4' ,'\xf5' ,'\xf6' ,'\xf7' /* 112 - 119 */ - ,'\xf8' ,'\xf9' ,'\xfa' ,'\xfb' ,'\xfc' ,'\xfd' ,'\xfe' ,'\xff' /* 120 - 127 */ - } -}; -struct nlsFnamTermUS nlsFnameTermHardcodedTable = { - 22, /* size of permittable character structure */ - 1, /* reserved */ - '\x00' ,'\xff', /* first/last permittable character */ - 0, /* reserved */ - '\x00' ,' ', /* first/last excluded character */ - 2, /* reserved */ - 14, /* number of separators */ - { /* separators */ - '.' ,'"' ,'/' ,'\\','[' ,']' ,':' ,'|', /* 0 - 7 */ - '<' ,'>' ,'+' ,'=' ,';' ,',' /* 8 - 13 */ - } -}; -struct nlsCharTbl256 nlsCollHardcodedTable = { - 256, /* collating sequence table */ - { - '\x00' ,'\x01' ,'\x02' ,'\x03' ,'\x04' ,'\x05' ,'\x06' ,'\x07' /* 0 - 7 */ - ,'\x08' ,'\x09' ,'\x0a' ,'\x0b' ,'\x0c' ,'\x0d' ,'\x0e' ,'\x0f' /* 8 - 15 */ - ,'\x10' ,'\x11' ,'\x12' ,'\x13' ,'\x14' ,'\x15' ,'\x16' ,'\x17' /* 16 - 23 */ - ,'\x18' ,'\x19' ,'\x1a' ,'\x1b' ,'\x1c' ,'\x1d' ,'\x1e' ,'\x1f' /* 24 - 31 */ - ,' ' ,'!' ,'"' ,'#' ,'$' ,'%' ,'&' ,'\'' /* 32 - 39 */ - ,'(' ,')' ,'*' ,'+' ,',' ,'-' ,'.' ,'/' /* 40 - 47 */ - ,'0' ,'1' ,'2' ,'3' ,'4' ,'5' ,'6' ,'7' /* 48 - 55 */ - ,'8' ,'9' ,':' ,';' ,'<' ,'=' ,'>' ,'?' /* 56 - 63 */ - ,'@' ,'A' ,'B' ,'C' ,'D' ,'E' ,'F' ,'G' /* 64 - 71 */ - ,'H' ,'I' ,'J' ,'K' ,'L' ,'M' ,'N' ,'O' /* 72 - 79 */ - ,'P' ,'Q' ,'R' ,'S' ,'T' ,'U' ,'V' ,'W' /* 80 - 87 */ - ,'X' ,'Y' ,'Z' ,'[' ,'\\',']' ,'^' ,'_' /* 88 - 95 */ - ,'`' ,'A' ,'B' ,'C' ,'D' ,'E' ,'F' ,'G' /* 96 - 103 */ - ,'H' ,'I' ,'J' ,'K' ,'L' ,'M' ,'N' ,'O' /* 104 - 111 */ - ,'P' ,'Q' ,'R' ,'S' ,'T' ,'U' ,'V' ,'W' /* 112 - 119 */ - ,'X' ,'Y' ,'Z' ,'{' ,'|' ,'}' ,'~' ,'\x7f' /* 120 - 127 */ - ,'C' ,'U' ,'E' ,'A' ,'A' ,'A' ,'A' ,'C' /* 128 - 135 */ - ,'E' ,'E' ,'E' ,'I' ,'I' ,'I' ,'A' ,'A' /* 136 - 143 */ - ,'E' ,'A' ,'A' ,'O' ,'O' ,'O' ,'U' ,'U' /* 144 - 151 */ - ,'Y' ,'O' ,'U' ,'$' ,'$' ,'$' ,'$' ,'$' /* 152 - 159 */ - ,'A' ,'I' ,'O' ,'U' ,'N' ,'N' ,'\xa6' ,'\xa7' /* 160 - 167 */ - ,'?' ,'\xa9' ,'\xaa' ,'\xab' ,'\xac' ,'!' ,'"' ,'"' /* 168 - 175 */ - ,'\xb0' ,'\xb1' ,'\xb2' ,'\xb3' ,'\xb4' ,'\xb5' ,'\xb6' ,'\xb7' /* 176 - 183 */ - ,'\xb8' ,'\xb9' ,'\xba' ,'\xbb' ,'\xbc' ,'\xbd' ,'\xbe' ,'\xbf' /* 184 - 191 */ - ,'\xc0' ,'\xc1' ,'\xc2' ,'\xc3' ,'\xc4' ,'\xc5' ,'\xc6' ,'\xc7' /* 192 - 199 */ - ,'\xc8' ,'\xc9' ,'\xca' ,'\xcb' ,'\xcc' ,'\xcd' ,'\xce' ,'\xcf' /* 200 - 207 */ - ,'\xd0' ,'\xd1' ,'\xd2' ,'\xd3' ,'\xd4' ,'\xd5' ,'\xd6' ,'\xd7' /* 208 - 215 */ - ,'\xd8' ,'\xd9' ,'\xda' ,'\xdb' ,'\xdc' ,'\xdd' ,'\xde' ,'\xdf' /* 216 - 223 */ - ,'\xe0' ,'S' ,'\xe2' ,'\xe3' ,'\xe4' ,'\xe5' ,'\xe6' ,'\xe7' /* 224 - 231 */ - ,'\xe8' ,'\xe9' ,'\xea' ,'\xeb' ,'\xec' ,'\xed' ,'\xee' ,'\xef' /* 232 - 239 */ - ,'\xf0' ,'\xf1' ,'\xf2' ,'\xf3' ,'\xf4' ,'\xf5' ,'\xf6' ,'\xf7' /* 240 - 247 */ - ,'\xf8' ,'\xf9' ,'\xfa' ,'\xfb' ,'\xfc' ,'\xfd' ,'\xfe' ,'\xff' /* 248 - 255 */ - } -}; -struct nlsDBCSUS nlsDBCSHardcodedTable = { - 0, /* no DBC support */ - 0, /* DBC end marker */ -}; - -struct nlsInfoBlockUS nlsInfo = { - (char FAR*)NULL /*fname*/ - ,437 /*sysCodePage*/ - ,(struct nlsPackage FAR*)&nlsInfo.chain /* actPkg */ -#ifdef NLS_CACHE_DATA - ,(struct nlsCharTbl FAR*)&nlsFnameUpHardcodedTable - ,(struct nlsCharTbl FAR*)&nlsUpHardcodedTable -#endif - , /* hardcoded nlsPackageUS */ { - (struct nlsPackage FAR*)NULL /* nxt */ - ,0 /* MUX calling flags */ - , /* Extended Country Information */ { - 1, /* subfct */ - 0x26, /* size */ - 1, /* country code */ - 437, /* code page */ - 0, /* date format */ - { - /* currency string */ - '$','\x00','\x00','\x00','\x00', /* 0 - 4 */ - }, - { /* thousand separator */ - ',' ,'\x00' /* 0 - 1 */ - }, - { /* decimal point */ - '.' ,'\x00' /* 0 - 1 */ - }, - { /* date separator */ - '-' ,'\x00' /* 0 - 1 */ - }, - { /* time separator */ - ':' ,'\x00' /* 0 - 1 */ - }, - 0, /* currency format */ - 2, /* currency prescision */ - 0, /* time format */ - CharMapSrvc, /* upcase function */ - { /* data separator */ - ',','\x00' /* 0 - 1 */ - } - } - , 'Y', 'N' /* yes / no */ - , 5 /* num of subfunctions */ - , /* subfunctions */ { - { 2, (VOID FAR*)&nlsUpHardcodedTable } /* #0 */ - , { 4, (VOID FAR*)&nlsFnameUpHardcodedTable } /* #1 */ - , { 5, (VOID FAR*)&nlsFnameTermHardcodedTable } /* #2 */ - , { 6, (VOID FAR*)&nlsCollHardcodedTable } /* #3 */ - , { 7, (VOID FAR*)&nlsDBCSHardcodedTable } /* #4 */ - } - } -}; diff --git a/kernel/nls_load.c b/kernel/nls_load.c new file mode 100644 index 00000000..f3bf199a --- /dev/null +++ b/kernel/nls_load.c @@ -0,0 +1,388 @@ +/****************************************************************/ +/* */ +/* nls_load.c */ +/* FreeDOS */ +/* */ +/* National Languge Support functions and data structures */ +/* Load an entry from FreeDOS COUNTRY.SYS file. */ +/* */ +/* Copyright (c) 2000 */ +/* Steffen Kaiser */ +/* All Rights Reserved */ +/* */ +/* This file is part of FreeDOS. */ +/* */ +/* DOS-C is free software; you can redistribute it and/or */ +/* modify it under the terms of the GNU General Public License */ +/* as published by the Free Software Foundation; either version */ +/* 2, or (at your option) any later version. */ +/* */ +/* DOS-C is distributed in the hope that it will be useful, but */ +/* WITHOUT ANY WARRANTY; without even the implied warranty of */ +/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See */ +/* the GNU General Public License for more details. */ +/* */ +/* You should have received a copy of the GNU General Public */ +/* License along with DOS-C; see the file COPYING. If not, */ +/* write to the Free Software Foundation, 675 Mass Ave, */ +/* Cambridge, MA 02139, USA. */ +/****************************************************************/ + + +#include "portab.h" +#include "globals.h" +//#include "pcb.h" +#include + +#ifdef VERSION_STRINGS +static BYTE *RcsId = "$Id$"; +#endif + +/* + * $Log$ + * Revision 1.1 2000/08/06 05:50:17 jimtabor + * Add new files and update cvs with patches and changes + * + */ + +#define filename Config.cfgCSYS_fnam +#define cntry Config.cfgCSYS_cntry +#define cp Config.cfgCSYS_cp + +static int err(void) +{ + printf("Syntax error in or invalid COUNTRY.SYS: \"%s\"\n" + , filename); + return 0; +} + +#define readStruct(s) readStructure(&(s), sizeof(s), fd) +static int readStructure(void *buf, int size, COUNT fd) +{ if(dos_read(fd, buf, size) == size) + return 1; + + return err(); +} + /* Evaluate each argument only once */ +#define readFct(p,f) readFct_((p), (f), fd) +int readFct_(void *buf, struct csys_function *fct, COUNT fd) +{ if(dos_lseek(fd, fct->csys_rpos, 0) >= 0) + return readStructure(buf, fct->csys_length, fd); + return err(); +} + +#define seek(n) rseek((LONG)(n), fd) +static rseek(LONG rpos, COUNT fd) +{ if(dos_lseek(fd, rpos, 1) >= 0) + return 1; + + return err(); +} + + +COUNT csysOpen(void) +{ COUNT fd; + struct nlsCSys_fileHeader header; + + if((fd = dos_open((BYTE FAR*)filename, 0)) < 0) { + printf("Cannot open: \"%s\"\n", filename); + return 1; + } + + if(dos_read(fd, &header, sizeof(header)) != sizeof(header); + || strcmp(header.csys_idstring, CSYS_FD_IDSTRING) != 0 + || dos_lseek(fd, (LONG)sizeof(csys_completeFileHeader), 0) + != (LONG)sizeof(csys_completeFileHeader)) { + printf("No valid COUNTRY.SYS: \"%s\"\n\nTry NLSFUNC /i %s\n" + , filename, filename); + dos_close(fd); + return -1; + } + + return fd; +} + +/* Searches for function definition of table #fctID and + moves it at index idx */ +static int chkTable(int idx, int fctID, struct csys_function *fcts + , int numFct) +{ struct csys_function *fct, hfct; + int i; + + for(i = 0, fct = fcts; i < numFct; ++i, ++fct) + if(fct->csys_fctID == fctID) { + /* function found */ + if(i == idx) /* already best place */ + return 1; + /* Swap both places */ + memcpy(&hfct, fct, sizeof(hfct)); + memcpy(fct, &fcts[idx], sizeof(hfct)); + memcpy(&fcts[idx], &hfct, sizeof(hfct)); + return 1; + } + + printf("Mandatory table %u not found.\n", fctID); + return 0; +} +/* + * Description of the algorithm the COUNTRY= information is loaded. + +1) LoadCountry() is activated in pass 1, because it offers the functionality +how to upcase characters to the kernel, it should be activated as +soon as possible within processing CONFIG.SYS. + +2) The method to locate the actual data within COUNTRY.SYS is pretty +basic and straight forward; so no detailed description here. + +3) To reduce permanent memory useage the option NLS_MODIFYABLE_DATA +controls whether or not the loaded NLS pkg may be modified. By default, +modifying this data is _not_ supported. +The reason is to allow to re-use already loaded data, e.g. to use the +same physical table for #2 (normal upcase) and #4 (filename upcase). +NLSFUNC even can re-use the data loaded via COUNTRY= and the hardcoded data. + +4) The problem is that even without point 3) it is not easily possible to +pre-judge how many bytes the NLS pkg will allocate in memory, because +this NLS implementation wants to support a wider range of NLS pkgs; because +neither the number of subfunctions nor the size of the data per subfunction +is fixed globally. +Therefore, the package is built-up incrementally: +4.1) First all function definition structures (S3) are read into memory. +While doing so the position field is transformed into the absolute +position within COUNTRY.SYS. +4.2) Then they are checked if a subfunction is defined more than once. +4.3) Then the entries are sorted in that way that tables 0x23, 1, 2, 4 and 5 +lead the table in that order. +4.4) Then the basic nlsPackage with as many entries within nlsPointers[] +is allocated as there are function definitions left (minus one as the +pseudo-table 0x23 does not require an entry). +4.5) Pseudo-table 0x23 is installed. +4.6) Table 1 is installed at the very end of the nlsPointers[] array. +4.7) In the order all remaining function definitions are installed in +the same order as in the other array. + +5) "Installing" means (except table 0x23): +5.1) Enlarge the nlsPackage structure to hold the necessary bytes of the +function definition (member csys_length). +5.2) Only if NLS_MODIFYABLE_DATA is _not_ defined and table is not #1: +The loaded data is compared to already loaded data and if such pattern is +already found in memory, a pointer to that memory area is used and the +loaded data is discarded. +First the local data is searched through, then the area of the hardcoded +NLS pkg. +Efficiency: function definitions with the same file position can automatically +use the same memory area. + +6) When all function definitions are loaded, the nlsPackage structure is +tightly filled without any pad bytes; two areas are wasted: +a) The area containing the S3 structures, and +b) probably the last loaded data could be found within the memory already, +so the nlsPackage structure is larger than necessary. + + +8) But the memory allocation in pass 1 is temporary anyway, because in +the PostConfig() phase, all memory allocations are revoked and created +anew. At this point -- immediately after revoking all memory and +_before_ allocating any new memory -- the NLS pkg is located completely +within memory and one knows exactly which bytes to spare, and which data +can share the same physical memory; but if the normal PostConfig() +process would go on, this information would be lost, because it could be +overwritten. +==> Therefore the almost first operation within PostConfig() is to +move the NLS pkg upto the top (base?) of memory, thus, making sure +it is not overwritten and one need not re-load all the structures from +memory and, by doing so, loose the information which memory can be shared. + +9) Once this operation has been completed, the NLS pkg is joined into the +nlsInfo chain of loaded packages and is made active. + +=== + +To ease implementation the value of FP_SEG(nlsPointers[].pointer) != 0, +if the pointer refers to an absolute place, whereas FP_SEG() == 0, +indicates that the FP_OFF(...) is the offset base-relative to the data +offset; which is base-relative to the "nls" pointer. + */ +int csysLoadPackage(COUNT fd) +{ struct csys_numEntries entries; + struct csys_ccDefinition entry; + struct csys_function *fcts; + struct nlsPackage *nls; + struct nlsPointer *poi; + int highmark, numFct, i, j; + int totalSize; +#ifndef NLS_MODIFYABLE_DATA + BYTE FAR * p; +#endif +#define numE entries.csys_entries +#define bufp(offset) (((BYTE*)nls) + (offset)) +#define fct fcts[numFct] + + /* When this function is called, the position of the file is + at offset 128 (number of country/codepage pairs) */ + if(!readStruct(entries)) + return 0; + while(numE--) { + if(!readStruct(entry)) + return 0; + if(entry.csys_cntry == cntry + && (cp == NLS_DEFAULT || entry.csys_cp == cp)) { + /* Requested entry found! */ + if(!seek(entry.csys_rpos) + || !readStruct(entries)) + return 0; + /* Now reading the function definitions at this position */ + if(numE < 5) { + printf("Syntax error in COUNTRY.SYS: Too few subfunctions\n"); + return 0; + } + /* If the file structure is good, each but one entry (0x23) is + one item within nlsPointers[] array */ + fcts = KernelAlloc(sizeof(struct csys_function) * numE); + numFct = 0; /* number of already loaded fct definition */ + totalSize = 0; + { + if(!readStruct(fct)) + return 0; + switch(fct.csys_fctID) { + case 0: case 0x20: case 0x21: case 0x22: + case 0xA0: case 0xA1: case 0xA2: + printf("Invalid subfunction %u ignored", fct.csys_fctID); + continue; + case 0x23: + if(fct.csys_length != 2) { + printf("Pseudo-table 35 length mismatch\n"); + continue; + } + } + /* Search if the subfunction is already there */ + for(j = 0; j < numFcts && fcts[j].csys_fctID != fct.csys_fctID + ; ++j); + if(j != numFct) { + printf("Subfunction %u defined multiple times, ignored\n" + , fct.csys_fctID); + continue; + } + + /* OK --> update the rpos member */ + fct.csys_rpos += dos_ltell(fd); + totalSize += fct.csys_length; + ++numFct; + } while(--numE); + + /* i is the number of available function definition */ + /* check if all mandatory tables are loaded, at the same + time re-order the function definitions like that: + 0x23, 1, 2, 4, 5 + */ + + /* That's automatically a check that more than 3 definitions + are available */ + if(!chkTable(0, 0x23, fcts, numFct) /* pseudo-table 0x23 yes/no */ + || !chkTable(1, 1, fcts, numFct) /* ext cntry info */ + || !chkTable(2, 2, fcts, numFct) /* normal upcase */ + || !chkTable(3, 4, fcts, numFct) /* filename upcase */ + || !chkTable(4, 5, fcts, numFct)) /* filename terminator chars */ + return 0; + + /* Begin the loading process by to allocate memory as if + we had to load every byte */ + /* One nlsPointers structure is already part of nlsPackage; + two function definitions need no nlsPointers entry (0x32, 1); + one additional byte is required by table 1, but which is + already within totalSize as the length of pseudo-table + 0x23 has been counted. */ + nls = KernelAlloc((data = sizeof(nlsPackage) + + (numFct - 3) * sizeof(struct nlsPointer)) + totalSize); + /* data := first byte not used by the control area of + the nlsPackage structure; at this point it is the + offset where table #1 is to be loaded to*/ + + /* Install pseudo-table 0x23 */ + if(!readFct((BYTE*)&nls->yeschar, fcts)) + return 0; + nls->numSubfct = numFct - 1; /* pseudo-table 0x23 */ + + /* Install table #1 has it must overlay the last nlsPointers[] + item */ + *bufp(data) = 1; /* table #1 starts with the subfctID + then the data from the file follows */ + if(!readFct(bufp(++data), ++fcts)) + return 0; + data += fcts->csys_length; /* first byte of local data area */ + highmark = data; /* first unused byte */ + + for(j = 0, poi = nls->nlsPointers; j < numFct - 1; ++j, ++poi) { + /* consecutively load all functions */ + if(!readFct(bufp(data), ++fcts)) + return 0; + poi->subfct = fcts->csys_fctID; + /* Now the function data is located at the current top of + used memory and, if allowed, the other memory is + tested, if such image is already loaded */ +#ifndef NLS_MODIFYABLE_DATA + /* Try to locate the contents of the buffer */ + /** brute force **/ + /* For the standard tables one need to match tables + 2 and 4 only. */ + for(i = data; i + fcts->csys_length < highmark; ++i) { + if(memcmp(bufp(i), bufp(highmark), fcts->csys_length) + == 0) { + /* found! */ + /* ==> leave highmark untouch, but modify pointer */ + poi->pointer = MK_FP(0, i); + /* the segment portion == 0 identifies this pointer + as local within the current data area */ + goto nxtEntry; + } + } + /* Now try the hardcoded area */ + for(p = hcTablesStart; p < hcTablesEnd - fcts->csys_length + ; ++p) { + if(fmemcmp(p, bufp(highmark), fcts->csys_length) == 0) { + /* found! */ + /* ==> leave highmark untouch, but modify pointer */ + poi->pointer = p; + /* the segment portion != 0 identifies this is an + absolute pointer */ + goto nxtEntry; + } + } +#endif + /* Either not found or modifyable data allowed */ + poi->pointer = MK_FP(0, highmark); /* local address */ + highmark += fcts->csys_length; /* need to keep the data */ + nxtEntry: + } + /* how many memory is really required */ + Country.cfgCSYS_memory = highmark; + Country.cfgCSYS_data = nls; + return 1; + } + } +#undef numE + if(cp == NLS_DEFAULT) + printf("No definition of country ID %u in file \"%s\"\n", + cntry, filename); + else + printf("No definition of country ID %u for codepage %u in file \"%s\"\n", + cntry, cp, filename); + + return 0; +} + +INIT BOOL LoadCountryInfo(char *fnam) +{ COUNT fd; + int rc; + + if(strlen(fnam) < sizeof(filename)) { + strcpy(filename, fnam); + if((fd = csysOpen()) >= 0) { + rc = csysLoadPackage(fd); + dos_close(fd); + return rc; + } + } else + printf("Filename too long\n"); + return 0; +} diff --git a/kernel/nlssupt.asm b/kernel/nlssupt.asm index 6c9d9c41..b188c98a 100644 --- a/kernel/nlssupt.asm +++ b/kernel/nlssupt.asm @@ -29,6 +29,9 @@ ; $Id$ ; ; $Log$ +; Revision 1.4 2000/08/06 05:50:17 jimtabor +; Add new files and update cvs with patches and changes +; ; Revision 1.3 2000/05/25 20:56:21 jimtabor ; Fixed project history ; @@ -95,10 +98,10 @@ _CharMapSrvc: push cx push bx - mov dx, DGROUP - mov ds, dx + push ax ; arg of _upChar + mov ax, DGROUP + mov ds, ax - push ax call _upChar ;add sp, byte 2 // next POP retrieves orig AX diff --git a/kernel/proto.h b/kernel/proto.h index cb3b9fda..b7554967 100644 --- a/kernel/proto.h +++ b/kernel/proto.h @@ -34,8 +34,8 @@ static BYTE *Proto_hRcsId = "$Id$"; /* * $Log$ - * Revision 1.5 2000/06/21 18:16:46 jimtabor - * Add UMB code, patch, and code fixes + * Revision 1.6 2000/08/06 05:50:17 jimtabor + * Add new files and update cvs with patches and changes * * Revision 1.4 2000/05/26 19:25:19 jimtabor * Read History file for Change info @@ -374,6 +374,7 @@ COUNT DosMemCheck(void); COUNT FreeProcessMem(UWORD ps); COUNT DosGetLargestBlock(UWORD FAR * block); VOID show_chain(void); +VOID DosUmbLink(BYTE n); VOID mcb_print(mcb FAR * mcbp); VOID _fmemcpy(BYTE FAR * d, BYTE FAR * s, REG COUNT n); @@ -385,19 +386,26 @@ VOID bcopy(REG BYTE * s, REG BYTE * d, REG COUNT n); __FAR_WRAPPER(VOID, fbcopy, (REG VOID FAR * s, REG VOID FAR * d, REG COUNT n)) /* nls.c */ -COUNT extCtryInfo(int subfct, UWORD codepage, - UWORD cntry, UWORD bufsize, UBYTE FAR * buf); -BYTE yesNo(unsigned char ch); -unsigned char upChar(unsigned char ch); -VOID upString(unsigned char FAR * str); -VOID upMem(unsigned char FAR * str, unsigned len); -unsigned char upFChar(unsigned char ch); -VOID upFString(unsigned char FAR * str); -VOID upFMem(unsigned char FAR * str, unsigned len); -COUNT setCountryCode(UWORD cntry); -COUNT getCountryInformation(UWORD cntry, BYTE FAR *buf); -COUNT getCodePage(UWORD FAR* actCP, UWORD FAR*sysCP); -COUNT setCodePage(UWORD actCP, UWORD sysCP); +BYTE DosYesNo(unsigned char ch); +#ifndef DosUpMem +VOID DosUpMem(VOID FAR * str, unsigned len); +#endif +unsigned char DosUpChar(unsigned char ch); +VOID DosUpString(char FAR *str); +VOID DosUpFMem(VOID FAR *str, unsigned len); +unsigned char DosUpFChar(unsigned char ch); +VOID DosUpFString(char FAR *str); +COUNT DosGetData(int subfct, UWORD cp, UWORD cntry + , UWORD bufsize, VOID FAR * buf); +#ifndef DosGetCountryInformation +COUNT DosGetCountryInformation(UWORD cntry, VOID FAR *buf); +#endif +#ifndef DosSetCountry +COUNT DosSetCountry(UWORD cntry); +#endif +COUNT DosGetCodepage(UWORD FAR* actCP, UWORD FAR* sysCP); +COUNT DosSetCodepage(UWORD actCP, UWORD sysCP); +UWORD syscall_MUX14(DIRECT_IREGS); /* prf.c */ VOID put_console(COUNT c); @@ -460,6 +468,8 @@ COUNT truename(char FAR * src, char FAR * dest, COUNT t); COUNT int2f_Remote_call(UWORD func, UWORD b, UCOUNT n, UWORD d, VOID FAR * s, UWORD i, VOID FAR * data); COUNT QRemote_Fn(char FAR * s, char FAR * d); +COUNT FAR Umb_Test(void); + UWORD get_machine_name(BYTE FAR * netname); VOID set_machine_name(BYTE FAR * netname, UWORD name_num); UCOUNT Remote_RW(UWORD func, UCOUNT n, BYTE FAR * bp, sft FAR * s, COUNT FAR * err); @@ -467,6 +477,9 @@ COUNT Remote_find(UWORD func, BYTE FAR * name, REG dmatch FAR * dmp); /* procsupt.asm */ VOID INRPT FAR exec_user(iregs FAR * irp); +#define strcpy(d, s) scopy(s, d) + +/* detect.c */ +unsigned long FAR is_dosemu(void); -#define strcpy(d, s) scopy(s, d) diff --git a/kernel/task.c b/kernel/task.c index 671e6b4a..447e2386 100644 --- a/kernel/task.c +++ b/kernel/task.c @@ -35,6 +35,9 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.5 2000/08/06 05:50:17 jimtabor + * Add new files and update cvs with patches and changes + * * Revision 1.4 2000/05/26 19:25:19 jimtabor * Read History file for Change info * @@ -661,8 +664,14 @@ static COUNT DosExeLoader(BYTE FAR * namep, exec_blk FAR * exp, COUNT mode) /* + long2para((LONG) sizeof(psp)); ?? -- 1999/04/21 ska */ if (exe_size > asize) exe_size = asize; - } - +/* /// Removed closing curly brace. We should not attempt to allocate + memory if we are overlaying the current process, because the new + process will simply re-use the block we already have allocated. + This was causing execl() to fail in applications which use it to + overlay (replace) the current exe file with a new one. + Jun 11, 2000 - rbc + } */ + /* Allocate our memory and pass back any errors */ /* We can still get an error on first fit if the above */ /* returned size was a bet fit case */ @@ -694,6 +703,18 @@ static COUNT DosExeLoader(BYTE FAR * namep, exec_blk FAR * exp, COUNT mode) else /* with no error, we got exactly what we asked for */ asize = exe_size; + +/* /// Added open curly brace and "else" clause. We should not attempt + to allocate memory if we are overlaying the current process, because + the new process will simply re-use the block we already have allocated. + This was causing execl() to fail in applications which use it to + overlay (replace) the current exe file with a new one. + Jun 11, 2000 - rbc */ + } + else + asize = exe_size; +/* /// End of additions. Jun 11, 2000 - rbc */ + if (mode != OVERLAY) { /* memory found large enough - continue processing */ diff --git a/sys/sys.c b/sys/sys.c index 8cd699d6..d14d060d 100644 --- a/sys/sys.c +++ b/sys/sys.c @@ -27,6 +27,9 @@ ***************************************************************/ /* $Log$ + * Revision 1.4 2000/08/06 05:50:17 jimtabor + * Add new files and update cvs with patches and changes + * * Revision 1.3 2000/05/25 20:56:23 jimtabor * Fixed project history * From 2bc370718d25ce4c69307ca5307178c52c1adfde Mon Sep 17 00:00:00 2001 From: Jim Tabor Date: Mon, 7 Aug 2000 03:03:12 +0000 Subject: [PATCH 029/671] Fix problem with devicehigh git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@62 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/config.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/kernel/config.c b/kernel/config.c index 9596cb13..57e2d6fa 100644 --- a/kernel/config.c +++ b/kernel/config.c @@ -39,6 +39,9 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.7 2000/08/07 03:03:12 jimtabor + * Fix problem with devicehigh + * * Revision 1.6 2000/08/06 05:50:17 jimtabor * Add new files and update cvs with patches and changes * @@ -398,20 +401,20 @@ INIT VOID configDone(VOID) { mumcb_init((mcb FAR *) (MK_FP(0x9fff, 0)), - umb_start - 0x9fff); - -/* make last end of mem block normal with SC */ - + umb_start - 0x9fff - 1); +/* Check if any devices were loaded in umb */ + if(umb_start != FP_SEG(upBase) ){ +/* make last block normal with SC for the devices */ mumcb_init((mcb FAR *) (MK_FP(uppermem_root, 0)), (FP_SEG(upBase) + ((FP_OFF(upBase) + 0x0f) >> 4)) - uppermem_root - 1); uppermem_root = FP_SEG(upBase) + ((FP_OFF(upBase) + 0x0f) >> 4); - zumcb_init((mcb FAR *) (MK_FP(uppermem_root, 0)), (umb_start + UMB_top ) - uppermem_root - 1); upBase += 16; } + } #ifdef DEBUG printf("UMB Allocation completed: top at 0x%04x:0x%04x\n", @@ -503,11 +506,12 @@ INIT VOID DoConfig(VOID) upBase = MK_FP(umb_start , 0); uppermem_root = umb_start; -/* master sig for umb region with full size */ +/* master sig for umb region with full size */ +/* umcb_init((mcb FAR *) upBase, UMB_top ); upBase += 16; - +*/ /* reset root */ uppermem_root = FP_SEG(upBase) + ((FP_OFF(upBase) + 0x0f) >> 4); @@ -516,11 +520,6 @@ INIT VOID DoConfig(VOID) zumcb_init((mcb FAR *) (MK_FP(uppermem_root, 0)), UMB_top - 1); upBase += 16; - -#ifdef DEBUG - printf("UMB Allocation completed: top at 0x%04x:0x%04x\n", - FP_SEG(upBase), FP_OFF(upBase)); -#endif } } @@ -1107,6 +1106,9 @@ INIT VOID mcbp->m_type = MCB_LAST; mcbp->m_psp = FREE_PSP; mcbp->m_size = size; + for (i = 0; i < 8; i++) + mcbp->m_name[i] = '\0'; + } INIT VOID From bf28027f7e2d70e3bc7f3345112225499c1ae4da Mon Sep 17 00:00:00 2001 From: Jim Tabor Date: Mon, 7 Aug 2000 04:48:50 +0000 Subject: [PATCH 030/671] Fixed LoadHigh probllem git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@63 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/memmgr.c | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/kernel/memmgr.c b/kernel/memmgr.c index 49942736..5f3ccfa6 100644 --- a/kernel/memmgr.c +++ b/kernel/memmgr.c @@ -35,6 +35,9 @@ static BYTE *memmgrRcsId = "$Id$"; /* * $Log$ + * Revision 1.6 2000/08/07 04:48:50 jimtabor + * Fixed LoadHigh probllem + * * Revision 1.5 2000/08/06 05:50:17 jimtabor * Add new files and update cvs with patches and changes * @@ -192,8 +195,10 @@ COUNT DosMemAlloc(UWORD size, COUNT mode, seg FAR * para, UWORD FAR * asize) biggestSeg = foundSeg = NULL; if((mode & (FIRST_FIT_UO | FIRST_FIT_U)) && uppermem_link) { - if(uppermem_root) + if(uppermem_root) { + printf("Upper Mem Allocate\n"); p = para2far(uppermem_root); + } } @@ -271,8 +276,7 @@ COUNT DosMemAlloc(UWORD size, COUNT mode, seg FAR * para, UWORD FAR * asize) /* foundSeg := pointer to allocated block p := pointer to MCB that will form the rest of the block */ - if ( - (mode == LAST_FIT)||(mode == LAST_FIT_UO)||(mode == LAST_FIT_U)) + if ((mode == LAST_FIT)||(mode == LAST_FIT_UO)||(mode == LAST_FIT_U)) { /* allocate the block from the end of the found block */ p = foundSeg; @@ -609,24 +613,26 @@ VOID DosUmbLink(BYTE n) if(uppermem_root){ q = p = para2far(first_mcb); - - if(uppermem_link){ - +/* like a xor thing! */ + if((uppermem_link == 1) && (n == 0)) + { while ( p != (mcb FAR *) para2far(0x9fff) ) { - + if (mcbFree(p)) + joinMCBs(p); if (!mcbValid(p)) goto DUL_exit; q = p; p = nxtMCB(p); } - printf("M end at 0x%04x:0x%04x\n", FP_SEG(q), FP_OFF(q)); - if(q->m_type == MCB_NORMAL) q->m_type = MCB_LAST; + uppermem_link = n; + } else + if((uppermem_link == 0) && (n == 1)) { while( q->m_type != MCB_LAST) { @@ -635,12 +641,10 @@ VOID DosUmbLink(BYTE n) q = nxtMCB(q); } - printf("Z end at 0x%04x:0x%04x\n", FP_SEG(q), FP_OFF(q)); - if(q->m_type == MCB_LAST) q->m_type = MCB_NORMAL; + uppermem_link = n; } - uppermem_link = n; } DUL_exit: return; From cadb4b7589a47c2394ec390d021e1ca7903cafb9 Mon Sep 17 00:00:00 2001 From: Jim Tabor Date: Mon, 7 Aug 2000 04:53:54 +0000 Subject: [PATCH 031/671] Cleanup code git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@64 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/memmgr.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/kernel/memmgr.c b/kernel/memmgr.c index 5f3ccfa6..cd1116dc 100644 --- a/kernel/memmgr.c +++ b/kernel/memmgr.c @@ -35,6 +35,9 @@ static BYTE *memmgrRcsId = "$Id$"; /* * $Log$ + * Revision 1.7 2000/08/07 04:53:54 jimtabor + * Cleanup code + * * Revision 1.6 2000/08/07 04:48:50 jimtabor * Fixed LoadHigh probllem * @@ -193,13 +196,12 @@ COUNT DosMemAlloc(UWORD size, COUNT mode, seg FAR * para, UWORD FAR * asize) p = para2far(first_mcb); biggestSeg = foundSeg = NULL; - +/* + Hack to the Umb Region direct for now. Save time and program space. +*/ if((mode & (FIRST_FIT_UO | FIRST_FIT_U)) && uppermem_link) { - if(uppermem_root) { - printf("Upper Mem Allocate\n"); + if(uppermem_root) p = para2far(uppermem_root); - } - } /* Search through memory blocks */ From 3bfafe6dc5962efb69fb56f24537d6b4837300b6 Mon Sep 17 00:00:00 2001 From: Jim Tabor Date: Mon, 7 Aug 2000 22:24:10 +0000 Subject: [PATCH 032/671] Add NLS Patch git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@65 6ac86273-5f31-0410-b378-82cca8765d1b --- hdr/algnbyte.h | 11 +++++++++++ hdr/algndflt.h | 7 +++++++ 2 files changed, 18 insertions(+) create mode 100644 hdr/algnbyte.h create mode 100644 hdr/algndflt.h diff --git a/hdr/algnbyte.h b/hdr/algnbyte.h new file mode 100644 index 00000000..23dfd069 --- /dev/null +++ b/hdr/algnbyte.h @@ -0,0 +1,11 @@ + +#if defined(_MSC_VER) +#define asm __asm +#pragma pack(1) +#elif defined(_QC) || defined(__WATCOM__) +#pragma pack(1) +#elif defined(__ZTC__) +#pragma ZTC align 1 +#elif defined(__TURBOC__) && (__TURBOC__ > 0x202) +#pragma option -a- +#endif diff --git a/hdr/algndflt.h b/hdr/algndflt.h new file mode 100644 index 00000000..58c07cd8 --- /dev/null +++ b/hdr/algndflt.h @@ -0,0 +1,7 @@ +#if defined (_MSC_VER) || defined(_QC) || defined(__WATCOMC__) +#pragma pack() +#elif defined (__ZTC__) +#pragma ZTC align +#elif defined(__TURBOC__) && (__TURBOC__ > 0x202) +#pragma option -a. +#endif From 115a8dd09f3819b1203569fff1e4260460278e32 Mon Sep 17 00:00:00 2001 From: Jim Tabor Date: Mon, 7 Aug 2000 22:51:34 +0000 Subject: [PATCH 033/671] Remove unused code git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@66 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/config.c | 29 +++-------------------------- kernel/proto.h | 7 ++++++- 2 files changed, 9 insertions(+), 27 deletions(-) diff --git a/kernel/config.c b/kernel/config.c index 57e2d6fa..c3cdb285 100644 --- a/kernel/config.c +++ b/kernel/config.c @@ -39,6 +39,9 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.8 2000/08/07 22:51:34 jimtabor + * Remove unused code + * * Revision 1.7 2000/08/07 03:03:12 jimtabor * Fix problem with devicehigh * @@ -505,19 +508,9 @@ INIT VOID DoConfig(VOID) UmbState = 1; upBase = MK_FP(umb_start , 0); uppermem_root = umb_start; - - -/* master sig for umb region with full size */ -/* - umcb_init((mcb FAR *) upBase, UMB_top ); - upBase += 16; -*/ /* reset root */ - uppermem_root = FP_SEG(upBase) + ((FP_OFF(upBase) + 0x0f) >> 4); - /* setup the real mcb for the devicehigh block */ - zumcb_init((mcb FAR *) (MK_FP(uppermem_root, 0)), UMB_top - 1); upBase += 16; } @@ -1083,22 +1076,6 @@ INIT VOID mem_access_mode = FIRST_FIT; } -/* master umb sig */ - -INIT VOID - umcb_init(mcb FAR * mcbp, UWORD size) -{ - COUNT i; - static char name[8] = "UMB "; - - mcbp->m_type = MCB_LAST; - mcbp->m_psp = (UWORD) FP_SEG( mcbp ); - mcbp->m_psp++; - mcbp->m_size = size; - for (i = 0; i < 8; i++) - mcbp->m_name[i] = name[i]; -} - INIT VOID zumcb_init(mcb FAR * mcbp, UWORD size) { diff --git a/kernel/proto.h b/kernel/proto.h index b7554967..354d0141 100644 --- a/kernel/proto.h +++ b/kernel/proto.h @@ -34,9 +34,15 @@ static BYTE *Proto_hRcsId = "$Id$"; /* * $Log$ + * Revision 1.7 2000/08/07 22:51:34 jimtabor + * Remove unused code + * * Revision 1.6 2000/08/06 05:50:17 jimtabor * Add new files and update cvs with patches and changes * + * Revision 1.5 2000/06/21 18:16:46 jimtabor + * Add UMB code, patch, and code fixes + * * Revision 1.4 2000/05/26 19:25:19 jimtabor * Read History file for Change info * @@ -189,7 +195,6 @@ INIT BYTE *GetNumber(REG BYTE * pszString, REG COUNT * pnNum); INIT COUNT tolower(COUNT c); INIT COUNT toupper(COUNT c); INIT VOID mcb_init(mcb FAR * mcbp, UWORD size); -INIT VOID umcb_init(mcb FAR * mcbp, UWORD size); INIT VOID strcat(REG BYTE * d, REG BYTE * s); /* dosfns.c */ From 386ccd20e5b8b72a906ae608380a2baf39546450 Mon Sep 17 00:00:00 2001 From: Jim Hall Date: Tue, 15 Aug 2000 03:41:19 +0000 Subject: [PATCH 034/671] minor formatting change. No content changes. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@67 6ac86273-5f31-0410-b378-82cca8765d1b --- docs/mkboot.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/mkboot.txt b/docs/mkboot.txt index 73be5d66..979cf7a2 100644 --- a/docs/mkboot.txt +++ b/docs/mkboot.txt @@ -2,10 +2,10 @@ To create a bootable floppy suitable for copying the system to another drive: 1. Change directory (if necessary) to where the FreeDOS Kernel BIN -directory. + directory. 3. Enter the command "install" to transfer the system files to the -diskette in drive A. If you want to install on drive B, type -"install b:" + diskette in drive A. If you want to install on drive B, type + "install b:" 4. Write protect this disk and use it to boot from. From 21693a043225b774a8d5e61c9da7f4740517a8f3 Mon Sep 17 00:00:00 2001 From: Jim Hall Date: Tue, 15 Aug 2000 03:42:17 +0000 Subject: [PATCH 035/671] update to the bugs.txt file to point the user to the bug database at the FreeDOS web site (http://www.freedos.org/bugs) update to the build.txt file to remove references to the now-defunct web site at gcfl.net (John's old site). git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@68 6ac86273-5f31-0410-b378-82cca8765d1b --- docs/bugs.txt | 4 ++-- docs/build.txt | 16 ++++++++++------ 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/docs/bugs.txt b/docs/bugs.txt index c44f37e7..62693842 100644 --- a/docs/bugs.txt +++ b/docs/bugs.txt @@ -1,6 +1,6 @@ The current bug database is available on the web at -http://www.gcfl.net/bugs/kernel + http://www.freedos.org/bugs/ -Send bug reports to kernel-bugs@gcfl.net. +Thanks! diff --git a/docs/build.txt b/docs/build.txt index 45c20513..f5af0494 100644 --- a/docs/build.txt +++ b/docs/build.txt @@ -15,12 +15,10 @@ kernel come out, you can extract them over your previous source, and not have to worry about resetting up your configuration because your CONFIG.BAT and CONFIG.MAK files will not get replaced! -You will also need to download the latest version of NASM (a mirror -is at ftp://ftp.gcfl.net/freedos/nasm) and Turbo C 2.01 (a mirror is -at ftp://ftp.gcfl.net/freedos/tools/borland/tc201.zip). Install -Turbo C and NASM somewhere (it doesn't really matter where) and then -be sure to edit the CONFIG.MAK file to reflect where you put the -tools. +You will also need to download the latest version of NASM and Turbo C +2.01. Install Turbo C and NASM somewhere (it doesn't really matter +where) and then be sure to edit the CONFIG.MAK file to reflect where +you put the tools. This program will now compile with Turbo C 2.01 (now freely available!), Turbo C 3.0, Borland C 4.51 & 5.01. It should work with @@ -67,6 +65,12 @@ component. Study the makefile to better understand this. $Id$ $Log$ +Revision 1.3 2000/08/15 03:42:17 jhall1 +update to the bugs.txt file to point the user to the bug database at + the FreeDOS web site (http://www.freedos.org/bugs) +update to the build.txt file to remove references to the now-defunct + web site at gcfl.net (John's old site). + Revision 1.2 2000/05/08 04:27:48 jimtabor Update CVS to 2020 From d53d9f4445f6c263d6f86a9cb4b7759ee6b30a60 Mon Sep 17 00:00:00 2001 From: Jim Tabor Date: Tue, 5 Sep 2000 00:56:50 +0000 Subject: [PATCH 036/671] *** empty log message *** git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@71 6ac86273-5f31-0410-b378-82cca8765d1b --- docs/history.txt | 9 +++++++ kernel/fatfs.c | 68 +++++++++++++++++++++++++++++++++++++++++++----- 2 files changed, 70 insertions(+), 7 deletions(-) diff --git a/docs/history.txt b/docs/history.txt index 23f8da9c..26c6ac0a 100644 --- a/docs/history.txt +++ b/docs/history.txt @@ -1,3 +1,12 @@ +2000 Aug 15 - Build 2022 +-------- James Tabor (jimtabor@infohwy.com) + 2000/08/12 22:49:00 Ron Cemer (roncemer@gte.net) + Fixed writeblock() to only use getbuf() if writing a + complete sector; otherwise use getbloc() and do a + read-modify-write to prevent writing garbage back + over pre-existing data in the file. + This was a major BUG. + 2000 Aug 05 - Build 2021 -------- James Tabor (jimtabor@infohwy.com) Clean up and finish umb code to get 2021 out. diff --git a/kernel/fatfs.c b/kernel/fatfs.c index e6a9241e..481b525a 100644 --- a/kernel/fatfs.c +++ b/kernel/fatfs.c @@ -36,6 +36,17 @@ BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.7 2000/09/05 00:56:50 jimtabor + * *** empty log message *** + * + * + * /// 2000/08/12 22:49:00 Ron Cemer + * Fixed writeblock() to only use getbuf() if writing a + * complete sector; otherwise use getbloc() and do a + * read-modify-write to prevent writing garbage back + * over pre-existing data in the file. + * This was a major BUG. + * * Revision 1.6 2000/08/06 05:50:17 jimtabor * Add new files and update cvs with patches and changes * @@ -1602,6 +1613,15 @@ UCOUNT writeblock(COUNT fd, VOID FAR * buffer, UCOUNT count, COUNT * err) return 0; } +/* /// BUG!!! Moved from below next block because we should NOT be able + to truncate the file if we can't write to it. - Ron Cemer */ + /* test that we have a valid mode for this fnode */ + if (fnp->f_mode != WRONLY && fnp->f_mode != RDWR) + { + *err = DE_INVLDACC; + return 0; + } + /* Test that we are really about to do a data transfer. If the */ /* count is zero and the mode is XFR_READ, just exit. (Any */ /* read with a count of zero is a nop). */ @@ -1618,12 +1638,16 @@ UCOUNT writeblock(COUNT fd, VOID FAR * buffer, UCOUNT count, COUNT * err) return 0; } +/* /// BUG!!! Moved to above previous block because we should NOT be able + to truncate the file if we can't write to it. - Ron Cemer /* test that we have a valid mode for this fnode */ +/* if (fnp->f_mode != WRONLY && fnp->f_mode != RDWR) { *err = DE_INVLDACC; return 0; } +*/ /* The variable secsize will be used later. */ secsize = fnp->f_dpb->dpb_secsize; @@ -1726,14 +1750,40 @@ UCOUNT writeblock(COUNT fd, VOID FAR * buffer, UCOUNT count, COUNT * err) fnp->f_cluster); #endif +/* /// Moved xfr_cnt calculation from below so we can + use it to help decide how to get the block: + read-modify-write using getblock() if we are only + going to write part of the block, or + write using getbuf() if we are going to write + the entire block. + - Ron Cemer */ + xfr_cnt = min(to_xfer, secsize - fnp->f_boff); + /* get a buffer to store the block in */ - if (!getbuf(&bp, (ULONG) clus2phys(fnp->f_cluster, - (fnp->f_dpb->dpb_clsmask + 1), - fnp->f_dpb->dpb_data) + fnp->f_sector, - fnp->f_dpb->dpb_unit)) - { - *err = DE_BLKINVLD; - return ret_cnt; + /* /// BUG!!! Added conditional to only use getbuf() if we're going + to write the entire block, which is faster because it does + not first read the block from disk. However, if we are + going to only write part of the block, we MUST use the + getblock() call, which first reads the block from disk. + Without this modification, the kernel was writing garbage + to the file when sequential writes were attempted at less + than the block size. This was causing problems with + piping and redirection in FreeCOM, as well as many other + potential problems. + - Ron Cemer */ + if ( (fnp->f_boff == 0) && (xfr_cnt == secsize) ) { + if (!getbuf(&bp, (ULONG) clus2phys(fnp->f_cluster, + (fnp->f_dpb->dpb_clsmask + 1), + fnp->f_dpb->dpb_data) + fnp->f_sector, + fnp->f_dpb->dpb_unit)) { + *err = DE_BLKINVLD; + return ret_cnt; + } + } else { + bp = getblock((ULONG) clus2phys(fnp->f_cluster, + (fnp->f_dpb->dpb_clsmask + 1), + fnp->f_dpb->dpb_data) + fnp->f_sector, + fnp->f_dpb->dpb_unit); } /* transfer a block */ @@ -1741,7 +1791,11 @@ UCOUNT writeblock(COUNT fd, VOID FAR * buffer, UCOUNT count, COUNT * err) /* requested transfer size, whichever is smaller. */ /* Then compare to what is left, since we can transfer */ /* a maximum of what is left. */ +/* /// Moved xfr_cnt calculation to above getbuf/getblock calls so we can + use it to help decide which one to call. + - Ron Cemer xfr_cnt = min(to_xfer, secsize - fnp->f_boff); +*/ fbcopy(buffer, (BYTE FAR *) & bp->b_buffer[fnp->f_boff], xfr_cnt); bp->b_flag |= BFR_DIRTY | BFR_VALID; From 584d44295978c5d5fbecd6a4d310a7a8c4bae23d Mon Sep 17 00:00:00 2001 From: Jim Tabor Date: Sun, 29 Oct 2000 23:51:56 +0000 Subject: [PATCH 037/671] Adding Share Support by Ron Cemer git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@77 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/dosfns.c | 279 +++++++++++++++++++++++++++++++++++++++++++++- kernel/fatfs.c | 103 ++++++++++++++++- kernel/inthndlr.c | 18 +++ 3 files changed, 391 insertions(+), 9 deletions(-) diff --git a/kernel/dosfns.c b/kernel/dosfns.c index 38c23b8e..75f927b1 100644 --- a/kernel/dosfns.c +++ b/kernel/dosfns.c @@ -33,7 +33,13 @@ static BYTE *dosfnsRcsId = "$Id$"; #endif /* + * + * /// Added SHARE support. 2000/09/04 Ron Cemer + * * $Log$ + * Revision 1.9 2000/10/29 23:51:56 jimtabor + * Adding Share Support by Ron Cemer + * * Revision 1.8 2000/08/06 05:50:17 jimtabor * Add new files and update cvs with patches and changes * @@ -150,6 +156,61 @@ BOOL cmatch(COUNT, COUNT, COUNT); struct f_node FAR *xlt_fd(COUNT); + +/* /// Added for SHARE. - Ron Cemer */ + +int share_installed = 0; + + /* DOS calls this to see if it's okay to open the file. + Returns a file_table entry number to use (>= 0) if okay + to open. Otherwise returns < 0 and may generate a critical + error. If < 0 is returned, it is the negated error return + code, so DOS simply negates this value and returns it in + AX. */ +static int share_open_check + (char far *filename, /* far pointer to fully qualified filename */ + unsigned short pspseg, /* psp segment address of owner process */ + int openmode, /* 0=read-only, 1=write-only, 2=read-write */ + int sharemode); /* SHARE_COMPAT, etc... */ + + /* DOS calls this to record the fact that it has successfully + closed a file, or the fact that the open for this file failed. */ +static void share_close_file + (int fileno); /* file_table entry number */ + + /* DOS calls this to determine whether it can access (read or + write) a specific section of a file. We call it internally + from lock_unlock (only when locking) to see if any portion + of the requested region is already locked. If pspseg is zero, + then it matches any pspseg in the lock table. Otherwise, only + locks which DO NOT belong to pspseg will be considered. + Returns zero if okay to access or lock (no portion of the + region is already locked). Otherwise returns non-zero and + generates a critical error (if allowcriter is non-zero). + If non-zero is returned, it is the negated return value for + the DOS call. */ +static int share_access_check + (unsigned short pspseg,/* psp segment address of owner process */ + int fileno, /* file_table entry number */ + unsigned long ofs, /* offset into file */ + unsigned long len, /* length (in bytes) of region to access */ + int allowcriter); /* allow a critical error to be generated */ + + /* DOS calls this to lock or unlock a specific section of a file. + Returns zero if successfully locked or unlocked. Otherwise + returns non-zero. + If the return value is non-zero, it is the negated error + return code for the DOS 0x5c call. */ +static int share_lock_unlock + (unsigned short pspseg,/* psp segment address of owner process */ + int fileno, /* file_table entry number */ + unsigned long ofs, /* offset into file */ + unsigned long len, /* length (in bytes) of region to lock or unlock */ + int unlock); /* non-zero to unlock; zero to lock */ + +/* /// End of additions for SHARE. - Ron Cemer */ + + static VOID DosGetFile(BYTE FAR * lpszPath, BYTE FAR * lpszDosFileName) { BYTE szLclName[FNAME_SIZE + 1]; @@ -292,6 +353,23 @@ UCOUNT GenericRead(COUNT hndl, UCOUNT n, BYTE FAR * bp, COUNT FAR * err, { COUNT rc; + /* /// Added for SHARE - Ron Cemer */ + if (IsShareInstalled()) { + if (s->sft_shroff >= 0) { + int share_result = share_access_check + (cu_psp, + s->sft_shroff, + s->sft_posit, + (unsigned long)n, + 1); + if (share_result != 0) { + *err = share_result; + return 0; + } + } + } + /* /// End of additions for SHARE - Ron Cemer */ + ReadCount = readblock(s->sft_status, bp, n, &rc); if (rc != SUCCESS) { @@ -482,6 +560,23 @@ UCOUNT DosWrite(COUNT hndl, UCOUNT n, BYTE FAR * bp, COUNT FAR * err) { COUNT rc; + /* /// Added for SHARE - Ron Cemer */ + if (IsShareInstalled()) { + if (s->sft_shroff >= 0) { + int share_result = share_access_check + (cu_psp, + s->sft_shroff, + s->sft_posit, + (unsigned long)n, + 1); + if (share_result != 0) { + *err = share_result; + return 0; + } + } + } + /* /// End of additions for SHARE - Ron Cemer */ + WriteCount = writeblock(s->sft_status, bp, n, &rc); if (rc < SUCCESS) { @@ -674,6 +769,8 @@ COUNT DosCreat(BYTE FAR * fname, COUNT attrib) if ((sftp = get_free_sft((WORD FAR *) & sft_idx)) == (sft FAR *) - 1) return DE_TOOMANY; + sftp->sft_shroff = -1; /* /// Added for SHARE - Ron Cemer */ + /* check for a device */ dhp = IsDevice(fname); if ( dhp ) @@ -712,6 +809,17 @@ COUNT DosCreat(BYTE FAR * fname, COUNT attrib) return result; } +/* /// Added for SHARE. - Ron Cemer */ + if (IsShareInstalled()) { + if ((sftp->sft_shroff = share_open_check + ((char far *)PriPathName, + cu_psp, + 0x02, /* read-write */ + 0)) < 0) /* compatibility mode */ + return sftp->sft_shroff; + } +/* /// End of additions for SHARE. - Ron Cemer */ + sftp->sft_status = dos_creat(fname, attrib); if (sftp->sft_status >= 0) { @@ -723,9 +831,15 @@ COUNT DosCreat(BYTE FAR * fname, COUNT attrib) sftp->sft_psp = cu_psp; DosGetFile(fname, sftp->sft_name); return hndl; - } - else + } else { +/* /// Added for SHARE *** CURLY BRACES ADDED ALSO!!! ***. - Ron Cemer */ + if (IsShareInstalled()) { + share_close_file(sftp->sft_shroff); + sftp->sft_shroff = -1; + } +/* /// End of additions for SHARE. - Ron Cemer */ return sftp->sft_status; + } } COUNT CloneHandle(COUNT hndl) @@ -841,6 +955,8 @@ COUNT DosOpen(BYTE FAR * fname, COUNT mode) if ((sftp = get_free_sft((WORD FAR *) & sft_idx)) == (sft FAR *) - 1) return DE_TOOMANY; + sftp->sft_shroff = -1; /* /// Added for SHARE - Ron Cemer */ + /* check for a device */ dhp = IsDevice(fname); if ( dhp ) @@ -880,6 +996,18 @@ COUNT DosOpen(BYTE FAR * fname, COUNT mode) } return result; } + +/* /// Added for SHARE. - Ron Cemer */ + if (IsShareInstalled()) { + if ((sftp->sft_shroff = share_open_check + ((char far *)PriPathName, + (unsigned short)cu_psp, + mode & 0x03, + (mode >> 2) & 0x07)) < 0) + return sftp->sft_shroff; + } +/* /// End of additions for SHARE. - Ron Cemer */ + sftp->sft_status = dos_open(fname, mode); if (sftp->sft_status >= 0) @@ -903,9 +1031,15 @@ COUNT DosOpen(BYTE FAR * fname, COUNT mode) sftp->sft_psp = cu_psp; DosGetFile(fname, sftp->sft_name); return hndl; - } - else + } else { +/* /// Added for SHARE *** CURLY BRACES ADDED ALSO!!! ***. - Ron Cemer */ + if (IsShareInstalled()) { + share_close_file(sftp->sft_shroff); + sftp->sft_shroff = -1; + } +/* /// End of additions for SHARE. - Ron Cemer */ return sftp->sft_status; + } } COUNT DosClose(COUNT hndl) @@ -951,8 +1085,15 @@ COUNT DosClose(COUNT hndl) s->sft_count -= 1; if (s->sft_count > 0) return SUCCESS; - else + else { +/* /// Added for SHARE *** CURLY BRACES ADDED ALSO!!! ***. - Ron Cemer */ + if (IsShareInstalled()) { + if (s->sft_shroff >= 0) share_close_file(s->sft_shroff); + s->sft_shroff = -1; + } +/* /// End of additions for SHARE. - Ron Cemer */ return dos_close(s->sft_status); + } } } @@ -1382,6 +1523,30 @@ COUNT DosRmdir(BYTE FAR * dir) return result; } +/* /// Added for SHARE. - Ron Cemer */ + +COUNT DosLockUnlock(COUNT hndl, LONG pos, LONG len, COUNT unlock) +{ + sft FAR *s; + + /* Invalid function unless SHARE is installed. */ + if (!IsShareInstalled()) return DE_INVLDFUNC; + + /* Test that the handle is valid */ + if (hndl < 0) return DE_INVLDHNDL; + + /* Get the SFT block that contains the SFT */ + if ((s = get_sft(hndl)) == (sft FAR *) -1) return DE_INVLDHNDL; + + /* Lock violation if this SFT entry does not support locking. */ + if (s->sft_shroff < 0) return DE_LOCK; + + /* Let SHARE do the work. */ + return share_lock_unlock(cu_psp, s->sft_shroff, pos, len, unlock); +} + +/* /// End of additions for SHARE. - Ron Cemer */ + /* * This seems to work well. */ @@ -1427,3 +1592,107 @@ struct dhdr FAR * IsDevice(BYTE FAR * fname) return (struct dhdr FAR *)0; } + +/* /// Added for SHARE. - Ron Cemer */ + +BOOL IsShareInstalled(void) { + if (!share_installed) { + iregs regs; + + regs.a.x = 0x1000; + intr(0x2f, ®s); + share_installed = ((regs.a.x & 0xff) == 0xff); + } + return share_installed; +} + + /* DOS calls this to see if it's okay to open the file. + Returns a file_table entry number to use (>= 0) if okay + to open. Otherwise returns < 0 and may generate a critical + error. If < 0 is returned, it is the negated error return + code, so DOS simply negates this value and returns it in + AX. */ +static int share_open_check + (char far *filename, /* far pointer to fully qualified filename */ + unsigned short pspseg, /* psp segment address of owner process */ + int openmode, /* 0=read-only, 1=write-only, 2=read-write */ + int sharemode) { /* SHARE_COMPAT, etc... */ + iregs regs; + + regs.a.x = 0x10a0; + regs.ds = FP_SEG(filename); + regs.si = FP_OFF(filename); + regs.b.x = pspseg; + regs.c.x = openmode; + regs.d.x = sharemode; + intr(0x2f, ®s); + return (int)regs.a.x; +} + + /* DOS calls this to record the fact that it has successfully + closed a file, or the fact that the open for this file failed. */ +static void share_close_file + (int fileno) { /* file_table entry number */ + iregs regs; + + regs.a.x = 0x10a1; + regs.b.x = fileno; + intr(0x2f, ®s); +} + + /* DOS calls this to determine whether it can access (read or + write) a specific section of a file. We call it internally + from lock_unlock (only when locking) to see if any portion + of the requested region is already locked. If pspseg is zero, + then it matches any pspseg in the lock table. Otherwise, only + locks which DO NOT belong to pspseg will be considered. + Returns zero if okay to access or lock (no portion of the + region is already locked). Otherwise returns non-zero and + generates a critical error (if allowcriter is non-zero). + If non-zero is returned, it is the negated return value for + the DOS call. */ +static int share_access_check + (unsigned short pspseg,/* psp segment address of owner process */ + int fileno, /* file_table entry number */ + unsigned long ofs, /* offset into file */ + unsigned long len, /* length (in bytes) of region to access */ + int allowcriter) { /* allow a critical error to be generated */ + iregs regs; + + regs.a.x = 0x10a2 | (allowcriter ? 0x01 : 0x00); + regs.b.x = pspseg; + regs.c.x = fileno; + regs.si = (unsigned short)((ofs >> 16) & 0xffffL); + regs.di = (unsigned short)(ofs & 0xffffL); + regs.es = (unsigned short)((len >> 16) & 0xffffL); + regs.d.x = (unsigned short)(len & 0xffffL); + intr(0x2f, ®s); + return (int)regs.a.x; +} + + /* DOS calls this to lock or unlock a specific section of a file. + Returns zero if successfully locked or unlocked. Otherwise + returns non-zero. + If the return value is non-zero, it is the negated error + return code for the DOS 0x5c call. */ +static int share_lock_unlock + (unsigned short pspseg,/* psp segment address of owner process */ + int fileno, /* file_table entry number */ + unsigned long ofs, /* offset into file */ + unsigned long len, /* length (in bytes) of region to lock or unlock */ + int unlock) { /* non-zero to unlock; zero to lock */ + iregs regs; + + regs.a.x = 0x10a4 | (unlock ? 0x01 : 0x00); + regs.b.x = pspseg; + regs.c.x = fileno; + regs.si = (unsigned short)((ofs >> 16) & 0xffffL); + regs.di = (unsigned short)(ofs & 0xffffL); + regs.es = (unsigned short)((len >> 16) & 0xffffL); + regs.d.x = (unsigned short)(len & 0xffffL); + intr(0x2f, ®s); + return (int)regs.a.x; +} + +/* /// End of additions for SHARE. - Ron Cemer */ + diff --git a/kernel/fatfs.c b/kernel/fatfs.c index 481b525a..c3bfa725 100644 --- a/kernel/fatfs.c +++ b/kernel/fatfs.c @@ -36,6 +36,9 @@ BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.8 2000/10/29 23:51:56 jimtabor + * Adding Share Support by Ron Cemer + * * Revision 1.7 2000/09/05 00:56:50 jimtabor * *** empty log message *** * @@ -199,6 +202,12 @@ struct f_node FAR *xlt_fd(COUNT); COUNT xlt_fnp(struct f_node FAR *); struct f_node FAR *split_path(BYTE FAR *, BYTE *, BYTE *, BYTE *); BOOL find_fname(struct f_node FAR *, BYTE *, BYTE *); + /* /// Added - Ron Cemer */ +static void merge_file_changes(struct f_node FAR *fnp, int collect); + /* /// Added - Ron Cemer */ +static int is_same_file(struct f_node FAR *fnp1, struct f_node FAR *fnp2); + /* /// Added - Ron Cemer */ +static int copy_file_changes(struct f_node FAR *src, struct f_node FAR *dst); date dos_getdate(VOID); time dos_gettime(VOID); BOOL find_free(struct f_node FAR *); @@ -255,13 +264,20 @@ COUNT dos_open(BYTE FAR * path, COUNT flag) fnp->f_highwater = fnp->f_dir.dir_size; fnp->f_back = LONG_LAST_CLUSTER; +/* /// Moved to below. - Ron Cemer fnp->f_cluster = fnp->f_dir.dir_start; - fnp->f_cluster_offset = 0l; /*JPP */ + fnp->f_cluster_offset = 0l; */ /*JPP */ fnp->f_flags.f_dmod = FALSE; fnp->f_flags.f_dnew = FALSE; fnp->f_flags.f_ddir = FALSE; + merge_file_changes(fnp, TRUE); /* /// Added - Ron Cemer */ + + /* /// Moved from above. - Ron Cemer */ + fnp->f_cluster = fnp->f_dir.dir_start; + fnp->f_cluster_offset = 0l; /*JPP */ + return xlt_fnp(fnp); } @@ -310,6 +326,7 @@ COUNT dos_close(COUNT fd) { fnp->f_dir.dir_size = fnp->f_highwater; fnp->f_flags.f_dmod = TRUE; + merge_file_changes(fnp, FALSE); /* /// Added - Ron Cemer */ } fnp->f_flags.f_ddir = TRUE; @@ -421,6 +438,74 @@ static BOOL find_fname(struct f_node FAR * fnp, BYTE * fname, BYTE * fext) return found; } + /* /// Added - Ron Cemer */ + /* If more than one f_node has a file open, and a write + occurs, this function must be called to propagate the + results of that write to the other f_nodes which have + that file open. Note that this function only has an + effect if SHARE is installed. This is for compatibility + reasons, since DOS without SHARE does not share changes + between two or more open instances of the same file + unless these instances were generated by dup() or dup2(). */ +static void merge_file_changes(struct f_node FAR *fnp, int collect) { + struct f_node FAR *fnp2; + int i; + + if (!IsShareInstalled()) return; + for (i = 0; i < NFILES; i++) { + fnp2 = &f_nodes[i]; + if ( (fnp != (struct f_node FAR *)0) + && (fnp != fnp2) + && (fnp->f_count > 0) + && (is_same_file(fnp, fnp2)) ) { + if (collect) { + /* We're collecting file changes from any other + f_node which refers to this file. */ + if (fnp2->f_mode != RDONLY) { + fnp2->f_dir.dir_size = fnp2->f_highwater; + copy_file_changes(fnp2, fnp); + break; + } + } else { + /* We just made changes to this file, so we are + distributing these changes to the other f_nodes + which refer to this file. */ + if (fnp->f_mode != RDONLY) + fnp->f_dir.dir_size = fnp->f_highwater; + copy_file_changes(fnp, fnp2); + } + } + } +} + + /* /// Added - Ron Cemer */ +static int is_same_file(struct f_node FAR *fnp1, struct f_node FAR *fnp2) { + return + (fnp1->f_dpb->dpb_unit == fnp2->f_dpb->dpb_unit) + && (fnp1->f_dpb->dpb_subunit == fnp2->f_dpb->dpb_subunit) + && (fcmp + ((BYTE FAR *)fnp1->f_dir.dir_name, + (BYTE FAR *)fnp2->f_dir.dir_name, FNAME_SIZE)) + && (fcmp + ((BYTE FAR *)fnp1->f_dir.dir_ext, + (BYTE FAR *)fnp2->f_dir.dir_ext, FEXT_SIZE)) + && ((fnp1->f_dir.dir_attrib & D_VOLID) == 0) + && ((fnp2->f_dir.dir_attrib & D_VOLID) == 0) + && (fnp1->f_flags.f_dremote == fnp2->f_flags.f_dremote) + && (fnp1->f_diroff == fnp2->f_diroff) + && (fnp1->f_dirstart == fnp2->f_dirstart) + && (fnp1->f_dpb == fnp2->f_dpb); +} + + /* /// Added - Ron Cemer */ +static int copy_file_changes(struct f_node FAR *src, struct f_node FAR *dst) { + dst->f_highwater = src->f_highwater; + dst->f_dir.dir_start = src->f_dir.dir_start; + dst->f_dir.dir_size = src->f_dir.dir_size; + dst->f_dir.dir_date = src->f_dir.dir_date; + dst->f_dir.dir_time = src->f_dir.dir_time; +} + COUNT dos_creat(BYTE FAR * path, COUNT attrib) { REG struct f_node FAR *fnp; @@ -521,6 +606,8 @@ COUNT dos_creat(BYTE FAR * path, COUNT attrib) fnp->f_flags.f_dnew = FALSE; fnp->f_flags.f_ddir = FALSE; + merge_file_changes(fnp, FALSE); /* /// Added - Ron Cemer */ + return xlt_fnp(fnp); } @@ -999,6 +1086,9 @@ BOOL dos_setfsize(COUNT fd, LONG size) /* Change the file size */ fnp->f_dir.dir_size = size; fnp->f_highwater = size; + + merge_file_changes(fnp, FALSE); /* /// Added - Ron Cemer */ + return TRUE; } @@ -1633,13 +1723,13 @@ UCOUNT writeblock(COUNT fd, VOID FAR * buffer, UCOUNT count, COUNT * err) if (count == 0) { fnp->f_highwater = fnp->f_offset; - + merge_file_changes(fnp, FALSE); /* /// Added - Ron Cemer */ *err = SUCCESS; return 0; } /* /// BUG!!! Moved to above previous block because we should NOT be able - to truncate the file if we can't write to it. - Ron Cemer + to truncate the file if we can't write to it. - Ron Cemer */ /* test that we have a valid mode for this fnode */ /* if (fnp->f_mode != WRONLY && fnp->f_mode != RDWR) @@ -1686,6 +1776,7 @@ UCOUNT writeblock(COUNT fd, VOID FAR * buffer, UCOUNT count, COUNT * err) fnp->f_back = LONG_LAST_CLUSTER; fnp->f_sector = 0; fnp->f_boff = 0; + merge_file_changes(fnp, FALSE); /* /// Added - Ron Cemer */ } /* The more difficult scenario is the (more common) */ @@ -1723,19 +1814,22 @@ UCOUNT writeblock(COUNT fd, VOID FAR * buffer, UCOUNT count, COUNT * err) return ret_cnt; case SUCCESS: + merge_file_changes(fnp, FALSE); /* /// Added - Ron Cemer */ break; } } /* XFR_WRITE case only - if we're at the end, the next */ /* FAT is an EOF marker, so just extend the file length */ - if (last_link(fnp)) + if (last_link(fnp)) { if (!extend(fnp)) { dir_close(fnp); *err = DE_HNDLDSKFULL; return ret_cnt; } + merge_file_changes(fnp, FALSE); /* /// Added - Ron Cemer */ + } /* Compute the block within the cluster and the offset */ /* within the block. */ @@ -1809,6 +1903,7 @@ UCOUNT writeblock(COUNT fd, VOID FAR * buffer, UCOUNT count, COUNT * err) fnp->f_highwater = fnp->f_offset; fnp->f_dir.dir_size = fnp->f_highwater; } + merge_file_changes(fnp, FALSE); /* /// Added - Ron Cemer */ } *err = SUCCESS; return ret_cnt; diff --git a/kernel/inthndlr.c b/kernel/inthndlr.c index 55b8930f..b445cd6a 100644 --- a/kernel/inthndlr.c +++ b/kernel/inthndlr.c @@ -36,6 +36,9 @@ BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.10 2000/10/29 23:51:56 jimtabor + * Adding Share Support by Ron Cemer + * * Revision 1.9 2000/08/06 05:50:17 jimtabor * Add new files and update cvs with patches and changes * @@ -1348,6 +1351,21 @@ VOID int21_service(iregs FAR * r) } break; +/* /// Added for SHARE. - Ron Cemer */ + /* Lock/unlock file access */ + case 0x5c: + if ((rc = DosLockUnlock + (r->BX, + (((unsigned long)r->CX)<<16)|(((unsigned long)r->DX)&0xffffL), + (((unsigned long)r->SI)<<16)|(((unsigned long)r->DI)&0xffffL), + ((r->AX & 0xff) != 0))) != 0) + r->FLAGS |= FLG_CARRY; + else + r->FLAGS &= ~FLG_CARRY; + r->AX = -rc; + break; +/* /// End of additions for SHARE. - Ron Cemer */ + /* UNDOCUMENTED: server, share.exe and sda function */ case 0x5d: switch (r->AL) From 0191c4bb2a11ed7aaa119222d92c275398fad021 Mon Sep 17 00:00:00 2001 From: Jim Tabor Date: Mon, 30 Oct 2000 00:03:40 +0000 Subject: [PATCH 038/671] Adding Share Support by Ron Cemer git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@78 6ac86273-5f31-0410-b378-82cca8765d1b --- docs/history.txt | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/docs/history.txt b/docs/history.txt index 26c6ac0a..73b1f518 100644 --- a/docs/history.txt +++ b/docs/history.txt @@ -1,3 +1,20 @@ +2000 Oct 29 - Build 2022 +-------- James Tabor (jimtabor@infohwy.com) + Rebuild local cvs tree after a crash. Update CVS at Sourceforge.net + with changes. + +2000 Sep 04 - Build 2022 +-------- James Tabor (jimtabor@infohwy.com) ++ ADD Adding Ron Cemer patch for Share support! + +2000 Sep 04 - Build 2022 +-------- James Tabor (jimtabor@infohwy.com) ++ Fixes Brian Reifsnyder (reifsnyderb@mindspring.com) + Modified dskxfer() such that error codes are now returned. + Functions that rely on dskxfer() have also been modified accordingly. + Modified interrupts 0x25 & 0x26 to return more accurate error codes. + Updated dskxfer() prototype. + 2000 Aug 15 - Build 2022 -------- James Tabor (jimtabor@infohwy.com) 2000/08/12 22:49:00 Ron Cemer (roncemer@gte.net) From c602b6a7ed463193819fd698fc175d1daee97e8e Mon Sep 17 00:00:00 2001 From: Jim Tabor Date: Mon, 30 Oct 2000 00:21:15 +0000 Subject: [PATCH 039/671] Adding Brian Reifsnyder Fix for Int 25/26 git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@79 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/blockio.c | 112 +++++++++++++++++++++++++++++----------------- kernel/inthndlr.c | 22 ++++++--- kernel/proto.h | 7 ++- 3 files changed, 93 insertions(+), 48 deletions(-) diff --git a/kernel/blockio.c b/kernel/blockio.c index 09748a49..dae4bf94 100644 --- a/kernel/blockio.c +++ b/kernel/blockio.c @@ -36,7 +36,14 @@ static BYTE *blockioRcsId = "$Id$"; #endif /* + * 2000/9/04 Brian Reifsnyder + * Modified dskxfer() such that error codes are now returned. + * Functions that rely on dskxfer() have also been modified accordingly. + * * $Log$ + * Revision 1.5 2000/10/30 00:21:15 jimtabor + * Adding Brian Reifsnyder Fix for Int 25/26 + * * Revision 1.4 2000/05/25 20:56:21 jimtabor * Fixed project history * @@ -226,14 +233,14 @@ struct buffer FAR *getblock(ULONG blkno, COUNT dsk) while (bp != NULL) { if ((bp->b_flag & BFR_VALID) && (bp->b_unit == dsk) - && (getblkno(bp) == blkno)) + && (getblkno(bp) == blkno)) { /* found it -- rearrange LRU links */ if (lbp != NULL) { - lbp->b_next = bp->b_next; - bp->b_next = firstbuf; - firstbuf = bp; + lbp->b_next = bp->b_next; + bp->b_next = firstbuf; + firstbuf = bp; } #ifdef DISPLAY_GETBLOCK printf("HIT]\n"); @@ -243,7 +250,7 @@ struct buffer FAR *getblock(ULONG blkno, COUNT dsk) else { if (bp->b_flag & BFR_FAT) - fat_count++; + fat_count++; mbp = lbp; /* move along to next buffer */ lbp = bp; bp = bp->b_next; @@ -282,7 +289,7 @@ struct buffer FAR *getblock(ULONG blkno, COUNT dsk) { /* put lbp at the top of the chain. */ if (mbp != NULL) - mbp->b_next = NULL; + mbp->b_next = NULL; lbp->b_next = firstbuf; firstbuf = bp = lbp; } @@ -304,7 +311,7 @@ struct buffer FAR *getblock(ULONG blkno, COUNT dsk) } /* take the buffer than lbp points to and flush it, then read new block. */ - if (flush1(lbp) && fill(lbp, blkno, dsk)) /* success */ + if (flush1(lbp) && fill(lbp, blkno, dsk)) /* success */ mbp = lbp; else mbp = NULL; /* failure */ @@ -341,14 +348,14 @@ BOOL getbuf(struct buffer FAR ** pbp, ULONG blkno, COUNT dsk) while (bp != NULL) { if ((bp->b_flag & BFR_VALID) && (bp->b_unit == dsk) - && (getblkno(bp) == blkno)) + && (getblkno(bp) == blkno)) { /* found it -- rearrange LRU links */ if (lbp != NULL) { - lbp->b_next = bp->b_next; - bp->b_next = firstbuf; - firstbuf = bp; + lbp->b_next = bp->b_next; + bp->b_next = firstbuf; + firstbuf = bp; } *pbp = bp; #ifdef DISPLAY_GETBLOCK @@ -359,7 +366,7 @@ BOOL getbuf(struct buffer FAR ** pbp, ULONG blkno, COUNT dsk) else { if (bp->b_flag & BFR_FAT) - fat_count++; + fat_count++; mbp = lbp; /* move along to next buffer */ lbp = bp; bp = bp->b_next; @@ -397,7 +404,7 @@ BOOL getbuf(struct buffer FAR ** pbp, ULONG blkno, COUNT dsk) { /* put lbp at the top of the chain. */ if (mbp != NULL) - mbp->b_next = NULL; + mbp->b_next = NULL; lbp->b_next = firstbuf; firstbuf = bp = lbp; } @@ -467,7 +474,7 @@ BOOL flush_buffers(REG COUNT dsk) { if (bp->b_unit == dsk) if (!flush1(bp)) - ok = FALSE; + ok = FALSE; bp = bp->b_next; } return ok; @@ -478,12 +485,14 @@ BOOL flush_buffers(REG COUNT dsk) /* */ BOOL flush1(struct buffer FAR * bp) { - REG WORD ok; +/* All lines with changes on 9/4/00 by BER marked below */ + + UWORD result; /* BER 9/4/00 */ if ((bp->b_flag & BFR_VALID) && (bp->b_flag & BFR_DIRTY)) { - ok = dskxfer(bp->b_unit, getblkno(bp), - (VOID FAR *) bp->b_buffer, 1, DSKWRITE); + result = dskxfer(bp->b_unit, getblkno(bp), + (VOID FAR *) bp->b_buffer, 1, DSKWRITE); /* BER 9/4/00 */ if (bp->b_flag & BFR_FAT) { int i = bp->b_copies; @@ -492,18 +501,19 @@ BOOL flush1(struct buffer FAR * bp) while (--i > 0) { - blkno += offset; - ok &= dskxfer(bp->b_unit, blkno, - (VOID FAR *) bp->b_buffer, 1, DSKWRITE); + blkno += offset; + result = dskxfer(bp->b_unit, blkno, + (VOID FAR *) bp->b_buffer, 1, DSKWRITE); /* BER 9/4/00 */ } } } else - ok = TRUE; + result = TRUE; /* This negates any error code returned in result...BER */ bp->b_flag &= ~BFR_DIRTY; /* even if error, mark not dirty */ - if (!ok) /* otherwise system has trouble */ + if (!result) /* otherwise system has trouble */ bp->b_flag &= ~BFR_VALID; /* continuing. */ - return (ok); + return (TRUE); /* Forced to TRUE...was like this before dskxfer() */ + /* returned error codes...BER */ } /* */ @@ -536,13 +546,21 @@ BOOL flush(void) sector is not already in the buffer ring */ BOOL fill(REG struct buffer FAR * bp, ULONG blkno, COUNT dsk) { - REG WORD ok; +/* Changed 9/4/00 BER */ + UWORD result; - ok = dskxfer(dsk, blkno, (VOID FAR *) bp->b_buffer, 1, DSKREAD); + result = dskxfer(dsk, blkno, (VOID FAR *) bp->b_buffer, 1, DSKREAD); +/* End of change */ bp->b_flag = BFR_VALID | BFR_DATA; bp->b_unit = dsk; setblkno(bp, blkno); - return (ok); + +/* Changed 9/4/00 BER */ + if(result==0) return(TRUE); /* Temporary code to convert the result to */ + else return(FALSE); /* the old BOOL result...BER */ + + /* return (result); This is what should eventually be returned */ +/* End of change */ } /************************************************************************/ @@ -553,20 +571,23 @@ BOOL fill(REG struct buffer FAR * bp, ULONG blkno, COUNT dsk) /* */ /* Transfer one or more blocks to/from disk */ /* */ -BOOL dskxfer(COUNT dsk, ULONG blkno, VOID FAR * buf, UWORD numblocks, COUNT mode) + +/* Changed to UWORD 9/4/00 BER */ +UWORD dskxfer(COUNT dsk, ULONG blkno, VOID FAR * buf, UWORD numblocks, COUNT mode) +/* End of change */ { /* REG struct dpb *dpbp = &blk_devices[dsk]; */ - REG struct dpb *dpbp = (struct dpb *)CDSp->cds_table[dsk].cdsDpb; + REG struct dpb *dpbp = (struct dpb *)CDSp->cds_table[dsk].cdsDpb; for (;;) { IoReqHdr.r_length = sizeof(request); IoReqHdr.r_unit = dpbp->dpb_subunit; IoReqHdr.r_command = - mode == DSKWRITE ? - (verify_ena ? C_OUTVFY : C_OUTPUT) - : C_INPUT; + mode == DSKWRITE ? + (verify_ena ? C_OUTVFY : C_OUTPUT) + : C_INPUT; IoReqHdr.r_status = 0; IoReqHdr.r_meddesc = dpbp->dpb_mdb; IoReqHdr.r_trans = (BYTE FAR *) buf; @@ -583,23 +604,32 @@ BOOL dskxfer(COUNT dsk, ULONG blkno, VOID FAR * buf, UWORD numblocks, COUNT mode break; else { +/* Changed 9/4/00 BER */ + return (IoReqHdr.r_status); + + /* Skip the abort, retry, fail code...it needs fixed...BER */ +/* End of change */ + loop: switch (block_error(&IoReqHdr, dpbp->dpb_unit, dpbp->dpb_device)) { - case ABORT: - case FAIL: - return FALSE; + case ABORT: + case FAIL: + return (IoReqHdr.r_status); - case RETRY: - continue; + case RETRY: + continue; - case CONTINUE: - break; + case CONTINUE: + break; - default: - goto loop; + default: + goto loop; } } } - return TRUE; +/* *** Changed 9/4/00 BER */ + return 0; /* Success! Return 0 for a successful operation. */ +/* End of change */ + } diff --git a/kernel/inthndlr.c b/kernel/inthndlr.c index b445cd6a..67e3c1e8 100644 --- a/kernel/inthndlr.c +++ b/kernel/inthndlr.c @@ -36,6 +36,12 @@ BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.11 2000/10/30 00:21:15 jimtabor + * Adding Brian Reifsnyder Fix for Int 25/26 + * + * 2000/09/04 Brian Reifsnyder + * Modified interrupts 0x25 & 0x26 to return more accurate error codes. + * * Revision 1.10 2000/10/29 23:51:56 jimtabor * Adding Share Support by Ron Cemer * @@ -1820,13 +1826,15 @@ VOID int25_handler(struct int25regs FAR * r) return; } - if (!dskxfer(drv, blkno, buf, nblks, DSKREAD)) +/* *** Changed 9/4/00 BER */ + r->ax=dskxfer(drv, blkno, buf, nblks, DSKREAD); + if (r->ax > 0) { - /* XXX: should tell the user exactly what the error was */ - r->ax = 0x202; r->flags |= FLG_CARRY; + --InDOS; return; } +/* End of change */ r->ax = 0; r->flags &= ~FLG_CARRY; @@ -1863,13 +1871,15 @@ VOID int26_handler(struct int25regs FAR * r) return; } - if (!dskxfer(drv, blkno, buf, nblks, DSKWRITE)) +/* *** Changed 9/4/00 BER */ + r->ax=dskxfer(drv, blkno, buf, nblks, DSKWRITE); + if (r->ax > 0) { - /* XXX: should tell the user exactly what the error was */ - r->ax = 0x202; r->flags |= FLG_CARRY; + --InDOS; return; } +/* End of change */ setinvld(drv); diff --git a/kernel/proto.h b/kernel/proto.h index 354d0141..906fee86 100644 --- a/kernel/proto.h +++ b/kernel/proto.h @@ -34,6 +34,9 @@ static BYTE *Proto_hRcsId = "$Id$"; /* * $Log$ + * Revision 1.8 2000/10/30 00:21:15 jimtabor + * Adding Brian Reifsnyder Fix for Int 25/26 + * * Revision 1.7 2000/08/07 22:51:34 jimtabor * Remove unused code * @@ -167,7 +170,9 @@ BOOL flush_buffers(REG COUNT dsk); BOOL flush1(struct buffer FAR * bp); BOOL flush(void); BOOL fill(REG struct buffer FAR * bp, ULONG blkno, COUNT dsk); -BOOL dskxfer(COUNT dsk, ULONG blkno, VOID FAR * buf, UWORD numblocks, COUNT mode); +/* *** Changed on 9/4/00 BER */ +UWORD dskxfer(COUNT dsk, ULONG blkno, VOID FAR * buf, UWORD numblocks, COUNT mode); +/* *** End of change /* chario.c */ VOID cso(COUNT c); From 603c15a253a59ab7bd045bd1721c2ac04b179308 Mon Sep 17 00:00:00 2001 From: Jim Tabor Date: Mon, 30 Oct 2000 00:32:08 +0000 Subject: [PATCH 040/671] Minor Fixes git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@80 6ac86273-5f31-0410-b378-82cca8765d1b --- docs/history.txt | 2 +- kernel/blockio.c | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/docs/history.txt b/docs/history.txt index 73b1f518..23ede3d6 100644 --- a/docs/history.txt +++ b/docs/history.txt @@ -9,7 +9,7 @@ 2000 Sep 04 - Build 2022 -------- James Tabor (jimtabor@infohwy.com) -+ Fixes Brian Reifsnyder (reifsnyderb@mindspring.com) ++ Fixes Brian Reifsnyder (reifsnyder@mindspring.com) Modified dskxfer() such that error codes are now returned. Functions that rely on dskxfer() have also been modified accordingly. Modified interrupts 0x25 & 0x26 to return more accurate error codes. diff --git a/kernel/blockio.c b/kernel/blockio.c index dae4bf94..58a4b55e 100644 --- a/kernel/blockio.c +++ b/kernel/blockio.c @@ -36,13 +36,15 @@ static BYTE *blockioRcsId = "$Id$"; #endif /* - * 2000/9/04 Brian Reifsnyder - * Modified dskxfer() such that error codes are now returned. - * Functions that rely on dskxfer() have also been modified accordingly. - * * $Log$ + * Revision 1.6 2000/10/30 00:32:08 jimtabor + * Minor Fixes + * * Revision 1.5 2000/10/30 00:21:15 jimtabor * Adding Brian Reifsnyder Fix for Int 25/26 + * 2000/9/04 Brian Reifsnyder + * Modified dskxfer() such that error codes are now returned. + * Functions that rely on dskxfer() have also been modified accordingly. * * Revision 1.4 2000/05/25 20:56:21 jimtabor * Fixed project history From 53be68df31b3ee6aa03642224c8f15897990f9c4 Mon Sep 17 00:00:00 2001 From: Jim Tabor Date: Mon, 30 Oct 2000 00:32:09 +0000 Subject: [PATCH 041/671] Minor Fixes git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@81 6ac86273-5f31-0410-b378-82cca8765d1b --- docs/history.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/history.txt b/docs/history.txt index 23ede3d6..73b1f518 100644 --- a/docs/history.txt +++ b/docs/history.txt @@ -9,7 +9,7 @@ 2000 Sep 04 - Build 2022 -------- James Tabor (jimtabor@infohwy.com) -+ Fixes Brian Reifsnyder (reifsnyder@mindspring.com) ++ Fixes Brian Reifsnyder (reifsnyderb@mindspring.com) Modified dskxfer() such that error codes are now returned. Functions that rely on dskxfer() have also been modified accordingly. Modified interrupts 0x25 & 0x26 to return more accurate error codes. From a29645f8a6aa5240df934f45f6f0d1177fc2eb4e Mon Sep 17 00:00:00 2001 From: Jim Tabor Date: Mon, 30 Oct 2000 01:13:01 +0000 Subject: [PATCH 042/671] Update 2022 git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@82 6ac86273-5f31-0410-b378-82cca8765d1b --- hdr/version.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hdr/version.h b/hdr/version.h index 4dcd3aff..d032b6a9 100644 --- a/hdr/version.h +++ b/hdr/version.h @@ -42,5 +42,5 @@ static BYTE *date_hRcsId = "$Id$"; #define REVISION_MAJOR 1 #define REVISION_MINOR 1 -#define REVISION_SEQ 21 -#define BUILD 2021 +#define REVISION_SEQ 22 +#define BUILD 2022 From 6967f811c3e9efe082879294f1bd3a823d06b55a Mon Sep 17 00:00:00 2001 From: Jim Tabor Date: Thu, 2 Nov 2000 06:56:53 +0000 Subject: [PATCH 043/671] Fix Share Patch git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@83 6ac86273-5f31-0410-b378-82cca8765d1b --- hdr/error.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/hdr/error.h b/hdr/error.h index 939b1790..83b90572 100644 --- a/hdr/error.h +++ b/hdr/error.h @@ -36,6 +36,9 @@ static BYTE *error_hRcsId = "$Id$"; /* * $Log$ + * Revision 1.4 2000/11/02 06:56:53 jimtabor + * Fix Share Patch + * * Revision 1.3 2000/05/25 20:56:19 jimtabor * Fixed project history * @@ -109,7 +112,10 @@ static BYTE *error_hRcsId = "$Id$"; #define DE_WRTPRTCT -19 /* No more files */ #define DE_BLKINVLD -20 /* invalid block */ #define DE_SEEK -25 /* error on file seek */ -#define DE_HNDLDSKFULL -39 /* handle disk full (?) */ +#define DE_HNDLDSKFULL -28 /* handle disk full (?) */ + +#define DE_DEADLOCK -36 +#define DE_LOCK -39 /* Critical error flags */ #define EFLG_READ 0x00 /* Read error */ From afa9874473ae966d5817b7772f642de37591915a Mon Sep 17 00:00:00 2001 From: Jim Tabor Date: Sat, 16 Dec 2000 01:38:35 +0000 Subject: [PATCH 044/671] Added patches from Bart Oldeman git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@89 6ac86273-5f31-0410-b378-82cca8765d1b --- docs/history.txt | 5 +++++ kernel/globals.h | 5 ++++- kernel/inthndlr.c | 5 ++++- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/docs/history.txt b/docs/history.txt index 73b1f518..eb49936c 100644 --- a/docs/history.txt +++ b/docs/history.txt @@ -1,3 +1,8 @@ +2000 Dec 15 - Build 2022 +-------- James Tabor (jimtabor@infohwy.com) ++ Fixes Added Patches from Bart Oldeman (Bart.Oldeman@bristol.ac.uk) + Fix for NLAST in globals.h and change default return in inthndlr.c. + 2000 Oct 29 - Build 2022 -------- James Tabor (jimtabor@infohwy.com) Rebuild local cvs tree after a crash. Update CVS at Sourceforge.net diff --git a/kernel/globals.h b/kernel/globals.h index 5c1dbdda..bbd5de3e 100644 --- a/kernel/globals.h +++ b/kernel/globals.h @@ -36,6 +36,9 @@ static BYTE *Globals_hRcsId = "$Id$"; /* * $Log$ + * Revision 1.6 2000/12/16 01:38:35 jimtabor + * Added patches from Bart Oldeman + * * Revision 1.5 2000/08/06 05:50:17 jimtabor * Add new files and update cvs with patches and changes * @@ -213,7 +216,7 @@ static BYTE *Globals_hRcsId = "$Id$"; #define NFCBS 16 /* number of fcbs */ #define NDEVS 8 /* number of supported devices */ #define NSTACKS 8 /* number of stacks */ -#define NLAST 2 /* last drive */ +#define NLAST 6 /* last drive */ #define NAMEMAX PARSE_MAX /* Maximum path for CDS */ #define NUMBUFF 6 /* Number of track buffers */ /* -- must be at least 3 */ diff --git a/kernel/inthndlr.c b/kernel/inthndlr.c index 67e3c1e8..45d48678 100644 --- a/kernel/inthndlr.c +++ b/kernel/inthndlr.c @@ -36,6 +36,9 @@ BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.12 2000/12/16 01:38:35 jimtabor + * Added patches from Bart Oldeman + * * Revision 1.11 2000/10/30 00:21:15 jimtabor * Adding Brian Reifsnyder Fix for Int 25/26 * @@ -346,7 +349,6 @@ VOID int21_service(iregs FAR * r) /* int 21h common error handler */ case 0x64: case 0x6b: - default: error_invalid: r->AX = -DE_INVLDFUNC; goto error_out; @@ -543,6 +545,7 @@ VOID int21_service(iregs FAR * r) #ifndef TSC case 0x61: #endif + default: r->AL = 0; break; From ec7800bfa3659142642a4798f4965c33ea29d3e2 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Mon, 19 Mar 2001 04:34:18 +0000 Subject: [PATCH 045/671] Update the redirector and Martin Stromberg changes to CVS. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@163 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/dosfns.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/kernel/dosfns.c b/kernel/dosfns.c index 75f927b1..3a33a14e 100644 --- a/kernel/dosfns.c +++ b/kernel/dosfns.c @@ -37,6 +37,12 @@ static BYTE *dosfnsRcsId = "$Id$"; * /// Added SHARE support. 2000/09/04 Ron Cemer * * $Log$ + * Revision 1.10 2001/03/19 04:34:18 bartoldeman + * Update the redirector and Martin Stromberg changes to CVS. + * + * Revision 1.10 2001/03/08 21:15:00 bartoldeman + * Redirector and DosSelectDrv() (Martin Stromberg) fixes + * * Revision 1.9 2000/10/29 23:51:56 jimtabor * Adding Share Support by Ron Cemer * @@ -625,7 +631,7 @@ COUNT SftSeek(sft FAR *s, LONG new_pos, COUNT mode) } else { - s->sft_posit = s->sft_size - new_pos; + s->sft_posit = s->sft_size + new_pos; return SUCCESS; } } @@ -1067,7 +1073,6 @@ COUNT DosClose(COUNT hndl) { int2f_Remote_call(REM_CLOSE, 0, 0, 0, (VOID FAR *) s, 0, 0); p->ps_filetab[hndl] = 0xff; - s->sft_flags = 0; return SUCCESS; } @@ -1406,7 +1411,7 @@ COUNT DosSetFattr(BYTE FAR * name, UWORD FAR * attrp) BYTE DosSelectDrv(BYTE drv) { - if ((drv <= (lastdrive -1 )) && (CDSp->cds_table[drv].cdsFlags & 0xf000)) + if ((0 <= drv) && (drv <= (lastdrive -1 )) &&(CDSp->cds_table[drv].cdsFlags & 0xf000)) { current_ldt = &CDSp->cds_table[drv]; default_drive = drv; From f22376eec8bee10d4f9a53af424f1c98c46376d4 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Mon, 19 Mar 2001 04:50:56 +0000 Subject: [PATCH 046/671] See history.txt for overview: put kernel 2022beo1 into CVS git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@164 6ac86273-5f31-0410-b378-82cca8765d1b --- config.m | 9 + docs/history.txt | 16 ++ hdr/portab.h | 10 +- kernel/config.c | 56 +++--- kernel/dsk.c | 213 +++++++++++++---------- kernel/fatdir.c | 10 +- kernel/fatfs.c | 9 +- kernel/inthndlr.c | 13 +- kernel/kernel.asm | 8 +- kernel/kernel.mak | 9 +- kernel/memmgr.c | 62 ++++--- kernel/nls/001-437.hc | 4 +- kernel/nls/049-850.hc | 4 +- kernel/nls_hc.asm | 4 +- kernel/nlssupt.asm | 11 +- kernel/prf.c | 389 ++++++++++++++++++++---------------------- kernel/task.c | 45 ++++- lib/libm.mak | 16 +- 18 files changed, 525 insertions(+), 363 deletions(-) diff --git a/config.m b/config.m index 840eb450..5f11ece5 100644 --- a/config.m +++ b/config.m @@ -20,6 +20,8 @@ #LIBPATH=$(COMPILERPATH)\lib #CLIB=$(COMPILERPATH)\lib\cs.lib #INCLUDEPATH=$(COMPILERPATH)\include +#MATH_EXTRACT=*LDIV *LLSH *LURSH *LXMUL *LRSH *SPUSH *SCOPY +#MATH_INSERT=+LDIV +LLSH +LURSH +LXMUL +LRSH +SPUSH +SCOPY # Use these for Turbo C 3.0 @@ -31,6 +33,8 @@ #LIBPATH=$(COMPILERPATH)\lib #CLIB=$(COMPILERPATH)\lib\cs.lib #INCLUDEPATH=$(COMPILERPATH)\include +#MATH_EXTRACT=*H_LDIV *H_LLSH *H_LURSH *N_LXMUL *F_LXMUL *H_LRSH *H_SPUSH *N_SCOPY +#MATH_INSERT=+H_LDIV +H_LLSH +H_LURSH +N_LXMUL +F_LXMUL +H_LRSH +H_SPUSH +N_SCOPY # Use these for Borland C++ @@ -42,12 +46,17 @@ #LIBPATH=$(COMPILERPATH)\lib #CLIB=$(COMPILERPATH)\lib\cs.lib #INCLUDEPATH=$(COMPILERPATH)\include +#MATH_EXTRACT=*H_LDIV *H_LLSH *H_LURSH *N_LXMUL *F_LXMUL *H_LRSH *H_SPUSH *N_SCOPY +#MATH_INSERT=+H_LDIV +H_LLSH +H_LURSH +N_LXMUL +F_LXMUL +H_LRSH +H_SPUSH +N_SCOPY # # $Id$ # # $Log$ +# Revision 1.4 2001/03/19 04:50:56 bartoldeman +# See history.txt for overview: put kernel 2022beo1 into CVS +# # Revision 1.3 2000/05/25 20:56:19 jimtabor # Fixed project history # diff --git a/docs/history.txt b/docs/history.txt index eb49936c..270f5fa6 100644 --- a/docs/history.txt +++ b/docs/history.txt @@ -1,3 +1,19 @@ +2001 Mar 08 - Build 2022 +-------- Bart Oldeman (bart.oldeman@bristol.ac.uk) ++ Fixes MCB chain corruption fix (thanks Tom Ehlert and Martin Stromberg) + Redirector fixes (CDROMs and DOSEmu lredir'ed drives appear to work fine now) + UMB fixes + Various recodings (dsk.c, prf.c, portab.h) to make kernel + object footprint 3k smaller (Tom Ehlert) + Fix handling of very long path names (Tom Ehlert) + FindFirst/FindNext fixes (Tom Ehlert) + Configuration for libm.mak is in config.mak (Martin Stromberg) + NLS fix to include pointer to CharMapSrvc. Note: these are + changes to automatically generated .asm files, but the + generator (GRAB_UNF.EXE) is missing. (thanks Tom Ehlert) + DosSelectDrv fix (Martin Stromberg) + config.c always converts to upper case and handles dos=umb correctly + 2000 Dec 15 - Build 2022 -------- James Tabor (jimtabor@infohwy.com) + Fixes Added Patches from Bart Oldeman (Bart.Oldeman@bristol.ac.uk) diff --git a/hdr/portab.h b/hdr/portab.h index 08f2783d..c948574d 100644 --- a/hdr/portab.h +++ b/hdr/portab.h @@ -36,6 +36,12 @@ static char *portab_hRcsId = "$Id$"; /* * $Log$ + * Revision 1.5 2001/03/19 04:50:56 bartoldeman + * See history.txt for overview: put kernel 2022beo1 into CVS + * + * Revision 1.5 2001/03/08 21:15:00 bartoldeman + * Fixes for MK_FP and friends from Tom Ehlert; reduces kernel by 1.5k. + * * Revision 1.4 2000/08/06 04:18:21 jimtabor * See history.txt * @@ -201,8 +207,8 @@ typedef signed long LONG; /* General far pointer macros */ #ifdef I86 #ifndef MK_FP -#define MK_FP(seg,ofs) ((VOID far *)(((LONG)(seg)<<16)|(UWORD)(ofs))) -#define FP_SEG(fp) ((UWORD)((LONG)(VOID FAR *)(fp)>>16)) +#define MK_FP(seg,ofs) ((VOID far *)(((ULONG)(seg)<<16)|(UWORD)(ofs))) +#define FP_SEG(fp) ((UWORD)((ULONG)(VOID FAR *)(fp)>>16)) #define FP_OFF(fp) ((UWORD)(fp)) #endif #endif diff --git a/kernel/config.c b/kernel/config.c index c3cdb285..38df5dad 100644 --- a/kernel/config.c +++ b/kernel/config.c @@ -39,6 +39,12 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.9 2001/03/19 04:50:56 bartoldeman + * See history.txt for overview: put kernel 2022beo1 into CVS + * + * Revision 1.9 2001/03/08 21:15:00 bartoldeman + * Fixed handling of "DOS=UMB", use toupper instead of tolower consistently. + * * Revision 1.8 2000/08/07 22:51:34 jimtabor * Remove unused code * @@ -206,23 +212,23 @@ struct table static struct table commands[] = { - {"break", 1, Break}, - {"buffers", 1, Buffers}, - {"command", 1, InitPgm}, - {"country", 1, Country}, - {"device", 2, Device}, - {"devicehigh", 2, DeviceHigh}, - {"dos", 2, Dosmem}, - {"fcbs", 1, Fcbs}, - {"files", 1, Files}, - {"lastdrive", 1, Lastdrive}, + {"BREAK", 1, Break}, + {"BUFFERS", 1, Buffers}, + {"COMMAND", 1, InitPgm}, + {"COUNTRY", 1, Country}, + {"DEVICE", 2, Device}, + {"DEVICEHIGH", 2, DeviceHigh}, + {"DOS", 2, Dosmem}, + {"FCBS", 1, Fcbs}, + {"FILES", 1, Files}, + {"LASTDRIVE", 1, Lastdrive}, /* rem is never executed by locking out pass */ - {"rem", 0, CfgFailure}, - {"shell", 1, InitPgm}, - {"stacks", 1, Stacks}, - {"switchar", 1, Switchar}, - {"screen", 1, sysScreenMode}, /* JPP */ - {"version", 1, sysVersion}, /* JPP */ + {"REM", 0, CfgFailure}, + {"SHELL", 1, InitPgm}, + {"STACKS", 1, Stacks}, + {"SWITCHAR", 1, Switchar}, + {"SCREEN", 1, sysScreenMode}, /* JPP */ + {"VERSION", 1, sysVersion}, /* JPP */ /* default action */ {"", -1, CfgFailure} }; @@ -403,8 +409,8 @@ INIT VOID configDone(VOID) if(UmbState == 1) { - mumcb_init((mcb FAR *) (MK_FP(0x9fff, 0)), - umb_start - 0x9fff - 1); + mumcb_init((mcb FAR *) (MK_FP(64*ram_top - 1, 0)), + umb_start - 64*ram_top); /* Check if any devices were loaded in umb */ if(umb_start != FP_SEG(upBase) ){ /* make last block normal with SC for the devices */ @@ -535,9 +541,9 @@ INIT VOID DoConfig(VOID) /* Skip leading white space and get verb. */ pLine = scan(pLine, szBuf); - /* Translate the verb to lower case ... */ + /* Translate the verb to upper case ... */ for (pTmp = szBuf; *pTmp != '\0'; pTmp++) - *pTmp = tolower(*pTmp); + *pTmp = toupper(*pTmp); /* If the line was blank, skip it. Otherwise, look up */ /* the verb and execute the appropriate function. */ @@ -715,11 +721,15 @@ INIT static VOID Lastdrive(BYTE * pLine) INIT static VOID Dosmem(BYTE * pLine) { + BYTE *pTmp; + if(UmbState == 0){ uppermem_link = 0; uppermem_root = 0; GetStringArg(pLine, szBuf); - UmbState = strcmp(szBuf, "UMB") ? 2 : 0; + for (pTmp = szBuf; *pTmp != '\0'; pTmp++) + *pTmp = toupper(*pTmp); + UmbState = strcmp(szBuf, "UMB") ? 0 : 2; } } @@ -861,7 +871,7 @@ INIT static VOID DeviceHigh(BYTE * pLine) } else { - printf("UMB's unavalable!\n"); + printf("UMB's unavailable!\n"); LoadDevice(pLine, ram_top, FALSE); } } @@ -1037,6 +1047,7 @@ INIT BYTE *GetNumber(REG BYTE * pszString, REG COUNT * pnNum) } /* Yet another change for true portability (WDL) */ +#if 0 INIT COUNT tolower(COUNT c) { if (c >= 'A' && c <= 'Z') @@ -1044,6 +1055,7 @@ INIT COUNT tolower(COUNT c) else return c; } +#endif /* Yet another change for true portability (PJV) */ INIT COUNT toupper(COUNT c) diff --git a/kernel/dsk.c b/kernel/dsk.c index 9a5b3d30..e6e69520 100644 --- a/kernel/dsk.c +++ b/kernel/dsk.c @@ -33,6 +33,12 @@ static BYTE *dskRcsId = "$Id$"; /* * $Log$ + * Revision 1.9 2001/03/19 04:50:56 bartoldeman + * See history.txt for overview: put kernel 2022beo1 into CVS + * + * Revision 1.9 2001/03/08 21:15:00 bartoldeman + * Space saving fixes from Tom Ehlert + * * Revision 1.8 2000/06/21 18:16:46 jimtabor * Add UMB code, patch, and code fixes * @@ -181,6 +187,10 @@ static struct FS_info fsarray[NDEV]; static bpb bpbarray[NDEV]; /* BIOS parameter blocks */ static bpb *bpbptrs[NDEV]; /* pointers to bpbs */ +/*TE - array access functions */ +struct media_info *getPMiarray(int dev) { return &miarray[dev];} + bpb *getPBpbarray(unsigned dev){ return &bpbarray[dev];} + #define N_PART 4 /* number of partitions per table partition */ @@ -226,7 +236,7 @@ WORD init(rqptr), blk_noerr(rqptr), blk_nondr(rqptr), blk_error(rqptr); -COUNT ltop(WORD *, WORD *, WORD *, COUNT, COUNT, LONG, byteptr); +COUNT ltop(WORD *, WORD *, WORD *, COUNT, COUNT, ULONG, byteptr); WORD dskerr(COUNT); COUNT processtable(COUNT ptDrive, BYTE ptHead, UWORD ptCylinder, BYTE ptSector, LONG ptAccuOff); #else @@ -311,7 +321,8 @@ COUNT processtable(COUNT ptDrive, BYTE ptHead, UWORD ptCylinder, LONG peStartSector; LONG peSectors; } - temp_part[N_PART]; + temp_part[N_PART], + *ptemp_part; /*TE*/ REG retry = N_RETRY; UBYTE packed_byte, @@ -363,49 +374,52 @@ COUNT processtable(COUNT ptDrive, BYTE ptHead, UWORD ptCylinder, array and process extended partitions */ for (Part = 0; Part < N_PART && nUnits < NDEV; Part++) { - if (temp_part[Part].peFileSystem == FAT12 || - temp_part[Part].peFileSystem == FAT16SMALL || - temp_part[Part].peFileSystem == FAT16LARGE) +/*TE*/ + ptemp_part = &temp_part[Part]; + + if (ptemp_part->peFileSystem == FAT12 || + ptemp_part->peFileSystem == FAT16SMALL || + ptemp_part->peFileSystem == FAT16LARGE) { miarray[nUnits].mi_offset = - temp_part[Part].peStartSector + ptAccuOff; + ptemp_part->peStartSector + ptAccuOff; miarray[nUnits].mi_drive = ptDrive; miarray[nUnits].mi_partidx = nPartitions; nUnits++; dos_partition[nPartitions].peDrive = ptDrive; dos_partition[nPartitions].peBootable = - temp_part[Part].peBootable; + ptemp_part->peBootable; dos_partition[nPartitions].peBeginHead = - temp_part[Part].peBeginHead; + ptemp_part->peBeginHead; dos_partition[nPartitions].peBeginSector = - temp_part[Part].peBeginSector; + ptemp_part->peBeginSector; dos_partition[nPartitions].peBeginCylinder = - temp_part[Part].peBeginCylinder; + ptemp_part->peBeginCylinder; dos_partition[nPartitions].peFileSystem = - temp_part[Part].peFileSystem; + ptemp_part->peFileSystem; dos_partition[nPartitions].peEndHead = - temp_part[Part].peEndHead; + ptemp_part->peEndHead; dos_partition[nPartitions].peEndSector = - temp_part[Part].peEndSector; + ptemp_part->peEndSector; dos_partition[nPartitions].peEndCylinder = - temp_part[Part].peEndCylinder; + ptemp_part->peEndCylinder; dos_partition[nPartitions].peStartSector = - temp_part[Part].peStartSector; + ptemp_part->peStartSector; dos_partition[nPartitions].peSectors = - temp_part[Part].peSectors; + ptemp_part->peSectors; dos_partition[nPartitions].peAbsStart = - temp_part[Part].peStartSector + ptAccuOff; + ptemp_part->peStartSector + ptAccuOff; nPartitions++; } - else if (temp_part[Part].peFileSystem == EXTENDED) + else if (ptemp_part->peFileSystem == EXTENDED) { /* call again to process extended part table */ processtable(ptDrive, - temp_part[Part].peBeginHead, - temp_part[Part].peBeginCylinder, - temp_part[Part].peBeginSector, - temp_part[Part].peStartSector + ptAccuOff); + ptemp_part->peBeginHead, + ptemp_part->peBeginCylinder, + ptemp_part->peBeginSector, + ptemp_part->peStartSector + ptAccuOff); }; }; return TRUE; @@ -429,6 +443,9 @@ static WORD init(rqptr rp) COUNT HardDrive, nHardDisk, Unit; + struct media_info *pmiarray; + bpb *pbpbarray; + /* Reset the drives */ fl_reset(0x80); @@ -441,26 +458,31 @@ static WORD init(rqptr rp) /* Setup media info and BPBs arrays */ for (Unit = 0; Unit < NDEV; Unit++) { - miarray[Unit].mi_size = 720l; - miarray[Unit].mi_heads = 2; - miarray[Unit].mi_cyls = 40; - miarray[Unit].mi_sectors = 9; - miarray[Unit].mi_offset = 0l; - miarray[Unit].mi_drive = Unit; + pmiarray = getPMiarray(Unit); + + pmiarray->mi_size = 720l; + pmiarray->mi_heads = 2; + pmiarray->mi_cyls = 40; + pmiarray->mi_sectors = 9; + pmiarray->mi_offset = 0l; + pmiarray->mi_drive = Unit; fsarray[Unit].fs_serialno = 0x12345678; +/*TE*/ + pbpbarray = getPBpbarray(Unit); - bpbarray[Unit].bpb_nbyte = SEC_SIZE; - bpbarray[Unit].bpb_nsector = 2; - bpbarray[Unit].bpb_nreserved = 1; - bpbarray[Unit].bpb_nfat = 2; - bpbarray[Unit].bpb_ndirent = 112; - bpbarray[Unit].bpb_nsize = 720l; - bpbarray[Unit].bpb_mdesc = 0xfd; - bpbarray[Unit].bpb_nfsect = 2; - bpbptrs[Unit] = &bpbarray[Unit]; + pbpbarray->bpb_nbyte = SEC_SIZE; + pbpbarray->bpb_nsector = 2; + pbpbarray->bpb_nreserved = 1; + pbpbarray->bpb_nfat = 2; + pbpbarray->bpb_ndirent = 112; + pbpbarray->bpb_nsize = 720l; + pbpbarray->bpb_mdesc = 0xfd; + pbpbarray->bpb_nfsect = 2; + + bpbptrs[Unit] = pbpbarray; }; nHardDisk = fl_nrdrives(); @@ -596,25 +618,31 @@ static WORD bldbpb(rqptr rp) ULONG count, i; byteptr trans; WORD local_word; +/*TE*/ + bpb *pbpbarray; + struct media_info *pmiarray; ret = RWzero( rp, 0); if (ret != 0) return (dskerr(ret)); - getword(&((((BYTE *) & buffer.bytes[BT_BPB]))[BPB_NBYTE]), &bpbarray[rp->r_unit].bpb_nbyte); - getbyte(&((((BYTE *) & buffer.bytes[BT_BPB]))[BPB_NSECTOR]), &bpbarray[rp->r_unit].bpb_nsector); - getword(&((((BYTE *) & buffer.bytes[BT_BPB]))[BPB_NRESERVED]), &bpbarray[rp->r_unit].bpb_nreserved); - getbyte(&((((BYTE *) & buffer.bytes[BT_BPB]))[BPB_NFAT]), &bpbarray[rp->r_unit].bpb_nfat); - getword(&((((BYTE *) & buffer.bytes[BT_BPB]))[BPB_NDIRENT]), &bpbarray[rp->r_unit].bpb_ndirent); - getword(&((((BYTE *) & buffer.bytes[BT_BPB]))[BPB_NSIZE]), &bpbarray[rp->r_unit].bpb_nsize); - getword(&((((BYTE *) & buffer.bytes[BT_BPB]))[BPB_NSIZE]), &bpbarray[rp->r_unit].bpb_nsize); - getbyte(&((((BYTE *) & buffer.bytes[BT_BPB]))[BPB_MDESC]), &bpbarray[rp->r_unit].bpb_mdesc); - getword(&((((BYTE *) & buffer.bytes[BT_BPB]))[BPB_NFSECT]), &bpbarray[rp->r_unit].bpb_nfsect); - getword(&((((BYTE *) & buffer.bytes[BT_BPB]))[BPB_NSECS]), &bpbarray[rp->r_unit].bpb_nsecs); - getword(&((((BYTE *) & buffer.bytes[BT_BPB]))[BPB_NHEADS]), &bpbarray[rp->r_unit].bpb_nheads); - getlong(&((((BYTE *) & buffer.bytes[BT_BPB])[BPB_HIDDEN])), &bpbarray[rp->r_unit].bpb_hidden); - getlong(&((((BYTE *) & buffer.bytes[BT_BPB])[BPB_HUGE])), &bpbarray[rp->r_unit].bpb_huge); +/*TE ~ 200 bytes*/ + pbpbarray = getPBpbarray(rp->r_unit); + + getword(&((((BYTE *) & buffer.bytes[BT_BPB]))[BPB_NBYTE]), &pbpbarray->bpb_nbyte); + getbyte(&((((BYTE *) & buffer.bytes[BT_BPB]))[BPB_NSECTOR]), &pbpbarray->bpb_nsector); + getword(&((((BYTE *) & buffer.bytes[BT_BPB]))[BPB_NRESERVED]), &pbpbarray->bpb_nreserved); + getbyte(&((((BYTE *) & buffer.bytes[BT_BPB]))[BPB_NFAT]), &pbpbarray->bpb_nfat); + getword(&((((BYTE *) & buffer.bytes[BT_BPB]))[BPB_NDIRENT]), &pbpbarray->bpb_ndirent); + getword(&((((BYTE *) & buffer.bytes[BT_BPB]))[BPB_NSIZE]), &pbpbarray->bpb_nsize); + getword(&((((BYTE *) & buffer.bytes[BT_BPB]))[BPB_NSIZE]), &pbpbarray->bpb_nsize); + getbyte(&((((BYTE *) & buffer.bytes[BT_BPB]))[BPB_MDESC]), &pbpbarray->bpb_mdesc); + getword(&((((BYTE *) & buffer.bytes[BT_BPB]))[BPB_NFSECT]), &pbpbarray->bpb_nfsect); + getword(&((((BYTE *) & buffer.bytes[BT_BPB]))[BPB_NSECS]), &pbpbarray->bpb_nsecs); + getword(&((((BYTE *) & buffer.bytes[BT_BPB]))[BPB_NHEADS]), &pbpbarray->bpb_nheads); + getlong(&((((BYTE *) & buffer.bytes[BT_BPB])[BPB_HIDDEN])), &pbpbarray->bpb_hidden); + getlong(&((((BYTE *) & buffer.bytes[BT_BPB])[BPB_HUGE])), &pbpbarray->bpb_huge); /* Needs fat32 offset code */ @@ -627,40 +655,43 @@ static WORD bldbpb(rqptr rp) #ifdef DSK_DEBUG - printf("BPB_NBYTE = %04x\n", bpbarray[rp->r_unit].bpb_nbyte); - printf("BPB_NSECTOR = %02x\n", bpbarray[rp->r_unit].bpb_nsector); - printf("BPB_NRESERVED = %04x\n", bpbarray[rp->r_unit].bpb_nreserved); - printf("BPB_NFAT = %02x\n", bpbarray[rp->r_unit].bpb_nfat); - printf("BPB_NDIRENT = %04x\n", bpbarray[rp->r_unit].bpb_ndirent); - printf("BPB_NSIZE = %04x\n", bpbarray[rp->r_unit].bpb_nsize); - printf("BPB_MDESC = %02x\n", bpbarray[rp->r_unit].bpb_mdesc); - printf("BPB_NFSECT = %04x\n", bpbarray[rp->r_unit].bpb_nfsect); + printf("BPB_NBYTE = %04x\n", pbpbarray->bpb_nbyte); + printf("BPB_NSECTOR = %02x\n", pbpbarray->bpb_nsector); + printf("BPB_NRESERVED = %04x\n", pbpbarray->bpb_nreserved); + printf("BPB_NFAT = %02x\n", pbpbarray->bpb_nfat); + printf("BPB_NDIRENT = %04x\n", pbpbarray->bpb_ndirent); + printf("BPB_NSIZE = %04x\n", pbpbarray->bpb_nsize); + printf("BPB_MDESC = %02x\n", pbpbarray->bpb_mdesc); + printf("BPB_NFSECT = %04x\n", pbpbarray->bpb_nfsect); #endif - rp->r_bpptr = &bpbarray[rp->r_unit]; - count = miarray[rp->r_unit].mi_size = - bpbarray[rp->r_unit].bpb_nsize == 0 ? - bpbarray[rp->r_unit].bpb_huge : - bpbarray[rp->r_unit].bpb_nsize; - getword((&(((BYTE *) & buffer.bytes[BT_BPB])[BPB_NHEADS])), &miarray[rp->r_unit].mi_heads); - head = miarray[rp->r_unit].mi_heads; - getword((&(((BYTE *) & buffer.bytes[BT_BPB])[BPB_NSECS])), &miarray[rp->r_unit].mi_sectors); - if (miarray[rp->r_unit].mi_size == 0) - getlong(&((((BYTE *) & buffer.bytes[BT_BPB])[BPB_HUGE])), &miarray[rp->r_unit].mi_size); - sector = miarray[rp->r_unit].mi_sectors; + rp->r_bpptr = pbpbarray; + + pmiarray = getPMiarray(rp->r_unit); + + count = pmiarray->mi_size = + pbpbarray->bpb_nsize == 0 ? + pbpbarray->bpb_huge : + pbpbarray->bpb_nsize; + getword((&(((BYTE *) & buffer.bytes[BT_BPB])[BPB_NHEADS])), &pmiarray->mi_heads); + head = pmiarray->mi_heads; + getword((&(((BYTE *) & buffer.bytes[BT_BPB])[BPB_NSECS])), &pmiarray->mi_sectors); + if (pmiarray->mi_size == 0) + getlong(&((((BYTE *) & buffer.bytes[BT_BPB])[BPB_HUGE])), &pmiarray->mi_size); + sector = pmiarray->mi_sectors; if (head == 0 || sector == 0) { tmark(); return failure(E_FAILURE); } - miarray[rp->r_unit].mi_cyls = count / (head * sector); + pmiarray->mi_cyls = count / (head * sector); tmark(); #ifdef DSK_DEBUG printf("BPB_NSECS = %04x\n", sector); printf("BPB_NHEADS = %04x\n", head); - printf("BPB_HIDDEN = %08lx\n", bpbarray[rp->r_unit].bpb_hidden); - printf("BPB_HUGE = %08lx\n", bpbarray[rp->r_unit].bpb_huge); + printf("BPB_HIDDEN = %08lx\n", pbpbarray->bpb_hidden); + printf("BPB_HUGE = %08lx\n", pbpbarray->bpb_huge); #endif return S_DONE; } @@ -893,29 +924,39 @@ static WORD dskerr(COUNT code) /* */ /* Do logical block number to physical head/track/sector mapping */ /* */ -static COUNT ltop(WORD * trackp, WORD * sectorp, WORD * headp, REG COUNT unit, COUNT count, LONG strt_sect, byteptr strt_addr) +static COUNT ltop(WORD * trackp, WORD * sectorp, WORD * headp, COUNT unit, COUNT count, ULONG strt_sect, byteptr strt_addr) { #ifdef I86 - ULONG ltemp; + UWORD utemp; #endif - REG ls, - ps; + REG struct media_info *pmiarray; #ifdef I86 +/*TE*/ /* Adjust for segmented architecture */ - ltemp = (((ULONG) mk_segment(strt_addr) << 4) + mk_offset(strt_addr)) & 0xffff; + utemp = (((UWORD) mk_segment(strt_addr) << 4) + mk_offset(strt_addr)); /* Test for 64K boundary crossing and return count large */ /* enough not to exceed the threshold. */ - count = (((ltemp + SEC_SIZE * count) & 0xffff0000l) != 0l) - ? (0xffffl - ltemp) / SEC_SIZE - : count; + +#define SEC_SHIFT 9 /* = 0x200 = 512 */ + + utemp >>= SEC_SHIFT; + + if (count > (0xffff >> SEC_SHIFT) - utemp) + { + count = (0xffff >> SEC_SHIFT) - utemp; + } + #endif - *trackp = strt_sect / (miarray[unit].mi_heads * miarray[unit].mi_sectors); - *sectorp = strt_sect % miarray[unit].mi_sectors + 1; - *headp = (strt_sect % (miarray[unit].mi_sectors * miarray[unit].mi_heads)) - / miarray[unit].mi_sectors; - if (*sectorp + count > miarray[unit].mi_sectors + 1) - count = miarray[unit].mi_sectors + 1 - *sectorp; +/*TE*/ + pmiarray = getPMiarray(unit); + + *trackp = strt_sect / (pmiarray->mi_heads * pmiarray->mi_sectors); + *sectorp = strt_sect % pmiarray->mi_sectors + 1; + *headp = (strt_sect % (pmiarray->mi_sectors * pmiarray->mi_heads)) + / pmiarray->mi_sectors; + if (*sectorp + count > pmiarray->mi_sectors + 1) + count = pmiarray->mi_sectors + 1 - *sectorp; return count; } diff --git a/kernel/fatdir.c b/kernel/fatdir.c index d005fbab..f4063175 100644 --- a/kernel/fatdir.c +++ b/kernel/fatdir.c @@ -36,6 +36,12 @@ static BYTE *fatdirRcsId = "$Id$"; /* * $Log$ + * Revision 1.10 2001/03/19 04:50:56 bartoldeman + * See history.txt for overview: put kernel 2022beo1 into CVS + * + * Revision 1.10 2001/03/08 21:00:00 bartoldeman + * Fix handling of very long path names (Tom Ehlert) + * * Revision 1.9 2000/08/06 05:50:17 jimtabor * Add new files and update cvs with patches and changes * @@ -583,7 +589,9 @@ COUNT dos_findfirst(UCOUNT attr, BYTE FAR * name) local_ext[FEXT_SIZE + 1], Tname[65]; - fscopy(name, (BYTE FAR *)&Tname); + fsncopy(name, (BYTE FAR *)&Tname, sizeof(Tname)); + Tname[sizeof(Tname)-1]=0; + /* printf("ff %s", Tname); */ diff --git a/kernel/fatfs.c b/kernel/fatfs.c index c3bfa725..102916a6 100644 --- a/kernel/fatfs.c +++ b/kernel/fatfs.c @@ -36,6 +36,12 @@ BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.9 2001/03/19 04:50:56 bartoldeman + * See history.txt for overview: put kernel 2022beo1 into CVS + * + * Revision 1.9 2001/03/08 21:00:00 bartoldeman + * Disabled select_unit() since it's not used + * * Revision 1.8 2000/10/29 23:51:56 jimtabor * Adding Share Support by Ron Cemer * @@ -2300,6 +2306,7 @@ COUNT xlt_fnp(struct f_node FAR * fnp) return fnp - f_nodes; } +#if 0 struct dhdr FAR *select_unit(COUNT drive) { /* Just get the header from the dhdr array */ @@ -2308,4 +2315,4 @@ struct dhdr FAR *select_unit(COUNT drive) return (struct dhdr FAR *)CDSp->cds_table[drive].cdsDpb; } - +#endif diff --git a/kernel/inthndlr.c b/kernel/inthndlr.c index 45d48678..26b34ae2 100644 --- a/kernel/inthndlr.c +++ b/kernel/inthndlr.c @@ -36,6 +36,12 @@ BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.13 2001/03/19 04:50:56 bartoldeman + * See history.txt for overview: put kernel 2022beo1 into CVS + * + * Revision 1.13 2001/03/08 21:00:00 bartoldeman + * MCB chain corruption and DosFindNext fix (thanks Martin Stromberg and Tom Ehlert) + * * Revision 1.12 2000/12/16 01:38:35 jimtabor * Added patches from Bart Oldeman * @@ -1199,6 +1205,7 @@ VOID int21_service(iregs FAR * r) else { r->FLAGS &= ~FLG_CARRY; + r->AX = -SUCCESS; } } break; @@ -1305,8 +1312,10 @@ VOID int21_service(iregs FAR * r) break; case 0x03: - DosUmbLink(r->BL); - break; + if (uppermem_root) { + DosUmbLink(r->BL); + break; + } /* else fall through */ default: goto error_invalid; diff --git a/kernel/kernel.asm b/kernel/kernel.asm index 9cfba57b..3afcbd89 100644 --- a/kernel/kernel.asm +++ b/kernel/kernel.asm @@ -28,6 +28,12 @@ ; $Id$ ; ; $Log$ +; Revision 1.6 2001/03/19 04:50:56 bartoldeman +; See history.txt for overview: put kernel 2022beo1 into CVS +; +; Revision 1.6 2001/03/08 21:15:00 bartoldeman +; uppermem_root initialised to 0 (no UMBs). +; ; Revision 1.5 2000/08/06 05:50:17 jimtabor ; Add new files and update cvs with patches and changes ; @@ -318,7 +324,7 @@ _uppermem_link db 0 ; 0063 upper memory link flag global _UMB_top _UMB_top dw 0 ; 0064 unknown UMB_top will do for now global _uppermem_root -_uppermem_root dw 0FFFFh ; 0066 dmd_upper_root +_uppermem_root dw 0 ; 0066 dmd_upper_root global _umb_start _umb_start dw 0 ; 0068 para of last mem search SysVarEnd: diff --git a/kernel/kernel.mak b/kernel/kernel.mak index 10988f6b..59dc98dc 100644 --- a/kernel/kernel.mak +++ b/kernel/kernel.mak @@ -5,6 +5,9 @@ # # $Log$ +# Revision 1.5 2001/03/19 04:50:56 bartoldeman +# See history.txt for overview: put kernel 2022beo1 into CVS +# # Revision 1.4 2000/08/06 05:50:17 jimtabor # Add new files and update cvs with patches and changes # @@ -209,7 +212,7 @@ clean: # XXX: This is a very ugly way of linking the kernel, forced upon us by the # inability of Turbo `make' 2.0 to perform command line redirection. -- ror4 kernel.exe: $(EXE_dependencies) $(LIBS) - del kernel.lib + $(RM) kernel.lib $(LIBUTIL) kernel +entry +io +blockio +chario +dosfns +console $(LIBUTIL) kernel +printer +serial +dsk +error +fatdir +fatfs $(LIBUTIL) kernel +fattab +fcbfns +initoem +inthndlr +ioctl +nls_hc @@ -218,9 +221,9 @@ kernel.exe: $(EXE_dependencies) $(LIBS) $(LIBUTIL) kernel +systime +task +int2f +irqstack +apisupt $(LIBUTIL) kernel +asmsupt +execrh +nlssupt +procsupt +break $(LIBUTIL) kernel +dosidle - del kernel.bak + $(RM) kernel.bak $(LINK) /m/c/L$(LIBPATH) kernel,kernel,kernel,kernel+$(LIBS); - del kernel.lib + $(RM) kernel.lib # *Individual File Dependencies* kernel.obj: kernel.asm segs.inc diff --git a/kernel/memmgr.c b/kernel/memmgr.c index cd1116dc..710e7066 100644 --- a/kernel/memmgr.c +++ b/kernel/memmgr.c @@ -35,6 +35,12 @@ static BYTE *memmgrRcsId = "$Id$"; /* * $Log$ + * Revision 1.8 2001/03/19 04:50:56 bartoldeman + * See history.txt for overview: put kernel 2022beo1 into CVS + * + * Revision 1.8 2001/03/08 21:00:00 bartoldeman + * UMB and MCB chain corruption (thanks Martin Stromberg) fixes + * * Revision 1.7 2000/08/07 04:53:54 jimtabor * Cleanup code * @@ -191,18 +197,19 @@ COUNT DosMemAlloc(UWORD size, COUNT mode, seg FAR * para, UWORD FAR * asize) REG mcb FAR *p; mcb FAR *foundSeg; mcb FAR *biggestSeg; - /* Initialize */ + +searchAgain: + p = para2far(first_mcb); biggestSeg = foundSeg = NULL; /* Hack to the Umb Region direct for now. Save time and program space. */ - if((mode & (FIRST_FIT_UO | FIRST_FIT_U)) && uppermem_link) { - if(uppermem_root) + if((mode != LARGEST) && (mode & (FIRST_FIT_UO | FIRST_FIT_U)) && + uppermem_link && uppermem_root) p = para2far(uppermem_root); - } /* Search through memory blocks */ FOREVER @@ -265,6 +272,11 @@ COUNT DosMemAlloc(UWORD size, COUNT mode, seg FAR * para, UWORD FAR * asize) if (!foundSeg || !foundSeg->m_size) { /* no block to fullfill the request */ + if((mode != LARGEST) && (mode & FIRST_FIT_UO) && + uppermem_link && uppermem_root) { + mode &= !FIRST_FIT_UO; + goto searchAgain; + } if (asize) *asize = biggestSeg ? biggestSeg->m_size : 0; return DE_NOMEM; @@ -337,7 +349,9 @@ COUNT DosMemLargest(UWORD FAR * size) COUNT found; /* Initialize */ - p = para2far(first_mcb); + p = ((mem_access_mode & (FIRST_FIT_UO | FIRST_FIT_U)) && uppermem_link && uppermem_root) + ? para2far(uppermem_root) + : para2far(first_mcb); /* Cycle through the whole MCB chain to find the largest unused area. Join all unused areas together. */ @@ -611,29 +625,28 @@ VOID DosUmbLink(BYTE n) { REG mcb FAR *p; REG mcb FAR *q; + mcb FAR *end_of_conv_mem = para2far(ram_top*64-1); - if(uppermem_root){ - - q = p = para2far(first_mcb); + q = p = para2far(first_mcb); /* like a xor thing! */ - if((uppermem_link == 1) && (n == 0)) + if((uppermem_link == 1) && (n == 0)) + { + while ( p != end_of_conv_mem ) { - while ( p != (mcb FAR *) para2far(0x9fff) ) - { - if (mcbFree(p)) - joinMCBs(p); - if (!mcbValid(p)) - goto DUL_exit; - q = p; - p = nxtMCB(p); - } - - if(q->m_type == MCB_NORMAL) - q->m_type = MCB_LAST; - uppermem_link = n; - + if (mcbFree(p)) + joinMCBs(p); + if (!mcbValid(p)) + goto DUL_exit; + q = p; + p = nxtMCB(p); } - else + + if(q->m_type == MCB_NORMAL) + q->m_type = MCB_LAST; + uppermem_link = n; + + } + else if((uppermem_link == 0) && (n == 1)) { while( q->m_type != MCB_LAST) @@ -647,7 +660,6 @@ VOID DosUmbLink(BYTE n) q->m_type = MCB_NORMAL; uppermem_link = n; } - } DUL_exit: return; } diff --git a/kernel/nls/001-437.hc b/kernel/nls/001-437.hc index 087c9e73..c963ee47 100644 --- a/kernel/nls/001-437.hc +++ b/kernel/nls/001-437.hc @@ -30,7 +30,9 @@ _nlsCountryInfoHardcoded: DB 01ch, 000h, 001h, 000h, 0b5h, 001h, 000h, 000h DB 024h, 000h, 000h, 000h, 000h, 02ch, 000h, 02eh DB 000h, 02dh, 000h, 03ah, 000h, 000h, 002h, 000h - DB 0e8h, 058h, 000h, 000h, 02ch, 000h +extern _CharMapSrvc:wrt TGROUP + DW _CharMapSrvc, SEG _CharMapSrvc + DB 02ch, 000h GLOBAL _hcTablesStart _hcTablesStart: GLOBAL _nlsFUpcaseHardcoded diff --git a/kernel/nls/049-850.hc b/kernel/nls/049-850.hc index aa4a6f9a..4f0204ab 100644 --- a/kernel/nls/049-850.hc +++ b/kernel/nls/049-850.hc @@ -30,7 +30,9 @@ _nlsCountryInfoHardcoded: DB 01ch, 000h, 031h, 000h, 052h, 003h, 001h, 000h DB 044h, 04dh, 000h, 000h, 000h, 02eh, 000h, 02ch DB 000h, 02eh, 000h, 03ah, 000h, 003h, 002h, 001h - DB 0e8h, 058h, 000h, 003h, 03bh, 000h +extern _CharMapSrvc:wrt TGROUP + DW _CharMapSrvc, SEG _CharMapSrvc + DB 03bh, 000h GLOBAL _hcTablesStart _hcTablesStart: GLOBAL _nlsFUpcaseHardcoded diff --git a/kernel/nls_hc.asm b/kernel/nls_hc.asm index 087c9e73..c963ee47 100644 --- a/kernel/nls_hc.asm +++ b/kernel/nls_hc.asm @@ -30,7 +30,9 @@ _nlsCountryInfoHardcoded: DB 01ch, 000h, 001h, 000h, 0b5h, 001h, 000h, 000h DB 024h, 000h, 000h, 000h, 000h, 02ch, 000h, 02eh DB 000h, 02dh, 000h, 03ah, 000h, 000h, 002h, 000h - DB 0e8h, 058h, 000h, 000h, 02ch, 000h +extern _CharMapSrvc:wrt TGROUP + DW _CharMapSrvc, SEG _CharMapSrvc + DB 02ch, 000h GLOBAL _hcTablesStart _hcTablesStart: GLOBAL _nlsFUpcaseHardcoded diff --git a/kernel/nlssupt.asm b/kernel/nlssupt.asm index b188c98a..c348b3cb 100644 --- a/kernel/nlssupt.asm +++ b/kernel/nlssupt.asm @@ -29,6 +29,13 @@ ; $Id$ ; ; $Log$ +; Revision 1.5 2001/03/19 04:50:56 bartoldeman +; See history.txt for overview: put kernel 2022beo1 into CVS +; +; +; Revision 1.5 2001/03/08 21:15:00 bartoldeman +; Fixed typo in dosUpChar (Tom Ehlert) +; ; Revision 1.4 2000/08/06 05:50:17 jimtabor ; Add new files and update cvs with patches and changes ; @@ -82,7 +89,7 @@ segment _TEXT global _CharMapSrvc - extern _upChar:wrt TGROUP + extern _DosUpChar:wrt TGROUP ; ; CharMapSrvc: ; User callable character mapping service. @@ -102,7 +109,7 @@ _CharMapSrvc: mov ax, DGROUP mov ds, ax - call _upChar + call _DosUpChar ;add sp, byte 2 // next POP retrieves orig AX pop bx diff --git a/kernel/prf.c b/kernel/prf.c index 919ebf21..e0bca677 100644 --- a/kernel/prf.c +++ b/kernel/prf.c @@ -34,6 +34,16 @@ static BYTE *prfRcsId = "$Id$"; /* * $Log$ + * Revision 1.4 2001/03/19 04:50:56 bartoldeman + * See history.txt for overview: put kernel 2022beo1 into CVS + * + * Revision 1.4 2001/03/07 10:00:00 tomehlert + * recoded for smaller object footprint, added main() for testing+QA + * + * $Log$ + * Revision 1.4 2001/03/19 04:50:56 bartoldeman + * See history.txt for overview: put kernel 2022beo1 into CVS + * * Revision 1.3 2000/05/25 20:56:21 jimtabor * Fixed project history * @@ -85,13 +95,11 @@ static BYTE *charp; VOID handle_char(COUNT); VOID put_console(COUNT); BYTE *ltob(LONG, BYTE *, COUNT); -static BYTE *itob(COUNT, BYTE *, COUNT); COUNT do_printf(CONST BYTE *, REG BYTE **); #else VOID handle_char(); VOID put_console(); BYTE *ltob(); -static BYTE *itob(); COUNT do_printf(); #endif @@ -122,75 +130,32 @@ static VOID } /* ltob -- convert an long integer to a string in any base (2-16) */ -static BYTE * +BYTE * ltob(LONG n, BYTE * s, COUNT base) { ULONG u; - REG BYTE *p, - *q; - REG negative, - c; + BYTE *p, *q; + int c; - if (n < 0 && base == -10) - { - negative = 1; - u = -n; - } - else - { - negative = 0; u = n; - } - if (base == -10) /* signals signed conversion */ - base = 10; - p = q = s; - do - { /* generate digits in reverse order */ - *p++ = "0123456789abcdef"[u % base]; - } - while ((u /= base) > 0); - if (negative) - *p++ = '-'; - *p = '\0'; /* terminate the string */ - while (q < --p) - { /* reverse the digits */ - c = *q; - *q++ = *p; - *p = c; - } - return s; -} - -/* itob -- convert an long integer to a string in any base (2-16) */ -static BYTE * - itob(COUNT n, BYTE * s, COUNT base) -{ - UWORD u; - REG BYTE *p, - *q; - REG negative, - c; - if (n < 0 && base == -10) - { - negative = 1; - u = -n; - } - else - { - negative = 0; - u = n; - } if (base == -10) /* signals signed conversion */ + { base = 10; + if (n < 0 ) + { + u = -n; + *s++ = '-'; + } + } + p = q = s; do { /* generate digits in reverse order */ *p++ = "0123456789abcdef"[u % base]; } while ((u /= base) > 0); - if (negative) - *p++ = '-'; + *p = '\0'; /* terminate the string */ while (q < --p) { /* reverse the digits */ @@ -201,9 +166,9 @@ static BYTE * return s; } -#define NONE 0 -#define LEFT 1 -#define RIGHT 2 + +#define LEFT 0 +#define RIGHT 1 /* printf -- short version of printf to conserve space */ WORD FAR @@ -214,7 +179,7 @@ WORD FAR } WORD -sprintf(BYTE * buff, CONST BYTE * fmt, BYTE * args) +sprintf(BYTE * buff, CONST BYTE * fmt, BYTE * args,...) { WORD ret; @@ -224,194 +189,214 @@ sprintf(BYTE * buff, CONST BYTE * fmt, BYTE * args) return ret; } -static COUNT - do_printf(CONST BYTE * fmt, REG BYTE ** arg) +COUNT + do_printf(CONST BYTE * fmt, BYTE ** arg) { - REG base; + int base; BYTE s[11], *p, *ltob(); - BYTE c, - slen, + int c, flag, size, fill; + int longarg; + long currentArg; - flag = NONE; - size = 0; while ((c = *fmt++) != '\0') { - if (size == 0 && flag == NONE && c != '%') + if (c != '%') { handle_char(c); continue; } - if (flag == NONE && *fmt == '0') + + longarg = FALSE; + size = 0; + flag = RIGHT; + fill = ' '; + + if ( *fmt == '-') + { + flag = LEFT; + fmt++; + } + + if ( *fmt == '0') { - flag = RIGHT; fill = '0'; + fmt++; } - switch (*fmt) + + while (*fmt >= '0' && *fmt <= '9') + { + size = size * 10 + (*fmt++ - '0'); + } + + + + if (*fmt == 'l') { - case '-': - flag = RIGHT; - fill = *(fmt + 1) == '0' ? '0' : ' '; - continue; - - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - if (flag == NONE) - flag = LEFT; - size = *fmt++ - '0'; - while ((c = *fmt++) != '\0') - { - switch (c) - { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - size = size * 10 + (c - '0'); - continue; - - default: - --fmt; - break; - } - break; - } - break; + longarg = TRUE; + fmt++; } + + switch (c = *fmt++) { + case '\0': + return 0; + case 'c': - handle_char(*(COUNT *) arg++); - continue; - - case 'd': - base = -10; - goto prt; + handle_char(*(COUNT *) arg++); + continue; - case 'o': - base = 8; - goto prt; - - case 'u': - base = 10; - goto prt; + case 's': + p = *((BYTE **) arg)++; + goto do_outputstring; - case 'x': - base = 16; - - prt: - itob(*((COUNT *) arg)++, s, base); - if (flag == RIGHT || flag == LEFT) - { - for (slen = 0, p = s; *p != '\0'; p++) - ++slen; - } - if (flag == RIGHT && slen < size) - { - WORD i; - - for (i = size - slen; i > 0; i--) - handle_char(fill); - } - for (p = s; *p != '\0'; p++) - handle_char(*p); - if (flag == LEFT) - { - WORD i; - BYTE sp = ' '; - - for (i = size - slen; i > 0; i--) - handle_char(sp); - } - size = 0; - flag = NONE; - continue; - - case 'l': - switch (c = *fmt++) - { - case 'd': + case 'd': base = -10; goto lprt; - case 'o': + case 'o': base = 8; goto lprt; - case 'u': + case 'u': base = 10; goto lprt; - case 'x': + case 'x': base = 16; lprt: - ltob(*((LONG *) arg)++, s, base); - if (flag == RIGHT || flag == LEFT) + if (longarg) + currentArg = *((LONG *) arg)++; + else + if (base < 0) currentArg = *((int*) arg)++; + else currentArg = *((unsigned int*) arg)++; + + + ltob(currentArg, s, base); + + p = s; +do_outputstring: + + size -= strlen(p); + + if (flag == RIGHT ) { - for (slen = 0, p = s; *p != '\0'; p++) - ++slen; - } - if (flag == RIGHT && slen < size) - { - WORD i; - - for (i = size - slen; i > 0; i--) + for ( ; size > 0; size--) handle_char(fill); } - for (p = s; *p != '\0'; p++) + for (; *p != '\0'; p++) handle_char(*p); - if (flag == LEFT) - { - WORD i; - BYTE sp = ' '; - for (i = size - slen; i > 0; i--) - handle_char(sp); - } - size = 0; - flag = NONE; + for ( ; size > 0; size--) + handle_char(fill); + continue; default: handle_char(c); - } + break; + - case 's': - for (p = *arg; *p != '\0'; p++) - { - --size; - handle_char(*p); - } - for (; size > 0; size--) - handle_char(' '); - ++arg; - size = 0; - flag = NONE; - continue; - - default: - handle_char(c); - continue; } } return 0; } + + +#ifdef TEST +/* + this testprogram verifies that the strings are printed correctly + ( or the way, I expect them to print) + + compile like (note -DTEST !) + + c:\tc\tcc -DTEST -DI86 -I..\hdr prf.c + + and run. if strings are wrong, the program will wait for the ANYKEY + +*/ +#include +void cso(char c) { putch(c); } + + +struct { + char *should; + char *format; + unsigned lowint; + unsigned highint; + +} testarray[] = + { + { "hello world", "%s %s", (unsigned)"hello",(unsigned)"world"}, + { "hello", "%3s", (unsigned)"hello",0}, + { " hello", "%7s", (unsigned)"hello",0}, + { "hello ", "%-7s", (unsigned)"hello",0}, + { "hello", "%s", (unsigned)"hello",0}, + + + + { "1", "%d", 1, 0}, + { "-1", "%d", -1,0}, + { "65535", "%u", -1,0}, + { "-32768", "%d", 0x8000,0}, + { "32767", "%d", 0x7fff,0}, + { "-32767", "%d", 0x8001,0}, + + {"8000", "%x", 0x8000, 0}, + {" 1", "%4x", 1, 0}, + {"0001", "%04x", 1, 0}, + {"1 ", "%-4x", 1, 0}, + {"1000", "%-04x", 1, 0}, + + { "1", "%ld", 1, 0}, + { "-1", "%ld", -1,-1}, + { "65535", "%ld", -1,0}, + { "65535", "%u", -1,0}, + {"8000", "%lx", 0x8000, 0}, + {"80000000", "%lx", 0,0x8000}, + {" 1", "%4lx", 1, 0}, + {"0001", "%04lx", 1, 0}, + {"1 ", "%-4lx", 1, 0}, + {"1000", "%-04lx", 1, 0}, + + { "-2147483648", "%ld", 0,0x8000}, + { "2147483648", "%lu", 0,0x8000}, + { "2147483649", "%lu", 1,0x8000}, + { "-2147483647", "%ld", 1,0x8000}, + { "32767", "%ld", 0x7fff,0}, + { "32769", "%ld", 0x8001,0}, + + + + 0 + }; + +test(char *should, char *format, unsigned lowint, unsigned highint) +{ + char b[100]; + + sprintf(b, format, lowint,highint); + + printf("'%s' = '%s'\n", should, b); + + if (strcmp(b,should)) { printf("\nhit the ANYKEY\n"); getch(); } +} + + +main() +{ + int i; + printf("hello world\n"); + + for (i = 0; testarray[i].should; i++) + { + test(testarray[i].should,testarray[i].format, testarray[i].lowint, testarray[i].highint); + } +} +#endif diff --git a/kernel/task.c b/kernel/task.c index 447e2386..1f6ca26c 100644 --- a/kernel/task.c +++ b/kernel/task.c @@ -35,6 +35,12 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.6 2001/03/19 04:50:56 bartoldeman + * See history.txt for overview: put kernel 2022beo1 into CVS + * + * Revision 1.6 2001/03/08 21:00:00 bartoldeman + * UMB fixes to DosComLoader + * * Revision 1.5 2000/08/06 05:50:17 jimtabor * Add new files and update cvs with patches and changes * @@ -246,7 +252,7 @@ COUNT ChildEnv(exec_blk FAR * exp, UWORD * pChildEnvSeg, char far * pathname) /* allocate enough space for env + path */ if ((RetCode = DosMemAlloc(long2para(nEnvSize + ENV_KEEPFREE), - FIRST_FIT, (seg FAR *) pChildEnvSeg, + mem_access_mode, (seg FAR *) pChildEnvSeg, NULL /*(UWORD FAR *) MaxEnvSize ska */ )) < 0) return RetCode; pDest = MK_FP(*pChildEnvSeg + 1, 0); @@ -457,12 +463,39 @@ static COUNT DosComLoader(BYTE FAR * namep, exec_blk FAR * exp, COUNT mode) { return rc; } - /* Allocate our memory and pass back any errors */ - if ((rc = DosMemAlloc(0, LARGEST, (seg FAR *) & mem, (UWORD FAR *) & asize)) < 0) + /* Now find out how many paragraphs are available */ + if ((rc = DosMemLargest((seg FAR *) & asize)) != SUCCESS) { - DosMemFree(env); /* env may be 0 */ + DosMemFree(env); return rc; } + com_size = asize; + /* Allocate our memory and pass back any errors */ + if ((rc = DosMemAlloc((seg) com_size, mem_access_mode, (seg FAR *) & mem + ,(UWORD FAR *) & asize)) < 0) + { + if (rc == DE_NOMEM) + { + if ((rc = DosMemAlloc(0, LARGEST, (seg FAR *) & mem + ,(UWORD FAR *) & asize)) < 0) + { + DosMemFree(env); + return rc; + } + /* This should never happen, but ... */ + if (asize < com_size) + { + DosMemFree(mem); + DosMemFree(env); + return rc; + } + } + else + { + DosMemFree(env); /* env may be 0 */ + return rc; + } + } ++mem; } else @@ -675,7 +708,7 @@ static COUNT DosExeLoader(BYTE FAR * namep, exec_blk FAR * exp, COUNT mode) /* Allocate our memory and pass back any errors */ /* We can still get an error on first fit if the above */ /* returned size was a bet fit case */ - if ((rc = DosMemAlloc((seg) exe_size, FIRST_FIT, (seg FAR *) & mem + if ((rc = DosMemAlloc((seg) exe_size, mem_access_mode, (seg FAR *) & mem ,(UWORD FAR *) & asize)) < 0) { if (rc == DE_NOMEM) @@ -686,7 +719,7 @@ static COUNT DosExeLoader(BYTE FAR * namep, exec_blk FAR * exp, COUNT mode) DosMemFree(env); return rc; } - /* This should never happen, but ... */ + /* This should never happen, but ... */ if (asize < exe_size) { DosMemFree(mem); diff --git a/lib/libm.mak b/lib/libm.mak index 55763177..d97d8d63 100644 --- a/lib/libm.mak +++ b/lib/libm.mak @@ -5,6 +5,12 @@ # # $Log$ +# Revision 1.4 2001/03/19 04:50:56 bartoldeman +# See history.txt for overview: put kernel 2022beo1 into CVS +# +# Revision 1.4 2001/03/08 21:15:00 bartoldeman +# Fix from Martin Stromberg to make this fully configurable from config.mak +# # Revision 1.3 2000/05/25 20:56:22 jimtabor # Fixed project history # @@ -32,13 +38,9 @@ libm.lib: $(CLIB) -# use these for Turbo 2 - $(LIBUTIL) $(CLIB) *LDIV *LLSH *LURSH *LXMUL *LRSH *SPUSH *SCOPY - $(LIBUTIL) libm +LDIV +LLSH +LURSH +LXMUL +LRSH +SPUSH +SCOPY -# use these for Turbo 3 or better -# $(LIBUTIL) $(CLIB) *H_LDIV *H_LLSH *H_LURSH *N_LXMUL *F_LXMUL *H_LRSH *H_SPUSH *N_SCOPY -# $(LIBUTIL) libm +H_LDIV +H_LLSH +H_LURSH +N_LXMUL +F_LXMUL +H_LRSH +H_SPUSH +N_SCOPY - del *.OBJ + $(LIBUTIL) $(CLIB) $(MATH_EXTRACT) + $(LIBUTIL) libm $(MATH_INSERT) + $(RM) *.OBJ clobber: clean From 1c12f47465ae6bedfc204d8c44288ef56dd0b9b9 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Mon, 19 Mar 2001 05:01:38 +0000 Subject: [PATCH 047/671] Space saving and partition detection fixes from Tom Ehlert and Brian Reifsnyder. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@165 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/dsk.c | 367 ++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 257 insertions(+), 110 deletions(-) diff --git a/kernel/dsk.c b/kernel/dsk.c index e6e69520..7a8dd63f 100644 --- a/kernel/dsk.c +++ b/kernel/dsk.c @@ -33,8 +33,9 @@ static BYTE *dskRcsId = "$Id$"; /* * $Log$ - * Revision 1.9 2001/03/19 04:50:56 bartoldeman - * See history.txt for overview: put kernel 2022beo1 into CVS + * Revision 1.10 2001/03/19 05:01:38 bartoldeman + * Space saving and partition detection fixes from Tom Ehlert and + * Brian Reifsnyder. * * Revision 1.9 2001/03/08 21:15:00 bartoldeman * Space saving fixes from Tom Ehlert @@ -123,6 +124,17 @@ static BYTE *dskRcsId = "$Id$"; * Initial revision. */ +#if 0 + #define PartCodePrintf(x) printf x +#else + #define PartCodePrintf(x) +#endif + +#define STATIC + + + + #ifdef PROTO BOOL fl_reset(WORD); COUNT fl_readdasd(WORD); @@ -143,7 +155,7 @@ COUNT fl_verify(); BOOL fl_format(); #endif -#define NDEV 8 /* only one for demo */ +#define NDEV 16 /* only one for demo */ #define SEC_SIZE 512 /* size of sector in bytes */ #define N_RETRY 5 /* number of retries permitted */ #define NENTRY 26 /* total size of dispatch table */ @@ -157,7 +169,7 @@ union } buffer; -static struct media_info +STATIC struct media_info { ULONG mi_size; /* physical sector count */ UWORD mi_heads; /* number of heads (sides) */ @@ -182,10 +194,10 @@ static struct Access_info BYTE AI_Flag; }; -static struct media_info miarray[NDEV]; /* Internal media info structs */ -static struct FS_info fsarray[NDEV]; -static bpb bpbarray[NDEV]; /* BIOS parameter blocks */ -static bpb *bpbptrs[NDEV]; /* pointers to bpbs */ +STATIC struct media_info miarray[NDEV]; /* Internal media info structs */ +STATIC struct FS_info fsarray[NDEV]; +STATIC bpb bpbarray[NDEV]; /* BIOS parameter blocks */ +STATIC bpb *bpbptrs[NDEV]; /* pointers to bpbs */ /*TE - array access functions */ struct media_info *getPMiarray(int dev) { return &miarray[dev];} @@ -194,17 +206,12 @@ struct media_info *getPMiarray(int dev) { return &miarray[dev];} #define N_PART 4 /* number of partitions per table partition */ -static WORD head, - track, - sector, - ret; /* globals for blockio */ -static WORD count; -static COUNT nUnits; /* number of returned units */ -static COUNT nPartitions; /* number of DOS partitions */ +STATIC COUNT nUnits; /* number of returned units */ +STATIC COUNT nPartitions; /* number of DOS partitions */ #define PARTOFF 0x1be -static struct +STATIC struct dos_partitionS { BYTE peDrive; /* BIOS drive number */ BYTE peBootable; @@ -238,7 +245,7 @@ WORD init(rqptr), blk_error(rqptr); COUNT ltop(WORD *, WORD *, WORD *, COUNT, COUNT, ULONG, byteptr); WORD dskerr(COUNT); -COUNT processtable(COUNT ptDrive, BYTE ptHead, UWORD ptCylinder, BYTE ptSector, LONG ptAccuOff); +COUNT processtable(int table_type,COUNT ptDrive, BYTE ptHead, UWORD ptCylinder, BYTE ptSector, LONG ptAccuOff); #else WORD init(), mediachk(), @@ -298,14 +305,61 @@ static WORD(*dispatch[NENTRY]) () = #define SIZEOF_PARTENT 16 +#define PRIMARY 0x01 + #define FAT12 0x01 #define FAT16SMALL 0x04 #define EXTENDED 0x05 #define FAT16LARGE 0x06 +#define EXTENDED_INT32 0x0f /* like 0x05, but uses extended INT32 */ #define hd(x) ((x) & 0x80) -COUNT processtable(COUNT ptDrive, BYTE ptHead, UWORD ptCylinder, + + +ULONG StartSector(WORD ptDrive, unsigned BeginHead, + unsigned BeginSector, + unsigned BeginCylinder, + ULONG peStartSector, + ULONG ptAccuOff) +{ + iregs regs; + + unsigned cylinders,heads,sectors; + ULONG startPos; + + regs.a.x = 0x0800; /* get drive parameters */ + regs.d.x = ptDrive; + intr(0x13, ®s); + + if ((regs.a.x & 0xff) != 0) + { + PartCodePrintf(("error getting drive parameters for drive %x\n", ptDrive)); + return peStartSector+ptAccuOff; + } + + /* cylinders = (regs.c.x >>8) | ((regs.c.x & 0x0c) << 2); */ + heads = (regs.d.x >> 8) + 1; + sectors = regs.c.x & 0x3f; + + startPos = ((ULONG)BeginCylinder * heads + BeginHead) * sectors + BeginSector - 1; + + PartCodePrintf((" CHS %x %x %x (%d %d %d) --> %lx ( %ld)\n", + BeginHead, + BeginSector, + BeginCylinder, + BeginHead, + BeginSector, + BeginCylinder, + startPos, startPos)); + + return startPos; +} + + + + +COUNT processtable(int table_type,COUNT ptDrive, BYTE ptHead, UWORD ptCylinder, BYTE ptSector, LONG ptAccuOff) { struct /* Temporary partition table */ @@ -324,104 +378,165 @@ COUNT processtable(COUNT ptDrive, BYTE ptHead, UWORD ptCylinder, temp_part[N_PART], *ptemp_part; /*TE*/ - REG retry = N_RETRY; + int retry; UBYTE packed_byte, pb1; - COUNT Part; +/* COUNT Part; */ + BYTE *p; + int partition_chain = 0; + int ret; + +restart: /* yes, it's a GOTO >:-) */ + + /* if someone has a circular linked + extended partition list, stop it sooner or later */ + if (partition_chain > 64) + return TRUE; + + + PartCodePrintf(("searching partition table at %x %x %x %x %lx\n", + ptDrive, ptHead, ptCylinder, + ptSector, ptAccuOff)); /* Read partition table */ - do + for ( retry = N_RETRY; --retry >= 0; ) { ret = fl_read((WORD) ptDrive, (WORD) ptHead, (WORD) ptCylinder, (WORD) ptSector, (WORD) 1, (byteptr) & buffer); + if (ret == 0) + break; } - while (ret != 0 && --retry > 0); if (ret != 0) return FALSE; /* Read each partition into temporary array */ - for (Part = 0; Part < N_PART; Part++) + + p = (BYTE *) & buffer.bytes[PARTOFF]; + + for (ptemp_part = &temp_part[0]; + ptemp_part < &temp_part[N_PART]; ptemp_part++) { - REG BYTE *p = - (BYTE *) & buffer.bytes[PARTOFF + (Part * SIZEOF_PARTENT)]; - - getbyte((VOID *) p, &temp_part[Part].peBootable); - ++p; - getbyte((VOID *) p, &temp_part[Part].peBeginHead); - ++p; - getbyte((VOID *) p, &packed_byte); - temp_part[Part].peBeginSector = packed_byte & 0x3f; - ++p; - getbyte((VOID *) p, &pb1); - ++p; - temp_part[Part].peBeginCylinder = pb1 + ((UWORD) (0xc0 & packed_byte) << 2); - getbyte((VOID *) p, &temp_part[Part].peFileSystem); - ++p; - getbyte((VOID *) p, &temp_part[Part].peEndHead); - ++p; - getbyte((VOID *) p, &packed_byte); - temp_part[Part].peEndSector = packed_byte & 0x3f; - ++p; - getbyte((VOID *) p, &pb1); - ++p; - temp_part[Part].peEndCylinder = pb1 + ((UWORD) (0xc0 & packed_byte) << 2); - getlong((VOID *) p, &temp_part[Part].peStartSector); - p += sizeof(LONG); - getlong((VOID *) p, &temp_part[Part].peSectors); - }; + + getbyte((VOID *) (p+0), &ptemp_part->peBootable); + getbyte((VOID *) (p+1), &ptemp_part->peBeginHead); + getbyte((VOID *) (p+2), &packed_byte); + ptemp_part->peBeginSector = packed_byte & 0x3f; + getbyte((VOID *) (p+3), &pb1); + ptemp_part->peBeginCylinder = pb1 + ((UWORD) (0xc0 & packed_byte) << 2); + getbyte((VOID *) (p+4), &ptemp_part->peFileSystem); + getbyte((VOID *) (p+5), &ptemp_part->peEndHead); + getbyte((VOID *) (p+6), &packed_byte); + ptemp_part->peEndSector = packed_byte & 0x3f; + getbyte((VOID *) (p+7), &pb1); + ptemp_part->peEndCylinder = pb1 + ((UWORD) (0xc0 & packed_byte) << 2); + getlong((VOID *) (p+8), &ptemp_part->peStartSector); + getlong((VOID *) (p+12), &ptemp_part->peSectors); + + p += SIZEOF_PARTENT; /* == 16 */ + } /* Walk through the table, add DOS partitions to global array and process extended partitions */ - for (Part = 0; Part < N_PART && nUnits < NDEV; Part++) + for (ptemp_part = &temp_part[0]; + ptemp_part < &temp_part[N_PART] && nUnits < NDEV; ptemp_part++) { -/*TE*/ - ptemp_part = &temp_part[Part]; - - if (ptemp_part->peFileSystem == FAT12 || - ptemp_part->peFileSystem == FAT16SMALL || - ptemp_part->peFileSystem == FAT16LARGE) + + /* when searching the EXT chain, + must skip primary partitions */ + if ( ( (table_type==PRIMARY) + || ( (table_type==EXTENDED) && (partition_chain!=0) ) ) && + ( ptemp_part->peFileSystem == FAT12 || + ptemp_part->peFileSystem == FAT16SMALL || + ptemp_part->peFileSystem == FAT16LARGE) ) { - miarray[nUnits].mi_offset = - ptemp_part->peStartSector + ptAccuOff; - miarray[nUnits].mi_drive = ptDrive; - miarray[nUnits].mi_partidx = nPartitions; + struct dos_partitionS *pdos_partition; + + struct media_info *pmiarray = getPMiarray(nUnits); + + pmiarray->mi_offset = ptemp_part->peStartSector + ptAccuOff; + + PartCodePrintf(("mioffset1 = %lx - ", pmiarray->mi_offset)); + pmiarray->mi_drive = ptDrive; + pmiarray->mi_partidx = nPartitions; + + { + ULONG newStartPos = StartSector(ptDrive, + ptemp_part->peBeginHead, + ptemp_part->peBeginSector, + ptemp_part->peBeginCylinder, + ptemp_part->peStartSector, + ptAccuOff); + + if (newStartPos != pmiarray->mi_offset) + { + printf("PART TABLE mismatch for drive %x, CHS=%d %d %d, startsec %d, offset %ld\n", + ptemp_part->peBeginCylinder, + ptemp_part->peBeginHead, + ptemp_part->peBeginSector, + ptemp_part->peStartSector, + ptAccuOff); + printf(" old startpos = %ld, new startpos = %ld, taking new\n", + pmiarray->mi_offset, newStartPos); + + pmiarray->mi_offset = newStartPos; + } + } + nUnits++; - dos_partition[nPartitions].peDrive = ptDrive; - dos_partition[nPartitions].peBootable = - ptemp_part->peBootable; - dos_partition[nPartitions].peBeginHead = - ptemp_part->peBeginHead; - dos_partition[nPartitions].peBeginSector = - ptemp_part->peBeginSector; - dos_partition[nPartitions].peBeginCylinder = - ptemp_part->peBeginCylinder; - dos_partition[nPartitions].peFileSystem = - ptemp_part->peFileSystem; - dos_partition[nPartitions].peEndHead = - ptemp_part->peEndHead; - dos_partition[nPartitions].peEndSector = - ptemp_part->peEndSector; - dos_partition[nPartitions].peEndCylinder = - ptemp_part->peEndCylinder; - dos_partition[nPartitions].peStartSector = - ptemp_part->peStartSector; - dos_partition[nPartitions].peSectors = - ptemp_part->peSectors; - dos_partition[nPartitions].peAbsStart = - ptemp_part->peStartSector + ptAccuOff; + pdos_partition = &dos_partition[nPartitions]; + + pdos_partition->peDrive = ptDrive; + pdos_partition->peBootable = ptemp_part->peBootable; + pdos_partition->peBeginHead = ptemp_part->peBeginHead; + pdos_partition->peBeginSector = ptemp_part->peBeginSector; + pdos_partition->peBeginCylinder=ptemp_part->peBeginCylinder; + pdos_partition->peFileSystem =ptemp_part->peFileSystem; + pdos_partition->peEndHead =ptemp_part->peEndHead; + pdos_partition->peEndSector =ptemp_part->peEndSector; + pdos_partition->peEndCylinder =ptemp_part->peEndCylinder; + pdos_partition->peStartSector =ptemp_part->peStartSector; + pdos_partition->peSectors =ptemp_part->peSectors; + pdos_partition->peAbsStart =ptemp_part->peStartSector + ptAccuOff; + + PartCodePrintf(("DOS PARTITION drive %x CHS %x-%x-%x %x-%x-%x %lx %lx %lx FS %x\n", + pdos_partition->peDrive, + pdos_partition->peBeginCylinder, + pdos_partition->peBeginHead , + pdos_partition->peBeginSector , + pdos_partition->peEndCylinder , + pdos_partition->peEndHead , + pdos_partition->peEndSector , + pdos_partition->peStartSector , + pdos_partition->peSectors , + pdos_partition->peAbsStart , + pdos_partition->peFileSystem + )); + + nPartitions++; } - else if (ptemp_part->peFileSystem == EXTENDED) + } + for (ptemp_part = &temp_part[0]; + ptemp_part < &temp_part[N_PART] && nUnits < NDEV; ptemp_part++) + { + if ( (table_type==EXTENDED) && + (ptemp_part->peFileSystem == EXTENDED || + ptemp_part->peFileSystem == EXTENDED_INT32 ) ) { - /* call again to process extended part table */ - processtable(ptDrive, - ptemp_part->peBeginHead, - ptemp_part->peBeginCylinder, - ptemp_part->peBeginSector, - ptemp_part->peStartSector + ptAccuOff); - }; - }; + /* restart with new extended part table, don't recurs */ + partition_chain++; + + ptHead = ptemp_part->peBeginHead; + ptCylinder = ptemp_part->peBeginCylinder; + ptSector = ptemp_part->peBeginSector; + ptAccuOff = ptemp_part->peStartSector + ptAccuOff; + + goto restart; + } + + } + return TRUE; } @@ -469,10 +584,8 @@ static WORD init(rqptr rp) fsarray[Unit].fs_serialno = 0x12345678; -/*TE*/ pbpbarray = getPBpbarray(Unit); - pbpbarray->bpb_nbyte = SEC_SIZE; pbpbarray->bpb_nsector = 2; pbpbarray->bpb_nreserved = 1; @@ -483,16 +596,32 @@ static WORD init(rqptr rp) pbpbarray->bpb_nfsect = 2; bpbptrs[Unit] = pbpbarray; - }; + } nHardDisk = fl_nrdrives(); + + /* as rather well documented, DOS searches 1st) all primary patitions on + all drives, 2nd) all extended partitions. that + makes many people (including me) unhappy, as all DRIVES D:,E:... + on 1st disk will move up/down, if other disk with + primary partitions are added/removed, but + thats the way it is (hope I got it right) + TE (with a little help from my friends) */ + for (HardDrive = 0; HardDrive < nHardDisk; HardDrive++) { /* Process primary partition table */ - if (!processtable((HardDrive | 0x80), 0, 0l, 1, 0l)) + if (!processtable(PRIMARY, (HardDrive | 0x80), 0, 0l, 1, 0l)) /* Exit if no hard drive */ break; - }; + } + for (HardDrive = 0; HardDrive < nHardDisk; HardDrive++) + { + /* Process extended partition table */ + if (!processtable(EXTENDED, (HardDrive | 0x80), 0, 0l, 1, 0l)) + /* Exit if no hard drive */ + break; + } rp->r_nunits = nUnits; rp->r_bpbptr = bpbptrs; @@ -533,9 +662,11 @@ static WORD mediachk(rqptr rp) /* * Read Write Sector Zero or Hard Drive Dos Bpb */ -static WORD RWzero(rqptr rp, WORD t) +STATIC WORD RWzero(rqptr rp, WORD t) { REG retry = N_RETRY; + WORD head,track,sector,ret; + if (hd(miarray[rp->r_unit].mi_drive)) { @@ -585,6 +716,7 @@ static WORD Getlogdev(rqptr rp) static WORD Setlogdev(rqptr rp) { + UNREFERENCED_PARAMETER(rp); return S_DONE; } @@ -602,6 +734,7 @@ static WORD blk_Close(rqptr rp) static WORD blk_nondr(rqptr rp) { + UNREFERENCED_PARAMETER(rp); return S_BUSY|S_DONE; } @@ -613,7 +746,7 @@ static WORD blk_Media(rqptr rp) return S_DONE; /* Floppy */ } -static WORD bldbpb(rqptr rp) +STATIC WORD bldbpb(rqptr rp) { ULONG count, i; byteptr trans; @@ -621,6 +754,7 @@ static WORD bldbpb(rqptr rp) /*TE*/ bpb *pbpbarray; struct media_info *pmiarray; + WORD head,track,sector,ret; ret = RWzero( rp, 0); @@ -647,10 +781,14 @@ static WORD bldbpb(rqptr rp) /* Needs fat32 offset code */ getlong(&((((BYTE *) & buffer.bytes[0x27])[0])), &fsarray[rp->r_unit].fs_serialno); +/*TE for(i = 0; i < 11 ;i++ ) fsarray[rp->r_unit].fs_volume[i] = buffer.bytes[0x2B + i]; for(i = 0; i < 8; i++ ) fsarray[rp->r_unit].fs_fstype[i] = buffer.bytes[0x36 + i]; +*/ + memcpy(fsarray[rp->r_unit].fs_volume,&buffer.bytes[0x2B], 11); + memcpy(fsarray[rp->r_unit].fs_fstype,&buffer.bytes[0x36], 8); @@ -696,7 +834,7 @@ static WORD bldbpb(rqptr rp) return S_DONE; } -static COUNT write_and_verify(WORD drive, WORD head, WORD track, WORD sector, +STATIC COUNT write_and_verify(WORD drive, WORD head, WORD track, WORD sector, WORD count, BYTE FAR * buffer) { REG COUNT ret; @@ -725,6 +863,7 @@ static WORD IoctlQueblk(rqptr rp) static WORD Genblkdev(rqptr rp) { + int ret; switch(rp->r_count){ case 0x0860: /* get device parameters */ { @@ -771,10 +910,8 @@ static WORD Genblkdev(rqptr rp) struct FS_info FAR * fs = &fsarray[rp->r_unit]; gioc->ioc_serialno = fs->fs_serialno; - for(i = 0; i < 11 ;i++ ) - gioc->ioc_volume[i] = fs->fs_volume[i]; - for(i = 0; i < 8; i++ ) - gioc->ioc_fstype[i] = fs->fs_fstype[i]; + fmemcpy(gioc->ioc_volume,fs->fs_volume,11); + fmemcpy(gioc->ioc_fstype, fs->fs_fstype,8); } break; case 0x0846: /* set volume serial number */ @@ -808,8 +945,7 @@ static WORD Genblkdev(rqptr rp) return S_DONE; } - -static WORD blockio(rqptr rp) +WORD blockio(rqptr rp) { REG retry = N_RETRY, remaining; @@ -817,6 +953,8 @@ static WORD blockio(rqptr rp) total; ULONG start; byteptr trans; + WORD head,track,sector,ret,count; + COUNT(*action) (WORD, WORD, WORD, WORD, WORD, BYTE FAR *); cmd = rp->r_command; @@ -832,6 +970,10 @@ static WORD blockio(rqptr rp) ) { count = ltop(&track, §or, &head, rp->r_unit, remaining, start, trans); + + /*printf("dskAction %02x THS=%x-%x-%x block=%lx\n", rp->r_unit,track, head, sector, start);*/ + + do { switch (cmd) @@ -848,6 +990,8 @@ static WORD blockio(rqptr rp) default: return failure(E_FAILURE); } + + if (count) ret = action((WORD) miarray[rp->r_unit].mi_drive, head, track, sector, count, trans); @@ -886,6 +1030,7 @@ static WORD blk_error(rqptr rp) static WORD blk_noerr(rqptr rp) { + UNREFERENCED_PARAMETER(rp); return S_DONE; } @@ -924,12 +1069,13 @@ static WORD dskerr(COUNT code) /* */ /* Do logical block number to physical head/track/sector mapping */ /* */ -static COUNT ltop(WORD * trackp, WORD * sectorp, WORD * headp, COUNT unit, COUNT count, ULONG strt_sect, byteptr strt_addr) +COUNT ltop(WORD * trackp, WORD * sectorp, WORD * headp, COUNT unit, COUNT count, ULONG strt_sect, byteptr strt_addr) { #ifdef I86 UWORD utemp; #endif - REG struct media_info *pmiarray; + struct media_info *pmiarray; + #ifdef I86 /*TE*/ @@ -954,9 +1100,10 @@ static COUNT ltop(WORD * trackp, WORD * sectorp, WORD * headp, COUNT unit, COUNT *trackp = strt_sect / (pmiarray->mi_heads * pmiarray->mi_sectors); *sectorp = strt_sect % pmiarray->mi_sectors + 1; - *headp = (strt_sect % (pmiarray->mi_sectors * pmiarray->mi_heads)) + *headp = (strt_sect % (pmiarray->mi_heads * pmiarray->mi_sectors)) / pmiarray->mi_sectors; if (*sectorp + count > pmiarray->mi_sectors + 1) count = pmiarray->mi_sectors + 1 - *sectorp; return count; } + From 513094d9fe3c186a1a800f311ecbeae5d53b709e Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Mon, 19 Mar 2001 05:08:53 +0000 Subject: [PATCH 048/671] New macros from Tom Ehlert to save even more bytes. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@166 6ac86273-5f31-0410-b378-82cca8765d1b --- hdr/portab.h | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/hdr/portab.h b/hdr/portab.h index c948574d..deb48a96 100644 --- a/hdr/portab.h +++ b/hdr/portab.h @@ -36,8 +36,8 @@ static char *portab_hRcsId = "$Id$"; /* * $Log$ - * Revision 1.5 2001/03/19 04:50:56 bartoldeman - * See history.txt for overview: put kernel 2022beo1 into CVS + * Revision 1.6 2001/03/19 05:08:53 bartoldeman + * New macros from Tom Ehlert to save even more bytes. * * Revision 1.5 2001/03/08 21:15:00 bartoldeman * Fixes for MK_FP and friends from Tom Ehlert; reduces kernel by 1.5k. @@ -218,3 +218,24 @@ typedef signed long LONG; #define FP_SEG(fp) (0) #define FP_OFF(fp) (fp) #endif + +/* + this suppresses the warning + unreferenced parameter 'x' + and (hopefully) generates no code +*/ + +#if defined(__TURBOC__) + #define UNREFERENCED_PARAMETER(x) if (x); +#else + #define UNREFERENCED_PARAMETER(x) x; +#endif + + +#if defined(__TURBOC__) + #define FDCALL pascal + #define CDECL cdecl +#else + #define FDCALL + #define CDECL +#endif \ No newline at end of file From f2184025dafe49ebbb29b0ce4861a1695a825aba Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Wed, 21 Mar 2001 02:56:26 +0000 Subject: [PATCH 049/671] See history.txt for changes. Bug fixes and HMA support are the main ones. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@167 6ac86273-5f31-0410-b378-82cca8765d1b --- docs/history.txt | 25 +++ drivers/devend.asm | 13 +- drivers/floppy.asm | 99 ++++----- drivers/getvec.asm | 7 +- drivers/rdpcclk.asm | 8 +- drivers/timer.asm | 8 +- drivers/wratclk.asm | 7 +- drivers/wrpcclk.asm | 7 +- hdr/portab.h | 4 +- hdr/version.h | 4 +- kernel/apisupt.asm | 5 +- kernel/asmsupt.asm | 479 +++++++++++++++++++++++++++++++++++++------- kernel/blockio.c | 314 ++++++++++++----------------- kernel/break.c | 27 ++- kernel/config.c | 367 ++++++++++++++++++++++++++------- kernel/console.asm | 5 +- kernel/dosfns.c | 14 +- kernel/dosidle.asm | 4 +- kernel/dosnames.c | 19 +- kernel/dsk.c | 249 ++++++++++++----------- kernel/entry.asm | 49 +++-- kernel/execrh.asm | 5 +- kernel/fatdir.c | 109 +++++----- kernel/fatfs.c | 18 +- kernel/fcbfns.c | 33 +-- kernel/globals.h | 30 ++- kernel/init-mod.h | 35 ++-- kernel/int2f.asm | 19 +- kernel/inthndlr.c | 376 ++++++++++++++++++---------------- kernel/intr.asm | 90 ++++++++- kernel/intr.h | 1 + kernel/io.asm | 37 ++-- kernel/io.inc | 14 +- kernel/kernel.asm | 424 +++++++++++++++++++++++++++++++++++++-- kernel/kernel.mak | 25 ++- kernel/main.c | 103 ++++++---- kernel/memmgr.c | 23 ++- kernel/misc.c | 5 + kernel/network.c | 9 +- kernel/nls.c | 9 +- kernel/nlssupt.asm | 16 +- kernel/prf.c | 61 +++++- kernel/procsupt.asm | 13 +- kernel/proto.h | 82 ++++++-- kernel/segs.inc | 11 +- kernel/strings.c | 5 + kernel/sysclk.c | 63 +++--- kernel/systime.c | 131 ++++++------ kernel/task.c | 10 +- sys/sys.mak | 10 +- 50 files changed, 2383 insertions(+), 1098 deletions(-) diff --git a/docs/history.txt b/docs/history.txt index 270f5fa6..e82fd1cd 100644 --- a/docs/history.txt +++ b/docs/history.txt @@ -1,3 +1,28 @@ +2001 Mar 21 - Build 2022 +-------- Bart Oldeman (bart.oldeman@bristol.ac.uk) ++ Clean A lot of space savings by Tom Ehlert, merely because Turbo C 2.01 does not + do it. And several more complicated situations as well, like coding some + string functions in assembly (asmsupt.asm). ++ Add Tom Ehlert: support for DOS=HIGH. Now most of the kernel can be loaded into + the HMA. This required a lot of segmentation changes. Let's hope the best + of it. Support for device drivers with multiple devices. ++ Fixes From Tom Ehlert: + task.c bug fix (image_size is in bytes) + dosfns.c change dir to E:\FREEDOS\*.PRJ fix + fcbfns.c fixes. + break.c Ctrl-C Ctrl-C -> crash temporary fix. ++ Fixes From Bart: + Let UMBs work again after HMA changes. + Be able to compile sys.com again. Is now really a .exe file but still masks + as .com in the hope that we can make it a real .com again. + DeviceHigh loads low if there are not enough UMB's available. + Fixed another redirector problem. ++ Update Optimized asmsupt.asm a bit with help of the glibc 2.2 source. ++ Fixes Tom Ehlert and Brian Reifsnyder: fix partition detection in dsk.c + + other bug fixes (also: floppy.asm). ++ Update Tom Ehlert optimized blockio.c. ++ Fixes a few small ones from Tom I forgot. + 2001 Mar 08 - Build 2022 -------- Bart Oldeman (bart.oldeman@bristol.ac.uk) + Fixes MCB chain corruption fix (thanks Tom Ehlert and Martin Stromberg) diff --git a/drivers/devend.asm b/drivers/devend.asm index a15c2500..30bff1ef 100644 --- a/drivers/devend.asm +++ b/drivers/devend.asm @@ -30,6 +30,9 @@ ; $Header$ ; ; $Log$ +; Revision 1.4 2001/03/21 02:56:25 bartoldeman +; See history.txt for changes. Bug fixes and HMA support are the main ones. +; ; Revision 1.3 2000/05/25 20:56:19 jimtabor ; Fixed project history ; @@ -66,20 +69,20 @@ ;Initial revision. ; -group TGROUP _TEXT -group DGROUP _DATA + %include "..\kernel\segs.inc" + segment _DATA align=2 class=DATA - extern last:wrt DGROUP + extern __bssend:wrt DGROUP -segment _TEXT class=CODE +segment HMA_TEXT global _device_end _device_end: push bp mov bp,sp - mov ax,last + mov ax,__bssend mov dx,DGROUP pop bp ret diff --git a/drivers/floppy.asm b/drivers/floppy.asm index 728beabf..aa502ccc 100644 --- a/drivers/floppy.asm +++ b/drivers/floppy.asm @@ -30,6 +30,9 @@ ; $Id$ ; ; $Log$ +; Revision 1.4 2001/03/21 02:56:25 bartoldeman +; See history.txt for changes. Bug fixes and HMA support are the main ones. +; ; Revision 1.3 2000/05/25 20:56:19 jimtabor ; Fixed project history ; @@ -77,9 +80,9 @@ ;Initial revision. ; -group TGROUP _TEXT + %include "..\kernel\segs.inc" -segment _TEXT class=CODE +segment HMA_TEXT ; ; @@ -211,37 +214,6 @@ _fl_rd_status: ; ; Returns 0 if successful, error code otherwise. ; - global _fl_read -_fl_read: - push bp ; C entry - mov bp,sp - - mov dl,[bp+4] ; get the drive (if or'ed 80h its - ; hard drive. - mov dh,[bp+6] ; get the head number - mov ch,[bp+8] ; cylinder number (lo only if hard) - mov al,[bp+9h] ; get the top of cylinder - xor ah,ah - mov cl,6 ; form top of cylinder for sector - shl ax,cl - mov cl,[bp+0Ah] ; sector number - and cl,03fh ; mask to sector field bits 5-0 - or cl,al ; or in bits 7-6 - mov al,[bp+0Ch] - les bx,[bp+0Eh] ; Load 32 bit buffer ptr - - mov ah,2 - int 13h ; read sectors to memory es:bx - - mov al,ah - jc fl_rd1 ; error, return error code - xor al,al ; Zero transfer count -fl_rd1: - xor ah,ah ; force into < 255 count - pop bp - ret - - ; ; Write Sectors ; @@ -251,60 +223,59 @@ fl_rd1: ; ; Returns 0 if successful, error code otherwise. ; + global _fl_read +_fl_read: + mov ah,2 ; cmd READ + jmp short fl_common + + global _fl_verify +_fl_verify: + mov ah,4 ; cmd verify + jmp short fl_common + global _fl_write _fl_write: + mov ah,3 ; cmd WRITE + +fl_common: push bp ; C entry mov bp,sp mov dl,[bp+4] ; get the drive (if or'ed 80h its ; hard drive. mov dh,[bp+6] ; get the head number - mov ch,[bp+8] ; cylinder number (lo only if hard) - mov al,[bp+9h] ; get the top of cylinder - xor ah,ah - mov cl,6 ; form top of cylinder for sector - shl ax,cl + mov bx,[bp+8] ; cylinder number (lo only if hard) + + mov al,1 ; this should be an error code + cmp bx,3ffh ; this code can't write above 3ff=1023 + ja fl_error + + mov ch,bl ; low 8 bits of cyl number + + xor bl,bl ; extract bits 8+9 to cl + shr bx,1 + shr bx,1 + + mov cl,[bp+0Ah] ; sector number and cl,03fh ; mask to sector field bits 5-0 - or cl,al ; or in bits 7-6 - mov al,[bp+0Ch] + or cl,bl ; or in bits 7-6 + + mov al,[bp+0Ch] ; count to read/write les bx,[bp+0Eh] ; Load 32 bit buffer ptr - mov ah,3 int 13h ; write sectors from mem es:bx mov al,ah jc fl_wr1 ; error, return error code xor al,al ; Zero transfer count fl_wr1: +fl_error: xor ah,ah ; force into < 255 count pop bp ret -; -; SUBROUTINE -; - - global _fl_verify -_fl_verify: - push bp - mov bp,sp - mov dl,[bp+4] - mov dh,[bp+6] - mov ch,[bp+8] - mov cl,[bp+0Ah] - mov al,[bp+0Ch] - mov ah,4 - int 13h ; Disk dl=drive a: ah=func 04h - ; verify sectors with mem es:bx - mov al,ah - jc fl_ver1 ; Jump if carry Set - xor al,al ; Zero register -fl_ver1: - xor ah,ah ; Zero register - pop bp - ret global _fl_format diff --git a/drivers/getvec.asm b/drivers/getvec.asm index 3c1c24aa..1dd298e6 100644 --- a/drivers/getvec.asm +++ b/drivers/getvec.asm @@ -30,6 +30,9 @@ ; $Header$ ; ; $Log$ +; Revision 1.4 2001/03/21 02:56:25 bartoldeman +; See history.txt for changes. Bug fixes and HMA support are the main ones. +; ; Revision 1.3 2000/05/25 20:56:19 jimtabor ; Fixed project history ; @@ -66,9 +69,9 @@ ;Initial revision. ; -group TGROUP _TEXT + %include "..\kernel\segs.inc" -segment _TEXT class=CODE +segment HMA_TEXT global _getvec _getvec: diff --git a/drivers/rdpcclk.asm b/drivers/rdpcclk.asm index e7734808..4288a80b 100644 --- a/drivers/rdpcclk.asm +++ b/drivers/rdpcclk.asm @@ -30,6 +30,9 @@ ; $Header$ ; ; $Log$ +; Revision 1.4 2001/03/21 02:56:25 bartoldeman +; See history.txt for changes. Bug fixes and HMA support are the main ones. +; ; Revision 1.3 2000/05/25 20:56:19 jimtabor ; Fixed project history ; @@ -69,9 +72,10 @@ ;Initial revision. ; -group TGROUP _TEXT + %include "..\kernel\segs.inc" + -segment _TEXT class=CODE +segment HMA_TEXT ; ; BOOL ReadPCClock(Ticks) diff --git a/drivers/timer.asm b/drivers/timer.asm index 3ea1b562..5600daa2 100644 --- a/drivers/timer.asm +++ b/drivers/timer.asm @@ -30,6 +30,9 @@ ; $Header$ ; ; $Log$ +; Revision 1.4 2001/03/21 02:56:25 bartoldeman +; See history.txt for changes. Bug fixes and HMA support are the main ones. +; ; Revision 1.3 2000/05/25 20:56:19 jimtabor ; Fixed project history ; @@ -66,10 +69,9 @@ ;Initial revision. ; -group TGROUP _TEXT -group DGROUP _BSS + %include "..\kernel\segs.inc" -segment _TEXT class=CODE +segment HMA_TEXT ; ; void tmark() diff --git a/drivers/wratclk.asm b/drivers/wratclk.asm index c2990c2f..067edc59 100644 --- a/drivers/wratclk.asm +++ b/drivers/wratclk.asm @@ -30,6 +30,9 @@ ; $Header$ ; ; $Log$ +; Revision 1.4 2001/03/21 02:56:25 bartoldeman +; See history.txt for changes. Bug fixes and HMA support are the main ones. +; ; Revision 1.3 2000/05/25 20:56:19 jimtabor ; Fixed project history ; @@ -66,9 +69,9 @@ ;Initial revision. ; -group TGROUP _TEXT + %include "..\kernel\segs.inc" -segment _TEXT class=CODE +segment HMA_TEXT ; ; VOID WriteATClock(bcdDays, bcdHours, bcdMinutes, bcdSeconds) diff --git a/drivers/wrpcclk.asm b/drivers/wrpcclk.asm index ccdf1bce..3e06f734 100644 --- a/drivers/wrpcclk.asm +++ b/drivers/wrpcclk.asm @@ -30,6 +30,9 @@ ; $Header$ ; ; $Log$ +; Revision 1.4 2001/03/21 02:56:25 bartoldeman +; See history.txt for changes. Bug fixes and HMA support are the main ones. +; ; Revision 1.3 2000/05/25 20:56:19 jimtabor ; Fixed project history ; @@ -65,10 +68,10 @@ ; Rev 1.0 02 Jul 1995 8:01:30 patv ;Initial revision. ; + %include "..\kernel\segs.inc" -group TGROUP _TEXT +segment HMA_TEXT -segment _TEXT class=CODE ; ; VOID WritePCClock(Ticks) diff --git a/hdr/portab.h b/hdr/portab.h index deb48a96..0214ea3d 100644 --- a/hdr/portab.h +++ b/hdr/portab.h @@ -36,8 +36,8 @@ static char *portab_hRcsId = "$Id$"; /* * $Log$ - * Revision 1.6 2001/03/19 05:08:53 bartoldeman - * New macros from Tom Ehlert to save even more bytes. + * Revision 1.7 2001/03/21 02:56:25 bartoldeman + * See history.txt for changes. Bug fixes and HMA support are the main ones. * * Revision 1.5 2001/03/08 21:15:00 bartoldeman * Fixes for MK_FP and friends from Tom Ehlert; reduces kernel by 1.5k. diff --git a/hdr/version.h b/hdr/version.h index d032b6a9..bfa903b4 100644 --- a/hdr/version.h +++ b/hdr/version.h @@ -32,9 +32,9 @@ static BYTE *date_hRcsId = "$Id$"; #endif #endif -/* This Kernel is at a min Dos Ver. 4.00 */ +/* This Kernel is at a min Dos Ver. 5.00 */ -#define MAJOR_RELEASE 4 +#define MAJOR_RELEASE 5 #define MINOR_RELEASE 00 #define REV_NUMBER 0 diff --git a/kernel/apisupt.asm b/kernel/apisupt.asm index dfe0fb05..fe39ebc1 100644 --- a/kernel/apisupt.asm +++ b/kernel/apisupt.asm @@ -27,6 +27,9 @@ ; $Id$ ; ; $Log$ +; Revision 1.4 2001/03/21 02:56:25 bartoldeman +; See history.txt for changes. Bug fixes and HMA support are the main ones. +; ; Revision 1.3 2000/05/25 20:56:21 jimtabor ; Fixed project history ; @@ -79,7 +82,7 @@ extern _usr_sp:wrt DGROUP ; user stacks extern _usr_ss:wrt DGROUP -segment _TEXT +segment HMA_TEXT global _set_stack ; ; void far set_stack(void) - diff --git a/kernel/asmsupt.asm b/kernel/asmsupt.asm index 7ceb4f25..baac1821 100644 --- a/kernel/asmsupt.asm +++ b/kernel/asmsupt.asm @@ -24,9 +24,19 @@ ; write to the Free Software Foundation, 675 Mass Ave, ; Cambridge, MA 02139, USA. ; +; version 1.4 by tom.ehlert@ginko.de +; added some more functions +; changed bcopy, scopy, sncopy,... +; to memcpy, strcpy, strncpy +; Bart Oldeman: optimized a bit: see /usr/include/bits/string.h from +; glibc 2.2 +; ; $Id$ ; ; $Log$ +; Revision 1.4 2001/03/21 02:56:25 bartoldeman +; See history.txt for changes. Bug fixes and HMA support are the main ones. +; ; Revision 1.3 2000/05/25 20:56:21 jimtabor ; Fixed project history ; @@ -77,126 +87,443 @@ %include "segs.inc" -segment _TEXT +segment HMA_TEXT + +;********************************************************************* +; this implements some of the common string handling functions ; -; VOID bcopy(s, d, n) -; REG BYTE *s, *d; -; REG COUNT n; +; every function has 2 entries ; +; NEAR FUNC() +; FAR init_call_FUNC() ; - global _bcopy -_bcopy: +; currently done: +; +; memcpy(void *dest, void *src, int count) +; fmemcpy(void FAR *dest, void FAR *src, int count) +; _fmemcpy(void FAR *dest, void FAR *src, int count) +; fmemset(void FAR *dest, int ch, int count); +; fstrncpy(void FAR*dest, void FAR *src, int count); +; strcpy (void *dest, void *src); +; fstrcpy (void FAR*dest, void FAR *src, int count); +; strlen (void *dest); +; fstrlen (void FAR*dest); +; strchr (BYTE *src , BYTE ch); +; fstrcmp (BYTE FAR *s1 , BYTE FAR *s2); +; strcmp (BYTE *s1 , BYTE *s2); +; fstrncmp(BYTE FAR *s1 , BYTE FAR *s2, int count); +; strncmp(BYTE *s1 , BYTE *s2, int count); + +;*********************************************** +; common_setup - set up the standard calling frame for C-functions +; and save registers needed later +; also preload the args for the near functions +; di=arg1 +; si=arg2 +; cx=arg3 +; +common_setup: + pop bx ; get return address + push bp ; Standard C entry mov bp,sp push si push di - push ds push es - - ; Get the repitition count, n - mov cx,[bp+8] - jcxz bcopy_exit - + push ds ; Set both ds and es to same segment (for near copy) - mov ax,ds - mov es,ax + pop es + push ds - ; Get the source pointer, ss - mov si,[bp+4] + ; Set direction to autoincrement + cld - ; and the destination pointer, d + ; to conserve even some more bytes, + ; the registers for the near routines + ; are preloaded here + + ; the destination pointer, d = arg1 mov di,[bp+6] -?doIt: - ; Set direction to autoincrement - cld + ; Get the source pointer, s = arg2 + mov si,[bp+8] + ; Get the repitition count, n = arg3 + mov cx,[bp+10] + + jmp bx + + +;*********************************************** +; +; VOID memcpy(REG BYTE *s, REG BYTE *d, REG COUNT n); +; + global _memcpy + global _init_call_memcpy +_memcpy: + pop ax + push cs + push ax +_init_call_memcpy: + call common_setup + + +domemcpy: ; And do the built-in byte copy, but do a 16-bit transfer ; whenever possible. - mov al, cl - and al,1 ; test for odd count - jz b_even - movsb -b_even: shr cx,1 + shr cx,1 rep movsw + jnc common_return + movsb - ; Finally do a C exit to return -fbcopy_exit: -bcopy_exit: pop es +; +; common_return - pop saved registers and do return +; + +common_return: pop ds + pop es pop di pop si pop bp - ret + retf + +;************************************************************ ; -; VOID fbcopy(s, d, n) +; VOID fmemcpy(REG BYTE FAR *d, REG BYTE FAR *s,REG COUNT n); ; -; REG VOID FAR *s, FAR *d; -; REG COUNT n; - global _fbcopy -_fbcopy: - push bp ; Standard C entry - mov bp,sp - push si - push di - - ; Save ds, since we won't necessarily be within our - ; small/tiny environment - push ds - push es - - ; Get the repititon count, n - mov cx,[bp+12] - jcxz fbcopy_exit + global __fmemcpy + global _fmemcpy + global _init_call_fmemcpy +_fmemcpy: +__fmemcpy: + pop ax + push cs + push ax +_init_call_fmemcpy: + call common_setup ; Get the far source pointer, s - lds si,[bp+4] + lds si,[bp+10] ; Get the far destination pointer d - les di,[bp+8] + les di,[bp+6] - jmp short ?doIt + ; Get the repetition count, n + mov cx,[bp+14] + + jmp short domemcpy + +;*************************************************************** ; -; VOID fmemset(s, ch, n) +; VOID fmemset(REG VOID FAR *d, REG BYTE ch, REG COUNT n); ; -; REG VOID FAR *s -; REG int ch -; REG COUNT n; global _fmemset + global _init_call_fmemset _fmemset: - push bp ; Standard C entry - mov bp,sp - push di + pop ax + push cs + push ax +_init_call_fmemset: - ; Save ds, since we won't necessarily be within our - ; small/tiny environment - push es + call common_setup - ; Get the repititon count, n - mov cx,[bp+10] - jcxz fmemset_exit + ; Get the repetition count, n + mov cx,[bp+12] ; Get the far source pointer, s - les di,[bp+4] - - ; Test if odd or even - mov al, cl - and al, 1 + les di,[bp+6] ; Get the far destination pointer ch - mov al,[bp+8] + mov al,[bp+10] + +domemset: mov ah, al - jz m_even - stosb -m_even: shr cx,1 + shr cx,1 rep stosw + jnc common_return + stosb + + jmp short common_return + +;*************************************************************** +; +; VOID memset(REG VOID *d, REG BYTE ch, REG COUNT n); +; + global _memset + global _init_call_memset +_memset: + pop ax + push cs + push ax +_init_call_memset: + + call common_setup + ; Get the far source pointer, s + ; mov di,[bp+6] + + ; Get the char ch + mov ax,si ; mov al, [bp+8] + + ; Get the repititon count, n + ; mov cx,[bp+10] + + jmp short domemset + + + + +;*************************************************************** + + global _fstrncpy + global _init_call_fstrncpy +_fstrncpy: + pop ax + push cs + push ax +_init_call_fstrncpy: + call common_setup + + ; Get the source pointer, ss + lds si,[bp+10] + + ; and the destination pointer, d + les di,[bp+6] + + mov cx,[bp+14] + + jcxz common_return + ;; dec cx + ; jcxz store_one_byte +strncpy_loop: lodsb + stosb + test al,al + loopnz strncpy_loop + +store_one_byte: xor al,al + ; the spec for strncpy() would require + ; rep stosb + ; to fill remaining part of buffer + stosb + + jmp short common_return + +;***************************************************************** + + + + global _fstrcpy + global _init_call_fstrcpy +_fstrcpy: + pop ax + push cs + push ax +_init_call_fstrcpy: + call common_setup + + ; Get the source pointer, ss + lds si,[bp+10] + + ; and the destination pointer, d + les di,[bp+6] + + jmp short dostrcpy + +;****** + global _strcpy + global _init_call_strcpy +_strcpy: + pop ax + push cs + push ax +_init_call_strcpy: + call common_setup + + + ; Get the source pointer, ss + ;mov si,[bp+8] + + ; and the destination pointer, d + ;mov di,[bp+6] + +dostrcpy: + +strcpy_loop: + lodsb + stosb + test al,al + jne strcpy_loop + + jmp short common_return + +;****************************************************************** + + global _fstrlen + global _init_call_fstrlen +_fstrlen: + pop ax + push cs + push ax +_init_call_fstrlen: + call common_setup + + ; Get the source pointer, ss + les di,[bp+6] + + jmp short dostrlen + +;********************************************** + global _strlen + global _init_call_strlen +_strlen: + pop ax + push cs + push ax +_init_call_strlen: + call common_setup + + ; The source pointer, ss, arg1 was loaded as di + +dostrlen: + mov al,0 + mov cx,0xffff + repne scasb + + mov ax,cx + not ax + dec ax + + jmp common_return + +;************************************************************ + global _strchr + global _init_call_strchr +_strchr: + pop ax + push cs + push ax +_init_call_strchr: + call common_setup + + ; Get the source pointer, ss + ; mov si,[bp+6] + ; mov bx,[bp+8] + mov bx,si + mov si,di + +strchr_loop: + lodsb + cmp al,bl + je strchr_found + test al,al + jne strchr_loop + + mov si,1 ; return NULL if not found +strchr_found: + mov ax,si + dec ax + + jmp common_return + +;********************************************************************** + global _fstrcmp + global _init_call_fstrcmp +_fstrcmp: + pop ax + push cs + push ax +_init_call_fstrcmp: + call common_setup + + ; Get the source pointer, ss + lds si,[bp+6] + + ; and the destination pointer, d + les di,[bp+10] + + jmp dostrcmp + +;****** + global _strcmp + global _init_call_strcmp +_strcmp: + pop ax + push cs + push ax +_init_call_strcmp: + call common_setup + + + ; Get the source pointer, ss + ; mov si,[bp+6] + + ; and the destination pointer, d + ; mov di,[bp+8] + xchg si,di + +dostrcmp: + ; replace strncmp(s1,s2)--> + ; strncmp(s1,s2,0xffff) + mov cx,0xffff + jmp short dostrncmp + + +;********************************************************************** + global _fstrncmp + global _init_call_fstrncmp +_fstrncmp: + pop ax + push cs + push ax +_init_call_fstrncmp: + call common_setup + + ; Get the source pointer, ss + lds si,[bp+6] + + ; and the destination pointer, d + les di,[bp+10] + mov cx,[bp+12] + + jmp short dostrncmp + +;****** + global _strncmp + global _init_call_strncmp +_strncmp: + pop ax + push cs + push ax +_init_call_strncmp: + call common_setup + + ; Get the source pointer, ss + ;mov si,[bp+6] + + ; and the destination pointer, d + ;mov di,[bp+8] + ;mov cx,[bp+10] + xchg si,di + +dostrncmp: + jcxz strncmp_retzero + +strncmp_loop: + lodsb + scasb + jne strncmp_done + test al,al + loopne strncmp_loop +strncmp_retzero: + xor ax, ax + jmp short strncmp_done2 +strncmp_done: + sbb ax,ax + or al,1 +strncmp_done2: jmp common_return -fmemset_exit: pop es - pop di - pop bp - ret diff --git a/kernel/blockio.c b/kernel/blockio.c index 58a4b55e..76ed45ec 100644 --- a/kernel/blockio.c +++ b/kernel/blockio.c @@ -37,6 +37,9 @@ static BYTE *blockioRcsId = "$Id$"; /* * $Log$ + * Revision 1.7 2001/03/21 02:56:25 bartoldeman + * See history.txt for changes. Bug fixes and HMA support are the main ones. + * * Revision 1.6 2000/10/30 00:32:08 jimtabor * Minor Fixes * @@ -152,34 +155,43 @@ static BYTE *blockioRcsId = "$Id$"; /* block cache routines */ /* */ /************************************************************************/ +/* #define DISPLAY_GETBLOCK */ + /* */ /* Initialize the buffer structure */ /* */ /* XXX: This should go into `INIT_TEXT'. -- ror4 */ -VOID FAR init_buffers(void) + +/* this code moved to CONFIG.C +VOID FAR reloc_call_init_buffers(void) { REG WORD i; REG WORD count; + printf("init_buffers %d buffers at %p\n",Config.cfgBuffers, (void FAR*)&buffers[0]); + for (i = 0; i < Config.cfgBuffers; ++i) { - buffers[i].b_unit = 0; - buffers[i].b_flag = 0; - buffers[i].b_blkno = 0; - buffers[i].b_copies = 0; - buffers[i].b_offset_lo = 0; - buffers[i].b_offset_hi = 0; + struct buffer FAR *pbuffer = &buffers[i]; + + pbuffer->b_unit = 0; + pbuffer->b_flag = 0; + pbuffer->b_blkno = 0; + pbuffer->b_copies = 0; + pbuffer->b_offset_lo = 0; + pbuffer->b_offset_hi = 0; if (i < (Config.cfgBuffers - 1)) - buffers[i].b_next = &buffers[i + 1]; + pbuffer->b_next = pbuffer + 1; else - buffers[i].b_next = NULL; + pbuffer->b_next = NULL; } firstbuf = &buffers[0]; lastbuf = &buffers[Config.cfgBuffers - 1]; } - +*/ /* Extract the block number from a buffer structure. */ +#if 0 /*TE*/ ULONG getblkno(struct buffer FAR * bp) { if (bp->b_blkno == 0xffffu) @@ -187,9 +199,13 @@ ULONG getblkno(struct buffer FAR * bp) else return bp->b_blkno; } +#else +#define getblkno(bp) (bp)->b_blkno +#endif /* Set the block number of a buffer structure. (The caller should */ /* set the unit number before calling this function.) */ +#if 0 /*TE*/ VOID setblkno(struct buffer FAR * bp, ULONG blkno) { if (blkno >= 0xffffu) @@ -206,118 +222,130 @@ VOID setblkno(struct buffer FAR * bp, ULONG blkno) } } +#else +#define setblkno(bp, blkno) (bp)->b_blkno = (blkno) +#endif -/* */ -/* Return the address of a buffer structure containing the */ -/* requested block. */ -/* */ -/* returns: */ -/* requested block with data */ -/* failure: */ -/* returns NULL */ -/* */ -struct buffer FAR *getblock(ULONG blkno, COUNT dsk) +/* + this searches the buffer list for the given disk/block. + + if found, the buffer is returned. + + if not found, NULL is returned, and *pReplacebp + contains a buffer to throw out. +*/ + +struct buffer FAR *searchblock(ULONG blkno, COUNT dsk, + struct buffer FAR ** pReplacebp) { - REG struct buffer FAR *bp; - REG struct buffer FAR *lbp; - REG struct buffer FAR *mbp; - REG BYTE fat_count = 0; + int fat_count = 0; + struct buffer FAR *bp; + struct buffer FAR *lbp = NULL; + struct buffer FAR *lastNonFat = NULL; + + +#ifdef DISPLAY_GETBLOCK + printf("[searchblock %d, blk %ld, buf ", dsk, blkno); +#endif + + /* Search through buffers to see if the required block */ /* is already in a buffer */ -#ifdef DISPLAY_GETBLOCK - printf("[getblock %d, blk %ld, buf ", dsk, blkno); -#endif - bp = firstbuf; - lbp = NULL; - mbp = NULL; - while (bp != NULL) + for (bp = firstbuf; bp != NULL;lbp = bp, bp = bp->b_next) { - if ((bp->b_flag & BFR_VALID) && (bp->b_unit == dsk) - && (getblkno(bp) == blkno)) + if ((getblkno(bp) == blkno) && + (bp->b_flag & BFR_VALID) && (bp->b_unit == dsk)) { /* found it -- rearrange LRU links */ if (lbp != NULL) { - lbp->b_next = bp->b_next; - bp->b_next = firstbuf; - firstbuf = bp; + lbp->b_next = bp->b_next; + bp->b_next = firstbuf; + firstbuf = bp; } #ifdef DISPLAY_GETBLOCK - printf("HIT]\n"); + printf("HIT %04x:%04x]\n", FP_SEG(bp), FP_OFF(bp)); #endif + return (bp); } + + if (bp->b_flag & BFR_FAT) + fat_count++; else - { - if (bp->b_flag & BFR_FAT) - fat_count++; - mbp = lbp; /* move along to next buffer */ - lbp = bp; - bp = bp->b_next; - } + lastNonFat = bp; } - /* The block we need is not in a buffer, we must make a buffer */ - /* available, and fill it with the desired block */ - - /* detach lru buffer */ + + /* + now take either the last buffer in chain (not used recently) + or, if we are low on FAT buffers, the last non FAT buffer + */ + + if (lbp ->b_flag & BFR_FAT && fat_count < 3 && lastNonFat) + { + lbp = lastNonFat; + } + *pReplacebp = lbp; + #ifdef DISPLAY_GETBLOCK - printf("MISS]\n"); + printf("MISS, replace %04x:%04x]\n", FP_SEG(lbp), FP_OFF(lbp)); #endif + - /* make sure we keep at least 3 buffers for the FAT. If this is not a */ - /* FAT buffer, or there are at least 3 already, then we can use this */ - /* buffer. */ - /* otherwise, search again, and find the last non-FAT buffer. */ - if ((lbp->b_flag & BFR_FAT) && (fat_count < 3)) - { - bp = firstbuf; - lbp = NULL; - mbp = NULL; - while ((bp != NULL) && (bp->b_flag & BFR_FAT)) + if (lbp != firstbuf) /* move to front */ { - /* if this is a FAT buffer, then move to the next one, else we found */ - /* the one we want. */ - mbp = lbp; /* move along to next buffer */ - lbp = bp; - bp = bp->b_next; + for (bp = firstbuf; bp->b_next != lbp; bp = bp->b_next) + ; + bp->b_next = bp->b_next->b_next; + lbp->b_next = firstbuf; + firstbuf = lbp; } - /* if we get to the end of the list here, then we must only have 3 */ - /* buffers, which is not suppose to happen, but if it does, then we */ - /* end up using the last buffer (even though it is FAT). */ + + return NULL; +} - if (bp == NULL) - { - /* put lbp at the top of the chain. */ - if (mbp != NULL) - mbp->b_next = NULL; - lbp->b_next = firstbuf; - firstbuf = bp = lbp; - } - else if (lbp != NULL) + +/* */ +/* Return the address of a buffer structure containing the */ +/* requested block. */ +/* */ +/* returns: */ +/* requested block with data */ +/* failure: */ +/* returns NULL */ +/* */ +struct buffer FAR *getblock(ULONG blkno, COUNT dsk) +{ + struct buffer FAR *bp; + struct buffer FAR *Replacebp; + + + + /* Search through buffers to see if the required block */ + /* is already in a buffer */ + + bp = searchblock(blkno, dsk, &Replacebp); + + if (bp) { - lbp->b_next = bp->b_next; - bp->b_next = firstbuf; - firstbuf = bp; + return (bp); } - lbp = bp; + + /* The block we need is not in a buffer, we must make a buffer */ + /* available, and fill it with the desired block */ + + + /* take the buffer that lbp points to and flush it, then read new block. */ + if (flush1(Replacebp) && fill(Replacebp, blkno, dsk)) /* success */ + { + return Replacebp; } else { - /* put lbp at the top of the chain. */ - if (mbp != NULL) - mbp->b_next = NULL; - lbp->b_next = firstbuf; - firstbuf = lbp; + return NULL; } - - /* take the buffer than lbp points to and flush it, then read new block. */ - if (flush1(lbp) && fill(lbp, blkno, dsk)) /* success */ - mbp = lbp; - else - mbp = NULL; /* failure */ - return (mbp); } /* @@ -333,107 +361,30 @@ struct buffer FAR *getblock(ULONG blkno, COUNT dsk) */ BOOL getbuf(struct buffer FAR ** pbp, ULONG blkno, COUNT dsk) { - REG struct buffer FAR *bp; - REG struct buffer FAR *lbp; - REG struct buffer FAR *mbp; - REG BYTE fat_count = 0; + struct buffer FAR *bp; + struct buffer FAR *Replacebp; /* Search through buffers to see if the required block */ /* is already in a buffer */ -#ifdef DISPLAY_GETBLOCK - printf("[getbuf %d, blk %ld, buf ", dsk, blkno); -#endif - bp = firstbuf; - lbp = NULL; - mbp = NULL; - while (bp != NULL) - { - if ((bp->b_flag & BFR_VALID) && (bp->b_unit == dsk) - && (getblkno(bp) == blkno)) + bp = searchblock(blkno, dsk, &Replacebp); + + if (bp) { - /* found it -- rearrange LRU links */ - if (lbp != NULL) - { - lbp->b_next = bp->b_next; - bp->b_next = firstbuf; - firstbuf = bp; - } *pbp = bp; -#ifdef DISPLAY_GETBLOCK - printf("HIT]\n"); -#endif return TRUE; - } - else - { - if (bp->b_flag & BFR_FAT) - fat_count++; - mbp = lbp; /* move along to next buffer */ - lbp = bp; - bp = bp->b_next; - } - } + } + /* The block we need is not in a buffer, we must make a buffer */ /* available. */ -#ifdef DISPLAY_GETBLOCK - printf("MISS]\n"); -#endif - - /* make sure we keep at least 3 buffers for the FAT. If this is not a */ - /* FAT buffer, or there are at least 3 already, then we can use this */ - /* buffer. */ - /* otherwise, search again, and find the last non-FAT buffer. */ - if ((lbp->b_flag & BFR_FAT) && (fat_count < 3)) - { - bp = firstbuf; - lbp = NULL; - mbp = NULL; - while ((bp != NULL) && (bp->b_flag & BFR_FAT)) - { - /* if this is a FAT buffer, then move to the next one, else we found */ - /* the one we want. */ - mbp = lbp; /* move along to next buffer */ - lbp = bp; - bp = bp->b_next; - } - /* if we get to the end of the list here, then we must only have 3 */ - /* buffers, which is not suppose to happen, but if it does, then we */ - /* end up using the last buffer (even though it is FAT). */ - - if (bp == NULL) - { - /* put lbp at the top of the chain. */ - if (mbp != NULL) - mbp->b_next = NULL; - lbp->b_next = firstbuf; - firstbuf = bp = lbp; - } - else if (lbp != NULL) - { - lbp->b_next = bp->b_next; - bp->b_next = firstbuf; - firstbuf = bp; - } - lbp = bp; - } - else - { - /* put lbp at the top of the chain. */ - if (mbp != NULL) - mbp->b_next = NULL; - lbp->b_next = firstbuf; - firstbuf = lbp; - } - /* take the buffer than lbp points to and flush it, then make it available. */ - if (flush1(lbp)) /* success */ + if (flush1(Replacebp)) /* success */ { - lbp->b_flag = 0; - lbp->b_unit = dsk; - setblkno(lbp, blkno); - *pbp = lbp; + Replacebp->b_flag = 0; + Replacebp->b_unit = dsk; + setblkno(Replacebp, blkno); + *pbp = Replacebp; return TRUE; } else @@ -443,7 +394,6 @@ BOOL getbuf(struct buffer FAR ** pbp, ULONG blkno, COUNT dsk) return FALSE; } } - /* */ /* Mark all buffers for a disk as not valid */ /* */ diff --git a/kernel/break.c b/kernel/break.c index 00a10d4e..a05f4072 100644 --- a/kernel/break.c +++ b/kernel/break.c @@ -30,7 +30,7 @@ #include "portab.h" #include "globals.h" -extern void spawn_int23(void); +extern void FAR init_call_spawn_int23(void); #ifdef VERSION_STRINGS static BYTE *RcsId = "$Id$"; @@ -38,6 +38,9 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.4 2001/03/21 02:56:25 bartoldeman + * See history.txt for changes. Bug fixes and HMA support are the main ones. + * * Revision 1.3 2000/05/25 20:56:21 jimtabor * Fixed project history * @@ -86,6 +89,26 @@ void handle_break(void) if (!ErrorMode) /* within int21_handler, InDOS is not incremented */ if (InDOS) --InDOS; /* fail-safe */ + + { + /*TE PATCH + CtrlC at DosInput (like C:>DATE does) + Nukes the Kernel. + + it looks like ENTRY.ASM+PROCSUPT.ASM + got out of sync. + + spawn_int() assumes a stack layout at + usr_ss:usr:sp. but usr:ss currently contains 0 + + this patch helps FreeDos to survive CtrlC, + but should clearly be done somehow else. + */ + extern ULONG lpUserStack; + + usr_ss = FP_SEG(lpUserStack); + usr_sp = FP_OFF(lpUserStack); + } - spawn_int23(); /* invoke user INT-23 and never come back */ + init_call_spawn_int23(); /* invoke user INT-23 and never come back */ } diff --git a/kernel/config.c b/kernel/config.c index 38df5dad..ed03bc95 100644 --- a/kernel/config.c +++ b/kernel/config.c @@ -27,6 +27,7 @@ /* Cambridge, MA 02139, USA. */ /****************************************************************/ + #include "init-mod.h" #include "portab.h" @@ -39,8 +40,8 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ - * Revision 1.9 2001/03/19 04:50:56 bartoldeman - * See history.txt for overview: put kernel 2022beo1 into CVS + * Revision 1.10 2001/03/21 02:56:25 bartoldeman + * See history.txt for changes. Bug fixes and HMA support are the main ones. * * Revision 1.9 2001/03/08 21:15:00 bartoldeman * Fixed handling of "DOS=UMB", use toupper instead of tolower consistently. @@ -148,9 +149,11 @@ static BYTE *RcsId = "$Id$"; */ #ifdef __TURBOC__ -void __int__(int); /* TC 2.01 requires this. :( -- ror4 */ + void __int__(int); /* TC 2.01 requires this. :( -- ror4 */ + #define int3() __int__(3); #endif + #ifdef KDB #include @@ -163,7 +166,7 @@ static BYTE FAR *lpOldLast; static BYTE FAR *upOldLast; static COUNT nCfgLine; static COUNT nPass; -static COUNT UmbState; + COUNT UmbState; static BYTE szLine[256]; static BYTE szBuf[256]; @@ -172,7 +175,7 @@ int singleStep = 0; INIT VOID zumcb_init(mcb FAR * mcbp, UWORD size); INIT VOID mumcb_init(mcb FAR * mcbp, UWORD size); -INIT VOID Buffers(BYTE * pLine); +INIT VOID Config_Buffers(BYTE * pLine); INIT VOID sysScreenMode(BYTE * pLine); INIT VOID sysVersion(BYTE * pLine); INIT VOID Break(BYTE * pLine); @@ -181,18 +184,29 @@ INIT VOID DeviceHigh(BYTE * pLine); INIT VOID Files(BYTE * pLine); INIT VOID Fcbs(BYTE * pLine); INIT VOID Lastdrive(BYTE * pLine); -INIT VOID LoadDevice(BYTE * pLine, COUNT top, COUNT mode); +INIT BOOL LoadDevice(BYTE * pLine, COUNT top, COUNT mode); INIT VOID Dosmem(BYTE * pLine); INIT VOID Country(BYTE * pLine); INIT VOID InitPgm(BYTE * pLine); INIT VOID Switchar(BYTE * pLine); INIT VOID CfgFailure(BYTE * pLine); INIT VOID Stacks(BYTE * pLine); +INIT VOID SetAnyDos(BYTE * pLine); INIT BYTE *GetNumArg(BYTE * pLine, COUNT * pnArg); INIT BYTE *GetStringArg(BYTE * pLine, BYTE * pszString); INIT struct dhdr FAR *linkdev(struct dhdr FAR * dhp); INIT UWORD initdev(struct dhdr FAR * dhp, BYTE FAR * cmdTail); INIT int SkipLine(char *pLine); +INIT char *stristr(char *s1, char *s2); + +INIT BYTE FAR *KernelAlloc(WORD nBytes); + +extern void HMAconfig(int finalize); +VOID config_init_buffers(COUNT anzBuffers); /* from BLOCKIO.C */ + +extern fmemcmp(BYTE far *s1, BYTE FAR *s2, unsigned len); + + INIT static VOID FAR *AlignParagraph(VOID FAR * lpPtr); #ifndef I86 @@ -213,12 +227,12 @@ struct table static struct table commands[] = { {"BREAK", 1, Break}, - {"BUFFERS", 1, Buffers}, + {"BUFFERS", 1, Config_Buffers}, {"COMMAND", 1, InitPgm}, {"COUNTRY", 1, Country}, {"DEVICE", 2, Device}, {"DEVICEHIGH", 2, DeviceHigh}, - {"DOS", 2, Dosmem}, + {"DOS", 1, Dosmem}, {"FCBS", 1, Fcbs}, {"FILES", 1, Files}, {"LASTDRIVE", 1, Lastdrive}, @@ -229,6 +243,7 @@ static struct table commands[] = {"SWITCHAR", 1, Switchar}, {"SCREEN", 1, sysScreenMode}, /* JPP */ {"VERSION", 1, sysVersion}, /* JPP */ + {"ANYDOS", 1, SetAnyDos}, /* JPP */ /* default action */ {"", -1, CfgFailure} }; @@ -240,6 +255,21 @@ INIT BYTE FAR *KernelAllocDma(WORD); BYTE *pLineStart; +BYTE HMATextIsAvailable = 0; + +void FAR * ConfigAlloc(COUNT bytes) +{ + VOID FAR *p; + + p = HMAalloc(bytes); + + if (p == NULL) p = KernelAlloc(bytes); + + /* printf("ConfigAllog %d at %p\n", bytes, p);*/ + + return p; +} + /* Do first time initialization. Store last so that we can reset it */ /* later. */ INIT void PreConfig(void) @@ -247,26 +277,34 @@ INIT void PreConfig(void) /* Set pass number */ nPass = 0; VgaSet = 0; - UmbState = 0; - + UmbState = 0; + /* Initialize the base memory pointers */ - lpOldLast = lpBase = AlignParagraph((BYTE FAR *) & last); + + + if ( HMATextIsAvailable ) + lpOldLast = lpBase = AlignParagraph((BYTE FAR *) & _HMATextAvailable); + else + lpOldLast = lpBase = AlignParagraph((BYTE FAR *) & _InitTextStart); #ifdef DEBUG - printf("SDA located at 0x%04x:0x%04x\n", - FP_SEG(internal_data), FP_OFF(internal_data)); + printf("SDA located at 0x%p\n", internal_data); #endif /* Begin by initializing our system buffers */ - dma_scratch = (BYTE FAR *) KernelAllocDma(BUFFERSIZE); + /* the dms_scratch buffer is statically allocated + in the DSK module */ + /* dma_scratch = (BYTE FAR *) KernelAllocDma(BUFFERSIZE); */ #ifdef DEBUG - printf("Preliminary DMA scratchpad allocated at 0x%04x:0x%04x\n", - FP_SEG(dma_scratch), FP_OFF(dma_scratch)); + /* printf("Preliminary DMA scratchpad allocated at 0x%p\n",dma_scratch);*/ #endif - buffers = (struct buffer FAR *) - KernelAlloc(Config.cfgBuffers * sizeof(struct buffer)); + + + + config_init_buffers( Config.cfgBuffers ); +/* buffers = (struct buffer FAR *) + KernelAlloc(Config.cfgBuffers * sizeof(struct buffer)); */ #ifdef DEBUG - printf("Preliminary %d buffers allocated at 0x%04x:0x%04x\n", Config.cfgBuffers, - FP_SEG(buffers), FP_OFF(buffers)); +/* printf("Preliminary %d buffers allocated at 0x%p\n", Config.cfgBuffers, buffers);*/ #endif /* Initialize the file table */ @@ -285,22 +323,16 @@ INIT void PreConfig(void) KernelAlloc(0x58 * (lastdrive)); #ifdef DEBUG - - printf("Preliminary f_node allocated at 0x%04x:0x%04x\n", - FP_SEG(f_nodes), FP_OFF(f_nodes)); - printf("Preliminary FCB table allocated at 0x%04x:0x%04x\n", - FP_SEG(FCBp), FP_OFF(FCBp)); - printf("Preliminary sft table allocated at 0x%04x:0x%04x\n", - FP_SEG(sfthead), FP_OFF(sfthead)); - printf("Preliminary CDS table allocated at 0x%04x:0x%04x\n", - FP_SEG(CDSp), FP_OFF(CDSp)); + printf("Preliminary f_node allocated at at 0x%p\n",f_nodes); + printf("Preliminary FCB table allocated at 0x%p\n",FCBp); + printf("Preliminary sft table allocated at 0x%p\n",sfthead); + printf("Preliminary CDS table allocated at 0x%p\n",CDSp); #endif /* Done. Now initialize the MCB structure */ /* This next line is 8086 and 80x86 real mode specific */ #ifdef DEBUG - printf("Preliminary allocation completed: top at 0x%04x:0x%04x\n", - FP_SEG(lpBase), FP_OFF(lpBase)); + printf("Preliminary allocation completed: top at 0x%p\n",lpBase); #endif #ifdef KDB @@ -327,20 +359,29 @@ INIT void PostConfig(void) if (lastdrive < nblkdev ) lastdrive = nblkdev ; + + /* Initialize the base memory pointers from last time. */ - lpBase = AlignParagraph(lpOldLast); + + if ( HMATextIsAvailable ) + lpOldLast = lpBase = AlignParagraph((BYTE FAR *) & _HMATextStart); + else + lpOldLast = lpBase = AlignParagraph((BYTE FAR *) & _InitTextStart); /* Begin by initializing our system buffers */ - dma_scratch = (BYTE FAR *) KernelAllocDma(BUFFERSIZE); + /* dma_scratch = (BYTE FAR *) KernelAllocDma(BUFFERSIZE); */ #ifdef DEBUG - printf("DMA scratchpad allocated at 0x%04x:0x%04x\n", FP_SEG(dma_scratch), - FP_OFF(dma_scratch)); + /* printf("DMA scratchpad allocated at 0x%p\n", dma_scratch); */ #endif - buffers = (struct buffer FAR *) - KernelAlloc(Config.cfgBuffers * sizeof(struct buffer)); + + + config_init_buffers( Config.cfgBuffers ); + + /* buffers = (struct buffer FAR *) + KernelAlloc(Config.cfgBuffers * sizeof(struct buffer)); */ + #ifdef DEBUG - printf("%d buffers allocated at 0x%04x:0x%04x\n", Config.cfgBuffers, - FP_SEG(buffers), FP_OFF(buffers)); + /* printf("%d buffers allocated at 0x%p\n", Config.cfgBuffers,buffers); */ #endif /* Initialize the file table */ @@ -360,14 +401,10 @@ INIT void PostConfig(void) #ifdef DEBUG - printf("f_node allocated at 0x%04x:0x%04x\n", - FP_SEG(f_nodes), FP_OFF(f_nodes)); - printf("FCB table allocated at 0x%04x:0x%04x\n", - FP_SEG(FCBp), FP_OFF(FCBp)); - printf("sft table allocated at 0x%04x:0x%04x\n", - FP_SEG(sfthead), FP_OFF(sfthead)); - printf("CDS table allocated at 0x%04x:0x%04x\n", - FP_SEG(CDSp), FP_OFF(CDSp)); + printf("f_node allocated at 0x%p\n",f_nodes); + printf("FCB table allocated at 0x%p\n",FCBp); + printf("sft table allocated at 0x%p\n",sfthead); + printf("CDS table allocated at 0x%p\n",CDSp); #endif if (Config.cfgStacks) { @@ -375,13 +412,11 @@ INIT void PostConfig(void) init_stacks(stackBase, Config.cfgStacks, Config.cfgStackSize); #ifdef DEBUG - printf("Stacks allocated at %04x:%04x\n", - FP_SEG(stackBase), FP_OFF(stackBase)); + printf("Stacks allocated at %p\n",stackBase); #endif } #ifdef DEBUG - printf("Allocation completed: top at 0x%04x:0x%04x\n", - FP_SEG(lpBase), FP_OFF(lpBase)); + printf("Allocation completed: top at 0x%p\n",lpBase); #endif @@ -391,6 +426,10 @@ INIT void PostConfig(void) INIT VOID configDone(VOID) { COUNT i; + + HMAconfig(TRUE); /* final HMA processing */ + + if (lastdrive < nblkdev) { #ifdef DEBUG @@ -426,8 +465,7 @@ INIT VOID configDone(VOID) } #ifdef DEBUG - printf("UMB Allocation completed: top at 0x%04x:0x%04x\n", - FP_SEG(upBase), FP_OFF(upBase)); + printf("UMB Allocation completed: top at 0x%p\n",upBase); #endif /* The standard handles should be reopened here, because @@ -509,6 +547,9 @@ INIT VOID DoConfig(VOID) /* Do it here in the loop. */ + + /* shouldn't this go also AFTER the last line has been read? + might be the UMB driver */ if(UmbState == 2){ if(!Umb_Test()){ UmbState = 1; @@ -624,7 +665,7 @@ INIT BYTE *GetStringArg(BYTE * pLine, BYTE * pszString) return scan(pLine, pszString); } -INIT static VOID Buffers(BYTE * pLine) +INIT void Config_Buffers(BYTE * pLine) { COUNT nBuffers; @@ -719,17 +760,49 @@ INIT static VOID Lastdrive(BYTE * pLine) UmbState of confidence, 1 is sure, 2 maybe, 4 unknown and 0 no way. */ +#ifdef __TURBOC__ +void __int__(int); /* TC 2.01 requires this. :( -- ror4 */ +#endif +#define int3() __int__(3); + INIT static VOID Dosmem(BYTE * pLine) { BYTE *pTmp; - - if(UmbState == 0){ - uppermem_link = 0; - uppermem_root = 0; - GetStringArg(pLine, szBuf); + BYTE UMBwanted = FALSE, HMAwanted = FALSE; + + + pLine = GetStringArg(pLine, szBuf); + for (pTmp = szBuf; *pTmp != '\0'; pTmp++) *pTmp = toupper(*pTmp); - UmbState = strcmp(szBuf, "UMB") ? 0 : 2; + + printf("DOS called with %s\n", szBuf); + int3(); + + for (pTmp = szBuf ; ; ) + { + if (fmemcmp(pTmp, "UMB" ,3) == 0) { UMBwanted = TRUE; pTmp += 3; } + if (fmemcmp(pTmp, "HIGH",4) == 0) { HMAwanted = TRUE; pTmp += 4; } + + pTmp = skipwh(pTmp); + + if (*pTmp != ',') + break; + pTmp++; + } + + + if(UmbState == 0){ + uppermem_link = 0; + uppermem_root = 0; + UmbState = UMBwanted ? 2 : 0; + } + + if (HMAwanted) + { + int MoveKernelToHMA(); + + HMATextIsAvailable = MoveKernelToHMA(); } } @@ -771,10 +844,15 @@ INIT static VOID Fcbs(BYTE * pLine) * Returns TRUE if successful, FALSE if not. */ -static INIT BOOL LoadCountryInfo(char *filename, UWORD ctryCode, UWORD codePage) +INIT BOOL LoadCountryInfo(char *filename, UWORD ctryCode, UWORD codePage) { /* printf("cntry: %u, CP%u, file=\"%s\"\n", ctryCode, codePage, filename); */ printf("Sorry, the COUNTRY= statement has been temporarily disabled\n"); + + UNREFERENCED_PARAMETER(codePage); + UNREFERENCED_PARAMETER(ctryCode); + UNREFERENCED_PARAMETER(filename); + return FALSE; } @@ -867,7 +945,11 @@ INIT static VOID DeviceHigh(BYTE * pLine) { if(UmbState == 1) { - LoadDevice(pLine, UMB_top, TRUE); + if (LoadDevice(pLine, UMB_top, TRUE) == DE_NOMEM) + { + printf("Not enough free memory in UMB's: loading low\n"); + LoadDevice(pLine, ram_top, FALSE); + } } else { @@ -876,12 +958,12 @@ INIT static VOID DeviceHigh(BYTE * pLine) } } -INIT static VOID Device(BYTE * pLine) +INIT void Device(BYTE * pLine) { LoadDevice(pLine, ram_top, FALSE); } -INIT static VOID LoadDevice(BYTE * pLine, COUNT top, COUNT mode) +INIT BOOL LoadDevice(BYTE * pLine, COUNT top, COUNT mode) { VOID FAR *driver_ptr; BYTE *pTmp; @@ -889,6 +971,7 @@ INIT static VOID LoadDevice(BYTE * pLine, COUNT top, COUNT mode) struct dhdr FAR *dhp; struct dhdr FAR *next_dhp; UWORD dev_seg; + BOOL result; if(mode) dev_seg = (((ULONG) FP_SEG(upBase) << 4) + FP_OFF(upBase) + 0xf) >> 4; @@ -908,18 +991,74 @@ INIT static VOID LoadDevice(BYTE * pLine, COUNT top, COUNT mode) szBuf, dev_seg); #endif + int3(); + if (DosExec(3, &eb, szBuf) == SUCCESS) { - /* Link in device driver and save nul_dev pointer to next */ - next_dhp = dhp->dh_next = nul_dev.dh_next; - nul_dev.dh_next = dhp; + /* TE this fixes the loading of devices drivers with + multiple devices in it. NUMEGA's SoftIce is such a beast + */ + + for ( ; ; ) + { + struct dhdr FAR *previous_nul_dhp; + + previous_nul_dhp = nul_dev.dh_next; + + next_dhp = dhp->dh_next; + + /* Link in device driver and save nul_dev pointer to next */ + dhp->dh_next = nul_dev.dh_next; + nul_dev.dh_next = dhp; + + /* that's a nice hack >:-) + + although we don't want HIMEM.SYS,(it's not free), other people + might load HIMEM.SYS to see if they are compatible to it. + + if it's HIMEM.SYS, we won't survive TESTMEM:ON + + so simply add TESTMEM:OFF to the commandline + */ + pTmp = pLine; + + int3(); + if (DosLoadedInHMA) + if (stristr(szBuf, "HIMEM.SYS") != NULL) + { + if (stristr(pLine, "/TESTMEM:OFF") == NULL) + { + pTmp = szBuf; + strcpy(pTmp, pLine); + strcat(pTmp, " /TESTMEM:OFF\r\n"); + } + } + /* end of HIMEM.SYS HACK */ + + result=init_device(dhp, pTmp, mode, top); + if(result){ + nul_dev.dh_next = previous_nul_dhp; /* return orig pointer if error */ + } + + /* multiple devices end */ + if (FP_OFF(next_dhp) == 0xffff) /* end of internal chain */ + break; + + FP_OFF(dhp) = FP_OFF(next_dhp); + + if (FP_SEG(next_dhp) != 0xffff) + { + printf("multisegmented device driver found, next %p\n",next_dhp); /* give warning message */ + dhp = next_dhp; + } + } + + HMAconfig(FALSE); /* let the HMA claim HMA usage */ - if(init_device(dhp, pLine, mode, top)){ - nul_dev.dh_next = next_dhp; /* return orig pointer if error */ - } } else CfgFailure(pLine); + return result; } INIT static VOID CfgFailure(BYTE * pLine) @@ -934,7 +1073,7 @@ INIT static VOID CfgFailure(BYTE * pLine) } #ifndef KDB -INIT static BYTE FAR *KernelAlloc(WORD nBytes) +INIT BYTE FAR *KernelAlloc(WORD nBytes) { BYTE FAR *lpAllocated; @@ -956,7 +1095,7 @@ INIT static BYTE FAR *KernelAlloc(WORD nBytes) #endif #ifdef I86 -INIT static BYTE FAR *KernelAllocDma(WORD bytes) +INIT BYTE FAR *KernelAllocDma(WORD bytes) { BYTE FAR *allocated; @@ -968,7 +1107,7 @@ INIT static BYTE FAR *KernelAllocDma(WORD bytes) return allocated; } -INIT static VOID FAR *AlignParagraph(VOID FAR * lpPtr) +INIT void FAR *AlignParagraph(VOID FAR * lpPtr) { ULONG lTemp; UWORD uSegVal; @@ -1122,4 +1261,86 @@ INIT VOID strcpy(d, s); } +/* see if the second string is contained in the first one, ignoring case */ +char *stristr(char *s1, char *s2) +{ + int loop; + + for ( ; *s1 ; s1++) + for ( loop = 0; ; loop++) + { + if (s2[loop] == 0) /* found end of string 2 -> success */ + { + return s1; /* position where s2 was found */ + } + if (toupper(s1[loop]) != toupper(s2[loop]) ) + break; + } + + return NULL; +} + +/* + moved from BLOCKIO.C here. + that saves some relocation problems +*/ + + +VOID config_init_buffers(COUNT anzBuffers) +{ + REG WORD i; + struct buffer FAR *pbuffer; + int HMAcount = 0; + + anzBuffers = max(anzBuffers,6); + anzBuffers = min(anzBuffers,64); + + firstbuf = ConfigAlloc(sizeof (struct buffer)); + + pbuffer = firstbuf; + + for (i = 0; ; ++i) + { + if (FP_SEG(pbuffer) == 0xffff) HMAcount++; + + lastbuf = pbuffer; + + pbuffer->b_unit = 0; + pbuffer->b_flag = 0; + pbuffer->b_blkno = 0; + pbuffer->b_copies = 0; + pbuffer->b_offset_lo = 0; + pbuffer->b_offset_hi = 0; + pbuffer->b_next = NULL; + + /* printf("init_buffers buffer %d at %p\n",i, pbuffer);*/ + + if (i < (anzBuffers - 1)) + pbuffer->b_next = ConfigAlloc(sizeof (struct buffer)); + + if (pbuffer->b_next == NULL) + break; + + pbuffer = pbuffer->b_next; + } + + if (HMAcount > 0) + printf("Kernel: allocated %d Diskbuffers = %u Bytes in HMA\n", + HMAcount, HMAcount*sizeof (struct buffer)); +} + +/* + Undocumented feature: + + ANYDOS + will report to MSDOS programs just the version number + they expect. be careful with it! +*/ + + +INIT VOID SetAnyDos(BYTE * pLine) +{ + UNREFERENCED_PARAMETER(pLine); + ReturnAnyDosVersionExpected = TRUE; +} diff --git a/kernel/console.asm b/kernel/console.asm index 9673def1..ad5b0fa5 100644 --- a/kernel/console.asm +++ b/kernel/console.asm @@ -28,6 +28,9 @@ ; $Header$ ; ; $Log$ +; Revision 1.5 2001/03/21 02:56:25 bartoldeman +; See history.txt for changes. Bug fixes and HMA support are the main ones. +; ; Revision 1.4 2000/05/26 19:25:19 jimtabor ; Read History file for Change info ; @@ -90,7 +93,7 @@ ConTable db 0Ah PRT_SCREEN equ 7200h CTL_P equ 10h -segment _IO_TEXT +segment _TEXT uScanCode db 0 ; Scan code for con: device diff --git a/kernel/dosfns.c b/kernel/dosfns.c index 3a33a14e..f741078d 100644 --- a/kernel/dosfns.c +++ b/kernel/dosfns.c @@ -37,8 +37,8 @@ static BYTE *dosfnsRcsId = "$Id$"; * /// Added SHARE support. 2000/09/04 Ron Cemer * * $Log$ - * Revision 1.10 2001/03/19 04:34:18 bartoldeman - * Update the redirector and Martin Stromberg changes to CVS. + * Revision 1.11 2001/03/21 02:56:25 bartoldeman + * See history.txt for changes. Bug fixes and HMA support are the main ones. * * Revision 1.10 2001/03/08 21:15:00 bartoldeman * Redirector and DosSelectDrv() (Martin Stromberg) fixes @@ -805,6 +805,7 @@ COUNT DosCreat(BYTE FAR * fname, COUNT attrib) if (CDSp->cds_table[drive].cdsFlags & CDSNETWDRV) { lpCurSft = (sfttbl FAR *)sftp; + sftp->sft_mode = attrib; result = int2f_Remote_call(REM_CREATE, 0, 0, 0, (VOID FAR *) sftp, 0, MK_FP(0, attrib)); result = -result; if (result == SUCCESS) { @@ -963,12 +964,13 @@ COUNT DosOpen(BYTE FAR * fname, COUNT mode) sftp->sft_shroff = -1; /* /// Added for SHARE - Ron Cemer */ + sftp->sft_mode = mode; + /* check for a device */ dhp = IsDevice(fname); if ( dhp ) { sftp->sft_count += 1; - sftp->sft_mode = mode; sftp->sft_attrib = 0; sftp->sft_flags = ((dhp->dh_attr & ~SFT_MASK) & ~SFT_FSHARED) | SFT_FDEVICE | SFT_FEOF; @@ -1185,6 +1187,12 @@ COUNT DosChangeDir(BYTE FAR * s) COUNT result; BYTE FAR *p; + /* don't do wildcard CHDIR --TE*/ + /* although this should be handled somewhere else */ + for (p = s; *p; p++) + if (*p == '*' || *p == '?') + return DE_PATHNOTFND; + drive = get_verify_drive(s); if (drive < 0 ) { return drive; diff --git a/kernel/dosidle.asm b/kernel/dosidle.asm index ade3a77a..64c868d6 100644 --- a/kernel/dosidle.asm +++ b/kernel/dosidle.asm @@ -31,7 +31,7 @@ PSP_USERSP equ 2eh PSP_USERSS equ 30h -segment _TEXT +segment HMA_TEXT global _DosIdle_int @@ -52,7 +52,7 @@ segment _TEXT _DosIdle_int: push ds push ax - mov ax,DGROUP + mov ax, DGROUP mov ds,ax pop ax cmp byte [_dosidle_flag],0 diff --git a/kernel/dosnames.c b/kernel/dosnames.c index e82488ce..bb2a9299 100644 --- a/kernel/dosnames.c +++ b/kernel/dosnames.c @@ -36,6 +36,9 @@ static BYTE *dosnamesRcsId = "$Id$"; /* * $Log$ + * Revision 1.7 2001/03/21 02:56:25 bartoldeman + * See history.txt for changes. Bug fixes and HMA support are the main ones. + * * Revision 1.6 2000/06/21 18:16:46 jimtabor * Add UMB code, patch, and code fixes * @@ -226,8 +229,8 @@ COUNT ParseDosName(BYTE FAR * lpszFileName, { if ((lpszFileName - lpszLclFile) == 2) /* for tail DotDot */ nDirCnt += 2; - if (nDirCnt > PARSE_MAX) - nDirCnt = PARSE_MAX; + if (nDirCnt > PARSE_MAX-1) + nDirCnt = PARSE_MAX-1; fbcopy(lpszLclDir, (BYTE FAR *) pszDir, nDirCnt); if (((lpszFileName - lpszLclFile) == 2) && (nDirCnt < PARSE_MAX)) pszDir[nDirCnt++] = '\\'; /* make DosTrimPath() enjoy, for tail DotDot */ @@ -272,8 +275,8 @@ COUNT ParseDosName(BYTE FAR * lpszFileName, return DE_FILENOTFND; /* Fix lengths to maximums allowed by MS-DOS. */ - if (nDirCnt > PARSE_MAX) - nDirCnt = PARSE_MAX; + if (nDirCnt > PARSE_MAX-1) + nDirCnt = PARSE_MAX-1; if (nFileCnt > FNAME_SIZE) nFileCnt = FNAME_SIZE; if (nExtCnt > FEXT_SIZE) @@ -344,9 +347,9 @@ COUNT ParseDosPath(BYTE FAR * lpszFileName, lpszLclDir = lpszFileName; if (!PathSep(*lpszLclDir)) { - fstrncpy(pszDir, pszCurPath, PARSE_MAX); + fstrncpy(pszDir, pszCurPath, PARSE_MAX - 1); /*TE*/ nPathCnt = fstrlen(pszCurPath); - if (!PathSep(pszDir[nPathCnt - 1]) && nPathCnt < PARSE_MAX) + if (!PathSep(pszDir[nPathCnt - 1]) && nPathCnt < PARSE_MAX - 1) /*TE*/ pszDir[nPathCnt++] = '\\'; if (nPathCnt > PARSE_MAX) nPathCnt = PARSE_MAX; @@ -363,8 +366,8 @@ COUNT ParseDosPath(BYTE FAR * lpszFileName, } /* Fix lengths to maximums allowed by MS-DOS. */ - if ((nDirCnt + nPathCnt) > PARSE_MAX) - nDirCnt = PARSE_MAX - nPathCnt; + if ((nDirCnt + nPathCnt) > PARSE_MAX - 1) /*TE*/ + nDirCnt = PARSE_MAX - 1 - nPathCnt; /* Finally copy whatever the user wants extracted to the user's */ /* buffers. */ diff --git a/kernel/dsk.c b/kernel/dsk.c index 7a8dd63f..d146ec3b 100644 --- a/kernel/dsk.c +++ b/kernel/dsk.c @@ -33,9 +33,8 @@ static BYTE *dskRcsId = "$Id$"; /* * $Log$ - * Revision 1.10 2001/03/19 05:01:38 bartoldeman - * Space saving and partition detection fixes from Tom Ehlert and - * Brian Reifsnyder. + * Revision 1.11 2001/03/21 02:56:25 bartoldeman + * See history.txt for changes. Bug fixes and HMA support are the main ones. * * Revision 1.9 2001/03/08 21:15:00 bartoldeman * Space saving fixes from Tom Ehlert @@ -124,7 +123,7 @@ static BYTE *dskRcsId = "$Id$"; * Initial revision. */ -#if 0 +#if defined(DEBUG) #define PartCodePrintf(x) printf x #else #define PartCodePrintf(x) @@ -155,7 +154,7 @@ COUNT fl_verify(); BOOL fl_format(); #endif -#define NDEV 16 /* only one for demo */ +#define NDEV 8 /* only one for demo */ #define SEC_SIZE 512 /* size of sector in bytes */ #define N_RETRY 5 /* number of retries permitted */ #define NENTRY 26 /* total size of dispatch table */ @@ -164,10 +163,17 @@ extern BYTE FAR nblk_rel; union { - BYTE bytes[2 * SEC_SIZE]; + BYTE bytes[1 * SEC_SIZE]; boot boot_sector; -} -buffer; +} buffer; + + /* if the buffer above is good enough for booting + it's also good enough for DMA input */ +BYTE /* scratchpad used for working around */ + FAR * dma_scratch_buffer = (BYTE FAR *)&buffer; /* DMA transfers during disk I/O */ + + + STATIC struct media_info { @@ -229,7 +235,7 @@ STATIC struct dos_partitionS dos_partition[NDEV - 2]; #ifdef PROTO -WORD init(rqptr), +WORD _dsk_init(rqptr), mediachk(rqptr), bldbpb(rqptr), blockio(rqptr), @@ -247,7 +253,7 @@ COUNT ltop(WORD *, WORD *, WORD *, COUNT, COUNT, ULONG, byteptr); WORD dskerr(COUNT); COUNT processtable(int table_type,COUNT ptDrive, BYTE ptHead, UWORD ptCylinder, BYTE ptSector, LONG ptAccuOff); #else -WORD init(), +WORD _dsk_init(), mediachk(), bldbpb(), blockio(), @@ -275,7 +281,7 @@ static WORD(*dispatch[NENTRY]) (rqptr) = static WORD(*dispatch[NENTRY]) () = #endif { - init, /* Initialize */ + _dsk_init, /* Initialize */ mediachk, /* Media Check */ bldbpb, /* Build BPB */ blk_error, /* Ioctl In */ @@ -317,9 +323,9 @@ static WORD(*dispatch[NENTRY]) () = -ULONG StartSector(WORD ptDrive, unsigned BeginHead, +ULONG StartSector(WORD ptDrive, unsigned BeginCylinder, unsigned BeginSector, - unsigned BeginCylinder, + unsigned BeginHead, ULONG peStartSector, ULONG ptAccuOff) { @@ -345,12 +351,8 @@ ULONG StartSector(WORD ptDrive, unsigned BeginHead, startPos = ((ULONG)BeginCylinder * heads + BeginHead) * sectors + BeginSector - 1; PartCodePrintf((" CHS %x %x %x (%d %d %d) --> %lx ( %ld)\n", - BeginHead, - BeginSector, - BeginCylinder, - BeginHead, - BeginSector, - BeginCylinder, + BeginCylinder, BeginHead, BeginSector, + BeginCylinder, BeginHead, BeginSector, startPos, startPos)); return startPos; @@ -385,6 +387,7 @@ COUNT processtable(int table_type,COUNT ptDrive, BYTE ptHead, UWORD ptCylinder, BYTE *p; int partition_chain = 0; int ret; + ULONG newStartPos; restart: /* yes, it's a GOTO >:-) */ @@ -395,8 +398,7 @@ COUNT processtable(int table_type,COUNT ptDrive, BYTE ptHead, UWORD ptCylinder, PartCodePrintf(("searching partition table at %x %x %x %x %lx\n", - ptDrive, ptHead, ptCylinder, - ptSector, ptAccuOff)); + ptDrive, ptCylinder, ptHead, ptSector, ptAccuOff)); /* Read partition table */ for ( retry = N_RETRY; --retry >= 0; ) @@ -437,110 +439,109 @@ COUNT processtable(int table_type,COUNT ptDrive, BYTE ptHead, UWORD ptCylinder, /* Walk through the table, add DOS partitions to global array and process extended partitions */ - for (ptemp_part = &temp_part[0]; - ptemp_part < &temp_part[N_PART] && nUnits < NDEV; ptemp_part++) - { - + /* when searching the EXT chain, must skip primary partitions */ - if ( ( (table_type==PRIMARY) - || ( (table_type==EXTENDED) && (partition_chain!=0) ) ) && - ( ptemp_part->peFileSystem == FAT12 || - ptemp_part->peFileSystem == FAT16SMALL || - ptemp_part->peFileSystem == FAT16LARGE) ) - { - struct dos_partitionS *pdos_partition; - - struct media_info *pmiarray = getPMiarray(nUnits); - - pmiarray->mi_offset = ptemp_part->peStartSector + ptAccuOff; - - PartCodePrintf(("mioffset1 = %lx - ", pmiarray->mi_offset)); - pmiarray->mi_drive = ptDrive; - pmiarray->mi_partidx = nPartitions; - + if ( (table_type==PRIMARY) || + ( (table_type==EXTENDED) && (partition_chain!=0) ) ) + { + + for (ptemp_part = &temp_part[0]; + ptemp_part < &temp_part[N_PART] && nUnits < NDEV; ptemp_part++) { - ULONG newStartPos = StartSector(ptDrive, - ptemp_part->peBeginHead, - ptemp_part->peBeginSector, - ptemp_part->peBeginCylinder, - ptemp_part->peStartSector, - ptAccuOff); - - if (newStartPos != pmiarray->mi_offset) + + if ( ptemp_part->peFileSystem == FAT12 || + ptemp_part->peFileSystem == FAT16SMALL || + ptemp_part->peFileSystem == FAT16LARGE ) { - printf("PART TABLE mismatch for drive %x, CHS=%d %d %d, startsec %d, offset %ld\n", - ptemp_part->peBeginCylinder, - ptemp_part->peBeginHead, - ptemp_part->peBeginSector, - ptemp_part->peStartSector, - ptAccuOff); - printf(" old startpos = %ld, new startpos = %ld, taking new\n", - pmiarray->mi_offset, newStartPos); - - pmiarray->mi_offset = newStartPos; - } + struct dos_partitionS *pdos_partition; + + struct media_info *pmiarray = getPMiarray(nUnits); + + pmiarray->mi_offset = ptemp_part->peStartSector + ptAccuOff; + + PartCodePrintf(("mioffset1 = %lx - ", pmiarray->mi_offset)); + pmiarray->mi_drive = ptDrive; + pmiarray->mi_partidx = nPartitions; + + newStartPos = StartSector(ptDrive, + ptemp_part->peBeginCylinder, + ptemp_part->peBeginHead, + ptemp_part->peBeginSector, + ptemp_part->peStartSector, + ptAccuOff); + + if (newStartPos != pmiarray->mi_offset) + { + printf("PART TABLE mismatch for drive %x, CHS=%d %d %d, startsec %d, offset %ld\n", + ptDrive, + ptemp_part->peBeginCylinder, ptemp_part->peBeginHead,ptemp_part->peBeginSector, + ptemp_part->peStartSector, ptAccuOff); + + printf(" old startpos = %ld, new startpos = %ld, using new\n", + pmiarray->mi_offset, newStartPos); + + pmiarray->mi_offset = newStartPos; + } + + nUnits++; + + pdos_partition = &dos_partition[nPartitions]; + + pdos_partition->peDrive = ptDrive; + pdos_partition->peBootable = ptemp_part->peBootable; + pdos_partition->peBeginHead = ptemp_part->peBeginHead; + pdos_partition->peBeginSector = ptemp_part->peBeginSector; + pdos_partition->peBeginCylinder=ptemp_part->peBeginCylinder; + pdos_partition->peFileSystem =ptemp_part->peFileSystem; + pdos_partition->peEndHead =ptemp_part->peEndHead; + pdos_partition->peEndSector =ptemp_part->peEndSector; + pdos_partition->peEndCylinder =ptemp_part->peEndCylinder; + pdos_partition->peStartSector =ptemp_part->peStartSector; + pdos_partition->peSectors =ptemp_part->peSectors; + pdos_partition->peAbsStart =ptemp_part->peStartSector + ptAccuOff; + + PartCodePrintf(("DOS PARTITION drive %x CHS %x-%x-%x %x-%x-%x %lx %lx %lx FS %x\n", + pdos_partition->peDrive, + pdos_partition->peBeginCylinder,pdos_partition->peBeginHead ,pdos_partition->peBeginSector , + pdos_partition->peEndCylinder ,pdos_partition->peEndHead ,pdos_partition->peEndSector , + pdos_partition->peStartSector , + pdos_partition->peSectors , + pdos_partition->peAbsStart , + pdos_partition->peFileSystem + )); + + nPartitions++; + } } - - nUnits++; - - pdos_partition = &dos_partition[nPartitions]; - - pdos_partition->peDrive = ptDrive; - pdos_partition->peBootable = ptemp_part->peBootable; - pdos_partition->peBeginHead = ptemp_part->peBeginHead; - pdos_partition->peBeginSector = ptemp_part->peBeginSector; - pdos_partition->peBeginCylinder=ptemp_part->peBeginCylinder; - pdos_partition->peFileSystem =ptemp_part->peFileSystem; - pdos_partition->peEndHead =ptemp_part->peEndHead; - pdos_partition->peEndSector =ptemp_part->peEndSector; - pdos_partition->peEndCylinder =ptemp_part->peEndCylinder; - pdos_partition->peStartSector =ptemp_part->peStartSector; - pdos_partition->peSectors =ptemp_part->peSectors; - pdos_partition->peAbsStart =ptemp_part->peStartSector + ptAccuOff; - - PartCodePrintf(("DOS PARTITION drive %x CHS %x-%x-%x %x-%x-%x %lx %lx %lx FS %x\n", - pdos_partition->peDrive, - pdos_partition->peBeginCylinder, - pdos_partition->peBeginHead , - pdos_partition->peBeginSector , - pdos_partition->peEndCylinder , - pdos_partition->peEndHead , - pdos_partition->peEndSector , - pdos_partition->peStartSector , - pdos_partition->peSectors , - pdos_partition->peAbsStart , - pdos_partition->peFileSystem - )); - - - nPartitions++; - } - } - for (ptemp_part = &temp_part[0]; - ptemp_part < &temp_part[N_PART] && nUnits < NDEV; ptemp_part++) + } + + /* search for EXT partitions only on 2. run */ + if (table_type==EXTENDED) { - if ( (table_type==EXTENDED) && - (ptemp_part->peFileSystem == EXTENDED || - ptemp_part->peFileSystem == EXTENDED_INT32 ) ) - { - /* restart with new extended part table, don't recurs */ - partition_chain++; - - ptHead = ptemp_part->peBeginHead; - ptCylinder = ptemp_part->peBeginCylinder; - ptSector = ptemp_part->peBeginSector; - ptAccuOff = ptemp_part->peStartSector + ptAccuOff; - - goto restart; - } - + for (ptemp_part = &temp_part[0]; + ptemp_part < &temp_part[N_PART] && nUnits < NDEV; ptemp_part++) + { + if ( (ptemp_part->peFileSystem == EXTENDED || + ptemp_part->peFileSystem == EXTENDED_INT32 ) ) + { + /* restart with new extended part table, don't recurs */ + partition_chain++; + + ptHead = ptemp_part->peBeginHead; + ptCylinder = ptemp_part->peBeginCylinder; + ptSector = ptemp_part->peBeginSector; + ptAccuOff = ptemp_part->peStartSector + ptAccuOff; + + goto restart; + } + } } return TRUE; } -COUNT blk_driver(rqptr rp) +COUNT FAR init_call_blk_driver(rqptr rp) { if (rp->r_unit >= nUnits && rp->r_command != C_INIT) return failure(E_UNIT); @@ -552,7 +553,7 @@ COUNT blk_driver(rqptr rp) return ((*dispatch[rp->r_command]) (rp)); } -static WORD init(rqptr rp) +WORD _dsk_init(rqptr rp) { extern COUNT fl_nrdrives(VOID); COUNT HardDrive, @@ -607,6 +608,9 @@ static WORD init(rqptr rp) primary partitions are added/removed, but thats the way it is (hope I got it right) TE (with a little help from my friends) */ + + PartCodePrintf(("DSK init: found %d disk drives\n",nHardDisk)); + for (HardDrive = 0; HardDrive < nHardDisk; HardDrive++) { @@ -905,7 +909,6 @@ static WORD Genblkdev(rqptr rp) } case 0x0866: /* get volume serial number */ { - REG COUNT i; struct Gioc_media FAR * gioc = (struct Gioc_media FAR *) rp->r_trans; struct FS_info FAR * fs = &fsarray[rp->r_unit]; @@ -992,19 +995,23 @@ WORD blockio(rqptr rp) } - if (count) + if (count && FP_SEG(trans) != 0xffff) + { ret = action((WORD) miarray[rp->r_unit].mi_drive, head, track, sector, count, trans); + } else { count = 1; - /* buffer crosses DMA boundary, use scratchpad */ + /* buffer crosses DMA boundary, use scratchpad */ + /* use scratchpad also, if going to HIGH memory */ + if (cmd != C_INPUT) - fbcopy(trans, dma_scratch, SEC_SIZE); + fbcopy(trans, dma_scratch_buffer, SEC_SIZE); ret = action((WORD) miarray[rp->r_unit].mi_drive, head, track, sector, - 1, dma_scratch); + 1, dma_scratch_buffer); if (cmd == C_INPUT) - fbcopy(dma_scratch, trans, SEC_SIZE); + fbcopy(dma_scratch_buffer, trans, SEC_SIZE); } if (ret != 0) fl_reset((WORD) miarray[rp->r_unit].mi_drive); diff --git a/kernel/entry.asm b/kernel/entry.asm index b9f2c2fa..78f8ed1a 100644 --- a/kernel/entry.asm +++ b/kernel/entry.asm @@ -28,6 +28,9 @@ ; $Id$ ; ; $Log$ +; Revision 1.4 2001/03/21 02:56:25 bartoldeman +; See history.txt for changes. Bug fixes and HMA support are the main ones. +; ; Revision 1.3 2000/05/25 20:56:21 jimtabor ; Fixed project history ; @@ -72,12 +75,12 @@ %include "segs.inc" %include "stacks.inc" -segment _TEXT - extern _int21_syscall:wrt TGROUP - extern _int25_handler:wrt TGROUP - extern _int26_handler:wrt TGROUP - extern _set_stack:wrt TGROUP - extern _restore_stack:wrt TGROUP +segment HMA_TEXT + extern _int21_syscall:wrt HGROUP + extern _int25_handler:wrt HGROUP + extern _int26_handler:wrt HGROUP + extern _set_stack:wrt HMA_TEXT + extern _restore_stack:wrt HGROUP extern _error_tos:wrt DGROUP extern _char_api_tos:wrt DGROUP extern _disk_api_tos:wrt DGROUP @@ -100,12 +103,12 @@ segment _TEXT extern _Int21AX:wrt DGROUP - global _cpm_entry - global _int20_handler - global _int21_handler - global _low_int25_handler - global _low_int26_handler - global _int27_handler + global reloc_call_cpm_entry + global reloc_call_int20_handler + global reloc_call_int21_handler + global reloc_call_low_int25_handler + global reloc_call_low_int26_handler + global reloc_call_int27_handler ; @@ -118,7 +121,7 @@ segment _TEXT ; function after the call. What we do is convert it to a normal call and ; fudge the stack to look like an int 21h call. ; -_cpm_entry: +reloc_call_cpm_entry: ; Stack is: ; return offset ; psp seg @@ -159,7 +162,7 @@ _cpm_entry: cmp cl,024h jbe cpm_error mov ah,cl ; get the call # from cl to ah - jmp short _int21_handler ; do the system call + jmp short reloc_call_int21_handler ; do the system call cpm_error: mov al,0 iret @@ -189,7 +192,7 @@ _RestartSysCall: ; VOID INRPT far ; int20_handler(iregs UserRegs) ; -_int20_handler: +reloc_call_int20_handler: mov ah,0 ; terminate through int 21h @@ -199,7 +202,7 @@ _int20_handler: ; VOID INRPT far ; int21_handler(iregs UserRegs) ; -_int21_handler: +reloc_call_int21_handler: ; ; Create the stack frame for C call. This is done to ; preserve machine state and provide a C structure for @@ -347,7 +350,7 @@ dos_crit_sect: ; VOID INRPT far ; int27_handler(iregs UserRegs) ; -_int27_handler: +reloc_call_int27_handler: ; ; First convert the memory to paragraphs ; @@ -360,7 +363,7 @@ _int27_handler: ; ... then use the standard system call ; mov ax,3100h - jmp _int21_handler ; terminate through int 21h + jmp reloc_call_int21_handler ; terminate through int 21h ; ; I really do need to get rid of this because it's the only thing stopping @@ -368,7 +371,7 @@ _int27_handler: ; stkframe dd 0 -_low_int25_handler: +reloc_call_low_int25_handler: sti pushf push ax @@ -417,7 +420,7 @@ _low_int25_handler: ; flag image on the stack. -_low_int26_handler: +reloc_call_low_int26_handler: sti pushf push ax @@ -478,12 +481,6 @@ PSP_USERSP equ 2eh PSP_USERSS equ 30h -; -; Default Int 24h handler -- always returns fail -; - global _int24_handler -_int24_handler: mov al,FAIL - iret ; ; COUNT diff --git a/kernel/execrh.asm b/kernel/execrh.asm index a67a5e9d..fa5738b6 100644 --- a/kernel/execrh.asm +++ b/kernel/execrh.asm @@ -30,6 +30,9 @@ ; $Id$ ; ; $Log$ +; Revision 1.4 2001/03/21 02:56:25 bartoldeman +; See history.txt for changes. Bug fixes and HMA support are the main ones. +; ; Revision 1.3 2000/05/25 20:56:21 jimtabor ; Fixed project history ; @@ -78,7 +81,7 @@ %include "segs.inc" -segment _TEXT +segment HMA_TEXT ; _execrh ; Execute Device Request ; diff --git a/kernel/fatdir.c b/kernel/fatdir.c index f4063175..765a6b4f 100644 --- a/kernel/fatdir.c +++ b/kernel/fatdir.c @@ -36,8 +36,8 @@ static BYTE *fatdirRcsId = "$Id$"; /* * $Log$ - * Revision 1.10 2001/03/19 04:50:56 bartoldeman - * See history.txt for overview: put kernel 2022beo1 into CVS + * Revision 1.11 2001/03/21 02:56:25 bartoldeman + * See history.txt for changes. Bug fixes and HMA support are the main ones. * * Revision 1.10 2001/03/08 21:00:00 bartoldeman * Fix handling of very long path names (Tom Ehlert) @@ -271,6 +271,9 @@ struct f_node FAR *dir_open(BYTE FAR * dirname) /* Convert the name into an absolute name for */ /* comparison... */ /* first the file name with trailing spaces... */ + + memset(TempBuffer, ' ', FNAME_SIZE+FEXT_SIZE); + for (i = 0; i < FNAME_SIZE; i++) { if (*p != '\0' && *p != '.' && *p != '/' && *p != '\\') @@ -279,9 +282,6 @@ struct f_node FAR *dir_open(BYTE FAR * dirname) break; } - for (; i < FNAME_SIZE; i++) - TempBuffer[i] = ' '; - /* and the extension (don't forget to */ /* add trailing spaces)... */ if (*p == '.') @@ -293,8 +293,6 @@ struct f_node FAR *dir_open(BYTE FAR * dirname) else break; } - for (; i < FEXT_SIZE; i++) - TempBuffer[i + FNAME_SIZE] = ' '; /* Now search through the directory to */ /* find the entry... */ @@ -586,12 +584,7 @@ COUNT dos_findfirst(UCOUNT attr, BYTE FAR * name) BYTE FAR *ptr; static BYTE local_name[FNAME_SIZE + 1], - local_ext[FEXT_SIZE + 1], - Tname[65]; - - fsncopy(name, (BYTE FAR *)&Tname, sizeof(Tname)); - Tname[sizeof(Tname)-1]=0; - + local_ext[FEXT_SIZE + 1]; /* printf("ff %s", Tname); */ @@ -610,7 +603,7 @@ COUNT dos_findfirst(UCOUNT attr, BYTE FAR * name) dmp->dm_attr_srch = attr | D_RDONLY | D_ARCHIVE; /* Parse out the drive, file name and file extension. */ - i = ParseDosName((BYTE FAR *)&Tname, &nDrive, &LocalPath[2], local_name, local_ext, TRUE); + i = ParseDosName((BYTE FAR *)name, &nDrive, &LocalPath[2], local_name, local_ext, TRUE); if (i != SUCCESS) return i; /* @@ -639,28 +632,16 @@ COUNT dos_findfirst(UCOUNT attr, BYTE FAR * name) /* copy the part of the pattern which belongs to the filename and is fixed */ for (p = local_name, i = 0; i < FNAME_SIZE && *p && *p != '*'; ++p, ++i) SearchDir.dir_name[i] = *p; - if (*p == '*') - { - for (; i < FNAME_SIZE; ++i) - SearchDir.dir_name[i] = '?'; - while (*++p) ; - } - else - for (; i < FNAME_SIZE; i++) - SearchDir.dir_name[i] = ' '; + + for (; i < FNAME_SIZE; ++i) + SearchDir.dir_name[i] = *p == '*' ? '?' : ' '; /* and the extension (don't forget to add trailing spaces)... */ for (p = local_ext, i = 0; i < FEXT_SIZE && *p && *p != '*'; ++p, ++i) SearchDir.dir_ext[i] = *p; - if (*p == '*') - { - for (; i < FEXT_SIZE; ++i) - SearchDir.dir_ext[i] = '?'; - while (*++p) ; - } - else - for (; i < FEXT_SIZE; i++) - SearchDir.dir_ext[i] = ' '; + + for (; i < FEXT_SIZE; ++i) + SearchDir.dir_ext[i] = *p == '*' ? '?' : ' '; /* Convert everything to uppercase. */ DosUpFMem(SearchDir.dir_name, FNAME_SIZE + FEXT_SIZE); @@ -912,9 +893,6 @@ COUNT dos_findnext(void) static VOID pop_dmp(dmatch FAR * dmp, struct f_node FAR * fnp) { - COUNT idx; - BYTE FAR *p; - BYTE FAR *q; dmp->dm_attr_fnd = fnp->f_dir.dir_attrib; dmp->dm_time = fnp->f_dir.dir_time; @@ -925,38 +903,43 @@ static VOID pop_dmp(dmatch FAR * dmp, struct f_node FAR * fnp) dmp->dm_flags.f_ddir = fnp->f_flags.f_ddir; dmp->dm_flags.f_dmod = fnp->f_flags.f_dmod; dmp->dm_flags.f_dnew = fnp->f_flags.f_dnew; - p = dmp->dm_name; - if (fnp->f_dir.dir_name[0] == '.') - { - for (idx = 0, q = (BYTE FAR *) fnp->f_dir.dir_name; - idx < FNAME_SIZE; idx++) + + ConvertName83ToNameSZ((BYTE FAR *)dmp->dm_name, (BYTE FAR *) fnp->f_dir.dir_name); + +} +#endif +/* + this receives a name in 11 char field NAME+EXT and builds + a zeroterminated string +*/ +void ConvertName83ToNameSZ(BYTE FAR *destSZ, BYTE FAR *srcFCBName) +{ + int loop; + int noExtension = FALSE; + + if (*srcFCBName == '.') { - if (*q == ' ') - break; - *p++ = *q++; + noExtension = TRUE; } - } - else - { - for (idx = 0, q = (BYTE FAR *) fnp->f_dir.dir_name; - idx < FNAME_SIZE; idx++) + + + for (loop = FNAME_SIZE; --loop >= 0; srcFCBName++) { - if (*q == ' ') - break; - *p++ = *q++; + if (*srcFCBName != ' ') + *destSZ++ = *srcFCBName; } - if (fnp->f_dir.dir_ext[0] != ' ') + + if (!noExtension) /* not for ".", ".." */ { - *p++ = '.'; - for (idx = 0, q = (BYTE FAR *) fnp->f_dir.dir_ext; idx < FEXT_SIZE; idx++) - { - if (*q == ' ') - break; - *p++ = *q++; - } + if (*srcFCBName != ' ') + { + *destSZ++ = '.'; + for (loop = FEXT_SIZE; --loop >= 0; srcFCBName++) + { + if (*srcFCBName != ' ') + *destSZ++ = *srcFCBName; + } + } } - } - *p++ = NULL; + *destSZ = '\0'; } -#endif - diff --git a/kernel/fatfs.c b/kernel/fatfs.c index 102916a6..6242178b 100644 --- a/kernel/fatfs.c +++ b/kernel/fatfs.c @@ -36,8 +36,8 @@ BYTE *RcsId = "$Id$"; /* * $Log$ - * Revision 1.9 2001/03/19 04:50:56 bartoldeman - * See history.txt for overview: put kernel 2022beo1 into CVS + * Revision 1.10 2001/03/21 02:56:25 bartoldeman + * See history.txt for changes. Bug fixes and HMA support are the main ones. * * Revision 1.9 2001/03/08 21:00:00 bartoldeman * Disabled select_unit() since it's not used @@ -348,7 +348,7 @@ COUNT FAR init_call_dos_close(COUNT fd) /* */ /* split a path into it's component directory and file name */ /* */ -static struct f_node FAR * +struct f_node FAR * split_path(BYTE FAR * path, BYTE * dname, BYTE * fname, BYTE * fext) { REG struct f_node FAR *fnp; @@ -1506,13 +1506,11 @@ UCOUNT readblock(COUNT fd, VOID FAR * buffer, UCOUNT count, COUNT * err) UWORD secsize; UCOUNT to_xfer = count; -#ifdef DEBUG +#if defined( DEBUG ) && 0 if (bDumpRdWrParms) { - printf("readblock:\n"); - printf(" fd buffer count\n -- ------ -----\n"); - printf(" %02d %04x:%04x %d\n", - fd, (COUNT) FP_SEG(buffer), (COUNT) FP_OFF(buffer), count); + printf("readblock:fd %02x buffer %04x:%04x count %x\n", + fd, FP_SEG(buffer), FP_OFF(buffer), count); } #endif /* Translate the fd into an fnode pointer, since all internal */ @@ -1690,9 +1688,7 @@ UCOUNT writeblock(COUNT fd, VOID FAR * buffer, UCOUNT count, COUNT * err) #ifdef DEBUG if (bDumpRdWrParms) { - printf("writeblock:\n"); - printf(" fd buffer count\n -- ------ -----\n"); - printf(" %02d %04x:%04x %d\n", + printf("writeblock: fd %02d buffer %04x:%04x count %d\n", fd, (COUNT) FP_SEG(buffer), (COUNT) FP_OFF(buffer), count); } #endif diff --git a/kernel/fcbfns.c b/kernel/fcbfns.c index 9d474a85..8a236805 100644 --- a/kernel/fcbfns.c +++ b/kernel/fcbfns.c @@ -35,6 +35,9 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.7 2001/03/21 02:56:26 bartoldeman + * See history.txt for changes. Bug fixes and HMA support are the main ones. + * * Revision 1.6 2000/08/06 05:50:17 jimtabor * Add new files and update cvs with patches and changes * @@ -722,29 +725,29 @@ void FcbNameInit(fcb FAR * lpFcb, BYTE * pszBuffer, COUNT * pCurDrive) { BYTE FAR *lpszFcbFname, FAR * lpszFcbFext; - COUNT nDrvIdx, - nFnameIdx, - nFextIdx; + COUNT loop; /* Build a traditional DOS file name */ - lpszFcbFname = (BYTE FAR *) lpFcb->fcb_fname; if (lpFcb->fcb_drive != 0) { *pCurDrive = lpFcb->fcb_drive; pszBuffer[0] = 'A' + lpFcb->fcb_drive - 1; pszBuffer[1] = ':'; - nDrvIdx = 2; + pszBuffer += 2; } else { *pCurDrive = default_drive + 1; - nDrvIdx = 0; } - for (nFnameIdx = 0; nFnameIdx < FNAME_SIZE; nFnameIdx++) + ConvertName83ToNameSZ((BYTE FAR *)pszBuffer, (BYTE FAR *) lpFcb->fcb_fname); + +/* + lpszFcbFname = (BYTE FAR *) lpFcb->fcb_fname; + for (loop = FNAME_SIZE; --loop >= 0; ) { if (*lpszFcbFname != ' ') - pszBuffer[nDrvIdx + nFnameIdx] = *lpszFcbFname++; + *pszBuffer++ = *lpszFcbFname++; else break; } @@ -752,19 +755,17 @@ void FcbNameInit(fcb FAR * lpFcb, BYTE * pszBuffer, COUNT * pCurDrive) lpszFcbFext = (BYTE FAR *) lpFcb->fcb_fext; if (*lpszFcbFext != ' ') { - pszBuffer[nDrvIdx + nFnameIdx++] = '.'; - for (nFextIdx = 0; nFextIdx < FEXT_SIZE; nFextIdx++) + *pszBuffer++ = '.'; + for (loop = FEXT_SIZE; --loop >= 0; ) { if (*lpszFcbFext != ' ') - pszBuffer[nDrvIdx + nFnameIdx + nFextIdx] = - *lpszFcbFext++; + *pszBuffer++ = *lpszFcbFext++; else - break; + break; } } - else - nFextIdx = 0; - pszBuffer[nDrvIdx + nFnameIdx + nFextIdx] = '\0'; + *pszBuffer = '\0'; +*/ } BOOL FcbOpen(xfcb FAR * lpXfcb) diff --git a/kernel/globals.h b/kernel/globals.h index bbd5de3e..0d4ee3db 100644 --- a/kernel/globals.h +++ b/kernel/globals.h @@ -36,6 +36,9 @@ static BYTE *Globals_hRcsId = "$Id$"; /* * $Log$ + * Revision 1.7 2001/03/21 02:56:26 bartoldeman + * See history.txt for changes. Bug fixes and HMA support are the main ones. + * * Revision 1.6 2000/12/16 01:38:35 jimtabor * Added patches from Bart Oldeman * @@ -214,7 +217,7 @@ static BYTE *Globals_hRcsId = "$Id$"; #define PARSE_MAX 67 /* maximum # of bytes in path */ #define NFILES 16 /* number of files in table */ #define NFCBS 16 /* number of fcbs */ -#define NDEVS 8 /* number of supported devices */ +#define NDEVS 26 /* number of supported devices */ #define NSTACKS 8 /* number of stacks */ #define NLAST 6 /* last drive */ #define NAMEMAX PARSE_MAX /* Maximum path for CDS */ @@ -295,16 +298,18 @@ struct buffer FAR *b_next; /* form linked list for LRU */ BYTE b_unit; /* disk for this buffer */ BYTE b_flag; /* buffer flags */ - UWORD b_blkno; /* block for this buffer */ + ULONG b_blkno; /* block for this buffer */ /* DOS-C: 0xffff for huge block numbers */ BYTE b_copies; /* number of copies to write */ UBYTE b_offset_lo; /* span between copies (low) */ - union +#if 0 /*TE*/ + union { struct dpb FAR *_b_dpbp; /* pointer to DPB */ LONG _b_huge_blkno; /* DOS-C: actual block number if >= 0xffff */ } _b; +#endif UBYTE b_offset_hi; /* DOS-C: span between copies (high) */ UBYTE b_unused; BYTE b_buffer[BUFFERSIZE]; /* 512 byte sectors for now */ @@ -351,7 +356,14 @@ extern COUNT * disk_api_tos, /* API handler stack - disk fns */ char_api_tos; /* API handler stack - char fns */ extern BYTE - FAR last; /* first available byte of ram */ + FAR _InitTextStart; /* first available byte of ram */ +extern BYTE + FAR _HMATextAvailable, /* first byte of available CODE area */ + FAR _HMATextStart[], /* first byte of HMAable CODE area */ + FAR _HMATextEnd[]; /* and the last byte of it */ +extern + BYTE DosLoadedInHMA; /* if InitHMA has moved DOS up */ + extern struct ClockRecord ClkRecord; @@ -593,8 +605,8 @@ GLOBAL struct f_node FAR * f_nodes; /* pointer to the array */ GLOBAL struct buffer -FAR *lastbuf, /* tail of ditto */ - FAR * buffers; /* pointer to array of track buffers */ +FAR *lastbuf; /* tail of ditto */ +/* FAR * buffers; /* pointer to array of track buffers */ GLOBAL BYTE /* scratchpad used for working around */ FAR * dma_scratch; /* DMA transfers during disk I/O */ @@ -675,6 +687,7 @@ VOID FAR restore_stack(VOID); WORD execrh(request FAR *, struct dhdr FAR *); #endif VOID FAR init_call_execrh(request FAR *, struct dhdr FAR *); +VOID FAR reloc_call_execrh(request FAR *, struct dhdr FAR *); VOID exit(COUNT); /*VOID INRPT FAR handle_break(VOID); */ VOID tmark(VOID); @@ -746,11 +759,12 @@ VOID fputbyte(); #ifdef I86 #define setvec(n, isr) (void)(*(VOID (INRPT FAR * FAR *)())(4 * (n)) = (isr)) #endif -#define is_leap_year(y) ((y) & 3 ? 0 : (y) % 100 ? 1 : (y) % 400 ? 0 : 1) +/*#define is_leap_year(y) ((y) & 3 ? 0 : (y) % 100 ? 1 : (y) % 400 ? 0 : 1) */ /* ^Break handling */ -void spawn_int23(void); /* procsupt.asm */ +void FAR _init_call_spawn_int23(void); /* procsupt.asm */ int control_break(void); /* break.c */ void handle_break(void); /* break.c */ +GLOBAL BYTE ReturnAnyDosVersionExpected; diff --git a/kernel/init-mod.h b/kernel/init-mod.h index 29f0411a..23565209 100644 --- a/kernel/init-mod.h +++ b/kernel/init-mod.h @@ -10,19 +10,22 @@ * calls for the latter functions therefore need to be wrapped up with far * entry points. */ -#define DosExec init_call_DosExec -#define DosMemAlloc init_call_DosMemAlloc -#define dos_close init_call_dos_close -#define dos_getdate init_call_dos_getdate -#define dos_gettime init_call_dos_gettime -#define dos_open init_call_dos_open -#define dos_read init_call_dos_read -#define execrh init_call_execrh -#define fatal init_call_fatal -#define fbcopy init_call_fbcopy -#define printf init_call_printf -#define scopy init_call_scopy -#define sti init_call_sti -#define strcmp init_call_strcmp -#define strlen init_call_strlen -#define WritePCClock init_call_WritePCClock +#define DosExec reloc_call_DosExec +#define DosMemAlloc reloc_call_DosMemAlloc +#define dos_close reloc_call_dos_close +#define dos_getdate reloc_call_dos_getdate +#define dos_gettime reloc_call_dos_gettime +#define dos_open reloc_call_dos_open +#define dos_read reloc_call_dos_read +#define execrh reloc_call_execrh +#define fatal reloc_call_fatal +#define fmemcpy reloc_call_fmemcpy +#define memcpy reloc_call_memcpy +#define fmemset reloc_call_fmemset +#define printf reloc_call_printf +#define strcpy reloc_call_strcpy +#define sti reloc_call_sti +#define strcmp reloc_call_strcmp +#define strlen reloc_call_strlen +#define WritePCClock reloc_call_WritePCClock +#define DaysFromYearMonthDay reloc_call_DaysFromYearMonthDay diff --git a/kernel/int2f.asm b/kernel/int2f.asm index 64b55e95..57ce2e8d 100644 --- a/kernel/int2f.asm +++ b/kernel/int2f.asm @@ -30,6 +30,9 @@ ; $Id$ ; ; $Log$ +; Revision 1.7 2001/03/21 02:56:26 bartoldeman +; See history.txt for changes. Bug fixes and HMA support are the main ones. +; ; Revision 1.6 2000/08/06 05:50:17 jimtabor ; Add new files and update cvs with patches and changes ; @@ -88,14 +91,14 @@ %include "segs.inc" %include "stacks.inc" -segment _TEXT +segment HMA_TEXT extern _nul_dev:wrt DGROUP extern _umb_start:wrt DGROUP extern _UMB_top:wrt DGROUP - extern _syscall_MUX14:wrt _TEXT + extern _syscall_MUX14:wrt HMA_TEXT - global _int2f_handler -_int2f_handler: + global reloc_call_int2f_handler +reloc_call_int2f_handler: sti ; Enable interrupts cmp ah,11h ; Network interrupt? jne Int2f3 ; No, continue @@ -336,6 +339,8 @@ int2f_call: ; B2h UMB segment number is invalid ; ; + +segment INIT_TEXT global _Umb_Test _Umb_Test push bp @@ -345,8 +350,8 @@ _Umb_Test push dx push bx - mov ax,DGROUP - mov ds,ax + mov ax, DGROUP + mov ds, ax mov ax,4300h ; is there a xms driver installed? int 2fh @@ -404,4 +409,4 @@ umbt_error: dec ax pop ds pop es pop bp - retf ; this was called FAR. + ret ; this was called NEAR!! diff --git a/kernel/inthndlr.c b/kernel/inthndlr.c index 26b34ae2..152803b5 100644 --- a/kernel/inthndlr.c +++ b/kernel/inthndlr.c @@ -36,8 +36,8 @@ BYTE *RcsId = "$Id$"; /* * $Log$ - * Revision 1.13 2001/03/19 04:50:56 bartoldeman - * See history.txt for overview: put kernel 2022beo1 into CVS + * Revision 1.14 2001/03/21 02:56:26 bartoldeman + * See history.txt for changes. Bug fixes and HMA support are the main ones. * * Revision 1.13 2001/03/08 21:00:00 bartoldeman * MCB chain corruption and DosFindNext fix (thanks Martin Stromberg and Tom Ehlert) @@ -309,14 +309,36 @@ VOID int21_syscall(iregs FAR * irp) } } +static int debug_cnt; + VOID int21_service(iregs FAR * r) { COUNT rc = 0, rc1; ULONG lrc; psp FAR *p = MK_FP(cu_psp, 0); + void FAR *FP_DS_DX = MK_FP(r->DS, r->DX); /* this is saved so often, + that this saves ~100 bytes */ + + +#define CLEAR_CARRY_FLAG() r->FLAGS &= ~FLG_CARRY +#define SET_CARRY_FLAG() r->FLAGS |= FLG_CARRY p->ps_stack = (BYTE FAR *) r; + + + switch(r->AH) + { + case 0x2a: /*DosGetDate */ + case 0x2b: /*DosSetDate */ + case 0x2c: /*DosGetTime */ + case 0x2d: /*DosSetDate */ + break; + default: + debug_cnt++; /* debuggable statement */ + } + + #ifdef DEBUG if (bDumpRegs) @@ -422,21 +444,20 @@ VOID int21_service(iregs FAR * r) case 0x09: { static COUNT scratch; - BYTE FAR *p = MK_FP(r->DS, r->DX), - FAR * q; - q = p; + BYTE FAR * q; + q = FP_DS_DX; while (*q != '$') ++q; - DosWrite(STDOUT, q - p, p, (COUNT FAR *) & scratch); + DosWrite(STDOUT, q - (BYTE FAR*)FP_DS_DX, FP_DS_DX, (COUNT FAR *) & scratch); } r->AL = '$'; break; /* Buffered Keyboard Input */ case 0x0a: - ((keyboard FAR *) MK_FP(r->DS, r->DX))->kb_count = 0; - sti((keyboard FAR *) MK_FP(r->DS, r->DX)); - ((keyboard FAR *) MK_FP(r->DS, r->DX))->kb_count -= 2; + ((keyboard FAR *) FP_DS_DX)->kb_count = 0; + sti((keyboard FAR *) FP_DS_DX); + ((keyboard FAR *) FP_DS_DX)->kb_count -= 2; break; /* Check Stdin Status */ @@ -477,35 +498,35 @@ VOID int21_service(iregs FAR * r) break; case 0x0f: - if (FcbOpen(MK_FP(r->DS, r->DX))) + if (FcbOpen(FP_DS_DX)) r->AL = 0; else r->AL = 0xff; break; case 0x10: - if (FcbClose(MK_FP(r->DS, r->DX))) + if (FcbClose(FP_DS_DX)) r->AL = 0; else r->AL = 0xff; break; case 0x11: - if (FcbFindFirst(MK_FP(r->DS, r->DX))) + if (FcbFindFirst(FP_DS_DX)) r->AL = 0; else r->AL = 0xff; break; case 0x12: - if (FcbFindNext(MK_FP(r->DS, r->DX))) + if (FcbFindNext(FP_DS_DX)) r->AL = 0; else r->AL = 0xff; break; case 0x13: - if (FcbDelete(MK_FP(r->DS, r->DX))) + if (FcbDelete(FP_DS_DX)) r->AL = 0; else r->AL = 0xff; @@ -513,7 +534,7 @@ VOID int21_service(iregs FAR * r) case 0x14: { - if (FcbRead(MK_FP(r->DS, r->DX), &CritErrCode)) + if (FcbRead(FP_DS_DX, &CritErrCode)) r->AL = 0; else r->AL = CritErrCode; @@ -522,7 +543,7 @@ VOID int21_service(iregs FAR * r) case 0x15: { - if (FcbWrite(MK_FP(r->DS, r->DX), &CritErrCode)) + if (FcbWrite(FP_DS_DX, &CritErrCode)) r->AL = 0; else r->AL = CritErrCode; @@ -530,14 +551,14 @@ VOID int21_service(iregs FAR * r) } case 0x16: - if (FcbCreate(MK_FP(r->DS, r->DX))) + if (FcbCreate(FP_DS_DX)) r->AL = 0; else r->AL = 0xff; break; case 0x17: - if (FcbRename(MK_FP(r->DS, r->DX))) + if (FcbRename(FP_DS_DX)) r->AL = 0; else r->AL = 0xff; @@ -565,7 +586,7 @@ VOID int21_service(iregs FAR * r) { psp FAR *p = MK_FP(cu_psp, 0); - p->ps_dta = MK_FP(r->DS, r->DX); + p->ps_dta = FP_DS_DX; dos_setdta(p->ps_dta); } break; @@ -625,7 +646,7 @@ VOID int21_service(iregs FAR * r) /* Random read using FCB */ case 0x21: { - if (FcbRandomRead(MK_FP(r->DS, r->DX), &CritErrCode)) + if (FcbRandomRead(FP_DS_DX, &CritErrCode)) r->AL = 0; else r->AL = CritErrCode; @@ -635,7 +656,7 @@ VOID int21_service(iregs FAR * r) /* Random write using FCB */ case 0x22: { - if (FcbRandomWrite(MK_FP(r->DS, r->DX), &CritErrCode)) + if (FcbRandomWrite(FP_DS_DX, &CritErrCode)) r->AL = 0; else r->AL = CritErrCode; @@ -644,7 +665,7 @@ VOID int21_service(iregs FAR * r) /* Get file size in records using FCB */ case 0x23: - if (FcbGetFileSize(MK_FP(r->DS, r->DX))) + if (FcbGetFileSize(FP_DS_DX)) r->AL = 0; else r->AL = 0xff; @@ -652,13 +673,13 @@ VOID int21_service(iregs FAR * r) /* Set random record field in FCB */ case 0x24: - FcbSetRandom(MK_FP(r->DS, r->DX)); + FcbSetRandom(FP_DS_DX); break; /* Set Interrupt Vector */ case 0x25: { - VOID(INRPT FAR * p) () = MK_FP(r->DS, r->DX); + VOID(INRPT FAR * p) () = FP_DS_DX; setvec(r->AL, p); } @@ -676,7 +697,7 @@ VOID int21_service(iregs FAR * r) /* Read random record(s) using FCB */ case 0x27: { - if (FcbRandomBlockRead(MK_FP(r->DS, r->DX), r->CX, &CritErrCode)) + if (FcbRandomBlockRead(FP_DS_DX, r->CX, &CritErrCode)) r->AL = 0; else r->AL = CritErrCode; @@ -686,7 +707,7 @@ VOID int21_service(iregs FAR * r) /* Write random record(s) using FCB */ case 0x28: { - if (FcbRandomBlockWrite(MK_FP(r->DS, r->DX), r->CX, &CritErrCode)) + if (FcbRandomBlockWrite(FP_DS_DX, r->CX, &CritErrCode)) r->AL = 0; else r->AL = CritErrCode; @@ -769,6 +790,34 @@ VOID int21_service(iregs FAR * r) r->CH = REVISION_MAJOR; /* JPP */ r->CL = REVISION_MINOR; r->BL = REVISION_SEQ; + + if (ReturnAnyDosVersionExpected) + { + /* TE for testing purpose only and NOT + to be documented: + return programs, who ask for version == XX.YY + exactly this XX.YY. + this makes most MS programs more happy. + */ + UBYTE FAR *retp = MK_FP(r->cs, r->ip); + + if ( retp[0] == 0x3d && /* cmp ax, xxyy */ + (retp[3] == 0x75 || retp[3] == 0x74)) /* je/jne error */ + { + r->AL = retp[1]; + r->AH = retp[2]; + } + else if(retp[0] == 0x86 && /* xchg al,ah */ + retp[1] == 0xc4 && + retp[2] == 0x3d && /* cmp ax, xxyy */ + (retp[5] == 0x75 || retp[5] == 0x74)) /* je/jne error */ + { + r->AL = retp[4]; + r->AH = retp[3]; + } + + } + break; /* Keep Program (Terminate and stay resident) */ @@ -872,65 +921,65 @@ VOID int21_service(iregs FAR * r) goto error_invalid; } else { /* Get Country Information */ - if((rc = DosGetCountryInformation(cntry, MK_FP(r->DS, r->DX))) < 0) + if((rc = DosGetCountryInformation(cntry, FP_DS_DX)) < 0) goto error_invalid; r->AX = r->BX = cntry; } - r->FLAGS &= ~FLG_CARRY; + CLEAR_CARRY_FLAG(); } break; /* Dos Create Directory */ case 0x39: - rc = DosMkdir((BYTE FAR *) MK_FP(r->DS, r->DX)); + rc = DosMkdir((BYTE FAR *) FP_DS_DX); if (rc != SUCCESS) goto error_exit; else { - r->FLAGS &= ~FLG_CARRY; + CLEAR_CARRY_FLAG(); } break; /* Dos Remove Directory */ case 0x3a: - rc = DosRmdir((BYTE FAR *) MK_FP(r->DS, r->DX)); + rc = DosRmdir((BYTE FAR *) FP_DS_DX); if (rc != SUCCESS) goto error_exit; else { - r->FLAGS &= ~FLG_CARRY; + CLEAR_CARRY_FLAG(); } break; /* Dos Change Directory */ case 0x3b: - if ((rc = DosChangeDir((BYTE FAR *) MK_FP(r->DS, r->DX))) < 0) + if ((rc = DosChangeDir((BYTE FAR *) FP_DS_DX)) < 0) goto error_exit; else { - r->FLAGS &= ~FLG_CARRY; + CLEAR_CARRY_FLAG(); } break; /* Dos Create File */ case 0x3c: - if ((rc = DosCreat(MK_FP(r->DS, r->DX), r->CX)) < 0) + if ((rc = DosCreat(FP_DS_DX, r->CX)) < 0) goto error_exit; else { r->AX = rc; - r->FLAGS &= ~FLG_CARRY; + CLEAR_CARRY_FLAG(); } break; /* Dos Open */ case 0x3d: - if ((rc = DosOpen(MK_FP(r->DS, r->DX), r->AL)) < 0) + if ((rc = DosOpen(FP_DS_DX, r->AL)) < 0) goto error_exit; else { r->AX = rc; - r->FLAGS &= ~FLG_CARRY; + CLEAR_CARRY_FLAG(); } break; @@ -939,12 +988,12 @@ VOID int21_service(iregs FAR * r) if ((rc = DosClose(r->BX)) < 0) goto error_exit; else - r->FLAGS &= ~FLG_CARRY; + CLEAR_CARRY_FLAG(); break; /* Dos Read */ case 0x3f: - rc = DosRead(r->BX, r->CX, MK_FP(r->DS, r->DX), (COUNT FAR *) & rc1); + rc = DosRead(r->BX, r->CX, FP_DS_DX, (COUNT FAR *) & rc1); if (rc1 != SUCCESS) { @@ -953,14 +1002,14 @@ VOID int21_service(iregs FAR * r) } else { - r->FLAGS &= ~FLG_CARRY; + CLEAR_CARRY_FLAG(); r->AX = rc; } break; /* Dos Write */ case 0x40: - rc = DosWrite(r->BX, r->CX, MK_FP(r->DS, r->DX), (COUNT FAR *) & rc1); + rc = DosWrite(r->BX, r->CX, FP_DS_DX, (COUNT FAR *) & rc1); if (rc1 != SUCCESS) { r->AX = -rc1; @@ -968,21 +1017,21 @@ VOID int21_service(iregs FAR * r) } else { - r->FLAGS &= ~FLG_CARRY; + CLEAR_CARRY_FLAG(); r->AX = rc; } break; /* Dos Delete File */ case 0x41: - rc = DosDelete((BYTE FAR *) MK_FP(r->DS, r->DX)); + rc = DosDelete((BYTE FAR *) FP_DS_DX); if (rc < 0) { r->AX = -rc; goto error_out; } else - r->FLAGS &= ~FLG_CARRY; + CLEAR_CARRY_FLAG(); break; /* Dos Seek */ @@ -992,8 +1041,8 @@ VOID int21_service(iregs FAR * r) else { r->DX = (lrc >> 16); - r->AX = lrc & 0xffff; - r->FLAGS &= ~FLG_CARRY; + r->AX = (UWORD)lrc; + CLEAR_CARRY_FLAG(); } break; @@ -1002,21 +1051,21 @@ VOID int21_service(iregs FAR * r) switch (r->AL) { case 0x00: - rc = DosGetFattr((BYTE FAR *) MK_FP(r->DS, r->DX), (UWORD FAR *) & r->CX); + rc = DosGetFattr((BYTE FAR *) FP_DS_DX, (UWORD FAR *) & r->CX); if (rc != SUCCESS) goto error_exit; else { - r->FLAGS &= ~FLG_CARRY; + CLEAR_CARRY_FLAG(); } break; case 0x01: - rc = DosSetFattr((BYTE FAR *) MK_FP(r->DS, r->DX), (UWORD FAR *) & r->CX); + rc = DosSetFattr((BYTE FAR *) FP_DS_DX, (UWORD FAR *) & r->CX); if (rc != SUCCESS) goto error_exit; else - r->FLAGS &= ~FLG_CARRY; + CLEAR_CARRY_FLAG(); break; default: @@ -1035,7 +1084,7 @@ VOID int21_service(iregs FAR * r) goto error_out; } else{ - r->FLAGS &= ~FLG_CARRY; + CLEAR_CARRY_FLAG(); } } break; @@ -1047,7 +1096,7 @@ VOID int21_service(iregs FAR * r) goto error_exit; else { - r->FLAGS &= ~FLG_CARRY; + CLEAR_CARRY_FLAG(); r->AX = rc; } break; @@ -1058,7 +1107,7 @@ VOID int21_service(iregs FAR * r) if (rc < SUCCESS) goto error_exit; else - r->FLAGS &= ~FLG_CARRY; + CLEAR_CARRY_FLAG(); break; /* Get Current Directory */ @@ -1067,7 +1116,7 @@ VOID int21_service(iregs FAR * r) goto error_exit; else { - r->FLAGS &= ~FLG_CARRY; + CLEAR_CARRY_FLAG(); r->AX = 0x0100; /*jpp: from interrupt list */ } break; @@ -1082,7 +1131,7 @@ VOID int21_service(iregs FAR * r) else { ++(r->AX); /* DosMemAlloc() returns seg of MCB rather than data */ - r->FLAGS &= ~FLG_CARRY; + CLEAR_CARRY_FLAG(); } break; @@ -1091,7 +1140,7 @@ VOID int21_service(iregs FAR * r) if ((rc = DosMemFree((r->ES) - 1)) < 0) goto error_exit; else - r->FLAGS &= ~FLG_CARRY; + CLEAR_CARRY_FLAG(); break; /* Set memory block size */ @@ -1117,7 +1166,7 @@ VOID int21_service(iregs FAR * r) goto error_exit; } else - r->FLAGS &= ~FLG_CARRY; + CLEAR_CARRY_FLAG(); break; } @@ -1126,11 +1175,11 @@ VOID int21_service(iregs FAR * r) case 0x4b: break_flg = FALSE; - if ((rc = DosExec(r->AL, MK_FP(r->ES, r->BX), MK_FP(r->DS, r->DX))) + if ((rc = DosExec(r->AL, MK_FP(r->ES, r->BX), FP_DS_DX)) != SUCCESS) goto error_exit; else - r->FLAGS &= ~FLG_CARRY; + CLEAR_CARRY_FLAG(); break; /* Terminate Program */ @@ -1179,12 +1228,12 @@ VOID int21_service(iregs FAR * r) { /* dta for this call is set on entry. This */ /* needs to be changed for new versions. */ - if ((rc = DosFindFirst((UCOUNT) r->CX, (BYTE FAR *) MK_FP(r->DS, r->DX))) < 0) + if ((rc = DosFindFirst((UCOUNT) r->CX, (BYTE FAR *) FP_DS_DX)) < 0) goto error_exit; else { r->AX = 0; - r->FLAGS &= ~FLG_CARRY; + CLEAR_CARRY_FLAG(); } } break; @@ -1204,7 +1253,7 @@ VOID int21_service(iregs FAR * r) } else { - r->FLAGS &= ~FLG_CARRY; + CLEAR_CARRY_FLAG(); r->AX = -SUCCESS; } } @@ -1235,12 +1284,12 @@ VOID int21_service(iregs FAR * r) /* Dos Rename */ case 0x56: - rc = DosRename((BYTE FAR *) MK_FP(r->DS, r->DX), (BYTE FAR *) MK_FP(r->ES, r->DI)); + rc = DosRename((BYTE FAR *) FP_DS_DX, (BYTE FAR *) MK_FP(r->ES, r->DI)); if (rc < SUCCESS) goto error_exit; else { - r->FLAGS &= ~FLG_CARRY; + CLEAR_CARRY_FLAG(); } break; @@ -1256,7 +1305,7 @@ VOID int21_service(iregs FAR * r) if (rc < SUCCESS) goto error_exit; else - r->FLAGS &= ~FLG_CARRY; + CLEAR_CARRY_FLAG(); break; case 0x01: @@ -1267,7 +1316,7 @@ VOID int21_service(iregs FAR * r) if (rc < SUCCESS) goto error_exit; else - r->FLAGS &= ~FLG_CARRY; + CLEAR_CARRY_FLAG(); break; default: @@ -1304,7 +1353,7 @@ VOID int21_service(iregs FAR * r) goto error_invalid; } } - r->FLAGS &= ~FLG_CARRY; + CLEAR_CARRY_FLAG(); break; case 0x02: @@ -1335,23 +1384,23 @@ VOID int21_service(iregs FAR * r) r->CH = CritErrLocus; r->BH = CritErrClass; r->BL = CritErrAction; - r->FLAGS &= ~FLG_CARRY; + CLEAR_CARRY_FLAG(); break; /* Create Temporary File */ case 0x5a: - if ((rc = DosMkTmp(MK_FP(r->DS, r->DX), r->CX)) < 0) + if ((rc = DosMkTmp(FP_DS_DX, r->CX)) < 0) goto error_exit; else { r->AX = rc; - r->FLAGS &= ~FLG_CARRY; + CLEAR_CARRY_FLAG(); } break; /* Create New File */ case 0x5b: - if ((rc = DosOpen(MK_FP(r->DS, r->DX), 0)) >= 0) + if ((rc = DosOpen(FP_DS_DX, 0)) >= 0) { DosClose(rc); r->AX = 80; @@ -1359,12 +1408,12 @@ VOID int21_service(iregs FAR * r) } else { - if ((rc = DosCreat(MK_FP(r->DS, r->DX), r->CX)) < 0) + if ((rc = DosCreat(FP_DS_DX, r->CX)) < 0) goto error_exit; else { r->AX = rc; - r->FLAGS &= ~FLG_CARRY; + CLEAR_CARRY_FLAG(); } } break; @@ -1379,7 +1428,7 @@ VOID int21_service(iregs FAR * r) ((r->AX & 0xff) != 0))) != 0) r->FLAGS |= FLG_CARRY; else - r->FLAGS &= ~FLG_CARRY; + CLEAR_CARRY_FLAG(); r->AX = -rc; break; /* /// End of additions for SHARE. - Ron Cemer */ @@ -1391,7 +1440,7 @@ VOID int21_service(iregs FAR * r) /* Remote Server Call */ case 0x00: { - UWORD FAR *x = MK_FP(r->DS, r->DX); + UWORD FAR *x = FP_DS_DX; r->AX = x[0]; r->BX = x[1]; r->CX = x[2]; @@ -1408,7 +1457,7 @@ VOID int21_service(iregs FAR * r) r->SI = FP_OFF(internal_data); r->CX = swap_always - internal_data; r->DX = swap_indos - internal_data; - r->FLAGS &= ~FLG_CARRY; + CLEAR_CARRY_FLAG(); break; case 0x07: @@ -1421,7 +1470,7 @@ VOID int21_service(iregs FAR * r) if (result != SUCCESS) { goto error_out; } else { - r->FLAGS &= ~FLG_CARRY; + CLEAR_CARRY_FLAG(); } break; } @@ -1434,11 +1483,11 @@ VOID int21_service(iregs FAR * r) switch (r->AL) { case 0x00: - r->CX = get_machine_name(MK_FP(r->DS, r->DX)); + r->CX = get_machine_name(FP_DS_DX); break; case 0x01: - set_machine_name(MK_FP(r->DS, r->DX), r->CX); + set_machine_name(FP_DS_DX, r->CX); break; default: @@ -1449,7 +1498,7 @@ VOID int21_service(iregs FAR * r) if (result != SUCCESS) { goto error_out; } else { - r->FLAGS &= ~FLG_CARRY; + CLEAR_CARRY_FLAG(); } break; } @@ -1479,7 +1528,7 @@ VOID int21_service(iregs FAR * r) if (result != SUCCESS) { goto error_out; } else { - r->FLAGS &= ~FLG_CARRY; + CLEAR_CARRY_FLAG(); } break; } @@ -1492,7 +1541,7 @@ VOID int21_service(iregs FAR * r) goto error_exit; else { - r->FLAGS &= ~FLG_CARRY; + CLEAR_CARRY_FLAG(); } break; @@ -1549,19 +1598,19 @@ VOID int21_service(iregs FAR * r) r->DL = DosUpChar(r->DL); break; case 0x21: /* upcase memory area */ - DosUpMem(MK_FP(r->DS, r->DX), r->CX); + DosUpMem(FP_DS_DX, r->CX); break; case 0x22: /* upcase ASCIZ */ - DosUpString(MK_FP(r->DS, r->DX)); + DosUpString(FP_DS_DX); break; case 0xA0: /* upcase single character of filenames */ r->DL = DosUpFChar(r->DL); break; case 0xA1: /* upcase memory area of filenames */ - DosUpFMem(MK_FP(r->DS, r->DX), r->CX); + DosUpFMem(FP_DS_DX, r->CX); break; case 0xA2: /* upcase ASCIZ of filenames */ - DosUpFString(MK_FP(r->DS, r->DX)); + DosUpFString(FP_DS_DX); break; case 0x23: /* check Yes/No response */ r->AX = DosYesNo(r->DL); @@ -1581,7 +1630,7 @@ VOID int21_service(iregs FAR * r) break; } - r->FLAGS &= ~FLG_CARRY; + CLEAR_CARRY_FLAG(); break; /* Code Page functions */ @@ -1601,7 +1650,7 @@ VOID int21_service(iregs FAR * r) } if(rc != SUCCESS) goto error_exit; - r->FLAGS &= ~FLG_CARRY; + CLEAR_CARRY_FLAG(); break; } @@ -1611,13 +1660,13 @@ VOID int21_service(iregs FAR * r) goto error_exit; else { - r->FLAGS &= ~FLG_CARRY; + CLEAR_CARRY_FLAG(); } break; /* Flush file buffer -- dummy function right now. */ case 0x68: - r->FLAGS &= ~FLG_CARRY; + CLEAR_CARRY_FLAG(); break; /* Get/Set Serial Number */ @@ -1648,7 +1697,7 @@ VOID int21_service(iregs FAR * r) } else { - r->FLAGS &= ~FLG_CARRY; + CLEAR_CARRY_FLAG(); } break; } @@ -1675,7 +1724,7 @@ VOID int21_service(iregs FAR * r) x += 2; r->CX = x; r->AX = rc; - r->FLAGS &= ~FLG_CARRY; + CLEAR_CARRY_FLAG(); } } break; @@ -1694,7 +1743,7 @@ VOID int21_service(iregs FAR * r) { r->CX = 0x02; r->AX = rc; - r->FLAGS &= ~FLG_CARRY; + CLEAR_CARRY_FLAG(); } } break; @@ -1708,7 +1757,7 @@ VOID int21_service(iregs FAR * r) { r->CX = 0x03; r->AX = rc; - r->FLAGS &= ~FLG_CARRY; + CLEAR_CARRY_FLAG(); } break; @@ -1717,7 +1766,7 @@ VOID int21_service(iregs FAR * r) { r->CX = 0x01; r->AX = rc; - r->FLAGS &= ~FLG_CARRY; + CLEAR_CARRY_FLAG(); } else{ if ((rc = DosCreat(MK_FP(r->DS, r->SI), r->CX )) < 0 ) @@ -1726,7 +1775,7 @@ VOID int21_service(iregs FAR * r) { r->CX = 0x02; r->AX = rc; - r->FLAGS &= ~FLG_CARRY; + CLEAR_CARRY_FLAG(); } } break; @@ -1738,7 +1787,7 @@ VOID int21_service(iregs FAR * r) { r->CX = 0x01; r->AX = rc; - r->FLAGS &= ~FLG_CARRY; + CLEAR_CARRY_FLAG(); } break; @@ -1808,109 +1857,92 @@ struct int25regs }; /* this function is called from an assembler wrapper function */ -VOID int25_handler(struct int25regs FAR * r) +/* + I'm probably either + A) totally braindamaged + B) chasing a compiler bug, which I can't find. + + LEAVE THIS CODE EXACTLY AS IS OR FDOS WON'T BOOT +*/ +VOID int2526_handler(WORD mode, struct int25regs FAR * r) { ULONG blkno; UWORD nblks; - BYTE FAR *buf; - UBYTE drv = r->ax & 0xFF; - - InDOS++; - - if (r->cx == 0xFFFF) - { - struct HugeSectorBlock FAR *lb = MK_FP(r->ds, r->bx); - blkno = lb->blkno; - nblks = lb->nblks; - buf = lb->buf; - } - else - { - nblks = r->cx; - blkno = r->dx; - buf = MK_FP(r->ds, r->bx); - } - + BYTE FAR *buf; + UBYTE drv = r->ax; + if (drv >= (lastdrive - 1)) { r->ax = 0x202; r->flags |= FLG_CARRY; return; } - -/* *** Changed 9/4/00 BER */ - r->ax=dskxfer(drv, blkno, buf, nblks, DSKREAD); - if (r->ax > 0) - { - r->flags |= FLG_CARRY; - --InDOS; - return; - } -/* End of change */ - - r->ax = 0; - r->flags &= ~FLG_CARRY; - --InDOS; -} - -VOID int26_handler(struct int25regs FAR * r) -{ - ULONG blkno; - UWORD nblks; - BYTE FAR *buf; - UBYTE drv = r->ax & 0xFF; + + + nblks = r->cx; + blkno = r->dx; + + buf = MK_FP(r->ds, r->bx); + + if (mode == DSKREAD) + { + if (nblks == 0xFFFF) + { + /*struct HugeSectorBlock FAR *lb = MK_FP(r->ds, r->bx);*/ + blkno = ((struct HugeSectorBlock FAR *)buf)->blkno; + nblks = ((struct HugeSectorBlock FAR *)buf)->nblks; + buf = ((struct HugeSectorBlock FAR *)buf)->buf; + } + else + { + buf = MK_FP(r->ds, r->bx); + } + } else { + if (nblks == 0xFFFF) + { + struct HugeSectorBlock FAR *lb = MK_FP(r->ds, r->bx); + blkno = lb->blkno; + nblks = lb->nblks; + buf = lb->buf; + } + else + { + buf = MK_FP(r->ds, r->bx); + } + } + + InDOS++; - if (r->cx == 0xFFFF) - { - struct HugeSectorBlock FAR *lb = MK_FP(r->ds, r->bx); - blkno = lb->blkno; - nblks = lb->nblks; - buf = lb->buf; - } - else - { - nblks = r->cx; - blkno = r->dx; - buf = MK_FP(r->ds, r->bx); - } - - if (drv >= (lastdrive -1)) + if (mode == DSKREAD) { - r->ax = 0x202; - r->flags |= FLG_CARRY; - return; - } + r->ax=dskxfer(drv, blkno, buf, nblks, mode); + } else { + r->ax=dskxfer(drv, blkno, buf, nblks, DSKWRITE); + if (r->ax <= 0) + setinvld(drv); + } -/* *** Changed 9/4/00 BER */ - r->ax=dskxfer(drv, blkno, buf, nblks, DSKWRITE); if (r->ax > 0) { r->flags |= FLG_CARRY; --InDOS; return; } -/* End of change */ - setinvld(drv); r->ax = 0; r->flags &= ~FLG_CARRY; --InDOS; + } +VOID int25_handler(struct int25regs FAR * r) { int2526_handler(DSKREAD,r); } +VOID int26_handler(struct int25regs FAR * r) { int2526_handler(DSKWRITE,r); } + -VOID INRPT FAR int28_handler(void) -{ -} -VOID INRPT FAR int2a_handler(void) -{ -} -VOID INRPT FAR empty_handler(void) -{ -} #ifdef TSC static VOID StartTrace(VOID) diff --git a/kernel/intr.asm b/kernel/intr.asm index 5704729e..3151904a 100644 --- a/kernel/intr.asm +++ b/kernel/intr.asm @@ -28,7 +28,7 @@ %include "segs.inc" -segment _TEXT +segment HMA_TEXT ; ; void intr(nr, rp) ; REG int nr @@ -90,3 +90,91 @@ intr?1: ret + global _int3 +_int3: + int 3 + retf + + + +segment INIT_TEXT +; +; void init_call_intr(nr, rp) +; REG int nr +; REG struct REGPACK *rp +; +; same stuff as above, but in INIT_SEGMENT + global _init_call_intr +_init_call_intr: + push bp ; Standard C entry + mov bp,sp + push si + push di + push ds + push es + + mov ax, [bp+4] ; interrupt number + mov [CS:init_intr?1-1], al + jmp short init_intr?2 ; flush the instruction cache +init_intr?2 mov bx, [bp+6] ; regpack structure + mov ax, [bx] + mov cx, [bx+4] + mov dx, [bx+6] + mov bp, [bx+8] + mov di, [bx+10] + mov si, [bx+12] + push Word [bx+14] ; ds + mov es, [bx+16] + mov bx, [bx+2] + pop ds + + int 0 +init_intr?1: + + pushf + push ds + push bx + mov bx, sp + mov ds, [SS:bx+8] + mov bx, [ss:bx+20] ; address of REGPACK + mov [bx], ax + pop ax + mov [bx+2], ax + mov [bx+4], cx + mov [bx+6], dx + mov [bx+8], bp + mov [bx+10], di + mov [bx+12], si + pop ax + mov [bx+14], ax + mov [bx+16], es + pop ax + mov [bx+18], ax + + pop es + pop ds + pop di + pop si + pop bp + ret + + + +; +; int init_call_XMScall( (WORD FAR * driverAddress)(), WORD AX, WORD DX) +; +; this calls HIMEM.SYS +; + global _init_call_XMScall +_init_call_XMScall: + push bp + mov bp,sp + + mov ax,[bp+8] + mov dx,[bp+10] + call far [bp+4] + + pop bp + ret + + \ No newline at end of file diff --git a/kernel/intr.h b/kernel/intr.h index be03c575..3983ef9d 100644 --- a/kernel/intr.h +++ b/kernel/intr.h @@ -7,3 +7,4 @@ struct REGPACK { }; extern void intr(int intrnr, struct REGPACK *rp); +extern void FAR int3(); diff --git a/kernel/io.asm b/kernel/io.asm index 1adff0f6..abbf43f8 100644 --- a/kernel/io.asm +++ b/kernel/io.asm @@ -28,6 +28,9 @@ ; $Header$ ; ; $Log$ +; Revision 1.7 2001/03/21 02:56:26 bartoldeman +; See history.txt for changes. Bug fixes and HMA support are the main ones. +; ; Revision 1.6 2000/06/21 18:16:46 jimtabor ; Add UMB code, patch, and code fixes ; @@ -72,8 +75,8 @@ extern _NumFloppies:wrt DGROUP extern blk_stk_top:wrt DGROUP extern clk_stk_top:wrt DGROUP - extern _blk_driver:wrt TGROUP - extern _clk_driver:wrt TGROUP + extern _reloc_call_blk_driver + extern _reloc_call_clk_driver ;--------------------------------------------------- ; @@ -224,12 +227,12 @@ blk_dos_seg resw 1 clk_dos_stk resw 1 clk_dos_seg resw 1 -segment _IO_TEXT - +segment _IO_TEXT global _ReqPktPtr _ReqPktPtr dd 0 uUnitNumber dw 0 + ; ; Name: ; GenStrategy @@ -413,8 +416,10 @@ DiskIntrEntry: push ds push bx mov bp,sp - mov ax,DGROUP - mov ds,ax + push ax + mov ax,DGROUP + mov ds,ax + pop ax cld call word [cs:si+1] pop cx @@ -435,10 +440,10 @@ AsmType: mov al,[bx+unit] xchg di,ax les di,[bx+trans] - push ax - mov ax,DGROUP + push ax + mov ax, DGROUP mov ds,ax - pop ax + pop ax cld jmp word [cs:si+1] @@ -542,9 +547,9 @@ blk_entry: push di push ds push es - + ; small model - mov ax,DGROUP ; correct for segments + mov ax,DGROUP ; correct for segments mov ds,ax ; ax to carry segment mov word [blk_dos_stk],sp ; use internal stack mov word [blk_dos_seg],ss @@ -558,7 +563,7 @@ blk_entry: mov bp,sp ; make a c frame push word [cs:_ReqPktPtr+2] push word [cs:_ReqPktPtr] - call _blk_driver + call far _reloc_call_blk_driver pop cx pop cx les bx,[cs:_ReqPktPtr] ; now return completion code @@ -580,6 +585,8 @@ blk_entry: + + ; ; clock device interrupt ; @@ -597,9 +604,9 @@ clk_entry: push di push ds push es - + ; small model - mov ax,DGROUP ; correct for segments + mov ax,DGROUP ; correct for segments mov ds,ax ; ax to carry segment mov word [clk_dos_stk],sp ; use internal stack mov word [clk_dos_seg],ss @@ -613,7 +620,7 @@ clk_entry: mov bp,sp ; make a c frame push word [cs:_ReqPktPtr+2] push word [cs:_ReqPktPtr] - call _clk_driver + call far _reloc_call_clk_driver pop cx pop cx les bx,[cs:_ReqPktPtr] ; now return completion code diff --git a/kernel/io.inc b/kernel/io.inc index 6a7d223b..800ca2a7 100644 --- a/kernel/io.inc +++ b/kernel/io.inc @@ -30,6 +30,9 @@ ; $Header$ ; ; $Log$ +; Revision 1.4 2001/03/21 02:56:26 bartoldeman +; See history.txt for changes. Bug fixes and HMA support are the main ones. +; ; Revision 1.3 2000/05/25 20:56:21 jimtabor ; Fixed project history ; @@ -58,16 +61,7 @@ ; $EndLog$ ; -group TGROUP _TEXT _IO_TEXT _IO_FIXED_DATA -group DGROUP _FIXED_DATA _DATA _BSS _BSSEND - -segment _TEXT class=CODE -segment _IO_TEXT class=CODE -segment _IO_FIXED_DATA class=CODE align=2 -segment _FIXED_DATA class=DATA align=16 -segment _DATA class=DATA align=2 -segment _BSS class=BSS align=2 -segment _BSSEND class=BSS + %include "segs.inc" extern _IOExit:wrt TGROUP extern _IOSuccess:wrt TGROUP diff --git a/kernel/kernel.asm b/kernel/kernel.asm index 3afcbd89..f844f0c0 100644 --- a/kernel/kernel.asm +++ b/kernel/kernel.asm @@ -28,8 +28,8 @@ ; $Id$ ; ; $Log$ -; Revision 1.6 2001/03/19 04:50:56 bartoldeman -; See history.txt for overview: put kernel 2022beo1 into CVS +; Revision 1.7 2001/03/21 02:56:26 bartoldeman +; See history.txt for changes. Bug fixes and HMA support are the main ones. ; ; Revision 1.6 2001/03/08 21:15:00 bartoldeman ; uppermem_root initialised to 0 (no UMBs). @@ -187,7 +187,7 @@ floppy: mov byte [_BootDrive],bl ; tell where we came from shr al,cl inc al mov byte [_NumFloppies],al ; and how many - + mov ax,ds mov es,ax jmp _main @@ -219,15 +219,6 @@ _nul_intr: pop es retf - extern _init_call_printf:wrt TGROUP - - global _printf - -_printf: - pop ax - push cs - push ax - jmp _init_call_printf segment _FIXED_DATA @@ -551,7 +542,9 @@ _FcbSearchBuffer: ; of error stack as scratch buffer _LocalPath: ; times 67 db 0 ; stacks are made to initialize to no-ops so that high-water - ; tesing can be performed + ; testing can be performed + + global apistk_bottom apistk_bottom: times STACK_SIZE dw 0 ;300 - Error Processing Stack global _error_tos @@ -594,6 +587,14 @@ _ram_top dw 0 +; +; mark front and end of bss area to clear +segment _BSSSTART + global __bssstart +__bssstart: +segment _BSSEND + global __bssend +__bssend: segment _BSSEND ; blockdev private stack @@ -607,17 +608,42 @@ blk_stk_top: clk_stk_top: ; interrupt stack + global intr_stk_top times 256 dw 0 intr_stk_top: ; kernel startup stack + global tos times 128 dw 0 tos: - global last -last: ; must always be end of stack area - global _last -_last: ; and c version +segment INIT_TEXT_START + global __InitTextStart +__InitTextStart: ; and c version + + +; +; start end end of HMA area + +segment HMA_TEXT_START + global __HMATextAvailable +__HMATextAvailable + global __HMATextStart +__HMATextStart: + +; +; the HMA area is filled with 16+22(=sizeof VDISK) = 32 byte dummy data, +; so nothing will ever be below 0xffff:25 +; +segment HMA_TEXT + times 16 db 0 ; filler [ffff:0..ffff:10] + times 22 db 0 ; filler [sizeof VDISK info] + +;End of HMA segment +segment HMA_TEXT_END + global __HMATextEnd +__HMATextEnd: ; and c version + ; The default stack (_TEXT:0) will overwrite the data area, so I create a dummy @@ -625,3 +651,367 @@ _last: ; and c version segment _STACK class=STACK stack + + + + +segment _TEXT + ; dummy interrupt return handlers + + global _int28_handler + global _int2a_handler + global _empty_handler +_int28_handler: +_int2a_handler: +_empty_handler: + iret + + +; to minimize relocations + global _DGROUP_ +_DGROUP_: + dw DGROUP + + +segment _TEXT + + global __HMARelocationTableStart +__HMARelocationTableStart: + + + extern _init_call_DosExec + global _reloc_call_DosExec +_reloc_call_DosExec: jmp far _init_call_DosExec + call near forceEnableA20 + + extern _init_call_DosMemAlloc + global _reloc_call_DosMemAlloc +_reloc_call_DosMemAlloc: jmp far _init_call_DosMemAlloc + call near forceEnableA20 + + extern _init_call_dos_close + global _reloc_call_dos_close +_reloc_call_dos_close: jmp far _init_call_dos_close + call near forceEnableA20 + + extern _init_call_dos_getdate + global _reloc_call_dos_getdate +_reloc_call_dos_getdate: jmp far _init_call_dos_getdate + call near forceEnableA20 + + extern _init_call_dos_gettime + global _reloc_call_dos_gettime +_reloc_call_dos_gettime: jmp far _init_call_dos_gettime + call near forceEnableA20 + + extern _init_call_dos_open + global _reloc_call_dos_open +_reloc_call_dos_open: jmp far _init_call_dos_open + call near forceEnableA20 + + extern _init_call_dos_read + global _reloc_call_dos_read +_reloc_call_dos_read: jmp far _init_call_dos_read + call near forceEnableA20 + + extern _init_call_execrh + global _reloc_call_execrh +_reloc_call_execrh: jmp far _init_call_execrh + call near forceEnableA20 + + extern _init_call_fatal + global _reloc_call_fatal +_reloc_call_fatal: jmp far _init_call_fatal + call near forceEnableA20 + + extern _init_call_fmemcpy + global _reloc_call_fmemcpy +_reloc_call_fmemcpy: jmp far _init_call_fmemcpy + call near forceEnableA20 + + + extern _init_call_memcpy + global _reloc_call_memcpy +_reloc_call_memcpy: jmp far _init_call_memcpy + call near forceEnableA20 + + extern _init_call_printf + global _reloc_call_printf +_reloc_call_printf: jmp far _init_call_printf + call near forceEnableA20 + + extern _init_call_strcpy + global _reloc_call_strcpy +_reloc_call_strcpy: jmp far _init_call_strcpy + call near forceEnableA20 + + extern _init_call_sti + global _reloc_call_sti +_reloc_call_sti: jmp far _init_call_sti + call near forceEnableA20 + + extern _init_call_strcmp + global _reloc_call_strcmp +_reloc_call_strcmp: jmp far _init_call_strcmp + call near forceEnableA20 + + extern _init_call_strlen + global _reloc_call_strlen +_reloc_call_strlen: jmp far _init_call_strlen + call near forceEnableA20 + + + extern _init_call_WritePCClock + global _reloc_call_WritePCClock +_reloc_call_WritePCClock: jmp far _init_call_WritePCClock + call near forceEnableA20 + + extern _init_call_DaysFromYearMonthDay + global _reloc_call_DaysFromYearMonthDay +_reloc_call_DaysFromYearMonthDay: jmp far _init_call_DaysFromYearMonthDay + call near forceEnableA20 + + global _CharMapSrvc + extern _reloc_call_CharMapSrvc +_CharMapSrvc: jmp far _reloc_call_CharMapSrvc + call near forceEnableA20 + + global _reloc_call_clk_driver + extern _init_call_clk_driver +_reloc_call_clk_driver: jmp far _init_call_clk_driver + call near forceEnableA20 + + + + global _reloc_call_fmemset + extern _init_call_fmemset +_reloc_call_fmemset: jmp far _init_call_fmemset + call near forceEnableA20 + + + global _reloc_call_blk_driver + extern _init_call_blk_driver +_reloc_call_blk_driver: jmp far _init_call_blk_driver + call near forceEnableA20 + + + global _int2f_handler + extern reloc_call_int2f_handler +_int2f_handler: jmp far reloc_call_int2f_handler + call near forceEnableA20 + + global _int20_handler + extern reloc_call_int20_handler +_int20_handler: jmp far reloc_call_int20_handler + call near forceEnableA20 + + + + + global _int21_handler + extern reloc_call_int21_handler +_int21_handler: jmp far reloc_call_int21_handler + call near forceEnableA20 + + + global _low_int25_handler + extern reloc_call_low_int25_handler +_low_int25_handler: jmp far reloc_call_low_int25_handler + call near forceEnableA20 + + global _low_int26_handler + extern reloc_call_low_int26_handler +_low_int26_handler: jmp far reloc_call_low_int26_handler + call near forceEnableA20 + + global _int27_handler + extern reloc_call_int27_handler +_int27_handler: jmp far reloc_call_int27_handler + call near forceEnableA20 + + + + global _cpm_entry + extern reloc_call_cpm_entry +_cpm_entry: jmp far reloc_call_cpm_entry + call near forceEnableA20 + +; global _init_call_init_buffers +; extern _reloc_call_init_buffers +;_init_call_init_buffers: jmp far _reloc_call_init_buffers +; call near forceEnableA20 + + global _init_call_p_0 + extern _reloc_call_p_0 +_init_call_p_0: jmp far _reloc_call_p_0 + call near forceEnableA20 + + + global __HMARelocationTableEnd +__HMARelocationTableEnd: + +; +; if we were lucky, we found all entries from the outside to the kernel. +; if not, BUMS +; +; +; this routine makes the HMA area available. PERIOD. +; must conserve ALL registers +; will be only ever called, if HMA (DOS=HIGH) is enabled. +; for obvious reasons it should be located at the relocation table +; + global enableA20 ; to see it in the map + +delay: + in al, 64h +delay_check: + and al, 2 + jnz delay + ret + +;void _EnableHMA() +;{ +; OutportWithDelay(0x64, 0xd1); +; OutportWithDelay(0x60, 0xdf); +; OutportWithDelay(0x64, 0xff); +;} + + global _XMSDriverAddress +_XMSDriverAddress: + dw 0 ; XMS driver, if detected + dw 0 + + global __EnableA20 +__EnableA20: + cmp word [cs:_XMSDriverAddress],0 + jne enableUsingXMSdriver + cmp word [cs:_XMSDriverAddress+2],0 + jne enableUsingXMSdriver + + + ; we do it ourself, without an XMS driver + mov al,0d1h + out 64h,al + call delay + mov al,0dfh + out 60h,al + call delay + mov al,0ffh + out 64h,al + call delay + retf + +enableUsingXMSdriver: + mov ah,3 +UsingXMSdriver: + call far [cs:_XMSDriverAddress] + retf + + global __DisableA20 +__DisableA20: + mov ah,4 + cmp word [cs:_XMSDriverAddress],0 + jne UsingXMSdriver + cmp word [cs:_XMSDriverAddress+2],0 + jne UsingXMSdriver + + ; we do it ourself, without an XMS driver + ;OutportWithDelay(0x64, 0xd1); + ;OutportWithDelay(0x60, 0xdd); + ;OutportWithDelay(0x64, 0xff); + mov al,0d1h + out 64h,al + call delay + mov al,0ddh + out 60h,al + call delay + mov al,0ffh + out 64h,al + call delay + + retf + + +dslowmem dw 0 +eshighmem dw 0ffffh + + global forceEnableA20 +forceEnableA20: + + push ds + push es + push ax + +forceEnableA20retry: + mov ds, [cs:dslowmem] + mov es, [cs:eshighmem] + + mov ax, [ds:00000h] + cmp ax, [es:00010h] + jne forceEnableA20success + + mov ax, [ds:00002h] + cmp ax, [es:00012h] + jne forceEnableA20success + + mov ax, [ds:00004h] + cmp ax, [es:00014h] + jne forceEnableA20success + + mov ax, [ds:00006h] + cmp ax, [es:00016h] + jne forceEnableA20success + +; +; ok, we have to enable A20 )at least seems so +; + ; some debug first + ; push bx + ; mov ah, 0eh + ; mov al, 'H' + ; mov bx, 0007h + ; int 10h + ; pop bx + + call far __EnableA20 + + jmp short forceEnableA20retry + + + +forceEnableA20success: + pop ax + pop es + pop ds + ret + + + + + + +segment _TEXT +; +; Default Int 24h handler -- always returns fail +; so we have not to relocate it (now) +; +FAIL equ 03h + + global _int24_handler +_int24_handler: mov al,FAIL + iret + + +segment HMA_TEXT + extern _init_call_printf:wrt TGROUP + global _printf + +_printf: + pop ax + push cs + push ax + jmp _init_call_printf + + + + diff --git a/kernel/kernel.mak b/kernel/kernel.mak index 59dc98dc..5a00a41e 100644 --- a/kernel/kernel.mak +++ b/kernel/kernel.mak @@ -5,8 +5,8 @@ # # $Log$ -# Revision 1.5 2001/03/19 04:50:56 bartoldeman -# See history.txt for overview: put kernel 2022beo1 into CVS +# Revision 1.6 2001/03/21 02:56:26 bartoldeman +# See history.txt for changes. Bug fixes and HMA support are the main ones. # # Revision 1.4 2000/08/06 05:50:17 jimtabor # Add new files and update cvs with patches and changes @@ -127,9 +127,11 @@ NASMFLAGS = -i../hdr/ LIBS =..\LIB\DEVICE.LIB ..\LIB\LIBM.LIB #CFLAGS = -1- -O -Z -d -I..\hdr -I. \ # -D__STDC__=0;DEBUG;KERNEL;I86;PROTO;ASMSUPT -CFLAGS = -1- -O -Z -d -I..\hdr -I. \ - -D__STDC__=0;KERNEL;I86;PROTO;ASMSUPT -INITCFLAGS = $(CFLAGS) -zAINIT -zCINIT_TEXT -zPIGROUP +ALLCFLAGS = -1- -O -Z -d -I..\hdr -I. \ + -D__STDC__=0;KERNEL;I86;PROTO;ASMSUPT \ + -g1 +INITCFLAGS = $(ALLCFLAGS) -zAINIT -zCINIT_TEXT -zPIGROUP +CFLAGS = $(ALLCFLAGS) -zAHMA -zCHMA_TEXT HDR=../hdr/ # *Implicit Rules* @@ -191,7 +193,8 @@ EXE_dependencies = \ sysclk.obj \ syspack.obj \ systime.obj \ - task.obj + task.obj \ + inithma.obj # *Explicit Rules* @@ -215,7 +218,7 @@ kernel.exe: $(EXE_dependencies) $(LIBS) $(RM) kernel.lib $(LIBUTIL) kernel +entry +io +blockio +chario +dosfns +console $(LIBUTIL) kernel +printer +serial +dsk +error +fatdir +fatfs - $(LIBUTIL) kernel +fattab +fcbfns +initoem +inthndlr +ioctl +nls_hc + $(LIBUTIL) kernel +fattab +fcbfns +initoem +initHMA+inthndlr +ioctl +nls_hc $(LIBUTIL) kernel +main +config +memmgr +misc +newstuff +nls +intr $(LIBUTIL) kernel +dosnames +prf +strings +network +sysclk +syspack $(LIBUTIL) kernel +systime +task +int2f +irqstack +apisupt @@ -284,6 +287,14 @@ main.obj: main.c init-mod.h $(HDR)portab.h globals.h $(HDR)device.h \ $(HDR)version.h proto.h $(CC) $(INITCFLAGS) -c main.c +initHMA.obj: initHMA.c init-mod.h $(HDR)portab.h globals.h $(HDR)device.h \ + $(HDR)mcb.h $(HDR)pcb.h $(HDR)date.h $(HDR)time.h $(HDR)fat.h \ + $(HDR)fcb.h $(HDR)tail.h $(HDR)process.h $(HDR)dcb.h $(HDR)sft.h \ + $(HDR)cds.h $(HDR)exe.h $(HDR)fnode.h $(HDR)dirmatch.h \ + $(HDR)file.h $(HDR)clock.h $(HDR)kbd.h $(HDR)error.h \ + $(HDR)version.h proto.h + $(CC) $(INITCFLAGS) -c initHMA.c + # XXX: I generated these using `gcc -MM' and `sed', so they may not be # completely correct... -- ror4 blockio.obj: blockio.c $(HDR)portab.h globals.h $(HDR)device.h \ diff --git a/kernel/main.c b/kernel/main.c index 026012bc..079d8ba6 100644 --- a/kernel/main.c +++ b/kernel/main.c @@ -36,9 +36,14 @@ #ifdef VERSION_STRINGS static BYTE *mainRcsId = "$Id$"; #endif +GLOBAL WORD bDumpRegs = FALSE; +GLOBAL WORD bDumpRdWrParms= FALSE; /* * $Log$ + * Revision 1.8 2001/03/21 02:56:26 bartoldeman + * See history.txt for changes. Bug fixes and HMA support are the main ones. + * * Revision 1.7 2000/08/06 05:50:17 jimtabor * Add new files and update cvs with patches and changes * @@ -158,6 +163,7 @@ extern BYTE FAR * upBase; INIT BOOL ReadATClock(BYTE *, BYTE *, BYTE *, BYTE *); VOID FAR init_call_WritePCClock(ULONG); +VOID FAR reloc_call_WritePCClock(ULONG); INIT VOID configDone(VOID); INIT static void InitIO(void); @@ -169,12 +175,31 @@ INIT static VOID signon(VOID); INIT VOID kernel(VOID); INIT VOID FsConfig(VOID); +#ifdef __TURBOC__ +void __int__(int); /* TC 2.01 requires this. :( -- ror4 */ +#endif + + + INIT VOID main(void) { + setvec(1, empty_handler); /* single step */ + setvec(3, empty_handler); /* debug breakpoint */ + + + #ifdef KDB BootDrive = 1; #endif + + { /* clear the BSS area (what normally the RTL does */ + extern BYTE _bssstart[],_bssend[]; + fmemset(_bssstart,0,_bssend-_bssstart); + } + + init_kernel(); + #ifdef DEBUG /* Non-portable message kludge alert! */ printf("KERNEL: Boot drive = %c\n", 'A' + BootDrive - 1); @@ -183,7 +208,7 @@ INIT VOID main(void) kernel(); } -INIT static VOID init_kernel(void) +INIT void init_kernel(void) { COUNT i; os_major = MAJOR_RELEASE; @@ -193,6 +218,8 @@ INIT static VOID init_kernel(void) maxbksize = 0x200; switchar = '/'; dosidle_flag = 1; + + /* Init oem hook - returns memory size in KB */ ram_top = init_oem(); @@ -371,31 +398,33 @@ INIT VOID FsConfig(VOID) /* Initialzie the current directory structures */ for (i = 0; i < lastdrive ; i++) { + struct cds FAR *pcds_table = &CDSp->cds_table[i]; fbcopy((VOID FAR *) "A:\\\0", - (VOID FAR *) CDSp->cds_table[i].cdsCurrentPath, 4); - CDSp->cds_table[i].cdsCurrentPath[0] += i; + (VOID FAR *) pcds_table->cdsCurrentPath, 4); + + pcds_table->cdsCurrentPath[0] += i; if (i < nblkdev) { - CDSp->cds_table[i].cdsDpb = &blk_devices[i]; - CDSp->cds_table[i].cdsFlags = CDSPHYSDRV; + pcds_table->cdsDpb = &blk_devices[i]; + pcds_table->cdsFlags = CDSPHYSDRV; } else { - CDSp->cds_table[i].cdsFlags = 0; + pcds_table->cdsFlags = 0; } - CDSp->cds_table[i].cdsStrtClst = 0xffff; - CDSp->cds_table[i].cdsParam = 0xffff; - CDSp->cds_table[i].cdsStoreUData = 0xffff; - CDSp->cds_table[i].cdsJoinOffset = 2; + pcds_table->cdsStrtClst = 0xffff; + pcds_table->cdsParam = 0xffff; + pcds_table->cdsStoreUData = 0xffff; + pcds_table->cdsJoinOffset = 2; } /* Initialze the disk buffer management functions */ - init_buffers(); + /* init_call_init_buffers(); done from CONFIG.C */ } -INIT static VOID signon() +INIT VOID signon() { printf("\nFreeDOS Kernel compatibility %d.%d\n%s\n", os_major, os_minor, copyright); @@ -404,7 +433,7 @@ INIT static VOID signon() BUILD); } -INIT static VOID kernel() +INIT void kernel() { seg asize; BYTE FAR *ep, @@ -434,7 +463,8 @@ INIT static VOID kernel() ep += sizeof(int); #endif RootPsp = ~0; - p_0(); + + init_call_p_0(); } /* If cmdLine is NULL, this is an internal driver */ @@ -457,7 +487,9 @@ BOOL init_device(struct dhdr FAR * dhp, BYTE FAR * cmdLine, COUNT mode, COUNT r_ rq.r_bpbptr = (void FAR *)(cmdLine ? cmdLine : "\n"); rq.r_firstunit = nblkdev; + execrh((request FAR *) & rq, dhp); + /* * Added needed Error handle */ @@ -478,17 +510,19 @@ BOOL init_device(struct dhdr FAR * dhp, BYTE FAR * cmdLine, COUNT mode, COUNT r_ for (Index = 0; Index < rq.r_nunits; Index++) { + struct dpb *pblk_devices = &blk_devices[nblkdev]; + if (nblkdev) - blk_devices[nblkdev - 1].dpb_next = &blk_devices[nblkdev]; + (pblk_devices-1)->dpb_next = pblk_devices; - blk_devices[nblkdev].dpb_next = (void FAR *)0xFFFFFFFF; - blk_devices[nblkdev].dpb_unit = nblkdev; - blk_devices[nblkdev].dpb_subunit = Index; - blk_devices[nblkdev].dpb_device = dhp; - blk_devices[nblkdev].dpb_flags = M_CHANGED; + pblk_devices->dpb_next = (void FAR *)0xFFFFFFFF; + pblk_devices->dpb_unit = nblkdev; + pblk_devices->dpb_subunit = Index; + pblk_devices->dpb_device = dhp; + pblk_devices->dpb_flags = M_CHANGED; if ((CDSp != 0) && (nblkdev <= lastdrive)) { - CDSp->cds_table[nblkdev].cdsDpb = &blk_devices[nblkdev]; + CDSp->cds_table[nblkdev].cdsDpb = pblk_devices; CDSp->cds_table[nblkdev].cdsFlags = CDSPHYSDRV; } ++nblkdev; @@ -508,6 +542,7 @@ INIT static void InitIO(void) ULONG ticks; /* Initialize driver chain */ + nul_dev.dh_next = (struct dhdr FAR *)&con_dev; setvec(0x29, int29_handler); /* Requires Fast Con Driver */ init_device((struct dhdr FAR *)&con_dev, NULL, NULL, ram_top); @@ -516,7 +551,11 @@ INIT static void InitIO(void) /* If AT clock exists, copy AT clock time to system clock */ if (!ReadATClock(bcd_days, &bcd_hours, &bcd_minutes, &bcd_seconds)) { - DaysSinceEpoch = BcdToDay(bcd_days); + DaysSinceEpoch = DaysFromYearMonthDay( + 100 * BcdToByte(bcd_days[3]) + BcdToByte(bcd_days[2]), + BcdToByte(bcd_days[1]), + BcdToByte(bcd_days[0]) ); + /* * This is a rather tricky calculation. The number of timer ticks per * second is not exactly 18.2, but rather 0x1800b0 / 86400 = 19663 / 1080 @@ -537,23 +576,3 @@ INIT static COUNT BcdToByte(COUNT x) return ((((x) >> 4) & 0xf) * 10 + ((x) & 0xf)); } -INIT static COUNT BcdToDay(BYTE * x) -{ - UWORD mon, - day, - yr; - - mon = BcdToByte(x[1]) - 1; - day = BcdToByte(x[0]) - 1; - yr = 100 * BcdToByte(x[3]) + BcdToByte(x[2]); - if (yr < 1980) - return 0; - else - { - day += days[is_leap_year(yr)][mon]; - while (--yr >= 1980) - day += is_leap_year(yr) ? 366 : 365; - return day; - } -} - diff --git a/kernel/memmgr.c b/kernel/memmgr.c index 710e7066..3b801ff3 100644 --- a/kernel/memmgr.c +++ b/kernel/memmgr.c @@ -35,8 +35,8 @@ static BYTE *memmgrRcsId = "$Id$"; /* * $Log$ - * Revision 1.8 2001/03/19 04:50:56 bartoldeman - * See history.txt for overview: put kernel 2022beo1 into CVS + * Revision 1.9 2001/03/21 02:56:26 bartoldeman + * See history.txt for changes. Bug fixes and HMA support are the main ones. * * Revision 1.8 2001/03/08 21:00:00 bartoldeman * UMB and MCB chain corruption (thanks Martin Stromberg) fixes @@ -114,8 +114,14 @@ VOID mcb_init(); VOID mcb_print(); VOID show_chain(); -#define nxtMCBsize(mcb,size) \ - MK_FP(far2para((VOID FAR *) (mcb)) + (size) + 1, 0) +/*#define nxtMCBsize(mcb,size) \ + MK_FP(far2para((VOID FAR *) (mcb)) + (size) + 1, 0) */ + +void FAR *nxtMCBsize(mcb FAR *Mcb, int size) +{ + return MK_FP(far2para((VOID FAR *) (Mcb)) + (size) + 1, 0); +} + #define nxtMCB(mcb) nxtMCBsize((mcb), (mcb)->m_size) #define mcbFree(mcb) ((mcb)->m_psp == FREE_PSP) @@ -164,6 +170,8 @@ seg long2para(LONG size) */ VOID FAR *add_far(VOID FAR * fp, ULONG off) { + if (FP_SEG(fp) == 0xffff) return ((BYTE FAR *)fp) + off; + off += FP_OFF(fp); return MK_FP(FP_SEG(fp) + (UWORD) (off >> 4), (UWORD) off & 0xf); @@ -176,6 +184,9 @@ VOID FAR *adjust_far(VOID FAR * fp) { /* and return an adddress adjusted to the nearest paragraph */ /* boundary. */ + + if (FP_SEG(fp) == 0xffff) return fp; + return MK_FP(FP_SEG(fp) + (FP_OFF(fp) >> 4), FP_OFF(fp) & 0xf); } @@ -613,14 +624,14 @@ VOID mcb_print(mcb FAR * mcbp) mcbp->m_psp, mcbp->m_size); } - +/* VOID _fmemcpy(BYTE FAR * d, BYTE FAR * s, REG COUNT n) { while (n--) *d++ = *s++; } - +*/ VOID DosUmbLink(BYTE n) { REG mcb FAR *p; diff --git a/kernel/misc.c b/kernel/misc.c index bdfb5870..2593a3b9 100644 --- a/kernel/misc.c +++ b/kernel/misc.c @@ -34,6 +34,9 @@ static BYTE *miscRcsId = "$Id$"; /* * $Log$ + * Revision 1.4 2001/03/21 02:56:26 bartoldeman + * See history.txt for changes. Bug fixes and HMA support are the main ones. + * * Revision 1.3 2000/05/25 20:56:21 jimtabor * Fixed project history * @@ -86,6 +89,7 @@ static BYTE *miscRcsId = "$Id$"; */ #include "globals.h" +#ifndef ASMSUPT VOID scopy(REG BYTE * s, REG BYTE * d) { @@ -145,3 +149,4 @@ VOID FAR init_call_fmemset(REG VOID FAR * s, REG int ch, REG COUNT n) { fmemset(s, ch, n); } +#endif diff --git a/kernel/network.c b/kernel/network.c index 55d79c20..79f2edfd 100644 --- a/kernel/network.c +++ b/kernel/network.c @@ -36,6 +36,9 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.8 2001/03/21 02:56:26 bartoldeman + * See history.txt for changes. Bug fixes and HMA support are the main ones. + * * Revision 1.7 2000/08/06 05:50:17 jimtabor * Add new files and update cvs with patches and changes * @@ -161,6 +164,7 @@ COUNT Remote_find(UWORD func, BYTE FAR * name, REG dmatch FAR * dmp ) /* Needed Code Rep-off.;) */ +/* p = dmp->dm_name; if (SDp->dir_name[0] == '.') { @@ -189,8 +193,11 @@ COUNT Remote_find(UWORD func, BYTE FAR * name, REG dmatch FAR * dmp ) *p++ = *q++; } } - } + } *p++ = NULL; +*/ + ConvertName83ToNameSZ((BYTE FAR *) dmp->dm_name, (BYTE FAR *) SDp->dir_name); + return i; } diff --git a/kernel/nls.c b/kernel/nls.c index a8b21a35..5e60ce4d 100644 --- a/kernel/nls.c +++ b/kernel/nls.c @@ -44,6 +44,9 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.5 2001/03/21 02:56:26 bartoldeman + * See history.txt for changes. Bug fixes and HMA support are the main ones. + * * Revision 1.4 2000/08/06 05:50:17 jimtabor * Add new files and update cvs with patches and changes * @@ -348,7 +351,9 @@ log( ("NLS: nlsGetData(): Subfunction not found\n") ); } VOID nlsCPchange(UWORD cp) -{ printf("\7\nSorry, to change the codepage is not implemented, yet.\n\ +{ + UNREFERENCED_PARAMETER(cp); + printf("\7\nSorry, to change the codepage is not implemented, yet.\n\ Hope it's OK to proceed ignoring this call.\n-- 2000/02/26 ska\n"); } @@ -610,6 +615,8 @@ COUNT DosSetCodepage(UWORD actCP, UWORD sysCP) UWORD syscall_MUX14(DIRECT_IREGS) { struct nlsPackage FAR*nls; /* addressed NLS package */ + if (flags || cs || ip || ds || es || si); + log( ("NLS: MUX14(): subfct=%x, cp=%u, cntry=%u\n", AL, BX, DX) ); diff --git a/kernel/nlssupt.asm b/kernel/nlssupt.asm index c348b3cb..030bafc0 100644 --- a/kernel/nlssupt.asm +++ b/kernel/nlssupt.asm @@ -29,8 +29,8 @@ ; $Id$ ; ; $Log$ -; Revision 1.5 2001/03/19 04:50:56 bartoldeman -; See history.txt for overview: put kernel 2022beo1 into CVS +; Revision 1.6 2001/03/21 02:56:26 bartoldeman +; See history.txt for changes. Bug fixes and HMA support are the main ones. ; ; ; Revision 1.5 2001/03/08 21:15:00 bartoldeman @@ -87,15 +87,15 @@ %include "segs.inc" -segment _TEXT - global _CharMapSrvc - extern _DosUpChar:wrt TGROUP +segment HMA_TEXT + global _reloc_call_CharMapSrvc + extern _DosUpChar:wrt HGROUP ; ; CharMapSrvc: ; User callable character mapping service. ; Part of Function 38h ; -_CharMapSrvc: +_reloc_call_CharMapSrvc: push ds push es push bp @@ -106,8 +106,10 @@ _CharMapSrvc: push bx push ax ; arg of _upChar - mov ax, DGROUP + push ax + mov ax,DGROUP mov ds, ax + pop ax call _DosUpChar ;add sp, byte 2 // next POP retrieves orig AX diff --git a/kernel/prf.c b/kernel/prf.c index e0bca677..a64c9fee 100644 --- a/kernel/prf.c +++ b/kernel/prf.c @@ -34,15 +34,15 @@ static BYTE *prfRcsId = "$Id$"; /* * $Log$ - * Revision 1.4 2001/03/19 04:50:56 bartoldeman - * See history.txt for overview: put kernel 2022beo1 into CVS + * Revision 1.5 2001/03/21 02:56:26 bartoldeman + * See history.txt for changes. Bug fixes and HMA support are the main ones. * * Revision 1.4 2001/03/07 10:00:00 tomehlert * recoded for smaller object footprint, added main() for testing+QA * * $Log$ - * Revision 1.4 2001/03/19 04:50:56 bartoldeman - * See history.txt for overview: put kernel 2022beo1 into CVS + * Revision 1.5 2001/03/21 02:56:26 bartoldeman + * See history.txt for changes. Bug fixes and HMA support are the main ones. * * Revision 1.3 2000/05/25 20:56:21 jimtabor * Fixed project history @@ -110,13 +110,21 @@ VOID cso(COUNT); VOID cso(); #endif +#ifdef __TURBOC__ +void __int__(int); /* TC 2.01 requires this. :( -- ror4 */ +#endif + + /* special console output routine */ VOID put_console(COUNT c) { if (c == '\n') - cso('\r'); - cso(c); + put_console('\r'); + + _AX = 0x0e00 | c; + _BX = 0x0070; + __int__(0x10); } /* special handler to switch between sprintf and printf */ @@ -188,7 +196,15 @@ sprintf(BYTE * buff, CONST BYTE * fmt, BYTE * args,...) handle_char(NULL); return ret; } - +/* +ULONG FAR retcs(int i) +{ + char *p = (char*)&i; + + p -= 4; + return *(ULONG *)p; +} +*/ COUNT do_printf(CONST BYTE * fmt, BYTE ** arg) { @@ -202,7 +218,19 @@ COUNT fill; int longarg; long currentArg; - + +/* + long cs = retcs(1); + put_console("0123456789ABCDEF"[(cs >> 28) & 0x0f]); + put_console("0123456789ABCDEF"[(cs >> 24) & 0x0f]); + put_console("0123456789ABCDEF"[(cs >> 20) & 0x0f]); + put_console("0123456789ABCDEF"[(cs >> 16) & 0x0f]); + put_console(':'); + put_console("0123456789ABCDEF"[(cs >> 12) & 0x0f]); + put_console("0123456789ABCDEF"[(cs >> 8) & 0x0f]); + put_console("0123456789ABCDEF"[(cs >> 4) & 0x0f]); + put_console("0123456789ABCDEF"[(cs >> 0) & 0x0f]); +*/ while ((c = *fmt++) != '\0') { if (c != '%') @@ -242,7 +270,8 @@ COUNT } - switch (c = *fmt++) + c = *fmt++; + switch (c) { case '\0': return 0; @@ -251,6 +280,15 @@ COUNT handle_char(*(COUNT *) arg++); continue; + case 'p': + { + WORD w[2]; + w[1] = *((unsigned int*) arg)++; + w[0] = *((unsigned int*) arg)++; + do_printf("%04x:%04x",(BYTE**)&w); + continue; + } + case 's': p = *((BYTE **) arg)++; goto do_outputstring; @@ -299,6 +337,8 @@ COUNT continue; default: + handle_char('?'); + handle_char(c); break; @@ -370,7 +410,8 @@ struct { { "2147483649", "%lu", 1,0x8000}, { "-2147483647", "%ld", 1,0x8000}, { "32767", "%ld", 0x7fff,0}, - { "32769", "%ld", 0x8001,0}, + + { "ptr 1234:5678", "ptr %p", 0x5678,0x1234}, diff --git a/kernel/procsupt.asm b/kernel/procsupt.asm index ed2bede7..043ebacb 100644 --- a/kernel/procsupt.asm +++ b/kernel/procsupt.asm @@ -30,6 +30,9 @@ ; $Id$ ; ; $Log$ +; Revision 1.4 2001/03/21 02:56:26 bartoldeman +; See history.txt for changes. Bug fixes and HMA support are the main ones. +; ; Revision 1.3 2000/05/25 20:56:21 jimtabor ; Fixed project history ; @@ -99,6 +102,8 @@ segment _TEXT + extern _DGROUP_:wrt TGROUP + ; ; Special call for switching processes ; @@ -109,8 +114,7 @@ segment _TEXT _exec_user: PUSH$ALL - mov ax,DGROUP - mov ds,ax + mov ds,[_DGROUP_] mov bp,sp cld cli @@ -302,6 +306,11 @@ _spawn_int23: jmp _int21_handler + global _init_call_spawn_int23 +_init_call_spawn_int23: + int 3 + call _spawn_int23 + retf ; ; interrupt enable and disable routines ; diff --git a/kernel/proto.h b/kernel/proto.h index 906fee86..5a35a6e3 100644 --- a/kernel/proto.h +++ b/kernel/proto.h @@ -34,6 +34,9 @@ static BYTE *Proto_hRcsId = "$Id$"; /* * $Log$ + * Revision 1.9 2001/03/21 02:56:26 bartoldeman + * See history.txt for changes. Bug fixes and HMA support are the main ones. + * * Revision 1.8 2000/10/30 00:21:15 jimtabor * Adding Brian Reifsnyder Fix for Int 25/26 * @@ -152,15 +155,16 @@ static BYTE *Proto_hRcsId = "$Id$"; #ifdef IN_INIT_MOD #define __FAR_WRAPPER(ret, name, proto) \ - ret FAR name proto; /* will be expanded to `init_call_' */ + ret FAR name proto; /* will be expanded to `init_call_' */ #else #define __FAR_WRAPPER(ret, name, proto) \ ret name proto; \ - ret FAR init_call_##name proto; + ret FAR init_call_##name proto; \ + ret FAR reloc_call_##name proto; #endif /* blockio.c */ -VOID FAR init_buffers(void); +VOID FAR init_call_init_buffers(COUNT anzBuffers); ULONG getblkno(struct buffer FAR *); VOID setblkno(struct buffer FAR *, ULONG); struct buffer FAR *getblock(ULONG blkno, COUNT dsk); @@ -207,7 +211,7 @@ BYTE FAR *get_root(BYTE FAR *); BOOL fnmatch(BYTE FAR *, BYTE FAR *, COUNT, COUNT); BOOL check_break(void); UCOUNT GenericRead(COUNT hndl, UCOUNT n, BYTE FAR * bp, COUNT FAR * err, - BOOL force_binary); + BOOL force_binary); COUNT SftSeek(sft FAR *sftp, LONG new_pos, COUNT mode); UCOUNT DosRead(COUNT hndl, UCOUNT n, BYTE FAR * bp, COUNT FAR * err); UCOUNT DosWrite(COUNT hndl, UCOUNT n, BYTE FAR * bp, COUNT FAR * err); @@ -243,7 +247,7 @@ COUNT ParseDosName(BYTE FAR *, COUNT *, BYTE *, BYTE *, BYTE *, BOOL); COUNT ParseDosPath(BYTE FAR *, COUNT *, BYTE *, BYTE FAR *); /* dsk.c */ -COUNT blk_driver(rqptr rp); +COUNT FAR init_call_blk_driver(rqptr rp); /* error.c */ VOID dump(void); @@ -345,7 +349,7 @@ BOOL FcbFindNext(xfcb FAR * lpXfcb); UWORD init_oem(void); /* inthndlr.c */ -VOID INRPT far got_cbreak(void); /* procsupt.asm */ +VOID INRPT far got_cbreak(void); /* procsupt.asm */ VOID INRPT far int20_handler(iregs UserRegs); VOID INRPT far int21_handler(iregs UserRegs); VOID far int21_entry(iregs UserRegs); @@ -376,7 +380,7 @@ seg long2para(LONG size); VOID FAR *add_far(VOID FAR * fp, ULONG off); VOID FAR *adjust_far(VOID FAR * fp); __FAR_WRAPPER(COUNT, DosMemAlloc, - (UWORD size, COUNT mode, seg FAR * para, UWORD FAR * asize)) + (UWORD size, COUNT mode, seg FAR * para, UWORD FAR * asize)) COUNT DosMemLargest(UWORD FAR * size); COUNT DosMemFree(UWORD para); COUNT DosMemChange(UWORD para, UWORD size, UWORD * maxSize); @@ -386,15 +390,35 @@ COUNT DosGetLargestBlock(UWORD FAR * block); VOID show_chain(void); VOID DosUmbLink(BYTE n); VOID mcb_print(mcb FAR * mcbp); -VOID _fmemcpy(BYTE FAR * d, BYTE FAR * s, REG COUNT n); /* misc.c */ +/* __FAR_WRAPPER(VOID, scopy, (REG BYTE * s, REG BYTE * d)) -VOID fscopy(REG BYTE FAR * s, REG BYTE FAR * d); -VOID fsncopy(BYTE FAR * s, BYTE FAR * d, REG COUNT n); -VOID bcopy(REG BYTE * s, REG BYTE * d, REG COUNT n); +#define strcpy(d, s) scopy(s, d) __FAR_WRAPPER(VOID, fbcopy, (REG VOID FAR * s, REG VOID FAR * d, REG COUNT n)) +*/ +__FAR_WRAPPER(VOID, strcpy, (REG BYTE * d, REG BYTE * s)) +#define scopy(s, d) strcpy(d,s) +__FAR_WRAPPER(VOID, fmemcpy, (REG VOID FAR * d, REG VOID FAR * s, REG COUNT n)) +#define fbcopy(s, d, n) fmemcpy(d,s,n) +void FAR _reloc_call_fmemcpy(REG VOID FAR * d, REG VOID FAR * s, REG COUNT n); + + +/*VOID fscopy(REG BYTE FAR * s, REG BYTE FAR * d);*/ +VOID fstrcpy(REG BYTE FAR * d, REG BYTE FAR * s); +#define fscopy(s,d) fstrcpy(d,s) + +VOID fstrcpy(REG BYTE FAR * d, REG BYTE FAR * s); + +/*VOID bcopy(REG BYTE * s, REG BYTE * d, REG COUNT n);*/ +void memcpy(REG BYTE * d, REG BYTE * s, REG COUNT n); +#define bcopy(s,d,n) memcpy(d,s,n) + +__FAR_WRAPPER(void, fmemset,(REG VOID FAR * s, REG int ch, REG COUNT n)) +__FAR_WRAPPER(void, memset ,(REG VOID * s, REG int ch, REG COUNT n)) + + /* nls.c */ BYTE DosYesNo(unsigned char ch); #ifndef DosUpMem @@ -431,11 +455,17 @@ __FAR_WRAPPER(COUNT, strcmp, (REG BYTE * d, REG BYTE * s)) COUNT fstrcmp(REG BYTE FAR * d, REG BYTE FAR * s); COUNT fstrncmp(REG BYTE FAR * d, REG BYTE FAR * s, COUNT l); COUNT strncmp(REG BYTE * d, REG BYTE * s, COUNT l); -VOID fstrncpy(REG BYTE FAR * d, REG BYTE FAR * s, COUNT l); +/* +void fsncopy(REG BYTE FAR * s, REG BYTE FAR * d, COUNT l); +#define fstrncpy(d,s,l) fsncopy(s,d,l) +*/ +void fstrncpy(REG BYTE FAR * d, REG BYTE FAR * s, COUNT l); +#define fsncopy(s,d,l) fstrncpy(d,s,l) + BYTE *strchr(BYTE * s, BYTE c); /* sysclk.c */ -WORD clk_driver(rqptr rp); +WORD FAR init_call_clk_driver(rqptr rp); COUNT BcdToByte(COUNT x); COUNT BcdToWord(BYTE * x, UWORD * mon, UWORD * day, UWORD * yr); COUNT ByteToBcd(COUNT x); @@ -456,6 +486,11 @@ COUNT DosSetTime(BYTE FAR * hp, BYTE FAR * mp, BYTE FAR * sp, BYTE FAR * hdp); VOID DosGetDate(BYTE FAR * wdp, BYTE FAR * mp, BYTE FAR * mdp, COUNT FAR * yp); COUNT DosSetDate(BYTE FAR * mp, BYTE FAR * mdp, COUNT FAR * yp); +WORD *is_leap_year_monthdays(int year); +__FAR_WRAPPER(WORD,DaysFromYearMonthDay,(WORD Year, WORD Month, WORD DayOfMonth)) + + + /* task.c */ COUNT ChildEnv(exec_blk FAR * exp, UWORD * pChildEnvSeg, char far * pathname); VOID new_psp(psp FAR * p, int psize); @@ -463,7 +498,7 @@ VOID return_user(void); __FAR_WRAPPER(COUNT, DosExec, (COUNT mode, exec_blk FAR * ep, BYTE FAR * lp)) __FAR_WRAPPER(VOID, InitPSP, (VOID)) -VOID FAR p_0(void); +VOID FAR init_call_p_0(VOID); /* irqstack.asm */ VOID init_stacks(VOID FAR * stack_base, COUNT nStacks, WORD stackSize); @@ -478,7 +513,7 @@ COUNT truename(char FAR * src, char FAR * dest, COUNT t); COUNT int2f_Remote_call(UWORD func, UWORD b, UCOUNT n, UWORD d, VOID FAR * s, UWORD i, VOID FAR * data); COUNT QRemote_Fn(char FAR * s, char FAR * d); -COUNT FAR Umb_Test(void); +COUNT Umb_Test(void); UWORD get_machine_name(BYTE FAR * netname); VOID set_machine_name(BYTE FAR * netname, UWORD name_num); @@ -487,9 +522,24 @@ COUNT Remote_find(UWORD func, BYTE FAR * name, REG dmatch FAR * dmp); /* procsupt.asm */ VOID INRPT FAR exec_user(iregs FAR * irp); -#define strcpy(d, s) scopy(s, d) /* detect.c */ unsigned long FAR is_dosemu(void); +/* new by TE */ + +/* + assert at compile time, that something is true. + + use like + ASSERT_CONST( SECSIZE == 512) + ASSERT_CONST( (BYTE FAR *)x->fcb_ext - (BYTE FAR *)x->fcbname == 8) +*/ + +#define ASSERT_CONST(x) { typedef struct { char x[2 * (x) - 1]; } xx ; } + +void ConvertName83ToNameSZ(BYTE FAR *destSZ, BYTE FAR *srcFCBName); + + +VOID FAR *HMAalloc(COUNT bytesToAllocate); \ No newline at end of file diff --git a/kernel/segs.inc b/kernel/segs.inc index 11d3c452..992212d6 100644 --- a/kernel/segs.inc +++ b/kernel/segs.inc @@ -29,6 +29,9 @@ ; $Header$ ; ; $Log$ +; Revision 1.4 2001/03/21 02:56:26 bartoldeman +; See history.txt for changes. Bug fixes and HMA support are the main ones. +; ; Revision 1.3 2000/05/25 20:56:21 jimtabor ; Fixed project history ; @@ -54,8 +57,9 @@ ; $EndLog ; -group TGROUP _TEXT _IO_TEXT _IO_FIXED_DATA +group TGROUP _TEXT _IO_TEXT _IO_FIXED_DATA group DGROUP _FIXED_DATA _DATA _BSS _BSSEND +group HGROUP HMA_TEXT_START HMA_TEXT HMA_TEXT_END group IGROUP INIT_TEXT_START INIT_TEXT INIT_TEXT_END segment _TEXT class=CODE @@ -63,8 +67,13 @@ segment _IO_TEXT class=CODE segment _IO_FIXED_DATA class=CODE align=2 segment _FIXED_DATA class=DATA align=16 segment _DATA class=DATA align=2 +segment _BSSSTART class=BSS align=2 segment _BSS class=BSS align=2 segment _BSSEND class=BSS +segment HMA_TEXT_START class=HMA +segment HMA_TEXT class=HMA +segment HMA_TEXT_END class=HMA segment INIT_TEXT_START class=INIT align=16 segment INIT_TEXT class=INIT segment INIT_TEXT_END class=INIT + diff --git a/kernel/strings.c b/kernel/strings.c index 93c1dff7..c97ca2b8 100644 --- a/kernel/strings.c +++ b/kernel/strings.c @@ -34,6 +34,9 @@ static BYTE *stringsRcsId = "$Id$"; /* * $Log$ + * Revision 1.4 2001/03/21 02:56:26 bartoldeman + * See history.txt for changes. Bug fixes and HMA support are the main ones. + * * Revision 1.3 2000/05/25 20:56:21 jimtabor * Fixed project history * @@ -91,6 +94,7 @@ static BYTE *stringsRcsId = "$Id$"; * Initial revision. */ +#ifndef ASMSUPT COUNT strlen(REG BYTE * s) { REG WORD cnt = 0; @@ -204,3 +208,4 @@ BYTE *strchr(BYTE * s, BYTE c) while (*p); return 0; } +#endif diff --git a/kernel/sysclk.c b/kernel/sysclk.c index 7e00f753..c3188b38 100644 --- a/kernel/sysclk.c +++ b/kernel/sysclk.c @@ -35,6 +35,9 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.4 2001/03/21 02:56:26 bartoldeman + * See history.txt for changes. Bug fixes and HMA support are the main ones. + * * Revision 1.3 2000/05/25 20:56:21 jimtabor * Fixed project history * @@ -107,12 +110,8 @@ VOID DayToBcd(); /* */ /* WARNING - THIS DRIVER IS NON-PORTABLE!!!! */ /* */ +extern WORD days[2][13]; /* this is defined by SYSTIME.C */ -WORD days[2][13] = -{ - {0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365}, - {0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366} -}; static struct ClockRecord clk; @@ -128,11 +127,12 @@ static BYTE bcdSeconds; static ULONG Ticks; UWORD DaysSinceEpoch = 0; -WORD clk_driver(rqptr rp) +WORD FAR init_call_clk_driver(rqptr rp) { - REG COUNT count, + COUNT c; - BYTE FAR *cp; + int FAR *cp; + WORD *pdays; switch (rp->r_command) { @@ -142,9 +142,6 @@ WORD clk_driver(rqptr rp) return S_DONE; case C_INPUT: - count = rp->r_count; - if (count > sizeof(struct ClockRecord)) - count = sizeof(struct ClockRecord); { ULONG remainder, hs; @@ -158,6 +155,7 @@ WORD clk_driver(rqptr rp) * (100 x 86400) / 0x1800b0 = 108000 / 19663. -- ror4 */ hs = 0; +#if 0 if (Ticks >= 64 * 19663ul) { hs += 64 * 108000ul; @@ -193,6 +191,15 @@ WORD clk_driver(rqptr rp) hs += 108000ul; Ticks -= 19663ul; } +#else + { + UWORD q1 = Ticks/19663ul; + + Ticks -= q1*19663ul; + hs = q1*108000ul; + } + +#endif /* * Now Ticks < 19663, so Ticks * 108000 < 2123604000 < ULONG_MAX. * *phew* -- ror4 @@ -205,15 +212,13 @@ WORD clk_driver(rqptr rp) clk.clkSeconds = remainder / 100ul; clk.clkHundredths = remainder % 100ul; } - fbcopy((BYTE FAR *) & clk, rp->r_trans, count); + + fbcopy((BYTE FAR *) & clk, rp->r_trans, min(sizeof(struct ClockRecord),rp->r_count )); return S_DONE; case C_OUTPUT: - count = rp->r_count; - if (count > sizeof(struct ClockRecord)) - count = sizeof(struct ClockRecord); - rp->r_count = count; - fbcopy(rp->r_trans, (BYTE FAR *) & clk, count); + rp->r_count = min(rp->r_count,sizeof(struct ClockRecord)); + fbcopy(rp->r_trans, (BYTE FAR *) & clk, rp->r_count); /* Set PC Clock first */ DaysSinceEpoch = clk.clkDays; @@ -224,6 +229,7 @@ WORD clk_driver(rqptr rp) 100ul * clk.clkSeconds + clk.clkHundredths; Ticks = 0; +#if 0 if (hs >= 64 * 108000ul) { Ticks += 64 * 19663ul; @@ -259,6 +265,15 @@ WORD clk_driver(rqptr rp) Ticks += 19663ul; hs -= 108000ul; } +#else + { + UWORD q1 = hs/108000ul; + + hs -= q1*108000ul; + Ticks = q1*19663ul; + } + +#endif Ticks += hs * 19663ul / 108000ul; } WritePCClock(Ticks); @@ -266,13 +281,13 @@ WORD clk_driver(rqptr rp) /* Now set AT clock */ /* Fix year by looping through each year, subtracting */ /* the appropriate number of days for that year. */ - for (Year = 1980, c = clk.clkDays; c > 0;) + for (Year = 1980, c = clk.clkDays; ;) { - count = is_leap_year(Year) ? 366 : 365; - if (c >= count) + pdays = is_leap_year_monthdays(Year); + if (c >= pdays[12]) { ++Year; - c -= count; + c -= pdays[12]; } else break; @@ -282,12 +297,14 @@ WORD clk_driver(rqptr rp) /* days for that year. Use this to index the table. */ for (Month = 1; Month < 13; ++Month) { - if (days[count == 366][Month] > c) + if (pdays[Month] > c) { - Day = c - days[count == 366][Month - 1] + 1; + Day = c - pdays[Month - 1] + 1; break; } } + + DayToBcd((BYTE *) bcdDays, &Month, &Day, &Year); bcdMinutes = ByteToBcd(clk.clkMinutes); bcdHours = ByteToBcd(clk.clkHours); diff --git a/kernel/systime.c b/kernel/systime.c index d2376180..0bb740f2 100644 --- a/kernel/systime.c +++ b/kernel/systime.c @@ -37,6 +37,9 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.4 2001/03/21 02:56:26 bartoldeman + * See history.txt for changes. Bug fixes and HMA support are the main ones. + * * Revision 1.3 2000/05/25 20:56:21 jimtabor * Fixed project history * @@ -94,39 +97,65 @@ static BYTE *RcsId = "$Id$"; * Initial revision. */ -static WORD days[2][13] = + +WORD days[2][13] = { {0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365}, {0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366} }; -static WORD ndays[2][13] = -{ - /* 1 2 3 4 5 6 7 8 9 10 11 12 */ - {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}, - {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}, -}; +extern request + ClkReqHdr; + +/* + return a pointer to an array with the days for that year +*/ -extern BYTE - Month, - DayOfMonth, - DayOfWeek; +WORD *is_leap_year_monthdays(int y) +{ + /* this is correct in a strict mathematical sense + return ((y) & 3 ? days[0] : (y) % 100 ? days[1] : (y) % 400 ? days[0] : days[1]); */ + + /* this will work until 2200 - long enough for me - and saves 0x1f bytes */ + + if ((y & 3) || y == 2100) return days[0]; + + return days[1]; +} -extern COUNT - Year, - YearsSince1980; +WORD DaysFromYearMonthDay(WORD Year, WORD Month, WORD DayOfMonth) +{ + if (Year < 1980) return 0; + + return DayOfMonth - 1 + + is_leap_year_monthdays(Year)[Month - 1] + + ((Year - 1980) * 365) + + ((Year - 1980 + 3) / 4); + +} +WORD FAR init_call_DaysFromYearMonthDay(WORD Year, WORD Month, WORD DayOfMonth) +{ + return DaysFromYearMonthDay(Year,Month,DayOfMonth); +} -extern request - ClkReqHdr; -VOID DosGetTime(BYTE FAR * hp, BYTE FAR * mp, BYTE FAR * sp, BYTE FAR * hdp) +/* common - call the clock driver */ +void ExecuteClockDriverRequest(BYTE command) { ClkReqHdr.r_length = sizeof(request); - ClkReqHdr.r_command = C_INPUT; + ClkReqHdr.r_command = command; ClkReqHdr.r_count = sizeof(struct ClockRecord); ClkReqHdr.r_trans = (BYTE FAR *) (&ClkRecord); ClkReqHdr.r_status = 0; execrh((request FAR *) & ClkReqHdr, (struct dhdr FAR *)clock); +} + + + +VOID DosGetTime(BYTE FAR * hp, BYTE FAR * mp, BYTE FAR * sp, BYTE FAR * hdp) +{ + ExecuteClockDriverRequest(C_INPUT); + if (ClkReqHdr.r_status & S_ERROR) return; @@ -138,6 +167,8 @@ VOID DosGetTime(BYTE FAR * hp, BYTE FAR * mp, BYTE FAR * sp, BYTE FAR * hdp) COUNT DosSetTime(BYTE FAR * hp, BYTE FAR * mp, BYTE FAR * sp, BYTE FAR * hdp) { + BYTE Month, DayOfMonth, DayOfWeek; COUNT Year; + DosGetDate((BYTE FAR *) & DayOfWeek, (BYTE FAR *) & Month, (BYTE FAR *) & DayOfMonth, (COUNT FAR *) & Year); @@ -146,18 +177,10 @@ COUNT DosSetTime(BYTE FAR * hp, BYTE FAR * mp, BYTE FAR * sp, BYTE FAR * hdp) ClkRecord.clkSeconds = *sp; ClkRecord.clkHundredths = *hdp; - YearsSince1980 = Year - 1980; - ClkRecord.clkDays = DayOfMonth - 1 - + days[is_leap_year(Year)][Month - 1] - + ((YearsSince1980) * 365) - + ((YearsSince1980 + 3) / 4); + ClkRecord.clkDays = DaysFromYearMonthDay(Year, Month, DayOfMonth); + + ExecuteClockDriverRequest(C_OUTPUT); - ClkReqHdr.r_length = sizeof(request); - ClkReqHdr.r_command = C_OUTPUT; - ClkReqHdr.r_count = sizeof(struct ClockRecord); - ClkReqHdr.r_trans = (BYTE FAR *) (&ClkRecord); - ClkReqHdr.r_status = 0; - execrh((request FAR *) & ClkReqHdr, (struct dhdr FAR *)clock); if (ClkReqHdr.r_status & S_ERROR) return char_error(&ClkReqHdr, (struct dhdr FAR *)clock); return SUCCESS; @@ -169,25 +192,22 @@ BYTE FAR *wdp, FAR * mdp; COUNT FAR *yp; { - COUNT count, - c; + WORD c; + WORD *pdays; + WORD Year,Month; + + ExecuteClockDriverRequest(C_INPUT); - ClkReqHdr.r_length = sizeof(request); - ClkReqHdr.r_command = C_INPUT; - ClkReqHdr.r_count = sizeof(struct ClockRecord); - ClkReqHdr.r_trans = (BYTE FAR *) (&ClkRecord); - ClkReqHdr.r_status = 0; - execrh((request FAR *) & ClkReqHdr, (struct dhdr FAR *)clock); if (ClkReqHdr.r_status & S_ERROR) return; - for (Year = 1980, c = ClkRecord.clkDays; c > 0;) + for (Year = 1980, c = ClkRecord.clkDays; ;) { - count = is_leap_year(Year) ? 366 : 365; - if (c >= count) + pdays = is_leap_year_monthdays(Year); + if (c >= pdays[12]) { ++Year; - c -= count; + c -= pdays[12]; } else break; @@ -196,21 +216,19 @@ COUNT FAR *yp; /* c contains the days left and count the number of days for */ /* that year. Use this to index the table. */ Month = 1; - while (c >= ndays[count == 366][Month]) + while (c >= pdays[Month]) { - c -= ndays[count == 366][Month]; ++Month; } *mp = Month; - *mdp = c + 1; + *mdp = c - pdays[Month-1] + 1; *yp = Year; /* Day of week is simple. Take mod 7, add 2 (for Tuesday */ /* 1-1-80) and take mod again */ - DayOfWeek = (ClkRecord.clkDays % 7 + 2) % 7; - *wdp = DayOfWeek; + *wdp = (ClkRecord.clkDays + 2) % 7; } COUNT DosSetDate(mp, mdp, yp) @@ -218,31 +236,28 @@ BYTE FAR *mp, FAR * mdp; COUNT FAR *yp; { + WORD *pdays, Month, DayOfMonth,Year; Month = *mp; DayOfMonth = *mdp; Year = *yp; + pdays = is_leap_year_monthdays(Year); + if (Year < 1980 || Year > 2099 || Month < 1 || Month > 12 - || DayOfMonth < 1 || DayOfMonth > ndays[is_leap_year(Year)][Month]) + || DayOfMonth < 1 + || DayOfMonth > pdays[Month] - pdays[Month-1]) return DE_INVLDDATA; + DosGetTime((BYTE FAR *) & ClkRecord.clkHours, (BYTE FAR *) & ClkRecord.clkMinutes, (BYTE FAR *) & ClkRecord.clkSeconds, (BYTE FAR *) & ClkRecord.clkHundredths); - YearsSince1980 = Year - 1980; - ClkRecord.clkDays = DayOfMonth - 1 - + days[is_leap_year(Year)][Month - 1] - + ((YearsSince1980) * 365) - + ((YearsSince1980 + 3) / 4); + ClkRecord.clkDays = DaysFromYearMonthDay(Year, Month, DayOfMonth); + + ExecuteClockDriverRequest(C_OUTPUT); - ClkReqHdr.r_length = sizeof(request); - ClkReqHdr.r_command = C_OUTPUT; - ClkReqHdr.r_count = sizeof(struct ClockRecord); - ClkReqHdr.r_trans = (BYTE FAR *) (&ClkRecord); - ClkReqHdr.r_status = 0; - execrh((request FAR *) & ClkReqHdr, (struct dhdr FAR *)clock); if (ClkReqHdr.r_status & S_ERROR) return char_error(&ClkReqHdr, (struct dhdr FAR *)clock); return SUCCESS; diff --git a/kernel/task.c b/kernel/task.c index 1f6ca26c..7d688892 100644 --- a/kernel/task.c +++ b/kernel/task.c @@ -35,8 +35,8 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ - * Revision 1.6 2001/03/19 04:50:56 bartoldeman - * See history.txt for overview: put kernel 2022beo1 into CVS + * Revision 1.7 2001/03/21 02:56:26 bartoldeman + * See history.txt for changes. Bug fixes and HMA support are the main ones. * * Revision 1.6 2001/03/08 21:00:00 bartoldeman * UMB fixes to DosComLoader @@ -441,7 +441,7 @@ static VOID patchPSP(UWORD pspseg, UWORD envseg, CommandTail FAR * cmdline } -static COUNT DosComLoader(BYTE FAR * namep, exec_blk FAR * exp, COUNT mode) +COUNT DosComLoader(BYTE FAR * namep, exec_blk FAR * exp, COUNT mode) { COUNT rc, err, @@ -674,7 +674,7 @@ static COUNT DosExeLoader(BYTE FAR * namep, exec_blk FAR * exp, COUNT mode) /* and finally add in the psp size */ if (mode != OVERLAY) - image_size += (ULONG) long2para((LONG) sizeof(psp)); + image_size += sizeof(psp); /*TE 03/20/01*/ if (mode != OVERLAY) { @@ -956,7 +956,7 @@ VOID InitPSP(VOID) } /* process 0 */ -VOID FAR p_0(VOID) +VOID FAR reloc_call_p_0(VOID) { exec_blk exb; CommandTail Cmd; diff --git a/sys/sys.mak b/sys/sys.mak index 3c99efa7..02c6d013 100644 --- a/sys/sys.mak +++ b/sys/sys.mak @@ -4,6 +4,9 @@ # $Id$ # # $Log$ +# Revision 1.4 2001/03/21 02:56:26 bartoldeman +# See history.txt for changes. Bug fixes and HMA support are the main ones. +# # Revision 1.3 2000/05/25 20:56:23 jimtabor # Fixed project history # @@ -36,7 +39,7 @@ #CFLAGS = -mt -1- -v -vi- -k- -f- -ff- -O -Z -d -I$(INCLUDEPATH);..\hdr \ # -L$(LIBPATH) -DI86;PROTO;DEBUG CFLAGS = -mt -1- -v -vi- -k- -f- -ff- -O -Z -d -I$(INCLUDEPATH);..\hdr \ - -L$(LIBPATH) -DI86;PROTO + -L$(LIBPATH) -DI86;PROTO -zAHMA -zCHMA_TEXT -zDHMA_TEXT # *Implicit Rules* .c.obj: @@ -66,8 +69,9 @@ b_fat16.h: ..\boot\b_fat16.bin bin2c.com bin2c ..\boot\b_fat16.bin b_fat16.h b_fat16 sys.com: $(EXE_dependencies) - $(LINK) /m/t/c $(LIBPATH)\c0t.obj+sys.obj,sys,,\ - $(LIBS)+$(CLIB); +# $(LINK) /m/t/c $(LIBPATH)\c0t.obj+sys.obj,sys,,\ + $(LINK) /m/c $(LIBPATH)\c0s.obj+sys.obj,sys.com,,\ + $(LIBS)+$(CLIB); clobber: clean $(RM) sys.com b_fat12.h b_fat16.h From 8dff303fda42de4b4dcdffd87674dca8517a9635 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Wed, 21 Mar 2001 03:01:45 +0000 Subject: [PATCH 050/671] New file by Tom Ehlert for HMA initialization. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@168 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/inithma.c | 534 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 534 insertions(+) create mode 100644 kernel/inithma.c diff --git a/kernel/inithma.c b/kernel/inithma.c new file mode 100644 index 00000000..a2d055b4 --- /dev/null +++ b/kernel/inithma.c @@ -0,0 +1,534 @@ +/****************************************************************/ +/* */ +/* initHMA.c */ +/* DOS-C */ +/* */ +/* move kernel to HMA area */ +/* */ +/* Copyright (c) 2001 */ +/* tom ehlert */ +/* All Rights Reserved */ +/* */ +/* This file is part of DOS-C. */ +/* */ +/* DOS-C is free software; you can redistribute it and/or */ +/* modify it under the terms of the GNU General Public License */ +/* as published by the Free Software Foundation; either version */ +/* 2, or (at your option) any later version. */ +/* */ +/* DOS-C is distributed in the hope that it will be useful, but */ +/* WITHOUT ANY WARRANTY; without even the implied warranty of */ +/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See */ +/* the GNU General Public License for more details. */ +/* */ +/* You should have received a copy of the GNU General Public */ +/* License along with DOS-C; see the file COPYING. If not, */ +/* write to the Free Software Foundation, 675 Mass Ave, */ +/* Cambridge, MA 02139, USA. */ +/****************************************************************/ + +/* + current status: + + load FreeDOS high, if DOS=HIGH detected + + suppress High Loading, if any SHIFT status detected (for debugging) + + if no XMS driver (HIMEM,FDXMS,...) loaded, should work + + cooperation with XMS drivers as follows: + + copy HMA_TEXT segment up. + + after each loaded DEVICE=SOMETHING.SYS, try to request the HMA + (XMS function 0x01). + if no XMS driver detected, during ONFIG.SYS processing, + create a dummy VDISK entry in high memory + + this works with + + FD FDXMS - no problems detected + + + MS HIMEM.SYS (from DOS 6.2, 9-30-93) + + works if and only if + + /TESTMEM:OFF + + is given + + otherwise HIMEM will TEST AND ZERO THE HIGH MEMORY+HMA. + so, in CONFIG.C, if "HIMEM.SYS" is detected, a "/TESTMEM:OFF" + parameter is forced. +*/ + + +#include "init-mod.h" + +#include "portab.h" +#include "globals.h" + +#ifdef VERSION_STRINGS +static BYTE *RcsId = "$Id$"; +#endif + +/* + * $Log$ + * Revision 1.1 2001/03/21 03:01:45 bartoldeman + * New file by Tom Ehlert for HMA initialization. + * + * Revision 0.1 2001/03/16 12:00:00 tom ehlert + * initial creation + */ + + +BYTE DosLoadedInHMA; /* set to TRUE if loaded HIGH */ +BYTE HMAclaimed; /* set to TRUE if claimed from HIMEM */ +WORD HMAFree; /* first byte in HMA not yet used */ + + +extern BYTE FAR * FAR XMSDriverAddress; +extern FAR _EnableA20(); +extern FAR _DisableA20(); + + +void FAR *DetectXMSDriver(); + +#ifdef DEBUG + #define int3() __int__(3); +#else + #define int3() +#endif + + +#if defined( DEBUG ) || 1 /* experimental kernel !! */ + #define HMAInitPrintf(x) printf x +#else + #define HMAInitPrintf(x) +#endif + + +#ifdef DEBUG +hdump(BYTE FAR *p) +{ + int loop; + HMAInitPrintf(("%p", p)); + + for (loop = 0; loop < 16; loop++) + HMAInitPrintf(("%02x ", p[loop])); + + printf("\n"); +} +#else + #define hdump(ptr) +#endif + + +#ifdef __TURBOC__ + void __int__(int); /* TC 2.01 requires this. :( -- ror4 */ + unsigned char __inportb__(int portid); + void __outportb__ (int portid, unsigned char value); +#endif + + + +#define KeyboardShiftState() (*(BYTE FAR *)(MK_FP(0x40,0x17))) + + +/* of course, this should go to ASMSUPT */ +fmemcmp(BYTE far *s1, BYTE FAR *s2, unsigned len) +{ + for ( ; len ; s1++,s2++,--len) + { + if (*s1 - *s2) + return *s1-*s2; + } + return 0; +} + + +/* Enable / Disable borrowed without understanding from FDXMS. Thanks. + gone done to KERNEL.ASM + +OutportWithDelay(WORD port, BYTE val) +{ + int loop; + + __outportb__(port,val); + + for (loop = 100; --loop && __inportb__(0x64) & 0x02;) + ; +} + + +void _EnableHMA() +{ + OutportWithDelay(0x64, 0xd1); + OutportWithDelay(0x60, 0xdf); + OutportWithDelay(0x64, 0xff); +} +void _DisableHMA() +{ + OutportWithDelay(0x64, 0xd1); + OutportWithDelay(0x60, 0xdd); + OutportWithDelay(0x64, 0xff); +} +*/ + +/* + this tests, if the HMA area can be enabled. + if so, it simply leaves it on +*/ + +int EnableHMA() +{ + + _EnableA20(); + + if (fmemcmp(MK_FP(0x0000,0x0000), MK_FP(0xffff,0x0010),128) == 0) + { + printf("HMA can't be enabled\n"); + return FALSE; + } + + + _DisableA20(); + + if (fmemcmp(MK_FP(0x0000,0x0000), MK_FP(0xffff,0x0010),128) != 0) + { + printf("HMA can't be disabled - no problem for us\n"); + } + + _EnableA20(); + if (fmemcmp(MK_FP(0x0000,0x0000), MK_FP(0xffff,0x0010),128) == 0) + { + printf("HMA can't be enabled second time\n"); + return FALSE; + } + + HMAInitPrintf(("HMA success - leaving enabled\n")); + + return TRUE; + +} + + + + +/* + move the kernel up to high memory + this is very unportable + + if we thin we succeeded, we return TRUE, else FALSE +*/ + +#define HMAOFFSET 0x20 +#define HMASEGMENT 0xffff + + +int MoveKernelToHMA() +{ + UBYTE FAR *HMASource; + unsigned len; + + + int3(); + + + if (DosLoadedInHMA) + { + return TRUE; + } + + { /* is very improbable - we are just booting - but + there might already a XMS handler installed + this is the case for DOSEMU + */ + + void FAR *pXMS = DetectXMSDriver(); + + if (pXMS != NULL) + { + XMSDriverAddress = pXMS; + + printf("DOSEMU ? detected XMS driver at %p\n", XMSDriverAddress); + + } + } + + + + /* A) for debugging purpose, suppress this, + if any shift key is pressed + */ + + if (KeyboardShiftState() & 0x0f) + { + printf("Keyboard state is %0x, NOT moving to HMA\n",KeyboardShiftState()); + return FALSE; + } + + /* B) check out, if we can have HMA */ + + if (!EnableHMA()) + { + printf("Can't enable HMA area (the famous A20), NOT moving to HMA\n"); + + return FALSE; + } + + + /* C) we have HMA, copy HMA_TEXT up to 0xffff:0..ffff */ + + { + + UBYTE FAR *HMADest = MK_FP(HMASEGMENT,0x0000); + + len = FP_OFF(_HMATextEnd) - FP_OFF(_HMATextStart); + + HMASource = _HMATextStart; + + + len += FP_OFF(HMASource) & 0x000f; + + FP_OFF(HMASource) &= 0xfff0; + + HMASource += HMAOFFSET; + HMADest += HMAOFFSET; + len -= HMAOFFSET; + + + HMAInitPrintf(("HMA moving %p up to %p for %04x bytes\n", + HMASource, HMADest, len)); + + fmemcpy(HMADest, HMASource, len); + + HMAFree = FP_OFF(HMADest)+len; /* first free byte after HMA_TEXT */ + + int3(); + + } + { + /* D) but it only makes sense, if we can relocate + all our entries to make use of HMA + */ + + /* this is for a + call near enableA20 + jmp far kernelentry + style table + */ + + struct RelocationTable { + UBYTE jmpFar; + UWORD jmpOffset; + UWORD jmpSegment; + UBYTE callNear; + UWORD callOffset; + }; + struct RelocatedEntry { + UBYTE callNear; + UWORD callOffset; + UBYTE jmpFar; + UWORD jmpOffset; + UWORD jmpSegment; + }; + extern struct RelocationTable + FAR _HMARelocationTableStart[], + FAR _HMARelocationTableEnd[]; + + struct RelocationTable FAR *rp, rtemp ; + + + UWORD HMATextSegment = FP_SEG( _HMATextStart ); + + /* verify, that all entries are valid */ + + for (rp = _HMARelocationTableStart; rp < _HMARelocationTableEnd; rp++) + { + if (rp->jmpFar != 0xea || /* jmp FAR */ + rp->jmpSegment != HMATextSegment || /* will only relocate HMA_TEXT */ + rp->callNear != 0xe8 || /* call NEAR */ + 0) + { + printf("illegal relocation entry # %d\n",rp - _HMARelocationTableStart); + goto errorReturn; + } + } + + /* OK, all valid, go to relocate*/ + + for (rp = _HMARelocationTableStart; rp < _HMARelocationTableEnd; rp++) + { + struct RelocatedEntry FAR *rel = (struct RelocatedEntry FAR *)rp; + + fmemcpy(&rtemp, rp, sizeof(rtemp)); + + rel->jmpFar = rtemp.jmpFar; + rel->jmpSegment = HMASEGMENT; + rel->jmpOffset = rtemp.jmpOffset; + rel->callNear = rtemp.callNear; + rel->callOffset = rtemp.callOffset+5; /* near calls are relative */ + } + + + } + + { + /* E) up to now, nothing really bad was done. + but now, we reuse the HMA area. bad things will happen + + to find bugs early, + cause INT 3 on all accesses to this area + */ + + fmemset(HMASource, 0xcc, len); + HMAInitPrintf(("HMA text segment filled with INT 3\n")); + + DosLoadedInHMA = TRUE; + } + + int3(); + return TRUE; + +errorReturn: + printf("HMA errors, not doing HMA\n"); + int3(); + return FALSE; +} + + +/* + + + + + +/* + now protect against HIMEM/FDXMS/... by simulating a VDISK + FDXMS should detect us and not give HMA access to ohers + unfortunately this also disables HIMEM completely + + so: we install this after all drivers have been loaded +*/ +void InstallVDISK() + { + static struct { /* Boot-Sektor of a RAM-Disk */ + BYTE dummy1[3]; /* HIMEM.SYS uses 3, but FDXMS uses 2 */ + char Name[5]; + BYTE dummy2[3]; + WORD BpS; + BYTE dummy3[6]; + WORD Sektoren; + BYTE dummy4; + } VDISK_BOOT_SEKTOR = + { + { 0xcf, ' ', ' '}, + { 'V', 'D', 'I', 'S', 'K'}, + { ' ', ' ', ' '}, + 512, + { 'F', 'D', 'O', 'S', ' ', ' '}, + 128, /* 128*512 = 64K */ + ' ' + }; + + if (!DosLoadedInHMA) return; + if (HMAclaimed) return; + + + fmemcpy(MK_FP(0xffff,0x0010), &VDISK_BOOT_SEKTOR, sizeof(VDISK_BOOT_SEKTOR)); + + setvec(0x19, MK_FP(0xffff,0x0010)); /* let INT 19 point to VDISK */ + + } + + +int init_call_XMScall( void FAR * driverAddress, UWORD ax, UWORD dx); +void init_call_intr(int intrnr, iregs *rp); + + +/* + after each driver, we try to allocate the HMA. + it might be HIMEM.SYS we just loaded. +*/ + +void ClaimHMA() +{ + void FAR *pXMS; + + if (!DosLoadedInHMA) return; + if (HMAclaimed) return; + + + pXMS = DetectXMSDriver(); + + if (pXMS != NULL) + { + XMSDriverAddress = pXMS; + + if (init_call_XMScall( pXMS, 0x0100, 0xffff)) + { + printf("HMA area successfully claimed\n"); + HMAclaimed = TRUE; + } + } +} +void FAR *DetectXMSDriver() +{ + iregs regs; + + regs.a.x = 0x4300; /* XMS installation check */ + init_call_intr(0x2f, ®s); + + if ((regs.a.x & 0xff) != 0x80) return NULL; + + regs.a.x = 0x4310; /* XMS get driver address */ + init_call_intr(0x2f, ®s); + + return MK_FP(regs.es, regs.b.x); +} + + +/* + this should be called, after each device driver + has been loaded with FALSE + and on finished CONFIG processing with TRUE. + + will try to grab HMA; + + on finalize, will install a VDISK +*/ + + + +void HMAconfig(int finalize) +{ + ClaimHMA(); + + if (finalize) + InstallVDISK(); +} + +/* + this allocates some bytes from the HMA area + only available if DOS=HIGH was successful +*/ + +VOID FAR *HMAalloc(COUNT bytesToAllocate) +{ + VOID FAR *HMAptr; + + if (!DosLoadedInHMA) return NULL; + + if (HMAFree >= 0xfff0 - bytesToAllocate) return NULL; + + HMAptr = MK_FP(0xffff, HMAFree); + + HMAFree += bytesToAllocate; + + /*printf("HMA allocated %d byte at %x\n", bytesToAllocate, HMAptr); */ + + return HMAptr; +} + From 86e87c91cd9c00ec2f3014289fa6c4942d6c9bf4 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Thu, 22 Mar 2001 04:13:30 +0000 Subject: [PATCH 051/671] Change LF to CR/LF in batch files. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@169 6ac86273-5f31-0410-b378-82cca8765d1b --- bin/install.bat | 3 +++ build.bat | 3 +++ clean.bat | 3 +++ clobber.bat | 3 +++ 4 files changed, 12 insertions(+) diff --git a/bin/install.bat b/bin/install.bat index c000e62e..4a02ac86 100644 --- a/bin/install.bat +++ b/bin/install.bat @@ -4,6 +4,9 @@ rem Create a distribution floppy rem rem $Header$ rem $Log$ +rem Revision 1.3 2001/03/22 04:12:43 bartoldeman +rem Change LF to CR/LF in batch files. +rem rem Revision 1.2 2000/05/11 03:51:37 jimtabor rem Clean up and Release rem diff --git a/build.bat b/build.bat index 8d5f15b5..b249898a 100644 --- a/build.bat +++ b/build.bat @@ -5,6 +5,9 @@ rem batch file to build everything rem $Id$ rem $Log$ +rem Revision 1.4 2001/03/22 04:13:30 bartoldeman +rem Change LF to CR/LF in batch files. +rem rem Revision 1.3 2000/05/25 20:56:19 jimtabor rem Fixed project history rem diff --git a/clean.bat b/clean.bat index ff080229..db83b748 100644 --- a/clean.bat +++ b/clean.bat @@ -5,6 +5,9 @@ rem batch file to clean everything rem $Id$ rem $Log$ +rem Revision 1.4 2001/03/22 04:13:30 bartoldeman +rem Change LF to CR/LF in batch files. +rem rem Revision 1.3 2000/05/25 20:56:19 jimtabor rem Fixed project history rem diff --git a/clobber.bat b/clobber.bat index 600badde..7c436e98 100644 --- a/clobber.bat +++ b/clobber.bat @@ -4,6 +4,9 @@ rem batch file to clobber everything rem $Id$ rem $Log$ +rem Revision 1.4 2001/03/22 04:13:30 bartoldeman +rem Change LF to CR/LF in batch files. +rem rem Revision 1.3 2000/05/25 20:56:19 jimtabor rem Fixed project history rem From 7ff9389c6a4d4f9704947acb885fffc79dfcdbba Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Thu, 22 Mar 2001 04:18:09 +0000 Subject: [PATCH 052/671] Compilation command shortened. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@170 6ac86273-5f31-0410-b378-82cca8765d1b --- sys/sys.mak | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/sys/sys.mak b/sys/sys.mak index 02c6d013..5cabe203 100644 --- a/sys/sys.mak +++ b/sys/sys.mak @@ -4,6 +4,9 @@ # $Id$ # # $Log$ +# Revision 1.5 2001/03/22 04:18:09 bartoldeman +# Compilation command shortened. +# # Revision 1.4 2001/03/21 02:56:26 bartoldeman # See history.txt for changes. Bug fixes and HMA support are the main ones. # @@ -38,8 +41,8 @@ #CFLAGS = -mt -1- -v -vi- -k- -f- -ff- -O -Z -d -I$(INCLUDEPATH);..\hdr \ # -L$(LIBPATH) -DI86;PROTO;DEBUG -CFLAGS = -mt -1- -v -vi- -k- -f- -ff- -O -Z -d -I$(INCLUDEPATH);..\hdr \ - -L$(LIBPATH) -DI86;PROTO -zAHMA -zCHMA_TEXT -zDHMA_TEXT +CFLAGS = -ms -1- -v -vi- -k- -f- -ff- -O -Z -d -I$(INCLUDEPATH);..\hdr \ + -DI86;PROTO -zAHMA -zCHMA_TEXT # *Implicit Rules* .c.obj: From 6b4bb899c8cc311b05c639885f04d5f8901f15a9 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Thu, 22 Mar 2001 04:26:14 +0000 Subject: [PATCH 053/671] dos_gettime() fix by Tom Ehlert. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@171 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/fatfs.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/kernel/fatfs.c b/kernel/fatfs.c index 6242178b..5aeefdbb 100644 --- a/kernel/fatfs.c +++ b/kernel/fatfs.c @@ -36,6 +36,9 @@ BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.11 2001/03/22 04:26:14 bartoldeman + * dos_gettime() fix by Tom Ehlert. + * * Revision 1.10 2001/03/21 02:56:25 bartoldeman * See history.txt for changes. Bug fixes and HMA support are the main ones. * @@ -969,9 +972,7 @@ time dos_gettime() (BYTE FAR *) & Minute, (BYTE FAR *) & Second, (BYTE FAR *) & Hundredth); - h = Second * 10 + ((Hundredth + 5) / 10); - Time = TM_ENCODE(Hour, Minute, h); - return Time; + return TM_ENCODE(Hour, Minute, Second/2); #else return 0; #endif From 390ffb8de67470fe1ed6f59c8b530b35d1b20395 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Thu, 22 Mar 2001 04:55:36 +0000 Subject: [PATCH 054/671] Fix prototypes. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@172 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/config.c | 5 +++-- kernel/proto.h | 8 +++++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/kernel/config.c b/kernel/config.c index ed03bc95..6beb11ab 100644 --- a/kernel/config.c +++ b/kernel/config.c @@ -40,6 +40,9 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.11 2001/03/22 04:55:36 bartoldeman + * Fix prototypes. + * * Revision 1.10 2001/03/21 02:56:25 bartoldeman * See history.txt for changes. Bug fixes and HMA support are the main ones. * @@ -800,8 +803,6 @@ INIT static VOID Dosmem(BYTE * pLine) if (HMAwanted) { - int MoveKernelToHMA(); - HMATextIsAvailable = MoveKernelToHMA(); } } diff --git a/kernel/proto.h b/kernel/proto.h index 5a35a6e3..baeb8964 100644 --- a/kernel/proto.h +++ b/kernel/proto.h @@ -34,6 +34,9 @@ static BYTE *Proto_hRcsId = "$Id$"; /* * $Log$ + * Revision 1.10 2001/03/22 04:55:36 bartoldeman + * Fix prototypes. + * * Revision 1.9 2001/03/21 02:56:26 bartoldeman * See history.txt for changes. Bug fixes and HMA support are the main ones. * @@ -345,6 +348,9 @@ BOOL FcbClose(xfcb FAR * lpXfcb); BOOL FcbFindFirst(xfcb FAR * lpXfcb); BOOL FcbFindNext(xfcb FAR * lpXfcb); +/* inithma.c */ +int MoveKernelToHMA(void); + /* initoem.c */ UWORD init_oem(void); @@ -542,4 +548,4 @@ unsigned long FAR is_dosemu(void); void ConvertName83ToNameSZ(BYTE FAR *destSZ, BYTE FAR *srcFCBName); -VOID FAR *HMAalloc(COUNT bytesToAllocate); \ No newline at end of file +VOID FAR *HMAalloc(COUNT bytesToAllocate); From d63d1765cb90e689604a33703f3c742a5e7039d1 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Thu, 22 Mar 2001 10:51:04 +0000 Subject: [PATCH 055/671] Suggest to extract F_SCOPY into libm.lib for Borland C++. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@173 6ac86273-5f31-0410-b378-82cca8765d1b --- config.m | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/config.m b/config.m index 5f11ece5..b2911b02 100644 --- a/config.m +++ b/config.m @@ -33,8 +33,8 @@ #LIBPATH=$(COMPILERPATH)\lib #CLIB=$(COMPILERPATH)\lib\cs.lib #INCLUDEPATH=$(COMPILERPATH)\include -#MATH_EXTRACT=*H_LDIV *H_LLSH *H_LURSH *N_LXMUL *F_LXMUL *H_LRSH *H_SPUSH *N_SCOPY -#MATH_INSERT=+H_LDIV +H_LLSH +H_LURSH +N_LXMUL +F_LXMUL +H_LRSH +H_SPUSH +N_SCOPY +#MATH_EXTRACT=*H_LDIV *H_LLSH *H_LURSH *N_LXMUL *F_LXMUL *H_LRSH *H_SPUSH *N_SCOPY *F_SCOPY +#MATH_INSERT=+H_LDIV +H_LLSH +H_LURSH +N_LXMUL +F_LXMUL +H_LRSH +H_SPUSH +N_SCOPY +F_SCOPY # Use these for Borland C++ @@ -46,14 +46,17 @@ #LIBPATH=$(COMPILERPATH)\lib #CLIB=$(COMPILERPATH)\lib\cs.lib #INCLUDEPATH=$(COMPILERPATH)\include -#MATH_EXTRACT=*H_LDIV *H_LLSH *H_LURSH *N_LXMUL *F_LXMUL *H_LRSH *H_SPUSH *N_SCOPY -#MATH_INSERT=+H_LDIV +H_LLSH +H_LURSH +N_LXMUL +F_LXMUL +H_LRSH +H_SPUSH +N_SCOPY +#MATH_EXTRACT=*H_LDIV *H_LLSH *H_LURSH *N_LXMUL *F_LXMUL *H_LRSH *H_SPUSH *N_SCOPY *F_SCOPY +#MATH_INSERT=+H_LDIV +H_LLSH +H_LURSH +N_LXMUL +F_LXMUL +H_LRSH +H_SPUSH +N_SCOPY +F_SCOPY # # $Id$ # # $Log$ +# Revision 1.5 2001/03/22 10:51:04 bartoldeman +# Suggest to extract F_SCOPY into libm.lib for Borland C++. +# # Revision 1.4 2001/03/19 04:50:56 bartoldeman # See history.txt for overview: put kernel 2022beo1 into CVS # From 729114cf001774f98334cb40bbf26280d1740d27 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Thu, 22 Mar 2001 20:46:46 +0000 Subject: [PATCH 056/671] cli/sti corrections (Bart) and int25, 26 stack corrections (Tom) git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@174 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/apisupt.asm | 15 +++++++-------- kernel/entry.asm | 24 ++++++++++++++---------- 2 files changed, 21 insertions(+), 18 deletions(-) diff --git a/kernel/apisupt.asm b/kernel/apisupt.asm index fe39ebc1..c3cf50bc 100644 --- a/kernel/apisupt.asm +++ b/kernel/apisupt.asm @@ -27,6 +27,9 @@ ; $Id$ ; ; $Log$ +; Revision 1.5 2001/03/22 20:46:46 bartoldeman +; cli/sti corrections (Bart) and int25, 26 stack corrections (Tom) +; ; Revision 1.4 2001/03/21 02:56:25 bartoldeman ; See history.txt for changes. Bug fixes and HMA support are the main ones. ; @@ -85,7 +88,7 @@ segment HMA_TEXT global _set_stack ; -; void far set_stack(void) - +; void set_stack(void) - ; save current stack and setup our local stack ; _set_stack: @@ -95,7 +98,6 @@ _set_stack: ; we need to get the return values from the stack ; since the current stack will change pop ax ;get return offset - pop bx ;get return segment ; Save the flags so that we can restore correct interrupt ; state later. We need to disable interrupts so that we @@ -125,17 +127,16 @@ _set_stack: add bp, cx ; setup for ret - push bx push ax ; now restore interrupt state push dx popf - retf + ret ; -; void far restore_stack(void) - +; void restore_stack(void) - ; restore foreground stack, throw ours away ; global _restore_stack @@ -144,7 +145,6 @@ _restore_stack: ; we need to get the return values from the stack ; since the current stack will change pop cx ;get return offset - pop bx ;get return segment ; Save the flags so that we can restore correct interrupt ; state later. We need to disable interrupts so that we @@ -169,11 +169,10 @@ _restore_stack: ;mov bp,sp ; setup for ret - push bx push cx ; now restore interrupt state push dx popf - retf + ret diff --git a/kernel/entry.asm b/kernel/entry.asm index 78f8ed1a..5577152c 100644 --- a/kernel/entry.asm +++ b/kernel/entry.asm @@ -28,6 +28,9 @@ ; $Id$ ; ; $Log$ +; Revision 1.5 2001/03/22 20:46:46 bartoldeman +; cli/sti corrections (Bart) and int25, 26 stack corrections (Tom) +; ; Revision 1.4 2001/03/21 02:56:25 bartoldeman ; See history.txt for changes. Bug fixes and HMA support are the main ones. ; @@ -79,7 +82,7 @@ segment HMA_TEXT extern _int21_syscall:wrt HGROUP extern _int25_handler:wrt HGROUP extern _int26_handler:wrt HGROUP - extern _set_stack:wrt HMA_TEXT + extern _set_stack:wrt HGROUP extern _restore_stack:wrt HGROUP extern _error_tos:wrt DGROUP extern _char_api_tos:wrt DGROUP @@ -260,21 +263,22 @@ int21_reentry: cmp ah,62h jne int21_1 -int21_user: push word [_user_r+2] +int21_user: sti + push word [_user_r+2] push word [_user_r] call _int21_syscall pop cx pop cx jmp int21_ret -int21_1: sti +int21_1: cli cmp byte [_ErrorMode],0 je int21_2 mov bp,ds mov ss,bp mov bp,_error_tos mov sp,bp - cli + sti push word [_user_r+2] push word [_user_r] call _int21_syscall @@ -293,7 +297,7 @@ int21_2: inc byte [_InDOS] mov ss,bp mov bp,_char_api_tos mov sp,bp - cli + sti push word [_user_r+2] push word [_user_r] call _int21_syscall @@ -306,7 +310,7 @@ int21_3: mov ss,bp mov bp,_disk_api_tos mov sp,bp - cli + sti ; ; Push the far pointer to the register frame for ; int21_syscall and remainder of kernel. @@ -395,14 +399,14 @@ reloc_call_low_int25_handler: mov word [_api_sp], _disk_api_tos mov word [_api_ss], ds - call far _set_stack + call _set_stack push word [cs:stkframe+2] push word [cs:stkframe] call _int25_handler add sp, byte 4 - call far _restore_stack + call _restore_stack pop es pop ds @@ -444,14 +448,14 @@ reloc_call_low_int26_handler: mov word [_api_sp], _disk_api_tos mov word [_api_ss], ds - call far _set_stack + call _set_stack push word [cs:stkframe+2] push word [cs:stkframe] call _int26_handler add sp, 4 - call far _restore_stack + call _restore_stack pop es pop ds From bf042f7face14dd4687f8cf0c96e77cb684faf01 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sat, 24 Mar 2001 22:00:37 +0000 Subject: [PATCH 057/671] Converted LF to CR/LF in config.b and config.sys. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@175 6ac86273-5f31-0410-b378-82cca8765d1b From 851eb99b631b21d06bcab84b3c543c48e94f67ba Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sat, 24 Mar 2001 22:13:05 +0000 Subject: [PATCH 058/671] See history.txt: dsk.c changes, warning removal and int21 entry handling. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@176 6ac86273-5f31-0410-b378-82cca8765d1b --- docs/history.txt | 7 + kernel/dsk.c | 391 +++++++++++++++++++++++++++++--------------- kernel/entry.asm | 152 +++++++++-------- kernel/fatfs.c | 7 +- kernel/procsupt.asm | 21 ++- 5 files changed, 369 insertions(+), 209 deletions(-) diff --git a/docs/history.txt b/docs/history.txt index e82fd1cd..753b7bc3 100644 --- a/docs/history.txt +++ b/docs/history.txt @@ -1,3 +1,10 @@ +2001 Mar 24 - Build 2022 +-------- Bart Oldeman (bart.oldeman@bristol.ac.uk) ++ Fixes Tom and Bart: cli/sti handling and other fixes in entry.asm, + procsupt.asm and apisupt.asm. + Bart: warning removal + other compile time fixes. + Tom: * more partition detection fixes in dsk.c. + * dos_gettime() fix. 2001 Mar 21 - Build 2022 -------- Bart Oldeman (bart.oldeman@bristol.ac.uk) + Clean A lot of space savings by Tom Ehlert, merely because Turbo C 2.01 does not diff --git a/kernel/dsk.c b/kernel/dsk.c index d146ec3b..0dfe49f8 100644 --- a/kernel/dsk.c +++ b/kernel/dsk.c @@ -33,6 +33,9 @@ static BYTE *dskRcsId = "$Id$"; /* * $Log$ + * Revision 1.12 2001/03/24 22:13:05 bartoldeman + * See history.txt: dsk.c changes, warning removal and int21 entry handling. + * * Revision 1.11 2001/03/21 02:56:25 bartoldeman * See history.txt for changes. Bug fixes and HMA support are the main ones. * @@ -251,7 +254,7 @@ WORD _dsk_init(rqptr), blk_error(rqptr); COUNT ltop(WORD *, WORD *, WORD *, COUNT, COUNT, ULONG, byteptr); WORD dskerr(COUNT); -COUNT processtable(int table_type,COUNT ptDrive, BYTE ptHead, UWORD ptCylinder, BYTE ptSector, LONG ptAccuOff); +COUNT processtable(int table_type,COUNT ptDrive, BYTE ptHead, UWORD ptCylinder, BYTE ptSector, LONG ptAccuOff, UWORD PartitionDone); #else WORD _dsk_init(), mediachk(), @@ -312,6 +315,7 @@ static WORD(*dispatch[NENTRY]) () = #define SIZEOF_PARTENT 16 #define PRIMARY 0x01 +#define PRIMARY2 0x02 #define FAT12 0x01 #define FAT16SMALL 0x04 @@ -333,6 +337,7 @@ ULONG StartSector(WORD ptDrive, unsigned BeginCylinder, unsigned cylinders,heads,sectors; ULONG startPos; + ULONG oldStartPos; regs.a.x = 0x0800; /* get drive parameters */ regs.d.x = ptDrive; @@ -354,15 +359,113 @@ ULONG StartSector(WORD ptDrive, unsigned BeginCylinder, BeginCylinder, BeginHead, BeginSector, BeginCylinder, BeginHead, BeginSector, startPos, startPos)); + + + oldStartPos = peStartSector + ptAccuOff; + + PartCodePrintf(("oldStartPos = %lx - ", oldStartPos)); + + + if (startPos != oldStartPos) + { + printf("PART TABLE mismatch for drive %x, CHS=%d %d %d, startsec %d, offset %ld\n", + ptDrive, BeginCylinder, BeginHead,BeginSector, + peStartSector, ptAccuOff); + + printf(" old startpos = %ld, new startpos = %ld, using new\n", + oldStartPos, startPos); + } return startPos; } - +/* + thats what MSDN says: + + How Windows 2000 Assigns, Reserves, and Stores Drive Letters + ID: q234048 + + BASIC Disk - Drive Letter Assignment Rules +The following are the basic disk drive letter assignment rules for Windows 2000: +Scan all fixed hard disks as they are enumerated, assign drive letters +starting with any active primary partitions (if there is one), otherwise, +scan the first primary partition on each drive. Assign next available +letter starting with C: + + +Repeat scan for all fixed hard disks and removable (JAZ, MO) disks +and assign drive letters to all logical drives in an extended partition, +or the removable disk(s) as enumerated. Assign next available letter +starting with C: + + +Finally, repeat scan for all fixed hard disk drives, and assign drive +letters to all remaining primary partitions. Assign next available letter +starting with C: + +Floppy drives. Assign letter starting with A: + +CD-ROM drives. Assign next available letter starting with D: + +************************************************************************* +Order in Which MS-DOS and Windows Assign Drive Letters +ID: q51978 + +MORE INFORMATION +The following occurs at startup: + +MS-DOS checks all installed disk devices, assigning the drive letter A +to the first physical floppy disk drive that is found. + +If a second physical floppy disk drive is present, it is assigned drive letter B. If it is not present, a logical drive B is created that uses the first physical floppy disk drive. + + +Regardless of whether a second floppy disk drive is present, +MS-DOS then assigns the drive letter C to the primary MS-DOS +partition on the first physical hard disk, and then goes on +to check for a second hard disk. + + +If a second physical hard disk is found, and a primary partition exists +on the second physical drive, the primary MS-DOS partition on the second +physical hard drive is assigned the letter D. MS-DOS version 5.0, which +supports up to eight physical drives, will continue to search for more +physical hard disk drives at this point. For example, if a third physical +hard disk is found, and a primary partition exists on the third physical +drive, the primary MS-DOS partition on the third physical hard drive is +assigned the letter E. +MS-DOS returns to the first physical hard disk drive and assigns drive +letters to any additional logical drives (in extended MS-DOS partitions) +on that drive in sequence. + + +MS-DOS repeats this process for the second physical hard disk drive, +if present. MS-DOS 5.0 will repeat this process for up to eight physical +hard drives, if present. After all logical drives (in extended MS-DOS +partitions) have been assigned drive letters, MS-DOS 5.0 returns to +the first physical drive and assigns drive letters to any other primary +MS-DOS partitions that exist, then searches other physical drives for +additional primary MS-DOS partitions. This support for multiple primary +MS-DOS partitions was added to version 5.0 for backward compatibility +with the previous OEM MS-DOS versions that support multiple primary partitions. + + +After all logical drives on the hard disk(s) have been assigned drive +letters, drive letters are assigned to drives installed using DRIVER.SYS +or created using RAMDRIVE.SYS in the order in which the drivers are loaded +in the CONFIG.SYS file. Which drive letters are assigned to which devices +can be influenced by changing the order of the device drivers or, if necessary, +by creating "dummy" drive letters with DRIVER.SYS. + +******************************************************** + +I don't know, if I did it right, but I tried to do it that way. TE + +*/ COUNT processtable(int table_type,COUNT ptDrive, BYTE ptHead, UWORD ptCylinder, - BYTE ptSector, LONG ptAccuOff) + BYTE ptSector, LONG ptAccuOff, UWORD PartitionDone ) { struct /* Temporary partition table */ { @@ -383,162 +486,177 @@ COUNT processtable(int table_type,COUNT ptDrive, BYTE ptHead, UWORD ptCylinder, int retry; UBYTE packed_byte, pb1; -/* COUNT Part; */ BYTE *p; int partition_chain = 0; int ret; ULONG newStartPos; + UWORD partMask; + int loop; restart: /* yes, it's a GOTO >:-) */ /* if someone has a circular linked extended partition list, stop it sooner or later */ if (partition_chain > 64) - return TRUE; + return PartitionDone; PartCodePrintf(("searching partition table at %x %x %x %x %lx\n", ptDrive, ptCylinder, ptHead, ptSector, ptAccuOff)); - /* Read partition table */ - for ( retry = N_RETRY; --retry >= 0; ) - { + /* Read partition table */ + for ( retry = N_RETRY; --retry >= 0; ) + { ret = fl_read((WORD) ptDrive, (WORD) ptHead, (WORD) ptCylinder, (WORD) ptSector, (WORD) 1, (byteptr) & buffer); if (ret == 0) break; - } - if (ret != 0) - return FALSE; + } + if (ret != 0) + return PartitionDone; /* Read each partition into temporary array */ - p = (BYTE *) & buffer.bytes[PARTOFF]; + p = (BYTE *) & buffer.bytes[PARTOFF]; - for (ptemp_part = &temp_part[0]; + for (ptemp_part = &temp_part[0]; ptemp_part < &temp_part[N_PART]; ptemp_part++) - { + { - getbyte((VOID *) (p+0), &ptemp_part->peBootable); - getbyte((VOID *) (p+1), &ptemp_part->peBeginHead); - getbyte((VOID *) (p+2), &packed_byte); - ptemp_part->peBeginSector = packed_byte & 0x3f; - getbyte((VOID *) (p+3), &pb1); - ptemp_part->peBeginCylinder = pb1 + ((UWORD) (0xc0 & packed_byte) << 2); - getbyte((VOID *) (p+4), &ptemp_part->peFileSystem); - getbyte((VOID *) (p+5), &ptemp_part->peEndHead); - getbyte((VOID *) (p+6), &packed_byte); - ptemp_part->peEndSector = packed_byte & 0x3f; - getbyte((VOID *) (p+7), &pb1); - ptemp_part->peEndCylinder = pb1 + ((UWORD) (0xc0 & packed_byte) << 2); - getlong((VOID *) (p+8), &ptemp_part->peStartSector); - getlong((VOID *) (p+12), &ptemp_part->peSectors); - - p += SIZEOF_PARTENT; /* == 16 */ - } + getbyte((VOID *) (p+0), &ptemp_part->peBootable); + getbyte((VOID *) (p+1), &ptemp_part->peBeginHead); + getbyte((VOID *) (p+2), &packed_byte); + ptemp_part->peBeginSector = packed_byte & 0x3f; + getbyte((VOID *) (p+3), &pb1); + ptemp_part->peBeginCylinder = pb1 + ((UWORD) (0xc0 & packed_byte) << 2); + getbyte((VOID *) (p+4), &ptemp_part->peFileSystem); + getbyte((VOID *) (p+5), &ptemp_part->peEndHead); + getbyte((VOID *) (p+6), &packed_byte); + ptemp_part->peEndSector = packed_byte & 0x3f; + getbyte((VOID *) (p+7), &pb1); + ptemp_part->peEndCylinder = pb1 + ((UWORD) (0xc0 & packed_byte) << 2); + getlong((VOID *) (p+8), &ptemp_part->peStartSector); + getlong((VOID *) (p+12), &ptemp_part->peSectors); + + p += SIZEOF_PARTENT; /* == 16 */ + } /* Walk through the table, add DOS partitions to global array and process extended partitions */ /* when searching the EXT chain, must skip primary partitions */ - if ( (table_type==PRIMARY) || - ( (table_type==EXTENDED) && (partition_chain!=0) ) ) - { - - for (ptemp_part = &temp_part[0]; - ptemp_part < &temp_part[N_PART] && nUnits < NDEV; ptemp_part++) - { - - if ( ptemp_part->peFileSystem == FAT12 || - ptemp_part->peFileSystem == FAT16SMALL || - ptemp_part->peFileSystem == FAT16LARGE ) - { - struct dos_partitionS *pdos_partition; - - struct media_info *pmiarray = getPMiarray(nUnits); - - pmiarray->mi_offset = ptemp_part->peStartSector + ptAccuOff; - - PartCodePrintf(("mioffset1 = %lx - ", pmiarray->mi_offset)); - pmiarray->mi_drive = ptDrive; - pmiarray->mi_partidx = nPartitions; - - newStartPos = StartSector(ptDrive, - ptemp_part->peBeginCylinder, - ptemp_part->peBeginHead, - ptemp_part->peBeginSector, - ptemp_part->peStartSector, - ptAccuOff); - - if (newStartPos != pmiarray->mi_offset) - { - printf("PART TABLE mismatch for drive %x, CHS=%d %d %d, startsec %d, offset %ld\n", - ptDrive, - ptemp_part->peBeginCylinder, ptemp_part->peBeginHead,ptemp_part->peBeginSector, - ptemp_part->peStartSector, ptAccuOff); - - printf(" old startpos = %ld, new startpos = %ld, using new\n", - pmiarray->mi_offset, newStartPos); - - pmiarray->mi_offset = newStartPos; - } - - nUnits++; - - pdos_partition = &dos_partition[nPartitions]; - - pdos_partition->peDrive = ptDrive; - pdos_partition->peBootable = ptemp_part->peBootable; - pdos_partition->peBeginHead = ptemp_part->peBeginHead; - pdos_partition->peBeginSector = ptemp_part->peBeginSector; - pdos_partition->peBeginCylinder=ptemp_part->peBeginCylinder; - pdos_partition->peFileSystem =ptemp_part->peFileSystem; - pdos_partition->peEndHead =ptemp_part->peEndHead; - pdos_partition->peEndSector =ptemp_part->peEndSector; - pdos_partition->peEndCylinder =ptemp_part->peEndCylinder; - pdos_partition->peStartSector =ptemp_part->peStartSector; - pdos_partition->peSectors =ptemp_part->peSectors; - pdos_partition->peAbsStart =ptemp_part->peStartSector + ptAccuOff; + if ( table_type==PRIMARY || + table_type==PRIMARY2 || + partition_chain!=0 ) + { + /* do this for + 0) all active partitions + 1) the first primary partition + */ + for (loop = 0; loop < 2; loop++) + { + for (ptemp_part = &temp_part[0], partMask = 1; + ptemp_part < &temp_part[N_PART] && nUnits < NDEV; + partMask <<= 1,ptemp_part++) + { + + + if (loop == 0 && /* scan for only for active */ + !ptemp_part->peBootable) + { + continue; + } + + if (PartitionDone & partMask) /* don't reassign partitions */ + { + continue; + } - PartCodePrintf(("DOS PARTITION drive %x CHS %x-%x-%x %x-%x-%x %lx %lx %lx FS %x\n", - pdos_partition->peDrive, - pdos_partition->peBeginCylinder,pdos_partition->peBeginHead ,pdos_partition->peBeginSector , - pdos_partition->peEndCylinder ,pdos_partition->peEndHead ,pdos_partition->peEndSector , - pdos_partition->peStartSector , - pdos_partition->peSectors , - pdos_partition->peAbsStart , - pdos_partition->peFileSystem - )); - - nPartitions++; - } - } - } + if ( ptemp_part->peFileSystem == FAT12 || + ptemp_part->peFileSystem == FAT16SMALL || + ptemp_part->peFileSystem == FAT16LARGE ) + { + struct dos_partitionS *pdos_partition; + + struct media_info *pmiarray = getPMiarray(nUnits); + + pmiarray->mi_drive = ptDrive; + pmiarray->mi_partidx = nPartitions; + + pmiarray->mi_offset = StartSector(ptDrive, + ptemp_part->peBeginCylinder, + ptemp_part->peBeginHead, + ptemp_part->peBeginSector, + ptemp_part->peStartSector, + ptAccuOff); + + nUnits++; + + pdos_partition = &dos_partition[nPartitions]; + + pdos_partition->peDrive = ptDrive; + pdos_partition->peBootable = ptemp_part->peBootable; + pdos_partition->peBeginHead = ptemp_part->peBeginHead; + pdos_partition->peBeginSector = ptemp_part->peBeginSector; + pdos_partition->peBeginCylinder=ptemp_part->peBeginCylinder; + pdos_partition->peFileSystem =ptemp_part->peFileSystem; + pdos_partition->peEndHead =ptemp_part->peEndHead; + pdos_partition->peEndSector =ptemp_part->peEndSector; + pdos_partition->peEndCylinder =ptemp_part->peEndCylinder; + pdos_partition->peStartSector =ptemp_part->peStartSector; + pdos_partition->peSectors =ptemp_part->peSectors; + pdos_partition->peAbsStart =ptemp_part->peStartSector + ptAccuOff; + + PartCodePrintf(("DOS PARTITION drive %x CHS %x-%x-%x %x-%x-%x %lx %lx %lx FS %x\n", + pdos_partition->peDrive, + pdos_partition->peBeginCylinder,pdos_partition->peBeginHead ,pdos_partition->peBeginSector , + pdos_partition->peEndCylinder ,pdos_partition->peEndHead ,pdos_partition->peEndSector , + pdos_partition->peStartSector , + pdos_partition->peSectors , + pdos_partition->peAbsStart , + pdos_partition->peFileSystem + )); + + nPartitions++; + + PartitionDone |= partMask; + + if ( table_type==PRIMARY ) + { + return PartitionDone; /* we are done */ + } + + } /* end FAT16 detected */ + } /* end PArtitionentry 0..3 */ + } /* end of loop 0..1 for active, nonactive */ + } /* if ( table_type==PRIMARY ) */ - /* search for EXT partitions only on 2. run */ - if (table_type==EXTENDED) - { - for (ptemp_part = &temp_part[0]; + /* search for EXT partitions only on 2. run */ + if (table_type==EXTENDED) + { + for (ptemp_part = &temp_part[0]; ptemp_part < &temp_part[N_PART] && nUnits < NDEV; ptemp_part++) - { - if ( (ptemp_part->peFileSystem == EXTENDED || - ptemp_part->peFileSystem == EXTENDED_INT32 ) ) { - /* restart with new extended part table, don't recurs */ - partition_chain++; - - ptHead = ptemp_part->peBeginHead; - ptCylinder = ptemp_part->peBeginCylinder; - ptSector = ptemp_part->peBeginSector; - ptAccuOff = ptemp_part->peStartSector + ptAccuOff; - - goto restart; - } - } - } + if ( (ptemp_part->peFileSystem == EXTENDED || + ptemp_part->peFileSystem == EXTENDED_INT32 ) ) + { + /* restart with new extended part table, don't recurs */ + partition_chain++; + + ptHead = ptemp_part->peBeginHead; + ptCylinder = ptemp_part->peBeginCylinder; + ptSector = ptemp_part->peBeginSector; + ptAccuOff = ptemp_part->peStartSector + ptAccuOff; + + PartitionDone = 0; /* not important for EXTENDED */ + + goto restart; + } + } + } - return TRUE; + return PartitionDone; } COUNT FAR init_call_blk_driver(rqptr rp) @@ -561,6 +679,7 @@ WORD _dsk_init(rqptr rp) Unit; struct media_info *pmiarray; bpb *pbpbarray; + UBYTE foundPartitions[16]; /* Reset the drives */ @@ -600,31 +719,37 @@ WORD _dsk_init(rqptr rp) } nHardDisk = fl_nrdrives(); + + nHardDisk = min(nHardDisk,sizeof(foundPartitions)); - /* as rather well documented, DOS searches 1st) all primary patitions on + /* as rather well documented, DOS searches 1st) 1 primary patitions on all drives, 2nd) all extended partitions. that makes many people (including me) unhappy, as all DRIVES D:,E:... on 1st disk will move up/down, if other disk with primary partitions are added/removed, but thats the way it is (hope I got it right) - TE (with a little help from my friends) */ + TE (with a little help from my friends) + see also above for WIN2000,DOS,MSDN */ PartCodePrintf(("DSK init: found %d disk drives\n",nHardDisk)); + /* Process primary partition table 1 partition only */ for (HardDrive = 0; HardDrive < nHardDisk; HardDrive++) { - /* Process primary partition table */ - if (!processtable(PRIMARY, (HardDrive | 0x80), 0, 0l, 1, 0l)) - /* Exit if no hard drive */ - break; + foundPartitions[HardDrive] = + processtable(PRIMARY, (HardDrive | 0x80), 0, 0l, 1, 0l,0); } + /* Process extended partition table */ for (HardDrive = 0; HardDrive < nHardDisk; HardDrive++) { - /* Process extended partition table */ - if (!processtable(EXTENDED, (HardDrive | 0x80), 0, 0l, 1, 0l)) - /* Exit if no hard drive */ - break; + processtable(EXTENDED, (HardDrive | 0x80), 0, 0l, 1, 0l,0); + } + + /* Process primary a 2nd time */ + for (HardDrive = 0; HardDrive < nHardDisk; HardDrive++) + { + processtable(PRIMARY, (HardDrive | 0x80), 0, 0l, 1, 0l,foundPartitions[HardDrive]); } rp->r_nunits = nUnits; diff --git a/kernel/entry.asm b/kernel/entry.asm index 5577152c..e5495cbd 100644 --- a/kernel/entry.asm +++ b/kernel/entry.asm @@ -28,8 +28,8 @@ ; $Id$ ; ; $Log$ -; Revision 1.5 2001/03/22 20:46:46 bartoldeman -; cli/sti corrections (Bart) and int25, 26 stack corrections (Tom) +; Revision 1.6 2001/03/24 22:13:05 bartoldeman +; See history.txt: dsk.c changes, warning removal and int21 entry handling. ; ; Revision 1.4 2001/03/21 02:56:25 bartoldeman ; See history.txt for changes. Bug fixes and HMA support are the main ones. @@ -80,6 +80,7 @@ segment HMA_TEXT extern _int21_syscall:wrt HGROUP + extern _int21_service:wrt HGROUP extern _int25_handler:wrt HGROUP extern _int26_handler:wrt HGROUP extern _set_stack:wrt HGROUP @@ -218,6 +219,7 @@ reloc_call_int21_handler: ; NB: stack frame is MS-DOS dependent and not compatible ; with compiler interrupt stack frames. ; + sti PUSH$ALL ; @@ -226,18 +228,51 @@ reloc_call_int21_handler: ; NB: At this point, SS != DS and won't be set that way ; until later when which stack to run on is determined. ; - mov bp,DGROUP - mov ds,bp + mov dx,DGROUP + mov ds,dx + +int21_reentry: + cmp ah,33h + je int21_user + cmp ah,50h + je int21_user + cmp ah,51h + je int21_user + cmp ah,62h + jne int21_1 + +int21_user: + mov bp,sp + push ss + push bp + call _int21_syscall + pop cx + pop cx + jmp int21_ret + +; +; normal entry, use one of our 4 stacks +; +; DX=DGROUP +; CX=STACK +; AX=userSS +; BX=userSP + + +int21_1: + mov ax,ss ; save user stack, to be retored later + mov bx,sp + ; - ; Now DS is set, let's save our stack for rentry + ; Now DS is set, let's save our stack for rentry (???TE) ; - mov bp,ss - mov word [_lpUserStack+2],bp - mov word [_user_r+2],bp - mov bp,sp - mov word [_lpUserStack],bp ; store and init - mov word [_user_r],bp ; store and init + ; I don't know who needs that, but ... (TE) + ; + mov word [_lpUserStack+2],ss + mov word [_user_r+2],ss + mov word [_lpUserStack],sp ; store and init + mov word [_user_r],sp ; store and init ; ; Decide which stack to run on. @@ -253,82 +288,69 @@ reloc_call_int21_handler: ; call number. Finally, all others run on the disk stack. ; They are evaluated in that order. -int21_reentry: - cmp ah,33h - je int21_user - cmp ah,50h - je int21_user - cmp ah,51h - je int21_user - cmp ah,62h - jne int21_1 -int21_user: sti - push word [_user_r+2] - push word [_user_r] - call _int21_syscall - pop cx - pop cx - jmp int21_ret + cmp byte [_InDOS],0 + jne int21_onerrorstack -int21_1: cli cmp byte [_ErrorMode],0 je int21_2 - mov bp,ds - mov ss,bp - mov bp,_error_tos - mov sp,bp + +int21_onerrorstack: + mov cx,_error_tos + + + cli + mov ss,dx + mov sp,cx sti - push word [_user_r+2] - push word [_user_r] - call _int21_syscall - jmp short int21_exit + + push ax ; user SS:SP + push bx + + call _int21_service + jmp short int21_exit_nodec + int21_2: inc byte [_InDOS] cmp ah,0ch - jg int21_3 -; -; Make FreeDOS better than the others! -; - cmp byte [_dosidle_flag],0 - jne int21_user - - mov bp,ds - mov ss,bp - mov bp,_char_api_tos - mov sp,bp - sti - push word [_user_r+2] - push word [_user_r] - call _int21_syscall - jmp short int21_exit + mov cx,_char_api_tos + jle int21_normalentry int21_3: call dos_crit_sect + mov cx,_disk_api_tos - mov bp,ds - mov ss,bp - mov bp,_disk_api_tos - mov sp,bp +int21_normalentry: + + cli + mov ss,dx + mov sp,cx sti + ; ; Push the far pointer to the register frame for ; int21_syscall and remainder of kernel. ; - push word [_user_r+2] - push word [_user_r] - call _int21_syscall + + push ax ; user SS:SP + push bx + call _int21_service + +int21_exit: dec byte [_InDOS] ; ; Recover registers from system call. Registers and flags ; were modified by the system call. ; -int21_exit: cli - mov bp,word [_user_r+2] - mov ss,bp - mov bp,word [_user_r] ; store and init - mov sp,bp - dec byte [_InDOS] + + +int21_exit_nodec: + pop bx ; get back user stack + pop ax + + cli + mov ss,ax + mov sp,bx sti int21_ret: POP$ALL diff --git a/kernel/fatfs.c b/kernel/fatfs.c index 5aeefdbb..c3766e4d 100644 --- a/kernel/fatfs.c +++ b/kernel/fatfs.c @@ -36,6 +36,9 @@ BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.12 2001/03/24 22:13:05 bartoldeman + * See history.txt: dsk.c changes, warning removal and int21 entry handling. + * * Revision 1.11 2001/03/22 04:26:14 bartoldeman * dos_gettime() fix by Tom Ehlert. * @@ -216,7 +219,7 @@ static void merge_file_changes(struct f_node FAR *fnp, int collect); /* /// Added - Ron Cemer */ static int is_same_file(struct f_node FAR *fnp1, struct f_node FAR *fnp2); /* /// Added - Ron Cemer */ -static int copy_file_changes(struct f_node FAR *src, struct f_node FAR *dst); +static void copy_file_changes(struct f_node FAR *src, struct f_node FAR *dst); date dos_getdate(VOID); time dos_gettime(VOID); BOOL find_free(struct f_node FAR *); @@ -507,7 +510,7 @@ static int is_same_file(struct f_node FAR *fnp1, struct f_node FAR *fnp2) { } /* /// Added - Ron Cemer */ -static int copy_file_changes(struct f_node FAR *src, struct f_node FAR *dst) { +static void copy_file_changes(struct f_node FAR *src, struct f_node FAR *dst) { dst->f_highwater = src->f_highwater; dst->f_dir.dir_start = src->f_dir.dir_start; dst->f_dir.dir_size = src->f_dir.dir_size; diff --git a/kernel/procsupt.asm b/kernel/procsupt.asm index 043ebacb..e3cd1989 100644 --- a/kernel/procsupt.asm +++ b/kernel/procsupt.asm @@ -30,6 +30,9 @@ ; $Id$ ; ; $Log$ +; Revision 1.5 2001/03/24 22:13:05 bartoldeman +; See history.txt: dsk.c changes, warning removal and int21 entry handling. +; ; Revision 1.4 2001/03/21 02:56:26 bartoldeman ; See history.txt for changes. Bug fixes and HMA support are the main ones. ; @@ -113,18 +116,19 @@ segment _TEXT global _exec_user _exec_user: - PUSH$ALL - mov ds,[_DGROUP_] - mov bp,sp - cld - cli +; PUSH$ALL +; mov ds,[_DGROUP_] +; cld ; ; ; - mov ax,word [bp+irp_low] ; irp (user ss:sp) - mov dx,word [bp+irp_hi] - mov sp,ax ; set-up user stack + mov bp,sp + + mov ax,word [bp+6] ; irp (user ss:sp) + mov dx,word [bp+8] + cli mov ss,dx + mov sp,ax ; set-up user stack sti ; POP$ALL @@ -308,7 +312,6 @@ _spawn_int23: global _init_call_spawn_int23 _init_call_spawn_int23: - int 3 call _spawn_int23 retf ; From 437e4cb1224655ed9c56729ab42da18bcb3b29be Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sun, 25 Mar 2001 04:33:56 +0000 Subject: [PATCH 059/671] Fix compilation of sys.com. Now a proper .com file once again. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@177 6ac86273-5f31-0410-b378-82cca8765d1b --- sys/sys.mak | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/sys/sys.mak b/sys/sys.mak index 5cabe203..d48f4026 100644 --- a/sys/sys.mak +++ b/sys/sys.mak @@ -4,6 +4,9 @@ # $Id$ # # $Log$ +# Revision 1.6 2001/03/25 04:33:56 bartoldeman +# Fix compilation of sys.com. Now a proper .com file once again. +# # Revision 1.5 2001/03/22 04:18:09 bartoldeman # Compilation command shortened. # @@ -39,10 +42,8 @@ !include "..\config.mak" -#CFLAGS = -mt -1- -v -vi- -k- -f- -ff- -O -Z -d -I$(INCLUDEPATH);..\hdr \ -# -L$(LIBPATH) -DI86;PROTO;DEBUG -CFLAGS = -ms -1- -v -vi- -k- -f- -ff- -O -Z -d -I$(INCLUDEPATH);..\hdr \ - -DI86;PROTO -zAHMA -zCHMA_TEXT +CFLAGS = -mt -1- -v -vi- -k- -f- -ff- -O -Z -d -I$(INCLUDEPATH);..\hdr \ + -DI86;PROTO -zAHMA -zCHMA_TEXT -zPDGROUP # *Implicit Rules* .c.obj: @@ -72,8 +73,7 @@ b_fat16.h: ..\boot\b_fat16.bin bin2c.com bin2c ..\boot\b_fat16.bin b_fat16.h b_fat16 sys.com: $(EXE_dependencies) -# $(LINK) /m/t/c $(LIBPATH)\c0t.obj+sys.obj,sys,,\ - $(LINK) /m/c $(LIBPATH)\c0s.obj+sys.obj,sys.com,,\ + $(LINK) /m/t/c $(LIBPATH)\c0t.obj+sys.obj,sys,,\ $(LIBS)+$(CLIB); clobber: clean From 58a5fa4438e75a548f78b4d95f38bd610d533f4d Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sun, 25 Mar 2001 17:11:54 +0000 Subject: [PATCH 060/671] Fixed sys.com compilation. Updated to 2023. Also: see history.txt. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@178 6ac86273-5f31-0410-b378-82cca8765d1b --- docs/history.txt | 8 ++++++++ docs/intfns.txt | 19 +++++++++++-------- hdr/version.h | 4 ++-- kernel/config.c | 48 +++++++++++++++++++++++++++++++++++++++-------- kernel/inthndlr.c | 12 ++++++++++-- kernel/kernel.mak | 5 ++++- kernel/main.c | 5 +++-- sys/sys.c | 13 ++++++++++--- 8 files changed, 88 insertions(+), 26 deletions(-) diff --git a/docs/history.txt b/docs/history.txt index 753b7bc3..120343ea 100644 --- a/docs/history.txt +++ b/docs/history.txt @@ -1,3 +1,11 @@ +2001 Mar 25 - Build 2023 +-------- Bart Oldeman (bart.oldeman@bristol.ac.uk) ++ Fixes sys.com compilation: it is a proper .com and works again. + Suggestions from Martin Stromberg: warning removal and some + debugging related changes. + Suggestion from Aitor Santamaria Merino: implemented NUMLOCK=ON/OFF + in config.sys. Also implemented strcasecmp. + Updated intfns.txt; reported version is now 5.0. 2001 Mar 24 - Build 2022 -------- Bart Oldeman (bart.oldeman@bristol.ac.uk) + Fixes Tom and Bart: cli/sti handling and other fixes in entry.asm, diff --git a/docs/intfns.txt b/docs/intfns.txt index ccc2396d..9b6db7b6 100644 --- a/docs/intfns.txt +++ b/docs/intfns.txt @@ -112,12 +112,12 @@ int 21 Description State Ver Status 5701h Set File Date and Time active 2.00 supported 5800h Get Allocation Strategy active 3.00 supported 5801h Set Allocation Strategy active 3.00 supported -5802h Get Upper-Memory Link active 5.00 planned -5803h Set Upper-Memory Link active 5.00 planned -59h Get Extended Error active 3.00 planned -5ah Create Temporary File active 3.00 -5bh Create New File active 3.00 -5ch Lock/Unlock File active 3.10 planned +5802h Get Upper-Memory Link active 5.00 supported +5803h Set Upper-Memory Link active 5.00 supported +59h Get Extended Error active 3.00 supported +5ah Create Temporary File active 3.00 supported +5bh Create New File active 3.00 supported +5ch Lock/Unlock File active 3.10 supported 5d00h Server Function Call active 3.10 supported 5d01h Commit All Files active 3.10 planned 5d02h Close File by Name active 3.10 planned @@ -142,8 +142,8 @@ int 21 Description State Ver Status 68h Commit File active 3.30 dummy func 69h GET/SET DISK SERIAL NUMBER active 4.00 supported 6ah COMMIT FILE (same as 68h) active 4.00 not supported -6bh NULL FUNCTION active 5.00 not supported -6ch Extended Open/Create active 4.00 supported +6bh NULL FUNCTION active 5.00 supported +6ch Extended Open/Create active 4.00 planned 71h LONG FILENAME FUNCTIONS active 7.00 not supported int 22: Program Termination Address. @@ -195,6 +195,9 @@ See COPYING in DOS-C root directory for license. $Id$ $Log$ +Revision 1.4 2001/03/25 17:11:53 bartoldeman +Fixed sys.com compilation. Updated to 2023. Also: see history.txt. + Revision 1.3 2000/05/09 00:29:50 jimtabor Clean up and Release diff --git a/hdr/version.h b/hdr/version.h index bfa903b4..c8d7865e 100644 --- a/hdr/version.h +++ b/hdr/version.h @@ -42,5 +42,5 @@ static BYTE *date_hRcsId = "$Id$"; #define REVISION_MAJOR 1 #define REVISION_MINOR 1 -#define REVISION_SEQ 22 -#define BUILD 2022 +#define REVISION_SEQ 23 +#define BUILD 2023 diff --git a/kernel/config.c b/kernel/config.c index 6beb11ab..e5b072da 100644 --- a/kernel/config.c +++ b/kernel/config.c @@ -40,6 +40,9 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.12 2001/03/25 17:11:54 bartoldeman + * Fixed sys.com compilation. Updated to 2023. Also: see history.txt. + * * Revision 1.11 2001/03/22 04:55:36 bartoldeman * Fix prototypes. * @@ -195,12 +198,14 @@ INIT VOID Switchar(BYTE * pLine); INIT VOID CfgFailure(BYTE * pLine); INIT VOID Stacks(BYTE * pLine); INIT VOID SetAnyDos(BYTE * pLine); +INIT VOID Numlock(BYTE * pLine); INIT BYTE *GetNumArg(BYTE * pLine, COUNT * pnArg); INIT BYTE *GetStringArg(BYTE * pLine, BYTE * pszString); INIT struct dhdr FAR *linkdev(struct dhdr FAR * dhp); INIT UWORD initdev(struct dhdr FAR * dhp, BYTE FAR * cmdTail); INIT int SkipLine(char *pLine); INIT char *stristr(char *s1, char *s2); +INIT COUNT strcasecmp(REG BYTE *d, REG BYTE *s); INIT BYTE FAR *KernelAlloc(WORD nBytes); @@ -239,6 +244,7 @@ static struct table commands[] = {"FCBS", 1, Fcbs}, {"FILES", 1, Files}, {"LASTDRIVE", 1, Lastdrive}, + {"NUMLOCK", 1, Numlock}, /* rem is never executed by locking out pass */ {"REM", 0, CfgFailure}, {"SHELL", 1, InitPgm}, @@ -585,10 +591,6 @@ INIT VOID DoConfig(VOID) /* Skip leading white space and get verb. */ pLine = scan(pLine, szBuf); - /* Translate the verb to upper case ... */ - for (pTmp = szBuf; *pTmp != '\0'; pTmp++) - *pTmp = toupper(*pTmp); - /* If the line was blank, skip it. Otherwise, look up */ /* the verb and execute the appropriate function. */ if (*szBuf != '\0') @@ -619,7 +621,7 @@ INIT struct table *LookUp(struct table *p, BYTE * token) { while (*(p->entry) != '\0') { - if (strcmp(p->entry, token) == 0) + if (strcasecmp(p->entry, token) == 0) break; else ++p; @@ -936,10 +938,22 @@ INIT static VOID InitPgm(BYTE * pLine) INIT static VOID Break(BYTE * pLine) { /* Format: BREAK = (ON | OFF) */ - BYTE *pTmp; + GetStringArg(pLine, szBuf); + break_ena = strcasecmp(szBuf, "OFF") ? 1 : 0; +} + +INIT static VOID Numlock(BYTE * pLine) +{ + /* Format: NUMLOCK = (ON | OFF) */ + iregs regs; + BYTE FAR *keyflags = (BYTE FAR *)MK_FP(0x40,0x17); GetStringArg(pLine, szBuf); - break_ena = strcmp(szBuf, "OFF") ? 1 : 0; + + *keyflags &= ~32; + *keyflags |= strcasecmp(szBuf, "OFF") ? 32 : 0; + regs.a.b.h = 1; + init_call_intr(0x16, ®s); } INIT static VOID DeviceHigh(BYTE * pLine) @@ -1279,8 +1293,26 @@ char *stristr(char *s1, char *s2) } return NULL; -} +} +/* compare two ASCII strings ignoring case */ +INIT COUNT strcasecmp(REG BYTE *d, REG BYTE *s) +{ + int loop; + + while (*s != '\0' && *d != '\0') + { + + if (toupper(*d) == toupper(*s)) + ++s, ++d; + + else + return toupper(*d) - toupper(*s); + + } + + return toupper(*d) - toupper(*s); +} /* moved from BLOCKIO.C here. diff --git a/kernel/inthndlr.c b/kernel/inthndlr.c index 152803b5..16e54a2c 100644 --- a/kernel/inthndlr.c +++ b/kernel/inthndlr.c @@ -36,6 +36,9 @@ BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.15 2001/03/25 17:11:54 bartoldeman + * Fixed sys.com compilation. Updated to 2023. Also: see history.txt. + * * Revision 1.14 2001/03/21 02:56:26 bartoldeman * See history.txt for changes. Bug fixes and HMA support are the main ones. * @@ -564,7 +567,13 @@ VOID int21_service(iregs FAR * r) r->AL = 0xff; break; - /* CP/M compatibility functions */ + default: +#ifdef DEBUG + printf("Unsupported INT21 AH = 0x%x, AL = 0x%x.\n", r->AH, r->AL); +#endif + /* Fall through. */ + + /* CP/M compatibility functions */ case 0x18: case 0x1d: case 0x1e: @@ -572,7 +581,6 @@ VOID int21_service(iregs FAR * r) #ifndef TSC case 0x61: #endif - default: r->AL = 0; break; diff --git a/kernel/kernel.mak b/kernel/kernel.mak index 5a00a41e..26808d10 100644 --- a/kernel/kernel.mak +++ b/kernel/kernel.mak @@ -5,6 +5,9 @@ # # $Log$ +# Revision 1.7 2001/03/25 17:11:54 bartoldeman +# Fixed sys.com compilation. Updated to 2023. Also: see history.txt. +# # Revision 1.6 2001/03/21 02:56:26 bartoldeman # See history.txt for changes. Bug fixes and HMA support are the main ones. # @@ -125,7 +128,7 @@ INCLUDEPATH = ..\HDR #AFLAGS = /Mx /DSTANDALONE=1 /I..\HDR NASMFLAGS = -i../hdr/ LIBS =..\LIB\DEVICE.LIB ..\LIB\LIBM.LIB -#CFLAGS = -1- -O -Z -d -I..\hdr -I. \ +#ALLCFLAGS = -1- -O -Z -d -I..\hdr -I. \ # -D__STDC__=0;DEBUG;KERNEL;I86;PROTO;ASMSUPT ALLCFLAGS = -1- -O -Z -d -I..\hdr -I. \ -D__STDC__=0;KERNEL;I86;PROTO;ASMSUPT \ diff --git a/kernel/main.c b/kernel/main.c index 079d8ba6..c53f278c 100644 --- a/kernel/main.c +++ b/kernel/main.c @@ -36,11 +36,12 @@ #ifdef VERSION_STRINGS static BYTE *mainRcsId = "$Id$"; #endif -GLOBAL WORD bDumpRegs = FALSE; -GLOBAL WORD bDumpRdWrParms= FALSE; /* * $Log$ + * Revision 1.9 2001/03/25 17:11:54 bartoldeman + * Fixed sys.com compilation. Updated to 2023. Also: see history.txt. + * * Revision 1.8 2001/03/21 02:56:26 bartoldeman * See history.txt for changes. Bug fixes and HMA support are the main ones. * diff --git a/sys/sys.c b/sys/sys.c index d14d060d..7114bc6c 100644 --- a/sys/sys.c +++ b/sys/sys.c @@ -27,9 +27,12 @@ ***************************************************************/ /* $Log$ - * Revision 1.4 2000/08/06 05:50:17 jimtabor - * Add new files and update cvs with patches and changes + * Revision 1.5 2001/03/25 17:11:54 bartoldeman + * Fixed sys.com compilation. Updated to 2023. Also: see history.txt. * +/* Revision 1.4 2000/08/06 05:50:17 jimtabor +/* Add new files and update cvs with patches and changes +/* * Revision 1.3 2000/05/25 20:56:23 jimtabor * Fixed project history * @@ -510,12 +513,14 @@ VOID get_boot(COUNT drive) BOOL check_space(COUNT drive, BYTE * BlkBuffer) { BYTE *bpbp; +#if 0 /* these local variables are never used */ BYTE nfat; UWORD nfsect; ULONG hidden; + UBYTE nreserved; +#endif ULONG count; ULONG block; - UBYTE nreserved; UCOUNT i; WORD track, head, sector; UBYTE buffer[SEC_SIZE]; @@ -523,10 +528,12 @@ BOOL check_space(COUNT drive, BYTE * BlkBuffer) UWORD bpb_nsize; /* get local information */ +#if 0 /* these local variables are never used */ getbyte((VOID *) & BlkBuffer[BT_BPB + BPB_NFAT], &nfat); getword((VOID *) & BlkBuffer[BT_BPB + BPB_NFSECT], &nfsect); getlong((VOID *) & BlkBuffer[BT_BPB + BPB_HIDDEN], &hidden); getbyte((VOID *) & BlkBuffer[BT_BPB + BPB_NRESERVED], &nreserved); +#endif getlong((VOID *) & BlkBuffer[BT_BPB + BPB_HUGE], &bpb_huge); getword((VOID *) & BlkBuffer[BT_BPB + BPB_NSIZE], &bpb_nsize); From d233a1d304ebff6369f00312c356338af839e9c8 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Tue, 27 Mar 2001 02:56:58 +0000 Subject: [PATCH 061/671] Fixed bugs in entry.asm: stack segment and int 2A/82 Ralf Brown compliant. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@179 6ac86273-5f31-0410-b378-82cca8765d1b --- docs/history.txt | 3 +++ kernel/entry.asm | 23 +++++++++++++++-------- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/docs/history.txt b/docs/history.txt index 120343ea..109029cd 100644 --- a/docs/history.txt +++ b/docs/history.txt @@ -1,3 +1,6 @@ +2001 Mar 27 - Build 2023 +-------- Bart Oldeman (bart.oldeman@bristol.ac.uk) ++ Fixes Bug fix release 2023a: fixed stack segment bug in entry.asm. 2001 Mar 25 - Build 2023 -------- Bart Oldeman (bart.oldeman@bristol.ac.uk) + Fixes sys.com compilation: it is a proper .com and works again. diff --git a/kernel/entry.asm b/kernel/entry.asm index e5495cbd..e156ac3e 100644 --- a/kernel/entry.asm +++ b/kernel/entry.asm @@ -28,6 +28,9 @@ ; $Id$ ; ; $Log$ +; Revision 1.7 2001/03/27 02:56:58 bartoldeman +; Fixed bugs in entry.asm: stack segment and int 2A/82 Ralf Brown compliant. +; ; Revision 1.6 2001/03/24 22:13:05 bartoldeman ; See history.txt: dsk.c changes, warning removal and int21 entry handling. ; @@ -219,7 +222,7 @@ reloc_call_int21_handler: ; NB: stack frame is MS-DOS dependent and not compatible ; with compiler interrupt stack frames. ; - sti + sti PUSH$ALL ; @@ -255,12 +258,12 @@ int21_user: ; ; DX=DGROUP ; CX=STACK -; AX=userSS +; SI=userSS ; BX=userSP int21_1: - mov ax,ss ; save user stack, to be retored later + mov si,ss ; save user stack, to be retored later mov bx,sp @@ -304,7 +307,7 @@ int21_onerrorstack: mov sp,cx sti - push ax ; user SS:SP + push si ; user SS:SP push bx call _int21_service @@ -312,9 +315,13 @@ int21_onerrorstack: int21_2: inc byte [_InDOS] + mov cx,_char_api_tos + or ah,ah + jz int21_3 cmp ah,0ch - mov cx,_char_api_tos jle int21_normalentry + cmp ah,59h + je int21_normalentry int21_3: call dos_crit_sect @@ -332,7 +339,7 @@ int21_normalentry: ; int21_syscall and remainder of kernel. ; - push ax ; user SS:SP + push si ; user SS:SP push bx call _int21_service @@ -346,10 +353,10 @@ int21_exit: dec byte [_InDOS] int21_exit_nodec: pop bx ; get back user stack - pop ax + pop si cli - mov ss,ax + mov ss,si mov sp,bx sti int21_ret: POP$ALL From ac1d293d9cd734ee12a015376f857bcb25eefc49 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Tue, 27 Mar 2001 20:27:43 +0000 Subject: [PATCH 062/671] dsk.c (reported by Nagy Daniel), inthndlr and int25/26 fixes by Tom Ehlert. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@180 6ac86273-5f31-0410-b378-82cca8765d1b --- docs/history.txt | 4 ++ kernel/config.c | 10 ++--- kernel/dsk.c | 21 ++++++---- kernel/entry.asm | 103 ++++++++++++++++++---------------------------- kernel/inthndlr.c | 99 +++++++++++++++++--------------------------- kernel/proto.h | 7 +++- 6 files changed, 100 insertions(+), 144 deletions(-) diff --git a/docs/history.txt b/docs/history.txt index 109029cd..c6cdfcd9 100644 --- a/docs/history.txt +++ b/docs/history.txt @@ -1,3 +1,7 @@ +2001 Mar 28 - Build 2023 +-------- Bart Oldeman (bart.oldeman@bristol.ac.uk) ++ Fixes Bug fix release 2023b: dsk.c (reported by Nagy Daniel), inthndlr and + int25/26 fixes by Tom Ehlert. 2001 Mar 27 - Build 2023 -------- Bart Oldeman (bart.oldeman@bristol.ac.uk) + Fixes Bug fix release 2023a: fixed stack segment bug in entry.asm. diff --git a/kernel/config.c b/kernel/config.c index e5b072da..3f39222c 100644 --- a/kernel/config.c +++ b/kernel/config.c @@ -40,6 +40,9 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.13 2001/03/27 20:27:27 bartoldeman + * dsk.c (reported by Nagy Daniel), inthndlr and int25/26 fixes by Tom Ehlert. + * * Revision 1.12 2001/03/25 17:11:54 bartoldeman * Fixed sys.com compilation. Updated to 2023. Also: see history.txt. * @@ -765,10 +768,6 @@ INIT static VOID Lastdrive(BYTE * pLine) UmbState of confidence, 1 is sure, 2 maybe, 4 unknown and 0 no way. */ -#ifdef __TURBOC__ -void __int__(int); /* TC 2.01 requires this. :( -- ror4 */ -#endif -#define int3() __int__(3); INIT static VOID Dosmem(BYTE * pLine) { @@ -782,7 +781,6 @@ INIT static VOID Dosmem(BYTE * pLine) *pTmp = toupper(*pTmp); printf("DOS called with %s\n", szBuf); - int3(); for (pTmp = szBuf ; ; ) { @@ -1006,7 +1004,6 @@ INIT BOOL LoadDevice(BYTE * pLine, COUNT top, COUNT mode) szBuf, dev_seg); #endif - int3(); if (DosExec(3, &eb, szBuf) == SUCCESS) { @@ -1037,7 +1034,6 @@ INIT BOOL LoadDevice(BYTE * pLine, COUNT top, COUNT mode) */ pTmp = pLine; - int3(); if (DosLoadedInHMA) if (stristr(szBuf, "HIMEM.SYS") != NULL) { diff --git a/kernel/dsk.c b/kernel/dsk.c index 0dfe49f8..685a8e05 100644 --- a/kernel/dsk.c +++ b/kernel/dsk.c @@ -33,6 +33,9 @@ static BYTE *dskRcsId = "$Id$"; /* * $Log$ + * Revision 1.13 2001/03/27 20:27:43 bartoldeman + * dsk.c (reported by Nagy Daniel), inthndlr and int25/26 fixes by Tom Ehlert. + * * Revision 1.12 2001/03/24 22:13:05 bartoldeman * See history.txt: dsk.c changes, warning removal and int21 entry handling. * @@ -328,14 +331,14 @@ static WORD(*dispatch[NENTRY]) () = ULONG StartSector(WORD ptDrive, unsigned BeginCylinder, - unsigned BeginSector, unsigned BeginHead, + unsigned BeginSector, ULONG peStartSector, ULONG ptAccuOff) { iregs regs; - unsigned cylinders,heads,sectors; + unsigned heads,sectors; ULONG startPos; ULONG oldStartPos; @@ -489,7 +492,7 @@ COUNT processtable(int table_type,COUNT ptDrive, BYTE ptHead, UWORD ptCylinder, BYTE *p; int partition_chain = 0; int ret; - ULONG newStartPos; +/* ULONG newStartPos;*/ UWORD partMask; int loop; @@ -749,7 +752,7 @@ WORD _dsk_init(rqptr rp) /* Process primary a 2nd time */ for (HardDrive = 0; HardDrive < nHardDisk; HardDrive++) { - processtable(PRIMARY, (HardDrive | 0x80), 0, 0l, 1, 0l,foundPartitions[HardDrive]); + processtable(PRIMARY2, (HardDrive | 0x80), 0, 0l, 1, 0l,foundPartitions[HardDrive]); } rp->r_nunits = nUnits; @@ -801,8 +804,8 @@ STATIC WORD RWzero(rqptr rp, WORD t) { COUNT partidx = miarray[rp->r_unit].mi_partidx; head = dos_partition[partidx].peBeginHead; - sector = dos_partition[partidx].peBeginSector; track = dos_partition[partidx].peBeginCylinder; + sector = dos_partition[partidx].peBeginSector; } else { @@ -877,13 +880,13 @@ static WORD blk_Media(rqptr rp) STATIC WORD bldbpb(rqptr rp) { - ULONG count, i; - byteptr trans; - WORD local_word; + ULONG count/*, i*/; +/* byteptr trans;*/ +/* WORD local_word;*/ /*TE*/ bpb *pbpbarray; struct media_info *pmiarray; - WORD head,track,sector,ret; + WORD head,/*track,*/sector,ret; ret = RWzero( rp, 0); diff --git a/kernel/entry.asm b/kernel/entry.asm index e156ac3e..967bbdce 100644 --- a/kernel/entry.asm +++ b/kernel/entry.asm @@ -28,8 +28,8 @@ ; $Id$ ; ; $Log$ -; Revision 1.7 2001/03/27 02:56:58 bartoldeman -; Fixed bugs in entry.asm: stack segment and int 2A/82 Ralf Brown compliant. +; Revision 1.8 2001/03/27 20:27:43 bartoldeman +; dsk.c (reported by Nagy Daniel), inthndlr and int25/26 fixes by Tom Ehlert. ; ; Revision 1.6 2001/03/24 22:13:05 bartoldeman ; See history.txt: dsk.c changes, warning removal and int21 entry handling. @@ -84,8 +84,7 @@ segment HMA_TEXT extern _int21_syscall:wrt HGROUP extern _int21_service:wrt HGROUP - extern _int25_handler:wrt HGROUP - extern _int26_handler:wrt HGROUP + extern _int2526_handler:wrt HGROUP extern _set_stack:wrt HGROUP extern _restore_stack:wrt HGROUP extern _error_tos:wrt DGROUP @@ -399,15 +398,20 @@ reloc_call_int27_handler: jmp reloc_call_int21_handler ; terminate through int 21h ; -; I really do need to get rid of this because it's the only thing stopping -; us from being ROMABLE. ; -stkframe dd 0 +reloc_call_low_int26_handler: + sti + pushf + push ax + mov ax,026h + jmp int2526 reloc_call_low_int25_handler: sti pushf push ax + mov ax,025h +int2526: push cx push dx push bx @@ -418,24 +422,41 @@ reloc_call_low_int25_handler: push ds push es - mov word [cs:stkframe], sp ; save stack frame - mov word [cs:stkframe+2], ss + + mov cx, sp ; save stack frame + mov dx, ss cld - mov ax, DGROUP - mov ds, ax + mov bx, DGROUP + mov ds, bx + + ; save away foreground process' stack + push word [_usr_ss] + push word [_usr_sp] - mov word [_api_sp], _disk_api_tos - mov word [_api_ss], ds + mov word [_usr_ss],ss + mov word [_usr_sp],sp - call _set_stack + ; setup our local stack + cli + mov ss,bx + mov sp,_disk_api_tos + sti - push word [cs:stkframe+2] - push word [cs:stkframe] - call _int25_handler + push dx ; SS:SP -> user stack + push cx + push ax ; was set on entry = 25,26 + call _int2526_handler add sp, byte 4 - call _restore_stack + + ; restore foreground stack here + cli + mov ss,word [_usr_ss] + mov sp,word [_usr_sp] + + pop word [_usr_sp] + pop word [_usr_ss] pop es pop ds @@ -453,52 +474,6 @@ reloc_call_low_int25_handler: ; flag image on the stack. -reloc_call_low_int26_handler: - sti - pushf - push ax - push cx - push dx - push bx - push sp - push bp - push si - push di - push ds - push es - - mov word [cs:stkframe], sp ; save stack frame - mov word [cs:stkframe+2], ss - - cld - mov ax, DGROUP - mov ds, ax - - mov word [_api_sp], _disk_api_tos - mov word [_api_ss], ds - - call _set_stack - - push word [cs:stkframe+2] - push word [cs:stkframe] - call _int26_handler - add sp, 4 - - call _restore_stack - - pop es - pop ds - pop di - pop si - pop bp - pop bx ; pop off sp value - pop bx - pop dx - pop cx - pop ax - popf - retf - CONTINUE equ 00h RETRY equ 01h diff --git a/kernel/inthndlr.c b/kernel/inthndlr.c index 16e54a2c..72eb964c 100644 --- a/kernel/inthndlr.c +++ b/kernel/inthndlr.c @@ -36,6 +36,9 @@ BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.16 2001/03/27 20:27:43 bartoldeman + * dsk.c (reported by Nagy Daniel), inthndlr and int25/26 fixes by Tom Ehlert. + * * Revision 1.15 2001/03/25 17:11:54 bartoldeman * Fixed sys.com compilation. Updated to 2023. Also: see history.txt. * @@ -230,6 +233,8 @@ VOID FAR int21_entry(iregs UserRegs) /* Normal entry. This minimizes user stack usage by avoiding local */ /* variables needed for the rest of the handler. */ +/* this here works on the users stack !! and only very few functions + are allowed */ VOID int21_syscall(iregs FAR * irp) { Int21AX = irp->AX; @@ -260,12 +265,16 @@ VOID int21_syscall(iregs FAR * irp) irp->BL = os_major; irp->BH = os_minor; irp->DL = rev_number; - irp->DH = version_flags; + irp->DH = version_flags; /* bit3:runs in ROM,bit 4: runs in HMA*/ break; - - default: - irp->AX = -DE_INVLDFUNC; - irp->FLAGS |= FLG_CARRY; + + case 0x02: /* andrew schulman: get/set extended control break + should be done */ + case 0x03: /* DOS 7 does not set AL */ + case 0x07: /* neither here */ + + default: /* set AL=0xFF as error, NOT carry */ + irp->AL = 0xff; break; /* Toggle DOS-C rdwrblock trace dump */ @@ -305,14 +314,12 @@ VOID int21_syscall(iregs FAR * irp) irp->BX = cu_psp; break; - /* Normal DOS function - switch stacks */ + /* Normal DOS function - DO NOT ARRIVE HERE */ default: - int21_service(user_r); break; } } -static int debug_cnt; VOID int21_service(iregs FAR * r) { @@ -330,16 +337,6 @@ VOID int21_service(iregs FAR * r) p->ps_stack = (BYTE FAR *) r; - switch(r->AH) - { - case 0x2a: /*DosGetDate */ - case 0x2b: /*DosSetDate */ - case 0x2c: /*DosGetTime */ - case 0x2d: /*DosSetDate */ - break; - default: - debug_cnt++; /* debuggable statement */ - } @@ -1864,21 +1861,21 @@ struct int25regs cs; }; -/* this function is called from an assembler wrapper function */ -/* - I'm probably either - A) totally braindamaged - B) chasing a compiler bug, which I can't find. - - LEAVE THIS CODE EXACTLY AS IS OR FDOS WON'T BOOT +/* + this function is called from an assembler wrapper function */ VOID int2526_handler(WORD mode, struct int25regs FAR * r) { ULONG blkno; UWORD nblks; BYTE FAR *buf; - UBYTE drv = r->ax; + UBYTE drv; + if (mode == 0x26) mode = DSKWRITE; + else mode = DSKREAD; + + drv = r->ax; + if (drv >= (lastdrive - 1)) { r->ax = 0x202; @@ -1892,45 +1889,22 @@ VOID int2526_handler(WORD mode, struct int25regs FAR * r) buf = MK_FP(r->ds, r->bx); - if (mode == DSKREAD) - { - if (nblks == 0xFFFF) - { - /*struct HugeSectorBlock FAR *lb = MK_FP(r->ds, r->bx);*/ - blkno = ((struct HugeSectorBlock FAR *)buf)->blkno; - nblks = ((struct HugeSectorBlock FAR *)buf)->nblks; - buf = ((struct HugeSectorBlock FAR *)buf)->buf; - } - else - { - buf = MK_FP(r->ds, r->bx); - } - } else { - if (nblks == 0xFFFF) - { - struct HugeSectorBlock FAR *lb = MK_FP(r->ds, r->bx); - blkno = lb->blkno; - nblks = lb->nblks; - buf = lb->buf; - } - else - { - buf = MK_FP(r->ds, r->bx); - } - } - + if (nblks == 0xFFFF) + { + /*struct HugeSectorBlock FAR *lb = MK_FP(r->ds, r->bx);*/ + blkno = ((struct HugeSectorBlock FAR *)buf)->blkno; + nblks = ((struct HugeSectorBlock FAR *)buf)->nblks; + buf = ((struct HugeSectorBlock FAR *)buf)->buf; + } InDOS++; - if (mode == DSKREAD) - { - r->ax=dskxfer(drv, blkno, buf, nblks, mode); - } else { - r->ax=dskxfer(drv, blkno, buf, nblks, DSKWRITE); - if (r->ax <= 0) - setinvld(drv); - } + r->ax=dskxfer(drv, blkno, buf, nblks, mode); + + if (mode == DSKWRITE) + if (r->ax <= 0) + setinvld(drv); if (r->ax > 0) { @@ -1945,9 +1919,10 @@ VOID int2526_handler(WORD mode, struct int25regs FAR * r) --InDOS; } +/* VOID int25_handler(struct int25regs FAR * r) { int2526_handler(DSKREAD,r); } VOID int26_handler(struct int25regs FAR * r) { int2526_handler(DSKWRITE,r); } - +*/ diff --git a/kernel/proto.h b/kernel/proto.h index baeb8964..bf483480 100644 --- a/kernel/proto.h +++ b/kernel/proto.h @@ -34,6 +34,9 @@ static BYTE *Proto_hRcsId = "$Id$"; /* * $Log$ + * Revision 1.11 2001/03/27 20:27:43 bartoldeman + * dsk.c (reported by Nagy Daniel), inthndlr and int25/26 fixes by Tom Ehlert. + * * Revision 1.10 2001/03/22 04:55:36 bartoldeman * Fix prototypes. * @@ -365,8 +368,8 @@ VOID INRPT FAR int23_handler(int es, int ds, int di, int si, int bp, int sp, int VOID INRPT FAR int24_handler(void); VOID INRPT FAR low_int25_handler(void); VOID INRPT FAR low_int26_handler(void); -VOID int25_handler(); -VOID int26_handler(); +/* VOID int25_handler(); +VOID int26_handler();*/ VOID INRPT FAR int27_handler(int es, int ds, int di, int si, int bp, int sp, int bx, int dx, int cx, int ax, int ip, int cs, int flags); VOID INRPT FAR int28_handler(void); VOID INRPT FAR int2a_handler(void); From 31b068e497391769996af965111bbb5f52481014 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Fri, 30 Mar 2001 19:30:06 +0000 Subject: [PATCH 063/671] Misc fixes and implementation of SHELLHIGH. See history.txt for details. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@181 6ac86273-5f31-0410-b378-82cca8765d1b --- docs/history.txt | 16 ++++++++++- kernel/config.c | 22 ++++++++++++++- kernel/dosfns.c | 5 +++- kernel/entry.asm | 36 +++++++++++++++++++++++++ kernel/fatfs.c | 9 ++++--- kernel/globals.h | 7 +++++ kernel/inithma.c | 16 ++++++----- kernel/inthndlr.c | 21 +++++++++------ kernel/kernel.asm | 12 ++++++--- kernel/main.c | 33 +++++++++++++++++++++-- kernel/memmgr.c | 11 +++++++- kernel/network.c | 55 ++++++------------------------------- kernel/prf.c | 20 ++++++++++++++ kernel/proto.h | 14 ++++++---- kernel/task.c | 69 ++++++++++++++++++++++++++++++++++++++++------- 15 files changed, 257 insertions(+), 89 deletions(-) diff --git a/docs/history.txt b/docs/history.txt index c6cdfcd9..e4cb6c88 100644 --- a/docs/history.txt +++ b/docs/history.txt @@ -1,5 +1,19 @@ -2001 Mar 28 - Build 2023 +2001 Mar 30 - Build 2023 -------- Bart Oldeman (bart.oldeman@bristol.ac.uk) ++ Fixes Tom: Kernel alloc initialises to 0. This avoids some weird errors. + Implemented default divide by 0 handler (INT 0) + FILES= fixes from config.sys. fatfs.c ignored it and always + used the default of 16. + Misc debug code removal. + int 21/ax=3306 report running HIGH fix. + int 21/ah=69 : save CX + InitializeAllBPBs() or MakeNortonDiskEditorHappy() + More extended information if MCB chain corruption occurs. + Bart: getdpb fixes (int 21/ah=32). + fix carry handling in int 21/ah=5e. + fix {get,set}_machine_name in network.c ++ Add Support for SHELLHIGH in config.sys +2001 Mar 28 - Build 2023 + Fixes Bug fix release 2023b: dsk.c (reported by Nagy Daniel), inthndlr and int25/26 fixes by Tom Ehlert. 2001 Mar 27 - Build 2023 diff --git a/kernel/config.c b/kernel/config.c index 3f39222c..993df89a 100644 --- a/kernel/config.c +++ b/kernel/config.c @@ -40,6 +40,9 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.14 2001/03/30 19:30:00 bartoldeman + * Misc fixes and implementation of SHELLHIGH. See history.txt for details. + * * Revision 1.13 2001/03/27 20:27:27 bartoldeman * dsk.c (reported by Nagy Daniel), inthndlr and int25/26 fixes by Tom Ehlert. * @@ -197,6 +200,7 @@ INIT BOOL LoadDevice(BYTE * pLine, COUNT top, COUNT mode); INIT VOID Dosmem(BYTE * pLine); INIT VOID Country(BYTE * pLine); INIT VOID InitPgm(BYTE * pLine); +INIT VOID InitPgmHigh(BYTE * pLine); INIT VOID Switchar(BYTE * pLine); INIT VOID CfgFailure(BYTE * pLine); INIT VOID Stacks(BYTE * pLine); @@ -251,6 +255,7 @@ static struct table commands[] = /* rem is never executed by locking out pass */ {"REM", 0, CfgFailure}, {"SHELL", 1, InitPgm}, + {"SHELLHIGH", 1, InitPgmHigh}, {"STACKS", 1, Stacks}, {"SWITCHAR", 1, Switchar}, {"SCREEN", 1, sysScreenMode}, /* JPP */ @@ -322,6 +327,8 @@ INIT void PreConfig(void) /* Initialize the file table */ f_nodes = (struct f_node FAR *) KernelAlloc(Config.cfgFiles * sizeof(struct f_node)); + + f_nodes_cnt = Config.cfgFiles; /* sfthead = (sfttbl FAR *)&basesft; */ /* FCBp = (sfttbl FAR *)&FcbSft; */ FCBp = (sfttbl FAR *) @@ -399,7 +406,9 @@ INIT void PostConfig(void) /* Initialize the file table */ f_nodes = (struct f_node FAR *) KernelAlloc(Config.cfgFiles * sizeof(struct f_node)); - /* sfthead = (sfttbl FAR *)&basesft; */ + + f_nodes_cnt = Config.cfgFiles; /* and the number of allocated files */ +/* sfthead = (sfttbl FAR *)&basesft; */ /* FCBp = (sfttbl FAR *)&FcbSft; */ FCBp = (sfttbl FAR *) KernelAlloc(sizeof(sftheader) @@ -920,6 +929,13 @@ INIT static VOID Stacks(BYTE * pLine) } } +INIT static VOID InitPgmHigh(BYTE * pLine) +{ + InitPgm(pLine); + Config.cfgP_0_startmode = 0x80; +} + + INIT static VOID InitPgm(BYTE * pLine) { /* Get the string argument that represents the new init pgm */ @@ -931,6 +947,8 @@ INIT static VOID InitPgm(BYTE * pLine) /* and add a DOS new line just to be safe */ strcat(Config.cfgInitTail, "\r\n"); + + Config.cfgP_0_startmode = 0; } INIT static VOID Break(BYTE * pLine) @@ -1101,6 +1119,8 @@ INIT BYTE FAR *KernelAlloc(WORD nBytes) else lpBase += nBytes; + fmemset( lpAllocated, 0, nBytes); + return lpAllocated; } #endif diff --git a/kernel/dosfns.c b/kernel/dosfns.c index f741078d..cb22f0b6 100644 --- a/kernel/dosfns.c +++ b/kernel/dosfns.c @@ -37,6 +37,9 @@ static BYTE *dosfnsRcsId = "$Id$"; * /// Added SHARE support. 2000/09/04 Ron Cemer * * $Log$ + * Revision 1.12 2001/03/30 19:30:06 bartoldeman + * Misc fixes and implementation of SHELLHIGH. See history.txt for details. + * * Revision 1.11 2001/03/21 02:56:25 bartoldeman * See history.txt for changes. Bug fixes and HMA support are the main ones. * @@ -1419,7 +1422,7 @@ COUNT DosSetFattr(BYTE FAR * name, UWORD FAR * attrp) BYTE DosSelectDrv(BYTE drv) { - if ((0 <= drv) && (drv <= (lastdrive -1 )) &&(CDSp->cds_table[drv].cdsFlags & 0xf000)) + if ((0 <= drv) && (drv < lastdrive) &&(CDSp->cds_table[drv].cdsFlags & 0xf000)) { current_ldt = &CDSp->cds_table[drv]; default_drive = drv; diff --git a/kernel/entry.asm b/kernel/entry.asm index 967bbdce..bf4ad99d 100644 --- a/kernel/entry.asm +++ b/kernel/entry.asm @@ -28,6 +28,9 @@ ; $Id$ ; ; $Log$ +; Revision 1.9 2001/03/30 19:30:06 bartoldeman +; Misc fixes and implementation of SHELLHIGH. See history.txt for details. +; ; Revision 1.8 2001/03/27 20:27:43 bartoldeman ; dsk.c (reported by Nagy Daniel), inthndlr and int25/26 fixes by Tom Ehlert. ; @@ -192,6 +195,39 @@ _RestartSysCall: jmp short int21_reentry ; restart the system call +; +; interrupt zero divide handler: +; print a message 'Interrupt divide by zero' +; Terminate the current process +; +; VOID INRPT far +; int20_handler(iregs UserRegs) +; + +divide_by_zero_message db 0dh,0ah,'Interrupt divide by zero',0dh,0ah,0 + + global reloc_call_int0_handler +reloc_call_int0_handler: + + mov si,divide_by_zero_message + +zero_message_loop: + mov al, [cs:si] + test al,al + je zero_done + + inc si + mov bx, 0070h + mov ah, 0eh + + int 10h + + jmp short zero_message_loop + +zero_done: + mov ax,04c7fh ; terminate with errorlevel 127 + int 21h + ; ; Terminate the current process ; diff --git a/kernel/fatfs.c b/kernel/fatfs.c index c3766e4d..0d574d36 100644 --- a/kernel/fatfs.c +++ b/kernel/fatfs.c @@ -36,6 +36,9 @@ BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.13 2001/03/30 19:30:06 bartoldeman + * Misc fixes and implementation of SHELLHIGH. See history.txt for details. + * * Revision 1.12 2001/03/24 22:13:05 bartoldeman * See history.txt: dsk.c changes, warning removal and int21 entry handling. * @@ -464,7 +467,7 @@ static void merge_file_changes(struct f_node FAR *fnp, int collect) { int i; if (!IsShareInstalled()) return; - for (i = 0; i < NFILES; i++) { + for (i = 0; i < f_nodes_cnt; i++) { fnp2 = &f_nodes[i]; if ( (fnp != (struct f_node FAR *)0) && (fnp != fnp2) @@ -2078,7 +2081,7 @@ struct f_node FAR *get_f_node(void) { REG i; - for (i = 0; i < NFILES; i++) + for (i = 0; i < f_nodes_cnt; i++) { if (f_nodes[i].f_count == 0) { @@ -2297,7 +2300,7 @@ COUNT media_check(REG struct dpb * dpbp) /* translate the fd into an f_node pointer */ struct f_node FAR *xlt_fd(COUNT fd) { - return fd >= NFILES ? (struct f_node FAR *)0 : &f_nodes[fd]; + return fd >= f_nodes_cnt ? (struct f_node FAR *)0 : &f_nodes[fd]; } /* translate the f_node pointer into an fd */ diff --git a/kernel/globals.h b/kernel/globals.h index 0d4ee3db..ed484c25 100644 --- a/kernel/globals.h +++ b/kernel/globals.h @@ -36,6 +36,9 @@ static BYTE *Globals_hRcsId = "$Id$"; /* * $Log$ + * Revision 1.8 2001/03/30 19:30:06 bartoldeman + * Misc fixes and implementation of SHELLHIGH. See history.txt for details. + * * Revision 1.7 2001/03/21 02:56:26 bartoldeman * See history.txt for changes. Bug fixes and HMA support are the main ones. * @@ -604,6 +607,8 @@ GLOBAL struct dpb GLOBAL struct f_node FAR * f_nodes; /* pointer to the array */ +GLOBAL UWORD f_nodes_cnt; /* number of allocated f_nodes */ + GLOBAL struct buffer FAR *lastbuf; /* tail of ditto */ /* FAR * buffers; /* pointer to array of track buffers */ @@ -637,6 +642,7 @@ GLOBAL struct config WORD cfgCSYS_memory; /* number of bytes required for the NLS pkg; 0 if none */ VOID FAR *cfgCSYS_data; /* where the loaded data is for PostConfig() */ + UBYTE cfgP_0_startmode; /* load command.com high or not */ } Config #ifdef MAIN = @@ -656,6 +662,7 @@ GLOBAL struct config ,"" /* filename */ ,0 /* amount required memory */ ,0 /* pointer to loaded data */ + ,0 /* strategy for command.com is low by default */ }; #else ; diff --git a/kernel/inithma.c b/kernel/inithma.c index a2d055b4..eb1cd1fb 100644 --- a/kernel/inithma.c +++ b/kernel/inithma.c @@ -75,6 +75,9 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.2 2001/03/30 19:30:06 bartoldeman + * Misc fixes and implementation of SHELLHIGH. See history.txt for details. + * * Revision 1.1 2001/03/21 03:01:45 bartoldeman * New file by Tom Ehlert for HMA initialization. * @@ -233,8 +236,6 @@ int MoveKernelToHMA() unsigned len; - int3(); - if (DosLoadedInHMA) { @@ -306,7 +307,6 @@ int MoveKernelToHMA() HMAFree = FP_OFF(HMADest)+len; /* first free byte after HMA_TEXT */ - int3(); } { @@ -388,13 +388,15 @@ int MoveKernelToHMA() DosLoadedInHMA = TRUE; } + + /* report the fact we are running high thorugh int 21, ax=3306 */ + version_flags |= 0x10; + - int3(); return TRUE; errorReturn: printf("HMA errors, not doing HMA\n"); - int3(); return FALSE; } @@ -415,7 +417,7 @@ int MoveKernelToHMA() void InstallVDISK() { static struct { /* Boot-Sektor of a RAM-Disk */ - BYTE dummy1[3]; /* HIMEM.SYS uses 3, but FDXMS uses 2 */ + UBYTE dummy1[3]; /* HIMEM.SYS uses 3, but FDXMS uses 2 */ char Name[5]; BYTE dummy2[3]; WORD BpS; @@ -529,6 +531,8 @@ VOID FAR *HMAalloc(COUNT bytesToAllocate) /*printf("HMA allocated %d byte at %x\n", bytesToAllocate, HMAptr); */ + fmemset( HMAptr,0, bytesToAllocate); + return HMAptr; } diff --git a/kernel/inthndlr.c b/kernel/inthndlr.c index 72eb964c..abe4d16d 100644 --- a/kernel/inthndlr.c +++ b/kernel/inthndlr.c @@ -36,6 +36,9 @@ BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.17 2001/03/30 19:30:06 bartoldeman + * Misc fixes and implementation of SHELLHIGH. See history.txt for details. + * * Revision 1.16 2001/03/27 20:27:43 bartoldeman * dsk.c (reported by Nagy Daniel), inthndlr and int25/26 fixes by Tom Ehlert. * @@ -840,7 +843,10 @@ VOID int21_service(iregs FAR * r) if (r->DL <= (lastdrive - 1)) { struct dpb FAR *dpb = CDSp->cds_table[r->DL].cdsDpb; - if (dpb == 0) + if (dpb == 0 || + (CDSp->cds_table[r->DL].cdsFlags & CDSNETWDRV) || + FP_SEG(dpb) != FP_SEG(&dpb) || /* check if it's a NEAR pointer */ + media_check((struct dpb *)dpb) < 0) { r->AL = 0xff; CritErrCode = 0x0f; @@ -1485,6 +1491,7 @@ VOID int21_service(iregs FAR * r) break; case 0x5e: + CLEAR_CARRY_FLAG(); switch (r->AL) { case 0x00: @@ -1500,13 +1507,9 @@ VOID int21_service(iregs FAR * r) COUNT result; result = int2f_Remote_call(REM_PRINTSET, r->BX, r->CX, r->DX, (MK_FP(r->ES, r->DI)), r->SI, (MK_FP(r->DS, Int21AX))); r->AX = result; - if (result != SUCCESS) { - goto error_out; - } else { - CLEAR_CARRY_FLAG(); - } - break; - } + if (result != SUCCESS) goto error_out; + break; + } } break; @@ -1679,6 +1682,7 @@ VOID int21_service(iregs FAR * r) rc = ( r->BL == 0 ? default_drive : r->BL - 1); if (rc <= (lastdrive -1)) { + UWORD saveCX = r->CX; if (CDSp->cds_table[rc].cdsFlags & CDSNETWDRV) { goto error_invalid; } @@ -1695,6 +1699,7 @@ VOID int21_service(iregs FAR * r) rc = DosDevIOctl(r, (COUNT FAR *) & rc1); break; } + r->CX = saveCX; if (rc1 != SUCCESS) { r->AX = -rc1; diff --git a/kernel/kernel.asm b/kernel/kernel.asm index f844f0c0..9b8db850 100644 --- a/kernel/kernel.asm +++ b/kernel/kernel.asm @@ -28,6 +28,9 @@ ; $Id$ ; ; $Log$ +; Revision 1.8 2001/03/30 19:30:06 bartoldeman +; Misc fixes and implementation of SHELLHIGH. See history.txt for details. +; ; Revision 1.7 2001/03/21 02:56:26 bartoldeman ; See history.txt for changes. Bug fixes and HMA support are the main ones. ; @@ -235,9 +238,7 @@ dos_data db 0 times (0eh - ($ - DATASTART)) db 0 global _NetBios -_NetBios db 0 ; NetBios Number - global _Num_Name -_Num_Name db 0 +_NetBios dw 0 ; NetBios Number times (26h - 0ch - ($ - DATASTART)) db 0 @@ -829,7 +830,10 @@ _low_int26_handler: jmp far reloc_call_low_int26_handler _int27_handler: jmp far reloc_call_int27_handler call near forceEnableA20 - + global _int0_handler + extern reloc_call_int0_handler +_int0_handler: jmp far reloc_call_int0_handler + call near forceEnableA20 global _cpm_entry extern reloc_call_cpm_entry diff --git a/kernel/main.c b/kernel/main.c index c53f278c..dc6e2b89 100644 --- a/kernel/main.c +++ b/kernel/main.c @@ -39,6 +39,9 @@ static BYTE *mainRcsId = "$Id$"; /* * $Log$ + * Revision 1.10 2001/03/30 19:30:06 bartoldeman + * Misc fixes and implementation of SHELLHIGH. See history.txt for details. + * * Revision 1.9 2001/03/25 17:11:54 bartoldeman * Fixed sys.com compilation. Updated to 2023. Also: see history.txt. * @@ -184,6 +187,7 @@ void __int__(int); /* TC 2.01 requires this. :( -- ror4 */ INIT VOID main(void) { + setvec(0, int0_handler); /* zero divide */ setvec(1, empty_handler); /* single step */ setvec(3, empty_handler); /* debug breakpoint */ @@ -209,6 +213,30 @@ INIT VOID main(void) kernel(); } +/* + InitializeAllBPBs() + + or MakeNortonDiskEditorHappy() + + it has been determined, that FDOS's BPB tables are initialized, + only when used (like DIR H:). + at least one known utility (norton DE) seems to access them directly. + ok, so we access for all drives, that the stuff gets build +*/ + +void InitializeAllBPBs() +{ + static char filename[] = "A:-@JUNK@-.TMP"; + int drive,fileno; + for (drive = 'Z'; drive >= 'C'; drive--) + { + filename[0] = drive; + if ((fileno = dos_open((BYTE FAR *) filename, O_RDONLY)) >= 0) + dos_close(fileno); + } +} + + INIT void init_kernel(void) { COUNT i; @@ -296,6 +324,9 @@ INIT void init_kernel(void) version_flags = 0; pDirFileNode = 0; dosidle_flag = 0; + + InitializeAllBPBs(); + } INIT VOID FsConfig(VOID) @@ -303,7 +334,6 @@ INIT VOID FsConfig(VOID) REG COUNT i; date Date; time Time; - BYTE x; /* Get the start-up date and time */ Date = dos_getdate(); @@ -439,7 +469,6 @@ INIT void kernel() seg asize; BYTE FAR *ep, *sp; - COUNT ret_code; #ifndef KDB static BYTE *path = "PATH=."; #endif diff --git a/kernel/memmgr.c b/kernel/memmgr.c index 3b801ff3..353cf4c6 100644 --- a/kernel/memmgr.c +++ b/kernel/memmgr.c @@ -35,6 +35,9 @@ static BYTE *memmgrRcsId = "$Id$"; /* * $Log$ + * Revision 1.10 2001/03/30 19:30:06 bartoldeman + * Misc fixes and implementation of SHELLHIGH. See history.txt for details. + * * Revision 1.9 2001/03/21 02:56:26 bartoldeman * See history.txt for changes. Bug fixes and HMA support are the main ones. * @@ -518,7 +521,7 @@ COUNT DosMemChange(UWORD para, UWORD size, UWORD * maxSize) COUNT DosMemCheck(void) { REG mcb FAR *p; - REG mcb FAR *u; + REG mcb FAR *pprev = 0; /* Initialize */ p = para2far(first_mcb); @@ -528,9 +531,15 @@ COUNT DosMemCheck(void) { /* check for corruption */ if (p->m_type != MCB_NORMAL) + { + printf("dos mem corrupt, first_mcb=%04x\n", first_mcb); + hexd("prev " ,pprev,16); + hexd("notMZ",p,16); return DE_MCBDESTRY; + } /* not corrupted - but not end, bump the pointer */ + pprev = p; p = nxtMCB(p); } return SUCCESS; diff --git a/kernel/network.c b/kernel/network.c index 79f2edfd..7d0afad3 100644 --- a/kernel/network.c +++ b/kernel/network.c @@ -36,6 +36,9 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.9 2001/03/30 19:30:06 bartoldeman + * Misc fixes and implementation of SHELLHIGH. See history.txt for details. + * * Revision 1.8 2001/03/21 02:56:26 bartoldeman * See history.txt for changes. Bug fixes and HMA support are the main ones. * @@ -75,25 +78,20 @@ static BYTE *RcsId = "$Id$"; * */ +/* see RBIL D-2152 and D-215D06 before attempting + to change these two functions! + */ UWORD get_machine_name(BYTE FAR * netname) { - BYTE FAR *xn; - - xn = MK_FP(net_name, 0); - fbcopy((BYTE FAR *) netname, xn, 15); + fmemcpy(netname, &net_name, 15); return (NetBios); - } VOID set_machine_name(BYTE FAR * netname, UWORD name_num) { - BYTE FAR *xn; - - xn = MK_FP(net_name, 0); NetBios = name_num; - fbcopy(xn, (BYTE FAR *) netname, 15); + fmemcpy(&net_name, netname, 15); net_set_count++; - } /* @@ -161,44 +159,7 @@ COUNT Remote_find(UWORD func, BYTE FAR * name, REG dmatch FAR * dmp ) dmp->dm_date = SDp->dir_date; dmp->dm_size = (LONG) SDp->dir_size; -/* - Needed Code Rep-off.;) - */ -/* - p = dmp->dm_name; - if (SDp->dir_name[0] == '.') - { - for (x = 0, q = (BYTE FAR *) SDp->dir_name; x < FNAME_SIZE; x++) - { - if (*q == ' ') - break; - *p++ = *q++; - } - } - else - { - for (x = 0, q = (BYTE FAR *) SDp->dir_name; x < FNAME_SIZE; x++) - { - if (*q == ' ') - break; - *p++ = *q++; - } - if (SDp->dir_ext[0] != ' ') - { - *p++ = '.'; - for (x = 0, q = (BYTE FAR *) SDp->dir_ext; x < FEXT_SIZE; x++) - { - if (*q == ' ') - break; - *p++ = *q++; - } - } - } - *p++ = NULL; -*/ ConvertName83ToNameSZ((BYTE FAR *) dmp->dm_name, (BYTE FAR *) SDp->dir_name); - - return i; } diff --git a/kernel/prf.c b/kernel/prf.c index a64c9fee..1c04d1ba 100644 --- a/kernel/prf.c +++ b/kernel/prf.c @@ -34,6 +34,9 @@ static BYTE *prfRcsId = "$Id$"; /* * $Log$ + * Revision 1.6 2001/03/30 19:30:06 bartoldeman + * Misc fixes and implementation of SHELLHIGH. See history.txt for details. + * * Revision 1.5 2001/03/21 02:56:26 bartoldeman * See history.txt for changes. Bug fixes and HMA support are the main ones. * @@ -41,6 +44,9 @@ static BYTE *prfRcsId = "$Id$"; * recoded for smaller object footprint, added main() for testing+QA * * $Log$ + * Revision 1.6 2001/03/30 19:30:06 bartoldeman + * Misc fixes and implementation of SHELLHIGH. See history.txt for details. + * * Revision 1.5 2001/03/21 02:56:26 bartoldeman * See history.txt for changes. Bug fixes and HMA support are the main ones. * @@ -348,6 +354,20 @@ COUNT return 0; } +void hexd(char *title,UBYTE FAR *p,COUNT numBytes) +{ + int loop; + printf("%s%04x|",title,p); + for (loop = 0; loop < numBytes; loop++) + printf("%02x ", p[loop]); + printf("|"); + + for (loop = 0; loop < numBytes; loop++) + printf("%c", p[loop] < 0x20 ? '.' : p[loop]); + printf("\n"); +} + + #ifdef TEST /* diff --git a/kernel/proto.h b/kernel/proto.h index bf483480..590c5d75 100644 --- a/kernel/proto.h +++ b/kernel/proto.h @@ -34,6 +34,9 @@ static BYTE *Proto_hRcsId = "$Id$"; /* * $Log$ + * Revision 1.12 2001/03/30 19:30:06 bartoldeman + * Misc fixes and implementation of SHELLHIGH. See history.txt for details. + * * Revision 1.11 2001/03/27 20:27:43 bartoldeman * dsk.c (reported by Nagy Daniel), inthndlr and int25/26 fixes by Tom Ehlert. * @@ -243,6 +246,8 @@ COUNT DosRename(BYTE FAR * path1, BYTE FAR * path2); COUNT DosMkdir(BYTE FAR * dir); COUNT DosRmdir(BYTE FAR * dir); struct dhdr FAR * IsDevice(BYTE FAR * FileName); +/* extern sft FAR *get_free_sft(WORD FAR * sft_idx); + #define FcbGetFreeSft(sft_idx) get_free_sft(sft_idx) */ /*dosidle.asm */ VOID DosIdle_int(void); @@ -269,6 +274,7 @@ COUNT dir_write(REG struct f_node FAR * fnp); VOID dir_close(REG struct f_node FAR * fnp); COUNT dos_findfirst(UCOUNT attr, BYTE FAR * name); COUNT dos_findnext(void); +void ConvertName83ToNameSZ(BYTE FAR *destSZ, BYTE FAR *srcFCBName); /* fatfs.c */ __FAR_WRAPPER(COUNT, dos_open, (BYTE FAR * path, COUNT flag)) @@ -353,6 +359,7 @@ BOOL FcbFindNext(xfcb FAR * lpXfcb); /* inithma.c */ int MoveKernelToHMA(void); +VOID FAR *HMAalloc(COUNT bytesToAllocate); /* initoem.c */ UWORD init_oem(void); @@ -375,6 +382,7 @@ VOID INRPT FAR int28_handler(void); VOID INRPT FAR int2a_handler(void); VOID INRPT FAR int2f_handler(void); VOID INRPT FAR empty_handler(void); +VOID INRPT FAR int0_handler(void); /* ioctl.c */ COUNT DosDevIOctl(iregs FAR * r, COUNT FAR * err); @@ -454,6 +462,7 @@ UWORD syscall_MUX14(DIRECT_IREGS); VOID put_console(COUNT c); __FAR_WRAPPER(WORD, printf, (CONST BYTE * fmt,...)) WORD sprintf(BYTE * buff, CONST BYTE * fmt,...); +VOID hexd(char *title,VOID FAR *p,COUNT numBytes); /* strings.c */ __FAR_WRAPPER(COUNT, strlen, (REG BYTE * s)) @@ -547,8 +556,3 @@ unsigned long FAR is_dosemu(void); */ #define ASSERT_CONST(x) { typedef struct { char x[2 * (x) - 1]; } xx ; } - -void ConvertName83ToNameSZ(BYTE FAR *destSZ, BYTE FAR *srcFCBName); - - -VOID FAR *HMAalloc(COUNT bytesToAllocate); diff --git a/kernel/task.c b/kernel/task.c index 7d688892..5440b6ef 100644 --- a/kernel/task.c +++ b/kernel/task.c @@ -35,6 +35,9 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.8 2001/03/30 19:30:06 bartoldeman + * Misc fixes and implementation of SHELLHIGH. See history.txt for details. + * * Revision 1.7 2001/03/21 02:56:26 bartoldeman * See history.txt for changes. Bug fixes and HMA support are the main ones. * @@ -149,6 +152,8 @@ static BYTE *RcsId = "$Id$"; #define LOAD 1 #define OVERLAY 3 +#define LOAD_HIGH 0x80 + static exe_header header; #define CHUNK 32256 @@ -176,7 +181,7 @@ LONG doslseek(COUNT fd, LONG foffset, COUNT origin) LONG DosGetFsize(COUNT hndl) { sft FAR *s; - sfttbl FAR *sp; +/* sfttbl FAR *sp;*/ /* Test that the handle is valid */ if (hndl < 0) @@ -444,8 +449,8 @@ static VOID patchPSP(UWORD pspseg, UWORD envseg, CommandTail FAR * cmdline COUNT DosComLoader(BYTE FAR * namep, exec_blk FAR * exp, COUNT mode) { COUNT rc, - err, - env_size; + err + /*,env_size*/; COUNT nread; UWORD mem; UWORD env, @@ -456,6 +461,11 @@ COUNT DosComLoader(BYTE FAR * namep, exec_blk FAR * exp, COUNT mode) iregs FAR *irp; LONG com_size; + int ModeLoadHigh = mode & 0x80; + int UMBstate = uppermem_link; + + mode &= 0x7f; + if (mode != OVERLAY) { @@ -470,6 +480,12 @@ COUNT DosComLoader(BYTE FAR * namep, exec_blk FAR * exp, COUNT mode) return rc; } com_size = asize; + + if ( ModeLoadHigh && uppermem_root) + { + DosUmbLink(1); /* link in UMB's */ + } + /* Allocate our memory and pass back any errors */ if ((rc = DosMemAlloc((seg) com_size, mem_access_mode, (seg FAR *) & mem ,(UWORD FAR *) & asize)) < 0) @@ -500,6 +516,12 @@ COUNT DosComLoader(BYTE FAR * namep, exec_blk FAR * exp, COUNT mode) } else mem = exp->load.load_seg; + + if ( ModeLoadHigh && uppermem_root) + { + DosUmbLink(UMBstate); /* restore link state */ + } + /* Now load the executable */ /* If file not found - error */ @@ -596,7 +618,7 @@ VOID return_user(void) FAR * q; REG COUNT i; iregs FAR *irp; - long j; +/* long j;*/ /* restore parent */ p = MK_FP(cu_psp, 0); @@ -630,11 +652,11 @@ VOID return_user(void) exec_user((iregs FAR *) q->ps_stack); } -static COUNT DosExeLoader(BYTE FAR * namep, exec_blk FAR * exp, COUNT mode) +COUNT DosExeLoader(BYTE FAR * namep, exec_blk FAR * exp, COUNT mode) { COUNT rc, err, - env_size, + /*env_size,*/ i; COUNT nBytesRead; UWORD mem, @@ -652,6 +674,12 @@ static COUNT DosExeLoader(BYTE FAR * namep, exec_blk FAR * exp, COUNT mode) seg FAR *spot; LONG exe_size; + int ModeLoadHigh = mode & 0x80; + int UMBstate = uppermem_link; + + mode &= 0x7f; + + /* Clone the environement and create a memory arena */ if (mode != OVERLAY) { @@ -675,7 +703,7 @@ static COUNT DosExeLoader(BYTE FAR * namep, exec_blk FAR * exp, COUNT mode) /* and finally add in the psp size */ if (mode != OVERLAY) image_size += sizeof(psp); /*TE 03/20/01*/ - + if (mode != OVERLAY) { /* Now find out how many paragraphs are available */ @@ -704,11 +732,18 @@ static COUNT DosExeLoader(BYTE FAR * namep, exec_blk FAR * exp, COUNT mode) overlay (replace) the current exe file with a new one. Jun 11, 2000 - rbc } */ + + + if ( ModeLoadHigh && uppermem_root) + { + DosUmbLink(1); /* link in UMB's */ + } /* Allocate our memory and pass back any errors */ /* We can still get an error on first fit if the above */ /* returned size was a bet fit case */ - if ((rc = DosMemAlloc((seg) exe_size, mem_access_mode, (seg FAR *) & mem + /* ModeLoadHigh = 80 = try high, then low */ + if ((rc = DosMemAlloc((seg) exe_size, mem_access_mode | ModeLoadHigh, (seg FAR *) & mem ,(UWORD FAR *) & asize)) < 0) { if (rc == DE_NOMEM) @@ -737,6 +772,10 @@ static COUNT DosExeLoader(BYTE FAR * namep, exec_blk FAR * exp, COUNT mode) /* with no error, we got exactly what we asked for */ asize = exe_size; +#ifdef DEBUG + printf("loading %s at %04x\n", (char*)namep,mem); +#endif + /* /// Added open curly brace and "else" clause. We should not attempt to allocate memory if we are overlaying the current process, because the new process will simply re-use the block we already have allocated. @@ -747,6 +786,12 @@ static COUNT DosExeLoader(BYTE FAR * namep, exec_blk FAR * exp, COUNT mode) else asize = exe_size; /* /// End of additions. Jun 11, 2000 - rbc */ + + if ( ModeLoadHigh && uppermem_root) + { + DosUmbLink(UMBstate); /* restore link state */ + } + if (mode != OVERLAY) { @@ -905,7 +950,7 @@ COUNT DosExec(COUNT mode, exec_blk FAR * ep, BYTE FAR * lp) COUNT rc, err; exec_blk leb = *ep; - BYTE FAR *cp; +/* BYTE FAR *cp;*/ BOOL bIsCom = FALSE; /* If file not found - free ram and return error */ @@ -918,6 +963,7 @@ COUNT DosExec(COUNT mode, exec_blk FAR * ep, BYTE FAR * lp) return DE_FILENOTFND; } + if (DosRead(rc, sizeof(exe_header), (VOID FAR *) & header, &err) != sizeof(exe_header)) { @@ -955,6 +1001,8 @@ VOID InitPSP(VOID) new_psp(p, 0); } +UBYTE P_0_startmode = 0; + /* process 0 */ VOID FAR reloc_call_p_0(VOID) { @@ -979,7 +1027,8 @@ VOID FAR reloc_call_p_0(VOID) #ifdef DEBUG printf("Process 0 starting: %s\n\n", (BYTE *) szfInitialPrgm); #endif - if ((rc = DosExec(0, (exec_blk FAR *) & exb, szfInitialPrgm)) != SUCCESS) + if ((rc = DosExec(Config.cfgP_0_startmode, + (exec_blk FAR *) & exb, szfInitialPrgm)) != SUCCESS) printf("\nBad or missing Command Interpreter: %d\n", rc); else printf("\nSystem shutdown complete\nReboot now.\n"); From 99f39bebec9784a64a08129526f26ec24e5a7b18 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Fri, 30 Mar 2001 20:11:14 +0000 Subject: [PATCH 064/671] Truly got DOS=HIGH reporting for INT21/AX=0x3306 working now. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@182 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/globals.h | 11 ++++++++++- kernel/main.c | 4 +++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/kernel/globals.h b/kernel/globals.h index ed484c25..c8a69350 100644 --- a/kernel/globals.h +++ b/kernel/globals.h @@ -36,6 +36,9 @@ static BYTE *Globals_hRcsId = "$Id$"; /* * $Log$ + * Revision 1.9 2001/03/30 20:11:14 bartoldeman + * Truly got DOS=HIGH reporting for INT21/AX=0x3306 working now. + * * Revision 1.8 2001/03/30 19:30:06 bartoldeman * Misc fixes and implementation of SHELLHIGH. See history.txt for details. * @@ -387,7 +390,13 @@ GLOBAL BYTE , #endif - version_flags; /* minor version number */ + version_flags /* minor version number */ +#ifdef MAIN += 0; +#else + ; +#endif + #ifdef DEBUG GLOBAL WORD bDumpRegs #ifdef MAIN diff --git a/kernel/main.c b/kernel/main.c index dc6e2b89..068f3342 100644 --- a/kernel/main.c +++ b/kernel/main.c @@ -39,6 +39,9 @@ static BYTE *mainRcsId = "$Id$"; /* * $Log$ + * Revision 1.11 2001/03/30 20:11:14 bartoldeman + * Truly got DOS=HIGH reporting for INT21/AX=0x3306 working now. + * * Revision 1.10 2001/03/30 19:30:06 bartoldeman * Misc fixes and implementation of SHELLHIGH. See history.txt for details. * @@ -321,7 +324,6 @@ INIT void init_kernel(void) mem_access_mode = FIRST_FIT; verify_ena = FALSE; InDOS = 0; - version_flags = 0; pDirFileNode = 0; dosidle_flag = 0; From 2799b7b810c81d549c8b02ef57b66b0d4585ab97 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Fri, 30 Mar 2001 22:27:42 +0000 Subject: [PATCH 065/671] Saner lastdrive handling. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@183 6ac86273-5f31-0410-b378-82cca8765d1b --- docs/history.txt | 1 + kernel/config.c | 9 ++++++--- kernel/dosfns.c | 7 +++++-- kernel/fatdir.c | 11 +++++++---- kernel/fcbfns.c | 11 +++++++---- kernel/inthndlr.c | 15 +++++++++------ kernel/ioctl.c | 5 ++++- kernel/main.c | 6 +++--- kernel/newstuff.c | 7 +++++-- 9 files changed, 47 insertions(+), 25 deletions(-) diff --git a/docs/history.txt b/docs/history.txt index e4cb6c88..1b2cb6a4 100644 --- a/docs/history.txt +++ b/docs/history.txt @@ -12,6 +12,7 @@ Bart: getdpb fixes (int 21/ah=32). fix carry handling in int 21/ah=5e. fix {get,set}_machine_name in network.c + saner lastdrive handling + Add Support for SHELLHIGH in config.sys 2001 Mar 28 - Build 2023 + Fixes Bug fix release 2023b: dsk.c (reported by Nagy Daniel), inthndlr and diff --git a/kernel/config.c b/kernel/config.c index 993df89a..de44f74a 100644 --- a/kernel/config.c +++ b/kernel/config.c @@ -40,6 +40,9 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.15 2001/03/30 22:27:42 bartoldeman + * Saner lastdrive handling. + * * Revision 1.14 2001/03/30 19:30:00 bartoldeman * Misc fixes and implementation of SHELLHIGH. See history.txt for details. * @@ -339,7 +342,7 @@ INIT void PreConfig(void) + Config.cfgFiles * sizeof(sft)); CDSp = (cdstbl FAR *) - KernelAlloc(0x58 * (lastdrive)); + KernelAlloc(0x58 * lastdrive); #ifdef DEBUG printf("Preliminary f_node allocated at at 0x%p\n",f_nodes); @@ -418,7 +421,7 @@ INIT void PostConfig(void) + Config.cfgFiles * sizeof(sft)); CDSp = (cdstbl FAR *) - KernelAlloc(0x58 * (lastdrive)); + KernelAlloc(0x58 * lastdrive); #ifdef DEBUG @@ -458,7 +461,7 @@ INIT VOID configDone(VOID) #endif /* DEBUG */ lastdrive = nblkdev; CDSp = (cdstbl FAR *) - KernelAlloc(0x58 * (lastdrive )); + KernelAlloc(0x58 * lastdrive); } first_mcb = FP_SEG(lpBase) + ((FP_OFF(lpBase) + 0x0f) >> 4); diff --git a/kernel/dosfns.c b/kernel/dosfns.c index cb22f0b6..0e09f530 100644 --- a/kernel/dosfns.c +++ b/kernel/dosfns.c @@ -37,6 +37,9 @@ static BYTE *dosfnsRcsId = "$Id$"; * /// Added SHARE support. 2000/09/04 Ron Cemer * * $Log$ + * Revision 1.13 2001/03/30 22:27:42 bartoldeman + * Saner lastdrive handling. + * * Revision 1.12 2001/03/30 19:30:06 bartoldeman * Misc fixes and implementation of SHELLHIGH. See history.txt for details. * @@ -1117,7 +1120,7 @@ VOID DosGetFree(COUNT drive, COUNT FAR * spc, COUNT FAR * navc, COUNT FAR * bps, drive = (drive == 0 ? default_drive : drive - 1); /* first check for valid drive */ - if (drive < 0 || drive > (lastdrive - 1)) + if (drive < 0 || drive >= lastdrive) { *spc = -1; return; @@ -1166,7 +1169,7 @@ COUNT DosGetCuDir(COUNT drive, BYTE FAR * s) drive = (drive == 0 ? default_drive : drive - 1); /* first check for valid drive */ - if (drive < 0 || drive > (lastdrive - 1)) { + if (drive < 0 || drive >= lastdrive) { return DE_INVLDDRV; } diff --git a/kernel/fatdir.c b/kernel/fatdir.c index 765a6b4f..ec10e7c2 100644 --- a/kernel/fatdir.c +++ b/kernel/fatdir.c @@ -36,6 +36,9 @@ static BYTE *fatdirRcsId = "$Id$"; /* * $Log$ + * Revision 1.12 2001/03/30 22:27:42 bartoldeman + * Saner lastdrive handling. + * * Revision 1.11 2001/03/21 02:56:25 bartoldeman * See history.txt for changes. Bug fixes and HMA support are the main ones. * @@ -202,7 +205,7 @@ struct f_node FAR *dir_open(BYTE FAR * dirname) { drive = default_drive; } - if (drive > (lastdrive-1)) { + if (drive >= lastdrive) { release_f_node(fnp); return NULL; } @@ -618,7 +621,7 @@ COUNT dos_findfirst(UCOUNT attr, BYTE FAR * name) else nDrive = default_drive; - if (nDrive > (lastdrive -1)) { + if (nDrive >= lastdrive) { return DE_INVLDDRV; } current_ldt = &CDSp->cds_table[nDrive]; @@ -799,7 +802,7 @@ COUNT dos_findnext(void) */ nDrive = dmp->dm_drive & 0x1f; - if (nDrive > (lastdrive -1)) { + if (nDrive >= lastdrive) { return DE_INVLDDRV; } current_ldt = &CDSp->cds_table[nDrive]; @@ -825,7 +828,7 @@ COUNT dos_findnext(void) /* Force the fnode into read-write mode */ fnp->f_mode = RDWR; - if (dmp->dm_drive > (lastdrive)) { + if (dmp->dm_drive >= lastdrive) { return DE_INVLDDRV; } /* Select the default to help non-drive specified path */ diff --git a/kernel/fcbfns.c b/kernel/fcbfns.c index 8a236805..3993b4ac 100644 --- a/kernel/fcbfns.c +++ b/kernel/fcbfns.c @@ -35,6 +35,9 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.8 2001/03/30 22:27:42 bartoldeman + * Saner lastdrive handling. + * * Revision 1.7 2001/03/21 02:56:26 bartoldeman * See history.txt for changes. Bug fixes and HMA support are the main ones. * @@ -152,7 +155,7 @@ VOID FatGetDrvData(COUNT drive, COUNT FAR * spc, COUNT FAR * bps, printf("FGDD\n"); /* first check for valid drive */ - if ((drive < 0) || (drive > (lastdrive -1)) || (drive > NDEVS)) + if ((drive < 0) || (drive >= lastdrive) || (drive >= NDEVS)) { *spc = -1; return; @@ -235,7 +238,7 @@ WORD FcbParseFname(int wTestMode, BYTE FAR ** lpFileName, fcb FAR * lpFcb) if (Drive < 'A' || Drive > 'Z') return PARSE_RET_BADDRIVE; Drive -= ('A' - 1); - if (Drive > (lastdrive -1)) + if (Drive >= lastdrive) return PARSE_RET_BADDRIVE; else lpFcb->fcb_drive = Drive; @@ -804,7 +807,7 @@ BOOL FcbOpen(xfcb FAR * lpXfcb) return TRUE; } fbcopy((BYTE FAR *) & lpFcb->fcb_fname, (BYTE FAR *) & sftp->sft_name, FNAME_SIZE + FEXT_SIZE); - if ((FcbDrive < 0) || (FcbDrive > (lastdrive -1))) { + if ((FcbDrive < 0) || (FcbDrive >= lastdrive)) { return DE_INVLDDRV; } if (CDSp->cds_table[FcbDrive].cdsFlags & CDSNETWDRV) { @@ -850,7 +853,7 @@ BOOL FcbDelete(xfcb FAR * lpXfcb) /* Build a traditional DOS file name */ CommonFcbInit(lpXfcb, PriPathName, &FcbDrive); - if ((FcbDrive < 0) || (FcbDrive > (lastdrive -1))) { + if ((FcbDrive < 0) || (FcbDrive >= lastdrive)) { return DE_INVLDDRV; } current_ldt = &CDSp->cds_table[FcbDrive]; diff --git a/kernel/inthndlr.c b/kernel/inthndlr.c index abe4d16d..085200fd 100644 --- a/kernel/inthndlr.c +++ b/kernel/inthndlr.c @@ -36,6 +36,9 @@ BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.18 2001/03/30 22:27:42 bartoldeman + * Saner lastdrive handling. + * * Revision 1.17 2001/03/30 19:30:06 bartoldeman * Misc fixes and implementation of SHELLHIGH. See history.txt for details. * @@ -631,7 +634,7 @@ VOID int21_service(iregs FAR * r) /* Get default DPB */ case 0x1f: - if (default_drive <= (lastdrive -1)) + if (default_drive < lastdrive) { struct dpb FAR *dpb = (struct dpb FAR *)CDSp->cds_table[default_drive].cdsDpb; if (dpb == 0) @@ -840,7 +843,7 @@ VOID int21_service(iregs FAR * r) /* Get DPB */ case 0x32: r->DL = ( r->DL == 0 ? default_drive : r->DL - 1); - if (r->DL <= (lastdrive - 1)) + if (r->DL < lastdrive) { struct dpb FAR *dpb = CDSp->cds_table[r->DL].cdsDpb; if (dpb == 0 || @@ -1517,13 +1520,13 @@ VOID int21_service(iregs FAR * r) switch (r->AL) { case 0x07: - if (r->DL <= (lastdrive -1)) { + if (r->DL < lastdrive) { CDSp->cds_table[r->DL].cdsFlags |= 0x100; } break; case 0x08: - if (r->DL <= (lastdrive -1)) { + if (r->DL < lastdrive) { CDSp->cds_table[r->DL].cdsFlags &= ~0x100; } break; @@ -1680,7 +1683,7 @@ VOID int21_service(iregs FAR * r) /* Get/Set Serial Number */ case 0x69: rc = ( r->BL == 0 ? default_drive : r->BL - 1); - if (rc <= (lastdrive -1)) + if (rc < lastdrive) { UWORD saveCX = r->CX; if (CDSp->cds_table[rc].cdsFlags & CDSNETWDRV) { @@ -1881,7 +1884,7 @@ VOID int2526_handler(WORD mode, struct int25regs FAR * r) drv = r->ax; - if (drv >= (lastdrive - 1)) + if (drv >= lastdrive) { r->ax = 0x202; r->flags |= FLG_CARRY; diff --git a/kernel/ioctl.c b/kernel/ioctl.c index e53998b1..04519d67 100644 --- a/kernel/ioctl.c +++ b/kernel/ioctl.c @@ -35,6 +35,9 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.7 2001/03/30 22:27:42 bartoldeman + * Saner lastdrive handling. + * * Revision 1.6 2000/06/21 18:16:46 jimtabor * Add UMB code, patch, and code fixes * @@ -164,7 +167,7 @@ COUNT DosDevIOctl(iregs FAR * r, COUNT FAR * err) dev = ( r->BL == 0 ? default_drive : r->BL - 1); - if (dev > (lastdrive -1)) + if (dev >= lastdrive) { *err = DE_INVLDDRV; return 0; diff --git a/kernel/main.c b/kernel/main.c index 068f3342..62cf0024 100644 --- a/kernel/main.c +++ b/kernel/main.c @@ -39,8 +39,8 @@ static BYTE *mainRcsId = "$Id$"; /* * $Log$ - * Revision 1.11 2001/03/30 20:11:14 bartoldeman - * Truly got DOS=HIGH reporting for INT21/AX=0x3306 working now. + * Revision 1.12 2001/03/30 22:27:42 bartoldeman + * Saner lastdrive handling. * * Revision 1.10 2001/03/30 19:30:06 bartoldeman * Misc fixes and implementation of SHELLHIGH. See history.txt for details. @@ -552,7 +552,7 @@ BOOL init_device(struct dhdr FAR * dhp, BYTE FAR * cmdLine, COUNT mode, COUNT r_ pblk_devices->dpb_subunit = Index; pblk_devices->dpb_device = dhp; pblk_devices->dpb_flags = M_CHANGED; - if ((CDSp != 0) && (nblkdev <= lastdrive)) + if ((CDSp != 0) && (nblkdev < lastdrive)) { CDSp->cds_table[nblkdev].cdsDpb = pblk_devices; CDSp->cds_table[nblkdev].cdsFlags = CDSPHYSDRV; diff --git a/kernel/newstuff.c b/kernel/newstuff.c index 459d3f84..fa270f7e 100644 --- a/kernel/newstuff.c +++ b/kernel/newstuff.c @@ -31,6 +31,9 @@ static BYTE *mainRcsId = "$Id$"; /* * $Log$ + * Revision 1.9 2001/03/30 22:27:42 bartoldeman + * Saner lastdrive handling. + * * Revision 1.8 2000/08/06 05:50:17 jimtabor * Add new files and update cvs with patches and changes * @@ -220,7 +223,7 @@ COUNT get_verify_drive(char FAR *src) } else drive = default_drive; - if ((drive < 0) || (drive > lastdrive)) { + if ((drive < 0) || (drive >= lastdrive)) { drive = DE_INVLDDRV; } return drive; @@ -255,7 +258,7 @@ COUNT truename(char FAR * src, char FAR * dest, COUNT t) { buf[0] = (src[0] | 0x20) + 'A' - 'a'; - if (buf[0] > lastdrive + 'A') + if (buf[0] >= lastdrive + 'A') return DE_PATHNOTFND; src += 2; From 2dca89f7ced60034003d36e3f2c9810ff0bfc67f Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sat, 31 Mar 2001 20:54:52 +0000 Subject: [PATCH 066/671] Made SHELLHIGH behave more like LOADHIGH. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@184 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/task.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/kernel/task.c b/kernel/task.c index 5440b6ef..4c3243f5 100644 --- a/kernel/task.c +++ b/kernel/task.c @@ -35,6 +35,9 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.9 2001/03/31 20:54:52 bartoldeman + * Made SHELLHIGH behave more like LOADHIGH. + * * Revision 1.8 2001/03/30 19:30:06 bartoldeman * Misc fixes and implementation of SHELLHIGH. See history.txt for details. * @@ -706,6 +709,12 @@ COUNT DosExeLoader(BYTE FAR * namep, exec_blk FAR * exp, COUNT mode) if (mode != OVERLAY) { + if ( ModeLoadHigh && uppermem_root) + { + DosUmbLink(1); /* link in UMB's */ + mem_access_mode |= ModeLoadHigh; + } + /* Now find out how many paragraphs are available */ if ((rc = DosMemLargest((seg FAR *) & asize)) != SUCCESS) { @@ -734,11 +743,6 @@ COUNT DosExeLoader(BYTE FAR * namep, exec_blk FAR * exp, COUNT mode) } */ - if ( ModeLoadHigh && uppermem_root) - { - DosUmbLink(1); /* link in UMB's */ - } - /* Allocate our memory and pass back any errors */ /* We can still get an error on first fit if the above */ /* returned size was a bet fit case */ @@ -789,6 +793,7 @@ COUNT DosExeLoader(BYTE FAR * namep, exec_blk FAR * exp, COUNT mode) if ( ModeLoadHigh && uppermem_root) { + mem_access_mode &= ~ModeLoadHigh; /* restore old situation */ DosUmbLink(UMBstate); /* restore link state */ } From 7c122b085032943756bcea048444870ffe9a1bd6 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Mon, 2 Apr 2001 23:18:30 +0000 Subject: [PATCH 067/671] Misc, zero terminated device names and redirector bugs fixed. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@188 6ac86273-5f31-0410-b378-82cca8765d1b --- docs/history.txt | 26 +++++++++++ kernel/config.c | 21 ++++----- kernel/dosfns.c | 58 ++++++++++++++++--------- kernel/entry.asm | 4 ++ kernel/execrh.asm | 37 ++++++++++++---- kernel/fatdir.c | 76 ++++++++++++++++---------------- kernel/globals.h | 9 +++- kernel/int2f.asm | 24 ++++++++--- kernel/inthndlr.c | 19 +++++--- kernel/memmgr.c | 9 +++- kernel/network.c | 7 ++- kernel/newstuff.c | 107 ++++++++++++++++++++++++---------------------- 12 files changed, 246 insertions(+), 151 deletions(-) diff --git a/docs/history.txt b/docs/history.txt index 1b2cb6a4..a3d6c657 100644 --- a/docs/history.txt +++ b/docs/history.txt @@ -1,3 +1,29 @@ +2001 Apr 2 - Build 2023 +-------- Bart Oldeman (bart.oldeman@bristol.ac.uk) ++ Fixes Bart: Volkov Commander revealed a few bugs: + -int 21/ah=55 forgot to set current psp to child psp. + -memory allocation: mem_access_mode was a signed byte, and hence 0x80 was + translated to 0xff80 and not 0x0080 when converting to a COUNT. Hence + changed it to become a UBYTE. + -An error in memmgr.c: search again in low mem for modes 0x80,81,82, not + 0x40,0x41,0x42 + * execrh.asm & int2f.asm: made code executable on a 8088 (no push + constant) + * entry.asm: made sure dos_crit_sect is executed when required to. + * Another redirector fix. int 2f/1122 needed DS=current psp. This caused a + bug for me: after compiling FreeCOM on a redirected drive "dir" did not + work any more. + * The nansi.sys problem: as it was, the initialisation phase of nansi + called int/ah=30, which checked control-break, which checks the console + driver, which at that point is the still not initialized nansi. This + messed up the request header passed to it. A solution I found is to link + a device into the device chain _after_ initialisation, not before. + * Redirector fix: network.c uses fmemcpy instead of fsncopy. + * Fixed INT 21/AH=6 (direct console input). + Tom: + * DE_NFILES instead of DE_FILENOTFOUND to allow Volkov Commander to browse empty + drives. + * Fixed bug wrt zero terminated device names (should be spaces terminated). 2001 Mar 30 - Build 2023 -------- Bart Oldeman (bart.oldeman@bristol.ac.uk) + Fixes Tom: Kernel alloc initialises to 0. This avoids some weird errors. diff --git a/kernel/config.c b/kernel/config.c index de44f74a..09679099 100644 --- a/kernel/config.c +++ b/kernel/config.c @@ -40,6 +40,9 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.16 2001/04/02 23:18:30 bartoldeman + * Misc, zero terminated device names and redirector bugs fixed. + * * Revision 1.15 2001/03/30 22:27:42 bartoldeman * Saner lastdrive handling. * @@ -1034,16 +1037,6 @@ INIT BOOL LoadDevice(BYTE * pLine, COUNT top, COUNT mode) for ( ; ; ) { - struct dhdr FAR *previous_nul_dhp; - - previous_nul_dhp = nul_dev.dh_next; - - next_dhp = dhp->dh_next; - - /* Link in device driver and save nul_dev pointer to next */ - dhp->dh_next = nul_dev.dh_next; - nul_dev.dh_next = dhp; - /* that's a nice hack >:-) although we don't want HIMEM.SYS,(it's not free), other people @@ -1068,8 +1061,12 @@ INIT BOOL LoadDevice(BYTE * pLine, COUNT top, COUNT mode) /* end of HIMEM.SYS HACK */ result=init_device(dhp, pTmp, mode, top); - if(result){ - nul_dev.dh_next = previous_nul_dhp; /* return orig pointer if error */ + + if(!result){ + next_dhp = dhp->dh_next; + /* Link in device driver and save nul_dev pointer to next */ + dhp->dh_next = nul_dev.dh_next; + nul_dev.dh_next = dhp; } /* multiple devices end */ diff --git a/kernel/dosfns.c b/kernel/dosfns.c index 0e09f530..da67c3dc 100644 --- a/kernel/dosfns.c +++ b/kernel/dosfns.c @@ -37,6 +37,9 @@ static BYTE *dosfnsRcsId = "$Id$"; * /// Added SHARE support. 2000/09/04 Ron Cemer * * $Log$ + * Revision 1.14 2001/04/02 23:18:30 bartoldeman + * Misc, zero terminated device names and redirector bugs fixed. + * * Revision 1.13 2001/03/30 22:27:42 bartoldeman * Saner lastdrive handling. * @@ -277,8 +280,8 @@ UCOUNT GenericRead(COUNT hndl, UCOUNT n, BYTE FAR * bp, COUNT FAR * err, BOOL force_binary) { sft FAR *s; - WORD sys_idx; - sfttbl FAR *sp; +/* WORD sys_idx;*/ +/*sfttbl FAR *sp;*/ UCOUNT ReadCount; /* Test that the handle is valid */ @@ -406,8 +409,8 @@ UCOUNT DosRead(COUNT hndl, UCOUNT n, BYTE FAR * bp, COUNT FAR * err) UCOUNT DosWrite(COUNT hndl, UCOUNT n, BYTE FAR * bp, COUNT FAR * err) { sft FAR *s; - WORD sys_idx; - sfttbl FAR *sp; +/* WORD sys_idx;*/ +/*sfttbl FAR *sp;*/ UCOUNT WriteCount; /* Test that the handle is valid */ @@ -496,7 +499,7 @@ UCOUNT DosWrite(COUNT hndl, UCOUNT n, BYTE FAR * bp, COUNT FAR * err) } else { - REG WORD c, + REG WORD /*c,*/ cnt = n, spaces_left = 0, next_pos, @@ -703,7 +706,7 @@ static WORD get_free_hndl(void) return 0xff; } -static sft FAR *get_free_sft(WORD FAR * sft_idx) +sft FAR *get_free_sft(WORD FAR * sft_idx) { WORD sys_idx = 0; sfttbl FAR *sp; @@ -769,8 +772,8 @@ COUNT DosCreat(BYTE FAR * fname, COUNT attrib) WORD hndl, sft_idx; sft FAR *sftp; struct dhdr FAR *dhp; - BYTE FAR *froot; - WORD i; +/* BYTE FAR *froot;*/ +/* WORD i;*/ COUNT result, drive; /* get a free handle */ @@ -940,8 +943,8 @@ COUNT DosOpen(BYTE FAR * fname, COUNT mode) WORD sft_idx; sft FAR *sftp; struct dhdr FAR *dhp; - BYTE FAR *froot; - WORD i; +/* BYTE FAR *froot;*/ +/* WORD i;*/ COUNT drive, result; /* /// Added to adjust for filenames which begin with ".\" @@ -1192,12 +1195,13 @@ COUNT DosChangeDir(BYTE FAR * s) REG COUNT drive; COUNT result; BYTE FAR *p; - - /* don't do wildcard CHDIR --TE*/ - /* although this should be handled somewhere else */ + + /* don't do wildcard CHDIR --TE*/ for (p = s; *p; p++) if (*p == '*' || *p == '?') return DE_PATHNOTFND; + + drive = get_verify_drive(s); if (drive < 0 ) { @@ -1263,7 +1267,7 @@ COUNT DosFindNext(void) COUNT DosGetFtime(COUNT hndl, date FAR * dp, time FAR * tp) { sft FAR *s; - sfttbl FAR *sp; +/*sfttbl FAR *sp;*/ /* Test that the handle is valid */ if (hndl < 0) @@ -1292,7 +1296,7 @@ COUNT DosGetFtime(COUNT hndl, date FAR * dp, time FAR * tp) COUNT DosSetFtime(COUNT hndl, date FAR * dp, time FAR * tp) { sft FAR *s; - sfttbl FAR *sp; +/*sfttbl FAR *sp;*/ /* Test that the handle is valid */ if (hndl < 0) @@ -1469,7 +1473,7 @@ COUNT DosRename(BYTE FAR * path1, BYTE FAR * path2) drive1 = get_verify_drive(path1); result = truename(path1, PriPathName, FALSE); - if (result != SUCCESS) { + if (result != SUCCESS) { return result; } drive2 = get_verify_drive(path2); @@ -1575,21 +1579,22 @@ struct dhdr FAR * IsDevice(BYTE FAR * fname) struct dhdr FAR *dhp; BYTE FAR *froot; WORD i; + BYTE tmpPathName[FNAME_SIZE+1]; /* check for a device */ froot = get_root(fname); for (i = 0; i < FNAME_SIZE; i++) { if (*froot != '\0' && *froot != '.') - SecPathName[i] = *froot++; + tmpPathName[i] = *froot++; else break; } for (; i < FNAME_SIZE; i++) - SecPathName[i] = ' '; + tmpPathName[i] = ' '; - SecPathName[i] = 0; + tmpPathName[i] = 0; /* /// BUG!!! This is absolutely wrong. A filename of "NUL.LST" must be treated EXACTLY the same as a filename of "NUL". The existence or @@ -1600,10 +1605,23 @@ struct dhdr FAR * IsDevice(BYTE FAR * fname) if (*froot != '.') { */ + for (dhp = (struct dhdr FAR *)&nul_dev; dhp != (struct dhdr FAR *)-1; dhp = dhp->dh_next) { - if (fnmatch((BYTE FAR *) SecPathName, (BYTE FAR *) dhp->dh_name, FNAME_SIZE, FALSE)) + + /* BUGFIX: MSCD000<00> should be handled like MSCD000<20> TE */ + + char dev_name_buff[FNAME_SIZE]; + + int namelen = fstrlen(dhp->dh_name); + + memset(dev_name_buff, ' ', FNAME_SIZE); + + fmemcpy(dev_name_buff,dhp->dh_name, min(namelen,FNAME_SIZE)); + + if (fnmatch((BYTE FAR *) tmpPathName, (BYTE FAR *) dev_name_buff, FNAME_SIZE, FALSE)) { + memcpy(SecPathName, tmpPathName, i+1); return dhp; } } diff --git a/kernel/entry.asm b/kernel/entry.asm index bf4ad99d..e211299e 100644 --- a/kernel/entry.asm +++ b/kernel/entry.asm @@ -28,6 +28,9 @@ ; $Id$ ; ; $Log$ +; Revision 1.10 2001/04/02 23:18:30 bartoldeman +; Misc, zero terminated device names and redirector bugs fixed. +; ; Revision 1.9 2001/03/30 19:30:06 bartoldeman ; Misc fixes and implementation of SHELLHIGH. See history.txt for details. ; @@ -280,6 +283,7 @@ int21_reentry: jne int21_1 int21_user: + call dos_crit_sect mov bp,sp push ss push bp diff --git a/kernel/execrh.asm b/kernel/execrh.asm index fa5738b6..63fbad8d 100644 --- a/kernel/execrh.asm +++ b/kernel/execrh.asm @@ -30,6 +30,9 @@ ; $Id$ ; ; $Log$ +; Revision 1.5 2001/04/02 23:18:30 bartoldeman +; Misc, zero terminated device names and redirector bugs fixed. +; ; Revision 1.4 2001/03/21 02:56:25 bartoldeman ; See history.txt for changes. Bug fixes and HMA support are the main ones. ; @@ -102,16 +105,34 @@ _execrh: push es ; sometimes it get lost push ds - lds si,[bp+8] ; ds:si = device header - les bx,[bp+4] ; es:bx = request header + lds si,[bp+8] ; ds:si = device header + les bx,[bp+4] ; es:bx = request header - push cs ; do this, the right way! - push word exit_execrh ; like 68k code - push ds - push word [ds:si+8] ; interrupt - push ds - push word [ds:si+6] ; strategy + push ds ; needed later + push si + + mov bp, execrh_ret1 ; construct return frame + push cs + push bp + + push ds ; call far the strategy + push word [si+6] + + retf +execrh_ret1: + pop si ; these were saved + pop ds + + mov bp, execrh_ret2 ; construct return frame + push cs + push bp + + push ds ; call far the interrupt + push word [si+8] + retf +execrh_ret2: + exit_execrh: sti ; damm driver turn off ints cld ; has gone backwards pop ds diff --git a/kernel/fatdir.c b/kernel/fatdir.c index ec10e7c2..773bccbc 100644 --- a/kernel/fatdir.c +++ b/kernel/fatdir.c @@ -36,6 +36,9 @@ static BYTE *fatdirRcsId = "$Id$"; /* * $Log$ + * Revision 1.13 2001/04/02 23:18:30 bartoldeman + * Misc, zero terminated device names and redirector bugs fixed. + * * Revision 1.12 2001/03/30 22:27:42 bartoldeman * Saner lastdrive handling. * @@ -167,9 +170,9 @@ struct f_node FAR *dir_open(BYTE FAR * dirname) struct f_node FAR *fnp; COUNT drive; BYTE *p; - WORD i, - x; - BYTE *s; + WORD i; + /*TEunused x; */ +/* BYTE *s;*/ struct cds FAR *cdsp; BYTE *pszPath = &TempCDS.cdsCurrentPath[2]; @@ -209,18 +212,19 @@ struct f_node FAR *dir_open(BYTE FAR * dirname) release_f_node(fnp); return NULL; } - TempCDS.cdsDpb = CDSp->cds_table[drive].cdsDpb; cdsp = &CDSp->cds_table[drive]; + TempCDS.cdsDpb = cdsp->cdsDpb; + TempCDS.cdsCurrentPath[0] = 'A' + drive; TempCDS.cdsCurrentPath[1] = ':'; TempCDS.cdsJoinOffset = 2; - x = cdsp->cdsJoinOffset; + i = cdsp->cdsJoinOffset; /* Generate full path name */ - ParseDosPath(dirname, (COUNT *) 0, pszPath, (BYTE FAR *) & cdsp->cdsCurrentPath[x]); + ParseDosPath(dirname, (COUNT *) 0, pszPath, (BYTE FAR *) & cdsp->cdsCurrentPath[i]); /* for testing only for now */ #if 0 @@ -346,8 +350,9 @@ struct f_node FAR *dir_open(BYTE FAR * dirname) COUNT dir_read(REG struct f_node FAR * fnp) { - REG i; - REG j; +/* REG i; */ +/* REG j; */ + struct buffer FAR *bp; /* Directories need to point to their current offset, not for */ @@ -584,7 +589,7 @@ COUNT dos_findfirst(UCOUNT attr, BYTE FAR * name) REG COUNT i; COUNT nDrive; BYTE *p; - BYTE FAR *ptr; +/* BYTE FAR *ptr;*/ static BYTE local_name[FNAME_SIZE + 1], local_ext[FEXT_SIZE + 1]; @@ -678,35 +683,26 @@ COUNT dos_findfirst(UCOUNT attr, BYTE FAR * name) } } if (!wild) { - struct dhdr FAR *dhp; - for (dhp = (struct dhdr FAR *)&nul_dev; - dhp != (struct dhdr FAR *)-1; - dhp = dhp->dh_next) { - if (fnmatch - ((BYTE FAR *)&Name, - (BYTE FAR *)dhp->dh_name, - FNAME_SIZE, - FALSE)) { - /* Found a matching device. */ - dmp->dm_entry = 0; - dmp->dm_cluster = 0; - dmp->dm_flags.f_dmod = 0; - dmp->dm_flags.f_droot = 0; - dmp->dm_flags.f_dnew = 0; - dmp->dm_flags.f_ddir = 0; - dmp->dm_flags.f_dfull = 0; - dmp->dm_dirstart = 0; - dmp->dm_attr_fnd = D_DEVICE; - dmp->dm_time = dos_gettime(); - dmp->dm_date = dos_getdate(); - dmp->dm_size = 0L; - for (d = 0; ( (d < FNAME_SIZE) && (Name[d] != ' ') ); d++) - dmp->dm_name[d] = Name[d]; - dmp->dm_name[d] = '\0'; - return SUCCESS; + if (IsDevice(Name)) { + /* Found a matching device. */ + dmp->dm_entry = 0; + dmp->dm_cluster = 0; + dmp->dm_flags.f_dmod = 0; + dmp->dm_flags.f_droot = 0; + dmp->dm_flags.f_dnew = 0; + dmp->dm_flags.f_ddir = 0; + dmp->dm_flags.f_dfull = 0; + dmp->dm_dirstart = 0; + dmp->dm_attr_fnd = D_DEVICE; + dmp->dm_time = dos_gettime(); + dmp->dm_date = dos_getdate(); + dmp->dm_size = 0L; + for (d = 0; ( (d < FNAME_SIZE) && (Name[d] != ' ') ); d++) + dmp->dm_name[d] = Name[d]; + dmp->dm_name[d] = '\0'; + return SUCCESS; } } - } } /* /// End of additions. - Ron Cemer */ @@ -779,8 +775,8 @@ COUNT dos_findnext(void) REG dmatch FAR *dmp = (dmatch FAR *) dta; REG struct f_node FAR *fnp; BOOL found = FALSE; - BYTE FAR *p; - BYTE FAR *q; +/* BYTE FAR *p;*/ +/* BYTE FAR *q;*/ COUNT nDrive; /* assign our match parameters pointer. */ @@ -809,7 +805,7 @@ COUNT dos_findnext(void) #if 0 printf("findnext: %c %s\n", - nDrive + 'A', (cdsp->cdsFlags & CDSNETWDRV)?"remote":"local"); + nDrive + 'A', (current_ldt->cdsFlags & CDSNETWDRV)?"remote":"local"); #endif if (current_ldt->cdsFlags & CDSNETWDRV) @@ -891,7 +887,7 @@ COUNT dos_findnext(void) /* return the result */ release_f_node(fnp); - return found ? SUCCESS : DE_FILENOTFND; + return found ? SUCCESS : DE_NFILES; } static VOID pop_dmp(dmatch FAR * dmp, struct f_node FAR * fnp) diff --git a/kernel/globals.h b/kernel/globals.h index c8a69350..005b8dc2 100644 --- a/kernel/globals.h +++ b/kernel/globals.h @@ -36,6 +36,9 @@ static BYTE *Globals_hRcsId = "$Id$"; /* * $Log$ + * Revision 1.10 2001/04/02 23:18:30 bartoldeman + * Misc, zero terminated device names and redirector bugs fixed. + * * Revision 1.9 2001/03/30 20:11:14 bartoldeman * Truly got DOS=HIGH reporting for INT21/AX=0x3306 working now. * @@ -480,8 +483,10 @@ extern BYTE extern struct dhdr nul_dev; extern BYTE - LocalPath[PARSE_MAX + 3], /* Room for drive spec */ - mem_access_mode, /* memory allocation scheme */ + LocalPath[PARSE_MAX + 3]; /* Room for drive spec */ +extern UBYTE + mem_access_mode; /* memory allocation scheme */ +extern BYTE ErrorMode, /* Critical error flag */ InDOS, /* In DOS critical section */ OpenMode, /* File Open Attributes */ diff --git a/kernel/int2f.asm b/kernel/int2f.asm index 57ce2e8d..9da2917a 100644 --- a/kernel/int2f.asm +++ b/kernel/int2f.asm @@ -30,6 +30,9 @@ ; $Id$ ; ; $Log$ +; Revision 1.8 2001/04/02 23:18:30 bartoldeman +; Misc, zero terminated device names and redirector bugs fixed. +; ; Revision 1.7 2001/03/21 02:56:26 bartoldeman ; See history.txt for changes. Bug fixes and HMA support are the main ones. ; @@ -95,6 +98,7 @@ segment HMA_TEXT extern _nul_dev:wrt DGROUP extern _umb_start:wrt DGROUP extern _UMB_top:wrt DGROUP + extern _cu_psp:wrt DGROUP extern _syscall_MUX14:wrt HMA_TEXT global reloc_call_int2f_handler @@ -210,7 +214,7 @@ int2f_skip1: xor ax,ax les di,[bp+18] ; do return data stuff mov [es:di],cx - jmp short int2f_rfner + jmp int2f_rfner int2f_r_2: cmp al,0ch ; Get Remote DPB jne short int2f_r_3 @@ -262,9 +266,15 @@ int2f_r_6: xor ax,ax jmp short int2f_rfner int2f_r_7: + cmp al,022h ; Terminate process + jne short int2f_r_8 + mov ds,[_cu_psp] + call int2f_call + jmp short int2f_rfner ; ; everything else goes through here. ; +int2f_r_8: call int2f_call jc int2f_rfner xor ax,ax @@ -364,12 +374,13 @@ _Umb_Test push es ; save driver entry point push bx - mov dx,0xffff ; go for broke! - mov ax,1000h ; get the umb's push cs ; setup far return - push word umbt1 + mov ax, umbt1 + push ax push es ; push the driver entry point push bx + mov dx,0xffff ; go for broke! + mov ax,1000h ; get the umb's retf ; Call the driver umbt1: ; @@ -389,11 +400,12 @@ umbtc: pop bx ; restore driver entry pop es - mov ax,1000h ; dx set with largest size push cs - push word umbt2 + mov ax, umbt2 + push ax push es push bx + mov ax,1000h ; dx set with largest size retf umbt2: cmp ax,1 diff --git a/kernel/inthndlr.c b/kernel/inthndlr.c index 085200fd..a205d12b 100644 --- a/kernel/inthndlr.c +++ b/kernel/inthndlr.c @@ -36,6 +36,9 @@ BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.19 2001/04/02 23:18:30 bartoldeman + * Misc, zero terminated device names and redirector bugs fixed. + * * Revision 1.18 2001/03/30 22:27:42 bartoldeman * Saner lastdrive handling. * @@ -428,13 +431,13 @@ VOID int21_service(iregs FAR * r) sto(r->DL); else if (StdinBusy()) { - r->AL = 0x00; - r->FLAGS |= FLG_ZERO; + r->FLAGS &= ~FLG_ZERO; + r->AL = _sti(); } else { - r->FLAGS &= ~FLG_ZERO; - r->AL = _sti(); + r->AL = 0x00; + r->FLAGS |= FLG_ZERO; } break; @@ -1294,6 +1297,7 @@ VOID int21_service(iregs FAR * r) /* Dos Create New Psp & set p_size */ case 0x55: new_psp((psp FAR *) MK_FP(r->DX, 0), r->SI); + cu_psp = r->DX; break; /* Dos Rename */ @@ -1343,12 +1347,13 @@ VOID int21_service(iregs FAR * r) switch (r->AL) { case 0x00: - r->AX = mem_access_mode; + r->AL = mem_access_mode; + r->AH = 0; break; case 0x01: { - switch (r->BX) + switch (r->BL) { case LAST_FIT: case LAST_FIT_U: @@ -1360,7 +1365,7 @@ VOID int21_service(iregs FAR * r) case FIRST_FIT: case FIRST_FIT_U: case FIRST_FIT_UO: - mem_access_mode = r->BX; + mem_access_mode = r->BL; break; default: diff --git a/kernel/memmgr.c b/kernel/memmgr.c index 353cf4c6..3e881fda 100644 --- a/kernel/memmgr.c +++ b/kernel/memmgr.c @@ -35,6 +35,9 @@ static BYTE *memmgrRcsId = "$Id$"; /* * $Log$ + * Revision 1.11 2001/04/02 23:18:30 bartoldeman + * Misc, zero terminated device names and redirector bugs fixed. + * * Revision 1.10 2001/03/30 19:30:06 bartoldeman * Misc fixes and implementation of SHELLHIGH. See history.txt for details. * @@ -286,9 +289,9 @@ COUNT DosMemAlloc(UWORD size, COUNT mode, seg FAR * para, UWORD FAR * asize) if (!foundSeg || !foundSeg->m_size) { /* no block to fullfill the request */ - if((mode != LARGEST) && (mode & FIRST_FIT_UO) && + if((mode != LARGEST) && (mode & FIRST_FIT_U) && uppermem_link && uppermem_root) { - mode &= !FIRST_FIT_UO; + mode &= ~FIRST_FIT_U; goto searchAgain; } if (asize) @@ -603,6 +606,7 @@ COUNT DosGetLargestBlock(UWORD FAR * block) } #endif +#ifdef DEBUG VOID show_chain(void) { mcb FAR *p, FAR *u; @@ -617,6 +621,7 @@ VOID show_chain(void) p = nxtMCB(p); } } +#endif VOID mcb_print(mcb FAR * mcbp) { diff --git a/kernel/network.c b/kernel/network.c index 7d0afad3..75db9daa 100644 --- a/kernel/network.c +++ b/kernel/network.c @@ -36,6 +36,9 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.10 2001/04/02 23:18:30 bartoldeman + * Misc, zero terminated device names and redirector bugs fixed. + * * Revision 1.9 2001/03/30 19:30:06 bartoldeman * Misc fixes and implementation of SHELLHIGH. See history.txt for details. * @@ -144,12 +147,12 @@ COUNT Remote_find(UWORD func, BYTE FAR * name, REG dmatch FAR * dmp ) else test = (VOID FAR *) &TempBuffer; - fsncopy(dta, (BYTE FAR *) &TempBuffer, 21); + fmemcpy((BYTE FAR *) &TempBuffer, dta, 21); p = dta; dta = (BYTE FAR *) &TempBuffer; i = int2f_Remote_call(func, 0, 0, 0, test, 0, 0); dta = p; - fsncopy((BYTE FAR *) &TempBuffer, dta, 21); + fmemcpy(dta, (BYTE FAR *) &TempBuffer, 21); if (i != 0) return i; diff --git a/kernel/newstuff.c b/kernel/newstuff.c index fa270f7e..8bb0a927 100644 --- a/kernel/newstuff.c +++ b/kernel/newstuff.c @@ -31,6 +31,9 @@ static BYTE *mainRcsId = "$Id$"; /* * $Log$ + * Revision 1.10 2001/04/02 23:18:30 bartoldeman + * Misc, zero terminated device names and redirector bugs fixed. + * * Revision 1.9 2001/03/30 22:27:42 bartoldeman * Saner lastdrive handling. * @@ -113,6 +116,10 @@ static BYTE *mainRcsId = "$Id$"; #include "globals.h" #include "proto.h" +/* + TE-TODO: if called repeatedly by same process, + last allocation must be freed. if handle count < 20, copy back to PSP +*/ int SetJFTSize(UWORD nHandles) { UWORD block, @@ -236,13 +243,27 @@ COUNT get_verify_drive(char FAR *src) * MSD returns \\D.\A.\????????.??? with SHSUCDX. So, this code is not * compatible MSD Func 60h. */ + +/*TE TODO: + + experimenting with NUL on MSDOS 7.0 (win95) + + WIN95 FREEDOS + TRUENAME NUL C:/NUL OK + TRUENAME .\NUL C:\DOS\NUL + TRUENAME ..\NUL C:\NUL + TRUENAME ..\..\NUL path not found + TRUENAME Z:NUL invalid drive (not lastdrive!!) + TRUENAME A:NUL A:/NUL OK + TRUENAME A:\NUL A:\NUL + +*/ + COUNT truename(char FAR * src, char FAR * dest, COUNT t) { static char buf[128] = "A:\\\0\0\0\0\0\0\0\0\0"; - /* /// Changed to FNAME_SIZE from 8 for cleanliness. - Ron Cemer */ - static char Name[FNAME_SIZE]; char *bufp = buf + 3; - COUNT i, n, rootEndPos = 2; /* renamed x to rootEndPos - Ron Cemer */ + COUNT i, rootEndPos = 2; /* renamed x to rootEndPos - Ron Cemer */ struct cds FAR *cdsp; struct dhdr FAR *dhp; BYTE FAR *froot; @@ -258,8 +279,8 @@ COUNT truename(char FAR * src, char FAR * dest, COUNT t) { buf[0] = (src[0] | 0x20) + 'A' - 'a'; - if (buf[0] >= lastdrive + 'A') - return DE_PATHNOTFND; + if (buf[0] >= lastdrive + 'A') /* BUG:should be: drive exists */ + return DE_INVLDDRV; src += 2; } @@ -282,62 +303,44 @@ COUNT truename(char FAR * src, char FAR * dest, COUNT t) MSD returns X:/CON for truename con. Not X:\CON */ /* check for a device */ - froot = get_root(src); - for (d = 0; d < FNAME_SIZE; d++) - { - if (*froot != '\0' && *froot != '.') - Name[d] = *froot++; - else - break; - } - for (; d < FNAME_SIZE; d++) - Name[d] = ' '; + if ((dhp = IsDevice(src)) != NULL) + { + + froot = get_root(src); /* /// Bugfix: NUL.LST is the same as NUL. This is true for all devices. On a device name, the extension is irrelevant as long as the name matches. - Ron Cemer */ -#if (0) - /* if we have an extension, can't be a device */ - if (*froot != '.') - { -#endif - for (dhp = (struct dhdr FAR *)&nul_dev; dhp != (struct dhdr FAR *)-1; dhp = dhp->dh_next) - { - if (fnmatch((BYTE FAR *) &Name, (BYTE FAR *) dhp->dh_name, FNAME_SIZE, FALSE)) - { - buf[2] ='/'; - /* /// Bug: should be only copying up to first space. - - Ron Cemer - for (d = 0; d < FNAME_SIZE || Name[d] == ' '; d++) */ - for (d = 0; ( (d < FNAME_SIZE) && (Name[d] != ' ') ); d++) - *bufp++ = Name[d]; - /* /// DOS will return C:/NUL.LST if you pass NUL.LST in. - DOS will also return C:/NUL.??? if you pass NUL.* in. - Code added here to support this. - - Ron Cemer */ - while ( (*froot != '.') && (*froot != '\0') ) froot++; - if (*froot) froot++; - if (*froot) { - *bufp++ = '.'; - for (i = 0; i < FEXT_SIZE; i++) { - if ( (*froot == '\0') || (*froot == '.') ) - break; - if (*froot == '*') { - for (; i < FEXT_SIZE; i++) *bufp++ = '?'; - break; - } - *bufp++ = *froot++; + + buf[2] ='/'; + /* /// Bug: should be only copying up to first space. + - Ron Cemer */ + + for (d = 0; d < FNAME_SIZE && dhp->dh_name[d] != 0 && dhp->dh_name[d] != ' '; d++) + *bufp++ = dhp->dh_name[d]; + /* /// DOS will return C:/NUL.LST if you pass NUL.LST in. + DOS will also return C:/NUL.??? if you pass NUL.* in. + Code added here to support this. + - Ron Cemer */ + while ( (*froot != '.') && (*froot != '\0') ) froot++; + if (*froot) froot++; + if (*froot) { + *bufp++ = '.'; + for (i = 0; i < FEXT_SIZE; i++) { + if ( (*froot == '\0') || (*froot == '.') ) + break; + if (*froot == '*') { + for (; i < FEXT_SIZE; i++) *bufp++ = '?'; + break; } + *bufp++ = *froot++; } - /* /// End of code additions. - Ron Cemer */ - goto exit_tn; - } } -#if (0) + /* /// End of code additions. - Ron Cemer */ + goto exit_tn; } -#endif cdsp = &CDSp->cds_table[i]; current_ldt = cdsp; @@ -370,7 +373,7 @@ COUNT truename(char FAR * src, char FAR * dest, COUNT t) else src++; -move_name: +/*move_name:*/ /* /// The block inside the "#if (0) ... #endif" is seriously broken. New code added below to replace it. From 3c89f5ae00af1c9d0d9d62fce49931b2763b0fee Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sun, 15 Apr 2001 02:23:43 +0000 Subject: [PATCH 068/671] apisupt.asm is not necessary anymore. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@194 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/apisupt.asm | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/kernel/apisupt.asm b/kernel/apisupt.asm index c3cf50bc..93cad345 100644 --- a/kernel/apisupt.asm +++ b/kernel/apisupt.asm @@ -27,6 +27,9 @@ ; $Id$ ; ; $Log$ +; Revision 1.6 2001/04/15 02:23:43 bartoldeman +; apisupt.asm is not necessary anymore. +; ; Revision 1.5 2001/03/22 20:46:46 bartoldeman ; cli/sti corrections (Bart) and int25, 26 stack corrections (Tom) ; @@ -86,6 +89,7 @@ extern _usr_ss:wrt DGROUP segment HMA_TEXT +%if 0 global _set_stack ; ; void set_stack(void) - @@ -176,3 +180,4 @@ _restore_stack: popf ret +%endif From 832ad2111bd3cabed9251779c80ee6e4cdd2bc8a Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sun, 15 Apr 2001 02:26:23 +0000 Subject: [PATCH 069/671] Hans Lermen: critical error handler destroyed AH (entry.asm). git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@195 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/entry.asm | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/kernel/entry.asm b/kernel/entry.asm index e211299e..b4b0fdb1 100644 --- a/kernel/entry.asm +++ b/kernel/entry.asm @@ -28,6 +28,9 @@ ; $Id$ ; ; $Log$ +; Revision 1.11 2001/04/15 02:26:23 bartoldeman +; Hans Lermen: critical error handler destroyed AH (entry.asm). +; ; Revision 1.10 2001/04/02 23:18:30 bartoldeman ; Misc, zero terminated device names and redirector bugs fixed. ; @@ -91,8 +94,6 @@ segment HMA_TEXT extern _int21_syscall:wrt HGROUP extern _int21_service:wrt HGROUP extern _int2526_handler:wrt HGROUP - extern _set_stack:wrt HGROUP - extern _restore_stack:wrt HGROUP extern _error_tos:wrt DGROUP extern _char_api_tos:wrt DGROUP extern _disk_api_tos:wrt DGROUP @@ -619,6 +620,8 @@ CritErr05: mov es,[_cu_psp] pop word [es:PSP_USERSP] pop word [es:PSP_USERSS] + mov bp, sp + mov ah, byte [bp+4+4] ; restore old AH from nFlags sti ; Enable interrupts ; ; clear flags @@ -629,7 +632,7 @@ CritErr05: ; Check for ignore and force fail if not ok cmp al,CONTINUE jne CritErr10 ; not ignore, keep testing - test bh,OK_IGNORE + test ah,OK_IGNORE jnz CritErr10 mov al,FAIL ; @@ -638,7 +641,7 @@ CritErr05: CritErr10: cmp al,RETRY jne CritErr20 ; not retry, keep testing - test bh,OK_RETRY + test ah,OK_RETRY jnz CritErr20 mov al,FAIL ; @@ -648,7 +651,7 @@ CritErr10: CritErr20: cmp al,FAIL jne CritErr30 ; not fail, do exit processing - test bh,OK_FAIL + test ah,OK_FAIL jnz CritErr30 mov al,ABORT ; From be2ae12b541f84c01f69f53a4d15e406e5225c54 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sun, 15 Apr 2001 03:21:50 +0000 Subject: [PATCH 070/671] See history.txt for the list of fixes. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@196 6ac86273-5f31-0410-b378-82cca8765d1b --- config.m | 7 +- docs/history.txt | 43 ++++++ drivers/devend.asm | 7 +- drivers/floppy.asm | 12 +- drivers/getvec.asm | 11 +- drivers/rdatclk.asm | 52 +++---- drivers/rdpcclk.asm | 5 +- drivers/timer.asm | 35 ++--- drivers/wratclk.asm | 21 ++- drivers/wrpcclk.asm | 15 +-- hdr/cds.h | 4 + hdr/dcb.h | 6 +- hdr/device.h | 9 +- hdr/fat.h | 7 +- hdr/fnode.h | 5 +- hdr/mcb.h | 5 +- hdr/pcb.h | 5 +- hdr/portab.h | 12 +- kernel/asmsupt.asm | 148 ++++++-------------- kernel/blockio.c | 5 +- kernel/break.c | 27 +--- kernel/chario.c | 12 +- kernel/config.c | 157 ++++++++++------------ kernel/console.asm | 7 +- kernel/dosfns.c | 159 ++++++++++------------ kernel/dosnames.c | 5 +- kernel/dsk.c | 32 ++--- kernel/error.c | 7 +- kernel/execrh.asm | 64 +++------ kernel/fatdir.c | 97 ++++++------- kernel/fatfs.c | 142 ++++++++------------ kernel/fattab.c | 39 +++--- kernel/fcbfns.c | 197 ++++++++------------------- kernel/globals.h | 21 ++- kernel/init-mod.h | 7 +- kernel/inithma.c | 79 +++++++---- kernel/inthndlr.c | 321 +++++++++++++++++--------------------------- kernel/intr.asm | 83 +++++++++++- kernel/ioctl.c | 67 ++++----- kernel/kernel.asm | 248 ++++++++++++++++++---------------- kernel/kernel.mak | 16 ++- kernel/main.c | 198 +++++++++++---------------- kernel/memmgr.c | 97 +++++++++---- kernel/misc.c | 22 +-- kernel/network.c | 9 +- kernel/newstuff.c | 97 ++++++------- kernel/nls.c | 5 +- kernel/prf.c | 19 ++- kernel/procsupt.asm | 36 +++-- kernel/proto.h | 109 +++++++-------- kernel/segs.inc | 12 +- kernel/strings.c | 13 +- kernel/sysclk.c | 14 +- kernel/systime.c | 8 +- kernel/task.c | 99 +++++++------- sys/sys.mak | 21 ++- 56 files changed, 1393 insertions(+), 1567 deletions(-) diff --git a/config.m b/config.m index b2911b02..363a6b4c 100644 --- a/config.m +++ b/config.m @@ -8,7 +8,9 @@ # These are generic definitions RM=..\utils\rm -f -NASM=nasm + +# Give path to nasm here (or if it's in your path just uncomment the line). +#NASM=nasm # Use these for Turbo C 2.01 @@ -54,6 +56,9 @@ # $Id$ # # $Log$ +# Revision 1.6 2001/04/15 03:21:49 bartoldeman +# See history.txt for the list of fixes. +# # Revision 1.5 2001/03/22 10:51:04 bartoldeman # Suggest to extract F_SCOPY into libm.lib for Borland C++. # diff --git a/docs/history.txt b/docs/history.txt index a3d6c657..67cb6133 100644 --- a/docs/history.txt +++ b/docs/history.txt @@ -1,3 +1,46 @@ +2001 Apr 15 - Build 2023 +-------- Bart Oldeman (bart.oldeman@bristol.ac.uk) ++ Fixes Tom: + * apisupt.asm not necessary anymore. + * fix warnings. + * Don't allow directories to be created in DOS_CREAT. + * LoadDevice: drivers should not hang the computer if they fail. + Bart: + * fixed SYS. + * made most calls near again, with a jump/stack trick to + switch between INIT_TEXT and HMA_TEXT. + * INIT_TEXT now calls INT21 itself for some things (setting + PSP, opening/reading/closing devices and (fd)config.sys). + * fixed some carry handling in inthndlr.c and + * drives are checked before trying to access them. + * fixed console driver "busy state" confusion: the built-in + driver had it wrong, nansi.sys had it right: + "If no characters in buffer, return BUSY". + * space savings (RTL related and various other places) + * redirector fixes for find_next. + * CREAT on a device file failed (FD said it already existed). + But for some reason it should not fail in DOS. + * get ATTRIB/other things on a device file should return + FILENOTFOUND, not PATHNOTFOUND. + The sft_status field is not used for redirected drives. + * DosSelectDrv checks the media before setting the default + drive. + * Fixed INT21/AH=3,4,5 (character R/W AUX/PRN). + Hans Lermen: + * critical error handler destroyed AH (entry.asm). + Martin Stromberg + * find_first for volume labels fix. + * check drive at more places and avoid drive "@:" for drive "':". + * config.m: comment out NASM= by default. + * printf fix with DEBUG on. ++ Add Tom: Introduce init_data segment. + New temp file creation implementation. + Bart: added INT21/AH=53. XMSDSK works fine now. + dynamic allocation of Drive Parameter Blocks (they are + all FAR now). ++ Update Bart: moved DOS_PSP to segment 0x60 as segment 0x50 is already used by + GWBASIC/BASICA + 2001 Apr 2 - Build 2023 -------- Bart Oldeman (bart.oldeman@bristol.ac.uk) + Fixes Bart: Volkov Commander revealed a few bugs: diff --git a/drivers/devend.asm b/drivers/devend.asm index 30bff1ef..30031b17 100644 --- a/drivers/devend.asm +++ b/drivers/devend.asm @@ -30,6 +30,9 @@ ; $Header$ ; ; $Log$ +; Revision 1.5 2001/04/15 03:21:50 bartoldeman +; See history.txt for the list of fixes. +; ; Revision 1.4 2001/03/21 02:56:25 bartoldeman ; See history.txt for changes. Bug fixes and HMA support are the main ones. ; @@ -72,7 +75,6 @@ %include "..\kernel\segs.inc" -segment _DATA align=2 class=DATA extern __bssend:wrt DGROUP segment HMA_TEXT @@ -80,9 +82,6 @@ segment HMA_TEXT global _device_end _device_end: - push bp - mov bp,sp mov ax,__bssend mov dx,DGROUP - pop bp ret diff --git a/drivers/floppy.asm b/drivers/floppy.asm index aa502ccc..a48273b2 100644 --- a/drivers/floppy.asm +++ b/drivers/floppy.asm @@ -30,6 +30,9 @@ ; $Id$ ; ; $Log$ +; Revision 1.5 2001/04/15 03:21:50 bartoldeman +; See history.txt for the list of fixes. +; ; Revision 1.4 2001/03/21 02:56:25 bartoldeman ; See history.txt for changes. Bug fixes and HMA support are the main ones. ; @@ -80,8 +83,13 @@ ;Initial revision. ; - %include "..\kernel\segs.inc" - +%ifndef SYS + %include "..\kernel\segs.inc" +%else +group TGROUP HMA_TEXT _TEXT +segment _TEXT class=CODE +segment HMA_TEXT class=CODE +%endif segment HMA_TEXT ; diff --git a/drivers/getvec.asm b/drivers/getvec.asm index 1dd298e6..73a7aaf1 100644 --- a/drivers/getvec.asm +++ b/drivers/getvec.asm @@ -30,6 +30,9 @@ ; $Header$ ; ; $Log$ +; Revision 1.5 2001/04/15 03:21:50 bartoldeman +; See history.txt for the list of fixes. +; ; Revision 1.4 2001/03/21 02:56:25 bartoldeman ; See history.txt for changes. Bug fixes and HMA support are the main ones. ; @@ -75,12 +78,8 @@ segment HMA_TEXT global _getvec _getvec: - push bp - mov bp,sp - mov ax,[bp+4] - call getvec - pop bp - ret + mov bx,sp + mov ax,[ss:bx+2] ; ; assembler version - ax = vector number diff --git a/drivers/rdatclk.asm b/drivers/rdatclk.asm index 8f66e6d4..b98870bd 100644 --- a/drivers/rdatclk.asm +++ b/drivers/rdatclk.asm @@ -60,9 +60,9 @@ ;Initial revision. ; -group IGROUP INIT_TEXT + %include "..\kernel\segs.inc" -segment INIT_TEXT class=INIT +segment INIT_TEXT ; ;COUNT ReadATClock(bcdDays, bcdHours, bcdMinutes, bcdSeconds) @@ -73,49 +73,29 @@ segment INIT_TEXT class=INIT ; global _ReadATClock _ReadATClock: + mov ah,2 + int 1ah + jnc @RdAT1140 + sbb ax,ax + ret +@RdAT1140: push bp mov bp,sp - sub sp,byte 10 -; Days = -6 -; Hours = -2 -; Minutes = -8 -; Seconds = -10 ; bcdSeconds = 10 ; bcdMinutes = 8 ; bcdHours = 6 ; bcdDays = 4 - mov ah,2 - int 26 - jnc @RdAT1140 - sbb ax,ax - mov sp,bp - pop bp - ret - nop -@RdAT1140: - mov byte [bp-2],ch ;Hours - mov byte [bp-8],cl ;Minutes - mov byte [bp-10],dh ;Seconds - mov ah,4 - int 26 - mov word [bp-6],dx ;Days - mov word [bp-4],cx - mov ax,word [bp-6] ;Days - mov dx,word [bp-4] - mov bx,word [bp+4] ;bcdDays - mov word [bx],ax - mov word [bx+2],dx - mov al,byte [bp-2] ;Hours mov bx,word [bp+6] ;bcdHours - mov byte [bx],al - mov al,byte [bp-8] ;Minutes + mov byte [bx],ch ;Hours mov bx,word [bp+8] ;bcdMinutes - mov byte [bx],al - mov al,byte [bp-10] ;Seconds + mov byte [bx],cl ;Minutes mov bx,word [bp+10] ;bcdSeconds - mov byte [bx],al + mov byte [bx],dh ;Seconds + mov ah,4 + int 1ah + mov bx,word [bp+4] ;bcdDays + mov word [bx],dx ;Days + mov word [bx+2],cx sub ax,ax - mov sp,bp pop bp ret - nop diff --git a/drivers/rdpcclk.asm b/drivers/rdpcclk.asm index 4288a80b..12b52a89 100644 --- a/drivers/rdpcclk.asm +++ b/drivers/rdpcclk.asm @@ -30,6 +30,9 @@ ; $Header$ ; ; $Log$ +; Revision 1.5 2001/04/15 03:21:50 bartoldeman +; See history.txt for the list of fixes. +; ; Revision 1.4 2001/03/21 02:56:25 bartoldeman ; See history.txt for changes. Bug fixes and HMA support are the main ones. ; @@ -84,7 +87,7 @@ segment HMA_TEXT global _ReadPCClock _ReadPCClock: xor ah,ah - int 26 + int 1ah mov bx,sp mov bx,[bx+2] mov [bx],dx diff --git a/drivers/timer.asm b/drivers/timer.asm index 5600daa2..757eb955 100644 --- a/drivers/timer.asm +++ b/drivers/timer.asm @@ -30,6 +30,9 @@ ; $Header$ ; ; $Log$ +; Revision 1.5 2001/04/15 03:21:50 bartoldeman +; See history.txt for the list of fixes. +; ; Revision 1.4 2001/03/21 02:56:25 bartoldeman ; See history.txt for changes. Bug fixes and HMA support are the main ones. ; @@ -78,14 +81,11 @@ segment HMA_TEXT ; global _tmark _tmark: - push bp - mov bp,sp xor ah,ah int 01aH ; get current time in ticks xor ah,ah mov word [LastTime],dx ; and store it mov word [LastTime+2],cx - pop bp ret @@ -96,12 +96,11 @@ _tmark: _tdelay: push bp mov bp,sp - sub sp,byte 4 xor ah,ah int 01aH ; get current time in ticks xor ah,ah - mov word [bp-4],dx ; and save it to a local variable - mov word [bp-2],cx ; "Ticks" + mov word bx,dx ; and save it to a local variable + ; "Ticks" (cx:bx) ; ; Do a c equivalent of: ; @@ -111,19 +110,16 @@ _tdelay: mov dx,word [LastTime] add dx,word [bp+4] adc ax,word [bp+6] - cmp ax,word [bp-2] + cmp ax,cx + mov ax,0 ; mov does not affect flags ja short tdel_1 jne short tdel_2 - cmp dx,word [bp-4] + cmp dx,bx ja short tdel_1 tdel_2: - mov ax,1 ; True return - jmp short tdel_3 + inc ax ; True return tdel_1: - xor ax,ax ; False return -tdel_3: - mov sp,bp - pop bp + pop bp ; False return ret @@ -134,7 +130,6 @@ tdel_3: _twait: push bp mov bp,sp - sub sp,byte 4 call _tmark ; mark a start ; ; c equivalent @@ -145,8 +140,7 @@ twait_1: xor ah,ah int 01aH xor ah,ah ; do GetNowTime - mov word [bp-4],dx ; and save it to "Now" - mov word [bp-2],cx + mov bx,dx ; and save it to "Now" (cx:bx) ; ; do comparison ; @@ -154,15 +148,14 @@ twait_1: mov dx,word [LastTime] add dx,word [bp+4] adc ax,word [bp+6] - cmp ax,word [bp-2] + cmp ax,cx jb short twait_1 jne short twait_2 - cmp dx,word [bp-4] + cmp dx,bx jb short twait_1 twait_2: - mov sp,bp pop bp ret -segment _BSS align=2 class=BSS +segment _BSS LastTime: resd 1 diff --git a/drivers/wratclk.asm b/drivers/wratclk.asm index 067edc59..c9316769 100644 --- a/drivers/wratclk.asm +++ b/drivers/wratclk.asm @@ -30,6 +30,9 @@ ; $Header$ ; ; $Log$ +; Revision 1.5 2001/04/15 03:21:50 bartoldeman +; See history.txt for the list of fixes. +; ; Revision 1.4 2001/03/21 02:56:25 bartoldeman ; See history.txt for changes. Bug fixes and HMA support are the main ones. ; @@ -84,28 +87,20 @@ segment HMA_TEXT _WriteATClock: push bp mov bp,sp - sub sp,byte 4 -; LocalCopy = -4 ; bcdSeconds = 10 ; bcdMinutes = 8 ; bcdHours = 6 ; bcdDays = 4 - mov bx,word [bp+4] ;bcdDays - mov ax,word [bx] - mov dx,word [bx+2] - mov word [bp-4],ax ;LocalCopy - mov word [bp-2],dx mov ch,byte [bp+6] ;bcdHours mov cl,byte [bp+8] ;bcdMinutes mov dh,byte [bp+10] ;bcdSeconds mov dl,0 mov ah,3 - int 26 - mov cx,word [bp-2] - mov dx,word [bp-4] ;LocalCopy + int 1ah + mov bx,word [bp+4] ;bcdDays + mov dx,word [bx] + mov cx,word [bx+2] mov ah,5 - int 26 - mov sp,bp + int 1ah pop bp ret - nop diff --git a/drivers/wrpcclk.asm b/drivers/wrpcclk.asm index 3e06f734..bd5a4fb8 100644 --- a/drivers/wrpcclk.asm +++ b/drivers/wrpcclk.asm @@ -30,6 +30,9 @@ ; $Header$ ; ; $Log$ +; Revision 1.5 2001/04/15 03:21:50 bartoldeman +; See history.txt for the list of fixes. +; ; Revision 1.4 2001/03/21 02:56:25 bartoldeman ; See history.txt for changes. Bug fixes and HMA support are the main ones. ; @@ -79,14 +82,10 @@ segment HMA_TEXT ; global _WritePCClock _WritePCClock: - push bp - mov bp,sp + mov bx,sp ; Ticks = 4 - mov cx,word [bp+6] - mov dx,word [bp+4] ;Ticks + mov cx,word [ss:bx+4] + mov dx,word [ss:bx+2] ;Ticks mov ah,1 - int 26 - mov sp,bp - pop bp + int 1ah ret - nop diff --git a/hdr/cds.h b/hdr/cds.h index 2e42adf9..27ca2831 100644 --- a/hdr/cds.h +++ b/hdr/cds.h @@ -34,6 +34,9 @@ static BYTE *Cds_hRcsId = "$Id$"; /* * $Log$ + * Revision 1.4 2001/04/15 03:21:50 bartoldeman + * See history.txt for the list of fixes. + * * Revision 1.3 2000/05/25 20:56:19 jimtabor * Fixed project history * @@ -116,4 +119,5 @@ cdstbl; #define CDSPHYSDRV 0x4000 #define CDSJOINED 0x2000 #define CDSSUBST 0x1000 +#define CDSVALID (CDSNETWDRV | CDSPHYSDRV) diff --git a/hdr/dcb.h b/hdr/dcb.h index 662aa112..8caa11e7 100644 --- a/hdr/dcb.h +++ b/hdr/dcb.h @@ -36,6 +36,9 @@ static BYTE *clock_hRcsId = "$Id$"; /* * $Log$ + * Revision 1.4 2001/04/15 03:21:50 bartoldeman + * See history.txt for the list of fixes. + * * Revision 1.3 2000/05/25 20:56:19 jimtabor * Fixed project history * @@ -112,5 +115,6 @@ struct dpb }; -#define UNKNCLUSTER 0xffff /* 0xffff = unknown for DOS */ +#define UNKNCLUSTER 0x0000 /* see RBIL INT 21/AH=52 entry */ +#define UNKNCLSTFREE 0xffff /* 0xffff = unknown for DOS */ diff --git a/hdr/device.h b/hdr/device.h index 8f1e0cd7..93f25ce2 100644 --- a/hdr/device.h +++ b/hdr/device.h @@ -35,6 +35,9 @@ static BYTE *device_hRcsId = "$Id$"; /* * $Log$ + * Revision 1.5 2001/04/15 03:21:50 bartoldeman + * See history.txt for the list of fixes. + * * Revision 1.4 2000/05/25 20:56:19 jimtabor * Fixed project history * @@ -448,12 +451,6 @@ typedef bpb FAR *bpbptr; typedef BYTE FAR *byteptr; typedef struct dhdr FAR *dhdrptr; -/* - * externals - */ - -extern BYTE FAR *device_end(); - /* * end of device.h */ diff --git a/hdr/fat.h b/hdr/fat.h index 145b9a3c..6a287a01 100644 --- a/hdr/fat.h +++ b/hdr/fat.h @@ -36,6 +36,9 @@ static BYTE *fat_hRcsId = "$Id$"; /* * $Log$ + * Revision 1.6 2001/04/15 03:21:50 bartoldeman + * See history.txt for the list of fixes. + * * Revision 1.5 2000/08/06 04:18:21 jimtabor * See history.txt * @@ -117,8 +120,8 @@ static BYTE *fat_hRcsId = "$Id$"; /* Test for 16 bit or 12 bit FAT */ #define SIZEOF_CLST16 2 #define FAT_MAGIC 4086 -#define FAT_MAGIC16 65526 -#define FAT_MAGIC32 268435456 +#define FAT_MAGIC16 ((unsigned)65526l) +#define FAT_MAGIC32 268435456l #define ISFAT32(dpbp) (((dpbp)->dpb_size)>FAT_MAGIC16 || ((dpbp)->dpb_size)<=FAT_MAGIC32 ) #define ISFAT16(dpbp) (((dpbp)->dpb_size)>FAT_MAGIC || ((dpbp)->dpb_size)<=FAT_MAGIC16 ) diff --git a/hdr/fnode.h b/hdr/fnode.h index 349706e8..fc829f00 100644 --- a/hdr/fnode.h +++ b/hdr/fnode.h @@ -36,6 +36,9 @@ static BYTE *fnode_hRcsId = "$Id$"; /* * $Log$ + * Revision 1.4 2001/04/15 03:21:50 bartoldeman + * See history.txt for the list of fixes. + * * Revision 1.3 2000/05/25 20:56:19 jimtabor * Fixed project history * @@ -108,7 +111,7 @@ struct f_node ULONG f_diroff; /* offset of the dir entry */ UWORD f_dirstart; /* the starting cluster of dir */ /* when dir is not root */ - struct dpb *f_dpb; /* the block device for file */ + struct dpb FAR *f_dpb; /* the block device for file */ ULONG f_dsize; /* file size (for directories) */ ULONG f_offset; /* byte offset for next op */ diff --git a/hdr/mcb.h b/hdr/mcb.h index 4e8e1178..273d3b62 100644 --- a/hdr/mcb.h +++ b/hdr/mcb.h @@ -36,6 +36,9 @@ static BYTE *mcb_hRcsId = "$Id$"; /* * $Log$ + * Revision 1.7 2001/04/15 03:21:50 bartoldeman + * See history.txt for the list of fixes. + * * Revision 1.6 2000/08/06 04:27:07 jimtabor * See history.txt * @@ -104,7 +107,7 @@ static BYTE *mcb_hRcsId = "$Id$"; #define MCB_NORMAL 0x4d #define MCB_LAST 0x5a -#define DOS_PSP 0x0050 /* 0x0008 What? seg 8 =0:0080 */ +#define DOS_PSP 0x0060 /* 0x0008 What? seg 8 =0:0080 */ #define FREE_PSP 0 #define MCB_SIZE(x) ((((LONG)(x))<<4)+sizeof(mcb)) diff --git a/hdr/pcb.h b/hdr/pcb.h index 292f39a9..bec11d1a 100644 --- a/hdr/pcb.h +++ b/hdr/pcb.h @@ -57,6 +57,9 @@ static BYTE *pcb_hRcsId = "$Id$"; /* * $Log$ + * Revision 1.5 2001/04/15 03:21:50 bartoldeman + * See history.txt for the list of fixes. + * * Revision 1.4 2000/08/06 04:18:21 jimtabor * See history.txt * @@ -128,7 +131,7 @@ xreg; Furthermore, the PUSH$ALL macro must push ES first and AX last. -- 2000/03/22 ska*/ /* maps MS-DOS unique stacking order */ -typedef struct +typedef struct _iregss { xreg a, b, diff --git a/hdr/portab.h b/hdr/portab.h index 0214ea3d..936d66a5 100644 --- a/hdr/portab.h +++ b/hdr/portab.h @@ -36,6 +36,9 @@ static char *portab_hRcsId = "$Id$"; /* * $Log$ + * Revision 1.8 2001/04/15 03:21:50 bartoldeman + * See history.txt for the list of fixes. + * * Revision 1.7 2001/03/21 02:56:25 bartoldeman * See history.txt for changes. Bug fixes and HMA support are the main ones. * @@ -238,4 +241,11 @@ typedef signed long LONG; #else #define FDCALL #define CDECL -#endif \ No newline at end of file +#endif + +#ifdef I86 + /* commandline overflow - removing /DPROTO + TE*/ + #define PROTO +#endif + diff --git a/kernel/asmsupt.asm b/kernel/asmsupt.asm index baac1821..27ebb596 100644 --- a/kernel/asmsupt.asm +++ b/kernel/asmsupt.asm @@ -34,6 +34,9 @@ ; $Id$ ; ; $Log$ +; Revision 1.5 2001/04/15 03:21:50 bartoldeman +; See history.txt for the list of fixes. +; ; Revision 1.4 2001/03/21 02:56:25 bartoldeman ; See history.txt for changes. Bug fixes and HMA support are the main ones. ; @@ -92,10 +95,9 @@ segment HMA_TEXT ;********************************************************************* ; this implements some of the common string handling functions ; -; every function has 2 entries +; every function has 1 entry ; ; NEAR FUNC() -; FAR init_call_FUNC() ; ; currently done: ; @@ -143,28 +145,23 @@ common_setup: ; are preloaded here ; the destination pointer, d = arg1 - mov di,[bp+6] + mov di,[bp+4] ; Get the source pointer, s = arg2 - mov si,[bp+8] + mov si,[bp+6] ; Get the repitition count, n = arg3 - mov cx,[bp+10] + mov cx,[bp+8] jmp bx - + ;*********************************************** ; ; VOID memcpy(REG BYTE *s, REG BYTE *d, REG COUNT n); ; global _memcpy - global _init_call_memcpy _memcpy: - pop ax - push cs - push ax -_init_call_memcpy: call common_setup @@ -186,7 +183,7 @@ common_return: pop di pop si pop bp - retf + ret @@ -196,23 +193,18 @@ common_return: ; global __fmemcpy global _fmemcpy - global _init_call_fmemcpy _fmemcpy: __fmemcpy: - pop ax - push cs - push ax -_init_call_fmemcpy: call common_setup ; Get the far source pointer, s - lds si,[bp+10] + lds si,[bp+8] ; Get the far destination pointer d - les di,[bp+6] + les di,[bp+4] ; Get the repetition count, n - mov cx,[bp+14] + mov cx,[bp+12] jmp short domemcpy @@ -222,23 +214,17 @@ _init_call_fmemcpy: ; VOID fmemset(REG VOID FAR *d, REG BYTE ch, REG COUNT n); ; global _fmemset - global _init_call_fmemset _fmemset: - pop ax - push cs - push ax -_init_call_fmemset: - call common_setup ; Get the repetition count, n - mov cx,[bp+12] + mov cx,[bp+10] ; Get the far source pointer, s - les di,[bp+6] + les di,[bp+4] ; Get the far destination pointer ch - mov al,[bp+10] + mov al,[bp+8] domemset: mov ah, al @@ -255,23 +241,17 @@ domemset: ; VOID memset(REG VOID *d, REG BYTE ch, REG COUNT n); ; global _memset - global _init_call_memset _memset: - pop ax - push cs - push ax -_init_call_memset: - call common_setup ; Get the far source pointer, s - ; mov di,[bp+6] + ; mov di,[bp+4] ; Get the char ch - mov ax,si ; mov al, [bp+8] + mov ax,si ; mov al, [bp+6] ; Get the repititon count, n - ; mov cx,[bp+10] + ; mov cx,[bp+8] jmp short domemset @@ -281,21 +261,16 @@ _init_call_memset: ;*************************************************************** global _fstrncpy - global _init_call_fstrncpy _fstrncpy: - pop ax - push cs - push ax -_init_call_fstrncpy: call common_setup ; Get the source pointer, ss - lds si,[bp+10] + lds si,[bp+8] ; and the destination pointer, d - les di,[bp+6] + les di,[bp+4] - mov cx,[bp+14] + mov cx,[bp+12] jcxz common_return ;; dec cx @@ -318,38 +293,28 @@ store_one_byte: xor al,al global _fstrcpy - global _init_call_fstrcpy _fstrcpy: - pop ax - push cs - push ax -_init_call_fstrcpy: call common_setup ; Get the source pointer, ss - lds si,[bp+10] + lds si,[bp+8] ; and the destination pointer, d - les di,[bp+6] + les di,[bp+4] jmp short dostrcpy ;****** global _strcpy - global _init_call_strcpy _strcpy: - pop ax - push cs - push ax -_init_call_strcpy: call common_setup ; Get the source pointer, ss - ;mov si,[bp+8] + ;mov si,[bp+6] ; and the destination pointer, d - ;mov di,[bp+6] + ;mov di,[bp+4] dostrcpy: @@ -364,27 +329,17 @@ strcpy_loop: ;****************************************************************** global _fstrlen - global _init_call_fstrlen _fstrlen: - pop ax - push cs - push ax -_init_call_fstrlen: call common_setup ; Get the source pointer, ss - les di,[bp+6] + les di,[bp+4] jmp short dostrlen ;********************************************** global _strlen - global _init_call_strlen _strlen: - pop ax - push cs - push ax -_init_call_strlen: call common_setup ; The source pointer, ss, arg1 was loaded as di @@ -398,21 +353,16 @@ dostrlen: not ax dec ax - jmp common_return + jmp short common_return ;************************************************************ global _strchr - global _init_call_strchr _strchr: - pop ax - push cs - push ax -_init_call_strchr: call common_setup ; Get the source pointer, ss - ; mov si,[bp+6] - ; mov bx,[bp+8] + ; mov si,[bp+4] + ; mov bx,[bp+6] mov bx,si mov si,di @@ -432,38 +382,28 @@ strchr_found: ;********************************************************************** global _fstrcmp - global _init_call_fstrcmp _fstrcmp: - pop ax - push cs - push ax -_init_call_fstrcmp: call common_setup ; Get the source pointer, ss - lds si,[bp+6] + lds si,[bp+4] ; and the destination pointer, d - les di,[bp+10] + les di,[bp+8] jmp dostrcmp ;****** global _strcmp - global _init_call_strcmp _strcmp: - pop ax - push cs - push ax -_init_call_strcmp: call common_setup ; Get the source pointer, ss - ; mov si,[bp+6] + ; mov si,[bp+4] ; and the destination pointer, d - ; mov di,[bp+8] + ; mov di,[bp+6] xchg si,di dostrcmp: @@ -475,39 +415,29 @@ dostrcmp: ;********************************************************************** global _fstrncmp - global _init_call_fstrncmp _fstrncmp: - pop ax - push cs - push ax -_init_call_fstrncmp: call common_setup ; Get the source pointer, ss - lds si,[bp+6] + lds si,[bp+4] ; and the destination pointer, d - les di,[bp+10] - mov cx,[bp+12] + les di,[bp+8] + mov cx,[bp+10] jmp short dostrncmp ;****** global _strncmp - global _init_call_strncmp _strncmp: - pop ax - push cs - push ax -_init_call_strncmp: call common_setup ; Get the source pointer, ss - ;mov si,[bp+6] + ;mov si,[bp+4] ; and the destination pointer, d - ;mov di,[bp+8] - ;mov cx,[bp+10] + ;mov di,[bp+6] + ;mov cx,[bp+8] xchg si,di dostrncmp: diff --git a/kernel/blockio.c b/kernel/blockio.c index 76ed45ec..fc999432 100644 --- a/kernel/blockio.c +++ b/kernel/blockio.c @@ -37,6 +37,9 @@ static BYTE *blockioRcsId = "$Id$"; /* * $Log$ + * Revision 1.8 2001/04/15 03:21:50 bartoldeman + * See history.txt for the list of fixes. + * * Revision 1.7 2001/03/21 02:56:25 bartoldeman * See history.txt for changes. Bug fixes and HMA support are the main ones. * @@ -530,7 +533,7 @@ UWORD dskxfer(COUNT dsk, ULONG blkno, VOID FAR * buf, UWORD numblocks, COUNT mod { /* REG struct dpb *dpbp = &blk_devices[dsk]; */ - REG struct dpb *dpbp = (struct dpb *)CDSp->cds_table[dsk].cdsDpb; + REG struct dpb FAR *dpbp = CDSp->cds_table[dsk].cdsDpb; for (;;) { diff --git a/kernel/break.c b/kernel/break.c index a05f4072..4cfb36e2 100644 --- a/kernel/break.c +++ b/kernel/break.c @@ -30,7 +30,7 @@ #include "portab.h" #include "globals.h" -extern void FAR init_call_spawn_int23(void); +extern void spawn_int23(void); #ifdef VERSION_STRINGS static BYTE *RcsId = "$Id$"; @@ -38,6 +38,9 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.5 2001/04/15 03:21:50 bartoldeman + * See history.txt for the list of fixes. + * * Revision 1.4 2001/03/21 02:56:25 bartoldeman * See history.txt for changes. Bug fixes and HMA support are the main ones. * @@ -90,25 +93,5 @@ void handle_break(void) if (InDOS) --InDOS; /* fail-safe */ - { - /*TE PATCH - CtrlC at DosInput (like C:>DATE does) - Nukes the Kernel. - - it looks like ENTRY.ASM+PROCSUPT.ASM - got out of sync. - - spawn_int() assumes a stack layout at - usr_ss:usr:sp. but usr:ss currently contains 0 - - this patch helps FreeDos to survive CtrlC, - but should clearly be done somehow else. - */ - extern ULONG lpUserStack; - - usr_ss = FP_SEG(lpUserStack); - usr_sp = FP_OFF(lpUserStack); - } - - init_call_spawn_int23(); /* invoke user INT-23 and never come back */ + spawn_int23(); /* invoke user INT-23 and never come back */ } diff --git a/kernel/chario.c b/kernel/chario.c index 45aa2bef..318cd552 100644 --- a/kernel/chario.c +++ b/kernel/chario.c @@ -36,6 +36,9 @@ static BYTE *charioRcsId = "$Id$"; /* * $Log$ + * Revision 1.5 2001/04/15 03:21:50 bartoldeman + * See history.txt for the list of fixes. + * * Revision 1.4 2000/05/26 19:25:19 jimtabor * Read History file for Change info * @@ -117,8 +120,6 @@ static BYTE *charioRcsId = "$Id$"; #include "globals.h" -static BYTE *con_name = "CON"; - #ifdef PROTO VOID kbfill(keyboard FAR *, UCOUNT, BOOL, UWORD *); struct dhdr FAR *finddev(UWORD attr_mask); @@ -192,7 +193,7 @@ VOID Do_DosIdle_loop(void) { FOREVER { - if (StdinBusy()) + if (!StdinBusy()) return; else { @@ -407,8 +408,3 @@ VOID sti(keyboard FAR * kp) } } } - -VOID FAR init_call_sti(keyboard FAR * kp) -{ - sti(kp); -} diff --git a/kernel/config.c b/kernel/config.c index 09679099..0d5435e8 100644 --- a/kernel/config.c +++ b/kernel/config.c @@ -27,7 +27,7 @@ /* Cambridge, MA 02139, USA. */ /****************************************************************/ - +#define CONFIG #include "init-mod.h" #include "portab.h" @@ -40,6 +40,9 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.17 2001/04/15 03:21:50 bartoldeman + * See history.txt for the list of fixes. + * * Revision 1.16 2001/04/02 23:18:30 bartoldeman * Misc, zero terminated device names and redirector bugs fixed. * @@ -178,15 +181,14 @@ static BYTE *RcsId = "$Id$"; #define KernelAlloc(x) adjust_far((void far *)malloc((unsigned long)(x))) #endif -BYTE FAR *lpBase; -BYTE FAR *upBase; -static BYTE FAR *lpOldLast; -static BYTE FAR *upOldLast; -static COUNT nCfgLine; -static COUNT nPass; - COUNT UmbState; -static BYTE szLine[256]; -static BYTE szBuf[256]; +BYTE FAR *lpBase = 0; +BYTE FAR *upBase = 0; +static BYTE FAR *lpOldLast = 0; +static COUNT nCfgLine = 0; +static COUNT nPass = 0; + COUNT UmbState = 0; +static BYTE szLine[256]={0}; +static BYTE szBuf[256]={0}; int singleStep = 0; @@ -220,8 +222,6 @@ INIT int SkipLine(char *pLine); INIT char *stristr(char *s1, char *s2); INIT COUNT strcasecmp(REG BYTE *d, REG BYTE *s); -INIT BYTE FAR *KernelAlloc(WORD nBytes); - extern void HMAconfig(int finalize); VOID config_init_buffers(COUNT anzBuffers); /* from BLOCKIO.C */ @@ -337,9 +337,9 @@ INIT void PreConfig(void) f_nodes_cnt = Config.cfgFiles; /* sfthead = (sfttbl FAR *)&basesft; */ /* FCBp = (sfttbl FAR *)&FcbSft; */ - FCBp = (sfttbl FAR *) + /* FCBp = (sfttbl FAR *) KernelAlloc(sizeof(sftheader) - + Config.cfgFiles * sizeof(sft)); + + Config.cfgFiles * sizeof(sft));*/ sfthead = (sfttbl FAR *) KernelAlloc(sizeof(sftheader) + Config.cfgFiles * sizeof(sft)); @@ -347,11 +347,15 @@ INIT void PreConfig(void) CDSp = (cdstbl FAR *) KernelAlloc(0x58 * lastdrive); + DPBp = (struct dpb FAR *) + KernelAlloc(blk_dev.dh_name[0]*sizeof(struct dpb)); + #ifdef DEBUG printf("Preliminary f_node allocated at at 0x%p\n",f_nodes); printf("Preliminary FCB table allocated at 0x%p\n",FCBp); printf("Preliminary sft table allocated at 0x%p\n",sfthead); printf("Preliminary CDS table allocated at 0x%p\n",CDSp); + printf("Preliminary DPB table allocated at 0x%p\n",DPBp); #endif /* Done. Now initialize the MCB structure */ @@ -369,7 +373,7 @@ INIT void PreConfig(void) /* We expect ram_top as Kbytes, so convert to paragraphs */ mcb_init((mcb FAR *) (MK_FP(first_mcb, 0)), - (ram_top << 6) - first_mcb - 1); + ((UCOUNT)ram_top << 6) - first_mcb - 1); nPass = 1; } @@ -416,9 +420,9 @@ INIT void PostConfig(void) f_nodes_cnt = Config.cfgFiles; /* and the number of allocated files */ /* sfthead = (sfttbl FAR *)&basesft; */ /* FCBp = (sfttbl FAR *)&FcbSft; */ - FCBp = (sfttbl FAR *) + /* FCBp = (sfttbl FAR *) KernelAlloc(sizeof(sftheader) - + Config.cfgFiles * sizeof(sft)); + + Config.cfgFiles * sizeof(sft));*/ sfthead = (sfttbl FAR *) KernelAlloc(sizeof(sftheader) + Config.cfgFiles * sizeof(sft)); @@ -426,12 +430,17 @@ INIT void PostConfig(void) CDSp = (cdstbl FAR *) KernelAlloc(0x58 * lastdrive); + DPBp = (struct dpb FAR *) + KernelAlloc(blk_dev.dh_name[0]*sizeof(struct dpb)); + + #ifdef DEBUG printf("f_node allocated at 0x%p\n",f_nodes); printf("FCB table allocated at 0x%p\n",FCBp); printf("sft table allocated at 0x%p\n",sfthead); printf("CDS table allocated at 0x%p\n",CDSp); + printf("DPB table allocated at 0x%p\n",DPBp); #endif if (Config.cfgStacks) { @@ -452,8 +461,6 @@ INIT void PostConfig(void) /* This code must be executed after device drivers has been loaded */ INIT VOID configDone(VOID) { - COUNT i; - HMAconfig(TRUE); /* final HMA processing */ @@ -470,7 +477,7 @@ INIT VOID configDone(VOID) /* We expect ram_top as Kbytes, so convert to paragraphs */ mcb_init((mcb FAR *) (MK_FP(first_mcb, 0)), - (ram_top << 6) - first_mcb - 1); + ((UCOUNT)ram_top << 6) - first_mcb - 1); if(UmbState == 1) { @@ -480,10 +487,12 @@ INIT VOID configDone(VOID) /* Check if any devices were loaded in umb */ if(umb_start != FP_SEG(upBase) ){ /* make last block normal with SC for the devices */ - mumcb_init((mcb FAR *) (MK_FP(uppermem_root, 0)), - (FP_SEG(upBase) + ((FP_OFF(upBase) + 0x0f) >> 4)) - uppermem_root - 1); + + UCOUNT umr_new = FP_SEG(upBase) + ((FP_OFF(upBase) + 0x0f) >> 4); + + mumcb_init((mcb FAR *) (MK_FP(uppermem_root, 0)), umr_new - uppermem_root - 1); - uppermem_root = FP_SEG(upBase) + ((FP_OFF(upBase) + 0x0f) >> 4); + uppermem_root = umr_new; zumcb_init((mcb FAR *) (MK_FP(uppermem_root, 0)), (umb_start + UMB_top ) - uppermem_root - 1); upBase += 16; @@ -511,12 +520,12 @@ INIT VOID DoConfig(VOID) /* Check to see if we have a config.sys file. If not, just */ /* exit since we don't force the user to have one. */ - if ((nFileDesc = dos_open((BYTE FAR *) "fdconfig.sys", 0)) < 0) + if ((nFileDesc = init_DosOpen("fdconfig.sys", 0)) < 0) { #ifdef DEBUG printf("FDCONFIG.SYS not found\n"); #endif - if ((nFileDesc = dos_open((BYTE FAR *) "config.sys", 0)) < 0) + if ((nFileDesc = init_DosOpen("config.sys", 0)) < 0) { #ifdef DEBUG printf("CONFIG.SYS not found\n"); @@ -557,7 +566,7 @@ INIT VOID DoConfig(VOID) /* Read a line from config */ /* Interrupt processing if read error or no bytes read */ - if ((nRetCode = dos_read(nFileDesc, pLine, LINESIZE - bytesLeft)) <= 0) + if ((nRetCode = init_DosRead(nFileDesc, pLine, LINESIZE - bytesLeft)) <= 0) break; /* If the buffer was not filled completely, append a @@ -571,6 +580,7 @@ INIT VOID DoConfig(VOID) while (!bEof && *pLine != EOF) { + /* Do it here in the loop. */ @@ -581,11 +591,10 @@ INIT VOID DoConfig(VOID) if(!Umb_Test()){ UmbState = 1; upBase = MK_FP(umb_start , 0); - uppermem_root = umb_start; /* reset root */ - uppermem_root = FP_SEG(upBase) + ((FP_OFF(upBase) + 0x0f) >> 4); + uppermem_root = umb_start; /* setup the real mcb for the devicehigh block */ - zumcb_init((mcb FAR *) (MK_FP(uppermem_root, 0)), UMB_top - 1); + zumcb_init((mcb FAR *) upBase, UMB_top - 1); upBase += 16; } } @@ -632,7 +641,7 @@ INIT VOID DoConfig(VOID) pLine += strlen(pLine) + 1; } } - dos_close(nFileDesc); + init_DosClose(nFileDesc); } INIT struct table *LookUp(struct table *p, BYTE * token) @@ -763,7 +772,6 @@ INIT static VOID Files(BYTE * pLine) INIT static VOID Lastdrive(BYTE * pLine) { /* Format: LASTDRIVE = letter */ - COUNT nFiles; BYTE drv; pLine = skipwh(pLine); @@ -789,6 +797,7 @@ INIT static VOID Dosmem(BYTE * pLine) BYTE *pTmp; BYTE UMBwanted = FALSE, HMAwanted = FALSE; + extern BYTE INITDataSegmentClaimed; pLine = GetStringArg(pLine, szBuf); @@ -801,7 +810,7 @@ INIT static VOID Dosmem(BYTE * pLine) { if (fmemcmp(pTmp, "UMB" ,3) == 0) { UMBwanted = TRUE; pTmp += 3; } if (fmemcmp(pTmp, "HIGH",4) == 0) { HMAwanted = TRUE; pTmp += 4; } - + if (fmemcmp(pTmp, "CLAIMINIT",9) == 0) { INITDataSegmentClaimed = 0; pTmp += 9; } pTmp = skipwh(pTmp); if (*pTmp != ',') @@ -966,16 +975,16 @@ INIT static VOID Break(BYTE * pLine) INIT static VOID Numlock(BYTE * pLine) { + extern VOID keycheck(); + /* Format: NUMLOCK = (ON | OFF) */ - iregs regs; BYTE FAR *keyflags = (BYTE FAR *)MK_FP(0x40,0x17); GetStringArg(pLine, szBuf); *keyflags &= ~32; *keyflags |= strcasecmp(szBuf, "OFF") ? 32 : 0; - regs.a.b.h = 1; - init_call_intr(0x16, ®s); + keycheck(); } INIT static VOID DeviceHigh(BYTE * pLine) @@ -1002,41 +1011,32 @@ INIT void Device(BYTE * pLine) INIT BOOL LoadDevice(BYTE * pLine, COUNT top, COUNT mode) { - VOID FAR *driver_ptr; BYTE *pTmp; exec_blk eb; struct dhdr FAR *dhp; struct dhdr FAR *next_dhp; - UWORD dev_seg; BOOL result; if(mode) - dev_seg = (((ULONG) FP_SEG(upBase) << 4) + FP_OFF(upBase) + 0xf) >> 4; + dhp = AlignParagraph(upBase); else - dev_seg = (((ULONG) FP_SEG(lpBase) << 4) + FP_OFF(lpBase) + 0xf) >> 4; + dhp = AlignParagraph(lpBase); /* Get the device driver name */ GetStringArg(pLine, szBuf); /* The driver is loaded at the top of allocated memory. */ /* The device driver is paragraph aligned. */ - eb.load.reloc = eb.load.load_seg = dev_seg; - dhp = MK_FP(dev_seg, 0); + eb.load.reloc = eb.load.load_seg = FP_SEG(dhp); #ifdef DEBUG printf("Loading device driver %s at segment %04x\n", - szBuf, dev_seg); + szBuf, FP_SEG(dhp)); #endif if (DosExec(3, &eb, szBuf) == SUCCESS) { - /* TE this fixes the loading of devices drivers with - multiple devices in it. NUMEGA's SoftIce is such a beast - */ - - for ( ; ; ) - { /* that's a nice hack >:-) although we don't want HIMEM.SYS,(it's not free), other people @@ -1058,28 +1058,27 @@ INIT BOOL LoadDevice(BYTE * pLine, COUNT top, COUNT mode) strcat(pTmp, " /TESTMEM:OFF\r\n"); } } - /* end of HIMEM.SYS HACK */ - - result=init_device(dhp, pTmp, mode, top); + /* end of HIMEM.SYS HACK */ - if(!result){ - next_dhp = dhp->dh_next; - /* Link in device driver and save nul_dev pointer to next */ - dhp->dh_next = nul_dev.dh_next; - nul_dev.dh_next = dhp; - } - - /* multiple devices end */ - if (FP_OFF(next_dhp) == 0xffff) /* end of internal chain */ - break; - - FP_OFF(dhp) = FP_OFF(next_dhp); - - if (FP_SEG(next_dhp) != 0xffff) - { - printf("multisegmented device driver found, next %p\n",next_dhp); /* give warning message */ - dhp = next_dhp; - } + /* TE this fixes the loading of devices drivers with + multiple devices in it. NUMEGA's SoftIce is such a beast + */ + for (next_dhp=NULL; FP_OFF(next_dhp) != 0xffff && + (result=init_device(dhp, pTmp, mode, top))==SUCCESS + ; dhp = next_dhp) + { + next_dhp = dhp->dh_next; + if (FP_SEG(next_dhp) == 0xffff) + /* Does this ever occur with FP_OFF(next_dhp) != 0xffff ??? */ + next_dhp = MK_FP(FP_SEG(dhp), FP_OFF(next_dhp)); +#ifdef DEBUG + else if (FP_OFF(next_dhp) != 0xffff) /* end of internal chain */ + printf("multisegmented device driver found, next %p\n",next_dhp); + /* give warning message */ +#endif + /* Link in device driver and save nul_dev pointer to next */ + dhp->dh_next = nul_dev.dh_next; + nul_dev.dh_next = dhp; } HMAconfig(FALSE); /* let the HMA claim HMA usage */ @@ -1109,7 +1108,7 @@ INIT BYTE FAR *KernelAlloc(WORD nBytes) lpBase = AlignParagraph(lpBase); lpAllocated = lpBase; - if (0x10000 - FP_OFF(lpBase) <= nBytes) + if (0xffff - FP_OFF(lpBase) <= nBytes) { UWORD newOffs = (FP_OFF(lpBase) + nBytes) & 0xFFFF; UWORD newSeg = FP_SEG(lpBase) + 0x1000; @@ -1140,19 +1139,13 @@ INIT BYTE FAR *KernelAllocDma(WORD bytes) INIT void FAR *AlignParagraph(VOID FAR * lpPtr) { - ULONG lTemp; UWORD uSegVal; /* First, convert the segmented pointer to linear address */ - lTemp = FP_SEG(lpPtr); - lTemp = (lTemp << 4) + FP_OFF(lpPtr); - - /* Next, round up the linear address to a paragraph boundary. */ - lTemp += 0x0f; - lTemp &= 0xfffffff0l; - - /* Break it into segments. */ - uSegVal = (UWORD) (lTemp >> 4); + uSegVal = FP_SEG(lpPtr); + uSegVal += (FP_OFF(lpPtr)+0xf) >> 4; + if (FP_OFF(lpPtr) > 0xfff0) + uSegVal += 0x1000; /* handle overflow */ /* and return an adddress adjusted to the nearest paragraph */ /* boundary. */ @@ -1238,7 +1231,7 @@ INIT COUNT toupper(COUNT c) /* The following code is 8086 dependant */ -#ifdef KERNEL +#if 1 /* ifdef KERNEL */ INIT VOID mcb_init(mcb FAR * mcbp, UWORD size) { @@ -1314,8 +1307,6 @@ char *stristr(char *s1, char *s2) /* compare two ASCII strings ignoring case */ INIT COUNT strcasecmp(REG BYTE *d, REG BYTE *s) { - int loop; - while (*s != '\0' && *d != '\0') { diff --git a/kernel/console.asm b/kernel/console.asm index ad5b0fa5..8705147c 100644 --- a/kernel/console.asm +++ b/kernel/console.asm @@ -28,6 +28,9 @@ ; $Header$ ; ; $Log$ +; Revision 1.6 2001/04/15 03:21:50 bartoldeman +; See history.txt for the list of fixes. +; ; Revision 1.5 2001/03/21 02:56:25 bartoldeman ; See history.txt for changes. Bug fixes and HMA support are the main ones. ; @@ -285,8 +288,8 @@ ConIS2: lds bx,[_ReqPktPtr] ; Set the status mov [bx+0Dh],al ConCharReady: - jmp _IODone ; key ready (busy=1) + jmp _IOExit ; key ready (busy=0) ConNoChar: - jmp _IOExit ; no key ready (busy=0) + jmp _IODone ; no key ready (busy=1) diff --git a/kernel/dosfns.c b/kernel/dosfns.c index da67c3dc..3cc66b51 100644 --- a/kernel/dosfns.c +++ b/kernel/dosfns.c @@ -37,6 +37,9 @@ static BYTE *dosfnsRcsId = "$Id$"; * /// Added SHARE support. 2000/09/04 Ron Cemer * * $Log$ + * Revision 1.15 2001/04/15 03:21:50 bartoldeman + * See history.txt for the list of fixes. + * * Revision 1.14 2001/04/02 23:18:30 bartoldeman * Misc, zero terminated device names and redirector bugs fixed. * @@ -776,6 +779,12 @@ COUNT DosCreat(BYTE FAR * fname, COUNT attrib) /* WORD i;*/ COUNT result, drive; + /* NEVER EVER allow directories to be created */ + if (attrib & ~(D_RDONLY|D_HIDDEN|D_SYSTEM|D_ARCHIVE)) + { + return DE_ACCESS; + } + /* get a free handle */ if ((hndl = get_free_hndl()) == 0xff) return DE_TOOMANY; @@ -815,8 +824,7 @@ COUNT DosCreat(BYTE FAR * fname, COUNT attrib) if (CDSp->cds_table[drive].cdsFlags & CDSNETWDRV) { lpCurSft = (sfttbl FAR *)sftp; sftp->sft_mode = attrib; - result = int2f_Remote_call(REM_CREATE, 0, 0, 0, (VOID FAR *) sftp, 0, MK_FP(0, attrib)); - result = -result; + result = -int2f_Remote_call(REM_CREATE, 0, 0, 0, (VOID FAR *) sftp, 0, MK_FP(0, attrib)); if (result == SUCCESS) { sftp->sft_count += 1; p->ps_filetab[hndl] = sft_idx; @@ -892,7 +900,7 @@ COUNT DosDup(COUNT Handle) return DE_TOOMANY; /* If everything looks ok, bump it up. */ - if ((Sftp->sft_flags & SFT_FDEVICE) || (Sftp->sft_status >= 0)) + if ((Sftp->sft_flags & (SFT_FDEVICE | SFT_FSHARED)) || (Sftp->sft_status >= 0)) { p->ps_filetab[NewHandle] = p->ps_filetab[Handle]; Sftp->sft_count += 1; @@ -925,7 +933,7 @@ COUNT DosForceDup(COUNT OldHandle, COUNT NewHandle) } /* If everything looks ok, bump it up. */ - if ((Sftp->sft_flags & SFT_FDEVICE) || (Sftp->sft_status >= 0)) + if ((Sftp->sft_flags & (SFT_FDEVICE | SFT_FSHARED)) || (Sftp->sft_status >= 0)) { p->ps_filetab[NewHandle] = p->ps_filetab[OldHandle]; @@ -1004,8 +1012,7 @@ COUNT DosOpen(BYTE FAR * fname, COUNT mode) if (CDSp->cds_table[drive].cdsFlags & CDSNETWDRV) { lpCurSft = (sfttbl FAR *)sftp; - result = int2f_Remote_call(REM_OPEN, 0, 0, 0, (VOID FAR *) sftp, 0, MK_FP(0, mode)); - result = -result; + result = -int2f_Remote_call(REM_OPEN, 0, 0, 0, (VOID FAR *) sftp, 0, MK_FP(0, mode)); if (result == SUCCESS) { sftp->sft_count += 1; p->ps_filetab[hndl] = sft_idx; @@ -1080,25 +1087,20 @@ COUNT DosClose(COUNT hndl) /* remote sub sft_count. */ + p->ps_filetab[hndl] = 0xff; if (s->sft_flags & SFT_FSHARED) { int2f_Remote_call(REM_CLOSE, 0, 0, 0, (VOID FAR *) s, 0, 0); - p->ps_filetab[hndl] = 0xff; return SUCCESS; } /* now just drop the count if a device, else */ /* call file system handler */ + s->sft_count -= 1; if (s->sft_flags & SFT_FDEVICE) - { - p->ps_filetab[hndl] = 0xff; - s->sft_count -= 1; return SUCCESS; - } else { - p->ps_filetab[hndl] = 0xff; - s->sft_count -= 1; if (s->sft_count > 0) return SUCCESS; else { @@ -1113,9 +1115,9 @@ COUNT DosClose(COUNT hndl) } } -VOID DosGetFree(COUNT drive, COUNT FAR * spc, COUNT FAR * navc, COUNT FAR * bps, COUNT FAR * nc) +VOID DosGetFree(UBYTE drive, COUNT FAR * spc, COUNT FAR * navc, COUNT FAR * bps, COUNT FAR * nc) { - struct dpb *dpbp; + struct dpb FAR *dpbp; struct cds FAR *cdsp; static COUNT rg[4]; @@ -1123,36 +1125,29 @@ VOID DosGetFree(COUNT drive, COUNT FAR * spc, COUNT FAR * navc, COUNT FAR * bps, drive = (drive == 0 ? default_drive : drive - 1); /* first check for valid drive */ - if (drive < 0 || drive >= lastdrive) - { - *spc = -1; - return; - } + *spc = -1; + if (drive >= lastdrive) + return; + + cdsp = &CDSp->cds_table[drive]; - cdsp = &CDSp->cds_table[drive]; - if (cdsp->cdsFlags & CDSNETWDRV) + if (!(cdsp->cdsFlags & CDSVALID)) + return; + + if (cdsp->cdsFlags & CDSNETWDRV) { - int2f_Remote_call(REM_GETSPACE, 0, 0, 0, cdsp, 0, &rg); + int2f_Remote_call(REM_GETSPACE, 0, 0, 0, cdsp, 0, &rg); - *spc = (COUNT) rg[0]; - *nc = (COUNT) rg[1]; - *bps = (COUNT) rg[2]; - *navc = (COUNT) rg[3]; - return; + *spc = (COUNT) rg[0]; + *nc = (COUNT) rg[1]; + *bps = (COUNT) rg[2]; + *navc = (COUNT) rg[3]; + return; } - dpbp = (struct dpb *)CDSp->cds_table[drive].cdsDpb; - if (dpbp == 0) - { - *spc = -1; - return; - } - - if ((media_check(dpbp) < 0)) - { - *spc = -1; - return; - } + dpbp = CDSp->cds_table[drive].cdsDpb; + if (dpbp == NULL || media_check(dpbp) < 0) + return; /* get the data vailable from dpb */ *nc = dpbp->dpb_size; @@ -1164,26 +1159,20 @@ VOID DosGetFree(COUNT drive, COUNT FAR * spc, COUNT FAR * navc, COUNT FAR * bps, *navc = dos_free(dpbp); } -COUNT DosGetCuDir(COUNT drive, BYTE FAR * s) +COUNT DosGetCuDir(UBYTE drive, BYTE FAR * s) { - REG struct cds FAR *cdsp; - /* next - "log" in the drive */ drive = (drive == 0 ? default_drive : drive - 1); - /* first check for valid drive */ - if (drive < 0 || drive >= lastdrive) { - return DE_INVLDDRV; - } - - cdsp = &CDSp->cds_table[drive]; - current_ldt = cdsp; - - if (!(cdsp->cdsFlags & CDSNETWDRV) && (cdsp->cdsDpb == 0)) { - return DE_INVLDDRV; + /* first check for valid drive */ + if (drive >= lastdrive || !(CDSp->cds_table[drive].cdsFlags & CDSVALID)) { + return DE_INVLDDRV; } + + current_ldt = &CDSp->cds_table[drive]; - fsncopy((BYTE FAR *) & cdsp->cdsCurrentPath[1 + cdsp->cdsJoinOffset], s, 64); + fsncopy((BYTE FAR *) & current_ldt->cdsCurrentPath[1 + current_ldt->cdsJoinOffset], + s, 64); return SUCCESS; } @@ -1225,13 +1214,12 @@ COUNT DosChangeDir(BYTE FAR * s) p = PriPathName; while(*p) printf("%c", *p++); printf("'\n"); #endif - result = int2f_Remote_call(REM_CHDIR, 0, 0, 0, PriPathName, 0, 0); + result = -int2f_Remote_call(REM_CHDIR, 0, 0, 0, PriPathName, 0, 0); #if defined(CHDIR_DEBUG) printf("status = %04x, new_path='", result); p = cdsd->cdsCurrentPath; while(p) printf("%c", *p++) printf("'\n"); #endif - result = -result; if (result != SUCCESS) { return DE_PATHNOTFND; } @@ -1330,10 +1318,9 @@ COUNT DosGetFattr(BYTE FAR * name, UWORD FAR * attrp) static UWORD srfa[5]; COUNT result, drive; struct cds FAR *last_cds; - BYTE FAR * p; if (IsDevice(name)) { - return DE_PATHNOTFND; + return DE_FILENOTFND; } drive = get_verify_drive(name); @@ -1360,10 +1347,10 @@ COUNT DosGetFattr(BYTE FAR * name, UWORD FAR * attrp) { last_cds = current_ldt; current_ldt = &CDSp->cds_table[drive]; - result = int2f_Remote_call(REM_GETATTRZ, 0, 0, 0, 0, 0, (VOID FAR *) srfa); - result = -result; + result = -int2f_Remote_call(REM_GETATTRZ, 0, 0, 0, 0, 0, (VOID FAR *) srfa); current_ldt = last_cds; *attrp = srfa[0]; + return result; } else { /* /// Use truename()'s result, which we already have in PriPathName. @@ -1378,20 +1365,17 @@ COUNT DosGetFattr(BYTE FAR * name, UWORD FAR * attrp) int i; for (i = 0; PriPathName[i] != '\0'; i++) tmp_name[i] = PriPathName[i]; tmp_name[i] = '\0'; - result = dos_getfattr(tmp_name, attrp); + return dos_getfattr(tmp_name, attrp); } -/* Sorry Ron someone else found this, see history.txt */ - return result; } COUNT DosSetFattr(BYTE FAR * name, UWORD FAR * attrp) { COUNT result, drive; struct cds FAR *last_cds; - BYTE FAR *p; if (IsDevice(name) ) { - return DE_PATHNOTFND; + return DE_FILENOTFND; } drive = get_verify_drive(name); @@ -1408,9 +1392,9 @@ COUNT DosSetFattr(BYTE FAR * name, UWORD FAR * attrp) { last_cds = current_ldt; current_ldt = &CDSp->cds_table[drive]; - result = int2f_Remote_call(REM_SETATTR, 0, 0, 0, 0, 0, MK_FP(0, attrp)); - result = -result; + result = -int2f_Remote_call(REM_SETATTR, 0, 0, 0, 0, 0, MK_FP(0, attrp)); current_ldt = last_cds; + return result; } else { /* /// Use truename()'s result, which we already have in PriPathName. @@ -1422,16 +1406,19 @@ COUNT DosSetFattr(BYTE FAR * name, UWORD FAR * attrp) int i; for (i = 0; PriPathName[i] != '\0'; i++) tmp_name[i] = PriPathName[i]; tmp_name[i] = '\0'; - result = dos_setfattr(name, attrp); + return dos_setfattr(name, attrp); } - return result; } -BYTE DosSelectDrv(BYTE drv) +UBYTE DosSelectDrv(UBYTE drv) { - if ((0 <= drv) && (drv < lastdrive) &&(CDSp->cds_table[drv].cdsFlags & 0xf000)) + struct cds FAR *cdsp = &CDSp->cds_table[drv]; + + if ((drv < lastdrive) && (cdsp->cdsFlags & CDSVALID) && + ((cdsp->cdsFlags & CDSNETWDRV) || + (cdsp->cdsDpb!=NULL && media_check(cdsp->cdsDpb)==SUCCESS))) { - current_ldt = &CDSp->cds_table[drv]; + current_ldt = cdsp; default_drive = drv; } return lastdrive; @@ -1442,7 +1429,7 @@ COUNT DosDelete(BYTE FAR *path) COUNT result, drive; if (IsDevice(path)) { - return DE_PATHNOTFND; + return DE_FILENOTFND; } drive = get_verify_drive(path); @@ -1455,12 +1442,10 @@ COUNT DosDelete(BYTE FAR *path) } current_ldt = &CDSp->cds_table[drive]; if (CDSp->cds_table[drive].cdsFlags & CDSNETWDRV) { - result = int2f_Remote_call(REM_DELETE, 0, 0, 0, 0, 0, 0); - result = -result; + return -int2f_Remote_call(REM_DELETE, 0, 0, 0, 0, 0, 0); } else { - result = dos_delete(path); + return dos_delete(path); } - return result; } COUNT DosRename(BYTE FAR * path1, BYTE FAR * path2) @@ -1468,7 +1453,7 @@ COUNT DosRename(BYTE FAR * path1, BYTE FAR * path2) COUNT result, drive1, drive2; if (IsDevice(path1) || IsDevice(path2)) { - return DE_PATHNOTFND; + return DE_FILENOTFND; } drive1 = get_verify_drive(path1); @@ -1486,12 +1471,10 @@ COUNT DosRename(BYTE FAR * path1, BYTE FAR * path2) } current_ldt = &CDSp->cds_table[drive1]; if (CDSp->cds_table[drive1].cdsFlags & CDSNETWDRV) { - result = int2f_Remote_call(REM_RENAME, 0, 0, 0, 0, 0, 0); - result = -result; + return -int2f_Remote_call(REM_RENAME, 0, 0, 0, 0, 0, 0); } else { - result = dos_rename(path1, path2); + return dos_rename(path1, path2); } - return result; } COUNT DosMkdir(BYTE FAR * dir) @@ -1512,12 +1495,10 @@ COUNT DosMkdir(BYTE FAR * dir) } current_ldt = &CDSp->cds_table[drive]; if (CDSp->cds_table[drive].cdsFlags & CDSNETWDRV) { - result = int2f_Remote_call(REM_MKDIR, 0, 0, 0, 0, 0, 0); - result = -result; + return -int2f_Remote_call(REM_MKDIR, 0, 0, 0, 0, 0, 0); } else { - result = dos_mkdir(dir); + return dos_mkdir(dir); } - return result; } COUNT DosRmdir(BYTE FAR * dir) @@ -1538,12 +1519,10 @@ COUNT DosRmdir(BYTE FAR * dir) } current_ldt = &CDSp->cds_table[drive]; if (CDSp->cds_table[drive].cdsFlags & CDSNETWDRV) { - result = int2f_Remote_call(REM_RMDIR, 0, 0, 0, 0, 0, 0); - result = -result; + return -int2f_Remote_call(REM_RMDIR, 0, 0, 0, 0, 0, 0); } else { - result = dos_rmdir(dir); + return dos_rmdir(dir); } - return result; } /* /// Added for SHARE. - Ron Cemer */ diff --git a/kernel/dosnames.c b/kernel/dosnames.c index bb2a9299..32d78668 100644 --- a/kernel/dosnames.c +++ b/kernel/dosnames.c @@ -36,6 +36,9 @@ static BYTE *dosnamesRcsId = "$Id$"; /* * $Log$ + * Revision 1.8 2001/04/15 03:21:50 bartoldeman + * See history.txt for the list of fixes. + * * Revision 1.7 2001/03/21 02:56:25 bartoldeman * See history.txt for changes. Bug fixes and HMA support are the main ones. * @@ -206,7 +209,7 @@ COUNT ParseDosName(BYTE FAR * lpszFileName, lpszLclFile = lpszFileName + 1; ++lpszFileName; } - nDirCnt = lpszLclFile - lpszLclDir; + nDirCnt = FP_OFF(lpszLclFile) - FP_OFF(lpszLclDir); /* Parse out the file name portion. */ lpszFileName = lpszLclFile; while (bAllowWildcards ? WildChar(*lpszFileName) : NameChar(*lpszFileName)) diff --git a/kernel/dsk.c b/kernel/dsk.c index 685a8e05..7b9dccb6 100644 --- a/kernel/dsk.c +++ b/kernel/dsk.c @@ -26,13 +26,15 @@ #include "portab.h" #include "globals.h" - #ifdef VERSION_STRINGS static BYTE *dskRcsId = "$Id$"; #endif /* * $Log$ + * Revision 1.14 2001/04/15 03:21:50 bartoldeman + * See history.txt for the list of fixes. + * * Revision 1.13 2001/03/27 20:27:43 bartoldeman * dsk.c (reported by Nagy Daniel), inthndlr and int25/26 fixes by Tom Ehlert. * @@ -662,7 +664,7 @@ COUNT processtable(int table_type,COUNT ptDrive, BYTE ptHead, UWORD ptCylinder, return PartitionDone; } -COUNT FAR init_call_blk_driver(rqptr rp) +COUNT FAR blk_driver(rqptr rp) { if (rp->r_unit >= nUnits && rp->r_command != C_INIT) return failure(E_UNIT); @@ -705,7 +707,7 @@ WORD _dsk_init(rqptr rp) pmiarray->mi_offset = 0l; pmiarray->mi_drive = Unit; - fsarray[Unit].fs_serialno = 0x12345678; + fsarray[Unit].fs_serialno = 0x12345678l; pbpbarray = getPBpbarray(Unit); @@ -1004,8 +1006,10 @@ static WORD Genblkdev(rqptr rp) if (!hd(miarray[rp->r_unit].mi_drive)){ y = 2; - switch(miarray[rp->r_unit].mi_size) - { + x = 8; /* any odd ball drives return this */ + if (miarray[rp->r_unit].mi_size <= 0xffff) + switch(miarray[rp->r_unit].mi_size) + { case 640l: case 720l: /* 320-360 */ x = 0; @@ -1023,15 +1027,13 @@ static WORD Genblkdev(rqptr rp) case 5760l: /* 2.88 almost forgot this one*/ x = 9; break; - default: - x = 8; /* any odd ball drives return this */ - } + } } gblp->gbio_devtype = (UBYTE) x; gblp->gbio_devattrib = (UWORD) y; gblp->gbio_media = (UBYTE) z; gblp->gbio_ncyl = miarray[rp->r_unit].mi_cyls; - gblp->gbio_bpb = bpbarray[rp->r_unit]; + fmemcpy(&gblp->gbio_bpb, &bpbarray[rp->r_unit], sizeof(gblp->gbio_bpb)); gblp->gbio_nsecs = bpbarray[rp->r_unit].bpb_nsector; break; } @@ -1092,13 +1094,10 @@ WORD blockio(rqptr rp) total = 0; trans = rp->r_trans; tmark(); - for ( - remaining = rp->r_count, - start = (rp->r_start != HUGECOUNT ? rp->r_start : rp->r_huge) + remaining = rp->r_count; + start = (rp->r_start != HUGECOUNT ? rp->r_start : rp->r_huge) + miarray[rp->r_unit].mi_offset; - remaining > 0; - remaining -= count, trans += count * SEC_SIZE, start += count - ) + while(remaining > 0) { count = ltop(&track, §or, &head, rp->r_unit, remaining, start, trans); @@ -1151,6 +1150,9 @@ WORD blockio(rqptr rp) return dskerr(ret); } total += count; + remaining -= count; + trans += count * SEC_SIZE; + start += count; } rp->r_count = total; return S_DONE; diff --git a/kernel/error.c b/kernel/error.c index 2f3b65ad..507cbbd0 100644 --- a/kernel/error.c +++ b/kernel/error.c @@ -34,6 +34,9 @@ static BYTE *errorRcsId = "$Id$"; /* * $Log$ + * Revision 1.4 2001/04/15 03:21:50 bartoldeman + * See history.txt for the list of fixes. + * * Revision 1.3 2000/05/25 20:56:21 jimtabor * Fixed project history * @@ -125,10 +128,6 @@ VOID fatal(BYTE * err_msg) for (;;) ; } -VOID FAR init_call_fatal(BYTE * err_msg) -{ - fatal(err_msg); -} #endif /* Abort, retry or fail for character devices */ diff --git a/kernel/execrh.asm b/kernel/execrh.asm index 63fbad8d..7f7bd987 100644 --- a/kernel/execrh.asm +++ b/kernel/execrh.asm @@ -30,6 +30,9 @@ ; $Id$ ; ; $Log$ +; Revision 1.6 2001/04/15 03:21:50 bartoldeman +; See history.txt for the list of fixes. +; ; Revision 1.5 2001/04/02 23:18:30 bartoldeman ; Misc, zero terminated device names and redirector bugs fixed. ; @@ -99,62 +102,33 @@ segment HMA_TEXT _execrh: push bp ; perform c entry mov bp,sp - push bp ; it will get destroyed push bx ; random char on display push si push es ; sometimes it get lost - push ds + push ds ; sp=bp-8 lds si,[bp+8] ; ds:si = device header les bx,[bp+4] ; es:bx = request header - push ds ; needed later - push si - - mov bp, execrh_ret1 ; construct return frame - push cs - push bp - - push ds ; call far the strategy - push word [si+6] - - retf -execrh_ret1: - pop si ; these were saved - pop ds - - mov bp, execrh_ret2 ; construct return frame - push cs - push bp - - push ds ; call far the interrupt - push word [si+8] - - retf -execrh_ret2: + push bp + push ds + push si ; needed later + mov ax, [si+6] + mov [bp+8], ax + call far[bp+8] ; call far the strategy + pop si ; these were saved + pop ds + pop bp + + mov ax, [si+8] + mov [bp+8], ax + call far[bp+8] ; call far the interrupt -exit_execrh: sti ; damm driver turn off ints - cld ; has gone backwards + sti ; damm driver turn off ints + cld ; has gone backwards pop ds pop es pop si pop bx pop bp - mov sp,bp - pop bp ret - - global _init_call_execrh - -_init_call_execrh: - push bp - mov bp,sp - push word [bp+12] - push word [bp+10] - push word [bp+8] - push word [bp+6] - call _execrh - mov sp,bp - pop bp - retf - diff --git a/kernel/fatdir.c b/kernel/fatdir.c index 773bccbc..e2e3cdd6 100644 --- a/kernel/fatdir.c +++ b/kernel/fatdir.c @@ -36,6 +36,9 @@ static BYTE *fatdirRcsId = "$Id$"; /* * $Log$ + * Revision 1.14 2001/04/15 03:21:50 bartoldeman + * See history.txt for the list of fixes. + * * Revision 1.13 2001/04/02 23:18:30 bartoldeman * Misc, zero terminated device names and redirector bugs fixed. * @@ -241,12 +244,12 @@ struct f_node FAR *dir_open(BYTE FAR * dirname) return NULL; } - fnp->f_dpb = (struct dpb *)TempCDS.cdsDpb; + fnp->f_dpb = TempCDS.cdsDpb; /* Perform all directory common handling after all special */ /* handling has been performed. */ - if (media_check((struct dpb *)TempCDS.cdsDpb) < 0) + if (media_check(TempCDS.cdsDpb) < 0) { release_f_node(fnp); return (struct f_node FAR *)0; @@ -450,7 +453,7 @@ COUNT dir_read(REG struct f_node FAR * fnp) /* Now that we have the block for our entry, get the */ /* directory entry. */ if (bp != NULL) - getdirent((BYTE FAR *) & bp->b_buffer[fnp->f_diroff % fnp->f_dpb->dpb_secsize], + getdirent((BYTE FAR *) & bp->b_buffer[((UWORD)fnp->f_diroff) % fnp->f_dpb->dpb_secsize], (struct dirent FAR *)&fnp->f_dir); else { @@ -484,7 +487,7 @@ COUNT dir_write(REG struct f_node FAR * fnp) if (fnp->f_flags.f_droot) { bp = getblock( - (ULONG) (fnp->f_diroff / fnp->f_dpb->dpb_secsize + (ULONG) ((UWORD)fnp->f_diroff / fnp->f_dpb->dpb_secsize + fnp->f_dpb->dpb_dirstrt), fnp->f_dpb->dpb_unit); bp->b_flag &= ~(BFR_DATA | BFR_FAT); @@ -554,7 +557,7 @@ COUNT dir_write(REG struct f_node FAR * fnp) return 0; } putdirent((struct dirent FAR *)&fnp->f_dir, - (VOID FAR *) & bp->b_buffer[fnp->f_diroff % fnp->f_dpb->dpb_secsize]); + (VOID FAR *) & bp->b_buffer[(UWORD)fnp->f_diroff % fnp->f_dpb->dpb_secsize]); bp->b_flag |= BFR_DIRTY; } return DIRENT_SIZE; @@ -589,7 +592,6 @@ COUNT dos_findfirst(UCOUNT attr, BYTE FAR * name) REG COUNT i; COUNT nDrive; BYTE *p; -/* BYTE FAR *ptr;*/ static BYTE local_name[FNAME_SIZE + 1], local_ext[FEXT_SIZE + 1]; @@ -604,7 +606,7 @@ COUNT dos_findfirst(UCOUNT attr, BYTE FAR * name) /* current directory, do a seek and read, then close the fnode. */ /* Start out by initializing the dirmatch structure. */ - dmp->dm_drive = default_drive ; + dmp->dm_drive = default_drive; dmp->dm_entry = 0; dmp->dm_cluster = 0; @@ -621,7 +623,7 @@ COUNT dos_findfirst(UCOUNT attr, BYTE FAR * name) */ if (nDrive >= 0) { - dmp->dm_drive = nDrive ; + dmp->dm_drive = nDrive; } else nDrive = default_drive; @@ -661,9 +663,8 @@ COUNT dos_findfirst(UCOUNT attr, BYTE FAR * name) if (current_ldt->cdsFlags & CDSNETWDRV) { - if (Remote_find(REM_FINDFIRST, name, dmp) != 0) - return DE_FILENOTFND; - return SUCCESS; + dmp->dm_drive |= 0x80; + return -Remote_find(REM_FINDFIRST, name, dmp); } /* /// Added code here to do matching against device names. @@ -708,17 +709,31 @@ COUNT dos_findfirst(UCOUNT attr, BYTE FAR * name) /* Now search through the directory to find the entry... */ + + /* Complete building the directory from the passed in */ + /* name */ + if (nDrive >= 0) + LocalPath[0] = 'A' + nDrive; + else + LocalPath[0] = 'A' + default_drive; + LocalPath[1] = ':'; + /* Special handling - the volume id is only in the root */ /* directory and only searched for once. So we need to open */ /* the root and return only the first entry that contains the */ /* volume id bit set. */ if ((attr & ~(D_RDONLY | D_ARCHIVE)) == D_VOLID) { - /* Now open this directory so that we can read the */ - /* fnode entry and do a match on it. */ - if ((fnp = dir_open((BYTE FAR *) "\\")) == NULL) - return DE_PATHNOTFND; + LocalPath[2] = '\\'; + LocalPath[3] = '\0'; + } + /* Now open this directory so that we can read the */ + /* fnode entry and do a match on it. */ + if ((fnp = dir_open((BYTE FAR *) LocalPath)) == NULL) + return DE_PATHNOTFND; + if ((attr & ~(D_RDONLY | D_ARCHIVE)) == D_VOLID) + { /* Now do the search */ while (dir_read(fnp) == DIRENT_SIZE) { @@ -736,23 +751,9 @@ COUNT dos_findfirst(UCOUNT attr, BYTE FAR * name) dir_close(fnp); return DE_FILENOTFND; } - /* Otherwise just do a normal find next */ else { - /* Complete building the directory from the passed in */ - /* name */ - if (nDrive >= 0) - LocalPath[0] = 'A' + nDrive; - else - LocalPath[0] = 'A' + default_drive; - LocalPath[1] = ':'; - - /* Now open this directory so that we can read the */ - /* fnode entry and do a match on it. */ - if ((fnp = dir_open((BYTE FAR *) LocalPath)) == NULL) - return DE_PATHNOTFND; - pop_dmp(dmp, fnp); dmp->dm_entry = 0; if (!fnp->f_flags.f_droot) @@ -775,9 +776,6 @@ COUNT dos_findnext(void) REG dmatch FAR *dmp = (dmatch FAR *) dta; REG struct f_node FAR *fnp; BOOL found = FALSE; -/* BYTE FAR *p;*/ -/* BYTE FAR *q;*/ - COUNT nDrive; /* assign our match parameters pointer. */ dmp = (dmatch FAR *) dta; @@ -790,50 +788,43 @@ COUNT dos_findnext(void) * test 40h. I used RamView to see location MSD 116:04be and * FD f??:04be, the byte set with 0xc4 = Remote/Network drive 4. * Ralf Brown docs for dos 4eh say bit 7 set == remote so what is - * bit 6 for? SHSUCDX Mod info say "test redir not network bit". + * bit 6 for? + * SHSUCDX Mod info say "test redir not network bit". * Just to confuse the rest, MSCDEX sets bit 5 too. * * So, assume bit 6 is redirector and bit 7 is network. * jt + * Bart: dm_drive can be the drive _letter_. + * but better just stay independent of it: we only use + * bit 7 to detect a network drive; the rest untouched. + * RBIL says that findnext can only return one error type anyway + * (12h, DE_NFILES) */ - nDrive = dmp->dm_drive & 0x1f; - - if (nDrive >= lastdrive) { - return DE_INVLDDRV; - } - current_ldt = &CDSp->cds_table[nDrive]; #if 0 - printf("findnext: %c %s\n", - nDrive + 'A', (current_ldt->cdsFlags & CDSNETWDRV)?"remote":"local"); + printf("findnext: %d\n", + dmp->dm_drive); #endif - if (current_ldt->cdsFlags & CDSNETWDRV) - { - if (Remote_find(REM_FINDNEXT, 0, dmp) != 0) - return DE_FILENOTFND; - return SUCCESS; - } + if (dmp->dm_drive & 0x80) + return -Remote_find(REM_FINDNEXT, 0, dmp); /* Allocate an fnode if possible - error return (0) if not. */ if ((fnp = get_f_node()) == (struct f_node FAR *)0) { - return DE_FILENOTFND; + return DE_NFILES; } /* Force the fnode into read-write mode */ fnp->f_mode = RDWR; - if (dmp->dm_drive >= lastdrive) { - return DE_INVLDDRV; - } /* Select the default to help non-drive specified path */ /* searches... */ - fnp->f_dpb = (struct dpb *)CDSp->cds_table[dmp->dm_drive].cdsDpb; + fnp->f_dpb = CDSp->cds_table[dmp->dm_drive].cdsDpb; if (media_check(fnp->f_dpb) < 0) { release_f_node(fnp); - return DE_FILENOTFND; + return DE_NFILES; } fnp->f_dsize = DIRENT_SIZE * (fnp->f_dpb)->dpb_dirents; diff --git a/kernel/fatfs.c b/kernel/fatfs.c index 0d574d36..23f46716 100644 --- a/kernel/fatfs.c +++ b/kernel/fatfs.c @@ -36,6 +36,9 @@ BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.14 2001/04/15 03:21:50 bartoldeman + * See history.txt for the list of fixes. + * * Revision 1.13 2001/03/30 19:30:06 bartoldeman * Misc fixes and implementation of SHELLHIGH. See history.txt for details. * @@ -247,8 +250,6 @@ COUNT map_cluster(struct f_node FAR *, COUNT); COUNT dos_open(BYTE FAR * path, COUNT flag) { REG struct f_node FAR *fnp; - COUNT i; - BYTE FAR *fnamep; /* First test the flag to see if the user has passed a valid */ /* file mode... */ @@ -296,11 +297,6 @@ COUNT dos_open(BYTE FAR * path, COUNT flag) return xlt_fnp(fnp); } -COUNT FAR init_call_dos_open(BYTE FAR * path, COUNT flag) -{ - return dos_open(path, flag); -} - BOOL fcmp(BYTE FAR * s1, BYTE FAR * s2, COUNT n) { while (n--) @@ -349,11 +345,6 @@ COUNT dos_close(COUNT fd) return SUCCESS; } -COUNT FAR init_call_dos_close(COUNT fd) -{ - return dos_close(fd); -} - /* */ /* split a path into it's component directory and file name */ /* */ @@ -378,7 +369,7 @@ struct f_node FAR * SpacePad(fname, FNAME_SIZE); SpacePad(fext, FEXT_SIZE); - if (nDrive > (lastdrive -1)) { + if (nDrive >= lastdrive) { return (struct f_node FAR *)0; } cdsp = &CDSp->cds_table[nDrive]; @@ -525,6 +516,12 @@ COUNT dos_creat(BYTE FAR * path, COUNT attrib) { REG struct f_node FAR *fnp; + /* NEVER EVER allow directories to be created */ + if (attrib & ~(D_RDONLY|D_HIDDEN|D_SYSTEM|D_ARCHIVE)) + { + return DE_ACCESS; + } + /* first split the passed dir into comopnents (i.e. - */ /* path to new directory and name of new directory */ if ((fnp = split_path(path, szDirName, szFileName, szFileExt)) == NULL) @@ -555,9 +552,6 @@ COUNT dos_creat(BYTE FAR * path, COUNT attrib) else { BOOL is_free; - REG COUNT idx; - struct buffer FAR *bp; - BYTE FAR *p; /* Reset the directory by a close followed by */ /* an open */ @@ -877,7 +871,7 @@ static VOID wipe_out(struct f_node FAR * fnp) { REG UWORD st, next; - struct dpb *dpbp = fnp->f_dpb; + struct dpb FAR *dpbp = fnp->f_dpb; /* if already free or not valid file, just exit */ if ((fnp == NULL) || (fnp->f_dir.dir_start == FREE)) @@ -954,11 +948,6 @@ date dos_getdate() #endif } -date FAR init_call_dos_getdate() -{ - return dos_getdate(); -} - /* */ /* dos_gettime for the file time */ /* */ @@ -969,8 +958,6 @@ time dos_gettime() Minute, Second, Hundredth; - time Time; - BYTE h; /* First - get the system time set by either the user */ /* on start-up or the CMOS clock */ @@ -984,11 +971,6 @@ time dos_gettime() #endif } -time FAR init_call_dos_gettime() -{ - return dos_gettime(); -} - /* */ /* dos_getftime for the file time */ /* */ @@ -1509,7 +1491,6 @@ UCOUNT readblock(COUNT fd, VOID FAR * buffer, UCOUNT count, COUNT * err) REG struct buffer FAR *bp; UCOUNT xfr_cnt = 0; UCOUNT ret_cnt = 0; - ULONG idx; UWORD secsize; UCOUNT to_xfer = count; @@ -1666,7 +1647,7 @@ UCOUNT readblock(COUNT fd, VOID FAR * buffer, UCOUNT count, COUNT * err) if (fnp->f_flags.f_ddir) xfr_cnt = min(to_xfer, secsize - fnp->f_boff); else - xfr_cnt = min(min(to_xfer, secsize - fnp->f_boff), + xfr_cnt = (UWORD)min(min(to_xfer, secsize - fnp->f_boff), fnp->f_dir.dir_size - fnp->f_offset); fbcopy((BYTE FAR *) & bp->b_buffer[fnp->f_boff], buffer, xfr_cnt); @@ -1688,7 +1669,6 @@ UCOUNT writeblock(COUNT fd, VOID FAR * buffer, UCOUNT count, COUNT * err) struct buffer FAR *bp; UCOUNT xfr_cnt = 0; UCOUNT ret_cnt = 0; - ULONG idx; UWORD secsize; UCOUNT to_xfer = count; @@ -1927,11 +1907,6 @@ COUNT dos_read(COUNT fd, VOID FAR * buffer, UCOUNT count) return err != SUCCESS ? err : xfr; } -COUNT FAR init_call_dos_read(COUNT fd, VOID FAR * buffer, UCOUNT count) -{ - return dos_read(fd, buffer, count); -} - #ifndef IPL COUNT dos_write(COUNT fd, VOID FAR * buffer, UCOUNT count) { @@ -2016,7 +1991,7 @@ LONG dos_lseek(COUNT fd, LONG foffset, COUNT origin) } /* returns the number of unused clusters */ -UWORD dos_free(struct dpb * dpbp) +UWORD dos_free(struct dpb FAR *dpbp) { /* There's an unwritten rule here. All fs */ /* cluster start at 2 and run to max_cluster+2 */ @@ -2029,7 +2004,7 @@ UWORD dos_free(struct dpb * dpbp) UWORD max_cluster = ( ((ULONG) dpbp->dpb_size * (ULONG) (dpbp->dpb_clsmask + 1)) / (dpbp->dpb_clsmask + 1) ) + 1; - if (dpbp->dpb_nfreeclst != UNKNCLUSTER) + if (dpbp->dpb_nfreeclst != UNKNCLSTFREE) return dpbp->dpb_nfreeclst; else { @@ -2048,18 +2023,13 @@ UWORD dos_free(struct dpb * dpbp) #ifndef IPL COUNT dos_cd(struct cds FAR * cdsp, BYTE FAR *PathName) { - BYTE FAR *p; struct f_node FAR *fnp; - REG struct dpb *dpbp; - COUNT x; /* first check for valid drive */ if (cdsp->cdsDpb == 0) return DE_INVLDDRV; - - dpbp = (struct dpb *)cdsp->cdsDpb; - if ((media_check(dpbp) < 0)) + if ((media_check(cdsp->cdsDpb) < 0)) return DE_INVLDDRV; /* now test for its existance. If it doesn't, return an error. */ @@ -2174,11 +2144,50 @@ COUNT dos_setfattr(BYTE FAR * name, UWORD FAR * attrp) } #endif -COUNT media_check(REG struct dpb * dpbp) +VOID bpb_to_dpb(bpb FAR *bpbp, REG struct dpb FAR * dpbp) { - bpb FAR *bpbp; ULONG size; REG COUNT i; + + dpbp->dpb_mdb = bpbp->bpb_mdesc; + dpbp->dpb_secsize = bpbp->bpb_nbyte; + dpbp->dpb_clsmask = bpbp->bpb_nsector - 1; + dpbp->dpb_fatstrt = bpbp->bpb_nreserved; + dpbp->dpb_fats = bpbp->bpb_nfat; + dpbp->dpb_dirents = bpbp->bpb_ndirent; + size = bpbp->bpb_nsize == 0 ? + bpbp->bpb_huge : + (ULONG) bpbp->bpb_nsize; +/* patch point + dpbp->dpb_size = size / ((ULONG) bpbp->bpb_nsector); +*/ + dpbp->dpb_fatsize = bpbp->bpb_nfsect; + dpbp->dpb_dirstrt = dpbp->dpb_fatstrt + + dpbp->dpb_fats * dpbp->dpb_fatsize; + dpbp->dpb_data = dpbp->dpb_dirstrt + + ((DIRENT_SIZE * dpbp->dpb_dirents + + (dpbp->dpb_secsize - 1)) + / dpbp->dpb_secsize); +/* + Michal Meller patch to jimtabor +*/ + dpbp->dpb_size = ((size - dpbp->dpb_data) / ((ULONG) bpbp->bpb_nsector) + 1); + + dpbp->dpb_flags = 0; +/* dpbp->dpb_next = (struct dpb FAR *)-1;*/ + dpbp->dpb_cluster = UNKNCLUSTER; + dpbp->dpb_nfreeclst = UNKNCLSTFREE; /* number of free clusters */ + for (i = 1, dpbp->dpb_shftcnt = 0; + i < (sizeof(dpbp->dpb_shftcnt) * 8); /* 8 bit bytes in C */ + dpbp->dpb_shftcnt++, i <<= 1) + { + if (i >= bpbp->bpb_nsector) + break; + } +} + +COUNT media_check(REG struct dpb FAR * dpbp) +{ /* First test if anyone has changed the removable media */ FOREVER { @@ -2257,42 +2266,7 @@ COUNT media_check(REG struct dpb * dpbp) } } } - bpbp = MediaReqHdr.r_bpptr; - dpbp->dpb_mdb = bpbp->bpb_mdesc; - dpbp->dpb_secsize = bpbp->bpb_nbyte; - dpbp->dpb_clsmask = bpbp->bpb_nsector - 1; - dpbp->dpb_fatstrt = bpbp->bpb_nreserved; - dpbp->dpb_fats = bpbp->bpb_nfat; - dpbp->dpb_dirents = bpbp->bpb_ndirent; - size = bpbp->bpb_nsize == 0 ? - bpbp->bpb_huge : - (ULONG) bpbp->bpb_nsize; -/* patch point - dpbp->dpb_size = size / ((ULONG) bpbp->bpb_nsector); -*/ - dpbp->dpb_fatsize = bpbp->bpb_nfsect; - dpbp->dpb_dirstrt = dpbp->dpb_fatstrt - + dpbp->dpb_fats * dpbp->dpb_fatsize; - dpbp->dpb_data = dpbp->dpb_dirstrt - + ((DIRENT_SIZE * dpbp->dpb_dirents - + (dpbp->dpb_secsize - 1)) - / dpbp->dpb_secsize); -/* - Michal Meller patch to jimtabor -*/ - dpbp->dpb_size = ((size - dpbp->dpb_data) / ((ULONG) bpbp->bpb_nsector) + 1); - - dpbp->dpb_flags = 0; -/* dpbp->dpb_next = (struct dpb FAR *)-1;*/ - dpbp->dpb_cluster = UNKNCLUSTER; - dpbp->dpb_nfreeclst = UNKNCLUSTER; /* number of free clusters */ - for (i = 1, dpbp->dpb_shftcnt = 0; - i < (sizeof(dpbp->dpb_shftcnt) * 8); /* 8 bit bytes in C */ - dpbp->dpb_shftcnt++, i <<= 1) - { - if (i >= bpbp->bpb_nsector) - break; - } + bpb_to_dpb(MediaReqHdr.r_bpptr, dpbp); return SUCCESS; } } @@ -2306,7 +2280,7 @@ struct f_node FAR *xlt_fd(COUNT fd) /* translate the f_node pointer into an fd */ COUNT xlt_fnp(struct f_node FAR * fnp) { - return fnp - f_nodes; + return (COUNT)(fnp - f_nodes); } #if 0 diff --git a/kernel/fattab.c b/kernel/fattab.c index 671b5a42..2b7fe899 100644 --- a/kernel/fattab.c +++ b/kernel/fattab.c @@ -35,6 +35,9 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.4 2001/04/15 03:21:50 bartoldeman + * See history.txt for the list of fixes. + * * Revision 1.3 2000/05/25 20:56:21 jimtabor * Fixed project history * @@ -99,10 +102,10 @@ static BYTE *RcsId = "$Id$"; */ #ifdef PROTO -UCOUNT link_fat12(struct dpb *, UCOUNT, UCOUNT); -UCOUNT link_fat16(struct dpb *, UCOUNT, UCOUNT); -UWORD next_cl12(struct dpb *, UCOUNT); -UWORD next_cl16(struct dpb *, UCOUNT); +UCOUNT link_fat12(struct dpb FAR *, UCOUNT, UCOUNT); +UCOUNT link_fat16(struct dpb FAR *, UCOUNT, UCOUNT); +UWORD next_cl12(struct dpb FAR *, UCOUNT); +UWORD next_cl16(struct dpb FAR *, UCOUNT); #else UCOUNT link_fat12(); UCOUNT link_fat16(); @@ -132,7 +135,7 @@ UWORD next_cl16(); /* 12 bytes are compressed to 9 bytes */ /* */ -UCOUNT link_fat(struct dpb *dpbp, UCOUNT Cluster1, REG UCOUNT Cluster2) +UCOUNT link_fat(struct dpb FAR *dpbp, UCOUNT Cluster1, REG UCOUNT Cluster2) { if (ISFAT12(dpbp)) return link_fat12(dpbp, Cluster1, Cluster2); @@ -142,7 +145,7 @@ UCOUNT link_fat(struct dpb *dpbp, UCOUNT Cluster1, REG UCOUNT Cluster2) return DE_BLKINVLD; } -UCOUNT link_fat16(struct dpb * dpbp, UCOUNT Cluster1, UCOUNT Cluster2) +UCOUNT link_fat16(struct dpb FAR *dpbp, UCOUNT Cluster1, UCOUNT Cluster2) { UCOUNT idx; struct buffer FAR *bp; @@ -164,7 +167,7 @@ UCOUNT link_fat16(struct dpb * dpbp, UCOUNT Cluster1, UCOUNT Cluster2) /* form an index so that we can read the block as a */ /* byte array */ - idx = (((LONG) Cluster1) * SIZEOF_CLST16) % dpbp->dpb_secsize; + idx = (UWORD)((((LONG) Cluster1) * SIZEOF_CLST16) % dpbp->dpb_secsize); /* Finally, put the word into the buffer and mark the */ /* buffer as dirty. */ @@ -177,21 +180,21 @@ UCOUNT link_fat16(struct dpb * dpbp, UCOUNT Cluster1, UCOUNT Cluster2) { /* update the free space count for returned */ /* cluster */ - if (dpbp->dpb_nfreeclst != UNKNCLUSTER) + if (dpbp->dpb_nfreeclst != UNKNCLSTFREE) ++dpbp->dpb_nfreeclst; } else { /* update the free space count for removed */ /* cluster */ - if (dpbp->dpb_nfreeclst != UNKNCLUSTER) + if (dpbp->dpb_nfreeclst != UNKNCLSTFREE) --dpbp->dpb_nfreeclst; } return SUCCESS; } -UCOUNT link_fat12(struct dpb * dpbp, UCOUNT Cluster1, UCOUNT Cluster2) +UCOUNT link_fat12(struct dpb FAR *dpbp, UCOUNT Cluster1, UCOUNT Cluster2) { REG UBYTE FAR *fbp0, FAR * fbp1; @@ -253,7 +256,7 @@ UCOUNT link_fat12(struct dpb * dpbp, UCOUNT Cluster1, UCOUNT Cluster2) else { *fbp0 = Cluster2 & 0xff; - *fbp1 = (*fbp1 & 0xf0) | (Cluster2 >> 8) & 0x0f; + *fbp1 = (*fbp1 & 0xf0) | ((Cluster2 >> 8) & 0x0f); } /* update the free space count */ @@ -261,14 +264,14 @@ UCOUNT link_fat12(struct dpb * dpbp, UCOUNT Cluster1, UCOUNT Cluster2) { /* update the free space count for returned */ /* cluster */ - if (dpbp->dpb_nfreeclst != UNKNCLUSTER) + if (dpbp->dpb_nfreeclst != UNKNCLSTFREE) ++dpbp->dpb_nfreeclst; } else { /* update the free space count for removed */ /* cluster */ - if (dpbp->dpb_nfreeclst != UNKNCLUSTER) + if (dpbp->dpb_nfreeclst != UNKNCLSTFREE) --dpbp->dpb_nfreeclst; } @@ -277,7 +280,7 @@ UCOUNT link_fat12(struct dpb * dpbp, UCOUNT Cluster1, UCOUNT Cluster2) /* Given the disk parameters, and a cluster number, this function looks at the FAT, and returns the next cluster in the clain. */ -UWORD next_cluster(struct dpb * dpbp, REG UCOUNT ClusterNum) +UWORD next_cluster(struct dpb FAR *dpbp, REG UCOUNT ClusterNum) { if (ISFAT12(dpbp)) return next_cl12(dpbp, ClusterNum); @@ -287,7 +290,7 @@ UWORD next_cluster(struct dpb * dpbp, REG UCOUNT ClusterNum) return LONG_LAST_CLUSTER; } -UWORD next_cl16(struct dpb * dpbp, REG UCOUNT ClusterNum) +UWORD next_cl16(struct dpb FAR *dpbp, REG UCOUNT ClusterNum) { UCOUNT idx; struct buffer FAR *bp; @@ -309,7 +312,7 @@ UWORD next_cl16(struct dpb * dpbp, REG UCOUNT ClusterNum) /* form an index so that we can read the block as a */ /* byte array */ - idx = (((LONG) ClusterNum) * SIZEOF_CLST16) % dpbp->dpb_secsize; + idx = (ClusterNum * SIZEOF_CLST16) % dpbp->dpb_secsize; /* Get the cluster number, */ fgetword((VOID FAR *) & (bp->b_buffer[idx]), (WORD FAR *) & RetCluster); @@ -318,7 +321,7 @@ UWORD next_cl16(struct dpb * dpbp, REG UCOUNT ClusterNum) return RetCluster; } -UWORD next_cl12(struct dpb * dpbp, REG UCOUNT ClusterNum) +UWORD next_cl12(struct dpb FAR *dpbp, REG UCOUNT ClusterNum) { REG UBYTE FAR *fbp0, FAR * fbp1; @@ -373,7 +376,7 @@ UWORD next_cl12(struct dpb * dpbp, REG UCOUNT ClusterNum) /* Now to unpack the contents of the FAT entry. Odd and */ /* even bytes are packed differently. */ if (ClusterNum & 0x01) - ClusterNum = ((*fbp0 & 0xf0) >> 4) | *fbp1 << 4; + ClusterNum = ((*fbp0 & 0xf0) >> 4) | (*fbp1 << 4); else ClusterNum = *fbp0 | ((*fbp1 & 0x0f) << 8); diff --git a/kernel/fcbfns.c b/kernel/fcbfns.c index 3993b4ac..1b057004 100644 --- a/kernel/fcbfns.c +++ b/kernel/fcbfns.c @@ -35,6 +35,9 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.9 2001/04/15 03:21:50 bartoldeman + * See history.txt for the list of fixes. + * * Revision 1.8 2001/03/30 22:27:42 bartoldeman * Saner lastdrive handling. * @@ -131,7 +134,7 @@ fcb FAR *CommonFcbInit(xfcb FAR * lpExtFcb, BYTE * pszBuffer, COUNT * pCurDrive) void FcbNameInit(fcb FAR * lpFcb, BYTE * pszBuffer, COUNT * pCurDrive); sft FAR *FcbGetSft(COUNT SftIndex); VOID FcbNextRecord(fcb FAR * lpFcb); -sft FAR *FcbGetFreeSft(WORD FAR * sft_idx); +/* sft FAR *FcbGetFreeSft(WORD FAR * sft_idx); */ BOOL FcbCalcRec(xfcb FAR * lpXfcb); VOID MoveDirInfo(dmatch FAR * lpDmatch, struct dirent FAR * lpDir); #else @@ -140,7 +143,7 @@ fcb FAR *CommonFcbInit(); void FcbNameInit(); sft FAR *FcbGetSft(); VOID FcbNextRecord(); -sft FAR *FcbGetFreeSft(); +/* sft FAR *FcbGetFreeSft(); */ BOOL FcbCalcRec(); VOID MoveDirInfo(); #endif @@ -150,12 +153,12 @@ static dmatch Dmatch; VOID FatGetDrvData(COUNT drive, COUNT FAR * spc, COUNT FAR * bps, COUNT FAR * nc, BYTE FAR ** mdp) { - struct dpb *dpbp; + struct dpb FAR *dpbp; printf("FGDD\n"); /* first check for valid drive */ - if ((drive < 0) || (drive >= lastdrive) || (drive >= NDEVS)) + if ((UCOUNT)drive >= lastdrive) { *spc = -1; return; @@ -168,7 +171,7 @@ VOID FatGetDrvData(COUNT drive, COUNT FAR * spc, COUNT FAR * bps, *spc = -1; return; } - dpbp = (struct dpb *)CDSp->cds_table[drive].cdsDpb; + dpbp = CDSp->cds_table[drive].cdsDpb; dpbp->dpb_flags = -1; if ((media_check(dpbp) < 0)) { @@ -181,8 +184,8 @@ VOID FatGetDrvData(COUNT drive, COUNT FAR * spc, COUNT FAR * bps, *spc = dpbp->dpb_clsmask + 1; *bps = dpbp->dpb_secsize; - /* Point to the media desctriptor fotr this drive */ - *mdp = &(dpbp->dpb_mdb); + /* Point to the media desctriptor for this drive */ + *mdp = (BYTE FAR*)&(dpbp->dpb_mdb); } #define PARSE_SEP_STOP 0x01 @@ -347,6 +350,13 @@ static VOID FcbNextRecord(fcb FAR * lpFcb) } } +static ULONG FcbRec(VOID) +{ + UWORD tmp = 128; + + return ((ULONG)lpFcb->fcb_cublock * tmp) + lpFcb->fcb_curec; +} + BOOL FcbRead(xfcb FAR * lpXfcb, COUNT * nErrorCode) { sft FAR *s; @@ -367,8 +377,7 @@ BOOL FcbRead(xfcb FAR * lpXfcb, COUNT * nErrorCode) /* Now update the fcb and compute where we need to position */ /* to. */ - lPosit = ((lpFcb->fcb_cublock * 128) + lpFcb->fcb_curec) - * lpFcb->fcb_recsiz; + lPosit = FcbRec() * lpFcb->fcb_recsiz; if (SftSeek(s, lPosit, 0) != SUCCESS) { *nErrorCode = FCB_ERR_EOF; @@ -439,8 +448,7 @@ BOOL FcbWrite(xfcb FAR * lpXfcb, COUNT * nErrorCode) /* Now update the fcb and compute where we need to position */ /* to. */ - lPosit = ((lpFcb->fcb_cublock * 128) + lpFcb->fcb_curec) - * lpFcb->fcb_recsiz; + lPosit = FcbRec() * lpFcb->fcb_recsiz; if (SftSeek(s, lPosit, 0) != SUCCESS) { *nErrorCode = FCB_ERR_EOF; @@ -511,30 +519,27 @@ BOOL FcbGetFileSize(xfcb FAR * lpXfcb) BOOL FcbSetRandom(xfcb FAR * lpXfcb) { - LONG lPosit; - /* Convert to fcb if necessary */ lpFcb = ExtFcbToFcb(lpXfcb); /* Now update the fcb and compute where we need to position */ - /* to. */ - lpFcb->fcb_rndm = (lpFcb->fcb_cublock * 128) - + lpFcb->fcb_curec; + /* to. */ + lpFcb->fcb_rndm = FcbRec(); return TRUE; } BOOL FcbCalcRec(xfcb FAR * lpXfcb) { - LONG lPosit; - + UWORD div=128; + /* Convert to fcb if necessary */ lpFcb = ExtFcbToFcb(lpXfcb); /* Now update the fcb and compute where we need to position */ /* to. */ - lpFcb->fcb_cublock = lpFcb->fcb_rndm / 128; - lpFcb->fcb_curec = lpFcb->fcb_rndm % 128; + lpFcb->fcb_cublock = lpFcb->fcb_rndm / div; + lpFcb->fcb_curec = lpFcb->fcb_rndm & 127; return TRUE; } @@ -551,7 +556,7 @@ BOOL FcbRandomBlockRead(xfcb FAR * lpXfcb, COUNT nRecords, COUNT * nErrorCode) while ((--nRecords > 0) && (*nErrorCode == 0)); /* Now update the fcb */ - lpFcb->fcb_rndm = lpFcb->fcb_cublock * 128 + lpFcb->fcb_curec; + lpFcb->fcb_rndm = FcbRec(); return TRUE; } @@ -568,32 +573,13 @@ BOOL FcbRandomBlockWrite(xfcb FAR * lpXfcb, COUNT nRecords, COUNT * nErrorCode) while ((--nRecords > 0) && (*nErrorCode == 0)); /* Now update the fcb */ - lpFcb->fcb_rndm = lpFcb->fcb_cublock * 128 + lpFcb->fcb_curec; - - return TRUE; -} - -BOOL FcbRandomRead(xfcb FAR * lpXfcb, COUNT * nErrorCode) -{ - UWORD uwCurrentBlock; - UBYTE ucCurrentRecord; - - FcbCalcRec(lpXfcb); - - /* Convert to fcb if necessary */ - lpFcb = ExtFcbToFcb(lpXfcb); + lpFcb->fcb_rndm = FcbRec(); - uwCurrentBlock = lpFcb->fcb_cublock; - ucCurrentRecord = lpFcb->fcb_curec; - - FcbRead(lpXfcb, nErrorCode); - - lpFcb->fcb_cublock = uwCurrentBlock; - lpFcb->fcb_curec = ucCurrentRecord; return TRUE; } -BOOL FcbRandomWrite(xfcb FAR * lpXfcb, COUNT * nErrorCode) +BOOL FcbRandomIO(xfcb FAR * lpXfcb, COUNT * nErrorCode, + BOOL (*FcbFunc)(xfcb FAR *, COUNT *)) { UWORD uwCurrentBlock; UBYTE ucCurrentRecord; @@ -606,37 +592,17 @@ BOOL FcbRandomWrite(xfcb FAR * lpXfcb, COUNT * nErrorCode) uwCurrentBlock = lpFcb->fcb_cublock; ucCurrentRecord = lpFcb->fcb_curec; - FcbWrite(lpXfcb, nErrorCode); + (*FcbFunc)(lpXfcb, nErrorCode); lpFcb->fcb_cublock = uwCurrentBlock; lpFcb->fcb_curec = ucCurrentRecord; return TRUE; } +/* static sft FAR *FcbGetFreeSft(WORD FAR * sft_idx) -{ - WORD sys_idx = 0; - sfttbl FAR *sp; - - /* Get the SFT block that contains the SFT */ - for (sp = sfthead; sp != (sfttbl FAR *) - 1; sp = sp->sftt_next) - { - REG WORD i; - - for (i = 0; i < sp->sftt_count; i++) - { - if (sp->sftt_table[i].sft_count == 0) - { - *sft_idx = sys_idx + i; - return (sft FAR *) & sp->sftt_table[sys_idx + i]; - } - } - sys_idx += i; - } - - /* If not found, return an error */ - return (sft FAR *) - 1; -} +see get_free_sft in dosfns.c +*/ BOOL FcbCreate(xfcb FAR * lpXfcb) { @@ -646,7 +612,7 @@ BOOL FcbCreate(xfcb FAR * lpXfcb) COUNT FcbDrive; /* get a free system file table entry */ - if ((sftp = FcbGetFreeSft((WORD FAR *) & sft_idx)) == (sft FAR *) - 1) + if ((sftp = get_free_sft((WORD FAR *) & sft_idx)) == (sft FAR *) - 1) return DE_TOOMANY; /* Build a traditional DOS file name */ @@ -654,46 +620,27 @@ BOOL FcbCreate(xfcb FAR * lpXfcb) /* check for a device */ dhp = IsDevice(PriPathName); - if (dhp) - { - sftp->sft_count += 1; - sftp->sft_mode = O_RDWR; - sftp->sft_attrib = 0; - sftp->sft_flags = - ((dhp->dh_attr & ~SFT_MASK) & ~SFT_FSHARED) | SFT_FDEVICE | SFT_FEOF; - sftp->sft_psp = cu_psp; - fbcopy(lpFcb->fcb_fname, sftp->sft_name, FNAME_SIZE + FEXT_SIZE); - sftp->sft_dev = dhp; - lpFcb->fcb_sftno = sft_idx; - lpFcb->fcb_curec = 0; - lpFcb->fcb_recsiz = 0; - lpFcb->fcb_fsize = 0; - lpFcb->fcb_date = dos_getdate(); - lpFcb->fcb_time = dos_gettime(); - lpFcb->fcb_rndm = 0; - return TRUE; - } - sftp->sft_status = dos_creat(PriPathName, 0); - if (sftp->sft_status >= 0) + if (dhp || ((sftp->sft_status = dos_creat(PriPathName, 0)) >= 0)) { - lpFcb->fcb_drive = FcbDrive; + sftp->sft_count += 1; + sftp->sft_mode = O_RDWR; + sftp->sft_attrib = 0; + sftp->sft_flags = dhp ? + ((dhp->dh_attr & ~SFT_MASK) & ~SFT_FSHARED) | SFT_FDEVICE | SFT_FEOF : 0; + sftp->sft_psp = cu_psp; + fbcopy(lpFcb->fcb_fname, sftp->sft_name, FNAME_SIZE + FEXT_SIZE); + sftp->sft_dev = dhp; lpFcb->fcb_sftno = sft_idx; lpFcb->fcb_curec = 0; - lpFcb->fcb_recsiz = 128; + lpFcb->fcb_recsiz = (dhp ? 0 : 128); + if (!dhp) lpFcb->fcb_drive = FcbDrive; lpFcb->fcb_fsize = 0; lpFcb->fcb_date = dos_getdate(); lpFcb->fcb_time = dos_gettime(); lpFcb->fcb_rndm = 0; - sftp->sft_count += 1; - sftp->sft_mode = O_RDWR; - sftp->sft_attrib = 0; - sftp->sft_flags = 0; - sftp->sft_psp = cu_psp; - fbcopy((BYTE FAR *) & lpFcb->fcb_fname, (BYTE FAR *) & sftp->sft_name, FNAME_SIZE + FEXT_SIZE); return TRUE; } - else - return FALSE; + return FALSE; } static fcb FAR *ExtFcbToFcb(xfcb FAR * lpExtFcb) @@ -707,11 +654,6 @@ static fcb FAR *ExtFcbToFcb(xfcb FAR * lpExtFcb) static fcb FAR *CommonFcbInit(xfcb FAR * lpExtFcb, BYTE * pszBuffer, COUNT * pCurDrive) { - BYTE FAR *lpszFcbFname, - *lpszFcbFext; - COUNT nDrvIdx, - nFnameIdx, - nFextIdx; fcb FAR *lpFcb; /* convert to fcb if needed first */ @@ -726,10 +668,6 @@ static fcb FAR *CommonFcbInit(xfcb FAR * lpExtFcb, BYTE * pszBuffer, void FcbNameInit(fcb FAR * lpFcb, BYTE * pszBuffer, COUNT * pCurDrive) { - BYTE FAR *lpszFcbFname, - FAR * lpszFcbFext; - COUNT loop; - /* Build a traditional DOS file name */ if (lpFcb->fcb_drive != 0) { @@ -779,7 +717,7 @@ BOOL FcbOpen(xfcb FAR * lpXfcb) COUNT FcbDrive; /* get a free system file table entry */ - if ((sftp = FcbGetFreeSft((WORD FAR *) & sft_idx)) == (sft FAR *) - 1) + if ((sftp = get_free_sft((WORD FAR *) & sft_idx)) == (sft FAR *) - 1) return DE_TOOMANY; /* Build a traditional DOS file name */ @@ -807,7 +745,7 @@ BOOL FcbOpen(xfcb FAR * lpXfcb) return TRUE; } fbcopy((BYTE FAR *) & lpFcb->fcb_fname, (BYTE FAR *) & sftp->sft_name, FNAME_SIZE + FEXT_SIZE); - if ((FcbDrive < 0) || (FcbDrive >= lastdrive)) { + if ((UCOUNT)FcbDrive >= lastdrive) { return DE_INVLDDRV; } if (CDSp->cds_table[FcbDrive].cdsFlags & CDSNETWDRV) { @@ -853,7 +791,7 @@ BOOL FcbDelete(xfcb FAR * lpXfcb) /* Build a traditional DOS file name */ CommonFcbInit(lpXfcb, PriPathName, &FcbDrive); - if ((FcbDrive < 0) || (FcbDrive >= lastdrive)) { + if ((UCOUNT)FcbDrive >= lastdrive) { return DE_INVLDDRV; } current_ldt = &CDSp->cds_table[FcbDrive]; @@ -927,16 +865,8 @@ BOOL FcbRename(xfcb FAR * lpXfcb) /* First, expand the find match into fcb style */ /* file name entry */ /* Fill with blanks first */ - for (pToName = LocalFcb.fcb_fname, nIndex = 0; - nIndex < FNAME_SIZE; nIndex++) - { - *pToName++ = ' '; - } - for (pToName = LocalFcb.fcb_fext, nIndex = 0; - nIndex < FEXT_SIZE; nIndex++) - { - *pToName++ = ' '; - } + memset(LocalFcb.fcb_fname, ' ', FNAME_SIZE); + memset(LocalFcb.fcb_fext, ' ', FEXT_SIZE); /* next move in the file name while overwriting */ /* the filler blanks */ @@ -1006,21 +936,14 @@ void MoveDirInfo(dmatch FAR * lpDmatch, struct dirent FAR * lpDir) /* First, expand the find match into dir style */ /* file name entry */ /* Fill with blanks first */ - for (lpToName = lpDir->dir_name, nIndex = 0; - nIndex < FNAME_SIZE; nIndex++) - { - *lpToName++ = ' '; - } - for (lpToName = lpDir->dir_ext, nIndex = 0; - nIndex < FEXT_SIZE; nIndex++) - { - *lpToName++ = ' '; - } + + fmemset(lpDir->dir_name, ' ', FNAME_SIZE); + fmemset(lpDir->dir_ext , ' ', FEXT_SIZE ); /* next move in the file name while overwriting */ /* the filler blanks */ lpszFrom = lpDmatch->dm_name; - lpToName = lpDir->dir_name; + lpToName = (BYTE FAR *)lpDir->dir_name; for (nIndex = 0; nIndex < FNAME_SIZE; nIndex++) { if (*lpszFrom != 0 && *lpszFrom != '.') @@ -1033,7 +956,7 @@ void MoveDirInfo(dmatch FAR * lpDmatch, struct dirent FAR * lpDir) { if (*lpszFrom == '.') ++lpszFrom; - lpToName = lpDir->dir_ext; + lpToName = (BYTE FAR *)lpDir->dir_ext; for (nIndex = 0; nIndex < FEXT_SIZE; nIndex++) { if (*lpszFrom != '\0') @@ -1098,10 +1021,8 @@ BOOL FcbClose(xfcb FAR * lpXfcb) BOOL FcbFindFirst(xfcb FAR * lpXfcb) { - BYTE FAR *lpOldDta; BYTE FAR *lpDir; - COUNT nIdx, - FcbDrive; + COUNT FcbDrive; psp FAR *lpPsp = MK_FP(cu_psp, 0); /* First, move the dta to a local and change it around to match */ @@ -1152,10 +1073,8 @@ BOOL FcbFindFirst(xfcb FAR * lpXfcb) BOOL FcbFindNext(xfcb FAR * lpXfcb) { - BYTE FAR *lpOldDta; BYTE FAR *lpDir; - COUNT nIdx, - FcbDrive; + COUNT FcbDrive; psp FAR *lpPsp = MK_FP(cu_psp, 0); /* First, move the dta to a local and change it around to match */ diff --git a/kernel/globals.h b/kernel/globals.h index 005b8dc2..b6090106 100644 --- a/kernel/globals.h +++ b/kernel/globals.h @@ -36,6 +36,9 @@ static BYTE *Globals_hRcsId = "$Id$"; /* * $Log$ + * Revision 1.11 2001/04/15 03:21:50 bartoldeman + * See history.txt for the list of fixes. + * * Revision 1.10 2001/04/02 23:18:30 bartoldeman * Misc, zero terminated device names and redirector bugs fixed. * @@ -226,7 +229,6 @@ static BYTE *Globals_hRcsId = "$Id$"; #define PARSE_MAX 67 /* maximum # of bytes in path */ #define NFILES 16 /* number of files in table */ #define NFCBS 16 /* number of fcbs */ -#define NDEVS 26 /* number of supported devices */ #define NSTACKS 8 /* number of stacks */ #define NLAST 6 /* last drive */ #define NAMEMAX PARSE_MAX /* Maximum path for CDS */ @@ -476,7 +478,7 @@ extern sfttbl FAR * FCBp; /* FCB table pointer */ extern WORD nprotfcb; /* number of protected fcbs */ -extern BYTE +extern UBYTE nblkdev, /* number of block devices */ lastdrive, /* value of last drive */ uppermem_link; /* UMB Link flag */ @@ -615,9 +617,6 @@ GLOBAL iregs error_regs; /* registers for dump */ GLOBAL WORD dump_regs; /* dump registers of bad call */ -GLOBAL struct dpb - blk_devices[NDEVS]; - GLOBAL struct f_node FAR * f_nodes; /* pointer to the array */ @@ -635,7 +634,7 @@ GLOBAL iregs FAR * kstackp; /* kernel stack */ /* Start of configuration variables */ -GLOBAL struct config +extern struct config { UBYTE cfgBuffers; /* number of buffers in the system */ UBYTE cfgFiles; /* number of available files */ @@ -643,7 +642,7 @@ GLOBAL struct config UBYTE cfgProtFcbs; /* number of protected FCBs */ BYTE cfgInit[NAMEMAX]; /* init of command.com */ BYTE cfgInitTail[NAMEMAX]; /* command.com's tail */ - BYTE cfgLastdrive; /* last drive */ + UBYTE cfgLastdrive; /* last drive */ BYTE cfgStacks; /* number of stacks */ UWORD cfgStackSize; /* stacks size for each stack */ /* COUNTRY= @@ -658,7 +657,7 @@ GLOBAL struct config VOID FAR *cfgCSYS_data; /* where the loaded data is for PostConfig() */ UBYTE cfgP_0_startmode; /* load command.com high or not */ } Config -#ifdef MAIN +#ifdef CONFIG = { NUMBUFF, @@ -704,11 +703,7 @@ CriticalError( VOID FAR CharMapSrvc(VOID); VOID FAR set_stack(VOID); VOID FAR restore_stack(VOID); -#ifndef IN_INIT_MOD WORD execrh(request FAR *, struct dhdr FAR *); -#endif -VOID FAR init_call_execrh(request FAR *, struct dhdr FAR *); -VOID FAR reloc_call_execrh(request FAR *, struct dhdr FAR *); VOID exit(COUNT); /*VOID INRPT FAR handle_break(VOID); */ VOID tmark(VOID); @@ -783,7 +778,7 @@ VOID fputbyte(); /*#define is_leap_year(y) ((y) & 3 ? 0 : (y) % 100 ? 1 : (y) % 400 ? 0 : 1) */ /* ^Break handling */ -void FAR _init_call_spawn_int23(void); /* procsupt.asm */ +void spawn_int23(void); /* procsupt.asm */ int control_break(void); /* break.c */ void handle_break(void); /* break.c */ diff --git a/kernel/init-mod.h b/kernel/init-mod.h index 23565209..cea37a07 100644 --- a/kernel/init-mod.h +++ b/kernel/init-mod.h @@ -12,11 +12,6 @@ */ #define DosExec reloc_call_DosExec #define DosMemAlloc reloc_call_DosMemAlloc -#define dos_close reloc_call_dos_close -#define dos_getdate reloc_call_dos_getdate -#define dos_gettime reloc_call_dos_gettime -#define dos_open reloc_call_dos_open -#define dos_read reloc_call_dos_read #define execrh reloc_call_execrh #define fatal reloc_call_fatal #define fmemcpy reloc_call_fmemcpy @@ -29,3 +24,5 @@ #define strlen reloc_call_strlen #define WritePCClock reloc_call_WritePCClock #define DaysFromYearMonthDay reloc_call_DaysFromYearMonthDay +#define p_0 reloc_call_p_0 + diff --git a/kernel/inithma.c b/kernel/inithma.c index eb1cd1fb..725bd261 100644 --- a/kernel/inithma.c +++ b/kernel/inithma.c @@ -75,6 +75,9 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.3 2001/04/15 03:21:50 bartoldeman + * See history.txt for the list of fixes. + * * Revision 1.2 2001/03/30 19:30:06 bartoldeman * Misc fixes and implementation of SHELLHIGH. See history.txt for details. * @@ -92,11 +95,11 @@ WORD HMAFree; /* first byte in HMA not yet used */ extern BYTE FAR * FAR XMSDriverAddress; -extern FAR _EnableA20(); -extern FAR _DisableA20(); +extern FAR _EnableA20(VOID); +extern FAR _DisableA20(VOID); -void FAR *DetectXMSDriver(); +extern void FAR *DetectXMSDriver(VOID); #ifdef DEBUG #define int3() __int__(3); @@ -105,7 +108,7 @@ void FAR *DetectXMSDriver(); #endif -#if defined( DEBUG ) || 1 /* experimental kernel !! */ +#ifdef DEBUG #define HMAInitPrintf(x) printf x #else #define HMAInitPrintf(x) @@ -184,7 +187,7 @@ void _DisableHMA() if so, it simply leaves it on */ -int EnableHMA() +int EnableHMA(VOID) { _EnableA20(); @@ -263,12 +266,13 @@ int MoveKernelToHMA() /* A) for debugging purpose, suppress this, if any shift key is pressed */ - +#ifdef DEBUG if (KeyboardShiftState() & 0x0f) { printf("Keyboard state is %0x, NOT moving to HMA\n",KeyboardShiftState()); return FALSE; } +#endif /* B) check out, if we can have HMA */ @@ -288,7 +292,7 @@ int MoveKernelToHMA() len = FP_OFF(_HMATextEnd) - FP_OFF(_HMATextStart); - HMASource = _HMATextStart; + HMASource = (UBYTE FAR *)_HMATextStart; len += FP_OFF(HMASource) & 0x000f; @@ -340,7 +344,6 @@ int MoveKernelToHMA() struct RelocationTable FAR *rp, rtemp ; - UWORD HMATextSegment = FP_SEG( _HMATextStart ); /* verify, that all entries are valid */ @@ -371,8 +374,46 @@ int MoveKernelToHMA() rel->callNear = rtemp.callNear; rel->callOffset = rtemp.callOffset+5; /* near calls are relative */ } + } + { + struct initRelocationTable { + UBYTE callNear; + UWORD callOffset; + UBYTE jmpFar; + UWORD jmpOffset; + UWORD jmpSegment; + }; + extern struct initRelocationTable + FAR _HMAinitRelocationTableStart[], + FAR _HMAinitRelocationTableEnd[]; + struct initRelocationTable FAR *rp, FAR *endrp; + + /* verify, that all entries are valid */ + + UWORD HMATextSegment = FP_SEG( _HMATextStart ); + endrp = MK_FP(_CS, FP_OFF(_HMAinitRelocationTableEnd)); - + for (rp = MK_FP(_CS, FP_OFF(_HMAinitRelocationTableStart)); rp < endrp; rp++) + { + if ( + rp->callNear != 0xe8 || /* call NEAR */ + rp->jmpFar != 0xea || /* jmp FAR */ + rp->jmpSegment != HMATextSegment || /* will only relocate HMA_TEXT */ + 0) + { + printf("illegal init relocation entry # %d\n", + FP_OFF(rp) - FP_OFF(_HMAinitRelocationTableStart)); + goto errorReturn; + } + } + + /* OK, all valid, go to relocate*/ + + for (rp = MK_FP(_CS, FP_OFF(_HMAinitRelocationTableStart)); rp < endrp; rp++) + { + rp->jmpSegment = HMASEGMENT; + rp->callOffset = rp->callOffset-5; /* near calls are relative */ + } } { @@ -414,7 +455,7 @@ int MoveKernelToHMA() so: we install this after all drivers have been loaded */ -void InstallVDISK() +void InstallVDISK(VOID) { static struct { /* Boot-Sektor of a RAM-Disk */ UBYTE dummy1[3]; /* HIMEM.SYS uses 3, but FDXMS uses 2 */ @@ -447,7 +488,6 @@ void InstallVDISK() int init_call_XMScall( void FAR * driverAddress, UWORD ax, UWORD dx); -void init_call_intr(int intrnr, iregs *rp); /* @@ -455,7 +495,7 @@ void init_call_intr(int intrnr, iregs *rp); it might be HIMEM.SYS we just loaded. */ -void ClaimHMA() +void ClaimHMA(VOID) { void FAR *pXMS; @@ -476,21 +516,6 @@ void ClaimHMA() } } } -void FAR *DetectXMSDriver() -{ - iregs regs; - - regs.a.x = 0x4300; /* XMS installation check */ - init_call_intr(0x2f, ®s); - - if ((regs.a.x & 0xff) != 0x80) return NULL; - - regs.a.x = 0x4310; /* XMS get driver address */ - init_call_intr(0x2f, ®s); - - return MK_FP(regs.es, regs.b.x); -} - /* this should be called, after each device driver diff --git a/kernel/inthndlr.c b/kernel/inthndlr.c index a205d12b..d8cdd285 100644 --- a/kernel/inthndlr.c +++ b/kernel/inthndlr.c @@ -26,6 +26,7 @@ /* Cambridge, MA 02139, USA. */ /* */ /****************************************************************/ +#define MAIN #include "portab.h" #include "globals.h" @@ -36,6 +37,9 @@ BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.20 2001/04/15 03:21:50 bartoldeman + * See history.txt for the list of fixes. + * * Revision 1.19 2001/04/02 23:18:30 bartoldeman * Misc, zero terminated device names and redirector bugs fixed. * @@ -344,10 +348,6 @@ VOID int21_service(iregs FAR * r) #define SET_CARRY_FLAG() r->FLAGS |= FLG_CARRY p->ps_stack = (BYTE FAR *) r; - - - - #ifdef DEBUG if (bDumpRegs) @@ -359,6 +359,10 @@ VOID int21_service(iregs FAR * r) } #endif + if(r->AH >=0x38 && r->AH <= 0x4F) + CLEAR_CARRY_FLAG(); + /* Clear carry by default for these functions */ + dispatch: /* Check for Ctrl-Break */ @@ -385,7 +389,6 @@ VOID int21_service(iregs FAR * r) { /* int 21h common error handler */ case 0x64: - case 0x6b: error_invalid: r->AX = -DE_INVLDFUNC; goto error_out; @@ -393,7 +396,7 @@ VOID int21_service(iregs FAR * r) r->AX = -rc; error_out: CritErrCode = r->AX; /* Maybe set */ - r->FLAGS |= FLG_CARRY; + SET_CARRY_FLAG(); break; /* case 0x00: --> Simulate a DOS-4C-00 */ @@ -412,32 +415,40 @@ VOID int21_service(iregs FAR * r) /* Auxiliary Input */ case 0x03: - r->AL = _sti(); + { + COUNT scratch; + GenericRead(STDAUX, 1, (BYTE FAR *) & r->AL, (COUNT FAR *) & scratch, TRUE); break; + } /* Auxiliary Output */ case 0x04: - sto(r->DL); + { + COUNT scratch; + DosWrite(STDAUX, 1, (BYTE FAR *) & r->DL, (COUNT FAR *) &scratch); break; - + } /* Print Character */ case 0x05: - sto(r->DL); - break; + { + COUNT scratch; + DosWrite(STDPRN, 1, (BYTE FAR *) & r->DL, (COUNT FAR *) &scratch); + break; + } - /* Direct Cosole I/O */ + /* Direct Console I/O */ case 0x06: if (r->DL != 0xff) sto(r->DL); else if (StdinBusy()) { - r->FLAGS &= ~FLG_ZERO; - r->AL = _sti(); + r->AL = 0x00; + r->FLAGS |= FLG_ZERO; } else { - r->AL = 0x00; - r->FLAGS |= FLG_ZERO; + r->FLAGS &= ~FLG_ZERO; + r->AL = _sti(); } break; @@ -457,7 +468,7 @@ VOID int21_service(iregs FAR * r) q = FP_DS_DX; while (*q != '$') ++q; - DosWrite(STDOUT, q - (BYTE FAR*)FP_DS_DX, FP_DS_DX, (COUNT FAR *) & scratch); + DosWrite(STDOUT, FP_OFF(q) - FP_OFF(FP_DS_DX), FP_DS_DX, (COUNT FAR *) & scratch); } r->AL = '$'; break; @@ -587,6 +598,7 @@ VOID int21_service(iregs FAR * r) #ifndef TSC case 0x61: #endif + case 0x6b: r->AL = 0; break; @@ -639,7 +651,7 @@ VOID int21_service(iregs FAR * r) case 0x1f: if (default_drive < lastdrive) { - struct dpb FAR *dpb = (struct dpb FAR *)CDSp->cds_table[default_drive].cdsDpb; + struct dpb FAR *dpb = CDSp->cds_table[default_drive].cdsDpb; if (dpb == 0) { r->AL = 0xff; @@ -660,7 +672,7 @@ VOID int21_service(iregs FAR * r) /* Random read using FCB */ case 0x21: { - if (FcbRandomRead(FP_DS_DX, &CritErrCode)) + if (FcbRandomIO(FP_DS_DX, &CritErrCode, FcbRead)) r->AL = 0; else r->AL = CritErrCode; @@ -670,7 +682,7 @@ VOID int21_service(iregs FAR * r) /* Random write using FCB */ case 0x22: { - if (FcbRandomWrite(FP_DS_DX, &CritErrCode)) + if (FcbRandomIO(FP_DS_DX, &CritErrCode, FcbWrite)) r->AL = 0; else r->AL = CritErrCode; @@ -851,8 +863,7 @@ VOID int21_service(iregs FAR * r) struct dpb FAR *dpb = CDSp->cds_table[r->DL].cdsDpb; if (dpb == 0 || (CDSp->cds_table[r->DL].cdsFlags & CDSNETWDRV) || - FP_SEG(dpb) != FP_SEG(&dpb) || /* check if it's a NEAR pointer */ - media_check((struct dpb *)dpb) < 0) + media_check(dpb) < 0) { r->AL = 0xff; CritErrCode = 0x0f; @@ -869,6 +880,10 @@ VOID int21_service(iregs FAR * r) } break; +/* + case 0x33: + see int21_syscall +*/ /* Get InDOS flag */ case 0x34: { @@ -894,7 +909,7 @@ VOID int21_service(iregs FAR * r) /* Dos Get Disk Free Space */ case 0x36: DosGetFree( - (COUNT) r->DL, + r->DL, (COUNT FAR *) & r->AX, (COUNT FAR *) & r->BX, (COUNT FAR *) & r->CX, @@ -942,7 +957,6 @@ VOID int21_service(iregs FAR * r) goto error_invalid; r->AX = r->BX = cntry; } - CLEAR_CARRY_FLAG(); } break; @@ -951,10 +965,6 @@ VOID int21_service(iregs FAR * r) rc = DosMkdir((BYTE FAR *) FP_DS_DX); if (rc != SUCCESS) goto error_exit; - else - { - CLEAR_CARRY_FLAG(); - } break; /* Dos Remove Directory */ @@ -962,20 +972,12 @@ VOID int21_service(iregs FAR * r) rc = DosRmdir((BYTE FAR *) FP_DS_DX); if (rc != SUCCESS) goto error_exit; - else - { - CLEAR_CARRY_FLAG(); - } break; /* Dos Change Directory */ case 0x3b: if ((rc = DosChangeDir((BYTE FAR *) FP_DS_DX)) < 0) goto error_exit; - else - { - CLEAR_CARRY_FLAG(); - } break; /* Dos Create File */ @@ -983,10 +985,7 @@ VOID int21_service(iregs FAR * r) if ((rc = DosCreat(FP_DS_DX, r->CX)) < 0) goto error_exit; else - { r->AX = rc; - CLEAR_CARRY_FLAG(); - } break; /* Dos Open */ @@ -994,61 +993,38 @@ VOID int21_service(iregs FAR * r) if ((rc = DosOpen(FP_DS_DX, r->AL)) < 0) goto error_exit; else - { r->AX = rc; - CLEAR_CARRY_FLAG(); - } break; /* Dos Close */ case 0x3e: if ((rc = DosClose(r->BX)) < 0) goto error_exit; - else - CLEAR_CARRY_FLAG(); break; /* Dos Read */ case 0x3f: - rc = DosRead(r->BX, r->CX, FP_DS_DX, (COUNT FAR *) & rc1); - - if (rc1 != SUCCESS) - { - r->AX = -rc1; - goto error_out; - } + rc1 = DosRead(r->BX, r->CX, FP_DS_DX, (COUNT FAR *) & rc); + if (rc != SUCCESS) + goto error_exit; else - { - CLEAR_CARRY_FLAG(); - r->AX = rc; - } + r->AX = rc1; break; /* Dos Write */ case 0x40: - rc = DosWrite(r->BX, r->CX, FP_DS_DX, (COUNT FAR *) & rc1); - if (rc1 != SUCCESS) - { - r->AX = -rc1; - goto error_out; - } + rc1 = DosWrite(r->BX, r->CX, FP_DS_DX, (COUNT FAR *) & rc); + if (rc != SUCCESS) + goto error_exit; else - { - CLEAR_CARRY_FLAG(); - r->AX = rc; - } + r->AX = rc1; break; /* Dos Delete File */ case 0x41: rc = DosDelete((BYTE FAR *) FP_DS_DX); if (rc < 0) - { - r->AX = -rc; - goto error_out; - } - else - CLEAR_CARRY_FLAG(); + goto error_exit; break; /* Dos Seek */ @@ -1059,7 +1035,6 @@ VOID int21_service(iregs FAR * r) { r->DX = (lrc >> 16); r->AX = (UWORD)lrc; - CLEAR_CARRY_FLAG(); } break; @@ -1069,41 +1044,25 @@ VOID int21_service(iregs FAR * r) { case 0x00: rc = DosGetFattr((BYTE FAR *) FP_DS_DX, (UWORD FAR *) & r->CX); - if (rc != SUCCESS) - goto error_exit; - else - { - CLEAR_CARRY_FLAG(); - } break; case 0x01: rc = DosSetFattr((BYTE FAR *) FP_DS_DX, (UWORD FAR *) & r->CX); - if (rc != SUCCESS) - goto error_exit; - else - CLEAR_CARRY_FLAG(); break; default: goto error_invalid; } + if (rc != SUCCESS) + goto error_exit; break; /* Device I/O Control */ case 0x44: - { - rc = DosDevIOctl(r, (COUNT FAR *) & rc1); + rc = DosDevIOctl(r); - if (rc1 != SUCCESS) - { - r->AX = -rc1; - goto error_out; - } - else{ - CLEAR_CARRY_FLAG(); - } - } + if (rc != SUCCESS) + goto error_exit; break; /* Duplicate File Handle */ @@ -1112,10 +1071,7 @@ VOID int21_service(iregs FAR * r) if (rc < SUCCESS) goto error_exit; else - { - CLEAR_CARRY_FLAG(); r->AX = rc; - } break; /* Force Duplicate File Handle */ @@ -1123,8 +1079,6 @@ VOID int21_service(iregs FAR * r) rc = DosForceDup(r->BX, r->CX); if (rc < SUCCESS) goto error_exit; - else - CLEAR_CARRY_FLAG(); break; /* Get Current Directory */ @@ -1132,10 +1086,7 @@ VOID int21_service(iregs FAR * r) if ((rc = DosGetCuDir(r->DL, MK_FP(r->DS, r->SI))) < 0) goto error_exit; else - { - CLEAR_CARRY_FLAG(); r->AX = 0x0100; /*jpp: from interrupt list */ - } break; /* Allocate memory */ @@ -1146,18 +1097,13 @@ VOID int21_service(iregs FAR * r) goto error_exit; } else - { ++(r->AX); /* DosMemAlloc() returns seg of MCB rather than data */ - CLEAR_CARRY_FLAG(); - } break; /* Free memory */ case 0x49: if ((rc = DosMemFree((r->ES) - 1)) < 0) goto error_exit; - else - CLEAR_CARRY_FLAG(); break; /* Set memory block size */ @@ -1182,8 +1128,6 @@ VOID int21_service(iregs FAR * r) #endif goto error_exit; } - else - CLEAR_CARRY_FLAG(); break; } @@ -1195,8 +1139,6 @@ VOID int21_service(iregs FAR * r) if ((rc = DosExec(r->AL, MK_FP(r->ES, r->BX), FP_DS_DX)) != SUCCESS) goto error_exit; - else - CLEAR_CARRY_FLAG(); break; /* Terminate Program */ @@ -1242,40 +1184,31 @@ VOID int21_service(iregs FAR * r) /* Dos Find First */ case 0x4e: - { - /* dta for this call is set on entry. This */ - /* needs to be changed for new versions. */ - if ((rc = DosFindFirst((UCOUNT) r->CX, (BYTE FAR *) FP_DS_DX)) < 0) - goto error_exit; - else - { - r->AX = 0; - CLEAR_CARRY_FLAG(); - } - } + /* dta for this call is set on entry. This */ + /* needs to be changed for new versions. */ + if ((rc = DosFindFirst((UCOUNT) r->CX, (BYTE FAR *) FP_DS_DX)) < 0) + goto error_exit; + r->AX = 0; break; /* Dos Find Next */ case 0x4f: + /* dta for this call is set on entry. This */ + /* needs to be changed for new versions. */ + if ((rc = DosFindNext()) < 0) { - /* dta for this call is set on entry. This */ - /* needs to be changed for new versions. */ - if ((rc = DosFindNext()) < 0) - { - r->AX = -rc; - - if (r->AX == 2) - r->AX = 18; - goto error_out; - } - else - { - CLEAR_CARRY_FLAG(); - r->AX = -SUCCESS; - } + if (rc == DE_FILENOTFND) + rc = DE_NFILES; + goto error_exit; } + else + r->AX = -SUCCESS; break; - +/* + case 0x50: + case 0x51: + see int21_syscall +*/ /* ************UNDOCUMENTED************************************* */ /* Get List of Lists */ case 0x52: @@ -1288,6 +1221,11 @@ VOID int21_service(iregs FAR * r) } break; + case 0x53: + /* DOS 2+ internal - TRANSLATE BIOS PARAMETER BLOCK TO DRIVE PARAM BLOCK */ + bpb_to_dpb((bpb FAR *)MK_FP(r->DS, r->SI), (struct dpb FAR *)MK_FP(r->ES, r->BP)); + break; + /* Get verify state */ case 0x54: r->AL = (verify_ena ? TRUE : FALSE); @@ -1306,13 +1244,12 @@ VOID int21_service(iregs FAR * r) if (rc < SUCCESS) goto error_exit; else - { CLEAR_CARRY_FLAG(); - } break; /* Get/Set File Date and Time */ case 0x57: + CLEAR_CARRY_FLAG(); switch (r->AL) { case 0x00: @@ -1322,8 +1259,6 @@ VOID int21_service(iregs FAR * r) (time FAR *) & r->CX); /* FileTime */ if (rc < SUCCESS) goto error_exit; - else - CLEAR_CARRY_FLAG(); break; case 0x01: @@ -1333,8 +1268,6 @@ VOID int21_service(iregs FAR * r) (time FAR *) & r->CX); /* FileTime */ if (rc < SUCCESS) goto error_exit; - else - CLEAR_CARRY_FLAG(); break; default: @@ -1344,6 +1277,7 @@ VOID int21_service(iregs FAR * r) /* Get/Set Allocation Strategy */ case 0x58: + CLEAR_CARRY_FLAG(); switch (r->AL) { case 0x00: @@ -1358,7 +1292,6 @@ VOID int21_service(iregs FAR * r) case LAST_FIT: case LAST_FIT_U: case LAST_FIT_UO: - case LARGEST: case BEST_FIT: case BEST_FIT_U: case BEST_FIT_UO: @@ -1372,7 +1305,6 @@ VOID int21_service(iregs FAR * r) goto error_invalid; } } - CLEAR_CARRY_FLAG(); break; case 0x02: @@ -1419,7 +1351,7 @@ VOID int21_service(iregs FAR * r) /* Create New File */ case 0x5b: - if ((rc = DosOpen(FP_DS_DX, 0)) >= 0) + if (!IsDevice(FP_DS_DX) && (rc = DosOpen(FP_DS_DX, 0)) >= 0) { DosClose(rc); r->AX = 80; @@ -1445,10 +1377,8 @@ VOID int21_service(iregs FAR * r) (((unsigned long)r->CX)<<16)|(((unsigned long)r->DX)&0xffffL), (((unsigned long)r->SI)<<16)|(((unsigned long)r->DI)&0xffffL), ((r->AX & 0xff) != 0))) != 0) - r->FLAGS |= FLG_CARRY; - else - CLEAR_CARRY_FLAG(); - r->AX = -rc; + goto error_exit; + CLEAR_CARRY_FLAG(); break; /* /// End of additions for SHARE. - Ron Cemer */ @@ -1482,17 +1412,11 @@ VOID int21_service(iregs FAR * r) case 0x07: case 0x08: case 0x09: - { - COUNT result; - result = int2f_Remote_call(REM_PRINTREDIR, 0, 0, r->DX, 0, 0, (MK_FP(0, Int21AX))); - r->AX = result; - if (result != SUCCESS) { - goto error_out; - } else { - CLEAR_CARRY_FLAG(); - } + rc = -int2f_Remote_call(REM_PRINTREDIR, 0, 0, r->DX, 0, 0, (MK_FP(0, Int21AX))); + if (rc != SUCCESS) + goto error_exit; + CLEAR_CARRY_FLAG(); break; - } default: goto error_invalid; } @@ -1511,54 +1435,44 @@ VOID int21_service(iregs FAR * r) break; default: - { - COUNT result; - result = int2f_Remote_call(REM_PRINTSET, r->BX, r->CX, r->DX, (MK_FP(r->ES, r->DI)), r->SI, (MK_FP(r->DS, Int21AX))); - r->AX = result; - if (result != SUCCESS) goto error_out; - break; - } + rc = -int2f_Remote_call(REM_PRINTSET, r->BX, r->CX, r->DX, (MK_FP(r->ES, r->DI)), r->SI, (MK_FP(r->DS, Int21AX))); + if (rc != SUCCESS) goto error_exit; + r->AX=SUCCESS; + break; } break; case 0x5f: + CLEAR_CARRY_FLAG(); switch (r->AL) { case 0x07: if (r->DL < lastdrive) { - CDSp->cds_table[r->DL].cdsFlags |= 0x100; + CDSp->cds_table[r->DL].cdsFlags |= 0x100; } break; case 0x08: if (r->DL < lastdrive) { - CDSp->cds_table[r->DL].cdsFlags &= ~0x100; + CDSp->cds_table[r->DL].cdsFlags &= ~0x100; } break; default: - { - COUNT result; - result = int2f_Remote_call(REM_DOREDIRECT, r->BX, r->CX, r->DX, (MK_FP(r->ES, r->DI)), r->SI, (MK_FP(r->DS, Int21AX))); - r->AX = result; - if (result != SUCCESS) { - goto error_out; - } else { - CLEAR_CARRY_FLAG(); - } + rc = -int2f_Remote_call(REM_DOREDIRECT, r->BX, r->CX, r->DX, + (MK_FP(r->ES, r->DI)), r->SI, (MK_FP(r->DS, Int21AX))); + if (rc != SUCCESS) + goto error_exit; + r->AX=SUCCESS; break; - } } break; case 0x60: /* TRUENAME */ + CLEAR_CARRY_FLAG(); if ((rc = truename(MK_FP(r->DS, r->SI), adjust_far(MK_FP(r->ES, r->DI)), TRUE)) != SUCCESS) goto error_exit; - else - { - CLEAR_CARRY_FLAG(); - } break; #ifdef TSC @@ -1582,11 +1496,12 @@ VOID int21_service(iregs FAR * r) break; #endif - /* UNDOCUMENTED: return current psp */ - case 0x62: + /* UNDOCUMENTED: return current psp + case 0x62: is in int21_syscall r->BX = cu_psp; break; - + */ + /* UNDOCUMENTED: Double byte and korean tables */ case 0x63: { @@ -1606,6 +1521,10 @@ VOID int21_service(iregs FAR * r) #endif break; } +/* + case 0x64: + see above (invalid) +*/ /* Extended country info */ case 0x65: @@ -1648,6 +1567,7 @@ VOID int21_service(iregs FAR * r) } CLEAR_CARRY_FLAG(); break; + /* Code Page functions */ case 0x66: { @@ -1675,13 +1595,12 @@ VOID int21_service(iregs FAR * r) if ((rc = SetJFTSize(r->BX)) != SUCCESS) goto error_exit; else - { CLEAR_CARRY_FLAG(); - } break; - /* Flush file buffer -- dummy function right now. */ + /* Flush file buffer -- COMMIT FILE -- dummy function right now. */ case 0x68: + case 0x6a: CLEAR_CARRY_FLAG(); break; @@ -1698,31 +1617,28 @@ VOID int21_service(iregs FAR * r) case 0x00: r->AL = 0x0d; r->CX = 0x0866; - rc = DosDevIOctl(r, (COUNT FAR *) & rc1); + rc = DosDevIOctl(r); break; case 0x01: r->AL = 0x0d; r->CX = 0x0846; - rc = DosDevIOctl(r, (COUNT FAR *) & rc1); + rc = DosDevIOctl(r); break; } r->CX = saveCX; - if (rc1 != SUCCESS) - { - r->AX = -rc1; - goto error_out; - } - else - { - CLEAR_CARRY_FLAG(); - } + if (rc != SUCCESS) + goto error_exit; + CLEAR_CARRY_FLAG(); break; } else r->AL = 0xFF; break; - +/* + case 0x6a: see case 0x68 + case 0x6b: dummy func: return AL=0 +*/ #if 0 /* Extended Open-Creat, not fully functional.*/ case 0x6c: @@ -1812,6 +1728,9 @@ VOID int21_service(iregs FAR * r) default: goto error_invalid; } + + /* case 0x6d and above not implemented : see default; return AL=0 */ + #endif } diff --git a/kernel/intr.asm b/kernel/intr.asm index 3151904a..649bd739 100644 --- a/kernel/intr.asm +++ b/kernel/intr.asm @@ -96,8 +96,8 @@ _int3: retf - segment INIT_TEXT +%if 0 ; ; void init_call_intr(nr, rp) ; REG int nr @@ -159,7 +159,7 @@ init_intr?1: ret - +%endif ; ; int init_call_XMScall( (WORD FAR * driverAddress)(), WORD AX, WORD DX) ; @@ -177,4 +177,83 @@ _init_call_XMScall: pop bp ret +; void FAR *DetectXMSDriver(VOID) +global _DetectXMSDriver +_DetectXMSDriver: + mov ax, 4300h + int 2fh ; XMS installation check + + cmp al, 80h + je detected + xor ax, ax + xor dx, dx + ret + +detected: + push es + push bx + mov ax, 4310h ; XMS get driver address + int 2fh + + mov ax, bx + mov dx, es + pop bx + pop es + ret + +global _keycheck +_keycheck: + mov ah, 1 + int 16h + ret + +;; COUNT init_DosOpen(BYTE *fname, COUNT mode) + global _init_DosOpen +_init_DosOpen: + ;; first implementation of init calling DOS through ints: + mov bx, sp + mov ah, 3dh + ;; we know that SS=DS during init stage. + mov al, [bx+4] + mov dx, [bx+2] + int 21h +common_exit: + jnc open_no_error + ;; AX has file handle + neg ax + ;; negative value for error code +open_no_error: + ret + +;; COUNT init_DosClose(COUNT hndl) + global _init_DosClose +_init_DosClose: + mov bx, sp + mov bx, [bx+2] + mov ah, 3eh + int 21h + jmp common_exit + +;; COUNT init_DosRead(COUNT hndl, BYTE *bp, UCOUNT n) + global _init_DosRead +_init_DosRead: + mov bx, sp + mov cx, [bx+6] + mov dx, [bx+4] + mov bx, [bx+2] + mov ah, 3fh + int 21h + jmp common_exit + +;; VOID init_PSPInit(seg psp_seg) + global _init_PSPInit +_init_PSPInit: + push si + mov ah, 55h + mov bx, sp + mov dx, [bx+4] + xor si, si + int 21h + pop si + ret \ No newline at end of file diff --git a/kernel/ioctl.c b/kernel/ioctl.c index 04519d67..867bf951 100644 --- a/kernel/ioctl.c +++ b/kernel/ioctl.c @@ -35,6 +35,9 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.8 2001/04/15 03:21:50 bartoldeman + * See history.txt for the list of fixes. + * * Revision 1.7 2001/03/30 22:27:42 bartoldeman * Saner lastdrive handling. * @@ -117,7 +120,7 @@ sft FAR *get_sft(); * WARNING: this code is non-portable (8086 specific). */ -COUNT DosDevIOctl(iregs FAR * r, COUNT FAR * err) +COUNT DosDevIOctl(iregs FAR * r) { sft FAR *s; struct dpb FAR *dpbp; @@ -139,10 +142,7 @@ COUNT DosDevIOctl(iregs FAR * r, COUNT FAR * err) /* Get the SFT block that contains the SFT */ if ((s = get_sft(r->BX)) == (sft FAR *) - 1) - { - *err = DE_INVLDHNDL; - return 0; - } + return DE_INVLDHNDL; break; case 0x04: @@ -168,10 +168,7 @@ COUNT DosDevIOctl(iregs FAR * r, COUNT FAR * err) dev = ( r->BL == 0 ? default_drive : r->BL - 1); if (dev >= lastdrive) - { - *err = DE_INVLDDRV; - return 0; - } + return DE_INVLDDRV; else { cdsp = &CDSp->cds_table[dev]; @@ -188,8 +185,7 @@ COUNT DosDevIOctl(iregs FAR * r, COUNT FAR * err) break; default: - *err = DE_INVLDFUNC; - return 0; + return DE_INVLDFUNC; } switch (r->AL) @@ -206,10 +202,7 @@ COUNT DosDevIOctl(iregs FAR * r, COUNT FAR * err) /* sft_flags is a file, return an error because you */ /* can't set the status of a file. */ if (!(s->sft_flags & SFT_FDEVICE)) - { - *err = DE_INVLDFUNC; - return 0; - } + return DE_INVLDFUNC; /* Set it to what we got in the DL register from the */ /* user. */ @@ -243,10 +236,8 @@ COUNT DosDevIOctl(iregs FAR * r, COUNT FAR * err) execrh((request FAR *) & CharReqHdr, s->sft_dev); if (CharReqHdr.r_status & S_ERROR) - { - *err = DE_DEVICE; - return 0; - } + return DE_DEVICE; + if (r->AL == 0x07) { r->AL = CharReqHdr.r_status & S_BUSY ? 00 : 0xff; @@ -263,8 +254,7 @@ COUNT DosDevIOctl(iregs FAR * r, COUNT FAR * err) } break; } - *err = DE_INVLDFUNC; - return 0; + return DE_INVLDFUNC; case 0x0d: nMode = C_GENIOCTL; @@ -280,16 +270,14 @@ COUNT DosDevIOctl(iregs FAR * r, COUNT FAR * err) IoBlockCommon: if(!dpbp) { - *err = DE_INVLDDRV; - return 0; + return DE_INVLDDRV; } if ( ((r->AL == 0x04 ) && !(dpbp->dpb_device->dh_attr & ATTR_IOCTL)) || ((r->AL == 0x05 ) && !(dpbp->dpb_device->dh_attr & ATTR_IOCTL)) || ((r->AL == 0x11) && !(dpbp->dpb_device->dh_attr & ATTR_QRYIOCTL)) || ((r->AL == 0x0d) && !(dpbp->dpb_device->dh_attr & ATTR_GENIOCTL))) { - *err = DE_INVLDFUNC; - return 0; + return DE_INVLDFUNC; } @@ -304,8 +292,7 @@ COUNT DosDevIOctl(iregs FAR * r, COUNT FAR * err) if (CharReqHdr.r_status & S_ERROR) { - *err = DE_DEVICE; - return 0; + return DE_DEVICE; } if (r->AL == 0x08) { @@ -345,16 +332,14 @@ COUNT DosDevIOctl(iregs FAR * r, COUNT FAR * err) case 0x08: if(!dpbp) { - *err = DE_INVLDDRV; - return 0; + return DE_INVLDDRV; } if (dpbp->dpb_device->dh_attr & ATTR_EXCALLS) { nMode = C_REMMEDIA; goto IoBlockCommon; } - *err = DE_INVLDFUNC; - return 0; + return DE_INVLDFUNC; case 0x09: if(cdsp->cdsFlags & CDSNETWDRV) @@ -366,8 +351,7 @@ COUNT DosDevIOctl(iregs FAR * r, COUNT FAR * err) { if(!dpbp) { - *err = DE_INVLDDRV; - return 0; + return DE_INVLDDRV; } /* Need to add subst bit 15 */ r->DX = dpbp->dpb_device->dh_attr; @@ -388,8 +372,7 @@ COUNT DosDevIOctl(iregs FAR * r, COUNT FAR * err) IoLogCommon: if(!dpbp) { - *err = DE_INVLDDRV; - return 0; + return DE_INVLDDRV; } if ((dpbp->dpb_device->dh_attr & ATTR_GENIOCTL)) { @@ -405,22 +388,18 @@ COUNT DosDevIOctl(iregs FAR * r, COUNT FAR * err) dpbp->dpb_device); if (CharReqHdr.r_status & S_ERROR) - *err = DE_ACCESS; + return DE_ACCESS; else { r->AL = CharReqHdr.r_unit; - *err = SUCCESS; + return SUCCESS; } - return 0; } - *err = DE_INVLDFUNC; - return 0; + return DE_INVLDFUNC; default: - *err = DE_INVLDFUNC; - return 0; + return DE_INVLDFUNC; } - *err = SUCCESS; - return 0; + return SUCCESS; } diff --git a/kernel/kernel.asm b/kernel/kernel.asm index 9b8db850..4736eac2 100644 --- a/kernel/kernel.asm +++ b/kernel/kernel.asm @@ -28,6 +28,9 @@ ; $Id$ ; ; $Log$ +; Revision 1.9 2001/04/15 03:21:50 bartoldeman +; See history.txt for the list of fixes. +; ; Revision 1.8 2001/03/30 19:30:06 bartoldeman ; Misc fixes and implementation of SHELLHIGH. See history.txt for details. ; @@ -131,6 +134,8 @@ STACK_SIZE equ 384/2 ; stack allocated in words ..start: entry: jmp far kernel_start +beyond_entry: resb 256-(beyond_entry-entry) + ; scratch area for data (DOS_PSP) segment INIT_TEXT @@ -143,7 +148,7 @@ kernel_start: mov ax,DGROUP cli mov ss,ax - mov sp,tos + mov sp,init_tos int 12h ; move the init code to higher memory mov cl,6 shl ax,cl @@ -321,10 +326,13 @@ _uppermem_root dw 0 ; 0066 dmd_upper_root _umb_start dw 0 ; 0068 para of last mem search SysVarEnd: +; We've got (01fb-006a) some room here: don't use all zeros! + + ; Some references seem to indicate that this data should start at 01fbh in ; order to maintain 100% MS-DOS compatibility. - times (01fbh - (SysVarEnd - DATASTART)) db 0 + times (01fbh - ($ - DATASTART)) db 0 global MARK01FBH MARK01FBH equ $ @@ -600,23 +608,34 @@ __bssend: segment _BSSEND ; blockdev private stack global blk_stk_top - times 256 dw 0 + times 192 dw 0 blk_stk_top: ; clockdev private stack global clk_stk_top - times 256 dw 0 + times 64 dw 0 clk_stk_top: +; this is nowhere needed ; interrupt stack - global intr_stk_top - times 256 dw 0 -intr_stk_top: +; global intr_stk_top +; times 256 dw 0 +;intr_stk_top: +segment ID ; init data + retaddr dd 0 ; return address to jump to from HMA_TEXT ; kernel startup stack - global tos - times 128 dw 0 -tos: + global init_tos + times 256 dw 0 +init_tos: + +segment ID_B + global __INIT_DATA_START +__INIT_DATA_START: +segment ID_E + global __INIT_DATA_END +__INIT_DATA_END: + segment INIT_TEXT_START global __InitTextStart @@ -639,6 +658,8 @@ __HMATextStart: segment HMA_TEXT times 16 db 0 ; filler [ffff:0..ffff:10] times 22 db 0 ; filler [sizeof VDISK info] + +init_ret: jmp far [retaddr] ; return from init_calls. ;End of HMA segment segment HMA_TEXT_END @@ -674,127 +695,124 @@ _DGROUP_: dw DGROUP -segment _TEXT +segment INIT_TEXT - global __HMARelocationTableStart -__HMARelocationTableStart: + call far initforceEnableA20 ; first enable A20 or not +manip_stack_A20: + pop word [retaddr+2] ; get last ret address + pop word [retaddr] ; get near ret address of init caller + mov ax, init_ret ; new init caller ret address + push ax + push word [retaddr+2] ; and back to the relocation entry + mov [retaddr+2], cs ; retaddr is now a far pointer to where we came from + ret + + global __HMAinitRelocationTableStart +__HMAinitRelocationTableStart: - extern _init_call_DosExec + extern _DosExec global _reloc_call_DosExec -_reloc_call_DosExec: jmp far _init_call_DosExec - call near forceEnableA20 +_reloc_call_DosExec: + call manip_stack_A20 + jmp far _DosExec - extern _init_call_DosMemAlloc + extern _DosMemAlloc global _reloc_call_DosMemAlloc -_reloc_call_DosMemAlloc: jmp far _init_call_DosMemAlloc - call near forceEnableA20 - - extern _init_call_dos_close - global _reloc_call_dos_close -_reloc_call_dos_close: jmp far _init_call_dos_close - call near forceEnableA20 +_reloc_call_DosMemAlloc: + call manip_stack_A20 + jmp far _DosMemAlloc - extern _init_call_dos_getdate - global _reloc_call_dos_getdate -_reloc_call_dos_getdate: jmp far _init_call_dos_getdate - call near forceEnableA20 - - extern _init_call_dos_gettime - global _reloc_call_dos_gettime -_reloc_call_dos_gettime: jmp far _init_call_dos_gettime - call near forceEnableA20 - - extern _init_call_dos_open - global _reloc_call_dos_open -_reloc_call_dos_open: jmp far _init_call_dos_open - call near forceEnableA20 - - extern _init_call_dos_read - global _reloc_call_dos_read -_reloc_call_dos_read: jmp far _init_call_dos_read - call near forceEnableA20 - - extern _init_call_execrh + extern _execrh global _reloc_call_execrh -_reloc_call_execrh: jmp far _init_call_execrh - call near forceEnableA20 +_reloc_call_execrh: + call manip_stack_A20 + jmp far _execrh - extern _init_call_fatal + extern _fatal global _reloc_call_fatal -_reloc_call_fatal: jmp far _init_call_fatal - call near forceEnableA20 +_reloc_call_fatal: + call manip_stack_A20 + jmp far _fatal - extern _init_call_fmemcpy + extern _fmemcpy global _reloc_call_fmemcpy -_reloc_call_fmemcpy: jmp far _init_call_fmemcpy - call near forceEnableA20 - +_reloc_call_fmemcpy: + call manip_stack_A20 + jmp far _fmemcpy - extern _init_call_memcpy + extern _memcpy global _reloc_call_memcpy -_reloc_call_memcpy: jmp far _init_call_memcpy - call near forceEnableA20 +_reloc_call_memcpy: + call manip_stack_A20 + jmp far _memcpy - extern _init_call_printf + extern _printf global _reloc_call_printf -_reloc_call_printf: jmp far _init_call_printf - call near forceEnableA20 +_reloc_call_printf: + call manip_stack_A20 + jmp far _printf - extern _init_call_strcpy + extern _strcpy global _reloc_call_strcpy -_reloc_call_strcpy: jmp far _init_call_strcpy - call near forceEnableA20 +_reloc_call_strcpy: + call manip_stack_A20 + jmp far _strcpy - extern _init_call_sti + extern _sti global _reloc_call_sti -_reloc_call_sti: jmp far _init_call_sti - call near forceEnableA20 +_reloc_call_sti: + call manip_stack_A20 + jmp far _sti - extern _init_call_strcmp + extern _strcmp global _reloc_call_strcmp -_reloc_call_strcmp: jmp far _init_call_strcmp - call near forceEnableA20 +_reloc_call_strcmp: + call manip_stack_A20 + jmp far _strcmp - extern _init_call_strlen + extern _strlen global _reloc_call_strlen -_reloc_call_strlen: jmp far _init_call_strlen - call near forceEnableA20 - +_reloc_call_strlen: + call manip_stack_A20 + jmp far _strlen - extern _init_call_WritePCClock + extern _WritePCClock global _reloc_call_WritePCClock -_reloc_call_WritePCClock: jmp far _init_call_WritePCClock - call near forceEnableA20 +_reloc_call_WritePCClock: + call manip_stack_A20 + jmp far _WritePCClock - extern _init_call_DaysFromYearMonthDay + extern _DaysFromYearMonthDay global _reloc_call_DaysFromYearMonthDay -_reloc_call_DaysFromYearMonthDay: jmp far _init_call_DaysFromYearMonthDay - call near forceEnableA20 - - global _CharMapSrvc - extern _reloc_call_CharMapSrvc -_CharMapSrvc: jmp far _reloc_call_CharMapSrvc - call near forceEnableA20 - - global _reloc_call_clk_driver - extern _init_call_clk_driver -_reloc_call_clk_driver: jmp far _init_call_clk_driver - call near forceEnableA20 +_reloc_call_DaysFromYearMonthDay: + call manip_stack_A20 + jmp far _DaysFromYearMonthDay + extern _fmemset + global _reloc_call_fmemset +_reloc_call_fmemset: + call manip_stack_A20 + jmp far _fmemset + extern _p_0 + global _reloc_call_p_0 +_reloc_call_p_0: + call manip_stack_A20 + jmp far _p_0 - global _reloc_call_fmemset - extern _init_call_fmemset -_reloc_call_fmemset: jmp far _init_call_fmemset - call near forceEnableA20 + global __HMAinitRelocationTableEnd +__HMAinitRelocationTableEnd: +segment _TEXT - global _reloc_call_blk_driver - extern _init_call_blk_driver -_reloc_call_blk_driver: jmp far _init_call_blk_driver - call near forceEnableA20 +global _initforceEnableA20 +initforceEnableA20: + call near forceEnableA20 + retf + global __HMARelocationTableStart +__HMARelocationTableStart: global _int2f_handler extern reloc_call_int2f_handler @@ -806,9 +824,6 @@ _int2f_handler: jmp far reloc_call_int2f_handler _int20_handler: jmp far reloc_call_int20_handler call near forceEnableA20 - - - global _int21_handler extern reloc_call_int21_handler _int21_handler: jmp far reloc_call_int21_handler @@ -837,17 +852,24 @@ _int0_handler: jmp far reloc_call_int0_handler global _cpm_entry extern reloc_call_cpm_entry -_cpm_entry: jmp far reloc_call_cpm_entry +_cpm_entry: jmp far reloc_call_cpm_entry + call near forceEnableA20 + + global _reloc_call_blk_driver + extern _blk_driver +_reloc_call_blk_driver: + jmp far _blk_driver call near forceEnableA20 -; global _init_call_init_buffers -; extern _reloc_call_init_buffers -;_init_call_init_buffers: jmp far _reloc_call_init_buffers -; call near forceEnableA20 + global _reloc_call_clk_driver + extern _clk_driver +_reloc_call_clk_driver: + jmp far _clk_driver + call near forceEnableA20 - global _init_call_p_0 - extern _reloc_call_p_0 -_init_call_p_0: jmp far _reloc_call_p_0 + global _CharMapSrvc + extern _reloc_call_CharMapSrvc +_CharMapSrvc: jmp far _reloc_call_CharMapSrvc call near forceEnableA20 @@ -1006,16 +1028,6 @@ _int24_handler: mov al,FAIL iret -segment HMA_TEXT - extern _init_call_printf:wrt TGROUP - global _printf - -_printf: - pop ax - push cs - push ax - jmp _init_call_printf - diff --git a/kernel/kernel.mak b/kernel/kernel.mak index 26808d10..f813bd20 100644 --- a/kernel/kernel.mak +++ b/kernel/kernel.mak @@ -5,6 +5,9 @@ # # $Log$ +# Revision 1.8 2001/04/15 03:21:50 bartoldeman +# See history.txt for the list of fixes. +# # Revision 1.7 2001/03/25 17:11:54 bartoldeman # Fixed sys.com compilation. Updated to 2023. Also: see history.txt. # @@ -131,10 +134,9 @@ LIBS =..\LIB\DEVICE.LIB ..\LIB\LIBM.LIB #ALLCFLAGS = -1- -O -Z -d -I..\hdr -I. \ # -D__STDC__=0;DEBUG;KERNEL;I86;PROTO;ASMSUPT ALLCFLAGS = -1- -O -Z -d -I..\hdr -I. \ - -D__STDC__=0;KERNEL;I86;PROTO;ASMSUPT \ - -g1 -INITCFLAGS = $(ALLCFLAGS) -zAINIT -zCINIT_TEXT -zPIGROUP -CFLAGS = $(ALLCFLAGS) -zAHMA -zCHMA_TEXT + -D__STDC__=0;I86;ASMSUPT -w -g1 +INITCFLAGS =$(ALLCFLAGS) -zAINIT -zCINIT_TEXT -zPIGROUP -zDIB -zRID -zTID +CFLAGS =$(ALLCFLAGS) -zAHMA -zCHMA_TEXT HDR=../hdr/ # *Implicit Rules* @@ -272,7 +274,7 @@ config.obj: config.c init-mod.h $(HDR)portab.h globals.h \ $(HDR)sft.h $(HDR)cds.h $(HDR)exe.h $(HDR)fnode.h \ $(HDR)dirmatch.h $(HDR)file.h $(HDR)clock.h $(HDR)kbd.h \ $(HDR)error.h $(HDR)version.h proto.h - $(CC) $(INITCFLAGS) -c config.c + $(CC) $(INITCFLAGS) -c config.c initoem.obj: initoem.c init-mod.h $(HDR)portab.h globals.h \ $(HDR)device.h $(HDR)mcb.h $(HDR)pcb.h $(HDR)date.h $(HDR)time.h \ @@ -288,7 +290,7 @@ main.obj: main.c init-mod.h $(HDR)portab.h globals.h $(HDR)device.h \ $(HDR)cds.h $(HDR)exe.h $(HDR)fnode.h $(HDR)dirmatch.h \ $(HDR)file.h $(HDR)clock.h $(HDR)kbd.h $(HDR)error.h \ $(HDR)version.h proto.h - $(CC) $(INITCFLAGS) -c main.c + $(CC) $(INITCFLAGS) -c main.c initHMA.obj: initHMA.c init-mod.h $(HDR)portab.h globals.h $(HDR)device.h \ $(HDR)mcb.h $(HDR)pcb.h $(HDR)date.h $(HDR)time.h $(HDR)fat.h \ @@ -296,7 +298,7 @@ initHMA.obj: initHMA.c init-mod.h $(HDR)portab.h globals.h $(HDR)device.h \ $(HDR)cds.h $(HDR)exe.h $(HDR)fnode.h $(HDR)dirmatch.h \ $(HDR)file.h $(HDR)clock.h $(HDR)kbd.h $(HDR)error.h \ $(HDR)version.h proto.h - $(CC) $(INITCFLAGS) -c initHMA.c + $(CC) $(INITCFLAGS) -c initHMA.c # XXX: I generated these using `gcc -MM' and `sed', so they may not be # completely correct... -- ror4 diff --git a/kernel/main.c b/kernel/main.c index 62cf0024..493dab43 100644 --- a/kernel/main.c +++ b/kernel/main.c @@ -29,7 +29,6 @@ #include "init-mod.h" -#define MAIN #include "portab.h" #include "globals.h" @@ -39,6 +38,9 @@ static BYTE *mainRcsId = "$Id$"; /* * $Log$ + * Revision 1.13 2001/04/15 03:21:50 bartoldeman + * See history.txt for the list of fixes. + * * Revision 1.12 2001/03/30 22:27:42 bartoldeman * Saner lastdrive handling. * @@ -169,14 +171,14 @@ extern BYTE FAR * lpBase; extern BYTE FAR * upBase; INIT BOOL ReadATClock(BYTE *, BYTE *, BYTE *, BYTE *); -VOID FAR init_call_WritePCClock(ULONG); -VOID FAR reloc_call_WritePCClock(ULONG); +VOID WritePCClock(ULONG); INIT VOID configDone(VOID); INIT static void InitIO(void); INIT static COUNT BcdToByte(COUNT); -INIT static COUNT BcdToDay(BYTE *); +/** INIT static COUNT BcdToDay(BYTE *);*/ +INIT static VOID update_dcb(struct dhdr FAR *); INIT static VOID init_kernel(VOID); INIT static VOID signon(VOID); INIT VOID kernel(VOID); @@ -226,26 +228,28 @@ INIT VOID main(void) at least one known utility (norton DE) seems to access them directly. ok, so we access for all drives, that the stuff gets build */ - -void InitializeAllBPBs() +/* + should not be necessary anymore (see DosSelectDrv in dosfns.c) +void InitializeAllBPBs(VOID) { static char filename[] = "A:-@JUNK@-.TMP"; int drive,fileno; for (drive = 'Z'; drive >= 'C'; drive--) { filename[0] = drive; - if ((fileno = dos_open((BYTE FAR *) filename, O_RDONLY)) >= 0) - dos_close(fileno); + if ((fileno = init_DosOpen(filename, O_RDONLY)) >= 0) + init_DosClose(fileno); } } - +*/ INIT void init_kernel(void) { COUNT i; + os_major = MAJOR_RELEASE; os_minor = MINOR_RELEASE; - cu_psp = DOS_PSP; + nblkdev = 0; maxbksize = 0x200; switchar = '/'; @@ -294,10 +298,13 @@ INIT void init_kernel(void) scr_pos = 0; break_ena = TRUE; + init_PSPInit(DOS_PSP); + /* Do first initialization of system variable buffers so that */ /* we can read config.sys later. */ lastdrive = Config.cfgLastdrive; PreConfig(); + init_device((struct dhdr FAR *)&blk_dev, NULL, NULL, ram_top); /* Now config the temporary file system */ FsConfig(); @@ -305,11 +312,12 @@ INIT void init_kernel(void) #ifndef KDB /* Now process CONFIG.SYS */ DoConfig(); - /* and do final buffer allocation. */ PostConfig(); + nblkdev = 0; + update_dcb(&blk_dev); - /* Init the file system on emore time */ + /* Init the file system one more time */ FsConfig(); /* and process CONFIG.SYS one last time to load device drivers. */ @@ -326,20 +334,12 @@ INIT void init_kernel(void) InDOS = 0; pDirFileNode = 0; dosidle_flag = 0; - - InitializeAllBPBs(); - } INIT VOID FsConfig(VOID) { REG COUNT i; - date Date; - time Time; - - /* Get the start-up date and time */ - Date = dos_getdate(); - Time = dos_gettime(); + struct dpb FAR *dpb; /* Initialize the file tables */ for (i = 0; i < Config.cfgFiles; i++) @@ -351,84 +351,36 @@ INIT VOID FsConfig(VOID) sfthead->sftt_count = Config.cfgFiles; for (i = 0; i < sfthead->sftt_count; i++) { + init_DosClose(i); sfthead->sftt_table[i].sft_count = 0; sfthead->sftt_table[i].sft_status = -1; } /* 0 is /dev/con (stdin) */ - sfthead->sftt_table[0].sft_count = 1; - sfthead->sftt_table[0].sft_mode = SFT_MREAD; - sfthead->sftt_table[0].sft_attrib = 0; - sfthead->sftt_table[0].sft_flags = - ((con_dev.dh_attr & ~SFT_MASK) & ~SFT_FSHARED) | SFT_FDEVICE | SFT_FEOF | SFT_FCONIN | SFT_FCONOUT; - sfthead->sftt_table[0].sft_psp = DOS_PSP; - sfthead->sftt_table[0].sft_date = Date; - sfthead->sftt_table[0].sft_time = Time; - fbcopy( - (VOID FAR *) "CON ", - (VOID FAR *) sfthead->sftt_table[0].sft_name, 11); - sfthead->sftt_table[0].sft_dev = (struct dhdr FAR *)&con_dev; + init_DosOpen("CON", SFT_MREAD); + sfthead->sftt_table[0].sft_flags |= SFT_FCONIN | SFT_FCONOUT; /* 1 is /dev/con (stdout) */ - sfthead->sftt_table[1].sft_count = 1; - sfthead->sftt_table[1].sft_mode = SFT_MWRITE; - sfthead->sftt_table[1].sft_attrib = 0; - sfthead->sftt_table[1].sft_flags = - ((con_dev.dh_attr & ~SFT_MASK) & ~SFT_FSHARED) | SFT_FDEVICE | SFT_FEOF | SFT_FCONIN | SFT_FCONOUT; - sfthead->sftt_table[1].sft_psp = DOS_PSP; - sfthead->sftt_table[1].sft_date = Date; - sfthead->sftt_table[1].sft_time = Time; - fbcopy( - (VOID FAR *) "CON ", - (VOID FAR *) sfthead->sftt_table[1].sft_name, 11); - sfthead->sftt_table[1].sft_dev = (struct dhdr FAR *)&con_dev; + init_DosOpen("CON", SFT_MWRITE); + sfthead->sftt_table[1].sft_flags |= SFT_FCONIN | SFT_FCONOUT; /* 2 is /dev/con (stderr) */ - sfthead->sftt_table[2].sft_count = 1; - sfthead->sftt_table[2].sft_mode = SFT_MWRITE; - sfthead->sftt_table[2].sft_attrib = 0; - sfthead->sftt_table[2].sft_flags = - ((con_dev.dh_attr & ~SFT_MASK) & ~SFT_FSHARED) | SFT_FDEVICE | SFT_FEOF | SFT_FCONIN | SFT_FCONOUT; - sfthead->sftt_table[2].sft_psp = DOS_PSP; - sfthead->sftt_table[2].sft_date = Date; - sfthead->sftt_table[2].sft_time = Time; - fbcopy( - (VOID FAR *) "CON ", - (VOID FAR *) sfthead->sftt_table[2].sft_name, 11); - sfthead->sftt_table[2].sft_dev = (struct dhdr FAR *)&con_dev; + init_DosOpen("CON", SFT_MWRITE); + sfthead->sftt_table[2].sft_flags |= SFT_FCONIN | SFT_FCONOUT; /* 3 is /dev/aux */ - sfthead->sftt_table[3].sft_count = 1; - sfthead->sftt_table[3].sft_mode = SFT_MRDWR; - sfthead->sftt_table[3].sft_attrib = 0; - sfthead->sftt_table[3].sft_flags = - ((aux_dev.dh_attr & ~SFT_MASK) & ~SFT_FSHARED) | SFT_FDEVICE; - sfthead->sftt_table[3].sft_psp = DOS_PSP; - sfthead->sftt_table[3].sft_date = Date; - sfthead->sftt_table[3].sft_time = Time; - fbcopy( - (VOID FAR *) "AUX ", - (VOID FAR *) sfthead->sftt_table[3].sft_name, 11); - sfthead->sftt_table[3].sft_dev = (struct dhdr FAR *)&aux_dev; + init_DosOpen("AUX", SFT_MRDWR); + sfthead->sftt_table[3].sft_flags &= ~SFT_FEOF; /* 4 is /dev/prn */ - sfthead->sftt_table[4].sft_count = 1; - sfthead->sftt_table[4].sft_mode = SFT_MWRITE; - sfthead->sftt_table[4].sft_attrib = 0; - sfthead->sftt_table[4].sft_flags = - ((prn_dev.dh_attr & ~SFT_MASK) & ~SFT_FSHARED) | SFT_FDEVICE; - sfthead->sftt_table[4].sft_psp = DOS_PSP; - sfthead->sftt_table[4].sft_date = Date; - sfthead->sftt_table[4].sft_time = Time; - fbcopy( - (VOID FAR *) "PRN ", - (VOID FAR *) sfthead->sftt_table[4].sft_name, 11); - sfthead->sftt_table[4].sft_dev = (struct dhdr FAR *)&prn_dev; + init_DosOpen("PRN", SFT_MWRITE); + sfthead->sftt_table[4].sft_flags &= ~SFT_FEOF; /* Log-in the default drive. */ /* Get the boot drive from the ipl and use it for default. */ default_drive = BootDrive - 1; + dpb = DPBp; - /* Initialzie the current directory structures */ + /* Initialize the current directory structures */ for (i = 0; i < lastdrive ; i++) { struct cds FAR *pcds_table = &CDSp->cds_table[i]; @@ -438,10 +390,11 @@ INIT VOID FsConfig(VOID) pcds_table->cdsCurrentPath[0] += i; - if (i < nblkdev) + if (i < nblkdev && (ULONG)dpb != 0xffffffffl) { - pcds_table->cdsDpb = &blk_devices[i]; + pcds_table->cdsDpb = dpb; pcds_table->cdsFlags = CDSPHYSDRV; + dpb = dpb->dpb_next; } else { @@ -453,7 +406,7 @@ INIT VOID FsConfig(VOID) pcds_table->cdsJoinOffset = 2; } - /* Initialze the disk buffer management functions */ + /* Initialize the disk buffer management functions */ /* init_call_init_buffers(); done from CONFIG.C */ } @@ -495,21 +448,55 @@ INIT void kernel() ep += sizeof(int); #endif RootPsp = ~0; - - init_call_p_0(); + p_0(); } +/* check for a block device and update device control block */ +static VOID update_dcb(struct dhdr FAR * dhp) +{ + REG COUNT Index; + COUNT nunits = dhp->dh_name[0]; + struct dpb FAR *dpb; + + if (nblkdev==0) + dpb = DPBp; + else { + for (dpb = DPBp; (ULONG)dpb->dpb_next != 0xffffffffl; dpb = dpb->dpb_next) + ; + dpb = dpb->dpb_next = (struct dpb FAR *)KernelAlloc(nunits*sizeof(struct dpb)); + } + + for(Index = 0; Index < nunits; Index++) + { + dpb->dpb_next = dpb+1; + dpb->dpb_unit = nblkdev; + dpb->dpb_subunit = Index; + dpb->dpb_device = dhp; + dpb->dpb_flags = M_CHANGED; + if ((CDSp != 0) && (nblkdev < lastdrive)) + { + CDSp->cds_table[nblkdev].cdsDpb = dpb; + CDSp->cds_table[nblkdev].cdsFlags = CDSPHYSDRV; + } + ++dpb; + ++nblkdev; + } + (dpb-1)->dpb_next = (void FAR *)0xFFFFFFFFl; +} + + /* If cmdLine is NULL, this is an internal driver */ BOOL init_device(struct dhdr FAR * dhp, BYTE FAR * cmdLine, COUNT mode, COUNT r_top) { request rq; - ULONG memtop = ((ULONG) r_top) << 10; - ULONG maxmem = memtop - ((ULONG) FP_SEG(dhp) << 4); + UCOUNT maxmem = ((UCOUNT)r_top << 6) - FP_SEG(dhp); - if (maxmem >= 0x10000) + if (maxmem >= 0x1000) maxmem = 0xFFFF; + else + maxmem <<= 4; rq.r_unit = 0; rq.r_status = 0; @@ -519,7 +506,6 @@ BOOL init_device(struct dhdr FAR * dhp, BYTE FAR * cmdLine, COUNT mode, COUNT r_ rq.r_bpbptr = (void FAR *)(cmdLine ? cmdLine : "\n"); rq.r_firstunit = nblkdev; - execrh((request FAR *) & rq, dhp); /* @@ -535,32 +521,11 @@ BOOL init_device(struct dhdr FAR * dhp, BYTE FAR * cmdLine, COUNT mode, COUNT r_ lpBase = rq.r_endaddr; } -/* check for a block device and update device control block */ - if (!(dhp->dh_attr & ATTR_CHAR) && (rq.r_nunits != 0)) - { - REG COUNT Index; - - for (Index = 0; Index < rq.r_nunits; Index++) - { - struct dpb *pblk_devices = &blk_devices[nblkdev]; - - if (nblkdev) - (pblk_devices-1)->dpb_next = pblk_devices; - - pblk_devices->dpb_next = (void FAR *)0xFFFFFFFF; - pblk_devices->dpb_unit = nblkdev; - pblk_devices->dpb_subunit = Index; - pblk_devices->dpb_device = dhp; - pblk_devices->dpb_flags = M_CHANGED; - if ((CDSp != 0) && (nblkdev < lastdrive)) - { - CDSp->cds_table[nblkdev].cdsDpb = pblk_devices; - CDSp->cds_table[nblkdev].cdsFlags = CDSPHYSDRV; - } - ++nblkdev; - } + if (!(dhp->dh_attr & ATTR_CHAR) && (rq.r_nunits != 0)) { + dhp->dh_name[0] = rq.r_nunits; + update_dcb(dhp); } - DPBp = &blk_devices[0]; + return FALSE; } @@ -579,7 +544,6 @@ INIT static void InitIO(void) setvec(0x29, int29_handler); /* Requires Fast Con Driver */ init_device((struct dhdr FAR *)&con_dev, NULL, NULL, ram_top); init_device((struct dhdr FAR *)&clk_dev, NULL, NULL, ram_top); - init_device((struct dhdr FAR *)&blk_dev, NULL, NULL, ram_top); /* If AT clock exists, copy AT clock time to system clock */ if (!ReadATClock(bcd_days, &bcd_hours, &bcd_minutes, &bcd_seconds)) { diff --git a/kernel/memmgr.c b/kernel/memmgr.c index 3e881fda..cd0bcb05 100644 --- a/kernel/memmgr.c +++ b/kernel/memmgr.c @@ -35,6 +35,9 @@ static BYTE *memmgrRcsId = "$Id$"; /* * $Log$ + * Revision 1.12 2001/04/15 03:21:50 bartoldeman + * See history.txt for the list of fixes. + * * Revision 1.11 2001/04/02 23:18:30 bartoldeman * Misc, zero terminated device names and redirector bugs fixed. * @@ -166,9 +169,12 @@ seg far2para(VOID FAR * p) return FP_SEG(p) + (FP_OFF(p) >> 4); } -seg long2para(LONG size) +seg long2para(ULONG size) { - return ((size + 0x0f) >> 4); + UWORD high = size>>16; + if ((UWORD)size > 0xfff0) + high++; + return (((UWORD)size + 0x0f) >> 4) + (high << 12); } /* @@ -176,11 +182,14 @@ seg long2para(LONG size) */ VOID FAR *add_far(VOID FAR * fp, ULONG off) { - if (FP_SEG(fp) == 0xffff) return ((BYTE FAR *)fp) + off; + UWORD off2; + + if (FP_SEG(fp) == 0xffff) return ((BYTE FAR *)fp) + FP_OFF(off); off += FP_OFF(fp); + off2 = ((off >> 16) << 12) + ((UWORD)off >> 4); - return MK_FP(FP_SEG(fp) + (UWORD) (off >> 4), (UWORD) off & 0xf); + return MK_FP(FP_SEG(fp) + off2, (UWORD) off & 0xf); } /* @@ -199,7 +208,7 @@ VOID FAR *adjust_far(VOID FAR * fp) #undef REG #define REG -#ifdef KERNEL +#if 1 /* #ifdef KERNEL KERNEL */ /* Allocate a new memory area. *para is assigned to the segment of the MCB rather then the segment of the data portion */ /* If mode == LARGEST, asize MUST be != NULL and will always recieve the @@ -234,7 +243,7 @@ COUNT DosMemAlloc(UWORD size, COUNT mode, seg FAR * para, UWORD FAR * asize) /* check for corruption */ if (!mcbValid(p)) return DE_MCBDESTRY; - + if (mcbFree(p)) { /* unused block, check if it applies to the rule */ if (joinMCBs(p) != SUCCESS) /* join following unused blocks */ @@ -347,11 +356,6 @@ COUNT DosMemAlloc(UWORD size, COUNT mode, seg FAR * para, UWORD FAR * asize) return SUCCESS; } -COUNT FAR init_call_DosMemAlloc(UWORD size, COUNT mode, seg FAR * para, UWORD FAR * asize) -{ - return DosMemAlloc(size, mode, para, asize); -} - /* * Unlike the name and the original prototype could suggest, this function * is used to return the _size_ of the largest available block rather than @@ -363,7 +367,6 @@ COUNT FAR init_call_DosMemAlloc(UWORD size, COUNT mode, seg FAR * para, UWORD FA COUNT DosMemLargest(UWORD FAR * size) { REG mcb FAR *p; - COUNT found; /* Initialize */ p = ((mem_access_mode & (FIRST_FIT_UO | FIRST_FIT_U)) && uppermem_link && uppermem_root) @@ -550,7 +553,7 @@ COUNT DosMemCheck(void) COUNT FreeProcessMem(UWORD ps) { - mcb FAR *p, FAR *u; + mcb FAR *p; COUNT x = 0; /* Initialize */ @@ -574,7 +577,7 @@ COUNT FreeProcessMem(UWORD ps) return DE_MCBDESTRY; } -#if 0 +#if 0 /* seems to be superceeded by DosMemLargest -- 1999/04/21 ska */ COUNT DosGetLargestBlock(UWORD FAR * block) @@ -621,14 +624,12 @@ VOID show_chain(void) p = nxtMCB(p); } } -#endif VOID mcb_print(mcb FAR * mcbp) { static BYTE buff[9]; - VOID _fmemcpy(); - _fmemcpy((BYTE FAR *) buff, (BYTE FAR *) (mcbp->m_name), 8); + fmemcpy((BYTE FAR *) buff, (BYTE FAR *) (mcbp->m_name), 8); buff[8] = '\0'; printf("%04x:%04x -> |%s| m_type = 0x%02x '%c'; m_psp = 0x%04x; m_size = 0x%04x\n", FP_SEG(mcbp), @@ -638,14 +639,8 @@ VOID mcb_print(mcb FAR * mcbp) mcbp->m_psp, mcbp->m_size); } -/* -VOID _fmemcpy(BYTE FAR * d, BYTE FAR * s, REG COUNT n) -{ - while (n--) - *d++ = *s++; +#endif -} -*/ VOID DosUmbLink(BYTE n) { REG mcb FAR *p; @@ -688,4 +683,58 @@ VOID DosUmbLink(BYTE n) DUL_exit: return; } + +/* + if we arrive here the first time, it's just + before jumping to COMMAND.COM + + so we are done initializing, and can claim the IMIT_DATA segment, + as these data/strings/buffers are no longer in use. + + we carve a free memory block out of it and hope that + it will be useful (maybe for storing environments) + +*/ + +BYTE INITDataSegmentClaimed = 1; /* must be enabled by CONFIG.SYS */ +extern BYTE _INIT_DATA_START[], _INIT_DATA_END[]; + +VOID ClaimINITDataSegment() +{ + unsigned ilow,ihigh; + VOID FAR * p; + + if (INITDataSegmentClaimed) + return; + INITDataSegmentClaimed = 1; + + + ilow = (unsigned)_INIT_DATA_START; + ilow = (ilow+0x0f) & ~0x000f; + ihigh = (unsigned)_INIT_DATA_END; + ihigh = ((ihigh + 0x0f) & ~0x000f) - 0x20; + + if (ilow +0x10 < ihigh) + { + printf("CLAIMING INIT_DATA memory - %u bytes\n",ihigh - ilow); + } + + + ((mcb*)ilow)->m_type = MCB_NORMAL; /* 'M' */ + ((mcb*)ilow)->m_psp = FREE_PSP; /* '0' */ + ((mcb*)ilow)->m_size = (ihigh-ilow-0x10)>>4; /* '0' */ + + ((mcb*)ihigh)->m_type = MCB_NORMAL; /* 'M' */ + ((mcb*)ihigh)->m_psp = 0x0008; /* system */ + + p = (void FAR*)(void*)ihigh; + + ((mcb*)ihigh)->m_size = first_mcb -1 - FP_SEG(p) - (FP_OFF(p) >> 4); + + p = (void FAR*)(void*)ilow; + + first_mcb = FP_SEG(p) + (FP_OFF(p) >> 4); + +} + #endif diff --git a/kernel/misc.c b/kernel/misc.c index 2593a3b9..fa26a114 100644 --- a/kernel/misc.c +++ b/kernel/misc.c @@ -34,6 +34,9 @@ static BYTE *miscRcsId = "$Id$"; /* * $Log$ + * Revision 1.5 2001/04/15 03:21:50 bartoldeman + * See history.txt for the list of fixes. + * * Revision 1.4 2001/03/21 02:56:26 bartoldeman * See history.txt for changes. Bug fixes and HMA support are the main ones. * @@ -98,11 +101,6 @@ VOID scopy(REG BYTE * s, REG BYTE * d) *d = '\0'; } -VOID FAR init_call_scopy(REG BYTE * s, REG BYTE * d) -{ - scopy(s, d); -} - VOID fscopy(REG BYTE FAR * s, REG BYTE FAR * d) { while (*s) @@ -117,7 +115,6 @@ VOID fsncopy(BYTE FAR * s, BYTE FAR * d, REG COUNT n) *d = '\0'; } -#ifndef ASMSUPT VOID bcopy(REG BYTE * s, REG BYTE * d, REG COUNT n) { while (n--) @@ -137,16 +134,3 @@ VOID fmemset(REG VOID FAR * s, REG int ch, REG COUNT n) } #endif - -VOID FAR init_call_fbcopy(REG VOID FAR * s, REG VOID FAR * d, REG COUNT n) -{ - fbcopy(s, d, n); -} - -VOID fmemset(VOID FAR *, int, COUNT); - -VOID FAR init_call_fmemset(REG VOID FAR * s, REG int ch, REG COUNT n) -{ - fmemset(s, ch, n); -} -#endif diff --git a/kernel/network.c b/kernel/network.c index 75db9daa..0c5f7631 100644 --- a/kernel/network.c +++ b/kernel/network.c @@ -36,6 +36,9 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.11 2001/04/15 03:21:50 bartoldeman + * See history.txt for the list of fixes. + * * Revision 1.10 2001/04/02 23:18:30 bartoldeman * Misc, zero terminated device names and redirector bugs fixed. * @@ -86,7 +89,7 @@ static BYTE *RcsId = "$Id$"; */ UWORD get_machine_name(BYTE FAR * netname) { - fmemcpy(netname, &net_name, 15); + fmemcpy(netname, &net_name, 16); return (NetBios); } @@ -124,8 +127,8 @@ UCOUNT Remote_RW(UWORD func, UCOUNT n, BYTE FAR * bp, sft FAR * s, COUNT FAR * e */ COUNT Remote_find(UWORD func, BYTE FAR * name, REG dmatch FAR * dmp ) { - COUNT i, x; - char FAR *p, FAR *q; + COUNT i; + char FAR *p; VOID FAR * test; struct dirent FAR *SDp = (struct dirent FAR *) &SearchDir; diff --git a/kernel/newstuff.c b/kernel/newstuff.c index 8bb0a927..497b697d 100644 --- a/kernel/newstuff.c +++ b/kernel/newstuff.c @@ -31,6 +31,9 @@ static BYTE *mainRcsId = "$Id$"; /* * $Log$ + * Revision 1.11 2001/04/15 03:21:50 bartoldeman + * See history.txt for the list of fixes. + * * Revision 1.10 2001/04/02 23:18:30 bartoldeman * Misc, zero terminated device names and redirector bugs fixed. * @@ -152,10 +155,10 @@ int SetJFTSize(UWORD nHandles) return SUCCESS; } +/* this is the same, is shorter (~170)and slightly easier to understand TE*/ int DosMkTmp(BYTE FAR * pathname, UWORD attr) { /* create filename from current date and time */ - static const char tokens[] = "0123456789ABCDEF"; char FAR *ptmp = pathname; BYTE wd, month, @@ -167,6 +170,8 @@ int DosMkTmp(BYTE FAR * pathname, UWORD attr) WORD sh; WORD year; int rc; + char name83[13]; + int loop; while (*ptmp) ptmp++; @@ -179,61 +184,46 @@ int DosMkTmp(BYTE FAR * pathname, UWORD attr) sh = s * 100 + hund; - ptmp[0] = tokens[year & 0xf]; - ptmp[1] = tokens[month]; - ptmp[2] = tokens[day & 0xf]; - ptmp[3] = tokens[h & 0xf]; - ptmp[4] = tokens[m & 0xf]; - ptmp[5] = tokens[(sh >> 8) & 0xf]; - ptmp[6] = tokens[(sh >> 4) & 0xf]; - ptmp[7] = tokens[sh & 0xf]; - ptmp[8] = '.'; - ptmp[9] = 'A'; - ptmp[10] = 'A'; - ptmp[11] = 'A'; - ptmp[12] = 0; - - while ((rc = DosOpen(pathname, 0)) >= 0) - { - DosClose(rc); + for ( loop = 0; loop < 0xfff; loop++) + { + sprintf(name83,"%x%x%x%x%x%03x.%03x", + + year & 0xf,month & 0xf, day & 0xf,h & 0xf,m & 0xf, sh&0xfff, + loop & 0xfff); + + fmemcpy(ptmp, name83, 13); + + if ((rc = DosOpen(pathname, 0)) < 0 && + rc != DE_ACCESS /* subdirectory ?? */ + /* todo: sharing collision on + network drive + */ + ) + break; - if (++ptmp[11] > 'Z') + if (rc >= 0) DosClose(rc); + } + + if (rc == DE_FILENOTFND) { - if (++ptmp[10] > 'Z') - { - if (++ptmp[9] > 'Z') - return DE_TOOMANY; - - ptmp[10] = 'A'; - } - ptmp[11] = 'A'; + rc = DosCreat(pathname, attr); } - } - - if (rc == DE_FILENOTFND) - { - rc = DosCreat(pathname, attr); - } - return rc; + return rc; } COUNT get_verify_drive(char FAR *src) { - COUNT drive; - /* First, adjust the source pointer */ - src = adjust_far(src); + UBYTE drive; /* Do we have a drive? */ if (src[1] == ':') - { - drive = (src[0] | 0x20) - 'a'; - } + drive = ((src[0]-1) | 0x20) - ('a'-1); else - drive = default_drive; - if ((drive < 0) || (drive >= lastdrive)) { - drive = DE_INVLDDRV; - } - return drive; + return default_drive; + if (drive < lastdrive && CDSp->cds_table[drive].cdsFlags & CDSVALID) + return drive; + else + return DE_INVLDDRV; } /* @@ -271,21 +261,19 @@ COUNT truename(char FAR * src, char FAR * dest, COUNT t) dest[0] = '\0'; + i = get_verify_drive(src); + if (i < 0) + return DE_INVLDDRV; + + buf[0] = i + 'A'; + buf[1] = ':'; /* Just to be sure */ + /* First, adjust the source pointer */ src = adjust_far(src); /* Do we have a drive? */ if (src[1] == ':') - { - buf[0] = (src[0] | 0x20) + 'A' - 'a'; - - if (buf[0] >= lastdrive + 'A') /* BUG:should be: drive exists */ - return DE_INVLDDRV; - src += 2; - } - else - buf[0] = default_drive + 'A'; /* /// Added to adjust for filenames which begin with ".\" The problem was manifesting itself in the inability @@ -297,7 +285,6 @@ COUNT truename(char FAR * src, char FAR * dest, COUNT t) /* /// Changed to "while" from "if". - Ron Cemer */ while ( (src[0] == '.') && (src[1] == '\\') ) src += 2; - i = buf[0] - 'A'; /* Code repoff from dosfns.c MSD returns X:/CON for truename con. Not X:\CON diff --git a/kernel/nls.c b/kernel/nls.c index 5e60ce4d..31a31775 100644 --- a/kernel/nls.c +++ b/kernel/nls.c @@ -44,6 +44,9 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.6 2001/04/15 03:21:50 bartoldeman + * See history.txt for the list of fixes. + * * Revision 1.5 2001/03/21 02:56:26 bartoldeman * See history.txt for changes. Bug fixes and HMA support are the main ones. * @@ -256,7 +259,7 @@ static COUNT cpyBuf(VOID FAR *dst, UWORD dstlen , VOID FAR *src, UWORD srclen) { if(srclen <= dstlen) { - _fmemcpy(dst, src, srclen); + fmemcpy(dst, src, srclen); return SUCCESS; } return DE_INVLDFUNC; /* buffer too small */ diff --git a/kernel/prf.c b/kernel/prf.c index 1c04d1ba..8be3991a 100644 --- a/kernel/prf.c +++ b/kernel/prf.c @@ -28,12 +28,18 @@ #include "portab.h" +COUNT strlen (BYTE * s); /* don't want globals.h, sorry */ + + #ifdef VERSION_STRINGS static BYTE *prfRcsId = "$Id$"; #endif /* * $Log$ + * Revision 1.7 2001/04/15 03:21:50 bartoldeman + * See history.txt for the list of fixes. + * * Revision 1.6 2001/03/30 19:30:06 bartoldeman * Misc fixes and implementation of SHELLHIGH. See history.txt for details. * @@ -44,6 +50,9 @@ static BYTE *prfRcsId = "$Id$"; * recoded for smaller object footprint, added main() for testing+QA * * $Log$ + * Revision 1.7 2001/04/15 03:21:50 bartoldeman + * See history.txt for the list of fixes. + * * Revision 1.6 2001/03/30 19:30:06 bartoldeman * Misc fixes and implementation of SHELLHIGH. See history.txt for details. * @@ -166,7 +175,7 @@ BYTE * p = q = s; do { /* generate digits in reverse order */ - *p++ = "0123456789abcdef"[u % base]; + *p++ = "0123456789abcdef"[(UWORD)(u % base)]; } while ((u /= base) > 0); @@ -185,11 +194,10 @@ BYTE * #define RIGHT 1 /* printf -- short version of printf to conserve space */ -WORD FAR - init_call_printf(CONST BYTE * fmt, BYTE * args) +WORD printf(CONST BYTE * fmt, ...) { charp = 0; - return do_printf(fmt, &args); + return do_printf(fmt, (BYTE **)&fmt + 1); } WORD @@ -216,8 +224,7 @@ COUNT { int base; BYTE s[11], - *p, - *ltob(); + *p; int c, flag, size, diff --git a/kernel/procsupt.asm b/kernel/procsupt.asm index e3cd1989..d5402b35 100644 --- a/kernel/procsupt.asm +++ b/kernel/procsupt.asm @@ -30,6 +30,9 @@ ; $Id$ ; ; $Log$ +; Revision 1.6 2001/04/15 03:21:50 bartoldeman +; See history.txt for the list of fixes. +; ; Revision 1.5 2001/03/24 22:13:05 bartoldeman ; See history.txt: dsk.c changes, warning removal and int21 entry handling. ; @@ -94,16 +97,14 @@ extern _api_ss:wrt DGROUP ; switching extern _usr_sp:wrt DGROUP ; user stacks extern _usr_ss:wrt DGROUP - - extern _kstackp:wrt TGROUP ; kernel stack - extern _ustackp:wrt TGROUP ; new task stack + extern _lpUserStack:wrt DGROUP extern _break_flg:wrt DGROUP ; break detected flag extern _int21_handler:wrt TGROUP ; far call system services %include "stacks.inc" -segment _TEXT +segment _TEXT extern _DGROUP_:wrt TGROUP @@ -149,6 +150,7 @@ _got_cbreak: pop ds iret +segment HMA_TEXT ; ; Special call for switching processes during break handling @@ -191,8 +193,23 @@ _spawn_int23: ; restore to user stack cli ;; Pre-8086 don't disable INT autom. - mov ss,[_usr_ss] - mov sp,[_usr_sp] +;*TE PATCH +; CtrlC at DosInput (like C:>DATE does) +; Nukes the Kernel. +; +; it looks like ENTRY.ASM+PROCSUPT.ASM +; got out of sync. +; +; spawn_int() assumes a stack layout at +; usr_ss:usr:sp. but usr:ss currently contains 0 +; +; this patch helps FreeDos to survive CtrlC, +; but should clearly be done somehow else. + mov ss, [_lpUserStack+2] + mov sp, [_lpUserStack] + +; mov ss,[_usr_ss] +; mov sp,[_usr_sp] sti ; get all the user registers back @@ -307,13 +324,8 @@ _spawn_int23: ??int23_respawn: pop bp ;; Restore the original register - jmp _int21_handler + jmp far _int21_handler - - global _init_call_spawn_int23 -_init_call_spawn_int23: - call _spawn_int23 - retf ; ; interrupt enable and disable routines ; diff --git a/kernel/proto.h b/kernel/proto.h index 590c5d75..8b5495aa 100644 --- a/kernel/proto.h +++ b/kernel/proto.h @@ -34,6 +34,9 @@ static BYTE *Proto_hRcsId = "$Id$"; /* * $Log$ + * Revision 1.13 2001/04/15 03:21:50 bartoldeman + * See history.txt for the list of fixes. + * * Revision 1.12 2001/03/30 19:30:06 bartoldeman * Misc fixes and implementation of SHELLHIGH. See history.txt for details. * @@ -162,18 +165,7 @@ static BYTE *Proto_hRcsId = "$Id$"; #define INIT -#ifdef IN_INIT_MOD -#define __FAR_WRAPPER(ret, name, proto) \ - ret FAR name proto; /* will be expanded to `init_call_' */ -#else -#define __FAR_WRAPPER(ret, name, proto) \ - ret name proto; \ - ret FAR init_call_##name proto; \ - ret FAR reloc_call_##name proto; -#endif - /* blockio.c */ -VOID FAR init_call_init_buffers(COUNT anzBuffers); ULONG getblkno(struct buffer FAR *); VOID setblkno(struct buffer FAR *, ULONG); struct buffer FAR *getblock(ULONG blkno, COUNT dsk); @@ -198,7 +190,7 @@ BOOL con_break(void); BOOL StdinBusy(void); VOID KbdFlush(void); VOID Do_DosIdle_loop(void); -__FAR_WRAPPER(VOID, sti, (keyboard FAR * kp)) +VOID sti(keyboard FAR * kp); sft FAR *get_sft(COUNT); @@ -214,6 +206,7 @@ INIT COUNT tolower(COUNT c); INIT COUNT toupper(COUNT c); INIT VOID mcb_init(mcb FAR * mcbp, UWORD size); INIT VOID strcat(REG BYTE * d, REG BYTE * s); +INIT BYTE FAR *KernelAlloc(WORD nBytes); /* dosfns.c */ BYTE FAR *get_root(BYTE FAR *); @@ -231,8 +224,8 @@ COUNT DosDup(COUNT Handle); COUNT DosForceDup(COUNT OldHandle, COUNT NewHandle); COUNT DosOpen(BYTE FAR * fname, COUNT mode); COUNT DosClose(COUNT hndl); -VOID DosGetFree(COUNT drive, COUNT FAR * spc, COUNT FAR * navc, COUNT FAR * bps, COUNT FAR * nc); -COUNT DosGetCuDir(COUNT drive, BYTE FAR * s); +VOID DosGetFree(UBYTE drive, COUNT FAR * spc, COUNT FAR * navc, COUNT FAR * bps, COUNT FAR * nc); +COUNT DosGetCuDir(UBYTE drive, BYTE FAR * s); COUNT DosChangeDir(BYTE FAR * s); COUNT DosFindFirst(UCOUNT attr, BYTE FAR * name); COUNT DosFindNext(void); @@ -240,14 +233,15 @@ COUNT DosGetFtime(COUNT hndl, date FAR * dp, time FAR * tp); COUNT DosSetFtime(COUNT hndl, date FAR * dp, time FAR * tp); COUNT DosGetFattr(BYTE FAR * name, UWORD FAR * attrp); COUNT DosSetFattr(BYTE FAR * name, UWORD FAR * attrp); -BYTE DosSelectDrv(BYTE drv); +UBYTE DosSelectDrv(UBYTE drv); COUNT DosDelete(BYTE FAR *path); COUNT DosRename(BYTE FAR * path1, BYTE FAR * path2); COUNT DosMkdir(BYTE FAR * dir); COUNT DosRmdir(BYTE FAR * dir); struct dhdr FAR * IsDevice(BYTE FAR * FileName); -/* extern sft FAR *get_free_sft(WORD FAR * sft_idx); - #define FcbGetFreeSft(sft_idx) get_free_sft(sft_idx) */ +BOOL IsShareInstalled(void); +COUNT DosLockUnlock(COUNT hndl, LONG pos, LONG len, COUNT unlock); +sft FAR *get_free_sft(WORD FAR * sft_idx); /*dosidle.asm */ VOID DosIdle_int(void); @@ -258,12 +252,12 @@ COUNT ParseDosName(BYTE FAR *, COUNT *, BYTE *, BYTE *, BYTE *, BOOL); COUNT ParseDosPath(BYTE FAR *, COUNT *, BYTE *, BYTE FAR *); /* dsk.c */ -COUNT FAR init_call_blk_driver(rqptr rp); +COUNT FAR blk_driver(rqptr rp); /* error.c */ VOID dump(void); VOID panic(BYTE * s); -__FAR_WRAPPER(VOID, fatal, (BYTE * err_msg)) +VOID fatal(BYTE * err_msg); COUNT char_error(request * rq, struct dhdr FAR * lpDevice); COUNT block_error(request * rq, COUNT nDrive, struct dhdr FAR * lpDevice); @@ -277,17 +271,17 @@ COUNT dos_findnext(void); void ConvertName83ToNameSZ(BYTE FAR *destSZ, BYTE FAR *srcFCBName); /* fatfs.c */ -__FAR_WRAPPER(COUNT, dos_open, (BYTE FAR * path, COUNT flag)) +COUNT dos_open(BYTE FAR * path, COUNT flag); BOOL fcmp(BYTE FAR * s1, BYTE FAR * s2, COUNT n); BOOL fcmp_wild(BYTE FAR * s1, BYTE FAR * s2, COUNT n); VOID touc(BYTE FAR * s, COUNT n); -__FAR_WRAPPER(COUNT, dos_close, (COUNT fd)) +COUNT dos_close(COUNT fd); COUNT dos_creat(BYTE FAR * path, COUNT attrib); COUNT dos_delete(BYTE FAR * path); COUNT dos_rmdir(BYTE FAR * path); COUNT dos_rename(BYTE FAR * path1, BYTE FAR * path2); -__FAR_WRAPPER(date, dos_getdate, (void)) -__FAR_WRAPPER(time, dos_gettime, (void)) +date dos_getdate(void); +time dos_gettime(void); COUNT dos_getftime(COUNT fd, date FAR * dp, time FAR * tp); COUNT dos_setftime(COUNT fd, date FAR * dp, time FAR * tp); LONG dos_getcufsize(COUNT fd); @@ -298,10 +292,10 @@ BOOL last_link(struct f_node FAR * fnp); COUNT map_cluster(REG struct f_node FAR * fnp, COUNT mode); UCOUNT readblock(COUNT fd, VOID FAR * buffer, UCOUNT count, COUNT * err); UCOUNT writeblock(COUNT fd, VOID FAR * buffer, UCOUNT count, COUNT * err); -__FAR_WRAPPER(COUNT, dos_read, (COUNT fd, VOID FAR * buffer, UCOUNT count)) +COUNT dos_read(COUNT fd, VOID FAR * buffer, UCOUNT count); COUNT dos_write(COUNT fd, VOID FAR * buffer, UCOUNT count); LONG dos_lseek(COUNT fd, LONG foffset, COUNT origin); -UWORD dos_free(struct dpb *dpbp); +UWORD dos_free(struct dpb FAR *dpbp); VOID trim_path(BYTE FAR * s); @@ -312,18 +306,19 @@ VOID release_f_node(struct f_node FAR * fnp); VOID dos_setdta(BYTE FAR * newdta); COUNT dos_getfattr(BYTE FAR * name, UWORD FAR * attrp); COUNT dos_setfattr(BYTE FAR * name, UWORD FAR * attrp); -COUNT media_check(REG struct dpb *dpbp); +COUNT media_check(REG struct dpb FAR *dpbp); struct f_node FAR *xlt_fd(COUNT fd); COUNT xlt_fnp(struct f_node FAR * fnp); struct dhdr FAR *select_unit(COUNT drive); +VOID bpb_to_dpb(bpb FAR *bpbp, REG struct dpb FAR * dpbp); /* fattab.c */ -UCOUNT link_fat(struct dpb *dpbp, UCOUNT Cluster1, REG UCOUNT Cluster2); -UCOUNT link_fat16(struct dpb *dpbp, UCOUNT Cluster1, UCOUNT Cluster2); -UCOUNT link_fat12(struct dpb *dpbp, UCOUNT Cluster1, UCOUNT Cluster2); -UWORD next_cluster(struct dpb *dpbp, REG UCOUNT ClusterNum); -UWORD next_cl16(struct dpb *dpbp, REG UCOUNT ClusterNum); -UWORD next_cl12(struct dpb *dpbp, REG UCOUNT ClusterNum); +UCOUNT link_fat(struct dpb FAR *dpbp, UCOUNT Cluster1, REG UCOUNT Cluster2); +UCOUNT link_fat16(struct dpb FAR *dpbp, UCOUNT Cluster1, UCOUNT Cluster2); +UCOUNT link_fat12(struct dpb FAR *dpbp, UCOUNT Cluster1, UCOUNT Cluster2); +UWORD next_cluster(struct dpb FAR *dpbp, REG UCOUNT ClusterNum); +UWORD next_cl16(struct dpb FAR *dpbp, REG UCOUNT ClusterNum); +UWORD next_cl12(struct dpb FAR *dpbp, REG UCOUNT ClusterNum); /* fcbfns.c */ VOID DosOutputString(BYTE FAR * s); @@ -345,8 +340,8 @@ BOOL FcbSetRandom(xfcb FAR * lpXfcb); BOOL FcbCalcRec(xfcb FAR * lpXfcb); BOOL FcbRandomBlockRead(xfcb FAR * lpXfcb, COUNT nRecords, COUNT * nErrorCode); BOOL FcbRandomBlockWrite(xfcb FAR * lpXfcb, COUNT nRecords, COUNT * nErrorCode); -BOOL FcbRandomRead(xfcb FAR * lpXfcb, COUNT * nErrorCode); -BOOL FcbRandomWrite(xfcb FAR * lpXfcb, COUNT * nErrorCode); +BOOL FcbRandomIO(xfcb FAR * lpXfcb, COUNT * nErrorCode, + BOOL (*FcbFunc)(xfcb FAR *, COUNT *)); BOOL FcbCreate(xfcb FAR * lpXfcb); void FcbNameInit(fcb FAR * lpFcb, BYTE * pszBuffer, COUNT * pCurDrive); BOOL FcbOpen(xfcb FAR * lpXfcb); @@ -384,8 +379,17 @@ VOID INRPT FAR int2f_handler(void); VOID INRPT FAR empty_handler(void); VOID INRPT FAR int0_handler(void); +/* intr.asm */ +/* void init_call_intr(int nr, iregs *rp); */ +INIT COUNT init_DosRead(COUNT hndl, BYTE *bp, UCOUNT n); +INIT COUNT init_DosOpen(BYTE *fname, COUNT mode); +INIT COUNT init_DosClose(COUNT hndl); +INIT VOID init_PSPInit(seg psp_seg); +INIT VOID keycheck(VOID); + /* ioctl.c */ -COUNT DosDevIOctl(iregs FAR * r, COUNT FAR * err); +COUNT DosDevIOctl(iregs FAR * r); + /* main.c */ INIT VOID main(void); @@ -393,11 +397,10 @@ INIT BOOL init_device(struct dhdr FAR * dhp, BYTE FAR * cmdLine, COUNT mode, COU /* memmgr.c */ seg far2para(VOID FAR * p); -seg long2para(LONG size); +seg long2para(ULONG size); VOID FAR *add_far(VOID FAR * fp, ULONG off); VOID FAR *adjust_far(VOID FAR * fp); -__FAR_WRAPPER(COUNT, DosMemAlloc, - (UWORD size, COUNT mode, seg FAR * para, UWORD FAR * asize)) +COUNT DosMemAlloc(UWORD size, COUNT mode, seg FAR * para, UWORD FAR * asize); COUNT DosMemLargest(UWORD FAR * size); COUNT DosMemFree(UWORD para); COUNT DosMemChange(UWORD para, UWORD size, UWORD * maxSize); @@ -410,16 +413,15 @@ VOID mcb_print(mcb FAR * mcbp); /* misc.c */ /* -__FAR_WRAPPER(VOID, scopy, (REG BYTE * s, REG BYTE * d)) +VOID scopy(REG BYTE * s, REG BYTE * d); #define strcpy(d, s) scopy(s, d) -__FAR_WRAPPER(VOID, fbcopy, (REG VOID FAR * s, REG VOID FAR * d, REG COUNT n)) +VOID fbcopy(REG VOID FAR * s, REG VOID FAR * d, REG COUNT n); */ -__FAR_WRAPPER(VOID, strcpy, (REG BYTE * d, REG BYTE * s)) +VOID strcpy(REG BYTE * d, REG BYTE * s); #define scopy(s, d) strcpy(d,s) -__FAR_WRAPPER(VOID, fmemcpy, (REG VOID FAR * d, REG VOID FAR * s, REG COUNT n)) +VOID fmemcpy(REG VOID FAR * d, REG VOID FAR * s, REG COUNT n); #define fbcopy(s, d, n) fmemcpy(d,s,n) -void FAR _reloc_call_fmemcpy(REG VOID FAR * d, REG VOID FAR * s, REG COUNT n); /*VOID fscopy(REG BYTE FAR * s, REG BYTE FAR * d);*/ @@ -432,8 +434,8 @@ VOID fstrcpy(REG BYTE FAR * d, REG BYTE FAR * s); void memcpy(REG BYTE * d, REG BYTE * s, REG COUNT n); #define bcopy(s,d,n) memcpy(d,s,n) -__FAR_WRAPPER(void, fmemset,(REG VOID FAR * s, REG int ch, REG COUNT n)) -__FAR_WRAPPER(void, memset ,(REG VOID * s, REG int ch, REG COUNT n)) +void fmemset(REG VOID FAR * s, REG int ch, REG COUNT n); +void memset(REG VOID * s, REG int ch, REG COUNT n); /* nls.c */ @@ -460,16 +462,16 @@ UWORD syscall_MUX14(DIRECT_IREGS); /* prf.c */ VOID put_console(COUNT c); -__FAR_WRAPPER(WORD, printf, (CONST BYTE * fmt,...)) +WORD printf(CONST BYTE * fmt,...); WORD sprintf(BYTE * buff, CONST BYTE * fmt,...); VOID hexd(char *title,VOID FAR *p,COUNT numBytes); /* strings.c */ -__FAR_WRAPPER(COUNT, strlen, (REG BYTE * s)) +COUNT strlen(REG BYTE * s); COUNT fstrlen(REG BYTE FAR * s); VOID _fstrcpy(REG BYTE FAR * d, REG BYTE FAR * s); VOID strncpy(REG BYTE * d, REG BYTE * s, COUNT l); -__FAR_WRAPPER(COUNT, strcmp, (REG BYTE * d, REG BYTE * s)) +COUNT strcmp(REG BYTE * d, REG BYTE * s); COUNT fstrcmp(REG BYTE FAR * d, REG BYTE FAR * s); COUNT fstrncmp(REG BYTE FAR * d, REG BYTE FAR * s, COUNT l); COUNT strncmp(REG BYTE * d, REG BYTE * s, COUNT l); @@ -483,7 +485,7 @@ void fstrncpy(REG BYTE FAR * d, REG BYTE FAR * s, COUNT l); BYTE *strchr(BYTE * s, BYTE c); /* sysclk.c */ -WORD FAR init_call_clk_driver(rqptr rp); +WORD FAR clk_driver(rqptr rp); COUNT BcdToByte(COUNT x); COUNT BcdToWord(BYTE * x, UWORD * mon, UWORD * day, UWORD * yr); COUNT ByteToBcd(COUNT x); @@ -505,7 +507,7 @@ VOID DosGetDate(BYTE FAR * wdp, BYTE FAR * mp, BYTE FAR * mdp, COUNT FAR * yp); COUNT DosSetDate(BYTE FAR * mp, BYTE FAR * mdp, COUNT FAR * yp); WORD *is_leap_year_monthdays(int year); -__FAR_WRAPPER(WORD,DaysFromYearMonthDay,(WORD Year, WORD Month, WORD DayOfMonth)) +WORD DaysFromYearMonthDay(WORD Year, WORD Month, WORD DayOfMonth); @@ -513,10 +515,9 @@ __FAR_WRAPPER(WORD,DaysFromYearMonthDay,(WORD Year, WORD Month, WORD DayOfMonth) COUNT ChildEnv(exec_blk FAR * exp, UWORD * pChildEnvSeg, char far * pathname); VOID new_psp(psp FAR * p, int psize); VOID return_user(void); -__FAR_WRAPPER(COUNT, DosExec, (COUNT mode, exec_blk FAR * ep, BYTE FAR * lp)) -__FAR_WRAPPER(VOID, InitPSP, (VOID)) - -VOID FAR init_call_p_0(VOID); +COUNT DosExec(COUNT mode, exec_blk FAR * ep, BYTE FAR * lp); +VOID InitPSP(VOID); +VOID p_0(VOID); /* irqstack.asm */ VOID init_stacks(VOID FAR * stack_base, COUNT nStacks, WORD stackSize); diff --git a/kernel/segs.inc b/kernel/segs.inc index 992212d6..6f88f733 100644 --- a/kernel/segs.inc +++ b/kernel/segs.inc @@ -29,6 +29,9 @@ ; $Header$ ; ; $Log$ +; Revision 1.5 2001/04/15 03:21:50 bartoldeman +; See history.txt for the list of fixes. +; ; Revision 1.4 2001/03/21 02:56:26 bartoldeman ; See history.txt for changes. Bug fixes and HMA support are the main ones. ; @@ -58,7 +61,7 @@ ; group TGROUP _TEXT _IO_TEXT _IO_FIXED_DATA -group DGROUP _FIXED_DATA _DATA _BSS _BSSEND +group DGROUP _FIXED_DATA _DATA _BSS _BSSEND ID_B ID ID_E group HGROUP HMA_TEXT_START HMA_TEXT HMA_TEXT_END group IGROUP INIT_TEXT_START INIT_TEXT INIT_TEXT_END @@ -67,11 +70,14 @@ segment _IO_TEXT class=CODE segment _IO_FIXED_DATA class=CODE align=2 segment _FIXED_DATA class=DATA align=16 segment _DATA class=DATA align=2 -segment _BSSSTART class=BSS align=2 +segment _BSSSTART class=BSS align=2 segment _BSS class=BSS align=2 segment _BSSEND class=BSS +segment ID_B class=ID align=2 +segment ID class=ID align=2 +segment ID_E class=ID align=2 segment HMA_TEXT_START class=HMA -segment HMA_TEXT class=HMA +segment HMA_TEXT class=HMA segment HMA_TEXT_END class=HMA segment INIT_TEXT_START class=INIT align=16 segment INIT_TEXT class=INIT diff --git a/kernel/strings.c b/kernel/strings.c index c97ca2b8..c9a89eed 100644 --- a/kernel/strings.c +++ b/kernel/strings.c @@ -34,6 +34,9 @@ static BYTE *stringsRcsId = "$Id$"; /* * $Log$ + * Revision 1.5 2001/04/15 03:21:50 bartoldeman + * See history.txt for the list of fixes. + * * Revision 1.4 2001/03/21 02:56:26 bartoldeman * See history.txt for changes. Bug fixes and HMA support are the main ones. * @@ -104,11 +107,6 @@ COUNT strlen(REG BYTE * s) return cnt; } -COUNT FAR init_call_strlen(REG BYTE * s) -{ - return strlen(s); -} - COUNT fstrlen(REG BYTE FAR * s) { REG WORD cnt = 0; @@ -145,11 +143,6 @@ COUNT strcmp(REG BYTE * d, REG BYTE * s) return *d - *s; } -COUNT FAR init_call_strcmp(REG BYTE * d, REG BYTE * s) -{ - return strcmp(d, s); -} - COUNT fstrcmp(REG BYTE FAR * d, REG BYTE FAR * s) { while (*s != '\0' && *d != '\0') diff --git a/kernel/sysclk.c b/kernel/sysclk.c index c3188b38..f13710c8 100644 --- a/kernel/sysclk.c +++ b/kernel/sysclk.c @@ -35,6 +35,9 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.5 2001/04/15 03:21:50 bartoldeman + * See history.txt for the list of fixes. + * * Revision 1.4 2001/03/21 02:56:26 bartoldeman * See history.txt for changes. Bug fixes and HMA support are the main ones. * @@ -121,17 +124,16 @@ static UWORD Month, Year; static BYTE bcdMinutes; static BYTE bcdHours; -static BYTE bcdHundredths; +/** static BYTE bcdHundredths;*/ static BYTE bcdSeconds; static ULONG Ticks; UWORD DaysSinceEpoch = 0; -WORD FAR init_call_clk_driver(rqptr rp) +WORD FAR clk_driver(rqptr rp) { COUNT c; - int FAR *cp; WORD *pdays; switch (rp->r_command) @@ -337,9 +339,3 @@ VOID DayToBcd(BYTE * x, UWORD * mon, UWORD * day, UWORD * yr) x[3] = ByteToBcd(*yr / 100); x[2] = ByteToBcd(*yr % 100); } - -/* Used by `main.c'. */ -VOID FAR init_call_WritePCClock(ULONG ticks) -{ - WritePCClock(ticks); -} diff --git a/kernel/systime.c b/kernel/systime.c index 0bb740f2..5bc13d2d 100644 --- a/kernel/systime.c +++ b/kernel/systime.c @@ -37,6 +37,9 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.5 2001/04/15 03:21:50 bartoldeman + * See history.txt for the list of fixes. + * * Revision 1.4 2001/03/21 02:56:26 bartoldeman * See history.txt for changes. Bug fixes and HMA support are the main ones. * @@ -133,11 +136,6 @@ WORD DaysFromYearMonthDay(WORD Year, WORD Month, WORD DayOfMonth) + ((Year - 1980 + 3) / 4); } -WORD FAR init_call_DaysFromYearMonthDay(WORD Year, WORD Month, WORD DayOfMonth) -{ - return DaysFromYearMonthDay(Year,Month,DayOfMonth); -} - /* common - call the clock driver */ void ExecuteClockDriverRequest(BYTE command) diff --git a/kernel/task.c b/kernel/task.c index 4c3243f5..c7702a9a 100644 --- a/kernel/task.c +++ b/kernel/task.c @@ -35,6 +35,9 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.10 2001/04/15 03:21:50 bartoldeman + * See history.txt for the list of fixes. + * * Revision 1.9 2001/03/31 20:54:52 bartoldeman * Made SHELLHIGH behave more like LOADHIGH. * @@ -149,6 +152,8 @@ static BYTE *RcsId = "$Id$"; * Initial revision. */ +extern VOID ClaimINITDataSegment(VOID); + #define toupper(c) ((c) >= 'a' && (c) <= 'z' ? (c) + ('A' - 'a') : (c)) #define LOADNGO 0 @@ -160,7 +165,7 @@ static BYTE *RcsId = "$Id$"; static exe_header header; #define CHUNK 32256 -#define MAXENV 32768 +#define MAXENV 32768u #define ENV_KEEPFREE 83 /* keep unallocated by environment variables */ /* The '65' added to nEnvSize does not cover the additional stuff: + 2 bytes: number of strings @@ -311,12 +316,10 @@ COUNT ChildEnv(exec_blk FAR * exp, UWORD * pChildEnvSeg, char far * pathname) VOID new_psp(psp FAR * p, int psize) { REG COUNT i; - BYTE FAR *lpPspBuffer; psp FAR *q = MK_FP(cu_psp, 0); /* Clear out new psp first */ - for (lpPspBuffer = (BYTE FAR *) p, i = 0; i < sizeof(psp); ++i) - *lpPspBuffer = 0; + fmemset(p, 0, sizeof(psp)); /* initialize all entries and exits */ /* CP/M-like exit point */ @@ -364,7 +367,7 @@ VOID new_psp(psp FAR * p, int psize) p->ps_filetab = p->ps_files; /* clone the file table */ - if (InDOS > 0) + if (p!=q) { REG COUNT i; @@ -376,15 +379,6 @@ VOID new_psp(psp FAR * p, int psize) p->ps_filetab[i] = 0xff; } } - else - { - /* initialize stdin, stdout, etc */ - p->ps_files[STDIN] = 0; /* stdin */ - p->ps_files[STDOUT] = 1; /* stdout */ - p->ps_files[STDERR] = 2; /* stderr */ - p->ps_files[STDAUX] = 3; /* stdaux */ - p->ps_files[STDPRN] = 4; /* stdprn */ - } /* first command line argument */ p->ps_fcb1.fcb_drive = 0; @@ -540,14 +534,16 @@ COUNT DosComLoader(BYTE FAR * namep, exec_blk FAR * exp, COUNT mode) sp = MK_FP(mem, 0); else { /* test the filesize against the allocated memory */ + UWORD tmp = 16; + sp = MK_FP(mem, sizeof(psp)); /* This is a potential problem, what to do with .COM files larger than the allocated memory? MS DOS always only loads the very first 64KB - sizeof(psp) bytes. -- 1999/04/21 ska */ - if (com_size > (LONG) asize << 4) /* less memory than the .COM file has */ - com_size = (LONG) asize << 4; + if ((ULONG)com_size > (ULONG)asize * tmp) /* less memory than the .COM file has */ + (ULONG)com_size = (ULONG)asize * tmp; /* << 4 */ } do { @@ -597,6 +593,14 @@ COUNT DosComLoader(BYTE FAR * namep, exec_blk FAR * exp, COUNT mode) { cu_psp = mem; dta = p->ps_dta; + + /* if that's the first time, we arrive here + now we 1 microsecond from COMMAND.COM + now we claim the ID = INIT_DATA segment, + which should no longer be used + */ + ClaimINITDataSegment(); + if (InDOS) --InDOS; exec_user(irp); @@ -693,13 +697,15 @@ COUNT DosExeLoader(BYTE FAR * namep, exec_blk FAR * exp, COUNT mode) mem = exp->load.load_seg; /* compute image offset from the header */ - image_offset = (ULONG) header.exHeaderSize * 16l; + asize = 16; + image_offset = (ULONG)header.exHeaderSize * asize; /* compute image size by removing the offset from the */ /* number pages scaled to bytes plus the remainder and */ /* the psp */ /* First scale the size */ - image_size = (ULONG) (header.exPages) * 512l; + asize = 512; + image_size = (ULONG)header.exPages * asize; /* remove the offset */ image_size -= image_offset; @@ -777,7 +783,15 @@ COUNT DosExeLoader(BYTE FAR * namep, exec_blk FAR * exp, COUNT mode) asize = exe_size; #ifdef DEBUG - printf("loading %s at %04x\n", (char*)namep,mem); +{ COUNT i = 0; + printf("loading '"); + while (namep[i]!=0) + { + cso(namep[i]); + i++; + } + printf("' at %04x\n", mem); +} #endif /* /// Added open curly brace and "else" clause. We should not attempt @@ -844,6 +858,8 @@ COUNT DosExeLoader(BYTE FAR * namep, exec_blk FAR * exp, COUNT mode) if (exe_size > 0) { + UCOUNT tmp = 16; + sp = MK_FP(start_seg, 0x0); if (mode != OVERLAY) @@ -851,7 +867,7 @@ COUNT DosExeLoader(BYTE FAR * namep, exec_blk FAR * exp, COUNT mode) if ((header.exMinAlloc == 0) && (header.exMaxAlloc == 0)) { sp = MK_FP(start_seg + mp->m_size - - (image_size + 15) / 16, 0); + - (image_size + 15) / tmp, 0); } } @@ -928,6 +944,15 @@ COUNT DosExeLoader(BYTE FAR * namep, exec_blk FAR * exp, COUNT mode) case LOADNGO: cu_psp = mem; dta = p->ps_dta; + + + /* if that's the first time, we arrive here + now we 1 microsecond from COMMAND.COM + now we claim the ID = INIT_DATA segment, + which should no longer be used + */ + ClaimINITDataSegment(); + if (InDOS) --InDOS; exec_user(irp); @@ -954,15 +979,14 @@ COUNT DosExec(COUNT mode, exec_blk FAR * ep, BYTE FAR * lp) { COUNT rc, err; - exec_blk leb = *ep; + exec_blk leb; + /* BYTE FAR *cp;*/ BOOL bIsCom = FALSE; + fmemcpy(&leb, ep, sizeof(exec_blk)); /* If file not found - free ram and return error */ - if (cu_psp == DOS_PSP) - InitPSP(); - if ((rc = DosOpen(lp, 0)) < 0) { return DE_FILENOTFND; @@ -985,43 +1009,22 @@ COUNT DosExec(COUNT mode, exec_blk FAR * ep, BYTE FAR * lp) rc = DosExeLoader(lp, &leb, mode); } if (mode == LOAD && rc == SUCCESS) - *ep = leb; + fmemcpy(ep, &leb, sizeof(exec_blk)); return rc; } -COUNT FAR init_call_DosExec(COUNT mode, exec_blk FAR * ep, BYTE FAR * lp) -{ - return DosExec(mode, ep, lp); -} - -VOID InitPSP(VOID) -{ - psp FAR *p = MK_FP(DOS_PSP, 0); -/* - Fixed Device Driver Print output. - */ - if(p->ps_exit == 0x000020cd) - return; - new_psp(p, 0); -} - -UBYTE P_0_startmode = 0; - /* process 0 */ -VOID FAR reloc_call_p_0(VOID) +VOID p_0(VOID) { exec_blk exb; CommandTail Cmd; BYTE FAR *szfInitialPrgm = (BYTE FAR *) Config.cfgInit; int rc; -/* init a fake psp file at seg 50:0000 */ - psp FAR *p = MK_FP(cu_psp, 0); - new_psp(p, 0); /* Execute command.com /P from the drive we just booted from */ exb.exec.env_seg = master_env; - strcpy(Cmd.ctBuffer, Config.cfgInitTail); + fstrncpy(Cmd.ctBuffer, Config.cfgInitTail, sizeof(Config.cfgInitTail)-1); for (Cmd.ctCount = 0; Cmd.ctCount < 127; Cmd.ctCount++) if (Cmd.ctBuffer[Cmd.ctCount] == '\r') diff --git a/sys/sys.mak b/sys/sys.mak index d48f4026..9f5e0bb1 100644 --- a/sys/sys.mak +++ b/sys/sys.mak @@ -4,6 +4,9 @@ # $Id$ # # $Log$ +# Revision 1.7 2001/04/15 03:21:50 bartoldeman +# See history.txt for the list of fixes. +# # Revision 1.6 2001/03/25 04:33:56 bartoldeman # Fix compilation of sys.com. Now a proper .com file once again. # @@ -43,7 +46,7 @@ !include "..\config.mak" CFLAGS = -mt -1- -v -vi- -k- -f- -ff- -O -Z -d -I$(INCLUDEPATH);..\hdr \ - -DI86;PROTO -zAHMA -zCHMA_TEXT -zPDGROUP + -DI86;PROTO # *Implicit Rules* .c.obj: @@ -54,11 +57,11 @@ CFLAGS = -mt -1- -v -vi- -k- -f- -ff- -O -Z -d -I$(INCLUDEPATH);..\hdr \ # *List Macros* -LIBS = ..\lib\device.lib +LIBS = floppy.obj EXE_dependencies = \ sys.obj \ - $(LIBS) + floppy.obj # *Explicit Rules* production: ..\bin\sys.com @@ -72,9 +75,12 @@ b_fat12.h: ..\boot\b_fat12.bin bin2c.com b_fat16.h: ..\boot\b_fat16.bin bin2c.com bin2c ..\boot\b_fat16.bin b_fat16.h b_fat16 +floppy.obj: ..\drivers\floppy.asm + $(NASM) -fobj -DSYS=1 ..\drivers\floppy.asm -o floppy.obj + sys.com: $(EXE_dependencies) - $(LINK) /m/t/c $(LIBPATH)\c0t.obj+sys.obj,sys,,\ - $(LIBS)+$(CLIB); + $(LINK) /m/t/c $(LIBPATH)\c0t.obj+sys.obj+$(LIBS),sys,,\ + $(CLIB); clobber: clean $(RM) sys.com b_fat12.h b_fat16.h @@ -84,3 +90,8 @@ clean: # *Individual File Dependencies* sys.obj: sys.c ..\hdr\portab.h ..\hdr\device.h b_fat12.h b_fat16.h + +# RULES (DEPENDENCIES) +# ---------------- +.asm.obj : + $(NASM) -f obj -DSYS=1 $< \ No newline at end of file From c07675522e50f3dc7e5eb4eb9aac6a5c16413c4a Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Mon, 16 Apr 2001 01:45:26 +0000 Subject: [PATCH 071/671] Fixed handles, config.sys drivers, warnings. Enabled INT21/AH=6C, printf %S/%Fs git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@197 6ac86273-5f31-0410-b378-82cca8765d1b --- docs/history.txt | 9 ++++ hdr/dirmatch.h | 15 +++--- hdr/error.h | 5 ++ kernel/chario.c | 9 +++- kernel/config.c | 8 +++ kernel/dsk.c | 17 ++++--- kernel/fatfs.c | 4 +- kernel/inithma.c | 5 +- kernel/inthndlr.c | 126 +++++++++++++++------------------------------- kernel/main.c | 24 ++++++++- kernel/memmgr.c | 5 +- kernel/prf.c | 23 +++++++-- kernel/proto.h | 5 +- kernel/task.c | 13 ++--- 14 files changed, 149 insertions(+), 119 deletions(-) diff --git a/docs/history.txt b/docs/history.txt index 67cb6133..530c8daf 100644 --- a/docs/history.txt +++ b/docs/history.txt @@ -1,3 +1,12 @@ +2001 Apr 16 - Build 2023 +-------- Bart Oldeman (bart.oldeman@bristol.ac.uk) ++ Fixes * Thanks to Martin Stromberg for pointing some bugs out: + * more warnings fixed. + * accidentally opened too many file handles at boot time. + * device drivers should not be linked into the device chain + if they do not take up memory. ++ Add * added printf "%S" and "%Fs" to print far strings. + * enabled and cleaned up INT21/AH=6C (extended open/create). 2001 Apr 15 - Build 2023 -------- Bart Oldeman (bart.oldeman@bristol.ac.uk) + Fixes Tom: diff --git a/hdr/dirmatch.h b/hdr/dirmatch.h index 5001ec9f..07679909 100644 --- a/hdr/dirmatch.h +++ b/hdr/dirmatch.h @@ -36,6 +36,9 @@ static BYTE *dirmatch_hRcsId = "$Id$"; /* * $Log$ + * Revision 1.4 2001/04/16 01:45:26 bartoldeman + * Fixed handles, config.sys drivers, warnings. Enabled INT21/AH=6C, printf %S/%Fs + * * Revision 1.3 2000/05/25 20:56:19 jimtabor * Fixed project history * @@ -98,17 +101,17 @@ typedef struct struct { - UWORD /* directory has been modified */ + BITS /* directory has been modified */ f_dmod:1; - UWORD /* directory is the root */ + BITS /* directory is the root */ f_droot:1; - UWORD /* fnode is new and needs fill */ + BITS /* fnode is new and needs fill */ f_dnew:1; - UWORD /* fnode is assigned to dir */ + BITS /* fnode is assigned to dir */ f_ddir:1; - UWORD /* directory is full */ + BITS /* directory is full */ f_dfull:1; - UWORD /* filler to avoid a bad bug (feature?) in */ + BITS /* filler to avoid a bad bug (feature?) in */ f_filler:11; /* TC 2.01 */ } dm_flags; /* file flags */ diff --git a/hdr/error.h b/hdr/error.h index 83b90572..1fcb216d 100644 --- a/hdr/error.h +++ b/hdr/error.h @@ -36,6 +36,9 @@ static BYTE *error_hRcsId = "$Id$"; /* * $Log$ + * Revision 1.5 2001/04/16 01:45:26 bartoldeman + * Fixed handles, config.sys drivers, warnings. Enabled INT21/AH=6C, printf %S/%Fs + * * Revision 1.4 2000/11/02 06:56:53 jimtabor * Fix Share Patch * @@ -117,6 +120,8 @@ static BYTE *error_hRcsId = "$Id$"; #define DE_DEADLOCK -36 #define DE_LOCK -39 +#define DE_FILEEXISTS -80 /* File exists */ + /* Critical error flags */ #define EFLG_READ 0x00 /* Read error */ #define EFLG_WRITE 0x01 /* Write error */ diff --git a/kernel/chario.c b/kernel/chario.c index 318cd552..33cc6a0c 100644 --- a/kernel/chario.c +++ b/kernel/chario.c @@ -36,6 +36,9 @@ static BYTE *charioRcsId = "$Id$"; /* * $Log$ + * Revision 1.6 2001/04/16 01:45:26 bartoldeman + * Fixed handles, config.sys drivers, warnings. Enabled INT21/AH=6C, printf %S/%Fs + * * Revision 1.5 2001/04/15 03:21:50 bartoldeman * See history.txt for the list of fixes. * @@ -121,11 +124,11 @@ static BYTE *charioRcsId = "$Id$"; #include "globals.h" #ifdef PROTO -VOID kbfill(keyboard FAR *, UCOUNT, BOOL, UWORD *); +static VOID kbfill(keyboard FAR *, UCOUNT, BOOL, UWORD *); struct dhdr FAR *finddev(UWORD attr_mask); #else -VOID kbfill(); +static VOID kbfill(); struct dhdr FAR *finddev(); #endif @@ -147,6 +150,7 @@ struct dhdr FAR *finddev(UWORD attr_mask) return &nul_dev; } +#if 0 VOID cso(COUNT c) { BYTE buf = c; @@ -162,6 +166,7 @@ VOID cso(COUNT c) if (CharReqHdr.r_status & S_ERROR) char_error(&CharReqHdr, lpDevice); } +#endif VOID sto(COUNT c) diff --git a/kernel/config.c b/kernel/config.c index 0d5435e8..0044fe8e 100644 --- a/kernel/config.c +++ b/kernel/config.c @@ -40,6 +40,9 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.18 2001/04/16 01:45:26 bartoldeman + * Fixed handles, config.sys drivers, warnings. Enabled INT21/AH=6C, printf %S/%Fs + * * Revision 1.17 2001/04/15 03:21:50 bartoldeman * See history.txt for the list of fixes. * @@ -381,6 +384,9 @@ INIT void PreConfig(void) /* Also, run config.sys to load drivers. */ INIT void PostConfig(void) { + /* close all (device) files */ + + /* Set pass number */ nPass = 2; /* compute lastdrive ... */ @@ -1067,6 +1073,8 @@ INIT BOOL LoadDevice(BYTE * pLine, COUNT top, COUNT mode) (result=init_device(dhp, pTmp, mode, top))==SUCCESS ; dhp = next_dhp) { + + printf("result=%d\n", result); next_dhp = dhp->dh_next; if (FP_SEG(next_dhp) == 0xffff) /* Does this ever occur with FP_OFF(next_dhp) != 0xffff ??? */ diff --git a/kernel/dsk.c b/kernel/dsk.c index 7b9dccb6..9688f404 100644 --- a/kernel/dsk.c +++ b/kernel/dsk.c @@ -32,6 +32,9 @@ static BYTE *dskRcsId = "$Id$"; /* * $Log$ + * Revision 1.15 2001/04/16 01:45:26 bartoldeman + * Fixed handles, config.sys drivers, warnings. Enabled INT21/AH=6C, printf %S/%Fs + * * Revision 1.14 2001/04/15 03:21:50 bartoldeman * See history.txt for the list of fixes. * @@ -1008,23 +1011,23 @@ static WORD Genblkdev(rqptr rp) y = 2; x = 8; /* any odd ball drives return this */ if (miarray[rp->r_unit].mi_size <= 0xffff) - switch(miarray[rp->r_unit].mi_size) + switch((UWORD)miarray[rp->r_unit].mi_size) { - case 640l: - case 720l: /* 320-360 */ + case 640: + case 720: /* 320-360 */ x = 0; z = 1; break; - case 1440l: /* 720 */ + case 1440: /* 720 */ x = 2; break; - case 2400l: /* 1.2 */ + case 2400: /* 1.2 */ x = 1; break; - case 2880l: /* 1.44 */ + case 2880: /* 1.44 */ x = 7; break; - case 5760l: /* 2.88 almost forgot this one*/ + case 5760: /* 2.88 almost forgot this one*/ x = 9; break; } diff --git a/kernel/fatfs.c b/kernel/fatfs.c index 23f46716..625e2bec 100644 --- a/kernel/fatfs.c +++ b/kernel/fatfs.c @@ -36,6 +36,9 @@ BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.15 2001/04/16 01:45:26 bartoldeman + * Fixed handles, config.sys drivers, warnings. Enabled INT21/AH=6C, printf %S/%Fs + * * Revision 1.14 2001/04/15 03:21:50 bartoldeman * See history.txt for the list of fixes. * @@ -394,7 +397,6 @@ struct f_node FAR * */ #ifdef DEBUG if (cdsp->cdsFlags & CDSNETWDRV) { - BYTE FAR *p; printf("split path called for redirected file: `%s.%s'\n", fname, fext); return (struct f_node FAR *)0; diff --git a/kernel/inithma.c b/kernel/inithma.c index 725bd261..aa2d772a 100644 --- a/kernel/inithma.c +++ b/kernel/inithma.c @@ -75,6 +75,9 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.4 2001/04/16 01:45:26 bartoldeman + * Fixed handles, config.sys drivers, warnings. Enabled INT21/AH=6C, printf %S/%Fs + * * Revision 1.3 2001/04/15 03:21:50 bartoldeman * See history.txt for the list of fixes. * @@ -116,7 +119,7 @@ extern void FAR *DetectXMSDriver(VOID); #ifdef DEBUG -hdump(BYTE FAR *p) +VOID hdump(BYTE FAR *p) { int loop; HMAInitPrintf(("%p", p)); diff --git a/kernel/inthndlr.c b/kernel/inthndlr.c index d8cdd285..0ad6227d 100644 --- a/kernel/inthndlr.c +++ b/kernel/inthndlr.c @@ -37,6 +37,9 @@ BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.21 2001/04/16 01:45:26 bartoldeman + * Fixed handles, config.sys drivers, warnings. Enabled INT21/AH=6C, printf %S/%Fs + * * Revision 1.20 2001/04/15 03:21:50 bartoldeman * See history.txt for the list of fixes. * @@ -1639,99 +1642,52 @@ VOID int21_service(iregs FAR * r) case 0x6a: see case 0x68 case 0x6b: dummy func: return AL=0 */ -#if 0 - /* Extended Open-Creat, not fully functional.*/ + /* Extended Open-Creat, not fully functional. (bits 4,5,6 of BH) */ case 0x6c: - switch(r->DL) { - case 0x12: - { - COUNT x = 0; - if ((rc = DosOpen(MK_FP(r->DS, r->SI), 0)) >= 0) - { - DosClose(rc); - x = 1; - } - if ((rc = DosCreat(MK_FP(r->DS, r->SI), r->CX )) < 0 ) - goto error_exit; - else - { - x += 2; - r->CX = x; - r->AX = rc; - CLEAR_CARRY_FLAG(); - } - } - break; - case 0x10: - if ((rc = DosOpen(MK_FP(r->DS, r->SI), 0)) >= 0) - { - DosClose(rc); - r->AX = 80; - r->FLAGS |= FLG_CARRY; - } - else - { - if ((rc = DosCreat(MK_FP(r->DS, r->SI), r->CX )) < 0 ) - goto error_exit; - else - { - r->CX = 0x02; - r->AX = rc; - CLEAR_CARRY_FLAG(); - } - } - break; - case 0x02: - if ((rc = DosOpen(MK_FP(r->DS, r->SI), 0)) < 0) + { + COUNT x = 0; + + if (r->AL != 0 || r->DH != 0 || + (r->DL&0x0f) > 0x2 || (r->DL&0xf0) > 0x10) + goto error_invalid; + CLEAR_CARRY_FLAG(); + if ((rc = DosOpen(MK_FP(r->DS, r->SI), + (r->DL&0x0f) == 0x1 ? r->BL : 0)) < 0) + { + if (r->DL < 0x10) goto error_exit; + /* else try to create below */ + } + else switch (r->DL & 0x0f) + { + case 0x0: + /* fail if file exists */ DosClose(rc); - if ((rc = DosCreat(MK_FP(r->DS, r->SI), r->CX )) < 0 ) - goto error_exit; - else - { - r->CX = 0x03; - r->AX = rc; - CLEAR_CARRY_FLAG(); - } - break; - - case 0x11: - if ((rc = DosOpen(MK_FP(r->DS, r->SI), 0)) >= 0) - { - r->CX = 0x01; - r->AX = rc; - CLEAR_CARRY_FLAG(); - } - else{ - if ((rc = DosCreat(MK_FP(r->DS, r->SI), r->CX )) < 0 ) - goto error_exit; - else - { - r->CX = 0x02; - r->AX = rc; - CLEAR_CARRY_FLAG(); - } - } - break; - - case 0x01: - if ((rc = DosOpen(MK_FP(r->DS, r->SI), r->BL )) < 0 ) - goto error_exit; - else - { - r->CX = 0x01; - r->AX = rc; - CLEAR_CARRY_FLAG(); - } + rc = DE_FILEEXISTS; + goto error_exit; + case 0x1: + /* file exists and opened: OK */ + r->CX = 0x01; + goto break_out; + case 0x2: + /* file exists: replace/open */ + DosClose(rc); + x = 1; break; + } + /* cases 0x00, 0x01 are finished now */ + if ((rc = DosCreat(MK_FP(r->DS, r->SI), r->CX)) < 0) + goto error_exit; + + r->CX = x+2; +break_out: + r->AX = rc; + break; + } - default: - goto error_invalid; - } /* case 0x6d and above not implemented : see default; return AL=0 */ -#endif } #ifdef DEBUG diff --git a/kernel/main.c b/kernel/main.c index 493dab43..af591ca1 100644 --- a/kernel/main.c +++ b/kernel/main.c @@ -38,6 +38,9 @@ static BYTE *mainRcsId = "$Id$"; /* * $Log$ + * Revision 1.14 2001/04/16 01:45:26 bartoldeman + * Fixed handles, config.sys drivers, warnings. Enabled INT21/AH=6C, printf %S/%Fs + * * Revision 1.13 2001/04/15 03:21:50 bartoldeman * See history.txt for the list of fixes. * @@ -312,6 +315,11 @@ INIT void init_kernel(void) #ifndef KDB /* Now process CONFIG.SYS */ DoConfig(); + + /* Close all (device) files */ + for (i = 0; i < lastdrive; i++) + init_DosClose(i); + /* and do final buffer allocation. */ PostConfig(); nblkdev = 0; @@ -324,6 +332,10 @@ INIT void init_kernel(void) DoConfig(); configDone(); + /* Close all (device) files */ + for (i = 0; i < lastdrive; i++) + init_DosClose(i); + /* Now config the final file system */ FsConfig(); @@ -351,7 +363,6 @@ INIT VOID FsConfig(VOID) sfthead->sftt_count = Config.cfgFiles; for (i = 0; i < sfthead->sftt_count; i++) { - init_DosClose(i); sfthead->sftt_table[i].sft_count = 0; sfthead->sftt_table[i].sft_status = -1; } @@ -516,10 +527,21 @@ BOOL init_device(struct dhdr FAR * dhp, BYTE FAR * cmdLine, COUNT mode, COUNT r_ if(cmdLine){ if (mode) + { + /* Don't link in device drivers which do not take up memory */ + if (rq.r_endaddr == (BYTE FAR *)dhp) + return TRUE; + else upBase = rq.r_endaddr; + } else + { + if (rq.r_endaddr == (BYTE FAR *)dhp) + return TRUE; + else lpBase = rq.r_endaddr; } + } if (!(dhp->dh_attr & ATTR_CHAR) && (rq.r_nunits != 0)) { dhp->dh_name[0] = rq.r_nunits; diff --git a/kernel/memmgr.c b/kernel/memmgr.c index cd0bcb05..0118975d 100644 --- a/kernel/memmgr.c +++ b/kernel/memmgr.c @@ -35,6 +35,9 @@ static BYTE *memmgrRcsId = "$Id$"; /* * $Log$ + * Revision 1.13 2001/04/16 01:45:26 bartoldeman + * Fixed handles, config.sys drivers, warnings. Enabled INT21/AH=6C, printf %S/%Fs + * * Revision 1.12 2001/04/15 03:21:50 bartoldeman * See history.txt for the list of fixes. * @@ -612,7 +615,7 @@ COUNT DosGetLargestBlock(UWORD FAR * block) #ifdef DEBUG VOID show_chain(void) { - mcb FAR *p, FAR *u; + mcb FAR *p; p = para2far(first_mcb); for (;;) diff --git a/kernel/prf.c b/kernel/prf.c index 8be3991a..44fc9f39 100644 --- a/kernel/prf.c +++ b/kernel/prf.c @@ -28,7 +28,7 @@ #include "portab.h" -COUNT strlen (BYTE * s); /* don't want globals.h, sorry */ +COUNT fstrlen (BYTE FAR * s); /* don't want globals.h, sorry */ #ifdef VERSION_STRINGS @@ -37,6 +37,9 @@ static BYTE *prfRcsId = "$Id$"; /* * $Log$ + * Revision 1.8 2001/04/16 01:45:26 bartoldeman + * Fixed handles, config.sys drivers, warnings. Enabled INT21/AH=6C, printf %S/%Fs + * * Revision 1.7 2001/04/15 03:21:50 bartoldeman * See history.txt for the list of fixes. * @@ -50,6 +53,9 @@ static BYTE *prfRcsId = "$Id$"; * recoded for smaller object footprint, added main() for testing+QA * * $Log$ + * Revision 1.8 2001/04/16 01:45:26 bartoldeman + * Fixed handles, config.sys drivers, warnings. Enabled INT21/AH=6C, printf %S/%Fs + * * Revision 1.7 2001/04/15 03:21:50 bartoldeman * See history.txt for the list of fixes. * @@ -224,7 +230,7 @@ COUNT { int base; BYTE s[11], - *p; + FAR *p; int c, flag, size, @@ -303,8 +309,15 @@ COUNT } case 's': - p = *((BYTE **) arg)++; - goto do_outputstring; + p = *((BYTE **) arg)++; + goto do_outputstring; + + case 'F': + fmt++; + /* we assume %Fs here */ + case 'S': + p = *((BYTE FAR **) arg)++; + goto do_outputstring; case 'd': base = -10; @@ -334,7 +347,7 @@ COUNT p = s; do_outputstring: - size -= strlen(p); + size -= fstrlen(p); if (flag == RIGHT ) { diff --git a/kernel/proto.h b/kernel/proto.h index 8b5495aa..60818522 100644 --- a/kernel/proto.h +++ b/kernel/proto.h @@ -34,6 +34,9 @@ static BYTE *Proto_hRcsId = "$Id$"; /* * $Log$ + * Revision 1.14 2001/04/16 01:45:26 bartoldeman + * Fixed handles, config.sys drivers, warnings. Enabled INT21/AH=6C, printf %S/%Fs + * * Revision 1.13 2001/04/15 03:21:50 bartoldeman * See history.txt for the list of fixes. * @@ -180,7 +183,7 @@ UWORD dskxfer(COUNT dsk, ULONG blkno, VOID FAR * buf, UWORD numblocks, COUNT mod /* *** End of change /* chario.c */ -VOID cso(COUNT c); +/* VOID cso(COUNT c);*/ VOID sto(COUNT c); VOID mod_sto(REG UCOUNT c); VOID destr_bs(void); diff --git a/kernel/task.c b/kernel/task.c index c7702a9a..c94d8675 100644 --- a/kernel/task.c +++ b/kernel/task.c @@ -35,6 +35,9 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.11 2001/04/16 01:45:26 bartoldeman + * Fixed handles, config.sys drivers, warnings. Enabled INT21/AH=6C, printf %S/%Fs + * * Revision 1.10 2001/04/15 03:21:50 bartoldeman * See history.txt for the list of fixes. * @@ -783,15 +786,7 @@ COUNT DosExeLoader(BYTE FAR * namep, exec_blk FAR * exp, COUNT mode) asize = exe_size; #ifdef DEBUG -{ COUNT i = 0; - printf("loading '"); - while (namep[i]!=0) - { - cso(namep[i]); - i++; - } - printf("' at %04x\n", mem); -} + printf("loading '%S' at %04x\n", namep, mem); #endif /* /// Added open curly brace and "else" clause. We should not attempt From 6a6899aef63f50a5e392ac5ea9802f1be30228bf Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Mon, 16 Apr 2001 14:28:32 +0000 Subject: [PATCH 072/671] Kernel build 2024. Fixed critical error handler/config.sys/makefiles/UMBs git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@201 6ac86273-5f31-0410-b378-82cca8765d1b --- docs/history.txt | 10 ++++++- hdr/version.h | 4 +-- kernel/config.c | 18 ++++++++---- kernel/entry.asm | 9 ++++-- kernel/kernel.mak | 70 +++++++++++++++++++++++++---------------------- kernel/task.c | 15 ++++++++++ kernel/turboc.cfg | 15 ++++++++++ 7 files changed, 96 insertions(+), 45 deletions(-) create mode 100644 kernel/turboc.cfg diff --git a/docs/history.txt b/docs/history.txt index 530c8daf..50d9ec61 100644 --- a/docs/history.txt +++ b/docs/history.txt @@ -1,4 +1,12 @@ -2001 Apr 16 - Build 2023 +2001 Apr 16 - Build 2024 +-------- Bart Oldeman (bart.oldeman@bristol.ac.uk) ++ Fixes * Use turboc.cfg to avoid long command lines; edit ALLCFLAGS + in config.mak to enable DEBUG etc. + * Fixed critical error handler. + * Fixed loading .exe's in UMBs if not enough space available. + * Some device drivers require \r\n at the end of their + parameter line. +2001 Apr 16 - Build 2023 -------- Bart Oldeman (bart.oldeman@bristol.ac.uk) + Fixes * Thanks to Martin Stromberg for pointing some bugs out: * more warnings fixed. diff --git a/hdr/version.h b/hdr/version.h index c8d7865e..89be5fab 100644 --- a/hdr/version.h +++ b/hdr/version.h @@ -42,5 +42,5 @@ static BYTE *date_hRcsId = "$Id$"; #define REVISION_MAJOR 1 #define REVISION_MINOR 1 -#define REVISION_SEQ 23 -#define BUILD 2023 +#define REVISION_SEQ 24 +#define BUILD 2024 diff --git a/kernel/config.c b/kernel/config.c index 0044fe8e..c6dfd83f 100644 --- a/kernel/config.c +++ b/kernel/config.c @@ -40,6 +40,9 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.19 2001/04/16 14:28:32 bartoldeman + * Kernel build 2024. Fixed critical error handler/config.sys/makefiles/UMBs + * * Revision 1.18 2001/04/16 01:45:26 bartoldeman * Fixed handles, config.sys drivers, warnings. Enabled INT21/AH=6C, printf %S/%Fs * @@ -1017,7 +1020,6 @@ INIT void Device(BYTE * pLine) INIT BOOL LoadDevice(BYTE * pLine, COUNT top, COUNT mode) { - BYTE *pTmp; exec_blk eb; struct dhdr FAR *dhp; struct dhdr FAR *next_dhp; @@ -1052,25 +1054,29 @@ INIT BOOL LoadDevice(BYTE * pLine, COUNT top, COUNT mode) so simply add TESTMEM:OFF to the commandline */ - pTmp = pLine; if (DosLoadedInHMA) if (stristr(szBuf, "HIMEM.SYS") != NULL) { if (stristr(pLine, "/TESTMEM:OFF") == NULL) { - pTmp = szBuf; - strcpy(pTmp, pLine); - strcat(pTmp, " /TESTMEM:OFF\r\n"); + strcpy(szBuf+2, pLine); + pLine=szBuf+2; + strcat(pLine, " /TESTMEM:OFF"); } } /* end of HIMEM.SYS HACK */ + /* add \r\n to the command line */ + pLine-=2; + strcpy(pLine, pLine+2); + strcat(pLine, "\r\n"); + /* TE this fixes the loading of devices drivers with multiple devices in it. NUMEGA's SoftIce is such a beast */ for (next_dhp=NULL; FP_OFF(next_dhp) != 0xffff && - (result=init_device(dhp, pTmp, mode, top))==SUCCESS + (result=init_device(dhp, pLine, mode, top))==SUCCESS ; dhp = next_dhp) { diff --git a/kernel/entry.asm b/kernel/entry.asm index b4b0fdb1..ac1343e5 100644 --- a/kernel/entry.asm +++ b/kernel/entry.asm @@ -28,6 +28,9 @@ ; $Id$ ; ; $Log$ +; Revision 1.12 2001/04/16 14:28:32 bartoldeman +; Kernel build 2024. Fixed critical error handler/config.sys/makefiles/UMBs +; ; Revision 1.11 2001/04/15 02:26:23 bartoldeman ; Hans Lermen: critical error handler destroyed AH (entry.asm). ; @@ -270,6 +273,7 @@ reloc_call_int21_handler: ; NB: At this point, SS != DS and won't be set that way ; until later when which stack to run on is determined. ; +int21_reentry_crit: mov dx,DGROUP mov ds,dx @@ -681,11 +685,10 @@ CritErrAbort: cli mov bp,word [_user_r+2] ;Get frame mov ss,bp - mov es,bp mov bp,word [_user_r] mov sp,bp mov byte [_ErrorMode],1 ; flag abort mov ax,4C00h - mov [es:reg_ax],ax + mov [bp+reg_ax],ax sti - jmp int21_reentry ; restart the system call + jmp int21_reentry_crit ; restart the system call diff --git a/kernel/kernel.mak b/kernel/kernel.mak index f813bd20..710a81cb 100644 --- a/kernel/kernel.mak +++ b/kernel/kernel.mak @@ -5,6 +5,9 @@ # # $Log$ +# Revision 1.9 2001/04/16 14:28:32 bartoldeman +# Kernel build 2024. Fixed critical error handler/config.sys/makefiles/UMBs +# # Revision 1.8 2001/04/15 03:21:50 bartoldeman # See history.txt for the list of fixes. # @@ -131,12 +134,8 @@ INCLUDEPATH = ..\HDR #AFLAGS = /Mx /DSTANDALONE=1 /I..\HDR NASMFLAGS = -i../hdr/ LIBS =..\LIB\DEVICE.LIB ..\LIB\LIBM.LIB -#ALLCFLAGS = -1- -O -Z -d -I..\hdr -I. \ -# -D__STDC__=0;DEBUG;KERNEL;I86;PROTO;ASMSUPT -ALLCFLAGS = -1- -O -Z -d -I..\hdr -I. \ - -D__STDC__=0;I86;ASMSUPT -w -g1 INITCFLAGS =$(ALLCFLAGS) -zAINIT -zCINIT_TEXT -zPIGROUP -zDIB -zRID -zTID -CFLAGS =$(ALLCFLAGS) -zAHMA -zCHMA_TEXT +CFLAGS =$(ALLCFLAGS) -zAHMA -zCHMA_TEXT HDR=../hdr/ # *Implicit Rules* @@ -273,7 +272,7 @@ config.obj: config.c init-mod.h $(HDR)portab.h globals.h \ $(HDR)fat.h $(HDR)fcb.h $(HDR)tail.h $(HDR)process.h $(HDR)dcb.h \ $(HDR)sft.h $(HDR)cds.h $(HDR)exe.h $(HDR)fnode.h \ $(HDR)dirmatch.h $(HDR)file.h $(HDR)clock.h $(HDR)kbd.h \ - $(HDR)error.h $(HDR)version.h proto.h + $(HDR)error.h $(HDR)version.h proto.h turboc.cfg $(CC) $(INITCFLAGS) -c config.c initoem.obj: initoem.c init-mod.h $(HDR)portab.h globals.h \ @@ -281,7 +280,7 @@ initoem.obj: initoem.c init-mod.h $(HDR)portab.h globals.h \ $(HDR)fat.h $(HDR)fcb.h $(HDR)tail.h $(HDR)process.h $(HDR)dcb.h \ $(HDR)sft.h $(HDR)cds.h $(HDR)exe.h $(HDR)fnode.h \ $(HDR)dirmatch.h $(HDR)file.h $(HDR)clock.h $(HDR)kbd.h \ - $(HDR)error.h $(HDR)version.h proto.h + $(HDR)error.h $(HDR)version.h proto.h turboc.cfg $(CC) $(INITCFLAGS) -c initoem.c main.obj: main.c init-mod.h $(HDR)portab.h globals.h $(HDR)device.h \ @@ -289,7 +288,7 @@ main.obj: main.c init-mod.h $(HDR)portab.h globals.h $(HDR)device.h \ $(HDR)fcb.h $(HDR)tail.h $(HDR)process.h $(HDR)dcb.h $(HDR)sft.h \ $(HDR)cds.h $(HDR)exe.h $(HDR)fnode.h $(HDR)dirmatch.h \ $(HDR)file.h $(HDR)clock.h $(HDR)kbd.h $(HDR)error.h \ - $(HDR)version.h proto.h + $(HDR)version.h proto.h turboc.cfg $(CC) $(INITCFLAGS) -c main.c initHMA.obj: initHMA.c init-mod.h $(HDR)portab.h globals.h $(HDR)device.h \ @@ -297,7 +296,7 @@ initHMA.obj: initHMA.c init-mod.h $(HDR)portab.h globals.h $(HDR)device.h \ $(HDR)fcb.h $(HDR)tail.h $(HDR)process.h $(HDR)dcb.h $(HDR)sft.h \ $(HDR)cds.h $(HDR)exe.h $(HDR)fnode.h $(HDR)dirmatch.h \ $(HDR)file.h $(HDR)clock.h $(HDR)kbd.h $(HDR)error.h \ - $(HDR)version.h proto.h + $(HDR)version.h proto.h turboc.cfg $(CC) $(INITCFLAGS) -c initHMA.c # XXX: I generated these using `gcc -MM' and `sed', so they may not be @@ -307,155 +306,160 @@ blockio.obj: blockio.c $(HDR)portab.h globals.h $(HDR)device.h \ $(HDR)fcb.h $(HDR)tail.h $(HDR)process.h $(HDR)dcb.h $(HDR)sft.h \ $(HDR)cds.h $(HDR)exe.h $(HDR)fnode.h $(HDR)dirmatch.h \ $(HDR)file.h $(HDR)clock.h $(HDR)kbd.h $(HDR)error.h \ - $(HDR)version.h proto.h + $(HDR)version.h proto.h turboc.cfg break.obj: break.c $(HDR)portab.h globals.h $(HDR)device.h \ $(HDR)mcb.h $(HDR)pcb.h $(HDR)date.h $(HDR)time.h $(HDR)fat.h \ $(HDR)fcb.h $(HDR)tail.h $(HDR)process.h $(HDR)dcb.h $(HDR)sft.h \ $(HDR)cds.h $(HDR)exe.h $(HDR)fnode.h $(HDR)dirmatch.h \ $(HDR)file.h $(HDR)clock.h $(HDR)kbd.h $(HDR)error.h \ - $(HDR)version.h proto.h + $(HDR)version.h proto.h turboc.cfg chario.obj: chario.c $(HDR)portab.h globals.h $(HDR)device.h \ $(HDR)mcb.h $(HDR)pcb.h $(HDR)date.h $(HDR)time.h $(HDR)fat.h \ $(HDR)fcb.h $(HDR)tail.h $(HDR)process.h $(HDR)dcb.h $(HDR)sft.h \ $(HDR)cds.h $(HDR)exe.h $(HDR)fnode.h $(HDR)dirmatch.h \ $(HDR)file.h $(HDR)clock.h $(HDR)kbd.h $(HDR)error.h \ - $(HDR)version.h proto.h + $(HDR)version.h proto.h turboc.cfg dosfns.obj: dosfns.c $(HDR)portab.h globals.h $(HDR)device.h \ $(HDR)mcb.h $(HDR)pcb.h $(HDR)date.h $(HDR)time.h $(HDR)fat.h \ $(HDR)fcb.h $(HDR)tail.h $(HDR)process.h $(HDR)dcb.h $(HDR)sft.h \ $(HDR)cds.h $(HDR)exe.h $(HDR)fnode.h $(HDR)dirmatch.h \ $(HDR)file.h $(HDR)clock.h $(HDR)kbd.h $(HDR)error.h \ - $(HDR)version.h proto.h + $(HDR)version.h proto.h turboc.cfg dosnames.obj: dosnames.c $(HDR)portab.h globals.h $(HDR)device.h \ $(HDR)mcb.h $(HDR)pcb.h $(HDR)date.h $(HDR)time.h $(HDR)fat.h \ $(HDR)fcb.h $(HDR)tail.h $(HDR)process.h $(HDR)dcb.h $(HDR)sft.h \ $(HDR)cds.h $(HDR)exe.h $(HDR)fnode.h $(HDR)dirmatch.h \ $(HDR)file.h $(HDR)clock.h $(HDR)kbd.h $(HDR)error.h \ - $(HDR)version.h proto.h + $(HDR)version.h proto.h turboc.cfg dsk.obj: dsk.c $(HDR)portab.h globals.h $(HDR)device.h $(HDR)mcb.h \ $(HDR)pcb.h $(HDR)date.h $(HDR)time.h $(HDR)fat.h $(HDR)fcb.h \ $(HDR)tail.h $(HDR)process.h $(HDR)dcb.h $(HDR)sft.h $(HDR)cds.h \ $(HDR)exe.h $(HDR)fnode.h $(HDR)dirmatch.h $(HDR)file.h \ - $(HDR)clock.h $(HDR)kbd.h $(HDR)error.h $(HDR)version.h proto.h + $(HDR)clock.h $(HDR)kbd.h $(HDR)error.h $(HDR)version.h proto.h \ + turboc.cfg error.obj: error.c $(HDR)portab.h globals.h $(HDR)device.h \ $(HDR)mcb.h $(HDR)pcb.h $(HDR)date.h $(HDR)time.h $(HDR)fat.h \ $(HDR)fcb.h $(HDR)tail.h $(HDR)process.h $(HDR)dcb.h $(HDR)sft.h \ $(HDR)cds.h $(HDR)exe.h $(HDR)fnode.h $(HDR)dirmatch.h \ $(HDR)file.h $(HDR)clock.h $(HDR)kbd.h $(HDR)error.h \ - $(HDR)version.h proto.h + $(HDR)version.h proto.h turboc.cfg fatdir.obj: fatdir.c $(HDR)portab.h globals.h $(HDR)device.h \ $(HDR)mcb.h $(HDR)pcb.h $(HDR)date.h $(HDR)time.h $(HDR)fat.h \ $(HDR)fcb.h $(HDR)tail.h $(HDR)process.h $(HDR)dcb.h $(HDR)sft.h \ $(HDR)cds.h $(HDR)exe.h $(HDR)fnode.h $(HDR)dirmatch.h \ $(HDR)file.h $(HDR)clock.h $(HDR)kbd.h $(HDR)error.h \ - $(HDR)version.h proto.h + $(HDR)version.h proto.h turboc.cfg fatfs.obj: fatfs.c $(HDR)portab.h globals.h $(HDR)device.h \ $(HDR)mcb.h $(HDR)pcb.h $(HDR)date.h $(HDR)time.h $(HDR)fat.h \ $(HDR)fcb.h $(HDR)tail.h $(HDR)process.h $(HDR)dcb.h $(HDR)sft.h \ $(HDR)cds.h $(HDR)exe.h $(HDR)fnode.h $(HDR)dirmatch.h \ $(HDR)file.h $(HDR)clock.h $(HDR)kbd.h $(HDR)error.h \ - $(HDR)version.h proto.h + $(HDR)version.h proto.h turboc.cfg fattab.obj: fattab.c $(HDR)portab.h globals.h $(HDR)device.h \ $(HDR)mcb.h $(HDR)pcb.h $(HDR)date.h $(HDR)time.h $(HDR)fat.h \ $(HDR)fcb.h $(HDR)tail.h $(HDR)process.h $(HDR)dcb.h $(HDR)sft.h \ $(HDR)cds.h $(HDR)exe.h $(HDR)fnode.h $(HDR)dirmatch.h \ $(HDR)file.h $(HDR)clock.h $(HDR)kbd.h $(HDR)error.h \ - $(HDR)version.h proto.h + $(HDR)version.h proto.h turboc.cfg fcbfns.obj: fcbfns.c $(HDR)portab.h globals.h $(HDR)device.h \ $(HDR)mcb.h $(HDR)pcb.h $(HDR)date.h $(HDR)time.h $(HDR)fat.h \ $(HDR)fcb.h $(HDR)tail.h $(HDR)process.h $(HDR)dcb.h $(HDR)sft.h \ $(HDR)cds.h $(HDR)exe.h $(HDR)fnode.h $(HDR)dirmatch.h \ $(HDR)file.h $(HDR)clock.h $(HDR)kbd.h $(HDR)error.h \ - $(HDR)version.h proto.h + $(HDR)version.h proto.h turboc.cfg inthndlr.obj: inthndlr.c $(HDR)portab.h globals.h $(HDR)device.h \ $(HDR)mcb.h $(HDR)pcb.h $(HDR)date.h $(HDR)time.h $(HDR)fat.h \ $(HDR)fcb.h $(HDR)tail.h $(HDR)process.h $(HDR)dcb.h $(HDR)sft.h \ $(HDR)cds.h $(HDR)exe.h $(HDR)fnode.h $(HDR)dirmatch.h \ $(HDR)file.h $(HDR)clock.h $(HDR)kbd.h $(HDR)error.h \ - $(HDR)version.h proto.h + $(HDR)version.h proto.h turboc.cfg ioctl.obj: ioctl.c $(HDR)portab.h globals.h $(HDR)device.h \ $(HDR)mcb.h $(HDR)pcb.h $(HDR)date.h $(HDR)time.h $(HDR)fat.h \ $(HDR)fcb.h $(HDR)tail.h $(HDR)process.h $(HDR)dcb.h $(HDR)sft.h \ $(HDR)cds.h $(HDR)exe.h $(HDR)fnode.h $(HDR)dirmatch.h \ $(HDR)file.h $(HDR)clock.h $(HDR)kbd.h $(HDR)error.h \ - $(HDR)version.h proto.h + $(HDR)version.h proto.h turboc.cfg memmgr.obj: memmgr.c $(HDR)portab.h globals.h $(HDR)device.h \ $(HDR)mcb.h $(HDR)pcb.h $(HDR)date.h $(HDR)time.h $(HDR)fat.h \ $(HDR)fcb.h $(HDR)tail.h $(HDR)process.h $(HDR)dcb.h $(HDR)sft.h \ $(HDR)cds.h $(HDR)exe.h $(HDR)fnode.h $(HDR)dirmatch.h \ $(HDR)file.h $(HDR)clock.h $(HDR)kbd.h $(HDR)error.h \ - $(HDR)version.h proto.h + $(HDR)version.h proto.h turboc.cfg misc.obj: misc.c $(HDR)portab.h globals.h $(HDR)device.h $(HDR)mcb.h \ $(HDR)pcb.h $(HDR)date.h $(HDR)time.h $(HDR)fat.h $(HDR)fcb.h \ $(HDR)tail.h $(HDR)process.h $(HDR)dcb.h $(HDR)sft.h $(HDR)cds.h \ $(HDR)exe.h $(HDR)fnode.h $(HDR)dirmatch.h $(HDR)file.h \ - $(HDR)clock.h $(HDR)kbd.h $(HDR)error.h $(HDR)version.h proto.h + $(HDR)clock.h $(HDR)kbd.h $(HDR)error.h $(HDR)version.h proto.h \ + turboc.cfg newstuff.obj: newstuff.c $(HDR)portab.h globals.h $(HDR)device.h \ $(HDR)mcb.h $(HDR)pcb.h $(HDR)date.h $(HDR)time.h $(HDR)fat.h \ $(HDR)fcb.h $(HDR)tail.h $(HDR)process.h $(HDR)dcb.h $(HDR)sft.h \ $(HDR)cds.h $(HDR)exe.h $(HDR)fnode.h $(HDR)dirmatch.h \ $(HDR)file.h $(HDR)clock.h $(HDR)kbd.h $(HDR)error.h \ - $(HDR)version.h proto.h + $(HDR)version.h proto.h turboc.cfg network.obj: network.c $(HDR)portab.h globals.h $(HDR)device.h \ $(HDR)mcb.h $(HDR)pcb.h $(HDR)date.h $(HDR)time.h $(HDR)fat.h \ $(HDR)fcb.h $(HDR)tail.h $(HDR)process.h $(HDR)dcb.h $(HDR)sft.h \ $(HDR)cds.h $(HDR)exe.h $(HDR)fnode.h $(HDR)dirmatch.h \ $(HDR)file.h $(HDR)clock.h $(HDR)kbd.h $(HDR)error.h \ - $(HDR)version.h proto.h + $(HDR)version.h proto.h turboc.cfg nls.obj: nls.c $(HDR)portab.h globals.h $(HDR)device.h $(HDR)mcb.h \ $(HDR)pcb.h $(HDR)date.h $(HDR)time.h $(HDR)fat.h $(HDR)fcb.h \ $(HDR)tail.h $(HDR)process.h $(HDR)dcb.h $(HDR)sft.h $(HDR)cds.h \ $(HDR)exe.h $(HDR)fnode.h $(HDR)dirmatch.h $(HDR)file.h \ - $(HDR)clock.h $(HDR)kbd.h $(HDR)error.h $(HDR)version.h proto.h + $(HDR)clock.h $(HDR)kbd.h $(HDR)error.h $(HDR)version.h proto.h \ + turboc.cfg # \ # 001-437.nls -prf.obj: prf.c $(HDR)portab.h +prf.obj: prf.c $(HDR)portab.h turboc.cfg -strings.obj: strings.c $(HDR)portab.h +strings.obj: strings.c $(HDR)portab.h turboc.cfg sysclk.obj: sysclk.c $(HDR)portab.h globals.h $(HDR)device.h \ $(HDR)mcb.h $(HDR)pcb.h $(HDR)date.h $(HDR)time.h $(HDR)fat.h \ $(HDR)fcb.h $(HDR)tail.h $(HDR)process.h $(HDR)dcb.h $(HDR)sft.h \ $(HDR)cds.h $(HDR)exe.h $(HDR)fnode.h $(HDR)dirmatch.h \ $(HDR)file.h $(HDR)clock.h $(HDR)kbd.h $(HDR)error.h \ - $(HDR)version.h proto.h + $(HDR)version.h proto.h turboc.cfg syspack.obj: syspack.c $(HDR)portab.h globals.h $(HDR)device.h \ $(HDR)mcb.h $(HDR)pcb.h $(HDR)date.h $(HDR)time.h $(HDR)fat.h \ $(HDR)fcb.h $(HDR)tail.h $(HDR)process.h $(HDR)dcb.h $(HDR)sft.h \ $(HDR)cds.h $(HDR)exe.h $(HDR)fnode.h $(HDR)dirmatch.h \ $(HDR)file.h $(HDR)clock.h $(HDR)kbd.h $(HDR)error.h \ - $(HDR)version.h proto.h + $(HDR)version.h proto.h turboc.cfg systime.obj: systime.c $(HDR)portab.h $(HDR)time.h $(HDR)date.h \ globals.h $(HDR)device.h $(HDR)mcb.h $(HDR)pcb.h $(HDR)fat.h \ $(HDR)fcb.h $(HDR)tail.h $(HDR)process.h $(HDR)dcb.h $(HDR)sft.h \ $(HDR)cds.h $(HDR)exe.h $(HDR)fnode.h $(HDR)dirmatch.h \ $(HDR)file.h $(HDR)clock.h $(HDR)kbd.h $(HDR)error.h \ - $(HDR)version.h proto.h + $(HDR)version.h proto.h turboc.cfg task.obj: task.c $(HDR)portab.h globals.h $(HDR)device.h $(HDR)mcb.h \ $(HDR)pcb.h $(HDR)date.h $(HDR)time.h $(HDR)fat.h $(HDR)fcb.h \ $(HDR)tail.h $(HDR)process.h $(HDR)dcb.h $(HDR)sft.h $(HDR)cds.h \ $(HDR)exe.h $(HDR)fnode.h $(HDR)dirmatch.h $(HDR)file.h \ - $(HDR)clock.h $(HDR)kbd.h $(HDR)error.h $(HDR)version.h proto.h + $(HDR)clock.h $(HDR)kbd.h $(HDR)error.h $(HDR)version.h proto.h \ + turboc.cfg + diff --git a/kernel/task.c b/kernel/task.c index c94d8675..8da0fb8e 100644 --- a/kernel/task.c +++ b/kernel/task.c @@ -35,6 +35,9 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.12 2001/04/16 14:28:32 bartoldeman + * Kernel build 2024. Fixed critical error handler/config.sys/makefiles/UMBs + * * Revision 1.11 2001/04/16 01:45:26 bartoldeman * Fixed handles, config.sys drivers, warnings. Enabled INT21/AH=6C, printf %S/%Fs * @@ -734,6 +737,18 @@ COUNT DosExeLoader(BYTE FAR * namep, exec_blk FAR * exp, COUNT mode) exe_size = (LONG) long2para(image_size) + header.exMinAlloc; /* + long2para((LONG) sizeof(psp)); ?? see above image_size += sizeof(psp) -- 1999/04/21 ska */ + if (exe_size > asize && (mem_access_mode & 0x80)) + { + /* First try low memory */ + mem_access_mode &= ~0x80; + rc = DosMemLargest((seg FAR *) & asize); + mem_access_mode |= 0x80; + if (rc != SUCCESS) + { + DosMemFree(env); + return rc; + } + } if (exe_size > asize) { DosMemFree(env); diff --git a/kernel/turboc.cfg b/kernel/turboc.cfg new file mode 100644 index 00000000..fa63626a --- /dev/null +++ b/kernel/turboc.cfg @@ -0,0 +1,15 @@ +-1- +-f- +-ff- +-O +-Z +-d +-k- +-vi- +-wpro +-weas +-wpre +-w +-g1 +-I..\hdr +-v- -I. -D__STDC__=0 -DKERNEL -DI86 -DPROTO -DASMSUPT From d6ebf8aa0cea2ba52e2ca45f7767c0d9f4bc0d6a Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Mon, 16 Apr 2001 14:36:56 +0000 Subject: [PATCH 073/671] Added ALLCFLAGS for compiler option configuration. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@202 6ac86273-5f31-0410-b378-82cca8765d1b --- config.m | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/config.m b/config.m index 363a6b4c..13f966fd 100644 --- a/config.m +++ b/config.m @@ -12,6 +12,9 @@ # Give path to nasm here (or if it's in your path just uncomment the line). #NASM=nasm +# Give extra Turbo C compiler flags here +#ALLCFLAGS=-DDEBUG + # Use these for Turbo C 2.01 #COMPILER=TC2 @@ -56,6 +59,9 @@ # $Id$ # # $Log$ +# Revision 1.7 2001/04/16 14:36:56 bartoldeman +# Added ALLCFLAGS for compiler option configuration. +# # Revision 1.6 2001/04/15 03:21:49 bartoldeman # See history.txt for the list of fixes. # From cb411f4dddbc9de7609868353ce9eb8af8916493 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Mon, 16 Apr 2001 14:44:29 +0000 Subject: [PATCH 074/671] Removed debug printf. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@203 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/config.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/kernel/config.c b/kernel/config.c index c6dfd83f..3230a234 100644 --- a/kernel/config.c +++ b/kernel/config.c @@ -40,6 +40,9 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.20 2001/04/16 14:44:29 bartoldeman + * Removed debug printf. + * * Revision 1.19 2001/04/16 14:28:32 bartoldeman * Kernel build 2024. Fixed critical error handler/config.sys/makefiles/UMBs * @@ -1079,8 +1082,6 @@ INIT BOOL LoadDevice(BYTE * pLine, COUNT top, COUNT mode) (result=init_device(dhp, pLine, mode, top))==SUCCESS ; dhp = next_dhp) { - - printf("result=%d\n", result); next_dhp = dhp->dh_next; if (FP_SEG(next_dhp) == 0xffff) /* Does this ever occur with FP_OFF(next_dhp) != 0xffff ??? */ From cb13571dab1375aa3d08a63630bae17b4d8ee205 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sat, 21 Apr 2001 22:32:53 +0000 Subject: [PATCH 075/671] Init DS=Init CS, fixed stack overflow problems and misc bugs. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@204 6ac86273-5f31-0410-b378-82cca8765d1b --- docs/history.txt | 25 +++++ hdr/buffer.h | 76 ++++++++++++++ hdr/file.h | 15 +++ hdr/version.h | 1 + kernel/blockio.c | 92 +++++++---------- kernel/chario.c | 18 +++- kernel/config.c | 159 ++++++++++++++++------------ kernel/dosfns.c | 34 +++--- kernel/entry.asm | 18 +++- kernel/execrh.asm | 7 +- kernel/fatfs.c | 10 +- kernel/fattab.c | 23 ++++- kernel/fcbfns.c | 12 +++ kernel/globals.h | 136 ++++-------------------- kernel/init-mod.h | 183 ++++++++++++++++++++++++++++++-- kernel/inithma.c | 29 ++++-- kernel/initoem.c | 7 +- kernel/inthndlr.c | 7 +- kernel/intr.asm | 93 ++++++++++++----- kernel/io.asm | 37 ++++--- kernel/kernel.asm | 157 ++++++++++++---------------- kernel/kernel.mak | 13 ++- kernel/main.c | 258 +++++++++++++++++++++++++--------------------- kernel/memmgr.c | 7 +- kernel/prf.c | 19 +++- kernel/proto.h | 71 ++----------- kernel/segs.inc | 18 +++- kernel/sysclk.c | 38 ++++++- kernel/task.c | 56 +++------- 29 files changed, 965 insertions(+), 654 deletions(-) create mode 100644 hdr/buffer.h diff --git a/docs/history.txt b/docs/history.txt index 50d9ec61..0fdb1e54 100644 --- a/docs/history.txt +++ b/docs/history.txt @@ -1,3 +1,28 @@ +2001 Apr 21 - Build 2024 +-------- Bart Oldeman (bart.oldeman@bristol.ac.uk) ++ Fixes Tom: + * fixed a missing close_dir in fatfs.c. + * many reductions of stack space requirements. + we hope this fixes some FAT corruption problems. + Bart: + * fixed "copy con" and INT21/AH=0B. The SFT_FEOF flag, + strangely enough, if true indicates NOT end-of-file. + Alan Kamrowski + * fixed intr: it wasn't putting the flags back correctly + and swapped si and bp. ++ Update Bart: + * Changed initialization data segment to its code segment. + This frees up a few more kb. + * This required some header reorganisation: + init-mod.h is for the init modules, globals.h for all the + others. + * Eliminated the master environment, as it is normally + managed by command.com, not by the kernel. This saves 512 + bytes and command.com now copies a default environment from + 0068:0000; this is in the DOS_PSP at 60:0. + * Moved low memory code segment to 70:0. ++ Add Tom: + * Default interrupt 6 handler (invalid opcode). 2001 Apr 16 - Build 2024 -------- Bart Oldeman (bart.oldeman@bristol.ac.uk) + Fixes * Use turboc.cfg to avoid long command lines; edit ALLCFLAGS diff --git a/hdr/buffer.h b/hdr/buffer.h new file mode 100644 index 00000000..b74e771b --- /dev/null +++ b/hdr/buffer.h @@ -0,0 +1,76 @@ +/****************************************************************/ +/* */ +/* buffer.h */ +/* */ +/* Sector buffer structure */ +/* */ +/* Copyright (c) 2001 */ +/* Pasquale J. Villani */ +/* All Rights Reserved */ +/* */ +/* This file is part of DOS-C. */ +/* */ +/* DOS-C is free software; you can redistribute it and/or */ +/* modify it under the terms of the GNU General Public License */ +/* as published by the Free Software Foundation; either version */ +/* 2, or (at your option) any later version. */ +/* */ +/* DOS-C is distributed in the hope that it will be useful, but */ +/* WITHOUT ANY WARRANTY; without even the implied warranty of */ +/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See */ +/* the GNU General Public License for more details. */ +/* */ +/* You should have received a copy of the GNU General Public */ +/* License along with DOS-C; see the file COPYING. If not, */ +/* write to the Free Software Foundation, 675 Mass Ave, */ +/* Cambridge, MA 02139, USA. */ +/****************************************************************/ + +#ifdef MAIN +#ifdef VERSION_STRINGS +static BYTE *buffer_hRcsId = "$Id$"; +#endif +#endif + +/* + * $Log$ + * Revision 1.1 2001/04/21 22:32:53 bartoldeman + * Init DS=Init CS, fixed stack overflow problems and misc bugs. + * + * Rev 1.0 20 Apr 2001 17:30:00 Bart Oldeman + * Initial revision. + */ + +#define BUFFERSIZE 512 +struct buffer +{ + struct buffer + FAR *b_next; /* form linked list for LRU */ + BYTE b_unit; /* disk for this buffer */ + BYTE b_flag; /* buffer flags */ + ULONG b_blkno; /* block for this buffer */ + /* DOS-C: 0xffff for huge block numbers */ + BYTE b_copies; /* number of copies to write */ + UBYTE b_offset_lo; /* span between copies (low) */ +#if 0 /*TE*/ + union + { + struct dpb FAR *_b_dpbp; /* pointer to DPB */ + LONG _b_huge_blkno; /* DOS-C: actual block number if >= 0xffff */ + } + _b; +#endif + UBYTE b_offset_hi; /* DOS-C: span between copies (high) */ + UBYTE b_unused; + BYTE b_buffer[BUFFERSIZE]; /* 512 byte sectors for now */ +}; + +#define b_dpbp _b._b_dpbp +#define b_huge_blkno _b._b_huge_blkno + +#define BFR_DIRTY 0x40 /* buffer modified */ +#define BFR_VALID 0x20 /* buffer contains valid data */ +#define BFR_DATA 0x08 /* buffer is from data area */ +#define BFR_DIR 0x04 /* buffer is from dir area */ +#define BFR_FAT 0x02 /* buffer is from fat area */ +#define BFR_BOOT 0x01 /* buffer is boot disk */ diff --git a/hdr/file.h b/hdr/file.h index 3326677e..439c0ec0 100644 --- a/hdr/file.h +++ b/hdr/file.h @@ -36,6 +36,9 @@ static BYTE *file_hRcsId = "$Id$"; /* * $Log$ + * Revision 1.4 2001/04/21 22:32:53 bartoldeman + * Init DS=Init CS, fixed stack overflow problems and misc bugs. + * * Revision 1.3 2000/05/25 20:56:19 jimtabor * Fixed project history * @@ -78,6 +81,18 @@ static BYTE *file_hRcsId = "$Id$"; * Initial revision. */ +/* 0 = CON, standard input, can be redirected */ +/* 1 = CON, standard output, can be redirected */ +/* 2 = CON, standard error */ +/* 3 = AUX, auxiliary */ +/* 4 = PRN, list device */ +/* 5 = 1st user file ... */ +#define STDIN 0 +#define STDOUT 1 +#define STDERR 2 +#define STDAUX 3 +#define STDPRN 4 + #define O_RDONLY SFT_MREAD #define O_WRONLY SFT_MWRITE #define O_RDWR SFT_MRDWR diff --git a/hdr/version.h b/hdr/version.h index 89be5fab..44de54fd 100644 --- a/hdr/version.h +++ b/hdr/version.h @@ -44,3 +44,4 @@ static BYTE *date_hRcsId = "$Id$"; #define REVISION_MINOR 1 #define REVISION_SEQ 24 #define BUILD 2024 +#define SUB_BUILD "a" diff --git a/kernel/blockio.c b/kernel/blockio.c index fc999432..455bce6c 100644 --- a/kernel/blockio.c +++ b/kernel/blockio.c @@ -37,6 +37,9 @@ static BYTE *blockioRcsId = "$Id$"; /* * $Log$ + * Revision 1.9 2001/04/21 22:32:53 bartoldeman + * Init DS=Init CS, fixed stack overflow problems and misc bugs. + * * Revision 1.8 2001/04/15 03:21:50 bartoldeman * See history.txt for the list of fixes. * @@ -232,14 +235,17 @@ VOID setblkno(struct buffer FAR * bp, ULONG blkno) /* this searches the buffer list for the given disk/block. - if found, the buffer is returned. + returns: + TRUE: + the buffer is found + FALSE: + the buffer is not found + *Buffp contains a block to flush and reuse later - if not found, NULL is returned, and *pReplacebp - contains a buffer to throw out. */ -struct buffer FAR *searchblock(ULONG blkno, COUNT dsk, - struct buffer FAR ** pReplacebp) +BOOL searchblock(ULONG blkno, COUNT dsk, + struct buffer FAR ** pBuffp) { int fat_count = 0; struct buffer FAR *bp; @@ -271,8 +277,8 @@ struct buffer FAR *searchblock(ULONG blkno, COUNT dsk, #ifdef DISPLAY_GETBLOCK printf("HIT %04x:%04x]\n", FP_SEG(bp), FP_OFF(bp)); #endif - - return (bp); + *pBuffp = bp; + return TRUE; } if (bp->b_flag & BFR_FAT) @@ -290,7 +296,8 @@ struct buffer FAR *searchblock(ULONG blkno, COUNT dsk, { lbp = lastNonFat; } - *pReplacebp = lbp; + + *pBuffp = lbp; #ifdef DISPLAY_GETBLOCK printf("MISS, replace %04x:%04x]\n", FP_SEG(lbp), FP_OFF(lbp)); @@ -306,7 +313,7 @@ struct buffer FAR *searchblock(ULONG blkno, COUNT dsk, firstbuf = lbp; } - return NULL; + return FALSE; } @@ -322,16 +329,13 @@ struct buffer FAR *searchblock(ULONG blkno, COUNT dsk, struct buffer FAR *getblock(ULONG blkno, COUNT dsk) { struct buffer FAR *bp; - struct buffer FAR *Replacebp; /* Search through buffers to see if the required block */ /* is already in a buffer */ - bp = searchblock(blkno, dsk, &Replacebp); - - if (bp) + if (searchblock(blkno, dsk, &bp)) { return (bp); } @@ -341,14 +345,22 @@ struct buffer FAR *getblock(ULONG blkno, COUNT dsk) /* take the buffer that lbp points to and flush it, then read new block. */ - if (flush1(Replacebp) && fill(Replacebp, blkno, dsk)) /* success */ - { - return Replacebp; - } - else - { - return NULL; - } + if (!flush1(bp)) + return NULL; + + /* Fill the indicated disk buffer with the current track and sector */ + + if (dskxfer(dsk, blkno, (VOID FAR *) bp->b_buffer, 1, DSKREAD)) + { + return NULL; + } + + bp->b_flag = BFR_VALID | BFR_DATA; + bp->b_unit = dsk; + setblkno(bp, blkno); + + return bp; + } /* @@ -365,14 +377,11 @@ struct buffer FAR *getblock(ULONG blkno, COUNT dsk) BOOL getbuf(struct buffer FAR ** pbp, ULONG blkno, COUNT dsk) { struct buffer FAR *bp; - struct buffer FAR *Replacebp; /* Search through buffers to see if the required block */ /* is already in a buffer */ - bp = searchblock(blkno, dsk, &Replacebp); - - if (bp) + if (searchblock(blkno, dsk, &bp)) { *pbp = bp; return TRUE; @@ -382,12 +391,12 @@ BOOL getbuf(struct buffer FAR ** pbp, ULONG blkno, COUNT dsk) /* available. */ /* take the buffer than lbp points to and flush it, then make it available. */ - if (flush1(Replacebp)) /* success */ + if (flush1(bp)) /* success */ { - Replacebp->b_flag = 0; - Replacebp->b_unit = dsk; - setblkno(Replacebp, blkno); - *pbp = Replacebp; + bp->b_flag = 0; + bp->b_unit = dsk; + setblkno(bp, blkno); + *pbp = bp; return TRUE; } else @@ -494,29 +503,6 @@ BOOL flush(void) return (ok); } -/* */ -/* Fill the indicated disk buffer with the current track and sector */ -/* */ -/* This function assumes that the buffer is ready for use and that the - sector is not already in the buffer ring */ -BOOL fill(REG struct buffer FAR * bp, ULONG blkno, COUNT dsk) -{ -/* Changed 9/4/00 BER */ - UWORD result; - - result = dskxfer(dsk, blkno, (VOID FAR *) bp->b_buffer, 1, DSKREAD); -/* End of change */ - bp->b_flag = BFR_VALID | BFR_DATA; - bp->b_unit = dsk; - setblkno(bp, blkno); - -/* Changed 9/4/00 BER */ - if(result==0) return(TRUE); /* Temporary code to convert the result to */ - else return(FALSE); /* the old BOOL result...BER */ - - /* return (result); This is what should eventually be returned */ -/* End of change */ -} /************************************************************************/ /* */ diff --git a/kernel/chario.c b/kernel/chario.c index 33cc6a0c..ea3ac5e6 100644 --- a/kernel/chario.c +++ b/kernel/chario.c @@ -36,6 +36,9 @@ static BYTE *charioRcsId = "$Id$"; /* * $Log$ + * Revision 1.7 2001/04/21 22:32:53 bartoldeman + * Init DS=Init CS, fixed stack overflow problems and misc bugs. + * * Revision 1.6 2001/04/16 01:45:26 bartoldeman * Fixed handles, config.sys drivers, warnings. Enabled INT21/AH=6C, printf %S/%Fs * @@ -295,19 +298,21 @@ static VOID kbfill(keyboard FAR * kp, UCOUNT c, BOOL ctlf, UWORD * vp) } } -VOID sti(keyboard FAR * kp) +/* return number of characters before EOF if there is one, else just the total */ +UCOUNT sti(keyboard FAR * kp) { REG UWORD c, cu_pos = scr_pos; UWORD virt_pos = scr_pos; WORD init_count = kp->kb_count; + BOOL eof = FALSE; #ifndef NOSPCL static BYTE local_buffer[LINESIZE]; #endif if (kp->kb_size == 0) - return; + return eof; if (kp->kb_size <= kp->kb_count || kp->kb_buf[kp->kb_count] != CR) kp->kb_count = 0; FOREVER @@ -391,7 +396,10 @@ VOID sti(keyboard FAR * kp) (BYTE FAR *) local_buffer, (COUNT) kp->kb_count); local_buffer[kp->kb_count] = '\0'; #endif - return; + if (eof) + return eof; + else + return kp->kb_count; case LF: sto(CR); @@ -405,8 +413,12 @@ VOID sti(keyboard FAR * kp) for (c = 0; c < cu_pos; c++) sto(' '); kp->kb_count = init_count; + eof = FALSE; break; + case CTL_Z: + eof = kp->kb_count; + /* fall through */ default: kbfill(kp, c, FALSE, &virt_pos); break; diff --git a/kernel/config.c b/kernel/config.c index 3230a234..f79e365a 100644 --- a/kernel/config.c +++ b/kernel/config.c @@ -27,12 +27,52 @@ /* Cambridge, MA 02139, USA. */ /****************************************************************/ -#define CONFIG +#include "portab.h" #include "init-mod.h" -#include "portab.h" -#include "globals.h" -#include "nls.h" +/* + These are the far variables from the DOS data segment that we need here. The + init procedure uses a different default DS data segment, which is discarded + after use. I hope to clean this up to use the DOS List of List and Swappable + Data Area obtained via INT21. + + -- Bart + */ +extern struct buffer FAR * FAR lastbuf;/* tail of ditto */ +extern struct f_node FAR * FAR f_nodes; /* pointer to the array */ +extern UWORD FAR f_nodes_cnt, /* number of allocated f_nodes */ + FAR first_mcb; /* Start of user memory */ + +extern UBYTE FAR lastdrive, FAR nblkdev, FAR mem_access_mode, + FAR uppermem_link; +extern struct dhdr + FAR blk_dev, /* Block device (Disk) driver */ + FAR nul_dev; +extern struct buffer FAR * FAR firstbuf; /* head of buffers linked list */ + +extern struct dpb FAR * FAR DPBp; +/* First drive Parameter Block */ +extern cdstbl FAR * FAR CDSp; +/* Current Directory Structure */ +extern sfttbl FAR * FAR sfthead; +/* System File Table head */ +extern sfttbl FAR * FAR FCBp; + +extern BYTE FAR VgaSet, + FAR _HMATextAvailable, /* first byte of available CODE area */ + FAR _HMATextStart[], /* first byte of HMAable CODE area */ + FAR _HMATextEnd[], + FAR break_ena, /* break enabled flag */ + FAR os_major, /* major version number */ + FAR os_minor, /* minor version number */ + FAR switchar, + FAR _InitTextStart, /* first available byte of ram */ + FAR ReturnAnyDosVersionExpected; + +extern UWORD FAR ram_top, /* How much ram in Kbytes */ + FAR UMB_top, + FAR umb_start, + FAR uppermem_root; #ifdef VERSION_STRINGS static BYTE *RcsId = "$Id$"; @@ -40,6 +80,9 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.21 2001/04/21 22:32:53 bartoldeman + * Init DS=Init CS, fixed stack overflow problems and misc bugs. + * * Revision 1.20 2001/04/16 14:44:29 bartoldeman * Removed debug printf. * @@ -178,28 +221,44 @@ static BYTE *RcsId = "$Id$"; * Added NLS, int2f and config.sys processing */ -#ifdef __TURBOC__ - void __int__(int); /* TC 2.01 requires this. :( -- ror4 */ - #define int3() __int__(3); -#endif - - #ifdef KDB #include #define KernelAlloc(x) adjust_far((void far *)malloc((unsigned long)(x))) #endif -BYTE FAR *lpBase = 0; -BYTE FAR *upBase = 0; -static BYTE FAR *lpOldLast = 0; -static COUNT nCfgLine = 0; -static COUNT nPass = 0; - COUNT UmbState = 0; -static BYTE szLine[256]={0}; -static BYTE szBuf[256]={0}; - -int singleStep = 0; +struct config Config + = + { + NUMBUFF, + NFILES, + NFCBS, + 0, + "command.com", + " /P\r\n", + NLAST, + NSTACKS, + 128 + /* COUNTRY= is initialized within DoConfig() */ + ,0 /* country ID */ + ,0 /* codepage */ + ,"" /* filename */ + ,0 /* amount required memory */ + ,0 /* pointer to loaded data */ + ,0 /* strategy for command.com is low by default */ + } +; + +BYTE FAR *lpBase; +BYTE FAR *upBase; +static BYTE FAR *lpOldLast; +static COUNT nCfgLine; +static COUNT nPass; + COUNT UmbState; +static BYTE szLine[256]; +static BYTE szBuf[256]; + +int singleStep; INIT VOID zumcb_init(mcb FAR * mcbp, UWORD size); INIT VOID mumcb_init(mcb FAR * mcbp, UWORD size); @@ -234,10 +293,6 @@ INIT COUNT strcasecmp(REG BYTE *d, REG BYTE *s); extern void HMAconfig(int finalize); VOID config_init_buffers(COUNT anzBuffers); /* from BLOCKIO.C */ -extern fmemcmp(BYTE far *s1, BYTE FAR *s2, unsigned len); - - - INIT static VOID FAR *AlignParagraph(VOID FAR * lpPtr); #ifndef I86 #define AlignParagraph(x) (x) @@ -287,7 +342,7 @@ INIT BYTE FAR *KernelAllocDma(WORD); BYTE *pLineStart; -BYTE HMATextIsAvailable = 0; +BYTE HMATextIsAvailable; void FAR * ConfigAlloc(COUNT bytes) { @@ -320,7 +375,10 @@ INIT void PreConfig(void) lpOldLast = lpBase = AlignParagraph((BYTE FAR *) & _InitTextStart); #ifdef DEBUG + { + extern BYTE FAR internal_data[]; printf("SDA located at 0x%p\n", internal_data); + } #endif /* Begin by initializing our system buffers */ /* the dms_scratch buffer is statically allocated @@ -447,7 +505,6 @@ INIT void PostConfig(void) #ifdef DEBUG - printf("f_node allocated at 0x%p\n",f_nodes); printf("FCB table allocated at 0x%p\n",FCBp); printf("sft table allocated at 0x%p\n",sfthead); @@ -532,12 +589,12 @@ INIT VOID DoConfig(VOID) /* Check to see if we have a config.sys file. If not, just */ /* exit since we don't force the user to have one. */ - if ((nFileDesc = init_DosOpen("fdconfig.sys", 0)) < 0) + if ((nFileDesc = open("fdconfig.sys", 0)) < 0) { #ifdef DEBUG printf("FDCONFIG.SYS not found\n"); #endif - if ((nFileDesc = init_DosOpen("config.sys", 0)) < 0) + if ((nFileDesc = open("config.sys", 0)) < 0) { #ifdef DEBUG printf("CONFIG.SYS not found\n"); @@ -578,7 +635,7 @@ INIT VOID DoConfig(VOID) /* Read a line from config */ /* Interrupt processing if read error or no bytes read */ - if ((nRetCode = init_DosRead(nFileDesc, pLine, LINESIZE - bytesLeft)) <= 0) + if ((nRetCode = read(nFileDesc, pLine, LINESIZE - bytesLeft)) <= 0) break; /* If the buffer was not filled completely, append a @@ -653,7 +710,7 @@ INIT VOID DoConfig(VOID) pLine += strlen(pLine) + 1; } } - init_DosClose(nFileDesc); + close(nFileDesc); } INIT struct table *LookUp(struct table *p, BYTE * token) @@ -671,14 +728,10 @@ INIT struct table *LookUp(struct table *p, BYTE * token) INIT BOOL SkipLine(char *pLine) { char kbdbuf[16]; - keyboard *kp = (keyboard *) kbdbuf; - char *pKbd = &kp->kb_buf[0]; - - kp->kb_size = 12; - kp->kb_count = 0; + char *pKbd = kbdbuf; printf("%s [Y,N]?", pLine); - sti(kp); + read(STDIN, kbdbuf, 12); pKbd = skipwh(pKbd); @@ -809,7 +862,7 @@ INIT static VOID Dosmem(BYTE * pLine) BYTE *pTmp; BYTE UMBwanted = FALSE, HMAwanted = FALSE; - extern BYTE INITDataSegmentClaimed; +/* extern BYTE FAR INITDataSegmentClaimed; */ pLine = GetStringArg(pLine, szBuf); @@ -822,7 +875,7 @@ INIT static VOID Dosmem(BYTE * pLine) { if (fmemcmp(pTmp, "UMB" ,3) == 0) { UMBwanted = TRUE; pTmp += 3; } if (fmemcmp(pTmp, "HIGH",4) == 0) { HMAwanted = TRUE; pTmp += 4; } - if (fmemcmp(pTmp, "CLAIMINIT",9) == 0) { INITDataSegmentClaimed = 0; pTmp += 9; } +/* if (fmemcmp(pTmp, "CLAIMINIT",9) == 0) { INITDataSegmentClaimed = 0; pTmp += 9; }*/ pTmp = skipwh(pTmp); if (*pTmp != ',') @@ -1046,40 +1099,18 @@ INIT BOOL LoadDevice(BYTE * pLine, COUNT top, COUNT mode) #endif - if (DosExec(3, &eb, szBuf) == SUCCESS) + if (init_DosExec(3, &eb, szBuf) == SUCCESS) { - /* that's a nice hack >:-) - - although we don't want HIMEM.SYS,(it's not free), other people - might load HIMEM.SYS to see if they are compatible to it. - - if it's HIMEM.SYS, we won't survive TESTMEM:ON - - so simply add TESTMEM:OFF to the commandline - */ + strcpy(szBuf, pLine); - if (DosLoadedInHMA) - if (stristr(szBuf, "HIMEM.SYS") != NULL) - { - if (stristr(pLine, "/TESTMEM:OFF") == NULL) - { - strcpy(szBuf+2, pLine); - pLine=szBuf+2; - strcat(pLine, " /TESTMEM:OFF"); - } - } - /* end of HIMEM.SYS HACK */ - /* add \r\n to the command line */ - pLine-=2; - strcpy(pLine, pLine+2); - strcat(pLine, "\r\n"); + strcat(szBuf, "\r\n"); /* TE this fixes the loading of devices drivers with multiple devices in it. NUMEGA's SoftIce is such a beast */ for (next_dhp=NULL; FP_OFF(next_dhp) != 0xffff && - (result=init_device(dhp, pLine, mode, top))==SUCCESS + (result=init_device(dhp, szBuf, mode, top))==SUCCESS ; dhp = next_dhp) { next_dhp = dhp->dh_next; diff --git a/kernel/dosfns.c b/kernel/dosfns.c index 3cc66b51..f32e838a 100644 --- a/kernel/dosfns.c +++ b/kernel/dosfns.c @@ -37,6 +37,9 @@ static BYTE *dosfnsRcsId = "$Id$"; * /// Added SHARE support. 2000/09/04 Ron Cemer * * $Log$ + * Revision 1.16 2001/04/21 22:32:53 bartoldeman + * Init DS=Init CS, fixed stack overflow problems and misc bugs. + * * Revision 1.15 2001/04/15 03:21:50 bartoldeman * See history.txt for the list of fixes. * @@ -354,10 +357,12 @@ UCOUNT GenericRead(COUNT hndl, UCOUNT n, BYTE FAR * bp, COUNT FAR * err, { kb_buf.kb_size = LINESIZE - 1; kb_buf.kb_count = 0; - sti((keyboard FAR *) & kb_buf); + ReadCount = sti((keyboard FAR *) & kb_buf); + if (ReadCount < kb_buf.kb_count) + s->sft_flags &= ~SFT_FEOF; fbcopy((BYTE FAR *) kb_buf.kb_buf, bp, kb_buf.kb_count); *err = SUCCESS; - return kb_buf.kb_count; + return ReadCount; } else { @@ -404,10 +409,12 @@ UCOUNT GenericRead(COUNT hndl, UCOUNT n, BYTE FAR * bp, COUNT FAR * err, return 0; } +#if 0 UCOUNT DosRead(COUNT hndl, UCOUNT n, BYTE FAR * bp, COUNT FAR * err) { return GenericRead(hndl, n, bp, err, FALSE); } +#endif UCOUNT DosWrite(COUNT hndl, UCOUNT n, BYTE FAR * bp, COUNT FAR * err) { @@ -451,7 +458,7 @@ UCOUNT DosWrite(COUNT hndl, UCOUNT n, BYTE FAR * bp, COUNT FAR * err) request rq; /* set to no EOF */ - s->sft_flags &= ~SFT_FEOF; + s->sft_flags |= SFT_FEOF; /* if null just report full transfer */ if (s->sft_flags & SFT_FNUL) @@ -1361,11 +1368,8 @@ COUNT DosGetFattr(BYTE FAR * name, UWORD FAR * attrp) or cleanup, such as converting "c:\a\b\.\c\.." to "C:\A\B". - Ron Cemer */ - BYTE tmp_name[128]; - int i; - for (i = 0; PriPathName[i] != '\0'; i++) tmp_name[i] = PriPathName[i]; - tmp_name[i] = '\0'; - return dos_getfattr(tmp_name, attrp); + memcpy(SecPathName,PriPathName,sizeof(SecPathName)); + return dos_getfattr(SecPathName, attrp); } } @@ -1402,21 +1406,21 @@ COUNT DosSetFattr(BYTE FAR * name, UWORD FAR * attrp) to get trashed somewhere in transit. - Ron Cemer */ - BYTE tmp_name[128]; - int i; - for (i = 0; PriPathName[i] != '\0'; i++) tmp_name[i] = PriPathName[i]; - tmp_name[i] = '\0'; - return dos_setfattr(name, attrp); - } + memcpy(SecPathName,PriPathName,sizeof(SecPathName)); + return dos_setfattr(SecPathName, attrp); + } } UBYTE DosSelectDrv(UBYTE drv) { struct cds FAR *cdsp = &CDSp->cds_table[drv]; - if ((drv < lastdrive) && (cdsp->cdsFlags & CDSVALID) && + if ((drv < lastdrive) && (cdsp->cdsFlags & CDSVALID)) +/* + && ((cdsp->cdsFlags & CDSNETWDRV) || (cdsp->cdsDpb!=NULL && media_check(cdsp->cdsDpb)==SUCCESS))) +*/ { current_ldt = cdsp; default_drive = drv; diff --git a/kernel/entry.asm b/kernel/entry.asm index ac1343e5..27d59047 100644 --- a/kernel/entry.asm +++ b/kernel/entry.asm @@ -28,6 +28,9 @@ ; $Id$ ; ; $Log$ +; Revision 1.13 2001/04/21 22:32:53 bartoldeman +; Init DS=Init CS, fixed stack overflow problems and misc bugs. +; ; Revision 1.12 2001/04/16 14:28:32 bartoldeman ; Kernel build 2024. Fixed critical error handler/config.sys/makefiles/UMBs ; @@ -191,6 +194,7 @@ cpm_error: mov al,0 ; NOTE: On exit, DS must point to kernel stack, SS:SP user stack after ; PUSH$ALL and BP == SP. ; +%if 0 ; this is dead code now _RestartSysCall: cli ; no interrupts mov bp,word [_lpUserStack+2] ;Get frame @@ -200,6 +204,7 @@ _RestartSysCall: sti POP$ALL ; get the original regs jmp short int21_reentry ; restart the system call +%endif ; @@ -235,6 +240,14 @@ zero_done: mov ax,04c7fh ; terminate with errorlevel 127 int 21h +invalid_opcode_message db 0dh,0ah,'Invalid Opcode',0dh,0ah,0 + + global reloc_call_int6_handler +reloc_call_int6_handler: + + mov si,invalid_opcode_message + jmp short zero_message_loop + ; ; Terminate the current process ; @@ -273,11 +286,10 @@ reloc_call_int21_handler: ; NB: At this point, SS != DS and won't be set that way ; until later when which stack to run on is determined. ; -int21_reentry_crit: +int21_reentry: mov dx,DGROUP mov ds,dx -int21_reentry: cmp ah,33h je int21_user cmp ah,50h @@ -691,4 +703,4 @@ CritErrAbort: mov ax,4C00h mov [bp+reg_ax],ax sti - jmp int21_reentry_crit ; restart the system call + jmp int21_reentry ; restart the system call diff --git a/kernel/execrh.asm b/kernel/execrh.asm index 7f7bd987..4754aef4 100644 --- a/kernel/execrh.asm +++ b/kernel/execrh.asm @@ -30,6 +30,9 @@ ; $Id$ ; ; $Log$ +; Revision 1.7 2001/04/21 22:32:53 bartoldeman +; Init DS=Init CS, fixed stack overflow problems and misc bugs. +; ; Revision 1.6 2001/04/15 03:21:50 bartoldeman ; See history.txt for the list of fixes. ; @@ -102,7 +105,7 @@ segment HMA_TEXT _execrh: push bp ; perform c entry mov bp,sp - push bx ; random char on display +; push bx ; random char on display push si push es ; sometimes it get lost push ds ; sp=bp-8 @@ -129,6 +132,6 @@ _execrh: pop ds pop es pop si - pop bx +; pop bx pop bp ret diff --git a/kernel/fatfs.c b/kernel/fatfs.c index 625e2bec..e3bb0921 100644 --- a/kernel/fatfs.c +++ b/kernel/fatfs.c @@ -36,6 +36,9 @@ BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.16 2001/04/21 22:32:53 bartoldeman + * Init DS=Init CS, fixed stack overflow problems and misc bugs. + * * Revision 1.15 2001/04/16 01:45:26 bartoldeman * Fixed handles, config.sys drivers, warnings. Enabled INT21/AH=6C, printf %S/%Fs * @@ -823,7 +826,10 @@ COUNT dos_rename(BYTE FAR * path1, BYTE FAR * path2) COUNT ret; if ((ret = extend_dir(fnp2)) != SUCCESS) + { + dir_close(fnp1); return ret; + } } if (!find_fname(fnp1, szPriFileName, szPriFileExt)) @@ -1411,7 +1417,6 @@ COUNT map_cluster(REG struct f_node FAR * fnp, COUNT mode) { ULONG idx; UWORD clssize; - UWORD secsize; #ifdef DISPLAY_GETBLOCK printf("map_cluster: current %lu, offset %lu, diff=%lu ", @@ -1419,8 +1424,7 @@ COUNT map_cluster(REG struct f_node FAR * fnp, COUNT mode) fnp->f_offset - fnp->f_cluster_offset); #endif /* The variable clssize will be used later. */ - secsize = fnp->f_dpb->dpb_secsize; - clssize = secsize * (fnp->f_dpb->dpb_clsmask + 1); + clssize = fnp->f_dpb->dpb_secsize * (fnp->f_dpb->dpb_clsmask + 1); /* If someone did a seek, but no writes have occured, we will */ /* need to initialize the fnode. */ diff --git a/kernel/fattab.c b/kernel/fattab.c index 2b7fe899..c688d180 100644 --- a/kernel/fattab.c +++ b/kernel/fattab.c @@ -35,6 +35,9 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.5 2001/04/21 22:32:53 bartoldeman + * Init DS=Init CS, fixed stack overflow problems and misc bugs. + * * Revision 1.4 2001/04/15 03:21:50 bartoldeman * See history.txt for the list of fixes. * @@ -280,7 +283,7 @@ UCOUNT link_fat12(struct dpb FAR *dpbp, UCOUNT Cluster1, UCOUNT Cluster2) /* Given the disk parameters, and a cluster number, this function looks at the FAT, and returns the next cluster in the clain. */ -UWORD next_cluster(struct dpb FAR *dpbp, REG UCOUNT ClusterNum) +UWORD next_cluster(struct dpb FAR *dpbp, UCOUNT ClusterNum) { if (ISFAT12(dpbp)) return next_cl12(dpbp, ClusterNum); @@ -290,11 +293,9 @@ UWORD next_cluster(struct dpb FAR *dpbp, REG UCOUNT ClusterNum) return LONG_LAST_CLUSTER; } -UWORD next_cl16(struct dpb FAR *dpbp, REG UCOUNT ClusterNum) +UWORD next_cl16(struct dpb FAR *dpbp, UCOUNT ClusterNum) { - UCOUNT idx; struct buffer FAR *bp; - UWORD RetCluster; /* Get the block that this cluster is in */ bp = getblock((ULONG) (((ULONG) ClusterNum) * SIZEOF_CLST16) / dpbp->dpb_secsize + dpbp->dpb_fatstrt, @@ -310,15 +311,29 @@ UWORD next_cl16(struct dpb FAR *dpbp, REG UCOUNT ClusterNum) bp->b_offset_lo = dpbp->dpb_fatsize; bp->b_offset_hi = dpbp->dpb_fatsize >> 8; + + +#ifndef I86 + UCOUNT idx; + UWORD RetCluster; + /* form an index so that we can read the block as a */ /* byte array */ idx = (ClusterNum * SIZEOF_CLST16) % dpbp->dpb_secsize; /* Get the cluster number, */ + fgetword((VOID FAR *) & (bp->b_buffer[idx]), (WORD FAR *) & RetCluster); /* and return successful. */ return RetCluster; +#else + /* this saves 2 WORDS of stack :-) */ + + return *(WORD FAR *)&(bp->b_buffer[(ClusterNum * SIZEOF_CLST16) % dpbp->dpb_secsize]); + +#endif + } UWORD next_cl12(struct dpb FAR *dpbp, REG UCOUNT ClusterNum) diff --git a/kernel/fcbfns.c b/kernel/fcbfns.c index 1b057004..be583e30 100644 --- a/kernel/fcbfns.c +++ b/kernel/fcbfns.c @@ -35,6 +35,9 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.10 2001/04/21 22:32:53 bartoldeman + * Init DS=Init CS, fixed stack overflow problems and misc bugs. + * * Revision 1.9 2001/04/15 03:21:50 bartoldeman * See history.txt for the list of fixes. * @@ -148,6 +151,10 @@ BOOL FcbCalcRec(); VOID MoveDirInfo(); #endif +#define TestCmnSeps(lpFileName) (strchr(":<|>+=,", *lpFileName) != NULL) +#define TestFieldSeps(lpFileName) (*(lpFileName) <= ' ' || strchr("/\"[]<>|.", *lpFileName) != NULL) + + static dmatch Dmatch; VOID FatGetDrvData(COUNT drive, COUNT FAR * spc, COUNT FAR * bps, @@ -265,6 +272,7 @@ BYTE FAR *ParseSkipWh(BYTE FAR * lpFileName) return lpFileName; } +#if 0 /* defined above */ BOOL TestCmnSeps(BYTE FAR * lpFileName) { BYTE *pszTest, @@ -275,7 +283,9 @@ BOOL TestCmnSeps(BYTE FAR * lpFileName) return TRUE; return FALSE; } +#endif +#if 0 BOOL TestFieldSeps(BYTE FAR * lpFileName) { BYTE *pszTest, @@ -290,6 +300,8 @@ BOOL TestFieldSeps(BYTE FAR * lpFileName) return TRUE; return FALSE; } +#endif + BYTE FAR *GetNameField(BYTE FAR * lpFileName, BYTE FAR * lpDestField, COUNT nFieldSize, BOOL * pbWildCard) diff --git a/kernel/globals.h b/kernel/globals.h index b6090106..15d900bf 100644 --- a/kernel/globals.h +++ b/kernel/globals.h @@ -36,6 +36,9 @@ static BYTE *Globals_hRcsId = "$Id$"; /* * $Log$ + * Revision 1.12 2001/04/21 22:32:53 bartoldeman + * Init DS=Init CS, fixed stack overflow problems and misc bugs. + * * Revision 1.11 2001/04/15 03:21:50 bartoldeman * See history.txt for the list of fixes. * @@ -199,6 +202,7 @@ static BYTE *Globals_hRcsId = "$Id$"; #include "version.h" #include "network.h" #include "config.h" +#include "buffer.h" /* JPP: for testing/debuging disk IO */ /*#define DISPLAY_GETBLOCK */ @@ -226,26 +230,8 @@ static BYTE *Globals_hRcsId = "$Id$"; /* Constants and macros */ /* */ /* Defaults and limits - System wide */ -#define PARSE_MAX 67 /* maximum # of bytes in path */ -#define NFILES 16 /* number of files in table */ -#define NFCBS 16 /* number of fcbs */ -#define NSTACKS 8 /* number of stacks */ -#define NLAST 6 /* last drive */ +#define PARSE_MAX MAX_CDSPATH /* maximum # of bytes in path */ #define NAMEMAX PARSE_MAX /* Maximum path for CDS */ -#define NUMBUFF 6 /* Number of track buffers */ - /* -- must be at least 3 */ - -/* 0 = CON, standard input, can be redirected */ -/* 1 = CON, standard output, can be redirected */ -/* 2 = CON, standard error */ -/* 3 = AUX, auxiliary */ -/* 4 = PRN, list device */ -/* 5 = 1st user file ... */ -#define STDIN 0 -#define STDOUT 1 -#define STDERR 2 -#define STDAUX 3 -#define STDPRN 4 /* internal error from failure or aborted operation */ #define ERROR -1 @@ -296,45 +282,7 @@ static BYTE *Globals_hRcsId = "$Id$"; #ifdef LINESIZE #undef LINESIZE #endif -#define LINESIZE 256 - -/* */ -/* Data structures and unions */ -/* */ -/* Sector buffer structure */ -#define BUFFERSIZE 512 -struct buffer -{ - struct buffer - FAR *b_next; /* form linked list for LRU */ - BYTE b_unit; /* disk for this buffer */ - BYTE b_flag; /* buffer flags */ - ULONG b_blkno; /* block for this buffer */ - /* DOS-C: 0xffff for huge block numbers */ - BYTE b_copies; /* number of copies to write */ - UBYTE b_offset_lo; /* span between copies (low) */ -#if 0 /*TE*/ - union - { - struct dpb FAR *_b_dpbp; /* pointer to DPB */ - LONG _b_huge_blkno; /* DOS-C: actual block number if >= 0xffff */ - } - _b; -#endif - UBYTE b_offset_hi; /* DOS-C: span between copies (high) */ - UBYTE b_unused; - BYTE b_buffer[BUFFERSIZE]; /* 512 byte sectors for now */ -}; - -#define b_dpbp _b._b_dpbp -#define b_huge_blkno _b._b_huge_blkno - -#define BFR_DIRTY 0x40 /* buffer modified */ -#define BFR_VALID 0x20 /* buffer contains valid data */ -#define BFR_DATA 0x08 /* buffer is from data area */ -#define BFR_DIR 0x04 /* buffer is from dir area */ -#define BFR_FAT 0x02 /* buffer is from fat area */ -#define BFR_BOOT 0x01 /* buffer is boot disk */ +#define LINESIZE KBD_MAXLENGTH /* NLS character table type */ typedef BYTE *UPMAP; @@ -381,9 +329,6 @@ extern struct ClockRecord /* */ /* Global variables */ /* */ -GLOBAL -seg master_env; /* Master environment segment */ - GLOBAL BYTE os_major, /* major version number */ os_minor, /* minor version number */ @@ -417,14 +362,17 @@ GLOBAL WORD bDumpRdWrParms #endif #endif -GLOBAL BYTE *copyright +GLOBAL BYTE copyright[] +#ifdef MAIN #if 0 -= "(C) Copyright 1995, 1996, 1997, 1998\nPasquale J. Villani\nAll Rights Reserved\n"; += "(C) Copyright 1995, 1996, 1997, 1998\nPasquale J. Villani\nAll Rights Reserved\n" #else - ; += "" +#endif #endif +; -GLOBAL BYTE *os_release +GLOBAL BYTE os_release[] #ifdef MAIN #if 0 = "DOS-C version %d.%d Beta %d [FreeDOS Release] (Build %d).\n\ @@ -435,13 +383,13 @@ Foundation; either version 2, or (at your option) any later version.\n\n\ For technical information and description of the DOS-C operating system\n\ consult \"FreeDOS Kernel\" by Pat Villani, published by Miller\n\ Freeman Publishing, Lawrence KS, USA (ISBN 0-87930-436-7).\n\ -\n"; +\n" #else -= "FreeDOS kernel version %d.%d.%d (Build %d) [" __DATE__ " " __TIME__ "]\n\n"; += "FreeDOS kernel version %d.%d.%d"SUB_BUILD + " (Build %d"SUB_BUILD") [" __DATE__ " " __TIME__ "]\n\n" #endif -#else - ; #endif +; /* Globally referenced variables - WARNING: ORDER IS DEFINED IN */ /* KERNAL.ASM AND MUST NOT BE CHANGED. DO NOT CHANGE ORDER BECAUSE THEY */ @@ -633,54 +581,6 @@ GLOBAL iregs FAR * ustackp, /* user stack */ FAR * kstackp; /* kernel stack */ -/* Start of configuration variables */ -extern struct config -{ - UBYTE cfgBuffers; /* number of buffers in the system */ - UBYTE cfgFiles; /* number of available files */ - UBYTE cfgFcbs; /* number of available FCBs */ - UBYTE cfgProtFcbs; /* number of protected FCBs */ - BYTE cfgInit[NAMEMAX]; /* init of command.com */ - BYTE cfgInitTail[NAMEMAX]; /* command.com's tail */ - UBYTE cfgLastdrive; /* last drive */ - BYTE cfgStacks; /* number of stacks */ - UWORD cfgStackSize; /* stacks size for each stack */ - /* COUNTRY= - In Pass #1 these information is collected and in PostConfig() - the NLS package is loaded into memory. - -- 2000/06/11 ska*/ - WORD cfgCSYS_cntry; /* country ID to be loaded */ - WORD cfgCSYS_cp; /* requested codepage; NLS_DEFAULT if default */ - BYTE cfgCSYS_fnam[NAMEMAX]; /* filename of COUNTRY= */ - WORD cfgCSYS_memory; /* number of bytes required for the NLS pkg; - 0 if none */ - VOID FAR *cfgCSYS_data; /* where the loaded data is for PostConfig() */ - UBYTE cfgP_0_startmode; /* load command.com high or not */ -} Config -#ifdef CONFIG -= -{ - NUMBUFF, - NFILES, - NFCBS, - 0, - "command.com", - " /P\r\n", - NLAST, - NSTACKS, - 128 - /* COUNTRY= is initialized within DoConfig() */ - ,0 /* country ID */ - ,0 /* codepage */ - ,"" /* filename */ - ,0 /* amount required memory */ - ,0 /* pointer to loaded data */ - ,0 /* strategy for command.com is low by default */ -}; -#else -; -#endif - /* */ /* Function prototypes - automatically generated */ /* */ @@ -784,3 +684,5 @@ void handle_break(void); /* break.c */ GLOBAL BYTE ReturnAnyDosVersionExpected; + +GLOBAL COUNT UnusedRetVal; /* put unused errors here (to save stack space) */ diff --git a/kernel/init-mod.h b/kernel/init-mod.h index cea37a07..36289c69 100644 --- a/kernel/init-mod.h +++ b/kernel/init-mod.h @@ -1,5 +1,30 @@ -/* Used by `proto.h'. */ +/* Included by initialisation functions */ #define IN_INIT_MOD + +#include "version.h" +#include "date.h" +#include "time.h" +#include "mcb.h" +#include "sft.h" +#include "fat.h" +#include "fnode.h" +#include "file.h" +#include "dcb.h" +#include "cds.h" +#include "device.h" +#include "kbd.h" +#include "error.h" +#include "fcb.h" +#include "tail.h" +#include "process.h" +#include "pcb.h" +#include "nls.h" +#include "buffer.h" + +#ifdef __TURBOC__ +void __int__(int); /* TC 2.01 requires this. :( -- ror4 */ +#endif + /* * The null macro `INIT' can be used to allow the reader to differentiate * between functions defined in `INIT_TEXT' and those defined in `_TEXT'. @@ -10,19 +35,155 @@ * calls for the latter functions therefore need to be wrapped up with far * entry points. */ -#define DosExec reloc_call_DosExec -#define DosMemAlloc reloc_call_DosMemAlloc +#define printf init_printf #define execrh reloc_call_execrh -#define fatal reloc_call_fatal #define fmemcpy reloc_call_fmemcpy -#define memcpy reloc_call_memcpy #define fmemset reloc_call_fmemset -#define printf reloc_call_printf +#define memset reloc_call_memset +#define fstrncpy reloc_call_fstrncpy #define strcpy reloc_call_strcpy -#define sti reloc_call_sti -#define strcmp reloc_call_strcmp #define strlen reloc_call_strlen -#define WritePCClock reloc_call_WritePCClock -#define DaysFromYearMonthDay reloc_call_DaysFromYearMonthDay -#define p_0 reloc_call_p_0 +WORD execrh(request FAR *, struct dhdr FAR *); +VOID fmemcpy(REG VOID FAR * d, REG VOID FAR * s, REG COUNT n); +void fmemset(REG VOID FAR * s, REG int ch, REG COUNT n); +void memset(REG VOID * s, REG int ch, REG COUNT n); +VOID strcpy(REG BYTE * d, REG BYTE * s); +VOID fstrncpy(REG BYTE FAR * d, REG BYTE FAR * s, REG COUNT n); +COUNT fstrlen(REG BYTE FAR * s); +COUNT strlen(REG BYTE * s); + +#undef LINESIZE +#define LINESIZE KBD_MAXLENGTH +#define fbcopy(s, d, n) fmemcpy(d,s,n) + +/*inithma.c*/ +extern BYTE DosLoadedInHMA; +extern fmemcmp(BYTE far *s1, BYTE FAR *s2, unsigned len); + +#define setvec(n, isr) (void)(*(VOID (INRPT FAR * FAR *)())(4 * (n)) = (isr)) + +#define fbcopy(s, d, n) fmemcpy(d,s,n) +#define GLOBAL extern +#define NAMEMAX MAX_CDSPATH /* Maximum path for CDS */ +#define PARSE_MAX MAX_CDSPATH /* maximum # of bytes in path */ +#define NFILES 16 /* number of files in table */ +#define NFCBS 16 /* number of fcbs */ +#define NSTACKS 8 /* number of stacks */ +#define NLAST 6 /* last drive */ +#define NUMBUFF 6 /* Number of track buffers */ + /* -- must be at least 3 */ + + +/* Start of configuration variables */ +struct config +{ + UBYTE cfgBuffers; + /* number of buffers in the system */ + UBYTE cfgFiles; + /* number of available files */ + UBYTE cfgFcbs; + /* number of available FCBs */ + UBYTE cfgProtFcbs; + /* number of protected FCBs */ + BYTE cfgInit[NAMEMAX]; + /* init of command.com */ + BYTE cfgInitTail[NAMEMAX]; + /* command.com's tail */ + UBYTE cfgLastdrive; + /* last drive */ + BYTE cfgStacks; + /* number of stacks */ + UWORD cfgStackSize; + /* stacks size for each stack */ + /* COUNTRY= + In Pass #1 these information is collected and in PostConfig() + the NLS package is loaded into memory. + -- 2000/06/11 ska*/ + WORD cfgCSYS_cntry; + /* country ID to be loaded */ + WORD cfgCSYS_cp; + /* requested codepage; NLS_DEFAULT if default */ + BYTE cfgCSYS_fnam[NAMEMAX]; + /* filename of COUNTRY= */ + WORD cfgCSYS_memory; + /* number of bytes required for the NLS pkg; + 0 if none */ + VOID FAR *cfgCSYS_data; + /* where the loaded data is for PostConfig() */ + UBYTE cfgP_0_startmode; + /* load command.com high or not */ +}; + +extern struct config Config; + +/* config.c */ +INIT VOID PreConfig(VOID); +INIT VOID DoConfig(VOID); +INIT VOID PostConfig(VOID); +INIT BYTE FAR *KernelAlloc(WORD nBytes); +INIT BYTE *skipwh(BYTE * s); +INIT BYTE *scan(BYTE * s, BYTE * d); +INIT BOOL isnum(BYTE * pszString); +INIT BYTE *GetNumber(REG BYTE * pszString, REG COUNT * pnNum); +INIT COUNT tolower(COUNT c); +INIT COUNT toupper(COUNT c); +INIT VOID mcb_init(mcb FAR * mcbp, UWORD size); +INIT VOID strcat(REG BYTE * d, REG BYTE * s); +INIT BYTE FAR *KernelAlloc(WORD nBytes); +INIT COUNT Umb_Test(void); +INIT BYTE *GetStringArg(BYTE * pLine, BYTE * pszString); + +/* int2f.asm */ +COUNT Umb_Test(void); + +/* inithma.c */ +int MoveKernelToHMA(void); +VOID FAR *HMAalloc(COUNT bytesToAllocate); + +/* initoem.c */ +UWORD init_oem(void); + +/* intr.asm */ +/* void init_call_intr(int nr, iregs *rp); */ +UCOUNT read(int fd, void *buf, UCOUNT count); +int open(const char *pathname, int flags); +int close(int fd); +int dup2(int oldfd, int newfd); +int allocmem(UWORD size, seg *segp); +INIT VOID init_PSPInit(seg psp_seg); +INIT COUNT init_DosExec(COUNT mode, exec_blk * ep, BYTE * lp); +INIT VOID keycheck(VOID); + +/* irqstack.asm */ +VOID init_stacks(VOID FAR * stack_base, COUNT nStacks, WORD stackSize); + +/* inthndlr.c */ +VOID far int21_entry(iregs UserRegs); +VOID int21_service(iregs far * r); +VOID INRPT FAR int0_handler(void); +VOID INRPT FAR int6_handler(void); +VOID INRPT FAR empty_handler(void); +VOID INRPT far got_cbreak(void); /* procsupt.asm */ +VOID INRPT far int20_handler(iregs UserRegs); +VOID INRPT far int21_handler(iregs UserRegs); +VOID INRPT FAR int22_handler(void); +VOID INRPT FAR int23_handler(int es, int ds, int di, int si, int bp, int sp, int bx, int dx, int cx, int ax, int ip, int cs + , int flags); +VOID INRPT FAR int24_handler(void); +VOID INRPT FAR low_int25_handler(void); +VOID INRPT FAR low_int26_handler(void); +VOID INRPT FAR int27_handler(int es, int ds, int di, int si, int bp, int sp, int bx, int dx, int cx, int ax, int ip, int cs + , int flags); +VOID INRPT FAR int28_handler(void); +VOID INRPT FAR int29_handler(int es, int ds, int di, int si, int bp, int sp, int bx, int dx, int cx, int ax, int ip, int cs + , int flags); +VOID INRPT FAR int2a_handler(void); +VOID INRPT FAR int2f_handler(void); + +/* main.c */ +INIT VOID main(void); +INIT BOOL init_device(struct dhdr FAR * dhp, BYTE FAR * cmdLine, COUNT mode, COUNT top); +INIT VOID init_fatal(BYTE * err_msg); +/* prf.c */ +WORD init_printf(CONST BYTE * fmt,...); diff --git a/kernel/inithma.c b/kernel/inithma.c index aa2d772a..effb6aa3 100644 --- a/kernel/inithma.c +++ b/kernel/inithma.c @@ -64,10 +64,15 @@ */ +#include "portab.h" #include "init-mod.h" -#include "portab.h" -#include "globals.h" +extern BYTE FAR version_flags; /* minor version number */ + +extern BYTE + FAR _HMATextAvailable, /* first byte of available CODE area */ + FAR _HMATextStart[], /* first byte of HMAable CODE area */ + FAR _HMATextEnd[]; /* and the last byte of it */ #ifdef VERSION_STRINGS static BYTE *RcsId = "$Id$"; @@ -75,6 +80,9 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.5 2001/04/21 22:32:53 bartoldeman + * Init DS=Init CS, fixed stack overflow problems and misc bugs. + * * Revision 1.4 2001/04/16 01:45:26 bartoldeman * Fixed handles, config.sys drivers, warnings. Enabled INT21/AH=6C, printf %S/%Fs * @@ -92,8 +100,8 @@ static BYTE *RcsId = "$Id$"; */ -BYTE DosLoadedInHMA; /* set to TRUE if loaded HIGH */ -BYTE HMAclaimed; /* set to TRUE if claimed from HIMEM */ +BYTE DosLoadedInHMA=FALSE; /* set to TRUE if loaded HIGH */ +BYTE HMAclaimed=FALSE; /* set to TRUE if claimed from HIMEM */ WORD HMAFree; /* first byte in HMA not yet used */ @@ -387,16 +395,15 @@ int MoveKernelToHMA() UWORD jmpSegment; }; extern struct initRelocationTable - FAR _HMAinitRelocationTableStart[], - FAR _HMAinitRelocationTableEnd[]; - struct initRelocationTable FAR *rp, FAR *endrp; + _HMAinitRelocationTableStart[], + _HMAinitRelocationTableEnd[]; + struct initRelocationTable *rp; /* verify, that all entries are valid */ UWORD HMATextSegment = FP_SEG( _HMATextStart ); - endrp = MK_FP(_CS, FP_OFF(_HMAinitRelocationTableEnd)); - for (rp = MK_FP(_CS, FP_OFF(_HMAinitRelocationTableStart)); rp < endrp; rp++) + for (rp = _HMAinitRelocationTableStart; rp < _HMAinitRelocationTableEnd; rp++) { if ( rp->callNear != 0xe8 || /* call NEAR */ @@ -405,14 +412,14 @@ int MoveKernelToHMA() 0) { printf("illegal init relocation entry # %d\n", - FP_OFF(rp) - FP_OFF(_HMAinitRelocationTableStart)); + rp - _HMAinitRelocationTableStart); goto errorReturn; } } /* OK, all valid, go to relocate*/ - for (rp = MK_FP(_CS, FP_OFF(_HMAinitRelocationTableStart)); rp < endrp; rp++) + for (rp = _HMAinitRelocationTableStart; rp < _HMAinitRelocationTableEnd; rp++) { rp->jmpSegment = HMASEGMENT; rp->callOffset = rp->callOffset-5; /* near calls are relative */ diff --git a/kernel/initoem.c b/kernel/initoem.c index c43529be..883adc63 100644 --- a/kernel/initoem.c +++ b/kernel/initoem.c @@ -27,10 +27,8 @@ /* */ /****************************************************************/ -#include "init-mod.h" - #include "portab.h" -#include "globals.h" +#include "init-mod.h" #ifdef VERSION_STRINGS static BYTE *RcsId = "$Id$"; @@ -38,6 +36,9 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.4 2001/04/21 22:32:53 bartoldeman + * Init DS=Init CS, fixed stack overflow problems and misc bugs. + * * Revision 1.3 2000/05/25 20:56:21 jimtabor * Fixed project history * diff --git a/kernel/inthndlr.c b/kernel/inthndlr.c index 0ad6227d..bd92f90e 100644 --- a/kernel/inthndlr.c +++ b/kernel/inthndlr.c @@ -37,6 +37,9 @@ BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.22 2001/04/21 22:32:53 bartoldeman + * Init DS=Init CS, fixed stack overflow problems and misc bugs. + * * Revision 1.21 2001/04/16 01:45:26 bartoldeman * Fixed handles, config.sys drivers, warnings. Enabled INT21/AH=6C, printf %S/%Fs * @@ -486,9 +489,9 @@ VOID int21_service(iregs FAR * r) /* Check Stdin Status */ case 0x0b: if (StdinBusy()) - r->AL = 0xFF; - else r->AL = 0x00; + else + r->AL = 0xFF; break; /* Flush Buffer, Read Keayboard */ diff --git a/kernel/intr.asm b/kernel/intr.asm index 649bd739..362d831e 100644 --- a/kernel/intr.asm +++ b/kernel/intr.asm @@ -51,9 +51,9 @@ intr?2 mov bx, [bp+6] ; regpack structure mov ax, [bx] mov cx, [bx+4] mov dx, [bx+6] - mov bp, [bx+8] + mov si, [bx+8] mov di, [bx+10] - mov si, [bx+12] + mov bp, [bx+12] push Word [bx+14] ; ds mov es, [bx+16] mov bx, [bx+2] @@ -73,14 +73,14 @@ intr?1: mov [bx+2], ax mov [bx+4], cx mov [bx+6], dx - mov [bx+8], bp + mov [bx+8], si mov [bx+10], di - mov [bx+12], si + mov [bx+12], bp pop ax mov [bx+14], ax mov [bx+16], es pop ax - mov [bx+18], ax + mov [bx+22], ax pop es pop ds @@ -120,9 +120,9 @@ init_intr?2 mov bx, [bp+6] ; regpack structure mov ax, [bx] mov cx, [bx+4] mov dx, [bx+6] - mov bp, [bx+8] + mov si, [bx+8] mov di, [bx+10] - mov si, [bx+12] + mov bp, [bx+12] push Word [bx+14] ; ds mov es, [bx+16] mov bx, [bx+2] @@ -142,14 +142,14 @@ init_intr?1: mov [bx+2], ax mov [bx+4], cx mov [bx+6], dx - mov [bx+8], bp + mov [bx+8], si mov [bx+10], di - mov [bx+12], si + mov [bx+12], bp pop ax mov [bx+14], ax mov [bx+16], es pop ax - mov [bx+18], ax + mov [bx+22], ax pop es pop ds @@ -207,9 +207,9 @@ _keycheck: int 16h ret -;; COUNT init_DosOpen(BYTE *fname, COUNT mode) - global _init_DosOpen -_init_DosOpen: +;; int open(const char *pathname, int flags); + global _open +_open: ;; first implementation of init calling DOS through ints: mov bx, sp mov ah, 3dh @@ -217,34 +217,45 @@ _init_DosOpen: mov al, [bx+4] mov dx, [bx+2] int 21h -common_exit: - jnc open_no_error ;; AX has file handle - neg ax - ;; negative value for error code -open_no_error: + +common_exit: + jnc common_no_error +common_error: + mov ax, -1 +common_no_error: ret -;; COUNT init_DosClose(COUNT hndl) - global _init_DosClose -_init_DosClose: +;; int close(int fd); + global _close +_close: mov bx, sp mov bx, [bx+2] mov ah, 3eh int 21h - jmp common_exit + jmp short common_exit -;; COUNT init_DosRead(COUNT hndl, BYTE *bp, UCOUNT n) - global _init_DosRead -_init_DosRead: +;; UCOUNT read(int fd, void *buf, UCOUNT count); + global _read +_read: mov bx, sp mov cx, [bx+6] mov dx, [bx+4] mov bx, [bx+2] mov ah, 3fh int 21h - jmp common_exit + jmp short common_exit +;; int dup2(int oldfd, int newfd); + global _dup2 +_dup2: + mov bx, sp + mov cx, [bx+4] + mov bx, [bx+2] + mov ah, 46h + int 21h + jmp short common_exit + ;; VOID init_PSPInit(seg psp_seg) global _init_PSPInit _init_PSPInit: @@ -256,4 +267,34 @@ _init_PSPInit: int 21h pop si ret + +;; COUNT init_DosExec(COUNT mode, exec_blk * ep, BYTE * lp) + global _init_DosExec +_init_DosExec: + mov ah, 4bh + mov bx, sp + mov al, [bx+2] + push ds + pop es + mov dx, [bx+6] ; filename + mov bx, [bx+4] ; exec block + int 21h + jc short exec_no_error + xor ax, ax +exec_no_error + ret + +;; int allocmem(UWORD size, seg *segp) + global _allocmem +_allocmem: + mov ah, 48h + mov bx, sp + mov bx, [bx+2] + int 21h + jc short common_error + mov bx, sp + mov bx, [bx+4] + mov [bx], ax + xor ax, ax + ret \ No newline at end of file diff --git a/kernel/io.asm b/kernel/io.asm index abbf43f8..41bee9b4 100644 --- a/kernel/io.asm +++ b/kernel/io.asm @@ -28,6 +28,9 @@ ; $Header$ ; ; $Log$ +; Revision 1.8 2001/04/21 22:32:53 bartoldeman +; Init DS=Init CS, fixed stack overflow problems and misc bugs. +; ; Revision 1.7 2001/03/21 02:56:26 bartoldeman ; See history.txt for changes. Bug fixes and HMA support are the main ones. ; @@ -191,7 +194,7 @@ _Com4Dev dw _clk_dev,TGROUP global _clk_dev _clk_dev equ $ dw _blk_dev,TGROUP - dw 8004h ; clock device + dw 8008h ; clock device dw GenStrategy dw clk_entry db 'CLOCK$ ' @@ -540,13 +543,8 @@ blk_entry: pushf push ax push bx - push cx - push dx - push bp - push si - push di push ds - push es + ; small model mov ax,DGROUP ; correct for segments @@ -560,24 +558,39 @@ blk_entry: mov sp,blk_stk_top push bx popf ; restore interrupt flag - mov bp,sp ; make a c frame + + + push cx ; push these registers on + push dx ; BLK_STACK + push bp ; to save stack space + push si + push di + push es + + push word [cs:_ReqPktPtr+2] push word [cs:_ReqPktPtr] call far _reloc_call_blk_driver pop cx pop cx + les bx,[cs:_ReqPktPtr] ; now return completion code mov word [es:bx+status],ax ; mark operation complete - cli ; no interrupts - mov sp,[blk_dos_stk] ; use dos stack - mov ss,[blk_dos_seg] + + pop es - pop ds pop di pop si pop bp pop dx pop cx + + cli ; no interrupts + mov sp,[blk_dos_stk] ; use dos stack + mov ss,[blk_dos_seg] + + + pop ds pop bx pop ax popf diff --git a/kernel/kernel.asm b/kernel/kernel.asm index 4736eac2..b0fc3b77 100644 --- a/kernel/kernel.asm +++ b/kernel/kernel.asm @@ -28,6 +28,9 @@ ; $Id$ ; ; $Log$ +; Revision 1.10 2001/04/21 22:32:53 bartoldeman +; Init DS=Init CS, fixed stack overflow problems and misc bugs. +; ; Revision 1.9 2001/04/15 03:21:50 bartoldeman ; See history.txt for the list of fixes. ; @@ -126,7 +129,7 @@ %include "segs.inc" -segment _TEXT +segment PSP extern _ReqPktPtr:wrt TGROUP @@ -145,7 +148,7 @@ segment INIT_TEXT ; kernel start-up ; kernel_start: - mov ax,DGROUP + mov ax,IGROUP cli mov ss,ax mov sp,init_tos @@ -170,6 +173,8 @@ kernel_start: push ax retf cont: ; inititalize api stacks for high water tests + mov ax,cs + mov ss,ax mov di,seg apistk_bottom mov es,di mov di,apistk_bottom @@ -181,7 +186,7 @@ cont: ; inititalize api stacks for high water tests cld rep stosw ; Now set up call frame - mov ax,ss + mov ax,DGROUP mov ds,ax mov es,ax mov bp,sp ; and set up stack frame for c @@ -196,12 +201,12 @@ floppy: mov byte [_BootDrive],bl ; tell where we came from inc al mov byte [_NumFloppies],al ; and how many - mov ax,ds + mov ax,cs + mov ds,ax mov es,ax jmp _main segment INIT_TEXT_END -init_end: segment _TEXT @@ -271,7 +276,7 @@ _clock dd 0 ; 0008 CLOCK$ device global _syscon _syscon dd 0 ; 000c console device global _maxbksize -_maxbksize dw 0 ; 0010 Number of Drives in system +_maxbksize dw 512 ; 0010 maximum bytes/sector of any block device global _firstbuf; _firstbuf dd 0 ; 0012 head of buffers linked list global _CDSp @@ -286,7 +291,9 @@ _nblkdev db 0 ; 0020 number of block devices _lastdrive db 0 ; 0021 value of last drive global _nul_dev _nul_dev: ; 0022 device chain root - dd -1 + extern _con_dev:wrt TGROUP + dw _con_dev, seg _con_dev + ; next is con_dev at init time. dw 8004h ; attributes = char device, NUL bit set dw _nul_strtgy dw _nul_intr @@ -300,7 +307,7 @@ setverPtr dw 0,0 ; 0037 setver list dw 1 ; 003F number of buffers dw 1 ; 0041 size of pre-read buffer global _BootDrive -_BootDrive db 0 ; 0043 drive we booted from +_BootDrive db 1 ; 0043 drive we booted from db 0 ; 0044 cpu type (1 if >=386) dw 0 ; 0045 Extended memory in KBytes buf_info dd 0 ; 0047 disk buffer chain @@ -327,8 +334,6 @@ _umb_start dw 0 ; 0068 para of last mem search SysVarEnd: ; We've got (01fb-006a) some room here: don't use all zeros! - - ; Some references seem to indicate that this data should start at 01fbh in ; order to maintain 100% MS-DOS compatibility. @@ -409,13 +414,14 @@ _CritErrCode dw 0 ; 04 - DOS format error Code _CritErrAction db 0 ; 06 - Error Action Code _CritErrClass db 0 ; 07 - Error Class _CritErrDev dd 0 ; 08 - Failing Device Address -_dta dd 0 ; 0C - current DTA +_dta dw _TempBuffer, seg _TempBuffer + ; 0C - current DTA, initialize to TempBuffer. _cu_psp dw 0 ; 10 - Current PSP break_sp dw 0 ; 12 - used in int 23 _return_code db 0 ; 14 - return code from process _return_mode db 0 ; 15 - reason for process terminate _default_drive db 0 ; 16 - Current Drive -_break_ena db 0 ; 17 - Break Flag +_break_ena db 1 ; 17 - Break Flag (default TRUE) db 0 ; 18 - flag, code page switching db 0 ; 19 - flag, copy of 18 on int 24h abort @@ -598,12 +604,23 @@ _ram_top dw 0 ; ; mark front and end of bss area to clear -segment _BSSSTART - global __bssstart -__bssstart: -segment _BSSEND - global __bssend -__bssend: +segment IB_B + global __ib_start +__ib_start: +segment IB_E + global __ib_end +__ib_end: + ;; do not clear the other init BSS variables + STACK: too late. + + retoff resw 1 ; return offset to jump to from HMA_TEXT + +; kernel startup stack + global init_tos + resw 256 +init_tos: +; the last paragraph of conventional memory might become an MCB + resb 16 +init_end: segment _BSSEND ; blockdev private stack @@ -615,20 +632,16 @@ blk_stk_top: global clk_stk_top times 64 dw 0 clk_stk_top: - + ; this is nowhere needed ; interrupt stack ; global intr_stk_top ; times 256 dw 0 ;intr_stk_top: -segment ID ; init data - retaddr dd 0 ; return address to jump to from HMA_TEXT -; kernel startup stack - global init_tos - times 256 dw 0 -init_tos: - +global __bssend +__bssend: + segment ID_B global __INIT_DATA_START __INIT_DATA_START: @@ -659,7 +672,9 @@ segment HMA_TEXT times 16 db 0 ; filler [ffff:0..ffff:10] times 22 db 0 ; filler [sizeof VDISK info] -init_ret: jmp far [retaddr] ; return from init_calls. +init_ret_np: push ds + push word [retoff] + retf ; return from init_calls. ;End of HMA segment segment HMA_TEXT_END @@ -698,78 +713,39 @@ _DGROUP_: segment INIT_TEXT call far initforceEnableA20 ; first enable A20 or not -manip_stack_A20: - pop word [retaddr+2] ; get last ret address - pop word [retaddr] ; get near ret address of init caller - mov ax, init_ret ; new init caller ret address +manip_stack_A20: + pop dx ; get last ret address + pop word [retoff] ; get near ret address of init caller + mov ax, init_ret_np ; new init caller ret address push ax - push word [retaddr+2] ; and back to the relocation entry - mov [retaddr+2], cs ; retaddr is now a far pointer to where we came from - ret - + jmp dx ; and back to the relocation entry + global __HMAinitRelocationTableStart __HMAinitRelocationTableStart: - - extern _DosExec - global _reloc_call_DosExec -_reloc_call_DosExec: - call manip_stack_A20 - jmp far _DosExec - - extern _DosMemAlloc - global _reloc_call_DosMemAlloc -_reloc_call_DosMemAlloc: - call manip_stack_A20 - jmp far _DosMemAlloc - extern _execrh global _reloc_call_execrh _reloc_call_execrh: call manip_stack_A20 jmp far _execrh - extern _fatal - global _reloc_call_fatal -_reloc_call_fatal: - call manip_stack_A20 - jmp far _fatal - extern _fmemcpy global _reloc_call_fmemcpy _reloc_call_fmemcpy: call manip_stack_A20 jmp far _fmemcpy - extern _memcpy - global _reloc_call_memcpy -_reloc_call_memcpy: - call manip_stack_A20 - jmp far _memcpy - - extern _printf - global _reloc_call_printf -_reloc_call_printf: - call manip_stack_A20 - jmp far _printf - extern _strcpy global _reloc_call_strcpy _reloc_call_strcpy: call manip_stack_A20 jmp far _strcpy - extern _sti - global _reloc_call_sti -_reloc_call_sti: - call manip_stack_A20 - jmp far _sti - - extern _strcmp - global _reloc_call_strcmp -_reloc_call_strcmp: + extern _fstrncpy + global _reloc_call_fstrncpy +_reloc_call_fstrncpy: call manip_stack_A20 - jmp far _strcmp + jmp far _fstrncpy extern _strlen global _reloc_call_strlen @@ -777,17 +753,11 @@ _reloc_call_strlen: call manip_stack_A20 jmp far _strlen - extern _WritePCClock - global _reloc_call_WritePCClock -_reloc_call_WritePCClock: - call manip_stack_A20 - jmp far _WritePCClock - - extern _DaysFromYearMonthDay - global _reloc_call_DaysFromYearMonthDay -_reloc_call_DaysFromYearMonthDay: + extern _fstrlen + global _reloc_call_fstrlen +_reloc_call_fstrlen: call manip_stack_A20 - jmp far _DaysFromYearMonthDay + jmp far _fstrlen extern _fmemset global _reloc_call_fmemset @@ -795,12 +765,12 @@ _reloc_call_fmemset: call manip_stack_A20 jmp far _fmemset - extern _p_0 - global _reloc_call_p_0 -_reloc_call_p_0: + extern _memset + global _reloc_call_memset +_reloc_call_memset: call manip_stack_A20 - jmp far _p_0 - + jmp far _memset + global __HMAinitRelocationTableEnd __HMAinitRelocationTableEnd: @@ -850,6 +820,11 @@ _int27_handler: jmp far reloc_call_int27_handler _int0_handler: jmp far reloc_call_int0_handler call near forceEnableA20 + global _int6_handler + extern reloc_call_int6_handler +_int6_handler: jmp far reloc_call_int6_handler + call near forceEnableA20 + global _cpm_entry extern reloc_call_cpm_entry _cpm_entry: jmp far reloc_call_cpm_entry diff --git a/kernel/kernel.mak b/kernel/kernel.mak index 710a81cb..32a3a5c9 100644 --- a/kernel/kernel.mak +++ b/kernel/kernel.mak @@ -5,6 +5,9 @@ # # $Log$ +# Revision 1.10 2001/04/21 22:32:53 bartoldeman +# Init DS=Init CS, fixed stack overflow problems and misc bugs. +# # Revision 1.9 2001/04/16 14:28:32 bartoldeman # Kernel build 2024. Fixed critical error handler/config.sys/makefiles/UMBs # @@ -134,7 +137,8 @@ INCLUDEPATH = ..\HDR #AFLAGS = /Mx /DSTANDALONE=1 /I..\HDR NASMFLAGS = -i../hdr/ LIBS =..\LIB\DEVICE.LIB ..\LIB\LIBM.LIB -INITCFLAGS =$(ALLCFLAGS) -zAINIT -zCINIT_TEXT -zPIGROUP -zDIB -zRID -zTID +INITCFLAGS =$(ALLCFLAGS) -zAINIT -zCINIT_TEXT -zDIB -zRID -zTID -zPIGROUP -zBIB \ +-zGIGROUP -zSIGROUP CFLAGS =$(ALLCFLAGS) -zAHMA -zCHMA_TEXT HDR=../hdr/ @@ -190,6 +194,7 @@ EXE_dependencies = \ nls_hc.obj \ nlssupt.obj \ prf.obj \ + initprf.obj \ printer.obj \ procsupt.obj \ serial.obj \ @@ -224,7 +229,7 @@ kernel.exe: $(EXE_dependencies) $(LIBS) $(LIBUTIL) kernel +printer +serial +dsk +error +fatdir +fatfs $(LIBUTIL) kernel +fattab +fcbfns +initoem +initHMA+inthndlr +ioctl +nls_hc $(LIBUTIL) kernel +main +config +memmgr +misc +newstuff +nls +intr - $(LIBUTIL) kernel +dosnames +prf +strings +network +sysclk +syspack + $(LIBUTIL) kernel +dosnames +prf +initprf +strings +network +sysclk +syspack $(LIBUTIL) kernel +systime +task +int2f +irqstack +apisupt $(LIBUTIL) kernel +asmsupt +execrh +nlssupt +procsupt +break $(LIBUTIL) kernel +dosidle @@ -299,6 +304,10 @@ initHMA.obj: initHMA.c init-mod.h $(HDR)portab.h globals.h $(HDR)device.h \ $(HDR)version.h proto.h turboc.cfg $(CC) $(INITCFLAGS) -c initHMA.c +#the printf for INIT_TEXT: +initprf.obj: prf.c $(HDR)portab.h turboc.cfg + $(CC) -DFORINIT $(INITCFLAGS) -oinitprf.obj -c prf.c + # XXX: I generated these using `gcc -MM' and `sed', so they may not be # completely correct... -- ror4 blockio.obj: blockio.c $(HDR)portab.h globals.h $(HDR)device.h \ diff --git a/kernel/main.c b/kernel/main.c index af591ca1..3ad987b6 100644 --- a/kernel/main.c +++ b/kernel/main.c @@ -27,10 +27,48 @@ /* Cambridge, MA 02139, USA. */ /****************************************************************/ +#include "portab.h" #include "init-mod.h" -#include "portab.h" -#include "globals.h" +/* + These are the far variables from the DOS data segment that we need here. The + init procedure uses a different default DS data segment, which is discarded + after use. I hope to clean this up to use the DOS List of List and Swappable + Data Area obtained via INT21. + + -- Bart + */ +extern UBYTE FAR nblkdev, + FAR lastdrive; /* value of last drive */ + +GLOBAL struct f_node FAR + * FAR f_nodes; /* pointer to the array */ + +GLOBAL BYTE + FAR os_major, /* major version number */ + FAR os_minor, /* minor version number */ + FAR dosidle_flag, + FAR BootDrive, /* Drive we came up from */ + FAR default_drive; /* default drive for dos */ + +GLOBAL BYTE FAR os_release[]; +GLOBAL BYTE FAR copyright[]; +GLOBAL seg FAR RootPsp; /* Root process -- do not abort */ + +GLOBAL struct f_node * FAR pDirFileNode; +extern struct dpb FAR * FAR DPBp; /* First drive Parameter Block */ +extern cdstbl FAR * FAR CDSp; /* Current Directory Structure */ +extern sfttbl FAR * FAR sfthead; /* System File Table head */ + +extern struct dhdr FAR * FAR clock, /* CLOCK$ device */ + FAR * FAR syscon; /* console device */ +extern struct dhdr FAR con_dev, /* console device drive */ + FAR clk_dev, /* Clock device driver */ + FAR blk_dev; /* Block device (Disk) driver */ +extern UWORD + FAR ram_top; /* How much ram in Kbytes */ + +extern iregs FAR * FAR user_r; /* User registers for int 21h call */ #ifdef VERSION_STRINGS static BYTE *mainRcsId = "$Id$"; @@ -38,6 +76,9 @@ static BYTE *mainRcsId = "$Id$"; /* * $Log$ + * Revision 1.15 2001/04/21 22:32:53 bartoldeman + * Init DS=Init CS, fixed stack overflow problems and misc bugs. + * * Revision 1.14 2001/04/16 01:45:26 bartoldeman * Fixed handles, config.sys drivers, warnings. Enabled INT21/AH=6C, printf %S/%Fs * @@ -168,18 +209,13 @@ static BYTE *mainRcsId = "$Id$"; * Initial revision. */ -extern UWORD DaysSinceEpoch; extern WORD days[2][13]; extern BYTE FAR * lpBase; extern BYTE FAR * upBase; - -INIT BOOL ReadATClock(BYTE *, BYTE *, BYTE *, BYTE *); -VOID WritePCClock(ULONG); +extern BYTE _ib_start[], _ib_end[]; INIT VOID configDone(VOID); INIT static void InitIO(void); -INIT static COUNT BcdToByte(COUNT); -/** INIT static COUNT BcdToDay(BYTE *);*/ INIT static VOID update_dcb(struct dhdr FAR *); INIT static VOID init_kernel(VOID); @@ -187,30 +223,16 @@ INIT static VOID signon(VOID); INIT VOID kernel(VOID); INIT VOID FsConfig(VOID); -#ifdef __TURBOC__ -void __int__(int); /* TC 2.01 requires this. :( -- ror4 */ -#endif - - - INIT VOID main(void) { setvec(0, int0_handler); /* zero divide */ setvec(1, empty_handler); /* single step */ setvec(3, empty_handler); /* debug breakpoint */ + setvec(6, empty_handler); /* invalid opcode */ - + /* clear the Init BSS area (what normally the RTL does */ + memset(_ib_start, 0, _ib_end - _ib_start); -#ifdef KDB - BootDrive = 1; -#endif - - { /* clear the BSS area (what normally the RTL does */ - extern BYTE _bssstart[],_bssend[]; - fmemset(_bssstart,0,_bssend-_bssstart); - } - - init_kernel(); #ifdef DEBUG @@ -231,20 +253,17 @@ INIT VOID main(void) at least one known utility (norton DE) seems to access them directly. ok, so we access for all drives, that the stuff gets build */ -/* - should not be necessary anymore (see DosSelectDrv in dosfns.c) void InitializeAllBPBs(VOID) { static char filename[] = "A:-@JUNK@-.TMP"; int drive,fileno; - for (drive = 'Z'; drive >= 'C'; drive--) + for (drive = 'C'; drive < 'A'+nblkdev; drive++) { filename[0] = drive; - if ((fileno = init_DosOpen(filename, O_RDONLY)) >= 0) - init_DosClose(fileno); + if ((fileno = open(filename, O_RDONLY)) >= 0) + close(fileno); } } -*/ INIT void init_kernel(void) { @@ -253,24 +272,12 @@ INIT void init_kernel(void) os_major = MAJOR_RELEASE; os_minor = MINOR_RELEASE; - nblkdev = 0; - maxbksize = 0x200; - switchar = '/'; - dosidle_flag = 1; - - - /* Init oem hook - returns memory size in KB */ ram_top = init_oem(); - UMB_top = 0; - umb_start = 0; /* Fake int 21h stack frame */ user_r = (iregs FAR *) DOS_PSP + 0xD0; -/* Set Init DTA to Tempbuffer */ - dta = (BYTE FAR *) &TempBuffer; - #ifndef KDB for (i = 0x20; i <= 0x3f; i++) setvec(i, empty_handler); @@ -278,8 +285,6 @@ INIT void init_kernel(void) /* Initialize IO subsystem */ InitIO(); - syscon = (struct dhdr FAR *)&con_dev; - clock = (struct dhdr FAR *)&clk_dev; #ifndef KDB /* set interrupt vectors */ @@ -297,10 +302,6 @@ INIT void init_kernel(void) setvec(0x2f, int2f_handler); #endif - /* Initialize the screen handler for backspaces */ - scr_pos = 0; - break_ena = TRUE; - init_PSPInit(DOS_PSP); /* Do first initialization of system variable buffers so that */ @@ -318,7 +319,7 @@ INIT void init_kernel(void) /* Close all (device) files */ for (i = 0; i < lastdrive; i++) - init_DosClose(i); + close(i); /* and do final buffer allocation. */ PostConfig(); @@ -334,18 +335,13 @@ INIT void init_kernel(void) /* Close all (device) files */ for (i = 0; i < lastdrive; i++) - init_DosClose(i); + close(i); /* Now config the final file system */ FsConfig(); #endif - /* Now to initialize all special flags, etc. */ - mem_access_mode = FIRST_FIT; - verify_ena = FALSE; - InDOS = 0; - pDirFileNode = 0; - dosidle_flag = 0; + InitializeAllBPBs(); } INIT VOID FsConfig(VOID) @@ -353,38 +349,31 @@ INIT VOID FsConfig(VOID) REG COUNT i; struct dpb FAR *dpb; - /* Initialize the file tables */ - for (i = 0; i < Config.cfgFiles; i++) - f_nodes[i].f_count = 0; - /* The system file tables need special handling and are "hand */ - /* built. Included is the stdin, stdout, stdaux and atdprn. */ + /* built. Included is the stdin, stdout, stdaux and stdprn. */ sfthead->sftt_next = (sfttbl FAR *) - 1; sfthead->sftt_count = Config.cfgFiles; - for (i = 0; i < sfthead->sftt_count; i++) + for (i = 0; i < Config.cfgFiles; i++) { + /* Initialize the file tables */ + f_nodes[i].f_count = 0; sfthead->sftt_table[i].sft_count = 0; sfthead->sftt_table[i].sft_status = -1; } /* 0 is /dev/con (stdin) */ - init_DosOpen("CON", SFT_MREAD); - sfthead->sftt_table[0].sft_flags |= SFT_FCONIN | SFT_FCONOUT; + open("CON", O_RDWR); /* 1 is /dev/con (stdout) */ - init_DosOpen("CON", SFT_MWRITE); - sfthead->sftt_table[1].sft_flags |= SFT_FCONIN | SFT_FCONOUT; + dup2(STDIN, STDOUT); /* 2 is /dev/con (stderr) */ - init_DosOpen("CON", SFT_MWRITE); - sfthead->sftt_table[2].sft_flags |= SFT_FCONIN | SFT_FCONOUT; + dup2(STDIN, STDERR); /* 3 is /dev/aux */ - init_DosOpen("AUX", SFT_MRDWR); - sfthead->sftt_table[3].sft_flags &= ~SFT_FEOF; + open("AUX", O_RDWR); /* 4 is /dev/prn */ - init_DosOpen("PRN", SFT_MWRITE); - sfthead->sftt_table[4].sft_flags &= ~SFT_FEOF; + open("PRN", O_WRONLY); /* Log-in the default drive. */ /* Get the boot drive from the ipl and use it for default. */ @@ -423,32 +412,43 @@ INIT VOID FsConfig(VOID) INIT VOID signon() { - printf("\nFreeDOS Kernel compatibility %d.%d\n%s\n", + BYTE tmp_or[81]; /* ugly constant, but this string should fit on one line */ + + printf("\nFreeDOS Kernel compatibility %d.%d\n%S\n", os_major, os_minor, copyright); - printf(os_release, + fmemcpy(tmp_or, os_release, 81); + printf(tmp_or, REVISION_MAJOR, REVISION_MINOR, REVISION_SEQ, BUILD); } INIT void kernel() { - seg asize; +#if 0 BYTE FAR *ep, *sp; +#endif + exec_blk exb; + CommandTail Cmd; + int rc; + #ifndef KDB - static BYTE *path = "PATH=."; + static BYTE master_env[] = "PATH=.\0\0\0\0\0"; +/* static BYTE *path = "PATH=.";*/ #endif #ifdef KDB kdb(); #else +#if 0 /* create the master environment area */ - if (DosMemAlloc(0x20, FIRST_FIT, (seg FAR *) & master_env, (seg FAR *) & asize) < 0) - fatal("cannot allocate master environment space"); + + if (allocmem(0x2, &exb.exec.env_seg)) + init_fatal("cannot allocate master environment space"); /* populate it with the minimum environment */ - ++master_env; - ep = MK_FP(master_env, 0); + ++exb.exec.env_seg; + ep = MK_FP(exb.exec.env_seg, 0); for (sp = path; *sp != 0;) *ep++ = *sp++; @@ -457,9 +457,55 @@ INIT void kernel() *ep++ = '\0'; *((int FAR *)ep) = 0; ep += sizeof(int); -#endif +#else + exb.exec.env_seg = DOS_PSP+8; + fmemcpy(MK_FP(exb.exec.env_seg, 0), master_env, sizeof(master_env)); +#endif +#endif + RootPsp = ~0; - p_0(); + + /* process 0 */ + /* Execute command.com /P from the drive we just booted from */ + fstrncpy(Cmd.ctBuffer, Config.cfgInitTail, sizeof(Config.cfgInitTail)-1); + + for (Cmd.ctCount = 0; Cmd.ctCount < 127; Cmd.ctCount++) + if (Cmd.ctBuffer[Cmd.ctCount] == '\r') + break; + + exb.exec.cmd_line = (CommandTail FAR *) & Cmd; + exb.exec.fcb_1 = exb.exec.fcb_2 = (fcb FAR *) 0; + +#ifdef DEBUG + printf("Process 0 starting: %s\n\n", Config.cfgInit); +#endif + + while ((rc = init_DosExec(Config.cfgP_0_startmode, &exb, Config.cfgInit)) != SUCCESS) + { + BYTE *pLine; + printf("\nBad or missing Command Interpreter: %d\n", rc); + printf("\nPlease enter the correct location (for example C:\\COMMAND.COM):\n"); + rc = read(STDIN, Cmd.ctBuffer, sizeof(Cmd.ctBuffer)-1); + Cmd.ctBuffer[rc]='\0'; + + /* Get the string argument that represents the new init pgm */ + pLine = GetStringArg(Cmd.ctBuffer, Config.cfgInit); + + /* Now take whatever tail is left and add it on as a single */ + /* string. */ + strcpy(Cmd.ctBuffer, pLine); + + /* and add a DOS new line just to be safe */ + strcat(Cmd.ctBuffer, "\r\n"); + + Cmd.ctCount = rc-(pLine-Cmd.ctBuffer); + +#ifdef DEBUG + printf("Process 0 starting: %s\n\n", Config.cfgInit); +#endif + } + printf("\nSystem shutdown complete\nReboot now.\n"); + for (;;) ; } /* check for a block device and update device control block */ @@ -518,7 +564,7 @@ BOOL init_device(struct dhdr FAR * dhp, BYTE FAR * cmdLine, COUNT mode, COUNT r_ rq.r_firstunit = nblkdev; execrh((request FAR *) & rq, dhp); - + /* * Added needed Error handle */ @@ -548,49 +594,27 @@ BOOL init_device(struct dhdr FAR * dhp, BYTE FAR * cmdLine, COUNT mode, COUNT r_ update_dcb(dhp); } + if (dhp->dh_attr & ATTR_CONIN) + syscon = dhp; + else if (dhp->dh_attr & ATTR_CLOCK) + clock = dhp; + return FALSE; } INIT static void InitIO(void) { - BYTE bcd_days[4], - bcd_minutes, - bcd_hours, - bcd_seconds; - ULONG ticks; - /* Initialize driver chain */ - nul_dev.dh_next = (struct dhdr FAR *)&con_dev; setvec(0x29, int29_handler); /* Requires Fast Con Driver */ - init_device((struct dhdr FAR *)&con_dev, NULL, NULL, ram_top); - init_device((struct dhdr FAR *)&clk_dev, NULL, NULL, ram_top); - /* If AT clock exists, copy AT clock time to system clock */ - if (!ReadATClock(bcd_days, &bcd_hours, &bcd_minutes, &bcd_seconds)) - { - DaysSinceEpoch = DaysFromYearMonthDay( - 100 * BcdToByte(bcd_days[3]) + BcdToByte(bcd_days[2]), - BcdToByte(bcd_days[1]), - BcdToByte(bcd_days[0]) ); - - /* - * This is a rather tricky calculation. The number of timer ticks per - * second is not exactly 18.2, but rather 0x1800b0 / 86400 = 19663 / 1080 - * (the timer interrupt updates the midnight flag when the tick count - * reaches 0x1800b0). Fortunately, 86400 * 19663 = 1698883200 < ULONG_MAX, - * so we can simply multiply the number of seconds by 19663 without - * worrying about overflow. :) -- ror4 - */ - ticks = (3600ul * BcdToByte(bcd_hours) + - 60ul * BcdToByte(bcd_minutes) + - BcdToByte(bcd_seconds)) * 19663ul / 1080ul; - WritePCClock(ticks); - } + init_device(&con_dev, NULL, NULL, ram_top); + init_device(&clk_dev, NULL, NULL, ram_top); } -INIT static COUNT BcdToByte(COUNT x) +/* issue an internal error message */ +VOID init_fatal(BYTE * err_msg) { - return ((((x) >> 4) & 0xf) * 10 + ((x) & 0xf)); + printf("\nInternal kernel error - %s\nSystem halted\n", err_msg); + for (;;) ; } - diff --git a/kernel/memmgr.c b/kernel/memmgr.c index 0118975d..116b3cfc 100644 --- a/kernel/memmgr.c +++ b/kernel/memmgr.c @@ -35,6 +35,9 @@ static BYTE *memmgrRcsId = "$Id$"; /* * $Log$ + * Revision 1.14 2001/04/21 22:32:53 bartoldeman + * Init DS=Init CS, fixed stack overflow problems and misc bugs. + * * Revision 1.13 2001/04/16 01:45:26 bartoldeman * Fixed handles, config.sys drivers, warnings. Enabled INT21/AH=6C, printf %S/%Fs * @@ -698,7 +701,7 @@ VOID DosUmbLink(BYTE n) it will be useful (maybe for storing environments) */ - +#if 0 BYTE INITDataSegmentClaimed = 1; /* must be enabled by CONFIG.SYS */ extern BYTE _INIT_DATA_START[], _INIT_DATA_END[]; @@ -739,5 +742,5 @@ VOID ClaimINITDataSegment() first_mcb = FP_SEG(p) + (FP_OFF(p) >> 4); } - +#endif #endif diff --git a/kernel/prf.c b/kernel/prf.c index 44fc9f39..3f72bacb 100644 --- a/kernel/prf.c +++ b/kernel/prf.c @@ -28,6 +28,17 @@ #include "portab.h" +#ifdef FORINIT +#define fstrlen reloc_call_fstrlen +#define put_console init_put_console +#define ltob init_ltob +#define do_printf init_do_printf +#define printf init_printf +#define sprintf init_sprintf +#define charp init_charp +#define hexd init_hexd +#endif + COUNT fstrlen (BYTE FAR * s); /* don't want globals.h, sorry */ @@ -37,6 +48,9 @@ static BYTE *prfRcsId = "$Id$"; /* * $Log$ + * Revision 1.9 2001/04/21 22:32:53 bartoldeman + * Init DS=Init CS, fixed stack overflow problems and misc bugs. + * * Revision 1.8 2001/04/16 01:45:26 bartoldeman * Fixed handles, config.sys drivers, warnings. Enabled INT21/AH=6C, printf %S/%Fs * @@ -53,6 +67,9 @@ static BYTE *prfRcsId = "$Id$"; * recoded for smaller object footprint, added main() for testing+QA * * $Log$ + * Revision 1.9 2001/04/21 22:32:53 bartoldeman + * Init DS=Init CS, fixed stack overflow problems and misc bugs. + * * Revision 1.8 2001/04/16 01:45:26 bartoldeman * Fixed handles, config.sys drivers, warnings. Enabled INT21/AH=6C, printf %S/%Fs * @@ -377,7 +394,7 @@ COUNT void hexd(char *title,UBYTE FAR *p,COUNT numBytes) { int loop; - printf("%s%04x|",title,p); + printf("%s%04x|", title, FP_SEG(p)); for (loop = 0; loop < numBytes; loop++) printf("%02x ", p[loop]); printf("|"); diff --git a/kernel/proto.h b/kernel/proto.h index 60818522..7368b4f6 100644 --- a/kernel/proto.h +++ b/kernel/proto.h @@ -34,6 +34,9 @@ static BYTE *Proto_hRcsId = "$Id$"; /* * $Log$ + * Revision 1.15 2001/04/21 22:32:53 bartoldeman + * Init DS=Init CS, fixed stack overflow problems and misc bugs. + * * Revision 1.14 2001/04/16 01:45:26 bartoldeman * Fixed handles, config.sys drivers, warnings. Enabled INT21/AH=6C, printf %S/%Fs * @@ -166,8 +169,6 @@ static BYTE *Proto_hRcsId = "$Id$"; *Initial revision. */ -#define INIT - /* blockio.c */ ULONG getblkno(struct buffer FAR *); VOID setblkno(struct buffer FAR *, ULONG); @@ -193,24 +194,10 @@ BOOL con_break(void); BOOL StdinBusy(void); VOID KbdFlush(void); VOID Do_DosIdle_loop(void); -VOID sti(keyboard FAR * kp); +UCOUNT sti(keyboard FAR * kp); sft FAR *get_sft(COUNT); -/* config.c */ -INIT VOID PreConfig(VOID); -INIT VOID DoConfig(VOID); -INIT VOID PostConfig(VOID); -INIT BYTE *skipwh(BYTE * s); -INIT BYTE *scan(BYTE * s, BYTE * d); -INIT BOOL isnum(BYTE * pszString); -INIT BYTE *GetNumber(REG BYTE * pszString, REG COUNT * pnNum); -INIT COUNT tolower(COUNT c); -INIT COUNT toupper(COUNT c); -INIT VOID mcb_init(mcb FAR * mcbp, UWORD size); -INIT VOID strcat(REG BYTE * d, REG BYTE * s); -INIT BYTE FAR *KernelAlloc(WORD nBytes); - /* dosfns.c */ BYTE FAR *get_root(BYTE FAR *); BOOL fnmatch(BYTE FAR *, BYTE FAR *, COUNT, COUNT); @@ -218,7 +205,8 @@ BOOL check_break(void); UCOUNT GenericRead(COUNT hndl, UCOUNT n, BYTE FAR * bp, COUNT FAR * err, BOOL force_binary); COUNT SftSeek(sft FAR *sftp, LONG new_pos, COUNT mode); -UCOUNT DosRead(COUNT hndl, UCOUNT n, BYTE FAR * bp, COUNT FAR * err); +/* COUNT DosRead(COUNT hndl, UCOUNT n, BYTE FAR * bp, COUNT FAR * err); */ +#define DosRead(hndl,n,bp,err) GenericRead(hndl, n, bp, err,FALSE) UCOUNT DosWrite(COUNT hndl, UCOUNT n, BYTE FAR * bp, COUNT FAR * err); COUNT DosSeek(COUNT hndl, LONG new_pos, COUNT mode, ULONG * set_pos); COUNT DosCreat(BYTE FAR * fname, COUNT attrib); @@ -355,49 +343,9 @@ BOOL FcbClose(xfcb FAR * lpXfcb); BOOL FcbFindFirst(xfcb FAR * lpXfcb); BOOL FcbFindNext(xfcb FAR * lpXfcb); -/* inithma.c */ -int MoveKernelToHMA(void); -VOID FAR *HMAalloc(COUNT bytesToAllocate); - -/* initoem.c */ -UWORD init_oem(void); - -/* inthndlr.c */ -VOID INRPT far got_cbreak(void); /* procsupt.asm */ -VOID INRPT far int20_handler(iregs UserRegs); -VOID INRPT far int21_handler(iregs UserRegs); -VOID far int21_entry(iregs UserRegs); -VOID int21_service(iregs far * r); -VOID INRPT FAR int22_handler(void); -VOID INRPT FAR int23_handler(int es, int ds, int di, int si, int bp, int sp, int bx, int dx, int cx, int ax, int ip, int cs, int flags); -VOID INRPT FAR int24_handler(void); -VOID INRPT FAR low_int25_handler(void); -VOID INRPT FAR low_int26_handler(void); -/* VOID int25_handler(); -VOID int26_handler();*/ -VOID INRPT FAR int27_handler(int es, int ds, int di, int si, int bp, int sp, int bx, int dx, int cx, int ax, int ip, int cs, int flags); -VOID INRPT FAR int28_handler(void); -VOID INRPT FAR int2a_handler(void); -VOID INRPT FAR int2f_handler(void); -VOID INRPT FAR empty_handler(void); -VOID INRPT FAR int0_handler(void); - -/* intr.asm */ -/* void init_call_intr(int nr, iregs *rp); */ -INIT COUNT init_DosRead(COUNT hndl, BYTE *bp, UCOUNT n); -INIT COUNT init_DosOpen(BYTE *fname, COUNT mode); -INIT COUNT init_DosClose(COUNT hndl); -INIT VOID init_PSPInit(seg psp_seg); -INIT VOID keycheck(VOID); - /* ioctl.c */ COUNT DosDevIOctl(iregs FAR * r); - -/* main.c */ -INIT VOID main(void); -INIT BOOL init_device(struct dhdr FAR * dhp, BYTE FAR * cmdLine, COUNT mode, COUNT top); - /* memmgr.c */ seg far2para(VOID FAR * p); seg long2para(ULONG size); @@ -497,7 +445,6 @@ LONG WordToBcd(BYTE * x, UWORD * mon, UWORD * day, UWORD * yr); /* syscon.c */ WORD con_driver(rqptr rp); VOID break_handler(void); -VOID INRPT FAR int29_handler(int es, int ds, int di, int si, int bp, int sp, int bx, int dx, int cx, int ax, int ip, int cs, int flags); /* syspack.c */ VOID getdirent(BYTE FAR * vp, struct dirent FAR * dp); @@ -520,10 +467,6 @@ VOID new_psp(psp FAR * p, int psize); VOID return_user(void); COUNT DosExec(COUNT mode, exec_blk FAR * ep, BYTE FAR * lp); VOID InitPSP(VOID); -VOID p_0(VOID); - -/* irqstack.asm */ -VOID init_stacks(VOID FAR * stack_base, COUNT nStacks, WORD stackSize); /* newstuff.c */ int SetJFTSize(UWORD nHandles); @@ -535,8 +478,6 @@ COUNT truename(char FAR * src, char FAR * dest, COUNT t); COUNT int2f_Remote_call(UWORD func, UWORD b, UCOUNT n, UWORD d, VOID FAR * s, UWORD i, VOID FAR * data); COUNT QRemote_Fn(char FAR * s, char FAR * d); -COUNT Umb_Test(void); - UWORD get_machine_name(BYTE FAR * netname); VOID set_machine_name(BYTE FAR * netname, UWORD name_num); UCOUNT Remote_RW(UWORD func, UCOUNT n, BYTE FAR * bp, sft FAR * s, COUNT FAR * err); diff --git a/kernel/segs.inc b/kernel/segs.inc index 6f88f733..997a368c 100644 --- a/kernel/segs.inc +++ b/kernel/segs.inc @@ -29,6 +29,9 @@ ; $Header$ ; ; $Log$ +; Revision 1.6 2001/04/21 22:32:53 bartoldeman +; Init DS=Init CS, fixed stack overflow problems and misc bugs. +; ; Revision 1.5 2001/04/15 03:21:50 bartoldeman ; See history.txt for the list of fixes. ; @@ -60,11 +63,13 @@ ; $EndLog ; +group PGROUP PSP group TGROUP _TEXT _IO_TEXT _IO_FIXED_DATA -group DGROUP _FIXED_DATA _DATA _BSS _BSSEND ID_B ID ID_E +group DGROUP _FIXED_DATA _DATA _BSSSTART _BSS _BSSEND group HGROUP HMA_TEXT_START HMA_TEXT HMA_TEXT_END -group IGROUP INIT_TEXT_START INIT_TEXT INIT_TEXT_END +group IGROUP INIT_TEXT_START INIT_TEXT INIT_TEXT_END ID_B ID ID_E IB_B IB IB_E +segment PSP class=PSP segment _TEXT class=CODE segment _IO_TEXT class=CODE segment _IO_FIXED_DATA class=CODE align=2 @@ -73,13 +78,16 @@ segment _DATA class=DATA align=2 segment _BSSSTART class=BSS align=2 segment _BSS class=BSS align=2 segment _BSSEND class=BSS -segment ID_B class=ID align=2 -segment ID class=ID align=2 -segment ID_E class=ID align=2 segment HMA_TEXT_START class=HMA segment HMA_TEXT class=HMA segment HMA_TEXT_END class=HMA segment INIT_TEXT_START class=INIT align=16 segment INIT_TEXT class=INIT segment INIT_TEXT_END class=INIT +segment ID_B class=ID align=2 +segment ID class=ID align=2 +segment ID_E class=ID align=2 +segment IB_B class=IB align=2 +segment IB class=IB align=2 +segment IB_E class=IB align=2 diff --git a/kernel/sysclk.c b/kernel/sysclk.c index f13710c8..dde096a0 100644 --- a/kernel/sysclk.c +++ b/kernel/sysclk.c @@ -35,6 +35,9 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.6 2001/04/21 22:32:53 bartoldeman + * Init DS=Init CS, fixed stack overflow problems and misc bugs. + * * Revision 1.5 2001/04/15 03:21:50 bartoldeman * See history.txt for the list of fixes. * @@ -130,15 +133,48 @@ static BYTE bcdSeconds; static ULONG Ticks; UWORD DaysSinceEpoch = 0; +BOOL ReadATClock(BYTE *, BYTE *, BYTE *, BYTE *); + +static COUNT BcdToByte(COUNT x) +{ + return ((((x) >> 4) & 0xf) * 10 + ((x) & 0xf)); +} + WORD FAR clk_driver(rqptr rp) { COUNT c; WORD *pdays; - + BYTE bcd_days[4], + bcd_minutes, + bcd_hours, + bcd_seconds; + ULONG ticks; + switch (rp->r_command) { case C_INIT: + /* If AT clock exists, copy AT clock time to system clock */ + if (!ReadATClock(bcd_days, &bcd_hours, &bcd_minutes, &bcd_seconds)) + { + DaysSinceEpoch = DaysFromYearMonthDay( + 100 * BcdToByte(bcd_days[3]) + BcdToByte(bcd_days[2]), + BcdToByte(bcd_days[1]), + BcdToByte(bcd_days[0]) ); + + /* + * This is a rather tricky calculation. The number of timer ticks per + * second is not exactly 18.2, but rather 0x1800b0 / 86400 = 19663 / 1080 + * (the timer interrupt updates the midnight flag when the tick count + * reaches 0x1800b0). Fortunately, 86400 * 19663 = 1698883200 < ULONG_MAX, + * so we can simply multiply the number of seconds by 19663 without + * worrying about overflow. :) -- ror4 + */ + ticks = (3600ul * BcdToByte(bcd_hours) + + 60ul * BcdToByte(bcd_minutes) + + BcdToByte(bcd_seconds)) * 19663ul / 1080ul; + WritePCClock(ticks); + } rp->r_endaddr = device_end(); rp->r_nunits = 0; return S_DONE; diff --git a/kernel/task.c b/kernel/task.c index 8da0fb8e..ee87722f 100644 --- a/kernel/task.c +++ b/kernel/task.c @@ -35,6 +35,9 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.13 2001/04/21 22:32:53 bartoldeman + * Init DS=Init CS, fixed stack overflow problems and misc bugs. + * * Revision 1.12 2001/04/16 14:28:32 bartoldeman * Kernel build 2024. Fixed critical error handler/config.sys/makefiles/UMBs * @@ -157,9 +160,9 @@ static BYTE *RcsId = "$Id$"; * Rev 1.0 02 Jul 1995 8:34:06 patv * Initial revision. */ - +#if 0 extern VOID ClaimINITDataSegment(VOID); - +#endif #define toupper(c) ((c) >= 'a' && (c) <= 'z' ? (c) + ('A' - 'a') : (c)) #define LOADNGO 0 @@ -451,8 +454,8 @@ static VOID patchPSP(UWORD pspseg, UWORD envseg, CommandTail FAR * cmdline COUNT DosComLoader(BYTE FAR * namep, exec_blk FAR * exp, COUNT mode) { - COUNT rc, - err + COUNT rc + /* err */ /*,env_size*/; COUNT nread; UWORD mem; @@ -553,7 +556,7 @@ COUNT DosComLoader(BYTE FAR * namep, exec_blk FAR * exp, COUNT mode) } do { - nread = DosRead(rc, CHUNK, sp, &err); + nread = DosRead(rc, CHUNK, sp, &UnusedRetVal); sp = add_far((VOID FAR *) sp, (ULONG) nread); } while ((com_size -= nread) > 0 && nread == CHUNK); @@ -604,8 +607,8 @@ COUNT DosComLoader(BYTE FAR * namep, exec_blk FAR * exp, COUNT mode) now we 1 microsecond from COMMAND.COM now we claim the ID = INIT_DATA segment, which should no longer be used - */ ClaimINITDataSegment(); + */ if (InDOS) --InDOS; @@ -668,7 +671,7 @@ VOID return_user(void) COUNT DosExeLoader(BYTE FAR * namep, exec_blk FAR * exp, COUNT mode) { COUNT rc, - err, + /*err, */ /*env_size,*/ i; COUNT nBytesRead; @@ -883,7 +886,7 @@ COUNT DosExeLoader(BYTE FAR * namep, exec_blk FAR * exp, COUNT mode) do { - nBytesRead = DosRead((COUNT) rc, (COUNT) (exe_size < CHUNK ? exe_size : CHUNK), (VOID FAR *) sp, &err); + nBytesRead = DosRead((COUNT) rc, (COUNT) (exe_size < CHUNK ? exe_size : CHUNK), (VOID FAR *) sp, &UnusedRetVal); sp = add_far((VOID FAR *) sp, (ULONG) nBytesRead); exe_size -= nBytesRead; } @@ -894,7 +897,7 @@ COUNT DosExeLoader(BYTE FAR * namep, exec_blk FAR * exp, COUNT mode) doslseek(rc, (LONG) header.exRelocTable, 0); for (i = 0; i < header.exRelocItems; i++) { - if (DosRead(rc, sizeof(reloc), (VOID FAR *) & reloc[0], &err) != sizeof(reloc)) + if (DosRead(rc, sizeof(reloc), (VOID FAR *) & reloc[0], &UnusedRetVal) != sizeof(reloc)) { return DE_INVLDDATA; } @@ -960,8 +963,8 @@ COUNT DosExeLoader(BYTE FAR * namep, exec_blk FAR * exp, COUNT mode) now we 1 microsecond from COMMAND.COM now we claim the ID = INIT_DATA segment, which should no longer be used - */ ClaimINITDataSegment(); + */ if (InDOS) --InDOS; @@ -987,8 +990,7 @@ COUNT DosExeLoader(BYTE FAR * namep, exec_blk FAR * exp, COUNT mode) */ COUNT DosExec(COUNT mode, exec_blk FAR * ep, BYTE FAR * lp) { - COUNT rc, - err; + COUNT rc; exec_blk leb; /* BYTE FAR *cp;*/ @@ -1003,7 +1005,7 @@ COUNT DosExec(COUNT mode, exec_blk FAR * ep, BYTE FAR * lp) } - if (DosRead(rc, sizeof(exe_header), (VOID FAR *) & header, &err) + if (DosRead(rc, sizeof(exe_header), (VOID FAR *) & header, &UnusedRetVal) != sizeof(exe_header)) { bIsCom = TRUE; @@ -1024,32 +1026,4 @@ COUNT DosExec(COUNT mode, exec_blk FAR * ep, BYTE FAR * lp) return rc; } -/* process 0 */ -VOID p_0(VOID) -{ - exec_blk exb; - CommandTail Cmd; - BYTE FAR *szfInitialPrgm = (BYTE FAR *) Config.cfgInit; - int rc; - - /* Execute command.com /P from the drive we just booted from */ - exb.exec.env_seg = master_env; - fstrncpy(Cmd.ctBuffer, Config.cfgInitTail, sizeof(Config.cfgInitTail)-1); - - for (Cmd.ctCount = 0; Cmd.ctCount < 127; Cmd.ctCount++) - if (Cmd.ctBuffer[Cmd.ctCount] == '\r') - break; - - exb.exec.cmd_line = (CommandTail FAR *) & Cmd; - exb.exec.fcb_1 = exb.exec.fcb_2 = (fcb FAR *) 0; -#ifdef DEBUG - printf("Process 0 starting: %s\n\n", (BYTE *) szfInitialPrgm); -#endif - if ((rc = DosExec(Config.cfgP_0_startmode, - (exec_blk FAR *) & exb, szfInitialPrgm)) != SUCCESS) - printf("\nBad or missing Command Interpreter: %d\n", rc); - else - printf("\nSystem shutdown complete\nReboot now.\n"); - for (;;) ; -} From 6882b1b13dc402e0289179a5e31b32c183d19c65 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sun, 22 Apr 2001 01:19:34 +0000 Subject: [PATCH 076/671] Avoid sys warning and have a VDISK signature in the HMA git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@205 6ac86273-5f31-0410-b378-82cca8765d1b --- drivers/floppy.asm | 12 ++++++------ drivers/rdatclk.asm | 2 +- kernel/kernel.asm | 20 ++++++++++++-------- 3 files changed, 19 insertions(+), 15 deletions(-) diff --git a/drivers/floppy.asm b/drivers/floppy.asm index a48273b2..e5443de3 100644 --- a/drivers/floppy.asm +++ b/drivers/floppy.asm @@ -30,6 +30,9 @@ ; $Id$ ; ; $Log$ +; Revision 1.6 2001/04/22 01:19:33 bartoldeman +; Avoid sys warning and have a VDISK signature in the HMA +; ; Revision 1.5 2001/04/15 03:21:50 bartoldeman ; See history.txt for the list of fixes. ; @@ -85,13 +88,10 @@ %ifndef SYS %include "..\kernel\segs.inc" + segment HMA_TEXT %else -group TGROUP HMA_TEXT _TEXT -segment _TEXT class=CODE -segment HMA_TEXT class=CODE -%endif -segment HMA_TEXT - + segment _TEXT class=CODE +%endif ; ; ; Reset both the diskette and hard disk system diff --git a/drivers/rdatclk.asm b/drivers/rdatclk.asm index b98870bd..df4fdeea 100644 --- a/drivers/rdatclk.asm +++ b/drivers/rdatclk.asm @@ -62,7 +62,7 @@ %include "..\kernel\segs.inc" -segment INIT_TEXT +segment HMA_TEXT ; ;COUNT ReadATClock(bcdDays, bcdHours, bcdMinutes, bcdSeconds) diff --git a/kernel/kernel.asm b/kernel/kernel.asm index b0fc3b77..24e02abb 100644 --- a/kernel/kernel.asm +++ b/kernel/kernel.asm @@ -28,8 +28,8 @@ ; $Id$ ; ; $Log$ -; Revision 1.10 2001/04/21 22:32:53 bartoldeman -; Init DS=Init CS, fixed stack overflow problems and misc bugs. +; Revision 1.11 2001/04/22 01:19:34 bartoldeman +; Avoid sys warning and have a VDISK signature in the HMA ; ; Revision 1.9 2001/04/15 03:21:50 bartoldeman ; See history.txt for the list of fixes. @@ -665,12 +665,16 @@ __HMATextAvailable __HMATextStart: ; -; the HMA area is filled with 16+22(=sizeof VDISK) = 32 byte dummy data, -; so nothing will ever be below 0xffff:25 -; -segment HMA_TEXT - times 16 db 0 ; filler [ffff:0..ffff:10] - times 22 db 0 ; filler [sizeof VDISK info] +; the HMA area is filled with 1eh+3(=sizeof VDISK) = 33 byte dummy data, +; so nothing will ever be below 0xffff:0031 +; +segment HMA_TEXT +begin_hma: + times 13h db 0 ; filler [ffff:0..ffff:12] + db 'VDISK',0 ; VDISK3.3 signature at ffff:0013 + times (2eh-($-begin_hma)) db 0 + dw 1088 ; 0x2e: first free kb position for extended memory + db 0 init_ret_np: push ds push word [retoff] From 34c621909eea3a5cba1b0580b06d185193b554f6 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sun, 22 Apr 2001 01:22:15 +0000 Subject: [PATCH 077/671] Updated history git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@206 6ac86273-5f31-0410-b378-82cca8765d1b --- docs/history.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/history.txt b/docs/history.txt index 0fdb1e54..767226ec 100644 --- a/docs/history.txt +++ b/docs/history.txt @@ -7,6 +7,7 @@ Bart: * fixed "copy con" and INT21/AH=0B. The SFT_FEOF flag, strangely enough, if true indicates NOT end-of-file. + * VDISK signature required in HMA (bug 701 dborca@usa.net). Alan Kamrowski * fixed intr: it wasn't putting the flags back correctly and swapped si and bp. From 081222031a74a5d8b2894ef7af4bd226fdb6157e Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Wed, 25 Apr 2001 00:56:03 +0000 Subject: [PATCH 078/671] Marked these files as binary, as they are exactly that. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@210 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/nls/001-437.up | Bin 254 -> 256 bytes kernel/nls/049-850.up | Bin 254 -> 256 bytes 2 files changed, 0 insertions(+), 0 deletions(-) diff --git a/kernel/nls/001-437.up b/kernel/nls/001-437.up index 8981596bb741b6d2413c2aa81e49868016956edd..c73fc9466e695de83ee903b1618991be93df55b2 100644 GIT binary patch delta 35 qcmeyz*uW&sz{teR!pg?Z!O6wV!^_7nASfg(A}S^>At^Oc@+kmHw*-p- delta 33 ocmZo*`o}2Az{teR!pg?Z!O6wV!^bZmC?qT*Dkd%=IZ^s407HTVWB>pF diff --git a/kernel/nls/049-850.up b/kernel/nls/049-850.up index 7a51fe8f14b1bf60bb989f04f0779d55bf083879..67a9e91dedd3467d435bb3dcfd38ea797652dba5 100644 GIT binary patch delta 35 qcmeyz*uW&sz{teR!pg?Z!O6wV!^_7nASfg(A}S^>At^Oc@+kmHw*-p- delta 33 ocmZo*`o}2Az{teR!pg?Z!O6wV!^bZmC?qT*Dkd%=IZ^s407HTVWB>pF From 64474e1dd4254f6d629c41f8c263c9ea9266012e Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sun, 29 Apr 2001 17:34:41 +0000 Subject: [PATCH 079/671] A new SYS.COM/config.sys single stepping/console output/misc fixes. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@216 6ac86273-5f31-0410-b378-82cca8765d1b --- boot/boot.asm | 4 + docs/history.txt | 24 ++++- hdr/fnode.h | 15 +-- hdr/version.h | 2 +- kernel/chario.c | 60 +++++++----- kernel/config.c | 181 +++++++++++++++++++++++++++++----- kernel/dosfns.c | 183 +++++++++++++++++++++-------------- kernel/dsk.c | 240 ++++++++++++++++++---------------------------- kernel/fatdir.c | 85 +--------------- kernel/fatfs.c | 14 +++ kernel/init-mod.h | 5 +- kernel/inithma.c | 4 + kernel/inthndlr.c | 9 +- kernel/intr.asm | 4 +- kernel/io.asm | 140 ++++++++++++--------------- kernel/kernel.asm | 28 ++++-- kernel/main.c | 82 ++++++++++++---- kernel/network.c | 29 +++--- kernel/prf.c | 25 ++++- kernel/proto.h | 7 +- kernel/segs.inc | 5 +- sys/sys.mak | 17 ++-- 22 files changed, 680 insertions(+), 483 deletions(-) diff --git a/boot/boot.asm b/boot/boot.asm index df24137d..975cacb0 100644 --- a/boot/boot.asm +++ b/boot/boot.asm @@ -27,6 +27,9 @@ ; ; ; $Log$ +; Revision 1.4 2001/04/29 17:34:39 bartoldeman +; A new SYS.COM/config.sys single stepping/console output/misc fixes. +; ; Revision 1.3 2000/05/25 20:56:19 jimtabor ; Fixed project history ; @@ -300,6 +303,7 @@ cont: mov ds, ax mov dx, word [root_dir_start+2] mov di, word [RootDirSecs] xor bx, bx + mov word [tempbuf], LOADSEG mov es, [tempbuf] call readDisk jc jmp_boot_error diff --git a/docs/history.txt b/docs/history.txt index 767226ec..68501ab9 100644 --- a/docs/history.txt +++ b/docs/history.txt @@ -1,4 +1,26 @@ -2001 Apr 21 - Build 2024 +2001 Apr 29 - Build 2024 +-------- Bart Oldeman (bart.oldeman@bristol.ac.uk) ++ Fixes Bart: + * fixed the "TYPE > FOO.TXT" poor man's editor. + * use "fast console output" (int 29) when applicable. + * moved 5 FILES to DOS DS:00CC and fixed the SFT linked list. + * cleaned up findfirst/findnext for redirected drives. + Tom: + * more VDISK changes (changed slightly by Bart) + * check for presence of A:/B: (changed by Bart to use the BIOS equipment flag + from INT11 instead of INT13). + * added F5/F8 stepping through config.sys; default SHELL=COMMAND.COM /P/E:256 + Use ESC to stop single stepping, F5 to skip remaining config.sys/autoexec.bat. + * new sys: uses INT25/26 instead of the low level INT13 related kernel code from + floppy.asm (see also comments in sys.c) + a few fixes (also boot.asm related) + from Bart. + * Hopefully fixed DateTime Changed + ATTRIB |= ARCHIVE bug. + * cleaned up dsk.c and saved more bytes. + Przemyslaw Czerpak: + * Default lastdrive should be 5 (E) not 6 (F). + * fixed not ignoring whitespace after '=' in config.sys + * noted INT21/AX=3800 bug for getting the country. Put in a workaround for now. + 2001 Apr 21 - Build 2024 -------- Bart Oldeman (bart.oldeman@bristol.ac.uk) + Fixes Tom: * fixed a missing close_dir in fatfs.c. diff --git a/hdr/fnode.h b/hdr/fnode.h index fc829f00..80e9f928 100644 --- a/hdr/fnode.h +++ b/hdr/fnode.h @@ -36,6 +36,9 @@ static BYTE *fnode_hRcsId = "$Id$"; /* * $Log$ + * Revision 1.5 2001/04/29 17:34:40 bartoldeman + * A new SYS.COM/config.sys single stepping/console output/misc fixes. + * * Revision 1.4 2001/04/15 03:21:50 bartoldeman * See history.txt for the list of fixes. * @@ -97,12 +100,12 @@ struct f_node struct { - BOOL f_dmod:1; /* directory has been modified */ - BOOL f_droot:1; /* directory is the root */ - BOOL f_dnew:1; /* fnode is new and needs fill */ - BOOL f_ddir:1; /* fnode is assigned to dir */ - BOOL f_dfull:1; /* directory is full */ - BOOL f_dremote:1; /* Remote Fake FNode */ + BITS f_dmod:1; /* directory has been modified */ + BITS f_droot:1; /* directory is the root */ + BITS f_dnew:1; /* fnode is new and needs fill */ + BITS f_ddir:1; /* fnode is assigned to dir */ + BITS f_dfull:1; /* directory is full */ + BITS f_dremote:1; /* Remote Fake FNode */ } f_flags; /* file flags */ diff --git a/hdr/version.h b/hdr/version.h index 44de54fd..134597e3 100644 --- a/hdr/version.h +++ b/hdr/version.h @@ -44,4 +44,4 @@ static BYTE *date_hRcsId = "$Id$"; #define REVISION_MINOR 1 #define REVISION_SEQ 24 #define BUILD 2024 -#define SUB_BUILD "a" +#define SUB_BUILD "b" diff --git a/kernel/chario.c b/kernel/chario.c index ea3ac5e6..d801eea3 100644 --- a/kernel/chario.c +++ b/kernel/chario.c @@ -36,6 +36,9 @@ static BYTE *charioRcsId = "$Id$"; /* * $Log$ + * Revision 1.8 2001/04/29 17:34:40 bartoldeman + * A new SYS.COM/config.sys single stepping/console output/misc fixes. + * * Revision 1.7 2001/04/21 22:32:53 bartoldeman * Init DS=Init CS, fixed stack overflow problems and misc bugs. * @@ -135,10 +138,15 @@ static VOID kbfill(); struct dhdr FAR *finddev(); #endif +#ifdef __TURBOC__ +void __int__(int); /* TC 2.01 requires this. :( -- ror4 */ +#endif + /* Return a pointer to the first driver in the chain that * matches the attributes. + * not necessary because we have the syscon pointer. */ - +#if 0 struct dhdr FAR *finddev(UWORD attr_mask) { struct dhdr far *dh; @@ -152,24 +160,24 @@ struct dhdr FAR *finddev(UWORD attr_mask) /* return dev/null if no matching driver found */ return &nul_dev; } +#endif -#if 0 VOID cso(COUNT c) { - BYTE buf = c; - struct dhdr FAR *lpDevice; - + if (syscon->dh_attr & ATTR_FASTCON) { + _AL = c; + __int__(0x29); + return; + } CharReqHdr.r_length = sizeof(request); CharReqHdr.r_command = C_OUTPUT; CharReqHdr.r_count = 1; - CharReqHdr.r_trans = (BYTE FAR *) (&buf); + CharReqHdr.r_trans = (BYTE FAR *) (&c); CharReqHdr.r_status = 0; - execrh((request FAR *) & CharReqHdr, - lpDevice = (struct dhdr FAR *)finddev(ATTR_CONOUT)); + execrh((request FAR *) & CharReqHdr, syscon); if (CharReqHdr.r_status & S_ERROR) - char_error(&CharReqHdr, lpDevice); + char_error(&CharReqHdr, syscon); } -#endif VOID sto(COUNT c) @@ -183,18 +191,18 @@ VOID mod_sto(REG UCOUNT c) { if (c < ' ' && c != HT) { - sto('^'); - sto(c + '@'); + cso('^'); + cso(c + '@'); } else - sto(c); + cso(c); } VOID destr_bs(void) { - sto(BS); - sto(' '); - sto(BS); + cso(BS); + cso(' '); + cso(BS); } VOID Do_DosIdle_loop(void) @@ -230,7 +238,7 @@ BOOL con_break(void) CharReqHdr.r_status = 0; CharReqHdr.r_command = C_NDREAD; CharReqHdr.r_length = sizeof(request); - execrh((request FAR *) & CharReqHdr, (struct dhdr FAR *)finddev(ATTR_CONIN)); + execrh((request FAR *) & CharReqHdr, syscon); if (CharReqHdr.r_status & S_BUSY) return FALSE; if (CharReqHdr.r_ndbyte == CTL_C) @@ -272,14 +280,14 @@ VOID KbdFlush(void) CharReqHdr.r_status = 0; CharReqHdr.r_command = C_IFLUSH; CharReqHdr.r_length = sizeof(request); - execrh((request FAR *) & CharReqHdr, (struct dhdr FAR *)finddev(ATTR_CONIN)); + execrh((request FAR *) & CharReqHdr, syscon); } static VOID kbfill(keyboard FAR * kp, UCOUNT c, BOOL ctlf, UWORD * vp) { if (kp->kb_count > kp->kb_size) { - sto(BELL); + cso(BELL); return; } kp->kb_buf[kp->kb_count++] = c; @@ -290,7 +298,7 @@ static VOID kbfill(keyboard FAR * kp, UCOUNT c, BOOL ctlf, UWORD * vp) } else { - sto(c); + cso(c); if (c != HT) ++ * vp; else @@ -402,16 +410,16 @@ UCOUNT sti(keyboard FAR * kp) return kp->kb_count; case LF: - sto(CR); - sto(LF); + cso(CR); + cso(LF); break; case ESC: - sto('\\'); - sto(CR); - sto(LF); + cso('\\'); + cso(CR); + cso(LF); for (c = 0; c < cu_pos; c++) - sto(' '); + cso(' '); kp->kb_count = init_count; eof = FALSE; break; diff --git a/kernel/config.c b/kernel/config.c index f79e365a..65541b5f 100644 --- a/kernel/config.c +++ b/kernel/config.c @@ -80,6 +80,9 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.22 2001/04/29 17:34:40 bartoldeman + * A new SYS.COM/config.sys single stepping/console output/misc fixes. + * * Revision 1.21 2001/04/21 22:32:53 bartoldeman * Init DS=Init CS, fixed stack overflow problems and misc bugs. * @@ -235,7 +238,7 @@ struct config Config NFCBS, 0, "command.com", - " /P\r\n", + " /P /E:256\r\n", NLAST, NSTACKS, 128 @@ -258,7 +261,8 @@ static COUNT nPass; static BYTE szLine[256]; static BYTE szBuf[256]; -int singleStep; +int singleStep = FALSE; +int SkipAllConfig = FALSE; INIT VOID zumcb_init(mcb FAR * mcbp, UWORD size); INIT VOID mumcb_init(mcb FAR * mcbp, UWORD size); @@ -407,9 +411,11 @@ INIT void PreConfig(void) /* FCBp = (sfttbl FAR *) KernelAlloc(sizeof(sftheader) + Config.cfgFiles * sizeof(sft));*/ - sfthead = (sfttbl FAR *) + sfthead->sftt_next = (sfttbl FAR *) KernelAlloc(sizeof(sftheader) - + Config.cfgFiles * sizeof(sft)); + + (Config.cfgFiles-5) * sizeof(sft)); + sfthead->sftt_next->sftt_next = (sfttbl FAR *) - 1; + sfthead->sftt_next->sftt_count = Config.cfgFiles-5; CDSp = (cdstbl FAR *) KernelAlloc(0x58 * lastdrive); @@ -420,7 +426,7 @@ INIT void PreConfig(void) #ifdef DEBUG printf("Preliminary f_node allocated at at 0x%p\n",f_nodes); printf("Preliminary FCB table allocated at 0x%p\n",FCBp); - printf("Preliminary sft table allocated at 0x%p\n",sfthead); + printf("Preliminary sft table allocated at 0x%p\n",sfthead->sftt_next); printf("Preliminary CDS table allocated at 0x%p\n",CDSp); printf("Preliminary DPB table allocated at 0x%p\n",DPBp); #endif @@ -493,9 +499,11 @@ INIT void PostConfig(void) /* FCBp = (sfttbl FAR *) KernelAlloc(sizeof(sftheader) + Config.cfgFiles * sizeof(sft));*/ - sfthead = (sfttbl FAR *) + sfthead->sftt_next = (sfttbl FAR *) KernelAlloc(sizeof(sftheader) - + Config.cfgFiles * sizeof(sft)); + + (Config.cfgFiles-5) * sizeof(sft)); + sfthead->sftt_next->sftt_next = (sfttbl FAR *) - 1; + sfthead->sftt_next->sftt_count = Config.cfgFiles-5; CDSp = (cdstbl FAR *) KernelAlloc(0x58 * lastdrive); @@ -507,7 +515,7 @@ INIT void PostConfig(void) #ifdef DEBUG printf("f_node allocated at 0x%p\n",f_nodes); printf("FCB table allocated at 0x%p\n",FCBp); - printf("sft table allocated at 0x%p\n",sfthead); + printf("sft table allocated at 0x%p\n",sfthead->sftt_next); printf("CDS table allocated at 0x%p\n",CDSp); printf("DPB table allocated at 0x%p\n",DPBp); #endif @@ -695,18 +703,18 @@ INIT VOID DoConfig(VOID) if (pEntry->pass < 0 || pEntry->pass == nPass) { - if (!singleStep || !SkipLine(pLineStart)) + if ( !SkipLine(pLineStart)) { - skipwh(pLine); + pLine = skipwh(pLine); if ('=' != *pLine) CfgFailure(pLine); else - (*(pEntry->func)) (++pLine); + (*(pEntry->func)) (skipwh(pLine+1)); } } } - skipLine:nCfgLine++; + nCfgLine++; pLine += strlen(pLine) + 1; } } @@ -725,20 +733,124 @@ INIT struct table *LookUp(struct table *p, BYTE * token) return p; } -INIT BOOL SkipLine(char *pLine) +/* + get BIOS key with timeout: + + timeout < 0: no timeout + timeout = 0: poll only once + timeout > 0: timeout in seconds + + return + 0xffff : no key hit + + 0xHH.. : scancode in upper half + 0x..LL : asciicode in lower half +*/ + +ULONG GetBiosTime(VOID) { - char kbdbuf[16]; - char *pKbd = kbdbuf; + return *(ULONG FAR *)(MK_FP(0x40,0x6c)); +} +GetBiosKey(int timeout) +{ + iregs r; + + ULONG startTime = GetBiosTime(); - printf("%s [Y,N]?", pLine); - read(STDIN, kbdbuf, 12); + for (;;) + { + r.a.x = 0x0100; /* are there keys available ? */ + init_call_intr(0x16,&r); - pKbd = skipwh(pKbd); + if ((r.flags & 0x40) == 0) /* yes - fetch and return */ + { + r.a.x = 0x0000; + init_call_intr(0x16,&r); + + return r.a.x; + } + + if (timeout < 0) + continue; + + if (GetBiosTime() - startTime >= timeout*18) + break; + } + return 0xffff; +} - if (*pKbd == 'n' || *pKbd == 'N') +INIT BOOL SkipLine(char *pLine) +{ + short key; + + static char initialized = FALSE; + + if (!initialized) + { + + initialized = TRUE; + + printf("Press F8 to trace or F5 to skip CONFIG.SYS/AUTOEXEC.BAT"); + + key = GetBiosKey(2); /* wait 2 seconds */ + + if (key == 0x3f00) /* F5 */ + { + SkipAllConfig = TRUE; + } + if (key == 0x4200) /* F8 */ + { + singleStep = TRUE; + } + + printf("\r%79s\r",""); /* clear line */ + + if (SkipAllConfig) + printf("Skipping CONFIG.SYS/AUTOEXEC.BAT\n"); + } + + if (SkipAllConfig) return TRUE; - return FALSE; + if (!singleStep) + return FALSE; + + printf("%s[Y,N]?", pLine); + + for (;;) + { + key = GetBiosKey(-1); + + switch(toupper(key & 0x00ff)) + { + case 'N': + case 'n': + printf("N"); + return TRUE; + + case 0x1b: /* don't know where documented + ESCAPE answers all following questions + with YES + */ + singleStep = FALSE; /* and fall through */ + + case '\r': + case '\n': + case 'Y': + case 'y': + printf("Y"); + return FALSE; + + } + + if (key == 0x3f00) /* YES, you may hit F5 here, too */ + { + printf("N"); + SkipAllConfig = TRUE; + return TRUE; + } + } + } INIT BYTE *GetNumArg(BYTE * pLine, COUNT * pnArg) @@ -1102,13 +1214,36 @@ INIT BOOL LoadDevice(BYTE * pLine, COUNT top, COUNT mode) if (init_DosExec(3, &eb, szBuf) == SUCCESS) { strcpy(szBuf, pLine); - - /* add \r\n to the command line */ - strcat(szBuf, "\r\n"); /* TE this fixes the loading of devices drivers with multiple devices in it. NUMEGA's SoftIce is such a beast */ + + /* that's a nice hack >:-) + + although we don't want HIMEM.SYS,(it's not free), other people + might load HIMEM.SYS to see if they are compatible to it. + + if it's HIMEM.SYS, we won't survive TESTMEM:ON + + so simply add TESTMEM:OFF to the commandline + */ + + if (DosLoadedInHMA) + if (stristr(szBuf, "HIMEM.SYS") != NULL) + { + if (stristr(szBuf, "/TESTMEM:OFF") == NULL) + { + strcat(szBuf, " /TESTMEM:OFF"); + } + } + /* end of HIMEM.SYS HACK */ + + + /* add \r\n to the command line */ + strcat(szBuf, "\r\n"); + + for (next_dhp=NULL; FP_OFF(next_dhp) != 0xffff && (result=init_device(dhp, szBuf, mode, top))==SUCCESS ; dhp = next_dhp) diff --git a/kernel/dosfns.c b/kernel/dosfns.c index f32e838a..46e34e4f 100644 --- a/kernel/dosfns.c +++ b/kernel/dosfns.c @@ -37,6 +37,9 @@ static BYTE *dosfnsRcsId = "$Id$"; * /// Added SHARE support. 2000/09/04 Ron Cemer * * $Log$ + * Revision 1.17 2001/04/29 17:34:40 bartoldeman + * A new SYS.COM/config.sys single stepping/console output/misc fixes. + * * Revision 1.16 2001/04/21 22:32:53 bartoldeman * Init DS=Init CS, fixed stack overflow problems and misc bugs. * @@ -510,72 +513,49 @@ UCOUNT DosWrite(COUNT hndl, UCOUNT n, BYTE FAR * bp, COUNT FAR * err) else { REG WORD /*c,*/ - cnt = n, - spaces_left = 0, - next_pos, - xfer = 0; - static BYTE space = ' '; - - start: - if (cnt-- == 0) - goto end; - if (*bp == CTL_Z) - goto end; - if (s->sft_flags & SFT_FCONOUT) - { - switch (*bp) + cnt = n, + xfer = 0; + + while(cnt-- != 0 && *bp != CTL_Z){ + if (s->sft_flags & SFT_FCONOUT) { - case CR: - next_pos = 0; - break; - case LF: - case BELL: - next_pos = scr_pos; - break; - case BS: - next_pos = scr_pos ? scr_pos - 1 : 0; - break; - case HT: - spaces_left = 8 - (scr_pos & 7); - next_pos = scr_pos + spaces_left; - goto output_space; - default: - next_pos = scr_pos + 1; + switch (*bp) + { + case CR: + scr_pos = 0; + break; + case LF: + case BELL: + break; + case BS: + scr_pos = scr_pos ? scr_pos - 1 : 0; + break; + case HT: + do cso(' '); while ((++scr_pos) & 7); + default: + scr_pos++; + } + if (*bp != HT) cso(*bp); + } + else + { + rq.r_length = sizeof(request); + rq.r_command = C_OUTPUT; + rq.r_count = 1; + rq.r_trans = bp; + rq.r_status = 0; + execrh((request FAR *) & rq, s->sft_dev); + if (rq.r_status & S_ERROR) + char_error(&rq, s->sft_dev); + } + ++bp; + ++xfer; + if (break_ena && control_break()) + { + handle_break(); + break; } } - rq.r_length = sizeof(request); - rq.r_command = C_OUTPUT; - rq.r_count = 1; - rq.r_trans = bp; - rq.r_status = 0; - execrh((request FAR *) & rq, s->sft_dev); - if (rq.r_status & S_ERROR) - char_error(&rq, s->sft_dev); - goto post; - output_space: - rq.r_length = sizeof(request); - rq.r_command = C_OUTPUT; - rq.r_count = 1; - rq.r_trans = &space; - rq.r_status = 0; - execrh((request FAR *) & rq, s->sft_dev); - if (rq.r_status & S_ERROR) - char_error(&rq, s->sft_dev); - --spaces_left; - post: - if (spaces_left) - goto output_space; - ++bp; - ++xfer; - if (s->sft_flags & SFT_FCONOUT) - scr_pos = next_pos; - if (break_ena && control_break()) - { - handle_break(); - goto end; - } - goto start; - end: *err = SUCCESS; return xfer; } @@ -724,17 +704,17 @@ sft FAR *get_free_sft(WORD FAR * sft_idx) /* Get the SFT block that contains the SFT */ for (sp = sfthead; sp != (sfttbl FAR *) - 1; sp = sp->sftt_next) { - REG WORD i; + REG COUNT i = sp->sftt_count; + sft FAR *sfti = sp->sftt_table; - for (i = 0; i < sp->sftt_count; i++) + for(sys_idx += i; i >= 1 ; sfti++, i--) { - if (sp->sftt_table[i].sft_count == 0) + if (sfti->sft_count == 0) { - *sft_idx = sys_idx + i; - return (sft FAR *) & sp->sftt_table[sys_idx + i]; + *sft_idx = sys_idx - i; + return sfti; } } - sys_idx += i; } /* If not found, return an error */ return (sft FAR *) - 1; @@ -1251,12 +1231,75 @@ COUNT DosChangeDir(BYTE FAR * s) COUNT DosFindFirst(UCOUNT attr, BYTE FAR * name) { + COUNT nDrive; + REG dmatch FAR *dmp = (dmatch FAR *) dta; + + /* /// Added code here to do matching against device names. + DOS findfirst will match exact device names if the + filename portion (excluding the extension) contains + a valid device name. + Credits: some of this code was ripped off from truename() + in newstuff.c. + - Ron Cemer */ + fmemset(dmp, 0, sizeof(dmatch)); + + nDrive=get_verify_drive(name); + if (nDrive < 0) + return nDrive; + + current_ldt = &CDSp->cds_table[nDrive]; + if (current_ldt->cdsFlags & CDSNETWDRV) + { + COUNT rc = -Remote_find(REM_FINDFIRST, attr, name); + if (dmp->dm_drive & 0x80) + return rc; + fmemset(dmp, 0, sizeof(dmatch)); + /* still have to resolve locally if dm_drive not set to remote */ + } + if (IsDevice(name)) + { + /* Found a matching device. Hence there cannot be wildcards. */ + dmp->dm_attr_fnd = D_DEVICE; + dmp->dm_time = dos_gettime(); + dmp->dm_date = dos_getdate(); + fstrncpy(dmp->dm_name, get_root(name), FNAME_SIZE+FEXT_SIZE+1); + return SUCCESS; + } + /* /// End of additions. - Ron Cemer ; heavily edited - Bart Oldeman */ return dos_findfirst(attr, name); } COUNT DosFindNext(void) { - return dos_findnext(); + + /* /// findnext will always fail on a device name. - Ron Cemer */ + if (((dmatch FAR *)dta)->dm_attr_fnd == D_DEVICE) + return DE_NFILES; + +/* + * The new version of SHSUCDX 1.0 looks at the dm_drive byte to + * test 40h. I used RamView to see location MSD 116:04be and + * FD f??:04be, the byte set with 0xc4 = Remote/Network drive 4. + * Ralf Brown docs for dos 4eh say bit 7 set == remote so what is + * bit 6 for? + * SHSUCDX Mod info say "test redir not network bit". + * Just to confuse the rest, MSCDEX sets bit 5 too. + * + * So, assume bit 6 is redirector and bit 7 is network. + * jt + * Bart: dm_drive can be the drive _letter_. + * but better just stay independent of it: we only use + * bit 7 to detect a network drive; the rest untouched. + * RBIL says that findnext can only return one error type anyway + * (12h, DE_NFILES) + */ +#if 0 + printf("findnext: %d\n", + ((dmatch FAR *)dta)->dm_drive); +#endif + return (((dmatch FAR *)dta)->dm_drive & 0x80) ? + -Remote_find(REM_FINDNEXT, 0, NULL) : + dos_findnext(); } COUNT DosGetFtime(COUNT hndl, date FAR * dp, time FAR * tp) diff --git a/kernel/dsk.c b/kernel/dsk.c index 9688f404..59bbd6a0 100644 --- a/kernel/dsk.c +++ b/kernel/dsk.c @@ -32,6 +32,9 @@ static BYTE *dskRcsId = "$Id$"; /* * $Log$ + * Revision 1.16 2001/04/29 17:34:40 bartoldeman + * A new SYS.COM/config.sys single stepping/console output/misc fixes. + * * Revision 1.15 2001/04/16 01:45:26 bartoldeman * Fixed handles, config.sys drivers, warnings. Enabled INT21/AH=6C, printf %S/%Fs * @@ -172,18 +175,17 @@ BOOL fl_format(); extern BYTE FAR nblk_rel; + + /* this buffer must not overlap a 64K boundary + due to DMA transfers + this is certainly true, if located somewhere + at 0xf+1000 and must hold already during BOOT time + */ union { BYTE bytes[1 * SEC_SIZE]; boot boot_sector; -} buffer; - - /* if the buffer above is good enough for booting - it's also good enough for DMA input */ -BYTE /* scratchpad used for working around */ - FAR * dma_scratch_buffer = (BYTE FAR *)&buffer; /* DMA transfers during disk I/O */ - - +} DiskTransferBuffer; STATIC struct media_info @@ -194,17 +196,22 @@ STATIC struct media_info UWORD mi_sectors; /* number of sectors/cyl */ ULONG mi_offset; /* relative partition offset */ BYTE mi_drive; /* BIOS drive number */ - COUNT mi_partidx; /* Index to partition array */ ULONG mi_FileOC; /* Count of Open files on Drv */ -}; + + UWORD mi_BeginCylinder; + BYTE mi_BeginHead; + BYTE mi_BeginSector; -static struct FS_info -{ - ULONG fs_serialno; - BYTE fs_volume[11]; - BYTE fs_fstype[8]; + struct FS_info + { + ULONG serialno; + BYTE volume[11]; + BYTE fstype[8]; + }fs; }; + + static struct Access_info { BYTE AI_spec; @@ -212,7 +219,6 @@ static struct Access_info }; STATIC struct media_info miarray[NDEV]; /* Internal media info structs */ -STATIC struct FS_info fsarray[NDEV]; STATIC bpb bpbarray[NDEV]; /* BIOS parameter blocks */ STATIC bpb *bpbptrs[NDEV]; /* pointers to bpbs */ @@ -224,26 +230,9 @@ struct media_info *getPMiarray(int dev) { return &miarray[dev];} table partition */ STATIC COUNT nUnits; /* number of returned units */ -STATIC COUNT nPartitions; /* number of DOS partitions */ #define PARTOFF 0x1be -STATIC struct dos_partitionS -{ - BYTE peDrive; /* BIOS drive number */ - BYTE peBootable; - BYTE peBeginHead; - BYTE peBeginSector; - UWORD peBeginCylinder; - BYTE peFileSystem; - BYTE peEndHead; - BYTE peEndSector; - UWORD peEndCylinder; - LONG peStartSector; - LONG peSectors; - LONG peAbsStart; /* Absolute sector start */ -} -dos_partition[NDEV - 2]; #ifdef PROTO WORD _dsk_init(rqptr), @@ -376,12 +365,12 @@ ULONG StartSector(WORD ptDrive, unsigned BeginCylinder, if (startPos != oldStartPos) { - printf("PART TABLE mismatch for drive %x, CHS=%d %d %d, startsec %d, offset %ld\n", + PartCodePrintf(("PART TABLE mismatch for drive %x, CHS=%d %d %d, startsec %d, offset %ld\n", ptDrive, BeginCylinder, BeginHead,BeginSector, - peStartSector, ptAccuOff); + peStartSector, ptAccuOff)); - printf(" old startpos = %ld, new startpos = %ld, using new\n", - oldStartPos, startPos); + PartCodePrintf((" old startpos = %ld, new startpos = %ld, using new\n", + oldStartPos, startPos)); } return startPos; @@ -516,7 +505,7 @@ COUNT processtable(int table_type,COUNT ptDrive, BYTE ptHead, UWORD ptCylinder, for ( retry = N_RETRY; --retry >= 0; ) { ret = fl_read((WORD) ptDrive, (WORD) ptHead, (WORD) ptCylinder, - (WORD) ptSector, (WORD) 1, (byteptr) & buffer); + (WORD) ptSector, (WORD) 1, (byteptr) & DiskTransferBuffer); if (ret == 0) break; } @@ -525,7 +514,7 @@ COUNT processtable(int table_type,COUNT ptDrive, BYTE ptHead, UWORD ptCylinder, /* Read each partition into temporary array */ - p = (BYTE *) & buffer.bytes[PARTOFF]; + p = (BYTE *) & DiskTransferBuffer.bytes[PARTOFF]; for (ptemp_part = &temp_part[0]; ptemp_part < &temp_part[N_PART]; ptemp_part++) @@ -585,12 +574,10 @@ COUNT processtable(int table_type,COUNT ptDrive, BYTE ptHead, UWORD ptCylinder, ptemp_part->peFileSystem == FAT16SMALL || ptemp_part->peFileSystem == FAT16LARGE ) { - struct dos_partitionS *pdos_partition; struct media_info *pmiarray = getPMiarray(nUnits); pmiarray->mi_drive = ptDrive; - pmiarray->mi_partidx = nPartitions; pmiarray->mi_offset = StartSector(ptDrive, ptemp_part->peBeginCylinder, @@ -598,35 +585,14 @@ COUNT processtable(int table_type,COUNT ptDrive, BYTE ptHead, UWORD ptCylinder, ptemp_part->peBeginSector, ptemp_part->peStartSector, ptAccuOff); + + pmiarray->mi_BeginCylinder = ptemp_part->peBeginCylinder; + pmiarray->mi_BeginHead = ptemp_part->peBeginHead; + pmiarray->mi_BeginSector = ptemp_part->peBeginSector; + nUnits++; - pdos_partition = &dos_partition[nPartitions]; - - pdos_partition->peDrive = ptDrive; - pdos_partition->peBootable = ptemp_part->peBootable; - pdos_partition->peBeginHead = ptemp_part->peBeginHead; - pdos_partition->peBeginSector = ptemp_part->peBeginSector; - pdos_partition->peBeginCylinder=ptemp_part->peBeginCylinder; - pdos_partition->peFileSystem =ptemp_part->peFileSystem; - pdos_partition->peEndHead =ptemp_part->peEndHead; - pdos_partition->peEndSector =ptemp_part->peEndSector; - pdos_partition->peEndCylinder =ptemp_part->peEndCylinder; - pdos_partition->peStartSector =ptemp_part->peStartSector; - pdos_partition->peSectors =ptemp_part->peSectors; - pdos_partition->peAbsStart =ptemp_part->peStartSector + ptAccuOff; - - PartCodePrintf(("DOS PARTITION drive %x CHS %x-%x-%x %x-%x-%x %lx %lx %lx FS %x\n", - pdos_partition->peDrive, - pdos_partition->peBeginCylinder,pdos_partition->peBeginHead ,pdos_partition->peBeginSector , - pdos_partition->peEndCylinder ,pdos_partition->peEndHead ,pdos_partition->peEndSector , - pdos_partition->peStartSector , - pdos_partition->peSectors , - pdos_partition->peAbsStart , - pdos_partition->peFileSystem - )); - - nPartitions++; PartitionDone |= partMask; @@ -695,8 +661,6 @@ WORD _dsk_init(rqptr rp) /* Initial number of disk units */ nUnits = 2; - /* Initial number of DOS partitions */ - nPartitions = 0; /* Setup media info and BPBs arrays */ for (Unit = 0; Unit < NDEV; Unit++) @@ -709,8 +673,13 @@ WORD _dsk_init(rqptr rp) pmiarray->mi_sectors = 9; pmiarray->mi_offset = 0l; pmiarray->mi_drive = Unit; + + pmiarray->mi_BeginCylinder = 0; /* initialize for floppies */ + pmiarray->mi_BeginHead = 0; + pmiarray->mi_BeginSector = 1; + - fsarray[Unit].fs_serialno = 0x12345678l; + pmiarray->fs.serialno = 0x12345678l; pbpbarray = getPBpbarray(Unit); @@ -802,35 +771,17 @@ static WORD mediachk(rqptr rp) STATIC WORD RWzero(rqptr rp, WORD t) { REG retry = N_RETRY; - WORD head,track,sector,ret; - - - if (hd(miarray[rp->r_unit].mi_drive)) - { - COUNT partidx = miarray[rp->r_unit].mi_partidx; - head = dos_partition[partidx].peBeginHead; - track = dos_partition[partidx].peBeginCylinder; - sector = dos_partition[partidx].peBeginSector; - } - else - { - head = 0; - sector = 1; - track = 0; - } + WORD ret; + struct media_info *pmiarray = getPMiarray(rp->r_unit); do { - if (!t) /* 0 == Read */ - { - ret = fl_read((WORD) miarray[rp->r_unit].mi_drive, - (WORD) head, (WORD) track, (WORD) sector, (WORD) 1, (byteptr) & buffer); - } - else - { - ret = fl_write((WORD) miarray[rp->r_unit].mi_drive, - (WORD) head, (WORD) track, (WORD) sector, (WORD) 1, (byteptr) & buffer); - } + ret = (t == 0 ? fl_read : fl_write)( + (WORD) pmiarray->mi_drive, + (WORD) pmiarray->mi_BeginHead, + (WORD) pmiarray->mi_BeginCylinder, + (WORD) pmiarray->mi_BeginSector, + (WORD) 1, (byteptr) & DiskTransferBuffer); } while (ret != 0 && --retry > 0); return ret; @@ -885,10 +836,7 @@ static WORD blk_Media(rqptr rp) STATIC WORD bldbpb(rqptr rp) { - ULONG count/*, i*/; -/* byteptr trans;*/ -/* WORD local_word;*/ -/*TE*/ + ULONG count; bpb *pbpbarray; struct media_info *pmiarray; WORD head,/*track,*/sector,ret; @@ -901,31 +849,29 @@ STATIC WORD bldbpb(rqptr rp) /*TE ~ 200 bytes*/ pbpbarray = getPBpbarray(rp->r_unit); - getword(&((((BYTE *) & buffer.bytes[BT_BPB]))[BPB_NBYTE]), &pbpbarray->bpb_nbyte); - getbyte(&((((BYTE *) & buffer.bytes[BT_BPB]))[BPB_NSECTOR]), &pbpbarray->bpb_nsector); - getword(&((((BYTE *) & buffer.bytes[BT_BPB]))[BPB_NRESERVED]), &pbpbarray->bpb_nreserved); - getbyte(&((((BYTE *) & buffer.bytes[BT_BPB]))[BPB_NFAT]), &pbpbarray->bpb_nfat); - getword(&((((BYTE *) & buffer.bytes[BT_BPB]))[BPB_NDIRENT]), &pbpbarray->bpb_ndirent); - getword(&((((BYTE *) & buffer.bytes[BT_BPB]))[BPB_NSIZE]), &pbpbarray->bpb_nsize); - getword(&((((BYTE *) & buffer.bytes[BT_BPB]))[BPB_NSIZE]), &pbpbarray->bpb_nsize); - getbyte(&((((BYTE *) & buffer.bytes[BT_BPB]))[BPB_MDESC]), &pbpbarray->bpb_mdesc); - getword(&((((BYTE *) & buffer.bytes[BT_BPB]))[BPB_NFSECT]), &pbpbarray->bpb_nfsect); - getword(&((((BYTE *) & buffer.bytes[BT_BPB]))[BPB_NSECS]), &pbpbarray->bpb_nsecs); - getword(&((((BYTE *) & buffer.bytes[BT_BPB]))[BPB_NHEADS]), &pbpbarray->bpb_nheads); - getlong(&((((BYTE *) & buffer.bytes[BT_BPB])[BPB_HIDDEN])), &pbpbarray->bpb_hidden); - getlong(&((((BYTE *) & buffer.bytes[BT_BPB])[BPB_HUGE])), &pbpbarray->bpb_huge); + getword(&((((BYTE *) & DiskTransferBuffer.bytes[BT_BPB]))[BPB_NBYTE]), &pbpbarray->bpb_nbyte); + getbyte(&((((BYTE *) & DiskTransferBuffer.bytes[BT_BPB]))[BPB_NSECTOR]), &pbpbarray->bpb_nsector); + getword(&((((BYTE *) & DiskTransferBuffer.bytes[BT_BPB]))[BPB_NRESERVED]), &pbpbarray->bpb_nreserved); + getbyte(&((((BYTE *) & DiskTransferBuffer.bytes[BT_BPB]))[BPB_NFAT]), &pbpbarray->bpb_nfat); + getword(&((((BYTE *) & DiskTransferBuffer.bytes[BT_BPB]))[BPB_NDIRENT]), &pbpbarray->bpb_ndirent); + getword(&((((BYTE *) & DiskTransferBuffer.bytes[BT_BPB]))[BPB_NSIZE]), &pbpbarray->bpb_nsize); + getword(&((((BYTE *) & DiskTransferBuffer.bytes[BT_BPB]))[BPB_NSIZE]), &pbpbarray->bpb_nsize); + getbyte(&((((BYTE *) & DiskTransferBuffer.bytes[BT_BPB]))[BPB_MDESC]), &pbpbarray->bpb_mdesc); + getword(&((((BYTE *) & DiskTransferBuffer.bytes[BT_BPB]))[BPB_NFSECT]), &pbpbarray->bpb_nfsect); + getword(&((((BYTE *) & DiskTransferBuffer.bytes[BT_BPB]))[BPB_NSECS]), &pbpbarray->bpb_nsecs); + getword(&((((BYTE *) & DiskTransferBuffer.bytes[BT_BPB]))[BPB_NHEADS]), &pbpbarray->bpb_nheads); + getlong(&((((BYTE *) & DiskTransferBuffer.bytes[BT_BPB])[BPB_HIDDEN])), &pbpbarray->bpb_hidden); + getlong(&((((BYTE *) & DiskTransferBuffer.bytes[BT_BPB])[BPB_HUGE])), &pbpbarray->bpb_huge); + + + pmiarray = getPMiarray(rp->r_unit); /* Needs fat32 offset code */ - getlong(&((((BYTE *) & buffer.bytes[0x27])[0])), &fsarray[rp->r_unit].fs_serialno); -/*TE - for(i = 0; i < 11 ;i++ ) - fsarray[rp->r_unit].fs_volume[i] = buffer.bytes[0x2B + i]; - for(i = 0; i < 8; i++ ) - fsarray[rp->r_unit].fs_fstype[i] = buffer.bytes[0x36 + i]; -*/ - memcpy(fsarray[rp->r_unit].fs_volume,&buffer.bytes[0x2B], 11); - memcpy(fsarray[rp->r_unit].fs_fstype,&buffer.bytes[0x36], 8); + getlong(&((((BYTE *) & DiskTransferBuffer.bytes[0x27])[0])), &pmiarray->fs.serialno); + + memcpy(pmiarray->fs.volume,&DiskTransferBuffer.bytes[0x2B], 11); + memcpy(pmiarray->fs.fstype,&DiskTransferBuffer.bytes[0x36], 8); @@ -941,17 +887,16 @@ STATIC WORD bldbpb(rqptr rp) #endif rp->r_bpptr = pbpbarray; - pmiarray = getPMiarray(rp->r_unit); count = pmiarray->mi_size = pbpbarray->bpb_nsize == 0 ? pbpbarray->bpb_huge : pbpbarray->bpb_nsize; - getword((&(((BYTE *) & buffer.bytes[BT_BPB])[BPB_NHEADS])), &pmiarray->mi_heads); + getword((&(((BYTE *) & DiskTransferBuffer.bytes[BT_BPB])[BPB_NHEADS])), &pmiarray->mi_heads); head = pmiarray->mi_heads; - getword((&(((BYTE *) & buffer.bytes[BT_BPB])[BPB_NSECS])), &pmiarray->mi_sectors); + getword((&(((BYTE *) & DiskTransferBuffer.bytes[BT_BPB])[BPB_NSECS])), &pmiarray->mi_sectors); if (pmiarray->mi_size == 0) - getlong(&((((BYTE *) & buffer.bytes[BT_BPB])[BPB_HUGE])), &pmiarray->mi_size); + getlong(&((((BYTE *) & DiskTransferBuffer.bytes[BT_BPB])[BPB_HUGE])), &pmiarray->mi_size); sector = pmiarray->mi_sectors; if (head == 0 || sector == 0) @@ -1001,17 +946,19 @@ static WORD IoctlQueblk(rqptr rp) static WORD Genblkdev(rqptr rp) { int ret; + struct media_info *pmiarray = getPMiarray(rp->r_unit); + switch(rp->r_count){ case 0x0860: /* get device parameters */ { struct gblkio FAR * gblp = (struct gblkio FAR *) rp->r_trans; REG COUNT x = 5,y = 1,z = 0; - if (!hd(miarray[rp->r_unit].mi_drive)){ + if (!hd(pmiarray->mi_drive)){ y = 2; - x = 8; /* any odd ball drives return this */ - if (miarray[rp->r_unit].mi_size <= 0xffff) - switch((UWORD)miarray[rp->r_unit].mi_size) + x = 8; /* any odd ball drives return this */ + if (pmiarray->mi_size <= 0xffff) + switch((UWORD)pmiarray->mi_size) { case 640: case 720: /* 320-360 */ @@ -1035,7 +982,7 @@ static WORD Genblkdev(rqptr rp) gblp->gbio_devtype = (UBYTE) x; gblp->gbio_devattrib = (UWORD) y; gblp->gbio_media = (UBYTE) z; - gblp->gbio_ncyl = miarray[rp->r_unit].mi_cyls; + gblp->gbio_ncyl = pmiarray->mi_cyls; fmemcpy(&gblp->gbio_bpb, &bpbarray[rp->r_unit], sizeof(gblp->gbio_bpb)); gblp->gbio_nsecs = bpbarray[rp->r_unit].bpb_nsector; break; @@ -1043,24 +990,24 @@ static WORD Genblkdev(rqptr rp) case 0x0866: /* get volume serial number */ { struct Gioc_media FAR * gioc = (struct Gioc_media FAR *) rp->r_trans; - struct FS_info FAR * fs = &fsarray[rp->r_unit]; + struct FS_info FAR * fs = &pmiarray->fs; - gioc->ioc_serialno = fs->fs_serialno; - fmemcpy(gioc->ioc_volume,fs->fs_volume,11); - fmemcpy(gioc->ioc_fstype, fs->fs_fstype,8); + gioc->ioc_serialno = fs->serialno; + fmemcpy(gioc->ioc_volume,fs->volume,11); + fmemcpy(gioc->ioc_fstype, fs->fstype,8); } break; case 0x0846: /* set volume serial number */ { struct Gioc_media FAR * gioc = (struct Gioc_media FAR *) rp->r_trans; - struct FS_info FAR * fs = (struct FS_info FAR *) &buffer.bytes[0x27]; + struct FS_info FAR * fs = (struct FS_info FAR *) &DiskTransferBuffer.bytes[0x27]; ret = RWzero( rp, 0); if (ret != 0) return (dskerr(ret)); - fs->fs_serialno = gioc->ioc_serialno; - fsarray[rp->r_unit].fs_serialno = fs->fs_serialno; + fs->serialno = gioc->ioc_serialno; + pmiarray->fs.serialno = fs->serialno; ret = RWzero( rp, 1); if (ret != 0) @@ -1092,6 +1039,9 @@ WORD blockio(rqptr rp) WORD head,track,sector,ret,count; COUNT(*action) (WORD, WORD, WORD, WORD, WORD, BYTE FAR *); + + struct media_info *pmiarray = getPMiarray(rp->r_unit); + cmd = rp->r_command; total = 0; @@ -1099,7 +1049,7 @@ WORD blockio(rqptr rp) tmark(); remaining = rp->r_count; start = (rp->r_start != HUGECOUNT ? rp->r_start : rp->r_huge) - + miarray[rp->r_unit].mi_offset; + + pmiarray->mi_offset; while(remaining > 0) { count = ltop(&track, §or, &head, rp->r_unit, remaining, start, trans); @@ -1127,7 +1077,7 @@ WORD blockio(rqptr rp) if (count && FP_SEG(trans) != 0xffff) { - ret = action((WORD) miarray[rp->r_unit].mi_drive, head, track, sector, + ret = action((WORD) pmiarray->mi_drive, head, track, sector, count, trans); } else @@ -1137,14 +1087,14 @@ WORD blockio(rqptr rp) /* use scratchpad also, if going to HIGH memory */ if (cmd != C_INPUT) - fbcopy(trans, dma_scratch_buffer, SEC_SIZE); - ret = action((WORD) miarray[rp->r_unit].mi_drive, head, track, sector, - 1, dma_scratch_buffer); + fbcopy(trans, &DiskTransferBuffer, SEC_SIZE); + ret = action((WORD) pmiarray->mi_drive, head, track, sector, + 1, (byteptr)&DiskTransferBuffer); if (cmd == C_INPUT) - fbcopy(dma_scratch_buffer, trans, SEC_SIZE); + fbcopy(&DiskTransferBuffer, trans, SEC_SIZE); } if (ret != 0) - fl_reset((WORD) miarray[rp->r_unit].mi_drive); + fl_reset((WORD) pmiarray->mi_drive); } while (ret != 0 && --retry > 0); if (ret != 0) diff --git a/kernel/fatdir.c b/kernel/fatdir.c index e2e3cdd6..3f2de6da 100644 --- a/kernel/fatdir.c +++ b/kernel/fatdir.c @@ -36,6 +36,9 @@ static BYTE *fatdirRcsId = "$Id$"; /* * $Log$ + * Revision 1.15 2001/04/29 17:34:40 bartoldeman + * A new SYS.COM/config.sys single stepping/console output/misc fixes. + * * Revision 1.14 2001/04/15 03:21:50 bartoldeman * See history.txt for the list of fixes. * @@ -549,7 +552,7 @@ COUNT dir_write(REG struct f_node FAR * fnp) #endif } - /* Now that we have a block, transfer the diectory */ + /* Now that we have a block, transfer the directory */ /* entry into the block. */ if (bp == NULL) { @@ -660,54 +663,6 @@ COUNT dos_findfirst(UCOUNT attr, BYTE FAR * name) fbcopy((BYTE FAR *) SearchDir.dir_name, dmp->dm_name_pat, FNAME_SIZE + FEXT_SIZE); - - if (current_ldt->cdsFlags & CDSNETWDRV) - { - dmp->dm_drive |= 0x80; - return -Remote_find(REM_FINDFIRST, name, dmp); - } - - /* /// Added code here to do matching against device names. - DOS findfirst will match exact device names if the - filename portion (excluding the extension) contains - a valid device name. - Credits: some of this code was ripped off from truename() - in newstuff.c. - - Ron Cemer */ - if (!(attr & D_VOLID)) { - char Name[FNAME_SIZE]; - int d, wild = 0; - for (d = 0; d < FNAME_SIZE; d++) { - if ((Name[d] = SearchDir.dir_name[d]) == '?') { - wild = 1; - break; - } - } - if (!wild) { - if (IsDevice(Name)) { - /* Found a matching device. */ - dmp->dm_entry = 0; - dmp->dm_cluster = 0; - dmp->dm_flags.f_dmod = 0; - dmp->dm_flags.f_droot = 0; - dmp->dm_flags.f_dnew = 0; - dmp->dm_flags.f_ddir = 0; - dmp->dm_flags.f_dfull = 0; - dmp->dm_dirstart = 0; - dmp->dm_attr_fnd = D_DEVICE; - dmp->dm_time = dos_gettime(); - dmp->dm_date = dos_getdate(); - dmp->dm_size = 0L; - for (d = 0; ( (d < FNAME_SIZE) && (Name[d] != ' ') ); d++) - dmp->dm_name[d] = Name[d]; - dmp->dm_name[d] = '\0'; - return SUCCESS; - } - } - } - /* /// End of additions. - Ron Cemer */ - - /* Now search through the directory to find the entry... */ /* Complete building the directory from the passed in */ @@ -777,38 +732,6 @@ COUNT dos_findnext(void) REG struct f_node FAR *fnp; BOOL found = FALSE; - /* assign our match parameters pointer. */ - dmp = (dmatch FAR *) dta; - - /* /// findnext will always fail on a device name. - Ron Cemer */ - if (dmp->dm_attr_fnd == D_DEVICE) return DE_FILENOTFND; - -/* - * The new version of SHSUCDX 1.0 looks at the dm_drive byte to - * test 40h. I used RamView to see location MSD 116:04be and - * FD f??:04be, the byte set with 0xc4 = Remote/Network drive 4. - * Ralf Brown docs for dos 4eh say bit 7 set == remote so what is - * bit 6 for? - * SHSUCDX Mod info say "test redir not network bit". - * Just to confuse the rest, MSCDEX sets bit 5 too. - * - * So, assume bit 6 is redirector and bit 7 is network. - * jt - * Bart: dm_drive can be the drive _letter_. - * but better just stay independent of it: we only use - * bit 7 to detect a network drive; the rest untouched. - * RBIL says that findnext can only return one error type anyway - * (12h, DE_NFILES) - */ - -#if 0 - printf("findnext: %d\n", - dmp->dm_drive); -#endif - - if (dmp->dm_drive & 0x80) - return -Remote_find(REM_FINDNEXT, 0, dmp); - /* Allocate an fnode if possible - error return (0) if not. */ if ((fnp = get_f_node()) == (struct f_node FAR *)0) { diff --git a/kernel/fatfs.c b/kernel/fatfs.c index e3bb0921..3377a68c 100644 --- a/kernel/fatfs.c +++ b/kernel/fatfs.c @@ -36,6 +36,9 @@ BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.17 2001/04/29 17:34:40 bartoldeman + * A new SYS.COM/config.sys single stepping/console output/misc fixes. + * * Revision 1.16 2001/04/21 22:32:53 bartoldeman * Init DS=Init CS, fixed stack overflow problems and misc bugs. * @@ -341,6 +344,14 @@ COUNT dos_close(COUNT fd) if (fnp->f_mode != RDONLY) { + /*TE experimental */ + if (fnp->f_flags.f_dmod) + { + fnp->f_dir.dir_attrib |= D_ARCHIVE; + fnp->f_dir.dir_time = dos_gettime(); + fnp->f_dir.dir_date = dos_getdate(); + } + fnp->f_dir.dir_size = fnp->f_highwater; fnp->f_flags.f_dmod = TRUE; merge_file_changes(fnp, FALSE); /* /// Added - Ron Cemer */ @@ -1888,6 +1899,9 @@ UCOUNT writeblock(COUNT fd, VOID FAR * buffer, UCOUNT count, COUNT * err) fbcopy(buffer, (BYTE FAR *) & bp->b_buffer[fnp->f_boff], xfr_cnt); bp->b_flag |= BFR_DIRTY | BFR_VALID; + fnp->f_flags.f_dmod = TRUE; /* mark file as modified */ + + /* update pointers and counters */ ret_cnt += xfr_cnt; to_xfer -= xfr_cnt; diff --git a/kernel/init-mod.h b/kernel/init-mod.h index 36289c69..2fcbc7fe 100644 --- a/kernel/init-mod.h +++ b/kernel/init-mod.h @@ -69,7 +69,7 @@ extern fmemcmp(BYTE far *s1, BYTE FAR *s2, unsigned len); #define NFILES 16 /* number of files in table */ #define NFCBS 16 /* number of fcbs */ #define NSTACKS 8 /* number of stacks */ -#define NLAST 6 /* last drive */ +#define NLAST 5 /* last drive */ #define NUMBUFF 6 /* Number of track buffers */ /* -- must be at least 3 */ @@ -144,7 +144,8 @@ VOID FAR *HMAalloc(COUNT bytesToAllocate); UWORD init_oem(void); /* intr.asm */ -/* void init_call_intr(int nr, iregs *rp); */ + +void init_call_intr(int nr, iregs *rp); UCOUNT read(int fd, void *buf, UCOUNT count); int open(const char *pathname, int flags); int close(int fd); diff --git a/kernel/inithma.c b/kernel/inithma.c index effb6aa3..30fd2424 100644 --- a/kernel/inithma.c +++ b/kernel/inithma.c @@ -80,6 +80,9 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.6 2001/04/29 17:34:40 bartoldeman + * A new SYS.COM/config.sys single stepping/console output/misc fixes. + * * Revision 1.5 2001/04/21 22:32:53 bartoldeman * Init DS=Init CS, fixed stack overflow problems and misc bugs. * @@ -494,6 +497,7 @@ void InstallVDISK(VOID) setvec(0x19, MK_FP(0xffff,0x0010)); /* let INT 19 point to VDISK */ + *(WORD FAR *)MK_FP(0xffff,0x002e) = 1024+64; } diff --git a/kernel/inthndlr.c b/kernel/inthndlr.c index bd92f90e..0526c940 100644 --- a/kernel/inthndlr.c +++ b/kernel/inthndlr.c @@ -37,6 +37,9 @@ BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.23 2001/04/29 17:34:40 bartoldeman + * A new SYS.COM/config.sys single stepping/console output/misc fixes. + * * Revision 1.22 2001/04/21 22:32:53 bartoldeman * Init DS=Init CS, fixed stack overflow problems and misc bugs. * @@ -961,7 +964,11 @@ VOID int21_service(iregs FAR * r) /* Get Country Information */ if((rc = DosGetCountryInformation(cntry, FP_DS_DX)) < 0) goto error_invalid; - r->AX = r->BX = cntry; + /* HACK FIXME */ + if(cntry == (UWORD)-1) + cntry = 1; + /* END OF HACK */ + r->AX = r->BX = cntry; } } break; diff --git a/kernel/intr.asm b/kernel/intr.asm index 362d831e..6783b90a 100644 --- a/kernel/intr.asm +++ b/kernel/intr.asm @@ -97,7 +97,6 @@ _int3: segment INIT_TEXT -%if 0 ; ; void init_call_intr(nr, rp) ; REG int nr @@ -159,7 +158,6 @@ init_intr?1: ret -%endif ; ; int init_call_XMScall( (WORD FAR * driverAddress)(), WORD AX, WORD DX) ; @@ -297,4 +295,4 @@ _allocmem: mov [bx], ax xor ax, ax ret - \ No newline at end of file + diff --git a/kernel/io.asm b/kernel/io.asm index 41bee9b4..37fec88c 100644 --- a/kernel/io.asm +++ b/kernel/io.asm @@ -28,6 +28,9 @@ ; $Header$ ; ; $Log$ +; Revision 1.9 2001/04/29 17:34:40 bartoldeman +; A new SYS.COM/config.sys single stepping/console output/misc fixes. +; ; Revision 1.8 2001/04/21 22:32:53 bartoldeman ; Init DS=Init CS, fixed stack overflow problems and misc bugs. ; @@ -81,6 +84,8 @@ extern _reloc_call_blk_driver extern _reloc_call_clk_driver + extern _TEXT_DGROUP:wrt TGROUP + ;--------------------------------------------------- ; ; Device entry points @@ -223,12 +228,13 @@ DiskTable db 0 ; ; Local storage ; - +%if 0 segment _BSS blk_dos_stk resw 1 blk_dos_seg resw 1 clk_dos_stk resw 1 clk_dos_seg resw 1 +%endif segment _IO_TEXT global _ReqPktPtr @@ -539,38 +545,71 @@ GetUnitNum: ; NOTE: This code is not standard device driver handlers ; It is written for sperate code and data space. ; + +blk_driver_params: + dw blk_stk_top + dw _reloc_call_blk_driver + dw seg _reloc_call_blk_driver + +clk_driver_params: + dw clk_stk_top + dw _reloc_call_clk_driver + dw seg _reloc_call_clk_driver + + ; clock device interrupt +clk_entry: + pushf + push bx + + mov bx, clk_driver_params + + jmp short clk_and_blk_common + + + ; block device interrupt blk_entry: pushf - push ax push bx - push ds + + mov bx, blk_driver_params + +clk_and_blk_common: + + push ax + push cx + push dx ; small model - mov ax,DGROUP ; correct for segments - mov ds,ax ; ax to carry segment - mov word [blk_dos_stk],sp ; use internal stack - mov word [blk_dos_seg],ss - pushf ; put flags in bx - pop bx + mov ax,sp ; use internal stack + mov dx,ss + pushf ; put flags in cx + pop cx cli ; no interrupts - mov ss,ax - mov sp,blk_stk_top - push bx + mov ss,[cs:_TEXT_DGROUP] + mov sp,[cs:bx] + + push cx popf ; restore interrupt flag + + - - push cx ; push these registers on - push dx ; BLK_STACK + push ax ; save old SS/SP + push dx + + ; push these registers on + push ds ; BLK_STACK push bp ; to save stack space push si push di push es + + mov ds,[cs:_TEXT_DGROUP] ; push word [cs:_ReqPktPtr+2] push word [cs:_ReqPktPtr] - call far _reloc_call_blk_driver + call far [cs:bx+2] pop cx pop cx @@ -582,74 +621,21 @@ blk_entry: pop di pop si pop bp - pop dx - pop cx - - cli ; no interrupts - mov sp,[blk_dos_stk] ; use dos stack - mov ss,[blk_dos_seg] - - pop ds - pop bx - pop ax - popf - retf - - + + pop dx ; get back old SS/SP + pop ax + + cli ; no interrupts + mov ss,dx ; use dos stack + mov sp,ax - ; - ; clock device interrupt - ; - ; NOTE: This code is not standard device driver handlers - ; It is written for sperate code and data space. - ; -clk_entry: - pushf - push ax - push bx - push cx - push dx - push bp - push si - push di - push ds - push es - - ; small model - mov ax,DGROUP ; correct for segments - mov ds,ax ; ax to carry segment - mov word [clk_dos_stk],sp ; use internal stack - mov word [clk_dos_seg],ss - pushf ; put flags in bx - pop bx - cli ; no interrupts - mov ss,ax - mov sp,clk_stk_top - push bx - popf ; restore interrupt flag - mov bp,sp ; make a c frame - push word [cs:_ReqPktPtr+2] - push word [cs:_ReqPktPtr] - call far _reloc_call_clk_driver - pop cx - pop cx - les bx,[cs:_ReqPktPtr] ; now return completion code - mov word [es:bx+status],ax ; mark operation complete - cli ; no interrupts - mov sp,[clk_dos_stk] ; use dos stack - mov ss,[clk_dos_seg] - pop es - pop ds - pop di - pop si - pop bp pop dx pop cx - pop bx pop ax + pop bx popf retf diff --git a/kernel/kernel.asm b/kernel/kernel.asm index 24e02abb..e280b545 100644 --- a/kernel/kernel.asm +++ b/kernel/kernel.asm @@ -28,6 +28,9 @@ ; $Id$ ; ; $Log$ +; Revision 1.12 2001/04/29 17:34:40 bartoldeman +; A new SYS.COM/config.sys single stepping/console output/misc fixes. +; ; Revision 1.11 2001/04/22 01:19:34 bartoldeman ; Avoid sys warning and have a VDISK signature in the HMA ; @@ -270,7 +273,8 @@ _first_mcb dw 0 ;-0002 Start of user memory MARK0026H equ $ _DPBp dd 0 ; 0000 First drive Parameter Block global _sfthead -_sfthead dd 0 ; 0004 System File Table head +_sfthead dw _firstsftt ; 0004 System File Table head + dw seg _firstsftt global _clock _clock dd 0 ; 0008 CLOCK$ device global _syscon @@ -333,7 +337,12 @@ _uppermem_root dw 0 ; 0066 dmd_upper_root _umb_start dw 0 ; 0068 para of last mem search SysVarEnd: -; We've got (01fb-006a) some room here: don't use all zeros! +;; The first 5 sft entries appear to have to be at DS:00cc + times (0cch - ($ - DATASTART)) db 0 + global _firstsftt +_firstsftt: + dd -1 ; link to next + dw 5 ; count ; Some references seem to indicate that this data should start at 01fbh in ; order to maintain 100% MS-DOS compatibility. @@ -670,10 +679,8 @@ __HMATextStart: ; segment HMA_TEXT begin_hma: - times 13h db 0 ; filler [ffff:0..ffff:12] - db 'VDISK',0 ; VDISK3.3 signature at ffff:0013 - times (2eh-($-begin_hma)) db 0 - dw 1088 ; 0x2e: first free kb position for extended memory + times 10h db 0 ; filler [ffff:0..ffff:10] + times 20h db 0 db 0 init_ret_np: push ds @@ -1006,7 +1013,16 @@ FAIL equ 03h _int24_handler: mov al,FAIL iret +; +; this makes some things easier +; +segment _TEXT + global _TEXT_DGROUP +_TEXT_DGROUP dw DGROUP +segment INIT_TEXT + global _INIT_DGROUP +_INIT_DGROUP dw DGROUP diff --git a/kernel/main.c b/kernel/main.c index 3ad987b6..2963bcca 100644 --- a/kernel/main.c +++ b/kernel/main.c @@ -41,9 +41,6 @@ extern UBYTE FAR nblkdev, FAR lastdrive; /* value of last drive */ -GLOBAL struct f_node FAR - * FAR f_nodes; /* pointer to the array */ - GLOBAL BYTE FAR os_major, /* major version number */ FAR os_minor, /* minor version number */ @@ -55,10 +52,8 @@ GLOBAL BYTE FAR os_release[]; GLOBAL BYTE FAR copyright[]; GLOBAL seg FAR RootPsp; /* Root process -- do not abort */ -GLOBAL struct f_node * FAR pDirFileNode; extern struct dpb FAR * FAR DPBp; /* First drive Parameter Block */ extern cdstbl FAR * FAR CDSp; /* Current Directory Structure */ -extern sfttbl FAR * FAR sfthead; /* System File Table head */ extern struct dhdr FAR * FAR clock, /* CLOCK$ device */ FAR * FAR syscon; /* console device */ @@ -76,6 +71,9 @@ static BYTE *mainRcsId = "$Id$"; /* * $Log$ + * Revision 1.16 2001/04/29 17:34:40 bartoldeman + * A new SYS.COM/config.sys single stepping/console output/misc fixes. + * * Revision 1.15 2001/04/21 22:32:53 bartoldeman * Init DS=Init CS, fixed stack overflow problems and misc bugs. * @@ -351,15 +349,7 @@ INIT VOID FsConfig(VOID) /* The system file tables need special handling and are "hand */ /* built. Included is the stdin, stdout, stdaux and stdprn. */ - sfthead->sftt_next = (sfttbl FAR *) - 1; - sfthead->sftt_count = Config.cfgFiles; - for (i = 0; i < Config.cfgFiles; i++) - { - /* Initialize the file tables */ - f_nodes[i].f_count = 0; - sfthead->sftt_table[i].sft_count = 0; - sfthead->sftt_table[i].sft_status = -1; - } + /* 0 is /dev/con (stdin) */ open("CON", O_RDWR); @@ -406,6 +396,20 @@ INIT VOID FsConfig(VOID) pcds_table->cdsJoinOffset = 2; } + /* + this is a quick patch - see if B: exists + test for A: also, need not exist + */ + { + iregs r; + + init_call_intr(0x11,&r); /* get equipment list */ + if ((r.a.x & 1)==0 || ((r.a.x & 1) && (r.a.x & 0xc0)==0)) + /* no floppy drives installed or no B: drive */ + CDSp->cds_table[1].cdsFlags = 0; + if ((r.a.x & 1)==0) /* no floppy drives installed */ + CDSp->cds_table[0].cdsFlags = 0; + } /* Initialize the disk buffer management functions */ /* init_call_init_buffers(); done from CONFIG.C */ } @@ -462,17 +466,63 @@ INIT void kernel() fmemcpy(MK_FP(exb.exec.env_seg, 0), master_env, sizeof(master_env)); #endif #endif + RootPsp = ~0; + + /* process 0 */ /* Execute command.com /P from the drive we just booted from */ - fstrncpy(Cmd.ctBuffer, Config.cfgInitTail, sizeof(Config.cfgInitTail)-1); + fstrncpy(Cmd.ctBuffer, Config.cfgInitTail, + sizeof(Config.cfgInitTail)-1); for (Cmd.ctCount = 0; Cmd.ctCount < 127; Cmd.ctCount++) if (Cmd.ctBuffer[Cmd.ctCount] == '\r') break; + + + + /* if stepping CONFIG.SYS (F5/F8), tell COMMAND.COM about it */ + + if (Cmd.ctCount < 127 - 3) + { + extern int singleStep ; + extern int SkipAllConfig; + char *insertString = NULL; + + if (singleStep) insertString = " /Y"; /* single step AUTOEXEC */ + + if (SkipAllConfig) insertString = " /D"; /* disable AUTOEXEC */ + + if (insertString) + { + + /* insert /D, /Y as first argument */ + int cmdEnd,i,slen = strlen(insertString); + + for (cmdEnd = 0;cmdEnd < 127; cmdEnd++) + { + if (Cmd.ctBuffer[cmdEnd] == ' ' || + Cmd.ctBuffer[cmdEnd] == '\t' || + Cmd.ctBuffer[cmdEnd] == '\r') + { + for (i = 127 - slen; i >= cmdEnd; i--) + Cmd.ctBuffer[i+slen] = Cmd.ctBuffer[i]; + + fmemcpy(&Cmd.ctBuffer[cmdEnd], insertString,slen); + + Cmd.ctCount += slen; + + break; + } + } + } + } + + + exb.exec.cmd_line = (CommandTail FAR *) & Cmd; exb.exec.fcb_1 = exb.exec.fcb_2 = (fcb FAR *) 0; @@ -483,7 +533,7 @@ INIT void kernel() while ((rc = init_DosExec(Config.cfgP_0_startmode, &exb, Config.cfgInit)) != SUCCESS) { BYTE *pLine; - printf("\nBad or missing Command Interpreter: %d\n", rc); + printf("\nBad or missing Command Interpreter: %d - %s\n", rc, Cmd.ctBuffer); printf("\nPlease enter the correct location (for example C:\\COMMAND.COM):\n"); rc = read(STDIN, Cmd.ctBuffer, sizeof(Cmd.ctBuffer)-1); Cmd.ctBuffer[rc]='\0'; diff --git a/kernel/network.c b/kernel/network.c index 0c5f7631..f990678c 100644 --- a/kernel/network.c +++ b/kernel/network.c @@ -36,6 +36,9 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.12 2001/04/29 17:34:40 bartoldeman + * A new SYS.COM/config.sys single stepping/console output/misc fixes. + * * Revision 1.11 2001/04/15 03:21:50 bartoldeman * See history.txt for the list of fixes. * @@ -125,16 +128,14 @@ UCOUNT Remote_RW(UWORD func, UCOUNT n, BYTE FAR * bp, sft FAR * s, COUNT FAR * e /* */ -COUNT Remote_find(UWORD func, BYTE FAR * name, REG dmatch FAR * dmp ) +COUNT Remote_find(UWORD func, UCOUNT attr, BYTE FAR * name) { COUNT i; char FAR *p; - VOID FAR * test; - struct dirent FAR *SDp = (struct dirent FAR *) &SearchDir; if (func == REM_FINDFIRST) { - test = (VOID FAR *) current_ldt; + SAttr = attr; i = truename(name, PriPathName, FALSE); if (i != SUCCESS) { return i; @@ -147,25 +148,23 @@ COUNT Remote_find(UWORD func, BYTE FAR * name, REG dmatch FAR * dmp ) printf("'\n"); #endif } - else - test = (VOID FAR *) &TempBuffer; - fmemcpy((BYTE FAR *) &TempBuffer, dta, 21); + fmemcpy(TempBuffer, dta, 21); p = dta; - dta = (BYTE FAR *) &TempBuffer; - i = int2f_Remote_call(func, 0, 0, 0, test, 0, 0); + dta = (BYTE FAR *)TempBuffer; + i = int2f_Remote_call(func, 0, 0, 0, (VOID FAR *)current_ldt, 0, 0); dta = p; - fmemcpy(dta, (BYTE FAR *) &TempBuffer, 21); + fmemcpy(dta, TempBuffer, 21); if (i != 0) return i; - dmp->dm_attr_fnd = (BYTE) SDp->dir_attrib; - dmp->dm_time = SDp->dir_time; - dmp->dm_date = SDp->dir_date; - dmp->dm_size = (LONG) SDp->dir_size; + ((dmatch FAR *)dta)->dm_attr_fnd = (BYTE) SearchDir.dir_attrib; + ((dmatch FAR *)dta)->dm_time = SearchDir.dir_time; + ((dmatch FAR *)dta)->dm_date = SearchDir.dir_date; + ((dmatch FAR *)dta)->dm_size = (LONG) SearchDir.dir_size; - ConvertName83ToNameSZ((BYTE FAR *) dmp->dm_name, (BYTE FAR *) SDp->dir_name); + ConvertName83ToNameSZ(((dmatch FAR *)dta)->dm_name, (BYTE *)SearchDir.dir_name); return i; } diff --git a/kernel/prf.c b/kernel/prf.c index 3f72bacb..1274bd75 100644 --- a/kernel/prf.c +++ b/kernel/prf.c @@ -48,6 +48,9 @@ static BYTE *prfRcsId = "$Id$"; /* * $Log$ + * Revision 1.10 2001/04/29 17:34:40 bartoldeman + * A new SYS.COM/config.sys single stepping/console output/misc fixes. + * * Revision 1.9 2001/04/21 22:32:53 bartoldeman * Init DS=Init CS, fixed stack overflow problems and misc bugs. * @@ -67,6 +70,9 @@ static BYTE *prfRcsId = "$Id$"; * recoded for smaller object footprint, added main() for testing+QA * * $Log$ + * Revision 1.10 2001/04/29 17:34:40 bartoldeman + * A new SYS.COM/config.sys single stepping/console output/misc fixes. + * * Revision 1.9 2001/04/21 22:32:53 bartoldeman * Init DS=Init CS, fixed stack overflow problems and misc bugs. * @@ -152,6 +158,17 @@ VOID cso(); void __int__(int); /* TC 2.01 requires this. :( -- ror4 */ #endif +#ifdef FORSYS +COUNT fstrlen (BYTE FAR * s) /* don't want globals.h, sorry */ +{ + int i = 0; + + while (*s++) + i++; + + return i; +} +#endif /* special console output routine */ VOID @@ -159,10 +176,14 @@ put_console(COUNT c) { if (c == '\n') put_console('\r'); - + +#ifdef FORSYS + write(1,&c,1); /* write character to stdout */ +#else _AX = 0x0e00 | c; _BX = 0x0070; __int__(0x10); +#endif } /* special handler to switch between sprintf and printf */ @@ -336,6 +357,7 @@ COUNT p = *((BYTE FAR **) arg)++; goto do_outputstring; + case 'i': case 'd': base = -10; goto lprt; @@ -348,6 +370,7 @@ COUNT base = 10; goto lprt; + case 'X': case 'x': base = 16; diff --git a/kernel/proto.h b/kernel/proto.h index 7368b4f6..b9471b10 100644 --- a/kernel/proto.h +++ b/kernel/proto.h @@ -34,6 +34,9 @@ static BYTE *Proto_hRcsId = "$Id$"; /* * $Log$ + * Revision 1.16 2001/04/29 17:34:40 bartoldeman + * A new SYS.COM/config.sys single stepping/console output/misc fixes. + * * Revision 1.15 2001/04/21 22:32:53 bartoldeman * Init DS=Init CS, fixed stack overflow problems and misc bugs. * @@ -184,7 +187,7 @@ UWORD dskxfer(COUNT dsk, ULONG blkno, VOID FAR * buf, UWORD numblocks, COUNT mod /* *** End of change /* chario.c */ -/* VOID cso(COUNT c);*/ +VOID cso(COUNT c); VOID sto(COUNT c); VOID mod_sto(REG UCOUNT c); VOID destr_bs(void); @@ -481,7 +484,7 @@ COUNT QRemote_Fn(char FAR * s, char FAR * d); UWORD get_machine_name(BYTE FAR * netname); VOID set_machine_name(BYTE FAR * netname, UWORD name_num); UCOUNT Remote_RW(UWORD func, UCOUNT n, BYTE FAR * bp, sft FAR * s, COUNT FAR * err); -COUNT Remote_find(UWORD func, BYTE FAR * name, REG dmatch FAR * dmp); +COUNT Remote_find(UWORD func, UCOUNT attr, BYTE FAR * name); /* procsupt.asm */ VOID INRPT FAR exec_user(iregs FAR * irp); diff --git a/kernel/segs.inc b/kernel/segs.inc index 997a368c..9aea54c4 100644 --- a/kernel/segs.inc +++ b/kernel/segs.inc @@ -29,6 +29,9 @@ ; $Header$ ; ; $Log$ +; Revision 1.7 2001/04/29 17:34:40 bartoldeman +; A new SYS.COM/config.sys single stepping/console output/misc fixes. +; ; Revision 1.6 2001/04/21 22:32:53 bartoldeman ; Init DS=Init CS, fixed stack overflow problems and misc bugs. ; @@ -78,7 +81,7 @@ segment _DATA class=DATA align=2 segment _BSSSTART class=BSS align=2 segment _BSS class=BSS align=2 segment _BSSEND class=BSS -segment HMA_TEXT_START class=HMA +segment HMA_TEXT_START class=HMA align=16 segment HMA_TEXT class=HMA segment HMA_TEXT_END class=HMA segment INIT_TEXT_START class=INIT align=16 diff --git a/sys/sys.mak b/sys/sys.mak index 9f5e0bb1..80f72b2f 100644 --- a/sys/sys.mak +++ b/sys/sys.mak @@ -4,6 +4,9 @@ # $Id$ # # $Log$ +# Revision 1.8 2001/04/29 17:34:41 bartoldeman +# A new SYS.COM/config.sys single stepping/console output/misc fixes. +# # Revision 1.7 2001/04/15 03:21:50 bartoldeman # See history.txt for the list of fixes. # @@ -46,7 +49,7 @@ !include "..\config.mak" CFLAGS = -mt -1- -v -vi- -k- -f- -ff- -O -Z -d -I$(INCLUDEPATH);..\hdr \ - -DI86;PROTO + -DI86;PROTO;FORSYS # *Implicit Rules* .c.obj: @@ -57,11 +60,10 @@ CFLAGS = -mt -1- -v -vi- -k- -f- -ff- -O -Z -d -I$(INCLUDEPATH);..\hdr \ # *List Macros* -LIBS = floppy.obj EXE_dependencies = \ sys.obj \ - floppy.obj + prf.obj # *Explicit Rules* production: ..\bin\sys.com @@ -75,11 +77,14 @@ b_fat12.h: ..\boot\b_fat12.bin bin2c.com b_fat16.h: ..\boot\b_fat16.bin bin2c.com bin2c ..\boot\b_fat16.bin b_fat16.h b_fat16 -floppy.obj: ..\drivers\floppy.asm - $(NASM) -fobj -DSYS=1 ..\drivers\floppy.asm -o floppy.obj +#floppy.obj: ..\drivers\floppy.asm +# $(NASM) -fobj -DSYS=1 ..\drivers\floppy.asm -o floppy.obj + +prf.obj: ..\kernel\prf.c + $(CC) $(CFLAGS) -c ..\kernel\prf.c sys.com: $(EXE_dependencies) - $(LINK) /m/t/c $(LIBPATH)\c0t.obj+sys.obj+$(LIBS),sys,,\ + $(LINK) /m/t/c $(LIBPATH)\c0t.obj+$(EXE_dependencies),sys,,\ $(CLIB); clobber: clean From f52e31f5c5927422728ef6cc85117cfeeecefd36 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sun, 29 Apr 2001 17:34:41 +0000 Subject: [PATCH 080/671] /* Revision 2.1 tomehlert 2001/4/26 changed the file system detection code. */ /* Revision 2.0 tomehlert 2001/4/26 no direct access to the disk any more, this is FORMAT's job no floppy.asm anymore, no segmentation problems. no access to partition tables instead copy boot sector using int25/int26 = absdiskread()/write if xxDOS is able to handle the disk, SYS should work additionally some space savers: replaced fopen() by open() included (slighly modified) PRF.c from kernel size is no ~7500 byte vs. ~13690 before */ git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@217 6ac86273-5f31-0410-b378-82cca8765d1b --- sys/sys.c | 569 +++++++++++++++--------------------------------------- 1 file changed, 159 insertions(+), 410 deletions(-) diff --git a/sys/sys.c b/sys/sys.c index 7114bc6c..4cd08d06 100644 --- a/sys/sys.c +++ b/sys/sys.c @@ -25,11 +25,55 @@ 675 Mass Ave, Cambridge, MA 02139, USA. ***************************************************************/ +/* Revision 2.0 tomehlert 2001/4/26 + + no direct access to the disk any more, this is FORMAT's job + no floppy.asm anymore, no segmentation problems. + no access to partition tables + + instead copy boot sector using int25/int26 = absdiskread()/write + + if xxDOS is able to handle the disk, SYS should work + + additionally some space savers: + + replaced fopen() by open() + + included (slighly modified) PRF.c from kernel + + size is no ~7500 byte vs. ~13690 before + +*/ /* $Log$ - * Revision 1.5 2001/03/25 17:11:54 bartoldeman - * Fixed sys.com compilation. Updated to 2023. Also: see history.txt. + * Revision 1.6 2001/04/29 17:34:41 bartoldeman + * /* Revision 2.1 tomehlert 2001/4/26 * + * changed the file system detection code. + * */ + * + * /* Revision 2.0 tomehlert 2001/4/26 + * + * no direct access to the disk any more, this is FORMAT's job + * no floppy.asm anymore, no segmentation problems. + * no access to partition tables + * + * instead copy boot sector using int25/int26 = absdiskread()/write + * + * if xxDOS is able to handle the disk, SYS should work + * + * additionally some space savers: + * + * replaced fopen() by open() + * + * included (slighly modified) PRF.c from kernel + * + * size is no ~7500 byte vs. ~13690 before + * */ + * +/* Revision 1.5 2001/03/25 17:11:54 bartoldeman +/* Fixed sys.com compilation. Updated to 2023. Also: see history.txt. +/* /* Revision 1.4 2000/08/06 05:50:17 jimtabor /* Add new files and update cvs with patches and changes /* @@ -80,108 +124,42 @@ * */ +/* + TE thinks, that the boot info storage should be done by FORMAT, noone else + + unfortunately, that doesn't work ??? +*/ #define STORE_BOOT_INFO +#define DEBUG + #include #include #include -/*#include */ +#include #include #include #include #include #include "portab.h" -#include "device.h" #include "b_fat12.h" #include "b_fat16.h" -BYTE *pgm = "sys"; +BYTE pgm[] = "sys"; -BOOL fl_reset(WORD); -COUNT fl_rd_status(WORD); -COUNT fl_read(WORD, WORD, WORD, WORD, WORD, BYTE FAR *); -COUNT fl_write(WORD, WORD, WORD, WORD, WORD, BYTE FAR *); -BOOL fl_verify(WORD, WORD, WORD, WORD, WORD, BYTE FAR *); -BOOL fl_format(WORD, BYTE FAR *); -VOID get_boot(COUNT); -VOID put_boot(COUNT); +void put_boot(COUNT); BOOL check_space(COUNT, BYTE *); -COUNT ltop(WORD *, WORD *, WORD *, COUNT, COUNT, LONG, byteptr); BOOL copy(COUNT, BYTE *); -BOOL DiskReset(COUNT); COUNT DiskRead(WORD, WORD, WORD, WORD, WORD, BYTE FAR *); COUNT DiskWrite(WORD, WORD, WORD, WORD, WORD, BYTE FAR *); -/* special word packing prototypes */ - -#ifdef NATIVE -#define getlong(vp, lp) (*(LONG *)(lp)=*(LONG *)(vp)) -#define getword(vp, wp) (*(WORD *)(wp)=*(WORD *)(vp)) -#define getbyte(vp, bp) (*(BYTE *)(bp)=*(BYTE *)(vp)) -#define fgetlong(vp, lp) (*(LONG FAR *)(lp)=*(LONG FAR *)(vp)) -#define fgetword(vp, wp) (*(WORD FAR *)(wp)=*(WORD FAR *)(vp)) -#define fgetbyte(vp, bp) (*(BYTE FAR *)(bp)=*(BYTE FAR *)(vp)) -#define fputlong(lp, vp) (*(LONG FAR *)(vp)=*(LONG FAR *)(lp)) -#define fputword(wp, vp) (*(WORD FAR *)(vp)=*(WORD FAR *)(wp)) -#define fputbyte(bp, vp) (*(BYTE FAR *)(vp)=*(BYTE FAR *)(bp)) -#else -VOID getword(VOID *, WORD *); -VOID getbyte(VOID *, BYTE *); -VOID fgetlong(VOID FAR *, LONG FAR *); -VOID fgetword(VOID FAR *, WORD FAR *); -VOID fgetbyte(VOID FAR *, BYTE FAR *); -VOID fputlong(LONG FAR *, VOID FAR *); -VOID fputword(WORD FAR *, VOID FAR *); -VOID fputbyte(BYTE FAR *, VOID FAR *); -#endif #define SEC_SIZE 512 -#define NDEV 4 #define COPY_SIZE 32768 -#define NRETRY 5 - -static struct media_info -{ - ULONG mi_size; /* physical sector size */ - UWORD mi_heads; /* number of heads (sides) */ - UWORD mi_cyls; /* number of cyl/drive */ - UWORD mi_sectors; /* number of sectors/cyl */ - ULONG mi_offset; /* relative partition offset */ -}; -union -{ - BYTE bytes[2 * SEC_SIZE]; - boot boot_sector; -} - buffer; -static struct media_info miarray[NDEV] = -{ - {720l, 2, 40, 9, 0l}, - {720l, 2, 40, 9, 0l}, - {720l, 2, 40, 9, 0l}, - {720l, 2, 40, 9, 0l} -}; - -#define PARTOFF 0x1be -#define N_PART 4 - -static struct -{ - BYTE peBootable; - BYTE peBeginHead; - BYTE peBeginSector; - UWORD peBeginCylinder; - BYTE peFileSystem; - BYTE peEndHead; - BYTE peEndSector; - UWORD peEndCylinder; - LONG peStartSector; - LONG peSectors; -} partition[N_PART]; struct bootsectortype { @@ -213,164 +191,87 @@ struct bootsectortype }; -static int DrvMap[4] = -{0, 1, 0x80, 0x81}; -COUNT drive, active; +COUNT drive; UBYTE newboot[SEC_SIZE], oldboot[SEC_SIZE]; -#ifdef DEBUG -FILE *log; -#endif -#define SBSIZE 51 #define SBOFFSET 11 +#define SBSIZE (sizeof(struct bootsectortype) - SBOFFSET) -#define SIZEOF_PARTENT 16 -#define FAT12 0x01 -#define FAT16SMALL 0x04 -#define EXTENDED 0x05 -#define FAT16LARGE 0x06 - -#define N_RETRY 5 - -COUNT get_part(COUNT drive, COUNT idx) -{ - REG retry = N_RETRY; - REG BYTE *p = (BYTE *) & buffer.bytes[PARTOFF + (idx * SIZEOF_PARTENT)]; - REG ret; - BYTE packed_byte, pb1; - - do - { - ret = fl_read((WORD) DrvMap[drive], (WORD) 0, (WORD) 0, (WORD) 1, (WORD) 1, (byteptr) & buffer); - } - while (ret != 0 && --retry > 0); - if (ret != 0) - return FALSE; - getbyte((VOID *) p, &partition[idx].peBootable); - ++p; - getbyte((VOID *) p, &partition[idx].peBeginHead); - ++p; - getbyte((VOID *) p, &packed_byte); - partition[idx].peBeginSector = packed_byte & 0x3f; - ++p; - getbyte((VOID *) p, &pb1); - ++p; - partition[idx].peBeginCylinder = pb1 + ((0xc0 & packed_byte) << 2); - getbyte((VOID *) p, &partition[idx].peFileSystem); - ++p; - getbyte((VOID *) p, &partition[idx].peEndHead); - ++p; - getbyte((VOID *) p, &packed_byte); - partition[idx].peEndSector = packed_byte & 0x3f; - ++p; - getbyte((VOID *) p, &pb1); - ++p; - partition[idx].peEndCylinder = pb1 + ((0xc0 & packed_byte) << 2); - getlong((VOID *) p, &partition[idx].peStartSector); - p += sizeof(LONG); - getlong((VOID *) p, &partition[idx].peSectors); - return TRUE; -} VOID main(COUNT argc, char **argv) { printf("FreeDOS System Installer v1.0\n\n"); - if (argc != 2) + if (argc != 2) { - fprintf(stderr, "Usage: %s drive\n drive = A,B,etc.\n", pgm); + printf("Usage: %s drive\n drive = A,B,etc.\n", pgm); exit(1); } - drive = *argv[1] - (islower(*argv[1]) ? 'a' : 'A'); - if (drive < 0 || drive >= NDEV) + drive = toupper(*argv[1]) - 'A'; + if (drive < 0 || drive >= 26) { - fprintf(stderr, "%s: drive out of range\n", pgm); + printf( "%s: drive %c must be A:..Z:\n", pgm,*argv[1]); exit(1); } - if (!DiskReset(drive)) - { - fprintf(stderr, "%s: cannot reset drive %c:", - drive, 'A' + drive); - exit(1); - } - - get_boot(drive); if (!check_space(drive, oldboot)) { - fprintf(stderr, "%s: Not enough space to transfer system files\n", pgm); + printf("%s: Not enough space to transfer system files\n", pgm); exit(1); } -#ifdef DEBUG - if ((log = fopen("sys.log", "w")) == NULL) - { - printf("Can't write log file.\n"); - log = NULL; - } -#endif - - printf("Writing boot sector...\n"); - put_boot(drive); printf("\nCopying KERNEL.SYS..."); if (!copy(drive, "kernel.sys")) { - fprintf(stderr, "\n%s: cannot copy \"KERNEL.SYS\"\n", pgm); -#ifdef DEBUG - fclose(log); -#endif + printf("\n%s: cannot copy \"KERNEL.SYS\"\n", pgm); exit(1); } printf("\nCopying COMMAND.COM..."); if (!copy(drive, "command.com")) { - fprintf(stderr, "\n%s: cannot copy \"COMMAND.COM\"\n", pgm); -#ifdef DEBUG - fclose(log); -#endif + printf("\n%s: cannot copy \"COMMAND.COM\"\n", pgm); exit(1); } - printf("\nSystem transfered.\n"); -#ifdef DEBUG - fclose(log); -#endif + + printf("\nWriting boot sector...\n"); + put_boot(drive); + + printf("\nSystem transferred.\n"); exit(0); } #ifdef DEBUG VOID dump_sector(unsigned char far * sec) { - if (log) - { COUNT x, y; char c; for (x = 0; x < 32; x++) { - fprintf(log, "%03X ", x * 16); + printf("%03X ", x * 16); for (y = 0; y < 16; y++) { - fprintf(log, "%02X ", sec[x * 16 + y]); + printf("%02X ", sec[x * 16 + y]); } for (y = 0; y < 16; y++) { c = oldboot[x * 16 + y]; if (isprint(c)) - fprintf(log, "%c", c); + printf( "%c", c); else - fprintf(log, "."); + printf( "."); } - fprintf(log, "\n"); - } - fprintf(log, "\n"); - } + printf( "\n"); + } + + printf( "\n"); } #endif @@ -383,306 +284,154 @@ VOID put_boot(COUNT drive) WORD count; ULONG temp; struct bootsectortype *bs; + - if (drive >= 2) - { - head = partition[active].peBeginHead; - sector = partition[active].peBeginSector; - track = partition[active].peBeginCylinder; - } - else - { - head = 0; - sector = 1; - track = 0; - } +#ifdef DEBUG + printf("Reading old bootsector from drive %c:\n",drive+'A'); +#endif - /* Read current boot sector */ - if ((i = DiskRead(DrvMap[drive], head, track, sector, 1, (BYTE far *) oldboot)) != 0) - { - fprintf(stderr, "%s: disk read error (code = 0x%02x)\n", pgm, i & 0xff); + if (absread(drive, 1, 0, oldboot) != 0) + { + printf("can't read old boot sector for drive %c:\n", drive +'A'); exit(1); - } + } + -#ifdef DEBUG - fprintf(log, "Old Boot Sector:\n"); +#ifdef DDEBUG + printf("Old Boot Sector:\n"); dump_sector(oldboot); #endif + bs = (struct bootsectortype *) & oldboot; if ((bs->bsFileSysType[4] == '6') && (bs->bsBootSignature == 0x29)) { memcpy(newboot, b_fat16, SEC_SIZE); /* copy FAT16 boot sector */ printf("FAT type: FAT16\n"); -#ifdef DEBUG - fprintf(log, "FAT type: FAT16\n"); -#endif } else { memcpy(newboot, b_fat12, SEC_SIZE); /* copy FAT12 boot sector */ printf("FAT type: FAT12\n"); -#ifdef DEBUG - fprintf(log, "FAT type: FAT12\n"); -#endif } /* Copy disk parameter from old sector to new sector */ memcpy(&newboot[SBOFFSET], &oldboot[SBOFFSET], SBSIZE); bs = (struct bootsectortype *) & newboot; - /* root directory sectors */ + #ifdef STORE_BOOT_INFO + /* TE thinks : never, see above */ + /* temporary HACK for the load segment (0x0060): it is in unused */ + /* only needed for older kernels */ + *((UWORD *)(bs->unused)) = *((UWORD *)(((struct bootsectortype *)&b_fat16)->unused)); + /* end of HACK */ + /* root directory sectors */ + bs->sysRootDirSecs = bs->bsRootDirEnts / 16; -#endif -#ifdef DEBUG - fprintf(log, "root dir entries = %u\n", bs->bsRootDirEnts); - fprintf(log, "root dir sectors = %u\n", bs->sysRootDirSecs); -#endif - /* sector FAT starts on */ + /* sector FAT starts on */ temp = bs->bsHiddenSecs + bs->bsResSectors; -#ifdef STORE_BOOT_INFO bs->sysFatStart = temp; -#endif -#ifdef DEBUG - fprintf(log, "FAT starts at sector %lu = (%lu + %u)\n", temp, - bs->bsHiddenSecs, bs->bsResSectors); -#endif - - /* sector root directory starts on */ + + /* sector root directory starts on */ temp = temp + bs->bsFATsecs * bs->bsFATs; -#ifdef STORE_BOOT_INFO bs->sysRootDirStart = temp; -#endif -#ifdef DEBUG - fprintf(log, "Root directory starts at sector %lu = (PREVIOUS + %u * %u)\n", - temp, bs->bsFATsecs, bs->bsFATs); -#endif - - /* sector data starts on */ + + /* sector data starts on */ temp = temp + bs->sysRootDirSecs; -#ifdef STORE_BOOT_INFO bs->sysDataStart = temp; -#endif + + #ifdef DEBUG - fprintf(log, "DATA starts at sector %lu = (PREVIOUS + %u)\n", temp, + printf("Root dir entries = %u\n", bs->bsRootDirEnts); + printf("Root dir sectors = %u\n", bs->sysRootDirSecs); + + printf( "FAT starts at sector %lu = (%lu + %u)\n", bs->sysFatStart, + bs->bsHiddenSecs, bs->bsResSectors); + printf("Root directory starts at sector %lu = (PREVIOUS + %u * %u)\n", + bs->sysRootDirStart, bs->bsFATsecs, bs->bsFATs); + printf("DATA starts at sector %lu = (PREVIOUS + %u)\n", bs->sysDataStart, bs->sysRootDirSecs); #endif +#endif -#ifdef DEBUG - fprintf(log, "\nNew Boot Sector:\n"); +#ifdef DDEBUG + printf("\nNew Boot Sector:\n"); dump_sector(newboot); #endif - if ((i = DiskWrite(DrvMap[drive], head, track, sector, 1, (BYTE far *) newboot)) != 0) - { - fprintf(stderr, "%s: disk write error (code = 0x%02x)\n", pgm, i & 0xff); - exit(1); - } -} - -VOID get_boot(COUNT drive) -{ - COUNT i; - COUNT ifd; - WORD head, track, sector, ret; - WORD count; - - if (drive >= 2) - { - head = partition[active].peBeginHead; - sector = partition[active].peBeginSector; - track = partition[active].peBeginCylinder; - } - else - { - head = 0; - sector = 1; - track = 0; - } +#ifdef DEBUG + printf("writing new bootsector to drive %c:\n",drive+'A'); +#endif - if ((i = DiskRead(DrvMap[drive], head, track, sector, 1, (BYTE far *) oldboot)) != 0) - { - fprintf(stderr, "%s: disk read error (code = 0x%02x)\n", pgm, i & 0xff); + if (abswrite(drive, 1, 0, newboot) != 0) + { + printf("Can't write new boot sector to drive %c:\n", drive +'A'); exit(1); - } + } + } + BOOL check_space(COUNT drive, BYTE * BlkBuffer) { - BYTE *bpbp; -#if 0 /* these local variables are never used */ - BYTE nfat; - UWORD nfsect; - ULONG hidden; - UBYTE nreserved; -#endif - ULONG count; - ULONG block; - UCOUNT i; - WORD track, head, sector; - UBYTE buffer[SEC_SIZE]; - ULONG bpb_huge; - UWORD bpb_nsize; - - /* get local information */ -#if 0 /* these local variables are never used */ - getbyte((VOID *) & BlkBuffer[BT_BPB + BPB_NFAT], &nfat); - getword((VOID *) & BlkBuffer[BT_BPB + BPB_NFSECT], &nfsect); - getlong((VOID *) & BlkBuffer[BT_BPB + BPB_HIDDEN], &hidden); - getbyte((VOID *) & BlkBuffer[BT_BPB + BPB_NRESERVED], &nreserved); -#endif - - getlong((VOID *) & BlkBuffer[BT_BPB + BPB_HUGE], &bpb_huge); - getword((VOID *) & BlkBuffer[BT_BPB + BPB_NSIZE], &bpb_nsize); - - count = miarray[drive].mi_size = bpb_nsize == 0 ? - bpb_huge : bpb_nsize; - - /* Fix media information for disk */ - getword((&(((BYTE *) & BlkBuffer[BT_BPB])[BPB_NHEADS])), &miarray[drive].mi_heads); - head = miarray[drive].mi_heads; - getword((&(((BYTE *) & BlkBuffer[BT_BPB])[BPB_NSECS])), &miarray[drive].mi_sectors); - if (miarray[drive].mi_size == 0) - getlong(&((((BYTE *) & BlkBuffer[BT_BPB])[BPB_HUGE])), &miarray[drive].mi_size); - sector = miarray[drive].mi_sectors; - if (head == 0 || sector == 0) - { - fprintf(stderr, "Drive initialization failure.\n"); - exit(1); - } - miarray[drive].mi_cyls = count / (head * sector); + /* this should check, if on destination is enough space + to hold command.com+ kernel.sys */ + + if (drive); + if (BlkBuffer); + return 1; } -/* */ -/* Do logical block number to physical head/track/sector mapping */ -/* */ -static COUNT ltop(trackp, sectorp, headp, unit, count, strt_sect, strt_addr) -WORD *trackp, *sectorp, *headp; -REG COUNT unit; -LONG strt_sect; -COUNT count; -byteptr strt_addr; -{ -#ifdef I86 - ULONG ltemp; -#endif - REG ls, ps; - -#ifdef I86 - /* Adjust for segmented architecture */ - ltemp = (((ULONG) mk_segment(strt_addr) << 4) + mk_offset(strt_addr)) & 0xffff; - /* Test for 64K boundary crossing and return count large */ - /* enough not to exceed the threshold. */ - count = (((ltemp + SEC_SIZE * count) & 0xffff0000l) != 0l) - ? (0xffffl - ltemp) / SEC_SIZE - : count; -#endif - - *trackp = strt_sect / (miarray[unit].mi_heads * miarray[unit].mi_sectors); - *sectorp = strt_sect % miarray[unit].mi_sectors + 1; - *headp = (strt_sect % (miarray[unit].mi_sectors * miarray[unit].mi_heads)) - / miarray[unit].mi_sectors; - if (((ls = *headp * miarray[unit].mi_sectors + *sectorp - 1) + count) > - (ps = miarray[unit].mi_heads * miarray[unit].mi_sectors)) - count = ps - ls; - return count; -} BOOL copy(COUNT drive, BYTE * file) { BYTE dest[64]; - COUNT ifd, ofd, ret; - FILE *s, *d; + COUNT ifd, ofd; + unsigned ret; + int fdin, fdout; BYTE buffer[COPY_SIZE]; struct ftime ftime; + ULONG copied = 0; sprintf(dest, "%c:\\%s", 'A' + drive, file); - if ((s = fopen(file, "rb")) == NULL) + if ((fdin = open(file, O_RDONLY|O_BINARY)) < 0) { - fprintf(stderr, "%s: \"%s\" not found\n", pgm, file); + printf( "%s: \"%s\" not found\n", pgm, file); return FALSE; } - _fmode = O_BINARY; - if ((d = fopen(dest, "wb")) == NULL) + if ((fdout = open(dest, O_RDWR | O_TRUNC | O_CREAT | O_BINARY,S_IREAD|S_IWRITE)) < 0) { - fclose(s); - fprintf(stderr, "%s: can't create\"%s\"\n", pgm, dest); + printf( " %s: can't create\"%s\"\nDOS errnum %d", pgm, dest, errno); + close(fdin); return FALSE; } - while ((ret = fread(buffer, 1, COPY_SIZE, s)) != 0) - fwrite(buffer, 1, ret, d); - - getftime(fileno(s), &ftime); - setftime(fileno(d), &ftime); - - fclose(s); - fclose(d); - - return TRUE; -} - -BOOL DiskReset(COUNT Drive) -{ - REG COUNT idx; - - /* Reset the drives */ - fl_reset(DrvMap[drive]); - - if (Drive >= 2 && Drive < NDEV) - { - COUNT RetCode; - - /* Retrieve all the partition information */ - for (RetCode = TRUE, idx = 0; RetCode && (idx < N_PART); idx++) - RetCode = get_part(Drive, idx); - if (!RetCode) - return FALSE; - - /* Search for the first DOS partition and start */ - /* building the map for the hard drive */ - for (idx = 0; idx < N_PART; idx++) + while ((ret = read(fdin, buffer,COPY_SIZE)) > 0) { - if (partition[idx].peFileSystem == FAT12 - || partition[idx].peFileSystem == FAT16SMALL - || partition[idx].peFileSystem == FAT16LARGE) - { - miarray[Drive].mi_offset - = partition[idx].peStartSector; - active = idx; - break; - } - } - } + if (write(fdout, buffer, ret) != ret) + { + printf("Can't write %u bytes to %s\n",dest); + close(fdout); + unlink(dest); + break; + } + copied += ret; + } + + getftime(fdin, &ftime); + setftime(fdout, &ftime); + + close(fdin); + close(fdout); + + printf("%lu Bytes transferred", copied); return TRUE; } -COUNT DiskRead(WORD drive, WORD head, WORD track, WORD sector, WORD count, BYTE FAR * buffer) -{ - int nRetriesLeft; - for (nRetriesLeft = NRETRY; nRetriesLeft > 0; --nRetriesLeft) - { - if (fl_read(drive, head, track, sector, count, buffer) == count) - return count; - } - return 0; -} - -COUNT DiskWrite(WORD drive, WORD head, WORD track, WORD sector, WORD count, BYTE FAR * buffer) -{ - int nRetriesLeft; - - for (nRetriesLeft = NRETRY; nRetriesLeft > 0; --nRetriesLeft) - { - if (fl_write(drive, head, track, sector, count, buffer) == count) - return count; - } - return 0; -} From 68375764dddc3967be2e98acc2ed6b5afe8c8fd0 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sun, 3 Jun 2001 14:16:18 +0000 Subject: [PATCH 081/671] BUFFERS tuning and misc bug fixes/cleanups (2024c). git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@232 6ac86273-5f31-0410-b378-82cca8765d1b --- docs/history.txt | 41 ++++++++ fdkernel.lsm | 8 +- hdr/buffer.h | 4 + hdr/device.h | 13 ++- hdr/fnode.h | 4 + hdr/portab.h | 6 ++ hdr/version.h | 2 +- kernel/blockio.c | 97 ++++++++++++----- kernel/chario.c | 14 +-- kernel/config.c | 150 +++++++++++++-------------- kernel/dosfns.c | 48 +++++++-- kernel/dosnames.c | 6 +- kernel/error.c | 9 +- kernel/fatdir.c | 100 ++++++++++++------ kernel/fatfs.c | 258 +++++++++++++++++++++++++++------------------- kernel/fattab.c | 125 +++++++++------------- kernel/fcbfns.c | 39 ++++--- kernel/globals.h | 15 ++- kernel/init-mod.h | 1 + kernel/inthndlr.c | 5 +- kernel/intr.asm | 15 +-- kernel/intr.h | 1 - kernel/ioctl.c | 16 ++- kernel/kernel.asm | 9 +- kernel/main.c | 4 + kernel/nls.c | 20 +++- kernel/proto.h | 34 +++--- kernel/task.c | 44 +++----- lib/libm.mak | 5 +- 29 files changed, 666 insertions(+), 427 deletions(-) diff --git a/docs/history.txt b/docs/history.txt index 68501ab9..220bedd1 100644 --- a/docs/history.txt +++ b/docs/history.txt @@ -1,3 +1,42 @@ +2001 Jun 2 - Build 2024 +-------- Bart Oldeman (bart.oldeman@bristol.ac.uk) ++ Fixes Tom: + * small fixes again. + * one possible cause for data corruption (BFR_VALID) detected + * directories with 'ARCHIVE' attribute could not be deleted + * saved even more bytes (now 20 buffers in HMA :-) + * some issues with pathnames around PARSE_MAX removed + * blanks in filenames weren't proper handled + * there was (at rare circumstances) a buffer overflow + while config.sys parsing. ++ Fixes Bart: + * INT 21 0A - Dos Buffered Input reworked ++ Added tom: + * slighly better buffer handling (search BFR_UNCACHE) + now go more FAT+DIR sectors, less DATA sectors into cache + * dos_mkdir tuned (was ~0.5 sec on 64K cluster partitions) +2001 Apr 29 - Build 2024 +-------- Bart Oldeman (bart.oldeman@bristol.ac.uk) ++ Fixes Bart: + * fixed the "TYPE > FOO.TXT" poor man's editor. + * use "fast console output" (int 29) when applicable. + * moved 5 FILES to DOS DS:00CC and fixed the SFT linked list. + * cleaned up findfirst/findnext for redirected drives. + Tom: + * more VDISK changes (changed slightly by Bart) + * check for presence of A:/B: (changed by Bart to use the BIOS equipment flag + from INT11 instead of INT13). + * added F5/F8 stepping through config.sys; default SHELL=COMMAND.COM /P/E:256 + Use ESC to stop single stepping, F5 to skip remaining config.sys/autoexec.bat. + * new sys: uses INT25/26 instead of the low level INT13 related kernel code from + floppy.asm (see also comments in sys.c) + a few fixes (also boot.asm related) + from Bart. + * Hopefully fixed DateTime Changed + ATTRIB |= ARCHIVE bug. + * cleaned up dsk.c and saved more bytes. + Przemyslaw Czerpak: + * Default lastdrive should be 5 (E) not 6 (F). + * fixed not ignoring whitespace after '=' in config.sys + * noted INT21/AX=3800 bug for getting the country. Put in a workaround for now. 2001 Apr 29 - Build 2024 -------- Bart Oldeman (bart.oldeman@bristol.ac.uk) + Fixes Bart: @@ -5,6 +44,7 @@ * use "fast console output" (int 29) when applicable. * moved 5 FILES to DOS DS:00CC and fixed the SFT linked list. * cleaned up findfirst/findnext for redirected drives. + * moved IO segments to 0x70 as this matches other DOS'es. Tom: * more VDISK changes (changed slightly by Bart) * check for presence of A:/B: (changed by Bart to use the BIOS equipment flag @@ -15,6 +55,7 @@ floppy.asm (see also comments in sys.c) + a few fixes (also boot.asm related) from Bart. * Hopefully fixed DateTime Changed + ATTRIB |= ARCHIVE bug. + * Combined clk and blk driver entries as much as possible. * cleaned up dsk.c and saved more bytes. Przemyslaw Czerpak: * Default lastdrive should be 5 (E) not 6 (F). diff --git a/fdkernel.lsm b/fdkernel.lsm index 54c2c33f..cd187e81 100644 --- a/fdkernel.lsm +++ b/fdkernel.lsm @@ -1,13 +1,13 @@ Begin3 Title: The FreeDOS Kernel -Version: 1.1.20 -Entered-date: 5 May 2000 +Version: 1.1.24 +Entered-date: 2 Jun 2001 Description: The FreeDOS Kernel. Keywords: kernel freedos dos msdos Author: (developers) -Maintained-by: jimtabor@infohwy.com +Maintained-by: bart.oldeman@bristol.ac.uk Primary-site: http://freedos.sourceforge.net -Alternate-site: www.freedos.org +Alternate-site: www.dosemu.org/~bart Original-site: http://www.gcfl.net/pub/FreeDOS/kernel Platforms: dos dosemu Copying-policy: GPL diff --git a/hdr/buffer.h b/hdr/buffer.h index b74e771b..c8762231 100644 --- a/hdr/buffer.h +++ b/hdr/buffer.h @@ -34,6 +34,9 @@ static BYTE *buffer_hRcsId = "$Id$"; /* * $Log$ + * Revision 1.2 2001/06/03 14:16:17 bartoldeman + * BUFFERS tuning and misc bug fixes/cleanups (2024c). + * * Revision 1.1 2001/04/21 22:32:53 bartoldeman * Init DS=Init CS, fixed stack overflow problems and misc bugs. * @@ -68,6 +71,7 @@ struct buffer #define b_dpbp _b._b_dpbp #define b_huge_blkno _b._b_huge_blkno +#define BFR_UNCACHE 0x80 /* indication, not really used */ #define BFR_DIRTY 0x40 /* buffer modified */ #define BFR_VALID 0x20 /* buffer contains valid data */ #define BFR_DATA 0x08 /* buffer is from data area */ diff --git a/hdr/device.h b/hdr/device.h index 93f25ce2..6e53ba5a 100644 --- a/hdr/device.h +++ b/hdr/device.h @@ -35,6 +35,9 @@ static BYTE *device_hRcsId = "$Id$"; /* * $Log$ + * Revision 1.6 2001/06/03 14:16:17 bartoldeman + * BUFFERS tuning and misc bug fixes/cleanups (2024c). + * * Revision 1.5 2001/04/15 03:21:50 bartoldeman * See history.txt for the list of fixes. * @@ -312,19 +315,19 @@ typedef boot super; /* Alias for boot structure */ typedef struct { - BYTE r_length; /* Request Header length */ - BYTE r_unit; /* Unit Code */ - BYTE r_command; /* Command Code */ + UBYTE r_length; /* Request Header length */ + UBYTE r_unit; /* Unit Code */ + UBYTE r_command; /* Command Code */ WORD r_status; /* Status */ BYTE r_reserved[8]; /* DOS Reserved Area */ union { struct { - BYTE _r_nunits; /* number of units */ + UBYTE _r_nunits; /* number of units */ BYTE FAR *_r_endaddr; /* Ending Address */ bpb *FAR * _r_bpbptr; /* ptr to BPB array */ - BYTE _r_firstunit; + UBYTE _r_firstunit; } _r_init; struct diff --git a/hdr/fnode.h b/hdr/fnode.h index 80e9f928..d7d3d878 100644 --- a/hdr/fnode.h +++ b/hdr/fnode.h @@ -36,6 +36,9 @@ static BYTE *fnode_hRcsId = "$Id$"; /* * $Log$ + * Revision 1.6 2001/06/03 14:16:17 bartoldeman + * BUFFERS tuning and misc bug fixes/cleanups (2024c). + * * Revision 1.5 2001/04/29 17:34:40 bartoldeman * A new SYS.COM/config.sys single stepping/console output/misc fixes. * @@ -126,3 +129,4 @@ struct f_node UWORD f_boff; /* the byte in the cluster */ }; +typedef struct f_node FAR * f_node_ptr; diff --git a/hdr/portab.h b/hdr/portab.h index 936d66a5..9ddae0bd 100644 --- a/hdr/portab.h +++ b/hdr/portab.h @@ -36,6 +36,9 @@ static char *portab_hRcsId = "$Id$"; /* * $Log$ + * Revision 1.9 2001/06/03 14:16:17 bartoldeman + * BUFFERS tuning and misc bug fixes/cleanups (2024c). + * * Revision 1.8 2001/04/15 03:21:50 bartoldeman * See history.txt for the list of fixes. * @@ -195,6 +198,9 @@ typedef int COUNT; typedef unsigned int UCOUNT; typedef unsigned long ULONG; +#define STATIC /* local calls inside module */ + + #ifdef UNIX typedef char FAR *ADDRESS; #else diff --git a/hdr/version.h b/hdr/version.h index 134597e3..b5703403 100644 --- a/hdr/version.h +++ b/hdr/version.h @@ -44,4 +44,4 @@ static BYTE *date_hRcsId = "$Id$"; #define REVISION_MINOR 1 #define REVISION_SEQ 24 #define BUILD 2024 -#define SUB_BUILD "b" +#define SUB_BUILD "c" diff --git a/kernel/blockio.c b/kernel/blockio.c index 455bce6c..098213a2 100644 --- a/kernel/blockio.c +++ b/kernel/blockio.c @@ -37,6 +37,9 @@ static BYTE *blockioRcsId = "$Id$"; /* * $Log$ + * Revision 1.10 2001/06/03 14:16:17 bartoldeman + * BUFFERS tuning and misc bug fixes/cleanups (2024c). + * * Revision 1.9 2001/04/21 22:32:53 bartoldeman * Init DS=Init CS, fixed stack overflow problems and misc bugs. * @@ -241,6 +244,11 @@ VOID setblkno(struct buffer FAR * bp, ULONG blkno) FALSE: the buffer is not found *Buffp contains a block to flush and reuse later + + new: + upper layer may set UNCACHE attribute + UNCACHE buffers are recycled first. + intended to be used for full sector reads into application buffer */ @@ -251,6 +259,7 @@ BOOL searchblock(ULONG blkno, COUNT dsk, struct buffer FAR *bp; struct buffer FAR *lbp = NULL; struct buffer FAR *lastNonFat = NULL; + struct buffer FAR *uncacheBuf = NULL; #ifdef DISPLAY_GETBLOCK @@ -281,6 +290,10 @@ BOOL searchblock(ULONG blkno, COUNT dsk, return TRUE; } + if (bp->b_flag & BFR_UNCACHE) + uncacheBuf = bp; + + if (bp->b_flag & BFR_FAT) fat_count++; else @@ -291,17 +304,27 @@ BOOL searchblock(ULONG blkno, COUNT dsk, now take either the last buffer in chain (not used recently) or, if we are low on FAT buffers, the last non FAT buffer */ - - if (lbp ->b_flag & BFR_FAT && fat_count < 3 && lastNonFat) + + if (uncacheBuf) + { + lbp = uncacheBuf; + } + else { + if (lbp ->b_flag & BFR_FAT && fat_count < 3 && lastNonFat) + { lbp = lastNonFat; - } + } + } + + lbp->b_flag &= ~BFR_UNCACHE; /* reset uncache attribute */ *pBuffp = lbp; #ifdef DISPLAY_GETBLOCK printf("MISS, replace %04x:%04x]\n", FP_SEG(lbp), FP_OFF(lbp)); #endif + if (lbp != firstbuf) /* move to front */ @@ -316,6 +339,23 @@ BOOL searchblock(ULONG blkno, COUNT dsk, return FALSE; } +void dumpBufferCache(void) +{ + struct buffer FAR *bp; + int printed = 0; + + /* Search through buffers to see if the required block */ + /* is already in a buffer */ + + for (bp = firstbuf; bp != NULL;bp = bp->b_next) + { + printf("%8lx %02x ",getblkno(bp),bp->b_flag); + if (++printed % 6 == 0) + printf("\n"); + } + printf("\n"); +} + /* */ /* Return the address of a buffer structure containing the */ @@ -364,17 +404,10 @@ struct buffer FAR *getblock(ULONG blkno, COUNT dsk) } /* - Return the address of a buffer structure for the - requested block. This is for writing new data to a block, so - we really don't care what is in the buffer now. - - returns: - TRUE = buffer available, flushed if necessary - parameter is filled with pointer to buffer - FALSE = there was an error flushing the buffer. - parameter is set to NULL + exactly the same as getblock(), but the data will be completely + overwritten. so there is no need to read from disk first */ -BOOL getbuf(struct buffer FAR ** pbp, ULONG blkno, COUNT dsk) +struct buffer FAR * getblockOver(ULONG blkno, COUNT dsk) { struct buffer FAR *bp; @@ -383,8 +416,7 @@ BOOL getbuf(struct buffer FAR ** pbp, ULONG blkno, COUNT dsk) if (searchblock(blkno, dsk, &bp)) { - *pbp = bp; - return TRUE; + return bp; } /* The block we need is not in a buffer, we must make a buffer */ @@ -396,14 +428,12 @@ BOOL getbuf(struct buffer FAR ** pbp, ULONG blkno, COUNT dsk) bp->b_flag = 0; bp->b_unit = dsk; setblkno(bp, blkno); - *pbp = bp; - return TRUE; + return bp; } else /* failure */ { - *pbp = NULL; - return FALSE; + return NULL; } } /* */ @@ -438,7 +468,7 @@ BOOL flush_buffers(REG COUNT dsk) { if (bp->b_unit == dsk) if (!flush1(bp)) - ok = FALSE; + ok = FALSE; bp = bp->b_next; } return ok; @@ -465,16 +495,17 @@ BOOL flush1(struct buffer FAR * bp) while (--i > 0) { - blkno += offset; - result = dskxfer(bp->b_unit, blkno, + blkno += offset; + result = dskxfer(bp->b_unit, blkno, (VOID FAR *) bp->b_buffer, 1, DSKWRITE); /* BER 9/4/00 */ } } } else - result = TRUE; /* This negates any error code returned in result...BER */ + result = 0; /* This negates any error code returned in result...BER */ + /* and 0 returned, if no errors occurred - tom */ bp->b_flag &= ~BFR_DIRTY; /* even if error, mark not dirty */ - if (!result) /* otherwise system has trouble */ + if (result != 0) /* otherwise system has trouble */ bp->b_flag &= ~BFR_VALID; /* continuing. */ return (TRUE); /* Forced to TRUE...was like this before dskxfer() */ /* returned error codes...BER */ @@ -521,6 +552,24 @@ UWORD dskxfer(COUNT dsk, ULONG blkno, VOID FAR * buf, UWORD numblocks, COUNT mod REG struct dpb FAR *dpbp = CDSp->cds_table[dsk].cdsDpb; + + if ((UCOUNT)dsk >= lastdrive || + !(CDSp->cds_table[dsk].cdsFlags & CDSPHYSDRV)) + { + return -1; /* illegal command */ + } + +#if 1 +#define KeyboardShiftState() (*(BYTE FAR *)(MK_FP(0x40,0x17))) + + if (KeyboardShiftState() & 0x01) + { + printf("dskxfer:%s %x - %lx %u\n", mode == DSKWRITE ? "write" : "read", dsk, blkno, numblocks); + if ((KeyboardShiftState() & 0x03) == 3) + dumpBufferCache(); + } +#endif + for (;;) { IoReqHdr.r_length = sizeof(request); diff --git a/kernel/chario.c b/kernel/chario.c index d801eea3..ffbc3b6e 100644 --- a/kernel/chario.c +++ b/kernel/chario.c @@ -36,6 +36,9 @@ static BYTE *charioRcsId = "$Id$"; /* * $Log$ + * Revision 1.9 2001/06/03 14:16:17 bartoldeman + * BUFFERS tuning and misc bug fixes/cleanups (2024c). + * * Revision 1.8 2001/04/29 17:34:40 bartoldeman * A new SYS.COM/config.sys single stepping/console output/misc fixes. * @@ -285,7 +288,7 @@ VOID KbdFlush(void) static VOID kbfill(keyboard FAR * kp, UCOUNT c, BOOL ctlf, UWORD * vp) { - if (kp->kb_count > kp->kb_size) + if (kp->kb_count >= kp->kb_size) { cso(BELL); return; @@ -349,8 +352,6 @@ UCOUNT sti(keyboard FAR * kp) for (i = kp->kb_count; local_buffer[i] != '\0'; i++) { c = local_buffer[kp->kb_count]; - if (c == '\r' || c == '\n') - break; kbfill(kp, c, FALSE, &virt_pos); } break; @@ -358,8 +359,6 @@ UCOUNT sti(keyboard FAR * kp) case RIGHT: c = local_buffer[kp->kb_count]; - if (c == '\r' || c == '\n') - break; kbfill(kp, c, FALSE, &virt_pos); break; } @@ -397,21 +396,18 @@ UCOUNT sti(keyboard FAR * kp) break; case CR: - kbfill(kp, CR, TRUE, &virt_pos); - kbfill(kp, LF, TRUE, &virt_pos); #ifndef NOSPCL fbcopy((BYTE FAR *) kp->kb_buf, (BYTE FAR *) local_buffer, (COUNT) kp->kb_count); local_buffer[kp->kb_count] = '\0'; #endif + kbfill(kp, CR, TRUE, &virt_pos); if (eof) return eof; else return kp->kb_count; case LF: - cso(CR); - cso(LF); break; case ESC: diff --git a/kernel/config.c b/kernel/config.c index 65541b5f..d9b60d7b 100644 --- a/kernel/config.c +++ b/kernel/config.c @@ -80,6 +80,9 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.23 2001/06/03 14:16:17 bartoldeman + * BUFFERS tuning and misc bug fixes/cleanups (2024c). + * * Revision 1.22 2001/04/29 17:34:40 bartoldeman * A new SYS.COM/config.sys single stepping/console output/misc fixes. * @@ -590,9 +593,7 @@ INIT VOID configDone(VOID) INIT VOID DoConfig(VOID) { COUNT nFileDesc; - COUNT nRetCode; - BYTE *pLine, - *pTmp; + BYTE *pLine; BOOL bEof; /* Check to see if we have a config.sys file. If not, just */ @@ -627,97 +628,82 @@ INIT VOID DoConfig(VOID) /* Read each line into the buffer and then parse the line, */ /* do the table lookup and execute the handler for that */ /* function. */ - while (!bEof) + + for (;!bEof;nCfgLine++) { struct table *pEntry; - UWORD bytesLeft = 0; - if (pLine > szLine) - bytesLeft = LINESIZE - (pLine - szLine); + pLineStart = szLine; + + /* read in a single line, \n or ^Z terminated */ + + for (pLine = szLine;;) + { + if (read(nFileDesc, pLine, 1) <= 0) + { + bEof = TRUE; + break; + } + if (pLine >= szLine + sizeof(szLine)-3) + { + CfgFailure(pLine); + printf("error - line overflow line %d \n",nCfgLine); + break; + } - if (bytesLeft) - { - fbcopy(pLine, szLine, LINESIZE - bytesLeft); - pLine = szLine + bytesLeft; - } + if (*pLine == '\n' || + *pLine == EOF ) /* end of line */ + break; + + if (*pLine == '\r') /* ignore */ + ; + else + pLine++; + } + + *pLine = 0; + pLine = szLine; + - /* Read a line from config */ - /* Interrupt processing if read error or no bytes read */ - if ((nRetCode = read(nFileDesc, pLine, LINESIZE - bytesLeft)) <= 0) - break; + /* Skip leading white space and get verb. */ + pLine = scan(pLine, szBuf); - /* If the buffer was not filled completely, append a - CTRL-Z character to mark where the file ends */ + /* If the line was blank, skip it. Otherwise, look up */ + /* the verb and execute the appropriate function. */ + if (*szBuf == '\0') + continue; - if (nRetCode + bytesLeft < LINESIZE) - szLine[nRetCode + bytesLeft] = EOF; + pEntry = LookUp(commands, szBuf); - /* Process the buffer, line by line */ - pLine = szLine; + if (pEntry->pass >= 0 && pEntry->pass != nPass) + continue; - while (!bEof && *pLine != EOF) - { + if ( SkipLine(pLineStart)) /* F5/F8 processing */ + continue; -/* - Do it here in the loop. -*/ + pLine = skipwh(pLine); - /* shouldn't this go also AFTER the last line has been read? - might be the UMB driver */ - if(UmbState == 2){ - if(!Umb_Test()){ - UmbState = 1; - upBase = MK_FP(umb_start , 0); + if ('=' != *pLine) + CfgFailure(pLine); + else /* YES. DO IT */ + (*(pEntry->func)) (skipwh(pLine+1)); + + + + /* might have been the UMB driver */ + if(UmbState == 2){ + if(!Umb_Test()){ + UmbState = 1; + upBase = MK_FP(umb_start , 0); /* reset root */ uppermem_root = umb_start; /* setup the real mcb for the devicehigh block */ zumcb_init((mcb FAR *) upBase, UMB_top - 1); upBase += 16; + } } - } - - - for (pTmp = pLine; pTmp - szLine < LINESIZE; pTmp++) - { - if (*pTmp == '\r' || *pTmp == EOF) - break; - } - - if (pTmp - szLine >= LINESIZE) - break; - - if (*pTmp == EOF) - bEof = TRUE; - - *pTmp = '\0'; - pLineStart = pLine; - - /* Skip leading white space and get verb. */ - pLine = scan(pLine, szBuf); - - /* If the line was blank, skip it. Otherwise, look up */ - /* the verb and execute the appropriate function. */ - if (*szBuf != '\0') - { - pEntry = LookUp(commands, szBuf); - - if (pEntry->pass < 0 || pEntry->pass == nPass) - { - if ( !SkipLine(pLineStart)) - { - pLine = skipwh(pLine); - if ('=' != *pLine) - CfgFailure(pLine); - else - (*(pEntry->func)) (skipwh(pLine+1)); - } - } } - nCfgLine++; - pLine += strlen(pLine) + 1; - } - } close(nFileDesc); } @@ -825,7 +811,7 @@ INIT BOOL SkipLine(char *pLine) { case 'N': case 'n': - printf("N"); + printf("N\n"); return TRUE; case 0x1b: /* don't know where documented @@ -838,14 +824,14 @@ INIT BOOL SkipLine(char *pLine) case '\n': case 'Y': case 'y': - printf("Y"); + printf("Y\n"); return FALSE; } if (key == 0x3f00) /* YES, you may hit F5 here, too */ { - printf("N"); + printf("N\n"); SkipAllConfig = TRUE; return TRUE; } @@ -969,7 +955,7 @@ INIT static VOID Lastdrive(BYTE * pLine) */ -INIT static VOID Dosmem(BYTE * pLine) +INIT STATIC VOID Dosmem(BYTE * pLine) { BYTE *pTmp; BYTE UMBwanted = FALSE, HMAwanted = FALSE; @@ -1515,7 +1501,11 @@ VOID config_init_buffers(COUNT anzBuffers) int HMAcount = 0; anzBuffers = max(anzBuffers,6); - anzBuffers = min(anzBuffers,64); + if (anzBuffers > 99) + { + printf("BUFFERS=%u not supported, reducing to 99\n",anzBuffers); + anzBuffers = 99; + } firstbuf = ConfigAlloc(sizeof (struct buffer)); diff --git a/kernel/dosfns.c b/kernel/dosfns.c index 46e34e4f..482da59d 100644 --- a/kernel/dosfns.c +++ b/kernel/dosfns.c @@ -37,6 +37,9 @@ static BYTE *dosfnsRcsId = "$Id$"; * /// Added SHARE support. 2000/09/04 Ron Cemer * * $Log$ + * Revision 1.18 2001/06/03 14:16:17 bartoldeman + * BUFFERS tuning and misc bug fixes/cleanups (2024c). + * * Revision 1.17 2001/04/29 17:34:40 bartoldeman * A new SYS.COM/config.sys single stepping/console output/misc fixes. * @@ -173,12 +176,12 @@ static BYTE *dosfnsRcsId = "$Id$"; #include "globals.h" -sft FAR *get_sft(COUNT); +sft FAR *get_sft(UCOUNT); WORD get_free_hndl(VOID); sft FAR *get_free_sft(WORD FAR *); BOOL cmatch(COUNT, COUNT, COUNT); -struct f_node FAR *xlt_fd(COUNT); +f_node_ptr xlt_fd(COUNT); /* /// Added for SHARE. - Ron Cemer */ @@ -248,7 +251,7 @@ static VOID DosGetFile(BYTE FAR * lpszPath, BYTE FAR * lpszDosFileName) fbcopy((BYTE FAR *) szLclExt, &lpszDosFileName[FNAME_SIZE], FEXT_SIZE); } -sft FAR *get_sft(COUNT hndl) +sft FAR *get_sft(UCOUNT hndl) { psp FAR *p = MK_FP(cu_psp, 0); WORD sys_idx; @@ -363,6 +366,11 @@ UCOUNT GenericRead(COUNT hndl, UCOUNT n, BYTE FAR * bp, COUNT FAR * err, ReadCount = sti((keyboard FAR *) & kb_buf); if (ReadCount < kb_buf.kb_count) s->sft_flags &= ~SFT_FEOF; + else if (kb_buf.kb_count < kb_buf.kb_size) { + kb_buf.kb_buf[kb_buf.kb_count++] = LF; + cso(LF); + ReadCount++; + } fbcopy((BYTE FAR *) kb_buf.kb_buf, bp, kb_buf.kb_count); *err = SUCCESS; return ReadCount; @@ -683,7 +691,7 @@ COUNT DosSeek(COUNT hndl, LONG new_pos, COUNT mode, ULONG * set_pos) return result; } -static WORD get_free_hndl(void) +STATIC WORD get_free_hndl(void) { psp FAR *p = MK_FP(cu_psp, 0); WORD hndl; @@ -1023,7 +1031,7 @@ COUNT DosOpen(BYTE FAR * fname, COUNT mode) if (sftp->sft_status >= 0) { - struct f_node FAR *fnp = xlt_fd(sftp->sft_status); + f_node_ptr fnp = xlt_fd(sftp->sft_status); sftp->sft_attrib = fnp->f_dir.dir_attrib; @@ -1214,7 +1222,7 @@ COUNT DosChangeDir(BYTE FAR * s) Some redirectors do not write back to the CDS. SHSUCdX needs this. jt */ - fscopy(&PriPathName[0], cdsp->cdsCurrentPath); + fstrncpy(cdsp->cdsCurrentPath,&PriPathName[0],sizeof(cdsp->cdsCurrentPath)-1); if (PriPathName[7] == 0) cdsp->cdsCurrentPath[8] = 0; /* Need two Zeros at the end */ @@ -1224,7 +1232,7 @@ COUNT DosChangeDir(BYTE FAR * s) result = dos_cd(cdsp, PriPathName); } if (result == SUCCESS) { - fscopy(&PriPathName[0], cdsp->cdsCurrentPath); + fstrncpy(cdsp->cdsCurrentPath,&PriPathName[0],sizeof(cdsp->cdsCurrentPath)-1); } return result; } @@ -1411,8 +1419,28 @@ COUNT DosGetFattr(BYTE FAR * name, UWORD FAR * attrp) or cleanup, such as converting "c:\a\b\.\c\.." to "C:\A\B". - Ron Cemer */ +/* memcpy(SecPathName,PriPathName,sizeof(SecPathName)); return dos_getfattr(SecPathName, attrp); +*/ + /* no longer true. dos_getfattr() is + A) intelligent (uses dos_open) anyway + B) there are some problems with MAX_PARSE, i.e. if PATH ~= 64 + and TRUENAME adds a C:, which leeds to trouble. + + the problem was discovered, when VC did something like + + fd = DosOpen(filename,...) + jc can't_copy_dialog; + + attr = DosGetAttrib(filename); + jc can't_copy_dialog; + and suddenly, the filehandle stays open + shit. + tom + */ + return dos_getfattr(name, attrp); + } } @@ -1449,8 +1477,14 @@ COUNT DosSetFattr(BYTE FAR * name, UWORD FAR * attrp) to get trashed somewhere in transit. - Ron Cemer */ +/* memcpy(SecPathName,PriPathName,sizeof(SecPathName)); return dos_setfattr(SecPathName, attrp); + + see DosGetAttr() +*/ + return dos_setfattr(name, attrp); + } } diff --git a/kernel/dosnames.c b/kernel/dosnames.c index 32d78668..3bf2939e 100644 --- a/kernel/dosnames.c +++ b/kernel/dosnames.c @@ -36,6 +36,9 @@ static BYTE *dosnamesRcsId = "$Id$"; /* * $Log$ + * Revision 1.9 2001/06/03 14:16:17 bartoldeman + * BUFFERS tuning and misc bug fixes/cleanups (2024c). + * * Revision 1.8 2001/04/15 03:21:50 bartoldeman * See history.txt for the list of fixes. * @@ -421,8 +424,9 @@ VOID DosTrimPath(BYTE FAR * lpszPathNamep) lpszRoot = lpszNext + 1; } + /* NAMEMAX + 2, must include C: TE*/ for (lpszLast = lpszNext = lpszPathNamep, nChars = 0; - *lpszNext != '\0' && nChars < NAMEMAX;) + *lpszNext != '\0' && nChars < NAMEMAX+2;) { /* Initialize flag for loop. */ flDotDot = FALSE; diff --git a/kernel/error.c b/kernel/error.c index 507cbbd0..c1a97e9b 100644 --- a/kernel/error.c +++ b/kernel/error.c @@ -34,6 +34,9 @@ static BYTE *errorRcsId = "$Id$"; /* * $Log$ + * Revision 1.5 2001/06/03 14:16:17 bartoldeman + * BUFFERS tuning and misc bug fixes/cleanups (2024c). + * * Revision 1.4 2001/04/15 03:21:50 bartoldeman * See history.txt for the list of fixes. * @@ -87,6 +90,7 @@ static BYTE *errorRcsId = "$Id$"; #include "globals.h" +#ifdef DEBUG /* error registers */ VOID dump(void) { @@ -105,6 +109,7 @@ VOID dump(void) error_regs.DS, error_regs.ES); } +#endif /* issue a panic message for corrupted data structures */ VOID panic(BYTE * s) @@ -124,8 +129,8 @@ VOID fatal(BYTE * err_msg) /* issue an internal error message */ VOID fatal(BYTE * err_msg) { - printf("\nInternal kernel error - %s\nSystem halted\n", err_msg); - for (;;) ; + printf("\nInternal kernel error - \n"); + panic(err_msg); } #endif diff --git a/kernel/fatdir.c b/kernel/fatdir.c index 3f2de6da..5103e4db 100644 --- a/kernel/fatdir.c +++ b/kernel/fatdir.c @@ -36,6 +36,9 @@ static BYTE *fatdirRcsId = "$Id$"; /* * $Log$ + * Revision 1.16 2001/06/03 14:16:17 bartoldeman + * BUFFERS tuning and misc bug fixes/cleanups (2024c). + * * Revision 1.15 2001/04/29 17:34:40 bartoldeman * A new SYS.COM/config.sys single stepping/console output/misc fixes. * @@ -169,11 +172,11 @@ static BYTE *fatdirRcsId = "$Id$"; * Initial revision. */ -VOID pop_dmp(dmatch FAR *, struct f_node FAR *); +VOID pop_dmp(dmatch FAR *, f_node_ptr); -struct f_node FAR *dir_open(BYTE FAR * dirname) +f_node_ptr dir_open(BYTE FAR * dirname) { - struct f_node FAR *fnp; + f_node_ptr fnp; COUNT drive; BYTE *p; WORD i; @@ -183,9 +186,9 @@ struct f_node FAR *dir_open(BYTE FAR * dirname) BYTE *pszPath = &TempCDS.cdsCurrentPath[2]; /* Allocate an fnode if possible - error return (0) if not. */ - if ((fnp = get_f_node()) == (struct f_node FAR *)0) + if ((fnp = get_f_node()) == (f_node_ptr)0) { - return (struct f_node FAR *)NULL; + return (f_node_ptr)0; } /* Force the fnode into read-write mode */ @@ -255,7 +258,7 @@ struct f_node FAR *dir_open(BYTE FAR * dirname) if (media_check(TempCDS.cdsDpb) < 0) { release_f_node(fnp); - return (struct f_node FAR *)0; + return (f_node_ptr)0; } fnp->f_dsize = DIRENT_SIZE * TempCDS.cdsDpb->dpb_dirents; @@ -329,7 +332,7 @@ struct f_node FAR *dir_open(BYTE FAR * dirname) { release_f_node(fnp); - return (struct f_node FAR *)0; + return (f_node_ptr)0; } else { @@ -354,7 +357,7 @@ struct f_node FAR *dir_open(BYTE FAR * dirname) return fnp; } -COUNT dir_read(REG struct f_node FAR * fnp) +COUNT dir_read(REG f_node_ptr fnp) { /* REG i; */ /* REG j; */ @@ -396,7 +399,7 @@ COUNT dir_read(REG struct f_node FAR * fnp) + fnp->f_dpb->dpb_dirstrt), fnp->f_dpb->dpb_unit); bp->b_flag &= ~(BFR_DATA | BFR_FAT); - bp->b_flag |= BFR_DIR; + bp->b_flag |= BFR_DIR | BFR_VALID; #ifdef DISPLAY_GETBLOCK printf("DIR (dir_read)\n"); #endif @@ -447,7 +450,7 @@ COUNT dir_read(REG struct f_node FAR * fnp) + fnp->f_sector, fnp->f_dpb->dpb_unit); bp->b_flag &= ~(BFR_DATA | BFR_FAT); - bp->b_flag |= BFR_DIR; + bp->b_flag |= BFR_DIR | BFR_VALID; #ifdef DISPLAY_GETBLOCK printf("DIR (dir_read)\n"); #endif @@ -478,7 +481,7 @@ COUNT dir_read(REG struct f_node FAR * fnp) } #ifndef IPL -COUNT dir_write(REG struct f_node FAR * fnp) +COUNT dir_write(REG f_node_ptr fnp) { struct buffer FAR *bp; @@ -494,7 +497,7 @@ COUNT dir_write(REG struct f_node FAR * fnp) + fnp->f_dpb->dpb_dirstrt), fnp->f_dpb->dpb_unit); bp->b_flag &= ~(BFR_DATA | BFR_FAT); - bp->b_flag |= BFR_DIR; + bp->b_flag |= BFR_DIR | BFR_VALID; #ifdef DISPLAY_GETBLOCK printf("DIR (dir_write)\n"); #endif @@ -546,7 +549,7 @@ COUNT dir_write(REG struct f_node FAR * fnp) + fnp->f_sector, fnp->f_dpb->dpb_unit); bp->b_flag &= ~(BFR_DATA | BFR_FAT); - bp->b_flag |= BFR_DIR; + bp->b_flag |= BFR_DIR | BFR_VALID; #ifdef DISPLAY_GETBLOCK printf("DIR (dir_write)\n"); #endif @@ -561,13 +564,13 @@ COUNT dir_write(REG struct f_node FAR * fnp) } putdirent((struct dirent FAR *)&fnp->f_dir, (VOID FAR *) & bp->b_buffer[(UWORD)fnp->f_diroff % fnp->f_dpb->dpb_secsize]); - bp->b_flag |= BFR_DIRTY; + bp->b_flag |= BFR_DIRTY | BFR_VALID; } return DIRENT_SIZE; } #endif -VOID dir_close(REG struct f_node FAR * fnp) +VOID dir_close(REG f_node_ptr fnp) { REG COUNT disk = fnp->f_dpb->dpb_unit; @@ -590,7 +593,7 @@ VOID dir_close(REG struct f_node FAR * fnp) #ifndef IPL COUNT dos_findfirst(UCOUNT attr, BYTE FAR * name) { - REG struct f_node FAR *fnp; + REG f_node_ptr fnp; REG dmatch FAR *dmp = (dmatch FAR *) dta; REG COUNT i; COUNT nDrive; @@ -729,11 +732,11 @@ COUNT dos_findfirst(UCOUNT attr, BYTE FAR * name) COUNT dos_findnext(void) { REG dmatch FAR *dmp = (dmatch FAR *) dta; - REG struct f_node FAR *fnp; + REG f_node_ptr fnp; BOOL found = FALSE; /* Allocate an fnode if possible - error return (0) if not. */ - if ((fnp = get_f_node()) == (struct f_node FAR *)0) + if ((fnp = get_f_node()) == (f_node_ptr)0) { return DE_NFILES; } @@ -804,7 +807,7 @@ COUNT dos_findnext(void) return found ? SUCCESS : DE_NFILES; } -static VOID pop_dmp(dmatch FAR * dmp, struct f_node FAR * fnp) +static VOID pop_dmp(dmatch FAR * dmp, f_node_ptr fnp) { dmp->dm_attr_fnd = fnp->f_dir.dir_attrib; @@ -824,6 +827,11 @@ static VOID pop_dmp(dmatch FAR * dmp, struct f_node FAR * fnp) /* this receives a name in 11 char field NAME+EXT and builds a zeroterminated string + + unfortunately, blanks are allowed in filenames. like + "test e", " test .y z",... + + so we have to work from the last blank backward */ void ConvertName83ToNameSZ(BYTE FAR *destSZ, BYTE FAR *srcFCBName) { @@ -835,24 +843,56 @@ void ConvertName83ToNameSZ(BYTE FAR *destSZ, BYTE FAR *srcFCBName) noExtension = TRUE; } + + + fmemcpy(destSZ,srcFCBName,FNAME_SIZE); + + srcFCBName += FNAME_SIZE; + + for (loop = FNAME_SIZE; --loop >= 0; ) + { + if (destSZ[loop] != ' ') + break; + } + destSZ += loop + 1; + - for (loop = FNAME_SIZE; --loop >= 0; srcFCBName++) - { - if (*srcFCBName != ' ') - *destSZ++ = *srcFCBName; - } if (!noExtension) /* not for ".", ".." */ { - if (*srcFCBName != ' ') + + for (loop = FEXT_SIZE; --loop >= 0; ) { + if (srcFCBName[loop] != ' ') + break; + } + if (loop >= 0) + { *destSZ++ = '.'; - for (loop = FEXT_SIZE; --loop >= 0; srcFCBName++) - { - if (*srcFCBName != ' ') - *destSZ++ = *srcFCBName; - } + fmemcpy(destSZ,srcFCBName,loop+1); + destSZ += loop+1; } } *destSZ = '\0'; } + +/* + returns the asciiSZ length of a 8.3 filename +*/ + +int FileName83Length(BYTE *filename83) +{ + BYTE buff[13]; + + ConvertName83ToNameSZ(buff, filename83); + + return strlen(buff); + +} + + + + + + + diff --git a/kernel/fatfs.c b/kernel/fatfs.c index 3377a68c..466e07e0 100644 --- a/kernel/fatfs.c +++ b/kernel/fatfs.c @@ -35,7 +35,13 @@ BYTE *RcsId = "$Id$"; #endif /* + * the dos_mkdir/extenddir (with getblock() instead of getblockOver) was a real + * performance killer on large drives. (~0.5 sec /dos_mkdir) TE + * * $Log$ + * Revision 1.18 2001/06/03 14:16:17 bartoldeman + * BUFFERS tuning and misc bug fixes/cleanups (2024c). + * * Revision 1.17 2001/04/29 17:34:40 bartoldeman * A new SYS.COM/config.sys single stepping/console output/misc fixes. * @@ -225,26 +231,26 @@ BYTE *RcsId = "$Id$"; /* */ /* function prototypes */ /* */ -struct f_node FAR *xlt_fd(COUNT); -COUNT xlt_fnp(struct f_node FAR *); -struct f_node FAR *split_path(BYTE FAR *, BYTE *, BYTE *, BYTE *); -BOOL find_fname(struct f_node FAR *, BYTE *, BYTE *); +f_node_ptrxlt_fd(COUNT); +COUNT xlt_fnp(f_node_ptr); +f_node_ptr split_path(BYTE FAR *, BYTE *, BYTE *, BYTE *); +BOOL find_fname(f_node_ptr, BYTE *, BYTE *); /* /// Added - Ron Cemer */ -static void merge_file_changes(struct f_node FAR *fnp, int collect); +STATIC void merge_file_changes(f_node_ptr fnp, int collect); /* /// Added - Ron Cemer */ -static int is_same_file(struct f_node FAR *fnp1, struct f_node FAR *fnp2); +STATIC int is_same_file(f_node_ptr fnp1, f_node_ptr fnp2); /* /// Added - Ron Cemer */ -static void copy_file_changes(struct f_node FAR *src, struct f_node FAR *dst); +STATIC void copy_file_changes(f_node_ptr src, f_node_ptr dst); date dos_getdate(VOID); time dos_gettime(VOID); -BOOL find_free(struct f_node FAR *); -UWORD find_fat_free(struct f_node FAR *); -VOID wipe_out(struct f_node FAR *); -BOOL last_link(struct f_node FAR *); -BOOL extend(struct f_node FAR *); -COUNT extend_dir(struct f_node FAR *); -BOOL first_fat(struct f_node FAR *); -COUNT map_cluster(struct f_node FAR *, COUNT); +BOOL find_free(f_node_ptr); +UWORD find_fat_free(f_node_ptr); +VOID wipe_out(f_node_ptr); +BOOL last_link(f_node_ptr); +BOOL extend(f_node_ptr); +COUNT extend_dir(f_node_ptr); +BOOL first_fat(f_node_ptr); +COUNT map_cluster(f_node_ptr, COUNT); /************************************************************************/ /* */ @@ -258,7 +264,7 @@ COUNT map_cluster(struct f_node FAR *, COUNT); COUNT dos_open(BYTE FAR * path, COUNT flag) { - REG struct f_node FAR *fnp; + REG f_node_ptr fnp; /* First test the flag to see if the user has passed a valid */ /* file mode... */ @@ -331,7 +337,7 @@ BOOL fcmp_wild(BYTE FAR * s1, BYTE FAR * s2, COUNT n) COUNT dos_close(COUNT fd) { - struct f_node FAR *fnp; + f_node_ptr fnp; /* Translate the fd into a useful pointer */ fnp = xlt_fd(fd); @@ -339,7 +345,7 @@ COUNT dos_close(COUNT fd) /* If the fd was invalid because it was out of range or the */ /* requested file was not open, tell the caller and exit */ /* note: an invalid fd is indicated by a 0 return */ - if (fnp == (struct f_node FAR *)0 || fnp->f_count <= 0) + if (fnp == (f_node_ptr)0 || fnp->f_count <= 0) return DE_INVLDHNDL; if (fnp->f_mode != RDONLY) @@ -365,17 +371,17 @@ COUNT dos_close(COUNT fd) /* */ /* split a path into it's component directory and file name */ /* */ -struct f_node FAR * +f_node_ptr split_path(BYTE FAR * path, BYTE * dname, BYTE * fname, BYTE * fext) { - REG struct f_node FAR *fnp; + REG f_node_ptr fnp; COUNT nDrive; struct cds FAR *cdsp; /* Start off by parsing out the components. */ if (ParseDosName(adjust_far(path), &nDrive, &dname[2], fname, fext, FALSE) != SUCCESS) - return (struct f_node FAR *)0; + return (f_node_ptr)0; if (nDrive < 0) nDrive = default_drive; @@ -387,7 +393,7 @@ struct f_node FAR * SpacePad(fext, FEXT_SIZE); if (nDrive >= lastdrive) { - return (struct f_node FAR *)0; + return (f_node_ptr)0; } cdsp = &CDSp->cds_table[nDrive]; @@ -413,7 +419,7 @@ struct f_node FAR * if (cdsp->cdsFlags & CDSNETWDRV) { printf("split path called for redirected file: `%s.%s'\n", fname, fext); - return (struct f_node FAR *)0; + return (f_node_ptr)0; } #endif @@ -423,10 +429,10 @@ struct f_node FAR * /* If the fd was invalid because it was out of range or the */ /* requested file was not open, tell the caller and exit... */ /* note: an invalid fd is indicated by a 0 return */ - if (fnp == (struct f_node FAR *)0 || fnp->f_count <= 0) + if (fnp == (f_node_ptr)0 || fnp->f_count <= 0) { dir_close(fnp); - return (struct f_node FAR *)0; + return (f_node_ptr)0; } /* Convert the name into an absolute name for comparison... */ @@ -437,7 +443,7 @@ struct f_node FAR * return fnp; } -static BOOL find_fname(struct f_node FAR * fnp, BYTE * fname, BYTE * fext) +STATIC BOOL find_fname(f_node_ptr fnp, BYTE * fname, BYTE * fext) { BOOL found = FALSE; @@ -469,14 +475,14 @@ static BOOL find_fname(struct f_node FAR * fnp, BYTE * fname, BYTE * fext) reasons, since DOS without SHARE does not share changes between two or more open instances of the same file unless these instances were generated by dup() or dup2(). */ -static void merge_file_changes(struct f_node FAR *fnp, int collect) { - struct f_node FAR *fnp2; +STATIC void merge_file_changes(f_node_ptr fnp, int collect) { + f_node_ptr fnp2; int i; if (!IsShareInstalled()) return; for (i = 0; i < f_nodes_cnt; i++) { - fnp2 = &f_nodes[i]; - if ( (fnp != (struct f_node FAR *)0) + fnp2 = (f_node_ptr)&f_nodes[i]; + if ( (fnp != (f_node_ptr)0) && (fnp != fnp2) && (fnp->f_count > 0) && (is_same_file(fnp, fnp2)) ) { @@ -501,7 +507,7 @@ static void merge_file_changes(struct f_node FAR *fnp, int collect) { } /* /// Added - Ron Cemer */ -static int is_same_file(struct f_node FAR *fnp1, struct f_node FAR *fnp2) { +STATIC int is_same_file(f_node_ptr fnp1, f_node_ptr fnp2) { return (fnp1->f_dpb->dpb_unit == fnp2->f_dpb->dpb_unit) && (fnp1->f_dpb->dpb_subunit == fnp2->f_dpb->dpb_subunit) @@ -520,7 +526,7 @@ static int is_same_file(struct f_node FAR *fnp1, struct f_node FAR *fnp2) { } /* /// Added - Ron Cemer */ -static void copy_file_changes(struct f_node FAR *src, struct f_node FAR *dst) { +STATIC void copy_file_changes(f_node_ptr src, f_node_ptr dst) { dst->f_highwater = src->f_highwater; dst->f_dir.dir_start = src->f_dir.dir_start; dst->f_dir.dir_size = src->f_dir.dir_size; @@ -530,7 +536,7 @@ static void copy_file_changes(struct f_node FAR *src, struct f_node FAR *dst) { COUNT dos_creat(BYTE FAR * path, COUNT attrib) { - REG struct f_node FAR *fnp; + REG f_node_ptr fnp; /* NEVER EVER allow directories to be created */ if (attrib & ~(D_RDONLY|D_HIDDEN|D_SYSTEM|D_ARCHIVE)) @@ -638,7 +644,7 @@ COUNT dos_creat(BYTE FAR * path, COUNT attrib) COUNT dos_delete(BYTE FAR * path) { - REG struct f_node FAR *fnp; + REG f_node_ptr fnp; /* first split the passed dir into components (i.e. - */ /* path to new directory and name of new directory */ @@ -687,8 +693,8 @@ COUNT dos_delete(BYTE FAR * path) COUNT dos_rmdir(BYTE FAR * path) { - REG struct f_node FAR *fnp; - REG struct f_node FAR *fnp1; + REG f_node_ptr fnp; + REG f_node_ptr fnp1; BOOL found; /* first split the passed dir into comopnents (i.e. - */ @@ -713,7 +719,13 @@ COUNT dos_rmdir(BYTE FAR * path) /* The only permissable attribute is directory, */ /* check for any other bit set. If it is, give */ /* an access error. */ - if (fnp->f_dir.dir_attrib & ~D_DIR) + /* if (fnp->f_dir.dir_attrib & ~D_DIR) */ + + /* directories may have attributes, too. at least my WinNT disk + has many 'archive' directories + we still don't allow SYSTEM or RDONLY directories to be deleted TE*/ + + if (fnp->f_dir.dir_attrib & ~(D_DIR |D_HIDDEN|D_ARCHIVE)) { dir_close(fnp); return DE_ACCESS; @@ -787,8 +799,8 @@ COUNT dos_rmdir(BYTE FAR * path) COUNT dos_rename(BYTE FAR * path1, BYTE FAR * path2) { - REG struct f_node FAR *fnp1; - REG struct f_node FAR *fnp2; + REG f_node_ptr fnp1; + REG f_node_ptr fnp2; BOOL is_free; /* first split the passed target into compnents (i.e. - path to */ @@ -886,7 +898,7 @@ COUNT dos_rename(BYTE FAR * path1, BYTE FAR * path2) /* */ /* wipe out all FAT entries for create, delete, etc. */ /* */ -static VOID wipe_out(struct f_node FAR * fnp) +STATIC VOID wipe_out(f_node_ptr fnp) { REG UWORD st, next; @@ -926,7 +938,7 @@ static VOID wipe_out(struct f_node FAR * fnp) } } -static BOOL find_free(struct f_node FAR * fnp) +STATIC BOOL find_free(f_node_ptr fnp) { while (dir_read(fnp) == DIRENT_SIZE) { @@ -995,7 +1007,7 @@ time dos_gettime() /* */ COUNT dos_getftime(COUNT fd, date FAR * dp, time FAR * tp) { - struct f_node FAR *fnp; + f_node_ptr fnp; /* Translate the fd into an fnode pointer, since all internal */ /* operations are achieved through fnodes. */ @@ -1004,7 +1016,7 @@ COUNT dos_getftime(COUNT fd, date FAR * dp, time FAR * tp) /* If the fd was invalid because it was out of range or the */ /* requested file was not open, tell the caller and exit */ /* note: an invalid fd is indicated by a 0 return */ - if (fnp == (struct f_node FAR *)0 || fnp->f_count <= 0) + if (fnp == (f_node_ptr)0 || fnp->f_count <= 0) return DE_INVLDHNDL; /* Get the date and time from the fnode and return */ @@ -1019,7 +1031,7 @@ COUNT dos_getftime(COUNT fd, date FAR * dp, time FAR * tp) /* */ COUNT dos_setftime(COUNT fd, date FAR * dp, time FAR * tp) { - struct f_node FAR *fnp; + f_node_ptr fnp; /* Translate the fd into an fnode pointer, since all internal */ /* operations are achieved through fnodes. */ @@ -1028,7 +1040,7 @@ COUNT dos_setftime(COUNT fd, date FAR * dp, time FAR * tp) /* If the fd was invalid because it was out of range or the */ /* requested file was not open, tell the caller and exit */ /* note: an invalid fd is indicated by a 0 return */ - if (fnp == (struct f_node FAR *)0 || fnp->f_count <= 0) + if (fnp == (f_node_ptr)0 || fnp->f_count <= 0) return DE_INVLDHNDL; /* Set the date and time from the fnode and return */ @@ -1043,7 +1055,7 @@ COUNT dos_setftime(COUNT fd, date FAR * dp, time FAR * tp) /* */ LONG dos_getcufsize(COUNT fd) { - struct f_node FAR *fnp; + f_node_ptr fnp; /* Translate the fd into an fnode pointer, since all internal */ /* operations are achieved through fnodes. */ @@ -1052,7 +1064,7 @@ LONG dos_getcufsize(COUNT fd) /* If the fd was invalid because it was out of range or the */ /* requested file was not open, tell the caller and exit */ /* note: an invalid fd is indicated by a 0 return */ - if (fnp == (struct f_node FAR *)0 || fnp->f_count <= 0) + if (fnp == (f_node_ptr)0 || fnp->f_count <= 0) return -1l; /* Return the file size */ @@ -1064,7 +1076,7 @@ LONG dos_getcufsize(COUNT fd) /* */ LONG dos_getfsize(COUNT fd) { - struct f_node FAR *fnp; + f_node_ptr fnp; /* Translate the fd into an fnode pointer, since all internal */ /* operations are achieved through fnodes. */ @@ -1073,7 +1085,7 @@ LONG dos_getfsize(COUNT fd) /* If the fd was invalid because it was out of range or the */ /* requested file was not open, tell the caller and exit */ /* note: an invalid fd is indicated by a 0 return */ - if (fnp == (struct f_node FAR *)0 || fnp->f_count <= 0) + if (fnp == (f_node_ptr)0 || fnp->f_count <= 0) return -1l; /* Return the file size */ @@ -1085,7 +1097,7 @@ LONG dos_getfsize(COUNT fd) /* */ BOOL dos_setfsize(COUNT fd, LONG size) { - struct f_node FAR *fnp; + f_node_ptr fnp; /* Translate the fd into an fnode pointer, since all internal */ /* operations are achieved through fnodes. */ @@ -1094,7 +1106,7 @@ BOOL dos_setfsize(COUNT fd, LONG size) /* If the fd was invalid because it was out of range or the */ /* requested file was not open, tell the caller and exit */ /* note: an invalid fd is indicated by a 0 return */ - if (fnp == (struct f_node FAR *)0 || fnp->f_count <= 0) + if (fnp == (f_node_ptr)0 || fnp->f_count <= 0) return FALSE; /* Change the file size */ @@ -1109,7 +1121,7 @@ BOOL dos_setfsize(COUNT fd, LONG size) /* */ /* Find free cluster in disk FAT table */ /* */ -static UWORD find_fat_free(struct f_node FAR * fnp) +STATIC UWORD find_fat_free(f_node_ptr fnp) { REG UWORD idx; @@ -1144,15 +1156,14 @@ static UWORD find_fat_free(struct f_node FAR * fnp) } /* */ -/* crate a directory - returns success or a negative error */ +/* create a directory - returns success or a negative error */ /* number */ /* */ COUNT dos_mkdir(BYTE FAR * dir) { - REG struct f_node FAR *fnp; + REG f_node_ptr fnp; REG COUNT idx; struct buffer FAR *bp; - BYTE FAR *p; UWORD free_fat; UWORD parent; @@ -1163,6 +1174,28 @@ COUNT dos_mkdir(BYTE FAR * dir) dir_close(fnp); return DE_PATHNOTFND; } + + /* check that the resulting combined path does not exceed + the 64 PARSE_MAX limit. this leeds to problems: + A) you can't CD to this directory later + B) you can't create files in this subdirectory + C) the created dir will not be found later, so you + can create an unlimited amount of same dirs. this space + is lost forever + */ + if (2 /* "C" */ + + strlen(szDirName) + + 1 /* "\\" */ + + FileName83Length(szFileName) /* the SZ is not SZ, of course */ + > PARSE_MAX+2) + { + dir_close(fnp); + return DE_PATHNOTFND; + } + + + + /* Check that we don't have a duplicate name, so if we */ /* find one, it's an error. */ @@ -1244,7 +1277,8 @@ COUNT dos_mkdir(BYTE FAR * dir) /* Craft the new directory. Note that if we're in a new */ /* directory just under the root, ".." pointer is 0. */ - bp = getblock((ULONG) clus2phys(free_fat, + /* as we are overwriting it completely, don't read first */ + bp = getblockOver((ULONG) clus2phys(free_fat, (fnp->f_dpb->dpb_clsmask + 1), fnp->f_dpb->dpb_data), fnp->f_dpb->dpb_unit); @@ -1277,19 +1311,17 @@ COUNT dos_mkdir(BYTE FAR * dir) putdirent((struct dirent FAR *)&DirEntBuffer, (BYTE FAR *) & bp->b_buffer[DIRENT_SIZE]); /* fill the rest of the block with zeros */ - for (p = (BYTE FAR *) & bp->b_buffer[2 * DIRENT_SIZE]; - p < &bp->b_buffer[BUFFERSIZE];) - *p++ = NULL; + fmemset( & bp->b_buffer[2 * DIRENT_SIZE],0, BUFFERSIZE - 2 * DIRENT_SIZE); /* Mark the block to be written out */ - bp->b_flag |= BFR_DIRTY; + bp->b_flag |= BFR_DIRTY | BFR_VALID; /* clear out the rest of the blocks in the cluster */ for (idx = 1; idx < (fnp->f_dpb->dpb_clsmask + 1); idx++) { - REG COUNT i; - bp = getblock((ULONG) clus2phys(fnp->f_dir.dir_start, + /* as we are overwriting it completely, don't read first */ + bp = getblockOver((ULONG) clus2phys(fnp->f_dir.dir_start, (fnp->f_dpb->dpb_clsmask + 1), fnp->f_dpb->dpb_data) + idx, fnp->f_dpb->dpb_unit); @@ -1301,9 +1333,9 @@ COUNT dos_mkdir(BYTE FAR * dir) dir_close(fnp); return DE_BLKINVLD; } - for (i = 0, p = (BYTE FAR *) bp->b_buffer; i < BUFFERSIZE; i++) - *p++ = NULL; - bp->b_flag |= BFR_DIRTY; + fmemset(bp->b_buffer, 0, BUFFERSIZE); + bp->b_flag |= BFR_DIRTY | BFR_VALID; + bp->b_flag |= BFR_UNCACHE; /* need not be cached */ } /* flush the drive buffers so that all info is written */ @@ -1316,12 +1348,12 @@ COUNT dos_mkdir(BYTE FAR * dir) return SUCCESS; } -BOOL last_link(struct f_node FAR * fnp) +BOOL last_link(f_node_ptr fnp) { return (((UWORD) fnp->f_cluster == (UWORD) LONG_LAST_CLUSTER)); } -static BOOL extend(struct f_node FAR * fnp) +STATIC BOOL extend(f_node_ptr fnp) { UWORD free_fat; @@ -1347,7 +1379,7 @@ static BOOL extend(struct f_node FAR * fnp) return TRUE; } -static COUNT extend_dir(struct f_node FAR * fnp) +STATIC COUNT extend_dir(f_node_ptr fnp) { REG COUNT idx; @@ -1360,11 +1392,9 @@ static COUNT extend_dir(struct f_node FAR * fnp) /* clear out the rest of the blocks in the cluster */ for (idx = 0; idx < (fnp->f_dpb->dpb_clsmask + 1); idx++) { - REG COUNT i; - REG BYTE FAR *p; REG struct buffer FAR *bp; - bp = getblock((ULONG) clus2phys(fnp->f_cluster, + bp = getblockOver((ULONG) clus2phys(fnp->f_cluster, (fnp->f_dpb->dpb_clsmask + 1), fnp->f_dpb->dpb_data) + idx, fnp->f_dpb->dpb_unit); @@ -1376,9 +1406,11 @@ static COUNT extend_dir(struct f_node FAR * fnp) dir_close(fnp); return DE_BLKINVLD; } - for (i = 0, p = (BYTE FAR *) bp->b_buffer; i < BUFFERSIZE; i++) - *p++ = NULL; - bp->b_flag |= BFR_DIRTY; + fmemset(bp->b_buffer,0, BUFFERSIZE); + bp->b_flag |= BFR_DIRTY | BFR_VALID; + + if (idx != 0) + bp->b_flag |= BFR_UNCACHE; /* needs not be cached */ } if (!find_free(fnp)) @@ -1395,7 +1427,7 @@ static COUNT extend_dir(struct f_node FAR * fnp) } /* JPP: finds the next free cluster in the FAT */ -static BOOL first_fat(struct f_node FAR * fnp) +STATIC BOOL first_fat(f_node_ptr fnp) { UWORD free_fat; @@ -1424,10 +1456,10 @@ static BOOL first_fat(struct f_node FAR * fnp) /* JPP: new map_cluster. If we are moving forward, then use the offset that we are at now (f_cluster_offset) to start, instead of starting at the beginning. */ -COUNT map_cluster(REG struct f_node FAR * fnp, COUNT mode) +COUNT map_cluster(REG f_node_ptr fnp, COUNT mode) { ULONG idx; - UWORD clssize; + ULONG clssize; /* might be 64K (by WinNT) TE */ #ifdef DISPLAY_GETBLOCK printf("map_cluster: current %lu, offset %lu, diff=%lu ", @@ -1435,7 +1467,7 @@ COUNT map_cluster(REG struct f_node FAR * fnp, COUNT mode) fnp->f_offset - fnp->f_cluster_offset); #endif /* The variable clssize will be used later. */ - clssize = fnp->f_dpb->dpb_secsize * (fnp->f_dpb->dpb_clsmask + 1); + clssize = (ULONG)fnp->f_dpb->dpb_secsize * (fnp->f_dpb->dpb_clsmask + 1); /* If someone did a seek, but no writes have occured, we will */ /* need to initialize the fnode. */ @@ -1504,7 +1536,7 @@ COUNT map_cluster(REG struct f_node FAR * fnp, COUNT mode) /* Read block from disk */ UCOUNT readblock(COUNT fd, VOID FAR * buffer, UCOUNT count, COUNT * err) { - REG struct f_node FAR *fnp; + REG f_node_ptr fnp; REG struct buffer FAR *bp; UCOUNT xfr_cnt = 0; UCOUNT ret_cnt = 0; @@ -1525,7 +1557,7 @@ UCOUNT readblock(COUNT fd, VOID FAR * buffer, UCOUNT count, COUNT * err) /* If the fd was invalid because it was out of range or the */ /* requested file was not open, tell the caller and exit */ /* note: an invalid fd is indicated by a 0 return */ - if (fnp == (struct f_node FAR *)0 || fnp->f_count <= 0) + if (fnp == (f_node_ptr)0 || fnp->f_count <= 0) { *err = DE_INVLDHNDL; return 0; @@ -1650,7 +1682,7 @@ UCOUNT readblock(COUNT fd, VOID FAR * buffer, UCOUNT count, COUNT * err) #ifdef DISPLAY_GETBLOCK printf("DATA (readblock)\n"); #endif - if (bp == (struct buffer *)0) + if (bp == NULL) /* (struct buffer *)0 --> DS:0 !! */ { *err = DE_BLKINVLD; return ret_cnt; @@ -1669,6 +1701,15 @@ UCOUNT readblock(COUNT fd, VOID FAR * buffer, UCOUNT count, COUNT * err) fbcopy((BYTE FAR *) & bp->b_buffer[fnp->f_boff], buffer, xfr_cnt); + /* complete buffer read ? + probably not reused later + */ + if (xfr_cnt == sizeof(bp->b_buffer) || + fnp->f_offset + xfr_cnt == fnp->f_dir.dir_size ) + { + bp->b_flag |= BFR_UNCACHE; + } + /* update pointers and counters */ ret_cnt += xfr_cnt; to_xfer -= xfr_cnt; @@ -1682,7 +1723,7 @@ UCOUNT readblock(COUNT fd, VOID FAR * buffer, UCOUNT count, COUNT * err) /* Write block to disk */ UCOUNT writeblock(COUNT fd, VOID FAR * buffer, UCOUNT count, COUNT * err) { - REG struct f_node FAR *fnp; + REG f_node_ptr fnp; struct buffer FAR *bp; UCOUNT xfr_cnt = 0; UCOUNT ret_cnt = 0; @@ -1703,7 +1744,7 @@ UCOUNT writeblock(COUNT fd, VOID FAR * buffer, UCOUNT count, COUNT * err) /* If the fd was invalid because it was out of range or the */ /* requested file was not open, tell the caller and exit */ /* note: an invalid fd is indicated by a 0 return */ - if (fnp == (struct f_node FAR *)0 || fnp->f_count <= 0) + if (fnp == (f_node_ptr)0 || fnp->f_count <= 0) { *err = DE_INVLDHNDL; return 0; @@ -1872,19 +1913,22 @@ UCOUNT writeblock(COUNT fd, VOID FAR * buffer, UCOUNT count, COUNT * err) potential problems. - Ron Cemer */ if ( (fnp->f_boff == 0) && (xfr_cnt == secsize) ) { - if (!getbuf(&bp, (ULONG) clus2phys(fnp->f_cluster, + bp = getblockOver((ULONG) clus2phys(fnp->f_cluster, (fnp->f_dpb->dpb_clsmask + 1), fnp->f_dpb->dpb_data) + fnp->f_sector, - fnp->f_dpb->dpb_unit)) { - *err = DE_BLKINVLD; - return ret_cnt; - } + fnp->f_dpb->dpb_unit); + } else { bp = getblock((ULONG) clus2phys(fnp->f_cluster, (fnp->f_dpb->dpb_clsmask + 1), fnp->f_dpb->dpb_data) + fnp->f_sector, fnp->f_dpb->dpb_unit); } + if (bp == NULL) { + *err = DE_BLKINVLD; + return ret_cnt; + } + /* transfer a block */ /* Transfer size as either a full block size, or the */ @@ -1899,6 +1943,12 @@ UCOUNT writeblock(COUNT fd, VOID FAR * buffer, UCOUNT count, COUNT * err) fbcopy(buffer, (BYTE FAR *) & bp->b_buffer[fnp->f_boff], xfr_cnt); bp->b_flag |= BFR_DIRTY | BFR_VALID; + if (xfr_cnt == sizeof(bp->b_buffer)) /* probably not used later */ + { + bp->b_flag |= BFR_UNCACHE; + } + + fnp->f_flags.f_dmod = TRUE; /* mark file as modified */ @@ -1930,7 +1980,7 @@ COUNT dos_read(COUNT fd, VOID FAR * buffer, UCOUNT count) #ifndef IPL COUNT dos_write(COUNT fd, VOID FAR * buffer, UCOUNT count) { - REG struct f_node FAR *fnp; + REG f_node_ptr fnp; COUNT err, xfr; @@ -1943,7 +1993,7 @@ COUNT dos_write(COUNT fd, VOID FAR * buffer, UCOUNT count) /* If the fd was invalid because it was out of range or the */ /* requested file was not open, tell the caller and exit */ /* note: an invalid fd is indicated by a 0 return */ - if (fnp == (struct f_node FAR *)0 || fnp->f_count <= 0) + if (fnp == (f_node_ptr)0 || fnp->f_count <= 0) { return DE_INVLDHNDL; } @@ -1975,7 +2025,7 @@ COUNT dos_write(COUNT fd, VOID FAR * buffer, UCOUNT count) /* Returns a long current offset or a negative error code */ LONG dos_lseek(COUNT fd, LONG foffset, COUNT origin) { - REG struct f_node FAR *fnp; + REG f_node_ptr fnp; /* Translate the fd into a useful pointer */ @@ -1985,7 +2035,7 @@ LONG dos_lseek(COUNT fd, LONG foffset, COUNT origin) /* requested file was not open, tell the caller and exit */ /* note: an invalid fd is indicated by a 0 return */ - if (fnp == (struct f_node FAR *)0 || fnp->f_count <= 0) + if (fnp == (f_node_ptr)0 || fnp->f_count <= 0) return (LONG) DE_INVLDHNDL; /* now do the actual lseek adjustment to the file poitner */ @@ -2043,7 +2093,7 @@ UWORD dos_free(struct dpb FAR *dpbp) #ifndef IPL COUNT dos_cd(struct cds FAR * cdsp, BYTE FAR *PathName) { - struct f_node FAR *fnp; + f_node_ptr fnp; /* first check for valid drive */ if (cdsp->cdsDpb == 0) @@ -2060,14 +2110,14 @@ COUNT dos_cd(struct cds FAR * cdsp, BYTE FAR *PathName) cdsp->cdsStrtClst = fnp->f_dirstart; dir_close(fnp); - fscopy(&PathName[0], cdsp->cdsCurrentPath); + fstrncpy(cdsp->cdsCurrentPath,&PathName[0],sizeof(cdsp->cdsCurrentPath)-1); return SUCCESS; } #endif /* Try to allocate an f_node from the available files array */ -struct f_node FAR *get_f_node(void) +f_node_ptr get_f_node(void) { REG i; @@ -2079,10 +2129,10 @@ struct f_node FAR *get_f_node(void) return &f_nodes[i]; } } - return (struct f_node FAR *)0; + return (f_node_ptr)0; } -VOID release_f_node(struct f_node FAR * fnp) +VOID release_f_node(f_node_ptr fnp) { if (fnp->f_count > 0) --fnp->f_count; @@ -2098,7 +2148,7 @@ VOID dos_setdta(BYTE FAR * newdta) COUNT dos_getfattr(BYTE FAR * name, UWORD FAR * attrp) { - struct f_node FAR *fnp; + f_node_ptr fnp; COUNT fd; /* Translate the fd into an fnode pointer, since all internal */ @@ -2107,7 +2157,7 @@ COUNT dos_getfattr(BYTE FAR * name, UWORD FAR * attrp) return DE_FILENOTFND; /* note: an invalid fd is indicated by a 0 return */ - if ((fnp = xlt_fd(fd)) == (struct f_node FAR *)0) + if ((fnp = xlt_fd(fd)) == (f_node_ptr)0) return DE_TOOMANY; /* If the fd was invalid because it was out of range or the */ @@ -2126,7 +2176,7 @@ COUNT dos_getfattr(BYTE FAR * name, UWORD FAR * attrp) COUNT dos_setfattr(BYTE FAR * name, UWORD FAR * attrp) { - struct f_node FAR *fnp; + f_node_ptr fnp; COUNT fd; /* Translate the fd into an fnode pointer, since all internal */ @@ -2135,7 +2185,7 @@ COUNT dos_setfattr(BYTE FAR * name, UWORD FAR * attrp) return DE_FILENOTFND; /* note: an invalid fd is indicated by a 0 return */ - if ((fnp = xlt_fd(fd)) == (struct f_node FAR *)0) + if ((fnp = xlt_fd(fd)) == (f_node_ptr)0) return DE_TOOMANY; /* If the fd was invalid because it was out of range or the */ @@ -2292,13 +2342,13 @@ COUNT media_check(REG struct dpb FAR * dpbp) } /* translate the fd into an f_node pointer */ -struct f_node FAR *xlt_fd(COUNT fd) +f_node_ptr xlt_fd(COUNT fd) { - return fd >= f_nodes_cnt ? (struct f_node FAR *)0 : &f_nodes[fd]; + return fd >= f_nodes_cnt ? (f_node_ptr)0 : &f_nodes[fd]; } /* translate the f_node pointer into an fd */ -COUNT xlt_fnp(struct f_node FAR * fnp) +COUNT xlt_fnp(f_node_ptr fnp) { return (COUNT)(fnp - f_nodes); } diff --git a/kernel/fattab.c b/kernel/fattab.c index c688d180..3e7d0cc2 100644 --- a/kernel/fattab.c +++ b/kernel/fattab.c @@ -35,6 +35,9 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.6 2001/06/03 14:16:17 bartoldeman + * BUFFERS tuning and misc bug fixes/cleanups (2024c). + * * Revision 1.5 2001/04/21 22:32:53 bartoldeman * Init DS=Init CS, fixed stack overflow problems and misc bugs. * @@ -122,6 +125,33 @@ UWORD next_cl16(); /* */ /************************************************************************/ +struct buffer FAR *getFATblock(UWORD cluster, struct dpb FAR *dpbp) +{ + ULONG sector; + struct buffer FAR *bp; + + if (ISFAT12(dpbp)) + { + sector = ((cluster << 1) + cluster) >> 1; + } + else /* FAT16 */ + { + sector = (ULONG)cluster * SIZEOF_CLST16; + } + sector = sector / dpbp->dpb_secsize + dpbp->dpb_fatstrt; + + bp = getblock(sector, dpbp->dpb_unit); + + if (bp) + { + bp->b_flag &= ~(BFR_DATA | BFR_DIR); + bp->b_flag |= BFR_FAT | BFR_VALID; + bp->b_copies = dpbp->dpb_fats; + bp->b_offset_lo = dpbp->dpb_fatsize; + bp->b_offset_hi = dpbp->dpb_fatsize >> 8; + } + return bp; +} /* */ /* The FAT file system is difficult to trace through FAT table. */ /* There are two kinds of FAT's, 12 bit and 16 bit. The 16 bit */ @@ -152,30 +182,21 @@ UCOUNT link_fat16(struct dpb FAR *dpbp, UCOUNT Cluster1, UCOUNT Cluster2) { UCOUNT idx; struct buffer FAR *bp; - UWORD Cl2 = Cluster2; /* Get the block that this cluster is in */ - bp = getblock((ULONG) (((ULONG) Cluster1) * SIZEOF_CLST16) / dpbp->dpb_secsize + dpbp->dpb_fatstrt, - dpbp->dpb_unit); -#ifdef DISPLAY_GETBLOCK - printf("FAT (link_fat16)\n"); -#endif + bp = getFATblock( Cluster1, dpbp); + if (bp == NULL) return DE_BLKINVLD; - bp->b_flag &= ~(BFR_DATA | BFR_DIR); - bp->b_flag |= BFR_FAT; - bp->b_copies = dpbp->dpb_fats; - bp->b_offset_lo = dpbp->dpb_fatsize; - bp->b_offset_hi = dpbp->dpb_fatsize >> 8; /* form an index so that we can read the block as a */ /* byte array */ - idx = (UWORD)((((LONG) Cluster1) * SIZEOF_CLST16) % dpbp->dpb_secsize); + idx = (UWORD)(( Cluster1 * SIZEOF_CLST16) % dpbp->dpb_secsize); /* Finally, put the word into the buffer and mark the */ /* buffer as dirty. */ - fputword((WORD FAR *) & Cl2, (VOID FAR *) & (bp->b_buffer[idx])); - bp->b_flag |= BFR_DIRTY; + fputword((WORD FAR *) & Cluster2, (VOID FAR *) & (bp->b_buffer[idx])); + bp->b_flag |= BFR_DIRTY | BFR_VALID; /* Return successful. */ /* update the free space count */ @@ -206,18 +227,9 @@ UCOUNT link_fat12(struct dpb FAR *dpbp, UCOUNT Cluster1, UCOUNT Cluster2) FAR * bp1; /* Get the block that this cluster is in */ - bp = getblock((ULONG) ((((Cluster1 << 1) + Cluster1) >> 1) / dpbp->dpb_secsize + dpbp->dpb_fatstrt), - dpbp->dpb_unit); -#ifdef DISPLAY_GETBLOCK - printf("FAT (link_fat12)\n"); -#endif + bp = getFATblock(Cluster1 , dpbp); if (bp == NULL) return DE_BLKINVLD; - bp->b_flag &= ~(BFR_DATA | BFR_DIR); - bp->b_flag |= BFR_FAT; - bp->b_copies = dpbp->dpb_fats; - bp->b_offset_lo = dpbp->dpb_fatsize; - bp->b_offset_hi = dpbp->dpb_fatsize >> 8; /* form an index so that we can read the block as a */ /* byte array */ @@ -229,26 +241,18 @@ UCOUNT link_fat12(struct dpb FAR *dpbp, UCOUNT Cluster1, UCOUNT Cluster2) /* block. */ if (idx >= dpbp->dpb_secsize - 1) { - bp1 = getblock((ULONG) (dpbp->dpb_fatstrt + - ((((Cluster1 << 1) + Cluster1) >> 1) / dpbp->dpb_secsize)) - + 1, - dpbp->dpb_unit); -#ifdef DISPLAY_GETBLOCK - printf("FAT (link_fat12)\n"); -#endif - if (bp1 == (struct buffer *)0) + bp1 = getFATblock(Cluster1 + 1,dpbp); + if (bp1 == 0) return DE_BLKINVLD; - bp1->b_flag &= ~(BFR_DATA | BFR_DIR); - bp1->b_flag |= BFR_FAT | BFR_DIRTY; - bp1->b_copies = dpbp->dpb_fats; - bp1->b_offset_lo = dpbp->dpb_fatsize; - bp1->b_offset_hi = dpbp->dpb_fatsize >> 8; + + bp1->b_flag |= BFR_DIRTY | BFR_VALID; + fbp1 = (UBYTE FAR *) & (bp1->b_buffer[0]); } else fbp1 = (UBYTE FAR *) & (bp->b_buffer[idx + 1]); fbp0 = (UBYTE FAR *) & (bp->b_buffer[idx]); - bp->b_flag |= BFR_DIRTY; + bp->b_flag |= BFR_DIRTY | BFR_VALID; /* Now pack the value in */ if (Cluster1 & 0x01) @@ -298,20 +302,10 @@ UWORD next_cl16(struct dpb FAR *dpbp, UCOUNT ClusterNum) struct buffer FAR *bp; /* Get the block that this cluster is in */ - bp = getblock((ULONG) (((ULONG) ClusterNum) * SIZEOF_CLST16) / dpbp->dpb_secsize + dpbp->dpb_fatstrt, - dpbp->dpb_unit); -#ifdef DISPLAY_GETBLOCK - printf("FAT (next_cl16)\n"); -#endif + bp = getFATblock( ClusterNum, dpbp); + if (bp == NULL) return DE_BLKINVLD; - bp->b_flag &= ~(BFR_DATA | BFR_DIR); - bp->b_flag |= BFR_FAT; - bp->b_copies = dpbp->dpb_fats; - bp->b_offset_lo = dpbp->dpb_fatsize; - bp->b_offset_hi = dpbp->dpb_fatsize >> 8; - - #ifndef I86 UCOUNT idx; @@ -330,7 +324,7 @@ UWORD next_cl16(struct dpb FAR *dpbp, UCOUNT ClusterNum) #else /* this saves 2 WORDS of stack :-) */ - return *(WORD FAR *)&(bp->b_buffer[(ClusterNum * SIZEOF_CLST16) % dpbp->dpb_secsize]); + return *(UWORD FAR *)&(bp->b_buffer[(ClusterNum * SIZEOF_CLST16) % dpbp->dpb_secsize]); #endif @@ -345,18 +339,10 @@ UWORD next_cl12(struct dpb FAR *dpbp, REG UCOUNT ClusterNum) FAR * bp1; /* Get the block that this cluster is in */ - bp = getblock((ULONG) ((((ClusterNum << 1) + ClusterNum) >> 1) / dpbp->dpb_secsize + dpbp->dpb_fatstrt), - dpbp->dpb_unit); -#ifdef DISPLAY_GETBLOCK - printf("FAT (next_cl12)\n"); -#endif + bp = getFATblock(ClusterNum , dpbp); + if (bp == NULL) return LONG_BAD; - bp->b_flag &= ~(BFR_DATA | BFR_DIR); - bp->b_flag |= BFR_FAT; - bp->b_copies = dpbp->dpb_fats; - bp->b_offset_lo = dpbp->dpb_fatsize; - bp->b_offset_hi = dpbp->dpb_fatsize >> 8; /* form an index so that we can read the block as a */ /* byte array */ @@ -368,20 +354,11 @@ UWORD next_cl12(struct dpb FAR *dpbp, REG UCOUNT ClusterNum) /* block. */ if (idx >= dpbp->dpb_secsize - 1) { - bp1 = getblock((ULONG) (dpbp->dpb_fatstrt + - ((((ClusterNum << 1) + ClusterNum) >> 1) / dpbp->dpb_secsize)) - + 1, - dpbp->dpb_unit); -#ifdef DISPLAY_GETBLOCK - printf("FAT (next_cl12)\n"); -#endif - if (bp1 == (struct buffer *)0) + bp1 = getFATblock(ClusterNum +1, dpbp); + + if (bp1 == 0) return LONG_BAD; - bp1->b_flag &= ~(BFR_DATA | BFR_DIR); - bp1->b_flag |= BFR_FAT; - bp1->b_copies = dpbp->dpb_fats; - bp1->b_offset_lo = dpbp->dpb_fatsize; - bp1->b_offset_hi = dpbp->dpb_fatsize >> 8; + fbp1 = (UBYTE FAR *) & (bp1->b_buffer[0]); } else diff --git a/kernel/fcbfns.c b/kernel/fcbfns.c index be583e30..6cd08c3c 100644 --- a/kernel/fcbfns.c +++ b/kernel/fcbfns.c @@ -35,6 +35,9 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.11 2001/06/03 14:16:17 bartoldeman + * BUFFERS tuning and misc bug fixes/cleanups (2024c). + * * Revision 1.10 2001/04/21 22:32:53 bartoldeman * Init DS=Init CS, fixed stack overflow problems and misc bugs. * @@ -157,32 +160,42 @@ VOID MoveDirInfo(); static dmatch Dmatch; -VOID FatGetDrvData(COUNT drive, COUNT FAR * spc, COUNT FAR * bps, +VOID FatGetDrvData(UCOUNT drive, COUNT FAR * spc, COUNT FAR * bps, COUNT FAR * nc, BYTE FAR ** mdp) { struct dpb FAR *dpbp; + struct cds FAR *cdsp; - printf("FGDD\n"); + /* first check for valid drive */ + *spc = -1; + + drive = (drive == 0 ? default_drive : drive - 1); - /* first check for valid drive */ - if ((UCOUNT)drive >= lastdrive) - { - *spc = -1; - return; - } + if (drive >= lastdrive) + return; + + cdsp = &CDSp->cds_table[drive]; + + if (!(cdsp->cdsFlags & CDSVALID)) + return; /* next - "log" in the drive */ - drive = (drive == 0 ? default_drive : drive - 1); - if (CDSp->cds_table[drive].cdsFlags & CDSNETWDRV) { - printf("FatGetDrvData not yet supported over network drives\n"); - *spc = -1; + if (cdsp->cdsFlags & CDSNETWDRV) { + /* Undoc DOS says, its not supported for + network drives. so it's probably OK */ + /*printf("FatGetDrvData not yet supported over network drives\n");*/ return; } dpbp = CDSp->cds_table[drive].cdsDpb; + + if (dpbp == NULL) + { + return; + } + dpbp->dpb_flags = -1; if ((media_check(dpbp) < 0)) { - *spc = -1; return; } diff --git a/kernel/globals.h b/kernel/globals.h index 15d900bf..856dc115 100644 --- a/kernel/globals.h +++ b/kernel/globals.h @@ -36,6 +36,9 @@ static BYTE *Globals_hRcsId = "$Id$"; /* * $Log$ + * Revision 1.13 2001/06/03 14:16:17 bartoldeman + * BUFFERS tuning and misc bug fixes/cleanups (2024c). + * * Revision 1.12 2001/04/21 22:32:53 bartoldeman * Init DS=Init CS, fixed stack overflow problems and misc bugs. * @@ -557,16 +560,20 @@ extern struct cds GLOBAL seg RootPsp; /* Root process -- do not abort */ +/* don't know what it should do, but its no longer in use TE GLOBAL struct f_node *pDirFileNode; +*/ +#ifdef DEBUG GLOBAL iregs error_regs; /* registers for dump */ GLOBAL WORD dump_regs; /* dump registers of bad call */ -GLOBAL struct f_node FAR -* f_nodes; /* pointer to the array */ +#endif + +GLOBAL f_node_ptr f_nodes; /* pointer to the array */ GLOBAL UWORD f_nodes_cnt; /* number of allocated f_nodes */ @@ -574,8 +581,8 @@ GLOBAL struct buffer FAR *lastbuf; /* tail of ditto */ /* FAR * buffers; /* pointer to array of track buffers */ -GLOBAL BYTE /* scratchpad used for working around */ - FAR * dma_scratch; /* DMA transfers during disk I/O */ +/*GLOBAL BYTE FAR * dma_scratch;*/ /* scratchpad used for working around */ + /* DMA transfers during disk I/O */ GLOBAL iregs FAR * ustackp, /* user stack */ diff --git a/kernel/init-mod.h b/kernel/init-mod.h index 2fcbc7fe..67a48e39 100644 --- a/kernel/init-mod.h +++ b/kernel/init-mod.h @@ -152,6 +152,7 @@ int close(int fd); int dup2(int oldfd, int newfd); int allocmem(UWORD size, seg *segp); INIT VOID init_PSPInit(seg psp_seg); +INIT VOID init_PSPSet(seg psp_seg); INIT COUNT init_DosExec(COUNT mode, exec_blk * ep, BYTE * lp); INIT VOID keycheck(VOID); diff --git a/kernel/inthndlr.c b/kernel/inthndlr.c index 0526c940..cc74fab3 100644 --- a/kernel/inthndlr.c +++ b/kernel/inthndlr.c @@ -37,6 +37,9 @@ BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.24 2001/06/03 14:16:18 bartoldeman + * BUFFERS tuning and misc bug fixes/cleanups (2024c). + * * Revision 1.23 2001/04/29 17:34:40 bartoldeman * A new SYS.COM/config.sys single stepping/console output/misc fixes. * @@ -486,7 +489,7 @@ VOID int21_service(iregs FAR * r) case 0x0a: ((keyboard FAR *) FP_DS_DX)->kb_count = 0; sti((keyboard FAR *) FP_DS_DX); - ((keyboard FAR *) FP_DS_DX)->kb_count -= 2; + ((keyboard FAR *) FP_DS_DX)->kb_count--; break; /* Check Stdin Status */ diff --git a/kernel/intr.asm b/kernel/intr.asm index 6783b90a..eebbfb04 100644 --- a/kernel/intr.asm +++ b/kernel/intr.asm @@ -90,12 +90,6 @@ intr?1: ret - global _int3 -_int3: - int 3 - retf - - segment INIT_TEXT ; ; void init_call_intr(nr, rp) @@ -266,6 +260,15 @@ _init_PSPInit: pop si ret +;; VOID init_PSPSet(seg psp_seg) + global _init_PSPSet +_init_PSPSet: + mov ah, 50h + mov bx, sp + mov bx, [bx+2] + int 21h + ret + ;; COUNT init_DosExec(COUNT mode, exec_blk * ep, BYTE * lp) global _init_DosExec _init_DosExec: diff --git a/kernel/intr.h b/kernel/intr.h index 3983ef9d..be03c575 100644 --- a/kernel/intr.h +++ b/kernel/intr.h @@ -7,4 +7,3 @@ struct REGPACK { }; extern void intr(int intrnr, struct REGPACK *rp); -extern void FAR int3(); diff --git a/kernel/ioctl.c b/kernel/ioctl.c index 867bf951..bb10cb1c 100644 --- a/kernel/ioctl.c +++ b/kernel/ioctl.c @@ -35,6 +35,9 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.9 2001/06/03 14:16:18 bartoldeman + * BUFFERS tuning and misc bug fixes/cleanups (2024c). + * * Revision 1.8 2001/04/15 03:21:50 bartoldeman * See history.txt for the list of fixes. * @@ -110,11 +113,6 @@ static BYTE *RcsId = "$Id$"; * Initial revision. */ -#ifdef PROTO -sft FAR *get_sft(COUNT); -#else -sft FAR *get_sft(); -#endif /* * WARNING: this code is non-portable (8086 specific). @@ -243,12 +241,12 @@ COUNT DosDevIOctl(iregs FAR * r) r->AL = CharReqHdr.r_status & S_BUSY ? 00 : 0xff; } - if (r->AL == 0x02 || r->AL == 0x03) + else if (r->AL == 0x02 || r->AL == 0x03) { r->AX = CharReqHdr.r_count; } - if (r->AL == 0x0c || r->AL == 0x10) + else if (r->AL == 0x0c || r->AL == 0x10) { r->AX = CharReqHdr.r_status; } @@ -300,12 +298,12 @@ COUNT DosDevIOctl(iregs FAR * r) } - if (r->AL == 0x04 || r->AL == 0x05) + else if (r->AL == 0x04 || r->AL == 0x05) { r->AX = CharReqHdr.r_count; } - if (r->AL == 0x0d || r->AL == 0x11) + else if (r->AL == 0x0d || r->AL == 0x11) { r->AX = CharReqHdr.r_status; } diff --git a/kernel/kernel.asm b/kernel/kernel.asm index e280b545..24bfb71f 100644 --- a/kernel/kernel.asm +++ b/kernel/kernel.asm @@ -28,6 +28,9 @@ ; $Id$ ; ; $Log$ +; Revision 1.13 2001/06/03 14:16:18 bartoldeman +; BUFFERS tuning and misc bug fixes/cleanups (2024c). +; ; Revision 1.12 2001/04/29 17:34:40 bartoldeman ; A new SYS.COM/config.sys single stepping/console output/misc fixes. ; @@ -625,7 +628,7 @@ __ib_end: ; kernel startup stack global init_tos - resw 256 + resw 384 init_tos: ; the last paragraph of conventional memory might become an MCB resb 16 @@ -915,8 +918,10 @@ __EnableA20: enableUsingXMSdriver: mov ah,3 -UsingXMSdriver: +UsingXMSdriver: + push bx call far [cs:_XMSDriverAddress] + pop bx retf global __DisableA20 diff --git a/kernel/main.c b/kernel/main.c index 2963bcca..44bafe2b 100644 --- a/kernel/main.c +++ b/kernel/main.c @@ -71,6 +71,9 @@ static BYTE *mainRcsId = "$Id$"; /* * $Log$ + * Revision 1.17 2001/06/03 14:16:18 bartoldeman + * BUFFERS tuning and misc bug fixes/cleanups (2024c). + * * Revision 1.16 2001/04/29 17:34:40 bartoldeman * A new SYS.COM/config.sys single stepping/console output/misc fixes. * @@ -300,6 +303,7 @@ INIT void init_kernel(void) setvec(0x2f, int2f_handler); #endif + init_PSPSet(DOS_PSP); init_PSPInit(DOS_PSP); /* Do first initialization of system variable buffers so that */ diff --git a/kernel/nls.c b/kernel/nls.c index 31a31775..df08f3ec 100644 --- a/kernel/nls.c +++ b/kernel/nls.c @@ -44,6 +44,9 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.7 2001/06/03 14:16:18 bartoldeman + * BUFFERS tuning and misc bug fixes/cleanups (2024c). + * * Revision 1.6 2001/04/15 03:21:50 bartoldeman * See history.txt for the list of fixes. * @@ -337,7 +340,9 @@ log( ("NLS: nlsGetData(): subfunction found\n") ); case NLS_DOS_38: /* Normal Country Information */ return cpyBuf(buf, bufsize , &(((struct nlsExtCntryInfo FAR*)poi)->dateFmt) - , 34); /* standard cinfo has no more 34 _used_ bytes */ + , 24); /* standard cinfo has no more 34 _used_ bytes */ + /* don't copy 34, copy only 0x18 instead, + see comment at DosGetCountryInformation TE */ default: /* All other subfunctions just return the found nlsPoinerInf structure */ @@ -356,8 +361,7 @@ log( ("NLS: nlsGetData(): Subfunction not found\n") ); VOID nlsCPchange(UWORD cp) { UNREFERENCED_PARAMETER(cp); - printf("\7\nSorry, to change the codepage is not implemented, yet.\n\ -Hope it's OK to proceed ignoring this call.\n-- 2000/02/26 ska\n"); + printf("\7\nchange codepage not yet done ska\n"); } /* @@ -564,9 +568,17 @@ log( ("NLS: GetData(): subfct=%x, cp=%u, cntry=%u, bufsize=%u\n", * it is assumed the buffer is large enough as described in RBIL, * which is 34 bytes _hardcoded_. */ +/* TE 05/04/01 + * NETX calls Int 21 AX=3800 + * and gives a buffer of (at most) 0x20 bytes + * MSDOS 6.2 copies only 0x18 bytes + * RBIL documents 0x18 bytes and calls 10 bytes 'reserved' + * so we change the amount of copied bytes to 0x18 + */ + #ifndef DosGetCountryInformation COUNT DosGetCountryInformation(UWORD cntry, VOID FAR *buf) -{ return DosGetData(NLS_DOS_38, NLS_DEFAULT, cntry, 34, buf); +{ return DosGetData(NLS_DOS_38, NLS_DEFAULT, cntry, 0x18, buf); } #endif diff --git a/kernel/proto.h b/kernel/proto.h index b9471b10..e9b7f087 100644 --- a/kernel/proto.h +++ b/kernel/proto.h @@ -34,6 +34,9 @@ static BYTE *Proto_hRcsId = "$Id$"; /* * $Log$ + * Revision 1.17 2001/06/03 14:16:18 bartoldeman + * BUFFERS tuning and misc bug fixes/cleanups (2024c). + * * Revision 1.16 2001/04/29 17:34:40 bartoldeman * A new SYS.COM/config.sys single stepping/console output/misc fixes. * @@ -175,8 +178,8 @@ static BYTE *Proto_hRcsId = "$Id$"; /* blockio.c */ ULONG getblkno(struct buffer FAR *); VOID setblkno(struct buffer FAR *, ULONG); -struct buffer FAR *getblock(ULONG blkno, COUNT dsk); -BOOL getbuf(struct buffer FAR ** pbp, ULONG blkno, COUNT dsk); +struct buffer FAR *getblock (ULONG blkno, COUNT dsk); +struct buffer FAR *getblockOver(ULONG blkno, COUNT dsk); VOID setinvld(REG COUNT dsk); BOOL flush_buffers(REG COUNT dsk); BOOL flush1(struct buffer FAR * bp); @@ -199,7 +202,7 @@ VOID KbdFlush(void); VOID Do_DosIdle_loop(void); UCOUNT sti(keyboard FAR * kp); -sft FAR *get_sft(COUNT); +sft FAR *get_sft(UCOUNT); /* dosfns.c */ BYTE FAR *get_root(BYTE FAR *); @@ -256,13 +259,14 @@ COUNT char_error(request * rq, struct dhdr FAR * lpDevice); COUNT block_error(request * rq, COUNT nDrive, struct dhdr FAR * lpDevice); /* fatdir.c */ -struct f_node FAR *dir_open(BYTE FAR * dirname); -COUNT dir_read(REG struct f_node FAR * fnp); -COUNT dir_write(REG struct f_node FAR * fnp); -VOID dir_close(REG struct f_node FAR * fnp); +f_node_ptr dir_open(BYTE FAR * dirname); +COUNT dir_read(REG f_node_ptr fnp); +COUNT dir_write(REG f_node_ptr fnp); +VOID dir_close(REG f_node_ptr fnp); COUNT dos_findfirst(UCOUNT attr, BYTE FAR * name); COUNT dos_findnext(void); void ConvertName83ToNameSZ(BYTE FAR *destSZ, BYTE FAR *srcFCBName); +int FileName83Length(BYTE *filename83); /* fatfs.c */ COUNT dos_open(BYTE FAR * path, COUNT flag); @@ -282,8 +286,8 @@ LONG dos_getcufsize(COUNT fd); LONG dos_getfsize(COUNT fd); BOOL dos_setfsize(COUNT fd, LONG size); COUNT dos_mkdir(BYTE FAR * dir); -BOOL last_link(struct f_node FAR * fnp); -COUNT map_cluster(REG struct f_node FAR * fnp, COUNT mode); +BOOL last_link(f_node_ptr fnp); +COUNT map_cluster(REG f_node_ptr fnp, COUNT mode); UCOUNT readblock(COUNT fd, VOID FAR * buffer, UCOUNT count, COUNT * err); UCOUNT writeblock(COUNT fd, VOID FAR * buffer, UCOUNT count, COUNT * err); COUNT dos_read(COUNT fd, VOID FAR * buffer, UCOUNT count); @@ -295,14 +299,14 @@ VOID trim_path(BYTE FAR * s); COUNT dos_cd(struct cds FAR * cdsp, BYTE FAR * PathName); -struct f_node FAR *get_f_node(void); -VOID release_f_node(struct f_node FAR * fnp); +f_node_ptr get_f_node(void); +VOID release_f_node(f_node_ptr fnp); VOID dos_setdta(BYTE FAR * newdta); COUNT dos_getfattr(BYTE FAR * name, UWORD FAR * attrp); COUNT dos_setfattr(BYTE FAR * name, UWORD FAR * attrp); COUNT media_check(REG struct dpb FAR *dpbp); -struct f_node FAR *xlt_fd(COUNT fd); -COUNT xlt_fnp(struct f_node FAR * fnp); +f_node_ptr xlt_fd(COUNT fd); +COUNT xlt_fnp(f_node_ptr fnp); struct dhdr FAR *select_unit(COUNT drive); VOID bpb_to_dpb(bpb FAR *bpbp, REG struct dpb FAR * dpbp); @@ -321,7 +325,7 @@ int DosCharInput(VOID); VOID DosDirectConsoleIO(iregs FAR * r); VOID DosCharOutput(COUNT c); VOID DosDisplayOutput(COUNT c); -VOID FatGetDrvData(COUNT drive, COUNT FAR * spc, COUNT FAR * bps, COUNT FAR * nc, BYTE FAR ** mdp); +VOID FatGetDrvData(UCOUNT drive, COUNT FAR * spc, COUNT FAR * bps, COUNT FAR * nc, BYTE FAR ** mdp); WORD FcbParseFname(int wTestMode, BYTE FAR ** lpFileName, fcb FAR * lpFcb); BYTE FAR *ParseSkipWh(BYTE FAR * lpFileName); BOOL TestCmnSeps(BYTE FAR * lpFileName); @@ -385,7 +389,7 @@ VOID fstrcpy(REG BYTE FAR * d, REG BYTE FAR * s); VOID fstrcpy(REG BYTE FAR * d, REG BYTE FAR * s); /*VOID bcopy(REG BYTE * s, REG BYTE * d, REG COUNT n);*/ -void memcpy(REG BYTE * d, REG BYTE * s, REG COUNT n); +void memcpy(REG void * d, REG VOID * s, REG COUNT n); #define bcopy(s,d,n) memcpy(d,s,n) void fmemset(REG VOID FAR * s, REG int ch, REG COUNT n); diff --git a/kernel/task.c b/kernel/task.c index ee87722f..e3aaa131 100644 --- a/kernel/task.c +++ b/kernel/task.c @@ -35,6 +35,9 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.14 2001/06/03 14:16:18 bartoldeman + * BUFFERS tuning and misc bug fixes/cleanups (2024c). + * * Revision 1.13 2001/04/21 22:32:53 bartoldeman * Init DS=Init CS, fixed stack overflow problems and misc bugs. * @@ -234,7 +237,7 @@ COUNT ChildEnv(exec_blk FAR * exp, UWORD * pChildEnvSeg, char far * pathname) /* create a new environment for the process */ /* copy parent's environment if exec.env_seg == 0 */ - pDest = pSrc = exp->exec.env_seg ? + pSrc = exp->exec.env_seg ? MK_FP(exp->exec.env_seg, 0) : MK_FP(ppsp->ps_environ, 0); @@ -254,24 +257,19 @@ COUNT ChildEnv(exec_blk FAR * exp, UWORD * pChildEnvSeg, char far * pathname) -- 1999/04/21 ska */ if (pSrc) { /* if no environment is available, one byte is required */ - while (*pSrc != '\0') + + for (nEnvSize = 0; ; nEnvSize++) { - while (*pSrc != '\0' && pSrc < pDest + MAXENV - ENV_KEEPFREE) - { - ++pSrc; - ++nEnvSize; - } - /* account for terminating null */ - ++nEnvSize; - ++pSrc; + /* Test env size and abort if greater than max */ + if (nEnvSize >= MAXENV - ENV_KEEPFREE) + return DE_INVLDENV; + + if (*(UWORD FAR *)(pSrc+nEnvSize) == 0) + break; } - pSrc = pDest; + nEnvSize += 2; /* account for trailing \0\0 */ } - /* Test env size and abort if greater than max */ - if (nEnvSize >= MAXENV) - return DE_INVLDENV; - /* allocate enough space for env + path */ if ((RetCode = DosMemAlloc(long2para(nEnvSize + ENV_KEEPFREE), mem_access_mode, (seg FAR *) pChildEnvSeg, @@ -291,21 +289,7 @@ COUNT ChildEnv(exec_blk FAR * exp, UWORD * pChildEnvSeg, char far * pathname) else *pDest++ = '\0'; /* create an empty environment */ -#if 0 - /* The size is already known, use a quicker copy function - -- 1999/04/21 ska */ - for (; *pSrc != '\0';) - { - while (*pSrc) - { - *pDest++ = *pSrc++; - } - pSrc++; - *pDest++ = 0; - } - *pDest++ = 0; -#endif - /* initialize 'extra strings' count */ + /* initialize 'extra strings' count */ *((UWORD FAR *) pDest)++ = 1; /* copy complete pathname */ diff --git a/lib/libm.mak b/lib/libm.mak index d97d8d63..ed6565f5 100644 --- a/lib/libm.mak +++ b/lib/libm.mak @@ -5,6 +5,9 @@ # # $Log$ +# Revision 1.5 2001/06/03 14:16:18 bartoldeman +# BUFFERS tuning and misc bug fixes/cleanups (2024c). +# # Revision 1.4 2001/03/19 04:50:56 bartoldeman # See history.txt for overview: put kernel 2022beo1 into CVS # @@ -37,7 +40,7 @@ !include "..\config.mak" -libm.lib: $(CLIB) +libm.lib: $(CLIB) ..\config.mak $(LIBUTIL) $(CLIB) $(MATH_EXTRACT) $(LIBUTIL) libm $(MATH_INSERT) $(RM) *.OBJ From c1b189648047e7e6910f9f1a0b24ed217e83eeb0 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Mon, 9 Jul 2001 22:19:33 +0000 Subject: [PATCH 082/671] LBA/FCB/FAT/SYS/Ctrl-C/ioctl fixes + memory savings git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@260 6ac86273-5f31-0410-b378-82cca8765d1b --- build.bat | 13 + docs/build.txt | 8 + docs/history.txt | 74 ++- docs/relnotes.txt | 177 +++++++ drivers/floppy.asm | 142 +++++- hdr/dirmatch.h | 4 + hdr/fat.h | 7 +- hdr/fcb.h | 5 +- hdr/fnode.h | 5 +- hdr/sft.h | 4 + hdr/version.h | 2 +- kernel/blockio.c | 52 +- kernel/config.c | 158 +++--- kernel/console.asm | 9 +- kernel/disk.h | 68 +++ kernel/dosfns.c | 7 +- kernel/dsk.c | 1174 +++++++++++++++++--------------------------- kernel/dyndata.c | 11 + kernel/dyndata.h | 25 + kernel/dyninit.c | 109 ++++ kernel/fatdir.c | 89 +++- kernel/fatfs.c | 206 ++++++-- kernel/fattab.c | 136 +++-- kernel/fcbfns.c | 60 ++- kernel/globals.h | 7 + kernel/init-mod.h | 8 + kernel/initdisk.c | 985 +++++++++++++++++++++++++++++++++++++ kernel/inithma.c | 303 +++++++----- kernel/int2f.asm | 7 +- kernel/inthndlr.c | 58 ++- kernel/ioctl.c | 9 +- kernel/kernel.asm | 42 +- kernel/kernel.cfg | 1 + kernel/kernel.mak | 71 ++- kernel/main.c | 11 +- kernel/nls.c | 31 +- kernel/segs.inc | 6 +- sys/sys.c | 166 +++++-- 38 files changed, 3081 insertions(+), 1169 deletions(-) create mode 100644 docs/relnotes.txt create mode 100644 kernel/disk.h create mode 100644 kernel/dyndata.c create mode 100644 kernel/dyndata.h create mode 100644 kernel/dyninit.c create mode 100644 kernel/initdisk.c diff --git a/build.bat b/build.bat index b249898a..8a58445a 100644 --- a/build.bat +++ b/build.bat @@ -5,6 +5,9 @@ rem batch file to build everything rem $Id$ rem $Log$ +rem Revision 1.5 2001/07/09 22:19:30 bartoldeman +rem LBA/FCB/FAT/SYS/Ctrl-C/ioctl fixes + memory savings +rem rem Revision 1.4 2001/03/22 04:13:30 bartoldeman rem Change LF to CR/LF in batch files. rem @@ -78,6 +81,16 @@ if errorlevel 1 goto abort cd ..\kernel %MAKE% -fkernel.mak production +if errorlevel 1 goto abort + +cd.. + +:- if you like, put some finalizing commands (like copy to floppy) +:- into build2.bat + +if exist build2.bat call build2 + +goto end :abort cd .. diff --git a/docs/build.txt b/docs/build.txt index f5af0494..4421bc5b 100644 --- a/docs/build.txt +++ b/docs/build.txt @@ -20,6 +20,11 @@ You will also need to download the latest version of NASM and Turbo C where) and then be sure to edit the CONFIG.MAK file to reflect where you put the tools. +*TE******* Make sure to use the NASMR version, as the DosExtender version + _seems_ to produce wrong code. the tested version is + NASM98R, 06/04/99, 202.606 bytes. + + This program will now compile with Turbo C 2.01 (now freely available!), Turbo C 3.0, Borland C 4.51 & 5.01. It should work with other Borland compilers as well. @@ -65,6 +70,9 @@ component. Study the makefile to better understand this. $Id$ $Log$ +Revision 1.4 2001/07/09 22:19:33 bartoldeman +LBA/FCB/FAT/SYS/Ctrl-C/ioctl fixes + memory savings + Revision 1.3 2000/08/15 03:42:17 jhall1 update to the bugs.txt file to point the user to the bug database at the FreeDOS web site (http://www.freedos.org/bugs) diff --git a/docs/history.txt b/docs/history.txt index 220bedd1..4e95694a 100644 --- a/docs/history.txt +++ b/docs/history.txt @@ -1,3 +1,51 @@ +2001 Jul 9 - Build 2024/d +-------- Bart Oldeman (bart.oldeman@bristol.ac.uk) ++ fixes Bart: + * fixed Ctrl-C (Ctrl-S and Ctrl-Q still missing). + * ioctl EOF fix (DJGPP less&gdb problem reported by Martin Stromberg) + * INT21/AH=29 (Parse Filename into FCB) fix (NC problem reported + by Ken Martwick) with clean up from Tom. + * ioctl should do a media_check before calling the block driver: + this fixes bug #726 (first dir gave serial no. 1234-5678). + * initdisk.c now uses the init data segment. ++ fixes Tom: + * fixes for INT21/AH=32; this should cure the problems with + Brian's new format. + * more SYS fixes. ++ added Tom: + * some more diagnostics (123) to aid finding bugs when booting from + a hard disk. + +from 2001 jun 23 : KE2024BP + ++ fixes Tom: + * FAT FS: would not expand files correctly, if lseek() + beyond EOF (see also relnotes.txt) + * FcbFindFirst/Next made compatible with MSDOS CHKDSK + * saved even more bytes (now 24 buffers in HMA :-) + +from KE2024BM ++ added Tom: + * a mechanism, to regain near data (like miarray, bpbarray,...) + this is somewhat braindamaging, moving the kernel up and down, + working with different CS/DS combinations, but somehow working, :-) + miarray allocated, using this mechanism. + * made f_nodes near (2 K saving in HMA_TEXT) + this technic might as well applied to CDs, DPB, sft's, ... + this even saves a few bytes on stack :-) + +from 2001 May 21: Build2024L ++ Fixes Tom: + * Clustersize 64K made working (one small ULONG was missing) + * check for drive existence for INT25/26 + * NDEV = max number of possible harddisk partitions bumped + from 8 to 20 (my testconfiguration has 13) + ++ Added tom: + * LBA support for disks > 8GB (with the help from Brian + Reifsnyder, see also relnotes.txt) + * moved initialization for DISK (partition scanning) to INIT_CODE + 2001 Jun 2 - Build 2024 -------- Bart Oldeman (bart.oldeman@bristol.ac.uk) + Fixes Tom: @@ -11,10 +59,12 @@ while config.sys parsing. + Fixes Bart: * INT 21 0A - Dos Buffered Input reworked + * init_PSPSet() fix for setting the PSP + Added tom: * slighly better buffer handling (search BFR_UNCACHE) now go more FAT+DIR sectors, less DATA sectors into cache * dos_mkdir tuned (was ~0.5 sec on 64K cluster partitions) + 2001 Apr 29 - Build 2024 -------- Bart Oldeman (bart.oldeman@bristol.ac.uk) + Fixes Bart: @@ -37,30 +87,6 @@ * Default lastdrive should be 5 (E) not 6 (F). * fixed not ignoring whitespace after '=' in config.sys * noted INT21/AX=3800 bug for getting the country. Put in a workaround for now. -2001 Apr 29 - Build 2024 --------- Bart Oldeman (bart.oldeman@bristol.ac.uk) -+ Fixes Bart: - * fixed the "TYPE > FOO.TXT" poor man's editor. - * use "fast console output" (int 29) when applicable. - * moved 5 FILES to DOS DS:00CC and fixed the SFT linked list. - * cleaned up findfirst/findnext for redirected drives. - * moved IO segments to 0x70 as this matches other DOS'es. - Tom: - * more VDISK changes (changed slightly by Bart) - * check for presence of A:/B: (changed by Bart to use the BIOS equipment flag - from INT11 instead of INT13). - * added F5/F8 stepping through config.sys; default SHELL=COMMAND.COM /P/E:256 - Use ESC to stop single stepping, F5 to skip remaining config.sys/autoexec.bat. - * new sys: uses INT25/26 instead of the low level INT13 related kernel code from - floppy.asm (see also comments in sys.c) + a few fixes (also boot.asm related) - from Bart. - * Hopefully fixed DateTime Changed + ATTRIB |= ARCHIVE bug. - * Combined clk and blk driver entries as much as possible. - * cleaned up dsk.c and saved more bytes. - Przemyslaw Czerpak: - * Default lastdrive should be 5 (E) not 6 (F). - * fixed not ignoring whitespace after '=' in config.sys - * noted INT21/AX=3800 bug for getting the country. Put in a workaround for now. 2001 Apr 21 - Build 2024 -------- Bart Oldeman (bart.oldeman@bristol.ac.uk) + Fixes Tom: diff --git a/docs/relnotes.txt b/docs/relnotes.txt new file mode 100644 index 00000000..787c31bf --- /dev/null +++ b/docs/relnotes.txt @@ -0,0 +1,177 @@ +Release notes for kernel 2024d and its development predecessors +2024BL,M,N: we think that by now we have ironed out most of these +bugs, but be careful nonetheless. + +About KE2024BL: + + ********************************************************* + * * + * THIS IS A BETA RELEASE * + * * + * BE CAREFUL * + * * + * SAVE YOUR DATA. SAVE OFTEN. * + * * + * THIS RELEASE MAY DESTROY YOUR DISK COMPLETELY * + * * + ********************************************************* + + +KE2024BL introduced full LBA support; i.e. disk may be up to +2^32 * 512 bytes = 2000 GB large. + +also new is the working of 64K FAT clustersize for a max +logical disksize of 2^16 * 64K = ~4 GB. + +KE2024BM is its follower, with some more bugfixes. + + +How dangerous is it? + +The KE2024BL kernel has been send by private mail to some of us, +has been tested on 7 maschines with and without LBA support. + +No errors (other then the known bugs) were reported. +And KE2024BM is pretty conservativ, before it accepts and uses +a disk. + +the main problem may be, that a disk recognized by an older +kernel, will no longer work with the new one, because strange +partitioning scemes, although nothing like that has been reported. + +So, if after booting you see all your drives, containing resonable +data, it should be pretty save to use. + +Be a bit careful, nevertheless. + + + + + + +full LBA support and 64K FAT clustersize for a max +logical disksize of 2^16 * 64K = ~4 GB + + +were have been tested in the following way: + +on my 30GB disk, a partition with 1.7 GB for 32K clusters and +3.5 GB for 64K clusters created. the 3.5 GB partition was created, +using Win2K. + +my WINNT directory (~350MB) was copied there - (using VC) +once for 32K, +for 64K, + xcopy c:\WINNT j:\WINNT /s + xcopy j:\WINNT j:\WINN1 /s + xcopy j:\WINN1 j:\WINN2 /s + xcopy j:\WINN2 j:\WINN3 /s + xcopy j:\WINN3 j:\WINN4 /s +to fill the disk. + + +the 350 MB files (WINNT for 32K, WINN4 for 64K) were then +compared to the original file. they were identical. + +no, not all files were copied due to restrictions in MAX_PATH_SIZE, +but the files, that were copied, compared ok. + +the files were also readable with WinNT, and they were identical, too. +WinNT chkdsk was content with the disk. + + +next, the kernel source was copied to this drive, compiled, +and verified. + +so, it _seems_ to work for me. + +known issues: + * VC will say, that the disk has size of 0 byte, with 0 byte free. + this is not a kernel bug. + VC simply multiplies BytesPerSec*SecPerCluster, gets + 128*512 = 0x10000, and saves the low part, which is 0. + + * the behaviour for filesize at or above 2GB (where the sign + gets negative) is completely untested. test it, if you like + + * there are some bugs, when the pathlength is around 64. + this may lead to incontinent (sorry, inconsistent) behaviour, + like + you can MKDIR a directory, but not CHDIR to it + and similiar things. + some of them found and removed, but there are probably more + to be found yet. fortunately, none lead to data loss :-) + + + ********************************************************* + * * + * BE CAREFUL * + * AND SAVE YOUR DATA. SAVE OFTEN. * + * * + ********************************************************* + + +Bugs and fixes in the FAT filesystem (tested on KE2024BN) + +--------------------------------------------------------- +KE2024BM: +Disk Full not detected in a compatible way. +it was possible to create a directory(pointing to nowhere), +even if disk was full. + +--------------------------------------------------------- +DosGetFreeSpace is wrong (verified on KE2022, too): + +when creating files, the 2nd and following clusters are +counted twice when created. + +simply copy one file to another, delete 2nd file; +watch free space before and after. +corrected in KE2024BP + +--------------------------------------------------------- +#include +#include +main() +{ + FILE *fd = fopen("test.dat","w"); + int fdn = fileno(fd); + + lseek(fdn,10000,SEEK_CUR); + write(fdn,"hello world",10); +} + +creates file of DirSize 10010 bytes, but reserves +a single FAT entry cluster + +this is obviously nonsense. + +and there is no "hello world" in it :-( + +cured by FATFS.C, + /* Now that we've found a free FAT entry, mark it as the last */ + /* entry and save it. */ + /* BUG!! this caused wrong allocation, if file was created, + then seeked, then written */ ++ fnp->f_cluster = + fnp->f_dir.dir_start = free_fat; + + + + +-------------------------------------------------------------- +when a big file is created, and cut afterward, the filespace is NOT freed +try: + copy command.com xx + dir + echo >xx + dir +and compare disk free info. +the space is freed, however, if xx is deleted after that. +-------------------------------------------------------------- + + + + +regards +tom ehlert (tom.ehlert@ginko.de) diff --git a/drivers/floppy.asm b/drivers/floppy.asm index e5443de3..7890dc27 100644 --- a/drivers/floppy.asm +++ b/drivers/floppy.asm @@ -30,6 +30,13 @@ ; $Id$ ; ; $Log$ +; Revision 1.7 2001/07/09 22:19:33 bartoldeman +; LBA/FCB/FAT/SYS/Ctrl-C/ioctl fixes + memory savings +; +; +; Revision 1.7 2001/04/29 brianreifsnyder +; Added phase 1 support for LBA hard drives +; ; Revision 1.6 2001/04/22 01:19:33 bartoldeman ; Avoid sys warning and have a VDISK signature in the HMA ; @@ -285,7 +292,7 @@ fl_error: - +%if 0 global _fl_format _fl_format: @@ -315,3 +322,136 @@ _fl_nrdrives: fl_nrd1: pop di ret +%endif + +; --------------------------------------------------------------------------- +; LBA Specific Code +; +; +; Added by: Brian E. Reifsnyder +; --------------------------------------------------------------------------- + +; +; +; Check for Enhanced Disk Drive support (EDD). If EDD is supported then +; LBA can be utilized to access the hard disk. +; +; unsigned int lba_support(WORD hard_disk_number) +; +; returns TRUE if LBA can be utilized +; +%if 0 + global _fl_lba_support +_fl_lba_support: + push bp ; C entry + mov bp,sp + + mov dl,[bp+4] ; get the drive number + mov ah,41h ; cmd CHECK EXTENSIONS PRESENT + mov bx,55aah + int 13h ; check for int 13h extensions + + jc fl_lba_support_no_lba + ; if carry set, don't use LBA + cmp bx,0aa55h + jne fl_lba_support_no_lba + ; if bx!=0xaa55, don't use LBA + test cl,01h + jz fl_lba_support_no_lba + ; if DAP cannot be used, don't use + ; LBA + mov ax,0001h ; return TRUE (LBA supported) + + pop bp ; C exit + ret + +fl_lba_support_no_lba + xor ax,ax ; return FALSE (LBA not supported) + pop bp ; C exit + ret + +; +; Read Sectors +; +; COUNT fl_lba_read(WORD drive, WORD dap_segment, WORD dap_offset); +; +; Reads one or more sectors. +; +; Returns 0 if successful, error code otherwise. +; +; +; Write Sectors +; +; COUNT fl_lba_write(WORD drive, WORD dap_segment, WORD dap_offset); +; +; Writes one or more sectors. +; +; Returns 0 if successful, error code otherwise. +; + global _fl_lba_read +_fl_lba_read: + mov ah,42h ; cmd READ + jmp short fl_lba_common + + global _fl_lba_write +_fl_lba_write: + mov ax,4300h ; cmd WRITE without verify + jmp short fl_lba_common + + global _fl_lba_write_and_verify +_fl_lba_write_and_verify: + mov ax,4302h ; cmd WRITE with VERIFY + jmp short fl_lba_common ; This has been added for + ; possible future use + + global _fl_lba_verify +_fl_lba_verify: + mov ah,44h ; cmd VERIFY + +fl_lba_common: + push bp ; C entry + mov bp,sp + + push ds + + mov dl,[bp+4] ; get the drive (if or'ed 80h its + ; hard drive. + lds si,[bp+6] ; get far dap pointer + int 13h ; read from/write to drive + + mov al,ah ; place any error code into al + + xor ah,ah ; zero out ah + + pop ds + + pop bp + ret +%endif + +; COUNT fl_lba_ReadWrite(BYTE drive, UWORD mode, VOID FAR *dap_p) +; +; Returns 0 if successful, error code otherwise. +; + global _fl_lba_ReadWrite +_fl_lba_ReadWrite: + push bp ; C entry + mov bp,sp + + push ds + push si ; wasn't in kernel < KE2024Bo6!! + + mov dl,[bp+4] ; get the drive (if or'ed 80h its + mov ax,[bp+6] ; get the command + lds si,[bp+8] ; get far dap pointer + int 13h ; read from/write to drive + + mov al,ah ; place any error code into al + + xor ah,ah ; zero out ah + + pop si + pop ds + + pop bp + ret diff --git a/hdr/dirmatch.h b/hdr/dirmatch.h index 07679909..8d686ed0 100644 --- a/hdr/dirmatch.h +++ b/hdr/dirmatch.h @@ -36,6 +36,9 @@ static BYTE *dirmatch_hRcsId = "$Id$"; /* * $Log$ + * Revision 1.5 2001/07/09 22:19:33 bartoldeman + * LBA/FCB/FAT/SYS/Ctrl-C/ioctl fixes + memory savings + * * Revision 1.4 2001/04/16 01:45:26 bartoldeman * Fixed handles, config.sys drivers, warnings. Enabled INT21/AH=6C, printf %S/%Fs * @@ -115,6 +118,7 @@ typedef struct f_filler:11; /* TC 2.01 */ } dm_flags; /* file flags */ + UWORD dm_dirstart; BYTE dm_attr_fnd; /* found file attribute */ diff --git a/hdr/fat.h b/hdr/fat.h index 6a287a01..b316ad7e 100644 --- a/hdr/fat.h +++ b/hdr/fat.h @@ -36,6 +36,9 @@ static BYTE *fat_hRcsId = "$Id$"; /* * $Log$ + * Revision 1.7 2001/07/09 22:19:33 bartoldeman + * LBA/FCB/FAT/SYS/Ctrl-C/ioctl fixes + memory savings + * * Revision 1.6 2001/04/15 03:21:50 bartoldeman * See history.txt for the list of fixes. * @@ -123,8 +126,8 @@ static BYTE *fat_hRcsId = "$Id$"; #define FAT_MAGIC16 ((unsigned)65526l) #define FAT_MAGIC32 268435456l -#define ISFAT32(dpbp) (((dpbp)->dpb_size)>FAT_MAGIC16 || ((dpbp)->dpb_size)<=FAT_MAGIC32 ) -#define ISFAT16(dpbp) (((dpbp)->dpb_size)>FAT_MAGIC || ((dpbp)->dpb_size)<=FAT_MAGIC16 ) +#define ISFAT32(dpbp) (((dpbp)->dpb_size)>FAT_MAGIC16 && ((dpbp)->dpb_size)<=FAT_MAGIC32 ) +#define ISFAT16(dpbp) (((dpbp)->dpb_size)>FAT_MAGIC && ((dpbp)->dpb_size)<=FAT_MAGIC16 ) #define ISFAT12(dpbp) (((dpbp)->dpb_size)<=FAT_MAGIC) /* FAT file system directory entry */ diff --git a/hdr/fcb.h b/hdr/fcb.h index ac63ca9d..1b97f58c 100644 --- a/hdr/fcb.h +++ b/hdr/fcb.h @@ -36,6 +36,9 @@ static BYTE *fcb_hRcsId = "$Id$"; /* * $Log$ + * Revision 1.4 2001/07/09 22:19:33 bartoldeman + * LBA/FCB/FAT/SYS/Ctrl-C/ioctl fixes + memory savings + * * Revision 1.3 2000/05/25 20:56:19 jimtabor * Fixed project history * @@ -144,7 +147,7 @@ typedef struct BYTE fcb_attrib_lo; /* dev attrib word lo, open mode */ UWORD fcb_strtclst; /* file starting cluster */ UWORD fcb_dirclst; /* cluster of the dir entry */ - UBYTE fcb_diroff; /* offset of the dir entry */ + UBYTE fcb_diroff_unused; /* offset of the dir entry */ /* end reserved */ UBYTE fcb_curec; /* Current block number of */ ULONG fcb_rndm; /* Current relative record number */ diff --git a/hdr/fnode.h b/hdr/fnode.h index d7d3d878..ff56de33 100644 --- a/hdr/fnode.h +++ b/hdr/fnode.h @@ -36,6 +36,9 @@ static BYTE *fnode_hRcsId = "$Id$"; /* * $Log$ + * Revision 1.7 2001/07/09 22:19:33 bartoldeman + * LBA/FCB/FAT/SYS/Ctrl-C/ioctl fixes + memory savings + * * Revision 1.6 2001/06/03 14:16:17 bartoldeman * BUFFERS tuning and misc bug fixes/cleanups (2024c). * @@ -129,4 +132,4 @@ struct f_node UWORD f_boff; /* the byte in the cluster */ }; -typedef struct f_node FAR * f_node_ptr; +typedef struct f_node * f_node_ptr; diff --git a/hdr/sft.h b/hdr/sft.h index 7decb20f..47d5a49a 100644 --- a/hdr/sft.h +++ b/hdr/sft.h @@ -35,6 +35,9 @@ static BYTE *sft_hRcsId = "$Id$"; /* * $Log$ + * Revision 1.4 2001/07/09 22:19:33 bartoldeman + * LBA/FCB/FAT/SYS/Ctrl-C/ioctl fixes + memory savings + * * Revision 1.3 2000/05/25 20:56:19 jimtabor * Fixed project history * @@ -114,6 +117,7 @@ typedef struct struct dhdr FAR * _sft_dev; /* device driver for char dev */ } + sft_dcb_or_dev; WORD sft_stclust; /* Starting cluster */ time sft_time; /* File time */ diff --git a/hdr/version.h b/hdr/version.h index b5703403..31cfec1c 100644 --- a/hdr/version.h +++ b/hdr/version.h @@ -44,4 +44,4 @@ static BYTE *date_hRcsId = "$Id$"; #define REVISION_MINOR 1 #define REVISION_SEQ 24 #define BUILD 2024 -#define SUB_BUILD "c" +#define SUB_BUILD "d" diff --git a/kernel/blockio.c b/kernel/blockio.c index 098213a2..f7dc357c 100644 --- a/kernel/blockio.c +++ b/kernel/blockio.c @@ -34,9 +34,12 @@ #ifdef VERSION_STRINGS static BYTE *blockioRcsId = "$Id$"; #endif - + /* * $Log$ + * Revision 1.11 2001/07/09 22:19:33 bartoldeman + * LBA/FCB/FAT/SYS/Ctrl-C/ioctl fixes + memory savings + * * Revision 1.10 2001/06/03 14:16:17 bartoldeman * BUFFERS tuning and misc bug fixes/cleanups (2024c). * @@ -553,10 +556,13 @@ UWORD dskxfer(COUNT dsk, ULONG blkno, VOID FAR * buf, UWORD numblocks, COUNT mod REG struct dpb FAR *dpbp = CDSp->cds_table[dsk].cdsDpb; - if ((UCOUNT)dsk >= lastdrive || - !(CDSp->cds_table[dsk].cdsFlags & CDSPHYSDRV)) + if ((UCOUNT)dsk >= lastdrive ) { - return -1; /* illegal command */ + return 0x0201; /* illegal command */ + } + if (!(CDSp->cds_table[dsk].cdsFlags & CDSPHYSDRV)) + { + return 0x0201; /* illegal command */ } #if 1 @@ -574,10 +580,19 @@ UWORD dskxfer(COUNT dsk, ULONG blkno, VOID FAR * buf, UWORD numblocks, COUNT mod { IoReqHdr.r_length = sizeof(request); IoReqHdr.r_unit = dpbp->dpb_subunit; - IoReqHdr.r_command = - mode == DSKWRITE ? - (verify_ena ? C_OUTVFY : C_OUTPUT) - : C_INPUT; + + switch(mode) + { + case DSKWRITE : if (verify_ena) { IoReqHdr.r_command = C_OUTVFY; break; } + /* else fall through */ + case DSKWRITEINT26: IoReqHdr.r_command = C_OUTPUT; break; + + case DSKREADINT25: + case DSKREAD : IoReqHdr.r_command = C_INPUT; break; + default: + return 0x0100; /* illegal command */ + } + IoReqHdr.r_status = 0; IoReqHdr.r_meddesc = dpbp->dpb_mdb; IoReqHdr.r_trans = (BYTE FAR *) buf; @@ -592,11 +607,24 @@ UWORD dskxfer(COUNT dsk, ULONG blkno, VOID FAR * buf, UWORD numblocks, COUNT mod execrh((request FAR *) & IoReqHdr, dpbp->dpb_device); if (!(IoReqHdr.r_status & S_ERROR) && (IoReqHdr.r_status & S_DONE)) break; - else - { + + /* INT25/26 (_SEEMS_ TO) return immediately with 0x8002, + if drive is not online,... + + normal operations (DIR) wait for ABORT/RETRY + + other condition codes not tested + */ + if (mode >= DSKWRITEINT26) + return (IoReqHdr.r_status); + /* Changed 9/4/00 BER */ return (IoReqHdr.r_status); + + + + /* Skip the abort, retry, fail code...it needs fixed...BER */ /* End of change */ @@ -616,8 +644,8 @@ UWORD dskxfer(COUNT dsk, ULONG blkno, VOID FAR * buf, UWORD numblocks, COUNT mod default: goto loop; } - } - } + + } /* retry loop */ /* *** Changed 9/4/00 BER */ return 0; /* Success! Return 0 for a successful operation. */ /* End of change */ diff --git a/kernel/config.c b/kernel/config.c index d9b60d7b..3446cbfb 100644 --- a/kernel/config.c +++ b/kernel/config.c @@ -29,6 +29,9 @@ #include "portab.h" #include "init-mod.h" +#include "dyndata.h" + + /* These are the far variables from the DOS data segment that we need here. The @@ -39,7 +42,7 @@ -- Bart */ extern struct buffer FAR * FAR lastbuf;/* tail of ditto */ -extern struct f_node FAR * FAR f_nodes; /* pointer to the array */ +extern f_node_ptr FAR f_nodes; /* pointer to the array */ extern UWORD FAR f_nodes_cnt, /* number of allocated f_nodes */ FAR first_mcb; /* Start of user memory */ @@ -78,8 +81,17 @@ extern UWORD FAR ram_top, /* How much ram in Kbytes static BYTE *RcsId = "$Id$"; #endif +#ifdef DEBUG + #define DebugPrintf(x) printf x +#else + #define DebugPrintf(x) +#endif + /* * $Log$ + * Revision 1.24 2001/07/09 22:19:33 bartoldeman + * LBA/FCB/FAT/SYS/Ctrl-C/ioctl fixes + memory savings + * * Revision 1.23 2001/06/03 14:16:17 bartoldeman * BUFFERS tuning and misc bug fixes/cleanups (2024c). * @@ -374,6 +386,8 @@ INIT void PreConfig(void) UmbState = 0; /* Initialize the base memory pointers */ + + DynFree(0); if ( HMATextIsAvailable ) @@ -391,9 +405,7 @@ INIT void PreConfig(void) /* the dms_scratch buffer is statically allocated in the DSK module */ /* dma_scratch = (BYTE FAR *) KernelAllocDma(BUFFERSIZE); */ -#ifdef DEBUG - /* printf("Preliminary DMA scratchpad allocated at 0x%p\n",dma_scratch);*/ -#endif +/* DebugPrintf(("Preliminary DMA scratchpad allocated at 0x%p\n",dma_scratch));*/ @@ -405,8 +417,12 @@ INIT void PreConfig(void) #endif /* Initialize the file table */ - f_nodes = (struct f_node FAR *) - KernelAlloc(Config.cfgFiles * sizeof(struct f_node)); +/* f_nodes = (f_node_ptr) + KernelAlloc(Config.cfgFiles * sizeof(struct f_node));*/ + + + f_nodes = (f_node_ptr) + DynAlloc("f_nodes", Config.cfgFiles , sizeof(struct f_node)); f_nodes_cnt = Config.cfgFiles; /* sfthead = (sfttbl FAR *)&basesft; */ @@ -427,11 +443,11 @@ INIT void PreConfig(void) KernelAlloc(blk_dev.dh_name[0]*sizeof(struct dpb)); #ifdef DEBUG - printf("Preliminary f_node allocated at at 0x%p\n",f_nodes); - printf("Preliminary FCB table allocated at 0x%p\n",FCBp); - printf("Preliminary sft table allocated at 0x%p\n",sfthead->sftt_next); - printf("Preliminary CDS table allocated at 0x%p\n",CDSp); - printf("Preliminary DPB table allocated at 0x%p\n",DPBp); + printf("Preliminary:\n f_node 0x%p",f_nodes); +/* printf(" FCB table 0x%p\n",FCBp);*/ + printf(" sft table 0x%p\n",sfthead->sftt_next); + printf(" CDS table 0x%p\n",CDSp); + printf(" DPB table 0x%p\n",DPBp); #endif /* Done. Now initialize the MCB structure */ @@ -467,14 +483,45 @@ INIT void PostConfig(void) if (lastdrive < nblkdev ) lastdrive = nblkdev ; + /* initialize NEAR allocated things */ + + DynFree(Config.cfgFiles * sizeof(struct f_node)); + + + /* Initialize the file table */ + f_nodes = (f_node_ptr) + DynAlloc("f_nodes", Config.cfgFiles , sizeof(struct f_node)); + + f_nodes_cnt = Config.cfgFiles; /* and the number of allocated files */ /* Initialize the base memory pointers from last time. */ + /* + if the kernel could be moved to HMA, everything behind the dynamic + near data is free. + otherwise, the kernel is moved down - behind the dynamic allocated data, + and allocation starts after the kernel. + */ if ( HMATextIsAvailable ) - lpOldLast = lpBase = AlignParagraph((BYTE FAR *) & _HMATextStart); - else - lpOldLast = lpBase = AlignParagraph((BYTE FAR *) & _InitTextStart); + lpBase = AlignParagraph((BYTE FAR *)DynLast()+0x0f); + else + { + lpBase = AlignParagraph((BYTE FAR *)DynLast()+0x0f); + + DebugPrintf(("HMA not available, moving text to %x\n",FP_SEG(lpBase))); + MoveKernel(FP_SEG(lpBase)); + + lpBase = AlignParagraph((BYTE FAR *)lpBase + HMAFree + 0x0f); + + DebugPrintf(("kernel is low, start alloc at %p",lpBase)); + } + + + DebugPrintf(("starting FAR allocations at %p\n",lpBase)); + + + lpOldLast = lpBase; /* Begin by initializing our system buffers */ /* dma_scratch = (BYTE FAR *) KernelAllocDma(BUFFERSIZE); */ @@ -492,11 +539,6 @@ INIT void PostConfig(void) /* printf("%d buffers allocated at 0x%p\n", Config.cfgBuffers,buffers); */ #endif - /* Initialize the file table */ - f_nodes = (struct f_node FAR *) - KernelAlloc(Config.cfgFiles * sizeof(struct f_node)); - - f_nodes_cnt = Config.cfgFiles; /* and the number of allocated files */ /* sfthead = (sfttbl FAR *)&basesft; */ /* FCBp = (sfttbl FAR *)&FcbSft; */ /* FCBp = (sfttbl FAR *) @@ -516,25 +558,20 @@ INIT void PostConfig(void) #ifdef DEBUG - printf("f_node allocated at 0x%p\n",f_nodes); - printf("FCB table allocated at 0x%p\n",FCBp); - printf("sft table allocated at 0x%p\n",sfthead->sftt_next); - printf("CDS table allocated at 0x%p\n",CDSp); - printf("DPB table allocated at 0x%p\n",DPBp); + printf("Final: \n f_node 0x%p\n",f_nodes); +/* printf(" FCB table 0x%p\n",FCBp);*/ + printf(" sft table 0x%p\n",sfthead->sftt_next); + printf(" CDS table 0x%p\n",CDSp); + printf(" DPB table 0x%p\n",DPBp); #endif if (Config.cfgStacks) { VOID FAR *stackBase = KernelAlloc(Config.cfgStacks * Config.cfgStackSize); init_stacks(stackBase, Config.cfgStacks, Config.cfgStackSize); -#ifdef DEBUG - printf("Stacks allocated at %p\n",stackBase); -#endif + DebugPrintf(("Stacks allocated at %p\n",stackBase)); } -#ifdef DEBUG - printf("Allocation completed: top at 0x%p\n",lpBase); -#endif - + DebugPrintf(("Allocation completed: top at 0x%p\n",lpBase)); } @@ -546,9 +583,9 @@ INIT VOID configDone(VOID) if (lastdrive < nblkdev) { -#ifdef DEBUG - printf("lastdrive %c too small upping it to: %c\n", lastdrive + 'A', nblkdev + 'A' -1); -#endif /* DEBUG */ + + DebugPrintf(("lastdrive %c too small upping it to: %c\n", lastdrive + 'A', nblkdev + 'A' -1)); + lastdrive = nblkdev; CDSp = (cdstbl FAR *) KernelAlloc(0x58 * lastdrive); @@ -568,21 +605,19 @@ INIT VOID configDone(VOID) if(umb_start != FP_SEG(upBase) ){ /* make last block normal with SC for the devices */ - UCOUNT umr_new = FP_SEG(upBase) + ((FP_OFF(upBase) + 0x0f) >> 4); + UCOUNT umr_new = FP_SEG(upBase) + ((FP_OFF(upBase) + 0x0f) >> 4); - mumcb_init((mcb FAR *) (MK_FP(uppermem_root, 0)), umr_new - uppermem_root - 1); + mumcb_init((mcb FAR *) (MK_FP(uppermem_root, 0)), umr_new - uppermem_root - 1); - uppermem_root = umr_new; - zumcb_init((mcb FAR *) (MK_FP(uppermem_root, 0)), + uppermem_root = umr_new; + zumcb_init((mcb FAR *) (MK_FP(uppermem_root, 0)), (umb_start + UMB_top ) - uppermem_root - 1); - upBase += 16; + upBase += 16; - } + } } -#ifdef DEBUG - printf("UMB Allocation completed: top at 0x%p\n",upBase); -#endif + DebugPrintf(("UMB Allocation completed: top at 0x%p\n",upBase)); /* The standard handles should be reopened here, because we may have loaded new console or printer drivers in CONFIG.SYS */ @@ -598,27 +633,21 @@ INIT VOID DoConfig(VOID) /* Check to see if we have a config.sys file. If not, just */ /* exit since we don't force the user to have one. */ - if ((nFileDesc = open("fdconfig.sys", 0)) < 0) + if ((nFileDesc = open("fdconfig.sys", 0)) >= 0) { -#ifdef DEBUG - printf("FDCONFIG.SYS not found\n"); -#endif + DebugPrintf(("Reading FDCONFIG.SYS...\n")); + } + else + { + DebugPrintf(("FDCONFIG.SYS not found\n")); if ((nFileDesc = open("config.sys", 0)) < 0) { -#ifdef DEBUG - printf("CONFIG.SYS not found\n"); -#endif + DebugPrintf(("CONFIG.SYS not found\n")); return; } -#ifdef DEBUG - else - printf("Reading CONFIG.SYS...\n"); -#endif + DebugPrintf(("Reading CONFIG.SYS...\n")); } -#ifdef DEBUG - else - printf("Reading FDCONFIG.SYS...\n"); -#endif + /* Have one -- initialize. */ nCfgLine = 0; @@ -663,7 +692,7 @@ INIT VOID DoConfig(VOID) *pLine = 0; pLine = szLine; - + /* Skip leading white space and get verb. */ pLine = scan(pLine, szBuf); @@ -678,15 +707,15 @@ INIT VOID DoConfig(VOID) if (pEntry->pass >= 0 && pEntry->pass != nPass) continue; - if ( SkipLine(pLineStart)) /* F5/F8 processing */ - continue; - + if ( SkipLine(pLineStart)) /* F5/F8 processing */ + continue; + pLine = skipwh(pLine); if ('=' != *pLine) - CfgFailure(pLine); + CfgFailure(pLine); else /* YES. DO IT */ - (*(pEntry->func)) (skipwh(pLine+1)); + (*(pEntry->func)) (skipwh(pLine+1)); @@ -1555,3 +1584,4 @@ INIT VOID SetAnyDos(BYTE * pLine) UNREFERENCED_PARAMETER(pLine); ReturnAnyDosVersionExpected = TRUE; } + diff --git a/kernel/console.asm b/kernel/console.asm index 8705147c..f43661a3 100644 --- a/kernel/console.asm +++ b/kernel/console.asm @@ -28,6 +28,9 @@ ; $Header$ ; ; $Log$ +; Revision 1.7 2001/07/09 22:19:33 bartoldeman +; LBA/FCB/FAT/SYS/Ctrl-C/ioctl fixes + memory savings +; ; Revision 1.6 2001/04/15 03:21:50 bartoldeman ; See history.txt for the list of fixes. ; @@ -166,7 +169,7 @@ CommonNdRdExit: jnz ConNdRd2 ; Jump if there's a char waiting mov ah,1 int 16h ; Get status, if zf=0 al=char - jz ConNdRd4 ; Jump if chrar available + jz ConNdRd4 ; Jump if no char available or ax,ax ; Zero ? jnz ConNdRd1 ; Jump if not zero int 16h ; get status, if zf=0 al=char @@ -178,7 +181,7 @@ ConNdRd1: mov al,CTL_P ConNdRd2: - lds bx,[_ReqPktPtr] ; Set the status + lds bx,[cs:_ReqPktPtr] ; Set the status mov [bx+0Dh],al ConNdRd3: @@ -285,7 +288,7 @@ ConIS1: mov al,CTL_P ConIS2: - lds bx,[_ReqPktPtr] ; Set the status + lds bx,[cs:_ReqPktPtr] ; Set the status mov [bx+0Dh],al ConCharReady: jmp _IOExit ; key ready (busy=0) diff --git a/kernel/disk.h b/kernel/disk.h new file mode 100644 index 00000000..a50df6f3 --- /dev/null +++ b/kernel/disk.h @@ -0,0 +1,68 @@ +/* + DISK.H + + common constants + structures, shared between + + DSK.C and INITDISK.C + + note: + +*/ + + +#define MAX_HARD_DRIVE 8 +#define N_RETRY 5 /* number of retries permitted */ +#define NDEV 20 /* only one for demo */ +#define SEC_SIZE 512 /* size of sector in bytes */ + + +#define LBA_READ 0x4200 +#define LBA_WRITE 0x4300 + + +/* physical characteristics of a drive */ + +struct CHS { + ULONG Cylinder; + UWORD Head; + UWORD Sector; + }; + +struct DriveParamS +{ + UBYTE driveno; /* = 0x8x */ + unsigned LBA_supported:1; /* set, if INT13 extensions enabled */ + unsigned WriteVerifySupported:1; /* */ + ULONG total_sectors; + + struct CHS chs; /* for normal INT 13 */ +}; + +struct media_info +{ + struct DriveParamS drive; /* physical charactereistics of drive */ + ULONG mi_size; /* physical sector count */ + ULONG mi_offset; /* relative partition offset */ + ULONG mi_FileOC; /* Count of Open files on Drv */ + + + struct FS_info + { + ULONG serialno; + BYTE volume[11]; + BYTE fstype[8]; + }fs; + +}; + +struct _bios_LBA_address_packet /* Used to access a hard disk via LBA */ + /* Added by Brian E. Reifsnyder */ +{ + unsigned char packet_size; /* size of this packet...set to 16 */ + unsigned char reserved_1; /* set to 0...unused */ + unsigned char number_of_blocks; /* 0 < number_of_blocks < 128 */ + unsigned char reserved_2; /* set to 0...unused */ + UBYTE far * buffer_address; /* addr of transfer buffer */ + unsigned long block_address; /* LBA address */ + unsigned long block_address_high; /* high bytes of LBA addr...unused */ +}; diff --git a/kernel/dosfns.c b/kernel/dosfns.c index 482da59d..b77f73cc 100644 --- a/kernel/dosfns.c +++ b/kernel/dosfns.c @@ -37,6 +37,9 @@ static BYTE *dosfnsRcsId = "$Id$"; * /// Added SHARE support. 2000/09/04 Ron Cemer * * $Log$ + * Revision 1.19 2001/07/09 22:19:33 bartoldeman + * LBA/FCB/FAT/SYS/Ctrl-C/ioctl fixes + memory savings + * * Revision 1.18 2001/06/03 14:16:17 bartoldeman * BUFFERS tuning and misc bug fixes/cleanups (2024c). * @@ -591,7 +594,9 @@ UCOUNT DosWrite(COUNT hndl, UCOUNT n, BYTE FAR * bp, COUNT FAR * err) /* /// End of additions for SHARE - Ron Cemer */ WriteCount = writeblock(s->sft_status, bp, n, &rc); - if (rc < SUCCESS) +/* if (rc < SUCCESS) */ + if (rc == DE_ACCESS || /* -5 Access denied */ + rc == DE_INVLDHNDL ) /* -6 Invalid handle */ { *err = rc; return 0; diff --git a/kernel/dsk.c b/kernel/dsk.c index 59bbd6a0..c4a8a4cc 100644 --- a/kernel/dsk.c +++ b/kernel/dsk.c @@ -26,14 +26,23 @@ #include "portab.h" #include "globals.h" +#include "disk.h" #ifdef VERSION_STRINGS static BYTE *dskRcsId = "$Id$"; #endif /* * $Log$ - * Revision 1.16 2001/04/29 17:34:40 bartoldeman - * A new SYS.COM/config.sys single stepping/console output/misc fixes. + * Revision 1.17 2001/07/09 22:19:33 bartoldeman + * LBA/FCB/FAT/SYS/Ctrl-C/ioctl fixes + memory savings + * + * Revision 1.17 2001/05/13 tomehlert + * Added full support for LBA hard drives + * initcode moved (mostly) to initdisk.c + * lower interface partly redesigned + * + * Revision 1.16 2001/04/29 brianreifsnyder + * Added phase 1 support for LBA hard drives * * Revision 1.15 2001/04/16 01:45:26 bartoldeman * Fixed handles, config.sys drivers, warnings. Enabled INT21/AH=6C, printf %S/%Fs @@ -138,9 +147,9 @@ static BYTE *dskRcsId = "$Id$"; */ #if defined(DEBUG) - #define PartCodePrintf(x) printf x + #define DebugPrintf(x) printf x #else - #define PartCodePrintf(x) + #define DebugPrintf(x) #endif #define STATIC @@ -153,10 +162,16 @@ BOOL fl_reset(WORD); COUNT fl_readdasd(WORD); COUNT fl_diskchanged(WORD); COUNT fl_rd_status(WORD); + COUNT fl_read(WORD, WORD, WORD, WORD, WORD, BYTE FAR *); COUNT fl_write(WORD, WORD, WORD, WORD, WORD, BYTE FAR *); COUNT fl_verify(WORD, WORD, WORD, WORD, WORD, BYTE FAR *); -BOOL fl_format(WORD, BYTE FAR *); + +extern COUNT fl_lba_ReadWrite (BYTE drive, WORD mode, + struct _bios_LBA_address_packet FAR *dap_p); + +int LBA_Transfer(struct DriveParamS *driveParam ,UWORD mode, VOID FAR *buffer, + ULONG LBA_address,unsigned total, UWORD *transferred); #else BOOL fl_reset(); COUNT fl_readdasd(); @@ -165,52 +180,26 @@ COUNT fl_rd_status(); COUNT fl_read(); COUNT fl_write(); COUNT fl_verify(); -BOOL fl_format(); #endif -#define NDEV 8 /* only one for demo */ -#define SEC_SIZE 512 /* size of sector in bytes */ -#define N_RETRY 5 /* number of retries permitted */ #define NENTRY 26 /* total size of dispatch table */ extern BYTE FAR nblk_rel; - /* this buffer must not overlap a 64K boundary - due to DMA transfers - this is certainly true, if located somewhere - at 0xf+1000 and must hold already during BOOT time - */ -union -{ - BYTE bytes[1 * SEC_SIZE]; - boot boot_sector; -} DiskTransferBuffer; - - -STATIC struct media_info -{ - ULONG mi_size; /* physical sector count */ - UWORD mi_heads; /* number of heads (sides) */ - UWORD mi_cyls; /* number of cyl/drive */ - UWORD mi_sectors; /* number of sectors/cyl */ - ULONG mi_offset; /* relative partition offset */ - BYTE mi_drive; /* BIOS drive number */ - ULONG mi_FileOC; /* Count of Open files on Drv */ - - UWORD mi_BeginCylinder; - BYTE mi_BeginHead; - BYTE mi_BeginSector; - - struct FS_info - { - ULONG serialno; - BYTE volume[11]; - BYTE fstype[8]; - }fs; -}; +#define LBA_READ 0x4200 +#define LBA_WRITE 0x4300 +UWORD LBA_WRITE_VERIFY = 0x4302; +#define LBA_VERIFY 0x4400 +extern void __int__(int); + /* this buffer must not overlap a 64K boundary + due to DMA transfers + this is certainly true, if located somewhere + at 0xf+1000 and must hold already during BOOT time + */ +UBYTE DiskTransferBuffer[1 * SEC_SIZE]; static struct Access_info { @@ -218,40 +207,39 @@ static struct Access_info BYTE AI_Flag; }; -STATIC struct media_info miarray[NDEV]; /* Internal media info structs */ -STATIC bpb bpbarray[NDEV]; /* BIOS parameter blocks */ -STATIC bpb *bpbptrs[NDEV]; /* pointers to bpbs */ +struct media_info *miarrayptr; /* Internal media info structs */ +bpb bpbarray[NDEV]; /* BIOS parameter blocks */ +/* STATIC bpb *bpbptrs[NDEV]; pointers to bpbs */ /*TE - array access functions */ -struct media_info *getPMiarray(int dev) { return &miarray[dev];} +struct media_info *getPMiarray(int dev) { return &miarrayptr[dev];} bpb *getPBpbarray(unsigned dev){ return &bpbarray[dev];} #define N_PART 4 /* number of partitions per - table partition */ + table partition */ -STATIC COUNT nUnits; /* number of returned units */ +COUNT nUnits; /* number of returned units */ #define PARTOFF 0x1be #ifdef PROTO -WORD _dsk_init(rqptr), - mediachk(rqptr), - bldbpb(rqptr), - blockio(rqptr), - IoctlQueblk(rqptr), - Genblkdev(rqptr), - Getlogdev(rqptr), - Setlogdev(rqptr), - blk_Open(rqptr), - blk_Close(rqptr), - blk_Media(rqptr), - blk_noerr(rqptr), - blk_nondr(rqptr), - blk_error(rqptr); -COUNT ltop(WORD *, WORD *, WORD *, COUNT, COUNT, ULONG, byteptr); +WORD + _dsk_init (rqptr rq, struct media_info *pmiarray), + mediachk (rqptr rq, struct media_info *pmiarray), + bldbpb (rqptr rq, struct media_info *pmiarray), + blockio (rqptr rq, struct media_info *pmiarray), + IoctlQueblk(rqptr rq, struct media_info *pmiarray), + Genblkdev (rqptr rq, struct media_info *pmiarray), + Getlogdev (rqptr rq, struct media_info *pmiarray), + Setlogdev (rqptr rq, struct media_info *pmiarray), + blk_Open (rqptr rq, struct media_info *pmiarray), + blk_Close (rqptr rq, struct media_info *pmiarray), + blk_Media (rqptr rq, struct media_info *pmiarray), + blk_noerr (rqptr rq, struct media_info *pmiarray), + blk_nondr (rqptr rq, struct media_info *pmiarray), + blk_error (rqptr rq, struct media_info *pmiarray); WORD dskerr(COUNT); -COUNT processtable(int table_type,COUNT ptDrive, BYTE ptHead, UWORD ptCylinder, BYTE ptSector, LONG ptAccuOff, UWORD PartitionDone); #else WORD _dsk_init(), mediachk(), @@ -268,7 +256,6 @@ WORD _dsk_init(), blk_nondr(), blk_error(); WORD dskerr(); -COUNT processtable(); #endif /* */ @@ -276,7 +263,7 @@ COUNT processtable(); /* */ #ifdef PROTO -static WORD(*dispatch[NENTRY]) (rqptr) = +static WORD(*dispatch[NENTRY]) (rqptr rq, struct media_info *pmiarray) = #else static WORD(*dispatch[NENTRY]) () = #endif @@ -309,329 +296,19 @@ static WORD(*dispatch[NENTRY]) () = IoctlQueblk /* Ioctl Query */ }; -#define SIZEOF_PARTENT 16 - -#define PRIMARY 0x01 -#define PRIMARY2 0x02 - -#define FAT12 0x01 -#define FAT16SMALL 0x04 -#define EXTENDED 0x05 -#define FAT16LARGE 0x06 -#define EXTENDED_INT32 0x0f /* like 0x05, but uses extended INT32 */ - -#define hd(x) ((x) & 0x80) - - - -ULONG StartSector(WORD ptDrive, unsigned BeginCylinder, - unsigned BeginHead, - unsigned BeginSector, - ULONG peStartSector, - ULONG ptAccuOff) -{ - iregs regs; - - unsigned heads,sectors; - ULONG startPos; - ULONG oldStartPos; - - regs.a.x = 0x0800; /* get drive parameters */ - regs.d.x = ptDrive; - intr(0x13, ®s); - - if ((regs.a.x & 0xff) != 0) - { - PartCodePrintf(("error getting drive parameters for drive %x\n", ptDrive)); - return peStartSector+ptAccuOff; - } - - /* cylinders = (regs.c.x >>8) | ((regs.c.x & 0x0c) << 2); */ - heads = (regs.d.x >> 8) + 1; - sectors = regs.c.x & 0x3f; - - startPos = ((ULONG)BeginCylinder * heads + BeginHead) * sectors + BeginSector - 1; - - PartCodePrintf((" CHS %x %x %x (%d %d %d) --> %lx ( %ld)\n", - BeginCylinder, BeginHead, BeginSector, - BeginCylinder, BeginHead, BeginSector, - startPos, startPos)); - - - oldStartPos = peStartSector + ptAccuOff; - - PartCodePrintf(("oldStartPos = %lx - ", oldStartPos)); - - - if (startPos != oldStartPos) - { - PartCodePrintf(("PART TABLE mismatch for drive %x, CHS=%d %d %d, startsec %d, offset %ld\n", - ptDrive, BeginCylinder, BeginHead,BeginSector, - peStartSector, ptAccuOff)); - - PartCodePrintf((" old startpos = %ld, new startpos = %ld, using new\n", - oldStartPos, startPos)); - } - - return startPos; -} - -/* - thats what MSDN says: - - How Windows 2000 Assigns, Reserves, and Stores Drive Letters - ID: q234048 - - BASIC Disk - Drive Letter Assignment Rules -The following are the basic disk drive letter assignment rules for Windows 2000: -Scan all fixed hard disks as they are enumerated, assign drive letters -starting with any active primary partitions (if there is one), otherwise, -scan the first primary partition on each drive. Assign next available -letter starting with C: - -Repeat scan for all fixed hard disks and removable (JAZ, MO) disks -and assign drive letters to all logical drives in an extended partition, -or the removable disk(s) as enumerated. Assign next available letter -starting with C: - - -Finally, repeat scan for all fixed hard disk drives, and assign drive -letters to all remaining primary partitions. Assign next available letter -starting with C: - -Floppy drives. Assign letter starting with A: - -CD-ROM drives. Assign next available letter starting with D: - -************************************************************************* -Order in Which MS-DOS and Windows Assign Drive Letters -ID: q51978 - -MORE INFORMATION -The following occurs at startup: - -MS-DOS checks all installed disk devices, assigning the drive letter A -to the first physical floppy disk drive that is found. - -If a second physical floppy disk drive is present, it is assigned drive letter B. If it is not present, a logical drive B is created that uses the first physical floppy disk drive. - - -Regardless of whether a second floppy disk drive is present, -MS-DOS then assigns the drive letter C to the primary MS-DOS -partition on the first physical hard disk, and then goes on -to check for a second hard disk. - - -If a second physical hard disk is found, and a primary partition exists -on the second physical drive, the primary MS-DOS partition on the second -physical hard drive is assigned the letter D. MS-DOS version 5.0, which -supports up to eight physical drives, will continue to search for more -physical hard disk drives at this point. For example, if a third physical -hard disk is found, and a primary partition exists on the third physical -drive, the primary MS-DOS partition on the third physical hard drive is -assigned the letter E. - - -MS-DOS returns to the first physical hard disk drive and assigns drive -letters to any additional logical drives (in extended MS-DOS partitions) -on that drive in sequence. - - -MS-DOS repeats this process for the second physical hard disk drive, -if present. MS-DOS 5.0 will repeat this process for up to eight physical -hard drives, if present. After all logical drives (in extended MS-DOS -partitions) have been assigned drive letters, MS-DOS 5.0 returns to -the first physical drive and assigns drive letters to any other primary -MS-DOS partitions that exist, then searches other physical drives for -additional primary MS-DOS partitions. This support for multiple primary -MS-DOS partitions was added to version 5.0 for backward compatibility -with the previous OEM MS-DOS versions that support multiple primary partitions. - - -After all logical drives on the hard disk(s) have been assigned drive -letters, drive letters are assigned to drives installed using DRIVER.SYS -or created using RAMDRIVE.SYS in the order in which the drivers are loaded -in the CONFIG.SYS file. Which drive letters are assigned to which devices -can be influenced by changing the order of the device drivers or, if necessary, -by creating "dummy" drive letters with DRIVER.SYS. - -******************************************************** - -I don't know, if I did it right, but I tried to do it that way. TE - -*/ -COUNT processtable(int table_type,COUNT ptDrive, BYTE ptHead, UWORD ptCylinder, - BYTE ptSector, LONG ptAccuOff, UWORD PartitionDone ) -{ - struct /* Temporary partition table */ - { - BYTE peBootable; - BYTE peBeginHead; - BYTE peBeginSector; - UWORD peBeginCylinder; - BYTE peFileSystem; - BYTE peEndHead; - BYTE peEndSector; - UWORD peEndCylinder; - LONG peStartSector; - LONG peSectors; - } - temp_part[N_PART], - *ptemp_part; /*TE*/ - - int retry; - UBYTE packed_byte, - pb1; - BYTE *p; - int partition_chain = 0; - int ret; -/* ULONG newStartPos;*/ - UWORD partMask; - int loop; -restart: /* yes, it's a GOTO >:-) */ - /* if someone has a circular linked - extended partition list, stop it sooner or later */ - if (partition_chain > 64) - return PartitionDone; - - PartCodePrintf(("searching partition table at %x %x %x %x %lx\n", - ptDrive, ptCylinder, ptHead, ptSector, ptAccuOff)); - /* Read partition table */ - for ( retry = N_RETRY; --retry >= 0; ) - { - ret = fl_read((WORD) ptDrive, (WORD) ptHead, (WORD) ptCylinder, - (WORD) ptSector, (WORD) 1, (byteptr) & DiskTransferBuffer); - if (ret == 0) - break; - } - if (ret != 0) - return PartitionDone; +#define hd(x) ((x) & 0x80) + +/* ----------------------------------------------------------------------- */ +/* F U N C T I O N S --------------------------------------------------- */ +/* ----------------------------------------------------------------------- */ - /* Read each partition into temporary array */ - - p = (BYTE *) & DiskTransferBuffer.bytes[PARTOFF]; - - for (ptemp_part = &temp_part[0]; - ptemp_part < &temp_part[N_PART]; ptemp_part++) - { - getbyte((VOID *) (p+0), &ptemp_part->peBootable); - getbyte((VOID *) (p+1), &ptemp_part->peBeginHead); - getbyte((VOID *) (p+2), &packed_byte); - ptemp_part->peBeginSector = packed_byte & 0x3f; - getbyte((VOID *) (p+3), &pb1); - ptemp_part->peBeginCylinder = pb1 + ((UWORD) (0xc0 & packed_byte) << 2); - getbyte((VOID *) (p+4), &ptemp_part->peFileSystem); - getbyte((VOID *) (p+5), &ptemp_part->peEndHead); - getbyte((VOID *) (p+6), &packed_byte); - ptemp_part->peEndSector = packed_byte & 0x3f; - getbyte((VOID *) (p+7), &pb1); - ptemp_part->peEndCylinder = pb1 + ((UWORD) (0xc0 & packed_byte) << 2); - getlong((VOID *) (p+8), &ptemp_part->peStartSector); - getlong((VOID *) (p+12), &ptemp_part->peSectors); - - p += SIZEOF_PARTENT; /* == 16 */ - } - /* Walk through the table, add DOS partitions to global - array and process extended partitions */ - - /* when searching the EXT chain, - must skip primary partitions */ - if ( table_type==PRIMARY || - table_type==PRIMARY2 || - partition_chain!=0 ) - { - /* do this for - 0) all active partitions - 1) the first primary partition - */ - for (loop = 0; loop < 2; loop++) - { - for (ptemp_part = &temp_part[0], partMask = 1; - ptemp_part < &temp_part[N_PART] && nUnits < NDEV; - partMask <<= 1,ptemp_part++) - { - - - if (loop == 0 && /* scan for only for active */ - !ptemp_part->peBootable) - { - continue; - } - - if (PartitionDone & partMask) /* don't reassign partitions */ - { - continue; - } - - if ( ptemp_part->peFileSystem == FAT12 || - ptemp_part->peFileSystem == FAT16SMALL || - ptemp_part->peFileSystem == FAT16LARGE ) - { - - struct media_info *pmiarray = getPMiarray(nUnits); - - pmiarray->mi_drive = ptDrive; - - pmiarray->mi_offset = StartSector(ptDrive, - ptemp_part->peBeginCylinder, - ptemp_part->peBeginHead, - ptemp_part->peBeginSector, - ptemp_part->peStartSector, - ptAccuOff); - - pmiarray->mi_BeginCylinder = ptemp_part->peBeginCylinder; - pmiarray->mi_BeginHead = ptemp_part->peBeginHead; - pmiarray->mi_BeginSector = ptemp_part->peBeginSector; - - - nUnits++; - - - PartitionDone |= partMask; - - if ( table_type==PRIMARY ) - { - return PartitionDone; /* we are done */ - } - - } /* end FAT16 detected */ - } /* end PArtitionentry 0..3 */ - } /* end of loop 0..1 for active, nonactive */ - } /* if ( table_type==PRIMARY ) */ - - /* search for EXT partitions only on 2. run */ - if (table_type==EXTENDED) - { - for (ptemp_part = &temp_part[0]; - ptemp_part < &temp_part[N_PART] && nUnits < NDEV; ptemp_part++) - { - if ( (ptemp_part->peFileSystem == EXTENDED || - ptemp_part->peFileSystem == EXTENDED_INT32 ) ) - { - /* restart with new extended part table, don't recurs */ - partition_chain++; - - ptHead = ptemp_part->peBeginHead; - ptCylinder = ptemp_part->peBeginCylinder; - ptSector = ptemp_part->peBeginSector; - ptAccuOff = ptemp_part->peStartSector + ptAccuOff; - - PartitionDone = 0; /* not important for EXTENDED */ - - goto restart; - } - } - } - - return PartitionDone; -} COUNT FAR blk_driver(rqptr rp) { @@ -642,103 +319,21 @@ COUNT FAR blk_driver(rqptr rp) return failure(E_FAILURE); /* general failure */ } else - return ((*dispatch[rp->r_command]) (rp)); + return ((*dispatch[rp->r_command]) (rp, getPMiarray(rp->r_unit))); } -WORD _dsk_init(rqptr rp) +/* disk init is done in diskinit.c, so this should never be called */ +WORD _dsk_init(rqptr rp, struct media_info *pmiarray) { - extern COUNT fl_nrdrives(VOID); - COUNT HardDrive, - nHardDisk, - Unit; - struct media_info *pmiarray; - bpb *pbpbarray; - UBYTE foundPartitions[16]; - - - /* Reset the drives */ - fl_reset(0x80); - - /* Initial number of disk units */ - nUnits = 2; - - /* Setup media info and BPBs arrays */ - for (Unit = 0; Unit < NDEV; Unit++) - { - pmiarray = getPMiarray(Unit); - - pmiarray->mi_size = 720l; - pmiarray->mi_heads = 2; - pmiarray->mi_cyls = 40; - pmiarray->mi_sectors = 9; - pmiarray->mi_offset = 0l; - pmiarray->mi_drive = Unit; - - pmiarray->mi_BeginCylinder = 0; /* initialize for floppies */ - pmiarray->mi_BeginHead = 0; - pmiarray->mi_BeginSector = 1; - - - pmiarray->fs.serialno = 0x12345678l; - - pbpbarray = getPBpbarray(Unit); - - pbpbarray->bpb_nbyte = SEC_SIZE; - pbpbarray->bpb_nsector = 2; - pbpbarray->bpb_nreserved = 1; - pbpbarray->bpb_nfat = 2; - pbpbarray->bpb_ndirent = 112; - pbpbarray->bpb_nsize = 720l; - pbpbarray->bpb_mdesc = 0xfd; - pbpbarray->bpb_nfsect = 2; - - bpbptrs[Unit] = pbpbarray; - } - - nHardDisk = fl_nrdrives(); - - nHardDisk = min(nHardDisk,sizeof(foundPartitions)); - - /* as rather well documented, DOS searches 1st) 1 primary patitions on - all drives, 2nd) all extended partitions. that - makes many people (including me) unhappy, as all DRIVES D:,E:... - on 1st disk will move up/down, if other disk with - primary partitions are added/removed, but - thats the way it is (hope I got it right) - TE (with a little help from my friends) - see also above for WIN2000,DOS,MSDN */ - - PartCodePrintf(("DSK init: found %d disk drives\n",nHardDisk)); - - - /* Process primary partition table 1 partition only */ - for (HardDrive = 0; HardDrive < nHardDisk; HardDrive++) - { - foundPartitions[HardDrive] = - processtable(PRIMARY, (HardDrive | 0x80), 0, 0l, 1, 0l,0); - } - /* Process extended partition table */ - for (HardDrive = 0; HardDrive < nHardDisk; HardDrive++) - { - processtable(EXTENDED, (HardDrive | 0x80), 0, 0l, 1, 0l,0); - } - - /* Process primary a 2nd time */ - for (HardDrive = 0; HardDrive < nHardDisk; HardDrive++) - { - processtable(PRIMARY2, (HardDrive | 0x80), 0, 0l, 1, 0l,foundPartitions[HardDrive]); - } - - rp->r_nunits = nUnits; - rp->r_bpbptr = bpbptrs; - rp->r_endaddr = device_end(); - nblk_rel = nUnits; /* make device header reflect units */ - return S_DONE; + UNREFERENCED_PARAMETER(rp); + UNREFERENCED_PARAMETER(pmiarray); + fatal("No disk init!"); + return S_DONE; /* to keep the compiler happy */ } -static WORD mediachk(rqptr rp) +WORD mediachk(rqptr rp, struct media_info *pmiarray) { - COUNT drive = miarray[rp->r_unit].mi_drive; + COUNT drive = pmiarray->drive.driveno; COUNT result; /* if it's a hard drive, media never changes */ @@ -747,7 +342,7 @@ static WORD mediachk(rqptr rp) else /* else, check floppy status */ { - if ((result = fl_readdasd(drive)) == 2) /* if we can detect a change ... */ + if ((result = fl_readdasd(drive)) == 2) /* if we can detect a change ... */ { if ((result = fl_diskchanged(drive)) == 1) /* check if it has changed... */ rp->r_mcretcode = M_CHANGED; @@ -770,75 +365,79 @@ static WORD mediachk(rqptr rp) */ STATIC WORD RWzero(rqptr rp, WORD t) { - REG retry = N_RETRY; - WORD ret; struct media_info *pmiarray = getPMiarray(rp->r_unit); + UWORD done; - do - { - ret = (t == 0 ? fl_read : fl_write)( - (WORD) pmiarray->mi_drive, - (WORD) pmiarray->mi_BeginHead, - (WORD) pmiarray->mi_BeginCylinder, - (WORD) pmiarray->mi_BeginSector, - (WORD) 1, (byteptr) & DiskTransferBuffer); - } - while (ret != 0 && --retry > 0); - return ret; + return LBA_Transfer(&pmiarray->drive, + t == 0 ? LBA_READ : LBA_WRITE, + (UBYTE FAR *)&DiskTransferBuffer, + pmiarray->mi_offset,1,&done); } /* 0 if not set, 1 = a, 2 = b, etc, assume set. page 424 MS Programmer's Ref. */ -static WORD Getlogdev(rqptr rp) +static WORD Getlogdev(rqptr rp, struct media_info *pmiarray) { BYTE x = rp->r_unit; + + UNREFERENCED_PARAMETER(pmiarray); + x++; if( x > nblk_rel ) - return failure(E_UNIT); + return failure(E_UNIT); rp->r_unit = x; return S_DONE; } -static WORD Setlogdev(rqptr rp) +static WORD Setlogdev(rqptr rp, struct media_info *pmiarray) { - UNREFERENCED_PARAMETER(rp); + UNREFERENCED_PARAMETER(rp); + UNREFERENCED_PARAMETER(pmiarray); + return S_DONE; } -static WORD blk_Open(rqptr rp) +static WORD blk_Open(rqptr rp, struct media_info *pmiarray) { - miarray[rp->r_unit].mi_FileOC++; + UNREFERENCED_PARAMETER(rp); + + pmiarray->mi_FileOC++; return S_DONE; } -static WORD blk_Close(rqptr rp) +static WORD blk_Close(rqptr rp, struct media_info *pmiarray) { - miarray[rp->r_unit].mi_FileOC--; + UNREFERENCED_PARAMETER(rp); + + pmiarray->mi_FileOC--; return S_DONE; } -static WORD blk_nondr(rqptr rp) +static WORD blk_nondr(rqptr rp, struct media_info *pmiarray) { - UNREFERENCED_PARAMETER(rp); + UNREFERENCED_PARAMETER(rp); + UNREFERENCED_PARAMETER(pmiarray); + return S_BUSY|S_DONE; } -static WORD blk_Media(rqptr rp) +static WORD blk_Media(rqptr rp, struct media_info *pmiarray) { - if (hd( miarray[rp->r_unit].mi_drive)) - return S_BUSY|S_DONE; /* Hard Drive */ + UNREFERENCED_PARAMETER(rp); + + if (hd( pmiarray->drive.driveno)) + return S_BUSY|S_DONE; /* Hard Drive */ else - return S_DONE; /* Floppy */ + return S_DONE; /* Floppy */ } -STATIC WORD bldbpb(rqptr rp) +STATIC WORD bldbpb(rqptr rp, struct media_info *pmiarray) { ULONG count; bpb *pbpbarray; - struct media_info *pmiarray; WORD head,/*track,*/sector,ret; ret = RWzero( rp, 0); @@ -849,29 +448,28 @@ STATIC WORD bldbpb(rqptr rp) /*TE ~ 200 bytes*/ pbpbarray = getPBpbarray(rp->r_unit); - getword(&((((BYTE *) & DiskTransferBuffer.bytes[BT_BPB]))[BPB_NBYTE]), &pbpbarray->bpb_nbyte); - getbyte(&((((BYTE *) & DiskTransferBuffer.bytes[BT_BPB]))[BPB_NSECTOR]), &pbpbarray->bpb_nsector); - getword(&((((BYTE *) & DiskTransferBuffer.bytes[BT_BPB]))[BPB_NRESERVED]), &pbpbarray->bpb_nreserved); - getbyte(&((((BYTE *) & DiskTransferBuffer.bytes[BT_BPB]))[BPB_NFAT]), &pbpbarray->bpb_nfat); - getword(&((((BYTE *) & DiskTransferBuffer.bytes[BT_BPB]))[BPB_NDIRENT]), &pbpbarray->bpb_ndirent); - getword(&((((BYTE *) & DiskTransferBuffer.bytes[BT_BPB]))[BPB_NSIZE]), &pbpbarray->bpb_nsize); - getword(&((((BYTE *) & DiskTransferBuffer.bytes[BT_BPB]))[BPB_NSIZE]), &pbpbarray->bpb_nsize); - getbyte(&((((BYTE *) & DiskTransferBuffer.bytes[BT_BPB]))[BPB_MDESC]), &pbpbarray->bpb_mdesc); - getword(&((((BYTE *) & DiskTransferBuffer.bytes[BT_BPB]))[BPB_NFSECT]), &pbpbarray->bpb_nfsect); - getword(&((((BYTE *) & DiskTransferBuffer.bytes[BT_BPB]))[BPB_NSECS]), &pbpbarray->bpb_nsecs); - getword(&((((BYTE *) & DiskTransferBuffer.bytes[BT_BPB]))[BPB_NHEADS]), &pbpbarray->bpb_nheads); - getlong(&((((BYTE *) & DiskTransferBuffer.bytes[BT_BPB])[BPB_HIDDEN])), &pbpbarray->bpb_hidden); - getlong(&((((BYTE *) & DiskTransferBuffer.bytes[BT_BPB])[BPB_HUGE])), &pbpbarray->bpb_huge); + getword(&((((BYTE *) & DiskTransferBuffer[BT_BPB]))[BPB_NBYTE]), &pbpbarray->bpb_nbyte); + getbyte(&((((BYTE *) & DiskTransferBuffer[BT_BPB]))[BPB_NSECTOR]), &pbpbarray->bpb_nsector); + getword(&((((BYTE *) & DiskTransferBuffer[BT_BPB]))[BPB_NRESERVED]), &pbpbarray->bpb_nreserved); + getbyte(&((((BYTE *) & DiskTransferBuffer[BT_BPB]))[BPB_NFAT]), &pbpbarray->bpb_nfat); + getword(&((((BYTE *) & DiskTransferBuffer[BT_BPB]))[BPB_NDIRENT]), &pbpbarray->bpb_ndirent); + getword(&((((BYTE *) & DiskTransferBuffer[BT_BPB]))[BPB_NSIZE]), &pbpbarray->bpb_nsize); + getword(&((((BYTE *) & DiskTransferBuffer[BT_BPB]))[BPB_NSIZE]), &pbpbarray->bpb_nsize); + getbyte(&((((BYTE *) & DiskTransferBuffer[BT_BPB]))[BPB_MDESC]), &pbpbarray->bpb_mdesc); + getword(&((((BYTE *) & DiskTransferBuffer[BT_BPB]))[BPB_NFSECT]), &pbpbarray->bpb_nfsect); + getword(&((((BYTE *) & DiskTransferBuffer[BT_BPB]))[BPB_NSECS]), &pbpbarray->bpb_nsecs); + getword(&((((BYTE *) & DiskTransferBuffer[BT_BPB]))[BPB_NHEADS]), &pbpbarray->bpb_nheads); + getlong(&((((BYTE *) & DiskTransferBuffer[BT_BPB])[BPB_HIDDEN])), &pbpbarray->bpb_hidden); + getlong(&((((BYTE *) & DiskTransferBuffer[BT_BPB])[BPB_HUGE])), &pbpbarray->bpb_huge); - pmiarray = getPMiarray(rp->r_unit); /* Needs fat32 offset code */ - getlong(&((((BYTE *) & DiskTransferBuffer.bytes[0x27])[0])), &pmiarray->fs.serialno); + getlong(&((((BYTE *) & DiskTransferBuffer[0x27])[0])), &pmiarray->fs.serialno); - memcpy(pmiarray->fs.volume,&DiskTransferBuffer.bytes[0x2B], 11); - memcpy(pmiarray->fs.fstype,&DiskTransferBuffer.bytes[0x36], 8); + memcpy(pmiarray->fs.volume,&DiskTransferBuffer[0x2B], 11); + memcpy(pmiarray->fs.fstype,&DiskTransferBuffer[0x36], 8); @@ -892,19 +490,19 @@ STATIC WORD bldbpb(rqptr rp) pbpbarray->bpb_nsize == 0 ? pbpbarray->bpb_huge : pbpbarray->bpb_nsize; - getword((&(((BYTE *) & DiskTransferBuffer.bytes[BT_BPB])[BPB_NHEADS])), &pmiarray->mi_heads); - head = pmiarray->mi_heads; - getword((&(((BYTE *) & DiskTransferBuffer.bytes[BT_BPB])[BPB_NSECS])), &pmiarray->mi_sectors); + getword((&(((BYTE *) & DiskTransferBuffer[BT_BPB])[BPB_NHEADS])), &pmiarray->drive.chs.Head); + head = pmiarray->drive.chs.Head; + getword((&(((BYTE *) & DiskTransferBuffer[BT_BPB])[BPB_NSECS])), &pmiarray->drive.chs.Sector); if (pmiarray->mi_size == 0) - getlong(&((((BYTE *) & DiskTransferBuffer.bytes[BT_BPB])[BPB_HUGE])), &pmiarray->mi_size); - sector = pmiarray->mi_sectors; + getlong(&((((BYTE *) & DiskTransferBuffer[BT_BPB])[BPB_HUGE])), &pmiarray->mi_size); + sector = pmiarray->drive.chs.Sector; if (head == 0 || sector == 0) { tmark(); return failure(E_FAILURE); } - pmiarray->mi_cyls = count / (head * sector); + pmiarray->drive.chs.Cylinder = count / (head * sector); tmark(); #ifdef DSK_DEBUG @@ -916,215 +514,165 @@ STATIC WORD bldbpb(rqptr rp) return S_DONE; } -STATIC COUNT write_and_verify(WORD drive, WORD head, WORD track, WORD sector, - WORD count, BYTE FAR * buffer) -{ - REG COUNT ret; - ret = fl_write(drive, head, track, sector, count, buffer); - if (ret != 0) - return ret; - return fl_verify(drive, head, track, sector, count, buffer); -} - -static WORD IoctlQueblk(rqptr rp) +static WORD IoctlQueblk(rqptr rp, struct media_info *pmiarray) { + UNREFERENCED_PARAMETER(pmiarray); + switch(rp->r_count){ - case 0x0846: - case 0x0847: - case 0x0860: - case 0x0866: - case 0x0867: - break; - default: - return failure(E_CMD); + case 0x0846: + case 0x0847: + case 0x0860: + case 0x0866: + case 0x0867: + break; + default: + return failure(E_CMD); } return S_DONE; } -static WORD Genblkdev(rqptr rp) +STATIC WORD Genblkdev(rqptr rp,struct media_info *pmiarray) { int ret; - struct media_info *pmiarray = getPMiarray(rp->r_unit); switch(rp->r_count){ - case 0x0860: /* get device parameters */ - { - struct gblkio FAR * gblp = (struct gblkio FAR *) rp->r_trans; - REG COUNT x = 5,y = 1,z = 0; - - if (!hd(pmiarray->mi_drive)){ - y = 2; - x = 8; /* any odd ball drives return this */ - if (pmiarray->mi_size <= 0xffff) - switch((UWORD)pmiarray->mi_size) - { - case 640: - case 720: /* 320-360 */ - x = 0; - z = 1; - break; - case 1440: /* 720 */ - x = 2; - break; - case 2400: /* 1.2 */ - x = 1; - break; - case 2880: /* 1.44 */ - x = 7; - break; - case 5760: /* 2.88 almost forgot this one*/ - x = 9; - break; - } - } - gblp->gbio_devtype = (UBYTE) x; - gblp->gbio_devattrib = (UWORD) y; - gblp->gbio_media = (UBYTE) z; - gblp->gbio_ncyl = pmiarray->mi_cyls; - fmemcpy(&gblp->gbio_bpb, &bpbarray[rp->r_unit], sizeof(gblp->gbio_bpb)); - gblp->gbio_nsecs = bpbarray[rp->r_unit].bpb_nsector; + case 0x0860: /* get device parameters */ + { + struct gblkio FAR * gblp = (struct gblkio FAR *) rp->r_trans; + REG COUNT x = 5,y = 1,z = 0; + + if (!hd(pmiarray->drive.driveno)){ + y = 2; + x = 8; /* any odd ball drives return this */ + if (pmiarray->mi_size <= 0xffff) + switch((UWORD)pmiarray->mi_size) + { + case 640: + case 720: /* 320-360 */ + x = 0; + z = 1; break; - } - case 0x0866: /* get volume serial number */ - { - struct Gioc_media FAR * gioc = (struct Gioc_media FAR *) rp->r_trans; - struct FS_info FAR * fs = &pmiarray->fs; - - gioc->ioc_serialno = fs->serialno; - fmemcpy(gioc->ioc_volume,fs->volume,11); - fmemcpy(gioc->ioc_fstype, fs->fstype,8); - } + case 1440: /* 720 */ + x = 2; break; - case 0x0846: /* set volume serial number */ - { - struct Gioc_media FAR * gioc = (struct Gioc_media FAR *) rp->r_trans; - struct FS_info FAR * fs = (struct FS_info FAR *) &DiskTransferBuffer.bytes[0x27]; - - ret = RWzero( rp, 0); - if (ret != 0) - return (dskerr(ret)); - - fs->serialno = gioc->ioc_serialno; - pmiarray->fs.serialno = fs->serialno; - - ret = RWzero( rp, 1); - if (ret != 0) - return (dskerr(ret)); - } + case 2400: /* 1.2 */ + x = 1; break; - case 0x0867: /* get access flag, always on*/ - { - struct Access_info FAR * ai = (struct Access_info FAR *) rp->r_trans; - ai->AI_Flag = 1; - } + case 2880: /* 1.44 */ + x = 7; break; - case 0x0847: /* set access flag, no real use*/ + case 5760: /* 2.88 almost forgot this one*/ + x = 9; break; - default: - return failure(E_CMD); + } + } + gblp->gbio_devtype = (UBYTE) x; + gblp->gbio_devattrib = (UWORD) y; + gblp->gbio_media = (UBYTE) z; + gblp->gbio_ncyl = pmiarray->drive.chs.Cylinder; + fmemcpy(&gblp->gbio_bpb, &bpbarray[rp->r_unit], sizeof(gblp->gbio_bpb)); + gblp->gbio_nsecs = bpbarray[rp->r_unit].bpb_nsector; + break; + } + case 0x0866: /* get volume serial number */ + { + struct Gioc_media FAR * gioc = (struct Gioc_media FAR *) rp->r_trans; + struct FS_info FAR * fs = &pmiarray->fs; + + gioc->ioc_serialno = fs->serialno; + fmemcpy(gioc->ioc_volume,fs->volume,11); + fmemcpy(gioc->ioc_fstype, fs->fstype,8); + } + break; + case 0x0846: /* set volume serial number */ + { + struct Gioc_media FAR * gioc = (struct Gioc_media FAR *) rp->r_trans; + struct FS_info FAR * fs = (struct FS_info FAR *) &DiskTransferBuffer[0x27]; + + ret = RWzero( rp, 0); + if (ret != 0) + return (dskerr(ret)); + + fs->serialno = gioc->ioc_serialno; + pmiarray->fs.serialno = fs->serialno; + + ret = RWzero( rp, 1); + if (ret != 0) + return (dskerr(ret)); + } + break; + case 0x0867: /* get access flag, always on*/ + { + struct Access_info FAR * ai = (struct Access_info FAR *) rp->r_trans; + ai->AI_Flag = 1; + } + break; + case 0x0847: /* set access flag, no real use*/ + break; + default: + return failure(E_CMD); } return S_DONE; } -WORD blockio(rqptr rp) +WORD blockio(rqptr rp, struct media_info *pmiarray) { - REG retry = N_RETRY, - remaining; - UWORD cmd, - total; - ULONG start; - byteptr trans; - WORD head,track,sector,ret,count; - - COUNT(*action) (WORD, WORD, WORD, WORD, WORD, BYTE FAR *); + ULONG start; + WORD ret; - struct media_info *pmiarray = getPMiarray(rp->r_unit); + int action; + + + switch (rp->r_command){ + case C_INPUT: action = LBA_READ; break; + case C_OUTPUT:action = LBA_WRITE; break; + case C_OUTVFY:action = LBA_WRITE_VERIFY; break; + default: + return failure(E_FAILURE); + } - cmd = rp->r_command; - total = 0; - trans = rp->r_trans; - tmark(); - remaining = rp->r_count; - start = (rp->r_start != HUGECOUNT ? rp->r_start : rp->r_huge) - + pmiarray->mi_offset; - while(remaining > 0) - { - count = ltop(&track, §or, &head, rp->r_unit, remaining, start, trans); + tmark(); + start = (rp->r_start != HUGECOUNT ? rp->r_start : rp->r_huge); - /*printf("dskAction %02x THS=%x-%x-%x block=%lx\n", rp->r_unit,track, head, sector, start);*/ - + if (start >= pmiarray->mi_size || + start + rp->r_count > pmiarray->mi_size) + { + return 0x0408; + } + start += pmiarray->mi_offset; + + ret = LBA_Transfer(&pmiarray->drive ,action, + rp->r_trans, + start, rp->r_count,(UWORD*)&rp->r_count); - do - { - switch (cmd) - { - case C_INPUT: - action = fl_read; - break; - case C_OUTPUT: - action = fl_write; - break; - case C_OUTVFY: - action = write_and_verify; - break; - default: - return failure(E_FAILURE); - } - - - if (count && FP_SEG(trans) != 0xffff) - { - ret = action((WORD) pmiarray->mi_drive, head, track, sector, - count, trans); - } - else - { - count = 1; - /* buffer crosses DMA boundary, use scratchpad */ - /* use scratchpad also, if going to HIGH memory */ - - if (cmd != C_INPUT) - fbcopy(trans, &DiskTransferBuffer, SEC_SIZE); - ret = action((WORD) pmiarray->mi_drive, head, track, sector, - 1, (byteptr)&DiskTransferBuffer); - if (cmd == C_INPUT) - fbcopy(&DiskTransferBuffer, trans, SEC_SIZE); - } - if (ret != 0) - fl_reset((WORD) pmiarray->mi_drive); - } - while (ret != 0 && --retry > 0); if (ret != 0) { - rp->r_count = total; return dskerr(ret); } - total += count; - remaining -= count; - trans += count * SEC_SIZE; - start += count; - } - rp->r_count = total; - return S_DONE; + return S_DONE; } -static WORD blk_error(rqptr rp) +STATIC WORD blk_error(rqptr rp, struct media_info *pmiarray) { + UNREFERENCED_PARAMETER(pmiarray); + rp->r_count = 0; return failure(E_FAILURE); /* general failure */ } -static WORD blk_noerr(rqptr rp) +STATIC WORD blk_noerr(rqptr rp, struct media_info *pmiarray) { - UNREFERENCED_PARAMETER(rp); + UNREFERENCED_PARAMETER(rp); + UNREFERENCED_PARAMETER(pmiarray); + return S_DONE; } -static WORD dskerr(COUNT code) +STATIC WORD dskerr(COUNT code) { /* printf("diskette error:\nhead = %d\ntrack = %d\nsector = %d\ncount = %d\n", head, track, sector, count); */ @@ -1132,9 +680,10 @@ static WORD dskerr(COUNT code) { case 1: /* invalid command - general failure */ if (code & 0x08) - return (E_FAILURE); + return S_ERROR | E_NOTRDY; /* failure(E_NOTRDY); at least on yhe INT25 route, + 0x8002 is returned */ else - return failure(E_CMD); + return failure(E_CMD); case 2: /* address mark not found - general failure */ return failure(E_FAILURE); @@ -1144,56 +693,221 @@ static WORD dskerr(COUNT code) default: if (code & 0x80) /* time-out */ - return failure(E_NOTRDY); + return failure(E_NOTRDY); else if (code & 0x40) /* seek error */ - return failure(E_SEEK); + return failure(E_SEEK); else if (code & 0x10) /* CRC error */ - return failure(E_CRC); + return failure(E_CRC); else if (code & 0x04) - return failure(E_NOTFND); + return failure(E_NOTFND); else - return failure(E_FAILURE); + return failure(E_FAILURE); } } -/* */ -/* Do logical block number to physical head/track/sector mapping */ -/* */ -COUNT ltop(WORD * trackp, WORD * sectorp, WORD * headp, COUNT unit, COUNT count, ULONG strt_sect, byteptr strt_addr) + +/* + translate LBA sectors into CHS addressing +*/ + +void LBA_to_CHS(struct CHS *chs, ULONG LBA_address, struct DriveParamS *driveparam) { -#ifdef I86 - UWORD utemp; -#endif - struct media_info *pmiarray; - - -#ifdef I86 -/*TE*/ - /* Adjust for segmented architecture */ - utemp = (((UWORD) mk_segment(strt_addr) << 4) + mk_offset(strt_addr)); - /* Test for 64K boundary crossing and return count large */ + chs->Sector = LBA_address% driveparam->chs.Sector + 1; + + LBA_address /= driveparam->chs.Sector; + + chs->Head = LBA_address % driveparam->chs.Head; + chs->Cylinder = LBA_address / driveparam->chs.Head; +} + + + + /* Test for 64K boundary crossing and return count small */ /* enough not to exceed the threshold. */ + +STATIC unsigned DMA_max_transfer(void FAR *buffer, unsigned count) +{ + UWORD utemp = (((UWORD) FP_SEG(buffer) << 4) + FP_OFF(buffer)); -#define SEC_SHIFT 9 /* = 0x200 = 512 */ +#define SEC_SHIFT 9 /* = 0x200 = 512 */ - utemp >>= SEC_SHIFT; + utemp >>= SEC_SHIFT; - if (count > (0xffff >> SEC_SHIFT) - utemp) - { - count = (0xffff >> SEC_SHIFT) - utemp; - } + if (count > (0xffff >> SEC_SHIFT) - utemp) + { + count = (0xffff >> SEC_SHIFT) - utemp; + } -#endif + return count; +} -/*TE*/ - pmiarray = getPMiarray(unit); - *trackp = strt_sect / (pmiarray->mi_heads * pmiarray->mi_sectors); - *sectorp = strt_sect % pmiarray->mi_sectors + 1; - *headp = (strt_sect % (pmiarray->mi_heads * pmiarray->mi_sectors)) - / pmiarray->mi_sectors; - if (*sectorp + count > pmiarray->mi_sectors + 1) - count = pmiarray->mi_sectors + 1 - *sectorp; - return count; -} +/* + int LBA_Transfer( + struct DriveParamS *driveParam, physical characteristics of drive + UWORD mode, LBA_READ/WRITE/WRITE_VERIFY + VOID FAR *buffer, user buffer + ULONG LBA_address, absolute sector address + unsigned totaltodo, number of sectors to transfer + UWORD *transferred sectors actually transferred + + Read/Write/Write+verify some sectors, using LBA addressing. + + + This function handles all the minor details, including: + + retry in case of errors + + crossing the 64K DMA boundary + + translation to CHS addressing if necessary + + crossing track boundaries (necessary for some BIOS's + + High memory doesn't work very well, use internal buffer + + write with verify details for LBA + +*/ + +int LBA_Transfer(struct DriveParamS *driveParam ,UWORD mode, VOID FAR *buffer, + ULONG LBA_address,unsigned totaltodo, UWORD *transferred) +{ + static struct _bios_LBA_address_packet dap = { + 16,0,0,0,0,0,0 + }; + + unsigned count; + unsigned error_code; + struct CHS chs; + void FAR *transfer_address; + + int num_retries; + + *transferred = 0; + + + if (LBA_address+totaltodo > driveParam->total_sectors) + { + printf("LBA-Transfer error : address overflow = %lu > %lu max\n",LBA_address+totaltodo,driveParam->total_sectors); + return 1; + } + + + for ( ;totaltodo != 0; ) + { + count = totaltodo; + + count = min(count, 0x7f); + + + /* avoid overflowing 64K DMA boundary */ + count = DMA_max_transfer(buffer,count); + + + if (FP_SEG(buffer) == 0xffff || count == 0) + { + transfer_address = DiskTransferBuffer; + count = 1; + + if ((mode & 0xff00) == (LBA_WRITE & 0xff00)) + { + fmemcpy(DiskTransferBuffer,buffer,512); + } + } + else { + transfer_address = buffer; + } + + + + for ( num_retries = 0; num_retries < N_RETRY; num_retries++) + { + if (driveParam->LBA_supported) + { + dap.number_of_blocks = count; + + dap.buffer_address = transfer_address; + + dap.block_address_high = 0; /* clear high part */ + dap.block_address = LBA_address; /* clear high part */ + + + /* Load the registers and call the interrupt. */ + + if (driveParam->WriteVerifySupported || mode != LBA_WRITE_VERIFY) + { + + error_code = fl_lba_ReadWrite(driveParam->driveno,mode, &dap); + } + else { + /* verify requested, but not supported */ + error_code = fl_lba_ReadWrite(driveParam->driveno,LBA_WRITE, &dap); + + if (error_code == 0) + { + error_code = fl_lba_ReadWrite(driveParam->driveno,LBA_VERIFY, &dap); + } + } + } + else + { /* transfer data, using old bios functions */ + + LBA_to_CHS(&chs, LBA_address, driveParam); + + /* avoid overflow at end of track */ + + if (chs.Sector + count > driveParam->chs.Sector + 1) + { + count = driveParam->chs.Sector + 1 - chs.Sector; + } + + if (chs.Cylinder > 1023) + { + printf("LBA-Transfer error : cylinder %u > 1023\n", chs.Cylinder); + return 1; + } + + error_code = (mode == LBA_READ ? fl_read : fl_write)( + driveParam->driveno, + chs.Head, chs.Cylinder, chs.Sector, + count, transfer_address); + + if (error_code == 0 && + mode == LBA_WRITE_VERIFY) + { + error_code = fl_verify( + driveParam->driveno, + chs.Head, chs.Cylinder, chs.Sector, + count, transfer_address); + } + } + if (error_code == 0) + break; + + fl_reset(driveParam->driveno); + + } /* end of retries */ + + if (error_code) + { + return error_code; + } + + /* copy to user buffer if nesessary */ + if (transfer_address == DiskTransferBuffer && + (mode & 0xff00) == (LBA_READ & 0xff00)) + { + fmemcpy(buffer,DiskTransferBuffer,512); + } + + *transferred += count; + LBA_address += count; + totaltodo -= count; + + buffer = add_far(buffer,count*512); + } + + return(error_code); +} diff --git a/kernel/dyndata.c b/kernel/dyndata.c new file mode 100644 index 00000000..0b376f88 --- /dev/null +++ b/kernel/dyndata.c @@ -0,0 +1,11 @@ +/* + DYNDATA.C + + this serves as a placeholder in the near data segment + + alll data herein goes to special segment + DYN_DATA AFTER BSS, but immediately before HMA_TEXT +*/ +#include "dyndata.h" + +struct DynS Dyn; diff --git a/kernel/dyndata.h b/kernel/dyndata.h new file mode 100644 index 00000000..ddec7aed --- /dev/null +++ b/kernel/dyndata.h @@ -0,0 +1,25 @@ +/* + DynData.h + + declarations for dynamic NEAR data allocations + + the DynBuffer must initially be large enough to hold + the PreConfig data. + after the disksystem has been initialized, the kernel is + moveable and Dyn.Buffer resizable, but not before +*/ + + +void *DynAlloc(char far *what, unsigned num, unsigned size); +void DynFree(unsigned memory_needed); +void far *DynLast(void); + +struct DynS { + unsigned Allocated; + unsigned UsedByDiskInit; + unsigned AllocMax; + char Buffer[1000 /* for InitDisk - Miarray's */ + + 16 * 71 /* initial f_nodes */ + +200 /* give some extra bytes */ + ]; + }; diff --git a/kernel/dyninit.c b/kernel/dyninit.c new file mode 100644 index 00000000..fd2c1272 --- /dev/null +++ b/kernel/dyninit.c @@ -0,0 +1,109 @@ +/* + DYNINIT.C + + this serves requests from the INIT modules to + allocate dynamic data. + + +kernel layout: + 00000H 000FFH 00100H PSP PSP + 00100H 004E1H 003E2H _TEXT CODE + 004E2H 007A7H 002C6H _IO_TEXT CODE + 007A8H 008E5H 0013EH _IO_FIXED_DATA CODE + 008F0H 0139FH 00AB0H _FIXED_DATA DATA + 013A0H 019F3H 00654H _DATA DATA + 019F4H 0240DH 00A1AH _BSS BSS + +additionally: + DYN_DATA DYN + + + 02610H 0F40EH 0CDFFH HMA_TEXT HMA + + FCB's, f_nodes, buffers,... + drivers + + + 0F410H 122DFH 02ED0H INIT_TEXT INIT + 122E0H 12AA5H 007C6H ID ID + 12AA6H 12CBFH 0021AH IB IB + + + purpose is to move the HMA_TEXT = resident kernel + around, so that below it - after BSS, there is data + addressable near by the kernel, to hold some arrays + like f_nodes + + making f_nodes near saves ~2.150 code in HMA + +*/ +#include "portab.h" +#include "init-mod.h" +#include "dyndata.h" + +#if defined(DEBUG) + #define DebugPrintf(x) printf x +#else + #define DebugPrintf(x) +#endif + + +extern struct DynS FAR Dyn; + +void *DynAlloc(char FAR *what, unsigned num, unsigned size) +{ + void *now; + unsigned total = num * size; + + UNREFERENCED_PARAMETER(what); + + DebugPrintf(("DYNDATA:allocating %Fs - %u * %u bytes, total %u, %u..%u\n", + what, num, size, total, Dyn.Allocated,Dyn.Allocated+total)); + + if (total > Dyn.AllocMax - Dyn.Allocated) + { + printf("DYNDATA overflow"); + for (;;); + } + now = (void*)&Dyn.Buffer[Dyn.Allocated]; + + Dyn.Allocated += total; + + + return now; +} + +void DynFree(unsigned memory_needed) +{ + if (memory_needed == 0) /* this is pass 0 */ + { + + Dyn.Allocated = 1000; /* this reserves space for initDisk */ + Dyn.AllocMax = sizeof(Dyn.Buffer); + } + else { + /* enlarge kernel data segment to 64K */ + if (memory_needed + Dyn.UsedByDiskInit > sizeof(Dyn.Buffer)) + { + if ((ULONG)memory_needed + Dyn.UsedByDiskInit > 0xffff) + { + printf("PANIC:Dyn %lu\n",memory_needed + Dyn.UsedByDiskInit); + for (;;); + } + + MoveKernel(FP_SEG(&Dyn.UsedByDiskInit) + 0x1000); + + Dyn.AllocMax = 0xffff - (unsigned)&Dyn.Buffer; + } + Dyn.Allocated = Dyn.UsedByDiskInit; + } + + DebugPrintf(("DYNDATA:free to %u, max %u\n",Dyn.Allocated,Dyn.AllocMax)); +} + +void FAR *DynLast() +{ + DebugPrintf(("dynamic data end at %p\n",(void FAR *)(Dyn.Buffer+Dyn.Allocated))); + + return Dyn.Buffer+Dyn.Allocated; +} diff --git a/kernel/fatdir.c b/kernel/fatdir.c index 5103e4db..3fa66b47 100644 --- a/kernel/fatdir.c +++ b/kernel/fatdir.c @@ -36,6 +36,9 @@ static BYTE *fatdirRcsId = "$Id$"; /* * $Log$ + * Revision 1.17 2001/07/09 22:19:33 bartoldeman + * LBA/FCB/FAT/SYS/Ctrl-C/ioctl fixes + memory savings + * * Revision 1.16 2001/06/03 14:16:17 bartoldeman * BUFFERS tuning and misc bug fixes/cleanups (2024c). * @@ -601,9 +604,9 @@ COUNT dos_findfirst(UCOUNT attr, BYTE FAR * name) static BYTE local_name[FNAME_SIZE + 1], local_ext[FEXT_SIZE + 1]; -/* - printf("ff %s", Tname); - */ + +/* printf("ff %Fs\n", name);*/ + /* The findfirst/findnext calls are probably the worst of the */ /* DOS calls. They must work somewhat on the fly (i.e. - open */ /* but never close). Since we don't want to lose fnodes every */ @@ -612,11 +615,13 @@ COUNT dos_findfirst(UCOUNT attr, BYTE FAR * name) /* current directory, do a seek and read, then close the fnode. */ /* Start out by initializing the dirmatch structure. */ + + fmemset(dmp, sizeof(*dmp),0); dmp->dm_drive = default_drive; - dmp->dm_entry = 0; +/* dmp->dm_entry = 0; dmp->dm_cluster = 0; - - dmp->dm_attr_srch = attr | D_RDONLY | D_ARCHIVE; +*/ + dmp->dm_attr_srch = attr; /* Parse out the drive, file name and file extension. */ i = ParseDosName((BYTE FAR *)name, &nDrive, &LocalPath[2], local_name, local_ext, TRUE); @@ -642,7 +647,7 @@ COUNT dos_findfirst(UCOUNT attr, BYTE FAR * name) /* Now build a directory. */ if (!LocalPath[2]) - strcpy(&LocalPath[2], "."); + fstrcpy(&LocalPath[0], current_ldt->cdsCurrentPath); /* Build the match pattern out of the passed string */ /* copy the part of the pattern which belongs to the filename and is fixed */ @@ -687,6 +692,8 @@ COUNT dos_findfirst(UCOUNT attr, BYTE FAR * name) } /* Now open this directory so that we can read the */ /* fnode entry and do a match on it. */ + +/* printf("dir_open %Fs\n",(BYTE FAR *) LocalPath);*/ if ((fnp = dir_open((BYTE FAR *) LocalPath)) == NULL) return DE_PATHNOTFND; @@ -728,6 +735,14 @@ COUNT dos_findfirst(UCOUNT attr, BYTE FAR * name) return dos_findnext(); } } +/* + BUGFIX TE 06/28/01 + + when using FcbFindXxx, the only information available is + the cluster number + entrycount. everything else MUST\ + be recalculated. + a good test for this is MSDOS CHKDSK, which now (seems too) work +*/ COUNT dos_findnext(void) { @@ -740,6 +755,8 @@ COUNT dos_findnext(void) { return DE_NFILES; } + + memset(fnp, 0, sizeof(*fnp)); /* Force the fnode into read-write mode */ fnp->f_mode = RDWR; @@ -758,18 +775,30 @@ COUNT dos_findnext(void) /* Search through the directory to find the entry, but do a */ /* seek first. */ if (dmp->dm_entry > 0) + { fnp->f_diroff = (dmp->dm_entry - 1) * DIRENT_SIZE; + fnp->f_flags.f_dnew = FALSE; + } + else + { + fnp->f_diroff = 0; + fnp->f_flags.f_dnew = TRUE; + } - fnp->f_offset = fnp->f_highwater = fnp->f_diroff; - fnp->f_cluster = dmp->dm_cluster; - fnp->f_cluster_offset = 0l; /*JPP */ - fnp->f_flags.f_dmod = dmp->dm_flags.f_dmod; - fnp->f_flags.f_droot = dmp->dm_flags.f_droot; - fnp->f_flags.f_dnew = dmp->dm_flags.f_dnew; - fnp->f_flags.f_ddir = dmp->dm_flags.f_ddir; - fnp->f_flags.f_dfull = dmp->dm_flags.f_dfull; + fnp->f_offset = fnp->f_diroff; + + fnp->f_dirstart = + fnp->f_dir.dir_start = + fnp->f_cluster = + dmp->dm_dirstart; - fnp->f_dirstart = dmp->dm_dirstart; + fnp->f_flags.f_droot = fnp->f_dirstart == 0; + fnp->f_flags.f_ddir = TRUE; + + + fnp->f_flags.f_dfull = FALSE; + + fnp->f_cluster_offset = 0l; /*JPP */ /* Loop through the directory */ while (dir_read(fnp) == DIRENT_SIZE) @@ -782,11 +811,12 @@ COUNT dos_findnext(void) /* MSD Command.com uses FCB FN 11 & 12 with attrib set to 0x16. Bits 0x21 seem to get set some where in MSD so Rd and Arc - files are returned. FD assumes the user knows what they need - to see. + files are returned. + RdOnly + Archive bits are ignored */ + /* Test the attribute as the final step */ - if (!(~dmp->dm_attr_srch & fnp->f_dir.dir_attrib)) + if (!(~dmp->dm_attr_srch & (fnp->f_dir.dir_attrib & ~(D_RDONLY|D_ARCHIVE)))) { found = TRUE; break; @@ -799,7 +829,20 @@ COUNT dos_findnext(void) /* If found, transfer it to the dmatch structure */ if (found) + { + extern VOID FAR *FcbFindFirstDirPtr; + + if (FcbFindFirstDirPtr) + { + /* this works MUCH better, then converting + 83 -> ASCIIZ ->83; + specifically ".", ".." + */ + fmemcpy(FcbFindFirstDirPtr, &fnp->f_dir, 32); + } + pop_dmp(dmp, fnp); + } /* return the result */ release_f_node(fnp); @@ -807,19 +850,21 @@ COUNT dos_findnext(void) return found ? SUCCESS : DE_NFILES; } -static VOID pop_dmp(dmatch FAR * dmp, f_node_ptr fnp) +STATIC VOID pop_dmp(dmatch FAR * dmp, f_node_ptr fnp) { dmp->dm_attr_fnd = fnp->f_dir.dir_attrib; dmp->dm_time = fnp->f_dir.dir_time; dmp->dm_date = fnp->f_dir.dir_date; dmp->dm_size = fnp->f_dir.dir_size; -/* dmp -> dm_cluster = fnp -> f_cluster; /* */ + dmp->dm_cluster = fnp->f_dir.dir_start; /* TE */ + dmp->dm_dirstart= fnp->f_dirstart; +/* dmp->dm_flags.f_droot = fnp->f_flags.f_droot; dmp->dm_flags.f_ddir = fnp->f_flags.f_ddir; dmp->dm_flags.f_dmod = fnp->f_flags.f_dmod; dmp->dm_flags.f_dnew = fnp->f_flags.f_dnew; - +*/ ConvertName83ToNameSZ((BYTE FAR *)dmp->dm_name, (BYTE FAR *) fnp->f_dir.dir_name); } diff --git a/kernel/fatfs.c b/kernel/fatfs.c index 466e07e0..f238346d 100644 --- a/kernel/fatfs.c +++ b/kernel/fatfs.c @@ -35,10 +35,21 @@ BYTE *RcsId = "$Id$"; #endif /* + * TE 12 jun 2001 bugs corrected + * handles disk full (in a incompatible way :-( ) + * allows use of last cluster + * prevents mkdir, if disk is full (was creating crosslinked dirs) + * bugs detected, but NOT corrected + * on disk full, MSDOS will NOT write any byte, simply return SUCCESS, 0 bytes + * FreeDOS will write all possible bytes, then close file(BUG) + * * the dos_mkdir/extenddir (with getblock() instead of getblockOver) was a real * performance killer on large drives. (~0.5 sec /dos_mkdir) TE * * $Log$ + * Revision 1.19 2001/07/09 22:19:33 bartoldeman + * LBA/FCB/FAT/SYS/Ctrl-C/ioctl fixes + memory savings + * * Revision 1.18 2001/06/03 14:16:17 bartoldeman * BUFFERS tuning and misc bug fixes/cleanups (2024c). * @@ -231,7 +242,7 @@ BYTE *RcsId = "$Id$"; /* */ /* function prototypes */ /* */ -f_node_ptrxlt_fd(COUNT); +f_node_ptr xlt_fd(COUNT); COUNT xlt_fnp(f_node_ptr); f_node_ptr split_path(BYTE FAR *, BYTE *, BYTE *, BYTE *); BOOL find_fname(f_node_ptr, BYTE *, BYTE *); @@ -251,6 +262,7 @@ BOOL extend(f_node_ptr); COUNT extend_dir(f_node_ptr); BOOL first_fat(f_node_ptr); COUNT map_cluster(f_node_ptr, COUNT); +STATIC VOID shrink_file(f_node_ptr fnp); /************************************************************************/ /* */ @@ -356,6 +368,8 @@ COUNT dos_close(COUNT fd) fnp->f_dir.dir_attrib |= D_ARCHIVE; fnp->f_dir.dir_time = dos_gettime(); fnp->f_dir.dir_date = dos_getdate(); + + shrink_file(fnp); /* reduce allocated filesize in FAT */ } fnp->f_dir.dir_size = fnp->f_highwater; @@ -659,9 +673,10 @@ COUNT dos_delete(BYTE FAR * path) if (find_fname(fnp, szFileName, szFileExt)) { /* The only permissable attribute is archive, */ + /* TE +hidden + system */ /* check for any other bit set. If it is, give */ /* an access error. */ - if (fnp->f_dir.dir_attrib & ~D_ARCHIVE) + if (fnp->f_dir.dir_attrib & ~(D_ARCHIVE | D_HIDDEN | D_SYSTEM)) { dir_close(fnp); return DE_ACCESS; @@ -1136,20 +1151,23 @@ STATIC UWORD find_fat_free(f_node_ptr fnp) /* Search the FAT table looking for the first free */ /* entry. */ - for (; idx < fnp->f_dpb->dpb_size; idx++) + for (; idx <= fnp->f_dpb->dpb_size; idx++) { if (next_cluster(fnp->f_dpb, idx) == FREE) break; } /* No empty clusters, disk is FULL! */ - if (idx >= fnp->f_dpb->dpb_size) + if (idx > fnp->f_dpb->dpb_size) { fnp->f_dpb->dpb_cluster = UNKNCLUSTER; dir_close(fnp); return LONG_LAST_CLUSTER; } + if (fnp->f_dpb->dpb_nfreeclst != UNKNCLSTFREE) + fnp->f_dpb->dpb_nfreeclst--; /* TE: moved from link_fat() */ + /* return the free entry */ fnp->f_dpb->dpb_cluster = idx; return idx; @@ -1166,6 +1184,7 @@ COUNT dos_mkdir(BYTE FAR * dir) struct buffer FAR *bp; UWORD free_fat; UWORD parent; + COUNT ret; /* first split the passed dir into comopnents (i.e. - */ /* path to new directory and name of new directory */ @@ -1204,9 +1223,7 @@ COUNT dos_mkdir(BYTE FAR * dir) dir_close(fnp); return DE_ACCESS; } - else - { - BOOL is_free; + /* Reset the directory by a close followed by */ /* an open */ @@ -1219,22 +1236,37 @@ COUNT dos_mkdir(BYTE FAR * dir) /* it in building the new file. */ /* Note that if we're in the root and we don't */ /* find an empty slot, we need to abort. */ - if (((is_free = find_free(fnp)) == 0) && (fnp->f_flags.f_droot)) + if (find_free(fnp) == 0) { - fnp->f_flags.f_dmod = FALSE; - dir_close(fnp); - return DE_TOOMANY; - } + if (fnp->f_flags.f_droot) + { + fnp->f_flags.f_dmod = FALSE; + dir_close(fnp); + return DE_TOOMANY; + } /* Otherwise just expand the directory */ - else if (!is_free && !(fnp->f_flags.f_droot)) - { - COUNT ret; if ((ret = extend_dir(fnp)) != SUCCESS) return ret; } + + /* get an empty cluster, so that we make it into a */ + /* directory. */ + /* TE this has to be done (and failed) BEFORE the dir entry */ + /* is changed */ + free_fat = find_fat_free(fnp); + + /* No empty clusters, disk is FULL! Translate into a */ + /* useful error message. */ + if (free_fat == LONG_LAST_CLUSTER) + { + dir_close(fnp); + return DE_HNDLDSKFULL; + } + + /* put the fnode's name into the directory. */ fbcopy((BYTE FAR *) szFileName, (BYTE FAR *) fnp->f_dir.dir_name, FNAME_SIZE); @@ -1257,19 +1289,7 @@ COUNT dos_mkdir(BYTE FAR * dir) fnp->f_highwater = 0l; fnp->f_offset = 0l; - } - /* get an empty cluster, so that we make it into a */ - /* directory. */ - free_fat = find_fat_free(fnp); - - /* No empty clusters, disk is FULL! Translate into a */ - /* useful error message. */ - if (free_fat == LONG_LAST_CLUSTER) - { - dir_close(fnp); - return DE_HNDLDSKFULL; - } /* Mark the cluster in the FAT as used */ fnp->f_dir.dir_start = fnp->f_cluster = free_fat; @@ -1441,7 +1461,10 @@ STATIC BOOL first_fat(f_node_ptr fnp) /* Now that we've found a free FAT entry, mark it as the last */ /* entry and save it. */ - fnp->f_dir.dir_start = free_fat; + /* BUG!! this caused wrong allocation, if file was created, + then seeked, then written */ + fnp->f_cluster = + fnp->f_dir.dir_start = free_fat; link_fat(fnp->f_dpb, (UCOUNT) free_fat, LONG_LAST_CLUSTER); /* Mark the directory so that the entry is updated */ @@ -1574,7 +1597,8 @@ UCOUNT readblock(COUNT fd, VOID FAR * buffer, UCOUNT count, COUNT * err) } /* Another test is to check for a seek past EOF */ - if (!fnp->f_flags.f_ddir && (fnp->f_offset >= fnp->f_dir.dir_size)) +/* if (!fnp->f_flags.f_ddir && (fnp->f_offset >= fnp->f_dir.dir_size)) BUG :-< */ + if (!fnp->f_flags.f_ddir && (fnp->f_offset >= fnp->f_highwater)) { *err = SUCCESS; return 0; @@ -1667,7 +1691,7 @@ UCOUNT readblock(COUNT fd, VOID FAR * buffer, UCOUNT count, COUNT * err) /* Do an EOF test and return whatever was transferred */ /* but only for regular files. */ if (!(fnp->f_flags.f_ddir) - && (fnp->f_offset >= fnp->f_dir.dir_size)) + && (fnp->f_offset >= fnp->f_highwater)) { *err = SUCCESS; return ret_cnt; @@ -1697,7 +1721,7 @@ UCOUNT readblock(COUNT fd, VOID FAR * buffer, UCOUNT count, COUNT * err) xfr_cnt = min(to_xfer, secsize - fnp->f_boff); else xfr_cnt = (UWORD)min(min(to_xfer, secsize - fnp->f_boff), - fnp->f_dir.dir_size - fnp->f_offset); + fnp->f_highwater - fnp->f_offset); fbcopy((BYTE FAR *) & bp->b_buffer[fnp->f_boff], buffer, xfr_cnt); @@ -1705,7 +1729,7 @@ UCOUNT readblock(COUNT fd, VOID FAR * buffer, UCOUNT count, COUNT * err) probably not reused later */ if (xfr_cnt == sizeof(bp->b_buffer) || - fnp->f_offset + xfr_cnt == fnp->f_dir.dir_size ) + fnp->f_offset + xfr_cnt == fnp->f_highwater ) { bp->b_flag |= BFR_UNCACHE; } @@ -1759,6 +1783,9 @@ UCOUNT writeblock(COUNT fd, VOID FAR * buffer, UCOUNT count, COUNT * err) return 0; } + fnp->f_flags.f_dmod = TRUE; /* mark file as modified */ + + /* Test that we are really about to do a data transfer. If the */ /* count is zero and the mode is XFR_READ, just exit. (Any */ /* read with a count of zero is a nop). */ @@ -1767,11 +1794,34 @@ UCOUNT writeblock(COUNT fd, VOID FAR * buffer, UCOUNT count, COUNT * err) /* file length to the current length (truncates it). */ /* */ /* NOTE: doing this up front saves a lot of headaches later. */ + if (count == 0) { + /* NOTE: doing this up front made a lot of headaches later :-( TE */ + /* FAT allocation has to be extended if necessary TE */ + + *err = SUCCESS; + if (fnp->f_highwater < fnp->f_offset) + { + switch (map_cluster(fnp, XFR_WRITE)) + { + case DE_SEEK: + *err = DE_SEEK; + dir_close(fnp); + break; + + default: + dir_close(fnp); + *err = DE_HNDLDSKFULL; + break; + + case SUCCESS: + break; + } + } + fnp->f_highwater = fnp->f_offset; merge_file_changes(fnp, FALSE); /* /// Added - Ron Cemer */ - *err = SUCCESS; return 0; } @@ -2071,8 +2121,11 @@ UWORD dos_free(struct dpb FAR *dpbp) * * (ULONG) (dpbp->dpb_clsmask + 1) - (dpbp->dpb_data + 1) ) * / (dpbp->dpb_clsmask + 1) ) + 2; */ - UWORD max_cluster = ( ((ULONG) dpbp->dpb_size * (ULONG) (dpbp->dpb_clsmask + 1)) + +/*?? UWORD max_cluster = ( ((ULONG) dpbp->dpb_size * (ULONG) (dpbp->dpb_clsmask + 1)) / (dpbp->dpb_clsmask + 1) ) + 1; +*/ + UWORD max_cluster = dpbp->dpb_size + 1; if (dpbp->dpb_nfreeclst != UNKNCLSTFREE) return dpbp->dpb_nfreeclst; @@ -2363,3 +2416,88 @@ struct dhdr FAR *select_unit(COUNT drive) } #endif + + +/* TE + if the current filesize in FAT is larger then the dir_size + it's truncated here. + the BUG was: + copy COMMAND.COM xxx + echo >xxx + + then, the dirsize of xxx was set to ~20, but the allocated + FAT entries not returned. + this code corrects this + + Unfortunately, this code _nearly_ works, but fails one of the + Apps tested (VB ISAM); so it's disabled for the moment +*/ + +STATIC VOID shrink_file(f_node_ptr fnp) +{ +#if 0 + UNREFERENCED_PARAMETER(fnp); +#else + + ULONG lastoffset = fnp->f_offset; /* has to be saved */ + UCOUNT next,st; + struct dpb FAR *dpbp = fnp->f_dpb; + + + fnp->f_offset = fnp->f_highwater; /* end of file */ + + if (map_cluster(fnp, XFR_READ) != SUCCESS) /* error, don't truncate */ + goto done; + + + st = fnp->f_cluster; + + if (st == FREE) /* first cluster is free, done */ + goto done; + + next = next_cluster(dpbp, st); + + if ( next == LONG_LAST_CLUSTER) /* last cluster found */ + goto done; + + /* Loop from start until either a FREE entry is */ + /* encountered (due to a fractured file system) of the */ + /* last cluster is encountered. */ + /* zap the FAT pointed to */ + + + if (fnp->f_highwater == 0) + { + fnp->f_dir.dir_start = FREE; + link_fat(dpbp, st, FREE); + } + else + { + link_fat(dpbp, st,LONG_LAST_CLUSTER); + } + + for ( st = next; st != LONG_LAST_CLUSTER; st = next) + { + /* get the next cluster pointed to */ + next = next_cluster(dpbp, st); + + /* just exit if a damaged file system exists */ + if (next == FREE) + return; + + /* zap the FAT pointed to */ + link_fat(dpbp, st, FREE); + + /* and the start of free space pointer */ + if ((dpbp->dpb_cluster == UNKNCLUSTER) + || (dpbp->dpb_cluster > st)) + dpbp->dpb_cluster = st; + + } + +done: + fnp->f_offset = lastoffset; /* has to be restored */ + + +#endif +} diff --git a/kernel/fattab.c b/kernel/fattab.c index 3e7d0cc2..095fc20f 100644 --- a/kernel/fattab.c +++ b/kernel/fattab.c @@ -35,6 +35,9 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.7 2001/07/09 22:19:33 bartoldeman + * LBA/FCB/FAT/SYS/Ctrl-C/ioctl fixes + memory savings + * * Revision 1.6 2001/06/03 14:16:17 bartoldeman * BUFFERS tuning and misc bug fixes/cleanups (2024c). * @@ -170,12 +173,38 @@ struct buffer FAR *getFATblock(UWORD cluster, struct dpb FAR *dpbp) UCOUNT link_fat(struct dpb FAR *dpbp, UCOUNT Cluster1, REG UCOUNT Cluster2) { + UCOUNT res; + if (ISFAT12(dpbp)) - return link_fat12(dpbp, Cluster1, Cluster2); + res = link_fat12(dpbp, Cluster1, Cluster2); else if (ISFAT16(dpbp)) - return link_fat16(dpbp, Cluster1, Cluster2); + res = link_fat16(dpbp, Cluster1, Cluster2); else return DE_BLKINVLD; + + + /* update the free space count */ + + if (res == SUCCESS) + if (dpbp->dpb_nfreeclst != UNKNCLSTFREE) + { + if (Cluster2 == FREE) + { + /* update the free space count for returned */ + /* cluster */ + ++dpbp->dpb_nfreeclst; + } + + /* update the free space count for removed */ + /* cluster */ + /* BUG: was counted twice for 2nd,.. cluster. moved to find_fat_free() */ + + /* else { + --dpbp->dpb_nfreeclst; + } + */ + } + return res; } UCOUNT link_fat16(struct dpb FAR *dpbp, UCOUNT Cluster1, UCOUNT Cluster2) @@ -199,21 +228,6 @@ UCOUNT link_fat16(struct dpb FAR *dpbp, UCOUNT Cluster1, UCOUNT Cluster2) bp->b_flag |= BFR_DIRTY | BFR_VALID; /* Return successful. */ - /* update the free space count */ - if (Cluster2 == FREE) - { - /* update the free space count for returned */ - /* cluster */ - if (dpbp->dpb_nfreeclst != UNKNCLSTFREE) - ++dpbp->dpb_nfreeclst; - } - else - { - /* update the free space count for removed */ - /* cluster */ - if (dpbp->dpb_nfreeclst != UNKNCLSTFREE) - --dpbp->dpb_nfreeclst; - } return SUCCESS; } @@ -266,22 +280,6 @@ UCOUNT link_fat12(struct dpb FAR *dpbp, UCOUNT Cluster1, UCOUNT Cluster2) *fbp1 = (*fbp1 & 0xf0) | ((Cluster2 >> 8) & 0x0f); } - /* update the free space count */ - if (Cluster2 == FREE) - { - /* update the free space count for returned */ - /* cluster */ - if (dpbp->dpb_nfreeclst != UNKNCLSTFREE) - ++dpbp->dpb_nfreeclst; - } - else - { - /* update the free space count for removed */ - /* cluster */ - if (dpbp->dpb_nfreeclst != UNKNCLSTFREE) - --dpbp->dpb_nfreeclst; - } - return SUCCESS; } @@ -330,6 +328,11 @@ UWORD next_cl16(struct dpb FAR *dpbp, UCOUNT ClusterNum) } +#if 0 + /* old version - correct, but a bit complicated coded. + it's also on one of the critical stack path's + */ + UWORD next_cl12(struct dpb FAR *dpbp, REG UCOUNT ClusterNum) { REG UBYTE FAR *fbp0, @@ -378,3 +381,70 @@ UWORD next_cl12(struct dpb FAR *dpbp, REG UCOUNT ClusterNum) ClusterNum = LONG_BAD; return ClusterNum; } +#else + /* new version - 50 byte smaller, saves 10 bytes on stack :-) + */ + +UWORD next_cl12(struct dpb FAR *dpbp, REG UCOUNT ClusterNum) +{ + union { + UBYTE bytes[2]; + UCOUNT word; + } clusterbuff; + + UCOUNT idx; + struct buffer FAR *bp; + + /* Get the block that this cluster is in */ + bp = getFATblock(ClusterNum , dpbp); + + if (bp == NULL) + return LONG_BAD; + + /* form an index so that we can read the block as a */ + /* byte array */ + idx = (((ClusterNum << 1) + ClusterNum) >> 1) % dpbp->dpb_secsize; + + clusterbuff.bytes[0] = bp->b_buffer[idx]; + + clusterbuff.bytes[1] = bp->b_buffer[idx+1]; /* next byte, will be overwritten, + if not valid */ + + /* Test to see if the cluster straddles the block. If it */ + /* does, get the next block and use both to form the */ + /* the FAT word. Otherwise, just point to the next */ + /* block. */ + if (idx >= dpbp->dpb_secsize - 1) + { + bp = getFATblock(ClusterNum +1, dpbp); + + if (bp == 0) + return LONG_BAD; + + clusterbuff.bytes[1] = bp->b_buffer[0]; + } + + /* Now to unpack the contents of the FAT entry. Odd and */ + /* even bytes are packed differently. */ + +#ifndef I86 /* the latter assumes byte ordering */ + if (ClusterNum & 0x01) + ClusterNum = ((clusterbuff.byte[0] & 0xf0) >> 4) | (clusterbuff.byte[1] << 4); + else + ClusterNum = clusterbuff.byte[0] | ((clusterbuff.byte[0] & 0x0f) << 8); +#else + + if (ClusterNum & 0x01) + ClusterNum = (unsigned short)clusterbuff.word >> 4; + else + ClusterNum = clusterbuff.word & 0x0fff; +#endif + + + if ((ClusterNum & MASK) == MASK) + ClusterNum = LONG_LAST_CLUSTER; + else if ((ClusterNum & BAD) == BAD) + ClusterNum = LONG_BAD; + return ClusterNum; +} +#endif diff --git a/kernel/fcbfns.c b/kernel/fcbfns.c index 6cd08c3c..be825e10 100644 --- a/kernel/fcbfns.c +++ b/kernel/fcbfns.c @@ -35,6 +35,9 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.12 2001/07/09 22:19:33 bartoldeman + * LBA/FCB/FAT/SYS/Ctrl-C/ioctl fixes + memory savings + * * Revision 1.11 2001/06/03 14:16:17 bartoldeman * BUFFERS tuning and misc bug fixes/cleanups (2024c). * @@ -160,6 +163,9 @@ VOID MoveDirInfo(); static dmatch Dmatch; +VOID FAR *FcbFindFirstDirPtr = NULL; + + VOID FatGetDrvData(UCOUNT drive, COUNT FAR * spc, COUNT FAR * bps, COUNT FAR * nc, BYTE FAR ** mdp) { @@ -221,7 +227,7 @@ VOID FatGetDrvData(UCOUNT drive, COUNT FAR * spc, COUNT FAR * bps, WORD FcbParseFname(int wTestMode, BYTE FAR ** lpFileName, fcb FAR * lpFcb) { COUNT nIndex; - WORD wRetCode = PARSE_RET_NOWILD; + WORD wRetCodeName,wRetCodeExt; /* pjv -- ExtFcbToFcb? */ /* Start out with some simple stuff first. Check if we are */ @@ -255,27 +261,24 @@ WORD FcbParseFname(int wTestMode, BYTE FAR ** lpFileName, fcb FAR * lpFcb) /* Now check for drive specification */ if (*(*lpFileName + 1) == ':') { - REG BYTE Drive = DosUpFChar(**lpFileName); - /* non-portable construct to be changed */ - if (Drive < 'A' || Drive > 'Z') - return PARSE_RET_BADDRIVE; - Drive -= ('A' - 1); + REG UBYTE Drive = DosUpFChar(**lpFileName) - 'A' + 1; + if (Drive >= lastdrive) return PARSE_RET_BADDRIVE; - else - lpFcb->fcb_drive = Drive; + + lpFcb->fcb_drive = Drive; *lpFileName += 2; } /* Now to format the file name into the string */ - *lpFileName = GetNameField(*lpFileName, (BYTE FAR *) lpFcb->fcb_fname, FNAME_SIZE, (BOOL *) & wRetCode); + *lpFileName = GetNameField(*lpFileName, (BYTE FAR *) lpFcb->fcb_fname, FNAME_SIZE, (BOOL *) & wRetCodeName); /* Do we have an extension? If do, format it else return */ if (**lpFileName == '.') - *lpFileName = GetNameField(++*lpFileName, (BYTE FAR *) lpFcb->fcb_fext, FEXT_SIZE, (BOOL *) & wRetCode); + *lpFileName = GetNameField(++*lpFileName, (BYTE FAR *) lpFcb->fcb_fext, FEXT_SIZE, (BOOL *) & wRetCodeExt); - return wRetCode ? PARSE_RET_WILD : PARSE_RET_NOWILD; + return (wRetCodeName|wRetCodeExt) ? PARSE_RET_WILD : PARSE_RET_NOWILD; } BYTE FAR *ParseSkipWh(BYTE FAR * lpFileName) @@ -668,7 +671,7 @@ BOOL FcbCreate(xfcb FAR * lpXfcb) return FALSE; } -static fcb FAR *ExtFcbToFcb(xfcb FAR * lpExtFcb) +STATIC fcb FAR *ExtFcbToFcb(xfcb FAR * lpExtFcb) { if (*((UBYTE FAR *) lpExtFcb) == 0xff) return &lpExtFcb->xfcb_fcb; @@ -676,7 +679,7 @@ static fcb FAR *ExtFcbToFcb(xfcb FAR * lpExtFcb) return (fcb FAR *) lpExtFcb; } -static fcb FAR *CommonFcbInit(xfcb FAR * lpExtFcb, BYTE * pszBuffer, +STATIC fcb FAR *CommonFcbInit(xfcb FAR * lpExtFcb, BYTE * pszBuffer, COUNT * pCurDrive) { fcb FAR *lpFcb; @@ -952,6 +955,12 @@ BOOL FcbRename(xfcb FAR * lpXfcb) } } +#if 0 +/* TE:the MoveDirInfo() is now done by simply copying the dirEntry into the FCB + this prevents problems with ".", ".." and saves code +*/ + + void MoveDirInfo(dmatch FAR * lpDmatch, struct dirent FAR * lpDir) { BYTE FAR *lpToName, @@ -998,6 +1007,7 @@ void MoveDirInfo(dmatch FAR * lpDmatch, struct dirent FAR * lpDir) lpDir->dir_start = lpDmatch->dm_cluster; lpDir->dir_size = lpDmatch->dm_size; } +#endif BOOL FcbClose(xfcb FAR * lpXfcb) { @@ -1068,17 +1078,22 @@ BOOL FcbFindFirst(xfcb FAR * lpXfcb) *lpDir++ = FcbDrive; + FcbFindFirstDirPtr = lpDir; if (dos_findfirst(wAttr, SecPathName) != SUCCESS) { + FcbFindFirstDirPtr = NULL; dta = lpPsp->ps_dta; return FALSE; } - MoveDirInfo((dmatch FAR *) & Dmatch, (struct dirent FAR *)lpDir); + FcbFindFirstDirPtr = NULL; - lpFcb->fcb_dirclst = Dmatch.dm_cluster; - lpFcb->fcb_diroff = Dmatch.dm_entry; +/* + MoveDirInfo((dmatch FAR *) & Dmatch, (struct dirent FAR *)lpDir); +*/ + lpFcb->fcb_dirclst = Dmatch.dm_dirstart; + lpFcb->fcb_strtclst = Dmatch.dm_entry; /* This is undocumented and seen using Pcwatch and Ramview. @@ -1126,19 +1141,26 @@ BOOL FcbFindNext(xfcb FAR * lpXfcb) DosUpFMem((BYTE FAR *) Dmatch.dm_name_pat, FNAME_SIZE + FEXT_SIZE); Dmatch.dm_attr_srch = wAttr; - Dmatch.dm_entry = lpFcb->fcb_diroff; + Dmatch.dm_entry = lpFcb->fcb_strtclst; Dmatch.dm_cluster = lpFcb->fcb_dirclst; + Dmatch.dm_dirstart= lpFcb->fcb_dirclst; + + FcbFindFirstDirPtr = lpDir; if (dos_findnext() != SUCCESS) { + FcbFindFirstDirPtr = NULL; dta = lpPsp->ps_dta; CritErrCode = 0x12; return FALSE; } + FcbFindFirstDirPtr = NULL; +/* MoveDirInfo((dmatch FAR *) & Dmatch, (struct dirent FAR *)lpDir); - lpFcb->fcb_dirclst = Dmatch.dm_cluster; - lpFcb->fcb_diroff = Dmatch.dm_entry; +*/ + lpFcb->fcb_dirclst = Dmatch.dm_dirstart; + lpFcb->fcb_strtclst = Dmatch.dm_entry; lpFcb->fcb_sftno = Dmatch.dm_drive; #if 0 diff --git a/kernel/globals.h b/kernel/globals.h index 856dc115..0f18cb79 100644 --- a/kernel/globals.h +++ b/kernel/globals.h @@ -36,6 +36,9 @@ static BYTE *Globals_hRcsId = "$Id$"; /* * $Log$ + * Revision 1.14 2001/07/09 22:19:33 bartoldeman + * LBA/FCB/FAT/SYS/Ctrl-C/ioctl fixes + memory savings + * * Revision 1.13 2001/06/03 14:16:17 bartoldeman * BUFFERS tuning and misc bug fixes/cleanups (2024c). * @@ -270,6 +273,10 @@ static BYTE *Globals_hRcsId = "$Id$"; /* Blockio constants */ #define DSKWRITE 1 /* dskxfr function parameters */ #define DSKREAD 2 +#define DSKWRITEINT26 3 +#define DSKREADINT25 4 + + /* FAT cluster special flags */ #define FREE 0x000 diff --git a/kernel/init-mod.h b/kernel/init-mod.h index 67a48e39..c28bba95 100644 --- a/kernel/init-mod.h +++ b/kernel/init-mod.h @@ -133,6 +133,9 @@ INIT BYTE FAR *KernelAlloc(WORD nBytes); INIT COUNT Umb_Test(void); INIT BYTE *GetStringArg(BYTE * pLine, BYTE * pszString); +/* diskinit.c */ +COUNT dsk_init(VOID); + /* int2f.asm */ COUNT Umb_Test(void); @@ -189,3 +192,8 @@ INIT VOID init_fatal(BYTE * err_msg); /* prf.c */ WORD init_printf(CONST BYTE * fmt,...); + +void MoveKernel(unsigned NewKernelSegment); +extern WORD HMAFree; /* first byte in HMA not yet used */ + +extern unsigned CurrentKernelSegment; diff --git a/kernel/initdisk.c b/kernel/initdisk.c new file mode 100644 index 00000000..360e1fb8 --- /dev/null +++ b/kernel/initdisk.c @@ -0,0 +1,985 @@ +/****************************************************************/ +/* */ +/* initDISK.c */ +/* */ +/* Copyright (c) 2001 */ +/* tom ehlert */ +/* All Rights Reserved */ +/* */ +/* This file is part of DOS-C. */ +/* */ +/* DOS-C is free software; you can redistribute it and/or */ +/* modify it under the terms of the GNU General Public License */ +/* as published by the Free Software Foundation; either version */ +/* 2, or (at your option) any later version. */ +/* */ +/* DOS-C is distributed in the hope that it will be useful, but */ +/* WITHOUT ANY WARRANTY; without even the implied warranty of */ +/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See */ +/* the GNU General Public License for more details. */ +/* */ +/* You should have received a copy of the GNU General Public */ +/* License along with DOS-C; see the file COPYING. If not, */ +/* write to the Free Software Foundation, 675 Mass Ave, */ +/* Cambridge, MA 02139, USA. */ +/****************************************************************/ + +#include "portab.h" +#include "init-mod.h" +#include "disk.h" +#include "dyndata.h" +#ifdef VERSION_STRINGS +static BYTE *dskRcsId = "$Id$"; +#endif + +/* + data shared between DSK.C and INITDISK.C +*/ +extern struct media_info * FAR miarrayptr; /* Internal media info structs */ + +extern UBYTE FAR DiskTransferBuffer[1 * SEC_SIZE]; + +extern COUNT FAR nUnits; + +extern UWORD FAR LBA_WRITE_VERIFY; + +/* + * Rev 1.0 13 May 2001 tom ehlert + * Initial revision. + * + * this module implements the disk scanning for DOS accesible partitions + * the drive letter ordering is somewhat chaotic, but like MSDOS does it. + * + * this module expects to run with CS = INIT_TEXT, like other init_code, + * but SS = DS = DATA = DOS_DS, unlike other init_code. + * + * history: + * 1.0 extracted the disk init code from DSK.C + * added LBA support + * moved code to INIT_TEXT + * done the funny code segment stuff to switch between INIT_TEXT and TEXT + * added a couple of snity checks for partitions + * + **************************************************************************** + * + * Implementation note: + * this module needs some interfacing to INT 13 + * how to implement them + * + * a) using inline assembly + * _ASM mov ax,0x1314 + * + * b) using assembly routines in some external FLOPPY.ASM + * + * c) using the funny TURBO-C style + * _AX = 0x1314 + * + * d) using intr(intno, ®s) method. + * + * whynot's + * + * a) this is my personal favorite, combining the best aof all worlds. + * TURBO-C does support inline assembly, but only by using TASM, + * which is not free. + * so - unfortunately- its excluded. + * + * b) keeping funny memory model in sync with external assembly + * routines is everything, but not fun + * + * c) you never know EXACT, what the compiler does, if its a bit + * more complicated. does + * _DL = drive & 0xff + * _BL = driveParam.chs.Sector; + * destroy any other register? sure? _really_ sure? + * at least, it has it's surprises. + * and - I found a couple of optimizer induced bugs (TC 2.01) + * believe me. + * it was coded - and operational that way. + * but - there are many surprises waiting there. so I opted against. + * + * + * d) this method is somewhat clumsy and certainly not the + * fastest way to do things. + * on the other hand, this is INIT code, executed once. + * and scince it's the only portable method, I opted for it. + * + * e) and all this is my private opinion. tom ehlert. + * + */ + + +/*#define DEBUG*/ + +#define _BETA_ /* messages for initial phase only */ + + +#if defined(DEBUG) + #define DebugPrintf(x) printf x +#else + #define DebugPrintf(x) +#endif + +#if defined(_BETA_) + #define BetaPrintf(x) printf x +#else + #define BetaPrintf(x) +#endif + + +#define LBA_to_CHS init_LBA_to_CHS + +/* + internal global data +*/ + +UBYTE GlobalEnableLBAsupport = 1; /* = 0 --> disable LBA support */ + +struct DriveParamS InitDriveParam[MAX_HARD_DRIVE]; + +/* + translate LBA sectors into CHS addressing + copied and pasted from dsk.c! +*/ + +void init_LBA_to_CHS(struct CHS *chs, ULONG LBA_address, struct DriveParamS *driveparam) +{ + chs->Sector = LBA_address% driveparam->chs.Sector + 1; + + LBA_address /= driveparam->chs.Sector; + + chs->Head = LBA_address % driveparam->chs.Head; + chs->Cylinder = LBA_address / driveparam->chs.Head; +} + +void printCHS(char *title,struct CHS *chs) +{ + printf("%s",title); + printf("%4lu-%u-%u",chs->Cylinder, chs->Head, chs->Sector); +} + +/* + reason for this modules existence: + + we have found a partition, and add them to the global + partition structure. + +*/ +void DosDefinePartition(struct DriveParamS *driveParam, + ULONG StartSector, ULONG NumSectors) +{ + extern struct DynS FAR Dyn; + struct media_info FAR *pmiarray = &((struct media_info FAR *)&Dyn.Buffer[0])[nUnits]; + struct CHS chs; + + if ( nUnits >= NDEV) + { + printf("more Partitions detected then possible, max = %d\n", NDEV); + return; /* we are done */ + } + + + fmemcpy((BYTE FAR*)&pmiarray->drive, (BYTE FAR*)driveParam, sizeof(struct DriveParamS)); + + if (pmiarray->drive.LBA_supported) + DebugPrintf(("LBA enabled for drive %c:\n", 'A'+nUnits)); + + pmiarray->mi_offset = StartSector; + pmiarray->mi_size = NumSectors; + +#ifdef _BETA_ /* Alain whishes to keep this in later versions, too */ + LBA_to_CHS(&chs,StartSector,driveParam); + + printf("%c: disk %02x", + 'A' + nUnits, + driveParam->driveno); + + printCHS(" CHS= ",&chs); + + printf(" start = %5luMB,size =%5lu", + StartSector/2048,NumSectors/2048); + + printf("\n"); +#endif + + + nUnits++; +} + + + +void __int__(int); + + +/* + interesting macros - used internally only +*/ + +#define SCAN_PRIMARYBOOT 0x00 +#define SCAN_PRIMARY 0x01 +#define SCAN_EXTENDED 0x02 +#define SCAN_PRIMARY2 0x03 + + +#define FAT12 0x01 +#define FAT16SMALL 0x04 +#define EXTENDED 0x05 +#define FAT16LARGE 0x06 +#define FAT32 0x0b /* FAT32 partition that ends before the 8.4 */ + /* GB boundary */ +#define FAT32_LBA 0x0c /* FAT32 partition that ends after the 8.4GB */ + /* boundary. LBA is needed to access this. */ +#define FAT16_LBA 0x0e /* like 0x06, but it is supposed to end past */ + /* the 8.4GB boundary */ +#define EXTENDED_LBA 0x0f /* like 0x05, but it is supposed to end past */ + +#define IsExtPartition(parttyp) ((parttyp) == EXTENDED || \ + (parttyp) == EXTENDED_LBA ) + +#define IsFAT16Partition(parttyp) ((parttyp) == FAT12 || \ + (parttyp) == FAT16SMALL || \ + (parttyp) == FAT16LARGE || \ + (parttyp) == FAT16_LBA ) + + + +/* local - returned and used for BIOS interface INT 13, AH=48*/ +struct _bios_LBA_disk_parameterS { + UWORD size; + UWORD information; + ULONG cylinders; + ULONG heads; + ULONG sectors; + + ULONG totalSect; + ULONG totalSectHigh; + UWORD BytesPerSector; + + ULONG eddparameters; + } ; + + +/* Get the parameters of the hard disk */ +int LBA_Get_Drive_Parameters(int drive,struct DriveParamS *driveParam) +{ + iregs regs; + + struct _bios_LBA_disk_parameterS lba_bios_parameters; + + if (driveParam->driveno) + return driveParam->driveno; + + driveParam->LBA_supported = FALSE; + + + drive |= 0x80; + + /* for tests - disable LBA support, + even if exists */ + if (!GlobalEnableLBAsupport) + { + goto StandardBios; + } + /* check for LBA support */ + regs.b.x = 0x55aa; + regs.a.b.h = 0x41; + regs.d.b.l = drive; + + init_call_intr(0x13,®s); + + + if (regs.b.x != 0xaa55 || (regs.flags & 0x01) ) + { + goto StandardBios; + } + + /* by ralph : + if DAP cannot be used, don't use + LBA + */ + if ((regs.c.x & 1) == 0) + { + goto StandardBios; + } + + + + /* drive supports LBA addressing */ + + /* version 1.0, 2.0 have different verify */ + if (regs.a.x < 0x2100) + LBA_WRITE_VERIFY = 0x4301; + + + lba_bios_parameters.size = sizeof(lba_bios_parameters); + + + regs.si = FP_OFF(&lba_bios_parameters); + regs.ds = FP_SEG(&lba_bios_parameters); + regs.a.b.h = 0x48; + regs.d.b.l = drive; + init_call_intr(0x13,®s); + + + if (regs.flags & 0x01) + { + goto StandardBios; + } + + /* verify maximum settings, we can't handle more */ + + if (lba_bios_parameters.heads > 0xffff || + lba_bios_parameters.sectors > 0xffff || + lba_bios_parameters.totalSectHigh != 0 ) + { + printf("Drive is too large to handle, using only 1'st 8 GB\n" + " drive %02x heads %lu sectors %lu , total=0x%lx-%08lx\n", + drive, + (ULONG)lba_bios_parameters.heads, + (ULONG)lba_bios_parameters.sectors, + (ULONG)lba_bios_parameters.sectors, + (ULONG)lba_bios_parameters.totalSectHigh); + + goto StandardBios; + } + + if (lba_bios_parameters.information & 8) + { + driveParam->WriteVerifySupported = 1; + } + else + driveParam->WriteVerifySupported = 0; + + driveParam->total_sectors = lba_bios_parameters.totalSect; + + /* if we arrive here, success */ + driveParam->LBA_supported = TRUE; + + + + +StandardBios: /* old way to get parameters */ + + regs.a.b.h = 0x08; + regs.d.b.l = drive; + + init_call_intr(0x13,®s); + + + if (regs.flags & 0x01) + goto ErrorReturn; + + + driveParam->chs.Head = (regs.d.x >> 8) + 1; + driveParam->chs.Sector = (regs.c.x & 0x3f); + driveParam->chs.Cylinder = (regs.c.x >> 8) | ((regs.c.x & 0xc0) << 2); + + + if (!driveParam->LBA_supported) + { + driveParam->total_sectors = + min(driveParam->chs.Cylinder,1023) + * driveParam->chs.Head + * driveParam->chs.Sector; + } + + driveParam->driveno = drive; + + DebugPrintf(("drive parameters %02x - %04lu-%u-%u", + drive,driveParam->chs.Cylinder, + drive,driveParam->chs.Head, + drive,driveParam->chs.Sector)); + DebugPrintf((" total size %luMB\n\n",driveParam->total_sectors/2048)); + + + +ErrorReturn: + + return driveParam->driveno; +} + + + + +struct PartTableEntry /* INTERNAL representation of partition table entry */ + { + UBYTE Bootable; + UBYTE FileSystem; + struct CHS Begin; + struct CHS End; + ULONG RelSect; + ULONG NumSect; + }; + +/* + converts physical into logical representation of partition entry +*/ + +ConvPartTableEntryToIntern(struct PartTableEntry *pEntry, UBYTE FAR * pDisk) +{ + int i; + + if (pDisk[0x1fe] != 0x55 || pDisk[0x1ff] != 0xaa) + { + memset(pEntry,0, 4 * sizeof(struct PartTableEntry)); + + return FALSE; + } + + pDisk += 0x1be; + + for (i = 0; i < 4; i++,pDisk += 16,pEntry++) + { + + pEntry->Bootable = *(UBYTE FAR*)(pDisk+0); + pEntry->FileSystem = *(UBYTE FAR*)(pDisk+4); + + pEntry->Begin.Head = *(UBYTE FAR*)(pDisk+1); + pEntry->Begin.Sector = *(UBYTE FAR*)(pDisk+2) & 0x3f; + pEntry->Begin.Cylinder = *(UBYTE FAR*)(pDisk+3) + + ((UWORD) (0xc0 & *(UBYTE FAR*)(pDisk+2)) << 2); + + pEntry->End.Head = *(UBYTE FAR*)(pDisk+5); + pEntry->End.Sector = *(UBYTE FAR*)(pDisk+6) & 0x3f; + pEntry->End.Cylinder = *(UBYTE FAR*)(pDisk+7) + + ((UWORD) (0xc0 & *(UBYTE FAR*)(pDisk+6)) << 2); + + + pEntry->RelSect = *(ULONG FAR*)(pDisk+8); + pEntry->NumSect = *(ULONG FAR*)(pDisk+12); + } + return TRUE; +} + +ScanForPrimaryPartitions(struct DriveParamS *driveParam,int scan_type, + struct PartTableEntry *pEntry, ULONG startSector, + int partitionsToIgnore + ) +{ + int i; + struct CHS chs,end; + ULONG partitionStart; + + for (i = 0; i < 4; i++,pEntry++) + { + if (pEntry->FileSystem == 0) + continue; + + if (partitionsToIgnore & (1 << i)) + continue; + + + if (IsExtPartition(pEntry->FileSystem)) + continue; + + if (scan_type == SCAN_PRIMARYBOOT && !pEntry->Bootable) + continue; + + + partitionStart = startSector + pEntry->RelSect; + + if (!IsFAT16Partition(pEntry->FileSystem)) + { + continue; + } + + /* + some sanity checks, that partition + structure is OK + */ + LBA_to_CHS(&chs, partitionStart,driveParam); + LBA_to_CHS(&end, partitionStart+pEntry->NumSect-1,driveParam); + + + /* some FDISK's enter for partitions + > 8 GB cyl = 1023, other (cyl&1023) + */ + + if ( ((chs.Cylinder & 0x3ff) != pEntry->Begin.Cylinder && + 1023 != pEntry->Begin.Cylinder ) || + chs.Head != pEntry->Begin.Head || + chs.Sector != pEntry->Begin.Sector ) + { + printf("NOT using suspect partition %u FS %02x:", + i, pEntry->FileSystem); + printCHS(" start calc ",&chs); + printCHS(" != ",&pEntry->Begin); + printf("\n"); + + continue; + } + + + if (((end.Cylinder & 0x3ff) != pEntry->End.Cylinder && + 1023 != pEntry->End.Cylinder ) || + end.Head != pEntry->End.Head || + end.Sector != pEntry->End.Sector ) + { + printf("NOT using suspect partition %u FS %02x:", + i, pEntry->FileSystem); + + printCHS(" end calc ",&end); + printCHS(" != ",&pEntry->End); + printf("\n"); + + continue; + } + + + if (chs.Cylinder > 1023 || end.Cylinder > 1023) + { + + if (!driveParam->LBA_supported) + { + printf("can't use LBA partition without LBA support - part %u FS %02x", + i, pEntry->FileSystem); + + printCHS(" start ",&chs); + printCHS(", end ", &end); + printf("\n"); + + continue; + } + + /* else its a diagnostic message only */ +#ifdef _BETA_ + printf("found and using LBA partition %u FS %02x", + i, pEntry->FileSystem); + printCHS(" start ",&chs); + printCHS(", end ", &end); + printf("\n"); +#endif + } + + + /* + here we have a partition table in our hand !! + */ + + partitionsToIgnore |= 1 << i; + + DosDefinePartition(driveParam,partitionStart, pEntry->NumSect); + + if (scan_type == SCAN_PRIMARYBOOT || + scan_type == SCAN_PRIMARY ) + { + return partitionsToIgnore; + } + } + + return partitionsToIgnore; +} + +void BIOS_drive_reset(unsigned drive); + +int Read1LBASector(struct DriveParamS *driveParam, unsigned drive, ULONG LBA_address, void FAR *buffer) +{ + static struct _bios_LBA_address_packet dap = { + 16,0,0,0,0,0,0 + }; + + struct CHS chs; + iregs regs; + int num_retries; + + if (LBA_address >= driveParam->total_sectors) + { + printf("LBA-Transfer error : address overflow = %lu > %lu max\n",LBA_address+1,driveParam->total_sectors); + return 1; + } + + + for ( num_retries = 0; num_retries < N_RETRY; num_retries++) + { + regs.d.b.l = drive | 0x80; + if (driveParam->LBA_supported) + { + dap.number_of_blocks = 1; + dap.buffer_address = buffer; + dap.block_address_high = 0; /* clear high part */ + dap.block_address = LBA_address; /* clear high part */ + + /* Load the registers and call the interrupt. */ + regs.a.b.h = 0x42; + regs.si = FP_OFF(&dap); + regs.ds = FP_SEG(&dap); + } + else + { /* transfer data, using old bios functions */ + init_LBA_to_CHS(&chs, LBA_address, driveParam); + /* avoid overflow at end of track */ + + if (chs.Cylinder > 1023) + { + printf("LBA-Transfer error : cylinder %u > 1023\n", chs.Cylinder); + return 1; + } + + regs.a.x = 0x0201; + regs.b.x = FP_OFF(buffer); + regs.c.x = ((chs.Cylinder&0xff) << 8) + ((chs.Cylinder&0x300) >> 2) + chs.Sector; + regs.d.b.h = chs.Head; + regs.es = FP_SEG(buffer); + } /* end of retries */ + init_call_intr(0x13, ®s); + if ((regs.flags & FLG_CARRY) == 0) break; + BIOS_drive_reset(driveParam->driveno); + } + + return regs.flags & FLG_CARRY ? 1 : 0; +} + +/* Load the Partition Tables and get information on all drives */ +int ProcessDisk(int scanType, unsigned drive, int PartitionsToIgnore) +{ + + struct PartTableEntry PTable[4]; + ULONG RelSectorOffset; + ULONG ExtendedPartitionOffset; + int iPart; + int strangeHardwareLoop; + + int num_extended_found = 0; + + struct DriveParamS *driveParam = &InitDriveParam[drive&0x7f]; + + /* Get the hard drive parameters and ensure that the drive exists. */ + /* If there was an error accessing the drive, skip that drive. */ + + if (!LBA_Get_Drive_Parameters(drive,driveParam)) + { + printf("can't get drive parameters for drive %02x\n",drive); + return PartitionsToIgnore; + } + + RelSectorOffset = 0; /* boot sector */ + ExtendedPartitionOffset = 0; /* not found yet */ + + + + /* Read the Primary Partition Table. */ + + +ReadNextPartitionTable: + + strangeHardwareLoop = 0; +strange_restart: + + + if (Read1LBASector(driveParam, drive, RelSectorOffset, DiskTransferBuffer)) + { + printf("Error reading partition table drive %02x sector %lu",drive,RelSectorOffset); + return PartitionsToIgnore; + } + + if (!ConvPartTableEntryToIntern(PTable, DiskTransferBuffer)) + { + /* there is some strange hardware out in the world, + which returns OK on first read, but the data are + rubbish. simply retrying works fine. + there is no logic behind this, but it works TE */ + + if (++strangeHardwareLoop < 3) + goto strange_restart; + + printf("illegal partition table - drive %02x sector %lu\n",drive,RelSectorOffset); + return PartitionsToIgnore; + } + + if ( scanType==SCAN_PRIMARYBOOT || + scanType==SCAN_PRIMARY || + scanType==SCAN_PRIMARY2 || + num_extended_found !=0 ) + { + + PartitionsToIgnore = ScanForPrimaryPartitions(driveParam,scanType, + PTable, RelSectorOffset,PartitionsToIgnore); + } + + if (scanType != SCAN_EXTENDED) + { + return PartitionsToIgnore; + } + + /* scan for extended partitions now */ + PartitionsToIgnore = 0; + + + for (iPart=0; iPart < 4; iPart++) + { + if (IsExtPartition(PTable[iPart].FileSystem)) + { + RelSectorOffset = ExtendedPartitionOffset + PTable[iPart].RelSect; + + if (ExtendedPartitionOffset == 0) + { + ExtendedPartitionOffset = PTable[iPart].RelSect; + } + + num_extended_found++; + + if (num_extended_found > 30) + { + printf("found more then 30 extended partitions, terminated\n"); + return 0; + } + + goto ReadNextPartitionTable; + } + } + + return PartitionsToIgnore; +} + + +BIOS_nrdrives(void) +{ + iregs regs; + + regs.a.b.h = 0x08; + regs.d.b.l = 0x80; + init_call_intr(0x13,®s); + + if (regs.flags & 1) + { + printf("no hard disks detected\n"); + return 0; + } + + return regs.d.b.l; +} + +void BIOS_drive_reset(unsigned drive) +{ + iregs regs; + + regs.d.b.l = drive | 0x80; + regs.a.b.h = 0; + + init_call_intr(0x13,®s); +} + +/* + thats what MSDN says: + + How Windows 2000 Assigns, Reserves, and Stores Drive Letters + ID: q234048 + + BASIC Disk - Drive Letter Assignment Rules +The following are the basic disk drive letter assignment rules for Windows 2000: +Scan all fixed hard disks as they are enumerated, assign drive letters +starting with any active primary partitions (if there is one), otherwise, +scan the first primary partition on each drive. Assign next available +letter starting with C: + + +Repeat scan for all fixed hard disks and removable (JAZ, MO) disks +and assign drive letters to all logical drives in an extended partition, +or the removable disk(s) as enumerated. Assign next available letter +starting with C: + + +Finally, repeat scan for all fixed hard disk drives, and assign drive +letters to all remaining primary partitions. Assign next available letter +starting with C: + +Floppy drives. Assign letter starting with A: + +CD-ROM drives. Assign next available letter starting with D: + +************************************************************************* +Order in Which MS-DOS and Windows Assign Drive Letters +ID: q51978 + +MORE INFORMATION +The following occurs at startup: + +MS-DOS checks all installed disk devices, assigning the drive letter A +to the first physical floppy disk drive that is found. + +If a second physical floppy disk drive is present, it is assigned drive letter B. If it is not present, a logical drive B is created that uses the first physical floppy disk drive. + + +Regardless of whether a second floppy disk drive is present, +MS-DOS then assigns the drive letter C to the primary MS-DOS +partition on the first physical hard disk, and then goes on +to check for a second hard disk. + + +If a second physical hard disk is found, and a primary partition exists +on the second physical drive, the primary MS-DOS partition on the second +physical hard drive is assigned the letter D. MS-DOS version 5.0, which +supports up to eight physical drives, will continue to search for more +physical hard disk drives at this point. For example, if a third physical +hard disk is found, and a primary partition exists on the third physical +drive, the primary MS-DOS partition on the third physical hard drive is +assigned the letter E. + + +MS-DOS returns to the first physical hard disk drive and assigns drive +letters to any additional logical drives (in extended MS-DOS partitions) +on that drive in sequence. + + +MS-DOS repeats this process for the second physical hard disk drive, +if present. MS-DOS 5.0 will repeat this process for up to eight physical +hard drives, if present. After all logical drives (in extended MS-DOS +partitions) have been assigned drive letters, MS-DOS 5.0 returns to +the first physical drive and assigns drive letters to any other primary +MS-DOS partitions that exist, then searches other physical drives for +additional primary MS-DOS partitions. This support for multiple primary +MS-DOS partitions was added to version 5.0 for backward compatibility +with the previous OEM MS-DOS versions that support multiple primary partitions. + + +After all logical drives on the hard disk(s) have been assigned drive +letters, drive letters are assigned to drives installed using DRIVER.SYS +or created using RAMDRIVE.SYS in the order in which the drivers are loaded +in the CONFIG.SYS file. Which drive letters are assigned to which devices +can be influenced by changing the order of the device drivers or, if necessary, +by creating "dummy" drive letters with DRIVER.SYS. + +******************************************************** + +or + + as rather well documented, DOS searches 1st) 1 primary patitions on + all drives, 2nd) all extended partitions. that + makes many people (including me) unhappy, as all DRIVES D:,E:... + on 1st disk will move up/down, if other disk with + primary partitions are added/removed, but + thats the way it is (hope I got it right) + TE (with a little help from my friends) + see also above for WIN2000,DOS,MSDN + +I don't know, if I did it right, but I tried to do it that way. TE + +***********************************************************************/ + + + +void ReadAllPartitionTables(void) +{ + UBYTE foundPartitions[MAX_HARD_DRIVE]; + + int HardDrive; + int nHardDisk = BIOS_nrdrives(); + struct media_info FAR *pmiarray; + int Unit; + + extern struct DynS FAR Dyn; +/* struct media_info *miarrayptr; /* Internal media info structs */ + + __int__(0x03); + + + miarrayptr = (struct media_info *)&Dyn.Buffer[0]; + + for (Unit = 0; Unit < NDEV; Unit++) + { + pmiarray = &((struct media_info FAR *)&Dyn.Buffer[0])[Unit]; + + pmiarray->drive.driveno = Unit; + pmiarray->drive.total_sectors = 1440*2; + pmiarray->drive.chs.Head = 2; + pmiarray->drive.chs.Cylinder = 40; + pmiarray->drive.chs.Sector = 9; + pmiarray->drive.LBA_supported = FALSE; + + pmiarray->mi_size = 1440*2; + pmiarray->mi_offset = 0l; + + + pmiarray->fs.serialno = 0x12345678l; + } + + + + nHardDisk = min(nHardDisk,MAX_HARD_DRIVE-1); + + memset(foundPartitions,0,sizeof(foundPartitions)); + + + + + DebugPrintf(("DSK init: found %d disk drives\n",nHardDisk)); + + /* Reset the drives */ + for (HardDrive = 0; HardDrive < nHardDisk; HardDrive++) + BIOS_drive_reset(HardDrive); + + + /* Process primary partition table 1 partition only */ + for (HardDrive = 0; HardDrive < nHardDisk; HardDrive++) + { + foundPartitions[HardDrive] = + ProcessDisk(SCAN_PRIMARYBOOT, HardDrive, 0); + + if (foundPartitions[HardDrive] == 0) + foundPartitions[HardDrive] = ProcessDisk(SCAN_PRIMARY, HardDrive, 0); + } + + /* Process extended partition table */ + for (HardDrive = 0; HardDrive < nHardDisk; HardDrive++) + { + ProcessDisk(SCAN_EXTENDED, HardDrive , 0); + } + + /* Process primary a 2nd time */ + for (HardDrive = 0; HardDrive < nHardDisk; HardDrive++) + { + ProcessDisk(SCAN_PRIMARY2, HardDrive ,foundPartitions[HardDrive]); + } + + + Dyn.UsedByDiskInit = nUnits * sizeof(struct media_info); + +} + +/*TE - array access functions */ +extern bpb FAR bpbarray[NDEV]; +bpb FAR *init_getPBpbarray(unsigned dev){ return &bpbarray[dev];} + +/* disk initialization: returns number of units */ +COUNT dsk_init() +{ + COUNT Unit; + bpb FAR *pbpbarray; + + printf(" - InitDisk\n"); + +#ifdef DEBUG + { + iregs regs; + regs.a.x = 0x1112; /* select 43 line mode - more space for partinfo */ + regs.b.x = 0; + init_call_intr(0x10, ®s); + } +#endif + + /* Reset the drives */ + BIOS_drive_reset(0); + + /* Initial number of disk units */ + nUnits = 2; + + + /* Setup media info and BPBs arrays */ + for (Unit = 0; Unit < NDEV; Unit++) + { + pbpbarray = init_getPBpbarray(Unit); + + pbpbarray->bpb_nbyte = SEC_SIZE; + pbpbarray->bpb_nsector = 2; + pbpbarray->bpb_nreserved = 1; + pbpbarray->bpb_nfat = 2; + pbpbarray->bpb_ndirent = 112; + pbpbarray->bpb_nsize = 720l; + pbpbarray->bpb_mdesc = 0xfd; + pbpbarray->bpb_nfsect = 2; + + } + + ReadAllPartitionTables(); + + return nUnits; +} diff --git a/kernel/inithma.c b/kernel/inithma.c index 30fd2424..71be97e2 100644 --- a/kernel/inithma.c +++ b/kernel/inithma.c @@ -67,6 +67,7 @@ #include "portab.h" #include "init-mod.h" + extern BYTE FAR version_flags; /* minor version number */ extern BYTE @@ -80,6 +81,9 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.7 2001/07/09 22:19:33 bartoldeman + * LBA/FCB/FAT/SYS/Ctrl-C/ioctl fixes + memory savings + * * Revision 1.6 2001/04/29 17:34:40 bartoldeman * A new SYS.COM/config.sys single stepping/console output/misc fixes. * @@ -128,6 +132,8 @@ extern void FAR *DetectXMSDriver(VOID); #define HMAInitPrintf(x) #endif +void MoveKernel(unsigned NewKernelSegment); + #ifdef DEBUG VOID hdump(BYTE FAR *p) @@ -249,10 +255,6 @@ int EnableHMA(VOID) int MoveKernelToHMA() { - UBYTE FAR *HMASource; - unsigned len; - - if (DosLoadedInHMA) { @@ -297,137 +299,8 @@ int MoveKernelToHMA() return FALSE; } + MoveKernel(0xffff); - /* C) we have HMA, copy HMA_TEXT up to 0xffff:0..ffff */ - - { - - UBYTE FAR *HMADest = MK_FP(HMASEGMENT,0x0000); - - len = FP_OFF(_HMATextEnd) - FP_OFF(_HMATextStart); - - HMASource = (UBYTE FAR *)_HMATextStart; - - - len += FP_OFF(HMASource) & 0x000f; - - FP_OFF(HMASource) &= 0xfff0; - - HMASource += HMAOFFSET; - HMADest += HMAOFFSET; - len -= HMAOFFSET; - - - HMAInitPrintf(("HMA moving %p up to %p for %04x bytes\n", - HMASource, HMADest, len)); - - fmemcpy(HMADest, HMASource, len); - - HMAFree = FP_OFF(HMADest)+len; /* first free byte after HMA_TEXT */ - - - } - { - /* D) but it only makes sense, if we can relocate - all our entries to make use of HMA - */ - - /* this is for a - call near enableA20 - jmp far kernelentry - style table - */ - - struct RelocationTable { - UBYTE jmpFar; - UWORD jmpOffset; - UWORD jmpSegment; - UBYTE callNear; - UWORD callOffset; - }; - struct RelocatedEntry { - UBYTE callNear; - UWORD callOffset; - UBYTE jmpFar; - UWORD jmpOffset; - UWORD jmpSegment; - }; - extern struct RelocationTable - FAR _HMARelocationTableStart[], - FAR _HMARelocationTableEnd[]; - - struct RelocationTable FAR *rp, rtemp ; - - UWORD HMATextSegment = FP_SEG( _HMATextStart ); - - /* verify, that all entries are valid */ - - for (rp = _HMARelocationTableStart; rp < _HMARelocationTableEnd; rp++) - { - if (rp->jmpFar != 0xea || /* jmp FAR */ - rp->jmpSegment != HMATextSegment || /* will only relocate HMA_TEXT */ - rp->callNear != 0xe8 || /* call NEAR */ - 0) - { - printf("illegal relocation entry # %d\n",rp - _HMARelocationTableStart); - goto errorReturn; - } - } - - /* OK, all valid, go to relocate*/ - - for (rp = _HMARelocationTableStart; rp < _HMARelocationTableEnd; rp++) - { - struct RelocatedEntry FAR *rel = (struct RelocatedEntry FAR *)rp; - - fmemcpy(&rtemp, rp, sizeof(rtemp)); - - rel->jmpFar = rtemp.jmpFar; - rel->jmpSegment = HMASEGMENT; - rel->jmpOffset = rtemp.jmpOffset; - rel->callNear = rtemp.callNear; - rel->callOffset = rtemp.callOffset+5; /* near calls are relative */ - } - } - { - struct initRelocationTable { - UBYTE callNear; - UWORD callOffset; - UBYTE jmpFar; - UWORD jmpOffset; - UWORD jmpSegment; - }; - extern struct initRelocationTable - _HMAinitRelocationTableStart[], - _HMAinitRelocationTableEnd[]; - struct initRelocationTable *rp; - - /* verify, that all entries are valid */ - - UWORD HMATextSegment = FP_SEG( _HMATextStart ); - - for (rp = _HMAinitRelocationTableStart; rp < _HMAinitRelocationTableEnd; rp++) - { - if ( - rp->callNear != 0xe8 || /* call NEAR */ - rp->jmpFar != 0xea || /* jmp FAR */ - rp->jmpSegment != HMATextSegment || /* will only relocate HMA_TEXT */ - 0) - { - printf("illegal init relocation entry # %d\n", - rp - _HMAinitRelocationTableStart); - goto errorReturn; - } - } - - /* OK, all valid, go to relocate*/ - - for (rp = _HMAinitRelocationTableStart; rp < _HMAinitRelocationTableEnd; rp++) - { - rp->jmpSegment = HMASEGMENT; - rp->callOffset = rp->callOffset-5; /* near calls are relative */ - } - } { /* E) up to now, nothing really bad was done. @@ -437,8 +310,6 @@ int MoveKernelToHMA() cause INT 3 on all accesses to this area */ - fmemset(HMASource, 0xcc, len); - HMAInitPrintf(("HMA text segment filled with INT 3\n")); DosLoadedInHMA = TRUE; } @@ -575,3 +446,163 @@ VOID FAR *HMAalloc(COUNT bytesToAllocate) return HMAptr; } + + +unsigned CurrentKernelSegment = 0; + +void MoveKernel(unsigned NewKernelSegment) +{ + UBYTE FAR *HMADest; + UBYTE FAR *HMASource; + unsigned len; + + __int__(3); + if (CurrentKernelSegment == 0) + CurrentKernelSegment = FP_SEG(_HMATextEnd); + + if (CurrentKernelSegment == 0xffff) + return; + + + HMASource = MK_FP(CurrentKernelSegment,(FP_OFF(_HMATextStart) & 0xfff0)); + HMADest = MK_FP(NewKernelSegment,0x0000); + + len = (FP_OFF(_HMATextEnd) | 0x000f) - (FP_OFF(_HMATextStart) & 0xfff0); + + if (NewKernelSegment == 0xffff) + { + HMASource += HMAOFFSET; + HMADest += HMAOFFSET; + len -= HMAOFFSET; + } + + HMAInitPrintf(("HMA moving %p up to %p for %04x bytes\n", + HMASource, HMADest, len)); + + if (NewKernelSegment < CurrentKernelSegment || + NewKernelSegment == 0xffff) + { + unsigned i; UBYTE FAR *s,FAR *d; + + for (i = 0, s = HMASource,d = HMADest; i < len; i++) + d[i] = s[i]; + } + else { + /* might overlap */ + unsigned i; UBYTE FAR *s,FAR *d; + + for (i = len, s = HMASource,d = HMADest; i != 0; i--) + d[i] = s[i]; + } + + HMAFree = FP_OFF(HMADest)+len; /* first free byte after HMA_TEXT */ + + { + /* D) but it only makes sense, if we can relocate + all our entries to make use of HMA + */ + + /* this is for a + call near enableA20 + jmp far kernelentry + style table + */ + + struct RelocationTable { + UBYTE jmpFar; + UWORD jmpOffset; + UWORD jmpSegment; + UBYTE callNear; + UWORD callOffset; + }; + struct RelocatedEntry { + UBYTE callNear; + UWORD callOffset; + UBYTE jmpFar; + UWORD jmpOffset; + UWORD jmpSegment; + }; + extern struct RelocationTable + FAR _HMARelocationTableStart[], + FAR _HMARelocationTableEnd[]; + + struct RelocationTable FAR *rp, rtemp ; + + /* verify, that all entries are valid */ + + for (rp = _HMARelocationTableStart; rp < _HMARelocationTableEnd; rp++) + { + if (rp->jmpFar != 0xea || /* jmp FAR */ + rp->jmpSegment != CurrentKernelSegment || /* will only relocate HMA_TEXT */ + rp->callNear != 0xe8 || /* call NEAR */ + 0) + { + printf("illegal relocation entry # %d\n",rp - _HMARelocationTableStart); + goto errorReturn; + } + } + + /* OK, all valid, go to relocate*/ + + for (rp = _HMARelocationTableStart; rp < _HMARelocationTableEnd; rp++) + { + if (NewKernelSegment == 0xffff) + { + struct RelocatedEntry FAR *rel = (struct RelocatedEntry FAR *)rp; + + fmemcpy(&rtemp, rp, sizeof(rtemp)); + + rel->jmpFar = rtemp.jmpFar; + rel->jmpSegment = NewKernelSegment; + rel->jmpOffset = rtemp.jmpOffset; + rel->callNear = rtemp.callNear; + rel->callOffset = rtemp.callOffset+5; /* near calls are relative */ + } + else + rp->jmpSegment = NewKernelSegment; + + } + } + { + struct initRelocationTable { + UBYTE callNear; + UWORD callOffset; + UBYTE jmpFar; + UWORD jmpOffset; + UWORD jmpSegment; + }; + extern struct initRelocationTable + _HMAinitRelocationTableStart[], + _HMAinitRelocationTableEnd[]; + struct initRelocationTable *rp; + + /* verify, that all entries are valid */ + + for (rp = _HMAinitRelocationTableStart; rp < _HMAinitRelocationTableEnd; rp++) + { + if ( + rp->callNear != 0xe8 || /* call NEAR */ + rp->jmpFar != 0xea || /* jmp FAR */ + rp->jmpSegment != CurrentKernelSegment || /* will only relocate HMA_TEXT */ + 0) + { + printf("illegal init relocation entry # %d\n", + rp - _HMAinitRelocationTableStart); + goto errorReturn; + } + } + + /* OK, all valid, go to relocate*/ + + for (rp = _HMAinitRelocationTableStart; rp < _HMAinitRelocationTableEnd; rp++) + { + rp->jmpSegment = NewKernelSegment; + } + } + + CurrentKernelSegment = NewKernelSegment; + return; + +errorReturn: + for (;;); +} diff --git a/kernel/int2f.asm b/kernel/int2f.asm index 9da2917a..1b6a4f87 100644 --- a/kernel/int2f.asm +++ b/kernel/int2f.asm @@ -30,6 +30,9 @@ ; $Id$ ; ; $Log$ +; Revision 1.9 2001/07/09 22:19:33 bartoldeman +; LBA/FCB/FAT/SYS/Ctrl-C/ioctl fixes + memory savings +; ; Revision 1.8 2001/04/02 23:18:30 bartoldeman ; Misc, zero terminated device names and redirector bugs fixed. ; @@ -375,7 +378,7 @@ _Umb_Test push bx push cs ; setup far return - mov ax, umbt1 + mov ax, umbt1 push ax push es ; push the driver entry point push bx @@ -401,7 +404,7 @@ umbtc: pop es push cs - mov ax, umbt2 + mov ax, umbt2 push ax push es push bx diff --git a/kernel/inthndlr.c b/kernel/inthndlr.c index cc74fab3..41ef73af 100644 --- a/kernel/inthndlr.c +++ b/kernel/inthndlr.c @@ -37,6 +37,9 @@ BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.25 2001/07/09 22:19:33 bartoldeman + * LBA/FCB/FAT/SYS/Ctrl-C/ioctl fixes + memory savings + * * Revision 1.24 2001/06/03 14:16:18 bartoldeman * BUFFERS tuning and misc bug fixes/cleanups (2024c). * @@ -489,7 +492,7 @@ VOID int21_service(iregs FAR * r) case 0x0a: ((keyboard FAR *) FP_DS_DX)->kb_count = 0; sti((keyboard FAR *) FP_DS_DX); - ((keyboard FAR *) FP_DS_DX)->kb_count--; + ((keyboard FAR *) FP_DS_DX)->kb_count --; break; /* Check Stdin Status */ @@ -869,29 +872,44 @@ VOID int21_service(iregs FAR * r) /* Get DPB */ case 0x32: - r->DL = ( r->DL == 0 ? default_drive : r->DL - 1); - if (r->DL < lastdrive) + /* r->DL is NOT changed by MS 6.22 */ + /* INT21/32 is documented to reread the DPB */ + { + struct dpb FAR *dpb; + UCOUNT drv = r->DL; + + if (drv == 0) drv = default_drive; + else drv--; + + if (drv >= lastdrive) + { + r->AL = 0xFF; + CritErrCode = 0x0f; + break; + } + + dpb = CDSp->cds_table[drv].cdsDpb; + if (dpb == 0 || + CDSp->cds_table[drv].cdsFlags & CDSNETWDRV) + { + r->AL = 0xFF; + CritErrCode = 0x0f; + break; + } + dpb->dpb_flags = M_CHANGED; /* force reread of drive BPB/DPB */ + + if (media_check(dpb) < 0) { - struct dpb FAR *dpb = CDSp->cds_table[r->DL].cdsDpb; - if (dpb == 0 || - (CDSp->cds_table[r->DL].cdsFlags & CDSNETWDRV) || - media_check(dpb) < 0) - { r->AL = 0xff; CritErrCode = 0x0f; break; - } - r->DS = FP_SEG(dpb); - r->BX = FP_OFF(dpb); - r->AL = 0; } - else { - r->AL = 0xFF; - CritErrCode = 0x0f; + r->DS = FP_SEG(dpb); + r->BX = FP_OFF(dpb); + r->AL = 0; + } - } break; - /* case 0x33: see int21_syscall @@ -1772,14 +1790,14 @@ VOID int2526_handler(WORD mode, struct int25regs FAR * r) BYTE FAR *buf; UBYTE drv; - if (mode == 0x26) mode = DSKWRITE; - else mode = DSKREAD; + if (mode == 0x26) mode = DSKWRITEINT26; + else mode = DSKREADINT25; drv = r->ax; if (drv >= lastdrive) { - r->ax = 0x202; + r->ax = 0x201; r->flags |= FLG_CARRY; return; } diff --git a/kernel/ioctl.c b/kernel/ioctl.c index bb10cb1c..9c77aaa6 100644 --- a/kernel/ioctl.c +++ b/kernel/ioctl.c @@ -35,6 +35,9 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.10 2001/07/09 22:19:33 bartoldeman + * LBA/FCB/FAT/SYS/Ctrl-C/ioctl fixes + memory savings + * * Revision 1.9 2001/06/03 14:16:18 bartoldeman * BUFFERS tuning and misc bug fixes/cleanups (2024c). * @@ -270,6 +273,10 @@ COUNT DosDevIOctl(iregs FAR * r) { return DE_INVLDDRV; } + if (media_check(dpbp) < 0) + { + return DE_INVLDDRV; + } if ( ((r->AL == 0x04 ) && !(dpbp->dpb_device->dh_attr & ATTR_IOCTL)) || ((r->AL == 0x05 ) && !(dpbp->dpb_device->dh_attr & ATTR_IOCTL)) || ((r->AL == 0x11) && !(dpbp->dpb_device->dh_attr & ATTR_QRYIOCTL)) @@ -312,7 +319,7 @@ COUNT DosDevIOctl(iregs FAR * r) case 0x06: if (s->sft_flags & SFT_FDEVICE) { - r->AL = s->sft_flags & SFT_FEOF ? 0 : 0xFF; + r->AL = s->sft_flags & SFT_FEOF ? 0xFF : 0; } else r->AL = s->sft_posit >= s->sft_size ? 0xFF : 0; diff --git a/kernel/kernel.asm b/kernel/kernel.asm index 24bfb71f..96ad29e6 100644 --- a/kernel/kernel.asm +++ b/kernel/kernel.asm @@ -28,6 +28,9 @@ ; $Id$ ; ; $Log$ +; Revision 1.14 2001/07/09 22:19:33 bartoldeman +; LBA/FCB/FAT/SYS/Ctrl-C/ioctl fixes + memory savings +; ; Revision 1.13 2001/06/03 14:16:18 bartoldeman ; BUFFERS tuning and misc bug fixes/cleanups (2024c). ; @@ -142,7 +145,18 @@ segment PSP STACK_SIZE equ 384/2 ; stack allocated in words ..start: -entry: jmp far kernel_start +entry: + push ax + push bx + pushf + mov ax, 0e31h ; '1' Tracecode - kernel entered + mov bx, 00f0h + int 010h + popf + pop bx + pop ax + + jmp far kernel_start beyond_entry: resb 256-(beyond_entry-entry) ; scratch area for data (DOS_PSP) @@ -154,6 +168,17 @@ segment INIT_TEXT ; kernel start-up ; kernel_start: + + push ax + push bx + pushf + mov ax, 0e32h ; '2' Tracecode - kernel entered + mov bx, 00f0h + int 010h + popf + pop bx + pop ax + mov ax,IGROUP cli mov ss,ax @@ -197,6 +222,17 @@ cont: ; inititalize api stacks for high water tests mov es,ax mov bp,sp ; and set up stack frame for c sti ; now enable them + + push ax + push bx + pushf + mov ax, 0e33h ; '3' Tracecode - kernel entered + mov bx, 00f0h + int 010h + popf + pop bx + pop ax + inc bl jns floppy add bl,3-1-128 @@ -918,10 +954,10 @@ __EnableA20: enableUsingXMSdriver: mov ah,3 -UsingXMSdriver: +UsingXMSdriver: push bx call far [cs:_XMSDriverAddress] - pop bx + pop bx retf global __DisableA20 diff --git a/kernel/kernel.cfg b/kernel/kernel.cfg index c92038f6..38d5ef57 100644 --- a/kernel/kernel.cfg +++ b/kernel/kernel.cfg @@ -6,6 +6,7 @@ -d -k- -vi- +-w -wpro -weas -wpre diff --git a/kernel/kernel.mak b/kernel/kernel.mak index 32a3a5c9..41694551 100644 --- a/kernel/kernel.mak +++ b/kernel/kernel.mak @@ -5,6 +5,9 @@ # # $Log$ +# Revision 1.11 2001/07/09 22:19:33 bartoldeman +# LBA/FCB/FAT/SYS/Ctrl-C/ioctl fixes + memory savings +# # Revision 1.10 2001/04/21 22:32:53 bartoldeman # Init DS=Init CS, fixed stack overflow problems and misc bugs. # @@ -129,6 +132,23 @@ RELEASE = 1.00 +# Compiler and Options for Borland C++ +# ------------------------------------ +# +# -zAname ¦ ¦ Code class +# -zBname ¦ ¦ BSS class +# -zCname ¦ ¦ Code segment +# -zDname ¦ ¦ BSS segment +# -zEname ¦ ¦ Far segment +# -zFname ¦ ¦ Far class +# -zGname ¦ ¦ BSS group +# -zHname ¦ ¦ Far group +# -zPname ¦ ¦ Code group +# -zRname ¦ ¦ Data segment +# -zSname ¦ ¦ Data group +# -zTname ¦ ¦ Data class +# -zX ¦«¦ Use default name for "X" + # # Compiler and Options for Borland C++ # ------------------------------------ @@ -170,6 +190,7 @@ EXE_dependencies = \ dosfns.obj \ dosnames.obj \ dsk.obj \ + initdisk.obj \ entry.obj \ error.obj \ execrh.obj \ @@ -203,7 +224,9 @@ EXE_dependencies = \ syspack.obj \ systime.obj \ task.obj \ - inithma.obj + inithma.obj \ + DynData.obj \ + DynInit.obj # *Explicit Rules* @@ -226,13 +249,13 @@ clean: kernel.exe: $(EXE_dependencies) $(LIBS) $(RM) kernel.lib $(LIBUTIL) kernel +entry +io +blockio +chario +dosfns +console - $(LIBUTIL) kernel +printer +serial +dsk +error +fatdir +fatfs + $(LIBUTIL) kernel +printer +serial +dsk +initdisk+error +fatdir +fatfs $(LIBUTIL) kernel +fattab +fcbfns +initoem +initHMA+inthndlr +ioctl +nls_hc $(LIBUTIL) kernel +main +config +memmgr +misc +newstuff +nls +intr $(LIBUTIL) kernel +dosnames +prf +initprf +strings +network +sysclk +syspack $(LIBUTIL) kernel +systime +task +int2f +irqstack +apisupt $(LIBUTIL) kernel +asmsupt +execrh +nlssupt +procsupt +break - $(LIBUTIL) kernel +dosidle + $(LIBUTIL) kernel +dosidle+dyndata+dyninit $(RM) kernel.bak $(LINK) /m/c/L$(LIBPATH) kernel,kernel,kernel,kernel+$(LIBS); $(RM) kernel.lib @@ -277,7 +300,7 @@ config.obj: config.c init-mod.h $(HDR)portab.h globals.h \ $(HDR)fat.h $(HDR)fcb.h $(HDR)tail.h $(HDR)process.h $(HDR)dcb.h \ $(HDR)sft.h $(HDR)cds.h $(HDR)exe.h $(HDR)fnode.h \ $(HDR)dirmatch.h $(HDR)file.h $(HDR)clock.h $(HDR)kbd.h \ - $(HDR)error.h $(HDR)version.h proto.h turboc.cfg + $(HDR)error.h $(HDR)version.h proto.h turboc.cfg dyndata.h $(CC) $(INITCFLAGS) -c config.c initoem.obj: initoem.c init-mod.h $(HDR)portab.h globals.h \ @@ -285,7 +308,7 @@ initoem.obj: initoem.c init-mod.h $(HDR)portab.h globals.h \ $(HDR)fat.h $(HDR)fcb.h $(HDR)tail.h $(HDR)process.h $(HDR)dcb.h \ $(HDR)sft.h $(HDR)cds.h $(HDR)exe.h $(HDR)fnode.h \ $(HDR)dirmatch.h $(HDR)file.h $(HDR)clock.h $(HDR)kbd.h \ - $(HDR)error.h $(HDR)version.h proto.h turboc.cfg + $(HDR)error.h $(HDR)version.h proto.h turboc.cfg dyndata.h $(CC) $(INITCFLAGS) -c initoem.c main.obj: main.c init-mod.h $(HDR)portab.h globals.h $(HDR)device.h \ @@ -293,7 +316,7 @@ main.obj: main.c init-mod.h $(HDR)portab.h globals.h $(HDR)device.h \ $(HDR)fcb.h $(HDR)tail.h $(HDR)process.h $(HDR)dcb.h $(HDR)sft.h \ $(HDR)cds.h $(HDR)exe.h $(HDR)fnode.h $(HDR)dirmatch.h \ $(HDR)file.h $(HDR)clock.h $(HDR)kbd.h $(HDR)error.h \ - $(HDR)version.h proto.h turboc.cfg + $(HDR)version.h proto.h turboc.cfg dyndata.h $(CC) $(INITCFLAGS) -c main.c initHMA.obj: initHMA.c init-mod.h $(HDR)portab.h globals.h $(HDR)device.h \ @@ -301,9 +324,40 @@ initHMA.obj: initHMA.c init-mod.h $(HDR)portab.h globals.h $(HDR)device.h \ $(HDR)fcb.h $(HDR)tail.h $(HDR)process.h $(HDR)dcb.h $(HDR)sft.h \ $(HDR)cds.h $(HDR)exe.h $(HDR)fnode.h $(HDR)dirmatch.h \ $(HDR)file.h $(HDR)clock.h $(HDR)kbd.h $(HDR)error.h \ - $(HDR)version.h proto.h turboc.cfg + $(HDR)version.h proto.h turboc.cfg dyndata.h $(CC) $(INITCFLAGS) -c initHMA.c +DynInit.obj: DynInit.c init-mod.h $(HDR)portab.h globals.h $(HDR)device.h \ + $(HDR)mcb.h $(HDR)pcb.h $(HDR)date.h $(HDR)time.h $(HDR)fat.h \ + $(HDR)fcb.h $(HDR)tail.h $(HDR)process.h $(HDR)dcb.h $(HDR)sft.h \ + $(HDR)cds.h $(HDR)exe.h $(HDR)fnode.h $(HDR)dirmatch.h \ + $(HDR)file.h $(HDR)clock.h $(HDR)kbd.h $(HDR)error.h \ + $(HDR)version.h proto.h turboc.cfg dyndata.h + $(CC) $(INITCFLAGS) -c DynInit.c + +initdisk.obj: initdisk.c disk.h $(HDR)portab.h globals.h $(HDR)device.h $(HDR)mcb.h \ + $(HDR)pcb.h $(HDR)date.h $(HDR)time.h $(HDR)fat.h $(HDR)fcb.h \ + $(HDR)tail.h $(HDR)process.h $(HDR)dcb.h $(HDR)sft.h $(HDR)cds.h \ + $(HDR)exe.h $(HDR)fnode.h $(HDR)dirmatch.h $(HDR)file.h \ + $(HDR)clock.h $(HDR)kbd.h $(HDR)error.h $(HDR)version.h proto.h \ + turboc.cfg dyndata.h + $(CC) $(INITCFLAGS) -c initDISK.c + + +# -zBname ¦ ¦ BSS class +# -zDname ¦ ¦ BSS segment +# -zEname ¦ ¦ Far segment +# -zFname ¦ ¦ Far class +# -zGname ¦ ¦ BSS group +# -zHname ¦ ¦ Far group +# -zRname ¦ ¦ Data segment +# -zSname ¦ ¦ Data group +# -zTname ¦ ¦ Data class + +dynDATA.obj: dynDATA.c dynDATA.H + $(CC) -c -zRDYN_DATA -zTDYN_DATA -zDDYN_DATA -zBDYN_DATA dynDATA.c + + #the printf for INIT_TEXT: initprf.obj: prf.c $(HDR)portab.h turboc.cfg $(CC) -DFORINIT $(INITCFLAGS) -oinitprf.obj -c prf.c @@ -345,13 +399,14 @@ dosnames.obj: dosnames.c $(HDR)portab.h globals.h $(HDR)device.h \ $(HDR)file.h $(HDR)clock.h $(HDR)kbd.h $(HDR)error.h \ $(HDR)version.h proto.h turboc.cfg -dsk.obj: dsk.c $(HDR)portab.h globals.h $(HDR)device.h $(HDR)mcb.h \ +dsk.obj: dsk.c disk.h $(HDR)portab.h globals.h $(HDR)device.h $(HDR)mcb.h \ $(HDR)pcb.h $(HDR)date.h $(HDR)time.h $(HDR)fat.h $(HDR)fcb.h \ $(HDR)tail.h $(HDR)process.h $(HDR)dcb.h $(HDR)sft.h $(HDR)cds.h \ $(HDR)exe.h $(HDR)fnode.h $(HDR)dirmatch.h $(HDR)file.h \ $(HDR)clock.h $(HDR)kbd.h $(HDR)error.h $(HDR)version.h proto.h \ turboc.cfg + error.obj: error.c $(HDR)portab.h globals.h $(HDR)device.h \ $(HDR)mcb.h $(HDR)pcb.h $(HDR)date.h $(HDR)time.h $(HDR)fat.h \ $(HDR)fcb.h $(HDR)tail.h $(HDR)process.h $(HDR)dcb.h $(HDR)sft.h \ diff --git a/kernel/main.c b/kernel/main.c index 44bafe2b..f34ef750 100644 --- a/kernel/main.c +++ b/kernel/main.c @@ -71,6 +71,9 @@ static BYTE *mainRcsId = "$Id$"; /* * $Log$ + * Revision 1.18 2001/07/09 22:19:33 bartoldeman + * LBA/FCB/FAT/SYS/Ctrl-C/ioctl fixes + memory savings + * * Revision 1.17 2001/06/03 14:16:18 bartoldeman * BUFFERS tuning and misc bug fixes/cleanups (2024c). * @@ -309,8 +312,14 @@ INIT void init_kernel(void) /* Do first initialization of system variable buffers so that */ /* we can read config.sys later. */ lastdrive = Config.cfgLastdrive; + PreConfig(); - init_device((struct dhdr FAR *)&blk_dev, NULL, NULL, ram_top); + + /* init_device((struct dhdr FAR *)&blk_dev, NULL, NULL, ram_top); */ + blk_dev.dh_name[0] = dsk_init(); + /* Number of units */ + if (blk_dev.dh_name[0] > 0) + update_dcb(&blk_dev); /* Now config the temporary file system */ FsConfig(); diff --git a/kernel/nls.c b/kernel/nls.c index df08f3ec..1dfe9d58 100644 --- a/kernel/nls.c +++ b/kernel/nls.c @@ -44,6 +44,9 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.8 2001/07/09 22:19:33 bartoldeman + * LBA/FCB/FAT/SYS/Ctrl-C/ioctl fixes + memory savings + * * Revision 1.7 2001/06/03 14:16:18 bartoldeman * BUFFERS tuning and misc bug fixes/cleanups (2024c). * @@ -124,7 +127,7 @@ struct nlsInfoBlock nlsInfo = { /*== DS:SI _always_ points to global NLS info structure <-> no * subfct can use these registers for anything different. ==ska*/ -static COUNT muxGo(int subfct, iregs *rp) +STATIC COUNT muxGo(int subfct, iregs *rp) { log( ("NLS: muxGo(): subfct=%x, cntry=%u, cp=%u, ES:DI=%04x:%04x\n", subfct , rp->DX, rp->BX, rp->ES, rp->DI) ); @@ -162,7 +165,7 @@ COUNT muxLoadPkg(UWORD cp, UWORD cntry) return muxGo(NLSFUNC_LOAD_PKG, &r); } -static int muxBufGo(int subfct, int bp, UWORD cp, UWORD cntry, UWORD bufsize +STATIC int muxBufGo(int subfct, int bp, UWORD cp, UWORD cntry, UWORD bufsize , VOID FAR *buf) { iregs r; @@ -195,7 +198,7 @@ log( ("NLS: muxBufGo(): subfct=%x, BP=%u, cp=%u, cntry=%u, len=%u, buf=%04x:%04x * Also resolves the default values (-1) into the currently * active codepage/country code. */ -static struct nlsPackage FAR *searchPackage(UWORD cp, UWORD cntry) +STATIC struct nlsPackage FAR *searchPackage(UWORD cp, UWORD cntry) { struct nlsPackage FAR *nls; if(cp == NLS_DEFAULT) @@ -213,7 +216,7 @@ static struct nlsPackage FAR *searchPackage(UWORD cp, UWORD cntry) /* For various robustnesses reasons and to simplify the implementation at other places, locateSubfct() returns NULL (== "not found"), if nls == NULL on entry. */ -static VOID FAR *locateSubfct(struct nlsPackage FAR *nls, int subfct) +STATIC VOID FAR *locateSubfct(struct nlsPackage FAR *nls, int subfct) { int cnt; struct nlsPointer FAR *p; @@ -232,7 +235,7 @@ static VOID FAR *locateSubfct(struct nlsPackage FAR *nls, int subfct) function is guaranteed to return valid pointers, rather than to let the user (some kernel function) deal with non-existing tables -- 2000/02/26 ska*/ -static VOID FAR *getTable(UBYTE subfct, struct nlsPackage FAR *nls) +STATIC VOID FAR *getTable(UBYTE subfct, struct nlsPackage FAR *nls) { struct nlsPointer FAR *poi; if((poi = locateSubfct(nls, subfct)) != NULL) @@ -258,7 +261,7 @@ static VOID FAR *getTable(UBYTE subfct, struct nlsPackage FAR *nls) * the code to push bufsize, buf, call cpyBuf() and return its result. * The parameter were ordered to allow this code optimization. */ -static COUNT cpyBuf(VOID FAR *dst, UWORD dstlen +STATIC COUNT cpyBuf(VOID FAR *dst, UWORD dstlen , VOID FAR *src, UWORD srclen) { if(srclen <= dstlen) { @@ -274,7 +277,7 @@ static COUNT cpyBuf(VOID FAR *dst, UWORD dstlen * This function assumes that 'map' is adjusted such that * map[0x80] is the uppercase of character 0x80. *== 128 byte chartables, lower range conform to 7bit-US-ASCII ==ska*/ -static VOID upMMem(UBYTE FAR *map, UBYTE FAR * str, unsigned len) +STATIC VOID upMMem(UBYTE FAR *map, UBYTE FAR * str, unsigned len) { REG unsigned c; @@ -316,7 +319,7 @@ printf("NLS: upMMem(): result=\""); the direct-access interface. subfct == NLS_DOS_38 is a value > 0xff in order to not clash with subfunctions valid to be passed as DOS-65-XX. */ -static int nlsGetData(struct nlsPackage FAR *nls, int subfct, UBYTE FAR *buf +STATIC int nlsGetData(struct nlsPackage FAR *nls, int subfct, UBYTE FAR *buf , unsigned bufsize) { VOID FAR *poi; @@ -385,7 +388,7 @@ VOID nlsCPchange(UWORD cp) * appropriate codepage on its own. */ -static COUNT nlsSetPackage(struct nlsPackage FAR *nls) +STATIC COUNT nlsSetPackage(struct nlsPackage FAR *nls) { if(nls->cp != nlsInfo.actPkg->cp) /* Codepage gets changed --> inform all character drivers thereabout. @@ -397,7 +400,7 @@ static COUNT nlsSetPackage(struct nlsPackage FAR *nls) return SUCCESS; } -static COUNT DosSetPackage(UWORD cp, UWORD cntry) +STATIC COUNT DosSetPackage(UWORD cp, UWORD cntry) { struct nlsPackage FAR*nls; /* NLS package to use to return the info from */ /* nls := NLS package of cntry/codepage */ @@ -409,18 +412,18 @@ static COUNT DosSetPackage(UWORD cp, UWORD cntry) return muxLoadPkg(cp, cntry); } -static void nlsUpMem(struct nlsPackage FAR *nls, VOID FAR *str, int len) +STATIC void nlsUpMem(struct nlsPackage FAR *nls, VOID FAR *str, int len) { log( ("NLS: nlsUpMem()\n") ); upMMem(getCharTbl2(nls), (UBYTE FAR*)str, len); } -static void nlsFUpMem(struct nlsPackage FAR *nls, VOID FAR *str, int len) +STATIC void nlsFUpMem(struct nlsPackage FAR *nls, VOID FAR *str, int len) { log( ("NLS: nlsFUpMem()\n") ); upMMem(getCharTbl4(nls), (UBYTE FAR*)str, len); } -static VOID xUpMem(struct nlsPackage FAR *nls, VOID FAR * str, unsigned len) +STATIC VOID xUpMem(struct nlsPackage FAR *nls, VOID FAR * str, unsigned len) /* upcase a memory area */ { log( ("NLS: xUpMem(): cp=%u, cntry=%u\n", nls->cp, nls->cntry) ); @@ -431,7 +434,7 @@ log( ("NLS: xUpMem(): cp=%u, cntry=%u\n", nls->cp, nls->cntry) ); muxBufGo(NLSFUNC_UPMEM, 0, nls->cp, nls->cntry, len, str); } -static int nlsYesNo(struct nlsPackage FAR *nls, unsigned char ch) +STATIC int nlsYesNo(struct nlsPackage FAR *nls, unsigned char ch) { assertDSeqSS(); /* because "&ch" */ diff --git a/kernel/segs.inc b/kernel/segs.inc index 9aea54c4..c550eeb8 100644 --- a/kernel/segs.inc +++ b/kernel/segs.inc @@ -29,6 +29,9 @@ ; $Header$ ; ; $Log$ +; Revision 1.8 2001/07/09 22:19:33 bartoldeman +; LBA/FCB/FAT/SYS/Ctrl-C/ioctl fixes + memory savings +; ; Revision 1.7 2001/04/29 17:34:40 bartoldeman ; A new SYS.COM/config.sys single stepping/console output/misc fixes. ; @@ -68,7 +71,7 @@ group PGROUP PSP group TGROUP _TEXT _IO_TEXT _IO_FIXED_DATA -group DGROUP _FIXED_DATA _DATA _BSSSTART _BSS _BSSEND +group DGROUP _FIXED_DATA _DATA _BSSSTART _BSS _BSSEND DYN_DATA group HGROUP HMA_TEXT_START HMA_TEXT HMA_TEXT_END group IGROUP INIT_TEXT_START INIT_TEXT INIT_TEXT_END ID_B ID ID_E IB_B IB IB_E @@ -81,6 +84,7 @@ segment _DATA class=DATA align=2 segment _BSSSTART class=BSS align=2 segment _BSS class=BSS align=2 segment _BSSEND class=BSS +segment DYN_DATA class=DYN_DATA segment HMA_TEXT_START class=HMA align=16 segment HMA_TEXT class=HMA segment HMA_TEXT_END class=HMA diff --git a/sys/sys.c b/sys/sys.c index 4cd08d06..dd3e5337 100644 --- a/sys/sys.c +++ b/sys/sys.c @@ -25,6 +25,17 @@ 675 Mass Ave, Cambridge, MA 02139, USA. ***************************************************************/ +/* $Log$ + * Revision 1.7 2001/07/09 22:19:33 bartoldeman + * LBA/FCB/FAT/SYS/Ctrl-C/ioctl fixes + memory savings + * +/* Revision 2.1 tomehlert 2001/4/26 + + changed the file system detection code. + + +*/ + /* Revision 2.0 tomehlert 2001/4/26 no direct access to the disk any more, this is FORMAT's job @@ -44,33 +55,9 @@ size is no ~7500 byte vs. ~13690 before */ - -/* $Log$ - * Revision 1.6 2001/04/29 17:34:41 bartoldeman - * /* Revision 2.1 tomehlert 2001/4/26 - * - * changed the file system detection code. - * */ - * - * /* Revision 2.0 tomehlert 2001/4/26 - * - * no direct access to the disk any more, this is FORMAT's job - * no floppy.asm anymore, no segmentation problems. - * no access to partition tables - * - * instead copy boot sector using int25/int26 = absdiskread()/write - * - * if xxDOS is able to handle the disk, SYS should work - * - * additionally some space savers: - * - * replaced fopen() by open() - * - * included (slighly modified) PRF.c from kernel - * - * size is no ~7500 byte vs. ~13690 before - * */ - * +/* Revision 1.6 2001/04/29 17:34:41 bartoldeman +/* A new SYS.COM/config.sys single stepping/console output/misc fixes. +/* /* Revision 1.5 2001/03/25 17:11:54 bartoldeman /* Fixed sys.com compilation. Updated to 2023. Also: see history.txt. /* @@ -203,7 +190,7 @@ UBYTE newboot[SEC_SIZE], oldboot[SEC_SIZE]; VOID main(COUNT argc, char **argv) { - printf("FreeDOS System Installer v1.0\n\n"); + printf("FreeDOS System Installer v2.1\n\n"); if (argc != 2) { @@ -277,6 +264,38 @@ VOID dump_sector(unsigned char far * sec) #endif +/* + TC absRead not functional on MSDOS 6.2, large disks + MSDOS requires int25, CX=ffff for drives > 32MB +*/ + +int MyAbsReadWrite(char DosDrive, int count, ULONG sector, void *buffer, unsigned intno) +{ + struct { + unsigned long sectorNumber; + unsigned short count; + void far *address; + } diskReadPacket; + int retval; + union REGS regs; + + + diskReadPacket.sectorNumber = sector; + diskReadPacket.count = count; + diskReadPacket.address = buffer; + + regs.h.al = DosDrive; + regs.x.bx = (short)&diskReadPacket; + regs.x.cx = 0xffff; + + if (intno != 0x25 && intno != 0x26) return 0xff; + + int86(intno,®s,®s); + + return regs.x.cflag ? 0xff : 0; +} + + VOID put_boot(COUNT drive) { COUNT i, z; @@ -284,13 +303,18 @@ VOID put_boot(COUNT drive) WORD count; ULONG temp; struct bootsectortype *bs; + int fs; + union REGS regs; + struct SREGS sregs; + char drivename[] = "A:\\"; + unsigned char x[0x40]; #ifdef DEBUG printf("Reading old bootsector from drive %c:\n",drive+'A'); #endif - if (absread(drive, 1, 0, oldboot) != 0) + if (MyAbsReadWrite(drive, 1, 0, oldboot,0x25) != 0) { printf("can't read old boot sector for drive %c:\n", drive +'A'); exit(1); @@ -302,23 +326,95 @@ VOID put_boot(COUNT drive) dump_sector(oldboot); #endif - bs = (struct bootsectortype *) & oldboot; if ((bs->bsFileSysType[4] == '6') && (bs->bsBootSignature == 0x29)) { - memcpy(newboot, b_fat16, SEC_SIZE); /* copy FAT16 boot sector */ - printf("FAT type: FAT16\n"); + fs = 16; } else { - memcpy(newboot, b_fat12, SEC_SIZE); /* copy FAT12 boot sector */ - printf("FAT type: FAT12\n"); + fs = 12; } +/* + the above code is not save enough for me (TE), so we change the + FS detection method to GetFreeDiskSpace(). + this should work, as the disk was writeable, so GetFreeDiskSpace should work. +*/ + + regs.h.ah = 0x36; /* get drive free space */ + regs.h.dl = drive+1; /* 1 = 'A',... */ + int86(0x21,®s,®s); + + if (regs.x.ax == 0xffff) + { + printf("can't get free disk space for %c:\n", drive+'A'); + exit(1); + } + + if (regs.x.dx <= 0xff6) + { + if (fs != 12) printf("warning : new detection overrides old detection\a\n"); + fs = 12; + } + else { + + if (fs != 16) printf("warning : new detection overrides old detection\a\n"); + fs = 16; + + /* fs = 16/32. + we don't want to crash a FAT32 drive + */ + + segread(&sregs); + sregs.es = sregs.ds; + + regs.x.ax = 0x7303; /* get extended drive free space */ + + drivename[0] = 'A' + drive; + regs.x.dx = (unsigned)&drivename; + regs.x.di = (unsigned)&x; + regs.x.cx = sizeof(x); + + int86x(0x21,®s,®s,&sregs); + + if (regs.x.cflag) /* error --> no Win98 --> no FAT32 */ + { + printf("get extended drive space not supported --> no FAT32\n"); + } + else { + if (*(unsigned long *)(x+0x2c) /* total number of clusters */ + > (unsigned)65526l) + { + fs = 32; + } + } + } + + + if (fs == 16) + { + memcpy(newboot, b_fat16, SEC_SIZE); /* copy FAT16 boot sector */ + printf("FAT type: FAT16\n"); + } + else if (fs == 12) + { + memcpy(newboot, b_fat12, SEC_SIZE); /* copy FAT12 boot sector */ + printf("FAT type: FAT12\n"); + } + else { + printf("FAT type: FAT32\n"); + printf("Sorry, we don't have a FAT32 boot sector (yet)\n"); + printf(" for this reason, we can't make the drive bootable\n"); + exit(1); + } + /* Copy disk parameter from old sector to new sector */ memcpy(&newboot[SBOFFSET], &oldboot[SBOFFSET], SBSIZE); bs = (struct bootsectortype *) & newboot; + + memcpy(bs->OemName, "FreeDOS ",8); #ifdef STORE_BOOT_INFO /* TE thinks : never, see above */ @@ -366,7 +462,7 @@ VOID put_boot(COUNT drive) printf("writing new bootsector to drive %c:\n",drive+'A'); #endif - if (abswrite(drive, 1, 0, newboot) != 0) + if (MyAbsReadWrite(drive, 1, 0, newboot,0x26) != 0) { printf("Can't write new boot sector to drive %c:\n", drive +'A'); exit(1); From 03865c6b69d68931409ce935202e21cb5ded09bc Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sun, 22 Jul 2001 01:58:58 +0000 Subject: [PATCH 083/671] Support for Brian's FORMAT, DJGPP libc compilation, cleanups, MSCDEX git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@265 6ac86273-5f31-0410-b378-82cca8765d1b --- docs/history.txt | 28 ++++ hdr/device.h | 72 ++++++++ hdr/sft.h | 4 + kernel/blockio.c | 9 +- kernel/config.c | 88 ++++++++-- kernel/disk.h | 68 -------- kernel/dosfns.c | 166 +++++++++--------- kernel/dosnames.c | 44 ++--- kernel/dsk.c | 247 +++++++++++++++------------ kernel/dyndata.c | 2 + kernel/dyndata.h | 3 +- kernel/fatdir.c | 81 +++------ kernel/fatfs.c | 129 +++++++------- kernel/fcbfns.c | 6 +- kernel/globals.h | 47 +++--- kernel/init-mod.h | 6 +- kernel/initdisk.c | 417 +++++++++++++++++++++++++++++++++------------- kernel/int2f.asm | 151 ++++++++++++----- kernel/inthndlr.c | 48 +++--- kernel/ioctl.c | 15 +- kernel/kernel.asm | 20 ++- kernel/kernel.mak | 7 +- kernel/main.c | 17 +- kernel/network.c | 21 +-- kernel/prf.c | 29 +++- kernel/proto.h | 41 ++--- kernel/sysclk.c | 29 +++- kernel/task.c | 51 +++--- 28 files changed, 1112 insertions(+), 734 deletions(-) delete mode 100644 kernel/disk.h diff --git a/docs/history.txt b/docs/history.txt index 4e95694a..1d46ca0c 100644 --- a/docs/history.txt +++ b/docs/history.txt @@ -1,3 +1,31 @@ ++ fixes Bart + * ioctl.c fix for INT21/AX=4400 + sft driveno field + * various small fcb fixes + * put file position number and pointers to Pri/SecPathName into + SDA. Now MSCDEX works as redirector + * redirector set attribute fixes + various cleanups + * truename+attr+ioctl fix => DJGPP libc compiles cleanly! ++ changes Bart + * use the output of truename() consistently: this saves a lot of + headaches in parsing later and also allows a lot of simplifying: + made many parameters in fatfs.c and fatdir.c NEAR ++ added Bart + * partly implemented the "Drive Data Table" see RBIL INT2f/AX=0803 + * implemented construction of default BPB in initdisk.c + * implemented the access flag in dsk.c + * printf writes to DOSEMU log if prf.c compiled with #define DOSEMU ++ fixes Bart + * dsk.c uses default BPB in the right places (with help from Tom and Brian) + * Brian's FORMAT now works + * Tab fix (bug reported by Martin Stromberg) + * INT21/AH=0x1f now simply uses AH=0x32 for the default drive ++ fixes Tom + * saved some static variables + * implementation of int_2f_111e_call() for network/LAN manager + * return AX=0001 for default redirector handler + * enable use of multiple UMBs + * fixed task.c 'LOADHIGH executables': minAlloc == maxAlloc = 0 + and an fixed overwriting the MCB 2001 Jul 9 - Build 2024/d -------- Bart Oldeman (bart.oldeman@bristol.ac.uk) + fixes Bart: diff --git a/hdr/device.h b/hdr/device.h index 6e53ba5a..cd854337 100644 --- a/hdr/device.h +++ b/hdr/device.h @@ -35,6 +35,9 @@ static BYTE *device_hRcsId = "$Id$"; /* * $Log$ + * Revision 1.7 2001/07/22 01:58:58 bartoldeman + * Support for Brian's FORMAT, DJGPP libc compilation, cleanups, MSCDEX + * * Revision 1.6 2001/06/03 14:16:17 bartoldeman * BUFFERS tuning and misc bug fixes/cleanups (2024c). * @@ -264,6 +267,75 @@ typedef struct } bpb; +#define N_RETRY 5 /* number of retries permitted */ +#define SEC_SIZE 512 /* size of sector in bytes */ + +#define LBA_READ 0x4200 +#define LBA_WRITE 0x4300 + + +struct _bios_LBA_address_packet /* Used to access a hard disk via LBA */ + /* Added by Brian E. Reifsnyder */ +{ + unsigned char packet_size; /* size of this packet...set to 16 */ + unsigned char reserved_1; /* set to 0...unused */ + unsigned char number_of_blocks; /* 0 < number_of_blocks < 128 */ + unsigned char reserved_2; /* set to 0...unused */ + UBYTE far * buffer_address; /* addr of transfer buffer */ + unsigned long block_address; /* LBA address */ + unsigned long block_address_high; /* high bytes of LBA addr...unused */ +}; + +struct CHS { + ULONG Cylinder; + UWORD Head; + UWORD Sector; +}; + +/* DOS 4.0-7.0 drive data table (see RBIL at INT2F,AX=0803) */ +typedef struct ddtstruct +{ + struct ddtstruct FAR *ddt_next; + /* pointer to next table (offset FFFFh if last table) */ + UBYTE ddt_driveno; /* physical unit number (for INT 13) */ + UBYTE ddt_logdriveno; /* logical drive number (0=A:) */ + bpb ddt_bpb; /* BIOS Parameter Block */ + UBYTE ddt_flags; + /* bit 6: 16-bit FAT instead of 12-bit + bit 7: unsupportable disk (all accesses will return Not Ready) */ + UWORD ddt_FileOC; /* Count of Open files on Drv */ + UBYTE ddt_type; /* device type */ + UWORD ddt_descflags;/* bit flags describing drive */ + UWORD ddt_ncyl; /* number of cylinders + (for partition only, if hard disk) */ + bpb ddt_defbpb; /* BPB for default (highest) capacity supported */ + UBYTE ddt_reserved[6]; /* (part of BPB above) */ + UBYTE ddt_ltrack; /* last track accessed */ + union + { + ULONG ddt_lasttime; /* removable media: time of last access + in clock ticks (FFFFFFFFh if never) */ + struct + { + UWORD ddt_part; /* partition (FFFFh = primary, 0001h = extended) + always 0001h for DOS 5+ */ + UWORD ddt_absyl; /* absolute cylinder number of partition's + start on physical drive + (FFFFh if primary partition in DOS 4.x)*/ + } ddt_hd; + } ddt_fh; + UBYTE ddt_volume[12]; /* ASCIIZ volume label or "NO NAME " if none + (apparently taken from extended boot record + rather than root directory) */ + ULONG ddt_serialno; /* serial number */ + UBYTE ddt_fstype[9]; /* ASCIIZ filesystem type ("FAT12 " or "FAT16 ")*/ + ULONG ddt_offset; /* relative partition offset */ + BITS ddt_LBASupported:1; /* set, if INT13 extensions enabled */ + BITS ddt_WriteVerifySupported:1; +} ddt; + +/* typedef struct ddtstruct ddt;*/ + struct gblkio { UBYTE gbio_spcfunbit; diff --git a/hdr/sft.h b/hdr/sft.h index 47d5a49a..cf6a3cdc 100644 --- a/hdr/sft.h +++ b/hdr/sft.h @@ -35,6 +35,9 @@ static BYTE *sft_hRcsId = "$Id$"; /* * $Log$ + * Revision 1.5 2001/07/22 01:58:58 bartoldeman + * Support for Brian's FORMAT, DJGPP libc compilation, cleanups, MSCDEX + * * Revision 1.4 2001/07/09 22:19:33 bartoldeman * LBA/FCB/FAT/SYS/Ctrl-C/ioctl fixes + memory savings * @@ -135,6 +138,7 @@ typedef struct WORD sft_psp; /* owner psp */ WORD sft_shroff; /* Sharing offset */ WORD sft_status; /* this sft status */ + BYTE FAR * sft_ifsptr; /* pointer to IFS driver for file, 0000000h if native DOS */ } sft; diff --git a/kernel/blockio.c b/kernel/blockio.c index f7dc357c..4ad8945c 100644 --- a/kernel/blockio.c +++ b/kernel/blockio.c @@ -37,6 +37,9 @@ static BYTE *blockioRcsId = "$Id$"; /* * $Log$ + * Revision 1.12 2001/07/22 01:58:58 bartoldeman + * Support for Brian's FORMAT, DJGPP libc compilation, cleanups, MSCDEX + * * Revision 1.11 2001/07/09 22:19:33 bartoldeman * LBA/FCB/FAT/SYS/Ctrl-C/ioctl fixes + memory savings * @@ -618,9 +621,9 @@ UWORD dskxfer(COUNT dsk, ULONG blkno, VOID FAR * buf, UWORD numblocks, COUNT mod if (mode >= DSKWRITEINT26) return (IoReqHdr.r_status); -/* Changed 9/4/00 BER */ - return (IoReqHdr.r_status); - +/* Changed 9/4/00 BER + return (IoReqHdr.r_status); +*/ diff --git a/kernel/config.c b/kernel/config.c index 3446cbfb..842365e5 100644 --- a/kernel/config.c +++ b/kernel/config.c @@ -89,6 +89,9 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.25 2001/07/22 01:58:58 bartoldeman + * Support for Brian's FORMAT, DJGPP libc compilation, cleanups, MSCDEX + * * Revision 1.24 2001/07/09 22:19:33 bartoldeman * LBA/FCB/FAT/SYS/Ctrl-C/ioctl fixes + memory savings * @@ -279,8 +282,8 @@ static BYTE szBuf[256]; int singleStep = FALSE; int SkipAllConfig = FALSE; -INIT VOID zumcb_init(mcb FAR * mcbp, UWORD size); -INIT VOID mumcb_init(mcb FAR * mcbp, UWORD size); +INIT VOID zumcb_init(UCOUNT seg, UWORD size); +INIT VOID mumcb_init(UCOUNT seg, UWORD size); INIT VOID Config_Buffers(BYTE * pLine); INIT VOID sysScreenMode(BYTE * pLine); @@ -464,8 +467,7 @@ INIT void PreConfig(void) #endif /* We expect ram_top as Kbytes, so convert to paragraphs */ - mcb_init((mcb FAR *) (MK_FP(first_mcb, 0)), - ((UCOUNT)ram_top << 6) - first_mcb - 1); + mcb_init(first_mcb, ram_top*64 - first_mcb - 1); nPass = 1; } @@ -593,27 +595,65 @@ INIT VOID configDone(VOID) first_mcb = FP_SEG(lpBase) + ((FP_OFF(lpBase) + 0x0f) >> 4); /* We expect ram_top as Kbytes, so convert to paragraphs */ - mcb_init((mcb FAR *) (MK_FP(first_mcb, 0)), - ((UCOUNT)ram_top << 6) - first_mcb - 1); + mcb_init(first_mcb, ram_top*64 - first_mcb - 1); if(UmbState == 1) { - mumcb_init((mcb FAR *) (MK_FP(64*ram_top - 1, 0)), - umb_start - 64*ram_top); + mumcb_init(ram_top*64 - 1, umb_start - 64*ram_top); /* Check if any devices were loaded in umb */ if(umb_start != FP_SEG(upBase) ){ /* make last block normal with SC for the devices */ UCOUNT umr_new = FP_SEG(upBase) + ((FP_OFF(upBase) + 0x0f) >> 4); - mumcb_init((mcb FAR *) (MK_FP(uppermem_root, 0)), umr_new - uppermem_root - 1); + mumcb_init(uppermem_root, umr_new - uppermem_root - 1); uppermem_root = umr_new; - zumcb_init((mcb FAR *) (MK_FP(uppermem_root, 0)), - (umb_start + UMB_top ) - uppermem_root - 1); + zumcb_init(uppermem_root, (umb_start + UMB_top ) - uppermem_root - 1); upBase += 16; + } + + { + /* are there any more UMB's ?? + this happens, if memory mapped devces are in between + like UMB memory c800..c8ff, d8ff..efff with device at d000..d7ff + */ + + /* TE - this code + a) isn't the best I ever wrote :-( + b) works for 2 memory areas (no while(), use of UMB_top,...) + and the first discovered is the larger one. + no idea what happens, if the larger one is higher in memory. + might work, though + */ + + UCOUNT umb_seg, umb_size, umbz_root; + + umbz_root = uppermem_root; + + if(UMB_get_largest(&umb_seg, &umb_size)){ + + mcb_init(umbz_root, (umb_start + UMB_top ) - uppermem_root - 1); + + /* change UMB 'Z' to 'M' */ + ((mcb FAR *)MK_FP(umbz_root,0))->m_type = 'M'; + + /* move to end */ + umbz_root += ((mcb FAR *)MK_FP(umbz_root,0))->m_size + 1; + + /* create link mcb */ + mumcb_init(umbz_root, umb_seg - umbz_root - 1); + + /* should the UMB driver return + adjacent memory in several pieces */ + if (umb_seg - umbz_root - 1 == 0) + ((mcb FAR *)MK_FP(umbz_root,0))->m_psp = FREE_PSP; + + /* create new 'Z' mcb */ + zumcb_init(umb_seg, umb_size - 1); + } } } @@ -721,13 +761,19 @@ INIT VOID DoConfig(VOID) /* might have been the UMB driver */ if(UmbState == 2){ - if(!Umb_Test()){ + + UCOUNT umb_seg, umb_size; + + if(UMB_get_largest(&umb_seg, &umb_size)){ UmbState = 1; - upBase = MK_FP(umb_start , 0); + upBase = MK_FP(umb_seg , 0); + UMB_top = umb_size; + umb_start = umb_seg; + /* reset root */ - uppermem_root = umb_start; + uppermem_root = umb_seg; /* setup the real mcb for the devicehigh block */ - zumcb_init((mcb FAR *) upBase, UMB_top - 1); + zumcb_init(umb_seg, UMB_top - 1); upBase += 16; } } @@ -1429,10 +1475,12 @@ INIT COUNT toupper(COUNT c) #if 1 /* ifdef KERNEL */ INIT VOID - mcb_init(mcb FAR * mcbp, UWORD size) + mcb_init(UCOUNT seg, UWORD size) { COUNT i; + mcb FAR * mcbp = MK_FP(seg,0); + mcbp->m_type = MCB_LAST; mcbp->m_psp = FREE_PSP; @@ -1448,9 +1496,11 @@ INIT VOID } INIT VOID - zumcb_init(mcb FAR * mcbp, UWORD size) + zumcb_init(UCOUNT seg, UWORD size) { COUNT i; + mcb FAR * mcbp = MK_FP(seg,0); + mcbp->m_type = MCB_LAST; mcbp->m_psp = FREE_PSP; mcbp->m_size = size; @@ -1460,9 +1510,11 @@ INIT VOID } INIT VOID - mumcb_init(mcb FAR * mcbp, UWORD size) + mumcb_init(UCOUNT seg, UWORD size) { COUNT i; + mcb FAR * mcbp = MK_FP(seg,0); + static char name[8] = "SC\0\0\0\0\0\0"; mcbp->m_type = MCB_NORMAL; diff --git a/kernel/disk.h b/kernel/disk.h deleted file mode 100644 index a50df6f3..00000000 --- a/kernel/disk.h +++ /dev/null @@ -1,68 +0,0 @@ -/* - DISK.H - - common constants + structures, shared between - - DSK.C and INITDISK.C - - note: - -*/ - - -#define MAX_HARD_DRIVE 8 -#define N_RETRY 5 /* number of retries permitted */ -#define NDEV 20 /* only one for demo */ -#define SEC_SIZE 512 /* size of sector in bytes */ - - -#define LBA_READ 0x4200 -#define LBA_WRITE 0x4300 - - -/* physical characteristics of a drive */ - -struct CHS { - ULONG Cylinder; - UWORD Head; - UWORD Sector; - }; - -struct DriveParamS -{ - UBYTE driveno; /* = 0x8x */ - unsigned LBA_supported:1; /* set, if INT13 extensions enabled */ - unsigned WriteVerifySupported:1; /* */ - ULONG total_sectors; - - struct CHS chs; /* for normal INT 13 */ -}; - -struct media_info -{ - struct DriveParamS drive; /* physical charactereistics of drive */ - ULONG mi_size; /* physical sector count */ - ULONG mi_offset; /* relative partition offset */ - ULONG mi_FileOC; /* Count of Open files on Drv */ - - - struct FS_info - { - ULONG serialno; - BYTE volume[11]; - BYTE fstype[8]; - }fs; - -}; - -struct _bios_LBA_address_packet /* Used to access a hard disk via LBA */ - /* Added by Brian E. Reifsnyder */ -{ - unsigned char packet_size; /* size of this packet...set to 16 */ - unsigned char reserved_1; /* set to 0...unused */ - unsigned char number_of_blocks; /* 0 < number_of_blocks < 128 */ - unsigned char reserved_2; /* set to 0...unused */ - UBYTE far * buffer_address; /* addr of transfer buffer */ - unsigned long block_address; /* LBA address */ - unsigned long block_address_high; /* high bytes of LBA addr...unused */ -}; diff --git a/kernel/dosfns.c b/kernel/dosfns.c index b77f73cc..f1c1bbeb 100644 --- a/kernel/dosfns.c +++ b/kernel/dosfns.c @@ -37,6 +37,9 @@ static BYTE *dosfnsRcsId = "$Id$"; * /// Added SHARE support. 2000/09/04 Ron Cemer * * $Log$ + * Revision 1.20 2001/07/22 01:58:58 bartoldeman + * Support for Brian's FORMAT, DJGPP libc compilation, cleanups, MSCDEX + * * Revision 1.19 2001/07/09 22:19:33 bartoldeman * LBA/FCB/FAT/SYS/Ctrl-C/ioctl fixes + memory savings * @@ -241,7 +244,7 @@ static int share_lock_unlock /* /// End of additions for SHARE. - Ron Cemer */ -static VOID DosGetFile(BYTE FAR * lpszPath, BYTE FAR * lpszDosFileName) +static VOID DosGetFile(BYTE * lpszPath, BYTE FAR * lpszDosFileName) { BYTE szLclName[FNAME_SIZE + 1]; BYTE szLclExt[FEXT_SIZE + 1]; @@ -543,6 +546,7 @@ UCOUNT DosWrite(COUNT hndl, UCOUNT n, BYTE FAR * bp, COUNT FAR * err) break; case HT: do cso(' '); while ((++scr_pos) & 7); + break; default: scr_pos++; } @@ -844,16 +848,16 @@ COUNT DosCreat(BYTE FAR * fname, COUNT attrib) } /* /// End of additions for SHARE. - Ron Cemer */ - sftp->sft_status = dos_creat(fname, attrib); + sftp->sft_status = dos_creat(PriPathName, attrib); if (sftp->sft_status >= 0) { p->ps_filetab[hndl] = sft_idx; sftp->sft_count += 1; sftp->sft_mode = SFT_MRDWR; sftp->sft_attrib = attrib; - sftp->sft_flags = 0; + sftp->sft_flags = drive; sftp->sft_psp = cu_psp; - DosGetFile(fname, sftp->sft_name); + DosGetFile(PriPathName, sftp->sft_name); return hndl; } else { /* /// Added for SHARE *** CURLY BRACES ADDED ALSO!!! ***. - Ron Cemer */ @@ -951,9 +955,7 @@ COUNT DosOpen(BYTE FAR * fname, COUNT mode) WORD sft_idx; sft FAR *sftp; struct dhdr FAR *dhp; -/* BYTE FAR *froot;*/ -/* WORD i;*/ - COUNT drive, result; + COUNT drive, result; /* /// Added to adjust for filenames which begin with ".\" The problem was manifesting itself in the inability @@ -962,7 +964,7 @@ COUNT DosOpen(BYTE FAR * fname, COUNT mode) contained ".", unless you explicitly specified the full path to the executable file. Jun 11, 2000 - rbc */ - if ( (fname[0] == '.') && (fname[1] == '\\') ) fname += 2; + if ( (fname[0] == '.') && ((fname[1] == '\\') || (fname[1] == '/'))) fname += 2; /* test if mode is in range */ if ((mode & ~SFT_OMASK) != 0) @@ -979,48 +981,52 @@ COUNT DosOpen(BYTE FAR * fname, COUNT mode) if ((sftp = get_free_sft((WORD FAR *) & sft_idx)) == (sft FAR *) - 1) return DE_TOOMANY; - sftp->sft_shroff = -1; /* /// Added for SHARE - Ron Cemer */ - - sftp->sft_mode = mode; + fmemset(sftp, 0, sizeof(sft)); /* check for a device */ - dhp = IsDevice(fname); - if ( dhp ) - { - sftp->sft_count += 1; - sftp->sft_attrib = 0; - sftp->sft_flags = - ((dhp->dh_attr & ~SFT_MASK) & ~SFT_FSHARED) | SFT_FDEVICE | SFT_FEOF; - sftp->sft_psp = cu_psp; - fbcopy((BYTE FAR *) SecPathName, sftp->sft_name, FNAME_SIZE + FEXT_SIZE); - sftp->sft_dev = dhp; - sftp->sft_date = dos_getdate(); - sftp->sft_time = dos_gettime(); - p->ps_filetab[hndl] = sft_idx; - return hndl; - } + dhp = IsDevice(fname); + if ( dhp ) + { + sftp->sft_shroff = -1; /* /// Added for SHARE - Ron Cemer */ - drive = get_verify_drive(fname); - if (drive < 0) { - return drive; - } + sftp->sft_mode = mode; - result = truename(fname, PriPathName, FALSE); - if (result != SUCCESS) { - return result; - } + sftp->sft_count += 1; + sftp->sft_flags = + ((dhp->dh_attr & ~SFT_MASK) & ~SFT_FSHARED) | SFT_FDEVICE | SFT_FEOF; + sftp->sft_psp = cu_psp; + fbcopy((BYTE FAR *) SecPathName, sftp->sft_name, FNAME_SIZE + FEXT_SIZE); + sftp->sft_dev = dhp; + sftp->sft_date = dos_getdate(); + sftp->sft_time = dos_gettime(); + p->ps_filetab[hndl] = sft_idx; + return hndl; + } - if (CDSp->cds_table[drive].cdsFlags & CDSNETWDRV) { - lpCurSft = (sfttbl FAR *)sftp; - result = -int2f_Remote_call(REM_OPEN, 0, 0, 0, (VOID FAR *) sftp, 0, MK_FP(0, mode)); - if (result == SUCCESS) { - sftp->sft_count += 1; - p->ps_filetab[hndl] = sft_idx; - return hndl; - } - return result; + drive = get_verify_drive(fname); + if (drive < 0) { + return drive; + } + + result = truename(fname, PriPathName, FALSE); + if (result != SUCCESS) { + return result; } + if (CDSp->cds_table[drive].cdsFlags & CDSNETWDRV) { + lpCurSft = (sfttbl FAR *)sftp; + result = -int2f_Remote_call(REM_OPEN, 0, 0, 0, (VOID FAR *) sftp, 0, MK_FP(0, mode)); + if (result == SUCCESS) { + sftp->sft_count += 1; + p->ps_filetab[hndl] = sft_idx; + return hndl; + } + return result; + } + sftp->sft_shroff = -1; /* /// Added for SHARE - Ron Cemer */ + + sftp->sft_mode = mode; + /* /// Added for SHARE. - Ron Cemer */ if (IsShareInstalled()) { if ((sftp->sft_shroff = share_open_check @@ -1032,7 +1038,7 @@ COUNT DosOpen(BYTE FAR * fname, COUNT mode) } /* /// End of additions for SHARE. - Ron Cemer */ - sftp->sft_status = dos_open(fname, mode); + sftp->sft_status = dos_open(PriPathName, mode); if (sftp->sft_status >= 0) { @@ -1050,10 +1056,9 @@ COUNT DosOpen(BYTE FAR * fname, COUNT mode) sftp->sft_count += 1; sftp->sft_mode = mode; - sftp->sft_attrib = 0; - sftp->sft_flags = 0; + sftp->sft_flags = drive; sftp->sft_psp = cu_psp; - DosGetFile(fname, sftp->sft_name); + DosGetFile(PriPathName, sftp->sft_name); return hndl; } else { /* /// Added for SHARE *** CURLY BRACES ADDED ALSO!!! ***. - Ron Cemer */ @@ -1119,7 +1124,7 @@ VOID DosGetFree(UBYTE drive, COUNT FAR * spc, COUNT FAR * navc, COUNT FAR * bps, { struct dpb FAR *dpbp; struct cds FAR *cdsp; - static COUNT rg[4]; + COUNT rg[4]; /* next - "log" in the drive */ drive = (drive == 0 ? default_drive : drive - 1); @@ -1244,7 +1249,7 @@ COUNT DosChangeDir(BYTE FAR * s) COUNT DosFindFirst(UCOUNT attr, BYTE FAR * name) { - COUNT nDrive; + COUNT nDrive, rc; REG dmatch FAR *dmp = (dmatch FAR *) dta; /* /// Added code here to do matching against device names. @@ -1256,19 +1261,6 @@ COUNT DosFindFirst(UCOUNT attr, BYTE FAR * name) - Ron Cemer */ fmemset(dmp, 0, sizeof(dmatch)); - nDrive=get_verify_drive(name); - if (nDrive < 0) - return nDrive; - - current_ldt = &CDSp->cds_table[nDrive]; - if (current_ldt->cdsFlags & CDSNETWDRV) - { - COUNT rc = -Remote_find(REM_FINDFIRST, attr, name); - if (dmp->dm_drive & 0x80) - return rc; - fmemset(dmp, 0, sizeof(dmatch)); - /* still have to resolve locally if dm_drive not set to remote */ - } if (IsDevice(name)) { /* Found a matching device. Hence there cannot be wildcards. */ @@ -1279,7 +1271,27 @@ COUNT DosFindFirst(UCOUNT attr, BYTE FAR * name) return SUCCESS; } /* /// End of additions. - Ron Cemer ; heavily edited - Bart Oldeman */ - return dos_findfirst(attr, name); + + nDrive=get_verify_drive(name); + if (nDrive < 0) + return nDrive; + SAttr = (BYTE) attr; + + current_ldt = &CDSp->cds_table[nDrive]; + + rc = truename(name, PriPathName, FALSE); + if (rc != SUCCESS) + return rc; + + if (current_ldt->cdsFlags & CDSNETWDRV) + { + return -Remote_find(REM_FINDFIRST); + } + else + { + dmp->dm_drive = nDrive; + return dos_findfirst(attr, PriPathName); + } } COUNT DosFindNext(void) @@ -1311,7 +1323,7 @@ COUNT DosFindNext(void) ((dmatch FAR *)dta)->dm_drive); #endif return (((dmatch FAR *)dta)->dm_drive & 0x80) ? - -Remote_find(REM_FINDNEXT, 0, NULL) : + -Remote_find(REM_FINDNEXT) : dos_findnext(); } @@ -1376,9 +1388,9 @@ COUNT DosSetFtime(COUNT hndl, date FAR * dp, time FAR * tp) return dos_setftime(s->sft_status, dp, tp); } -COUNT DosGetFattr(BYTE FAR * name, UWORD FAR * attrp) +COUNT DosGetFattr(BYTE FAR * name) { - static UWORD srfa[5]; + UWORD srfa[5]; COUNT result, drive; struct cds FAR *last_cds; @@ -1402,8 +1414,7 @@ COUNT DosGetFattr(BYTE FAR * name, UWORD FAR * attrp) && (PriPathName[1] == ':') && ( (PriPathName[2] == '/') || (PriPathName[2] == '\\') ) && (PriPathName[3] == '\0') ) { - *attrp = 0x10; - return SUCCESS; + return 0x10; } if (CDSp->cds_table[drive].cdsFlags & CDSNETWDRV) @@ -1412,8 +1423,7 @@ COUNT DosGetFattr(BYTE FAR * name, UWORD FAR * attrp) current_ldt = &CDSp->cds_table[drive]; result = -int2f_Remote_call(REM_GETATTRZ, 0, 0, 0, 0, 0, (VOID FAR *) srfa); current_ldt = last_cds; - *attrp = srfa[0]; - return result; + return (result < SUCCESS ? result : srfa[0]); } else { /* /// Use truename()'s result, which we already have in PriPathName. @@ -1443,13 +1453,13 @@ COUNT DosGetFattr(BYTE FAR * name, UWORD FAR * attrp) and suddenly, the filehandle stays open shit. tom - */ - return dos_getfattr(name, attrp); + */ + return dos_getfattr(PriPathName); } } -COUNT DosSetFattr(BYTE FAR * name, UWORD FAR * attrp) +COUNT DosSetFattr(BYTE FAR * name, UWORD attrp) { COUNT result, drive; struct cds FAR *last_cds; @@ -1488,7 +1498,7 @@ COUNT DosSetFattr(BYTE FAR * name, UWORD FAR * attrp) see DosGetAttr() */ - return dos_setfattr(name, attrp); + return dos_setfattr(PriPathName, attrp); } } @@ -1530,7 +1540,7 @@ COUNT DosDelete(BYTE FAR *path) if (CDSp->cds_table[drive].cdsFlags & CDSNETWDRV) { return -int2f_Remote_call(REM_DELETE, 0, 0, 0, 0, 0, 0); } else { - return dos_delete(path); + return dos_delete(PriPathName); } } @@ -1559,7 +1569,7 @@ COUNT DosRename(BYTE FAR * path1, BYTE FAR * path2) if (CDSp->cds_table[drive1].cdsFlags & CDSNETWDRV) { return -int2f_Remote_call(REM_RENAME, 0, 0, 0, 0, 0, 0); } else { - return dos_rename(path1, path2); + return dos_rename(PriPathName, SecPathName); } } @@ -1583,7 +1593,7 @@ COUNT DosMkdir(BYTE FAR * dir) if (CDSp->cds_table[drive].cdsFlags & CDSNETWDRV) { return -int2f_Remote_call(REM_MKDIR, 0, 0, 0, 0, 0, 0); } else { - return dos_mkdir(dir); + return dos_mkdir(PriPathName); } } @@ -1607,7 +1617,7 @@ COUNT DosRmdir(BYTE FAR * dir) if (CDSp->cds_table[drive].cdsFlags & CDSNETWDRV) { return -int2f_Remote_call(REM_RMDIR, 0, 0, 0, 0, 0, 0); } else { - return dos_rmdir(dir); + return dos_rmdir(PriPathName); } } diff --git a/kernel/dosnames.c b/kernel/dosnames.c index 3bf2939e..c7f172b4 100644 --- a/kernel/dosnames.c +++ b/kernel/dosnames.c @@ -36,6 +36,9 @@ static BYTE *dosnamesRcsId = "$Id$"; /* * $Log$ + * Revision 1.10 2001/07/22 01:58:58 bartoldeman + * Support for Brian's FORMAT, DJGPP libc compilation, cleanups, MSCDEX + * * Revision 1.9 2001/06/03 14:16:17 bartoldeman * BUFFERS tuning and misc bug fixes/cleanups (2024c). * @@ -130,7 +133,7 @@ static BYTE *dosnamesRcsId = "$Id$"; #define WildChar(c) (!strchr(".\"/\\[]:|<>+=;,", (c))) VOID XlateLcase(BYTE * szFname, COUNT nChars); -VOID DosTrimPath(BYTE FAR * lpszPathNamep); +VOID DosTrimPath(BYTE * lpszPathNamep); /* Should be converted to a portable version after v1.0 is released. */ VOID XlateLcase(BYTE * szFname, COUNT nChars) @@ -157,7 +160,7 @@ VOID SpacePad(BYTE * szString, COUNT nChars) (..) == Back one directory *.* */ -COUNT ParseDosName(BYTE FAR * lpszFileName, +COUNT ParseDosName(BYTE * lpszFileName, COUNT * pnDrive, BYTE * pszDir, BYTE * pszFile, @@ -167,9 +170,9 @@ COUNT ParseDosName(BYTE FAR * lpszFileName, COUNT nDirCnt, nFileCnt, nExtCnt; - BYTE FAR *lpszLclDir, - FAR * lpszLclFile, - FAR * lpszLclExt; + BYTE *lpszLclDir, + *lpszLclFile, + *lpszLclExt; /* Initialize the users data fields */ if (pszDir) @@ -237,7 +240,7 @@ COUNT ParseDosName(BYTE FAR * lpszFileName, nDirCnt += 2; if (nDirCnt > PARSE_MAX-1) nDirCnt = PARSE_MAX-1; - fbcopy(lpszLclDir, (BYTE FAR *) pszDir, nDirCnt); + bcopy(lpszLclDir, pszDir, nDirCnt); if (((lpszFileName - lpszLclFile) == 2) && (nDirCnt < PARSE_MAX)) pszDir[nDirCnt++] = '\\'; /* make DosTrimPath() enjoy, for tail DotDot */ pszDir[nDirCnt] = '\0'; @@ -292,17 +295,17 @@ COUNT ParseDosName(BYTE FAR * lpszFileName, /* buffers. */ if (pszDir) { - fbcopy(lpszLclDir, (BYTE FAR *) pszDir, nDirCnt); + bcopy(lpszLclDir, pszDir, nDirCnt); pszDir[nDirCnt] = '\0'; } if (pszFile) { - fbcopy(lpszLclFile, (BYTE FAR *) pszFile, nFileCnt); + bcopy(lpszLclFile, pszFile, nFileCnt); pszFile[nFileCnt] = '\0'; } if (pszExt) { - fbcopy(lpszLclExt, (BYTE FAR *) pszExt, nExtCnt); + bcopy(lpszLclExt, pszExt, nExtCnt); pszExt[nExtCnt] = '\0'; } @@ -314,14 +317,16 @@ COUNT ParseDosName(BYTE FAR * lpszFileName, return SUCCESS; } -COUNT ParseDosPath(BYTE FAR * lpszFileName, +#if 0 +/* not necessary anymore because of truename */ +COUNT ParseDosPath(BYTE * lpszFileName, COUNT * pnDrive, BYTE * pszDir, - BYTE FAR * pszCurPath) + BYTE * pszCurPath) { COUNT nDirCnt, nPathCnt; - BYTE FAR *lpszLclDir, + BYTE *lpszLclDir, *pszBase = pszDir; /* Initialize the users data fields */ @@ -379,12 +384,12 @@ COUNT ParseDosPath(BYTE FAR * lpszFileName, /* buffers. */ if (pszDir) { - fbcopy(lpszLclDir, (BYTE FAR *) pszDir, nDirCnt); + bcopy(lpszLclDir, pszDir, nDirCnt); pszDir[nDirCnt] = '\0'; } /* Clean up before leaving */ - DosTrimPath((BYTE FAR *) pszBase); + DosTrimPath(pszBase); /* Before returning to the user, eliminate any useless */ /* trailing "\\." since the path prior to this is sufficient. */ @@ -402,13 +407,13 @@ COUNT ParseDosPath(BYTE FAR * lpszFileName, return SUCCESS; } +#endif - -VOID DosTrimPath(BYTE FAR * lpszPathNamep) +VOID DosTrimPath(BYTE * lpszPathNamep) { - BYTE FAR *lpszLast, - FAR * lpszNext, - FAR * lpszRoot = (BYTE FAR *) 0; + BYTE *lpszLast, + *lpszNext, + *lpszRoot = NULL; COUNT nChars, flDotDot; @@ -477,6 +482,7 @@ VOID DosTrimPath(BYTE FAR * lpszPathNamep) else if (*(lpszNext + 2) == '\\') { fstrncpy(lpszNext, lpszNext + 2, NAMEMAX); + flDotDot = TRUE; } /* If we're at the end of a string, */ /* just exit. */ diff --git a/kernel/dsk.c b/kernel/dsk.c index c4a8a4cc..513e4e7c 100644 --- a/kernel/dsk.c +++ b/kernel/dsk.c @@ -26,13 +26,15 @@ #include "portab.h" #include "globals.h" -#include "disk.h" #ifdef VERSION_STRINGS static BYTE *dskRcsId = "$Id$"; #endif /* * $Log$ + * Revision 1.18 2001/07/22 01:58:58 bartoldeman + * Support for Brian's FORMAT, DJGPP libc compilation, cleanups, MSCDEX + * * Revision 1.17 2001/07/09 22:19:33 bartoldeman * LBA/FCB/FAT/SYS/Ctrl-C/ioctl fixes + memory savings * @@ -152,7 +154,7 @@ static BYTE *dskRcsId = "$Id$"; #define DebugPrintf(x) #endif -#define STATIC +/* #define STATIC */ @@ -170,7 +172,7 @@ COUNT fl_verify(WORD, WORD, WORD, WORD, WORD, BYTE FAR *); extern COUNT fl_lba_ReadWrite (BYTE drive, WORD mode, struct _bios_LBA_address_packet FAR *dap_p); -int LBA_Transfer(struct DriveParamS *driveParam ,UWORD mode, VOID FAR *buffer, +int LBA_Transfer(ddt *pddt ,UWORD mode, VOID FAR *buffer, ULONG LBA_address,unsigned total, UWORD *transferred); #else BOOL fl_reset(); @@ -207,13 +209,18 @@ static struct Access_info BYTE AI_Flag; }; -struct media_info *miarrayptr; /* Internal media info structs */ -bpb bpbarray[NDEV]; /* BIOS parameter blocks */ +struct FS_info +{ + ULONG serialno; + BYTE volume[11]; + BYTE fstype[8]; +}; + +ddt *pddt0; /* Internal media info structs */ /* STATIC bpb *bpbptrs[NDEV]; pointers to bpbs */ /*TE - array access functions */ -struct media_info *getPMiarray(int dev) { return &miarrayptr[dev];} - bpb *getPBpbarray(unsigned dev){ return &bpbarray[dev];} +ddt *getddt(int dev) { return &pddt0[dev];} #define N_PART 4 /* number of partitions per table partition */ @@ -225,20 +232,20 @@ COUNT nUnits; /* number of returned units */ #ifdef PROTO WORD - _dsk_init (rqptr rq, struct media_info *pmiarray), - mediachk (rqptr rq, struct media_info *pmiarray), - bldbpb (rqptr rq, struct media_info *pmiarray), - blockio (rqptr rq, struct media_info *pmiarray), - IoctlQueblk(rqptr rq, struct media_info *pmiarray), - Genblkdev (rqptr rq, struct media_info *pmiarray), - Getlogdev (rqptr rq, struct media_info *pmiarray), - Setlogdev (rqptr rq, struct media_info *pmiarray), - blk_Open (rqptr rq, struct media_info *pmiarray), - blk_Close (rqptr rq, struct media_info *pmiarray), - blk_Media (rqptr rq, struct media_info *pmiarray), - blk_noerr (rqptr rq, struct media_info *pmiarray), - blk_nondr (rqptr rq, struct media_info *pmiarray), - blk_error (rqptr rq, struct media_info *pmiarray); + _dsk_init (rqptr rq, ddt *pddt), + mediachk (rqptr rq, ddt *pddt), + bldbpb (rqptr rq, ddt *pddt), + blockio (rqptr rq, ddt *pddt), + IoctlQueblk(rqptr rq, ddt *pddt), + Genblkdev (rqptr rq, ddt *pddt), + Getlogdev (rqptr rq, ddt *pddt), + Setlogdev (rqptr rq, ddt *pddt), + blk_Open (rqptr rq, ddt *pddt), + blk_Close (rqptr rq, ddt *pddt), + blk_Media (rqptr rq, ddt *pddt), + blk_noerr (rqptr rq, ddt *pddt), + blk_nondr (rqptr rq, ddt *pddt), + blk_error (rqptr rq, ddt *pddt); WORD dskerr(COUNT); #else WORD _dsk_init(), @@ -263,7 +270,7 @@ WORD dskerr(); /* */ #ifdef PROTO -static WORD(*dispatch[NENTRY]) (rqptr rq, struct media_info *pmiarray) = +static WORD(*dispatch[NENTRY]) (rqptr rq, ddt *pddt) = #else static WORD(*dispatch[NENTRY]) () = #endif @@ -319,21 +326,21 @@ COUNT FAR blk_driver(rqptr rp) return failure(E_FAILURE); /* general failure */ } else - return ((*dispatch[rp->r_command]) (rp, getPMiarray(rp->r_unit))); + return ((*dispatch[rp->r_command]) (rp, getddt(rp->r_unit))); } /* disk init is done in diskinit.c, so this should never be called */ -WORD _dsk_init(rqptr rp, struct media_info *pmiarray) +WORD _dsk_init(rqptr rp, ddt *pddt) { UNREFERENCED_PARAMETER(rp); - UNREFERENCED_PARAMETER(pmiarray); + UNREFERENCED_PARAMETER(pddt); fatal("No disk init!"); return S_DONE; /* to keep the compiler happy */ } -WORD mediachk(rqptr rp, struct media_info *pmiarray) +WORD mediachk(rqptr rp, ddt *pddt) { - COUNT drive = pmiarray->drive.driveno; + COUNT drive = pddt->ddt_driveno; COUNT result; /* if it's a hard drive, media never changes */ @@ -365,24 +372,24 @@ WORD mediachk(rqptr rp, struct media_info *pmiarray) */ STATIC WORD RWzero(rqptr rp, WORD t) { - struct media_info *pmiarray = getPMiarray(rp->r_unit); + ddt *pddt = getddt(rp->r_unit); UWORD done; - return LBA_Transfer(&pmiarray->drive, + return LBA_Transfer(pddt, t == 0 ? LBA_READ : LBA_WRITE, (UBYTE FAR *)&DiskTransferBuffer, - pmiarray->mi_offset,1,&done); + pddt->ddt_offset,1,&done); } /* 0 if not set, 1 = a, 2 = b, etc, assume set. page 424 MS Programmer's Ref. */ -static WORD Getlogdev(rqptr rp, struct media_info *pmiarray) +static WORD Getlogdev(rqptr rp, ddt *pddt) { BYTE x = rp->r_unit; - UNREFERENCED_PARAMETER(pmiarray); + UNREFERENCED_PARAMETER(pddt); x++; if( x > nblk_rel ) @@ -392,69 +399,78 @@ static WORD Getlogdev(rqptr rp, struct media_info *pmiarray) return S_DONE; } -static WORD Setlogdev(rqptr rp, struct media_info *pmiarray) +static WORD Setlogdev(rqptr rp, ddt *pddt) { UNREFERENCED_PARAMETER(rp); - UNREFERENCED_PARAMETER(pmiarray); + UNREFERENCED_PARAMETER(pddt); return S_DONE; } -static WORD blk_Open(rqptr rp, struct media_info *pmiarray) +static WORD blk_Open(rqptr rp, ddt *pddt) { UNREFERENCED_PARAMETER(rp); - pmiarray->mi_FileOC++; + pddt->ddt_FileOC++; return S_DONE; } -static WORD blk_Close(rqptr rp, struct media_info *pmiarray) +static WORD blk_Close(rqptr rp, ddt *pddt) { UNREFERENCED_PARAMETER(rp); - pmiarray->mi_FileOC--; + pddt->ddt_FileOC--; return S_DONE; } -static WORD blk_nondr(rqptr rp, struct media_info *pmiarray) +static WORD blk_nondr(rqptr rp, ddt *pddt) { UNREFERENCED_PARAMETER(rp); - UNREFERENCED_PARAMETER(pmiarray); + UNREFERENCED_PARAMETER(pddt); return S_BUSY|S_DONE; } -static WORD blk_Media(rqptr rp, struct media_info *pmiarray) +static WORD blk_Media(rqptr rp, ddt *pddt) { UNREFERENCED_PARAMETER(rp); - if (hd( pmiarray->drive.driveno)) + if (hd( pddt->ddt_driveno)) return S_BUSY|S_DONE; /* Hard Drive */ else return S_DONE; /* Floppy */ } -STATIC WORD bldbpb(rqptr rp, struct media_info *pmiarray) +STATIC WORD bldbpb(rqptr rp, ddt *pddt) { ULONG count; - bpb *pbpbarray; + bpb *pbpbarray = &pddt->ddt_bpb; WORD head,/*track,*/sector,ret; ret = RWzero( rp, 0); + getword(&((((BYTE *) & DiskTransferBuffer[BT_BPB]))[BPB_NBYTE]), &pbpbarray->bpb_nbyte); + + pddt->ddt_descflags |= 0x200; /* set drive to not accessible */ if (ret != 0) - return (dskerr(ret)); + return (dskerr(ret)); + + if (DiskTransferBuffer[0x1fe]!=0x55 || DiskTransferBuffer[0x1ff]!=0xaa || + pbpbarray->bpb_nbyte != 512) { + /* copy default bpb to be sure that there is no bogus data */ + memcpy(pbpbarray, &pddt->ddt_defbpb, sizeof(bpb)); + return S_DONE; + } + + pddt->ddt_descflags &= ~0x200; /* set drive to accessible */ /*TE ~ 200 bytes*/ - pbpbarray = getPBpbarray(rp->r_unit); - getword(&((((BYTE *) & DiskTransferBuffer[BT_BPB]))[BPB_NBYTE]), &pbpbarray->bpb_nbyte); getbyte(&((((BYTE *) & DiskTransferBuffer[BT_BPB]))[BPB_NSECTOR]), &pbpbarray->bpb_nsector); getword(&((((BYTE *) & DiskTransferBuffer[BT_BPB]))[BPB_NRESERVED]), &pbpbarray->bpb_nreserved); getbyte(&((((BYTE *) & DiskTransferBuffer[BT_BPB]))[BPB_NFAT]), &pbpbarray->bpb_nfat); getword(&((((BYTE *) & DiskTransferBuffer[BT_BPB]))[BPB_NDIRENT]), &pbpbarray->bpb_ndirent); getword(&((((BYTE *) & DiskTransferBuffer[BT_BPB]))[BPB_NSIZE]), &pbpbarray->bpb_nsize); - getword(&((((BYTE *) & DiskTransferBuffer[BT_BPB]))[BPB_NSIZE]), &pbpbarray->bpb_nsize); getbyte(&((((BYTE *) & DiskTransferBuffer[BT_BPB]))[BPB_MDESC]), &pbpbarray->bpb_mdesc); getword(&((((BYTE *) & DiskTransferBuffer[BT_BPB]))[BPB_NFSECT]), &pbpbarray->bpb_nfsect); getword(&((((BYTE *) & DiskTransferBuffer[BT_BPB]))[BPB_NSECS]), &pbpbarray->bpb_nsecs); @@ -466,10 +482,10 @@ STATIC WORD bldbpb(rqptr rp, struct media_info *pmiarray) /* Needs fat32 offset code */ - getlong(&((((BYTE *) & DiskTransferBuffer[0x27])[0])), &pmiarray->fs.serialno); + getlong(&((((BYTE *) & DiskTransferBuffer[0x27])[0])), &pddt->ddt_serialno); - memcpy(pmiarray->fs.volume,&DiskTransferBuffer[0x2B], 11); - memcpy(pmiarray->fs.fstype,&DiskTransferBuffer[0x36], 8); + memcpy(pddt->ddt_volume,&DiskTransferBuffer[0x2B], 11); + memcpy(pddt->ddt_fstype,&DiskTransferBuffer[0x36], 8); @@ -486,23 +502,19 @@ STATIC WORD bldbpb(rqptr rp, struct media_info *pmiarray) rp->r_bpptr = pbpbarray; - count = pmiarray->mi_size = + count = pbpbarray->bpb_nsize == 0 ? pbpbarray->bpb_huge : pbpbarray->bpb_nsize; - getword((&(((BYTE *) & DiskTransferBuffer[BT_BPB])[BPB_NHEADS])), &pmiarray->drive.chs.Head); - head = pmiarray->drive.chs.Head; - getword((&(((BYTE *) & DiskTransferBuffer[BT_BPB])[BPB_NSECS])), &pmiarray->drive.chs.Sector); - if (pmiarray->mi_size == 0) - getlong(&((((BYTE *) & DiskTransferBuffer[BT_BPB])[BPB_HUGE])), &pmiarray->mi_size); - sector = pmiarray->drive.chs.Sector; + head = pbpbarray->bpb_nheads; + sector = pbpbarray->bpb_nsecs; if (head == 0 || sector == 0) { tmark(); return failure(E_FAILURE); } - pmiarray->drive.chs.Cylinder = count / (head * sector); + pddt->ddt_ncyl = count / (head * sector); tmark(); #ifdef DSK_DEBUG @@ -515,9 +527,9 @@ STATIC WORD bldbpb(rqptr rp, struct media_info *pmiarray) } -static WORD IoctlQueblk(rqptr rp, struct media_info *pmiarray) +static WORD IoctlQueblk(rqptr rp, ddt *pddt) { - UNREFERENCED_PARAMETER(pmiarray); + UNREFERENCED_PARAMETER(pddt); switch(rp->r_count){ case 0x0846: @@ -533,9 +545,10 @@ static WORD IoctlQueblk(rqptr rp, struct media_info *pmiarray) } -STATIC WORD Genblkdev(rqptr rp,struct media_info *pmiarray) +STATIC WORD Genblkdev(rqptr rp,ddt *pddt) { int ret; + bpb FAR *pbpb; switch(rp->r_count){ case 0x0860: /* get device parameters */ @@ -543,11 +556,10 @@ STATIC WORD Genblkdev(rqptr rp,struct media_info *pmiarray) struct gblkio FAR * gblp = (struct gblkio FAR *) rp->r_trans; REG COUNT x = 5,y = 1,z = 0; - if (!hd(pmiarray->drive.driveno)){ + if (!hd(pddt->ddt_driveno)){ y = 2; x = 8; /* any odd ball drives return this */ - if (pmiarray->mi_size <= 0xffff) - switch((UWORD)pmiarray->mi_size) + switch(pddt->ddt_bpb.bpb_nsize) { case 640: case 720: /* 320-360 */ @@ -571,19 +583,30 @@ STATIC WORD Genblkdev(rqptr rp,struct media_info *pmiarray) gblp->gbio_devtype = (UBYTE) x; gblp->gbio_devattrib = (UWORD) y; gblp->gbio_media = (UBYTE) z; - gblp->gbio_ncyl = pmiarray->drive.chs.Cylinder; - fmemcpy(&gblp->gbio_bpb, &bpbarray[rp->r_unit], sizeof(gblp->gbio_bpb)); - gblp->gbio_nsecs = bpbarray[rp->r_unit].bpb_nsector; + gblp->gbio_ncyl = pddt->ddt_ncyl; + /* use default dpb or current bpb? */ + pbpb = (gblp->gbio_spcfunbit & 0x01) == 0 ? &pddt->ddt_defbpb : &pddt->ddt_bpb; + fmemcpy(&gblp->gbio_bpb, pbpb, sizeof(gblp->gbio_bpb)); + gblp->gbio_spcfunbit |= 0x04; /* bit 2 set if all sectors in track same size (should be set) */ + gblp->gbio_nsecs = pbpb->bpb_nsector; break; } case 0x0866: /* get volume serial number */ { struct Gioc_media FAR * gioc = (struct Gioc_media FAR *) rp->r_trans; - struct FS_info FAR * fs = &pmiarray->fs; + struct FS_info FAR * fs = (struct FS_info FAR *) &DiskTransferBuffer[0x27]; + + ret = RWzero( rp, 0); + if (ret != 0) + return (dskerr(ret)); gioc->ioc_serialno = fs->serialno; - fmemcpy(gioc->ioc_volume,fs->volume,11); - fmemcpy(gioc->ioc_fstype, fs->fstype,8); + pddt->ddt_serialno = fs->serialno; + + fmemcpy(pddt->ddt_volume, fs->volume,11); + fmemcpy(pddt->ddt_volume, fs->fstype,8); + fmemcpy(gioc->ioc_volume, pddt->ddt_volume,11); + fmemcpy(gioc->ioc_fstype, pddt->ddt_fstype,8); } break; case 0x0846: /* set volume serial number */ @@ -596,20 +619,25 @@ STATIC WORD Genblkdev(rqptr rp,struct media_info *pmiarray) return (dskerr(ret)); fs->serialno = gioc->ioc_serialno; - pmiarray->fs.serialno = fs->serialno; + pddt->ddt_serialno = fs->serialno; ret = RWzero( rp, 1); if (ret != 0) return (dskerr(ret)); } break; - case 0x0867: /* get access flag, always on*/ + case 0x0867: /* get access flag */ { struct Access_info FAR * ai = (struct Access_info FAR *) rp->r_trans; - ai->AI_Flag = 1; + ai->AI_Flag = pddt->ddt_descflags & 0x200 ? 0 : 1; /* bit 9 */ } break; - case 0x0847: /* set access flag, no real use*/ + case 0x0847: /* set access flag */ + { + struct Access_info FAR * ai = (struct Access_info FAR *) rp->r_trans; + pddt->ddt_descflags &= ~0x200; + pddt->ddt_descflags |= (ai->AI_Flag ? 0 : 0x200); + } break; default: return failure(E_CMD); @@ -617,12 +645,13 @@ STATIC WORD Genblkdev(rqptr rp,struct media_info *pmiarray) return S_DONE; } -WORD blockio(rqptr rp, struct media_info *pmiarray) +WORD blockio(rqptr rp, ddt *pddt) { - ULONG start; + ULONG start, size; WORD ret; int action; + bpb *pbpb; switch (rp->r_command){ @@ -632,19 +661,23 @@ WORD blockio(rqptr rp, struct media_info *pmiarray) default: return failure(E_FAILURE); } - + + if (pddt->ddt_descflags & 0x200) /* drive inaccessible */ + return failure(E_FAILURE); tmark(); start = (rp->r_start != HUGECOUNT ? rp->r_start : rp->r_huge); + pbpb = hd(pddt->ddt_driveno) ? &pddt->ddt_defbpb : &pddt->ddt_bpb; + size = (pbpb->bpb_nsize ? pbpb->bpb_nsize : pbpb->bpb_huge); - if (start >= pmiarray->mi_size || - start + rp->r_count > pmiarray->mi_size) + if (start >= size || + start + rp->r_count > size) { return 0x0408; } - start += pmiarray->mi_offset; + start += pddt->ddt_offset; - ret = LBA_Transfer(&pmiarray->drive ,action, + ret = LBA_Transfer(pddt, action, rp->r_trans, start, rp->r_count,(UWORD*)&rp->r_count); @@ -655,19 +688,19 @@ WORD blockio(rqptr rp, struct media_info *pmiarray) return S_DONE; } -STATIC WORD blk_error(rqptr rp, struct media_info *pmiarray) +STATIC WORD blk_error(rqptr rp, ddt *pddt) { - UNREFERENCED_PARAMETER(pmiarray); + UNREFERENCED_PARAMETER(pddt); rp->r_count = 0; return failure(E_FAILURE); /* general failure */ } -STATIC WORD blk_noerr(rqptr rp, struct media_info *pmiarray) +STATIC WORD blk_noerr(rqptr rp, ddt *pddt) { UNREFERENCED_PARAMETER(rp); - UNREFERENCED_PARAMETER(pmiarray); + UNREFERENCED_PARAMETER(pddt); return S_DONE; } @@ -710,14 +743,14 @@ STATIC WORD dskerr(COUNT code) translate LBA sectors into CHS addressing */ -void LBA_to_CHS(struct CHS *chs, ULONG LBA_address, struct DriveParamS *driveparam) +void LBA_to_CHS(struct CHS *chs, ULONG LBA_address, ddt *pddt) { - chs->Sector = LBA_address% driveparam->chs.Sector + 1; + chs->Sector = LBA_address% pddt->ddt_bpb.bpb_nsecs + 1; - LBA_address /= driveparam->chs.Sector; + LBA_address /= pddt->ddt_bpb.bpb_nsecs; - chs->Head = LBA_address % driveparam->chs.Head; - chs->Cylinder = LBA_address / driveparam->chs.Head; + chs->Head = LBA_address % pddt->ddt_bpb.bpb_nheads; + chs->Cylinder = LBA_address / pddt->ddt_bpb.bpb_nheads; } @@ -745,7 +778,7 @@ STATIC unsigned DMA_max_transfer(void FAR *buffer, unsigned count) /* int LBA_Transfer( - struct DriveParamS *driveParam, physical characteristics of drive + ddt *pddt, physical characteristics of drive UWORD mode, LBA_READ/WRITE/WRITE_VERIFY VOID FAR *buffer, user buffer ULONG LBA_address, absolute sector address @@ -771,7 +804,7 @@ STATIC unsigned DMA_max_transfer(void FAR *buffer, unsigned count) */ -int LBA_Transfer(struct DriveParamS *driveParam ,UWORD mode, VOID FAR *buffer, +int LBA_Transfer(ddt *pddt ,UWORD mode, VOID FAR *buffer, ULONG LBA_address,unsigned totaltodo, UWORD *transferred) { static struct _bios_LBA_address_packet dap = { @@ -787,13 +820,13 @@ int LBA_Transfer(struct DriveParamS *driveParam ,UWORD mode, VOID FAR *buffer, *transferred = 0; - - if (LBA_address+totaltodo > driveParam->total_sectors) +/* + if (LBA_address+totaltodo > pddt->total_sectors) { printf("LBA-Transfer error : address overflow = %lu > %lu max\n",LBA_address+totaltodo,driveParam->total_sectors); return 1; } - +*/ for ( ;totaltodo != 0; ) { @@ -824,7 +857,7 @@ int LBA_Transfer(struct DriveParamS *driveParam ,UWORD mode, VOID FAR *buffer, for ( num_retries = 0; num_retries < N_RETRY; num_retries++) { - if (driveParam->LBA_supported) + if (pddt->ddt_LBASupported) { dap.number_of_blocks = count; @@ -836,31 +869,31 @@ int LBA_Transfer(struct DriveParamS *driveParam ,UWORD mode, VOID FAR *buffer, /* Load the registers and call the interrupt. */ - if (driveParam->WriteVerifySupported || mode != LBA_WRITE_VERIFY) + if (pddt->ddt_WriteVerifySupported || mode != LBA_WRITE_VERIFY) { - error_code = fl_lba_ReadWrite(driveParam->driveno,mode, &dap); + error_code = fl_lba_ReadWrite(pddt->ddt_driveno,mode, &dap); } else { /* verify requested, but not supported */ - error_code = fl_lba_ReadWrite(driveParam->driveno,LBA_WRITE, &dap); + error_code = fl_lba_ReadWrite(pddt->ddt_driveno,LBA_WRITE, &dap); if (error_code == 0) { - error_code = fl_lba_ReadWrite(driveParam->driveno,LBA_VERIFY, &dap); + error_code = fl_lba_ReadWrite(pddt->ddt_driveno,LBA_VERIFY, &dap); } } } else { /* transfer data, using old bios functions */ - LBA_to_CHS(&chs, LBA_address, driveParam); + LBA_to_CHS(&chs, LBA_address, pddt); /* avoid overflow at end of track */ - if (chs.Sector + count > driveParam->chs.Sector + 1) + if (chs.Sector + count > pddt->ddt_bpb.bpb_nsecs + 1) { - count = driveParam->chs.Sector + 1 - chs.Sector; + count = pddt->ddt_bpb.bpb_nsecs + 1 - chs.Sector; } if (chs.Cylinder > 1023) @@ -870,7 +903,7 @@ int LBA_Transfer(struct DriveParamS *driveParam ,UWORD mode, VOID FAR *buffer, } error_code = (mode == LBA_READ ? fl_read : fl_write)( - driveParam->driveno, + pddt->ddt_driveno, chs.Head, chs.Cylinder, chs.Sector, count, transfer_address); @@ -878,7 +911,7 @@ int LBA_Transfer(struct DriveParamS *driveParam ,UWORD mode, VOID FAR *buffer, mode == LBA_WRITE_VERIFY) { error_code = fl_verify( - driveParam->driveno, + pddt->ddt_driveno, chs.Head, chs.Cylinder, chs.Sector, count, transfer_address); } @@ -886,7 +919,7 @@ int LBA_Transfer(struct DriveParamS *driveParam ,UWORD mode, VOID FAR *buffer, if (error_code == 0) break; - fl_reset(driveParam->driveno); + fl_reset(pddt->ddt_driveno); } /* end of retries */ diff --git a/kernel/dyndata.c b/kernel/dyndata.c index 0b376f88..20aaad9c 100644 --- a/kernel/dyndata.c +++ b/kernel/dyndata.c @@ -6,6 +6,8 @@ alll data herein goes to special segment DYN_DATA AFTER BSS, but immediately before HMA_TEXT */ +#include "portab.h" +#include "init-mod.h" #include "dyndata.h" struct DynS Dyn; diff --git a/kernel/dyndata.h b/kernel/dyndata.h index ddec7aed..f35d2ab4 100644 --- a/kernel/dyndata.h +++ b/kernel/dyndata.h @@ -9,7 +9,6 @@ moveable and Dyn.Buffer resizable, but not before */ - void *DynAlloc(char far *what, unsigned num, unsigned size); void DynFree(unsigned memory_needed); void far *DynLast(void); @@ -18,7 +17,7 @@ struct DynS { unsigned Allocated; unsigned UsedByDiskInit; unsigned AllocMax; - char Buffer[1000 /* for InitDisk - Miarray's */ + char Buffer[NDEV*sizeof(ddt) /* for InitDisk - Drive Data Table */ + 16 * 71 /* initial f_nodes */ +200 /* give some extra bytes */ ]; diff --git a/kernel/fatdir.c b/kernel/fatdir.c index 3fa66b47..48ff9146 100644 --- a/kernel/fatdir.c +++ b/kernel/fatdir.c @@ -36,6 +36,9 @@ static BYTE *fatdirRcsId = "$Id$"; /* * $Log$ + * Revision 1.18 2001/07/22 01:58:58 bartoldeman + * Support for Brian's FORMAT, DJGPP libc compilation, cleanups, MSCDEX + * * Revision 1.17 2001/07/09 22:19:33 bartoldeman * LBA/FCB/FAT/SYS/Ctrl-C/ioctl fixes + memory savings * @@ -177,16 +180,14 @@ static BYTE *fatdirRcsId = "$Id$"; VOID pop_dmp(dmatch FAR *, f_node_ptr); -f_node_ptr dir_open(BYTE FAR * dirname) +f_node_ptr dir_open(BYTE * dirname) { f_node_ptr fnp; COUNT drive; BYTE *p; WORD i; - /*TEunused x; */ -/* BYTE *s;*/ struct cds FAR *cdsp; - BYTE *pszPath = &TempCDS.cdsCurrentPath[2]; + BYTE *pszPath = dirname + 2; /* Allocate an fnode if possible - error return (0) if not. */ if ((fnp = get_f_node()) == (f_node_ptr)0) @@ -197,10 +198,7 @@ f_node_ptr dir_open(BYTE FAR * dirname) /* Force the fnode into read-write mode */ fnp->f_mode = RDWR; - /* and initialize temporary CDS */ - TempCDS.cdsFlags = 0; /* determine what drive we are using... */ - dirname = adjust_far(dirname); if (ParseDosName(dirname, &drive, (BYTE *) 0, (BYTE *) 0, (BYTE *) 0, FALSE) != SUCCESS) { @@ -227,16 +225,10 @@ f_node_ptr dir_open(BYTE FAR * dirname) cdsp = &CDSp->cds_table[drive]; - TempCDS.cdsDpb = cdsp->cdsDpb; - - TempCDS.cdsCurrentPath[0] = 'A' + drive; - TempCDS.cdsCurrentPath[1] = ':'; - TempCDS.cdsJoinOffset = 2; - - i = cdsp->cdsJoinOffset; - /* Generate full path name */ - ParseDosPath(dirname, (COUNT *) 0, pszPath, (BYTE FAR *) & cdsp->cdsCurrentPath[i]); + /* not necessary anymore, since truename did that already + i = cdsp->cdsJoinOffset; + ParseDosPath(dirname, (COUNT *) 0, pszPath, (BYTE FAR *) & cdsp->cdsCurrentPath[i]); */ /* for testing only for now */ #if 0 @@ -247,24 +239,24 @@ f_node_ptr dir_open(BYTE FAR * dirname) } #endif - if (TempCDS.cdsDpb == 0) + if (cdsp->cdsDpb == 0) { release_f_node(fnp); return NULL; } - fnp->f_dpb = TempCDS.cdsDpb; + fnp->f_dpb = cdsp->cdsDpb; /* Perform all directory common handling after all special */ /* handling has been performed. */ - if (media_check(TempCDS.cdsDpb) < 0) + if (media_check(fnp->f_dpb) < 0) { release_f_node(fnp); return (f_node_ptr)0; } - fnp->f_dsize = DIRENT_SIZE * TempCDS.cdsDpb->dpb_dirents; + fnp->f_dsize = DIRENT_SIZE * fnp->f_dpb->dpb_dirents; fnp->f_diroff = 0l; fnp->f_flags.f_dmod = FALSE; /* a brand new fnode */ @@ -323,7 +315,7 @@ f_node_ptr dir_open(BYTE FAR * dirname) { if (fnp->f_dir.dir_name[0] != '\0' && fnp->f_dir.dir_name[0] != DELETED) { - if (fcmp((BYTE FAR *) TempBuffer, (BYTE FAR *) fnp->f_dir.dir_name, FNAME_SIZE + FEXT_SIZE)) + if (fcmp(TempBuffer, (BYTE *)fnp->f_dir.dir_name, FNAME_SIZE + FEXT_SIZE)) { i = TRUE; break; @@ -353,7 +345,7 @@ f_node_ptr dir_open(BYTE FAR * dirname) fnp->f_diroff = 0l; fnp->f_flags.f_dmod = FALSE; fnp->f_flags.f_dnew = TRUE; - fnp->f_dsize = DIRENT_SIZE * TempCDS.cdsDpb->dpb_dirents; + fnp->f_dsize = DIRENT_SIZE * fnp->f_dpb->dpb_dirents; } } @@ -594,15 +586,14 @@ VOID dir_close(REG f_node_ptr fnp) } #ifndef IPL -COUNT dos_findfirst(UCOUNT attr, BYTE FAR * name) +COUNT dos_findfirst(UCOUNT attr, BYTE *name) { REG f_node_ptr fnp; REG dmatch FAR *dmp = (dmatch FAR *) dta; REG COUNT i; - COUNT nDrive; BYTE *p; - static BYTE local_name[FNAME_SIZE + 1], + BYTE local_name[FNAME_SIZE + 1], local_ext[FEXT_SIZE + 1]; /* printf("ff %Fs\n", name);*/ @@ -616,15 +607,10 @@ COUNT dos_findfirst(UCOUNT attr, BYTE FAR * name) /* Start out by initializing the dirmatch structure. */ - fmemset(dmp, sizeof(*dmp),0); - dmp->dm_drive = default_drive; -/* dmp->dm_entry = 0; - dmp->dm_cluster = 0; -*/ dmp->dm_attr_srch = attr; /* Parse out the drive, file name and file extension. */ - i = ParseDosName((BYTE FAR *)name, &nDrive, &LocalPath[2], local_name, local_ext, TRUE); + i = ParseDosName(name, NULL, &szDirName[2], local_name, local_ext, TRUE); if (i != SUCCESS) return i; /* @@ -632,22 +618,10 @@ COUNT dos_findfirst(UCOUNT attr, BYTE FAR * name) printf("ff %s", local_name); printf("ff %s\n", local_ext); */ - if (nDrive >= 0) - { - dmp->dm_drive = nDrive; - } - else - nDrive = default_drive; - - if (nDrive >= lastdrive) { - return DE_INVLDDRV; - } - current_ldt = &CDSp->cds_table[nDrive]; - SAttr = (BYTE) attr; /* Now build a directory. */ - if (!LocalPath[2]) - fstrcpy(&LocalPath[0], current_ldt->cdsCurrentPath); + if (!szDirName[2]) + fstrcpy(&szDirName[0], current_ldt->cdsCurrentPath); /* Build the match pattern out of the passed string */ /* copy the part of the pattern which belongs to the filename and is fixed */ @@ -675,11 +649,8 @@ COUNT dos_findfirst(UCOUNT attr, BYTE FAR * name) /* Complete building the directory from the passed in */ /* name */ - if (nDrive >= 0) - LocalPath[0] = 'A' + nDrive; - else - LocalPath[0] = 'A' + default_drive; - LocalPath[1] = ':'; + szDirName[0] = 'A' + dmp->dm_drive; + szDirName[1] = ':'; /* Special handling - the volume id is only in the root */ /* directory and only searched for once. So we need to open */ @@ -687,14 +658,14 @@ COUNT dos_findfirst(UCOUNT attr, BYTE FAR * name) /* volume id bit set. */ if ((attr & ~(D_RDONLY | D_ARCHIVE)) == D_VOLID) { - LocalPath[2] = '\\'; - LocalPath[3] = '\0'; + szDirName[2] = '\\'; + szDirName[3] = '\0'; } /* Now open this directory so that we can read the */ /* fnode entry and do a match on it. */ -/* printf("dir_open %Fs\n",(BYTE FAR *) LocalPath);*/ - if ((fnp = dir_open((BYTE FAR *) LocalPath)) == NULL) +/* printf("dir_open %s\n", szDirName);*/ + if ((fnp = dir_open(szDirName)) == NULL) return DE_PATHNOTFND; if ((attr & ~(D_RDONLY | D_ARCHIVE)) == D_VOLID) @@ -806,7 +777,7 @@ COUNT dos_findnext(void) ++dmp->dm_entry; if (fnp->f_dir.dir_name[0] != '\0' && fnp->f_dir.dir_name[0] != DELETED) { - if (fcmp_wild((BYTE FAR *) (dmp->dm_name_pat), (BYTE FAR *) fnp->f_dir.dir_name, FNAME_SIZE + FEXT_SIZE)) + if (fcmp_wild((BYTE FAR *)dmp->dm_name_pat, (BYTE FAR *)fnp->f_dir.dir_name, FNAME_SIZE + FEXT_SIZE)) { /* MSD Command.com uses FCB FN 11 & 12 with attrib set to 0x16. diff --git a/kernel/fatfs.c b/kernel/fatfs.c index f238346d..db7d73d2 100644 --- a/kernel/fatfs.c +++ b/kernel/fatfs.c @@ -47,6 +47,9 @@ BYTE *RcsId = "$Id$"; * performance killer on large drives. (~0.5 sec /dos_mkdir) TE * * $Log$ + * Revision 1.20 2001/07/22 01:58:58 bartoldeman + * Support for Brian's FORMAT, DJGPP libc compilation, cleanups, MSCDEX + * * Revision 1.19 2001/07/09 22:19:33 bartoldeman * LBA/FCB/FAT/SYS/Ctrl-C/ioctl fixes + memory savings * @@ -244,7 +247,7 @@ BYTE *RcsId = "$Id$"; /* */ f_node_ptr xlt_fd(COUNT); COUNT xlt_fnp(f_node_ptr); -f_node_ptr split_path(BYTE FAR *, BYTE *, BYTE *, BYTE *); +f_node_ptr split_path(BYTE *, BYTE *, BYTE *); BOOL find_fname(f_node_ptr, BYTE *, BYTE *); /* /// Added - Ron Cemer */ STATIC void merge_file_changes(f_node_ptr fnp, int collect); @@ -274,7 +277,7 @@ STATIC VOID shrink_file(f_node_ptr fnp); /* for update. */ /* Returns an integer file desriptor or a negative error code */ -COUNT dos_open(BYTE FAR * path, COUNT flag) +COUNT dos_open(BYTE * path, COUNT flag) { REG f_node_ptr fnp; @@ -285,7 +288,7 @@ COUNT dos_open(BYTE FAR * path, COUNT flag) /* first split the passed dir into comopnents (i.e. - path to */ /* new directory and name of new directory. */ - if ((fnp = split_path(path, szDirName, szFileName, szFileExt)) == NULL) + if ((fnp = split_path(path, szFileName, szFileExt)) == NULL) { dir_close(fnp); return DE_PATHNOTFND; @@ -324,7 +327,7 @@ COUNT dos_open(BYTE FAR * path, COUNT flag) return xlt_fnp(fnp); } -BOOL fcmp(BYTE FAR * s1, BYTE FAR * s2, COUNT n) +BOOL fcmp(BYTE * s1, BYTE * s2, COUNT n) { while (n--) if (*s1++ != *s2++) @@ -386,21 +389,21 @@ COUNT dos_close(COUNT fd) /* split a path into it's component directory and file name */ /* */ f_node_ptr - split_path(BYTE FAR * path, BYTE * dname, BYTE * fname, BYTE * fext) + split_path(BYTE * path, BYTE * fname, BYTE * fext) { REG f_node_ptr fnp; COUNT nDrive; struct cds FAR *cdsp; /* Start off by parsing out the components. */ - if (ParseDosName(adjust_far(path), &nDrive, &dname[2], fname, fext, FALSE) + if (ParseDosName(path, &nDrive, &szDirName[2], fname, fext, FALSE) != SUCCESS) return (f_node_ptr)0; if (nDrive < 0) nDrive = default_drive; - dname[0] = 'A' + nDrive; - dname[1] = ':'; + szDirName[0] = 'A' + nDrive; + szDirName[1] = ':'; /* Add trailing spaces to the file name and extension */ SpacePad(fname, FNAME_SIZE); @@ -413,9 +416,9 @@ f_node_ptr /* If the path is null, we to default to the current */ /* directory... */ - if (!dname[2]) + if (!szDirName[2]) { - fsncopy(cdsp->cdsCurrentPath, (BYTE FAR *) dname, PARSE_MAX); + fsncopy(cdsp->cdsCurrentPath, (BYTE FAR *) szDirName, PARSE_MAX); } /* 11/29/99 jt @@ -438,7 +441,7 @@ f_node_ptr #endif /* Translate the path into a useful pointer */ - fnp = dir_open((BYTE FAR *) dname); + fnp = dir_open(szDirName); /* If the fd was invalid because it was out of range or the */ /* requested file was not open, tell the caller and exit... */ @@ -450,7 +453,7 @@ f_node_ptr } /* Convert the name into an absolute name for comparison... */ - DosUpFString((BYTE FAR *) dname); + DosUpFString((BYTE FAR *) szDirName); DosUpFMem((BYTE FAR *) fname, FNAME_SIZE); DosUpFMem((BYTE FAR *) fext, FEXT_SIZE); @@ -468,8 +471,8 @@ STATIC BOOL find_fname(f_node_ptr fnp, BYTE * fname, BYTE * fext) if (fnp->f_dir.dir_name[0] == DELETED) continue; - if (fcmp((BYTE FAR *) fname, (BYTE FAR *) fnp->f_dir.dir_name, FNAME_SIZE) - && fcmp((BYTE FAR *) fext, (BYTE FAR *) fnp->f_dir.dir_ext, FEXT_SIZE) + if (fcmp(fname, (BYTE *)fnp->f_dir.dir_name, FNAME_SIZE) + && fcmp(fext, (BYTE *)fnp->f_dir.dir_ext, FEXT_SIZE) && ((fnp->f_dir.dir_attrib & D_VOLID) == 0)) { found = TRUE; @@ -526,11 +529,11 @@ STATIC int is_same_file(f_node_ptr fnp1, f_node_ptr fnp2) { (fnp1->f_dpb->dpb_unit == fnp2->f_dpb->dpb_unit) && (fnp1->f_dpb->dpb_subunit == fnp2->f_dpb->dpb_subunit) && (fcmp - ((BYTE FAR *)fnp1->f_dir.dir_name, - (BYTE FAR *)fnp2->f_dir.dir_name, FNAME_SIZE)) + ((BYTE *)fnp1->f_dir.dir_name, + (BYTE *)fnp2->f_dir.dir_name, FNAME_SIZE)) && (fcmp - ((BYTE FAR *)fnp1->f_dir.dir_ext, - (BYTE FAR *)fnp2->f_dir.dir_ext, FEXT_SIZE)) + ((BYTE *)fnp1->f_dir.dir_ext, + (BYTE *)fnp2->f_dir.dir_ext, FEXT_SIZE)) && ((fnp1->f_dir.dir_attrib & D_VOLID) == 0) && ((fnp2->f_dir.dir_attrib & D_VOLID) == 0) && (fnp1->f_flags.f_dremote == fnp2->f_flags.f_dremote) @@ -548,7 +551,7 @@ STATIC void copy_file_changes(f_node_ptr src, f_node_ptr dst) { dst->f_dir.dir_time = src->f_dir.dir_time; } -COUNT dos_creat(BYTE FAR * path, COUNT attrib) +COUNT dos_creat(BYTE * path, COUNT attrib) { REG f_node_ptr fnp; @@ -560,7 +563,7 @@ COUNT dos_creat(BYTE FAR * path, COUNT attrib) /* first split the passed dir into comopnents (i.e. - */ /* path to new directory and name of new directory */ - if ((fnp = split_path(path, szDirName, szFileName, szFileExt)) == NULL) + if ((fnp = split_path(path, szFileName, szFileExt)) == NULL) { dir_close(fnp); return DE_PATHNOTFND; @@ -593,7 +596,7 @@ COUNT dos_creat(BYTE FAR * path, COUNT attrib) /* an open */ fnp->f_flags.f_dmod = FALSE; dir_close(fnp); - fnp = dir_open((BYTE FAR *) szDirName); + fnp = split_path(path, szFileName, szFileExt); /* Get a free f_node pointer so that we can use */ /* it in building the new file. */ @@ -616,10 +619,8 @@ COUNT dos_creat(BYTE FAR * path, COUNT attrib) } /* put the fnode's name into the directory. */ - fbcopy((BYTE FAR *) szFileName, - (BYTE FAR *) fnp->f_dir.dir_name, FNAME_SIZE); - fbcopy((BYTE FAR *) szFileExt, - (BYTE FAR *) fnp->f_dir.dir_ext, FEXT_SIZE); + bcopy(szFileName, fnp->f_dir.dir_name, FNAME_SIZE); + bcopy(szFileExt, fnp->f_dir.dir_ext, FEXT_SIZE); } /* Set the fnode to the desired mode */ /* Updating the directory entry first. */ @@ -656,13 +657,13 @@ COUNT dos_creat(BYTE FAR * path, COUNT attrib) return xlt_fnp(fnp); } -COUNT dos_delete(BYTE FAR * path) +COUNT dos_delete(BYTE * path) { REG f_node_ptr fnp; /* first split the passed dir into components (i.e. - */ /* path to new directory and name of new directory */ - if ((fnp = split_path(path, szDirName, szFileName, szFileExt)) == NULL) + if ((fnp = split_path(path, szFileName, szFileExt)) == NULL) { dir_close(fnp); return DE_PATHNOTFND; @@ -706,7 +707,7 @@ COUNT dos_delete(BYTE FAR * path) } } -COUNT dos_rmdir(BYTE FAR * path) +COUNT dos_rmdir(BYTE * path) { REG f_node_ptr fnp; REG f_node_ptr fnp1; @@ -714,7 +715,7 @@ COUNT dos_rmdir(BYTE FAR * path) /* first split the passed dir into comopnents (i.e. - */ /* path to new directory and name of new directory */ - if ((fnp = split_path(path, szDirName, szFileName, szFileExt)) == NULL) + if ((fnp = split_path(path, szFileName, szFileExt)) == NULL) { dir_close(fnp); return DE_PATHNOTFND; @@ -749,7 +750,7 @@ COUNT dos_rmdir(BYTE FAR * path) /* Check that the directory is empty. Only the */ /* "." and ".." are permissable. */ fnp->f_flags.f_dmod = FALSE; - fnp1 = dir_open((BYTE FAR *) path); + fnp1 = dir_open(path); dir_read(fnp1); if (fnp1->f_dir.dir_name[0] != '.') { @@ -812,7 +813,7 @@ COUNT dos_rmdir(BYTE FAR * path) } } -COUNT dos_rename(BYTE FAR * path1, BYTE FAR * path2) +COUNT dos_rename(BYTE * path1, BYTE * path2) { REG f_node_ptr fnp1; REG f_node_ptr fnp2; @@ -820,7 +821,7 @@ COUNT dos_rename(BYTE FAR * path1, BYTE FAR * path2) /* first split the passed target into compnents (i.e. - path to */ /* new file name and name of new file name */ - if ((fnp2 = split_path(path2, szSecDirName, szSecFileName, szSecFileExt)) == NULL) + if ((fnp2 = split_path(path2, szFileName, szFileExt)) == NULL) { dir_close(fnp2); return DE_PATHNOTFND; @@ -828,7 +829,7 @@ COUNT dos_rename(BYTE FAR * path1, BYTE FAR * path2) /* Check that we don't have a duplicate name, so if we find */ /* one, it's an error. */ - if (find_fname(fnp2, szSecFileName, szSecFileExt)) + if (find_fname(fnp2, szFileName, szFileExt)) { dir_close(fnp2); return DE_ACCESS; @@ -836,17 +837,25 @@ COUNT dos_rename(BYTE FAR * path1, BYTE FAR * path2) /* next split the passed source into compnents (i.e. - path to */ /* old file name and name of old file name */ - if ((fnp1 = split_path(path1, szPriDirName, szPriFileName, szPriFileExt)) == NULL) + if ((fnp1 = split_path(path1, szFileName, szFileExt)) == NULL) { dir_close(fnp1); dir_close(fnp2); return DE_PATHNOTFND; } + if (!find_fname(fnp1, szFileName, szFileExt)) + { + /* No such file, return the error */ + dir_close(fnp1); + dir_close(fnp2); + return DE_FILENOTFND; + } + /* Reset the directory by a close followed by an open */ fnp2->f_flags.f_dmod = FALSE; dir_close(fnp2); - fnp2 = dir_open((BYTE FAR *) szSecDirName); + fnp2 = split_path(path2, szFileName, szFileExt); /* Now find a free slot to put the file into. */ /* If it's the root and we don't have room, return an error. */ @@ -870,19 +879,9 @@ COUNT dos_rename(BYTE FAR * path1, BYTE FAR * path2) } } - if (!find_fname(fnp1, szPriFileName, szPriFileExt)) - { - /* No such file, return the error */ - dir_close(fnp1); - dir_close(fnp2); - return DE_FILENOTFND; - } - /* put the fnode's name into the directory. */ - fbcopy((BYTE FAR *) szSecFileName, - (BYTE FAR *) fnp2->f_dir.dir_name, FNAME_SIZE); - fbcopy((BYTE FAR *) szSecFileExt, - (BYTE FAR *) fnp2->f_dir.dir_ext, FEXT_SIZE); + bcopy(szFileName, (BYTE *)fnp2->f_dir.dir_name, FNAME_SIZE); + bcopy(szFileExt, (BYTE *)fnp2->f_dir.dir_ext, FEXT_SIZE); /* Set the fnode to the desired mode */ fnp2->f_dir.dir_size = fnp1->f_dir.dir_size; @@ -1177,7 +1176,7 @@ STATIC UWORD find_fat_free(f_node_ptr fnp) /* create a directory - returns success or a negative error */ /* number */ /* */ -COUNT dos_mkdir(BYTE FAR * dir) +COUNT dos_mkdir(BYTE * dir) { REG f_node_ptr fnp; REG COUNT idx; @@ -1188,7 +1187,7 @@ COUNT dos_mkdir(BYTE FAR * dir) /* first split the passed dir into comopnents (i.e. - */ /* path to new directory and name of new directory */ - if ((fnp = split_path(dir, szDirName, szFileName, szFileExt)) == NULL) + if ((fnp = split_path(dir, szFileName, szFileExt)) == NULL) { dir_close(fnp); return DE_PATHNOTFND; @@ -1202,11 +1201,7 @@ COUNT dos_mkdir(BYTE FAR * dir) can create an unlimited amount of same dirs. this space is lost forever */ - if (2 /* "C" */ - + strlen(szDirName) - + 1 /* "\\" */ - + FileName83Length(szFileName) /* the SZ is not SZ, of course */ - > PARSE_MAX+2) + if (strlen(dir) > PARSE_MAX+2) /* dir is already output of "truename" */ { dir_close(fnp); return DE_PATHNOTFND; @@ -1230,7 +1225,7 @@ COUNT dos_mkdir(BYTE FAR * dir) fnp->f_flags.f_dmod = FALSE; parent = fnp->f_dirstart; dir_close(fnp); - fnp = dir_open((BYTE FAR *) szDirName); + fnp = split_path(dir, szFileName, szFileExt); /* Get a free f_node pointer so that we can use */ /* it in building the new file. */ @@ -1268,10 +1263,8 @@ COUNT dos_mkdir(BYTE FAR * dir) /* put the fnode's name into the directory. */ - fbcopy((BYTE FAR *) szFileName, - (BYTE FAR *) fnp->f_dir.dir_name, FNAME_SIZE); - fbcopy((BYTE FAR *) szFileExt, - (BYTE FAR *) fnp->f_dir.dir_ext, FEXT_SIZE); + bcopy(szFileName, (BYTE *) fnp->f_dir.dir_name, FNAME_SIZE); + bcopy(szFileExt, (BYTE *) fnp->f_dir.dir_ext, FEXT_SIZE); /* Set the fnode to the desired mode */ fnp->f_mode = WRONLY; @@ -2144,7 +2137,7 @@ UWORD dos_free(struct dpb FAR *dpbp) #ifndef IPL -COUNT dos_cd(struct cds FAR * cdsp, BYTE FAR *PathName) +COUNT dos_cd(struct cds FAR * cdsp, BYTE *PathName) { f_node_ptr fnp; @@ -2158,7 +2151,7 @@ COUNT dos_cd(struct cds FAR * cdsp, BYTE FAR *PathName) /* now test for its existance. If it doesn't, return an error. */ /* If it does, copy the path to the current directory */ /* structure. */ - if ((fnp = dir_open(PathName)) == NULL) + if ((fnp = dir_open(PathName)) == NULL) return DE_PATHNOTFND; cdsp->cdsStrtClst = fnp->f_dirstart; @@ -2199,10 +2192,10 @@ VOID dos_setdta(BYTE FAR * newdta) dta = newdta; } -COUNT dos_getfattr(BYTE FAR * name, UWORD FAR * attrp) +COUNT dos_getfattr(BYTE * name) { f_node_ptr fnp; - COUNT fd; + COUNT fd, result; /* Translate the fd into an fnode pointer, since all internal */ /* operations are achieved through fnodes. */ @@ -2222,12 +2215,12 @@ COUNT dos_getfattr(BYTE FAR * name, UWORD FAR * attrp) } /* Get the attribute from the fnode and return */ - *attrp = fnp->f_dir.dir_attrib; + result = fnp->f_dir.dir_attrib; dos_close(fd); - return SUCCESS; + return result; } -COUNT dos_setfattr(BYTE FAR * name, UWORD FAR * attrp) +COUNT dos_setfattr(BYTE * name, UWORD attrp) { f_node_ptr fnp; COUNT fd; @@ -2249,7 +2242,7 @@ COUNT dos_setfattr(BYTE FAR * name, UWORD FAR * attrp) return DE_FILENOTFND; } /* JPP-If user tries to set VOLID or DIR bits, return error */ - if ((*attrp & (D_VOLID | D_DIR | 0xC0)) != 0) + if ((attrp & (D_VOLID | D_DIR | 0xC0)) != 0) { dos_close(fd); return DE_ACCESS; @@ -2260,7 +2253,7 @@ COUNT dos_setfattr(BYTE FAR * name, UWORD FAR * attrp) fnp->f_dir.dir_attrib &= (D_VOLID | D_DIR); /* JPP */ /* set attributes that user requested */ - fnp->f_dir.dir_attrib |= *attrp; /* JPP */ + fnp->f_dir.dir_attrib |= attrp; /* JPP */ fnp->f_flags.f_dmod = TRUE; dos_close(fd); return SUCCESS; diff --git a/kernel/fcbfns.c b/kernel/fcbfns.c index be825e10..858e82d9 100644 --- a/kernel/fcbfns.c +++ b/kernel/fcbfns.c @@ -35,6 +35,9 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.13 2001/07/22 01:58:58 bartoldeman + * Support for Brian's FORMAT, DJGPP libc compilation, cleanups, MSCDEX + * * Revision 1.12 2001/07/09 22:19:33 bartoldeman * LBA/FCB/FAT/SYS/Ctrl-C/ioctl fixes + memory savings * @@ -779,8 +782,7 @@ BOOL FcbOpen(xfcb FAR * lpXfcb) if (CDSp->cds_table[FcbDrive].cdsFlags & CDSNETWDRV) { COUNT result; lpCurSft = (sfttbl FAR *)sftp; - result = int2f_Remote_call(REM_OPEN, 0, 0, 0, (VOID FAR *) sftp, 0, MK_FP(0, O_RDWR)); - result = -result; + result = -int2f_Remote_call(REM_OPEN, 0, 0, 0, (VOID FAR *) sftp, 0, MK_FP(0, O_RDWR)); sftp->sft_status = result; } else { diff --git a/kernel/globals.h b/kernel/globals.h index 0f18cb79..e0d1b9fc 100644 --- a/kernel/globals.h +++ b/kernel/globals.h @@ -36,6 +36,9 @@ static BYTE *Globals_hRcsId = "$Id$"; /* * $Log$ + * Revision 1.15 2001/07/22 01:58:58 bartoldeman + * Support for Brian's FORMAT, DJGPP libc compilation, cleanups, MSCDEX + * * Revision 1.14 2001/07/09 22:19:33 bartoldeman * LBA/FCB/FAT/SYS/Ctrl-C/ioctl fixes + memory savings * @@ -432,6 +435,7 @@ extern cdstbl FAR * CDSp; /* Current Directory Structure */ extern struct cds FAR *current_ldt; +extern LONG current_filepos; /* current file position */ extern sfttbl FAR * FCBp; /* FCB table pointer */ extern WORD @@ -442,8 +446,6 @@ extern UBYTE uppermem_link; /* UMB Link flag */ extern struct dhdr nul_dev; -extern BYTE - LocalPath[PARSE_MAX + 3]; /* Room for drive spec */ extern UBYTE mem_access_mode; /* memory allocation scheme */ extern BYTE @@ -474,42 +476,31 @@ extern struct } FcbSearchBuffer; -extern union /* Path name parsing buffer */ +extern struct /* Path name parsing buffer */ { BYTE _PriPathName[128]; - struct - { - BYTE _dname[NAMEMAX]; - BYTE _fname[FNAME_SIZE]; - BYTE _fext[FEXT_SIZE]; - } - _f; } _PriPathBuffer; + +extern struct +{ + BYTE _fname[FNAME_SIZE]; + BYTE _fext[FEXT_SIZE+1]; /* space for 0 */ +} +szNames; + #define PriPathName _PriPathBuffer._PriPathName -#define szDirName _PriPathBuffer._f._dname -#define szFileName _PriPathBuffer._f._fname -#define szFileExt _PriPathBuffer._f._fext -#define szPriDirName _PriPathBuffer._f._dname -#define szPriFileName _PriPathBuffer._f._fname -#define szPriFileExt _PriPathBuffer._f._fext - -extern union /* Alternate path name parsing buffer */ +#define szDirName TempCDS.cdsCurrentPath +#define szFileName szNames._fname +#define szFileExt szNames._fext + +extern struct /* Alternate path name parsing buffer */ { BYTE _SecPathName[128]; - struct - { - BYTE _dname[NAMEMAX]; - BYTE _fname[FNAME_SIZE]; - BYTE _fext[FEXT_SIZE]; - } - _f; } _SecPathBuffer; + #define SecPathName _SecPathBuffer._SecPathName -#define szSecDirName _SecPathBuffer._f._dname -#define szSecFileName _SecPathBuffer._f._fname -#define szSecFileExt _SecPathBuffer._f._fext extern UWORD wAttr; diff --git a/kernel/init-mod.h b/kernel/init-mod.h index c28bba95..572b85a7 100644 --- a/kernel/init-mod.h +++ b/kernel/init-mod.h @@ -72,6 +72,9 @@ extern fmemcmp(BYTE far *s1, BYTE FAR *s2, unsigned len); #define NLAST 5 /* last drive */ #define NUMBUFF 6 /* Number of track buffers */ /* -- must be at least 3 */ +#define MAX_HARD_DRIVE 8 +#define NDEV 20 /* only one for demo */ + /* Start of configuration variables */ @@ -127,10 +130,11 @@ INIT BOOL isnum(BYTE * pszString); INIT BYTE *GetNumber(REG BYTE * pszString, REG COUNT * pnNum); INIT COUNT tolower(COUNT c); INIT COUNT toupper(COUNT c); -INIT VOID mcb_init(mcb FAR * mcbp, UWORD size); +INIT VOID mcb_init(UCOUNT seg, UWORD size); INIT VOID strcat(REG BYTE * d, REG BYTE * s); INIT BYTE FAR *KernelAlloc(WORD nBytes); INIT COUNT Umb_Test(void); +INIT COUNT UMB_get_largest(UCOUNT *seg, UCOUNT *size); INIT BYTE *GetStringArg(BYTE * pLine, BYTE * pszString); /* diskinit.c */ diff --git a/kernel/initdisk.c b/kernel/initdisk.c index 360e1fb8..20b7f18e 100644 --- a/kernel/initdisk.c +++ b/kernel/initdisk.c @@ -26,7 +26,6 @@ #include "portab.h" #include "init-mod.h" -#include "disk.h" #include "dyndata.h" #ifdef VERSION_STRINGS static BYTE *dskRcsId = "$Id$"; @@ -35,7 +34,7 @@ static BYTE *dskRcsId = "$Id$"; /* data shared between DSK.C and INITDISK.C */ -extern struct media_info * FAR miarrayptr; /* Internal media info structs */ +extern ddt * FAR pddt0; /* Pointer to drive data tables */ extern UBYTE FAR DiskTransferBuffer[1 * SEC_SIZE]; @@ -108,7 +107,7 @@ extern UWORD FAR LBA_WRITE_VERIFY; */ -/*#define DEBUG*/ +/* #define DEBUG */ #define _BETA_ /* messages for initial phase only */ @@ -128,14 +127,75 @@ extern UWORD FAR LBA_WRITE_VERIFY; #define LBA_to_CHS init_LBA_to_CHS +/* + interesting macros - used internally only +*/ + +#define SCAN_PRIMARYBOOT 0x00 +#define SCAN_PRIMARY 0x01 +#define SCAN_EXTENDED 0x02 +#define SCAN_PRIMARY2 0x03 + + +#define FAT12 0x01 +#define FAT16SMALL 0x04 +#define EXTENDED 0x05 +#define FAT16LARGE 0x06 +#define FAT32 0x0b /* FAT32 partition that ends before the 8.4 */ + /* GB boundary */ +#define FAT32_LBA 0x0c /* FAT32 partition that ends after the 8.4GB */ + /* boundary. LBA is needed to access this. */ +#define FAT16_LBA 0x0e /* like 0x06, but it is supposed to end past */ + /* the 8.4GB boundary */ +#define EXTENDED_LBA 0x0f /* like 0x05, but it is supposed to end past */ + +#define IsExtPartition(parttyp) ((parttyp) == EXTENDED || \ + (parttyp) == EXTENDED_LBA ) + +#define IsFAT16Partition(parttyp) ((parttyp) == FAT12 || \ + (parttyp) == FAT16SMALL || \ + (parttyp) == FAT16LARGE || \ + (parttyp) == FAT16_LBA ) + +#define MSDOS_EXT_SIGN 0x29 /* extended boot sector signature */ +#define MSDOS_FAT12_SIGN "FAT12 " /* FAT12 filesystem signature */ +#define MSDOS_FAT16_SIGN "FAT16 " /* FAT16 filesystem signature */ +#define MSDOS_FAT32_SIGN "FAT32 " /* FAT32 filesystem signature */ + +/* local - returned and used for BIOS interface INT 13, AH=48*/ +struct _bios_LBA_disk_parameterS { + UWORD size; + UWORD information; + ULONG cylinders; + ULONG heads; + ULONG sectors; + + ULONG totalSect; + ULONG totalSectHigh; + UWORD BytesPerSector; + + ULONG eddparameters; + } ; + + +/* physical characteristics of a drive */ + +struct DriveParamS +{ + UBYTE driveno; /* = 0x8x */ + BITS LBA_supported:1; /* set, if INT13 extensions enabled */ + BITS WriteVerifySupported:1; /* */ + ULONG total_sectors; + + struct CHS chs; /* for normal INT 13 */ +}; + /* internal global data */ UBYTE GlobalEnableLBAsupport = 1; /* = 0 --> disable LBA support */ -struct DriveParamS InitDriveParam[MAX_HARD_DRIVE]; - /* translate LBA sectors into CHS addressing copied and pasted from dsk.c! @@ -164,11 +224,162 @@ void printCHS(char *title,struct CHS *chs) partition structure. */ + +/* Compute ceil(a/b) */ +#define cdiv(a, b) (((a) + (b) - 1) / (b)) + +/* calculates FAT data: + code adapted by Bart Oldeman from mkdosfs from the Linux dosfstools: + Author: Dave Hudson + Updated by: Roman Hodek + Portions copyright 1992, 1993 Remy Card + and 1991 Linus Torvalds +*/ +VOID CalculateFATData(ddt FAR *pddt, ULONG NumSectors, UBYTE FileSystem) +{ + ULONG fatlength, maxclust, clust; + UBYTE maxclustsize; + ULONG fatdata; + + bpb FAR *defbpb = &pddt->ddt_defbpb; + + /* FAT related items */ + defbpb->bpb_nfat = 2; + defbpb->bpb_ndirent = 512; /* normal value of number of entries in root dir + should be 0 for FAT32 drives */ + defbpb->bpb_nreserved = 1; /* 0x20 for FAT32 */ + + fatdata = NumSectors - cdiv (defbpb->bpb_ndirent * 32, defbpb->bpb_nbyte) - + defbpb->bpb_nreserved; + maxclustsize = 128; +#ifdef DEBUG + if (FileSystem!=FAT12) + DebugPrintf(( "%ld sectors for FAT+data, starting with %d sectors/cluster\n", + fatdata, defbpb->bpb_nsector )); +#endif + switch(FileSystem) { + + case FAT12: + /* in DOS, FAT12 defaults to 4096kb (8 sector) - clusters. */ + defbpb->bpb_nsector = 8; + /* Force maximal fatdata=32696 sectors since with our only possible sector + size (512 bytes) this is the maximum for 4k clusters. + #clus*secperclus+#fats*fatlength= 4084 * 8 + 2 * 12 = 32696. + max FAT12 size for FreeDOS = 16,728,064 bytes */ + if (fatdata > 32696) + fatdata = 32696; + /* The factor 2 below avoids cut-off errors for nr_fats == 1. + * The "defbpb->bpb_nfat*3" is for the reserved first two FAT entries */ + clust = 2*((ULONG) fatdata * defbpb->bpb_nbyte + defbpb->bpb_nfat*3) / + (2*(ULONG) defbpb->bpb_nsector * defbpb->bpb_nbyte + defbpb->bpb_nfat*3); + fatlength = cdiv (((clust+2) * 3 + 1) >> 1, defbpb->bpb_nbyte); + /* Need to recalculate number of clusters, since the unused parts of the + * FATS and data area together could make up space for an additional, + * not really present cluster. */ + clust = (fatdata - defbpb->bpb_nfat*fatlength)/defbpb->bpb_nsector; + maxclust = (fatlength * 2 * defbpb->bpb_nbyte) / 3; + if (maxclust > FAT_MAGIC) + maxclust = FAT_MAGIC; + DebugPrintf(( "FAT12: #clu=%lu, fatlen=%lu, maxclu=%lu, limit=%u\n", + clust, fatlength, maxclust, FAT_MAGIC )); + if (clust > maxclust-2) { + clust = maxclust-2; + DebugPrintf(( "FAT12: too many clusters: setting to maxclu-2\n" )); + } + defbpb->bpb_nfsect = fatlength; + fmemcpy(pddt->ddt_fstype, MSDOS_FAT12_SIGN, 8); + break; + + case FAT16SMALL: + case FAT16LARGE: + case FAT16_LBA: + /* FAT16: start at 4 sectors per cluster */ + defbpb->bpb_nsector = 4; + /* Force maximal fatdata=8387584 sectors (NumSectors=8387617) + since with our only possible sectorsize (512 bytes) this is the + maximum we can address with 64k clusters + #clus*secperclus+#fats*fatlength=65524 * 128 + 2 * 256=8387584. + max FAT16 size for FreeDOS = 4,294,180,864 bytes = 4GiB-786,432 */ + if (fatdata > 8387584ul) + fatdata = 8387584ul; + do { + DebugPrintf(( "Trying with %d sectors/cluster:\n", defbpb->bpb_nsector )); + + clust = ((ULONG) fatdata *defbpb->bpb_nbyte + defbpb->bpb_nfat*4) / + ((ULONG) defbpb->bpb_nsector * defbpb->bpb_nbyte + defbpb->bpb_nfat*2); + fatlength = cdiv ((clust+2) * 2, defbpb->bpb_nbyte); + /* Need to recalculate number of clusters, since the unused parts of the + * FATS and data area together could make up space for an additional, + * not really present cluster. */ + clust = (fatdata - defbpb->bpb_nfat*fatlength)/defbpb->bpb_nsector; + maxclust = (fatlength * defbpb->bpb_nbyte) / 2; + if (maxclust > FAT_MAGIC16) + maxclust = FAT_MAGIC16; + DebugPrintf(( "FAT16: #clu=%lu, fatlen=%lu, maxclu=%lu, limit=%u\n", + clust, fatlength, maxclust, FAT_MAGIC16 )); + if (clust > maxclust-2) { + DebugPrintf(( "FAT16: too many clusters\n" )); + clust = 0; + } else if (clust <= FAT_MAGIC) { + /* The <= 4086 avoids that the filesystem will be misdetected as having a + * 12 bit FAT. */ + DebugPrintf(("FAT16: would be misdetected as FAT12\n")); + clust = 0; + } + if (clust) + break; + defbpb->bpb_nsector <<= 1; + } + while (defbpb->bpb_nsector && defbpb->bpb_nsector <= maxclustsize); + defbpb->bpb_nfsect = fatlength; + fmemcpy(pddt->ddt_fstype, MSDOS_FAT16_SIGN, 8); + break; + + /* FAT 32 code: commented out for now */ +#ifdef WITHFAT32 + case FAT32: + /* For FAT32, use 4k clusters on sufficiently large file systems, + * otherwise 1 sector per cluster. This is also what M$'s format + * command does for FAT32. */ + defbpb->bpb_nsector = ((long long)blocks*SECTORS_PER_BLOCK >= 512*1024 ? 8 : 1); + do { + clust = ((long long) fatdata *defbpb->bpb_nbyte + defbpb->bpb_nfat*8) / + ((int) defbpb->bpb_nsector * defbpb->bpb_nbyte + defbpb->bpb_nfat*4); + fatlength = cdiv ((clust+2) * 4, defbpb->bpb_nbyte); + /* Need to recalculate number of clusters, since the unused parts of the + * FATS and data area together could make up space for an additional, + * not really present cluster. */ + clust = (fatdata - defbpb->bpb_nfat*fatlength)/defbpb->bpb_nsector; + maxclust = (fatlength * defbpb->bpb_nbyte) / 4; + if (maxclust > MAX_CLUST_32) + maxclust = MAX_CLUST_32; + DebugPrintf(( "FAT32: #clu=%u, fatlen=%u, maxclu=%u, limit=%u\n", + clust, fatlength, maxclust, FAT_MAGIC )); + if (clust > maxclust) + { + clust = 0; + DebugPrintf(( "FAT32: too many clusters\n" )); + } + if (clust) + break; + defbpb->bpb_nsector <<= 1; + } while (defbpb->bpb_nsector && defbpb->bpb_nsector <= maxclustsize); + bpb_nfsect = fatlength; + defbpb->bpb_nfsect = 0; + defbpb->fat32.fat32_length = fatlength; + memcpy(pddt->ddt_fstype, MSDOS_FAT32_SIGN, 8); + break; +#endif + } + pddt->ddt_fstype[8] = '\0'; +} + + void DosDefinePartition(struct DriveParamS *driveParam, - ULONG StartSector, ULONG NumSectors) + ULONG StartSector, ULONG NumSectors, UBYTE FileSystem) { extern struct DynS FAR Dyn; - struct media_info FAR *pmiarray = &((struct media_info FAR *)&Dyn.Buffer[0])[nUnits]; + ddt FAR *pddt = &((ddt FAR *)&Dyn.Buffer[0])[nUnits]; struct CHS chs; if ( nUnits >= NDEV) @@ -177,14 +388,32 @@ void DosDefinePartition(struct DriveParamS *driveParam, return; /* we are done */ } - - fmemcpy((BYTE FAR*)&pmiarray->drive, (BYTE FAR*)driveParam, sizeof(struct DriveParamS)); - - if (pmiarray->drive.LBA_supported) + pddt->ddt_driveno = driveParam->driveno; + pddt->ddt_LBASupported = driveParam->LBA_supported; + pddt->ddt_WriteVerifySupported = driveParam->WriteVerifySupported; + pddt->ddt_ncyl = driveParam->chs.Cylinder; + + if (pddt->ddt_LBASupported) DebugPrintf(("LBA enabled for drive %c:\n", 'A'+nUnits)); - pmiarray->mi_offset = StartSector; - pmiarray->mi_size = NumSectors; + pddt->ddt_offset = StartSector; + + pddt->ddt_defbpb.bpb_nbyte = SEC_SIZE; + pddt->ddt_defbpb.bpb_mdesc = 0xf8; + pddt->ddt_defbpb.bpb_nheads = driveParam->chs.Head; + pddt->ddt_defbpb.bpb_nsecs = driveParam->chs.Sector; + pddt->ddt_defbpb.bpb_nsize = 0; + if (NumSectors > 0xffff) + pddt->ddt_defbpb.bpb_huge = NumSectors; + else + pddt->ddt_defbpb.bpb_nsize = (UWORD)NumSectors; + + /* sectors per cluster, sectors per FAT etc. */ + CalculateFATData(pddt, NumSectors, FileSystem); + + pddt->ddt_serialno = 0x12345678l; + pddt->ddt_descflags = 0x200; /* drive inaccessible until bldbpb successful */ + fmemcpy(&pddt->ddt_bpb, &pddt->ddt_defbpb, sizeof(bpb)); #ifdef _BETA_ /* Alain whishes to keep this in later versions, too */ LBA_to_CHS(&chs,StartSector,driveParam); @@ -210,54 +439,6 @@ void DosDefinePartition(struct DriveParamS *driveParam, void __int__(int); -/* - interesting macros - used internally only -*/ - -#define SCAN_PRIMARYBOOT 0x00 -#define SCAN_PRIMARY 0x01 -#define SCAN_EXTENDED 0x02 -#define SCAN_PRIMARY2 0x03 - - -#define FAT12 0x01 -#define FAT16SMALL 0x04 -#define EXTENDED 0x05 -#define FAT16LARGE 0x06 -#define FAT32 0x0b /* FAT32 partition that ends before the 8.4 */ - /* GB boundary */ -#define FAT32_LBA 0x0c /* FAT32 partition that ends after the 8.4GB */ - /* boundary. LBA is needed to access this. */ -#define FAT16_LBA 0x0e /* like 0x06, but it is supposed to end past */ - /* the 8.4GB boundary */ -#define EXTENDED_LBA 0x0f /* like 0x05, but it is supposed to end past */ - -#define IsExtPartition(parttyp) ((parttyp) == EXTENDED || \ - (parttyp) == EXTENDED_LBA ) - -#define IsFAT16Partition(parttyp) ((parttyp) == FAT12 || \ - (parttyp) == FAT16SMALL || \ - (parttyp) == FAT16LARGE || \ - (parttyp) == FAT16_LBA ) - - - -/* local - returned and used for BIOS interface INT 13, AH=48*/ -struct _bios_LBA_disk_parameterS { - UWORD size; - UWORD information; - ULONG cylinders; - ULONG heads; - ULONG sectors; - - ULONG totalSect; - ULONG totalSectHigh; - UWORD BytesPerSector; - - ULONG eddparameters; - } ; - - /* Get the parameters of the hard disk */ int LBA_Get_Drive_Parameters(int drive,struct DriveParamS *driveParam) { @@ -359,6 +540,7 @@ int LBA_Get_Drive_Parameters(int drive,struct DriveParamS *driveParam) StandardBios: /* old way to get parameters */ + regs.a.b.h = 0x08; regs.d.b.l = drive; @@ -372,7 +554,7 @@ int LBA_Get_Drive_Parameters(int drive,struct DriveParamS *driveParam) driveParam->chs.Head = (regs.d.x >> 8) + 1; driveParam->chs.Sector = (regs.c.x & 0x3f); driveParam->chs.Cylinder = (regs.c.x >> 8) | ((regs.c.x & 0xc0) << 2); - + if (!driveParam->LBA_supported) { @@ -557,7 +739,7 @@ ScanForPrimaryPartitions(struct DriveParamS *driveParam,int scan_type, partitionsToIgnore |= 1 << i; - DosDefinePartition(driveParam,partitionStart, pEntry->NumSect); + DosDefinePartition(driveParam,partitionStart, pEntry->NumSect, pEntry->FileSystem); if (scan_type == SCAN_PRIMARYBOOT || scan_type == SCAN_PRIMARY ) @@ -581,12 +763,16 @@ int Read1LBASector(struct DriveParamS *driveParam, unsigned drive, ULONG LBA_add iregs regs; int num_retries; +/* disabled because this should not happen and if it happens the BIOS + should complain; also there are weird disks around with + CMOS geometry < real geometry */ +#if 0 if (LBA_address >= driveParam->total_sectors) { printf("LBA-Transfer error : address overflow = %lu > %lu max\n",LBA_address+1,driveParam->total_sectors); return 1; } - +#endif for ( num_retries = 0; num_retries < N_RETRY; num_retries++) { @@ -599,7 +785,7 @@ int Read1LBASector(struct DriveParamS *driveParam, unsigned drive, ULONG LBA_add dap.block_address = LBA_address; /* clear high part */ /* Load the registers and call the interrupt. */ - regs.a.b.h = 0x42; + regs.a.x = LBA_READ; regs.si = FP_OFF(&dap); regs.ds = FP_SEG(&dap); } @@ -640,12 +826,14 @@ int ProcessDisk(int scanType, unsigned drive, int PartitionsToIgnore) int num_extended_found = 0; - struct DriveParamS *driveParam = &InitDriveParam[drive&0x7f]; + struct DriveParamS driveParam; /* Get the hard drive parameters and ensure that the drive exists. */ /* If there was an error accessing the drive, skip that drive. */ - if (!LBA_Get_Drive_Parameters(drive,driveParam)) + memset(&driveParam, 0, sizeof(driveParam)); + + if (!LBA_Get_Drive_Parameters(drive,&driveParam)) { printf("can't get drive parameters for drive %02x\n",drive); return PartitionsToIgnore; @@ -665,7 +853,7 @@ int ProcessDisk(int scanType, unsigned drive, int PartitionsToIgnore) strange_restart: - if (Read1LBASector(driveParam, drive, RelSectorOffset, DiskTransferBuffer)) + if (Read1LBASector(&driveParam, drive, RelSectorOffset, DiskTransferBuffer)) { printf("Error reading partition table drive %02x sector %lu",drive,RelSectorOffset); return PartitionsToIgnore; @@ -691,7 +879,7 @@ int ProcessDisk(int scanType, unsigned drive, int PartitionsToIgnore) num_extended_found !=0 ) { - PartitionsToIgnore = ScanForPrimaryPartitions(driveParam,scanType, + PartitionsToIgnore = ScanForPrimaryPartitions(&driveParam,scanType, PTable, RelSectorOffset,PartitionsToIgnore); } @@ -731,7 +919,7 @@ int ProcessDisk(int scanType, unsigned drive, int PartitionsToIgnore) } -BIOS_nrdrives(void) +int BIOS_nrdrives(void) { iregs regs; @@ -863,36 +1051,56 @@ void ReadAllPartitionTables(void) int HardDrive; int nHardDisk = BIOS_nrdrives(); - struct media_info FAR *pmiarray; + ddt FAR *pddt; + bpb FAR *pbpbarray; int Unit; extern struct DynS FAR Dyn; -/* struct media_info *miarrayptr; /* Internal media info structs */ - - __int__(0x03); +/* ddt *miarrayptr; /* Internal media info structs */ - - miarrayptr = (struct media_info *)&Dyn.Buffer[0]; + pddt0 = (ddt *)&Dyn.Buffer[0]; - for (Unit = 0; Unit < NDEV; Unit++) - { - pmiarray = &((struct media_info FAR *)&Dyn.Buffer[0])[Unit]; - - pmiarray->drive.driveno = Unit; - pmiarray->drive.total_sectors = 1440*2; - pmiarray->drive.chs.Head = 2; - pmiarray->drive.chs.Cylinder = 40; - pmiarray->drive.chs.Sector = 9; - pmiarray->drive.LBA_supported = FALSE; + /* Setup media info and BPBs arrays for floppies (this is a 360kb flop) */ + for (Unit = 0; Unit < nUnits; Unit++) + { + pddt = &((ddt FAR *)&Dyn.Buffer[0])[Unit]; + pbpbarray = &pddt->ddt_defbpb; + + pbpbarray->bpb_nbyte = SEC_SIZE; + pbpbarray->bpb_nsector = 2; + pbpbarray->bpb_nreserved = 1; + pbpbarray->bpb_nfat = 2; + pbpbarray->bpb_ndirent = 112; + pbpbarray->bpb_nsize = 360*2; + pbpbarray->bpb_mdesc = 0xfd; + pbpbarray->bpb_nfsect = 2; + pbpbarray->bpb_nheads = 2; + pbpbarray->bpb_nsecs = 9; + + pddt->ddt_driveno = 0; + pddt->ddt_ncyl = 40; + pddt->ddt_LBASupported = FALSE; - pmiarray->mi_size = 1440*2; - pmiarray->mi_offset = 0l; + pddt->ddt_offset = 0l; - pmiarray->fs.serialno = 0x12345678l; - } - - + pddt->ddt_serialno = 0x12345678l; + fmemcpy(&pddt->ddt_bpb, pbpbarray, sizeof(bpb)); + } + + /* + this is a quick patch - see if B: exists + test for A: also, need not exist + */ + { + iregs r; + + init_call_intr(0x11,&r); /* get equipment list */ + if ((r.a.x & 1) && (r.a.x & 0xc0)) + pddt->ddt_driveno = 1; + /* floppy drives installed and a B: drive */ + /*if ((r.a.x & 1)==0) */ /* no floppy drives installed */ + } nHardDisk = min(nHardDisk,MAX_HARD_DRIVE-1); @@ -931,20 +1139,13 @@ void ReadAllPartitionTables(void) } - Dyn.UsedByDiskInit = nUnits * sizeof(struct media_info); + Dyn.UsedByDiskInit = nUnits * sizeof(ddt); } -/*TE - array access functions */ -extern bpb FAR bpbarray[NDEV]; -bpb FAR *init_getPBpbarray(unsigned dev){ return &bpbarray[dev];} - /* disk initialization: returns number of units */ COUNT dsk_init() { - COUNT Unit; - bpb FAR *pbpbarray; - printf(" - InitDisk\n"); #ifdef DEBUG @@ -963,22 +1164,6 @@ COUNT dsk_init() nUnits = 2; - /* Setup media info and BPBs arrays */ - for (Unit = 0; Unit < NDEV; Unit++) - { - pbpbarray = init_getPBpbarray(Unit); - - pbpbarray->bpb_nbyte = SEC_SIZE; - pbpbarray->bpb_nsector = 2; - pbpbarray->bpb_nreserved = 1; - pbpbarray->bpb_nfat = 2; - pbpbarray->bpb_ndirent = 112; - pbpbarray->bpb_nsize = 720l; - pbpbarray->bpb_mdesc = 0xfd; - pbpbarray->bpb_nfsect = 2; - - } - ReadAllPartitionTables(); return nUnits; diff --git a/kernel/int2f.asm b/kernel/int2f.asm index 1b6a4f87..08f371e1 100644 --- a/kernel/int2f.asm +++ b/kernel/int2f.asm @@ -30,6 +30,9 @@ ; $Id$ ; ; $Log$ +; Revision 1.10 2001/07/22 01:58:58 bartoldeman +; Support for Brian's FORMAT, DJGPP libc compilation, cleanups, MSCDEX +; ; Revision 1.9 2001/07/09 22:19:33 bartoldeman ; LBA/FCB/FAT/SYS/Ctrl-C/ioctl fixes + memory savings ; @@ -99,8 +102,6 @@ segment HMA_TEXT extern _nul_dev:wrt DGROUP - extern _umb_start:wrt DGROUP - extern _UMB_top:wrt DGROUP extern _cu_psp:wrt DGROUP extern _syscall_MUX14:wrt HMA_TEXT @@ -113,6 +114,10 @@ Int2f1: or al,al ; Installation check? jz FarTabRetn ; yes, just return Int2f2: + mov ax,1 ; TE 07/13/01 + ; at least for redirected INT21/5F44 + ; --> 2f/111e + ; the error code is AX=0001 = unknown function stc FarTabRetn: retf 2 ; Return far @@ -327,8 +332,81 @@ int2f_call: pop bp pop bp ret + +%if 0 +; int_2f_111e_call(iregs FAR *iregs) +; +; set up all registers to the int21 entry registers +; call int2f/111e +; copy returned registers into int21 entry registers back +; +; disabled: does not work better than previous implementation + global _int_2f_111e_call +_int_2f_111e_call: + + push bp + mov bp,sp + push si + push di + push ds + + lds si, [bp+4] ; ds:si -> iregs + + mov ax, [si ] + mov bx, [si+2] + mov cx, [si+4] + mov dx, [si+6] + push word [si+8] ; si + mov di, [si+10] + mov bp, [si+12] + mov es, [si+16] + mov ds, [si+14] + pop si + + push ax + mov ax, 111eh + int 2fh + jc fault + pop ax ; restore orig value of ax if no errors + push ax +fault: + + pushf + push ds + push si + push bp + + mov bp,sp + lds si,[bp+4+6+10] ; 4=fun, 6=si,di,ds, 10 additional bytes on stack + + pop word [si+12] ; bp + pop word [si+ 8] ; si + pop word [si+14] ; ds + pop word [si+22] ; flags + add sp,2 ; pushed function value + + mov [si ],ax + + cmp ax, 5f02h ; 5f02 is special: it manipulates the user stack directly + je skip5f02 + mov [si+2],bx + mov [si+4],cx +skip5f02: + + mov [si+6],dx + mov [si+10],di + mov [si+16],es + + pop ds + pop di + pop si + pop bp + ret +%endif + ; ; Test to see if a umb driver has been loaded. +; if so, retrieve largest available block+size ; ; From RB list and Dosemu xms.c. ; @@ -353,18 +431,16 @@ int2f_call: ; ; + segment INIT_TEXT - global _Umb_Test -_Umb_Test + ; int UMB_get_largest(UCOUNT *seg, UCOUNT *size); + global _UMB_get_largest + +_UMB_get_largest: push bp mov bp,sp - push es - push ds - push dx - push bx - mov ax, DGROUP - mov ds, ax + sub sp,4 ; for the far call mov ax,4300h ; is there a xms driver installed? int 2fh @@ -374,54 +450,41 @@ _Umb_Test mov ax,4310h int 2fh - push es ; save driver entry point - push bx - push cs ; setup far return - mov ax, umbt1 - push ax - push es ; push the driver entry point - push bx + mov [bp-2],es ; save driver entry point + mov [bp-4],bx + mov dx,0xffff ; go for broke! mov ax,1000h ; get the umb's - retf ; Call the driver -umbt1: + call far [bp-4] ; Call the driver ; ; bl = 0xB0 and ax = 0 so do it again. ; cmp bl,0xb0 ; fail safe - je umbtb - add sp,4 - jmp umbt_error -umbtb: - and dx,dx ; if it returns a size of zero. - jne umbtc - add sp,4 - jmp umbt_error + jne umbt_error -umbtc: - pop bx ; restore driver entry - pop es + and dx,dx ; if it returns a size of zero. + je umbt_error - push cs - mov ax, umbt2 - push ax - push es - push bx mov ax,1000h ; dx set with largest size - retf -umbt2: + call far [bp-4] ; Call the driver + cmp ax,1 jne umbt_error + ; now return the segment + ; and the size - mov word [_umb_start], bx ; save the segment - mov word [_UMB_top], dx ; and the true size + mov cx,bx ; *seg = segment + mov bx, [bp+4] + mov [bx],cx -umbt_error: dec ax + mov bx, [bp+6] ; *size = size + mov [bx],dx - pop bx - pop dx - pop ds - pop es +umbt_ret: + mov sp,bp pop bp ret ; this was called NEAR!! + +umbt_error: xor ax,ax + jmp umbt_ret diff --git a/kernel/inthndlr.c b/kernel/inthndlr.c index 41ef73af..34180b22 100644 --- a/kernel/inthndlr.c +++ b/kernel/inthndlr.c @@ -37,6 +37,9 @@ BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.26 2001/07/22 01:58:58 bartoldeman + * Support for Brian's FORMAT, DJGPP libc compilation, cleanups, MSCDEX + * * Revision 1.25 2001/07/09 22:19:33 bartoldeman * LBA/FCB/FAT/SYS/Ctrl-C/ioctl fixes + memory savings * @@ -353,7 +356,6 @@ VOID int21_service(iregs FAR * r) { COUNT rc = 0, rc1; - ULONG lrc; psp FAR *p = MK_FP(cu_psp, 0); void FAR *FP_DS_DX = MK_FP(r->DS, r->DX); /* this is saved so often, that this saves ~100 bytes */ @@ -478,12 +480,11 @@ VOID int21_service(iregs FAR * r) /* Display String */ case 0x09: { - static COUNT scratch; BYTE FAR * q; q = FP_DS_DX; while (*q != '$') ++q; - DosWrite(STDOUT, FP_OFF(q) - FP_OFF(FP_DS_DX), FP_DS_DX, (COUNT FAR *) & scratch); + DosWrite(STDOUT, FP_OFF(q) - FP_OFF(FP_DS_DX), FP_DS_DX, (COUNT FAR *) & UnusedRetVal); } r->AL = '$'; break; @@ -663,26 +664,7 @@ VOID int21_service(iregs FAR * r) break; /* Get default DPB */ - case 0x1f: - if (default_drive < lastdrive) - { - struct dpb FAR *dpb = CDSp->cds_table[default_drive].cdsDpb; - if (dpb == 0) - { - r->AL = 0xff; - CritErrCode = 0x0f; - break; - } - - r->DS = FP_SEG(dpb); - r->BX = FP_OFF(dpb); - r->AL = 0; - } - else{ - r->AL = 0xff; - CritErrCode = 0x0f; - } - break; + /* case 0x1f: see case 0x32 */ /* Random read using FCB */ case 0x21: @@ -870,6 +852,8 @@ VOID int21_service(iregs FAR * r) return_user(); break; + /* Get default BPB */ + case 0x1f: /* Get DPB */ case 0x32: /* r->DL is NOT changed by MS 6.22 */ @@ -878,7 +862,7 @@ VOID int21_service(iregs FAR * r) struct dpb FAR *dpb; UCOUNT drv = r->DL; - if (drv == 0) drv = default_drive; + if (drv == 0 || r->AH == 0x1f) drv = default_drive; else drv--; if (drv >= lastdrive) @@ -1063,6 +1047,8 @@ VOID int21_service(iregs FAR * r) /* Dos Seek */ case 0x42: + { + ULONG lrc; if ((rc = DosSeek(r->BX, (LONG) ((((LONG) (r->CX)) << 16) + r->DX), r->AL, &lrc)) < 0) goto error_exit; else @@ -1070,6 +1056,7 @@ VOID int21_service(iregs FAR * r) r->DX = (lrc >> 16); r->AX = (UWORD)lrc; } + } break; /* Get/Set File Attributes */ @@ -1077,17 +1064,19 @@ VOID int21_service(iregs FAR * r) switch (r->AL) { case 0x00: - rc = DosGetFattr((BYTE FAR *) FP_DS_DX, (UWORD FAR *) & r->CX); + rc = DosGetFattr((BYTE FAR *) FP_DS_DX); + if (rc >= SUCCESS) + r->CX = rc; break; case 0x01: - rc = DosSetFattr((BYTE FAR *) FP_DS_DX, (UWORD FAR *) & r->CX); + rc = DosSetFattr((BYTE FAR *) FP_DS_DX, r->CX); break; default: goto error_invalid; } - if (rc != SUCCESS) + if (rc < SUCCESS) goto error_exit; break; @@ -1493,6 +1482,11 @@ VOID int21_service(iregs FAR * r) break; default: +/* + void int_2f_111e_call(iregs FAR *r); + int_2f_111e_call(r); + break;*/ + rc = -int2f_Remote_call(REM_DOREDIRECT, r->BX, r->CX, r->DX, (MK_FP(r->ES, r->DI)), r->SI, (MK_FP(r->DS, Int21AX))); if (rc != SUCCESS) diff --git a/kernel/ioctl.c b/kernel/ioctl.c index 9c77aaa6..f6daef23 100644 --- a/kernel/ioctl.c +++ b/kernel/ioctl.c @@ -35,6 +35,9 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.11 2001/07/22 01:58:58 bartoldeman + * Support for Brian's FORMAT, DJGPP libc compilation, cleanups, MSCDEX + * * Revision 1.10 2001/07/09 22:19:33 bartoldeman * LBA/FCB/FAT/SYS/Ctrl-C/ioctl fixes + memory savings * @@ -193,10 +196,12 @@ COUNT DosDevIOctl(iregs FAR * r) { case 0x00: /* Get the flags from the SFT */ - r->AX = s->sft_dev->dh_attr; - r->DH = r->AH; + if (s->sft_flags & SFT_FDEVICE) + r->AX = (s->sft_dev->dh_attr & 0xff00) | s->sft_flags_lo; + else + r->AX = s->sft_flags; /* Undocumented result, Ax = Dx seen using Pcwatch */ - r->DL = r->AL = s->sft_flags; + r->DX = r->AX; break; case 0x01: @@ -273,10 +278,6 @@ COUNT DosDevIOctl(iregs FAR * r) { return DE_INVLDDRV; } - if (media_check(dpbp) < 0) - { - return DE_INVLDDRV; - } if ( ((r->AL == 0x04 ) && !(dpbp->dpb_device->dh_attr & ATTR_IOCTL)) || ((r->AL == 0x05 ) && !(dpbp->dpb_device->dh_attr & ATTR_IOCTL)) || ((r->AL == 0x11) && !(dpbp->dpb_device->dh_attr & ATTR_QRYIOCTL)) diff --git a/kernel/kernel.asm b/kernel/kernel.asm index 96ad29e6..041be036 100644 --- a/kernel/kernel.asm +++ b/kernel/kernel.asm @@ -28,6 +28,9 @@ ; $Id$ ; ; $Log$ +; Revision 1.15 2001/07/22 01:58:58 bartoldeman +; Support for Brian's FORMAT, DJGPP libc compilation, cleanups, MSCDEX +; ; Revision 1.14 2001/07/09 22:19:33 bartoldeman ; LBA/FCB/FAT/SYS/Ctrl-C/ioctl fixes + memory savings ; @@ -581,10 +584,15 @@ _lpFcb times 2 dw 0 ;286 - pointer to callers FCB global current_ifn current_ifn dw 0 ;28A - SFT index for next open + ; Pad to 05b2h + times (292h - ($ - _internal_data)) db 0 + dw __PriPathBuffer ; 292 - "sda_WFP_START" offset in DOS DS of first filename argument + dw __SecPathBuffer ; 294 - "sda_REN_WFP" offset in DOS DS of second filename argument + ; Pad to 05ceh times (2aeh - ($ - _internal_data)) db 0 - global current_filepos -current_filepos times 2 dw 0 ;2AE - current offset in file + global _current_filepos +_current_filepos times 2 dw 0 ;2AE - current offset in file ; Pad to 05f0h times (2d0h - ($ - _internal_data)) db 0 @@ -597,13 +605,13 @@ prev_int21regs_seg dw 0 ; Pad to 0620h times (300h - ($ - _internal_data)) db 0 + global _szNames +_szNames: +;; times 11 db 0 global _FcbSearchBuffer ; during FCB search 1st/next use bottom _FcbSearchBuffer: ; of error stack as scratch buffer ; times 43 db 0 ; - only used during int 21 call - global _LocalPath -_LocalPath: -; times 67 db 0 ; stacks are made to initialize to no-ops so that high-water ; testing can be performed @@ -664,7 +672,7 @@ __ib_end: ; kernel startup stack global init_tos - resw 384 + resw 512 init_tos: ; the last paragraph of conventional memory might become an MCB resb 16 diff --git a/kernel/kernel.mak b/kernel/kernel.mak index 41694551..942f5527 100644 --- a/kernel/kernel.mak +++ b/kernel/kernel.mak @@ -5,6 +5,9 @@ # # $Log$ +# Revision 1.12 2001/07/22 01:58:58 bartoldeman +# Support for Brian's FORMAT, DJGPP libc compilation, cleanups, MSCDEX +# # Revision 1.11 2001/07/09 22:19:33 bartoldeman # LBA/FCB/FAT/SYS/Ctrl-C/ioctl fixes + memory savings # @@ -335,7 +338,7 @@ DynInit.obj: DynInit.c init-mod.h $(HDR)portab.h globals.h $(HDR)device.h \ $(HDR)version.h proto.h turboc.cfg dyndata.h $(CC) $(INITCFLAGS) -c DynInit.c -initdisk.obj: initdisk.c disk.h $(HDR)portab.h globals.h $(HDR)device.h $(HDR)mcb.h \ +initdisk.obj: initdisk.c $(HDR)portab.h globals.h $(HDR)device.h $(HDR)mcb.h \ $(HDR)pcb.h $(HDR)date.h $(HDR)time.h $(HDR)fat.h $(HDR)fcb.h \ $(HDR)tail.h $(HDR)process.h $(HDR)dcb.h $(HDR)sft.h $(HDR)cds.h \ $(HDR)exe.h $(HDR)fnode.h $(HDR)dirmatch.h $(HDR)file.h \ @@ -399,7 +402,7 @@ dosnames.obj: dosnames.c $(HDR)portab.h globals.h $(HDR)device.h \ $(HDR)file.h $(HDR)clock.h $(HDR)kbd.h $(HDR)error.h \ $(HDR)version.h proto.h turboc.cfg -dsk.obj: dsk.c disk.h $(HDR)portab.h globals.h $(HDR)device.h $(HDR)mcb.h \ +dsk.obj: dsk.c $(HDR)portab.h globals.h $(HDR)device.h $(HDR)mcb.h \ $(HDR)pcb.h $(HDR)date.h $(HDR)time.h $(HDR)fat.h $(HDR)fcb.h \ $(HDR)tail.h $(HDR)process.h $(HDR)dcb.h $(HDR)sft.h $(HDR)cds.h \ $(HDR)exe.h $(HDR)fnode.h $(HDR)dirmatch.h $(HDR)file.h \ diff --git a/kernel/main.c b/kernel/main.c index f34ef750..73b26da3 100644 --- a/kernel/main.c +++ b/kernel/main.c @@ -71,6 +71,9 @@ static BYTE *mainRcsId = "$Id$"; /* * $Log$ + * Revision 1.19 2001/07/22 01:58:58 bartoldeman + * Support for Brian's FORMAT, DJGPP libc compilation, cleanups, MSCDEX + * * Revision 1.18 2001/07/09 22:19:33 bartoldeman * LBA/FCB/FAT/SYS/Ctrl-C/ioctl fixes + memory savings * @@ -409,20 +412,6 @@ INIT VOID FsConfig(VOID) pcds_table->cdsJoinOffset = 2; } - /* - this is a quick patch - see if B: exists - test for A: also, need not exist - */ - { - iregs r; - - init_call_intr(0x11,&r); /* get equipment list */ - if ((r.a.x & 1)==0 || ((r.a.x & 1) && (r.a.x & 0xc0)==0)) - /* no floppy drives installed or no B: drive */ - CDSp->cds_table[1].cdsFlags = 0; - if ((r.a.x & 1)==0) /* no floppy drives installed */ - CDSp->cds_table[0].cdsFlags = 0; - } /* Initialize the disk buffer management functions */ /* init_call_init_buffers(); done from CONFIG.C */ } diff --git a/kernel/network.c b/kernel/network.c index f990678c..b0d52da0 100644 --- a/kernel/network.c +++ b/kernel/network.c @@ -36,6 +36,9 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.13 2001/07/22 01:58:58 bartoldeman + * Support for Brian's FORMAT, DJGPP libc compilation, cleanups, MSCDEX + * * Revision 1.12 2001/04/29 17:34:40 bartoldeman * A new SYS.COM/config.sys single stepping/console output/misc fixes. * @@ -117,6 +120,7 @@ UCOUNT Remote_RW(UWORD func, UCOUNT n, BYTE FAR * bp, sft FAR * s, COUNT FAR * e save_dta = dta; lpCurSft = (sfttbl FAR *) s; + current_filepos = s->sft_posit; /* needed for MSCDEX */ dta = bp; rx = int2f_Remote_call(func, 0, n, 0, (VOID FAR *) s, 0, (VOID FAR *) & rc); dta = save_dta; @@ -128,26 +132,17 @@ UCOUNT Remote_RW(UWORD func, UCOUNT n, BYTE FAR * bp, sft FAR * s, COUNT FAR * e /* */ -COUNT Remote_find(UWORD func, UCOUNT attr, BYTE FAR * name) +COUNT Remote_find(UWORD func) { COUNT i; char FAR *p; +#if defined(FIND_DEBUG) if (func == REM_FINDFIRST) { - SAttr = attr; - i = truename(name, PriPathName, FALSE); - if (i != SUCCESS) { - return i; - } -#if defined(FIND_DEBUG) - printf("Remote Find: n='"); - p = name; while(*p) printf("%c", *p++); - printf("' p='"); - p = PriPathName; while(*p) printf("%c", *p++); - printf("'\n"); -#endif + printf("Remote Find: n='%Fs\n", PriPathName); } +#endif fmemcpy(TempBuffer, dta, 21); p = dta; diff --git a/kernel/prf.c b/kernel/prf.c index 1274bd75..2d73e7da 100644 --- a/kernel/prf.c +++ b/kernel/prf.c @@ -28,6 +28,8 @@ #include "portab.h" +/* #define DOSEMU */ + #ifdef FORINIT #define fstrlen reloc_call_fstrlen #define put_console init_put_console @@ -48,6 +50,9 @@ static BYTE *prfRcsId = "$Id$"; /* * $Log$ + * Revision 1.11 2001/07/22 01:58:58 bartoldeman + * Support for Brian's FORMAT, DJGPP libc compilation, cleanups, MSCDEX + * * Revision 1.10 2001/04/29 17:34:40 bartoldeman * A new SYS.COM/config.sys single stepping/console output/misc fixes. * @@ -70,6 +75,9 @@ static BYTE *prfRcsId = "$Id$"; * recoded for smaller object footprint, added main() for testing+QA * * $Log$ + * Revision 1.11 2001/07/22 01:58:58 bartoldeman + * Support for Brian's FORMAT, DJGPP libc compilation, cleanups, MSCDEX + * * Revision 1.10 2001/04/29 17:34:40 bartoldeman * A new SYS.COM/config.sys single stepping/console output/misc fixes. * @@ -238,19 +246,36 @@ BYTE * #define RIGHT 1 /* printf -- short version of printf to conserve space */ +#ifdef DOSEMU +WORD printf(CONST BYTE * fmt, ...) +{ + WORD ret; + + static char buff[80]; /* adjust if necessary */ + charp = buff; + ret = do_printf(fmt, (BYTE **)&fmt + 1); + handle_char(NULL); + _ES = FP_SEG(buff); + _DX = FP_OFF(buff); + _AX = 0x13; + __int__(0xe6); + return ret; +} +#else WORD printf(CONST BYTE * fmt, ...) { charp = 0; return do_printf(fmt, (BYTE **)&fmt + 1); } +#endif WORD -sprintf(BYTE * buff, CONST BYTE * fmt, BYTE * args,...) +sprintf(BYTE * buff, CONST BYTE * fmt, ...) { WORD ret; charp = buff; - ret = do_printf(fmt, &args); + ret = do_printf(fmt, (BYTE **)&fmt + 1); handle_char(NULL); return ret; } diff --git a/kernel/proto.h b/kernel/proto.h index e9b7f087..84bd96e2 100644 --- a/kernel/proto.h +++ b/kernel/proto.h @@ -34,6 +34,9 @@ static BYTE *Proto_hRcsId = "$Id$"; /* * $Log$ + * Revision 1.18 2001/07/22 01:58:58 bartoldeman + * Support for Brian's FORMAT, DJGPP libc compilation, cleanups, MSCDEX + * * Revision 1.17 2001/06/03 14:16:18 bartoldeman * BUFFERS tuning and misc bug fixes/cleanups (2024c). * @@ -228,8 +231,8 @@ COUNT DosFindFirst(UCOUNT attr, BYTE FAR * name); COUNT DosFindNext(void); COUNT DosGetFtime(COUNT hndl, date FAR * dp, time FAR * tp); COUNT DosSetFtime(COUNT hndl, date FAR * dp, time FAR * tp); -COUNT DosGetFattr(BYTE FAR * name, UWORD FAR * attrp); -COUNT DosSetFattr(BYTE FAR * name, UWORD FAR * attrp); +COUNT DosGetFattr(BYTE FAR * name); +COUNT DosSetFattr(BYTE FAR * name, UWORD attrp); UBYTE DosSelectDrv(UBYTE drv); COUNT DosDelete(BYTE FAR *path); COUNT DosRename(BYTE FAR * path1, BYTE FAR * path2); @@ -245,8 +248,8 @@ VOID DosIdle_int(void); /* dosnames.c */ VOID SpacePad(BYTE *, COUNT); -COUNT ParseDosName(BYTE FAR *, COUNT *, BYTE *, BYTE *, BYTE *, BOOL); -COUNT ParseDosPath(BYTE FAR *, COUNT *, BYTE *, BYTE FAR *); +COUNT ParseDosName(BYTE *, COUNT *, BYTE *, BYTE *, BYTE *, BOOL); +/* COUNT ParseDosPath(BYTE *, COUNT *, BYTE *, BYTE FAR *); */ /* dsk.c */ COUNT FAR blk_driver(rqptr rp); @@ -259,25 +262,25 @@ COUNT char_error(request * rq, struct dhdr FAR * lpDevice); COUNT block_error(request * rq, COUNT nDrive, struct dhdr FAR * lpDevice); /* fatdir.c */ -f_node_ptr dir_open(BYTE FAR * dirname); +f_node_ptr dir_open(BYTE * dirname); COUNT dir_read(REG f_node_ptr fnp); COUNT dir_write(REG f_node_ptr fnp); VOID dir_close(REG f_node_ptr fnp); -COUNT dos_findfirst(UCOUNT attr, BYTE FAR * name); +COUNT dos_findfirst(UCOUNT attr, BYTE * name); COUNT dos_findnext(void); void ConvertName83ToNameSZ(BYTE FAR *destSZ, BYTE FAR *srcFCBName); int FileName83Length(BYTE *filename83); /* fatfs.c */ -COUNT dos_open(BYTE FAR * path, COUNT flag); -BOOL fcmp(BYTE FAR * s1, BYTE FAR * s2, COUNT n); +COUNT dos_open(BYTE * path, COUNT flag); +BOOL fcmp(BYTE * s1, BYTE * s2, COUNT n); BOOL fcmp_wild(BYTE FAR * s1, BYTE FAR * s2, COUNT n); -VOID touc(BYTE FAR * s, COUNT n); +VOID touc(BYTE * s, COUNT n); COUNT dos_close(COUNT fd); -COUNT dos_creat(BYTE FAR * path, COUNT attrib); -COUNT dos_delete(BYTE FAR * path); -COUNT dos_rmdir(BYTE FAR * path); -COUNT dos_rename(BYTE FAR * path1, BYTE FAR * path2); +COUNT dos_creat(BYTE * path, COUNT attrib); +COUNT dos_delete(BYTE * path); +COUNT dos_rmdir(BYTE * path); +COUNT dos_rename(BYTE * path1, BYTE * path2); date dos_getdate(void); time dos_gettime(void); COUNT dos_getftime(COUNT fd, date FAR * dp, time FAR * tp); @@ -285,7 +288,7 @@ COUNT dos_setftime(COUNT fd, date FAR * dp, time FAR * tp); LONG dos_getcufsize(COUNT fd); LONG dos_getfsize(COUNT fd); BOOL dos_setfsize(COUNT fd, LONG size); -COUNT dos_mkdir(BYTE FAR * dir); +COUNT dos_mkdir(BYTE * dir); BOOL last_link(f_node_ptr fnp); COUNT map_cluster(REG f_node_ptr fnp, COUNT mode); UCOUNT readblock(COUNT fd, VOID FAR * buffer, UCOUNT count, COUNT * err); @@ -297,13 +300,13 @@ UWORD dos_free(struct dpb FAR *dpbp); VOID trim_path(BYTE FAR * s); -COUNT dos_cd(struct cds FAR * cdsp, BYTE FAR * PathName); +COUNT dos_cd(struct cds FAR * cdsp, BYTE * PathName); f_node_ptr get_f_node(void); VOID release_f_node(f_node_ptr fnp); VOID dos_setdta(BYTE FAR * newdta); -COUNT dos_getfattr(BYTE FAR * name, UWORD FAR * attrp); -COUNT dos_setfattr(BYTE FAR * name, UWORD FAR * attrp); +COUNT dos_getfattr(BYTE * name); +COUNT dos_setfattr(BYTE * name, UWORD attrp); COUNT media_check(REG struct dpb FAR *dpbp); f_node_ptr xlt_fd(COUNT fd); COUNT xlt_fnp(f_node_ptr fnp); @@ -421,7 +424,7 @@ UWORD syscall_MUX14(DIRECT_IREGS); /* prf.c */ VOID put_console(COUNT c); WORD printf(CONST BYTE * fmt,...); -WORD sprintf(BYTE * buff, CONST BYTE * fmt,...); +WORD sprintf(BYTE * buff, CONST BYTE * fmt, ...); VOID hexd(char *title,VOID FAR *p,COUNT numBytes); /* strings.c */ @@ -488,7 +491,7 @@ COUNT QRemote_Fn(char FAR * s, char FAR * d); UWORD get_machine_name(BYTE FAR * netname); VOID set_machine_name(BYTE FAR * netname, UWORD name_num); UCOUNT Remote_RW(UWORD func, UCOUNT n, BYTE FAR * bp, sft FAR * s, COUNT FAR * err); -COUNT Remote_find(UWORD func, UCOUNT attr, BYTE FAR * name); +COUNT Remote_find(UWORD func); /* procsupt.asm */ VOID INRPT FAR exec_user(iregs FAR * irp); diff --git a/kernel/sysclk.c b/kernel/sysclk.c index dde096a0..9dddce54 100644 --- a/kernel/sysclk.c +++ b/kernel/sysclk.c @@ -35,6 +35,9 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.7 2001/07/22 01:58:58 bartoldeman + * Support for Brian's FORMAT, DJGPP libc compilation, cleanups, MSCDEX + * * Revision 1.6 2001/04/21 22:32:53 bartoldeman * Init DS=Init CS, fixed stack overflow problems and misc bugs. * @@ -121,17 +124,19 @@ extern WORD days[2][13]; /* this is defined by SYSTIME.C */ static struct ClockRecord clk; +/* static BYTE bcdDays[4]; static UWORD Month, Day, Year; static BYTE bcdMinutes; static BYTE bcdHours; -/** static BYTE bcdHundredths;*/ +/ ** static BYTE bcdHundredths;* / static BYTE bcdSeconds; static ULONG Ticks; UWORD DaysSinceEpoch = 0; +*/ BOOL ReadATClock(BYTE *, BYTE *, BYTE *, BYTE *); @@ -149,7 +154,13 @@ WORD FAR clk_driver(rqptr rp) bcd_minutes, bcd_hours, bcd_seconds; - ULONG ticks; + ULONG Ticks; + UWORD DaysSinceEpoch; + UWORD Month, + Day, + Year; + + switch (rp->r_command) { @@ -170,10 +181,10 @@ WORD FAR clk_driver(rqptr rp) * so we can simply multiply the number of seconds by 19663 without * worrying about overflow. :) -- ror4 */ - ticks = (3600ul * BcdToByte(bcd_hours) + + Ticks = (3600ul * BcdToByte(bcd_hours) + 60ul * BcdToByte(bcd_minutes) + BcdToByte(bcd_seconds)) * 19663ul / 1080ul; - WritePCClock(ticks); + WritePCClock(Ticks); } rp->r_endaddr = device_end(); rp->r_nunits = 0; @@ -343,11 +354,11 @@ WORD FAR clk_driver(rqptr rp) } - DayToBcd((BYTE *) bcdDays, &Month, &Day, &Year); - bcdMinutes = ByteToBcd(clk.clkMinutes); - bcdHours = ByteToBcd(clk.clkHours); - bcdSeconds = ByteToBcd(clk.clkSeconds); - WriteATClock(bcdDays, bcdHours, bcdMinutes, bcdSeconds); + DayToBcd((BYTE *) bcd_days, &Month, &Day, &Year); + bcd_minutes = ByteToBcd(clk.clkMinutes); + bcd_hours = ByteToBcd(clk.clkHours); + bcd_seconds = ByteToBcd(clk.clkSeconds); + WriteATClock(bcd_days, bcd_hours, bcd_minutes, bcd_seconds); return S_DONE; case C_OFLUSH: diff --git a/kernel/task.c b/kernel/task.c index e3aaa131..1e8ff9b6 100644 --- a/kernel/task.c +++ b/kernel/task.c @@ -35,6 +35,9 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.15 2001/07/22 01:58:58 bartoldeman + * Support for Brian's FORMAT, DJGPP libc compilation, cleanups, MSCDEX + * * Revision 1.14 2001/06/03 14:16:18 bartoldeman * BUFFERS tuning and misc bug fixes/cleanups (2024c). * @@ -163,9 +166,6 @@ static BYTE *RcsId = "$Id$"; * Rev 1.0 02 Jul 1995 8:34:06 patv * Initial revision. */ -#if 0 -extern VOID ClaimINITDataSegment(VOID); -#endif #define toupper(c) ((c) >= 'a' && (c) <= 'z' ? (c) + ('A' - 'a') : (c)) #define LOADNGO 0 @@ -185,6 +185,10 @@ static exe_header header; + 1 byte: '\0' -- 1999/04/21 ska */ +#ifdef __TURBOC__ +void __int__(int); /* TC 2.01 requires this. :( -- ror4 */ +#endif + #ifndef PROTO COUNT ChildEnv(exec_blk FAR *, UWORD *, char far *); #else @@ -587,13 +591,6 @@ COUNT DosComLoader(BYTE FAR * namep, exec_blk FAR * exp, COUNT mode) cu_psp = mem; dta = p->ps_dta; - /* if that's the first time, we arrive here - now we 1 microsecond from COMMAND.COM - now we claim the ID = INIT_DATA segment, - which should no longer be used - ClaimINITDataSegment(); - */ - if (InDOS) --InDOS; exec_user(irp); @@ -658,7 +655,7 @@ COUNT DosExeLoader(BYTE FAR * namep, exec_blk FAR * exp, COUNT mode) /*err, */ /*env_size,*/ i; - COUNT nBytesRead; + UCOUNT nBytesRead; UWORD mem, env, asize, @@ -722,6 +719,8 @@ COUNT DosExeLoader(BYTE FAR * namep, exec_blk FAR * exp, COUNT mode) } exe_size = (LONG) long2para(image_size) + header.exMinAlloc; + + /* + long2para((LONG) sizeof(psp)); ?? see above image_size += sizeof(psp) -- 1999/04/21 ska */ if (exe_size > asize && (mem_access_mode & 0x80)) @@ -745,6 +744,16 @@ COUNT DosExeLoader(BYTE FAR * namep, exec_blk FAR * exp, COUNT mode) /* + long2para((LONG) sizeof(psp)); ?? -- 1999/04/21 ska */ if (exe_size > asize) exe_size = asize; + + /* TE if header.exMinAlloc == header.exMaxAlloc == 0, + DOS will allocate the largest possible memory area + and load the image as high as possible into it. + discovered (and after that found in RBIL), when testing NET */ + + if ((header.exMinAlloc | header.exMaxAlloc ) == 0) + exe_size = asize; + + /* /// Removed closing curly brace. We should not attempt to allocate memory if we are overlaying the current process, because the new process will simply re-use the block we already have allocated. @@ -848,26 +857,24 @@ COUNT DosExeLoader(BYTE FAR * namep, exec_blk FAR * exp, COUNT mode) /* read in the image in 32K chunks */ if (mode != OVERLAY) { - exe_size = image_size - long2para((LONG) sizeof(psp)); + exe_size = image_size - sizeof(psp); } else exe_size = image_size; if (exe_size > 0) { - UCOUNT tmp = 16; - - sp = MK_FP(start_seg, 0x0); - if (mode != OVERLAY) { if ((header.exMinAlloc == 0) && (header.exMaxAlloc == 0)) { - sp = MK_FP(start_seg + mp->m_size - - (image_size + 15) / tmp, 0); + /* then the image should be placed as high as possible */ + start_seg = start_seg + mp->m_size - (image_size + 15) / 16; } } + sp = MK_FP(start_seg, 0x0); + do { nBytesRead = DosRead((COUNT) rc, (COUNT) (exe_size < CHUNK ? exe_size : CHUNK), (VOID FAR *) sp, &UnusedRetVal); @@ -942,14 +949,6 @@ COUNT DosExeLoader(BYTE FAR * namep, exec_blk FAR * exp, COUNT mode) cu_psp = mem; dta = p->ps_dta; - - /* if that's the first time, we arrive here - now we 1 microsecond from COMMAND.COM - now we claim the ID = INIT_DATA segment, - which should no longer be used - ClaimINITDataSegment(); - */ - if (InDOS) --InDOS; exec_user(irp); From 77e49f87c763016be34cb436337ddbae90bb7585 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Mon, 23 Jul 2001 12:47:42 +0000 Subject: [PATCH 084/671] FCB fixes and clean-ups, exec int21/ax=4b01, initdisk.c printf git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@267 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/chario.c | 10 +- kernel/dosfns.c | 320 ++++++++++++++++++------------------- kernel/fatdir.c | 41 ++--- kernel/fcbfns.c | 392 +++++++++++++++------------------------------- kernel/initdisk.c | 7 +- kernel/inthndlr.c | 5 +- kernel/proto.h | 17 +- kernel/task.c | 116 +++++++------- 8 files changed, 401 insertions(+), 507 deletions(-) diff --git a/kernel/chario.c b/kernel/chario.c index ffbc3b6e..337a271c 100644 --- a/kernel/chario.c +++ b/kernel/chario.c @@ -36,6 +36,9 @@ static BYTE *charioRcsId = "$Id$"; /* * $Log$ + * Revision 1.10 2001/07/23 12:47:42 bartoldeman + * FCB fixes and clean-ups, exec int21/ax=4b01, initdisk.c printf + * * Revision 1.9 2001/06/03 14:16:17 bartoldeman * BUFFERS tuning and misc bug fixes/cleanups (2024c). * @@ -185,9 +188,7 @@ VOID cso(COUNT c) VOID sto(COUNT c) { - static COUNT scratch; /* make this static to save stack space */ - - DosWrite(STDOUT, 1, (BYTE FAR *) & c, (COUNT FAR *) &scratch); + DosWrite(STDOUT, 1, (BYTE FAR *) & c, (COUNT FAR *) &UnusedRetVal); } VOID mod_sto(REG UCOUNT c) @@ -224,13 +225,12 @@ VOID Do_DosIdle_loop(void) UCOUNT _sti(void) { - static COUNT scratch; UBYTE c; /* * XXX: If there's a read error, this will just keep retrying the read until * the error disappears. Maybe it should do something else instead. -- ror4 */ - while (GenericRead(STDIN, 1, (BYTE FAR *) & c, (COUNT FAR *) & scratch, TRUE) + while (GenericRead(STDIN, 1, (BYTE FAR *) & c, (COUNT FAR *) & UnusedRetVal, TRUE) != 1) ; return c; } diff --git a/kernel/dosfns.c b/kernel/dosfns.c index f1c1bbeb..4e522e4b 100644 --- a/kernel/dosfns.c +++ b/kernel/dosfns.c @@ -37,6 +37,9 @@ static BYTE *dosfnsRcsId = "$Id$"; * /// Added SHARE support. 2000/09/04 Ron Cemer * * $Log$ + * Revision 1.21 2001/07/23 12:47:42 bartoldeman + * FCB fixes and clean-ups, exec int21/ax=4b01, initdisk.c printf + * * Revision 1.20 2001/07/22 01:58:58 bartoldeman * Support for Brian's FORMAT, DJGPP libc compilation, cleanups, MSCDEX * @@ -182,9 +185,8 @@ static BYTE *dosfnsRcsId = "$Id$"; #include "globals.h" -sft FAR *get_sft(UCOUNT); -WORD get_free_hndl(VOID); -sft FAR *get_free_sft(WORD FAR *); +COUNT get_free_hndl(VOID); +sft FAR *get_free_sft(COUNT *); BOOL cmatch(COUNT, COUNT, COUNT); f_node_ptr xlt_fd(COUNT); @@ -257,34 +259,41 @@ static VOID DosGetFile(BYTE * lpszPath, BYTE FAR * lpszDosFileName) fbcopy((BYTE FAR *) szLclExt, &lpszDosFileName[FNAME_SIZE], FEXT_SIZE); } -sft FAR *get_sft(UCOUNT hndl) +sft FAR *idx_to_sft(COUNT SftIndex) { - psp FAR *p = MK_FP(cu_psp, 0); - WORD sys_idx; sfttbl FAR *sp; - if (hndl >= p->ps_maxfiles) + if (SftIndex < 0) return (sft FAR *) - 1; /* Get the SFT block that contains the SFT */ - if (p->ps_filetab[hndl] == 0xff) - return (sft FAR *) - 1; - - sys_idx = p->ps_filetab[hndl]; - for (sp = sfthead; sp != (sfttbl FAR *) - 1; sp = sp->sftt_next) + for (sp = sfthead; sp != (sfttbl FAR *) - 1; + sp = sp->sftt_next) { - if (sys_idx < sp->sftt_count) - break; + if (SftIndex < sp->sftt_count) + /* finally, point to the right entry */ + return (sft FAR *) & (sp->sftt_table[SftIndex]); else - sys_idx -= sp->sftt_count; + SftIndex -= sp->sftt_count; } - /* If not found, return an error */ - if (sp == (sfttbl FAR *) - 1) - return (sft FAR *) - 1; + return (sft FAR *) - 1; +} + +STATIC COUNT get_sft_idx(UCOUNT hndl) +{ + psp FAR *p = MK_FP(cu_psp, 0); - /* finally, point to the right entry */ - return (sft FAR *) & (sp->sftt_table[sys_idx]); + if (hndl >= p->ps_maxfiles) + return DE_INVLDHNDL; + + return p->ps_filetab[hndl] == 0xff ? DE_INVLDHNDL : p->ps_filetab[hndl]; +} + +sft FAR *get_sft(UCOUNT hndl) +{ + /* Get the SFT block that contains the SFT */ + return idx_to_sft(get_sft_idx(hndl)); } /* @@ -298,17 +307,8 @@ UCOUNT GenericRead(COUNT hndl, UCOUNT n, BYTE FAR * bp, COUNT FAR * err, BOOL force_binary) { sft FAR *s; -/* WORD sys_idx;*/ -/*sfttbl FAR *sp;*/ UCOUNT ReadCount; - /* Test that the handle is valid */ - if (hndl < 0) - { - *err = DE_INVLDHNDL; - return 0; - } - /* Get the SFT block that contains the SFT */ if ((s = get_sft(hndl)) == (sft FAR *) - 1) { @@ -436,17 +436,8 @@ UCOUNT DosRead(COUNT hndl, UCOUNT n, BYTE FAR * bp, COUNT FAR * err) UCOUNT DosWrite(COUNT hndl, UCOUNT n, BYTE FAR * bp, COUNT FAR * err) { sft FAR *s; -/* WORD sys_idx;*/ -/*sfttbl FAR *sp;*/ UCOUNT WriteCount; - /* Test that the handle is valid */ - if (hndl < 0) - { - *err = DE_INVLDHNDL; - return 0; - } - /* Get the SFT block that contains the SFT */ if ((s = get_sft(hndl)) == (sft FAR *) - 1) { @@ -685,10 +676,6 @@ COUNT DosSeek(COUNT hndl, LONG new_pos, COUNT mode, ULONG * set_pos) sft FAR *s; COUNT result; - /* Test that the handle is valid */ - if (hndl < 0) - return DE_INVLDHNDL; - /* Get the SFT block that contains the SFT */ if ((s = get_sft(hndl)) == (sft FAR *) - 1) return DE_INVLDHNDL; @@ -700,7 +687,7 @@ COUNT DosSeek(COUNT hndl, LONG new_pos, COUNT mode, ULONG * set_pos) return result; } -STATIC WORD get_free_hndl(void) +STATIC COUNT get_free_hndl(void) { psp FAR *p = MK_FP(cu_psp, 0); WORD hndl; @@ -710,12 +697,12 @@ STATIC WORD get_free_hndl(void) if (p->ps_filetab[hndl] == 0xff) return hndl; } - return 0xff; + return DE_TOOMANY; } -sft FAR *get_free_sft(WORD FAR * sft_idx) +sft FAR *get_free_sft(COUNT *sft_idx) { - WORD sys_idx = 0; + COUNT sys_idx = 0; sfttbl FAR *sp; /* Get the SFT block that contains the SFT */ @@ -773,15 +760,13 @@ BOOL fnmatch(BYTE FAR * s, BYTE FAR * d, COUNT n, COUNT mode) return TRUE; } -COUNT DosCreat(BYTE FAR * fname, COUNT attrib) +COUNT DosCreatSft(BYTE * fname, COUNT attrib) { - psp FAR *p = MK_FP(cu_psp, 0); - WORD hndl, sft_idx; + COUNT sft_idx; sft FAR *sftp; struct dhdr FAR *dhp; -/* BYTE FAR *froot;*/ -/* WORD i;*/ - COUNT result, drive; + WORD result; + COUNT drive; /* NEVER EVER allow directories to be created */ if (attrib & ~(D_RDONLY|D_HIDDEN|D_SYSTEM|D_ARCHIVE)) @@ -789,30 +774,28 @@ COUNT DosCreat(BYTE FAR * fname, COUNT attrib) return DE_ACCESS; } - /* get a free handle */ - if ((hndl = get_free_hndl()) == 0xff) - return DE_TOOMANY; - /* now get a free system file table entry */ - if ((sftp = get_free_sft((WORD FAR *) & sft_idx)) == (sft FAR *) - 1) + if ((sftp = get_free_sft(&sft_idx)) == (sft FAR *) - 1) return DE_TOOMANY; + fmemset(sftp, 0, sizeof(sft)); + sftp->sft_shroff = -1; /* /// Added for SHARE - Ron Cemer */ + sftp->sft_psp = cu_psp; + sftp->sft_mode = SFT_MRDWR; + sftp->sft_attrib = attrib; + sftp->sft_psp = cu_psp; /* check for a device */ dhp = IsDevice(fname); if ( dhp ) { sftp->sft_count += 1; - sftp->sft_mode = SFT_MRDWR; - sftp->sft_attrib = attrib; sftp->sft_flags = ((dhp->dh_attr & ~SFT_MASK) & ~SFT_FSHARED) | SFT_FDEVICE | SFT_FEOF; - sftp->sft_psp = cu_psp; fbcopy((BYTE FAR *) SecPathName, sftp->sft_name, FNAME_SIZE + FEXT_SIZE); sftp->sft_dev = dhp; - p->ps_filetab[hndl] = sft_idx; - return hndl; + return sft_idx; } drive = get_verify_drive(fname); @@ -820,27 +803,21 @@ COUNT DosCreat(BYTE FAR * fname, COUNT attrib) return drive; } - result = truename(fname, PriPathName, FALSE); - if (result != SUCCESS) { - return result; - } - if (CDSp->cds_table[drive].cdsFlags & CDSNETWDRV) { lpCurSft = (sfttbl FAR *)sftp; sftp->sft_mode = attrib; result = -int2f_Remote_call(REM_CREATE, 0, 0, 0, (VOID FAR *) sftp, 0, MK_FP(0, attrib)); - if (result == SUCCESS) { - sftp->sft_count += 1; - p->ps_filetab[hndl] = sft_idx; - return hndl; - } + if (result == SUCCESS) { + sftp->sft_count += 1; + return sft_idx; + } return result; } /* /// Added for SHARE. - Ron Cemer */ if (IsShareInstalled()) { if ((sftp->sft_shroff = share_open_check - ((char far *)PriPathName, + ((char far *)fname, cu_psp, 0x02, /* read-write */ 0)) < 0) /* compatibility mode */ @@ -848,17 +825,13 @@ COUNT DosCreat(BYTE FAR * fname, COUNT attrib) } /* /// End of additions for SHARE. - Ron Cemer */ - sftp->sft_status = dos_creat(PriPathName, attrib); + sftp->sft_status = dos_creat(fname, attrib); if (sftp->sft_status >= 0) { - p->ps_filetab[hndl] = sft_idx; sftp->sft_count += 1; - sftp->sft_mode = SFT_MRDWR; - sftp->sft_attrib = attrib; sftp->sft_flags = drive; - sftp->sft_psp = cu_psp; - DosGetFile(PriPathName, sftp->sft_name); - return hndl; + DosGetFile(fname, sftp->sft_name); + return sft_idx; } else { /* /// Added for SHARE *** CURLY BRACES ADDED ALSO!!! ***. - Ron Cemer */ if (IsShareInstalled()) { @@ -870,6 +843,29 @@ COUNT DosCreat(BYTE FAR * fname, COUNT attrib) } } +COUNT DosCreat(BYTE FAR * fname, COUNT attrib) +{ + psp FAR *p = MK_FP(cu_psp, 0); + COUNT sft_idx, hndl, result; + + /* get a free handle */ + if ((hndl = get_free_hndl()) < 0) + return hndl; + + result = truename(fname, PriPathName, FALSE); + if (result != SUCCESS) { + return result; + } + + sft_idx = DosCreatSft(PriPathName, attrib); + + if (sft_idx < SUCCESS) + return sft_idx; + + p->ps_filetab[hndl] = sft_idx; + return hndl; +} + COUNT CloneHandle(COUNT hndl) { sft FAR *sftp; @@ -900,8 +896,8 @@ COUNT DosDup(COUNT Handle) return DE_INVLDHNDL; /* now get a free handle */ - if ((NewHandle = get_free_hndl()) == 0xff) - return DE_TOOMANY; + if ((NewHandle = get_free_hndl()) < 0) + return NewHandle; /* If everything looks ok, bump it up. */ if ((Sftp->sft_flags & (SFT_FDEVICE | SFT_FSHARED)) || (Sftp->sft_status >= 0)) @@ -948,40 +944,30 @@ COUNT DosForceDup(COUNT OldHandle, COUNT NewHandle) return DE_INVLDHNDL; } -COUNT DosOpen(BYTE FAR * fname, COUNT mode) +COUNT DosOpenSft(BYTE * fname, COUNT mode) { - psp FAR *p = MK_FP(cu_psp, 0); - WORD hndl; - WORD sft_idx; + COUNT sft_idx; sft FAR *sftp; struct dhdr FAR *dhp; COUNT drive, result; -/* /// Added to adjust for filenames which begin with ".\" - The problem was manifesting itself in the inability - to run an program whose filename (without the extension) - was longer than six characters and the PATH variable - contained ".", unless you explicitly specified the full - path to the executable file. - Jun 11, 2000 - rbc */ - if ( (fname[0] == '.') && ((fname[1] == '\\') || (fname[1] == '/'))) fname += 2; + OpenMode = (BYTE) mode; /* test if mode is in range */ if ((mode & ~SFT_OMASK) != 0) return DE_INVLDACC; mode &= 3; - /* get a free handle */ - if ((hndl = get_free_hndl()) == 0xff) - return DE_TOOMANY; OpenMode = (BYTE) mode; /* now get a free system file table entry */ - if ((sftp = get_free_sft((WORD FAR *) & sft_idx)) == (sft FAR *) - 1) + if ((sftp = get_free_sft(&sft_idx)) == (sft FAR *) - 1) return DE_TOOMANY; fmemset(sftp, 0, sizeof(sft)); + sftp->sft_psp = cu_psp; + sftp->sft_mode = mode; /* check for a device */ dhp = IsDevice(fname); @@ -989,18 +975,15 @@ COUNT DosOpen(BYTE FAR * fname, COUNT mode) { sftp->sft_shroff = -1; /* /// Added for SHARE - Ron Cemer */ - sftp->sft_mode = mode; sftp->sft_count += 1; sftp->sft_flags = ((dhp->dh_attr & ~SFT_MASK) & ~SFT_FSHARED) | SFT_FDEVICE | SFT_FEOF; - sftp->sft_psp = cu_psp; fbcopy((BYTE FAR *) SecPathName, sftp->sft_name, FNAME_SIZE + FEXT_SIZE); sftp->sft_dev = dhp; sftp->sft_date = dos_getdate(); sftp->sft_time = dos_gettime(); - p->ps_filetab[hndl] = sft_idx; - return hndl; + return sft_idx; } drive = get_verify_drive(fname); @@ -1008,29 +991,21 @@ COUNT DosOpen(BYTE FAR * fname, COUNT mode) return drive; } - result = truename(fname, PriPathName, FALSE); - if (result != SUCCESS) { - return result; - } - if (CDSp->cds_table[drive].cdsFlags & CDSNETWDRV) { lpCurSft = (sfttbl FAR *)sftp; result = -int2f_Remote_call(REM_OPEN, 0, 0, 0, (VOID FAR *) sftp, 0, MK_FP(0, mode)); if (result == SUCCESS) { sftp->sft_count += 1; - p->ps_filetab[hndl] = sft_idx; - return hndl; + return sft_idx; } return result; } sftp->sft_shroff = -1; /* /// Added for SHARE - Ron Cemer */ - sftp->sft_mode = mode; - -/* /// Added for SHARE. - Ron Cemer */ + /* /// Added for SHARE. - Ron Cemer */ if (IsShareInstalled()) { if ((sftp->sft_shroff = share_open_check - ((char far *)PriPathName, + ((char far *)fname, (unsigned short)cu_psp, mode & 0x03, (mode >> 2) & 0x07)) < 0) @@ -1038,7 +1013,7 @@ COUNT DosOpen(BYTE FAR * fname, COUNT mode) } /* /// End of additions for SHARE. - Ron Cemer */ - sftp->sft_status = dos_open(PriPathName, mode); + sftp->sft_status = dos_open(fname, mode); if (sftp->sft_status >= 0) { @@ -1052,14 +1027,16 @@ COUNT DosOpen(BYTE FAR * fname, COUNT mode) { return DE_ACCESS; } - p->ps_filetab[hndl] = sft_idx; + sftp->sft_size = dos_getfsize(sftp->sft_status); + dos_getftime(sftp->sft_status, + (date FAR *) & sftp->sft_date, + (time FAR *) & sftp->sft_time); sftp->sft_count += 1; sftp->sft_mode = mode; sftp->sft_flags = drive; - sftp->sft_psp = cu_psp; - DosGetFile(PriPathName, sftp->sft_name); - return hndl; + DosGetFile(fname, sftp->sft_name); + return sft_idx; } else { /* /// Added for SHARE *** CURLY BRACES ADDED ALSO!!! ***. - Ron Cemer */ if (IsShareInstalled()) { @@ -1071,33 +1048,47 @@ COUNT DosOpen(BYTE FAR * fname, COUNT mode) } } -COUNT DosClose(COUNT hndl) +COUNT DosOpen(BYTE FAR * fname, COUNT mode) { psp FAR *p = MK_FP(cu_psp, 0); - sft FAR *s; + COUNT sft_idx, result, hndl; - /* Test that the handle is valid */ - if (hndl < 0) - return DE_INVLDHNDL; + /* get a free handle */ + if ((hndl = get_free_hndl()) < 0) + return hndl; - /* Get the SFT block that contains the SFT */ - if ((s = get_sft(hndl)) == (sft FAR *) - 1) + result = truename(fname, PriPathName, FALSE); + if (result != SUCCESS) { + return result; + } + + sft_idx = DosOpenSft(PriPathName, mode); + + if (sft_idx < SUCCESS) + return sft_idx; + + p->ps_filetab[hndl] = sft_idx; + return hndl; +} + +COUNT DosCloseSft(WORD sft_idx) +{ + sft FAR *s = idx_to_sft(sft_idx); + + if (s == (sft FAR *) - 1) return DE_INVLDHNDL; /* If this is not opened another error */ - if (s->sft_count == 0) + /* The second condition is a sanity check and necessary for FcbCloseAll */ + if (s->sft_count == 0 || (s->sft_count == 1 && s->sft_psp != cu_psp)) return DE_ACCESS; lpCurSft = (sfttbl FAR *) s; /* remote sub sft_count. */ - p->ps_filetab[hndl] = 0xff; if (s->sft_flags & SFT_FSHARED) - { - int2f_Remote_call(REM_CLOSE, 0, 0, 0, (VOID FAR *) s, 0, 0); - return SUCCESS; - } + return -int2f_Remote_call(REM_CLOSE, 0, 0, 0, (VOID FAR *) s, 0, 0); /* now just drop the count if a device, else */ /* call file system handler */ @@ -1120,6 +1111,18 @@ COUNT DosClose(COUNT hndl) } } +COUNT DosClose(COUNT hndl) +{ + psp FAR *p = MK_FP(cu_psp, 0); + COUNT ret; + + /* Get the SFT block that contains the SFT */ + ret = DosCloseSft(get_sft_idx(hndl)); + if (ret != DE_INVLDHNDL && ret != DE_ACCESS) + p->ps_filetab[hndl] = 0xff; + return ret; +} + VOID DosGetFree(UBYTE drive, COUNT FAR * spc, COUNT FAR * navc, COUNT FAR * bps, COUNT FAR * nc) { struct dpb FAR *dpbp; @@ -1332,10 +1335,6 @@ COUNT DosGetFtime(COUNT hndl, date FAR * dp, time FAR * tp) sft FAR *s; /*sfttbl FAR *sp;*/ - /* Test that the handle is valid */ - if (hndl < 0) - return DE_INVLDHNDL; - /* Get the SFT block that contains the SFT */ if ((s = get_sft(hndl)) == (sft FAR *) - 1) return DE_INVLDHNDL; @@ -1356,17 +1355,12 @@ COUNT DosGetFtime(COUNT hndl, date FAR * dp, time FAR * tp) return dos_getftime(s->sft_status, dp, tp); } -COUNT DosSetFtime(COUNT hndl, date FAR * dp, time FAR * tp) +COUNT DosSetFtimeSft(WORD sft_idx, date FAR * dp, time FAR * tp) { - sft FAR *s; -/*sfttbl FAR *sp;*/ - - /* Test that the handle is valid */ - if (hndl < 0) - return DE_INVLDHNDL; - /* Get the SFT block that contains the SFT */ - if ((s = get_sft(hndl)) == (sft FAR *) - 1) + sft FAR *s = idx_to_sft(sft_idx); + + if (s == (sft FAR *) - 1) return DE_INVLDHNDL; /* If this is not opened another error */ @@ -1544,33 +1538,42 @@ COUNT DosDelete(BYTE FAR *path) } } -COUNT DosRename(BYTE FAR * path1, BYTE FAR * path2) +COUNT DosRenameTrue(BYTE * path1, BYTE * path2) { - COUNT result, drive1, drive2; + COUNT drive1, drive2; if (IsDevice(path1) || IsDevice(path2)) { return DE_FILENOTFND; - } + } drive1 = get_verify_drive(path1); + drive2 = get_verify_drive(path2); + if ((drive1 != drive2) || (drive1 < 0)) { + return DE_INVLDDRV; + } + current_ldt = &CDSp->cds_table[drive1]; + if (CDSp->cds_table[drive1].cdsFlags & CDSNETWDRV) { + return -int2f_Remote_call(REM_RENAME, 0, 0, 0, 0, 0, 0); + } else { + return dos_rename(PriPathName, SecPathName); + } +} + +COUNT DosRename(BYTE FAR * path1, BYTE FAR * path2) +{ + COUNT result; + result = truename(path1, PriPathName, FALSE); if (result != SUCCESS) { return result; } - drive2 = get_verify_drive(path2); + result = truename(path2, SecPathName, FALSE); if (result != SUCCESS) { return result; } - if ((drive1 != drive2) || (drive1 < 0)) { - return DE_INVLDDRV; - } - current_ldt = &CDSp->cds_table[drive1]; - if (CDSp->cds_table[drive1].cdsFlags & CDSNETWDRV) { - return -int2f_Remote_call(REM_RENAME, 0, 0, 0, 0, 0, 0); - } else { - return dos_rename(PriPathName, SecPathName); - } + + return DosRenameTrue(PriPathName, SecPathName); } COUNT DosMkdir(BYTE FAR * dir) @@ -1630,9 +1633,6 @@ COUNT DosLockUnlock(COUNT hndl, LONG pos, LONG len, COUNT unlock) /* Invalid function unless SHARE is installed. */ if (!IsShareInstalled()) return DE_INVLDFUNC; - /* Test that the handle is valid */ - if (hndl < 0) return DE_INVLDHNDL; - /* Get the SFT block that contains the SFT */ if ((s = get_sft(hndl)) == (sft FAR *) -1) return DE_INVLDHNDL; diff --git a/kernel/fatdir.c b/kernel/fatdir.c index 48ff9146..5c132618 100644 --- a/kernel/fatdir.c +++ b/kernel/fatdir.c @@ -36,6 +36,9 @@ static BYTE *fatdirRcsId = "$Id$"; /* * $Log$ + * Revision 1.19 2001/07/23 12:47:42 bartoldeman + * FCB fixes and clean-ups, exec int21/ax=4b01, initdisk.c printf + * * Revision 1.18 2001/07/22 01:58:58 bartoldeman * Support for Brian's FORMAT, DJGPP libc compilation, cleanups, MSCDEX * @@ -358,6 +361,7 @@ COUNT dir_read(REG f_node_ptr fnp) /* REG j; */ struct buffer FAR *bp; + REG UWORD secsize = fnp->f_dpb->dpb_secsize; /* Directories need to point to their current offset, not for */ /* next op. Therefore, if it is anything other than the first */ @@ -382,7 +386,7 @@ COUNT dir_read(REG f_node_ptr fnp) { if (fnp->f_flags.f_droot) { - if ((fnp->f_diroff / fnp->f_dpb->dpb_secsize + if ((fnp->f_diroff / secsize + fnp->f_dpb->dpb_dirstrt) >= fnp->f_dpb->dpb_data) { @@ -390,18 +394,15 @@ COUNT dir_read(REG f_node_ptr fnp) return 0; } - bp = getblock((ULONG) (fnp->f_diroff / fnp->f_dpb->dpb_secsize + bp = getblock((ULONG) (fnp->f_diroff / secsize + fnp->f_dpb->dpb_dirstrt), fnp->f_dpb->dpb_unit); - bp->b_flag &= ~(BFR_DATA | BFR_FAT); - bp->b_flag |= BFR_DIR | BFR_VALID; #ifdef DISPLAY_GETBLOCK printf("DIR (dir_read)\n"); #endif } else { - REG UWORD secsize = fnp->f_dpb->dpb_secsize; /* Do a "seek" to the directory position */ fnp->f_offset = fnp->f_diroff; @@ -444,8 +445,6 @@ COUNT dir_read(REG f_node_ptr fnp) fnp->f_dpb->dpb_data) + fnp->f_sector, fnp->f_dpb->dpb_unit); - bp->b_flag &= ~(BFR_DATA | BFR_FAT); - bp->b_flag |= BFR_DIR | BFR_VALID; #ifdef DISPLAY_GETBLOCK printf("DIR (dir_read)\n"); #endif @@ -453,15 +452,18 @@ COUNT dir_read(REG f_node_ptr fnp) /* Now that we have the block for our entry, get the */ /* directory entry. */ - if (bp != NULL) - getdirent((BYTE FAR *) & bp->b_buffer[((UWORD)fnp->f_diroff) % fnp->f_dpb->dpb_secsize], - (struct dirent FAR *)&fnp->f_dir); - else + if (bp == NULL) { fnp->f_flags.f_dfull = TRUE; return 0; } + bp->b_flag &= ~(BFR_DATA | BFR_FAT); + bp->b_flag |= BFR_DIR | BFR_VALID; + + getdirent((BYTE FAR *) & bp->b_buffer[((UWORD)fnp->f_diroff) % fnp->f_dpb->dpb_secsize], + (struct dirent FAR *)&fnp->f_dir); + /* Update the fnode's directory info */ fnp->f_flags.f_dfull = FALSE; fnp->f_flags.f_dmod = FALSE; @@ -479,6 +481,7 @@ COUNT dir_read(REG f_node_ptr fnp) COUNT dir_write(REG f_node_ptr fnp) { struct buffer FAR *bp; + REG UWORD secsize = fnp->f_dpb->dpb_secsize; /* Update the entry if it was modified by a write or create... */ if (fnp->f_flags.f_dmod) @@ -488,11 +491,9 @@ COUNT dir_write(REG f_node_ptr fnp) if (fnp->f_flags.f_droot) { bp = getblock( - (ULONG) ((UWORD)fnp->f_diroff / fnp->f_dpb->dpb_secsize + (ULONG) ((UWORD)fnp->f_diroff / secsize + fnp->f_dpb->dpb_dirstrt), fnp->f_dpb->dpb_unit); - bp->b_flag &= ~(BFR_DATA | BFR_FAT); - bp->b_flag |= BFR_DIR | BFR_VALID; #ifdef DISPLAY_GETBLOCK printf("DIR (dir_write)\n"); #endif @@ -503,7 +504,6 @@ COUNT dir_write(REG f_node_ptr fnp) /* can continually update the same directory entry. */ else { - REG UWORD secsize = fnp->f_dpb->dpb_secsize; /* Do a "seek" to the directory position */ /* and convert the fnode to a directory fnode. */ @@ -558,8 +558,10 @@ COUNT dir_write(REG f_node_ptr fnp) return 0; } putdirent((struct dirent FAR *)&fnp->f_dir, - (VOID FAR *) & bp->b_buffer[(UWORD)fnp->f_diroff % fnp->f_dpb->dpb_secsize]); - bp->b_flag |= BFR_DIRTY | BFR_VALID; + (VOID FAR *) & bp->b_buffer[(UWORD)fnp->f_diroff % fnp->f_dpb->dpb_secsize]); + + bp->b_flag &= ~(BFR_DATA | BFR_FAT); + bp->b_flag |= BFR_DIR | BFR_DIRTY | BFR_VALID; } return DIRENT_SIZE; } @@ -801,16 +803,19 @@ COUNT dos_findnext(void) /* If found, transfer it to the dmatch structure */ if (found) { +#if 0 extern VOID FAR *FcbFindFirstDirPtr; - if (FcbFindFirstDirPtr) { /* this works MUCH better, then converting 83 -> ASCIIZ ->83; specifically ".", ".." + + But completely bypasses the network case! */ fmemcpy(FcbFindFirstDirPtr, &fnp->f_dir, 32); } +#endif pop_dmp(dmp, fnp); } diff --git a/kernel/fcbfns.c b/kernel/fcbfns.c index 858e82d9..b5101880 100644 --- a/kernel/fcbfns.c +++ b/kernel/fcbfns.c @@ -35,6 +35,9 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.14 2001/07/23 12:47:42 bartoldeman + * FCB fixes and clean-ups, exec int21/ax=4b01, initdisk.c printf + * * Revision 1.13 2001/07/22 01:58:58 bartoldeman * Support for Brian's FORMAT, DJGPP libc compilation, cleanups, MSCDEX * @@ -144,18 +147,14 @@ static BYTE *RcsId = "$Id$"; fcb FAR *ExtFcbToFcb(xfcb FAR * lpExtFcb); fcb FAR *CommonFcbInit(xfcb FAR * lpExtFcb, BYTE * pszBuffer, COUNT * pCurDrive); void FcbNameInit(fcb FAR * lpFcb, BYTE * pszBuffer, COUNT * pCurDrive); -sft FAR *FcbGetSft(COUNT SftIndex); VOID FcbNextRecord(fcb FAR * lpFcb); -/* sft FAR *FcbGetFreeSft(WORD FAR * sft_idx); */ BOOL FcbCalcRec(xfcb FAR * lpXfcb); -VOID MoveDirInfo(dmatch FAR * lpDmatch, struct dirent FAR * lpDir); +VOID MoveDirInfo(dmatch * lpDmatch, fcb FAR * lpDir); #else fcb FAR *ExtFcbToFcb(); fcb FAR *CommonFcbInit(); void FcbNameInit(); -sft FAR *FcbGetSft(); VOID FcbNextRecord(); -/* sft FAR *FcbGetFreeSft(); */ BOOL FcbCalcRec(); VOID MoveDirInfo(); #endif @@ -166,7 +165,7 @@ VOID MoveDirInfo(); static dmatch Dmatch; -VOID FAR *FcbFindFirstDirPtr = NULL; +/* VOID FAR *FcbFindFirstDirPtr = NULL; */ VOID FatGetDrvData(UCOUNT drive, COUNT FAR * spc, COUNT FAR * bps, @@ -274,6 +273,19 @@ WORD FcbParseFname(int wTestMode, BYTE FAR ** lpFileName, fcb FAR * lpFcb) *lpFileName += 2; } + /* special cases: '.' and '..' */ + if (**lpFileName == '.') + { + lpFcb->fcb_fname[0]='.'; + ++*lpFileName; + if (**lpFileName == '.') + { + lpFcb->fcb_fname[1]='.'; + ++*lpFileName; + } + return PARSE_RET_NOWILD; + } + /* Now to format the file name into the string */ *lpFileName = GetNameField(*lpFileName, (BYTE FAR *) lpFcb->fcb_fname, FNAME_SIZE, (BOOL *) & wRetCodeName); @@ -352,26 +364,6 @@ BYTE FAR *GetNameField(BYTE FAR * lpFileName, BYTE FAR * lpDestField, return lpFileName; } -static sft FAR *FcbGetSft(COUNT SftIndex) -{ - /* Get the SFT block that contains the SFT */ - for (lpCurSft = sfthead; lpCurSft != (sfttbl FAR *) - 1; - lpCurSft = lpCurSft->sftt_next) - { - if (SftIndex < lpCurSft->sftt_count) - break; - else - SftIndex -= lpCurSft->sftt_count; - } - - /* If not found, return an error */ - if (lpCurSft == (sfttbl FAR *) - 1) - return (sft FAR *) - 1; - - /* finally, point to the right entry */ - return (sft FAR *) & (lpCurSft->sftt_table[SftIndex]); -} - static VOID FcbNextRecord(fcb FAR * lpFcb) { if (++lpFcb->fcb_curec > 128) @@ -399,7 +391,7 @@ BOOL FcbRead(xfcb FAR * lpXfcb, COUNT * nErrorCode) lpFcb = ExtFcbToFcb(lpXfcb); /* Get the SFT block that contains the SFT */ - if ((s = FcbGetSft(lpFcb->fcb_sftno)) == (sft FAR *) - 1) + if ((s = idx_to_sft(lpFcb->fcb_sftno)) == (sft FAR *) - 1) return FALSE; /* If this is not opened another error */ @@ -470,7 +462,7 @@ BOOL FcbWrite(xfcb FAR * lpXfcb, COUNT * nErrorCode) lpFcb = ExtFcbToFcb(lpXfcb); /* Get the SFT block that contains the SFT */ - if ((s = FcbGetSft(lpFcb->fcb_sftno)) == (sft FAR *) - 1) + if ((s = idx_to_sft(lpFcb->fcb_sftno)) == (sft FAR *) - 1) return FALSE; /* If this is not opened another error */ @@ -517,24 +509,23 @@ BOOL FcbWrite(xfcb FAR * lpXfcb, COUNT * nErrorCode) BOOL FcbGetFileSize(xfcb FAR * lpXfcb) { - COUNT FcbDrive, - FileNum; + COUNT FcbDrive, hndl; /* Build a traditional DOS file name */ - lpFcb = CommonFcbInit(lpXfcb, PriPathName, &FcbDrive); + lpFcb = CommonFcbInit(lpXfcb, SecPathName, &FcbDrive); /* check for a device */ - if (IsDevice(PriPathName) || (lpFcb->fcb_recsiz == 0)) + if (IsDevice(SecPathName) || (lpFcb->fcb_recsiz == 0)) { return FALSE; } - FileNum = dos_open(PriPathName, O_RDONLY); - if (FileNum >= 0) + hndl = DosOpen(SecPathName, O_RDONLY); + if (hndl >= 0) { LONG fsize; /* Get the size */ - fsize = dos_getfsize(FileNum); + fsize = DosGetFsize(hndl); /* compute the size and update the fcb */ lpFcb->fcb_rndm = fsize / lpFcb->fcb_recsiz; @@ -542,7 +533,7 @@ BOOL FcbGetFileSize(xfcb FAR * lpXfcb) ++lpFcb->fcb_rndm; /* close the file and leave */ - return dos_close(FileNum) == SUCCESS; + return DosClose(hndl) == SUCCESS; } else return FALSE; @@ -631,47 +622,33 @@ BOOL FcbRandomIO(xfcb FAR * lpXfcb, COUNT * nErrorCode, } /* -static sft FAR *FcbGetFreeSft(WORD FAR * sft_idx) +static sft FAR *FcbGetFreeSft(COUNT * sft_idx) see get_free_sft in dosfns.c */ BOOL FcbCreate(xfcb FAR * lpXfcb) { - WORD sft_idx; - sft FAR *sftp; + COUNT sft_idx, FcbDrive; struct dhdr FAR *dhp; - COUNT FcbDrive; - - /* get a free system file table entry */ - if ((sftp = get_free_sft((WORD FAR *) & sft_idx)) == (sft FAR *) - 1) - return DE_TOOMANY; /* Build a traditional DOS file name */ lpFcb = CommonFcbInit(lpXfcb, PriPathName, &FcbDrive); + sft_idx = DosCreatSft(PriPathName, 0); + if (sft_idx < 0) + return FALSE; + /* check for a device */ dhp = IsDevice(PriPathName); - if (dhp || ((sftp->sft_status = dos_creat(PriPathName, 0)) >= 0)) - { - sftp->sft_count += 1; - sftp->sft_mode = O_RDWR; - sftp->sft_attrib = 0; - sftp->sft_flags = dhp ? - ((dhp->dh_attr & ~SFT_MASK) & ~SFT_FSHARED) | SFT_FDEVICE | SFT_FEOF : 0; - sftp->sft_psp = cu_psp; - fbcopy(lpFcb->fcb_fname, sftp->sft_name, FNAME_SIZE + FEXT_SIZE); - sftp->sft_dev = dhp; - lpFcb->fcb_sftno = sft_idx; - lpFcb->fcb_curec = 0; - lpFcb->fcb_recsiz = (dhp ? 0 : 128); - if (!dhp) lpFcb->fcb_drive = FcbDrive; - lpFcb->fcb_fsize = 0; - lpFcb->fcb_date = dos_getdate(); - lpFcb->fcb_time = dos_gettime(); - lpFcb->fcb_rndm = 0; - return TRUE; - } - return FALSE; + lpFcb->fcb_sftno = sft_idx; + lpFcb->fcb_curec = 0; + lpFcb->fcb_recsiz = (dhp ? 0 : 128); + if (!dhp) lpFcb->fcb_drive = FcbDrive; + lpFcb->fcb_fsize = 0; + lpFcb->fcb_date = dos_getdate(); + lpFcb->fcb_time = dos_gettime(); + lpFcb->fcb_rndm = 0; + return TRUE; } STATIC fcb FAR *ExtFcbToFcb(xfcb FAR * lpExtFcb) @@ -697,8 +674,11 @@ STATIC fcb FAR *CommonFcbInit(xfcb FAR * lpExtFcb, BYTE * pszBuffer, return lpFcb; } -void FcbNameInit(fcb FAR * lpFcb, BYTE * pszBuffer, COUNT * pCurDrive) +void FcbNameInit(fcb FAR * lpFcb, BYTE * szBuffer, COUNT * pCurDrive) { + BYTE loc_szBuffer[FNAME_SIZE+1+FEXT_SIZE+1]; + BYTE *pszBuffer = loc_szBuffer; + /* Build a traditional DOS file name */ if (lpFcb->fcb_drive != 0) { @@ -711,107 +691,46 @@ void FcbNameInit(fcb FAR * lpFcb, BYTE * pszBuffer, COUNT * pCurDrive) { *pCurDrive = default_drive + 1; } - ConvertName83ToNameSZ((BYTE FAR *)pszBuffer, (BYTE FAR *) lpFcb->fcb_fname); - -/* - lpszFcbFname = (BYTE FAR *) lpFcb->fcb_fname; - for (loop = FNAME_SIZE; --loop >= 0; ) - { - if (*lpszFcbFname != ' ') - *pszBuffer++ = *lpszFcbFname++; - else - break; - } - - lpszFcbFext = (BYTE FAR *) lpFcb->fcb_fext; - if (*lpszFcbFext != ' ') - { - *pszBuffer++ = '.'; - for (loop = FEXT_SIZE; --loop >= 0; ) - { - if (*lpszFcbFext != ' ') - *pszBuffer++ = *lpszFcbFext++; - else - break; - } - } - *pszBuffer = '\0'; -*/ + truename(loc_szBuffer, szBuffer, FALSE); + /* XXX fix truename error handling */ } BOOL FcbOpen(xfcb FAR * lpXfcb) { - WORD sft_idx; sft FAR *sftp; struct dhdr FAR *dhp; - COUNT FcbDrive; - - /* get a free system file table entry */ - if ((sftp = get_free_sft((WORD FAR *) & sft_idx)) == (sft FAR *) - 1) - return DE_TOOMANY; + COUNT FcbDrive, sft_idx; /* Build a traditional DOS file name */ lpFcb = CommonFcbInit(lpXfcb, PriPathName, &FcbDrive); + sft_idx = DosOpenSft(PriPathName, O_RDWR); + if (sft_idx < 0) + return FALSE; + /* check for a device */ + lpFcb->fcb_curec = 0; + lpFcb->fcb_rndm = 0; + lpFcb->fcb_sftno = sft_idx; dhp = IsDevice(PriPathName); if (dhp ) { - sftp->sft_count += 1; - sftp->sft_mode = O_RDWR; - sftp->sft_attrib = 0; - sftp->sft_flags = - ((dhp->dh_attr & ~SFT_MASK) & ~SFT_FSHARED) | SFT_FDEVICE | SFT_FEOF; - sftp->sft_psp = cu_psp; - fbcopy(lpFcb->fcb_fname, sftp->sft_name, FNAME_SIZE + FEXT_SIZE); - sftp->sft_dev = dhp; - lpFcb->fcb_sftno = sft_idx; - lpFcb->fcb_curec = 0; - lpFcb->fcb_recsiz = 0; - lpFcb->fcb_fsize = 0; - lpFcb->fcb_date = dos_getdate(); - lpFcb->fcb_time = dos_gettime(); - lpFcb->fcb_rndm = 0; - return TRUE; + lpFcb->fcb_recsiz = 0; + lpFcb->fcb_fsize = 0; + lpFcb->fcb_date = dos_getdate(); + lpFcb->fcb_time = dos_gettime(); } - fbcopy((BYTE FAR *) & lpFcb->fcb_fname, (BYTE FAR *) & sftp->sft_name, FNAME_SIZE + FEXT_SIZE); - if ((UCOUNT)FcbDrive >= lastdrive) { - return DE_INVLDDRV; - } - if (CDSp->cds_table[FcbDrive].cdsFlags & CDSNETWDRV) { - COUNT result; - lpCurSft = (sfttbl FAR *)sftp; - result = -int2f_Remote_call(REM_OPEN, 0, 0, 0, (VOID FAR *) sftp, 0, MK_FP(0, O_RDWR)); - sftp->sft_status = result; - } - else { - sftp->sft_status = dos_open(PriPathName, O_RDWR); - sftp->sft_size = dos_getfsize(sftp->sft_status); - dos_getftime(sftp->sft_status, - (date FAR *) & sftp->sft_date, - (time FAR *) & sftp->sft_time); - - } - if (sftp->sft_status >= 0) + else { - lpFcb->fcb_drive = FcbDrive; - lpFcb->fcb_sftno = sft_idx; - lpFcb->fcb_curec = 0; - lpFcb->fcb_recsiz = 128; - lpFcb->fcb_fsize = sftp->sft_size; - lpFcb->fcb_date = sftp->sft_date; - lpFcb->fcb_time = sftp->sft_time; - lpFcb->fcb_rndm = 0; - sftp->sft_count += 1; - sftp->sft_mode = O_RDWR; - sftp->sft_attrib = 0; - sftp->sft_flags = 0; - sftp->sft_psp = cu_psp; - return TRUE; + sftp = idx_to_sft(sft_idx); + lpFcb->fcb_drive = FcbDrive; + lpFcb->fcb_recsiz = 128; + lpFcb->fcb_fsize = sftp->sft_size; + lpFcb->fcb_date = sftp->sft_date; + lpFcb->fcb_time = sftp->sft_time; } - else - return FALSE; + return TRUE; } BOOL FcbDelete(xfcb FAR * lpXfcb) @@ -819,18 +738,14 @@ BOOL FcbDelete(xfcb FAR * lpXfcb) COUNT FcbDrive; /* Build a traditional DOS file name */ - CommonFcbInit(lpXfcb, PriPathName, &FcbDrive); + CommonFcbInit(lpXfcb, SecPathName, &FcbDrive); if ((UCOUNT)FcbDrive >= lastdrive) { return DE_INVLDDRV; } - current_ldt = &CDSp->cds_table[FcbDrive]; - if (CDSp->cds_table[FcbDrive].cdsFlags & CDSNETWDRV) { - return -int2f_Remote_call(REM_DELETE, 0, 0, 0, 0, 0, 0); - } /* check for a device */ - if (IsDevice(PriPathName)) + if (IsDevice(SecPathName)) { return FALSE; } @@ -840,20 +755,21 @@ BOOL FcbDelete(xfcb FAR * lpXfcb) dmatch Dmatch; dta = (BYTE FAR *) & Dmatch; - if (dos_findfirst(D_ALL, PriPathName[1] == ':' ? &PriPathName[2] : PriPathName) != SUCCESS) + if (DosFindFirst(D_ALL, SecPathName[1] == ':' ? &SecPathName[2] : SecPathName) != SUCCESS) { dta = lpOldDta; return FALSE; } do { - if (dos_delete(Dmatch.dm_name) != SUCCESS) + truename(Dmatch.dm_name, SecPathName, FALSE); + if (DosDelete(SecPathName) != SUCCESS) { dta = lpOldDta; return FALSE; } } - while (dos_findnext() == SUCCESS); + while (DosFindNext() == SUCCESS); dta = lpOldDta; return TRUE; } @@ -865,10 +781,10 @@ BOOL FcbRename(xfcb FAR * lpXfcb) COUNT FcbDrive; /* Build a traditional DOS file name */ - lpRenameFcb = (rfcb FAR *) CommonFcbInit(lpXfcb, PriPathName, &FcbDrive); + lpRenameFcb = (rfcb FAR *) CommonFcbInit(lpXfcb, SecPathName, &FcbDrive); /* check for a device */ - if (IsDevice(PriPathName)) + if (IsDevice(SecPathName)) { return FALSE; } @@ -878,7 +794,7 @@ BOOL FcbRename(xfcb FAR * lpXfcb) dmatch Dmatch; dta = (BYTE FAR *) & Dmatch; - if (dos_findfirst(D_ALL, PriPathName[1] == ':' ? &PriPathName[2] : PriPathName) != SUCCESS) + if (DosFindFirst(D_ALL, SecPathName[1] == ':' ? &SecPathName[2] : SecPathName) != SUCCESS) { dta = lpOldDta; return FALSE; @@ -942,74 +858,38 @@ BOOL FcbRename(xfcb FAR * lpXfcb) /* now to build a dos name again */ LocalFcb.fcb_drive = 0; - FcbNameInit((fcb FAR *) & LocalFcb, PriPathName, &FcbDrive); + FcbNameInit((fcb FAR *) & LocalFcb, SecPathName, &FcbDrive); + + truename(Dmatch.dm_name, PriPathName, FALSE); - if (dos_rename(Dmatch.dm_name, - PriPathName[1] == ':' ? &PriPathName[2] : PriPathName) != SUCCESS) + if (DosRenameTrue(PriPathName, SecPathName) != SUCCESS) { dta = lpOldDta; return FALSE; } } - while (dos_findnext() == SUCCESS); + while (DosFindNext() == SUCCESS); dta = lpOldDta; return TRUE; } } -#if 0 /* TE:the MoveDirInfo() is now done by simply copying the dirEntry into the FCB this prevents problems with ".", ".." and saves code + BO:use FcbParseFname: avoid redirector problems and is there anyway */ - -void MoveDirInfo(dmatch FAR * lpDmatch, struct dirent FAR * lpDir) +VOID MoveDirInfo(dmatch * lpDmatch, fcb FAR * lpDir) { - BYTE FAR *lpToName, - FAR * lpszFrom; - COUNT nIndex; - + BYTE FAR *lpszFrom = lpDmatch->dm_name; /* First, expand the find match into dir style */ - /* file name entry */ - /* Fill with blanks first */ - - fmemset(lpDir->dir_name, ' ', FNAME_SIZE); - fmemset(lpDir->dir_ext , ' ', FEXT_SIZE ); - - /* next move in the file name while overwriting */ - /* the filler blanks */ - lpszFrom = lpDmatch->dm_name; - lpToName = (BYTE FAR *)lpDir->dir_name; - for (nIndex = 0; nIndex < FNAME_SIZE; nIndex++) - { - if (*lpszFrom != 0 && *lpszFrom != '.') - *lpToName++ = *lpszFrom++; - else - break; - } - - if (*lpszFrom != '\0') - { - if (*lpszFrom == '.') - ++lpszFrom; - lpToName = (BYTE FAR *)lpDir->dir_ext; - for (nIndex = 0; nIndex < FEXT_SIZE; nIndex++) - { - if (*lpszFrom != '\0') - *lpToName++ = *lpszFrom++; - else - break; - } - } - for (nIndex = 0; nIndex < 10; nIndex++) - lpDir->dir_reserved[nIndex] = 0; - lpDir->dir_attrib = lpDmatch->dm_attr_fnd; - lpDir->dir_time = lpDmatch->dm_time; - lpDir->dir_date = lpDmatch->dm_date; - lpDir->dir_start = lpDmatch->dm_cluster; - lpDir->dir_size = lpDmatch->dm_size; + FcbParseFname(PARSE_DFLT_DRIVE | PARSE_SEP_STOP, &lpszFrom, lpDir); + /* lpDir->dir_attrib = lpDmatch->dm_attr_fnd; XXX for extended fcb! */ + lpDir->fcb_time = lpDmatch->dm_time; + lpDir->fcb_date = lpDmatch->dm_date; + lpDir->fcb_dirclst = lpDmatch->dm_cluster; + lpDir->fcb_fsize = lpDmatch->dm_size; } -#endif BOOL FcbClose(xfcb FAR * lpXfcb) { @@ -1019,52 +899,37 @@ BOOL FcbClose(xfcb FAR * lpXfcb) lpFcb = ExtFcbToFcb(lpXfcb); /* Get the SFT block that contains the SFT */ - if ((s = FcbGetSft(lpFcb->fcb_sftno)) == (sft FAR *) - 1) + if ((s = idx_to_sft(lpFcb->fcb_sftno)) == (sft FAR *) - 1) return FALSE; - /* If this is not opened another error */ - if (s->sft_count == 0) - return FALSE; + /* change time and set file size */ + s->sft_size = lpFcb->fcb_fsize; + if (!(s->sft_flags & SFT_FSHARED)) + dos_setfsize(s->sft_status, lpFcb->fcb_fsize); + DosSetFtimeSft(lpFcb->fcb_sftno, (date FAR *) &lpFcb->fcb_date, (time FAR *) &lpFcb->fcb_time); + return DosCloseSft(lpFcb->fcb_sftno) == SUCCESS; +} - if (s->sft_flags & SFT_FSHARED) - { - int2f_Remote_call(REM_CLOSE, 0, 0, 0, (VOID FAR *) s, 0, 0); - } +/* close all files opened by FCBs + DosCloseSft checks the open count (has to be 1) and current psp + */ +VOID FcbCloseAll() +{ + COUNT idx = 0; - /* now just drop the count if a device, else */ - /* call file system handler */ - if (s->sft_flags & SFT_FDEVICE) - { - s->sft_count -= 1; - return TRUE; - } - else - { - s->sft_count -= 1; - if (s->sft_count > 0) - return SUCCESS; - else - { - /* change time and set file size */ - dos_setftime(s->sft_status, - (date FAR *) & lpFcb->fcb_date, - (time FAR *) & lpFcb->fcb_time); - dos_setfsize(s->sft_status, - lpFcb->fcb_fsize); - return dos_close(s->sft_status) == SUCCESS; - } - } + for (idx = 0; DosCloseSft(idx) != DE_INVLDHNDL; idx++) + ; } BOOL FcbFindFirst(xfcb FAR * lpXfcb) { - BYTE FAR *lpDir; + fcb FAR *lpDir; COUNT FcbDrive; psp FAR *lpPsp = MK_FP(cu_psp, 0); /* First, move the dta to a local and change it around to match */ /* our functions. */ - lpDir = (BYTE FAR *) dta; + lpDir = (fcb FAR *) dta; dta = (BYTE FAR *) & Dmatch; /* Next initialze local variables by moving them from the fcb */ @@ -1072,28 +937,28 @@ BOOL FcbFindFirst(xfcb FAR * lpXfcb) if (lpXfcb->xfcb_flag == 0xff) { wAttr = lpXfcb->xfcb_attrib; - fbcopy(lpXfcb, lpDir, 7); + /* fbcopy(lpXfcb, lpDir, 7); lpDir += 7; + BO:WHY??? + */ } else wAttr = D_ALL; - *lpDir++ = FcbDrive; + /* *lpDir++ = FcbDrive; */ - FcbFindFirstDirPtr = lpDir; + /* FcbFindFirstDirPtr = lpDir; */ - if (dos_findfirst(wAttr, SecPathName) != SUCCESS) + if (DosFindFirst(wAttr, SecPathName) != SUCCESS) { - FcbFindFirstDirPtr = NULL; + /* FcbFindFirstDirPtr = NULL;*/ dta = lpPsp->ps_dta; return FALSE; } - FcbFindFirstDirPtr = NULL; + /* FcbFindFirstDirPtr = NULL; */ -/* - MoveDirInfo((dmatch FAR *) & Dmatch, (struct dirent FAR *)lpDir); -*/ + MoveDirInfo(&Dmatch, lpDir); lpFcb->fcb_dirclst = Dmatch.dm_dirstart; lpFcb->fcb_strtclst = Dmatch.dm_entry; @@ -1115,13 +980,13 @@ BOOL FcbFindFirst(xfcb FAR * lpXfcb) BOOL FcbFindNext(xfcb FAR * lpXfcb) { - BYTE FAR *lpDir; + fcb FAR *lpDir; COUNT FcbDrive; psp FAR *lpPsp = MK_FP(cu_psp, 0); /* First, move the dta to a local and change it around to match */ /* our functions. */ - lpDir = (BYTE FAR *) dta; + lpDir = (fcb FAR *) dta; dta = (BYTE FAR *) & Dmatch; /* Next initialze local variables by moving them from the fcb */ @@ -1129,14 +994,17 @@ BOOL FcbFindNext(xfcb FAR * lpXfcb) if ((xfcb FAR *) lpFcb != lpXfcb) { wAttr = lpXfcb->xfcb_attrib; + /* fbcopy(lpXfcb, lpDir, 7); lpDir += 7; + BO:WHY??? + */ } else wAttr = D_ALL; /* Reconstrct the dirmatch structure from the fcb */ - *lpDir++ = FcbDrive; + /* *lpDir++ = FcbDrive; */ Dmatch.dm_drive = lpFcb->fcb_sftno; fbcopy(lpFcb->fcb_fname, (BYTE FAR *) Dmatch.dm_name_pat, FNAME_SIZE + FEXT_SIZE); @@ -1147,20 +1015,18 @@ BOOL FcbFindNext(xfcb FAR * lpXfcb) Dmatch.dm_cluster = lpFcb->fcb_dirclst; Dmatch.dm_dirstart= lpFcb->fcb_dirclst; - FcbFindFirstDirPtr = lpDir; + /* FcbFindFirstDirPtr = lpDir; */ - if (dos_findnext() != SUCCESS) + if (DosFindNext() != SUCCESS) { - FcbFindFirstDirPtr = NULL; + /* FcbFindFirstDirPtr = NULL; */ dta = lpPsp->ps_dta; CritErrCode = 0x12; return FALSE; } - FcbFindFirstDirPtr = NULL; + /*FcbFindFirstDirPtr = NULL;*/ -/* - MoveDirInfo((dmatch FAR *) & Dmatch, (struct dirent FAR *)lpDir); -*/ + MoveDirInfo(&Dmatch, lpDir); lpFcb->fcb_dirclst = Dmatch.dm_dirstart; lpFcb->fcb_strtclst = Dmatch.dm_entry; diff --git a/kernel/initdisk.c b/kernel/initdisk.c index 20b7f18e..a7c8ac2a 100644 --- a/kernel/initdisk.c +++ b/kernel/initdisk.c @@ -567,9 +567,10 @@ int LBA_Get_Drive_Parameters(int drive,struct DriveParamS *driveParam) driveParam->driveno = drive; DebugPrintf(("drive parameters %02x - %04lu-%u-%u", - drive,driveParam->chs.Cylinder, - drive,driveParam->chs.Head, - drive,driveParam->chs.Sector)); + drive, + driveParam->chs.Cylinder, + driveParam->chs.Head, + driveParam->chs.Sector)); DebugPrintf((" total size %luMB\n\n",driveParam->total_sectors/2048)); diff --git a/kernel/inthndlr.c b/kernel/inthndlr.c index 34180b22..43515502 100644 --- a/kernel/inthndlr.c +++ b/kernel/inthndlr.c @@ -37,6 +37,9 @@ BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.27 2001/07/23 12:47:42 bartoldeman + * FCB fixes and clean-ups, exec int21/ax=4b01, initdisk.c printf + * * Revision 1.26 2001/07/22 01:58:58 bartoldeman * Support for Brian's FORMAT, DJGPP libc compilation, cleanups, MSCDEX * @@ -1174,8 +1177,6 @@ VOID int21_service(iregs FAR * r) || ((psp FAR *) (MK_FP(cu_psp, 0)))->ps_parent == cu_psp) break; tsr = FALSE; - int2f_Remote_call(REM_PROCESS_END, 0, 0, 0, 0, 0, 0); - int2f_Remote_call(REM_CLOSEALL, 0, 0, 0, 0, 0, 0); if (ErrorMode) { ErrorMode = FALSE; diff --git a/kernel/proto.h b/kernel/proto.h index 84bd96e2..0b2ecbb5 100644 --- a/kernel/proto.h +++ b/kernel/proto.h @@ -34,6 +34,9 @@ static BYTE *Proto_hRcsId = "$Id$"; /* * $Log$ + * Revision 1.19 2001/07/23 12:47:42 bartoldeman + * FCB fixes and clean-ups, exec int21/ax=4b01, initdisk.c printf + * * Revision 1.18 2001/07/22 01:58:58 bartoldeman * Support for Brian's FORMAT, DJGPP libc compilation, cleanups, MSCDEX * @@ -219,29 +222,35 @@ COUNT SftSeek(sft FAR *sftp, LONG new_pos, COUNT mode); UCOUNT DosWrite(COUNT hndl, UCOUNT n, BYTE FAR * bp, COUNT FAR * err); COUNT DosSeek(COUNT hndl, LONG new_pos, COUNT mode, ULONG * set_pos); COUNT DosCreat(BYTE FAR * fname, COUNT attrib); +COUNT DosCreatSft(BYTE * fname, COUNT attrib); COUNT CloneHandle(COUNT hndl); COUNT DosDup(COUNT Handle); COUNT DosForceDup(COUNT OldHandle, COUNT NewHandle); COUNT DosOpen(BYTE FAR * fname, COUNT mode); +COUNT DosOpenSft(BYTE * fname, COUNT mode); COUNT DosClose(COUNT hndl); +COUNT DosCloseSft(WORD sft_idx); VOID DosGetFree(UBYTE drive, COUNT FAR * spc, COUNT FAR * navc, COUNT FAR * bps, COUNT FAR * nc); COUNT DosGetCuDir(UBYTE drive, BYTE FAR * s); COUNT DosChangeDir(BYTE FAR * s); COUNT DosFindFirst(UCOUNT attr, BYTE FAR * name); COUNT DosFindNext(void); COUNT DosGetFtime(COUNT hndl, date FAR * dp, time FAR * tp); -COUNT DosSetFtime(COUNT hndl, date FAR * dp, time FAR * tp); +COUNT DosSetFtimeSft(WORD sft_idx, date FAR * dp, time FAR * tp); +#define DosSetFtime(hndl, dp, tp) DosSetFtimeSft(get_sft_idx(hndl), (dp), (tp)) COUNT DosGetFattr(BYTE FAR * name); COUNT DosSetFattr(BYTE FAR * name, UWORD attrp); UBYTE DosSelectDrv(UBYTE drv); COUNT DosDelete(BYTE FAR *path); COUNT DosRename(BYTE FAR * path1, BYTE FAR * path2); +COUNT DosRenameTrue(BYTE * path1, BYTE * path2); COUNT DosMkdir(BYTE FAR * dir); COUNT DosRmdir(BYTE FAR * dir); struct dhdr FAR * IsDevice(BYTE FAR * FileName); BOOL IsShareInstalled(void); COUNT DosLockUnlock(COUNT hndl, LONG pos, LONG len, COUNT unlock); -sft FAR *get_free_sft(WORD FAR * sft_idx); +sft FAR *idx_to_sft(COUNT SftIndex); +COUNT get_sft_idx(UCOUNT hndl); /*dosidle.asm */ VOID DosIdle_int(void); @@ -348,8 +357,9 @@ void FcbNameInit(fcb FAR * lpFcb, BYTE * pszBuffer, COUNT * pCurDrive); BOOL FcbOpen(xfcb FAR * lpXfcb); BOOL FcbDelete(xfcb FAR * lpXfcb); BOOL FcbRename(xfcb FAR * lpXfcb); -void MoveDirInfo(dmatch FAR * lpDmatch, struct dirent FAR * lpDir); +VOID MoveDirInfo(dmatch * lpDmatch, fcb FAR * lpDir); BOOL FcbClose(xfcb FAR * lpXfcb); +VOID FcbCloseAll(VOID); BOOL FcbFindFirst(xfcb FAR * lpXfcb); BOOL FcbFindNext(xfcb FAR * lpXfcb); @@ -476,6 +486,7 @@ COUNT ChildEnv(exec_blk FAR * exp, UWORD * pChildEnvSeg, char far * pathname); VOID new_psp(psp FAR * p, int psize); VOID return_user(void); COUNT DosExec(COUNT mode, exec_blk FAR * ep, BYTE FAR * lp); +LONG DosGetFsize(COUNT hndl); VOID InitPSP(VOID); /* newstuff.c */ diff --git a/kernel/task.c b/kernel/task.c index 1e8ff9b6..eeb377fb 100644 --- a/kernel/task.c +++ b/kernel/task.c @@ -35,6 +35,9 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.16 2001/07/23 12:47:42 bartoldeman + * FCB fixes and clean-ups, exec int21/ax=4b01, initdisk.c printf + * * Revision 1.15 2001/07/22 01:58:58 bartoldeman * Support for Brian's FORMAT, DJGPP libc compilation, cleanups, MSCDEX * @@ -207,10 +210,6 @@ LONG DosGetFsize(COUNT hndl) sft FAR *s; /* sfttbl FAR *sp;*/ - /* Test that the handle is valid */ - if (hndl < 0) - return DE_INVLDHNDL; - /* Get the SFT block that contains the SFT */ if ((s = get_sft(hndl)) == (sft FAR *) - 1) return DE_INVLDHNDL; @@ -389,8 +388,8 @@ VOID new_psp(psp FAR * p, int psize) RootPsp = FP_SEG(p); } -static VOID patchPSP(UWORD pspseg, UWORD envseg, CommandTail FAR * cmdline - ,BYTE FAR * fnam) +static UWORD patchPSP(UWORD pspseg, UWORD envseg, exec_blk FAR *exb, + BYTE FAR * fnam) { psp FAR *psp; mcb FAR *pspmcb; @@ -401,9 +400,11 @@ static VOID patchPSP(UWORD pspseg, UWORD envseg, CommandTail FAR * cmdline ++pspseg; psp = MK_FP(pspseg, 0); - /* complete the psp by adding the command line */ - fbcopy(cmdline->ctBuffer, psp->ps_cmd, 127); - psp->ps_cmd_count = cmdline->ctCount; + /* complete the psp by adding the command line and FCBs */ + fbcopy(exb->exec.cmd_line->ctBuffer, psp->ps_cmd, 127); + fbcopy(exb->exec.fcb_1, &psp->ps_fcb1, 16); + fbcopy(exb->exec.fcb_2, &psp->ps_fcb2, 16); + psp->ps_cmd_count = exb->exec.cmd_line->ctCount; /* identify the mcb as this functions' */ pspmcb->m_psp = pspseg; @@ -438,6 +439,11 @@ static VOID patchPSP(UWORD pspseg, UWORD envseg, CommandTail FAR * cmdline if (i < 8) pspmcb->m_name[i] = '\0'; + /* return value: AX value to be passed based on FCB values */ + return ((psp->ps_fcb1.fcb_drivecds_table[psp->ps_fcb1.fcb_drive].cdsFlags & CDSVALID) ? 0 : 0xff) + + ((psp->ps_fcb2.fcb_drivecds_table[psp->ps_fcb2.fcb_drive].cdsFlags & CDSVALID) ? 0 : 0xff) * 0x100; } COUNT DosComLoader(BYTE FAR * namep, exec_blk FAR * exp, COUNT mode) @@ -559,37 +565,37 @@ COUNT DosComLoader(BYTE FAR * namep, exec_blk FAR * exp, COUNT mode) setvec(0x22, (VOID(INRPT FAR *) (VOID)) MK_FP(user_r->CS, user_r->IP)); new_psp(p, mem + asize); - patchPSP(mem - 1, env, exp->exec.cmd_line, namep); - - /* build the user area on the stack */ - *((UWORD FAR *) MK_FP(mem, 0xfffe)) = (UWORD) 0; - irp = MK_FP(mem, (0xfffe - sizeof(iregs))); - - /* start allocating REGs */ - irp->ES = irp->DS = mem; - irp->CS = mem; - irp->IP = 0x100; - irp->AX = 0xffff; /* for now, until fcb code is in */ - irp->BX = - irp->CX = - irp->DX = - irp->SI = - irp->DI = - irp->BP = 0; - irp->FLAGS = 0x200; + asize = patchPSP(mem - 1, env, exp, namep); /* asize=fcbcode for ax */ /* Transfer control to the executable */ p->ps_parent = cu_psp; p->ps_prevpsp = (BYTE FAR *) MK_FP(cu_psp, 0); q->ps_stack = (BYTE FAR *) user_r; user_r->FLAGS &= ~FLG_CARRY; + cu_psp = mem; + dta = p->ps_dta; switch (mode) { case LOADNGO: { - cu_psp = mem; - dta = p->ps_dta; + *((UWORD FAR *) MK_FP(mem, 0xfffe)) = (UWORD) 0; + + /* build the user area on the stack */ + irp = MK_FP(mem, (0xfffe - sizeof(iregs))); + + /* start allocating REGs */ + irp->ES = irp->DS = mem; + irp->CS = mem; + irp->IP = 0x100; + irp->AX = asize; /* fcbcode */ + irp->BX = + irp->CX = + irp->DX = + irp->SI = + irp->DI = + irp->BP = 0; + irp->FLAGS = 0x200; if (InDOS) --InDOS; @@ -600,9 +606,9 @@ COUNT DosComLoader(BYTE FAR * namep, exec_blk FAR * exp, COUNT mode) break; } case LOAD: - cu_psp = mem; - exp->exec.stack = (BYTE FAR *) irp; - exp->exec.start_addr = MK_FP(irp->CS, irp->IP); + exp->exec.stack = MK_FP(mem, 0xfffe); + *((UWORD FAR *)exp->exec.stack) = asize; + exp->exec.start_addr = MK_FP(mem, 0x100); return SUCCESS; } @@ -626,12 +632,15 @@ VOID return_user(void) setvec(0x24, p->ps_isv24); /* And free all process memory if not a TSR return */ + int2f_Remote_call(REM_PROCESS_END, 0, 0, 0, 0, 0, 0); if (!tsr) { + int2f_Remote_call(REM_CLOSEALL, 0, 0, 0, 0, 0, 0); for (i = 0; i < p->ps_maxfiles; i++) { DosClose(i); } + FcbCloseAll(); FreeProcessMem(cu_psp); } @@ -917,25 +926,7 @@ COUNT DosExeLoader(BYTE FAR * namep, exec_blk FAR * exp, COUNT mode) setvec(0x22, (VOID(INRPT FAR *) (VOID)) MK_FP(user_r->CS, user_r->IP)); new_psp(p, mem + asize); - patchPSP(mem - 1, env, exp->exec.cmd_line, namep); - - /* build the user area on the stack */ - irp = MK_FP(header.exInitSS + start_seg, - ((header.exInitSP - sizeof(iregs)) & 0xffff)); - - /* start allocating REGs */ - /* Note: must match es & ds memory segment */ - irp->ES = irp->DS = mem; - irp->CS = header.exInitCS + start_seg; - irp->IP = header.exInitIP; - irp->AX = 0xffff; /* for now, until fcb code is in */ - irp->BX = - irp->CX = - irp->DX = - irp->SI = - irp->DI = - irp->BP = 0; - irp->FLAGS = 0x200; + asize = patchPSP(mem - 1, env, exp, namep); /* asize = fcbcode */ /* Transfer control to the executable */ p->ps_parent = cu_psp; @@ -946,6 +937,24 @@ COUNT DosExeLoader(BYTE FAR * namep, exec_blk FAR * exp, COUNT mode) switch (mode) { case LOADNGO: + /* build the user area on the stack */ + irp = MK_FP(header.exInitSS + start_seg, + ((header.exInitSP - sizeof(iregs)) & 0xffff)); + + /* start allocating REGs */ + /* Note: must match es & ds memory segment */ + irp->ES = irp->DS = mem; + irp->CS = header.exInitCS + start_seg; + irp->IP = header.exInitIP; + irp->AX = asize; /* asize = fcbcode */ + irp->BX = + irp->CX = + irp->DX = + irp->SI = + irp->DI = + irp->BP = 0; + irp->FLAGS = 0x200; + cu_psp = mem; dta = p->ps_dta; @@ -958,8 +967,9 @@ COUNT DosExeLoader(BYTE FAR * namep, exec_blk FAR * exp, COUNT mode) case LOAD: cu_psp = mem; - exp->exec.stack = (BYTE FAR *) irp; - exp->exec.start_addr = MK_FP(irp->CS, irp->IP); + exp->exec.stack = MK_FP(header.exInitSS + start_seg, header.exInitSP); + *((UWORD FAR *) exp->exec.stack) = asize; /* fcbcode */ + exp->exec.start_addr = MK_FP(header.exInitCS + start_seg, header.exInitIP); return SUCCESS; } return DE_INVLDFMT; From d4a9888f7b74e6d1f5878a362527fc5243ded21d Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Tue, 24 Jul 2001 16:56:29 +0000 Subject: [PATCH 085/671] fixes for FCBs, DJGPP ls, DBLBYTE, dyninit allocation (2024e). git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@269 6ac86273-5f31-0410-b378-82cca8765d1b --- docs/history.txt | 20 ++++++++++- hdr/buffer.h | 7 ++++ hdr/version.h | 2 +- kernel/dosfns.c | 85 +++++++++++++++++++++++++++++++++++++---------- kernel/dosnames.c | 5 +++ kernel/dyninit.c | 2 +- kernel/fatdir.c | 85 +++++++++++++++-------------------------------- kernel/fatfs.c | 5 ++- kernel/fcbfns.c | 76 ++++++++++++++---------------------------- kernel/inthndlr.c | 9 +++-- kernel/kernel.mak | 8 +++-- kernel/network.c | 38 ++------------------- kernel/proto.h | 4 ++- readme.txt | 2 +- 14 files changed, 176 insertions(+), 172 deletions(-) diff --git a/docs/history.txt b/docs/history.txt index 1d46ca0c..518deb44 100644 --- a/docs/history.txt +++ b/docs/history.txt @@ -1,8 +1,26 @@ +2001 Jul 9 - Build 2024/e +-------- Bart Oldeman (bart.oldeman@bristol.ac.uk) ++ fixes Tom + * dyninit allocation fix + * various clean ups ++ fixes Bart + * #define DBLBYTE in inhndlr.c. Necessary for PQDI + * FCB corrections and cleanups (with a little help from Tom) + * cleaned up (FCB)FindFirst/FindNext a little more. + * task.c: copies default FCBs, initializes AX properly and + an int21/ax=4b01 fix. Also closes all FCB opened files upon + termination of a program. + * dosnames.c: fixed DJGPP "ls c:/" problem reported by Martin ++ fixes Victor Vlasenko + * Makefile fix for dealing with Borland make 3.6 + * fix for fatfs.c shrink_file() + fixes Bart + * handle B: just like A: on a single floppy system. There still needs to be + user interaction like "Please put a floppy in drive B:". * ioctl.c fix for INT21/AX=4400 + sft driveno field * various small fcb fixes * put file position number and pointers to Pri/SecPathName into - SDA. Now MSCDEX works as redirector + SDA. Now MSCDEX works as redirector (but still not always :-() * redirector set attribute fixes + various cleanups * truename+attr+ioctl fix => DJGPP libc compiles cleanly! + changes Bart diff --git a/hdr/buffer.h b/hdr/buffer.h index c8762231..8662fe82 100644 --- a/hdr/buffer.h +++ b/hdr/buffer.h @@ -5,6 +5,10 @@ /* Sector buffer structure */ /* */ /* Copyright (c) 2001 */ +/* Bart Oldeman */ +/* */ +/* Largely taken from globals.h: */ +/* Copyright (c) 1995, 1996 */ /* Pasquale J. Villani */ /* All Rights Reserved */ /* */ @@ -34,6 +38,9 @@ static BYTE *buffer_hRcsId = "$Id$"; /* * $Log$ + * Revision 1.3 2001/07/24 16:56:29 bartoldeman + * fixes for FCBs, DJGPP ls, DBLBYTE, dyninit allocation (2024e). + * * Revision 1.2 2001/06/03 14:16:17 bartoldeman * BUFFERS tuning and misc bug fixes/cleanups (2024c). * diff --git a/hdr/version.h b/hdr/version.h index 31cfec1c..656bd78c 100644 --- a/hdr/version.h +++ b/hdr/version.h @@ -44,4 +44,4 @@ static BYTE *date_hRcsId = "$Id$"; #define REVISION_MINOR 1 #define REVISION_SEQ 24 #define BUILD 2024 -#define SUB_BUILD "d" +#define SUB_BUILD "e" diff --git a/kernel/dosfns.c b/kernel/dosfns.c index 4e522e4b..453c8439 100644 --- a/kernel/dosfns.c +++ b/kernel/dosfns.c @@ -37,6 +37,9 @@ static BYTE *dosfnsRcsId = "$Id$"; * /// Added SHARE support. 2000/09/04 Ron Cemer * * $Log$ + * Revision 1.22 2001/07/24 16:56:29 bartoldeman + * fixes for FCBs, DJGPP ls, DBLBYTE, dyninit allocation (2024e). + * * Revision 1.21 2001/07/23 12:47:42 bartoldeman * FCB fixes and clean-ups, exec int21/ax=4b01, initdisk.c printf * @@ -1250,10 +1253,20 @@ COUNT DosChangeDir(BYTE FAR * s) return result; } +STATIC VOID pop_dmp(dmatch FAR * dmp) +{ + dmp->dm_attr_fnd = (BYTE) SearchDir.dir_attrib; + dmp->dm_time = SearchDir.dir_time; + dmp->dm_date = SearchDir.dir_date; + dmp->dm_size = (LONG) SearchDir.dir_size; + ConvertName83ToNameSZ(dmp->dm_name, (BYTE FAR *)SearchDir.dir_name); +} + COUNT DosFindFirst(UCOUNT attr, BYTE FAR * name) { COUNT nDrive, rc; REG dmatch FAR *dmp = (dmatch FAR *) dta; + BYTE FAR *p; /* /// Added code here to do matching against device names. DOS findfirst will match exact device names if the @@ -1262,15 +1275,30 @@ COUNT DosFindFirst(UCOUNT attr, BYTE FAR * name) Credits: some of this code was ripped off from truename() in newstuff.c. - Ron Cemer */ - fmemset(dmp, 0, sizeof(dmatch)); - if (IsDevice(name)) + fmemset(dta, 0, sizeof(dmatch)); + memset(&SearchDir, 0, sizeof(struct dirent)); + + rc = truename(name, PriPathName, FALSE); + if (rc != SUCCESS) + return rc; + + if (IsDevice(PriPathName)) { + COUNT i; + /* Found a matching device. Hence there cannot be wildcards. */ - dmp->dm_attr_fnd = D_DEVICE; - dmp->dm_time = dos_gettime(); - dmp->dm_date = dos_getdate(); - fstrncpy(dmp->dm_name, get_root(name), FNAME_SIZE+FEXT_SIZE+1); + SearchDir.dir_attrib = D_DEVICE; + SearchDir.dir_time = dos_gettime(); + SearchDir.dir_date = dos_getdate(); + p = get_root(PriPathName); + memset(SearchDir.dir_name, ' ', FNAME_SIZE+FEXT_SIZE); + for (i = 0; i < FNAME_SIZE && *p && *p != '.'; i++) + SearchDir.dir_name[i] = *p++; + if (*p == '.') p++; + for (i = 0; i < FEXT_SIZE && *p && *p != '.'; i++) + SearchDir.dir_ext[i] = *p++; + pop_dmp(dmp); return SUCCESS; } /* /// End of additions. - Ron Cemer ; heavily edited - Bart Oldeman */ @@ -1282,23 +1310,32 @@ COUNT DosFindFirst(UCOUNT attr, BYTE FAR * name) current_ldt = &CDSp->cds_table[nDrive]; - rc = truename(name, PriPathName, FALSE); +#if defined(FIND_DEBUG) + printf("Remote Find: n='%Fs\n", PriPathName); +#endif + + fmemcpy(TempBuffer, dta, 21); + p = dta; + dta = (BYTE FAR *)TempBuffer; + + rc = current_ldt->cdsFlags & CDSNETWDRV ? + -int2f_Remote_call(REM_FINDFIRST, 0, 0, 0, (VOID FAR *)current_ldt, 0, 0) : + dos_findfirst(attr, PriPathName); + + dta = p; + if (rc != SUCCESS) return rc; - if (current_ldt->cdsFlags & CDSNETWDRV) - { - return -Remote_find(REM_FINDFIRST); - } - else - { - dmp->dm_drive = nDrive; - return dos_findfirst(attr, PriPathName); - } + fmemcpy(dta, TempBuffer, 21); + pop_dmp((dmatch FAR *)dta); + return SUCCESS; } COUNT DosFindNext(void) { + COUNT rc; + BYTE FAR *p; /* /// findnext will always fail on a device name. - Ron Cemer */ if (((dmatch FAR *)dta)->dm_attr_fnd == D_DEVICE) @@ -1325,9 +1362,21 @@ COUNT DosFindNext(void) printf("findnext: %d\n", ((dmatch FAR *)dta)->dm_drive); #endif - return (((dmatch FAR *)dta)->dm_drive & 0x80) ? - -Remote_find(REM_FINDNEXT) : + fmemcpy(TempBuffer, dta, 21); + fmemset(dta, 0, sizeof(dmatch)); + p = dta; + dta = (BYTE FAR *)TempBuffer; + rc = (((dmatch *)TempBuffer)->dm_drive & 0x80) ? + -int2f_Remote_call(REM_FINDNEXT, 0, 0, 0, (VOID FAR *)current_ldt, 0, 0) : dos_findnext(); + + dta = p; + if (rc != SUCCESS) + return rc; + + fmemcpy(dta, TempBuffer, 21); + pop_dmp((dmatch FAR *)dta); + return SUCCESS; } COUNT DosGetFtime(COUNT hndl, date FAR * dp, time FAR * tp) diff --git a/kernel/dosnames.c b/kernel/dosnames.c index c7f172b4..b5132047 100644 --- a/kernel/dosnames.c +++ b/kernel/dosnames.c @@ -36,6 +36,9 @@ static BYTE *dosnamesRcsId = "$Id$"; /* * $Log$ + * Revision 1.11 2001/07/24 16:56:29 bartoldeman + * fixes for FCBs, DJGPP ls, DBLBYTE, dyninit allocation (2024e). + * * Revision 1.10 2001/07/22 01:58:58 bartoldeman * Support for Brian's FORMAT, DJGPP libc compilation, cleanups, MSCDEX * @@ -234,6 +237,8 @@ COUNT ParseDosName(BYTE * lpszFileName, lpszFileName++; if (*lpszFileName != '\0') return DE_FILENOTFND; + if (nDirCnt == 1) /* for d:\ */ + return DE_NFILES; if (pszDir) { if ((lpszFileName - lpszLclFile) == 2) /* for tail DotDot */ diff --git a/kernel/dyninit.c b/kernel/dyninit.c index fd2c1272..9ff45a11 100644 --- a/kernel/dyninit.c +++ b/kernel/dyninit.c @@ -78,7 +78,7 @@ void DynFree(unsigned memory_needed) if (memory_needed == 0) /* this is pass 0 */ { - Dyn.Allocated = 1000; /* this reserves space for initDisk */ + Dyn.Allocated = NDEV*sizeof(ddt); /* this reserves space for initDisk */ Dyn.AllocMax = sizeof(Dyn.Buffer); } else { diff --git a/kernel/fatdir.c b/kernel/fatdir.c index 5c132618..c26279d3 100644 --- a/kernel/fatdir.c +++ b/kernel/fatdir.c @@ -36,6 +36,9 @@ static BYTE *fatdirRcsId = "$Id$"; /* * $Log$ + * Revision 1.20 2001/07/24 16:56:29 bartoldeman + * fixes for FCBs, DJGPP ls, DBLBYTE, dyninit allocation (2024e). + * * Revision 1.19 2001/07/23 12:47:42 bartoldeman * FCB fixes and clean-ups, exec int21/ax=4b01, initdisk.c printf * @@ -181,8 +184,6 @@ static BYTE *fatdirRcsId = "$Id$"; * Initial revision. */ -VOID pop_dmp(dmatch FAR *, f_node_ptr); - f_node_ptr dir_open(BYTE * dirname) { f_node_ptr fnp; @@ -591,8 +592,9 @@ VOID dir_close(REG f_node_ptr fnp) COUNT dos_findfirst(UCOUNT attr, BYTE *name) { REG f_node_ptr fnp; - REG dmatch FAR *dmp = (dmatch FAR *) dta; + REG dmatch *dmp = (dmatch *) TempBuffer; REG COUNT i; + COUNT nDrive; BYTE *p; BYTE local_name[FNAME_SIZE + 1], @@ -607,12 +609,8 @@ COUNT dos_findfirst(UCOUNT attr, BYTE *name) /* dirmatch structure and then for every find, we will open the */ /* current directory, do a seek and read, then close the fnode. */ - /* Start out by initializing the dirmatch structure. */ - - dmp->dm_attr_srch = attr; - /* Parse out the drive, file name and file extension. */ - i = ParseDosName(name, NULL, &szDirName[2], local_name, local_ext, TRUE); + i = ParseDosName(name, &nDrive, &szDirName[2], local_name, local_ext, TRUE); if (i != SUCCESS) return i; /* @@ -643,15 +641,11 @@ COUNT dos_findfirst(UCOUNT attr, BYTE *name) /* Convert everything to uppercase. */ DosUpFMem(SearchDir.dir_name, FNAME_SIZE + FEXT_SIZE); - /* Copy the raw pattern from our data segment to the DTA. */ - fbcopy((BYTE FAR *) SearchDir.dir_name, dmp->dm_name_pat, - FNAME_SIZE + FEXT_SIZE); - /* Now search through the directory to find the entry... */ /* Complete building the directory from the passed in */ /* name */ - szDirName[0] = 'A' + dmp->dm_drive; + szDirName[0] = 'A' + nDrive; szDirName[1] = ':'; /* Special handling - the volume id is only in the root */ @@ -670,6 +664,18 @@ COUNT dos_findfirst(UCOUNT attr, BYTE *name) if ((fnp = dir_open(szDirName)) == NULL) return DE_PATHNOTFND; + /* Now initialize the dirmatch structure. */ + + nDrive=get_verify_drive(name); + if (nDrive < 0) + return nDrive; + dmp->dm_drive = nDrive; + dmp->dm_attr_srch = attr; + + /* Copy the raw pattern from our data segment to the DTA. */ + fbcopy((BYTE FAR *) SearchDir.dir_name, dmp->dm_name_pat, + FNAME_SIZE + FEXT_SIZE); + if ((attr & ~(D_RDONLY | D_ARCHIVE)) == D_VOLID) { /* Now do the search */ @@ -678,7 +684,9 @@ COUNT dos_findfirst(UCOUNT attr, BYTE *name) /* Test the attribute and return first found */ if ((fnp->f_dir.dir_attrib & ~(D_RDONLY | D_ARCHIVE)) == D_VOLID) { - pop_dmp(dmp, fnp); + dmp->dm_dirstart= fnp->f_dirstart; + dmp->dm_cluster = fnp->f_dir.dir_start; /* TE */ + memcpy(&SearchDir, &fnp->f_dir, sizeof(struct dirent)); dir_close(fnp); return SUCCESS; } @@ -692,7 +700,6 @@ COUNT dos_findfirst(UCOUNT attr, BYTE *name) /* Otherwise just do a normal find next */ else { - pop_dmp(dmp, fnp); dmp->dm_entry = 0; if (!fnp->f_flags.f_droot) { @@ -719,7 +726,7 @@ COUNT dos_findfirst(UCOUNT attr, BYTE *name) COUNT dos_findnext(void) { - REG dmatch FAR *dmp = (dmatch FAR *) dta; + REG dmatch *dmp = (dmatch *) TempBuffer; REG f_node_ptr fnp; BOOL found = FALSE; @@ -803,21 +810,9 @@ COUNT dos_findnext(void) /* If found, transfer it to the dmatch structure */ if (found) { -#if 0 - extern VOID FAR *FcbFindFirstDirPtr; - if (FcbFindFirstDirPtr) - { - /* this works MUCH better, then converting - 83 -> ASCIIZ ->83; - specifically ".", ".." - - But completely bypasses the network case! - */ - fmemcpy(FcbFindFirstDirPtr, &fnp->f_dir, 32); - } -#endif - - pop_dmp(dmp, fnp); + dmp->dm_dirstart= fnp->f_dirstart; + dmp->dm_cluster = fnp->f_dir.dir_start; /* TE */ + memcpy(&SearchDir, &fnp->f_dir, sizeof(struct dirent)); } /* return the result */ @@ -825,25 +820,6 @@ COUNT dos_findnext(void) return found ? SUCCESS : DE_NFILES; } - -STATIC VOID pop_dmp(dmatch FAR * dmp, f_node_ptr fnp) -{ - - dmp->dm_attr_fnd = fnp->f_dir.dir_attrib; - dmp->dm_time = fnp->f_dir.dir_time; - dmp->dm_date = fnp->f_dir.dir_date; - dmp->dm_size = fnp->f_dir.dir_size; - dmp->dm_cluster = fnp->f_dir.dir_start; /* TE */ - dmp->dm_dirstart= fnp->f_dirstart; -/* - dmp->dm_flags.f_droot = fnp->f_flags.f_droot; - dmp->dm_flags.f_ddir = fnp->f_flags.f_ddir; - dmp->dm_flags.f_dmod = fnp->f_flags.f_dmod; - dmp->dm_flags.f_dnew = fnp->f_flags.f_dnew; -*/ - ConvertName83ToNameSZ((BYTE FAR *)dmp->dm_name, (BYTE FAR *) fnp->f_dir.dir_name); - -} #endif /* this receives a name in 11 char field NAME+EXT and builds @@ -909,11 +885,4 @@ int FileName83Length(BYTE *filename83) return strlen(buff); -} - - - - - - - +} diff --git a/kernel/fatfs.c b/kernel/fatfs.c index db7d73d2..96c73220 100644 --- a/kernel/fatfs.c +++ b/kernel/fatfs.c @@ -47,6 +47,9 @@ BYTE *RcsId = "$Id$"; * performance killer on large drives. (~0.5 sec /dos_mkdir) TE * * $Log$ + * Revision 1.21 2001/07/24 16:56:29 bartoldeman + * fixes for FCBs, DJGPP ls, DBLBYTE, dyninit allocation (2024e). + * * Revision 1.20 2001/07/22 01:58:58 bartoldeman * Support for Brian's FORMAT, DJGPP libc compilation, cleanups, MSCDEX * @@ -2445,7 +2448,7 @@ STATIC VOID shrink_file(f_node_ptr fnp) st = fnp->f_cluster; - if (st == FREE) /* first cluster is free, done */ + if (st == FREE || st == LONG_LAST_CLUSTER) /* first cluster is free or EOC, done */ goto done; next = next_cluster(dpbp, st); diff --git a/kernel/fcbfns.c b/kernel/fcbfns.c index b5101880..6c9f5f92 100644 --- a/kernel/fcbfns.c +++ b/kernel/fcbfns.c @@ -35,6 +35,9 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.15 2001/07/24 16:56:29 bartoldeman + * fixes for FCBs, DJGPP ls, DBLBYTE, dyninit allocation (2024e). + * * Revision 1.14 2001/07/23 12:47:42 bartoldeman * FCB fixes and clean-ups, exec int21/ax=4b01, initdisk.c printf * @@ -149,14 +152,12 @@ fcb FAR *CommonFcbInit(xfcb FAR * lpExtFcb, BYTE * pszBuffer, COUNT * pCurDrive) void FcbNameInit(fcb FAR * lpFcb, BYTE * pszBuffer, COUNT * pCurDrive); VOID FcbNextRecord(fcb FAR * lpFcb); BOOL FcbCalcRec(xfcb FAR * lpXfcb); -VOID MoveDirInfo(dmatch * lpDmatch, fcb FAR * lpDir); #else fcb FAR *ExtFcbToFcb(); fcb FAR *CommonFcbInit(); void FcbNameInit(); VOID FcbNextRecord(); BOOL FcbCalcRec(); -VOID MoveDirInfo(); #endif #define TestCmnSeps(lpFileName) (strchr(":<|>+=,", *lpFileName) != NULL) @@ -165,9 +166,6 @@ VOID MoveDirInfo(); static dmatch Dmatch; -/* VOID FAR *FcbFindFirstDirPtr = NULL; */ - - VOID FatGetDrvData(UCOUNT drive, COUNT FAR * spc, COUNT FAR * bps, COUNT FAR * nc, BYTE FAR ** mdp) { @@ -676,7 +674,7 @@ STATIC fcb FAR *CommonFcbInit(xfcb FAR * lpExtFcb, BYTE * pszBuffer, void FcbNameInit(fcb FAR * lpFcb, BYTE * szBuffer, COUNT * pCurDrive) { - BYTE loc_szBuffer[FNAME_SIZE+1+FEXT_SIZE+1]; + BYTE loc_szBuffer[2+FNAME_SIZE+1+FEXT_SIZE+1]; /* 'A:' + '.' + '\0' */ BYTE *pszBuffer = loc_szBuffer; /* Build a traditional DOS file name */ @@ -691,7 +689,7 @@ void FcbNameInit(fcb FAR * lpFcb, BYTE * szBuffer, COUNT * pCurDrive) { *pCurDrive = default_drive + 1; } - ConvertName83ToNameSZ((BYTE FAR *)pszBuffer, (BYTE FAR *) lpFcb->fcb_fname); + ConvertName83ToNameSZ(pszBuffer, (BYTE FAR *) lpFcb->fcb_fname); truename(loc_szBuffer, szBuffer, FALSE); /* XXX fix truename error handling */ } @@ -876,21 +874,9 @@ BOOL FcbRename(xfcb FAR * lpXfcb) /* TE:the MoveDirInfo() is now done by simply copying the dirEntry into the FCB this prevents problems with ".", ".." and saves code - BO:use FcbParseFname: avoid redirector problems and is there anyway + BO:use global SearchDir, as produced by FindFirst/Next */ -VOID MoveDirInfo(dmatch * lpDmatch, fcb FAR * lpDir) -{ - BYTE FAR *lpszFrom = lpDmatch->dm_name; - /* First, expand the find match into dir style */ - FcbParseFname(PARSE_DFLT_DRIVE | PARSE_SEP_STOP, &lpszFrom, lpDir); - /* lpDir->dir_attrib = lpDmatch->dm_attr_fnd; XXX for extended fcb! */ - lpDir->fcb_time = lpDmatch->dm_time; - lpDir->fcb_date = lpDmatch->dm_date; - lpDir->fcb_dirclst = lpDmatch->dm_cluster; - lpDir->fcb_fsize = lpDmatch->dm_size; -} - BOOL FcbClose(xfcb FAR * lpXfcb) { sft FAR *s; @@ -923,13 +909,13 @@ VOID FcbCloseAll() BOOL FcbFindFirst(xfcb FAR * lpXfcb) { - fcb FAR *lpDir; + BYTE FAR *lpDir; COUNT FcbDrive; psp FAR *lpPsp = MK_FP(cu_psp, 0); /* First, move the dta to a local and change it around to match */ /* our functions. */ - lpDir = (fcb FAR *) dta; + lpDir = (BYTE FAR *) dta; dta = (BYTE FAR *) & Dmatch; /* Next initialze local variables by moving them from the fcb */ @@ -937,28 +923,21 @@ BOOL FcbFindFirst(xfcb FAR * lpXfcb) if (lpXfcb->xfcb_flag == 0xff) { wAttr = lpXfcb->xfcb_attrib; - /* fbcopy(lpXfcb, lpDir, 7); - lpDir += 7; - BO:WHY??? - */ + fbcopy(lpXfcb, lpDir, 7); + lpDir += 7; } else wAttr = D_ALL; - /* *lpDir++ = FcbDrive; */ - - /* FcbFindFirstDirPtr = lpDir; */ - if (DosFindFirst(wAttr, SecPathName) != SUCCESS) { - /* FcbFindFirstDirPtr = NULL;*/ dta = lpPsp->ps_dta; return FALSE; } - /* FcbFindFirstDirPtr = NULL; */ + *lpDir++ = FcbDrive; + fmemcpy(lpDir, &SearchDir, sizeof(struct dirent)); - MoveDirInfo(&Dmatch, lpDir); lpFcb->fcb_dirclst = Dmatch.dm_dirstart; lpFcb->fcb_strtclst = Dmatch.dm_entry; @@ -980,31 +959,19 @@ BOOL FcbFindFirst(xfcb FAR * lpXfcb) BOOL FcbFindNext(xfcb FAR * lpXfcb) { - fcb FAR *lpDir; + BYTE FAR *lpDir; COUNT FcbDrive; psp FAR *lpPsp = MK_FP(cu_psp, 0); /* First, move the dta to a local and change it around to match */ /* our functions. */ - lpDir = (fcb FAR *) dta; + lpDir = (BYTE FAR *) dta; dta = (BYTE FAR *) & Dmatch; /* Next initialze local variables by moving them from the fcb */ lpFcb = CommonFcbInit(lpXfcb, SecPathName, &FcbDrive); - if ((xfcb FAR *) lpFcb != lpXfcb) - { - wAttr = lpXfcb->xfcb_attrib; - /* - fbcopy(lpXfcb, lpDir, 7); - lpDir += 7; - BO:WHY??? - */ - } - else - wAttr = D_ALL; /* Reconstrct the dirmatch structure from the fcb */ - /* *lpDir++ = FcbDrive; */ Dmatch.dm_drive = lpFcb->fcb_sftno; fbcopy(lpFcb->fcb_fname, (BYTE FAR *) Dmatch.dm_name_pat, FNAME_SIZE + FEXT_SIZE); @@ -1015,18 +982,25 @@ BOOL FcbFindNext(xfcb FAR * lpXfcb) Dmatch.dm_cluster = lpFcb->fcb_dirclst; Dmatch.dm_dirstart= lpFcb->fcb_dirclst; - /* FcbFindFirstDirPtr = lpDir; */ + if ((xfcb FAR *) lpFcb != lpXfcb) + { + wAttr = lpXfcb->xfcb_attrib; + fbcopy(lpXfcb, lpDir, 7); + lpDir += 7; + } + else + wAttr = D_ALL; if (DosFindNext() != SUCCESS) { - /* FcbFindFirstDirPtr = NULL; */ dta = lpPsp->ps_dta; CritErrCode = 0x12; return FALSE; } - /*FcbFindFirstDirPtr = NULL;*/ - MoveDirInfo(&Dmatch, lpDir); + *lpDir++ = FcbDrive; + fmemcpy((struct dirent FAR *)lpDir, &SearchDir, sizeof(struct dirent)); + lpFcb->fcb_dirclst = Dmatch.dm_dirstart; lpFcb->fcb_strtclst = Dmatch.dm_entry; diff --git a/kernel/inthndlr.c b/kernel/inthndlr.c index 43515502..495692b0 100644 --- a/kernel/inthndlr.c +++ b/kernel/inthndlr.c @@ -37,6 +37,9 @@ BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.28 2001/07/24 16:56:29 bartoldeman + * fixes for FCBs, DJGPP ls, DBLBYTE, dyninit allocation (2024e). + * * Revision 1.27 2001/07/23 12:47:42 bartoldeman * FCB fixes and clean-ups, exec int21/ax=4b01, initdisk.c printf * @@ -369,7 +372,7 @@ VOID int21_service(iregs FAR * r) p->ps_stack = (BYTE FAR *) r; -#ifdef DEBUG +#ifdef DEBUG if (bDumpRegs) { fbcopy((VOID FAR *) user_r, (VOID FAR *) & error_regs, sizeof(iregs)); @@ -1534,6 +1537,7 @@ VOID int21_service(iregs FAR * r) /* UNDOCUMENTED: Double byte and korean tables */ case 0x63: { +#define DBLBYTE #ifdef DBLBYTE static char dbcsTable[2] = { @@ -1546,7 +1550,8 @@ VOID int21_service(iregs FAR * r) r->AL = 0; #else /* not really supported, but will pass. */ - r->AL = 0x00; /*jpp: according to interrupt list */ + r->AL = 0x00; /*jpp: according to interrupt list */ + /*Bart: fails for PQDI: use the above again */ #endif break; } diff --git a/kernel/kernel.mak b/kernel/kernel.mak index 942f5527..b4771351 100644 --- a/kernel/kernel.mak +++ b/kernel/kernel.mak @@ -5,6 +5,9 @@ # # $Log$ +# Revision 1.13 2001/07/24 16:56:29 bartoldeman +# fixes for FCBs, DJGPP ls, DBLBYTE, dyninit allocation (2024e). +# # Revision 1.12 2001/07/22 01:58:58 bartoldeman # Support for Brian's FORMAT, DJGPP libc compilation, cleanups, MSCDEX # @@ -169,8 +172,9 @@ HDR=../hdr/ .c.obj: $(CC) $(CFLAGS) -c $< -.c.asm: - $(CC) $(CFLAGS) -S $< +# Borland make 3.6 does not like this rule. +#.c.asm: +# $(CC) $(CFLAGS) -S $< .cpp.obj: $(CC) $(CFLAGS) -c $< diff --git a/kernel/network.c b/kernel/network.c index b0d52da0..e941e7f8 100644 --- a/kernel/network.c +++ b/kernel/network.c @@ -36,6 +36,9 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.14 2001/07/24 16:56:29 bartoldeman + * fixes for FCBs, DJGPP ls, DBLBYTE, dyninit allocation (2024e). + * * Revision 1.13 2001/07/22 01:58:58 bartoldeman * Support for Brian's FORMAT, DJGPP libc compilation, cleanups, MSCDEX * @@ -128,40 +131,5 @@ UCOUNT Remote_RW(UWORD func, UCOUNT n, BYTE FAR * bp, sft FAR * s, COUNT FAR * e return ((UCOUNT) rc); } -#undef FIND_DEBUG -/* - - */ -COUNT Remote_find(UWORD func) -{ - COUNT i; - char FAR *p; - -#if defined(FIND_DEBUG) - if (func == REM_FINDFIRST) - { - printf("Remote Find: n='%Fs\n", PriPathName); - } -#endif - - fmemcpy(TempBuffer, dta, 21); - p = dta; - dta = (BYTE FAR *)TempBuffer; - i = int2f_Remote_call(func, 0, 0, 0, (VOID FAR *)current_ldt, 0, 0); - dta = p; - fmemcpy(dta, TempBuffer, 21); - - if (i != 0) - return i; - - ((dmatch FAR *)dta)->dm_attr_fnd = (BYTE) SearchDir.dir_attrib; - ((dmatch FAR *)dta)->dm_time = SearchDir.dir_time; - ((dmatch FAR *)dta)->dm_date = SearchDir.dir_date; - ((dmatch FAR *)dta)->dm_size = (LONG) SearchDir.dir_size; - - ConvertName83ToNameSZ(((dmatch FAR *)dta)->dm_name, (BYTE *)SearchDir.dir_name); - return i; -} - diff --git a/kernel/proto.h b/kernel/proto.h index 0b2ecbb5..1e3f9152 100644 --- a/kernel/proto.h +++ b/kernel/proto.h @@ -34,6 +34,9 @@ static BYTE *Proto_hRcsId = "$Id$"; /* * $Log$ + * Revision 1.20 2001/07/24 16:56:29 bartoldeman + * fixes for FCBs, DJGPP ls, DBLBYTE, dyninit allocation (2024e). + * * Revision 1.19 2001/07/23 12:47:42 bartoldeman * FCB fixes and clean-ups, exec int21/ax=4b01, initdisk.c printf * @@ -357,7 +360,6 @@ void FcbNameInit(fcb FAR * lpFcb, BYTE * pszBuffer, COUNT * pCurDrive); BOOL FcbOpen(xfcb FAR * lpXfcb); BOOL FcbDelete(xfcb FAR * lpXfcb); BOOL FcbRename(xfcb FAR * lpXfcb); -VOID MoveDirInfo(dmatch * lpDmatch, fcb FAR * lpDir); BOOL FcbClose(xfcb FAR * lpXfcb); VOID FcbCloseAll(VOID); BOOL FcbFindFirst(xfcb FAR * lpXfcb); diff --git a/readme.txt b/readme.txt index 42bde4ae..43048a5c 100644 --- a/readme.txt +++ b/readme.txt @@ -1,6 +1,6 @@ INTRODUCTION ------------ -This archive contains FreeDOS Kernel version 1.1.18, build 2018, also +This archive contains the current FreeDOS Kernel, also known as DOS-C, originally written by Pasquale J. Villani. The FreeDOS Kernel is available from http://freedos.sourceforge.net. From c5cb6b1cac7938cb3f20bd3121ef271632a2ab27 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sat, 28 Jul 2001 18:13:06 +0000 Subject: [PATCH 086/671] Fixes for FORMAT+SYS, FATFS, get current dir, kernel init memory situation. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@274 6ac86273-5f31-0410-b378-82cca8765d1b --- docs/history.txt | 17 +++++- hdr/version.h | 2 +- kernel/config.c | 151 +++++++++++++++++++++------------------------- kernel/dosfns.c | 34 ++++++----- kernel/dsk.c | 10 ++- kernel/dyndata.h | 11 +--- kernel/dyninit.c | 53 +++++----------- kernel/fatdir.c | 7 ++- kernel/fatfs.c | 41 +++++-------- kernel/init-mod.h | 2 +- kernel/initdisk.c | 56 +++++++---------- kernel/inithma.c | 64 ++++++-------------- kernel/int2f.asm | 5 +- kernel/inthndlr.c | 5 +- kernel/kernel.asm | 62 ++----------------- kernel/main.c | 21 +++++-- kernel/newstuff.c | 15 ++--- 17 files changed, 230 insertions(+), 326 deletions(-) diff --git a/docs/history.txt b/docs/history.txt index 518deb44..eeb01d2c 100644 --- a/docs/history.txt +++ b/docs/history.txt @@ -1,4 +1,19 @@ -2001 Jul 9 - Build 2024/e +2001 Jul 28 - Build 2024/f +-------- Bart Oldeman (bart.oldeman@bristol.ac.uk) ++ fixes Bart + * fixed get current directory - MSCDEX works now (always) + * initdisk.c correctly sets number of hidden sectors: necessary + for FORMAT - SYS chain to work ++ updates Bart + * initialisation memory situation changed: kernel is loaded + to the top of conventional memory in the beginning. Then + move it back low or high depending on DOS=HIGH and the presence + of an XMS driver. + DOS=HIGH without an XMS driver (such as FDXMS) has no effect anymore! ++ fixes Tom, Victor, Bart + * various fatfs.c fixes and clean ups + +2001 Jul 23 - Build 2024/e -------- Bart Oldeman (bart.oldeman@bristol.ac.uk) + fixes Tom * dyninit allocation fix diff --git a/hdr/version.h b/hdr/version.h index 656bd78c..8ce45def 100644 --- a/hdr/version.h +++ b/hdr/version.h @@ -44,4 +44,4 @@ static BYTE *date_hRcsId = "$Id$"; #define REVISION_MINOR 1 #define REVISION_SEQ 24 #define BUILD 2024 -#define SUB_BUILD "e" +#define SUB_BUILD "f" diff --git a/kernel/config.c b/kernel/config.c index 842365e5..8ba76aa9 100644 --- a/kernel/config.c +++ b/kernel/config.c @@ -89,6 +89,9 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.26 2001/07/28 18:13:06 bartoldeman + * Fixes for FORMAT+SYS, FATFS, get current dir, kernel init memory situation. + * * Revision 1.25 2001/07/22 01:58:58 bartoldeman * Support for Brian's FORMAT, DJGPP libc compilation, cleanups, MSCDEX * @@ -272,7 +275,8 @@ struct config Config BYTE FAR *lpBase; BYTE FAR *upBase; -static BYTE FAR *lpOldLast; +BYTE FAR *lpTop; +BYTE FAR *lpOldTop; static COUNT nCfgLine; static COUNT nPass; COUNT UmbState; @@ -364,17 +368,21 @@ INIT BYTE FAR *KernelAllocDma(WORD); BYTE *pLineStart; -BYTE HMATextIsAvailable; +BYTE HMAState; +#define HMA_NONE 0 /* do nothing */ +#define HMA_REQ 1 /* DOS = HIGH detected */ +#define HMA_DONE 2 /* Moved kernel to HMA */ +#define HMA_LOW 3 /* Definitely LOW */ void FAR * ConfigAlloc(COUNT bytes) { VOID FAR *p; - + p = HMAalloc(bytes); if (p == NULL) p = KernelAlloc(bytes); - - /* printf("ConfigAllog %d at %p\n", bytes, p);*/ + + /* printf("ConfigAlloc %d at %p\n", bytes, p);*/ return p; } @@ -389,15 +397,7 @@ INIT void PreConfig(void) UmbState = 0; /* Initialize the base memory pointers */ - - DynFree(0); - - - if ( HMATextIsAvailable ) - lpOldLast = lpBase = AlignParagraph((BYTE FAR *) & _HMATextAvailable); - else - lpOldLast = lpBase = AlignParagraph((BYTE FAR *) & _InitTextStart); - + #ifdef DEBUG { extern BYTE FAR internal_data[]; @@ -412,7 +412,6 @@ INIT void PreConfig(void) - config_init_buffers( Config.cfgBuffers ); /* buffers = (struct buffer FAR *) KernelAlloc(Config.cfgBuffers * sizeof(struct buffer)); */ #ifdef DEBUG @@ -422,7 +421,6 @@ INIT void PreConfig(void) /* Initialize the file table */ /* f_nodes = (f_node_ptr) KernelAlloc(Config.cfgFiles * sizeof(struct f_node));*/ - f_nodes = (f_node_ptr) DynAlloc("f_nodes", Config.cfgFiles , sizeof(struct f_node)); @@ -433,6 +431,11 @@ INIT void PreConfig(void) /* FCBp = (sfttbl FAR *) KernelAlloc(sizeof(sftheader) + Config.cfgFiles * sizeof(sft));*/ + + lpBase = AlignParagraph((BYTE FAR *)DynLast()+0x0f); + + config_init_buffers( Config.cfgBuffers); + sfthead->sftt_next = (sfttbl FAR *) KernelAlloc(sizeof(sftheader) + (Config.cfgFiles-5) * sizeof(sft)); @@ -446,7 +449,7 @@ INIT void PreConfig(void) KernelAlloc(blk_dev.dh_name[0]*sizeof(struct dpb)); #ifdef DEBUG - printf("Preliminary:\n f_node 0x%p",f_nodes); + printf("Preliminary:\n f_node 0x%x",f_nodes); /* printf(" FCB table 0x%p\n",FCBp);*/ printf(" sft table 0x%p\n",sfthead->sftt_next); printf(" CDS table 0x%p\n",CDSp); @@ -487,10 +490,8 @@ INIT void PostConfig(void) /* initialize NEAR allocated things */ - DynFree(Config.cfgFiles * sizeof(struct f_node)); - - /* Initialize the file table */ + DynFree(f_nodes); f_nodes = (f_node_ptr) DynAlloc("f_nodes", Config.cfgFiles , sizeof(struct f_node)); @@ -505,26 +506,11 @@ INIT void PostConfig(void) and allocation starts after the kernel. */ - if ( HMATextIsAvailable ) - lpBase = AlignParagraph((BYTE FAR *)DynLast()+0x0f); - else - { - lpBase = AlignParagraph((BYTE FAR *)DynLast()+0x0f); - - DebugPrintf(("HMA not available, moving text to %x\n",FP_SEG(lpBase))); - MoveKernel(FP_SEG(lpBase)); - - lpBase = AlignParagraph((BYTE FAR *)lpBase + HMAFree + 0x0f); - - DebugPrintf(("kernel is low, start alloc at %p",lpBase)); - } - + lpBase = AlignParagraph((BYTE FAR *)DynLast()+0x0f); DebugPrintf(("starting FAR allocations at %p\n",lpBase)); - lpOldLast = lpBase; - /* Begin by initializing our system buffers */ /* dma_scratch = (BYTE FAR *) KernelAllocDma(BUFFERSIZE); */ #ifdef DEBUG @@ -532,14 +518,7 @@ INIT void PostConfig(void) #endif - config_init_buffers( Config.cfgBuffers ); - - /* buffers = (struct buffer FAR *) - KernelAlloc(Config.cfgBuffers * sizeof(struct buffer)); */ - -#ifdef DEBUG - /* printf("%d buffers allocated at 0x%p\n", Config.cfgBuffers,buffers); */ -#endif + config_init_buffers(Config.cfgBuffers); /* sfthead = (sfttbl FAR *)&basesft; */ /* FCBp = (sfttbl FAR *)&FcbSft; */ @@ -560,7 +539,7 @@ INIT void PostConfig(void) #ifdef DEBUG - printf("Final: \n f_node 0x%p\n",f_nodes); + printf("Final: \n f_node 0x%x\n",f_nodes); /* printf(" FCB table 0x%p\n",FCBp);*/ printf(" sft table 0x%p\n",sfthead->sftt_next); printf(" CDS table 0x%p\n",CDSp); @@ -580,9 +559,21 @@ INIT void PostConfig(void) /* This code must be executed after device drivers has been loaded */ INIT VOID configDone(VOID) { - HMAconfig(TRUE); /* final HMA processing */ - - + if ( HMAState != HMA_DONE ) + { + lpBase = AlignParagraph(lpBase); + + DebugPrintf(("HMA not available, moving text to %x\n",FP_SEG(lpBase))); + MoveKernel(FP_SEG(lpBase)); + + lpBase = AlignParagraph((BYTE FAR *)lpBase + HMAFree + 0x0f); + + DebugPrintf(("kernel is low, start alloc at %p",lpBase)); + + /* final buffer processing, now upwards */ + HMAState = HMA_LOW; + config_init_buffers( Config.cfgBuffers); + } if (lastdrive < nblkdev) { @@ -713,6 +704,10 @@ INIT VOID DoConfig(VOID) bEof = TRUE; break; } + + /* immediately convert to upper case */ + *pLine = toupper(*pLine); + if (pLine >= szLine + sizeof(szLine)-3) { CfgFailure(pLine); @@ -1033,7 +1028,7 @@ INIT static VOID Lastdrive(BYTE * pLine) INIT STATIC VOID Dosmem(BYTE * pLine) { BYTE *pTmp; - BYTE UMBwanted = FALSE, HMAwanted = FALSE; + BYTE UMBwanted = FALSE; /* extern BYTE FAR INITDataSegmentClaimed; */ @@ -1047,7 +1042,7 @@ INIT STATIC VOID Dosmem(BYTE * pLine) for (pTmp = szBuf ; ; ) { if (fmemcmp(pTmp, "UMB" ,3) == 0) { UMBwanted = TRUE; pTmp += 3; } - if (fmemcmp(pTmp, "HIGH",4) == 0) { HMAwanted = TRUE; pTmp += 4; } + if (fmemcmp(pTmp, "HIGH",4) == 0) { HMAState = HMA_REQ; pTmp += 4; } /* if (fmemcmp(pTmp, "CLAIMINIT",9) == 0) { INITDataSegmentClaimed = 0; pTmp += 9; }*/ pTmp = skipwh(pTmp); @@ -1062,10 +1057,9 @@ INIT STATIC VOID Dosmem(BYTE * pLine) uppermem_root = 0; UmbState = UMBwanted ? 2 : 0; } - - if (HMAwanted) - { - HMATextIsAvailable = MoveKernelToHMA(); + /* Check if HMA is available straight away */ + if (HMAState == HMA_REQ && MoveKernelToHMA()){ + HMAState = HMA_DONE; } } @@ -1280,27 +1274,6 @@ INIT BOOL LoadDevice(BYTE * pLine, COUNT top, COUNT mode) multiple devices in it. NUMEGA's SoftIce is such a beast */ - /* that's a nice hack >:-) - - although we don't want HIMEM.SYS,(it's not free), other people - might load HIMEM.SYS to see if they are compatible to it. - - if it's HIMEM.SYS, we won't survive TESTMEM:ON - - so simply add TESTMEM:OFF to the commandline - */ - - if (DosLoadedInHMA) - if (stristr(szBuf, "HIMEM.SYS") != NULL) - { - if (stristr(szBuf, "/TESTMEM:OFF") == NULL) - { - strcat(szBuf, " /TESTMEM:OFF"); - } - } - /* end of HIMEM.SYS HACK */ - - /* add \r\n to the command line */ strcat(szBuf, "\r\n"); @@ -1321,10 +1294,15 @@ INIT BOOL LoadDevice(BYTE * pLine, COUNT top, COUNT mode) /* Link in device driver and save nul_dev pointer to next */ dhp->dh_next = nul_dev.dh_next; nul_dev.dh_next = dhp; - } - - HMAconfig(FALSE); /* let the HMA claim HMA usage */ - + } + /* We could just have loaded FDXMS or HIMEM */ + if (HMAState == HMA_REQ && MoveKernelToHMA()) + { + /* final HMA processing: */ + /* final buffer processing, now upwards */ + HMAState = HMA_DONE; + config_init_buffers( Config.cfgBuffers); + } } else CfgFailure(pLine); @@ -1580,6 +1558,7 @@ VOID config_init_buffers(COUNT anzBuffers) REG WORD i; struct buffer FAR *pbuffer; int HMAcount = 0; + BYTE FAR *tmplpBase = lpBase; anzBuffers = max(anzBuffers,6); if (anzBuffers > 99) @@ -1588,6 +1567,11 @@ VOID config_init_buffers(COUNT anzBuffers) anzBuffers = 99; } + lpTop = lpOldTop; + + if (HMAState == HMA_NONE || HMAState == HMA_REQ) + lpTop = lpBase = lpTop - anzBuffers * (sizeof (struct buffer) + 0xf); + firstbuf = ConfigAlloc(sizeof (struct buffer)); pbuffer = firstbuf; @@ -1606,7 +1590,7 @@ VOID config_init_buffers(COUNT anzBuffers) pbuffer->b_offset_hi = 0; pbuffer->b_next = NULL; - /* printf("init_buffers buffer %d at %p\n",i, pbuffer);*/ + DebugPrintf(("init_buffers buffer %d at %p\n",i, pbuffer)); if (i < (anzBuffers - 1)) pbuffer->b_next = ConfigAlloc(sizeof (struct buffer)); @@ -1617,9 +1601,10 @@ VOID config_init_buffers(COUNT anzBuffers) pbuffer = pbuffer->b_next; } - if (HMAcount > 0) - printf("Kernel: allocated %d Diskbuffers = %u Bytes in HMA\n", - HMAcount, HMAcount*sizeof (struct buffer)); + DebugPrintf(("Kernel: allocated %d Diskbuffers = %u Bytes in HMA\n", + HMAcount, HMAcount*sizeof (struct buffer))); + if (HMAState == HMA_NONE || HMAState == HMA_REQ) + lpBase = tmplpBase; } /* diff --git a/kernel/dosfns.c b/kernel/dosfns.c index 453c8439..083daa0c 100644 --- a/kernel/dosfns.c +++ b/kernel/dosfns.c @@ -37,6 +37,9 @@ static BYTE *dosfnsRcsId = "$Id$"; * /// Added SHARE support. 2000/09/04 Ron Cemer * * $Log$ + * Revision 1.23 2001/07/28 18:13:06 bartoldeman + * Fixes for FORMAT+SYS, FATFS, get current dir, kernel init memory situation. + * * Revision 1.22 2001/07/24 16:56:29 bartoldeman * fixes for FCBs, DJGPP ls, DBLBYTE, dyninit allocation (2024e). * @@ -1172,6 +1175,8 @@ VOID DosGetFree(UBYTE drive, COUNT FAR * spc, COUNT FAR * navc, COUNT FAR * bps, COUNT DosGetCuDir(UBYTE drive, BYTE FAR * s) { + BYTE FAR *cp; + /* next - "log" in the drive */ drive = (drive == 0 ? default_drive : drive - 1); @@ -1182,8 +1187,11 @@ COUNT DosGetCuDir(UBYTE drive, BYTE FAR * s) current_ldt = &CDSp->cds_table[drive]; - fsncopy((BYTE FAR *) & current_ldt->cdsCurrentPath[1 + current_ldt->cdsJoinOffset], - s, 64); + cp = ¤t_ldt->cdsCurrentPath[current_ldt->cdsJoinOffset]; + if (*cp == '\0') + s[0]='\0'; + else + fstrncpy(s, cp+1, 64); return SUCCESS; } @@ -1264,7 +1272,7 @@ STATIC VOID pop_dmp(dmatch FAR * dmp) COUNT DosFindFirst(UCOUNT attr, BYTE FAR * name) { - COUNT nDrive, rc; + COUNT rc; REG dmatch FAR *dmp = (dmatch FAR *) dta; BYTE FAR *p; @@ -1277,6 +1285,10 @@ COUNT DosFindFirst(UCOUNT attr, BYTE FAR * name) - Ron Cemer */ fmemset(dta, 0, sizeof(dmatch)); + + /* initially mark the dta as invalid for further findnexts */ + ((dmatch FAR *)dta)->dm_attr_fnd = D_DEVICE; + memset(&SearchDir, 0, sizeof(struct dirent)); rc = truename(name, PriPathName, FALSE); @@ -1303,13 +1315,8 @@ COUNT DosFindFirst(UCOUNT attr, BYTE FAR * name) } /* /// End of additions. - Ron Cemer ; heavily edited - Bart Oldeman */ - nDrive=get_verify_drive(name); - if (nDrive < 0) - return nDrive; SAttr = (BYTE) attr; - current_ldt = &CDSp->cds_table[nDrive]; - #if defined(FIND_DEBUG) printf("Remote Find: n='%Fs\n", PriPathName); #endif @@ -1324,12 +1331,10 @@ COUNT DosFindFirst(UCOUNT attr, BYTE FAR * name) dta = p; - if (rc != SUCCESS) - return rc; - fmemcpy(dta, TempBuffer, 21); pop_dmp((dmatch FAR *)dta); - return SUCCESS; + if (rc != SUCCESS) ((dmatch FAR *)dta)->dm_attr_fnd = D_DEVICE; /* mark invalid */ + return rc; } COUNT DosFindNext(void) @@ -1371,12 +1376,9 @@ COUNT DosFindNext(void) dos_findnext(); dta = p; - if (rc != SUCCESS) - return rc; - fmemcpy(dta, TempBuffer, 21); pop_dmp((dmatch FAR *)dta); - return SUCCESS; + return rc; } COUNT DosGetFtime(COUNT hndl, date FAR * dp, time FAR * tp) diff --git a/kernel/dsk.c b/kernel/dsk.c index 513e4e7c..4d050dab 100644 --- a/kernel/dsk.c +++ b/kernel/dsk.c @@ -26,12 +26,17 @@ #include "portab.h" #include "globals.h" +#include "dyndata.h" + #ifdef VERSION_STRINGS static BYTE *dskRcsId = "$Id$"; #endif /* * $Log$ + * Revision 1.19 2001/07/28 18:13:06 bartoldeman + * Fixes for FORMAT+SYS, FATFS, get current dir, kernel init memory situation. + * * Revision 1.18 2001/07/22 01:58:58 bartoldeman * Support for Brian's FORMAT, DJGPP libc compilation, cleanups, MSCDEX * @@ -216,11 +221,10 @@ struct FS_info BYTE fstype[8]; }; -ddt *pddt0; /* Internal media info structs */ -/* STATIC bpb *bpbptrs[NDEV]; pointers to bpbs */ +extern struct DynS Dyn; /*TE - array access functions */ -ddt *getddt(int dev) { return &pddt0[dev];} +ddt *getddt(int dev) { return &(((ddt*)Dyn.Buffer)[dev]);} #define N_PART 4 /* number of partitions per table partition */ diff --git a/kernel/dyndata.h b/kernel/dyndata.h index f35d2ab4..fb61dc3f 100644 --- a/kernel/dyndata.h +++ b/kernel/dyndata.h @@ -9,16 +9,11 @@ moveable and Dyn.Buffer resizable, but not before */ -void *DynAlloc(char far *what, unsigned num, unsigned size); -void DynFree(unsigned memory_needed); +void far *DynAlloc(char *what, unsigned num, unsigned size); void far *DynLast(void); +void DynFree(void *ptr); struct DynS { unsigned Allocated; - unsigned UsedByDiskInit; - unsigned AllocMax; - char Buffer[NDEV*sizeof(ddt) /* for InitDisk - Drive Data Table */ - + 16 * 71 /* initial f_nodes */ - +200 /* give some extra bytes */ - ]; + char Buffer[0]; }; diff --git a/kernel/dyninit.c b/kernel/dyninit.c index 9ff45a11..2d90efac 100644 --- a/kernel/dyninit.c +++ b/kernel/dyninit.c @@ -50,57 +50,36 @@ kernel layout: extern struct DynS FAR Dyn; -void *DynAlloc(char FAR *what, unsigned num, unsigned size) +void far *DynAlloc(char *what, unsigned num, unsigned size) { - void *now; + void far *now; unsigned total = num * size; - +#ifndef DEBUG UNREFERENCED_PARAMETER(what); +#endif - DebugPrintf(("DYNDATA:allocating %Fs - %u * %u bytes, total %u, %u..%u\n", + if ((ULONG)total + Dyn.Allocated > 0xffff) + { + printf("PANIC:Dyn %lu\n", (ULONG)total + Dyn.Allocated); + for (;;); + } + + DebugPrintf(("DYNDATA:allocating %s - %u * %u bytes, total %u, %u..%u\n", what, num, size, total, Dyn.Allocated,Dyn.Allocated+total)); - if (total > Dyn.AllocMax - Dyn.Allocated) - { - printf("DYNDATA overflow"); - for (;;); - } - now = (void*)&Dyn.Buffer[Dyn.Allocated]; + now = (void far *)&Dyn.Buffer[Dyn.Allocated]; + fmemset(now, 0, total); Dyn.Allocated += total; - return now; } -void DynFree(unsigned memory_needed) +void DynFree(void *ptr) { - if (memory_needed == 0) /* this is pass 0 */ - { + Dyn.Allocated = (char *)ptr - (char *)Dyn.Buffer; +} - Dyn.Allocated = NDEV*sizeof(ddt); /* this reserves space for initDisk */ - Dyn.AllocMax = sizeof(Dyn.Buffer); - } - else { - /* enlarge kernel data segment to 64K */ - if (memory_needed + Dyn.UsedByDiskInit > sizeof(Dyn.Buffer)) - { - if ((ULONG)memory_needed + Dyn.UsedByDiskInit > 0xffff) - { - printf("PANIC:Dyn %lu\n",memory_needed + Dyn.UsedByDiskInit); - for (;;); - } - - MoveKernel(FP_SEG(&Dyn.UsedByDiskInit) + 0x1000); - - Dyn.AllocMax = 0xffff - (unsigned)&Dyn.Buffer; - } - Dyn.Allocated = Dyn.UsedByDiskInit; - } - - DebugPrintf(("DYNDATA:free to %u, max %u\n",Dyn.Allocated,Dyn.AllocMax)); -} - void FAR *DynLast() { DebugPrintf(("dynamic data end at %p\n",(void FAR *)(Dyn.Buffer+Dyn.Allocated))); diff --git a/kernel/fatdir.c b/kernel/fatdir.c index c26279d3..9e661a53 100644 --- a/kernel/fatdir.c +++ b/kernel/fatdir.c @@ -36,6 +36,9 @@ static BYTE *fatdirRcsId = "$Id$"; /* * $Log$ + * Revision 1.21 2001/07/28 18:13:06 bartoldeman + * Fixes for FORMAT+SYS, FATFS, get current dir, kernel init memory situation. + * * Revision 1.20 2001/07/24 16:56:29 bartoldeman * fixes for FCBs, DJGPP ls, DBLBYTE, dyninit allocation (2024e). * @@ -652,7 +655,7 @@ COUNT dos_findfirst(UCOUNT attr, BYTE *name) /* directory and only searched for once. So we need to open */ /* the root and return only the first entry that contains the */ /* volume id bit set. */ - if ((attr & ~(D_RDONLY | D_ARCHIVE)) == D_VOLID) + if (attr & D_VOLID) { szDirName[2] = '\\'; szDirName[3] = '\0'; @@ -676,7 +679,7 @@ COUNT dos_findfirst(UCOUNT attr, BYTE *name) fbcopy((BYTE FAR *) SearchDir.dir_name, dmp->dm_name_pat, FNAME_SIZE + FEXT_SIZE); - if ((attr & ~(D_RDONLY | D_ARCHIVE)) == D_VOLID) + if (attr & D_VOLID) { /* Now do the search */ while (dir_read(fnp) == DIRENT_SIZE) diff --git a/kernel/fatfs.c b/kernel/fatfs.c index 96c73220..7284881e 100644 --- a/kernel/fatfs.c +++ b/kernel/fatfs.c @@ -47,6 +47,9 @@ BYTE *RcsId = "$Id$"; * performance killer on large drives. (~0.5 sec /dos_mkdir) TE * * $Log$ + * Revision 1.22 2001/07/28 18:13:06 bartoldeman + * Fixes for FORMAT+SYS, FATFS, get current dir, kernel init memory situation. + * * Revision 1.21 2001/07/24 16:56:29 bartoldeman * fixes for FCBs, DJGPP ls, DBLBYTE, dyninit allocation (2024e). * @@ -293,7 +296,6 @@ COUNT dos_open(BYTE * path, COUNT flag) /* new directory and name of new directory. */ if ((fnp = split_path(path, szFileName, szFileExt)) == NULL) { - dir_close(fnp); return DE_PATHNOTFND; } @@ -366,20 +368,14 @@ COUNT dos_close(COUNT fd) if (fnp == (f_node_ptr)0 || fnp->f_count <= 0) return DE_INVLDHNDL; - if (fnp->f_mode != RDONLY) + if (fnp->f_mode != RDONLY && fnp->f_flags.f_dmod) { - /*TE experimental */ - if (fnp->f_flags.f_dmod) - { - fnp->f_dir.dir_attrib |= D_ARCHIVE; - fnp->f_dir.dir_time = dos_gettime(); - fnp->f_dir.dir_date = dos_getdate(); + fnp->f_dir.dir_attrib |= D_ARCHIVE; + fnp->f_dir.dir_time = dos_gettime(); + fnp->f_dir.dir_date = dos_getdate(); - shrink_file(fnp); /* reduce allocated filesize in FAT */ - } - + shrink_file(fnp); /* reduce allocated filesize in FAT */ fnp->f_dir.dir_size = fnp->f_highwater; - fnp->f_flags.f_dmod = TRUE; merge_file_changes(fnp, FALSE); /* /// Added - Ron Cemer */ } fnp->f_flags.f_ddir = TRUE; @@ -568,7 +564,6 @@ COUNT dos_creat(BYTE * path, COUNT attrib) /* path to new directory and name of new directory */ if ((fnp = split_path(path, szFileName, szFileExt)) == NULL) { - dir_close(fnp); return DE_PATHNOTFND; } @@ -668,7 +663,6 @@ COUNT dos_delete(BYTE * path) /* path to new directory and name of new directory */ if ((fnp = split_path(path, szFileName, szFileExt)) == NULL) { - dir_close(fnp); return DE_PATHNOTFND; } @@ -720,7 +714,6 @@ COUNT dos_rmdir(BYTE * path) /* path to new directory and name of new directory */ if ((fnp = split_path(path, szFileName, szFileExt)) == NULL) { - dir_close(fnp); return DE_PATHNOTFND; } @@ -742,9 +735,9 @@ COUNT dos_rmdir(BYTE * path) /* directories may have attributes, too. at least my WinNT disk has many 'archive' directories - we still don't allow SYSTEM or RDONLY directories to be deleted TE*/ + we still don't allow RDONLY directories to be deleted TE*/ - if (fnp->f_dir.dir_attrib & ~(D_DIR |D_HIDDEN|D_ARCHIVE)) + if (fnp->f_dir.dir_attrib & ~(D_DIR |D_HIDDEN|D_ARCHIVE|D_SYSTEM)) { dir_close(fnp); return DE_ACCESS; @@ -826,7 +819,6 @@ COUNT dos_rename(BYTE * path1, BYTE * path2) /* new file name and name of new file name */ if ((fnp2 = split_path(path2, szFileName, szFileExt)) == NULL) { - dir_close(fnp2); return DE_PATHNOTFND; } @@ -842,7 +834,6 @@ COUNT dos_rename(BYTE * path1, BYTE * path2) /* old file name and name of old file name */ if ((fnp1 = split_path(path1, szFileName, szFileExt)) == NULL) { - dir_close(fnp1); dir_close(fnp2); return DE_PATHNOTFND; } @@ -1192,7 +1183,6 @@ COUNT dos_mkdir(BYTE * dir) /* path to new directory and name of new directory */ if ((fnp = split_path(dir, szFileName, szFileExt)) == NULL) { - dir_close(fnp); return DE_PATHNOTFND; } @@ -1995,9 +1985,6 @@ UCOUNT writeblock(COUNT fd, VOID FAR * buffer, UCOUNT count, COUNT * err) } - fnp->f_flags.f_dmod = TRUE; /* mark file as modified */ - - /* update pointers and counters */ ret_cnt += xfr_cnt; to_xfer -= xfr_cnt; @@ -2439,8 +2426,12 @@ STATIC VOID shrink_file(f_node_ptr fnp) UCOUNT next,st; struct dpb FAR *dpbp = fnp->f_dpb; - + if (fnp->f_flags.f_ddir) /* can't shrink dirs */ + return; + fnp->f_offset = fnp->f_highwater; /* end of file */ + + if (fnp->f_offset) fnp->f_offset--; /* last existing cluster */ if (map_cluster(fnp, XFR_READ) != SUCCESS) /* error, don't truncate */ goto done; @@ -2457,7 +2448,7 @@ STATIC VOID shrink_file(f_node_ptr fnp) goto done; /* Loop from start until either a FREE entry is */ - /* encountered (due to a fractured file system) of the */ + /* encountered (due to a damaged file system) or the */ /* last cluster is encountered. */ /* zap the FAT pointed to */ diff --git a/kernel/init-mod.h b/kernel/init-mod.h index 572b85a7..cc6d6aac 100644 --- a/kernel/init-mod.h +++ b/kernel/init-mod.h @@ -73,7 +73,7 @@ extern fmemcmp(BYTE far *s1, BYTE FAR *s2, unsigned len); #define NUMBUFF 6 /* Number of track buffers */ /* -- must be at least 3 */ #define MAX_HARD_DRIVE 8 -#define NDEV 20 /* only one for demo */ +#define NDEV 26 /* up to Z: */ diff --git a/kernel/initdisk.c b/kernel/initdisk.c index a7c8ac2a..62f55319 100644 --- a/kernel/initdisk.c +++ b/kernel/initdisk.c @@ -34,8 +34,6 @@ static BYTE *dskRcsId = "$Id$"; /* data shared between DSK.C and INITDISK.C */ -extern ddt * FAR pddt0; /* Pointer to drive data tables */ - extern UBYTE FAR DiskTransferBuffer[1 * SEC_SIZE]; extern COUNT FAR nUnits; @@ -190,6 +188,16 @@ struct DriveParamS struct CHS chs; /* for normal INT 13 */ }; +struct PartTableEntry /* INTERNAL representation of partition table entry */ + { + UBYTE Bootable; + UBYTE FileSystem; + struct CHS Begin; + struct CHS End; + ULONG RelSect; + ULONG NumSect; + }; + /* internal global data */ @@ -376,10 +384,9 @@ VOID CalculateFATData(ddt FAR *pddt, ULONG NumSectors, UBYTE FileSystem) void DosDefinePartition(struct DriveParamS *driveParam, - ULONG StartSector, ULONG NumSectors, UBYTE FileSystem) + ULONG StartSector, struct PartTableEntry *pEntry) { - extern struct DynS FAR Dyn; - ddt FAR *pddt = &((ddt FAR *)&Dyn.Buffer[0])[nUnits]; + ddt FAR *pddt = DynAlloc("ddt", 1, sizeof(ddt)); struct CHS chs; if ( nUnits >= NDEV) @@ -397,19 +404,20 @@ void DosDefinePartition(struct DriveParamS *driveParam, DebugPrintf(("LBA enabled for drive %c:\n", 'A'+nUnits)); pddt->ddt_offset = StartSector; - + pddt->ddt_defbpb.bpb_nbyte = SEC_SIZE; pddt->ddt_defbpb.bpb_mdesc = 0xf8; pddt->ddt_defbpb.bpb_nheads = driveParam->chs.Head; pddt->ddt_defbpb.bpb_nsecs = driveParam->chs.Sector; pddt->ddt_defbpb.bpb_nsize = 0; - if (NumSectors > 0xffff) - pddt->ddt_defbpb.bpb_huge = NumSectors; + pddt->ddt_defbpb.bpb_hidden = pEntry->RelSect; + if (pEntry->NumSect > 0xffff) + pddt->ddt_defbpb.bpb_huge = pEntry->NumSect; else - pddt->ddt_defbpb.bpb_nsize = (UWORD)NumSectors; + pddt->ddt_defbpb.bpb_nsize = (UWORD)(pEntry->NumSect); /* sectors per cluster, sectors per FAT etc. */ - CalculateFATData(pddt, NumSectors, FileSystem); + CalculateFATData(pddt, pEntry->NumSect, pEntry->FileSystem); pddt->ddt_serialno = 0x12345678l; pddt->ddt_descflags = 0x200; /* drive inaccessible until bldbpb successful */ @@ -425,7 +433,7 @@ void DosDefinePartition(struct DriveParamS *driveParam, printCHS(" CHS= ",&chs); printf(" start = %5luMB,size =%5lu", - StartSector/2048,NumSectors/2048); + StartSector/2048,pEntry->NumSect/2048); printf("\n"); #endif @@ -583,16 +591,6 @@ int LBA_Get_Drive_Parameters(int drive,struct DriveParamS *driveParam) -struct PartTableEntry /* INTERNAL representation of partition table entry */ - { - UBYTE Bootable; - UBYTE FileSystem; - struct CHS Begin; - struct CHS End; - ULONG RelSect; - ULONG NumSect; - }; - /* converts physical into logical representation of partition entry */ @@ -740,7 +738,7 @@ ScanForPrimaryPartitions(struct DriveParamS *driveParam,int scan_type, partitionsToIgnore |= 1 << i; - DosDefinePartition(driveParam,partitionStart, pEntry->NumSect, pEntry->FileSystem); + DosDefinePartition(driveParam,partitionStart, pEntry); if (scan_type == SCAN_PRIMARYBOOT || scan_type == SCAN_PRIMARY ) @@ -1052,19 +1050,15 @@ void ReadAllPartitionTables(void) int HardDrive; int nHardDisk = BIOS_nrdrives(); - ddt FAR *pddt; bpb FAR *pbpbarray; int Unit; - - extern struct DynS FAR Dyn; -/* ddt *miarrayptr; /* Internal media info structs */ - - pddt0 = (ddt *)&Dyn.Buffer[0]; + ddt FAR *pddt; /* Setup media info and BPBs arrays for floppies (this is a 360kb flop) */ for (Unit = 0; Unit < nUnits; Unit++) { - pddt = &((ddt FAR *)&Dyn.Buffer[0])[Unit]; + pddt = DynAlloc("ddt", 1, sizeof(ddt)); + pbpbarray = &pddt->ddt_defbpb; pbpbarray->bpb_nbyte = SEC_SIZE; @@ -1138,10 +1132,6 @@ void ReadAllPartitionTables(void) { ProcessDisk(SCAN_PRIMARY2, HardDrive ,foundPartitions[HardDrive]); } - - - Dyn.UsedByDiskInit = nUnits * sizeof(ddt); - } /* disk initialization: returns number of units */ diff --git a/kernel/inithma.c b/kernel/inithma.c index 71be97e2..9bba26e8 100644 --- a/kernel/inithma.c +++ b/kernel/inithma.c @@ -81,6 +81,9 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.8 2001/07/28 18:13:06 bartoldeman + * Fixes for FORMAT+SYS, FATFS, get current dir, kernel init memory situation. + * * Revision 1.7 2001/07/09 22:19:33 bartoldeman * LBA/FCB/FAT/SYS/Ctrl-C/ioctl fixes + memory savings * @@ -106,6 +109,7 @@ static BYTE *RcsId = "$Id$"; * initial creation */ +void ClaimHMA(VOID); BYTE DosLoadedInHMA=FALSE; /* set to TRUE if loaded HIGH */ BYTE HMAclaimed=FALSE; /* set to TRUE if claimed from HIMEM */ @@ -174,34 +178,6 @@ fmemcmp(BYTE far *s1, BYTE FAR *s2, unsigned len) } -/* Enable / Disable borrowed without understanding from FDXMS. Thanks. - gone done to KERNEL.ASM - -OutportWithDelay(WORD port, BYTE val) -{ - int loop; - - __outportb__(port,val); - - for (loop = 100; --loop && __inportb__(0x64) & 0x02;) - ; -} - - -void _EnableHMA() -{ - OutportWithDelay(0x64, 0xd1); - OutportWithDelay(0x60, 0xdf); - OutportWithDelay(0x64, 0xff); -} -void _DisableHMA() -{ - OutportWithDelay(0x64, 0xd1); - OutportWithDelay(0x60, 0xdd); - OutportWithDelay(0x64, 0xff); -} -*/ - /* this tests, if the HMA area can be enabled. if so, it simply leaves it on @@ -261,20 +237,15 @@ int MoveKernelToHMA() return TRUE; } - { /* is very improbable - we are just booting - but - there might already a XMS handler installed - this is the case for DOSEMU - */ - + { void FAR *pXMS = DetectXMSDriver(); if (pXMS != NULL) { XMSDriverAddress = pXMS; - - printf("DOSEMU ? detected XMS driver at %p\n", XMSDriverAddress); - } + else + return FALSE; } @@ -297,7 +268,9 @@ int MoveKernelToHMA() printf("Can't enable HMA area (the famous A20), NOT moving to HMA\n"); return FALSE; - } + } + + ClaimHMA(); MoveKernel(0xffff); @@ -326,12 +299,7 @@ int MoveKernelToHMA() } -/* - - - - - +/* not necessary anymore : BO */ /* now protect against HIMEM/FDXMS/... by simulating a VDISK FDXMS should detect us and not give HMA access to ohers @@ -339,6 +307,7 @@ int MoveKernelToHMA() so: we install this after all drivers have been loaded */ +#if 0 void InstallVDISK(VOID) { static struct { /* Boot-Sektor of a RAM-Disk */ @@ -370,14 +339,14 @@ void InstallVDISK(VOID) *(WORD FAR *)MK_FP(0xffff,0x002e) = 1024+64; } +#endif int init_call_XMScall( void FAR * driverAddress, UWORD ax, UWORD dx); /* - after each driver, we try to allocate the HMA. - it might be HIMEM.SYS we just loaded. + allocate HMA through XMS driver */ void ClaimHMA(VOID) @@ -412,7 +381,7 @@ void ClaimHMA(VOID) on finalize, will install a VDISK */ - +#if 0 /* not necessary anymore */ void HMAconfig(int finalize) { @@ -420,7 +389,8 @@ void HMAconfig(int finalize) if (finalize) InstallVDISK(); -} +} +#endif /* this allocates some bytes from the HMA area diff --git a/kernel/int2f.asm b/kernel/int2f.asm index 08f371e1..7545b906 100644 --- a/kernel/int2f.asm +++ b/kernel/int2f.asm @@ -30,6 +30,9 @@ ; $Id$ ; ; $Log$ +; Revision 1.11 2001/07/28 18:13:06 bartoldeman +; Fixes for FORMAT+SYS, FATFS, get current dir, kernel init memory situation. +; ; Revision 1.10 2001/07/22 01:58:58 bartoldeman ; Support for Brian's FORMAT, DJGPP libc compilation, cleanups, MSCDEX ; @@ -313,7 +316,7 @@ _QRemote_Fn stc int 2fh mov ax,0xffff - jnc QRemote_Fn_out + jc QRemote_Fn_out xor ax,ax QRemote_Fn_out: pop di diff --git a/kernel/inthndlr.c b/kernel/inthndlr.c index 495692b0..978f3300 100644 --- a/kernel/inthndlr.c +++ b/kernel/inthndlr.c @@ -37,6 +37,9 @@ BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.29 2001/07/28 18:13:06 bartoldeman + * Fixes for FORMAT+SYS, FATFS, get current dir, kernel init memory situation. + * * Revision 1.28 2001/07/24 16:56:29 bartoldeman * fixes for FCBs, DJGPP ls, DBLBYTE, dyninit allocation (2024e). * @@ -1503,7 +1506,7 @@ VOID int21_service(iregs FAR * r) case 0x60: /* TRUENAME */ CLEAR_CARRY_FLAG(); if ((rc = truename(MK_FP(r->DS, r->SI), - adjust_far(MK_FP(r->ES, r->DI)), TRUE)) != SUCCESS) + adjust_far(MK_FP(r->ES, r->DI)), FALSE)) != SUCCESS) goto error_exit; break; diff --git a/kernel/kernel.asm b/kernel/kernel.asm index 041be036..94525f77 100644 --- a/kernel/kernel.asm +++ b/kernel/kernel.asm @@ -28,6 +28,9 @@ ; $Id$ ; ; $Log$ +; Revision 1.16 2001/07/28 18:13:06 bartoldeman +; Fixes for FORMAT+SYS, FATFS, get current dir, kernel init memory situation. +; ; Revision 1.15 2001/07/22 01:58:58 bartoldeman ; Support for Brian's FORMAT, DJGPP libc compilation, cleanups, MSCDEX ; @@ -676,6 +679,8 @@ __ib_end: init_tos: ; the last paragraph of conventional memory might become an MCB resb 16 + global __init_end +__init_end: init_end: segment _BSSEND @@ -919,22 +924,6 @@ __HMARelocationTableEnd: ; will be only ever called, if HMA (DOS=HIGH) is enabled. ; for obvious reasons it should be located at the relocation table ; - global enableA20 ; to see it in the map - -delay: - in al, 64h -delay_check: - and al, 2 - jnz delay - ret - -;void _EnableHMA() -;{ -; OutportWithDelay(0x64, 0xd1); -; OutportWithDelay(0x60, 0xdf); -; OutportWithDelay(0x64, 0xff); -;} - global _XMSDriverAddress _XMSDriverAddress: dw 0 ; XMS driver, if detected @@ -942,25 +931,6 @@ _XMSDriverAddress: global __EnableA20 __EnableA20: - cmp word [cs:_XMSDriverAddress],0 - jne enableUsingXMSdriver - cmp word [cs:_XMSDriverAddress+2],0 - jne enableUsingXMSdriver - - - ; we do it ourself, without an XMS driver - mov al,0d1h - out 64h,al - call delay - mov al,0dfh - out 60h,al - call delay - mov al,0ffh - out 64h,al - call delay - retf - -enableUsingXMSdriver: mov ah,3 UsingXMSdriver: push bx @@ -971,27 +941,7 @@ UsingXMSdriver: global __DisableA20 __DisableA20: mov ah,4 - cmp word [cs:_XMSDriverAddress],0 - jne UsingXMSdriver - cmp word [cs:_XMSDriverAddress+2],0 - jne UsingXMSdriver - - ; we do it ourself, without an XMS driver - ;OutportWithDelay(0x64, 0xd1); - ;OutportWithDelay(0x60, 0xdd); - ;OutportWithDelay(0x64, 0xff); - mov al,0d1h - out 64h,al - call delay - mov al,0ddh - out 60h,al - call delay - mov al,0ffh - out 64h,al - call delay - - retf - + jmp short UsingXMSdriver dslowmem dw 0 eshighmem dw 0ffffh diff --git a/kernel/main.c b/kernel/main.c index 73b26da3..943f267f 100644 --- a/kernel/main.c +++ b/kernel/main.c @@ -62,8 +62,8 @@ extern struct dhdr FAR con_dev, /* console device drive FAR blk_dev; /* Block device (Disk) driver */ extern UWORD FAR ram_top; /* How much ram in Kbytes */ - extern iregs FAR * FAR user_r; /* User registers for int 21h call */ +extern BYTE FAR _HMATextEnd[]; #ifdef VERSION_STRINGS static BYTE *mainRcsId = "$Id$"; @@ -71,6 +71,9 @@ static BYTE *mainRcsId = "$Id$"; /* * $Log$ + * Revision 1.20 2001/07/28 18:13:06 bartoldeman + * Fixes for FORMAT+SYS, FATFS, get current dir, kernel init memory situation. + * * Revision 1.19 2001/07/22 01:58:58 bartoldeman * Support for Brian's FORMAT, DJGPP libc compilation, cleanups, MSCDEX * @@ -218,8 +221,10 @@ static BYTE *mainRcsId = "$Id$"; extern WORD days[2][13]; extern BYTE FAR * lpBase; +extern BYTE FAR * lpOldTop; +extern BYTE FAR * lpTop; extern BYTE FAR * upBase; -extern BYTE _ib_start[], _ib_end[]; +extern BYTE _ib_start[], _ib_end[], _init_end[]; INIT VOID configDone(VOID); INIT static void InitIO(void); @@ -282,6 +287,13 @@ INIT void init_kernel(void) /* Init oem hook - returns memory size in KB */ ram_top = init_oem(); + /* move kernel to high conventional RAM, just below the init code */ + lpTop = MK_FP(ram_top * 64 - (FP_OFF(_init_end)+15)/16 - + (FP_OFF(_HMATextEnd)+15)/16, 0); + + MoveKernel(FP_SEG(lpTop)); + lpOldTop = lpTop = MK_FP(FP_SEG(lpTop) - 0xfff, 0xfff0); + /* Fake int 21h stack frame */ user_r = (iregs FAR *) DOS_PSP + 0xD0; @@ -316,10 +328,11 @@ INIT void init_kernel(void) /* we can read config.sys later. */ lastdrive = Config.cfgLastdrive; - PreConfig(); - /* init_device((struct dhdr FAR *)&blk_dev, NULL, NULL, ram_top); */ blk_dev.dh_name[0] = dsk_init(); + + PreConfig(); + /* Number of units */ if (blk_dev.dh_name[0] > 0) update_dcb(&blk_dev); diff --git a/kernel/newstuff.c b/kernel/newstuff.c index 497b697d..bcaa8930 100644 --- a/kernel/newstuff.c +++ b/kernel/newstuff.c @@ -31,6 +31,9 @@ static BYTE *mainRcsId = "$Id$"; /* * $Log$ + * Revision 1.12 2001/07/28 18:13:06 bartoldeman + * Fixes for FORMAT+SYS, FATFS, get current dir, kernel init memory situation. + * * Revision 1.11 2001/04/15 03:21:50 bartoldeman * See history.txt for the list of fixes. * @@ -254,7 +257,6 @@ COUNT truename(char FAR * src, char FAR * dest, COUNT t) static char buf[128] = "A:\\\0\0\0\0\0\0\0\0\0"; char *bufp = buf + 3; COUNT i, rootEndPos = 2; /* renamed x to rootEndPos - Ron Cemer */ - struct cds FAR *cdsp; struct dhdr FAR *dhp; BYTE FAR *froot; WORD d; @@ -329,21 +331,20 @@ COUNT truename(char FAR * src, char FAR * dest, COUNT t) goto exit_tn; } - cdsp = &CDSp->cds_table[i]; - current_ldt = cdsp; + current_ldt = &CDSp->cds_table[i]; /* Always give the redirector a chance to rewrite the filename */ fsncopy((BYTE FAR *) src, bufp -1, sizeof(buf) - (bufp - buf)); - if ((QRemote_Fn(buf, dest) == SUCCESS) && (dest[0] != '\0')) { + if ((t == FALSE) && (QRemote_Fn(buf, dest) == SUCCESS) && (dest[0] != '\0')) { return SUCCESS; } else { bufp[-1] = '\\'; } if (t == FALSE) { - fsncopy((BYTE FAR *) & cdsp->cdsCurrentPath[0], (BYTE FAR *) & buf[0], cdsp->cdsJoinOffset); - bufp = buf + cdsp->cdsJoinOffset; - rootEndPos = cdsp->cdsJoinOffset; /* renamed x to rootEndPos - Ron Cemer */ + fsncopy((BYTE FAR *) & current_ldt->cdsCurrentPath[0], (BYTE FAR *) & buf[0], current_ldt->cdsJoinOffset); + bufp = buf + current_ldt->cdsJoinOffset; + rootEndPos = current_ldt->cdsJoinOffset; /* renamed x to rootEndPos - Ron Cemer */ *bufp++ = '\\'; } From d9c11a4095c2b63f5dda6a6babf579246d2a03ba Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sun, 19 Aug 2001 12:58:36 +0000 Subject: [PATCH 087/671] Time and date fixes, Ctrl-S/P, findfirst/next, FCBs, buffers, tsr unloading git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@278 6ac86273-5f31-0410-b378-82cca8765d1b --- hdr/buffer.h | 4 ++ hdr/fnode.h | 4 ++ kernel/break.c | 4 ++ kernel/chario.c | 128 +++++++++++++++++++++++++++++++++-------- kernel/config.c | 10 +++- kernel/dosfns.c | 46 +++++---------- kernel/fatdir.c | 10 +++- kernel/fatfs.c | 24 ++++++-- kernel/fcbfns.c | 15 ++++- kernel/globals.h | 11 +++- kernel/inithma.c | 6 +- kernel/int2f.asm | 142 +++++++++++++++++++++++++++++++++++++++++++--- kernel/inthndlr.c | 22 +++---- kernel/kernel.asm | 14 +++-- kernel/proto.h | 20 ++++--- kernel/sysclk.c | 10 ++-- kernel/systime.c | 17 +++--- kernel/task.c | 5 +- 18 files changed, 377 insertions(+), 115 deletions(-) diff --git a/hdr/buffer.h b/hdr/buffer.h index 8662fe82..2d3b6651 100644 --- a/hdr/buffer.h +++ b/hdr/buffer.h @@ -38,6 +38,9 @@ static BYTE *buffer_hRcsId = "$Id$"; /* * $Log$ + * Revision 1.4 2001/08/19 12:58:34 bartoldeman + * Time and date fixes, Ctrl-S/P, findfirst/next, FCBs, buffers, tsr unloading + * * Revision 1.3 2001/07/24 16:56:29 bartoldeman * fixes for FCBs, DJGPP ls, DBLBYTE, dyninit allocation (2024e). * @@ -54,6 +57,7 @@ static BYTE *buffer_hRcsId = "$Id$"; #define BUFFERSIZE 512 struct buffer { + WORD b_dummy; /* dummy self pointing word to keep MFT from crashing */ struct buffer FAR *b_next; /* form linked list for LRU */ BYTE b_unit; /* disk for this buffer */ diff --git a/hdr/fnode.h b/hdr/fnode.h index ff56de33..525c55b0 100644 --- a/hdr/fnode.h +++ b/hdr/fnode.h @@ -36,6 +36,9 @@ static BYTE *fnode_hRcsId = "$Id$"; /* * $Log$ + * Revision 1.8 2001/08/19 12:58:34 bartoldeman + * Time and date fixes, Ctrl-S/P, findfirst/next, FCBs, buffers, tsr unloading + * * Revision 1.7 2001/07/09 22:19:33 bartoldeman * LBA/FCB/FAT/SYS/Ctrl-C/ioctl fixes + memory savings * @@ -112,6 +115,7 @@ struct f_node BITS f_ddir:1; /* fnode is assigned to dir */ BITS f_dfull:1; /* directory is full */ BITS f_dremote:1; /* Remote Fake FNode */ + BITS f_ddate:1; /* date set using setdate */ } f_flags; /* file flags */ diff --git a/kernel/break.c b/kernel/break.c index 4cfb36e2..0e2d5676 100644 --- a/kernel/break.c +++ b/kernel/break.c @@ -38,6 +38,9 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.6 2001/08/19 12:58:36 bartoldeman + * Time and date fixes, Ctrl-S/P, findfirst/next, FCBs, buffers, tsr unloading + * * Revision 1.5 2001/04/15 03:21:50 bartoldeman * See history.txt for the list of fixes. * @@ -87,6 +90,7 @@ int control_break(void) */ void handle_break(void) { + mod_cso(CTL_C); CB_FLG &= ~CB_MSK; /* reset the ^Break flag */ KbdFlush(); /* Er, this is con_flush() */ if (!ErrorMode) /* within int21_handler, InDOS is not incremented */ diff --git a/kernel/chario.c b/kernel/chario.c index 337a271c..dd84f575 100644 --- a/kernel/chario.c +++ b/kernel/chario.c @@ -36,6 +36,9 @@ static BYTE *charioRcsId = "$Id$"; /* * $Log$ + * Revision 1.11 2001/08/19 12:58:36 bartoldeman + * Time and date fixes, Ctrl-S/P, findfirst/next, FCBs, buffers, tsr unloading + * * Revision 1.10 2001/07/23 12:47:42 bartoldeman * FCB fixes and clean-ups, exec int21/ax=4b01, initdisk.c printf * @@ -168,7 +171,7 @@ struct dhdr FAR *finddev(UWORD attr_mask) } #endif -VOID cso(COUNT c) +VOID _cso(COUNT c) { if (syscon->dh_attr & ATTR_FASTCON) { _AL = c; @@ -185,13 +188,40 @@ VOID cso(COUNT c) char_error(&CharReqHdr, syscon); } +VOID cso(COUNT c) +{ + /* Test for hold char */ + con_hold(); + + if (PrinterEcho) + DosWrite(STDPRN, 1, (BYTE FAR *) & c, (COUNT FAR *) &UnusedRetVal); + + switch (c) + { + case CR: + scr_pos = 0; + break; + case LF: + case BELL: + break; + case BS: + if (scr_pos > 0) scr_pos--; + break; + case HT: + do _cso(' '); while ((++scr_pos) & 7); + break; + default: + scr_pos++; + } + if (c != HT) _cso(c); +} VOID sto(COUNT c) { DosWrite(STDOUT, 1, (BYTE FAR *) & c, (COUNT FAR *) &UnusedRetVal); } -VOID mod_sto(REG UCOUNT c) +VOID mod_cso(REG UCOUNT c) { if (c < ' ' && c != HT) { @@ -223,13 +253,59 @@ VOID Do_DosIdle_loop(void) } } -UCOUNT _sti(void) +COUNT ndread(void) +{ + CharReqHdr.r_unit = 0; + CharReqHdr.r_status = 0; + CharReqHdr.r_command = C_NDREAD; + CharReqHdr.r_length = sizeof(request); + execrh((request FAR *) & CharReqHdr, syscon); + if (CharReqHdr.r_status & S_BUSY) + return -1; + return CharReqHdr.r_ndbyte; +} + +COUNT con_read(void) +{ + BYTE c; + + CharReqHdr.r_length = sizeof(request); + CharReqHdr.r_command = C_INPUT; + CharReqHdr.r_count = 1; + CharReqHdr.r_trans = (BYTE FAR *)&c; + CharReqHdr.r_status = 0; + execrh((request FAR *) & CharReqHdr, syscon); + if (CharReqHdr.r_status & S_ERROR) + char_error(&CharReqHdr, syscon); + if (c == CTL_C) + handle_break(); + return c; +} + +VOID con_hold(void) +{ + UBYTE c = ndread(); + if(c == CTL_S) + { + con_read(); + Do_DosIdle_loop(); + /* just wait */ + c = con_read(); + } + if (c == CTL_C) + handle_break(); +} + +UCOUNT _sti(BOOL check_break) { UBYTE c; /* * XXX: If there's a read error, this will just keep retrying the read until * the error disappears. Maybe it should do something else instead. -- ror4 */ + Do_DosIdle_loop(); + if (check_break) + con_hold(); while (GenericRead(STDIN, 1, (BYTE FAR *) & c, (COUNT FAR *) & UnusedRetVal, TRUE) != 1) ; return c; @@ -237,16 +313,9 @@ UCOUNT _sti(void) BOOL con_break(void) { - CharReqHdr.r_unit = 0; - CharReqHdr.r_status = 0; - CharReqHdr.r_command = C_NDREAD; - CharReqHdr.r_length = sizeof(request); - execrh((request FAR *) & CharReqHdr, syscon); - if (CharReqHdr.r_status & S_BUSY) - return FALSE; - if (CharReqHdr.r_ndbyte == CTL_C) + if (ndread() == CTL_C) { - _sti(); + con_read(); return TRUE; } else @@ -296,7 +365,7 @@ static VOID kbfill(keyboard FAR * kp, UCOUNT c, BOOL ctlf, UWORD * vp) kp->kb_buf[kp->kb_count++] = c; if (!ctlf) { - mod_sto(c); + mod_cso(c); *vp += 2; } else @@ -310,13 +379,13 @@ static VOID kbfill(keyboard FAR * kp, UCOUNT c, BOOL ctlf, UWORD * vp) } /* return number of characters before EOF if there is one, else just the total */ -UCOUNT sti(keyboard FAR * kp) +UCOUNT sti_0a(keyboard FAR * kp) { REG UWORD c, cu_pos = scr_pos; UWORD virt_pos = scr_pos; - WORD init_count = kp->kb_count; + UWORD init_count = 0; /* kp->kb_count; */ BOOL eof = FALSE; #ifndef NOSPCL static BYTE local_buffer[LINESIZE]; @@ -324,14 +393,11 @@ UCOUNT sti(keyboard FAR * kp) if (kp->kb_size == 0) return eof; - if (kp->kb_size <= kp->kb_count || kp->kb_buf[kp->kb_count] != CR) - kp->kb_count = 0; + /* if (kp->kb_size <= kp->kb_count || kp->kb_buf[kp->kb_count] != CR) */ + kp->kb_count = 0; FOREVER { - - Do_DosIdle_loop(); - - switch (c = _sti()) + switch (c = _sti(TRUE)) { case CTL_C: handle_break(); @@ -340,7 +406,7 @@ UCOUNT sti(keyboard FAR * kp) #ifndef NOSPCL case SPCL: - switch (c = _sti()) + switch (c = _sti(TRUE)) { case LEFT: goto backspace; @@ -405,8 +471,8 @@ UCOUNT sti(keyboard FAR * kp) if (eof) return eof; else - return kp->kb_count; - + return kp->kb_count--; + case LF: break; @@ -429,3 +495,17 @@ UCOUNT sti(keyboard FAR * kp) } } } + +UCOUNT sti(keyboard * kp) +{ + UCOUNT ReadCount = sti_0a(kp); + kp->kb_count++; + + if (ReadCount >= kp->kb_count && kp->kb_count < kp->kb_size) + { + kp->kb_buf[kp->kb_count++] = LF; + cso(LF); + ReadCount++; + } + return ReadCount; +} diff --git a/kernel/config.c b/kernel/config.c index 8ba76aa9..16db0666 100644 --- a/kernel/config.c +++ b/kernel/config.c @@ -75,7 +75,8 @@ extern BYTE FAR VgaSet, extern UWORD FAR ram_top, /* How much ram in Kbytes */ FAR UMB_top, FAR umb_start, - FAR uppermem_root; + FAR uppermem_root, + FAR LoL_nbuffers; #ifdef VERSION_STRINGS static BYTE *RcsId = "$Id$"; @@ -89,6 +90,9 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.27 2001/08/19 12:58:36 bartoldeman + * Time and date fixes, Ctrl-S/P, findfirst/next, FCBs, buffers, tsr unloading + * * Revision 1.26 2001/07/28 18:13:06 bartoldeman * Fixes for FORMAT+SYS, FATFS, get current dir, kernel init memory situation. * @@ -1566,6 +1570,7 @@ VOID config_init_buffers(COUNT anzBuffers) printf("BUFFERS=%u not supported, reducing to 99\n",anzBuffers); anzBuffers = 99; } + LoL_nbuffers = anzBuffers; lpTop = lpOldTop; @@ -1581,7 +1586,8 @@ VOID config_init_buffers(COUNT anzBuffers) if (FP_SEG(pbuffer) == 0xffff) HMAcount++; lastbuf = pbuffer; - + + pbuffer->b_dummy = FP_OFF(pbuffer); pbuffer->b_unit = 0; pbuffer->b_flag = 0; pbuffer->b_blkno = 0; diff --git a/kernel/dosfns.c b/kernel/dosfns.c index 083daa0c..ef864c63 100644 --- a/kernel/dosfns.c +++ b/kernel/dosfns.c @@ -37,6 +37,9 @@ static BYTE *dosfnsRcsId = "$Id$"; * /// Added SHARE support. 2000/09/04 Ron Cemer * * $Log$ + * Revision 1.24 2001/08/19 12:58:36 bartoldeman + * Time and date fixes, Ctrl-S/P, findfirst/next, FCBs, buffers, tsr unloading + * * Revision 1.23 2001/07/28 18:13:06 bartoldeman * Fixes for FORMAT+SYS, FATFS, get current dir, kernel init memory situation. * @@ -374,22 +377,16 @@ UCOUNT GenericRead(COUNT hndl, UCOUNT n, BYTE FAR * bp, COUNT FAR * err, else if (s->sft_flags & SFT_FCONIN) { kb_buf.kb_size = LINESIZE - 1; - kb_buf.kb_count = 0; - ReadCount = sti((keyboard FAR *) & kb_buf); + ReadCount = sti(&kb_buf); if (ReadCount < kb_buf.kb_count) s->sft_flags &= ~SFT_FEOF; - else if (kb_buf.kb_count < kb_buf.kb_size) { - kb_buf.kb_buf[kb_buf.kb_count++] = LF; - cso(LF); - ReadCount++; - } fbcopy((BYTE FAR *) kb_buf.kb_buf, bp, kb_buf.kb_count); *err = SUCCESS; return ReadCount; } else { - *bp = _sti(); + *bp = _sti(FALSE); *err = SUCCESS; return 1; } @@ -529,25 +526,8 @@ UCOUNT DosWrite(COUNT hndl, UCOUNT n, BYTE FAR * bp, COUNT FAR * err) while(cnt-- != 0 && *bp != CTL_Z){ if (s->sft_flags & SFT_FCONOUT) - { - switch (*bp) - { - case CR: - scr_pos = 0; - break; - case LF: - case BELL: - break; - case BS: - scr_pos = scr_pos ? scr_pos - 1 : 0; - break; - case HT: - do cso(' '); while ((++scr_pos) & 7); - break; - default: - scr_pos++; - } - if (*bp != HT) cso(*bp); + { + cso(*bp); } else { @@ -562,7 +542,7 @@ UCOUNT DosWrite(COUNT hndl, UCOUNT n, BYTE FAR * bp, COUNT FAR * err) } ++bp; ++xfer; - if (break_ena && control_break()) + if (control_break()) { handle_break(); break; @@ -1406,7 +1386,7 @@ COUNT DosGetFtime(COUNT hndl, date FAR * dp, time FAR * tp) return dos_getftime(s->sft_status, dp, tp); } -COUNT DosSetFtimeSft(WORD sft_idx, date FAR * dp, time FAR * tp) +COUNT DosSetFtimeSft(WORD sft_idx, date dp, time tp) { /* Get the SFT block that contains the SFT */ sft FAR *s = idx_to_sft(sft_idx); @@ -1422,12 +1402,12 @@ COUNT DosSetFtimeSft(WORD sft_idx, date FAR * dp, time FAR * tp) if (s->sft_flags & SFT_FDEVICE) return SUCCESS; + s->sft_flags |= SFT_FDATE; + s->sft_date = dp; + s->sft_time = tp; + if (s->sft_flags & SFT_FSHARED) - { - s->sft_date = *dp; - s->sft_time = *tp; return SUCCESS; - } /* call file system handler */ return dos_setftime(s->sft_status, dp, tp); diff --git a/kernel/fatdir.c b/kernel/fatdir.c index 9e661a53..c3fe2d97 100644 --- a/kernel/fatdir.c +++ b/kernel/fatdir.c @@ -36,6 +36,9 @@ static BYTE *fatdirRcsId = "$Id$"; /* * $Log$ + * Revision 1.22 2001/08/19 12:58:36 bartoldeman + * Time and date fixes, Ctrl-S/P, findfirst/next, FCBs, buffers, tsr unloading + * * Revision 1.21 2001/07/28 18:13:06 bartoldeman * Fixes for FORMAT+SYS, FATFS, get current dir, kernel init memory situation. * @@ -655,7 +658,7 @@ COUNT dos_findfirst(UCOUNT attr, BYTE *name) /* directory and only searched for once. So we need to open */ /* the root and return only the first entry that contains the */ /* volume id bit set. */ - if (attr & D_VOLID) + if (attr == D_VOLID) { szDirName[2] = '\\'; szDirName[3] = '\0'; @@ -679,7 +682,7 @@ COUNT dos_findfirst(UCOUNT attr, BYTE *name) fbcopy((BYTE FAR *) SearchDir.dir_name, dmp->dm_name_pat, FNAME_SIZE + FEXT_SIZE); - if (attr & D_VOLID) + if (attr == D_VOLID) { /* Now do the search */ while (dir_read(fnp) == DIRENT_SIZE) @@ -799,7 +802,8 @@ COUNT dos_findnext(void) */ /* Test the attribute as the final step */ - if (!(~dmp->dm_attr_srch & (fnp->f_dir.dir_attrib & ~(D_RDONLY|D_ARCHIVE)))) + if (!(fnp->f_dir.dir_attrib & D_VOLID) && + ((~dmp->dm_attr_srch & fnp->f_dir.dir_attrib & (D_DIR | D_SYSTEM | D_HIDDEN)) == 0)) { found = TRUE; break; diff --git a/kernel/fatfs.c b/kernel/fatfs.c index 7284881e..66ab7459 100644 --- a/kernel/fatfs.c +++ b/kernel/fatfs.c @@ -47,6 +47,9 @@ BYTE *RcsId = "$Id$"; * performance killer on large drives. (~0.5 sec /dos_mkdir) TE * * $Log$ + * Revision 1.23 2001/08/19 12:58:36 bartoldeman + * Time and date fixes, Ctrl-S/P, findfirst/next, FCBs, buffers, tsr unloading + * * Revision 1.22 2001/07/28 18:13:06 bartoldeman * Fixes for FORMAT+SYS, FATFS, get current dir, kernel init memory situation. * @@ -368,11 +371,14 @@ COUNT dos_close(COUNT fd) if (fnp == (f_node_ptr)0 || fnp->f_count <= 0) return DE_INVLDHNDL; - if (fnp->f_mode != RDONLY && fnp->f_flags.f_dmod) + if (fnp->f_flags.f_dmod) { fnp->f_dir.dir_attrib |= D_ARCHIVE; - fnp->f_dir.dir_time = dos_gettime(); - fnp->f_dir.dir_date = dos_getdate(); + if (fnp->f_flags.f_ddate == FALSE) + { + fnp->f_dir.dir_time = dos_gettime(); + fnp->f_dir.dir_date = dos_getdate(); + } shrink_file(fnp); /* reduce allocated filesize in FAT */ fnp->f_dir.dir_size = fnp->f_highwater; @@ -631,6 +637,7 @@ COUNT dos_creat(BYTE * path, COUNT attrib) fnp->f_dir.dir_date = dos_getdate(); fnp->f_flags.f_dmod = TRUE; + fnp->f_flags.f_ddate = FALSE; fnp->f_flags.f_dnew = FALSE; fnp->f_flags.f_ddir = TRUE; if (dir_write(fnp) != DIRENT_SIZE) @@ -647,6 +654,7 @@ COUNT dos_creat(BYTE * path, COUNT attrib) fnp->f_cluster = fnp->f_dir.dir_start = FREE; fnp->f_cluster_offset = 0l; /*JPP */ fnp->f_flags.f_dmod = TRUE; + fnp->f_flags.f_ddate = FALSE; fnp->f_flags.f_dnew = FALSE; fnp->f_flags.f_ddir = FALSE; @@ -1037,7 +1045,7 @@ COUNT dos_getftime(COUNT fd, date FAR * dp, time FAR * tp) /* */ /* dos_setftime for the file time */ /* */ -COUNT dos_setftime(COUNT fd, date FAR * dp, time FAR * tp) +COUNT dos_setftime(COUNT fd, date dp, time tp) { f_node_ptr fnp; @@ -1052,8 +1060,10 @@ COUNT dos_setftime(COUNT fd, date FAR * dp, time FAR * tp) return DE_INVLDHNDL; /* Set the date and time from the fnode and return */ - fnp->f_dir.dir_date = *dp; - fnp->f_dir.dir_time = *tp; + fnp->f_dir.dir_date = dp; + fnp->f_dir.dir_time = tp; + fnp->f_flags.f_dmod = TRUE; /* mark file as modified */ + fnp->f_flags.f_ddate = TRUE; /* set this date upon closing */ return SUCCESS; } @@ -1770,6 +1780,7 @@ UCOUNT writeblock(COUNT fd, VOID FAR * buffer, UCOUNT count, COUNT * err) } fnp->f_flags.f_dmod = TRUE; /* mark file as modified */ + fnp->f_flags.f_ddate = FALSE; /* set date not valid any more */ /* Test that we are really about to do a data transfer. If the */ @@ -2245,6 +2256,7 @@ COUNT dos_setfattr(BYTE * name, UWORD attrp) /* set attributes that user requested */ fnp->f_dir.dir_attrib |= attrp; /* JPP */ fnp->f_flags.f_dmod = TRUE; + fnp->f_flags.f_ddate = TRUE; dos_close(fd); return SUCCESS; } diff --git a/kernel/fcbfns.c b/kernel/fcbfns.c index 6c9f5f92..29820f6e 100644 --- a/kernel/fcbfns.c +++ b/kernel/fcbfns.c @@ -35,6 +35,9 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.16 2001/08/19 12:58:36 bartoldeman + * Time and date fixes, Ctrl-S/P, findfirst/next, FCBs, buffers, tsr unloading + * * Revision 1.15 2001/07/24 16:56:29 bartoldeman * fixes for FCBs, DJGPP ls, DBLBYTE, dyninit allocation (2024e). * @@ -884,6 +887,10 @@ BOOL FcbClose(xfcb FAR * lpXfcb) /* Convert to fcb if necessary */ lpFcb = ExtFcbToFcb(lpXfcb); + /* An already closed FCB can be closed again without error */ + if (lpFcb->fcb_sftno == (BYTE)0xff) + return TRUE; + /* Get the SFT block that contains the SFT */ if ((s = idx_to_sft(lpFcb->fcb_sftno)) == (sft FAR *) - 1) return FALSE; @@ -892,8 +899,12 @@ BOOL FcbClose(xfcb FAR * lpXfcb) s->sft_size = lpFcb->fcb_fsize; if (!(s->sft_flags & SFT_FSHARED)) dos_setfsize(s->sft_status, lpFcb->fcb_fsize); - DosSetFtimeSft(lpFcb->fcb_sftno, (date FAR *) &lpFcb->fcb_date, (time FAR *) &lpFcb->fcb_time); - return DosCloseSft(lpFcb->fcb_sftno) == SUCCESS; + DosSetFtimeSft(lpFcb->fcb_sftno, lpFcb->fcb_date, lpFcb->fcb_time); + if (DosCloseSft(lpFcb->fcb_sftno) == SUCCESS) { + lpFcb->fcb_sftno = (BYTE)0xff; + return TRUE; + } + return FALSE; } /* close all files opened by FCBs diff --git a/kernel/globals.h b/kernel/globals.h index e0d1b9fc..cf33fde5 100644 --- a/kernel/globals.h +++ b/kernel/globals.h @@ -36,6 +36,9 @@ static BYTE *Globals_hRcsId = "$Id$"; /* * $Log$ + * Revision 1.16 2001/08/19 12:58:36 bartoldeman + * Time and date fixes, Ctrl-S/P, findfirst/next, FCBs, buffers, tsr unloading + * * Revision 1.15 2001/07/22 01:58:58 bartoldeman * Support for Brian's FORMAT, DJGPP libc compilation, cleanups, MSCDEX * @@ -263,6 +266,7 @@ static BYTE *Globals_hRcsId = "$Id$"; #define HT 0x09 #define LF 0x0a #define CR 0x0d +#define CTL_P 0x10 #define CTL_Q 0x11 #define CTL_S 0x13 #define CTL_Z 0x1a @@ -443,7 +447,12 @@ extern WORD extern UBYTE nblkdev, /* number of block devices */ lastdrive, /* value of last drive */ - uppermem_link; /* UMB Link flag */ + uppermem_link, /* UMB Link flag */ + PrinterEcho; /* Printer Echo Flag */ + +extern UWORD + LoL_nbuffers; /* Number of buffers */ + extern struct dhdr nul_dev; extern UBYTE diff --git a/kernel/inithma.c b/kernel/inithma.c index 9bba26e8..a3441ba3 100644 --- a/kernel/inithma.c +++ b/kernel/inithma.c @@ -81,6 +81,9 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.9 2001/08/19 12:58:36 bartoldeman + * Time and date fixes, Ctrl-S/P, findfirst/next, FCBs, buffers, tsr unloading + * * Revision 1.8 2001/07/28 18:13:06 bartoldeman * Fixes for FORMAT+SYS, FATFS, get current dir, kernel init memory situation. * @@ -407,7 +410,8 @@ VOID FAR *HMAalloc(COUNT bytesToAllocate) HMAptr = MK_FP(0xffff, HMAFree); - HMAFree += bytesToAllocate; + /* align on 16 byte boundary */ + HMAFree = (HMAFree + bytesToAllocate + 0xf) & 0xfff0; /*printf("HMA allocated %d byte at %x\n", bytesToAllocate, HMAptr); */ diff --git a/kernel/int2f.asm b/kernel/int2f.asm index 7545b906..43cb5d41 100644 --- a/kernel/int2f.asm +++ b/kernel/int2f.asm @@ -30,6 +30,9 @@ ; $Id$ ; ; $Log$ +; Revision 1.12 2001/08/19 12:58:36 bartoldeman +; Time and date fixes, Ctrl-S/P, findfirst/next, FCBs, buffers, tsr unloading +; ; Revision 1.11 2001/07/28 18:13:06 bartoldeman ; Fixes for FORMAT+SYS, FATFS, get current dir, kernel init memory situation. ; @@ -154,34 +157,155 @@ Int2f?14?1: or BYTE [bp-6], 1 Int2f?iret: iret + +FarTabRetnBX: pop bx + jmp FarTabRetn ; ;return dos data seg. IntDosCal: - cmp al,03 - jne IntDosCal_1 + cmp al, 31h + ja FarTabRetn + push bx + mov bl, al + mov bh, 0 + shl bx, 1 + jmp [cs:bx+DosCalTbl] + +DosCalTbl: +dw retff, IntDosCal_1, IntDosCal_2, IntDosCal_3, IntDosCal_4, IntDosCal_5, +dw IntDosCal_6, IntDosCal_7, IntDosCal_8, IntDosCal_9, IntDosCal_a, +dw IntDosCal_b, IntDosCal_c, IntDosCal_d, IntDosCal_e, IntDosCal_f, +dw IntDosCal_10, IntDosCal_11, IntDosCal_12, IntDosCal_13, IntDosCal_14, +dw IntDosCal_15, IntDosCal_16, IntDosCal_17, IntDosCal_18, IntDosCal_19, +dw IntDosCal_1a, IntDosCal_1b, IntDosCal_1c, IntDosCal_1d, IntDosCal_1e, +dw IntDosCal_1f, IntDosCal_20, IntDosCal_21, IntDosCal_22, IntDosCal_23, +dw IntDosCal_24, IntDosCal_25, IntDosCal_26, IntDosCal_27, IntDosCal_28, +dw IntDosCal_29, IntDosCal_2a, IntDosCal_2b, IntDosCal_2c, IntDosCal_2d, +dw IntDosCal_2e, IntDosCal_2f, IntDosCal_30, IntDosCal_31 + +retff: mov al,0ffh + jmp FarTabRetnBX + +IntDosCal_3: push ax mov ax, seg _nul_dev mov ds,ax pop ax clc - jmp FarTabRetn + jmp FarTabRetnBX + +IntDosCal_8: + ; decrease SFT reference count + dec word [es:di] + jnz .skip + dec word [es:di] +.skip: + jmp FarTabRetnBX + +IntDosCal_1: +IntDosCal_2: +IntDosCal_4: +IntDosCal_5: +IntDosCal_6: +IntDosCal_7: +IntDosCal_9: +IntDosCal_a: +IntDosCal_b: +IntDosCal_c: +IntDosCal_d: +IntDosCal_e: +IntDosCal_f: +IntDosCal_10: +IntDosCal_11: +IntDosCal_13: +IntDosCal_14: +IntDosCal_15: +IntDosCal_16: +IntDosCal_17: +IntDosCal_19: +IntDosCal_1a: +IntDosCal_1c: +IntDosCal_1d: +IntDosCal_1e: +IntDosCal_1f: +IntDosCal_20: +IntDosCal_22: +IntDosCal_23: +IntDosCal_24: +IntDosCal_26: +IntDosCal_27: +IntDosCal_28: +IntDosCal_29: +IntDosCal_2b: +IntDosCal_2d: +IntDosCal_2e: +IntDosCal_2f: +IntDosCal_30: +IntDosCal_31: + jmp FarTabRetnBX + +; get length of asciiz string +IntDosCal_12: + push di + push es + extern _fstrlen + call _fstrlen + add sp, byte 4 + mov cx, ax + inc cx + jmp FarTabRetnBX + +; get caller's registers +IntDosCal_18: + extern _user_r + lds si, [_user_r] + jmp FarTabRetnBX + +; #days in February - valid until 2099. +IntDosCal_1b: + mov al, 28 + test cl, 3 + jnz .noleap + inc al +.noleap: jmp FarTabRetnBX + +; truename +IntDosCal_21: + xor bx, bx + push bx + push es + push di + push ds + push si + extern _truename + call _truename + add sp, byte 10 + jmp FarTabRetnBX + +; get length of asciiz string +IntDosCal_25: + push si + push ds + call _fstrlen + add sp, byte 4 + mov cx, ax + inc cx + jmp FarTabRetnBX + ; ;Set FastOpen but does nothing. -IntDosCal_1: - cmp al,02ah - jne IntDosCal_2 +IntDosCal_2a: clc jmp FarTabRetn ; ; added by James Tabor For Zip Drives ;Return Null Device Pointer -IntDosCal_2: - cmp al,02ch - jne Int2f2 +IntDosCal_2c: mov ax,_nul_dev mov bx,seg _nul_dev clc jmp FarTabRetn + ; Int 2F Multipurpose Remote System Calls ; diff --git a/kernel/inthndlr.c b/kernel/inthndlr.c index 978f3300..d0167929 100644 --- a/kernel/inthndlr.c +++ b/kernel/inthndlr.c @@ -37,6 +37,9 @@ BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.30 2001/08/19 12:58:36 bartoldeman + * Time and date fixes, Ctrl-S/P, findfirst/next, FCBs, buffers, tsr unloading + * * Revision 1.29 2001/07/28 18:13:06 bartoldeman * Fixes for FORMAT+SYS, FATFS, get current dir, kernel init memory situation. * @@ -429,8 +432,7 @@ VOID int21_service(iregs FAR * r) /* Read Keyboard with Echo */ case 0x01: - Do_DosIdle_loop(); - r->AL = _sti(); + r->AL = _sti(TRUE); sto(r->AL); break; @@ -474,16 +476,18 @@ VOID int21_service(iregs FAR * r) else { r->FLAGS &= ~FLG_ZERO; - r->AL = _sti(); + r->AL = _sti(FALSE); } break; /* Direct Console Input */ case 0x07: + r->AL = _sti(FALSE); + break; + /* Read Keyboard Without Echo */ case 0x08: - Do_DosIdle_loop(); - r->AL = _sti(); + r->AL = _sti(TRUE); break; /* Display String */ @@ -500,9 +504,7 @@ VOID int21_service(iregs FAR * r) /* Buffered Keyboard Input */ case 0x0a: - ((keyboard FAR *) FP_DS_DX)->kb_count = 0; - sti((keyboard FAR *) FP_DS_DX); - ((keyboard FAR *) FP_DS_DX)->kb_count --; + sti_0a((keyboard FAR *) FP_DS_DX); break; /* Check Stdin Status */ @@ -1294,8 +1296,8 @@ VOID int21_service(iregs FAR * r) case 0x01: rc = DosSetFtime( (COUNT) r->BX, /* Handle */ - (date FAR *) & r->DX, /* FileDate */ - (time FAR *) & r->CX); /* FileTime */ + (date) r->DX, /* FileDate */ + (time) r->CX); /* FileTime */ if (rc < SUCCESS) goto error_exit; break; diff --git a/kernel/kernel.asm b/kernel/kernel.asm index 94525f77..ca74ba59 100644 --- a/kernel/kernel.asm +++ b/kernel/kernel.asm @@ -28,6 +28,9 @@ ; $Id$ ; ; $Log$ +; Revision 1.17 2001/08/19 12:58:36 bartoldeman +; Time and date fixes, Ctrl-S/P, findfirst/next, FCBs, buffers, tsr unloading +; ; Revision 1.16 2001/07/28 18:13:06 bartoldeman ; Fixes for FORMAT+SYS, FATFS, get current dir, kernel init memory situation. ; @@ -326,8 +329,8 @@ _clock dd 0 ; 0008 CLOCK$ device _syscon dd 0 ; 000c console device global _maxbksize _maxbksize dw 512 ; 0010 maximum bytes/sector of any block device - global _firstbuf; -_firstbuf dd 0 ; 0012 head of buffers linked list + dw buf_info ; 0012 pointer to buffers info structure + dw seg buf_info global _CDSp _CDSp dd 0 ; 0016 Current Directory Structure global _FCBp @@ -353,13 +356,16 @@ _njoined db 0 ; 0034 number of joined devices setverPtr dw 0,0 ; 0037 setver list dw 0 ; 003B cs offset for fix a20 dw 0 ; 003D psp of last umb exec - dw 1 ; 003F number of buffers + global _LoL_nbuffers +_LoL_nbuffers dw 1 ; 003F number of buffers dw 1 ; 0041 size of pre-read buffer global _BootDrive _BootDrive db 1 ; 0043 drive we booted from db 0 ; 0044 cpu type (1 if >=386) dw 0 ; 0045 Extended memory in KBytes -buf_info dd 0 ; 0047 disk buffer chain +buf_info: + global _firstbuf +_firstbuf dd 0 ; 0047 disk buffer chain dw 0 ; 004B 0 (DOS 4 = # hashing chains) dd 0 ; 004D pre-read buffer dw 0 ; 0051 # of sectors diff --git a/kernel/proto.h b/kernel/proto.h index 1e3f9152..3631c907 100644 --- a/kernel/proto.h +++ b/kernel/proto.h @@ -34,6 +34,9 @@ static BYTE *Proto_hRcsId = "$Id$"; /* * $Log$ + * Revision 1.21 2001/08/19 12:58:36 bartoldeman + * Time and date fixes, Ctrl-S/P, findfirst/next, FCBs, buffers, tsr unloading + * * Revision 1.20 2001/07/24 16:56:29 bartoldeman * fixes for FCBs, DJGPP ls, DBLBYTE, dyninit allocation (2024e). * @@ -199,17 +202,18 @@ UWORD dskxfer(COUNT dsk, ULONG blkno, VOID FAR * buf, UWORD numblocks, COUNT mod /* *** End of change /* chario.c */ -VOID cso(COUNT c); VOID sto(COUNT c); -VOID mod_sto(REG UCOUNT c); +VOID cso(COUNT c); +VOID mod_cso(REG UCOUNT c); VOID destr_bs(void); -UCOUNT _sti(void); +UCOUNT _sti(BOOL check_break); VOID con_hold(void); BOOL con_break(void); BOOL StdinBusy(void); VOID KbdFlush(void); VOID Do_DosIdle_loop(void); -UCOUNT sti(keyboard FAR * kp); +UCOUNT sti_0a(keyboard FAR * kp); +UCOUNT sti(keyboard * kp); sft FAR *get_sft(UCOUNT); @@ -239,7 +243,7 @@ COUNT DosChangeDir(BYTE FAR * s); COUNT DosFindFirst(UCOUNT attr, BYTE FAR * name); COUNT DosFindNext(void); COUNT DosGetFtime(COUNT hndl, date FAR * dp, time FAR * tp); -COUNT DosSetFtimeSft(WORD sft_idx, date FAR * dp, time FAR * tp); +COUNT DosSetFtimeSft(WORD sft_idx, date dp, time tp); #define DosSetFtime(hndl, dp, tp) DosSetFtimeSft(get_sft_idx(hndl), (dp), (tp)) COUNT DosGetFattr(BYTE FAR * name); COUNT DosSetFattr(BYTE FAR * name, UWORD attrp); @@ -296,7 +300,7 @@ COUNT dos_rename(BYTE * path1, BYTE * path2); date dos_getdate(void); time dos_gettime(void); COUNT dos_getftime(COUNT fd, date FAR * dp, time FAR * tp); -COUNT dos_setftime(COUNT fd, date FAR * dp, time FAR * tp); +COUNT dos_setftime(COUNT fd, date dp, time tp); LONG dos_getcufsize(COUNT fd); LONG dos_getfsize(COUNT fd); BOOL dos_setfsize(COUNT fd, LONG size); @@ -478,8 +482,8 @@ COUNT DosSetTime(BYTE FAR * hp, BYTE FAR * mp, BYTE FAR * sp, BYTE FAR * hdp); VOID DosGetDate(BYTE FAR * wdp, BYTE FAR * mp, BYTE FAR * mdp, COUNT FAR * yp); COUNT DosSetDate(BYTE FAR * mp, BYTE FAR * mdp, COUNT FAR * yp); -WORD *is_leap_year_monthdays(int year); -WORD DaysFromYearMonthDay(WORD Year, WORD Month, WORD DayOfMonth); +UWORD *is_leap_year_monthdays(UWORD year); +UWORD DaysFromYearMonthDay(UWORD Year, UWORD Month, UWORD DayOfMonth); diff --git a/kernel/sysclk.c b/kernel/sysclk.c index 9dddce54..5fd37077 100644 --- a/kernel/sysclk.c +++ b/kernel/sysclk.c @@ -35,6 +35,9 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.8 2001/08/19 12:58:36 bartoldeman + * Time and date fixes, Ctrl-S/P, findfirst/next, FCBs, buffers, tsr unloading + * * Revision 1.7 2001/07/22 01:58:58 bartoldeman * Support for Brian's FORMAT, DJGPP libc compilation, cleanups, MSCDEX * @@ -119,7 +122,7 @@ VOID DayToBcd(); /* */ /* WARNING - THIS DRIVER IS NON-PORTABLE!!!! */ /* */ -extern WORD days[2][13]; /* this is defined by SYSTIME.C */ +extern UWORD days[2][13]; /* this is defined by SYSTIME.C */ static struct ClockRecord clk; @@ -135,8 +138,8 @@ static BYTE bcdHours; static BYTE bcdSeconds; static ULONG Ticks; -UWORD DaysSinceEpoch = 0; */ +UWORD DaysSinceEpoch = 0; BOOL ReadATClock(BYTE *, BYTE *, BYTE *, BYTE *); @@ -149,13 +152,12 @@ WORD FAR clk_driver(rqptr rp) { COUNT c; - WORD *pdays; + UWORD *pdays; BYTE bcd_days[4], bcd_minutes, bcd_hours, bcd_seconds; ULONG Ticks; - UWORD DaysSinceEpoch; UWORD Month, Day, Year; diff --git a/kernel/systime.c b/kernel/systime.c index 5bc13d2d..c614b7d3 100644 --- a/kernel/systime.c +++ b/kernel/systime.c @@ -37,6 +37,9 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.6 2001/08/19 12:58:36 bartoldeman + * Time and date fixes, Ctrl-S/P, findfirst/next, FCBs, buffers, tsr unloading + * * Revision 1.5 2001/04/15 03:21:50 bartoldeman * See history.txt for the list of fixes. * @@ -101,7 +104,7 @@ static BYTE *RcsId = "$Id$"; */ -WORD days[2][13] = +UWORD days[2][13] = { {0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365}, {0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366} @@ -114,7 +117,7 @@ extern request return a pointer to an array with the days for that year */ -WORD *is_leap_year_monthdays(int y) +UWORD *is_leap_year_monthdays(UWORD y) { /* this is correct in a strict mathematical sense return ((y) & 3 ? days[0] : (y) % 100 ? days[1] : (y) % 400 ? days[0] : days[1]); */ @@ -126,7 +129,7 @@ WORD *is_leap_year_monthdays(int y) return days[1]; } -WORD DaysFromYearMonthDay(WORD Year, WORD Month, WORD DayOfMonth) +UWORD DaysFromYearMonthDay(UWORD Year, UWORD Month, UWORD DayOfMonth) { if (Year < 1980) return 0; @@ -190,9 +193,9 @@ BYTE FAR *wdp, FAR * mdp; COUNT FAR *yp; { - WORD c; - WORD *pdays; - WORD Year,Month; + UWORD c; + UWORD *pdays; + UWORD Year,Month; ExecuteClockDriverRequest(C_INPUT); @@ -234,7 +237,7 @@ BYTE FAR *mp, FAR * mdp; COUNT FAR *yp; { - WORD *pdays, Month, DayOfMonth,Year; + UWORD *pdays, Month, DayOfMonth,Year; Month = *mp; DayOfMonth = *mdp; Year = *yp; diff --git a/kernel/task.c b/kernel/task.c index eeb377fb..1420480e 100644 --- a/kernel/task.c +++ b/kernel/task.c @@ -35,6 +35,9 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.17 2001/08/19 12:58:36 bartoldeman + * Time and date fixes, Ctrl-S/P, findfirst/next, FCBs, buffers, tsr unloading + * * Revision 1.16 2001/07/23 12:47:42 bartoldeman * FCB fixes and clean-ups, exec int21/ax=4b01, initdisk.c printf * @@ -352,7 +355,7 @@ VOID new_psp(psp FAR * p, int psize) /* File System parameters */ /* user stack pointer - int 21 */ - p->ps_stack = (BYTE FAR *) - 1; + p->ps_stack = q->ps_stack; /* file table - 0xff is unused */ for (i = 0; i < 20; i++) p->ps_files[i] = 0xff; From c468cb5112df511fab87f0717885ed8ec34716a1 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sun, 19 Aug 2001 13:42:25 +0000 Subject: [PATCH 088/671] Updated documentation git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@279 6ac86273-5f31-0410-b378-82cca8765d1b --- docs/history.txt | 13 +++++++++++++ hdr/version.h | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/docs/history.txt b/docs/history.txt index eeb01d2c..d70f4c0f 100644 --- a/docs/history.txt +++ b/docs/history.txt @@ -1,3 +1,16 @@ +2001 Aug 19 - Build 2024/g +-------- Bart Oldeman (bart.oldeman@bristol.ac.uk) ++ fixes Bart + * set file time fixes + * clock fixes + * findfirst/next fixes + * added a bit more int2f/ax=12xx functionality + * buffers trick to fool MFT so that it does not crash + * Ctrl-S (pause) and Ctrl-P (printer echo) now work. + Ctrl-Q is ignored by DOS. + * FCB "closing twice is legal" fix. Necessary for visicalc. ++ fixes Bart + Tom + * fixed shsucdx /u unloading problem 2001 Jul 28 - Build 2024/f -------- Bart Oldeman (bart.oldeman@bristol.ac.uk) + fixes Bart diff --git a/hdr/version.h b/hdr/version.h index 8ce45def..8e5a8a17 100644 --- a/hdr/version.h +++ b/hdr/version.h @@ -44,4 +44,4 @@ static BYTE *date_hRcsId = "$Id$"; #define REVISION_MINOR 1 #define REVISION_SEQ 24 #define BUILD 2024 -#define SUB_BUILD "f" +#define SUB_BUILD "g" From b447c6c0be87f792a2fc870a72cfcb44e815a4f4 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Mon, 20 Aug 2001 20:32:15 +0000 Subject: [PATCH 089/671] Truename, get free space and ctrl-break fixes. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@280 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/chario.c | 6 ++++++ kernel/dosfns.c | 5 ++++- kernel/fcbfns.c | 5 ++++- kernel/newstuff.c | 32 +++++++++++++++++++------------- 4 files changed, 33 insertions(+), 15 deletions(-) diff --git a/kernel/chario.c b/kernel/chario.c index dd84f575..53eba670 100644 --- a/kernel/chario.c +++ b/kernel/chario.c @@ -36,6 +36,9 @@ static BYTE *charioRcsId = "$Id$"; /* * $Log$ + * Revision 1.12 2001/08/20 20:32:15 bartoldeman + * Truename, get free space and ctrl-break fixes. + * * Revision 1.11 2001/08/19 12:58:36 bartoldeman * Time and date fixes, Ctrl-S/P, findfirst/next, FCBs, buffers, tsr unloading * @@ -293,7 +296,10 @@ VOID con_hold(void) c = con_read(); } if (c == CTL_C) + { + con_read(); handle_break(); + } } UCOUNT _sti(BOOL check_break) diff --git a/kernel/dosfns.c b/kernel/dosfns.c index ef864c63..c694fc82 100644 --- a/kernel/dosfns.c +++ b/kernel/dosfns.c @@ -37,6 +37,9 @@ static BYTE *dosfnsRcsId = "$Id$"; * /// Added SHARE support. 2000/09/04 Ron Cemer * * $Log$ + * Revision 1.25 2001/08/20 20:32:15 bartoldeman + * Truename, get free space and ctrl-break fixes. + * * Revision 1.24 2001/08/19 12:58:36 bartoldeman * Time and date fixes, Ctrl-S/P, findfirst/next, FCBs, buffers, tsr unloading * @@ -1144,7 +1147,7 @@ VOID DosGetFree(UBYTE drive, COUNT FAR * spc, COUNT FAR * navc, COUNT FAR * bps, return; /* get the data vailable from dpb */ - *nc = dpbp->dpb_size; + *nc = dpbp->dpb_size - 1; *spc = dpbp->dpb_clsmask + 1; *bps = dpbp->dpb_secsize; diff --git a/kernel/fcbfns.c b/kernel/fcbfns.c index 29820f6e..cdf2b917 100644 --- a/kernel/fcbfns.c +++ b/kernel/fcbfns.c @@ -35,6 +35,9 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.17 2001/08/20 20:32:15 bartoldeman + * Truename, get free space and ctrl-break fixes. + * * Revision 1.16 2001/08/19 12:58:36 bartoldeman * Time and date fixes, Ctrl-S/P, findfirst/next, FCBs, buffers, tsr unloading * @@ -209,7 +212,7 @@ VOID FatGetDrvData(UCOUNT drive, COUNT FAR * spc, COUNT FAR * bps, } /* get the data vailable from dpb */ - *nc = dpbp->dpb_size; + *nc = dpbp->dpb_size - 1; *spc = dpbp->dpb_clsmask + 1; *bps = dpbp->dpb_secsize; diff --git a/kernel/newstuff.c b/kernel/newstuff.c index bcaa8930..f9b17417 100644 --- a/kernel/newstuff.c +++ b/kernel/newstuff.c @@ -31,6 +31,9 @@ static BYTE *mainRcsId = "$Id$"; /* * $Log$ + * Revision 1.13 2001/08/20 20:32:15 bartoldeman + * Truename, get free space and ctrl-break fixes. + * * Revision 1.12 2001/07/28 18:13:06 bartoldeman * Fixes for FORMAT+SYS, FATFS, get current dir, kernel init memory situation. * @@ -277,23 +280,13 @@ COUNT truename(char FAR * src, char FAR * dest, COUNT t) if (src[1] == ':') src += 2; -/* /// Added to adjust for filenames which begin with ".\" - The problem was manifesting itself in the inability - to run an program whose filename (without the extension) - was longer than six characters and the PATH variable - contained ".", unless you explicitly specified the full - path to the executable file. - Jun 11, 2000 - rbc */ -/* /// Changed to "while" from "if". - Ron Cemer */ - while ( (src[0] == '.') && (src[1] == '\\') ) src += 2; - /* Code repoff from dosfns.c MSD returns X:/CON for truename con. Not X:\CON */ /* check for a device */ - if ((dhp = IsDevice(src)) != NULL) + if ((*src != '.') && (*src != '\\') && (*src != '/') && ((dhp = IsDevice(src)) != NULL)) { froot = get_root(src); @@ -331,6 +324,16 @@ COUNT truename(char FAR * src, char FAR * dest, COUNT t) goto exit_tn; } + /* /// Added to adjust for filenames which begin with ".\" + * The problem was manifesting itself in the inability + * to run an program whose filename (without the extension) + * was longer than six characters and the PATH variable + * contained ".", unless you explicitly specified the full + * path to the executable file. + * Jun 11, 2000 - rbc */ + /* /// Changed to "while" from "if". - Ron Cemer */ + while ( (src[0] == '.') && (src[1] == '\\') ) src += 2; + current_ldt = &CDSp->cds_table[i]; /* Always give the redirector a chance to rewrite the filename */ @@ -495,11 +498,14 @@ COUNT truename(char FAR * src, char FAR * dest, COUNT t) && (*bufp != '/') && (*bufp != '\\') ) bufp--; - } + } else { + /* .. in root dir illegal */ + return DE_PATHNOTFND; + } } else { /* New segment. If any wildcards in previous segment(s), this is an invalid path. */ - if (gotAnyWildcards) return DE_PATHNOTFND; + if (gotAnyWildcards || src[0]=='.') return DE_PATHNOTFND; /* Append current path segment to result. */ *(bufp++) = '\\'; if (bufp >= bufend) break; From 6c5e9311a8c88bcd26c3d4134ee2fd261a39f766 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Mon, 20 Aug 2001 20:49:46 +0000 Subject: [PATCH 090/671] Version 2024h doc updates. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@281 6ac86273-5f31-0410-b378-82cca8765d1b --- docs/history.txt | 6 ++++++ hdr/version.h | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/docs/history.txt b/docs/history.txt index d70f4c0f..731cd21c 100644 --- a/docs/history.txt +++ b/docs/history.txt @@ -1,3 +1,9 @@ +2001 Aug 19 - Build 2024/h +-------- Bart Oldeman (bart.oldeman@bristol.ac.uk) ++ fixes Bart + * truename fixes (#580) + * free space fixes (#249) + * Ctrl-C/Ctrl-Break fix 2001 Aug 19 - Build 2024/g -------- Bart Oldeman (bart.oldeman@bristol.ac.uk) + fixes Bart diff --git a/hdr/version.h b/hdr/version.h index 8e5a8a17..de27c7e2 100644 --- a/hdr/version.h +++ b/hdr/version.h @@ -44,4 +44,4 @@ static BYTE *date_hRcsId = "$Id$"; #define REVISION_MINOR 1 #define REVISION_SEQ 24 #define BUILD 2024 -#define SUB_BUILD "g" +#define SUB_BUILD "h" From 048c87bbac02b5cb53335e1b5d88fd8d6ae3f663 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sun, 23 Sep 2001 20:39:44 +0000 Subject: [PATCH 091/671] FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@305 6ac86273-5f31-0410-b378-82cca8765d1b --- boot/boot.mak | 10 +- config.m | 6 + docs/history.txt | 44 +++++ drivers/floppy.asm | 8 + hdr/algnbyte.h | 13 +- hdr/buffer.h | 13 +- hdr/dcb.h | 47 ++++- hdr/device.h | 63 ++++--- hdr/dirmatch.h | 12 +- hdr/error.h | 16 +- hdr/fat.h | 40 ++++- hdr/fnode.h | 24 ++- hdr/pcb.h | 5 +- hdr/portab.h | 66 +++++-- hdr/process.h | 7 +- hdr/version.h | 8 +- kernel/asmsupt.asm | 5 +- kernel/blockio.c | 12 +- kernel/break.c | 5 +- kernel/chario.c | 18 +- kernel/config.c | 182 +++++++++++-------- kernel/dosfns.c | 138 +++++++++++++-- kernel/dosidle.asm | 12 -- kernel/dsk.c | 259 +++++++++++++++++---------- kernel/dyndata.c | 2 +- kernel/dyndata.h | 2 +- kernel/dyninit.c | 15 +- kernel/entry.asm | 36 ++-- kernel/fatdir.c | 57 +++--- kernel/fatfs.c | 301 ++++++++++++++++++++++---------- kernel/fattab.c | 215 ++++++++++++++++++----- kernel/fcbfns.c | 36 ++-- kernel/globals.h | 104 +++++------ kernel/init-mod.h | 97 +++++------ kernel/initdisk.c | 117 ++++++++----- kernel/inithma.c | 105 ++++------- kernel/initoem.c | 14 +- kernel/int2f.asm | 189 +++++--------------- kernel/inthndlr.c | 413 ++++++++++++++++++++++++++++++++++++++++---- kernel/intr.h | 2 +- kernel/io.asm | 12 ++ kernel/io.inc | 22 +++ kernel/kernel.asm | 23 ++- kernel/main.c | 138 +++++++++++---- kernel/memmgr.c | 9 + kernel/newstuff.c | 7 +- kernel/nls.c | 10 +- kernel/prf.c | 32 +++- kernel/printer.asm | 111 ++++++++++-- kernel/procsupt.asm | 21 +-- kernel/proto.h | 104 +++++++---- kernel/segs.inc | 11 +- kernel/sysclk.c | 13 +- kernel/syspack.c | 5 +- kernel/task.c | 21 ++- sys/sys.mak | 12 +- 56 files changed, 2234 insertions(+), 1035 deletions(-) diff --git a/boot/boot.mak b/boot/boot.mak index 47c515c7..c7dc2861 100644 --- a/boot/boot.mak +++ b/boot/boot.mak @@ -5,6 +5,9 @@ # # $Log$ +# Revision 1.4 2001/09/23 20:39:44 bartoldeman +# FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling +# # Revision 1.3 2000/05/25 20:56:19 jimtabor # Fixed project history # @@ -49,7 +52,7 @@ !include "..\config.mak" -production: b_fat12.bin b_fat16.bin +production: b_fat12.bin b_fat16.bin b_fat32.bin b_fat12.bin: boot.asm $(NASM) -dISFAT12 boot.asm -ob_fat12.bin @@ -57,8 +60,11 @@ b_fat12.bin: boot.asm b_fat16.bin: boot.asm $(NASM) -dISFAT16 boot.asm -ob_fat16.bin +b_fat32.bin: boot32.asm + $(NASM) boot32.asm -ob_fat32.bin + clobber: clean - $(RM) b_fat12.bin b_fat16.bin status.me + $(RM) b_fat12.bin b_fat16.bin b_fat32.bin status.me clean: $(RM) *.lst *.map *.bak *.obj diff --git a/config.m b/config.m index 13f966fd..d08787ba 100644 --- a/config.m +++ b/config.m @@ -13,6 +13,9 @@ #NASM=nasm # Give extra Turbo C compiler flags here +# such as -DDEBUG : extra DEBUG output +# -DDOSEMU : printf output goes to dosemu log +# -DWITHFAT32 : compile with FAT32 support #ALLCFLAGS=-DDEBUG @@ -59,6 +62,9 @@ # $Id$ # # $Log$ +# Revision 1.8 2001/09/23 20:39:43 bartoldeman +# FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling +# # Revision 1.7 2001/04/16 14:36:56 bartoldeman # Added ALLCFLAGS for compiler option configuration. # diff --git a/docs/history.txt b/docs/history.txt index 731cd21c..edf9fabe 100644 --- a/docs/history.txt +++ b/docs/history.txt @@ -1,3 +1,47 @@ +2001 Sep 24 - Build 2025 +-------- Bart Oldeman (bart.oldeman@bristol.ac.uk) ++ Fixes Victor + * More FAT32 fixes ++ Fixes Tom + * Printer handling + * misc INT2F/AH=12 fixes. + * misc clean-ups ++ Fixes Bart + * Added drive B: handling if only one floppy drive available + (look for play_dj() in dsk.c) + * Simplify Victor's FAT32 fixes a bit + * More printer clean-ups +2001 Sep 22 - Build 2025 (test) +-------- Bart Oldeman (bart.oldeman@bristol.ac.uk) ++ Added Victor + * FAT32 support + * Delete long file names if short file name given ++ Added Jeremy + * modified SYS so it takes optional 2nd parameter (similar to PC DOS) + where if only 1 argument is given, assume to be destination drive, + but if two arguments given, 1st is source (drive and/or path) + and second is destination drive ++ fixes Victor + * some small FCB and dsk.c fixes ++ fixes Tom + * some FAT32 issues + * many compiler portability changes (compiles with Watcom, MSC, ...) + * DosMemChange should set the PSP + * converted INT2F/AH=12 functions to C and added some - enough to + get most of the MS LAN network client working ++ fixes Bart + * some FAT32 issues + * Dos{Open,Creat}Sft drive letter issues + for CDROMs (thanks Jeremy) + * shrink_file should ALWAYS fail for directories, also with + dos_set_fattr (thanks Jeremy) + * only give warnings for slightly suspect partitions at boot + time where CHS does not match LBA. + * re-enabled copyright notice. + * some dsk.c clean-ups to avoid DIR giving the same contents for + a different floppy (get serial number/volume label did reset the + changed state). + * attribute should be 8-bit fix 2001 Aug 19 - Build 2024/h -------- Bart Oldeman (bart.oldeman@bristol.ac.uk) + fixes Bart diff --git a/drivers/floppy.asm b/drivers/floppy.asm index 7890dc27..876c77ab 100644 --- a/drivers/floppy.asm +++ b/drivers/floppy.asm @@ -30,6 +30,9 @@ ; $Id$ ; ; $Log$ +; Revision 1.8 2001/09/23 20:39:44 bartoldeman +; FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling +; ; Revision 1.7 2001/07/09 22:19:33 bartoldeman ; LBA/FCB/FAT/SYS/Ctrl-C/ioctl fixes + memory savings ; @@ -455,3 +458,8 @@ _fl_lba_ReadWrite: pop bp ret + +global _fl_readkey +_fl_readkey: xor ah, ah + int 16h + ret diff --git a/hdr/algnbyte.h b/hdr/algnbyte.h index 23dfd069..55d1c3df 100644 --- a/hdr/algnbyte.h +++ b/hdr/algnbyte.h @@ -1,11 +1,14 @@ #if defined(_MSC_VER) -#define asm __asm -#pragma pack(1) + #define asm __asm + #if _MSC_VER >= 700 + #pragma warning(disable:4103) + #endif + #pragma pack(1) #elif defined(_QC) || defined(__WATCOM__) -#pragma pack(1) + #pragma pack(1) #elif defined(__ZTC__) -#pragma ZTC align 1 + #pragma ZTC align 1 #elif defined(__TURBOC__) && (__TURBOC__ > 0x202) -#pragma option -a- + #pragma option -a- #endif diff --git a/hdr/buffer.h b/hdr/buffer.h index 2d3b6651..b7f1ec43 100644 --- a/hdr/buffer.h +++ b/hdr/buffer.h @@ -38,6 +38,9 @@ static BYTE *buffer_hRcsId = "$Id$"; /* * $Log$ + * Revision 1.5 2001/09/23 20:39:44 bartoldeman + * FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling + * * Revision 1.4 2001/08/19 12:58:34 bartoldeman * Time and date fixes, Ctrl-S/P, findfirst/next, FCBs, buffers, tsr unloading * @@ -65,17 +68,19 @@ struct buffer ULONG b_blkno; /* block for this buffer */ /* DOS-C: 0xffff for huge block numbers */ BYTE b_copies; /* number of copies to write */ - UBYTE b_offset_lo; /* span between copies (low) */ +#ifdef WITHFAT32 + ULONG b_offset; /* span between copies */ +#else + UWORD b_offset; /* span between copies */ +#endif #if 0 /*TE*/ union { - struct dpb FAR *_b_dpbp; /* pointer to DPB */ + struct dpb FAR *_b_dpbp; /* pointer to DPB */ LONG _b_huge_blkno; /* DOS-C: actual block number if >= 0xffff */ } _b; #endif - UBYTE b_offset_hi; /* DOS-C: span between copies (high) */ - UBYTE b_unused; BYTE b_buffer[BUFFERSIZE]; /* 512 byte sectors for now */ }; diff --git a/hdr/dcb.h b/hdr/dcb.h index 8caa11e7..3061a22e 100644 --- a/hdr/dcb.h +++ b/hdr/dcb.h @@ -36,6 +36,9 @@ static BYTE *clock_hRcsId = "$Id$"; /* * $Log$ + * Revision 1.5 2001/09/23 20:39:44 bartoldeman + * FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling + * * Revision 1.4 2001/04/15 03:21:50 bartoldeman * See history.txt for the list of fixes. * @@ -87,7 +90,7 @@ static BYTE *clock_hRcsId = "$Id$"; * Initial revision. */ -/* Internal drive parameter block */ +/* Internal drive parameter block */ struct dpb { BYTE dpb_unit; /* unit for error reporting */ @@ -98,9 +101,18 @@ struct dpb UWORD dpb_fatstrt; /* FAT start sector */ UBYTE dpb_fats; /* # of FAT copies */ UWORD dpb_dirents; /* # of dir entries */ +#ifdef WITHFAT32 + UWORD dpb_wdata; /* start of data area */ + UWORD dpb_wsize; /* # of clusters+1 on media */ + UWORD dpb_wfatsize; /* # of sectors / FAT */ +#else UWORD dpb_data; /* start of data area */ UWORD dpb_size; /* # of clusters+1 on media */ UWORD dpb_fatsize; /* # of sectors / FAT */ +#define dpb_wdata dpb_data +#define dpb_wsize dpb_size +#define dpb_wfatsize dpb_fatsize +#endif UWORD dpb_dirstrt; /* start sec. of root dir */ struct dhdr FAR * /* pointer to device header */ dpb_device; @@ -108,13 +120,36 @@ struct dpb BYTE dpb_flags; /* -1 = force MEDIA CHK */ struct dpb FAR * /* next dpb in chain */ dpb_next; /* -1 = end */ +#ifdef WITHFAT32 + UWORD dpb_wcluster; /* cluster # of first free */ + /* -1 if not known */ + ULONG dpb_nfreeclst; /* number of free clusters */ + /* -1 if not known */ + UWORD dpb_xflags; /* extended flags, see bpb */ + UWORD dpb_xfsinfosec; /* FS info sector number, */ + /* 0xFFFF if unknown */ + UWORD dpb_xbackupsec; /* backup boot sector number */ + /* 0xFFFF if unknown */ + ULONG dpb_data; + ULONG dpb_size; /* # of clusters+1 on media */ + ULONG dpb_fatsize; /* # of sectors / FAT */ + ULONG dpb_xrootclst; /* starting cluster of root dir */ + ULONG dpb_cluster; /* cluster # of first free */ + /* -1 if not known */ +#else UWORD dpb_cluster; /* cluster # of first free */ - /* -1 if not known */ + /* -1 if not known */ +#define dpb_wcluster dpb_cluster UWORD dpb_nfreeclst; /* number of free clusters */ - /* -1 if not known */ - + /* -1 if not known */ +#endif }; -#define UNKNCLUSTER 0x0000 /* see RBIL INT 21/AH=52 entry */ -#define UNKNCLSTFREE 0xffff /* 0xffff = unknown for DOS */ +#define UNKNCLUSTER 0x0000 /* see RBIL INT 21/AH=52 entry */ +#ifdef WITHFAT32 +#define UNKNCLSTFREE 0xffffffffl /* unknown for DOS */ +#else +#define UNKNCLSTFREE 0xffff /* unknown for DOS */ +#endif +#define UNKNCLSTFREE16 0xffff /* unknown for DOS */ diff --git a/hdr/device.h b/hdr/device.h index cd854337..f3f9eafe 100644 --- a/hdr/device.h +++ b/hdr/device.h @@ -35,6 +35,9 @@ static BYTE *device_hRcsId = "$Id$"; /* * $Log$ + * Revision 1.8 2001/09/23 20:39:44 bartoldeman + * FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling + * * Revision 1.7 2001/07/22 01:58:58 bartoldeman * Support for Brian's FORMAT, DJGPP libc compilation, cleanups, MSCDEX * @@ -229,25 +232,10 @@ struct dhdr /* */ /* Bios Parameter Block structure */ /* */ -/* The following offsets are computed as byte offsets and are based on */ -/* the struct below. The struct itself cannot be used because on some */ -/* compilers, structure alignement may be forced, throwing following */ -/* fields off (e.g. - BYTE, followed by a WORD may have a byte of fill */ -/* inserted in between; the WORD would then be at offset 2, not 1). */ -/* */ -#define BPB_NBYTE 0 -#define BPB_NSECTOR 2 -#define BPB_NRESERVED 3 -#define BPB_NFAT 5 -#define BPB_NDIRENT 6 -#define BPB_NSIZE 8 -#define BPB_MDESC 10 -#define BPB_NFSECT 11 -#define BPB_NSECS 13 -#define BPB_NHEADS 15 -#define BPB_HIDDEN 17 -#define BPB_HUGE 21 -#define BPB_SIZEOF 25 + +#define FAT_NO_MIRRORING 0x80 + +#define BPB_SIZEOF 31 /* size of the standard BPB */ typedef struct { @@ -263,7 +251,21 @@ typedef struct UWORD bpb_nheads; /* Number of heads */ ULONG bpb_hidden; /* Hidden sectors */ ULONG bpb_huge; /* Size in sectors if */ - /* bpb_nsize== 0 */ + /* bpb_nsize == 0 */ +#ifdef WITHFAT32 + ULONG bpb_xnfsect; /* FAT size in sectors if */ + /* bpb_nfsect == 0 */ + UWORD bpb_xflags; /* extended flags */ + /* bit 7: disable mirroring */ + /* bits 6-4: reserved (0) */ + /* bits 3-0: active FAT number */ + UWORD bpb_xfsversion; /* filesystem version */ + ULONG bpb_xrootclst; /* starting cluster of root dir */ + UWORD bpb_xfsinfosec; /* FS info sector number, */ + /* 0xFFFF if unknown */ + UWORD bpb_xbackupsec; /* backup boot sector number */ + /* 0xFFFF if unknown */ +#endif } bpb; @@ -334,6 +336,18 @@ typedef struct ddtstruct BITS ddt_WriteVerifySupported:1; } ddt; +/* description flag bits */ +#define DF_FIXED 0x001 +#define DF_CHANGELINE 0x002 +#define DF_CURBPBLOCK 0x004 +#define DF_SAMESIZE 0x008 +#define DF_MULTLOG 0x010 +#define DF_CURLOG 0x020 +#define DF_DISKCHANGE 0x040 +#define DF_DPCHANGED 0x080 +#define DF_REFORMAT 0x100 +#define DF_NOACCESS 0x200 + /* typedef struct ddtstruct ddt;*/ struct gblkio @@ -383,6 +397,15 @@ typedef struct } boot; +/* File system information structure */ +struct fsinfo +{ + UDWORD fi_signature; /* must be 0x61417272 */ + DWORD fi_nfreeclst; /* number of free clusters, -1 if unknown */ + DWORD fi_cluster; /* most recently allocated cluster, -1 if unknown */ + UBYTE fi_reserved[12]; +}; + typedef boot super; /* Alias for boot structure */ typedef struct diff --git a/hdr/dirmatch.h b/hdr/dirmatch.h index 8d686ed0..6956f20a 100644 --- a/hdr/dirmatch.h +++ b/hdr/dirmatch.h @@ -36,6 +36,9 @@ static BYTE *dirmatch_hRcsId = "$Id$"; /* * $Log$ + * Revision 1.6 2001/09/23 20:39:44 bartoldeman + * FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling + * * Revision 1.5 2001/07/09 22:19:33 bartoldeman * LBA/FCB/FAT/SYS/Ctrl-C/ioctl fixes + memory savings * @@ -100,7 +103,12 @@ typedef struct BYTE dm_name_pat[FNAME_SIZE + FEXT_SIZE]; BYTE dm_attr_srch; UWORD dm_entry; - UWORD dm_cluster; +#ifdef WITHFAT32 + ULONG dm_dircluster; +#else + UWORD dm_dircluster; + UWORD reserved; +#endif struct { @@ -119,8 +127,6 @@ typedef struct } dm_flags; /* file flags */ - UWORD dm_dirstart; - BYTE dm_attr_fnd; /* found file attribute */ time dm_time; /* file time */ date dm_date; /* file date */ diff --git a/hdr/error.h b/hdr/error.h index 1fcb216d..41541c8f 100644 --- a/hdr/error.h +++ b/hdr/error.h @@ -36,6 +36,9 @@ static BYTE *error_hRcsId = "$Id$"; /* * $Log$ + * Revision 1.6 2001/09/23 20:39:44 bartoldeman + * FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling + * * Revision 1.5 2001/04/16 01:45:26 bartoldeman * Fixed handles, config.sys drivers, warnings. Enabled INT21/AH=6C, printf %S/%Fs * @@ -93,7 +96,7 @@ static BYTE *error_hRcsId = "$Id$"; * Initial revision. */ -/* Internal system error returns */ +/* Internal system error returns */ #define SUCCESS 0 /* Function was successful */ #define DE_INVLDFUNC -1 /* Invalid function number */ #define DE_FILENOTFND -2 /* File not found */ @@ -107,22 +110,25 @@ static BYTE *error_hRcsId = "$Id$"; #define DE_INVLDENV -10 /* Invalid enviornement */ #define DE_INVLDFMT -11 /* Invalid format */ #define DE_INVLDACC -12 /* Invalid access */ -#define DE_INVLDDATA -13 /* Inavalid data */ +#define DE_INVLDDATA -13 /* Invalid data */ #define DE_INVLDDRV -15 /* Invalid drive */ #define DE_RMVCUDIR -16 /* Attempt remove current dir */ #define DE_DEVICE -17 /* Not same device */ #define DE_NFILES -18 /* No more files */ #define DE_WRTPRTCT -19 /* No more files */ #define DE_BLKINVLD -20 /* invalid block */ +#define DE_INVLDBUF -24 /* invalid buffer size, ext fnc */ #define DE_SEEK -25 /* error on file seek */ #define DE_HNDLDSKFULL -28 /* handle disk full (?) */ +#define DE_INVLDPARM -0x57 /* invalid parameter */ + #define DE_DEADLOCK -36 #define DE_LOCK -39 #define DE_FILEEXISTS -80 /* File exists */ -/* Critical error flags */ +/* Critical error flags */ #define EFLG_READ 0x00 /* Read error */ #define EFLG_WRITE 0x01 /* Write error */ #define EFLG_RSVRD 0x00 /* Error in rserved area */ @@ -134,8 +140,8 @@ static BYTE *error_hRcsId = "$Id$"; #define EFLG_IGNORE 0x20 /* Handler can ignore */ #define EFLG_CHAR 0x80 /* Error in char or FAT image */ -/* error results returned after asking user */ -/* MS-DOS compatible -- returned by CriticalError */ +/* error results returned after asking user */ +/* MS-DOS compatible -- returned by CriticalError */ #define CONTINUE 0 #define RETRY 1 #define ABORT 2 diff --git a/hdr/fat.h b/hdr/fat.h index b316ad7e..7259deb7 100644 --- a/hdr/fat.h +++ b/hdr/fat.h @@ -36,6 +36,9 @@ static BYTE *fat_hRcsId = "$Id$"; /* * $Log$ + * Revision 1.8 2001/09/23 20:39:44 bartoldeman + * FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling + * * Revision 1.7 2001/07/09 22:19:33 bartoldeman * LBA/FCB/FAT/SYS/Ctrl-C/ioctl fixes + memory savings * @@ -104,6 +107,8 @@ static BYTE *fat_hRcsId = "$Id$"; /* /// Added D_DEVICE bit. - Ron Cemer */ #define D_DEVICE 0x40 /* device bit */ +#define D_LFN (D_RDONLY | D_HIDDEN | D_SYSTEM | D_VOLID) + /* FAT file name constants */ #define FNAME_SIZE 8 #define FEXT_SIZE 3 @@ -122,11 +127,15 @@ static BYTE *fat_hRcsId = "$Id$"; /* Test for 16 bit or 12 bit FAT */ #define SIZEOF_CLST16 2 +#define SIZEOF_CLST32 4 #define FAT_MAGIC 4086 #define FAT_MAGIC16 ((unsigned)65526l) #define FAT_MAGIC32 268435456l -#define ISFAT32(dpbp) (((dpbp)->dpb_size)>FAT_MAGIC16 && ((dpbp)->dpb_size)<=FAT_MAGIC32 ) +/* int ISFAT32(struct dpb FAR *dpbp);*/ +#define ISFAT32(x) _ISFAT32(x) + +#define _ISFAT32(dpbp) (((dpbp)->dpb_size)>FAT_MAGIC16 && ((dpbp)->dpb_size)<=FAT_MAGIC32 ) #define ISFAT16(dpbp) (((dpbp)->dpb_size)>FAT_MAGIC && ((dpbp)->dpb_size)<=FAT_MAGIC16 ) #define ISFAT12(dpbp) (((dpbp)->dpb_size)<=FAT_MAGIC) @@ -136,11 +145,16 @@ struct dirent UBYTE dir_name[FNAME_SIZE]; /* Filename */ UBYTE dir_ext[FEXT_SIZE]; /* Filename extension */ UBYTE dir_attrib; /* File Attribute */ - BYTE dir_reserved[10]; /* reserved */ + UBYTE dir_case; /* File case */ + UBYTE dir_crtimems; /* Milliseconds */ + UWORD dir_crtime; /* Creation time */ + UWORD dir_crdate; /* Creation date */ + UWORD dir_accdate; /* Last access date */ + UWORD dir_start_high; /* High word of the cluster */ time dir_time; /* Time file created/updated */ - date dir_date; /* Date file created/updated */ + date dir_date; /* Date file created/updated */ UWORD dir_start; /* Starting cluster */ - /* 1st available = 2 */ + /* 1st available = 2 */ ULONG dir_size; /* File size in bytes */ }; @@ -148,6 +162,24 @@ struct dirent /* filesystem sizeof(dirent) - may be different from core */ /* */ +#ifdef WITHFAT32 +#define getdstart(dentry) \ + (((ULONG)dentry.dir_start_high << 16) | dentry.dir_start) +#define setdstart(dentry, value) \ + dentry.dir_start = (UCOUNT)value; \ + dentry.dir_start_high = (UCOUNT)(value >> 16) +#define checkdstart(dentry, value) \ + (dentry.dir_start == (UCOUNT)value && \ + dentry.dir_start_high == (UCOUNT)(value >> 16)) +#else +#define getdstart(dentry) \ + dentry.dir_start +#define setdstart(dentry, value) \ + dentry.dir_start = (UCOUNT)value +#define checkdstart(dentry, value) \ + (dentry.dir_start == (UCOUNT)value) +#endif + #define DIR_NAME 0 #define DIR_EXT FNAME_SIZE #define DIR_ATTRIB FNAME_SIZE+FEXT_SIZE diff --git a/hdr/fnode.h b/hdr/fnode.h index 525c55b0..9085ae66 100644 --- a/hdr/fnode.h +++ b/hdr/fnode.h @@ -36,6 +36,9 @@ static BYTE *fnode_hRcsId = "$Id$"; /* * $Log$ + * Revision 1.9 2001/09/23 20:39:44 bartoldeman + * FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling + * * Revision 1.8 2001/08/19 12:58:34 bartoldeman * Time and date fixes, Ctrl-S/P, findfirst/next, FCBs, buffers, tsr unloading * @@ -122,18 +125,33 @@ struct f_node struct dirent f_dir; /* this file's dir entry image */ ULONG f_diroff; /* offset of the dir entry */ - UWORD f_dirstart; /* the starting cluster of dir */ + CLUSTER f_dirstart; /* the starting cluster of dir */ /* when dir is not root */ struct dpb FAR *f_dpb; /* the block device for file */ ULONG f_dsize; /* file size (for directories) */ ULONG f_offset; /* byte offset for next op */ ULONG f_highwater; /* the largest offset ever */ - UWORD f_back; /* the cluster we were at */ + CLUSTER f_back; /* the cluster we were at */ ULONG f_cluster_offset; /* byte offset that the next 3 point to */ - UWORD f_cluster; /* the cluster we are at */ + CLUSTER f_cluster; /* the cluster we are at */ UWORD f_sector; /* the sector in the cluster */ UWORD f_boff; /* the byte in the cluster */ }; +#if 0 +struct lfn_inode + { + UNICODE name[255]; + + struct dirent l_dir; /* this file's dir entry image */ + + ULONG l_diroff; /* offset of the dir entry */ + CLUSTER l_dirstart; /* the starting cluster of dir */ + /* when dir is not root */ + }; + +typedef struct lfn_inode FAR * lfn_inode_ptr; +#endif + typedef struct f_node * f_node_ptr; diff --git a/hdr/pcb.h b/hdr/pcb.h index bec11d1a..d02c2ebe 100644 --- a/hdr/pcb.h +++ b/hdr/pcb.h @@ -57,6 +57,9 @@ static BYTE *pcb_hRcsId = "$Id$"; /* * $Log$ + * Revision 1.6 2001/09/23 20:39:44 bartoldeman + * FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling + * * Revision 1.5 2001/04/15 03:21:50 bartoldeman * See history.txt for the list of fixes. * @@ -239,7 +242,7 @@ pcb; * On return, all processor registers are stored into *pr (including * flags). */ -void intr(int intnr, iregs * const pr); +void ASMCFUNC intr(int intnr, iregs * const pr); #endif diff --git a/hdr/portab.h b/hdr/portab.h index 9ddae0bd..e4fd11bd 100644 --- a/hdr/portab.h +++ b/hdr/portab.h @@ -36,6 +36,9 @@ static char *portab_hRcsId = "$Id$"; /* * $Log$ + * Revision 1.10 2001/09/23 20:39:44 bartoldeman + * FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling + * * Revision 1.9 2001/06/03 14:16:17 bartoldeman * BUFFERS tuning and misc bug fixes/cleanups (2024c). * @@ -119,6 +122,49 @@ static char *portab_hRcsId = "$Id$"; /* */ /****************************************************************/ + + /* commandline overflow - removing -DI86 TE*/ +#if defined(__TURBOC__) + + #define I86 + #define CDECL cdecl + void __int__(int); + +#elif defined (_MSC_VER) + + #define I86 + #define CDECL _cdecl + #define __int__(intno) asm int intno; + + #if defined(M_I286) /* /G3 doesn't set M_I386, but sets M_I286 TE*/ + #define I386 + #endif + +#elif defined(__WATCOMC__) /* don't know a better way */ + + #define I86 + #define __int__(intno) asm int intno; + #define asm __asm + #define far __far + #define CDECL __cdecl + + #if _M_IX86 >= 300 + #define I386 + #endif + +#elif defined (_MYMC68K_COMILER_) + + #define MC68K + +#else + anyone knows a _portable_ way to create nice errors?? + at least this causes the compiler not to compile :-) +#endif + /* functions, that are shared between C and ASM _must_ + have a certain calling standard. These are declared + as 'ASMCFUNC', and is (and will be ?-) cdecl */ +#define ASMCFUNC cdecl + #ifdef MC68K #define far /* No far type */ @@ -198,6 +244,13 @@ typedef int COUNT; typedef unsigned int UCOUNT; typedef unsigned long ULONG; +#ifdef WITHFAT32 +typedef unsigned long CLUSTER; +#else +typedef unsigned short CLUSTER; +#endif +typedef unsigned short UNICODE; + #define STATIC /* local calls inside module */ @@ -240,18 +293,7 @@ typedef signed long LONG; #define UNREFERENCED_PARAMETER(x) x; #endif - -#if defined(__TURBOC__) - #define FDCALL pascal - #define CDECL cdecl -#else - #define FDCALL - #define CDECL -#endif - -#ifdef I86 - /* commandline overflow - removing /DPROTO - TE*/ +#ifdef I86 /* commandline overflow - removing /DPROTO TE*/ #define PROTO #endif diff --git a/hdr/process.h b/hdr/process.h index 70dc6fdf..12684fd8 100644 --- a/hdr/process.h +++ b/hdr/process.h @@ -36,6 +36,9 @@ static BYTE *process_hRcsId = "$Id$"; /* * $Log$ + * Revision 1.5 2001/09/23 20:39:44 bartoldeman + * FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling + * * Revision 1.4 2000/08/06 04:18:21 jimtabor * See history.txt * @@ -128,7 +131,7 @@ typedef struct BYTE ps_fill1; /* single char fill */ /* CP/M-like entry point */ - BYTE ps_farcall; /* far call opcode */ + UBYTE ps_farcall; /* far call opcode */ VOID(FAR * ps_reentry) (); /* re-entry point */ VOID(interrupt FAR * ps_isv22) (), /* terminate address */ (interrupt FAR * ps_isv23) (), /* break address */ @@ -142,7 +145,7 @@ typedef struct VOID FAR *ps_prevpsp; /* previous psp pointer */ BYTE FAR *ps_dta; /* process dta address */ BYTE ps_fill2[16]; - BYTE ps_unix[3]; /* unix style call - 0xcd 0x21 0xcb */ + UBYTE ps_unix[3]; /* unix style call - 0xcd 0x21 0xcb */ BYTE ps_fill3[9]; union { diff --git a/hdr/version.h b/hdr/version.h index de27c7e2..edc6f082 100644 --- a/hdr/version.h +++ b/hdr/version.h @@ -42,6 +42,8 @@ static BYTE *date_hRcsId = "$Id$"; #define REVISION_MAJOR 1 #define REVISION_MINOR 1 -#define REVISION_SEQ 24 -#define BUILD 2024 -#define SUB_BUILD "h" +#define REVISION_SEQ 25 +#define BUILD "2025" +#define SUB_BUILD "test" +#define KERNEL_VERSION_STRING "1.1.25" /*#REVISION_MAJOR "." #REVISION_MINOR "." #REVISION_SEQ*/ +#define KERNEL_BUILD_STRING "2025test" /*#BUILD SUB_BUILD*/ diff --git a/kernel/asmsupt.asm b/kernel/asmsupt.asm index 27ebb596..dd18bb81 100644 --- a/kernel/asmsupt.asm +++ b/kernel/asmsupt.asm @@ -34,6 +34,9 @@ ; $Id$ ; ; $Log$ +; Revision 1.6 2001/09/23 20:39:44 bartoldeman +; FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling +; ; Revision 1.5 2001/04/15 03:21:50 bartoldeman ; See history.txt for the list of fixes. ; @@ -423,7 +426,7 @@ _fstrncmp: ; and the destination pointer, d les di,[bp+8] - mov cx,[bp+10] + mov cx,[bp+12] jmp short dostrncmp diff --git a/kernel/blockio.c b/kernel/blockio.c index 4ad8945c..3c8278fe 100644 --- a/kernel/blockio.c +++ b/kernel/blockio.c @@ -37,6 +37,9 @@ static BYTE *blockioRcsId = "$Id$"; /* * $Log$ + * Revision 1.13 2001/09/23 20:39:44 bartoldeman + * FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling + * * Revision 1.12 2001/07/22 01:58:58 bartoldeman * Support for Brian's FORMAT, DJGPP libc compilation, cleanups, MSCDEX * @@ -194,15 +197,13 @@ VOID FAR reloc_call_init_buffers(void) pbuffer->b_flag = 0; pbuffer->b_blkno = 0; pbuffer->b_copies = 0; - pbuffer->b_offset_lo = 0; - pbuffer->b_offset_hi = 0; + pbuffer->b_offset = 0; if (i < (Config.cfgBuffers - 1)) pbuffer->b_next = pbuffer + 1; else pbuffer->b_next = NULL; } firstbuf = &buffers[0]; - lastbuf = &buffers[Config.cfgBuffers - 1]; } */ /* Extract the block number from a buffer structure. */ @@ -496,12 +497,11 @@ BOOL flush1(struct buffer FAR * bp) if (bp->b_flag & BFR_FAT) { int i = bp->b_copies; - LONG blkno = getblkno(bp); - UWORD offset = ((UWORD) bp->b_offset_hi << 8) | bp->b_offset_lo; + ULONG blkno = getblkno(bp); while (--i > 0) { - blkno += offset; + blkno += bp->b_offset; result = dskxfer(bp->b_unit, blkno, (VOID FAR *) bp->b_buffer, 1, DSKWRITE); /* BER 9/4/00 */ } diff --git a/kernel/break.c b/kernel/break.c index 0e2d5676..a0c574ed 100644 --- a/kernel/break.c +++ b/kernel/break.c @@ -30,7 +30,7 @@ #include "portab.h" #include "globals.h" -extern void spawn_int23(void); +extern void ASMCFUNC spawn_int23(void); #ifdef VERSION_STRINGS static BYTE *RcsId = "$Id$"; @@ -38,6 +38,9 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.7 2001/09/23 20:39:44 bartoldeman + * FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling + * * Revision 1.6 2001/08/19 12:58:36 bartoldeman * Time and date fixes, Ctrl-S/P, findfirst/next, FCBs, buffers, tsr unloading * diff --git a/kernel/chario.c b/kernel/chario.c index 53eba670..568fa7fa 100644 --- a/kernel/chario.c +++ b/kernel/chario.c @@ -36,6 +36,9 @@ static BYTE *charioRcsId = "$Id$"; /* * $Log$ + * Revision 1.13 2001/09/23 20:39:44 bartoldeman + * FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling + * * Revision 1.12 2001/08/20 20:32:15 bartoldeman * Truename, get free space and ctrl-break fixes. * @@ -150,10 +153,6 @@ static VOID kbfill(); struct dhdr FAR *finddev(); #endif -#ifdef __TURBOC__ -void __int__(int); /* TC 2.01 requires this. :( -- ror4 */ -#endif - /* Return a pointer to the first driver in the chain that * matches the attributes. * not necessary because we have the syscon pointer. @@ -177,8 +176,15 @@ struct dhdr FAR *finddev(UWORD attr_mask) VOID _cso(COUNT c) { if (syscon->dh_attr & ATTR_FASTCON) { - _AL = c; - __int__(0x29); + #if defined(__TURBOC__) + _AL = c; + __int__(0x29); + #else + asm { + mov al, byte ptr c; + int 0x29; + } + #endif return; } CharReqHdr.r_length = sizeof(request); diff --git a/kernel/config.c b/kernel/config.c index 16db0666..751c1511 100644 --- a/kernel/config.c +++ b/kernel/config.c @@ -29,10 +29,10 @@ #include "portab.h" #include "init-mod.h" +#include "init-dat.h" #include "dyndata.h" - /* These are the far variables from the DOS data segment that we need here. The init procedure uses a different default DS data segment, which is discarded @@ -41,42 +41,41 @@ -- Bart */ -extern struct buffer FAR * FAR lastbuf;/* tail of ditto */ -extern f_node_ptr FAR f_nodes; /* pointer to the array */ -extern UWORD FAR f_nodes_cnt, /* number of allocated f_nodes */ - FAR first_mcb; /* Start of user memory */ +extern f_node_ptr DOSFAR f_nodes; /* pointer to the array */ +extern UWORD DOSFAR f_nodes_cnt, /* number of allocated f_nodes */ + DOSFAR first_mcb; /* Start of user memory */ -extern UBYTE FAR lastdrive, FAR nblkdev, FAR mem_access_mode, - FAR uppermem_link; +extern UBYTE DOSFAR lastdrive, DOSFAR nblkdev, DOSFAR mem_access_mode, + DOSFAR uppermem_link; extern struct dhdr - FAR blk_dev, /* Block device (Disk) driver */ - FAR nul_dev; -extern struct buffer FAR * FAR firstbuf; /* head of buffers linked list */ + DOSTEXTFAR blk_dev, /* Block device (Disk) driver */ + DOSFAR nul_dev; +extern struct buffer FAR * DOSFAR firstbuf; /* head of buffers linked list */ -extern struct dpb FAR * FAR DPBp; +extern struct dpb FAR * DOSFAR DPBp; /* First drive Parameter Block */ -extern cdstbl FAR * FAR CDSp; +extern cdstbl FAR * DOSFAR CDSp; /* Current Directory Structure */ -extern sfttbl FAR * FAR sfthead; +extern sfttbl FAR * DOSFAR sfthead; /* System File Table head */ -extern sfttbl FAR * FAR FCBp; +extern sfttbl FAR * DOSFAR FCBp; -extern BYTE FAR VgaSet, - FAR _HMATextAvailable, /* first byte of available CODE area */ +extern BYTE DOSFAR VgaSet, + DOSFAR _HMATextAvailable, /* first byte of available CODE area */ FAR _HMATextStart[], /* first byte of HMAable CODE area */ FAR _HMATextEnd[], - FAR break_ena, /* break enabled flag */ - FAR os_major, /* major version number */ - FAR os_minor, /* minor version number */ - FAR switchar, - FAR _InitTextStart, /* first available byte of ram */ - FAR ReturnAnyDosVersionExpected; - -extern UWORD FAR ram_top, /* How much ram in Kbytes */ - FAR UMB_top, - FAR umb_start, - FAR uppermem_root, - FAR LoL_nbuffers; + DOSFAR break_ena, /* break enabled flag */ + DOSFAR os_major, /* major version number */ + DOSFAR os_minor, /* minor version number */ + DOSFAR switchar, + DOSFAR _InitTextStart, /* first available byte of ram */ + DOSFAR ReturnAnyDosVersionExpected; + +extern UWORD DOSFAR ram_top, /* How much ram in Kbytes */ + DOSFAR UMB_top, + DOSFAR umb_start, + DOSFAR uppermem_root, + DOSFAR LoL_nbuffers; #ifdef VERSION_STRINGS static BYTE *RcsId = "$Id$"; @@ -90,6 +89,9 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.28 2001/09/23 20:39:44 bartoldeman + * FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling + * * Revision 1.27 2001/08/19 12:58:36 bartoldeman * Time and date fixes, Ctrl-S/P, findfirst/next, FCBs, buffers, tsr unloading * @@ -276,16 +278,20 @@ struct config Config ,0 /* strategy for command.com is low by default */ } ; - -BYTE FAR *lpBase; -BYTE FAR *upBase; -BYTE FAR *lpTop; -BYTE FAR *lpOldTop; -static COUNT nCfgLine; -static COUNT nPass; - COUNT UmbState; -static BYTE szLine[256]; -static BYTE szBuf[256]; + /* MSC places uninitialized data into COMDEF records, + that end up in DATA segment. this can't be tolerated + in INIT code. + please make sure, that ALL data in INIT is initialized !! + */ +BYTE FAR *lpBase = 0; +BYTE FAR *upBase = 0; +BYTE FAR *lpTop = 0; +BYTE FAR *lpOldTop = 0; +STATIC COUNT nCfgLine = 0; +STATIC COUNT nPass = 0; + COUNT UmbState = 0; +STATIC BYTE szLine[256] = {0}; +STATIC BYTE szBuf[256] = {0}; int singleStep = FALSE; int SkipAllConfig = FALSE; @@ -296,18 +302,18 @@ INIT VOID mumcb_init(UCOUNT seg, UWORD size); INIT VOID Config_Buffers(BYTE * pLine); INIT VOID sysScreenMode(BYTE * pLine); INIT VOID sysVersion(BYTE * pLine); -INIT VOID Break(BYTE * pLine); +INIT VOID CfgBreak(BYTE * pLine); INIT VOID Device(BYTE * pLine); INIT VOID DeviceHigh(BYTE * pLine); INIT VOID Files(BYTE * pLine); INIT VOID Fcbs(BYTE * pLine); -INIT VOID Lastdrive(BYTE * pLine); +INIT VOID CfgLastdrive(BYTE * pLine); INIT BOOL LoadDevice(BYTE * pLine, COUNT top, COUNT mode); INIT VOID Dosmem(BYTE * pLine); INIT VOID Country(BYTE * pLine); INIT VOID InitPgm(BYTE * pLine); INIT VOID InitPgmHigh(BYTE * pLine); -INIT VOID Switchar(BYTE * pLine); +INIT VOID CfgSwitchar(BYTE * pLine); INIT VOID CfgFailure(BYTE * pLine); INIT VOID Stacks(BYTE * pLine); INIT VOID SetAnyDos(BYTE * pLine); @@ -323,7 +329,7 @@ INIT COUNT strcasecmp(REG BYTE *d, REG BYTE *s); extern void HMAconfig(int finalize); VOID config_init_buffers(COUNT anzBuffers); /* from BLOCKIO.C */ -INIT static VOID FAR *AlignParagraph(VOID FAR * lpPtr); +INIT STATIC VOID FAR *AlignParagraph(VOID FAR * lpPtr); #ifndef I86 #define AlignParagraph(x) (x) #endif @@ -339,9 +345,9 @@ struct table VOID(*func) (BYTE * pLine); }; -static struct table commands[] = +STATIC struct table commands[] = { - {"BREAK", 1, Break}, + {"BREAK", 1, CfgBreak}, {"BUFFERS", 1, Config_Buffers}, {"COMMAND", 1, InitPgm}, {"COUNTRY", 1, Country}, @@ -350,14 +356,14 @@ static struct table commands[] = {"DOS", 1, Dosmem}, {"FCBS", 1, Fcbs}, {"FILES", 1, Files}, - {"LASTDRIVE", 1, Lastdrive}, + {"LASTDRIVE", 1, CfgLastdrive}, {"NUMLOCK", 1, Numlock}, /* rem is never executed by locking out pass */ {"REM", 0, CfgFailure}, {"SHELL", 1, InitPgm}, {"SHELLHIGH", 1, InitPgmHigh}, {"STACKS", 1, Stacks}, - {"SWITCHAR", 1, Switchar}, + {"SWITCHAR", 1, CfgSwitchar}, {"SCREEN", 1, sysScreenMode}, /* JPP */ {"VERSION", 1, sysVersion}, /* JPP */ {"ANYDOS", 1, SetAnyDos}, /* JPP */ @@ -370,9 +376,9 @@ INIT BYTE FAR *KernelAlloc(WORD nBytes); INIT BYTE FAR *KernelAllocDma(WORD); #endif -BYTE *pLineStart; +BYTE *pLineStart = 0; -BYTE HMAState; +BYTE HMAState = 0; #define HMA_NONE 0 /* do nothing */ #define HMA_REQ 1 /* DOS = HIGH detected */ #define HMA_DONE 2 /* Moved kernel to HMA */ @@ -548,7 +554,7 @@ INIT void PostConfig(void) printf(" sft table 0x%p\n",sfthead->sftt_next); printf(" CDS table 0x%p\n",CDSp); printf(" DPB table 0x%p\n",DPBp); -#endif +#endif if (Config.cfgStacks) { VOID FAR *stackBase = KernelAlloc(Config.cfgStacks * Config.cfgStackSize); @@ -707,7 +713,7 @@ INIT VOID DoConfig(VOID) { bEof = TRUE; break; - } + } /* immediately convert to upper case */ *pLine = toupper(*pLine); @@ -946,7 +952,7 @@ INIT void Config_Buffers(BYTE * pLine) Config.cfgBuffers = max(Config.cfgBuffers, nBuffers); } -INIT static VOID sysScreenMode(BYTE * pLine) +INIT STATIC VOID sysScreenMode(BYTE * pLine) { COUNT nMode; @@ -962,12 +968,20 @@ INIT static VOID sysScreenMode(BYTE * pLine) 0x12 (18) 43/50 lines 0x14 (20) 25 lines */ +#if defined(__TURBOC__) _AX = (0x11 << 8) + nMode; _BL = 0; __int__(0x10); +#else + asm { + mov al, byte ptr nMode; + mov ah, 0x11; + int 0x10; + } +#endif } -INIT static VOID sysVersion(BYTE * pLine) +INIT STATIC VOID sysVersion(BYTE * pLine) { COUNT major, minor; @@ -994,7 +1008,7 @@ INIT static VOID sysVersion(BYTE * pLine) os_minor = minor; } -INIT static VOID Files(BYTE * pLine) +INIT STATIC VOID Files(BYTE * pLine) { COUNT nFiles; @@ -1006,7 +1020,7 @@ INIT static VOID Files(BYTE * pLine) Config.cfgFiles = max(Config.cfgFiles, nFiles); } -INIT static VOID Lastdrive(BYTE * pLine) +INIT STATIC VOID CfgLastdrive(BYTE * pLine) { /* Format: LASTDRIVE = letter */ BYTE drv; @@ -1067,7 +1081,7 @@ INIT STATIC VOID Dosmem(BYTE * pLine) } } -INIT static VOID Switchar(BYTE * pLine) +INIT STATIC VOID CfgSwitchar(BYTE * pLine) { /* Format: SWITCHAR = character */ @@ -1075,7 +1089,7 @@ INIT static VOID Switchar(BYTE * pLine) switchar = *szBuf; } -INIT static VOID Fcbs(BYTE * pLine) +INIT STATIC VOID Fcbs(BYTE * pLine) { /* Format: FCBS = totalFcbs [,protectedFcbs] */ COUNT fcbs; @@ -1117,7 +1131,7 @@ INIT BOOL LoadCountryInfo(char *filename, UWORD ctryCode, UWORD codePage) return FALSE; } -INIT static VOID Country(BYTE * pLine) +INIT STATIC VOID Country(BYTE * pLine) { /* Format: COUNTRY = countryCode, [codePage], filename */ COUNT ctryCode; @@ -1153,7 +1167,7 @@ INIT static VOID Country(BYTE * pLine) CfgFailure(pLine); } -INIT static VOID Stacks(BYTE * pLine) +INIT STATIC VOID Stacks(BYTE * pLine) { COUNT stacks; @@ -1180,14 +1194,14 @@ INIT static VOID Stacks(BYTE * pLine) } } -INIT static VOID InitPgmHigh(BYTE * pLine) +INIT STATIC VOID InitPgmHigh(BYTE * pLine) { InitPgm(pLine); Config.cfgP_0_startmode = 0x80; } -INIT static VOID InitPgm(BYTE * pLine) +INIT STATIC VOID InitPgm(BYTE * pLine) { /* Get the string argument that represents the new init pgm */ pLine = GetStringArg(pLine, Config.cfgInit); @@ -1202,16 +1216,16 @@ INIT static VOID InitPgm(BYTE * pLine) Config.cfgP_0_startmode = 0; } -INIT static VOID Break(BYTE * pLine) +INIT STATIC VOID CfgBreak(BYTE * pLine) { /* Format: BREAK = (ON | OFF) */ GetStringArg(pLine, szBuf); break_ena = strcasecmp(szBuf, "OFF") ? 1 : 0; } -INIT static VOID Numlock(BYTE * pLine) +INIT STATIC VOID Numlock(BYTE * pLine) { - extern VOID keycheck(); + extern VOID ASMCFUNC keycheck(); /* Format: NUMLOCK = (ON | OFF) */ BYTE FAR *keyflags = (BYTE FAR *)MK_FP(0x40,0x17); @@ -1223,7 +1237,7 @@ INIT static VOID Numlock(BYTE * pLine) keycheck(); } -INIT static VOID DeviceHigh(BYTE * pLine) +INIT STATIC VOID DeviceHigh(BYTE * pLine) { if(UmbState == 1) { @@ -1313,7 +1327,7 @@ INIT BOOL LoadDevice(BYTE * pLine, COUNT top, COUNT mode) return result; } -INIT static VOID CfgFailure(BYTE * pLine) +INIT STATIC VOID CfgFailure(BYTE * pLine) { BYTE *pTmp = pLineStart; @@ -1581,34 +1595,52 @@ VOID config_init_buffers(COUNT anzBuffers) pbuffer = firstbuf; + DebugPrintf(("init_buffers at")); + for (i = 0; ; ++i) { if (FP_SEG(pbuffer) == 0xffff) HMAcount++; - lastbuf = pbuffer; - pbuffer->b_dummy = FP_OFF(pbuffer); pbuffer->b_unit = 0; pbuffer->b_flag = 0; pbuffer->b_blkno = 0; pbuffer->b_copies = 0; - pbuffer->b_offset_lo = 0; - pbuffer->b_offset_hi = 0; + pbuffer->b_offset = 0; pbuffer->b_next = NULL; - DebugPrintf(("init_buffers buffer %d at %p\n",i, pbuffer)); - + DebugPrintf((" (%d,%p)",i, pbuffer)); + + /* now, we can have quite some buffers in HMA + -- up to 37 for KE38616. + so we fill the HMA with buffers + */ + if (i < (anzBuffers - 1)) - pbuffer->b_next = ConfigAlloc(sizeof (struct buffer)); - + { + pbuffer->b_next = HMAalloc(sizeof (struct buffer)); + + if (pbuffer->b_next == NULL) + { + /* if more buffer requested then fit into HMA, allocate + some from low memory as rewuested + */ + pbuffer->b_next = ConfigAlloc(sizeof (struct buffer)); + } + } + if (pbuffer->b_next == NULL) break; pbuffer = pbuffer->b_next; } - DebugPrintf(("Kernel: allocated %d Diskbuffers = %u Bytes in HMA\n", - HMAcount, HMAcount*sizeof (struct buffer))); + DebugPrintf((" done\n")); + + if (HMAcount) + printf("Kernel: allocated %d Diskbuffers = %u Bytes in HMA\n", + HMAcount, HMAcount*sizeof (struct buffer)); + if (HMAState == HMA_NONE || HMAState == HMA_REQ) lpBase = tmplpBase; } diff --git a/kernel/dosfns.c b/kernel/dosfns.c index c694fc82..ab068e87 100644 --- a/kernel/dosfns.c +++ b/kernel/dosfns.c @@ -37,6 +37,9 @@ static BYTE *dosfnsRcsId = "$Id$"; * /// Added SHARE support. 2000/09/04 Ron Cemer * * $Log$ + * Revision 1.26 2001/09/23 20:39:44 bartoldeman + * FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling + * * Revision 1.25 2001/08/20 20:32:15 bartoldeman * Truename, get free space and ctrl-break fixes. * @@ -258,6 +261,31 @@ static int share_lock_unlock /* /// End of additions for SHARE. - Ron Cemer */ +#ifdef WITHFAT32 +struct dpb FAR *GetDriveDPB(UBYTE drive, COUNT *rc) +{ + struct dpb FAR *dpb; + drive = drive == 0 ? default_drive : drive - 1; + + if (drive >= lastdrive) + { + *rc = DE_INVLDDRV; + return 0; + } + + dpb = CDSp->cds_table[drive].cdsDpb; + if (dpb == 0 || + CDSp->cds_table[drive].cdsFlags & CDSNETWDRV) + { + *rc = DE_INVLDDRV; + return 0; + } + + *rc = SUCCESS; + return dpb; +} +#endif + static VOID DosGetFile(BYTE * lpszPath, BYTE FAR * lpszDosFileName) { BYTE szLclName[FNAME_SIZE + 1]; @@ -758,7 +786,7 @@ COUNT DosCreatSft(BYTE * fname, COUNT attrib) COUNT drive; /* NEVER EVER allow directories to be created */ - if (attrib & ~(D_RDONLY|D_HIDDEN|D_SYSTEM|D_ARCHIVE)) + if (attrib & 0xff & ~(D_RDONLY|D_HIDDEN|D_SYSTEM|D_ARCHIVE)) { return DE_ACCESS; } @@ -772,7 +800,7 @@ COUNT DosCreatSft(BYTE * fname, COUNT attrib) sftp->sft_shroff = -1; /* /// Added for SHARE - Ron Cemer */ sftp->sft_psp = cu_psp; sftp->sft_mode = SFT_MRDWR; - sftp->sft_attrib = attrib; + sftp->sft_attrib = attrib & 0xff; sftp->sft_psp = cu_psp; /* check for a device */ @@ -787,12 +815,7 @@ COUNT DosCreatSft(BYTE * fname, COUNT attrib) return sft_idx; } - drive = get_verify_drive(fname); - if(drive < 0) { - return drive; - } - - if (CDSp->cds_table[drive].cdsFlags & CDSNETWDRV) { + if (current_ldt->cdsFlags & CDSNETWDRV) { lpCurSft = (sfttbl FAR *)sftp; sftp->sft_mode = attrib; result = -int2f_Remote_call(REM_CREATE, 0, 0, 0, (VOID FAR *) sftp, 0, MK_FP(0, attrib)); @@ -802,7 +825,12 @@ COUNT DosCreatSft(BYTE * fname, COUNT attrib) } return result; } - + + drive = get_verify_drive(fname); + if (drive < 0) { + return drive; + } + /* /// Added for SHARE. - Ron Cemer */ if (IsShareInstalled()) { if ((sftp->sft_shroff = share_open_check @@ -975,12 +1003,7 @@ COUNT DosOpenSft(BYTE * fname, COUNT mode) return sft_idx; } - drive = get_verify_drive(fname); - if (drive < 0) { - return drive; - } - - if (CDSp->cds_table[drive].cdsFlags & CDSNETWDRV) { + if (current_ldt->cdsFlags & CDSNETWDRV) { lpCurSft = (sfttbl FAR *)sftp; result = -int2f_Remote_call(REM_OPEN, 0, 0, 0, (VOID FAR *) sftp, 0, MK_FP(0, mode)); if (result == SUCCESS) { @@ -989,6 +1012,12 @@ COUNT DosOpenSft(BYTE * fname, COUNT mode) } return result; } + + drive = get_verify_drive(fname); + if (drive < 0) { + return drive; + } + sftp->sft_shroff = -1; /* /// Added for SHARE - Ron Cemer */ /* /// Added for SHARE. - Ron Cemer */ @@ -1116,7 +1145,11 @@ VOID DosGetFree(UBYTE drive, COUNT FAR * spc, COUNT FAR * navc, COUNT FAR * bps, { struct dpb FAR *dpbp; struct cds FAR *cdsp; - COUNT rg[4]; + COUNT rg[4]; +#ifdef WITHFAT32 + UCOUNT shift = 0; + ULONG cluster_size, ntotal, nfree; +#endif /* next - "log" in the drive */ drive = (drive == 0 ? default_drive : drive - 1); @@ -1145,8 +1178,28 @@ VOID DosGetFree(UBYTE drive, COUNT FAR * spc, COUNT FAR * navc, COUNT FAR * bps, dpbp = CDSp->cds_table[drive].cdsDpb; if (dpbp == NULL || media_check(dpbp) < 0) return; +#ifdef WITHFAT32 + cluster_size = (dpbp->dpb_clsmask + 1) * dpbp->dpb_secsize; + ntotal = dpbp->dpb_size - 1; + if (ISFAT32(dpbp)) while (cluster_size <= 0x7fff) { + cluster_size <<= 1; + ntotal >>= 1; + shift++; + } + /* get the data available from dpb */ + *nc = (UCOUNT)ntotal; + if (ntotal > 0xfffe) + *nc = 0xfffe; + *spc = (dpbp->dpb_clsmask + 1) << shift; + *bps = dpbp->dpb_secsize; - /* get the data vailable from dpb */ + /* now tell fs to give us free cluster */ + /* count */ + nfree = dos_free(dpbp) >> shift; + if (nfree > 0xfffe) nfree = 0xfffe; + *navc = (UCOUNT)nfree; +#else + /* get the data available from dpb */ *nc = dpbp->dpb_size - 1; *spc = dpbp->dpb_clsmask + 1; *bps = dpbp->dpb_secsize; @@ -1154,8 +1207,59 @@ VOID DosGetFree(UBYTE drive, COUNT FAR * spc, COUNT FAR * navc, COUNT FAR * bps, /* now tell fs to give us free cluster */ /* count */ *navc = dos_free(dpbp); +#endif } +#ifdef WITHFAT32 +/* network names like \\SERVER\C aren't supported yet */ +#define IS_SLASH(ch) (ch == '\\' || ch == '/') +COUNT DosGetExtFree(BYTE FAR *DriveString, struct xfreespace FAR *xfsp) +{ + struct dpb FAR *dpbp; + struct cds FAR *cdsp; + UBYTE drive; + UCOUNT rg[4]; + + if (IS_SLASH(DriveString[0]) || !IS_SLASH(DriveString[2]) + || DriveString[1] != ':') + return DE_INVLDDRV; + drive = DosUpFChar(*DriveString) - 'A'; + if (drive >= lastdrive) return DE_INVLDDRV; + + cdsp = &CDSp->cds_table[drive]; + + if (!(cdsp->cdsFlags & CDSVALID)) + return DE_INVLDDRV; + + if (cdsp->cdsFlags & CDSNETWDRV) + { + int2f_Remote_call(REM_GETSPACE, 0, 0, 0, cdsp, 0, &rg); + + xfsp->xfs_clussize = rg[0]; + xfsp->xfs_totalclusters = rg[1]; + xfsp->xfs_secsize = rg[2]; + xfsp->xfs_freeclusters = rg[3]; + } else { + dpbp = CDSp->cds_table[drive].cdsDpb; + if (dpbp == NULL || media_check(dpbp) < 0) + return DE_INVLDDRV; + xfsp->xfs_secsize = dpbp->dpb_secsize; + xfsp->xfs_totalclusters = dpbp->dpb_size; + xfsp->xfs_freeclusters = dos_free(dpbp); + xfsp->xfs_clussize = dpbp->dpb_clsmask + 1; + } + xfsp->xfs_totalunits = xfsp->xfs_totalclusters; + xfsp->xfs_freeunits = xfsp->xfs_freeclusters; + xfsp->xfs_totalsectors = xfsp->xfs_totalclusters * xfsp->xfs_clussize; + xfsp->xfs_freesectors = xfsp->xfs_freeclusters * xfsp->xfs_clussize; + xfsp->xfs_datasize = sizeof(struct xfreespace); + + fmemset(xfsp->xfs_reserved, 0, 8); + + return SUCCESS; +} +#endif + COUNT DosGetCuDir(UBYTE drive, BYTE FAR * s) { BYTE FAR *cp; diff --git a/kernel/dosidle.asm b/kernel/dosidle.asm index 64c868d6..bbcdf479 100644 --- a/kernel/dosidle.asm +++ b/kernel/dosidle.asm @@ -42,10 +42,6 @@ segment HMA_TEXT extern critical_sp:wrt DGROUP extern _lpUserStack:wrt DGROUP extern _user_r:wrt DGROUP - extern _api_sp:wrt DGROUP ; api stacks - for context - extern _api_ss:wrt DGROUP ; switching - extern _usr_sp:wrt DGROUP ; user stacks - extern _usr_ss:wrt DGROUP extern _dosidle_flag:wrt DGROUP ; ; @@ -71,10 +67,6 @@ Do_DosI: push word [_user_r+2] push word [_lpUserStack] push word [_lpUserStack+2] - push word [_api_sp] - push word [_api_ss] - push word [_usr_sp] - push word [_usr_ss] mov es,word [_cu_psp] push word [es:PSP_USERSS] push word [es:PSP_USERSP] @@ -84,10 +76,6 @@ Do_DosI: mov es,word [_cu_psp] pop word [es:PSP_USERSP] pop word [es:PSP_USERSS] - pop word [_usr_ss] - pop word [_usr_sp] - pop word [_api_ss] - pop word [_api_sp] pop word [_lpUserStack+2] pop word [_lpUserStack] pop word [_user_r+2] diff --git a/kernel/dsk.c b/kernel/dsk.c index 4d050dab..1e6d8ef7 100644 --- a/kernel/dsk.c +++ b/kernel/dsk.c @@ -34,6 +34,9 @@ static BYTE *dskRcsId = "$Id$"; /* * $Log$ + * Revision 1.20 2001/09/23 20:39:44 bartoldeman + * FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling + * * Revision 1.19 2001/07/28 18:13:06 bartoldeman * Fixes for FORMAT+SYS, FATFS, get current dir, kernel init memory situation. * @@ -165,16 +168,17 @@ static BYTE *dskRcsId = "$Id$"; #ifdef PROTO -BOOL fl_reset(WORD); -COUNT fl_readdasd(WORD); -COUNT fl_diskchanged(WORD); -COUNT fl_rd_status(WORD); +BOOL ASMCFUNC fl_reset(WORD); +COUNT ASMCFUNC fl_readdasd(WORD); +COUNT ASMCFUNC fl_diskchanged(WORD); +COUNT ASMCFUNC fl_rd_status(WORD); -COUNT fl_read(WORD, WORD, WORD, WORD, WORD, BYTE FAR *); -COUNT fl_write(WORD, WORD, WORD, WORD, WORD, BYTE FAR *); -COUNT fl_verify(WORD, WORD, WORD, WORD, WORD, BYTE FAR *); +COUNT ASMCFUNC fl_read(WORD, WORD, WORD, WORD, WORD, BYTE FAR *); +COUNT ASMCFUNC fl_write(WORD, WORD, WORD, WORD, WORD, BYTE FAR *); +COUNT ASMCFUNC fl_verify(WORD, WORD, WORD, WORD, WORD, BYTE FAR *); +VOID ASMCFUNC fl_readkey(VOID); -extern COUNT fl_lba_ReadWrite (BYTE drive, WORD mode, +extern COUNT ASMCFUNC fl_lba_ReadWrite (BYTE drive, WORD mode, struct _bios_LBA_address_packet FAR *dap_p); int LBA_Transfer(ddt *pddt ,UWORD mode, VOID FAR *buffer, @@ -187,20 +191,22 @@ COUNT fl_rd_status(); COUNT fl_read(); COUNT fl_write(); COUNT fl_verify(); +VOID fl_readkey(); #endif #define NENTRY 26 /* total size of dispatch table */ extern BYTE FAR nblk_rel; +extern int FAR ASMCFUNC Get_nblk_rel(void); + + #define LBA_READ 0x4200 #define LBA_WRITE 0x4300 UWORD LBA_WRITE_VERIFY = 0x4302; #define LBA_VERIFY 0x4400 -extern void __int__(int); - /* this buffer must not overlap a 64K boundary due to DMA transfers this is certainly true, if located somewhere @@ -312,7 +318,7 @@ static WORD(*dispatch[NENTRY]) () = -#define hd(x) ((x) & 0x80) +#define hd(x) ((x) & DF_FIXED) /* ----------------------------------------------------------------------- */ /* F U N C T I O N S --------------------------------------------------- */ @@ -321,7 +327,7 @@ static WORD(*dispatch[NENTRY]) () = -COUNT FAR blk_driver(rqptr rp) +COUNT FAR ASMCFUNC blk_driver(rqptr rp) { if (rp->r_unit >= nUnits && rp->r_command != C_INIT) return failure(E_UNIT); @@ -342,45 +348,83 @@ WORD _dsk_init(rqptr rp, ddt *pddt) return S_DONE; /* to keep the compiler happy */ } -WORD mediachk(rqptr rp, ddt *pddt) +STATIC WORD play_dj(ddt*pddt) +{ + /* play the DJ ... */ + if ((pddt->ddt_descflags & (DF_MULTLOG | DF_CURLOG)) == DF_MULTLOG) + { + int i; + ddt *pddt2 = getddt(0); + for (i = 0; i < nUnits; i++, pddt2++) + { + if (pddt->ddt_driveno == pddt2->ddt_driveno && + (pddt2->ddt_descflags & (DF_MULTLOG | DF_CURLOG)) == + (DF_MULTLOG | DF_CURLOG)) + break; + } + if (i == nUnits) + { + printf("Error in the DJ mechanism!\n"); /* should not happen! */ + return M_CHANGED; + } + printf("Remove diskette in drive %c:\n", 'A'+pddt2->ddt_logdriveno); + printf("Insert diskette in drive %c:\n", 'A'+pddt->ddt_logdriveno); + printf("Press the any key to continue ... \n"); + fl_readkey(); + pddt2->ddt_descflags &= ~DF_CURLOG; + pddt->ddt_descflags |= DF_CURLOG; + return M_CHANGED; + } + return M_NOT_CHANGED; +} + +STATIC WORD diskchange(ddt *pddt) { - COUNT drive = pddt->ddt_driveno; COUNT result; /* if it's a hard drive, media never changes */ - if (hd(drive)) - rp->r_mcretcode = M_NOT_CHANGED; - else - /* else, check floppy status */ + if (hd(pddt->ddt_descflags)) + return M_NOT_CHANGED; + + if (play_dj(pddt) == M_CHANGED) + return M_CHANGED; + + if (pddt->ddt_descflags & DF_CHANGELINE) /* if we can detect a change ... */ { - if ((result = fl_readdasd(drive)) == 2) /* if we can detect a change ... */ - { - if ((result = fl_diskchanged(drive)) == 1) /* check if it has changed... */ - rp->r_mcretcode = M_CHANGED; - else if (result == 0) - rp->r_mcretcode = M_NOT_CHANGED; - else - rp->r_mcretcode = tdelay((LONG) 37) ? M_DONT_KNOW : M_NOT_CHANGED; - } - else if (result == 3) /* if it's a fixed disk, then no change */ - rp->r_mcretcode = M_NOT_CHANGED; - else /* can not detect or error... */ - rp->r_mcretcode = tdelay((LONG) 37) ? M_DONT_KNOW : M_NOT_CHANGED; + if ((result = fl_diskchanged(pddt->ddt_driveno)) == 1) + /* check if it has changed... */ + return M_CHANGED; + else if (result == 0) + return M_NOT_CHANGED; } + /* can not detect or error... */ + return tdelay((LONG) 37) ? M_DONT_KNOW : M_NOT_CHANGED; +} + +WORD mediachk(rqptr rp, ddt *pddt) +{ + /* check floppy status */ + if (pddt->ddt_descflags & DF_DISKCHANGE) + { + pddt->ddt_descflags &= ~DF_DISKCHANGE; + rp->r_mcretcode = M_DONT_KNOW; + } + else + { + rp->r_mcretcode = diskchange(pddt); + } return S_DONE; } /* * Read Write Sector Zero or Hard Drive Dos Bpb */ -STATIC WORD RWzero(rqptr rp, WORD t) +STATIC WORD RWzero(ddt *pddt, UWORD mode) { - ddt *pddt = getddt(rp->r_unit); UWORD done; - return LBA_Transfer(pddt, - t == 0 ? LBA_READ : LBA_WRITE, + return LBA_Transfer(pddt, mode, (UBYTE FAR *)&DiskTransferBuffer, pddt->ddt_offset,1,&done); } @@ -396,8 +440,8 @@ static WORD Getlogdev(rqptr rp, ddt *pddt) UNREFERENCED_PARAMETER(pddt); x++; - if( x > nblk_rel ) - return failure(E_UNIT); + if( x > Get_nblk_rel() ) + return failure(E_UNIT); rp->r_unit = x; return S_DONE; @@ -439,22 +483,24 @@ static WORD blk_Media(rqptr rp, ddt *pddt) { UNREFERENCED_PARAMETER(rp); - if (hd( pddt->ddt_driveno)) + if (hd( pddt->ddt_descflags)) return S_BUSY|S_DONE; /* Hard Drive */ else return S_DONE; /* Floppy */ } -STATIC WORD bldbpb(rqptr rp, ddt *pddt) +static getbpb(ddt *pddt) { ULONG count; bpb *pbpbarray = &pddt->ddt_bpb; WORD head,/*track,*/sector,ret; - ret = RWzero( rp, 0); - getword(&((((BYTE *) & DiskTransferBuffer[BT_BPB]))[BPB_NBYTE]), &pbpbarray->bpb_nbyte); + ret = RWzero(pddt, LBA_READ); + getword(&((((BYTE *) & DiskTransferBuffer[BT_BPB]))[0]), &pbpbarray->bpb_nbyte); - pddt->ddt_descflags |= 0x200; /* set drive to not accessible */ + pddt->ddt_descflags |= DF_NOACCESS; /* set drive to not accessible and changed */ + if (diskchange(pddt) != M_NOT_CHANGED) + pddt->ddt_descflags |= DF_DISKCHANGE; if (ret != 0) return (dskerr(ret)); @@ -466,30 +512,41 @@ STATIC WORD bldbpb(rqptr rp, ddt *pddt) return S_DONE; } - pddt->ddt_descflags &= ~0x200; /* set drive to accessible */ - -/*TE ~ 200 bytes*/ + pddt->ddt_descflags &= ~DF_NOACCESS; /* set drive to accessible */ - getbyte(&((((BYTE *) & DiskTransferBuffer[BT_BPB]))[BPB_NSECTOR]), &pbpbarray->bpb_nsector); - getword(&((((BYTE *) & DiskTransferBuffer[BT_BPB]))[BPB_NRESERVED]), &pbpbarray->bpb_nreserved); - getbyte(&((((BYTE *) & DiskTransferBuffer[BT_BPB]))[BPB_NFAT]), &pbpbarray->bpb_nfat); - getword(&((((BYTE *) & DiskTransferBuffer[BT_BPB]))[BPB_NDIRENT]), &pbpbarray->bpb_ndirent); - getword(&((((BYTE *) & DiskTransferBuffer[BT_BPB]))[BPB_NSIZE]), &pbpbarray->bpb_nsize); - getbyte(&((((BYTE *) & DiskTransferBuffer[BT_BPB]))[BPB_MDESC]), &pbpbarray->bpb_mdesc); - getword(&((((BYTE *) & DiskTransferBuffer[BT_BPB]))[BPB_NFSECT]), &pbpbarray->bpb_nfsect); - getword(&((((BYTE *) & DiskTransferBuffer[BT_BPB]))[BPB_NSECS]), &pbpbarray->bpb_nsecs); - getword(&((((BYTE *) & DiskTransferBuffer[BT_BPB]))[BPB_NHEADS]), &pbpbarray->bpb_nheads); - getlong(&((((BYTE *) & DiskTransferBuffer[BT_BPB])[BPB_HIDDEN])), &pbpbarray->bpb_hidden); - getlong(&((((BYTE *) & DiskTransferBuffer[BT_BPB])[BPB_HUGE])), &pbpbarray->bpb_huge); +/*TE ~ 200 bytes*/ + fmemcpy(pbpbarray, &DiskTransferBuffer[BT_BPB], sizeof(bpb)); - -/* Needs fat32 offset code */ - +#ifdef WITHFAT32 + /*??*/ + /* 2b is fat16 volume label. if memcmp, then offset 0x36. + if (fstrncmp((BYTE *) & DiskTransferBuffer[0x36], "FAT16",5) == 0 || + fstrncmp((BYTE *) & DiskTransferBuffer[0x36], "FAT12",5) == 0) { + TE: I'm not sure, what the _real_ decision point is, however MSDN + 'A_BF_BPB_SectorsPerFAT + The number of sectors per FAT. + Note: This member will always be zero in a FAT32 BPB. + Use the values from A_BF_BPB_BigSectorsPerFat... + */ + if (pbpbarray->bpb_nfsect != 0) + { + /* FAT16/FAT12 boot sector */ + getlong(&((((BYTE *) & DiskTransferBuffer[0x27])[0])), &pddt->ddt_serialno); + memcpy(pddt->ddt_volume,&DiskTransferBuffer[0x2B], 11); + memcpy(pddt->ddt_fstype,&DiskTransferBuffer[0x36], 8); + } else { + /* FAT32 boot sector */ + getlong(&((((BYTE *) & DiskTransferBuffer[0x43])[0])), &pddt->ddt_serialno); + memcpy(pddt->ddt_volume,&DiskTransferBuffer[0x47], 11); + memcpy(pddt->ddt_fstype,&DiskTransferBuffer[0x52], 8); + pbpbarray->bpb_ndirent = 512; + } +#else getlong(&((((BYTE *) & DiskTransferBuffer[0x27])[0])), &pddt->ddt_serialno); - memcpy(pddt->ddt_volume,&DiskTransferBuffer[0x2B], 11); memcpy(pddt->ddt_fstype,&DiskTransferBuffer[0x36], 8); +#endif @@ -503,9 +560,7 @@ STATIC WORD bldbpb(rqptr rp, ddt *pddt) printf("BPB_MDESC = %02x\n", pbpbarray->bpb_mdesc); printf("BPB_NFSECT = %04x\n", pbpbarray->bpb_nfsect); #endif - rp->r_bpptr = pbpbarray; - count = pbpbarray->bpb_nsize == 0 ? pbpbarray->bpb_huge : @@ -518,7 +573,7 @@ STATIC WORD bldbpb(rqptr rp, ddt *pddt) tmark(); return failure(E_FAILURE); } - pddt->ddt_ncyl = count / (head * sector); + pddt->ddt_ncyl = (count + head * sector - 1) / (head * sector); tmark(); #ifdef DSK_DEBUG @@ -527,6 +582,19 @@ STATIC WORD bldbpb(rqptr rp, ddt *pddt) printf("BPB_HIDDEN = %08lx\n", pbpbarray->bpb_hidden); printf("BPB_HUGE = %08lx\n", pbpbarray->bpb_huge); #endif + + return 0; +} + + +STATIC WORD bldbpb(rqptr rp, ddt *pddt) +{ + WORD result; + + if ((result = getbpb(pddt)) != 0) + return result; + + rp->r_bpptr = &pddt->ddt_bpb; return S_DONE; } @@ -553,14 +621,22 @@ STATIC WORD Genblkdev(rqptr rp,ddt *pddt) { int ret; bpb FAR *pbpb; +#ifdef WITHFAT32 + int extended = 0; - switch(rp->r_count){ - case 0x0860: /* get device parameters */ + if ((rp->r_count >> 8) == 0x48) extended = 1; + else +#endif + if ((rp->r_count >> 8) != 8) + return failure(E_CMD); + + switch(rp->r_count & 0xff){ + case 0x60: /* get device parameters */ { struct gblkio FAR * gblp = (struct gblkio FAR *) rp->r_trans; REG COUNT x = 5,y = 1,z = 0; - if (!hd(pddt->ddt_driveno)){ + if (!hd(pddt->ddt_descflags)){ y = 2; x = 8; /* any odd ball drives return this */ switch(pddt->ddt_bpb.bpb_nsize) @@ -590,57 +666,57 @@ STATIC WORD Genblkdev(rqptr rp,ddt *pddt) gblp->gbio_ncyl = pddt->ddt_ncyl; /* use default dpb or current bpb? */ pbpb = (gblp->gbio_spcfunbit & 0x01) == 0 ? &pddt->ddt_defbpb : &pddt->ddt_bpb; +#ifdef WITHFAT32 + if (!extended) fmemcpy(&gblp->gbio_bpb, pbpb, BPB_SIZEOF); + else +#endif fmemcpy(&gblp->gbio_bpb, pbpb, sizeof(gblp->gbio_bpb)); - gblp->gbio_spcfunbit |= 0x04; /* bit 2 set if all sectors in track same size (should be set) */ gblp->gbio_nsecs = pbpb->bpb_nsector; break; } - case 0x0866: /* get volume serial number */ + case 0x66: /* get volume serial number */ { struct Gioc_media FAR * gioc = (struct Gioc_media FAR *) rp->r_trans; - struct FS_info FAR * fs = (struct FS_info FAR *) &DiskTransferBuffer[0x27]; - ret = RWzero( rp, 0); + ret = getbpb(pddt); if (ret != 0) - return (dskerr(ret)); + return (ret); - gioc->ioc_serialno = fs->serialno; - pddt->ddt_serialno = fs->serialno; - - fmemcpy(pddt->ddt_volume, fs->volume,11); - fmemcpy(pddt->ddt_volume, fs->fstype,8); + gioc->ioc_serialno = pddt->ddt_serialno; fmemcpy(gioc->ioc_volume, pddt->ddt_volume,11); fmemcpy(gioc->ioc_fstype, pddt->ddt_fstype,8); } break; - case 0x0846: /* set volume serial number */ + case 0x46: /* set volume serial number */ { struct Gioc_media FAR * gioc = (struct Gioc_media FAR *) rp->r_trans; - struct FS_info FAR * fs = (struct FS_info FAR *) &DiskTransferBuffer[0x27]; - - ret = RWzero( rp, 0); + struct FS_info FAR * fs; + + ret = getbpb(pddt); if (ret != 0) - return (dskerr(ret)); + return (ret); + fs = (struct FS_info FAR *) &DiskTransferBuffer + [(pddt->ddt_bpb.bpb_nfsect != 0 ? 0x27 : 0x43)]; fs->serialno = gioc->ioc_serialno; pddt->ddt_serialno = fs->serialno; - ret = RWzero( rp, 1); + ret = RWzero(pddt, LBA_WRITE); if (ret != 0) return (dskerr(ret)); } break; - case 0x0867: /* get access flag */ + case 0x67: /* get access flag */ { struct Access_info FAR * ai = (struct Access_info FAR *) rp->r_trans; - ai->AI_Flag = pddt->ddt_descflags & 0x200 ? 0 : 1; /* bit 9 */ + ai->AI_Flag = pddt->ddt_descflags & DF_NOACCESS ? 0 : 1; /* bit 9 */ } break; - case 0x0847: /* set access flag */ + case 0x47: /* set access flag */ { struct Access_info FAR * ai = (struct Access_info FAR *) rp->r_trans; - pddt->ddt_descflags &= ~0x200; - pddt->ddt_descflags |= (ai->AI_Flag ? 0 : 0x200); + pddt->ddt_descflags &= ~DF_NOACCESS; + pddt->ddt_descflags |= (ai->AI_Flag ? 0 : DF_NOACCESS); } break; default: @@ -671,7 +747,7 @@ WORD blockio(rqptr rp, ddt *pddt) tmark(); start = (rp->r_start != HUGECOUNT ? rp->r_start : rp->r_huge); - pbpb = hd(pddt->ddt_driveno) ? &pddt->ddt_defbpb : &pddt->ddt_bpb; + pbpb = hd(pddt->ddt_descflags) ? &pddt->ddt_defbpb : &pddt->ddt_bpb; size = (pbpb->bpb_nsize ? pbpb->bpb_nsize : pbpb->bpb_huge); if (start >= size || @@ -822,6 +898,9 @@ int LBA_Transfer(ddt *pddt ,UWORD mode, VOID FAR *buffer, int num_retries; + /* optionally change from A: to B: or back */ + play_dj(pddt); + *transferred = 0; /* @@ -908,7 +987,7 @@ int LBA_Transfer(ddt *pddt ,UWORD mode, VOID FAR *buffer, error_code = (mode == LBA_READ ? fl_read : fl_write)( pddt->ddt_driveno, - chs.Head, chs.Cylinder, chs.Sector, + chs.Head, (UWORD)chs.Cylinder, chs.Sector, count, transfer_address); if (error_code == 0 && @@ -916,7 +995,7 @@ int LBA_Transfer(ddt *pddt ,UWORD mode, VOID FAR *buffer, { error_code = fl_verify( pddt->ddt_driveno, - chs.Head, chs.Cylinder, chs.Sector, + chs.Head, (UWORD)chs.Cylinder, chs.Sector, count, transfer_address); } } diff --git a/kernel/dyndata.c b/kernel/dyndata.c index 20aaad9c..63888960 100644 --- a/kernel/dyndata.c +++ b/kernel/dyndata.c @@ -10,4 +10,4 @@ #include "init-mod.h" #include "dyndata.h" -struct DynS Dyn; +struct DynS Dyn = {0}; diff --git a/kernel/dyndata.h b/kernel/dyndata.h index fb61dc3f..fa306168 100644 --- a/kernel/dyndata.h +++ b/kernel/dyndata.h @@ -15,5 +15,5 @@ void DynFree(void *ptr); struct DynS { unsigned Allocated; - char Buffer[0]; + char Buffer[1]; }; diff --git a/kernel/dyninit.c b/kernel/dyninit.c index 2d90efac..a6bb222e 100644 --- a/kernel/dyninit.c +++ b/kernel/dyninit.c @@ -39,7 +39,7 @@ kernel layout: */ #include "portab.h" #include "init-mod.h" -#include "dyndata.h" +#include "dyndata.h" #if defined(DEBUG) #define DebugPrintf(x) printf x @@ -48,7 +48,16 @@ kernel layout: #endif -extern struct DynS FAR Dyn; +/*extern struct DynS FAR Dyn;*/ + +#ifndef __TURBOC__ + #include "init-dat.h" + extern struct DynS DOSFAR Dyn; +#else + extern struct DynS FAR Dyn; +#endif + + void far *DynAlloc(char *what, unsigned num, unsigned size) { @@ -57,7 +66,7 @@ void far *DynAlloc(char *what, unsigned num, unsigned size) #ifndef DEBUG UNREFERENCED_PARAMETER(what); #endif - + if ((ULONG)total + Dyn.Allocated > 0xffff) { printf("PANIC:Dyn %lu\n", (ULONG)total + Dyn.Allocated); diff --git a/kernel/entry.asm b/kernel/entry.asm index 27d59047..30a8914d 100644 --- a/kernel/entry.asm +++ b/kernel/entry.asm @@ -28,6 +28,9 @@ ; $Id$ ; ; $Log$ +; Revision 1.14 2001/09/23 20:39:44 bartoldeman +; FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling +; ; Revision 1.13 2001/04/21 22:32:53 bartoldeman ; Init DS=Init CS, fixed stack overflow problems and misc bugs. ; @@ -111,10 +114,6 @@ segment HMA_TEXT extern _MachineId:wrt DGROUP extern critical_sp:wrt DGROUP - extern _api_sp:wrt DGROUP ; api stacks - for context - extern _api_ss:wrt DGROUP ; switching - extern _usr_sp:wrt DGROUP ; user stacks - extern _usr_ss:wrt DGROUP extern int21regs_seg:wrt DGROUP extern int21regs_off:wrt DGROUP @@ -487,33 +486,28 @@ int2526: mov bx, DGROUP mov ds, bx - ; save away foreground process' stack - push word [_usr_ss] - push word [_usr_sp] - - mov word [_usr_ss],ss - mov word [_usr_sp],sp - ; setup our local stack cli mov ss,bx mov sp,_disk_api_tos sti + push dx + push cx ; save user stack + push dx ; SS:SP -> user stack push cx push ax ; was set on entry = 25,26 call _int2526_handler - add sp, byte 4 + add sp, byte 6 + pop cx + pop dx ; restore user stack ; restore foreground stack here cli - mov ss,word [_usr_ss] - mov sp,word [_usr_sp] - - pop word [_usr_sp] - pop word [_usr_ss] + mov ss, dx + mov sp, cx pop es pop ds @@ -593,10 +587,6 @@ CritErr05: push word [_MachineId] push word [int21regs_seg] push word [int21regs_off] - push word [_api_sp] - push word [_api_ss] - push word [_usr_sp] - push word [_usr_ss] push word [_user_r+2] push word [_user_r] mov [critical_sp],sp @@ -626,10 +616,6 @@ CritErr05: mov sp,[critical_sp] pop word [_user_r] pop word [_user_r+2] - pop word [_usr_ss] - pop word [_usr_sp] - pop word [_api_ss] - pop word [_api_sp] pop word [int21regs_off] pop word [int21regs_seg] pop word [_MachineId] diff --git a/kernel/fatdir.c b/kernel/fatdir.c index c3fe2d97..50b3c306 100644 --- a/kernel/fatdir.c +++ b/kernel/fatdir.c @@ -36,6 +36,9 @@ static BYTE *fatdirRcsId = "$Id$"; /* * $Log$ + * Revision 1.23 2001/09/23 20:39:44 bartoldeman + * FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling + * * Revision 1.22 2001/08/19 12:58:36 bartoldeman * Time and date fixes, Ctrl-S/P, findfirst/next, FCBs, buffers, tsr unloading * @@ -280,6 +283,18 @@ f_node_ptr dir_open(BYTE * dirname) /* Set the root flags since we always start from the root */ fnp->f_flags.f_droot = TRUE; +#ifdef WITHFAT32 + if (ISFAT32(fnp->f_dpb)) { + fnp->f_flags.f_droot = FALSE; + fnp->f_flags.f_ddir = TRUE; + fnp->f_offset = 0l; + fnp->f_cluster_offset = 0l; + fnp->f_highwater = 0l; + fnp->f_cluster = fnp->f_dpb->dpb_xrootclst; + fnp->f_dirstart = fnp->f_dpb->dpb_xrootclst; + } +#endif + for (p = pszPath; *p != '\0';) { /* skip all path seperators */ @@ -349,8 +364,8 @@ f_node_ptr dir_open(BYTE * dirname) fnp->f_offset = 0l; fnp->f_cluster_offset = 0l; /*JPP */ fnp->f_highwater = 0l; - fnp->f_cluster = fnp->f_dir.dir_start; - fnp->f_dirstart = fnp->f_dir.dir_start; + fnp->f_cluster = getdstart(fnp->f_dir); + fnp->f_dirstart = fnp->f_cluster; /* reset the directory flags */ fnp->f_diroff = 0l; fnp->f_flags.f_dmod = FALSE; @@ -474,7 +489,7 @@ COUNT dir_read(REG f_node_ptr fnp) /* Update the fnode's directory info */ fnp->f_flags.f_dfull = FALSE; fnp->f_flags.f_dmod = FALSE; - + /* and for efficiency, stop when we hit the first */ /* unused entry. */ if (fnp->f_dir.dir_name[0] == '\0') @@ -564,6 +579,9 @@ COUNT dir_write(REG f_node_ptr fnp) release_f_node(fnp); return 0; } + + if (fnp->f_flags.f_dnew && fnp->f_dir.dir_attrib != D_LFN) + fmemset(&fnp->f_dir.dir_case, 0, 8); putdirent((struct dirent FAR *)&fnp->f_dir, (VOID FAR *) & bp->b_buffer[(UWORD)fnp->f_diroff % fnp->f_dpb->dpb_secsize]); @@ -690,8 +708,7 @@ COUNT dos_findfirst(UCOUNT attr, BYTE *name) /* Test the attribute and return first found */ if ((fnp->f_dir.dir_attrib & ~(D_RDONLY | D_ARCHIVE)) == D_VOLID) { - dmp->dm_dirstart= fnp->f_dirstart; - dmp->dm_cluster = fnp->f_dir.dir_start; /* TE */ + dmp->dm_dircluster = fnp->f_dirstart; /* TE */ memcpy(&SearchDir, &fnp->f_dir, sizeof(struct dirent)); dir_close(fnp); return SUCCESS; @@ -708,15 +725,9 @@ COUNT dos_findfirst(UCOUNT attr, BYTE *name) { dmp->dm_entry = 0; if (!fnp->f_flags.f_droot) - { - dmp->dm_cluster = fnp->f_dirstart; - dmp->dm_dirstart = fnp->f_dirstart; - } + dmp->dm_dircluster = fnp->f_dirstart; else - { - dmp->dm_cluster = 0; - dmp->dm_dirstart = 0; - } + dmp->dm_dircluster = 0; dir_close(fnp); return dos_findnext(); } @@ -772,11 +783,14 @@ COUNT dos_findnext(void) } fnp->f_offset = fnp->f_diroff; - - fnp->f_dirstart = - fnp->f_dir.dir_start = - fnp->f_cluster = - dmp->dm_dirstart; + + fnp->f_dir.dir_start = dmp->dm_dircluster; +#ifdef WITHFAT32 + fnp->f_dir.dir_start_high = dmp->dm_dircluster >> 16; +#endif + + fnp->f_cluster = fnp->f_dirstart = + dmp->dm_dircluster; fnp->f_flags.f_droot = fnp->f_dirstart == 0; fnp->f_flags.f_ddir = TRUE; @@ -790,7 +804,8 @@ COUNT dos_findnext(void) while (dir_read(fnp) == DIRENT_SIZE) { ++dmp->dm_entry; - if (fnp->f_dir.dir_name[0] != '\0' && fnp->f_dir.dir_name[0] != DELETED) + if (fnp->f_dir.dir_name[0] != '\0' && fnp->f_dir.dir_name[0] != DELETED + && (fnp->f_dir.dir_attrib & D_VOLID) != D_VOLID ) { if (fcmp_wild((BYTE FAR *)dmp->dm_name_pat, (BYTE FAR *)fnp->f_dir.dir_name, FNAME_SIZE + FEXT_SIZE)) { @@ -817,8 +832,7 @@ COUNT dos_findnext(void) /* If found, transfer it to the dmatch structure */ if (found) { - dmp->dm_dirstart= fnp->f_dirstart; - dmp->dm_cluster = fnp->f_dir.dir_start; /* TE */ + dmp->dm_dircluster = fnp->f_dirstart; memcpy(&SearchDir, &fnp->f_dir, sizeof(struct dirent)); } @@ -891,5 +905,4 @@ int FileName83Length(BYTE *filename83) ConvertName83ToNameSZ(buff, filename83); return strlen(buff); - } diff --git a/kernel/fatfs.c b/kernel/fatfs.c index 66ab7459..28b26236 100644 --- a/kernel/fatfs.c +++ b/kernel/fatfs.c @@ -47,6 +47,9 @@ BYTE *RcsId = "$Id$"; * performance killer on large drives. (~0.5 sec /dos_mkdir) TE * * $Log$ + * Revision 1.24 2001/09/23 20:39:44 bartoldeman + * FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling + * * Revision 1.23 2001/08/19 12:58:36 bartoldeman * Time and date fixes, Ctrl-S/P, findfirst/next, FCBs, buffers, tsr unloading * @@ -267,7 +270,7 @@ STATIC void copy_file_changes(f_node_ptr src, f_node_ptr dst); date dos_getdate(VOID); time dos_gettime(VOID); BOOL find_free(f_node_ptr); -UWORD find_fat_free(f_node_ptr); +CLUSTER find_fat_free(f_node_ptr); VOID wipe_out(f_node_ptr); BOOL last_link(f_node_ptr); BOOL extend(f_node_ptr); @@ -318,9 +321,6 @@ COUNT dos_open(BYTE * path, COUNT flag) fnp->f_highwater = fnp->f_dir.dir_size; fnp->f_back = LONG_LAST_CLUSTER; -/* /// Moved to below. - Ron Cemer - fnp->f_cluster = fnp->f_dir.dir_start; - fnp->f_cluster_offset = 0l; */ /*JPP */ fnp->f_flags.f_dmod = FALSE; fnp->f_flags.f_dnew = FALSE; @@ -329,7 +329,7 @@ COUNT dos_open(BYTE * path, COUNT flag) merge_file_changes(fnp, TRUE); /* /// Added - Ron Cemer */ /* /// Moved from above. - Ron Cemer */ - fnp->f_cluster = fnp->f_dir.dir_start; + fnp->f_cluster = getdstart(fnp->f_dir); fnp->f_cluster_offset = 0l; /*JPP */ return xlt_fnp(fnp); @@ -488,6 +488,55 @@ STATIC BOOL find_fname(f_node_ptr fnp, BYTE * fname, BYTE * fext) return found; } +/* STATIC BOOL find_full_fname(f_node_ptr fnp, f_node_ptr lfnp, BYTE * fname, + BYTE * fext) +{ + BOOL found = FALSE; + + lfnp->f_cluster = LONG_LAST_CLUSTER; + while (dir_read(fnp) == DIRENT_SIZE) + { + if (fnp->f_dir.dir_name[0] != '\0') + { + if (fnp->f_dir.dir_name[0] == DELETED) + continue; + + if (fnp->f_dir.dir_attrib != 0xf) lfnp->f_cluster = LONG_LAST_CLUSTER; + else if (lfnp->f_cluster == LONG_LAST_CLUSTER) + memcpy(lfnp, struct fnp, sizeof(f_node)); + + if (fcmp(fname, (BYTE *)fnp->f_dir.dir_name, FNAME_SIZE) + && fcmp(fext, (BYTE *)fnp->f_dir.dir_ext, FEXT_SIZE) + && ((fnp->f_dir.dir_attrib & D_VOLID) == 0)) + { + found = TRUE; + break; + } + } + } + return found; +} */ + +/* input: fnp with valid non-LFN directory entry, not equal to '..' or +'.' */ +void remove_lfn_entries(f_node_ptr fnp) +{ + ULONG original_diroff = fnp->f_diroff; + while (TRUE) { + if(fnp->f_diroff == 0) break; + fnp->f_diroff -= 2*DIRENT_SIZE; + /* it cannot / should not get below 0 because of '.' and '..' + but maybe add another check for robustness */ + dir_read(fnp); + if (fnp->f_dir.dir_attrib != D_LFN) + break; + fnp->f_dir.dir_name[0] = DELETED; + fnp->f_flags.f_dmod = TRUE; + dir_write(fnp); + } + fnp->f_diroff = original_diroff - DIRENT_SIZE; + dir_read(fnp); +} /* /// Added - Ron Cemer */ /* If more than one f_node has a file open, and a write occurs, this function must be called to propagate the @@ -551,6 +600,9 @@ STATIC int is_same_file(f_node_ptr fnp1, f_node_ptr fnp2) { STATIC void copy_file_changes(f_node_ptr src, f_node_ptr dst) { dst->f_highwater = src->f_highwater; dst->f_dir.dir_start = src->f_dir.dir_start; +#ifdef WITHFAT32 + dst->f_dir.dir_start_high = src->f_dir.dir_start_high; +#endif dst->f_dir.dir_size = src->f_dir.dir_size; dst->f_dir.dir_date = src->f_dir.dir_date; dst->f_dir.dir_time = src->f_dir.dir_time; @@ -631,7 +683,7 @@ COUNT dos_creat(BYTE * path, COUNT attrib) fnp->f_mode = RDWR; fnp->f_dir.dir_size = 0l; - fnp->f_dir.dir_start = FREE; + setdstart(fnp->f_dir, FREE); fnp->f_dir.dir_attrib = attrib | D_ARCHIVE; fnp->f_dir.dir_time = dos_gettime(); fnp->f_dir.dir_date = dos_getdate(); @@ -651,7 +703,8 @@ COUNT dos_creat(BYTE * path, COUNT attrib) fnp->f_highwater = 0l; fnp->f_back = LONG_LAST_CLUSTER; - fnp->f_cluster = fnp->f_dir.dir_start = FREE; + fnp->f_cluster = FREE; + setdstart(fnp->f_dir, FREE); fnp->f_cluster_offset = 0l; /*JPP */ fnp->f_flags.f_dmod = TRUE; fnp->f_flags.f_ddate = FALSE; @@ -691,6 +744,7 @@ COUNT dos_delete(BYTE * path) /* Ok, so we can delete. Start out by */ /* clobbering all FAT entries for this file */ /* (or, in English, truncate the FAT). */ + remove_lfn_entries(fnp); wipe_out(fnp); fnp->f_dir.dir_size = 0l; *(fnp->f_dir.dir_name) = DELETED; @@ -745,11 +799,11 @@ COUNT dos_rmdir(BYTE * path) has many 'archive' directories we still don't allow RDONLY directories to be deleted TE*/ - if (fnp->f_dir.dir_attrib & ~(D_DIR |D_HIDDEN|D_ARCHIVE|D_SYSTEM)) +/* if (fnp->f_dir.dir_attrib & ~(D_DIR |D_HIDDEN|D_ARCHIVE|D_SYSTEM)) { dir_close(fnp); return DE_ACCESS; - } + } */ /* Check that the directory is empty. Only the */ /* "." and ".." are permissable. */ @@ -776,7 +830,7 @@ COUNT dos_rmdir(BYTE * path) { if (fnp1->f_dir.dir_name[0] == '\0') break; - if (fnp1->f_dir.dir_name[0] == DELETED) + if (fnp1->f_dir.dir_name[0] == DELETED || fnp1->f_dir.dir_attrib == D_LFN) continue; else { @@ -796,6 +850,7 @@ COUNT dos_rmdir(BYTE * path) /* Ok, so we can delete. Start out by */ /* clobbering all FAT entries for this file */ /* (or, in English, truncate the FAT). */ + remove_lfn_entries(fnp); wipe_out(fnp); fnp->f_dir.dir_size = 0l; *(fnp->f_dir.dir_name) = DELETED; @@ -880,6 +935,7 @@ COUNT dos_rename(BYTE * path1, BYTE * path2) return ret; } } + remove_lfn_entries(fnp1); /* put the fnode's name into the directory. */ bcopy(szFileName, (BYTE *)fnp2->f_dir.dir_name, FNAME_SIZE); @@ -888,6 +944,9 @@ COUNT dos_rename(BYTE * path1, BYTE * path2) /* Set the fnode to the desired mode */ fnp2->f_dir.dir_size = fnp1->f_dir.dir_size; fnp2->f_dir.dir_start = fnp1->f_dir.dir_start; +#ifdef WITHFAT32 + fnp2->f_dir.dir_start_high = fnp1->f_dir.dir_start_high; +#endif fnp2->f_dir.dir_attrib = fnp1->f_dir.dir_attrib; fnp2->f_dir.dir_time = fnp1->f_dir.dir_time; fnp2->f_dir.dir_date = fnp1->f_dir.dir_date; @@ -916,22 +975,18 @@ COUNT dos_rename(BYTE * path1, BYTE * path2) /* */ STATIC VOID wipe_out(f_node_ptr fnp) { - REG UWORD st, + REG CLUSTER st, next; struct dpb FAR *dpbp = fnp->f_dpb; - + /* if already free or not valid file, just exit */ - if ((fnp == NULL) || (fnp->f_dir.dir_start == FREE)) - return; - - /* if there are no FAT entries, just exit */ - if (fnp->f_dir.dir_start == FREE) + if ((fnp == NULL) || checkdstart(fnp->f_dir, FREE)) return; /* Loop from start until either a FREE entry is */ /* encountered (due to a fractured file system) of the */ /* last cluster is encountered. */ - for (st = fnp->f_dir.dir_start; + for (st = getdstart(fnp->f_dir); st != LONG_LAST_CLUSTER;) { /* get the next cluster pointed to */ @@ -952,6 +1007,9 @@ STATIC VOID wipe_out(f_node_ptr fnp) /* and just follow the linked list */ st = next; } +#ifdef WITHFAT32 + if (ISFAT32(dpbp)) write_fsinfo(dpbp); +#endif } STATIC BOOL find_free(f_node_ptr fnp) @@ -1139,9 +1197,9 @@ BOOL dos_setfsize(COUNT fd, LONG size) /* */ /* Find free cluster in disk FAT table */ /* */ -STATIC UWORD find_fat_free(f_node_ptr fnp) +STATIC CLUSTER find_fat_free(f_node_ptr fnp) { - REG UWORD idx; + REG CLUSTER idx; #ifdef DISPLAY_GETBLOCK printf("[find_fat_free]\n"); @@ -1152,6 +1210,7 @@ STATIC UWORD find_fat_free(f_node_ptr fnp) else idx = 2; + /* Search the FAT table looking for the first free */ /* entry. */ for (; idx <= fnp->f_dpb->dpb_size; idx++) @@ -1164,6 +1223,9 @@ STATIC UWORD find_fat_free(f_node_ptr fnp) if (idx > fnp->f_dpb->dpb_size) { fnp->f_dpb->dpb_cluster = UNKNCLUSTER; +#ifdef WITHFAT32 + if (ISFAT32(fnp->f_dpb)) write_fsinfo(fnp->f_dpb); +#endif dir_close(fnp); return LONG_LAST_CLUSTER; } @@ -1173,6 +1235,9 @@ STATIC UWORD find_fat_free(f_node_ptr fnp) /* return the free entry */ fnp->f_dpb->dpb_cluster = idx; +#ifdef WITHFAT32 + if (ISFAT32(fnp->f_dpb)) write_fsinfo(fnp->f_dpb); +#endif return idx; } @@ -1185,8 +1250,7 @@ COUNT dos_mkdir(BYTE * dir) REG f_node_ptr fnp; REG COUNT idx; struct buffer FAR *bp; - UWORD free_fat; - UWORD parent; + CLUSTER free_fat, parent; COUNT ret; /* first split the passed dir into comopnents (i.e. - */ @@ -1274,7 +1338,6 @@ COUNT dos_mkdir(BYTE * dir) fnp->f_back = LONG_LAST_CLUSTER; fnp->f_dir.dir_size = 0l; - fnp->f_dir.dir_start = FREE; fnp->f_dir.dir_attrib = D_DIR; fnp->f_dir.dir_time = dos_gettime(); fnp->f_dir.dir_date = dos_getdate(); @@ -1288,8 +1351,9 @@ COUNT dos_mkdir(BYTE * dir) /* Mark the cluster in the FAT as used */ - fnp->f_dir.dir_start = fnp->f_cluster = free_fat; - link_fat(fnp->f_dpb, (UCOUNT) free_fat, LONG_LAST_CLUSTER); + fnp->f_cluster = free_fat; + setdstart(fnp->f_dir, free_fat); + link_fat(fnp->f_dpb, free_fat, LONG_LAST_CLUSTER); /* Craft the new directory. Note that if we're in a new */ /* directory just under the root, ".." pointer is 0. */ @@ -1313,7 +1377,7 @@ COUNT dos_mkdir(BYTE * dir) DirEntBuffer.dir_attrib = D_DIR; DirEntBuffer.dir_time = dos_gettime(); DirEntBuffer.dir_date = dos_getdate(); - DirEntBuffer.dir_start = free_fat; + setdstart(DirEntBuffer, free_fat); DirEntBuffer.dir_size = 0l; /* And put it out */ @@ -1321,7 +1385,12 @@ COUNT dos_mkdir(BYTE * dir) /* create the ".." entry */ bcopy(".. ", (BYTE *) DirEntBuffer.dir_name, FNAME_SIZE); - DirEntBuffer.dir_start = parent; +#ifdef WITHFAT32 + if (ISFAT32(fnp->f_dpb) && parent == fnp->f_dpb->dpb_xrootclst) { + parent = 0; + } +#endif + setdstart(DirEntBuffer, parent); /* and put it out */ putdirent((struct dirent FAR *)&DirEntBuffer, (BYTE FAR *) & bp->b_buffer[DIRENT_SIZE]); @@ -1337,7 +1406,7 @@ COUNT dos_mkdir(BYTE * dir) { /* as we are overwriting it completely, don't read first */ - bp = getblockOver((ULONG) clus2phys(fnp->f_dir.dir_start, + bp = getblockOver((ULONG) clus2phys(getdstart(fnp->f_dir), (fnp->f_dpb->dpb_clsmask + 1), fnp->f_dpb->dpb_data) + idx, fnp->f_dpb->dpb_unit); @@ -1366,12 +1435,12 @@ COUNT dos_mkdir(BYTE * dir) BOOL last_link(f_node_ptr fnp) { - return (((UWORD) fnp->f_cluster == (UWORD) LONG_LAST_CLUSTER)); + return (fnp->f_cluster == LONG_LAST_CLUSTER); } STATIC BOOL extend(f_node_ptr fnp) { - UWORD free_fat; + CLUSTER free_fat; #ifdef DISPLAY_GETBLOCK printf("extend\n"); @@ -1386,9 +1455,9 @@ STATIC BOOL extend(f_node_ptr fnp) /* Now that we've found a free FAT entry, mark it as the last */ /* entry and save. */ - link_fat(fnp->f_dpb, (UCOUNT) fnp->f_back, free_fat); + link_fat(fnp->f_dpb, fnp->f_back, free_fat); fnp->f_cluster = free_fat; - link_fat(fnp->f_dpb, (UCOUNT) free_fat, LONG_LAST_CLUSTER); + link_fat(fnp->f_dpb, free_fat, LONG_LAST_CLUSTER); /* Mark the directory so that the entry is updated */ fnp->f_flags.f_dmod = TRUE; @@ -1445,7 +1514,7 @@ STATIC COUNT extend_dir(f_node_ptr fnp) /* JPP: finds the next free cluster in the FAT */ STATIC BOOL first_fat(f_node_ptr fnp) { - UWORD free_fat; + CLUSTER free_fat; /* get an empty cluster, so that we make it into a file. */ free_fat = find_fat_free(fnp); @@ -1459,9 +1528,9 @@ STATIC BOOL first_fat(f_node_ptr fnp) /* entry and save it. */ /* BUG!! this caused wrong allocation, if file was created, then seeked, then written */ - fnp->f_cluster = - fnp->f_dir.dir_start = free_fat; - link_fat(fnp->f_dpb, (UCOUNT) free_fat, LONG_LAST_CLUSTER); + fnp->f_cluster = free_fat; + setdstart(fnp->f_dir, free_fat); + link_fat(fnp->f_dpb, free_fat, LONG_LAST_CLUSTER); /* Mark the directory so that the entry is updated */ fnp->f_flags.f_dmod = TRUE; @@ -1485,12 +1554,13 @@ COUNT map_cluster(REG f_node_ptr fnp, COUNT mode) fnp->f_cluster_offset, fnp->f_offset, fnp->f_offset - fnp->f_cluster_offset); #endif + /* The variable clssize will be used later. */ clssize = (ULONG)fnp->f_dpb->dpb_secsize * (fnp->f_dpb->dpb_clsmask + 1); /* If someone did a seek, but no writes have occured, we will */ /* need to initialize the fnode. */ - if ((mode == XFR_WRITE) && (fnp->f_dir.dir_start == FREE)) + if ((mode == XFR_WRITE) && checkdstart(fnp->f_dir, FREE)) { /* If there are no more free fat entries, then we are full! */ if (!first_fat(fnp)) @@ -1508,7 +1578,7 @@ COUNT map_cluster(REG f_node_ptr fnp, COUNT mode) idx = fnp->f_offset; fnp->f_cluster = fnp->f_flags.f_ddir ? fnp->f_dirstart : - fnp->f_dir.dir_start; + getdstart(fnp->f_dir); fnp->f_cluster_offset = 0; } @@ -1532,7 +1602,6 @@ COUNT map_cluster(REG f_node_ptr fnp, COUNT mode) /* the last cluster marker. */ else if ((mode == XFR_WRITE) && last_link(fnp)) { - if (!extend(fnp)) { dir_close(fnp); @@ -1545,6 +1614,7 @@ COUNT map_cluster(REG f_node_ptr fnp, COUNT mode) fnp->f_cluster = next_cluster(fnp->f_dpb, fnp->f_cluster); fnp->f_cluster_offset += clssize; } + #ifdef DISPLAY_GETBLOCK printf("done.\n"); #endif @@ -1627,7 +1697,7 @@ UCOUNT readblock(COUNT fd, VOID FAR * buffer, UCOUNT count, COUNT * err) /* initializing to the starting cluster and */ /* setting all offsets to zero. */ fnp->f_cluster = fnp->f_flags.f_ddir ? fnp->f_dirstart : - fnp->f_dir.dir_start; + getdstart(fnp->f_dir); fnp->f_cluster_offset = 0l; fnp->f_back = LONG_LAST_CLUSTER; @@ -1679,7 +1749,7 @@ UCOUNT readblock(COUNT fd, VOID FAR * buffer, UCOUNT count, COUNT * err) fnp->f_boff = fnp->f_offset & (secsize - 1); #ifdef DSK_DEBUG - printf("read %d links; dir offset %ld, cluster %d\n", + printf("read %d links; dir offset %ld, cluster %lx\n", fnp->f_count, fnp->f_diroff, fnp->f_cluster); @@ -1853,7 +1923,7 @@ UCOUNT writeblock(COUNT fd, VOID FAR * buffer, UCOUNT count, COUNT * err) /* will have a start cluster of FREE. If we're */ /* doing a write and this is the first time */ /* through, allocate a new cluster to the file. */ - if (fnp->f_dir.dir_start == FREE) + if (checkdstart(fnp->f_dir, FREE)) if (!first_fat(fnp)) /* get a free cluster */ { /* error means disk full */ dir_close(fnp); @@ -1864,7 +1934,7 @@ UCOUNT writeblock(COUNT fd, VOID FAR * buffer, UCOUNT count, COUNT * err) /* initializing to the starting cluster and */ /* setting all offsets to zero. */ fnp->f_cluster = fnp->f_flags.f_ddir ? fnp->f_dirstart : - fnp->f_dir.dir_start; + getdstart(fnp->f_dir); fnp->f_cluster_offset = 0l; fnp->f_back = LONG_LAST_CLUSTER; @@ -2105,12 +2175,12 @@ LONG dos_lseek(COUNT fd, LONG foffset, COUNT origin) } /* returns the number of unused clusters */ -UWORD dos_free(struct dpb FAR *dpbp) +CLUSTER dos_free(struct dpb FAR *dpbp) { /* There's an unwritten rule here. All fs */ /* cluster start at 2 and run to max_cluster+2 */ - REG UWORD i; - REG UWORD cnt = 0; + REG CLUSTER i; + REG CLUSTER cnt = 0; /* UWORD max_cluster = ( ((ULONG) dpbp->dpb_size * * (ULONG) (dpbp->dpb_clsmask + 1) - (dpbp->dpb_data + 1) ) * / (dpbp->dpb_clsmask + 1) ) + 2; @@ -2119,7 +2189,7 @@ UWORD dos_free(struct dpb FAR *dpbp) /*?? UWORD max_cluster = ( ((ULONG) dpbp->dpb_size * (ULONG) (dpbp->dpb_clsmask + 1)) / (dpbp->dpb_clsmask + 1) ) + 1; */ - UWORD max_cluster = dpbp->dpb_size + 1; + CLUSTER max_cluster = dpbp->dpb_size + 1; if (dpbp->dpb_nfreeclst != UNKNCLSTFREE) return dpbp->dpb_nfreeclst; @@ -2131,6 +2201,9 @@ UWORD dos_free(struct dpb FAR *dpbp) ++cnt; } dpbp->dpb_nfreeclst = cnt; +#ifdef WITHFAT32 + if (ISFAT32(dpbp)) write_fsinfo(dpbp); +#endif return cnt; } } @@ -2262,46 +2335,82 @@ COUNT dos_setfattr(BYTE * name, UWORD attrp) } #endif +#ifdef WITHFAT32 +VOID bpb_to_dpb(bpb FAR *bpbp, REG struct dpb FAR * dpbp, BOOL extended) +#else VOID bpb_to_dpb(bpb FAR *bpbp, REG struct dpb FAR * dpbp) +#endif { ULONG size; REG COUNT i; - dpbp->dpb_mdb = bpbp->bpb_mdesc; - dpbp->dpb_secsize = bpbp->bpb_nbyte; - dpbp->dpb_clsmask = bpbp->bpb_nsector - 1; - dpbp->dpb_fatstrt = bpbp->bpb_nreserved; - dpbp->dpb_fats = bpbp->bpb_nfat; - dpbp->dpb_dirents = bpbp->bpb_ndirent; - size = bpbp->bpb_nsize == 0 ? - bpbp->bpb_huge : - (ULONG) bpbp->bpb_nsize; -/* patch point - dpbp->dpb_size = size / ((ULONG) bpbp->bpb_nsector); -*/ - dpbp->dpb_fatsize = bpbp->bpb_nfsect; - dpbp->dpb_dirstrt = dpbp->dpb_fatstrt - + dpbp->dpb_fats * dpbp->dpb_fatsize; - dpbp->dpb_data = dpbp->dpb_dirstrt - + ((DIRENT_SIZE * dpbp->dpb_dirents - + (dpbp->dpb_secsize - 1)) - / dpbp->dpb_secsize); -/* - Michal Meller patch to jimtabor -*/ - dpbp->dpb_size = ((size - dpbp->dpb_data) / ((ULONG) bpbp->bpb_nsector) + 1); - - dpbp->dpb_flags = 0; -/* dpbp->dpb_next = (struct dpb FAR *)-1;*/ - dpbp->dpb_cluster = UNKNCLUSTER; - dpbp->dpb_nfreeclst = UNKNCLSTFREE; /* number of free clusters */ - for (i = 1, dpbp->dpb_shftcnt = 0; - i < (sizeof(dpbp->dpb_shftcnt) * 8); /* 8 bit bytes in C */ - dpbp->dpb_shftcnt++, i <<= 1) - { - if (i >= bpbp->bpb_nsector) - break; - } + dpbp->dpb_mdb = bpbp->bpb_mdesc; + dpbp->dpb_secsize = bpbp->bpb_nbyte; + dpbp->dpb_clsmask = bpbp->bpb_nsector - 1; + dpbp->dpb_fatstrt = bpbp->bpb_nreserved; + dpbp->dpb_fats = bpbp->bpb_nfat; + dpbp->dpb_dirents = bpbp->bpb_ndirent; + size = bpbp->bpb_nsize == 0 ? + bpbp->bpb_huge : + (ULONG) bpbp->bpb_nsize; + dpbp->dpb_wfatsize = bpbp->bpb_nfsect; + dpbp->dpb_dirstrt = dpbp->dpb_fatstrt + + dpbp->dpb_fats * dpbp->dpb_wfatsize; + dpbp->dpb_wdata = dpbp->dpb_dirstrt + + ((DIRENT_SIZE * dpbp->dpb_dirents + + (dpbp->dpb_secsize - 1)) + / dpbp->dpb_secsize); +/* Michal Meller patch to jimtabor */ + dpbp->dpb_wsize = ((size - dpbp->dpb_wdata) + / ((ULONG) bpbp->bpb_nsector) + 1); + dpbp->dpb_flags = 0; + dpbp->dpb_wcluster = UNKNCLUSTER; + /* number of free clusters */ + *((UWORD FAR *)(&dpbp->dpb_nfreeclst)) = UNKNCLSTFREE16; + +#ifdef WITHFAT32 + if (extended) + { + dpbp->dpb_fatsize = bpbp->bpb_nfsect == 0 ? bpbp->bpb_xnfsect + : bpbp->bpb_nfsect; + dpbp->dpb_cluster = UNKNCLUSTER; + dpbp->dpb_nfreeclst = UNKNCLSTFREE; /* number of free clusters */ + + dpbp->dpb_xflags = 0; + dpbp->dpb_xfsinfosec = 0xffff; + dpbp->dpb_xbackupsec = 0xffff; + dpbp->dpb_xrootclst = 0; + dpbp->dpb_size = ((size - (dpbp->dpb_fatstrt + dpbp->dpb_fats + * dpbp->dpb_fatsize)) + / ((ULONG) bpbp->bpb_nsector) + 1); + + if (ISFAT32(dpbp)) + { + dpbp->dpb_xflags = bpbp->bpb_xflags; + dpbp->dpb_xfsinfosec = bpbp->bpb_xfsinfosec; + dpbp->dpb_xbackupsec = bpbp->bpb_xbackupsec; + dpbp->dpb_dirents = 0; + dpbp->dpb_dirstrt = 0xffff; + dpbp->dpb_wsize = 0; + dpbp->dpb_data = dpbp->dpb_fatstrt + dpbp->dpb_fats * dpbp->dpb_fatsize; + dpbp->dpb_xrootclst = bpbp->bpb_xrootclst; + read_fsinfo(dpbp); + } + else + { + dpbp->dpb_data = dpbp->dpb_wdata; + dpbp->dpb_size = dpbp->dpb_wsize; + } + } +#endif + + for (i = 1, dpbp->dpb_shftcnt = 0; + i < (sizeof(dpbp->dpb_shftcnt) * 8); /* 8 bit bytes in C */ + dpbp->dpb_shftcnt++, i <<= 1) + { + if (i >= bpbp->bpb_nsector) + break; + } } COUNT media_check(REG struct dpb FAR * dpbp) @@ -2384,7 +2493,11 @@ COUNT media_check(REG struct dpb FAR * dpbp) } } } +#ifdef WITHFAT32 + bpb_to_dpb(MediaReqHdr.r_bpptr, dpbp, TRUE); +#else bpb_to_dpb(MediaReqHdr.r_bpptr, dpbp); +#endif return SUCCESS; } } @@ -2435,10 +2548,10 @@ STATIC VOID shrink_file(f_node_ptr fnp) #else ULONG lastoffset = fnp->f_offset; /* has to be saved */ - UCOUNT next,st; + CLUSTER next,st; struct dpb FAR *dpbp = fnp->f_dpb; - if (fnp->f_flags.f_ddir) /* can't shrink dirs */ + if (fnp->f_flags.f_ddir || (fnp->f_dir.dir_attrib & D_DIR)) /* can't shrink dirs */ return; fnp->f_offset = fnp->f_highwater; /* end of file */ @@ -2446,17 +2559,17 @@ STATIC VOID shrink_file(f_node_ptr fnp) if (fnp->f_offset) fnp->f_offset--; /* last existing cluster */ if (map_cluster(fnp, XFR_READ) != SUCCESS) /* error, don't truncate */ - goto done; - - - st = fnp->f_cluster; + goto done; - if (st == FREE || st == LONG_LAST_CLUSTER) /* first cluster is free or EOC, done */ + st = fnp->f_cluster; + + /* first cluster is free or EOC */ + if (st == FREE || st == LONG_LAST_CLUSTER) goto done; next = next_cluster(dpbp, st); - if ( next == LONG_LAST_CLUSTER) /* last cluster found */ + if (next == LONG_LAST_CLUSTER) /* last cluster found */ goto done; /* Loop from start until either a FREE entry is */ @@ -2467,7 +2580,7 @@ STATIC VOID shrink_file(f_node_ptr fnp) if (fnp->f_highwater == 0) { - fnp->f_dir.dir_start = FREE; + setdstart(fnp->f_dir, FREE); link_fat(dpbp, st, FREE); } else @@ -2491,12 +2604,14 @@ STATIC VOID shrink_file(f_node_ptr fnp) if ((dpbp->dpb_cluster == UNKNCLUSTER) || (dpbp->dpb_cluster > st)) dpbp->dpb_cluster = st; - } done: fnp->f_offset = lastoffset; /* has to be restored */ - +#ifdef WITHFAT32 + if (ISFAT32(dpbp)) write_fsinfo(dpbp); +#endif + #endif } diff --git a/kernel/fattab.c b/kernel/fattab.c index 095fc20f..19432592 100644 --- a/kernel/fattab.c +++ b/kernel/fattab.c @@ -35,6 +35,9 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.8 2001/09/23 20:39:44 bartoldeman + * FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling + * * Revision 1.7 2001/07/09 22:19:33 bartoldeman * LBA/FCB/FAT/SYS/Ctrl-C/ioctl fixes + memory savings * @@ -111,15 +114,19 @@ static BYTE *RcsId = "$Id$"; */ #ifdef PROTO -UCOUNT link_fat12(struct dpb FAR *, UCOUNT, UCOUNT); -UCOUNT link_fat16(struct dpb FAR *, UCOUNT, UCOUNT); -UWORD next_cl12(struct dpb FAR *, UCOUNT); -UWORD next_cl16(struct dpb FAR *, UCOUNT); +UCOUNT link_fat12(struct dpb FAR *, CLUSTER, CLUSTER); +UCOUNT link_fat16(struct dpb FAR *, CLUSTER, CLUSTER); +UCOUNT link_fat32(struct dpb FAR *, CLUSTER, CLUSTER); +CLUSTER next_cl12(struct dpb FAR *, CLUSTER); +CLUSTER next_cl16(struct dpb FAR *, CLUSTER); +CLUSTER next_cl32(struct dpb FAR *, CLUSTER); #else UCOUNT link_fat12(); UCOUNT link_fat16(); -UWORD next_cl12(); -UWORD next_cl16(); +UCOUNT link_fat32(); +CLUSTER next_cl12(); +CLUSTER next_cl16(); +CLUSTER next_cl32(); #endif /************************************************************************/ @@ -128,33 +135,87 @@ UWORD next_cl16(); /* */ /************************************************************************/ -struct buffer FAR *getFATblock(UWORD cluster, struct dpb FAR *dpbp) +#ifndef ISFAT32 +int ISFAT32(struct dpb FAR *dpbp) +{ + return _ISFAT32(dpbp); +} +#endif + + +struct buffer FAR *getFATblock(CLUSTER cluster, struct dpb FAR *dpbp) { ULONG sector; struct buffer FAR *bp; - + if (ISFAT12(dpbp)) { sector = ((cluster << 1) + cluster) >> 1; - } - else /* FAT16 */ + } +#ifdef WITHFAT32 + else if (ISFAT32(dpbp)) + { + sector = (ULONG)cluster * SIZEOF_CLST32; + } +#endif + else { sector = (ULONG)cluster * SIZEOF_CLST16; } sector = sector / dpbp->dpb_secsize + dpbp->dpb_fatstrt; +#ifdef WITHFAT32 + if (ISFAT32(dpbp) && (dpbp->dpb_xflags & FAT_NO_MIRRORING)) { + /* we must modify the active fat, + it's number is in the 0-3 bits of dpb_xflags */ + sector += (dpbp->dpb_xflags & 0xf) * dpbp->dpb_fatsize; + } +#endif bp = getblock(sector, dpbp->dpb_unit); if (bp) { - bp->b_flag &= ~(BFR_DATA | BFR_DIR); - bp->b_flag |= BFR_FAT | BFR_VALID; - bp->b_copies = dpbp->dpb_fats; - bp->b_offset_lo = dpbp->dpb_fatsize; - bp->b_offset_hi = dpbp->dpb_fatsize >> 8; + bp->b_flag &= ~(BFR_DATA | BFR_DIR); + bp->b_flag |= BFR_FAT | BFR_VALID; + bp->b_copies = dpbp->dpb_fats; +#ifdef WITHFAT32 + if (ISFAT32(dpbp) && (dpbp->dpb_xflags & FAT_NO_MIRRORING)) bp->b_copies = 1; +#endif + bp->b_offset = dpbp->dpb_fatsize; } return bp; } + +#ifdef WITHFAT32 +void read_fsinfo(struct dpb FAR *dpbp) +{ + struct buffer FAR *bp; + struct fsinfo FAR *fip; + + bp = getblock(dpbp->dpb_xfsinfosec, dpbp->dpb_unit); + bp->b_flag &= ~(BFR_DATA | BFR_DIR | BFR_FAT | BFR_DIRTY); + bp->b_flag |= BFR_VALID; + + fip = (struct fsinfo FAR *) & bp->b_buffer[0x1e4]; + dpbp->dpb_nfreeclst = fip->fi_nfreeclst; + dpbp->dpb_cluster = fip->fi_cluster; +} + +void write_fsinfo(struct dpb FAR *dpbp) +{ + struct buffer FAR *bp; + struct fsinfo FAR *fip; + + bp = getblock(dpbp->dpb_xfsinfosec, dpbp->dpb_unit); + bp->b_flag &= ~(BFR_DATA | BFR_DIR | BFR_FAT); + bp->b_flag |= BFR_VALID | BFR_DIRTY; + + fip = (struct fsinfo FAR *) & bp->b_buffer[0x1e4]; + fip->fi_nfreeclst = dpbp->dpb_nfreeclst; + fip->fi_cluster = dpbp->dpb_cluster; +} +#endif + /* */ /* The FAT file system is difficult to trace through FAT table. */ /* There are two kinds of FAT's, 12 bit and 16 bit. The 16 bit */ @@ -171,7 +232,7 @@ struct buffer FAR *getFATblock(UWORD cluster, struct dpb FAR *dpbp) /* 12 bytes are compressed to 9 bytes */ /* */ -UCOUNT link_fat(struct dpb FAR *dpbp, UCOUNT Cluster1, REG UCOUNT Cluster2) +UCOUNT link_fat(struct dpb FAR *dpbp, CLUSTER Cluster1, REG CLUSTER Cluster2) { UCOUNT res; @@ -179,41 +240,76 @@ UCOUNT link_fat(struct dpb FAR *dpbp, UCOUNT Cluster1, REG UCOUNT Cluster2) res = link_fat12(dpbp, Cluster1, Cluster2); else if (ISFAT16(dpbp)) res = link_fat16(dpbp, Cluster1, Cluster2); +#ifdef WITHFAT32 + else if (ISFAT32(dpbp)) + res = link_fat32(dpbp, Cluster1, Cluster2); +#endif else return DE_BLKINVLD; - /* update the free space count */ + /* update the free space count */ if (res == SUCCESS) if (dpbp->dpb_nfreeclst != UNKNCLSTFREE) { if (Cluster2 == FREE) - { - /* update the free space count for returned */ - /* cluster */ - ++dpbp->dpb_nfreeclst; - } + { + /* update the free space count for returned */ + /* cluster */ + ++dpbp->dpb_nfreeclst; + } - /* update the free space count for removed */ + /* update the free space count for removed */ /* cluster */ /* BUG: was counted twice for 2nd,.. cluster. moved to find_fat_free() */ - - /* else { - --dpbp->dpb_nfreeclst; - } - */ - } + + /* else + { + --dpbp->dpb_nfreeclst; + } */ + } +#ifdef WITHFAT32 + if (ISFAT32(dpbp)) write_fsinfo(dpbp); +#endif return res; } -UCOUNT link_fat16(struct dpb FAR *dpbp, UCOUNT Cluster1, UCOUNT Cluster2) +#ifdef WITHFAT32 +UCOUNT link_fat32(struct dpb FAR *dpbp, CLUSTER Cluster1, CLUSTER Cluster2) { UCOUNT idx; struct buffer FAR *bp; /* Get the block that this cluster is in */ - bp = getFATblock( Cluster1, dpbp); + bp = getFATblock(Cluster1, dpbp); + + if (bp == NULL) + return DE_BLKINVLD; + + /* form an index so that we can read the block as a */ + /* byte array */ + idx = (UWORD)((Cluster1 * SIZEOF_CLST32) % dpbp->dpb_secsize); + + /* Finally, put the word into the buffer and mark the */ + /* buffer as dirty. */ + fputlong((DWORD FAR *) & Cluster2, (VOID FAR *) & (bp->b_buffer[idx])); + bp->b_flag |= BFR_DIRTY | BFR_VALID; + + /* Return successful. */ + + return SUCCESS; +} + +#endif + +UCOUNT link_fat16(struct dpb FAR *dpbp, CLUSTER Cluster1, CLUSTER Cluster2) +{ + UCOUNT idx; + struct buffer FAR *bp; + + /* Get the block that this cluster is in */ + bp = getFATblock(Cluster1, dpbp); if (bp == NULL) return DE_BLKINVLD; @@ -232,7 +328,7 @@ UCOUNT link_fat16(struct dpb FAR *dpbp, UCOUNT Cluster1, UCOUNT Cluster2) return SUCCESS; } -UCOUNT link_fat12(struct dpb FAR *dpbp, UCOUNT Cluster1, UCOUNT Cluster2) +UCOUNT link_fat12(struct dpb FAR *dpbp, CLUSTER Cluster1, CLUSTER Cluster2) { REG UBYTE FAR *fbp0, FAR * fbp1; @@ -247,7 +343,7 @@ UCOUNT link_fat12(struct dpb FAR *dpbp, UCOUNT Cluster1, UCOUNT Cluster2) /* form an index so that we can read the block as a */ /* byte array */ - idx = (((Cluster1 << 1) + Cluster1) >> 1) % dpbp->dpb_secsize; + idx = (UCOUNT)(((Cluster1 << 1) + Cluster1) >> 1) % dpbp->dpb_secsize; /* Test to see if the cluster straddles the block. If */ /* it does, get the next block and use both to form the */ @@ -285,19 +381,44 @@ UCOUNT link_fat12(struct dpb FAR *dpbp, UCOUNT Cluster1, UCOUNT Cluster2) /* Given the disk parameters, and a cluster number, this function looks at the FAT, and returns the next cluster in the clain. */ -UWORD next_cluster(struct dpb FAR *dpbp, UCOUNT ClusterNum) +CLUSTER next_cluster(struct dpb FAR *dpbp, CLUSTER ClusterNum) { - if (ISFAT12(dpbp)) + if (ClusterNum == LONG_LAST_CLUSTER) printf("fatal error: trying to do next_cluster(dpbp, EOC)!\n"); + if (ISFAT12(dpbp)) return next_cl12(dpbp, ClusterNum); else if (ISFAT16(dpbp)) return next_cl16(dpbp, ClusterNum); +#ifdef WITHFAT32 + else if (ISFAT32(dpbp)) + return next_cl32(dpbp, ClusterNum); +#endif else return LONG_LAST_CLUSTER; } -UWORD next_cl16(struct dpb FAR *dpbp, UCOUNT ClusterNum) +#ifdef WITHFAT32 +CLUSTER next_cl32(struct dpb FAR *dpbp, CLUSTER ClusterNum) +{ + struct buffer FAR *bp; + UDWORD res; + + /* Get the block that this cluster is in */ + bp = getFATblock(ClusterNum, dpbp); + + if (bp == NULL) + return DE_BLKINVLD; + + res = *(UDWORD FAR *)&(bp->b_buffer[(UCOUNT)((ClusterNum * SIZEOF_CLST32) % dpbp->dpb_secsize)]); + if (res > LONG_BAD) return LONG_LAST_CLUSTER; + + return res; +} +#endif + +CLUSTER next_cl16(struct dpb FAR *dpbp, CLUSTER ClusterNum) { struct buffer FAR *bp; + UWORD res; /* Get the block that this cluster is in */ bp = getFATblock( ClusterNum, dpbp); @@ -307,7 +428,6 @@ UWORD next_cl16(struct dpb FAR *dpbp, UCOUNT ClusterNum) #ifndef I86 UCOUNT idx; - UWORD RetCluster; /* form an index so that we can read the block as a */ /* byte array */ @@ -315,17 +435,17 @@ UWORD next_cl16(struct dpb FAR *dpbp, UCOUNT ClusterNum) /* Get the cluster number, */ - fgetword((VOID FAR *) & (bp->b_buffer[idx]), (WORD FAR *) & RetCluster); + fgetword((VOID FAR *) & (bp->b_buffer[idx]), (WORD FAR *) & res); - /* and return successful. */ - return RetCluster; #else /* this saves 2 WORDS of stack :-) */ - return *(UWORD FAR *)&(bp->b_buffer[(ClusterNum * SIZEOF_CLST16) % dpbp->dpb_secsize]); - + res = *(UWORD FAR *)&(bp->b_buffer[(UCOUNT)((ClusterNum * SIZEOF_CLST16) % dpbp->dpb_secsize)]); #endif - + if ((res & MASK16) == MASK16) return LONG_LAST_CLUSTER; + else if ((res & BAD16) == BAD16) return LONG_BAD; + + return res; } #if 0 @@ -385,7 +505,7 @@ UWORD next_cl12(struct dpb FAR *dpbp, REG UCOUNT ClusterNum) /* new version - 50 byte smaller, saves 10 bytes on stack :-) */ -UWORD next_cl12(struct dpb FAR *dpbp, REG UCOUNT ClusterNum) +CLUSTER next_cl12(struct dpb FAR *dpbp, REG CLUSTER ClusterNum) { union { UBYTE bytes[2]; @@ -403,7 +523,7 @@ UWORD next_cl12(struct dpb FAR *dpbp, REG UCOUNT ClusterNum) /* form an index so that we can read the block as a */ /* byte array */ - idx = (((ClusterNum << 1) + ClusterNum) >> 1) % dpbp->dpb_secsize; + idx = (UCOUNT)(((ClusterNum << 1) + ClusterNum) >> 1) % dpbp->dpb_secsize; clusterbuff.bytes[0] = bp->b_buffer[idx]; @@ -440,10 +560,9 @@ UWORD next_cl12(struct dpb FAR *dpbp, REG UCOUNT ClusterNum) ClusterNum = clusterbuff.word & 0x0fff; #endif - - if ((ClusterNum & MASK) == MASK) + if ((ClusterNum & MASK12) == MASK12) ClusterNum = LONG_LAST_CLUSTER; - else if ((ClusterNum & BAD) == BAD) + else if ((ClusterNum & BAD12) == BAD12) ClusterNum = LONG_BAD; return ClusterNum; } diff --git a/kernel/fcbfns.c b/kernel/fcbfns.c index cdf2b917..5da0c181 100644 --- a/kernel/fcbfns.c +++ b/kernel/fcbfns.c @@ -35,6 +35,9 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.18 2001/09/23 20:39:44 bartoldeman + * FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling + * * Revision 1.17 2001/08/20 20:32:15 bartoldeman * Truename, get free space and ctrl-break fixes. * @@ -177,6 +180,10 @@ VOID FatGetDrvData(UCOUNT drive, COUNT FAR * spc, COUNT FAR * bps, { struct dpb FAR *dpbp; struct cds FAR *cdsp; +#ifdef WITHFAT32 + UCOUNT shift = 0; + ULONG cluster_size, ntotal; +#endif /* first check for valid drive */ *spc = -1; @@ -211,9 +218,23 @@ VOID FatGetDrvData(UCOUNT drive, COUNT FAR * spc, COUNT FAR * bps, return; } +#ifdef WITHFAT32 + cluster_size = (dpbp->dpb_clsmask + 1) * dpbp->dpb_secsize; + ntotal = dpbp->dpb_size - 1; + while (cluster_size <= 0x7fff) { + cluster_size <<= 1; + ntotal >>= 1; + shift++; + } + /* get the data available from dpb */ + if (ntotal > 0xfffe) ntotal = 0xfffe; + *nc = (UCOUNT)ntotal; + *spc = (dpbp->dpb_clsmask + 1) << shift; +#else /* get the data vailable from dpb */ *nc = dpbp->dpb_size - 1; *spc = dpbp->dpb_clsmask + 1; +#endif *bps = dpbp->dpb_secsize; /* Point to the media desctriptor for this drive */ @@ -268,12 +289,12 @@ WORD FcbParseFname(int wTestMode, BYTE FAR ** lpFileName, fcb FAR * lpFcb) if (*(*lpFileName + 1) == ':') { /* non-portable construct to be changed */ - REG UBYTE Drive = DosUpFChar(**lpFileName) - 'A' + 1; + REG UBYTE Drive = DosUpFChar(**lpFileName) - 'A'; if (Drive >= lastdrive) return PARSE_RET_BADDRIVE; - lpFcb->fcb_drive = Drive; + lpFcb->fcb_drive = Drive + 1; *lpFileName += 2; } @@ -744,10 +765,6 @@ BOOL FcbDelete(xfcb FAR * lpXfcb) /* Build a traditional DOS file name */ CommonFcbInit(lpXfcb, SecPathName, &FcbDrive); - if ((UCOUNT)FcbDrive >= lastdrive) { - return DE_INVLDDRV; - } - /* check for a device */ if (IsDevice(SecPathName)) { @@ -952,7 +969,7 @@ BOOL FcbFindFirst(xfcb FAR * lpXfcb) *lpDir++ = FcbDrive; fmemcpy(lpDir, &SearchDir, sizeof(struct dirent)); - lpFcb->fcb_dirclst = Dmatch.dm_dirstart; + lpFcb->fcb_dirclst = (UWORD)Dmatch.dm_dircluster; lpFcb->fcb_strtclst = Dmatch.dm_entry; /* @@ -993,8 +1010,7 @@ BOOL FcbFindNext(xfcb FAR * lpXfcb) Dmatch.dm_attr_srch = wAttr; Dmatch.dm_entry = lpFcb->fcb_strtclst; - Dmatch.dm_cluster = lpFcb->fcb_dirclst; - Dmatch.dm_dirstart= lpFcb->fcb_dirclst; + Dmatch.dm_dircluster = lpFcb->fcb_dirclst; if ((xfcb FAR *) lpFcb != lpXfcb) { @@ -1015,7 +1031,7 @@ BOOL FcbFindNext(xfcb FAR * lpXfcb) *lpDir++ = FcbDrive; fmemcpy((struct dirent FAR *)lpDir, &SearchDir, sizeof(struct dirent)); - lpFcb->fcb_dirclst = Dmatch.dm_dirstart; + lpFcb->fcb_dirclst = (UWORD)Dmatch.dm_dircluster; lpFcb->fcb_strtclst = Dmatch.dm_entry; lpFcb->fcb_sftno = Dmatch.dm_drive; diff --git a/kernel/globals.h b/kernel/globals.h index cf33fde5..d1db37af 100644 --- a/kernel/globals.h +++ b/kernel/globals.h @@ -36,6 +36,9 @@ static BYTE *Globals_hRcsId = "$Id$"; /* * $Log$ + * Revision 1.17 2001/09/23 20:39:44 bartoldeman + * FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling + * * Revision 1.16 2001/08/19 12:58:36 bartoldeman * Time and date fixes, Ctrl-S/P, findfirst/next, FCBs, buffers, tsr unloading * @@ -215,6 +218,7 @@ static BYTE *Globals_hRcsId = "$Id$"; #include "network.h" #include "config.h" #include "buffer.h" +#include "xstructs.h" /* JPP: for testing/debuging disk IO */ /*#define DISPLAY_GETBLOCK */ @@ -288,12 +292,17 @@ static BYTE *Globals_hRcsId = "$Id$"; /* FAT cluster special flags */ #define FREE 0x000 +#ifdef WITHFAT32 +#define LONG_LAST_CLUSTER 0x0FFFFFFFl +#define LONG_BAD 0x0FFFFFF7l +#else #define LONG_LAST_CLUSTER 0xFFFF -#define LONG_MASK 0xFFF8 -#define LONG_BAD 0xFFF0 -#define LAST_CLUSTER 0x0FFF -#define MASK 0xFF8 -#define BAD 0xFF0 +#define LONG_BAD 0xFFF8 +#endif +#define MASK16 0xFFF8 +#define BAD16 0xFFF0 +#define MASK12 0xFF8 +#define BAD12 0xFF0 /* Keyboard buffer maximum size */ #ifdef LINESIZE @@ -314,20 +323,8 @@ FAR clk_dev, /* Clock device driver */ FAR aux_dev, /* Generic aux device driver */ FAR blk_dev; /* Block device (Disk) driver */ extern UWORD - ram_top, /* How much ram in Kbytes */ -#ifdef I86 - - api_sp, /* api stacks - for context */ -#endif - - api_ss, /* switching */ - usr_sp, /* user stack */ - usr_ss; + ram_top; /* How much ram in Kbytes */ extern COUNT * -#ifdef MC68K - api_sp, /* api stacks - for context */ -#endif - error_tos, /* error stack */ disk_api_tos, /* API handler stack - disk fns */ char_api_tos; /* API handler stack - char fns */ @@ -381,29 +378,26 @@ GLOBAL WORD bDumpRdWrParms GLOBAL BYTE copyright[] #ifdef MAIN -#if 0 -= "(C) Copyright 1995, 1996, 1997, 1998\nPasquale J. Villani\nAll Rights Reserved\n" -#else -= "" -#endif += "(C) Copyright 1995-2001 Pasquale J. Villani and The FreeDOS Project.\n\ +All Rights Reserved. This is free software and comes with ABSOLUTELY NO\n\ +WARRANTY; you can redistribute it and/or modify it under the terms of the\n\ +GNU General Public License as published by the Free Software Foundation;\n\ +either version 2, or (at your option) any later version.\n" #endif ; GLOBAL BYTE os_release[] #ifdef MAIN #if 0 -= "DOS-C version %d.%d Beta %d [FreeDOS Release] (Build %d).\n\ -\n\ -DOS-C is free software; you can redistribute it and/or modify it under the\n\ -terms of the GNU General Public License as published by the Free Software\n\ -Foundation; either version 2, or (at your option) any later version.\n\n\ -For technical information and description of the DOS-C operating system\n\ += "DOS-C version %d.%d Beta %d [FreeDOS Release] (Build %d).\n" +#endif += "FreeDOS kernel version " KERNEL_VERSION_STRING \ + " (Build " KERNEL_BUILD_STRING ") [" __DATE__ " " __TIME__ "]\n" +#if 0 +"For technical information and description of the DOS-C operating system\n\ consult \"FreeDOS Kernel\" by Pat Villani, published by Miller\n\ Freeman Publishing, Lawrence KS, USA (ISBN 0-87930-436-7).\n\ \n" -#else -= "FreeDOS kernel version %d.%d.%d"SUB_BUILD - " (Build %d"SUB_BUILD") [" __DATE__ " " __TIME__ "]\n\n" #endif #endif ; @@ -584,13 +578,6 @@ GLOBAL f_node_ptr f_nodes; /* pointer to the array */ GLOBAL UWORD f_nodes_cnt; /* number of allocated f_nodes */ -GLOBAL struct buffer -FAR *lastbuf; /* tail of ditto */ -/* FAR * buffers; /* pointer to array of track buffers */ - -/*GLOBAL BYTE FAR * dma_scratch;*/ /* scratchpad used for working around */ - /* DMA transfers during disk I/O */ - GLOBAL iregs FAR * ustackp, /* user stack */ FAR * kstackp; /* kernel stack */ @@ -603,34 +590,31 @@ GLOBAL iregs /* Process related functions - not under automatic generation. */ /* Typically, these are in ".asm" files. */ VOID -FAR cpm_entry(VOID), -INRPT FAR re_entry(VOID) /*, - INRPT FAR handle_break(VOID) */ ; +FAR ASMCFUNC cpm_entry(VOID) +/*INRPT FAR handle_break(VOID) */ ; VOID enable(VOID), disable(VOID); COUNT -CriticalError( +ASMCFUNC CriticalError( COUNT nFlag, COUNT nDrive, COUNT nError, struct dhdr FAR * lpDevice); #ifdef PROTO -VOID FAR CharMapSrvc(VOID); -VOID FAR set_stack(VOID); -VOID FAR restore_stack(VOID); -WORD execrh(request FAR *, struct dhdr FAR *); +VOID FAR ASMCFUNC CharMapSrvc(VOID); +VOID FAR ASMCFUNC set_stack(VOID); +VOID FAR ASMCFUNC restore_stack(VOID); +WORD ASMCFUNC execrh(request FAR *, struct dhdr FAR *); VOID exit(COUNT); /*VOID INRPT FAR handle_break(VOID); */ -VOID tmark(VOID); -BOOL tdelay(LONG); -BYTE FAR *device_end(VOID); -COUNT kb_data(VOID); -COUNT kb_input(VOID); -COUNT kb_init(VOID); -VOID setvec(UWORD, VOID(INRPT FAR *) ()); -BYTE FAR *getvec(UWORD); +VOID ASMCFUNC tmark(VOID); +BOOL ASMCFUNC tdelay(LONG); +BYTE FAR *ASMCFUNC device_end(VOID); +COUNT ASMCFUNC kb_data(VOID); +COUNT ASMCFUNC kb_input(VOID); +COUNT ASMCFUNC kb_init(VOID); +VOID ASMCFUNC setvec(UWORD, VOID(INRPT FAR *) ()); +BYTE FAR *ASMCFUNC getvec(UWORD); COUNT con(COUNT); -VOID getdirent(BYTE FAR *, struct dirent FAR *); -VOID putdirent(struct dirent FAR *, BYTE FAR *); #else VOID FAR CharMapSrvc(); VOID FAR set_stack(); @@ -647,8 +631,6 @@ COUNT kb_init(); VOID setvec(); BYTE FAR *getvec(); COUNT con(); -VOID getdirent(); -VOID putdirent(); #endif /* */ @@ -687,12 +669,12 @@ VOID fputbyte(); #endif #ifdef I86 -#define setvec(n, isr) (void)(*(VOID (INRPT FAR * FAR *)())(4 * (n)) = (isr)) +#define setvec(n, isr) (void)(*(VOID (INRPT FAR * FAR *)())(MK_FP(0,4 * (n))) = (isr)) #endif /*#define is_leap_year(y) ((y) & 3 ? 0 : (y) % 100 ? 1 : (y) % 400 ? 0 : 1) */ /* ^Break handling */ -void spawn_int23(void); /* procsupt.asm */ +void ASMCFUNC spawn_int23(void); /* procsupt.asm */ int control_break(void); /* break.c */ void handle_break(void); /* break.c */ diff --git a/kernel/init-mod.h b/kernel/init-mod.h index cc6d6aac..102e6413 100644 --- a/kernel/init-mod.h +++ b/kernel/init-mod.h @@ -21,10 +21,6 @@ #include "nls.h" #include "buffer.h" -#ifdef __TURBOC__ -void __int__(int); /* TC 2.01 requires this. :( -- ror4 */ -#endif - /* * The null macro `INIT' can be used to allow the reader to differentiate * between functions defined in `INIT_TEXT' and those defined in `_TEXT'. @@ -43,14 +39,14 @@ void __int__(int); /* TC 2.01 requires this. :( -- ror4 */ #define fstrncpy reloc_call_fstrncpy #define strcpy reloc_call_strcpy #define strlen reloc_call_strlen -WORD execrh(request FAR *, struct dhdr FAR *); -VOID fmemcpy(REG VOID FAR * d, REG VOID FAR * s, REG COUNT n); -void fmemset(REG VOID FAR * s, REG int ch, REG COUNT n); -void memset(REG VOID * s, REG int ch, REG COUNT n); -VOID strcpy(REG BYTE * d, REG BYTE * s); -VOID fstrncpy(REG BYTE FAR * d, REG BYTE FAR * s, REG COUNT n); -COUNT fstrlen(REG BYTE FAR * s); -COUNT strlen(REG BYTE * s); +WORD ASMCFUNC execrh(request FAR *, struct dhdr FAR *); +VOID ASMCFUNC fmemcpy(REG VOID FAR * d, REG VOID FAR * s, REG COUNT n); +void ASMCFUNC fmemset(REG VOID FAR * s, REG int ch, REG COUNT n); +void ASMCFUNC memset(REG VOID * s, REG int ch, REG COUNT n); +VOID ASMCFUNC strcpy(REG BYTE * d, REG BYTE * s); +VOID ASMCFUNC fstrncpy(REG BYTE FAR * d, REG BYTE FAR * s, REG COUNT n); +COUNT ASMCFUNC fstrlen(REG BYTE FAR * s); +COUNT ASMCFUNC strlen(REG BYTE * s); #undef LINESIZE #define LINESIZE KBD_MAXLENGTH @@ -60,7 +56,7 @@ COUNT strlen(REG BYTE * s); extern BYTE DosLoadedInHMA; extern fmemcmp(BYTE far *s1, BYTE FAR *s2, unsigned len); -#define setvec(n, isr) (void)(*(VOID (INRPT FAR * FAR *)())(4 * (n)) = (isr)) +#define setvec(n, isr) (void)(*(VOID (FAR * FAR *)())(MK_FP(0,4 * (n))) = (isr)) #define fbcopy(s, d, n) fmemcpy(d,s,n) #define GLOBAL extern @@ -133,15 +129,15 @@ INIT COUNT toupper(COUNT c); INIT VOID mcb_init(UCOUNT seg, UWORD size); INIT VOID strcat(REG BYTE * d, REG BYTE * s); INIT BYTE FAR *KernelAlloc(WORD nBytes); -INIT COUNT Umb_Test(void); -INIT COUNT UMB_get_largest(UCOUNT *seg, UCOUNT *size); +INIT COUNT ASMCFUNC Umb_Test(void); +INIT COUNT ASMCFUNC UMB_get_largest(UCOUNT *seg, UCOUNT *size); INIT BYTE *GetStringArg(BYTE * pLine, BYTE * pszString); /* diskinit.c */ COUNT dsk_init(VOID); /* int2f.asm */ -COUNT Umb_Test(void); +COUNT ASMCFUNC Umb_Test(void); /* inithma.c */ int MoveKernelToHMA(void); @@ -152,45 +148,41 @@ UWORD init_oem(void); /* intr.asm */ -void init_call_intr(int nr, iregs *rp); -UCOUNT read(int fd, void *buf, UCOUNT count); -int open(const char *pathname, int flags); -int close(int fd); -int dup2(int oldfd, int newfd); -int allocmem(UWORD size, seg *segp); -INIT VOID init_PSPInit(seg psp_seg); -INIT VOID init_PSPSet(seg psp_seg); -INIT COUNT init_DosExec(COUNT mode, exec_blk * ep, BYTE * lp); -INIT VOID keycheck(VOID); +void ASMCFUNC init_call_intr(int nr, iregs *rp); +UCOUNT ASMCFUNC read(int fd, void *buf, UCOUNT count); +int ASMCFUNC open(const char *pathname, int flags); +int ASMCFUNC close(int fd); +int ASMCFUNC dup2(int oldfd, int newfd); +int ASMCFUNC allocmem(UWORD size, seg *segp); +INIT VOID ASMCFUNC init_PSPInit(seg psp_seg); +INIT VOID ASMCFUNC init_PSPSet(seg psp_seg); +INIT COUNT ASMCFUNC init_DosExec(COUNT mode, exec_blk * ep, BYTE * lp); +INIT VOID ASMCFUNC keycheck(VOID); /* irqstack.asm */ -VOID init_stacks(VOID FAR * stack_base, COUNT nStacks, WORD stackSize); +VOID ASMCFUNC init_stacks(VOID FAR * stack_base, COUNT nStacks, WORD stackSize); /* inthndlr.c */ -VOID far int21_entry(iregs UserRegs); -VOID int21_service(iregs far * r); -VOID INRPT FAR int0_handler(void); -VOID INRPT FAR int6_handler(void); -VOID INRPT FAR empty_handler(void); -VOID INRPT far got_cbreak(void); /* procsupt.asm */ -VOID INRPT far int20_handler(iregs UserRegs); -VOID INRPT far int21_handler(iregs UserRegs); -VOID INRPT FAR int22_handler(void); -VOID INRPT FAR int23_handler(int es, int ds, int di, int si, int bp, int sp, int bx, int dx, int cx, int ax, int ip, int cs - , int flags); -VOID INRPT FAR int24_handler(void); -VOID INRPT FAR low_int25_handler(void); -VOID INRPT FAR low_int26_handler(void); -VOID INRPT FAR int27_handler(int es, int ds, int di, int si, int bp, int sp, int bx, int dx, int cx, int ax, int ip, int cs - , int flags); -VOID INRPT FAR int28_handler(void); -VOID INRPT FAR int29_handler(int es, int ds, int di, int si, int bp, int sp, int bx, int dx, int cx, int ax, int ip, int cs - , int flags); -VOID INRPT FAR int2a_handler(void); -VOID INRPT FAR int2f_handler(void); +VOID far ASMCFUNC int21_entry(iregs UserRegs); +VOID ASMCFUNC int21_service(iregs far * r); +VOID FAR ASMCFUNC int0_handler(void); +VOID FAR ASMCFUNC int6_handler(void); +VOID FAR ASMCFUNC empty_handler(void); +VOID far ASMCFUNC got_cbreak(void); /* procsupt.asm */ +VOID far ASMCFUNC int20_handler(iregs UserRegs); +VOID far ASMCFUNC int21_handler(iregs UserRegs); +VOID FAR ASMCFUNC int22_handler(void); +VOID FAR ASMCFUNC int24_handler(void); +VOID FAR ASMCFUNC low_int25_handler(void); +VOID FAR ASMCFUNC low_int26_handler(void); +VOID FAR ASMCFUNC int27_handler(void); +VOID FAR ASMCFUNC int28_handler(void); +VOID FAR ASMCFUNC int29_handler(void); +VOID FAR ASMCFUNC int2a_handler(void); +VOID FAR ASMCFUNC int2f_handler(void); /* main.c */ -INIT VOID main(void); +INIT VOID ASMCFUNC FreeDOSmain(void); INIT BOOL init_device(struct dhdr FAR * dhp, BYTE FAR * cmdLine, COUNT mode, COUNT top); INIT VOID init_fatal(BYTE * err_msg); @@ -201,3 +193,10 @@ void MoveKernel(unsigned NewKernelSegment); extern WORD HMAFree; /* first byte in HMA not yet used */ extern unsigned CurrentKernelSegment; + +#if defined(WATCOM) && 0 +ULONG FAR ASMCFUNC MULULUS(ULONG mul1, UWORD mul2); /* MULtiply ULong by UShort */ +ULONG FAR ASMCFUNC MULULUL(ULONG mul1, ULONG mul2); /* MULtiply ULong by ULong */ +ULONG FAR ASMCFUNC DIVULUS(ULONG mul1, UWORD mul2); /* DIVide ULong by UShort */ +ULONG FAR ASMCFUNC DIVMODULUS(ULONG mul1, UWORD mul2,UWORD *rem); /* DIVide ULong by UShort */ +#endif diff --git a/kernel/initdisk.c b/kernel/initdisk.c index 62f55319..bedf800d 100644 --- a/kernel/initdisk.c +++ b/kernel/initdisk.c @@ -26,6 +26,7 @@ #include "portab.h" #include "init-mod.h" +#include "init-dat.h" #include "dyndata.h" #ifdef VERSION_STRINGS static BYTE *dskRcsId = "$Id$"; @@ -34,11 +35,11 @@ static BYTE *dskRcsId = "$Id$"; /* data shared between DSK.C and INITDISK.C */ -extern UBYTE FAR DiskTransferBuffer[1 * SEC_SIZE]; +extern UBYTE DOSFAR DiskTransferBuffer[1 * SEC_SIZE]; -extern COUNT FAR nUnits; +extern COUNT DOSFAR nUnits; -extern UWORD FAR LBA_WRITE_VERIFY; +extern UWORD DOSFAR LBA_WRITE_VERIFY; /* * Rev 1.0 13 May 2001 tom ehlert @@ -150,10 +151,19 @@ extern UWORD FAR LBA_WRITE_VERIFY; #define IsExtPartition(parttyp) ((parttyp) == EXTENDED || \ (parttyp) == EXTENDED_LBA ) -#define IsFAT16Partition(parttyp) ((parttyp) == FAT12 || \ - (parttyp) == FAT16SMALL || \ - (parttyp) == FAT16LARGE || \ - (parttyp) == FAT16_LBA ) +#ifdef WITHFAT32 +#define IsFATPartition(parttyp) ((parttyp) == FAT12 || \ + (parttyp) == FAT16SMALL || \ + (parttyp) == FAT16LARGE || \ + (parttyp) == FAT16_LBA || \ + (parttyp) == FAT32 || \ + (parttyp) == FAT32_LBA) +#else +#define IsFATPartition(parttyp) ((parttyp) == FAT12 || \ + (parttyp) == FAT16SMALL || \ + (parttyp) == FAT16LARGE || \ + (parttyp) == FAT16_LBA) +#endif #define MSDOS_EXT_SIGN 0x29 /* extended boot sector signature */ #define MSDOS_FAT12_SIGN "FAT12 " /* FAT12 filesystem signature */ @@ -204,6 +214,23 @@ struct PartTableEntry /* INTERNAL representation of partition table entry */ UBYTE GlobalEnableLBAsupport = 1; /* = 0 --> disable LBA support */ +COUNT init_readdasd(UBYTE drive) +{ + static iregs regs; + + regs.a.b.h = 0x15; + regs.d.b.l = drive; + init_call_intr(0x13,®s); + if ((regs.flags & 1) == 0) switch (regs.a.b.h) + { + case 2: + return DF_CHANGELINE; + case 3: + return DF_FIXED; + } + return 0; +} + /* translate LBA sectors into CHS addressing copied and pasted from dsk.c! @@ -343,26 +370,29 @@ VOID CalculateFATData(ddt FAR *pddt, ULONG NumSectors, UBYTE FileSystem) fmemcpy(pddt->ddt_fstype, MSDOS_FAT16_SIGN, 8); break; - /* FAT 32 code: commented out for now */ #ifdef WITHFAT32 case FAT32: /* For FAT32, use 4k clusters on sufficiently large file systems, * otherwise 1 sector per cluster. This is also what M$'s format * command does for FAT32. */ - defbpb->bpb_nsector = ((long long)blocks*SECTORS_PER_BLOCK >= 512*1024 ? 8 : 1); + defbpb->bpb_nsector = (NumSectors >= 512*1024 ? 8 : 1); do { - clust = ((long long) fatdata *defbpb->bpb_nbyte + defbpb->bpb_nfat*8) / - ((int) defbpb->bpb_nsector * defbpb->bpb_nbyte + defbpb->bpb_nfat*4); + /* simple calculation - no long long available */ + clust = (ULONG)fatdata / defbpb->bpb_nsector; + /* this calculation below yields a smaller value - the above is non-optimal + but should not be dangerous */ + /* clust = ((long long) fatdata *defbpb->bpb_nbyte + defbpb->bpb_nfat*8) / + ((int) defbpb->bpb_nsector * defbpb->bpb_nbyte + defbpb->bpb_nfat*4); */ fatlength = cdiv ((clust+2) * 4, defbpb->bpb_nbyte); /* Need to recalculate number of clusters, since the unused parts of the * FATS and data area together could make up space for an additional, * not really present cluster. */ clust = (fatdata - defbpb->bpb_nfat*fatlength)/defbpb->bpb_nsector; maxclust = (fatlength * defbpb->bpb_nbyte) / 4; - if (maxclust > MAX_CLUST_32) - maxclust = MAX_CLUST_32; + if (maxclust > FAT_MAGIC32) + maxclust = FAT_MAGIC32; DebugPrintf(( "FAT32: #clu=%u, fatlen=%u, maxclu=%u, limit=%u\n", - clust, fatlength, maxclust, FAT_MAGIC )); + clust, fatlength, maxclust, FAT_MAGIC32 )); if (clust > maxclust) { clust = 0; @@ -372,10 +402,9 @@ VOID CalculateFATData(ddt FAR *pddt, ULONG NumSectors, UBYTE FileSystem) break; defbpb->bpb_nsector <<= 1; } while (defbpb->bpb_nsector && defbpb->bpb_nsector <= maxclustsize); - bpb_nfsect = fatlength; defbpb->bpb_nfsect = 0; - defbpb->fat32.fat32_length = fatlength; - memcpy(pddt->ddt_fstype, MSDOS_FAT32_SIGN, 8); + defbpb->bpb_xnfsect = fatlength; + fmemcpy(pddt->ddt_fstype, MSDOS_FAT32_SIGN, 8); break; #endif } @@ -396,6 +425,7 @@ void DosDefinePartition(struct DriveParamS *driveParam, } pddt->ddt_driveno = driveParam->driveno; + pddt->ddt_logdriveno = nUnits; pddt->ddt_LBASupported = driveParam->LBA_supported; pddt->ddt_WriteVerifySupported = driveParam->WriteVerifySupported; pddt->ddt_ncyl = driveParam->chs.Cylinder; @@ -420,7 +450,8 @@ void DosDefinePartition(struct DriveParamS *driveParam, CalculateFATData(pddt, pEntry->NumSect, pEntry->FileSystem); pddt->ddt_serialno = 0x12345678l; - pddt->ddt_descflags = 0x200; /* drive inaccessible until bldbpb successful */ + /* drive inaccessible until bldbpb successful */ + pddt->ddt_descflags = init_readdasd(pddt->ddt_driveno) | DF_NOACCESS; fmemcpy(&pddt->ddt_bpb, &pddt->ddt_defbpb, sizeof(bpb)); #ifdef _BETA_ /* Alain whishes to keep this in later versions, too */ @@ -443,10 +474,6 @@ void DosDefinePartition(struct DriveParamS *driveParam, } - -void __int__(int); - - /* Get the parameters of the hard disk */ int LBA_Get_Drive_Parameters(int drive,struct DriveParamS *driveParam) { @@ -658,7 +685,7 @@ ScanForPrimaryPartitions(struct DriveParamS *driveParam,int scan_type, partitionStart = startSector + pEntry->RelSect; - if (!IsFAT16Partition(pEntry->FileSystem)) + if (!IsFATPartition(pEntry->FileSystem)) { continue; } @@ -680,13 +707,13 @@ ScanForPrimaryPartitions(struct DriveParamS *driveParam,int scan_type, chs.Head != pEntry->Begin.Head || chs.Sector != pEntry->Begin.Sector ) { - printf("NOT using suspect partition %u FS %02x:", + printf("WARNING: using suspect partition %u FS %02x:", i, pEntry->FileSystem); - printCHS(" start calc ",&chs); - printCHS(" != ",&pEntry->Begin); + printCHS(" with calculated values ",&chs); + printCHS(" instead of ",&pEntry->Begin); printf("\n"); + fmemcpy(&pEntry->Begin, &chs, sizeof(struct CHS)); - continue; } @@ -695,14 +722,20 @@ ScanForPrimaryPartitions(struct DriveParamS *driveParam,int scan_type, end.Head != pEntry->End.Head || end.Sector != pEntry->End.Sector ) { - printf("NOT using suspect partition %u FS %02x:", + if (pEntry->NumSect == 0) + { + printf("Not using partition %u with 0 sectors\n", i); + continue; + } + + printf("WARNING: using suspect partition %u FS %02x:", i, pEntry->FileSystem); - printCHS(" end calc ",&end); - printCHS(" != ",&pEntry->End); + printCHS(" with calculated values ",&end); + printCHS(" instead of ",&pEntry->End); printf("\n"); + fmemcpy(&pEntry->End, &end, sizeof(struct CHS)); - continue; } @@ -1053,6 +1086,7 @@ void ReadAllPartitionTables(void) bpb FAR *pbpbarray; int Unit; ddt FAR *pddt; + static iregs regs; /* Setup media info and BPBs arrays for floppies (this is a 360kb flop) */ for (Unit = 0; Unit < nUnits; Unit++) @@ -1073,12 +1107,12 @@ void ReadAllPartitionTables(void) pbpbarray->bpb_nsecs = 9; pddt->ddt_driveno = 0; + pddt->ddt_logdriveno = Unit; pddt->ddt_ncyl = 40; pddt->ddt_LBASupported = FALSE; + pddt->ddt_descflags = init_readdasd(0); pddt->ddt_offset = 0l; - - pddt->ddt_serialno = 0x12345678l; fmemcpy(&pddt->ddt_bpb, pbpbarray, sizeof(bpb)); } @@ -1087,14 +1121,15 @@ void ReadAllPartitionTables(void) this is a quick patch - see if B: exists test for A: also, need not exist */ - { - iregs r; - - init_call_intr(0x11,&r); /* get equipment list */ - if ((r.a.x & 1) && (r.a.x & 0xc0)) - pddt->ddt_driveno = 1; - /* floppy drives installed and a B: drive */ - /*if ((r.a.x & 1)==0) */ /* no floppy drives installed */ + init_call_intr(0x11,®s); /* get equipment list */ + if ((regs.a.x & 1) && (regs.a.x & 0xc0)) { + pddt->ddt_driveno = 1; + pddt->ddt_descflags = init_readdasd(1); + /* floppy drives installed and a B: drive */ + /*if ((r.a.x & 1)==0) */ /* no floppy drives installed */ + } else { /* set up the DJ method : multiple logical drives */ + (pddt-1)->ddt_descflags |= DF_CURLOG | DF_MULTLOG; + pddt->ddt_descflags |= DF_MULTLOG; } nHardDisk = min(nHardDisk,MAX_HARD_DRIVE-1); diff --git a/kernel/inithma.c b/kernel/inithma.c index a3441ba3..fd104256 100644 --- a/kernel/inithma.c +++ b/kernel/inithma.c @@ -66,9 +66,9 @@ #include "portab.h" #include "init-mod.h" +#include "init-dat.h" -extern BYTE FAR version_flags; /* minor version number */ extern BYTE FAR _HMATextAvailable, /* first byte of available CODE area */ @@ -81,6 +81,9 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.10 2001/09/23 20:39:44 bartoldeman + * FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling + * * Revision 1.9 2001/08/19 12:58:36 bartoldeman * Time and date fixes, Ctrl-S/P, findfirst/next, FCBs, buffers, tsr unloading * @@ -112,22 +115,28 @@ static BYTE *RcsId = "$Id$"; * initial creation */ -void ClaimHMA(VOID); BYTE DosLoadedInHMA=FALSE; /* set to TRUE if loaded HIGH */ BYTE HMAclaimed=FALSE; /* set to TRUE if claimed from HIMEM */ -WORD HMAFree; /* first byte in HMA not yet used */ +WORD HMAFree = 0; /* first byte in HMA not yet used */ -extern BYTE FAR * FAR XMSDriverAddress; -extern FAR _EnableA20(VOID); -extern FAR _DisableA20(VOID); +extern BYTE FAR * DOSTEXTFAR ASMCFUNC XMSDriverAddress; +extern FAR ASMCFUNC _EnableA20(VOID); +extern FAR ASMCFUNC _DisableA20(VOID); -extern void FAR *DetectXMSDriver(VOID); - +extern void FAR *ASMCFUNC DetectXMSDriver(VOID); +extern int ASMCFUNC init_call_XMScall( void FAR * driverAddress, UWORD ax, UWORD dx); + #ifdef DEBUG - #define int3() __int__(3); + #ifdef __TURBOC__ + #define int3() __int__(3); + #else + void int3() + { __asm int 3; + } + #endif #else #define int3() #endif @@ -158,14 +167,6 @@ VOID hdump(BYTE FAR *p) #endif -#ifdef __TURBOC__ - void __int__(int); /* TC 2.01 requires this. :( -- ror4 */ - unsigned char __inportb__(int portid); - void __outportb__ (int portid, unsigned char value); -#endif - - - #define KeyboardShiftState() (*(BYTE FAR *)(MK_FP(0x40,0x17))) @@ -240,23 +241,13 @@ int MoveKernelToHMA() return TRUE; } - { - void FAR *pXMS = DetectXMSDriver(); - - if (pXMS != NULL) - { - XMSDriverAddress = pXMS; - } - else - return FALSE; - } - - + if ((XMSDriverAddress = DetectXMSDriver()) == NULL) + return FALSE; +#ifdef DEBUG /* A) for debugging purpose, suppress this, if any shift key is pressed */ -#ifdef DEBUG if (KeyboardShiftState() & 0x0f) { printf("Keyboard state is %0x, NOT moving to HMA\n",KeyboardShiftState()); @@ -273,7 +264,15 @@ int MoveKernelToHMA() return FALSE; } - ClaimHMA(); + /* allocate HMA through XMS driver */ + + if (HMAclaimed == 0 && + (HMAclaimed = init_call_XMScall( XMSDriverAddress, 0x0100, 0xffff)) == 0) + { + printf("Can't reserve HMA area ??\n"); + + return FALSE; + } MoveKernel(0xffff); @@ -293,12 +292,8 @@ int MoveKernelToHMA() /* report the fact we are running high thorugh int 21, ax=3306 */ version_flags |= 0x10; - return TRUE; -errorReturn: - printf("HMA errors, not doing HMA\n"); - return FALSE; } @@ -345,35 +340,6 @@ void InstallVDISK(VOID) #endif -int init_call_XMScall( void FAR * driverAddress, UWORD ax, UWORD dx); - - -/* - allocate HMA through XMS driver -*/ - -void ClaimHMA(VOID) -{ - void FAR *pXMS; - - if (!DosLoadedInHMA) return; - if (HMAclaimed) return; - - - pXMS = DetectXMSDriver(); - - if (pXMS != NULL) - { - XMSDriverAddress = pXMS; - - if (init_call_XMScall( pXMS, 0x0100, 0xffff)) - { - printf("HMA area successfully claimed\n"); - HMAclaimed = TRUE; - } - } -} - /* this should be called, after each device driver has been loaded with FALSE @@ -430,7 +396,7 @@ void MoveKernel(unsigned NewKernelSegment) UBYTE FAR *HMASource; unsigned len; - __int__(3); + int3(); if (CurrentKernelSegment == 0) CurrentKernelSegment = FP_SEG(_HMATextEnd); @@ -497,12 +463,12 @@ void MoveKernel(unsigned NewKernelSegment) UWORD jmpSegment; }; extern struct RelocationTable - FAR _HMARelocationTableStart[], - FAR _HMARelocationTableEnd[]; + DOSTEXTFAR _HMARelocationTableStart[], + DOSTEXTFAR _HMARelocationTableEnd[]; struct RelocationTable FAR *rp, rtemp ; - /* verify, that all entries are valid */ + /* verify, that all entries are valid */ for (rp = _HMARelocationTableStart; rp < _HMARelocationTableEnd; rp++) { @@ -511,7 +477,8 @@ void MoveKernel(unsigned NewKernelSegment) rp->callNear != 0xe8 || /* call NEAR */ 0) { - printf("illegal relocation entry # %d\n",rp - _HMARelocationTableStart); + printf("illegal relocation entry # %d\n",(FP_OFF(rp) - FP_OFF(_HMARelocationTableStart))/sizeof(struct RelocationTable)); + int3(); goto errorReturn; } } diff --git a/kernel/initoem.c b/kernel/initoem.c index 883adc63..2e52b4e2 100644 --- a/kernel/initoem.c +++ b/kernel/initoem.c @@ -36,6 +36,9 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.5 2001/09/23 20:39:44 bartoldeman + * FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling + * * Revision 1.4 2001/04/21 22:32:53 bartoldeman * Init DS=Init CS, fixed stack overflow problems and misc bugs. * @@ -90,20 +93,15 @@ static BYTE *RcsId = "$Id$"; * Initial revision. */ -#ifdef __TURBOC__ -void __int__(int); /* TC 2.01 requires this. :( -- ror4 */ -#endif - UWORD init_oem(void) { UWORD top_k; #ifndef __TURBOC__ - _asm + asm { - int 12 h - mov top_k, - ax + int 0x12; + mov top_k,ax; } #else __int__(0x12); diff --git a/kernel/int2f.asm b/kernel/int2f.asm index 43cb5d41..d73bdba7 100644 --- a/kernel/int2f.asm +++ b/kernel/int2f.asm @@ -30,6 +30,9 @@ ; $Id$ ; ; $Log$ +; Revision 1.13 2001/09/23 20:39:44 bartoldeman +; FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling +; ; Revision 1.12 2001/08/19 12:58:36 bartoldeman ; Time and date fixes, Ctrl-S/P, findfirst/next, FCBs, buffers, tsr unloading ; @@ -107,7 +110,6 @@ %include "stacks.inc" segment HMA_TEXT - extern _nul_dev:wrt DGROUP extern _cu_psp:wrt DGROUP extern _syscall_MUX14:wrt HMA_TEXT @@ -158,153 +160,46 @@ Int2f?iret: iret -FarTabRetnBX: pop bx - jmp FarTabRetn -; -;return dos data seg. -IntDosCal: - cmp al, 31h - ja FarTabRetn - push bx - mov bl, al - mov bh, 0 - shl bx, 1 - jmp [cs:bx+DosCalTbl] - -DosCalTbl: -dw retff, IntDosCal_1, IntDosCal_2, IntDosCal_3, IntDosCal_4, IntDosCal_5, -dw IntDosCal_6, IntDosCal_7, IntDosCal_8, IntDosCal_9, IntDosCal_a, -dw IntDosCal_b, IntDosCal_c, IntDosCal_d, IntDosCal_e, IntDosCal_f, -dw IntDosCal_10, IntDosCal_11, IntDosCal_12, IntDosCal_13, IntDosCal_14, -dw IntDosCal_15, IntDosCal_16, IntDosCal_17, IntDosCal_18, IntDosCal_19, -dw IntDosCal_1a, IntDosCal_1b, IntDosCal_1c, IntDosCal_1d, IntDosCal_1e, -dw IntDosCal_1f, IntDosCal_20, IntDosCal_21, IntDosCal_22, IntDosCal_23, -dw IntDosCal_24, IntDosCal_25, IntDosCal_26, IntDosCal_27, IntDosCal_28, -dw IntDosCal_29, IntDosCal_2a, IntDosCal_2b, IntDosCal_2c, IntDosCal_2d, -dw IntDosCal_2e, IntDosCal_2f, IntDosCal_30, IntDosCal_31 - -retff: mov al,0ffh - jmp FarTabRetnBX - -IntDosCal_3: - push ax - mov ax, seg _nul_dev - mov ds,ax - pop ax - clc - jmp FarTabRetnBX - -IntDosCal_8: - ; decrease SFT reference count - dec word [es:di] - jnz .skip - dec word [es:di] -.skip: - jmp FarTabRetnBX - -IntDosCal_1: -IntDosCal_2: -IntDosCal_4: -IntDosCal_5: -IntDosCal_6: -IntDosCal_7: -IntDosCal_9: -IntDosCal_a: -IntDosCal_b: -IntDosCal_c: -IntDosCal_d: -IntDosCal_e: -IntDosCal_f: -IntDosCal_10: -IntDosCal_11: -IntDosCal_13: -IntDosCal_14: -IntDosCal_15: -IntDosCal_16: -IntDosCal_17: -IntDosCal_19: -IntDosCal_1a: -IntDosCal_1c: -IntDosCal_1d: -IntDosCal_1e: -IntDosCal_1f: -IntDosCal_20: -IntDosCal_22: -IntDosCal_23: -IntDosCal_24: -IntDosCal_26: -IntDosCal_27: -IntDosCal_28: -IntDosCal_29: -IntDosCal_2b: -IntDosCal_2d: -IntDosCal_2e: -IntDosCal_2f: -IntDosCal_30: -IntDosCal_31: - jmp FarTabRetnBX - -; get length of asciiz string -IntDosCal_12: - push di - push es - extern _fstrlen - call _fstrlen - add sp, byte 4 - mov cx, ax - inc cx - jmp FarTabRetnBX - -; get caller's registers -IntDosCal_18: - extern _user_r - lds si, [_user_r] - jmp FarTabRetnBX - -; #days in February - valid until 2099. -IntDosCal_1b: - mov al, 28 - test cl, 3 - jnz .noleap - inc al -.noleap: jmp FarTabRetnBX - -; truename -IntDosCal_21: - xor bx, bx - push bx - push es - push di - push ds - push si - extern _truename - call _truename - add sp, byte 10 - jmp FarTabRetnBX -; get length of asciiz string -IntDosCal_25: - push si - push ds - call _fstrlen - add sp, byte 4 - mov cx, ax - inc cx - jmp FarTabRetnBX - -; -;Set FastOpen but does nothing. -IntDosCal_2a: - clc - jmp FarTabRetn -; -; added by James Tabor For Zip Drives -;Return Null Device Pointer -IntDosCal_2c: - mov ax,_nul_dev - mov bx,seg _nul_dev - clc - jmp FarTabRetn +;*********************************************************** +; internal doscalls INT2F/11xx - handled through C +;*********************************************************** +IntDosCal: + ; set up register frame +;struct int2f12regs +;{ +; UWORD es,ds; +; UWORD di,si,bp,bx,dx,cx,ax; +; UWORD ip,cs,flags; +; UWORD callerARG1; +;}; + push ax + push cx + push dx + push bx + push bp + push si + push di + push ds + push es + + mov ax,DGROUP + mov ds,ax + extern _int2F_12_handler:wrt HGROUP + call _int2F_12_handler + + pop es + pop ds + pop di + pop si + pop bp + pop bx + pop dx + pop cx + pop ax + + iret + ; Int 2F Multipurpose Remote System Calls diff --git a/kernel/inthndlr.c b/kernel/inthndlr.c index d0167929..7b3161c7 100644 --- a/kernel/inthndlr.c +++ b/kernel/inthndlr.c @@ -37,6 +37,9 @@ BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.31 2001/09/23 20:39:44 bartoldeman + * FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling + * * Revision 1.30 2001/08/19 12:58:36 bartoldeman * Time and date fixes, Ctrl-S/P, findfirst/next, FCBs, buffers, tsr unloading * @@ -274,11 +277,19 @@ VOID FAR int21_entry(iregs UserRegs) } #endif +/* Structures needed for int 25 / int 26 */ +struct HugeSectorBlock +{ + ULONG blkno; + WORD nblks; + BYTE FAR *buf; +}; + /* Normal entry. This minimizes user stack usage by avoiding local */ /* variables needed for the rest of the handler. */ /* this here works on the users stack !! and only very few functions are allowed */ -VOID int21_syscall(iregs FAR * irp) +VOID ASMCFUNC int21_syscall(iregs FAR * irp) { Int21AX = irp->AX; @@ -364,7 +375,7 @@ VOID int21_syscall(iregs FAR * irp) } -VOID int21_service(iregs FAR * r) +VOID ASMCFUNC int21_service(iregs FAR * r) { COUNT rc = 0, rc1; @@ -893,7 +904,11 @@ VOID int21_service(iregs FAR * r) } dpb->dpb_flags = M_CHANGED; /* force reread of drive BPB/DPB */ +#ifdef WITHFAT32 + if (media_check(dpb) < 0 || ISFAT32(dpb)) +#else if (media_check(dpb) < 0) +#endif { r->AL = 0xff; CritErrCode = 0x0f; @@ -1255,7 +1270,11 @@ VOID int21_service(iregs FAR * r) case 0x53: /* DOS 2+ internal - TRANSLATE BIOS PARAMETER BLOCK TO DRIVE PARAM BLOCK */ - bpb_to_dpb((bpb FAR *)MK_FP(r->DS, r->SI), (struct dpb FAR *)MK_FP(r->ES, r->BP)); + bpb_to_dpb((bpb FAR *)MK_FP(r->DS, r->SI), (struct dpb FAR *)MK_FP(r->ES, r->BP) +#ifdef WITHFAT32 + ,(r->CX == 0x4558 && r->DX == 0x4152) +#endif + ); break; /* Get verify state */ @@ -1645,7 +1664,7 @@ VOID int21_service(iregs FAR * r) /* Get/Set Serial Number */ case 0x69: - rc = ( r->BL == 0 ? default_drive : r->BL - 1); + rc = (r->BL == 0 ? default_drive : r->BL - 1); if (rc < lastdrive) { UWORD saveCX = r->CX; @@ -1679,7 +1698,7 @@ VOID int21_service(iregs FAR * r) case 0x6b: dummy func: return AL=0 */ /* Extended Open-Creat, not fully functional. (bits 4,5,6 of BH) */ - case 0x6c: + case 0x6c: { COUNT x = 0; @@ -1721,27 +1740,227 @@ VOID int21_service(iregs FAR * r) break; } - /* case 0x6d and above not implemented : see default; return AL=0 */ - - } +#ifdef WITHFAT32 + /* DOS 7.0+ FAT32 extended funcitons */ + case 0x73: + { + switch(r->AL) + { + /* Get extended drive parameter block */ + case 0x02: + { + struct xdpbdata FAR *xddp = (struct xdpbdata FAR *)MK_FP(r->ES, r->DI); + struct dpb FAR *dpb; + + if (r->CX < sizeof(struct xdpbdata)) + { + r->AX = -DE_INVLDBUF; + goto error_out; + } + + dpb = GetDriveDPB(r->DL, &rc); + if (rc != SUCCESS) goto error_exit; + + dpb->dpb_flags = M_CHANGED; /* force reread of drive BPB/DPB */ + + if (media_check(dpb) < 0) + { + r->AX = -DE_INVLDDRV; + goto error_out; + } + + fmemcpy(&xddp->xdd_dpb, dpb, sizeof(struct dpb)); + xddp->xdd_dpbsize = sizeof(struct dpb); + CLEAR_CARRY_FLAG(); + + break; + } + /* Get extended free drive space */ + case 0x03: + { + struct xfreespace FAR *xfsp = + (struct xfreespace FAR *)MK_FP(r->ES, r->DI); + if (r->CX < sizeof(struct xfreespace)) + { + r->AX = -DE_INVLDBUF; + goto error_out; + } + CLEAR_CARRY_FLAG(); + rc = DosGetExtFree((BYTE FAR *)FP_DS_DX, xfsp); + if (rc != SUCCESS) + goto error_exit; + xfsp->xfs_datasize = sizeof(struct xfreespace); + xfsp->xfs_version.actual = 0; + break; + } + /* Set DPB to use for formatting */ + case 0x04: + { + struct xdpbforformat FAR *xdffp = + (struct xdpbforformat FAR *)MK_FP(r->ES, r->DI); + struct dpb FAR *dpb; + if (r->CX < sizeof(struct xdpbforformat)) + { + r->AX = -DE_INVLDBUF; + goto error_out; + } + dpb = GetDriveDPB(r->DL, &rc); + if (rc != SUCCESS) goto error_exit; + + CLEAR_CARRY_FLAG(); + xdffp->xdff_datasize = sizeof(struct xdpbforformat); + xdffp->xdff_version.actual = 0; + + switch ((UWORD)xdffp->xdff_function) + { + case 0x00: + { + DWORD nfreeclst = xdffp->xdff_f.setdpbcounts.nfreeclst; + DWORD cluster = xdffp->xdff_f.setdpbcounts.cluster; + if ((dpb->dpb_xfsinfosec == 0xffff && (nfreeclst != 0 || + cluster != 0)) || + nfreeclst == 1 || nfreeclst > dpb->dpb_size || + cluster == 1 || cluster > dpb->dpb_size) + { + r->AX = -DE_INVLDPARM; + goto error_out; + } + dpb->dpb_nfreeclst = nfreeclst; + dpb->dpb_cluster = cluster; + write_fsinfo(dpb); + break; + } + case 0x01: + { + ddt *pddt = getddt(r->DL); + fmemcpy(&pddt->ddt_bpb, xdffp->xdff_f.rebuilddpb.bpbp, + sizeof(bpb)); + } + case 0x02: + { +rebuild_dpb: + dpb->dpb_flags = M_CHANGED; + + if (media_check(dpb) < 0) + { + r->AX = -DE_INVLDDRV; + goto error_out; + } + + break; + } + case 0x03: + { + struct buffer FAR *bp; + bpb FAR *bpbp; + DWORD newmirroring = xdffp->xdff_f.setmirroring.newmirroring; + if (newmirroring != -1 && newmirroring & ~(0xf | 0x80)) + { + r->AX = -DE_INVLDPARM; + goto error_out; + } + xdffp->xdff_f.setmirroring.oldmirroring = dpb->dpb_xflags; + if (newmirroring != -1) + { + bp = getblock(1, dpb->dpb_unit); + bp->b_flag &= ~(BFR_DATA | BFR_DIR | BFR_FAT); + bp->b_flag |= BFR_VALID | BFR_DIRTY; + bpbp = (bpb FAR *)& bp->b_buffer[BT_BPB]; + bpbp->bpb_xflags = newmirroring; + } + goto rebuild_dpb; + } + case 0x04: + { + struct buffer FAR *bp; + bpb FAR *bpbp; + DWORD rootclst = xdffp->xdff_f.setroot.newrootclst; + if (rootclst != -1 && (rootclst == 1 || + rootclst > dpb->dpb_size)) + { + r->AX = -DE_INVLDPARM; + goto error_out; + } + xdffp->xdff_f.setroot.oldrootclst = dpb->dpb_xrootclst; + if (rootclst != -1) + { + bp = getblock(1, dpb->dpb_unit); + bp->b_flag &= ~(BFR_DATA | BFR_DIR | BFR_FAT); + bp->b_flag |= BFR_VALID | BFR_DIRTY; + bpbp = (bpb FAR *) & bp->b_buffer[BT_BPB]; + bpbp->bpb_xrootclst = rootclst; + } + goto rebuild_dpb; + } + } + + break; + } + /* Extended absolute disk read/write */ + /* TODO(vlp) consider using of the 13-14th bits of SI */ + case 0x05: + { + struct HugeSectorBlock FAR *SectorBlock = + (struct HugeSectorBlock FAR *)MK_FP(r->DS, r->BX); + UBYTE mode; + + if (r->CX != 0xffff || ((r->SI & 1) == 0 && r->SI != 0) + || (r->SI & ~0x6001)) + { + r->AX = -DE_INVLDPARM; + goto error_out; + } + + if (r->DL - 1 >= lastdrive || r->DL == 0) + { + r->AX = 0x207; + goto error_out; + } + CLEAR_CARRY_FLAG(); + + if (r->SI == 0) mode = DSKREAD; + else mode = DSKWRITE; + InDOS++; + + r->AX=dskxfer(r->DL - 1, SectorBlock->blkno, SectorBlock->buf, + SectorBlock->nblks, mode); + + if (mode == DSKWRITE) + if (r->AX <= 0) + setinvld(r->DL - 1); + + if (r->AX > 0) + { + r->AX = 0x20c; + r->flags |= FLG_CARRY; + --InDOS; + return; + } + + + r->AX = 0; + r->flags &= ~FLG_CARRY; + --InDOS; + break; + } + } + break; + } +#endif + } #ifdef DEBUG if (bDumpRegs) - { - fbcopy((VOID FAR *) user_r, (VOID FAR *) & error_regs, - sizeof(iregs)); - dump_regs = TRUE; - dump(); - } + { + fbcopy((VOID FAR *) user_r, (VOID FAR *) & error_regs, + sizeof(iregs)); + dump_regs = TRUE; + dump(); + } #endif } -/* terminate handler */ -VOID INRPT FAR int22_handler(void) -{ -} - #if 0 /* No kernel INT-23 handler required no longer -- 1999/04/15 ska */ /* ctrl-Break handler */ @@ -1760,14 +1979,6 @@ VOID INRPT FAR int23_handler(int es, int ds, int di, int si, int bp, int sp, int } #endif -/* Structures needed for int 25 / int 26 */ -struct HugeSectorBlock -{ - ULONG blkno; - WORD nblks; - BYTE FAR *buf; -}; - struct int25regs { UWORD es, @@ -1788,7 +1999,7 @@ struct int25regs /* this function is called from an assembler wrapper function */ -VOID int2526_handler(WORD mode, struct int25regs FAR * r) +VOID ASMCFUNC int2526_handler(WORD mode, struct int25regs FAR * r) { ULONG blkno; UWORD nblks; @@ -1806,7 +2017,16 @@ VOID int2526_handler(WORD mode, struct int25regs FAR * r) r->flags |= FLG_CARRY; return; } - + +#ifdef WITHFAT32 + if (!(CDSp->cds_table[drv].cdsFlags & CDSNETWDRV) && + ISFAT32(CDSp->cds_table[drv].cdsDpb)) + { + r->ax = 0x207; + r->flags |= FLG_CARRY; + return; + } +#endif nblks = r->cx; blkno = r->dx; @@ -1868,3 +2088,138 @@ static VOID StartTrace(VOID) } #endif +/* + this function is called from an assembler wrapper function + and serves the internal dos calls - int2f/12xx +*/ +struct int2f12regs +{ + UWORD es,ds; + UWORD di,si,bp,bx,dx,cx,ax; + UWORD ip,cs,flags; + UWORD callerARG1; /* used if called from INT2F/12 */ +}; + +VOID ASMCFUNC int2F_12_handler(struct int2f12regs r) +{ + UWORD function = r.ax & 0xff; + + if (function > 0x31) + return; + + switch(function) + { + case 0x00: /* installation check */ + r.ax |= 0x00ff; + break; + + case 0x03: /* get DOS data segment */ + r.ds = FP_SEG(&nul_dev); + break; + + case 0x08: /* decrease SFT reference count */ + { + UWORD FAR *SFTp = MK_FP(r.es,r.di); + + r.ax = *SFTp; + + if (--*SFTp == 0) --*SFTp; + + } + break; + + case 0x12: /* get length of asciiz string */ + + r.cx = fstrlen(MK_FP(r.es, r.di))+1; + + break; + + + + case 0x18: /* get caller's registers */ + + r.ds = FP_SEG(user_r); + r.si = FP_OFF(user_r); + break; + + case 0x1b: /* #days in February - valid until 2099.*/ + + r.ax = (r.ax & 0xff00) | (r.cx & 3 ? 28 : 29); + break; + + case 0x21: /* truename */ + + truename(MK_FP(r.ds,r.si), MK_FP(r.es,r.di),0); + + break; + + case 0x25: /* get length of asciiz string */ + + r.cx = fstrlen(MK_FP(r.ds, r.si))+1; + break; + + + case 0x2a: /* Set FastOpen but does nothing. */ + + r.flags &= ~FLG_CARRY; + break; + + case 0x2c: /* added by James Tabor For Zip Drives + Return Null Device Pointer */ + /* by UDOS+RBIL: get header of SECOND device driver in device chain, + omitting the NUL device TE*/ + r.bx = FP_SEG(nul_dev.dh_next); + r.ax = FP_OFF(nul_dev.dh_next); + + break; + + case 0x2e: /* GET or SET error table addresse - ignored + called by MS debug with DS != DOSDS, printf + doesn't work!! */ + break; + + case 0x16: /* get address of system file table entry - used by NET.EXE + BX system file table entry number ( such as returned from 2F/1220) + returns + ES:DI pointer to SFT entry */ + { + sft FAR *p = get_sft(r.bx); + + r.es = FP_SEG(p); + r.di = FP_OFF(p); + break; + } + + + case 0x17: /* get current directory structure for drive - used by NET.EXE + STACK: drive (0=A:,1=B,...) + ; returns + ; CF set if error + ; DS:SI pointer to CDS for drive + ; + ; called like + ; push 2 (c-drive) + ; mov ax,1217 + ; int 2f + ; + ; probable use: get sizeof(CDSentry) + */ + { + UWORD drv = r.callerARG1 & 0xff; + + if (drv >= lastdrive) + r.flags |= FLG_CARRY; + else + { + r.ds = FP_SEG(CDSp); + r.si = FP_OFF(&CDSp->cds_table[drv]); + r.flags &= ~FLG_CARRY; + } + break; + } + default: + printf("unknown internal dos function INT2F/12%02x\n",function); + + } + +} diff --git a/kernel/intr.h b/kernel/intr.h index be03c575..2b6fd903 100644 --- a/kernel/intr.h +++ b/kernel/intr.h @@ -6,4 +6,4 @@ struct REGPACK { unsigned r_bp, r_di, r_si, r_ds, r_es, r_flags; }; -extern void intr(int intrnr, struct REGPACK *rp); +extern void ASMCFUNC intr(int intrnr, struct REGPACK *rp); diff --git a/kernel/io.asm b/kernel/io.asm index 37fec88c..1708c9b5 100644 --- a/kernel/io.asm +++ b/kernel/io.asm @@ -28,6 +28,9 @@ ; $Header$ ; ; $Log$ +; Revision 1.10 2001/09/23 20:39:44 bartoldeman +; FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling +; ; Revision 1.9 2001/04/29 17:34:40 bartoldeman ; A new SYS.COM/config.sys single stepping/console output/misc fixes. ; @@ -217,6 +220,15 @@ _blk_dev equ $ _nblk_rel db 4 db 0,0,0,0,0,0,0 +; quick hack for MSC + global _Get_nblk_rel +_Get_nblk_rel: + mov ah,0 + mov al,[cs:_nblk_rel] + retf +;end of hack + + ; ; Temporary table until next release diff --git a/kernel/io.inc b/kernel/io.inc index 800ca2a7..4a62ab2d 100644 --- a/kernel/io.inc +++ b/kernel/io.inc @@ -30,6 +30,9 @@ ; $Header$ ; ; $Log$ +; Revision 1.5 2001/09/23 20:39:44 bartoldeman +; FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling +; ; Revision 1.4 2001/03/21 02:56:26 bartoldeman ; See history.txt for changes. Bug fixes and HMA support are the main ones. ; @@ -63,6 +66,25 @@ %include "segs.inc" +; +; Error Return Codes +; + +%define E_WRPRT 0 ; Write Protect +%define E_UNIT 1 ; Unknown Unit +%define E_NOTRDY 2 ; Device Not Ready +%define E_CMD 3 ; Unknown Command +%define E_CRC 4 ; Crc Error +%define E_LENGTH 5 ; Bad Length +%define E_SEEK 6 ; Seek Error +%define E_MEDIA 7 ; Unknown MEDIA +%define E_NOTFND 8 ; Sector Not Found +%define E_PAPER 9 ; No Paper +%define E_WRITE 10 ; Write Fault +%define E_READ 11 ; Read Fault +%define E_FAILURE 12 ; General Failure + + extern _IOExit:wrt TGROUP extern _IOSuccess:wrt TGROUP extern _IOErrorExit:wrt TGROUP diff --git a/kernel/kernel.asm b/kernel/kernel.asm index ca74ba59..5898e3a4 100644 --- a/kernel/kernel.asm +++ b/kernel/kernel.asm @@ -28,6 +28,9 @@ ; $Id$ ; ; $Log$ +; Revision 1.18 2001/09/23 20:39:44 bartoldeman +; FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling +; ; Revision 1.17 2001/08/19 12:58:36 bartoldeman ; Time and date fixes, Ctrl-S/P, findfirst/next, FCBs, buffers, tsr unloading ; @@ -171,7 +174,7 @@ beyond_entry: resb 256-(beyond_entry-entry) segment INIT_TEXT - extern _main:wrt IGROUP + extern _FreeDOSmain:wrt IGROUP ; ; kernel start-up @@ -255,7 +258,7 @@ floppy: mov byte [_BootDrive],bl ; tell where we came from mov ax,cs mov ds,ax mov es,ax - jmp _main + jmp _FreeDOSmain segment INIT_TEXT_END @@ -292,6 +295,8 @@ segment _FIXED_DATA ; use. A 0 indicates MS-DOS 3.X style, a 1 indicates MS-DOS 4.0-6.X style. global DATASTART DATASTART: + global _DATASTART +_DATASTART: dos_data db 0 dw kernel_start db 0 ; padding @@ -326,7 +331,7 @@ _sfthead dw _firstsftt ; 0004 System File Table head global _clock _clock dd 0 ; 0008 CLOCK$ device global _syscon -_syscon dd 0 ; 000c console device +_syscon dw _con_dev,seg _con_dev ; 000c console device global _maxbksize _maxbksize dw 512 ; 0010 maximum bytes/sector of any block device dw buf_info ; 0012 pointer to buffers info structure @@ -654,14 +659,6 @@ intr_dos_stk resw 1 intr_dos_seg resw 1 - global _api_sp -_api_sp dw 0 ; api stacks - for context - global _api_ss -_api_ss dw 0 ; switching - global _usr_sp -_usr_sp dw 0 ; user stacks - global _usr_ss -_usr_ss dw 0 global _ram_top _ram_top dw 0 @@ -763,10 +760,12 @@ segment _STACK class=STACK stack segment _TEXT ; dummy interrupt return handlers - + + global _int22_handler global _int28_handler global _int2a_handler global _empty_handler +_int22_handler: _int28_handler: _int2a_handler: _empty_handler: diff --git a/kernel/main.c b/kernel/main.c index 943f267f..2293cab6 100644 --- a/kernel/main.c +++ b/kernel/main.c @@ -29,6 +29,10 @@ #include "portab.h" #include "init-mod.h" +#include "dyndata.h" +#include "init-dat.h" + + /* These are the far variables from the DOS data segment that we need here. The @@ -38,31 +42,31 @@ -- Bart */ -extern UBYTE FAR nblkdev, - FAR lastdrive; /* value of last drive */ +extern UBYTE DOSFAR nblkdev, + DOSFAR lastdrive; /* value of last drive */ GLOBAL BYTE - FAR os_major, /* major version number */ - FAR os_minor, /* minor version number */ - FAR dosidle_flag, - FAR BootDrive, /* Drive we came up from */ - FAR default_drive; /* default drive for dos */ - -GLOBAL BYTE FAR os_release[]; -GLOBAL BYTE FAR copyright[]; -GLOBAL seg FAR RootPsp; /* Root process -- do not abort */ - -extern struct dpb FAR * FAR DPBp; /* First drive Parameter Block */ -extern cdstbl FAR * FAR CDSp; /* Current Directory Structure */ - -extern struct dhdr FAR * FAR clock, /* CLOCK$ device */ - FAR * FAR syscon; /* console device */ -extern struct dhdr FAR con_dev, /* console device drive */ - FAR clk_dev, /* Clock device driver */ - FAR blk_dev; /* Block device (Disk) driver */ + DOSFAR os_major, /* major version number */ + DOSFAR os_minor, /* minor version number */ + DOSFAR dosidle_flag, + DOSFAR BootDrive, /* Drive we came up from */ + DOSFAR default_drive; /* default drive for dos */ + +GLOBAL BYTE DOSFAR os_release[]; +GLOBAL BYTE DOSFAR copyright[]; +GLOBAL seg DOSFAR RootPsp; /* Root process -- do not abort */ + +extern struct dpb FAR * DOSFAR DPBp; /* First drive Parameter Block */ +extern cdstbl FAR * DOSFAR CDSp; /* Current Directory Structure */ + +extern struct dhdr FAR * DOSFAR clock, /* CLOCK$ device */ + FAR * DOSFAR syscon; /* console device */ +extern struct dhdr DOSTEXTFAR con_dev, /* console device drive */ + DOSTEXTFAR clk_dev, /* Clock device driver */ + DOSTEXTFAR blk_dev; /* Block device (Disk) driver */ extern UWORD - FAR ram_top; /* How much ram in Kbytes */ -extern iregs FAR * FAR user_r; /* User registers for int 21h call */ + DOSFAR ram_top; /* How much ram in Kbytes */ +extern iregs FAR * DOSFAR user_r; /* User registers for int 21h call */ extern BYTE FAR _HMATextEnd[]; #ifdef VERSION_STRINGS @@ -71,6 +75,9 @@ static BYTE *mainRcsId = "$Id$"; /* * $Log$ + * Revision 1.21 2001/09/23 20:39:44 bartoldeman + * FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling + * * Revision 1.20 2001/07/28 18:13:06 bartoldeman * Fixes for FORMAT+SYS, FATFS, get current dir, kernel init memory situation. * @@ -234,9 +241,32 @@ INIT static VOID init_kernel(VOID); INIT static VOID signon(VOID); INIT VOID kernel(VOID); INIT VOID FsConfig(VOID); +INIT VOID InitPrinters(VOID); + +#ifdef _MSC_VER + BYTE _acrtused = 0; +#endif + +#ifdef _MSC_VER +__segment DosDataSeg = 0; /* serves for all references to the DOS DATA segment + necessary for MSC+our funny linking model + */ +__segment DosTextSeg = 0; + +#endif + -INIT VOID main(void) +INIT VOID ASMCFUNC FreeDOSmain(void) { +#ifdef _MSC_VER + extern FAR DATASTART; + extern FAR prn_dev; + DosDataSeg = (__segment)&DATASTART; + DosTextSeg = (__segment)&prn_dev; +#endif + + + setvec(0, int0_handler); /* zero divide */ setvec(1, empty_handler); /* single step */ setvec(3, empty_handler); /* debug breakpoint */ @@ -295,7 +325,7 @@ INIT void init_kernel(void) lpOldTop = lpTop = MK_FP(FP_SEG(lpTop) - 0xfff, 0xfff0); /* Fake int 21h stack frame */ - user_r = (iregs FAR *) DOS_PSP + 0xD0; + user_r = (iregs FAR *) MK_FP(DOS_PSP,0xD0); #ifndef KDB for (i = 0x20; i <= 0x3f; i++) @@ -304,6 +334,7 @@ INIT void init_kernel(void) /* Initialize IO subsystem */ InitIO(); + InitPrinters(); #ifndef KDB /* set interrupt vectors */ @@ -431,14 +462,31 @@ INIT VOID FsConfig(VOID) INIT VOID signon() { - BYTE tmp_or[81]; /* ugly constant, but this string should fit on one line */ - - printf("\nFreeDOS Kernel compatibility %d.%d\n%S\n", - os_major, os_minor, copyright); - fmemcpy(tmp_or, os_release, 81); - printf(tmp_or, - REVISION_MAJOR, REVISION_MINOR, REVISION_SEQ, - BUILD); + printf("\n%S" ,(void FAR *)os_release); + + printf("Kernel compatibility %d.%d", + os_major, os_minor ); + +#if defined(__TURBOC__) + printf(" - TURBOC"); +#elif defined(_MSC_VER) + printf(" - MSC"); +#elif defined(__WATCOMC__) + printf(" - WATCOMC"); +#else + generate some bullshit error here, as the compiler should be known +#endif + +#if defined (I386) + printf(" - 80386 CPU required"); +#elif defined (I186) + printf(" - 80186 CPU required"); +#endif + +#ifdef WITHFAT32 + printf(" - FAT32 support"); +#endif + printf("\n\n%S",(void FAR *)copyright); } INIT void kernel() @@ -683,3 +731,29 @@ VOID init_fatal(BYTE * err_msg) printf("\nInternal kernel error - %s\nSystem halted\n", err_msg); for (;;) ; } + +/* + Initialize all printers + + this should work. IMHO, this might also be done on first use + of printer, as I never liked the noise by a resetting printer, and + I usually much more often reset my system, then I print :-) + */ + +INIT VOID InitPrinters(VOID) +{ + iregs r; + int num_printers,i; + + init_call_intr(0x11,&r); /* get equipment list */ + + num_printers = (r.a.x >> 14) & 3; /* bits 15-14 */ + + for (i = 0;i < num_printers;i++) + { + r.a.x = 0x0100; /* initialize printer */ + r.d.x = i; + init_call_intr(0x17,&r); + } +} + diff --git a/kernel/memmgr.c b/kernel/memmgr.c index 116b3cfc..3537ed2c 100644 --- a/kernel/memmgr.c +++ b/kernel/memmgr.c @@ -35,6 +35,9 @@ static BYTE *memmgrRcsId = "$Id$"; /* * $Log$ + * Revision 1.15 2001/09/23 20:39:44 bartoldeman + * FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling + * * Revision 1.14 2001/04/21 22:32:53 bartoldeman * Init DS=Init CS, fixed stack overflow problems and misc bugs. * @@ -524,6 +527,12 @@ COUNT DosMemChange(UWORD para, UWORD size, UWORD * maxSize) for (i = 0; i < 8; i++) q->m_name[i] = '\0'; } + + /* MS network client NET.EXE: DosMemChange sets the PSP * + * not tested, if always, or only on success TE* + * only on success seems more logical to me - Bart */ + p->m_psp = cu_psp; + return SUCCESS; } diff --git a/kernel/newstuff.c b/kernel/newstuff.c index f9b17417..00a31c43 100644 --- a/kernel/newstuff.c +++ b/kernel/newstuff.c @@ -31,6 +31,9 @@ static BYTE *mainRcsId = "$Id$"; /* * $Log$ + * Revision 1.14 2001/09/23 20:39:44 bartoldeman + * FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling + * * Revision 1.13 2001/08/20 20:32:15 bartoldeman * Truename, get free space and ctrl-break fixes. * @@ -255,7 +258,7 @@ COUNT get_verify_drive(char FAR *src) */ -COUNT truename(char FAR * src, char FAR * dest, COUNT t) +COUNT ASMCFUNC truename(char FAR * src, char FAR * dest, COUNT t) { static char buf[128] = "A:\\\0\0\0\0\0\0\0\0\0"; char *bufp = buf + 3; @@ -353,7 +356,7 @@ COUNT truename(char FAR * src, char FAR * dest, COUNT t) if (*src != '\\' && *src != '/') /* append current dir */ { - DosGetCuDir(i+1, bufp); + DosGetCuDir((UBYTE)(i+1), bufp); if (*bufp) { while (*bufp) diff --git a/kernel/nls.c b/kernel/nls.c index 1dfe9d58..5b8b3acf 100644 --- a/kernel/nls.c +++ b/kernel/nls.c @@ -44,6 +44,9 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.9 2001/09/23 20:39:44 bartoldeman + * FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling + * * Revision 1.8 2001/07/09 22:19:33 bartoldeman * LBA/FCB/FAT/SYS/Ctrl-C/ioctl fixes + memory savings * @@ -482,7 +485,7 @@ VOID DosUpMem(VOID FAR * str, unsigned len) * the HiByte of the first argument must remain unchanged. * See NLSSUPT.ASM -- 2000/03/30 ska */ -unsigned char DosUpChar(unsigned char ch) +unsigned char ASMCFUNC DosUpChar(unsigned char ch) /* upcase a single character */ { assertDSeqSS(); /* because "&ch" */ @@ -629,11 +632,10 @@ COUNT DosSetCodepage(UWORD actCP, UWORD sysCP) Return value: AL register to be returned if AL == 0, Carry must be cleared, otherwise set */ -#pragma argsused -UWORD syscall_MUX14(DIRECT_IREGS) +UWORD ASMCFUNC syscall_MUX14(DIRECT_IREGS) { struct nlsPackage FAR*nls; /* addressed NLS package */ - if (flags || cs || ip || ds || es || si); + UNREFERENCED_PARAMETER (flags || cs || ip || ds || es || si); log( ("NLS: MUX14(): subfct=%x, cp=%u, cntry=%u\n", AL, BX, DX) ); diff --git a/kernel/prf.c b/kernel/prf.c index 2d73e7da..d43a352c 100644 --- a/kernel/prf.c +++ b/kernel/prf.c @@ -28,7 +28,7 @@ #include "portab.h" -/* #define DOSEMU */ +/*#define DOSEMU*/ #ifdef FORINIT #define fstrlen reloc_call_fstrlen @@ -41,7 +41,7 @@ #define hexd init_hexd #endif -COUNT fstrlen (BYTE FAR * s); /* don't want globals.h, sorry */ +COUNT ASMCFUNC fstrlen (BYTE FAR * s); /* don't want globals.h, sorry */ #ifdef VERSION_STRINGS @@ -50,6 +50,9 @@ static BYTE *prfRcsId = "$Id$"; /* * $Log$ + * Revision 1.12 2001/09/23 20:39:44 bartoldeman + * FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling + * * Revision 1.11 2001/07/22 01:58:58 bartoldeman * Support for Brian's FORMAT, DJGPP libc compilation, cleanups, MSCDEX * @@ -75,6 +78,9 @@ static BYTE *prfRcsId = "$Id$"; * recoded for smaller object footprint, added main() for testing+QA * * $Log$ + * Revision 1.12 2001/09/23 20:39:44 bartoldeman + * FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling + * * Revision 1.11 2001/07/22 01:58:58 bartoldeman * Support for Brian's FORMAT, DJGPP libc compilation, cleanups, MSCDEX * @@ -141,7 +147,7 @@ static BYTE *prfRcsId = "$Id$"; * Initial revision. */ -static BYTE *charp; +static BYTE *charp = 0; #ifdef PROTO VOID handle_char(COUNT); @@ -162,10 +168,6 @@ VOID cso(COUNT); VOID cso(); #endif -#ifdef __TURBOC__ -void __int__(int); /* TC 2.01 requires this. :( -- ror4 */ -#endif - #ifdef FORSYS COUNT fstrlen (BYTE FAR * s) /* don't want globals.h, sorry */ { @@ -188,9 +190,18 @@ put_console(COUNT c) #ifdef FORSYS write(1,&c,1); /* write character to stdout */ #else +#if defined(__TURBOC__) _AX = 0x0e00 | c; _BX = 0x0070; __int__(0x10); +#else + __asm { + mov al, byte ptr c; + mov ah, 0x0e; + mov bx, 0x0070; + int 0x10; + } +#endif /* __TURBO__*/ #endif } @@ -227,7 +238,9 @@ BYTE * p = q = s; do { /* generate digits in reverse order */ - *p++ = "0123456789abcdef"[(UWORD)(u % base)]; + static char hexDigits[] = "0123456789abcdef"; + + *p++ = hexDigits[(UWORD)(u % base)]; } while ((u /= base) > 0); @@ -365,9 +378,10 @@ COUNT case 'p': { WORD w[2]; + static char pointerFormat[] = "%04x:%04x"; w[1] = *((unsigned int*) arg)++; w[0] = *((unsigned int*) arg)++; - do_printf("%04x:%04x",(BYTE**)&w); + do_printf(pointerFormat,(BYTE**)&w); continue; } diff --git a/kernel/printer.asm b/kernel/printer.asm index a3718a88..ee855ec5 100644 --- a/kernel/printer.asm +++ b/kernel/printer.asm @@ -28,6 +28,9 @@ ; $Header$ ; ; $Log$ +; Revision 1.4 2001/09/23 20:39:44 bartoldeman +; FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling +; ; Revision 1.3 2000/05/25 20:56:21 jimtabor ; Fixed project history ; @@ -52,6 +55,17 @@ %include "io.inc" + %define PRT_TIMEOUT 01h + %define PRT_IOERROR 08h + %define PRT_SELECTED 10h + %define PRT_OUTOFPAPER 20h + %define PRT_ACK 40h + %define PRT_NOTBUSY 80h + + %define PRT_WRITECHAR 00h + %define PRT_INITPORT 01h + %define PRT_GETSTATUS 02h + segment _IO_FIXED_DATA global LptTable @@ -93,18 +107,16 @@ uPrtQuantum dw 50h PrtWrite: jcxz PrtWr3 ; Exit if nothing to write PrtWr1: - mov bx,2 + mov bx,2 ; number of retries PrtWr2: - mov al,[es:di] - inc di - xor ah,ah ; Zero register - call PrtIOCall ; (0800) + + call PrintSingleCharacter + jnz PrtWr4 ; Exit if done loop PrtWr1 ; otherwise loop PrtWr3: jmp _IOExit PrtWr4: - dec di dec bx jnz PrtWr2 PrtWr5: @@ -115,32 +127,32 @@ PrtWr5: PrtOutStat: call GetPrtStat jnz PrtWr5 - mov al,9 - test ah,20h + mov al, E_PAPER + test ah, PRT_OUTOFPAPER jnz PrtWr5 - test ah,80h + test ah, PRT_NOTBUSY jnz PrtWr3 jmp _IODone GetPrtStat: - mov ah,2 + mov ah,PRT_GETSTATUS PrtIOCall: call GetUnitNum int 17h ; print char al, get status ah - test ah,8 - jz PrtIOCal2 - mov al,9 - test ah,20h + test ah, PRT_TIMEOUT|PRT_IOERROR + jnz PrtIOCal2 + mov al, E_PAPER + test ah, PRT_OUTOFPAPER jnz PrtIOCal1 - inc al + inc al ; al<-E_WRITE PrtIOCal1: retn PrtIOCal2: - mov al,2 - test ah,1 + mov al, E_NOTRDY + test ah, PRT_TIMEOUT retn @@ -161,7 +173,7 @@ PrtOtBsy1: PrtOtBsy2: call GetPrtStat jnz PrtOtBsy3 - test ah,80h + test ah, PRT_NOTBUSY loopz PrtOtBsy2 pop cx jz PrtOtBsy4 @@ -206,3 +218,66 @@ PrtGnIoctl3: mov [cs:uPrtQuantum+bx],cx mov [es:di],cx jmp _IOExit + + + +; +; original implementation didn't work at all. +; this one's not much better either, +; but should print a little bit +; +; the status bits = AH +; +; 1 0 +; 80 - BUSY not busy busy +; 40 - ACK transfer finished not yet finished +; 20 - PAP no paper available paper OK +; 10 - ONOF printer online not online +; 08 - ERR some error no error +; 01 - TIM some error when transfer OK +; +; some states +; 30 - there is no printer at all +; c8 - there is a printer without power +; 10 - printer with power, but not initialized +; 90 - this one is fine +; + + +; you must not simply print without asking for status +; as the BIOS has a LARGE timeout before aborting +; + +PrintSingleCharacter: + + mov ah, PRT_GETSTATUS ; get status, ah=2 + call GetUnitNum + int 17h ; print char al, get status ah + + test ah, PRT_OUTOFPAPER|PRT_IOERROR + jnz decode_error + + test ah, PRT_NOTBUSY + jz decode_error + + + mov al,[es:di] + mov ah,PRT_WRITECHAR ; print character, ah=0 + call GetUnitNum + int 17h ; print char al, get status ah + + test ah, PRT_OUTOFPAPER|PRT_IOERROR|PRT_TIMEOUT + jnz decode_error + inc di + xor al,al ; set zero flag + clear al + ret + + +decode_error: + mov al, E_PAPER + test ah, PRT_OUTOFPAPER ;out_of_paper, 20h + jnz out_of_paper + mov al, E_WRITE +out_of_paper: + or al,al ; reset zero flag + ret diff --git a/kernel/procsupt.asm b/kernel/procsupt.asm index d5402b35..aa7a8983 100644 --- a/kernel/procsupt.asm +++ b/kernel/procsupt.asm @@ -30,6 +30,9 @@ ; $Id$ ; ; $Log$ +; Revision 1.7 2001/09/23 20:39:44 bartoldeman +; FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling +; ; Revision 1.6 2001/04/15 03:21:50 bartoldeman ; See history.txt for the list of fixes. ; @@ -93,10 +96,6 @@ %include "segs.inc" - extern _api_sp:wrt DGROUP ; api stacks - for context - extern _api_ss:wrt DGROUP ; switching - extern _usr_sp:wrt DGROUP ; user stacks - extern _usr_ss:wrt DGROUP extern _lpUserStack:wrt DGROUP extern _break_flg:wrt DGROUP ; break detected flag @@ -104,14 +103,14 @@ %include "stacks.inc" -segment _TEXT +segment HMA_TEXT extern _DGROUP_:wrt TGROUP ; ; Special call for switching processes ; -; void interrupt far exec_user(irp) +; void exec_user(irp) ; iregs far *irp; ; global _exec_user @@ -123,10 +122,10 @@ _exec_user: ; ; ; - mov bp,sp + pop ax ; return address (unused) - mov ax,word [bp+6] ; irp (user ss:sp) - mov dx,word [bp+8] + pop ax ; irp (user ss:sp) + pop dx cli mov ss,dx mov sp,ax ; set-up user stack @@ -135,7 +134,7 @@ _exec_user: POP$ALL iret - +segment _TEXT ;; Called whenever the BIOS detects a ^Break state @@ -208,8 +207,6 @@ _spawn_int23: mov ss, [_lpUserStack+2] mov sp, [_lpUserStack] -; mov ss,[_usr_ss] -; mov sp,[_usr_sp] sti ; get all the user registers back diff --git a/kernel/proto.h b/kernel/proto.h index 3631c907..93211a58 100644 --- a/kernel/proto.h +++ b/kernel/proto.h @@ -34,6 +34,9 @@ static BYTE *Proto_hRcsId = "$Id$"; /* * $Log$ + * Revision 1.22 2001/09/23 20:39:44 bartoldeman + * FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling + * * Revision 1.21 2001/08/19 12:58:36 bartoldeman * Time and date fixes, Ctrl-S/P, findfirst/next, FCBs, buffers, tsr unloading * @@ -199,7 +202,7 @@ BOOL flush(void); BOOL fill(REG struct buffer FAR * bp, ULONG blkno, COUNT dsk); /* *** Changed on 9/4/00 BER */ UWORD dskxfer(COUNT dsk, ULONG blkno, VOID FAR * buf, UWORD numblocks, COUNT mode); -/* *** End of change +/* *** End of change */ /* chario.c */ VOID sto(COUNT c); @@ -218,6 +221,9 @@ UCOUNT sti(keyboard * kp); sft FAR *get_sft(UCOUNT); /* dosfns.c */ +#ifdef WITHFAT32 +struct dpb FAR *GetDriveDPB(UBYTE drive, COUNT *rc); +#endif BYTE FAR *get_root(BYTE FAR *); BOOL fnmatch(BYTE FAR *, BYTE FAR *, COUNT, COUNT); BOOL check_break(void); @@ -238,6 +244,7 @@ COUNT DosOpenSft(BYTE * fname, COUNT mode); COUNT DosClose(COUNT hndl); COUNT DosCloseSft(WORD sft_idx); VOID DosGetFree(UBYTE drive, COUNT FAR * spc, COUNT FAR * navc, COUNT FAR * bps, COUNT FAR * nc); +COUNT DosGetExtFree(BYTE FAR *DriveString, struct xfreespace FAR *xfsp); COUNT DosGetCuDir(UBYTE drive, BYTE FAR * s); COUNT DosChangeDir(BYTE FAR * s); COUNT DosFindFirst(UCOUNT attr, BYTE FAR * name); @@ -260,7 +267,7 @@ sft FAR *idx_to_sft(COUNT SftIndex); COUNT get_sft_idx(UCOUNT hndl); /*dosidle.asm */ -VOID DosIdle_int(void); +VOID ASMCFUNC DosIdle_int(void); /* dosnames.c */ VOID SpacePad(BYTE *, COUNT); @@ -268,7 +275,8 @@ COUNT ParseDosName(BYTE *, COUNT *, BYTE *, BYTE *, BYTE *, BOOL); /* COUNT ParseDosPath(BYTE *, COUNT *, BYTE *, BYTE FAR *); */ /* dsk.c */ -COUNT FAR blk_driver(rqptr rp); +COUNT FAR ASMCFUNC blk_driver(rqptr rp); +ddt *getddt(int dev); /* error.c */ VOID dump(void); @@ -312,7 +320,7 @@ UCOUNT writeblock(COUNT fd, VOID FAR * buffer, UCOUNT count, COUNT * err); COUNT dos_read(COUNT fd, VOID FAR * buffer, UCOUNT count); COUNT dos_write(COUNT fd, VOID FAR * buffer, UCOUNT count); LONG dos_lseek(COUNT fd, LONG foffset, COUNT origin); -UWORD dos_free(struct dpb FAR *dpbp); +CLUSTER dos_free(struct dpb FAR *dpbp); VOID trim_path(BYTE FAR * s); @@ -327,15 +335,23 @@ COUNT media_check(REG struct dpb FAR *dpbp); f_node_ptr xlt_fd(COUNT fd); COUNT xlt_fnp(f_node_ptr fnp); struct dhdr FAR *select_unit(COUNT drive); +#ifdef WITHFAT32 +VOID bpb_to_dpb(bpb FAR *bpbp, REG struct dpb FAR * dpbp, BOOL extended); +#else VOID bpb_to_dpb(bpb FAR *bpbp, REG struct dpb FAR * dpbp); +#endif /* fattab.c */ -UCOUNT link_fat(struct dpb FAR *dpbp, UCOUNT Cluster1, REG UCOUNT Cluster2); -UCOUNT link_fat16(struct dpb FAR *dpbp, UCOUNT Cluster1, UCOUNT Cluster2); -UCOUNT link_fat12(struct dpb FAR *dpbp, UCOUNT Cluster1, UCOUNT Cluster2); -UWORD next_cluster(struct dpb FAR *dpbp, REG UCOUNT ClusterNum); -UWORD next_cl16(struct dpb FAR *dpbp, REG UCOUNT ClusterNum); -UWORD next_cl12(struct dpb FAR *dpbp, REG UCOUNT ClusterNum); +void read_fsinfo(struct dpb FAR *dpbp); +void write_fsinfo(struct dpb FAR *dpbp); +UCOUNT link_fat(struct dpb FAR *dpbp, CLUSTER Cluster1, REG CLUSTER Cluster2); +UCOUNT link_fat32(struct dpb FAR *dpbp, CLUSTER Cluster1, CLUSTER Cluster2); +UCOUNT link_fat16(struct dpb FAR *dpbp, CLUSTER Cluster1, CLUSTER Cluster2); +UCOUNT link_fat12(struct dpb FAR *dpbp, CLUSTER Cluster1, CLUSTER Cluster2); +CLUSTER next_cluster(struct dpb FAR *dpbp, REG CLUSTER ClusterNum); +CLUSTER next_cl32(struct dpb FAR *dpbp, REG CLUSTER ClusterNum); +CLUSTER next_cl16(struct dpb FAR *dpbp, REG CLUSTER ClusterNum); +CLUSTER next_cl12(struct dpb FAR *dpbp, REG CLUSTER ClusterNum); /* fcbfns.c */ VOID DosOutputString(BYTE FAR * s); @@ -397,22 +413,22 @@ VOID fbcopy(REG VOID FAR * s, REG VOID FAR * d, REG COUNT n); */ VOID strcpy(REG BYTE * d, REG BYTE * s); #define scopy(s, d) strcpy(d,s) -VOID fmemcpy(REG VOID FAR * d, REG VOID FAR * s, REG COUNT n); +VOID ASMCFUNC fmemcpy(REG VOID FAR * d, REG VOID FAR * s, REG COUNT n); #define fbcopy(s, d, n) fmemcpy(d,s,n) /*VOID fscopy(REG BYTE FAR * s, REG BYTE FAR * d);*/ -VOID fstrcpy(REG BYTE FAR * d, REG BYTE FAR * s); +VOID ASMCFUNC fstrcpy(REG BYTE FAR * d, REG BYTE FAR * s); #define fscopy(s,d) fstrcpy(d,s) -VOID fstrcpy(REG BYTE FAR * d, REG BYTE FAR * s); +VOID ASMCFUNC fstrcpy(REG BYTE FAR * d, REG BYTE FAR * s); /*VOID bcopy(REG BYTE * s, REG BYTE * d, REG COUNT n);*/ -void memcpy(REG void * d, REG VOID * s, REG COUNT n); +void ASMCFUNC memcpy(REG void * d, REG VOID * s, REG COUNT n); #define bcopy(s,d,n) memcpy(d,s,n) -void fmemset(REG VOID FAR * s, REG int ch, REG COUNT n); -void memset(REG VOID * s, REG int ch, REG COUNT n); +void ASMCFUNC fmemset(REG VOID FAR * s, REG int ch, REG COUNT n); +void ASMCFUNC memset(REG VOID * s, REG int ch, REG COUNT n); /* nls.c */ @@ -420,7 +436,7 @@ BYTE DosYesNo(unsigned char ch); #ifndef DosUpMem VOID DosUpMem(VOID FAR * str, unsigned len); #endif -unsigned char DosUpChar(unsigned char ch); +unsigned char ASMCFUNC DosUpChar(unsigned char ch); VOID DosUpString(char FAR *str); VOID DosUpFMem(VOID FAR *str, unsigned len); unsigned char DosUpFChar(unsigned char ch); @@ -435,7 +451,7 @@ COUNT DosSetCountry(UWORD cntry); #endif COUNT DosGetCodepage(UWORD FAR* actCP, UWORD FAR* sysCP); COUNT DosSetCodepage(UWORD actCP, UWORD sysCP); -UWORD syscall_MUX14(DIRECT_IREGS); +UWORD ASMCFUNC syscall_MUX14(DIRECT_IREGS); /* prf.c */ VOID put_console(COUNT c); @@ -444,37 +460,42 @@ WORD sprintf(BYTE * buff, CONST BYTE * fmt, ...); VOID hexd(char *title,VOID FAR *p,COUNT numBytes); /* strings.c */ -COUNT strlen(REG BYTE * s); -COUNT fstrlen(REG BYTE FAR * s); -VOID _fstrcpy(REG BYTE FAR * d, REG BYTE FAR * s); -VOID strncpy(REG BYTE * d, REG BYTE * s, COUNT l); -COUNT strcmp(REG BYTE * d, REG BYTE * s); -COUNT fstrcmp(REG BYTE FAR * d, REG BYTE FAR * s); -COUNT fstrncmp(REG BYTE FAR * d, REG BYTE FAR * s, COUNT l); -COUNT strncmp(REG BYTE * d, REG BYTE * s, COUNT l); +COUNT ASMCFUNC strlen(REG BYTE * s); +COUNT ASMCFUNC fstrlen(REG BYTE FAR * s); +VOID ASMCFUNC _fstrcpy(REG BYTE FAR * d, REG BYTE FAR * s); +VOID ASMCFUNC strncpy(REG BYTE * d, REG BYTE * s, COUNT l); +COUNT ASMCFUNC strcmp(REG BYTE * d, REG BYTE * s); +COUNT ASMCFUNC fstrcmp(REG BYTE FAR * d, REG BYTE FAR * s); +COUNT ASMCFUNC fstrncmp(REG BYTE FAR * d, REG BYTE FAR * s, COUNT l); +COUNT ASMCFUNC strncmp(REG BYTE * d, REG BYTE * s, COUNT l); /* void fsncopy(REG BYTE FAR * s, REG BYTE FAR * d, COUNT l); #define fstrncpy(d,s,l) fsncopy(s,d,l) */ -void fstrncpy(REG BYTE FAR * d, REG BYTE FAR * s, COUNT l); +void ASMCFUNC fstrncpy(REG BYTE FAR * d, REG BYTE FAR * s, COUNT l); #define fsncopy(s,d,l) fstrncpy(d,s,l) -BYTE *strchr(BYTE * s, BYTE c); +BYTE * ASMCFUNC strchr(BYTE * s, BYTE c); /* sysclk.c */ -WORD FAR clk_driver(rqptr rp); +WORD FAR ASMCFUNC clk_driver(rqptr rp); COUNT BcdToByte(COUNT x); COUNT BcdToWord(BYTE * x, UWORD * mon, UWORD * day, UWORD * yr); COUNT ByteToBcd(COUNT x); LONG WordToBcd(BYTE * x, UWORD * mon, UWORD * day, UWORD * yr); -/* syscon.c */ -WORD con_driver(rqptr rp); -VOID break_handler(void); - /* syspack.c */ +#ifdef NONNATIVE VOID getdirent(BYTE FAR * vp, struct dirent FAR * dp); VOID putdirent(struct dirent FAR * dp, BYTE FAR * vp); +#else +#define getdirent(vp, dp) fmemcpy(dp, vp, sizeof(struct dirent)) +#define putdirent(dp, vp) fmemcpy(vp, dp, sizeof(struct dirent)) +#endif + +/* syscon.c */ +WORD con_driver(rqptr rp); +VOID break_handler(void); /* systime.c */ VOID DosGetTime(BYTE FAR * hp, BYTE FAR * mp, BYTE FAR * sp, BYTE FAR * hdp); @@ -499,11 +520,11 @@ VOID InitPSP(VOID); int SetJFTSize(UWORD nHandles); int DosMkTmp(BYTE FAR * pathname, UWORD attr); COUNT get_verify_drive(char FAR * src); -COUNT truename(char FAR * src, char FAR * dest, COUNT t); +COUNT ASMCFUNC truename(char FAR * src, char FAR * dest, COUNT t); /* network.c */ -COUNT int2f_Remote_call(UWORD func, UWORD b, UCOUNT n, UWORD d, VOID FAR * s, UWORD i, VOID FAR * data); -COUNT QRemote_Fn(char FAR * s, char FAR * d); +COUNT ASMCFUNC int2f_Remote_call(UWORD func, UWORD b, UCOUNT n, UWORD d, VOID FAR * s, UWORD i, VOID FAR * data); +COUNT ASMCFUNC QRemote_Fn(char FAR * s, char FAR * d); UWORD get_machine_name(BYTE FAR * netname); VOID set_machine_name(BYTE FAR * netname, UWORD name_num); @@ -511,7 +532,7 @@ UCOUNT Remote_RW(UWORD func, UCOUNT n, BYTE FAR * bp, sft FAR * s, COUNT FAR * e COUNT Remote_find(UWORD func); /* procsupt.asm */ -VOID INRPT FAR exec_user(iregs FAR * irp); +VOID ASMCFUNC exec_user(iregs FAR * irp); /* detect.c */ unsigned long FAR is_dosemu(void); @@ -527,4 +548,11 @@ unsigned long FAR is_dosemu(void); ASSERT_CONST( (BYTE FAR *)x->fcb_ext - (BYTE FAR *)x->fcbname == 8) */ -#define ASSERT_CONST(x) { typedef struct { char x[2 * (x) - 1]; } xx ; } +#define ASSERT_CONST(x) { typedef struct { char _xx[x ? 1 : -1]; } xx ; } + +#if defined(WATCOM) && 0 +ULONG FAR ASMCFUNC MULULUS(ULONG mul1, UWORD mul2); /* MULtiply ULong by UShort */ +ULONG FAR ASMCFUNC MULULUL(ULONG mul1, ULONG mul2); /* MULtiply ULong by ULong */ +ULONG FAR ASMCFUNC DIVULUS(ULONG mul1, UWORD mul2); /* DIVide ULong by UShort */ +ULONG FAR ASMCFUNC DIVMODULUS(ULONG mul1, UWORD mul2,UWORD *rem); /* DIVide ULong by UShort */ +#endif diff --git a/kernel/segs.inc b/kernel/segs.inc index c550eeb8..3a39e581 100644 --- a/kernel/segs.inc +++ b/kernel/segs.inc @@ -29,6 +29,9 @@ ; $Header$ ; ; $Log$ +; Revision 1.9 2001/09/23 20:39:44 bartoldeman +; FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling +; ; Revision 1.8 2001/07/09 22:19:33 bartoldeman ; LBA/FCB/FAT/SYS/Ctrl-C/ioctl fixes + memory savings ; @@ -71,9 +74,9 @@ group PGROUP PSP group TGROUP _TEXT _IO_TEXT _IO_FIXED_DATA -group DGROUP _FIXED_DATA _DATA _BSSSTART _BSS _BSSEND DYN_DATA +group DGROUP _FIXED_DATA _DATA _BSSSTART _BSS _BSSEND DYN_DATA DCONST group HGROUP HMA_TEXT_START HMA_TEXT HMA_TEXT_END -group IGROUP INIT_TEXT_START INIT_TEXT INIT_TEXT_END ID_B ID ID_E IB_B IB IB_E +group IGROUP INIT_TEXT_START INIT_TEXT INIT_TEXT_END ID_B ID ID_E IB_B IB IB_E IC IDATA segment PSP class=PSP segment _TEXT class=CODE @@ -84,6 +87,8 @@ segment _DATA class=DATA align=2 segment _BSSSTART class=BSS align=2 segment _BSS class=BSS align=2 segment _BSSEND class=BSS +;for MSC +segment DCONST class=DCONST align=2 segment DYN_DATA class=DYN_DATA segment HMA_TEXT_START class=HMA align=16 segment HMA_TEXT class=HMA @@ -94,7 +99,9 @@ segment INIT_TEXT_END class=INIT segment ID_B class=ID align=2 segment ID class=ID align=2 segment ID_E class=ID align=2 +segment IDATA class=ID align=2 segment IB_B class=IB align=2 segment IB class=IB align=2 segment IB_E class=IB align=2 +segment IC class=IC align=2 diff --git a/kernel/sysclk.c b/kernel/sysclk.c index 5fd37077..8fe71088 100644 --- a/kernel/sysclk.c +++ b/kernel/sysclk.c @@ -35,6 +35,9 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.9 2001/09/23 20:39:44 bartoldeman + * FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling + * * Revision 1.8 2001/08/19 12:58:36 bartoldeman * Time and date fixes, Ctrl-S/P, findfirst/next, FCBs, buffers, tsr unloading * @@ -102,9 +105,9 @@ static BYTE *RcsId = "$Id$"; */ #ifdef PROTO -BOOL ReadPCClock(ULONG *); -VOID WriteATClock(BYTE *, BYTE, BYTE, BYTE); -VOID WritePCClock(ULONG); +BOOL ASMCFUNC ReadPCClock(ULONG *); +VOID ASMCFUNC WriteATClock(BYTE *, BYTE, BYTE, BYTE); +VOID ASMCFUNC WritePCClock(ULONG); COUNT BcdToByte(COUNT); COUNT BcdToWord(BYTE *, UWORD *, UWORD *, UWORD *); COUNT ByteToBcd(COUNT); @@ -141,14 +144,14 @@ static ULONG Ticks; */ UWORD DaysSinceEpoch = 0; -BOOL ReadATClock(BYTE *, BYTE *, BYTE *, BYTE *); +BOOL ASMCFUNC ReadATClock(BYTE *, BYTE *, BYTE *, BYTE *); static COUNT BcdToByte(COUNT x) { return ((((x) >> 4) & 0xf) * 10 + ((x) & 0xf)); } -WORD FAR clk_driver(rqptr rp) +WORD FAR ASMCFUNC clk_driver(rqptr rp) { COUNT c; diff --git a/kernel/syspack.c b/kernel/syspack.c index 3e7d1ee7..2947bacb 100644 --- a/kernel/syspack.c +++ b/kernel/syspack.c @@ -36,6 +36,9 @@ static BYTE *syspackRcsId = "$Id$"; /* * $Log$ + * Revision 1.4 2001/09/23 20:39:44 bartoldeman + * FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling + * * Revision 1.3 2000/05/25 20:56:21 jimtabor * Fixed project history * @@ -134,7 +137,6 @@ VOID fputbyte(BYTE FAR * bp, VOID FAR * vp) { *(BYTE FAR *) vp = *bp; } -#endif VOID getdirent(BYTE FAR * vp, struct dirent FAR * dp) { @@ -162,3 +164,4 @@ VOID putdirent(struct dirent FAR * dp, BYTE FAR * vp) for (i = 0, p = (BYTE FAR *) & vp[DIR_RESERVED]; i < 10; i++) *p++ = NULL; } +#endif \ No newline at end of file diff --git a/kernel/task.c b/kernel/task.c index 1420480e..a7bbd8e6 100644 --- a/kernel/task.c +++ b/kernel/task.c @@ -35,6 +35,9 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.18 2001/09/23 20:39:44 bartoldeman + * FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling + * * Revision 1.17 2001/08/19 12:58:36 bartoldeman * Time and date fixes, Ctrl-S/P, findfirst/next, FCBs, buffers, tsr unloading * @@ -191,10 +194,6 @@ static exe_header header; + 1 byte: '\0' -- 1999/04/21 ska */ -#ifdef __TURBOC__ -void __int__(int); /* TC 2.01 requires this. :( -- ror4 */ -#endif - #ifndef PROTO COUNT ChildEnv(exec_blk FAR *, UWORD *, char far *); #else @@ -326,7 +325,7 @@ VOID new_psp(psp FAR * p, int psize) /* CP/M-like entry point - jump to special entry */ p->ps_farcall = 0xea; - p->ps_reentry = cpm_entry; + p->ps_reentry = (VOID(FAR *) ())cpm_entry; /* unix style call - 0xcd 0x21 0xcb (int 21, retf) */ p->ps_unix[0] = 0xcd; p->ps_unix[1] = 0x21; @@ -347,11 +346,11 @@ VOID new_psp(psp FAR * p, int psize) p->ps_dta = (BYTE FAR *) (&p->ps_cmd_count); /* terminate address */ - p->ps_isv22 = (VOID(interrupt FAR *) (void))getvec(0x22); + p->ps_isv22 = (VOID(INRPT FAR *) (void))getvec(0x22); /* break address */ - p->ps_isv23 = (VOID(interrupt FAR *) (void))getvec(0x23); + p->ps_isv23 = (VOID(INRPT FAR *) (void))getvec(0x23); /* critical error address */ - p->ps_isv24 = (VOID(interrupt FAR *) (void))getvec(0x24); + p->ps_isv24 = (VOID(INRPT FAR *) (void))getvec(0x24); /* File System parameters */ /* user stack pointer - int 21 */ @@ -465,7 +464,7 @@ COUNT DosComLoader(BYTE FAR * namep, exec_blk FAR * exp, COUNT mode) LONG com_size; int ModeLoadHigh = mode & 0x80; - int UMBstate = uppermem_link; + UBYTE UMBstate = uppermem_link; mode &= 0x7f; @@ -522,7 +521,7 @@ COUNT DosComLoader(BYTE FAR * namep, exec_blk FAR * exp, COUNT mode) if ( ModeLoadHigh && uppermem_root) { - DosUmbLink(UMBstate); /* restore link state */ + DosUmbLink(UMBstate); /* restore link state */ } @@ -684,7 +683,7 @@ COUNT DosExeLoader(BYTE FAR * namep, exec_blk FAR * exp, COUNT mode) LONG exe_size; int ModeLoadHigh = mode & 0x80; - int UMBstate = uppermem_link; + UBYTE UMBstate = uppermem_link; mode &= 0x7f; diff --git a/sys/sys.mak b/sys/sys.mak index 80f72b2f..50d83237 100644 --- a/sys/sys.mak +++ b/sys/sys.mak @@ -4,6 +4,9 @@ # $Id$ # # $Log$ +# Revision 1.9 2001/09/23 20:39:44 bartoldeman +# FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling +# # Revision 1.8 2001/04/29 17:34:41 bartoldeman # A new SYS.COM/config.sys single stepping/console output/misc fixes. # @@ -49,7 +52,7 @@ !include "..\config.mak" CFLAGS = -mt -1- -v -vi- -k- -f- -ff- -O -Z -d -I$(INCLUDEPATH);..\hdr \ - -DI86;PROTO;FORSYS + -DI86;PROTO;FORSYS;WITHFAT32 # *Implicit Rules* .c.obj: @@ -77,6 +80,9 @@ b_fat12.h: ..\boot\b_fat12.bin bin2c.com b_fat16.h: ..\boot\b_fat16.bin bin2c.com bin2c ..\boot\b_fat16.bin b_fat16.h b_fat16 +b_fat32.h: ..\boot\b_fat32.bin bin2c.com + bin2c ..\boot\b_fat32.bin b_fat32.h b_fat32 + #floppy.obj: ..\drivers\floppy.asm # $(NASM) -fobj -DSYS=1 ..\drivers\floppy.asm -o floppy.obj @@ -88,13 +94,13 @@ sys.com: $(EXE_dependencies) $(CLIB); clobber: clean - $(RM) sys.com b_fat12.h b_fat16.h + $(RM) sys.com b_fat12.h b_fat16.h b_fat32.h clean: $(RM) *.obj *.bak *.crf *.xrf *.map *.lst *.las status.me # *Individual File Dependencies* -sys.obj: sys.c ..\hdr\portab.h ..\hdr\device.h b_fat12.h b_fat16.h +sys.obj: sys.c ..\hdr\portab.h ..\hdr\device.h b_fat12.h b_fat16.h b_fat32.h # RULES (DEPENDENCIES) # ---------------- From a957122ff6faeefd89fe3f9a0a5461ea6a3ebd51 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sun, 23 Sep 2001 20:39:44 +0000 Subject: [PATCH 092/671] version 2.1a jeremyd 2001/8/19 modified so takes optional 2nd parameter (similar to PC DOS) where if only 1 argument is given, assume to be destination drive, but if two arguments given, 1st is source (drive and/or path) and second is destination drive FAT32 support. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@306 6ac86273-5f31-0410-b378-82cca8765d1b --- sys/sys.c | 228 ++++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 197 insertions(+), 31 deletions(-) diff --git a/sys/sys.c b/sys/sys.c index dd3e5337..d86db93c 100644 --- a/sys/sys.c +++ b/sys/sys.c @@ -26,9 +26,26 @@ ***************************************************************/ /* $Log$ - * Revision 1.7 2001/07/09 22:19:33 bartoldeman - * LBA/FCB/FAT/SYS/Ctrl-C/ioctl fixes + memory savings + * Revision 1.8 2001/09/23 20:39:44 bartoldeman + * version 2.1a jeremyd 2001/8/19 + * modified so takes optional 2nd parameter (similar to PC DOS) + * where if only 1 argument is given, assume to be destination drive, + * but if two arguments given, 1st is source (drive and/or path) + * and second is destination drive * + * FAT32 support. + * + +/* version 2.1a jeremyd 2001/8/19 + modified so takes optional 2nd parameter (similar to PC DOS) + where if only 1 argument is given, assume to be destination drive, + but if two arguments given, 1st is source (drive and/or path) + and second is destination drive +*/ + +/* Revision 1.7 2001/07/09 22:19:33 bartoldeman +/* LBA/FCB/FAT/SYS/Ctrl-C/ioctl fixes + memory savings +/* /* Revision 2.1 tomehlert 2001/4/26 changed the file system detection code. @@ -119,6 +136,9 @@ #define STORE_BOOT_INFO #define DEBUG +/* #define DDEBUG */ + +#define SYS_VERSION "v2.1a" #include #include @@ -127,11 +147,20 @@ #include #include #include -#include +#ifdef __TURBOC__ + #include +#else + #include +#endif +#include +#include #include "portab.h" #include "b_fat12.h" #include "b_fat16.h" +#ifdef WITHFAT32 +#include "b_fat32.h" +#endif BYTE pgm[] = "sys"; @@ -143,7 +172,7 @@ COUNT DiskWrite(WORD, WORD, WORD, WORD, WORD, BYTE FAR *); #define SEC_SIZE 512 -#define COPY_SIZE 32768 +#define COPY_SIZE 32768u @@ -177,28 +206,89 @@ struct bootsectortype ULONG sysDataStart; /* first data sector */ }; +struct bootsectortype32 +{ + UBYTE bsJump[3]; + char OemName[8]; + UWORD bsBytesPerSec; + UBYTE bsSecPerClust; + UWORD bsResSectors; + UBYTE bsFATs; + UWORD bsRootDirEnts; + UWORD bsSectors; + UBYTE bsMedia; + UWORD bsFATsecs; + UWORD bsSecPerTrack; + UWORD bsHeads; + ULONG bsHiddenSecs; + ULONG bsHugeSectors; + ULONG bsBigFatSize; + UBYTE bsFlags; + UBYTE bsMajorVersion; + UWORD bsMinorVersion; + ULONG bsRootCluster; + UWORD bsFSInfoSector; + UWORD bsBackupBoot; + ULONG bsReserved2[3]; + UBYTE bsDriveNumber; + UBYTE bsReserved3; + UBYTE bsExtendedSignature; + ULONG bsSerialNumber; + char bsVolumeLabel[11]; + char bsFileSystemID[8]; + ULONG sysFatStart; + ULONG sysDataStart; + UWORD sysFatSecMask; + UWORD sysFatSecShift; +}; - -COUNT drive; +COUNT drive; /* destination drive */ +BYTE srcPath[MAXPATH]; /* source drive and/or path */ +BYTE *endOfSrcPath; /* marks start of filename */ UBYTE newboot[SEC_SIZE], oldboot[SEC_SIZE]; #define SBOFFSET 11 #define SBSIZE (sizeof(struct bootsectortype) - SBOFFSET) +#define SBSIZE32 (sizeof(struct bootsectortype32) - SBOFFSET) VOID main(COUNT argc, char **argv) { - printf("FreeDOS System Installer v2.1\n\n"); + WORD slen; + + printf("FreeDOS System Installer " SYS_VERSION "\n\n"); - if (argc != 2) + if (argc == 2) { - printf("Usage: %s drive\n drive = A,B,etc.\n", pgm); + drive = toupper(*argv[1]) - 'A'; + srcPath[0] = '\0'; + endOfSrcPath = srcPath; + } + else if (argc == 3) + { + drive = toupper(*argv[2]) - 'A'; + strncpy(srcPath, argv[1], MAXDIR); + /* make sure srcPath + "file" is a valid path */ + slen = strlen(srcPath); + if ( (srcPath[slen-1] != ':') && + ((srcPath[slen-1] != '\\') || (srcPath[slen-1] != '/')) ) + { + srcPath[slen] = '\\'; + slen++; + srcPath[slen] = '\0'; + } + endOfSrcPath = srcPath + slen; + } + else + { + printf("Usage: %s [source] drive\n", pgm); + printf(" source = A:,B:,C:\\KERNEL\\BIN\\,etc., or current directory if not given\n"); + printf(" drive = A,B,etc.\n"); exit(1); } - drive = toupper(*argv[1]) - 'A'; if (drive < 0 || drive >= 26) { printf( "%s: drive %c must be A:..Z:\n", pgm,*argv[1]); @@ -213,14 +303,14 @@ VOID main(COUNT argc, char **argv) } - printf("\nCopying KERNEL.SYS..."); + printf("\nCopying KERNEL.SYS...\n"); if (!copy(drive, "kernel.sys")) { printf("\n%s: cannot copy \"KERNEL.SYS\"\n", pgm); exit(1); } - printf("\nCopying COMMAND.COM..."); + printf("\nCopying COMMAND.COM...\n"); if (!copy(drive, "command.com")) { printf("\n%s: cannot copy \"COMMAND.COM\"\n", pgm); @@ -269,7 +359,7 @@ VOID dump_sector(unsigned char far * sec) MSDOS requires int25, CX=ffff for drives > 32MB */ -int MyAbsReadWrite(char DosDrive, int count, ULONG sector, void *buffer, unsigned intno) +int MyAbsReadWrite(int DosDrive, int count, ULONG sector, void *buffer, unsigned intno) { struct { unsigned long sectorNumber; @@ -284,13 +374,25 @@ int MyAbsReadWrite(char DosDrive, int count, ULONG sector, void *buffer, unsigne diskReadPacket.count = count; diskReadPacket.address = buffer; - regs.h.al = DosDrive; + regs.h.al = (BYTE)DosDrive; regs.x.bx = (short)&diskReadPacket; regs.x.cx = 0xffff; if (intno != 0x25 && intno != 0x26) return 0xff; int86(intno,®s,®s); + +#ifdef WITHFAT32 + if (regs.x.cflag) + { + regs.x.ax = 0x7305; + regs.h.dl = DosDrive + 1; + regs.x.bx = (short)&diskReadPacket; + regs.x.cx = 0xffff; + regs.x.si = intno - 0x25; + int86(0x21, ®s, ®s); + } +#endif return regs.x.cflag ? 0xff : 0; } @@ -303,6 +405,9 @@ VOID put_boot(COUNT drive) WORD count; ULONG temp; struct bootsectortype *bs; +#ifdef WITHFAT32 + struct bootsectortype32 *bs32; +#endif int fs; union REGS regs; struct SREGS sregs; @@ -402,20 +507,53 @@ VOID put_boot(COUNT drive) memcpy(newboot, b_fat12, SEC_SIZE); /* copy FAT12 boot sector */ printf("FAT type: FAT12\n"); } - else { - printf("FAT type: FAT32\n"); - printf("Sorry, we don't have a FAT32 boot sector (yet)\n"); - printf(" for this reason, we can't make the drive bootable\n"); - exit(1); + else + { + printf("FAT type: FAT32\n"); +#ifdef WITHFAT32 + memcpy(newboot, b_fat32, SEC_SIZE); /* copy FAT32 boot sector */ +#else + printf("SYS hasn't been compiled with FAT32 support."); + printf("Consider using -DWITHFAT32 option.\n"); + exit(1); +#endif } /* Copy disk parameter from old sector to new sector */ - memcpy(&newboot[SBOFFSET], &oldboot[SBOFFSET], SBSIZE); +#ifdef WITHFAT32 + if (fs == 32) + memcpy(&newboot[SBOFFSET], &oldboot[SBOFFSET], SBSIZE32); + else +#endif + memcpy(&newboot[SBOFFSET], &oldboot[SBOFFSET], SBSIZE); bs = (struct bootsectortype *) & newboot; memcpy(bs->OemName, "FreeDOS ",8); +#ifdef WITHFAT32 + if (fs == 32) + { + bs32 = (struct bootsectortype32 *) & newboot; + + temp = bs32->bsHiddenSecs + bs32->bsResSectors; + bs32->sysFatStart = temp; + + bs32->sysDataStart = temp + bs32->bsBigFatSize * bs32->bsFATs; + bs32->sysFatSecMask = bs32->bsBytesPerSec / 4 - 1; + + temp = bs32->sysFatSecMask + 1; + for (bs32->sysFatSecShift = 0; temp != 1; bs32->sysFatSecShift++, temp >>= 1); + } +#ifdef DEBUG + if (fs == 32) + { + printf( "FAT starts at sector %lx = (%lx + %x)\n", bs32->sysFatStart, + bs32->bsHiddenSecs, bs32->bsResSectors); + printf("DATA starts at sector %lx\n", bs32->sysDataStart); + } +#endif +#else #ifdef STORE_BOOT_INFO /* TE thinks : never, see above */ /* temporary HACK for the load segment (0x0060): it is in unused */ @@ -438,7 +576,6 @@ VOID put_boot(COUNT drive) temp = temp + bs->sysRootDirSecs; bs->sysDataStart = temp; - #ifdef DEBUG printf("Root dir entries = %u\n", bs->bsRootDirEnts); printf("Root dir sectors = %u\n", bs->sysRootDirSecs); @@ -451,6 +588,7 @@ VOID put_boot(COUNT drive) bs->sysRootDirSecs); #endif #endif +#endif #ifdef DDEBUG @@ -476,13 +614,14 @@ BOOL check_space(COUNT drive, BYTE * BlkBuffer) /* this should check, if on destination is enough space to hold command.com+ kernel.sys */ - if (drive); - if (BlkBuffer); + UNREFERENCED_PARAMETER(drive); + UNREFERENCED_PARAMETER(BlkBuffer); return 1; } +BYTE copybuffer[COPY_SIZE]; BOOL copy(COUNT drive, BYTE * file) { @@ -490,16 +629,25 @@ BOOL copy(COUNT drive, BYTE * file) COUNT ifd, ofd; unsigned ret; int fdin, fdout; - BYTE buffer[COPY_SIZE]; - struct ftime ftime; ULONG copied = 0; + struct stat fstatbuf; + + if (stat(file,&fstatbuf)) + { + printf( "%s: \"%s\" not found\n", pgm, file); + return FALSE; + } + sprintf(dest, "%c:\\%s", 'A' + drive, file); - if ((fdin = open(file, O_RDONLY|O_BINARY)) < 0) + strcpy(endOfSrcPath, file); + if ((fdin = open(srcPath, O_RDONLY|O_BINARY)) < 0) { - printf( "%s: \"%s\" not found\n", pgm, file); + printf( "%s: \"%s\" not found\n", pgm, srcPath); return FALSE; } + + if ((fdout = open(dest, O_RDWR | O_TRUNC | O_CREAT | O_BINARY,S_IREAD|S_IWRITE)) < 0) { printf( " %s: can't create\"%s\"\nDOS errnum %d", pgm, dest, errno); @@ -507,9 +655,9 @@ BOOL copy(COUNT drive, BYTE * file) return FALSE; } - while ((ret = read(fdin, buffer,COPY_SIZE)) > 0) + while ((ret = read(fdin, copybuffer,COPY_SIZE)) > 0) { - if (write(fdout, buffer, ret) != ret) + if (write(fdout, copybuffer, ret) != ret) { printf("Can't write %u bytes to %s\n",dest); close(fdout); @@ -519,12 +667,30 @@ BOOL copy(COUNT drive, BYTE * file) copied += ret; } - getftime(fdin, &ftime); - setftime(fdout, &ftime); +#ifdef __TURBO__ + { + struct ftime ftime; + getftime(fdin, &ftime); + setftime(fdout, &ftime); + } +#endif close(fdin); close(fdout); +#ifdef _MSV_VER + { + #include + struct utimbuf utimb; + + utimb.actime = /* access time */ + utimb.modtime = fstatbuf.st_mtime; /* modification time */ + utime(dest,&utimb); + }; + +#endif + + printf("%lu Bytes transferred", copied); return TRUE; From c8f7d6646162849bae38bba484f8cb01e47b69a4 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Mon, 24 Sep 2001 02:21:14 +0000 Subject: [PATCH 093/671] SYS and printer fixes git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@307 6ac86273-5f31-0410-b378-82cca8765d1b --- boot/boot32.asm | 362 +++++++++++++++++++++++++++++++++++++++++++++ docs/lfnapi.txt | 24 +++ hdr/xstructs.h | 84 +++++++++++ kernel/dosfns.c | 33 +++-- kernel/init-dat.h | 31 ++++ kernel/lfnapi.c | 147 ++++++++++++++++++ kernel/printer.asm | 102 ++++++------- 7 files changed, 718 insertions(+), 65 deletions(-) create mode 100644 boot/boot32.asm create mode 100644 docs/lfnapi.txt create mode 100644 hdr/xstructs.h create mode 100644 kernel/init-dat.h create mode 100644 kernel/lfnapi.c diff --git a/boot/boot32.asm b/boot/boot32.asm new file mode 100644 index 00000000..8c4b2495 --- /dev/null +++ b/boot/boot32.asm @@ -0,0 +1,362 @@ +; +--------+ +; | | +; | | +; |--------| 4000:0000 +; | | +; | FAT | +; | | +; |--------| 2000:0000 +; |BOOT SEC| +; |RELOCATE| +; |--------| 1FE0:0000 +; | | +; | | +; | | +; | | +; |--------| +; |BOOT SEC| +; |ORIGIN | 07C0:0000 +; |--------| +; | | +; | | +; | | +; |--------| +; |KERNEL | +; |LOADED | +; |--------| 0060:0000 +; | | +; +--------+ + +;%define MULTI_SEC_READ 1 + + +segment .text + +%define BASE 0x7c00 + + org BASE + +Entry: jmp short real_start + nop + +; bp is initialized to 7c00h +%define bsOemName bp+0x03 ; OEM label +%define bsBytesPerSec bp+0x0b ; bytes/sector +%define bsSecPerClust bp+0x0d ; sectors/allocation unit +%define bsResSectors bp+0x0e ; # reserved sectors +%define bsFATs bp+0x10 ; # of fats +%define bsRootDirEnts bp+0x11 ; # of root dir entries +%define bsSectors bp+0x13 ; # sectors total in image +%define bsMedia bp+0x15 ; media descrip: fd=2side9sec, etc... +%define sectPerFat bp+0x16 ; # sectors in a fat +%define sectPerTrack bp+0x18 ; # sectors/track +%define nHeads bp+0x1a ; # heads +%define nHidden bp+0x1c ; # hidden sectors +%define nSectorHuge bp+0x20 ; # sectors if > 65536 +%define xsectPerFat bp+0x24 ; Sectors/Fat +%define xrootClst bp+0x2c ; Starting cluster of root directory +%define drive bp+0x40 ; Drive number + +%define LOADSEG 0x0060 + +%define FATSEG 0x2000 + +%define fat_sector bp+0x48 ; last accessed sector of the FAT + dd 0 + + times 0x5a-$+$$ db 0 +%define fat_start bp+0x5a ; first FAT sector + dd 0 +%define data_start bp+0x5e ; first data sector + dd 0 +%define fat_secmask bp+0x62 ; number of clusters in a FAT sector - 1 + dw 0 +%define fat_secshift bp+0x64 ; fat_secmask+1 = 2^fat_secshift + dw 0 + +;----------------------------------------------------------------------- +; ENTRY +;----------------------------------------------------------------------- + +real_start: cld + sub ax, ax + mov ds, ax + mov bp, 0x7c00 + mov ss, ax ; initialize stack + lea sp, [bp-0x20] + int 0x13 ; reset drive + + mov ax, 0x1FE0 + mov es, ax + mov si, bp + mov di, bp + mov cx, 0x0100 + rep movsw ; move boot code to the 0x1FE0:0x0000 + push es + mov bx, cont + push bx + retf + +cont: mov ds, ax + mov ss, ax + mov [drive], dl ; BIOS passes drive number in DL + + call print + db "Loading FreeDOS...",13,10,0 + +; FINDFILE: Searches for the file in the root directory. +; +; Returns: +; DX:AX = first cluster of file + + mov word [fat_sector], cx ; CX is 0 after movsw + mov word [fat_sector + 2], cx + + mov ax, word [xrootClst] + mov dx, word [xrootClst + 2] +ff_next_cluster: + push dx ; save cluster + push ax + call convert_cluster + jc boot_error ; EOC encountered + +ff_next_sector: + push bx ; save sector count + + mov bx, LOADSEG + mov es, bx + sub bx, bx + call readDisk + push dx ; save sector + push ax + + mov ax, [bsBytesPerSec] + + ; Search for KERNEL.SYS file name, and find start cluster. +ff_next_entry: mov cx, 11 + mov si, filename + mov di, ax + sub di, 0x20 + repe cmpsb + jz ff_done + + sub ax, 0x20 + jnz ff_next_entry + pop ax ; restore sector + pop dx + pop bx ; restore sector count + dec bx + jnz ff_next_sector +ff_find_next_cluster: + pop ax ; restore current cluster + pop dx + call next_cluster + jmp ff_next_cluster +ff_done: + + mov ax, [es:di+0x1A-11] ; get cluster number + mov dx, [es:di+0x14-11] +c4: + sub bx, bx ; ES points to LOADSEG +c5: push dx + push ax + push bx + call convert_cluster + jc boot_success + mov di, bx + pop bx +c6: + call readDisk + dec di + jnz c6 + pop ax + pop dx + call next_cluster + jmp c5 + + +boot_error: call print + db 13,10,"BOOT error!",13,10,0 + + xor ah,ah + int 0x16 ; wait for a key + int 0x19 ; reboot the machine + +; input: +; DX:AX - cluster +; output: +; DX:AX - next cluster +; CX = 0 +; modify: +; DI +next_cluster: + push es + mov di, ax + and di, [fat_secmask] + + mov cx, [fat_secshift] +cn_loop: + shr dx,1 + rcr ax,1 + dec cx + jnz cn_loop ; DX:AX fat sector where our + ; cluster resides + ; DI - cluster index in this + ; sector + + shl di,1 ; DI - offset in the sector + shl di,1 + add ax, [fat_start] + adc dx, [fat_start+2] ; DX:AX absolute fat sector + + push bx + mov bx, FATSEG + mov es, bx + sub bx, bx + + cmp ax, [fat_sector] + jne cn1 ; if the last fat sector we + ; read was this, than skip + cmp dx,[fat_sector+2] + je cn_exit +cn1: + mov [fat_sector],ax ; save the fat sector number, + mov [fat_sector+2],dx ; we are going to read + call readDisk +cn_exit: + pop bx + mov ax, [es:di] ; DX:AX - next cluster + mov dx, [es:di + 2] ; + pop es + ret + + +boot_success: + mov bl, [drive] + jmp word LOADSEG:0 + +; Convert cluster to the absolute sector +;input: +; DX:AX - target cluster +;output: +; DX:AX - absoulute sector +; BX - [bsSectPerClust] +;modify: +; CX +convert_cluster: + cmp dx,0x0fff + jne c3 + cmp ax,0xfff8 + jb c3 ; if cluster is EOC (carry is set), do ret + stc + ret +c3: + mov cx, dx ; sector = (cluster - 2)*clussize + + ; + data_start + sub ax, 2 + sbb cx, byte 0 ; CX:AX == cluster - 2 + mov bl, [bsSecPerClust] + sub bh, bh + xchg cx, ax ; AX:CX == cluster - 2 + mul bx ; first handle high word + ; DX must be 0 here + xchg ax, cx ; then low word + mul bx + add dx, cx ; DX:AX target sector + add ax, [data_start] + adc dx, [data_start + 2] + ret + +; prints text after call to this function. + +print: pop si ; this is the first character + xor bx, bx ; video page 0 + mov ah, 0x0E ; else print it +print1: lodsb ; get token + cmp al, bl ; end of string? (al == bl == 0) + je print2 ; if so, exit + int 0x10 ; via TTY mode + jmp short print1 ; until done +print2: push si ; stack up return address + ret ; and jump to it + + +;input: +; DX:AX - 32-bit DOS sector number +; ES:BX - destination buffer +;output: +; ES:BX points one byte after the last byte read. +; DX:AX - next sector +;modify: +; ES if DI * bsBytesPerSec >= 65536, CX + +readDisk: +read_next: push dx + push ax + ; + ; translate sector number to BIOS parameters + ; + + ; + ; abs = sector offset in track + ; + head * sectPerTrack offset in cylinder + ; + track * sectPerTrack * nHeads offset in platter + ; + ; t1 = abs / sectPerTrack (ax has t1) + ; sector = abs mod sectPerTrack (cx has sector) + ; + div word [sectPerTrack] + mov cx, dx + + ; + ; t1 = head + track * nHeads + ; + ; track = t1 / nHeads (ax has track) + ; head = t1 mod nHeads (dl has head) + ; + xor dx, dx + div word [nHeads] + + ; the following manipulations are necessary in order to + ; properly place parameters into registers. + ; ch = cylinder number low 8 bits + ; cl = 7-6: cylinder high two bits + ; 5-0: sector + mov dh, dl ; save head into dh for bios + ror ah, 1 ; move track high bits into + ror ah, 1 ; bits 7-6 (assumes top = 0) + xchg al, ah ; swap for later + mov dl, byte [sectPerTrack] + sub dl, cl + inc cl ; sector offset from 1 + or cx, ax ; merge cylinder into sector + + mov ax, 0x0201 + mov dl, [drive] + int 0x13 + + pop ax + pop dx + jnc read_ok ; jump if no error + xor ah, ah ; else, reset floppy + int 0x13 + jmp read_next +read_ok: + add bx, word [bsBytesPerSec] + + jnc no_incr_es ; if overflow... + + mov cx, es + add ch, 0x10 ; ...add 1000h to ES + mov es, cx + +no_incr_es: + add ax,byte 1 + adc dx,byte 0 + ret + +filename db "KERNEL SYS" + + times 0x01fe-$+$$ db 0 + +sign dw 0xAA55 diff --git a/docs/lfnapi.txt b/docs/lfnapi.txt new file mode 100644 index 00000000..8270b520 --- /dev/null +++ b/docs/lfnapi.txt @@ -0,0 +1,24 @@ + FreeDOS LFN aid API. + + +struct lfn_inode +{ + UNICODE name[255]; + + struct dirent l_dir; /* this file's dir entry image */ + + ULONG l_diroff; /* offset of the dir entry */ + CLUSTER l_dirstart; /* the starting cluster of dir */ + /* when dir is not root */ +}; + +typedef struct lfn_inode FAR * lfn_inode_ptr; + +COUNT lfn_allocate_inode(); +COUNT lfn_free_inode(COUNT handle); + +COUNT lfn_create_entries(COUNT handle, lfn_inode_ptr lip); +COUNT lfn_remove_entries(COUNT handle, lfn_inode_ptr lip); + +COUNT lfn_dir_read(COUNT handle, lfn_inode_ptr lip); +COUNT lfn_dir_write(COUNT handle, lfn_inode_ptr lip); diff --git a/hdr/xstructs.h b/hdr/xstructs.h new file mode 100644 index 00000000..4b0d6315 --- /dev/null +++ b/hdr/xstructs.h @@ -0,0 +1,84 @@ +/****************************************************************/ +/* */ +/* xstructs.h */ +/* */ +/* Extended DOS 7.0+ structures */ +/* */ +/****************************************************************/ + +#ifdef MAIN +#ifdef VERSION_STRINGS +static BYTE *XStructs_hRcsId = "$Id$"; +#endif +#endif + +struct xdpbdata +{ + UWORD xdd_dpbsize; + struct dpb xdd_dpb; +}; + +struct xfreespace +{ + UWORD xfs_datasize; /* size of this structure */ + union { + UWORD requested; /* requested structure version */ + UWORD actual; /* actual structure version */ + } xfs_version; + ULONG xfs_clussize; /* number of sectors per cluster */ + ULONG xfs_secsize; /* number of bytes per sector */ + ULONG xfs_freeclusters; /* number of available clusters */ + ULONG xfs_totalclusters; /* total number of clusters on the drive */ + ULONG xfs_freesectors; /* number of physical sectors available */ + ULONG xfs_totalsectors; /* total number of physical sectors */ + ULONG xfs_freeunits; /* number of available allocation units */ + ULONG xfs_totalunits; /* total allocation units */ + UBYTE xfs_reserved[8]; +}; + +struct xdpbforformat +{ + UWORD xdff_datasize; /* size of this structure */ + union { + UWORD requested; /* requested structure version */ + UWORD actual; /* actual structure version */ + } xdff_version; + UDWORD xdff_function; /* function number: + 00h invalidate DPB counts + 01h rebuild DPB from BPB + 02h force media change + 03h get/set active FAT number and mirroring + 04h get/set root directory cluster number + */ + union { + struct { + DWORD nfreeclst; /* # free clusters + (-1 - unknown, 0 - don't change) */ + DWORD cluster; /* cluster # of first free + (-1 - unknown, 0 - don't change) */ + UDWORD reserved[2]; + } setdpbcounts; + + struct { + UDWORD unknown; + bpb FAR *bpbp; + UDWORD reserved[2]; + } rebuilddpb; + + struct { + DWORD newmirroring; /* new active FAT/mirroring state, or -1 to get + bits 3-0: the 0-based FAT number of the active FAT + bits 6-4: reserved (0) + bit 7: do not mirror active FAT to inactive FATs + */ + DWORD oldmirroring; /* previous active FAT/mirroring state (as above) */ + UDWORD reserved[2]; + } setmirroring; + + struct { + DWORD newrootclst; /* set new root directory cluster, -1 - get current */ + DWORD oldrootclst; /* get previous root directory cluster */ + UDWORD reserved[2]; + } setroot; + } xdff_f; +}; diff --git a/kernel/dosfns.c b/kernel/dosfns.c index ab068e87..5de38733 100644 --- a/kernel/dosfns.c +++ b/kernel/dosfns.c @@ -37,6 +37,9 @@ static BYTE *dosfnsRcsId = "$Id$"; * /// Added SHARE support. 2000/09/04 Ron Cemer * * $Log$ + * Revision 1.27 2001/09/24 02:21:14 bartoldeman + * SYS and printer fixes + * * Revision 1.26 2001/09/23 20:39:44 bartoldeman * FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling * @@ -551,16 +554,15 @@ UCOUNT DosWrite(COUNT hndl, UCOUNT n, BYTE FAR * bp, COUNT FAR * err) } else { - REG WORD /*c,*/ - cnt = n, - xfer = 0; + REG WORD xfer; - while(cnt-- != 0 && *bp != CTL_Z){ + for(xfer = 0; xfer < n && *bp != CTL_Z; bp++, xfer++) + { if (s->sft_flags & SFT_FCONOUT) { cso(*bp); } - else + else FOREVER { rq.r_length = sizeof(request); rq.r_command = C_OUTPUT; @@ -568,11 +570,24 @@ UCOUNT DosWrite(COUNT hndl, UCOUNT n, BYTE FAR * bp, COUNT FAR * err) rq.r_trans = bp; rq.r_status = 0; execrh((request FAR *) & rq, s->sft_dev); - if (rq.r_status & S_ERROR) - char_error(&rq, s->sft_dev); + if (!(rq.r_status & S_ERROR)) + break; + charloop: + switch(char_error(&rq, s->sft_dev)) + { + case ABORT: + case FAIL: + *err = DE_INVLDACC; + return xfer; + case CONTINUE: + break; + case RETRY: + continue; + default: + goto charloop; + } + break; } - ++bp; - ++xfer; if (control_break()) { handle_break(); diff --git a/kernel/init-dat.h b/kernel/init-dat.h new file mode 100644 index 00000000..ea6e79d3 --- /dev/null +++ b/kernel/init-dat.h @@ -0,0 +1,31 @@ +/* Included by initialisation functions */ + +#if _MSC_VER != 0 + extern __segment DosDataSeg;/* serves for all references to the DOS DATA segment + necessary for MSC+our funny linking model + */ + + extern __segment DosTextSeg; + + #define DOSFAR __based(DosDataSeg) + #define DOSTEXTFAR __based(DosTextSeg) + +#elif defined(__TURBOC__) + + #define DOSFAR FAR + #define DOSTEXTFAR FAR + +#elif defined(__WATCOMC__) + + #define DOSFAR FAR + #define DOSTEXTFAR FAR + +#else + #pragma error("unknown compiler - please adjust") + this should simply not compile !! +#endif + + + +extern BYTE DOSFAR version_flags; /* minor version number */ + diff --git a/kernel/lfnapi.c b/kernel/lfnapi.c new file mode 100644 index 00000000..71211ee5 --- /dev/null +++ b/kernel/lfnapi.c @@ -0,0 +1,147 @@ +/****************************************************************/ +/* */ +/* lfnapi.c */ +/* */ +/* Directory access functions for LFN aid API */ +/* Module is under construction! */ +/****************************************************************/ + +#include "portab.h" +#include "globals.h" + +#ifdef VERSION_STRINGS +static BYTE *lfnaidRcsId = "$Id$"; +#endif + +#if 0 +#define E_INVLDHNDL -1 +#define E_NOFREEHNDL -2 +#define E_IOERROR -3 +#define E_INVLDDRV -4 + +COUNT lfn_allocate_inode() +{ + f_node_ptr fnp = get_f_node(); + struct cds FAR *cdsp; + if (fnp == 0) return E_NOFREEHNDL; + + cdsp = &CDSp->cds_table[default_drive]; + + if (cdsp->cdsDpb == 0) + { + release_f_node(fnp); + return E_INVLDDRV; + } + + fnp->f_dpb = cdsp->cdsDpb; + + if (media_check(fnp->f_dpb) < 0) + { + release_f_node(fnp); + return E_INVLDDRV; + } + + fnp->f_dsize = DIRENT_SIZE * fnp->f_dpb->dpb_dirents; + + return xlt_fnp(fnp); +} + +COUNT lfn_free_inode(COUNT handle) +{ + f_node_ptr fnp = xlt_fd(handle); + if (fnp == 0 || fnp->f_count <= 0) return E_INVLHNDL; + + release_f_node(fnp); +} + +COUNT lfn_to_unicode_chunk(UNICODE FAR **nptr, UNICODE FAR **uptr, + UCOUNT *index, COUNT count) +{ + COUNT j; + + for (j = 0; j < count; j++, *uptr++, *index++, *nptr++) + { + **nptr = **uptr; + if (**uptr == 0) return 0; + } + + return 1; +} + +COUNT lfn_to_unicode(UNICODE FAR *name, UBYTE FAR *lfn_entry, UCOUNT *index) +{ + COUNT j; + UNICODE FAR *uptr; + UNICODE FAR *nptr = name; + + uptr = (UNICODE FAR *)&lfn_entry[1]; + if (!lfn_to_unicode_chunk(&nptr, &uptr, index, 5)) return 0; + uptr = (UNICODE FAR *)&lfn_entry[0xe]; + if (!lfn_to_unicode_chunk(&nptr, &uptr, index, 6)) return 0; + uptr = (UNICODE FAR *)&lfn_entry[0x1c]; + if (!lfn_to_unicode_chunk(&nptr, &uptr, index, 2)) return 0; + + return 1; +} + +COUNT lfn_dir_read(COUNT handle, lfn_inode_ptr lip) +{ + COUNT index = 0; /* index of the first non-filled char in the long file + name string */ + ULONG original_diroff; + f_node_ptr fnp = xlt_fd(handle); + if (fnp == 0 || fnp->f_count <= 0) return E_INVLHNDL; + + if (lfnp->l_dirstart == 0) + { + } + + original_diroff = fnp->f_diroff; + + lip->name[0] = 0; + + while (TRUE) + { + if (dir_read(fnp) != DIRENT_SIZE) return E_IOERROR; + if (fnp->f_dir.dir_name[0] != DELETED && fnp->f_dir.dir_name[0] != 0 + && fnp->f_dir.dir_attrib != D_LFN) + { + fmemcpy(lip->l_dir, fnp->f_dir, sizeof(struct dirent)); + lip->l_diroff = fnp->f_diroff; + lip->l_dirstart = fnp->f_dirstart; + break; + } + } + fnp->f_diroff = original_diroff - DIRENT_SIZE; + + while (TRUE) + { + if (fnp->f_diroff == 0) break; + fnp->f_diroff -= 2*DIRENT_SIZE; + if (dir_read(fnp) != DIRENT_SIZE) return E_IOERROR; + if (fnp->f_dir.dir_name[0] == '\0' + || fnp->f_dir.dir_name[0] == DELETED) break; + if (!lfn_to_unicode(lip->name, + (UBYTE FAR *)fnp->f_dir, index)) break; + } + + if (lip->name[0] == 0) + { + ConvertName83ToNameSZ(lip->name, lip->l_dir.dir_name); + } + + return SUCCESS; +} + +/* Calculate checksum for the 8.3 name */ +UBYTE lfn_checksum(char *name) +{ + UBYTE sum; + COUNT i; + + for (sum = 0, i = 11; --i >= 0; sum += *name++) + sum = (sum << 7) | (sum >> 1); + + return sum; +} +#endif diff --git a/kernel/printer.asm b/kernel/printer.asm index ee855ec5..cbcf898a 100644 --- a/kernel/printer.asm +++ b/kernel/printer.asm @@ -28,6 +28,9 @@ ; $Header$ ; ; $Log$ +; Revision 1.5 2001/09/24 02:21:14 bartoldeman +; SYS and printer fixes +; ; Revision 1.4 2001/09/23 20:39:44 bartoldeman ; FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling ; @@ -106,19 +109,29 @@ uPrtQuantum dw 50h PrtWrite: jcxz PrtWr3 ; Exit if nothing to write -PrtWr1: - mov bx,2 ; number of retries -PrtWr2: - call PrintSingleCharacter +PrtCharLoop: ; next character loop + + mov bx, 2 ; number of retries +PrtRetryTwice: + mov ah, PRT_GETSTATUS ; get status, ah=2 + call PrtIOCall ; + jnz PrtWr4 + + mov al,[es:di] + + mov ah, PRT_WRITECHAR ; print character, ah=0 + call PrtIOCall ; (0800) + + jnz PrtWr4 ; NZ = error, retry - jnz PrtWr4 ; Exit if done - loop PrtWr1 ; otherwise loop + inc di + loop PrtCharLoop ; next character PrtWr3: jmp _IOExit -PrtWr4: +PrtWr4: ; repeat dec bx - jnz PrtWr2 + jnz PrtRetryTwice PrtWr5: jmp _IOErrCnt @@ -141,18 +154,27 @@ GetPrtStat: PrtIOCall: call GetUnitNum - int 17h ; print char al, get status ah - test ah, PRT_TIMEOUT|PRT_IOERROR - jnz PrtIOCal2 - mov al, E_PAPER - test ah, PRT_OUTOFPAPER - jnz PrtIOCal1 - inc al ; al<-E_WRITE -PrtIOCal1: - retn -PrtIOCal2: + int 17h ; print char al, get status ah + + mov al, ah ; if (stat & 0x30) == 0x30 return 10; + and al, PRT_SELECTED|PRT_OUTOFPAPER + cmp al, PRT_SELECTED|PRT_OUTOFPAPER + mov al, E_WRITE + je ret_error_code + + test ah, PRT_OUTOFPAPER|PRT_IOERROR|PRT_TIMEOUT ; 29h mov al, E_NOTRDY - test ah, PRT_TIMEOUT + jz ret_error_code + + test ah, PRT_OUTOFPAPER ; 20h + mov al, E_WRITE + jz ret_error_code ; not out of paper -> E_WRITE + +ret_error_code_9: + mov al, E_PAPER + +ret_error_code: + cmp al, E_NOTRDY ; 2 = no error retn @@ -222,8 +244,11 @@ PrtGnIoctl3: ; -; original implementation didn't work at all. -; this one's not much better either, +; some comments to last changes (TE, 23/09/01) +; +; original implementation didn't print at all - on my machine,LPT2 +; +; maybe this one's not much better either, ; but should print a little bit ; ; the status bits = AH @@ -242,42 +267,7 @@ PrtGnIoctl3: ; 10 - printer with power, but not initialized ; 90 - this one is fine ; - - ; you must not simply print without asking for status ; as the BIOS has a LARGE timeout before aborting ; -PrintSingleCharacter: - - mov ah, PRT_GETSTATUS ; get status, ah=2 - call GetUnitNum - int 17h ; print char al, get status ah - - test ah, PRT_OUTOFPAPER|PRT_IOERROR - jnz decode_error - - test ah, PRT_NOTBUSY - jz decode_error - - - mov al,[es:di] - mov ah,PRT_WRITECHAR ; print character, ah=0 - call GetUnitNum - int 17h ; print char al, get status ah - - test ah, PRT_OUTOFPAPER|PRT_IOERROR|PRT_TIMEOUT - jnz decode_error - inc di - xor al,al ; set zero flag + clear al - ret - - -decode_error: - mov al, E_PAPER - test ah, PRT_OUTOFPAPER ;out_of_paper, 20h - jnz out_of_paper - mov al, E_WRITE -out_of_paper: - or al,al ; reset zero flag - ret From f8e0429da8a9ee33141d2bba7e2372774ac29afc Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Mon, 24 Sep 2001 02:21:14 +0000 Subject: [PATCH 094/671] /* version 2.2 jeremyd 2001/9/20 Changed so if no source given or only source drive (no path) given, then checks for kernel.sys & command.com in current path (of current drive or given drive) and if not there uses root (but only if source & destination drive are different). Fix printf to include count(ret) if copy can't write all requested bytes */ git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@308 6ac86273-5f31-0410-b378-82cca8765d1b --- sys/sys.c | 133 ++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 85 insertions(+), 48 deletions(-) diff --git a/sys/sys.c b/sys/sys.c index d86db93c..4da3d0f0 100644 --- a/sys/sys.c +++ b/sys/sys.c @@ -26,16 +26,26 @@ ***************************************************************/ /* $Log$ - * Revision 1.8 2001/09/23 20:39:44 bartoldeman - * version 2.1a jeremyd 2001/8/19 - * modified so takes optional 2nd parameter (similar to PC DOS) - * where if only 1 argument is given, assume to be destination drive, - * but if two arguments given, 1st is source (drive and/or path) - * and second is destination drive - * - * FAT32 support. + * Revision 1.9 2001/09/24 02:21:14 bartoldeman + * /* version 2.2 jeremyd 2001/9/20 + * Changed so if no source given or only source drive (no path) + * given, then checks for kernel.sys & command.com in current + * path (of current drive or given drive) and if not there + * uses root (but only if source & destination drive are different). + * Fix printf to include count(ret) if copy can't write all requested bytes + * */ * +/* Revision 1.8 2001/09/23 20:39:44 bartoldeman +/* FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling +/* +/* version 2.2 jeremyd 2001/9/20 + Changed so if no source given or only source drive (no path) + given, then checks for kernel.sys & command.com in current + path (of current drive or given drive) and if not there + uses root (but only if source & destination drive are different). + Fix printf to include count(ret) if copy can't write all requested bytes +*/ /* version 2.1a jeremyd 2001/8/19 modified so takes optional 2nd parameter (similar to PC DOS) where if only 1 argument is given, assume to be destination drive, @@ -138,7 +148,7 @@ #define DEBUG /* #define DDEBUG */ -#define SYS_VERSION "v2.1a" +#define SYS_VERSION "v2.2" #include #include @@ -166,7 +176,7 @@ BYTE pgm[] = "sys"; void put_boot(COUNT); BOOL check_space(COUNT, BYTE *); -BOOL copy(COUNT, BYTE *); +BOOL copy(COUNT drive, BYTE * srcPath, BYTE * rootPath, BYTE * file); COUNT DiskRead(WORD, WORD, WORD, WORD, WORD, BYTE FAR *); COUNT DiskWrite(WORD, WORD, WORD, WORD, WORD, BYTE FAR *); @@ -242,9 +252,6 @@ struct bootsectortype32 UWORD sysFatSecShift; }; -COUNT drive; /* destination drive */ -BYTE srcPath[MAXPATH]; /* source drive and/or path */ -BYTE *endOfSrcPath; /* marks start of filename */ UBYTE newboot[SEC_SIZE], oldboot[SEC_SIZE]; @@ -254,8 +261,12 @@ UBYTE newboot[SEC_SIZE], oldboot[SEC_SIZE]; -VOID main(COUNT argc, char **argv) +int main(int argc, char **argv) { + COUNT drive; /* destination drive */ + COUNT srcDrive; /* source drive */ + BYTE srcPath[MAXPATH]; /* user specified source drive and/or path */ + BYTE rootPath[4]; /* alternate source path to try if not '\0' */ WORD slen; printf("FreeDOS System Installer " SYS_VERSION "\n\n"); @@ -264,12 +275,13 @@ VOID main(COUNT argc, char **argv) { drive = toupper(*argv[1]) - 'A'; srcPath[0] = '\0'; - endOfSrcPath = srcPath; } else if (argc == 3) { drive = toupper(*argv[2]) - 'A'; - strncpy(srcPath, argv[1], MAXDIR); + strncpy(srcPath, argv[1], MAXPATH-12); + /* leave room for COMMAND.COM\0 */ + srcPath[MAXPATH-13] = '\0'; /* make sure srcPath + "file" is a valid path */ slen = strlen(srcPath); if ( (srcPath[slen-1] != ':') && @@ -279,7 +291,6 @@ VOID main(COUNT argc, char **argv) slen++; srcPath[slen] = '\0'; } - endOfSrcPath = srcPath + slen; } else { @@ -291,11 +302,23 @@ VOID main(COUNT argc, char **argv) if (drive < 0 || drive >= 26) { - printf( "%s: drive %c must be A:..Z:\n", pgm,*argv[1]); + printf( "%s: drive %c must be A:..Z:\n", pgm,*argv[(argc == 3 ? 2 : 1)]); exit(1); } + /* Get source drive */ + if ((strlen(srcPath) > 1) && (srcPath[1] == ':')) /* src specifies drive */ + srcDrive = toupper(*srcPath) - 'A'; + else /* src doesn't specify drive, so assume current drive */ + srcDrive = getdisk(); + + /* Don't try root if src==dst drive or source path given */ + if ( (drive == srcDrive) || (*srcPath && ((srcPath[1] != ':') || ((srcPath[1] == ':') && srcPath[2]))) ) + *rootPath = '\0'; + else + sprintf(rootPath, "%c:\\", 'A' + srcDrive); + if (!check_space(drive, oldboot)) { printf("%s: Not enough space to transfer system files\n", pgm); @@ -304,14 +327,14 @@ VOID main(COUNT argc, char **argv) printf("\nCopying KERNEL.SYS...\n"); - if (!copy(drive, "kernel.sys")) + if (!copy(drive, srcPath, rootPath, "kernel.sys")) { printf("\n%s: cannot copy \"KERNEL.SYS\"\n", pgm); exit(1); } printf("\nCopying COMMAND.COM...\n"); - if (!copy(drive, "command.com")) + if (!copy(drive, srcPath, rootPath, "command.com")) { printf("\n%s: cannot copy \"COMMAND.COM\"\n", pgm); exit(1); @@ -321,10 +344,10 @@ VOID main(COUNT argc, char **argv) put_boot(drive); printf("\nSystem transferred.\n"); - exit(0); + return 0; } -#ifdef DEBUG +#ifdef DDEBUG VOID dump_sector(unsigned char far * sec) { COUNT x, y; @@ -553,28 +576,31 @@ VOID put_boot(COUNT drive) printf("DATA starts at sector %lx\n", bs32->sysDataStart); } #endif -#else + else +#endif + { #ifdef STORE_BOOT_INFO /* TE thinks : never, see above */ - /* temporary HACK for the load segment (0x0060): it is in unused */ - /* only needed for older kernels */ - *((UWORD *)(bs->unused)) = *((UWORD *)(((struct bootsectortype *)&b_fat16)->unused)); - /* end of HACK */ + /* temporary HACK for the load segment (0x0060): it is in unused */ + /* only needed for older kernels */ + *((UWORD *)(bs->unused)) = *((UWORD *)(((struct bootsectortype *)&b_fat16)->unused)); + /* end of HACK */ /* root directory sectors */ - bs->sysRootDirSecs = bs->bsRootDirEnts / 16; + bs->sysRootDirSecs = bs->bsRootDirEnts / 16; /* sector FAT starts on */ - temp = bs->bsHiddenSecs + bs->bsResSectors; - bs->sysFatStart = temp; + temp = bs->bsHiddenSecs + bs->bsResSectors; + bs->sysFatStart = temp; /* sector root directory starts on */ - temp = temp + bs->bsFATsecs * bs->bsFATs; - bs->sysRootDirStart = temp; + temp = temp + bs->bsFATsecs * bs->bsFATs; + bs->sysRootDirStart = temp; /* sector data starts on */ - temp = temp + bs->sysRootDirSecs; - bs->sysDataStart = temp; + temp = temp + bs->sysRootDirSecs; + bs->sysDataStart = temp; + } #ifdef DEBUG printf("Root dir entries = %u\n", bs->bsRootDirEnts); @@ -588,7 +614,6 @@ VOID put_boot(COUNT drive) bs->sysRootDirSecs); #endif #endif -#endif #ifdef DDEBUG @@ -618,36 +643,48 @@ BOOL check_space(COUNT drive, BYTE * BlkBuffer) UNREFERENCED_PARAMETER(BlkBuffer); - return 1; + return TRUE; } BYTE copybuffer[COPY_SIZE]; -BOOL copy(COUNT drive, BYTE * file) +BOOL copy(COUNT drive, BYTE * srcPath, BYTE * rootPath, BYTE * file) { - BYTE dest[64]; + BYTE dest[MAXPATH], source[MAXPATH]; COUNT ifd, ofd; unsigned ret; int fdin, fdout; ULONG copied = 0; struct stat fstatbuf; - if (stat(file,&fstatbuf)) - { - printf( "%s: \"%s\" not found\n", pgm, file); - return FALSE; - } + sprintf(dest, "%c:\\%s", 'A' + drive, file); + sprintf(source, "%s%s", srcPath, file); + if (stat(source, &fstatbuf)) + { + printf( "%s: \"%s\" not found\n", pgm, srcPath); + printf( "%s: \"%s\" not found\n", pgm, source); - sprintf(dest, "%c:\\%s", 'A' + drive, file); - strcpy(endOfSrcPath, file); - if ((fdin = open(srcPath, O_RDONLY|O_BINARY)) < 0) + if ((rootPath != NULL) && (*rootPath) /* && (errno == ENOENT) */ ) + { + sprintf(source, "%s%s", rootPath, file); + printf("%s: Trying \"%s\"\n", pgm, source); + if (stat(source, &fstatbuf)) + { + printf( "%s: \"%s\" not found\n", pgm, source); + return FALSE; + } + } + else + return FALSE; + } + + if ((fdin = open(source, O_RDONLY|O_BINARY)) < 0) { printf( "%s: \"%s\" not found\n", pgm, srcPath); return FALSE; } - if ((fdout = open(dest, O_RDWR | O_TRUNC | O_CREAT | O_BINARY,S_IREAD|S_IWRITE)) < 0) { printf( " %s: can't create\"%s\"\nDOS errnum %d", pgm, dest, errno); @@ -659,7 +696,7 @@ BOOL copy(COUNT drive, BYTE * file) { if (write(fdout, copybuffer, ret) != ret) { - printf("Can't write %u bytes to %s\n",dest); + printf("Can't write %u bytes to %s\n", ret, dest); close(fdout); unlink(dest); break; From e43dc517fab6a59af406e23129032d3e63f32161 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Mon, 24 Sep 2001 02:28:14 +0000 Subject: [PATCH 095/671] Minor printf fixes. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@309 6ac86273-5f31-0410-b378-82cca8765d1b --- sys/sys.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/sys/sys.c b/sys/sys.c index 4da3d0f0..77dc7c43 100644 --- a/sys/sys.c +++ b/sys/sys.c @@ -26,15 +26,12 @@ ***************************************************************/ /* $Log$ - * Revision 1.9 2001/09/24 02:21:14 bartoldeman - * /* version 2.2 jeremyd 2001/9/20 - * Changed so if no source given or only source drive (no path) - * given, then checks for kernel.sys & command.com in current - * path (of current drive or given drive) and if not there - * uses root (but only if source & destination drive are different). - * Fix printf to include count(ret) if copy can't write all requested bytes - * */ + * Revision 1.10 2001/09/24 02:28:14 bartoldeman + * Minor printf fixes. * +/* Revision 1.9 2001/09/24 02:21:14 bartoldeman +/* SYS and printer fixes +/* /* Revision 1.8 2001/09/23 20:39:44 bartoldeman /* FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling /* @@ -662,7 +659,6 @@ BOOL copy(COUNT drive, BYTE * srcPath, BYTE * rootPath, BYTE * file) if (stat(source, &fstatbuf)) { - printf( "%s: \"%s\" not found\n", pgm, srcPath); printf( "%s: \"%s\" not found\n", pgm, source); if ((rootPath != NULL) && (*rootPath) /* && (errno == ENOENT) */ ) @@ -681,7 +677,7 @@ BOOL copy(COUNT drive, BYTE * srcPath, BYTE * rootPath, BYTE * file) if ((fdin = open(source, O_RDONLY|O_BINARY)) < 0) { - printf( "%s: \"%s\" not found\n", pgm, srcPath); + printf( "%s: failed to open \"%s\"\n", pgm, source); return FALSE; } From 6c76f67376c4a7a499bfd87cb810b62deeb3bd8d Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Wed, 26 Sep 2001 01:06:05 +0000 Subject: [PATCH 096/671] Change dir gives error for path too long, 2025 without test. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@310 6ac86273-5f31-0410-b378-82cca8765d1b --- hdr/version.h | 4 ++-- kernel/dosfns.c | 7 +++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/hdr/version.h b/hdr/version.h index edc6f082..19f8b28a 100644 --- a/hdr/version.h +++ b/hdr/version.h @@ -44,6 +44,6 @@ static BYTE *date_hRcsId = "$Id$"; #define REVISION_MINOR 1 #define REVISION_SEQ 25 #define BUILD "2025" -#define SUB_BUILD "test" +#define SUB_BUILD "" #define KERNEL_VERSION_STRING "1.1.25" /*#REVISION_MAJOR "." #REVISION_MINOR "." #REVISION_SEQ*/ -#define KERNEL_BUILD_STRING "2025test" /*#BUILD SUB_BUILD*/ +#define KERNEL_BUILD_STRING "2025" /*#BUILD SUB_BUILD*/ diff --git a/kernel/dosfns.c b/kernel/dosfns.c index 5de38733..b51c0301 100644 --- a/kernel/dosfns.c +++ b/kernel/dosfns.c @@ -37,8 +37,8 @@ static BYTE *dosfnsRcsId = "$Id$"; * /// Added SHARE support. 2000/09/04 Ron Cemer * * $Log$ - * Revision 1.27 2001/09/24 02:21:14 bartoldeman - * SYS and printer fixes + * Revision 1.28 2001/09/26 01:06:05 bartoldeman + * Change dir gives error for path too long, 2025 without test. * * Revision 1.26 2001/09/23 20:39:44 bartoldeman * FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling @@ -1326,6 +1326,9 @@ COUNT DosChangeDir(BYTE FAR * s) cdsp = &CDSp->cds_table[drive]; current_ldt = cdsp; + if (strlen(PriPathName) > sizeof(cdsp->cdsCurrentPath)-1) + return DE_PATHNOTFND; + if (cdsp->cdsFlags & CDSNETWDRV) { #if defined(CHDIR_DEBUG) From f95b129d2896856da060870bbc51a1164f161031 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Wed, 26 Sep 2001 01:07:58 +0000 Subject: [PATCH 097/671] updated history git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@311 6ac86273-5f31-0410-b378-82cca8765d1b --- docs/history.txt | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/docs/history.txt b/docs/history.txt index edf9fabe..74e16345 100644 --- a/docs/history.txt +++ b/docs/history.txt @@ -11,10 +11,18 @@ (look for play_dj() in dsk.c) * Simplify Victor's FAT32 fixes a bit * More printer clean-ups + * fixed sys (thanks Jeremy) + * DosChangeDir fails for path name too long. ++ Fixes Jeremy + * Changed SYS so if no source given or only source drive (no path) + given, then checks for kernel.sys & command.com in current + path (of current drive or given drive) and if not there + uses root (but only if source & destination drive are different). + Fix printf to include count(ret) if copy can't write all requested bytes 2001 Sep 22 - Build 2025 (test) -------- Bart Oldeman (bart.oldeman@bristol.ac.uk) + Added Victor - * FAT32 support + * FAT32 support (credits to Martin Stromberg for boot32.asm optimizations) * Delete long file names if short file name given + Added Jeremy * modified SYS so it takes optional 2nd parameter (similar to PC DOS) From 9e007d884e028138445dea5fb0c4c1deaf42c414 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sun, 4 Nov 2001 19:47:39 +0000 Subject: [PATCH 098/671] kernel 2025a changes: see history.txt git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@314 6ac86273-5f31-0410-b378-82cca8765d1b --- build.bat | 194 +++++++---- clean.bat | 21 +- clobber.bat | 22 +- config.b | 22 ++ config.m | 96 +++--- docs/build.txt | 11 +- docs/history.txt | 47 +++ drivers/floppy.asm | 74 +++- drivers/rdatclk.asm | 27 +- fdkernel.lsm | 4 +- hdr/cds.h | 7 +- hdr/dcb.h | 54 ++- hdr/device.h | 23 +- hdr/dirmatch.h | 7 +- hdr/fat.h | 13 +- hdr/fnode.h | 6 +- hdr/process.h | 35 +- hdr/sft.h | 45 +-- hdr/stacks.inc | 64 ++++ kernel/blockio.c | 26 +- kernel/config.c | 75 ++++- kernel/dosfns.c | 279 ++++++++------- kernel/dosnames.c | 80 ++--- kernel/dsk.c | 275 +++++++++++---- kernel/entry.asm | 34 +- kernel/execrh.asm | 24 +- kernel/fatdir.c | 300 +++++++---------- kernel/fatfs.c | 805 +++++++++++++++++++++++++------------------- kernel/fattab.c | 288 ++++++---------- kernel/fcbfns.c | 77 ++--- kernel/globals.h | 32 +- kernel/init-mod.h | 8 +- kernel/initdisk.c | 254 +++++++++----- kernel/int2f.asm | 338 ++++++++++++------- kernel/inthndlr.c | 274 +++++++++------ kernel/io.asm | 5 +- kernel/ioctl.c | 57 ++-- kernel/kernel.asm | 96 +++++- kernel/lfnapi.c | 18 +- kernel/main.c | 21 +- kernel/memmgr.c | 39 ++- kernel/misc.c | 5 +- kernel/network.c | 28 +- kernel/nls_load.c | 21 +- kernel/prf.c | 8 +- kernel/proto.h | 46 ++- kernel/strings.c | 5 +- kernel/syspack.c | 5 +- kernel/systime.c | 26 +- kernel/task.c | 106 +++--- kernel/turboc.cfg | 1 - readme.txt | 8 - sys/sys.c | 27 +- 53 files changed, 2709 insertions(+), 1754 deletions(-) diff --git a/build.bat b/build.bat index 8a58445a..b58a9441 100644 --- a/build.bat +++ b/build.bat @@ -1,86 +1,135 @@ -@echo off - -rem batch file to build everything - -rem $Id$ - -rem $Log$ -rem Revision 1.5 2001/07/09 22:19:30 bartoldeman -rem LBA/FCB/FAT/SYS/Ctrl-C/ioctl fixes + memory savings -rem -rem Revision 1.4 2001/03/22 04:13:30 bartoldeman -rem Change LF to CR/LF in batch files. -rem -rem Revision 1.3 2000/05/25 20:56:19 jimtabor -rem Fixed project history -rem -rem Revision 1.2 2000/05/14 17:05:39 jimtabor -rem Cleanup CRs -rem -rem Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 -rem The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with -rem MS-DOS. Distributed under the GNU GPL. -rem -rem Revision 1.5 1999/08/25 03:59:14 jprice -rem New build batch files. -rem -rem Revision 1.4 1999/08/25 03:38:16 jprice -rem New build config -rem -rem Revision 1.3 1999/04/23 03:46:02 jprice -rem Improved by jprice -rem -rem Revision 1.2 1999/04/17 19:13:29 jprice -rem ror4 patches -rem -rem Revision 1.1.1.1 1999/03/29 15:39:13 jprice -rem New version without IPL.SYS -rem -rem Revision 1.5 1999/02/09 04:47:54 jprice -rem Make makefile use common config.mak file -rem -rem Revision 1.4 1999/01/30 08:29:10 jprice -rem Clean up -rem -rem Revision 1.3 1999/01/30 07:49:16 jprice -rem Clean up -rem - -if not exist config.bat goto noconfigbat -if not exist config.mak goto noconfigmak -goto start - -:noconfigbat -echo You must copy CONFIG.B to CONFIG.BAT and edit it to reflect your setup! -goto end - -:noconfigmak -echo You must copy CONFIG.M to CONFIG.MAK and edit it to reflect your setup! -goto end +:-@echo off + +:- batch file to build everything + +:- $Id$ + +:- $Log$ +:- Revision 1.6 2001/11/04 19:47:37 bartoldeman +:- kernel 2025a changes: see history.txt +:- +:- Revision 1.5 2001/07/09 22:19:30 bartoldeman +:- LBA/FCB/FAT/SYS/Ctrl-C/ioctl fixes + memory savings +:- +:- Revision 1.4 2001/03/22 04:13:30 bartoldeman +:- Change LF to CR/LF in batch files. +:- +:- Revision 1.3 2000/05/25 20:56:19 jimtabor +:- Fixed project history +:- +:- Revision 1.2 2000/05/14 17:05:39 jimtabor +:- Cleanup CRs +:- +:- Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 +:- The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with +:- MS-DOS. Distributed under the GNU GPL. +:- +:- Revision 1.5 1999/08/25 03:59:14 jprice +:- New build batch files. +:- +:- Revision 1.4 1999/08/25 03:38:16 jprice +:- New build config +:- +:- Revision 1.3 1999/04/23 03:46:02 jprice +:- Improved by jprice +:- +:- Revision 1.2 1999/04/17 19:13:29 jprice +:- ror4 patches +:- +:- Revision 1.1.1.1 1999/03/29 15:39:13 jprice +:- New version without IPL.SYS +:- +:- Revision 1.5 1999/02/09 04:47:54 jprice +:- Make makefile use common config.mak file +:- +:- Revision 1.4 1999/01/30 08:29:10 jprice +:- Clean up +:- +:- Revision 1.3 1999/01/30 07:49:16 jprice +:- Clean up +:- + +set XERROR= + + +if not exist config.bat echo You must copy CONFIG.B to CONFIG.BAT and edit it to reflect your setup! +if not exist config.bat goto end + +if not \%1 == \-r goto norebuild + del kernel\*.obj + del lib\libm.lib +:norebuild + -:start call config.bat -cd lib -%MAKE% -flibm.mak +set XERROR= + +:********************************************************************** +:* DONE with preferences - following is command line handling +:* +:* options on the commandline overwrite your default settings +:* +:* options handled ( case significant !! ) +:* +:* BUILD [fat32|fat16] [msc|wc|tc|tcpp] [86|186|386] +:* +:********************************************************************** + +:loop_commandline + +if \%1 == \ goto done_with_commandline + +if %1 == fat32 set XFAT=32 +if %1 == fat16 set XFAT=16 + +if %1 == msc set COMPILER=MSCL8 +if %1 == wc set COMPILER=WATCOM +if %1 == tc set COMPILER=TC2 +if %1 == tcpp set COMPILER=TURBOCPP + + +if %1 == 86 set XCPU=86 +if %1 == 186 set XCPU=186 +if %1 == 386 set XCPU=386 + +shift +goto loop_commandline + +:done_with_commandline + +if \%COMPILER% == \ echo you MUST define a COMPILER variable in CONFIG.BAT +if \%COMPILER% == \ goto end + +:************************************************************************ +:* finally - we are going to compile +:************************************************************************ + +cd utils +%MAKE% production +if errorlevel 1 goto abort + +cd ..\lib +%MAKE% if errorlevel 1 goto abort cd ..\drivers -%MAKE% -fdevice.mak production +%MAKE% production if errorlevel 1 goto abort + cd ..\boot -%MAKE% -fboot.mak production +%MAKE% production if errorlevel 1 goto abort cd ..\sys -%MAKE% -fbin2c.mak production -if errorlevel 1 goto abort -%MAKE% -fsys.mak production +%MAKE% production if errorlevel 1 goto abort +:start + cd ..\kernel -%MAKE% -fkernel.mak production +%MAKE% production if errorlevel 1 goto abort cd.. @@ -90,9 +139,14 @@ cd.. if exist build2.bat call build2 -goto end +@goto end :abort cd .. +set XERROR=1 :end -set MAKE= +:***** cleanup ****** +@set MAKE= +@set COMPILER= +@set XCPU= +@set XFAT= diff --git a/clean.bat b/clean.bat index db83b748..f7fe99a7 100644 --- a/clean.bat +++ b/clean.bat @@ -5,6 +5,9 @@ rem batch file to clean everything rem $Id$ rem $Log$ +rem Revision 1.5 2001/11/04 19:47:37 bartoldeman +rem kernel 2025a changes: see history.txt +rem rem Revision 1.4 2001/03/22 04:13:30 bartoldeman rem Change LF to CR/LF in batch files. rem @@ -47,23 +50,26 @@ echo You must copy CONFIG.M to CONFIG.MAK and edit it to reflect your setup! goto end :start +@set COMPILER=tc2 call config.bat -cd lib -%MAKE% -flibm.mak clean +cd utils +%MAKE% clean + +cd ..\lib +%MAKE% clean cd ..\drivers -%MAKE% -fdevice.mak clean +%MAKE% clean cd ..\boot -%MAKE% -fboot.mak clean +%MAKE% clean cd ..\sys -%MAKE% -fbin2c.mak clean -%MAKE% -fsys.mak clean +%MAKE% clean cd ..\kernel -%MAKE% -fkernel.mak clean +%MAKE% clean cd ..\hdr del *.bak @@ -74,3 +80,4 @@ del *.bak :end set MAKE= +set COMPILER= diff --git a/clobber.bat b/clobber.bat index 7c436e98..96d3230c 100644 --- a/clobber.bat +++ b/clobber.bat @@ -4,6 +4,9 @@ rem batch file to clobber everything rem $Id$ rem $Log$ +rem Revision 1.5 2001/11/04 19:47:37 bartoldeman +rem kernel 2025a changes: see history.txt +rem rem Revision 1.4 2001/03/22 04:13:30 bartoldeman rem Change LF to CR/LF in batch files. rem @@ -40,23 +43,27 @@ echo You must copy CONFIG.M to CONFIG.MAK and edit it to reflect your setup! goto end :start +set COMPILER=tc2 call config.bat -cd lib -%MAKE% -flibm.mak clobber +cd utils +%MAKE% clobber + +cd ..\lib +%MAKE% clobber cd ..\drivers -%MAKE% -fdevice.mak clobber +%MAKE% clobber cd ..\boot -%MAKE% -fboot.mak clobber +%MAKE% clobber cd ..\sys -%MAKE% -fbin2c.mak clobber -%MAKE% -fsys.mak clobber +%MAKE% clobber +%MAKE% clobber cd ..\kernel -%MAKE% -fkernel.mak clobber +%MAKE% clobber cd ..\hdr del *.bak @@ -68,3 +75,4 @@ del status.me :end set MAKE= +set COMPILER= \ No newline at end of file diff --git a/config.b b/config.b index 3f5bf681..d9a230d5 100644 --- a/config.b +++ b/config.b @@ -1 +1,23 @@ +rem ********************************************************************** +rem - define your MAKE type here, pick one of them +rem ********************************************************************** + set MAKE=c:\tc201\make +rem set MAKE=c:\watcom\binw\wmake /ms +rem set MAKE=c:\msvc\bin\nmake /nologo + +rem ********************************************************************** +rem - define your COMPILER type here, pick one of them +rem ********************************************************************** + +set COMPILER=TC2 +rem set COMPILER=TURBOCPP +rem set COMPILER=TC3 +rem set COMPILER=BC5 +rem set COMPILER=MSCL8 + +rem warning: watcom can compile but the result does not work yet. +rem set COMPILER=WATCOM + +rem skip MS compiler in buildall. +rem set SKIPMS=yes diff --git a/config.m b/config.m index d08787ba..8ecc114a 100644 --- a/config.m +++ b/config.m @@ -6,11 +6,44 @@ # NOTICE! You must edit and rename this file to CONFIG.MAK! # ################################################################ -# These are generic definitions -RM=..\utils\rm -f +#********************************************************************* +# determine your compiler settings +# +# you have to +# search for NASM - and set the path for NASM +# search for ??_BASE - and set the path to your compiler +# search for LINK - and set the path to your linker +# +#********************************************************************* -# Give path to nasm here (or if it's in your path just uncomment the line). -#NASM=nasm +#********************************************************************** +#- define where to find NASM - remember - it should not be protected +# mode DJGPP version if you're using Windows NT/2k/XP to compile +#********************************************************************** + +NASM=c:\bin\nasm16 + +#********************************************************************** +#- where is the BASE dir of your compiler(s) ?? +#********************************************************************** + +WC_BASE=C:\watcom +MS_BASE=C:\msvc +TC2_BASE=C:\tc201 +TP1_BASE=C:\tcpp +TC3_BASE=C:\tc3 +BC5_BASE=C:\bc5 + +#********************************************************************** +#- select your default target: required CPU and what FAT system to support +#********************************************************************** + +#XCPU=86 +#XCPU=186 +#XCPU=386 + +#XFAT=16 +#XFAT=32 # Give extra Turbo C compiler flags here # such as -DDEBUG : extra DEBUG output @@ -18,50 +51,33 @@ # -DWITHFAT32 : compile with FAT32 support #ALLCFLAGS=-DDEBUG +!include "..\mkfiles\generic.mak" -# Use these for Turbo C 2.01 -#COMPILER=TC2 -#COMPILERPATH=c:\tc201 -#CC=$(COMPILERPATH)\tcc -#LINK=$(COMPILERPATH)\tlink -#LIBUTIL=$(COMPILERPATH)\tlib -#LIBPATH=$(COMPILERPATH)\lib -#CLIB=$(COMPILERPATH)\lib\cs.lib -#INCLUDEPATH=$(COMPILERPATH)\include -#MATH_EXTRACT=*LDIV *LLSH *LURSH *LXMUL *LRSH *SPUSH *SCOPY -#MATH_INSERT=+LDIV +LLSH +LURSH +LXMUL +LRSH +SPUSH +SCOPY +#********************************************************************** +#- which linker to use: WATCOM wlink is not suitable for linking +#********************************************************************** +# Turbo Link +#LINK=$(TC2_BASE)\tlink /m/c +LINK=d:\util\tlink /m/c +# Microsoft Link +#LINK=$(COMPILERBIN)\link /ONERROR:NOEXE /ma +# VAL: you need VAL95, NOT the one in LANG1.ZIP (yet); +# look at the software list on www.freedos.org. +# VAL complains about MODEND record missing for Watcom compiled objects! +# LINK=c:\bin\val /MP /NCI -# Use these for Turbo C 3.0 -#COMPILER=TC3 -#COMPILERPATH=c:\tc -#CC=$(COMPILERPATH)\bin\tcc -#LINK=$(COMPILERPATH)\bin\tlink -#LIBUTIL=$(COMPILERPATH)\bin\tlib -#LIBPATH=$(COMPILERPATH)\lib -#CLIB=$(COMPILERPATH)\lib\cs.lib -#INCLUDEPATH=$(COMPILERPATH)\include -#MATH_EXTRACT=*H_LDIV *H_LLSH *H_LURSH *N_LXMUL *F_LXMUL *H_LRSH *H_SPUSH *N_SCOPY *F_SCOPY -#MATH_INSERT=+H_LDIV +H_LLSH +H_LURSH +N_LXMUL +F_LXMUL +H_LRSH +H_SPUSH +N_SCOPY +F_SCOPY - - -# Use these for Borland C++ -#COMPILER=BC5 -#COMPILERPATH=c:\bc5 -#CC=$(COMPILERPATH)\bin\tcc -#LINK=$(COMPILERPATH)\bin\tlink -#LIBUTIL=$(COMPILERPATH)\bin\tlib -#LIBPATH=$(COMPILERPATH)\lib -#CLIB=$(COMPILERPATH)\lib\cs.lib -#INCLUDEPATH=$(COMPILERPATH)\include -#MATH_EXTRACT=*H_LDIV *H_LLSH *H_LURSH *N_LXMUL *F_LXMUL *H_LRSH *H_SPUSH *N_SCOPY *F_SCOPY -#MATH_INSERT=+H_LDIV +H_LLSH +H_LURSH +N_LXMUL +F_LXMUL +H_LRSH +H_SPUSH +N_SCOPY +F_SCOPY - +# use a ; to end the LINK command line? +LINKTERM=; + # # $Id$ # # $Log$ +# Revision 1.9 2001/11/04 19:47:37 bartoldeman +# kernel 2025a changes: see history.txt +# # Revision 1.8 2001/09/23 20:39:43 bartoldeman # FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling # diff --git a/docs/build.txt b/docs/build.txt index 4421bc5b..2e492f4f 100644 --- a/docs/build.txt +++ b/docs/build.txt @@ -23,11 +23,17 @@ you put the tools. *TE******* Make sure to use the NASMR version, as the DosExtender version _seems_ to produce wrong code. the tested version is NASM98R, 06/04/99, 202.606 bytes. +*Bart***** This is probably only true for Windows NT/2k/XP; In that + case you could use the Win32 version anyway. +Look at +ftp://ftp.kernel.org/pub/software/devel/nasm +or a mirror of ftp.kernel.org. This program will now compile with Turbo C 2.01 (now freely available!), Turbo C 3.0, Borland C 4.51 & 5.01. It should work with -other Borland compilers as well. +other Borland compilers and Microsoft C as well. Watcom C can compile +it but the result does not work yet. If you feel hardy, read on to understand the directory structure. A more complete description of the build environment is contained in a @@ -70,6 +76,9 @@ component. Study the makefile to better understand this. $Id$ $Log$ +Revision 1.5 2001/11/04 19:47:39 bartoldeman +kernel 2025a changes: see history.txt + Revision 1.4 2001/07/09 22:19:33 bartoldeman LBA/FCB/FAT/SYS/Ctrl-C/ioctl fixes + memory savings diff --git a/docs/history.txt b/docs/history.txt index 74e16345..50407d26 100644 --- a/docs/history.txt +++ b/docs/history.txt @@ -1,3 +1,50 @@ +2001 Nov xx - Build 2025a +-------- Bart Oldeman (bart.oldeman@bristol.ac.uk) ++ Changes tom + * config.sys processing: placing ? on the left side of '=' like + ?device= or device ?= + asks for this single line + fill the available HMA with buffers + * added kernel configuration options to sys.com, small area at 60:xx + * readblock optimized to read as many data as possible in one + int13 request - great speedups for large reads + * some more SDA variables need to be updated for the network + redirector (the sft index) + * reduce stack usage in task.c, fattab.c, ioctl.c, execrh.asm, inthndlr.c + * protect high part of 32-bit registers (stacks.inc) + * moved copyright messages to init data to save a bit of memory + * added relocinf, patchobj, sorted + some more output of exeflat + * UMB fixes ++ Fixes Bart, Victor, Tom + * more FAT32 fixes - to work with device drivers + * fixed overflow problem with more than 2048 directory entries + * various space saving changes, dir_init_fnode ++ Changes Bart, Tom + * many makefile changes to enable compilation with different + compilers (MS, Watcom, Borland). Watcom compiles but the result + does not run yet. ++ Changes Bart + * support for IOCTL AX=440D, CL=40,41,42,61,62 for + read/write/format track - this enables R. Nordier format to work + * default floppy type depends on the drive + * rewrote many parts of int2f.asm to have a cleaner remote_xxx + interface with less code and stack usage. + * limit for int21/ah=36 is FFF6 total/free sectors + * made the rtc clock reading code a bit more robust - assumes + there is no rtc if the returned date is zero + * removed non-necessary code in dosnames.c because we're always + dealing with a TRUENAME there + * added zero extending of files, but removed it (unless you force + it) since MSDOS doesn't zero-extend files either + * wrote a source for exeflat, removed all binaries from the source + * added more INT2F/AH=12 functions to solve some MSCDEX issues + * changed BAD sector handling : only ....FF7 is recognized as BAD, + but FORMAT information from initdisk will only give ....FEF as + the largest cluster (for safety), so ....FF0-....FF6 are not used + for newly formatted disks (here .... is either nothing, F, or + FFFF, FAT12/FAT16/FAT32). + * more fatfs/fatdir clean-ups - now unnecessary fields dfull, + dremote and dsize removed from fnodes. 2001 Sep 24 - Build 2025 -------- Bart Oldeman (bart.oldeman@bristol.ac.uk) + Fixes Victor diff --git a/drivers/floppy.asm b/drivers/floppy.asm index 876c77ab..1fb4de43 100644 --- a/drivers/floppy.asm +++ b/drivers/floppy.asm @@ -30,6 +30,9 @@ ; $Id$ ; ; $Log$ +; Revision 1.9 2001/11/04 19:47:39 bartoldeman +; kernel 2025a changes: see history.txt +; ; Revision 1.8 2001/09/23 20:39:44 bartoldeman ; FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling ; @@ -223,6 +226,18 @@ _fl_rd_status: ret +; +; Format Sectors +; +; COUNT fl_format(WORD drive, WORD head, WORD track, WORD sector, WORD count, BYTE FAR *buffer); +; +; Formats one or more tracks, sector should be 0. +; +; Returns 0 if successful, error code otherwise. + global _fl_format +_fl_format: + mov ah, 5 + jmp short fl_common ; ; Read Sectors ; @@ -294,15 +309,7 @@ fl_error: ret - %if 0 - global _fl_format -_fl_format: - - xor ax,ax - ret - - ; ; ; Get number of disks @@ -463,3 +470,54 @@ global _fl_readkey _fl_readkey: xor ah, ah int 16h ret + +global _fl_setdisktype +_fl_setdisktype: + push bp + mov bp, sp + mov dl,[bp+4] ; drive number + mov al,[bp+6] ; disk type + mov ah,17h + int 13h + mov al,ah + xor ah,ah + pop bp + ret + +global _fl_setmediatype +_fl_setmediatype: + push bp + mov bp, sp + push di + + mov dl,[bp+4] ; drive number + mov bx,[bp+6] ; number of tracks + dec bx ; should be highest track + mov ch,bl ; low 8 bits of cyl number + + xor bl,bl ; extract bits 8+9 to cl + shr bx,1 + shr bx,1 + + mov cl,[bp+8] ; sectors/track + and cl,03fh ; mask to sector field bits 5-0 + or cl,bl ; or in bits 7-6 + + mov ah,18h + int 13h + mov al,ah + mov ah,0 + jc skipint1e + mov bx,es + xor dx,dx + mov es,dx + cli + mov [es:0x1e*4 ], di + mov [es:0x1e*4+2], bx ; set int 0x1e table to es:di (bx:di) + sti +skipint1e: + pop di + pop bp + ret + + diff --git a/drivers/rdatclk.asm b/drivers/rdatclk.asm index df4fdeea..73391587 100644 --- a/drivers/rdatclk.asm +++ b/drivers/rdatclk.asm @@ -73,14 +73,27 @@ segment HMA_TEXT ; global _ReadATClock _ReadATClock: - mov ah,2 + push bp + mov bp, sp + xor cx, cx ; cx=dx=0 check if present + xor dx, dx ; if it returns non-zero + clc ; necessary according to RBIL + mov ah,4 int 1ah - jnc @RdAT1140 - sbb ax,ax + jc @RdATerror + + or cx, cx + jnz @RdAT1140 + or dx, dx + jnz @RdAT1140 +@RdATerror: mov ax, 1 + pop bp ret @RdAT1140: - push bp - mov bp,sp + clc + mov ah, 2 + int 1ah + jc @RdATerror ; bcdSeconds = 10 ; bcdMinutes = 8 ; bcdHours = 6 @@ -91,11 +104,13 @@ _ReadATClock: mov byte [bx],cl ;Minutes mov bx,word [bp+10] ;bcdSeconds mov byte [bx],dh ;Seconds + clc mov ah,4 int 1ah + jc @RdATerror mov bx,word [bp+4] ;bcdDays mov word [bx],dx ;Days mov word [bx+2],cx sub ax,ax - pop bp + pop bp ret diff --git a/fdkernel.lsm b/fdkernel.lsm index cd187e81..839365d0 100644 --- a/fdkernel.lsm +++ b/fdkernel.lsm @@ -1,7 +1,7 @@ Begin3 Title: The FreeDOS Kernel -Version: 1.1.24 -Entered-date: 2 Jun 2001 +Version: 1.1.25 +Entered-date: 26 Sep 2001 Description: The FreeDOS Kernel. Keywords: kernel freedos dos msdos Author: (developers) diff --git a/hdr/cds.h b/hdr/cds.h index 27ca2831..dba497ed 100644 --- a/hdr/cds.h +++ b/hdr/cds.h @@ -34,6 +34,9 @@ static BYTE *Cds_hRcsId = "$Id$"; /* * $Log$ + * Revision 1.5 2001/11/04 19:47:39 bartoldeman + * kernel 2025a changes: see history.txt + * * Revision 1.4 2001/04/15 03:21:50 bartoldeman * See history.txt for the list of fixes. * @@ -87,14 +90,14 @@ struct cds _cdsRedirRec; struct { - WORD _cdsStrtClst; + UWORD _cdsStrtClst; UWORD _cdsParam; } _cdsRedir; } _cdsUnion; - WORD cdsStoreUData; + UWORD cdsStoreUData; WORD cdsJoinOffset; diff --git a/hdr/dcb.h b/hdr/dcb.h index 3061a22e..966ec4be 100644 --- a/hdr/dcb.h +++ b/hdr/dcb.h @@ -36,6 +36,9 @@ static BYTE *clock_hRcsId = "$Id$"; /* * $Log$ + * Revision 1.6 2001/11/04 19:47:39 bartoldeman + * kernel 2025a changes: see history.txt + * * Revision 1.5 2001/09/23 20:39:44 bartoldeman * FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling * @@ -101,18 +104,9 @@ struct dpb UWORD dpb_fatstrt; /* FAT start sector */ UBYTE dpb_fats; /* # of FAT copies */ UWORD dpb_dirents; /* # of dir entries */ -#ifdef WITHFAT32 - UWORD dpb_wdata; /* start of data area */ - UWORD dpb_wsize; /* # of clusters+1 on media */ - UWORD dpb_wfatsize; /* # of sectors / FAT */ -#else UWORD dpb_data; /* start of data area */ UWORD dpb_size; /* # of clusters+1 on media */ UWORD dpb_fatsize; /* # of sectors / FAT */ -#define dpb_wdata dpb_data -#define dpb_wsize dpb_size -#define dpb_wfatsize dpb_fatsize -#endif UWORD dpb_dirstrt; /* start sec. of root dir */ struct dhdr FAR * /* pointer to device header */ dpb_device; @@ -120,36 +114,40 @@ struct dpb BYTE dpb_flags; /* -1 = force MEDIA CHK */ struct dpb FAR * /* next dpb in chain */ dpb_next; /* -1 = end */ -#ifdef WITHFAT32 - UWORD dpb_wcluster; /* cluster # of first free */ + UWORD dpb_cluster; /* cluster # of first free */ /* -1 if not known */ - ULONG dpb_nfreeclst; /* number of free clusters */ +#ifndef WITHFAT32 + UWORD dpb_nfreeclst; /* number of free clusters */ /* -1 if not known */ +#else + union + { + struct + { + UWORD dpb_nfreeclst_lo; + UWORD dpb_nfreeclst_hi; + } dpb_nfreeclst_st; + ULONG _dpb_xnfreeclst; /* number of free clusters */ + /* -1 if not known */ + } dpb_nfreeclst_un; + #define dpb_nfreeclst dpb_nfreeclst_un.dpb_nfreeclst_st.dpb_nfreeclst_lo + #define dpb_xnfreeclst dpb_nfreeclst_un._dpb_xnfreeclst + UWORD dpb_xflags; /* extended flags, see bpb */ UWORD dpb_xfsinfosec; /* FS info sector number, */ /* 0xFFFF if unknown */ UWORD dpb_xbackupsec; /* backup boot sector number */ /* 0xFFFF if unknown */ - ULONG dpb_data; - ULONG dpb_size; /* # of clusters+1 on media */ - ULONG dpb_fatsize; /* # of sectors / FAT */ + ULONG dpb_xdata; + ULONG dpb_xsize; /* # of clusters+1 on media */ + ULONG dpb_xfatsize; /* # of sectors / FAT */ ULONG dpb_xrootclst; /* starting cluster of root dir */ - ULONG dpb_cluster; /* cluster # of first free */ + ULONG dpb_xcluster; /* cluster # of first free */ /* -1 if not known */ -#else - UWORD dpb_cluster; /* cluster # of first free */ - /* -1 if not known */ -#define dpb_wcluster dpb_cluster - UWORD dpb_nfreeclst; /* number of free clusters */ - /* -1 if not known */ -#endif +#endif }; #define UNKNCLUSTER 0x0000 /* see RBIL INT 21/AH=52 entry */ -#ifdef WITHFAT32 -#define UNKNCLSTFREE 0xffffffffl /* unknown for DOS */ -#else +#define XUNKNCLSTFREE 0xffffffffl /* unknown for DOS */ #define UNKNCLSTFREE 0xffff /* unknown for DOS */ -#endif -#define UNKNCLSTFREE16 0xffff /* unknown for DOS */ diff --git a/hdr/device.h b/hdr/device.h index f3f9eafe..5a499f68 100644 --- a/hdr/device.h +++ b/hdr/device.h @@ -35,6 +35,9 @@ static BYTE *device_hRcsId = "$Id$"; /* * $Log$ + * Revision 1.9 2001/11/04 19:47:39 bartoldeman + * kernel 2025a changes: see history.txt + * * Revision 1.8 2001/09/23 20:39:44 bartoldeman * FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling * @@ -321,7 +324,7 @@ typedef struct ddtstruct { UWORD ddt_part; /* partition (FFFFh = primary, 0001h = extended) always 0001h for DOS 5+ */ - UWORD ddt_absyl; /* absolute cylinder number of partition's + UWORD ddt_abscyl; /* absolute cylinder number of partition's start on physical drive (FFFFh if primary partition in DOS 4.x)*/ } ddt_hd; @@ -361,6 +364,24 @@ struct gblkio UWORD gbio_nsecs; }; +struct gblkfv /* for format / verify track */ +{ + UBYTE gbfv_spcfunbit; + UWORD gbfv_head; + UWORD gbfv_cyl; + UWORD gbfv_ntracks; +}; + +struct gblkrw /* for read / write track */ +{ + UBYTE gbrw_spcfunbit; + UWORD gbrw_head; + UWORD gbrw_cyl; + UWORD gbrw_sector; + UWORD gbrw_nsecs; + UBYTE FAR * gbrw_buffer; +}; + struct Gioc_media { WORD ioc_level; diff --git a/hdr/dirmatch.h b/hdr/dirmatch.h index 6956f20a..52c2567f 100644 --- a/hdr/dirmatch.h +++ b/hdr/dirmatch.h @@ -36,6 +36,9 @@ static BYTE *dirmatch_hRcsId = "$Id$"; /* * $Log$ + * Revision 1.7 2001/11/04 19:47:39 bartoldeman + * kernel 2025a changes: see history.txt + * * Revision 1.6 2001/09/23 20:39:44 bartoldeman * FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling * @@ -120,10 +123,8 @@ typedef struct f_dnew:1; BITS /* fnode is assigned to dir */ f_ddir:1; - BITS /* directory is full */ - f_dfull:1; BITS /* filler to avoid a bad bug (feature?) in */ - f_filler:11; /* TC 2.01 */ + f_filler:12; /* TC 2.01 */ } dm_flags; /* file flags */ diff --git a/hdr/fat.h b/hdr/fat.h index 7259deb7..fb1736e7 100644 --- a/hdr/fat.h +++ b/hdr/fat.h @@ -36,6 +36,9 @@ static BYTE *fat_hRcsId = "$Id$"; /* * $Log$ + * Revision 1.9 2001/11/04 19:47:39 bartoldeman + * kernel 2025a changes: see history.txt + * * Revision 1.8 2001/09/23 20:39:44 bartoldeman * FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling * @@ -121,10 +124,6 @@ static BYTE *fat_hRcsId = "$Id$"; * (ULONG) cluster_size \ + (ULONG) data_start)) -#define clus2phys(cl_no,cl_size,d_st) ((ULONG) (((ULONG) cl_no - 2L) \ - * (ULONG) cl_size \ - + (ULONG) d_st)) - /* Test for 16 bit or 12 bit FAT */ #define SIZEOF_CLST16 2 #define SIZEOF_CLST32 4 @@ -135,9 +134,13 @@ static BYTE *fat_hRcsId = "$Id$"; /* int ISFAT32(struct dpb FAR *dpbp);*/ #define ISFAT32(x) _ISFAT32(x) +/* #define _ISFAT32(dpbp) (((dpbp)->dpb_size)>FAT_MAGIC16 && ((dpbp)->dpb_size)<=FAT_MAGIC32 ) +*/ +#define _ISFAT32(dpbp) (((dpbp)->dpb_fatsize)==0) #define ISFAT16(dpbp) (((dpbp)->dpb_size)>FAT_MAGIC && ((dpbp)->dpb_size)<=FAT_MAGIC16 ) -#define ISFAT12(dpbp) (((dpbp)->dpb_size)<=FAT_MAGIC) +#define ISFAT12(dpbp) ((((dpbp)->dpb_size)-1)b_next) + { + if (blknolow <= getblkno(bp) && + getblkno(bp) <= blknohigh && + (bp->b_flag & BFR_VALID) && (bp->b_unit == dsk)) + { + flush1(bp); + } + } + + return FALSE; +} + + void dumpBufferCache(void) { struct buffer FAR *bp; @@ -535,7 +559,7 @@ BOOL flush(void) bp = bp->b_next; } - int2f_Remote_call(REM_FLUSHALL, 0, 0, 0, 0, 0, 0); + remote_flushall(); return (ok); } diff --git a/kernel/config.c b/kernel/config.c index 751c1511..243beb04 100644 --- a/kernel/config.c +++ b/kernel/config.c @@ -89,6 +89,9 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.29 2001/11/04 19:47:39 bartoldeman + * kernel 2025a changes: see history.txt + * * Revision 1.28 2001/09/23 20:39:44 bartoldeman * FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling * @@ -293,8 +296,11 @@ STATIC COUNT nPass = 0; STATIC BYTE szLine[256] = {0}; STATIC BYTE szBuf[256] = {0}; -int singleStep = FALSE; -int SkipAllConfig = FALSE; +BYTE singleStep = FALSE; /* F8 processing */ +BYTE SkipAllConfig = FALSE; /* F5 processing */ +BYTE askThisSingleCommand = FALSE; /* ?device= device?= */ + + INIT VOID zumcb_init(UCOUNT seg, UWORD size); INIT VOID mumcb_init(UCOUNT seg, UWORD size); @@ -817,7 +823,7 @@ ULONG GetBiosTime(VOID) { return *(ULONG FAR *)(MK_FP(0x40,0x6c)); } -GetBiosKey(int timeout) +UWORD GetBiosKey(int timeout) { iregs r; @@ -854,11 +860,15 @@ INIT BOOL SkipLine(char *pLine) if (!initialized) { - initialized = TRUE; + initialized = TRUE; - printf("Press F8 to trace or F5 to skip CONFIG.SYS/AUTOEXEC.BAT"); + if (InitKernelConfig.SkipConfigSeconds < 0) + return FALSE; + + if (InitKernelConfig.SkipConfigSeconds > 0) + printf("Press F8 to trace or F5 to skip CONFIG.SYS/AUTOEXEC.BAT"); - key = GetBiosKey(2); /* wait 2 seconds */ + key = GetBiosKey(InitKernelConfig.SkipConfigSeconds); /* wait 2 seconds */ if (key == 0x3f00) /* F5 */ { @@ -874,11 +884,13 @@ INIT BOOL SkipLine(char *pLine) if (SkipAllConfig) printf("Skipping CONFIG.SYS/AUTOEXEC.BAT\n"); } + + if (SkipAllConfig) return TRUE; - if (!singleStep) + if (!askThisSingleCommand && !singleStep) return FALSE; printf("%s[Y,N]?", pLine); @@ -923,7 +935,7 @@ INIT BYTE *GetNumArg(BYTE * pLine, COUNT * pnArg) { /* look for NUMBER */ pLine = skipwh(pLine); - if (!isnum(pLine)) + if (!isnum(pLine) && *pLine != '-') { CfgFailure(pLine); return (BYTE *) 0; @@ -949,7 +961,7 @@ INIT void Config_Buffers(BYTE * pLine) return; /* Got the value, assign either default or new value */ - Config.cfgBuffers = max(Config.cfgBuffers, nBuffers); + Config.cfgBuffers = (nBuffers < 0 ? nBuffers : max(Config.cfgBuffers, nBuffers)); } INIT STATIC VOID sysScreenMode(BYTE * pLine) @@ -1284,8 +1296,12 @@ INIT BOOL LoadDevice(BYTE * pLine, COUNT top, COUNT mode) #endif - if (init_DosExec(3, &eb, szBuf) == SUCCESS) - { + if ((result = init_DosExec(3, &eb, szBuf)) != SUCCESS) + { + CfgFailure(pLine); + return result; + } + strcpy(szBuf, pLine); /* TE this fixes the loading of devices drivers with @@ -1321,9 +1337,7 @@ INIT BOOL LoadDevice(BYTE * pLine, COUNT top, COUNT mode) HMAState = HMA_DONE; config_init_buffers( Config.cfgBuffers); } - } - else - CfgFailure(pLine); + return result; } @@ -1402,6 +1416,8 @@ INIT BYTE * INIT BYTE * scan(BYTE * s, BYTE * d) { + askThisSingleCommand = FALSE; + s = skipwh(s); while (*s && !(*s == 0x0d @@ -1409,11 +1425,20 @@ INIT BYTE * || *s == ' ' || *s == '\t' || *s == '=')) - *d++ = *s++; + { + if (*s == '?') + { + askThisSingleCommand = TRUE; + s++; + } + else + *d++ = *s++; + } *d = '\0'; return s; } +/* INIT BYTE *scan_seperator(BYTE * s, BYTE * d) { s = skipwh(s); @@ -1422,6 +1447,7 @@ INIT BYTE *scan_seperator(BYTE * s, BYTE * d) *d = '\0'; return s; } +*/ INIT BOOL isnum(BYTE * pLine) { @@ -1432,8 +1458,15 @@ INIT BOOL isnum(BYTE * pLine) INIT BYTE *GetNumber(REG BYTE * pszString, REG COUNT * pnNum) { BYTE Base = 10; + BOOL Sign = FALSE; *pnNum = 0; + if (*pszString == '-') + { + pszString++; + Sign = TRUE; + } + while (isnum(pszString) || toupper(*pszString) == 'X') { if (toupper(*pszString) == 'X') @@ -1444,6 +1477,8 @@ INIT BYTE *GetNumber(REG BYTE * pszString, REG COUNT * pnNum) else *pnNum = *pnNum * Base + (*pszString++ - '0'); } + if (Sign) + *pnNum = -*pnNum; return pszString; } @@ -1577,6 +1612,13 @@ VOID config_init_buffers(COUNT anzBuffers) struct buffer FAR *pbuffer; int HMAcount = 0; BYTE FAR *tmplpBase = lpBase; + BOOL fillhma = TRUE; + + if (anzBuffers < 0) + { + anzBuffers = -anzBuffers; + fillhma = FALSE; + } anzBuffers = max(anzBuffers,6); if (anzBuffers > 99) @@ -1614,6 +1656,7 @@ VOID config_init_buffers(COUNT anzBuffers) /* now, we can have quite some buffers in HMA -- up to 37 for KE38616. so we fill the HMA with buffers + but not if the BUFFERS count is negative ;-) */ if (i < (anzBuffers - 1)) @@ -1628,6 +1671,8 @@ VOID config_init_buffers(COUNT anzBuffers) pbuffer->b_next = ConfigAlloc(sizeof (struct buffer)); } } + else if (fillhma) + pbuffer->b_next = HMAalloc(sizeof (struct buffer)); if (pbuffer->b_next == NULL) break; diff --git a/kernel/dosfns.c b/kernel/dosfns.c index b51c0301..e96fb90c 100644 --- a/kernel/dosfns.c +++ b/kernel/dosfns.c @@ -37,6 +37,9 @@ static BYTE *dosfnsRcsId = "$Id$"; * /// Added SHARE support. 2000/09/04 Ron Cemer * * $Log$ + * Revision 1.29 2001/11/04 19:47:39 bartoldeman + * kernel 2025a changes: see history.txt + * * Revision 1.28 2001/09/26 01:06:05 bartoldeman * Change dir gives error for path too long, 2025 without test. * @@ -212,7 +215,7 @@ f_node_ptr xlt_fd(COUNT); /* /// Added for SHARE. - Ron Cemer */ -int share_installed = 0; +BYTE share_installed = 0; /* DOS calls this to see if it's okay to open the file. Returns a file_table entry number to use (>= 0) if okay @@ -313,9 +316,13 @@ sft FAR *idx_to_sft(COUNT SftIndex) for (sp = sfthead; sp != (sfttbl FAR *) - 1; sp = sp->sftt_next) { - if (SftIndex < sp->sftt_count) + if (SftIndex < sp->sftt_count) + { + lpCurSft = (sft FAR *) & (sp->sftt_table[SftIndex]); + /* finally, point to the right entry */ - return (sft FAR *) & (sp->sftt_table[SftIndex]); + return lpCurSft; + } else SftIndex -= sp->sftt_count; } @@ -346,14 +353,13 @@ sft FAR *get_sft(UCOUNT hndl) * binary reads, while for 0x40 the type of read (binary/text) depends on what * the SFT says. -- ror4 */ -UCOUNT GenericRead(COUNT hndl, UCOUNT n, BYTE FAR * bp, COUNT FAR * err, +UCOUNT GenericReadSft(sft FAR *s, UCOUNT n, BYTE FAR * bp, COUNT FAR * err, BOOL force_binary) { - sft FAR *s; UCOUNT ReadCount; /* Get the SFT block that contains the SFT */ - if ((s = get_sft(hndl)) == (sft FAR *) - 1) + if (s == (sft FAR *) - 1) { *err = DE_INVLDHNDL; return 0; @@ -372,8 +378,17 @@ UCOUNT GenericRead(COUNT hndl, UCOUNT n, BYTE FAR * bp, COUNT FAR * err, */ if (s->sft_flags & SFT_FSHARED) { - ReadCount = Remote_RW(REM_READ, n, bp, s, err); - return *err == SUCCESS ? ReadCount : 0; + COUNT rc; + BYTE FAR *save_dta; + + save_dta = dta; + lpCurSft = s; + current_filepos = s->sft_posit; /* needed for MSCDEX */ + dta = bp; + ReadCount = remote_read(s, n, &rc); + dta = save_dta; + *err = rc; + return rc == SUCCESS ? ReadCount : 0; } /* Do a device read if device */ if (s->sft_flags & SFT_FDEVICE) @@ -448,16 +463,8 @@ UCOUNT GenericRead(COUNT hndl, UCOUNT n, BYTE FAR * bp, COUNT FAR * err, /* /// End of additions for SHARE - Ron Cemer */ ReadCount = readblock(s->sft_status, bp, n, &rc); - if (rc != SUCCESS) - { - *err = rc; - return 0; - } - else - { - *err = SUCCESS; - return ReadCount; - } + *err = rc; + return (rc == SUCCESS ? ReadCount : 0); } *err = SUCCESS; return 0; @@ -470,13 +477,12 @@ UCOUNT DosRead(COUNT hndl, UCOUNT n, BYTE FAR * bp, COUNT FAR * err) } #endif -UCOUNT DosWrite(COUNT hndl, UCOUNT n, BYTE FAR * bp, COUNT FAR * err) +UCOUNT DosWriteSft(sft FAR *s, UCOUNT n, BYTE FAR * bp, COUNT FAR * err) { - sft FAR *s; UCOUNT WriteCount; /* Get the SFT block that contains the SFT */ - if ((s = get_sft(hndl)) == (sft FAR *) - 1) + if (s == (sft FAR *) - 1) { *err = DE_INVLDHNDL; return 0; @@ -493,8 +499,17 @@ UCOUNT DosWrite(COUNT hndl, UCOUNT n, BYTE FAR * bp, COUNT FAR * err) if (s->sft_flags & SFT_FSHARED) { - WriteCount = Remote_RW(REM_WRITE, n, bp, s, err); - return *err == SUCCESS ? WriteCount : 0; + COUNT rc; + BYTE FAR *save_dta; + + save_dta = dta; + lpCurSft = s; + current_filepos = s->sft_posit; /* needed for MSCDEX */ + dta = bp; + WriteCount = remote_write(s, n, &rc); + dta = save_dta; + *err = rc; + return rc == SUCCESS ? WriteCount : 0; } /* Do a device write if device */ @@ -621,6 +636,7 @@ UCOUNT DosWrite(COUNT hndl, UCOUNT n, BYTE FAR * bp, COUNT FAR * err) /* /// End of additions for SHARE - Ron Cemer */ WriteCount = writeblock(s->sft_status, bp, n, &rc); + s->sft_size = dos_getcufsize(s->sft_status); /* if (rc < SUCCESS) */ if (rc == DE_ACCESS || /* -5 Access denied */ rc == DE_INVLDHNDL ) /* -6 Invalid handle */ @@ -640,13 +656,11 @@ UCOUNT DosWrite(COUNT hndl, UCOUNT n, BYTE FAR * bp, COUNT FAR * err) COUNT SftSeek(sft FAR *s, LONG new_pos, COUNT mode) { - ULONG data; - /* Test for invalid mode */ if (mode < 0 || mode > 2) return DE_INVLDFUNC; - lpCurSft = (sfttbl FAR *) s; + lpCurSft = s; if (s->sft_flags & SFT_FSHARED) { @@ -664,8 +678,7 @@ COUNT SftSeek(sft FAR *s, LONG new_pos, COUNT mode) */ if ((s->sft_mode & SFT_MDENYREAD) || (s->sft_mode & SFT_MDENYNONE)) { - int2f_Remote_call(REM_LSEEK, 0, (UWORD) FP_SEG(new_pos), (UWORD) FP_OFF(new_pos), (VOID FAR *) s, 0, (VOID FAR *)&data); - s->sft_posit = data; + s->sft_posit = remote_lseek(s, new_pos); return SUCCESS; } else @@ -743,11 +756,18 @@ sft FAR *get_free_sft(COUNT *sft_idx) REG COUNT i = sp->sftt_count; sft FAR *sfti = sp->sftt_table; - for(sys_idx += i; i >= 1 ; sfti++, i--) + for(; --i >= 0 ; sys_idx++, sfti++) { if (sfti->sft_count == 0) { - *sft_idx = sys_idx - i; + *sft_idx = sys_idx; + + /* MS NET uses this on open/creat TE*/ + { + extern WORD current_sft_idx; + current_sft_idx = sys_idx; + } + return sfti; } } @@ -801,7 +821,8 @@ COUNT DosCreatSft(BYTE * fname, COUNT attrib) COUNT drive; /* NEVER EVER allow directories to be created */ - if (attrib & 0xff & ~(D_RDONLY|D_HIDDEN|D_SYSTEM|D_ARCHIVE)) + attrib &= 0xff; + if (attrib & ~(D_RDONLY|D_HIDDEN|D_SYSTEM|D_ARCHIVE)) { return DE_ACCESS; } @@ -815,7 +836,7 @@ COUNT DosCreatSft(BYTE * fname, COUNT attrib) sftp->sft_shroff = -1; /* /// Added for SHARE - Ron Cemer */ sftp->sft_psp = cu_psp; sftp->sft_mode = SFT_MRDWR; - sftp->sft_attrib = attrib & 0xff; + sftp->sft_attrib = attrib; sftp->sft_psp = cu_psp; /* check for a device */ @@ -831,9 +852,8 @@ COUNT DosCreatSft(BYTE * fname, COUNT attrib) } if (current_ldt->cdsFlags & CDSNETWDRV) { - lpCurSft = (sfttbl FAR *)sftp; - sftp->sft_mode = attrib; - result = -int2f_Remote_call(REM_CREATE, 0, 0, 0, (VOID FAR *) sftp, 0, MK_FP(0, attrib)); + lpCurSft = sftp; + result = remote_creat(sftp, attrib); if (result == SUCCESS) { sftp->sft_count += 1; return sft_idx; @@ -1019,8 +1039,9 @@ COUNT DosOpenSft(BYTE * fname, COUNT mode) } if (current_ldt->cdsFlags & CDSNETWDRV) { - lpCurSft = (sfttbl FAR *)sftp; - result = -int2f_Remote_call(REM_OPEN, 0, 0, 0, (VOID FAR *) sftp, 0, MK_FP(0, mode)); + lpCurSft = sftp; + result = remote_open(sftp, mode); + /* printf("open SFT %d = %p\n",sft_idx,sftp); */ if (result == SUCCESS) { sftp->sft_count += 1; return sft_idx; @@ -1058,6 +1079,7 @@ COUNT DosOpenSft(BYTE * fname, COUNT mode) if ((sftp->sft_attrib & (D_DIR | D_VOLID)) || ((sftp->sft_attrib & D_RDONLY) && (mode != O_RDONLY))) { + dos_close(sftp->sft_status); return DE_ACCESS; } @@ -1106,40 +1128,43 @@ COUNT DosOpen(BYTE FAR * fname, COUNT mode) COUNT DosCloseSft(WORD sft_idx) { - sft FAR *s = idx_to_sft(sft_idx); + sft FAR *sftp = idx_to_sft(sft_idx); - if (s == (sft FAR *) - 1) + if (sftp == (sft FAR *) - 1) return DE_INVLDHNDL; /* If this is not opened another error */ /* The second condition is a sanity check and necessary for FcbCloseAll */ - if (s->sft_count == 0 || (s->sft_count == 1 && s->sft_psp != cu_psp)) + if (sftp->sft_count == 0 || (sftp->sft_count == 1 && sftp->sft_psp != cu_psp)) return DE_ACCESS; - lpCurSft = (sfttbl FAR *) s; + lpCurSft = sftp; /* remote sub sft_count. */ - if (s->sft_flags & SFT_FSHARED) - return -int2f_Remote_call(REM_CLOSE, 0, 0, 0, (VOID FAR *) s, 0, 0); + if (sftp->sft_flags & SFT_FSHARED) + { + /* printf("closing SFT %d = %p\n",sft_idx,sftp); */ + return remote_close(sftp); + } /* now just drop the count if a device, else */ /* call file system handler */ - s->sft_count -= 1; - if (s->sft_flags & SFT_FDEVICE) + sftp->sft_count -= 1; + if (sftp->sft_flags & SFT_FDEVICE) return SUCCESS; else { - if (s->sft_count > 0) + if (sftp->sft_count > 0) return SUCCESS; else { /* /// Added for SHARE *** CURLY BRACES ADDED ALSO!!! ***. - Ron Cemer */ if (IsShareInstalled()) { - if (s->sft_shroff >= 0) share_close_file(s->sft_shroff); - s->sft_shroff = -1; + if (sftp->sft_shroff >= 0) share_close_file(sftp->sft_shroff); + sftp->sft_shroff = -1; } /* /// End of additions for SHARE. - Ron Cemer */ - return dos_close(s->sft_status); + return dos_close(sftp->sft_status); } } } @@ -1161,10 +1186,6 @@ VOID DosGetFree(UBYTE drive, COUNT FAR * spc, COUNT FAR * navc, COUNT FAR * bps, struct dpb FAR *dpbp; struct cds FAR *cdsp; COUNT rg[4]; -#ifdef WITHFAT32 - UCOUNT shift = 0; - ULONG cluster_size, ntotal, nfree; -#endif /* next - "log" in the drive */ drive = (drive == 0 ? default_drive : drive - 1); @@ -1181,7 +1202,7 @@ VOID DosGetFree(UBYTE drive, COUNT FAR * spc, COUNT FAR * navc, COUNT FAR * bps, if (cdsp->cdsFlags & CDSNETWDRV) { - int2f_Remote_call(REM_GETSPACE, 0, 0, 0, cdsp, 0, &rg); + remote_getfree(cdsp, rg); *spc = (COUNT) rg[0]; *nc = (COUNT) rg[1]; @@ -1193,27 +1214,6 @@ VOID DosGetFree(UBYTE drive, COUNT FAR * spc, COUNT FAR * navc, COUNT FAR * bps, dpbp = CDSp->cds_table[drive].cdsDpb; if (dpbp == NULL || media_check(dpbp) < 0) return; -#ifdef WITHFAT32 - cluster_size = (dpbp->dpb_clsmask + 1) * dpbp->dpb_secsize; - ntotal = dpbp->dpb_size - 1; - if (ISFAT32(dpbp)) while (cluster_size <= 0x7fff) { - cluster_size <<= 1; - ntotal >>= 1; - shift++; - } - /* get the data available from dpb */ - *nc = (UCOUNT)ntotal; - if (ntotal > 0xfffe) - *nc = 0xfffe; - *spc = (dpbp->dpb_clsmask + 1) << shift; - *bps = dpbp->dpb_secsize; - - /* now tell fs to give us free cluster */ - /* count */ - nfree = dos_free(dpbp) >> shift; - if (nfree > 0xfffe) nfree = 0xfffe; - *navc = (UCOUNT)nfree; -#else /* get the data available from dpb */ *nc = dpbp->dpb_size - 1; *spc = dpbp->dpb_clsmask + 1; @@ -1221,8 +1221,32 @@ VOID DosGetFree(UBYTE drive, COUNT FAR * spc, COUNT FAR * navc, COUNT FAR * bps, /* now tell fs to give us free cluster */ /* count */ - *navc = dos_free(dpbp); +#ifdef WITHFAT32 + if (ISFAT32(dpbp)) + { + ULONG cluster_size, ntotal, nfree; + + /* we shift ntotal until it is equal to or below 0xfff6 */ + cluster_size = (ULONG)dpbp->dpb_secsize << dpbp->dpb_shftcnt; + ntotal = dpbp->dpb_xsize - 1; + nfree = dos_free(dpbp); + while (ntotal > FAT_MAGIC16 && cluster_size < 0x8000) + { + cluster_size <<= 1; + *spc <<= 1; + ntotal >>= 1; + nfree >>= 1; + } + /* get the data available from dpb */ + *nc = ntotal > FAT_MAGIC16 ? FAT_MAGIC16 : (UCOUNT)ntotal; + + /* now tell fs to give us free cluster */ + /* count */ + *navc = nfree > FAT_MAGIC16 ? FAT_MAGIC16 : (UCOUNT)nfree; + return; + } #endif + *navc = (COUNT)dos_free(dpbp); } #ifdef WITHFAT32 @@ -1248,7 +1272,7 @@ COUNT DosGetExtFree(BYTE FAR *DriveString, struct xfreespace FAR *xfsp) if (cdsp->cdsFlags & CDSNETWDRV) { - int2f_Remote_call(REM_GETSPACE, 0, 0, 0, cdsp, 0, &rg); + remote_getfree(cdsp, rg); xfsp->xfs_clussize = rg[0]; xfsp->xfs_totalclusters = rg[1]; @@ -1259,7 +1283,7 @@ COUNT DosGetExtFree(BYTE FAR *DriveString, struct xfreespace FAR *xfsp) if (dpbp == NULL || media_check(dpbp) < 0) return DE_INVLDDRV; xfsp->xfs_secsize = dpbp->dpb_secsize; - xfsp->xfs_totalclusters = dpbp->dpb_size; + xfsp->xfs_totalclusters = (ISFAT32(dpbp) ? dpbp->dpb_xsize : dpbp->dpb_size); xfsp->xfs_freeclusters = dos_free(dpbp); xfsp->xfs_clussize = dpbp->dpb_clsmask + 1; } @@ -1301,7 +1325,6 @@ COUNT DosGetCuDir(UBYTE drive, BYTE FAR * s) #undef CHDIR_DEBUG COUNT DosChangeDir(BYTE FAR * s) { - REG struct cds FAR *cdsp; REG COUNT drive; COUNT result; BYTE FAR *p; @@ -1319,51 +1342,38 @@ COUNT DosChangeDir(BYTE FAR * s) } result = truename(s, PriPathName, FALSE); - if (result != SUCCESS) { - return result; + if (result != SUCCESS) { + return result; } - cdsp = &CDSp->cds_table[drive]; - current_ldt = cdsp; + current_ldt = &CDSp->cds_table[drive]; - if (strlen(PriPathName) > sizeof(cdsp->cdsCurrentPath)-1) + if (strlen(PriPathName) > sizeof(current_ldt->cdsCurrentPath)-1) return DE_PATHNOTFND; - if (cdsp->cdsFlags & CDSNETWDRV) - { #if defined(CHDIR_DEBUG) - printf("Remote Chdir: n='"); - p = s; while(*p) printf("%c", *p++); - printf("' p='"); - p = PriPathName; while(*p) printf("%c", *p++); - printf("'\n"); + printf("Remote Chdir: n='%Fs' p='%Fs\n",s,PriPathName); #endif - result = -int2f_Remote_call(REM_CHDIR, 0, 0, 0, PriPathName, 0, 0); + /* now get fs to change to new */ + /* directory */ + result = (current_ldt->cdsFlags & CDSNETWDRV) ? remote_chdir() : + dos_cd(current_ldt, PriPathName); #if defined(CHDIR_DEBUG) - printf("status = %04x, new_path='", result); - p = cdsd->cdsCurrentPath; while(p) printf("%c", *p++) - printf("'\n"); + printf("status = %04x, new_path='%Fs'\n", result, cdsd->cdsCurrentPath); #endif - if (result != SUCCESS) { - return DE_PATHNOTFND; - } + if (result != SUCCESS) + return result; /* + Copy the path to the current directory + structure. + Some redirectors do not write back to the CDS. SHSUCdX needs this. jt */ - fstrncpy(cdsp->cdsCurrentPath,&PriPathName[0],sizeof(cdsp->cdsCurrentPath)-1); - if (PriPathName[7] == 0) - cdsp->cdsCurrentPath[8] = 0; /* Need two Zeros at the end */ - - } else { - /* now get fs to change to new */ - /* directory */ - result = dos_cd(cdsp, PriPathName); - } - if (result == SUCCESS) { - fstrncpy(cdsp->cdsCurrentPath,&PriPathName[0],sizeof(cdsp->cdsCurrentPath)-1); - } - return result; + fstrcpy(current_ldt->cdsCurrentPath,PriPathName); + if (PriPathName[7] == 0) + current_ldt->cdsCurrentPath[8] = 0; /* Need two Zeros at the end */ + return SUCCESS; } STATIC VOID pop_dmp(dmatch FAR * dmp) @@ -1431,7 +1441,7 @@ COUNT DosFindFirst(UCOUNT attr, BYTE FAR * name) dta = (BYTE FAR *)TempBuffer; rc = current_ldt->cdsFlags & CDSNETWDRV ? - -int2f_Remote_call(REM_FINDFIRST, 0, 0, 0, (VOID FAR *)current_ldt, 0, 0) : + remote_findfirst((VOID FAR *)current_ldt) : dos_findfirst(attr, PriPathName); dta = p; @@ -1477,7 +1487,7 @@ COUNT DosFindNext(void) p = dta; dta = (BYTE FAR *)TempBuffer; rc = (((dmatch *)TempBuffer)->dm_drive & 0x80) ? - -int2f_Remote_call(REM_FINDNEXT, 0, 0, 0, (VOID FAR *)current_ldt, 0, 0) : + remote_findnext((VOID FAR *)current_ldt) : dos_findnext(); dta = p; @@ -1540,9 +1550,7 @@ COUNT DosSetFtimeSft(WORD sft_idx, date dp, time tp) COUNT DosGetFattr(BYTE FAR * name) { - UWORD srfa[5]; COUNT result, drive; - struct cds FAR *last_cds; if (IsDevice(name)) { return DE_FILENOTFND; @@ -1567,13 +1575,10 @@ COUNT DosGetFattr(BYTE FAR * name) return 0x10; } - if (CDSp->cds_table[drive].cdsFlags & CDSNETWDRV) + current_ldt = &CDSp->cds_table[drive]; + if (current_ldt->cdsFlags & CDSNETWDRV) { - last_cds = current_ldt; - current_ldt = &CDSp->cds_table[drive]; - result = -int2f_Remote_call(REM_GETATTRZ, 0, 0, 0, 0, 0, (VOID FAR *) srfa); - current_ldt = last_cds; - return (result < SUCCESS ? result : srfa[0]); + return remote_getfattr(); } else { /* /// Use truename()'s result, which we already have in PriPathName. @@ -1612,7 +1617,6 @@ COUNT DosGetFattr(BYTE FAR * name) COUNT DosSetFattr(BYTE FAR * name, UWORD attrp) { COUNT result, drive; - struct cds FAR *last_cds; if (IsDevice(name) ) { return DE_FILENOTFND; @@ -1628,13 +1632,10 @@ COUNT DosSetFattr(BYTE FAR * name, UWORD attrp) return result; } - if (CDSp->cds_table[drive].cdsFlags & CDSNETWDRV) + current_ldt = &CDSp->cds_table[drive]; + if (current_ldt->cdsFlags & CDSNETWDRV) { - last_cds = current_ldt; - current_ldt = &CDSp->cds_table[drive]; - result = -int2f_Remote_call(REM_SETATTR, 0, 0, 0, 0, 0, MK_FP(0, attrp)); - current_ldt = last_cds; - return result; + return remote_setfattr(attrp); } else { /* /// Use truename()'s result, which we already have in PriPathName. @@ -1655,18 +1656,16 @@ COUNT DosSetFattr(BYTE FAR * name, UWORD attrp) UBYTE DosSelectDrv(UBYTE drv) { - struct cds FAR *cdsp = &CDSp->cds_table[drv]; + current_ldt = &CDSp->cds_table[drv]; - if ((drv < lastdrive) && (cdsp->cdsFlags & CDSVALID)) + if ((drv < lastdrive) && (current_ldt->cdsFlags & CDSVALID)) /* && ((cdsp->cdsFlags & CDSNETWDRV) || (cdsp->cdsDpb!=NULL && media_check(cdsp->cdsDpb)==SUCCESS))) */ - { - current_ldt = cdsp; default_drive = drv; - } + return lastdrive; } @@ -1687,8 +1686,8 @@ COUNT DosDelete(BYTE FAR *path) return result; } current_ldt = &CDSp->cds_table[drive]; - if (CDSp->cds_table[drive].cdsFlags & CDSNETWDRV) { - return -int2f_Remote_call(REM_DELETE, 0, 0, 0, 0, 0, 0); + if (current_ldt->cdsFlags & CDSNETWDRV) { + return remote_delete(); } else { return dos_delete(PriPathName); } @@ -1708,8 +1707,8 @@ COUNT DosRenameTrue(BYTE * path1, BYTE * path2) return DE_INVLDDRV; } current_ldt = &CDSp->cds_table[drive1]; - if (CDSp->cds_table[drive1].cdsFlags & CDSNETWDRV) { - return -int2f_Remote_call(REM_RENAME, 0, 0, 0, 0, 0, 0); + if (current_ldt->cdsFlags & CDSNETWDRV) { + return remote_rename(); } else { return dos_rename(PriPathName, SecPathName); } @@ -1749,8 +1748,8 @@ COUNT DosMkdir(BYTE FAR * dir) return result; } current_ldt = &CDSp->cds_table[drive]; - if (CDSp->cds_table[drive].cdsFlags & CDSNETWDRV) { - return -int2f_Remote_call(REM_MKDIR, 0, 0, 0, 0, 0, 0); + if (current_ldt->cdsFlags & CDSNETWDRV) { + return remote_mkdir(); } else { return dos_mkdir(PriPathName); } @@ -1774,7 +1773,7 @@ COUNT DosRmdir(BYTE FAR * dir) } current_ldt = &CDSp->cds_table[drive]; if (CDSp->cds_table[drive].cdsFlags & CDSNETWDRV) { - return -int2f_Remote_call(REM_RMDIR, 0, 0, 0, 0, 0, 0); + return remote_rmdir(); } else { return dos_rmdir(PriPathName); } diff --git a/kernel/dosnames.c b/kernel/dosnames.c index b5132047..e5d21955 100644 --- a/kernel/dosnames.c +++ b/kernel/dosnames.c @@ -36,6 +36,9 @@ static BYTE *dosnamesRcsId = "$Id$"; /* * $Log$ + * Revision 1.12 2001/11/04 19:47:39 bartoldeman + * kernel 2025a changes: see history.txt + * * Revision 1.11 2001/07/24 16:56:29 bartoldeman * fixes for FCBs, DJGPP ls, DBLBYTE, dyninit allocation (2024e). * @@ -139,6 +142,7 @@ VOID XlateLcase(BYTE * szFname, COUNT nChars); VOID DosTrimPath(BYTE * lpszPathNamep); /* Should be converted to a portable version after v1.0 is released. */ +#if 0 VOID XlateLcase(BYTE * szFname, COUNT nChars) { while (nChars--) @@ -148,6 +152,7 @@ VOID XlateLcase(BYTE * szFname, COUNT nChars) ++szFname; } } +#endif VOID SpacePad(BYTE * szString, COUNT nChars) { @@ -156,12 +161,14 @@ VOID SpacePad(BYTE * szString, COUNT nChars) for (i = strlen(szString); i < nChars; i++) szString[i] = ' '; } + /* MSD durring an FindFirst search string looks like this; (*), & (.) == Current directory *.* (\) == Root directory *.* (..) == Back one directory *.* + This always has a "truename" as input, so we may do some shortcuts */ COUNT ParseDosName(BYTE * lpszFileName, COUNT * pnDrive, @@ -187,26 +194,11 @@ COUNT ParseDosName(BYTE * lpszFileName, lpszLclFile = lpszLclExt = lpszLclDir = 0; nDirCnt = nFileCnt = nExtCnt = 0; - /* Start by cheking for a drive specifier ... */ - if (DriveChar(*lpszFileName) && ':' == lpszFileName[1]) - { - /* found a drive, fetch it and bump pointer past drive */ - /* NB: this code assumes ASCII */ - if (pnDrive) - { - *pnDrive = *lpszFileName - 'A'; - if (*pnDrive > 26) - *pnDrive -= ('a' - 'A'); - } - lpszFileName += 2; - } - else - { - if (pnDrive) - { - *pnDrive = -1; - } - } + /* found a drive, fetch it and bump pointer past drive */ + /* NB: this code assumes ASCII */ + if (pnDrive) + *pnDrive = *lpszFileName - 'A'; + lpszFileName += 2; if (!pszDir && !pszFile && !pszExt) return SUCCESS; @@ -214,11 +206,15 @@ COUNT ParseDosName(BYTE * lpszFileName, lpszLclDir = lpszLclFile = lpszFileName; while (DirChar(*lpszFileName)) { - if (PathSep(*lpszFileName)) + if (*lpszFileName == '\\') lpszLclFile = lpszFileName + 1; ++lpszFileName; } nDirCnt = FP_OFF(lpszLclFile) - FP_OFF(lpszLclDir); + /* Fix lengths to maximums allowed by MS-DOS. */ + if (nDirCnt > PARSE_MAX-1) + nDirCnt = PARSE_MAX-1; + /* Parse out the file name portion. */ lpszFileName = lpszLclFile; while (bAllowWildcards ? WildChar(*lpszFileName) : NameChar(*lpszFileName)) @@ -231,36 +227,19 @@ COUNT ParseDosName(BYTE * lpszFileName, /* Lixing Yuan Patch */ if (bAllowWildcards) /* for find first */ { - if (*lpszFileName == '.') - lpszFileName++; - if (*lpszFileName == '.') - lpszFileName++; if (*lpszFileName != '\0') return DE_FILENOTFND; if (nDirCnt == 1) /* for d:\ */ return DE_NFILES; if (pszDir) { - if ((lpszFileName - lpszLclFile) == 2) /* for tail DotDot */ - nDirCnt += 2; - if (nDirCnt > PARSE_MAX-1) - nDirCnt = PARSE_MAX-1; - bcopy(lpszLclDir, pszDir, nDirCnt); - if (((lpszFileName - lpszLclFile) == 2) && (nDirCnt < PARSE_MAX)) - pszDir[nDirCnt++] = '\\'; /* make DosTrimPath() enjoy, for tail DotDot */ + memcpy(pszDir, lpszLclDir, nDirCnt); pszDir[nDirCnt] = '\0'; - DosTrimPath(pszDir); } if (pszFile) - { - *pszFile++ = '*'; - *pszFile = '\0'; - } + memcpy(pszFile, "????????", FNAME_SIZE+1); if (pszExt) - { - *pszExt++ = '*'; - *pszExt = '\0'; - } + memcpy(pszExt, "???", FEXT_SIZE+1); return SUCCESS; } else @@ -288,36 +267,25 @@ COUNT ParseDosName(BYTE * lpszFileName, else if (*lpszFileName) return DE_FILENOTFND; - /* Fix lengths to maximums allowed by MS-DOS. */ - if (nDirCnt > PARSE_MAX-1) - nDirCnt = PARSE_MAX-1; - if (nFileCnt > FNAME_SIZE) - nFileCnt = FNAME_SIZE; - if (nExtCnt > FEXT_SIZE) - nExtCnt = FEXT_SIZE; - /* Finally copy whatever the user wants extracted to the user's */ /* buffers. */ if (pszDir) { - bcopy(lpszLclDir, pszDir, nDirCnt); + memcpy(pszDir, lpszLclDir, nDirCnt); pszDir[nDirCnt] = '\0'; } if (pszFile) { - bcopy(lpszLclFile, pszFile, nFileCnt); + memcpy(pszFile, lpszLclFile, nFileCnt); pszFile[nFileCnt] = '\0'; } if (pszExt) { - bcopy(lpszLclExt, pszExt, nExtCnt); + memcpy(pszExt, lpszLclExt, nExtCnt); pszExt[nExtCnt] = '\0'; } /* Clean up before leaving */ - if (pszDir) - DosTrimPath(pszDir); - return SUCCESS; } @@ -412,7 +380,6 @@ COUNT ParseDosPath(BYTE * lpszFileName, return SUCCESS; } -#endif VOID DosTrimPath(BYTE * lpszPathNamep) { @@ -526,4 +493,5 @@ VOID DosTrimPath(BYTE * lpszPathNamep) ++lpszNext; } } +#endif diff --git a/kernel/dsk.c b/kernel/dsk.c index 1e6d8ef7..43a39962 100644 --- a/kernel/dsk.c +++ b/kernel/dsk.c @@ -34,6 +34,9 @@ static BYTE *dskRcsId = "$Id$"; /* * $Log$ + * Revision 1.21 2001/11/04 19:47:39 bartoldeman + * kernel 2025a changes: see history.txt + * * Revision 1.20 2001/09/23 20:39:44 bartoldeman * FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling * @@ -173,9 +176,12 @@ COUNT ASMCFUNC fl_readdasd(WORD); COUNT ASMCFUNC fl_diskchanged(WORD); COUNT ASMCFUNC fl_rd_status(WORD); -COUNT ASMCFUNC fl_read(WORD, WORD, WORD, WORD, WORD, BYTE FAR *); -COUNT ASMCFUNC fl_write(WORD, WORD, WORD, WORD, WORD, BYTE FAR *); -COUNT ASMCFUNC fl_verify(WORD, WORD, WORD, WORD, WORD, BYTE FAR *); +COUNT ASMCFUNC fl_format(WORD, WORD, WORD, WORD, WORD, UBYTE FAR *); +COUNT ASMCFUNC fl_read(WORD, WORD, WORD, WORD, WORD, UBYTE FAR *); +COUNT ASMCFUNC fl_write(WORD, WORD, WORD, WORD, WORD, UBYTE FAR *); +COUNT ASMCFUNC fl_verify(WORD, WORD, WORD, WORD, WORD, UBYTE FAR *); +COUNT ASMCFUNC fl_setdisktype(WORD, WORD); +COUNT ASMCFUNC fl_setmediatype(WORD, WORD, WORD); VOID ASMCFUNC fl_readkey(VOID); extern COUNT ASMCFUNC fl_lba_ReadWrite (BYTE drive, WORD mode, @@ -188,13 +194,16 @@ BOOL fl_reset(); COUNT fl_readdasd(); COUNT fl_diskchanged(); COUNT fl_rd_status(); +COUNT fl_format(); COUNT fl_read(); COUNT fl_write(); COUNT fl_verify(); VOID fl_readkey(); +COUNT fl_setmediatype(); +COUNT fl_setdisktype(); #endif -#define NENTRY 26 /* total size of dispatch table */ +#define NENTRY 26 /* total size of dispatch table */ extern BYTE FAR nblk_rel; @@ -206,6 +215,8 @@ extern int FAR ASMCFUNC Get_nblk_rel(void); #define LBA_WRITE 0x4300 UWORD LBA_WRITE_VERIFY = 0x4302; #define LBA_VERIFY 0x4400 +#define LBA_FORMAT 0xffff /* fake number for FORMAT track + (only for NON-LBA floppies now!) */ /* this buffer must not overlap a 64K boundary due to DMA transfers @@ -405,12 +416,17 @@ STATIC WORD diskchange(ddt *pddt) WORD mediachk(rqptr rp, ddt *pddt) { /* check floppy status */ - if (pddt->ddt_descflags & DF_DISKCHANGE) + if (pddt->ddt_descflags & DF_REFORMAT) + { + pddt->ddt_descflags &= ~DF_REFORMAT; + rp->r_mcretcode = M_CHANGED; + } + else if (pddt->ddt_descflags & DF_DISKCHANGE) { pddt->ddt_descflags &= ~DF_DISKCHANGE; rp->r_mcretcode = M_DONT_KNOW; } - else + else { rp->r_mcretcode = diskchange(pddt); } @@ -574,6 +590,7 @@ static getbpb(ddt *pddt) return failure(E_FAILURE); } pddt->ddt_ncyl = (count + head * sector - 1) / (head * sector); + tmark(); #ifdef DSK_DEBUG @@ -617,10 +634,23 @@ static WORD IoctlQueblk(rqptr rp, ddt *pddt) } +COUNT Genblockio(ddt *pddt, UWORD mode, WORD head, WORD track, WORD sector, + WORD count, VOID FAR *buffer) +{ + UWORD transferred; + + /* apparently sector is ZERO, not ONE based !!! */ + return LBA_Transfer(pddt, mode, buffer, + ((ULONG)track * pddt->ddt_bpb.bpb_nheads + head) * + (ULONG)pddt->ddt_bpb.bpb_nsecs + + pddt->ddt_offset + sector, + count, &transferred); +} + STATIC WORD Genblkdev(rqptr rp,ddt *pddt) { int ret; - bpb FAR *pbpb; + bpb *pbpb; #ifdef WITHFAT32 int extended = 0; @@ -631,60 +661,143 @@ STATIC WORD Genblkdev(rqptr rp,ddt *pddt) return failure(E_CMD); switch(rp->r_count & 0xff){ - case 0x60: /* get device parameters */ + case 0x40: /* set device parameters */ { struct gblkio FAR * gblp = (struct gblkio FAR *) rp->r_trans; - REG COUNT x = 5,y = 1,z = 0; - - if (!hd(pddt->ddt_descflags)){ - y = 2; - x = 8; /* any odd ball drives return this */ - switch(pddt->ddt_bpb.bpb_nsize) - { - case 640: - case 720: /* 320-360 */ - x = 0; - z = 1; - break; - case 1440: /* 720 */ - x = 2; - break; - case 2400: /* 1.2 */ - x = 1; - break; - case 2880: /* 1.44 */ - x = 7; - break; - case 5760: /* 2.88 almost forgot this one*/ - x = 9; - break; - } - } - gblp->gbio_devtype = (UBYTE) x; - gblp->gbio_devattrib = (UWORD) y; - gblp->gbio_media = (UBYTE) z; - gblp->gbio_ncyl = pddt->ddt_ncyl; + + pddt->ddt_type = gblp->gbio_devtype; + pddt->ddt_descflags &= ~3; + pddt->ddt_descflags |= (gblp->gbio_devattrib & 3) + | (DF_DPCHANGED | DF_REFORMAT); + pddt->ddt_ncyl = gblp->gbio_ncyl; /* use default dpb or current bpb? */ pbpb = (gblp->gbio_spcfunbit & 0x01) == 0 ? &pddt->ddt_defbpb : &pddt->ddt_bpb; #ifdef WITHFAT32 - if (!extended) fmemcpy(&gblp->gbio_bpb, pbpb, BPB_SIZEOF); + if (!extended) fmemcpy(pbpb, &gblp->gbio_bpb, BPB_SIZEOF); else #endif - fmemcpy(&gblp->gbio_bpb, pbpb, sizeof(gblp->gbio_bpb)); - gblp->gbio_nsecs = pbpb->bpb_nsector; + fmemcpy(pbpb, &gblp->gbio_bpb, sizeof(gblp->gbio_bpb)); + /*pbpb->bpb_nsector = gblp->gbio_nsecs;*/ break; } - case 0x66: /* get volume serial number */ + case 0x41: /* write track */ { - struct Gioc_media FAR * gioc = (struct Gioc_media FAR *) rp->r_trans; + struct gblkrw FAR * rw = (struct gblkrw FAR *) rp->r_trans; + ret = Genblockio(pddt, LBA_WRITE, rw->gbrw_head, rw->gbrw_cyl, + rw->gbrw_sector, rw->gbrw_nsecs, rw->gbrw_buffer); + if (ret != 0) + return dskerr(ret); + } + break; + case 0x42: /* format/verify track */ + { + struct gblkfv FAR * fv = (struct gblkfv FAR *) rp->r_trans; + COUNT tracks; + struct thst {UBYTE track, head, sector, type;} *addrfield, afentry; - ret = getbpb(pddt); - if (ret != 0) - return (ret); + if (hd(pddt->ddt_descflags)) + { + /* XXX no low-level formatting for hard disks implemented */ + fv->gbfv_spcfunbit = 1; /* "not supported by bios" */ + pddt->ddt_descflags &= ~DF_DPCHANGED; + return S_DONE; + } + if (pddt->ddt_descflags & DF_DPCHANGED) + { + pddt->ddt_descflags &= ~DF_DPCHANGED; - gioc->ioc_serialno = pddt->ddt_serialno; - fmemcpy(gioc->ioc_volume, pddt->ddt_volume,11); - fmemcpy(gioc->ioc_fstype, pddt->ddt_fstype,8); + /* first try newer setmediatype function */ + ret = fl_setmediatype(pddt->ddt_driveno, pddt->ddt_ncyl, + pddt->ddt_bpb.bpb_nsecs); + if (ret == 0xc) + { + /* specified tracks, sectors/track not allowed for drive */ + fv->gbfv_spcfunbit = 2; + return dskerr(ret); + } + else if (ret == 0x80) { + fv->gbfv_spcfunbit = 3; /* no disk in drive */ + return dskerr(ret); + } + else if (ret != 0) + /* otherwise, setdisktype */ + { + COUNT type = 0; + if ((fv->gbfv_spcfunbit & 1) && + (ret = fl_read(pddt->ddt_driveno,0,0,1,1,DiskTransferBuffer)) != 0) + { + fv->gbfv_spcfunbit = 3; /* no disk in drive */ + return dskerr(ret); + } + if (pddt->ddt_ncyl == 40 && + (pddt->ddt_bpb.bpb_nsecs == 9 || pddt->ddt_bpb.bpb_nsecs == 8)) + { + if (pddt->ddt_type == 0) + type = 1; /* 320/360K disk in 360K drive */ + else if (pddt->ddt_type == 1) + type = 2; /* 320/360K disk in 1.2M drive */ + } + else if (pddt->ddt_type == 1 && pddt->ddt_ncyl == 80 && + pddt->ddt_bpb.bpb_nsecs == 15) + type = 3; /* 1.2M disk in 1.2M drive */ + else if ((pddt->ddt_type == 2 || pddt->ddt_type == 7) && + pddt->ddt_ncyl == 80 && pddt->ddt_bpb.bpb_nsecs == 15 + ) + type = 4; /* 720kb disk in 1.44M or 720kb drive */ + + if (type == 0) + { + /* specified tracks, sectors/track not allowed for drive */ + fv->gbfv_spcfunbit = 2; + return dskerr(0xc); + } + fl_setdisktype(pddt->ddt_driveno, type); + } + } + if (fv->gbfv_spcfunbit & 1) return S_DONE; + + afentry.type = 2; /* 512 byte sectors */ + afentry.track = fv->gbfv_cyl; + afentry.head = fv->gbfv_head; + + for (tracks = fv->gbfv_spcfunbit & 2 ? fv->gbfv_ntracks : 1; tracks > 0; + tracks--) + { + addrfield = (struct thst *)DiskTransferBuffer; + + if (afentry.track > pddt->ddt_ncyl) + return failure(E_FAILURE); + + for (afentry.sector = 1; afentry.sector <= pddt->ddt_bpb.bpb_nsecs; + afentry.sector++) + memcpy(addrfield++, &afentry, sizeof(afentry)); + + ret = Genblockio(pddt, LBA_FORMAT, afentry.head, afentry.track, 0, + pddt->ddt_bpb.bpb_nsecs, DiskTransferBuffer); + if (ret != 0) + return dskerr(ret); + } + afentry.head++; + if (afentry.head >= pddt->ddt_bpb.bpb_nheads) + { + afentry.head = 0; + afentry.track++; + } + } + + /* fall through to verify */ + + case 0x62: /* verify track */ + { + struct gblkfv FAR * fv = (struct gblkfv FAR *) rp->r_trans; + + ret = Genblockio(pddt, LBA_VERIFY, fv->gbfv_head, fv->gbfv_cyl, 0, + (fv->gbfv_spcfunbit ? + fv->gbfv_ntracks * pddt->ddt_defbpb.bpb_nsecs : + pddt->ddt_defbpb.bpb_nsecs), DiskTransferBuffer); + if (ret != 0) + return dskerr(ret); + fv->gbfv_spcfunbit = 0; /* success */ } break; case 0x46: /* set volume serial number */ @@ -706,17 +819,58 @@ STATIC WORD Genblkdev(rqptr rp,ddt *pddt) return (dskerr(ret)); } break; - case 0x67: /* get access flag */ + case 0x47: /* set access flag */ { struct Access_info FAR * ai = (struct Access_info FAR *) rp->r_trans; - ai->AI_Flag = pddt->ddt_descflags & DF_NOACCESS ? 0 : 1; /* bit 9 */ + pddt->ddt_descflags &= ~DF_NOACCESS; + pddt->ddt_descflags |= (ai->AI_Flag ? 0 : DF_NOACCESS); } break; - case 0x47: /* set access flag */ + case 0x60: /* get device parameters */ + { + struct gblkio FAR * gblp = (struct gblkio FAR *) rp->r_trans; + + gblp->gbio_devtype = pddt->ddt_type; + gblp->gbio_devattrib = pddt->ddt_descflags & 3; + /* 360 kb disk in 1.2 MB drive */ + gblp->gbio_media = (pddt->ddt_type == 1) && (pddt->ddt_ncyl == 40); + gblp->gbio_ncyl = pddt->ddt_ncyl; + /* use default dpb or current bpb? */ + pbpb = (gblp->gbio_spcfunbit & 0x01) == 0 ? &pddt->ddt_defbpb : &pddt->ddt_bpb; +#ifdef WITHFAT32 + if (!extended) fmemcpy(&gblp->gbio_bpb, pbpb, BPB_SIZEOF); + else +#endif + fmemcpy(&gblp->gbio_bpb, pbpb, sizeof(gblp->gbio_bpb)); + /*gblp->gbio_nsecs = pbpb->bpb_nsector;*/ + break; + } + case 0x61: /* read track */ + { + struct gblkrw FAR * rw = (struct gblkrw FAR *) rp->r_trans; + ret = Genblockio(pddt, LBA_READ, rw->gbrw_head, rw->gbrw_cyl, + rw->gbrw_sector, rw->gbrw_nsecs, rw->gbrw_buffer); + if (ret != 0) + return dskerr(ret); + } + break; + case 0x66: /* get volume serial number */ + { + struct Gioc_media FAR * gioc = (struct Gioc_media FAR *) rp->r_trans; + + ret = getbpb(pddt); + if (ret != 0) + return (ret); + + gioc->ioc_serialno = pddt->ddt_serialno; + fmemcpy(gioc->ioc_volume, pddt->ddt_volume,11); + fmemcpy(gioc->ioc_fstype, pddt->ddt_fstype,8); + } + break; + case 0x67: /* get access flag */ { struct Access_info FAR * ai = (struct Access_info FAR *) rp->r_trans; - pddt->ddt_descflags &= ~DF_NOACCESS; - pddt->ddt_descflags |= (ai->AI_Flag ? 0 : DF_NOACCESS); + ai->AI_Flag = pddt->ddt_descflags & DF_NOACCESS ? 0 : 1; /* bit 9 */ } break; default: @@ -859,7 +1013,7 @@ STATIC unsigned DMA_max_transfer(void FAR *buffer, unsigned count) /* int LBA_Transfer( ddt *pddt, physical characteristics of drive - UWORD mode, LBA_READ/WRITE/WRITE_VERIFY + UWORD mode, LBA_READ/WRITE/WRITE_VERIFY/VERIFY VOID FAR *buffer, user buffer ULONG LBA_address, absolute sector address unsigned totaltodo, number of sectors to transfer @@ -898,11 +1052,14 @@ int LBA_Transfer(ddt *pddt ,UWORD mode, VOID FAR *buffer, int num_retries; + /* only low-level format floppies for now ! */ + if (mode == LBA_FORMAT && hd(pddt->ddt_descflags)) + return 0; + /* optionally change from A: to B: or back */ play_dj(pddt); *transferred = 0; - /* if (LBA_address+totaltodo > pddt->total_sectors) { @@ -940,7 +1097,7 @@ int LBA_Transfer(ddt *pddt ,UWORD mode, VOID FAR *buffer, for ( num_retries = 0; num_retries < N_RETRY; num_retries++) { - if (pddt->ddt_LBASupported) + if (pddt->ddt_LBASupported && mode != LBA_FORMAT) { dap.number_of_blocks = count; @@ -985,7 +1142,9 @@ int LBA_Transfer(ddt *pddt ,UWORD mode, VOID FAR *buffer, return 1; } - error_code = (mode == LBA_READ ? fl_read : fl_write)( + error_code = (mode == LBA_READ ? fl_read : + mode == LBA_VERIFY ? fl_verify : + mode == LBA_FORMAT ? fl_format : fl_write)( pddt->ddt_driveno, chs.Head, (UWORD)chs.Cylinder, chs.Sector, count, transfer_address); diff --git a/kernel/entry.asm b/kernel/entry.asm index 30a8914d..e32fbe34 100644 --- a/kernel/entry.asm +++ b/kernel/entry.asm @@ -28,6 +28,9 @@ ; $Id$ ; ; $Log$ +; Revision 1.15 2001/11/04 19:47:39 bartoldeman +; kernel 2025a changes: see history.txt +; ; Revision 1.14 2001/09/23 20:39:44 bartoldeman ; FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling ; @@ -278,9 +281,12 @@ reloc_call_int21_handler: ; sti PUSH$ALL + mov bp,sp + + ProtectHighPartOfRegistersOn386 ; - ; Create kernel refernce frame. + ; Create kernel reference frame. ; ; NB: At this point, SS != DS and won't be set that way ; until later when which stack to run on is determined. @@ -300,7 +306,7 @@ int21_reentry: int21_user: call dos_crit_sect - mov bp,sp + push ss push bp call _int21_syscall @@ -319,7 +325,6 @@ int21_user: int21_1: mov si,ss ; save user stack, to be retored later - mov bx,sp ; @@ -329,8 +334,8 @@ int21_1: ; mov word [_lpUserStack+2],ss mov word [_user_r+2],ss - mov word [_lpUserStack],sp ; store and init - mov word [_user_r],sp ; store and init + mov word [_lpUserStack],bp ; store and init + mov word [_user_r],bp ; store and init ; ; Decide which stack to run on. @@ -363,7 +368,7 @@ int21_onerrorstack: sti push si ; user SS:SP - push bx + push bp call _int21_service jmp short int21_exit_nodec @@ -395,7 +400,7 @@ int21_normalentry: ; push si ; user SS:SP - push bx + push bp call _int21_service int21_exit: dec byte [_InDOS] @@ -407,14 +412,21 @@ int21_exit: dec byte [_InDOS] int21_exit_nodec: - pop bx ; get back user stack + pop bp ; get back user stack pop si +%IFDEF I386 + sub bp,8 +%endif + cli mov ss,si - mov sp,bx - sti -int21_ret: POP$ALL + mov sp,bp + +int21_ret: + RestoreHighPartOfRegistersOn386 + + POP$ALL ; ; ... and return. diff --git a/kernel/execrh.asm b/kernel/execrh.asm index 4754aef4..656d5853 100644 --- a/kernel/execrh.asm +++ b/kernel/execrh.asm @@ -30,6 +30,9 @@ ; $Id$ ; ; $Log$ +; Revision 1.8 2001/11/04 19:47:39 bartoldeman +; kernel 2025a changes: see history.txt +; ; Revision 1.7 2001/04/21 22:32:53 bartoldeman ; Init DS=Init CS, fixed stack overflow problems and misc bugs. ; @@ -105,33 +108,26 @@ segment HMA_TEXT _execrh: push bp ; perform c entry mov bp,sp -; push bx ; random char on display push si - push es ; sometimes it get lost push ds ; sp=bp-8 lds si,[bp+8] ; ds:si = device header les bx,[bp+4] ; es:bx = request header - push bp - push ds - push si ; needed later - mov ax, [si+6] + + mov ax, [si+6] ; construct strategy address mov [bp+8], ax - call far[bp+8] ; call far the strategy - pop si ; these were saved - pop ds - pop bp + + mov si, [si+8] ; save 'interrupt' address - mov ax, [si+8] - mov [bp+8], ax + call far[bp+8] ; call far the strategy + + mov [bp+8],si ; construct interrupt address call far[bp+8] ; call far the interrupt sti ; damm driver turn off ints cld ; has gone backwards pop ds - pop es pop si -; pop bx pop bp ret diff --git a/kernel/fatdir.c b/kernel/fatdir.c index 50b3c306..91e2a8a7 100644 --- a/kernel/fatdir.c +++ b/kernel/fatdir.c @@ -36,6 +36,9 @@ static BYTE *fatdirRcsId = "$Id$"; /* * $Log$ + * Revision 1.24 2001/11/04 19:47:39 bartoldeman + * kernel 2025a changes: see history.txt + * * Revision 1.23 2001/09/23 20:39:44 bartoldeman * FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling * @@ -193,6 +196,38 @@ static BYTE *fatdirRcsId = "$Id$"; * Initial revision. */ +/* Description. + * Initialize a fnode so that it will point to the directory with + * dirstart starting cluster; in case of passing dirstart == 0 + * fnode will point to the start of a root directory */ +VOID dir_init_fnode(f_node_ptr fnp, CLUSTER dirstart) +{ + /* reset the directory flags */ + fnp->f_flags.f_dmod = FALSE; + fnp->f_flags.f_droot = FALSE; + fnp->f_flags.f_ddir = TRUE; + fnp->f_flags.f_dnew = TRUE; + fnp->f_diroff = fnp->f_offset = fnp->f_cluster_offset = fnp->f_highwater = 0l; + + /* root directory */ + if (dirstart == 0) + { +#ifdef WITHFAT32 + if (ISFAT32(fnp->f_dpb)) + { + fnp->f_cluster = fnp->f_dirstart = fnp->f_dpb->dpb_xrootclst; + } + else +#endif + { + fnp->f_dirstart = 0l; + fnp->f_flags.f_droot = TRUE; + } + } + else /* non-root */ + fnp->f_cluster = fnp->f_dirstart = dirstart; +} + f_node_ptr dir_open(BYTE * dirname) { f_node_ptr fnp; @@ -269,31 +304,11 @@ f_node_ptr dir_open(BYTE * dirname) return (f_node_ptr)0; } - fnp->f_dsize = DIRENT_SIZE * fnp->f_dpb->dpb_dirents; - - fnp->f_diroff = 0l; - fnp->f_flags.f_dmod = FALSE; /* a brand new fnode */ - fnp->f_flags.f_dnew = TRUE; - fnp->f_flags.f_dremote = FALSE; - - fnp->f_dirstart = 0; - /* Walk the directory tree to find the starting cluster */ /* */ - /* Set the root flags since we always start from the root */ + /* Start from the root directory (dirstart = 0) */ - fnp->f_flags.f_droot = TRUE; -#ifdef WITHFAT32 - if (ISFAT32(fnp->f_dpb)) { - fnp->f_flags.f_droot = FALSE; - fnp->f_flags.f_ddir = TRUE; - fnp->f_offset = 0l; - fnp->f_cluster_offset = 0l; - fnp->f_highwater = 0l; - fnp->f_cluster = fnp->f_dpb->dpb_xrootclst; - fnp->f_dirstart = fnp->f_dpb->dpb_xrootclst; - } -#endif + dir_init_fnode(fnp, 0); for (p = pszPath; *p != '\0';) { @@ -336,7 +351,7 @@ f_node_ptr dir_open(BYTE * dirname) DosUpFMem((BYTE FAR *) TempBuffer, FNAME_SIZE + FEXT_SIZE); - while (dir_read(fnp) == DIRENT_SIZE) + while (dir_read(fnp) == 1) { if (fnp->f_dir.dir_name[0] != '\0' && fnp->f_dir.dir_name[0] != DELETED) { @@ -358,149 +373,122 @@ f_node_ptr dir_open(BYTE * dirname) { /* make certain we've moved off */ /* root */ - fnp->f_flags.f_droot = FALSE; - fnp->f_flags.f_ddir = TRUE; - /* set up for file read/write */ - fnp->f_offset = 0l; - fnp->f_cluster_offset = 0l; /*JPP */ - fnp->f_highwater = 0l; - fnp->f_cluster = getdstart(fnp->f_dir); - fnp->f_dirstart = fnp->f_cluster; - /* reset the directory flags */ - fnp->f_diroff = 0l; - fnp->f_flags.f_dmod = FALSE; - fnp->f_flags.f_dnew = TRUE; - fnp->f_dsize = DIRENT_SIZE * fnp->f_dpb->dpb_dirents; - + dir_init_fnode(fnp, getdstart(fnp->f_dir)); } } return fnp; } +/* Description. + * Read next consequitive directory entry, pointed by fnp. + * If some error occures the other critical + * fields aren't changed, except those used for caching. + * The fnp->f_diroff always corresponds to the directory entry + * which has been read. + * Return value. + * 1 - all OK, directory entry having been read is not empty. + * 0 - Directory entry is empty. + * DE_HNDLDSKFULL - Disk full + * DE_SEEK - Other error from map_cluster + * DE_TOOMANY - Too many files in root dir. + * DE_BLKINVLD - Invalid block + * Note. Empty directory entries always resides at the end of the directory. */ COUNT dir_read(REG f_node_ptr fnp) { -/* REG i; */ -/* REG j; */ - struct buffer FAR *bp; REG UWORD secsize = fnp->f_dpb->dpb_secsize; + ULONG new_diroff = fnp->f_diroff; /* Directories need to point to their current offset, not for */ /* next op. Therefore, if it is anything other than the first */ /* directory entry, we will update the offset on entry rather */ /* than wait until exit. If it was new, clear the special new */ /* flag. */ - if (fnp->f_flags.f_dnew) - fnp->f_flags.f_dnew = FALSE; - else - fnp->f_diroff += DIRENT_SIZE; + if (!fnp->f_flags.f_dnew) + new_diroff += DIRENT_SIZE; /* Determine if we hit the end of the directory. If we have, */ /* bump the offset back to the end and exit. If not, fill the */ /* dirent portion of the fnode, clear the f_dmod bit and leave, */ /* but only for root directories */ - if (fnp->f_flags.f_droot && fnp->f_diroff >= fnp->f_dsize) - { - fnp->f_diroff -= DIRENT_SIZE; - return 0; - } - else + + if (fnp->f_flags.f_droot) { - if (fnp->f_flags.f_droot) - { - if ((fnp->f_diroff / secsize - + fnp->f_dpb->dpb_dirstrt) - >= fnp->f_dpb->dpb_data) - { - fnp->f_flags.f_dfull = TRUE; - return 0; - } + if (new_diroff >= DIRENT_SIZE * (ULONG)fnp->f_dpb->dpb_dirents) + return DE_TOOMANY; - bp = getblock((ULONG) (fnp->f_diroff / secsize - + fnp->f_dpb->dpb_dirstrt), - fnp->f_dpb->dpb_unit); + bp = getblock((ULONG) (new_diroff / secsize + + fnp->f_dpb->dpb_dirstrt), + fnp->f_dpb->dpb_unit); #ifdef DISPLAY_GETBLOCK - printf("DIR (dir_read)\n"); + printf("DIR (dir_read)\n"); #endif - } - else - { - - /* Do a "seek" to the directory position */ - fnp->f_offset = fnp->f_diroff; + } + else + { + COUNT rc; + + /* Do a "seek" to the directory position */ + fnp->f_offset = new_diroff; - /* Search through the FAT to find the block */ - /* that this entry is in. */ + /* Search through the FAT to find the block */ + /* that this entry is in. */ #ifdef DISPLAY_GETBLOCK - printf("dir_read: "); + printf("dir_read: "); #endif - if (map_cluster(fnp, XFR_READ) != SUCCESS) - { - fnp->f_flags.f_dfull = TRUE; - return 0; - } + if ((rc = map_cluster(fnp, XFR_READ)) != SUCCESS) + return rc; - /* If the returned cluster is FREE, return zero */ - /* bytes read. */ - if (fnp->f_cluster == FREE) - return 0; + /* If the returned cluster is FREE, LAST_CLUSTER */ + /* LONG_LAST_CLUSTER, return "disk as full" */ - /* If the returned cluster is LAST_CLUSTER or */ - /* LONG_LAST_CLUSTER, return zero bytes read */ - /* and set the directory as full. */ - - if (last_link(fnp)) - { - fnp->f_diroff -= DIRENT_SIZE; - fnp->f_flags.f_dfull = TRUE; - return 0; - } + if (fnp->f_cluster == FREE || last_link(fnp)) + return DE_HNDLDSKFULL; - /* Compute the block within the cluster and the */ - /* offset within the block. */ - fnp->f_sector = (fnp->f_offset / secsize) & fnp->f_dpb->dpb_clsmask; - fnp->f_boff = fnp->f_offset % secsize; + /* Compute the block within the cluster and the */ + /* offset within the block. */ + fnp->f_sector = (fnp->f_offset / secsize) & fnp->f_dpb->dpb_clsmask; + fnp->f_boff = fnp->f_offset % secsize; - /* Get the block we need from cache */ - bp = getblock((ULONG) clus2phys(fnp->f_cluster, - (fnp->f_dpb->dpb_clsmask + 1), - fnp->f_dpb->dpb_data) - + fnp->f_sector, - fnp->f_dpb->dpb_unit); + /* Get the block we need from cache */ + bp = getblock(clus2phys(fnp->f_cluster, fnp->f_dpb) + fnp->f_sector, + fnp->f_dpb->dpb_unit); #ifdef DISPLAY_GETBLOCK - printf("DIR (dir_read)\n"); + printf("DIR (dir_read)\n"); #endif - } + } - /* Now that we have the block for our entry, get the */ - /* directory entry. */ - if (bp == NULL) - { - fnp->f_flags.f_dfull = TRUE; - return 0; - } + /* Now that we have the block for our entry, get the */ + /* directory entry. */ + if (bp == NULL) + return DE_BLKINVLD; - bp->b_flag &= ~(BFR_DATA | BFR_FAT); - bp->b_flag |= BFR_DIR | BFR_VALID; + bp->b_flag &= ~(BFR_DATA | BFR_FAT); + bp->b_flag |= BFR_DIR | BFR_VALID; - getdirent((BYTE FAR *) & bp->b_buffer[((UWORD)fnp->f_diroff) % fnp->f_dpb->dpb_secsize], - (struct dirent FAR *)&fnp->f_dir); + getdirent((BYTE FAR *) & bp->b_buffer[((UWORD)new_diroff) % fnp->f_dpb->dpb_secsize], + (struct dirent FAR *)&fnp->f_dir); - /* Update the fnode's directory info */ - fnp->f_flags.f_dfull = FALSE; - fnp->f_flags.f_dmod = FALSE; + /* Update the fnode's directory info */ + fnp->f_flags.f_dmod = FALSE; + fnp->f_flags.f_dnew = FALSE; + fnp->f_diroff = new_diroff; - /* and for efficiency, stop when we hit the first */ - /* unused entry. */ - if (fnp->f_dir.dir_name[0] == '\0') - return 0; - else - return DIRENT_SIZE; - } + /* and for efficiency, stop when we hit the first */ + /* unused entry. */ + /* either returns 1 or 0 */ + return (fnp->f_dir.dir_name[0] != '\0'); } +/* Description. + * Writes directory entry pointed by fnp to disk. In case of erroneous + * situation fnode is released. + * Return value. + * TRUE - all OK. + * FALSE - error occured (fnode is released). + */ #ifndef IPL -COUNT dir_write(REG f_node_ptr fnp) +BOOL dir_write(REG f_node_ptr fnp) { struct buffer FAR *bp; REG UWORD secsize = fnp->f_dpb->dpb_secsize; @@ -539,19 +527,12 @@ COUNT dir_write(REG f_node_ptr fnp) #ifdef DISPLAY_GETBLOCK printf("dir_write: "); #endif - if (map_cluster(fnp, XFR_READ) != SUCCESS) - { - fnp->f_flags.f_dfull = TRUE; - release_f_node(fnp); - return 0; - } - - /* If the returned cluster is FREE, return zero */ - /* bytes read. */ - if (fnp->f_cluster == FREE) + /* If map_cluster gives an error or the returned cluster is FREE, + return FALSE */ + if (map_cluster(fnp, XFR_READ) != SUCCESS || fnp->f_cluster == FREE) { release_f_node(fnp); - return 0; + return FALSE; } /* Compute the block within the cluster and the */ @@ -560,10 +541,7 @@ COUNT dir_write(REG f_node_ptr fnp) fnp->f_boff = fnp->f_offset % secsize; /* Get the block we need from cache */ - bp = getblock((ULONG) clus2phys(fnp->f_cluster, - (fnp->f_dpb->dpb_clsmask + 1), - fnp->f_dpb->dpb_data) - + fnp->f_sector, + bp = getblock(clus2phys(fnp->f_cluster, fnp->f_dpb) + fnp->f_sector, fnp->f_dpb->dpb_unit); bp->b_flag &= ~(BFR_DATA | BFR_FAT); bp->b_flag |= BFR_DIR | BFR_VALID; @@ -577,7 +555,7 @@ COUNT dir_write(REG f_node_ptr fnp) if (bp == NULL) { release_f_node(fnp); - return 0; + return FALSE; } if (fnp->f_flags.f_dnew && fnp->f_dir.dir_attrib != D_LFN) @@ -588,7 +566,7 @@ COUNT dir_write(REG f_node_ptr fnp) bp->b_flag &= ~(BFR_DATA | BFR_FAT); bp->b_flag |= BFR_DIR | BFR_DIRTY | BFR_VALID; } - return DIRENT_SIZE; + return TRUE; } #endif @@ -643,24 +621,20 @@ COUNT dos_findfirst(UCOUNT attr, BYTE *name) printf("ff %s\n", local_ext); */ - /* Now build a directory. */ - if (!szDirName[2]) - fstrcpy(&szDirName[0], current_ldt->cdsCurrentPath); - /* Build the match pattern out of the passed string */ /* copy the part of the pattern which belongs to the filename and is fixed */ - for (p = local_name, i = 0; i < FNAME_SIZE && *p && *p != '*'; ++p, ++i) + for (p = local_name, i = 0; i < FNAME_SIZE && *p; ++p, ++i) SearchDir.dir_name[i] = *p; for (; i < FNAME_SIZE; ++i) - SearchDir.dir_name[i] = *p == '*' ? '?' : ' '; + SearchDir.dir_name[i] = ' '; /* and the extension (don't forget to add trailing spaces)... */ - for (p = local_ext, i = 0; i < FEXT_SIZE && *p && *p != '*'; ++p, ++i) + for (p = local_ext, i = 0; i < FEXT_SIZE && *p; ++p, ++i) SearchDir.dir_ext[i] = *p; for (; i < FEXT_SIZE; ++i) - SearchDir.dir_ext[i] = *p == '*' ? '?' : ' '; + SearchDir.dir_ext[i] = ' '; /* Convert everything to uppercase. */ DosUpFMem(SearchDir.dir_name, FNAME_SIZE + FEXT_SIZE); @@ -703,7 +677,7 @@ COUNT dos_findfirst(UCOUNT attr, BYTE *name) if (attr == D_VOLID) { /* Now do the search */ - while (dir_read(fnp) == DIRENT_SIZE) + while (dir_read(fnp) == 1) { /* Test the attribute and return first found */ if ((fnp->f_dir.dir_attrib & ~(D_RDONLY | D_ARCHIVE)) == D_VOLID) @@ -767,13 +741,13 @@ COUNT dos_findnext(void) return DE_NFILES; } - fnp->f_dsize = DIRENT_SIZE * (fnp->f_dpb)->dpb_dirents; + dir_init_fnode(fnp, dmp->dm_dircluster); /* Search through the directory to find the entry, but do a */ /* seek first. */ if (dmp->dm_entry > 0) { - fnp->f_diroff = (dmp->dm_entry - 1) * DIRENT_SIZE; + fnp->f_diroff = (ULONG)(dmp->dm_entry - 1) * DIRENT_SIZE; fnp->f_flags.f_dnew = FALSE; } else @@ -782,26 +756,8 @@ COUNT dos_findnext(void) fnp->f_flags.f_dnew = TRUE; } - fnp->f_offset = fnp->f_diroff; - - fnp->f_dir.dir_start = dmp->dm_dircluster; -#ifdef WITHFAT32 - fnp->f_dir.dir_start_high = dmp->dm_dircluster >> 16; -#endif - - fnp->f_cluster = fnp->f_dirstart = - dmp->dm_dircluster; - - fnp->f_flags.f_droot = fnp->f_dirstart == 0; - fnp->f_flags.f_ddir = TRUE; - - - fnp->f_flags.f_dfull = FALSE; - - fnp->f_cluster_offset = 0l; /*JPP */ - /* Loop through the directory */ - while (dir_read(fnp) == DIRENT_SIZE) + while (dir_read(fnp) == 1) { ++dmp->dm_entry; if (fnp->f_dir.dir_name[0] != '\0' && fnp->f_dir.dir_name[0] != DELETED diff --git a/kernel/fatfs.c b/kernel/fatfs.c index 28b26236..3da3c891 100644 --- a/kernel/fatfs.c +++ b/kernel/fatfs.c @@ -47,6 +47,9 @@ BYTE *RcsId = "$Id$"; * performance killer on large drives. (~0.5 sec /dos_mkdir) TE * * $Log$ + * Revision 1.25 2001/11/04 19:47:39 bartoldeman + * kernel 2025a changes: see history.txt + * * Revision 1.24 2001/09/23 20:39:44 bartoldeman * FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling * @@ -279,6 +282,18 @@ BOOL first_fat(f_node_ptr); COUNT map_cluster(f_node_ptr, COUNT); STATIC VOID shrink_file(f_node_ptr fnp); +ULONG clus2phys(CLUSTER cl_no, struct dpb FAR *dpbp) +{ + CLUSTER data = +#ifdef WITHFAT32 + ISFAT32(dpbp) ? + dpbp->dpb_xdata : +#endif + dpbp->dpb_data; + return ((ULONG)(cl_no - 2) << dpbp->dpb_shftcnt) + data; +} + + /************************************************************************/ /* */ /* Internal file handlers - open, create, read, write, close, etc. */ @@ -380,7 +395,6 @@ COUNT dos_close(COUNT fd) fnp->f_dir.dir_date = dos_getdate(); } - shrink_file(fnp); /* reduce allocated filesize in FAT */ fnp->f_dir.dir_size = fnp->f_highwater; merge_file_changes(fnp, FALSE); /* /// Added - Ron Cemer */ } @@ -469,7 +483,7 @@ STATIC BOOL find_fname(f_node_ptr fnp, BYTE * fname, BYTE * fext) { BOOL found = FALSE; - while (dir_read(fnp) == DIRENT_SIZE) + while (dir_read(fnp) == 1) { if (fnp->f_dir.dir_name[0] != '\0') { @@ -488,46 +502,26 @@ STATIC BOOL find_fname(f_node_ptr fnp, BYTE * fname, BYTE * fext) return found; } -/* STATIC BOOL find_full_fname(f_node_ptr fnp, f_node_ptr lfnp, BYTE * fname, - BYTE * fext) -{ - BOOL found = FALSE; - - lfnp->f_cluster = LONG_LAST_CLUSTER; - while (dir_read(fnp) == DIRENT_SIZE) - { - if (fnp->f_dir.dir_name[0] != '\0') - { - if (fnp->f_dir.dir_name[0] == DELETED) - continue; - - if (fnp->f_dir.dir_attrib != 0xf) lfnp->f_cluster = LONG_LAST_CLUSTER; - else if (lfnp->f_cluster == LONG_LAST_CLUSTER) - memcpy(lfnp, struct fnp, sizeof(f_node)); - - if (fcmp(fname, (BYTE *)fnp->f_dir.dir_name, FNAME_SIZE) - && fcmp(fext, (BYTE *)fnp->f_dir.dir_ext, FEXT_SIZE) - && ((fnp->f_dir.dir_attrib & D_VOLID) == 0)) - { - found = TRUE; - break; - } - } - } - return found; -} */ - -/* input: fnp with valid non-LFN directory entry, not equal to '..' or -'.' */ -void remove_lfn_entries(f_node_ptr fnp) +/* Description. + * Remove entries with D_LFN attribute preceeding the directory entry + * pointed by fnp, fnode isn't modified (I hope). + * Return value. + * SUCCESS - completed successfully. + * ERROR - error occured. + * input: fnp with valid non-LFN directory entry, not equal to '..' or + * '.' + */ +COUNT remove_lfn_entries(f_node_ptr fnp) { ULONG original_diroff = fnp->f_diroff; + COUNT rc; + while (TRUE) { if(fnp->f_diroff == 0) break; fnp->f_diroff -= 2*DIRENT_SIZE; - /* it cannot / should not get below 0 because of '.' and '..' - but maybe add another check for robustness */ - dir_read(fnp); + /* it cannot / should not get below 0 because of '.' and '..' */ + if ((rc = dir_read(fnp)) < 0) + return rc; if (fnp->f_dir.dir_attrib != D_LFN) break; fnp->f_dir.dir_name[0] = DELETED; @@ -535,7 +529,9 @@ void remove_lfn_entries(f_node_ptr fnp) dir_write(fnp); } fnp->f_diroff = original_diroff - DIRENT_SIZE; - dir_read(fnp); + if ((rc = dir_read(fnp)) < 0) + return rc; + return SUCCESS; } /* /// Added - Ron Cemer */ /* If more than one f_node has a file open, and a write @@ -590,7 +586,6 @@ STATIC int is_same_file(f_node_ptr fnp1, f_node_ptr fnp2) { (BYTE *)fnp2->f_dir.dir_ext, FEXT_SIZE)) && ((fnp1->f_dir.dir_attrib & D_VOLID) == 0) && ((fnp2->f_dir.dir_attrib & D_VOLID) == 0) - && (fnp1->f_flags.f_dremote == fnp2->f_flags.f_dremote) && (fnp1->f_diroff == fnp2->f_diroff) && (fnp1->f_dirstart == fnp2->f_dirstart) && (fnp1->f_dpb == fnp2->f_dpb); @@ -612,13 +607,7 @@ COUNT dos_creat(BYTE * path, COUNT attrib) { REG f_node_ptr fnp; - /* NEVER EVER allow directories to be created */ - if (attrib & ~(D_RDONLY|D_HIDDEN|D_SYSTEM|D_ARCHIVE)) - { - return DE_ACCESS; - } - - /* first split the passed dir into comopnents (i.e. - */ + /* first split the passed dir into components (i.e. - */ /* path to new directory and name of new directory */ if ((fnp = split_path(path, szFileName, szFileExt)) == NULL) { @@ -692,7 +681,7 @@ COUNT dos_creat(BYTE * path, COUNT attrib) fnp->f_flags.f_ddate = FALSE; fnp->f_flags.f_dnew = FALSE; fnp->f_flags.f_ddir = TRUE; - if (dir_write(fnp) != DIRENT_SIZE) + if (!dir_write(fnp)) { release_f_node(fnp); return DE_ACCESS; @@ -716,6 +705,29 @@ COUNT dos_creat(BYTE * path, COUNT attrib) return xlt_fnp(fnp); } +STATIC COUNT delete_dir_entry(f_node_ptr fnp) +{ + COUNT rc; + + /* Ok, so we can delete. Start out by */ + /* clobbering all FAT entries for this file */ + /* (or, in English, truncate the FAT). */ + if ((rc=remove_lfn_entries(fnp)) < 0) + return rc; + + wipe_out(fnp); + *(fnp->f_dir.dir_name) = DELETED; + + /* The directory has been modified, so set the */ + /* bit before closing it, allowing it to be */ + /* updated */ + fnp->f_flags.f_dmod = TRUE; + dir_close(fnp); + + /* SUCCESSful completion, return it */ + return SUCCESS; +} + COUNT dos_delete(BYTE * path) { REG f_node_ptr fnp; @@ -741,22 +753,7 @@ COUNT dos_delete(BYTE * path) return DE_ACCESS; } - /* Ok, so we can delete. Start out by */ - /* clobbering all FAT entries for this file */ - /* (or, in English, truncate the FAT). */ - remove_lfn_entries(fnp); - wipe_out(fnp); - fnp->f_dir.dir_size = 0l; - *(fnp->f_dir.dir_name) = DELETED; - - /* The directory has been modified, so set the */ - /* bit before closing it, allowing it to be */ - /* updated */ - fnp->f_flags.f_dmod = TRUE; - dir_close(fnp); - - /* SUCCESSful completion, return it */ - return SUCCESS; + return delete_dir_entry(fnp); } else { @@ -826,7 +823,7 @@ COUNT dos_rmdir(BYTE * path) /* Now search through the directory and make certain */ /* that there are no entries. */ found = FALSE; - while (dir_read(fnp1) == DIRENT_SIZE) + while (dir_read(fnp1) == 1) { if (fnp1->f_dir.dir_name[0] == '\0') break; @@ -846,23 +843,7 @@ COUNT dos_rmdir(BYTE * path) dir_close(fnp); return DE_ACCESS; } - - /* Ok, so we can delete. Start out by */ - /* clobbering all FAT entries for this file */ - /* (or, in English, truncate the FAT). */ - remove_lfn_entries(fnp); - wipe_out(fnp); - fnp->f_dir.dir_size = 0l; - *(fnp->f_dir.dir_name) = DELETED; - - /* The directory has been modified, so set the */ - /* bit before closing it, allowing it to be */ - /* updated */ - fnp->f_flags.f_dmod = TRUE; - dir_close(fnp); - - /* SUCCESSful completion, return it */ - return SUCCESS; + return delete_dir_entry(fnp); } else { @@ -877,6 +858,7 @@ COUNT dos_rename(BYTE * path1, BYTE * path2) REG f_node_ptr fnp1; REG f_node_ptr fnp2; BOOL is_free; + COUNT ret; /* first split the passed target into compnents (i.e. - path to */ /* new file name and name of new file name */ @@ -927,15 +909,15 @@ COUNT dos_rename(BYTE * path1, BYTE * path2) /* Otherwise just expand the directory */ else if (!is_free && !(fnp2->f_flags.f_droot)) { - COUNT ret; - if ((ret = extend_dir(fnp2)) != SUCCESS) { dir_close(fnp1); return ret; } } - remove_lfn_entries(fnp1); + + if ((ret=remove_lfn_entries(fnp1)) < 0) + return ret; /* put the fnode's name into the directory. */ bcopy(szFileName, (BYTE *)fnp2->f_dir.dir_name, FNAME_SIZE); @@ -960,7 +942,6 @@ COUNT dos_rename(BYTE * path1, BYTE * path2) fnp2->f_highwater = fnp2->f_offset = fnp1->f_dir.dir_size; /* Ok, so we can delete this one. Save the file info. */ - fnp1->f_dir.dir_size = 0l; *(fnp1->f_dir.dir_name) = DELETED; dir_close(fnp1); @@ -971,23 +952,16 @@ COUNT dos_rename(BYTE * path1, BYTE * path2) } /* */ -/* wipe out all FAT entries for create, delete, etc. */ +/* wipe out all FAT entries starting from st for create, delete, etc. */ /* */ -STATIC VOID wipe_out(f_node_ptr fnp) +STATIC VOID wipe_out_clusters(struct dpb FAR *dpbp, CLUSTER st) { - REG CLUSTER st, - next; - struct dpb FAR *dpbp = fnp->f_dpb; + REG CLUSTER next; - /* if already free or not valid file, just exit */ - if ((fnp == NULL) || checkdstart(fnp->f_dir, FREE)) - return; - /* Loop from start until either a FREE entry is */ /* encountered (due to a fractured file system) of the */ /* last cluster is encountered. */ - for (st = getdstart(fnp->f_dir); - st != LONG_LAST_CLUSTER;) + while (st != LONG_LAST_CLUSTER) { /* get the next cluster pointed to */ next = next_cluster(dpbp, st); @@ -1000,6 +974,14 @@ STATIC VOID wipe_out(f_node_ptr fnp) link_fat(dpbp, st, FREE); /* and the start of free space pointer */ +#ifdef WITHFAT32 + if (ISFAT32(dpbp)) + { + if ((dpbp->dpb_xcluster == UNKNCLUSTER) + || (dpbp->dpb_xcluster > st)) + dpbp->dpb_xcluster = st; + } else +#endif if ((dpbp->dpb_cluster == UNKNCLUSTER) || (dpbp->dpb_cluster > st)) dpbp->dpb_cluster = st; @@ -1012,17 +994,26 @@ STATIC VOID wipe_out(f_node_ptr fnp) #endif } +/* */ +/* wipe out all FAT entries for create, delete, etc. */ +/* */ +STATIC VOID wipe_out(f_node_ptr fnp) +{ + /* if already free or not valid file, just exit */ + if ((fnp == NULL) || checkdstart(fnp->f_dir, FREE)) + return; + + wipe_out_clusters(fnp->f_dpb, getdstart(fnp->f_dir)); +} + STATIC BOOL find_free(f_node_ptr fnp) { - while (dir_read(fnp) == DIRENT_SIZE) - { - if (fnp->f_dir.dir_name[0] == '\0' - || fnp->f_dir.dir_name[0] == DELETED) - { + COUNT rc; + + while ((rc = dir_read(fnp)) == 1) + if (fnp->f_dir.dir_name[0] == DELETED) return TRUE; - } - } - return !fnp->f_flags.f_dfull; + return rc >= 0; } /* */ @@ -1199,45 +1190,69 @@ BOOL dos_setfsize(COUNT fd, LONG size) /* */ STATIC CLUSTER find_fat_free(f_node_ptr fnp) { - REG CLUSTER idx; + REG CLUSTER idx, size; + struct dpb FAR *dpbp = fnp->f_dpb; #ifdef DISPLAY_GETBLOCK printf("[find_fat_free]\n"); #endif + /* Start from optimized lookup point for start of FAT */ - if (fnp->f_dpb->dpb_cluster != UNKNCLUSTER) - idx = fnp->f_dpb->dpb_cluster; - else - idx = 2; + idx = 2; + size = dpbp->dpb_size; +#ifdef WITHFAT32 + if (ISFAT32(dpbp)) + { + if (dpbp->dpb_xcluster != UNKNCLUSTER) + idx = dpbp->dpb_xcluster; + size = dpbp->dpb_xsize; + } else +#endif + if (dpbp->dpb_cluster != UNKNCLUSTER) + idx = dpbp->dpb_cluster; /* Search the FAT table looking for the first free */ /* entry. */ - for (; idx <= fnp->f_dpb->dpb_size; idx++) + for (; idx <= size; idx++) { - if (next_cluster(fnp->f_dpb, idx) == FREE) + if (next_cluster(dpbp, idx) == FREE) break; } /* No empty clusters, disk is FULL! */ - if (idx > fnp->f_dpb->dpb_size) - { - fnp->f_dpb->dpb_cluster = UNKNCLUSTER; #ifdef WITHFAT32 - if (ISFAT32(fnp->f_dpb)) write_fsinfo(fnp->f_dpb); -#endif + if (ISFAT32(dpbp)) + { + if (idx > dpbp->dpb_xsize) + { + dpbp->dpb_xcluster = UNKNCLUSTER; + write_fsinfo(dpbp); + dir_close(fnp); + return LONG_LAST_CLUSTER; + } + if (dpbp->dpb_xnfreeclst != XUNKNCLSTFREE) + dpbp->dpb_xnfreeclst--; /* TE: moved from link_fat() */ + + /* return the free entry */ + dpbp->dpb_xcluster = idx; + write_fsinfo(dpbp); + return idx; + } +#endif + + if (idx > dpbp->dpb_size) + { + dpbp->dpb_cluster = UNKNCLUSTER; dir_close(fnp); return LONG_LAST_CLUSTER; } - if (fnp->f_dpb->dpb_nfreeclst != UNKNCLSTFREE) - fnp->f_dpb->dpb_nfreeclst--; /* TE: moved from link_fat() */ + if (dpbp->dpb_nfreeclst != UNKNCLSTFREE) + dpbp->dpb_nfreeclst--; /* TE: moved from link_fat() */ /* return the free entry */ - fnp->f_dpb->dpb_cluster = idx; -#ifdef WITHFAT32 - if (ISFAT32(fnp->f_dpb)) write_fsinfo(fnp->f_dpb); -#endif + dpbp->dpb_cluster = idx; return idx; } @@ -1250,6 +1265,7 @@ COUNT dos_mkdir(BYTE * dir) REG f_node_ptr fnp; REG COUNT idx; struct buffer FAR *bp; + struct dpb FAR *dpbp; CLUSTER free_fat, parent; COUNT ret; @@ -1273,10 +1289,6 @@ COUNT dos_mkdir(BYTE * dir) dir_close(fnp); return DE_PATHNOTFND; } - - - - /* Check that we don't have a duplicate name, so if we */ /* find one, it's an error. */ @@ -1286,7 +1298,6 @@ COUNT dos_mkdir(BYTE * dir) return DE_ACCESS; } - /* Reset the directory by a close followed by */ /* an open */ fnp->f_flags.f_dmod = FALSE; @@ -1353,15 +1364,14 @@ COUNT dos_mkdir(BYTE * dir) /* Mark the cluster in the FAT as used */ fnp->f_cluster = free_fat; setdstart(fnp->f_dir, free_fat); - link_fat(fnp->f_dpb, free_fat, LONG_LAST_CLUSTER); + dpbp = fnp->f_dpb; + link_fat(dpbp, free_fat, LONG_LAST_CLUSTER); /* Craft the new directory. Note that if we're in a new */ /* directory just under the root, ".." pointer is 0. */ /* as we are overwriting it completely, don't read first */ - bp = getblockOver((ULONG) clus2phys(free_fat, - (fnp->f_dpb->dpb_clsmask + 1), - fnp->f_dpb->dpb_data), - fnp->f_dpb->dpb_unit); + bp = getblockOver(clus2phys(free_fat, dpbp), + dpbp->dpb_unit); #ifdef DISPLAY_GETBLOCK printf("FAT (dos_mkdir)\n"); #endif @@ -1386,7 +1396,7 @@ COUNT dos_mkdir(BYTE * dir) /* create the ".." entry */ bcopy(".. ", (BYTE *) DirEntBuffer.dir_name, FNAME_SIZE); #ifdef WITHFAT32 - if (ISFAT32(fnp->f_dpb) && parent == fnp->f_dpb->dpb_xrootclst) { + if (ISFAT32(dpbp) && parent == dpbp->dpb_xrootclst) { parent = 0; } #endif @@ -1402,14 +1412,12 @@ COUNT dos_mkdir(BYTE * dir) bp->b_flag |= BFR_DIRTY | BFR_VALID; /* clear out the rest of the blocks in the cluster */ - for (idx = 1; idx < (fnp->f_dpb->dpb_clsmask + 1); idx++) + for (idx = 1; idx <= dpbp->dpb_clsmask; idx++) { /* as we are overwriting it completely, don't read first */ - bp = getblockOver((ULONG) clus2phys(getdstart(fnp->f_dir), - (fnp->f_dpb->dpb_clsmask + 1), - fnp->f_dpb->dpb_data) + idx, - fnp->f_dpb->dpb_unit); + bp = getblockOver(clus2phys(getdstart(fnp->f_dir), dpbp) + idx, + dpbp->dpb_unit); #ifdef DISPLAY_GETBLOCK printf("DIR (dos_mkdir)\n"); #endif @@ -1424,7 +1432,7 @@ COUNT dos_mkdir(BYTE * dir) } /* flush the drive buffers so that all info is written */ - flush_buffers((COUNT) (fnp->f_dpb->dpb_unit)); + flush_buffers((COUNT) (dpbp->dpb_unit)); /* Close the directory so that the entry is updated */ fnp->f_flags.f_dmod = TRUE; @@ -1474,24 +1482,22 @@ STATIC COUNT extend_dir(f_node_ptr fnp) return DE_HNDLDSKFULL; } - /* clear out the rest of the blocks in the cluster */ - for (idx = 0; idx < (fnp->f_dpb->dpb_clsmask + 1); idx++) + /* clear out the blocks in the cluster */ + for (idx = 0; idx <= fnp->f_dpb->dpb_clsmask; idx++) { REG struct buffer FAR *bp; - bp = getblockOver((ULONG) clus2phys(fnp->f_cluster, - (fnp->f_dpb->dpb_clsmask + 1), - fnp->f_dpb->dpb_data) + idx, - fnp->f_dpb->dpb_unit); + /* as we are overwriting it completely, don't read first */ + bp = getblockOver(clus2phys(fnp->f_cluster, fnp->f_dpb) + idx, + fnp->f_dpb->dpb_unit); #ifdef DISPLAY_GETBLOCK printf("DIR (extend_dir)\n"); #endif - if (bp == NULL) - { + if (bp == NULL) { dir_close(fnp); return DE_BLKINVLD; } - fmemset(bp->b_buffer,0, BUFFERSIZE); + fmemset(bp->b_buffer, 0, BUFFERSIZE); bp->b_flag |= BFR_DIRTY | BFR_VALID; if (idx != 0) @@ -1556,7 +1562,7 @@ COUNT map_cluster(REG f_node_ptr fnp, COUNT mode) #endif /* The variable clssize will be used later. */ - clssize = (ULONG)fnp->f_dpb->dpb_secsize * (fnp->f_dpb->dpb_clsmask + 1); + clssize = (ULONG)fnp->f_dpb->dpb_secsize << fnp->f_dpb->dpb_shftcnt; /* If someone did a seek, but no writes have occured, we will */ /* need to initialize the fnode. */ @@ -1605,7 +1611,7 @@ COUNT map_cluster(REG f_node_ptr fnp, COUNT mode) if (!extend(fnp)) { dir_close(fnp); - return DE_HNDLDSKFULL; + return DE_HNDLDSKFULL; } } fnp->f_back = fnp->f_cluster; @@ -1622,6 +1628,72 @@ COUNT map_cluster(REG f_node_ptr fnp, COUNT mode) return SUCCESS; } +/* + comments read optimization for large reads: read total clusters in one piece + + running a program like + + while (1) { + read(fd, header, sizeof(header)); // small read + read(fd, buffer, header.size); // where size is large, up to 63K + // with average ~32K + } + + FreeDOS 2025 is really slow. + on a P200 with modern 30GB harddisk, doing above for a 14.5 MB file + + MSDOS 6.22 clustersize 8K ~2.5 sec (accumulates over clusters, reads for 63 sectors seen), + IBM PCDOS 7.0 8K ~4.3 + IBM PCDOS 7.0 16K ~2.8 + FreeDOS ke2025 ~17.5 + + with the read optimization (ke2025a), + + clustersize 8K ~6.5 sec + clustersize 16K ~4.2 sec + + it was verified with IBM feature tool, + that the drive read ahead cache (says it) is on. still this huge difference ;-) + + + it's coded pretty conservative to avoid all special cases, + so it shouldn't break anything :-) + + possible further optimization: + + collect read across clusters (if file is not fragmented). + MSDOS does this (as readcounts up to 63 sectors where seen) + specially important for diskettes, where clustersize is 1 sector + + the same should be done for writes as well + + + the time to compile the complete kernel (on some P200) is + reduced from 67 to 56 seconds - in an otherwise identical configuration. + + it's not clear if this improvement shows up elsewhere, but it shouldn't harm either + + + TE 10/18/01 14:00 + + collect read across clusters (if file is not fragmented) done. + + seems still to work :-)) + + no large performance gains visible, but should now work _much_ + better for the people, that complain about slow floppy access + + the + fnp->f_offset +to_xfer < fnp->f_highwater && avoid EOF problems + + condition can probably _carefully_ be dropped + + + TE 10/18/01 19:00 + +*/ + + /* Read block from disk */ UCOUNT readblock(COUNT fd, VOID FAR * buffer, UCOUNT count, COUNT * err) { @@ -1631,6 +1703,7 @@ UCOUNT readblock(COUNT fd, VOID FAR * buffer, UCOUNT count, COUNT * err) UCOUNT ret_cnt = 0; UWORD secsize; UCOUNT to_xfer = count; + ULONG currentblock; #if defined( DEBUG ) && 0 if (bDumpRdWrParms) @@ -1734,8 +1807,8 @@ UCOUNT readblock(COUNT fd, VOID FAR * buffer, UCOUNT count, COUNT * err) return ret_cnt; default: - dir_close(fnp); *err = DE_HNDLDSKFULL; + dir_close(fnp); return ret_cnt; case SUCCESS: @@ -1744,10 +1817,84 @@ UCOUNT readblock(COUNT fd, VOID FAR * buffer, UCOUNT count, COUNT * err) } /* Compute the block within the cluster and the offset */ - /* within the block. */ + /* within the block. */ fnp->f_sector = (fnp->f_offset / secsize) & fnp->f_dpb->dpb_clsmask; fnp->f_boff = fnp->f_offset & (secsize - 1); + + + + currentblock = clus2phys(fnp->f_cluster, fnp->f_dpb) + fnp->f_sector; + + /* see comments above */ + + if (!fnp->f_flags.f_ddir && /* don't experiment with directories yet */ + fnp->f_boff == 0 ) /* complete sectors only */ + { + static ULONG startoffset; + UCOUNT sectors_to_read,sectors_wanted; + + + startoffset = fnp->f_offset; + + /* avoid EOF problems */ + sectors_wanted = ((UCOUNT) min(fnp->f_highwater - fnp->f_offset, to_xfer)) / + secsize; + + if (sectors_wanted < 2) + goto normal_read; + + sectors_to_read = fnp->f_dpb->dpb_clsmask + 1 - fnp->f_sector; + + sectors_to_read = min(sectors_to_read, sectors_wanted); + + fnp->f_offset += sectors_to_read*secsize; + + while (sectors_to_read < sectors_wanted) + { + if (map_cluster(fnp, XFR_READ) != SUCCESS) + break; + + if (clus2phys(fnp->f_cluster, fnp->f_dpb) != currentblock + sectors_to_read) + break; + + sectors_to_read += fnp->f_dpb->dpb_clsmask + 1; + + sectors_to_read = min(sectors_to_read, sectors_wanted); + + fnp->f_offset = startoffset + sectors_to_read*secsize; + + } + + xfr_cnt = sectors_to_read * secsize; + + /* avoid caching trouble */ + + DeleteBlockInBufferCache(currentblock, + currentblock + sectors_to_read - 1, + fnp->f_dpb->dpb_unit); + + if (dskxfer(fnp->f_dpb->dpb_unit, + currentblock, + (VOID FAR *) buffer, sectors_to_read, DSKREAD)) + { + fnp->f_offset = startoffset; + *err = DE_BLKINVLD; + return ret_cnt; + } + + + goto update_pointers; + } + + + + + + /* normal read: just the old, buffer = sector based read */ +normal_read: + + #ifdef DSK_DEBUG printf("read %d links; dir offset %ld, cluster %lx\n", fnp->f_count, @@ -1764,9 +1911,7 @@ UCOUNT readblock(COUNT fd, VOID FAR * buffer, UCOUNT count, COUNT * err) } /* Get the block we need from cache */ - bp = getblock((ULONG) clus2phys(fnp->f_cluster, - (fnp->f_dpb->dpb_clsmask + 1), - fnp->f_dpb->dpb_data) + fnp->f_sector, + bp = getblock(currentblock /*clus2phys(fnp->f_cluster, fnp->f_dpb) + fnp->f_sector*/, fnp->f_dpb->dpb_unit); #ifdef DISPLAY_GETBLOCK @@ -1800,16 +1945,115 @@ UCOUNT readblock(COUNT fd, VOID FAR * buffer, UCOUNT count, COUNT * err) bp->b_flag |= BFR_UNCACHE; } + /* update pointers and counters */ + fnp->f_offset += xfr_cnt; + +update_pointers: ret_cnt += xfr_cnt; to_xfer -= xfr_cnt; - fnp->f_offset += xfr_cnt; buffer = add_far((VOID FAR *) buffer, (ULONG) xfr_cnt); } *err = SUCCESS; return ret_cnt; } +/* extends a file from f_highwater to f_offset */ +/* Proper OS's write zeros in between, but DOS just adds */ +/* garbage sectors, and lets the caller do the zero filling */ +/* if you prefer you can have this enabled using */ +/* #define WRITEZEROS 1 */ +/* but because we want to be compatible, we don't do this by */ +/* default */ +STATIC COUNT dos_extend(f_node_ptr fnp) +{ +#ifdef WRITEZEROS + struct buffer FAR *bp; + UCOUNT xfr_cnt = 0; + /* The variable secsize will be used later. */ + UWORD secsize = fnp->f_dpb->dpb_secsize; + ULONG count; +#endif + + if (fnp->f_offset <= fnp->f_highwater) + return SUCCESS; + +#ifdef WRITEZEROS + count = fnp->f_offset - fnp->f_highwater; + fnp->f_offset = fnp->f_highwater; + while (count > 0) + { +#endif + switch (map_cluster(fnp, XFR_WRITE)) + { + case DE_SEEK: + dir_close(fnp); + return DE_SEEK; + + default: + dir_close(fnp); + return DE_HNDLDSKFULL; + + case SUCCESS: + merge_file_changes(fnp, FALSE); /* /// Added - Ron Cemer */ + break; + } + +#ifdef WRITEZEROS + /* Compute the block within the cluster and the offset */ + /* within the block. */ + fnp->f_sector = + (fnp->f_offset / secsize) & fnp->f_dpb->dpb_clsmask; + fnp->f_boff = fnp->f_offset & (secsize - 1); + +#ifdef DSK_DEBUG + printf("write %d links; dir offset %ld, cluster %d\n", + fnp->f_count, + fnp->f_diroff, + fnp->f_cluster); +#endif + + xfr_cnt = count < (ULONG)secsize - fnp->f_boff ? + (UWORD) count : + secsize - fnp->f_boff; + + /* get a buffer to store the block in */ + if ( (fnp->f_boff == 0) && (xfr_cnt == secsize) ) { + bp = getblockOver(clus2phys(fnp->f_cluster, fnp->f_dpb) + fnp->f_sector, + fnp->f_dpb->dpb_unit); + + } else { + bp = getblock(clus2phys(fnp->f_cluster, fnp->f_dpb) + fnp->f_sector, + fnp->f_dpb->dpb_unit); + } + if (bp == NULL) { + return DE_BLKINVLD; + } + + + /* set a block to zero */ + fmemset((BYTE FAR *) & bp->b_buffer[fnp->f_boff], 0, xfr_cnt); + bp->b_flag |= BFR_DIRTY | BFR_VALID; + + if (xfr_cnt == sizeof(bp->b_buffer)) /* probably not used later */ + { + bp->b_flag |= BFR_UNCACHE; + } + + /* update pointers and counters */ + count -= xfr_cnt; + fnp->f_offset += xfr_cnt; + fnp->f_highwater = fnp->f_offset; + fnp->f_dir.dir_size = fnp->f_highwater; + merge_file_changes(fnp, FALSE); /* /// Added - Ron Cemer */ + } +#else + fnp->f_highwater = fnp->f_offset; + merge_file_changes(fnp, FALSE); /* /// Added - Ron Cemer */ +#endif + return SUCCESS; +} + /* Write block to disk */ UCOUNT writeblock(COUNT fd, VOID FAR * buffer, UCOUNT count, COUNT * err) { @@ -1827,6 +2071,7 @@ UCOUNT writeblock(COUNT fd, VOID FAR * buffer, UCOUNT count, COUNT * err) fd, (COUNT) FP_SEG(buffer), (COUNT) FP_OFF(buffer), count); } #endif + /* Translate the fd into an fnode pointer, since all internal */ /* operations are achieved through fnodes. */ fnp = xlt_fd(fd); @@ -1840,8 +2085,6 @@ UCOUNT writeblock(COUNT fd, VOID FAR * buffer, UCOUNT count, COUNT * err) return 0; } -/* /// BUG!!! Moved from below next block because we should NOT be able - to truncate the file if we can't write to it. - Ron Cemer */ /* test that we have a valid mode for this fnode */ if (fnp->f_mode != WRONLY && fnp->f_mode != RDWR) { @@ -1852,7 +2095,11 @@ UCOUNT writeblock(COUNT fd, VOID FAR * buffer, UCOUNT count, COUNT * err) fnp->f_flags.f_dmod = TRUE; /* mark file as modified */ fnp->f_flags.f_ddate = FALSE; /* set date not valid any more */ - + /* extend file from fnp->f_highwater to fnp->f_offset */ + *err = dos_extend(fnp); + if (*err != SUCCESS) + return 0; + /* Test that we are really about to do a data transfer. If the */ /* count is zero and the mode is XFR_READ, just exit. (Any */ /* read with a count of zero is a nop). */ @@ -1866,42 +2113,11 @@ UCOUNT writeblock(COUNT fd, VOID FAR * buffer, UCOUNT count, COUNT * err) { /* NOTE: doing this up front made a lot of headaches later :-( TE */ /* FAT allocation has to be extended if necessary TE */ - - *err = SUCCESS; - if (fnp->f_highwater < fnp->f_offset) - { - switch (map_cluster(fnp, XFR_WRITE)) - { - case DE_SEEK: - *err = DE_SEEK; - dir_close(fnp); - break; - - default: - dir_close(fnp); - *err = DE_HNDLDSKFULL; - break; - - case SUCCESS: - break; - } - } - - fnp->f_highwater = fnp->f_offset; - merge_file_changes(fnp, FALSE); /* /// Added - Ron Cemer */ - return 0; - } - -/* /// BUG!!! Moved to above previous block because we should NOT be able - to truncate the file if we can't write to it. - Ron Cemer */ - /* test that we have a valid mode for this fnode */ -/* - if (fnp->f_mode != WRONLY && fnp->f_mode != RDWR) - { - *err = DE_INVLDACC; + /* Now done in dos_extend BO */ + /* remove all the following allocated clusters in shrink_file */ + shrink_file(fnp); return 0; } -*/ /* The variable secsize will be used later. */ secsize = fnp->f_dpb->dpb_secsize; @@ -1989,7 +2205,7 @@ UCOUNT writeblock(COUNT fd, VOID FAR * buffer, UCOUNT count, COUNT * err) if (!extend(fnp)) { dir_close(fnp); - *err = DE_HNDLDSKFULL; + *err = DE_HNDLDSKFULL; return ret_cnt; } merge_file_changes(fnp, FALSE); /* /// Added - Ron Cemer */ @@ -2030,15 +2246,11 @@ UCOUNT writeblock(COUNT fd, VOID FAR * buffer, UCOUNT count, COUNT * err) potential problems. - Ron Cemer */ if ( (fnp->f_boff == 0) && (xfr_cnt == secsize) ) { - bp = getblockOver((ULONG) clus2phys(fnp->f_cluster, - (fnp->f_dpb->dpb_clsmask + 1), - fnp->f_dpb->dpb_data) + fnp->f_sector, + bp = getblockOver(clus2phys(fnp->f_cluster, fnp->f_dpb) + fnp->f_sector, fnp->f_dpb->dpb_unit); } else { - bp = getblock((ULONG) clus2phys(fnp->f_cluster, - (fnp->f_dpb->dpb_clsmask + 1), - fnp->f_dpb->dpb_data) + fnp->f_sector, + bp = getblock(clus2phys(fnp->f_cluster, fnp->f_dpb) + fnp->f_sector, fnp->f_dpb->dpb_unit); } if (bp == NULL) { @@ -2082,59 +2294,6 @@ UCOUNT writeblock(COUNT fd, VOID FAR * buffer, UCOUNT count, COUNT * err) return ret_cnt; } -COUNT dos_read(COUNT fd, VOID FAR * buffer, UCOUNT count) -{ - COUNT err; - UCOUNT xfr; - - xfr = readblock(fd, buffer, count, &err); - return err != SUCCESS ? err : xfr; -} - -#ifndef IPL -COUNT dos_write(COUNT fd, VOID FAR * buffer, UCOUNT count) -{ - REG f_node_ptr fnp; - COUNT err, - xfr; - - /* First test if we need to fill to new EOF. */ - - /* Translate the fd into an fnode pointer, since all internal */ - /* operations are achieved through fnodes. */ - fnp = xlt_fd(fd); - - /* If the fd was invalid because it was out of range or the */ - /* requested file was not open, tell the caller and exit */ - /* note: an invalid fd is indicated by a 0 return */ - if (fnp == (f_node_ptr)0 || fnp->f_count <= 0) - { - return DE_INVLDHNDL; - } - - /* Future note: for security purposes, this should be set to */ - /* blocks of 0. This satisfies spec and guarantees no secure */ - /* info is written to disk. */ - /* Also, with real memory management, this may cause a page */ - /* fault. */ - if (fnp->f_offset > fnp->f_highwater) - { - ULONG lCount = fnp->f_offset - fnp->f_highwater; - - while (lCount > 0) - { - writeblock(fd, buffer, - lCount > 512l ? 512 : (UCOUNT) lCount, - &err); - lCount -= 512; - } - } - - xfr = writeblock(fd, buffer, count, &err); - return err != SUCCESS ? err : xfr; -} -#endif - /* Position the file pointer to the desired offset */ /* Returns a long current offset or a negative error code */ LONG dos_lseek(COUNT fd, LONG foffset, COUNT origin) @@ -2181,31 +2340,34 @@ CLUSTER dos_free(struct dpb FAR *dpbp) /* cluster start at 2 and run to max_cluster+2 */ REG CLUSTER i; REG CLUSTER cnt = 0; -/* UWORD max_cluster = ( ((ULONG) dpbp->dpb_size - * * (ULONG) (dpbp->dpb_clsmask + 1) - (dpbp->dpb_data + 1) ) - * / (dpbp->dpb_clsmask + 1) ) + 2; - */ + CLUSTER max_cluster = dpbp->dpb_size + 1; -/*?? UWORD max_cluster = ( ((ULONG) dpbp->dpb_size * (ULONG) (dpbp->dpb_clsmask + 1)) - / (dpbp->dpb_clsmask + 1) ) + 1; -*/ - CLUSTER max_cluster = dpbp->dpb_size + 1; - - if (dpbp->dpb_nfreeclst != UNKNCLSTFREE) - return dpbp->dpb_nfreeclst; - else +#ifdef WITHFAT32 + if (ISFAT32(dpbp)) + { + if (dpbp->dpb_xnfreeclst != XUNKNCLSTFREE) + return dpbp->dpb_xnfreeclst; + max_cluster = dpbp->dpb_xsize + 1; + } + else +#endif + if (dpbp->dpb_nfreeclst != UNKNCLSTFREE) + return dpbp->dpb_nfreeclst; + + for (i = 2; i < max_cluster; i++) { - for (i = 2; i < max_cluster; i++) - { - if (next_cluster(dpbp, i) == 0) - ++cnt; - } - dpbp->dpb_nfreeclst = cnt; + if (next_cluster(dpbp, i) == 0) + ++cnt; + } #ifdef WITHFAT32 - if (ISFAT32(dpbp)) write_fsinfo(dpbp); -#endif + if (ISFAT32(dpbp)) { + dpbp->dpb_xnfreeclst = cnt; + write_fsinfo(dpbp); return cnt; } +#endif + dpbp->dpb_nfreeclst = cnt; + return cnt; } @@ -2215,22 +2377,19 @@ COUNT dos_cd(struct cds FAR * cdsp, BYTE *PathName) { f_node_ptr fnp; - /* first check for valid drive */ - if (cdsp->cdsDpb == 0) - return DE_INVLDDRV; + /* first check for valid drive */ + if (cdsp->cdsDpb == 0) + return DE_INVLDDRV; - if ((media_check(cdsp->cdsDpb) < 0)) - return DE_INVLDDRV; + if ((media_check(cdsp->cdsDpb) < 0)) + return DE_INVLDDRV; /* now test for its existance. If it doesn't, return an error. */ - /* If it does, copy the path to the current directory */ - /* structure. */ if ((fnp = dir_open(PathName)) == NULL) return DE_PATHNOTFND; cdsp->cdsStrtClst = fnp->f_dirstart; dir_close(fnp); - fstrncpy(cdsp->cdsCurrentPath,&PathName[0],sizeof(cdsp->cdsCurrentPath)-1); return SUCCESS; } #endif @@ -2342,7 +2501,7 @@ VOID bpb_to_dpb(bpb FAR *bpbp, REG struct dpb FAR * dpbp) #endif { ULONG size; - REG COUNT i; + REG UWORD shftcnt; dpbp->dpb_mdb = bpbp->bpb_mdesc; dpbp->dpb_secsize = bpbp->bpb_nbyte; @@ -2353,37 +2512,36 @@ VOID bpb_to_dpb(bpb FAR *bpbp, REG struct dpb FAR * dpbp) size = bpbp->bpb_nsize == 0 ? bpbp->bpb_huge : (ULONG) bpbp->bpb_nsize; - dpbp->dpb_wfatsize = bpbp->bpb_nfsect; + dpbp->dpb_fatsize = bpbp->bpb_nfsect; dpbp->dpb_dirstrt = dpbp->dpb_fatstrt - + dpbp->dpb_fats * dpbp->dpb_wfatsize; - dpbp->dpb_wdata = dpbp->dpb_dirstrt - + ((DIRENT_SIZE * dpbp->dpb_dirents + + dpbp->dpb_fats * dpbp->dpb_fatsize; + dpbp->dpb_data = dpbp->dpb_dirstrt + + ((DIRENT_SIZE * (ULONG)dpbp->dpb_dirents + (dpbp->dpb_secsize - 1)) / dpbp->dpb_secsize); /* Michal Meller patch to jimtabor */ - dpbp->dpb_wsize = ((size - dpbp->dpb_wdata) - / ((ULONG) bpbp->bpb_nsector) + 1); + dpbp->dpb_size = ((size - dpbp->dpb_data) + / ((ULONG) bpbp->bpb_nsector) + 1); dpbp->dpb_flags = 0; - dpbp->dpb_wcluster = UNKNCLUSTER; + dpbp->dpb_cluster = UNKNCLUSTER; /* number of free clusters */ - *((UWORD FAR *)(&dpbp->dpb_nfreeclst)) = UNKNCLSTFREE16; + dpbp->dpb_nfreeclst = UNKNCLSTFREE; #ifdef WITHFAT32 if (extended) { - dpbp->dpb_fatsize = bpbp->bpb_nfsect == 0 ? bpbp->bpb_xnfsect + dpbp->dpb_xfatsize = bpbp->bpb_nfsect == 0 ? bpbp->bpb_xnfsect : bpbp->bpb_nfsect; - dpbp->dpb_cluster = UNKNCLUSTER; - dpbp->dpb_nfreeclst = UNKNCLSTFREE; /* number of free clusters */ + dpbp->dpb_xcluster = UNKNCLUSTER; + dpbp->dpb_xnfreeclst = XUNKNCLSTFREE; /* number of free clusters */ dpbp->dpb_xflags = 0; dpbp->dpb_xfsinfosec = 0xffff; dpbp->dpb_xbackupsec = 0xffff; dpbp->dpb_xrootclst = 0; - dpbp->dpb_size = ((size - (dpbp->dpb_fatstrt + dpbp->dpb_fats - * dpbp->dpb_fatsize)) - / ((ULONG) bpbp->bpb_nsector) + 1); - + dpbp->dpb_xdata = dpbp->dpb_data; + dpbp->dpb_xsize = dpbp->dpb_size; + if (ISFAT32(dpbp)) { dpbp->dpb_xflags = bpbp->bpb_xflags; @@ -2391,26 +2549,19 @@ VOID bpb_to_dpb(bpb FAR *bpbp, REG struct dpb FAR * dpbp) dpbp->dpb_xbackupsec = bpbp->bpb_xbackupsec; dpbp->dpb_dirents = 0; dpbp->dpb_dirstrt = 0xffff; - dpbp->dpb_wsize = 0; - dpbp->dpb_data = dpbp->dpb_fatstrt + dpbp->dpb_fats * dpbp->dpb_fatsize; + dpbp->dpb_size = 0; + dpbp->dpb_xdata = dpbp->dpb_fatstrt + dpbp->dpb_fats * dpbp->dpb_xfatsize; + dpbp->dpb_xsize = ((size - dpbp->dpb_xdata) + / ((ULONG) bpbp->bpb_nsector) + 1); dpbp->dpb_xrootclst = bpbp->bpb_xrootclst; read_fsinfo(dpbp); } - else - { - dpbp->dpb_data = dpbp->dpb_wdata; - dpbp->dpb_size = dpbp->dpb_wsize; - } } #endif - for (i = 1, dpbp->dpb_shftcnt = 0; - i < (sizeof(dpbp->dpb_shftcnt) * 8); /* 8 bit bytes in C */ - dpbp->dpb_shftcnt++, i <<= 1) - { - if (i >= bpbp->bpb_nsector) - break; - } + for (shftcnt = 0; (bpbp->bpb_nsector >> shftcnt) > 1; shftcnt++) + ; + dpbp->dpb_shftcnt = shftcnt; } COUNT media_check(REG struct dpb FAR * dpbp) @@ -2538,22 +2689,16 @@ struct dhdr FAR *select_unit(COUNT drive) this code corrects this Unfortunately, this code _nearly_ works, but fails one of the - Apps tested (VB ISAM); so it's disabled for the moment + Apps tested (VB ISAM); BO: confirmation??? */ STATIC VOID shrink_file(f_node_ptr fnp) { -#if 0 - UNREFERENCED_PARAMETER(fnp); -#else ULONG lastoffset = fnp->f_offset; /* has to be saved */ CLUSTER next,st; struct dpb FAR *dpbp = fnp->f_dpb; - if (fnp->f_flags.f_ddir || (fnp->f_dir.dir_attrib & D_DIR)) /* can't shrink dirs */ - return; - fnp->f_offset = fnp->f_highwater; /* end of file */ if (fnp->f_offset) fnp->f_offset--; /* last existing cluster */ @@ -2588,30 +2733,10 @@ STATIC VOID shrink_file(f_node_ptr fnp) link_fat(dpbp, st,LONG_LAST_CLUSTER); } - for ( st = next; st != LONG_LAST_CLUSTER; st = next) - { - /* get the next cluster pointed to */ - next = next_cluster(dpbp, st); - - /* just exit if a damaged file system exists */ - if (next == FREE) - return; - - /* zap the FAT pointed to */ - link_fat(dpbp, st, FREE); + wipe_out_clusters(dpbp, next); - /* and the start of free space pointer */ - if ((dpbp->dpb_cluster == UNKNCLUSTER) - || (dpbp->dpb_cluster > st)) - dpbp->dpb_cluster = st; - } - done: fnp->f_offset = lastoffset; /* has to be restored */ -#ifdef WITHFAT32 - if (ISFAT32(dpbp)) write_fsinfo(dpbp); -#endif +} -#endif -} diff --git a/kernel/fattab.c b/kernel/fattab.c index 19432592..35c36b5e 100644 --- a/kernel/fattab.c +++ b/kernel/fattab.c @@ -35,6 +35,9 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.9 2001/11/04 19:47:39 bartoldeman + * kernel 2025a changes: see history.txt + * * Revision 1.8 2001/09/23 20:39:44 bartoldeman * FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling * @@ -167,22 +170,27 @@ struct buffer FAR *getFATblock(CLUSTER cluster, struct dpb FAR *dpbp) if (ISFAT32(dpbp) && (dpbp->dpb_xflags & FAT_NO_MIRRORING)) { /* we must modify the active fat, it's number is in the 0-3 bits of dpb_xflags */ - sector += (dpbp->dpb_xflags & 0xf) * dpbp->dpb_fatsize; + sector += (dpbp->dpb_xflags & 0xf) * dpbp->dpb_xfatsize; } #endif bp = getblock(sector, dpbp->dpb_unit); if (bp) - { - bp->b_flag &= ~(BFR_DATA | BFR_DIR); - bp->b_flag |= BFR_FAT | BFR_VALID; - bp->b_copies = dpbp->dpb_fats; + { + bp->b_flag &= ~(BFR_DATA | BFR_DIR); + bp->b_flag |= BFR_FAT | BFR_VALID; + bp->b_copies = dpbp->dpb_fats; + bp->b_offset = dpbp->dpb_fatsize; #ifdef WITHFAT32 - if (ISFAT32(dpbp) && (dpbp->dpb_xflags & FAT_NO_MIRRORING)) bp->b_copies = 1; -#endif - bp->b_offset = dpbp->dpb_fatsize; + if (ISFAT32(dpbp)) + { + if (dpbp->dpb_xflags & FAT_NO_MIRRORING) + bp->b_copies = 1; + bp->b_offset = dpbp->dpb_xfatsize; } +#endif + } return bp; } @@ -197,8 +205,8 @@ void read_fsinfo(struct dpb FAR *dpbp) bp->b_flag |= BFR_VALID; fip = (struct fsinfo FAR *) & bp->b_buffer[0x1e4]; - dpbp->dpb_nfreeclst = fip->fi_nfreeclst; - dpbp->dpb_cluster = fip->fi_cluster; + dpbp->dpb_xnfreeclst = fip->fi_nfreeclst; + dpbp->dpb_xcluster = fip->fi_cluster; } void write_fsinfo(struct dpb FAR *dpbp) @@ -211,8 +219,8 @@ void write_fsinfo(struct dpb FAR *dpbp) bp->b_flag |= BFR_VALID | BFR_DIRTY; fip = (struct fsinfo FAR *) & bp->b_buffer[0x1e4]; - fip->fi_nfreeclst = dpbp->dpb_nfreeclst; - fip->fi_cluster = dpbp->dpb_cluster; + fip->fi_nfreeclst = dpbp->dpb_xnfreeclst; + fip->fi_cluster = dpbp->dpb_xcluster; } #endif @@ -250,28 +258,37 @@ UCOUNT link_fat(struct dpb FAR *dpbp, CLUSTER Cluster1, REG CLUSTER Cluster2) /* update the free space count */ - if (res == SUCCESS) + if (res == SUCCESS && Cluster2 == FREE) + { +#ifdef WITHFAT32 + if (ISFAT32(dpbp) && dpbp->dpb_xnfreeclst != XUNKNCLSTFREE) + { + /* update the free space count for returned */ + /* cluster */ + ++dpbp->dpb_xnfreeclst; + write_fsinfo(dpbp); + } else +#endif if (dpbp->dpb_nfreeclst != UNKNCLSTFREE) - { - if (Cluster2 == FREE) - { + ++dpbp->dpb_nfreeclst; + } + + /*if (Cluster2 == FREE) + { */ /* update the free space count for returned */ /* cluster */ - ++dpbp->dpb_nfreeclst; - } + /* ++dpbp->dpb_nfreeclst; + }*/ /* update the free space count for removed */ /* cluster */ /* BUG: was counted twice for 2nd,.. cluster. moved to find_fat_free() */ - + /* BO: don't completely understand this yet - leave here for now as + a comment */ /* else { --dpbp->dpb_nfreeclst; } */ - } -#ifdef WITHFAT32 - if (ISFAT32(dpbp)) write_fsinfo(dpbp); -#endif return res; } @@ -382,25 +399,10 @@ UCOUNT link_fat12(struct dpb FAR *dpbp, CLUSTER Cluster1, CLUSTER Cluster2) /* Given the disk parameters, and a cluster number, this function looks at the FAT, and returns the next cluster in the clain. */ CLUSTER next_cluster(struct dpb FAR *dpbp, CLUSTER ClusterNum) -{ - if (ClusterNum == LONG_LAST_CLUSTER) printf("fatal error: trying to do next_cluster(dpbp, EOC)!\n"); - if (ISFAT12(dpbp)) - return next_cl12(dpbp, ClusterNum); - else if (ISFAT16(dpbp)) - return next_cl16(dpbp, ClusterNum); -#ifdef WITHFAT32 - else if (ISFAT32(dpbp)) - return next_cl32(dpbp, ClusterNum); -#endif - else - return LONG_LAST_CLUSTER; -} - -#ifdef WITHFAT32 -CLUSTER next_cl32(struct dpb FAR *dpbp, CLUSTER ClusterNum) { struct buffer FAR *bp; - UDWORD res; + if (ClusterNum == LONG_LAST_CLUSTER) printf("fatal error: trying to do next_cluster(dpbp, EOC)!\n"); + /* Get the block that this cluster is in */ bp = getFATblock(ClusterNum, dpbp); @@ -408,162 +410,96 @@ CLUSTER next_cl32(struct dpb FAR *dpbp, CLUSTER ClusterNum) if (bp == NULL) return DE_BLKINVLD; - res = *(UDWORD FAR *)&(bp->b_buffer[(UCOUNT)((ClusterNum * SIZEOF_CLST32) % dpbp->dpb_secsize)]); - if (res > LONG_BAD) return LONG_LAST_CLUSTER; - - return res; -} -#endif - -CLUSTER next_cl16(struct dpb FAR *dpbp, CLUSTER ClusterNum) -{ - struct buffer FAR *bp; - UWORD res; - - /* Get the block that this cluster is in */ - bp = getFATblock( ClusterNum, dpbp); + if (ISFAT12(dpbp)) + { + union { + UBYTE bytes[2]; + UCOUNT word; + } clusterbuff; + + UCOUNT idx; - if (bp == NULL) - return DE_BLKINVLD; + /* form an index so that we can read the block as a */ + /* byte array */ + idx = (UCOUNT)(((ClusterNum << 1) + ClusterNum) >> 1) % dpbp->dpb_secsize; -#ifndef I86 - UCOUNT idx; + clusterbuff.bytes[0] = bp->b_buffer[idx]; - /* form an index so that we can read the block as a */ - /* byte array */ - idx = (ClusterNum * SIZEOF_CLST16) % dpbp->dpb_secsize; + clusterbuff.bytes[1] = bp->b_buffer[idx+1]; /* next byte, will be overwritten, + if not valid */ - /* Get the cluster number, */ - - fgetword((VOID FAR *) & (bp->b_buffer[idx]), (WORD FAR *) & res); + /* Test to see if the cluster straddles the block. If it */ + /* does, get the next block and use both to form the */ + /* the FAT word. Otherwise, just point to the next */ + /* block. */ + if (idx >= dpbp->dpb_secsize - 1) + { + bp = getFATblock(ClusterNum +1, dpbp); -#else - /* this saves 2 WORDS of stack :-) */ - - res = *(UWORD FAR *)&(bp->b_buffer[(UCOUNT)((ClusterNum * SIZEOF_CLST16) % dpbp->dpb_secsize)]); -#endif - if ((res & MASK16) == MASK16) return LONG_LAST_CLUSTER; - else if ((res & BAD16) == BAD16) return LONG_BAD; + if (bp == 0) + return LONG_BAD; - return res; -} + clusterbuff.bytes[1] = bp->b_buffer[0]; + } -#if 0 - /* old version - correct, but a bit complicated coded. - it's also on one of the critical stack path's - */ + /* Now to unpack the contents of the FAT entry. Odd and */ + /* even bytes are packed differently. */ -UWORD next_cl12(struct dpb FAR *dpbp, REG UCOUNT ClusterNum) -{ - REG UBYTE FAR *fbp0, - FAR * fbp1; - UCOUNT idx; - struct buffer FAR *bp, - FAR * bp1; - - /* Get the block that this cluster is in */ - bp = getFATblock(ClusterNum , dpbp); +#ifndef I86 /* the latter assumes byte ordering */ + if (ClusterNum & 0x01) + idx = ((clusterbuff.byte[0] & 0xf0) >> 4) | (clusterbuff.byte[1] << 4); + else + idx = clusterbuff.byte[0] | ((clusterbuff.byte[0] & 0x0f) << 8); +#else - if (bp == NULL) - return LONG_BAD; - - /* form an index so that we can read the block as a */ - /* byte array */ - idx = (((ClusterNum << 1) + ClusterNum) >> 1) % dpbp->dpb_secsize; - - /* Test to see if the cluster straddles the block. If it */ - /* does, get the next block and use both to form the */ - /* the FAT word. Otherwise, just point to the next */ - /* block. */ - if (idx >= dpbp->dpb_secsize - 1) - { - bp1 = getFATblock(ClusterNum +1, dpbp); + if (ClusterNum & 0x01) + idx = (unsigned short)clusterbuff.word >> 4; + else + idx = clusterbuff.word & 0x0fff; +#endif - if (bp1 == 0) + if (idx >= MASK12) + return LONG_LAST_CLUSTER; + if (idx == BAD12) return LONG_BAD; - - fbp1 = (UBYTE FAR *) & (bp1->b_buffer[0]); + return idx; } - else - fbp1 = (UBYTE FAR *) & (bp->b_buffer[idx + 1]); - fbp0 = (UBYTE FAR *) & (bp->b_buffer[idx]); + else if (ISFAT16(dpbp)) + { + UWORD res; - /* Now to unpack the contents of the FAT entry. Odd and */ - /* even bytes are packed differently. */ - if (ClusterNum & 0x01) - ClusterNum = ((*fbp0 & 0xf0) >> 4) | (*fbp1 << 4); - else - ClusterNum = *fbp0 | ((*fbp1 & 0x0f) << 8); +#ifndef I86 + UCOUNT idx; - if ((ClusterNum & MASK) == MASK) - ClusterNum = LONG_LAST_CLUSTER; - else if ((ClusterNum & BAD) == BAD) - ClusterNum = LONG_BAD; - return ClusterNum; -} -#else - /* new version - 50 byte smaller, saves 10 bytes on stack :-) - */ - -CLUSTER next_cl12(struct dpb FAR *dpbp, REG CLUSTER ClusterNum) -{ - union { - UBYTE bytes[2]; - UCOUNT word; - } clusterbuff; - - UCOUNT idx; - struct buffer FAR *bp; + /* form an index so that we can read the block as a */ + /* byte array */ + idx = (ClusterNum * SIZEOF_CLST16) % dpbp->dpb_secsize; - /* Get the block that this cluster is in */ - bp = getFATblock(ClusterNum , dpbp); + /* Get the cluster number, */ - if (bp == NULL) - return LONG_BAD; - - /* form an index so that we can read the block as a */ - /* byte array */ - idx = (UCOUNT)(((ClusterNum << 1) + ClusterNum) >> 1) % dpbp->dpb_secsize; + fgetword((VOID FAR *) & (bp->b_buffer[idx]), (WORD FAR *) & res); - clusterbuff.bytes[0] = bp->b_buffer[idx]; - - clusterbuff.bytes[1] = bp->b_buffer[idx+1]; /* next byte, will be overwritten, - if not valid */ +#else + /* this saves 2 WORDS of stack :-) */ + + res = *(UWORD FAR *)&(bp->b_buffer[(UCOUNT)((ClusterNum * SIZEOF_CLST16) % dpbp->dpb_secsize)]); +#endif + if (res >= MASK16) return LONG_LAST_CLUSTER; + if (res == BAD16) return LONG_BAD; - /* Test to see if the cluster straddles the block. If it */ - /* does, get the next block and use both to form the */ - /* the FAT word. Otherwise, just point to the next */ - /* block. */ - if (idx >= dpbp->dpb_secsize - 1) + return res; + } +#ifdef WITHFAT32 + else if (ISFAT32(dpbp)) { - bp = getFATblock(ClusterNum +1, dpbp); + UDWORD res; - if (bp == 0) - return LONG_BAD; + res = *(UDWORD FAR *)&(bp->b_buffer[(UCOUNT)((ClusterNum * SIZEOF_CLST32) % dpbp->dpb_secsize)]); + if (res > LONG_BAD) return LONG_LAST_CLUSTER; - clusterbuff.bytes[1] = bp->b_buffer[0]; + return res; } - - /* Now to unpack the contents of the FAT entry. Odd and */ - /* even bytes are packed differently. */ - -#ifndef I86 /* the latter assumes byte ordering */ - if (ClusterNum & 0x01) - ClusterNum = ((clusterbuff.byte[0] & 0xf0) >> 4) | (clusterbuff.byte[1] << 4); - else - ClusterNum = clusterbuff.byte[0] | ((clusterbuff.byte[0] & 0x0f) << 8); -#else - - if (ClusterNum & 0x01) - ClusterNum = (unsigned short)clusterbuff.word >> 4; - else - ClusterNum = clusterbuff.word & 0x0fff; -#endif - - if ((ClusterNum & MASK12) == MASK12) - ClusterNum = LONG_LAST_CLUSTER; - else if ((ClusterNum & BAD12) == BAD12) - ClusterNum = LONG_BAD; - return ClusterNum; -} #endif + return LONG_LAST_CLUSTER; +} + diff --git a/kernel/fcbfns.c b/kernel/fcbfns.c index 5da0c181..f207945d 100644 --- a/kernel/fcbfns.c +++ b/kernel/fcbfns.c @@ -35,6 +35,9 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.19 2001/11/04 19:47:39 bartoldeman + * kernel 2025a changes: see history.txt + * * Revision 1.18 2001/09/23 20:39:44 bartoldeman * FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling * @@ -180,12 +183,8 @@ VOID FatGetDrvData(UCOUNT drive, COUNT FAR * spc, COUNT FAR * bps, { struct dpb FAR *dpbp; struct cds FAR *cdsp; -#ifdef WITHFAT32 - UCOUNT shift = 0; - ULONG cluster_size, ntotal; -#endif - /* first check for valid drive */ + /* first check for valid drive */ *spc = -1; drive = (drive == 0 ? default_drive : drive - 1); @@ -218,22 +217,24 @@ VOID FatGetDrvData(UCOUNT drive, COUNT FAR * spc, COUNT FAR * bps, return; } -#ifdef WITHFAT32 - cluster_size = (dpbp->dpb_clsmask + 1) * dpbp->dpb_secsize; - ntotal = dpbp->dpb_size - 1; - while (cluster_size <= 0x7fff) { - cluster_size <<= 1; - ntotal >>= 1; - shift++; - } - /* get the data available from dpb */ - if (ntotal > 0xfffe) ntotal = 0xfffe; - *nc = (UCOUNT)ntotal; - *spc = (dpbp->dpb_clsmask + 1) << shift; -#else - /* get the data vailable from dpb */ + /* get the data available from dpb */ *nc = dpbp->dpb_size - 1; *spc = dpbp->dpb_clsmask + 1; +#ifdef WITHFAT32 + if (ISFAT32(dpbp)) + { + ULONG cluster_size, ntotal; + + cluster_size = (ULONG)dpbp->dpb_secsize << dpbp->dpb_shftcnt; + ntotal = dpbp->dpb_xsize - 1; + while (ntotal > FAT_MAGIC16 && cluster_size < 0x8000) { + cluster_size <<= 1; + *spc <<= 1; + ntotal >>= 1; + } + /* get the data available from dpb */ + *nc = ntotal > FAT_MAGIC16 ? FAT_MAGIC16 : (UCOUNT)ntotal; + } #endif *bps = dpbp->dpb_secsize; @@ -432,16 +433,8 @@ BOOL FcbRead(xfcb FAR * lpXfcb, COUNT * nErrorCode) return FALSE; } - if (s->sft_flags & SFT_FSHARED) - { - nRead = Remote_RW(REM_READ, lpFcb->fcb_recsiz, p->ps_dta, s, nErrorCode); - } - else - { - - /* Do the read */ - nRead = dos_read(s->sft_status, p->ps_dta, lpFcb->fcb_recsiz); - } + /* Do the read */ + nRead = DosReadSft(s, lpFcb->fcb_recsiz, p->ps_dta, nErrorCode); /* Now find out how we will return and do it. */ if (nRead == lpFcb->fcb_recsiz) @@ -462,14 +455,7 @@ BOOL FcbRead(xfcb FAR * lpXfcb, COUNT * nErrorCode) } else { - COUNT nIdx, - nCount; - BYTE FAR *lpDta; - - nCount = lpFcb->fcb_recsiz - nRead; - lpDta = (BYTE FAR *) & (p->ps_dta[nRead]); - for (nIdx = 0; nIdx < nCount; nIdx++) - *lpDta++ = 0; + fmemset(&p->ps_dta[nRead], 0, lpFcb->fcb_recsiz - nRead); *nErrorCode = FCB_ERR_EOF; FcbNextRecord(lpFcb); return FALSE; @@ -503,17 +489,7 @@ BOOL FcbWrite(xfcb FAR * lpXfcb, COUNT * nErrorCode) return FALSE; } - if (s->sft_flags & SFT_FSHARED) - { - nWritten = Remote_RW(REM_WRITE, lpFcb->fcb_recsiz, p->ps_dta, s, nErrorCode); - } - else - { - - /* Do the read */ - nWritten = dos_write(s->sft_status, p->ps_dta, lpFcb->fcb_recsiz); - s->sft_size = dos_getcufsize(s->sft_status); - } + nWritten = DosWriteSft(s, lpFcb->fcb_recsiz, p->ps_dta, nErrorCode); /* Now find out how we will return and do it. */ if (nWritten == lpFcb->fcb_recsiz) @@ -578,14 +554,13 @@ BOOL FcbSetRandom(xfcb FAR * lpXfcb) BOOL FcbCalcRec(xfcb FAR * lpXfcb) { - UWORD div=128; - + /* Convert to fcb if necessary */ lpFcb = ExtFcbToFcb(lpXfcb); /* Now update the fcb and compute where we need to position */ /* to. */ - lpFcb->fcb_cublock = lpFcb->fcb_rndm / div; + lpFcb->fcb_cublock = lpFcb->fcb_rndm / 128; lpFcb->fcb_curec = lpFcb->fcb_rndm & 127; return TRUE; diff --git a/kernel/globals.h b/kernel/globals.h index d1db37af..9c52a6aa 100644 --- a/kernel/globals.h +++ b/kernel/globals.h @@ -36,6 +36,9 @@ static BYTE *Globals_hRcsId = "$Id$"; /* * $Log$ + * Revision 1.18 2001/11/04 19:47:39 bartoldeman + * kernel 2025a changes: see history.txt + * * Revision 1.17 2001/09/23 20:39:44 bartoldeman * FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling * @@ -376,15 +379,16 @@ GLOBAL WORD bDumpRdWrParms #endif #endif -GLOBAL BYTE copyright[] -#ifdef MAIN -= "(C) Copyright 1995-2001 Pasquale J. Villani and The FreeDOS Project.\n\ -All Rights Reserved. This is free software and comes with ABSOLUTELY NO\n\ -WARRANTY; you can redistribute it and/or modify it under the terms of the\n\ -GNU General Public License as published by the Free Software Foundation;\n\ -either version 2, or (at your option) any later version.\n" +#if 0 /* defined in MAIN.C now to save low memory */ + +GLOBAL BYTE copyright[] = + "(C) Copyright 1995-2001 Pasquale J. Villani and The FreeDOS Project.\n" + "All Rights Reserved. This is free software and comes with ABSOLUTELY NO\n" + "WARRANTY; you can redistribute it and/or modify it under the terms of the\n" + "GNU General Public License as published by the Free Software Foundation;\n" + "either version 2, or (at your option) any later version.\n"; + #endif -; GLOBAL BYTE os_release[] #ifdef MAIN @@ -536,7 +540,7 @@ extern request /* I/O Request packets */ extern fcb FAR * lpFcb; /* Pointer to users fcb */ -extern sfttbl +extern sft FAR * lpCurSft; extern BYTE @@ -548,8 +552,8 @@ extern BYTE extern BYTE BootDrive, /* Drive we came up from */ scr_pos; /* screen position for bs, ht, etc */ -extern WORD - NumFloppies; /* How many floppies we have */ +/*extern WORD + NumFloppies; !!*/ /* How many floppies we have */ extern keyboard kb_buf; @@ -578,9 +582,9 @@ GLOBAL f_node_ptr f_nodes; /* pointer to the array */ GLOBAL UWORD f_nodes_cnt; /* number of allocated f_nodes */ -GLOBAL iregs - FAR * ustackp, /* user stack */ - FAR * kstackp; /* kernel stack */ +/*!! GLOBAL iregs + FAR * ustackp, /* user stack */ +/*!! FAR * kstackp; */ /* kernel stack */ /* */ /* Function prototypes - automatically generated */ diff --git a/kernel/init-mod.h b/kernel/init-mod.h index 102e6413..f18c4497 100644 --- a/kernel/init-mod.h +++ b/kernel/init-mod.h @@ -21,6 +21,10 @@ #include "nls.h" #include "buffer.h" +#include "KConfig.h" +extern struct _KernelConfig InitKernelConfig; + + /* * The null macro `INIT' can be used to allow the reader to differentiate * between functions defined in `INIT_TEXT' and those defined in `_TEXT'. @@ -76,7 +80,7 @@ extern fmemcmp(BYTE far *s1, BYTE FAR *s2, unsigned len); /* Start of configuration variables */ struct config { - UBYTE cfgBuffers; + BYTE cfgBuffers; /* number of buffers in the system */ UBYTE cfgFiles; /* number of available files */ @@ -152,7 +156,7 @@ void ASMCFUNC init_call_intr(int nr, iregs *rp); UCOUNT ASMCFUNC read(int fd, void *buf, UCOUNT count); int ASMCFUNC open(const char *pathname, int flags); int ASMCFUNC close(int fd); -int ASMCFUNC dup2(int oldfd, int newfd); +int ASMCFUNC dup2(int oldfd, int newfd); int ASMCFUNC allocmem(UWORD size, seg *segp); INIT VOID ASMCFUNC init_PSPInit(seg psp_seg); INIT VOID ASMCFUNC init_PSPSet(seg psp_seg); diff --git a/kernel/initdisk.c b/kernel/initdisk.c index bedf800d..5ee13437 100644 --- a/kernel/initdisk.c +++ b/kernel/initdisk.c @@ -148,6 +148,15 @@ extern UWORD DOSFAR LBA_WRITE_VERIFY; /* the 8.4GB boundary */ #define EXTENDED_LBA 0x0f /* like 0x05, but it is supposed to end past */ +/* Let's play it safe and do not allow partitions with clusters above * + * or equal to 0xff0/0xfff0/0xffffff0 to be created * + * the problem with fff0-fff6 is that they might be interpreted as BAD * + * even though the standard BAD value is ...ff7 */ + +#define FAT12MAX (FAT_MAGIC-7) +#define FAT16MAX (FAT_MAGIC16-7) +#define FAT32MAX (FAT_MAGIC32-7) + #define IsExtPartition(parttyp) ((parttyp) == EXTENDED || \ (parttyp) == EXTENDED_LBA ) @@ -231,6 +240,65 @@ COUNT init_readdasd(UBYTE drive) return 0; } +typedef struct +{ + UWORD bpb_nbyte; /* Bytes per Sector */ + UBYTE bpb_nsector; /* Sectors per Allocation Unit */ + UWORD bpb_nreserved; /* # Reserved Sectors */ + UBYTE bpb_nfat; /* # FAT's */ + UWORD bpb_ndirent; /* # Root Directory entries */ + UWORD bpb_nsize; /* Size in sectors */ + UBYTE bpb_mdesc; /* MEDIA Descriptor Byte */ + UWORD bpb_nfsect; /* FAT size in sectors */ + UWORD bpb_nsecs; /* Sectors per track */ + UWORD bpb_nheads; /* Number of heads */ +} floppy_bpb; + +floppy_bpb floppy_bpbs[5] = { +/* copied from Brian Reifsnyder's FORMAT, bpb.h */ + {SEC_SIZE,2,1,2,112, 720,0xfd,2, 9,2}, /* FD360 5.25 DS */ + {SEC_SIZE,1,1,2,224,2400,0xf9,7,15,2}, /* FD1200 5.25 HD */ + {SEC_SIZE,2,1,2,112,1440,0xf9,3, 9,2}, /* FD720 3.5 LD */ + {SEC_SIZE,1,1,2,224,2880,0xf0,9,18,2}, /* FD1440 3.5 HD */ + {SEC_SIZE,2,1,2,240,5760,0xf0,9,36,2} /* FD2880 3.5 ED */ +}; + +COUNT init_getdriveparm(UBYTE drive, bpb FAR *pbpbarray) +{ + static iregs regs; + + if (drive & 0x80) + return 5; + regs.a.b.h = 0x08; + regs.d.b.l = drive; + init_call_intr(0x13,®s); + if (regs.flags & 1) + return 0; /* return 320-360 for XTs */ + + switch(regs.b.b.l) + { + case 1: /* 320-360 */ + fmemcpy(pbpbarray, &floppy_bpbs[0], sizeof(floppy_bpb)); + return 0; + case 2: /* 1.2 */ + fmemcpy(pbpbarray, &floppy_bpbs[1], sizeof(floppy_bpb)); + return 1; + case 3: /* 720 */ + fmemcpy(pbpbarray, &floppy_bpbs[2], sizeof(floppy_bpb)); + return 2; + case 4: /* 1.44 */ + fmemcpy(pbpbarray, &floppy_bpbs[3], sizeof(floppy_bpb)); + return 7; + case 5: /* 2.88 almost forgot this one*/ + case 6: + fmemcpy(pbpbarray, &floppy_bpbs[4], sizeof(floppy_bpb)); + return 9; + } + /* any odd ball drives return this */ + fmemcpy(pbpbarray, &floppy_bpbs[0], sizeof(floppy_bpb)); + return 8; +} + /* translate LBA sectors into CHS addressing copied and pasted from dsk.c! @@ -280,11 +348,11 @@ VOID CalculateFATData(ddt FAR *pddt, ULONG NumSectors, UBYTE FileSystem) /* FAT related items */ defbpb->bpb_nfat = 2; - defbpb->bpb_ndirent = 512; /* normal value of number of entries in root dir - should be 0 for FAT32 drives */ - defbpb->bpb_nreserved = 1; /* 0x20 for FAT32 */ + defbpb->bpb_ndirent = (FileSystem == FAT32 || FileSystem == FAT32_LBA) ? 0 : 512; + /* normal value of number of entries in root dir */ + defbpb->bpb_nreserved = (FileSystem == FAT32 || FileSystem == FAT32_LBA) ? 0x20 : 1; - fatdata = NumSectors - cdiv (defbpb->bpb_ndirent * 32, defbpb->bpb_nbyte) - + fatdata = NumSectors - cdiv (defbpb->bpb_ndirent * DIRENT_SIZE, defbpb->bpb_nbyte) - defbpb->bpb_nreserved; maxclustsize = 128; #ifdef DEBUG @@ -299,10 +367,10 @@ VOID CalculateFATData(ddt FAR *pddt, ULONG NumSectors, UBYTE FileSystem) defbpb->bpb_nsector = 8; /* Force maximal fatdata=32696 sectors since with our only possible sector size (512 bytes) this is the maximum for 4k clusters. - #clus*secperclus+#fats*fatlength= 4084 * 8 + 2 * 12 = 32696. + #clus*secperclus+#fats*fatlength= 4077 * 8 + 2 * 12 = 32640. max FAT12 size for FreeDOS = 16,728,064 bytes */ - if (fatdata > 32696) - fatdata = 32696; + if (fatdata > 32640) + fatdata = 32640; /* The factor 2 below avoids cut-off errors for nr_fats == 1. * The "defbpb->bpb_nfat*3" is for the reserved first two FAT entries */ clust = 2*((ULONG) fatdata * defbpb->bpb_nbyte + defbpb->bpb_nfat*3) / @@ -313,10 +381,10 @@ VOID CalculateFATData(ddt FAR *pddt, ULONG NumSectors, UBYTE FileSystem) * not really present cluster. */ clust = (fatdata - defbpb->bpb_nfat*fatlength)/defbpb->bpb_nsector; maxclust = (fatlength * 2 * defbpb->bpb_nbyte) / 3; - if (maxclust > FAT_MAGIC) - maxclust = FAT_MAGIC; + if (maxclust > FAT12MAX) + maxclust = FAT12MAX; DebugPrintf(( "FAT12: #clu=%lu, fatlen=%lu, maxclu=%lu, limit=%u\n", - clust, fatlength, maxclust, FAT_MAGIC )); + clust, fatlength, maxclust, FATMAX12 )); if (clust > maxclust-2) { clust = maxclust-2; DebugPrintf(( "FAT12: too many clusters: setting to maxclu-2\n" )); @@ -333,10 +401,10 @@ VOID CalculateFATData(ddt FAR *pddt, ULONG NumSectors, UBYTE FileSystem) /* Force maximal fatdata=8387584 sectors (NumSectors=8387617) since with our only possible sectorsize (512 bytes) this is the maximum we can address with 64k clusters - #clus*secperclus+#fats*fatlength=65524 * 128 + 2 * 256=8387584. - max FAT16 size for FreeDOS = 4,294,180,864 bytes = 4GiB-786,432 */ - if (fatdata > 8387584ul) - fatdata = 8387584ul; + #clus*secperclus+#fats*fatlength=65517 * 128 + 2 * 256=8386688. + max FAT16 size for FreeDOS = 4,293,984,256 bytes = 4GiB-983,040 */ + if (fatdata > 8386688ul) + fatdata = 8386688ul; do { DebugPrintf(( "Trying with %d sectors/cluster:\n", defbpb->bpb_nsector )); @@ -348,8 +416,8 @@ VOID CalculateFATData(ddt FAR *pddt, ULONG NumSectors, UBYTE FileSystem) * not really present cluster. */ clust = (fatdata - defbpb->bpb_nfat*fatlength)/defbpb->bpb_nsector; maxclust = (fatlength * defbpb->bpb_nbyte) / 2; - if (maxclust > FAT_MAGIC16) - maxclust = FAT_MAGIC16; + if (maxclust > FAT16MAX) + maxclust = FAT16MAX; DebugPrintf(( "FAT16: #clu=%lu, fatlen=%lu, maxclu=%lu, limit=%u\n", clust, fatlength, maxclust, FAT_MAGIC16 )); if (clust > maxclust-2) { @@ -372,10 +440,11 @@ VOID CalculateFATData(ddt FAR *pddt, ULONG NumSectors, UBYTE FileSystem) #ifdef WITHFAT32 case FAT32: + case FAT32_LBA: /* For FAT32, use 4k clusters on sufficiently large file systems, * otherwise 1 sector per cluster. This is also what M$'s format * command does for FAT32. */ - defbpb->bpb_nsector = (NumSectors >= 512*1024 ? 8 : 1); + defbpb->bpb_nsector = (NumSectors >= 512*1024ul ? 8 : 1); do { /* simple calculation - no long long available */ clust = (ULONG)fatdata / defbpb->bpb_nsector; @@ -389,11 +458,11 @@ VOID CalculateFATData(ddt FAR *pddt, ULONG NumSectors, UBYTE FileSystem) * not really present cluster. */ clust = (fatdata - defbpb->bpb_nfat*fatlength)/defbpb->bpb_nsector; maxclust = (fatlength * defbpb->bpb_nbyte) / 4; - if (maxclust > FAT_MAGIC32) - maxclust = FAT_MAGIC32; + if (maxclust > FAT32MAX) + maxclust = FAT32MAX; DebugPrintf(( "FAT32: #clu=%u, fatlen=%u, maxclu=%u, limit=%u\n", - clust, fatlength, maxclust, FAT_MAGIC32 )); - if (clust > maxclust) + clust, fatlength, maxclust, FATMAX32 )); + if (clust > maxclust-2) { clust = 0; DebugPrintf(( "FAT32: too many clusters\n" )); @@ -404,6 +473,12 @@ VOID CalculateFATData(ddt FAR *pddt, ULONG NumSectors, UBYTE FileSystem) } while (defbpb->bpb_nsector && defbpb->bpb_nsector <= maxclustsize); defbpb->bpb_nfsect = 0; defbpb->bpb_xnfsect = fatlength; + /* set up additional FAT32 fields */ + defbpb->bpb_xflags = 0; + defbpb->bpb_xfsversion = 0; + defbpb->bpb_xrootclst = 2; + defbpb->bpb_xfsinfosec = 1; + defbpb->bpb_xbackupsec = 6; fmemcpy(pddt->ddt_fstype, MSDOS_FAT32_SIGN, 8); break; #endif @@ -413,7 +488,7 @@ VOID CalculateFATData(ddt FAR *pddt, ULONG NumSectors, UBYTE FileSystem) void DosDefinePartition(struct DriveParamS *driveParam, - ULONG StartSector, struct PartTableEntry *pEntry) + ULONG StartSector, struct PartTableEntry *pEntry, int extendedPartNo, int PrimaryNum) { ddt FAR *pddt = DynAlloc("ddt", 1, sizeof(ddt)); struct CHS chs; @@ -452,22 +527,32 @@ void DosDefinePartition(struct DriveParamS *driveParam, pddt->ddt_serialno = 0x12345678l; /* drive inaccessible until bldbpb successful */ pddt->ddt_descflags = init_readdasd(pddt->ddt_driveno) | DF_NOACCESS; + pddt->ddt_type = 5; fmemcpy(&pddt->ddt_bpb, &pddt->ddt_defbpb, sizeof(bpb)); -#ifdef _BETA_ /* Alain whishes to keep this in later versions, too */ - LBA_to_CHS(&chs,StartSector,driveParam); + /* Alain whishes to keep this in later versions, too + Tom likes this too, so he made it configurable by SYS CONFIG ... + */ - printf("%c: disk %02x", - 'A' + nUnits, - driveParam->driveno); + if (InitKernelConfig.InitDiskShowDriveAssignment) + { + LBA_to_CHS(&chs,StartSector,driveParam); + + printf("%c: HD%d", + 'A' + nUnits, + (driveParam->driveno & 0x7f)+1); + + if (extendedPartNo) printf(" Ext:%d", extendedPartNo); + else printf(" Pri:%d", PrimaryNum + 1); + + printCHS(" CHS= ",&chs); + + printf(" start = %5luMB,size =%5lu", + StartSector/2048,pEntry->NumSect/2048); + + printf("\n"); + } - printCHS(" CHS= ",&chs); - - printf(" start = %5luMB,size =%5lu", - StartSector/2048,pEntry->NumSect/2048); - - printf("\n"); -#endif nUnits++; @@ -660,7 +745,7 @@ ConvPartTableEntryToIntern(struct PartTableEntry *pEntry, UBYTE FAR * pDisk) ScanForPrimaryPartitions(struct DriveParamS *driveParam,int scan_type, struct PartTableEntry *pEntry, ULONG startSector, - int partitionsToIgnore + int partitionsToIgnore, int extendedPartNo ) { int i; @@ -755,7 +840,7 @@ ScanForPrimaryPartitions(struct DriveParamS *driveParam,int scan_type, } /* else its a diagnostic message only */ -#ifdef _BETA_ +#ifdef DEBUG printf("found and using LBA partition %u FS %02x", i, pEntry->FileSystem); printCHS(" start ",&chs); @@ -771,7 +856,8 @@ ScanForPrimaryPartitions(struct DriveParamS *driveParam,int scan_type, partitionsToIgnore |= 1 << i; - DosDefinePartition(driveParam,partitionStart, pEntry); + DosDefinePartition(driveParam,partitionStart, pEntry, + extendedPartNo, i); if (scan_type == SCAN_PRIMARYBOOT || scan_type == SCAN_PRIMARY ) @@ -912,7 +998,7 @@ int ProcessDisk(int scanType, unsigned drive, int PartitionsToIgnore) { PartitionsToIgnore = ScanForPrimaryPartitions(&driveParam,scanType, - PTable, RelSectorOffset,PartitionsToIgnore); + PTable, RelSectorOffset,PartitionsToIgnore,num_extended_found); } if (scanType != SCAN_EXTENDED) @@ -1075,48 +1161,33 @@ I don't know, if I did it right, but I tried to do it that way. TE ***********************************************************************/ - - void ReadAllPartitionTables(void) { UBYTE foundPartitions[MAX_HARD_DRIVE]; int HardDrive; int nHardDisk = BIOS_nrdrives(); - bpb FAR *pbpbarray; int Unit; ddt FAR *pddt; static iregs regs; - /* Setup media info and BPBs arrays for floppies (this is a 360kb flop) */ + /* Setup media info and BPBs arrays for floppies */ for (Unit = 0; Unit < nUnits; Unit++) { pddt = DynAlloc("ddt", 1, sizeof(ddt)); - pbpbarray = &pddt->ddt_defbpb; - - pbpbarray->bpb_nbyte = SEC_SIZE; - pbpbarray->bpb_nsector = 2; - pbpbarray->bpb_nreserved = 1; - pbpbarray->bpb_nfat = 2; - pbpbarray->bpb_ndirent = 112; - pbpbarray->bpb_nsize = 360*2; - pbpbarray->bpb_mdesc = 0xfd; - pbpbarray->bpb_nfsect = 2; - pbpbarray->bpb_nheads = 2; - pbpbarray->bpb_nsecs = 9; - pddt->ddt_driveno = 0; pddt->ddt_logdriveno = Unit; - pddt->ddt_ncyl = 40; + pddt->ddt_type = init_getdriveparm(0, &pddt->ddt_defbpb); + pddt->ddt_ncyl = (pddt->ddt_type & 7) ? 80 : 40; pddt->ddt_LBASupported = FALSE; pddt->ddt_descflags = init_readdasd(0); pddt->ddt_offset = 0l; pddt->ddt_serialno = 0x12345678l; - fmemcpy(&pddt->ddt_bpb, pbpbarray, sizeof(bpb)); - } - + fmemcpy(&pddt->ddt_bpb, &pddt->ddt_defbpb, sizeof(bpb)); + } + /* this is a quick patch - see if B: exists test for A: also, need not exist @@ -1124,7 +1195,9 @@ void ReadAllPartitionTables(void) init_call_intr(0x11,®s); /* get equipment list */ if ((regs.a.x & 1) && (regs.a.x & 0xc0)) { pddt->ddt_driveno = 1; + pddt->ddt_type = init_getdriveparm(1, &pddt->ddt_defbpb); pddt->ddt_descflags = init_readdasd(1); + pddt->ddt_ncyl = (pddt->ddt_type & 7) ? 80 : 40; /* floppy drives installed and a B: drive */ /*if ((r.a.x & 1)==0) */ /* no floppy drives installed */ } else { /* set up the DJ method : multiple logical drives */ @@ -1145,28 +1218,57 @@ void ReadAllPartitionTables(void) for (HardDrive = 0; HardDrive < nHardDisk; HardDrive++) BIOS_drive_reset(HardDrive); - - /* Process primary partition table 1 partition only */ - for (HardDrive = 0; HardDrive < nHardDisk; HardDrive++) + + + if (InitKernelConfig.DLASortByDriveNo == 0) { - foundPartitions[HardDrive] = - ProcessDisk(SCAN_PRIMARYBOOT, HardDrive, 0); + /* printf("Drive Letter Assignment - DOS order \n"); */ + + + /* Process primary partition table 1 partition only */ + for (HardDrive = 0; HardDrive < nHardDisk; HardDrive++) + { + foundPartitions[HardDrive] = + ProcessDisk(SCAN_PRIMARYBOOT, HardDrive, 0); + + if (foundPartitions[HardDrive] == 0) + foundPartitions[HardDrive] = ProcessDisk(SCAN_PRIMARY, HardDrive, 0); + } - if (foundPartitions[HardDrive] == 0) - foundPartitions[HardDrive] = ProcessDisk(SCAN_PRIMARY, HardDrive, 0); + /* Process extended partition table */ + for (HardDrive = 0; HardDrive < nHardDisk; HardDrive++) + { + ProcessDisk(SCAN_EXTENDED, HardDrive , 0); + } + + /* Process primary a 2nd time */ + for (HardDrive = 0; HardDrive < nHardDisk; HardDrive++) + { + ProcessDisk(SCAN_PRIMARY2, HardDrive ,foundPartitions[HardDrive]); + } } - - /* Process extended partition table */ - for (HardDrive = 0; HardDrive < nHardDisk; HardDrive++) + else { - ProcessDisk(SCAN_EXTENDED, HardDrive , 0); - } + printf("Drive Letter Assignment - sorted by drive\n"); + + + /* Process primary partition table 1 partition only */ + for (HardDrive = 0; HardDrive < nHardDisk; HardDrive++) + { + foundPartitions[HardDrive] = + ProcessDisk(SCAN_PRIMARYBOOT, HardDrive, 0); + + if (foundPartitions[HardDrive] == 0) + foundPartitions[HardDrive] = ProcessDisk(SCAN_PRIMARY, HardDrive, 0); - /* Process primary a 2nd time */ - for (HardDrive = 0; HardDrive < nHardDisk; HardDrive++) - { - ProcessDisk(SCAN_PRIMARY2, HardDrive ,foundPartitions[HardDrive]); - } + /* Process extended partition table */ + ProcessDisk(SCAN_EXTENDED, HardDrive , 0); + + + /* Process primary a 2nd time */ + ProcessDisk(SCAN_PRIMARY2, HardDrive ,foundPartitions[HardDrive]); + } + } } /* disk initialization: returns number of units */ diff --git a/kernel/int2f.asm b/kernel/int2f.asm index d73bdba7..6f89f123 100644 --- a/kernel/int2f.asm +++ b/kernel/int2f.asm @@ -30,6 +30,9 @@ ; $Id$ ; ; $Log$ +; Revision 1.14 2001/11/04 19:47:39 bartoldeman +; kernel 2025a changes: see history.txt +; ; Revision 1.13 2001/09/23 20:39:44 bartoldeman ; FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling ; @@ -200,161 +203,254 @@ IntDosCal: iret - - ; Int 2F Multipurpose Remote System Calls ; ; added by James Tabor jimtabor@infohwy.com +; changed by Bart Oldeman ; -; int_2f_Remote_call(ax,bx,cx,dx,[es:di],si, return data * ptr) ; assume ss == ds after setup of stack in entry ; sumtimes return data *ptr is the push stack word -; - global _int2f_Remote_call -_int2f_Remote_call: +; + + global _remote_rmdir +_remote_rmdir: + mov al, 01h + jmp short call_int2f + + global _remote_mkdir +_remote_mkdir: + mov al, 03h + jmp short call_int2f + + global _remote_chdir +_remote_chdir: + mov al, 05h + jmp short call_int2f + + global _remote_close +_remote_close: + mov al, 06h + jmp short call_int2f + + global _remote_read +_remote_read: mov al, 08h + jmp short call_int2f + + global _remote_write +_remote_write: mov al, 09h + jmp short call_int2f + + global _remote_getfree +_remote_getfree: + mov al, 0ch + jmp short call_int2f + + global _remote_setfattr +_remote_setfattr: + mov al, 0eh + jmp short call_int2f + + global _remote_getfattr +_remote_getfattr: + mov al, 0fh + jmp short call_int2f + + global _remote_rename +_remote_rename: + mov al, 11h + jmp short call_int2f + + global _remote_delete +_remote_delete: + mov al, 13h + jmp short call_int2f + + global _remote_open +_remote_open: + mov al, 16h + jmp short call_int2f + + global _remote_creat +_remote_creat: + mov al, 17h + jmp short call_int2f + + global _remote_findfirst +_remote_findfirst: + mov al, 1bh + jmp short call_int2f + + global _remote_findnext +_remote_findnext: + mov al, 1ch + jmp short call_int2f + + global _remote_close_all +_remote_close_all: + mov al, 1dh + jmp short call_int2f + + global _remote_doredirect +_remote_doredirect: + mov al, 1eh + jmp short call_int2f + + global _remote_printset +_remote_printset: + mov al, 1fh + jmp short call_int2f + + global _remote_flushall +_remote_flushall: + mov al, 20h + jmp short call_int2f + + global _remote_lseek +_remote_lseek: + mov al, 21h + jmp short call_int2f + + global _QRemote_Fn +_QRemote_Fn + mov al, 23h + jmp short call_int2f + + global _remote_printredir +_remote_printredir: + mov al, 25h + +call_int2f: + mov ah, 11h push bp mov bp,sp push es - push ds push si push di push dx push cx push bx - push ss ; hay, did I say assume - pop ds - - mov si,[bp+16] - les di,[bp+12] - mov dx,[bp+10] - mov cx,[bp+8] - mov bx,[bp+6] - mov ax,[bp+4] - - cmp al,08h ; R/W Remote File - je short int2f_r_1 - cmp al,09h - jne short int2f_r_2 -int2f_r_1: - call int2f_call - jnc short int2f_skip1 - jmp int2f_rfner -int2f_skip1: - xor ax,ax - les di,[bp+18] ; do return data stuff - mov [es:di],cx - jmp int2f_rfner -int2f_r_2: - cmp al,0ch ; Get Remote DPB - jne short int2f_r_3 - call int2f_call - jc int2f_rfner - les di,[bp+18] - mov [es:di+0],ax - mov [es:di+2],bx - mov [es:di+4],cx - mov [es:di+6],dx - xor ax,ax - jmp short int2f_rfner -int2f_r_3: - cmp al,0fh ; Get Remote File Attrib - jne short int2f_r_4 - call int2f_call - jc short int2f_rfner - mov si,di - les di,[bp+18] ; pointer to struct - mov [es:di+0],ax - mov [es:di+2],si ; lo - mov [es:di+4],bx ; high - mov [es:di+6],cx - mov [es:di+8],dx - xor ax,ax - jmp short int2f_rfner -int2f_r_4: - cmp al,01eh - je short int2f_r_5 - cmp al,01fh - jne short int2f_r_6 -int2f_r_5: - push ds - push word [bp+20] - pop ds - call int2f_call - pop ds - jc short int2f_rfner - xor ax,ax - jmp short int2f_rfner -int2f_r_6: - cmp al,021h ; Lseek from eof - jne short int2f_r_7 - call int2f_call - jc short int2f_rfner - les di,[bp+18] - mov [es:di],ax - mov [es:di+2],dx - xor ax,ax - jmp short int2f_rfner -int2f_r_7: - cmp al,022h ; Terminate process - jne short int2f_r_8 - mov ds,[_cu_psp] - call int2f_call - jmp short int2f_rfner -; -; everything else goes through here. -; -int2f_r_8: - call int2f_call - jc int2f_rfner + cmp al, 0eh + je remote_setfattr + cmp al, 0fh + je remote_getfattr + cmp al, 1eh + je print_doredir + cmp al, 1fh + je print_doredir + cmp al, 21h ; 21h, Lseek from eof + je lseekeof + cmp al, 23h + je qremote_fn + cmp al, 25h + je remote_printredir + + les di, [bp+4] + cmp al, 08h + je remote_rw + cmp al, 09h + je remote_rw + cmp al, 0ch + je remote_getfree + +int2f_call_push: + push word [bp+8] ; very fakey, HaHa ;) +int2f_call: + stc ; set to fail + int 2fh + pop bx + jc no_clear_ax +clear_ax: xor ax,ax -int2f_rfner: +no_clear_ax: + neg ax +no_neg_ax: pop bx pop cx pop dx pop di pop si - pop ds pop es pop bp ret -; -; Pull this one out of the Chain. -; - global _QRemote_Fn -_QRemote_Fn - push bp - mov bp,sp - push es + +lseekeof: + mov dx, [bp+8] + mov cx, [bp+10] + jmp int2f_call_push + +remote_getfattr: + stc ; set to fail + int 2fh + jc no_clear_ax + jmp short no_neg_ax + +remote_setfattr: + push word [bp+4] + jmp short int2f_call + +print_doredir: push ds - push si - push di - mov ax,1123h + mov si,[bp+14] + les di,[bp+10] + mov dx,[bp+8] + mov cx,[bp+6] + mov bx,[bp+4] + + mov ds, [bp+18] + push word [bp+16] ; very fakey, HaHa ;) + stc ; set to fail + int 2fh + pop bx + pop ds + jc no_clear_ax + jmp short clear_ax + +remote_getfree: + stc ; set to fail + int 2fh + jc no_clear_ax + mov di,[bp+8] + mov [di],ax + mov [di+2],bx + mov [di+4],cx + mov [di+6],dx + jmp short clear_ax + +remote_printredir: + mov dx, [bp+4] + push word [bp+6] + jmp short int2f_call + +qremote_fn: lds si,[bp+4] les di,[bp+8] stc int 2fh mov ax,0xffff - jc QRemote_Fn_out - xor ax,ax -QRemote_Fn_out: - pop di - pop si - pop ds - pop es - pop bp - ret - + jc no_neg_ax + jmp short clear_ax -int2f_call: - push bp - push word [bp+18] ; very fakey, HaHa ;) +remote_rw: mov cx, [bp+8] stc ; set to fail int 2fh - pop bp - pop bp - ret + jc int2f_carry + xor ax, ax +int2f_carry: neg ax + mov di, [bp+10] + mov [di], ax + mov ax, cx + jmp short no_neg_ax + global _remote_process_end +_remote_process_end: ; Terminate process + mov ds, [_cu_psp] + mov al, 22h + call call_int2f + push ss + pop ds + ret + %if 0 ; int_2f_111e_call(iregs FAR *iregs) ; diff --git a/kernel/inthndlr.c b/kernel/inthndlr.c index 7b3161c7..38d1403c 100644 --- a/kernel/inthndlr.c +++ b/kernel/inthndlr.c @@ -37,6 +37,9 @@ BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.32 2001/11/04 19:47:39 bartoldeman + * kernel 2025a changes: see history.txt + * * Revision 1.31 2001/09/23 20:39:44 bartoldeman * FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling * @@ -301,14 +304,22 @@ VOID ASMCFUNC int21_syscall(iregs FAR * irp) { /* Get Ctrl-C flag */ case 0x00: - irp->DL = break_ena ? TRUE : FALSE; + irp->DL = break_ena; break; /* Set Ctrl-C flag */ case 0x01: - break_ena = irp->DL ? TRUE : FALSE; + break_ena = irp->DL != 0; break; + case 0x02: /* andrew schulman: get/set extended control break */ + { + UBYTE tmp = break_ena; + irp->DL = break_ena; + break_ena = tmp != 0; + } + + /* Get Boot Drive */ case 0x05: irp->DL = BootDrive; @@ -322,8 +333,6 @@ VOID ASMCFUNC int21_syscall(iregs FAR * irp) irp->DH = version_flags; /* bit3:runs in ROM,bit 4: runs in HMA*/ break; - case 0x02: /* andrew schulman: get/set extended control break - should be done */ case 0x03: /* DOS 7 does not set AL */ case 0x07: /* neither here */ @@ -377,9 +386,7 @@ VOID ASMCFUNC int21_syscall(iregs FAR * irp) VOID ASMCFUNC int21_service(iregs FAR * r) { - COUNT rc = 0, - rc1; - psp FAR *p = MK_FP(cu_psp, 0); + COUNT rc = 0; void FAR *FP_DS_DX = MK_FP(r->DS, r->DX); /* this is saved so often, that this saves ~100 bytes */ @@ -387,7 +394,7 @@ VOID ASMCFUNC int21_service(iregs FAR * r) #define CLEAR_CARRY_FLAG() r->FLAGS &= ~FLG_CARRY #define SET_CARRY_FLAG() r->FLAGS |= FLG_CARRY - p->ps_stack = (BYTE FAR *) r; + ((psp FAR *)MK_FP(cu_psp, 0))->ps_stack = (BYTE FAR *) r; #ifdef DEBUG if (bDumpRegs) @@ -785,13 +792,10 @@ VOID ASMCFUNC int21_service(iregs FAR * r) /* Set Date */ case 0x2b: rc = DosSetDate( - (BYTE FAR *) & (r->DH), /* Month */ - (BYTE FAR *) & (r->DL), /* MonthDay */ - (COUNT FAR *) & (r->CX)); /* Year */ - if (rc != SUCCESS) - r->AL = 0xff; - else - r->AL = 0; + r->DH, /* Month */ + r->DL, /* MonthDay */ + r->CX); /* Year */ + r->AL = (rc != SUCCESS ? 0xff : 0); break; /* Get Time */ @@ -806,14 +810,11 @@ VOID ASMCFUNC int21_service(iregs FAR * r) /* Set Date */ case 0x2d: rc = DosSetTime( - (BYTE FAR *) & (r->CH), /* Hour */ - (BYTE FAR *) & (r->CL), /* Minutes */ - (BYTE FAR *) & (r->DH), /* Seconds */ - (BYTE FAR *) & (r->DL)); /* Hundredths */ - if (rc != SUCCESS) - r->AL = 0xff; - else - r->AL = 0; + r->CH, /* Hour */ + r->CL, /* Minutes */ + r->DH, /* Seconds */ + r->DL); /* Hundredths */ + r->AL = (rc != SUCCESS ? 0xff : 0); break; /* Set verify flag */ @@ -1048,20 +1049,16 @@ VOID ASMCFUNC int21_service(iregs FAR * r) /* Dos Read */ case 0x3f: - rc1 = DosRead(r->BX, r->CX, FP_DS_DX, (COUNT FAR *) & rc); + r->AX = DosRead(r->BX, r->CX, FP_DS_DX, (COUNT FAR *) & rc); if (rc != SUCCESS) goto error_exit; - else - r->AX = rc1; break; /* Dos Write */ case 0x40: - rc1 = DosWrite(r->BX, r->CX, FP_DS_DX, (COUNT FAR *) & rc); + r->AX = DosWrite(r->BX, r->CX, FP_DS_DX, (COUNT FAR *) & rc); if (rc != SUCCESS) goto error_exit; - else - r->AX = rc1; break; /* Dos Delete File */ @@ -1075,7 +1072,7 @@ VOID ASMCFUNC int21_service(iregs FAR * r) case 0x42: { ULONG lrc; - if ((rc = DosSeek(r->BX, (LONG) ((((LONG) (r->CX)) << 16) + r->DX), r->AL, &lrc)) < 0) + if ((rc = DosSeek(r->BX, (LONG) ((((LONG) (r->CX)) << 16) | r->DX), r->AL, &lrc)) < 0) goto error_exit; else { @@ -1243,13 +1240,8 @@ VOID ASMCFUNC int21_service(iregs FAR * r) /* dta for this call is set on entry. This */ /* needs to be changed for new versions. */ if ((rc = DosFindNext()) < 0) - { - if (rc == DE_FILENOTFND) - rc = DE_NFILES; goto error_exit; - } - else - r->AX = -SUCCESS; + r->AX = -SUCCESS; break; /* case 0x50: @@ -1363,10 +1355,12 @@ VOID ASMCFUNC int21_service(iregs FAR * r) break; case 0x03: - if (uppermem_root) { + if (uppermem_root) /* always error if not exists */ + { DosUmbLink(r->BL); break; - } /* else fall through */ + } + /* else fall through */ default: goto error_invalid; @@ -1463,7 +1457,7 @@ VOID ASMCFUNC int21_service(iregs FAR * r) case 0x07: case 0x08: case 0x09: - rc = -int2f_Remote_call(REM_PRINTREDIR, 0, 0, r->DX, 0, 0, (MK_FP(0, Int21AX))); + rc = remote_printredir(r->DX, Int21AX); if (rc != SUCCESS) goto error_exit; CLEAR_CARRY_FLAG(); @@ -1486,7 +1480,7 @@ VOID ASMCFUNC int21_service(iregs FAR * r) break; default: - rc = -int2f_Remote_call(REM_PRINTSET, r->BX, r->CX, r->DX, (MK_FP(r->ES, r->DI)), r->SI, (MK_FP(r->DS, Int21AX))); + rc = remote_printset(r->BX, r->CX, r->DX, (MK_FP(r->ES, r->DI)), r->SI, (MK_FP(r->DS, Int21AX))); if (rc != SUCCESS) goto error_exit; r->AX=SUCCESS; break; @@ -1515,7 +1509,7 @@ VOID ASMCFUNC int21_service(iregs FAR * r) int_2f_111e_call(r); break;*/ - rc = -int2f_Remote_call(REM_DOREDIRECT, r->BX, r->CX, r->DX, + rc = remote_doredirect(r->BX, r->CX, r->DX, (MK_FP(r->ES, r->DI)), r->SI, (MK_FP(r->DS, Int21AX))); if (rc != SUCCESS) goto error_exit; @@ -1561,21 +1555,17 @@ VOID ASMCFUNC int21_service(iregs FAR * r) /* UNDOCUMENTED: Double byte and korean tables */ case 0x63: { -#define DBLBYTE -#ifdef DBLBYTE - static char dbcsTable[2] = + static char dbcsTable[4] = { - 0, 0 + 0, 0, 0, 0 }; - void FAR *dp = &dbcsTable; - - r->DS = FP_SEG(dp); - r->SI = FP_OFF(dp); - r->AL = 0; -#else + r->DS = FP_SEG(&dbcsTable); + r->SI = FP_OFF(&dbcsTable); +#if 0 /* not really supported, but will pass. */ r->AL = 0x00; /*jpp: according to interrupt list */ - /*Bart: fails for PQDI: use the above again */ + /*Bart: fails for PQDI and WATCOM utilities: + use the above again */ #endif break; } @@ -1819,17 +1809,31 @@ VOID ASMCFUNC int21_service(iregs FAR * r) { DWORD nfreeclst = xdffp->xdff_f.setdpbcounts.nfreeclst; DWORD cluster = xdffp->xdff_f.setdpbcounts.cluster; - if ((dpb->dpb_xfsinfosec == 0xffff && (nfreeclst != 0 || + if (ISFAT32(dpb)) + { + if ((dpb->dpb_xfsinfosec == 0xffff && (nfreeclst != 0 || cluster != 0)) || - nfreeclst == 1 || nfreeclst > dpb->dpb_size || + nfreeclst == 1 || nfreeclst > dpb->dpb_xsize || + cluster == 1 || cluster > dpb->dpb_xsize) + { + r->AX = -DE_INVLDPARM; + goto error_out; + } + dpb->dpb_xnfreeclst = nfreeclst; + dpb->dpb_xcluster = cluster; + write_fsinfo(dpb); + } + else + { + if (nfreeclst == 1 || nfreeclst > dpb->dpb_size || cluster == 1 || cluster > dpb->dpb_size) { r->AX = -DE_INVLDPARM; goto error_out; } - dpb->dpb_nfreeclst = nfreeclst; - dpb->dpb_cluster = cluster; - write_fsinfo(dpb); + dpb->dpb_nfreeclst = nfreeclst; + dpb->dpb_cluster = cluster; + } break; } case 0x01: @@ -1856,13 +1860,14 @@ VOID ASMCFUNC int21_service(iregs FAR * r) struct buffer FAR *bp; bpb FAR *bpbp; DWORD newmirroring = xdffp->xdff_f.setmirroring.newmirroring; - if (newmirroring != -1 && newmirroring & ~(0xf | 0x80)) + + if (newmirroring != -1 && (ISFAT32(dpb) && (newmirroring & ~(0xf | 0x80)))) { r->AX = -DE_INVLDPARM; goto error_out; } - xdffp->xdff_f.setmirroring.oldmirroring = dpb->dpb_xflags; - if (newmirroring != -1) + xdffp->xdff_f.setmirroring.oldmirroring = (ISFAT32(dpb) ? dpb->dpb_xflags : 0); + if (newmirroring != -1 && ISFAT32(dpb)) { bp = getblock(1, dpb->dpb_unit); bp->b_flag &= ~(BFR_DATA | BFR_DIR | BFR_FAT); @@ -1877,8 +1882,8 @@ VOID ASMCFUNC int21_service(iregs FAR * r) struct buffer FAR *bp; bpb FAR *bpbp; DWORD rootclst = xdffp->xdff_f.setroot.newrootclst; - if (rootclst != -1 && (rootclst == 1 || - rootclst > dpb->dpb_size)) + if (!ISFAT32(dpb) || (rootclst != -1 && (rootclst == 1 || + rootclst > dpb->dpb_xsize))) { r->AX = -DE_INVLDPARM; goto error_out; @@ -2115,19 +2120,52 @@ VOID ASMCFUNC int2F_12_handler(struct int2f12regs r) case 0x03: /* get DOS data segment */ r.ds = FP_SEG(&nul_dev); - break; + break; + + case 0x06: /* invoke critical error */ + + /* code, drive number, error, device header */ + r.ax &= 0xff00; + r.ax |= CriticalError( + r.callerARG1 >> 8, + (r.callerARG1 & (EFLG_CHAR << 8)) ? 0 : r.callerARG1 & 0xff, + r.di, + MK_FP(r.bp,r.si)); + break; case 0x08: /* decrease SFT reference count */ { - UWORD FAR *SFTp = MK_FP(r.es,r.di); + sft FAR *p = MK_FP(r.es,r.di); - r.ax = *SFTp; - - if (--*SFTp == 0) --*SFTp; + r.ax = p->sft_count; + if (--p->sft_count == 0) --p->sft_count; } break; + case 0x0c: /* perform "device open" for device, set owner for FCB */ + + if (lpCurSft->sft_flags & SFT_FDEVICE) + { + request rq; + + rq.r_unit = 0; + rq.r_status = 0; + rq.r_command = C_OPEN; + rq.r_length = sizeof(request); + execrh((request FAR *) & rq, lpCurSft->sft_dev); + } + + /* just do it always, not just for FCBs */ + lpCurSft->sft_psp = cu_psp; + break; + + case 0x0d: /* get dos date/time */ + + r.ax = dos_getdate(); + r.dx = dos_gettime(); + break; + case 0x12: /* get length of asciiz string */ r.cx = fstrlen(MK_FP(r.es, r.di))+1; @@ -2135,6 +2173,44 @@ VOID ASMCFUNC int2F_12_handler(struct int2f12regs r) break; + case 0x16: /* get address of system file table entry - used by NET.EXE + BX system file table entry number ( such as returned from 2F/1220) + returns + ES:DI pointer to SFT entry */ + { + sft FAR *p = get_sft(r.bx); + + r.es = FP_SEG(p); + r.di = FP_OFF(p); + break; + } + + case 0x17: /* get current directory structure for drive - used by NET.EXE + STACK: drive (0=A:,1=B,...) + ; returns + ; CF set if error + ; DS:SI pointer to CDS for drive + ; + ; called like + ; push 2 (c-drive) + ; mov ax,1217 + ; int 2f + ; + ; probable use: get sizeof(CDSentry) + */ + { + UWORD drv = r.callerARG1 & 0xff; + + if (drv >= lastdrive) + r.flags |= FLG_CARRY; + else + { + r.ds = FP_SEG(CDSp); + r.si = FP_OFF(&CDSp->cds_table[drv]); + r.flags &= ~FLG_CARRY; + } + break; + } case 0x18: /* get caller's registers */ @@ -2152,6 +2228,25 @@ VOID ASMCFUNC int2F_12_handler(struct int2f12regs r) truename(MK_FP(r.ds,r.si), MK_FP(r.es,r.di),0); break; + + case 0x23: /* check if character device */ + { + struct dhdr FAR *dhp; + + dhp = IsDevice((BYTE FAR *)DirEntBuffer.dir_name); + + if (dhp) + { + r.bx = (r.bx & 0xff) | (dhp->dh_attr <<8); + r.flags &= ~FLG_CARRY; + } + else { + r.flags |= FLG_CARRY; + } + + } + + break; case 0x25: /* get length of asciiz string */ @@ -2178,48 +2273,11 @@ VOID ASMCFUNC int2F_12_handler(struct int2f12regs r) doesn't work!! */ break; - case 0x16: /* get address of system file table entry - used by NET.EXE - BX system file table entry number ( such as returned from 2F/1220) - returns - ES:DI pointer to SFT entry */ - { - sft FAR *p = get_sft(r.bx); - - r.es = FP_SEG(p); - r.di = FP_OFF(p); + default: + printf("unimplemented internal dos function INT2F/12%02x\n",function); + r.flags |= FLG_CARRY; break; - } - - case 0x17: /* get current directory structure for drive - used by NET.EXE - STACK: drive (0=A:,1=B,...) - ; returns - ; CF set if error - ; DS:SI pointer to CDS for drive - ; - ; called like - ; push 2 (c-drive) - ; mov ax,1217 - ; int 2f - ; - ; probable use: get sizeof(CDSentry) - */ - { - UWORD drv = r.callerARG1 & 0xff; - - if (drv >= lastdrive) - r.flags |= FLG_CARRY; - else - { - r.ds = FP_SEG(CDSp); - r.si = FP_OFF(&CDSp->cds_table[drv]); - r.flags &= ~FLG_CARRY; - } - break; - } - default: - printf("unknown internal dos function INT2F/12%02x\n",function); - - } + } } diff --git a/kernel/io.asm b/kernel/io.asm index 1708c9b5..a3a389fd 100644 --- a/kernel/io.asm +++ b/kernel/io.asm @@ -28,6 +28,9 @@ ; $Header$ ; ; $Log$ +; Revision 1.11 2001/11/04 19:47:39 bartoldeman +; kernel 2025a changes: see history.txt +; ; Revision 1.10 2001/09/23 20:39:44 bartoldeman ; FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling ; @@ -81,7 +84,7 @@ extern ComTable:wrt TGROUP extern uPrtNo:wrt TGROUP extern CommonNdRdExit:wrt TGROUP - extern _NumFloppies:wrt DGROUP +;!! extern _NumFloppies:wrt DGROUP extern blk_stk_top:wrt DGROUP extern clk_stk_top:wrt DGROUP extern _reloc_call_blk_driver diff --git a/kernel/ioctl.c b/kernel/ioctl.c index f6daef23..eeca65d6 100644 --- a/kernel/ioctl.c +++ b/kernel/ioctl.c @@ -35,6 +35,9 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.12 2001/11/04 19:47:39 bartoldeman + * kernel 2025a changes: see history.txt + * * Revision 1.11 2001/07/22 01:58:58 bartoldeman * Support for Brian's FORMAT, DJGPP libc compilation, cleanups, MSCDEX * @@ -124,13 +127,37 @@ static BYTE *RcsId = "$Id$"; * WARNING: this code is non-portable (8086 specific). */ +/* TE 10/29/01 + + although device drivers have only 20 pushes available for them, + MS NET plays by its own rules + + at least TE's network card driver DM9PCI (some 10$ NE2000 clone) does: + with SP=8DC before calling down to execrh, and SP=8CC when + callf [interrupt], DM9PCI touches DOSDS:792, + 14 bytes into error stack :-((( + + so some optimizations were made. + this uses the fact, that only CharReq device buffer is ever used. + fortunately, this saves some code as well :-) + +*/ + + COUNT DosDevIOctl(iregs FAR * r) { sft FAR *s; struct dpb FAR *dpbp; - struct cds FAR *cdsp; - BYTE FAR *pBuffer = MK_FP(r->DS, r->DX); - COUNT nMode , dev; + COUNT nMode; + + /* commonly used, shouldn't harm to do front up */ + + CharReqHdr.r_length = sizeof(request); + CharReqHdr.r_trans = MK_FP(r->DS, r->DX); + CharReqHdr.r_status = 0; + CharReqHdr.r_count = r->CX; + + /* Test that the handle is valid */ switch (r->AL) @@ -169,14 +196,14 @@ COUNT DosDevIOctl(iregs FAR * r) /* JPP - changed to use default drive if drive=0 */ /* JT Fixed it */ - dev = ( r->BL == 0 ? default_drive : r->BL - 1); + CharReqHdr.r_unit = ( r->BL == 0 ? default_drive : r->BL - 1); - if (dev >= lastdrive) + if (CharReqHdr.r_unit >= lastdrive) return DE_INVLDDRV; else { - cdsp = &CDSp->cds_table[dev]; - dpbp = cdsp->cdsDpb; +/* cdsp = &CDSp->cds_table[CharReqHdr.r_unit]; */ + dpbp = CDSp->cds_table[CharReqHdr.r_unit].cdsDpb; } break; @@ -234,11 +261,7 @@ COUNT DosDevIOctl(iregs FAR * r) || ((r->AL == 0x0c) && (s->sft_dev->dh_attr & ATTR_GENIOCTL))) { CharReqHdr.r_unit = 0; - CharReqHdr.r_length = sizeof(request); CharReqHdr.r_command = nMode; - CharReqHdr.r_count = r->CX; - CharReqHdr.r_trans = pBuffer; - CharReqHdr.r_status = 0; execrh((request FAR *) & CharReqHdr, s->sft_dev); if (CharReqHdr.r_status & S_ERROR) @@ -287,12 +310,7 @@ COUNT DosDevIOctl(iregs FAR * r) } - CharReqHdr.r_unit = dev; - CharReqHdr.r_length = sizeof(request); CharReqHdr.r_command = nMode; - CharReqHdr.r_count = r->CX; - CharReqHdr.r_trans = pBuffer; - CharReqHdr.r_status = 0; execrh((request FAR *) & CharReqHdr, dpbp->dpb_device); @@ -348,7 +366,7 @@ COUNT DosDevIOctl(iregs FAR * r) return DE_INVLDFUNC; case 0x09: - if(cdsp->cdsFlags & CDSNETWDRV) + if(CDSp->cds_table[CharReqHdr.r_unit].cdsFlags & CDSNETWDRV) { r->DX = ATTR_REMOTE ; r->AX = S_DONE|S_BUSY; @@ -384,12 +402,7 @@ COUNT DosDevIOctl(iregs FAR * r) { - CharReqHdr.r_unit = dev; - CharReqHdr.r_length = sizeof(request); CharReqHdr.r_command = nMode; - CharReqHdr.r_count = r->CX; - CharReqHdr.r_trans = pBuffer; - CharReqHdr.r_status = 0; execrh((request FAR *) & CharReqHdr, dpbp->dpb_device); diff --git a/kernel/kernel.asm b/kernel/kernel.asm index 5898e3a4..c0cd5c3a 100644 --- a/kernel/kernel.asm +++ b/kernel/kernel.asm @@ -28,6 +28,9 @@ ; $Id$ ; ; $Log$ +; Revision 1.19 2001/11/04 19:47:39 bartoldeman +; kernel 2025a changes: see history.txt +; ; Revision 1.18 2001/09/23 20:39:44 bartoldeman ; FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling ; @@ -156,8 +159,51 @@ segment PSP STACK_SIZE equ 384/2 ; stack allocated in words +;************************************************************ +; KERNEL BEGINS HERE, i.e. this is byte 0 of KERNEL.SYS +;************************************************************ + ..start: -entry: +entry: + jmp short realentry + +;************************************************************ +; KERNEL CONFIGURATION AREA +; this is copied up on the very beginning +; it's a good idea to keep this in sync with KConfig.h +;************************************************************ + global _LowKernelConfig +_LowKernelConfig: + db 'CONFIG' ; constant + dw configend-configstart; size of config area + ; to be checked !!! + +configstart: + +DLASortByDriveNo db 0 ; sort disks by drive order +InitDiskShowDriveAssignment db 1 ; +SkipConfigSeconds db 2 ; + +configend: + +;************************************************************ +; KERNEL CONFIGURATION AREA END +;************************************************************ + + +;************************************************************ +; KERNEL real entry (at ~60:20) +; +; moves the INIT part of kernel.sys to high memory (~9000:0) +; then jumps there +; to aid debugging, some '123' messages are output +; this area is discardable and used as temporary PSP for the +; init sequence +;************************************************************ + + +realentry: ; execution continues here + push ax push bx pushf @@ -249,11 +295,12 @@ cont: ; inititalize api stacks for high water tests jns floppy add bl,3-1-128 floppy: mov byte [_BootDrive],bl ; tell where we came from - int 11h - mov cl,6 - shr al,cl - inc al - mov byte [_NumFloppies],al ; and how many + +;!! int 11h +;!! mov cl,6 +;!! shr al,cl +;!! inc al +;!! mov byte [_NumFloppies],al ; and how many mov ax,cs mov ds,ax @@ -262,6 +309,12 @@ floppy: mov byte [_BootDrive],bl ; tell where we came from segment INIT_TEXT_END + +;************************************************************ +; KERNEL CODE AREA END +; the NUL device +;************************************************************ + segment _TEXT ; @@ -288,6 +341,11 @@ _nul_intr: +;************************************************************ +; KERNEL FIXED DATA AREA +;************************************************************ + + segment _FIXED_DATA ; Because of the following bytes of data, THIS MODULE MUST BE THE FIRST @@ -365,8 +423,14 @@ setverPtr dw 0,0 ; 0037 setver list _LoL_nbuffers dw 1 ; 003F number of buffers dw 1 ; 0041 size of pre-read buffer global _BootDrive -_BootDrive db 1 ; 0043 drive we booted from +_BootDrive db 1 ; 0043 drive we booted from + +%IFNDEF I386 db 0 ; 0044 cpu type (1 if >=386) +%ELSE + db 1 ; 0044 cpu type (1 if >=386) +%ENDIF + dw 0 ; 0045 Extended memory in KBytes buf_info: global _firstbuf @@ -595,11 +659,12 @@ _lpCurSft times 2 dw 0 ;27e - Current SFT _current_ldt times 2 dw 0 ;282 - Current CDS global _lpFcb _lpFcb times 2 dw 0 ;286 - pointer to callers FCB - global current_ifn -current_ifn dw 0 ;28A - SFT index for next open + global _current_sft_idx +_current_sft_idx dw 0 ;28A - SFT index for next open + ; used by MS NET ; Pad to 05b2h - times (292h - ($ - _internal_data)) db 0 + times (292h - ($ - _internal_data)) db 0 dw __PriPathBuffer ; 292 - "sda_WFP_START" offset in DOS DS of first filename argument dw __SecPathBuffer ; 294 - "sda_REN_WFP" offset in DOS DS of second filename argument @@ -641,22 +706,23 @@ _disk_api_tos: global _char_api_tos _char_api_tos: apistk_top: - + db 0 ; 780 ??? _VolChange db 0 ;781 - volume change _VirtOpen db 0 ;782 - virtual open flag ; controlled variables end at offset 78Ch so pad to end times (78ch - ($ - _internal_data)) db 0 _swap_indos: + ; ; end of controlled variables ; segment _BSS - global _NumFloppies -_NumFloppies resw 1 -intr_dos_stk resw 1 -intr_dos_seg resw 1 +;!! global _NumFloppies +;!!_NumFloppies resw 1 +;!!intr_dos_stk resw 1 +;!!intr_dos_seg resw 1 global _ram_top diff --git a/kernel/lfnapi.c b/kernel/lfnapi.c index 71211ee5..22ea1406 100644 --- a/kernel/lfnapi.c +++ b/kernel/lfnapi.c @@ -49,7 +49,7 @@ COUNT lfn_allocate_inode() COUNT lfn_free_inode(COUNT handle) { f_node_ptr fnp = xlt_fd(handle); - if (fnp == 0 || fnp->f_count <= 0) return E_INVLHNDL; + if (fnp == 0 || fnp->f_count <= 0) return E_INVLDHNDL; release_f_node(fnp); } @@ -90,7 +90,7 @@ COUNT lfn_dir_read(COUNT handle, lfn_inode_ptr lip) name string */ ULONG original_diroff; f_node_ptr fnp = xlt_fd(handle); - if (fnp == 0 || fnp->f_count <= 0) return E_INVLHNDL; + if (fnp == 0 || fnp->f_count <= 0) return E_INVLDHNDL; if (lfnp->l_dirstart == 0) { @@ -102,13 +102,13 @@ COUNT lfn_dir_read(COUNT handle, lfn_inode_ptr lip) while (TRUE) { - if (dir_read(fnp) != DIRENT_SIZE) return E_IOERROR; - if (fnp->f_dir.dir_name[0] != DELETED && fnp->f_dir.dir_name[0] != 0 - && fnp->f_dir.dir_attrib != D_LFN) + if (dir_read(fnp) <= 0) return E_IOERROR; + if (fnp->f_dir.dir_name[0] != DELETED && fnp->f_dir.dir_name[0] != '\0' + && fnp->f_dir.dir_attrib != D_LFN) { - fmemcpy(lip->l_dir, fnp->f_dir, sizeof(struct dirent)); + fmemcpy(lip->l_dir, fnp->f_dir, sizeof(struct dirent)); lip->l_diroff = fnp->f_diroff; - lip->l_dirstart = fnp->f_dirstart; + lip->l_dirstart = fnp->f_dirstart; break; } } @@ -118,11 +118,11 @@ COUNT lfn_dir_read(COUNT handle, lfn_inode_ptr lip) { if (fnp->f_diroff == 0) break; fnp->f_diroff -= 2*DIRENT_SIZE; - if (dir_read(fnp) != DIRENT_SIZE) return E_IOERROR; + if (dir_read(fnp) <= 0) return E_IOERROR; if (fnp->f_dir.dir_name[0] == '\0' || fnp->f_dir.dir_name[0] == DELETED) break; if (!lfn_to_unicode(lip->name, - (UBYTE FAR *)fnp->f_dir, index)) break; + (UBYTE FAR *)fnp->f_dir, index)) break; } if (lip->name[0] == 0) diff --git a/kernel/main.c b/kernel/main.c index 2293cab6..07c41c9c 100644 --- a/kernel/main.c +++ b/kernel/main.c @@ -32,6 +32,12 @@ #include "dyndata.h" #include "init-dat.h" +GLOBAL BYTE copyright[] = + "(C) Copyright 1995-2001 Pasquale J. Villani and The FreeDOS Project.\n" + "All Rights Reserved. This is free software and comes with ABSOLUTELY NO\n" + "WARRANTY; you can redistribute it and/or modify it under the terms of the\n" + "GNU General Public License as published by the Free Software Foundation;\n" + "either version 2, or (at your option) any later version.\n"; /* @@ -53,7 +59,7 @@ GLOBAL BYTE DOSFAR default_drive; /* default drive for dos */ GLOBAL BYTE DOSFAR os_release[]; -GLOBAL BYTE DOSFAR copyright[]; +/* GLOBAL BYTE DOSFAR copyright[]; */ GLOBAL seg DOSFAR RootPsp; /* Root process -- do not abort */ extern struct dpb FAR * DOSFAR DPBp; /* First drive Parameter Block */ @@ -73,8 +79,14 @@ extern BYTE FAR _HMATextEnd[]; static BYTE *mainRcsId = "$Id$"; #endif +struct _KernelConfig InitKernelConfig = {0}; + + /* * $Log$ + * Revision 1.22 2001/11/04 19:47:39 bartoldeman + * kernel 2025a changes: see history.txt + * * Revision 1.21 2001/09/23 20:39:44 bartoldeman * FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling * @@ -264,8 +276,9 @@ INIT VOID ASMCFUNC FreeDOSmain(void) DosDataSeg = (__segment)&DATASTART; DosTextSeg = (__segment)&prn_dev; #endif - - + + fmemcpy(&InitKernelConfig,&LowKernelConfig,sizeof(InitKernelConfig)); + setvec(0, int0_handler); /* zero divide */ setvec(1, empty_handler); /* single step */ @@ -417,7 +430,7 @@ INIT VOID FsConfig(VOID) dup2(STDIN, STDOUT); /* 2 is /dev/con (stderr) */ - dup2(STDIN, STDERR); + dup2(STDIN, STDERR); /* 3 is /dev/aux */ open("AUX", O_RDWR); diff --git a/kernel/memmgr.c b/kernel/memmgr.c index 3537ed2c..fa89de77 100644 --- a/kernel/memmgr.c +++ b/kernel/memmgr.c @@ -35,6 +35,9 @@ static BYTE *memmgrRcsId = "$Id$"; /* * $Log$ + * Revision 1.16 2001/11/04 19:47:39 bartoldeman + * kernel 2025a changes: see history.txt + * * Revision 1.15 2001/09/23 20:39:44 bartoldeman * FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling * @@ -569,27 +572,28 @@ COUNT DosMemCheck(void) COUNT FreeProcessMem(UWORD ps) { mcb FAR *p; - COUNT x = 0; + BYTE oldumbstate = uppermem_link; - /* Initialize */ - p = para2far(first_mcb); + /* link in upper memory to free those , too */ + DosUmbLink(1); - /* Search through memory blocks */ - while (mcbValid(p)) /* check for corruption */ - { - if (p->m_psp == ps) - DosMemFree(FP_SEG(p)); + /* Search through all memory blocks */ + for (p = para2far(first_mcb);; p = nxtMCB(p)) + { - /* not corrupted - if last we're OK! */ - if (p->m_type == MCB_LAST){ - if(x) - return DE_MCBDESTRY; - return SUCCESS; + if (!mcbValid(p)) /* check for corruption */ + return DE_MCBDESTRY; + + if (p->m_psp == ps) + DosMemFree(FP_SEG(p)); + + if (p->m_type == MCB_LAST) + break; } - p = nxtMCB(p); - } - return DE_MCBDESTRY; + DosUmbLink(oldumbstate); + + return SUCCESS; } #if 0 @@ -661,6 +665,9 @@ VOID DosUmbLink(BYTE n) REG mcb FAR *p; REG mcb FAR *q; mcb FAR *end_of_conv_mem = para2far(ram_top*64-1); + + if (uppermem_root == 0) + return; q = p = para2far(first_mcb); /* like a xor thing! */ diff --git a/kernel/misc.c b/kernel/misc.c index fa26a114..784d7d77 100644 --- a/kernel/misc.c +++ b/kernel/misc.c @@ -34,6 +34,9 @@ static BYTE *miscRcsId = "$Id$"; /* * $Log$ + * Revision 1.6 2001/11/04 19:47:39 bartoldeman + * kernel 2025a changes: see history.txt + * * Revision 1.5 2001/04/15 03:21:50 bartoldeman * See history.txt for the list of fixes. * @@ -92,7 +95,7 @@ static BYTE *miscRcsId = "$Id$"; */ #include "globals.h" -#ifndef ASMSUPT +#ifndef I86 VOID scopy(REG BYTE * s, REG BYTE * d) { diff --git a/kernel/network.c b/kernel/network.c index e941e7f8..aab61c87 100644 --- a/kernel/network.c +++ b/kernel/network.c @@ -36,6 +36,9 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.15 2001/11/04 19:47:39 bartoldeman + * kernel 2025a changes: see history.txt + * * Revision 1.14 2001/07/24 16:56:29 bartoldeman * fixes for FCBs, DJGPP ls, DBLBYTE, dyninit allocation (2024e). * @@ -108,28 +111,3 @@ VOID set_machine_name(BYTE FAR * netname, UWORD name_num) fmemcpy(&net_name, netname, 15); net_set_count++; } - -/* - * Read/Write from/to remote file. - * SFT gets updated with the amount of bytes r/w. - * - */ -UCOUNT Remote_RW(UWORD func, UCOUNT n, BYTE FAR * bp, sft FAR * s, COUNT FAR * err) -{ - - BYTE FAR *save_dta; - UWORD rc, - rx; - - save_dta = dta; - lpCurSft = (sfttbl FAR *) s; - current_filepos = s->sft_posit; /* needed for MSCDEX */ - dta = bp; - rx = int2f_Remote_call(func, 0, n, 0, (VOID FAR *) s, 0, (VOID FAR *) & rc); - dta = save_dta; - *err = -rx; - return ((UCOUNT) rc); -} - - - diff --git a/kernel/nls_load.c b/kernel/nls_load.c index f3bf199a..ac8f657b 100644 --- a/kernel/nls_load.c +++ b/kernel/nls_load.c @@ -40,6 +40,9 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.2 2001/11/04 19:47:39 bartoldeman + * kernel 2025a changes: see history.txt + * * Revision 1.1 2000/08/06 05:50:17 jimtabor * Add new files and update cvs with patches and changes * @@ -58,7 +61,7 @@ static int err(void) #define readStruct(s) readStructure(&(s), sizeof(s), fd) static int readStructure(void *buf, int size, COUNT fd) -{ if(dos_read(fd, buf, size) == size) +{ if(DosRead(fd, buf, size) == size) return 1; return err(); @@ -66,14 +69,14 @@ static int readStructure(void *buf, int size, COUNT fd) /* Evaluate each argument only once */ #define readFct(p,f) readFct_((p), (f), fd) int readFct_(void *buf, struct csys_function *fct, COUNT fd) -{ if(dos_lseek(fd, fct->csys_rpos, 0) >= 0) +{ if(DosLseek(fd, fct->csys_rpos, 0) >= 0) return readStructure(buf, fct->csys_length, fd); return err(); } #define seek(n) rseek((LONG)(n), fd) static rseek(LONG rpos, COUNT fd) -{ if(dos_lseek(fd, rpos, 1) >= 0) +{ if(DosLseek(fd, rpos, 1) >= 0) return 1; return err(); @@ -84,18 +87,18 @@ COUNT csysOpen(void) { COUNT fd; struct nlsCSys_fileHeader header; - if((fd = dos_open((BYTE FAR*)filename, 0)) < 0) { + if((fd = DosOpen((BYTE FAR*)filename, 0)) < 0) { printf("Cannot open: \"%s\"\n", filename); return 1; } - if(dos_read(fd, &header, sizeof(header)) != sizeof(header); + if(DosRead(fd, &header, sizeof(header)) != sizeof(header); || strcmp(header.csys_idstring, CSYS_FD_IDSTRING) != 0 - || dos_lseek(fd, (LONG)sizeof(csys_completeFileHeader), 0) + || DosLseek(fd, (LONG)sizeof(csys_completeFileHeader), 0) != (LONG)sizeof(csys_completeFileHeader)) { printf("No valid COUNTRY.SYS: \"%s\"\n\nTry NLSFUNC /i %s\n" , filename, filename); - dos_close(fd); + DosClose(fd); return -1; } @@ -265,7 +268,7 @@ int csysLoadPackage(COUNT fd) } /* OK --> update the rpos member */ - fct.csys_rpos += dos_ltell(fd); + fct.csys_rpos += DosLtell(fd); totalSize += fct.csys_length; ++numFct; } while(--numE); @@ -379,7 +382,7 @@ INIT BOOL LoadCountryInfo(char *fnam) strcpy(filename, fnam); if((fd = csysOpen()) >= 0) { rc = csysLoadPackage(fd); - dos_close(fd); + DosClose(fd); return rc; } } else diff --git a/kernel/prf.c b/kernel/prf.c index d43a352c..0bb613fa 100644 --- a/kernel/prf.c +++ b/kernel/prf.c @@ -30,7 +30,7 @@ /*#define DOSEMU*/ -#ifdef FORINIT +#ifdef _INIT #define fstrlen reloc_call_fstrlen #define put_console init_put_console #define ltob init_ltob @@ -50,6 +50,9 @@ static BYTE *prfRcsId = "$Id$"; /* * $Log$ + * Revision 1.13 2001/11/04 19:47:39 bartoldeman + * kernel 2025a changes: see history.txt + * * Revision 1.12 2001/09/23 20:39:44 bartoldeman * FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling * @@ -78,6 +81,9 @@ static BYTE *prfRcsId = "$Id$"; * recoded for smaller object footprint, added main() for testing+QA * * $Log$ + * Revision 1.13 2001/11/04 19:47:39 bartoldeman + * kernel 2025a changes: see history.txt + * * Revision 1.12 2001/09/23 20:39:44 bartoldeman * FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling * diff --git a/kernel/proto.h b/kernel/proto.h index 93211a58..0fe04b5f 100644 --- a/kernel/proto.h +++ b/kernel/proto.h @@ -34,6 +34,9 @@ static BYTE *Proto_hRcsId = "$Id$"; /* * $Log$ + * Revision 1.23 2001/11/04 19:47:39 bartoldeman + * kernel 2025a changes: see history.txt + * * Revision 1.22 2001/09/23 20:39:44 bartoldeman * FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling * @@ -200,6 +203,7 @@ BOOL flush_buffers(REG COUNT dsk); BOOL flush1(struct buffer FAR * bp); BOOL flush(void); BOOL fill(REG struct buffer FAR * bp, ULONG blkno, COUNT dsk); +BOOL DeleteBlockInBufferCache(ULONG blknolow, ULONG blknohigh, COUNT dsk); /* *** Changed on 9/4/00 BER */ UWORD dskxfer(COUNT dsk, ULONG blkno, VOID FAR * buf, UWORD numblocks, COUNT mode); /* *** End of change */ @@ -227,12 +231,15 @@ struct dpb FAR *GetDriveDPB(UBYTE drive, COUNT *rc); BYTE FAR *get_root(BYTE FAR *); BOOL fnmatch(BYTE FAR *, BYTE FAR *, COUNT, COUNT); BOOL check_break(void); -UCOUNT GenericRead(COUNT hndl, UCOUNT n, BYTE FAR * bp, COUNT FAR * err, +UCOUNT GenericReadSft(sft far *sftp, UCOUNT n, BYTE FAR * bp, COUNT FAR * err, BOOL force_binary); COUNT SftSeek(sft FAR *sftp, LONG new_pos, COUNT mode); /* COUNT DosRead(COUNT hndl, UCOUNT n, BYTE FAR * bp, COUNT FAR * err); */ -#define DosRead(hndl,n,bp,err) GenericRead(hndl, n, bp, err,FALSE) -UCOUNT DosWrite(COUNT hndl, UCOUNT n, BYTE FAR * bp, COUNT FAR * err); +#define GenericRead(hndl, n, bp, err, t) GenericReadSft(get_sft(hndl), n, bp, err, t) +#define DosRead(hndl, n, bp, err) GenericRead(hndl, n, bp, err, FALSE) +#define DosReadSft(sftp, n, bp, err) GenericReadSft(sftp, n, bp, err, FALSE) +UCOUNT DosWriteSft(sft FAR *sftp, UCOUNT n, BYTE FAR * bp, COUNT FAR * err); +#define DosWrite(hndl, n, bp, err) DosWriteSft(get_sft(hndl), n, bp, err) COUNT DosSeek(COUNT hndl, LONG new_pos, COUNT mode, ULONG * set_pos); COUNT DosCreat(BYTE FAR * fname, COUNT attrib); COUNT DosCreatSft(BYTE * fname, COUNT attrib); @@ -286,9 +293,10 @@ COUNT char_error(request * rq, struct dhdr FAR * lpDevice); COUNT block_error(request * rq, COUNT nDrive, struct dhdr FAR * lpDevice); /* fatdir.c */ +VOID dir_init_fnode(f_node_ptr fnp, CLUSTER dirstart); f_node_ptr dir_open(BYTE * dirname); COUNT dir_read(REG f_node_ptr fnp); -COUNT dir_write(REG f_node_ptr fnp); +BOOL dir_write(REG f_node_ptr fnp); VOID dir_close(REG f_node_ptr fnp); COUNT dos_findfirst(UCOUNT attr, BYTE * name); COUNT dos_findnext(void); @@ -296,6 +304,7 @@ void ConvertName83ToNameSZ(BYTE FAR *destSZ, BYTE FAR *srcFCBName); int FileName83Length(BYTE *filename83); /* fatfs.c */ +ULONG clus2phys(CLUSTER cl_no, struct dpb FAR *dpbp); COUNT dos_open(BYTE * path, COUNT flag); BOOL fcmp(BYTE * s1, BYTE * s2, COUNT n); BOOL fcmp_wild(BYTE FAR * s1, BYTE FAR * s2, COUNT n); @@ -499,9 +508,9 @@ VOID break_handler(void); /* systime.c */ VOID DosGetTime(BYTE FAR * hp, BYTE FAR * mp, BYTE FAR * sp, BYTE FAR * hdp); -COUNT DosSetTime(BYTE FAR * hp, BYTE FAR * mp, BYTE FAR * sp, BYTE FAR * hdp); +COUNT DosSetTime(BYTE h, BYTE m, BYTE s, BYTE hd); VOID DosGetDate(BYTE FAR * wdp, BYTE FAR * mp, BYTE FAR * mdp, COUNT FAR * yp); -COUNT DosSetDate(BYTE FAR * mp, BYTE FAR * mdp, COUNT FAR * yp); +COUNT DosSetDate(UWORD Month, UWORD DayOfMonth, UWORD Year); UWORD *is_leap_year_monthdays(UWORD year); UWORD DaysFromYearMonthDay(UWORD Year, UWORD Month, UWORD DayOfMonth); @@ -523,13 +532,32 @@ COUNT get_verify_drive(char FAR * src); COUNT ASMCFUNC truename(char FAR * src, char FAR * dest, COUNT t); /* network.c */ -COUNT ASMCFUNC int2f_Remote_call(UWORD func, UWORD b, UCOUNT n, UWORD d, VOID FAR * s, UWORD i, VOID FAR * data); +COUNT ASMCFUNC remote_doredirect(UWORD b, UCOUNT n, UWORD d, VOID FAR * s, UWORD i, VOID FAR * data); +COUNT ASMCFUNC remote_printset(UWORD b, UCOUNT n, UWORD d, VOID FAR * s, UWORD i, VOID FAR * data); +COUNT ASMCFUNC remote_rename(VOID); +COUNT ASMCFUNC remote_delete(VOID); +COUNT ASMCFUNC remote_chdir(VOID); +COUNT ASMCFUNC remote_mkdir(VOID); +COUNT ASMCFUNC remote_rmdir(VOID); +COUNT ASMCFUNC remote_close_all(VOID); +COUNT ASMCFUNC remote_process_end(VOID); +COUNT ASMCFUNC remote_flushall(VOID); +COUNT ASMCFUNC remote_findfirst(VOID FAR *s); +COUNT ASMCFUNC remote_findnext(VOID FAR *s); +COUNT ASMCFUNC remote_getfattr(VOID); +COUNT ASMCFUNC remote_getfree(VOID FAR *s, VOID *d); +COUNT ASMCFUNC remote_open(sft FAR *s, COUNT mode); +LONG ASMCFUNC remote_lseek(sft FAR *s, LONG new_pos); +UCOUNT ASMCFUNC remote_read(sft FAR *s, UCOUNT n, COUNT * err); +UCOUNT ASMCFUNC remote_write(sft FAR *s, UCOUNT n, COUNT * err); +COUNT ASMCFUNC remote_creat(sft FAR *s, COUNT attr); +COUNT ASMCFUNC remote_setfattr(COUNT attr); +COUNT ASMCFUNC remote_printredir(UCOUNT dx, UCOUNT ax); +COUNT ASMCFUNC remote_close(sft FAR *s); COUNT ASMCFUNC QRemote_Fn(char FAR * s, char FAR * d); UWORD get_machine_name(BYTE FAR * netname); VOID set_machine_name(BYTE FAR * netname, UWORD name_num); -UCOUNT Remote_RW(UWORD func, UCOUNT n, BYTE FAR * bp, sft FAR * s, COUNT FAR * err); -COUNT Remote_find(UWORD func); /* procsupt.asm */ VOID ASMCFUNC exec_user(iregs FAR * irp); diff --git a/kernel/strings.c b/kernel/strings.c index c9a89eed..b23fa757 100644 --- a/kernel/strings.c +++ b/kernel/strings.c @@ -34,6 +34,9 @@ static BYTE *stringsRcsId = "$Id$"; /* * $Log$ + * Revision 1.6 2001/11/04 19:47:39 bartoldeman + * kernel 2025a changes: see history.txt + * * Revision 1.5 2001/04/15 03:21:50 bartoldeman * See history.txt for the list of fixes. * @@ -97,7 +100,7 @@ static BYTE *stringsRcsId = "$Id$"; * Initial revision. */ -#ifndef ASMSUPT +#ifndef I86 COUNT strlen(REG BYTE * s) { REG WORD cnt = 0; diff --git a/kernel/syspack.c b/kernel/syspack.c index 2947bacb..992f682d 100644 --- a/kernel/syspack.c +++ b/kernel/syspack.c @@ -36,6 +36,9 @@ static BYTE *syspackRcsId = "$Id$"; /* * $Log$ + * Revision 1.5 2001/11/04 19:47:39 bartoldeman + * kernel 2025a changes: see history.txt + * * Revision 1.4 2001/09/23 20:39:44 bartoldeman * FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling * @@ -164,4 +167,4 @@ VOID putdirent(struct dirent FAR * dp, BYTE FAR * vp) for (i = 0, p = (BYTE FAR *) & vp[DIR_RESERVED]; i < 10; i++) *p++ = NULL; } -#endif \ No newline at end of file +#endif diff --git a/kernel/systime.c b/kernel/systime.c index c614b7d3..4599c0ca 100644 --- a/kernel/systime.c +++ b/kernel/systime.c @@ -37,6 +37,9 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.7 2001/11/04 19:47:39 bartoldeman + * kernel 2025a changes: see history.txt + * * Revision 1.6 2001/08/19 12:58:36 bartoldeman * Time and date fixes, Ctrl-S/P, findfirst/next, FCBs, buffers, tsr unloading * @@ -166,17 +169,17 @@ VOID DosGetTime(BYTE FAR * hp, BYTE FAR * mp, BYTE FAR * sp, BYTE FAR * hdp) *hdp = ClkRecord.clkHundredths; } -COUNT DosSetTime(BYTE FAR * hp, BYTE FAR * mp, BYTE FAR * sp, BYTE FAR * hdp) +COUNT DosSetTime(BYTE h, BYTE m, BYTE s, BYTE hd) { BYTE Month, DayOfMonth, DayOfWeek; COUNT Year; DosGetDate((BYTE FAR *) & DayOfWeek, (BYTE FAR *) & Month, (BYTE FAR *) & DayOfMonth, (COUNT FAR *) & Year); - ClkRecord.clkHours = *hp; - ClkRecord.clkMinutes = *mp; - ClkRecord.clkSeconds = *sp; - ClkRecord.clkHundredths = *hdp; + ClkRecord.clkHours = h; + ClkRecord.clkMinutes = m; + ClkRecord.clkSeconds = s; + ClkRecord.clkHundredths = hd; ClkRecord.clkDays = DaysFromYearMonthDay(Year, Month, DayOfMonth); @@ -232,15 +235,12 @@ COUNT FAR *yp; *wdp = (ClkRecord.clkDays + 2) % 7; } -COUNT DosSetDate(mp, mdp, yp) -BYTE FAR *mp, - FAR * mdp; -COUNT FAR *yp; +COUNT DosSetDate(Month, DayOfMonth, Year) +UWORD Month, + DayOfMonth, + Year; { - UWORD *pdays, Month, DayOfMonth,Year; - Month = *mp; - DayOfMonth = *mdp; - Year = *yp; + UWORD *pdays; pdays = is_leap_year_monthdays(Year); if (Year < 1980 || Year > 2099 diff --git a/kernel/task.c b/kernel/task.c index a7bbd8e6..4c7b76ab 100644 --- a/kernel/task.c +++ b/kernel/task.c @@ -35,6 +35,9 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.19 2001/11/04 19:47:39 bartoldeman + * kernel 2025a changes: see history.txt + * * Revision 1.18 2001/09/23 20:39:44 bartoldeman * FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling * @@ -313,7 +316,7 @@ COUNT ChildEnv(exec_blk FAR * exp, UWORD * pChildEnvSeg, char far * pathname) /* The following code is 8086 dependant */ VOID new_psp(psp FAR * p, int psize) { - REG COUNT i; + REG COUNT i; psp FAR *q = MK_FP(cu_psp, 0); /* Clear out new psp first */ @@ -356,6 +359,7 @@ VOID new_psp(psp FAR * p, int psize) /* user stack pointer - int 21 */ p->ps_stack = q->ps_stack; /* file table - 0xff is unused */ + for (i = 0; i < 20; i++) p->ps_files[i] = 0xff; @@ -390,7 +394,7 @@ VOID new_psp(psp FAR * p, int psize) RootPsp = FP_SEG(p); } -static UWORD patchPSP(UWORD pspseg, UWORD envseg, exec_blk FAR *exb, +STATIC UWORD patchPSP(UWORD pspseg, UWORD envseg, exec_blk FAR *exb, BYTE FAR * fnam) { psp FAR *psp; @@ -475,6 +479,9 @@ COUNT DosComLoader(BYTE FAR * namep, exec_blk FAR * exp, COUNT mode) { return rc; } + + /* COMFILES will always be loaded in largest area. is that true TE*/ + /* Now find out how many paragraphs are available */ if ((rc = DosMemLargest((seg FAR *) & asize)) != SUCCESS) { @@ -483,7 +490,7 @@ COUNT DosComLoader(BYTE FAR * namep, exec_blk FAR * exp, COUNT mode) } com_size = asize; - if ( ModeLoadHigh && uppermem_root) + if ( ModeLoadHigh ) { DosUmbLink(1); /* link in UMB's */ } @@ -519,7 +526,7 @@ COUNT DosComLoader(BYTE FAR * namep, exec_blk FAR * exp, COUNT mode) else mem = exp->load.load_seg; - if ( ModeLoadHigh && uppermem_root) + if ( ModeLoadHigh ) { DosUmbLink(UMBstate); /* restore link state */ } @@ -539,16 +546,19 @@ COUNT DosComLoader(BYTE FAR * namep, exec_blk FAR * exp, COUNT mode) sp = MK_FP(mem, 0); else { /* test the filesize against the allocated memory */ - UWORD tmp = 16; - + sp = MK_FP(mem, sizeof(psp)); /* This is a potential problem, what to do with .COM files larger than the allocated memory? MS DOS always only loads the very first 64KB - sizeof(psp) bytes. -- 1999/04/21 ska */ - if ((ULONG)com_size > (ULONG)asize * tmp) /* less memory than the .COM file has */ - (ULONG)com_size = (ULONG)asize * tmp; /* << 4 */ + + /* BUG !! in case of LH, memory may be smaller then 64K TE*/ + + + if ((ULONG)com_size > ((ULONG)asize << 4)) /* less memory than the .COM file has */ + (ULONG)com_size = (ULONG)asize << 4; } do { @@ -581,6 +591,12 @@ COUNT DosComLoader(BYTE FAR * namep, exec_blk FAR * exp, COUNT mode) { case LOADNGO: { + /* BUG !! + this works only, if COMSIZE >= 64K + in case of LH, this is not necessarily true + */ + + *((UWORD FAR *) MK_FP(mem, 0xfffe)) = (UWORD) 0; /* build the user area on the stack */ @@ -603,8 +619,8 @@ COUNT DosComLoader(BYTE FAR * namep, exec_blk FAR * exp, COUNT mode) --InDOS; exec_user(irp); - /* We should never be here */ - fatal("KERNEL RETURNED!!!"); + /* We should never be here + fatal("KERNEL RETURNED!!!"); */ break; } case LOAD: @@ -634,10 +650,11 @@ VOID return_user(void) setvec(0x24, p->ps_isv24); /* And free all process memory if not a TSR return */ - int2f_Remote_call(REM_PROCESS_END, 0, 0, 0, 0, 0, 0); + remote_process_end(); /* might be a good idea to do that after closing + but doesn't help NET either TE */ if (!tsr) { - int2f_Remote_call(REM_CLOSEALL, 0, 0, 0, 0, 0, 0); + remote_close_all(); for (i = 0; i < p->ps_maxfiles; i++) { DosClose(i); @@ -645,6 +662,7 @@ VOID return_user(void) FcbCloseAll(); FreeProcessMem(cu_psp); } + cu_psp = p->ps_parent; q = MK_FP(cu_psp, 0); @@ -662,25 +680,14 @@ VOID return_user(void) COUNT DosExeLoader(BYTE FAR * namep, exec_blk FAR * exp, COUNT mode) { - COUNT rc, + COUNT rc; /*err, */ /*env_size,*/ - i; - UCOUNT nBytesRead; + UWORD mem, env, asize, start_seg; - ULONG image_size; - ULONG image_offset; - BYTE FAR *sp; - psp FAR *p; - psp FAR *q = MK_FP(cu_psp, 0); - mcb FAR *mp; - iregs FAR *irp; - UWORD reloc[2]; - seg FAR *spot; - LONG exe_size; int ModeLoadHigh = mode & 0x80; UBYTE UMBstate = uppermem_link; @@ -696,17 +703,23 @@ COUNT DosExeLoader(BYTE FAR * namep, exec_blk FAR * exp, COUNT mode) } else mem = exp->load.load_seg; + + + { + ULONG image_size; + ULONG image_offset; + LONG exe_size; + mcb FAR *mp; + /* compute image offset from the header */ - asize = 16; - image_offset = (ULONG)header.exHeaderSize * asize; + image_offset = (ULONG)header.exHeaderSize * 16; /* compute image size by removing the offset from the */ /* number pages scaled to bytes plus the remainder and */ /* the psp */ /* First scale the size */ - asize = 512; - image_size = (ULONG)header.exPages * asize; + image_size = (ULONG)header.exPages * 512; /* remove the offset */ image_size -= image_offset; @@ -716,7 +729,7 @@ COUNT DosExeLoader(BYTE FAR * namep, exec_blk FAR * exp, COUNT mode) if (mode != OVERLAY) { - if ( ModeLoadHigh && uppermem_root) + if ( ModeLoadHigh ) { DosUmbLink(1); /* link in UMB's */ mem_access_mode |= ModeLoadHigh; @@ -765,7 +778,7 @@ COUNT DosExeLoader(BYTE FAR * namep, exec_blk FAR * exp, COUNT mode) exe_size = asize; -/* /// Removed closing curly brace. We should not attempt to allocate + /* /// Removed closing curly brace. We should not attempt to allocate memory if we are overlaying the current process, because the new process will simply re-use the block we already have allocated. This was causing execl() to fail in applications which use it to @@ -822,7 +835,7 @@ COUNT DosExeLoader(BYTE FAR * namep, exec_blk FAR * exp, COUNT mode) asize = exe_size; /* /// End of additions. Jun 11, 2000 - rbc */ - if ( ModeLoadHigh && uppermem_root) + if ( ModeLoadHigh ) { mem_access_mode &= ~ModeLoadHigh; /* restore old situation */ DosUmbLink(UMBstate); /* restore link state */ @@ -875,6 +888,9 @@ COUNT DosExeLoader(BYTE FAR * namep, exec_blk FAR * exp, COUNT mode) if (exe_size > 0) { + UCOUNT nBytesRead; + BYTE FAR *sp; + if (mode != OVERLAY) { if ((header.exMinAlloc == 0) && (header.exMaxAlloc == 0)) @@ -894,8 +910,13 @@ COUNT DosExeLoader(BYTE FAR * namep, exec_blk FAR * exp, COUNT mode) } while (nBytesRead && exe_size > 0); } - - /* relocate the image for new segment */ + } + + { /* relocate the image for new segment */ + COUNT i; + UWORD reloc[2]; + seg FAR *spot; + doslseek(rc, (LONG) header.exRelocTable, 0); for (i = 0; i < header.exRelocItems; i++) { @@ -915,7 +936,8 @@ COUNT DosExeLoader(BYTE FAR * namep, exec_blk FAR * exp, COUNT mode) *spot += start_seg; } } - + } + /* and finally close the file */ DosClose(rc); @@ -923,6 +945,11 @@ COUNT DosExeLoader(BYTE FAR * namep, exec_blk FAR * exp, COUNT mode) if (mode == OVERLAY) return SUCCESS; + + { + psp FAR *p; + psp FAR *q = MK_FP(cu_psp, 0); + /* point to the PSP so we can build it */ p = MK_FP(mem, 0); setvec(0x22, (VOID(INRPT FAR *) (VOID)) MK_FP(user_r->CS, user_r->IP)); @@ -939,8 +966,9 @@ COUNT DosExeLoader(BYTE FAR * namep, exec_blk FAR * exp, COUNT mode) switch (mode) { case LOADNGO: + { /* build the user area on the stack */ - irp = MK_FP(header.exInitSS + start_seg, + iregs FAR *irp = MK_FP(header.exInitSS + start_seg, ((header.exInitSP - sizeof(iregs)) & 0xffff)); /* start allocating REGs */ @@ -963,9 +991,10 @@ COUNT DosExeLoader(BYTE FAR * namep, exec_blk FAR * exp, COUNT mode) if (InDOS) --InDOS; exec_user(irp); - /* We should never be here */ - fatal("KERNEL RETURNED!!!"); + /* We should never be here + fatal("KERNEL RETURNED!!!"); */ break; + } case LOAD: cu_psp = mem; @@ -974,6 +1003,7 @@ COUNT DosExeLoader(BYTE FAR * namep, exec_blk FAR * exp, COUNT mode) exp->exec.start_addr = MK_FP(header.exInitCS + start_seg, header.exInitIP); return SUCCESS; } + } return DE_INVLDFMT; } diff --git a/kernel/turboc.cfg b/kernel/turboc.cfg index fa63626a..73162d23 100644 --- a/kernel/turboc.cfg +++ b/kernel/turboc.cfg @@ -1,4 +1,3 @@ --1- -f- -ff- -O diff --git a/readme.txt b/readme.txt index 43048a5c..3d52068c 100644 --- a/readme.txt +++ b/readme.txt @@ -13,14 +13,6 @@ See the DOCS directory for more documentation and information about the FreeDOS Kernel. -AGREEMENT ---------- -All users of the FreeDOS kernel must accept the disclaimer of -warranty and license terms contained in the file "COPYING" in order -to use it. You may not, under any circumstance, use this operating -system or any component without first reading and agreeing to the -terms of the license. - BUG REPORTS ----------- If you have found a bug, think you have found a bug, or would just diff --git a/sys/sys.c b/sys/sys.c index 77dc7c43..c2ed3584 100644 --- a/sys/sys.c +++ b/sys/sys.c @@ -26,9 +26,12 @@ ***************************************************************/ /* $Log$ - * Revision 1.10 2001/09/24 02:28:14 bartoldeman - * Minor printf fixes. + * Revision 1.11 2001/11/04 19:47:39 bartoldeman + * kernel 2025a changes: see history.txt * +/* Revision 1.10 2001/09/24 02:28:14 bartoldeman +/* Minor printf fixes. +/* /* Revision 1.9 2001/09/24 02:21:14 bartoldeman /* SYS and printer fixes /* @@ -160,7 +163,8 @@ #include #endif #include -#include +/*#include */ +#define MAXPATH 260 #include "portab.h" #include "b_fat12.h" @@ -169,7 +173,7 @@ #include "b_fat32.h" #endif -BYTE pgm[] = "sys"; +BYTE pgm[] = "SYS"; void put_boot(COUNT); BOOL check_space(COUNT, BYTE *); @@ -257,6 +261,7 @@ UBYTE newboot[SEC_SIZE], oldboot[SEC_SIZE]; #define SBSIZE32 (sizeof(struct bootsectortype32) - SBOFFSET) +int FDKrnConfigMain(int argc,char **argv); int main(int argc, char **argv) { @@ -267,6 +272,11 @@ int main(int argc, char **argv) WORD slen; printf("FreeDOS System Installer " SYS_VERSION "\n\n"); + + if (memicmp(argv[1],"CONFIG",6) == 0) + { + exit(FDKrnConfigMain(argc,argv)); + } if (argc == 2) { @@ -294,6 +304,7 @@ int main(int argc, char **argv) printf("Usage: %s [source] drive\n", pgm); printf(" source = A:,B:,C:\\KERNEL\\BIN\\,etc., or current directory if not given\n"); printf(" drive = A,B,etc.\n"); + printf("%s CONFIG /help\n",pgm); exit(1); } @@ -307,7 +318,13 @@ int main(int argc, char **argv) if ((strlen(srcPath) > 1) && (srcPath[1] == ':')) /* src specifies drive */ srcDrive = toupper(*srcPath) - 'A'; else /* src doesn't specify drive, so assume current drive */ + { +#ifdef __TURBOC__ srcDrive = getdisk(); +#else + _dos_getdrive(&srcDrive); +#endif + } /* Don't try root if src==dst drive or source path given */ if ( (drive == srcDrive) || (*srcPath && ((srcPath[1] != ':') || ((srcPath[1] == ':') && srcPath[2]))) ) @@ -700,7 +717,7 @@ BOOL copy(COUNT drive, BYTE * srcPath, BYTE * rootPath, BYTE * file) copied += ret; } -#ifdef __TURBO__ +#ifdef __TURBOC__ { struct ftime ftime; getftime(fdin, &ftime); From 27e19b1af283ab34ae4f864dcbf0ecfa25195de3 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sun, 4 Nov 2001 20:02:28 +0000 Subject: [PATCH 099/671] Remove binaries and old makefile names git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@315 6ac86273-5f31-0410-b378-82cca8765d1b --- boot/boot.mak | 72 ------ drivers/device.mak | 110 ---------- kernel/kernel.mak | 536 --------------------------------------------- lib/libm.mak | 53 ----- sys/bin2c.mak | 61 ------ sys/sys.mak | 108 --------- 6 files changed, 940 deletions(-) delete mode 100644 boot/boot.mak delete mode 100644 drivers/device.mak delete mode 100644 kernel/kernel.mak delete mode 100644 lib/libm.mak delete mode 100644 sys/bin2c.mak delete mode 100644 sys/sys.mak diff --git a/boot/boot.mak b/boot/boot.mak deleted file mode 100644 index c7dc2861..00000000 --- a/boot/boot.mak +++ /dev/null @@ -1,72 +0,0 @@ -# -# makefile for DOS-C boot -# -# $Id$ -# - -# $Log$ -# Revision 1.4 2001/09/23 20:39:44 bartoldeman -# FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling -# -# Revision 1.3 2000/05/25 20:56:19 jimtabor -# Fixed project history -# -# Revision 1.2 2000/05/11 03:56:42 jimtabor -# Clean up and Release -# -# Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 -# The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with -# MS-DOS. Distributed under the GNU GPL. -# -# Revision 1.3 1999/04/23 03:44:17 jprice -# Ported to NASM by ror4. Improvements -# -# Revision 1.2 1999/04/01 07:23:20 jprice -# New boot loader -# -# Revision 1.1.1.1 1999/03/29 15:39:39 jprice -# New version without IPL.SYS -# -# Revision 1.3 1999/02/09 04:49:17 jprice -# Make makefile use common config.mak file -# -# Revision 1.2 1999/01/21 05:03:58 jprice -# Formating. -# -# Revision 1.1.1.1 1999/01/20 05:51:00 jprice -# Imported sources -# -# -# Rev 1.3 10 Jan 1997 4:51:54 patv -#Changed to use FreeDOS exe2bin and support new boot code -# -# Rev 1.2 17 Dec 1996 12:52:32 patv -#Converted to FreeDOS exe2bin. -# -# Rev 1.1 29 Aug 1996 13:06:50 patv -#Bug fixes for v0.91b -# -# Rev 1.0 02 Jul 1995 9:11:26 patv -#Initial revision. -# - -!include "..\config.mak" - -production: b_fat12.bin b_fat16.bin b_fat32.bin - -b_fat12.bin: boot.asm - $(NASM) -dISFAT12 boot.asm -ob_fat12.bin - -b_fat16.bin: boot.asm - $(NASM) -dISFAT16 boot.asm -ob_fat16.bin - -b_fat32.bin: boot32.asm - $(NASM) boot32.asm -ob_fat32.bin - -clobber: clean - $(RM) b_fat12.bin b_fat16.bin b_fat32.bin status.me - -clean: - $(RM) *.lst *.map *.bak *.obj - - diff --git a/drivers/device.mak b/drivers/device.mak deleted file mode 100644 index 1efaefc7..00000000 --- a/drivers/device.mak +++ /dev/null @@ -1,110 +0,0 @@ -# -# makefile for device.lib -# -# $Id$ -# - -# $Log$ -# Revision 1.3 2000/05/25 20:56:19 jimtabor -# Fixed project history -# -# Revision 1.2 2000/05/11 03:56:20 jimtabor -# Clean up and Release -# -# Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 -# The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with -# MS-DOS. Distributed under the GNU GPL. -# -# Revision 1.6 1999/08/25 03:16:36 jprice -# ror4 patches to allow TC 2.01 compile. -# -# Revision 1.5 1999/08/10 17:21:08 jprice -# ror4 2011-01 patch -# -# Revision 1.4 1999/04/23 03:44:52 jprice -# Improved by jprice -# -# Revision 1.3 1999/04/13 15:47:07 jprice -# no message -# -# Revision 1.2 1999/03/29 17:08:31 jprice -# ror4 changes -# -# Revision 1.1.1.1 1999/03/29 15:40:23 jprice -# New version without IPL.SYS -# -# Revision 1.3 1999/02/09 04:49:25 jprice -# Make makefile use common config.mak file -# -# Revision 1.2 1999/01/22 04:16:39 jprice -# Formating -# -# Revision 1.1.1.1 1999/01/20 05:51:00 jprice -# Imported sources -# -# -# Rev 1.2 29 Aug 1996 13:07:12 patv -#Bug fixes for v0.91b -# -# Rev 1.1 19 Feb 1996 3:19:26 patv -#Added NLS, int2f and config.sys processing -# -# Rev 1.0 02 Jul 1995 7:54:52 patv -#Initial revision. -# - -!include "..\config.mak" - - -# MICROSOFT C -# ----------- -#MODEL = s -#CFLAGS = /c /Gs /A$(MODEL) -#AFLAGS = /Mx /Dmem$(MODEL)=1 -#TERM = ; - -# BORLAND C -# ----------- -MODEL = s -CFLAGS = -c -m$(MODEL) -AFLAGS = /Mx /Dmem$(MODEL)=1 -LIBFLAGS = /c -TERM = - -OBJS = devend.obj floppy.obj getvec.obj timer.obj rdpcclk.obj rdatclk.obj \ -wrpcclk.obj wratclk.obj - -LIBOBJS= +devend +floppy +getvec +timer +rdpcclk +rdatclk +wrpcclk +wratclk - - - -# Build the LIBRARY -# ----------------- -all: production - -production: ..\lib\device.lib - -..\lib\device.lib: device.lib - copy device.lib ..\lib - -clobber: clean - $(RM) device.lib status.me ..\lib\device.lib - -clean: - $(RM) *.obj *.bak *.crf *.xrf *.map *.lst - -device.lib : $(OBJS) - del device.lib - $(LIBUTIL) $(LIBFLAGS) device $(LIBOBJS) $(TERM) - - - -# RULES (DEPENDENCIES) -# ---------------- -.c.obj : - $(CC) $(CFLAGS) $< - -.asm.obj : - $(NASM) -f obj $< - - diff --git a/kernel/kernel.mak b/kernel/kernel.mak deleted file mode 100644 index b4771351..00000000 --- a/kernel/kernel.mak +++ /dev/null @@ -1,536 +0,0 @@ -# -# Makefile for Borland C++ 3.1 for kernel.sys -# -# $Id$ -# - -# $Log$ -# Revision 1.13 2001/07/24 16:56:29 bartoldeman -# fixes for FCBs, DJGPP ls, DBLBYTE, dyninit allocation (2024e). -# -# Revision 1.12 2001/07/22 01:58:58 bartoldeman -# Support for Brian's FORMAT, DJGPP libc compilation, cleanups, MSCDEX -# -# Revision 1.11 2001/07/09 22:19:33 bartoldeman -# LBA/FCB/FAT/SYS/Ctrl-C/ioctl fixes + memory savings -# -# Revision 1.10 2001/04/21 22:32:53 bartoldeman -# Init DS=Init CS, fixed stack overflow problems and misc bugs. -# -# Revision 1.9 2001/04/16 14:28:32 bartoldeman -# Kernel build 2024. Fixed critical error handler/config.sys/makefiles/UMBs -# -# Revision 1.8 2001/04/15 03:21:50 bartoldeman -# See history.txt for the list of fixes. -# -# Revision 1.7 2001/03/25 17:11:54 bartoldeman -# Fixed sys.com compilation. Updated to 2023. Also: see history.txt. -# -# Revision 1.6 2001/03/21 02:56:26 bartoldeman -# See history.txt for changes. Bug fixes and HMA support are the main ones. -# -# Revision 1.4 2000/08/06 05:50:17 jimtabor -# Add new files and update cvs with patches and changes -# -# Revision 1.3 2000/05/25 20:56:21 jimtabor -# Fixed project history -# -# Revision 1.2 2000/05/08 04:30:00 jimtabor -# Update CVS to 2020 -# -# Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 -# The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with -# MS-DOS. Distributed under the GNU GPL. -# -# Revision 1.14 2000/03/31 05:40:09 jtabor -# Added Eric W. Biederman Patches -# -# Revision 1.13 2000/03/17 22:59:04 kernel -# Steffen Kaiser's NLS changes -# -# Revision 1.12 2000/03/09 06:07:11 kernel -# 2017f updates by James Tabor -# -# Revision 1.11 1999/09/23 04:40:47 jprice -# *** empty log message *** -# -# Revision 1.8 1999/09/13 20:41:41 jprice -# Some clean up. -# -# Revision 1.7 1999/08/25 03:18:09 jprice -# ror4 patches to allow TC 2.01 compile. -# -# Revision 1.6 1999/08/10 17:57:13 jprice -# ror4 2011-02 patch -# -# Revision 1.5 1999/04/23 04:25:15 jprice -# no message -# -# Revision 1.4 1999/04/23 03:45:11 jprice -# Improved by jprice -# -# Revision 1.3 1999/04/16 12:21:22 jprice -# Steffen c-break handler changes -# -# Revision 1.2 1999/04/13 15:48:21 jprice -# no message -# -# Revision 1.1.1.1 1999/03/29 15:41:15 jprice -# New version without IPL.SYS -# -# Revision 1.7 1999/03/01 06:04:37 jprice -# Fixed so it'll work with config.mak -# -# Revision 1.6 1999/03/01 05:46:43 jprice -# Turned off DEBUG define. -# -# Revision 1.5 1999/02/09 04:49:43 jprice -# Make makefile use common config.mak file -# -# Revision 1.4 1999/02/08 05:55:57 jprice -# Added Pat's 1937 kernel patches -# -# Revision 1.3 1999/02/04 03:09:59 jprice -# Added option to share constants (-d). -# -# Revision 1.2 1999/01/22 04:13:26 jprice -# Formating -# -# Revision 1.1.1.1 1999/01/20 05:51:01 jprice -# Imported sources -# -# -# Rev 1.8.1 10 Jan 1999 SRM -#Took out "/P-" from TLINK -#Changed "bcc" to "tcc" -# -# Rev 1.9 06 Dec 1998 8:45:40 patv -#Added new files for I/O subsystem. -# -# Rev 1.8 22 Jan 1998 14:50:06 patv -#Outdated stacks.asm. -# -# Rev 1.6 03 Jan 1998 8:36:50 patv -#Converted data area to SDA format -# -# Rev 1.5 30 Jan 1997 7:55:54 patv -#Added TSC flag for trace support. -# -# Rev 1.4 16 Jan 1997 12:46:42 patv -#pre-Release 0.92 feature additions -# -# Rev 1.3 29 Aug 1996 13:07:34 patv -#Bug fixes for v0.91b -# -# Rev 1.2 29 May 1996 21:03:32 patv -#bug fixes for v0.91a -# -# Rev 1.1 19 Feb 1996 3:35:38 patv -#Added NLS, int2f and config.sys processing -# -# Rev 1.0 02 Jul 1995 8:30:22 patv -#Initial revision. -# -# $EndLog$ -# - -!include "..\config.mak" - -RELEASE = 1.00 - -# Compiler and Options for Borland C++ -# ------------------------------------ -# -# -zAname ¦ ¦ Code class -# -zBname ¦ ¦ BSS class -# -zCname ¦ ¦ Code segment -# -zDname ¦ ¦ BSS segment -# -zEname ¦ ¦ Far segment -# -zFname ¦ ¦ Far class -# -zGname ¦ ¦ BSS group -# -zHname ¦ ¦ Far group -# -zPname ¦ ¦ Code group -# -zRname ¦ ¦ Data segment -# -zSname ¦ ¦ Data group -# -zTname ¦ ¦ Data class -# -zX ¦«¦ Use default name for "X" - -# -# Compiler and Options for Borland C++ -# ------------------------------------ -LIBPATH = . -INCLUDEPATH = ..\HDR -#AFLAGS = /Mx /DSTANDALONE=1 /I..\HDR -NASMFLAGS = -i../hdr/ -LIBS =..\LIB\DEVICE.LIB ..\LIB\LIBM.LIB -INITCFLAGS =$(ALLCFLAGS) -zAINIT -zCINIT_TEXT -zDIB -zRID -zTID -zPIGROUP -zBIB \ --zGIGROUP -zSIGROUP -CFLAGS =$(ALLCFLAGS) -zAHMA -zCHMA_TEXT -HDR=../hdr/ - -# *Implicit Rules* -.c.obj: - $(CC) $(CFLAGS) -c $< - -# Borland make 3.6 does not like this rule. -#.c.asm: -# $(CC) $(CFLAGS) -S $< - -.cpp.obj: - $(CC) $(CFLAGS) -c $< - -.asm.obj: - $(NASM) $(NASMFLAGS) -f obj $< - -# *List Macros* - - -EXE_dependencies = \ - apisupt.obj \ - asmsupt.obj \ - blockio.obj \ - break.obj \ - chario.obj \ - config.obj \ - console.obj \ - dosidle.obj \ - dosfns.obj \ - dosnames.obj \ - dsk.obj \ - initdisk.obj \ - entry.obj \ - error.obj \ - execrh.obj \ - fatdir.obj \ - fatfs.obj \ - fattab.obj \ - fcbfns.obj \ - initoem.obj \ - int2f.obj \ - inthndlr.obj \ - io.obj \ - intr.obj \ - ioctl.obj \ - irqstack.obj \ - kernel.obj \ - main.obj \ - memmgr.obj \ - misc.obj \ - newstuff.obj \ - network.obj \ - nls.obj \ - nls_hc.obj \ - nlssupt.obj \ - prf.obj \ - initprf.obj \ - printer.obj \ - procsupt.obj \ - serial.obj \ - strings.obj \ - sysclk.obj \ - syspack.obj \ - systime.obj \ - task.obj \ - inithma.obj \ - DynData.obj \ - DynInit.obj - -# *Explicit Rules* - -production: ..\bin\kernel.sys - -..\bin\kernel.sys: kernel.sys - copy kernel.sys ..\bin - -kernel.sys: kernel.exe - ..\utils\exeflat kernel.exe kernel.sys 0x60 - -clobber: clean - $(RM) kernel.exe kernel.sys status.me - -clean: - $(RM) *.obj *.bak *.crf *.xrf *.map *.lst - -# XXX: This is a very ugly way of linking the kernel, forced upon us by the -# inability of Turbo `make' 2.0 to perform command line redirection. -- ror4 -kernel.exe: $(EXE_dependencies) $(LIBS) - $(RM) kernel.lib - $(LIBUTIL) kernel +entry +io +blockio +chario +dosfns +console - $(LIBUTIL) kernel +printer +serial +dsk +initdisk+error +fatdir +fatfs - $(LIBUTIL) kernel +fattab +fcbfns +initoem +initHMA+inthndlr +ioctl +nls_hc - $(LIBUTIL) kernel +main +config +memmgr +misc +newstuff +nls +intr - $(LIBUTIL) kernel +dosnames +prf +initprf +strings +network +sysclk +syspack - $(LIBUTIL) kernel +systime +task +int2f +irqstack +apisupt - $(LIBUTIL) kernel +asmsupt +execrh +nlssupt +procsupt +break - $(LIBUTIL) kernel +dosidle+dyndata+dyninit - $(RM) kernel.bak - $(LINK) /m/c/L$(LIBPATH) kernel,kernel,kernel,kernel+$(LIBS); - $(RM) kernel.lib - -# *Individual File Dependencies* -kernel.obj: kernel.asm segs.inc - -console.obj: console.asm io.inc - -printer.obj: printer.asm io.inc - -serial.obj: serial.asm io.inc - -entry.obj: entry.asm segs.inc $(HDR)stacks.inc - -apisupt.obj: apisupt.asm segs.inc - -asmsupt.obj: asmsupt.asm segs.inc - -execrh.obj: execrh.asm segs.inc - -int2f.obj: int2f.asm segs.inc - -intr.obj: intr.asm segs.inc intr.h - -io.obj: io.asm segs.inc - -irqstack.obj: irqstack.asm - -nls_hc.obj: nls_hc.asm segs.inc - -nlssupt.obj: nlssupt.asm segs.inc - -procsupt.obj: procsupt.asm segs.inc $(HDR)stacks.inc - -dosidle.obj: dosidle.asm segs.inc - -# XXX: Special handling for initialization modules -- this is required because -# TC 2.01 cannot handle `#pragma option' like TC 3 can. -- ror4 -config.obj: config.c init-mod.h $(HDR)portab.h globals.h \ - $(HDR)device.h $(HDR)mcb.h $(HDR)pcb.h $(HDR)date.h $(HDR)time.h \ - $(HDR)fat.h $(HDR)fcb.h $(HDR)tail.h $(HDR)process.h $(HDR)dcb.h \ - $(HDR)sft.h $(HDR)cds.h $(HDR)exe.h $(HDR)fnode.h \ - $(HDR)dirmatch.h $(HDR)file.h $(HDR)clock.h $(HDR)kbd.h \ - $(HDR)error.h $(HDR)version.h proto.h turboc.cfg dyndata.h - $(CC) $(INITCFLAGS) -c config.c - -initoem.obj: initoem.c init-mod.h $(HDR)portab.h globals.h \ - $(HDR)device.h $(HDR)mcb.h $(HDR)pcb.h $(HDR)date.h $(HDR)time.h \ - $(HDR)fat.h $(HDR)fcb.h $(HDR)tail.h $(HDR)process.h $(HDR)dcb.h \ - $(HDR)sft.h $(HDR)cds.h $(HDR)exe.h $(HDR)fnode.h \ - $(HDR)dirmatch.h $(HDR)file.h $(HDR)clock.h $(HDR)kbd.h \ - $(HDR)error.h $(HDR)version.h proto.h turboc.cfg dyndata.h - $(CC) $(INITCFLAGS) -c initoem.c - -main.obj: main.c init-mod.h $(HDR)portab.h globals.h $(HDR)device.h \ - $(HDR)mcb.h $(HDR)pcb.h $(HDR)date.h $(HDR)time.h $(HDR)fat.h \ - $(HDR)fcb.h $(HDR)tail.h $(HDR)process.h $(HDR)dcb.h $(HDR)sft.h \ - $(HDR)cds.h $(HDR)exe.h $(HDR)fnode.h $(HDR)dirmatch.h \ - $(HDR)file.h $(HDR)clock.h $(HDR)kbd.h $(HDR)error.h \ - $(HDR)version.h proto.h turboc.cfg dyndata.h - $(CC) $(INITCFLAGS) -c main.c - -initHMA.obj: initHMA.c init-mod.h $(HDR)portab.h globals.h $(HDR)device.h \ - $(HDR)mcb.h $(HDR)pcb.h $(HDR)date.h $(HDR)time.h $(HDR)fat.h \ - $(HDR)fcb.h $(HDR)tail.h $(HDR)process.h $(HDR)dcb.h $(HDR)sft.h \ - $(HDR)cds.h $(HDR)exe.h $(HDR)fnode.h $(HDR)dirmatch.h \ - $(HDR)file.h $(HDR)clock.h $(HDR)kbd.h $(HDR)error.h \ - $(HDR)version.h proto.h turboc.cfg dyndata.h - $(CC) $(INITCFLAGS) -c initHMA.c - -DynInit.obj: DynInit.c init-mod.h $(HDR)portab.h globals.h $(HDR)device.h \ - $(HDR)mcb.h $(HDR)pcb.h $(HDR)date.h $(HDR)time.h $(HDR)fat.h \ - $(HDR)fcb.h $(HDR)tail.h $(HDR)process.h $(HDR)dcb.h $(HDR)sft.h \ - $(HDR)cds.h $(HDR)exe.h $(HDR)fnode.h $(HDR)dirmatch.h \ - $(HDR)file.h $(HDR)clock.h $(HDR)kbd.h $(HDR)error.h \ - $(HDR)version.h proto.h turboc.cfg dyndata.h - $(CC) $(INITCFLAGS) -c DynInit.c - -initdisk.obj: initdisk.c $(HDR)portab.h globals.h $(HDR)device.h $(HDR)mcb.h \ - $(HDR)pcb.h $(HDR)date.h $(HDR)time.h $(HDR)fat.h $(HDR)fcb.h \ - $(HDR)tail.h $(HDR)process.h $(HDR)dcb.h $(HDR)sft.h $(HDR)cds.h \ - $(HDR)exe.h $(HDR)fnode.h $(HDR)dirmatch.h $(HDR)file.h \ - $(HDR)clock.h $(HDR)kbd.h $(HDR)error.h $(HDR)version.h proto.h \ - turboc.cfg dyndata.h - $(CC) $(INITCFLAGS) -c initDISK.c - - -# -zBname ¦ ¦ BSS class -# -zDname ¦ ¦ BSS segment -# -zEname ¦ ¦ Far segment -# -zFname ¦ ¦ Far class -# -zGname ¦ ¦ BSS group -# -zHname ¦ ¦ Far group -# -zRname ¦ ¦ Data segment -# -zSname ¦ ¦ Data group -# -zTname ¦ ¦ Data class - -dynDATA.obj: dynDATA.c dynDATA.H - $(CC) -c -zRDYN_DATA -zTDYN_DATA -zDDYN_DATA -zBDYN_DATA dynDATA.c - - -#the printf for INIT_TEXT: -initprf.obj: prf.c $(HDR)portab.h turboc.cfg - $(CC) -DFORINIT $(INITCFLAGS) -oinitprf.obj -c prf.c - -# XXX: I generated these using `gcc -MM' and `sed', so they may not be -# completely correct... -- ror4 -blockio.obj: blockio.c $(HDR)portab.h globals.h $(HDR)device.h \ - $(HDR)mcb.h $(HDR)pcb.h $(HDR)date.h $(HDR)time.h $(HDR)fat.h \ - $(HDR)fcb.h $(HDR)tail.h $(HDR)process.h $(HDR)dcb.h $(HDR)sft.h \ - $(HDR)cds.h $(HDR)exe.h $(HDR)fnode.h $(HDR)dirmatch.h \ - $(HDR)file.h $(HDR)clock.h $(HDR)kbd.h $(HDR)error.h \ - $(HDR)version.h proto.h turboc.cfg - -break.obj: break.c $(HDR)portab.h globals.h $(HDR)device.h \ - $(HDR)mcb.h $(HDR)pcb.h $(HDR)date.h $(HDR)time.h $(HDR)fat.h \ - $(HDR)fcb.h $(HDR)tail.h $(HDR)process.h $(HDR)dcb.h $(HDR)sft.h \ - $(HDR)cds.h $(HDR)exe.h $(HDR)fnode.h $(HDR)dirmatch.h \ - $(HDR)file.h $(HDR)clock.h $(HDR)kbd.h $(HDR)error.h \ - $(HDR)version.h proto.h turboc.cfg - -chario.obj: chario.c $(HDR)portab.h globals.h $(HDR)device.h \ - $(HDR)mcb.h $(HDR)pcb.h $(HDR)date.h $(HDR)time.h $(HDR)fat.h \ - $(HDR)fcb.h $(HDR)tail.h $(HDR)process.h $(HDR)dcb.h $(HDR)sft.h \ - $(HDR)cds.h $(HDR)exe.h $(HDR)fnode.h $(HDR)dirmatch.h \ - $(HDR)file.h $(HDR)clock.h $(HDR)kbd.h $(HDR)error.h \ - $(HDR)version.h proto.h turboc.cfg - -dosfns.obj: dosfns.c $(HDR)portab.h globals.h $(HDR)device.h \ - $(HDR)mcb.h $(HDR)pcb.h $(HDR)date.h $(HDR)time.h $(HDR)fat.h \ - $(HDR)fcb.h $(HDR)tail.h $(HDR)process.h $(HDR)dcb.h $(HDR)sft.h \ - $(HDR)cds.h $(HDR)exe.h $(HDR)fnode.h $(HDR)dirmatch.h \ - $(HDR)file.h $(HDR)clock.h $(HDR)kbd.h $(HDR)error.h \ - $(HDR)version.h proto.h turboc.cfg - -dosnames.obj: dosnames.c $(HDR)portab.h globals.h $(HDR)device.h \ - $(HDR)mcb.h $(HDR)pcb.h $(HDR)date.h $(HDR)time.h $(HDR)fat.h \ - $(HDR)fcb.h $(HDR)tail.h $(HDR)process.h $(HDR)dcb.h $(HDR)sft.h \ - $(HDR)cds.h $(HDR)exe.h $(HDR)fnode.h $(HDR)dirmatch.h \ - $(HDR)file.h $(HDR)clock.h $(HDR)kbd.h $(HDR)error.h \ - $(HDR)version.h proto.h turboc.cfg - -dsk.obj: dsk.c $(HDR)portab.h globals.h $(HDR)device.h $(HDR)mcb.h \ - $(HDR)pcb.h $(HDR)date.h $(HDR)time.h $(HDR)fat.h $(HDR)fcb.h \ - $(HDR)tail.h $(HDR)process.h $(HDR)dcb.h $(HDR)sft.h $(HDR)cds.h \ - $(HDR)exe.h $(HDR)fnode.h $(HDR)dirmatch.h $(HDR)file.h \ - $(HDR)clock.h $(HDR)kbd.h $(HDR)error.h $(HDR)version.h proto.h \ - turboc.cfg - - -error.obj: error.c $(HDR)portab.h globals.h $(HDR)device.h \ - $(HDR)mcb.h $(HDR)pcb.h $(HDR)date.h $(HDR)time.h $(HDR)fat.h \ - $(HDR)fcb.h $(HDR)tail.h $(HDR)process.h $(HDR)dcb.h $(HDR)sft.h \ - $(HDR)cds.h $(HDR)exe.h $(HDR)fnode.h $(HDR)dirmatch.h \ - $(HDR)file.h $(HDR)clock.h $(HDR)kbd.h $(HDR)error.h \ - $(HDR)version.h proto.h turboc.cfg - -fatdir.obj: fatdir.c $(HDR)portab.h globals.h $(HDR)device.h \ - $(HDR)mcb.h $(HDR)pcb.h $(HDR)date.h $(HDR)time.h $(HDR)fat.h \ - $(HDR)fcb.h $(HDR)tail.h $(HDR)process.h $(HDR)dcb.h $(HDR)sft.h \ - $(HDR)cds.h $(HDR)exe.h $(HDR)fnode.h $(HDR)dirmatch.h \ - $(HDR)file.h $(HDR)clock.h $(HDR)kbd.h $(HDR)error.h \ - $(HDR)version.h proto.h turboc.cfg - -fatfs.obj: fatfs.c $(HDR)portab.h globals.h $(HDR)device.h \ - $(HDR)mcb.h $(HDR)pcb.h $(HDR)date.h $(HDR)time.h $(HDR)fat.h \ - $(HDR)fcb.h $(HDR)tail.h $(HDR)process.h $(HDR)dcb.h $(HDR)sft.h \ - $(HDR)cds.h $(HDR)exe.h $(HDR)fnode.h $(HDR)dirmatch.h \ - $(HDR)file.h $(HDR)clock.h $(HDR)kbd.h $(HDR)error.h \ - $(HDR)version.h proto.h turboc.cfg - -fattab.obj: fattab.c $(HDR)portab.h globals.h $(HDR)device.h \ - $(HDR)mcb.h $(HDR)pcb.h $(HDR)date.h $(HDR)time.h $(HDR)fat.h \ - $(HDR)fcb.h $(HDR)tail.h $(HDR)process.h $(HDR)dcb.h $(HDR)sft.h \ - $(HDR)cds.h $(HDR)exe.h $(HDR)fnode.h $(HDR)dirmatch.h \ - $(HDR)file.h $(HDR)clock.h $(HDR)kbd.h $(HDR)error.h \ - $(HDR)version.h proto.h turboc.cfg - -fcbfns.obj: fcbfns.c $(HDR)portab.h globals.h $(HDR)device.h \ - $(HDR)mcb.h $(HDR)pcb.h $(HDR)date.h $(HDR)time.h $(HDR)fat.h \ - $(HDR)fcb.h $(HDR)tail.h $(HDR)process.h $(HDR)dcb.h $(HDR)sft.h \ - $(HDR)cds.h $(HDR)exe.h $(HDR)fnode.h $(HDR)dirmatch.h \ - $(HDR)file.h $(HDR)clock.h $(HDR)kbd.h $(HDR)error.h \ - $(HDR)version.h proto.h turboc.cfg - -inthndlr.obj: inthndlr.c $(HDR)portab.h globals.h $(HDR)device.h \ - $(HDR)mcb.h $(HDR)pcb.h $(HDR)date.h $(HDR)time.h $(HDR)fat.h \ - $(HDR)fcb.h $(HDR)tail.h $(HDR)process.h $(HDR)dcb.h $(HDR)sft.h \ - $(HDR)cds.h $(HDR)exe.h $(HDR)fnode.h $(HDR)dirmatch.h \ - $(HDR)file.h $(HDR)clock.h $(HDR)kbd.h $(HDR)error.h \ - $(HDR)version.h proto.h turboc.cfg - -ioctl.obj: ioctl.c $(HDR)portab.h globals.h $(HDR)device.h \ - $(HDR)mcb.h $(HDR)pcb.h $(HDR)date.h $(HDR)time.h $(HDR)fat.h \ - $(HDR)fcb.h $(HDR)tail.h $(HDR)process.h $(HDR)dcb.h $(HDR)sft.h \ - $(HDR)cds.h $(HDR)exe.h $(HDR)fnode.h $(HDR)dirmatch.h \ - $(HDR)file.h $(HDR)clock.h $(HDR)kbd.h $(HDR)error.h \ - $(HDR)version.h proto.h turboc.cfg - -memmgr.obj: memmgr.c $(HDR)portab.h globals.h $(HDR)device.h \ - $(HDR)mcb.h $(HDR)pcb.h $(HDR)date.h $(HDR)time.h $(HDR)fat.h \ - $(HDR)fcb.h $(HDR)tail.h $(HDR)process.h $(HDR)dcb.h $(HDR)sft.h \ - $(HDR)cds.h $(HDR)exe.h $(HDR)fnode.h $(HDR)dirmatch.h \ - $(HDR)file.h $(HDR)clock.h $(HDR)kbd.h $(HDR)error.h \ - $(HDR)version.h proto.h turboc.cfg - -misc.obj: misc.c $(HDR)portab.h globals.h $(HDR)device.h $(HDR)mcb.h \ - $(HDR)pcb.h $(HDR)date.h $(HDR)time.h $(HDR)fat.h $(HDR)fcb.h \ - $(HDR)tail.h $(HDR)process.h $(HDR)dcb.h $(HDR)sft.h $(HDR)cds.h \ - $(HDR)exe.h $(HDR)fnode.h $(HDR)dirmatch.h $(HDR)file.h \ - $(HDR)clock.h $(HDR)kbd.h $(HDR)error.h $(HDR)version.h proto.h \ - turboc.cfg - -newstuff.obj: newstuff.c $(HDR)portab.h globals.h $(HDR)device.h \ - $(HDR)mcb.h $(HDR)pcb.h $(HDR)date.h $(HDR)time.h $(HDR)fat.h \ - $(HDR)fcb.h $(HDR)tail.h $(HDR)process.h $(HDR)dcb.h $(HDR)sft.h \ - $(HDR)cds.h $(HDR)exe.h $(HDR)fnode.h $(HDR)dirmatch.h \ - $(HDR)file.h $(HDR)clock.h $(HDR)kbd.h $(HDR)error.h \ - $(HDR)version.h proto.h turboc.cfg - -network.obj: network.c $(HDR)portab.h globals.h $(HDR)device.h \ - $(HDR)mcb.h $(HDR)pcb.h $(HDR)date.h $(HDR)time.h $(HDR)fat.h \ - $(HDR)fcb.h $(HDR)tail.h $(HDR)process.h $(HDR)dcb.h $(HDR)sft.h \ - $(HDR)cds.h $(HDR)exe.h $(HDR)fnode.h $(HDR)dirmatch.h \ - $(HDR)file.h $(HDR)clock.h $(HDR)kbd.h $(HDR)error.h \ - $(HDR)version.h proto.h turboc.cfg - -nls.obj: nls.c $(HDR)portab.h globals.h $(HDR)device.h $(HDR)mcb.h \ - $(HDR)pcb.h $(HDR)date.h $(HDR)time.h $(HDR)fat.h $(HDR)fcb.h \ - $(HDR)tail.h $(HDR)process.h $(HDR)dcb.h $(HDR)sft.h $(HDR)cds.h \ - $(HDR)exe.h $(HDR)fnode.h $(HDR)dirmatch.h $(HDR)file.h \ - $(HDR)clock.h $(HDR)kbd.h $(HDR)error.h $(HDR)version.h proto.h \ - turboc.cfg - -# \ -# 001-437.nls - -prf.obj: prf.c $(HDR)portab.h turboc.cfg - -strings.obj: strings.c $(HDR)portab.h turboc.cfg - -sysclk.obj: sysclk.c $(HDR)portab.h globals.h $(HDR)device.h \ - $(HDR)mcb.h $(HDR)pcb.h $(HDR)date.h $(HDR)time.h $(HDR)fat.h \ - $(HDR)fcb.h $(HDR)tail.h $(HDR)process.h $(HDR)dcb.h $(HDR)sft.h \ - $(HDR)cds.h $(HDR)exe.h $(HDR)fnode.h $(HDR)dirmatch.h \ - $(HDR)file.h $(HDR)clock.h $(HDR)kbd.h $(HDR)error.h \ - $(HDR)version.h proto.h turboc.cfg - -syspack.obj: syspack.c $(HDR)portab.h globals.h $(HDR)device.h \ - $(HDR)mcb.h $(HDR)pcb.h $(HDR)date.h $(HDR)time.h $(HDR)fat.h \ - $(HDR)fcb.h $(HDR)tail.h $(HDR)process.h $(HDR)dcb.h $(HDR)sft.h \ - $(HDR)cds.h $(HDR)exe.h $(HDR)fnode.h $(HDR)dirmatch.h \ - $(HDR)file.h $(HDR)clock.h $(HDR)kbd.h $(HDR)error.h \ - $(HDR)version.h proto.h turboc.cfg - -systime.obj: systime.c $(HDR)portab.h $(HDR)time.h $(HDR)date.h \ - globals.h $(HDR)device.h $(HDR)mcb.h $(HDR)pcb.h $(HDR)fat.h \ - $(HDR)fcb.h $(HDR)tail.h $(HDR)process.h $(HDR)dcb.h $(HDR)sft.h \ - $(HDR)cds.h $(HDR)exe.h $(HDR)fnode.h $(HDR)dirmatch.h \ - $(HDR)file.h $(HDR)clock.h $(HDR)kbd.h $(HDR)error.h \ - $(HDR)version.h proto.h turboc.cfg - -task.obj: task.c $(HDR)portab.h globals.h $(HDR)device.h $(HDR)mcb.h \ - $(HDR)pcb.h $(HDR)date.h $(HDR)time.h $(HDR)fat.h $(HDR)fcb.h \ - $(HDR)tail.h $(HDR)process.h $(HDR)dcb.h $(HDR)sft.h $(HDR)cds.h \ - $(HDR)exe.h $(HDR)fnode.h $(HDR)dirmatch.h $(HDR)file.h \ - $(HDR)clock.h $(HDR)kbd.h $(HDR)error.h $(HDR)version.h proto.h \ - turboc.cfg - - diff --git a/lib/libm.mak b/lib/libm.mak deleted file mode 100644 index ed6565f5..00000000 --- a/lib/libm.mak +++ /dev/null @@ -1,53 +0,0 @@ -# -# makefile for libm.lib -# -# $Id$ -# - -# $Log$ -# Revision 1.5 2001/06/03 14:16:18 bartoldeman -# BUFFERS tuning and misc bug fixes/cleanups (2024c). -# -# Revision 1.4 2001/03/19 04:50:56 bartoldeman -# See history.txt for overview: put kernel 2022beo1 into CVS -# -# Revision 1.4 2001/03/08 21:15:00 bartoldeman -# Fix from Martin Stromberg to make this fully configurable from config.mak -# -# Revision 1.3 2000/05/25 20:56:22 jimtabor -# Fixed project history -# -# Revision 1.2 2000/05/11 03:57:10 jimtabor -# Clean up and Release -# -# Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 -# The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with -# MS-DOS. Distributed under the GNU GPL. -# -# Revision 1.6 1999/09/14 17:32:20 jprice -# no message -# -# Revision 1.5 1999/09/13 20:13:15 jprice -# Added !if so we can use TC2 or TC3 to compile. -# -# Revision 1.4 1999/08/25 03:19:22 jprice -# ror4 patches to allow TC 2.01 compile. -# -# Revision 1.3 1999/04/23 03:45:18 jprice -# Improved by jprice -# - -!include "..\config.mak" - - -libm.lib: $(CLIB) ..\config.mak - $(LIBUTIL) $(CLIB) $(MATH_EXTRACT) - $(LIBUTIL) libm $(MATH_INSERT) - $(RM) *.OBJ - - -clobber: clean - $(RM) libm.lib status.me - -clean: - $(RM) *.obj *.bak diff --git a/sys/bin2c.mak b/sys/bin2c.mak deleted file mode 100644 index ae4a92c5..00000000 --- a/sys/bin2c.mak +++ /dev/null @@ -1,61 +0,0 @@ -# -# makefile for bin2c.com -# -# $Id$ -# -# $Log$ -# Revision 1.3 2000/05/25 20:56:23 jimtabor -# Fixed project history -# -# Revision 1.2 2000/05/15 05:28:09 jimtabor -# Cleanup CRs -# -# Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 -# The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with -# MS-DOS. Distributed under the GNU GPL. -# -# Revision 1.6 1999/09/20 18:34:40 jprice -# *** empty log message *** -# -# Revision 1.5 1999/08/25 03:19:51 jprice -# ror4 patches to allow TC 2.01 compile. -# -# Revision 1.4 1999/05/03 05:01:38 jprice -# no message -# -# Revision 1.3 1999/04/23 03:45:33 jprice -# Improved by jprice -# - -!include "..\config.mak" - -CFLAGS = -mt -1- -v -vi- -k- -f- -ff- -O -Z -d -I$(INCLUDEPATH) -L$(LIBPATH) - -# *Implicit Rules* -.c.obj: - $(CC) $(CFLAGS) -c $< - -.cpp.obj: - $(CC) $(CFLAGS) -c $< - -# *List Macros* - -EXE_dependencies = \ - bin2c.obj - -# *Explicit Rules* -production: bin2c.com - -bin2c.com: $(EXE_dependencies) - $(LINK) /m/t/c $(LIBPATH)\c0t.obj+bin2c.obj,bin2c,,\ - $(LIBS)+$(CLIB); - - -clobber: clean - $(RM) bin2c.com - -clean: - ..\utils\rm -f *.obj *.bak *.crf *.xrf *.map *.lst *.las status.me - -# *Individual File Dependencies* -bin2c.obj: bin2c.c diff --git a/sys/sys.mak b/sys/sys.mak deleted file mode 100644 index 50d83237..00000000 --- a/sys/sys.mak +++ /dev/null @@ -1,108 +0,0 @@ -# -# makefile for sys.com -# -# $Id$ -# -# $Log$ -# Revision 1.9 2001/09/23 20:39:44 bartoldeman -# FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling -# -# Revision 1.8 2001/04/29 17:34:41 bartoldeman -# A new SYS.COM/config.sys single stepping/console output/misc fixes. -# -# Revision 1.7 2001/04/15 03:21:50 bartoldeman -# See history.txt for the list of fixes. -# -# Revision 1.6 2001/03/25 04:33:56 bartoldeman -# Fix compilation of sys.com. Now a proper .com file once again. -# -# Revision 1.5 2001/03/22 04:18:09 bartoldeman -# Compilation command shortened. -# -# Revision 1.4 2001/03/21 02:56:26 bartoldeman -# See history.txt for changes. Bug fixes and HMA support are the main ones. -# -# Revision 1.3 2000/05/25 20:56:23 jimtabor -# Fixed project history -# -# Revision 1.2 2000/05/15 05:28:09 jimtabor -# Cleanup CRs -# -# Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 -# The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with -# MS-DOS. Distributed under the GNU GPL. -# -# Revision 1.10 1999/09/23 04:41:43 jprice -# *** empty log message *** -# -# Revision 1.9 1999/09/14 17:30:44 jprice -# Added debug log creation to sys.com. -# -# Revision 1.8 1999/08/25 03:19:51 jprice -# ror4 patches to allow TC 2.01 compile. -# -# Revision 1.7 1999/05/03 05:01:54 jprice -# no message -# -# Revision 1.6 1999/04/23 03:45:33 jprice -# Improved by jprice -# - - -!include "..\config.mak" - -CFLAGS = -mt -1- -v -vi- -k- -f- -ff- -O -Z -d -I$(INCLUDEPATH);..\hdr \ - -DI86;PROTO;FORSYS;WITHFAT32 - -# *Implicit Rules* -.c.obj: - $(CC) $(CFLAGS) -c $< - -.cpp.obj: - $(CC) $(CFLAGS) -c $< - -# *List Macros* - - -EXE_dependencies = \ - sys.obj \ - prf.obj - -# *Explicit Rules* -production: ..\bin\sys.com - -..\bin\sys.com: sys.com - copy sys.com ..\bin - -b_fat12.h: ..\boot\b_fat12.bin bin2c.com - bin2c ..\boot\b_fat12.bin b_fat12.h b_fat12 - -b_fat16.h: ..\boot\b_fat16.bin bin2c.com - bin2c ..\boot\b_fat16.bin b_fat16.h b_fat16 - -b_fat32.h: ..\boot\b_fat32.bin bin2c.com - bin2c ..\boot\b_fat32.bin b_fat32.h b_fat32 - -#floppy.obj: ..\drivers\floppy.asm -# $(NASM) -fobj -DSYS=1 ..\drivers\floppy.asm -o floppy.obj - -prf.obj: ..\kernel\prf.c - $(CC) $(CFLAGS) -c ..\kernel\prf.c - -sys.com: $(EXE_dependencies) - $(LINK) /m/t/c $(LIBPATH)\c0t.obj+$(EXE_dependencies),sys,,\ - $(CLIB); - -clobber: clean - $(RM) sys.com b_fat12.h b_fat16.h b_fat32.h - -clean: - $(RM) *.obj *.bak *.crf *.xrf *.map *.lst *.las status.me - -# *Individual File Dependencies* -sys.obj: sys.c ..\hdr\portab.h ..\hdr\device.h b_fat12.h b_fat16.h b_fat32.h - -# RULES (DEPENDENCIES) -# ---------------- -.asm.obj : - $(NASM) -f obj -DSYS=1 $< \ No newline at end of file From a4c844dc62dd1ea9137bd3cc58d483f0bb26ed46 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sun, 4 Nov 2001 20:10:15 +0000 Subject: [PATCH 100/671] Added new makefile names, utils sources, kconfig.h git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@316 6ac86273-5f31-0410-b378-82cca8765d1b --- boot/makefile | 75 +++++++++ buildall.bat | 124 ++++++++++++++ drivers/makefile | 100 +++++++++++ hdr/kconfig.h | 25 +++ kernel/makefile | 421 +++++++++++++++++++++++++++++++++++++++++++++++ lib/makefile | 57 +++++++ sys/makefile | 85 ++++++++++ utils/exeflat.c | 231 ++++++++++++++++++++++++++ utils/makefile | 23 +++ utils/patchobj.c | 215 ++++++++++++++++++++++++ utils/relocinf.c | 163 ++++++++++++++++++ 11 files changed, 1519 insertions(+) create mode 100644 boot/makefile create mode 100644 buildall.bat create mode 100644 drivers/makefile create mode 100644 hdr/kconfig.h create mode 100644 kernel/makefile create mode 100644 lib/makefile create mode 100644 sys/makefile create mode 100644 utils/exeflat.c create mode 100644 utils/makefile create mode 100644 utils/patchobj.c create mode 100644 utils/relocinf.c diff --git a/boot/makefile b/boot/makefile new file mode 100644 index 00000000..f5dad31e --- /dev/null +++ b/boot/makefile @@ -0,0 +1,75 @@ +# +# makefile for DOS-C boot +# +# $Id$ +# + +# $Log$ +# Revision 1.1 2001/11/04 20:10:15 bartoldeman +# Added new makefile names, utils sources, kconfig.h +# +# Revision 1.4 2001/09/23 20:39:44 bartoldeman +# FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling +# +# Revision 1.3 2000/05/25 20:56:19 jimtabor +# Fixed project history +# +# Revision 1.2 2000/05/11 03:56:42 jimtabor +# Clean up and Release +# +# Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 +# The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with +# MS-DOS. Distributed under the GNU GPL. +# +# Revision 1.3 1999/04/23 03:44:17 jprice +# Ported to NASM by ror4. Improvements +# +# Revision 1.2 1999/04/01 07:23:20 jprice +# New boot loader +# +# Revision 1.1.1.1 1999/03/29 15:39:39 jprice +# New version without IPL.SYS +# +# Revision 1.3 1999/02/09 04:49:17 jprice +# Make makefile use common config.mak file +# +# Revision 1.2 1999/01/21 05:03:58 jprice +# Formating. +# +# Revision 1.1.1.1 1999/01/20 05:51:00 jprice +# Imported sources +# +# +# Rev 1.3 10 Jan 1997 4:51:54 patv +#Changed to use FreeDOS exe2bin and support new boot code +# +# Rev 1.2 17 Dec 1996 12:52:32 patv +#Converted to FreeDOS exe2bin. +# +# Rev 1.1 29 Aug 1996 13:06:50 patv +#Bug fixes for v0.91b +# +# Rev 1.0 02 Jul 1995 9:11:26 patv +#Initial revision. +# + +!include "..\config.mak" + +production: b_fat12.bin b_fat16.bin b_fat32.bin + +b_fat12.bin: boot.asm + $(NASM) -dISFAT12 boot.asm -ob_fat12.bin + +b_fat16.bin: boot.asm + $(NASM) -dISFAT16 boot.asm -ob_fat16.bin + +b_fat32.bin: boot32.asm + $(NASM) boot32.asm -ob_fat32.bin + +clobber: clean + $(RM) b_fat12.bin b_fat16.bin b_fat32.bin status.me + +clean: + $(RM) *.lst *.map *.bak *.obj + + diff --git a/buildall.bat b/buildall.bat new file mode 100644 index 00000000..bb9c2b1e --- /dev/null +++ b/buildall.bat @@ -0,0 +1,124 @@ +:-@echo off + +:- +:- Revision 1.0 2001/09/05 tomehlert +:- + + +:---------------------------------------------------------- +:- batch file to build _many_ KERNELS, hope build works +:- +:- takes 3 minutes on my(TE) Win2K/P700. your milage may vary :-) +:---------------------------------------------------------- + +if \%1 == \$SUMMARY goto summary + +:-goto xsummary + +set onerror=if not \%XERROR% == \ goto daswarwohlnix + +:***** some MSCL kernels + +call config.bat +if not \%SKIPMS% == \ goto no_ms +call build -r msc 386 fat16 +%ONERROR% +call build -r msc 186 fat16 +%ONERROR% +call build -r msc 86 fat16 +%ONERROR% +call build -r msc 386 fat32 +%ONERROR% +call build -r msc 186 fat32 +%ONERROR% +call build -r msc 86 fat32 +%ONERROR% +no_ms: +SET SKIPMS= + +:***** some TC 2.01 kernels + +call build -r tc 186 fat16 +%ONERROR% +call build -r tc 86 fat16 +%ONERROR% +call build -r tc 186 fat32 +%ONERROR% +call build -r tc 86 fat32 +%ONERROR% + + +:wc + +:***** some WATCOM kernels - just for fun !!! + +:- +:- this is definitively only for fun - now +:- hope, this gets better +:- +call build -r wc 386 fat32 +call build -r wc 386 fat16 +call build -r wc 86 fat32 +call build -r wc 86 fat16 + +:- the watcom executables will currently NOT RUN +@del bin\kwc*.sys >nul + + +:***** now rebuild the normal kernel !! +call build -r + + +:************************************************************** +:* now we build a summary of all kernels HMA size + total size +:* Yes, I know - "mit Linux waer das nicht passiert" :-) +:* at least, it's possible with standard DOS tools +:************************************************************** + +:xsummary + +set Sumfile=bin\ksummary.txt +set TempSumfile=bin\tsummary.txt + +:****@echo >%TempSumfile% Summary of all kernels build +:****@echo.|date >>%TempSumfile% +:****@echo.|time >>%TempSumfile% +:****for %%i in (bin\k*.map) do call %0 $SUMMARY %%i +:****for %%i in (bin\k*.map) do call %0 $SUMMARY %%i +:****for %%i in (bin\k*.map) do call %0 $SUMMARY %%i + +del %Sumfile% +del %TempSumfile% +del ktemp.bat +for %%i in (bin\k*.map) do echo call %0 $SUMMARY %%i >>ktemp.bat +sort ktemps.bat +call ktemps +del ktemp.bat +del ktemps.bat + + +@echo >>%Sumfile% Summary of all kernels build +@echo.|date >>%Sumfile% +@echo.|time >>%Sumfile% +find <%TempSumfile% "H" >>%Sumfile% +del %TempSumfile% + +set TempSumfile= +set Sumfile= +goto end + +:summary +echo >>%TempSumfile% H************************************************* %2 +type %2| find " HMA_TEXT" |find /V "HMA_TEXT_START" |find /V "HMA_TEXT_END" >>%TempSumfile% +type %2| find " STACK" >>%TempSumfile% +goto end + +:************* done with summary ********************************* + + +:daswarwohlnix +@echo Sorry, something didn't work as expected :-( +@set ONERROR= +:end + + diff --git a/drivers/makefile b/drivers/makefile new file mode 100644 index 00000000..1073f7c7 --- /dev/null +++ b/drivers/makefile @@ -0,0 +1,100 @@ +# +# makefile for device.lib +# +# $Id$ +# + +# $Log$ +# Revision 1.1 2001/11/04 20:10:15 bartoldeman +# Added new makefile names, utils sources, kconfig.h +# +# Revision 1.3 2000/05/25 20:56:19 jimtabor +# Fixed project history +# +# Revision 1.2 2000/05/11 03:56:20 jimtabor +# Clean up and Release +# +# Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 +# The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with +# MS-DOS. Distributed under the GNU GPL. +# +# Revision 1.6 1999/08/25 03:16:36 jprice +# ror4 patches to allow TC 2.01 compile. +# +# Revision 1.5 1999/08/10 17:21:08 jprice +# ror4 2011-01 patch +# +# Revision 1.4 1999/04/23 03:44:52 jprice +# Improved by jprice +# +# Revision 1.3 1999/04/13 15:47:07 jprice +# no message +# +# Revision 1.2 1999/03/29 17:08:31 jprice +# ror4 changes +# +# Revision 1.1.1.1 1999/03/29 15:40:23 jprice +# New version without IPL.SYS +# +# Revision 1.3 1999/02/09 04:49:25 jprice +# Make makefile use common config.mak file +# +# Revision 1.2 1999/01/22 04:16:39 jprice +# Formating +# +# Revision 1.1.1.1 1999/01/20 05:51:00 jprice +# Imported sources +# +# +# Rev 1.2 29 Aug 1996 13:07:12 patv +#Bug fixes for v0.91b +# +# Rev 1.1 19 Feb 1996 3:19:26 patv +#Added NLS, int2f and config.sys processing +# +# Rev 1.0 02 Jul 1995 7:54:52 patv +#Initial revision. +# + +!include "..\config.mak" + + +# MICROSOFT C +# ----------- +#MODEL = s +#CFLAGS = /c /Gs /A$(MODEL) +#AFLAGS = /Mx /Dmem$(MODEL)=1 +#TERM = ; + +# BORLAND C +# ----------- +#MODEL = s +#CFLAGS = -c -m$(MODEL) +#AFLAGS = /Mx /Dmem$(MODEL)=1 +#LIBFLAGS = /c + +OBJS = devend.obj floppy.obj getvec.obj timer.obj rdpcclk.obj rdatclk.obj \ +wrpcclk.obj wratclk.obj + +LIBOBJS= +devend +floppy +getvec +timer +rdpcclk +rdatclk +wrpcclk +wratclk + + + +# Build the LIBRARY +# ----------------- +all: production + +production: ..\lib\device.lib + +..\lib\device.lib: device.lib + copy device.lib ..\lib + +clobber: clean + $(RM) device.lib status.me ..\lib\device.lib + +clean: + $(RM) *.obj *.bak *.crf *.xrf *.map *.lst + +device.lib : $(OBJS) + $(RM) device.lib + $(LIBUTIL) $(LIBFLAGS) device $(LIBOBJS) $(LIBTERM) diff --git a/hdr/kconfig.h b/hdr/kconfig.h new file mode 100644 index 00000000..dd2e6a51 --- /dev/null +++ b/hdr/kconfig.h @@ -0,0 +1,25 @@ +/* + KConfig.h + + DLASortByDriveNo + 0 : Drive Letter Assignement ike MSDOS + 1 : DLA - first drive completely first, then to next drive + + InitDiskShowDriveAssignment + 0 : don't show what drive/partition assigned to what drive letter + 1 : show info + + SkipConfigSeconds: + < 0 : not possible to skip config.sys + = 0 : only possible if already pressed before, no message + > 0 : wait so long for F5/F8 +*/ +typedef struct _KernelConfig { + char CONFIG[6]; /* "CONFIG" */ + unsigned short ConfigSize; + + unsigned char DLASortByDriveNo; + unsigned char InitDiskShowDriveAssignment; + signed char SkipConfigSeconds; + } KernelConfig; +extern struct _KernelConfig FAR LowKernelConfig; diff --git a/kernel/makefile b/kernel/makefile new file mode 100644 index 00000000..5ad94d24 --- /dev/null +++ b/kernel/makefile @@ -0,0 +1,421 @@ +# +# Makefile for Borland C++ 3.1 for kernel.sys +# +# $Id$ +# + +# $Log$ +# Revision 1.1 2001/11/04 20:10:15 bartoldeman +# Added new makefile names, utils sources, kconfig.h +# +# Revision 1.13 2001/07/24 16:56:29 bartoldeman +# fixes for FCBs, DJGPP ls, DBLBYTE, dyninit allocation (2024e). +# +# Revision 1.12 2001/07/22 01:58:58 bartoldeman +# Support for Brian's FORMAT, DJGPP libc compilation, cleanups, MSCDEX +# +# Revision 1.11 2001/07/09 22:19:33 bartoldeman +# LBA/FCB/FAT/SYS/Ctrl-C/ioctl fixes + memory savings +# +# Revision 1.10 2001/04/21 22:32:53 bartoldeman +# Init DS=Init CS, fixed stack overflow problems and misc bugs. +# +# Revision 1.9 2001/04/16 14:28:32 bartoldeman +# Kernel build 2024. Fixed critical error handler/config.sys/makefiles/UMBs +# +# Revision 1.8 2001/04/15 03:21:50 bartoldeman +# See history.txt for the list of fixes. +# +# Revision 1.7 2001/03/25 17:11:54 bartoldeman +# Fixed sys.com compilation. Updated to 2023. Also: see history.txt. +# +# Revision 1.6 2001/03/21 02:56:26 bartoldeman +# See history.txt for changes. Bug fixes and HMA support are the main ones. +# +# Revision 1.4 2000/08/06 05:50:17 jimtabor +# Add new files and update cvs with patches and changes +# +# Revision 1.3 2000/05/25 20:56:21 jimtabor +# Fixed project history +# +# Revision 1.2 2000/05/08 04:30:00 jimtabor +# Update CVS to 2020 +# +# Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 +# The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with +# MS-DOS. Distributed under the GNU GPL. +# +# Revision 1.14 2000/03/31 05:40:09 jtabor +# Added Eric W. Biederman Patches +# +# Revision 1.13 2000/03/17 22:59:04 kernel +# Steffen Kaiser's NLS changes +# +# Revision 1.12 2000/03/09 06:07:11 kernel +# 2017f updates by James Tabor +# +# Revision 1.11 1999/09/23 04:40:47 jprice +# *** empty log message *** +# +# Revision 1.8 1999/09/13 20:41:41 jprice +# Some clean up. +# +# Revision 1.7 1999/08/25 03:18:09 jprice +# ror4 patches to allow TC 2.01 compile. +# +# Revision 1.6 1999/08/10 17:57:13 jprice +# ror4 2011-02 patch +# +# Revision 1.5 1999/04/23 04:25:15 jprice +# no message +# +# Revision 1.4 1999/04/23 03:45:11 jprice +# Improved by jprice +# +# Revision 1.3 1999/04/16 12:21:22 jprice +# Steffen c-break handler changes +# +# Revision 1.2 1999/04/13 15:48:21 jprice +# no message +# +# Revision 1.1.1.1 1999/03/29 15:41:15 jprice +# New version without IPL.SYS +# +# Revision 1.7 1999/03/01 06:04:37 jprice +# Fixed so it'll work with config.mak +# +# Revision 1.6 1999/03/01 05:46:43 jprice +# Turned off DEBUG define. +# +# Revision 1.5 1999/02/09 04:49:43 jprice +# Make makefile use common config.mak file +# +# Revision 1.4 1999/02/08 05:55:57 jprice +# Added Pat's 1937 kernel patches +# +# Revision 1.3 1999/02/04 03:09:59 jprice +# Added option to share constants (-d). +# +# Revision 1.2 1999/01/22 04:13:26 jprice +# Formating +# +# Revision 1.1.1.1 1999/01/20 05:51:01 jprice +# Imported sources +# +# +# Rev 1.8.1 10 Jan 1999 SRM +#Took out "/P-" from TLINK +#Changed "bcc" to "tcc" +# +# Rev 1.9 06 Dec 1998 8:45:40 patv +#Added new files for I/O subsystem. +# +# Rev 1.8 22 Jan 1998 14:50:06 patv +#Outdated stacks.asm. +# +# Rev 1.6 03 Jan 1998 8:36:50 patv +#Converted data area to SDA format +# +# Rev 1.5 30 Jan 1997 7:55:54 patv +#Added TSC flag for trace support. +# +# Rev 1.4 16 Jan 1997 12:46:42 patv +#pre-Release 0.92 feature additions +# +# Rev 1.3 29 Aug 1996 13:07:34 patv +#Bug fixes for v0.91b +# +# Rev 1.2 29 May 1996 21:03:32 patv +#bug fixes for v0.91a +# +# Rev 1.1 19 Feb 1996 3:35:38 patv +#Added NLS, int2f and config.sys processing +# +# Rev 1.0 02 Jul 1995 8:30:22 patv +#Initial revision. +# +# $EndLog$ +# + +!include "..\config.mak" + +RELEASE = 1.00 + +# Compiler and Options for Borland C++ +# ------------------------------------ +# +# -zAname ¦ ¦ Code class +# -zBname ¦ ¦ BSS class +# -zCname ¦ ¦ Code segment +# -zDname ¦ ¦ BSS segment +# -zEname ¦ ¦ Far segment +# -zFname ¦ ¦ Far class +# -zGname ¦ ¦ BSS group +# -zHname ¦ ¦ Far group +# -zPname ¦ ¦ Code group +# -zRname ¦ ¦ Data segment +# -zSname ¦ ¦ Data group +# -zTname ¦ ¦ Data class +# -zX ¦«¦ Use default name for "X" + + +# Compiler and Options + +INCLUDE=$(COMPILERBASE)\include +LIB= $(COMPILERBASE)\lib + +LIBPATH = . +#AFLAGS = /Mx /DSTANDALONE=1 /I..\HDR + +LIBS =..\LIB\DEVICE.LIB ..\LIB\LIBM.LIB +#INITCFLAGS =$(ALLCFLAGS) -zAINIT -zCINIT_TEXT -zDIB -zRID -zTID -zPIGROUP -zBIB \ +#-zGIGROUP -zSIGROUP +#CFLAGS =$(ALLCFLAGS) -zAHMA -zCHMA_TEXT +HDR=../hdr/ + +# *Implicit Rules* +# 'standard' compiles + +.c.obj : + $(CC) $(CFLAGS) -c $*.c + $(PATCHOBJ) $*.obj $(STDPATCH) + +# *List Macros* + + +EXE_dependencies = \ + apisupt.obj \ + rtlsupt.obj \ + asmsupt.obj \ + blockio.obj \ + break.obj \ + chario.obj \ + config.obj \ + console.obj \ + dosidle.obj \ + dosfns.obj \ + dosnames.obj \ + dsk.obj \ + initdisk.obj \ + entry.obj \ + error.obj \ + execrh.obj \ + fatdir.obj \ + fatfs.obj \ + fattab.obj \ + fcbfns.obj \ + initoem.obj \ + int2f.obj \ + inthndlr.obj \ + io.obj \ + intr.obj \ + ioctl.obj \ + irqstack.obj \ + kernel.obj \ + main.obj \ + memmgr.obj \ + misc.obj \ + newstuff.obj \ + network.obj \ + nls.obj \ + nls_hc.obj \ + nlssupt.obj \ + prf.obj \ + iprf.obj \ + printer.obj \ + procsupt.obj \ + serial.obj \ + strings.obj \ + sysclk.obj \ + syspack.obj \ + systime.obj \ + task.obj \ + inithma.obj \ + dyndata.obj \ + dyninit.obj + +# *Explicit Rules* + +production: ..\bin\kernel.sys + +..\bin\kernel.sys: kernel.sys + copy kernel.sys ..\bin + copy kernel.sys ..\bin\$(THETARGET).sys + copy kernel.map ..\bin\$(THETARGET).map + +kernel.sys: kernel.exe ..\utils\exeflat.exe + ..\utils\exeflat kernel.exe kernel.sys 0x60 + +clobber: clean + $(RM) kernel.exe kernel.sys status.me + +clean: + $(RM) *.obj *.bak *.crf *.xrf *.map *.lst *.cod + +# XXX: This is a very ugly way of linking the kernel, forced upon us by the +# inability of Turbo `make' 2.0 to perform command line redirection. -- ror4 +kernel.exe: $(EXE_dependencies) $(LIBS) + $(RM) kernel.lib + $(LIBUTIL) kernel.lib $(LIBPLUS)entry.obj $(LIBPLUS)io.obj $(LIBPLUS)blockio.obj $(LIBPLUS)chario.obj $(LIBPLUS)dosfns.obj $(LIBPLUS)console.obj$(LIBTERM) + $(LIBUTIL) kernel.lib $(LIBPLUS)printer.obj $(LIBPLUS)serial.obj $(LIBPLUS)dsk.obj $(LIBPLUS)initdisk.obj $(LIBPLUS)error.obj $(LIBPLUS)fatdir.obj $(LIBPLUS)fatfs.obj$(LIBTERM) + $(LIBUTIL) kernel.lib $(LIBPLUS)fattab.obj $(LIBPLUS)fcbfns.obj $(LIBPLUS)initoem.obj $(LIBPLUS)initHMA.obj $(LIBPLUS)inthndlr.obj $(LIBPLUS)ioctl.obj $(LIBPLUS)nls_hc.obj$(LIBTERM) + $(LIBUTIL) kernel.lib $(LIBPLUS)main.obj $(LIBPLUS)config.obj $(LIBPLUS)memmgr.obj $(LIBPLUS)misc.obj $(LIBPLUS)newstuff.obj $(LIBPLUS)nls.obj $(LIBPLUS)intr.obj$(LIBTERM) + $(LIBUTIL) kernel.lib $(LIBPLUS)dosnames.obj $(LIBPLUS)prf.obj $(LIBPLUS)strings.obj $(LIBPLUS)network.obj $(LIBPLUS)sysclk.obj $(LIBPLUS)syspack.obj$(LIBTERM) + $(LIBUTIL) kernel.lib $(LIBPLUS)systime.obj $(LIBPLUS)task.obj $(LIBPLUS)int2f.obj $(LIBPLUS)irqstack.obj $(LIBPLUS)apisupt.obj$(LIBTERM) + $(LIBUTIL) kernel.lib $(LIBPLUS)asmsupt.obj $(LIBPLUS)execrh.obj $(LIBPLUS)nlssupt.obj $(LIBPLUS)procsupt.obj $(LIBPLUS)break.obj$(LIBTERM) + $(LIBUTIL) kernel.lib $(LIBPLUS)dosidle.obj $(LIBPLUS)dyndata.obj $(LIBPLUS)dyninit.obj $(LIBPLUS)rtlsupt.obj $(LIBTERM) + $(RM) kernel.bak + $(LINK) kernel iprf,kernel,kernel,kernel+$(LIBS)$(LINKTERM) + $(RM) kernel.lib + +# *Individual File Dependencies* +kernel.obj: kernel.asm segs.inc + +console.obj: console.asm io.inc + +printer.obj: printer.asm io.inc + +serial.obj: serial.asm io.inc + +entry.obj: entry.asm segs.inc $(HDR)stacks.inc + +apisupt.obj: apisupt.asm segs.inc + +rtlsupt.obj: rtlsupt.asm segs.inc + +execrh.obj: execrh.asm segs.inc + +int2f.obj: int2f.asm segs.inc + +intr.obj: intr.asm segs.inc intr.h + +io.obj: io.asm segs.inc + +irqstack.obj: irqstack.asm + +nls_hc.obj: nls_hc.asm segs.inc + +nlssupt.obj: nlssupt.asm segs.inc + +procsupt.obj: procsupt.asm segs.inc $(HDR)stacks.inc + +dosidle.obj: dosidle.asm segs.inc + +# XXX: Special handling for initialization modules -- this is required because +# TC 2.01 cannot handle `#pragma option' like TC 3 can. -- ror4 + +INITHEADERS=init-mod.h init-dat.h + +CONFIGURATION = turboc.cfg makefile ..\config.mak ..\mkfiles\$(COMPILER).MAK + +HEADERS=\ + $(HDR)portab.h $(HDR)device.h $(HDR)mcb.h $(HDR)pcb.h \ + $(HDR)fat.h $(HDR)fcb.h $(HDR)tail.h $(HDR)time.h $(HDR)process.h \ + $(HDR)dcb.h $(HDR)sft.h $(HDR)cds.h $(HDR)exe.h $(HDR)fnode.h \ + $(HDR)dirmatch.h $(HDR)file.h $(HDR)clock.h $(HDR)kbd.h $(HDR)error.h \ + $(HDR)version.h globals.h proto.h dyndata.h + +# XXX: I generated these using `gcc -MM' and `sed', so they may not be +# completely correct... -- ror4 + +blockio.obj: blockio.c $(HEADERS) $(CONFIGURATION) + +break.obj: break.c $(HEADERS) $(CONFIGURATION) + +chario.obj: chario.c $(HEADERS) $(CONFIGURATION) + +dosfns.obj: dosfns.c $(HEADERS) $(CONFIGURATION) + +dosnames.obj: dosnames.c $(HEADERS) $(CONFIGURATION) + +dsk.obj: dsk.c $(HEADERS) $(CONFIGURATION) + +error.obj: error.c $(HEADERS) $(CONFIGURATION) + +fatdir.obj: fatdir.c $(HEADERS) $(CONFIGURATION) + +fatfs.obj: fatfs.c $(HEADERS) $(CONFIGURATION) + +fattab.obj: fattab.c $(HEADERS) $(CONFIGURATION) + +fcbfns.obj: fcbfns.c $(HEADERS) $(CONFIGURATION) + +inthndlr.obj: inthndlr.c $(HEADERS) $(CONFIGURATION) + +ioctl.obj: ioctl.c $(HEADERS) $(CONFIGURATION) + +memmgr.obj: memmgr.c $(HEADERS) $(CONFIGURATION) + +misc.obj: misc.c $(HEADERS) $(CONFIGURATION) + +newstuff.obj: newstuff.c $(HEADERS) $(CONFIGURATION) + +network.obj: network.c $(HEADERS) $(CONFIGURATION) + +nls.obj: nls.c $(HEADERS) $(CONFIGURATION) + +# \ +# 001-437.nls + +prf.obj: prf.c $(HDR)\portab.h $(CONFIGURATION) + +strings.obj: strings.c $(CONFIGURATION) + +sysclk.obj: sysclk.c $(HEADERS) $(CONFIGURATION) + +syspack.obj: syspack.c $(HEADERS) $(CONFIGURATION) + +systime.obj: systime.c $(HEADERS) $(CONFIGURATION) + +task.obj: task.c $(HEADERS) $(CONFIGURATION) + +# now the funny stuff :-) +# Files in the INIT segment + +# $(CC) $(INITCFLAGS) -c $*.c +# patchobj $*.obj $(INITPATCH) + +config.obj: config.c $(INITHEADERS) $(HEADERS) $(CONFIGURATION) + $(CC) $(INITCFLAGS) -c $*.c + $(PATCHOBJ) $*.obj $(INITPATCH) + +initoem.obj: initoem.c $(INITHEADERS) $(HEADERS) $(CONFIGURATION) + $(CC) $(INITCFLAGS) -c $*.c + $(PATCHOBJ) $*.obj $(INITPATCH) + +main.obj: main.c $(INITHEADERS) $(HEADERS) $(CONFIGURATION) + $(CC) $(INITCFLAGS) -c $*.c + $(PATCHOBJ) $*.obj $(INITPATCH) + +inithma.obj: inithma.c $(INITHEADERS) $(HEADERS) $(CONFIGURATION) + $(CC) $(INITCFLAGS) -c $*.c + $(PATCHOBJ) $*.obj $(INITPATCH) + +dyninit.obj: dyninit.c $(INITHEADERS) $(HEADERS) $(CONFIGURATION) + $(CC) $(INITCFLAGS) -c $*.c + $(PATCHOBJ) $*.obj $(INITPATCH) + +initdisk.obj: initdisk.c $(INITHEADERS) $(HEADERS) $(CONFIGURATION) + $(CC) $(INITCFLAGS) -c $*.c + $(PATCHOBJ) $*.obj $(INITPATCH) + + +# $(CC) $(CFLAGS) -c $*.c +# patchobj $*.obj _DATA=DYN_DATA DATA=DYN_DATA CODE=HMA CONST=DCONST + +dyndata.obj: dyndata.c dyndata.h + $(CC) $(DYNCFLAGS) -c $*.c + $(PATCHOBJ) $*.obj $(DYNPATCH) + + + +#the printf for INIT_TEXT - yet another special case +# $(CC) -D_INIT $(INITCFLAGS) -Foiprf.obj -c prf.c +# patchobj Iprf.obj $(INITPATCH) + +iprf.obj: prf.c $(HDR)\portab.h $(CONFIGURATION) + $(CC) -D_INIT $(IPRFCFLAGS) -c prf.c + $(PATCHOBJ) iprf.obj $(INITPATCH) + + + diff --git a/lib/makefile b/lib/makefile new file mode 100644 index 00000000..50858a80 --- /dev/null +++ b/lib/makefile @@ -0,0 +1,57 @@ +# +# makefile for libm.lib +# +# $Id$ +# + +# $Log$ +# Revision 1.1 2001/11/04 20:10:15 bartoldeman +# Added new makefile names, utils sources, kconfig.h +# +# Revision 1.5 2001/06/03 14:16:18 bartoldeman +# BUFFERS tuning and misc bug fixes/cleanups (2024c). +# +# Revision 1.4 2001/03/19 04:50:56 bartoldeman +# See history.txt for overview: put kernel 2022beo1 into CVS +# +# Revision 1.4 2001/03/08 21:15:00 bartoldeman +# Fix from Martin Stromberg to make this fully configurable from config.mak +# +# Revision 1.3 2000/05/25 20:56:22 jimtabor +# Fixed project history +# +# Revision 1.2 2000/05/11 03:57:10 jimtabor +# Clean up and Release +# +# Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 +# The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with +# MS-DOS. Distributed under the GNU GPL. +# +# Revision 1.6 1999/09/14 17:32:20 jprice +# no message +# +# Revision 1.5 1999/09/13 20:13:15 jprice +# Added !if so we can use TC2 or TC3 to compile. +# +# Revision 1.4 1999/08/25 03:19:22 jprice +# ror4 patches to allow TC 2.01 compile. +# +# Revision 1.3 1999/04/23 03:45:18 jprice +# Improved by jprice +# + +!include "..\config.mak" + + +libm.lib: $(CLIB) ..\config.mak + $(RM) libm.lib + $(LIBUTIL) $(CLIB) $(MATH_EXTRACT) $(LIBTERM) + $(LIBUTIL) libm $(MATH_INSERT) $(LIBTERM) + $(RM) *.OBJ + + +clobber: clean + $(RM) libm.lib status.me + +clean: + $(RM) *.obj *.bak diff --git a/sys/makefile b/sys/makefile new file mode 100644 index 00000000..4d7a787f --- /dev/null +++ b/sys/makefile @@ -0,0 +1,85 @@ +# +# makefile for bin2c.com and sys.com +# +# $Id$ +# +# $Log$ +# Revision 1.1 2001/11/04 20:10:15 bartoldeman +# Added new makefile names, utils sources, kconfig.h +# +# Revision 1.3 2000/05/25 20:56:23 jimtabor +# Fixed project history +# +# Revision 1.2 2000/05/15 05:28:09 jimtabor +# Cleanup CRs +# +# Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 +# The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with +# MS-DOS. Distributed under the GNU GPL. +# +# Revision 1.6 1999/09/20 18:34:40 jprice +# *** empty log message *** +# +# Revision 1.5 1999/08/25 03:19:51 jprice +# ror4 patches to allow TC 2.01 compile. +# +# Revision 1.4 1999/05/03 05:01:38 jprice +# no message +# +# Revision 1.3 1999/04/23 03:45:33 jprice +# Improved by jprice +# + +!include "..\config.mak" + +CFLAGS = -I$(INCLUDEPATH) -I..\hdr -DFORSYS -DWITHFAT32 $(CFLAGST) +NASMFLAGS = -DSYS=1 + +# *List Macros* + +BIN2C_EXE_dependencies = \ + bin2c.obj + +SYS_EXE_dependencies = \ + sys.obj \ + fdkrncfg.obj \ + prf.obj + +# *Explicit Rules* +production: bin2c.com ..\bin\sys.com + +bin2c.com: $(BIN2C_EXE_dependencies) + $(CC) $(CFLAGST) -L$(LIBPATH) $(BIN2C_EXE_dependencies) + +..\bin\sys.com: sys.com + copy sys.com ..\bin + +b_fat12.h: ..\boot\b_fat12.bin bin2c.com + .\bin2c ..\boot\b_fat12.bin b_fat12.h b_fat12 + +b_fat16.h: ..\boot\b_fat16.bin bin2c.com + .\bin2c ..\boot\b_fat16.bin b_fat16.h b_fat16 + +b_fat32.h: ..\boot\b_fat32.bin bin2c.com + .\bin2c ..\boot\b_fat32.bin b_fat32.h b_fat32 + +prf.obj: ..\kernel\prf.c + $(CC) $(CFLAGS) -c ..\kernel\prf.c + +fdkrncfg.obj: fdkrncfg.c ..\hdr\kconfig.h + +sys.com: $(SYS_EXE_dependencies) + $(CC) $(CFLAGST) -L$(LIBPATH) $(SYS_EXE_dependencies) + +clobber: clean + $(RM) bin2c.com sys.com b_fat12.h b_fat16.h b_fat32.h + +clean: + $(RM) *.obj *.bak *.crf *.xrf *.map *.lst *.las status.me + +# *Individual File Dependencies* +bin2c.obj: bin2c.c + $(CC) $(CFLAGS) -c $*.c + +sys.obj: sys.c ..\hdr\portab.h ..\hdr\device.h b_fat12.h b_fat16.h b_fat32.h + $(CC) $(CFLAGS) -c $*.c diff --git a/utils/exeflat.c b/utils/exeflat.c new file mode 100644 index 00000000..348e2272 --- /dev/null +++ b/utils/exeflat.c @@ -0,0 +1,231 @@ +/****************************************************************/ +/* */ +/* exeflat.c */ +/* */ +/* EXE flattening program */ +/* */ +/* Copyright (c) 2001 */ +/* Bart E. Oldeman */ +/* All Rights Reserved */ +/* */ +/* This file is part of DOS-C. */ +/* */ +/* DOS-C is free software; you can redistribute it and/or */ +/* modify it under the terms of the GNU General Public License */ +/* as published by the Free Software Foundation; either version */ +/* 2, or (at your option) any later version. */ +/* */ +/* DOS-C is distributed in the hope that it will be useful, but */ +/* WITHOUT ANY WARRANTY; without even the implied warranty of */ +/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See */ +/* the GNU General Public License for more details. */ +/* */ +/* You should have received a copy of the GNU General Public */ +/* License along with DOS-C; see the file COPYING. If not, */ +/* write to the Free Software Foundation, 675 Mass Ave, */ +/* Cambridge, MA 02139, USA. */ +/****************************************************************/ + +/* + +Usage: exeflat (src.exe) (dest.sys) (relocation-factor) + +large portions copied from task.c + +*/ + +#include "portab.h" +#include "exe.h" +#include +#include +#include + +#define BUFSIZE 32768u + +/* JPP - changed so will accept hex number. */ +COUNT our_atoi(REG BYTE * pszString) +{ + BYTE Base = 10; + BOOL Sign = FALSE; + COUNT pnNum = 0; + UCOUNT digit; + if (*pszString == '-') + + { + pszString++; + Sign = TRUE; + } + if (pszString[0] == '0' && toupper(pszString[1]) == 'X') + + { + Base = 16; + pszString += 2; + } + for (; isxdigit(*pszString); pszString++) + + { + if (isdigit(pszString[0])) + digit = pszString[0] - '0'; + + else + digit = toupper(pszString[0]) - 'A' + 10; + if (digit > Base) + + { + printf("illegal digit '%s' in offset\n", pszString); + exit(1); + } + pnNum = pnNum * Base + digit; + } + if (Sign) + pnNum = -pnNum; + return pnNum; +} +typedef struct { + UWORD off, seg; +} farptr; +int compReloc(const void *p1, const void *p2) +{ + farptr *r1 = (farptr *) p1; + farptr *r2 = (farptr *) p2; + if (r1->seg > r2->seg) + return 1; + if (r1->seg < r2->seg) + return -1; + if (r1->off > r2->off) + return 1; + if (r1->off < r2->off) + return -1; + return 0; +} +int main(int argc, char **argv) +{ + exe_header header; + int i; + size_t bufsize; + farptr *reloc; + UWORD start_seg; + ULONG size, to_xfer; + UBYTE **buffers; + UBYTE **curbuf; + FILE *src, *dest; + if (argc != 4) + + { + printf("usage: exeflat (src.exe) (dest.sys) (relocation-factor)\n"); + return 1; + } + if ((src = fopen(argv[1], "rb")) == NULL) + + { + printf("Source file %s could not be opened\n", argv[1]); + return 1; + } + if (fread(&header, sizeof(header), 1, src) != 1) + + { + printf("Error reading header from %s\n", argv[1]); + fclose(src); + return 1; + } + if (header.exSignature != MAGIC) + + { + printf("Source file %s is not a valid .EXE\n", argv[1]); + fclose(src); + return 1; + } + if ((dest = fopen(argv[2], "wb+")) == NULL) + + { + printf("Destination file %s could not be created\n", argv[2]); + return 1; + } + start_seg = our_atoi(argv[3]); + printf("header len = %ld = 0x%lx\n", header.exHeaderSize * 16UL, + header.exHeaderSize * 16UL); + fseek(src, 0, SEEK_END); + size = ftell(src) - header.exHeaderSize * 16UL; + printf("image size (less header) = %ld = 0x%lx\n", size, size); + printf("first relocation offset = 0 = 0x0\n"); + + /* first read file into memory chunks */ + fseek(src, header.exHeaderSize * 16UL, SEEK_SET); + buffers = malloc((size + BUFSIZE - 1) / BUFSIZE * sizeof(char *)); + if (buffers == NULL) + + { + printf("Allocation error\n"); + return 1; + } + bufsize = BUFSIZE; + for (to_xfer = size, curbuf = buffers; to_xfer > 0; + to_xfer -= bufsize, curbuf++) + + { + if (to_xfer < BUFSIZE) + bufsize = to_xfer; + *curbuf = malloc(bufsize); + if (*curbuf == NULL) + + { + printf("Allocation error\n"); + return 1; + } + if (fread(*curbuf, sizeof(char), bufsize, src) != bufsize) + + { + printf("Source file read error %ld %d\n", to_xfer, bufsize); + return 1; + } + } + fseek(src, header.exRelocTable, SEEK_SET); + reloc = malloc(header.exRelocItems * sizeof(farptr)); + if (reloc == NULL) + + { + printf("Allocation error\n"); + return 1; + } + if (fread(reloc, sizeof(farptr), header.exRelocItems, src) != + header.exRelocItems) + + { + printf("Source file read error\n"); + return 1; + } + fclose(src); + qsort(reloc, header.exRelocItems, sizeof(reloc[0]), compReloc); + for (i = 0; i < header.exRelocItems; i++) + + { + ULONG spot = ((ULONG) reloc[i].seg << 4) + reloc[i].off; + UBYTE *spot0 = &buffers[spot / BUFSIZE][spot % BUFSIZE]; + UBYTE *spot1 = &buffers[(spot + 1) / BUFSIZE][(spot + 1) % BUFSIZE]; + UWORD segment = ((UWORD) * spot1 << 8) + *spot0; + printf("relocation at 0x%04x:0x%04x ->%04x\n", reloc[i].seg, + reloc[i].off, segment); + segment += start_seg; + *spot0 = segment & 0xff; + *spot1 = segment >> 8; + } + + /* write dest file from memory chunks */ + bufsize = BUFSIZE; + for (to_xfer = size, curbuf = buffers; to_xfer > 0; + to_xfer -= bufsize, curbuf++) + + { + if (to_xfer < BUFSIZE) + bufsize = to_xfer; + if (fwrite(*curbuf, sizeof(char), bufsize, dest) != bufsize) + + { + printf("Destination file write error\n"); + return 1; + } + } + fclose(dest); + printf("\nProcessed %d relocations\n", header.exRelocItems); + return 0; +} diff --git a/utils/makefile b/utils/makefile new file mode 100644 index 00000000..b88a6194 --- /dev/null +++ b/utils/makefile @@ -0,0 +1,23 @@ +!include "..\config.mak" + +CFLAGS = -I$(INCLUDEPATH) -I..\hdr + +production: patchobj.exe exeflat.exe + +patchobj.exe: patchobj.obj + $(CC) -L$(LIBPATH) patchobj.obj + +exeflat.exe: exeflat.obj + $(CC) -L$(LIBPATH) $(CFLAGSC) exeflat.obj + +patchobj.obj: patchobj.c ..\config.mak + +exeflat.obj: exeflat.c ..\hdr\exe.h ..\config.mak + $(CC) $(CFLAGSC) $(CFLAGS) -c exeflat.c + +clobber: clean + $(RM) bin2c.com exeflat.exe patchobj.exe + +clean: + $(RM) *.obj *.bak *.crf *.xrf *.map *.lst *.las status.me + diff --git a/utils/patchobj.c b/utils/patchobj.c new file mode 100644 index 00000000..74c20dcb --- /dev/null +++ b/utils/patchobj.c @@ -0,0 +1,215 @@ +/***************************************************************************** +** PATCHOBJ facility - change strings in the LNAMES record +** +** Copyright 2001 by tom ehlert +** +** GPL bla to be added, but intended as GPL +** +** +** 09/06/2001 - initial revision +** not my biggest kind of software; anyone willing to add +** comments, errormessages, usage info,...??? +** +*****************************************************************************/ + +#include +#include +#include + +#ifndef TRUE + #define TRUE (1==1) + #define FALSE (0==1) +#endif + + +struct { + char *sin,*sout; + } repl[100]; +int repl_count; + + +void quit(char *s,...) +{ + vprintf(s,(void*)((char *)&s+sizeof(s))); + exit(1); +} + +void define_replace(char *sin) +{ + char *s; + + if (repl_count >= 99) + quit("too many replacements"); + + if ((s = strchr(sin, '=')) == NULL) + quit("illegal replacement <%s>, missing '='", sin); + + *s = 0; + repl[repl_count].sin = sin; + repl[repl_count].sout = s+1; + + repl_count++; +} + +int main(int argc, char *argv[]) +{ + char *argptr; + int argloop; + int cont; + int file = 0; + FILE *fd,*fdo; + char *inname=0,*outname= "~patchob.tmp"; + + int use_temp_file = TRUE; + + argc--,argv++; + + for (; argc != 0; argc--,argv++) + { + argptr = *argv; + + if (*argptr != '-' && *argptr != '-') + { + if (inname == 0) { inname = argptr; continue;} + define_replace(argptr); + continue; + } + switch (toupper(argptr[1])) + { + case 'O': + outname = argptr+2; + use_temp_file = FALSE; + break; + default: + quit("illegal argument <%s>\n",argptr); + break; + } + } + + + + if (inname == 0) + quit("Inputfile must be specified\n"); + + if (repl_count == 0) + quit("no replacements defined"); + + + if ((fd = fopen(inname,"rb")) == NULL) /* open for READ/WRITE */ + quit("can't read %s\n",inname); + + if ((fdo = fopen(outname,"wb")) == NULL) /* open for READ/WRITE */ + quit("can't write %s\n",outname); + + go_records(fd,fdo); + + fclose(fd); + fclose(fdo); + if (use_temp_file) + { + unlink(inname); + rename(outname,inname); + } + + return 0; + +} + +usage() +{ + fputs( + "DELSYM V1.0 5'95by tom ehlert, SIG Aachen\n" + " delete symbolic info in object files\n" + "usage:\n" + " DELSYM infile [outfile]\n" + ,stderr); + exit(1); +} + +struct record + { + unsigned char rectyp; + unsigned datalen; + unsigned char buffer[0x2000]; + } Record,Outrecord; + + +go_records(FILE *fdin,FILE *fdo) +{ + unsigned char stringlen; + unsigned char *string,*s; + int i,j; + unsigned char chksum; + +do { + if (fread(&Record,1,3,fdin) != 3) { /* read type and reclen*/ + /* printf("end of fdin read\n"); */ + break; + } + if (Record.datalen > sizeof(Record.buffer)) + quit ("record to large : length %u Bytes \n",Record.datalen); + + if (fread(Record.buffer,1,Record.datalen,fdin) != Record.datalen) + { + printf("invalid record format\n"); + quit ("can't continue\n"); + } + + + + if (Record.rectyp != 0x96) /* we are only interested in LNAMES */ + { + fwrite(&Record,1,3+Record.datalen,fdo); + continue; + } + + Outrecord.rectyp = 0x96; + Outrecord.datalen= 0; + + + + + + + for (i = 0; i < Record.datalen-1; ) + { + stringlen = Record.buffer[i]; + i++; + + string = &Record.buffer[i]; + i += stringlen; + + + if (i > Record.datalen) + quit("invalid lnames record"); + + + for (j = 0; j < repl_count; j++) + if (memcmp(string,repl[j].sin,stringlen) == 0 + && strlen(repl[j].sin) == stringlen) + { + string = repl[j].sout; + stringlen = strlen(repl[j].sout); + } + Outrecord.buffer[Outrecord.datalen] = stringlen; + Outrecord.datalen++; + memcpy(Outrecord.buffer+Outrecord.datalen,string,stringlen); + Outrecord.datalen += stringlen; + } + + chksum = 0; + for (s = (unsigned char *)&Outrecord; s < &Outrecord.buffer[Outrecord.datalen]; s++) + chksum += *s; + + Outrecord.buffer[Outrecord.datalen] = -chksum; + Outrecord.datalen++; + + /* printf("^sum = %02x - %02x\n",chksum,-chksum); */ + + + fwrite(&Outrecord,1,3+Outrecord.datalen,fdo); + + } while (Record.rectyp != 0x00 /*ENDFIL*/); + +printf("\n"); +} diff --git a/utils/relocinf.c b/utils/relocinf.c new file mode 100644 index 00000000..1de577ef --- /dev/null +++ b/utils/relocinf.c @@ -0,0 +1,163 @@ +/***************************************************************************** +** RelocInf.C +** +** provide some info about relocation entries in an exe file +** +** usage: +** RelocInfo exefile +** +** +** Copyright 2001 by tom ehlert +** +** GPL bla to be added, but intended as GPL +** +** +** 09/06/2001 - initial revision +** not my biggest kind of software; anyone willing to add +** comments, errormessages, usage info,...??? +** +*****************************************************************************/ + + +*/ + +#include +#include +#include + +typedef unsigned short UWORD; +typedef unsigned long ULONG; +#ifndef _MSC_VER + #define const + #define __cdecl cdecl +#endif + +/* from EXE.H */ +typedef struct +{ + UWORD exSignature; + UWORD exExtraBytes; + UWORD exPages; + UWORD exRelocItems; + UWORD exHeaderSize; + UWORD exMinAlloc; + UWORD exMaxAlloc; + UWORD exInitSS; + UWORD exInitSP; + UWORD exCheckSum; + UWORD exInitIP; + UWORD exInitCS; + UWORD exRelocTable; + UWORD exOverlay; +} +exe_header; + +#define MAGIC 0x5a4d + +struct relocEntry{ + UWORD off; + UWORD seg; + UWORD refseg; + }; + +int __cdecl compReloc(const void *p1, const void *p2) + { + struct relocEntry *r1 = (struct relocEntry*)p1; + struct relocEntry *r2 = (struct relocEntry*)p2; + + if (r1->refseg > r2->refseg) return 1; + if (r1->refseg < r2->refseg) return -1; + + if (r1->seg > r2->seg) return 1; + if (r1->seg < r2->seg) return -1; + + if (r1->off > r2->off) return 1; + if (r1->off < r2->off) return -1; + + return 0; + } + + + +main(int argc,char *argv[]) +{ + FILE *fdin; + exe_header header; + struct relocEntry *reloc; + + int i; + ULONG image_offset; + + + if (argc < 2 || (fdin = fopen(argv[1],"rb")) == NULL) + { + printf("can't open %s\n",argv[1]); + exit(1); + } + + if (fread(&header, sizeof(header),1,fdin) != 1 || + header.exSignature != MAGIC) + { + printf("%s is no EXE file\n"); + exit(1); + } + + printf("%u relocation entries found\n", header.exRelocItems); + + if (header.exRelocItems > 0x8000/sizeof(*reloc)) + { + printf("too many relocation entries \n"); + exit(1); + } + + if ((reloc = malloc(header.exRelocItems*sizeof(*reloc))) == NULL) + { + printf("can't alloc memory\n"); + exit(1); + } + + if (fseek(fdin, header.exRelocTable, 0)) + { + printf("can't seek\n"); + exit(1); + } + + for (i = 0; i < header.exRelocItems; i++) + if (fread(reloc+i, 4,1,fdin) != 1) + { + printf("can't read reloc info\n"); + exit(1); + } + + for (i = 0; i < header.exRelocItems; i++) + { + image_offset = (ULONG)header.exHeaderSize * 16; + + image_offset += ((ULONG)reloc[i].seg << 4) + reloc[i].off; + + if (fseek(fdin, image_offset, 0)) + { + printf("can't seek reloc data\n"); + exit(1); + } + + if (fread(&reloc[i].refseg, 2,1,fdin) != 1) + { + printf("can't read rel data for item %d\n",i); + exit(1); + } + /* printf("%04x:%04x -> %04x\n", reloc[i].seg, reloc[i].off, reloc[i].refseg); */ + } + + /* sort reloc entries */ + + qsort(reloc, header.exRelocItems, sizeof(*reloc), compReloc); + + for (i = 0; i < header.exRelocItems; i++) + { + if (i == 0) + printf("# seg:off references data in -->\n"); + printf("%3d %04x:%04x -> %04x\n", i,reloc[i].seg, reloc[i].off, reloc[i].refseg); + } + +} \ No newline at end of file From 6b297246a340f30dc90a024b9591a31b0b97233e Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sun, 4 Nov 2001 21:35:20 +0000 Subject: [PATCH 101/671] History and version needed to be adjusted for 2025a test git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@317 6ac86273-5f31-0410-b378-82cca8765d1b --- docs/history.txt | 3 ++- hdr/version.h | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/docs/history.txt b/docs/history.txt index 50407d26..22198e28 100644 --- a/docs/history.txt +++ b/docs/history.txt @@ -1,4 +1,4 @@ -2001 Nov xx - Build 2025a +2001 Nov 4 - Build 2025a (test) -------- Bart Oldeman (bart.oldeman@bristol.ac.uk) + Changes tom * config.sys processing: placing ? on the left side of '=' like @@ -6,6 +6,7 @@ asks for this single line fill the available HMA with buffers * added kernel configuration options to sys.com, small area at 60:xx + (in cooperation with Jeremy) * readblock optimized to read as many data as possible in one int13 request - great speedups for large reads * some more SDA variables need to be updated for the network diff --git a/hdr/version.h b/hdr/version.h index 19f8b28a..b80e9d16 100644 --- a/hdr/version.h +++ b/hdr/version.h @@ -44,6 +44,6 @@ static BYTE *date_hRcsId = "$Id$"; #define REVISION_MINOR 1 #define REVISION_SEQ 25 #define BUILD "2025" -#define SUB_BUILD "" +#define SUB_BUILD "a test" #define KERNEL_VERSION_STRING "1.1.25" /*#REVISION_MAJOR "." #REVISION_MINOR "." #REVISION_SEQ*/ -#define KERNEL_BUILD_STRING "2025" /*#BUILD SUB_BUILD*/ +#define KERNEL_BUILD_STRING "2025a test" /*#BUILD SUB_BUILD*/ From e092c873fadc0dab9bb44dd24e09035ebcf66c71 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sun, 4 Nov 2001 21:39:00 +0000 Subject: [PATCH 102/671] Added fdkrncfg.c, the kernel configuration part of sys git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@318 6ac86273-5f31-0410-b378-82cca8765d1b --- sys/fdkrncfg.c | 335 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 335 insertions(+) create mode 100644 sys/fdkrncfg.c diff --git a/sys/fdkrncfg.c b/sys/fdkrncfg.c new file mode 100644 index 00000000..a68d5e59 --- /dev/null +++ b/sys/fdkrncfg.c @@ -0,0 +1,335 @@ +/*************************************************************************** +* * +* FDKRNCFG.C - FreeDOS Kernel Configuration * +* This is a simple little program that merely displays and/or changes * +* the configuration options specified within the CONFIG section of * +* the FreeDOS Kernel (if supported) * +* * +* Initially Written by Kenneth J. Davis Oct 11, 2001 (public domain) * +* Future versions may contain copyrighted portions, if so the * +* copyright holders should be listed after this line. * +* Initial release - public domain * +* * +* merged into SYS by tom ehlert * +***************************************************************************/ + +/* This source compiled & tested with Borland C/C++ 3.1 + TC 2.01*/ + + +char VERSION[] = "v1.00"; +char PROGRAM[] = "SYS CONFIG"; +char KERNEL[] = "KERNEL.SYS"; + + +#include +#include +#include +#include +#include + +#define FAR far +#include "kconfig.h" + +KernelConfig cfg = {0}; + + +typedef unsigned char byte; +typedef unsigned short word; +typedef unsigned long dword; + + +/* These structures need to be byte packed, if your compiler + does not do this by default, add the appropriate command, + such as #pragma pack(1) here, protected with #ifdefs of course. +*/ + + + +/* Displays command line syntax */ +void showUsage(void) +{ + + printf("FreeDOS Kernel Configuration %s\n", VERSION); + printf("Usage: \n" + " %s \n" + " %s [/help | /?]\n" + " %s [ [drive:][path]%s] [option=value ...] \n", + PROGRAM, PROGRAM, PROGRAM, KERNEL); + printf("\n"); + printf(" If no options are given, the current values are shown.\n"); + printf(" %/help or ? displays this usage information.\n" + " [drive:][path]KERNEL.SYS specifies the kernel file to\n" + " modify, if not given defaults to \\%s\n", + KERNEL); + printf("\n"); + printf(" option=value ... specifies one or more options and the values\n" + " to set each to. If an option is given multiple times,\n" + " the value set will be the rightmost one.\n"); + printf(" Current Options are: DLASORT=0|1, SHOWDRIVEASSIGNMENT=0|1\n"); +} + + + +/* simply reads in current configuration values, exiting program + with an error message and error code unable to, otherwise + cfg & kfile are valid on return. +*/ + + +/* Reads in the current kernel configuration settings, + return 0 on success, nonzero on error. If there was + an actual error the return value is positive, if there + were no errors, but the CONFIG section was not found + then a negative value is returned. cfg is only altered + if the return value is 0 (ie successfully found and + read in the config section). The position of the file + pointer on input does not matter, the file position + upon return may be anywhere. The memory allocated for + cfg should be freed to prevent memory leakage (it should + not point to allocated memory on entry, as that memory + will not be used, and will likely not be freed as a result). +*/ +int readConfigSettings(int kfile, char *kfilename, KernelConfig *cfg) +{ + int ch; + int configBlkFound; + word cfgSize; + + + /* Seek to start of kernel file */ + if (lseek(kfile, 2, SEEK_SET) != 2) + printf("can't seek to offset 2\n"),exit(1); + + if (read(kfile,cfg,sizeof(KernelConfig)) != sizeof(KernelConfig)) + printf("can't read %u bytes\n",sizeof(KernelConfig)),exit(1); + + if (memcmp(cfg->CONFIG, "CONFIG", 6) != 0) + { + printf("Error: no CONFIG section found in kernel file <%s>\n", kfilename); + printf("Only FreeDOS kernels after 2025 contain a CONFIG section!\n"); + exit(1); + } + + return 1; +} + + +/* Writes config values out to file. + Returns 0 on success, nonzero on error. +*/ +int writeConfigSettings(int kfile, KernelConfig *cfg) +{ + + /* Seek to CONFIG section at start of options of kernel file */ + if (lseek(kfile, 2, SEEK_SET) != 2) + return 1; + + /* Write just the config option information out */ + if (write(kfile, cfg, sizeof(KernelConfig)) != sizeof(KernelConfig)) + return 1; + + /* successfully wrote out kernel config data */ + return 0; +} + + +/* Displays kernel configuration information */ +void displayConfigSettings(KernelConfig *cfg) +{ + /* print known options and current value - only if available */ + + if (cfg->ConfigSize >= 1) + { + printf("DLASORT=0x%02X Sort disks by drive order: *0=no, 1=yes\n", + cfg->DLASortByDriveNo); + } + + if (cfg->ConfigSize >= 2) + { + printf("SHOWDRIVEASSIGNMENT=0x%02X Show how drives assigned: *1=yes 0=no\n", + cfg->InitDiskShowDriveAssignment); + } + + if (cfg->ConfigSize >= 3) + { + printf("SKIPCONFIGSECONDS=%-2d time to wait for F5/F8 : *2 sec\n", + cfg->SkipConfigSeconds); + } + +#if 0 /* we assume that SYS is as current as the kernel */ + + /* Print value any options added that are unknown as hex dump */ + if (cfg->configHdr.configSize > sizeof(ConfigData)) + { + printf("Additional options are available, they are not currently\n" + "supported by this tool. The current extra values are (in Hex):\n"); + for (i = 0; i < (cfg->configSize-sizeof(ConfigData)); i++) + { + if ((i%32) == 0) printf("\n"); + else if ((i%4) == 0) printf(" "); + printf("%02X", (unsigned int)cfg->extra[i]); + } + printf("\n"); + } +#endif + printf("\n"); +} + + + + +/* Sets the given location to a byte value if different, + displays warning if values exceeds max +*/ +void setByteOption(byte *option, char *value, word max, int *updated, char *name) +{ + int optionValue; + + optionValue = atoi(value); + if (optionValue > max) + { + printf("Warning: Option %s: Value <0x%02X> may be invalid!\n", + name, (unsigned int)((byte)optionValue)); + } + /* Don't bother updating if same value */ + if ((byte)optionValue != *option) + { + *option = (byte)optionValue; + *updated = 1; + } +} + + +/* Main, processes command line options and calls above + functions as required. +*/ +int FDKrnConfigMain(int argc,char **argv) +{ + char *kfilename = KERNEL; + int kfile; + int updates = 0; /* flag used to indicate if we need to update kernel */ + int argstart,i; + char *cptr; + char *argptr; + + printf("FreeDOS System configurator %s \n", VERSION); + + + /* 1st go through and just process arguments (help/filename/etc) */ + for (i = 2; i < argc; i++) + { + argptr = argv[i]; + + /* is it an argument or an option specifier */ + if (argptr[0] == '-' || argptr[0] == '/') + { + switch(argptr[1]) + { + case 'H': + case 'h': + case '?': + showUsage(); + exit(0); + + default: + printf("Invalid argument found <%s>.\nUse %s /help for usage.\n", + argptr, PROGRAM); + exit(1); + } + } + } + + argstart = 2; + + argptr = argv[argstart]; + + cptr = strchr(argptr, '='); + + if (argptr == 0) + { + showUsage(); + exit(1); + } + /* the first argument may be the kernel name */ + if (strchr(argptr, '=') == NULL) + { + kfilename = argptr; + argstart++; + } + + + kfile = open(kfilename, O_RDWR | O_BINARY); + + if (kfile < 0) + printf("Error: unable to open kernel file <%s>\n", kfilename),exit(1); + + + /* now that we know the filename (default or given) get config info */ + readConfigSettings(kfile, kfilename, &cfg); + + for (i = argstart; i < argc; i++) + { + argptr = argv[i]; + + if ((cptr = strchr(argptr,'=')) == NULL) + goto illegal_arg; + + /* split argptr into 2 pieces and make cptr point to 2nd one */ + *cptr = '\0'; + cptr++; + + /* allow 3 valid characters */ + if (memicmp(argptr, "DLASORT",3) == 0) + { + setByteOption(&(cfg.DLASortByDriveNo), + cptr, 1, &updates, "DLASORT"); + } + else if (memicmp(argptr, "SHOWDRIVEASSIGNMENT",3) == 0) + { + setByteOption(&(cfg.InitDiskShowDriveAssignment), + cptr, 1, &updates, "SHOWDRIVEASSIGNMENT"); + } + else if (memicmp(argptr, "SKIPCONFIGSECONDS",3) == 0) + { + setByteOption(&(cfg.SkipConfigSeconds), + cptr, 1, &updates, "SKIPCONFIGSECONDS"); + updates++; + } + else + { +illegal_arg: + printf("Unknown option found <%s>.\nUse %s /help for usage.\n", + argptr, PROGRAM); + exit(1); + } + } + + /* write out new config values if modified */ + if (updates) + { + /* update it */ + if (writeConfigSettings(kfile, &cfg)) + { + printf("Error: Unable to write configuration changes to kernel!\n"); + printf(" <%s>\n", kfilename); + close(kfile); + exit(1); + } + + + /* display new settings */ + printf("\nUpdated Kernel settings.\n"); + } + else + printf("Current Kernel settings.\n"); + + + /* display current settings */ + displayConfigSettings(&cfg); + + /* and done */ + close(kfile); + + return 0; +} + From a904ce9dc3a43611c1a0f9c0ef7ac02b21bf0be2 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sun, 4 Nov 2001 21:43:35 +0000 Subject: [PATCH 103/671] Added compiler specific makefiles git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@319 6ac86273-5f31-0410-b378-82cca8765d1b --- mkfiles/bc5.mak | 53 +++++++++++++++++++++++++++++ mkfiles/generic.mak | 49 +++++++++++++++++++++++++++ mkfiles/mscl8.mak | 42 +++++++++++++++++++++++ mkfiles/tc2.mak | 56 +++++++++++++++++++++++++++++++ mkfiles/tc3.mak | 53 +++++++++++++++++++++++++++++ mkfiles/turbocpp.mak | 52 ++++++++++++++++++++++++++++ mkfiles/watcom.mak | 80 ++++++++++++++++++++++++++++++++++++++++++++ 7 files changed, 385 insertions(+) create mode 100644 mkfiles/bc5.mak create mode 100644 mkfiles/generic.mak create mode 100644 mkfiles/mscl8.mak create mode 100644 mkfiles/tc2.mak create mode 100644 mkfiles/tc3.mak create mode 100644 mkfiles/turbocpp.mak create mode 100644 mkfiles/watcom.mak diff --git a/mkfiles/bc5.mak b/mkfiles/bc5.mak new file mode 100644 index 00000000..6c3393d2 --- /dev/null +++ b/mkfiles/bc5.mak @@ -0,0 +1,53 @@ +# +# BC5.MAK - kernel copiler options for Borland C++ +# + +# Use these for Borland C++ + +COMPILERPATH=$(BC5_BASE) +COMPILERBIN=$(COMPILERPATH)\bin +CC=$(COMPILERBIN)\tcc +CFLAGST=-mt -lt -a- -k- -f- -ff- -O -Z -d +CFLAGSC=-a- -mc +INCLUDEPATH=$(COMPILERPATH)\include +LIBUTIL=$(COMPILERBIN)\tlib +LIBPATH=$(COMPILERPATH)\lib +LIBTERM= +LIBPLUS=+ + +TARGET=KBC + +# used for building the library + +CLIB=$(COMPILERPATH)\lib\cs.lib +MATH_EXTRACT=*H_LDIV *H_LLSH *H_LURSH *N_LXMUL *F_LXMUL *H_LRSH +MATH_INSERT=+H_LDIV +H_LLSH +H_LURSH +N_LXMUL +F_LXMUL +H_LRSH + +# +# heavy stuff - building the kernel +# Compiler and Options for Borland C++ +# ------------------------------------ +# +# -zAname ¦ ¦ Code class +# -zBname ¦ ¦ BSS class +# -zCname ¦ ¦ Code segment +# -zDname ¦ ¦ BSS segment +# -zEname ¦ ¦ Far segment +# -zFname ¦ ¦ Far class +# -zGname ¦ ¦ BSS group +# -zHname ¦ ¦ Far group +# -zPname ¦ ¦ Code group +# -zRname ¦ ¦ Data segment +# -zSname ¦ ¦ Data group +# -zTname ¦ ¦ Data class +# -zX ¦«¦ Use default name for "X" + +# +# ALLCFLAGS specified by turbo.cfg and config.mak +# +ALLCFLAGS = $(TARGETOPT) $(ALLCFLAGS) +INITCFLAGS = $(ALLCFLAGS) -zAINIT -zCINIT_TEXT -zDIB -zRID -zTID -zPIGROUP -zBIB -zGIGROUP -zSIGROUP +CFLAGS = $(ALLCFLAGS) -zAHMA -zCHMA_TEXT +DYNCFLAGS = $(ALLCFLAGS) -zRDYN_DATA -zTDYN_DATA -zDDYN_DATA -zBDYN_DATA +IPRFCFLAGS = $(INITCFLAGS) -oiprf.obj + diff --git a/mkfiles/generic.mak b/mkfiles/generic.mak new file mode 100644 index 00000000..2e01e3a0 --- /dev/null +++ b/mkfiles/generic.mak @@ -0,0 +1,49 @@ +#********************************************************************** +#* TARGET : we create a %TARGET%.sys file +#* TARGETOPT : options, handled down to the compiler +#********************************************************************** + +TARGETOPT=-1- + +!if $(XCPU)+1 != 1 +!if $(XCPU) == 186 +TARGETOPT=-1 +!endif +!if $(XCPU) == 386 +TARGETOPT=-3 +!endif +!endif + +!if $(XFAT)+1 != 1 +!if $(XFAT) == 32 +ALLCFLAGS=$(ALLCFLAGS) -DWITHFAT32 +!endif +!endif + +!if $(XCPU) == 386 +NASMFLAGS = $(NASMFLAGS) -i../hdr/ -DI386 +!else +NASMFLAGS = $(NASMFLAGS) -i../hdr/ +!endif + +PATCHOBJ=@rem +INITPATCH = CODE=INIT _DATA=IDATA DATA=ID BSS=ID DGROUP=IGROUP CONST=IC +STDPATCH = CODE=HMA CONST=DCONST +DYNPATCH = _DATA=DYN_DATA DATA=DYN_DATA CODE=HMA CONST=DCONST + +!include "..\mkfiles\$(COMPILER).mak" + +THETARGET=$(TARGET)$(XCPU)$(XFAT) +# These are generic definitions +RM=-del + +.asm.obj : + $(NASM) $(NASMFLAGS) -f obj $*.asm + +# *Implicit Rules* +.c.obj : + $(CC) $(CFLAGS) -c $*.c + +.cpp.obj : + $(CC) $(CFLAGS) -c $*.cpp + diff --git a/mkfiles/mscl8.mak b/mkfiles/mscl8.mak new file mode 100644 index 00000000..64498c26 --- /dev/null +++ b/mkfiles/mscl8.mak @@ -0,0 +1,42 @@ +# +# MSCL8.MAK - kernel copiler options for MS CL8 = MSVC1.52 +# + +# Use these for MSCV 1.52 +COMPILERPATH=$(MS_BASE) +COMPILERBIN=$(COMPILERPATH)\bin +INCLUDEPATH=$(COMPILERPATH)\include +CC=$(COMPILERBIN)\cl +CFLAGST = /Fm /AS /Os ???? +CFLAGSC=-a- -mc ???? +LIBUTIL=$(COMPILERBIN)\lib /nologo +LIBPATH=$(COMPILERPATH)\lib +LIBUTIL=$(COMPILERBIN)\lib /nologo +LIBTERM=; + + +# used for building the library + +CLIB=$(COMPILERPATH)\lib\slibce.lib +MATH_EXTRACT=*aflmul *aFlshl *aFNauldi *aFulrem *aFulshr *aFuldiv *aFlrem *aFldiv +MATH_INSERT= +aflmul +aFlshl +aFNauldi +aFulrem +aFulshr +aFuldiv +aFlrem +aFldiv + +!if $(XCPU) == 186 +TARGETOPT=-G1 +!end +!if $(XCPU) == 386 +TARGETOPT=-G3 +!end + +TARGET=KMS + +# +# heavy stuff - building + + +ALLCFLAGS = -I..\hdr $(TARGETOPT) $(ALLCFLAGS) -nologo -c -Zl -Fc -Zp1 -Gs -Os -WX +INITCFLAGS = $(ALLCFLAGS) -NTINIT_TEXT -AT +CFLAGS = $(ALLCFLAGS) -NTHMA_TEXT +DYNCFLAGS = $(ALLCFLAGS) -NTHMA_TEXT +IPRFCFLAGS = $(INITCFLAGS) -Foiprf.obj +PATCHOBJ = patchobj diff --git a/mkfiles/tc2.mak b/mkfiles/tc2.mak new file mode 100644 index 00000000..1a938ab4 --- /dev/null +++ b/mkfiles/tc2.mak @@ -0,0 +1,56 @@ +# +# TURBOC.MAK - kernel copiler options for TURBOC +# + +# Use these for Turbo C 2.01 + +COMPILERPATH=$(TC2_BASE) +COMPILERBIN=$(COMPILERPATH) +CC=$(COMPILERBIN)\tcc +CFLAGST=-mt -lt -a- -k- -f- -ff- -O -Z -d +CFLAGSC=-a- -mc +INCLUDEPATH=$(COMPILERPATH)\include +LIBUTIL=$(COMPILERBIN)\tlib +LIBPATH=$(COMPILERPATH)\lib +LIBTERM= +LIBPLUS=+ + +TARGET=KTC + +# used for building the library + +CLIB=$(COMPILERPATH)\lib\cs.lib +MATH_EXTRACT=*LDIV *LXMUL *LURSH *LLSH *LRSH +MATH_INSERT=+LDIV +LXMUL +LURSH +LLSH +LRSH + +# +# heavy stuff - building the kernel +# Compiler and Options for Borland C++ +# ------------------------------------ +# +# -zAname ¦ ¦ Code class +# -zBname ¦ ¦ BSS class +# -zCname ¦ ¦ Code segment +# -zDname ¦ ¦ BSS segment +# -zEname ¦ ¦ Far segment +# -zFname ¦ ¦ Far class +# -zGname ¦ ¦ BSS group +# -zHname ¦ ¦ Far group +# -zPname ¦ ¦ Code group +# -zRname ¦ ¦ Data segment +# -zSname ¦ ¦ Data group +# -zTname ¦ ¦ Data class +# -zX ¦«¦ Use default name for "X" + +# +# ALLCFLAGS specified by turbo.cfg and config.mak +# +ALLCFLAGS = $(TARGETOPT) $(ALLCFLAGS) +INITCFLAGS = $(ALLCFLAGS) -zAINIT -zCINIT_TEXT -zDIB -zRID -zTID -zPIGROUP -zBIB -zGIGROUP -zSIGROUP +CFLAGS = $(ALLCFLAGS) -zAHMA -zCHMA_TEXT +DYNCFLAGS = $(ALLCFLAGS) -zRDYN_DATA -zTDYN_DATA -zDDYN_DATA -zBDYN_DATA +IPRFCFLAGS = $(INITCFLAGS) -oiprf.obj + + + + diff --git a/mkfiles/tc3.mak b/mkfiles/tc3.mak new file mode 100644 index 00000000..2740121f --- /dev/null +++ b/mkfiles/tc3.mak @@ -0,0 +1,53 @@ +# +# TC3.MAK - kernel copiler options for Turbo C 3.0 +# + +# Use these for Turbo C 3.0 + +COMPILERPATH=$(TC3_BASE) +COMPILERBIN=$(COMPILERPATH)\bin +CC=$(COMPILERBIN)\tcc +CFLAGST=-mt -lt -a- -k- -f- -ff- -O -Z -d +CFLAGSC=-a- -mc +INCLUDEPATH=$(COMPILERPATH)\include +LIBUTIL=$(COMPILERBIN)\tlib +LIBPATH=$(COMPILERPATH)\lib +LIBTERM= +LIBPLUS=+ + +TARGET=KT3 + +# used for building the library + +CLIB=$(COMPILERPATH)\lib\cs.lib +MATH_EXTRACT=*H_LDIV *H_LLSH *H_LURSH *N_LXMUL *F_LXMUL *H_LRSH +MATH_INSERT=+H_LDIV +H_LLSH +H_LURSH +N_LXMUL +F_LXMUL +H_LRSH + +# +# heavy stuff - building the kernel +# Compiler and Options for Borland C++ +# ------------------------------------ +# +# -zAname ¦ ¦ Code class +# -zBname ¦ ¦ BSS class +# -zCname ¦ ¦ Code segment +# -zDname ¦ ¦ BSS segment +# -zEname ¦ ¦ Far segment +# -zFname ¦ ¦ Far class +# -zGname ¦ ¦ BSS group +# -zHname ¦ ¦ Far group +# -zPname ¦ ¦ Code group +# -zRname ¦ ¦ Data segment +# -zSname ¦ ¦ Data group +# -zTname ¦ ¦ Data class +# -zX ¦«¦ Use default name for "X" + +# +# ALLCFLAGS specified by turbo.cfg and config.mak +# +ALLCFLAGS = $(TARGETOPT) $(ALLCFLAGS) +INITCFLAGS = $(ALLCFLAGS) -zAINIT -zCINIT_TEXT -zDIB -zRID -zTID -zPIGROUP -zBIB -zGIGROUP -zSIGROUP +CFLAGS = $(ALLCFLAGS) -zAHMA -zCHMA_TEXT +DYNCFLAGS = $(ALLCFLAGS) -zRDYN_DATA -zTDYN_DATA -zDDYN_DATA -zBDYN_DATA +IPRFCFLAGS = $(INITCFLAGS) -oiprf.obj + diff --git a/mkfiles/turbocpp.mak b/mkfiles/turbocpp.mak new file mode 100644 index 00000000..a6c45b70 --- /dev/null +++ b/mkfiles/turbocpp.mak @@ -0,0 +1,52 @@ +# +# TURBOCPP.MAK - kernel copiler options for TCPP 1.01 +# + +# Use these for Turbo CPP 1.01 + +COMPILERPATH=$(TP1_BASE) +COMPILERBIN=$(COMPILERPATH)\bin +CC=$(COMPILERBIN)\tcc +CFLAGST=-mt -lt -a- -k- -f- -ff- -O -Z -d +CFLAGSC=-a- -mc +INCLUDEPATH=$(COMPILERPATH)\include +LIBUTIL=$(COMPILERBIN)\tlib +LIBPATH=$(COMPILERPATH)\lib +LIBTERM= +LIBPLUS=+ + +TARGET=KTP + +# used for building the library + +CLIB=$(COMPILERPATH)\lib\cs.lib +MATH_EXTRACT=*H_LDIV *F_LXMUL *H_LURSH *H_LLSH *H_LRSH +MATH_INSERT=+H_LDIV +F_LXMUL +H_LURSH +H_LLSH +H_LRSH + +# +# heavy stuff - building the kernel +# Compiler and Options for Borland C++ +# ------------------------------------ +# +# -zAname ¦ ¦ Code class +# -zBname ¦ ¦ BSS class +# -zCname ¦ ¦ Code segment +# -zDname ¦ ¦ BSS segment +# -zEname ¦ ¦ Far segment +# -zFname ¦ ¦ Far class +# -zGname ¦ ¦ BSS group +# -zHname ¦ ¦ Far group +# -zPname ¦ ¦ Code group +# -zRname ¦ ¦ Data segment +# -zSname ¦ ¦ Data group +# -zTname ¦ ¦ Data class +# -zX ¦«¦ Use default name for "X" + +# +# ALLCFLAGS specified by turbo.cfg and config.mak +# +ALLCFLAGS = $(TARGETOPT) $(ALLCFLAGS) +INITCFLAGS = $(ALLCFLAGS) -zAINIT -zCINIT_TEXT -zDIB -zRID -zTID -zPIGROUP -zBIB -zGIGROUP -zSIGROUP +CFLAGS = $(ALLCFLAGS) -zAHMA -zCHMA_TEXT +DYNCFLAGS = $(ALLCFLAGS) -zRDYN_DATA -zTDYN_DATA -zDDYN_DATA -zBDYN_DATA +IPRFCFLAGS = $(INITCFLAGS) -oiprf.obj diff --git a/mkfiles/watcom.mak b/mkfiles/watcom.mak new file mode 100644 index 00000000..5b5dca6b --- /dev/null +++ b/mkfiles/watcom.mak @@ -0,0 +1,80 @@ +# +# WATCOM.MAK - kernel copiler options for MS CL8 = MSVC1.52 +# + +# Use these for WATCOM 11.0c +COMPILERPATH=$(WC_BASE) +COMPILERBIN=$(WC_BASE)\binw +CC=$(COMPILERBIN)\wcl +CFLAGST=-mt +CFLAGSC=-mc +INCLUDEPATH=$(COMPILERPATH)\H +WATCOM=$(COMPILERPATH) +PATH=$(COMPILERPATH)\binnt;$(COMPILERPATH)\binw +INCLUDE=$(COMPILERPATH)\h +EDPATH=$(COMPILERPATH)\EDDAT + +!if $(XCPU) != 186 +!if $(XCPU) != 386 +TARGETOPT=-0 +!endif +!endif + +TARGET=KWC + +LINKTERM=; + +LIBPATH=$(COMPILERPATH)\lib +LIBUTIL=$(COMPILERBIN)\wlib +LIBPLUS= +LIBTERM= + +# used for building the library + +CLIB=$(COMPILERPATH)\lib286\dos\clibs.lib + +# +#MATH_EXTRACT=*i4d *i4m +#MATH_INSERT= +i4d +i4m +# +# these are NOT usable, as they are called NEAR, and are in TEXT segment. +# so we can't use them, when moving the kernel. called ~15 times +# +# so I include 1 dummy library routine (stridup()), to make lib happy +# + +MATH_EXTRACT=*_icstrdu +MATH_INSERT= +_icstrdu +MATH_EXTRACT=*i4d *i4m +MATH_INSERT= +i4d +i4m + + +# +# heavy stuff - building +# +# -e= set limit on number of error messages +# -ms small memory model (small code/small data) +# -j change char default from unsigned to signed +#-nc= set code class name +#-nd= set data segment name +#-nm= set module name +#-nt= set name of text segment +# -g= set code group name +# -os -> favor code size over execution time in optimizations +# -s remove stack overflow checks +# -w= set warning level number +# -we treat all warnings as errors +# -ze enable extensions (i.e., near, far, export, etc.) +# -zl remove default library information +# -zp= pack structure members with alignment {1,2,4,8,16} +# -zq operate quietly +# +# -3 optimization for 386 - given in CONFIG.MAK, not here +# + +ALLCFLAGS = $(TARGETOPT) $(ALLCFLAGS) -c -zq -os -ms -s -e=5 -j -zl -zp=1 +INITCFLAGS = $(ALLCFLAGS) -nt=INIT_TEXT -nc=INIT -g=IGROUP +CFLAGS = $(ALLCFLAGS) -nt=HMA_TEXT -nc=HMA -g=HGROUP +DYNCFLAGS = $(ALLCFLAGS) +IPRFCFLAGS = $(INITCFLAGS) -Foiprf.obj + From 482452473850039218ffc8bcdb7819ca6ccb4cb1 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sun, 4 Nov 2001 21:46:53 +0000 Subject: [PATCH 104/671] Text files need to be LF ended at the server. So be it... git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@320 6ac86273-5f31-0410-b378-82cca8765d1b --- bin/install.bat | 3 +++ 1 file changed, 3 insertions(+) diff --git a/bin/install.bat b/bin/install.bat index 4a02ac86..9051939b 100644 --- a/bin/install.bat +++ b/bin/install.bat @@ -4,6 +4,9 @@ rem Create a distribution floppy rem rem $Header$ rem $Log$ +rem Revision 1.4 2001/11/04 21:46:53 bartoldeman +rem Text files need to be LF ended at the server. So be it... +rem rem Revision 1.3 2001/03/22 04:12:43 bartoldeman rem Change LF to CR/LF in batch files. rem From 5a18de7cbbadd63d1ffd06911375747f3d6174be Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Tue, 13 Nov 2001 23:36:45 +0000 Subject: [PATCH 105/671] Kernel 2025a final changes. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@321 6ac86273-5f31-0410-b378-82cca8765d1b --- boot/boot.asm | 18 +-- boot/boot32.asm | 17 ++- boot/makefile | 9 +- build.bat | 38 ++++++- buildall.bat | 11 +- clean.bat | 10 +- clobber.bat | 12 +- config.b | 163 ++++++++++++++++++++++++--- docs/history.txt | 33 ++++++ docs/lfnapi.txt | 16 ++- drivers/makefile | 11 +- hdr/fat.h | 26 +++++ hdr/kconfig.h | 2 + hdr/version.h | 6 +- kernel/blockio.c | 5 +- kernel/config.c | 10 +- kernel/dosfns.c | 54 +++++++-- kernel/dsk.c | 20 +++- kernel/entry.asm | 44 +++++++- kernel/fatdir.c | 27 ++--- kernel/fatfs.c | 115 ++++++++------------ kernel/fattab.c | 7 +- kernel/fcbfns.c | 87 ++++----------- kernel/init-mod.h | 2 + kernel/initdisk.c | 157 +++++++++++++++++++------- kernel/inthndlr.c | 91 +++++++++++++--- kernel/ioctl.c | 10 ++ kernel/kernel.asm | 5 + kernel/lfnapi.c | 254 +++++++++++++++++++++++++++++++++---------- kernel/main.c | 5 +- kernel/makefile | 61 ++++------- kernel/newstuff.c | 7 +- kernel/proto.h | 18 ++- lib/makefile | 15 ++- mkfiles/bc5.mak | 17 ++- mkfiles/generic.mak | 12 +- mkfiles/mscl8.mak | 27 +++-- mkfiles/tc2.mak | 18 ++- mkfiles/tc3.mak | 15 ++- mkfiles/turbocpp.mak | 14 +-- mkfiles/watcom.mak | 30 +++-- sys/fdkrncfg.c | 164 +++++++++++++++++++++++++--- sys/makefile | 13 ++- sys/sys.c | 95 ++++++++++++---- utils/exeflat.c | 126 ++++++++++----------- utils/makefile | 16 +-- utils/patchobj.c | 4 +- 47 files changed, 1305 insertions(+), 612 deletions(-) diff --git a/boot/boot.asm b/boot/boot.asm index 975cacb0..8413bab1 100644 --- a/boot/boot.asm +++ b/boot/boot.asm @@ -27,6 +27,9 @@ ; ; ; $Log$ +; Revision 1.5 2001/11/13 23:36:45 bartoldeman +; Kernel 2025a final changes. +; ; Revision 1.4 2001/04/29 17:34:39 bartoldeman ; A new SYS.COM/config.sys single stepping/console output/misc fixes. ; @@ -274,10 +277,7 @@ real_start: cli mov di, bp mov cx, 0x0100 rep movsw - push es - mov bx, cont - push bx - retf + jmp word 0x1FE0:cont cont: mov ds, ax mov ss, ax @@ -455,15 +455,15 @@ boot_success: call print ; prints text after call to this function. -print: pop si ; this is the first character +print_1char: xor bx, bx ; video page 0 mov ah, 0x0E ; else print it + int 0x10 ; via TTY mode +print: pop si ; this is the first character print1: lodsb ; get token + push si ; stack up potential return address cmp al, 0 ; end of string? - je print2 ; if so, exit - int 0x10 ; via TTY mode - jmp short print1 ; until done -print2: push si ; stack up return address + jne print_1char ; until done ret ; and jump to it diff --git a/boot/boot32.asm b/boot/boot32.asm index 8c4b2495..51973f07 100644 --- a/boot/boot32.asm +++ b/boot/boot32.asm @@ -92,10 +92,7 @@ real_start: cld mov di, bp mov cx, 0x0100 rep movsw ; move boot code to the 0x1FE0:0x0000 - push es - mov bx, cont - push bx - retf + jmp word 0x1FE0:cont cont: mov ds, ax mov ss, ax @@ -269,15 +266,15 @@ c3: ; prints text after call to this function. -print: pop si ; this is the first character +print_1char: xor bx, bx ; video page 0 mov ah, 0x0E ; else print it -print1: lodsb ; get token - cmp al, bl ; end of string? (al == bl == 0) - je print2 ; if so, exit int 0x10 ; via TTY mode - jmp short print1 ; until done -print2: push si ; stack up return address +print: pop si ; this is the first character +print1: lodsb ; get token + push si ; stack up potential return address + cmp al, 0 ; end of string? + jne print_1char ; until done ret ; and jump to it diff --git a/boot/makefile b/boot/makefile index f5dad31e..0aa3740f 100644 --- a/boot/makefile +++ b/boot/makefile @@ -5,6 +5,9 @@ # # $Log$ +# Revision 1.2 2001/11/13 23:36:45 bartoldeman +# Kernel 2025a final changes. +# # Revision 1.1 2001/11/04 20:10:15 bartoldeman # Added new makefile names, utils sources, kconfig.h # @@ -53,7 +56,7 @@ #Initial revision. # -!include "..\config.mak" +!include "..\mkfiles\generic.mak" production: b_fat12.bin b_fat16.bin b_fat32.bin @@ -67,9 +70,9 @@ b_fat32.bin: boot32.asm $(NASM) boot32.asm -ob_fat32.bin clobber: clean - $(RM) b_fat12.bin b_fat16.bin b_fat32.bin status.me + -$(RM) b_fat12.bin b_fat16.bin b_fat32.bin status.me clean: - $(RM) *.lst *.map *.bak *.obj + -$(RM) *.lst *.map *.bak *.obj diff --git a/build.bat b/build.bat index b58a9441..ed546bf1 100644 --- a/build.bat +++ b/build.bat @@ -5,6 +5,9 @@ :- $Id$ :- $Log$ +:- Revision 1.7 2001/11/13 23:36:43 bartoldeman +:- Kernel 2025a final changes. +:- :- Revision 1.6 2001/11/04 19:47:37 bartoldeman :- kernel 2025a changes: see history.txt :- @@ -52,18 +55,34 @@ set XERROR= -if not exist config.bat echo You must copy CONFIG.B to CONFIG.BAT and edit it to reflect your setup! -if not exist config.bat goto end +@if not exist config.bat echo You must copy CONFIG.B to CONFIG.BAT and edit it to reflect your setup! +@if not exist config.bat goto end -if not \%1 == \-r goto norebuild - del kernel\*.obj - del lib\libm.lib +@if not \%1 == \-r goto norebuild + call clobber :norebuild call config.bat +call getmake.bat -set XERROR= +@if not \%XLINK% == \ goto link_set + +@if \%COMPILER% == \TC2 set XLINK=%TC2_BASE%\tlink /m/c +@if \%COMPILER% == \TURBOCPP set XLINK=%TP1_BASE%\bin\tlink /m/c +@if \%COMPILER% == \TC3 set XLINK=%TC3_BASE%\bin\tlink /m/c +@if \%COMPILER% == \BC5 set XLINK=%BC5_BASE%\bin\tlink /m/c +@if \%COMPILER% == \WATCOM goto watcom_problem +@if \%COMPILER% == \MSCL8 set XLINK=%MS_BASE%\link /ONERROR:NOEXE /ma /nologo +goto link_set + +:watcom_problem +@echo you MUST set XLINK for Watcom in config.bat as WLINK is not suitable +goto end + +:link_set + +@set XERROR= :********************************************************************** :* DONE with preferences - following is command line handling @@ -150,3 +169,10 @@ set XERROR=1 @set COMPILER= @set XCPU= @set XFAT= +@set XLINK= +@set TC2_BASE= +@set TP1_BASE= +@set TC3_BASE= +@set BC5_BASE= +@set MS_BASE= + diff --git a/buildall.bat b/buildall.bat index bb9c2b1e..53535488 100644 --- a/buildall.bat +++ b/buildall.bat @@ -20,7 +20,8 @@ set onerror=if not \%XERROR% == \ goto daswarwohlnix :***** some MSCL kernels call config.bat -if not \%SKIPMS% == \ goto no_ms + +if \%MS_BASE% == \ goto no_ms call build -r msc 386 fat16 %ONERROR% call build -r msc 186 fat16 @@ -33,11 +34,11 @@ call build -r msc 186 fat32 %ONERROR% call build -r msc 86 fat32 %ONERROR% -no_ms: -SET SKIPMS= +:no_ms :***** some TC 2.01 kernels +if \%TC2_BASE% == \ goto no_tc call build -r tc 186 fat16 %ONERROR% call build -r tc 86 fat16 @@ -46,7 +47,7 @@ call build -r tc 186 fat32 %ONERROR% call build -r tc 86 fat32 %ONERROR% - +:no_tc :wc @@ -56,10 +57,12 @@ call build -r tc 86 fat32 :- this is definitively only for fun - now :- hope, this gets better :- +if \%WATCOM% == \ goto no_wc call build -r wc 386 fat32 call build -r wc 386 fat16 call build -r wc 86 fat32 call build -r wc 86 fat16 +:no_wc :- the watcom executables will currently NOT RUN @del bin\kwc*.sys >nul diff --git a/clean.bat b/clean.bat index f7fe99a7..b5df82e7 100644 --- a/clean.bat +++ b/clean.bat @@ -5,6 +5,9 @@ rem batch file to clean everything rem $Id$ rem $Log$ +rem Revision 1.6 2001/11/13 23:36:43 bartoldeman +rem Kernel 2025a final changes. +rem rem Revision 1.5 2001/11/04 19:47:37 bartoldeman rem kernel 2025a changes: see history.txt rem @@ -38,20 +41,15 @@ rem Clean up rem if not exist config.bat goto noconfigbat -if not exist config.mak goto noconfigmak goto start :noconfigbat echo You must copy CONFIG.B to CONFIG.BAT and edit it to reflect your setup! goto end -:noconfigmak -echo You must copy CONFIG.M to CONFIG.MAK and edit it to reflect your setup! -goto end - :start -@set COMPILER=tc2 call config.bat +call getmake.bat cd utils %MAKE% clean diff --git a/clobber.bat b/clobber.bat index 96d3230c..e4312724 100644 --- a/clobber.bat +++ b/clobber.bat @@ -4,6 +4,9 @@ rem batch file to clobber everything rem $Id$ rem $Log$ +rem Revision 1.6 2001/11/13 23:36:43 bartoldeman +rem Kernel 2025a final changes. +rem rem Revision 1.5 2001/11/04 19:47:37 bartoldeman rem kernel 2025a changes: see history.txt rem @@ -31,20 +34,15 @@ rem Initial include rem if not exist config.bat goto noconfigbat -if not exist config.mak goto noconfigmak goto start :noconfigbat echo You must copy CONFIG.B to CONFIG.BAT and edit it to reflect your setup! goto end -:noconfigmak -echo You must copy CONFIG.M to CONFIG.MAK and edit it to reflect your setup! -goto end - :start -set COMPILER=tc2 call config.bat +call getmake.bat cd utils %MAKE% clobber @@ -75,4 +73,4 @@ del status.me :end set MAKE= -set COMPILER= \ No newline at end of file +set COMPILER= diff --git a/config.b b/config.b index d9a230d5..0b086a28 100644 --- a/config.b +++ b/config.b @@ -1,23 +1,152 @@ -rem ********************************************************************** -rem - define your MAKE type here, pick one of them -rem ********************************************************************** +:- +:- batch file that is included in all other batch files for configuration +:- -set MAKE=c:\tc201\make -rem set MAKE=c:\watcom\binw\wmake /ms -rem set MAKE=c:\msvc\bin\nmake /nologo +:-**************************************************************** +:- NOTICE! You must edit and rename this file to CONFIG.BAT! * +:-**************************************************************** -rem ********************************************************************** -rem - define your COMPILER type here, pick one of them -rem ********************************************************************** +:-********************************************************************* +:- determine your compiler settings +:- +:- you have to +:- search for XNASM - and set the path for NASM +:- search for COMPILER - and set your compiler +:- search for ??_BASE - and set the path to your compiler +:- +:-********************************************************************* +:-********************************************************************** +:-- define where to find NASM - remember - it should not be protected +:- mode DJGPP version if you're using Windows NT/2k/XP to compile +:- also: DJGPP-nasm crashes when using protected mode Borland's make +:-********************************************************************** + +set XNASM=c:\bin\nasm16 + +:********************************************************************** +:- define your COMPILER type here, pick one of them +:********************************************************************** + +:- Turbo C 2.01 set COMPILER=TC2 -rem set COMPILER=TURBOCPP -rem set COMPILER=TC3 -rem set COMPILER=BC5 -rem set COMPILER=MSCL8 +:- Turbo C++ 1.01 +:- set COMPILER=TURBOCPP +:- Turbo C 3.0 +:- set COMPILER=TC3 +:- Borland C +:- set COMPILER=BC5 +:- Microsoft C +:- set COMPILER=MSCL8 + +:- warning: watcom can compile but the result does not work yet. +:- set COMPILER=WATCOM + +:-********************************************************************** +:-- where is the BASE dir of your compiler(s) ?? +:-********************************************************************** + +set TC2_BASE=c:\tc201 +:- set TP1_BASE=c:\tcpp +:- set TC3_BASE=c:\tc3 +:- set BC5_BASE=c:\bc5 +:- set MS_BASE=c:\msvc + +:- if WATCOM maybe you need to set your WATCOM environment variables +:- and path +:- if not %WATCOM% == \ goto watcom_defined +:- set WATCOM=c:\watcom +:- set PATH=%PATH%;%WATCOM%\binw +:watcom_defined + +:-********************************************************************** +:- (optionally) which linker to use: +:- (otherwise will be determined automatically) +:- WATCOM wlink is not (yet) suitable for linking +:- (the map file and syntax are not compatible) +:- Turbo C 2.01 TLINK 2.0 can't link WATCOM (but can link TC2) +:- Turbo C++ 1.01 and higher TLINK 3.01+ are ok +:- or get TLINK 4 (creates nice map file) from simtel at +:- ftp://ftp.simtel.net/pub/simtelnet/msdos/borland/tlink4.zip +:-********************************************************************** + +:- Turbo Link +:- set XLINK=%TC2_BASE%\tlink /m/c +:- Microsoft Link +:- set XLINK=%MS_BASE%\bin\link /ONERROR:NOEXE /ma /nologo + +:********************************************************************** +:* optionally define your MAKE type here, if not then +:* it will be automatically determined, pick one of them +:* use MS nmake if you want to compile with MSCL +:********************************************************************** + +:- Borland MAKE +:- set MAKE=%TC2_BASE%\make +:- Watcom MAKE in MS mode +:- set MAKE=%WATCOM%\binw\wmake /ms +:- Microsoft MAKE +:- set MAKE=%MS_BASE%\bin\nmake /nologo + +:********************************************************************** +:* select your default target: required CPU and what FAT system to support +:********************************************************************** + +set XCPU=86 +:- set XCPU=186 +:- set XCPU=386 + +set XFAT=16 +:- set XFAT=32 + +:- Give extra compiler DEFINE flags here +:- such as -DDEBUG : extra DEBUG output +:- -DDOSEMU : printf output goes to dosemu log +:- set ALLCFLAGS=-DDEBUG -rem warning: watcom can compile but the result does not work yet. -rem set COMPILER=WATCOM -rem skip MS compiler in buildall. -rem set SKIPMS=yes +:- +:- $Id$ +:- +:- $Log$ +:- Revision 1.5 2001/11/13 23:36:43 bartoldeman +:- Kernel 2025a final changes. +:- +:- Revision 1.9 2001/11/04 19:47:37 bartoldeman +:- kernel 2025a changes: see history.txt +:- +:- Revision 1.8 2001/09/23 20:39:43 bartoldeman +:- FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling +:- +:- Revision 1.7 2001/04/16 14:36:56 bartoldeman +:- Added ALLCFLAGS for compiler option configuration. +:- +:- Revision 1.6 2001/04/15 03:21:49 bartoldeman +:- See history.txt for the list of fixes. +:- +:- Revision 1.5 2001/03/22 10:51:04 bartoldeman +:- Suggest to extract F_SCOPY into libm.lib for Borland C++. +:- +:- Revision 1.4 2001/03/19 04:50:56 bartoldeman +:- See history.txt for overview: put kernel 2022beo1 into CVS +:- +:- Revision 1.3 2000/05/25 20:56:19 jimtabor +:- Fixed project history +:- +:- Revision 1.2 2000/05/14 17:07:07 jimtabor +:- Cleanup CRs +:- +:- Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 +:- The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with +:- MS-DOS. Distributed under the GNU GPL. +:- +:- Revision 1.3 1999/09/13 20:40:17 jprice +:- Added COMPILER variable +:- +:- Revision 1.2 1999/08/25 03:59:14 jprice +:- New build batch files. +:- +:- Revision 1.1 1999/08/25 03:20:39 jprice +:- ror4 patches to allow TC 2.01 compile. +:- +:- diff --git a/docs/history.txt b/docs/history.txt index 22198e28..7aac7626 100644 --- a/docs/history.txt +++ b/docs/history.txt @@ -1,3 +1,34 @@ +2001 Nov 12 - Build 2025a +-------- Bart Oldeman (bart.oldeman@bristol.ac.uk) ++ Changes Tom + * initialize LBA parameter struct to 0's - some BIOSes don't fill + in everything. Thanks to Bernd Blaauw's bug report. + * Minor boot sector optimization. + * added some exeflat options ++ Changes Jeremy + * changes to fdkrncfg.c: mostly cosmetic to the output + * added sys.doc file (updated by Bart) ++ Changes Bart + * let int 0 (divide by zero) and int 6 (invalid opcode) print a + stack trace to aid in debugging + * fixed floppy drive detection for XT's. + * fixed bug in int21/ah=0x32 and friends - we should flush data before the + forced media_check + * Use CHS addressing if possible on partitions with the relevant ID, + you can overide this using the new FORCELBA and GLOBALENABLELBASUPPORT + sys config options. + * Always use BIOS values for translating LBA to CHS for fixed disks - + ignoring the boot sector values. For floppies the boot sector is used. + * fixed "truename hello." to remove the trailing dot. + * added options to SYS to write to a boot sector image file + * set Critical Error Code for ioctl's + * fake cluster size for 64k clusters just like FAT32 for INT21/AH=0x36 + and friends. ++ Changes Bart+Tom+Victor + * make makefile system more robust ++ Changes Victor + * cleaned up map_cluster and dir_read (bug fixed by Bart) + * updated LFN API (in development, not used yet) 2001 Nov 4 - Build 2025a (test) -------- Bart Oldeman (bart.oldeman@bristol.ac.uk) + Changes tom @@ -25,6 +56,8 @@ compilers (MS, Watcom, Borland). Watcom compiles but the result does not run yet. + Changes Bart + * extended the double-byte lead table from int21/ah=63 to 4 zeros + to make Watcom happy * support for IOCTL AX=440D, CL=40,41,42,61,62 for read/write/format track - this enables R. Nordier format to work * default floppy type depends on the drive diff --git a/docs/lfnapi.txt b/docs/lfnapi.txt index 8270b520..a2e8d57c 100644 --- a/docs/lfnapi.txt +++ b/docs/lfnapi.txt @@ -1,24 +1,22 @@ - FreeDOS LFN aid API. - + FreeDOS LFN helper API. struct lfn_inode { - UNICODE name[255]; + UNICODE name[256]; struct dirent l_dir; /* this file's dir entry image */ ULONG l_diroff; /* offset of the dir entry */ - CLUSTER l_dirstart; /* the starting cluster of dir */ - /* when dir is not root */ }; - typedef struct lfn_inode FAR * lfn_inode_ptr; -COUNT lfn_allocate_inode(); +COUNT lfn_allocate_inode(VOID); COUNT lfn_free_inode(COUNT handle); +COUNT lfn_setup_inode(COUNT handle, CLUSTER dirstart, ULONG diroff); + COUNT lfn_create_entries(COUNT handle, lfn_inode_ptr lip); -COUNT lfn_remove_entries(COUNT handle, lfn_inode_ptr lip); +COUNT lfn_remove_entries(COUNT handle); COUNT lfn_dir_read(COUNT handle, lfn_inode_ptr lip); -COUNT lfn_dir_write(COUNT handle, lfn_inode_ptr lip); +COUNT lfn_dir_write(COUNT handle); diff --git a/drivers/makefile b/drivers/makefile index 1073f7c7..cfae1a19 100644 --- a/drivers/makefile +++ b/drivers/makefile @@ -5,6 +5,9 @@ # # $Log$ +# Revision 1.2 2001/11/13 23:36:45 bartoldeman +# Kernel 2025a final changes. +# # Revision 1.1 2001/11/04 20:10:15 bartoldeman # Added new makefile names, utils sources, kconfig.h # @@ -56,7 +59,7 @@ #Initial revision. # -!include "..\config.mak" +!include "..\mkfiles\generic.mak" # MICROSOFT C @@ -90,11 +93,11 @@ production: ..\lib\device.lib copy device.lib ..\lib clobber: clean - $(RM) device.lib status.me ..\lib\device.lib + -$(RM) device.lib status.me ..\lib\device.lib clean: - $(RM) *.obj *.bak *.crf *.xrf *.map *.lst + -$(RM) *.obj *.bak *.crf *.xrf *.map *.lst *.cod device.lib : $(OBJS) - $(RM) device.lib + -$(RM) device.lib $(LIBUTIL) $(LIBFLAGS) device $(LIBOBJS) $(LIBTERM) diff --git a/hdr/fat.h b/hdr/fat.h index fb1736e7..c67ce57b 100644 --- a/hdr/fat.h +++ b/hdr/fat.h @@ -36,6 +36,9 @@ static BYTE *fat_hRcsId = "$Id$"; /* * $Log$ + * Revision 1.10 2001/11/13 23:36:45 bartoldeman + * Kernel 2025a final changes. + * * Revision 1.9 2001/11/04 19:47:39 bartoldeman * kernel 2025a changes: see history.txt * @@ -161,6 +164,18 @@ struct dirent ULONG dir_size; /* File size in bytes */ }; +struct lfn_entry +{ + UBYTE lfn_id; + UNICODE lfn_name0_4[5]; + UBYTE lfn_attrib; + UBYTE lfn_reserved1; + UBYTE lfn_checksum; + UNICODE lfn_name5_10[6]; + UWORD lfn_reserved2; + UNICODE lfn_name11_12[2]; +}; + /* */ /* filesystem sizeof(dirent) - may be different from core */ /* */ @@ -193,3 +208,14 @@ struct dirent #define DIR_SIZE FNAME_SIZE+FEXT_SIZE+17 #define DIRENT_SIZE 32 + +struct lfn_inode +{ + UNICODE name[256]; + + struct dirent l_dir; + + ULONG l_diroff; /* offset of the dir entry */ +}; + +typedef struct lfn_inode FAR * lfn_inode_ptr; diff --git a/hdr/kconfig.h b/hdr/kconfig.h index dd2e6a51..cddbfcb0 100644 --- a/hdr/kconfig.h +++ b/hdr/kconfig.h @@ -21,5 +21,7 @@ typedef struct _KernelConfig { unsigned char DLASortByDriveNo; unsigned char InitDiskShowDriveAssignment; signed char SkipConfigSeconds; + unsigned char ForceLBA; + unsigned char GlobalEnableLBAsupport; /* = 0 --> disable LBA support */ } KernelConfig; extern struct _KernelConfig FAR LowKernelConfig; diff --git a/hdr/version.h b/hdr/version.h index b80e9d16..b8bbd66e 100644 --- a/hdr/version.h +++ b/hdr/version.h @@ -44,6 +44,6 @@ static BYTE *date_hRcsId = "$Id$"; #define REVISION_MINOR 1 #define REVISION_SEQ 25 #define BUILD "2025" -#define SUB_BUILD "a test" -#define KERNEL_VERSION_STRING "1.1.25" /*#REVISION_MAJOR "." #REVISION_MINOR "." #REVISION_SEQ*/ -#define KERNEL_BUILD_STRING "2025a test" /*#BUILD SUB_BUILD*/ +#define SUB_BUILD "a" +#define KERNEL_VERSION_STRING "1.1.25a" /*#REVISION_MAJOR "." #REVISION_MINOR "." #REVISION_SEQ*/ +#define KERNEL_BUILD_STRING "2025a" /*#BUILD SUB_BUILD*/ diff --git a/kernel/blockio.c b/kernel/blockio.c index 1c697aa4..7e54b160 100644 --- a/kernel/blockio.c +++ b/kernel/blockio.c @@ -37,6 +37,9 @@ static BYTE *blockioRcsId = "$Id$"; /* * $Log$ + * Revision 1.15 2001/11/13 23:36:45 bartoldeman + * Kernel 2025a final changes. + * * Revision 1.14 2001/11/04 19:47:39 bartoldeman * kernel 2025a changes: see history.txt * @@ -592,7 +595,7 @@ UWORD dskxfer(COUNT dsk, ULONG blkno, VOID FAR * buf, UWORD numblocks, COUNT mod return 0x0201; /* illegal command */ } -#if 1 +#if TOM #define KeyboardShiftState() (*(BYTE FAR *)(MK_FP(0x40,0x17))) if (KeyboardShiftState() & 0x01) diff --git a/kernel/config.c b/kernel/config.c index 243beb04..5b8a2309 100644 --- a/kernel/config.c +++ b/kernel/config.c @@ -89,6 +89,9 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.30 2001/11/13 23:36:45 bartoldeman + * Kernel 2025a final changes. + * * Revision 1.29 2001/11/04 19:47:39 bartoldeman * kernel 2025a changes: see history.txt * @@ -366,6 +369,7 @@ STATIC struct table commands[] = {"NUMLOCK", 1, Numlock}, /* rem is never executed by locking out pass */ {"REM", 0, CfgFailure}, + {";", 0, CfgFailure}, {"SHELL", 1, InitPgm}, {"SHELLHIGH", 1, InitPgmHigh}, {"STACKS", 1, Stacks}, @@ -1419,7 +1423,11 @@ INIT BYTE * askThisSingleCommand = FALSE; s = skipwh(s); - while (*s && + if (*s == ';') { + /* semicolon is a synonym for rem */ + *d++ = *s++; + } + else while (*s && !(*s == 0x0d || *s == 0x0a || *s == ' ' diff --git a/kernel/dosfns.c b/kernel/dosfns.c index e96fb90c..aa528059 100644 --- a/kernel/dosfns.c +++ b/kernel/dosfns.c @@ -37,6 +37,9 @@ static BYTE *dosfnsRcsId = "$Id$"; * /// Added SHARE support. 2000/09/04 Ron Cemer * * $Log$ + * Revision 1.30 2001/11/13 23:36:45 bartoldeman + * Kernel 2025a final changes. + * * Revision 1.29 2001/11/04 19:47:39 bartoldeman * kernel 2025a changes: see history.txt * @@ -1134,8 +1137,7 @@ COUNT DosCloseSft(WORD sft_idx) return DE_INVLDHNDL; /* If this is not opened another error */ - /* The second condition is a sanity check and necessary for FcbCloseAll */ - if (sftp->sft_count == 0 || (sftp->sft_count == 1 && sftp->sft_psp != cu_psp)) + if (sftp->sft_count == 0) return DE_ACCESS; lpCurSft = sftp; @@ -1181,8 +1183,9 @@ COUNT DosClose(COUNT hndl) return ret; } -VOID DosGetFree(UBYTE drive, COUNT FAR * spc, COUNT FAR * navc, COUNT FAR * bps, COUNT FAR * nc) +BOOL DosGetFree(UBYTE drive, UCOUNT FAR * spc, UCOUNT FAR * navc, UCOUNT FAR * bps, UCOUNT FAR * nc) { + /* *nc==0xffff means: called from FatGetDrvData, fcbfns.c */ struct dpb FAR *dpbp; struct cds FAR *cdsp; COUNT rg[4]; @@ -1193,29 +1196,45 @@ VOID DosGetFree(UBYTE drive, COUNT FAR * spc, COUNT FAR * navc, COUNT FAR * bps, /* first check for valid drive */ *spc = -1; if (drive >= lastdrive) - return; + return FALSE; cdsp = &CDSp->cds_table[drive]; if (!(cdsp->cdsFlags & CDSVALID)) - return; + return FALSE; if (cdsp->cdsFlags & CDSNETWDRV) { + if (*nc == 0xffff) + { + /* Undoc DOS says, its not supported for + network drives. so it's probably OK */ + /*printf("FatGetDrvData not yet supported over network drives\n");*/ + return FALSE; + } + remote_getfree(cdsp, rg); *spc = (COUNT) rg[0]; *nc = (COUNT) rg[1]; *bps = (COUNT) rg[2]; *navc = (COUNT) rg[3]; - return; + return TRUE; } dpbp = CDSp->cds_table[drive].cdsDpb; - if (dpbp == NULL || media_check(dpbp) < 0) - return; + if (dpbp == NULL) + return FALSE; + + if (*nc == 0xffff) + { + flush_buffers(dpbp->dpb_unit); + dpbp->dpb_flags = M_CHANGED; + } + + if (media_check(dpbp) < 0) + return FALSE; /* get the data available from dpb */ - *nc = dpbp->dpb_size - 1; *spc = dpbp->dpb_clsmask + 1; *bps = dpbp->dpb_secsize; @@ -1229,7 +1248,7 @@ VOID DosGetFree(UBYTE drive, COUNT FAR * spc, COUNT FAR * navc, COUNT FAR * bps, /* we shift ntotal until it is equal to or below 0xfff6 */ cluster_size = (ULONG)dpbp->dpb_secsize << dpbp->dpb_shftcnt; ntotal = dpbp->dpb_xsize - 1; - nfree = dos_free(dpbp); + if (*nc != 0xffff) nfree = dos_free(dpbp); while (ntotal > FAT_MAGIC16 && cluster_size < 0x8000) { cluster_size <<= 1; @@ -1243,10 +1262,21 @@ VOID DosGetFree(UBYTE drive, COUNT FAR * spc, COUNT FAR * navc, COUNT FAR * bps, /* now tell fs to give us free cluster */ /* count */ *navc = nfree > FAT_MAGIC16 ? FAT_MAGIC16 : (UCOUNT)nfree; - return; + return TRUE; } #endif - *navc = (COUNT)dos_free(dpbp); + /* a passed nc of 0xffff means: skip free; see FatGetDrvData + fcbfns.c */ + if (*nc != 0xffff) *navc = (COUNT)dos_free(dpbp); + *nc = dpbp->dpb_size - 1; + if (*spc > 64) { + /* fake for 64k clusters do confuse some DOS programs, but let + others work without overflowing */ + *spc >>= 1; + *navc = (*navc < FAT_MAGIC16/2) ? (*navc << 1) : FAT_MAGIC16; + *nc = (*nc < FAT_MAGIC16/2) ? (*nc << 1) : FAT_MAGIC16; + } + return TRUE; } #ifdef WITHFAT32 diff --git a/kernel/dsk.c b/kernel/dsk.c index 43a39962..e3d76684 100644 --- a/kernel/dsk.c +++ b/kernel/dsk.c @@ -34,6 +34,9 @@ static BYTE *dskRcsId = "$Id$"; /* * $Log$ + * Revision 1.22 2001/11/13 23:36:45 bartoldeman + * Kernel 2025a final changes. + * * Revision 1.21 2001/11/04 19:47:39 bartoldeman * kernel 2025a changes: see history.txt * @@ -979,12 +982,19 @@ STATIC WORD dskerr(COUNT code) void LBA_to_CHS(struct CHS *chs, ULONG LBA_address, ddt *pddt) { - chs->Sector = LBA_address% pddt->ddt_bpb.bpb_nsecs + 1; + /* we need the defbpb values since those are taken from the + BIOS, not from some random boot sector, except when + we're dealing with a floppy */ + bpb *pbpb = hd(pddt->ddt_descflags) ? + &pddt->ddt_defbpb : + &pddt->ddt_bpb; + + chs->Sector = LBA_address % pbpb->bpb_nsecs + 1; - LBA_address /= pddt->ddt_bpb.bpb_nsecs; + LBA_address /= pbpb->bpb_nsecs; - chs->Head = LBA_address % pddt->ddt_bpb.bpb_nheads; - chs->Cylinder = LBA_address / pddt->ddt_bpb.bpb_nheads; + chs->Head = LBA_address % pbpb->bpb_nheads; + chs->Cylinder = LBA_address / pbpb->bpb_nheads; } @@ -1079,7 +1089,7 @@ int LBA_Transfer(ddt *pddt ,UWORD mode, VOID FAR *buffer, count = DMA_max_transfer(buffer,count); - if (FP_SEG(buffer) == 0xffff || count == 0) + if (FP_SEG(buffer) >= 0xa000 || count == 0) { transfer_address = DiskTransferBuffer; count = 1; diff --git a/kernel/entry.asm b/kernel/entry.asm index e32fbe34..a7deb29f 100644 --- a/kernel/entry.asm +++ b/kernel/entry.asm @@ -28,6 +28,9 @@ ; $Id$ ; ; $Log$ +; Revision 1.16 2001/11/13 23:36:45 bartoldeman +; Kernel 2025a final changes. +; ; Revision 1.15 2001/11/04 19:47:39 bartoldeman ; kernel 2025a changes: see history.txt ; @@ -183,7 +186,7 @@ reloc_call_cpm_entry: cmp cl,024h jbe cpm_error mov ah,cl ; get the call # from cl to ah - jmp short reloc_call_int21_handler ; do the system call + jmp reloc_call_int21_handler ; do the system call cpm_error: mov al,0 iret @@ -218,13 +221,30 @@ _RestartSysCall: ; int20_handler(iregs UserRegs) ; -divide_by_zero_message db 0dh,0ah,'Interrupt divide by zero',0dh,0ah,0 +print_hex: mov cx, 404h +hex_loop: + rol dx, cl + mov al, dl + and al, 0fh + add al, 30h + cmp al, 39h + jbe no_letter + add al, 7 +no_letter: + mov bx, 0070h + mov ah, 0eh + int 10h + dec ch + jnz hex_loop + ret + +divide_by_zero_message db 0dh,0ah,'Interrupt divide by zero, stack:',0dh,0ah,0 global reloc_call_int0_handler reloc_call_int0_handler: mov si,divide_by_zero_message - + zero_message_loop: mov al, [cs:si] test al,al @@ -239,10 +259,26 @@ zero_message_loop: jmp short zero_message_loop zero_done: + mov bp, sp + xor si, si ; print 13 words of stack for debugging LUDIV etc. +stack_loop: + mov dx, [bp+si] + call print_hex + mov al, ' ' + int 10h + inc si + inc si + cmp si, 13*2 + jb stack_loop + mov al, 0dh + int 10h + mov al, 0ah + int 10h + mov ax,04c7fh ; terminate with errorlevel 127 int 21h -invalid_opcode_message db 0dh,0ah,'Invalid Opcode',0dh,0ah,0 +invalid_opcode_message db 0dh,0ah,'Invalid Opcode at ',0 global reloc_call_int6_handler reloc_call_int6_handler: diff --git a/kernel/fatdir.c b/kernel/fatdir.c index 91e2a8a7..35be0360 100644 --- a/kernel/fatdir.c +++ b/kernel/fatdir.c @@ -36,6 +36,9 @@ static BYTE *fatdirRcsId = "$Id$"; /* * $Log$ + * Revision 1.25 2001/11/13 23:36:45 bartoldeman + * Kernel 2025a final changes. + * * Revision 1.24 2001/11/04 19:47:39 bartoldeman * kernel 2025a changes: see history.txt * @@ -388,10 +391,8 @@ f_node_ptr dir_open(BYTE * dirname) * Return value. * 1 - all OK, directory entry having been read is not empty. * 0 - Directory entry is empty. - * DE_HNDLDSKFULL - Disk full - * DE_SEEK - Other error from map_cluster - * DE_TOOMANY - Too many files in root dir. - * DE_BLKINVLD - Invalid block + * DE_SEEK - Attempt to read beyound the end of the directory. + * DE_BLKINVLD - Invalid block. * Note. Empty directory entries always resides at the end of the directory. */ COUNT dir_read(REG f_node_ptr fnp) { @@ -415,7 +416,7 @@ COUNT dir_read(REG f_node_ptr fnp) if (fnp->f_flags.f_droot) { if (new_diroff >= DIRENT_SIZE * (ULONG)fnp->f_dpb->dpb_dirents) - return DE_TOOMANY; + return DE_SEEK; bp = getblock((ULONG) (new_diroff / secsize + fnp->f_dpb->dpb_dirstrt), @@ -426,8 +427,6 @@ COUNT dir_read(REG f_node_ptr fnp) } else { - COUNT rc; - /* Do a "seek" to the directory position */ fnp->f_offset = new_diroff; @@ -436,14 +435,8 @@ COUNT dir_read(REG f_node_ptr fnp) #ifdef DISPLAY_GETBLOCK printf("dir_read: "); #endif - if ((rc = map_cluster(fnp, XFR_READ)) != SUCCESS) - return rc; - - /* If the returned cluster is FREE, LAST_CLUSTER */ - /* LONG_LAST_CLUSTER, return "disk as full" */ - - if (fnp->f_cluster == FREE || last_link(fnp)) - return DE_HNDLDSKFULL; + if (map_cluster(fnp, XFR_READ) != SUCCESS) + return DE_SEEK; /* Compute the block within the cluster and the */ /* offset within the block. */ @@ -527,9 +520,7 @@ BOOL dir_write(REG f_node_ptr fnp) #ifdef DISPLAY_GETBLOCK printf("dir_write: "); #endif - /* If map_cluster gives an error or the returned cluster is FREE, - return FALSE */ - if (map_cluster(fnp, XFR_READ) != SUCCESS || fnp->f_cluster == FREE) + if (map_cluster(fnp, XFR_READ) != SUCCESS) { release_f_node(fnp); return FALSE; diff --git a/kernel/fatfs.c b/kernel/fatfs.c index 3da3c891..08000d16 100644 --- a/kernel/fatfs.c +++ b/kernel/fatfs.c @@ -47,6 +47,9 @@ BYTE *RcsId = "$Id$"; * performance killer on large drives. (~0.5 sec /dos_mkdir) TE * * $Log$ + * Revision 1.26 2001/11/13 23:36:45 bartoldeman + * Kernel 2025a final changes. + * * Revision 1.25 2001/11/04 19:47:39 bartoldeman * kernel 2025a changes: see history.txt * @@ -1543,13 +1546,25 @@ STATIC BOOL first_fat(f_node_ptr fnp) return TRUE; } -/* JPP: I think this starts at the beginning of a file, and follows - the fat chain to find the cluster that contains the data for the - file at f_offset. */ +/* Description. + * Finds the cluster which contains byte at the fnp->f_offset offset and + * stores its number to the fnp->f_cluster. The search begins from the start of + * a file or a directory depending whether fnp->f_ddir is FALSE or TRUE + * and continues through the FAT chain until the target cluster is found. + * The mode can have only XFR_READ or XFR_WRITE values. + * In the XFR_WRITE mode map_cluster extends the FAT chain by creating + * new clusters upon necessity. + * Return value. + * DE_HNDLDSKFULL - [XFR_WRITE mode only] unable to find free cluster + * for extending the FAT chain, the disk is full. + * The fnode is released from memory. + * DE_SEEK - [XFR_READ mode only] byte at f_offset lies outside of + * the FAT chain. The fnode is not released. + * Notes. + * JPP: new map_cluster. If we are moving forward, then use the offset + * that we are at now (f_cluster_offset) to start, instead of starting + * at the beginning. */ -/* JPP: new map_cluster. If we are moving forward, then use the offset - that we are at now (f_cluster_offset) to start, instead of starting - at the beginning. */ COUNT map_cluster(REG f_node_ptr fnp, COUNT mode) { ULONG idx; @@ -1570,7 +1585,10 @@ COUNT map_cluster(REG f_node_ptr fnp, COUNT mode) { /* If there are no more free fat entries, then we are full! */ if (!first_fat(fnp)) + { + dir_close(fnp); return DE_HNDLDSKFULL; + } } if (fnp->f_offset >= fnp->f_cluster_offset) /*JPP */ @@ -1594,19 +1612,16 @@ COUNT map_cluster(REG f_node_ptr fnp, COUNT mode) /* physical cluster. Our search is performed by pacing an index */ /* up to the relative cluster position where the index falls */ /* within the cluster. */ - /* */ - /* NOTE: make sure your compiler does not optimize for loop */ - /* tests to the loop exit. We need to fall out immediately for */ - /* files whose length < cluster size. */ - for (; idx >= clssize; idx -= clssize) + + FOREVER { /* If this is a read and the next is a LAST_CLUSTER, */ /* then we are going to read past EOF, return zero read */ - if ((mode == XFR_READ) && last_link(fnp)) + if ((mode == XFR_READ) && (last_link(fnp) || fnp->f_cluster == FREE)) return DE_SEEK; -/* expand the list if we're going to write and have run into */ -/* the last cluster marker. */ - else if ((mode == XFR_WRITE) && last_link(fnp)) + /* expand the list if we're going to write and have run into */ + /* the last cluster marker. */ + if ((mode == XFR_WRITE) && (last_link(fnp))) { if (!extend(fnp)) { @@ -1614,13 +1629,18 @@ COUNT map_cluster(REG f_node_ptr fnp, COUNT mode) return DE_HNDLDSKFULL; } } + + if (idx < clssize) + break; + fnp->f_back = fnp->f_cluster; /* get next cluster in the chain */ fnp->f_cluster = next_cluster(fnp->f_dpb, fnp->f_cluster); fnp->f_cluster_offset += clssize; + idx -= clssize; } - + #ifdef DISPLAY_GETBLOCK printf("done.\n"); #endif @@ -1799,20 +1819,11 @@ UCOUNT readblock(COUNT fd, VOID FAR * buffer, UCOUNT count, COUNT * err) #ifdef DISPLAY_GETBLOCK printf("readblock: "); #endif - switch (map_cluster(fnp, XFR_READ)) + if (map_cluster(fnp, XFR_READ) != SUCCESS) { - case DE_SEEK: - *err = DE_SEEK; - dir_close(fnp); - return ret_cnt; - - default: - *err = DE_HNDLDSKFULL; - dir_close(fnp); - return ret_cnt; - - case SUCCESS: - break; + *err = DE_SEEK; + dir_close(fnp); + return ret_cnt; } } @@ -1984,20 +1995,8 @@ STATIC COUNT dos_extend(f_node_ptr fnp) while (count > 0) { #endif - switch (map_cluster(fnp, XFR_WRITE)) - { - case DE_SEEK: - dir_close(fnp); - return DE_SEEK; - - default: - dir_close(fnp); - return DE_HNDLDSKFULL; - - case SUCCESS: - merge_file_changes(fnp, FALSE); /* /// Added - Ron Cemer */ - break; - } + if (map_cluster(fnp, XFR_WRITE) != SUCCESS) + return DE_HNDLDSKFULL; #ifdef WRITEZEROS /* Compute the block within the cluster and the offset */ @@ -2181,31 +2180,9 @@ UCOUNT writeblock(COUNT fd, VOID FAR * buffer, UCOUNT count, COUNT * err) #ifdef DISPLAY_GETBLOCK printf("writeblock: "); #endif - switch (map_cluster(fnp, XFR_WRITE)) + if (map_cluster(fnp, XFR_WRITE) != SUCCESS) { - case DE_SEEK: - *err = DE_SEEK; - dir_close(fnp); - return ret_cnt; - - default: - dir_close(fnp); - *err = DE_HNDLDSKFULL; - return ret_cnt; - - case SUCCESS: - merge_file_changes(fnp, FALSE); /* /// Added - Ron Cemer */ - break; - } - } - - /* XFR_WRITE case only - if we're at the end, the next */ - /* FAT is an EOF marker, so just extend the file length */ - if (last_link(fnp)) { - if (!extend(fnp)) - { - dir_close(fnp); - *err = DE_HNDLDSKFULL; + *err = DE_HNDLDSKFULL; return ret_cnt; } merge_file_changes(fnp, FALSE); /* /// Added - Ron Cemer */ @@ -2708,10 +2685,6 @@ STATIC VOID shrink_file(f_node_ptr fnp) st = fnp->f_cluster; - /* first cluster is free or EOC */ - if (st == FREE || st == LONG_LAST_CLUSTER) - goto done; - next = next_cluster(dpbp, st); if (next == LONG_LAST_CLUSTER) /* last cluster found */ diff --git a/kernel/fattab.c b/kernel/fattab.c index 35c36b5e..eaec6df0 100644 --- a/kernel/fattab.c +++ b/kernel/fattab.c @@ -35,6 +35,9 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.10 2001/11/13 23:36:45 bartoldeman + * Kernel 2025a final changes. + * * Revision 1.9 2001/11/04 19:47:39 bartoldeman * kernel 2025a changes: see history.txt * @@ -401,8 +404,10 @@ UCOUNT link_fat12(struct dpb FAR *dpbp, CLUSTER Cluster1, CLUSTER Cluster2) CLUSTER next_cluster(struct dpb FAR *dpbp, CLUSTER ClusterNum) { struct buffer FAR *bp; +#ifdef DEBUG if (ClusterNum == LONG_LAST_CLUSTER) printf("fatal error: trying to do next_cluster(dpbp, EOC)!\n"); - + if (ClusterNum == 0) printf("fatal error: trying to do next_cluster(dpbp, 0)!\n"); +#endif /* Get the block that this cluster is in */ bp = getFATblock(ClusterNum, dpbp); diff --git a/kernel/fcbfns.c b/kernel/fcbfns.c index f207945d..65b70424 100644 --- a/kernel/fcbfns.c +++ b/kernel/fcbfns.c @@ -35,6 +35,9 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.20 2001/11/13 23:36:45 bartoldeman + * Kernel 2025a final changes. + * * Revision 1.19 2001/11/04 19:47:39 bartoldeman * kernel 2025a changes: see history.txt * @@ -178,68 +181,16 @@ BOOL FcbCalcRec(); static dmatch Dmatch; -VOID FatGetDrvData(UCOUNT drive, COUNT FAR * spc, COUNT FAR * bps, - COUNT FAR * nc, BYTE FAR ** mdp) +VOID FatGetDrvData(UCOUNT drive, UCOUNT FAR * spc, UCOUNT FAR * bps, + UCOUNT FAR * nc, BYTE FAR ** mdp) { - struct dpb FAR *dpbp; - struct cds FAR *cdsp; - - /* first check for valid drive */ - *spc = -1; - - drive = (drive == 0 ? default_drive : drive - 1); - - if (drive >= lastdrive) - return; - - cdsp = &CDSp->cds_table[drive]; - - if (!(cdsp->cdsFlags & CDSVALID)) - return; - - /* next - "log" in the drive */ - if (cdsp->cdsFlags & CDSNETWDRV) { - /* Undoc DOS says, its not supported for - network drives. so it's probably OK */ - /*printf("FatGetDrvData not yet supported over network drives\n");*/ - return; - } - dpbp = CDSp->cds_table[drive].cdsDpb; - - if (dpbp == NULL) - { - return; - } - - dpbp->dpb_flags = -1; - if ((media_check(dpbp) < 0)) - { - return; - } - + UCOUNT navc; + /* get the data available from dpb */ - *nc = dpbp->dpb_size - 1; - *spc = dpbp->dpb_clsmask + 1; -#ifdef WITHFAT32 - if (ISFAT32(dpbp)) - { - ULONG cluster_size, ntotal; - - cluster_size = (ULONG)dpbp->dpb_secsize << dpbp->dpb_shftcnt; - ntotal = dpbp->dpb_xsize - 1; - while (ntotal > FAT_MAGIC16 && cluster_size < 0x8000) { - cluster_size <<= 1; - *spc <<= 1; - ntotal >>= 1; - } - /* get the data available from dpb */ - *nc = ntotal > FAT_MAGIC16 ? FAT_MAGIC16 : (UCOUNT)ntotal; - } -#endif - *bps = dpbp->dpb_secsize; - + *nc = 0xffff; /* pass 0xffff to skip free count */ + if (DosGetFree(drive, spc, &navc, bps, nc)) /* Point to the media desctriptor for this drive */ - *mdp = (BYTE FAR*)&(dpbp->dpb_mdb); + *mdp = (BYTE FAR*)&(CDSp->cds_table[drive].cdsDpb->dpb_mdb); } #define PARSE_SEP_STOP 0x01 @@ -628,6 +579,7 @@ see get_free_sft in dosfns.c BOOL FcbCreate(xfcb FAR * lpXfcb) { + sft FAR *sftp; COUNT sft_idx, FcbDrive; struct dhdr FAR *dhp; @@ -638,6 +590,9 @@ BOOL FcbCreate(xfcb FAR * lpXfcb) if (sft_idx < 0) return FALSE; + sftp = idx_to_sft(sft_idx); + sftp->sft_attrib |= SFT_MFCB; + /* check for a device */ dhp = IsDevice(PriPathName); lpFcb->fcb_sftno = sft_idx; @@ -709,6 +664,9 @@ BOOL FcbOpen(xfcb FAR * lpXfcb) if (sft_idx < 0) return FALSE; + sftp = idx_to_sft(sft_idx); + sftp->sft_attrib |= SFT_MFCB; + /* check for a device */ lpFcb->fcb_curec = 0; lpFcb->fcb_rndm = 0; @@ -723,7 +681,6 @@ BOOL FcbOpen(xfcb FAR * lpXfcb) } else { - sftp = idx_to_sft(sft_idx); lpFcb->fcb_drive = FcbDrive; lpFcb->fcb_recsiz = 128; lpFcb->fcb_fsize = sftp->sft_size; @@ -902,15 +859,15 @@ BOOL FcbClose(xfcb FAR * lpXfcb) return FALSE; } -/* close all files opened by FCBs - DosCloseSft checks the open count (has to be 1) and current psp - */ +/* close all files the current process opened by FCBs */ VOID FcbCloseAll() { COUNT idx = 0; + sft FAR *sftp; - for (idx = 0; DosCloseSft(idx) != DE_INVLDHNDL; idx++) - ; + for (idx = 0; (sftp = idx_to_sft(idx)) != (sft FAR *) -1; idx++) + if ((sftp->sft_attrib & SFT_MFCB) && sftp->sft_psp == cu_psp) + DosCloseSft(idx); } BOOL FcbFindFirst(xfcb FAR * lpXfcb) diff --git a/kernel/init-mod.h b/kernel/init-mod.h index f18c4497..5dffac9a 100644 --- a/kernel/init-mod.h +++ b/kernel/init-mod.h @@ -36,6 +36,7 @@ extern struct _KernelConfig InitKernelConfig; * entry points. */ #define printf init_printf +#define sprintf init_sprintf #define execrh reloc_call_execrh #define fmemcpy reloc_call_fmemcpy #define fmemset reloc_call_fmemset @@ -192,6 +193,7 @@ INIT VOID init_fatal(BYTE * err_msg); /* prf.c */ WORD init_printf(CONST BYTE * fmt,...); +WORD init_sprintf(BYTE * buff, CONST BYTE * fmt, ...); void MoveKernel(unsigned NewKernelSegment); extern WORD HMAFree; /* first byte in HMA not yet used */ diff --git a/kernel/initdisk.c b/kernel/initdisk.c index 5ee13437..358ff26c 100644 --- a/kernel/initdisk.c +++ b/kernel/initdisk.c @@ -103,9 +103,58 @@ extern UWORD DOSFAR LBA_WRITE_VERIFY; * * e) and all this is my private opinion. tom ehlert. * + * + * Some thoughts about LBA vs. CHS. by Bart Oldeman 2001/Nov/11 + * Matthias Paul writes in www.freedos.org/freedos/news/technote/113.html: + * (...) MS-DOS 7.10+, which will always access logical drives in a type + * 05h extended partition via CHS, even if the individual logical drives + * in there are of LBA type, or go beyond 8 Gb... (Although this workaround + * is sometimes used in conjunction with OS/2, using a 05h partition going + * beyond 8 Gb may cause MS-DOS 7.10 to hang or corrupt your data...) (...) + * + * Also at http://www.win.tue.nl/~aeb/partitions/partition_types-1.html: + * (...) 5 DOS 3.3+ Extended Partition + * Supports at most 8.4 GB disks: with type 5 DOS/Windows will not use the + * extended BIOS call, even if it is available. (...) + * + * So MS-DOS 7.10+ is brain-dead in this respect, but we knew that ;-) + * However there is one reason to use old-style CHS calls: + * some programs intercept int 13 and do not support LBA addressing. So + * it is worth using CHS if possible, unless the user asks us not to, + * either by specifying a 0x0c/0x0e/0x0f partition type or enabling + * the ForceLBA setting in the fd kernel (sys) config. This will make + * multi-sector reads and BIOS computations more efficient, at the cost + * of some compatibility. + * + * However we need to be safe, and with varying CHS at different levels + * that might be difficult. Hence we _only_ trust the LBA values in the + * partition tables and the heads and sectors values the BIOS gives us. + * After all these are the values the BIOS uses to process our CHS values. + * So unless the BIOS is buggy, using CHS on one partition and LBA on another + * should be safe. The CHS values in the partition table are NOT trusted. + * We print a warning if there is a mismatch with the calculated values. + * + * The CHS values in the boot sector are used at a higher level. The CHS + * that DOS uses in various INT21/AH=44 IOCTL calls are converted to LBA + * using the boot sector values and then converted back to CHS using BIOS + * values if necessary. Internally we do LBA as much as possible. + * + * However if the partition extends beyond cylinder 1023 and is not labelled + * as one of the LBA types, we can't use CHS and print a warning, using LBA + * instead if possible, and otherwise refuse to use it. + * + * As for EXTENDED_LBA vs. EXTENDED, FreeDOS makes no difference. This is + * boot time - there is no reason not to use LBA for reading partition tables, + * and the MSDOS 7.10 behaviour is not desirable. + * + * Note: for floppies we need the boot sector values though and the boot sector + * code does not use LBA addressing yet. + * + * Conclusion: with all this implemented, FreeDOS should be able to gracefully + * handle and read foreign hard disks moved across computers, whether using + * CHS or LBA, strengthening its role as a rescue environment. */ - /* #define DEBUG */ #define _BETA_ /* messages for initial phase only */ @@ -146,6 +195,7 @@ extern UWORD DOSFAR LBA_WRITE_VERIFY; /* boundary. LBA is needed to access this. */ #define FAT16_LBA 0x0e /* like 0x06, but it is supposed to end past */ /* the 8.4GB boundary */ +#define FAT12_LBA 0xff /* fake FAT12 LBA entry for internal use */ #define EXTENDED_LBA 0x0f /* like 0x05, but it is supposed to end past */ /* Let's play it safe and do not allow partitions with clusters above * @@ -160,6 +210,10 @@ extern UWORD DOSFAR LBA_WRITE_VERIFY; #define IsExtPartition(parttyp) ((parttyp) == EXTENDED || \ (parttyp) == EXTENDED_LBA ) +#define IsLBAPartition(parttyp) ((parttyp) == FAT12_LBA || \ + (parttyp) == FAT16_LBA || \ + (parttyp) == FAT32_LBA) + #ifdef WITHFAT32 #define IsFATPartition(parttyp) ((parttyp) == FAT12 || \ (parttyp) == FAT16SMALL || \ @@ -221,8 +275,6 @@ struct PartTableEntry /* INTERNAL representation of partition table entry */ internal global data */ -UBYTE GlobalEnableLBAsupport = 1; /* = 0 --> disable LBA support */ - COUNT init_readdasd(UBYTE drive) { static iregs regs; @@ -266,37 +318,31 @@ floppy_bpb floppy_bpbs[5] = { COUNT init_getdriveparm(UBYTE drive, bpb FAR *pbpbarray) { static iregs regs; + REG UBYTE type; if (drive & 0x80) return 5; regs.a.b.h = 0x08; regs.d.b.l = drive; init_call_intr(0x13,®s); + type = regs.b.b.l - 1; if (regs.flags & 1) - return 0; /* return 320-360 for XTs */ - - switch(regs.b.b.l) - { - case 1: /* 320-360 */ - fmemcpy(pbpbarray, &floppy_bpbs[0], sizeof(floppy_bpb)); - return 0; - case 2: /* 1.2 */ - fmemcpy(pbpbarray, &floppy_bpbs[1], sizeof(floppy_bpb)); - return 1; - case 3: /* 720 */ - fmemcpy(pbpbarray, &floppy_bpbs[2], sizeof(floppy_bpb)); - return 2; - case 4: /* 1.44 */ - fmemcpy(pbpbarray, &floppy_bpbs[3], sizeof(floppy_bpb)); - return 7; - case 5: /* 2.88 almost forgot this one*/ - case 6: - fmemcpy(pbpbarray, &floppy_bpbs[4], sizeof(floppy_bpb)); - return 9; - } - /* any odd ball drives return this */ - fmemcpy(pbpbarray, &floppy_bpbs[0], sizeof(floppy_bpb)); - return 8; + type = 0; /* return 320-360 for XTs */ + else if (type > 6) + type = 8; /* any odd ball drives get 8&7=0: the 320-360 table */ + else if (type == 5) + type = 4; /* 5 and 4 are both 2.88 MB */ + + fmemcpy(pbpbarray, &floppy_bpbs[type & 7], sizeof(floppy_bpb)); + + if (type == 3) + return 7; /* 1.44 MB */ + + if (type == 4) + return 9; /* 2.88 almost forgot this one*/ + + /* 0=320-360kB, 1=1.2MB, 2=720kB, 8=any odd ball drives */ + return type; } /* @@ -363,6 +409,7 @@ VOID CalculateFATData(ddt FAR *pddt, ULONG NumSectors, UBYTE FileSystem) switch(FileSystem) { case FAT12: + case FAT12_LBA: /* in DOS, FAT12 defaults to 4096kb (8 sector) - clusters. */ defbpb->bpb_nsector = 8; /* Force maximal fatdata=32696 sectors since with our only possible sector @@ -502,6 +549,11 @@ void DosDefinePartition(struct DriveParamS *driveParam, pddt->ddt_driveno = driveParam->driveno; pddt->ddt_logdriveno = nUnits; pddt->ddt_LBASupported = driveParam->LBA_supported; + /* Turn of LBA if not forced and the partition is within 1023 cyls and of the right type */ + /* the FileSystem type was internally converted to LBA_xxxx if a non-LBA partition + above cylinder 1023 was found */ + if (!InitKernelConfig.ForceLBA && !IsLBAPartition(pEntry->FileSystem)) + pddt->ddt_LBASupported = FALSE; pddt->ddt_WriteVerifySupported = driveParam->WriteVerifySupported; pddt->ddt_ncyl = driveParam->chs.Cylinder; @@ -576,7 +628,7 @@ int LBA_Get_Drive_Parameters(int drive,struct DriveParamS *driveParam) /* for tests - disable LBA support, even if exists */ - if (!GlobalEnableLBAsupport) + if (!InitKernelConfig.GlobalEnableLBAsupport) { goto StandardBios; } @@ -611,6 +663,7 @@ int LBA_Get_Drive_Parameters(int drive,struct DriveParamS *driveParam) LBA_WRITE_VERIFY = 0x4301; + memset(&lba_bios_parameters, 0, sizeof(lba_bios_parameters)); lba_bios_parameters.size = sizeof(lba_bios_parameters); @@ -637,7 +690,7 @@ int LBA_Get_Drive_Parameters(int drive,struct DriveParamS *driveParam) drive, (ULONG)lba_bios_parameters.heads, (ULONG)lba_bios_parameters.sectors, - (ULONG)lba_bios_parameters.sectors, + (ULONG)lba_bios_parameters.totalSect, (ULONG)lba_bios_parameters.totalSectHigh); goto StandardBios; @@ -751,6 +804,8 @@ ScanForPrimaryPartitions(struct DriveParamS *driveParam,int scan_type, int i; struct CHS chs,end; ULONG partitionStart; + char partitionName[12]; + for (i = 0; i < 4; i++,pEntry++) { @@ -775,6 +830,12 @@ ScanForPrimaryPartitions(struct DriveParamS *driveParam,int scan_type, continue; } + + + if (extendedPartNo) sprintf(partitionName, "Ext:%d", extendedPartNo); + else sprintf(partitionName, "Pri:%d",i+1); + + /* some sanity checks, that partition structure is OK @@ -792,8 +853,8 @@ ScanForPrimaryPartitions(struct DriveParamS *driveParam,int scan_type, chs.Head != pEntry->Begin.Head || chs.Sector != pEntry->Begin.Sector ) { - printf("WARNING: using suspect partition %u FS %02x:", - i, pEntry->FileSystem); + printf("WARNING: using suspect partition %s FS %02x:", + partitionName, pEntry->FileSystem); printCHS(" with calculated values ",&chs); printCHS(" instead of ",&pEntry->Begin); printf("\n"); @@ -809,12 +870,12 @@ ScanForPrimaryPartitions(struct DriveParamS *driveParam,int scan_type, { if (pEntry->NumSect == 0) { - printf("Not using partition %u with 0 sectors\n", i); + printf("Not using partition %s with 0 sectors\n", partitionName); continue; } - printf("WARNING: using suspect partition %u FS %02x:", - i, pEntry->FileSystem); + printf("WARNING: using suspect partition %s FS %02x:", + partitionName, pEntry->FileSystem); printCHS(" with calculated values ",&end); printCHS(" instead of ",&pEntry->End); @@ -825,12 +886,12 @@ ScanForPrimaryPartitions(struct DriveParamS *driveParam,int scan_type, if (chs.Cylinder > 1023 || end.Cylinder > 1023) - { + { if (!driveParam->LBA_supported) { - printf("can't use LBA partition without LBA support - part %u FS %02x", - i, pEntry->FileSystem); + printf("can't use LBA partition without LBA support - part %s FS %02x", + partitionName, pEntry->FileSystem); printCHS(" start ",&chs); printCHS(", end ", &end); @@ -839,15 +900,29 @@ ScanForPrimaryPartitions(struct DriveParamS *driveParam,int scan_type, continue; } - /* else its a diagnostic message only */ + if (!InitKernelConfig.ForceLBA && !IsLBAPartition(pEntry->FileSystem)) + { + printf("WARNING: Partition ID does not suggest LBA - part %s FS %02x.\n" + "Please run FDISK to correct this - using LBA to access partition.\n", + partitionName, pEntry->FileSystem); + + printCHS(" start ",&chs); + printCHS(", end ", &end); + printf("\n"); + pEntry->FileSystem = (pEntry->FileSystem == FAT12 ? FAT12_LBA : + pEntry->FileSystem == FAT32 ? FAT32_LBA : + /* pEntry->FileSystem == FAT16 ? */ FAT16_LBA); + } + + /* else its a diagnostic message only */ #ifdef DEBUG - printf("found and using LBA partition %u FS %02x", - i, pEntry->FileSystem); + printf("found and using LBA partition %s FS %02x", + partitionName, pEntry->FileSystem); printCHS(" start ",&chs); printCHS(", end ", &end); printf("\n"); #endif - } + } /* diff --git a/kernel/inthndlr.c b/kernel/inthndlr.c index 38d1403c..f88365cb 100644 --- a/kernel/inthndlr.c +++ b/kernel/inthndlr.c @@ -37,6 +37,9 @@ BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.33 2001/11/13 23:36:45 bartoldeman + * Kernel 2025a final changes. + * * Revision 1.32 2001/11/04 19:47:39 bartoldeman * kernel 2025a changes: see history.txt * @@ -668,9 +671,9 @@ VOID ASMCFUNC int21_service(iregs FAR * r) BYTE FAR *p; FatGetDrvData(0, - (COUNT FAR *) & r->AX, - (COUNT FAR *) & r->CX, - (COUNT FAR *) & r->DX, + (UCOUNT FAR *) & r->AX, + (UCOUNT FAR *) & r->CX, + (UCOUNT FAR *) & r->DX, (BYTE FAR **) & p); r->DS = FP_SEG(p); r->BX = FP_OFF(p); @@ -683,9 +686,9 @@ VOID ASMCFUNC int21_service(iregs FAR * r) BYTE FAR *p; FatGetDrvData(r->DL, - (COUNT FAR *) & r->AX, - (COUNT FAR *) & r->CX, - (COUNT FAR *) & r->DX, + (UCOUNT FAR *) & r->AX, + (UCOUNT FAR *) & r->CX, + (UCOUNT FAR *) & r->DX, (BYTE FAR **) & p); r->DS = FP_SEG(p); r->BX = FP_OFF(p); @@ -902,8 +905,9 @@ VOID ASMCFUNC int21_service(iregs FAR * r) r->AL = 0xFF; CritErrCode = 0x0f; break; - } - dpb->dpb_flags = M_CHANGED; /* force reread of drive BPB/DPB */ + } + flush_buffers(dpb->dpb_unit); + dpb->dpb_flags = M_CHANGED; /* force flush and reread of drive BPB/DPB */ #ifdef WITHFAT32 if (media_check(dpb) < 0 || ISFAT32(dpb)) @@ -951,10 +955,10 @@ VOID ASMCFUNC int21_service(iregs FAR * r) case 0x36: DosGetFree( r->DL, - (COUNT FAR *) & r->AX, - (COUNT FAR *) & r->BX, - (COUNT FAR *) & r->CX, - (COUNT FAR *) & r->DX); + (UCOUNT FAR *) & r->AX, + (UCOUNT FAR *) & r->BX, + (UCOUNT FAR *) & r->CX, + (UCOUNT FAR *) & r->DX); break; /* Undocumented Get/Set Switchar */ @@ -1105,10 +1109,15 @@ VOID ASMCFUNC int21_service(iregs FAR * r) /* Device I/O Control */ case 0x44: - rc = DosDevIOctl(r); + rc = DosDevIOctl(r); /* can set critical error code! */ if (rc != SUCCESS) - goto error_exit; + { + r->AX = -rc; + if (rc != DE_DEVICE && rc != DE_ACCESS) + CritErrCode = -rc; + SET_CARRY_FLAG(); + } break; /* Duplicate File Handle */ @@ -1753,6 +1762,7 @@ VOID ASMCFUNC int21_service(iregs FAR * r) dpb = GetDriveDPB(r->DL, &rc); if (rc != SUCCESS) goto error_exit; + flush_buffers(dpbp->dpb_unit); dpb->dpb_flags = M_CHANGED; /* force reread of drive BPB/DPB */ if (media_check(dpb) < 0) @@ -1845,6 +1855,7 @@ VOID ASMCFUNC int21_service(iregs FAR * r) case 0x02: { rebuild_dpb: + flush_buffers(dpbp->dpb_unit); dpb->dpb_flags = M_CHANGED; if (media_check(dpb) < 0) @@ -1953,6 +1964,58 @@ VOID ASMCFUNC int21_service(iregs FAR * r) } break; } +#endif +#ifdef WITHLFNAPI + /* FreeDOS LFN helper API functions */ + case 0x74: + { + switch(r->AL) + { + /* Allocate LFN inode */ + case 0x01: + { + r->AX = lfn_allocate_inode(); + break; + } + /* Free LFN inode */ + case 0x02: + { + r->AX = lfn_free_inode(r->BX); + break; + } + /* Setup LFN inode */ + case 0x03: + { + r->AX = lfn_setup_inode(r->BX, r->CX, r->DX); + break; + } + /* Create LFN entries */ + case 0x04: + { + r->AX = lfn_create_entries(r->BX, (lfn_inode_ptr)FP_DS_DX); + break; + } + /* Delete LFN entries */ + case 0x05: + { + r->AX = lfn_remove_entries(r->BX); + break; + } + /* Read next LFN */ + case 0x06: + { + r->AX = lfn_dir_read(r->BX, (lfn_inode_ptr)FP_DS_DX); + break; + } + /* Write SFN pointed by LFN inode */ + case 0x07: + { + r->AX = lfn_dir_write(r->BX); + break; + } + } + break; + } #endif } #ifdef DEBUG diff --git a/kernel/ioctl.c b/kernel/ioctl.c index eeca65d6..5f996413 100644 --- a/kernel/ioctl.c +++ b/kernel/ioctl.c @@ -35,6 +35,9 @@ static BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.13 2001/11/13 23:36:45 bartoldeman + * Kernel 2025a final changes. + * * Revision 1.12 2001/11/04 19:47:39 bartoldeman * kernel 2025a changes: see history.txt * @@ -265,7 +268,10 @@ COUNT DosDevIOctl(iregs FAR * r) execrh((request FAR *) & CharReqHdr, s->sft_dev); if (CharReqHdr.r_status & S_ERROR) + { + CritErrCode = (CharReqHdr.r_status & S_MASK) + 0x13; return DE_DEVICE; + } if (r->AL == 0x07) { @@ -316,6 +322,7 @@ COUNT DosDevIOctl(iregs FAR * r) if (CharReqHdr.r_status & S_ERROR) { + CritErrCode = (CharReqHdr.r_status & S_MASK) + 0x13; return DE_DEVICE; } if (r->AL == 0x08) @@ -407,7 +414,10 @@ COUNT DosDevIOctl(iregs FAR * r) dpbp->dpb_device); if (CharReqHdr.r_status & S_ERROR) + { + CritErrCode = (CharReqHdr.r_status & S_MASK) + 0x13; return DE_ACCESS; + } else { r->AL = CharReqHdr.r_unit; diff --git a/kernel/kernel.asm b/kernel/kernel.asm index c0cd5c3a..c0ebdffc 100644 --- a/kernel/kernel.asm +++ b/kernel/kernel.asm @@ -28,6 +28,9 @@ ; $Id$ ; ; $Log$ +; Revision 1.20 2001/11/13 23:36:45 bartoldeman +; Kernel 2025a final changes. +; ; Revision 1.19 2001/11/04 19:47:39 bartoldeman ; kernel 2025a changes: see history.txt ; @@ -183,6 +186,8 @@ configstart: DLASortByDriveNo db 0 ; sort disks by drive order InitDiskShowDriveAssignment db 1 ; SkipConfigSeconds db 2 ; +ForceLBA db 0 ; +GlobalEnableLBAsupport db 1 ; configend: diff --git a/kernel/lfnapi.c b/kernel/lfnapi.c index 22ea1406..b25b5f08 100644 --- a/kernel/lfnapi.c +++ b/kernel/lfnapi.c @@ -2,8 +2,8 @@ /* */ /* lfnapi.c */ /* */ -/* Directory access functions for LFN aid API */ -/* Module is under construction! */ +/* Directory access functions for LFN helper API */ +/* */ /****************************************************************/ #include "portab.h" @@ -13,24 +13,37 @@ static BYTE *lfnaidRcsId = "$Id$"; #endif -#if 0 -#define E_INVLDHNDL -1 -#define E_NOFREEHNDL -2 -#define E_IOERROR -3 -#define E_INVLDDRV -4 +#ifdef WITHLFNAPI + +#define LHE_INVLDHNDL -1 +#define LHE_NOFREEHNDL -2 +#define LHE_IOERROR -3 +#define LHE_INVLDDRV -4 +#define LHE_DAMAGEDFS -5 +#define LHE_NOSPACE -6 +#define LHE_SEEK -7 + +#define lfn(fnp) ((struct lfn_entry FAR *)&(fnp->f_dir)) +#define CHARS_IN_LFN_ENTRY 13 +#define UNICODE_FILLER 0xffff + +COUNT ufstrlen(REG UNICODE FAR *); /* fstrlen for UNICODE strings */ +UBYTE lfn_checksum(UBYTE *); +COUNT extend_dir(f_node_ptr); +COUNT remove_lfn_entries(f_node_ptr fnp); -COUNT lfn_allocate_inode() +COUNT lfn_allocate_inode(VOID) { f_node_ptr fnp = get_f_node(); struct cds FAR *cdsp; - if (fnp == 0) return E_NOFREEHNDL; + if (fnp == 0) return LHE_NOFREEHNDL; cdsp = &CDSp->cds_table[default_drive]; if (cdsp->cdsDpb == 0) { release_f_node(fnp); - return E_INVLDDRV; + return LHE_INVLDDRV; } fnp->f_dpb = cdsp->cdsDpb; @@ -38,110 +51,231 @@ COUNT lfn_allocate_inode() if (media_check(fnp->f_dpb) < 0) { release_f_node(fnp); - return E_INVLDDRV; + return LHE_INVLDDRV; } - fnp->f_dsize = DIRENT_SIZE * fnp->f_dpb->dpb_dirents; - return xlt_fnp(fnp); } COUNT lfn_free_inode(COUNT handle) { f_node_ptr fnp = xlt_fd(handle); - if (fnp == 0 || fnp->f_count <= 0) return E_INVLDHNDL; + if (fnp == 0 || fnp->f_count <= 0) return LHE_INVLDHNDL; release_f_node(fnp); + + return SUCCESS; +} + +COUNT lfn_setup_inode(COUNT handle, CLUSTER dirstart, ULONG diroff) +{ + f_node_ptr fnp = xlt_fd(handle); + if (fnp == 0 || fnp->f_count <= 0) return LHE_INVLDHNDL; + + dir_init_fnode(fnp, dirstart); + fnp->f_diroff = diroff; + + return SUCCESS; } -COUNT lfn_to_unicode_chunk(UNICODE FAR **nptr, UNICODE FAR **uptr, - UCOUNT *index, COUNT count) +BOOL transfer_unicode(UNICODE FAR **dptr, UNICODE FAR **sptr, COUNT count) { COUNT j; + BOOL found_zerro = FALSE; - for (j = 0; j < count; j++, *uptr++, *index++, *nptr++) + for (j = 0; j < count; j++, (*dptr)++, (*sptr)++) { - **nptr = **uptr; - if (**uptr == 0) return 0; + if (found_zerro) **dptr = UNICODE_FILLER; + else **dptr = **sptr; + if (**sptr == 0) found_zerro = TRUE; } - return 1; + return found_zerro; } -COUNT lfn_to_unicode(UNICODE FAR *name, UBYTE FAR *lfn_entry, UCOUNT *index) +BOOL lfn_to_unicode(UNICODE FAR **name, struct lfn_entry FAR *lep) { - COUNT j; - UNICODE FAR *uptr; - UNICODE FAR *nptr = name; + UNICODE FAR *ptr; + + ptr = lep->lfn_name0_4; + if (!transfer_unicode(name, &ptr, 5)) return FALSE; + ptr = lep->lfn_name5_10; + if (!transfer_unicode(name, &ptr, 6)) return FALSE; + ptr = lep->lfn_name11_12; + if (!transfer_unicode(name, &ptr, 2)) return FALSE; - uptr = (UNICODE FAR *)&lfn_entry[1]; - if (!lfn_to_unicode_chunk(&nptr, &uptr, index, 5)) return 0; - uptr = (UNICODE FAR *)&lfn_entry[0xe]; - if (!lfn_to_unicode_chunk(&nptr, &uptr, index, 6)) return 0; - uptr = (UNICODE FAR *)&lfn_entry[0x1c]; - if (!lfn_to_unicode_chunk(&nptr, &uptr, index, 2)) return 0; + return TRUE; +} - return 1; +VOID unicode_to_lfn(UNICODE FAR **name, struct lfn_entry FAR *lep) +{ + UNICODE FAR *ptr; + + ptr = lep->lfn_name0_4; + transfer_unicode(&ptr, name, 5); + ptr = lep->lfn_name5_10; + transfer_unicode(&ptr, name, 6); + ptr = lep->lfn_name11_12; + transfer_unicode(&ptr, name, 2); } COUNT lfn_dir_read(COUNT handle, lfn_inode_ptr lip) { - COUNT index = 0; /* index of the first non-filled char in the long file - name string */ - ULONG original_diroff; + COUNT rc; + UBYTE id = 1, real_id; + UNICODE FAR *lfn_name = lip->name; + ULONG sfn_diroff; + BOOL name_tail = FALSE; f_node_ptr fnp = xlt_fd(handle); - if (fnp == 0 || fnp->f_count <= 0) return E_INVLDHNDL; - - if (lfnp->l_dirstart == 0) - { - } - - original_diroff = fnp->f_diroff; - - lip->name[0] = 0; + if (fnp == 0 || fnp->f_count <= 0) return LHE_INVLDHNDL; while (TRUE) { - if (dir_read(fnp) <= 0) return E_IOERROR; - if (fnp->f_dir.dir_name[0] != DELETED && fnp->f_dir.dir_name[0] != '\0' - && fnp->f_dir.dir_attrib != D_LFN) + rc = dir_read(fnp); + if (rc == 0) return SUCCESS; + else if (rc == DE_SEEK) return LHE_SEEK; + else if (rc == DE_BLKINVLD) return LHE_IOERROR; + if (fnp->f_dir.dir_name[0] != DELETED && fnp->f_dir.dir_attrib != D_LFN) { - fmemcpy(lip->l_dir, fnp->f_dir, sizeof(struct dirent)); - lip->l_diroff = fnp->f_diroff; - lip->l_dirstart = fnp->f_dirstart; + fmemcpy(&lip->l_dir, &fnp->f_dir, sizeof(struct dirent)); + sfn_diroff = fnp->f_diroff; break; } - } - fnp->f_diroff = original_diroff - DIRENT_SIZE; + } + fnp->f_diroff = lip->l_diroff; + fmemset(lip->name, 0, 256 * sizeof(UNICODE)); while (TRUE) { if (fnp->f_diroff == 0) break; fnp->f_diroff -= 2*DIRENT_SIZE; - if (dir_read(fnp) <= 0) return E_IOERROR; - if (fnp->f_dir.dir_name[0] == '\0' - || fnp->f_dir.dir_name[0] == DELETED) break; - if (!lfn_to_unicode(lip->name, - (UBYTE FAR *)fnp->f_dir, index)) break; + rc = dir_read(fnp); + if (rc == DE_BLKINVLD) return LHE_IOERROR; + if (fnp->f_dir.dir_name[0] == DELETED + || fnp->f_dir.dir_attrib != D_LFN) break; + name_tail = lfn_to_unicode(&lfn_name, lfn(fnp)); + real_id = lfn(fnp)->lfn_id; + if (real_id & 0x40) + { + if ((real_id | 0x40) != id) return LHE_DAMAGEDFS; + } + else + { + if (name_tail || real_id != id + || lfn(fnp)->lfn_checksum != lfn_checksum(fnp->f_dir.dir_name)) + return LHE_DAMAGEDFS; + } } - if (lip->name[0] == 0) + fnp->f_diroff = lip->l_diroff = sfn_diroff; + fnp->f_flags.f_dnew = TRUE; + + return SUCCESS; +} + +COUNT lfn_dir_write(COUNT handle) +{ + f_node_ptr fnp = xlt_fd(handle); + if (fnp == 0 || fnp->f_count <= 0) return LHE_INVLDHNDL; + + if (!dir_write(fnp)) + { + lfn_allocate_inode(); /* protection against dir_write fault + * this must restore things to the state before + * the call */ + /* Yes, it's a hack! */ + return LHE_IOERROR; + } + + return SUCCESS; +} + +COUNT lfn_create_entries(COUNT handle, lfn_inode_ptr lip) +{ + f_node_ptr fnp = xlt_fd(handle); + COUNT entries_needed, free_entries, i, rc; + UNICODE FAR *lfn_name = lip->name; + ULONG sfn_offset; + if (fnp == 0 || fnp->f_count <= 0) return LHE_INVLDHNDL; + + entries_needed = (ufstrlen(lfn_name) + CHARS_IN_LFN_ENTRY - 1) + / CHARS_IN_LFN_ENTRY + 1; /* We want to create SFN entry too */ + + /* Scan the directory from the very begining for the free directory entries */ + lfn_setup_inode(handle, fnp->f_dirstart, 0); + + free_entries = 0; + while ((rc = dir_read(fnp)) == 1) { - ConvertName83ToNameSZ(lip->name, lip->l_dir.dir_name); + if (fnp->f_dir.dir_name[0] == DELETED) + { + free_entries++; + if (free_entries == entries_needed) + break; + } + else free_entries = 0; } + if (rc == DE_BLKINVLD) return LHE_IOERROR; + /* We have reached the end of the directory here. */ + + if (free_entries != entries_needed) free_entries = 0; + while (free_entries != entries_needed) + { + rc = dir_read(fnp); + if (rc == 0) free_entries++; + else if (rc == DE_BLKINVLD) return LHE_IOERROR; + else if (rc == DE_SEEK && extend_dir(fnp) != SUCCESS) + { + lfn_allocate_inode(); /* Another hack. */ + return LHE_IOERROR; + } + } + sfn_offset = fnp->f_diroff; + fnp->f_diroff -= DIRENT_SIZE; + + for (i = entries_needed - 2; i >= 0; i++) + { + lfn_name = &lip->name[i * CHARS_IN_LFN_ENTRY]; + unicode_to_lfn(&lfn_name, lfn(fnp)); + fnp->f_dir.dir_attrib = D_LFN; + if (!dir_write(fnp)) return LHE_IOERROR; + fnp->f_diroff -= DIRENT_SIZE; + } + + fnp->f_diroff = sfn_offset; return SUCCESS; } +COUNT lfn_remove_entries(COUNT handle) +{ + f_node_ptr fnp = xlt_fd(handle); + if (fnp == 0 || fnp->f_count <= 0) return LHE_INVLDHNDL; + + if(remove_lfn_entries(fnp) < 0) return LHE_IOERROR; + + return SUCCESS; +} + /* Calculate checksum for the 8.3 name */ -UBYTE lfn_checksum(char *name) +UBYTE lfn_checksum(UBYTE *sfn_name) { UBYTE sum; COUNT i; - for (sum = 0, i = 11; --i >= 0; sum += *name++) + for (sum = 0, i = 11; --i >= 0; sum += *sfn_name++) sum = (sum << 7) | (sum >> 1); return sum; } + +COUNT ufstrlen(REG UNICODE FAR *s) +{ + REG COUNT cnt = 0; + + while (*s++ != 0) + ++cnt; + return cnt; +} + #endif diff --git a/kernel/main.c b/kernel/main.c index 07c41c9c..bdf6cc3e 100644 --- a/kernel/main.c +++ b/kernel/main.c @@ -79,11 +79,14 @@ extern BYTE FAR _HMATextEnd[]; static BYTE *mainRcsId = "$Id$"; #endif -struct _KernelConfig InitKernelConfig = {0}; +struct _KernelConfig InitKernelConfig = {"", 0, 0, 0, 0, 0, 0}; /* * $Log$ + * Revision 1.23 2001/11/13 23:36:45 bartoldeman + * Kernel 2025a final changes. + * * Revision 1.22 2001/11/04 19:47:39 bartoldeman * kernel 2025a changes: see history.txt * diff --git a/kernel/makefile b/kernel/makefile index 5ad94d24..c09fa406 100644 --- a/kernel/makefile +++ b/kernel/makefile @@ -5,6 +5,9 @@ # # $Log$ +# Revision 1.2 2001/11/13 23:36:45 bartoldeman +# Kernel 2025a final changes. +# # Revision 1.1 2001/11/04 20:10:15 bartoldeman # Added new makefile names, utils sources, kconfig.h # @@ -137,31 +140,13 @@ # $EndLog$ # -!include "..\config.mak" +!include "..\mkfiles\generic.mak" RELEASE = 1.00 -# Compiler and Options for Borland C++ -# ------------------------------------ -# -# -zAname ¦ ¦ Code class -# -zBname ¦ ¦ BSS class -# -zCname ¦ ¦ Code segment -# -zDname ¦ ¦ BSS segment -# -zEname ¦ ¦ Far segment -# -zFname ¦ ¦ Far class -# -zGname ¦ ¦ BSS group -# -zHname ¦ ¦ Far group -# -zPname ¦ ¦ Code group -# -zRname ¦ ¦ Data segment -# -zSname ¦ ¦ Data group -# -zTname ¦ ¦ Data class -# -zX ¦«¦ Use default name for "X" - - # Compiler and Options -INCLUDE=$(COMPILERBASE)\include +INCLUDE=..\hdr LIB= $(COMPILERBASE)\lib LIBPATH = . @@ -212,6 +197,7 @@ EXE_dependencies = \ ioctl.obj \ irqstack.obj \ kernel.obj \ + lfnapi.obj \ main.obj \ memmgr.obj \ misc.obj \ @@ -244,18 +230,18 @@ production: ..\bin\kernel.sys copy kernel.map ..\bin\$(THETARGET).map kernel.sys: kernel.exe ..\utils\exeflat.exe - ..\utils\exeflat kernel.exe kernel.sys 0x60 + ..\utils\exeflat kernel.exe kernel.sys 0x60 -S0x10 -S0x8B clobber: clean - $(RM) kernel.exe kernel.sys status.me + -$(RM) kernel.exe kernel.sys status.me clean: - $(RM) *.obj *.bak *.crf *.xrf *.map *.lst *.cod + -$(RM) *.obj *.bak *.crf *.xrf *.map *.lst *.cod # XXX: This is a very ugly way of linking the kernel, forced upon us by the # inability of Turbo `make' 2.0 to perform command line redirection. -- ror4 kernel.exe: $(EXE_dependencies) $(LIBS) - $(RM) kernel.lib + -$(RM) kernel.lib $(LIBUTIL) kernel.lib $(LIBPLUS)entry.obj $(LIBPLUS)io.obj $(LIBPLUS)blockio.obj $(LIBPLUS)chario.obj $(LIBPLUS)dosfns.obj $(LIBPLUS)console.obj$(LIBTERM) $(LIBUTIL) kernel.lib $(LIBPLUS)printer.obj $(LIBPLUS)serial.obj $(LIBPLUS)dsk.obj $(LIBPLUS)initdisk.obj $(LIBPLUS)error.obj $(LIBPLUS)fatdir.obj $(LIBPLUS)fatfs.obj$(LIBTERM) $(LIBUTIL) kernel.lib $(LIBPLUS)fattab.obj $(LIBPLUS)fcbfns.obj $(LIBPLUS)initoem.obj $(LIBPLUS)initHMA.obj $(LIBPLUS)inthndlr.obj $(LIBPLUS)ioctl.obj $(LIBPLUS)nls_hc.obj$(LIBTERM) @@ -264,9 +250,9 @@ kernel.exe: $(EXE_dependencies) $(LIBS) $(LIBUTIL) kernel.lib $(LIBPLUS)systime.obj $(LIBPLUS)task.obj $(LIBPLUS)int2f.obj $(LIBPLUS)irqstack.obj $(LIBPLUS)apisupt.obj$(LIBTERM) $(LIBUTIL) kernel.lib $(LIBPLUS)asmsupt.obj $(LIBPLUS)execrh.obj $(LIBPLUS)nlssupt.obj $(LIBPLUS)procsupt.obj $(LIBPLUS)break.obj$(LIBTERM) $(LIBUTIL) kernel.lib $(LIBPLUS)dosidle.obj $(LIBPLUS)dyndata.obj $(LIBPLUS)dyninit.obj $(LIBPLUS)rtlsupt.obj $(LIBTERM) - $(RM) kernel.bak - $(LINK) kernel iprf,kernel,kernel,kernel+$(LIBS)$(LINKTERM) - $(RM) kernel.lib + -$(RM) kernel.bak + $(LINK) kernel iprf,kernel,kernel,kernel+$(LIBS); + -$(RM) kernel.lib # *Individual File Dependencies* kernel.obj: kernel.asm segs.inc @@ -306,7 +292,7 @@ dosidle.obj: dosidle.asm segs.inc INITHEADERS=init-mod.h init-dat.h -CONFIGURATION = turboc.cfg makefile ..\config.mak ..\mkfiles\$(COMPILER).MAK +CONFIGURATION = turboc.cfg makefile ..\mkfiles\generic.mak ..\mkfiles\$(COMPILER).MAK HEADERS=\ $(HDR)portab.h $(HDR)device.h $(HDR)mcb.h $(HDR)pcb.h \ @@ -348,6 +334,8 @@ memmgr.obj: memmgr.c $(HEADERS) $(CONFIGURATION) misc.obj: misc.c $(HEADERS) $(CONFIGURATION) +lfnapi.obj: lfnapi.c $(HEADERS) $(CONFIGURATION) + newstuff.obj: newstuff.c $(HEADERS) $(CONFIGURATION) network.obj: network.c $(HEADERS) $(CONFIGURATION) @@ -399,23 +387,16 @@ initdisk.obj: initdisk.c $(INITHEADERS) $(HEADERS) $(CONFIGURATION) $(CC) $(INITCFLAGS) -c $*.c $(PATCHOBJ) $*.obj $(INITPATCH) +#the printf for INIT_TEXT - yet another special case, this file includes prf.c +iprf.obj: iprf.c prf.c $(HDR)\portab.h $(CONFIGURATION) + $(CC) $(INITCFLAGS) -c $*.c + $(PATCHOBJ) $*.obj $(INITPATCH) -# $(CC) $(CFLAGS) -c $*.c -# patchobj $*.obj _DATA=DYN_DATA DATA=DYN_DATA CODE=HMA CONST=DCONST - +#dynamic NEAR data dyndata.obj: dyndata.c dyndata.h $(CC) $(DYNCFLAGS) -c $*.c $(PATCHOBJ) $*.obj $(DYNPATCH) -#the printf for INIT_TEXT - yet another special case -# $(CC) -D_INIT $(INITCFLAGS) -Foiprf.obj -c prf.c -# patchobj Iprf.obj $(INITPATCH) - -iprf.obj: prf.c $(HDR)\portab.h $(CONFIGURATION) - $(CC) -D_INIT $(IPRFCFLAGS) -c prf.c - $(PATCHOBJ) iprf.obj $(INITPATCH) - - diff --git a/kernel/newstuff.c b/kernel/newstuff.c index 00a31c43..aeb9ac4d 100644 --- a/kernel/newstuff.c +++ b/kernel/newstuff.c @@ -31,6 +31,9 @@ static BYTE *mainRcsId = "$Id$"; /* * $Log$ + * Revision 1.15 2001/11/13 23:36:45 bartoldeman + * Kernel 2025a final changes. + * * Revision 1.14 2001/09/23 20:39:44 bartoldeman * FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling * @@ -529,7 +532,7 @@ COUNT ASMCFUNC truename(char FAR * src, char FAR * dest, COUNT t) break; } if (c == '.') { - *(bufp++) = '.'; + if (src[i+1] != '.' && i+1 < seglen) *(bufp++) = '.'; copylen = 0; state = 2; /* Copy extension next */ break; @@ -543,7 +546,7 @@ COUNT ASMCFUNC truename(char FAR * src, char FAR * dest, COUNT t) } break; case 1: /* Looking for dot so we can copy exten */ - if (src[i] == '.') { + if (src[i] == '.' && src[i+1] != '.' && i+1 < seglen) { *(bufp++) = '.'; state = 2; } diff --git a/kernel/proto.h b/kernel/proto.h index 0fe04b5f..db393b71 100644 --- a/kernel/proto.h +++ b/kernel/proto.h @@ -34,6 +34,9 @@ static BYTE *Proto_hRcsId = "$Id$"; /* * $Log$ + * Revision 1.24 2001/11/13 23:36:45 bartoldeman + * Kernel 2025a final changes. + * * Revision 1.23 2001/11/04 19:47:39 bartoldeman * kernel 2025a changes: see history.txt * @@ -250,7 +253,7 @@ COUNT DosOpen(BYTE FAR * fname, COUNT mode); COUNT DosOpenSft(BYTE * fname, COUNT mode); COUNT DosClose(COUNT hndl); COUNT DosCloseSft(WORD sft_idx); -VOID DosGetFree(UBYTE drive, COUNT FAR * spc, COUNT FAR * navc, COUNT FAR * bps, COUNT FAR * nc); +BOOL DosGetFree(UBYTE drive, UCOUNT FAR * spc, UCOUNT FAR * navc, UCOUNT FAR * bps, UCOUNT FAR * nc); COUNT DosGetExtFree(BYTE FAR *DriveString, struct xfreespace FAR *xfsp); COUNT DosGetCuDir(UBYTE drive, BYTE FAR * s); COUNT DosChangeDir(BYTE FAR * s); @@ -369,7 +372,7 @@ int DosCharInput(VOID); VOID DosDirectConsoleIO(iregs FAR * r); VOID DosCharOutput(COUNT c); VOID DosDisplayOutput(COUNT c); -VOID FatGetDrvData(UCOUNT drive, COUNT FAR * spc, COUNT FAR * bps, COUNT FAR * nc, BYTE FAR ** mdp); +VOID FatGetDrvData(UCOUNT drive, UCOUNT FAR * spc, UCOUNT FAR * bps, UCOUNT FAR * nc, BYTE FAR ** mdp); WORD FcbParseFname(int wTestMode, BYTE FAR ** lpFileName, fcb FAR * lpFcb); BYTE FAR *ParseSkipWh(BYTE FAR * lpFileName); BOOL TestCmnSeps(BYTE FAR * lpFileName); @@ -439,6 +442,17 @@ void ASMCFUNC memcpy(REG void * d, REG VOID * s, REG COUNT n); void ASMCFUNC fmemset(REG VOID FAR * s, REG int ch, REG COUNT n); void ASMCFUNC memset(REG VOID * s, REG int ch, REG COUNT n); +/* lfnapi.c */ +COUNT lfn_allocate_inode(VOID); +COUNT lfn_free_inode(COUNT handle); + +COUNT lfn_setup_inode(COUNT handle, CLUSTER dirstart, ULONG diroff); + +COUNT lfn_create_entries(COUNT handle, lfn_inode_ptr lip); +COUNT lfn_remove_entries(COUNT handle); + +COUNT lfn_dir_read(COUNT handle, lfn_inode_ptr lip); +COUNT lfn_dir_write(COUNT handle); /* nls.c */ BYTE DosYesNo(unsigned char ch); diff --git a/lib/makefile b/lib/makefile index 50858a80..012d12c3 100644 --- a/lib/makefile +++ b/lib/makefile @@ -5,6 +5,9 @@ # # $Log$ +# Revision 1.2 2001/11/13 23:36:45 bartoldeman +# Kernel 2025a final changes. +# # Revision 1.1 2001/11/04 20:10:15 bartoldeman # Added new makefile names, utils sources, kconfig.h # @@ -40,18 +43,18 @@ # Improved by jprice # -!include "..\config.mak" +!include "..\mkfiles\generic.mak" -libm.lib: $(CLIB) ..\config.mak - $(RM) libm.lib +libm.lib: $(CLIB) + -$(RM) libm.lib $(LIBUTIL) $(CLIB) $(MATH_EXTRACT) $(LIBTERM) $(LIBUTIL) libm $(MATH_INSERT) $(LIBTERM) - $(RM) *.OBJ + -$(RM) *.OBJ clobber: clean - $(RM) libm.lib status.me + -$(RM) libm.lib status.me clean: - $(RM) *.obj *.bak + -$(RM) *.obj *.bak diff --git a/mkfiles/bc5.mak b/mkfiles/bc5.mak index 6c3393d2..13a3c8a9 100644 --- a/mkfiles/bc5.mak +++ b/mkfiles/bc5.mak @@ -6,15 +6,16 @@ COMPILERPATH=$(BC5_BASE) COMPILERBIN=$(COMPILERPATH)\bin -CC=$(COMPILERBIN)\tcc -CFLAGST=-mt -lt -a- -k- -f- -ff- -O -Z -d -CFLAGSC=-a- -mc +CC=$(COMPILERBIN)\bcc INCLUDEPATH=$(COMPILERPATH)\include LIBUTIL=$(COMPILERBIN)\tlib LIBPATH=$(COMPILERPATH)\lib LIBTERM= LIBPLUS=+ +CFLAGST=-L$(LIBPATH) -mt -lt -a- -k- -f- -ff- -O -Z -d +CFLAGSC=-L$(LIBPATH) -a- -mc + TARGET=KBC # used for building the library @@ -45,9 +46,7 @@ MATH_INSERT=+H_LDIV +H_LLSH +H_LURSH +N_LXMUL +F_LXMUL +H_LRSH # # ALLCFLAGS specified by turbo.cfg and config.mak # -ALLCFLAGS = $(TARGETOPT) $(ALLCFLAGS) -INITCFLAGS = $(ALLCFLAGS) -zAINIT -zCINIT_TEXT -zDIB -zRID -zTID -zPIGROUP -zBIB -zGIGROUP -zSIGROUP -CFLAGS = $(ALLCFLAGS) -zAHMA -zCHMA_TEXT -DYNCFLAGS = $(ALLCFLAGS) -zRDYN_DATA -zTDYN_DATA -zDDYN_DATA -zBDYN_DATA -IPRFCFLAGS = $(INITCFLAGS) -oiprf.obj - +ALLCFLAGS=$(TARGETOPT) $(ALLCFLAGS) +INITCFLAGS=$(ALLCFLAGS) -zAINIT -zCINIT_TEXT -zDIB -zRID -zTID -zPIGROUP -zBIB -zGIGROUP -zSIGROUP +CFLAGS=$(ALLCFLAGS) -zAHMA -zCHMA_TEXT +DYNCFLAGS=$(ALLCFLAGS) -zRDYN_DATA -zTDYN_DATA -zDDYN_DATA -zBDYN_DATA diff --git a/mkfiles/generic.mak b/mkfiles/generic.mak index 2e01e3a0..486e70a9 100644 --- a/mkfiles/generic.mak +++ b/mkfiles/generic.mak @@ -1,3 +1,5 @@ +# These are generic definitions + #********************************************************************** #* TARGET : we create a %TARGET%.sys file #* TARGETOPT : options, handled down to the compiler @@ -5,27 +7,26 @@ TARGETOPT=-1- -!if $(XCPU)+1 != 1 !if $(XCPU) == 186 TARGETOPT=-1 !endif !if $(XCPU) == 386 TARGETOPT=-3 !endif -!endif -!if $(XFAT)+1 != 1 !if $(XFAT) == 32 ALLCFLAGS=$(ALLCFLAGS) -DWITHFAT32 !endif -!endif +NASM=$(XNASM) !if $(XCPU) == 386 NASMFLAGS = $(NASMFLAGS) -i../hdr/ -DI386 !else NASMFLAGS = $(NASMFLAGS) -i../hdr/ !endif +LINK=$(XLINK) + PATCHOBJ=@rem INITPATCH = CODE=INIT _DATA=IDATA DATA=ID BSS=ID DGROUP=IGROUP CONST=IC STDPATCH = CODE=HMA CONST=DCONST @@ -34,8 +35,7 @@ DYNPATCH = _DATA=DYN_DATA DATA=DYN_DATA CODE=HMA CONST=DCONST !include "..\mkfiles\$(COMPILER).mak" THETARGET=$(TARGET)$(XCPU)$(XFAT) -# These are generic definitions -RM=-del +RM=..\utils\rmfiles .asm.obj : $(NASM) $(NASMFLAGS) -f obj $*.asm diff --git a/mkfiles/mscl8.mak b/mkfiles/mscl8.mak index 64498c26..756d1b25 100644 --- a/mkfiles/mscl8.mak +++ b/mkfiles/mscl8.mak @@ -7,13 +7,16 @@ COMPILERPATH=$(MS_BASE) COMPILERBIN=$(COMPILERPATH)\bin INCLUDEPATH=$(COMPILERPATH)\include CC=$(COMPILERBIN)\cl -CFLAGST = /Fm /AS /Os ???? -CFLAGSC=-a- -mc ???? -LIBUTIL=$(COMPILERBIN)\lib /nologo +CFLAGST=/Fm /AT /Os +CFLAGSC=/Fm /AL /Os LIBPATH=$(COMPILERPATH)\lib +LIB=$(COMPILERPATH)\lib +INCLUDE=$(COMPILERPATH)\include LIBUTIL=$(COMPILERBIN)\lib /nologo +LIBPLUS=+ LIBTERM=; - +INCLUDE=$(COMPILERPATH)\include +LIB=$(COMPILERPATH)\lib # used for building the library @@ -21,12 +24,13 @@ CLIB=$(COMPILERPATH)\lib\slibce.lib MATH_EXTRACT=*aflmul *aFlshl *aFNauldi *aFulrem *aFulshr *aFuldiv *aFlrem *aFldiv MATH_INSERT= +aflmul +aFlshl +aFNauldi +aFulrem +aFulshr +aFuldiv +aFlrem +aFldiv +TARGETOPT= !if $(XCPU) == 186 TARGETOPT=-G1 -!end +!endif !if $(XCPU) == 386 TARGETOPT=-G3 -!end +!endif TARGET=KMS @@ -34,9 +38,8 @@ TARGET=KMS # heavy stuff - building -ALLCFLAGS = -I..\hdr $(TARGETOPT) $(ALLCFLAGS) -nologo -c -Zl -Fc -Zp1 -Gs -Os -WX -INITCFLAGS = $(ALLCFLAGS) -NTINIT_TEXT -AT -CFLAGS = $(ALLCFLAGS) -NTHMA_TEXT -DYNCFLAGS = $(ALLCFLAGS) -NTHMA_TEXT -IPRFCFLAGS = $(INITCFLAGS) -Foiprf.obj -PATCHOBJ = patchobj +ALLCFLAGS=-I..\hdr $(TARGETOPT) $(ALLCFLAGS) -nologo -Zl -Fc -Zp1 -Gs -Os -WX +INITCFLAGS=$(ALLCFLAGS) -NTINIT_TEXT -AT +CFLAGS=$(ALLCFLAGS) -NTHMA_TEXT +DYNCFLAGS=$(ALLCFLAGS) -NTHMA_TEXT +PATCHOBJ=patchobj diff --git a/mkfiles/tc2.mak b/mkfiles/tc2.mak index 1a938ab4..290d97b4 100644 --- a/mkfiles/tc2.mak +++ b/mkfiles/tc2.mak @@ -7,14 +7,15 @@ COMPILERPATH=$(TC2_BASE) COMPILERBIN=$(COMPILERPATH) CC=$(COMPILERBIN)\tcc -CFLAGST=-mt -lt -a- -k- -f- -ff- -O -Z -d -CFLAGSC=-a- -mc INCLUDEPATH=$(COMPILERPATH)\include LIBUTIL=$(COMPILERBIN)\tlib LIBPATH=$(COMPILERPATH)\lib LIBTERM= LIBPLUS=+ +CFLAGST=-L$(LIBPATH) -mt -lt -a- -k- -f- -ff- -O -Z -d +CFLAGSC=-L$(LIBPATH) -a- -mc + TARGET=KTC # used for building the library @@ -45,12 +46,7 @@ MATH_INSERT=+LDIV +LXMUL +LURSH +LLSH +LRSH # # ALLCFLAGS specified by turbo.cfg and config.mak # -ALLCFLAGS = $(TARGETOPT) $(ALLCFLAGS) -INITCFLAGS = $(ALLCFLAGS) -zAINIT -zCINIT_TEXT -zDIB -zRID -zTID -zPIGROUP -zBIB -zGIGROUP -zSIGROUP -CFLAGS = $(ALLCFLAGS) -zAHMA -zCHMA_TEXT -DYNCFLAGS = $(ALLCFLAGS) -zRDYN_DATA -zTDYN_DATA -zDDYN_DATA -zBDYN_DATA -IPRFCFLAGS = $(INITCFLAGS) -oiprf.obj - - - - +ALLCFLAGS=$(TARGETOPT) $(ALLCFLAGS) +INITCFLAGS=$(ALLCFLAGS) -zAINIT -zCINIT_TEXT -zDIB -zRID -zTID -zPIGROUP -zBIB -zGIGROUP -zSIGROUP +CFLAGS=$(ALLCFLAGS) -zAHMA -zCHMA_TEXT +DYNCFLAGS=$(ALLCFLAGS) -zRDYN_DATA -zTDYN_DATA -zDDYN_DATA -zBDYN_DATA diff --git a/mkfiles/tc3.mak b/mkfiles/tc3.mak index 2740121f..18c1850f 100644 --- a/mkfiles/tc3.mak +++ b/mkfiles/tc3.mak @@ -7,14 +7,15 @@ COMPILERPATH=$(TC3_BASE) COMPILERBIN=$(COMPILERPATH)\bin CC=$(COMPILERBIN)\tcc -CFLAGST=-mt -lt -a- -k- -f- -ff- -O -Z -d -CFLAGSC=-a- -mc INCLUDEPATH=$(COMPILERPATH)\include LIBUTIL=$(COMPILERBIN)\tlib LIBPATH=$(COMPILERPATH)\lib LIBTERM= LIBPLUS=+ +CFLAGST=-L$(LIBPATH) -mt -lt -a- -k- -f- -ff- -O -Z -d +CFLAGSC=-L$(LIBPATH) -a- -mc + TARGET=KT3 # used for building the library @@ -45,9 +46,7 @@ MATH_INSERT=+H_LDIV +H_LLSH +H_LURSH +N_LXMUL +F_LXMUL +H_LRSH # # ALLCFLAGS specified by turbo.cfg and config.mak # -ALLCFLAGS = $(TARGETOPT) $(ALLCFLAGS) -INITCFLAGS = $(ALLCFLAGS) -zAINIT -zCINIT_TEXT -zDIB -zRID -zTID -zPIGROUP -zBIB -zGIGROUP -zSIGROUP -CFLAGS = $(ALLCFLAGS) -zAHMA -zCHMA_TEXT -DYNCFLAGS = $(ALLCFLAGS) -zRDYN_DATA -zTDYN_DATA -zDDYN_DATA -zBDYN_DATA -IPRFCFLAGS = $(INITCFLAGS) -oiprf.obj - +ALLCFLAGS=$(TARGETOPT) $(ALLCFLAGS) +INITCFLAGS=$(ALLCFLAGS) -zAINIT -zCINIT_TEXT -zDIB -zRID -zTID -zPIGROUP -zBIB -zGIGROUP -zSIGROUP +CFLAGS=$(ALLCFLAGS) -zAHMA -zCHMA_TEXT +DYNCFLAGS=$(ALLCFLAGS) -zRDYN_DATA -zTDYN_DATA -zDDYN_DATA -zBDYN_DATA diff --git a/mkfiles/turbocpp.mak b/mkfiles/turbocpp.mak index a6c45b70..7187111e 100644 --- a/mkfiles/turbocpp.mak +++ b/mkfiles/turbocpp.mak @@ -7,14 +7,15 @@ COMPILERPATH=$(TP1_BASE) COMPILERBIN=$(COMPILERPATH)\bin CC=$(COMPILERBIN)\tcc -CFLAGST=-mt -lt -a- -k- -f- -ff- -O -Z -d -CFLAGSC=-a- -mc INCLUDEPATH=$(COMPILERPATH)\include LIBUTIL=$(COMPILERBIN)\tlib LIBPATH=$(COMPILERPATH)\lib LIBTERM= LIBPLUS=+ +CFLAGST=-L$(LIBPATH) -mt -lt -a- -k- -f- -ff- -O -Z -d +CFLAGSC=-L$(LIBPATH) -a- -mc + TARGET=KTP # used for building the library @@ -45,8 +46,7 @@ MATH_INSERT=+H_LDIV +F_LXMUL +H_LURSH +H_LLSH +H_LRSH # # ALLCFLAGS specified by turbo.cfg and config.mak # -ALLCFLAGS = $(TARGETOPT) $(ALLCFLAGS) -INITCFLAGS = $(ALLCFLAGS) -zAINIT -zCINIT_TEXT -zDIB -zRID -zTID -zPIGROUP -zBIB -zGIGROUP -zSIGROUP -CFLAGS = $(ALLCFLAGS) -zAHMA -zCHMA_TEXT -DYNCFLAGS = $(ALLCFLAGS) -zRDYN_DATA -zTDYN_DATA -zDDYN_DATA -zBDYN_DATA -IPRFCFLAGS = $(INITCFLAGS) -oiprf.obj +ALLCFLAGS=$(TARGETOPT) $(ALLCFLAGS) +INITCFLAGS=$(ALLCFLAGS) -zAINIT -zCINIT_TEXT -zDIB -zRID -zTID -zPIGROUP -zBIB -zGIGROUP -zSIGROUP +CFLAGS=$(ALLCFLAGS) -zAHMA -zCHMA_TEXT +DYNCFLAGS=$(ALLCFLAGS) -zRDYN_DATA -zTDYN_DATA -zDDYN_DATA -zBDYN_DATA diff --git a/mkfiles/watcom.mak b/mkfiles/watcom.mak index 5b5dca6b..ac61955b 100644 --- a/mkfiles/watcom.mak +++ b/mkfiles/watcom.mak @@ -1,16 +1,12 @@ # -# WATCOM.MAK - kernel copiler options for MS CL8 = MSVC1.52 +# WATCOM.MAK - kernel copiler options for WATCOM C 11.0c # # Use these for WATCOM 11.0c -COMPILERPATH=$(WC_BASE) -COMPILERBIN=$(WC_BASE)\binw +COMPILERPATH=$(WATCOM) +COMPILERBIN=$(WATCOM)\binw CC=$(COMPILERBIN)\wcl -CFLAGST=-mt -CFLAGSC=-mc INCLUDEPATH=$(COMPILERPATH)\H -WATCOM=$(COMPILERPATH) -PATH=$(COMPILERPATH)\binnt;$(COMPILERPATH)\binw INCLUDE=$(COMPILERPATH)\h EDPATH=$(COMPILERPATH)\EDDAT @@ -20,15 +16,16 @@ TARGETOPT=-0 !endif !endif -TARGET=KWC - -LINKTERM=; - -LIBPATH=$(COMPILERPATH)\lib +LIBPATH=$(COMPILERPATH)\lib286 LIBUTIL=$(COMPILERBIN)\wlib LIBPLUS= LIBTERM= +CFLAGST=-mt +CFLAGSC=-zp=1 -mc + +TARGET=KWC + # used for building the library CLIB=$(COMPILERPATH)\lib286\dos\clibs.lib @@ -72,9 +69,8 @@ MATH_INSERT= +i4d +i4m # -3 optimization for 386 - given in CONFIG.MAK, not here # -ALLCFLAGS = $(TARGETOPT) $(ALLCFLAGS) -c -zq -os -ms -s -e=5 -j -zl -zp=1 -INITCFLAGS = $(ALLCFLAGS) -nt=INIT_TEXT -nc=INIT -g=IGROUP -CFLAGS = $(ALLCFLAGS) -nt=HMA_TEXT -nc=HMA -g=HGROUP -DYNCFLAGS = $(ALLCFLAGS) -IPRFCFLAGS = $(INITCFLAGS) -Foiprf.obj +ALLCFLAGS=-I..\hdr $(TARGETOPT) $(ALLCFLAGS) -zq -os -ms -s -e=5 -j -zl -zp=1 +INITCFLAGS=$(ALLCFLAGS) -nt=INIT_TEXT -nc=INIT -g=IGROUP +CFLAGS=$(ALLCFLAGS) -nt=HMA_TEXT -nc=HMA -g=HGROUP +DYNCFLAGS=$(ALLCFLAGS) diff --git a/sys/fdkrncfg.c b/sys/fdkrncfg.c index a68d5e59..d1dd706c 100644 --- a/sys/fdkrncfg.c +++ b/sys/fdkrncfg.c @@ -34,8 +34,11 @@ KernelConfig cfg = {0}; typedef unsigned char byte; +typedef signed char sbyte; typedef unsigned short word; +typedef signed short sword; typedef unsigned long dword; +typedef signed long sdword; /* These structures need to be byte packed, if your compiler @@ -48,8 +51,6 @@ typedef unsigned long dword; /* Displays command line syntax */ void showUsage(void) { - - printf("FreeDOS Kernel Configuration %s\n", VERSION); printf("Usage: \n" " %s \n" " %s [/help | /?]\n" @@ -57,15 +58,17 @@ void showUsage(void) PROGRAM, PROGRAM, PROGRAM, KERNEL); printf("\n"); printf(" If no options are given, the current values are shown.\n"); - printf(" %/help or ? displays this usage information.\n" + printf(" /help or /? displays this usage information.\n" " [drive:][path]KERNEL.SYS specifies the kernel file to\n" - " modify, if not given defaults to \\%s\n", + " modify, if not given defaults to %s\n", KERNEL); printf("\n"); printf(" option=value ... specifies one or more options and the values\n" " to set each to. If an option is given multiple times,\n" " the value set will be the rightmost one.\n"); - printf(" Current Options are: DLASORT=0|1, SHOWDRIVEASSIGNMENT=0|1\n"); + printf(" Current Options are: DLASORT=0|1, SHOWDRIVEASSIGNMENT=0|1\n" + " SKIPCONFIGSECONDS=#, FORCELBA=0|1\n" + " GLOBALENABLELBASUPPORT=0|1\n"); } @@ -152,10 +155,22 @@ void displayConfigSettings(KernelConfig *cfg) if (cfg->ConfigSize >= 3) { - printf("SKIPCONFIGSECONDS=%-2d time to wait for F5/F8 : *2 sec\n", + printf("SKIPCONFIGSECONDS=%-3d time to wait for F5/F8 : *2 sec (skip < 0)\n", cfg->SkipConfigSeconds); } + if (cfg->ConfigSize >= 4) + { + printf("FORCELBA=0x%02X Always use LBA if possible: *0=no, 1=yes\n", + cfg->ForceLBA); + } + + if (cfg->ConfigSize >= 5) + { + printf("GLOBALENABLELBASUPPORT=0x%02X Enable LBA support: *1=yes, 0=no\n", + cfg->GlobalEnableLBAsupport); + } + #if 0 /* we assume that SYS is as current as the kernel */ /* Print value any options added that are unknown as hex dump */ @@ -177,16 +192,32 @@ void displayConfigSettings(KernelConfig *cfg) +/* Note: The setXXXOption functions will set the config option of + type XXX to the value given. It will display a warning, but + allow probably invalid values to be used (cause I believe in + letting the user do what they want, not what we guess they mean). + Additionally, we only indicate a change if a new value is used, + to force changes written even if same value is used, use same + option twice, first with a different value & second time with + (same) value desired. kjd +*/ -/* Sets the given location to a byte value if different, +/* Sets the given location to an unsigned byte value if different, displays warning if values exceeds max */ void setByteOption(byte *option, char *value, word max, int *updated, char *name) { - int optionValue; + unsigned long optionValue; - optionValue = atoi(value); - if (optionValue > max) + /* optionValue = atoi(value); Use strtoul instead of atoi/atol as it detect base (0xFF & 255) */ + optionValue = strtoul(value, NULL, 0); + + if (optionValue > 255) + { + printf("Warning: Option %s: Value <0x%02lX> will be truncated!\n", + name, optionValue); + } + if ((byte)optionValue > max) { printf("Warning: Option %s: Value <0x%02X> may be invalid!\n", name, (unsigned int)((byte)optionValue)); @@ -199,6 +230,93 @@ void setByteOption(byte *option, char *value, word max, int *updated, char *name } } +/* Sets the given location to a signed byte value if different, + displays warning if values exceeds max or is less than min +*/ +void setSByteOption(sbyte *option, char *value, sword min, sword max, int *updated, char *name) +{ + signed long optionValue; + + /* optionValue = atoi(value); Use strtol instead of atoi/atol as it detects base */ + optionValue = strtol(value, NULL, 0); + + if ( (optionValue < -128) || (optionValue > 127) ) + { + printf("Warning: Option %s: Value <0x%02lX> will be truncated!\n", + name, optionValue); + } + if ( ((sbyte)optionValue > max) || ((sbyte)optionValue < min) ) + { + printf("Warning: Option %s: Value <0x%02X> may be invalid!\n", + name, (signed int)((byte)optionValue)); + } + /* Don't bother updating if same value */ + if ((sbyte)optionValue != *option) + { + *option = (sbyte)optionValue; + *updated = 1; + } +} + +#if 0 /* disable until there are (un)signed word configuration values */ +/* Sets the given location to an unsigned word value if different, + displays warning if values exceeds max +*/ +void setWordOption(word *option, char *value, dword max, int *updated, char *name) +{ + unsigned long optionValue; + + /* optionValue = atol(value); Use strtoul instead of atoi/atol as it allows 0xFF and 255 */ + optionValue = strtoul(value, NULL, 0); + + if (optionValue > 65535) + { + printf("Warning: Option %s: Value <0x%02lX> will be truncated!\n", + name, optionValue); + } + if ((word)optionValue > max) + { + printf("Warning: Option %s: Value <0x%02X> may be invalid!\n", + name, (unsigned int)optionValue); + } + /* Don't bother updating if same value */ + if ((word)optionValue != *option) + { + *option = (word)optionValue; + *updated = 1; + } +} + +/* Sets the given location to a signed byte value if different, + displays warning if values exceeds max or is less than min +*/ +void setSWordOption(sword *option, char *value, sdword min, sdword max, int *updated, char *name) +{ + signed long optionValue; + + /* optionValue = atol(value); Use strtol instead of atoi/atol as it allows 0xFF and 255 */ + optionValue = strtol(value, NULL, 0); + + if ( (optionValue < -32768) || (optionValue > 32767) ) + { + printf("Warning: Option %s: Value <0x%02lX> will be truncated!\n", + name, optionValue); + } + + if ( ((sword)optionValue > max) || ((sword)optionValue < min) ) + { + printf("Warning: Option %s: Value <0x%02X> may be invalid!\n", + name, (signed int)optionValue); + } + /* Don't bother updating if same value */ + if ((sword)optionValue != *option) + { + *option = (sword)optionValue; + *updated = 1; + } +} +#endif + /* Main, processes command line options and calls above functions as required. @@ -212,7 +330,7 @@ int FDKrnConfigMain(int argc,char **argv) char *cptr; char *argptr; - printf("FreeDOS System configurator %s \n", VERSION); + printf("FreeDOS Kernel Configuration %s\n", VERSION); /* 1st go through and just process arguments (help/filename/etc) */ @@ -243,15 +361,16 @@ int FDKrnConfigMain(int argc,char **argv) argptr = argv[argstart]; - cptr = strchr(argptr, '='); - +#if 0 /* No arguments is acceptable, just displays current settings using default kernel file */ if (argptr == 0) { showUsage(); exit(1); } +#endif + /* the first argument may be the kernel name */ - if (strchr(argptr, '=') == NULL) + if ( (argstart < argc) && (strchr(argptr, '=') == NULL) ) { kfilename = argptr; argstart++; @@ -291,9 +410,18 @@ int FDKrnConfigMain(int argc,char **argv) } else if (memicmp(argptr, "SKIPCONFIGSECONDS",3) == 0) { - setByteOption(&(cfg.SkipConfigSeconds), - cptr, 1, &updates, "SKIPCONFIGSECONDS"); - updates++; + setSByteOption(&(cfg.SkipConfigSeconds), + cptr, -128, 127, &updates, "SKIPCONFIGSECONDS"); + } + else if (memicmp(argptr, "FORCELBA",3) == 0) + { + setByteOption(&(cfg.ForceLBA), + cptr, 1, &updates, "FORCELBA"); + } + else if (memicmp(argptr, "GLOBALENABLELBASUPPORT",3) == 0) + { + setByteOption(&(cfg.GlobalEnableLBAsupport), + cptr, 1, &updates, "GLOBALENABLELBASUPPORT"); } else { @@ -321,7 +449,7 @@ int FDKrnConfigMain(int argc,char **argv) printf("\nUpdated Kernel settings.\n"); } else - printf("Current Kernel settings.\n"); + printf("\nCurrent Kernel settings.\n"); /* display current settings */ diff --git a/sys/makefile b/sys/makefile index 4d7a787f..ffeafd6d 100644 --- a/sys/makefile +++ b/sys/makefile @@ -4,6 +4,9 @@ # $Id$ # # $Log$ +# Revision 1.2 2001/11/13 23:36:45 bartoldeman +# Kernel 2025a final changes. +# # Revision 1.1 2001/11/04 20:10:15 bartoldeman # Added new makefile names, utils sources, kconfig.h # @@ -30,7 +33,7 @@ # Improved by jprice # -!include "..\config.mak" +!include "..\mkfiles\generic.mak" CFLAGS = -I$(INCLUDEPATH) -I..\hdr -DFORSYS -DWITHFAT32 $(CFLAGST) NASMFLAGS = -DSYS=1 @@ -49,7 +52,7 @@ SYS_EXE_dependencies = \ production: bin2c.com ..\bin\sys.com bin2c.com: $(BIN2C_EXE_dependencies) - $(CC) $(CFLAGST) -L$(LIBPATH) $(BIN2C_EXE_dependencies) + $(CC) $(CFLAGST) $(BIN2C_EXE_dependencies) ..\bin\sys.com: sys.com copy sys.com ..\bin @@ -69,13 +72,13 @@ prf.obj: ..\kernel\prf.c fdkrncfg.obj: fdkrncfg.c ..\hdr\kconfig.h sys.com: $(SYS_EXE_dependencies) - $(CC) $(CFLAGST) -L$(LIBPATH) $(SYS_EXE_dependencies) + $(CC) $(CFLAGST) $(SYS_EXE_dependencies) clobber: clean - $(RM) bin2c.com sys.com b_fat12.h b_fat16.h b_fat32.h + -$(RM) bin2c.com sys.com b_fat12.h b_fat16.h b_fat32.h clean: - $(RM) *.obj *.bak *.crf *.xrf *.map *.lst *.las status.me + -$(RM) *.obj *.bak *.crf *.xrf *.map *.lst *.las *.cod status.me # *Individual File Dependencies* bin2c.obj: bin2c.c diff --git a/sys/sys.c b/sys/sys.c index c2ed3584..354f957e 100644 --- a/sys/sys.c +++ b/sys/sys.c @@ -26,9 +26,12 @@ ***************************************************************/ /* $Log$ - * Revision 1.11 2001/11/04 19:47:39 bartoldeman - * kernel 2025a changes: see history.txt + * Revision 1.12 2001/11/13 23:36:45 bartoldeman + * Kernel 2025a final changes. * +/* Revision 1.11 2001/11/04 19:47:39 bartoldeman +/* kernel 2025a changes: see history.txt +/* /* Revision 1.10 2001/09/24 02:28:14 bartoldeman /* Minor printf fixes. /* @@ -148,7 +151,7 @@ #define DEBUG /* #define DDEBUG */ -#define SYS_VERSION "v2.2" +#define SYS_VERSION "v2.3" #include #include @@ -175,7 +178,7 @@ BYTE pgm[] = "SYS"; -void put_boot(COUNT); +void put_boot(COUNT, BYTE *, BOOL); BOOL check_space(COUNT, BYTE *); BOOL copy(COUNT drive, BYTE * srcPath, BYTE * rootPath, BYTE * file); COUNT DiskRead(WORD, WORD, WORD, WORD, WORD, BYTE FAR *); @@ -185,8 +188,9 @@ COUNT DiskWrite(WORD, WORD, WORD, WORD, WORD, BYTE FAR *); #define SEC_SIZE 512 #define COPY_SIZE 32768u - - +#ifdef _MSC_VER + #pragma pack(1) +#endif struct bootsectortype { @@ -260,12 +264,20 @@ UBYTE newboot[SEC_SIZE], oldboot[SEC_SIZE]; #define SBSIZE (sizeof(struct bootsectortype) - SBOFFSET) #define SBSIZE32 (sizeof(struct bootsectortype32) - SBOFFSET) +/* essentially - verify alignment on byte boundaries at compile time */ +struct VerifyBootSectorSize +{ + char failure1[sizeof(struct bootsectortype) == 78 ? 1 : -1]; + char failure2[sizeof(struct bootsectortype) == 78 ? 1 : 0]; +}; int FDKrnConfigMain(int argc,char **argv); int main(int argc, char **argv) { COUNT drive; /* destination drive */ + COUNT drivearg = 0; /* drive argument position */ + BYTE *bsFile = NULL; /* user specified destination boot sector */ COUNT srcDrive; /* source drive */ BYTE srcPath[MAXPATH]; /* user specified source drive and/or path */ BYTE rootPath[4]; /* alternate source path to try if not '\0' */ @@ -273,19 +285,18 @@ int main(int argc, char **argv) printf("FreeDOS System Installer " SYS_VERSION "\n\n"); - if (memicmp(argv[1],"CONFIG",6) == 0) + if (argc > 1 && memicmp(argv[1],"CONFIG",6) == 0) { exit(FDKrnConfigMain(argc,argv)); } - if (argc == 2) - { - drive = toupper(*argv[1]) - 'A'; - srcPath[0] = '\0'; - } - else if (argc == 3) + srcPath[0] = '\0'; + if (argc > 1 && argv[1][1] == ':' && argv[1][2] == '\0') + drivearg = 1; + + if (argc > 2 && argv[2][1] == ':' && argv[2][2] == '\0') { - drive = toupper(*argv[2]) - 'A'; + drivearg = 2; strncpy(srcPath, argv[1], MAXPATH-12); /* leave room for COMMAND.COM\0 */ srcPath[MAXPATH-13] = '\0'; @@ -299,14 +310,19 @@ int main(int argc, char **argv) srcPath[slen] = '\0'; } } - else + + if (drivearg == 0) { - printf("Usage: %s [source] drive\n", pgm); - printf(" source = A:,B:,C:\\KERNEL\\BIN\\,etc., or current directory if not given\n"); - printf(" drive = A,B,etc.\n"); + printf("Usage: %s [source] drive: [bootsect [BOTH]]\n", pgm); + printf(" source = A:,B:,C:\\KERNEL\\BIN\\,etc., or current directory if not given\n"); + printf(" drive = A,B,etc.\n"); + printf(" bootsect = name of 512-byte boot sector file image for drive:\n"); + printf(" to write to instead of real boot sector\n"); + printf(" BOTH : write to both the real boot sector and the image file\n"); printf("%s CONFIG /help\n",pgm); exit(1); } + drive = toupper(argv[drivearg][0]) - 'A'; if (drive < 0 || drive >= 26) { @@ -353,9 +369,13 @@ int main(int argc, char **argv) printf("\n%s: cannot copy \"COMMAND.COM\"\n", pgm); exit(1); } - + + if (argc > drivearg+1) + bsFile = argv[drivearg+1]; + printf("\nWriting boot sector...\n"); - put_boot(drive); + put_boot(drive, bsFile, + (argc > drivearg+2) && memicmp(argv[drivearg+2], "BOTH", 4) == 0); printf("\nSystem transferred.\n"); return 0; @@ -435,7 +455,7 @@ int MyAbsReadWrite(int DosDrive, int count, ULONG sector, void *buffer, unsigned } -VOID put_boot(COUNT drive) +VOID put_boot(COUNT drive, BYTE *bsFile, BOOL both) { COUNT i, z; WORD head, track, sector, ret; @@ -635,16 +655,43 @@ VOID put_boot(COUNT drive) dump_sector(newboot); #endif + if ((bsFile == NULL) || both) + { + #ifdef DEBUG printf("writing new bootsector to drive %c:\n",drive+'A'); #endif - if (MyAbsReadWrite(drive, 1, 0, newboot,0x26) != 0) + if (MyAbsReadWrite(drive, 1, 0, newboot,0x26) != 0) { - printf("Can't write new boot sector to drive %c:\n", drive +'A'); - exit(1); + printf("Can't write new boot sector to drive %c:\n", drive +'A'); + exit(1); } + } + + if (bsFile != NULL) + { + int fd; + +#ifdef DEBUG + printf("writing new bootsector to file %s\n", bsFile); +#endif + /* write newboot to bsFile */ + if ((fd = open(bsFile, O_RDWR | O_TRUNC | O_CREAT | O_BINARY,S_IREAD|S_IWRITE)) < 0) + { + printf( " %s: can't create\"%s\"\nDOS errnum %d", pgm, bsFile, errno); + exit(1); + } + if (write(fd, newboot, SEC_SIZE) != SEC_SIZE) + { + printf("Can't write %u bytes to %s\n", SEC_SIZE, bsFile); + close(fd); + unlink(bsFile); + exit(1); + } + close(fd); + } } diff --git a/utils/exeflat.c b/utils/exeflat.c index 348e2272..779505b9 100644 --- a/utils/exeflat.c +++ b/utils/exeflat.c @@ -42,48 +42,12 @@ large portions copied from task.c #define BUFSIZE 32768u -/* JPP - changed so will accept hex number. */ -COUNT our_atoi(REG BYTE * pszString) -{ - BYTE Base = 10; - BOOL Sign = FALSE; - COUNT pnNum = 0; - UCOUNT digit; - if (*pszString == '-') - - { - pszString++; - Sign = TRUE; - } - if (pszString[0] == '0' && toupper(pszString[1]) == 'X') - - { - Base = 16; - pszString += 2; - } - for (; isxdigit(*pszString); pszString++) - - { - if (isdigit(pszString[0])) - digit = pszString[0] - '0'; +#define LENGTH(x) (sizeof(x)/sizeof(x[0])) - else - digit = toupper(pszString[0]) - 'A' + 10; - if (digit > Base) - - { - printf("illegal digit '%s' in offset\n", pszString); - exit(1); - } - pnNum = pnNum * Base + digit; - } - if (Sign) - pnNum = -pnNum; - return pnNum; -} typedef struct { UWORD off, seg; } farptr; + int compReloc(const void *p1, const void *p2) { farptr *r1 = (farptr *) p1; @@ -98,10 +62,20 @@ int compReloc(const void *p1, const void *p2) return -1; return 0; } + +void usage() +{ + printf("usage: exeflat (src.exe) (dest.sys) (relocation-factor)\n"); + printf + (" -S10 - Silent relocate segment 10 (down list)\n"); + + exit(1); +} + int main(int argc, char **argv) { exe_header header; - int i; + int i, j; size_t bufsize; farptr *reloc; UWORD start_seg; @@ -109,51 +83,75 @@ int main(int argc, char **argv) UBYTE **buffers; UBYTE **curbuf; FILE *src, *dest; - if (argc != 4) + short silentSegments[20], silentcount = 0, silentdone = 0; + /* do optional argument processing here */ + for (i = 4; i < argc; i++) { - printf("usage: exeflat (src.exe) (dest.sys) (relocation-factor)\n"); - return 1; + char *argptr = argv[i]; + + if (argptr[0] != '-' && argptr[0] != '/') + usage(); + + argptr++; + + switch (toupper(argptr[0])) + { + case 'S': + if (silentcount >= LENGTH(silentSegments)) + { + printf("can't handle more then %d silent's\n", + LENGTH(silentSegments)); + exit(1); + } + + silentSegments[silentcount++] = strtol(argptr + 1, NULL, 0); + break; + + default: + usage(); + } } - if ((src = fopen(argv[1], "rb")) == NULL) + /* arguments left : + infile outfile relocation offset */ + + if ((src = fopen(argv[1], "rb")) == NULL) { printf("Source file %s could not be opened\n", argv[1]); return 1; } if (fread(&header, sizeof(header), 1, src) != 1) - { printf("Error reading header from %s\n", argv[1]); fclose(src); return 1; } if (header.exSignature != MAGIC) - { printf("Source file %s is not a valid .EXE\n", argv[1]); fclose(src); return 1; } if ((dest = fopen(argv[2], "wb+")) == NULL) - { printf("Destination file %s could not be created\n", argv[2]); return 1; } - start_seg = our_atoi(argv[3]); - printf("header len = %ld = 0x%lx\n", header.exHeaderSize * 16UL, + start_seg = strtol(argv[3], NULL, 0); + printf("header len = %lu = 0x%lx\n", header.exHeaderSize * 16UL, header.exHeaderSize * 16UL); - fseek(src, 0, SEEK_END); - size = ftell(src) - header.exHeaderSize * 16UL; - printf("image size (less header) = %ld = 0x%lx\n", size, size); - printf("first relocation offset = 0 = 0x0\n"); + size = + ((DWORD) (header.exPages - 1) << 9) + header.exExtraBytes - + header.exHeaderSize * 16UL; + printf("image size (less header) = %lu = 0x%lx\n", size, size); + printf("first relocation offset = %u = 0x%u\n", header.exOverlay, + header.exOverlay); /* first read file into memory chunks */ fseek(src, header.exHeaderSize * 16UL, SEEK_SET); buffers = malloc((size + BUFSIZE - 1) / BUFSIZE * sizeof(char *)); if (buffers == NULL) - { printf("Allocation error\n"); return 1; @@ -161,19 +159,16 @@ int main(int argc, char **argv) bufsize = BUFSIZE; for (to_xfer = size, curbuf = buffers; to_xfer > 0; to_xfer -= bufsize, curbuf++) - { if (to_xfer < BUFSIZE) bufsize = to_xfer; *curbuf = malloc(bufsize); if (*curbuf == NULL) - { printf("Allocation error\n"); return 1; } if (fread(*curbuf, sizeof(char), bufsize, src) != bufsize) - { printf("Source file read error %ld %d\n", to_xfer, bufsize); return 1; @@ -182,14 +177,12 @@ int main(int argc, char **argv) fseek(src, header.exRelocTable, SEEK_SET); reloc = malloc(header.exRelocItems * sizeof(farptr)); if (reloc == NULL) - { printf("Allocation error\n"); return 1; } if (fread(reloc, sizeof(farptr), header.exRelocItems, src) != header.exRelocItems) - { printf("Source file read error\n"); return 1; @@ -197,14 +190,24 @@ int main(int argc, char **argv) fclose(src); qsort(reloc, header.exRelocItems, sizeof(reloc[0]), compReloc); for (i = 0; i < header.exRelocItems; i++) - { ULONG spot = ((ULONG) reloc[i].seg << 4) + reloc[i].off; UBYTE *spot0 = &buffers[spot / BUFSIZE][spot % BUFSIZE]; UBYTE *spot1 = &buffers[(spot + 1) / BUFSIZE][(spot + 1) % BUFSIZE]; UWORD segment = ((UWORD) * spot1 << 8) + *spot0; + + for (j = 0; j < silentcount; j++) + if (segment == silentSegments[j]) + { + silentdone++; + goto dontPrint; + } + printf("relocation at 0x%04x:0x%04x ->%04x\n", reloc[i].seg, reloc[i].off, segment); + + dontPrint: + segment += start_seg; *spot0 = segment & 0xff; *spot1 = segment >> 8; @@ -214,7 +217,6 @@ int main(int argc, char **argv) bufsize = BUFSIZE; for (to_xfer = size, curbuf = buffers; to_xfer > 0; to_xfer -= bufsize, curbuf++) - { if (to_xfer < BUFSIZE) bufsize = to_xfer; @@ -225,7 +227,9 @@ int main(int argc, char **argv) return 1; } } + fclose(dest); - printf("\nProcessed %d relocations\n", header.exRelocItems); + printf("\nProcessed %d relocations, %d not shown\n", header.exRelocItems, + silentdone); return 0; } diff --git a/utils/makefile b/utils/makefile index b88a6194..20b628b4 100644 --- a/utils/makefile +++ b/utils/makefile @@ -1,23 +1,19 @@ -!include "..\config.mak" +!include "..\mkfiles\generic.mak" CFLAGS = -I$(INCLUDEPATH) -I..\hdr production: patchobj.exe exeflat.exe -patchobj.exe: patchobj.obj - $(CC) -L$(LIBPATH) patchobj.obj +patchobj.exe: patchobj.c + $(CC) $(CFLAGST) $(CFLAGS) patchobj.c -exeflat.exe: exeflat.obj - $(CC) -L$(LIBPATH) $(CFLAGSC) exeflat.obj +exeflat.exe: exeflat.c ..\hdr\exe.h + $(CC) $(CFLAGSC) $(CFLAGS) exeflat.c -patchobj.obj: patchobj.c ..\config.mak - -exeflat.obj: exeflat.c ..\hdr\exe.h ..\config.mak - $(CC) $(CFLAGSC) $(CFLAGS) -c exeflat.c clobber: clean $(RM) bin2c.com exeflat.exe patchobj.exe clean: - $(RM) *.obj *.bak *.crf *.xrf *.map *.lst *.las status.me + $(RM) *.obj *.bak *.crf *.xrf *.map *.lst *.las *.cod status.me diff --git a/utils/patchobj.c b/utils/patchobj.c index 74c20dcb..478f5718 100644 --- a/utils/patchobj.c +++ b/utils/patchobj.c @@ -201,10 +201,10 @@ do { for (s = (unsigned char *)&Outrecord; s < &Outrecord.buffer[Outrecord.datalen]; s++) chksum += *s; - Outrecord.buffer[Outrecord.datalen] = -chksum; + Outrecord.buffer[Outrecord.datalen] = ~chksum; Outrecord.datalen++; - /* printf("^sum = %02x - %02x\n",chksum,-chksum); */ + /* printf("^sum = %02x - %02x\n",chksum,~chksum); */ fwrite(&Outrecord,1,3+Outrecord.datalen,fdo); From 5fc87d0148d73496621d09de2fe75b4d287ad30b Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Tue, 13 Nov 2001 23:41:53 +0000 Subject: [PATCH 106/671] Removed config.m git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@322 6ac86273-5f31-0410-b378-82cca8765d1b --- config.m | 115 ------------------------------------------------------- 1 file changed, 115 deletions(-) delete mode 100644 config.m diff --git a/config.m b/config.m deleted file mode 100644 index 8ecc114a..00000000 --- a/config.m +++ /dev/null @@ -1,115 +0,0 @@ -# -# makefile that is included in all other makefiles for configuration -# - -################################################################ -# NOTICE! You must edit and rename this file to CONFIG.MAK! # -################################################################ - -#********************************************************************* -# determine your compiler settings -# -# you have to -# search for NASM - and set the path for NASM -# search for ??_BASE - and set the path to your compiler -# search for LINK - and set the path to your linker -# -#********************************************************************* - -#********************************************************************** -#- define where to find NASM - remember - it should not be protected -# mode DJGPP version if you're using Windows NT/2k/XP to compile -#********************************************************************** - -NASM=c:\bin\nasm16 - -#********************************************************************** -#- where is the BASE dir of your compiler(s) ?? -#********************************************************************** - -WC_BASE=C:\watcom -MS_BASE=C:\msvc -TC2_BASE=C:\tc201 -TP1_BASE=C:\tcpp -TC3_BASE=C:\tc3 -BC5_BASE=C:\bc5 - -#********************************************************************** -#- select your default target: required CPU and what FAT system to support -#********************************************************************** - -#XCPU=86 -#XCPU=186 -#XCPU=386 - -#XFAT=16 -#XFAT=32 - -# Give extra Turbo C compiler flags here -# such as -DDEBUG : extra DEBUG output -# -DDOSEMU : printf output goes to dosemu log -# -DWITHFAT32 : compile with FAT32 support -#ALLCFLAGS=-DDEBUG - -!include "..\mkfiles\generic.mak" - -#********************************************************************** -#- which linker to use: WATCOM wlink is not suitable for linking -#********************************************************************** - -# Turbo Link -#LINK=$(TC2_BASE)\tlink /m/c -LINK=d:\util\tlink /m/c -# Microsoft Link -#LINK=$(COMPILERBIN)\link /ONERROR:NOEXE /ma -# VAL: you need VAL95, NOT the one in LANG1.ZIP (yet); -# look at the software list on www.freedos.org. -# VAL complains about MODEND record missing for Watcom compiled objects! -# LINK=c:\bin\val /MP /NCI - -# use a ; to end the LINK command line? -LINKTERM=; - - -# -# $Id$ -# -# $Log$ -# Revision 1.9 2001/11/04 19:47:37 bartoldeman -# kernel 2025a changes: see history.txt -# -# Revision 1.8 2001/09/23 20:39:43 bartoldeman -# FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling -# -# Revision 1.7 2001/04/16 14:36:56 bartoldeman -# Added ALLCFLAGS for compiler option configuration. -# -# Revision 1.6 2001/04/15 03:21:49 bartoldeman -# See history.txt for the list of fixes. -# -# Revision 1.5 2001/03/22 10:51:04 bartoldeman -# Suggest to extract F_SCOPY into libm.lib for Borland C++. -# -# Revision 1.4 2001/03/19 04:50:56 bartoldeman -# See history.txt for overview: put kernel 2022beo1 into CVS -# -# Revision 1.3 2000/05/25 20:56:19 jimtabor -# Fixed project history -# -# Revision 1.2 2000/05/14 17:07:07 jimtabor -# Cleanup CRs -# -# Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 -# The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with -# MS-DOS. Distributed under the GNU GPL. -# -# Revision 1.3 1999/09/13 20:40:17 jprice -# Added COMPILER variable -# -# Revision 1.2 1999/08/25 03:59:14 jprice -# New build batch files. -# -# Revision 1.1 1999/08/25 03:20:39 jprice -# ror4 patches to allow TC 2.01 compile. -# -# From 0855648f58f675435a951443ab4ecdd25dfc4824 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Tue, 13 Nov 2001 23:45:25 +0000 Subject: [PATCH 107/671] Added new build system files, sys documentation, "rm" batch file git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@323 6ac86273-5f31-0410-b378-82cca8765d1b --- docs/sys.txt | 177 +++++++++++++++++++++++++++++++++++++++++++++ getmake.bat | 10 +++ kernel/iprf.c | 6 ++ kernel/rtlsupt.asm | 68 +++++++++++++++++ utils/rmfiles.bat | 10 +++ 5 files changed, 271 insertions(+) create mode 100644 docs/sys.txt create mode 100644 getmake.bat create mode 100644 kernel/iprf.c create mode 100644 kernel/rtlsupt.asm create mode 100644 utils/rmfiles.bat diff --git a/docs/sys.txt b/docs/sys.txt new file mode 100644 index 00000000..1782b0b5 --- /dev/null +++ b/docs/sys.txt @@ -0,0 +1,177 @@ +SYS documentation by Jeremy Davis +Updated by Bart Oldeman + +SYS's standard behavior is very similar (though in +my opinion improved) to that of other DOSes. +SYS (no options) should provide a general usage, +and SYS CONFIG /help (or SYS CONFIG /?) should +provide usage for the new configuration options. + +Admittedly its brief, but it is there. +Below is a more detailed documentation on its +usage (from memory, but I believe it is close to right). +The best documentation (and maybe only) is the +source itself. + + +The simplest usage: + +SYS dest: + +dest should be the drive (A:, B:, C:, ...) you wish +to be bootable with FreeDOS (kernel & command.com) +When using this form, KERNEL.SYS and COMMAND.COM +must reside either in the current directory (which +is searched first) or in recent revisions may also +be in the root directory of the current drive. + +Complete form: + +SYS [source] dest: [bootsect [BOTH]] + +Here dest is the same as before, but this time +you specify where KERNEL.SYS and COMMAND.COM are. +Source may simply be a drive (in this case it +is similar to PC & MS SYS). The current directory +of the specified drive is first searched for +KERNEL.SYS & COMMAND.COM and if not found then +the root directory of the specified drive is tried. +Alternatively, you may specify a path (either fully +qualified or relative) to where KERNEL.SYS and +COMMAND.COM may be found; note that this should +only search this directory and will fail if they +are not found, ie it will not check for them on +the root directory of the drive specified when +a path is given. It should also fail if the +source and destination drive are both the same +and would result in trying to SYS from the root +to the root (ie trying to SYS from C:\ to C:\). + +If you specify a name for "bootsect", for instance, +bootsect.fd, SYS will write to that file instead of +the real boot sector. You will obtain a 512-byte file +containing the boot sector, which can then be used +for dual booting or diagnostic purposes. + +If you also specify BOTH, sys will write to both +the image file and the boot sector. + + +Kernel Configuration Options: + +Simplest form: + +SYS CONFIG + +This will simply display the current settings +for the file KERNEL.SYS in the current directory. +It is useful to see what the options are currently +set to, what options are supported, and should +show valid values along with defaults (defaults are +the valid values with a '*' next to them). + +Optionally specify file: + +SYS CONFIG [drive][path]KERNEL.SYS + +This form behaves as above, except will display +the settings for the kernel file you specify. +drive and path are optional, and generally just +a \ will be used to indicate root directory of +current drive. KERNEL.SYS specifies the filename +of the kernel, which may not be "KERNEL.SYS", +for example when testing you want to alter +KERNTEST.SYS and later copy (or rename) this to +KERNEL.SYS for booting. + + +Changing options: + +SYS CONFIG OPTION1=value [OPTION2=value ...] + +This form will read the current settings from +the kernel (KERNEL.SYS in the current directory) +and set the options specified to the value given. +If the value is potentially invalid (too large, too +small, etc) then a warning will be displayed, but +the change will still occur. The kernel file is +only updated if at least one option is different from the +current settings. If you wish to force the kernel +file to be written to, then set the same option +twice (OPTION1=oddvalue OPTION1=desiredvalue), with +the 1st time the value being different from the +current one and the rightmost one being the desired +value. Currently three options are supported. +Note: currently only the 1st three letters are +actually checked, so they may be abreviated to +DLA, SHO, and SKI and with my recent patch you may +specify the value as either a decimal number 0,10,255,... +or as a hexidecimal number 0x0,0xA, 0xFF... + +DLASORT which may be set to 0 or 1 +DLASORT=0 or DLASORT=1 +This option is for specifying whether Drive Letter +Assignment should follow the normal MSDOS way of +all primary partitions across drives and then +extended partitions, or the more logical +all partitions (primary & extended) on the 1st +drive, then repeat for all following drives +(all primary & extended, then try next drive). +0 corresponds to MS way and 1 corresponds to first +drive completely, then next ... + +SHOWDRIVEASSIGNMENT which may be 0 or 1 +SHOWDRIVEASSIGNMENT=0 or SHOWDRIVEASSIGNMENT=1 +If 1 then the normal drive assignment information +is displayed upon booting. If 0 then this information +is supressed (not shown). + +SKIPCONFIGSECONDS which may be -128 to 127. +A negative value ( < 0 ) indicates that F5/F8 +processing will be skipped (the kernel won't check +if you pressed these keys, so you can't skip config +file (CONFIG.SYS) processing). A 0 means you must +have pressed the key precisely for when the kernel +checks for it - essentially skipping, though a well +timed finger will still get to use it. And any value +greater than 0 I belive is the seconds the kernel will +display the prompt and wait for you to press the key +before assuming you didn't. + +FORCELBA which may be 0 or 1 +FORCELBA=0 or FORCELBA=1 +If 1 then the kernel will use LBA (extended INT13) +techniques to address all partitions if possible, +even if these have a non-LBA partition type and +are completely below cylinder 1023 (usually the 8MB +boundary). This is 0 by default, for compatibility +reasons. Setting this to 1 may bypass some buggy +BIOSes and gives slightly better performance. + +GLOBALENABLELBASUPPORT which maybe 0 or 1 +GLOBALENABLELBASUPPORT=0 or GLOBALENABLELBASUPPORT=1 +If 0 then LBA will be completely disabled, irrespective +of the FORCELBA setting. You need this if FreeDOS thinks +you have LBA available, but in reality you do not. +This setting is set to 1 by default. + +Example: To set the kernel in the current directory +to have a timeout of 5 seconds (default is 2) run +SYS CONFIG SKI=5 + + +Changing options of specified file: + +SYS CONFIG [drive][path]KERNEL.SYS OPTION1=value ...] + +This is just like previous section on setting options, +except the first argument after CONFIG specifies which +kernel file to use. The filename is the same form used +for displaying options of specified kernel file described +above. + +Example2: To set a kernel in the root directory to +not show drive assignment and change the timeout +to never check +SYS CONFIG \KERNEL.SYS SKI=-1 SHOWDRIVEASSIGNMENT=0x0 + diff --git a/getmake.bat b/getmake.bat new file mode 100644 index 00000000..25c9c0b0 --- /dev/null +++ b/getmake.bat @@ -0,0 +1,10 @@ +@if not \%MAKE% == \ goto make_set + +@if \%COMPILER% == \TC2 set MAKE=%TC2_BASE%\make +@if \%COMPILER% == \TURBOCPP set MAKE=%TP1_BASE%\bin\make +@if \%COMPILER% == \TC3 set MAKE=%TC3_BASE%\bin\make +@if \%COMPILER% == \BC5 set MAKE=%BC5_BASE%\bin\make +@if \%COMPILER% == \WATCOM set MAKE=%WATCOM%\binw\wmake /ms +@if \%COMPILER% == \MSCL8 set MAKE=%MS_BASE%\nmake /nologo + +:make_set diff --git a/kernel/iprf.c b/kernel/iprf.c new file mode 100644 index 00000000..873a7eb3 --- /dev/null +++ b/kernel/iprf.c @@ -0,0 +1,6 @@ +/* init code printf */ +/* simply include prf.c while defining */ +/* _INIT: reduces command line length */ +/* and simplifies make procedure */ +#define _INIT 1 +#include "prf.c" diff --git a/kernel/rtlsupt.asm b/kernel/rtlsupt.asm new file mode 100644 index 00000000..5f5a82ef --- /dev/null +++ b/kernel/rtlsupt.asm @@ -0,0 +1,68 @@ +; File: +; rtlsupt.asm +; Description: +; Assembly support routines for long mul/div +; was forced to do that for WATCOM C, which has _near +; LMUL/LDIV routines. shouldn't harm for others +; +; Copyright (c) 2001 +; tom ehlert +; All Rights Reserved +; +; This file is part of DOS-C. +; +; DOS-C is free software; you can redistribute it and/or +; modify it under the terms of the GNU General Public License +; as published by the Free Software Foundation; either version +; 2, or (at your option) any later version. +; +; DOS-C is distributed in the hope that it will be useful, but +; WITHOUT ANY WARRANTY; without even the implied warranty of +; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See +; the GNU General Public License for more details. +; +; You should have received a copy of the GNU General Public +; License along with DOS-C; see the file COPYING. If not, +; write to the Free Software Foundation, 675 Mass Ave, +; Cambridge, MA 02139, USA. +; +; $Id$ +; +; Rev 1.0 02 Jul 1995 9:04:50 patv +;Initial revision. +; $EndLog$ +; + + %include "segs.inc" + + +segment _TEXT + +; +; cdecl calling conventions +; +; ULONG FAR MULULUS(ULONG mul1, USHORT mul2) - MULtiply ULong by UShort +; +%IFNDEF I386 +P8086 +%ELSE +P386 ; Turn on 386 instructions. +%ENDIF ; I386 + + + global _MULULUS +_MULULUS: + + push bp + mov bp,sp + mov bx,[bp+6+4] ; short mul2 + mov ax,[bp+6+2] ; high part of mul1 + mul bx + mov cx,ax + mov ax,[bp+6+0] ; low part of mul1 + mul bx + add dx,cx ; add in high part of result + + pop bp + retf + diff --git a/utils/rmfiles.bat b/utils/rmfiles.bat new file mode 100644 index 00000000..5633e425 --- /dev/null +++ b/utils/rmfiles.bat @@ -0,0 +1,10 @@ +@echo off +:loop_commandline + +if \%1 == \ goto done_with_commandline +del %1 +shift +goto loop_commandline + +:done_with_commandline + From 56c49450feee734cd946a27ced1ddcfa87ddcf94 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Wed, 14 Nov 2001 00:15:05 +0000 Subject: [PATCH 108/671] Fixed typo in dpbp git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@324 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/inthndlr.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/kernel/inthndlr.c b/kernel/inthndlr.c index f88365cb..44c904ce 100644 --- a/kernel/inthndlr.c +++ b/kernel/inthndlr.c @@ -37,6 +37,9 @@ BYTE *RcsId = "$Id$"; /* * $Log$ + * Revision 1.34 2001/11/14 00:15:05 bartoldeman + * Fixed typo in dpbp + * * Revision 1.33 2001/11/13 23:36:45 bartoldeman * Kernel 2025a final changes. * @@ -1762,7 +1765,7 @@ VOID ASMCFUNC int21_service(iregs FAR * r) dpb = GetDriveDPB(r->DL, &rc); if (rc != SUCCESS) goto error_exit; - flush_buffers(dpbp->dpb_unit); + flush_buffers(dpb->dpb_unit); dpb->dpb_flags = M_CHANGED; /* force reread of drive BPB/DPB */ if (media_check(dpb) < 0) @@ -1855,7 +1858,7 @@ VOID ASMCFUNC int21_service(iregs FAR * r) case 0x02: { rebuild_dpb: - flush_buffers(dpbp->dpb_unit); + flush_buffers(dpb->dpb_unit); dpb->dpb_flags = M_CHANGED; if (media_check(dpb) < 0) From fe51b7a036cbb050bc15163f4a9f6284bb2dad1c Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sat, 17 Nov 2001 23:26:45 +0000 Subject: [PATCH 109/671] Truncated and disabled $Logs, fixed r/w bugs for kernel 2025b git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@326 6ac86273-5f31-0410-b378-82cca8765d1b --- bin/install.bat | 41 ++-- boot/boot.asm | 142 +++++++------- boot/makefile | 62 +++--- build.bat | 86 ++++----- clean.bat | 53 ++---- clobber.bat | 43 ++--- config.b | 40 +--- docs/build.txt | 10 +- docs/history.txt | 74 +++++--- docs/intfns.txt | 10 +- drivers/devend.asm | 49 ++--- drivers/floppy.asm | 109 ++++------- drivers/getvec.asm | 68 +++---- drivers/makefile | 94 ++++------ drivers/rdatclk.asm | 62 +++--- drivers/rdpcclk.asm | 56 ++---- drivers/timer.asm | 71 +++---- drivers/wratclk.asm | 72 +++---- drivers/wrpcclk.asm | 52 ++--- fdkernel.lsm | 6 +- getmake.bat | 2 +- hdr/buffer.h | 28 +-- hdr/cds.h | 71 +++---- hdr/clock.h | 30 ++- hdr/date.h | 47 ++--- hdr/dcb.h | 99 ++++------ hdr/device.h | 143 ++++++-------- hdr/dirmatch.h | 98 ++++------ hdr/dosnames.h | 23 +-- hdr/error.h | 105 +++++------ hdr/exe.h | 54 +++--- hdr/fat.h | 108 ++++------- hdr/fcb.h | 93 ++++----- hdr/file.h | 47 ++--- hdr/fnode.h | 117 +++++------- hdr/kbd.h | 34 ++-- hdr/mcb.h | 88 ++++----- hdr/pcb.h | 92 ++++----- hdr/portab.h | 101 ++++------ hdr/process.h | 100 ++++------ hdr/sft.h | 104 +++++----- hdr/stacks.inc | 72 +++---- hdr/tail.h | 34 ++-- hdr/time.h | 34 ++-- hdr/version.h | 6 +- kernel/apisupt.asm | 91 ++++----- kernel/asmsupt.asm | 96 ++++------ kernel/blockio.c | 236 ++++++++++------------- kernel/break.c | 44 ++--- kernel/chario.c | 185 ++++++++---------- kernel/config.c | 282 ++++++++++------------------ kernel/console.asm | 77 +++----- kernel/dosfns.c | 273 +++++++++------------------ kernel/dosnames.c | 166 +++++++--------- kernel/dsk.c | 252 ++++++++++++------------- kernel/entry.asm | 106 ++++------- kernel/error.c | 98 +++++----- kernel/execrh.asm | 100 ++++------ kernel/fatdir.c | 259 +++++++++---------------- kernel/fatfs.c | 449 +++++++++++++++++--------------------------- kernel/fattab.c | 144 ++++++-------- kernel/fcbfns.c | 198 +++++++------------ kernel/globals.h | 278 +++++++++++---------------- kernel/init-mod.h | 1 - kernel/inithma.c | 45 +---- kernel/initoem.c | 50 ++--- kernel/int2f.asm | 118 ++++-------- kernel/inthndlr.c | 410 +++++++++++++++++----------------------- kernel/io.asm | 64 ++----- kernel/io.inc | 55 ++---- kernel/ioctl.c | 148 ++++++--------- kernel/irqstack.asm | 79 ++++---- kernel/kernel.asm | 192 +++++++------------ kernel/main.c | 256 ++++++++++--------------- kernel/makefile | 232 +++++++++-------------- kernel/memmgr.c | 149 +++++---------- kernel/misc.c | 107 +++++------ kernel/network.c | 78 ++------ kernel/newstuff.c | 157 ++++++---------- kernel/nls.c | 41 ++-- kernel/nls_load.c | 19 +- kernel/nlssupt.asm | 93 ++++----- kernel/prf.c | 174 ++++++----------- kernel/printer.asm | 42 ++--- kernel/procsupt.asm | 107 +++++------ kernel/proto.h | 274 +++++++++------------------ kernel/rtlsupt.asm | 3 - kernel/segs.inc | 61 ++---- kernel/serial.asm | 34 ++-- kernel/strings.c | 119 +++++------- kernel/sysclk.c | 120 +++++------- kernel/syspack.c | 87 ++++----- kernel/systime.c | 122 +++++------- kernel/task.c | 248 ++++++++++-------------- lib/makefile | 53 ++---- mkfiles/mscl8.mak | 3 +- mkfiles/watcom.mak | 4 +- sys/makefile | 44 ++--- sys/sys.c | 192 ++++++++----------- 99 files changed, 3911 insertions(+), 6334 deletions(-) diff --git a/bin/install.bat b/bin/install.bat index 9051939b..e959074e 100644 --- a/bin/install.bat +++ b/bin/install.bat @@ -3,26 +3,6 @@ rem rem Create a distribution floppy rem rem $Header$ -rem $Log$ -rem Revision 1.4 2001/11/04 21:46:53 bartoldeman -rem Text files need to be LF ended at the server. So be it... -rem -rem Revision 1.3 2001/03/22 04:12:43 bartoldeman -rem Change LF to CR/LF in batch files. -rem -rem Revision 1.2 2000/05/11 03:51:37 jimtabor -rem Clean up and Release -rem -rem Revision 1.3 1999/08/25 03:15:33 jprice -rem ror4 patches to allow TC 2.01 compile. -rem -rem Revision 1.2 1999/04/01 07:22:58 jprice -rem no message -rem -rem Revision 1.1.1.1 1999/03/29 15:40:21 jprice -rem New version without IPL.SYS -rem -rem set D=A: if "%1" == "b:" set D=B: @@ -53,3 +33,24 @@ goto done echo Floppy creation aborted :done set D= + +rem Log: install.bat,v +rem Revision 1.4 2001/11/04 21:46:53 bartoldeman +rem Text files need to be LF ended at the server. So be it... +rem +rem Revision 1.3 2001/03/22 04:12:43 bartoldeman +rem Change LF to CR/LF in batch files. +rem +rem Revision 1.2 2000/05/11 03:51:37 jimtabor +rem Clean up and Release +rem +rem Revision 1.3 1999/08/25 03:15:33 jprice +rem ror4 patches to allow TC 2.01 compile. +rem +rem Revision 1.2 1999/04/01 07:22:58 jprice +rem no message +rem +rem Revision 1.1.1.1 1999/03/29 15:40:21 jprice +rem New version without IPL.SYS +rem +rem diff --git a/boot/boot.asm b/boot/boot.asm index 8413bab1..68f8444d 100644 --- a/boot/boot.asm +++ b/boot/boot.asm @@ -26,84 +26,6 @@ ; Cambridge, MA 02139, USA. ; ; -; $Log$ -; Revision 1.5 2001/11/13 23:36:45 bartoldeman -; Kernel 2025a final changes. -; -; Revision 1.4 2001/04/29 17:34:39 bartoldeman -; A new SYS.COM/config.sys single stepping/console output/misc fixes. -; -; Revision 1.3 2000/05/25 20:56:19 jimtabor -; Fixed project history -; -; Revision 1.2 2000/05/11 03:56:42 jimtabor -; Clean up and Release -; -; Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 -; The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with -; MS-DOS. Distributed under the GNU GPL. -; -; Revision 1.12 1999/09/25 06:42:18 jprice -; Optimize boot loader. Documentation. -; -; Revision 1.11 1999/09/24 19:04:55 jprice -; Added changes recommended by Jens Horstmeier - -; to make their bootable CD work. -; -; Revision 1.10 1999/09/23 04:39:02 jprice -; *** empty log message *** -; -; Revision 1.7 1999/04/23 03:43:46 jprice -; Ported to NASM by ror4 -; -; Revision 1.6 1999/04/17 19:14:03 jprice -; Fixed multi-sector code -; -; Revision 1.5 1999/04/17 06:23:26 jprice -; Changed so multi-sector IO is optional. -; -; Revision 1.4 1999/04/13 15:52:22 jprice -; Moves boot sector to top of mem -; -; Revision 1.3 1999/04/06 22:53:36 jprice -; Put back code to read multiple sectors at a time. -; -; Revision 1.2 1999/04/01 07:23:20 jprice -; New boot loader -; -; Revision 1.1.1.1 1999/03/29 15:39:39 jprice -; New version without IPL.SYS -; -; Revision 1.3 1999/03/02 06:57:14 jprice -; Added entry address for more recent versions of TLINK -; -; Revision 1.2 1999/01/21 05:03:58 jprice -; Formating. -; -; Revision 1.1.1.1 1999/01/20 05:51:00 jprice -; Imported sources -; -; -; Rev 1.5 10 Jan 1997 4:58:06 patv -; Corrected copyright -; -; Rev 1.4 10 Jan 1997 4:52:50 patv -; Re-written to support C drive and eliminate restrictions on IPL.SYS -; -; Rev 1.3 29 Aug 1996 13:06:50 patv -; Bug fixes for v0.91b -; -; Rev 1.2 01 Sep 1995 17:56:44 patv -; First GPL release. -; -; Rev 1.1 30 Jul 1995 20:37:38 patv -; Initialized stack before use. -; -; Rev 1.0 02 Jul 1995 10:57:52 patv -; Initial revision. -; - ; +--------+ ; | | ; | | @@ -606,3 +528,67 @@ filename db "KERNEL SYS" times 0x01fe-$+$$ db 0 sign dw 0xAA55 + +; Log: boot.asm,v +; +; Revision 1.12 1999/09/25 06:42:18 jprice +; Optimize boot loader. Documentation. +; +; Revision 1.11 1999/09/24 19:04:55 jprice +; Added changes recommended by Jens Horstmeier + +; to make their bootable CD work. +; +; Revision 1.10 1999/09/23 04:39:02 jprice +; *** empty log message *** +; +; Revision 1.7 1999/04/23 03:43:46 jprice +; Ported to NASM by ror4 +; +; Revision 1.6 1999/04/17 19:14:03 jprice +; Fixed multi-sector code +; +; Revision 1.5 1999/04/17 06:23:26 jprice +; Changed so multi-sector IO is optional. +; +; Revision 1.4 1999/04/13 15:52:22 jprice +; Moves boot sector to top of mem +; +; Revision 1.3 1999/04/06 22:53:36 jprice +; Put back code to read multiple sectors at a time. +; +; Revision 1.2 1999/04/01 07:23:20 jprice +; New boot loader +; +; Revision 1.1.1.1 1999/03/29 15:39:39 jprice +; New version without IPL.SYS +; +; Revision 1.3 1999/03/02 06:57:14 jprice +; Added entry address for more recent versions of TLINK +; +; Revision 1.2 1999/01/21 05:03:58 jprice +; Formating. +; +; Revision 1.1.1.1 1999/01/20 05:51:00 jprice +; Imported sources +; +; +; Rev 1.5 10 Jan 1997 4:58:06 patv +; Corrected copyright +; +; Rev 1.4 10 Jan 1997 4:52:50 patv +; Re-written to support C drive and eliminate restrictions on IPL.SYS +; +; Rev 1.3 29 Aug 1996 13:06:50 patv +; Bug fixes for v0.91b +; +; Rev 1.2 01 Sep 1995 17:56:44 patv +; First GPL release. +; +; Rev 1.1 30 Jul 1995 20:37:38 patv +; Initialized stack before use. +; +; Rev 1.0 02 Jul 1995 10:57:52 patv +; Initial revision. +; + diff --git a/boot/makefile b/boot/makefile index 0aa3740f..b4dc6b3a 100644 --- a/boot/makefile +++ b/boot/makefile @@ -4,25 +4,28 @@ # $Id$ # -# $Log$ -# Revision 1.2 2001/11/13 23:36:45 bartoldeman -# Kernel 2025a final changes. -# -# Revision 1.1 2001/11/04 20:10:15 bartoldeman -# Added new makefile names, utils sources, kconfig.h -# -# Revision 1.4 2001/09/23 20:39:44 bartoldeman -# FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling -# -# Revision 1.3 2000/05/25 20:56:19 jimtabor -# Fixed project history -# -# Revision 1.2 2000/05/11 03:56:42 jimtabor -# Clean up and Release -# -# Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 -# The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with -# MS-DOS. Distributed under the GNU GPL. + +!include "..\mkfiles\generic.mak" + +production: b_fat12.bin b_fat16.bin b_fat32.bin + +b_fat12.bin: boot.asm + $(NASM) -dISFAT12 boot.asm -ob_fat12.bin + +b_fat16.bin: boot.asm + $(NASM) -dISFAT16 boot.asm -ob_fat16.bin + +b_fat32.bin: boot32.asm + $(NASM) boot32.asm -ob_fat32.bin + +clobber: clean + -$(RM) b_fat12.bin b_fat16.bin b_fat32.bin status.me + +clean: + -$(RM) *.lst *.map *.bak *.obj + + +# Log: makefile,v # # Revision 1.3 1999/04/23 03:44:17 jprice # Ported to NASM by ror4. Improvements @@ -55,24 +58,3 @@ # Rev 1.0 02 Jul 1995 9:11:26 patv #Initial revision. # - -!include "..\mkfiles\generic.mak" - -production: b_fat12.bin b_fat16.bin b_fat32.bin - -b_fat12.bin: boot.asm - $(NASM) -dISFAT12 boot.asm -ob_fat12.bin - -b_fat16.bin: boot.asm - $(NASM) -dISFAT16 boot.asm -ob_fat16.bin - -b_fat32.bin: boot32.asm - $(NASM) boot32.asm -ob_fat32.bin - -clobber: clean - -$(RM) b_fat12.bin b_fat16.bin b_fat32.bin status.me - -clean: - -$(RM) *.lst *.map *.bak *.obj - - diff --git a/build.bat b/build.bat index ed546bf1..c4686014 100644 --- a/build.bat +++ b/build.bat @@ -4,54 +4,6 @@ :- $Id$ -:- $Log$ -:- Revision 1.7 2001/11/13 23:36:43 bartoldeman -:- Kernel 2025a final changes. -:- -:- Revision 1.6 2001/11/04 19:47:37 bartoldeman -:- kernel 2025a changes: see history.txt -:- -:- Revision 1.5 2001/07/09 22:19:30 bartoldeman -:- LBA/FCB/FAT/SYS/Ctrl-C/ioctl fixes + memory savings -:- -:- Revision 1.4 2001/03/22 04:13:30 bartoldeman -:- Change LF to CR/LF in batch files. -:- -:- Revision 1.3 2000/05/25 20:56:19 jimtabor -:- Fixed project history -:- -:- Revision 1.2 2000/05/14 17:05:39 jimtabor -:- Cleanup CRs -:- -:- Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 -:- The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with -:- MS-DOS. Distributed under the GNU GPL. -:- -:- Revision 1.5 1999/08/25 03:59:14 jprice -:- New build batch files. -:- -:- Revision 1.4 1999/08/25 03:38:16 jprice -:- New build config -:- -:- Revision 1.3 1999/04/23 03:46:02 jprice -:- Improved by jprice -:- -:- Revision 1.2 1999/04/17 19:13:29 jprice -:- ror4 patches -:- -:- Revision 1.1.1.1 1999/03/29 15:39:13 jprice -:- New version without IPL.SYS -:- -:- Revision 1.5 1999/02/09 04:47:54 jprice -:- Make makefile use common config.mak file -:- -:- Revision 1.4 1999/01/30 08:29:10 jprice -:- Clean up -:- -:- Revision 1.3 1999/01/30 07:49:16 jprice -:- Clean up -:- - set XERROR= @@ -66,7 +18,7 @@ set XERROR= call config.bat call getmake.bat -@if not \%XLINK% == \ goto link_set +@if not "%XLINK%" == "" goto link_set @if \%COMPILER% == \TC2 set XLINK=%TC2_BASE%\tlink /m/c @if \%COMPILER% == \TURBOCPP set XLINK=%TP1_BASE%\bin\tlink /m/c @@ -165,6 +117,13 @@ cd .. set XERROR=1 :end :***** cleanup ****** +@echo off + +@if "%OLDPATH%" == "" goto no_path_change +@set PATH=%OLDPATH% +@set OLDPATH= +:no_path_change + @set MAKE= @set COMPILER= @set XCPU= @@ -175,4 +134,33 @@ set XERROR=1 @set TC3_BASE= @set BC5_BASE= @set MS_BASE= +@set XNASM= +@set XERROR= + +:- Log: build.bat,v +:- +:- Revision 1.5 1999/08/25 03:59:14 jprice +:- New build batch files. +:- +:- Revision 1.4 1999/08/25 03:38:16 jprice +:- New build config +:- +:- Revision 1.3 1999/04/23 03:46:02 jprice +:- Improved by jprice +:- +:- Revision 1.2 1999/04/17 19:13:29 jprice +:- ror4 patches +:- +:- Revision 1.1.1.1 1999/03/29 15:39:13 jprice +:- New version without IPL.SYS +:- +:- Revision 1.5 1999/02/09 04:47:54 jprice +:- Make makefile use common config.mak file +:- +:- Revision 1.4 1999/01/30 08:29:10 jprice +:- Clean up +:- +:- Revision 1.3 1999/01/30 07:49:16 jprice +:- Clean up +:- diff --git a/clean.bat b/clean.bat index b5df82e7..c6af6d17 100644 --- a/clean.bat +++ b/clean.bat @@ -4,42 +4,6 @@ rem batch file to clean everything rem $Id$ -rem $Log$ -rem Revision 1.6 2001/11/13 23:36:43 bartoldeman -rem Kernel 2025a final changes. -rem -rem Revision 1.5 2001/11/04 19:47:37 bartoldeman -rem kernel 2025a changes: see history.txt -rem -rem Revision 1.4 2001/03/22 04:13:30 bartoldeman -rem Change LF to CR/LF in batch files. -rem -rem Revision 1.3 2000/05/25 20:56:19 jimtabor -rem Fixed project history -rem -rem Revision 1.2 2000/05/14 17:05:58 jimtabor -rem Cleanup CRs -rem -rem Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 -rem The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with -rem MS-DOS. Distributed under the GNU GPL. -rem -rem Revision 1.3 1999/08/25 03:59:14 jprice -rem New build batch files. -rem -rem Revision 1.2 1999/04/23 03:46:02 jprice -rem Improved by jprice -rem -rem Revision 1.1.1.1 1999/03/29 15:39:15 jprice -rem New version without IPL.SYS -rem -rem Revision 1.4 1999/02/09 04:47:54 jprice -rem Make makefile use common config.mak file -rem -rem Revision 1.3 1999/01/30 08:29:10 jprice -rem Clean up -rem - if not exist config.bat goto noconfigbat goto start @@ -79,3 +43,20 @@ del *.bak :end set MAKE= set COMPILER= + +rem Log: clean.bat,v +rem Revision 1.3 1999/08/25 03:59:14 jprice +rem New build batch files. +rem +rem Revision 1.2 1999/04/23 03:46:02 jprice +rem Improved by jprice +rem +rem Revision 1.1.1.1 1999/03/29 15:39:15 jprice +rem New version without IPL.SYS +rem +rem Revision 1.4 1999/02/09 04:47:54 jprice +rem Make makefile use common config.mak file +rem +rem Revision 1.3 1999/01/30 08:29:10 jprice +rem Clean up +rem diff --git a/clobber.bat b/clobber.bat index e4312724..9fd173c6 100644 --- a/clobber.bat +++ b/clobber.bat @@ -3,36 +3,6 @@ rem batch file to clobber everything rem $Id$ -rem $Log$ -rem Revision 1.6 2001/11/13 23:36:43 bartoldeman -rem Kernel 2025a final changes. -rem -rem Revision 1.5 2001/11/04 19:47:37 bartoldeman -rem kernel 2025a changes: see history.txt -rem -rem Revision 1.4 2001/03/22 04:13:30 bartoldeman -rem Change LF to CR/LF in batch files. -rem -rem Revision 1.3 2000/05/25 20:56:19 jimtabor -rem Fixed project history -rem -rem Revision 1.2 2000/05/14 17:06:17 jimtabor -rem Cleanup CRs -rem -rem Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 -rem The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with -rem MS-DOS. Distributed under the GNU GPL. -rem -rem Revision 1.3 1999/08/25 03:59:14 jprice -rem New build batch files. -rem -rem Revision 1.2 1999/08/10 18:34:06 jprice -rem case -rem -rem Revision 1.1 1999/04/23 03:47:19 jprice -rem Initial include -rem - if not exist config.bat goto noconfigbat goto start @@ -74,3 +44,16 @@ del status.me :end set MAKE= set COMPILER= + +rem Log: clobber.bat,v +rem +rem Revision 1.3 1999/08/25 03:59:14 jprice +rem New build batch files. +rem +rem Revision 1.2 1999/08/10 18:34:06 jprice +rem case +rem +rem Revision 1.1 1999/04/23 03:47:19 jprice +rem Initial include +rem + diff --git a/config.b b/config.b index 0b086a28..029dcc32 100644 --- a/config.b +++ b/config.b @@ -68,6 +68,8 @@ set TC2_BASE=c:\tc201 :- Turbo C++ 1.01 and higher TLINK 3.01+ are ok :- or get TLINK 4 (creates nice map file) from simtel at :- ftp://ftp.simtel.net/pub/simtelnet/msdos/borland/tlink4.zip +:- +:- WARNING TLINK needs to be in your PATH! :-********************************************************************** :- Turbo Link @@ -75,6 +77,10 @@ set TC2_BASE=c:\tc201 :- Microsoft Link :- set XLINK=%MS_BASE%\bin\link /ONERROR:NOEXE /ma /nologo +:- set path for Turbo Link - use OLDPATH to restore normal path +:- set OLDPATH=%PATH% +:- set PATH=%PATH%;%TC2_BASE% + :********************************************************************** :* optionally define your MAKE type here, if not then :* it will be automatically determined, pick one of them @@ -108,37 +114,7 @@ set XFAT=16 :- :- $Id$ :- -:- $Log$ -:- Revision 1.5 2001/11/13 23:36:43 bartoldeman -:- Kernel 2025a final changes. -:- -:- Revision 1.9 2001/11/04 19:47:37 bartoldeman -:- kernel 2025a changes: see history.txt -:- -:- Revision 1.8 2001/09/23 20:39:43 bartoldeman -:- FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling -:- -:- Revision 1.7 2001/04/16 14:36:56 bartoldeman -:- Added ALLCFLAGS for compiler option configuration. -:- -:- Revision 1.6 2001/04/15 03:21:49 bartoldeman -:- See history.txt for the list of fixes. -:- -:- Revision 1.5 2001/03/22 10:51:04 bartoldeman -:- Suggest to extract F_SCOPY into libm.lib for Borland C++. -:- -:- Revision 1.4 2001/03/19 04:50:56 bartoldeman -:- See history.txt for overview: put kernel 2022beo1 into CVS -:- -:- Revision 1.3 2000/05/25 20:56:19 jimtabor -:- Fixed project history -:- -:- Revision 1.2 2000/05/14 17:07:07 jimtabor -:- Cleanup CRs -:- -:- Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 -:- The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with -:- MS-DOS. Distributed under the GNU GPL. +:- Log: config.b,v :- :- Revision 1.3 1999/09/13 20:40:17 jprice :- Added COMPILER variable @@ -148,5 +124,3 @@ set XFAT=16 :- :- Revision 1.1 1999/08/25 03:20:39 jprice :- ror4 patches to allow TC 2.01 compile. -:- -:- diff --git a/docs/build.txt b/docs/build.txt index 2e492f4f..e8752e3a 100644 --- a/docs/build.txt +++ b/docs/build.txt @@ -75,16 +75,8 @@ component. Study the makefile to better understand this. $Id$ -$Log$ -Revision 1.5 2001/11/04 19:47:39 bartoldeman -kernel 2025a changes: see history.txt - -Revision 1.4 2001/07/09 22:19:33 bartoldeman -LBA/FCB/FAT/SYS/Ctrl-C/ioctl fixes + memory savings - +Log: build.txt,v Revision 1.3 2000/08/15 03:42:17 jhall1 -update to the bugs.txt file to point the user to the bug database at - the FreeDOS web site (http://www.freedos.org/bugs) update to the build.txt file to remove references to the now-defunct web site at gcfl.net (John's old site). diff --git a/docs/history.txt b/docs/history.txt index 7aac7626..7d0d4ba7 100644 --- a/docs/history.txt +++ b/docs/history.txt @@ -1,5 +1,31 @@ +2001 Nov 17 - Build 2025b +-------- Bart Oldeman (bart@dosemu.org) ++ Changes Tom + * fix a few more batch file and makefile details + * fix problems with command line editing: F1 and right key + * string merging in dosnames.c + * optimizations for MSC ++ Changes Bart + * fix readblock problem not properly detecting EOF - it sometimes + returned an error where it should just report a short count. + Also fnp->f_offset==0 is not a special case for blockread + (neither should it be for write - but that'll be for later) + For both cases it's perfectly legal to do a seek first. + * fix writeblock not setting highwater to offset when doing a + truncate (count == 0) + * hopefully now really fix the floppy change problem - + dsk.c: getbpb() should query changeline BEFORE reading the BPB. + * fixed warnings from WATCOM compiler - one of them was in fact + a bug in fcbfns.c + * started big clean-up + - converted obsolete bcopy(), sncopy() and friends to memcpy(), + strncpy() etc. + - removed $Log entries that are also on the CVS server and + removed the $ so no new entries will be added in files. + indenting will be next - other fixes will be buried in diffs if + I do that now. 2001 Nov 12 - Build 2025a --------- Bart Oldeman (bart.oldeman@bristol.ac.uk) +-------- Bart Oldeman (bart@dosemu.org) + Changes Tom * initialize LBA parameter struct to 0's - some BIOSes don't fill in everything. Thanks to Bernd Blaauw's bug report. @@ -30,7 +56,7 @@ * cleaned up map_cluster and dir_read (bug fixed by Bart) * updated LFN API (in development, not used yet) 2001 Nov 4 - Build 2025a (test) --------- Bart Oldeman (bart.oldeman@bristol.ac.uk) +-------- Bart Oldeman (bart@dosemu.org) + Changes tom * config.sys processing: placing ? on the left side of '=' like ?device= or device ?= @@ -80,7 +106,7 @@ * more fatfs/fatdir clean-ups - now unnecessary fields dfull, dremote and dsize removed from fnodes. 2001 Sep 24 - Build 2025 --------- Bart Oldeman (bart.oldeman@bristol.ac.uk) +-------- Bart Oldeman (bart@dosemu.org) + Fixes Victor * More FAT32 fixes + Fixes Tom @@ -101,7 +127,7 @@ uses root (but only if source & destination drive are different). Fix printf to include count(ret) if copy can't write all requested bytes 2001 Sep 22 - Build 2025 (test) --------- Bart Oldeman (bart.oldeman@bristol.ac.uk) +-------- Bart Oldeman (bart@dosemu.org) + Added Victor * FAT32 support (credits to Martin Stromberg for boot32.asm optimizations) * Delete long file names if short file name given @@ -132,13 +158,13 @@ changed state). * attribute should be 8-bit fix 2001 Aug 19 - Build 2024/h --------- Bart Oldeman (bart.oldeman@bristol.ac.uk) +-------- Bart Oldeman (bart@dosemu.org) + fixes Bart * truename fixes (#580) * free space fixes (#249) * Ctrl-C/Ctrl-Break fix 2001 Aug 19 - Build 2024/g --------- Bart Oldeman (bart.oldeman@bristol.ac.uk) +-------- Bart Oldeman (bart@dosemu.org) + fixes Bart * set file time fixes * clock fixes @@ -151,7 +177,7 @@ + fixes Bart + Tom * fixed shsucdx /u unloading problem 2001 Jul 28 - Build 2024/f --------- Bart Oldeman (bart.oldeman@bristol.ac.uk) +-------- Bart Oldeman (bart@dosemu.org) + fixes Bart * fixed get current directory - MSCDEX works now (always) * initdisk.c correctly sets number of hidden sectors: necessary @@ -166,7 +192,7 @@ * various fatfs.c fixes and clean ups 2001 Jul 23 - Build 2024/e --------- Bart Oldeman (bart.oldeman@bristol.ac.uk) +-------- Bart Oldeman (bart@dosemu.org) + fixes Tom * dyninit allocation fix * various clean ups @@ -212,7 +238,7 @@ * fixed task.c 'LOADHIGH executables': minAlloc == maxAlloc = 0 and an fixed overwriting the MCB 2001 Jul 9 - Build 2024/d --------- Bart Oldeman (bart.oldeman@bristol.ac.uk) +-------- Bart Oldeman (bart@dosemu.org) + fixes Bart: * fixed Ctrl-C (Ctrl-S and Ctrl-Q still missing). * ioctl EOF fix (DJGPP less&gdb problem reported by Martin Stromberg) @@ -260,7 +286,7 @@ from 2001 May 21: Build2024L * moved initialization for DISK (partition scanning) to INIT_CODE 2001 Jun 2 - Build 2024 --------- Bart Oldeman (bart.oldeman@bristol.ac.uk) +-------- Bart Oldeman (bart@dosemu.org) + Fixes Tom: * small fixes again. * one possible cause for data corruption (BFR_VALID) detected @@ -279,7 +305,7 @@ from 2001 May 21: Build2024L * dos_mkdir tuned (was ~0.5 sec on 64K cluster partitions) 2001 Apr 29 - Build 2024 --------- Bart Oldeman (bart.oldeman@bristol.ac.uk) +-------- Bart Oldeman (bart@dosemu.org) + Fixes Bart: * fixed the "TYPE > FOO.TXT" poor man's editor. * use "fast console output" (int 29) when applicable. @@ -301,7 +327,7 @@ from 2001 May 21: Build2024L * fixed not ignoring whitespace after '=' in config.sys * noted INT21/AX=3800 bug for getting the country. Put in a workaround for now. 2001 Apr 21 - Build 2024 --------- Bart Oldeman (bart.oldeman@bristol.ac.uk) +-------- Bart Oldeman (bart@dosemu.org) + Fixes Tom: * fixed a missing close_dir in fatfs.c. * many reductions of stack space requirements. @@ -327,7 +353,7 @@ from 2001 May 21: Build2024L + Add Tom: * Default interrupt 6 handler (invalid opcode). 2001 Apr 16 - Build 2024 --------- Bart Oldeman (bart.oldeman@bristol.ac.uk) +-------- Bart Oldeman (bart@dosemu.org) + Fixes * Use turboc.cfg to avoid long command lines; edit ALLCFLAGS in config.mak to enable DEBUG etc. * Fixed critical error handler. @@ -335,7 +361,7 @@ from 2001 May 21: Build2024L * Some device drivers require \r\n at the end of their parameter line. 2001 Apr 16 - Build 2023 --------- Bart Oldeman (bart.oldeman@bristol.ac.uk) +-------- Bart Oldeman (bart@dosemu.org) + Fixes * Thanks to Martin Stromberg for pointing some bugs out: * more warnings fixed. * accidentally opened too many file handles at boot time. @@ -344,7 +370,7 @@ from 2001 May 21: Build2024L + Add * added printf "%S" and "%Fs" to print far strings. * enabled and cleaned up INT21/AH=6C (extended open/create). 2001 Apr 15 - Build 2023 --------- Bart Oldeman (bart.oldeman@bristol.ac.uk) +-------- Bart Oldeman (bart@dosemu.org) + Fixes Tom: * apisupt.asm not necessary anymore. * fix warnings. @@ -387,7 +413,7 @@ from 2001 May 21: Build2024L GWBASIC/BASICA 2001 Apr 2 - Build 2023 --------- Bart Oldeman (bart.oldeman@bristol.ac.uk) +-------- Bart Oldeman (bart@dosemu.org) + Fixes Bart: Volkov Commander revealed a few bugs: -int 21/ah=55 forgot to set current psp to child psp. -memory allocation: mem_access_mode was a signed byte, and hence 0x80 was @@ -413,7 +439,7 @@ from 2001 May 21: Build2024L drives. * Fixed bug wrt zero terminated device names (should be spaces terminated). 2001 Mar 30 - Build 2023 --------- Bart Oldeman (bart.oldeman@bristol.ac.uk) +-------- Bart Oldeman (bart@dosemu.org) + Fixes Tom: Kernel alloc initialises to 0. This avoids some weird errors. Implemented default divide by 0 handler (INT 0) FILES= fixes from config.sys. fatfs.c ignored it and always @@ -432,10 +458,10 @@ from 2001 May 21: Build2024L + Fixes Bug fix release 2023b: dsk.c (reported by Nagy Daniel), inthndlr and int25/26 fixes by Tom Ehlert. 2001 Mar 27 - Build 2023 --------- Bart Oldeman (bart.oldeman@bristol.ac.uk) +-------- Bart Oldeman (bart@dosemu.org) + Fixes Bug fix release 2023a: fixed stack segment bug in entry.asm. 2001 Mar 25 - Build 2023 --------- Bart Oldeman (bart.oldeman@bristol.ac.uk) +-------- Bart Oldeman (bart@dosemu.org) + Fixes sys.com compilation: it is a proper .com and works again. Suggestions from Martin Stromberg: warning removal and some debugging related changes. @@ -443,14 +469,14 @@ from 2001 May 21: Build2024L in config.sys. Also implemented strcasecmp. Updated intfns.txt; reported version is now 5.0. 2001 Mar 24 - Build 2022 --------- Bart Oldeman (bart.oldeman@bristol.ac.uk) +-------- Bart Oldeman (bart@dosemu.org) + Fixes Tom and Bart: cli/sti handling and other fixes in entry.asm, procsupt.asm and apisupt.asm. Bart: warning removal + other compile time fixes. Tom: * more partition detection fixes in dsk.c. * dos_gettime() fix. 2001 Mar 21 - Build 2022 --------- Bart Oldeman (bart.oldeman@bristol.ac.uk) +-------- Bart Oldeman (bart@dosemu.org) + Clean A lot of space savings by Tom Ehlert, merely because Turbo C 2.01 does not do it. And several more complicated situations as well, like coding some string functions in assembly (asmsupt.asm). @@ -475,7 +501,7 @@ from 2001 May 21: Build2024L + Fixes a few small ones from Tom I forgot. 2001 Mar 08 - Build 2022 --------- Bart Oldeman (bart.oldeman@bristol.ac.uk) +-------- Bart Oldeman (bart@dosemu.org) + Fixes MCB chain corruption fix (thanks Tom Ehlert and Martin Stromberg) Redirector fixes (CDROMs and DOSEmu lredir'ed drives appear to work fine now) UMB fixes @@ -492,7 +518,7 @@ from 2001 May 21: Build2024L 2000 Dec 15 - Build 2022 -------- James Tabor (jimtabor@infohwy.com) -+ Fixes Added Patches from Bart Oldeman (Bart.Oldeman@bristol.ac.uk) ++ Fixes Added Patches from Bart Oldeman (bart@dosemu.org) Fix for NLAST in globals.h and change default return in inthndlr.c. 2000 Oct 29 - Build 2022 @@ -540,7 +566,7 @@ from 2001 May 21: Build2024L 2000 Jun 20 - Build 2021 -------- James Tabor (jimtabor@infohwy.com) -+ Fix Bart Oldeman (Bart.Oldeman@bristol.ac.uk) found bugs with copy ++ Fix Bart Oldeman (bart@dosemu.org) found bugs with copy command using Dosemu Lredir. Fixed Dosfns return for ReadCount, WriteCount and DosGetFattr. Fixed the return in int2f.asm for Read/Write Remote. By adding xor ax,ax. diff --git a/docs/intfns.txt b/docs/intfns.txt index 9b6db7b6..d694952f 100644 --- a/docs/intfns.txt +++ b/docs/intfns.txt @@ -194,15 +194,7 @@ See COPYING in DOS-C root directory for license. $Id$ -$Log$ -Revision 1.4 2001/03/25 17:11:53 bartoldeman -Fixed sys.com compilation. Updated to 2023. Also: see history.txt. - -Revision 1.3 2000/05/09 00:29:50 jimtabor -Clean up and Release - -Revision 1.2 2000/05/08 04:27:48 jimtabor -Update CVS to 2020 +Log: intfns.txt,v Revision 1.2 2000/03/18 05:51:55 kernel changes in supported functions diff --git a/drivers/devend.asm b/drivers/devend.asm index 30031b17..8b12b8c3 100644 --- a/drivers/devend.asm +++ b/drivers/devend.asm @@ -25,27 +25,24 @@ ; write to the Free Software Foundation, 675 Mass Ave, ; Cambridge, MA 02139, USA. ; -; $Logfile: C:/dos-c/src/drivers/devend.asv $ -; ; $Header$ ; -; $Log$ -; Revision 1.5 2001/04/15 03:21:50 bartoldeman -; See history.txt for the list of fixes. -; -; Revision 1.4 2001/03/21 02:56:25 bartoldeman -; See history.txt for changes. Bug fixes and HMA support are the main ones. -; -; Revision 1.3 2000/05/25 20:56:19 jimtabor -; Fixed project history -; -; Revision 1.2 2000/05/11 03:56:20 jimtabor -; Clean up and Release -; -; Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 -; The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with -; MS-DOS. Distributed under the GNU GPL. -; + + %include "..\kernel\segs.inc" + + + extern __bssend:wrt DGROUP + +segment HMA_TEXT + + global _device_end + +_device_end: + mov ax,__bssend + mov dx,DGROUP + ret + +; Log: devend.asm,v ; Revision 1.3 1999/08/10 17:21:08 jprice ; ror4 2011-01 patch ; @@ -71,17 +68,3 @@ ; Rev 1.0 02 Jul 1995 7:56:50 patv ;Initial revision. ; - - %include "..\kernel\segs.inc" - - - extern __bssend:wrt DGROUP - -segment HMA_TEXT - - global _device_end - -_device_end: - mov ax,__bssend - mov dx,DGROUP - ret diff --git a/drivers/floppy.asm b/drivers/floppy.asm index 1fb4de43..ca7bb1e5 100644 --- a/drivers/floppy.asm +++ b/drivers/floppy.asm @@ -25,79 +25,8 @@ ; write to the Free Software Foundation, 675 Mass Ave, ; Cambridge, MA 02139, USA. ; -; $Logfile: C:/usr/patv/dos-c/src/drivers/floppy.asv $ -; ; $Id$ ; -; $Log$ -; Revision 1.9 2001/11/04 19:47:39 bartoldeman -; kernel 2025a changes: see history.txt -; -; Revision 1.8 2001/09/23 20:39:44 bartoldeman -; FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling -; -; Revision 1.7 2001/07/09 22:19:33 bartoldeman -; LBA/FCB/FAT/SYS/Ctrl-C/ioctl fixes + memory savings -; -; -; Revision 1.7 2001/04/29 brianreifsnyder -; Added phase 1 support for LBA hard drives -; -; Revision 1.6 2001/04/22 01:19:33 bartoldeman -; Avoid sys warning and have a VDISK signature in the HMA -; -; Revision 1.5 2001/04/15 03:21:50 bartoldeman -; See history.txt for the list of fixes. -; -; Revision 1.4 2001/03/21 02:56:25 bartoldeman -; See history.txt for changes. Bug fixes and HMA support are the main ones. -; -; Revision 1.3 2000/05/25 20:56:19 jimtabor -; Fixed project history -; -; Revision 1.2 2000/05/11 03:56:20 jimtabor -; Clean up and Release -; -; Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 -; The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with -; MS-DOS. Distributed under the GNU GPL. -; -; Revision 1.4 1999/08/10 17:21:08 jprice -; ror4 2011-01 patch -; -; Revision 1.3 1999/04/16 21:29:17 jprice -; ror4 multi-sector IO -; -; Revision 1.2 1999/03/29 17:08:31 jprice -; ror4 changes -; -; Revision 1.1.1.1 1999/03/29 15:40:24 jprice -; New version without IPL.SYS -; -; Revision 1.4 1999/02/14 04:25:16 jprice -; Added functions to check if a floppy disk has been changed. -; -; Revision 1.3 1999/02/08 05:49:47 jprice -; Added Pat's 1937 kernel patches -; -; Revision 1.2 1999/01/22 04:16:39 jprice -; Formating -; -; Revision 1.1.1.1 1999/01/20 05:51:00 jprice -; Imported sources -; -; Rev 1.3 06 Dec 1998 8:43:00 patv -;New floppy support functions. -; -; Rev 1.2 29 Aug 1996 13:07:14 patv -;Bug fixes for v0.91b -; -; Rev 1.1 01 Sep 1995 18:50:34 patv -;Initial GPL release. -; -; Rev 1.0 02 Jul 1995 7:57:02 patv -;Initial revision. -; %ifndef SYS %include "..\kernel\segs.inc" @@ -521,3 +450,41 @@ skipint1e: ret +; Log: floppy.asm,v +; +; Revision 1.4 1999/08/10 17:21:08 jprice +; ror4 2011-01 patch +; +; Revision 1.3 1999/04/16 21:29:17 jprice +; ror4 multi-sector IO +; +; Revision 1.2 1999/03/29 17:08:31 jprice +; ror4 changes +; +; Revision 1.1.1.1 1999/03/29 15:40:24 jprice +; New version without IPL.SYS +; +; Revision 1.4 1999/02/14 04:25:16 jprice +; Added functions to check if a floppy disk has been changed. +; +; Revision 1.3 1999/02/08 05:49:47 jprice +; Added Pat's 1937 kernel patches +; +; Revision 1.2 1999/01/22 04:16:39 jprice +; Formating +; +; Revision 1.1.1.1 1999/01/20 05:51:00 jprice +; Imported sources +; +; Rev 1.3 06 Dec 1998 8:43:00 patv +;New floppy support functions. +; +; Rev 1.2 29 Aug 1996 13:07:14 patv +;Bug fixes for v0.91b +; +; Rev 1.1 01 Sep 1995 18:50:34 patv +;Initial GPL release. +; +; Rev 1.0 02 Jul 1995 7:57:02 patv +;Initial revision. +; diff --git a/drivers/getvec.asm b/drivers/getvec.asm index 73a7aaf1..3821d7d2 100644 --- a/drivers/getvec.asm +++ b/drivers/getvec.asm @@ -25,22 +25,38 @@ ; write to the Free Software Foundation, 675 Mass Ave, ; Cambridge, MA 02139, USA. ; -; $Logfile: C:/dos-c/src/drivers/getvec.asv $ -; ; $Header$ ; -; $Log$ -; Revision 1.5 2001/04/15 03:21:50 bartoldeman -; See history.txt for the list of fixes. -; -; Revision 1.4 2001/03/21 02:56:25 bartoldeman -; See history.txt for changes. Bug fixes and HMA support are the main ones. + + %include "..\kernel\segs.inc" + +segment HMA_TEXT + + global _getvec +_getvec: + mov bx,sp + mov ax,[ss:bx+2] + ; -; Revision 1.3 2000/05/25 20:56:19 jimtabor -; Fixed project history +; assembler version - ax = vector number +; returns vector in dx:ax ; -; Revision 1.2 2000/05/11 03:56:20 jimtabor -; Clean up and Release + + global getvec +getvec: + shl ax,1 ; Multiply by 4 + shl ax,1 + xor dx,dx ; and set segment to 0 + mov es,dx + mov bx,ax + pushf ; Push flags + cli ; Disable interrupts + mov ax,[es:bx] + mov dx,[es:bx+2] + popf ; Pop flags + ret + +; Log: getvec.asm,v ; ; Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 ; The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with @@ -71,31 +87,3 @@ ; Rev 1.0 02 Jul 1995 8:00:36 patv ;Initial revision. ; - - %include "..\kernel\segs.inc" - -segment HMA_TEXT - - global _getvec -_getvec: - mov bx,sp - mov ax,[ss:bx+2] - -; -; assembler version - ax = vector number -; returns vector in dx:ax -; - - global getvec -getvec: - shl ax,1 ; Multiply by 4 - shl ax,1 - xor dx,dx ; and set segment to 0 - mov es,dx - mov bx,ax - pushf ; Push flags - cli ; Disable interrupts - mov ax,[es:bx] - mov dx,[es:bx+2] - popf ; Pop flags - ret diff --git a/drivers/makefile b/drivers/makefile index cfae1a19..17f28055 100644 --- a/drivers/makefile +++ b/drivers/makefile @@ -4,60 +4,6 @@ # $Id$ # -# $Log$ -# Revision 1.2 2001/11/13 23:36:45 bartoldeman -# Kernel 2025a final changes. -# -# Revision 1.1 2001/11/04 20:10:15 bartoldeman -# Added new makefile names, utils sources, kconfig.h -# -# Revision 1.3 2000/05/25 20:56:19 jimtabor -# Fixed project history -# -# Revision 1.2 2000/05/11 03:56:20 jimtabor -# Clean up and Release -# -# Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 -# The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with -# MS-DOS. Distributed under the GNU GPL. -# -# Revision 1.6 1999/08/25 03:16:36 jprice -# ror4 patches to allow TC 2.01 compile. -# -# Revision 1.5 1999/08/10 17:21:08 jprice -# ror4 2011-01 patch -# -# Revision 1.4 1999/04/23 03:44:52 jprice -# Improved by jprice -# -# Revision 1.3 1999/04/13 15:47:07 jprice -# no message -# -# Revision 1.2 1999/03/29 17:08:31 jprice -# ror4 changes -# -# Revision 1.1.1.1 1999/03/29 15:40:23 jprice -# New version without IPL.SYS -# -# Revision 1.3 1999/02/09 04:49:25 jprice -# Make makefile use common config.mak file -# -# Revision 1.2 1999/01/22 04:16:39 jprice -# Formating -# -# Revision 1.1.1.1 1999/01/20 05:51:00 jprice -# Imported sources -# -# -# Rev 1.2 29 Aug 1996 13:07:12 patv -#Bug fixes for v0.91b -# -# Rev 1.1 19 Feb 1996 3:19:26 patv -#Added NLS, int2f and config.sys processing -# -# Rev 1.0 02 Jul 1995 7:54:52 patv -#Initial revision. -# !include "..\mkfiles\generic.mak" @@ -101,3 +47,43 @@ clean: device.lib : $(OBJS) -$(RM) device.lib $(LIBUTIL) $(LIBFLAGS) device $(LIBOBJS) $(LIBTERM) + +# Log: makefile,v +# +# Revision 1.6 1999/08/25 03:16:36 jprice +# ror4 patches to allow TC 2.01 compile. +# +# Revision 1.5 1999/08/10 17:21:08 jprice +# ror4 2011-01 patch +# +# Revision 1.4 1999/04/23 03:44:52 jprice +# Improved by jprice +# +# Revision 1.3 1999/04/13 15:47:07 jprice +# no message +# +# Revision 1.2 1999/03/29 17:08:31 jprice +# ror4 changes +# +# Revision 1.1.1.1 1999/03/29 15:40:23 jprice +# New version without IPL.SYS +# +# Revision 1.3 1999/02/09 04:49:25 jprice +# Make makefile use common config.mak file +# +# Revision 1.2 1999/01/22 04:16:39 jprice +# Formating +# +# Revision 1.1.1.1 1999/01/20 05:51:00 jprice +# Imported sources +# +# +# Rev 1.2 29 Aug 1996 13:07:12 patv +#Bug fixes for v0.91b +# +# Rev 1.1 19 Feb 1996 3:19:26 patv +#Added NLS, int2f and config.sys processing +# +# Rev 1.0 02 Jul 1995 7:54:52 patv +#Initial revision. +# diff --git a/drivers/rdatclk.asm b/drivers/rdatclk.asm index 73391587..ed0766bf 100644 --- a/drivers/rdatclk.asm +++ b/drivers/rdatclk.asm @@ -25,39 +25,9 @@ ; write to the Free Software Foundation, 675 Mass Ave, ; Cambridge, MA 02139, USA. ; -; @Logfile: C:/dos-c/src/drivers/rdatclk.asv @ +; Logfile: C:/dos-c/src/drivers/rdatclk.asv ; -; @Header: /home/cvsroot/fdkernel/DRIVERS/RDATCLK.ASM,v 1.3 1999/04/12 03:19:44 jprice Exp @ -; -; @Log: rdatclk.asm,v @ -; Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 -; The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with -; MS-DOS. Distributed under the GNU GPL. -; -; Revision 1.3 1999/04/12 03:19:44 jprice -; more ror4 patches -; -; Revision 1.2 1999/03/29 17:08:31 jprice -; ror4 changes -; -; Revision 1.1.1.1 1999/03/29 15:40:31 jprice -; New version without IPL.SYS -; -; Revision 1.2 1999/01/22 04:16:39 jprice -; Formating -; -; Revision 1.1.1.1 1999/01/20 05:51:00 jprice -; Imported sources -; -; -; Rev 1.2 29 Aug 1996 13:07:10 patv -;Bug fixes for v0.91b -; -; Rev 1.1 01 Sep 1995 18:50:40 patv -;Initial GPL release. -; -; Rev 1.0 02 Jul 1995 8:00:16 patv -;Initial revision. +; $Header$ ; %include "..\kernel\segs.inc" @@ -114,3 +84,31 @@ _ReadATClock: sub ax,ax pop bp ret + +; Log: rdatclk.asm,v +; +; Revision 1.3 1999/04/12 03:19:44 jprice +; more ror4 patches +; +; Revision 1.2 1999/03/29 17:08:31 jprice +; ror4 changes +; +; Revision 1.1.1.1 1999/03/29 15:40:31 jprice +; New version without IPL.SYS +; +; Revision 1.2 1999/01/22 04:16:39 jprice +; Formating +; +; Revision 1.1.1.1 1999/01/20 05:51:00 jprice +; Imported sources +; +; +; Rev 1.2 29 Aug 1996 13:07:10 patv +;Bug fixes for v0.91b +; +; Rev 1.1 01 Sep 1995 18:50:40 patv +;Initial GPL release. +; +; Rev 1.0 02 Jul 1995 8:00:16 patv +;Initial revision. +; diff --git a/drivers/rdpcclk.asm b/drivers/rdpcclk.asm index 12b52a89..29d71fd6 100644 --- a/drivers/rdpcclk.asm +++ b/drivers/rdpcclk.asm @@ -25,27 +25,29 @@ ; write to the Free Software Foundation, 675 Mass Ave, ; Cambridge, MA 02139, USA. ; -; $Logfile: C:/dos-c/src/drivers/rdpcclk.asv $ -; ; $Header$ ; -; $Log$ -; Revision 1.5 2001/04/15 03:21:50 bartoldeman -; See history.txt for the list of fixes. -; -; Revision 1.4 2001/03/21 02:56:25 bartoldeman -; See history.txt for changes. Bug fixes and HMA support are the main ones. -; -; Revision 1.3 2000/05/25 20:56:19 jimtabor -; Fixed project history -; -; Revision 1.2 2000/05/11 03:56:20 jimtabor -; Clean up and Release + + %include "..\kernel\segs.inc" + +segment HMA_TEXT + ; -; Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 -; The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with -; MS-DOS. Distributed under the GNU GPL. +; BOOL ReadPCClock(Ticks) +; ULONG *Ticks; ; + global _ReadPCClock +_ReadPCClock: + xor ah,ah + int 1ah + mov bx,sp + mov bx,[bx+2] + mov [bx],dx + mov [bx+2],cx + cbw + ret + +; Log: rdpcclk.asm,v ; Revision 1.4 1999/08/10 17:21:08 jprice ; ror4 2011-01 patch ; @@ -74,23 +76,3 @@ ; Rev 1.0 02 Jul 1995 8:00:26 patv ;Initial revision. ; - - %include "..\kernel\segs.inc" - - -segment HMA_TEXT - -; -; BOOL ReadPCClock(Ticks) -; ULONG *Ticks; -; - global _ReadPCClock -_ReadPCClock: - xor ah,ah - int 1ah - mov bx,sp - mov bx,[bx+2] - mov [bx],dx - mov [bx+2],cx - cbw - ret diff --git a/drivers/timer.asm b/drivers/timer.asm index 757eb955..849272c0 100644 --- a/drivers/timer.asm +++ b/drivers/timer.asm @@ -25,51 +25,7 @@ ; write to the Free Software Foundation, 675 Mass Ave, ; Cambridge, MA 02139, USA. ; -; $Logfile: C:/dos-c/src/drivers/timer.asv $ -; ; $Header$ -; -; $Log$ -; Revision 1.5 2001/04/15 03:21:50 bartoldeman -; See history.txt for the list of fixes. -; -; Revision 1.4 2001/03/21 02:56:25 bartoldeman -; See history.txt for changes. Bug fixes and HMA support are the main ones. -; -; Revision 1.3 2000/05/25 20:56:19 jimtabor -; Fixed project history -; -; Revision 1.2 2000/05/11 03:56:20 jimtabor -; Clean up and Release -; -; Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 -; The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with -; MS-DOS. Distributed under the GNU GPL. -; -; Revision 1.3 1999/08/10 17:21:08 jprice -; ror4 2011-01 patch -; -; Revision 1.2 1999/03/29 17:08:31 jprice -; ror4 changes -; -; Revision 1.1.1.1 1999/03/29 15:40:34 jprice -; New version without IPL.SYS -; -; Revision 1.2 1999/01/22 04:16:39 jprice -; Formating -; -; Revision 1.1.1.1 1999/01/20 05:51:00 jprice -; Imported sources -; -; -; Rev 1.2 29 Aug 1996 13:07:12 patv -;Bug fixes for v0.91b -; -; Rev 1.1 01 Sep 1995 18:50:42 patv -;Initial GPL release. -; -; Rev 1.0 02 Jul 1995 8:01:04 patv -;Initial revision. ; %include "..\kernel\segs.inc" @@ -159,3 +115,30 @@ twait_2: segment _BSS LastTime: resd 1 + +; Log: timer.asm,v +; Revision 1.3 1999/08/10 17:21:08 jprice +; ror4 2011-01 patch +; +; Revision 1.2 1999/03/29 17:08:31 jprice +; ror4 changes +; +; Revision 1.1.1.1 1999/03/29 15:40:34 jprice +; New version without IPL.SYS +; +; Revision 1.2 1999/01/22 04:16:39 jprice +; Formating +; +; Revision 1.1.1.1 1999/01/20 05:51:00 jprice +; Imported sources +; +; +; Rev 1.2 29 Aug 1996 13:07:12 patv +;Bug fixes for v0.91b +; +; Rev 1.1 01 Sep 1995 18:50:42 patv +;Initial GPL release. +; +; Rev 1.0 02 Jul 1995 8:01:04 patv +;Initial revision. +; diff --git a/drivers/wratclk.asm b/drivers/wratclk.asm index c9316769..1c59d74d 100644 --- a/drivers/wratclk.asm +++ b/drivers/wratclk.asm @@ -25,51 +25,7 @@ ; write to the Free Software Foundation, 675 Mass Ave, ; Cambridge, MA 02139, USA. ; -; $Logfile: C:/dos-c/src/drivers/wratclk.asv $ -; ; $Header$ -; -; $Log$ -; Revision 1.5 2001/04/15 03:21:50 bartoldeman -; See history.txt for the list of fixes. -; -; Revision 1.4 2001/03/21 02:56:25 bartoldeman -; See history.txt for changes. Bug fixes and HMA support are the main ones. -; -; Revision 1.3 2000/05/25 20:56:19 jimtabor -; Fixed project history -; -; Revision 1.2 2000/05/11 03:56:20 jimtabor -; Clean up and Release -; -; Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 -; The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with -; MS-DOS. Distributed under the GNU GPL. -; -; Revision 1.3 1999/08/10 17:21:08 jprice -; ror4 2011-01 patch -; -; Revision 1.2 1999/03/29 17:08:31 jprice -; ror4 changes -; -; Revision 1.1.1.1 1999/03/29 15:40:34 jprice -; New version without IPL.SYS -; -; Revision 1.2 1999/01/22 04:16:40 jprice -; Formating -; -; Revision 1.1.1.1 1999/01/20 05:51:00 jprice -; Imported sources -; -; -; Rev 1.2 29 Aug 1996 13:07:12 patv -;Bug fixes for v0.91b -; -; Rev 1.1 01 Sep 1995 18:50:42 patv -;Initial GPL release. -; -; Rev 1.0 02 Jul 1995 8:01:18 patv -;Initial revision. ; %include "..\kernel\segs.inc" @@ -104,3 +60,31 @@ _WriteATClock: int 1ah pop bp ret + +; Log: wratclk.asm,v +; +; Revision 1.3 1999/08/10 17:21:08 jprice +; ror4 2011-01 patch +; +; Revision 1.2 1999/03/29 17:08:31 jprice +; ror4 changes +; +; Revision 1.1.1.1 1999/03/29 15:40:34 jprice +; New version without IPL.SYS +; +; Revision 1.2 1999/01/22 04:16:40 jprice +; Formating +; +; Revision 1.1.1.1 1999/01/20 05:51:00 jprice +; Imported sources +; +; +; Rev 1.2 29 Aug 1996 13:07:12 patv +;Bug fixes for v0.91b +; +; Rev 1.1 01 Sep 1995 18:50:42 patv +;Initial GPL release. +; +; Rev 1.0 02 Jul 1995 8:01:18 patv +;Initial revision. +; diff --git a/drivers/wrpcclk.asm b/drivers/wrpcclk.asm index bd5a4fb8..989de394 100644 --- a/drivers/wrpcclk.asm +++ b/drivers/wrpcclk.asm @@ -25,26 +25,28 @@ ; write to the Free Software Foundation, 675 Mass Ave, ; Cambridge, MA 02139, USA. ; -; $Logfile: C:/dos-c/src/drivers/wrpcclk.asv $ -; ; $Header$ ; -; $Log$ -; Revision 1.5 2001/04/15 03:21:50 bartoldeman -; See history.txt for the list of fixes. -; -; Revision 1.4 2001/03/21 02:56:25 bartoldeman -; See history.txt for changes. Bug fixes and HMA support are the main ones. -; -; Revision 1.3 2000/05/25 20:56:19 jimtabor -; Fixed project history + %include "..\kernel\segs.inc" + +segment HMA_TEXT + + ; -; Revision 1.2 2000/05/11 03:56:20 jimtabor -; Clean up and Release +; VOID WritePCClock(Ticks) +; ULONG Ticks; ; -; Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 -; The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with -; MS-DOS. Distributed under the GNU GPL. + global _WritePCClock +_WritePCClock: + mov bx,sp +; Ticks = 4 + mov cx,word [ss:bx+4] + mov dx,word [ss:bx+2] ;Ticks + mov ah,1 + int 1ah + ret + +; Log: wrpcclk.asm,v ; ; Revision 1.3 1999/08/10 17:21:08 jprice ; ror4 2011-01 patch @@ -71,21 +73,3 @@ ; Rev 1.0 02 Jul 1995 8:01:30 patv ;Initial revision. ; - %include "..\kernel\segs.inc" - -segment HMA_TEXT - - -; -; VOID WritePCClock(Ticks) -; ULONG Ticks; -; - global _WritePCClock -_WritePCClock: - mov bx,sp -; Ticks = 4 - mov cx,word [ss:bx+4] - mov dx,word [ss:bx+2] ;Ticks - mov ah,1 - int 1ah - ret diff --git a/fdkernel.lsm b/fdkernel.lsm index 839365d0..3492e897 100644 --- a/fdkernel.lsm +++ b/fdkernel.lsm @@ -1,11 +1,11 @@ Begin3 Title: The FreeDOS Kernel -Version: 1.1.25 -Entered-date: 26 Sep 2001 +Version: 2.0.25.b +Entered-date: 17 Nov 2001 Description: The FreeDOS Kernel. Keywords: kernel freedos dos msdos Author: (developers) -Maintained-by: bart.oldeman@bristol.ac.uk +Maintained-by: bart@dosemu.org Primary-site: http://freedos.sourceforge.net Alternate-site: www.dosemu.org/~bart Original-site: http://www.gcfl.net/pub/FreeDOS/kernel diff --git a/getmake.bat b/getmake.bat index 25c9c0b0..ca53831e 100644 --- a/getmake.bat +++ b/getmake.bat @@ -1,4 +1,4 @@ -@if not \%MAKE% == \ goto make_set +@if not "%MAKE%" == "" goto make_set @if \%COMPILER% == \TC2 set MAKE=%TC2_BASE%\make @if \%COMPILER% == \TURBOCPP set MAKE=%TP1_BASE%\bin\make diff --git a/hdr/buffer.h b/hdr/buffer.h index b7f1ec43..20cc7d28 100644 --- a/hdr/buffer.h +++ b/hdr/buffer.h @@ -36,27 +36,6 @@ static BYTE *buffer_hRcsId = "$Id$"; #endif #endif -/* - * $Log$ - * Revision 1.5 2001/09/23 20:39:44 bartoldeman - * FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling - * - * Revision 1.4 2001/08/19 12:58:34 bartoldeman - * Time and date fixes, Ctrl-S/P, findfirst/next, FCBs, buffers, tsr unloading - * - * Revision 1.3 2001/07/24 16:56:29 bartoldeman - * fixes for FCBs, DJGPP ls, DBLBYTE, dyninit allocation (2024e). - * - * Revision 1.2 2001/06/03 14:16:17 bartoldeman - * BUFFERS tuning and misc bug fixes/cleanups (2024c). - * - * Revision 1.1 2001/04/21 22:32:53 bartoldeman - * Init DS=Init CS, fixed stack overflow problems and misc bugs. - * - * Rev 1.0 20 Apr 2001 17:30:00 Bart Oldeman - * Initial revision. - */ - #define BUFFERSIZE 512 struct buffer { @@ -94,3 +73,10 @@ struct buffer #define BFR_DIR 0x04 /* buffer is from dir area */ #define BFR_FAT 0x02 /* buffer is from fat area */ #define BFR_BOOT 0x01 /* buffer is boot disk */ + +/* + * Log: buffer.h,v + * Rev 1.0 20 Apr 2001 17:30:00 Bart Oldeman + * Initial revision. + */ + diff --git a/hdr/cds.h b/hdr/cds.h index dba497ed..0af52695 100644 --- a/hdr/cds.h +++ b/hdr/cds.h @@ -32,50 +32,6 @@ static BYTE *Cds_hRcsId = "$Id$"; #endif #endif -/* - * $Log$ - * Revision 1.5 2001/11/04 19:47:39 bartoldeman - * kernel 2025a changes: see history.txt - * - * Revision 1.4 2001/04/15 03:21:50 bartoldeman - * See history.txt for the list of fixes. - * - * Revision 1.3 2000/05/25 20:56:19 jimtabor - * Fixed project history - * - * Revision 1.2 2000/05/08 04:28:22 jimtabor - * Update CVS to 2020 - * - * Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 - * The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with - * MS-DOS. Distributed under the GNU GPL. - * - * Revision 1.2 2000/03/09 06:06:38 kernel - * 2017f updates by James Tabor - * - * Revision 1.1.1.1 1999/03/29 15:39:22 jprice - * New version without IPL.SYS - * - * Revision 1.4 1999/02/01 01:40:06 jprice - * Clean up - * - * Revision 1.3 1999/01/30 08:21:43 jprice - * Clean up - * - * Revision 1.2 1999/01/22 04:17:40 jprice - * Formating - * - * Revision 1.1.1.1 1999/01/20 05:51:01 jprice - * Imported sources - * - - Rev 1.1 04 Jan 1998 23:14:18 patv - Changed Log for strip utility - - Rev 1.0 19 Feb 1996 3:15:52 patv - Added NLS, int2f and config.sys processing - */ - #define MAX_CDSPATH 67 struct cds @@ -124,3 +80,30 @@ cdstbl; #define CDSSUBST 0x1000 #define CDSVALID (CDSNETWDRV | CDSPHYSDRV) +/* + * Log: cds.h,v + * Revision 1.2 2000/03/09 06:06:38 kernel + * 2017f updates by James Tabor + * + * Revision 1.1.1.1 1999/03/29 15:39:22 jprice + * New version without IPL.SYS + * + * Revision 1.4 1999/02/01 01:40:06 jprice + * Clean up + * + * Revision 1.3 1999/01/30 08:21:43 jprice + * Clean up + * + * Revision 1.2 1999/01/22 04:17:40 jprice + * Formating + * + * Revision 1.1.1.1 1999/01/20 05:51:01 jprice + * Imported sources + * + + Rev 1.1 04 Jan 1998 23:14:18 patv + Changed Log for strip utility + + Rev 1.0 19 Feb 1996 3:15:52 patv + Added NLS, int2f and config.sys processing + */ diff --git a/hdr/clock.h b/hdr/clock.h index dec444f5..aeaea891 100644 --- a/hdr/clock.h +++ b/hdr/clock.h @@ -36,17 +36,18 @@ static BYTE *clock_hRcsId = "$Id$"; #endif #endif + +struct ClockRecord +{ + UWORD clkDays; /* days since Jan 1, 1980. */ + UBYTE clkMinutes; /* residual minutes. */ + UBYTE clkHours; /* residual hours. */ + UBYTE clkHundredths; /* residual hundredths of a second. */ + UBYTE clkSeconds; /* residual seconds. */ +}; + /* - * $Log$ - * Revision 1.3 2000/05/25 20:56:19 jimtabor - * Fixed project history - * - * Revision 1.2 2000/05/08 04:28:22 jimtabor - * Update CVS to 2020 - * - * Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 - * The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with - * MS-DOS. Distributed under the GNU GPL. + * Log: clock.h,v * * Revision 1.1.1.1 1999/03/29 15:39:22 jprice * New version without IPL.SYS @@ -82,12 +83,3 @@ static BYTE *clock_hRcsId = "$Id$"; * Rev 1.0 02 Jul 1995 10:39:26 patv * Initial revision. */ - -struct ClockRecord -{ - UWORD clkDays; /* days since Jan 1, 1980. */ - UBYTE clkMinutes; /* residual minutes. */ - UBYTE clkHours; /* residual hours. */ - UBYTE clkHundredths; /* residual hundredths of a second. */ - UBYTE clkSeconds; /* residual seconds. */ -}; diff --git a/hdr/date.h b/hdr/date.h index 557a7fb0..f7368bf7 100644 --- a/hdr/date.h +++ b/hdr/date.h @@ -36,17 +36,26 @@ static BYTE *date_hRcsId = "$Id$"; #endif #endif +/* FAT file date - takes the form of yyyy yyym mmmd dddd where physical */ +/* year=1980+yyyyyy */ + +#define DT_YEAR(d) (((d)>>9)&0x7f) +#define DT_MONTH(d) (((d)>>5)&0x0f) +#define DT_DAY(d) ((d)&0x1f) + +#define DT_ENCODE(m,d,y) ((((m)&0x0f)<<5)|((d)&0x1f)|(((y)&0x7f)<<9)) + +#define EPOCH_WEEKDAY 2 /* Tuesday (i. e.- 0 == Sunday) */ +#define EPOCH_MONTH 1 /* January */ +#define EPOCH_DAY 1 /* 1 for January 1 */ +#define EPOCH_YEAR 1980 /* for Tues 1-1-80 epoch */ + +typedef UWORD date; + +#endif + /* - * $Log$ - * Revision 1.3 2000/05/25 20:56:19 jimtabor - * Fixed project history - * - * Revision 1.2 2000/05/08 04:28:22 jimtabor - * Update CVS to 2020 - * - * Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 - * The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with - * MS-DOS. Distributed under the GNU GPL. + * Log: date.h,v * * Revision 1.2 1999/08/25 03:17:11 jprice * ror4 patches to allow TC 2.01 compile. @@ -82,21 +91,3 @@ static BYTE *date_hRcsId = "$Id$"; * Rev 1.0 02 Jul 1995 10:39:28 patv * Initial revision. */ - -/* FAT file date - takes the form of yyyy yyym mmmd dddd where physical */ -/* year=1980+yyyyyy */ - -#define DT_YEAR(d) (((d)>>9)&0x7f) -#define DT_MONTH(d) (((d)>>5)&0x0f) -#define DT_DAY(d) ((d)&0x1f) - -#define DT_ENCODE(m,d,y) ((((m)&0x0f)<<5)|((d)&0x1f)|(((y)&0x7f)<<9)) - -#define EPOCH_WEEKDAY 2 /* Tuesday (i. e.- 0 == Sunday) */ -#define EPOCH_MONTH 1 /* January */ -#define EPOCH_DAY 1 /* 1 for January 1 */ -#define EPOCH_YEAR 1980 /* for Tues 1-1-80 epoch */ - -typedef UWORD date; - -#endif diff --git a/hdr/dcb.h b/hdr/dcb.h index 966ec4be..4be6a51c 100644 --- a/hdr/dcb.h +++ b/hdr/dcb.h @@ -34,65 +34,6 @@ static BYTE *clock_hRcsId = "$Id$"; #endif #endif -/* - * $Log$ - * Revision 1.6 2001/11/04 19:47:39 bartoldeman - * kernel 2025a changes: see history.txt - * - * Revision 1.5 2001/09/23 20:39:44 bartoldeman - * FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling - * - * Revision 1.4 2001/04/15 03:21:50 bartoldeman - * See history.txt for the list of fixes. - * - * Revision 1.3 2000/05/25 20:56:19 jimtabor - * Fixed project history - * - * Revision 1.2 2000/05/08 04:28:22 jimtabor - * Update CVS to 2020 - * - * Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 - * The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with - * MS-DOS. Distributed under the GNU GPL. - * - * Revision 1.3 2000/03/09 06:06:38 kernel - * 2017f updates by James Tabor - * - * Revision 1.2 1999/04/16 00:52:09 jprice - * Optimized FAT handling - * - * Revision 1.1.1.1 1999/03/29 15:39:23 jprice - * New version without IPL.SYS - * - * Revision 1.3 1999/02/01 01:40:06 jprice - * Clean up - * - * Revision 1.2 1999/01/22 04:17:40 jprice - * Formating - * - * Revision 1.1.1.1 1999/01/20 05:51:01 jprice - * Imported sources - * - * - * Rev 1.5 04 Jan 1998 23:14:18 patv - * Changed Log for strip utility - * - * Rev 1.4 29 May 1996 21:25:20 patv - * bug fixes for v0.91a - * - * Rev 1.3 19 Feb 1996 3:15:30 patv - * Added NLS, int2f and config.sys processing - * - * Rev 1.2 01 Sep 1995 17:35:40 patv - * First GPL release. - * - * Rev 1.1 30 Jul 1995 20:43:48 patv - * Eliminated version strings in ipl - * - * Rev 1.0 02 Jul 1995 10:39:30 patv - * Initial revision. - */ - /* Internal drive parameter block */ struct dpb { @@ -151,3 +92,43 @@ struct dpb #define XUNKNCLSTFREE 0xffffffffl /* unknown for DOS */ #define UNKNCLSTFREE 0xffff /* unknown for DOS */ +/* + * Log: dcb.h,v + * + * Revision 1.3 2000/03/09 06:06:38 kernel + * 2017f updates by James Tabor + * + * Revision 1.2 1999/04/16 00:52:09 jprice + * Optimized FAT handling + * + * Revision 1.1.1.1 1999/03/29 15:39:23 jprice + * New version without IPL.SYS + * + * Revision 1.3 1999/02/01 01:40:06 jprice + * Clean up + * + * Revision 1.2 1999/01/22 04:17:40 jprice + * Formating + * + * Revision 1.1.1.1 1999/01/20 05:51:01 jprice + * Imported sources + * + * + * Rev 1.5 04 Jan 1998 23:14:18 patv + * Changed Log for strip utility + * + * Rev 1.4 29 May 1996 21:25:20 patv + * bug fixes for v0.91a + * + * Rev 1.3 19 Feb 1996 3:15:30 patv + * Added NLS, int2f and config.sys processing + * + * Rev 1.2 01 Sep 1995 17:35:40 patv + * First GPL release. + * + * Rev 1.1 30 Jul 1995 20:43:48 patv + * Eliminated version strings in ipl + * + * Rev 1.0 02 Jul 1995 10:39:30 patv + * Initial revision. + */ diff --git a/hdr/device.h b/hdr/device.h index 5a499f68..f2a8bf7c 100644 --- a/hdr/device.h +++ b/hdr/device.h @@ -33,91 +33,6 @@ static BYTE *device_hRcsId = "$Id$"; #endif #endif -/* - * $Log$ - * Revision 1.9 2001/11/04 19:47:39 bartoldeman - * kernel 2025a changes: see history.txt - * - * Revision 1.8 2001/09/23 20:39:44 bartoldeman - * FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling - * - * Revision 1.7 2001/07/22 01:58:58 bartoldeman - * Support for Brian's FORMAT, DJGPP libc compilation, cleanups, MSCDEX - * - * Revision 1.6 2001/06/03 14:16:17 bartoldeman - * BUFFERS tuning and misc bug fixes/cleanups (2024c). - * - * Revision 1.5 2001/04/15 03:21:50 bartoldeman - * See history.txt for the list of fixes. - * - * Revision 1.4 2000/05/25 20:56:19 jimtabor - * Fixed project history - * - * Revision 1.3 2000/05/11 04:24:51 jimtabor - * Added Boot blk structs - * - * Revision 1.2 2000/05/08 04:28:22 jimtabor - * Update CVS to 2020 - * - * Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 - * The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with - * MS-DOS. Distributed under the GNU GPL. - * - * Revision 1.4 2000/04/29 05:13:16 jtabor - * Added new functions and clean up code - * - * Revision 1.3 2000/03/09 06:06:38 kernel - * 2017f updates by James Tabor - * - * Revision 1.2 1999/04/04 18:50:14 jprice - * no message - * - * Revision 1.1.1.1 1999/03/29 15:39:26 jprice - * New version without IPL.SYS - * - * Revision 1.5 1999/02/08 05:58:24 jprice - * Added Pat's 1937 kernel patches - * - * Revision 1.4 1999/02/04 03:08:47 jprice - * no message - * - * Revision 1.3 1999/02/01 01:40:06 jprice - * Clean up - * - * Revision 1.2 1999/01/22 04:17:40 jprice - * Formating - * - * Revision 1.1.1.1 1999/01/20 05:51:01 jprice - * Imported sources - * - * - * Rev 1.8 06 Dec 1998 8:41:30 patv - * Changed for new I/O subsystem - * - * Rev 1.7 11 Jan 1998 2:05:54 patv - * Added functionality to ioctl. - * - * Rev 1.6 04 Jan 1998 23:14:20 patv - * Changed Log for strip utility - * - * Rev 1.5 16 Jan 1997 12:46:06 patv - * pre-Release 0.92 feature additions - * - * Rev 1.4 29 May 1996 21:25:12 patv - * bug fixes for v0.91a - * - * Rev 1.3 19 Feb 1996 3:15:30 patv - * Added NLS, int2f and config.sys processing - * - * Rev 1.2 01 Sep 1995 17:35:40 patv - * First GPL release. - * - * Rev 1.1 30 Jul 1995 20:43:48 patv - * Eliminated version strings in ipl - * - * Rev 1.0 02 Jul 1995 10:39:30 patv - * Initial revision. - */ /* * Status Word Bits @@ -574,3 +489,61 @@ typedef struct dhdr FAR *dhdrptr; * end of device.h */ +/* + * Log: device.h,v + * + * Revision 1.4 2000/04/29 05:13:16 jtabor + * Added new functions and clean up code + * + * Revision 1.3 2000/03/09 06:06:38 kernel + * 2017f updates by James Tabor + * + * Revision 1.2 1999/04/04 18:50:14 jprice + * no message + * + * Revision 1.1.1.1 1999/03/29 15:39:26 jprice + * New version without IPL.SYS + * + * Revision 1.5 1999/02/08 05:58:24 jprice + * Added Pat's 1937 kernel patches + * + * Revision 1.4 1999/02/04 03:08:47 jprice + * no message + * + * Revision 1.3 1999/02/01 01:40:06 jprice + * Clean up + * + * Revision 1.2 1999/01/22 04:17:40 jprice + * Formating + * + * Revision 1.1.1.1 1999/01/20 05:51:01 jprice + * Imported sources + * + * + * Rev 1.8 06 Dec 1998 8:41:30 patv + * Changed for new I/O subsystem + * + * Rev 1.7 11 Jan 1998 2:05:54 patv + * Added functionality to ioctl. + * + * Rev 1.6 04 Jan 1998 23:14:20 patv + * Changed Log for strip utility + * + * Rev 1.5 16 Jan 1997 12:46:06 patv + * pre-Release 0.92 feature additions + * + * Rev 1.4 29 May 1996 21:25:12 patv + * bug fixes for v0.91a + * + * Rev 1.3 19 Feb 1996 3:15:30 patv + * Added NLS, int2f and config.sys processing + * + * Rev 1.2 01 Sep 1995 17:35:40 patv + * First GPL release. + * + * Rev 1.1 30 Jul 1995 20:43:48 patv + * Eliminated version strings in ipl + * + * Rev 1.0 02 Jul 1995 10:39:30 patv + * Initial revision. + */ diff --git a/hdr/dirmatch.h b/hdr/dirmatch.h index 52c2567f..112b82fe 100644 --- a/hdr/dirmatch.h +++ b/hdr/dirmatch.h @@ -34,30 +34,45 @@ static BYTE *dirmatch_hRcsId = "$Id$"; #endif #endif + +typedef struct +{ + BYTE dm_drive; + BYTE dm_name_pat[FNAME_SIZE + FEXT_SIZE]; + BYTE dm_attr_srch; + UWORD dm_entry; +#ifdef WITHFAT32 + ULONG dm_dircluster; +#else + UWORD dm_dircluster; + UWORD reserved; +#endif + + struct + { + BITS /* directory has been modified */ + f_dmod:1; + BITS /* directory is the root */ + f_droot:1; + BITS /* fnode is new and needs fill */ + f_dnew:1; + BITS /* fnode is assigned to dir */ + f_ddir:1; + BITS /* filler to avoid a bad bug (feature?) in */ + f_filler:12; /* TC 2.01 */ + } + dm_flags; /* file flags */ + + BYTE dm_attr_fnd; /* found file attribute */ + time dm_time; /* file time */ + date dm_date; /* file date */ + LONG dm_size; /* file size */ + BYTE dm_name[FNAME_SIZE + FEXT_SIZE + 2]; /* file name */ +} +dmatch; + /* - * $Log$ - * Revision 1.7 2001/11/04 19:47:39 bartoldeman - * kernel 2025a changes: see history.txt - * - * Revision 1.6 2001/09/23 20:39:44 bartoldeman - * FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling - * - * Revision 1.5 2001/07/09 22:19:33 bartoldeman - * LBA/FCB/FAT/SYS/Ctrl-C/ioctl fixes + memory savings - * - * Revision 1.4 2001/04/16 01:45:26 bartoldeman - * Fixed handles, config.sys drivers, warnings. Enabled INT21/AH=6C, printf %S/%Fs - * - * Revision 1.3 2000/05/25 20:56:19 jimtabor - * Fixed project history - * - * Revision 1.2 2000/05/08 04:28:22 jimtabor - * Update CVS to 2020 - * - * Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 - * The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with - * MS-DOS. Distributed under the GNU GPL. - * + * Log: dirmatch.h,v * Revision 1.3 2000/03/09 06:06:38 kernel * 2017f updates by James Tabor * @@ -99,40 +114,3 @@ static BYTE *dirmatch_hRcsId = "$Id$"; * Initial revision. * */ - -typedef struct -{ - BYTE dm_drive; - BYTE dm_name_pat[FNAME_SIZE + FEXT_SIZE]; - BYTE dm_attr_srch; - UWORD dm_entry; -#ifdef WITHFAT32 - ULONG dm_dircluster; -#else - UWORD dm_dircluster; - UWORD reserved; -#endif - - struct - { - BITS /* directory has been modified */ - f_dmod:1; - BITS /* directory is the root */ - f_droot:1; - BITS /* fnode is new and needs fill */ - f_dnew:1; - BITS /* fnode is assigned to dir */ - f_ddir:1; - BITS /* filler to avoid a bad bug (feature?) in */ - f_filler:12; /* TC 2.01 */ - } - dm_flags; /* file flags */ - - BYTE dm_attr_fnd; /* found file attribute */ - time dm_time; /* file time */ - date dm_date; /* file date */ - LONG dm_size; /* file size */ - BYTE dm_name[FNAME_SIZE + FEXT_SIZE + 2]; /* file name */ -} -dmatch; - diff --git a/hdr/dosnames.h b/hdr/dosnames.h index 56daa7f9..73e6ce04 100644 --- a/hdr/dosnames.h +++ b/hdr/dosnames.h @@ -34,8 +34,19 @@ static BYTE *dosnames_hRcsId = "$Id$"; #endif #endif + +#define PARSE_MAX 64 + +struct dosnames +{ + UBYTE dn_drive; /* the drive that was parsed */ + UBYTE dn_network[PARSE_MAX]; /* specified network */ + UBYTE dn_path[PARSE_MAX]; /* the path */ + UBYTE dn_name[FNAME_SIZE + FEXT_SIZE + 1]; /* the file name */ +}; + /* - * $Log$ + * Log: dosnames.h,v * Revision 1.2 2000/05/08 04:28:22 jimtabor * Update CVS to 2020 * @@ -67,13 +78,3 @@ static BYTE *dosnames_hRcsId = "$Id$"; * Rev 1.0 02 Jul 1995 10:39:34 patv * Initial revision. */ - -#define PARSE_MAX 64 - -struct dosnames -{ - UBYTE dn_drive; /* the drive that was parsed */ - UBYTE dn_network[PARSE_MAX]; /* specified network */ - UBYTE dn_path[PARSE_MAX]; /* the path */ - UBYTE dn_name[FNAME_SIZE + FEXT_SIZE + 1]; /* the file name */ -}; diff --git a/hdr/error.h b/hdr/error.h index 41541c8f..98b180d0 100644 --- a/hdr/error.h +++ b/hdr/error.h @@ -34,67 +34,6 @@ static BYTE *error_hRcsId = "$Id$"; #endif #endif -/* - * $Log$ - * Revision 1.6 2001/09/23 20:39:44 bartoldeman - * FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling - * - * Revision 1.5 2001/04/16 01:45:26 bartoldeman - * Fixed handles, config.sys drivers, warnings. Enabled INT21/AH=6C, printf %S/%Fs - * - * Revision 1.4 2000/11/02 06:56:53 jimtabor - * Fix Share Patch - * - * Revision 1.3 2000/05/25 20:56:19 jimtabor - * Fixed project history - * - * Revision 1.2 2000/05/08 04:28:22 jimtabor - * Update CVS to 2020 - * - * Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 - * The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with - * MS-DOS. Distributed under the GNU GPL. - * - * Revision 1.1.1.1 1999/03/29 15:39:27 jprice - * New version without IPL.SYS - * - * Revision 1.5 1999/02/08 05:58:24 jprice - * Added Pat's 1937 kernel patches - * - * Revision 1.4 1999/02/01 01:40:06 jprice - * Clean up - * - * Revision 1.3 1999/01/30 08:21:43 jprice - * Clean up - * - * Revision 1.2 1999/01/22 04:17:40 jprice - * Formating - * - * Revision 1.1.1.1 1999/01/20 05:51:01 jprice - * Imported sources - * - * - * Rev 1.6 06 Dec 1998 8:41:00 patv - * Added new errors for new I/O subsystem. - * - * Rev 1.5 04 Jan 1998 23:14:16 patv - * Changed Log for strip utility - * - * Rev 1.4 29 May 1996 21:25:18 patv - * bug fixes for v0.91a - * - * Rev 1.3 19 Feb 1996 3:15:28 patv - * Added NLS, int2f and config.sys processing - * - * Rev 1.2 01 Sep 1995 17:35:38 patv - * First GPL release. - * - * Rev 1.1 30 Jul 1995 20:42:28 patv - * fixed ipl - * - * Rev 1.0 02 Jul 1995 10:39:36 patv - * Initial revision. - */ /* Internal system error returns */ #define SUCCESS 0 /* Function was successful */ @@ -146,3 +85,47 @@ static BYTE *error_hRcsId = "$Id$"; #define RETRY 1 #define ABORT 2 #define FAIL 3 + +/* + * Log: error.h,v + * + * Revision 1.1.1.1 1999/03/29 15:39:27 jprice + * New version without IPL.SYS + * + * Revision 1.5 1999/02/08 05:58:24 jprice + * Added Pat's 1937 kernel patches + * + * Revision 1.4 1999/02/01 01:40:06 jprice + * Clean up + * + * Revision 1.3 1999/01/30 08:21:43 jprice + * Clean up + * + * Revision 1.2 1999/01/22 04:17:40 jprice + * Formating + * + * Revision 1.1.1.1 1999/01/20 05:51:01 jprice + * Imported sources + * + * + * Rev 1.6 06 Dec 1998 8:41:00 patv + * Added new errors for new I/O subsystem. + * + * Rev 1.5 04 Jan 1998 23:14:16 patv + * Changed Log for strip utility + * + * Rev 1.4 29 May 1996 21:25:18 patv + * bug fixes for v0.91a + * + * Rev 1.3 19 Feb 1996 3:15:28 patv + * Added NLS, int2f and config.sys processing + * + * Rev 1.2 01 Sep 1995 17:35:38 patv + * First GPL release. + * + * Rev 1.1 30 Jul 1995 20:42:28 patv + * fixed ipl + * + * Rev 1.0 02 Jul 1995 10:39:36 patv + * Initial revision. + */ diff --git a/hdr/exe.h b/hdr/exe.h index 0bbbf5fb..d8058c2c 100644 --- a/hdr/exe.h +++ b/hdr/exe.h @@ -34,17 +34,30 @@ static BYTE *exe_hRcsId = "$Id$"; #endif #endif + +typedef struct +{ + UWORD exSignature; + UWORD exExtraBytes; + UWORD exPages; + UWORD exRelocItems; + UWORD exHeaderSize; + UWORD exMinAlloc; + UWORD exMaxAlloc; + UWORD exInitSS; + UWORD exInitSP; + UWORD exCheckSum; + UWORD exInitIP; + UWORD exInitCS; + UWORD exRelocTable; + UWORD exOverlay; +} +exe_header; + +#define MAGIC 0x5a4d + /* - * $Log$ - * Revision 1.3 2000/05/25 20:56:19 jimtabor - * Fixed project history - * - * Revision 1.2 2000/05/08 04:28:22 jimtabor - * Update CVS to 2020 - * - * Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 - * The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with - * MS-DOS. Distributed under the GNU GPL. + * Log: exe.h,v * * Revision 1.1.1.1 1999/03/29 15:39:28 jprice * New version without IPL.SYS @@ -77,24 +90,3 @@ static BYTE *exe_hRcsId = "$Id$"; * Rev 1.0 02 Jul 1995 10:39:38 patv * Initial revision. */ - -typedef struct -{ - UWORD exSignature; - UWORD exExtraBytes; - UWORD exPages; - UWORD exRelocItems; - UWORD exHeaderSize; - UWORD exMinAlloc; - UWORD exMaxAlloc; - UWORD exInitSS; - UWORD exInitSP; - UWORD exCheckSum; - UWORD exInitIP; - UWORD exInitCS; - UWORD exRelocTable; - UWORD exOverlay; -} -exe_header; - -#define MAGIC 0x5a4d diff --git a/hdr/fat.h b/hdr/fat.h index c67ce57b..0c7ad4bb 100644 --- a/hdr/fat.h +++ b/hdr/fat.h @@ -34,73 +34,6 @@ static BYTE *fat_hRcsId = "$Id$"; #endif #endif -/* - * $Log$ - * Revision 1.10 2001/11/13 23:36:45 bartoldeman - * Kernel 2025a final changes. - * - * Revision 1.9 2001/11/04 19:47:39 bartoldeman - * kernel 2025a changes: see history.txt - * - * Revision 1.8 2001/09/23 20:39:44 bartoldeman - * FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling - * - * Revision 1.7 2001/07/09 22:19:33 bartoldeman - * LBA/FCB/FAT/SYS/Ctrl-C/ioctl fixes + memory savings - * - * Revision 1.6 2001/04/15 03:21:50 bartoldeman - * See history.txt for the list of fixes. - * - * Revision 1.5 2000/08/06 04:18:21 jimtabor - * See history.txt - * - * Revision 1.3 2000/05/25 20:56:19 jimtabor - * Fixed project history - * - * Revision 1.2 2000/05/08 04:28:22 jimtabor - * Update CVS to 2020 - * - * Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 - * The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with - * MS-DOS. Distributed under the GNU GPL. - * - * Revision 1.2 1999/05/03 06:28:00 jprice - * Changed some variables from signed to unsigned. - * - * Revision 1.1.1.1 1999/03/29 15:39:28 jprice - * New version without IPL.SYS - * - * Revision 1.4 1999/02/01 01:40:06 jprice - * Clean up - * - * Revision 1.3 1999/01/30 08:21:43 jprice - * Clean up - * - * Revision 1.2 1999/01/22 04:17:40 jprice - * Formating - * - * Revision 1.1.1.1 1999/01/20 05:51:01 jprice - * Imported sources - * - * - * Rev 1.5 04 Jan 1998 23:14:18 patv - * Changed Log for strip utility - * - * Rev 1.4 29 May 1996 21:25:14 patv - * bug fixes for v0.91a - * - * Rev 1.3 19 Feb 1996 3:15:30 patv - * Added NLS, int2f and config.sys processing - * - * Rev 1.2 01 Sep 1995 17:35:42 patv - * First GPL release. - * - * Rev 1.1 30 Jul 1995 20:43:48 patv - * Eliminated version strings in ipl - * - * Rev 1.0 02 Jul 1995 10:39:40 patv - * Initial revision. - */ /* FAT file system attribute bits */ #define D_NORMAL 0 /* normal */ @@ -219,3 +152,44 @@ struct lfn_inode }; typedef struct lfn_inode FAR * lfn_inode_ptr; + +/* + * Log: fat.h,v + * + * Revision 1.2 1999/05/03 06:28:00 jprice + * Changed some variables from signed to unsigned. + * + * Revision 1.1.1.1 1999/03/29 15:39:28 jprice + * New version without IPL.SYS + * + * Revision 1.4 1999/02/01 01:40:06 jprice + * Clean up + * + * Revision 1.3 1999/01/30 08:21:43 jprice + * Clean up + * + * Revision 1.2 1999/01/22 04:17:40 jprice + * Formating + * + * Revision 1.1.1.1 1999/01/20 05:51:01 jprice + * Imported sources + * + * + * Rev 1.5 04 Jan 1998 23:14:18 patv + * Changed Log for strip utility + * + * Rev 1.4 29 May 1996 21:25:14 patv + * bug fixes for v0.91a + * + * Rev 1.3 19 Feb 1996 3:15:30 patv + * Added NLS, int2f and config.sys processing + * + * Rev 1.2 01 Sep 1995 17:35:42 patv + * First GPL release. + * + * Rev 1.1 30 Jul 1995 20:43:48 patv + * Eliminated version strings in ipl + * + * Rev 1.0 02 Jul 1995 10:39:40 patv + * Initial revision. + */ diff --git a/hdr/fcb.h b/hdr/fcb.h index 1b97f58c..61f467a7 100644 --- a/hdr/fcb.h +++ b/hdr/fcb.h @@ -34,58 +34,6 @@ static BYTE *fcb_hRcsId = "$Id$"; #endif #endif -/* - * $Log$ - * Revision 1.4 2001/07/09 22:19:33 bartoldeman - * LBA/FCB/FAT/SYS/Ctrl-C/ioctl fixes + memory savings - * - * Revision 1.3 2000/05/25 20:56:19 jimtabor - * Fixed project history - * - * Revision 1.2 2000/05/08 04:28:22 jimtabor - * Update CVS to 2020 - * - * Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 - * The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with - * MS-DOS. Distributed under the GNU GPL. - * - * Revision 1.2 1999/09/20 21:24:54 jprice - * *** empty log message *** - * - * Revision 1.1.1.1 1999/03/29 15:39:29 jprice - * New version without IPL.SYS - * - * Revision 1.3 1999/02/01 01:40:06 jprice - * Clean up - * - * Revision 1.2 1999/01/22 04:17:40 jprice - * Formating - * - * Revision 1.1.1.1 1999/01/20 05:51:01 jprice - * Imported sources - * - * - * Rev 1.6 04 Jan 1998 23:14:16 patv - * Changed Log for strip utility - * - * Rev 1.5 16 Jan 1997 12:46:06 patv - * pre-Release 0.92 feature additions - * - * Rev 1.4 29 May 1996 21:25:14 patv - * bug fixes for v0.91a - * - * Rev 1.3 19 Feb 1996 3:15:32 patv - * Added NLS, int2f and config.sys processing - * - * Rev 1.2 01 Sep 1995 17:35:42 patv - * First GPL release. - * - * Rev 1.1 30 Jul 1995 20:43:48 patv - * Eliminated version strings in ipl - * - * Rev 1.0 02 Jul 1995 10:39:40 patv - * Initial revision. - */ /* fcb convience defines */ /* block device info */ @@ -175,3 +123,44 @@ typedef struct BYTE renReserved2[9]; } rfcb; + +/* + * Log: fcb.h,v + * + * Revision 1.2 1999/09/20 21:24:54 jprice + * *** empty log message *** + * + * Revision 1.1.1.1 1999/03/29 15:39:29 jprice + * New version without IPL.SYS + * + * Revision 1.3 1999/02/01 01:40:06 jprice + * Clean up + * + * Revision 1.2 1999/01/22 04:17:40 jprice + * Formating + * + * Revision 1.1.1.1 1999/01/20 05:51:01 jprice + * Imported sources + * + * + * Rev 1.6 04 Jan 1998 23:14:16 patv + * Changed Log for strip utility + * + * Rev 1.5 16 Jan 1997 12:46:06 patv + * pre-Release 0.92 feature additions + * + * Rev 1.4 29 May 1996 21:25:14 patv + * bug fixes for v0.91a + * + * Rev 1.3 19 Feb 1996 3:15:32 patv + * Added NLS, int2f and config.sys processing + * + * Rev 1.2 01 Sep 1995 17:35:42 patv + * First GPL release. + * + * Rev 1.1 30 Jul 1995 20:43:48 patv + * Eliminated version strings in ipl + * + * Rev 1.0 02 Jul 1995 10:39:40 patv + * Initial revision. + */ diff --git a/hdr/file.h b/hdr/file.h index 439c0ec0..7fe79ffb 100644 --- a/hdr/file.h +++ b/hdr/file.h @@ -34,20 +34,25 @@ static BYTE *file_hRcsId = "$Id$"; #endif #endif + +/* 0 = CON, standard input, can be redirected */ +/* 1 = CON, standard output, can be redirected */ +/* 2 = CON, standard error */ +/* 3 = AUX, auxiliary */ +/* 4 = PRN, list device */ +/* 5 = 1st user file ... */ +#define STDIN 0 +#define STDOUT 1 +#define STDERR 2 +#define STDAUX 3 +#define STDPRN 4 + +#define O_RDONLY SFT_MREAD +#define O_WRONLY SFT_MWRITE +#define O_RDWR SFT_MRDWR + /* - * $Log$ - * Revision 1.4 2001/04/21 22:32:53 bartoldeman - * Init DS=Init CS, fixed stack overflow problems and misc bugs. - * - * Revision 1.3 2000/05/25 20:56:19 jimtabor - * Fixed project history - * - * Revision 1.2 2000/05/08 04:28:22 jimtabor - * Update CVS to 2020 - * - * Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 - * The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with - * MS-DOS. Distributed under the GNU GPL. + * Log: file.h,v * * Revision 1.1.1.1 1999/03/29 15:39:30 jprice * New version without IPL.SYS @@ -80,19 +85,3 @@ static BYTE *file_hRcsId = "$Id$"; * Rev 1.0 02 Jul 1995 10:39:42 patv * Initial revision. */ - -/* 0 = CON, standard input, can be redirected */ -/* 1 = CON, standard output, can be redirected */ -/* 2 = CON, standard error */ -/* 3 = AUX, auxiliary */ -/* 4 = PRN, list device */ -/* 5 = 1st user file ... */ -#define STDIN 0 -#define STDOUT 1 -#define STDERR 2 -#define STDAUX 3 -#define STDPRN 4 - -#define O_RDONLY SFT_MREAD -#define O_WRONLY SFT_MWRITE -#define O_RDWR SFT_MRDWR diff --git a/hdr/fnode.h b/hdr/fnode.h index 810710b5..d7502c21 100644 --- a/hdr/fnode.h +++ b/hdr/fnode.h @@ -34,79 +34,6 @@ static BYTE *fnode_hRcsId = "$Id$"; #endif #endif -/* - * $Log$ - * Revision 1.10 2001/11/04 19:47:39 bartoldeman - * kernel 2025a changes: see history.txt - * - * Revision 1.9 2001/09/23 20:39:44 bartoldeman - * FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling - * - * Revision 1.8 2001/08/19 12:58:34 bartoldeman - * Time and date fixes, Ctrl-S/P, findfirst/next, FCBs, buffers, tsr unloading - * - * Revision 1.7 2001/07/09 22:19:33 bartoldeman - * LBA/FCB/FAT/SYS/Ctrl-C/ioctl fixes + memory savings - * - * Revision 1.6 2001/06/03 14:16:17 bartoldeman - * BUFFERS tuning and misc bug fixes/cleanups (2024c). - * - * Revision 1.5 2001/04/29 17:34:40 bartoldeman - * A new SYS.COM/config.sys single stepping/console output/misc fixes. - * - * Revision 1.4 2001/04/15 03:21:50 bartoldeman - * See history.txt for the list of fixes. - * - * Revision 1.3 2000/05/25 20:56:19 jimtabor - * Fixed project history - * - * Revision 1.2 2000/05/08 04:28:22 jimtabor - * Update CVS to 2020 - * - * Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 - * The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with - * MS-DOS. Distributed under the GNU GPL. - * - * Revision 1.3 2000/03/09 06:06:38 kernel - * 2017f updates by James Tabor - * - * Revision 1.2 1999/04/16 00:52:10 jprice - * Optimized FAT handling - * - * Revision 1.1.1.1 1999/03/29 15:39:30 jprice - * New version without IPL.SYS - * - * Revision 1.4 1999/02/01 01:40:06 jprice - * Clean up - * - * Revision 1.3 1999/01/30 08:21:43 jprice - * Clean up - * - * Revision 1.2 1999/01/22 04:17:40 jprice - * Formating - * - * Revision 1.1.1.1 1999/01/20 05:51:01 jprice - * Imported sources - * - * - * Rev 1.5 04 Jan 1998 23:14:18 patv - * Changed Log for strip utility - * - * Rev 1.4 29 May 1996 21:25:16 patv - * bug fixes for v0.91a - * - * Rev 1.3 19 Feb 1996 3:15:32 patv - * Added NLS, int2f and config.sys processing - * - * Rev 1.2 01 Sep 1995 17:35:42 patv - * First GPL release. - * - * Rev 1.1 30 Jul 1995 20:43:48 patv - * Eliminated version strings in ipl - * - * Rev 1.0 02 Jul 1995 10:39:44 patv - * Initial revision. - */ struct f_node { @@ -155,3 +82,47 @@ typedef struct lfn_inode FAR * lfn_inode_ptr; #endif typedef struct f_node * f_node_ptr; + +/* + * Log: fnode.h,v + * + * Revision 1.3 2000/03/09 06:06:38 kernel + * 2017f updates by James Tabor + * + * Revision 1.2 1999/04/16 00:52:10 jprice + * Optimized FAT handling + * + * Revision 1.1.1.1 1999/03/29 15:39:30 jprice + * New version without IPL.SYS + * + * Revision 1.4 1999/02/01 01:40:06 jprice + * Clean up + * + * Revision 1.3 1999/01/30 08:21:43 jprice + * Clean up + * + * Revision 1.2 1999/01/22 04:17:40 jprice + * Formating + * + * Revision 1.1.1.1 1999/01/20 05:51:01 jprice + * Imported sources + * + * + * Rev 1.5 04 Jan 1998 23:14:18 patv + * Changed Log for strip utility + * + * Rev 1.4 29 May 1996 21:25:16 patv + * bug fixes for v0.91a + * + * Rev 1.3 19 Feb 1996 3:15:32 patv + * Added NLS, int2f and config.sys processing + * + * Rev 1.2 01 Sep 1995 17:35:42 patv + * First GPL release. + * + * Rev 1.1 30 Jul 1995 20:43:48 patv + * Eliminated version strings in ipl + * + * Rev 1.0 02 Jul 1995 10:39:44 patv + * Initial revision. + */ diff --git a/hdr/kbd.h b/hdr/kbd.h index 8f229536..7493639c 100644 --- a/hdr/kbd.h +++ b/hdr/kbd.h @@ -34,17 +34,20 @@ static BYTE *kbd_hRcsId = "$Id$"; #endif #endif + +#define KBD_MAXLENGTH 256 + +/* Keyboard buffer */ +typedef struct +{ + UBYTE kb_size; /* size of buffer in bytes */ + UBYTE kb_count; /* number of bytes returned */ + BYTE kb_buf[KBD_MAXLENGTH]; /* the buffer itself */ +} +keyboard; + /* - * $Log$ - * Revision 1.3 2000/05/25 20:56:19 jimtabor - * Fixed project history - * - * Revision 1.2 2000/05/08 04:28:22 jimtabor - * Update CVS to 2020 - * - * Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 - * The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with - * MS-DOS. Distributed under the GNU GPL. + * Log: kbd.h,v * * Revision 1.1.1.1 1999/03/29 15:39:31 jprice * New version without IPL.SYS @@ -77,14 +80,3 @@ static BYTE *kbd_hRcsId = "$Id$"; * Rev 1.0 02 Jul 1995 10:39:46 patv * Initial revision. */ - -#define KBD_MAXLENGTH 256 - -/* Keyboard buffer */ -typedef struct -{ - UBYTE kb_size; /* size of buffer in bytes */ - UBYTE kb_count; /* number of bytes returned */ - BYTE kb_buf[KBD_MAXLENGTH]; /* the buffer itself */ -} -keyboard; diff --git a/hdr/mcb.h b/hdr/mcb.h index 273d3b62..6637e037 100644 --- a/hdr/mcb.h +++ b/hdr/mcb.h @@ -34,29 +34,40 @@ static BYTE *mcb_hRcsId = "$Id$"; #endif #endif +#define LARGEST -1 +#define FIRST_FIT 0 +#define BEST_FIT 1 +#define LAST_FIT 2 +#define FIRST_FIT_UO 0x40 +#define BEST_FIT_UO 0x41 +#define LAST_FIT_UO 0x42 +#define FIRST_FIT_U 0x80 +#define BEST_FIT_U 0x81 +#define LAST_FIT_U 0x82 + +#define MCB_NORMAL 0x4d +#define MCB_LAST 0x5a + +#define DOS_PSP 0x0060 /* 0x0008 What? seg 8 =0:0080 */ +#define FREE_PSP 0 + +#define MCB_SIZE(x) ((((LONG)(x))<<4)+sizeof(mcb)) + +typedef UWORD seg; +typedef UWORD offset; + +typedef struct +{ + BYTE m_type; /* mcb type - chain or end */ + UWORD m_psp; /* owner id via psp segment */ + UWORD m_size; /* size of segment in paragraphs */ + BYTE m_fill[3]; + BYTE m_name[8]; /* owner name limited to 8 bytes */ +} +mcb; + /* - * $Log$ - * Revision 1.7 2001/04/15 03:21:50 bartoldeman - * See history.txt for the list of fixes. - * - * Revision 1.6 2000/08/06 04:27:07 jimtabor - * See history.txt - * - * Revision 1.5 2000/08/06 04:18:21 jimtabor - * See history.txt - * - * Revision 1.4 2000/06/21 18:16:46 jimtabor - * Add UMB code, patch, and code fixes - * - * Revision 1.3 2000/05/25 20:56:19 jimtabor - * Fixed project history - * - * Revision 1.2 2000/05/08 04:28:22 jimtabor - * Update CVS to 2020 - * - * Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 - * The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with - * MS-DOS. Distributed under the GNU GPL. + * Log: mcb.h,v * * Revision 1.2 2000/03/09 06:06:38 kernel * 2017f updates by James Tabor @@ -92,36 +103,3 @@ static BYTE *mcb_hRcsId = "$Id$"; * Rev 1.0 02 Jul 1995 10:39:46 patv * Initial revision. */ - -#define LARGEST -1 -#define FIRST_FIT 0 -#define BEST_FIT 1 -#define LAST_FIT 2 -#define FIRST_FIT_UO 0x40 -#define BEST_FIT_UO 0x41 -#define LAST_FIT_UO 0x42 -#define FIRST_FIT_U 0x80 -#define BEST_FIT_U 0x81 -#define LAST_FIT_U 0x82 - -#define MCB_NORMAL 0x4d -#define MCB_LAST 0x5a - -#define DOS_PSP 0x0060 /* 0x0008 What? seg 8 =0:0080 */ -#define FREE_PSP 0 - -#define MCB_SIZE(x) ((((LONG)(x))<<4)+sizeof(mcb)) - -typedef UWORD seg; -typedef UWORD offset; - -typedef struct -{ - BYTE m_type; /* mcb type - chain or end */ - UWORD m_psp; /* owner id via psp segment */ - UWORD m_size; /* size of segment in paragraphs */ - BYTE m_fill[3]; - BYTE m_name[8]; /* owner name limited to 8 bytes */ -} -mcb; - diff --git a/hdr/pcb.h b/hdr/pcb.h index d02c2ebe..4a6520e9 100644 --- a/hdr/pcb.h +++ b/hdr/pcb.h @@ -55,61 +55,6 @@ static BYTE *pcb_hRcsId = "$Id$"; #endif #endif -/* - * $Log$ - * Revision 1.6 2001/09/23 20:39:44 bartoldeman - * FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling - * - * Revision 1.5 2001/04/15 03:21:50 bartoldeman - * See history.txt for the list of fixes. - * - * Revision 1.4 2000/08/06 04:18:21 jimtabor - * See history.txt - * - * Revision 1.3 2000/05/25 20:56:19 jimtabor - * Fixed project history - * - * Revision 1.2 2000/05/08 04:28:22 jimtabor - * Update CVS to 2020 - * - * Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 - * The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with - * MS-DOS. Distributed under the GNU GPL. - * - * Revision 1.1.1.1 1999/03/29 15:39:32 jprice - * New version without IPL.SYS - * - * Revision 1.3 1999/02/01 01:40:06 jprice - * Clean up - * - * Revision 1.2 1999/01/22 04:17:40 jprice - * Formating - * - * Revision 1.1.1.1 1999/01/20 05:51:01 jprice - * Imported sources - * - * - * Rev 1.6 07 Feb 1998 20:47:40 patv - * Modified stack frame to match DOS standard - * - * Rev 1.5 04 Jan 1998 23:14:18 patv - * Changed Log for strip utility - * - * Rev 1.4 29 May 1996 21:25:16 patv - * bug fixes for v0.91a - * - * Rev 1.3 19 Feb 1996 3:15:32 patv - * Added NLS, int2f and config.sys processing - * - * Rev 1.2 01 Sep 1995 17:35:44 patv - * First GPL release. - * - * Rev 1.1 30 Jul 1995 20:43:50 patv - * Eliminated version strings in ipl - * - * Rev 1.0 02 Jul 1995 10:39:48 patv - * Initial revision. - */ /* Force one-byte alignment for all the internal structures, see above */ #include @@ -246,3 +191,40 @@ void ASMCFUNC intr(int intnr, iregs * const pr); #endif +/* + * Log: pcb.h,v + * + * Revision 1.1.1.1 1999/03/29 15:39:32 jprice + * New version without IPL.SYS + * + * Revision 1.3 1999/02/01 01:40:06 jprice + * Clean up + * + * Revision 1.2 1999/01/22 04:17:40 jprice + * Formating + * + * Revision 1.1.1.1 1999/01/20 05:51:01 jprice + * Imported sources + * + * + * Rev 1.6 07 Feb 1998 20:47:40 patv + * Modified stack frame to match DOS standard + * + * Rev 1.5 04 Jan 1998 23:14:18 patv + * Changed Log for strip utility + * + * Rev 1.4 29 May 1996 21:25:16 patv + * bug fixes for v0.91a + * + * Rev 1.3 19 Feb 1996 3:15:32 patv + * Added NLS, int2f and config.sys processing + * + * Rev 1.2 01 Sep 1995 17:35:44 patv + * First GPL release. + * + * Rev 1.1 30 Jul 1995 20:43:50 patv + * Eliminated version strings in ipl + * + * Rev 1.0 02 Jul 1995 10:39:48 patv + * Initial revision. + */ diff --git a/hdr/portab.h b/hdr/portab.h index e4fd11bd..4269ff26 100644 --- a/hdr/portab.h +++ b/hdr/portab.h @@ -34,71 +34,6 @@ static char *portab_hRcsId = "$Id$"; #endif #endif -/* - * $Log$ - * Revision 1.10 2001/09/23 20:39:44 bartoldeman - * FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling - * - * Revision 1.9 2001/06/03 14:16:17 bartoldeman - * BUFFERS tuning and misc bug fixes/cleanups (2024c). - * - * Revision 1.8 2001/04/15 03:21:50 bartoldeman - * See history.txt for the list of fixes. - * - * Revision 1.7 2001/03/21 02:56:25 bartoldeman - * See history.txt for changes. Bug fixes and HMA support are the main ones. - * - * Revision 1.5 2001/03/08 21:15:00 bartoldeman - * Fixes for MK_FP and friends from Tom Ehlert; reduces kernel by 1.5k. - * - * Revision 1.4 2000/08/06 04:18:21 jimtabor - * See history.txt - * - * Revision 1.3 2000/05/25 20:56:19 jimtabor - * Fixed project history - * - * Revision 1.2 2000/05/08 04:28:22 jimtabor - * Update CVS to 2020 - * - * Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 - * The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with - * MS-DOS. Distributed under the GNU GPL. - * - * Revision 1.2 1999/08/25 03:17:11 jprice - * ror4 patches to allow TC 2.01 compile. - * - * Revision 1.1.1.1 1999/03/29 15:39:33 jprice - * New version without IPL.SYS - * - * Revision 1.3 1999/02/01 01:40:06 jprice - * Clean up - * - * Revision 1.2 1999/01/22 04:17:40 jprice - * Formating - * - * Revision 1.1.1.1 1999/01/20 05:51:01 jprice - * Imported sources - * - * - * Rev 1.5 04 Jan 1998 23:14:16 patv - * Changed Log for strip utility - * - * Rev 1.4 29 May 1996 21:25:16 patv - * bug fixes for v0.91a - * - * Rev 1.3 19 Feb 1996 3:15:32 patv - * Added NLS, int2f and config.sys processing - * - * Rev 1.2 01 Sep 1995 17:35:44 patv - * First GPL release. - * - * Rev 1.1 30 Jul 1995 20:43:50 patv - * Eliminated version strings in ipl - * - * Rev 1.0 02 Jul 1995 10:39:50 patv - * Initial revision. - */ - /****************************************************************/ /* */ /* Machine dependant portable types. Note that this section is */ @@ -297,3 +232,39 @@ typedef signed long LONG; #define PROTO #endif +/* + * Log: portab.h,v + * Revision 1.2 1999/08/25 03:17:11 jprice + * ror4 patches to allow TC 2.01 compile. + * + * Revision 1.1.1.1 1999/03/29 15:39:33 jprice + * New version without IPL.SYS + * + * Revision 1.3 1999/02/01 01:40:06 jprice + * Clean up + * + * Revision 1.2 1999/01/22 04:17:40 jprice + * Formating + * + * Revision 1.1.1.1 1999/01/20 05:51:01 jprice + * Imported sources + * + * + * Rev 1.5 04 Jan 1998 23:14:16 patv + * Changed Log for strip utility + * + * Rev 1.4 29 May 1996 21:25:16 patv + * bug fixes for v0.91a + * + * Rev 1.3 19 Feb 1996 3:15:32 patv + * Added NLS, int2f and config.sys processing + * + * Rev 1.2 01 Sep 1995 17:35:44 patv + * First GPL release. + * + * Rev 1.1 30 Jul 1995 20:43:50 patv + * Eliminated version strings in ipl + * + * Rev 1.0 02 Jul 1995 10:39:50 patv + * Initial revision. + */ diff --git a/hdr/process.h b/hdr/process.h index cbc6ea3a..6c8da928 100644 --- a/hdr/process.h +++ b/hdr/process.h @@ -34,65 +34,6 @@ static BYTE *process_hRcsId = "$Id$"; #endif #endif -/* - * $Log$ - * Revision 1.6 2001/11/04 19:47:39 bartoldeman - * kernel 2025a changes: see history.txt - * - * Revision 1.5 2001/09/23 20:39:44 bartoldeman - * FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling - * - * Revision 1.4 2000/08/06 04:18:21 jimtabor - * See history.txt - * - * Revision 1.3 2000/05/25 20:56:19 jimtabor - * Fixed project history - * - * Revision 1.2 2000/05/08 04:28:22 jimtabor - * Update CVS to 2020 - * - * Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 - * The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with - * MS-DOS. Distributed under the GNU GPL. - * - * Revision 1.1.1.1 1999/03/29 15:39:34 jprice - * New version without IPL.SYS - * - * Revision 1.3 1999/02/01 01:40:06 jprice - * Clean up - * - * Revision 1.2 1999/01/22 04:17:40 jprice - * Formating - * - * Revision 1.1.1.1 1999/01/20 05:51:01 jprice - * Imported sources - * - * - * Rev 1.7 22 Jan 1998 22:13:00 patv - * Had to change ps_prevps to VOID FAR * due to BC++ error. - * - * Rev 1.6 22 Jan 1998 22:05:22 patv - * Corrected ps_prevpsp declaration. - * - * Rev 1.5 04 Jan 1998 23:14:16 patv - * Changed Log for strip utility - * - * Rev 1.4 29 May 1996 21:25:16 patv - * bug fixes for v0.91a - * - * Rev 1.3 19 Feb 1996 3:15:32 patv - * Added NLS, int2f and config.sys processing - * - * Rev 1.2 01 Sep 1995 17:35:44 patv - * First GPL release. - * - * Rev 1.1 30 Jul 1995 20:43:50 patv - * Eliminated version strings in ipl - * - * Rev 1.0 02 Jul 1995 10:39:52 patv - * Initial revision. - */ - /* Modes available as first argument to the spawnxx functions. */ #define P_WAIT 0 /* child runs separately, parent waits until exit */ @@ -186,3 +127,44 @@ psp; #define ps_fcb2 _u._u2._ps_fcb2 #define ps_cmd _u._u3._u4._ps_cmd #define ps_cmd_count _u._u3._u4._ps_cmd_count + +/* + * Log: process.h,v + * + * Revision 1.1.1.1 1999/03/29 15:39:34 jprice + * New version without IPL.SYS + * + * Revision 1.3 1999/02/01 01:40:06 jprice + * Clean up + * + * Revision 1.2 1999/01/22 04:17:40 jprice + * Formating + * + * Revision 1.1.1.1 1999/01/20 05:51:01 jprice + * Imported sources + * + * + * Rev 1.7 22 Jan 1998 22:13:00 patv + * Had to change ps_prevps to VOID FAR * due to BC++ error. + * + * Rev 1.6 22 Jan 1998 22:05:22 patv + * Corrected ps_prevpsp declaration. + * + * Rev 1.5 04 Jan 1998 23:14:16 patv + * Changed Log for strip utility + * + * Rev 1.4 29 May 1996 21:25:16 patv + * bug fixes for v0.91a + * + * Rev 1.3 19 Feb 1996 3:15:32 patv + * Added NLS, int2f and config.sys processing + * + * Rev 1.2 01 Sep 1995 17:35:44 patv + * First GPL release. + * + * Rev 1.1 30 Jul 1995 20:43:50 patv + * Eliminated version strings in ipl + * + * Rev 1.0 02 Jul 1995 10:39:52 patv + * Initial revision. + */ diff --git a/hdr/sft.h b/hdr/sft.h index 80c479a3..c91a53d8 100644 --- a/hdr/sft.h +++ b/hdr/sft.h @@ -33,67 +33,6 @@ static BYTE *sft_hRcsId = "$Id$"; #endif #endif -/* - * $Log$ - * Revision 1.6 2001/11/04 19:47:39 bartoldeman - * kernel 2025a changes: see history.txt - * - * Revision 1.5 2001/07/22 01:58:58 bartoldeman - * Support for Brian's FORMAT, DJGPP libc compilation, cleanups, MSCDEX - * - * Revision 1.4 2001/07/09 22:19:33 bartoldeman - * LBA/FCB/FAT/SYS/Ctrl-C/ioctl fixes + memory savings - * - * Revision 1.3 2000/05/25 20:56:19 jimtabor - * Fixed project history - * - * Revision 1.2 2000/05/08 04:28:22 jimtabor - * Update CVS to 2020 - * - * Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 - * The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with - * MS-DOS. Distributed under the GNU GPL. - * - * Revision 1.3 2000/03/09 06:06:38 kernel - * 2017f updates by James Tabor - * - * Revision 1.2 1999/04/04 18:50:25 jprice - * no message - * - * Revision 1.1.1.1 1999/03/29 15:39:35 jprice - * New version without IPL.SYS - * - * Revision 1.3 1999/02/01 01:40:06 jprice - * Clean up - * - * Revision 1.2 1999/01/22 04:17:40 jprice - * Formating - * - * Revision 1.1.1.1 1999/01/20 05:51:01 jprice - * Imported sources - * - * - * Rev 1.6 04 Jan 1998 23:14:18 patv - * Changed Log for strip utility - * - * Rev 1.5 16 Jan 1997 12:46:04 patv - * pre-Release 0.92 feature additions - * - * Rev 1.4 29 May 1996 21:25:18 patv - * bug fixes for v0.91a - * - * Rev 1.3 19 Feb 1996 3:15:34 patv - * Added NLS, int2f and config.sys processing - * - * Rev 1.2 01 Sep 1995 17:35:44 patv - * First GPL release. - * - * Rev 1.1 30 Jul 1995 20:43:50 patv - * Eliminated version strings in ipl - * - * Rev 1.0 02 Jul 1995 10:39:52 patv - * Initial revision. - */ #define SFTMAX 128 @@ -215,3 +154,46 @@ sfttbl; #define sft_flags_lo sft_flags_union._split_sft_flags._sft_flags_lo +/* + * Log: sft.h,v + * + * Revision 1.3 2000/03/09 06:06:38 kernel + * 2017f updates by James Tabor + * + * Revision 1.2 1999/04/04 18:50:25 jprice + * no message + * + * Revision 1.1.1.1 1999/03/29 15:39:35 jprice + * New version without IPL.SYS + * + * Revision 1.3 1999/02/01 01:40:06 jprice + * Clean up + * + * Revision 1.2 1999/01/22 04:17:40 jprice + * Formating + * + * Revision 1.1.1.1 1999/01/20 05:51:01 jprice + * Imported sources + * + * + * Rev 1.6 04 Jan 1998 23:14:18 patv + * Changed Log for strip utility + * + * Rev 1.5 16 Jan 1997 12:46:04 patv + * pre-Release 0.92 feature additions + * + * Rev 1.4 29 May 1996 21:25:18 patv + * bug fixes for v0.91a + * + * Rev 1.3 19 Feb 1996 3:15:34 patv + * Added NLS, int2f and config.sys processing + * + * Rev 1.2 01 Sep 1995 17:35:44 patv + * First GPL release. + * + * Rev 1.1 30 Jul 1995 20:43:50 patv + * Eliminated version strings in ipl + * + * Rev 1.0 02 Jul 1995 10:39:52 patv + * Initial revision. + */ diff --git a/hdr/stacks.inc b/hdr/stacks.inc index f3a1bd8e..d54819e6 100644 --- a/hdr/stacks.inc +++ b/hdr/stacks.inc @@ -25,53 +25,8 @@ ; write to the Free Software Foundation, 675 Mass Ave, ; Cambridge, MA 02139, USA. ; -; $Logfile: C:/dos-c/hdr/stacks.inv $ -; ; $Id$ ; -; $Log$ -; Revision 1.6 2001/11/04 19:47:39 bartoldeman -; kernel 2025a changes: see history.txt -; -; Revision 1.5 2000/08/06 04:18:21 jimtabor -; See history.txt -; -; Revision 1.4 2000/05/26 19:46:52 jimtabor -; Read History file for Change info -; -; Revision 1.3 2000/05/25 20:56:19 jimtabor -; Fixed project history -; -; Revision 1.2 2000/05/08 04:28:22 jimtabor -; Update CVS to 2020 -; -; Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 -; The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with -; MS-DOS. Distributed under the GNU GPL. -; -; Revision 1.3 2000/03/09 06:06:38 kernel -; 2017f updates by James Tabor -; -; Revision 1.2 1999/08/10 17:56:26 jprice -; ror4 2011-02 patch -; -; Revision 1.1.1.1 1999/03/29 15:39:35 jprice -; New version without IPL.SYS -; -; Revision 1.3 1999/02/01 01:40:06 jprice -; Clean up -; -; Revision 1.2 1999/01/22 04:17:40 jprice -; Formating -; -; Revision 1.1.1.1 1999/01/20 05:51:01 jprice -; Imported sources -; -; -; Rev 1.0 07 Feb 1998 20:59:16 patv -;Modified stack frame to match DOS standard -; $EndLog$ - ; ; Standard stack frame used throughout DOS-C @@ -215,4 +170,29 @@ irp_hi equ 26 ror eax,16 %endmacro -%ENDIF \ No newline at end of file +%ENDIF + +; Log: stacks.inc,v +; Revision 1.3 2000/03/09 06:06:38 kernel +; 2017f updates by James Tabor +; +; Revision 1.2 1999/08/10 17:56:26 jprice +; ror4 2011-02 patch +; +; Revision 1.1.1.1 1999/03/29 15:39:35 jprice +; New version without IPL.SYS +; +; Revision 1.3 1999/02/01 01:40:06 jprice +; Clean up +; +; Revision 1.2 1999/01/22 04:17:40 jprice +; Formating +; +; Revision 1.1.1.1 1999/01/20 05:51:01 jprice +; Imported sources +; +; +; Rev 1.0 07 Feb 1998 20:59:16 patv +;Modified stack frame to match DOS standard +; EndLog + diff --git a/hdr/tail.h b/hdr/tail.h index 80fd8c7f..3577f448 100644 --- a/hdr/tail.h +++ b/hdr/tail.h @@ -34,17 +34,20 @@ static BYTE *tail_hRcsId = "$Id$"; #endif #endif + +#ifndef LINESIZE +#define LINESIZE 127 +#endif + +typedef struct +{ + UBYTE ctCount; /* number of bytes returned */ + BYTE ctBuffer[LINESIZE]; /* the buffer itself */ +} +CommandTail; + /* - * $Log$ - * Revision 1.3 2000/05/25 20:56:19 jimtabor - * Fixed project history - * - * Revision 1.2 2000/05/08 04:28:22 jimtabor - * Update CVS to 2020 - * - * Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 - * The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with - * MS-DOS. Distributed under the GNU GPL. + * Log: tail.h,v * * Revision 1.1.1.1 1999/03/29 15:39:36 jprice * New version without IPL.SYS @@ -77,14 +80,3 @@ static BYTE *tail_hRcsId = "$Id$"; * Rev 1.0 02 Jul 1995 10:39:54 patv * Initial revision. */ - -#ifndef LINESIZE -#define LINESIZE 127 -#endif - -typedef struct -{ - UBYTE ctCount; /* number of bytes returned */ - BYTE ctBuffer[LINESIZE]; /* the buffer itself */ -} -CommandTail; diff --git a/hdr/time.h b/hdr/time.h index 4c2591bb..8ee7f45a 100644 --- a/hdr/time.h +++ b/hdr/time.h @@ -38,17 +38,20 @@ static BYTE *time_hRcsId = "$Id$"; #endif #endif +/* FAT Time notation in the form of hhhh hmmm mmmd dddd */ + +#define TM_HOUR(t) (((t)>>11)&0x1f) +#define TM_MIN(t) (((t)>>5)&0x3f) +#define TM_DEC(t) ((t)&0x1f) + +#define TM_ENCODE(h,m,d) ((((h&0x1f))<<11)|(((m)&0x3f)<<5)|((d)&0x1f)) + +typedef UWORD time; + +#endif + /* - * $Log$ - * Revision 1.3 2000/05/25 20:56:19 jimtabor - * Fixed project history - * - * Revision 1.2 2000/05/08 04:28:22 jimtabor - * Update CVS to 2020 - * - * Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 - * The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with - * MS-DOS. Distributed under the GNU GPL. + * Log: time.h,v * * Revision 1.2 1999/08/25 03:17:11 jprice * ror4 patches to allow TC 2.01 compile. @@ -85,14 +88,3 @@ static BYTE *time_hRcsId = "$Id$"; * Initial revision. */ -/* FAT Time notation in the form of hhhh hmmm mmmd dddd */ - -#define TM_HOUR(t) (((t)>>11)&0x1f) -#define TM_MIN(t) (((t)>>5)&0x3f) -#define TM_DEC(t) ((t)&0x1f) - -#define TM_ENCODE(h,m,d) ((((h&0x1f))<<11)|(((m)&0x3f)<<5)|((d)&0x1f)) - -typedef UWORD time; - -#endif diff --git a/hdr/version.h b/hdr/version.h index b8bbd66e..e953a81d 100644 --- a/hdr/version.h +++ b/hdr/version.h @@ -44,6 +44,6 @@ static BYTE *date_hRcsId = "$Id$"; #define REVISION_MINOR 1 #define REVISION_SEQ 25 #define BUILD "2025" -#define SUB_BUILD "a" -#define KERNEL_VERSION_STRING "1.1.25a" /*#REVISION_MAJOR "." #REVISION_MINOR "." #REVISION_SEQ*/ -#define KERNEL_BUILD_STRING "2025a" /*#BUILD SUB_BUILD*/ +#define SUB_BUILD "b" +#define KERNEL_VERSION_STRING "1.1.25b" /*#REVISION_MAJOR "." #REVISION_MINOR "." #REVISION_SEQ*/ +#define KERNEL_BUILD_STRING "2025b" /*#BUILD SUB_BUILD*/ diff --git a/kernel/apisupt.asm b/kernel/apisupt.asm index 93cad345..113828f2 100644 --- a/kernel/apisupt.asm +++ b/kernel/apisupt.asm @@ -25,60 +25,6 @@ ; Cambridge, MA 02139, USA. ; ; $Id$ -; -; $Log$ -; Revision 1.6 2001/04/15 02:23:43 bartoldeman -; apisupt.asm is not necessary anymore. -; -; Revision 1.5 2001/03/22 20:46:46 bartoldeman -; cli/sti corrections (Bart) and int25, 26 stack corrections (Tom) -; -; Revision 1.4 2001/03/21 02:56:25 bartoldeman -; See history.txt for changes. Bug fixes and HMA support are the main ones. -; -; Revision 1.3 2000/05/25 20:56:21 jimtabor -; Fixed project history -; -; Revision 1.2 2000/05/08 04:29:59 jimtabor -; Update CVS to 2020 -; -; Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 -; The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with -; MS-DOS. Distributed under the GNU GPL. -; -; Revision 1.2 1999/08/10 17:57:12 jprice -; ror4 2011-02 patch -; -; Revision 1.1.1.1 1999/03/29 15:40:38 jprice -; New version without IPL.SYS -; -; Revision 1.4 1999/02/08 05:55:57 jprice -; Added Pat's 1937 kernel patches -; -; Revision 1.3 1999/02/01 01:48:41 jprice -; Clean up; Now you can use hex numbers in config.sys. added config.sys screen function to change screen mode (28 or 43/50 lines) -; -; Revision 1.2 1999/01/22 04:13:25 jprice -; Formating -; -; Revision 1.1.1.1 1999/01/20 05:51:01 jprice -; Imported sources -; -; Rev 1.4 06 Dec 1998 8:47:02 patv -;Expanded due to new I/O subsystem. -; -; Rev 1.3 16 Jan 1997 12:46:44 patv -;pre-Release 0.92 feature additions -; -; Rev 1.2 29 May 1996 21:03:38 patv -;bug fixes for v0.91a -; -; Rev 1.1 01 Sep 1995 17:54:26 patv -;First GPL release. -; -; Rev 1.0 02 Jul 1995 9:04:50 patv -;Initial revision. -; $EndLog$ ; %include "segs.inc" @@ -181,3 +127,40 @@ _restore_stack: ret %endif + +; Log: apisupt.asm,v +; +; Revision 1.2 1999/08/10 17:57:12 jprice +; ror4 2011-02 patch +; +; Revision 1.1.1.1 1999/03/29 15:40:38 jprice +; New version without IPL.SYS +; +; Revision 1.4 1999/02/08 05:55:57 jprice +; Added Pat's 1937 kernel patches +; +; Revision 1.3 1999/02/01 01:48:41 jprice +; Clean up; Now you can use hex numbers in config.sys. added config.sys screen function to change screen mode (28 or 43/50 lines) +; +; Revision 1.2 1999/01/22 04:13:25 jprice +; Formating +; +; Revision 1.1.1.1 1999/01/20 05:51:01 jprice +; Imported sources +; +; Rev 1.4 06 Dec 1998 8:47:02 patv +;Expanded due to new I/O subsystem. +; +; Rev 1.3 16 Jan 1997 12:46:44 patv +;pre-Release 0.92 feature additions +; +; Rev 1.2 29 May 1996 21:03:38 patv +;bug fixes for v0.91a +; +; Rev 1.1 01 Sep 1995 17:54:26 patv +;First GPL release. +; +; Rev 1.0 02 Jul 1995 9:04:50 patv +;Initial revision. +; EndLog +; diff --git a/kernel/asmsupt.asm b/kernel/asmsupt.asm index dd18bb81..5a1abd0a 100644 --- a/kernel/asmsupt.asm +++ b/kernel/asmsupt.asm @@ -32,63 +32,6 @@ ; glibc 2.2 ; ; $Id$ -; -; $Log$ -; Revision 1.6 2001/09/23 20:39:44 bartoldeman -; FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling -; -; Revision 1.5 2001/04/15 03:21:50 bartoldeman -; See history.txt for the list of fixes. -; -; Revision 1.4 2001/03/21 02:56:25 bartoldeman -; See history.txt for changes. Bug fixes and HMA support are the main ones. -; -; Revision 1.3 2000/05/25 20:56:21 jimtabor -; Fixed project history -; -; Revision 1.2 2000/05/08 04:29:59 jimtabor -; Update CVS to 2020 -; -; Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 -; The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with -; MS-DOS. Distributed under the GNU GPL. -; -; Revision 1.3 1999/08/10 17:57:12 jprice -; ror4 2011-02 patch -; -; Revision 1.2 1999/04/23 04:24:39 jprice -; Memory manager changes made by ska -; -; Revision 1.1.1.1 1999/03/29 15:40:41 jprice -; New version without IPL.SYS -; -; Revision 1.4 1999/02/08 05:55:57 jprice -; Added Pat's 1937 kernel patches -; -; Revision 1.3 1999/02/01 01:48:41 jprice -; Clean up; Now you can use hex numbers in config.sys. added config.sys screen function to change screen mode (28 or 43/50 lines) -; -; Revision 1.2 1999/01/22 04:13:25 jprice -; Formating -; -; Revision 1.1.1.1 1999/01/20 05:51:01 jprice -; Imported sources -; -; Rev 1.4 06 Dec 1998 8:46:50 patv -; Bug fixes. -; -; Rev 1.3 03 Jan 1998 8:36:44 patv -; Converted data area to SDA format -; -; Rev 1.2 29 May 1996 21:03:38 patv -; bug fixes for v0.91a -; -; Rev 1.1 01 Sep 1995 17:54:26 patv -; First GPL release. -; -; Rev 1.0 05 Jul 1995 11:38:42 patv -; Initial revision. -; $EndLog$ ; %include "segs.inc" @@ -460,3 +403,42 @@ strncmp_done: or al,1 strncmp_done2: jmp common_return +; Log: asmsupt.asm,v +; +; Revision 1.3 1999/08/10 17:57:12 jprice +; ror4 2011-02 patch +; +; Revision 1.2 1999/04/23 04:24:39 jprice +; Memory manager changes made by ska +; +; Revision 1.1.1.1 1999/03/29 15:40:41 jprice +; New version without IPL.SYS +; +; Revision 1.4 1999/02/08 05:55:57 jprice +; Added Pat's 1937 kernel patches +; +; Revision 1.3 1999/02/01 01:48:41 jprice +; Clean up; Now you can use hex numbers in config.sys. added config.sys screen function to change screen mode (28 or 43/50 lines) +; +; Revision 1.2 1999/01/22 04:13:25 jprice +; Formating +; +; Revision 1.1.1.1 1999/01/20 05:51:01 jprice +; Imported sources +; +; Rev 1.4 06 Dec 1998 8:46:50 patv +; Bug fixes. +; +; Rev 1.3 03 Jan 1998 8:36:44 patv +; Converted data area to SDA format +; +; Rev 1.2 29 May 1996 21:03:38 patv +; bug fixes for v0.91a +; +; Rev 1.1 01 Sep 1995 17:54:26 patv +; First GPL release. +; +; Rev 1.0 05 Jul 1995 11:38:42 patv +; Initial revision. +; EndLog +; diff --git a/kernel/blockio.c b/kernel/blockio.c index 7e54b160..1f4d5406 100644 --- a/kernel/blockio.c +++ b/kernel/blockio.c @@ -35,145 +35,6 @@ static BYTE *blockioRcsId = "$Id$"; #endif -/* - * $Log$ - * Revision 1.15 2001/11/13 23:36:45 bartoldeman - * Kernel 2025a final changes. - * - * Revision 1.14 2001/11/04 19:47:39 bartoldeman - * kernel 2025a changes: see history.txt - * - * Revision 1.13 2001/09/23 20:39:44 bartoldeman - * FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling - * - * Revision 1.12 2001/07/22 01:58:58 bartoldeman - * Support for Brian's FORMAT, DJGPP libc compilation, cleanups, MSCDEX - * - * Revision 1.11 2001/07/09 22:19:33 bartoldeman - * LBA/FCB/FAT/SYS/Ctrl-C/ioctl fixes + memory savings - * - * Revision 1.10 2001/06/03 14:16:17 bartoldeman - * BUFFERS tuning and misc bug fixes/cleanups (2024c). - * - * Revision 1.9 2001/04/21 22:32:53 bartoldeman - * Init DS=Init CS, fixed stack overflow problems and misc bugs. - * - * Revision 1.8 2001/04/15 03:21:50 bartoldeman - * See history.txt for the list of fixes. - * - * Revision 1.7 2001/03/21 02:56:25 bartoldeman - * See history.txt for changes. Bug fixes and HMA support are the main ones. - * - * Revision 1.6 2000/10/30 00:32:08 jimtabor - * Minor Fixes - * - * Revision 1.5 2000/10/30 00:21:15 jimtabor - * Adding Brian Reifsnyder Fix for Int 25/26 - * 2000/9/04 Brian Reifsnyder - * Modified dskxfer() such that error codes are now returned. - * Functions that rely on dskxfer() have also been modified accordingly. - * - * Revision 1.4 2000/05/25 20:56:21 jimtabor - * Fixed project history - * - * Revision 1.3 2000/05/11 04:26:26 jimtabor - * Added code for DOS FN 69 & 6C - * - * Revision 1.2 2000/05/08 04:29:59 jimtabor - * Update CVS to 2020 - * - * Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 - * The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with - * MS-DOS. Distributed under the GNU GPL. - * - * Revision 1.15 2000/04/29 05:13:16 jtabor - * Added new functions and clean up code - * - * Revision 1.14 2000/03/09 06:07:10 kernel - * 2017f updates by James Tabor - * - * Revision 1.13 1999/08/25 03:18:07 jprice - * ror4 patches to allow TC 2.01 compile. - * - * Revision 1.12 1999/08/10 18:03:39 jprice - * ror4 2011-03 patch - * - * Revision 1.11 1999/05/03 06:25:45 jprice - * Patches from ror4 and many changed of signed to unsigned variables. - * - * Revision 1.10 1999/05/03 04:55:35 jprice - * Changed getblock & getbuf so that they leave at least 3 buffer for FAT data. - * - * Revision 1.9 1999/04/21 01:44:40 jprice - * no message - * - * Revision 1.8 1999/04/18 05:28:39 jprice - * no message - * - * Revision 1.7 1999/04/16 21:43:40 jprice - * ror4 multi-sector IO - * - * Revision 1.6 1999/04/16 00:53:32 jprice - * Optimized FAT handling - * - * Revision 1.5 1999/04/12 23:41:53 jprice - * Using getbuf to write data instead of getblock - * using getblock made it read the block before it wrote it - * - * Revision 1.4 1999/04/11 05:28:10 jprice - * Working on multi-block IO - * - * Revision 1.3 1999/04/11 04:33:38 jprice - * ror4 patches - * - * Revision 1.1.1.1 1999/03/29 15:41:43 jprice - * New version without IPL.SYS - * - * Revision 1.5 1999/02/09 02:54:23 jprice - * Added Pat's 1937 kernel patches - * - * Revision 1.4 1999/02/01 01:43:27 jprice - * Fixed findfirst function to find volume label with Windows long filenames - * - * Revision 1.3 1999/01/30 08:25:34 jprice - * Clean up; Fixed bug with set attribute function. If you tried to - * change the attributes of a directory, it would erase it. - * - * Revision 1.2 1999/01/22 04:15:28 jprice - * Formating - * - * Revision 1.1.1.1 1999/01/20 05:51:00 jprice - * Imported sources - * - * - * Rev 1.8 06 Dec 1998 8:43:16 patv - * Changes in block I/O because of new I/O subsystem. - * - * Rev 1.7 22 Jan 1998 4:09:00 patv - * Fixed pointer problems affecting SDA - * - * Rev 1.6 04 Jan 1998 23:14:36 patv - * Changed Log for strip utility - * - * Rev 1.5 03 Jan 1998 8:36:02 patv - * Converted data area to SDA format - * - * Rev 1.4 16 Jan 1997 12:46:34 patv - * pre-Release 0.92 feature additions - * - * Rev 1.3 29 May 1996 21:15:10 patv - * bug fixes for v0.91a - * - * Rev 1.2 01 Sep 1995 17:48:46 patv - * First GPL release. - * - * Rev 1.1 30 Jul 1995 20:50:28 patv - * Eliminated version strings in ipl - * - * Rev 1.0 02 Jul 1995 8:04:06 patv - * Initial revision. - */ - /************************************************************************/ /* */ /* block cache routines */ @@ -681,3 +542,100 @@ UWORD dskxfer(COUNT dsk, ULONG blkno, VOID FAR * buf, UWORD numblocks, COUNT mod /* End of change */ } + +/* + * 2000/9/04 Brian Reifsnyder + * Modified dskxfer() such that error codes are now returned. + * Functions that rely on dskxfer() have also been modified accordingly. + */ + +/* + * Log: blockio.c,v - for newer entries do "cvs log blockio.c" + * + * Revision 1.15 2000/04/29 05:13:16 jtabor + * Added new functions and clean up code + * + * Revision 1.14 2000/03/09 06:07:10 kernel + * 2017f updates by James Tabor + * + * Revision 1.13 1999/08/25 03:18:07 jprice + * ror4 patches to allow TC 2.01 compile. + * + * Revision 1.12 1999/08/10 18:03:39 jprice + * ror4 2011-03 patch + * + * Revision 1.11 1999/05/03 06:25:45 jprice + * Patches from ror4 and many changed of signed to unsigned variables. + * + * Revision 1.10 1999/05/03 04:55:35 jprice + * Changed getblock & getbuf so that they leave at least 3 buffer for FAT data. + * + * Revision 1.9 1999/04/21 01:44:40 jprice + * no message + * + * Revision 1.8 1999/04/18 05:28:39 jprice + * no message + * + * Revision 1.7 1999/04/16 21:43:40 jprice + * ror4 multi-sector IO + * + * Revision 1.6 1999/04/16 00:53:32 jprice + * Optimized FAT handling + * + * Revision 1.5 1999/04/12 23:41:53 jprice + * Using getbuf to write data instead of getblock + * using getblock made it read the block before it wrote it + * + * Revision 1.4 1999/04/11 05:28:10 jprice + * Working on multi-block IO + * + * Revision 1.3 1999/04/11 04:33:38 jprice + * ror4 patches + * + * Revision 1.1.1.1 1999/03/29 15:41:43 jprice + * New version without IPL.SYS + * + * Revision 1.5 1999/02/09 02:54:23 jprice + * Added Pat's 1937 kernel patches + * + * Revision 1.4 1999/02/01 01:43:27 jprice + * Fixed findfirst function to find volume label with Windows long filenames + * + * Revision 1.3 1999/01/30 08:25:34 jprice + * Clean up; Fixed bug with set attribute function. If you tried to + * change the attributes of a directory, it would erase it. + * + * Revision 1.2 1999/01/22 04:15:28 jprice + * Formating + * + * Revision 1.1.1.1 1999/01/20 05:51:00 jprice + * Imported sources + * + * + * Rev 1.8 06 Dec 1998 8:43:16 patv + * Changes in block I/O because of new I/O subsystem. + * + * Rev 1.7 22 Jan 1998 4:09:00 patv + * Fixed pointer problems affecting SDA + * + * Rev 1.6 04 Jan 1998 23:14:36 patv + * Changed Log for strip utility + * + * Rev 1.5 03 Jan 1998 8:36:02 patv + * Converted data area to SDA format + * + * Rev 1.4 16 Jan 1997 12:46:34 patv + * pre-Release 0.92 feature additions + * + * Rev 1.3 29 May 1996 21:15:10 patv + * bug fixes for v0.91a + * + * Rev 1.2 01 Sep 1995 17:48:46 patv + * First GPL release. + * + * Rev 1.1 30 Jul 1995 20:50:28 patv + * Eliminated version strings in ipl + * + * Rev 1.0 02 Jul 1995 8:04:06 patv + * Initial revision. + */ diff --git a/kernel/break.c b/kernel/break.c index a0c574ed..48612e5c 100644 --- a/kernel/break.c +++ b/kernel/break.c @@ -36,38 +36,6 @@ extern void ASMCFUNC spawn_int23(void); static BYTE *RcsId = "$Id$"; #endif -/* - * $Log$ - * Revision 1.7 2001/09/23 20:39:44 bartoldeman - * FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling - * - * Revision 1.6 2001/08/19 12:58:36 bartoldeman - * Time and date fixes, Ctrl-S/P, findfirst/next, FCBs, buffers, tsr unloading - * - * Revision 1.5 2001/04/15 03:21:50 bartoldeman - * See history.txt for the list of fixes. - * - * Revision 1.4 2001/03/21 02:56:25 bartoldeman - * See history.txt for changes. Bug fixes and HMA support are the main ones. - * - * Revision 1.3 2000/05/25 20:56:21 jimtabor - * Fixed project history - * - * Revision 1.2 2000/05/08 04:29:59 jimtabor - * Update CVS to 2020 - * - * Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 - * The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with - * MS-DOS. Distributed under the GNU GPL. - * - * Revision 1.2 2000/03/09 06:07:10 kernel - * 2017f updates by James Tabor - * - * Revision 1.1 1999/04/16 21:18:17 jprice - * Steffen contributed. - * - */ - #define CB_FLG *(UBYTE FAR*)MK_FP(0x40, 0x71) #define CB_MSK 0x80 @@ -102,3 +70,15 @@ void handle_break(void) spawn_int23(); /* invoke user INT-23 and never come back */ } + +/* + * Log: break.c,v - for newer entries see "cvs log break.c" + * + * Revision 1.2 2000/03/09 06:07:10 kernel + * 2017f updates by James Tabor + * + * Revision 1.1 1999/04/16 21:18:17 jprice + * Steffen contributed. + * + */ + diff --git a/kernel/chario.c b/kernel/chario.c index 568fa7fa..baf0d2e7 100644 --- a/kernel/chario.c +++ b/kernel/chario.c @@ -34,114 +34,6 @@ static BYTE *charioRcsId = "$Id$"; #endif -/* - * $Log$ - * Revision 1.13 2001/09/23 20:39:44 bartoldeman - * FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling - * - * Revision 1.12 2001/08/20 20:32:15 bartoldeman - * Truename, get free space and ctrl-break fixes. - * - * Revision 1.11 2001/08/19 12:58:36 bartoldeman - * Time and date fixes, Ctrl-S/P, findfirst/next, FCBs, buffers, tsr unloading - * - * Revision 1.10 2001/07/23 12:47:42 bartoldeman - * FCB fixes and clean-ups, exec int21/ax=4b01, initdisk.c printf - * - * Revision 1.9 2001/06/03 14:16:17 bartoldeman - * BUFFERS tuning and misc bug fixes/cleanups (2024c). - * - * Revision 1.8 2001/04/29 17:34:40 bartoldeman - * A new SYS.COM/config.sys single stepping/console output/misc fixes. - * - * Revision 1.7 2001/04/21 22:32:53 bartoldeman - * Init DS=Init CS, fixed stack overflow problems and misc bugs. - * - * Revision 1.6 2001/04/16 01:45:26 bartoldeman - * Fixed handles, config.sys drivers, warnings. Enabled INT21/AH=6C, printf %S/%Fs - * - * Revision 1.5 2001/04/15 03:21:50 bartoldeman - * See history.txt for the list of fixes. - * - * Revision 1.4 2000/05/26 19:25:19 jimtabor - * Read History file for Change info - * - * Revision 1.3 2000/05/25 20:56:21 jimtabor - * Fixed project history - * - * Revision 1.2 2000/05/08 04:29:59 jimtabor - * Update CVS to 2020 - * - * Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 - * The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with - * MS-DOS. Distributed under the GNU GPL. - * - * Revision 1.7 2000/03/09 06:07:10 kernel - * 2017f updates by James Tabor - * - * Revision 1.6 1999/09/23 04:40:45 jprice - * *** empty log message *** - * - * Revision 1.4 1999/08/25 03:18:07 jprice - * ror4 patches to allow TC 2.01 compile. - * - * Revision 1.3 1999/04/16 12:21:21 jprice - * Steffen c-break handler changes - * - * Revision 1.2 1999/04/04 18:51:42 jprice - * no message - * - * Revision 1.1.1.1 1999/03/29 15:41:45 jprice - * New version without IPL.SYS - * - * Revision 1.5 1999/02/09 02:54:23 jprice - * Added Pat's 1937 kernel patches - * - * Revision 1.4 1999/02/04 03:18:37 jprice - * Formating. Added comments. - * - * Revision 1.3 1999/02/01 01:43:28 jprice - * Fixed findfirst function to find volume label with Windows long filenames - * - * Revision 1.2 1999/01/22 04:15:28 jprice - * Formating - * - * Revision 1.1.1.1 1999/01/20 05:51:00 jprice - * Imported sources - * - * - * Rev 1.9 06 Dec 1998 8:43:36 patv - * changes in character I/O because of new I/O subsystem. - * - * Rev 1.8 11 Jan 1998 2:06:08 patv - * Added functionality to ioctl. - * - * Rev 1.7 08 Jan 1998 21:36:40 patv - * Changed automatic requestic packets to static to save stack space. - * - * Rev 1.6 04 Jan 1998 23:14:38 patv - * Changed Log for strip utility - * - * Rev 1.5 30 Dec 1997 4:00:20 patv - * Modified to support SDA - * - * Rev 1.4 16 Jan 1997 12:46:36 patv - * pre-Release 0.92 feature additions - * - * Rev 1.3 29 May 1996 21:15:12 patv - * bug fixes for v0.91a - * - * Rev 1.2 01 Sep 1995 17:48:42 patv - * First GPL release. - * - * Rev 1.1 30 Jul 1995 20:50:26 patv - * Eliminated version strings in ipl - * - * Rev 1.0 02 Jul 1995 8:05:44 patv - * Initial revision. - * - */ - #include "globals.h" #ifdef PROTO @@ -435,9 +327,11 @@ UCOUNT sti_0a(keyboard FAR * kp) break; } + case F1: case RIGHT: c = local_buffer[kp->kb_count]; - kbfill(kp, c, FALSE, &virt_pos); + if (c) + kbfill(kp, c, FALSE, &virt_pos); break; } break; @@ -475,8 +369,7 @@ UCOUNT sti_0a(keyboard FAR * kp) case CR: #ifndef NOSPCL - fbcopy((BYTE FAR *) kp->kb_buf, - (BYTE FAR *) local_buffer, (COUNT) kp->kb_count); + fmemcpy(local_buffer, kp->kb_buf, (COUNT) kp->kb_count); local_buffer[kp->kb_count] = '\0'; #endif kbfill(kp, CR, TRUE, &virt_pos); @@ -521,3 +414,73 @@ UCOUNT sti(keyboard * kp) } return ReadCount; } + +/* + * Log: chario.c,v - for newer logs do "cvs log chario.c" + * + * Revision 1.7 2000/03/09 06:07:10 kernel + * 2017f updates by James Tabor + * + * Revision 1.6 1999/09/23 04:40:45 jprice + * *** empty log message *** + * + * Revision 1.4 1999/08/25 03:18:07 jprice + * ror4 patches to allow TC 2.01 compile. + * + * Revision 1.3 1999/04/16 12:21:21 jprice + * Steffen c-break handler changes + * + * Revision 1.2 1999/04/04 18:51:42 jprice + * no message + * + * Revision 1.1.1.1 1999/03/29 15:41:45 jprice + * New version without IPL.SYS + * + * Revision 1.5 1999/02/09 02:54:23 jprice + * Added Pat's 1937 kernel patches + * + * Revision 1.4 1999/02/04 03:18:37 jprice + * Formating. Added comments. + * + * Revision 1.3 1999/02/01 01:43:28 jprice + * Fixed findfirst function to find volume label with Windows long filenames + * + * Revision 1.2 1999/01/22 04:15:28 jprice + * Formating + * + * Revision 1.1.1.1 1999/01/20 05:51:00 jprice + * Imported sources + * + * + * Rev 1.9 06 Dec 1998 8:43:36 patv + * changes in character I/O because of new I/O subsystem. + * + * Rev 1.8 11 Jan 1998 2:06:08 patv + * Added functionality to ioctl. + * + * Rev 1.7 08 Jan 1998 21:36:40 patv + * Changed automatic requestic packets to static to save stack space. + * + * Rev 1.6 04 Jan 1998 23:14:38 patv + * Changed Log for strip utility + * + * Rev 1.5 30 Dec 1997 4:00:20 patv + * Modified to support SDA + * + * Rev 1.4 16 Jan 1997 12:46:36 patv + * pre-Release 0.92 feature additions + * + * Rev 1.3 29 May 1996 21:15:12 patv + * bug fixes for v0.91a + * + * Rev 1.2 01 Sep 1995 17:48:42 patv + * First GPL release. + * + * Rev 1.1 30 Jul 1995 20:50:26 patv + * Eliminated version strings in ipl + * + * Rev 1.0 02 Jul 1995 8:05:44 patv + * Initial revision. + * + */ + diff --git a/kernel/config.c b/kernel/config.c index 5b8a2309..b15b2e35 100644 --- a/kernel/config.c +++ b/kernel/config.c @@ -32,6 +32,21 @@ #include "init-dat.h" #include "dyndata.h" +#ifdef VERSION_STRINGS +static BYTE *RcsId = "$Id$"; +#endif + +#ifdef DEBUG + #define DebugPrintf(x) printf x +#else + #define DebugPrintf(x) +#endif + +#ifdef KDB +#include + +#define KernelAlloc(x) adjust_far((void far *)malloc((unsigned long)(x))) +#endif /* These are the far variables from the DOS data segment that we need here. The @@ -77,192 +92,6 @@ extern UWORD DOSFAR ram_top, /* How much ram in Kbytes DOSFAR uppermem_root, DOSFAR LoL_nbuffers; -#ifdef VERSION_STRINGS -static BYTE *RcsId = "$Id$"; -#endif - -#ifdef DEBUG - #define DebugPrintf(x) printf x -#else - #define DebugPrintf(x) -#endif - -/* - * $Log$ - * Revision 1.30 2001/11/13 23:36:45 bartoldeman - * Kernel 2025a final changes. - * - * Revision 1.29 2001/11/04 19:47:39 bartoldeman - * kernel 2025a changes: see history.txt - * - * Revision 1.28 2001/09/23 20:39:44 bartoldeman - * FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling - * - * Revision 1.27 2001/08/19 12:58:36 bartoldeman - * Time and date fixes, Ctrl-S/P, findfirst/next, FCBs, buffers, tsr unloading - * - * Revision 1.26 2001/07/28 18:13:06 bartoldeman - * Fixes for FORMAT+SYS, FATFS, get current dir, kernel init memory situation. - * - * Revision 1.25 2001/07/22 01:58:58 bartoldeman - * Support for Brian's FORMAT, DJGPP libc compilation, cleanups, MSCDEX - * - * Revision 1.24 2001/07/09 22:19:33 bartoldeman - * LBA/FCB/FAT/SYS/Ctrl-C/ioctl fixes + memory savings - * - * Revision 1.23 2001/06/03 14:16:17 bartoldeman - * BUFFERS tuning and misc bug fixes/cleanups (2024c). - * - * Revision 1.22 2001/04/29 17:34:40 bartoldeman - * A new SYS.COM/config.sys single stepping/console output/misc fixes. - * - * Revision 1.21 2001/04/21 22:32:53 bartoldeman - * Init DS=Init CS, fixed stack overflow problems and misc bugs. - * - * Revision 1.20 2001/04/16 14:44:29 bartoldeman - * Removed debug printf. - * - * Revision 1.19 2001/04/16 14:28:32 bartoldeman - * Kernel build 2024. Fixed critical error handler/config.sys/makefiles/UMBs - * - * Revision 1.18 2001/04/16 01:45:26 bartoldeman - * Fixed handles, config.sys drivers, warnings. Enabled INT21/AH=6C, printf %S/%Fs - * - * Revision 1.17 2001/04/15 03:21:50 bartoldeman - * See history.txt for the list of fixes. - * - * Revision 1.16 2001/04/02 23:18:30 bartoldeman - * Misc, zero terminated device names and redirector bugs fixed. - * - * Revision 1.15 2001/03/30 22:27:42 bartoldeman - * Saner lastdrive handling. - * - * Revision 1.14 2001/03/30 19:30:00 bartoldeman - * Misc fixes and implementation of SHELLHIGH. See history.txt for details. - * - * Revision 1.13 2001/03/27 20:27:27 bartoldeman - * dsk.c (reported by Nagy Daniel), inthndlr and int25/26 fixes by Tom Ehlert. - * - * Revision 1.12 2001/03/25 17:11:54 bartoldeman - * Fixed sys.com compilation. Updated to 2023. Also: see history.txt. - * - * Revision 1.11 2001/03/22 04:55:36 bartoldeman - * Fix prototypes. - * - * Revision 1.10 2001/03/21 02:56:25 bartoldeman - * See history.txt for changes. Bug fixes and HMA support are the main ones. - * - * Revision 1.9 2001/03/08 21:15:00 bartoldeman - * Fixed handling of "DOS=UMB", use toupper instead of tolower consistently. - * - * Revision 1.8 2000/08/07 22:51:34 jimtabor - * Remove unused code - * - * Revision 1.7 2000/08/07 03:03:12 jimtabor - * Fix problem with devicehigh - * - * Revision 1.6 2000/08/06 05:50:17 jimtabor - * Add new files and update cvs with patches and changes - * - * Revision 1.5 2000/06/21 18:16:46 jimtabor - * Add UMB code, patch, and code fixes - * - * Revision 1.4 2000/05/26 19:25:19 jimtabor - * Read History file for Change info - * - * Revision 1.3 2000/05/25 20:56:21 jimtabor - * Fixed project history - * - * Revision 1.2 2000/05/08 04:29:59 jimtabor - * Update CVS to 2020 - * - * Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 - * The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with - * MS-DOS. Distributed under the GNU GPL. - * - * Revision 1.15 2000/03/31 05:40:09 jtabor - * Added Eric W. Biederman Patches - * - * Revision 1.14 2000/03/17 22:59:04 kernel - * Steffen Kaiser's NLS changes - * - * Revision 1.13 2000/03/09 06:07:10 kernel - * 2017f updates by James Tabor - * - * Revision 1.12 1999/09/23 04:40:46 jprice - * *** empty log message *** - * - * Revision 1.10 1999/08/25 03:18:07 jprice - * ror4 patches to allow TC 2.01 compile. - * - * Revision 1.9 1999/05/03 06:25:45 jprice - * Patches from ror4 and many changed of signed to unsigned variables. - * - * Revision 1.8 1999/04/16 21:43:40 jprice - * ror4 multi-sector IO - * - * Revision 1.7 1999/04/16 12:21:21 jprice - * Steffen c-break handler changes - * - * Revision 1.6 1999/04/16 00:53:32 jprice - * Optimized FAT handling - * - * Revision 1.5 1999/04/12 03:21:17 jprice - * more ror4 patches. Changes for multi-block IO - * - * Revision 1.4 1999/04/11 04:33:38 jprice - * ror4 patches - * - * Revision 1.2 1999/04/04 22:57:47 jprice - * no message - * - * Revision 1.1.1.1 1999/03/29 15:40:46 jprice - * New version without IPL.SYS - * - * Revision 1.6 1999/03/23 23:38:15 jprice - * Now checks for a reads fdconfig.sys file, if exists - * - * Revision 1.5 1999/02/08 05:55:57 jprice - * Added Pat's 1937 kernel patches - * - * Revision 1.4 1999/02/01 01:48:41 jprice - * Clean up; Now you can use hex numbers in config.sys. added config.sys screen function to change screen mode (28 or 43/50 lines) - * - * Revision 1.3 1999/01/30 08:28:11 jprice - * Clean up; Fixed bug with set attribute function. - * - * Revision 1.2 1999/01/22 04:13:25 jprice - * Formating - * - * Revision 1.1.1.1 1999/01/20 05:51:01 jprice - * Imported sources - * - * - * Rev 1.6 22 Jan 1998 4:09:24 patv - * Fixed pointer problems affecting SDA - * - * Rev 1.5 04 Jan 1998 23:15:18 patv - * Changed Log for strip utility - * - * Rev 1.4 04 Jan 1998 17:26:14 patv - * Corrected subdirectory bug - * - * Rev 1.3 16 Jan 1997 12:46:50 patv - * pre-Release 0.92 feature additions - * - * Rev 1.1 29 May 1996 21:03:44 patv - * bug fixes for v0.91a - * - * Rev 1.0 19 Feb 1996 3:22:16 patv - * Added NLS, int2f and config.sys processing - */ - -#ifdef KDB -#include - -#define KernelAlloc(x) adjust_far((void far *)malloc((unsigned long)(x))) -#endif - struct config Config = { @@ -992,6 +821,7 @@ INIT STATIC VOID sysScreenMode(BYTE * pLine) asm { mov al, byte ptr nMode; mov ah, 0x11; + mov bl, 0; int 0x10; } #endif @@ -1713,3 +1543,83 @@ INIT VOID SetAnyDos(BYTE * pLine) ReturnAnyDosVersionExpected = TRUE; } +/* + * Log: config.c,v - for newer log entries see "cvs log config.c" + * + * Revision 1.15 2000/03/31 05:40:09 jtabor + * Added Eric W. Biederman Patches + * + * Revision 1.14 2000/03/17 22:59:04 kernel + * Steffen Kaiser's NLS changes + * + * Revision 1.13 2000/03/09 06:07:10 kernel + * 2017f updates by James Tabor + * + * Revision 1.12 1999/09/23 04:40:46 jprice + * *** empty log message *** + * + * Revision 1.10 1999/08/25 03:18:07 jprice + * ror4 patches to allow TC 2.01 compile. + * + * Revision 1.9 1999/05/03 06:25:45 jprice + * Patches from ror4 and many changed of signed to unsigned variables. + * + * Revision 1.8 1999/04/16 21:43:40 jprice + * ror4 multi-sector IO + * + * Revision 1.7 1999/04/16 12:21:21 jprice + * Steffen c-break handler changes + * + * Revision 1.6 1999/04/16 00:53:32 jprice + * Optimized FAT handling + * + * Revision 1.5 1999/04/12 03:21:17 jprice + * more ror4 patches. Changes for multi-block IO + * + * Revision 1.4 1999/04/11 04:33:38 jprice + * ror4 patches + * + * Revision 1.2 1999/04/04 22:57:47 jprice + * no message + * + * Revision 1.1.1.1 1999/03/29 15:40:46 jprice + * New version without IPL.SYS + * + * Revision 1.6 1999/03/23 23:38:15 jprice + * Now checks for a reads fdconfig.sys file, if exists + * + * Revision 1.5 1999/02/08 05:55:57 jprice + * Added Pat's 1937 kernel patches + * + * Revision 1.4 1999/02/01 01:48:41 jprice + * Clean up; Now you can use hex numbers in config.sys. added config.sys screen function to change screen mode (28 or 43/50 lines) + * + * Revision 1.3 1999/01/30 08:28:11 jprice + * Clean up; Fixed bug with set attribute function. + * + * Revision 1.2 1999/01/22 04:13:25 jprice + * Formating + * + * Revision 1.1.1.1 1999/01/20 05:51:01 jprice + * Imported sources + * + * + * Rev 1.6 22 Jan 1998 4:09:24 patv + * Fixed pointer problems affecting SDA + * + * Rev 1.5 04 Jan 1998 23:15:18 patv + * Changed Log for strip utility + * + * Rev 1.4 04 Jan 1998 17:26:14 patv + * Corrected subdirectory bug + * + * Rev 1.3 16 Jan 1997 12:46:50 patv + * pre-Release 0.92 feature additions + * + * Rev 1.1 29 May 1996 21:03:44 patv + * bug fixes for v0.91a + * + * Rev 1.0 19 Feb 1996 3:22:16 patv + * Added NLS, int2f and config.sys processing + */ + diff --git a/kernel/console.asm b/kernel/console.asm index f43661a3..93e41267 100644 --- a/kernel/console.asm +++ b/kernel/console.asm @@ -26,55 +26,6 @@ ; Cambridge, MA 02139, USA. ; ; $Header$ -; -; $Log$ -; Revision 1.7 2001/07/09 22:19:33 bartoldeman -; LBA/FCB/FAT/SYS/Ctrl-C/ioctl fixes + memory savings -; -; Revision 1.6 2001/04/15 03:21:50 bartoldeman -; See history.txt for the list of fixes. -; -; Revision 1.5 2001/03/21 02:56:25 bartoldeman -; See history.txt for changes. Bug fixes and HMA support are the main ones. -; -; Revision 1.4 2000/05/26 19:25:19 jimtabor -; Read History file for Change info -; -; Revision 1.3 2000/05/25 20:56:21 jimtabor -; Fixed project history -; -; Revision 1.2 2000/05/08 04:29:59 jimtabor -; Update CVS to 2020 -; -; Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 -; The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with -; MS-DOS. Distributed under the GNU GPL. -; -; Revision 1.8 2000/03/09 06:07:10 kernel -; 2017f updates by James Tabor -; -; Revision 1.7 1999/09/23 04:40:46 jprice -; *** empty log message *** -; -; Revision 1.5 1999/09/14 16:31:38 jprice -; no message -; -; Revision 1.4 1999/09/13 22:16:14 jprice -; Fix 210B function -; -; Revision 1.3 1999/09/13 21:00:19 jprice -; Changes from Helmut Fritsch to fix INT21 func B -; -; Revision 1.2 1999/08/10 17:57:12 jprice -; ror4 2011-02 patch -; -; Revision 1.1.1.1 1999/03/29 15:40:47 jprice -; New version without IPL.SYS -; -; Revision 1.1 1999/02/08 05:55:57 jprice -; Added Pat's 1937 kernel patches -; -; $EndLog$ ; %include "io.inc" @@ -296,3 +247,31 @@ ConNoChar: jmp _IODone ; no key ready (busy=1) +; Log: console.asm,v +; +; Revision 1.8 2000/03/09 06:07:10 kernel +; 2017f updates by James Tabor +; +; Revision 1.7 1999/09/23 04:40:46 jprice +; *** empty log message *** +; +; Revision 1.5 1999/09/14 16:31:38 jprice +; no message +; +; Revision 1.4 1999/09/13 22:16:14 jprice +; Fix 210B function +; +; Revision 1.3 1999/09/13 21:00:19 jprice +; Changes from Helmut Fritsch to fix INT21 func B +; +; Revision 1.2 1999/08/10 17:57:12 jprice +; ror4 2011-02 patch +; +; Revision 1.1.1.1 1999/03/29 15:40:47 jprice +; New version without IPL.SYS +; +; Revision 1.1 1999/02/08 05:55:57 jprice +; Added Pat's 1937 kernel patches +; +; EndLog +; diff --git a/kernel/dosfns.c b/kernel/dosfns.c index aa528059..527001ec 100644 --- a/kernel/dosfns.c +++ b/kernel/dosfns.c @@ -32,181 +32,6 @@ static BYTE *dosfnsRcsId = "$Id$"; #endif -/* - * - * /// Added SHARE support. 2000/09/04 Ron Cemer - * - * $Log$ - * Revision 1.30 2001/11/13 23:36:45 bartoldeman - * Kernel 2025a final changes. - * - * Revision 1.29 2001/11/04 19:47:39 bartoldeman - * kernel 2025a changes: see history.txt - * - * Revision 1.28 2001/09/26 01:06:05 bartoldeman - * Change dir gives error for path too long, 2025 without test. - * - * Revision 1.26 2001/09/23 20:39:44 bartoldeman - * FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling - * - * Revision 1.25 2001/08/20 20:32:15 bartoldeman - * Truename, get free space and ctrl-break fixes. - * - * Revision 1.24 2001/08/19 12:58:36 bartoldeman - * Time and date fixes, Ctrl-S/P, findfirst/next, FCBs, buffers, tsr unloading - * - * Revision 1.23 2001/07/28 18:13:06 bartoldeman - * Fixes for FORMAT+SYS, FATFS, get current dir, kernel init memory situation. - * - * Revision 1.22 2001/07/24 16:56:29 bartoldeman - * fixes for FCBs, DJGPP ls, DBLBYTE, dyninit allocation (2024e). - * - * Revision 1.21 2001/07/23 12:47:42 bartoldeman - * FCB fixes and clean-ups, exec int21/ax=4b01, initdisk.c printf - * - * Revision 1.20 2001/07/22 01:58:58 bartoldeman - * Support for Brian's FORMAT, DJGPP libc compilation, cleanups, MSCDEX - * - * Revision 1.19 2001/07/09 22:19:33 bartoldeman - * LBA/FCB/FAT/SYS/Ctrl-C/ioctl fixes + memory savings - * - * Revision 1.18 2001/06/03 14:16:17 bartoldeman - * BUFFERS tuning and misc bug fixes/cleanups (2024c). - * - * Revision 1.17 2001/04/29 17:34:40 bartoldeman - * A new SYS.COM/config.sys single stepping/console output/misc fixes. - * - * Revision 1.16 2001/04/21 22:32:53 bartoldeman - * Init DS=Init CS, fixed stack overflow problems and misc bugs. - * - * Revision 1.15 2001/04/15 03:21:50 bartoldeman - * See history.txt for the list of fixes. - * - * Revision 1.14 2001/04/02 23:18:30 bartoldeman - * Misc, zero terminated device names and redirector bugs fixed. - * - * Revision 1.13 2001/03/30 22:27:42 bartoldeman - * Saner lastdrive handling. - * - * Revision 1.12 2001/03/30 19:30:06 bartoldeman - * Misc fixes and implementation of SHELLHIGH. See history.txt for details. - * - * Revision 1.11 2001/03/21 02:56:25 bartoldeman - * See history.txt for changes. Bug fixes and HMA support are the main ones. - * - * Revision 1.10 2001/03/08 21:15:00 bartoldeman - * Redirector and DosSelectDrv() (Martin Stromberg) fixes - * - * Revision 1.9 2000/10/29 23:51:56 jimtabor - * Adding Share Support by Ron Cemer - * - * Revision 1.8 2000/08/06 05:50:17 jimtabor - * Add new files and update cvs with patches and changes - * - * Revision 1.7 2000/06/21 18:16:46 jimtabor - * Add UMB code, patch, and code fixes - * - * Revision 1.6 2000/06/01 06:37:38 jimtabor - * Read History for Changes - * - * Revision 1.5 2000/05/26 19:25:19 jimtabor - * Read History file for Change info - * - * Revision 1.4 2000/05/25 20:56:21 jimtabor - * Fixed project history - * - * Revision 1.3 2000/05/17 19:15:12 jimtabor - * Cleanup, add and fix source. - * - * Revision 1.2 2000/05/08 04:29:59 jimtabor - * Update CVS to 2020 - * - * Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 - * The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with - * MS-DOS. Distributed under the GNU GPL. - * - * Revision 1.14 2000/04/02 05:01:08 jtabor - * Replaced ChgDir Code - * - * Revision 1.13 2000/04/02 04:53:56 jtabor - * Fix to DosChgDir - * - * Revision 1.12 2000/03/31 05:40:09 jtabor - * Added Eric W. Biederman Patches - * - * Revision 1.11 2000/03/09 06:07:11 kernel - * 2017f updates by James Tabor - * - * Revision 1.10 1999/09/23 04:40:46 jprice - * *** empty log message *** - * - * Revision 1.8 1999/09/14 01:01:53 jprice - * Fixed bug where you could write over directories. - * - * Revision 1.7 1999/08/25 03:18:07 jprice - * ror4 patches to allow TC 2.01 compile. - * - * Revision 1.6 1999/05/03 06:25:45 jprice - * Patches from ror4 and many changed of signed to unsigned variables. - * - * Revision 1.5 1999/04/16 12:21:22 jprice - * Steffen c-break handler changes - * - * Revision 1.4 1999/04/12 03:21:17 jprice - * more ror4 patches. Changes for multi-block IO - * - * Revision 1.3 1999/04/11 04:33:38 jprice - * ror4 patches - * - * Revision 1.2 1999/04/04 18:51:43 jprice - * no message - * - * Revision 1.1.1.1 1999/03/29 15:41:52 jprice - * New version without IPL.SYS - * - * Revision 1.4 1999/02/09 02:54:23 jprice - * Added Pat's 1937 kernel patches - * - * Revision 1.3 1999/02/01 01:43:28 jprice - * Fixed findfirst function to find volume label with Windows long filenames - * - * Revision 1.2 1999/01/22 04:15:28 jprice - * Formating - * - * Revision 1.1.1.1 1999/01/20 05:51:00 jprice - * Imported sources - * - * Rev 1.10 06 Dec 1998 8:44:42 patv - * Expanded dos functions due to new I/O subsystem. - * - * Rev 1.9 04 Jan 1998 23:14:38 patv - * Changed Log for strip utility - * - * Rev 1.8 03 Jan 1998 8:36:04 patv - * Converted data area to SDA format - * - * Rev 1.7 22 Jan 1997 12:59:56 patv - * pre-0.92 bug fixes - * - * Rev 1.6 16 Jan 1997 12:46:32 patv - * pre-Release 0.92 feature additions - * - * Rev 1.5 29 May 1996 21:15:20 patv - * bug fixes for v0.91a - * - * Rev 1.4 19 Feb 1996 3:20:08 patv - * Added NLS, int2f and config.sys processing - * - * Rev 1.2 01 Sep 1995 17:48:48 patv - * First GPL release. - * - * Rev 1.1 30 Jul 1995 20:50:24 patv - * Eliminated version strings in ipl - * - * Rev 1.0 02 Jul 1995 8:04:20 patv - * Initial revision. - */ - #include "globals.h" COUNT get_free_hndl(VOID); @@ -304,8 +129,8 @@ static VOID DosGetFile(BYTE * lpszPath, BYTE FAR * lpszDosFileName) szLclName, szLclExt, FALSE); SpacePad(szLclName, FNAME_SIZE); SpacePad(szLclExt, FEXT_SIZE); - fbcopy((BYTE FAR *) szLclName, lpszDosFileName, FNAME_SIZE); - fbcopy((BYTE FAR *) szLclExt, &lpszDosFileName[FNAME_SIZE], FEXT_SIZE); + fmemcpy(lpszDosFileName, (BYTE FAR *) szLclName, FNAME_SIZE); + fmemcpy(&lpszDosFileName[FNAME_SIZE], (BYTE FAR *) szLclExt, FEXT_SIZE); } sft FAR *idx_to_sft(COUNT SftIndex) @@ -432,7 +257,7 @@ UCOUNT GenericReadSft(sft FAR *s, UCOUNT n, BYTE FAR * bp, COUNT FAR * err, ReadCount = sti(&kb_buf); if (ReadCount < kb_buf.kb_count) s->sft_flags &= ~SFT_FEOF; - fbcopy((BYTE FAR *) kb_buf.kb_buf, bp, kb_buf.kb_count); + fmemcpy(bp, (BYTE FAR *) kb_buf.kb_buf, kb_buf.kb_count); *err = SUCCESS; return ReadCount; } @@ -849,7 +674,7 @@ COUNT DosCreatSft(BYTE * fname, COUNT attrib) sftp->sft_count += 1; sftp->sft_flags = ((dhp->dh_attr & ~SFT_MASK) & ~SFT_FSHARED) | SFT_FDEVICE | SFT_FEOF; - fbcopy((BYTE FAR *) SecPathName, sftp->sft_name, FNAME_SIZE + FEXT_SIZE); + fmemcpy(sftp->sft_name, (BYTE FAR *) SecPathName, FNAME_SIZE + FEXT_SIZE); sftp->sft_dev = dhp; return sft_idx; } @@ -1034,7 +859,7 @@ COUNT DosOpenSft(BYTE * fname, COUNT mode) sftp->sft_count += 1; sftp->sft_flags = ((dhp->dh_attr & ~SFT_MASK) & ~SFT_FSHARED) | SFT_FDEVICE | SFT_FEOF; - fbcopy((BYTE FAR *) SecPathName, sftp->sft_name, FNAME_SIZE + FEXT_SIZE); + fmemcpy(sftp->sft_name, (BYTE FAR *) SecPathName, FNAME_SIZE + FEXT_SIZE); sftp->sft_dev = dhp; sftp->sft_date = dos_getdate(); sftp->sft_time = dos_gettime(); @@ -1993,3 +1818,91 @@ static int share_lock_unlock /* /// End of additions for SHARE. - Ron Cemer */ +/* + * + * /// Added SHARE support. 2000/09/04 Ron Cemer + * + * Log: dosfns.c,v - for newer log entries do a "cvs log dosfns.c" + * + * Revision 1.14 2000/04/02 05:01:08 jtabor + * Replaced ChgDir Code + * + * Revision 1.13 2000/04/02 04:53:56 jtabor + * Fix to DosChgDir + * + * Revision 1.12 2000/03/31 05:40:09 jtabor + * Added Eric W. Biederman Patches + * + * Revision 1.11 2000/03/09 06:07:11 kernel + * 2017f updates by James Tabor + * + * Revision 1.10 1999/09/23 04:40:46 jprice + * *** empty log message *** + * + * Revision 1.8 1999/09/14 01:01:53 jprice + * Fixed bug where you could write over directories. + * + * Revision 1.7 1999/08/25 03:18:07 jprice + * ror4 patches to allow TC 2.01 compile. + * + * Revision 1.6 1999/05/03 06:25:45 jprice + * Patches from ror4 and many changed of signed to unsigned variables. + * + * Revision 1.5 1999/04/16 12:21:22 jprice + * Steffen c-break handler changes + * + * Revision 1.4 1999/04/12 03:21:17 jprice + * more ror4 patches. Changes for multi-block IO + * + * Revision 1.3 1999/04/11 04:33:38 jprice + * ror4 patches + * + * Revision 1.2 1999/04/04 18:51:43 jprice + * no message + * + * Revision 1.1.1.1 1999/03/29 15:41:52 jprice + * New version without IPL.SYS + * + * Revision 1.4 1999/02/09 02:54:23 jprice + * Added Pat's 1937 kernel patches + * + * Revision 1.3 1999/02/01 01:43:28 jprice + * Fixed findfirst function to find volume label with Windows long filenames + * + * Revision 1.2 1999/01/22 04:15:28 jprice + * Formating + * + * Revision 1.1.1.1 1999/01/20 05:51:00 jprice + * Imported sources + * + * Rev 1.10 06 Dec 1998 8:44:42 patv + * Expanded dos functions due to new I/O subsystem. + * + * Rev 1.9 04 Jan 1998 23:14:38 patv + * Changed Log for strip utility + * + * Rev 1.8 03 Jan 1998 8:36:04 patv + * Converted data area to SDA format + * + * Rev 1.7 22 Jan 1997 12:59:56 patv + * pre-0.92 bug fixes + * + * Rev 1.6 16 Jan 1997 12:46:32 patv + * pre-Release 0.92 feature additions + * + * Rev 1.5 29 May 1996 21:15:20 patv + * bug fixes for v0.91a + * + * Rev 1.4 19 Feb 1996 3:20:08 patv + * Added NLS, int2f and config.sys processing + * + * Rev 1.2 01 Sep 1995 17:48:48 patv + * First GPL release. + * + * Rev 1.1 30 Jul 1995 20:50:24 patv + * Eliminated version strings in ipl + * + * Rev 1.0 02 Jul 1995 8:04:20 patv + * Initial revision. + */ + diff --git a/kernel/dosnames.c b/kernel/dosnames.c index e5d21955..3a99cfb7 100644 --- a/kernel/dosnames.c +++ b/kernel/dosnames.c @@ -34,109 +34,15 @@ static BYTE *dosnamesRcsId = "$Id$"; #endif -/* - * $Log$ - * Revision 1.12 2001/11/04 19:47:39 bartoldeman - * kernel 2025a changes: see history.txt - * - * Revision 1.11 2001/07/24 16:56:29 bartoldeman - * fixes for FCBs, DJGPP ls, DBLBYTE, dyninit allocation (2024e). - * - * Revision 1.10 2001/07/22 01:58:58 bartoldeman - * Support for Brian's FORMAT, DJGPP libc compilation, cleanups, MSCDEX - * - * Revision 1.9 2001/06/03 14:16:17 bartoldeman - * BUFFERS tuning and misc bug fixes/cleanups (2024c). - * - * Revision 1.8 2001/04/15 03:21:50 bartoldeman - * See history.txt for the list of fixes. - * - * Revision 1.7 2001/03/21 02:56:25 bartoldeman - * See history.txt for changes. Bug fixes and HMA support are the main ones. - * - * Revision 1.6 2000/06/21 18:16:46 jimtabor - * Add UMB code, patch, and code fixes - * - * Revision 1.5 2000/06/01 06:37:38 jimtabor - * Read History for Changes - * - * Revision 1.4 2000/05/26 19:25:19 jimtabor - * Read History file for Change info - * - * Revision 1.3 2000/05/25 20:56:21 jimtabor - * Fixed project history - * - * Revision 1.2 2000/05/08 04:29:59 jimtabor - * Update CVS to 2020 - * - * Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 - * The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with - * MS-DOS. Distributed under the GNU GPL. - * - * Revision 1.2 2000/05/08 04:29:59 jimtabor - * Update CVS to 2020 - * - * Revision 1.4 2000/03/31 05:40:09 jtabor - * Added Eric W. Biederman Patches - * - * Revision 1.3 2000/03/09 06:07:11 kernel - * 2017f updates by James Tabor - * - * Revision 1.2 1999/04/04 18:51:43 jprice - * no message - * - * Revision 1.1.1.1 1999/03/29 15:41:54 jprice - * New version without IPL.SYS - * - * Revision 1.4 1999/02/02 04:40:49 jprice - * Steve Miller fixed a bug with doing "cd ." would lock the machine. - * - * Revision 1.3 1999/02/01 01:43:28 jprice - * Fixed findfirst function to find volume label with Windows long filenames - * - * Revision 1.2 1999/01/22 04:15:28 jprice - * Formating - * - * Revision 1.1.1.1 1999/01/20 05:51:00 jprice - * Imported sources - * - * - * Rev 1.8 22 Jan 1998 4:09:00 patv - * Fixed pointer problems affecting SDA - * - * Rev 1.7 04 Jan 1998 23:14:38 patv - * Changed Log for strip utility - * - * Rev 1.6 03 Jan 1998 8:36:04 patv - * Converted data area to SDA format - * - * Rev 1.5 16 Jan 1997 12:46:36 patv - * pre-Release 0.92 feature additions - * - * Rev 1.4 29 May 1996 21:15:12 patv - * bug fixes for v0.91a - * - * Rev 1.3 19 Feb 1996 3:20:08 patv - * Added NLS, int2f and config.sys processing - * - * Rev 1.2 01 Sep 1995 17:48:44 patv - * First GPL release. - * - * Rev 1.1 30 Jul 1995 20:50:26 patv - * Eliminated version strings in ipl - * - * Rev 1.0 02 Jul 1995 8:05:56 patv - * Initial revision. - * - */ - #include "globals.h" +char _DirWildNameChars[] = "*?./\\\"[]:|<>+=;,"; + #define PathSep(c) ((c)=='/'||(c)=='\\') #define DriveChar(c) (((c)>='A'&&(c)<='Z')||((c)>='a'&&(c)<='z')) -#define DirChar(c) (!strchr("\"[]:|<>+=;,", (c))) -#define NameChar(c) (!strchr(".\"/\\[]:|<>+=;,*?", (c))) -#define WildChar(c) (!strchr(".\"/\\[]:|<>+=;,", (c))) +#define DirChar(c) (!strchr(_DirWildNameChars+5, (c))) +#define WildChar(c) (!strchr(_DirWildNameChars+2, (c))) +#define NameChar(c) (!strchr(_DirWildNameChars, (c))) VOID XlateLcase(BYTE * szFname, COUNT nChars); VOID DosTrimPath(BYTE * lpszPathNamep); @@ -357,7 +263,7 @@ COUNT ParseDosPath(BYTE * lpszFileName, /* buffers. */ if (pszDir) { - bcopy(lpszLclDir, pszDir, nDirCnt); + memcpy(pszDir, lpszLclDir, nDirCnt); pszDir[nDirCnt] = '\0'; } @@ -495,3 +401,63 @@ VOID DosTrimPath(BYTE * lpszPathNamep) } #endif +/* + * Log: dosnames.c,v - for newer log entries do "cvs log dosnames.c" + * + * Revision 1.2 2000/05/08 04:29:59 jimtabor + * Update CVS to 2020 + * + * Revision 1.4 2000/03/31 05:40:09 jtabor + * Added Eric W. Biederman Patches + * + * Revision 1.3 2000/03/09 06:07:11 kernel + * 2017f updates by James Tabor + * + * Revision 1.2 1999/04/04 18:51:43 jprice + * no message + * + * Revision 1.1.1.1 1999/03/29 15:41:54 jprice + * New version without IPL.SYS + * + * Revision 1.4 1999/02/02 04:40:49 jprice + * Steve Miller fixed a bug with doing "cd ." would lock the machine. + * + * Revision 1.3 1999/02/01 01:43:28 jprice + * Fixed findfirst function to find volume label with Windows long filenames + * + * Revision 1.2 1999/01/22 04:15:28 jprice + * Formating + * + * Revision 1.1.1.1 1999/01/20 05:51:00 jprice + * Imported sources + * + * + * Rev 1.8 22 Jan 1998 4:09:00 patv + * Fixed pointer problems affecting SDA + * + * Rev 1.7 04 Jan 1998 23:14:38 patv + * Changed Log for strip utility + * + * Rev 1.6 03 Jan 1998 8:36:04 patv + * Converted data area to SDA format + * + * Rev 1.5 16 Jan 1997 12:46:36 patv + * pre-Release 0.92 feature additions + * + * Rev 1.4 29 May 1996 21:15:12 patv + * bug fixes for v0.91a + * + * Rev 1.3 19 Feb 1996 3:20:08 patv + * Added NLS, int2f and config.sys processing + * + * Rev 1.2 01 Sep 1995 17:48:44 patv + * First GPL release. + * + * Rev 1.1 30 Jul 1995 20:50:26 patv + * Eliminated version strings in ipl + * + * Rev 1.0 02 Jul 1995 8:05:56 patv + * Initial revision. + * + */ + diff --git a/kernel/dsk.c b/kernel/dsk.c index e3d76684..075c5eed 100644 --- a/kernel/dsk.c +++ b/kernel/dsk.c @@ -32,136 +32,6 @@ static BYTE *dskRcsId = "$Id$"; #endif -/* - * $Log$ - * Revision 1.22 2001/11/13 23:36:45 bartoldeman - * Kernel 2025a final changes. - * - * Revision 1.21 2001/11/04 19:47:39 bartoldeman - * kernel 2025a changes: see history.txt - * - * Revision 1.20 2001/09/23 20:39:44 bartoldeman - * FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling - * - * Revision 1.19 2001/07/28 18:13:06 bartoldeman - * Fixes for FORMAT+SYS, FATFS, get current dir, kernel init memory situation. - * - * Revision 1.18 2001/07/22 01:58:58 bartoldeman - * Support for Brian's FORMAT, DJGPP libc compilation, cleanups, MSCDEX - * - * Revision 1.17 2001/07/09 22:19:33 bartoldeman - * LBA/FCB/FAT/SYS/Ctrl-C/ioctl fixes + memory savings - * - * Revision 1.17 2001/05/13 tomehlert - * Added full support for LBA hard drives - * initcode moved (mostly) to initdisk.c - * lower interface partly redesigned - * - * Revision 1.16 2001/04/29 brianreifsnyder - * Added phase 1 support for LBA hard drives - * - * Revision 1.15 2001/04/16 01:45:26 bartoldeman - * Fixed handles, config.sys drivers, warnings. Enabled INT21/AH=6C, printf %S/%Fs - * - * Revision 1.14 2001/04/15 03:21:50 bartoldeman - * See history.txt for the list of fixes. - * - * Revision 1.13 2001/03/27 20:27:43 bartoldeman - * dsk.c (reported by Nagy Daniel), inthndlr and int25/26 fixes by Tom Ehlert. - * - * Revision 1.12 2001/03/24 22:13:05 bartoldeman - * See history.txt: dsk.c changes, warning removal and int21 entry handling. - * - * Revision 1.11 2001/03/21 02:56:25 bartoldeman - * See history.txt for changes. Bug fixes and HMA support are the main ones. - * - * Revision 1.9 2001/03/08 21:15:00 bartoldeman - * Space saving fixes from Tom Ehlert - * - * Revision 1.8 2000/06/21 18:16:46 jimtabor - * Add UMB code, patch, and code fixes - * - * Revision 1.7 2000/06/01 06:37:38 jimtabor - * Read History for Changes - * - * Revision 1.6 2000/05/26 19:25:19 jimtabor - * Read History file for Change info - * - * Revision 1.5 2000/05/25 20:56:21 jimtabor - * Fixed project history - * - * Revision 1.4 2000/05/17 19:15:12 jimtabor - * Cleanup, add and fix source. - * - * Revision 1.3 2000/05/11 04:26:26 jimtabor - * Added code for DOS FN 69 & 6C - * - * Revision 1.2 2000/05/08 04:29:59 jimtabor - * Update CVS to 2020 - * - * Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 - * The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with - * MS-DOS. Distributed under the GNU GPL. - * - * Revision 1.6 2000/04/29 05:13:16 jtabor - * Added new functions and clean up code - * - * Revision 1.5 2000/03/09 06:07:11 kernel - * 2017f updates by James Tabor - * - * Revision 1.4 1999/08/10 18:07:57 jprice - * ror4 2011-04 patch - * - * Revision 1.3 1999/04/16 21:43:40 jprice - * ror4 multi-sector IO - * - * Revision 1.2 1999/04/16 00:53:32 jprice - * Optimized FAT handling - * - * Revision 1.1.1.1 1999/03/29 15:40:51 jprice - * New version without IPL.SYS - * - * Revision 1.5 1999/02/14 04:26:46 jprice - * Changed check media so that it checks if a floppy disk has been changed. - * - * Revision 1.4 1999/02/08 05:55:57 jprice - * Added Pat's 1937 kernel patches - * - * Revision 1.3 1999/02/01 01:48:41 jprice - * Clean up; Now you can use hex numbers in config.sys. added config.sys screen function to change screen mode (28 or 43/50 lines) - * - * Revision 1.2 1999/01/22 04:13:25 jprice - * Formating - * - * Revision 1.1.1.1 1999/01/20 05:51:01 jprice - * Imported sources - * - * - * Rev 1.7 06 Dec 1998 8:45:18 patv - * Changed due to new I/O subsystem. - * - * Rev 1.6 04 Jan 1998 23:15:16 patv - * Changed Log for strip utility - * - * Rev 1.5 10 Jan 1997 5:41:48 patv - * Modified for extended partition support - * - * Rev 1.4 29 May 1996 21:03:32 patv - * bug fixes for v0.91a - * - * Rev 1.3 19 Feb 1996 3:21:36 patv - * Added NLS, int2f and config.sys processing - * - * Rev 1.2 01 Sep 1995 17:54:18 patv - * First GPL release. - * - * Rev 1.1 30 Jul 1995 20:52:00 patv - * Eliminated version strings in ipl - * - * Rev 1.0 02 Jul 1995 8:32:42 patv - * Initial revision. - */ - #if defined(DEBUG) #define DebugPrintf(x) printf x #else @@ -508,22 +378,22 @@ static WORD blk_Media(rqptr rp, ddt *pddt) return S_DONE; /* Floppy */ } -static getbpb(ddt *pddt) +static WORD getbpb(ddt *pddt) { ULONG count; bpb *pbpbarray = &pddt->ddt_bpb; WORD head,/*track,*/sector,ret; - ret = RWzero(pddt, LBA_READ); - getword(&((((BYTE *) & DiskTransferBuffer[BT_BPB]))[0]), &pbpbarray->bpb_nbyte); - pddt->ddt_descflags |= DF_NOACCESS; /* set drive to not accessible and changed */ if (diskchange(pddt) != M_NOT_CHANGED) pddt->ddt_descflags |= DF_DISKCHANGE; + ret = RWzero(pddt, LBA_READ); if (ret != 0) return (dskerr(ret)); + getword(&((((BYTE *) & DiskTransferBuffer[BT_BPB]))[0]), &pbpbarray->bpb_nbyte); + if (DiskTransferBuffer[0x1fe]!=0x55 || DiskTransferBuffer[0x1ff]!=0xaa || pbpbarray->bpb_nbyte != 512) { /* copy default bpb to be sure that there is no bogus data */ @@ -1196,3 +1066,117 @@ int LBA_Transfer(ddt *pddt ,UWORD mode, VOID FAR *buffer, return(error_code); } + +/* + * Revision 1.17 2001/05/13 tomehlert + * Added full support for LBA hard drives + * initcode moved (mostly) to initdisk.c + * lower interface partly redesigned + */ + +/* Log: dsk.c,v - for newer log entries: "cvs log dsk.c" + * + * Revision 1.16 2001/04/29 brianreifsnyder + * Added phase 1 support for LBA hard drives + * + * Revision 1.15 2001/04/16 01:45:26 bartoldeman + * Fixed handles, config.sys drivers, warnings. Enabled INT21/AH=6C, printf %S/%Fs + * + * Revision 1.14 2001/04/15 03:21:50 bartoldeman + * See history.txt for the list of fixes. + * + * Revision 1.13 2001/03/27 20:27:43 bartoldeman + * dsk.c (reported by Nagy Daniel), inthndlr and int25/26 fixes by Tom Ehlert. + * + * Revision 1.12 2001/03/24 22:13:05 bartoldeman + * See history.txt: dsk.c changes, warning removal and int21 entry handling. + * + * Revision 1.11 2001/03/21 02:56:25 bartoldeman + * See history.txt for changes. Bug fixes and HMA support are the main ones. + * + * Revision 1.9 2001/03/08 21:15:00 bartoldeman + * Space saving fixes from Tom Ehlert + * + * Revision 1.8 2000/06/21 18:16:46 jimtabor + * Add UMB code, patch, and code fixes + * + * Revision 1.7 2000/06/01 06:37:38 jimtabor + * Read History for Changes + * + * Revision 1.6 2000/05/26 19:25:19 jimtabor + * Read History file for Change info + * + * Revision 1.5 2000/05/25 20:56:21 jimtabor + * Fixed project history + * + * Revision 1.4 2000/05/17 19:15:12 jimtabor + * Cleanup, add and fix source. + * + * Revision 1.3 2000/05/11 04:26:26 jimtabor + * Added code for DOS FN 69 & 6C + * + * Revision 1.2 2000/05/08 04:29:59 jimtabor + * Update CVS to 2020 + * + * Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 + * The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with + * MS-DOS. Distributed under the GNU GPL. + * + * Revision 1.6 2000/04/29 05:13:16 jtabor + * Added new functions and clean up code + * + * Revision 1.5 2000/03/09 06:07:11 kernel + * 2017f updates by James Tabor + * + * Revision 1.4 1999/08/10 18:07:57 jprice + * ror4 2011-04 patch + * + * Revision 1.3 1999/04/16 21:43:40 jprice + * ror4 multi-sector IO + * + * Revision 1.2 1999/04/16 00:53:32 jprice + * Optimized FAT handling + * + * Revision 1.1.1.1 1999/03/29 15:40:51 jprice + * New version without IPL.SYS + * + * Revision 1.5 1999/02/14 04:26:46 jprice + * Changed check media so that it checks if a floppy disk has been changed. + * + * Revision 1.4 1999/02/08 05:55:57 jprice + * Added Pat's 1937 kernel patches + * + * Revision 1.3 1999/02/01 01:48:41 jprice + * Clean up; Now you can use hex numbers in config.sys. added config.sys screen function to change screen mode (28 or 43/50 lines) + * + * Revision 1.2 1999/01/22 04:13:25 jprice + * Formating + * + * Revision 1.1.1.1 1999/01/20 05:51:01 jprice + * Imported sources + * + * + * Rev 1.7 06 Dec 1998 8:45:18 patv + * Changed due to new I/O subsystem. + * + * Rev 1.6 04 Jan 1998 23:15:16 patv + * Changed Log for strip utility + * + * Rev 1.5 10 Jan 1997 5:41:48 patv + * Modified for extended partition support + * + * Rev 1.4 29 May 1996 21:03:32 patv + * bug fixes for v0.91a + * + * Rev 1.3 19 Feb 1996 3:21:36 patv + * Added NLS, int2f and config.sys processing + * + * Rev 1.2 01 Sep 1995 17:54:18 patv + * First GPL release. + * + * Rev 1.1 30 Jul 1995 20:52:00 patv + * Eliminated version strings in ipl + * + * Rev 1.0 02 Jul 1995 8:32:42 patv + * Initial revision. + */ diff --git a/kernel/entry.asm b/kernel/entry.asm index a7deb29f..97e97949 100644 --- a/kernel/entry.asm +++ b/kernel/entry.asm @@ -27,80 +27,6 @@ ; ; $Id$ ; -; $Log$ -; Revision 1.16 2001/11/13 23:36:45 bartoldeman -; Kernel 2025a final changes. -; -; Revision 1.15 2001/11/04 19:47:39 bartoldeman -; kernel 2025a changes: see history.txt -; -; Revision 1.14 2001/09/23 20:39:44 bartoldeman -; FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling -; -; Revision 1.13 2001/04/21 22:32:53 bartoldeman -; Init DS=Init CS, fixed stack overflow problems and misc bugs. -; -; Revision 1.12 2001/04/16 14:28:32 bartoldeman -; Kernel build 2024. Fixed critical error handler/config.sys/makefiles/UMBs -; -; Revision 1.11 2001/04/15 02:26:23 bartoldeman -; Hans Lermen: critical error handler destroyed AH (entry.asm). -; -; Revision 1.10 2001/04/02 23:18:30 bartoldeman -; Misc, zero terminated device names and redirector bugs fixed. -; -; Revision 1.9 2001/03/30 19:30:06 bartoldeman -; Misc fixes and implementation of SHELLHIGH. See history.txt for details. -; -; Revision 1.8 2001/03/27 20:27:43 bartoldeman -; dsk.c (reported by Nagy Daniel), inthndlr and int25/26 fixes by Tom Ehlert. -; -; Revision 1.6 2001/03/24 22:13:05 bartoldeman -; See history.txt: dsk.c changes, warning removal and int21 entry handling. -; -; Revision 1.4 2001/03/21 02:56:25 bartoldeman -; See history.txt for changes. Bug fixes and HMA support are the main ones. -; -; Revision 1.3 2000/05/25 20:56:21 jimtabor -; Fixed project history -; -; Revision 1.2 2000/05/08 04:29:59 jimtabor -; Update CVS to 2020 -; -; Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 -; The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with -; MS-DOS. Distributed under the GNU GPL. -; -; Revision 1.5 2000/03/20 03:15:49 kernel -; Change in Entry.asm -; -; Revision 1.4 1999/09/23 04:40:46 jprice -; *** empty log message *** -; -; Revision 1.2 1999/08/10 17:57:12 jprice -; ror4 2011-02 patch -; -; Revision 1.1.1.1 1999/03/29 15:40:53 jprice -; New version without IPL.SYS -; -; Revision 1.4 1999/02/08 05:55:57 jprice -; Added Pat's 1937 kernel patches -; -; Revision 1.3 1999/02/01 01:48:41 jprice -; Clean up; Now you can use hex numbers in config.sys. added config.sys screen function to change screen mode (28 or 43/50 lines) -; -; Revision 1.2 1999/01/22 04:13:25 jprice -; Formating -; -; Revision 1.1.1.1 1999/01/20 05:51:01 jprice -; Imported sources -; -; Rev 1.1 06 Dec 1998 8:48:40 patv -; New int 21h handler code. -; -; Rev 1.0 07 Feb 1998 20:42:08 patv -; Modified stack frame to match DOS standard -; $EndLog$ %include "segs.inc" %include "stacks.inc" @@ -738,3 +664,35 @@ CritErrAbort: mov [bp+reg_ax],ax sti jmp int21_reentry ; restart the system call + +; Log: entry.asm,v +; Revision 1.5 2000/03/20 03:15:49 kernel +; Change in Entry.asm +; +; Revision 1.4 1999/09/23 04:40:46 jprice +; *** empty log message *** +; +; Revision 1.2 1999/08/10 17:57:12 jprice +; ror4 2011-02 patch +; +; Revision 1.1.1.1 1999/03/29 15:40:53 jprice +; New version without IPL.SYS +; +; Revision 1.4 1999/02/08 05:55:57 jprice +; Added Pat's 1937 kernel patches +; +; Revision 1.3 1999/02/01 01:48:41 jprice +; Clean up; Now you can use hex numbers in config.sys. added config.sys screen function to change screen mode (28 or 43/50 lines) +; +; Revision 1.2 1999/01/22 04:13:25 jprice +; Formating +; +; Revision 1.1.1.1 1999/01/20 05:51:01 jprice +; Imported sources +; +; Rev 1.1 06 Dec 1998 8:48:40 patv +; New int 21h handler code. +; +; Rev 1.0 07 Feb 1998 20:42:08 patv +; Modified stack frame to match DOS standard +; EndLog diff --git a/kernel/error.c b/kernel/error.c index c1a97e9b..8a6df37c 100644 --- a/kernel/error.c +++ b/kernel/error.c @@ -32,62 +32,6 @@ static BYTE *errorRcsId = "$Id$"; #endif -/* - * $Log$ - * Revision 1.5 2001/06/03 14:16:17 bartoldeman - * BUFFERS tuning and misc bug fixes/cleanups (2024c). - * - * Revision 1.4 2001/04/15 03:21:50 bartoldeman - * See history.txt for the list of fixes. - * - * Revision 1.3 2000/05/25 20:56:21 jimtabor - * Fixed project history - * - * Revision 1.2 2000/05/08 04:30:00 jimtabor - * Update CVS to 2020 - * - * Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 - * The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with - * MS-DOS. Distributed under the GNU GPL. - * - * Revision 1.2 2000/03/09 06:07:11 kernel - * 2017f updates by James Tabor - * - * Revision 1.1.1.1 1999/03/29 15:41:55 jprice - * New version without IPL.SYS - * - * Revision 1.4 1999/02/09 02:54:23 jprice - * Added Pat's 1937 kernel patches - * - * Revision 1.3 1999/02/01 01:43:28 jprice - * Fixed findfirst function to find volume label with Windows long filenames - * - * Revision 1.2 1999/01/22 04:15:28 jprice - * Formating - * - * Revision 1.1.1.1 1999/01/20 05:51:00 jprice - * Imported sources - * - * - * Rev 1.5 06 Dec 1998 8:43:54 patv - * Now handles errors like MS-DOS. - * - * Rev 1.4 04 Jan 1998 23:14:36 patv - * Changed Log for strip utility - * - * Rev 1.3 29 May 1996 21:15:10 patv - * bug fixes for v0.91a - * - * Rev 1.2 01 Sep 1995 17:48:46 patv - * First GPL release. - * - * Rev 1.1 30 Jul 1995 20:50:26 patv - * Eliminated version strings in ipl - * - * Rev 1.0 02 Jul 1995 8:06:14 patv - * Initial revision. - */ - #include "globals.h" #ifdef DEBUG @@ -154,3 +98,45 @@ COUNT block_error(request * rq, COUNT nDrive, struct dhdr FAR * lpDevice) rq->r_status & S_MASK, lpDevice); } + +/* + * Log: error.c,v - for newer entries do "cvs log error.c" + * + * Revision 1.2 2000/03/09 06:07:11 kernel + * 2017f updates by James Tabor + * + * Revision 1.1.1.1 1999/03/29 15:41:55 jprice + * New version without IPL.SYS + * + * Revision 1.4 1999/02/09 02:54:23 jprice + * Added Pat's 1937 kernel patches + * + * Revision 1.3 1999/02/01 01:43:28 jprice + * Fixed findfirst function to find volume label with Windows long filenames + * + * Revision 1.2 1999/01/22 04:15:28 jprice + * Formating + * + * Revision 1.1.1.1 1999/01/20 05:51:00 jprice + * Imported sources + * + * + * Rev 1.5 06 Dec 1998 8:43:54 patv + * Now handles errors like MS-DOS. + * + * Rev 1.4 04 Jan 1998 23:14:36 patv + * Changed Log for strip utility + * + * Rev 1.3 29 May 1996 21:15:10 patv + * bug fixes for v0.91a + * + * Rev 1.2 01 Sep 1995 17:48:46 patv + * First GPL release. + * + * Rev 1.1 30 Jul 1995 20:50:26 patv + * Eliminated version strings in ipl + * + * Rev 1.0 02 Jul 1995 8:06:14 patv + * Initial revision. + */ + diff --git a/kernel/execrh.asm b/kernel/execrh.asm index 656d5853..3654e975 100644 --- a/kernel/execrh.asm +++ b/kernel/execrh.asm @@ -25,70 +25,7 @@ ; write to the Free Software Foundation, 675 Mass Ave, ; Cambridge, MA 02139, USA. ; -; $Logfile: C:/usr/patv/dos-c/src/kernel/execrh.asv $ -; ; $Id$ -; -; $Log$ -; Revision 1.8 2001/11/04 19:47:39 bartoldeman -; kernel 2025a changes: see history.txt -; -; Revision 1.7 2001/04/21 22:32:53 bartoldeman -; Init DS=Init CS, fixed stack overflow problems and misc bugs. -; -; Revision 1.6 2001/04/15 03:21:50 bartoldeman -; See history.txt for the list of fixes. -; -; Revision 1.5 2001/04/02 23:18:30 bartoldeman -; Misc, zero terminated device names and redirector bugs fixed. -; -; Revision 1.4 2001/03/21 02:56:25 bartoldeman -; See history.txt for changes. Bug fixes and HMA support are the main ones. -; -; Revision 1.3 2000/05/25 20:56:21 jimtabor -; Fixed project history -; -; Revision 1.2 2000/05/08 04:30:00 jimtabor -; Update CVS to 2020 -; -; Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 -; The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with -; MS-DOS. Distributed under the GNU GPL. -; -; Revision 1.3 2000/03/09 06:07:11 kernel -; 2017f updates by James Tabor -; -; Revision 1.2 1999/08/10 17:57:12 jprice -; ror4 2011-02 patch -; -; Revision 1.1.1.1 1999/03/29 15:40:54 jprice -; New version without IPL.SYS -; -; Revision 1.4 1999/02/08 05:55:57 jprice -; Added Pat's 1937 kernel patches -; -; Revision 1.3 1999/02/01 01:48:41 jprice -; Clean up; Now you can use hex numbers in config.sys. added config.sys screen function to change screen mode (28 or 43/50 lines) -; -; Revision 1.2 1999/01/22 04:13:25 jprice -; Formating -; -; Revision 1.1.1.1 1999/01/20 05:51:01 jprice -; Imported sources -; -; -; Rev 1.3 06 Dec 1998 8:45:06 patv -;Bug fixes. -; -; Rev 1.2 29 May 1996 21:03:30 patv -;bug fixes for v0.91a -; -; Rev 1.1 01 Sep 1995 17:54:22 patv -;First GPL release. -; -; Rev 1.0 02 Jul 1995 9:05:34 patv -;Initial revision. -; $EndLog$ ; %include "segs.inc" @@ -131,3 +68,40 @@ _execrh: pop si pop bp ret + +; Log: execrh.asm,v +; Revision 1.3 2000/03/09 06:07:11 kernel +; 2017f updates by James Tabor +; +; Revision 1.2 1999/08/10 17:57:12 jprice +; ror4 2011-02 patch +; +; Revision 1.1.1.1 1999/03/29 15:40:54 jprice +; New version without IPL.SYS +; +; Revision 1.4 1999/02/08 05:55:57 jprice +; Added Pat's 1937 kernel patches +; +; Revision 1.3 1999/02/01 01:48:41 jprice +; Clean up; Now you can use hex numbers in config.sys. added config.sys screen function to change screen mode (28 or 43/50 lines) +; +; Revision 1.2 1999/01/22 04:13:25 jprice +; Formating +; +; Revision 1.1.1.1 1999/01/20 05:51:01 jprice +; Imported sources +; +; +; Rev 1.3 06 Dec 1998 8:45:06 patv +;Bug fixes. +; +; Rev 1.2 29 May 1996 21:03:30 patv +;bug fixes for v0.91a +; +; Rev 1.1 01 Sep 1995 17:54:22 patv +;First GPL release. +; +; Rev 1.0 02 Jul 1995 9:05:34 patv +;Initial revision. +; EndLog +; diff --git a/kernel/fatdir.c b/kernel/fatdir.c index 35be0360..5445558c 100644 --- a/kernel/fatdir.c +++ b/kernel/fatdir.c @@ -34,171 +34,6 @@ static BYTE *fatdirRcsId = "$Id$"; #endif -/* - * $Log$ - * Revision 1.25 2001/11/13 23:36:45 bartoldeman - * Kernel 2025a final changes. - * - * Revision 1.24 2001/11/04 19:47:39 bartoldeman - * kernel 2025a changes: see history.txt - * - * Revision 1.23 2001/09/23 20:39:44 bartoldeman - * FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling - * - * Revision 1.22 2001/08/19 12:58:36 bartoldeman - * Time and date fixes, Ctrl-S/P, findfirst/next, FCBs, buffers, tsr unloading - * - * Revision 1.21 2001/07/28 18:13:06 bartoldeman - * Fixes for FORMAT+SYS, FATFS, get current dir, kernel init memory situation. - * - * Revision 1.20 2001/07/24 16:56:29 bartoldeman - * fixes for FCBs, DJGPP ls, DBLBYTE, dyninit allocation (2024e). - * - * Revision 1.19 2001/07/23 12:47:42 bartoldeman - * FCB fixes and clean-ups, exec int21/ax=4b01, initdisk.c printf - * - * Revision 1.18 2001/07/22 01:58:58 bartoldeman - * Support for Brian's FORMAT, DJGPP libc compilation, cleanups, MSCDEX - * - * Revision 1.17 2001/07/09 22:19:33 bartoldeman - * LBA/FCB/FAT/SYS/Ctrl-C/ioctl fixes + memory savings - * - * Revision 1.16 2001/06/03 14:16:17 bartoldeman - * BUFFERS tuning and misc bug fixes/cleanups (2024c). - * - * Revision 1.15 2001/04/29 17:34:40 bartoldeman - * A new SYS.COM/config.sys single stepping/console output/misc fixes. - * - * Revision 1.14 2001/04/15 03:21:50 bartoldeman - * See history.txt for the list of fixes. - * - * Revision 1.13 2001/04/02 23:18:30 bartoldeman - * Misc, zero terminated device names and redirector bugs fixed. - * - * Revision 1.12 2001/03/30 22:27:42 bartoldeman - * Saner lastdrive handling. - * - * Revision 1.11 2001/03/21 02:56:25 bartoldeman - * See history.txt for changes. Bug fixes and HMA support are the main ones. - * - * Revision 1.10 2001/03/08 21:00:00 bartoldeman - * Fix handling of very long path names (Tom Ehlert) - * - * Revision 1.9 2000/08/06 05:50:17 jimtabor - * Add new files and update cvs with patches and changes - * - * Revision 1.8 2000/06/21 18:16:46 jimtabor - * Add UMB code, patch, and code fixes - * - * Revision 1.7 2000/06/01 06:46:57 jimtabor - * Removed Debug printf - * - * Revision 1.6 2000/06/01 06:37:38 jimtabor - * Read History for Changes - * - * Revision 1.5 2000/05/26 19:25:19 jimtabor - * Read History file for Change info - * - * Revision 1.4 2000/05/25 20:56:21 jimtabor - * Fixed project history - * - * Revision 1.3 2000/05/17 19:15:12 jimtabor - * Cleanup, add and fix source. - * - * Revision 1.2 2000/05/08 04:30:00 jimtabor - * Update CVS to 2020 - * - * Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 - * The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with - * MS-DOS. Distributed under the GNU GPL. - * - * Revision 1.12 2000/03/31 05:40:09 jtabor - * Added Eric W. Biederman Patches - * - * Revision 1.11 2000/03/17 22:59:04 kernel - * Steffen Kaiser's NLS changes - * - * Revision 1.10 2000/03/09 06:07:11 kernel - * 2017f updates by James Tabor - * - * Revision 1.9 1999/08/25 03:18:07 jprice - * ror4 patches to allow TC 2.01 compile. - * - * Revision 1.8 1999/08/10 17:57:12 jprice - * ror4 2011-02 patch - * - * Revision 1.7 1999/05/03 06:25:45 jprice - * Patches from ror4 and many changed of signed to unsigned variables. - * - * Revision 1.6 1999/04/16 00:53:32 jprice - * Optimized FAT handling - * - * Revision 1.5 1999/04/13 15:48:20 jprice - * no message - * - * Revision 1.4 1999/04/11 04:33:38 jprice - * ror4 patches - * - * Revision 1.2 1999/04/04 18:51:43 jprice - * no message - * - * Revision 1.1.1.1 1999/03/29 15:41:58 jprice - * New version without IPL.SYS - * - * Revision 1.7 1999/03/25 05:06:57 jprice - * Fixed findfirst & findnext functions to treat the attributes like MSDOS does. - * - * Revision 1.6 1999/02/14 04:27:09 jprice - * Changed check media so that it checks if a floppy disk has been changed. - * - * Revision 1.5 1999/02/09 02:54:23 jprice - * Added Pat's 1937 kernel patches - * - * Revision 1.4 1999/02/01 01:43:28 jprice - * Fixed findfirst function to find volume label with Windows long filenames - * - * Revision 1.3 1999/01/30 08:25:34 jprice - * Clean up; Fixed bug with set attribute function. If you tried to - * change the attributres of a directory, it would erase it. - * - * Revision 1.2 1999/01/22 04:15:28 jprice - * Formating - * - * Revision 1.1.1.1 1999/01/20 05:51:00 jprice - * Imported sources - * - * - * Rev 1.10 06 Dec 1998 8:44:36 patv - * Bug fixes. - * - * Rev 1.9 22 Jan 1998 4:09:00 patv - * Fixed pointer problems affecting SDA - * - * Rev 1.8 04 Jan 1998 23:14:36 patv - * Changed Log for strip utility - * - * Rev 1.7 03 Jan 1998 8:36:02 patv - * Converted data area to SDA format - * - * Rev 1.6 16 Jan 1997 12:46:30 patv - * pre-Release 0.92 feature additions - * - * Rev 1.5 29 May 1996 21:15:18 patv - * bug fixes for v0.91a - * - * Rev 1.4 19 Feb 1996 3:20:12 patv - * Added NLS, int2f and config.sys processing - * - * Rev 1.2 01 Sep 1995 17:48:38 patv - * First GPL release. - * - * Rev 1.1 30 Jul 1995 20:50:24 patv - * Eliminated version strings in ipl - * - * Rev 1.0 02 Jul 1995 8:04:34 patv - * Initial revision. - */ - /* Description. * Initialize a fnode so that it will point to the directory with * dirstart starting cluster; in case of passing dirstart == 0 @@ -662,8 +497,7 @@ COUNT dos_findfirst(UCOUNT attr, BYTE *name) dmp->dm_attr_srch = attr; /* Copy the raw pattern from our data segment to the DTA. */ - fbcopy((BYTE FAR *) SearchDir.dir_name, dmp->dm_name_pat, - FNAME_SIZE + FEXT_SIZE); + fmemcpy(dmp->dm_name_pat, SearchDir.dir_name, FNAME_SIZE + FEXT_SIZE); if (attr == D_VOLID) { @@ -853,3 +687,94 @@ int FileName83Length(BYTE *filename83) return strlen(buff); } + +/* + * Log: fatdir.c,v - for newer log entries do a "cvs log fatdir.c" + * + * Revision 1.12 2000/03/31 05:40:09 jtabor + * Added Eric W. Biederman Patches + * + * Revision 1.11 2000/03/17 22:59:04 kernel + * Steffen Kaiser's NLS changes + * + * Revision 1.10 2000/03/09 06:07:11 kernel + * 2017f updates by James Tabor + * + * Revision 1.9 1999/08/25 03:18:07 jprice + * ror4 patches to allow TC 2.01 compile. + * + * Revision 1.8 1999/08/10 17:57:12 jprice + * ror4 2011-02 patch + * + * Revision 1.7 1999/05/03 06:25:45 jprice + * Patches from ror4 and many changed of signed to unsigned variables. + * + * Revision 1.6 1999/04/16 00:53:32 jprice + * Optimized FAT handling + * + * Revision 1.5 1999/04/13 15:48:20 jprice + * no message + * + * Revision 1.4 1999/04/11 04:33:38 jprice + * ror4 patches + * + * Revision 1.2 1999/04/04 18:51:43 jprice + * no message + * + * Revision 1.1.1.1 1999/03/29 15:41:58 jprice + * New version without IPL.SYS + * + * Revision 1.7 1999/03/25 05:06:57 jprice + * Fixed findfirst & findnext functions to treat the attributes like MSDOS does. + * + * Revision 1.6 1999/02/14 04:27:09 jprice + * Changed check media so that it checks if a floppy disk has been changed. + * + * Revision 1.5 1999/02/09 02:54:23 jprice + * Added Pat's 1937 kernel patches + * + * Revision 1.4 1999/02/01 01:43:28 jprice + * Fixed findfirst function to find volume label with Windows long filenames + * + * Revision 1.3 1999/01/30 08:25:34 jprice + * Clean up; Fixed bug with set attribute function. If you tried to + * change the attributres of a directory, it would erase it. + * + * Revision 1.2 1999/01/22 04:15:28 jprice + * Formating + * + * Revision 1.1.1.1 1999/01/20 05:51:00 jprice + * Imported sources + * + * + * Rev 1.10 06 Dec 1998 8:44:36 patv + * Bug fixes. + * + * Rev 1.9 22 Jan 1998 4:09:00 patv + * Fixed pointer problems affecting SDA + * + * Rev 1.8 04 Jan 1998 23:14:36 patv + * Changed Log for strip utility + * + * Rev 1.7 03 Jan 1998 8:36:02 patv + * Converted data area to SDA format + * + * Rev 1.6 16 Jan 1997 12:46:30 patv + * pre-Release 0.92 feature additions + * + * Rev 1.5 29 May 1996 21:15:18 patv + * bug fixes for v0.91a + * + * Rev 1.4 19 Feb 1996 3:20:12 patv + * Added NLS, int2f and config.sys processing + * + * Rev 1.2 01 Sep 1995 17:48:38 patv + * First GPL release. + * + * Rev 1.1 30 Jul 1995 20:50:24 patv + * Eliminated version strings in ipl + * + * Rev 1.0 02 Jul 1995 8:04:34 patv + * Initial revision. + */ + diff --git a/kernel/fatfs.c b/kernel/fatfs.c index 08000d16..e4068ae9 100644 --- a/kernel/fatfs.c +++ b/kernel/fatfs.c @@ -34,232 +34,6 @@ BYTE *RcsId = "$Id$"; #endif -/* - * TE 12 jun 2001 bugs corrected - * handles disk full (in a incompatible way :-( ) - * allows use of last cluster - * prevents mkdir, if disk is full (was creating crosslinked dirs) - * bugs detected, but NOT corrected - * on disk full, MSDOS will NOT write any byte, simply return SUCCESS, 0 bytes - * FreeDOS will write all possible bytes, then close file(BUG) - * - * the dos_mkdir/extenddir (with getblock() instead of getblockOver) was a real - * performance killer on large drives. (~0.5 sec /dos_mkdir) TE - * - * $Log$ - * Revision 1.26 2001/11/13 23:36:45 bartoldeman - * Kernel 2025a final changes. - * - * Revision 1.25 2001/11/04 19:47:39 bartoldeman - * kernel 2025a changes: see history.txt - * - * Revision 1.24 2001/09/23 20:39:44 bartoldeman - * FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling - * - * Revision 1.23 2001/08/19 12:58:36 bartoldeman - * Time and date fixes, Ctrl-S/P, findfirst/next, FCBs, buffers, tsr unloading - * - * Revision 1.22 2001/07/28 18:13:06 bartoldeman - * Fixes for FORMAT+SYS, FATFS, get current dir, kernel init memory situation. - * - * Revision 1.21 2001/07/24 16:56:29 bartoldeman - * fixes for FCBs, DJGPP ls, DBLBYTE, dyninit allocation (2024e). - * - * Revision 1.20 2001/07/22 01:58:58 bartoldeman - * Support for Brian's FORMAT, DJGPP libc compilation, cleanups, MSCDEX - * - * Revision 1.19 2001/07/09 22:19:33 bartoldeman - * LBA/FCB/FAT/SYS/Ctrl-C/ioctl fixes + memory savings - * - * Revision 1.18 2001/06/03 14:16:17 bartoldeman - * BUFFERS tuning and misc bug fixes/cleanups (2024c). - * - * Revision 1.17 2001/04/29 17:34:40 bartoldeman - * A new SYS.COM/config.sys single stepping/console output/misc fixes. - * - * Revision 1.16 2001/04/21 22:32:53 bartoldeman - * Init DS=Init CS, fixed stack overflow problems and misc bugs. - * - * Revision 1.15 2001/04/16 01:45:26 bartoldeman - * Fixed handles, config.sys drivers, warnings. Enabled INT21/AH=6C, printf %S/%Fs - * - * Revision 1.14 2001/04/15 03:21:50 bartoldeman - * See history.txt for the list of fixes. - * - * Revision 1.13 2001/03/30 19:30:06 bartoldeman - * Misc fixes and implementation of SHELLHIGH. See history.txt for details. - * - * Revision 1.12 2001/03/24 22:13:05 bartoldeman - * See history.txt: dsk.c changes, warning removal and int21 entry handling. - * - * Revision 1.11 2001/03/22 04:26:14 bartoldeman - * dos_gettime() fix by Tom Ehlert. - * - * Revision 1.10 2001/03/21 02:56:25 bartoldeman - * See history.txt for changes. Bug fixes and HMA support are the main ones. - * - * Revision 1.9 2001/03/08 21:00:00 bartoldeman - * Disabled select_unit() since it's not used - * - * Revision 1.8 2000/10/29 23:51:56 jimtabor - * Adding Share Support by Ron Cemer - * - * Revision 1.7 2000/09/05 00:56:50 jimtabor - * *** empty log message *** - * - * - * /// 2000/08/12 22:49:00 Ron Cemer - * Fixed writeblock() to only use getbuf() if writing a - * complete sector; otherwise use getbloc() and do a - * read-modify-write to prevent writing garbage back - * over pre-existing data in the file. - * This was a major BUG. - * - * Revision 1.6 2000/08/06 05:50:17 jimtabor - * Add new files and update cvs with patches and changes - * - * Revision 1.5 2000/06/21 18:16:46 jimtabor - * Add UMB code, patch, and code fixes - * - * Revision 1.4 2000/05/25 20:56:21 jimtabor - * Fixed project history - * - * Revision 1.3 2000/05/11 04:26:26 jimtabor - * Added code for DOS FN 69 & 6C - * - * Revision 1.2 2000/05/08 04:30:00 jimtabor - * Update CVS to 2020 - * - * Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 - * The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with - * MS-DOS. Distributed under the GNU GPL. - * - * Revision 1.23 2000/04/29 05:13:16 jtabor - * Added new functions and clean up code - * - * Revision 1.19 2000/03/17 22:59:04 kernel - * Steffen Kaiser's NLS changes - * - * Revision 1.18 2000/03/17 04:13:12 kernel - * Added Change for media_check - * - * Revision 1.17 2000/03/17 04:01:20 kernel - * Added Change for media_check - * - * Revision 1.16 2000/03/09 06:07:11 kernel - * 2017f updates by James Tabor - * - * Revision 1.15 1999/09/23 04:40:46 jprice - * *** empty log message *** - * - * Revision 1.12 1999/09/14 01:01:54 jprice - * Fixed bug where you could write over directories. - * - * Revision 1.11 1999/08/25 03:18:08 jprice - * ror4 patches to allow TC 2.01 compile. - * - * Revision 1.10 1999/08/10 18:03:42 jprice - * ror4 2011-03 patch - * - * Revision 1.9 1999/05/03 06:25:45 jprice - * Patches from ror4 and many changed of signed to unsigned variables. - * - * Revision 1.8 1999/05/03 05:00:24 jprice - * Fixed bug in map_cluster function - * - * Revision 1.7 1999/04/16 00:53:33 jprice - * Optimized FAT handling - * - * Revision 1.6 1999/04/12 23:41:54 jprice - * Using getbuf to write data instead of getblock - * using getblock made it read the block before it wrote it - * - * Revision 1.5 1999/04/12 03:21:17 jprice - * more ror4 patches. Changes for multi-block IO - * - * Revision 1.4 1999/04/11 04:33:38 jprice - * ror4 patches - * - * Revision 1.2 1999/04/04 18:51:43 jprice - * no message - * - * Revision 1.1.1.1 1999/03/29 15:42:07 jprice - * New version without IPL.SYS - * - * Revision 1.8 1999/03/23 23:37:39 jprice - * Fixed mkdir DOS function so it will create a directory with same name as the volument label - * - * Revision 1.7 1999/03/02 07:00:51 jprice - * Fixed bugs with dos set attribute function. Now returns correct - * error code, and errors if user tries to set bits 6 & 7. - * - * Revision 1.6 1999/02/09 02:54:23 jprice - * Added Pat's 1937 kernel patches - * - * Revision 1.5 1999/02/04 03:18:37 jprice - * Formating. Added comments. - * - * Revision 1.4 1999/02/01 01:43:28 jprice - * Fixed findfirst function to find volume label with Windows long filenames - * - * Revision 1.3 1999/01/30 08:25:34 jprice - * Clean up; Fixed bug with set attribute function. If you tried to - * change the attributes of a directory, it would erase it. - * - * Revision 1.2 1999/01/22 04:15:28 jprice - * Formating - * - * Revision 1.1.1.1 1999/01/20 05:51:00 jprice - * Imported sources - * - * - * Rev 1.14 06 Dec 1998 8:44:26 patv - * Bug fixes. - * - * Rev 1.13 09 Feb 1998 5:43:30 patv - * Eliminated FAT12 EOF and error useage. - * - * Rev 1.12 03 Feb 1998 11:28:04 patv - * Fixed lseek bug. - * - * Rev 1.11 22 Jan 1998 5:38:08 patv - * Corrected remaining file name and extension copies that did not - * account for far file nodes due to allocated FILES= spec. - * - * Rev 1.10 22 Jan 1998 4:09:00 patv - * Fixed pointer problems affecting SDA - * - * Rev 1.9 04 Jan 1998 23:14:40 patv - * Changed Log for strip utility - * - * Rev 1.8 04 Jan 1998 17:24:14 patv - * Corrected subdirectory bug - * - * Rev 1.7 03 Jan 1998 8:36:04 patv - * Converted data area to SDA format - * - * Rev 1.6 22 Jan 1997 13:00:30 patv - * pre-0.92 bug fixes - * - * Rev 1.5 16 Jan 1997 12:46:24 patv - * pre-Release 0.92 feature additions - * - * Rev 1.4 29 May 1996 21:15:16 patv - * bug fixes for v0.91a - * - * Rev 1.3 19 Feb 1996 3:20:10 patv - * Added NLS, int2f and config.sys processing - * - * Rev 1.2 01 Sep 1995 17:48:40 patv - * First GPL release. - * - * Rev 1.1 30 Jul 1995 20:50:24 patv - * Eliminated version strings in ipl - * - * Rev 1.0 02 Jul 1995 8:04:46 patv - * Initial revision. - */ - /* */ /* function prototypes */ /* */ @@ -440,7 +214,7 @@ f_node_ptr /* directory... */ if (!szDirName[2]) { - fsncopy(cdsp->cdsCurrentPath, (BYTE FAR *) szDirName, PARSE_MAX); + fstrncpy(szDirName, cdsp->cdsCurrentPath, PARSE_MAX); } /* 11/29/99 jt @@ -667,8 +441,8 @@ COUNT dos_creat(BYTE * path, COUNT attrib) } /* put the fnode's name into the directory. */ - bcopy(szFileName, fnp->f_dir.dir_name, FNAME_SIZE); - bcopy(szFileExt, fnp->f_dir.dir_ext, FEXT_SIZE); + memcpy(fnp->f_dir.dir_name, szFileName, FNAME_SIZE); + memcpy(fnp->f_dir.dir_ext, szFileExt, FEXT_SIZE); } /* Set the fnode to the desired mode */ /* Updating the directory entry first. */ @@ -923,8 +697,8 @@ COUNT dos_rename(BYTE * path1, BYTE * path2) return ret; /* put the fnode's name into the directory. */ - bcopy(szFileName, (BYTE *)fnp2->f_dir.dir_name, FNAME_SIZE); - bcopy(szFileExt, (BYTE *)fnp2->f_dir.dir_ext, FEXT_SIZE); + memcpy(fnp2->f_dir.dir_name, szFileName, FNAME_SIZE); + memcpy(fnp2->f_dir.dir_ext, szFileExt, FEXT_SIZE); /* Set the fnode to the desired mode */ fnp2->f_dir.dir_size = fnp1->f_dir.dir_size; @@ -1344,8 +1118,8 @@ COUNT dos_mkdir(BYTE * dir) /* put the fnode's name into the directory. */ - bcopy(szFileName, (BYTE *) fnp->f_dir.dir_name, FNAME_SIZE); - bcopy(szFileExt, (BYTE *) fnp->f_dir.dir_ext, FEXT_SIZE); + memcpy(fnp->f_dir.dir_name, szFileName, FNAME_SIZE); + memcpy(fnp->f_dir.dir_ext, szFileExt, FEXT_SIZE); /* Set the fnode to the desired mode */ fnp->f_mode = WRONLY; @@ -1385,8 +1159,8 @@ COUNT dos_mkdir(BYTE * dir) } /* Create the "." entry */ - bcopy(". ", (BYTE *) DirEntBuffer.dir_name, FNAME_SIZE); - bcopy(" ", (BYTE *) DirEntBuffer.dir_ext, FEXT_SIZE); + memcpy(DirEntBuffer.dir_name, ". ", FNAME_SIZE); + memcpy(DirEntBuffer.dir_ext, " ", FEXT_SIZE); DirEntBuffer.dir_attrib = D_DIR; DirEntBuffer.dir_time = dos_gettime(); DirEntBuffer.dir_date = dos_getdate(); @@ -1397,7 +1171,7 @@ COUNT dos_mkdir(BYTE * dir) putdirent((struct dirent FAR *)&DirEntBuffer, (BYTE FAR *) bp->b_buffer); /* create the ".." entry */ - bcopy(".. ", (BYTE *) DirEntBuffer.dir_name, FNAME_SIZE); + memcpy(DirEntBuffer.dir_name, ".. ", FNAME_SIZE); #ifdef WITHFAT32 if (ISFAT32(dpbp) && parent == dpbp->dpb_xrootclst) { parent = 0; @@ -1780,23 +1554,20 @@ UCOUNT readblock(COUNT fd, VOID FAR * buffer, UCOUNT count, COUNT * err) /* can utilize memory management in future DOS-C versions. */ while (ret_cnt < count) { + /* Do an EOF test and return whatever was transferred */ + /* but only for regular files. */ + if (!(fnp->f_flags.f_ddir) + && (fnp->f_offset >= fnp->f_highwater)) + { + *err = SUCCESS; + return ret_cnt; + } + /* Position the file to the fnode's pointer position. This is */ /* done by updating the fnode's cluster, block (sector) and */ /* byte offset so that read becomes a simple data move */ /* out of the block data buffer. */ - if (fnp->f_offset == 0l) - { - /* complete the common operations of */ - /* initializing to the starting cluster and */ - /* setting all offsets to zero. */ - fnp->f_cluster = fnp->f_flags.f_ddir ? fnp->f_dirstart : - getdstart(fnp->f_dir); - fnp->f_cluster_offset = 0l; - fnp->f_back = LONG_LAST_CLUSTER; - fnp->f_sector = 0; - fnp->f_boff = 0; - } /* The more difficult scenario is the (more common) */ /* file offset case. Here, we need to take the fnode's */ /* offset pointer (f_offset) and translate it into a */ @@ -1814,17 +1585,14 @@ UCOUNT readblock(COUNT fd, VOID FAR * buffer, UCOUNT count, COUNT * err) /* The algorithm in this function takes advantage of */ /* the blockio block buffering scheme to simplify the */ /* task. */ - else - { #ifdef DISPLAY_GETBLOCK - printf("readblock: "); + printf("readblock: "); #endif - if (map_cluster(fnp, XFR_READ) != SUCCESS) - { - *err = DE_SEEK; - dir_close(fnp); - return ret_cnt; - } + if (map_cluster(fnp, XFR_READ) != SUCCESS) + { + *err = DE_SEEK; + dir_close(fnp); + return ret_cnt; } /* Compute the block within the cluster and the offset */ @@ -1832,9 +1600,6 @@ UCOUNT readblock(COUNT fd, VOID FAR * buffer, UCOUNT count, COUNT * err) fnp->f_sector = (fnp->f_offset / secsize) & fnp->f_dpb->dpb_clsmask; fnp->f_boff = fnp->f_offset & (secsize - 1); - - - currentblock = clus2phys(fnp->f_cluster, fnp->f_dpb) + fnp->f_sector; /* see comments above */ @@ -1884,7 +1649,7 @@ UCOUNT readblock(COUNT fd, VOID FAR * buffer, UCOUNT count, COUNT * err) DeleteBlockInBufferCache(currentblock, currentblock + sectors_to_read - 1, fnp->f_dpb->dpb_unit); - + if (dskxfer(fnp->f_dpb->dpb_unit, currentblock, (VOID FAR *) buffer, sectors_to_read, DSKREAD)) @@ -1903,7 +1668,7 @@ UCOUNT readblock(COUNT fd, VOID FAR * buffer, UCOUNT count, COUNT * err) /* normal read: just the old, buffer = sector based read */ -normal_read: +normal_read: #ifdef DSK_DEBUG @@ -1912,14 +1677,6 @@ UCOUNT readblock(COUNT fd, VOID FAR * buffer, UCOUNT count, COUNT * err) fnp->f_diroff, fnp->f_cluster); #endif - /* Do an EOF test and return whatever was transferred */ - /* but only for regular files. */ - if (!(fnp->f_flags.f_ddir) - && (fnp->f_offset >= fnp->f_highwater)) - { - *err = SUCCESS; - return ret_cnt; - } /* Get the block we need from cache */ bp = getblock(currentblock /*clus2phys(fnp->f_cluster, fnp->f_dpb) + fnp->f_sector*/, @@ -1945,7 +1702,7 @@ UCOUNT readblock(COUNT fd, VOID FAR * buffer, UCOUNT count, COUNT * err) xfr_cnt = (UWORD)min(min(to_xfer, secsize - fnp->f_boff), fnp->f_highwater - fnp->f_offset); - fbcopy((BYTE FAR *) & bp->b_buffer[fnp->f_boff], buffer, xfr_cnt); + fmemcpy(buffer, &bp->b_buffer[fnp->f_boff], xfr_cnt); /* complete buffer read ? probably not reused later @@ -2114,6 +1871,7 @@ UCOUNT writeblock(COUNT fd, VOID FAR * buffer, UCOUNT count, COUNT * err) /* FAT allocation has to be extended if necessary TE */ /* Now done in dos_extend BO */ /* remove all the following allocated clusters in shrink_file */ + fnp->f_highwater = fnp->f_offset; shrink_file(fnp); return 0; } @@ -2246,7 +2004,7 @@ UCOUNT writeblock(COUNT fd, VOID FAR * buffer, UCOUNT count, COUNT * err) - Ron Cemer xfr_cnt = min(to_xfer, secsize - fnp->f_boff); */ - fbcopy(buffer, (BYTE FAR *) & bp->b_buffer[fnp->f_boff], xfr_cnt); + fmemcpy(&bp->b_buffer[fnp->f_boff], buffer, xfr_cnt); bp->b_flag |= BFR_DIRTY | BFR_VALID; if (xfr_cnt == sizeof(bp->b_buffer)) /* probably not used later */ @@ -2713,3 +2471,150 @@ STATIC VOID shrink_file(f_node_ptr fnp) } +/* + * TE 12 jun 2001 bugs corrected + * handles disk full (in a incompatible way :-( ) + * allows use of last cluster + * prevents mkdir, if disk is full (was creating crosslinked dirs) + * bugs detected, but NOT corrected + * on disk full, MSDOS will NOT write any byte, simply return SUCCESS, 0 bytes + * FreeDOS will write all possible bytes, then close file(BUG) + * + * the dos_mkdir/extenddir (with getblock() instead of getblockOver) was a real + * performance killer on large drives. (~0.5 sec /dos_mkdir) TE + * + * Log: fatfs.c,v - for newer log entries do "cvs log fatfs.c" + * + * /// 2000/08/12 22:49:00 Ron Cemer + * Fixed writeblock() to only use getbuf() if writing a + * complete sector; otherwise use getbloc() and do a + * read-modify-write to prevent writing garbage back + * over pre-existing data in the file. + * This was a major BUG. + * + * Revision 1.23 2000/04/29 05:13:16 jtabor + * Added new functions and clean up code + * + * Revision 1.19 2000/03/17 22:59:04 kernel + * Steffen Kaiser's NLS changes + * + * Revision 1.18 2000/03/17 04:13:12 kernel + * Added Change for media_check + * + * Revision 1.17 2000/03/17 04:01:20 kernel + * Added Change for media_check + * + * Revision 1.16 2000/03/09 06:07:11 kernel + * 2017f updates by James Tabor + * + * Revision 1.15 1999/09/23 04:40:46 jprice + * *** empty log message *** + * + * Revision 1.12 1999/09/14 01:01:54 jprice + * Fixed bug where you could write over directories. + * + * Revision 1.11 1999/08/25 03:18:08 jprice + * ror4 patches to allow TC 2.01 compile. + * + * Revision 1.10 1999/08/10 18:03:42 jprice + * ror4 2011-03 patch + * + * Revision 1.9 1999/05/03 06:25:45 jprice + * Patches from ror4 and many changed of signed to unsigned variables. + * + * Revision 1.8 1999/05/03 05:00:24 jprice + * Fixed bug in map_cluster function + * + * Revision 1.7 1999/04/16 00:53:33 jprice + * Optimized FAT handling + * + * Revision 1.6 1999/04/12 23:41:54 jprice + * Using getbuf to write data instead of getblock + * using getblock made it read the block before it wrote it + * + * Revision 1.5 1999/04/12 03:21:17 jprice + * more ror4 patches. Changes for multi-block IO + * + * Revision 1.4 1999/04/11 04:33:38 jprice + * ror4 patches + * + * Revision 1.2 1999/04/04 18:51:43 jprice + * no message + * + * Revision 1.1.1.1 1999/03/29 15:42:07 jprice + * New version without IPL.SYS + * + * Revision 1.8 1999/03/23 23:37:39 jprice + * Fixed mkdir DOS function so it will create a directory with same name as the volument label + * + * Revision 1.7 1999/03/02 07:00:51 jprice + * Fixed bugs with dos set attribute function. Now returns correct + * error code, and errors if user tries to set bits 6 & 7. + * + * Revision 1.6 1999/02/09 02:54:23 jprice + * Added Pat's 1937 kernel patches + * + * Revision 1.5 1999/02/04 03:18:37 jprice + * Formating. Added comments. + * + * Revision 1.4 1999/02/01 01:43:28 jprice + * Fixed findfirst function to find volume label with Windows long filenames + * + * Revision 1.3 1999/01/30 08:25:34 jprice + * Clean up; Fixed bug with set attribute function. If you tried to + * change the attributes of a directory, it would erase it. + * + * Revision 1.2 1999/01/22 04:15:28 jprice + * Formating + * + * Revision 1.1.1.1 1999/01/20 05:51:00 jprice + * Imported sources + * + * + * Rev 1.14 06 Dec 1998 8:44:26 patv + * Bug fixes. + * + * Rev 1.13 09 Feb 1998 5:43:30 patv + * Eliminated FAT12 EOF and error useage. + * + * Rev 1.12 03 Feb 1998 11:28:04 patv + * Fixed lseek bug. + * + * Rev 1.11 22 Jan 1998 5:38:08 patv + * Corrected remaining file name and extension copies that did not + * account for far file nodes due to allocated FILES= spec. + * + * Rev 1.10 22 Jan 1998 4:09:00 patv + * Fixed pointer problems affecting SDA + * + * Rev 1.9 04 Jan 1998 23:14:40 patv + * Changed Log for strip utility + * + * Rev 1.8 04 Jan 1998 17:24:14 patv + * Corrected subdirectory bug + * + * Rev 1.7 03 Jan 1998 8:36:04 patv + * Converted data area to SDA format + * + * Rev 1.6 22 Jan 1997 13:00:30 patv + * pre-0.92 bug fixes + * + * Rev 1.5 16 Jan 1997 12:46:24 patv + * pre-Release 0.92 feature additions + * + * Rev 1.4 29 May 1996 21:15:16 patv + * bug fixes for v0.91a + * + * Rev 1.3 19 Feb 1996 3:20:10 patv + * Added NLS, int2f and config.sys processing + * + * Rev 1.2 01 Sep 1995 17:48:40 patv + * First GPL release. + * + * Rev 1.1 30 Jul 1995 20:50:24 patv + * Eliminated version strings in ipl + * + * Rev 1.0 02 Jul 1995 8:04:46 patv + * Initial revision. + */ + diff --git a/kernel/fattab.c b/kernel/fattab.c index eaec6df0..ce510d4b 100644 --- a/kernel/fattab.c +++ b/kernel/fattab.c @@ -33,92 +33,6 @@ static BYTE *RcsId = "$Id$"; #endif -/* - * $Log$ - * Revision 1.10 2001/11/13 23:36:45 bartoldeman - * Kernel 2025a final changes. - * - * Revision 1.9 2001/11/04 19:47:39 bartoldeman - * kernel 2025a changes: see history.txt - * - * Revision 1.8 2001/09/23 20:39:44 bartoldeman - * FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling - * - * Revision 1.7 2001/07/09 22:19:33 bartoldeman - * LBA/FCB/FAT/SYS/Ctrl-C/ioctl fixes + memory savings - * - * Revision 1.6 2001/06/03 14:16:17 bartoldeman - * BUFFERS tuning and misc bug fixes/cleanups (2024c). - * - * Revision 1.5 2001/04/21 22:32:53 bartoldeman - * Init DS=Init CS, fixed stack overflow problems and misc bugs. - * - * Revision 1.4 2001/04/15 03:21:50 bartoldeman - * See history.txt for the list of fixes. - * - * Revision 1.3 2000/05/25 20:56:21 jimtabor - * Fixed project history - * - * Revision 1.2 2000/05/08 04:30:00 jimtabor - * Update CVS to 2020 - * - * Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 - * The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with - * MS-DOS. Distributed under the GNU GPL. - * - * Revision 1.6 1999/08/10 18:03:42 jprice - * ror4 2011-03 patch - * - * Revision 1.5 1999/05/03 06:25:45 jprice - * Patches from ror4 and many changed of signed to unsigned variables. - * - * Revision 1.4 1999/04/16 00:53:33 jprice - * Optimized FAT handling - * - * Revision 1.3 1999/04/11 04:33:38 jprice - * ror4 patches - * - * Revision 1.1.1.1 1999/03/29 15:42:09 jprice - * New version without IPL.SYS - * - * Revision 1.4 1999/02/09 02:54:23 jprice - * Added Pat's 1937 kernel patches - * - * Revision 1.3 1999/02/01 01:43:28 jprice - * Fixed findfirst function to find volume label with Windows long filenames - * - * Revision 1.2 1999/01/22 04:15:28 jprice - * Formating - * - * Revision 1.1.1.1 1999/01/20 05:51:00 jprice - * Imported sources - * - * - * Rev 1.7 09 Feb 1998 5:41:08 patv - * Eliminated FAT12 EOF and error returns. - * - * Rev 1.6 04 Jan 1998 23:14:38 patv - * Changed Log for strip utility - * - * Rev 1.5 16 Jan 1997 12:46:22 patv - * pre-Release 0.92 feature additions - * - * Rev 1.4 29 May 1996 21:15:14 patv - * bug fixes for v0.91a - * - * Rev 1.3 19 Feb 1996 3:20:08 patv - * Added NLS, int2f and config.sys processing - * - * Rev 1.2 01 Sep 1995 17:48:42 patv - * First GPL release. - * - * Rev 1.1 30 Jul 1995 20:50:26 patv - * Eliminated version strings in ipl - * - * Rev 1.0 02 Jul 1995 8:04:56 patv - * Initial revision. - */ - #ifdef PROTO UCOUNT link_fat12(struct dpb FAR *, CLUSTER, CLUSTER); UCOUNT link_fat16(struct dpb FAR *, CLUSTER, CLUSTER); @@ -508,3 +422,61 @@ CLUSTER next_cluster(struct dpb FAR *dpbp, CLUSTER ClusterNum) return LONG_LAST_CLUSTER; } +/* + * Log: fattab.c,v - for newer log entries do "cvs log fattab.c" + * + * Revision 1.6 1999/08/10 18:03:42 jprice + * ror4 2011-03 patch + * + * Revision 1.5 1999/05/03 06:25:45 jprice + * Patches from ror4 and many changed of signed to unsigned variables. + * + * Revision 1.4 1999/04/16 00:53:33 jprice + * Optimized FAT handling + * + * Revision 1.3 1999/04/11 04:33:38 jprice + * ror4 patches + * + * Revision 1.1.1.1 1999/03/29 15:42:09 jprice + * New version without IPL.SYS + * + * Revision 1.4 1999/02/09 02:54:23 jprice + * Added Pat's 1937 kernel patches + * + * Revision 1.3 1999/02/01 01:43:28 jprice + * Fixed findfirst function to find volume label with Windows long filenames + * + * Revision 1.2 1999/01/22 04:15:28 jprice + * Formating + * + * Revision 1.1.1.1 1999/01/20 05:51:00 jprice + * Imported sources + * + * + * Rev 1.7 09 Feb 1998 5:41:08 patv + * Eliminated FAT12 EOF and error returns. + * + * Rev 1.6 04 Jan 1998 23:14:38 patv + * Changed Log for strip utility + * + * Rev 1.5 16 Jan 1997 12:46:22 patv + * pre-Release 0.92 feature additions + * + * Rev 1.4 29 May 1996 21:15:14 patv + * bug fixes for v0.91a + * + * Rev 1.3 19 Feb 1996 3:20:08 patv + * Added NLS, int2f and config.sys processing + * + * Rev 1.2 01 Sep 1995 17:48:42 patv + * First GPL release. + * + * Rev 1.1 30 Jul 1995 20:50:26 patv + * Eliminated version strings in ipl + * + * Rev 1.0 02 Jul 1995 8:04:56 patv + * Initial revision. + */ + + + diff --git a/kernel/fcbfns.c b/kernel/fcbfns.c index 65b70424..ff8969d2 100644 --- a/kernel/fcbfns.c +++ b/kernel/fcbfns.c @@ -33,128 +33,6 @@ static BYTE *RcsId = "$Id$"; #endif -/* - * $Log$ - * Revision 1.20 2001/11/13 23:36:45 bartoldeman - * Kernel 2025a final changes. - * - * Revision 1.19 2001/11/04 19:47:39 bartoldeman - * kernel 2025a changes: see history.txt - * - * Revision 1.18 2001/09/23 20:39:44 bartoldeman - * FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling - * - * Revision 1.17 2001/08/20 20:32:15 bartoldeman - * Truename, get free space and ctrl-break fixes. - * - * Revision 1.16 2001/08/19 12:58:36 bartoldeman - * Time and date fixes, Ctrl-S/P, findfirst/next, FCBs, buffers, tsr unloading - * - * Revision 1.15 2001/07/24 16:56:29 bartoldeman - * fixes for FCBs, DJGPP ls, DBLBYTE, dyninit allocation (2024e). - * - * Revision 1.14 2001/07/23 12:47:42 bartoldeman - * FCB fixes and clean-ups, exec int21/ax=4b01, initdisk.c printf - * - * Revision 1.13 2001/07/22 01:58:58 bartoldeman - * Support for Brian's FORMAT, DJGPP libc compilation, cleanups, MSCDEX - * - * Revision 1.12 2001/07/09 22:19:33 bartoldeman - * LBA/FCB/FAT/SYS/Ctrl-C/ioctl fixes + memory savings - * - * Revision 1.11 2001/06/03 14:16:17 bartoldeman - * BUFFERS tuning and misc bug fixes/cleanups (2024c). - * - * Revision 1.10 2001/04/21 22:32:53 bartoldeman - * Init DS=Init CS, fixed stack overflow problems and misc bugs. - * - * Revision 1.9 2001/04/15 03:21:50 bartoldeman - * See history.txt for the list of fixes. - * - * Revision 1.8 2001/03/30 22:27:42 bartoldeman - * Saner lastdrive handling. - * - * Revision 1.7 2001/03/21 02:56:26 bartoldeman - * See history.txt for changes. Bug fixes and HMA support are the main ones. - * - * Revision 1.6 2000/08/06 05:50:17 jimtabor - * Add new files and update cvs with patches and changes - * - * Revision 1.5 2000/06/21 18:16:46 jimtabor - * Add UMB code, patch, and code fixes - * - * Revision 1.4 2000/05/26 19:25:19 jimtabor - * Read History file for Change info - * - * Revision 1.3 2000/05/25 20:56:21 jimtabor - * Fixed project history - * - * Revision 1.2 2000/05/08 04:30:00 jimtabor - * Update CVS to 2020 - * - * Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 - * The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with - * MS-DOS. Distributed under the GNU GPL. - * - * Revision 1.7 2000/03/31 05:40:09 jtabor - * Added Eric W. Biederman Patches - * - * Revision 1.6 2000/03/17 22:59:04 kernel - * Steffen Kaiser's NLS changes - * - * Revision 1.5 2000/03/09 06:07:11 kernel - * 2017f updates by James Tabor - * - * Revision 1.4 1999/09/23 04:40:46 jprice - * *** empty log message *** - * - * Revision 1.2 1999/04/04 18:51:43 jprice - * no message - * - * Revision 1.1.1.1 1999/03/29 15:42:15 jprice - * New version without IPL.SYS - * - * Revision 1.5 1999/02/09 02:54:23 jprice - * Added Pat's 1937 kernel patches - * - * Revision 1.4 1999/02/04 03:18:37 jprice - * Formating. Added comments. - * - * Revision 1.3 1999/02/01 01:43:28 jprice - * Fixed findfirst function to find volume label with Windows long filenames - * - * Revision 1.2 1999/01/22 04:15:28 jprice - * Formating - * - * Revision 1.1.1.1 1999/01/20 05:51:00 jprice - * Imported sources - * - * - * Rev 1.7 06 Dec 1998 8:44:10 patv - * Expanded fcb functions for new I/O subsystem. - * - * Rev 1.6 04 Jan 1998 23:14:38 patv - * Changed Log for strip utility - * - * Rev 1.5 03 Jan 1998 8:36:02 patv - * Converted data area to SDA format - * - * Rev 1.4 16 Jan 1997 12:46:38 patv - * pre-Release 0.92 feature additions - * - * Rev 1.3 29 May 1996 21:15:14 patv - * bug fixes for v0.91a - * - * Rev 1.2 01 Sep 1995 17:48:44 patv - * First GPL release. - * - * Rev 1.1 30 Jul 1995 20:50:26 patv - * Eliminated version strings in ipl - * - * Rev 1.0 02 Jul 1995 8:06:06 patv - * Initial revision. - */ - #define FCB_SUCCESS 0 #define FCB_ERR_NODATA 1 #define FCB_ERR_EOF 3 @@ -188,7 +66,7 @@ VOID FatGetDrvData(UCOUNT drive, UCOUNT FAR * spc, UCOUNT FAR * bps, /* get the data available from dpb */ *nc = 0xffff; /* pass 0xffff to skip free count */ - if (DosGetFree(drive, spc, &navc, bps, nc)) + if (DosGetFree((UBYTE)drive, spc, &navc, bps, nc)) /* Point to the media desctriptor for this drive */ *mdp = (BYTE FAR*)&(CDSp->cds_table[drive].cdsDpb->dpb_mdb); } @@ -591,7 +469,7 @@ BOOL FcbCreate(xfcb FAR * lpXfcb) return FALSE; sftp = idx_to_sft(sft_idx); - sftp->sft_attrib |= SFT_MFCB; + sftp->sft_mode |= SFT_MFCB; /* check for a device */ dhp = IsDevice(PriPathName); @@ -665,7 +543,7 @@ BOOL FcbOpen(xfcb FAR * lpXfcb) return FALSE; sftp = idx_to_sft(sft_idx); - sftp->sft_attrib |= SFT_MFCB; + sftp->sft_mode |= SFT_MFCB; /* check for a device */ lpFcb->fcb_curec = 0; @@ -866,7 +744,7 @@ VOID FcbCloseAll() sft FAR *sftp; for (idx = 0; (sftp = idx_to_sft(idx)) != (sft FAR *) -1; idx++) - if ((sftp->sft_attrib & SFT_MFCB) && sftp->sft_psp == cu_psp) + if ((sftp->sft_mode & SFT_MFCB) && sftp->sft_psp == cu_psp) DosCloseSft(idx); } @@ -886,7 +764,7 @@ BOOL FcbFindFirst(xfcb FAR * lpXfcb) if (lpXfcb->xfcb_flag == 0xff) { wAttr = lpXfcb->xfcb_attrib; - fbcopy(lpXfcb, lpDir, 7); + fmemcpy(lpDir, lpXfcb, 7); lpDir += 7; } else @@ -937,7 +815,7 @@ BOOL FcbFindNext(xfcb FAR * lpXfcb) /* Reconstrct the dirmatch structure from the fcb */ Dmatch.dm_drive = lpFcb->fcb_sftno; - fbcopy(lpFcb->fcb_fname, (BYTE FAR *) Dmatch.dm_name_pat, FNAME_SIZE + FEXT_SIZE); + fmemcpy(Dmatch.dm_name_pat, lpFcb->fcb_fname, FNAME_SIZE + FEXT_SIZE); DosUpFMem((BYTE FAR *) Dmatch.dm_name_pat, FNAME_SIZE + FEXT_SIZE); Dmatch.dm_attr_srch = wAttr; @@ -947,7 +825,7 @@ BOOL FcbFindNext(xfcb FAR * lpXfcb) if ((xfcb FAR *) lpFcb != lpXfcb) { wAttr = lpXfcb->xfcb_attrib; - fbcopy(lpXfcb, lpDir, 7); + fmemcpy(lpDir, lpXfcb, 7); lpDir += 7; } else @@ -978,4 +856,66 @@ BOOL FcbFindNext(xfcb FAR * lpXfcb) } #endif +/* + * Log: fcbfns.c,v - for newer entries see "cvs log fcbfns.c" + * + * Revision 1.7 2000/03/31 05:40:09 jtabor + * Added Eric W. Biederman Patches + * + * Revision 1.6 2000/03/17 22:59:04 kernel + * Steffen Kaiser's NLS changes + * + * Revision 1.5 2000/03/09 06:07:11 kernel + * 2017f updates by James Tabor + * + * Revision 1.4 1999/09/23 04:40:46 jprice + * *** empty log message *** + * + * Revision 1.2 1999/04/04 18:51:43 jprice + * no message + * + * Revision 1.1.1.1 1999/03/29 15:42:15 jprice + * New version without IPL.SYS + * + * Revision 1.5 1999/02/09 02:54:23 jprice + * Added Pat's 1937 kernel patches + * + * Revision 1.4 1999/02/04 03:18:37 jprice + * Formating. Added comments. + * + * Revision 1.3 1999/02/01 01:43:28 jprice + * Fixed findfirst function to find volume label with Windows long filenames + * + * Revision 1.2 1999/01/22 04:15:28 jprice + * Formating + * + * Revision 1.1.1.1 1999/01/20 05:51:00 jprice + * Imported sources + * + * + * Rev 1.7 06 Dec 1998 8:44:10 patv + * Expanded fcb functions for new I/O subsystem. + * + * Rev 1.6 04 Jan 1998 23:14:38 patv + * Changed Log for strip utility + * + * Rev 1.5 03 Jan 1998 8:36:02 patv + * Converted data area to SDA format + * + * Rev 1.4 16 Jan 1997 12:46:38 patv + * pre-Release 0.92 feature additions + * + * Rev 1.3 29 May 1996 21:15:14 patv + * bug fixes for v0.91a + * + * Rev 1.2 01 Sep 1995 17:48:44 patv + * First GPL release. + * + * Rev 1.1 30 Jul 1995 20:50:26 patv + * Eliminated version strings in ipl + * + * Rev 1.0 02 Jul 1995 8:06:06 patv + * Initial revision. + */ + diff --git a/kernel/globals.h b/kernel/globals.h index 9c52a6aa..6baac315 100644 --- a/kernel/globals.h +++ b/kernel/globals.h @@ -27,176 +27,12 @@ /* Cambridge, MA 02139, USA. */ /****************************************************************/ -/* $Logfile: C:/usr/patv/dos-c/src/kernel/globals.h_v $ */ #ifdef VERSION_STRINGS #ifdef MAIN static BYTE *Globals_hRcsId = "$Id$"; #endif #endif -/* - * $Log$ - * Revision 1.18 2001/11/04 19:47:39 bartoldeman - * kernel 2025a changes: see history.txt - * - * Revision 1.17 2001/09/23 20:39:44 bartoldeman - * FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling - * - * Revision 1.16 2001/08/19 12:58:36 bartoldeman - * Time and date fixes, Ctrl-S/P, findfirst/next, FCBs, buffers, tsr unloading - * - * Revision 1.15 2001/07/22 01:58:58 bartoldeman - * Support for Brian's FORMAT, DJGPP libc compilation, cleanups, MSCDEX - * - * Revision 1.14 2001/07/09 22:19:33 bartoldeman - * LBA/FCB/FAT/SYS/Ctrl-C/ioctl fixes + memory savings - * - * Revision 1.13 2001/06/03 14:16:17 bartoldeman - * BUFFERS tuning and misc bug fixes/cleanups (2024c). - * - * Revision 1.12 2001/04/21 22:32:53 bartoldeman - * Init DS=Init CS, fixed stack overflow problems and misc bugs. - * - * Revision 1.11 2001/04/15 03:21:50 bartoldeman - * See history.txt for the list of fixes. - * - * Revision 1.10 2001/04/02 23:18:30 bartoldeman - * Misc, zero terminated device names and redirector bugs fixed. - * - * Revision 1.9 2001/03/30 20:11:14 bartoldeman - * Truly got DOS=HIGH reporting for INT21/AX=0x3306 working now. - * - * Revision 1.8 2001/03/30 19:30:06 bartoldeman - * Misc fixes and implementation of SHELLHIGH. See history.txt for details. - * - * Revision 1.7 2001/03/21 02:56:26 bartoldeman - * See history.txt for changes. Bug fixes and HMA support are the main ones. - * - * Revision 1.6 2000/12/16 01:38:35 jimtabor - * Added patches from Bart Oldeman - * - * Revision 1.5 2000/08/06 05:50:17 jimtabor - * Add new files and update cvs with patches and changes - * - * Revision 1.3 2000/05/25 20:56:21 jimtabor - * Fixed project history - * - * Revision 1.2 2000/05/08 04:30:00 jimtabor - * Update CVS to 2020 - * - * Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 - * The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with - * MS-DOS. Distributed under the GNU GPL. - * - * Revision 1.17 2000/03/16 03:28:49 kernel - * *** empty log message *** - * - * Revision 1.16 2000/03/09 06:07:11 kernel - * 2017f updates by James Tabor - * - * Revision 1.15 1999/09/23 04:40:47 jprice - * *** empty log message *** - * - * Revision 1.13 1999/08/25 03:18:08 jprice - * ror4 patches to allow TC 2.01 compile. - * - * Revision 1.12 1999/08/10 18:03:43 jprice - * ror4 2011-03 patch - * - * Revision 1.11 1999/05/03 06:25:45 jprice - * Patches from ror4 and many changed of signed to unsigned variables. - * - * Revision 1.10 1999/04/16 21:43:40 jprice - * ror4 multi-sector IO - * - * Revision 1.9 1999/04/16 12:21:22 jprice - * Steffen c-break handler changes - * - * Revision 1.8 1999/04/16 00:53:33 jprice - * Optimized FAT handling - * - * Revision 1.7 1999/04/12 03:21:17 jprice - * more ror4 patches. Changes for multi-block IO - * - * Revision 1.6 1999/04/11 04:33:39 jprice - * ror4 patches - * - * Revision 1.4 1999/04/04 22:57:47 jprice - * no message - * - * Revision 1.3 1999/04/04 18:51:43 jprice - * no message - * - * Revision 1.2 1999/03/29 17:05:09 jprice - * ror4 changes - * - * Revision 1.1.1.1 1999/03/29 15:40:58 jprice - * New version without IPL.SYS - * - * Revision 1.5 1999/02/08 05:55:57 jprice - * Added Pat's 1937 kernel patches - * - * Revision 1.4 1999/02/01 01:48:41 jprice - * Clean up; Now you can use hex numbers in config.sys. added config.sys screen function to change screen mode (28 or 43/50 lines) - * - * Revision 1.3 1999/01/30 08:26:46 jprice - * Clean up; commented out copyright messages while we debug. - * - * Revision 1.2 1999/01/22 04:13:26 jprice - * Formating - * - * Revision 1.1.1.1 1999/01/20 05:51:01 jprice - * Imported sources - * - - Rev 1.16 06 Dec 1998 8:45:56 patv - Expanded due to new I/O subsystem. - - Rev 1.15 07 Feb 1998 20:38:00 patv - Modified stack fram to match DOS standard - - Rev 1.14 02 Feb 1998 22:33:46 patv - Fixed size of default_drive. Caused failures when break_ena was not zero. - - Rev 1.13 22 Jan 1998 4:09:24 patv - Fixed pointer problems affecting SDA - - Rev 1.12 04 Jan 1998 23:16:22 patv - Changed Log for strip utility - - Rev 1.11 03 Jan 1998 8:36:50 patv - Converted data area to SDA format - - Rev 1.10 06 Feb 1997 21:57:04 patv - Changed version format string - - Rev 1.9 06 Feb 1997 21:35:08 patv - Modified to support new version format - - Rev 1.8 22 Jan 1997 13:17:14 patv - Changed to support version.h and pre-0.92 Svante Frey bug fixes. - - Rev 1.6 16 Jan 1997 12:47:00 patv - pre-Release 0.92 feature additions - - Rev 1.5 13 Sep 1996 19:26:32 patv - Fixed boot for hard drive - - Rev 1.4 29 Aug 1996 13:07:22 patv - Bug fixes for v0.91b - - Rev 1.3 29 May 1996 21:03:34 patv - bug fixes for v0.91a - - Rev 1.2 19 Feb 1996 3:23:04 patv - Added NLS, int2f and config.sys processing - - Rev 1.1 01 Sep 1995 17:54:16 patv - First GPL release. - - Rev 1.0 02 Jul 1995 8:31:00 patv - Initial revision. - */ #include "device.h" #include "mcb.h" @@ -280,6 +116,7 @@ static BYTE *Globals_hRcsId = "$Id$"; #define ESC 0x1b #define CTL_BS 0x7f +#define F1 0x3b #define F3 0x3d #define LEFT 0x4b #define RIGHT 0x4d @@ -686,3 +523,116 @@ void handle_break(void); /* break.c */ GLOBAL BYTE ReturnAnyDosVersionExpected; GLOBAL COUNT UnusedRetVal; /* put unused errors here (to save stack space) */ + +/* + * Log: globals.h,v + * + * Revision 1.17 2000/03/16 03:28:49 kernel + * *** empty log message *** + * + * Revision 1.16 2000/03/09 06:07:11 kernel + * 2017f updates by James Tabor + * + * Revision 1.15 1999/09/23 04:40:47 jprice + * *** empty log message *** + * + * Revision 1.13 1999/08/25 03:18:08 jprice + * ror4 patches to allow TC 2.01 compile. + * + * Revision 1.12 1999/08/10 18:03:43 jprice + * ror4 2011-03 patch + * + * Revision 1.11 1999/05/03 06:25:45 jprice + * Patches from ror4 and many changed of signed to unsigned variables. + * + * Revision 1.10 1999/04/16 21:43:40 jprice + * ror4 multi-sector IO + * + * Revision 1.9 1999/04/16 12:21:22 jprice + * Steffen c-break handler changes + * + * Revision 1.8 1999/04/16 00:53:33 jprice + * Optimized FAT handling + * + * Revision 1.7 1999/04/12 03:21:17 jprice + * more ror4 patches. Changes for multi-block IO + * + * Revision 1.6 1999/04/11 04:33:39 jprice + * ror4 patches + * + * Revision 1.4 1999/04/04 22:57:47 jprice + * no message + * + * Revision 1.3 1999/04/04 18:51:43 jprice + * no message + * + * Revision 1.2 1999/03/29 17:05:09 jprice + * ror4 changes + * + * Revision 1.1.1.1 1999/03/29 15:40:58 jprice + * New version without IPL.SYS + * + * Revision 1.5 1999/02/08 05:55:57 jprice + * Added Pat's 1937 kernel patches + * + * Revision 1.4 1999/02/01 01:48:41 jprice + * Clean up; Now you can use hex numbers in config.sys. added config.sys screen function to change screen mode (28 or 43/50 lines) + * + * Revision 1.3 1999/01/30 08:26:46 jprice + * Clean up; commented out copyright messages while we debug. + * + * Revision 1.2 1999/01/22 04:13:26 jprice + * Formating + * + * Revision 1.1.1.1 1999/01/20 05:51:01 jprice + * Imported sources + * + + Rev 1.16 06 Dec 1998 8:45:56 patv + Expanded due to new I/O subsystem. + + Rev 1.15 07 Feb 1998 20:38:00 patv + Modified stack fram to match DOS standard + + Rev 1.14 02 Feb 1998 22:33:46 patv + Fixed size of default_drive. Caused failures when break_ena was not zero. + + Rev 1.13 22 Jan 1998 4:09:24 patv + Fixed pointer problems affecting SDA + + Rev 1.12 04 Jan 1998 23:16:22 patv + Changed Log for strip utility + + Rev 1.11 03 Jan 1998 8:36:50 patv + Converted data area to SDA format + + Rev 1.10 06 Feb 1997 21:57:04 patv + Changed version format string + + Rev 1.9 06 Feb 1997 21:35:08 patv + Modified to support new version format + + Rev 1.8 22 Jan 1997 13:17:14 patv + Changed to support version.h and pre-0.92 Svante Frey bug fixes. + + Rev 1.6 16 Jan 1997 12:47:00 patv + pre-Release 0.92 feature additions + + Rev 1.5 13 Sep 1996 19:26:32 patv + Fixed boot for hard drive + + Rev 1.4 29 Aug 1996 13:07:22 patv + Bug fixes for v0.91b + + Rev 1.3 29 May 1996 21:03:34 patv + bug fixes for v0.91a + + Rev 1.2 19 Feb 1996 3:23:04 patv + Added NLS, int2f and config.sys processing + + Rev 1.1 01 Sep 1995 17:54:16 patv + First GPL release. + + Rev 1.0 02 Jul 1995 8:31:00 patv + Initial revision. + */ diff --git a/kernel/init-mod.h b/kernel/init-mod.h index 5dffac9a..c1c1e29c 100644 --- a/kernel/init-mod.h +++ b/kernel/init-mod.h @@ -55,7 +55,6 @@ COUNT ASMCFUNC strlen(REG BYTE * s); #undef LINESIZE #define LINESIZE KBD_MAXLENGTH -#define fbcopy(s, d, n) fmemcpy(d,s,n) /*inithma.c*/ extern BYTE DosLoadedInHMA; diff --git a/kernel/inithma.c b/kernel/inithma.c index fd104256..a68fcab7 100644 --- a/kernel/inithma.c +++ b/kernel/inithma.c @@ -79,43 +79,7 @@ extern BYTE static BYTE *RcsId = "$Id$"; #endif -/* - * $Log$ - * Revision 1.10 2001/09/23 20:39:44 bartoldeman - * FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling - * - * Revision 1.9 2001/08/19 12:58:36 bartoldeman - * Time and date fixes, Ctrl-S/P, findfirst/next, FCBs, buffers, tsr unloading - * - * Revision 1.8 2001/07/28 18:13:06 bartoldeman - * Fixes for FORMAT+SYS, FATFS, get current dir, kernel init memory situation. - * - * Revision 1.7 2001/07/09 22:19:33 bartoldeman - * LBA/FCB/FAT/SYS/Ctrl-C/ioctl fixes + memory savings - * - * Revision 1.6 2001/04/29 17:34:40 bartoldeman - * A new SYS.COM/config.sys single stepping/console output/misc fixes. - * - * Revision 1.5 2001/04/21 22:32:53 bartoldeman - * Init DS=Init CS, fixed stack overflow problems and misc bugs. - * - * Revision 1.4 2001/04/16 01:45:26 bartoldeman - * Fixed handles, config.sys drivers, warnings. Enabled INT21/AH=6C, printf %S/%Fs - * - * Revision 1.3 2001/04/15 03:21:50 bartoldeman - * See history.txt for the list of fixes. - * - * Revision 1.2 2001/03/30 19:30:06 bartoldeman - * Misc fixes and implementation of SHELLHIGH. See history.txt for details. - * - * Revision 1.1 2001/03/21 03:01:45 bartoldeman - * New file by Tom Ehlert for HMA initialization. - * - * Revision 0.1 2001/03/16 12:00:00 tom ehlert - * initial creation - */ - - + BYTE DosLoadedInHMA=FALSE; /* set to TRUE if loaded HIGH */ BYTE HMAclaimed=FALSE; /* set to TRUE if claimed from HIMEM */ WORD HMAFree = 0; /* first byte in HMA not yet used */ @@ -547,3 +511,10 @@ void MoveKernel(unsigned NewKernelSegment) errorReturn: for (;;); } + +/* + * Log: inithma.c,v - for newer entries do "cvs log inithma.c" + * + * Revision 0.1 2001/03/16 12:00:00 tom ehlert + * initial creation + */ diff --git a/kernel/initoem.c b/kernel/initoem.c index 2e52b4e2..7c0112ce 100644 --- a/kernel/initoem.c +++ b/kernel/initoem.c @@ -34,23 +34,25 @@ static BYTE *RcsId = "$Id$"; #endif +UWORD init_oem(void) +{ + UWORD top_k; + +#ifndef __TURBOC__ + asm + { + int 0x12; + mov top_k,ax; + } +#else + __int__(0x12); + top_k = _AX; +#endif + return top_k; +} + /* - * $Log$ - * Revision 1.5 2001/09/23 20:39:44 bartoldeman - * FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling - * - * Revision 1.4 2001/04/21 22:32:53 bartoldeman - * Init DS=Init CS, fixed stack overflow problems and misc bugs. - * - * Revision 1.3 2000/05/25 20:56:21 jimtabor - * Fixed project history - * - * Revision 1.2 2000/05/08 04:30:00 jimtabor - * Update CVS to 2020 - * - * Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 - * The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with - * MS-DOS. Distributed under the GNU GPL. + * Log: initoem.c,v - for newer entries do "cvs log initoem.c" * * Revision 1.3 2000/03/09 06:07:11 kernel * 2017f updates by James Tabor @@ -93,19 +95,3 @@ static BYTE *RcsId = "$Id$"; * Initial revision. */ -UWORD init_oem(void) -{ - UWORD top_k; - -#ifndef __TURBOC__ - asm - { - int 0x12; - mov top_k,ax; - } -#else - __int__(0x12); - top_k = _AX; -#endif - return top_k; -} diff --git a/kernel/int2f.asm b/kernel/int2f.asm index 6f89f123..4a0cd059 100644 --- a/kernel/int2f.asm +++ b/kernel/int2f.asm @@ -25,88 +25,7 @@ ; write to the Free Software Foundation, 675 Mass Ave, ; Cambridge, MA 02139, USA. ; -; $Logfile: D:/dos-c/src/kernel/int2f.asv $ -; ; $Id$ -; -; $Log$ -; Revision 1.14 2001/11/04 19:47:39 bartoldeman -; kernel 2025a changes: see history.txt -; -; Revision 1.13 2001/09/23 20:39:44 bartoldeman -; FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling -; -; Revision 1.12 2001/08/19 12:58:36 bartoldeman -; Time and date fixes, Ctrl-S/P, findfirst/next, FCBs, buffers, tsr unloading -; -; Revision 1.11 2001/07/28 18:13:06 bartoldeman -; Fixes for FORMAT+SYS, FATFS, get current dir, kernel init memory situation. -; -; Revision 1.10 2001/07/22 01:58:58 bartoldeman -; Support for Brian's FORMAT, DJGPP libc compilation, cleanups, MSCDEX -; -; Revision 1.9 2001/07/09 22:19:33 bartoldeman -; LBA/FCB/FAT/SYS/Ctrl-C/ioctl fixes + memory savings -; -; Revision 1.8 2001/04/02 23:18:30 bartoldeman -; Misc, zero terminated device names and redirector bugs fixed. -; -; Revision 1.7 2001/03/21 02:56:26 bartoldeman -; See history.txt for changes. Bug fixes and HMA support are the main ones. -; -; Revision 1.6 2000/08/06 05:50:17 jimtabor -; Add new files and update cvs with patches and changes -; -; Revision 1.5 2000/06/21 18:16:46 jimtabor -; Add UMB code, patch, and code fixes -; -; Revision 1.4 2000/05/25 20:56:21 jimtabor -; Fixed project history -; -; Revision 1.3 2000/05/17 19:15:12 jimtabor -; Cleanup, add and fix source. -; -; Revision 1.2 2000/05/08 04:30:00 jimtabor -; Update CVS to 2020 -; -; Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 -; The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with -; MS-DOS. Distributed under the GNU GPL. -; -; Revision 1.4 2000/03/31 05:40:09 jtabor -; Added Eric W. Biederman Patches -; -; Revision 1.3 2000/03/09 06:07:11 kernel -; 2017f updates by James Tabor -; -; Revision 1.2 1999/08/10 17:57:12 jprice -; ror4 2011-02 patch -; -; Revision 1.1.1.1 1999/03/29 15:40:59 jprice -; New version without IPL.SYS -; -; Revision 1.4 1999/02/08 05:55:57 jprice -; Added Pat's 1937 kernel patches -; -; Revision 1.3 1999/02/01 01:48:41 jprice -; Clean up; Now you can use hex numbers in config.sys. added config.sys screen function to change screen mode (28 or 43/50 lines) -; -; Revision 1.2 1999/01/22 04:13:26 jprice -; Formating -; -; Revision 1.1.1.1 1999/01/20 05:51:01 jprice -; Imported sources -; -; -; Rev 1.2 06 Dec 1998 8:48:12 patv -; Bug fixes. -; -; Rev 1.1 29 May 1996 21:03:46 patv -; bug fixes for v0.91a -; -; Rev 1.0 19 Feb 1996 3:34:38 patv -; Initial revision. -; $EndLog$ ; %include "segs.inc" @@ -606,3 +525,40 @@ umbt_ret: umbt_error: xor ax,ax jmp umbt_ret + +; Log: int2f.asm,v +; Revision 1.4 2000/03/31 05:40:09 jtabor +; Added Eric W. Biederman Patches +; +; Revision 1.3 2000/03/09 06:07:11 kernel +; 2017f updates by James Tabor +; +; Revision 1.2 1999/08/10 17:57:12 jprice +; ror4 2011-02 patch +; +; Revision 1.1.1.1 1999/03/29 15:40:59 jprice +; New version without IPL.SYS +; +; Revision 1.4 1999/02/08 05:55:57 jprice +; Added Pat's 1937 kernel patches +; +; Revision 1.3 1999/02/01 01:48:41 jprice +; Clean up; Now you can use hex numbers in config.sys. added config.sys screen function to change screen mode (28 or 43/50 lines) +; +; Revision 1.2 1999/01/22 04:13:26 jprice +; Formating +; +; Revision 1.1.1.1 1999/01/20 05:51:01 jprice +; Imported sources +; +; +; Rev 1.2 06 Dec 1998 8:48:12 patv +; Bug fixes. +; +; Rev 1.1 29 May 1996 21:03:46 patv +; bug fixes for v0.91a +; +; Rev 1.0 19 Feb 1996 3:34:38 patv +; Initial revision. +; EndLog +; diff --git a/kernel/inthndlr.c b/kernel/inthndlr.c index 44c904ce..00adcfd8 100644 --- a/kernel/inthndlr.c +++ b/kernel/inthndlr.c @@ -35,242 +35,6 @@ BYTE *RcsId = "$Id$"; #endif -/* - * $Log$ - * Revision 1.34 2001/11/14 00:15:05 bartoldeman - * Fixed typo in dpbp - * - * Revision 1.33 2001/11/13 23:36:45 bartoldeman - * Kernel 2025a final changes. - * - * Revision 1.32 2001/11/04 19:47:39 bartoldeman - * kernel 2025a changes: see history.txt - * - * Revision 1.31 2001/09/23 20:39:44 bartoldeman - * FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling - * - * Revision 1.30 2001/08/19 12:58:36 bartoldeman - * Time and date fixes, Ctrl-S/P, findfirst/next, FCBs, buffers, tsr unloading - * - * Revision 1.29 2001/07/28 18:13:06 bartoldeman - * Fixes for FORMAT+SYS, FATFS, get current dir, kernel init memory situation. - * - * Revision 1.28 2001/07/24 16:56:29 bartoldeman - * fixes for FCBs, DJGPP ls, DBLBYTE, dyninit allocation (2024e). - * - * Revision 1.27 2001/07/23 12:47:42 bartoldeman - * FCB fixes and clean-ups, exec int21/ax=4b01, initdisk.c printf - * - * Revision 1.26 2001/07/22 01:58:58 bartoldeman - * Support for Brian's FORMAT, DJGPP libc compilation, cleanups, MSCDEX - * - * Revision 1.25 2001/07/09 22:19:33 bartoldeman - * LBA/FCB/FAT/SYS/Ctrl-C/ioctl fixes + memory savings - * - * Revision 1.24 2001/06/03 14:16:18 bartoldeman - * BUFFERS tuning and misc bug fixes/cleanups (2024c). - * - * Revision 1.23 2001/04/29 17:34:40 bartoldeman - * A new SYS.COM/config.sys single stepping/console output/misc fixes. - * - * Revision 1.22 2001/04/21 22:32:53 bartoldeman - * Init DS=Init CS, fixed stack overflow problems and misc bugs. - * - * Revision 1.21 2001/04/16 01:45:26 bartoldeman - * Fixed handles, config.sys drivers, warnings. Enabled INT21/AH=6C, printf %S/%Fs - * - * Revision 1.20 2001/04/15 03:21:50 bartoldeman - * See history.txt for the list of fixes. - * - * Revision 1.19 2001/04/02 23:18:30 bartoldeman - * Misc, zero terminated device names and redirector bugs fixed. - * - * Revision 1.18 2001/03/30 22:27:42 bartoldeman - * Saner lastdrive handling. - * - * Revision 1.17 2001/03/30 19:30:06 bartoldeman - * Misc fixes and implementation of SHELLHIGH. See history.txt for details. - * - * Revision 1.16 2001/03/27 20:27:43 bartoldeman - * dsk.c (reported by Nagy Daniel), inthndlr and int25/26 fixes by Tom Ehlert. - * - * Revision 1.15 2001/03/25 17:11:54 bartoldeman - * Fixed sys.com compilation. Updated to 2023. Also: see history.txt. - * - * Revision 1.14 2001/03/21 02:56:26 bartoldeman - * See history.txt for changes. Bug fixes and HMA support are the main ones. - * - * Revision 1.13 2001/03/08 21:00:00 bartoldeman - * MCB chain corruption and DosFindNext fix (thanks Martin Stromberg and Tom Ehlert) - * - * Revision 1.12 2000/12/16 01:38:35 jimtabor - * Added patches from Bart Oldeman - * - * Revision 1.11 2000/10/30 00:21:15 jimtabor - * Adding Brian Reifsnyder Fix for Int 25/26 - * - * 2000/09/04 Brian Reifsnyder - * Modified interrupts 0x25 & 0x26 to return more accurate error codes. - * - * Revision 1.10 2000/10/29 23:51:56 jimtabor - * Adding Share Support by Ron Cemer - * - * Revision 1.9 2000/08/06 05:50:17 jimtabor - * Add new files and update cvs with patches and changes - * - * Revision 1.8 2000/06/21 18:16:46 jimtabor - * Add UMB code, patch, and code fixes - * - * Revision 1.7 2000/05/25 20:56:21 jimtabor - * Fixed project history - * - * Revision 1.6 2000/05/17 19:15:12 jimtabor - * Cleanup, add and fix source. - * - * Revision 1.5 2000/05/11 06:14:45 jimtabor - * Removed #if statement - * - * Revision 1.4 2000/05/11 04:26:26 jimtabor - * Added code for DOS FN 69 & 6C - * - * Revision 1.3 2000/05/09 00:30:11 jimtabor - * Clean up and Release - * - * Revision 1.2 2000/05/08 04:30:00 jimtabor - * Update CVS to 2020 - * - * Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 - * The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with - * MS-DOS. Distributed under the GNU GPL. - * - * Revision 1.24 2000/04/29 05:13:16 jtabor - * Added new functions and clean up code - * - * Revision 1.22 2000/03/17 22:59:04 kernel - * Steffen Kaiser's NLS changes - * - * Revision 1.21 2000/03/17 05:00:11 kernel - * Fixed Func 0x32 - * - * Revision 1.20 2000/03/16 03:28:49 kernel - * *** empty log message *** - * - * Revision 1.19 2000/03/09 06:07:11 kernel - * 2017f updates by James Tabor - * - * Revision 1.18 1999/09/23 04:40:47 jprice - * *** empty log message *** - * - * Revision 1.13 1999/09/14 01:18:36 jprice - * ror4: fix int25 & 26 are not cached. - * - * Revision 1.12 1999/09/13 22:16:47 jprice - * Fix 210B function - * - * Revision 1.11 1999/08/25 03:18:08 jprice - * ror4 patches to allow TC 2.01 compile. - * - * Revision 1.10 1999/08/10 18:07:57 jprice - * ror4 2011-04 patch - * - * Revision 1.9 1999/08/10 18:03:43 jprice - * ror4 2011-03 patch - * - * Revision 1.8 1999/05/03 06:25:45 jprice - * Patches from ror4 and many changed of signed to unsigned variables. - * - * Revision 1.7 1999/04/23 04:24:39 jprice - * Memory manager changes made by ska - * - * Revision 1.6 1999/04/16 12:21:22 jprice - * Steffen c-break handler changes - * - * Revision 1.5 1999/04/11 04:33:39 jprice - * ror4 patches - * - * Revision 1.3 1999/04/04 22:57:47 jprice - * no message - * - * Revision 1.2 1999/04/04 18:51:43 jprice - * no message - * - * Revision 1.1.1.1 1999/03/29 15:41:04 jprice - * New version without IPL.SYS - * - * Revision 1.9 1999/03/23 23:38:49 jprice - * Now sets carry when we don't support a function - * - * Revision 1.8 1999/03/02 07:02:55 jprice - * Added some comments. Fixed some minor bugs. - * - * Revision 1.7 1999/03/01 05:45:08 jprice - * Added some DEBUG ifdef's so that it will compile without DEBUG defined. - * - * Revision 1.6 1999/02/08 05:55:57 jprice - * Added Pat's 1937 kernel patches - * - * Revision 1.5 1999/02/04 03:11:07 jprice - * Formating - * - * Revision 1.4 1999/02/01 01:48:41 jprice - * Clean up; Now you can use hex numbers in config.sys. added config.sys screen function to change screen mode (28 or 43/50 lines) - * - * Revision 1.3 1999/01/30 08:28:11 jprice - * Clean up; Fixed bug with set attribute function. - * - * Revision 1.2 1999/01/22 04:13:26 jprice - * Formating - * - * Revision 1.1.1.1 1999/01/20 05:51:00 jprice - * Imported sources - * - * - * Rev 1.14 06 Dec 1998 8:47:38 patv - * Expanded due to improved int 21h handler code. - * - * Rev 1.13 07 Feb 1998 20:38:46 patv - * Modified stack fram to match DOS standard - * - * Rev 1.12 22 Jan 1998 4:09:26 patv - * Fixed pointer problems affecting SDA - * - * Rev 1.11 06 Jan 1998 20:13:18 patv - * Broke apart int21_system from int21_handler. - * - * Rev 1.10 04 Jan 1998 23:15:22 patv - * Changed Log for strip utility - * - * Rev 1.9 04 Jan 1998 17:26:16 patv - * Corrected subdirectory bug - * - * Rev 1.8 03 Jan 1998 8:36:48 patv - * Converted data area to SDA format - * - * Rev 1.7 01 Aug 1997 2:00:10 patv - * COMPATIBILITY: Added return '$' in AL for function int 21h fn 09h - * - * Rev 1.6 06 Feb 1997 19:05:54 patv - * Added hooks for tsc command - * - * Rev 1.5 22 Jan 1997 13:18:32 patv - * pre-0.92 Svante Frey bug fixes. - * - * Rev 1.4 16 Jan 1997 12:46:46 patv - * pre-Release 0.92 feature additions - * - * Rev 1.3 29 May 1996 21:03:40 patv - * bug fixes for v0.91a - * - * Rev 1.2 19 Feb 1996 3:21:48 patv - * Added NLS, int2f and config.sys processing - * - * Rev 1.1 01 Sep 1995 17:54:20 patv - * First GPL release. - * - * Rev 1.0 02 Jul 1995 8:33:34 patv - * Initial revision. - */ - #ifdef TSC static VOID StartTrace(VOID); static bTraceNext = FALSE; @@ -405,7 +169,7 @@ VOID ASMCFUNC int21_service(iregs FAR * r) #ifdef DEBUG if (bDumpRegs) { - fbcopy((VOID FAR *) user_r, (VOID FAR *) & error_regs, sizeof(iregs)); + fmemcpy(&error_regs, user_r, sizeof(iregs)); printf("System call (21h): %02x\n", user_r->AX); dump_regs = TRUE; dump(); @@ -2024,8 +1788,7 @@ VOID ASMCFUNC int21_service(iregs FAR * r) #ifdef DEBUG if (bDumpRegs) { - fbcopy((VOID FAR *) user_r, (VOID FAR *) & error_regs, - sizeof(iregs)); + fmemcpy(&error_regs, user_r, sizeof(iregs)); dump_regs = TRUE; dump(); } @@ -2171,7 +1934,7 @@ struct int2f12regs UWORD callerARG1; /* used if called from INT2F/12 */ }; -VOID ASMCFUNC int2F_12_handler(struct int2f12regs r) +VOID ASMCFUNC int2F_12_handler(volatile struct int2f12regs r) { UWORD function = r.ax & 0xff; @@ -2347,3 +2110,170 @@ VOID ASMCFUNC int2F_12_handler(struct int2f12regs r) } } + +/* + * 2000/09/04 Brian Reifsnyder + * Modified interrupts 0x25 & 0x26 to return more accurate error codes. + */ + +/* + * Log: inthndlr.c,v - see "cvs log inthndlr.c" for newer entries. + * + * Revision 1.10 2000/10/29 23:51:56 jimtabor + * Adding Share Support by Ron Cemer + * + * Revision 1.9 2000/08/06 05:50:17 jimtabor + * Add new files and update cvs with patches and changes + * + * Revision 1.8 2000/06/21 18:16:46 jimtabor + * Add UMB code, patch, and code fixes + * + * Revision 1.7 2000/05/25 20:56:21 jimtabor + * Fixed project history + * + * Revision 1.6 2000/05/17 19:15:12 jimtabor + * Cleanup, add and fix source. + * + * Revision 1.5 2000/05/11 06:14:45 jimtabor + * Removed #if statement + * + * Revision 1.4 2000/05/11 04:26:26 jimtabor + * Added code for DOS FN 69 & 6C + * + * Revision 1.3 2000/05/09 00:30:11 jimtabor + * Clean up and Release + * + * Revision 1.2 2000/05/08 04:30:00 jimtabor + * Update CVS to 2020 + * + * Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 + * The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with + * MS-DOS. Distributed under the GNU GPL. + * + * Revision 1.24 2000/04/29 05:13:16 jtabor + * Added new functions and clean up code + * + * Revision 1.22 2000/03/17 22:59:04 kernel + * Steffen Kaiser's NLS changes + * + * Revision 1.21 2000/03/17 05:00:11 kernel + * Fixed Func 0x32 + * + * Revision 1.20 2000/03/16 03:28:49 kernel + * *** empty log message *** + * + * Revision 1.19 2000/03/09 06:07:11 kernel + * 2017f updates by James Tabor + * + * Revision 1.18 1999/09/23 04:40:47 jprice + * *** empty log message *** + * + * Revision 1.13 1999/09/14 01:18:36 jprice + * ror4: fix int25 & 26 are not cached. + * + * Revision 1.12 1999/09/13 22:16:47 jprice + * Fix 210B function + * + * Revision 1.11 1999/08/25 03:18:08 jprice + * ror4 patches to allow TC 2.01 compile. + * + * Revision 1.10 1999/08/10 18:07:57 jprice + * ror4 2011-04 patch + * + * Revision 1.9 1999/08/10 18:03:43 jprice + * ror4 2011-03 patch + * + * Revision 1.8 1999/05/03 06:25:45 jprice + * Patches from ror4 and many changed of signed to unsigned variables. + * + * Revision 1.7 1999/04/23 04:24:39 jprice + * Memory manager changes made by ska + * + * Revision 1.6 1999/04/16 12:21:22 jprice + * Steffen c-break handler changes + * + * Revision 1.5 1999/04/11 04:33:39 jprice + * ror4 patches + * + * Revision 1.3 1999/04/04 22:57:47 jprice + * no message + * + * Revision 1.2 1999/04/04 18:51:43 jprice + * no message + * + * Revision 1.1.1.1 1999/03/29 15:41:04 jprice + * New version without IPL.SYS + * + * Revision 1.9 1999/03/23 23:38:49 jprice + * Now sets carry when we don't support a function + * + * Revision 1.8 1999/03/02 07:02:55 jprice + * Added some comments. Fixed some minor bugs. + * + * Revision 1.7 1999/03/01 05:45:08 jprice + * Added some DEBUG ifdef's so that it will compile without DEBUG defined. + * + * Revision 1.6 1999/02/08 05:55:57 jprice + * Added Pat's 1937 kernel patches + * + * Revision 1.5 1999/02/04 03:11:07 jprice + * Formating + * + * Revision 1.4 1999/02/01 01:48:41 jprice + * Clean up; Now you can use hex numbers in config.sys. added config.sys screen function to change screen mode (28 or 43/50 lines) + * + * Revision 1.3 1999/01/30 08:28:11 jprice + * Clean up; Fixed bug with set attribute function. + * + * Revision 1.2 1999/01/22 04:13:26 jprice + * Formating + * + * Revision 1.1.1.1 1999/01/20 05:51:00 jprice + * Imported sources + * + * + * Rev 1.14 06 Dec 1998 8:47:38 patv + * Expanded due to improved int 21h handler code. + * + * Rev 1.13 07 Feb 1998 20:38:46 patv + * Modified stack fram to match DOS standard + * + * Rev 1.12 22 Jan 1998 4:09:26 patv + * Fixed pointer problems affecting SDA + * + * Rev 1.11 06 Jan 1998 20:13:18 patv + * Broke apart int21_system from int21_handler. + * + * Rev 1.10 04 Jan 1998 23:15:22 patv + * Changed Log for strip utility + * + * Rev 1.9 04 Jan 1998 17:26:16 patv + * Corrected subdirectory bug + * + * Rev 1.8 03 Jan 1998 8:36:48 patv + * Converted data area to SDA format + * + * Rev 1.7 01 Aug 1997 2:00:10 patv + * COMPATIBILITY: Added return '$' in AL for function int 21h fn 09h + * + * Rev 1.6 06 Feb 1997 19:05:54 patv + * Added hooks for tsc command + * + * Rev 1.5 22 Jan 1997 13:18:32 patv + * pre-0.92 Svante Frey bug fixes. + * + * Rev 1.4 16 Jan 1997 12:46:46 patv + * pre-Release 0.92 feature additions + * + * Rev 1.3 29 May 1996 21:03:40 patv + * bug fixes for v0.91a + * + * Rev 1.2 19 Feb 1996 3:21:48 patv + * Added NLS, int2f and config.sys processing + * + * Rev 1.1 01 Sep 1995 17:54:20 patv + * First GPL release. + * + * Rev 1.0 02 Jul 1995 8:33:34 patv + * Initial revision. + */ diff --git a/kernel/io.asm b/kernel/io.asm index a3a389fd..031f8fb8 100644 --- a/kernel/io.asm +++ b/kernel/io.asm @@ -26,55 +26,6 @@ ; Cambridge, MA 02139, USA. ; ; $Header$ -; -; $Log$ -; Revision 1.11 2001/11/04 19:47:39 bartoldeman -; kernel 2025a changes: see history.txt -; -; Revision 1.10 2001/09/23 20:39:44 bartoldeman -; FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling -; -; Revision 1.9 2001/04/29 17:34:40 bartoldeman -; A new SYS.COM/config.sys single stepping/console output/misc fixes. -; -; Revision 1.8 2001/04/21 22:32:53 bartoldeman -; Init DS=Init CS, fixed stack overflow problems and misc bugs. -; -; Revision 1.7 2001/03/21 02:56:26 bartoldeman -; See history.txt for changes. Bug fixes and HMA support are the main ones. -; -; Revision 1.6 2000/06/21 18:16:46 jimtabor -; Add UMB code, patch, and code fixes -; -; Revision 1.5 2000/06/01 06:37:38 jimtabor -; Read History for Changes -; -; Revision 1.4 2000/05/26 19:25:19 jimtabor -; Read History file for Change info -; -; Revision 1.3 2000/05/25 20:56:21 jimtabor -; Fixed project history -; -; Revision 1.2 2000/05/08 04:30:00 jimtabor -; Update CVS to 2020 -; -; Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 -; The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with -; MS-DOS. Distributed under the GNU GPL. -; -; Revision 1.3 2000/03/09 06:07:11 kernel -; 2017f updates by James Tabor -; -; Revision 1.2 1999/08/10 17:57:12 jprice -; ror4 2011-02 patch -; -; Revision 1.1.1.1 1999/03/29 15:41:07 jprice -; New version without IPL.SYS -; -; Revision 1.1 1999/02/08 05:55:57 jprice -; Added Pat's 1937 kernel patches -; -; $EndLog$ ; %include "segs.inc" @@ -654,3 +605,18 @@ clk_and_blk_common: popf retf +; Log: io.asm,v +; Revision 1.3 2000/03/09 06:07:11 kernel +; 2017f updates by James Tabor +; +; Revision 1.2 1999/08/10 17:57:12 jprice +; ror4 2011-02 patch +; +; Revision 1.1.1.1 1999/03/29 15:41:07 jprice +; New version without IPL.SYS +; +; Revision 1.1 1999/02/08 05:55:57 jprice +; Added Pat's 1937 kernel patches +; +; EndLog +; diff --git a/kernel/io.inc b/kernel/io.inc index 4a62ab2d..b0afcd7c 100644 --- a/kernel/io.inc +++ b/kernel/io.inc @@ -25,43 +25,7 @@ ; write to the Free Software Foundation, 675 Mass Ave, ; Cambridge, MA 02139, USA. ; -; $Logfile: C:/usr/patv/dos-c/src/kernel/io.inv $ -; ; $Header$ -; -; $Log$ -; Revision 1.5 2001/09/23 20:39:44 bartoldeman -; FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling -; -; Revision 1.4 2001/03/21 02:56:26 bartoldeman -; See history.txt for changes. Bug fixes and HMA support are the main ones. -; -; Revision 1.3 2000/05/25 20:56:21 jimtabor -; Fixed project history -; -; Revision 1.2 2000/05/08 04:30:00 jimtabor -; Update CVS to 2020 -; -; Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 -; The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with -; MS-DOS. Distributed under the GNU GPL. -; -; Revision 1.3 1999/08/10 17:57:12 jprice -; ror4 2011-02 patch -; -; Revision 1.2 1999/03/29 17:05:09 jprice -; ror4 changes -; -; Revision 1.1.1.1 1999/03/29 15:41:08 jprice -; New version without IPL.SYS -; -; Revision 1.1 1999/02/08 05:55:57 jprice -; Added Pat's 1937 kernel patches -; -; -; Rev 1.0 06 Dec 1998 8:13:02 patv -; Initial revision. -; $EndLog$ ; %include "segs.inc" @@ -93,3 +57,22 @@ extern _IOCommandError:wrt TGROUP extern GetUnitNum:wrt TGROUP extern _ReqPktPtr:wrt TGROUP +; Log: io.inc,v +; +; Revision 1.3 1999/08/10 17:57:12 jprice +; ror4 2011-02 patch +; +; Revision 1.2 1999/03/29 17:05:09 jprice +; ror4 changes +; +; Revision 1.1.1.1 1999/03/29 15:41:08 jprice +; New version without IPL.SYS +; +; Revision 1.1 1999/02/08 05:55:57 jprice +; Added Pat's 1937 kernel patches +; +; +; Rev 1.0 06 Dec 1998 8:13:02 patv +; Initial revision. +; EndLog +; diff --git a/kernel/ioctl.c b/kernel/ioctl.c index 5f996413..d0f876af 100644 --- a/kernel/ioctl.c +++ b/kernel/ioctl.c @@ -33,99 +33,6 @@ static BYTE *RcsId = "$Id$"; #endif -/* - * $Log$ - * Revision 1.13 2001/11/13 23:36:45 bartoldeman - * Kernel 2025a final changes. - * - * Revision 1.12 2001/11/04 19:47:39 bartoldeman - * kernel 2025a changes: see history.txt - * - * Revision 1.11 2001/07/22 01:58:58 bartoldeman - * Support for Brian's FORMAT, DJGPP libc compilation, cleanups, MSCDEX - * - * Revision 1.10 2001/07/09 22:19:33 bartoldeman - * LBA/FCB/FAT/SYS/Ctrl-C/ioctl fixes + memory savings - * - * Revision 1.9 2001/06/03 14:16:18 bartoldeman - * BUFFERS tuning and misc bug fixes/cleanups (2024c). - * - * Revision 1.8 2001/04/15 03:21:50 bartoldeman - * See history.txt for the list of fixes. - * - * Revision 1.7 2001/03/30 22:27:42 bartoldeman - * Saner lastdrive handling. - * - * Revision 1.6 2000/06/21 18:16:46 jimtabor - * Add UMB code, patch, and code fixes - * - * Revision 1.5 2000/05/25 20:56:21 jimtabor - * Fixed project history - * - * Revision 1.4 2000/05/17 19:15:12 jimtabor - * Cleanup, add and fix source. - * - * Revision 1.3 2000/05/11 04:26:26 jimtabor - * Added code for DOS FN 69 & 6C - * - * Revision 1.2 2000/05/08 04:30:00 jimtabor - * Update CVS to 2020 - * - * Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 - * The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with - * MS-DOS. Distributed under the GNU GPL. - * - * Revision 1.4 2000/04/29 05:13:16 jtabor - * Added new functions and clean up code - * - * Revision 1.3 2000/03/09 06:07:11 kernel - * 2017f updates by James Tabor - * - * Revision 1.2 1999/04/04 18:51:43 jprice - * no message - * - * Revision 1.1.1.1 1999/03/29 15:41:09 jprice - * New version without IPL.SYS - * - * Revision 1.4 1999/02/08 05:55:57 jprice - * Added Pat's 1937 kernel patches - * - * Revision 1.3 1999/02/01 01:48:41 jprice - * Clean up; Now you can use hex numbers in config.sys. added config.sys screen function to change screen mode (28 or 43/50 lines) - * - * Revision 1.2 1999/01/22 04:13:26 jprice - * Formating - * - * Revision 1.1.1.1 1999/01/20 05:51:01 jprice - * Imported sources - * - * - * Rev 1.7 06 Dec 1998 8:48:22 patv - * Expanded due to new I/O subsystem. - * - * Rev 1.6 11 Jan 1998 2:06:22 patv - * Added functionality to ioctl. - * - * Rev 1.5 04 Jan 1998 23:15:18 patv - * Changed Log for strip utility - * - * Rev 1.4 16 Jan 1997 12:46:54 patv - * pre-Release 0.92 feature additions - * - * Rev 1.3 29 May 1996 21:03:30 patv - * bug fixes for v0.91a - * - * Rev 1.2 19 Feb 1996 3:21:34 patv - * Added NLS, int2f and config.sys processing - * - * Rev 1.1 01 Sep 1995 17:54:16 patv - * First GPL release. - * - * Rev 1.0 02 Jul 1995 8:32:04 patv - * Initial revision. - */ - - /* * WARNING: this code is non-portable (8086 specific). */ @@ -432,3 +339,58 @@ COUNT DosDevIOctl(iregs FAR * r) return SUCCESS; } +/* + * Log: ioctl.c,v - for newer log entries do "cvs log ioctl.c" + * + * Revision 1.4 2000/04/29 05:13:16 jtabor + * Added new functions and clean up code + * + * Revision 1.3 2000/03/09 06:07:11 kernel + * 2017f updates by James Tabor + * + * Revision 1.2 1999/04/04 18:51:43 jprice + * no message + * + * Revision 1.1.1.1 1999/03/29 15:41:09 jprice + * New version without IPL.SYS + * + * Revision 1.4 1999/02/08 05:55:57 jprice + * Added Pat's 1937 kernel patches + * + * Revision 1.3 1999/02/01 01:48:41 jprice + * Clean up; Now you can use hex numbers in config.sys. added config.sys screen function to change screen mode (28 or 43/50 lines) + * + * Revision 1.2 1999/01/22 04:13:26 jprice + * Formating + * + * Revision 1.1.1.1 1999/01/20 05:51:01 jprice + * Imported sources + * + * + * Rev 1.7 06 Dec 1998 8:48:22 patv + * Expanded due to new I/O subsystem. + * + * Rev 1.6 11 Jan 1998 2:06:22 patv + * Added functionality to ioctl. + * + * Rev 1.5 04 Jan 1998 23:15:18 patv + * Changed Log for strip utility + * + * Rev 1.4 16 Jan 1997 12:46:54 patv + * pre-Release 0.92 feature additions + * + * Rev 1.3 29 May 1996 21:03:30 patv + * bug fixes for v0.91a + * + * Rev 1.2 19 Feb 1996 3:21:34 patv + * Added NLS, int2f and config.sys processing + * + * Rev 1.1 01 Sep 1995 17:54:16 patv + * First GPL release. + * + * Rev 1.0 02 Jul 1995 8:32:04 patv + * Initial revision. + */ + + + diff --git a/kernel/irqstack.asm b/kernel/irqstack.asm index 38262ff9..d40d9129 100644 --- a/kernel/irqstack.asm +++ b/kernel/irqstack.asm @@ -24,53 +24,8 @@ ; write to the Free Software Foundation, 675 Mass Ave, ; Cambridge, MA 02139, USA. ; -; $Logfile: C:/dos-c/src/kernel/irqstack.asv $ -; ; $Id$ ; -; $Log$ -; Revision 1.3 2000/05/25 20:56:21 jimtabor -; Fixed project history -; -; Revision 1.2 2000/05/08 04:30:00 jimtabor -; Update CVS to 2020 -; -; Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 -; The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with -; MS-DOS. Distributed under the GNU GPL. -; -; Revision 1.3 1999/08/10 17:57:13 jprice -; ror4 2011-02 patch -; -; Revision 1.2 1999/04/16 12:21:22 jprice -; Steffen c-break handler changes -; -; Revision 1.1.1.1 1999/03/29 15:41:10 jprice -; New version without IPL.SYS -; -; Revision 1.4 1999/02/08 05:55:57 jprice -; Added Pat's 1937 kernel patches -; -; Revision 1.3 1999/02/01 01:48:41 jprice -; Clean up; Now you can use hex numbers in config.sys. added config.sys screen function to change screen mode (28 or 43/50 lines) -; -; Revision 1.2 1999/01/22 04:13:26 jprice -; Formating -; -; Revision 1.1.1.1 1999/01/20 05:51:01 jprice -; Imported sources -; -; -; Rev 1.2 06 Dec 1998 8:49:08 patv -; Bug fixes. -; -; Rev 1.1 22 Jan 1997 13:15:34 patv -; pre-0.92 Svante Frey bug fixes -; -; Rev 1.0 16 Jan 1997 21:43:44 patv -; Initial revision. -; $EndLog$ -; ; Code for stack switching during hardware interrupts. @@ -273,3 +228,37 @@ set_next: mov ax, dx loop set_next ret + +; Log: irqstack.asm,v +; Revision 1.3 1999/08/10 17:57:13 jprice +; ror4 2011-02 patch +; +; Revision 1.2 1999/04/16 12:21:22 jprice +; Steffen c-break handler changes +; +; Revision 1.1.1.1 1999/03/29 15:41:10 jprice +; New version without IPL.SYS +; +; Revision 1.4 1999/02/08 05:55:57 jprice +; Added Pat's 1937 kernel patches +; +; Revision 1.3 1999/02/01 01:48:41 jprice +; Clean up; Now you can use hex numbers in config.sys. added config.sys screen function to change screen mode (28 or 43/50 lines) +; +; Revision 1.2 1999/01/22 04:13:26 jprice +; Formating +; +; Revision 1.1.1.1 1999/01/20 05:51:01 jprice +; Imported sources +; +; +; Rev 1.2 06 Dec 1998 8:49:08 patv +; Bug fixes. +; +; Rev 1.1 22 Jan 1997 13:15:34 patv +; pre-0.92 Svante Frey bug fixes +; +; Rev 1.0 16 Jan 1997 21:43:44 patv +; Initial revision. +; EndLog +; diff --git a/kernel/kernel.asm b/kernel/kernel.asm index c0ebdffc..d1c225ea 100644 --- a/kernel/kernel.asm +++ b/kernel/kernel.asm @@ -26,131 +26,6 @@ ; Cambridge, MA 02139, USA. ; ; $Id$ -; -; $Log$ -; Revision 1.20 2001/11/13 23:36:45 bartoldeman -; Kernel 2025a final changes. -; -; Revision 1.19 2001/11/04 19:47:39 bartoldeman -; kernel 2025a changes: see history.txt -; -; Revision 1.18 2001/09/23 20:39:44 bartoldeman -; FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling -; -; Revision 1.17 2001/08/19 12:58:36 bartoldeman -; Time and date fixes, Ctrl-S/P, findfirst/next, FCBs, buffers, tsr unloading -; -; Revision 1.16 2001/07/28 18:13:06 bartoldeman -; Fixes for FORMAT+SYS, FATFS, get current dir, kernel init memory situation. -; -; Revision 1.15 2001/07/22 01:58:58 bartoldeman -; Support for Brian's FORMAT, DJGPP libc compilation, cleanups, MSCDEX -; -; Revision 1.14 2001/07/09 22:19:33 bartoldeman -; LBA/FCB/FAT/SYS/Ctrl-C/ioctl fixes + memory savings -; -; Revision 1.13 2001/06/03 14:16:18 bartoldeman -; BUFFERS tuning and misc bug fixes/cleanups (2024c). -; -; Revision 1.12 2001/04/29 17:34:40 bartoldeman -; A new SYS.COM/config.sys single stepping/console output/misc fixes. -; -; Revision 1.11 2001/04/22 01:19:34 bartoldeman -; Avoid sys warning and have a VDISK signature in the HMA -; -; Revision 1.9 2001/04/15 03:21:50 bartoldeman -; See history.txt for the list of fixes. -; -; Revision 1.8 2001/03/30 19:30:06 bartoldeman -; Misc fixes and implementation of SHELLHIGH. See history.txt for details. -; -; Revision 1.7 2001/03/21 02:56:26 bartoldeman -; See history.txt for changes. Bug fixes and HMA support are the main ones. -; -; Revision 1.6 2001/03/08 21:15:00 bartoldeman -; uppermem_root initialised to 0 (no UMBs). -; -; Revision 1.5 2000/08/06 05:50:17 jimtabor -; Add new files and update cvs with patches and changes -; -; Revision 1.4 2000/06/21 18:16:46 jimtabor -; Add UMB code, patch, and code fixes -; -; Revision 1.3 2000/05/25 20:56:21 jimtabor -; Fixed project history -; -; Revision 1.2 2000/05/08 04:30:00 jimtabor -; Update CVS to 2020 -; -; Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 -; The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with -; MS-DOS. Distributed under the GNU GPL. -; -; Revision 1.6 2000/03/09 06:07:11 kernel -; 2017f updates by James Tabor -; -; Revision 1.5 1999/09/23 04:40:47 jprice -; *** empty log message *** -; -; Revision 1.3 1999/08/10 17:57:13 jprice -; ror4 2011-02 patch -; -; Revision 1.2 1999/04/13 15:52:57 jprice -; changes for boot loader -; -; Revision 1.1.1.1 1999/03/29 15:41:14 jprice -; New version without IPL.SYS -; -; Revision 1.4 1999/02/08 05:55:57 jprice -; Added Pat's 1937 kernel patches -; -; Revision 1.3 1999/02/01 01:48:41 jprice -; Clean up; Now you can use hex numbers in config.sys. added config.sys screen function to change screen mode (28 or 43/50 lines) -; -; Revision 1.2 1999/01/22 04:13:26 jprice -; Formating -; -; Revision 1.1.1.1 1999/01/20 05:51:01 jprice -; Imported sources -; -; Rev 1.11 06 Dec 1998 8:48:04 patv -;Bug fixes. -; -; Rev 1.10 03 Feb 1998 23:30:08 patv -;Added a start-up stack for loadable device drivers. Need the separate -;stack so that all int 21h functions can be called. -; -; Rev 1.9 22 Jan 1998 4:09:24 patv -;Fixed pointer problems affecting SDA -; -; Rev 1.8 06 Jan 1998 20:12:32 patv -;Reduced device driver stack sizes. -; -; Rev 1.7 04 Jan 1998 17:26:18 patv -;Corrected subdirectory bug -; -; Rev 1.6 03 Jan 1998 8:36:50 patv -;Converted data area to SDA format -; -; Rev 1.5 06 Feb 1997 22:43:18 patv -;Reduced stack sizes for block and clock devices. -; -; Rev 1.4 06 Feb 1997 19:05:48 patv -;Added hooks for tsc command -; -; Rev 1.3 29 May 1996 21:03:44 patv -;bug fixes for v0.91a -; -; Rev 1.2 19 Feb 1996 3:24:06 patv -;Added NLS, int2f and config.sys processing -; -; Rev 1.1 01 Sep 1995 17:54:24 patv -;First GPL release. -; -; Rev 1.0 02 Jul 1995 9:05:44 patv -;Initial revision. -; -; $EndLog$ ; %include "segs.inc" @@ -1101,3 +976,70 @@ segment INIT_TEXT _INIT_DGROUP dw DGROUP +; Log: kernel.asm,v +; Revision 1.6 2000/03/09 06:07:11 kernel +; 2017f updates by James Tabor +; +; Revision 1.5 1999/09/23 04:40:47 jprice +; *** empty log message *** +; +; Revision 1.3 1999/08/10 17:57:13 jprice +; ror4 2011-02 patch +; +; Revision 1.2 1999/04/13 15:52:57 jprice +; changes for boot loader +; +; Revision 1.1.1.1 1999/03/29 15:41:14 jprice +; New version without IPL.SYS +; +; Revision 1.4 1999/02/08 05:55:57 jprice +; Added Pat's 1937 kernel patches +; +; Revision 1.3 1999/02/01 01:48:41 jprice +; Clean up; Now you can use hex numbers in config.sys. added config.sys screen function to change screen mode (28 or 43/50 lines) +; +; Revision 1.2 1999/01/22 04:13:26 jprice +; Formating +; +; Revision 1.1.1.1 1999/01/20 05:51:01 jprice +; Imported sources +; +; Rev 1.11 06 Dec 1998 8:48:04 patv +;Bug fixes. +; +; Rev 1.10 03 Feb 1998 23:30:08 patv +;Added a start-up stack for loadable device drivers. Need the separate +;stack so that all int 21h functions can be called. +; +; Rev 1.9 22 Jan 1998 4:09:24 patv +;Fixed pointer problems affecting SDA +; +; Rev 1.8 06 Jan 1998 20:12:32 patv +;Reduced device driver stack sizes. +; +; Rev 1.7 04 Jan 1998 17:26:18 patv +;Corrected subdirectory bug +; +; Rev 1.6 03 Jan 1998 8:36:50 patv +;Converted data area to SDA format +; +; Rev 1.5 06 Feb 1997 22:43:18 patv +;Reduced stack sizes for block and clock devices. +; +; Rev 1.4 06 Feb 1997 19:05:48 patv +;Added hooks for tsc command +; +; Rev 1.3 29 May 1996 21:03:44 patv +;bug fixes for v0.91a +; +; Rev 1.2 19 Feb 1996 3:24:06 patv +;Added NLS, int2f and config.sys processing +; +; Rev 1.1 01 Sep 1995 17:54:24 patv +;First GPL release. +; +; Rev 1.0 02 Jul 1995 9:05:44 patv +;Initial revision. +; +; EndLog +; diff --git a/kernel/main.c b/kernel/main.c index bdf6cc3e..f7d0cb30 100644 --- a/kernel/main.c +++ b/kernel/main.c @@ -82,165 +82,6 @@ static BYTE *mainRcsId = "$Id$"; struct _KernelConfig InitKernelConfig = {"", 0, 0, 0, 0, 0, 0}; -/* - * $Log$ - * Revision 1.23 2001/11/13 23:36:45 bartoldeman - * Kernel 2025a final changes. - * - * Revision 1.22 2001/11/04 19:47:39 bartoldeman - * kernel 2025a changes: see history.txt - * - * Revision 1.21 2001/09/23 20:39:44 bartoldeman - * FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling - * - * Revision 1.20 2001/07/28 18:13:06 bartoldeman - * Fixes for FORMAT+SYS, FATFS, get current dir, kernel init memory situation. - * - * Revision 1.19 2001/07/22 01:58:58 bartoldeman - * Support for Brian's FORMAT, DJGPP libc compilation, cleanups, MSCDEX - * - * Revision 1.18 2001/07/09 22:19:33 bartoldeman - * LBA/FCB/FAT/SYS/Ctrl-C/ioctl fixes + memory savings - * - * Revision 1.17 2001/06/03 14:16:18 bartoldeman - * BUFFERS tuning and misc bug fixes/cleanups (2024c). - * - * Revision 1.16 2001/04/29 17:34:40 bartoldeman - * A new SYS.COM/config.sys single stepping/console output/misc fixes. - * - * Revision 1.15 2001/04/21 22:32:53 bartoldeman - * Init DS=Init CS, fixed stack overflow problems and misc bugs. - * - * Revision 1.14 2001/04/16 01:45:26 bartoldeman - * Fixed handles, config.sys drivers, warnings. Enabled INT21/AH=6C, printf %S/%Fs - * - * Revision 1.13 2001/04/15 03:21:50 bartoldeman - * See history.txt for the list of fixes. - * - * Revision 1.12 2001/03/30 22:27:42 bartoldeman - * Saner lastdrive handling. - * - * Revision 1.10 2001/03/30 19:30:06 bartoldeman - * Misc fixes and implementation of SHELLHIGH. See history.txt for details. - * - * Revision 1.9 2001/03/25 17:11:54 bartoldeman - * Fixed sys.com compilation. Updated to 2023. Also: see history.txt. - * - * Revision 1.8 2001/03/21 02:56:26 bartoldeman - * See history.txt for changes. Bug fixes and HMA support are the main ones. - * - * Revision 1.7 2000/08/06 05:50:17 jimtabor - * Add new files and update cvs with patches and changes - * - * Revision 1.6 2000/06/21 18:16:46 jimtabor - * Add UMB code, patch, and code fixes - * - * Revision 1.5 2000/05/26 19:25:19 jimtabor - * Read History file for Change info - * - * Revision 1.4 2000/05/25 20:56:21 jimtabor - * Fixed project history - * - * Revision 1.3 2000/05/17 19:15:12 jimtabor - * Cleanup, add and fix source. - * - * Revision 1.2 2000/05/08 04:30:00 jimtabor - * Update CVS to 2020 - * - * Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 - * The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with - * MS-DOS. Distributed under the GNU GPL. - * - * Revision 1.14 2000/03/31 05:40:09 jtabor - * Added Eric W. Biederman Patches - * - * Revision 1.13 2000/03/09 06:07:11 kernel - * 2017f updates by James Tabor - * - * Revision 1.12 1999/09/23 04:40:48 jprice - * *** empty log message *** - * - * Revision 1.10 1999/08/25 03:18:09 jprice - * ror4 patches to allow TC 2.01 compile. - * - * Revision 1.9 1999/04/16 21:43:40 jprice - * ror4 multi-sector IO - * - * Revision 1.8 1999/04/16 12:21:22 jprice - * Steffen c-break handler changes - * - * Revision 1.7 1999/04/16 00:53:33 jprice - * Optimized FAT handling - * - * Revision 1.6 1999/04/12 03:21:17 jprice - * more ror4 patches. Changes for multi-block IO - * - * Revision 1.5 1999/04/11 04:33:39 jprice - * ror4 patches - * - * Revision 1.3 1999/04/04 22:57:47 jprice - * no message - * - * Revision 1.2 1999/04/04 18:51:43 jprice - * no message - * - * Revision 1.1.1.1 1999/03/29 15:41:18 jprice - * New version without IPL.SYS - * - * Revision 1.5 1999/02/08 05:55:57 jprice - * Added Pat's 1937 kernel patches - * - * Revision 1.4 1999/02/01 01:48:41 jprice - * Clean up; Now you can use hex numbers in config.sys. added config.sys screen function to change screen mode (28 or 43/50 lines) - * - * Revision 1.3 1999/01/30 08:28:12 jprice - * Clean up; Fixed bug with set attribute function. - * - * Revision 1.2 1999/01/22 04:13:26 jprice - * Formating - * - * Revision 1.1.1.1 1999/01/20 05:51:01 jprice - * Imported sources - * - * - * Rev 1.12 06 Dec 1998 8:45:30 patv - * Changed due to new I/O subsystem. - * - * Rev 1.11 22 Jan 1998 4:09:24 patv - * Fixed pointer problems affecting SDA - * - * Rev 1.10 04 Jan 1998 23:15:20 patv - * Changed Log for strip utility - * - * Rev 1.9 04 Jan 1998 17:26:16 patv - * Corrected subdirectory bug - * - * Rev 1.8 03 Jan 1998 8:36:48 patv - * Converted data area to SDA format - * - * Rev 1.7 06 Feb 1997 21:35:46 patv - * Modified to support new version format and changed debug message to - * output drive letter instead of number. - * - * Rev 1.6 22 Jan 1997 13:05:02 patv - * Now does correct default drive initialization. - * - * Rev 1.5 16 Jan 1997 12:47:00 patv - * pre-Release 0.92 feature additions - * - * Rev 1.3 29 May 1996 21:03:32 patv - * bug fixes for v0.91a - * - * Rev 1.2 19 Feb 1996 3:21:36 patv - * Added NLS, int2f and config.sys processing - * - * Rev 1.1 01 Sep 1995 17:54:18 patv - * First GPL release. - * - * Rev 1.0 02 Jul 1995 8:33:18 patv - * Initial revision. - */ - extern WORD days[2][13]; extern BYTE FAR * lpBase; extern BYTE FAR * lpOldTop; @@ -451,8 +292,7 @@ INIT VOID FsConfig(VOID) { struct cds FAR *pcds_table = &CDSp->cds_table[i]; - fbcopy((VOID FAR *) "A:\\\0", - (VOID FAR *) pcds_table->cdsCurrentPath, 4); + fmemcpy(pcds_table->cdsCurrentPath, "A:\\\0", 4); pcds_table->cdsCurrentPath[0] += i; @@ -773,3 +613,97 @@ INIT VOID InitPrinters(VOID) } } +/* + * Log: main.c,v - for newer log entries do "cvs log main.c" + * + * Revision 1.14 2000/03/31 05:40:09 jtabor + * Added Eric W. Biederman Patches + * + * Revision 1.13 2000/03/09 06:07:11 kernel + * 2017f updates by James Tabor + * + * Revision 1.12 1999/09/23 04:40:48 jprice + * *** empty log message *** + * + * Revision 1.10 1999/08/25 03:18:09 jprice + * ror4 patches to allow TC 2.01 compile. + * + * Revision 1.9 1999/04/16 21:43:40 jprice + * ror4 multi-sector IO + * + * Revision 1.8 1999/04/16 12:21:22 jprice + * Steffen c-break handler changes + * + * Revision 1.7 1999/04/16 00:53:33 jprice + * Optimized FAT handling + * + * Revision 1.6 1999/04/12 03:21:17 jprice + * more ror4 patches. Changes for multi-block IO + * + * Revision 1.5 1999/04/11 04:33:39 jprice + * ror4 patches + * + * Revision 1.3 1999/04/04 22:57:47 jprice + * no message + * + * Revision 1.2 1999/04/04 18:51:43 jprice + * no message + * + * Revision 1.1.1.1 1999/03/29 15:41:18 jprice + * New version without IPL.SYS + * + * Revision 1.5 1999/02/08 05:55:57 jprice + * Added Pat's 1937 kernel patches + * + * Revision 1.4 1999/02/01 01:48:41 jprice + * Clean up; Now you can use hex numbers in config.sys. added config.sys screen function to change screen mode (28 or 43/50 lines) + * + * Revision 1.3 1999/01/30 08:28:12 jprice + * Clean up; Fixed bug with set attribute function. + * + * Revision 1.2 1999/01/22 04:13:26 jprice + * Formating + * + * Revision 1.1.1.1 1999/01/20 05:51:01 jprice + * Imported sources + * + * + * Rev 1.12 06 Dec 1998 8:45:30 patv + * Changed due to new I/O subsystem. + * + * Rev 1.11 22 Jan 1998 4:09:24 patv + * Fixed pointer problems affecting SDA + * + * Rev 1.10 04 Jan 1998 23:15:20 patv + * Changed Log for strip utility + * + * Rev 1.9 04 Jan 1998 17:26:16 patv + * Corrected subdirectory bug + * + * Rev 1.8 03 Jan 1998 8:36:48 patv + * Converted data area to SDA format + * + * Rev 1.7 06 Feb 1997 21:35:46 patv + * Modified to support new version format and changed debug message to + * output drive letter instead of number. + * + * Rev 1.6 22 Jan 1997 13:05:02 patv + * Now does correct default drive initialization. + * + * Rev 1.5 16 Jan 1997 12:47:00 patv + * pre-Release 0.92 feature additions + * + * Rev 1.3 29 May 1996 21:03:32 patv + * bug fixes for v0.91a + * + * Rev 1.2 19 Feb 1996 3:21:36 patv + * Added NLS, int2f and config.sys processing + * + * Rev 1.1 01 Sep 1995 17:54:18 patv + * First GPL release. + * + * Rev 1.0 02 Jul 1995 8:33:18 patv + * Initial revision. + */ + + diff --git a/kernel/makefile b/kernel/makefile index c09fa406..4e4316b7 100644 --- a/kernel/makefile +++ b/kernel/makefile @@ -4,142 +4,6 @@ # $Id$ # -# $Log$ -# Revision 1.2 2001/11/13 23:36:45 bartoldeman -# Kernel 2025a final changes. -# -# Revision 1.1 2001/11/04 20:10:15 bartoldeman -# Added new makefile names, utils sources, kconfig.h -# -# Revision 1.13 2001/07/24 16:56:29 bartoldeman -# fixes for FCBs, DJGPP ls, DBLBYTE, dyninit allocation (2024e). -# -# Revision 1.12 2001/07/22 01:58:58 bartoldeman -# Support for Brian's FORMAT, DJGPP libc compilation, cleanups, MSCDEX -# -# Revision 1.11 2001/07/09 22:19:33 bartoldeman -# LBA/FCB/FAT/SYS/Ctrl-C/ioctl fixes + memory savings -# -# Revision 1.10 2001/04/21 22:32:53 bartoldeman -# Init DS=Init CS, fixed stack overflow problems and misc bugs. -# -# Revision 1.9 2001/04/16 14:28:32 bartoldeman -# Kernel build 2024. Fixed critical error handler/config.sys/makefiles/UMBs -# -# Revision 1.8 2001/04/15 03:21:50 bartoldeman -# See history.txt for the list of fixes. -# -# Revision 1.7 2001/03/25 17:11:54 bartoldeman -# Fixed sys.com compilation. Updated to 2023. Also: see history.txt. -# -# Revision 1.6 2001/03/21 02:56:26 bartoldeman -# See history.txt for changes. Bug fixes and HMA support are the main ones. -# -# Revision 1.4 2000/08/06 05:50:17 jimtabor -# Add new files and update cvs with patches and changes -# -# Revision 1.3 2000/05/25 20:56:21 jimtabor -# Fixed project history -# -# Revision 1.2 2000/05/08 04:30:00 jimtabor -# Update CVS to 2020 -# -# Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 -# The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with -# MS-DOS. Distributed under the GNU GPL. -# -# Revision 1.14 2000/03/31 05:40:09 jtabor -# Added Eric W. Biederman Patches -# -# Revision 1.13 2000/03/17 22:59:04 kernel -# Steffen Kaiser's NLS changes -# -# Revision 1.12 2000/03/09 06:07:11 kernel -# 2017f updates by James Tabor -# -# Revision 1.11 1999/09/23 04:40:47 jprice -# *** empty log message *** -# -# Revision 1.8 1999/09/13 20:41:41 jprice -# Some clean up. -# -# Revision 1.7 1999/08/25 03:18:09 jprice -# ror4 patches to allow TC 2.01 compile. -# -# Revision 1.6 1999/08/10 17:57:13 jprice -# ror4 2011-02 patch -# -# Revision 1.5 1999/04/23 04:25:15 jprice -# no message -# -# Revision 1.4 1999/04/23 03:45:11 jprice -# Improved by jprice -# -# Revision 1.3 1999/04/16 12:21:22 jprice -# Steffen c-break handler changes -# -# Revision 1.2 1999/04/13 15:48:21 jprice -# no message -# -# Revision 1.1.1.1 1999/03/29 15:41:15 jprice -# New version without IPL.SYS -# -# Revision 1.7 1999/03/01 06:04:37 jprice -# Fixed so it'll work with config.mak -# -# Revision 1.6 1999/03/01 05:46:43 jprice -# Turned off DEBUG define. -# -# Revision 1.5 1999/02/09 04:49:43 jprice -# Make makefile use common config.mak file -# -# Revision 1.4 1999/02/08 05:55:57 jprice -# Added Pat's 1937 kernel patches -# -# Revision 1.3 1999/02/04 03:09:59 jprice -# Added option to share constants (-d). -# -# Revision 1.2 1999/01/22 04:13:26 jprice -# Formating -# -# Revision 1.1.1.1 1999/01/20 05:51:01 jprice -# Imported sources -# -# -# Rev 1.8.1 10 Jan 1999 SRM -#Took out "/P-" from TLINK -#Changed "bcc" to "tcc" -# -# Rev 1.9 06 Dec 1998 8:45:40 patv -#Added new files for I/O subsystem. -# -# Rev 1.8 22 Jan 1998 14:50:06 patv -#Outdated stacks.asm. -# -# Rev 1.6 03 Jan 1998 8:36:50 patv -#Converted data area to SDA format -# -# Rev 1.5 30 Jan 1997 7:55:54 patv -#Added TSC flag for trace support. -# -# Rev 1.4 16 Jan 1997 12:46:42 patv -#pre-Release 0.92 feature additions -# -# Rev 1.3 29 Aug 1996 13:07:34 patv -#Bug fixes for v0.91b -# -# Rev 1.2 29 May 1996 21:03:32 patv -#bug fixes for v0.91a -# -# Rev 1.1 19 Feb 1996 3:35:38 patv -#Added NLS, int2f and config.sys processing -# -# Rev 1.0 02 Jul 1995 8:30:22 patv -#Initial revision. -# -# $EndLog$ -# - !include "..\mkfiles\generic.mak" RELEASE = 1.00 @@ -397,6 +261,96 @@ dyndata.obj: dyndata.c dyndata.h $(CC) $(DYNCFLAGS) -c $*.c $(PATCHOBJ) $*.obj $(DYNPATCH) - - - +# Log: makefile,v +# +# Revision 1.14 2000/03/31 05:40:09 jtabor +# Added Eric W. Biederman Patches +# +# Revision 1.13 2000/03/17 22:59:04 kernel +# Steffen Kaiser's NLS changes +# +# Revision 1.12 2000/03/09 06:07:11 kernel +# 2017f updates by James Tabor +# +# Revision 1.11 1999/09/23 04:40:47 jprice +# *** empty log message *** +# +# Revision 1.8 1999/09/13 20:41:41 jprice +# Some clean up. +# +# Revision 1.7 1999/08/25 03:18:09 jprice +# ror4 patches to allow TC 2.01 compile. +# +# Revision 1.6 1999/08/10 17:57:13 jprice +# ror4 2011-02 patch +# +# Revision 1.5 1999/04/23 04:25:15 jprice +# no message +# +# Revision 1.4 1999/04/23 03:45:11 jprice +# Improved by jprice +# +# Revision 1.3 1999/04/16 12:21:22 jprice +# Steffen c-break handler changes +# +# Revision 1.2 1999/04/13 15:48:21 jprice +# no message +# +# Revision 1.1.1.1 1999/03/29 15:41:15 jprice +# New version without IPL.SYS +# +# Revision 1.7 1999/03/01 06:04:37 jprice +# Fixed so it'll work with config.mak +# +# Revision 1.6 1999/03/01 05:46:43 jprice +# Turned off DEBUG define. +# +# Revision 1.5 1999/02/09 04:49:43 jprice +# Make makefile use common config.mak file +# +# Revision 1.4 1999/02/08 05:55:57 jprice +# Added Pat's 1937 kernel patches +# +# Revision 1.3 1999/02/04 03:09:59 jprice +# Added option to share constants (-d). +# +# Revision 1.2 1999/01/22 04:13:26 jprice +# Formating +# +# Revision 1.1.1.1 1999/01/20 05:51:01 jprice +# Imported sources +# +# +# Rev 1.8.1 10 Jan 1999 SRM +#Took out "/P-" from TLINK +#Changed "bcc" to "tcc" +# +# Rev 1.9 06 Dec 1998 8:45:40 patv +#Added new files for I/O subsystem. +# +# Rev 1.8 22 Jan 1998 14:50:06 patv +#Outdated stacks.asm. +# +# Rev 1.6 03 Jan 1998 8:36:50 patv +#Converted data area to SDA format +# +# Rev 1.5 30 Jan 1997 7:55:54 patv +#Added TSC flag for trace support. +# +# Rev 1.4 16 Jan 1997 12:46:42 patv +#pre-Release 0.92 feature additions +# +# Rev 1.3 29 Aug 1996 13:07:34 patv +#Bug fixes for v0.91b +# +# Rev 1.2 29 May 1996 21:03:32 patv +#bug fixes for v0.91a +# +# Rev 1.1 19 Feb 1996 3:35:38 patv +#Added NLS, int2f and config.sys processing +# +# Rev 1.0 02 Jul 1995 8:30:22 patv +#Initial revision. +# +# EndLog +# diff --git a/kernel/memmgr.c b/kernel/memmgr.c index fa89de77..0eca2097 100644 --- a/kernel/memmgr.c +++ b/kernel/memmgr.c @@ -33,104 +33,6 @@ static BYTE *memmgrRcsId = "$Id$"; #endif -/* - * $Log$ - * Revision 1.16 2001/11/04 19:47:39 bartoldeman - * kernel 2025a changes: see history.txt - * - * Revision 1.15 2001/09/23 20:39:44 bartoldeman - * FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling - * - * Revision 1.14 2001/04/21 22:32:53 bartoldeman - * Init DS=Init CS, fixed stack overflow problems and misc bugs. - * - * Revision 1.13 2001/04/16 01:45:26 bartoldeman - * Fixed handles, config.sys drivers, warnings. Enabled INT21/AH=6C, printf %S/%Fs - * - * Revision 1.12 2001/04/15 03:21:50 bartoldeman - * See history.txt for the list of fixes. - * - * Revision 1.11 2001/04/02 23:18:30 bartoldeman - * Misc, zero terminated device names and redirector bugs fixed. - * - * Revision 1.10 2001/03/30 19:30:06 bartoldeman - * Misc fixes and implementation of SHELLHIGH. See history.txt for details. - * - * Revision 1.9 2001/03/21 02:56:26 bartoldeman - * See history.txt for changes. Bug fixes and HMA support are the main ones. - * - * Revision 1.8 2001/03/08 21:00:00 bartoldeman - * UMB and MCB chain corruption (thanks Martin Stromberg) fixes - * - * Revision 1.7 2000/08/07 04:53:54 jimtabor - * Cleanup code - * - * Revision 1.6 2000/08/07 04:48:50 jimtabor - * Fixed LoadHigh probllem - * - * Revision 1.5 2000/08/06 05:50:17 jimtabor - * Add new files and update cvs with patches and changes - * - * Revision 1.4 2000/06/21 18:16:46 jimtabor - * Add UMB code, patch, and code fixes - * - * Revision 1.3 2000/05/25 20:56:21 jimtabor - * Fixed project history - * - * Revision 1.2 2000/05/08 04:30:00 jimtabor - * Update CVS to 2020 - * - * Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 - * The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with - * MS-DOS. Distributed under the GNU GPL. - * - * Revision 1.4 2000/03/09 06:07:11 kernel - * 2017f updates by James Tabor - * - * Revision 1.3 1999/08/25 03:18:09 jprice - * ror4 patches to allow TC 2.01 compile. - * - * Revision 1.2 1999/04/23 04:24:39 jprice - * Memory manager changes made by ska - * - * Revision 1.1.1.1 1999/03/29 15:41:20 jprice - * New version without IPL.SYS - * - * Revision 1.4 1999/02/08 05:55:57 jprice - * Added Pat's 1937 kernel patches - * - * Revision 1.3 1999/02/01 01:48:41 jprice - * Clean up; Now you can use hex numbers in config.sys. added config.sys screen function to change screen mode (28 or 43/50 lines) - * - * Revision 1.2 1999/01/22 04:13:26 jprice - * Formating - * - * Revision 1.1.1.1 1999/01/20 05:51:01 jprice - * Imported sources - * - * - * Rev 1.6 04 Jan 1998 23:15:18 patv - * Changed Log for strip utility - * - * Rev 1.5 16 Jan 1997 12:47:00 patv - * pre-Release 0.92 feature additions - * - * Rev 1.4 29 May 1996 21:03:34 patv - * bug fixes for v0.91a - * - * Rev 1.3 19 Feb 1996 3:21:36 patv - * Added NLS, int2f and config.sys processing - * - * Rev 1.2 01 Sep 1995 17:54:20 patv - * First GPL release. - * - * Rev 1.1 30 Jul 1995 20:51:58 patv - * Eliminated version strings in ipl - * - * Rev 1.0 02 Jul 1995 8:33:08 patv - * Initial revision. - */ - VOID mcb_init(); VOID mcb_print(); VOID show_chain(); @@ -760,3 +662,54 @@ VOID ClaimINITDataSegment() } #endif #endif + +/* + * Log: memmgr.c,v - for newer log entries do "cvs log memmgr.c" + * + * Revision 1.4 2000/03/09 06:07:11 kernel + * 2017f updates by James Tabor + * + * Revision 1.3 1999/08/25 03:18:09 jprice + * ror4 patches to allow TC 2.01 compile. + * + * Revision 1.2 1999/04/23 04:24:39 jprice + * Memory manager changes made by ska + * + * Revision 1.1.1.1 1999/03/29 15:41:20 jprice + * New version without IPL.SYS + * + * Revision 1.4 1999/02/08 05:55:57 jprice + * Added Pat's 1937 kernel patches + * + * Revision 1.3 1999/02/01 01:48:41 jprice + * Clean up; Now you can use hex numbers in config.sys. added config.sys screen function to change screen mode (28 or 43/50 lines) + * + * Revision 1.2 1999/01/22 04:13:26 jprice + * Formating + * + * Revision 1.1.1.1 1999/01/20 05:51:01 jprice + * Imported sources + * + * + * Rev 1.6 04 Jan 1998 23:15:18 patv + * Changed Log for strip utility + * + * Rev 1.5 16 Jan 1997 12:47:00 patv + * pre-Release 0.92 feature additions + * + * Rev 1.4 29 May 1996 21:03:34 patv + * bug fixes for v0.91a + * + * Rev 1.3 19 Feb 1996 3:21:36 patv + * Added NLS, int2f and config.sys processing + * + * Rev 1.2 01 Sep 1995 17:54:20 patv + * First GPL release. + * + * Rev 1.1 30 Jul 1995 20:51:58 patv + * Eliminated version strings in ipl + * + * Rev 1.0 02 Jul 1995 8:33:08 patv + * Initial revision. + */ + diff --git a/kernel/misc.c b/kernel/misc.c index 784d7d77..e4c4e306 100644 --- a/kernel/misc.c +++ b/kernel/misc.c @@ -32,26 +32,52 @@ static BYTE *miscRcsId = "$Id$"; #endif +#include "globals.h" +#ifndef I86 + +VOID strcpy(REG BYTE * d, REG BYTE * s) +{ + while (*s) + *d++ = *s++; + *d = '\0'; +} + +VOID fstrcpy(REG BYTE FAR * d, REG BYTE FAR * s) +{ + while (*s) + *d++ = *s++; + *d = '\0'; +} + +VOID fstrncpy(BYTE FAR * d, BYTE FAR * s, REG COUNT n) +{ + while (*s && n--) + *d++ = *s++; + *d = '\0'; +} + +VOID memcpy(REG VOID * d, REG VOID * s, REG COUNT n) +{ + while (n--) + *d++ = *s++; +} + +VOID fmemcpy(REG VOID FAR * d, REG VOID FAR * s, REG COUNT n) +{ + while (n--) + *((BYTE FAR *) d)++ = *((BYTE FAR *) s)++; +} + +VOID fmemset(REG VOID FAR * s, REG int ch, REG COUNT n) +{ + while (n--) + *((BYTE FAR *) s)++ = ch; +} + +#endif + /* - * $Log$ - * Revision 1.6 2001/11/04 19:47:39 bartoldeman - * kernel 2025a changes: see history.txt - * - * Revision 1.5 2001/04/15 03:21:50 bartoldeman - * See history.txt for the list of fixes. - * - * Revision 1.4 2001/03/21 02:56:26 bartoldeman - * See history.txt for changes. Bug fixes and HMA support are the main ones. - * - * Revision 1.3 2000/05/25 20:56:21 jimtabor - * Fixed project history - * - * Revision 1.2 2000/05/08 04:30:00 jimtabor - * Update CVS to 2020 - * - * Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 - * The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with - * MS-DOS. Distributed under the GNU GPL. + * Log: misc.c,v - for newer entries see "cvs log misc.c" * * Revision 1.4 2000/03/09 06:07:11 kernel * 2017f updates by James Tabor @@ -94,46 +120,3 @@ static BYTE *miscRcsId = "$Id$"; * Initial revision. */ -#include "globals.h" -#ifndef I86 - -VOID scopy(REG BYTE * s, REG BYTE * d) -{ - while (*s) - *d++ = *s++; - *d = '\0'; -} - -VOID fscopy(REG BYTE FAR * s, REG BYTE FAR * d) -{ - while (*s) - *d++ = *s++; - *d = '\0'; -} - -VOID fsncopy(BYTE FAR * s, BYTE FAR * d, REG COUNT n) -{ - while (*s && n--) - *d++ = *s++; - *d = '\0'; -} - -VOID bcopy(REG BYTE * s, REG BYTE * d, REG COUNT n) -{ - while (n--) - *d++ = *s++; -} - -VOID fbcopy(REG VOID FAR * s, REG VOID FAR * d, REG COUNT n) -{ - while (n--) - *((BYTE FAR *) d)++ = *((BYTE FAR *) s)++; -} - -VOID fmemset(REG VOID FAR * s, REG int ch, REG COUNT n) -{ - while (n--) - *((BYTE FAR *) s)++ = ch; -} - -#endif diff --git a/kernel/network.c b/kernel/network.c index aab61c87..75186d40 100644 --- a/kernel/network.c +++ b/kernel/network.c @@ -34,53 +34,24 @@ static BYTE *RcsId = "$Id$"; #endif +/* see RBIL D-2152 and D-215D06 before attempting + to change these two functions! + */ +UWORD get_machine_name(BYTE FAR * netname) +{ + fmemcpy(netname, &net_name, 16); + return (NetBios); +} + +VOID set_machine_name(BYTE FAR * netname, UWORD name_num) +{ + NetBios = name_num; + fmemcpy(&net_name, netname, 15); + net_set_count++; +} + /* - * $Log$ - * Revision 1.15 2001/11/04 19:47:39 bartoldeman - * kernel 2025a changes: see history.txt - * - * Revision 1.14 2001/07/24 16:56:29 bartoldeman - * fixes for FCBs, DJGPP ls, DBLBYTE, dyninit allocation (2024e). - * - * Revision 1.13 2001/07/22 01:58:58 bartoldeman - * Support for Brian's FORMAT, DJGPP libc compilation, cleanups, MSCDEX - * - * Revision 1.12 2001/04/29 17:34:40 bartoldeman - * A new SYS.COM/config.sys single stepping/console output/misc fixes. - * - * Revision 1.11 2001/04/15 03:21:50 bartoldeman - * See history.txt for the list of fixes. - * - * Revision 1.10 2001/04/02 23:18:30 bartoldeman - * Misc, zero terminated device names and redirector bugs fixed. - * - * Revision 1.9 2001/03/30 19:30:06 bartoldeman - * Misc fixes and implementation of SHELLHIGH. See history.txt for details. - * - * Revision 1.8 2001/03/21 02:56:26 bartoldeman - * See history.txt for changes. Bug fixes and HMA support are the main ones. - * - * Revision 1.7 2000/08/06 05:50:17 jimtabor - * Add new files and update cvs with patches and changes - * - * Revision 1.6 2000/06/21 18:16:46 jimtabor - * Add UMB code, patch, and code fixes - * - * Revision 1.5 2000/05/26 19:25:19 jimtabor - * Read History file for Change info - * - * Revision 1.4 2000/05/25 20:56:21 jimtabor - * Fixed project history - * - * Revision 1.3 2000/05/17 19:15:12 jimtabor - * Cleanup, add and fix source. - * - * Revision 1.2 2000/05/08 04:30:00 jimtabor - * Update CVS to 2020 - * - * Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 - * The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with - * MS-DOS. Distributed under the GNU GPL. + * Log: network.c,v - for newer entries see "cvs log network.c" * * Revision 1.5 2000/03/31 05:40:09 jtabor * Added Eric W. Biederman Patches @@ -96,18 +67,3 @@ static BYTE *RcsId = "$Id$"; * */ -/* see RBIL D-2152 and D-215D06 before attempting - to change these two functions! - */ -UWORD get_machine_name(BYTE FAR * netname) -{ - fmemcpy(netname, &net_name, 16); - return (NetBios); -} - -VOID set_machine_name(BYTE FAR * netname, UWORD name_num) -{ - NetBios = name_num; - fmemcpy(&net_name, netname, 15); - net_set_count++; -} diff --git a/kernel/newstuff.c b/kernel/newstuff.c index aeb9ac4d..8c4fdd94 100644 --- a/kernel/newstuff.c +++ b/kernel/newstuff.c @@ -29,104 +29,6 @@ static BYTE *mainRcsId = "$Id$"; #endif -/* - * $Log$ - * Revision 1.15 2001/11/13 23:36:45 bartoldeman - * Kernel 2025a final changes. - * - * Revision 1.14 2001/09/23 20:39:44 bartoldeman - * FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling - * - * Revision 1.13 2001/08/20 20:32:15 bartoldeman - * Truename, get free space and ctrl-break fixes. - * - * Revision 1.12 2001/07/28 18:13:06 bartoldeman - * Fixes for FORMAT+SYS, FATFS, get current dir, kernel init memory situation. - * - * Revision 1.11 2001/04/15 03:21:50 bartoldeman - * See history.txt for the list of fixes. - * - * Revision 1.10 2001/04/02 23:18:30 bartoldeman - * Misc, zero terminated device names and redirector bugs fixed. - * - * Revision 1.9 2001/03/30 22:27:42 bartoldeman - * Saner lastdrive handling. - * - * Revision 1.8 2000/08/06 05:50:17 jimtabor - * Add new files and update cvs with patches and changes - * - * Revision 1.7 2000/06/21 18:16:46 jimtabor - * Add UMB code, patch, and code fixes - * - * Revision 1.6 2000/06/01 06:37:38 jimtabor - * Read History for Changes - * - * Revision 1.5 2000/05/26 19:25:19 jimtabor - * Read History file for Change info - * - * Revision 1.4 2000/05/25 20:56:21 jimtabor - * Fixed project history - * - * Revision 1.3 2000/05/17 19:15:12 jimtabor - * Cleanup, add and fix source. - * - * Revision 1.2 2000/05/08 04:30:00 jimtabor - * Update CVS to 2020 - * - * Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 - * The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with - * MS-DOS. Distributed under the GNU GPL. - * - * Revision 1.8 2000/04/02 06:11:35 jtabor - * Fix ChgDir Code - * - * Revision 1.7 2000/04/02 05:30:48 jtabor - * Fix ChgDir Code - * - * Revision 1.6 2000/03/31 05:40:09 jtabor - * Added Eric W. Biederman Patches - * - * Revision 1.5 2000/03/09 06:07:11 kernel - * 2017f updates by James Tabor - * - * Revision 1.4 1999/08/25 03:18:09 jprice - * ror4 patches to allow TC 2.01 compile. - * - * Revision 1.3 1999/04/11 04:33:39 jprice - * ror4 patches - * - * Revision 1.2 1999/04/04 18:51:43 jprice - * no message - * - * Revision 1.1.1.1 1999/03/29 15:41:22 jprice - * New version without IPL.SYS - * - * Revision 1.4 1999/02/08 05:55:57 jprice - * Added Pat's 1937 kernel patches - * - * Revision 1.3 1999/02/01 01:48:41 jprice - * Clean up; Now you can use hex numbers in config.sys. added config.sys screen function to change screen mode (28 or 43/50 lines) - * - * Revision 1.2 1999/01/22 04:13:26 jprice - * Formating - * - * Revision 1.1.1.1 1999/01/20 05:51:01 jprice - * Imported sources - * - * - * Rev 1.4 06 Dec 1998 8:49:02 patv - * Bug fixes. - * - * Rev 1.3 04 Jan 1998 23:15:22 patv - * Changed Log for strip utility - * - * Rev 1.2 04 Jan 1998 17:26:14 patv - * Corrected subdirectory bug - * - * Rev 1.1 22 Jan 1997 13:21:22 patv - * pre-0.92 Svante Frey bug fixes. - */ - #include "portab.h" #include "globals.h" #include "proto.h" @@ -343,7 +245,7 @@ COUNT ASMCFUNC truename(char FAR * src, char FAR * dest, COUNT t) current_ldt = &CDSp->cds_table[i]; /* Always give the redirector a chance to rewrite the filename */ - fsncopy((BYTE FAR *) src, bufp -1, sizeof(buf) - (bufp - buf)); + fstrncpy(bufp - 1, src, sizeof(buf) - (bufp - buf)); if ((t == FALSE) && (QRemote_Fn(buf, dest) == SUCCESS) && (dest[0] != '\0')) { return SUCCESS; } else { @@ -351,7 +253,7 @@ COUNT ASMCFUNC truename(char FAR * src, char FAR * dest, COUNT t) } if (t == FALSE) { - fsncopy((BYTE FAR *) & current_ldt->cdsCurrentPath[0], (BYTE FAR *) & buf[0], current_ldt->cdsJoinOffset); + fstrncpy(buf, current_ldt->cdsCurrentPath, current_ldt->cdsJoinOffset); bufp = buf + current_ldt->cdsJoinOffset; rootEndPos = current_ldt->cdsJoinOffset; /* renamed x to rootEndPos - Ron Cemer */ *bufp++ = '\\'; @@ -594,8 +496,61 @@ COUNT ASMCFUNC truename(char FAR * src, char FAR * dest, COUNT t) DosUpString(buf); /* copy to user's buffer */ - fbcopy(buf, dest, bufp - buf); + fmemcpy(dest, buf, bufp - buf); return SUCCESS; } +/* + * Log: newstuff.c,v - for newer entries see "cvs log newstuff.c" + * + * Revision 1.8 2000/04/02 06:11:35 jtabor + * Fix ChgDir Code + * + * Revision 1.7 2000/04/02 05:30:48 jtabor + * Fix ChgDir Code + * + * Revision 1.6 2000/03/31 05:40:09 jtabor + * Added Eric W. Biederman Patches + * + * Revision 1.5 2000/03/09 06:07:11 kernel + * 2017f updates by James Tabor + * + * Revision 1.4 1999/08/25 03:18:09 jprice + * ror4 patches to allow TC 2.01 compile. + * + * Revision 1.3 1999/04/11 04:33:39 jprice + * ror4 patches + * + * Revision 1.2 1999/04/04 18:51:43 jprice + * no message + * + * Revision 1.1.1.1 1999/03/29 15:41:22 jprice + * New version without IPL.SYS + * + * Revision 1.4 1999/02/08 05:55:57 jprice + * Added Pat's 1937 kernel patches + * + * Revision 1.3 1999/02/01 01:48:41 jprice + * Clean up; Now you can use hex numbers in config.sys. added config.sys screen function to change screen mode (28 or 43/50 lines) + * + * Revision 1.2 1999/01/22 04:13:26 jprice + * Formating + * + * Revision 1.1.1.1 1999/01/20 05:51:01 jprice + * Imported sources + * + * + * Rev 1.4 06 Dec 1998 8:49:02 patv + * Bug fixes. + * + * Rev 1.3 04 Jan 1998 23:15:22 patv + * Changed Log for strip utility + * + * Rev 1.2 04 Jan 1998 17:26:14 patv + * Corrected subdirectory bug + * + * Rev 1.1 22 Jan 1997 13:21:22 patv + * pre-0.92 Svante Frey bug fixes. + */ + diff --git a/kernel/nls.c b/kernel/nls.c index 5b8b3acf..bc1cb96d 100644 --- a/kernel/nls.c +++ b/kernel/nls.c @@ -42,31 +42,6 @@ static BYTE *RcsId = "$Id$"; #endif -/* - * $Log$ - * Revision 1.9 2001/09/23 20:39:44 bartoldeman - * FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling - * - * Revision 1.8 2001/07/09 22:19:33 bartoldeman - * LBA/FCB/FAT/SYS/Ctrl-C/ioctl fixes + memory savings - * - * Revision 1.7 2001/06/03 14:16:18 bartoldeman - * BUFFERS tuning and misc bug fixes/cleanups (2024c). - * - * Revision 1.6 2001/04/15 03:21:50 bartoldeman - * See history.txt for the list of fixes. - * - * Revision 1.5 2001/03/21 02:56:26 bartoldeman - * See history.txt for changes. Bug fixes and HMA support are the main ones. - * - * Revision 1.4 2000/08/06 05:50:17 jimtabor - * Add new files and update cvs with patches and changes - * - * Revision 1.1 2000/03/23 02:44:21 ska - * Initial revision - * - */ - /* * assertDSeqSS() - test if DS == SS * Otherwise pointers to local variables (that ones on the stack) will @@ -635,7 +610,12 @@ COUNT DosSetCodepage(UWORD actCP, UWORD sysCP) UWORD ASMCFUNC syscall_MUX14(DIRECT_IREGS) { struct nlsPackage FAR*nls; /* addressed NLS package */ - UNREFERENCED_PARAMETER (flags || cs || ip || ds || es || si); + UNREFERENCED_PARAMETER (flags); + UNREFERENCED_PARAMETER (cs); + UNREFERENCED_PARAMETER (ip); + UNREFERENCED_PARAMETER (ds); + UNREFERENCED_PARAMETER (es); + UNREFERENCED_PARAMETER (si); log( ("NLS: MUX14(): subfct=%x, cp=%u, cntry=%u\n", AL, BX, DX) ); @@ -680,3 +660,12 @@ log( ("NLS: MUX14(FILE_UPMEM): len=%u, %04x:%04x=\"", CX, ES, DI) ); log( ("NLS: MUX14(): Invalid function %x\n", AL) ); return DE_INVLDFUNC; /* no such function */ } + +/* + * Log: nls.c,v - for newer log entries see "cvs log nls.c" + * + * Revision 1.1 2000/03/23 02:44:21 ska + * Initial revision + * + */ + diff --git a/kernel/nls_load.c b/kernel/nls_load.c index ac8f657b..43b7a524 100644 --- a/kernel/nls_load.c +++ b/kernel/nls_load.c @@ -38,16 +38,6 @@ static BYTE *RcsId = "$Id$"; #endif -/* - * $Log$ - * Revision 1.2 2001/11/04 19:47:39 bartoldeman - * kernel 2025a changes: see history.txt - * - * Revision 1.1 2000/08/06 05:50:17 jimtabor - * Add new files and update cvs with patches and changes - * - */ - #define filename Config.cfgCSYS_fnam #define cntry Config.cfgCSYS_cntry #define cp Config.cfgCSYS_cp @@ -389,3 +379,12 @@ INIT BOOL LoadCountryInfo(char *fnam) printf("Filename too long\n"); return 0; } + +/* + * Log: nls_load.c,v for newer entries do "cvs log nls_load.c" + * + * Revision 1.1 2000/08/06 05:50:17 jimtabor + * Add new files and update cvs with patches and changes + * + */ + diff --git a/kernel/nlssupt.asm b/kernel/nlssupt.asm index 030bafc0..eb3c92e4 100644 --- a/kernel/nlssupt.asm +++ b/kernel/nlssupt.asm @@ -24,64 +24,7 @@ ; write to the Free Software Foundation, 675 Mass Ave, ; Cambridge, MA 02139, USA. ; -; $Logfile: C:/dos-c/src/kernel/nlssupt.asv $ -; ; $Id$ -; -; $Log$ -; Revision 1.6 2001/03/21 02:56:26 bartoldeman -; See history.txt for changes. Bug fixes and HMA support are the main ones. -; -; -; Revision 1.5 2001/03/08 21:15:00 bartoldeman -; Fixed typo in dosUpChar (Tom Ehlert) -; -; Revision 1.4 2000/08/06 05:50:17 jimtabor -; Add new files and update cvs with patches and changes -; -; Revision 1.3 2000/05/25 20:56:21 jimtabor -; Fixed project history -; -; Revision 1.2 2000/05/08 04:30:00 jimtabor -; Update CVS to 2020 -; -; Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 -; The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with -; MS-DOS. Distributed under the GNU GPL. -; -; Revision 1.3 2000/03/17 22:59:04 kernel -; Steffen Kaiser's NLS changes -; -; Revision 1.2 1999/08/10 17:57:13 jprice -; ror4 2011-02 patch -; -; Revision 1.1.1.1 1999/03/29 15:41:25 jprice -; New version without IPL.SYS -; -; Revision 1.4 1999/02/08 05:55:57 jprice -; Added Pat's 1937 kernel patches -; -; Revision 1.3 1999/02/01 01:48:41 jprice -; Clean up; Now you can use hex numbers in config.sys. added config.sys screen function to change screen mode (28 or 43/50 lines) -; -; Revision 1.2 1999/01/22 04:13:26 jprice -; Formating -; -; Revision 1.1.1.1 1999/01/20 05:51:01 jprice -; Imported sources -; -; Rev 1.3 06 Dec 1998 8:46:56 patv -; Bug fixes. -; -; Rev 1.2 16 Jan 1997 12:46:44 patv -; pre-Release 0.92 feature additions -; -; Rev 1.1 29 May 1996 21:03:38 patv -; bug fixes for v0.91a -; -; Rev 1.0 19 Feb 1996 3:24:04 patv -; Added NLS, int2f and config.sys processing -; $EndLog$ ; @@ -126,3 +69,39 @@ _reloc_call_CharMapSrvc: pop es pop ds retf ; Return far +; Log: nlssupt.asm,v +; +; Revision 1.3 2000/03/17 22:59:04 kernel +; Steffen Kaiser's NLS changes +; +; Revision 1.2 1999/08/10 17:57:13 jprice +; ror4 2011-02 patch +; +; Revision 1.1.1.1 1999/03/29 15:41:25 jprice +; New version without IPL.SYS +; +; Revision 1.4 1999/02/08 05:55:57 jprice +; Added Pat's 1937 kernel patches +; +; Revision 1.3 1999/02/01 01:48:41 jprice +; Clean up; Now you can use hex numbers in config.sys. added config.sys screen function to change screen mode (28 or 43/50 lines) +; +; Revision 1.2 1999/01/22 04:13:26 jprice +; Formating +; +; Revision 1.1.1.1 1999/01/20 05:51:01 jprice +; Imported sources +; +; Rev 1.3 06 Dec 1998 8:46:56 patv +; Bug fixes. +; +; Rev 1.2 16 Jan 1997 12:46:44 patv +; pre-Release 0.92 feature additions +; +; Rev 1.1 29 May 1996 21:03:38 patv +; bug fixes for v0.91a +; +; Rev 1.0 19 Feb 1996 3:24:04 patv +; Added NLS, int2f and config.sys processing +; EndLog +; diff --git a/kernel/prf.c b/kernel/prf.c index 0bb613fa..cf759317 100644 --- a/kernel/prf.c +++ b/kernel/prf.c @@ -48,111 +48,6 @@ COUNT ASMCFUNC fstrlen (BYTE FAR * s); /* don't want globals.h, sorry */ static BYTE *prfRcsId = "$Id$"; #endif -/* - * $Log$ - * Revision 1.13 2001/11/04 19:47:39 bartoldeman - * kernel 2025a changes: see history.txt - * - * Revision 1.12 2001/09/23 20:39:44 bartoldeman - * FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling - * - * Revision 1.11 2001/07/22 01:58:58 bartoldeman - * Support for Brian's FORMAT, DJGPP libc compilation, cleanups, MSCDEX - * - * Revision 1.10 2001/04/29 17:34:40 bartoldeman - * A new SYS.COM/config.sys single stepping/console output/misc fixes. - * - * Revision 1.9 2001/04/21 22:32:53 bartoldeman - * Init DS=Init CS, fixed stack overflow problems and misc bugs. - * - * Revision 1.8 2001/04/16 01:45:26 bartoldeman - * Fixed handles, config.sys drivers, warnings. Enabled INT21/AH=6C, printf %S/%Fs - * - * Revision 1.7 2001/04/15 03:21:50 bartoldeman - * See history.txt for the list of fixes. - * - * Revision 1.6 2001/03/30 19:30:06 bartoldeman - * Misc fixes and implementation of SHELLHIGH. See history.txt for details. - * - * Revision 1.5 2001/03/21 02:56:26 bartoldeman - * See history.txt for changes. Bug fixes and HMA support are the main ones. - * - * Revision 1.4 2001/03/07 10:00:00 tomehlert - * recoded for smaller object footprint, added main() for testing+QA - * - * $Log$ - * Revision 1.13 2001/11/04 19:47:39 bartoldeman - * kernel 2025a changes: see history.txt - * - * Revision 1.12 2001/09/23 20:39:44 bartoldeman - * FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling - * - * Revision 1.11 2001/07/22 01:58:58 bartoldeman - * Support for Brian's FORMAT, DJGPP libc compilation, cleanups, MSCDEX - * - * Revision 1.10 2001/04/29 17:34:40 bartoldeman - * A new SYS.COM/config.sys single stepping/console output/misc fixes. - * - * Revision 1.9 2001/04/21 22:32:53 bartoldeman - * Init DS=Init CS, fixed stack overflow problems and misc bugs. - * - * Revision 1.8 2001/04/16 01:45:26 bartoldeman - * Fixed handles, config.sys drivers, warnings. Enabled INT21/AH=6C, printf %S/%Fs - * - * Revision 1.7 2001/04/15 03:21:50 bartoldeman - * See history.txt for the list of fixes. - * - * Revision 1.6 2001/03/30 19:30:06 bartoldeman - * Misc fixes and implementation of SHELLHIGH. See history.txt for details. - * - * Revision 1.5 2001/03/21 02:56:26 bartoldeman - * See history.txt for changes. Bug fixes and HMA support are the main ones. - * - * Revision 1.3 2000/05/25 20:56:21 jimtabor - * Fixed project history - * - * Revision 1.2 2000/05/08 04:30:00 jimtabor - * Update CVS to 2020 - * - * Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 - * The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with - * MS-DOS. Distributed under the GNU GPL. - * - * Revision 1.3 2000/03/09 06:07:11 kernel - * 2017f updates by James Tabor - * - * Revision 1.2 1999/04/04 18:51:43 jprice - * no message - * - * Revision 1.1.1.1 1999/03/29 15:42:20 jprice - * New version without IPL.SYS - * - * Revision 1.3 1999/02/01 01:43:28 jprice - * Fixed findfirst function to find volume label with Windows long filenames - * - * Revision 1.2 1999/01/22 04:15:28 jprice - * Formating - * - * Revision 1.1.1.1 1999/01/20 05:51:00 jprice - * Imported sources - * - * - * Rev 1.4 04 Jan 1998 23:14:38 patv - * Changed Log for strip utility - * - * Rev 1.3 29 May 1996 21:15:10 patv - * bug fixes for v0.91a - * - * Rev 1.2 01 Sep 1995 17:48:42 patv - * First GPL release. - * - * Rev 1.1 30 Jul 1995 20:50:26 patv - * Eliminated version strings in ipl - * - * Rev 1.0 02 Jul 1995 8:05:10 patv - * Initial revision. - */ - static BYTE *charp = 0; #ifdef PROTO @@ -383,23 +278,27 @@ COUNT case 'p': { - WORD w[2]; + UWORD w[2]; static char pointerFormat[] = "%04x:%04x"; - w[1] = *((unsigned int*) arg)++; - w[0] = *((unsigned int*) arg)++; + w[1] = *((UWORD *) arg); + arg += sizeof(UWORD); + w[0] = *((UWORD *) arg); + arg += sizeof(UWORD); do_printf(pointerFormat,(BYTE**)&w); continue; } case 's': - p = *((BYTE **) arg)++; + p = *((BYTE **) arg); + arg += sizeof(BYTE *); goto do_outputstring; case 'F': fmt++; /* we assume %Fs here */ case 'S': - p = *((BYTE FAR **) arg)++; + p = *((BYTE FAR **) arg); + arg += sizeof(BYTE FAR *); goto do_outputstring; case 'i': @@ -421,11 +320,16 @@ COUNT lprt: if (longarg) - currentArg = *((LONG *) arg)++; + { + currentArg = *((LONG *) arg); + arg += sizeof(LONG); + } else - if (base < 0) currentArg = *((int*) arg)++; - else currentArg = *((unsigned int*) arg)++; - + { + if (base < 0) currentArg = *((int*) arg); + else currentArg = *((unsigned int*) arg); + arg += sizeof(int); + } ltob(currentArg, s, base); @@ -566,3 +470,45 @@ main() } } #endif + +/* + * Log: prf.c,v - see "cvs log prf.c" for newer entries + * + * Revision 1.4 2001/03/07 10:00:00 tomehlert + * recoded for smaller object footprint, added main() for testing+QA + * + * Revision 1.3 2000/03/09 06:07:11 kernel + * 2017f updates by James Tabor + * + * Revision 1.2 1999/04/04 18:51:43 jprice + * no message + * + * Revision 1.1.1.1 1999/03/29 15:42:20 jprice + * New version without IPL.SYS + * + * Revision 1.3 1999/02/01 01:43:28 jprice + * Fixed findfirst function to find volume label with Windows long filenames + * + * Revision 1.2 1999/01/22 04:15:28 jprice + * Formating + * + * Revision 1.1.1.1 1999/01/20 05:51:00 jprice + * Imported sources + * + * + * Rev 1.4 04 Jan 1998 23:14:38 patv + * Changed Log for strip utility + * + * Rev 1.3 29 May 1996 21:15:10 patv + * bug fixes for v0.91a + * + * Rev 1.2 01 Sep 1995 17:48:42 patv + * First GPL release. + * + * Rev 1.1 30 Jul 1995 20:50:26 patv + * Eliminated version strings in ipl + * + * Rev 1.0 02 Jul 1995 8:05:10 patv + * Initial revision. + */ + diff --git a/kernel/printer.asm b/kernel/printer.asm index cbcf898a..f007f18b 100644 --- a/kernel/printer.asm +++ b/kernel/printer.asm @@ -26,34 +26,6 @@ ; Cambridge, MA 02139, USA. ; ; $Header$ -; -; $Log$ -; Revision 1.5 2001/09/24 02:21:14 bartoldeman -; SYS and printer fixes -; -; Revision 1.4 2001/09/23 20:39:44 bartoldeman -; FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling -; -; Revision 1.3 2000/05/25 20:56:21 jimtabor -; Fixed project history -; -; Revision 1.2 2000/05/08 04:30:00 jimtabor -; Update CVS to 2020 -; -; Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 -; The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with -; MS-DOS. Distributed under the GNU GPL. -; -; Revision 1.2 1999/08/10 17:57:13 jprice -; ror4 2011-02 patch -; -; Revision 1.1.1.1 1999/03/29 15:41:26 jprice -; New version without IPL.SYS -; -; Revision 1.1 1999/02/08 05:55:57 jprice -; Added Pat's 1937 kernel patches -; -; $EndLog$ ; %include "io.inc" @@ -271,3 +243,17 @@ PrtGnIoctl3: ; as the BIOS has a LARGE timeout before aborting ; +; Log: printer.asm,v +; +; Revision 1.2 1999/08/10 17:57:13 jprice +; ror4 2011-02 patch +; +; Revision 1.1.1.1 1999/03/29 15:41:26 jprice +; New version without IPL.SYS +; +; Revision 1.1 1999/02/08 05:55:57 jprice +; Added Pat's 1937 kernel patches +; +; EndLog +; + diff --git a/kernel/procsupt.asm b/kernel/procsupt.asm index aa7a8983..05fffaf1 100644 --- a/kernel/procsupt.asm +++ b/kernel/procsupt.asm @@ -25,72 +25,7 @@ ; write to the Free Software Foundation, 675 Mass Ave, ; Cambridge, MA 02139, USA. ; -; $Logfile: C:/usr/patv/dos-c/src/kernel/procsupt.asv $ -; ; $Id$ -; -; $Log$ -; Revision 1.7 2001/09/23 20:39:44 bartoldeman -; FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling -; -; Revision 1.6 2001/04/15 03:21:50 bartoldeman -; See history.txt for the list of fixes. -; -; Revision 1.5 2001/03/24 22:13:05 bartoldeman -; See history.txt: dsk.c changes, warning removal and int21 entry handling. -; -; Revision 1.4 2001/03/21 02:56:26 bartoldeman -; See history.txt for changes. Bug fixes and HMA support are the main ones. -; -; Revision 1.3 2000/05/25 20:56:21 jimtabor -; Fixed project history -; -; Revision 1.2 2000/05/08 04:30:00 jimtabor -; Update CVS to 2020 -; -; Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 -; The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with -; MS-DOS. Distributed under the GNU GPL. -; -; Revision 1.4 1999/08/10 17:57:13 jprice -; ror4 2011-02 patch -; -; Revision 1.3 1999/04/23 22:38:36 jprice -; Fixed got_cbreak function. -; -; Revision 1.2 1999/04/16 12:21:22 jprice -; Steffen c-break handler changes -; -; Revision 1.1.1.1 1999/03/29 15:41:27 jprice -; New version without IPL.SYS -; -; Revision 1.4 1999/02/08 05:55:57 jprice -; Added Pat's 1937 kernel patches -; -; Revision 1.3 1999/02/01 01:48:41 jprice -; Clean up; Now you can use hex numbers in config.sys. added config.sys screen function to change screen mode (28 or 43/50 lines) -; -; Revision 1.2 1999/01/22 04:13:27 jprice -; Formating -; -; Revision 1.1.1.1 1999/01/20 05:51:01 jprice -; Imported sources -; -; Rev 1.4 06 Dec 1998 8:46:44 patv -;Bug fixes. -; -; Rev 1.3 07 Feb 1998 20:42:08 patv -;Modified stack fram to match DOS standard -; -; Rev 1.2 29 May 1996 21:03:36 patv -;bug fixes for v0.91a -; -; Rev 1.1 01 Sep 1995 17:54:24 patv -;First GPL release. -; -; Rev 1.0 02 Jul 1995 9:05:58 patv -;Initial revision. -; $EndLog$ ; @@ -338,3 +273,45 @@ _spawn_int23: ; ret ;_disable endp +; Log: procsupt.asm,v +; Revision 1.4 1999/08/10 17:57:13 jprice +; ror4 2011-02 patch +; +; Revision 1.3 1999/04/23 22:38:36 jprice +; Fixed got_cbreak function. +; +; Revision 1.2 1999/04/16 12:21:22 jprice +; Steffen c-break handler changes +; +; Revision 1.1.1.1 1999/03/29 15:41:27 jprice +; New version without IPL.SYS +; +; Revision 1.4 1999/02/08 05:55:57 jprice +; Added Pat's 1937 kernel patches +; +; Revision 1.3 1999/02/01 01:48:41 jprice +; Clean up; Now you can use hex numbers in config.sys. added config.sys screen function to change screen mode (28 or 43/50 lines) +; +; Revision 1.2 1999/01/22 04:13:27 jprice +; Formating +; +; Revision 1.1.1.1 1999/01/20 05:51:01 jprice +; Imported sources +; +; Rev 1.4 06 Dec 1998 8:46:44 patv +;Bug fixes. +; +; Rev 1.3 07 Feb 1998 20:42:08 patv +;Modified stack fram to match DOS standard +; +; Rev 1.2 29 May 1996 21:03:36 patv +;bug fixes for v0.91a +; +; Rev 1.1 01 Sep 1995 17:54:24 patv +;First GPL release. +; +; Rev 1.0 02 Jul 1995 9:05:58 patv +;Initial revision. +; EndLog +; + diff --git a/kernel/proto.h b/kernel/proto.h index db393b71..9789168c 100644 --- a/kernel/proto.h +++ b/kernel/proto.h @@ -32,169 +32,6 @@ static BYTE *Proto_hRcsId = "$Id$"; #endif #endif -/* - * $Log$ - * Revision 1.24 2001/11/13 23:36:45 bartoldeman - * Kernel 2025a final changes. - * - * Revision 1.23 2001/11/04 19:47:39 bartoldeman - * kernel 2025a changes: see history.txt - * - * Revision 1.22 2001/09/23 20:39:44 bartoldeman - * FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling - * - * Revision 1.21 2001/08/19 12:58:36 bartoldeman - * Time and date fixes, Ctrl-S/P, findfirst/next, FCBs, buffers, tsr unloading - * - * Revision 1.20 2001/07/24 16:56:29 bartoldeman - * fixes for FCBs, DJGPP ls, DBLBYTE, dyninit allocation (2024e). - * - * Revision 1.19 2001/07/23 12:47:42 bartoldeman - * FCB fixes and clean-ups, exec int21/ax=4b01, initdisk.c printf - * - * Revision 1.18 2001/07/22 01:58:58 bartoldeman - * Support for Brian's FORMAT, DJGPP libc compilation, cleanups, MSCDEX - * - * Revision 1.17 2001/06/03 14:16:18 bartoldeman - * BUFFERS tuning and misc bug fixes/cleanups (2024c). - * - * Revision 1.16 2001/04/29 17:34:40 bartoldeman - * A new SYS.COM/config.sys single stepping/console output/misc fixes. - * - * Revision 1.15 2001/04/21 22:32:53 bartoldeman - * Init DS=Init CS, fixed stack overflow problems and misc bugs. - * - * Revision 1.14 2001/04/16 01:45:26 bartoldeman - * Fixed handles, config.sys drivers, warnings. Enabled INT21/AH=6C, printf %S/%Fs - * - * Revision 1.13 2001/04/15 03:21:50 bartoldeman - * See history.txt for the list of fixes. - * - * Revision 1.12 2001/03/30 19:30:06 bartoldeman - * Misc fixes and implementation of SHELLHIGH. See history.txt for details. - * - * Revision 1.11 2001/03/27 20:27:43 bartoldeman - * dsk.c (reported by Nagy Daniel), inthndlr and int25/26 fixes by Tom Ehlert. - * - * Revision 1.10 2001/03/22 04:55:36 bartoldeman - * Fix prototypes. - * - * Revision 1.9 2001/03/21 02:56:26 bartoldeman - * See history.txt for changes. Bug fixes and HMA support are the main ones. - * - * Revision 1.8 2000/10/30 00:21:15 jimtabor - * Adding Brian Reifsnyder Fix for Int 25/26 - * - * Revision 1.7 2000/08/07 22:51:34 jimtabor - * Remove unused code - * - * Revision 1.6 2000/08/06 05:50:17 jimtabor - * Add new files and update cvs with patches and changes - * - * Revision 1.5 2000/06/21 18:16:46 jimtabor - * Add UMB code, patch, and code fixes - * - * Revision 1.4 2000/05/26 19:25:19 jimtabor - * Read History file for Change info - * - * Revision 1.3 2000/05/25 20:56:21 jimtabor - * Fixed project history - * - * Revision 1.2 2000/05/08 04:30:00 jimtabor - * Update CVS to 2020 - * - * Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 - * The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with - * MS-DOS. Distributed under the GNU GPL. - * - * Revision 1.17 2000/03/31 05:40:09 jtabor - * Added Eric W. Biederman Patches - * - * Revision 1.16 2000/03/17 22:59:04 kernel - * Steffen Kaiser's NLS changes - * - * Revision 1.15 2000/03/09 06:07:11 kernel - * 2017f updates by James Tabor - * - * Revision 1.14 1999/09/23 04:40:48 jprice - * *** empty log message *** - * - * Revision 1.10 1999/08/25 03:18:09 jprice - * ror4 patches to allow TC 2.01 compile. - * - * Revision 1.9 1999/05/03 06:25:45 jprice - * Patches from ror4 and many changed of signed to unsigned variables. - * - * Revision 1.8 1999/04/23 04:24:39 jprice - * Memory manager changes made by ska - * - * Revision 1.7 1999/04/16 21:43:40 jprice - * ror4 multi-sector IO - * - * Revision 1.6 1999/04/16 12:21:22 jprice - * Steffen c-break handler changes - * - * Revision 1.5 1999/04/12 03:21:17 jprice - * more ror4 patches. Changes for multi-block IO - * - * Revision 1.4 1999/04/11 04:33:39 jprice - * ror4 patches - * - * Revision 1.2 1999/04/04 18:51:43 jprice - * no message - * - * Revision 1.1.1.1 1999/03/29 15:41:30 jprice - * New version without IPL.SYS - * - * Revision 1.4 1999/02/08 05:55:57 jprice - * Added Pat's 1937 kernel patches - * - * Revision 1.3 1999/02/01 01:48:41 jprice - * Clean up; Now you can use hex numbers in config.sys. added config.sys screen function to change screen mode (28 or 43/50 lines) - * - * Revision 1.2 1999/01/22 04:13:27 jprice - * Formating - * - * Revision 1.1.1.1 1999/01/20 05:51:01 jprice - * Imported sources - * - * - * Rev 1.11 06 Dec 1998 8:47:18 patv - *Expanded due to new I/O subsystem. - * - * Rev 1.10 07 Feb 1998 20:38:00 patv - *Modified stack fram to match DOS standard - * - * Rev 1.9 22 Jan 1998 4:09:26 patv - *Fixed pointer problems affecting SDA - * - * Rev 1.8 11 Jan 1998 2:06:22 patv - *Added functionality to ioctl. - * - * Rev 1.7 04 Jan 1998 23:16:22 patv - *Changed Log for strip utility - * - * Rev 1.6 03 Jan 1998 8:36:48 patv - *Converted data area to SDA format - * - * Rev 1.5 16 Jan 1997 12:46:44 patv - *pre-Release 0.92 feature additions - * - * Rev 1.4 29 May 1996 21:03:40 patv - *bug fixes for v0.91a - * - * Rev 1.3 19 Feb 1996 3:23:06 patv - *Added NLS, int2f and config.sys processing - * - * Rev 1.2 01 Sep 1995 17:54:26 patv - *First GPL release. - * - * Rev 1.1 30 Jul 1995 20:51:58 patv - *Eliminated version strings in ipl - * - * Rev 1.0 05 Jul 1995 11:32:16 patv - *Initial revision. - */ /* blockio.c */ ULONG getblkno(struct buffer FAR *); @@ -417,30 +254,13 @@ VOID DosUmbLink(BYTE n); VOID mcb_print(mcb FAR * mcbp); /* misc.c */ -/* -VOID scopy(REG BYTE * s, REG BYTE * d); -#define strcpy(d, s) scopy(s, d) -VOID fbcopy(REG VOID FAR * s, REG VOID FAR * d, REG COUNT n); - -*/ VOID strcpy(REG BYTE * d, REG BYTE * s); -#define scopy(s, d) strcpy(d,s) VOID ASMCFUNC fmemcpy(REG VOID FAR * d, REG VOID FAR * s, REG COUNT n); -#define fbcopy(s, d, n) fmemcpy(d,s,n) - - -/*VOID fscopy(REG BYTE FAR * s, REG BYTE FAR * d);*/ VOID ASMCFUNC fstrcpy(REG BYTE FAR * d, REG BYTE FAR * s); -#define fscopy(s,d) fstrcpy(d,s) - VOID ASMCFUNC fstrcpy(REG BYTE FAR * d, REG BYTE FAR * s); - -/*VOID bcopy(REG BYTE * s, REG BYTE * d, REG COUNT n);*/ void ASMCFUNC memcpy(REG void * d, REG VOID * s, REG COUNT n); -#define bcopy(s,d,n) memcpy(d,s,n) - void ASMCFUNC fmemset(REG VOID FAR * s, REG int ch, REG COUNT n); -void ASMCFUNC memset(REG VOID * s, REG int ch, REG COUNT n); +void ASMCFUNC memset(REG VOID * s, REG int ch, REG COUNT n); /* lfnapi.c */ COUNT lfn_allocate_inode(VOID); @@ -598,3 +418,95 @@ ULONG FAR ASMCFUNC MULULUL(ULONG mul1, ULONG mul2); /* MULtiply ULong by ULong * ULONG FAR ASMCFUNC DIVULUS(ULONG mul1, UWORD mul2); /* DIVide ULong by UShort */ ULONG FAR ASMCFUNC DIVMODULUS(ULONG mul1, UWORD mul2,UWORD *rem); /* DIVide ULong by UShort */ #endif + +/* + * Log: proto.h,v + * + * Revision 1.17 2000/03/31 05:40:09 jtabor + * Added Eric W. Biederman Patches + * + * Revision 1.16 2000/03/17 22:59:04 kernel + * Steffen Kaiser's NLS changes + * + * Revision 1.15 2000/03/09 06:07:11 kernel + * 2017f updates by James Tabor + * + * Revision 1.14 1999/09/23 04:40:48 jprice + * *** empty log message *** + * + * Revision 1.10 1999/08/25 03:18:09 jprice + * ror4 patches to allow TC 2.01 compile. + * + * Revision 1.9 1999/05/03 06:25:45 jprice + * Patches from ror4 and many changed of signed to unsigned variables. + * + * Revision 1.8 1999/04/23 04:24:39 jprice + * Memory manager changes made by ska + * + * Revision 1.7 1999/04/16 21:43:40 jprice + * ror4 multi-sector IO + * + * Revision 1.6 1999/04/16 12:21:22 jprice + * Steffen c-break handler changes + * + * Revision 1.5 1999/04/12 03:21:17 jprice + * more ror4 patches. Changes for multi-block IO + * + * Revision 1.4 1999/04/11 04:33:39 jprice + * ror4 patches + * + * Revision 1.2 1999/04/04 18:51:43 jprice + * no message + * + * Revision 1.1.1.1 1999/03/29 15:41:30 jprice + * New version without IPL.SYS + * + * Revision 1.4 1999/02/08 05:55:57 jprice + * Added Pat's 1937 kernel patches + * + * Revision 1.3 1999/02/01 01:48:41 jprice + * Clean up; Now you can use hex numbers in config.sys. added config.sys screen function to change screen mode (28 or 43/50 lines) + * + * Revision 1.2 1999/01/22 04:13:27 jprice + * Formating + * + * Revision 1.1.1.1 1999/01/20 05:51:01 jprice + * Imported sources + * + * + * Rev 1.11 06 Dec 1998 8:47:18 patv + *Expanded due to new I/O subsystem. + * + * Rev 1.10 07 Feb 1998 20:38:00 patv + *Modified stack fram to match DOS standard + * + * Rev 1.9 22 Jan 1998 4:09:26 patv + *Fixed pointer problems affecting SDA + * + * Rev 1.8 11 Jan 1998 2:06:22 patv + *Added functionality to ioctl. + * + * Rev 1.7 04 Jan 1998 23:16:22 patv + *Changed Log for strip utility + * + * Rev 1.6 03 Jan 1998 8:36:48 patv + *Converted data area to SDA format + * + * Rev 1.5 16 Jan 1997 12:46:44 patv + *pre-Release 0.92 feature additions + * + * Rev 1.4 29 May 1996 21:03:40 patv + *bug fixes for v0.91a + * + * Rev 1.3 19 Feb 1996 3:23:06 patv + *Added NLS, int2f and config.sys processing + * + * Rev 1.2 01 Sep 1995 17:54:26 patv + *First GPL release. + * + * Rev 1.1 30 Jul 1995 20:51:58 patv + *Eliminated version strings in ipl + * + * Rev 1.0 05 Jul 1995 11:32:16 patv + *Initial revision. + */ diff --git a/kernel/rtlsupt.asm b/kernel/rtlsupt.asm index 5f5a82ef..0c7111df 100644 --- a/kernel/rtlsupt.asm +++ b/kernel/rtlsupt.asm @@ -28,9 +28,6 @@ ; ; $Id$ ; -; Rev 1.0 02 Jul 1995 9:04:50 patv -;Initial revision. -; $EndLog$ ; %include "segs.inc" diff --git a/kernel/segs.inc b/kernel/segs.inc index 3a39e581..e1dd76e0 100644 --- a/kernel/segs.inc +++ b/kernel/segs.inc @@ -24,53 +24,8 @@ ; write to the Free Software Foundation, 675 Mass Ave, ; Cambridge, MA 02139, USA. ; -; $Logfile: C:/usr/patv/dos-c/src/kernel/segs.inv $ -; ; $Header$ ; -; $Log$ -; Revision 1.9 2001/09/23 20:39:44 bartoldeman -; FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling -; -; Revision 1.8 2001/07/09 22:19:33 bartoldeman -; LBA/FCB/FAT/SYS/Ctrl-C/ioctl fixes + memory savings -; -; Revision 1.7 2001/04/29 17:34:40 bartoldeman -; A new SYS.COM/config.sys single stepping/console output/misc fixes. -; -; Revision 1.6 2001/04/21 22:32:53 bartoldeman -; Init DS=Init CS, fixed stack overflow problems and misc bugs. -; -; Revision 1.5 2001/04/15 03:21:50 bartoldeman -; See history.txt for the list of fixes. -; -; Revision 1.4 2001/03/21 02:56:26 bartoldeman -; See history.txt for changes. Bug fixes and HMA support are the main ones. -; -; Revision 1.3 2000/05/25 20:56:21 jimtabor -; Fixed project history -; -; Revision 1.2 2000/05/08 04:30:00 jimtabor -; Update CVS to 2020 -; -; Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 -; The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with -; MS-DOS. Distributed under the GNU GPL. -; -; Revision 1.2 1999/08/10 17:57:13 jprice -; ror4 2011-02 patch -; -; Revision 1.1.1.1 1999/03/29 15:41:30 jprice -; New version without IPL.SYS -; -; Revision 1.1 1999/02/08 05:55:57 jprice -; Added Pat's 1937 kernel patches -; -; -; Rev 1.0 06 Dec 1998 8:12:36 patv -; Initial revision. -; $EndLog -; group PGROUP PSP group TGROUP _TEXT _IO_TEXT _IO_FIXED_DATA @@ -105,3 +60,19 @@ segment IB class=IB align=2 segment IB_E class=IB align=2 segment IC class=IC align=2 +; Log: segs.inc,v +; +; Revision 1.2 1999/08/10 17:57:13 jprice +; ror4 2011-02 patch +; +; Revision 1.1.1.1 1999/03/29 15:41:30 jprice +; New version without IPL.SYS +; +; Revision 1.1 1999/02/08 05:55:57 jprice +; Added Pat's 1937 kernel patches +; +; +; Rev 1.0 06 Dec 1998 8:12:36 patv +; Initial revision. +; EndLog +; diff --git a/kernel/serial.asm b/kernel/serial.asm index 5dc886d6..4916f21a 100644 --- a/kernel/serial.asm +++ b/kernel/serial.asm @@ -26,28 +26,6 @@ ; Cambridge, MA 02139, USA. ; ; $Header$ -; -; $Log$ -; Revision 1.3 2000/05/25 20:56:21 jimtabor -; Fixed project history -; -; Revision 1.2 2000/05/08 04:30:00 jimtabor -; Update CVS to 2020 -; -; Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 -; The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with -; MS-DOS. Distributed under the GNU GPL. -; -; Revision 1.2 1999/08/10 17:57:13 jprice -; ror4 2011-02 patch -; -; Revision 1.1.1.1 1999/03/29 15:41:31 jprice -; New version without IPL.SYS -; -; Revision 1.1 1999/02/08 05:55:57 jprice -; Added Pat's 1937 kernel patches -; -; $EndLog$ ; %include "io.inc" @@ -176,3 +154,15 @@ GetComStat: segment _DATA ComStatArray db 0, 0, 0, 0 + +; Revision 1.2 1999/08/10 17:57:13 jprice +; ror4 2011-02 patch +; +; Revision 1.1.1.1 1999/03/29 15:41:31 jprice +; New version without IPL.SYS +; +; Revision 1.1 1999/02/08 05:55:57 jprice +; Added Pat's 1937 kernel patches +; +; EndLog +; diff --git a/kernel/strings.c b/kernel/strings.c index b23fa757..bf7967cf 100644 --- a/kernel/strings.c +++ b/kernel/strings.c @@ -32,74 +32,6 @@ static BYTE *stringsRcsId = "$Id$"; #endif -/* - * $Log$ - * Revision 1.6 2001/11/04 19:47:39 bartoldeman - * kernel 2025a changes: see history.txt - * - * Revision 1.5 2001/04/15 03:21:50 bartoldeman - * See history.txt for the list of fixes. - * - * Revision 1.4 2001/03/21 02:56:26 bartoldeman - * See history.txt for changes. Bug fixes and HMA support are the main ones. - * - * Revision 1.3 2000/05/25 20:56:21 jimtabor - * Fixed project history - * - * Revision 1.2 2000/05/08 04:30:00 jimtabor - * Update CVS to 2020 - * - * Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 - * The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with - * MS-DOS. Distributed under the GNU GPL. - * - * Revision 1.4 2000/03/09 06:07:11 kernel - * 2017f updates by James Tabor - * - * Revision 1.3 1999/08/25 03:18:09 jprice - * ror4 patches to allow TC 2.01 compile. - * - * Revision 1.2 1999/04/04 18:51:43 jprice - * no message - * - * Revision 1.1.1.1 1999/03/29 15:41:32 jprice - * New version without IPL.SYS - * - * Revision 1.4 1999/02/04 03:14:07 jprice - * Formating. Added comments. - * - * Revision 1.3 1999/02/01 01:48:41 jprice - * Clean up; Now you can use hex numbers in config.sys. added config.sys screen function to change screen mode (28 or 43/50 lines) - * - * Revision 1.2 1999/01/22 04:13:27 jprice - * Formating - * - * Revision 1.1.1.1 1999/01/20 05:51:01 jprice - * Imported sources - * - * - * Rev 1.6 04 Jan 1998 23:15:16 patv - * Changed Log for strip utility - * - * Rev 1.5 31 Dec 1997 3:59:30 patv - * Added new far string functions. - * - * Rev 1.4 29 May 1996 21:03:30 patv - * bug fixes for v0.91a - * - * Rev 1.3 19 Feb 1996 3:21:36 patv - * Added NLS, int2f and config.sys processing - * - * Rev 1.2 01 Sep 1995 17:54:22 patv - * First GPL release. - * - * Rev 1.1 30 Jul 1995 20:51:58 patv - * Eliminated version strings in ipl - * - * Rev 1.0 02 Jul 1995 8:33:46 patv - * Initial revision. - */ - #ifndef I86 COUNT strlen(REG BYTE * s) { @@ -205,3 +137,54 @@ BYTE *strchr(BYTE * s, BYTE c) return 0; } #endif + +/* + * Log: strings.c,v - see "cvs log strings.c" for newer entries + * + * Revision 1.4 2000/03/09 06:07:11 kernel + * 2017f updates by James Tabor + * + * Revision 1.3 1999/08/25 03:18:09 jprice + * ror4 patches to allow TC 2.01 compile. + * + * Revision 1.2 1999/04/04 18:51:43 jprice + * no message + * + * Revision 1.1.1.1 1999/03/29 15:41:32 jprice + * New version without IPL.SYS + * + * Revision 1.4 1999/02/04 03:14:07 jprice + * Formating. Added comments. + * + * Revision 1.3 1999/02/01 01:48:41 jprice + * Clean up; Now you can use hex numbers in config.sys. added config.sys screen function to change screen mode (28 or 43/50 lines) + * + * Revision 1.2 1999/01/22 04:13:27 jprice + * Formating + * + * Revision 1.1.1.1 1999/01/20 05:51:01 jprice + * Imported sources + * + * + * Rev 1.6 04 Jan 1998 23:15:16 patv + * Changed Log for strip utility + * + * Rev 1.5 31 Dec 1997 3:59:30 patv + * Added new far string functions. + * + * Rev 1.4 29 May 1996 21:03:30 patv + * bug fixes for v0.91a + * + * Rev 1.3 19 Feb 1996 3:21:36 patv + * Added NLS, int2f and config.sys processing + * + * Rev 1.2 01 Sep 1995 17:54:22 patv + * First GPL release. + * + * Rev 1.1 30 Jul 1995 20:51:58 patv + * Eliminated version strings in ipl + * + * Rev 1.0 02 Jul 1995 8:33:46 patv + * Initial revision. + */ + diff --git a/kernel/sysclk.c b/kernel/sysclk.c index 8fe71088..867c7cb4 100644 --- a/kernel/sysclk.c +++ b/kernel/sysclk.c @@ -33,77 +33,6 @@ static BYTE *RcsId = "$Id$"; #endif -/* - * $Log$ - * Revision 1.9 2001/09/23 20:39:44 bartoldeman - * FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling - * - * Revision 1.8 2001/08/19 12:58:36 bartoldeman - * Time and date fixes, Ctrl-S/P, findfirst/next, FCBs, buffers, tsr unloading - * - * Revision 1.7 2001/07/22 01:58:58 bartoldeman - * Support for Brian's FORMAT, DJGPP libc compilation, cleanups, MSCDEX - * - * Revision 1.6 2001/04/21 22:32:53 bartoldeman - * Init DS=Init CS, fixed stack overflow problems and misc bugs. - * - * Revision 1.5 2001/04/15 03:21:50 bartoldeman - * See history.txt for the list of fixes. - * - * Revision 1.4 2001/03/21 02:56:26 bartoldeman - * See history.txt for changes. Bug fixes and HMA support are the main ones. - * - * Revision 1.3 2000/05/25 20:56:21 jimtabor - * Fixed project history - * - * Revision 1.2 2000/05/08 04:30:00 jimtabor - * Update CVS to 2020 - * - * Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 - * The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with - * MS-DOS. Distributed under the GNU GPL. - * - * Revision 1.3 2000/03/09 06:07:11 kernel - * 2017f updates by James Tabor - * - * Revision 1.2 1999/04/12 03:21:17 jprice - * more ror4 patches. Changes for multi-block IO - * - * Revision 1.1.1.1 1999/03/29 15:41:33 jprice - * New version without IPL.SYS - * - * Revision 1.5 1999/02/08 05:55:58 jprice - * Added Pat's 1937 kernel patches - * - * Revision 1.4 1999/02/04 03:14:07 jprice - * Formating. Added comments. - * - * Revision 1.3 1999/02/01 01:48:41 jprice - * Clean up; Now you can use hex numbers in config.sys. added config.sys screen function to change screen mode (28 or 43/50 lines) - * - * Revision 1.2 1999/01/22 04:13:27 jprice - * Formating - * - * Revision 1.1.1.1 1999/01/20 05:51:01 jprice - * Imported sources - * - * - * Rev 1.4 04 Jan 1998 23:15:16 patv - * Changed Log for strip utility - * - * Rev 1.3 29 May 1996 21:03:48 patv - * bug fixes for v0.91a - * - * Rev 1.2 19 Feb 1996 3:21:34 patv - * Added NLS, int2f and config.sys processing - * - * Rev 1.1 01 Sep 1995 17:54:18 patv - * First GPL release. - * - * Rev 1.0 02 Jul 1995 8:32:30 patv - * Initial revision. - */ - #ifdef PROTO BOOL ASMCFUNC ReadPCClock(ULONG *); VOID ASMCFUNC WriteATClock(BYTE *, BYTE, BYTE, BYTE); @@ -267,12 +196,12 @@ WORD FAR ASMCFUNC clk_driver(rqptr rp) clk.clkHundredths = remainder % 100ul; } - fbcopy((BYTE FAR *) & clk, rp->r_trans, min(sizeof(struct ClockRecord),rp->r_count )); + fmemcpy(rp->r_trans, &clk, min(sizeof(struct ClockRecord),rp->r_count )); return S_DONE; case C_OUTPUT: rp->r_count = min(rp->r_count,sizeof(struct ClockRecord)); - fbcopy(rp->r_trans, (BYTE FAR *) & clk, rp->r_count); + fmemcpy(&clk, rp->r_trans, rp->r_count); /* Set PC Clock first */ DaysSinceEpoch = clk.clkDays; @@ -391,3 +320,48 @@ VOID DayToBcd(BYTE * x, UWORD * mon, UWORD * day, UWORD * yr) x[3] = ByteToBcd(*yr / 100); x[2] = ByteToBcd(*yr % 100); } + +/* + * Log: sysclk.c,v - for newer entries do "cvs log sysclk.c" + * + * Revision 1.3 2000/03/09 06:07:11 kernel + * 2017f updates by James Tabor + * + * Revision 1.2 1999/04/12 03:21:17 jprice + * more ror4 patches. Changes for multi-block IO + * + * Revision 1.1.1.1 1999/03/29 15:41:33 jprice + * New version without IPL.SYS + * + * Revision 1.5 1999/02/08 05:55:58 jprice + * Added Pat's 1937 kernel patches + * + * Revision 1.4 1999/02/04 03:14:07 jprice + * Formating. Added comments. + * + * Revision 1.3 1999/02/01 01:48:41 jprice + * Clean up; Now you can use hex numbers in config.sys. added config.sys screen function to change screen mode (28 or 43/50 lines) + * + * Revision 1.2 1999/01/22 04:13:27 jprice + * Formating + * + * Revision 1.1.1.1 1999/01/20 05:51:01 jprice + * Imported sources + * + * + * Rev 1.4 04 Jan 1998 23:15:16 patv + * Changed Log for strip utility + * + * Rev 1.3 29 May 1996 21:03:48 patv + * bug fixes for v0.91a + * + * Rev 1.2 19 Feb 1996 3:21:34 patv + * Added NLS, int2f and config.sys processing + * + * Rev 1.1 01 Sep 1995 17:54:18 patv + * First GPL release. + * + * Rev 1.0 02 Jul 1995 8:32:30 patv + * Initial revision. + */ + diff --git a/kernel/syspack.c b/kernel/syspack.c index 992f682d..41aede48 100644 --- a/kernel/syspack.c +++ b/kernel/syspack.c @@ -34,53 +34,6 @@ static BYTE *syspackRcsId = "$Id$"; #endif -/* - * $Log$ - * Revision 1.5 2001/11/04 19:47:39 bartoldeman - * kernel 2025a changes: see history.txt - * - * Revision 1.4 2001/09/23 20:39:44 bartoldeman - * FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling - * - * Revision 1.3 2000/05/25 20:56:21 jimtabor - * Fixed project history - * - * Revision 1.2 2000/05/08 04:30:00 jimtabor - * Update CVS to 2020 - * - * Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 - * The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with - * MS-DOS. Distributed under the GNU GPL. - * - * Revision 1.1.1.1 1999/03/29 15:42:21 jprice - * New version without IPL.SYS - * - * Revision 1.3 1999/02/01 01:43:28 jprice - * Fixed findfirst function to find volume label with Windows long filenames - * - * Revision 1.2 1999/01/22 04:15:28 jprice - * Formating - * - * Revision 1.1.1.1 1999/01/20 05:51:00 jprice - * Imported sources - * - * - * Rev 1.4 04 Jan 1998 23:14:38 patv - * Changed Log for strip utility - * - * Rev 1.3 29 May 1996 21:15:12 patv - * bug fixes for v0.91a - * - * Rev 1.2 01 Sep 1995 17:48:42 patv - * First GPL release. - * - * Rev 1.1 30 Jul 1995 20:50:26 patv - * Eliminated version strings in ipl - * - * Rev 1.0 02 Jul 1995 8:05:34 patv - * Initial revision. - */ - #ifdef NONNATIVE VOID getlong(REG VOID * vp, LONG * lp) { @@ -143,8 +96,8 @@ VOID fputbyte(BYTE FAR * bp, VOID FAR * vp) VOID getdirent(BYTE FAR * vp, struct dirent FAR * dp) { - fbcopy(&vp[DIR_NAME], dp->dir_name, FNAME_SIZE); - fbcopy(&vp[DIR_EXT], dp->dir_ext, FEXT_SIZE); + fmemcpy(dp->dir_name, &vp[DIR_NAME], FNAME_SIZE); + fmemcpy(dp->dir_ext, &vp[DIR_EXT], FEXT_SIZE); fgetbyte(&vp[DIR_ATTRIB], (BYTE FAR *) & dp->dir_attrib); fgetword(&vp[DIR_TIME], (WORD FAR *) & dp->dir_time); fgetword(&vp[DIR_DATE], (WORD FAR *) & dp->dir_date); @@ -157,8 +110,8 @@ VOID putdirent(struct dirent FAR * dp, BYTE FAR * vp) REG COUNT i; REG BYTE FAR *p; - fbcopy(dp->dir_name, &vp[DIR_NAME], FNAME_SIZE); - fbcopy(dp->dir_ext, &vp[DIR_EXT], FEXT_SIZE); + fmemcpy(&vp[DIR_NAME], dp->dir_name, FNAME_SIZE); + fmemcpy(&vp[DIR_EXT], dp->dir_ext, FEXT_SIZE); fputbyte((BYTE FAR *) & dp->dir_attrib, &vp[DIR_ATTRIB]); fputword((WORD FAR *) & dp->dir_time, &vp[DIR_TIME]); fputword((WORD FAR *) & dp->dir_date, &vp[DIR_DATE]); @@ -168,3 +121,35 @@ VOID putdirent(struct dirent FAR * dp, BYTE FAR * vp) *p++ = NULL; } #endif + +/* + * Log: syspack.c,v - for newer entries see "cvs log syspack.c" + * + * Revision 1.1.1.1 1999/03/29 15:42:21 jprice + * New version without IPL.SYS + * + * Revision 1.3 1999/02/01 01:43:28 jprice + * Fixed findfirst function to find volume label with Windows long filenames + * + * Revision 1.2 1999/01/22 04:15:28 jprice + * Formating + * + * Revision 1.1.1.1 1999/01/20 05:51:00 jprice + * Imported sources + * + * + * Rev 1.4 04 Jan 1998 23:14:38 patv + * Changed Log for strip utility + * + * Rev 1.3 29 May 1996 21:15:12 patv + * bug fixes for v0.91a + * + * Rev 1.2 01 Sep 1995 17:48:42 patv + * First GPL release. + * + * Rev 1.1 30 Jul 1995 20:50:26 patv + * Eliminated version strings in ipl + * + * Rev 1.0 02 Jul 1995 8:05:34 patv + * Initial revision. + */ diff --git a/kernel/systime.c b/kernel/systime.c index 4599c0ca..dd96ab92 100644 --- a/kernel/systime.c +++ b/kernel/systime.c @@ -35,78 +35,6 @@ static BYTE *RcsId = "$Id$"; #endif -/* - * $Log$ - * Revision 1.7 2001/11/04 19:47:39 bartoldeman - * kernel 2025a changes: see history.txt - * - * Revision 1.6 2001/08/19 12:58:36 bartoldeman - * Time and date fixes, Ctrl-S/P, findfirst/next, FCBs, buffers, tsr unloading - * - * Revision 1.5 2001/04/15 03:21:50 bartoldeman - * See history.txt for the list of fixes. - * - * Revision 1.4 2001/03/21 02:56:26 bartoldeman - * See history.txt for changes. Bug fixes and HMA support are the main ones. - * - * Revision 1.3 2000/05/25 20:56:21 jimtabor - * Fixed project history - * - * Revision 1.2 2000/05/08 04:30:00 jimtabor - * Update CVS to 2020 - * - * Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 - * The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with - * MS-DOS. Distributed under the GNU GPL. - * - * Revision 1.3 1999/05/04 16:40:30 jprice - * ror4 date fix - * - * Revision 1.2 1999/04/12 03:21:18 jprice - * more ror4 patches. Changes for multi-block IO - * - * Revision 1.1.1.1 1999/03/29 15:41:34 jprice - * New version without IPL.SYS - * - * Revision 1.5 1999/02/08 05:55:58 jprice - * Added Pat's 1937 kernel patches - * - * Revision 1.4 1999/02/04 03:14:07 jprice - * Formating. Added comments. - * - * Revision 1.3 1999/02/01 01:48:41 jprice - * Clean up; Now you can use hex numbers in config.sys. added config.sys screen function to change screen mode (28 or 43/50 lines) - * - * Revision 1.2 1999/01/22 04:13:27 jprice - * Formating - * - * Revision 1.1.1.1 1999/01/20 05:51:01 jprice - * Imported sources - * - * - * Rev 1.6 06 Dec 1998 8:47:30 patv - * Bug fixes. - * - * Rev 1.5 04 Jan 1998 23:15:22 patv - * Changed Log for strip utility - * - * Rev 1.4 03 Jan 1998 8:36:50 patv - * Converted data area to SDA format - * - * Rev 1.3 29 May 1996 21:03:40 patv - * bug fixes for v0.91a - * - * Rev 1.2 19 Feb 1996 3:21:34 patv - * Added NLS, int2f and config.sys processing - * - * Rev 1.1 01 Sep 1995 17:54:16 patv - * First GPL release. - * - * Rev 1.0 02 Jul 1995 8:32:20 patv - * Initial revision. - */ - - UWORD days[2][13] = { {0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365}, @@ -263,3 +191,53 @@ UWORD Month, return char_error(&ClkReqHdr, (struct dhdr FAR *)clock); return SUCCESS; } + +/* + * Log: systime.c,v - see "cvs log systime.c" for newer entries + * + * Revision 1.3 1999/05/04 16:40:30 jprice + * ror4 date fix + * + * Revision 1.2 1999/04/12 03:21:18 jprice + * more ror4 patches. Changes for multi-block IO + * + * Revision 1.1.1.1 1999/03/29 15:41:34 jprice + * New version without IPL.SYS + * + * Revision 1.5 1999/02/08 05:55:58 jprice + * Added Pat's 1937 kernel patches + * + * Revision 1.4 1999/02/04 03:14:07 jprice + * Formating. Added comments. + * + * Revision 1.3 1999/02/01 01:48:41 jprice + * Clean up; Now you can use hex numbers in config.sys. added config.sys screen function to change screen mode (28 or 43/50 lines) + * + * Revision 1.2 1999/01/22 04:13:27 jprice + * Formating + * + * Revision 1.1.1.1 1999/01/20 05:51:01 jprice + * Imported sources + * + * + * Rev 1.6 06 Dec 1998 8:47:30 patv + * Bug fixes. + * + * Rev 1.5 04 Jan 1998 23:15:22 patv + * Changed Log for strip utility + * + * Rev 1.4 03 Jan 1998 8:36:50 patv + * Converted data area to SDA format + * + * Rev 1.3 29 May 1996 21:03:40 patv + * bug fixes for v0.91a + * + * Rev 1.2 19 Feb 1996 3:21:34 patv + * Added NLS, int2f and config.sys processing + * + * Rev 1.1 01 Sep 1995 17:54:16 patv + * First GPL release. + * + * Rev 1.0 02 Jul 1995 8:32:20 patv + * Initial revision. + */ diff --git a/kernel/task.c b/kernel/task.c index 4c7b76ab..45ffaa75 100644 --- a/kernel/task.c +++ b/kernel/task.c @@ -33,151 +33,6 @@ static BYTE *RcsId = "$Id$"; #endif -/* - * $Log$ - * Revision 1.19 2001/11/04 19:47:39 bartoldeman - * kernel 2025a changes: see history.txt - * - * Revision 1.18 2001/09/23 20:39:44 bartoldeman - * FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling - * - * Revision 1.17 2001/08/19 12:58:36 bartoldeman - * Time and date fixes, Ctrl-S/P, findfirst/next, FCBs, buffers, tsr unloading - * - * Revision 1.16 2001/07/23 12:47:42 bartoldeman - * FCB fixes and clean-ups, exec int21/ax=4b01, initdisk.c printf - * - * Revision 1.15 2001/07/22 01:58:58 bartoldeman - * Support for Brian's FORMAT, DJGPP libc compilation, cleanups, MSCDEX - * - * Revision 1.14 2001/06/03 14:16:18 bartoldeman - * BUFFERS tuning and misc bug fixes/cleanups (2024c). - * - * Revision 1.13 2001/04/21 22:32:53 bartoldeman - * Init DS=Init CS, fixed stack overflow problems and misc bugs. - * - * Revision 1.12 2001/04/16 14:28:32 bartoldeman - * Kernel build 2024. Fixed critical error handler/config.sys/makefiles/UMBs - * - * Revision 1.11 2001/04/16 01:45:26 bartoldeman - * Fixed handles, config.sys drivers, warnings. Enabled INT21/AH=6C, printf %S/%Fs - * - * Revision 1.10 2001/04/15 03:21:50 bartoldeman - * See history.txt for the list of fixes. - * - * Revision 1.9 2001/03/31 20:54:52 bartoldeman - * Made SHELLHIGH behave more like LOADHIGH. - * - * Revision 1.8 2001/03/30 19:30:06 bartoldeman - * Misc fixes and implementation of SHELLHIGH. See history.txt for details. - * - * Revision 1.7 2001/03/21 02:56:26 bartoldeman - * See history.txt for changes. Bug fixes and HMA support are the main ones. - * - * Revision 1.6 2001/03/08 21:00:00 bartoldeman - * UMB fixes to DosComLoader - * - * Revision 1.5 2000/08/06 05:50:17 jimtabor - * Add new files and update cvs with patches and changes - * - * Revision 1.4 2000/05/26 19:25:19 jimtabor - * Read History file for Change info - * - * Revision 1.3 2000/05/25 20:56:21 jimtabor - * Fixed project history - * - * Revision 1.2 2000/05/08 04:30:00 jimtabor - * Update CVS to 2020 - * - * Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 - * The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with - * MS-DOS. Distributed under the GNU GPL. - * - * Revision 1.8 2000/03/31 05:40:09 jtabor - * Added Eric W. Biederman Patches - * - * Revision 1.7 2000/03/09 06:07:11 kernel - * 2017f updates by James Tabor - * - * Revision 1.6 1999/08/25 03:18:10 jprice - * ror4 patches to allow TC 2.01 compile. - * - * Revision 1.5 1999/04/23 04:24:39 jprice - * Memory manager changes made by ska - * - * Revision 1.4 1999/04/16 00:53:33 jprice - * Optimized FAT handling - * - * Revision 1.3 1999/04/11 04:33:39 jprice - * ror4 patches - * - * Revision 1.2 1999/03/29 17:05:09 jprice - * ror4 changes - * - * Revision 1.1.1.1 1999/03/29 15:41:41 jprice - * New version without IPL.SYS - * - * Revision 1.5 1999/02/08 05:55:58 jprice - * Added Pat's 1937 kernel patches - * - * Revision 1.4 1999/02/04 03:14:07 jprice - * Formating. Added comments. - * - * Revision 1.3 1999/02/01 01:48:41 jprice - * Clean up; Now you can use hex numbers in config.sys. added config.sys screen function to change screen mode (28 or 43/50 lines) - * - * Revision 1.2 1999/01/22 04:13:27 jprice - * Formating - * - * Revision 1.1.1.1 1999/01/20 05:51:01 jprice - * Imported sources - * - * - * Rev 1.15 06 Dec 1998 8:46:28 patv - * Bug fixes. - * - * Rev 1.14 07 Feb 1998 20:38:32 patv - * Modified stack fram to match DOS standard - * - * Rev 1.13 31 Jan 1998 14:39:20 patv - * Corrected type in load high code. - * - * Rev 1.12 31 Jan 1998 14:02:52 patv - * Added load high in memory option in DosExeLoader. - * - * Rev 1.11 22 Jan 1998 22:17:14 patv - * Eliminated warnings. - * - * Rev 1.10 22 Jan 1998 21:31:36 patv - * Corrected short .COM problem. - * - * Rev 1.9 04 Jan 1998 23:15:16 patv - * Changed Log for strip utility - * - * Rev 1.8 22 Jan 1997 13:18:14 patv - * pre-0.92 Svante Frey bug fixes. - * - * Rev 1.7 16 Jan 1997 12:46:56 patv - * pre-Release 0.92 feature additions - * - * Rev 1.5 29 Aug 1996 13:07:22 patv - * Bug fixes for v0.91b - * - * Rev 1.4 29 May 1996 21:03:36 patv - * bug fixes for v0.91a - * - * Rev 1.3 19 Feb 1996 3:21:48 patv - * Added NLS, int2f and config.sys processing - * - * Rev 1.2 01 Sep 1995 17:54:22 patv - * First GPL release. - * - * Rev 1.1 30 Jul 1995 20:51:58 patv - * Eliminated version strings in ipl - * - * Rev 1.0 02 Jul 1995 8:34:06 patv - * Initial revision. - */ #define toupper(c) ((c) >= 'a' && (c) <= 'z' ? (c) + ('A' - 'a') : (c)) #define LOADNGO 0 @@ -291,14 +146,15 @@ COUNT ChildEnv(exec_blk FAR * exp, UWORD * pChildEnvSeg, char far * pathname) /* copy the environment */ if (pSrc) { - fbcopy(pSrc, pDest, nEnvSize); + fmemcpy(pDest, pSrc, nEnvSize); pDest += nEnvSize; } else *pDest++ = '\0'; /* create an empty environment */ /* initialize 'extra strings' count */ - *((UWORD FAR *) pDest)++ = 1; + *((UWORD FAR *) pDest) = 1; + pDest += sizeof(UWORD); /* copy complete pathname */ if ((RetCode = truename(pathname, pDest, TRUE)) != SUCCESS) { @@ -407,9 +263,9 @@ STATIC UWORD patchPSP(UWORD pspseg, UWORD envseg, exec_blk FAR *exb, psp = MK_FP(pspseg, 0); /* complete the psp by adding the command line and FCBs */ - fbcopy(exb->exec.cmd_line->ctBuffer, psp->ps_cmd, 127); - fbcopy(exb->exec.fcb_1, &psp->ps_fcb1, 16); - fbcopy(exb->exec.fcb_2, &psp->ps_fcb2, 16); + fmemcpy(psp->ps_cmd, exb->exec.cmd_line->ctBuffer, 127); + fmemcpy(&psp->ps_fcb1, exb->exec.fcb_1, 16); + fmemcpy(&psp->ps_fcb2, exb->exec.fcb_2, 16); psp->ps_cmd_count = exb->exec.cmd_line->ctCount; /* identify the mcb as this functions' */ @@ -557,8 +413,8 @@ COUNT DosComLoader(BYTE FAR * namep, exec_blk FAR * exp, COUNT mode) /* BUG !! in case of LH, memory may be smaller then 64K TE*/ - if ((ULONG)com_size > ((ULONG)asize << 4)) /* less memory than the .COM file has */ - (ULONG)com_size = (ULONG)asize << 4; + if (com_size > ((LONG)asize << 4)) /* less memory than the .COM file has */ + com_size = (LONG)asize << 4; } do { @@ -1051,4 +907,92 @@ COUNT DosExec(COUNT mode, exec_blk FAR * ep, BYTE FAR * lp) return rc; } +/* + * Log: task.c,v - for newer log entries do "cvs log task.c" + * + * Revision 1.8 2000/03/31 05:40:09 jtabor + * Added Eric W. Biederman Patches + * + * Revision 1.7 2000/03/09 06:07:11 kernel + * 2017f updates by James Tabor + * + * Revision 1.6 1999/08/25 03:18:10 jprice + * ror4 patches to allow TC 2.01 compile. + * + * Revision 1.5 1999/04/23 04:24:39 jprice + * Memory manager changes made by ska + * + * Revision 1.4 1999/04/16 00:53:33 jprice + * Optimized FAT handling + * + * Revision 1.3 1999/04/11 04:33:39 jprice + * ror4 patches + * + * Revision 1.2 1999/03/29 17:05:09 jprice + * ror4 changes + * + * Revision 1.1.1.1 1999/03/29 15:41:41 jprice + * New version without IPL.SYS + * + * Revision 1.5 1999/02/08 05:55:58 jprice + * Added Pat's 1937 kernel patches + * + * Revision 1.4 1999/02/04 03:14:07 jprice + * Formating. Added comments. + * + * Revision 1.3 1999/02/01 01:48:41 jprice + * Clean up; Now you can use hex numbers in config.sys. added config.sys screen function to change screen mode (28 or 43/50 lines) + * + * Revision 1.2 1999/01/22 04:13:27 jprice + * Formating + * + * Revision 1.1.1.1 1999/01/20 05:51:01 jprice + * Imported sources + * + * + * Rev 1.15 06 Dec 1998 8:46:28 patv + * Bug fixes. + * + * Rev 1.14 07 Feb 1998 20:38:32 patv + * Modified stack fram to match DOS standard + * + * Rev 1.13 31 Jan 1998 14:39:20 patv + * Corrected type in load high code. + * + * Rev 1.12 31 Jan 1998 14:02:52 patv + * Added load high in memory option in DosExeLoader. + * + * Rev 1.11 22 Jan 1998 22:17:14 patv + * Eliminated warnings. + * + * Rev 1.10 22 Jan 1998 21:31:36 patv + * Corrected short .COM problem. + * + * Rev 1.9 04 Jan 1998 23:15:16 patv + * Changed Log for strip utility + * + * Rev 1.8 22 Jan 1997 13:18:14 patv + * pre-0.92 Svante Frey bug fixes. + * + * Rev 1.7 16 Jan 1997 12:46:56 patv + * pre-Release 0.92 feature additions + * + * Rev 1.5 29 Aug 1996 13:07:22 patv + * Bug fixes for v0.91b + * + * Rev 1.4 29 May 1996 21:03:36 patv + * bug fixes for v0.91a + * + * Rev 1.3 19 Feb 1996 3:21:48 patv + * Added NLS, int2f and config.sys processing + * + * Rev 1.2 01 Sep 1995 17:54:22 patv + * First GPL release. + * + * Rev 1.1 30 Jul 1995 20:51:58 patv + * Eliminated version strings in ipl + * + * Rev 1.0 02 Jul 1995 8:34:06 patv + * Initial revision. + */ diff --git a/lib/makefile b/lib/makefile index 012d12c3..0abc5315 100644 --- a/lib/makefile +++ b/lib/makefile @@ -4,44 +4,6 @@ # $Id$ # -# $Log$ -# Revision 1.2 2001/11/13 23:36:45 bartoldeman -# Kernel 2025a final changes. -# -# Revision 1.1 2001/11/04 20:10:15 bartoldeman -# Added new makefile names, utils sources, kconfig.h -# -# Revision 1.5 2001/06/03 14:16:18 bartoldeman -# BUFFERS tuning and misc bug fixes/cleanups (2024c). -# -# Revision 1.4 2001/03/19 04:50:56 bartoldeman -# See history.txt for overview: put kernel 2022beo1 into CVS -# -# Revision 1.4 2001/03/08 21:15:00 bartoldeman -# Fix from Martin Stromberg to make this fully configurable from config.mak -# -# Revision 1.3 2000/05/25 20:56:22 jimtabor -# Fixed project history -# -# Revision 1.2 2000/05/11 03:57:10 jimtabor -# Clean up and Release -# -# Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 -# The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with -# MS-DOS. Distributed under the GNU GPL. -# -# Revision 1.6 1999/09/14 17:32:20 jprice -# no message -# -# Revision 1.5 1999/09/13 20:13:15 jprice -# Added !if so we can use TC2 or TC3 to compile. -# -# Revision 1.4 1999/08/25 03:19:22 jprice -# ror4 patches to allow TC 2.01 compile. -# -# Revision 1.3 1999/04/23 03:45:18 jprice -# Improved by jprice -# !include "..\mkfiles\generic.mak" @@ -58,3 +20,18 @@ clobber: clean clean: -$(RM) *.obj *.bak + +# Log: makefile,v +# +# Revision 1.6 1999/09/14 17:32:20 jprice +# no message +# +# Revision 1.5 1999/09/13 20:13:15 jprice +# Added !if so we can use TC2 or TC3 to compile. +# +# Revision 1.4 1999/08/25 03:19:22 jprice +# ror4 patches to allow TC 2.01 compile. +# +# Revision 1.3 1999/04/23 03:45:18 jprice +# Improved by jprice +# diff --git a/mkfiles/mscl8.mak b/mkfiles/mscl8.mak index 756d1b25..b606102c 100644 --- a/mkfiles/mscl8.mak +++ b/mkfiles/mscl8.mak @@ -38,7 +38,8 @@ TARGET=KMS # heavy stuff - building -ALLCFLAGS=-I..\hdr $(TARGETOPT) $(ALLCFLAGS) -nologo -Zl -Fc -Zp1 -Gs -Os -WX +ALLCFLAGS=-I..\hdr $(TARGETOPT) $(ALLCFLAGS) -nologo -Zl -Fc -Zp1 -WX -Gr -f- -Os -Gs -Ob1 -OV4 -Gy -Oe + INITCFLAGS=$(ALLCFLAGS) -NTINIT_TEXT -AT CFLAGS=$(ALLCFLAGS) -NTHMA_TEXT DYNCFLAGS=$(ALLCFLAGS) -NTHMA_TEXT diff --git a/mkfiles/watcom.mak b/mkfiles/watcom.mak index ac61955b..4cf2d292 100644 --- a/mkfiles/watcom.mak +++ b/mkfiles/watcom.mak @@ -21,7 +21,7 @@ LIBUTIL=$(COMPILERBIN)\wlib LIBPLUS= LIBTERM= -CFLAGST=-mt +CFLAGST=-zp=1 -mt CFLAGSC=-zp=1 -mc TARGET=KWC @@ -69,7 +69,7 @@ MATH_INSERT= +i4d +i4m # -3 optimization for 386 - given in CONFIG.MAK, not here # -ALLCFLAGS=-I..\hdr $(TARGETOPT) $(ALLCFLAGS) -zq -os -ms -s -e=5 -j -zl -zp=1 +ALLCFLAGS=-I..\hdr $(TARGETOPT) $(ALLCFLAGS) -zq -os -ms -s -e=5 -j -zl -zp=1 -we INITCFLAGS=$(ALLCFLAGS) -nt=INIT_TEXT -nc=INIT -g=IGROUP CFLAGS=$(ALLCFLAGS) -nt=HMA_TEXT -nc=HMA -g=HGROUP DYNCFLAGS=$(ALLCFLAGS) diff --git a/sys/makefile b/sys/makefile index ffeafd6d..08ba3304 100644 --- a/sys/makefile +++ b/sys/makefile @@ -3,35 +3,6 @@ # # $Id$ # -# $Log$ -# Revision 1.2 2001/11/13 23:36:45 bartoldeman -# Kernel 2025a final changes. -# -# Revision 1.1 2001/11/04 20:10:15 bartoldeman -# Added new makefile names, utils sources, kconfig.h -# -# Revision 1.3 2000/05/25 20:56:23 jimtabor -# Fixed project history -# -# Revision 1.2 2000/05/15 05:28:09 jimtabor -# Cleanup CRs -# -# Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 -# The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with -# MS-DOS. Distributed under the GNU GPL. -# -# Revision 1.6 1999/09/20 18:34:40 jprice -# *** empty log message *** -# -# Revision 1.5 1999/08/25 03:19:51 jprice -# ror4 patches to allow TC 2.01 compile. -# -# Revision 1.4 1999/05/03 05:01:38 jprice -# no message -# -# Revision 1.3 1999/04/23 03:45:33 jprice -# Improved by jprice -# !include "..\mkfiles\generic.mak" @@ -86,3 +57,18 @@ bin2c.obj: bin2c.c sys.obj: sys.c ..\hdr\portab.h ..\hdr\device.h b_fat12.h b_fat16.h b_fat32.h $(CC) $(CFLAGS) -c $*.c + +# Log: makefile,v +# +# Revision 1.6 1999/09/20 18:34:40 jprice +# *** empty log message *** +# +# Revision 1.5 1999/08/25 03:19:51 jprice +# ror4 patches to allow TC 2.01 compile. +# +# Revision 1.4 1999/05/03 05:01:38 jprice +# no message +# +# Revision 1.3 1999/04/23 03:45:33 jprice +# Improved by jprice +# diff --git a/sys/sys.c b/sys/sys.c index 354f957e..53929044 100644 --- a/sys/sys.c +++ b/sys/sys.c @@ -25,121 +25,6 @@ 675 Mass Ave, Cambridge, MA 02139, USA. ***************************************************************/ -/* $Log$ - * Revision 1.12 2001/11/13 23:36:45 bartoldeman - * Kernel 2025a final changes. - * -/* Revision 1.11 2001/11/04 19:47:39 bartoldeman -/* kernel 2025a changes: see history.txt -/* -/* Revision 1.10 2001/09/24 02:28:14 bartoldeman -/* Minor printf fixes. -/* -/* Revision 1.9 2001/09/24 02:21:14 bartoldeman -/* SYS and printer fixes -/* -/* Revision 1.8 2001/09/23 20:39:44 bartoldeman -/* FAT32 support, misc fixes, INT2F/AH=12 support, drive B: handling -/* - -/* version 2.2 jeremyd 2001/9/20 - Changed so if no source given or only source drive (no path) - given, then checks for kernel.sys & command.com in current - path (of current drive or given drive) and if not there - uses root (but only if source & destination drive are different). - Fix printf to include count(ret) if copy can't write all requested bytes -*/ -/* version 2.1a jeremyd 2001/8/19 - modified so takes optional 2nd parameter (similar to PC DOS) - where if only 1 argument is given, assume to be destination drive, - but if two arguments given, 1st is source (drive and/or path) - and second is destination drive -*/ - -/* Revision 1.7 2001/07/09 22:19:33 bartoldeman -/* LBA/FCB/FAT/SYS/Ctrl-C/ioctl fixes + memory savings -/* -/* Revision 2.1 tomehlert 2001/4/26 - - changed the file system detection code. - - -*/ - -/* Revision 2.0 tomehlert 2001/4/26 - - no direct access to the disk any more, this is FORMAT's job - no floppy.asm anymore, no segmentation problems. - no access to partition tables - - instead copy boot sector using int25/int26 = absdiskread()/write - - if xxDOS is able to handle the disk, SYS should work - - additionally some space savers: - - replaced fopen() by open() - - included (slighly modified) PRF.c from kernel - - size is no ~7500 byte vs. ~13690 before - -*/ -/* Revision 1.6 2001/04/29 17:34:41 bartoldeman -/* A new SYS.COM/config.sys single stepping/console output/misc fixes. -/* -/* Revision 1.5 2001/03/25 17:11:54 bartoldeman -/* Fixed sys.com compilation. Updated to 2023. Also: see history.txt. -/* -/* Revision 1.4 2000/08/06 05:50:17 jimtabor -/* Add new files and update cvs with patches and changes -/* - * Revision 1.3 2000/05/25 20:56:23 jimtabor - * Fixed project history - * - * Revision 1.2 2000/05/15 05:28:09 jimtabor - * Cleanup CRs - * - * Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 - * The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with - * MS-DOS. Distributed under the GNU GPL. - * - * Revision 1.10 2000/03/31 06:59:10 jprice - * Added discription of program. - * - * Revision 1.9 1999/09/20 18:34:40 jprice - * *** empty log message *** - * - * Revision 1.8 1999/09/20 18:27:19 jprice - * Changed open/creat to fopen to make TC2 happy. - * - * Revision 1.7 1999/09/15 05:39:02 jprice - * Changed boot sector writing code so easier to read. - * - * Revision 1.6 1999/09/14 17:30:44 jprice - * Added debug log creation to sys.com. - * - * Revision 1.5 1999/08/25 03:19:51 jprice - * ror4 patches to allow TC 2.01 compile. - * - * Revision 1.4 1999/04/17 19:14:44 jprice - * Fixed multi-sector code - * - * Revision 1.3 1999/04/01 07:24:05 jprice - * SYS modified for new boot loader - * - * Revision 1.2 1999/03/29 16:24:48 jprice - * Fixed error message - * - * Revision 1.1.1.1 1999/03/29 15:43:15 jprice - * New version without IPL.SYS - * Revision 1.3 1999/01/21 04:35:21 jprice Fixed comments. - * Added indent program - * - * Revision 1.2 1999/01/21 04:13:52 jprice Added messages to sys. Also made - * it create a .COM file. - * - */ /* TE thinks, that the boot info storage should be done by FORMAT, noone else @@ -793,4 +678,81 @@ BOOL copy(COUNT drive, BYTE * srcPath, BYTE * rootPath, BYTE * file) return TRUE; } +/* Log: sys.c,v see "cvs log sys.c" for newer entries. + +/* version 2.2 jeremyd 2001/9/20 + Changed so if no source given or only source drive (no path) + given, then checks for kernel.sys & command.com in current + path (of current drive or given drive) and if not there + uses root (but only if source & destination drive are different). + Fix printf to include count(ret) if copy can't write all requested bytes +*/ +/* version 2.1a jeremyd 2001/8/19 + modified so takes optional 2nd parameter (similar to PC DOS) + where if only 1 argument is given, assume to be destination drive, + but if two arguments given, 1st is source (drive and/or path) + and second is destination drive +*/ + +/* Revision 2.1 tomehlert 2001/4/26 + + changed the file system detection code. + + +*/ + +/* Revision 2.0 tomehlert 2001/4/26 + + no direct access to the disk any more, this is FORMAT's job + no floppy.asm anymore, no segmentation problems. + no access to partition tables + + instead copy boot sector using int25/int26 = absdiskread()/write + + if xxDOS is able to handle the disk, SYS should work + + additionally some space savers: + + replaced fopen() by open() + + included (slighly modified) PRF.c from kernel + + size is no ~7500 byte vs. ~13690 before + + * Revision 1.10 2000/03/31 06:59:10 jprice + * Added discription of program. + * + * Revision 1.9 1999/09/20 18:34:40 jprice + * *** empty log message *** + * + * Revision 1.8 1999/09/20 18:27:19 jprice + * Changed open/creat to fopen to make TC2 happy. + * + * Revision 1.7 1999/09/15 05:39:02 jprice + * Changed boot sector writing code so easier to read. + * + * Revision 1.6 1999/09/14 17:30:44 jprice + * Added debug log creation to sys.com. + * + * Revision 1.5 1999/08/25 03:19:51 jprice + * ror4 patches to allow TC 2.01 compile. + * + * Revision 1.4 1999/04/17 19:14:44 jprice + * Fixed multi-sector code + * + * Revision 1.3 1999/04/01 07:24:05 jprice + * SYS modified for new boot loader + * + * Revision 1.2 1999/03/29 16:24:48 jprice + * Fixed error message + * + * Revision 1.1.1.1 1999/03/29 15:43:15 jprice + * New version without IPL.SYS + * Revision 1.3 1999/01/21 04:35:21 jprice Fixed comments. + * Added indent program + * + * Revision 1.2 1999/01/21 04:13:52 jprice Added messages to sys. Also made + * it create a .COM file. + * + */ From 684a2cb93d37a1cbda507233f5579cb3a40ab1e6 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sun, 18 Nov 2001 12:46:48 +0000 Subject: [PATCH 110/671] Fixed warning fixes for printf - did it the wrong way before. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@328 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/prf.c | 24 +++++++++++++++--------- kernel/task.c | 2 +- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/kernel/prf.c b/kernel/prf.c index cf759317..499f1ef8 100644 --- a/kernel/prf.c +++ b/kernel/prf.c @@ -281,16 +281,15 @@ COUNT UWORD w[2]; static char pointerFormat[] = "%04x:%04x"; w[1] = *((UWORD *) arg); - arg += sizeof(UWORD); + arg += sizeof(UWORD)/sizeof(BYTE *); w[0] = *((UWORD *) arg); - arg += sizeof(UWORD); + arg += sizeof(UWORD)/sizeof(BYTE *); do_printf(pointerFormat,(BYTE**)&w); continue; } case 's': - p = *((BYTE **) arg); - arg += sizeof(BYTE *); + p = *arg++; goto do_outputstring; case 'F': @@ -298,7 +297,7 @@ COUNT /* we assume %Fs here */ case 'S': p = *((BYTE FAR **) arg); - arg += sizeof(BYTE FAR *); + arg += sizeof(BYTE FAR *)/sizeof(BYTE *); goto do_outputstring; case 'i': @@ -322,13 +321,20 @@ COUNT if (longarg) { currentArg = *((LONG *) arg); - arg += sizeof(LONG); + arg += sizeof(LONG)/sizeof(BYTE *); } else { - if (base < 0) currentArg = *((int*) arg); - else currentArg = *((unsigned int*) arg); - arg += sizeof(int); + if (base < 0) + { + currentArg = *((int*) arg); + arg += sizeof(int)/sizeof(BYTE *); + } + else + { + currentArg = *((unsigned int*) arg); + arg += sizeof(unsigned int)/sizeof(BYTE *); + } } ltob(currentArg, s, base); diff --git a/kernel/task.c b/kernel/task.c index 45ffaa75..214e5ef9 100644 --- a/kernel/task.c +++ b/kernel/task.c @@ -154,7 +154,7 @@ COUNT ChildEnv(exec_blk FAR * exp, UWORD * pChildEnvSeg, char far * pathname) /* initialize 'extra strings' count */ *((UWORD FAR *) pDest) = 1; - pDest += sizeof(UWORD); + pDest += sizeof(UWORD)/sizeof(BYTE); /* copy complete pathname */ if ((RetCode = truename(pathname, pDest, TRUE)) != SUCCESS) { From b6d423a1b3ab80703f2ae03e30fe039c59477e9a Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sun, 18 Nov 2001 14:01:12 +0000 Subject: [PATCH 111/671] Ran all .c and .h files through "indent" git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@329 6ac86273-5f31-0410-b378-82cca8765d1b --- hdr/algnbyte.h | 16 +- hdr/buffer.h | 19 +- hdr/cds.h | 27 +- hdr/clock.h | 7 +- hdr/date.h | 3 +- hdr/dcb.h | 44 +- hdr/device.h | 266 ++++---- hdr/dirmatch.h | 22 +- hdr/dosnames.h | 9 +- hdr/error.h | 6 +- hdr/exe.h | 10 +- hdr/fat.h | 23 +- hdr/fcb.h | 22 +- hdr/file.h | 4 +- hdr/fnode.h | 24 +- hdr/kbd.h | 10 +- hdr/kconfig.h | 22 +- hdr/mcb.h | 9 +- hdr/network.h | 20 +- hdr/nls.h | 238 ++++--- hdr/pcb.h | 49 +- hdr/portab.h | 91 ++- hdr/process.h | 80 +-- hdr/sft.h | 47 +- hdr/tail.h | 10 +- hdr/time.h | 4 +- hdr/version.h | 7 +- hdr/xstructs.h | 80 ++- kernel/blockio.c | 295 ++++----- kernel/break.c | 6 +- kernel/chario.c | 85 +-- kernel/config.c | 1175 ++++++++++++++++----------------- kernel/config.h | 7 +- kernel/dosfns.c | 1365 ++++++++++++++++++++------------------ kernel/dosnames.c | 120 ++-- kernel/dsk.c | 1156 ++++++++++++++++---------------- kernel/dyndata.c | 4 +- kernel/dyndata.h | 6 +- kernel/dyninit.c | 69 +- kernel/error.c | 32 +- kernel/fatdir.c | 227 +++---- kernel/fatfs.c | 818 ++++++++++++----------- kernel/fattab.c | 190 +++--- kernel/fcbfns.c | 148 +++-- kernel/globals.h | 198 +++--- kernel/init-dat.h | 32 +- kernel/init-mod.h | 112 ++-- kernel/initdisk.c | 1596 ++++++++++++++++++++++----------------------- kernel/inithma.c | 658 +++++++++---------- kernel/initoem.c | 6 +- kernel/inthndlr.c | 1308 +++++++++++++++++++------------------ kernel/intr.h | 4 +- kernel/ioctl.c | 173 +++-- kernel/lfnapi.c | 227 ++++--- kernel/main.c | 335 +++++----- kernel/memmgr.c | 242 ++++--- kernel/misc.c | 4 +- kernel/network.c | 4 +- kernel/newstuff.c | 471 +++++++------ kernel/nls.c | 646 +++++++++--------- kernel/nls_load.c | 477 +++++++------- kernel/prf.c | 468 ++++++------- kernel/proto.h | 152 +++-- kernel/strings.c | 4 +- kernel/sysclk.c | 106 ++- kernel/syspack.c | 6 +- kernel/systime.c | 78 +-- kernel/task.c | 693 ++++++++++---------- sys/bin2c.c | 3 +- sys/fdkrncfg.c | 393 ++++++----- sys/sys.c | 501 +++++++------- utils/patchobj.c | 340 +++++----- utils/relocinf.c | 219 ++++--- 73 files changed, 8094 insertions(+), 8234 deletions(-) diff --git a/hdr/algnbyte.h b/hdr/algnbyte.h index 55d1c3df..4040b415 100644 --- a/hdr/algnbyte.h +++ b/hdr/algnbyte.h @@ -1,14 +1,14 @@ #if defined(_MSC_VER) - #define asm __asm - #if _MSC_VER >= 700 - #pragma warning(disable:4103) - #endif - #pragma pack(1) +#define asm __asm +#if _MSC_VER >= 700 +#pragma warning(disable:4103) +#endif +#pragma pack(1) #elif defined(_QC) || defined(__WATCOM__) - #pragma pack(1) +#pragma pack(1) #elif defined(__ZTC__) - #pragma ZTC align 1 +#pragma ZTC align 1 #elif defined(__TURBOC__) && (__TURBOC__ > 0x202) - #pragma option -a- +#pragma option -a- #endif diff --git a/hdr/buffer.h b/hdr/buffer.h index 20cc7d28..36c1ebe6 100644 --- a/hdr/buffer.h +++ b/hdr/buffer.h @@ -32,14 +32,14 @@ #ifdef MAIN #ifdef VERSION_STRINGS -static BYTE *buffer_hRcsId = "$Id$"; +static BYTE *buffer_hRcsId = + "$Id$"; #endif #endif #define BUFFERSIZE 512 -struct buffer -{ - WORD b_dummy; /* dummy self pointing word to keep MFT from crashing */ +struct buffer { + WORD b_dummy; /* dummy self pointing word to keep MFT from crashing */ struct buffer FAR *b_next; /* form linked list for LRU */ BYTE b_unit; /* disk for this buffer */ @@ -52,14 +52,12 @@ struct buffer #else UWORD b_offset; /* span between copies */ #endif -#if 0 /*TE*/ - union - { +#if 0 /*TE*/ + union { struct dpb FAR *_b_dpbp; /* pointer to DPB */ LONG _b_huge_blkno; /* DOS-C: actual block number if >= 0xffff */ - } - _b; -#endif + } _b; +#endif BYTE b_buffer[BUFFERSIZE]; /* 512 byte sectors for now */ }; @@ -79,4 +77,3 @@ struct buffer * Rev 1.0 20 Apr 2001 17:30:00 Bart Oldeman * Initial revision. */ - diff --git a/hdr/cds.h b/hdr/cds.h index 0af52695..c7b6522b 100644 --- a/hdr/cds.h +++ b/hdr/cds.h @@ -28,30 +28,25 @@ #ifdef MAIN #ifdef VERSION_STRINGS -static BYTE *Cds_hRcsId = "$Id$"; +static BYTE *Cds_hRcsId = + "$Id$"; #endif #endif #define MAX_CDSPATH 67 -struct cds -{ +struct cds { BYTE cdsCurrentPath[MAX_CDSPATH]; UWORD cdsFlags; struct dpb FAR *cdsDpb; - union - { - BYTE FAR * - _cdsRedirRec; - struct - { + union { + BYTE FAR *_cdsRedirRec; + struct { UWORD _cdsStrtClst; UWORD _cdsParam; - } - _cdsRedir; - } - _cdsUnion; + } _cdsRedir; + } _cdsUnion; UWORD cdsStoreUData; @@ -67,11 +62,9 @@ struct cds #define cdsRedirRec _cdsUnion._cdsRedirRec #define cdsParam _cdsUnion._cdsRedir._cdsParam -typedef struct _cdstbl -{ +typedef struct _cdstbl { struct cds cds_table[26]; -} -cdstbl; +} cdstbl; /* Bits for cdsFlags */ #define CDSNETWDRV 0x8000 diff --git a/hdr/clock.h b/hdr/clock.h index aeaea891..45cd9964 100644 --- a/hdr/clock.h +++ b/hdr/clock.h @@ -32,13 +32,12 @@ #ifdef MAIN #ifdef VERSION_STRINGS -static BYTE *clock_hRcsId = "$Id$"; +static BYTE *clock_hRcsId = + "$Id$"; #endif #endif - -struct ClockRecord -{ +struct ClockRecord { UWORD clkDays; /* days since Jan 1, 1980. */ UBYTE clkMinutes; /* residual minutes. */ UBYTE clkHours; /* residual hours. */ diff --git a/hdr/date.h b/hdr/date.h index f7368bf7..03a7d930 100644 --- a/hdr/date.h +++ b/hdr/date.h @@ -32,7 +32,8 @@ #ifdef MAIN #ifdef VERSION_STRINGS -static BYTE *date_hRcsId = "$Id$"; +static BYTE *date_hRcsId = + "$Id$"; #endif #endif diff --git a/hdr/dcb.h b/hdr/dcb.h index 4be6a51c..23ccfbb9 100644 --- a/hdr/dcb.h +++ b/hdr/dcb.h @@ -30,13 +30,13 @@ #ifdef MAIN #ifdef VERSION_STRINGS -static BYTE *clock_hRcsId = "$Id$"; +static BYTE *clock_hRcsId = + "$Id$"; #endif #endif /* Internal drive parameter block */ -struct dpb -{ +struct dpb { BYTE dpb_unit; /* unit for error reporting */ BYTE dpb_subunit; /* the sub-unit for driver */ UWORD dpb_secsize; /* sector size */ @@ -56,41 +56,39 @@ struct dpb struct dpb FAR * /* next dpb in chain */ dpb_next; /* -1 = end */ UWORD dpb_cluster; /* cluster # of first free */ - /* -1 if not known */ + /* -1 if not known */ #ifndef WITHFAT32 - UWORD dpb_nfreeclst; /* number of free clusters */ - /* -1 if not known */ -#else - union - { - struct - { + UWORD dpb_nfreeclst; /* number of free clusters */ + /* -1 if not known */ +#else + union { + struct { UWORD dpb_nfreeclst_lo; UWORD dpb_nfreeclst_hi; } dpb_nfreeclst_st; - ULONG _dpb_xnfreeclst; /* number of free clusters */ - /* -1 if not known */ + ULONG _dpb_xnfreeclst; /* number of free clusters */ + /* -1 if not known */ } dpb_nfreeclst_un; - #define dpb_nfreeclst dpb_nfreeclst_un.dpb_nfreeclst_st.dpb_nfreeclst_lo - #define dpb_xnfreeclst dpb_nfreeclst_un._dpb_xnfreeclst - +#define dpb_nfreeclst dpb_nfreeclst_un.dpb_nfreeclst_st.dpb_nfreeclst_lo +#define dpb_xnfreeclst dpb_nfreeclst_un._dpb_xnfreeclst + UWORD dpb_xflags; /* extended flags, see bpb */ UWORD dpb_xfsinfosec; /* FS info sector number, */ - /* 0xFFFF if unknown */ + /* 0xFFFF if unknown */ UWORD dpb_xbackupsec; /* backup boot sector number */ - /* 0xFFFF if unknown */ + /* 0xFFFF if unknown */ ULONG dpb_xdata; ULONG dpb_xsize; /* # of clusters+1 on media */ ULONG dpb_xfatsize; /* # of sectors / FAT */ ULONG dpb_xrootclst; /* starting cluster of root dir */ ULONG dpb_xcluster; /* cluster # of first free */ - /* -1 if not known */ -#endif + /* -1 if not known */ +#endif }; -#define UNKNCLUSTER 0x0000 /* see RBIL INT 21/AH=52 entry */ -#define XUNKNCLSTFREE 0xffffffffl /* unknown for DOS */ -#define UNKNCLSTFREE 0xffff /* unknown for DOS */ +#define UNKNCLUSTER 0x0000 /* see RBIL INT 21/AH=52 entry */ +#define XUNKNCLSTFREE 0xffffffffl /* unknown for DOS */ +#define UNKNCLSTFREE 0xffff /* unknown for DOS */ /* * Log: dcb.h,v diff --git a/hdr/device.h b/hdr/device.h index f2a8bf7c..1de1e928 100644 --- a/hdr/device.h +++ b/hdr/device.h @@ -29,11 +29,11 @@ #ifdef MAIN #ifdef VERSION_STRINGS -static BYTE *device_hRcsId = "$Id$"; +static BYTE *device_hRcsId = + "$Id$"; #endif #endif - /* * Status Word Bits */ @@ -122,8 +122,7 @@ static BYTE *device_hRcsId = "$Id$"; /* Device header */ -struct dhdr -{ +struct dhdr { struct dhdr FAR *dh_next; UWORD dh_attr; @@ -153,10 +152,9 @@ struct dhdr #define FAT_NO_MIRRORING 0x80 -#define BPB_SIZEOF 31 /* size of the standard BPB */ +#define BPB_SIZEOF 31 /* size of the standard BPB */ -typedef struct -{ +typedef struct { UWORD bpb_nbyte; /* Bytes per Sector */ UBYTE bpb_nsector; /* Sectors per Allocation Unit */ UWORD bpb_nreserved; /* # Reserved Sectors */ @@ -169,23 +167,22 @@ typedef struct UWORD bpb_nheads; /* Number of heads */ ULONG bpb_hidden; /* Hidden sectors */ ULONG bpb_huge; /* Size in sectors if */ - /* bpb_nsize == 0 */ + /* bpb_nsize == 0 */ #ifdef WITHFAT32 ULONG bpb_xnfsect; /* FAT size in sectors if */ - /* bpb_nfsect == 0 */ + /* bpb_nfsect == 0 */ UWORD bpb_xflags; /* extended flags */ - /* bit 7: disable mirroring */ - /* bits 6-4: reserved (0) */ - /* bits 3-0: active FAT number */ + /* bit 7: disable mirroring */ + /* bits 6-4: reserved (0) */ + /* bits 3-0: active FAT number */ UWORD bpb_xfsversion; /* filesystem version */ ULONG bpb_xrootclst; /* starting cluster of root dir */ UWORD bpb_xfsinfosec; /* FS info sector number, */ - /* 0xFFFF if unknown */ + /* 0xFFFF if unknown */ UWORD bpb_xbackupsec; /* backup boot sector number */ - /* 0xFFFF if unknown */ + /* 0xFFFF if unknown */ #endif -} -bpb; +} bpb; #define N_RETRY 5 /* number of retries permitted */ #define SEC_SIZE 512 /* size of sector in bytes */ @@ -193,64 +190,61 @@ bpb; #define LBA_READ 0x4200 #define LBA_WRITE 0x4300 - -struct _bios_LBA_address_packet /* Used to access a hard disk via LBA */ - /* Added by Brian E. Reifsnyder */ +struct _bios_LBA_address_packet + /* Used to access a hard disk via LBA */ + /* Added by Brian E. Reifsnyder */ { - unsigned char packet_size; /* size of this packet...set to 16 */ - unsigned char reserved_1; /* set to 0...unused */ - unsigned char number_of_blocks; /* 0 < number_of_blocks < 128 */ - unsigned char reserved_2; /* set to 0...unused */ - UBYTE far * buffer_address; /* addr of transfer buffer */ - unsigned long block_address; /* LBA address */ - unsigned long block_address_high; /* high bytes of LBA addr...unused */ + unsigned char packet_size; /* size of this packet...set to 16 */ + unsigned char reserved_1; /* set to 0...unused */ + unsigned char number_of_blocks; /* 0 < number_of_blocks < 128 */ + unsigned char reserved_2; /* set to 0...unused */ + UBYTE far *buffer_address; /* addr of transfer buffer */ + unsigned long block_address; /* LBA address */ + unsigned long block_address_high; /* high bytes of LBA addr...unused */ }; struct CHS { - ULONG Cylinder; - UWORD Head; - UWORD Sector; + ULONG Cylinder; + UWORD Head; + UWORD Sector; }; /* DOS 4.0-7.0 drive data table (see RBIL at INT2F,AX=0803) */ -typedef struct ddtstruct -{ +typedef struct ddtstruct { struct ddtstruct FAR *ddt_next; - /* pointer to next table (offset FFFFh if last table) */ - UBYTE ddt_driveno; /* physical unit number (for INT 13) */ - UBYTE ddt_logdriveno; /* logical drive number (0=A:) */ - bpb ddt_bpb; /* BIOS Parameter Block */ + /* pointer to next table (offset FFFFh if last table) */ + UBYTE ddt_driveno; /* physical unit number (for INT 13) */ + UBYTE ddt_logdriveno; /* logical drive number (0=A:) */ + bpb ddt_bpb; /* BIOS Parameter Block */ UBYTE ddt_flags; - /* bit 6: 16-bit FAT instead of 12-bit - bit 7: unsupportable disk (all accesses will return Not Ready) */ - UWORD ddt_FileOC; /* Count of Open files on Drv */ - UBYTE ddt_type; /* device type */ - UWORD ddt_descflags;/* bit flags describing drive */ - UWORD ddt_ncyl; /* number of cylinders - (for partition only, if hard disk) */ - bpb ddt_defbpb; /* BPB for default (highest) capacity supported */ - UBYTE ddt_reserved[6]; /* (part of BPB above) */ - UBYTE ddt_ltrack; /* last track accessed */ - union - { - ULONG ddt_lasttime; /* removable media: time of last access - in clock ticks (FFFFFFFFh if never) */ - struct - { - UWORD ddt_part; /* partition (FFFFh = primary, 0001h = extended) - always 0001h for DOS 5+ */ - UWORD ddt_abscyl; /* absolute cylinder number of partition's - start on physical drive - (FFFFh if primary partition in DOS 4.x)*/ + /* bit 6: 16-bit FAT instead of 12-bit + bit 7: unsupportable disk (all accesses will return Not Ready) */ + UWORD ddt_FileOC; /* Count of Open files on Drv */ + UBYTE ddt_type; /* device type */ + UWORD ddt_descflags; /* bit flags describing drive */ + UWORD ddt_ncyl; /* number of cylinders + (for partition only, if hard disk) */ + bpb ddt_defbpb; /* BPB for default (highest) capacity supported */ + UBYTE ddt_reserved[6]; /* (part of BPB above) */ + UBYTE ddt_ltrack; /* last track accessed */ + union { + ULONG ddt_lasttime; /* removable media: time of last access + in clock ticks (FFFFFFFFh if never) */ + struct { + UWORD ddt_part; /* partition (FFFFh = primary, 0001h = extended) + always 0001h for DOS 5+ */ + UWORD ddt_abscyl; /* absolute cylinder number of partition's + start on physical drive + (FFFFh if primary partition in DOS 4.x) */ } ddt_hd; } ddt_fh; - UBYTE ddt_volume[12]; /* ASCIIZ volume label or "NO NAME " if none - (apparently taken from extended boot record - rather than root directory) */ - ULONG ddt_serialno; /* serial number */ - UBYTE ddt_fstype[9]; /* ASCIIZ filesystem type ("FAT12 " or "FAT16 ")*/ - ULONG ddt_offset; /* relative partition offset */ - BITS ddt_LBASupported:1; /* set, if INT13 extensions enabled */ + UBYTE ddt_volume[12]; /* ASCIIZ volume label or "NO NAME " if none + (apparently taken from extended boot record + rather than root directory) */ + ULONG ddt_serialno; /* serial number */ + UBYTE ddt_fstype[9]; /* ASCIIZ filesystem type ("FAT12 " or "FAT16 ") */ + ULONG ddt_offset; /* relative partition offset */ + BITS ddt_LBASupported:1; /* set, if INT13 extensions enabled */ BITS ddt_WriteVerifySupported:1; } ddt; @@ -268,41 +262,39 @@ typedef struct ddtstruct /* typedef struct ddtstruct ddt;*/ -struct gblkio -{ - UBYTE gbio_spcfunbit; - UBYTE gbio_devtype; - UWORD gbio_devattrib; - UWORD gbio_ncyl; - UBYTE gbio_media; - bpb gbio_bpb; - UWORD gbio_nsecs; +struct gblkio { + UBYTE gbio_spcfunbit; + UBYTE gbio_devtype; + UWORD gbio_devattrib; + UWORD gbio_ncyl; + UBYTE gbio_media; + bpb gbio_bpb; + UWORD gbio_nsecs; }; -struct gblkfv /* for format / verify track */ +struct gblkfv /* for format / verify track */ { - UBYTE gbfv_spcfunbit; - UWORD gbfv_head; - UWORD gbfv_cyl; - UWORD gbfv_ntracks; + UBYTE gbfv_spcfunbit; + UWORD gbfv_head; + UWORD gbfv_cyl; + UWORD gbfv_ntracks; }; -struct gblkrw /* for read / write track */ +struct gblkrw /* for read / write track */ { - UBYTE gbrw_spcfunbit; - UWORD gbrw_head; - UWORD gbrw_cyl; - UWORD gbrw_sector; - UWORD gbrw_nsecs; - UBYTE FAR * gbrw_buffer; + UBYTE gbrw_spcfunbit; + UWORD gbrw_head; + UWORD gbrw_cyl; + UWORD gbrw_sector; + UWORD gbrw_nsecs; + UBYTE FAR *gbrw_buffer; }; -struct Gioc_media -{ - WORD ioc_level; +struct Gioc_media { + WORD ioc_level; ULONG ioc_serialno; - BYTE ioc_volume[11]; - BYTE ioc_fstype[8]; + BYTE ioc_volume[11]; + BYTE ioc_fstype[8]; }; /* */ @@ -315,90 +307,68 @@ struct Gioc_media #define BT_BPB 11 #define BT_SIZEOF 36 -typedef struct -{ - BYTE bt_jump[3]; /* Boot Jump opcodes */ - BYTE bt_oem[8]; /* OEM Name */ - bpb bt_bpb; /* BPB for this media/device */ - WORD bt_nsecs; /* # Sectors per Track */ - WORD bt_nheads; /* # Heads */ - WORD bt_hidden; /* # Hidden sectors */ - LONG bt_huge; /* use if nsecs == 0 */ - BYTE bt_drvno; - BYTE bt_reserv; - BYTE bt_btid; +typedef struct { + BYTE bt_jump[3]; /* Boot Jump opcodes */ + BYTE bt_oem[8]; /* OEM Name */ + bpb bt_bpb; /* BPB for this media/device */ + WORD bt_nsecs; /* # Sectors per Track */ + WORD bt_nheads; /* # Heads */ + WORD bt_hidden; /* # Hidden sectors */ + LONG bt_huge; /* use if nsecs == 0 */ + BYTE bt_drvno; + BYTE bt_reserv; + BYTE bt_btid; ULONG bt_serialno; - BYTE bt_volume[11]; - BYTE bt_fstype[8]; -} -boot; + BYTE bt_volume[11]; + BYTE bt_fstype[8]; +} boot; /* File system information structure */ -struct fsinfo -{ - UDWORD fi_signature; /* must be 0x61417272 */ - DWORD fi_nfreeclst; /* number of free clusters, -1 if unknown */ - DWORD fi_cluster; /* most recently allocated cluster, -1 if unknown */ +struct fsinfo { + UDWORD fi_signature; /* must be 0x61417272 */ + DWORD fi_nfreeclst; /* number of free clusters, -1 if unknown */ + DWORD fi_cluster; /* most recently allocated cluster, -1 if unknown */ UBYTE fi_reserved[12]; }; typedef boot super; /* Alias for boot structure */ -typedef struct -{ +typedef struct { UBYTE r_length; /* Request Header length */ UBYTE r_unit; /* Unit Code */ UBYTE r_command; /* Command Code */ WORD r_status; /* Status */ BYTE r_reserved[8]; /* DOS Reserved Area */ - union - { - struct - { + union { + struct { UBYTE _r_nunits; /* number of units */ BYTE FAR *_r_endaddr; /* Ending Address */ bpb *FAR * _r_bpbptr; /* ptr to BPB array */ UBYTE _r_firstunit; - } - _r_init; - struct - { + } _r_init; + struct { BYTE _r_meddesc; /* MEDIA Descriptor */ BYTE _r_retcode; /* Return Code */ - BYTE FAR - * _r_vid; /* volume id */ - } - _r_media; - struct - { + BYTE FAR * _r_vid; /* volume id */ + } _r_media; + struct { BYTE _r_meddesc; /* MEDIA Descriptor */ - boot FAR - * _r_fat; /* boot sector pointer */ - bpb FAR - * _r_bpbpt; /* ptr to BPB table */ - } - _r_bpb; - struct - { + boot FAR * _r_fat; /* boot sector pointer */ + bpb FAR * _r_bpbpt; /* ptr to BPB table */ + } _r_bpb; + struct { BYTE _r_meddesc; /* MEDIA Descriptor */ - BYTE FAR - * _r_trans; /* Transfer Address */ + BYTE FAR * _r_trans; /* Transfer Address */ UWORD _r_count; /* Byte/Sector Count */ UWORD _r_start; /* Starting Sector No. */ - BYTE FAR - * _r_vid; /* Pointer to volume id */ + BYTE FAR * _r_vid; /* Pointer to volume id */ LONG _r_huge; /* for > 32Mb drives */ - } - _r_rw; - struct - { + } _r_rw; + struct { BYTE _r_ndbyte; /* Byte Read From Device */ - } - _r_nd; - } - _r_x; -} -request; + } _r_nd; + } _r_x; +} request; #define HUGECOUNT 0xffff #define MAXSHORT 0xffffl diff --git a/hdr/dirmatch.h b/hdr/dirmatch.h index 112b82fe..b8e55d1a 100644 --- a/hdr/dirmatch.h +++ b/hdr/dirmatch.h @@ -30,26 +30,24 @@ #ifdef MAIN #ifdef VERSION_STRINGS -static BYTE *dirmatch_hRcsId = "$Id$"; +static BYTE *dirmatch_hRcsId = + "$Id$"; #endif #endif - -typedef struct -{ +typedef struct { BYTE dm_drive; BYTE dm_name_pat[FNAME_SIZE + FEXT_SIZE]; BYTE dm_attr_srch; UWORD dm_entry; -#ifdef WITHFAT32 +#ifdef WITHFAT32 ULONG dm_dircluster; -#else +#else UWORD dm_dircluster; UWORD reserved; #endif - struct - { + struct { BITS /* directory has been modified */ f_dmod:1; BITS /* directory is the root */ @@ -60,16 +58,14 @@ typedef struct f_ddir:1; BITS /* filler to avoid a bad bug (feature?) in */ f_filler:12; /* TC 2.01 */ - } - dm_flags; /* file flags */ + } dm_flags; /* file flags */ BYTE dm_attr_fnd; /* found file attribute */ time dm_time; /* file time */ date dm_date; /* file date */ LONG dm_size; /* file size */ - BYTE dm_name[FNAME_SIZE + FEXT_SIZE + 2]; /* file name */ -} -dmatch; + BYTE dm_name[FNAME_SIZE + FEXT_SIZE + 2]; /* file name */ +} dmatch; /* * Log: dirmatch.h,v diff --git a/hdr/dosnames.h b/hdr/dosnames.h index 73e6ce04..e06cc622 100644 --- a/hdr/dosnames.h +++ b/hdr/dosnames.h @@ -30,19 +30,18 @@ #ifdef MAIN #ifdef VERSION_STRINGS -static BYTE *dosnames_hRcsId = "$Id$"; +static BYTE *dosnames_hRcsId = + "$Id$"; #endif #endif - #define PARSE_MAX 64 -struct dosnames -{ +struct dosnames { UBYTE dn_drive; /* the drive that was parsed */ UBYTE dn_network[PARSE_MAX]; /* specified network */ UBYTE dn_path[PARSE_MAX]; /* the path */ - UBYTE dn_name[FNAME_SIZE + FEXT_SIZE + 1]; /* the file name */ + UBYTE dn_name[FNAME_SIZE + FEXT_SIZE + 1]; /* the file name */ }; /* diff --git a/hdr/error.h b/hdr/error.h index 98b180d0..984df3f8 100644 --- a/hdr/error.h +++ b/hdr/error.h @@ -30,11 +30,11 @@ #ifdef MAIN #ifdef VERSION_STRINGS -static BYTE *error_hRcsId = "$Id$"; +static BYTE *error_hRcsId = + "$Id$"; #endif #endif - /* Internal system error returns */ #define SUCCESS 0 /* Function was successful */ #define DE_INVLDFUNC -1 /* Invalid function number */ @@ -60,7 +60,7 @@ static BYTE *error_hRcsId = "$Id$"; #define DE_SEEK -25 /* error on file seek */ #define DE_HNDLDSKFULL -28 /* handle disk full (?) */ -#define DE_INVLDPARM -0x57 /* invalid parameter */ +#define DE_INVLDPARM -0x57 /* invalid parameter */ #define DE_DEADLOCK -36 #define DE_LOCK -39 diff --git a/hdr/exe.h b/hdr/exe.h index d8058c2c..c895db0d 100644 --- a/hdr/exe.h +++ b/hdr/exe.h @@ -30,13 +30,12 @@ #ifdef MAIN #ifdef VERSION_STRINGS -static BYTE *exe_hRcsId = "$Id$"; +static BYTE *exe_hRcsId = + "$Id$"; #endif #endif - -typedef struct -{ +typedef struct { UWORD exSignature; UWORD exExtraBytes; UWORD exPages; @@ -51,8 +50,7 @@ typedef struct UWORD exInitCS; UWORD exRelocTable; UWORD exOverlay; -} -exe_header; +} exe_header; #define MAGIC 0x5a4d diff --git a/hdr/fat.h b/hdr/fat.h index 0c7ad4bb..164079d6 100644 --- a/hdr/fat.h +++ b/hdr/fat.h @@ -30,11 +30,11 @@ #ifdef MAIN #ifdef VERSION_STRINGS -static BYTE *fat_hRcsId = "$Id$"; +static BYTE *fat_hRcsId = + "$Id$"; #endif #endif - /* FAT file system attribute bits */ #define D_NORMAL 0 /* normal */ #define D_RDONLY 0x01 /* read-only file */ @@ -79,8 +79,7 @@ static BYTE *fat_hRcsId = "$Id$"; /* dpb_size == 0 for FAT32, hence doing -1 here */ /* FAT file system directory entry */ -struct dirent -{ +struct dirent { UBYTE dir_name[FNAME_SIZE]; /* Filename */ UBYTE dir_ext[FEXT_SIZE]; /* Filename extension */ UBYTE dir_attrib; /* File Attribute */ @@ -93,12 +92,11 @@ struct dirent time dir_time; /* Time file created/updated */ date dir_date; /* Date file created/updated */ UWORD dir_start; /* Starting cluster */ - /* 1st available = 2 */ + /* 1st available = 2 */ ULONG dir_size; /* File size in bytes */ }; -struct lfn_entry -{ +struct lfn_entry { UBYTE lfn_id; UNICODE lfn_name0_4[5]; UBYTE lfn_attrib; @@ -142,16 +140,15 @@ struct lfn_entry #define DIRENT_SIZE 32 -struct lfn_inode -{ +struct lfn_inode { UNICODE name[256]; - + struct dirent l_dir; - + ULONG l_diroff; /* offset of the dir entry */ }; - -typedef struct lfn_inode FAR * lfn_inode_ptr; + +typedef struct lfn_inode FAR *lfn_inode_ptr; /* * Log: fat.h,v diff --git a/hdr/fcb.h b/hdr/fcb.h index 61f467a7..1253b721 100644 --- a/hdr/fcb.h +++ b/hdr/fcb.h @@ -30,11 +30,11 @@ #ifdef MAIN #ifdef VERSION_STRINGS -static BYTE *fcb_hRcsId = "$Id$"; +static BYTE *fcb_hRcsId = + "$Id$"; #endif #endif - /* fcb convience defines */ /* block device info */ #define FID_CHARDEV 0x80 /* 1 defines character device */ @@ -77,8 +77,7 @@ static BYTE *fcb_hRcsId = "$Id$"; #define FCB_WRITE 1 /* File Control Block (FCB) */ -typedef struct -{ +typedef struct { BYTE fcb_drive; /* Drive number 0=default, 1=A, etc */ BYTE fcb_fname[FNAME_SIZE]; /* File name */ BYTE fcb_fext[FEXT_SIZE]; /* File name Extension */ @@ -99,21 +98,17 @@ typedef struct /* end reserved */ UBYTE fcb_curec; /* Current block number of */ ULONG fcb_rndm; /* Current relative record number */ -} -fcb; +} fcb; /* FAT extended fcb */ -typedef struct -{ +typedef struct { UBYTE xfcb_flag; /* 0xff indicates Extended FCB */ BYTE xfcb_resvrd[5]; /* Reserved */ UBYTE xfcb_attrib; /* Attribute */ fcb xfcb_fcb; -} -xfcb; +} xfcb; -typedef struct -{ +typedef struct { UBYTE renDriveID; /* drive no. */ BYTE renOldName[8]; /* Old Filename */ BYTE renOldExtent[3]; /* Old File Extension */ @@ -121,8 +116,7 @@ typedef struct BYTE renNewName[8]; /* New Filename */ BYTE renNewExtent[3]; /* New FileExtension */ BYTE renReserved2[9]; -} -rfcb; +} rfcb; /* * Log: fcb.h,v diff --git a/hdr/file.h b/hdr/file.h index 7fe79ffb..e143e43a 100644 --- a/hdr/file.h +++ b/hdr/file.h @@ -30,11 +30,11 @@ #ifdef MAIN #ifdef VERSION_STRINGS -static BYTE *file_hRcsId = "$Id$"; +static BYTE *file_hRcsId = + "$Id$"; #endif #endif - /* 0 = CON, standard input, can be redirected */ /* 1 = CON, standard output, can be redirected */ /* 2 = CON, standard error */ diff --git a/hdr/fnode.h b/hdr/fnode.h index d7502c21..21bac170 100644 --- a/hdr/fnode.h +++ b/hdr/fnode.h @@ -30,25 +30,22 @@ #ifdef MAIN #ifdef VERSION_STRINGS -static BYTE *fnode_hRcsId = "$Id$"; +static BYTE *fnode_hRcsId = + "$Id$"; #endif #endif - -struct f_node -{ +struct f_node { UWORD f_count; /* number of uses of this file */ COUNT f_mode; /* read, write, read-write, etc */ - struct - { + struct { BITS f_dmod:1; /* directory has been modified */ BITS f_droot:1; /* directory is the root */ BITS f_dnew:1; /* fnode is new and needs fill */ BITS f_ddir:1; /* fnode is assigned to dir */ BITS f_ddate:1; /* date set using setdate */ - } - f_flags; /* file flags */ + } f_flags; /* file flags */ struct dirent f_dir; /* this file's dir entry image */ @@ -67,21 +64,20 @@ struct f_node }; #if 0 -struct lfn_inode - { +struct lfn_inode { UNICODE name[255]; struct dirent l_dir; /* this file's dir entry image */ ULONG l_diroff; /* offset of the dir entry */ CLUSTER l_dirstart; /* the starting cluster of dir */ - /* when dir is not root */ - }; + /* when dir is not root */ +}; -typedef struct lfn_inode FAR * lfn_inode_ptr; +typedef struct lfn_inode FAR *lfn_inode_ptr; #endif -typedef struct f_node * f_node_ptr; +typedef struct f_node *f_node_ptr; /* * Log: fnode.h,v diff --git a/hdr/kbd.h b/hdr/kbd.h index 7493639c..4894665a 100644 --- a/hdr/kbd.h +++ b/hdr/kbd.h @@ -30,21 +30,19 @@ #ifdef MAIN #ifdef VERSION_STRINGS -static BYTE *kbd_hRcsId = "$Id$"; +static BYTE *kbd_hRcsId = + "$Id$"; #endif #endif - #define KBD_MAXLENGTH 256 /* Keyboard buffer */ -typedef struct -{ +typedef struct { UBYTE kb_size; /* size of buffer in bytes */ UBYTE kb_count; /* number of bytes returned */ BYTE kb_buf[KBD_MAXLENGTH]; /* the buffer itself */ -} -keyboard; +} keyboard; /* * Log: kbd.h,v diff --git a/hdr/kconfig.h b/hdr/kconfig.h index cddbfcb0..f08506e8 100644 --- a/hdr/kconfig.h +++ b/hdr/kconfig.h @@ -13,15 +13,15 @@ < 0 : not possible to skip config.sys = 0 : only possible if already pressed before, no message > 0 : wait so long for F5/F8 -*/ +*/ typedef struct _KernelConfig { - char CONFIG[6]; /* "CONFIG" */ - unsigned short ConfigSize; - - unsigned char DLASortByDriveNo; - unsigned char InitDiskShowDriveAssignment; - signed char SkipConfigSeconds; - unsigned char ForceLBA; - unsigned char GlobalEnableLBAsupport; /* = 0 --> disable LBA support */ - } KernelConfig; -extern struct _KernelConfig FAR LowKernelConfig; + char CONFIG[6]; /* "CONFIG" */ + unsigned short ConfigSize; + + unsigned char DLASortByDriveNo; + unsigned char InitDiskShowDriveAssignment; + signed char SkipConfigSeconds; + unsigned char ForceLBA; + unsigned char GlobalEnableLBAsupport; /* = 0 --> disable LBA support */ +} KernelConfig; +extern struct _KernelConfig FAR LowKernelConfig; diff --git a/hdr/mcb.h b/hdr/mcb.h index 6637e037..71d87bc1 100644 --- a/hdr/mcb.h +++ b/hdr/mcb.h @@ -30,7 +30,8 @@ #ifdef MAIN #ifdef VERSION_STRINGS -static BYTE *mcb_hRcsId = "$Id$"; +static BYTE *mcb_hRcsId = + "$Id$"; #endif #endif @@ -56,15 +57,13 @@ static BYTE *mcb_hRcsId = "$Id$"; typedef UWORD seg; typedef UWORD offset; -typedef struct -{ +typedef struct { BYTE m_type; /* mcb type - chain or end */ UWORD m_psp; /* owner id via psp segment */ UWORD m_size; /* size of segment in paragraphs */ BYTE m_fill[3]; BYTE m_name[8]; /* owner name limited to 8 bytes */ -} -mcb; +} mcb; /* * Log: mcb.h,v diff --git a/hdr/network.h b/hdr/network.h index a9fddd8d..dcb66f08 100644 --- a/hdr/network.h +++ b/hdr/network.h @@ -59,30 +59,22 @@ #define REM_PRINTREDIR 0x1125 #define REM_EXTOC 0x112e -struct rgds -{ +struct rgds { UWORD r_spc; UWORD r_navc; UWORD r_bps; UWORD r_nc; }; -struct remote_fileattrib -{ +struct remote_fileattrib { UWORD rfa_file; /* File Attributes */ - union - { + union { ULONG rfa_filesize; /* file size */ - struct - { + struct { UWORD rfa_filesize_lo; /* DI Low */ UWORD rfa_filesize_hi; /* BX High */ - } - _split_rfa_fz; - } - rfa_fz_union; + } _split_rfa_fz; + } rfa_fz_union; UWORD rfa_time; UWORD rfa_date; }; - - diff --git a/hdr/nls.h b/hdr/nls.h index 072d8173..a8d1b37b 100644 --- a/hdr/nls.h +++ b/hdr/nls.h @@ -281,20 +281,19 @@ access to often used and mandatoryly present tables. */ #define NLS_REORDER_POINTERS - /* * How the kernel and NLSFUNC communicate with each other */ - /* Must be returned by NLSFUNC upon MUX-14-00 */ + /* Must be returned by NLSFUNC upon MUX-14-00 */ #define NLS_FREEDOS_NLSFUNC_ID 0x534b - /* Represents a call to DOS-38 within DOS-65 handlers. - Current implementation relys on 0x101! */ + /* Represents a call to DOS-38 within DOS-65 handlers. + Current implementation relys on 0x101! */ #define NLS_DOS_38 0x101 - /* NLSFUNC may return NLS_REDO to instruct the kernel to - try to perform the same action another time. This is most - useful if the kernel only loads the NLS pkg into memory so - the kernel will find it and will process the request internally - now. */ + /* NLSFUNC may return NLS_REDO to instruct the kernel to + try to perform the same action another time. This is most + useful if the kernel only loads the NLS pkg into memory so + the kernel will find it and will process the request internally + now. */ #define NLS_REDO 353 /* Codes of the subfunctions of external NLSFUNC */ @@ -320,42 +319,41 @@ a "1" in the bitfield means that the feature is active/enabled. All currently non-defined bits are to be zero to allow future useage. */ -#define NLS_FLAG_DIRECT_UPCASE 0x0001 /* DOS-65-2[012], */ -#define NLS_FLAG_DIRECT_FUPCASE 0x0002 /* DOS-65-A[012], internal */ -#define NLS_FLAG_DIRECT_YESNO 0x0004 /* DOS-65-23 */ -#define NLS_FLAG_DIRECT_GETDATA 0x0008 /* DOS-65-XX, DOS-38 */ +#define NLS_FLAG_DIRECT_UPCASE 0x0001 /* DOS-65-2[012], */ +#define NLS_FLAG_DIRECT_FUPCASE 0x0002 /* DOS-65-A[012], internal */ +#define NLS_FLAG_DIRECT_YESNO 0x0004 /* DOS-65-23 */ +#define NLS_FLAG_DIRECT_GETDATA 0x0008 /* DOS-65-XX, DOS-38 */ #define NLS_FLAG_HARDCODED NLS_FLAG_DIRECT_UPCASE \ | NLS_FLAG_DIRECT_FUPCASE \ | NLS_FLAG_DIRECT_YESNO \ | NLS_FLAG_DIRECT_GETDATA - /* No codepage / country code given */ + /* No codepage / country code given */ #define NLS_DEFAULT ((UWORD)-1) /* * This is the data in the exact order returned by DOS-65-01 */ -struct nlsExtCntryInfo -{ - UBYTE subfct; /* always 1 */ - WORD size; /* size of this structure - without this WORD itself */ - WORD countryCode; /* current country code */ - WORD codePage; /* current code page (CP) */ - - /* - * This is the data in the exact order as to return on - * DOS-38; it is also the most (important) part of DOS-65-01 - */ - /* Note: The ASCIZ strings might become - a totally different understanding with - DBCS (Double Byte Character Support) */ +struct nlsExtCntryInfo { + UBYTE subfct; /* always 1 */ + WORD size; /* size of this structure + without this WORD itself */ + WORD countryCode; /* current country code */ + WORD codePage; /* current code page (CP) */ + + /* + * This is the data in the exact order as to return on + * DOS-38; it is also the most (important) part of DOS-65-01 + */ + /* Note: The ASCIZ strings might become + a totally different understanding with + DBCS (Double Byte Character Support) */ WORD dateFmt; /* order of portions of date - 0: mm/dd/yyyy (USA) - 1: dd/mm/yyyy (Europe) - 2: yyyy/mm/dd (Japan) - */ + 0: mm/dd/yyyy (USA) + 1: dd/mm/yyyy (Europe) + 2: yyyy/mm/dd (Japan) + */ char curr[5]; /* ASCIZ of currency string */ char thSep[2]; /* ASCIZ of thousand's separator */ char point[2]; /* ASCIZ of decimal point */ @@ -363,64 +361,63 @@ struct nlsExtCntryInfo char timeSep[2]; /* ASCIZ of time separator */ BYTE currFmt; /* format of currency: bit 0: currency string is placed - 0: before number - 1: behind number + 0: before number + 1: behind number bit 1: currency string and number are - separated by a space - 0: No - 1: Yes + separated by a space + 0: No + 1: Yes bit 2: currency string replaces decimal - sign - 0: No - 1: Yes + sign + 0: No + 1: Yes */ BYTE prescision; /* of monetary numbers */ BYTE timeFmt; /* time format: - 0: 12 hours (append AM/PM) - 1: 24 houres - */ - VOID(FAR * upCaseFct) (VOID); /* far call to a function upcasing the - character in register AL */ + 0: 12 hours (append AM/PM) + 1: 24 houres + */ + VOID(FAR * upCaseFct) (VOID); /* far call to a function upcasing the + character in register AL */ char dataSep[2]; /* ASCIZ of separator in data records */ }; -struct nlsPointer { /* Information of DOS-65-0X is addressed - by a pointer */ - UBYTE subfct; /* number of the subfunction */ - VOID FAR *pointer; /* the pointer to be returned when the subfunction - of DOS-65 is called (Note: won't work for - subfunctions 0, 1, 0x20, 0x21, 0x22, 0x23, - 0xA0, 0xA1,& 0xA2 */ +struct nlsPointer { /* Information of DOS-65-0X is addressed + by a pointer */ + UBYTE subfct; /* number of the subfunction */ + VOID FAR *pointer; /* the pointer to be returned when the subfunction + of DOS-65 is called (Note: won't work for + subfunctions 0, 1, 0x20, 0x21, 0x22, 0x23, + 0xA0, 0xA1,& 0xA2 */ }; - -struct nlsPackage { /* the contents of one chain item of the - list of NLS packages */ - struct nlsPackage FAR *nxt; /* next item in chain */ - UWORD cntry, cp; /* country ID / codepage of this NLS pkg */ - int flags; /* direct access and other flags */ - /* Note: Depending on the flags above all remaining - portions may be omitted, if the external NLSFUNC-like - MUX-14 processor does not require them and performs - all actions itself, so that the kernel never tries to - fetch this information itself. */ - UBYTE yeschar; /* yes / no character DOS-65-23 */ - UBYTE nochar; - unsigned numSubfct; /* number of supported sub-functions */ - struct nlsPointer nlsPointers[1]; /* grows dynamically */ +struct nlsPackage { /* the contents of one chain item of the + list of NLS packages */ + struct nlsPackage FAR *nxt; /* next item in chain */ + UWORD cntry, cp; /* country ID / codepage of this NLS pkg */ + int flags; /* direct access and other flags */ + /* Note: Depending on the flags above all remaining + portions may be omitted, if the external NLSFUNC-like + MUX-14 processor does not require them and performs + all actions itself, so that the kernel never tries to + fetch this information itself. */ + UBYTE yeschar; /* yes / no character DOS-65-23 */ + UBYTE nochar; + unsigned numSubfct; /* number of supported sub-functions */ + struct nlsPointer nlsPointers[1]; /* grows dynamically */ }; -struct nlsDBCS { /* The internal structure is unknown to me */ - UWORD numEntries; - UWORD dbcsTbl[1]; +struct nlsDBCS { /* The internal structure is unknown to me */ + UWORD numEntries; + UWORD dbcsTbl[1]; }; struct nlsCharTbl { - /* table containing a list of characters */ - UWORD numEntries; /* number of entries of this table. - If <= 0x80, the first element of - the table corresponse to character 0x80 */ - unsigned char tbl[1]; /* grows dynamically */ + /* table containing a list of characters */ + UWORD numEntries; /* number of entries of this table. + If <= 0x80, the first element of + the table corresponse to character 0x80 */ + unsigned char tbl[1]; /* grows dynamically */ }; #define nlsChBuf(len) struct nlsCharTbl##len { \ UWORD numEntries; \ @@ -431,37 +428,35 @@ nlsChBuf(256); /* in file names permittable characters for DOS-65-05 */ struct nlsFnamTerm { - WORD size; /* size of this structure */ - BYTE dummy1; - char firstCh, - lastCh; /* first, last permittable character */ - BYTE dummy2; - char firstExcl, - lastExcl; /* first, last excluded character */ - BYTE dummy3; - BYTE numSep; /* number of file name separators */ - char separators[1]; /* grows dynamically */ + WORD size; /* size of this structure */ + BYTE dummy1; + char firstCh, lastCh; /* first, last permittable character */ + BYTE dummy2; + char firstExcl, lastExcl; /* first, last excluded character */ + BYTE dummy3; + BYTE numSep; /* number of file name separators */ + char separators[1]; /* grows dynamically */ }; -struct nlsInfoBlock { /* This block contains all information - shared by the kernel and the external NLSFUNC program */ - char FAR *fname; /* filename from COUNTRY=; - maybe tweaked by NLSFUNC */ - UWORD sysCodePage; /* system code page */ - unsigned flags; /* implementation flags */ - struct nlsPackage FAR *actPkg; /* current NLS package */ - struct nlsPackage FAR *chain; /* first item of info chain -- - hardcoded U.S.A./CP437 */ +struct nlsInfoBlock { /* This block contains all information + shared by the kernel and the external NLSFUNC program */ + char FAR *fname; /* filename from COUNTRY=; + maybe tweaked by NLSFUNC */ + UWORD sysCodePage; /* system code page */ + unsigned flags; /* implementation flags */ + struct nlsPackage FAR *actPkg; /* current NLS package */ + struct nlsPackage FAR *chain; /* first item of info chain -- + hardcoded U.S.A./CP437 */ }; -extern struct nlsInfoBlock nlsInfo; -extern struct nlsPackage nlsPackageHardcoded; - /* These are the "must have" tables within the hard coded NLS pkg */ -extern struct nlsFnamTerm nlsFnameTermHardcoded; -extern struct nlsDBCS nlsDBCSHardcoded; -extern struct nlsCharTbl nlsUpcaseHardcoded; -extern struct nlsCharTbl nlsFUpcaseHardcoded; -extern struct nlsCharTbl nlsCollHardcoded; +extern struct nlsInfoBlock nlsInfo; +extern struct nlsPackage nlsPackageHardcoded; + /* These are the "must have" tables within the hard coded NLS pkg */ +extern struct nlsFnamTerm nlsFnameTermHardcoded; +extern struct nlsDBCS nlsDBCSHardcoded; +extern struct nlsCharTbl nlsUpcaseHardcoded; +extern struct nlsCharTbl nlsFUpcaseHardcoded; +extern struct nlsCharTbl nlsCollHardcoded; extern struct nlsExtCntryInfo nlsCntryInfoHardcoded; extern BYTE FAR hcTablesStart[], hcTablesEnd[]; @@ -522,35 +517,34 @@ extern BYTE FAR hcTablesStart[], hcTablesEnd[]; #define CSYS_FD_IDSTRING "FreeDOS COUNTRY.SYS v1.0\r\n" -struct nlsCSys_function { /* S3: function definition */ - UDWORD csys_rpos; /* relative position to actual data */ - UWORD csys_length; - UBYTE csys_fctID; /* As passed to DOS-65-XX */ - UBYTE csys_reserved1; /* always 0, reserved for future use */ +struct nlsCSys_function { /* S3: function definition */ + UDWORD csys_rpos; /* relative position to actual data */ + UWORD csys_length; + UBYTE csys_fctID; /* As passed to DOS-65-XX */ + UBYTE csys_reserved1; /* always 0, reserved for future use */ }; -struct nlsCSys_ccDefinition { /* S1: country/codepage reference */ - UDWORD csys_rpos; /* moving the 4byte value to the front - can increase performance */ - UWORD csys_cp; - UWORD csys_cntry; +struct nlsCSys_ccDefinition { /* S1: country/codepage reference */ + UDWORD csys_rpos; /* moving the 4byte value to the front + can increase performance */ + UWORD csys_cp; + UWORD csys_cntry; }; -struct nlsCSys_numEntries { /* helper structure for "number of entries" */ - UWORD csys_numEntries; +struct nlsCSys_numEntries { /* helper structure for "number of entries" */ + UWORD csys_numEntries; }; /* Actually, this structure is never really used */ -struct nlsCSys_fileHeader { /* S0: primary structure */ - unsigned char csys_idstring[sizeof(CSYS_FD_IDSTRING) - 1]; - /* decrement by 1 to cut off \0 from IDString -- ska*/ +struct nlsCSys_fileHeader { /* S0: primary structure */ + unsigned char csys_idstring[sizeof(CSYS_FD_IDSTRING) - 1]; + /* decrement by 1 to cut off \0 from IDString -- ska */ }; -struct nlsCSys_completeFileHeader { /* as S0, but full 128 bytes */ - unsigned char csys_idstring[sizeof(CSYS_FD_IDSTRING) - 1]; - unsigned char csys_padbytes[128 - (sizeof(CSYS_FD_IDSTRING) - 1)]; +struct nlsCSys_completeFileHeader { /* as S0, but full 128 bytes */ + unsigned char csys_idstring[sizeof(CSYS_FD_IDSTRING) - 1]; + unsigned char csys_padbytes[128 - (sizeof(CSYS_FD_IDSTRING) - 1)]; }; - /* standard alignment */ #include diff --git a/hdr/pcb.h b/hdr/pcb.h index 4a6520e9..87a37859 100644 --- a/hdr/pcb.h +++ b/hdr/pcb.h @@ -51,27 +51,23 @@ #ifdef MAIN #ifdef VERSION_STRINGS -static BYTE *pcb_hRcsId = "$Id$"; +static BYTE *pcb_hRcsId = + "$Id$"; #endif #endif - /* Force one-byte alignment for all the internal structures, see above */ #include /* */ /* interrupt handler structure definition */ /* */ -typedef union -{ +typedef union { UWORD x; /* access mode for ax, bx, etc. */ - struct - { + struct { UBYTE l; /* access mode for al, bl, etc. */ UBYTE h; /* access mode for ah, bh, etc. */ - } - b; -} -xreg; + } b; +} xreg; /* The structure assumes that: 1) An interrupt was invoked, & @@ -79,41 +75,26 @@ xreg; Furthermore, the PUSH$ALL macro must push ES first and AX last. -- 2000/03/22 ska*/ /* maps MS-DOS unique stacking order */ -typedef struct _iregss -{ - xreg a, - b, - c, - d; - UWORD si, - di, - bp, - ds, - es; - UWORD ip, - cs, - flags; -} -iregs; +typedef struct _iregss { + xreg a, b, c, d; + UWORD si, di, bp, ds, es; + UWORD ip, cs, flags; +} iregs; /* Registers directly passed to syscall; - must be the same order as iregs! - Is used to define parameters. */ + must be the same order as iregs! + Is used to define parameters. */ #define DIRECT_IREGS \ xreg a, xreg b, xreg c, xreg d, \ UWORD si, UWORD di, UWORD bp, UWORD ds, UWORD es, \ UWORD ip, UWORD cs, UWORD flags - - /* Process control block for task switching */ -typedef struct -{ +typedef struct { UWORD pc_ss; UWORD pc_sp; iregs pc_regs; -} -pcb; +} pcb; /* Note: The following figure is not made by myself and I assume that the order of "ES" through "AX" are misinterpreted?! -- 2000/03/22 ska*/ diff --git a/hdr/portab.h b/hdr/portab.h index 4269ff26..5a202982 100644 --- a/hdr/portab.h +++ b/hdr/portab.h @@ -30,7 +30,8 @@ #ifdef MAIN #ifdef VERSION_STRINGS -static char *portab_hRcsId = "$Id$"; +static char *portab_hRcsId = + "$Id$"; #endif #endif @@ -57,84 +58,71 @@ static char *portab_hRcsId = "$Id$"; /* */ /****************************************************************/ - - /* commandline overflow - removing -DI86 TE*/ + /* commandline overflow - removing -DI86 TE */ #if defined(__TURBOC__) - #define I86 - #define CDECL cdecl - void __int__(int); - -#elif defined (_MSC_VER) +#define I86 +#define CDECL cdecl +void __int__(int); + +#elif defined (_MSC_VER) + +#define I86 +#define CDECL _cdecl +#define __int__(intno) asm int intno; - #define I86 - #define CDECL _cdecl - #define __int__(intno) asm int intno; +#if defined(M_I286) /* /G3 doesn't set M_I386, but sets M_I286 TE */ +#define I386 +#endif - #if defined(M_I286) /* /G3 doesn't set M_I386, but sets M_I286 TE*/ - #define I386 - #endif +#elif defined(__WATCOMC__) /* don't know a better way */ -#elif defined(__WATCOMC__) /* don't know a better way */ +#define I86 +#define __int__(intno) asm int intno; +#define asm __asm +#define far __far +#define CDECL __cdecl - #define I86 - #define __int__(intno) asm int intno; - #define asm __asm - #define far __far - #define CDECL __cdecl - - #if _M_IX86 >= 300 - #define I386 - #endif +#if _M_IX86 >= 300 +#define I386 +#endif #elif defined (_MYMC68K_COMILER_) - #define MC68K +#define MC68K -#else - anyone knows a _portable_ way to create nice errors?? - at least this causes the compiler not to compile :-) +#else +anyone knows a _portable_ way to create nice errors ? ? + at least this causes the compiler not to compile : -) #endif /* functions, that are shared between C and ASM _must_ - have a certain calling standard. These are declared - as 'ASMCFUNC', and is (and will be ?-) cdecl */ + have a certain calling standard. These are declared + as 'ASMCFUNC', and is (and will be ?-) cdecl */ #define ASMCFUNC cdecl - #ifdef MC68K - #define far /* No far type */ #define interrupt /* No interrupt type */ - #define VOID void #define FAR /* linear architecture */ #define NEAR /* " " */ #define INRPT interrupt - #define CONST #define REG register - #define API int /* linear architecture */ #define NONNATIVE - #define PARASIZE 4096 /* "paragraph" size */ #endif - #ifdef I86 - #define VOID void #define FAR far /* segment architecture */ #define NEAR near /* " " */ #define INRPT interrupt - #define CONST const #define REG register - -#define API int far pascal /* segment architecture */ +#define API int far pascal /* segment architecture */ #define NATIVE - #define PARASIZE 16 /* "paragraph" size */ #endif - /* */ /* Boolean type & definitions of TRUE and FALSE boolean values */ /* */ @@ -186,8 +174,7 @@ typedef unsigned short CLUSTER; #endif typedef unsigned short UNICODE; -#define STATIC /* local calls inside module */ - +#define STATIC /* local calls inside module */ #ifdef UNIX typedef char FAR *ADDRESS; @@ -220,16 +207,16 @@ typedef signed long LONG; this suppresses the warning unreferenced parameter 'x' and (hopefully) generates no code -*/ +*/ #if defined(__TURBOC__) - #define UNREFERENCED_PARAMETER(x) if (x); -#else - #define UNREFERENCED_PARAMETER(x) x; -#endif +#define UNREFERENCED_PARAMETER(x) if (x); +#else +#define UNREFERENCED_PARAMETER(x) x; +#endif -#ifdef I86 /* commandline overflow - removing /DPROTO TE*/ - #define PROTO +#ifdef I86 /* commandline overflow - removing /DPROTO TE */ +#define PROTO #endif /* diff --git a/hdr/process.h b/hdr/process.h index 6c8da928..5cd99cf3 100644 --- a/hdr/process.h +++ b/hdr/process.h @@ -30,7 +30,8 @@ #ifdef MAIN #ifdef VERSION_STRINGS -static BYTE *process_hRcsId = "$Id$"; +static BYTE *process_hRcsId = + "$Id$"; #endif #endif @@ -40,36 +41,27 @@ static BYTE *process_hRcsId = "$Id$"; #define P_NOWAIT 1 /* both concurrent -- not implemented */ #define P_OVERLAY 2 /* child replaces parent, parent no longer exists */ -typedef struct -{ - union - { - struct - { +typedef struct { + union { + struct { UWORD load_seg; UWORD reloc; - } - _load; - struct - { + } _load; + struct { UWORD env_seg; CommandTail FAR *cmd_line; fcb FAR *fcb_1; fcb FAR *fcb_2; BYTE FAR *stack; BYTE FAR *start_addr; - } - _exec; - } - ldata; -} -exec_blk; + } _exec; + } ldata; +} exec_blk; #define exec ldata._exec #define load ldata._load -typedef struct -{ +typedef struct { UWORD ps_exit; /* 00 CP/M-like exit poimt */ UWORD ps_size; /* 02 memory size in paragraphs */ BYTE ps_fill1; /* 04 single char fill */ @@ -77,9 +69,9 @@ typedef struct /* CP/M-like entry point */ UBYTE ps_farcall; /* 05 far call opcode */ VOID(FAR * ps_reentry) (); /* 06 re-entry point */ - VOID(interrupt FAR * ps_isv22) (),/* 0a terminate address */ - (interrupt FAR * ps_isv23) (), /* 0e break address */ - (interrupt FAR * ps_isv24) (); /* 12 critical error address */ + VOID(interrupt FAR * ps_isv22) (), /* 0a terminate address */ + (interrupt FAR * ps_isv23) (), /* 0e break address */ + (interrupt FAR * ps_isv24) (); /* 12 critical error address */ UWORD ps_parent; /* 16 parent psp segment */ UBYTE ps_files[20]; /* 18 file table - 0xff is unused */ UWORD ps_environ; /* 2c environment paragraph */ @@ -89,39 +81,25 @@ typedef struct VOID FAR *ps_prevpsp; /* 38 previous psp pointer */ BYTE FAR *ps_dta; /* 3c process dta address */ BYTE ps_fill2[16]; - UBYTE ps_unix[3]; /* unix style call - 0xcd 0x21 0xcb */ + UBYTE ps_unix[3]; /* unix style call - 0xcd 0x21 0xcb */ BYTE ps_fill3[9]; - union - { - struct - { - fcb - _ps_fcb1; /* first command line argument */ - } - _u1; - struct - { - BYTE - fill4[16]; - fcb - _ps_fcb2; /* second command line argument */ - } - _u2; - struct - { + union { + struct { + fcb _ps_fcb1; /* first command line argument */ + } _u1; + struct { + BYTE fill4[16]; + fcb _ps_fcb2; /* second command line argument */ + } _u2; + struct { BYTE fill5[36]; - struct - { + struct { BYTE _ps_cmd_count; BYTE _ps_cmd[127]; /* command tail */ - } - _u4; - } - _u3; - } - _u; -} -psp; + } _u4; + } _u3; + } _u; +} psp; #define ps_fcb1 _u._u1._ps_fcb1 #define ps_fcb2 _u._u2._ps_fcb2 diff --git a/hdr/sft.h b/hdr/sft.h index c91a53d8..98c5dcc4 100644 --- a/hdr/sft.h +++ b/hdr/sft.h @@ -29,16 +29,15 @@ #ifdef MAIN #ifdef VERSION_STRINGS -static BYTE *sft_hRcsId = "$Id$"; +static BYTE *sft_hRcsId = + "$Id$"; #endif #endif - #define SFTMAX 128 /* Handle Definition entry */ -typedef struct -{ +typedef struct { WORD sft_count; /* 00 - reference count */ WORD sft_mode; /* 02 - open mode - see below */ BYTE sft_attrib; /* 04 - file attribute - dir style */ @@ -46,24 +45,17 @@ typedef struct union /* 05 */ { WORD _sft_flags; - struct - { + struct { BYTE _sft_flags_lo; BYTE _sft_flags_hi; - } - _split_sft_flags; - } - sft_flags_union; + } _split_sft_flags; + } sft_flags_union; union /* 07 */ { - struct dpb FAR * - _sft_dcb; /* The device control block */ - struct dhdr FAR * - _sft_dev; /* device driver for char dev */ - } - - sft_dcb_or_dev; + struct dpb FAR *_sft_dcb; /* The device control block */ + struct dhdr FAR *_sft_dev; /* device driver for char dev */ + } sft_dcb_or_dev; WORD sft_stclust; /* 0b - Starting cluster */ time sft_time; /* 0d - File time */ date sft_date; /* 0f - File date */ @@ -74,36 +66,30 @@ typedef struct WORD sft_dirdlust; /* 1d - Sector containing cluster */ BYTE sft_diridx; /* 1f - directory index */ BYTE sft_name[11]; /* 20 - dir style file name */ - BYTE FAR * - sft_bshare; /* 2b - backward link of file sharing sft */ + BYTE FAR *sft_bshare; /* 2b - backward link of file sharing sft */ WORD sft_mach; /* 2f - machine number - network apps */ WORD sft_psp; /* 31 - owner psp */ WORD sft_shroff; /* 33 - Sharing offset */ WORD sft_status; /* 35 - this sft status */ - BYTE FAR * sft_ifsptr; /* 37 - pointer to IFS driver for file, 0000000h if native DOS */ -} -sft; + BYTE FAR *sft_ifsptr; /* 37 - pointer to IFS driver for file, 0000000h if native DOS */ +} sft; /* SFT Table header definition */ -typedef struct _sftheader -{ +typedef struct _sftheader { struct _sfttbl FAR * /* link to next table in list */ sftt_next; WORD sftt_count; /* # of handle definition */ /* entries, this table */ -} -sftheader; +} sftheader; /* System File Definition List */ -typedef struct _sfttbl -{ +typedef struct _sfttbl { struct _sfttbl FAR * /* link to next table in list */ sftt_next; WORD sftt_count; /* # of handle definition */ /* entries, this table */ sft sftt_table[SFTMAX]; /* The array of sft for block */ -} -sfttbl; +} sfttbl; /* defines for sft use */ #define SFT_MASK 0x0060 /* splits device data */ @@ -153,7 +139,6 @@ sfttbl; #define sft_flags_hi sft_flags_union._split_sft_flags._sft_flags_hi #define sft_flags_lo sft_flags_union._split_sft_flags._sft_flags_lo - /* * Log: sft.h,v * diff --git a/hdr/tail.h b/hdr/tail.h index 3577f448..2b36d281 100644 --- a/hdr/tail.h +++ b/hdr/tail.h @@ -30,21 +30,19 @@ #ifdef MAIN #ifdef VERSION_STRINGS -static BYTE *tail_hRcsId = "$Id$"; +static BYTE *tail_hRcsId = + "$Id$"; #endif #endif - #ifndef LINESIZE #define LINESIZE 127 #endif -typedef struct -{ +typedef struct { UBYTE ctCount; /* number of bytes returned */ BYTE ctBuffer[LINESIZE]; /* the buffer itself */ -} -CommandTail; +} CommandTail; /* * Log: tail.h,v diff --git a/hdr/time.h b/hdr/time.h index 8ee7f45a..951450a5 100644 --- a/hdr/time.h +++ b/hdr/time.h @@ -34,7 +34,8 @@ #ifdef MAIN #ifdef VERSION_STRINGS -static BYTE *time_hRcsId = "$Id$"; +static BYTE *time_hRcsId = + "$Id$"; #endif #endif @@ -87,4 +88,3 @@ typedef UWORD time; * Rev 1.0 02 Jul 1995 10:39:56 patv * Initial revision. */ - diff --git a/hdr/version.h b/hdr/version.h index e953a81d..f98d5423 100644 --- a/hdr/version.h +++ b/hdr/version.h @@ -28,7 +28,8 @@ #ifdef MAIN #ifdef VERSION_STRINGS -static BYTE *date_hRcsId = "$Id$"; +static BYTE *date_hRcsId = + "$Id$"; #endif #endif @@ -45,5 +46,5 @@ static BYTE *date_hRcsId = "$Id$"; #define REVISION_SEQ 25 #define BUILD "2025" #define SUB_BUILD "b" -#define KERNEL_VERSION_STRING "1.1.25b" /*#REVISION_MAJOR "." #REVISION_MINOR "." #REVISION_SEQ*/ -#define KERNEL_BUILD_STRING "2025b" /*#BUILD SUB_BUILD*/ +#define KERNEL_VERSION_STRING "1.1.25b" /*#REVISION_MAJOR "." #REVISION_MINOR "." #REVISION_SEQ */ +#define KERNEL_BUILD_STRING "2025b" /*#BUILD SUB_BUILD */ diff --git a/hdr/xstructs.h b/hdr/xstructs.h index 4b0d6315..90310a58 100644 --- a/hdr/xstructs.h +++ b/hdr/xstructs.h @@ -8,54 +8,52 @@ #ifdef MAIN #ifdef VERSION_STRINGS -static BYTE *XStructs_hRcsId = "$Id$"; +static BYTE *XStructs_hRcsId = + "$Id$"; #endif #endif -struct xdpbdata -{ - UWORD xdd_dpbsize; +struct xdpbdata { + UWORD xdd_dpbsize; struct dpb xdd_dpb; }; -struct xfreespace -{ - UWORD xfs_datasize; /* size of this structure */ +struct xfreespace { + UWORD xfs_datasize; /* size of this structure */ union { - UWORD requested; /* requested structure version */ - UWORD actual; /* actual structure version */ + UWORD requested; /* requested structure version */ + UWORD actual; /* actual structure version */ } xfs_version; - ULONG xfs_clussize; /* number of sectors per cluster */ - ULONG xfs_secsize; /* number of bytes per sector */ - ULONG xfs_freeclusters; /* number of available clusters */ - ULONG xfs_totalclusters; /* total number of clusters on the drive */ - ULONG xfs_freesectors; /* number of physical sectors available */ - ULONG xfs_totalsectors; /* total number of physical sectors */ - ULONG xfs_freeunits; /* number of available allocation units */ - ULONG xfs_totalunits; /* total allocation units */ + ULONG xfs_clussize; /* number of sectors per cluster */ + ULONG xfs_secsize; /* number of bytes per sector */ + ULONG xfs_freeclusters; /* number of available clusters */ + ULONG xfs_totalclusters; /* total number of clusters on the drive */ + ULONG xfs_freesectors; /* number of physical sectors available */ + ULONG xfs_totalsectors; /* total number of physical sectors */ + ULONG xfs_freeunits; /* number of available allocation units */ + ULONG xfs_totalunits; /* total allocation units */ UBYTE xfs_reserved[8]; }; -struct xdpbforformat -{ - UWORD xdff_datasize; /* size of this structure */ +struct xdpbforformat { + UWORD xdff_datasize; /* size of this structure */ union { - UWORD requested; /* requested structure version */ - UWORD actual; /* actual structure version */ + UWORD requested; /* requested structure version */ + UWORD actual; /* actual structure version */ } xdff_version; - UDWORD xdff_function; /* function number: - 00h invalidate DPB counts - 01h rebuild DPB from BPB - 02h force media change - 03h get/set active FAT number and mirroring - 04h get/set root directory cluster number - */ + UDWORD xdff_function; /* function number: + 00h invalidate DPB counts + 01h rebuild DPB from BPB + 02h force media change + 03h get/set active FAT number and mirroring + 04h get/set root directory cluster number + */ union { struct { - DWORD nfreeclst; /* # free clusters - (-1 - unknown, 0 - don't change) */ - DWORD cluster; /* cluster # of first free - (-1 - unknown, 0 - don't change) */ + DWORD nfreeclst; /* # free clusters + (-1 - unknown, 0 - don't change) */ + DWORD cluster; /* cluster # of first free + (-1 - unknown, 0 - don't change) */ UDWORD reserved[2]; } setdpbcounts; @@ -66,18 +64,18 @@ struct xdpbforformat } rebuilddpb; struct { - DWORD newmirroring; /* new active FAT/mirroring state, or -1 to get - bits 3-0: the 0-based FAT number of the active FAT - bits 6-4: reserved (0) - bit 7: do not mirror active FAT to inactive FATs - */ - DWORD oldmirroring; /* previous active FAT/mirroring state (as above) */ + DWORD newmirroring; /* new active FAT/mirroring state, or -1 to get + bits 3-0: the 0-based FAT number of the active FAT + bits 6-4: reserved (0) + bit 7: do not mirror active FAT to inactive FATs + */ + DWORD oldmirroring; /* previous active FAT/mirroring state (as above) */ UDWORD reserved[2]; } setmirroring; struct { - DWORD newrootclst; /* set new root directory cluster, -1 - get current */ - DWORD oldrootclst; /* get previous root directory cluster */ + DWORD newrootclst; /* set new root directory cluster, -1 - get current */ + DWORD oldrootclst; /* get previous root directory cluster */ UDWORD reserved[2]; } setroot; } xdff_f; diff --git a/kernel/blockio.c b/kernel/blockio.c index 1f4d5406..7a78e7ba 100644 --- a/kernel/blockio.c +++ b/kernel/blockio.c @@ -32,9 +32,10 @@ #include "globals.h" #ifdef VERSION_STRINGS -static BYTE *blockioRcsId = "$Id$"; +static BYTE *blockioRcsId = + "$Id$"; #endif - + /************************************************************************/ /* */ /* block cache routines */ @@ -42,7 +43,6 @@ static BYTE *blockioRcsId = "$Id$"; /************************************************************************/ /* #define DISPLAY_GETBLOCK */ - /* */ /* Initialize the buffer structure */ /* */ @@ -75,7 +75,7 @@ VOID FAR reloc_call_init_buffers(void) */ /* Extract the block number from a buffer structure. */ #if 0 /*TE*/ -ULONG getblkno(struct buffer FAR * bp) + ULONG getblkno(struct buffer FAR * bp) { if (bp->b_blkno == 0xffffu) return bp->b_huge_blkno; @@ -89,7 +89,7 @@ ULONG getblkno(struct buffer FAR * bp) /* Set the block number of a buffer structure. (The caller should */ /* set the unit number before calling this function.) */ #if 0 /*TE*/ -VOID setblkno(struct buffer FAR * bp, ULONG blkno) + VOID setblkno(struct buffer FAR * bp, ULONG blkno) { if (blkno >= 0xffffu) { @@ -101,7 +101,7 @@ VOID setblkno(struct buffer FAR * bp, ULONG blkno) bp->b_blkno = blkno; /* bp->b_dpbp = &blk_devices[bp->b_unit]; */ - bp->b_dpbp = CDSp->cds_table[bp->b_unit].cdsDpb; + bp->b_dpbp = CDSp->cds_table[bp->b_unit].cdsDpb; } } @@ -124,38 +124,34 @@ VOID setblkno(struct buffer FAR * bp, ULONG blkno) UNCACHE buffers are recycled first. intended to be used for full sector reads into application buffer -*/ +*/ -BOOL searchblock(ULONG blkno, COUNT dsk, - struct buffer FAR ** pBuffp) +BOOL searchblock(ULONG blkno, COUNT dsk, struct buffer FAR ** pBuffp) { - int fat_count = 0; - struct buffer FAR *bp; - struct buffer FAR *lbp = NULL; - struct buffer FAR *lastNonFat = NULL; - struct buffer FAR *uncacheBuf = NULL; + int fat_count = 0; + struct buffer FAR *bp; + struct buffer FAR *lbp = NULL; + struct buffer FAR *lastNonFat = NULL; + struct buffer FAR *uncacheBuf = NULL; - #ifdef DISPLAY_GETBLOCK - printf("[searchblock %d, blk %ld, buf ", dsk, blkno); + printf("[searchblock %d, blk %ld, buf ", dsk, blkno); #endif - - /* Search through buffers to see if the required block */ /* is already in a buffer */ - for (bp = firstbuf; bp != NULL;lbp = bp, bp = bp->b_next) + for (bp = firstbuf; bp != NULL; lbp = bp, bp = bp->b_next) { - if ((getblkno(bp) == blkno) && + if ((getblkno(bp) == blkno) && (bp->b_flag & BFR_VALID) && (bp->b_unit == dsk)) { /* found it -- rearrange LRU links */ if (lbp != NULL) { - lbp->b_next = bp->b_next; - bp->b_next = firstbuf; - firstbuf = bp; + lbp->b_next = bp->b_next; + bp->b_next = firstbuf; + firstbuf = bp; } #ifdef DISPLAY_GETBLOCK printf("HIT %04x:%04x]\n", FP_SEG(bp), FP_OFF(bp)); @@ -165,92 +161,87 @@ BOOL searchblock(ULONG blkno, COUNT dsk, } if (bp->b_flag & BFR_UNCACHE) - uncacheBuf = bp; - + uncacheBuf = bp; if (bp->b_flag & BFR_FAT) - fat_count++; + fat_count++; else - lastNonFat = bp; + lastNonFat = bp; } - + /* - now take either the last buffer in chain (not used recently) - or, if we are low on FAT buffers, the last non FAT buffer - */ + now take either the last buffer in chain (not used recently) + or, if we are low on FAT buffers, the last non FAT buffer + */ - if (uncacheBuf) + if (uncacheBuf) { - lbp = uncacheBuf; - } - else + lbp = uncacheBuf; + } + else { - if (lbp ->b_flag & BFR_FAT && fat_count < 3 && lastNonFat) + if (lbp->b_flag & BFR_FAT && fat_count < 3 && lastNonFat) { - lbp = lastNonFat; + lbp = lastNonFat; } - } - - lbp->b_flag &= ~BFR_UNCACHE; /* reset uncache attribute */ - + } + + lbp->b_flag &= ~BFR_UNCACHE; /* reset uncache attribute */ + *pBuffp = lbp; - + #ifdef DISPLAY_GETBLOCK printf("MISS, replace %04x:%04x]\n", FP_SEG(lbp), FP_OFF(lbp)); #endif - - - if (lbp != firstbuf) /* move to front */ - { + if (lbp != firstbuf) /* move to front */ + { for (bp = firstbuf; bp->b_next != lbp; bp = bp->b_next) - ; + ; bp->b_next = bp->b_next->b_next; lbp->b_next = firstbuf; firstbuf = lbp; - } - + } + return FALSE; -} +} BOOL DeleteBlockInBufferCache(ULONG blknolow, ULONG blknohigh, COUNT dsk) { - struct buffer FAR *bp; + struct buffer FAR *bp; /* Search through buffers to see if the required block */ /* is already in a buffer */ for (bp = firstbuf; bp != NULL; bp = bp->b_next) { - if (blknolow <= getblkno(bp) && + if (blknolow <= getblkno(bp) && getblkno(bp) <= blknohigh && - (bp->b_flag & BFR_VALID) && (bp->b_unit == dsk)) + (bp->b_flag & BFR_VALID) && (bp->b_unit == dsk)) { - flush1(bp); + flush1(bp); } } - return FALSE; -} - + return FALSE; +} void dumpBufferCache(void) { - struct buffer FAR *bp; - int printed = 0; + struct buffer FAR *bp; + int printed = 0; /* Search through buffers to see if the required block */ /* is already in a buffer */ - for (bp = firstbuf; bp != NULL;bp = bp->b_next) + for (bp = firstbuf; bp != NULL; bp = bp->b_next) { - printf("%8lx %02x ",getblkno(bp),bp->b_flag); + printf("%8lx %02x ", getblkno(bp), bp->b_flag); if (++printed % 6 == 0) - printf("\n"); - } + printf("\n"); + } printf("\n"); -} - +} /* */ /* Return the address of a buffer structure containing the */ @@ -263,37 +254,34 @@ void dumpBufferCache(void) /* */ struct buffer FAR *getblock(ULONG blkno, COUNT dsk) { - struct buffer FAR *bp; - - + struct buffer FAR *bp; /* Search through buffers to see if the required block */ /* is already in a buffer */ - if (searchblock(blkno, dsk, &bp)) - { - return (bp); - } + if (searchblock(blkno, dsk, &bp)) + { + return (bp); + } /* The block we need is not in a buffer, we must make a buffer */ /* available, and fill it with the desired block */ - /* take the buffer that lbp points to and flush it, then read new block. */ if (!flush1(bp)) - return NULL; - - /* Fill the indicated disk buffer with the current track and sector */ + return NULL; + + /* Fill the indicated disk buffer with the current track and sector */ if (dskxfer(dsk, blkno, (VOID FAR *) bp->b_buffer, 1, DSKREAD)) - { - return NULL; - } + { + return NULL; + } bp->b_flag = BFR_VALID | BFR_DATA; bp->b_unit = dsk; setblkno(bp, blkno); - + return bp; } @@ -302,23 +290,23 @@ struct buffer FAR *getblock(ULONG blkno, COUNT dsk) exactly the same as getblock(), but the data will be completely overwritten. so there is no need to read from disk first */ -struct buffer FAR * getblockOver(ULONG blkno, COUNT dsk) +struct buffer FAR *getblockOver(ULONG blkno, COUNT dsk) { - struct buffer FAR *bp; + struct buffer FAR *bp; /* Search through buffers to see if the required block */ /* is already in a buffer */ - if (searchblock(blkno, dsk, &bp)) - { - return bp; - } + if (searchblock(blkno, dsk, &bp)) + { + return bp; + } /* The block we need is not in a buffer, we must make a buffer */ /* available. */ /* take the buffer than lbp points to and flush it, then make it available. */ - if (flush1(bp)) /* success */ + if (flush1(bp)) /* success */ { bp->b_flag = 0; bp->b_unit = dsk; @@ -331,6 +319,7 @@ struct buffer FAR * getblockOver(ULONG blkno, COUNT dsk) return NULL; } } + /* */ /* Mark all buffers for a disk as not valid */ /* */ @@ -374,14 +363,13 @@ BOOL flush_buffers(REG COUNT dsk) /* */ BOOL flush1(struct buffer FAR * bp) { -/* All lines with changes on 9/4/00 by BER marked below */ - - UWORD result; /* BER 9/4/00 */ +/* All lines with changes on 9/4/00 by BER marked below */ + + UWORD result; /* BER 9/4/00 */ if ((bp->b_flag & BFR_VALID) && (bp->b_flag & BFR_DIRTY)) { - result = dskxfer(bp->b_unit, getblkno(bp), - (VOID FAR *) bp->b_buffer, 1, DSKWRITE); /* BER 9/4/00 */ + result = dskxfer(bp->b_unit, getblkno(bp), (VOID FAR *) bp->b_buffer, 1, DSKWRITE); /* BER 9/4/00 */ if (bp->b_flag & BFR_FAT) { int i = bp->b_copies; @@ -390,19 +378,18 @@ BOOL flush1(struct buffer FAR * bp) while (--i > 0) { blkno += bp->b_offset; - result = dskxfer(bp->b_unit, blkno, - (VOID FAR *) bp->b_buffer, 1, DSKWRITE); /* BER 9/4/00 */ + result = dskxfer(bp->b_unit, blkno, (VOID FAR *) bp->b_buffer, 1, DSKWRITE); /* BER 9/4/00 */ } } } else - result = 0; /* This negates any error code returned in result...BER */ - /* and 0 returned, if no errors occurred - tom */ + result = 0; /* This negates any error code returned in result...BER */ + /* and 0 returned, if no errors occurred - tom */ bp->b_flag &= ~BFR_DIRTY; /* even if error, mark not dirty */ if (result != 0) /* otherwise system has trouble */ bp->b_flag &= ~BFR_VALID; /* continuing. */ - return (TRUE); /* Forced to TRUE...was like this before dskxfer() */ - /* returned error codes...BER */ + return (TRUE); /* Forced to TRUE...was like this before dskxfer() */ + /* returned error codes...BER */ } /* */ @@ -428,7 +415,6 @@ BOOL flush(void) return (ok); } - /************************************************************************/ /* */ /* Device Driver Interface Functions */ @@ -439,32 +425,33 @@ BOOL flush(void) /* */ /* Changed to UWORD 9/4/00 BER */ -UWORD dskxfer(COUNT dsk, ULONG blkno, VOID FAR * buf, UWORD numblocks, COUNT mode) +UWORD dskxfer(COUNT dsk, ULONG blkno, VOID FAR * buf, UWORD numblocks, + COUNT mode) /* End of change */ { /* REG struct dpb *dpbp = &blk_devices[dsk]; */ REG struct dpb FAR *dpbp = CDSp->cds_table[dsk].cdsDpb; - - if ((UCOUNT)dsk >= lastdrive ) - { - return 0x0201; /* illegal command */ - } + if ((UCOUNT) dsk >= lastdrive) + { + return 0x0201; /* illegal command */ + } if (!(CDSp->cds_table[dsk].cdsFlags & CDSPHYSDRV)) - { - return 0x0201; /* illegal command */ - } - + { + return 0x0201; /* illegal command */ + } + #if TOM #define KeyboardShiftState() (*(BYTE FAR *)(MK_FP(0x40,0x17))) if (KeyboardShiftState() & 0x01) - { - printf("dskxfer:%s %x - %lx %u\n", mode == DSKWRITE ? "write" : "read", dsk, blkno, numblocks); + { + printf("dskxfer:%s %x - %lx %u\n", mode == DSKWRITE ? "write" : "read", + dsk, blkno, numblocks); if ((KeyboardShiftState() & 0x03) == 3) - dumpBufferCache(); - } + dumpBufferCache(); + } #endif for (;;) @@ -472,18 +459,27 @@ UWORD dskxfer(COUNT dsk, ULONG blkno, VOID FAR * buf, UWORD numblocks, COUNT mod IoReqHdr.r_length = sizeof(request); IoReqHdr.r_unit = dpbp->dpb_subunit; - switch(mode) + switch (mode) + { + case DSKWRITE: + if (verify_ena) { - case DSKWRITE : if (verify_ena) { IoReqHdr.r_command = C_OUTVFY; break; } - /* else fall through */ - case DSKWRITEINT26: IoReqHdr.r_command = C_OUTPUT; break; - - case DSKREADINT25: - case DSKREAD : IoReqHdr.r_command = C_INPUT; break; - default: - return 0x0100; /* illegal command */ - } - + IoReqHdr.r_command = C_OUTVFY; + break; + } + /* else fall through */ + case DSKWRITEINT26: + IoReqHdr.r_command = C_OUTPUT; + break; + + case DSKREADINT25: + case DSKREAD: + IoReqHdr.r_command = C_INPUT; + break; + default: + return 0x0100; /* illegal command */ + } + IoReqHdr.r_status = 0; IoReqHdr.r_meddesc = dpbp->dpb_mdb; IoReqHdr.r_trans = (BYTE FAR *) buf; @@ -499,46 +495,43 @@ UWORD dskxfer(COUNT dsk, ULONG blkno, VOID FAR * buf, UWORD numblocks, COUNT mod if (!(IoReqHdr.r_status & S_ERROR) && (IoReqHdr.r_status & S_DONE)) break; - /* INT25/26 (_SEEMS_ TO) return immediately with 0x8002, - if drive is not online,... - - normal operations (DIR) wait for ABORT/RETRY - - other condition codes not tested - */ + /* INT25/26 (_SEEMS_ TO) return immediately with 0x8002, + if drive is not online,... + + normal operations (DIR) wait for ABORT/RETRY + + other condition codes not tested + */ if (mode >= DSKWRITEINT26) - return (IoReqHdr.r_status); + return (IoReqHdr.r_status); /* Changed 9/4/00 BER return (IoReqHdr.r_status); */ - - - /* Skip the abort, retry, fail code...it needs fixed...BER */ /* End of change */ - loop: - switch (block_error(&IoReqHdr, dpbp->dpb_unit, dpbp->dpb_device)) - { - case ABORT: - case FAIL: - return (IoReqHdr.r_status); + loop: + switch (block_error(&IoReqHdr, dpbp->dpb_unit, dpbp->dpb_device)) + { + case ABORT: + case FAIL: + return (IoReqHdr.r_status); - case RETRY: - continue; + case RETRY: + continue; - case CONTINUE: - break; + case CONTINUE: + break; - default: - goto loop; - } + default: + goto loop; + } - } /* retry loop */ + } /* retry loop */ /* *** Changed 9/4/00 BER */ - return 0; /* Success! Return 0 for a successful operation. */ + return 0; /* Success! Return 0 for a successful operation. */ /* End of change */ } @@ -547,7 +540,7 @@ UWORD dskxfer(COUNT dsk, ULONG blkno, VOID FAR * buf, UWORD numblocks, COUNT mod * 2000/9/04 Brian Reifsnyder * Modified dskxfer() such that error codes are now returned. * Functions that rely on dskxfer() have also been modified accordingly. - */ + */ /* * Log: blockio.c,v - for newer entries do "cvs log blockio.c" diff --git a/kernel/break.c b/kernel/break.c index 48612e5c..c9e1c555 100644 --- a/kernel/break.c +++ b/kernel/break.c @@ -33,7 +33,8 @@ extern void ASMCFUNC spawn_int23(void); #ifdef VERSION_STRINGS -static BYTE *RcsId = "$Id$"; +static BYTE *RcsId = + "$Id$"; #endif #define CB_FLG *(UBYTE FAR*)MK_FP(0x40, 0x71) @@ -67,7 +68,7 @@ void handle_break(void) if (!ErrorMode) /* within int21_handler, InDOS is not incremented */ if (InDOS) --InDOS; /* fail-safe */ - + spawn_int23(); /* invoke user INT-23 and never come back */ } @@ -81,4 +82,3 @@ void handle_break(void) * Steffen contributed. * */ - diff --git a/kernel/chario.c b/kernel/chario.c index baf0d2e7..d8b45b63 100644 --- a/kernel/chario.c +++ b/kernel/chario.c @@ -31,7 +31,8 @@ #include "portab.h" #ifdef VERSION_STRINGS -static BYTE *charioRcsId = "$Id$"; +static BYTE *charioRcsId = + "$Id$"; #endif #include "globals.h" @@ -67,26 +68,28 @@ struct dhdr FAR *finddev(UWORD attr_mask) VOID _cso(COUNT c) { - if (syscon->dh_attr & ATTR_FASTCON) { - #if defined(__TURBOC__) - _AL = c; - __int__(0x29); - #else - asm { - mov al, byte ptr c; - int 0x29; - } - #endif - return; - } - CharReqHdr.r_length = sizeof(request); - CharReqHdr.r_command = C_OUTPUT; - CharReqHdr.r_count = 1; - CharReqHdr.r_trans = (BYTE FAR *) (&c); - CharReqHdr.r_status = 0; - execrh((request FAR *) & CharReqHdr, syscon); - if (CharReqHdr.r_status & S_ERROR) - char_error(&CharReqHdr, syscon); + if (syscon->dh_attr & ATTR_FASTCON) + { +#if defined(__TURBOC__) + _AL = c; + __int__(0x29); +#else + asm + { + mov al, byte ptr c; + int 0x29; + } +#endif + return; + } + CharReqHdr.r_length = sizeof(request); + CharReqHdr.r_command = C_OUTPUT; + CharReqHdr.r_count = 1; + CharReqHdr.r_trans = (BYTE FAR *) (&c); + CharReqHdr.r_status = 0; + execrh((request FAR *) & CharReqHdr, syscon); + if (CharReqHdr.r_status & S_ERROR) + char_error(&CharReqHdr, syscon); } VOID cso(COUNT c) @@ -95,7 +98,7 @@ VOID cso(COUNT c) con_hold(); if (PrinterEcho) - DosWrite(STDPRN, 1, (BYTE FAR *) & c, (COUNT FAR *) &UnusedRetVal); + DosWrite(STDPRN, 1, (BYTE FAR *) & c, (COUNT FAR *) & UnusedRetVal); switch (c) { @@ -106,20 +109,24 @@ VOID cso(COUNT c) case BELL: break; case BS: - if (scr_pos > 0) scr_pos--; + if (scr_pos > 0) + scr_pos--; break; case HT: - do _cso(' '); while ((++scr_pos) & 7); + do + _cso(' '); + while ((++scr_pos) & 7); break; default: scr_pos++; } - if (c != HT) _cso(c); + if (c != HT) + _cso(c); } VOID sto(COUNT c) { - DosWrite(STDOUT, 1, (BYTE FAR *) & c, (COUNT FAR *) &UnusedRetVal); + DosWrite(STDOUT, 1, (BYTE FAR *) & c, (COUNT FAR *) & UnusedRetVal); } VOID mod_cso(REG UCOUNT c) @@ -169,11 +176,11 @@ COUNT ndread(void) COUNT con_read(void) { BYTE c; - + CharReqHdr.r_length = sizeof(request); CharReqHdr.r_command = C_INPUT; CharReqHdr.r_count = 1; - CharReqHdr.r_trans = (BYTE FAR *)&c; + CharReqHdr.r_trans = (BYTE FAR *) & c; CharReqHdr.r_status = 0; execrh((request FAR *) & CharReqHdr, syscon); if (CharReqHdr.r_status & S_ERROR) @@ -186,7 +193,7 @@ COUNT con_read(void) VOID con_hold(void) { UBYTE c = ndread(); - if(c == CTL_S) + if (c == CTL_S) { con_read(); Do_DosIdle_loop(); @@ -210,8 +217,9 @@ UCOUNT _sti(BOOL check_break) Do_DosIdle_loop(); if (check_break) con_hold(); - while (GenericRead(STDIN, 1, (BYTE FAR *) & c, (COUNT FAR *) & UnusedRetVal, TRUE) - != 1) ; + while (GenericRead + (STDIN, 1, (BYTE FAR *) & c, (COUNT FAR *) & UnusedRetVal, + TRUE) != 1) ; return c; } @@ -285,11 +293,9 @@ static VOID kbfill(keyboard FAR * kp, UCOUNT c, BOOL ctlf, UWORD * vp) /* return number of characters before EOF if there is one, else just the total */ UCOUNT sti_0a(keyboard FAR * kp) { - REG UWORD c, - cu_pos = scr_pos; - UWORD - virt_pos = scr_pos; - UWORD init_count = 0; /* kp->kb_count; */ + REG UWORD c, cu_pos = scr_pos; + UWORD virt_pos = scr_pos; + UWORD init_count = 0; /* kp->kb_count; */ BOOL eof = FALSE; #ifndef NOSPCL static BYTE local_buffer[LINESIZE]; @@ -327,7 +333,7 @@ UCOUNT sti_0a(keyboard FAR * kp) break; } - case F1: + case F1: case RIGHT: c = local_buffer[kp->kb_count]; if (c) @@ -377,7 +383,7 @@ UCOUNT sti_0a(keyboard FAR * kp) return eof; else return kp->kb_count--; - + case LF: break; @@ -406,7 +412,7 @@ UCOUNT sti(keyboard * kp) UCOUNT ReadCount = sti_0a(kp); kp->kb_count++; - if (ReadCount >= kp->kb_count && kp->kb_count < kp->kb_size) + if (ReadCount >= kp->kb_count && kp->kb_count < kp->kb_size) { kp->kb_buf[kp->kb_count++] = LF; cso(LF); @@ -483,4 +489,3 @@ UCOUNT sti(keyboard * kp) * Initial revision. * */ - diff --git a/kernel/config.c b/kernel/config.c index b15b2e35..3c9daf80 100644 --- a/kernel/config.c +++ b/kernel/config.c @@ -33,14 +33,15 @@ #include "dyndata.h" #ifdef VERSION_STRINGS -static BYTE *RcsId = "$Id$"; +static BYTE *RcsId = + "$Id$"; #endif #ifdef DEBUG - #define DebugPrintf(x) printf x -#else - #define DebugPrintf(x) -#endif +#define DebugPrintf(x) printf x +#else +#define DebugPrintf(x) +#endif #ifdef KDB #include @@ -56,86 +57,77 @@ static BYTE *RcsId = "$Id$"; -- Bart */ -extern f_node_ptr DOSFAR f_nodes; /* pointer to the array */ -extern UWORD DOSFAR f_nodes_cnt, /* number of allocated f_nodes */ - DOSFAR first_mcb; /* Start of user memory */ +extern f_node_ptr DOSFAR f_nodes; /* pointer to the array */ +extern UWORD DOSFAR f_nodes_cnt, /* number of allocated f_nodes */ + DOSFAR first_mcb; /* Start of user memory */ extern UBYTE DOSFAR lastdrive, DOSFAR nblkdev, DOSFAR mem_access_mode, - DOSFAR uppermem_link; -extern struct dhdr - DOSTEXTFAR blk_dev, /* Block device (Disk) driver */ - DOSFAR nul_dev; -extern struct buffer FAR * DOSFAR firstbuf; /* head of buffers linked list */ + DOSFAR uppermem_link; +extern struct dhdr +DOSTEXTFAR blk_dev, /* Block device (Disk) driver */ + DOSFAR nul_dev; +extern struct buffer FAR *DOSFAR firstbuf; /* head of buffers linked list */ -extern struct dpb FAR * DOSFAR DPBp; +extern struct dpb FAR *DOSFAR DPBp; /* First drive Parameter Block */ -extern cdstbl FAR * DOSFAR CDSp; +extern cdstbl FAR *DOSFAR CDSp; /* Current Directory Structure */ -extern sfttbl FAR * DOSFAR sfthead; +extern sfttbl FAR *DOSFAR sfthead; /* System File Table head */ -extern sfttbl FAR * DOSFAR FCBp; - -extern BYTE DOSFAR VgaSet, - DOSFAR _HMATextAvailable, /* first byte of available CODE area */ - FAR _HMATextStart[], /* first byte of HMAable CODE area */ - FAR _HMATextEnd[], - DOSFAR break_ena, /* break enabled flag */ - DOSFAR os_major, /* major version number */ - DOSFAR os_minor, /* minor version number */ - DOSFAR switchar, - DOSFAR _InitTextStart, /* first available byte of ram */ - DOSFAR ReturnAnyDosVersionExpected; - -extern UWORD DOSFAR ram_top, /* How much ram in Kbytes */ +extern sfttbl FAR *DOSFAR FCBp; + +extern BYTE DOSFAR VgaSet, DOSFAR _HMATextAvailable, /* first byte of available CODE area */ + FAR _HMATextStart[], /* first byte of HMAable CODE area */ + FAR _HMATextEnd[], DOSFAR break_ena, /* break enabled flag */ + DOSFAR os_major, /* major version number */ + DOSFAR os_minor, /* minor version number */ + DOSFAR switchar, DOSFAR _InitTextStart, /* first available byte of ram */ + DOSFAR ReturnAnyDosVersionExpected; + +extern UWORD DOSFAR ram_top, /* How much ram in Kbytes */ + DOSFAR UMB_top, - DOSFAR umb_start, - DOSFAR uppermem_root, - DOSFAR LoL_nbuffers; - -struct config Config - = - { - NUMBUFF, - NFILES, - NFCBS, - 0, - "command.com", - " /P /E:256\r\n", - NLAST, - NSTACKS, - 128 - /* COUNTRY= is initialized within DoConfig() */ - ,0 /* country ID */ - ,0 /* codepage */ - ,"" /* filename */ - ,0 /* amount required memory */ - ,0 /* pointer to loaded data */ - ,0 /* strategy for command.com is low by default */ - } -; - /* MSC places uninitialized data into COMDEF records, - that end up in DATA segment. this can't be tolerated - in INIT code. - please make sure, that ALL data in INIT is initialized !! - */ + DOSFAR umb_start, DOSFAR uppermem_root, DOSFAR LoL_nbuffers; + +struct config Config = { + NUMBUFF, + NFILES, + NFCBS, + 0, + "command.com", + " /P /E:256\r\n", + NLAST, + NSTACKS, + 128 + /* COUNTRY= is initialized within DoConfig() */ + , 0 /* country ID */ + , 0 /* codepage */ + , "" /* filename */ + , 0 /* amount required memory */ + , 0 /* pointer to loaded data */ + , 0 /* strategy for command.com is low by default */ +}; + /* MSC places uninitialized data into COMDEF records, + that end up in DATA segment. this can't be tolerated + in INIT code. + please make sure, that ALL data in INIT is initialized !! + */ BYTE FAR *lpBase = 0; BYTE FAR *upBase = 0; -BYTE FAR *lpTop = 0; +BYTE FAR *lpTop = 0; BYTE FAR *lpOldTop = 0; STATIC COUNT nCfgLine = 0; STATIC COUNT nPass = 0; - COUNT UmbState = 0; -STATIC BYTE szLine[256] = {0}; -STATIC BYTE szBuf[256] = {0}; - -BYTE singleStep = FALSE; /* F8 processing */ -BYTE SkipAllConfig = FALSE; /* F5 processing */ -BYTE askThisSingleCommand = FALSE; /* ?device= device?= */ - +COUNT UmbState = 0; +STATIC BYTE szLine[256] = { 0 }; +STATIC BYTE szBuf[256] = { 0 }; +BYTE singleStep = FALSE; /* F8 processing */ +BYTE SkipAllConfig = FALSE; /* F5 processing */ +BYTE askThisSingleCommand = FALSE; /* ?device= device?= */ -INIT VOID zumcb_init(UCOUNT seg, UWORD size); -INIT VOID mumcb_init(UCOUNT seg, UWORD size); +INIT VOID zumcb_init(UCOUNT seg, UWORD size); +INIT VOID mumcb_init(UCOUNT seg, UWORD size); INIT VOID Config_Buffers(BYTE * pLine); INIT VOID sysScreenMode(BYTE * pLine); @@ -162,10 +154,10 @@ INIT struct dhdr FAR *linkdev(struct dhdr FAR * dhp); INIT UWORD initdev(struct dhdr FAR * dhp, BYTE FAR * cmdTail); INIT int SkipLine(char *pLine); INIT char *stristr(char *s1, char *s2); -INIT COUNT strcasecmp(REG BYTE *d, REG BYTE *s); +INIT COUNT strcasecmp(REG BYTE * d, REG BYTE * s); extern void HMAconfig(int finalize); -VOID config_init_buffers(COUNT anzBuffers); /* from BLOCKIO.C */ +VOID config_init_buffers(COUNT anzBuffers); /* from BLOCKIO.C */ INIT STATIC VOID FAR *AlignParagraph(VOID FAR * lpPtr); #ifndef I86 @@ -176,15 +168,13 @@ INIT STATIC VOID FAR *AlignParagraph(VOID FAR * lpPtr); INIT struct table *LookUp(struct table *p, BYTE * token); -struct table -{ +struct table { BYTE *entry; BYTE pass; VOID(*func) (BYTE * pLine); }; -STATIC struct table commands[] = -{ +STATIC struct table commands[] = { {"BREAK", 1, CfgBreak}, {"BUFFERS", 1, Config_Buffers}, {"COMMAND", 1, InitPgm}, @@ -196,7 +186,7 @@ STATIC struct table commands[] = {"FILES", 1, Files}, {"LASTDRIVE", 1, CfgLastdrive}, {"NUMLOCK", 1, Numlock}, - /* rem is never executed by locking out pass */ + /* rem is never executed by locking out pass */ {"REM", 0, CfgFailure}, {";", 0, CfgFailure}, {"SHELL", 1, InitPgm}, @@ -205,8 +195,8 @@ STATIC struct table commands[] = {"SWITCHAR", 1, CfgSwitchar}, {"SCREEN", 1, sysScreenMode}, /* JPP */ {"VERSION", 1, sysVersion}, /* JPP */ - {"ANYDOS", 1, SetAnyDos}, /* JPP */ - /* default action */ + {"ANYDOS", 1, SetAnyDos}, /* JPP */ + /* default action */ {"", -1, CfgFailure} }; @@ -218,23 +208,24 @@ INIT BYTE FAR *KernelAllocDma(WORD); BYTE *pLineStart = 0; BYTE HMAState = 0; -#define HMA_NONE 0 /* do nothing */ -#define HMA_REQ 1 /* DOS = HIGH detected */ -#define HMA_DONE 2 /* Moved kernel to HMA */ -#define HMA_LOW 3 /* Definitely LOW */ +#define HMA_NONE 0 /* do nothing */ +#define HMA_REQ 1 /* DOS = HIGH detected */ +#define HMA_DONE 2 /* Moved kernel to HMA */ +#define HMA_LOW 3 /* Definitely LOW */ -void FAR * ConfigAlloc(COUNT bytes) +void FAR *ConfigAlloc(COUNT bytes) { - VOID FAR *p; + VOID FAR *p; - p = HMAalloc(bytes); - - if (p == NULL) p = KernelAlloc(bytes); + p = HMAalloc(bytes); - /* printf("ConfigAlloc %d at %p\n", bytes, p);*/ - - return p; -} + if (p == NULL) + p = KernelAlloc(bytes); + + /* printf("ConfigAlloc %d at %p\n", bytes, p); */ + + return p; +} /* Do first time initialization. Store last so that we can reset it */ /* later. */ @@ -243,15 +234,15 @@ INIT void PreConfig(void) /* Set pass number */ nPass = 0; VgaSet = 0; - UmbState = 0; - + UmbState = 0; + /* Initialize the base memory pointers */ - + #ifdef DEBUG - { - extern BYTE FAR internal_data[]; - printf("SDA located at 0x%p\n", internal_data); - } + { + extern BYTE FAR internal_data[]; + printf("SDA located at 0x%p\n", internal_data); + } #endif /* Begin by initializing our system buffers */ /* the dms_scratch buffer is statically allocated @@ -259,8 +250,6 @@ INIT void PreConfig(void) /* dma_scratch = (BYTE FAR *) KernelAllocDma(BUFFERSIZE); */ /* DebugPrintf(("Preliminary DMA scratchpad allocated at 0x%p\n",dma_scratch));*/ - - /* buffers = (struct buffer FAR *) KernelAlloc(Config.cfgBuffers * sizeof(struct buffer)); */ #ifdef DEBUG @@ -272,43 +261,41 @@ INIT void PreConfig(void) KernelAlloc(Config.cfgFiles * sizeof(struct f_node));*/ f_nodes = (f_node_ptr) - DynAlloc("f_nodes", Config.cfgFiles , sizeof(struct f_node)); + DynAlloc("f_nodes", Config.cfgFiles, sizeof(struct f_node)); f_nodes_cnt = Config.cfgFiles; /* sfthead = (sfttbl FAR *)&basesft; */ /* FCBp = (sfttbl FAR *)&FcbSft; */ /* FCBp = (sfttbl FAR *) - KernelAlloc(sizeof(sftheader) - + Config.cfgFiles * sizeof(sft));*/ + KernelAlloc(sizeof(sftheader) + + Config.cfgFiles * sizeof(sft)); */ - lpBase = AlignParagraph((BYTE FAR *)DynLast()+0x0f); + lpBase = AlignParagraph((BYTE FAR *) DynLast() + 0x0f); - config_init_buffers( Config.cfgBuffers); + config_init_buffers(Config.cfgBuffers); sfthead->sftt_next = (sfttbl FAR *) - KernelAlloc(sizeof(sftheader) - + (Config.cfgFiles-5) * sizeof(sft)); + KernelAlloc(sizeof(sftheader) + (Config.cfgFiles - 5) * sizeof(sft)); sfthead->sftt_next->sftt_next = (sfttbl FAR *) - 1; - sfthead->sftt_next->sftt_count = Config.cfgFiles-5; + sfthead->sftt_next->sftt_count = Config.cfgFiles - 5; - CDSp = (cdstbl FAR *) - KernelAlloc(0x58 * lastdrive); + CDSp = (cdstbl FAR *) KernelAlloc(0x58 * lastdrive); DPBp = (struct dpb FAR *) - KernelAlloc(blk_dev.dh_name[0]*sizeof(struct dpb)); + KernelAlloc(blk_dev.dh_name[0] * sizeof(struct dpb)); #ifdef DEBUG - printf("Preliminary:\n f_node 0x%x",f_nodes); + printf("Preliminary:\n f_node 0x%x", f_nodes); /* printf(" FCB table 0x%p\n",FCBp);*/ - printf(" sft table 0x%p\n",sfthead->sftt_next); - printf(" CDS table 0x%p\n",CDSp); - printf(" DPB table 0x%p\n",DPBp); + printf(" sft table 0x%p\n", sfthead->sftt_next); + printf(" CDS table 0x%p\n", CDSp); + printf(" DPB table 0x%p\n", DPBp); #endif /* Done. Now initialize the MCB structure */ /* This next line is 8086 and 80x86 real mode specific */ #ifdef DEBUG - printf("Preliminary allocation completed: top at 0x%p\n",lpBase); + printf("Preliminary allocation completed: top at 0x%p\n", lpBase); #endif #ifdef KDB @@ -319,7 +306,7 @@ INIT void PreConfig(void) #endif /* We expect ram_top as Kbytes, so convert to paragraphs */ - mcb_init(first_mcb, ram_top*64 - first_mcb - 1); + mcb_init(first_mcb, ram_top * 64 - first_mcb - 1); nPass = 1; } @@ -329,36 +316,33 @@ INIT void PostConfig(void) { /* close all (device) files */ - /* Set pass number */ nPass = 2; /* compute lastdrive ... */ lastdrive = Config.cfgLastdrive; - if (lastdrive < nblkdev ) - lastdrive = nblkdev ; + if (lastdrive < nblkdev) + lastdrive = nblkdev; - /* initialize NEAR allocated things */ + /* initialize NEAR allocated things */ /* Initialize the file table */ DynFree(f_nodes); f_nodes = (f_node_ptr) - DynAlloc("f_nodes", Config.cfgFiles , sizeof(struct f_node)); - - f_nodes_cnt = Config.cfgFiles; /* and the number of allocated files */ + DynAlloc("f_nodes", Config.cfgFiles, sizeof(struct f_node)); + f_nodes_cnt = Config.cfgFiles; /* and the number of allocated files */ /* Initialize the base memory pointers from last time. */ /* - if the kernel could be moved to HMA, everything behind the dynamic - near data is free. - otherwise, the kernel is moved down - behind the dynamic allocated data, - and allocation starts after the kernel. - */ + if the kernel could be moved to HMA, everything behind the dynamic + near data is free. + otherwise, the kernel is moved down - behind the dynamic allocated data, + and allocation starts after the kernel. + */ - lpBase = AlignParagraph((BYTE FAR *)DynLast()+0x0f); - - DebugPrintf(("starting FAR allocations at %p\n",lpBase)); - + lpBase = AlignParagraph((BYTE FAR *) DynLast() + 0x0f); + + DebugPrintf(("starting FAR allocations at %p\n", lpBase)); /* Begin by initializing our system buffers */ /* dma_scratch = (BYTE FAR *) KernelAllocDma(BUFFERSIZE); */ @@ -366,143 +350,142 @@ INIT void PostConfig(void) /* printf("DMA scratchpad allocated at 0x%p\n", dma_scratch); */ #endif - config_init_buffers(Config.cfgBuffers); /* sfthead = (sfttbl FAR *)&basesft; */ /* FCBp = (sfttbl FAR *)&FcbSft; */ /* FCBp = (sfttbl FAR *) - KernelAlloc(sizeof(sftheader) - + Config.cfgFiles * sizeof(sft));*/ + KernelAlloc(sizeof(sftheader) + + Config.cfgFiles * sizeof(sft)); */ sfthead->sftt_next = (sfttbl FAR *) - KernelAlloc(sizeof(sftheader) - + (Config.cfgFiles-5) * sizeof(sft)); + KernelAlloc(sizeof(sftheader) + (Config.cfgFiles - 5) * sizeof(sft)); sfthead->sftt_next->sftt_next = (sfttbl FAR *) - 1; - sfthead->sftt_next->sftt_count = Config.cfgFiles-5; + sfthead->sftt_next->sftt_count = Config.cfgFiles - 5; - CDSp = (cdstbl FAR *) - KernelAlloc(0x58 * lastdrive); + CDSp = (cdstbl FAR *) KernelAlloc(0x58 * lastdrive); DPBp = (struct dpb FAR *) - KernelAlloc(blk_dev.dh_name[0]*sizeof(struct dpb)); - + KernelAlloc(blk_dev.dh_name[0] * sizeof(struct dpb)); #ifdef DEBUG - printf("Final: \n f_node 0x%x\n",f_nodes); + printf("Final: \n f_node 0x%x\n", f_nodes); /* printf(" FCB table 0x%p\n",FCBp);*/ - printf(" sft table 0x%p\n",sfthead->sftt_next); - printf(" CDS table 0x%p\n",CDSp); - printf(" DPB table 0x%p\n",DPBp); -#endif + printf(" sft table 0x%p\n", sfthead->sftt_next); + printf(" CDS table 0x%p\n", CDSp); + printf(" DPB table 0x%p\n", DPBp); +#endif if (Config.cfgStacks) { - VOID FAR *stackBase = KernelAlloc(Config.cfgStacks * Config.cfgStackSize); + VOID FAR *stackBase = + KernelAlloc(Config.cfgStacks * Config.cfgStackSize); init_stacks(stackBase, Config.cfgStacks, Config.cfgStackSize); - DebugPrintf(("Stacks allocated at %p\n",stackBase)); + DebugPrintf(("Stacks allocated at %p\n", stackBase)); } - DebugPrintf(("Allocation completed: top at 0x%p\n",lpBase)); + DebugPrintf(("Allocation completed: top at 0x%p\n", lpBase)); } /* This code must be executed after device drivers has been loaded */ INIT VOID configDone(VOID) { - if ( HMAState != HMA_DONE ) - { - lpBase = AlignParagraph(lpBase); - - DebugPrintf(("HMA not available, moving text to %x\n",FP_SEG(lpBase))); - MoveKernel(FP_SEG(lpBase)); - - lpBase = AlignParagraph((BYTE FAR *)lpBase + HMAFree + 0x0f); - - DebugPrintf(("kernel is low, start alloc at %p",lpBase)); - - /* final buffer processing, now upwards */ - HMAState = HMA_LOW; - config_init_buffers( Config.cfgBuffers); - } + if (HMAState != HMA_DONE) + { + lpBase = AlignParagraph(lpBase); + + DebugPrintf(("HMA not available, moving text to %x\n", + FP_SEG(lpBase))); + MoveKernel(FP_SEG(lpBase)); + + lpBase = AlignParagraph((BYTE FAR *) lpBase + HMAFree + 0x0f); - if (lastdrive < nblkdev) { + DebugPrintf(("kernel is low, start alloc at %p", lpBase)); + + /* final buffer processing, now upwards */ + HMAState = HMA_LOW; + config_init_buffers(Config.cfgBuffers); + } + + if (lastdrive < nblkdev) + { - DebugPrintf(("lastdrive %c too small upping it to: %c\n", lastdrive + 'A', nblkdev + 'A' -1)); + DebugPrintf(("lastdrive %c too small upping it to: %c\n", + lastdrive + 'A', nblkdev + 'A' - 1)); lastdrive = nblkdev; - CDSp = (cdstbl FAR *) - KernelAlloc(0x58 * lastdrive); + CDSp = (cdstbl FAR *) KernelAlloc(0x58 * lastdrive); } first_mcb = FP_SEG(lpBase) + ((FP_OFF(lpBase) + 0x0f) >> 4); /* We expect ram_top as Kbytes, so convert to paragraphs */ - mcb_init(first_mcb, ram_top*64 - first_mcb - 1); + mcb_init(first_mcb, ram_top * 64 - first_mcb - 1); - if(UmbState == 1) - { + if (UmbState == 1) + { - mumcb_init(ram_top*64 - 1, umb_start - 64*ram_top); + mumcb_init(ram_top * 64 - 1, umb_start - 64 * ram_top); /* Check if any devices were loaded in umb */ - if(umb_start != FP_SEG(upBase) ){ + if (umb_start != FP_SEG(upBase)) + { /* make last block normal with SC for the devices */ - - UCOUNT umr_new = FP_SEG(upBase) + ((FP_OFF(upBase) + 0x0f) >> 4); - - mumcb_init(uppermem_root, umr_new - uppermem_root - 1); - uppermem_root = umr_new; - zumcb_init(uppermem_root, (umb_start + UMB_top ) - uppermem_root - 1); - upBase += 16; - } - - { - /* are there any more UMB's ?? - this happens, if memory mapped devces are in between - like UMB memory c800..c8ff, d8ff..efff with device at d000..d7ff - */ - - /* TE - this code - a) isn't the best I ever wrote :-( - b) works for 2 memory areas (no while(), use of UMB_top,...) - and the first discovered is the larger one. - no idea what happens, if the larger one is higher in memory. - might work, though - */ - - UCOUNT umb_seg, umb_size, umbz_root; - - umbz_root = uppermem_root; - - if(UMB_get_largest(&umb_seg, &umb_size)){ - - mcb_init(umbz_root, (umb_start + UMB_top ) - uppermem_root - 1); - - /* change UMB 'Z' to 'M' */ - ((mcb FAR *)MK_FP(umbz_root,0))->m_type = 'M'; + UCOUNT umr_new = FP_SEG(upBase) + ((FP_OFF(upBase) + 0x0f) >> 4); - /* move to end */ - umbz_root += ((mcb FAR *)MK_FP(umbz_root,0))->m_size + 1; - - /* create link mcb */ - mumcb_init(umbz_root, umb_seg - umbz_root - 1); + mumcb_init(uppermem_root, umr_new - uppermem_root - 1); + uppermem_root = umr_new; + zumcb_init(uppermem_root, (umb_start + UMB_top) - uppermem_root - 1); + upBase += 16; + } + + { + /* are there any more UMB's ?? + this happens, if memory mapped devces are in between + like UMB memory c800..c8ff, d8ff..efff with device at d000..d7ff + */ + + /* TE - this code + a) isn't the best I ever wrote :-( + b) works for 2 memory areas (no while(), use of UMB_top,...) + and the first discovered is the larger one. + no idea what happens, if the larger one is higher in memory. + might work, though + */ + + UCOUNT umb_seg, umb_size, umbz_root; + + umbz_root = uppermem_root; + + if (UMB_get_largest(&umb_seg, &umb_size)) + { - /* should the UMB driver return - adjacent memory in several pieces */ - if (umb_seg - umbz_root - 1 == 0) - ((mcb FAR *)MK_FP(umbz_root,0))->m_psp = FREE_PSP; + mcb_init(umbz_root, (umb_start + UMB_top) - uppermem_root - 1); - /* create new 'Z' mcb */ - zumcb_init(umb_seg, umb_size - 1); - } - } + /* change UMB 'Z' to 'M' */ + ((mcb FAR *) MK_FP(umbz_root, 0))->m_type = 'M'; + + /* move to end */ + umbz_root += ((mcb FAR *) MK_FP(umbz_root, 0))->m_size + 1; + + /* create link mcb */ + mumcb_init(umbz_root, umb_seg - umbz_root - 1); + + /* should the UMB driver return + adjacent memory in several pieces */ + if (umb_seg - umbz_root - 1 == 0) + ((mcb FAR *) MK_FP(umbz_root, 0))->m_psp = FREE_PSP; + + /* create new 'Z' mcb */ + zumcb_init(umb_seg, umb_size - 1); + } } + } - DebugPrintf(("UMB Allocation completed: top at 0x%p\n",upBase)); + DebugPrintf(("UMB Allocation completed: top at 0x%p\n", upBase)); /* The standard handles should be reopened here, because we may have loaded new console or printer drivers in CONFIG.SYS */ - } INIT VOID DoConfig(VOID) @@ -515,9 +498,9 @@ INIT VOID DoConfig(VOID) /* exit since we don't force the user to have one. */ if ((nFileDesc = open("fdconfig.sys", 0)) >= 0) { - DebugPrintf(("Reading FDCONFIG.SYS...\n")); + DebugPrintf(("Reading FDCONFIG.SYS...\n")); } - else + else { DebugPrintf(("FDCONFIG.SYS not found\n")); if ((nFileDesc = open("config.sys", 0)) < 0) @@ -527,7 +510,6 @@ INIT VOID DoConfig(VOID) } DebugPrintf(("Reading CONFIG.SYS...\n")); } - /* Have one -- initialize. */ nCfgLine = 0; @@ -538,91 +520,89 @@ INIT VOID DoConfig(VOID) /* do the table lookup and execute the handler for that */ /* function. */ - for (;!bEof;nCfgLine++) + for (; !bEof; nCfgLine++) { struct table *pEntry; pLineStart = szLine; - - /* read in a single line, \n or ^Z terminated */ - + + /* read in a single line, \n or ^Z terminated */ + for (pLine = szLine;;) - { - if (read(nFileDesc, pLine, 1) <= 0) - { - bEof = TRUE; - break; - } - - /* immediately convert to upper case */ - *pLine = toupper(*pLine); - - if (pLine >= szLine + sizeof(szLine)-3) - { - CfgFailure(pLine); - printf("error - line overflow line %d \n",nCfgLine); - break; - } - - if (*pLine == '\n' || - *pLine == EOF ) /* end of line */ - break; - - if (*pLine == '\r') /* ignore */ - ; - else - pLine++; - } - - *pLine = 0; - pLine = szLine; - - - /* Skip leading white space and get verb. */ - pLine = scan(pLine, szBuf); - - /* If the line was blank, skip it. Otherwise, look up */ - /* the verb and execute the appropriate function. */ - if (*szBuf == '\0') - continue; - - pEntry = LookUp(commands, szBuf); - - if (pEntry->pass >= 0 && pEntry->pass != nPass) - continue; - - if ( SkipLine(pLineStart)) /* F5/F8 processing */ - continue; - - pLine = skipwh(pLine); - - if ('=' != *pLine) - CfgFailure(pLine); - else /* YES. DO IT */ - (*(pEntry->func)) (skipwh(pLine+1)); - - - - /* might have been the UMB driver */ - if(UmbState == 2){ - - UCOUNT umb_seg, umb_size; - - if(UMB_get_largest(&umb_seg, &umb_size)){ - UmbState = 1; - upBase = MK_FP(umb_seg , 0); - UMB_top = umb_size; - umb_start = umb_seg; - + { + if (read(nFileDesc, pLine, 1) <= 0) + { + bEof = TRUE; + break; + } + + /* immediately convert to upper case */ + *pLine = toupper(*pLine); + + if (pLine >= szLine + sizeof(szLine) - 3) + { + CfgFailure(pLine); + printf("error - line overflow line %d \n", nCfgLine); + break; + } + + if (*pLine == '\n' || *pLine == EOF) /* end of line */ + break; + + if (*pLine == '\r') /* ignore */ + ; + else + pLine++; + } + + *pLine = 0; + pLine = szLine; + + /* Skip leading white space and get verb. */ + pLine = scan(pLine, szBuf); + + /* If the line was blank, skip it. Otherwise, look up */ + /* the verb and execute the appropriate function. */ + if (*szBuf == '\0') + continue; + + pEntry = LookUp(commands, szBuf); + + if (pEntry->pass >= 0 && pEntry->pass != nPass) + continue; + + if (SkipLine(pLineStart)) /* F5/F8 processing */ + continue; + + pLine = skipwh(pLine); + + if ('=' != *pLine) + CfgFailure(pLine); + else /* YES. DO IT */ + (*(pEntry->func)) (skipwh(pLine + 1)); + + /* might have been the UMB driver */ + if (UmbState == 2) + { + + UCOUNT umb_seg, umb_size; + + if (UMB_get_largest(&umb_seg, &umb_size)) + { + UmbState = 1; + upBase = MK_FP(umb_seg, 0); + UMB_top = umb_size; + umb_start = umb_seg; + /* reset root */ - uppermem_root = umb_seg; + uppermem_root = umb_seg; /* setup the real mcb for the devicehigh block */ - zumcb_init(umb_seg, UMB_top - 1); - upBase += 16; - } - } - + zumcb_init(umb_seg, UMB_top - 1); + upBase += 16; } + } + + } close(nFileDesc); } @@ -654,114 +634,113 @@ INIT struct table *LookUp(struct table *p, BYTE * token) ULONG GetBiosTime(VOID) { - return *(ULONG FAR *)(MK_FP(0x40,0x6c)); -} + return *(ULONG FAR *) (MK_FP(0x40, 0x6c)); +} + UWORD GetBiosKey(int timeout) { - iregs r; - - ULONG startTime = GetBiosTime(); + iregs r; - for (;;) + ULONG startTime = GetBiosTime(); + + for (;;) + { + r.a.x = 0x0100; /* are there keys available ? */ + init_call_intr(0x16, &r); + + if ((r.flags & 0x40) == 0) /* yes - fetch and return */ { - r.a.x = 0x0100; /* are there keys available ? */ - init_call_intr(0x16,&r); + r.a.x = 0x0000; + init_call_intr(0x16, &r); - if ((r.flags & 0x40) == 0) /* yes - fetch and return */ - { - r.a.x = 0x0000; - init_call_intr(0x16,&r); - - return r.a.x; - } + return r.a.x; + } if (timeout < 0) - continue; - - if (GetBiosTime() - startTime >= timeout*18) - break; - } - return 0xffff; -} + continue; + + if (GetBiosTime() - startTime >= timeout * 18) + break; + } + return 0xffff; +} INIT BOOL SkipLine(char *pLine) { short key; - + static char initialized = FALSE; - + if (!initialized) { - - initialized = TRUE; - - if (InitKernelConfig.SkipConfigSeconds < 0) - return FALSE; - - if (InitKernelConfig.SkipConfigSeconds > 0) - printf("Press F8 to trace or F5 to skip CONFIG.SYS/AUTOEXEC.BAT"); - - key = GetBiosKey(InitKernelConfig.SkipConfigSeconds); /* wait 2 seconds */ - - if (key == 0x3f00) /* F5 */ - { - SkipAllConfig = TRUE; - } - if (key == 0x4200) /* F8 */ - { - singleStep = TRUE; - } - - printf("\r%79s\r",""); /* clear line */ - - if (SkipAllConfig) - printf("Skipping CONFIG.SYS/AUTOEXEC.BAT\n"); - } + initialized = TRUE; - - if (SkipAllConfig) + if (InitKernelConfig.SkipConfigSeconds < 0) + return FALSE; + + if (InitKernelConfig.SkipConfigSeconds > 0) + printf("Press F8 to trace or F5 to skip CONFIG.SYS/AUTOEXEC.BAT"); + + key = GetBiosKey(InitKernelConfig.SkipConfigSeconds); /* wait 2 seconds */ + + if (key == 0x3f00) /* F5 */ + { + SkipAllConfig = TRUE; + } + if (key == 0x4200) /* F8 */ + { + singleStep = TRUE; + } + + printf("\r%79s\r", ""); /* clear line */ + + if (SkipAllConfig) + printf("Skipping CONFIG.SYS/AUTOEXEC.BAT\n"); + } + + if (SkipAllConfig) return TRUE; if (!askThisSingleCommand && !singleStep) return FALSE; - + printf("%s[Y,N]?", pLine); - + for (;;) { key = GetBiosKey(-1); - - switch(toupper(key & 0x00ff)) + + switch (toupper(key & 0x00ff)) { - case 'N': - case 'n': - printf("N\n"); - return TRUE; - - case 0x1b: /* don't know where documented - ESCAPE answers all following questions - with YES - */ - singleStep = FALSE; /* and fall through */ - - case '\r': - case '\n': - case 'Y': - case 'y': - printf("Y\n"); - return FALSE; - + case 'N': + case 'n': + printf("N\n"); + return TRUE; + + case 0x1b: /* don't know where documented + ESCAPE answers all following questions + with YES + */ + singleStep = FALSE; /* and fall through */ + + case '\r': + case '\n': + case 'Y': + case 'y': + printf("Y\n"); + return FALSE; + } - - if (key == 0x3f00) /* YES, you may hit F5 here, too */ + + if (key == 0x3f00) /* YES, you may hit F5 here, too */ { - printf("N\n"); - SkipAllConfig = TRUE; - return TRUE; + printf("N\n"); + SkipAllConfig = TRUE; + return TRUE; } - } - + } + } INIT BYTE *GetNumArg(BYTE * pLine, COUNT * pnArg) @@ -794,7 +773,8 @@ INIT void Config_Buffers(BYTE * pLine) return; /* Got the value, assign either default or new value */ - Config.cfgBuffers = (nBuffers < 0 ? nBuffers : max(Config.cfgBuffers, nBuffers)); + Config.cfgBuffers = + (nBuffers < 0 ? nBuffers : max(Config.cfgBuffers, nBuffers)); } INIT STATIC VOID sysScreenMode(BYTE * pLine) @@ -813,24 +793,24 @@ INIT STATIC VOID sysScreenMode(BYTE * pLine) 0x12 (18) 43/50 lines 0x14 (20) 25 lines */ -#if defined(__TURBOC__) +#if defined(__TURBOC__) _AX = (0x11 << 8) + nMode; _BL = 0; __int__(0x10); #else - asm { - mov al, byte ptr nMode; - mov ah, 0x11; - mov bl, 0; - int 0x10; - } + asm + { + mov al, byte ptr nMode; + mov ah, 0x11; + mov bl, 0; + int 0x10; + } #endif } INIT STATIC VOID sysVersion(BYTE * pLine) { - COUNT major, - minor; + COUNT major, minor; char *p; p = pLine; @@ -880,7 +860,7 @@ INIT STATIC VOID CfgLastdrive(BYTE * pLine) return; } drv -= 'A'; - drv++; /* Make real number*/ + drv++; /* Make real number */ Config.cfgLastdrive = max(Config.cfgLastdrive, drv); } @@ -888,43 +868,51 @@ INIT STATIC VOID CfgLastdrive(BYTE * pLine) UmbState of confidence, 1 is sure, 2 maybe, 4 unknown and 0 no way. */ - INIT STATIC VOID Dosmem(BYTE * pLine) { - BYTE *pTmp; - BYTE UMBwanted = FALSE; + BYTE *pTmp; + BYTE UMBwanted = FALSE; /* extern BYTE FAR INITDataSegmentClaimed; */ - pLine = GetStringArg(pLine, szBuf); + pLine = GetStringArg(pLine, szBuf); - for (pTmp = szBuf; *pTmp != '\0'; pTmp++) - *pTmp = toupper(*pTmp); + for (pTmp = szBuf; *pTmp != '\0'; pTmp++) + *pTmp = toupper(*pTmp); - printf("DOS called with %s\n", szBuf); + printf("DOS called with %s\n", szBuf); - for (pTmp = szBuf ; ; ) + for (pTmp = szBuf;;) + { + if (fmemcmp(pTmp, "UMB", 3) == 0) { - if (fmemcmp(pTmp, "UMB" ,3) == 0) { UMBwanted = TRUE; pTmp += 3; } - if (fmemcmp(pTmp, "HIGH",4) == 0) { HMAState = HMA_REQ; pTmp += 4; } -/* if (fmemcmp(pTmp, "CLAIMINIT",9) == 0) { INITDataSegmentClaimed = 0; pTmp += 9; }*/ - pTmp = skipwh(pTmp); - - if (*pTmp != ',') - break; - pTmp++; - } - - - if(UmbState == 0){ - uppermem_link = 0; - uppermem_root = 0; - UmbState = UMBwanted ? 2 : 0; + UMBwanted = TRUE; + pTmp += 3; } - /* Check if HMA is available straight away */ - if (HMAState == HMA_REQ && MoveKernelToHMA()){ - HMAState = HMA_DONE; + if (fmemcmp(pTmp, "HIGH", 4) == 0) + { + HMAState = HMA_REQ; + pTmp += 4; } +/* if (fmemcmp(pTmp, "CLAIMINIT",9) == 0) { INITDataSegmentClaimed = 0; pTmp += 9; }*/ + pTmp = skipwh(pTmp); + + if (*pTmp != ',') + break; + pTmp++; + } + + if (UmbState == 0) + { + uppermem_link = 0; + uppermem_root = 0; + UmbState = UMBwanted ? 2 : 0; + } + /* Check if HMA is available straight away */ + if (HMAState == HMA_REQ && MoveKernelToHMA()) + { + HMAState = HMA_DONE; + } } INIT STATIC VOID CfgSwitchar(BYTE * pLine) @@ -968,13 +956,13 @@ INIT STATIC VOID Fcbs(BYTE * pLine) INIT BOOL LoadCountryInfo(char *filename, UWORD ctryCode, UWORD codePage) { /* printf("cntry: %u, CP%u, file=\"%s\"\n", ctryCode, codePage, filename); */ - printf("Sorry, the COUNTRY= statement has been temporarily disabled\n"); - - UNREFERENCED_PARAMETER(codePage); - UNREFERENCED_PARAMETER(ctryCode); - UNREFERENCED_PARAMETER(filename); - - return FALSE; + printf("Sorry, the COUNTRY= statement has been temporarily disabled\n"); + + UNREFERENCED_PARAMETER(codePage); + UNREFERENCED_PARAMETER(ctryCode); + UNREFERENCED_PARAMETER(filename); + + return FALSE; } INIT STATIC VOID Country(BYTE * pLine) @@ -1046,7 +1034,6 @@ INIT STATIC VOID InitPgmHigh(BYTE * pLine) Config.cfgP_0_startmode = 0x80; } - INIT STATIC VOID InitPgm(BYTE * pLine) { /* Get the string argument that represents the new init pgm */ @@ -1072,9 +1059,9 @@ INIT STATIC VOID CfgBreak(BYTE * pLine) INIT STATIC VOID Numlock(BYTE * pLine) { extern VOID ASMCFUNC keycheck(); - + /* Format: NUMLOCK = (ON | OFF) */ - BYTE FAR *keyflags = (BYTE FAR *)MK_FP(0x40,0x17); + BYTE FAR *keyflags = (BYTE FAR *) MK_FP(0x40, 0x17); GetStringArg(pLine, szBuf); @@ -1085,24 +1072,24 @@ INIT STATIC VOID Numlock(BYTE * pLine) INIT STATIC VOID DeviceHigh(BYTE * pLine) { - if(UmbState == 1) - { - if (LoadDevice(pLine, UMB_top, TRUE) == DE_NOMEM) - { - printf("Not enough free memory in UMB's: loading low\n"); - LoadDevice(pLine, ram_top, FALSE); - } - } - else + if (UmbState == 1) + { + if (LoadDevice(pLine, UMB_top, TRUE) == DE_NOMEM) { - printf("UMB's unavailable!\n"); - LoadDevice(pLine, ram_top, FALSE); + printf("Not enough free memory in UMB's: loading low\n"); + LoadDevice(pLine, ram_top, FALSE); } + } + else + { + printf("UMB's unavailable!\n"); + LoadDevice(pLine, ram_top, FALSE); + } } INIT void Device(BYTE * pLine) { - LoadDevice(pLine, ram_top, FALSE); + LoadDevice(pLine, ram_top, FALSE); } INIT BOOL LoadDevice(BYTE * pLine, COUNT top, COUNT mode) @@ -1112,7 +1099,7 @@ INIT BOOL LoadDevice(BYTE * pLine, COUNT top, COUNT mode) struct dhdr FAR *next_dhp; BOOL result; - if(mode) + if (mode) dhp = AlignParagraph(upBase); else dhp = AlignParagraph(lpBase); @@ -1125,52 +1112,49 @@ INIT BOOL LoadDevice(BYTE * pLine, COUNT top, COUNT mode) eb.load.reloc = eb.load.load_seg = FP_SEG(dhp); #ifdef DEBUG - printf("Loading device driver %s at segment %04x\n", - szBuf, FP_SEG(dhp)); + printf("Loading device driver %s at segment %04x\n", szBuf, FP_SEG(dhp)); #endif - if ((result = init_DosExec(3, &eb, szBuf)) != SUCCESS) - { + { CfgFailure(pLine); return result; - } - - strcpy(szBuf, pLine); + } - /* TE this fixes the loading of devices drivers with - multiple devices in it. NUMEGA's SoftIce is such a beast - */ - - /* add \r\n to the command line */ - strcat(szBuf, "\r\n"); - - - for (next_dhp=NULL; FP_OFF(next_dhp) != 0xffff && - (result=init_device(dhp, szBuf, mode, top))==SUCCESS - ; dhp = next_dhp) - { - next_dhp = dhp->dh_next; - if (FP_SEG(next_dhp) == 0xffff) - /* Does this ever occur with FP_OFF(next_dhp) != 0xffff ??? */ + strcpy(szBuf, pLine); + + /* TE this fixes the loading of devices drivers with + multiple devices in it. NUMEGA's SoftIce is such a beast + */ + + /* add \r\n to the command line */ + strcat(szBuf, "\r\n"); + + for (next_dhp = NULL; FP_OFF(next_dhp) != 0xffff && + (result = init_device(dhp, szBuf, mode, top)) == SUCCESS; + dhp = next_dhp) + { + next_dhp = dhp->dh_next; + if (FP_SEG(next_dhp) == 0xffff) + /* Does this ever occur with FP_OFF(next_dhp) != 0xffff ??? */ next_dhp = MK_FP(FP_SEG(dhp), FP_OFF(next_dhp)); -#ifdef DEBUG - else if (FP_OFF(next_dhp) != 0xffff) /* end of internal chain */ - printf("multisegmented device driver found, next %p\n",next_dhp); - /* give warning message */ -#endif - /* Link in device driver and save nul_dev pointer to next */ - dhp->dh_next = nul_dev.dh_next; - nul_dev.dh_next = dhp; - } - /* We could just have loaded FDXMS or HIMEM */ - if (HMAState == HMA_REQ && MoveKernelToHMA()) - { - /* final HMA processing: */ - /* final buffer processing, now upwards */ - HMAState = HMA_DONE; - config_init_buffers( Config.cfgBuffers); - } +#ifdef DEBUG + else if (FP_OFF(next_dhp) != 0xffff) /* end of internal chain */ + printf("multisegmented device driver found, next %p\n", next_dhp); + /* give warning message */ +#endif + /* Link in device driver and save nul_dev pointer to next */ + dhp->dh_next = nul_dev.dh_next; + nul_dev.dh_next = dhp; + } + /* We could just have loaded FDXMS or HIMEM */ + if (HMAState == HMA_REQ && MoveKernelToHMA()) + { + /* final HMA processing: */ + /* final buffer processing, now upwards */ + HMAState = HMA_DONE; + config_init_buffers(Config.cfgBuffers); + } return result; } @@ -1204,7 +1188,7 @@ INIT BYTE FAR *KernelAlloc(WORD nBytes) else lpBase += nBytes; - fmemset( lpAllocated, 0, nBytes); + fmemset(lpAllocated, 0, nBytes); return lpAllocated; } @@ -1229,9 +1213,9 @@ INIT void FAR *AlignParagraph(VOID FAR * lpPtr) /* First, convert the segmented pointer to linear address */ uSegVal = FP_SEG(lpPtr); - uSegVal += (FP_OFF(lpPtr)+0xf) >> 4; + uSegVal += (FP_OFF(lpPtr) + 0xf) >> 4; if (FP_OFF(lpPtr) > 0xfff0) - uSegVal += 0x1000; /* handle overflow */ + uSegVal += 0x1000; /* handle overflow */ /* and return an adddress adjusted to the nearest paragraph */ /* boundary. */ @@ -1239,39 +1223,36 @@ INIT void FAR *AlignParagraph(VOID FAR * lpPtr) } #endif -INIT BYTE * - skipwh(BYTE * s) +INIT BYTE *skipwh(BYTE * s) { while (*s && (*s == 0x0d || *s == 0x0a || *s == ' ' || *s == '\t')) ++s; return s; } -INIT BYTE * - scan(BYTE * s, BYTE * d) +INIT BYTE *scan(BYTE * s, BYTE * d) { askThisSingleCommand = FALSE; - + s = skipwh(s); - if (*s == ';') { + if (*s == ';') + { /* semicolon is a synonym for rem */ *d++ = *s++; } - else while (*s && - !(*s == 0x0d - || *s == 0x0a - || *s == ' ' - || *s == '\t' - || *s == '=')) - { - if (*s == '?') - { - askThisSingleCommand = TRUE; - s++; - } - else - *d++ = *s++; - } + else + while (*s && + !(*s == 0x0d + || *s == 0x0a || *s == ' ' || *s == '\t' || *s == '=')) + { + if (*s == '?') + { + askThisSingleCommand = TRUE; + s++; + } + else + *d++ = *s++; + } *d = '\0'; return s; } @@ -1304,7 +1285,7 @@ INIT BYTE *GetNumber(REG BYTE * pszString, REG COUNT * pnNum) pszString++; Sign = TRUE; } - + while (isnum(pszString) || toupper(*pszString) == 'X') { if (toupper(*pszString) == 'X') @@ -1342,20 +1323,19 @@ INIT COUNT toupper(COUNT c) /* The following code is 8086 dependant */ -#if 1 /* ifdef KERNEL */ -INIT VOID - mcb_init(UCOUNT seg, UWORD size) +#if 1 /* ifdef KERNEL */ +INIT VOID mcb_init(UCOUNT seg, UWORD size) { COUNT i; - mcb FAR * mcbp = MK_FP(seg,0); - + mcb FAR *mcbp = MK_FP(seg, 0); + mcbp->m_type = MCB_LAST; mcbp->m_psp = FREE_PSP; /* if(UmbState == 1)*/ - mcbp->m_size = (size - 1); + mcbp->m_size = (size - 1); /* mcbp->m_size = size; */ @@ -1364,12 +1344,11 @@ INIT VOID mem_access_mode = FIRST_FIT; } -INIT VOID - zumcb_init(UCOUNT seg, UWORD size) +INIT VOID zumcb_init(UCOUNT seg, UWORD size) { COUNT i; - mcb FAR * mcbp = MK_FP(seg,0); - + mcb FAR *mcbp = MK_FP(seg, 0); + mcbp->m_type = MCB_LAST; mcbp->m_psp = FREE_PSP; mcbp->m_size = size; @@ -1378,12 +1357,11 @@ INIT VOID } -INIT VOID - mumcb_init(UCOUNT seg, UWORD size) +INIT VOID mumcb_init(UCOUNT seg, UWORD size) { COUNT i; - mcb FAR * mcbp = MK_FP(seg,0); - + mcb FAR *mcbp = MK_FP(seg, 0); + static char name[8] = "SC\0\0\0\0\0\0"; mcbp->m_type = MCB_NORMAL; @@ -1394,8 +1372,7 @@ INIT VOID } #endif -INIT VOID - strcat(REG BYTE * d, REG BYTE * s) +INIT VOID strcat(REG BYTE * d, REG BYTE * s) { while (*d != 0) ++d; @@ -1405,37 +1382,37 @@ INIT VOID /* see if the second string is contained in the first one, ignoring case */ char *stristr(char *s1, char *s2) { - int loop; - - for ( ; *s1 ; s1++) - for ( loop = 0; ; loop++) - { - if (s2[loop] == 0) /* found end of string 2 -> success */ - { - return s1; /* position where s2 was found */ - } - if (toupper(s1[loop]) != toupper(s2[loop]) ) - break; - } - - return NULL; + int loop; + + for (; *s1; s1++) + for (loop = 0;; loop++) + { + if (s2[loop] == 0) /* found end of string 2 -> success */ + { + return s1; /* position where s2 was found */ + } + if (toupper(s1[loop]) != toupper(s2[loop])) + break; + } + + return NULL; } /* compare two ASCII strings ignoring case */ -INIT COUNT strcasecmp(REG BYTE *d, REG BYTE *s) +INIT COUNT strcasecmp(REG BYTE * d, REG BYTE * s) { - while (*s != '\0' && *d != '\0') - { - - if (toupper(*d) == toupper(*s)) - ++s, ++d; - - else - return toupper(*d) - toupper(*s); - - } - - return toupper(*d) - toupper(*s); + while (*s != '\0' && *d != '\0') + { + + if (toupper(*d) == toupper(*s)) + ++s, ++d; + + else + return toupper(*d) - toupper(*s); + + } + + return toupper(*d) - toupper(*s); } /* @@ -1443,7 +1420,6 @@ INIT COUNT strcasecmp(REG BYTE *d, REG BYTE *s) that saves some relocation problems */ - VOID config_init_buffers(COUNT anzBuffers) { REG WORD i; @@ -1457,30 +1433,31 @@ VOID config_init_buffers(COUNT anzBuffers) anzBuffers = -anzBuffers; fillhma = FALSE; } - - anzBuffers = max(anzBuffers,6); + + anzBuffers = max(anzBuffers, 6); if (anzBuffers > 99) - { - printf("BUFFERS=%u not supported, reducing to 99\n",anzBuffers); + { + printf("BUFFERS=%u not supported, reducing to 99\n", anzBuffers); anzBuffers = 99; - } + } LoL_nbuffers = anzBuffers; - + lpTop = lpOldTop; if (HMAState == HMA_NONE || HMAState == HMA_REQ) - lpTop = lpBase = lpTop - anzBuffers * (sizeof (struct buffer) + 0xf); - - firstbuf = ConfigAlloc(sizeof (struct buffer)); - - pbuffer = firstbuf; + lpTop = lpBase = lpTop - anzBuffers * (sizeof(struct buffer) + 0xf); + + firstbuf = ConfigAlloc(sizeof(struct buffer)); + + pbuffer = firstbuf; DebugPrintf(("init_buffers at")); - for (i = 0; ; ++i) + for (i = 0;; ++i) { - if (FP_SEG(pbuffer) == 0xffff) HMAcount++; - + if (FP_SEG(pbuffer) == 0xffff) + HMAcount++; + pbuffer->b_dummy = FP_OFF(pbuffer); pbuffer->b_unit = 0; pbuffer->b_flag = 0; @@ -1489,43 +1466,43 @@ VOID config_init_buffers(COUNT anzBuffers) pbuffer->b_offset = 0; pbuffer->b_next = NULL; - DebugPrintf((" (%d,%p)",i, pbuffer)); - - /* now, we can have quite some buffers in HMA - -- up to 37 for KE38616. - so we fill the HMA with buffers - but not if the BUFFERS count is negative ;-) - */ - + DebugPrintf((" (%d,%p)", i, pbuffer)); + + /* now, we can have quite some buffers in HMA + -- up to 37 for KE38616. + so we fill the HMA with buffers + but not if the BUFFERS count is negative ;-) + */ + if (i < (anzBuffers - 1)) { - pbuffer->b_next = HMAalloc(sizeof (struct buffer)); - - if (pbuffer->b_next == NULL) - { - /* if more buffer requested then fit into HMA, allocate - some from low memory as rewuested - */ - pbuffer->b_next = ConfigAlloc(sizeof (struct buffer)); - } + pbuffer->b_next = HMAalloc(sizeof(struct buffer)); + + if (pbuffer->b_next == NULL) + { + /* if more buffer requested then fit into HMA, allocate + some from low memory as rewuested + */ + pbuffer->b_next = ConfigAlloc(sizeof(struct buffer)); + } } else if (fillhma) - pbuffer->b_next = HMAalloc(sizeof (struct buffer)); - + pbuffer->b_next = HMAalloc(sizeof(struct buffer)); + if (pbuffer->b_next == NULL) - break; - - pbuffer = pbuffer->b_next; + break; + + pbuffer = pbuffer->b_next; } - + DebugPrintf((" done\n")); - + if (HMAcount) - printf("Kernel: allocated %d Diskbuffers = %u Bytes in HMA\n", - HMAcount, HMAcount*sizeof (struct buffer)); - + printf("Kernel: allocated %d Diskbuffers = %u Bytes in HMA\n", + HMAcount, HMAcount * sizeof(struct buffer)); + if (HMAState == HMA_NONE || HMAState == HMA_REQ) - lpBase = tmplpBase; + lpBase = tmplpBase; } /* @@ -1534,13 +1511,12 @@ VOID config_init_buffers(COUNT anzBuffers) ANYDOS will report to MSDOS programs just the version number they expect. be careful with it! -*/ - +*/ INIT VOID SetAnyDos(BYTE * pLine) { - UNREFERENCED_PARAMETER(pLine); - ReturnAnyDosVersionExpected = TRUE; + UNREFERENCED_PARAMETER(pLine); + ReturnAnyDosVersionExpected = TRUE; } /* @@ -1622,4 +1598,3 @@ INIT VOID SetAnyDos(BYTE * pLine) * Rev 1.0 19 Feb 1996 3:22:16 patv * Added NLS, int2f and config.sys processing */ - diff --git a/kernel/config.h b/kernel/config.h index 0a800fa8..d06e885b 100644 --- a/kernel/config.h +++ b/kernel/config.h @@ -27,12 +27,11 @@ /* Cambridge, MA 02139, USA. */ /****************************************************************/ - #ifdef DEBUG - /* Enable debugging of NLS part */ + /* Enable debugging of NLS part */ - /* Caution: Enabling NLS debugging usually generates - _a_lot_ of noise. */ + /* Caution: Enabling NLS debugging usually generates + _a_lot_ of noise. */ /*& #define NLS_DEBUG */ #endif diff --git a/kernel/dosfns.c b/kernel/dosfns.c index 527001ec..ae286847 100644 --- a/kernel/dosfns.c +++ b/kernel/dosfns.c @@ -29,7 +29,8 @@ #include "portab.h" #ifdef VERSION_STRINGS -static BYTE *dosfnsRcsId = "$Id$"; +static BYTE *dosfnsRcsId = + "$Id$"; #endif #include "globals.h" @@ -40,80 +41,73 @@ BOOL cmatch(COUNT, COUNT, COUNT); f_node_ptr xlt_fd(COUNT); - /* /// Added for SHARE. - Ron Cemer */ BYTE share_installed = 0; - /* DOS calls this to see if it's okay to open the file. - Returns a file_table entry number to use (>= 0) if okay - to open. Otherwise returns < 0 and may generate a critical - error. If < 0 is returned, it is the negated error return - code, so DOS simply negates this value and returns it in - AX. */ -static int share_open_check - (char far *filename, /* far pointer to fully qualified filename */ - unsigned short pspseg, /* psp segment address of owner process */ - int openmode, /* 0=read-only, 1=write-only, 2=read-write */ - int sharemode); /* SHARE_COMPAT, etc... */ - - /* DOS calls this to record the fact that it has successfully - closed a file, or the fact that the open for this file failed. */ -static void share_close_file - (int fileno); /* file_table entry number */ - - /* DOS calls this to determine whether it can access (read or - write) a specific section of a file. We call it internally - from lock_unlock (only when locking) to see if any portion - of the requested region is already locked. If pspseg is zero, - then it matches any pspseg in the lock table. Otherwise, only - locks which DO NOT belong to pspseg will be considered. - Returns zero if okay to access or lock (no portion of the - region is already locked). Otherwise returns non-zero and - generates a critical error (if allowcriter is non-zero). - If non-zero is returned, it is the negated return value for - the DOS call. */ -static int share_access_check - (unsigned short pspseg,/* psp segment address of owner process */ - int fileno, /* file_table entry number */ - unsigned long ofs, /* offset into file */ - unsigned long len, /* length (in bytes) of region to access */ - int allowcriter); /* allow a critical error to be generated */ - - /* DOS calls this to lock or unlock a specific section of a file. - Returns zero if successfully locked or unlocked. Otherwise - returns non-zero. - If the return value is non-zero, it is the negated error - return code for the DOS 0x5c call. */ -static int share_lock_unlock - (unsigned short pspseg,/* psp segment address of owner process */ - int fileno, /* file_table entry number */ - unsigned long ofs, /* offset into file */ - unsigned long len, /* length (in bytes) of region to lock or unlock */ - int unlock); /* non-zero to unlock; zero to lock */ + /* DOS calls this to see if it's okay to open the file. + Returns a file_table entry number to use (>= 0) if okay + to open. Otherwise returns < 0 and may generate a critical + error. If < 0 is returned, it is the negated error return + code, so DOS simply negates this value and returns it in + AX. */ +static int share_open_check(char far * filename, /* far pointer to fully qualified filename */ + unsigned short pspseg, /* psp segment address of owner process */ + int openmode, /* 0=read-only, 1=write-only, 2=read-write */ + int sharemode); /* SHARE_COMPAT, etc... */ + + /* DOS calls this to record the fact that it has successfully + closed a file, or the fact that the open for this file failed. */ +static void share_close_file(int fileno); /* file_table entry number */ + + /* DOS calls this to determine whether it can access (read or + write) a specific section of a file. We call it internally + from lock_unlock (only when locking) to see if any portion + of the requested region is already locked. If pspseg is zero, + then it matches any pspseg in the lock table. Otherwise, only + locks which DO NOT belong to pspseg will be considered. + Returns zero if okay to access or lock (no portion of the + region is already locked). Otherwise returns non-zero and + generates a critical error (if allowcriter is non-zero). + If non-zero is returned, it is the negated return value for + the DOS call. */ +static int share_access_check(unsigned short pspseg, /* psp segment address of owner process */ + int fileno, /* file_table entry number */ + unsigned long ofs, /* offset into file */ + unsigned long len, /* length (in bytes) of region to access */ + int allowcriter); /* allow a critical error to be generated */ + + /* DOS calls this to lock or unlock a specific section of a file. + Returns zero if successfully locked or unlocked. Otherwise + returns non-zero. + If the return value is non-zero, it is the negated error + return code for the DOS 0x5c call. */ +static int share_lock_unlock(unsigned short pspseg, /* psp segment address of owner process */ + int fileno, /* file_table entry number */ + unsigned long ofs, /* offset into file */ + unsigned long len, /* length (in bytes) of region to lock or unlock */ + int unlock); /* non-zero to unlock; zero to lock */ /* /// End of additions for SHARE. - Ron Cemer */ - #ifdef WITHFAT32 -struct dpb FAR *GetDriveDPB(UBYTE drive, COUNT *rc) +struct dpb FAR *GetDriveDPB(UBYTE drive, COUNT * rc) { struct dpb FAR *dpb; drive = drive == 0 ? default_drive : drive - 1; - + if (drive >= lastdrive) - { - *rc = DE_INVLDDRV; - return 0; - } + { + *rc = DE_INVLDDRV; + return 0; + } dpb = CDSp->cds_table[drive].cdsDpb; - if (dpb == 0 || - CDSp->cds_table[drive].cdsFlags & CDSNETWDRV) - { - *rc = DE_INVLDDRV; - return 0; - } + if (dpb == 0 || CDSp->cds_table[drive].cdsFlags & CDSNETWDRV) + { + *rc = DE_INVLDDRV; + return 0; + } *rc = SUCCESS; return dpb; @@ -141,16 +135,15 @@ sft FAR *idx_to_sft(COUNT SftIndex) return (sft FAR *) - 1; /* Get the SFT block that contains the SFT */ - for (sp = sfthead; sp != (sfttbl FAR *) - 1; - sp = sp->sftt_next) + for (sp = sfthead; sp != (sfttbl FAR *) - 1; sp = sp->sftt_next) { - if (SftIndex < sp->sftt_count) + if (SftIndex < sp->sftt_count) { lpCurSft = (sft FAR *) & (sp->sftt_table[SftIndex]); - + /* finally, point to the right entry */ return lpCurSft; - } + } else SftIndex -= sp->sftt_count; } @@ -181,8 +174,8 @@ sft FAR *get_sft(UCOUNT hndl) * binary reads, while for 0x40 the type of read (binary/text) depends on what * the SFT says. -- ror4 */ -UCOUNT GenericReadSft(sft FAR *s, UCOUNT n, BYTE FAR * bp, COUNT FAR * err, - BOOL force_binary) +UCOUNT GenericReadSft(sft FAR * s, UCOUNT n, BYTE FAR * bp, + COUNT FAR * err, BOOL force_binary) { UCOUNT ReadCount; @@ -211,7 +204,7 @@ UCOUNT GenericReadSft(sft FAR *s, UCOUNT n, BYTE FAR * bp, COUNT FAR * err, save_dta = dta; lpCurSft = s; - current_filepos = s->sft_posit; /* needed for MSCDEX */ + current_filepos = s->sft_posit; /* needed for MSCDEX */ dta = bp; ReadCount = remote_read(s, n, &rc); dta = save_dta; @@ -274,19 +267,21 @@ UCOUNT GenericReadSft(sft FAR *s, UCOUNT n, BYTE FAR * bp, COUNT FAR * err, COUNT rc; /* /// Added for SHARE - Ron Cemer */ - if (IsShareInstalled()) { - if (s->sft_shroff >= 0) { - int share_result = share_access_check - (cu_psp, - s->sft_shroff, - s->sft_posit, - (unsigned long)n, - 1); - if (share_result != 0) { - *err = share_result; - return 0; - } - } + if (IsShareInstalled()) + { + if (s->sft_shroff >= 0) + { + int share_result = share_access_check(cu_psp, + s->sft_shroff, + s->sft_posit, + (unsigned long)n, + 1); + if (share_result != 0) + { + *err = share_result; + return 0; + } + } } /* /// End of additions for SHARE - Ron Cemer */ @@ -305,7 +300,7 @@ UCOUNT DosRead(COUNT hndl, UCOUNT n, BYTE FAR * bp, COUNT FAR * err) } #endif -UCOUNT DosWriteSft(sft FAR *s, UCOUNT n, BYTE FAR * bp, COUNT FAR * err) +UCOUNT DosWriteSft(sft FAR * s, UCOUNT n, BYTE FAR * bp, COUNT FAR * err) { UCOUNT WriteCount; @@ -332,7 +327,7 @@ UCOUNT DosWriteSft(sft FAR *s, UCOUNT n, BYTE FAR * bp, COUNT FAR * err) save_dta = dta; lpCurSft = s; - current_filepos = s->sft_posit; /* needed for MSCDEX */ + current_filepos = s->sft_posit; /* needed for MSCDEX */ dta = bp; WriteCount = remote_write(s, n, &rc); dta = save_dta; @@ -399,13 +394,14 @@ UCOUNT DosWriteSft(sft FAR *s, UCOUNT n, BYTE FAR * bp, COUNT FAR * err) { REG WORD xfer; - for(xfer = 0; xfer < n && *bp != CTL_Z; bp++, xfer++) + for (xfer = 0; xfer < n && *bp != CTL_Z; bp++, xfer++) { if (s->sft_flags & SFT_FCONOUT) - { - cso(*bp); + { + cso(*bp); } - else FOREVER + else + FOREVER { rq.r_length = sizeof(request); rq.r_command = C_OUTPUT; @@ -414,22 +410,22 @@ UCOUNT DosWriteSft(sft FAR *s, UCOUNT n, BYTE FAR * bp, COUNT FAR * err) rq.r_status = 0; execrh((request FAR *) & rq, s->sft_dev); if (!(rq.r_status & S_ERROR)) - break; - charloop: - switch(char_error(&rq, s->sft_dev)) - { - case ABORT: - case FAIL: - *err = DE_INVLDACC; - return xfer; - case CONTINUE: - break; - case RETRY: - continue; - default: - goto charloop; - } - break; + break; + charloop: + switch (char_error(&rq, s->sft_dev)) + { + case ABORT: + case FAIL: + *err = DE_INVLDACC; + return xfer; + case CONTINUE: + break; + case RETRY: + continue; + default: + goto charloop; + } + break; } if (control_break()) { @@ -447,27 +443,29 @@ UCOUNT DosWriteSft(sft FAR *s, UCOUNT n, BYTE FAR * bp, COUNT FAR * err) COUNT rc; /* /// Added for SHARE - Ron Cemer */ - if (IsShareInstalled()) { - if (s->sft_shroff >= 0) { - int share_result = share_access_check - (cu_psp, - s->sft_shroff, - s->sft_posit, - (unsigned long)n, - 1); - if (share_result != 0) { - *err = share_result; - return 0; - } - } + if (IsShareInstalled()) + { + if (s->sft_shroff >= 0) + { + int share_result = share_access_check(cu_psp, + s->sft_shroff, + s->sft_posit, + (unsigned long)n, + 1); + if (share_result != 0) + { + *err = share_result; + return 0; + } + } } /* /// End of additions for SHARE - Ron Cemer */ WriteCount = writeblock(s->sft_status, bp, n, &rc); s->sft_size = dos_getcufsize(s->sft_status); /* if (rc < SUCCESS) */ - if (rc == DE_ACCESS || /* -5 Access denied */ - rc == DE_INVLDHNDL ) /* -6 Invalid handle */ + if (rc == DE_ACCESS || /* -5 Access denied */ + rc == DE_INVLDHNDL) /* -6 Invalid handle */ { *err = rc; return 0; @@ -482,7 +480,7 @@ UCOUNT DosWriteSft(sft FAR *s, UCOUNT n, BYTE FAR * bp, COUNT FAR * err) return 0; } -COUNT SftSeek(sft FAR *s, LONG new_pos, COUNT mode) +COUNT SftSeek(sft FAR * s, LONG new_pos, COUNT mode) { /* Test for invalid mode */ if (mode < 0 || mode > 2) @@ -493,7 +491,8 @@ COUNT SftSeek(sft FAR *s, LONG new_pos, COUNT mode) if (s->sft_flags & SFT_FSHARED) { /* seek from end of file */ - if (mode == 2) { + if (mode == 2) + { /* * RB list has it as Note: * this function is called by the DOS 3.1+ kernel, but only when seeking @@ -504,60 +503,64 @@ COUNT SftSeek(sft FAR *s, LONG new_pos, COUNT mode) * Lredir via mfs.c from DosEMU works when writing appended files. * Mfs.c looks for these mode bits set, so here is my best guess.;^) */ - if ((s->sft_mode & SFT_MDENYREAD) || (s->sft_mode & SFT_MDENYNONE)) - { - s->sft_posit = remote_lseek(s, new_pos); - return SUCCESS; - } - else - { - s->sft_posit = s->sft_size + new_pos; - return SUCCESS; - } - } - if (mode == 0) { - s->sft_posit = new_pos; + if ((s->sft_mode & SFT_MDENYREAD) || (s->sft_mode & SFT_MDENYNONE)) + { + s->sft_posit = remote_lseek(s, new_pos); return SUCCESS; - } - if (mode == 1) { - s->sft_posit += new_pos; + } + else + { + s->sft_posit = s->sft_size + new_pos; return SUCCESS; + } } - return DE_INVLDFUNC; + if (mode == 0) + { + s->sft_posit = new_pos; + return SUCCESS; } - - /* Do special return for character devices */ - if (s->sft_flags & SFT_FDEVICE) + if (mode == 1) { - s->sft_posit = 0l; - return SUCCESS; + s->sft_posit += new_pos; + return SUCCESS; } + return DE_INVLDFUNC; + } + + /* Do special return for character devices */ + if (s->sft_flags & SFT_FDEVICE) + { + s->sft_posit = 0l; + return SUCCESS; + } + else + { + LONG result = dos_lseek(s->sft_status, new_pos, mode); + if (result < 0l) + return (int)result; else { - LONG result = dos_lseek(s->sft_status, new_pos, mode); - if (result < 0l) - return (int)result; - else { - s->sft_posit = result; - return SUCCESS; - } + s->sft_posit = result; + return SUCCESS; } + } } COUNT DosSeek(COUNT hndl, LONG new_pos, COUNT mode, ULONG * set_pos) { - sft FAR *s; - COUNT result; - - /* Get the SFT block that contains the SFT */ - if ((s = get_sft(hndl)) == (sft FAR *) - 1) - return DE_INVLDHNDL; - - result = SftSeek(s, new_pos, mode); - if (result == SUCCESS) { - *set_pos = s->sft_posit; - } - return result; + sft FAR *s; + COUNT result; + + /* Get the SFT block that contains the SFT */ + if ((s = get_sft(hndl)) == (sft FAR *) - 1) + return DE_INVLDHNDL; + + result = SftSeek(s, new_pos, mode); + if (result == SUCCESS) + { + *set_pos = s->sft_posit; + } + return result; } STATIC COUNT get_free_hndl(void) @@ -573,7 +576,7 @@ STATIC COUNT get_free_hndl(void) return DE_TOOMANY; } -sft FAR *get_free_sft(COUNT *sft_idx) +sft FAR *get_free_sft(COUNT * sft_idx) { COUNT sys_idx = 0; sfttbl FAR *sp; @@ -584,17 +587,17 @@ sft FAR *get_free_sft(COUNT *sft_idx) REG COUNT i = sp->sftt_count; sft FAR *sfti = sp->sftt_table; - for(; --i >= 0 ; sys_idx++, sfti++) + for (; --i >= 0; sys_idx++, sfti++) { if (sfti->sft_count == 0) { - *sft_idx = sys_idx; + *sft_idx = sys_idx; - /* MS NET uses this on open/creat TE*/ - { + /* MS NET uses this on open/creat TE */ + { extern WORD current_sft_idx; current_sft_idx = sys_idx; - } + } return sfti; } @@ -648,12 +651,12 @@ COUNT DosCreatSft(BYTE * fname, COUNT attrib) WORD result; COUNT drive; - /* NEVER EVER allow directories to be created */ + /* NEVER EVER allow directories to be created */ attrib &= 0xff; - if (attrib & ~(D_RDONLY|D_HIDDEN|D_SYSTEM|D_ARCHIVE)) - { - return DE_ACCESS; - } + if (attrib & ~(D_RDONLY | D_HIDDEN | D_SYSTEM | D_ARCHIVE)) + { + return DE_ACCESS; + } /* now get a free system file table entry */ if ((sftp = get_free_sft(&sft_idx)) == (sft FAR *) - 1) @@ -661,47 +664,50 @@ COUNT DosCreatSft(BYTE * fname, COUNT attrib) fmemset(sftp, 0, sizeof(sft)); - sftp->sft_shroff = -1; /* /// Added for SHARE - Ron Cemer */ + sftp->sft_shroff = -1; /* /// Added for SHARE - Ron Cemer */ sftp->sft_psp = cu_psp; sftp->sft_mode = SFT_MRDWR; sftp->sft_attrib = attrib; sftp->sft_psp = cu_psp; - /* check for a device */ - dhp = IsDevice(fname); - if ( dhp ) - { - sftp->sft_count += 1; - sftp->sft_flags = - ((dhp->dh_attr & ~SFT_MASK) & ~SFT_FSHARED) | SFT_FDEVICE | SFT_FEOF; - fmemcpy(sftp->sft_name, (BYTE FAR *) SecPathName, FNAME_SIZE + FEXT_SIZE); - sftp->sft_dev = dhp; - return sft_idx; - } + /* check for a device */ + dhp = IsDevice(fname); + if (dhp) + { + sftp->sft_count += 1; + sftp->sft_flags = + ((dhp-> + dh_attr & ~SFT_MASK) & ~SFT_FSHARED) | SFT_FDEVICE | SFT_FEOF; + fmemcpy(sftp->sft_name, (BYTE FAR *) SecPathName, + FNAME_SIZE + FEXT_SIZE); + sftp->sft_dev = dhp; + return sft_idx; + } - if (current_ldt->cdsFlags & CDSNETWDRV) { - lpCurSft = sftp; - result = remote_creat(sftp, attrib); - if (result == SUCCESS) { - sftp->sft_count += 1; - return sft_idx; - } - return result; + if (current_ldt->cdsFlags & CDSNETWDRV) + { + lpCurSft = sftp; + result = remote_creat(sftp, attrib); + if (result == SUCCESS) + { + sftp->sft_count += 1; + return sft_idx; + } + return result; } - + drive = get_verify_drive(fname); - if (drive < 0) { - return drive; + if (drive < 0) + { + return drive; } - + /* /// Added for SHARE. - Ron Cemer */ - if (IsShareInstalled()) { - if ((sftp->sft_shroff = share_open_check - ((char far *)fname, - cu_psp, - 0x02, /* read-write */ - 0)) < 0) /* compatibility mode */ - return sftp->sft_shroff; + if (IsShareInstalled()) + { + if ((sftp->sft_shroff = share_open_check((char far *)fname, cu_psp, 0x02, /* read-write */ + 0)) < 0) /* compatibility mode */ + return sftp->sft_shroff; } /* /// End of additions for SHARE. - Ron Cemer */ @@ -712,11 +718,14 @@ COUNT DosCreatSft(BYTE * fname, COUNT attrib) sftp->sft_flags = drive; DosGetFile(fname, sftp->sft_name); return sft_idx; - } else { + } + else + { /* /// Added for SHARE *** CURLY BRACES ADDED ALSO!!! ***. - Ron Cemer */ - if (IsShareInstalled()) { - share_close_file(sftp->sft_shroff); - sftp->sft_shroff = -1; + if (IsShareInstalled()) + { + share_close_file(sftp->sft_shroff); + sftp->sft_shroff = -1; } /* /// End of additions for SHARE. - Ron Cemer */ return sftp->sft_status; @@ -727,21 +736,22 @@ COUNT DosCreat(BYTE FAR * fname, COUNT attrib) { psp FAR *p = MK_FP(cu_psp, 0); COUNT sft_idx, hndl, result; - + /* get a free handle */ if ((hndl = get_free_hndl()) < 0) return hndl; result = truename(fname, PriPathName, FALSE); - if (result != SUCCESS) { + if (result != SUCCESS) + { return result; } sft_idx = DosCreatSft(PriPathName, attrib); if (sft_idx < SUCCESS) - return sft_idx; - + return sft_idx; + p->ps_filetab[hndl] = sft_idx; return hndl; } @@ -780,7 +790,8 @@ COUNT DosDup(COUNT Handle) return NewHandle; /* If everything looks ok, bump it up. */ - if ((Sftp->sft_flags & (SFT_FDEVICE | SFT_FSHARED)) || (Sftp->sft_status >= 0)) + if ((Sftp->sft_flags & (SFT_FDEVICE | SFT_FSHARED)) + || (Sftp->sft_status >= 0)) { p->ps_filetab[NewHandle] = p->ps_filetab[Handle]; Sftp->sft_count += 1; @@ -813,7 +824,8 @@ COUNT DosForceDup(COUNT OldHandle, COUNT NewHandle) } /* If everything looks ok, bump it up. */ - if ((Sftp->sft_flags & (SFT_FDEVICE | SFT_FSHARED)) || (Sftp->sft_status >= 0)) + if ((Sftp->sft_flags & (SFT_FDEVICE | SFT_FSHARED)) + || (Sftp->sft_status >= 0)) { p->ps_filetab[NewHandle] = p->ps_filetab[OldHandle]; @@ -851,47 +863,50 @@ COUNT DosOpenSft(BYTE * fname, COUNT mode) /* check for a device */ dhp = IsDevice(fname); - if ( dhp ) + if (dhp) { - sftp->sft_shroff = -1; /* /// Added for SHARE - Ron Cemer */ - + sftp->sft_shroff = -1; /* /// Added for SHARE - Ron Cemer */ sftp->sft_count += 1; sftp->sft_flags = - ((dhp->dh_attr & ~SFT_MASK) & ~SFT_FSHARED) | SFT_FDEVICE | SFT_FEOF; - fmemcpy(sftp->sft_name, (BYTE FAR *) SecPathName, FNAME_SIZE + FEXT_SIZE); + ((dhp-> + dh_attr & ~SFT_MASK) & ~SFT_FSHARED) | SFT_FDEVICE | SFT_FEOF; + fmemcpy(sftp->sft_name, (BYTE FAR *) SecPathName, + FNAME_SIZE + FEXT_SIZE); sftp->sft_dev = dhp; sftp->sft_date = dos_getdate(); sftp->sft_time = dos_gettime(); return sft_idx; } - if (current_ldt->cdsFlags & CDSNETWDRV) { - lpCurSft = sftp; - result = remote_open(sftp, mode); - /* printf("open SFT %d = %p\n",sft_idx,sftp); */ - if (result == SUCCESS) { - sftp->sft_count += 1; - return sft_idx; - } - return result; + if (current_ldt->cdsFlags & CDSNETWDRV) + { + lpCurSft = sftp; + result = remote_open(sftp, mode); + /* printf("open SFT %d = %p\n",sft_idx,sftp); */ + if (result == SUCCESS) + { + sftp->sft_count += 1; + return sft_idx; + } + return result; } drive = get_verify_drive(fname); - if (drive < 0) { - return drive; + if (drive < 0) + { + return drive; } - sftp->sft_shroff = -1; /* /// Added for SHARE - Ron Cemer */ + sftp->sft_shroff = -1; /* /// Added for SHARE - Ron Cemer */ /* /// Added for SHARE. - Ron Cemer */ - if (IsShareInstalled()) { + if (IsShareInstalled()) + { if ((sftp->sft_shroff = share_open_check - ((char far *)fname, - (unsigned short)cu_psp, - mode & 0x03, - (mode >> 2) & 0x07)) < 0) - return sftp->sft_shroff; + ((char far *)fname, + (unsigned short)cu_psp, mode & 0x03, (mode >> 2) & 0x07)) < 0) + return sftp->sft_shroff; } /* /// End of additions for SHARE. - Ron Cemer */ @@ -907,24 +922,27 @@ COUNT DosOpenSft(BYTE * fname, COUNT mode) if ((sftp->sft_attrib & (D_DIR | D_VOLID)) || ((sftp->sft_attrib & D_RDONLY) && (mode != O_RDONLY))) { - dos_close(sftp->sft_status); + dos_close(sftp->sft_status); return DE_ACCESS; } sftp->sft_size = dos_getfsize(sftp->sft_status); dos_getftime(sftp->sft_status, - (date FAR *) & sftp->sft_date, - (time FAR *) & sftp->sft_time); + (date FAR *) & sftp->sft_date, + (time FAR *) & sftp->sft_time); sftp->sft_count += 1; sftp->sft_mode = mode; sftp->sft_flags = drive; DosGetFile(fname, sftp->sft_name); return sft_idx; - } else { + } + else + { /* /// Added for SHARE *** CURLY BRACES ADDED ALSO!!! ***. - Ron Cemer */ - if (IsShareInstalled()) { - share_close_file(sftp->sft_shroff); - sftp->sft_shroff = -1; + if (IsShareInstalled()) + { + share_close_file(sftp->sft_shroff); + sftp->sft_shroff = -1; } /* /// End of additions for SHARE. - Ron Cemer */ return sftp->sft_status; @@ -941,15 +959,16 @@ COUNT DosOpen(BYTE FAR * fname, COUNT mode) return hndl; result = truename(fname, PriPathName, FALSE); - if (result != SUCCESS) { - return result; + if (result != SUCCESS) + { + return result; } sft_idx = DosOpenSft(PriPathName, mode); if (sft_idx < SUCCESS) - return sft_idx; - + return sft_idx; + p->ps_filetab[hndl] = sft_idx; return hndl; } @@ -957,7 +976,7 @@ COUNT DosOpen(BYTE FAR * fname, COUNT mode) COUNT DosCloseSft(WORD sft_idx) { sft FAR *sftp = idx_to_sft(sft_idx); - + if (sftp == (sft FAR *) - 1) return DE_INVLDHNDL; @@ -970,10 +989,10 @@ COUNT DosCloseSft(WORD sft_idx) remote sub sft_count. */ if (sftp->sft_flags & SFT_FSHARED) - { + { /* printf("closing SFT %d = %p\n",sft_idx,sftp); */ return remote_close(sftp); - } + } /* now just drop the count if a device, else */ /* call file system handler */ @@ -984,11 +1003,14 @@ COUNT DosCloseSft(WORD sft_idx) { if (sftp->sft_count > 0) return SUCCESS; - else { + else + { /* /// Added for SHARE *** CURLY BRACES ADDED ALSO!!! ***. - Ron Cemer */ - if (IsShareInstalled()) { - if (sftp->sft_shroff >= 0) share_close_file(sftp->sft_shroff); - sftp->sft_shroff = -1; + if (IsShareInstalled()) + { + if (sftp->sft_shroff >= 0) + share_close_file(sftp->sft_shroff); + sftp->sft_shroff = -1; } /* /// End of additions for SHARE. - Ron Cemer */ return dos_close(sftp->sft_status); @@ -1008,57 +1030,58 @@ COUNT DosClose(COUNT hndl) return ret; } -BOOL DosGetFree(UBYTE drive, UCOUNT FAR * spc, UCOUNT FAR * navc, UCOUNT FAR * bps, UCOUNT FAR * nc) +BOOL DosGetFree(UBYTE drive, UCOUNT FAR * spc, UCOUNT FAR * navc, + UCOUNT FAR * bps, UCOUNT FAR * nc) { - /* *nc==0xffff means: called from FatGetDrvData, fcbfns.c */ + /* *nc==0xffff means: called from FatGetDrvData, fcbfns.c */ struct dpb FAR *dpbp; struct cds FAR *cdsp; - COUNT rg[4]; + COUNT rg[4]; /* next - "log" in the drive */ drive = (drive == 0 ? default_drive : drive - 1); - /* first check for valid drive */ + /* first check for valid drive */ *spc = -1; if (drive >= lastdrive) - return FALSE; - + return FALSE; + cdsp = &CDSp->cds_table[drive]; if (!(cdsp->cdsFlags & CDSVALID)) - return FALSE; - + return FALSE; + if (cdsp->cdsFlags & CDSNETWDRV) { - if (*nc == 0xffff) - { - /* Undoc DOS says, its not supported for - network drives. so it's probably OK */ - /*printf("FatGetDrvData not yet supported over network drives\n");*/ - return FALSE; - } - - remote_getfree(cdsp, rg); - - *spc = (COUNT) rg[0]; - *nc = (COUNT) rg[1]; - *bps = (COUNT) rg[2]; - *navc = (COUNT) rg[3]; - return TRUE; + if (*nc == 0xffff) + { + /* Undoc DOS says, its not supported for + network drives. so it's probably OK */ + /*printf("FatGetDrvData not yet supported over network drives\n"); */ + return FALSE; + } + + remote_getfree(cdsp, rg); + + *spc = (COUNT) rg[0]; + *nc = (COUNT) rg[1]; + *bps = (COUNT) rg[2]; + *navc = (COUNT) rg[3]; + return TRUE; } dpbp = CDSp->cds_table[drive].cdsDpb; if (dpbp == NULL) - return FALSE; + return FALSE; if (*nc == 0xffff) { - flush_buffers(dpbp->dpb_unit); - dpbp->dpb_flags = M_CHANGED; + flush_buffers(dpbp->dpb_unit); + dpbp->dpb_flags = M_CHANGED; } - + if (media_check(dpbp) < 0) - return FALSE; + return FALSE; /* get the data available from dpb */ *spc = dpbp->dpb_clsmask + 1; *bps = dpbp->dpb_secsize; @@ -1071,9 +1094,10 @@ BOOL DosGetFree(UBYTE drive, UCOUNT FAR * spc, UCOUNT FAR * navc, UCOUNT FAR * b ULONG cluster_size, ntotal, nfree; /* we shift ntotal until it is equal to or below 0xfff6 */ - cluster_size = (ULONG)dpbp->dpb_secsize << dpbp->dpb_shftcnt; + cluster_size = (ULONG) dpbp->dpb_secsize << dpbp->dpb_shftcnt; ntotal = dpbp->dpb_xsize - 1; - if (*nc != 0xffff) nfree = dos_free(dpbp); + if (*nc != 0xffff) + nfree = dos_free(dpbp); while (ntotal > FAT_MAGIC16 && cluster_size < 0x8000) { cluster_size <<= 1; @@ -1082,24 +1106,26 @@ BOOL DosGetFree(UBYTE drive, UCOUNT FAR * spc, UCOUNT FAR * navc, UCOUNT FAR * b nfree >>= 1; } /* get the data available from dpb */ - *nc = ntotal > FAT_MAGIC16 ? FAT_MAGIC16 : (UCOUNT)ntotal; + *nc = ntotal > FAT_MAGIC16 ? FAT_MAGIC16 : (UCOUNT) ntotal; /* now tell fs to give us free cluster */ /* count */ - *navc = nfree > FAT_MAGIC16 ? FAT_MAGIC16 : (UCOUNT)nfree; + *navc = nfree > FAT_MAGIC16 ? FAT_MAGIC16 : (UCOUNT) nfree; return TRUE; } #endif /* a passed nc of 0xffff means: skip free; see FatGetDrvData fcbfns.c */ - if (*nc != 0xffff) *navc = (COUNT)dos_free(dpbp); + if (*nc != 0xffff) + *navc = (COUNT) dos_free(dpbp); *nc = dpbp->dpb_size - 1; - if (*spc > 64) { - /* fake for 64k clusters do confuse some DOS programs, but let - others work without overflowing */ + if (*spc > 64) + { + /* fake for 64k clusters do confuse some DOS programs, but let + others work without overflowing */ *spc >>= 1; - *navc = (*navc < FAT_MAGIC16/2) ? (*navc << 1) : FAT_MAGIC16; - *nc = (*nc < FAT_MAGIC16/2) ? (*nc << 1) : FAT_MAGIC16; + *navc = (*navc < FAT_MAGIC16 / 2) ? (*navc << 1) : FAT_MAGIC16; + *nc = (*nc < FAT_MAGIC16 / 2) ? (*nc << 1) : FAT_MAGIC16; } return TRUE; } @@ -1107,48 +1133,52 @@ BOOL DosGetFree(UBYTE drive, UCOUNT FAR * spc, UCOUNT FAR * navc, UCOUNT FAR * b #ifdef WITHFAT32 /* network names like \\SERVER\C aren't supported yet */ #define IS_SLASH(ch) (ch == '\\' || ch == '/') -COUNT DosGetExtFree(BYTE FAR *DriveString, struct xfreespace FAR *xfsp) +COUNT DosGetExtFree(BYTE FAR * DriveString, struct xfreespace FAR * xfsp) { struct dpb FAR *dpbp; struct cds FAR *cdsp; UBYTE drive; - UCOUNT rg[4]; + UCOUNT rg[4]; if (IS_SLASH(DriveString[0]) || !IS_SLASH(DriveString[2]) - || DriveString[1] != ':') - return DE_INVLDDRV; + || DriveString[1] != ':') + return DE_INVLDDRV; drive = DosUpFChar(*DriveString) - 'A'; - if (drive >= lastdrive) return DE_INVLDDRV; + if (drive >= lastdrive) + return DE_INVLDDRV; cdsp = &CDSp->cds_table[drive]; if (!(cdsp->cdsFlags & CDSVALID)) - return DE_INVLDDRV; - + return DE_INVLDDRV; + if (cdsp->cdsFlags & CDSNETWDRV) { - remote_getfree(cdsp, rg); - - xfsp->xfs_clussize = rg[0]; - xfsp->xfs_totalclusters = rg[1]; - xfsp->xfs_secsize = rg[2]; - xfsp->xfs_freeclusters = rg[3]; - } else { - dpbp = CDSp->cds_table[drive].cdsDpb; - if (dpbp == NULL || media_check(dpbp) < 0) + remote_getfree(cdsp, rg); + + xfsp->xfs_clussize = rg[0]; + xfsp->xfs_totalclusters = rg[1]; + xfsp->xfs_secsize = rg[2]; + xfsp->xfs_freeclusters = rg[3]; + } + else + { + dpbp = CDSp->cds_table[drive].cdsDpb; + if (dpbp == NULL || media_check(dpbp) < 0) return DE_INVLDDRV; - xfsp->xfs_secsize = dpbp->dpb_secsize; - xfsp->xfs_totalclusters = (ISFAT32(dpbp) ? dpbp->dpb_xsize : dpbp->dpb_size); - xfsp->xfs_freeclusters = dos_free(dpbp); - xfsp->xfs_clussize = dpbp->dpb_clsmask + 1; - } - xfsp->xfs_totalunits = xfsp->xfs_totalclusters; - xfsp->xfs_freeunits = xfsp->xfs_freeclusters; - xfsp->xfs_totalsectors = xfsp->xfs_totalclusters * xfsp->xfs_clussize; - xfsp->xfs_freesectors = xfsp->xfs_freeclusters * xfsp->xfs_clussize; - xfsp->xfs_datasize = sizeof(struct xfreespace); - - fmemset(xfsp->xfs_reserved, 0, 8); + xfsp->xfs_secsize = dpbp->dpb_secsize; + xfsp->xfs_totalclusters = + (ISFAT32(dpbp) ? dpbp->dpb_xsize : dpbp->dpb_size); + xfsp->xfs_freeclusters = dos_free(dpbp); + xfsp->xfs_clussize = dpbp->dpb_clsmask + 1; + } + xfsp->xfs_totalunits = xfsp->xfs_totalclusters; + xfsp->xfs_freeunits = xfsp->xfs_freeclusters; + xfsp->xfs_totalsectors = xfsp->xfs_totalclusters * xfsp->xfs_clussize; + xfsp->xfs_freesectors = xfsp->xfs_freeclusters * xfsp->xfs_clussize; + xfsp->xfs_datasize = sizeof(struct xfreespace); + + fmemset(xfsp->xfs_reserved, 0, 8); return SUCCESS; } @@ -1157,22 +1187,23 @@ COUNT DosGetExtFree(BYTE FAR *DriveString, struct xfreespace FAR *xfsp) COUNT DosGetCuDir(UBYTE drive, BYTE FAR * s) { BYTE FAR *cp; - + /* next - "log" in the drive */ drive = (drive == 0 ? default_drive : drive - 1); /* first check for valid drive */ - if (drive >= lastdrive || !(CDSp->cds_table[drive].cdsFlags & CDSVALID)) { + if (drive >= lastdrive || !(CDSp->cds_table[drive].cdsFlags & CDSVALID)) + { return DE_INVLDDRV; } - + current_ldt = &CDSp->cds_table[drive]; cp = ¤t_ldt->cdsCurrentPath[current_ldt->cdsJoinOffset]; if (*cp == '\0') - s[0]='\0'; + s[0] = '\0'; else - fstrncpy(s, cp+1, 64); + fstrncpy(s, cp + 1, 64); return SUCCESS; } @@ -1181,43 +1212,43 @@ COUNT DosGetCuDir(UBYTE drive, BYTE FAR * s) COUNT DosChangeDir(BYTE FAR * s) { REG COUNT drive; - COUNT result; - BYTE FAR *p; - - /* don't do wildcard CHDIR --TE*/ - for (p = s; *p; p++) - if (*p == '*' || *p == '?') - return DE_PATHNOTFND; - - - - drive = get_verify_drive(s); - if (drive < 0 ) { - return drive; - } + COUNT result; + BYTE FAR *p; - result = truename(s, PriPathName, FALSE); - if (result != SUCCESS) { - return result; - } + /* don't do wildcard CHDIR --TE */ + for (p = s; *p; p++) + if (*p == '*' || *p == '?') + return DE_PATHNOTFND; + + drive = get_verify_drive(s); + if (drive < 0) + { + return drive; + } + + result = truename(s, PriPathName, FALSE); + if (result != SUCCESS) + { + return result; + } current_ldt = &CDSp->cds_table[drive]; - if (strlen(PriPathName) > sizeof(current_ldt->cdsCurrentPath)-1) + if (strlen(PriPathName) > sizeof(current_ldt->cdsCurrentPath) - 1) return DE_PATHNOTFND; #if defined(CHDIR_DEBUG) - printf("Remote Chdir: n='%Fs' p='%Fs\n",s,PriPathName); + printf("Remote Chdir: n='%Fs' p='%Fs\n", s, PriPathName); #endif /* now get fs to change to new */ - /* directory */ + /* directory */ result = (current_ldt->cdsFlags & CDSNETWDRV) ? remote_chdir() : dos_cd(current_ldt, PriPathName); #if defined(CHDIR_DEBUG) printf("status = %04x, new_path='%Fs'\n", result, cdsd->cdsCurrentPath); #endif if (result != SUCCESS) - return result; + return result; /* Copy the path to the current directory structure. @@ -1225,9 +1256,9 @@ COUNT DosChangeDir(BYTE FAR * s) Some redirectors do not write back to the CDS. SHSUCdX needs this. jt */ - fstrcpy(current_ldt->cdsCurrentPath,PriPathName); + fstrcpy(current_ldt->cdsCurrentPath, PriPathName); if (PriPathName[7] == 0) - current_ldt->cdsCurrentPath[8] = 0; /* Need two Zeros at the end */ + current_ldt->cdsCurrentPath[8] = 0; /* Need two Zeros at the end */ return SUCCESS; } @@ -1237,7 +1268,7 @@ STATIC VOID pop_dmp(dmatch FAR * dmp) dmp->dm_time = SearchDir.dir_time; dmp->dm_date = SearchDir.dir_date; dmp->dm_size = (LONG) SearchDir.dir_size; - ConvertName83ToNameSZ(dmp->dm_name, (BYTE FAR *)SearchDir.dir_name); + ConvertName83ToNameSZ(dmp->dm_name, (BYTE FAR *) SearchDir.dir_name); } COUNT DosFindFirst(UCOUNT attr, BYTE FAR * name) @@ -1246,40 +1277,41 @@ COUNT DosFindFirst(UCOUNT attr, BYTE FAR * name) REG dmatch FAR *dmp = (dmatch FAR *) dta; BYTE FAR *p; - /* /// Added code here to do matching against device names. - DOS findfirst will match exact device names if the - filename portion (excluding the extension) contains - a valid device name. - Credits: some of this code was ripped off from truename() - in newstuff.c. - - Ron Cemer */ + /* /// Added code here to do matching against device names. + DOS findfirst will match exact device names if the + filename portion (excluding the extension) contains + a valid device name. + Credits: some of this code was ripped off from truename() + in newstuff.c. + - Ron Cemer */ fmemset(dta, 0, sizeof(dmatch)); - + /* initially mark the dta as invalid for further findnexts */ - ((dmatch FAR *)dta)->dm_attr_fnd = D_DEVICE; - + ((dmatch FAR *) dta)->dm_attr_fnd = D_DEVICE; + memset(&SearchDir, 0, sizeof(struct dirent)); - + rc = truename(name, PriPathName, FALSE); if (rc != SUCCESS) - return rc; - + return rc; + if (IsDevice(PriPathName)) { COUNT i; - + /* Found a matching device. Hence there cannot be wildcards. */ SearchDir.dir_attrib = D_DEVICE; SearchDir.dir_time = dos_gettime(); SearchDir.dir_date = dos_getdate(); p = get_root(PriPathName); - memset(SearchDir.dir_name, ' ', FNAME_SIZE+FEXT_SIZE); + memset(SearchDir.dir_name, ' ', FNAME_SIZE + FEXT_SIZE); for (i = 0; i < FNAME_SIZE && *p && *p != '.'; i++) - SearchDir.dir_name[i] = *p++; - if (*p == '.') p++; + SearchDir.dir_name[i] = *p++; + if (*p == '.') + p++; for (i = 0; i < FEXT_SIZE && *p && *p != '.'; i++) - SearchDir.dir_ext[i] = *p++; + SearchDir.dir_ext[i] = *p++; pop_dmp(dmp); return SUCCESS; } @@ -1293,17 +1325,18 @@ COUNT DosFindFirst(UCOUNT attr, BYTE FAR * name) fmemcpy(TempBuffer, dta, 21); p = dta; - dta = (BYTE FAR *)TempBuffer; - + dta = (BYTE FAR *) TempBuffer; + rc = current_ldt->cdsFlags & CDSNETWDRV ? - remote_findfirst((VOID FAR *)current_ldt) : - dos_findfirst(attr, PriPathName); + remote_findfirst((VOID FAR *) current_ldt) : + dos_findfirst(attr, PriPathName); dta = p; fmemcpy(dta, TempBuffer, 21); - pop_dmp((dmatch FAR *)dta); - if (rc != SUCCESS) ((dmatch FAR *)dta)->dm_attr_fnd = D_DEVICE; /* mark invalid */ + pop_dmp((dmatch FAR *) dta); + if (rc != SUCCESS) + ((dmatch FAR *) dta)->dm_attr_fnd = D_DEVICE; /* mark invalid */ return rc; } @@ -1313,8 +1346,8 @@ COUNT DosFindNext(void) BYTE FAR *p; /* /// findnext will always fail on a device name. - Ron Cemer */ - if (((dmatch FAR *)dta)->dm_attr_fnd == D_DEVICE) - return DE_NFILES; + if (((dmatch FAR *) dta)->dm_attr_fnd == D_DEVICE) + return DE_NFILES; /* * The new version of SHSUCDX 1.0 looks at the dm_drive byte to @@ -1334,20 +1367,18 @@ COUNT DosFindNext(void) * (12h, DE_NFILES) */ #if 0 - printf("findnext: %d\n", - ((dmatch FAR *)dta)->dm_drive); + printf("findnext: %d\n", ((dmatch FAR *) dta)->dm_drive); #endif fmemcpy(TempBuffer, dta, 21); fmemset(dta, 0, sizeof(dmatch)); p = dta; - dta = (BYTE FAR *)TempBuffer; - rc = (((dmatch *)TempBuffer)->dm_drive & 0x80) ? - remote_findnext((VOID FAR *)current_ldt) : - dos_findnext(); - + dta = (BYTE FAR *) TempBuffer; + rc = (((dmatch *) TempBuffer)->dm_drive & 0x80) ? + remote_findnext((VOID FAR *) current_ldt) : dos_findnext(); + dta = p; fmemcpy(dta, TempBuffer, 21); - pop_dmp((dmatch FAR *)dta); + pop_dmp((dmatch FAR *) dta); return rc; } @@ -1380,7 +1411,7 @@ COUNT DosSetFtimeSft(WORD sft_idx, date dp, time tp) { /* Get the SFT block that contains the SFT */ sft FAR *s = idx_to_sft(sft_idx); - + if (s == (sft FAR *) - 1) return DE_INVLDHNDL; @@ -1405,37 +1436,42 @@ COUNT DosSetFtimeSft(WORD sft_idx, date dp, time tp) COUNT DosGetFattr(BYTE FAR * name) { - COUNT result, drive; + COUNT result, drive; - if (IsDevice(name)) { - return DE_FILENOTFND; - } + if (IsDevice(name)) + { + return DE_FILENOTFND; + } - drive = get_verify_drive(name); - if (drive < 0) { - return drive; - } + drive = get_verify_drive(name); + if (drive < 0) + { + return drive; + } - result = truename(name, PriPathName, FALSE); - if (result != SUCCESS) { - return result; - } + result = truename(name, PriPathName, FALSE); + if (result != SUCCESS) + { + return result; + } /* /// Added check for "d:\", which returns 0x10 (subdirectory) under DOS. - Ron Cemer */ - if ( (PriPathName[0] != '\0') - && (PriPathName[1] == ':') - && ( (PriPathName[2] == '/') || (PriPathName[2] == '\\') ) - && (PriPathName[3] == '\0') ) { - return 0x10; - } + if ((PriPathName[0] != '\0') + && (PriPathName[1] == ':') + && ((PriPathName[2] == '/') || (PriPathName[2] == '\\')) + && (PriPathName[3] == '\0')) + { + return 0x10; + } - current_ldt = &CDSp->cds_table[drive]; - if (current_ldt->cdsFlags & CDSNETWDRV) - { - return remote_getfattr(); - } - else { + current_ldt = &CDSp->cds_table[drive]; + if (current_ldt->cdsFlags & CDSNETWDRV) + { + return remote_getfattr(); + } + else + { /* /// Use truename()'s result, which we already have in PriPathName. I copy it to tmp_name because PriPathName is global and seems to get trashed somewhere in transit. @@ -1451,48 +1487,52 @@ COUNT DosGetFattr(BYTE FAR * name) /* no longer true. dos_getfattr() is A) intelligent (uses dos_open) anyway B) there are some problems with MAX_PARSE, i.e. if PATH ~= 64 - and TRUENAME adds a C:, which leeds to trouble. - + and TRUENAME adds a C:, which leeds to trouble. + the problem was discovered, when VC did something like - - fd = DosOpen(filename,...) - jc can't_copy_dialog; - - attr = DosGetAttrib(filename); - jc can't_copy_dialog; - and suddenly, the filehandle stays open - shit. - tom - */ - return dos_getfattr(PriPathName); - - } + + fd = DosOpen(filename,...) + jc can't_copy_dialog; + + attr = DosGetAttrib(filename); + jc can't_copy_dialog; + and suddenly, the filehandle stays open + shit. + tom + */ + return dos_getfattr(PriPathName); + + } } COUNT DosSetFattr(BYTE FAR * name, UWORD attrp) { - COUNT result, drive; - - if (IsDevice(name) ) { - return DE_FILENOTFND; - } - - drive = get_verify_drive(name); - if (drive < 0) { - return drive; - } - - result = truename(name, PriPathName, FALSE); - if (result != SUCCESS) { - return result; - } - - current_ldt = &CDSp->cds_table[drive]; - if (current_ldt->cdsFlags & CDSNETWDRV) - { - return remote_setfattr(attrp); - } - else { + COUNT result, drive; + + if (IsDevice(name)) + { + return DE_FILENOTFND; + } + + drive = get_verify_drive(name); + if (drive < 0) + { + return drive; + } + + result = truename(name, PriPathName, FALSE); + if (result != SUCCESS) + { + return result; + } + + current_ldt = &CDSp->cds_table[drive]; + if (current_ldt->cdsFlags & CDSNETWDRV) + { + return remote_setfattr(attrp); + } + else + { /* /// Use truename()'s result, which we already have in PriPathName. I copy it to tmp_name because PriPathName is global and seems to get trashed somewhere in transit. @@ -1503,135 +1543,160 @@ COUNT DosSetFattr(BYTE FAR * name, UWORD attrp) return dos_setfattr(SecPathName, attrp); see DosGetAttr() -*/ - return dos_setfattr(PriPathName, attrp); +*/ + return dos_setfattr(PriPathName, attrp); - } + } } UBYTE DosSelectDrv(UBYTE drv) { current_ldt = &CDSp->cds_table[drv]; - + if ((drv < lastdrive) && (current_ldt->cdsFlags & CDSVALID)) /* && ((cdsp->cdsFlags & CDSNETWDRV) || (cdsp->cdsDpb!=NULL && media_check(cdsp->cdsDpb)==SUCCESS))) -*/ +*/ default_drive = drv; - + return lastdrive; } -COUNT DosDelete(BYTE FAR *path) +COUNT DosDelete(BYTE FAR * path) { - COUNT result, drive; - - if (IsDevice(path)) { - return DE_FILENOTFND; - } - - drive = get_verify_drive(path); - if (drive < 0) { - return drive; - } - result = truename(path, PriPathName, FALSE); - if (result != SUCCESS) { - return result; - } - current_ldt = &CDSp->cds_table[drive]; - if (current_ldt->cdsFlags & CDSNETWDRV) { - return remote_delete(); - } else { - return dos_delete(PriPathName); - } + COUNT result, drive; + + if (IsDevice(path)) + { + return DE_FILENOTFND; + } + + drive = get_verify_drive(path); + if (drive < 0) + { + return drive; + } + result = truename(path, PriPathName, FALSE); + if (result != SUCCESS) + { + return result; + } + current_ldt = &CDSp->cds_table[drive]; + if (current_ldt->cdsFlags & CDSNETWDRV) + { + return remote_delete(); + } + else + { + return dos_delete(PriPathName); + } } COUNT DosRenameTrue(BYTE * path1, BYTE * path2) { - COUNT drive1, drive2; + COUNT drive1, drive2; - if (IsDevice(path1) || IsDevice(path2)) { - return DE_FILENOTFND; - } + if (IsDevice(path1) || IsDevice(path2)) + { + return DE_FILENOTFND; + } - drive1 = get_verify_drive(path1); - drive2 = get_verify_drive(path2); - if ((drive1 != drive2) || (drive1 < 0)) { - return DE_INVLDDRV; - } - current_ldt = &CDSp->cds_table[drive1]; - if (current_ldt->cdsFlags & CDSNETWDRV) { - return remote_rename(); - } else { - return dos_rename(PriPathName, SecPathName); - } + drive1 = get_verify_drive(path1); + drive2 = get_verify_drive(path2); + if ((drive1 != drive2) || (drive1 < 0)) + { + return DE_INVLDDRV; + } + current_ldt = &CDSp->cds_table[drive1]; + if (current_ldt->cdsFlags & CDSNETWDRV) + { + return remote_rename(); + } + else + { + return dos_rename(PriPathName, SecPathName); + } } COUNT DosRename(BYTE FAR * path1, BYTE FAR * path2) { - COUNT result; + COUNT result; - result = truename(path1, PriPathName, FALSE); - if (result != SUCCESS) { - return result; - } + result = truename(path1, PriPathName, FALSE); + if (result != SUCCESS) + { + return result; + } - result = truename(path2, SecPathName, FALSE); - if (result != SUCCESS) { - return result; - } + result = truename(path2, SecPathName, FALSE); + if (result != SUCCESS) + { + return result; + } - return DosRenameTrue(PriPathName, SecPathName); + return DosRenameTrue(PriPathName, SecPathName); } COUNT DosMkdir(BYTE FAR * dir) { - COUNT result, drive; - - if (IsDevice(dir)) { - return DE_PATHNOTFND; - } - - drive = get_verify_drive(dir); - if (drive < 0) { - return drive; - } - result = truename(dir, PriPathName, FALSE); - if (result != SUCCESS) { - return result; - } - current_ldt = &CDSp->cds_table[drive]; - if (current_ldt->cdsFlags & CDSNETWDRV) { - return remote_mkdir(); - } else { - return dos_mkdir(PriPathName); - } + COUNT result, drive; + + if (IsDevice(dir)) + { + return DE_PATHNOTFND; + } + + drive = get_verify_drive(dir); + if (drive < 0) + { + return drive; + } + result = truename(dir, PriPathName, FALSE); + if (result != SUCCESS) + { + return result; + } + current_ldt = &CDSp->cds_table[drive]; + if (current_ldt->cdsFlags & CDSNETWDRV) + { + return remote_mkdir(); + } + else + { + return dos_mkdir(PriPathName); + } } COUNT DosRmdir(BYTE FAR * dir) { - COUNT result, drive; - - if (IsDevice(dir)) { - return DE_PATHNOTFND; - } - - drive = get_verify_drive(dir); - if (drive < 0) { - return drive; - } - result = truename(dir, PriPathName, FALSE); - if (result != SUCCESS) { - return result; - } - current_ldt = &CDSp->cds_table[drive]; - if (CDSp->cds_table[drive].cdsFlags & CDSNETWDRV) { - return remote_rmdir(); - } else { - return dos_rmdir(PriPathName); - } + COUNT result, drive; + + if (IsDevice(dir)) + { + return DE_PATHNOTFND; + } + + drive = get_verify_drive(dir); + if (drive < 0) + { + return drive; + } + result = truename(dir, PriPathName, FALSE); + if (result != SUCCESS) + { + return result; + } + current_ldt = &CDSp->cds_table[drive]; + if (CDSp->cds_table[drive].cdsFlags & CDSNETWDRV) + { + return remote_rmdir(); + } + else + { + return dos_rmdir(PriPathName); + } } /* /// Added for SHARE. - Ron Cemer */ @@ -1641,13 +1706,16 @@ COUNT DosLockUnlock(COUNT hndl, LONG pos, LONG len, COUNT unlock) sft FAR *s; /* Invalid function unless SHARE is installed. */ - if (!IsShareInstalled()) return DE_INVLDFUNC; + if (!IsShareInstalled()) + return DE_INVLDFUNC; /* Get the SFT block that contains the SFT */ - if ((s = get_sft(hndl)) == (sft FAR *) -1) return DE_INVLDHNDL; + if ((s = get_sft(hndl)) == (sft FAR *) - 1) + return DE_INVLDHNDL; /* Lock violation if this SFT entry does not support locking. */ - if (s->sft_shroff < 0) return DE_LOCK; + if (s->sft_shroff < 0) + return DE_LOCK; /* Let SHARE do the work. */ return share_lock_unlock(cu_psp, s->sft_shroff, pos, len, unlock); @@ -1659,12 +1727,12 @@ COUNT DosLockUnlock(COUNT hndl, LONG pos, LONG len, COUNT unlock) * This seems to work well. */ -struct dhdr FAR * IsDevice(BYTE FAR * fname) +struct dhdr FAR *IsDevice(BYTE FAR * fname) { struct dhdr FAR *dhp; BYTE FAR *froot; WORD i; - BYTE tmpPathName[FNAME_SIZE+1]; + BYTE tmpPathName[FNAME_SIZE + 1]; /* check for a device */ froot = get_root(fname); @@ -1691,129 +1759,133 @@ struct dhdr FAR * IsDevice(BYTE FAR * fname) { */ - for (dhp = (struct dhdr FAR *)&nul_dev; dhp != (struct dhdr FAR *)-1; dhp = dhp->dh_next) - { + for (dhp = (struct dhdr FAR *)&nul_dev; dhp != (struct dhdr FAR *)-1; + dhp = dhp->dh_next) + { - /* BUGFIX: MSCD000<00> should be handled like MSCD000<20> TE */ + /* BUGFIX: MSCD000<00> should be handled like MSCD000<20> TE */ - char dev_name_buff[FNAME_SIZE]; + char dev_name_buff[FNAME_SIZE]; - int namelen = fstrlen(dhp->dh_name); - - memset(dev_name_buff, ' ', FNAME_SIZE); - - fmemcpy(dev_name_buff,dhp->dh_name, min(namelen,FNAME_SIZE)); - - if (fnmatch((BYTE FAR *) tmpPathName, (BYTE FAR *) dev_name_buff, FNAME_SIZE, FALSE)) - { - memcpy(SecPathName, tmpPathName, i+1); - return dhp; - } + int namelen = fstrlen(dhp->dh_name); + + memset(dev_name_buff, ' ', FNAME_SIZE); + + fmemcpy(dev_name_buff, dhp->dh_name, min(namelen, FNAME_SIZE)); + + if (fnmatch + ((BYTE FAR *) tmpPathName, (BYTE FAR *) dev_name_buff, FNAME_SIZE, + FALSE)) + { + memcpy(SecPathName, tmpPathName, i + 1); + return dhp; } + } return (struct dhdr FAR *)0; } - /* /// Added for SHARE. - Ron Cemer */ -BOOL IsShareInstalled(void) { - if (!share_installed) { - iregs regs; - - regs.a.x = 0x1000; - intr(0x2f, ®s); - share_installed = ((regs.a.x & 0xff) == 0xff); - } - return share_installed; -} - - /* DOS calls this to see if it's okay to open the file. - Returns a file_table entry number to use (>= 0) if okay - to open. Otherwise returns < 0 and may generate a critical - error. If < 0 is returned, it is the negated error return - code, so DOS simply negates this value and returns it in - AX. */ -static int share_open_check - (char far *filename, /* far pointer to fully qualified filename */ - unsigned short pspseg, /* psp segment address of owner process */ - int openmode, /* 0=read-only, 1=write-only, 2=read-write */ - int sharemode) { /* SHARE_COMPAT, etc... */ +BOOL IsShareInstalled(void) +{ + if (!share_installed) + { iregs regs; - regs.a.x = 0x10a0; - regs.ds = FP_SEG(filename); - regs.si = FP_OFF(filename); - regs.b.x = pspseg; - regs.c.x = openmode; - regs.d.x = sharemode; + regs.a.x = 0x1000; intr(0x2f, ®s); - return (int)regs.a.x; + share_installed = ((regs.a.x & 0xff) == 0xff); + } + return share_installed; } - /* DOS calls this to record the fact that it has successfully - closed a file, or the fact that the open for this file failed. */ -static void share_close_file - (int fileno) { /* file_table entry number */ - iregs regs; - - regs.a.x = 0x10a1; - regs.b.x = fileno; - intr(0x2f, ®s); + /* DOS calls this to see if it's okay to open the file. + Returns a file_table entry number to use (>= 0) if okay + to open. Otherwise returns < 0 and may generate a critical + error. If < 0 is returned, it is the negated error return + code, so DOS simply negates this value and returns it in + AX. */ +static int share_open_check(char far * filename, /* far pointer to fully qualified filename */ + unsigned short pspseg, /* psp segment address of owner process */ + int openmode, /* 0=read-only, 1=write-only, 2=read-write */ + int sharemode) +{ /* SHARE_COMPAT, etc... */ + iregs regs; + + regs.a.x = 0x10a0; + regs.ds = FP_SEG(filename); + regs.si = FP_OFF(filename); + regs.b.x = pspseg; + regs.c.x = openmode; + regs.d.x = sharemode; + intr(0x2f, ®s); + return (int)regs.a.x; } - /* DOS calls this to determine whether it can access (read or - write) a specific section of a file. We call it internally - from lock_unlock (only when locking) to see if any portion - of the requested region is already locked. If pspseg is zero, - then it matches any pspseg in the lock table. Otherwise, only - locks which DO NOT belong to pspseg will be considered. - Returns zero if okay to access or lock (no portion of the - region is already locked). Otherwise returns non-zero and - generates a critical error (if allowcriter is non-zero). - If non-zero is returned, it is the negated return value for - the DOS call. */ -static int share_access_check - (unsigned short pspseg,/* psp segment address of owner process */ - int fileno, /* file_table entry number */ - unsigned long ofs, /* offset into file */ - unsigned long len, /* length (in bytes) of region to access */ - int allowcriter) { /* allow a critical error to be generated */ - iregs regs; + /* DOS calls this to record the fact that it has successfully + closed a file, or the fact that the open for this file failed. */ +static void share_close_file(int fileno) +{ /* file_table entry number */ + iregs regs; - regs.a.x = 0x10a2 | (allowcriter ? 0x01 : 0x00); - regs.b.x = pspseg; - regs.c.x = fileno; - regs.si = (unsigned short)((ofs >> 16) & 0xffffL); - regs.di = (unsigned short)(ofs & 0xffffL); - regs.es = (unsigned short)((len >> 16) & 0xffffL); - regs.d.x = (unsigned short)(len & 0xffffL); - intr(0x2f, ®s); - return (int)regs.a.x; + regs.a.x = 0x10a1; + regs.b.x = fileno; + intr(0x2f, ®s); } - /* DOS calls this to lock or unlock a specific section of a file. - Returns zero if successfully locked or unlocked. Otherwise - returns non-zero. - If the return value is non-zero, it is the negated error - return code for the DOS 0x5c call. */ -static int share_lock_unlock - (unsigned short pspseg,/* psp segment address of owner process */ - int fileno, /* file_table entry number */ - unsigned long ofs, /* offset into file */ - unsigned long len, /* length (in bytes) of region to lock or unlock */ - int unlock) { /* non-zero to unlock; zero to lock */ - iregs regs; + /* DOS calls this to determine whether it can access (read or + write) a specific section of a file. We call it internally + from lock_unlock (only when locking) to see if any portion + of the requested region is already locked. If pspseg is zero, + then it matches any pspseg in the lock table. Otherwise, only + locks which DO NOT belong to pspseg will be considered. + Returns zero if okay to access or lock (no portion of the + region is already locked). Otherwise returns non-zero and + generates a critical error (if allowcriter is non-zero). + If non-zero is returned, it is the negated return value for + the DOS call. */ +static int share_access_check(unsigned short pspseg, /* psp segment address of owner process */ + int fileno, /* file_table entry number */ + unsigned long ofs, /* offset into file */ + unsigned long len, /* length (in bytes) of region to access */ + int allowcriter) +{ /* allow a critical error to be generated */ + iregs regs; + + regs.a.x = 0x10a2 | (allowcriter ? 0x01 : 0x00); + regs.b.x = pspseg; + regs.c.x = fileno; + regs.si = (unsigned short)((ofs >> 16) & 0xffffL); + regs.di = (unsigned short)(ofs & 0xffffL); + regs.es = (unsigned short)((len >> 16) & 0xffffL); + regs.d.x = (unsigned short)(len & 0xffffL); + intr(0x2f, ®s); + return (int)regs.a.x; +} - regs.a.x = 0x10a4 | (unlock ? 0x01 : 0x00); - regs.b.x = pspseg; - regs.c.x = fileno; - regs.si = (unsigned short)((ofs >> 16) & 0xffffL); - regs.di = (unsigned short)(ofs & 0xffffL); - regs.es = (unsigned short)((len >> 16) & 0xffffL); - regs.d.x = (unsigned short)(len & 0xffffL); - intr(0x2f, ®s); - return (int)regs.a.x; + /* DOS calls this to lock or unlock a specific section of a file. + Returns zero if successfully locked or unlocked. Otherwise + returns non-zero. + If the return value is non-zero, it is the negated error + return code for the DOS 0x5c call. */ +static int share_lock_unlock(unsigned short pspseg, /* psp segment address of owner process */ + int fileno, /* file_table entry number */ + unsigned long ofs, /* offset into file */ + unsigned long len, /* length (in bytes) of region to lock or unlock */ + int unlock) +{ /* non-zero to unlock; zero to lock */ + iregs regs; + + regs.a.x = 0x10a4 | (unlock ? 0x01 : 0x00); + regs.b.x = pspseg; + regs.c.x = fileno; + regs.si = (unsigned short)((ofs >> 16) & 0xffffL); + regs.di = (unsigned short)(ofs & 0xffffL); + regs.es = (unsigned short)((len >> 16) & 0xffffL); + regs.d.x = (unsigned short)(len & 0xffffL); + intr(0x2f, ®s); + return (int)regs.a.x; } /* /// End of additions for SHARE. - Ron Cemer */ @@ -1905,4 +1977,3 @@ static int share_lock_unlock * Rev 1.0 02 Jul 1995 8:04:20 patv * Initial revision. */ - diff --git a/kernel/dosnames.c b/kernel/dosnames.c index 3a99cfb7..eceff6ce 100644 --- a/kernel/dosnames.c +++ b/kernel/dosnames.c @@ -31,7 +31,8 @@ #include "portab.h" #ifdef VERSION_STRINGS -static BYTE *dosnamesRcsId = "$Id$"; +static BYTE *dosnamesRcsId = + "$Id$"; #endif #include "globals.h" @@ -79,16 +80,10 @@ VOID SpacePad(BYTE * szString, COUNT nChars) COUNT ParseDosName(BYTE * lpszFileName, COUNT * pnDrive, BYTE * pszDir, - BYTE * pszFile, - BYTE * pszExt, - BOOL bAllowWildcards) + BYTE * pszFile, BYTE * pszExt, BOOL bAllowWildcards) { - COUNT nDirCnt, - nFileCnt, - nExtCnt; - BYTE *lpszLclDir, - *lpszLclFile, - *lpszLclExt; + COUNT nDirCnt, nFileCnt, nExtCnt; + BYTE *lpszLclDir, *lpszLclFile, *lpszLclExt; /* Initialize the users data fields */ if (pszDir) @@ -118,12 +113,13 @@ COUNT ParseDosName(BYTE * lpszFileName, } nDirCnt = FP_OFF(lpszLclFile) - FP_OFF(lpszLclDir); /* Fix lengths to maximums allowed by MS-DOS. */ - if (nDirCnt > PARSE_MAX-1) - nDirCnt = PARSE_MAX-1; + if (nDirCnt > PARSE_MAX - 1) + nDirCnt = PARSE_MAX - 1; /* Parse out the file name portion. */ lpszFileName = lpszLclFile; - while (bAllowWildcards ? WildChar(*lpszFileName) : NameChar(*lpszFileName)) + while (bAllowWildcards ? WildChar(*lpszFileName) : + NameChar(*lpszFileName)) { ++nFileCnt; ++lpszFileName; @@ -131,26 +127,25 @@ COUNT ParseDosName(BYTE * lpszFileName, if (nFileCnt == 0) /* Lixing Yuan Patch */ - if (bAllowWildcards) /* for find first */ - { - if (*lpszFileName != '\0') - return DE_FILENOTFND; - if (nDirCnt == 1) /* for d:\ */ - return DE_NFILES; - if (pszDir) - { - memcpy(pszDir, lpszLclDir, nDirCnt); - pszDir[nDirCnt] = '\0'; - } - if (pszFile) - memcpy(pszFile, "????????", FNAME_SIZE+1); - if (pszExt) - memcpy(pszExt, "???", FEXT_SIZE+1); - return SUCCESS; - } - else - return DE_FILENOTFND; - + if (bAllowWildcards) /* for find first */ + { + if (*lpszFileName != '\0') + return DE_FILENOTFND; + if (nDirCnt == 1) /* for d:\ */ + return DE_NFILES; + if (pszDir) + { + memcpy(pszDir, lpszLclDir, nDirCnt); + pszDir[nDirCnt] = '\0'; + } + if (pszFile) + memcpy(pszFile, "????????", FNAME_SIZE + 1); + if (pszExt) + memcpy(pszExt, "???", FEXT_SIZE + 1); + return SUCCESS; + } + else + return DE_FILENOTFND; /* Now we have pointers set to the directory portion and the */ /* file portion. Now determine the existance of an extension. */ @@ -160,14 +155,16 @@ COUNT ParseDosName(BYTE * lpszFileName, lpszLclExt = ++lpszFileName; while (*lpszFileName) { - if (bAllowWildcards ? WildChar(*lpszFileName) : NameChar(*lpszFileName)) + if (bAllowWildcards ? WildChar(*lpszFileName) : + NameChar(*lpszFileName)) { ++nExtCnt; ++lpszFileName; } - else{ + else + { return DE_FILENOTFND; - } + } } } else if (*lpszFileName) @@ -199,14 +196,10 @@ COUNT ParseDosName(BYTE * lpszFileName, #if 0 /* not necessary anymore because of truename */ COUNT ParseDosPath(BYTE * lpszFileName, - COUNT * pnDrive, - BYTE * pszDir, - BYTE * pszCurPath) + COUNT * pnDrive, BYTE * pszDir, BYTE * pszCurPath) { - COUNT nDirCnt, - nPathCnt; - BYTE *lpszLclDir, - *pszBase = pszDir; + COUNT nDirCnt, nPathCnt; + BYTE *lpszLclDir, *pszBase = pszDir; /* Initialize the users data fields */ *pszDir = '\0'; @@ -237,10 +230,10 @@ COUNT ParseDosPath(BYTE * lpszFileName, lpszLclDir = lpszFileName; if (!PathSep(*lpszLclDir)) { - fstrncpy(pszDir, pszCurPath, PARSE_MAX - 1); /*TE*/ - nPathCnt = fstrlen(pszCurPath); - if (!PathSep(pszDir[nPathCnt - 1]) && nPathCnt < PARSE_MAX - 1) /*TE*/ - pszDir[nPathCnt++] = '\\'; + fstrncpy(pszDir, pszCurPath, PARSE_MAX - 1); + /*TE*/ nPathCnt = fstrlen(pszCurPath); + if (!PathSep(pszDir[nPathCnt - 1]) && nPathCnt < PARSE_MAX - 1) + /*TE*/ pszDir[nPathCnt++] = '\\'; if (nPathCnt > PARSE_MAX) nPathCnt = PARSE_MAX; pszDir += nPathCnt; @@ -248,16 +241,15 @@ COUNT ParseDosPath(BYTE * lpszFileName, /* Now see how long a directory component we have. */ while (NameChar(*lpszFileName) - || PathSep(*lpszFileName) - || '.' == *lpszFileName) + || PathSep(*lpszFileName) || '.' == *lpszFileName) { ++nDirCnt; ++lpszFileName; } /* Fix lengths to maximums allowed by MS-DOS. */ - if ((nDirCnt + nPathCnt) > PARSE_MAX - 1) /*TE*/ - nDirCnt = PARSE_MAX - 1 - nPathCnt; + if ((nDirCnt + nPathCnt) > PARSE_MAX - 1) + /*TE*/ nDirCnt = PARSE_MAX - 1 - nPathCnt; /* Finally copy whatever the user wants extracted to the user's */ /* buffers. */ @@ -289,11 +281,8 @@ COUNT ParseDosPath(BYTE * lpszFileName, VOID DosTrimPath(BYTE * lpszPathNamep) { - BYTE *lpszLast, - *lpszNext, - *lpszRoot = NULL; - COUNT nChars, - flDotDot; + BYTE *lpszLast, *lpszNext, *lpszRoot = NULL; + COUNT nChars, flDotDot; /* First, convert all '/' to '\'. Look for root as we scan */ if (*lpszPathNamep == '\\') @@ -302,14 +291,13 @@ VOID DosTrimPath(BYTE * lpszPathNamep) { if (*lpszNext == '/') *lpszNext = '\\'; - if (!lpszRoot && - *lpszNext == ':' && *(lpszNext + 1) == '\\') + if (!lpszRoot && *lpszNext == ':' && *(lpszNext + 1) == '\\') lpszRoot = lpszNext + 1; } - /* NAMEMAX + 2, must include C: TE*/ + /* NAMEMAX + 2, must include C: TE */ for (lpszLast = lpszNext = lpszPathNamep, nChars = 0; - *lpszNext != '\0' && nChars < NAMEMAX+2;) + *lpszNext != '\0' && nChars < NAMEMAX + 2;) { /* Initialize flag for loop. */ flDotDot = FALSE; @@ -325,8 +313,7 @@ VOID DosTrimPath(BYTE * lpszPathNamep) /* as appropriate. */ else if (*(lpszNext + 1) == '.') { - if (*(lpszNext + 2) == '.' - && !(*(lpszNext + 3))) + if (*(lpszNext + 2) == '.' && !(*(lpszNext + 3))) { /* At the end, just truncate */ /* and exit. */ @@ -337,8 +324,7 @@ VOID DosTrimPath(BYTE * lpszPathNamep) return; } - if (*(lpszNext + 2) == '.' - && *(lpszNext + 3) == '\\') + if (*(lpszNext + 2) == '.' && *(lpszNext + 3) == '\\') { fstrncpy(lpszLast, lpszNext + 3, NAMEMAX); /* bump back to the last */ @@ -351,8 +337,7 @@ VOID DosTrimPath(BYTE * lpszPathNamep) { --lpszLast; } - while (lpszLast != lpszPathNamep - && *lpszLast != '\\'); + while (lpszLast != lpszPathNamep && *lpszLast != '\\'); flDotDot = TRUE; } /* Note: we skip strange stuff that */ @@ -360,7 +345,7 @@ VOID DosTrimPath(BYTE * lpszPathNamep) else if (*(lpszNext + 2) == '\\') { fstrncpy(lpszNext, lpszNext + 2, NAMEMAX); - flDotDot = TRUE; + flDotDot = TRUE; } /* If we're at the end of a string, */ /* just exit. */ @@ -460,4 +445,3 @@ VOID DosTrimPath(BYTE * lpszPathNamep) * Initial revision. * */ - diff --git a/kernel/dsk.c b/kernel/dsk.c index 075c5eed..be89ccbe 100644 --- a/kernel/dsk.c +++ b/kernel/dsk.c @@ -29,22 +29,20 @@ #include "dyndata.h" #ifdef VERSION_STRINGS -static BYTE *dskRcsId = "$Id$"; +static BYTE *dskRcsId = + "$Id$"; #endif -#if defined(DEBUG) - #define DebugPrintf(x) printf x -#else - #define DebugPrintf(x) -#endif +#if defined(DEBUG) +#define DebugPrintf(x) printf x +#else +#define DebugPrintf(x) +#endif /* #define STATIC */ - - - #ifdef PROTO -BOOL ASMCFUNC fl_reset(WORD); +BOOL ASMCFUNC fl_reset(WORD); COUNT ASMCFUNC fl_readdasd(WORD); COUNT ASMCFUNC fl_diskchanged(WORD); COUNT ASMCFUNC fl_rd_status(WORD); @@ -57,11 +55,12 @@ COUNT ASMCFUNC fl_setdisktype(WORD, WORD); COUNT ASMCFUNC fl_setmediatype(WORD, WORD, WORD); VOID ASMCFUNC fl_readkey(VOID); -extern COUNT ASMCFUNC fl_lba_ReadWrite (BYTE drive, WORD mode, - struct _bios_LBA_address_packet FAR *dap_p); +extern COUNT ASMCFUNC fl_lba_ReadWrite(BYTE drive, WORD mode, + struct _bios_LBA_address_packet FAR + * dap_p); -int LBA_Transfer(ddt *pddt ,UWORD mode, VOID FAR *buffer, - ULONG LBA_address,unsigned total, UWORD *transferred); +int LBA_Transfer(ddt * pddt, UWORD mode, VOID FAR * buffer, + ULONG LBA_address, unsigned total, UWORD * transferred); #else BOOL fl_reset(); COUNT fl_readdasd(); @@ -76,86 +75,79 @@ COUNT fl_setmediatype(); COUNT fl_setdisktype(); #endif -#define NENTRY 26 /* total size of dispatch table */ +#define NENTRY 26 /* total size of dispatch table */ extern BYTE FAR nblk_rel; extern int FAR ASMCFUNC Get_nblk_rel(void); - - #define LBA_READ 0x4200 #define LBA_WRITE 0x4300 -UWORD LBA_WRITE_VERIFY = 0x4302; +UWORD LBA_WRITE_VERIFY = 0x4302; #define LBA_VERIFY 0x4400 -#define LBA_FORMAT 0xffff /* fake number for FORMAT track - (only for NON-LBA floppies now!) */ +#define LBA_FORMAT 0xffff /* fake number for FORMAT track + (only for NON-LBA floppies now!) */ /* this buffer must not overlap a 64K boundary due to DMA transfers this is certainly true, if located somewhere at 0xf+1000 and must hold already during BOOT time - */ + */ UBYTE DiskTransferBuffer[1 * SEC_SIZE]; -static struct Access_info -{ - BYTE AI_spec; - BYTE AI_Flag; +static struct Access_info { + BYTE AI_spec; + BYTE AI_Flag; }; -struct FS_info -{ - ULONG serialno; - BYTE volume[11]; - BYTE fstype[8]; +struct FS_info { + ULONG serialno; + BYTE volume[11]; + BYTE fstype[8]; }; extern struct DynS Dyn; /*TE - array access functions */ -ddt *getddt(int dev) { return &(((ddt*)Dyn.Buffer)[dev]);} +ddt *getddt(int dev) +{ + return &(((ddt *) Dyn.Buffer)[dev]); +} #define N_PART 4 /* number of partitions per - table partition */ + table partition */ -COUNT nUnits; /* number of returned units */ +COUNT nUnits; /* number of returned units */ #define PARTOFF 0x1be - #ifdef PROTO WORD - _dsk_init (rqptr rq, ddt *pddt), - mediachk (rqptr rq, ddt *pddt), - bldbpb (rqptr rq, ddt *pddt), - blockio (rqptr rq, ddt *pddt), - IoctlQueblk(rqptr rq, ddt *pddt), - Genblkdev (rqptr rq, ddt *pddt), - Getlogdev (rqptr rq, ddt *pddt), - Setlogdev (rqptr rq, ddt *pddt), - blk_Open (rqptr rq, ddt *pddt), - blk_Close (rqptr rq, ddt *pddt), - blk_Media (rqptr rq, ddt *pddt), - blk_noerr (rqptr rq, ddt *pddt), - blk_nondr (rqptr rq, ddt *pddt), - blk_error (rqptr rq, ddt *pddt); +_dsk_init(rqptr rq, ddt * pddt), +mediachk(rqptr rq, ddt * pddt), +bldbpb(rqptr rq, ddt * pddt), +blockio(rqptr rq, ddt * pddt), +IoctlQueblk(rqptr rq, ddt * pddt), +Genblkdev(rqptr rq, ddt * pddt), +Getlogdev(rqptr rq, ddt * pddt), +Setlogdev(rqptr rq, ddt * pddt), +blk_Open(rqptr rq, ddt * pddt), +blk_Close(rqptr rq, ddt * pddt), +blk_Media(rqptr rq, ddt * pddt), +blk_noerr(rqptr rq, ddt * pddt), +blk_nondr(rqptr rq, ddt * pddt), blk_error(rqptr rq, ddt * pddt); WORD dskerr(COUNT); #else WORD _dsk_init(), - mediachk(), - bldbpb(), - blockio(), - IoctlQueblk(), - Genblkdev(), - Getlogdev(), - Setlogdev(), - blk_Open(), - blk_Close(), - blk_Media(), - blk_noerr(), - blk_nondr(), - blk_error(); +mediachk(), +bldbpb(), +blockio(), +IoctlQueblk(), +Genblkdev(), +Getlogdev(), +Setlogdev(), +blk_Open(), +blk_Close(), blk_Media(), blk_noerr(), blk_nondr(), blk_error(); WORD dskerr(); #endif @@ -164,12 +156,12 @@ WORD dskerr(); /* */ #ifdef PROTO -static WORD(*dispatch[NENTRY]) (rqptr rq, ddt *pddt) = +static WORD(*dispatch[NENTRY]) (rqptr rq, ddt * pddt) = #else static WORD(*dispatch[NENTRY]) () = #endif { - _dsk_init, /* Initialize */ + _dsk_init, /* Initialize */ mediachk, /* Media Check */ bldbpb, /* Build BPB */ blk_error, /* Ioctl In */ @@ -197,20 +189,12 @@ static WORD(*dispatch[NENTRY]) () = IoctlQueblk /* Ioctl Query */ }; - - - - - #define hd(x) ((x) & DF_FIXED) /* ----------------------------------------------------------------------- */ /* F U N C T I O N S --------------------------------------------------- */ /* ----------------------------------------------------------------------- */ - - - COUNT FAR ASMCFUNC blk_driver(rqptr rp) { if (rp->r_unit >= nUnits && rp->r_command != C_INIT) @@ -224,45 +208,45 @@ COUNT FAR ASMCFUNC blk_driver(rqptr rp) } /* disk init is done in diskinit.c, so this should never be called */ -WORD _dsk_init(rqptr rp, ddt *pddt) +WORD _dsk_init(rqptr rp, ddt * pddt) { UNREFERENCED_PARAMETER(rp); UNREFERENCED_PARAMETER(pddt); fatal("No disk init!"); - return S_DONE; /* to keep the compiler happy */ + return S_DONE; /* to keep the compiler happy */ } -STATIC WORD play_dj(ddt*pddt) +STATIC WORD play_dj(ddt * pddt) { /* play the DJ ... */ if ((pddt->ddt_descflags & (DF_MULTLOG | DF_CURLOG)) == DF_MULTLOG) { - int i; - ddt *pddt2 = getddt(0); - for (i = 0; i < nUnits; i++, pddt2++) - { - if (pddt->ddt_driveno == pddt2->ddt_driveno && - (pddt2->ddt_descflags & (DF_MULTLOG | DF_CURLOG)) == - (DF_MULTLOG | DF_CURLOG)) - break; - } - if (i == nUnits) - { - printf("Error in the DJ mechanism!\n"); /* should not happen! */ - return M_CHANGED; - } - printf("Remove diskette in drive %c:\n", 'A'+pddt2->ddt_logdriveno); - printf("Insert diskette in drive %c:\n", 'A'+pddt->ddt_logdriveno); - printf("Press the any key to continue ... \n"); - fl_readkey(); - pddt2->ddt_descflags &= ~DF_CURLOG; - pddt->ddt_descflags |= DF_CURLOG; + int i; + ddt *pddt2 = getddt(0); + for (i = 0; i < nUnits; i++, pddt2++) + { + if (pddt->ddt_driveno == pddt2->ddt_driveno && + (pddt2->ddt_descflags & (DF_MULTLOG | DF_CURLOG)) == + (DF_MULTLOG | DF_CURLOG)) + break; + } + if (i == nUnits) + { + printf("Error in the DJ mechanism!\n"); /* should not happen! */ return M_CHANGED; + } + printf("Remove diskette in drive %c:\n", 'A' + pddt2->ddt_logdriveno); + printf("Insert diskette in drive %c:\n", 'A' + pddt->ddt_logdriveno); + printf("Press the any key to continue ... \n"); + fl_readkey(); + pddt2->ddt_descflags &= ~DF_CURLOG; + pddt->ddt_descflags |= DF_CURLOG; + return M_CHANGED; } return M_NOT_CHANGED; -} +} -STATIC WORD diskchange(ddt *pddt) +STATIC WORD diskchange(ddt * pddt) { COUNT result; @@ -273,7 +257,7 @@ STATIC WORD diskchange(ddt *pddt) if (play_dj(pddt) == M_CHANGED) return M_CHANGED; - if (pddt->ddt_descflags & DF_CHANGELINE) /* if we can detect a change ... */ + if (pddt->ddt_descflags & DF_CHANGELINE) /* if we can detect a change ... */ { if ((result = fl_diskchanged(pddt->ddt_driveno)) == 1) /* check if it has changed... */ @@ -286,7 +270,7 @@ STATIC WORD diskchange(ddt *pddt) return tdelay((LONG) 37) ? M_DONT_KNOW : M_NOT_CHANGED; } -WORD mediachk(rqptr rp, ddt *pddt) +WORD mediachk(rqptr rp, ddt * pddt) { /* check floppy status */ if (pddt->ddt_descflags & DF_REFORMAT) @@ -299,7 +283,7 @@ WORD mediachk(rqptr rp, ddt *pddt) pddt->ddt_descflags &= ~DF_DISKCHANGE; rp->r_mcretcode = M_DONT_KNOW; } - else + else { rp->r_mcretcode = diskchange(pddt); } @@ -309,136 +293,141 @@ WORD mediachk(rqptr rp, ddt *pddt) /* * Read Write Sector Zero or Hard Drive Dos Bpb */ -STATIC WORD RWzero(ddt *pddt, UWORD mode) +STATIC WORD RWzero(ddt * pddt, UWORD mode) { - UWORD done; + UWORD done; return LBA_Transfer(pddt, mode, - (UBYTE FAR *)&DiskTransferBuffer, - pddt->ddt_offset,1,&done); + (UBYTE FAR *) & DiskTransferBuffer, + pddt->ddt_offset, 1, &done); } /* 0 if not set, 1 = a, 2 = b, etc, assume set. page 424 MS Programmer's Ref. */ -static WORD Getlogdev(rqptr rp, ddt *pddt) +static WORD Getlogdev(rqptr rp, ddt * pddt) { - BYTE x = rp->r_unit; - - UNREFERENCED_PARAMETER(pddt); - - x++; - if( x > Get_nblk_rel() ) - return failure(E_UNIT); + BYTE x = rp->r_unit; - rp->r_unit = x; - return S_DONE; + UNREFERENCED_PARAMETER(pddt); + + x++; + if (x > Get_nblk_rel()) + return failure(E_UNIT); + + rp->r_unit = x; + return S_DONE; } -static WORD Setlogdev(rqptr rp, ddt *pddt) +static WORD Setlogdev(rqptr rp, ddt * pddt) { - UNREFERENCED_PARAMETER(rp); - UNREFERENCED_PARAMETER(pddt); + UNREFERENCED_PARAMETER(rp); + UNREFERENCED_PARAMETER(pddt); - return S_DONE; + return S_DONE; } -static WORD blk_Open(rqptr rp, ddt *pddt) +static WORD blk_Open(rqptr rp, ddt * pddt) { - UNREFERENCED_PARAMETER(rp); + UNREFERENCED_PARAMETER(rp); - pddt->ddt_FileOC++; - return S_DONE; + pddt->ddt_FileOC++; + return S_DONE; } -static WORD blk_Close(rqptr rp, ddt *pddt) +static WORD blk_Close(rqptr rp, ddt * pddt) { - UNREFERENCED_PARAMETER(rp); + UNREFERENCED_PARAMETER(rp); - pddt->ddt_FileOC--; - return S_DONE; + pddt->ddt_FileOC--; + return S_DONE; } -static WORD blk_nondr(rqptr rp, ddt *pddt) +static WORD blk_nondr(rqptr rp, ddt * pddt) { - UNREFERENCED_PARAMETER(rp); - UNREFERENCED_PARAMETER(pddt); + UNREFERENCED_PARAMETER(rp); + UNREFERENCED_PARAMETER(pddt); - return S_BUSY|S_DONE; + return S_BUSY | S_DONE; } -static WORD blk_Media(rqptr rp, ddt *pddt) +static WORD blk_Media(rqptr rp, ddt * pddt) { UNREFERENCED_PARAMETER(rp); - if (hd( pddt->ddt_descflags)) - return S_BUSY|S_DONE; /* Hard Drive */ + if (hd(pddt->ddt_descflags)) + return S_BUSY | S_DONE; /* Hard Drive */ else return S_DONE; /* Floppy */ } -static WORD getbpb(ddt *pddt) +static WORD getbpb(ddt * pddt) { ULONG count; bpb *pbpbarray = &pddt->ddt_bpb; - WORD head,/*track,*/sector,ret; + WORD head, /*track, */ sector, ret; - pddt->ddt_descflags |= DF_NOACCESS; /* set drive to not accessible and changed */ + pddt->ddt_descflags |= DF_NOACCESS; /* set drive to not accessible and changed */ if (diskchange(pddt) != M_NOT_CHANGED) - pddt->ddt_descflags |= DF_DISKCHANGE; + pddt->ddt_descflags |= DF_DISKCHANGE; ret = RWzero(pddt, LBA_READ); if (ret != 0) - return (dskerr(ret)); - - getword(&((((BYTE *) & DiskTransferBuffer[BT_BPB]))[0]), &pbpbarray->bpb_nbyte); - - if (DiskTransferBuffer[0x1fe]!=0x55 || DiskTransferBuffer[0x1ff]!=0xaa || - pbpbarray->bpb_nbyte != 512) { - /* copy default bpb to be sure that there is no bogus data */ - memcpy(pbpbarray, &pddt->ddt_defbpb, sizeof(bpb)); - return S_DONE; + return (dskerr(ret)); + + getword(&((((BYTE *) & DiskTransferBuffer[BT_BPB]))[0]), + &pbpbarray->bpb_nbyte); + + if (DiskTransferBuffer[0x1fe] != 0x55 + || DiskTransferBuffer[0x1ff] != 0xaa || pbpbarray->bpb_nbyte != 512) + { + /* copy default bpb to be sure that there is no bogus data */ + memcpy(pbpbarray, &pddt->ddt_defbpb, sizeof(bpb)); + return S_DONE; } - pddt->ddt_descflags &= ~DF_NOACCESS; /* set drive to accessible */ + pddt->ddt_descflags &= ~DF_NOACCESS; /* set drive to accessible */ -/*TE ~ 200 bytes*/ +/*TE ~ 200 bytes*/ fmemcpy(pbpbarray, &DiskTransferBuffer[BT_BPB], sizeof(bpb)); #ifdef WITHFAT32 - /*??*/ + /*?? */ /* 2b is fat16 volume label. if memcmp, then offset 0x36. - if (fstrncmp((BYTE *) & DiskTransferBuffer[0x36], "FAT16",5) == 0 || - fstrncmp((BYTE *) & DiskTransferBuffer[0x36], "FAT12",5) == 0) { - TE: I'm not sure, what the _real_ decision point is, however MSDN - 'A_BF_BPB_SectorsPerFAT - The number of sectors per FAT. - Note: This member will always be zero in a FAT32 BPB. - Use the values from A_BF_BPB_BigSectorsPerFat... - */ + if (fstrncmp((BYTE *) & DiskTransferBuffer[0x36], "FAT16",5) == 0 || + fstrncmp((BYTE *) & DiskTransferBuffer[0x36], "FAT12",5) == 0) { + TE: I'm not sure, what the _real_ decision point is, however MSDN + 'A_BF_BPB_SectorsPerFAT + The number of sectors per FAT. + Note: This member will always be zero in a FAT32 BPB. + Use the values from A_BF_BPB_BigSectorsPerFat... + */ if (pbpbarray->bpb_nfsect != 0) { /* FAT16/FAT12 boot sector */ - getlong(&((((BYTE *) & DiskTransferBuffer[0x27])[0])), &pddt->ddt_serialno); - memcpy(pddt->ddt_volume,&DiskTransferBuffer[0x2B], 11); - memcpy(pddt->ddt_fstype,&DiskTransferBuffer[0x36], 8); - } else { - /* FAT32 boot sector */ - getlong(&((((BYTE *) & DiskTransferBuffer[0x43])[0])), &pddt->ddt_serialno); - memcpy(pddt->ddt_volume,&DiskTransferBuffer[0x47], 11); - memcpy(pddt->ddt_fstype,&DiskTransferBuffer[0x52], 8); + getlong(&((((BYTE *) & DiskTransferBuffer[0x27])[0])), + &pddt->ddt_serialno); + memcpy(pddt->ddt_volume, &DiskTransferBuffer[0x2B], 11); + memcpy(pddt->ddt_fstype, &DiskTransferBuffer[0x36], 8); + } + else + { + /* FAT32 boot sector */ + getlong(&((((BYTE *) & DiskTransferBuffer[0x43])[0])), + &pddt->ddt_serialno); + memcpy(pddt->ddt_volume, &DiskTransferBuffer[0x47], 11); + memcpy(pddt->ddt_fstype, &DiskTransferBuffer[0x52], 8); pbpbarray->bpb_ndirent = 512; - } + } #else - getlong(&((((BYTE *) & DiskTransferBuffer[0x27])[0])), &pddt->ddt_serialno); - memcpy(pddt->ddt_volume,&DiskTransferBuffer[0x2B], 11); - memcpy(pddt->ddt_fstype,&DiskTransferBuffer[0x36], 8); + getlong(&((((BYTE *) & DiskTransferBuffer[0x27])[0])), + &pddt->ddt_serialno); + memcpy(pddt->ddt_volume, &DiskTransferBuffer[0x2B], 11); + memcpy(pddt->ddt_fstype, &DiskTransferBuffer[0x36], 8); #endif - - #ifdef DSK_DEBUG printf("BPB_NBYTE = %04x\n", pbpbarray->bpb_nbyte); printf("BPB_NSECTOR = %02x\n", pbpbarray->bpb_nsector); @@ -452,8 +441,7 @@ static WORD getbpb(ddt *pddt) count = pbpbarray->bpb_nsize == 0 ? - pbpbarray->bpb_huge : - pbpbarray->bpb_nsize; + pbpbarray->bpb_huge : pbpbarray->bpb_nsize; head = pbpbarray->bpb_nheads; sector = pbpbarray->bpb_nsecs; @@ -463,7 +451,7 @@ static WORD getbpb(ddt *pddt) return failure(E_FAILURE); } pddt->ddt_ncyl = (count + head * sector - 1) / (head * sector); - + tmark(); #ifdef DSK_DEBUG @@ -476,340 +464,357 @@ static WORD getbpb(ddt *pddt) return 0; } - -STATIC WORD bldbpb(rqptr rp, ddt *pddt) +STATIC WORD bldbpb(rqptr rp, ddt * pddt) { WORD result; if ((result = getbpb(pddt)) != 0) - return result; + return result; rp->r_bpptr = &pddt->ddt_bpb; return S_DONE; } - -static WORD IoctlQueblk(rqptr rp, ddt *pddt) +static WORD IoctlQueblk(rqptr rp, ddt * pddt) { - UNREFERENCED_PARAMETER(pddt); + UNREFERENCED_PARAMETER(pddt); - switch(rp->r_count){ + switch (rp->r_count) + { case 0x0846: case 0x0847: case 0x0860: case 0x0866: case 0x0867: - break; + break; default: - return failure(E_CMD); - } + return failure(E_CMD); + } return S_DONE; } -COUNT Genblockio(ddt *pddt, UWORD mode, WORD head, WORD track, WORD sector, - WORD count, VOID FAR *buffer) +COUNT Genblockio(ddt * pddt, UWORD mode, WORD head, WORD track, + WORD sector, WORD count, VOID FAR * buffer) { - UWORD transferred; - - /* apparently sector is ZERO, not ONE based !!! */ - return LBA_Transfer(pddt, mode, buffer, - ((ULONG)track * pddt->ddt_bpb.bpb_nheads + head) * - (ULONG)pddt->ddt_bpb.bpb_nsecs + - pddt->ddt_offset + sector, - count, &transferred); + UWORD transferred; + + /* apparently sector is ZERO, not ONE based !!! */ + return LBA_Transfer(pddt, mode, buffer, + ((ULONG) track * pddt->ddt_bpb.bpb_nheads + head) * + (ULONG) pddt->ddt_bpb.bpb_nsecs + + pddt->ddt_offset + sector, count, &transferred); } -STATIC WORD Genblkdev(rqptr rp,ddt *pddt) +STATIC WORD Genblkdev(rqptr rp, ddt * pddt) { - int ret; - bpb *pbpb; + int ret; + bpb *pbpb; #ifdef WITHFAT32 - int extended = 0; - - if ((rp->r_count >> 8) == 0x48) extended = 1; - else + int extended = 0; + + if ((rp->r_count >> 8) == 0x48) + extended = 1; + else #endif - if ((rp->r_count >> 8) != 8) - return failure(E_CMD); + if ((rp->r_count >> 8) != 8) + return failure(E_CMD); - switch(rp->r_count & 0xff){ - case 0x40: /* set device parameters */ - { - struct gblkio FAR * gblp = (struct gblkio FAR *) rp->r_trans; - - pddt->ddt_type = gblp->gbio_devtype; - pddt->ddt_descflags &= ~3; - pddt->ddt_descflags |= (gblp->gbio_devattrib & 3) - | (DF_DPCHANGED | DF_REFORMAT); - pddt->ddt_ncyl = gblp->gbio_ncyl; - /* use default dpb or current bpb? */ - pbpb = (gblp->gbio_spcfunbit & 0x01) == 0 ? &pddt->ddt_defbpb : &pddt->ddt_bpb; + switch (rp->r_count & 0xff) + { + case 0x40: /* set device parameters */ + { + struct gblkio FAR *gblp = (struct gblkio FAR *)rp->r_trans; + + pddt->ddt_type = gblp->gbio_devtype; + pddt->ddt_descflags &= ~3; + pddt->ddt_descflags |= (gblp->gbio_devattrib & 3) + | (DF_DPCHANGED | DF_REFORMAT); + pddt->ddt_ncyl = gblp->gbio_ncyl; + /* use default dpb or current bpb? */ + pbpb = + (gblp->gbio_spcfunbit & 0x01) == + 0 ? &pddt->ddt_defbpb : &pddt->ddt_bpb; #ifdef WITHFAT32 - if (!extended) fmemcpy(pbpb, &gblp->gbio_bpb, BPB_SIZEOF); - else + if (!extended) + fmemcpy(pbpb, &gblp->gbio_bpb, BPB_SIZEOF); + else #endif - fmemcpy(pbpb, &gblp->gbio_bpb, sizeof(gblp->gbio_bpb)); - /*pbpb->bpb_nsector = gblp->gbio_nsecs;*/ - break; - } - case 0x41: /* write track */ - { - struct gblkrw FAR * rw = (struct gblkrw FAR *) rp->r_trans; - ret = Genblockio(pddt, LBA_WRITE, rw->gbrw_head, rw->gbrw_cyl, - rw->gbrw_sector, rw->gbrw_nsecs, rw->gbrw_buffer); - if (ret != 0) - return dskerr(ret); - } - break; - case 0x42: /* format/verify track */ - { - struct gblkfv FAR * fv = (struct gblkfv FAR *) rp->r_trans; - COUNT tracks; - struct thst {UBYTE track, head, sector, type;} *addrfield, afentry; - - if (hd(pddt->ddt_descflags)) - { - /* XXX no low-level formatting for hard disks implemented */ - fv->gbfv_spcfunbit = 1; /* "not supported by bios" */ - pddt->ddt_descflags &= ~DF_DPCHANGED; - return S_DONE; - } - if (pddt->ddt_descflags & DF_DPCHANGED) - { - pddt->ddt_descflags &= ~DF_DPCHANGED; + fmemcpy(pbpb, &gblp->gbio_bpb, sizeof(gblp->gbio_bpb)); + /*pbpb->bpb_nsector = gblp->gbio_nsecs; */ + break; + } + case 0x41: /* write track */ + { + struct gblkrw FAR *rw = (struct gblkrw FAR *)rp->r_trans; + ret = Genblockio(pddt, LBA_WRITE, rw->gbrw_head, rw->gbrw_cyl, + rw->gbrw_sector, rw->gbrw_nsecs, rw->gbrw_buffer); + if (ret != 0) + return dskerr(ret); + } + break; + case 0x42: /* format/verify track */ + { + struct gblkfv FAR *fv = (struct gblkfv FAR *)rp->r_trans; + COUNT tracks; + struct thst { + UBYTE track, head, sector, type; + } *addrfield, afentry; - /* first try newer setmediatype function */ - ret = fl_setmediatype(pddt->ddt_driveno, pddt->ddt_ncyl, - pddt->ddt_bpb.bpb_nsecs); - if (ret == 0xc) + if (hd(pddt->ddt_descflags)) + { + /* XXX no low-level formatting for hard disks implemented */ + fv->gbfv_spcfunbit = 1; /* "not supported by bios" */ + pddt->ddt_descflags &= ~DF_DPCHANGED; + return S_DONE; + } + if (pddt->ddt_descflags & DF_DPCHANGED) { + pddt->ddt_descflags &= ~DF_DPCHANGED; + + /* first try newer setmediatype function */ + ret = fl_setmediatype(pddt->ddt_driveno, pddt->ddt_ncyl, + pddt->ddt_bpb.bpb_nsecs); + if (ret == 0xc) + { /* specified tracks, sectors/track not allowed for drive */ fv->gbfv_spcfunbit = 2; return dskerr(ret); - } - else if (ret == 0x80) { - fv->gbfv_spcfunbit = 3; /* no disk in drive */ + } + else if (ret == 0x80) + { + fv->gbfv_spcfunbit = 3; /* no disk in drive */ return dskerr(ret); - } - else if (ret != 0) - /* otherwise, setdisktype */ - { + } + else if (ret != 0) + /* otherwise, setdisktype */ + { COUNT type = 0; if ((fv->gbfv_spcfunbit & 1) && - (ret = fl_read(pddt->ddt_driveno,0,0,1,1,DiskTransferBuffer)) != 0) + (ret = + fl_read(pddt->ddt_driveno, 0, 0, 1, 1, + DiskTransferBuffer)) != 0) { - fv->gbfv_spcfunbit = 3; /* no disk in drive */ - return dskerr(ret); + fv->gbfv_spcfunbit = 3; /* no disk in drive */ + return dskerr(ret); } if (pddt->ddt_ncyl == 40 && - (pddt->ddt_bpb.bpb_nsecs == 9 || pddt->ddt_bpb.bpb_nsecs == 8)) + (pddt->ddt_bpb.bpb_nsecs == 9 + || pddt->ddt_bpb.bpb_nsecs == 8)) { - if (pddt->ddt_type == 0) - type = 1; /* 320/360K disk in 360K drive */ - else if (pddt->ddt_type == 1) - type = 2; /* 320/360K disk in 1.2M drive */ + if (pddt->ddt_type == 0) + type = 1; /* 320/360K disk in 360K drive */ + else if (pddt->ddt_type == 1) + type = 2; /* 320/360K disk in 1.2M drive */ } else if (pddt->ddt_type == 1 && pddt->ddt_ncyl == 80 && pddt->ddt_bpb.bpb_nsecs == 15) - type = 3; /* 1.2M disk in 1.2M drive */ + type = 3; /* 1.2M disk in 1.2M drive */ else if ((pddt->ddt_type == 2 || pddt->ddt_type == 7) && - pddt->ddt_ncyl == 80 && pddt->ddt_bpb.bpb_nsecs == 15 - ) - type = 4; /* 720kb disk in 1.44M or 720kb drive */ + pddt->ddt_ncyl == 80 && pddt->ddt_bpb.bpb_nsecs == 15) + type = 4; /* 720kb disk in 1.44M or 720kb drive */ if (type == 0) { - /* specified tracks, sectors/track not allowed for drive */ - fv->gbfv_spcfunbit = 2; - return dskerr(0xc); + /* specified tracks, sectors/track not allowed for drive */ + fv->gbfv_spcfunbit = 2; + return dskerr(0xc); } fl_setdisktype(pddt->ddt_driveno, type); + } } - } - if (fv->gbfv_spcfunbit & 1) return S_DONE; + if (fv->gbfv_spcfunbit & 1) + return S_DONE; - afentry.type = 2; /* 512 byte sectors */ - afentry.track = fv->gbfv_cyl; - afentry.head = fv->gbfv_head; + afentry.type = 2; /* 512 byte sectors */ + afentry.track = fv->gbfv_cyl; + afentry.head = fv->gbfv_head; - for (tracks = fv->gbfv_spcfunbit & 2 ? fv->gbfv_ntracks : 1; tracks > 0; - tracks--) - { - addrfield = (struct thst *)DiskTransferBuffer; + for (tracks = fv->gbfv_spcfunbit & 2 ? fv->gbfv_ntracks : 1; + tracks > 0; tracks--) + { + addrfield = (struct thst *)DiskTransferBuffer; - if (afentry.track > pddt->ddt_ncyl) - return failure(E_FAILURE); + if (afentry.track > pddt->ddt_ncyl) + return failure(E_FAILURE); - for (afentry.sector = 1; afentry.sector <= pddt->ddt_bpb.bpb_nsecs; - afentry.sector++) - memcpy(addrfield++, &afentry, sizeof(afentry)); + for (afentry.sector = 1; + afentry.sector <= pddt->ddt_bpb.bpb_nsecs; afentry.sector++) + memcpy(addrfield++, &afentry, sizeof(afentry)); - ret = Genblockio(pddt, LBA_FORMAT, afentry.head, afentry.track, 0, - pddt->ddt_bpb.bpb_nsecs, DiskTransferBuffer); - if (ret != 0) - return dskerr(ret); + ret = + Genblockio(pddt, LBA_FORMAT, afentry.head, afentry.track, 0, + pddt->ddt_bpb.bpb_nsecs, DiskTransferBuffer); + if (ret != 0) + return dskerr(ret); + } + afentry.head++; + if (afentry.head >= pddt->ddt_bpb.bpb_nheads) + { + afentry.head = 0; + afentry.track++; + } } - afentry.head++; - if (afentry.head >= pddt->ddt_bpb.bpb_nheads) + + /* fall through to verify */ + + case 0x62: /* verify track */ { - afentry.head = 0; - afentry.track++; - } - } + struct gblkfv FAR *fv = (struct gblkfv FAR *)rp->r_trans; - /* fall through to verify */ + ret = Genblockio(pddt, LBA_VERIFY, fv->gbfv_head, fv->gbfv_cyl, 0, + (fv->gbfv_spcfunbit ? + fv->gbfv_ntracks * pddt->ddt_defbpb.bpb_nsecs : + pddt->ddt_defbpb.bpb_nsecs), DiskTransferBuffer); + if (ret != 0) + return dskerr(ret); + fv->gbfv_spcfunbit = 0; /* success */ + } + break; + case 0x46: /* set volume serial number */ + { + struct Gioc_media FAR *gioc = (struct Gioc_media FAR *)rp->r_trans; + struct FS_info FAR *fs; - case 0x62: /* verify track */ - { - struct gblkfv FAR * fv = (struct gblkfv FAR *) rp->r_trans; - - ret = Genblockio(pddt, LBA_VERIFY, fv->gbfv_head, fv->gbfv_cyl, 0, - (fv->gbfv_spcfunbit ? - fv->gbfv_ntracks * pddt->ddt_defbpb.bpb_nsecs : - pddt->ddt_defbpb.bpb_nsecs), DiskTransferBuffer); - if (ret != 0) - return dskerr(ret); - fv->gbfv_spcfunbit = 0; /* success */ - } - break; - case 0x46: /* set volume serial number */ - { - struct Gioc_media FAR * gioc = (struct Gioc_media FAR *) rp->r_trans; - struct FS_info FAR * fs; - ret = getbpb(pddt); if (ret != 0) - return (ret); + return (ret); - fs = (struct FS_info FAR *) &DiskTransferBuffer + fs = (struct FS_info FAR *)&DiskTransferBuffer [(pddt->ddt_bpb.bpb_nfsect != 0 ? 0x27 : 0x43)]; - fs->serialno = gioc->ioc_serialno; + fs->serialno = gioc->ioc_serialno; pddt->ddt_serialno = fs->serialno; ret = RWzero(pddt, LBA_WRITE); if (ret != 0) - return (dskerr(ret)); - } - break; - case 0x47: /* set access flag */ - { - struct Access_info FAR * ai = (struct Access_info FAR *) rp->r_trans; - pddt->ddt_descflags &= ~DF_NOACCESS; - pddt->ddt_descflags |= (ai->AI_Flag ? 0 : DF_NOACCESS); - } - break; - case 0x60: /* get device parameters */ - { - struct gblkio FAR * gblp = (struct gblkio FAR *) rp->r_trans; - - gblp->gbio_devtype = pddt->ddt_type; - gblp->gbio_devattrib = pddt->ddt_descflags & 3; - /* 360 kb disk in 1.2 MB drive */ - gblp->gbio_media = (pddt->ddt_type == 1) && (pddt->ddt_ncyl == 40); - gblp->gbio_ncyl = pddt->ddt_ncyl; - /* use default dpb or current bpb? */ - pbpb = (gblp->gbio_spcfunbit & 0x01) == 0 ? &pddt->ddt_defbpb : &pddt->ddt_bpb; + return (dskerr(ret)); + } + break; + case 0x47: /* set access flag */ + { + struct Access_info FAR *ai = (struct Access_info FAR *)rp->r_trans; + pddt->ddt_descflags &= ~DF_NOACCESS; + pddt->ddt_descflags |= (ai->AI_Flag ? 0 : DF_NOACCESS); + } + break; + case 0x60: /* get device parameters */ + { + struct gblkio FAR *gblp = (struct gblkio FAR *)rp->r_trans; + + gblp->gbio_devtype = pddt->ddt_type; + gblp->gbio_devattrib = pddt->ddt_descflags & 3; + /* 360 kb disk in 1.2 MB drive */ + gblp->gbio_media = (pddt->ddt_type == 1) && (pddt->ddt_ncyl == 40); + gblp->gbio_ncyl = pddt->ddt_ncyl; + /* use default dpb or current bpb? */ + pbpb = + (gblp->gbio_spcfunbit & 0x01) == + 0 ? &pddt->ddt_defbpb : &pddt->ddt_bpb; #ifdef WITHFAT32 - if (!extended) fmemcpy(&gblp->gbio_bpb, pbpb, BPB_SIZEOF); - else + if (!extended) + fmemcpy(&gblp->gbio_bpb, pbpb, BPB_SIZEOF); + else #endif - fmemcpy(&gblp->gbio_bpb, pbpb, sizeof(gblp->gbio_bpb)); - /*gblp->gbio_nsecs = pbpb->bpb_nsector;*/ - break; - } - case 0x61: /* read track */ - { - struct gblkrw FAR * rw = (struct gblkrw FAR *) rp->r_trans; - ret = Genblockio(pddt, LBA_READ, rw->gbrw_head, rw->gbrw_cyl, - rw->gbrw_sector, rw->gbrw_nsecs, rw->gbrw_buffer); - if (ret != 0) - return dskerr(ret); - } - break; - case 0x66: /* get volume serial number */ - { - struct Gioc_media FAR * gioc = (struct Gioc_media FAR *) rp->r_trans; + fmemcpy(&gblp->gbio_bpb, pbpb, sizeof(gblp->gbio_bpb)); + /*gblp->gbio_nsecs = pbpb->bpb_nsector; */ + break; + } + case 0x61: /* read track */ + { + struct gblkrw FAR *rw = (struct gblkrw FAR *)rp->r_trans; + ret = Genblockio(pddt, LBA_READ, rw->gbrw_head, rw->gbrw_cyl, + rw->gbrw_sector, rw->gbrw_nsecs, rw->gbrw_buffer); + if (ret != 0) + return dskerr(ret); + } + break; + case 0x66: /* get volume serial number */ + { + struct Gioc_media FAR *gioc = (struct Gioc_media FAR *)rp->r_trans; ret = getbpb(pddt); if (ret != 0) - return (ret); + return (ret); gioc->ioc_serialno = pddt->ddt_serialno; - fmemcpy(gioc->ioc_volume, pddt->ddt_volume,11); - fmemcpy(gioc->ioc_fstype, pddt->ddt_fstype,8); - } - break; - case 0x67: /* get access flag */ - { - struct Access_info FAR * ai = (struct Access_info FAR *) rp->r_trans; - ai->AI_Flag = pddt->ddt_descflags & DF_NOACCESS ? 0 : 1; /* bit 9 */ - } - break; + fmemcpy(gioc->ioc_volume, pddt->ddt_volume, 11); + fmemcpy(gioc->ioc_fstype, pddt->ddt_fstype, 8); + } + break; + case 0x67: /* get access flag */ + { + struct Access_info FAR *ai = (struct Access_info FAR *)rp->r_trans; + ai->AI_Flag = pddt->ddt_descflags & DF_NOACCESS ? 0 : 1; /* bit 9 */ + } + break; default: - return failure(E_CMD); - } + return failure(E_CMD); + } return S_DONE; } -WORD blockio(rqptr rp, ddt *pddt) +WORD blockio(rqptr rp, ddt * pddt) { - ULONG start, size; - WORD ret; - - int action; - bpb *pbpb; - - - switch (rp->r_command){ - case C_INPUT: action = LBA_READ; break; - case C_OUTPUT:action = LBA_WRITE; break; - case C_OUTVFY:action = LBA_WRITE_VERIFY; break; - default: - return failure(E_FAILURE); - } + ULONG start, size; + WORD ret; - if (pddt->ddt_descflags & 0x200) /* drive inaccessible */ - return failure(E_FAILURE); + int action; + bpb *pbpb; - tmark(); - start = (rp->r_start != HUGECOUNT ? rp->r_start : rp->r_huge); - pbpb = hd(pddt->ddt_descflags) ? &pddt->ddt_defbpb : &pddt->ddt_bpb; - size = (pbpb->bpb_nsize ? pbpb->bpb_nsize : pbpb->bpb_huge); - - if (start >= size || - start + rp->r_count > size) - { - return 0x0408; - } - start += pddt->ddt_offset; - - ret = LBA_Transfer(pddt, action, - rp->r_trans, - start, rp->r_count,(UWORD*)&rp->r_count); - - if (ret != 0) - { - return dskerr(ret); - } - return S_DONE; + switch (rp->r_command) + { + case C_INPUT: + action = LBA_READ; + break; + case C_OUTPUT: + action = LBA_WRITE; + break; + case C_OUTVFY: + action = LBA_WRITE_VERIFY; + break; + default: + return failure(E_FAILURE); + } + + if (pddt->ddt_descflags & 0x200) /* drive inaccessible */ + return failure(E_FAILURE); + + tmark(); + start = (rp->r_start != HUGECOUNT ? rp->r_start : rp->r_huge); + pbpb = hd(pddt->ddt_descflags) ? &pddt->ddt_defbpb : &pddt->ddt_bpb; + size = (pbpb->bpb_nsize ? pbpb->bpb_nsize : pbpb->bpb_huge); + + if (start >= size || start + rp->r_count > size) + { + return 0x0408; + } + start += pddt->ddt_offset; + + ret = LBA_Transfer(pddt, action, + rp->r_trans, + start, rp->r_count, (UWORD *) & rp->r_count); + + if (ret != 0) + { + return dskerr(ret); + } + return S_DONE; } -STATIC WORD blk_error(rqptr rp, ddt *pddt) +STATIC WORD blk_error(rqptr rp, ddt * pddt) { UNREFERENCED_PARAMETER(pddt); - + rp->r_count = 0; return failure(E_FAILURE); /* general failure */ } - -STATIC WORD blk_noerr(rqptr rp, ddt *pddt) +STATIC WORD blk_noerr(rqptr rp, ddt * pddt) { - UNREFERENCED_PARAMETER(rp); - UNREFERENCED_PARAMETER(pddt); - - return S_DONE; + UNREFERENCED_PARAMETER(rp); + UNREFERENCED_PARAMETER(pddt); + + return S_DONE; } STATIC WORD dskerr(COUNT code) @@ -820,10 +825,10 @@ STATIC WORD dskerr(COUNT code) { case 1: /* invalid command - general failure */ if (code & 0x08) - return S_ERROR | E_NOTRDY; /* failure(E_NOTRDY); at least on yhe INT25 route, - 0x8002 is returned */ + return S_ERROR | E_NOTRDY; /* failure(E_NOTRDY); at least on yhe INT25 route, + 0x8002 is returned */ else - return failure(E_CMD); + return failure(E_CMD); case 2: /* address mark not found - general failure */ return failure(E_FAILURE); @@ -833,62 +838,55 @@ STATIC WORD dskerr(COUNT code) default: if (code & 0x80) /* time-out */ - return failure(E_NOTRDY); + return failure(E_NOTRDY); else if (code & 0x40) /* seek error */ - return failure(E_SEEK); + return failure(E_SEEK); else if (code & 0x10) /* CRC error */ - return failure(E_CRC); + return failure(E_CRC); else if (code & 0x04) - return failure(E_NOTFND); + return failure(E_NOTFND); else - return failure(E_FAILURE); + return failure(E_FAILURE); } } - /* translate LBA sectors into CHS addressing */ -void LBA_to_CHS(struct CHS *chs, ULONG LBA_address, ddt *pddt) +void LBA_to_CHS(struct CHS *chs, ULONG LBA_address, ddt * pddt) { - /* we need the defbpb values since those are taken from the - BIOS, not from some random boot sector, except when - we're dealing with a floppy */ - bpb *pbpb = hd(pddt->ddt_descflags) ? - &pddt->ddt_defbpb : - &pddt->ddt_bpb; - - chs->Sector = LBA_address % pbpb->bpb_nsecs + 1; - - LBA_address /= pbpb->bpb_nsecs; + /* we need the defbpb values since those are taken from the + BIOS, not from some random boot sector, except when + we're dealing with a floppy */ + bpb *pbpb = hd(pddt->ddt_descflags) ? &pddt->ddt_defbpb : &pddt->ddt_bpb; - chs->Head = LBA_address % pbpb->bpb_nheads; - chs->Cylinder = LBA_address / pbpb->bpb_nheads; -} + chs->Sector = LBA_address % pbpb->bpb_nsecs + 1; + LBA_address /= pbpb->bpb_nsecs; + chs->Head = LBA_address % pbpb->bpb_nheads; + chs->Cylinder = LBA_address / pbpb->bpb_nheads; +} /* Test for 64K boundary crossing and return count small */ /* enough not to exceed the threshold. */ -STATIC unsigned DMA_max_transfer(void FAR *buffer, unsigned count) +STATIC unsigned DMA_max_transfer(void FAR * buffer, unsigned count) { - UWORD utemp = (((UWORD) FP_SEG(buffer) << 4) + FP_OFF(buffer)); - -#define SEC_SHIFT 9 /* = 0x200 = 512 */ - - utemp >>= SEC_SHIFT; - - if (count > (0xffff >> SEC_SHIFT) - utemp) - { - count = (0xffff >> SEC_SHIFT) - utemp; - } + UWORD utemp = (((UWORD) FP_SEG(buffer) << 4) + FP_OFF(buffer)); + +#define SEC_SHIFT 9 /* = 0x200 = 512 */ - return count; -} + utemp >>= SEC_SHIFT; + if (count > (0xffff >> SEC_SHIFT) - utemp) + { + count = (0xffff >> SEC_SHIFT) - utemp; + } + return count; +} /* int LBA_Transfer( @@ -918,153 +916,157 @@ STATIC unsigned DMA_max_transfer(void FAR *buffer, unsigned count) */ -int LBA_Transfer(ddt *pddt ,UWORD mode, VOID FAR *buffer, - ULONG LBA_address,unsigned totaltodo, UWORD *transferred) +int LBA_Transfer(ddt * pddt, UWORD mode, VOID FAR * buffer, + ULONG LBA_address, unsigned totaltodo, + UWORD * transferred) { - static struct _bios_LBA_address_packet dap = { - 16,0,0,0,0,0,0 - }; - - unsigned count; - unsigned error_code; - struct CHS chs; - void FAR *transfer_address; + static struct _bios_LBA_address_packet dap = { + 16, 0, 0, 0, 0, 0, 0 + }; - int num_retries; + unsigned count; + unsigned error_code; + struct CHS chs; + void FAR *transfer_address; - /* only low-level format floppies for now ! */ - if (mode == LBA_FORMAT && hd(pddt->ddt_descflags)) - return 0; + int num_retries; - /* optionally change from A: to B: or back */ - play_dj(pddt); + /* only low-level format floppies for now ! */ + if (mode == LBA_FORMAT && hd(pddt->ddt_descflags)) + return 0; - *transferred = 0; + /* optionally change from A: to B: or back */ + play_dj(pddt); + + *transferred = 0; /* if (LBA_address+totaltodo > pddt->total_sectors) { printf("LBA-Transfer error : address overflow = %lu > %lu max\n",LBA_address+totaltodo,driveParam->total_sectors); return 1; } -*/ +*/ - for ( ;totaltodo != 0; ) - { - count = totaltodo; - - count = min(count, 0x7f); - + for (; totaltodo != 0;) + { + count = totaltodo; - /* avoid overflowing 64K DMA boundary */ - count = DMA_max_transfer(buffer,count); - + count = min(count, 0x7f); - if (FP_SEG(buffer) >= 0xa000 || count == 0) - { - transfer_address = DiskTransferBuffer; - count = 1; - - if ((mode & 0xff00) == (LBA_WRITE & 0xff00)) - { - fmemcpy(DiskTransferBuffer,buffer,512); - } - } - else { - transfer_address = buffer; - } + /* avoid overflowing 64K DMA boundary */ + count = DMA_max_transfer(buffer, count); + + if (FP_SEG(buffer) >= 0xa000 || count == 0) + { + transfer_address = DiskTransferBuffer; + count = 1; + if ((mode & 0xff00) == (LBA_WRITE & 0xff00)) + { + fmemcpy(DiskTransferBuffer, buffer, 512); + } + } + else + { + transfer_address = buffer; + } + for (num_retries = 0; num_retries < N_RETRY; num_retries++) + { + if (pddt->ddt_LBASupported && mode != LBA_FORMAT) + { + dap.number_of_blocks = count; - for ( num_retries = 0; num_retries < N_RETRY; num_retries++) - { - if (pddt->ddt_LBASupported && mode != LBA_FORMAT) - { - dap.number_of_blocks = count; - - dap.buffer_address = transfer_address; - - dap.block_address_high = 0; /* clear high part */ - dap.block_address = LBA_address; /* clear high part */ - - - /* Load the registers and call the interrupt. */ - - if (pddt->ddt_WriteVerifySupported || mode != LBA_WRITE_VERIFY) - { - - error_code = fl_lba_ReadWrite(pddt->ddt_driveno,mode, &dap); - } - else { - /* verify requested, but not supported */ - error_code = fl_lba_ReadWrite(pddt->ddt_driveno,LBA_WRITE, &dap); - - if (error_code == 0) - { - error_code = fl_lba_ReadWrite(pddt->ddt_driveno,LBA_VERIFY, &dap); - } - } - } - else - { /* transfer data, using old bios functions */ - - LBA_to_CHS(&chs, LBA_address, pddt); - - /* avoid overflow at end of track */ - - if (chs.Sector + count > pddt->ddt_bpb.bpb_nsecs + 1) - { - count = pddt->ddt_bpb.bpb_nsecs + 1 - chs.Sector; - } - - if (chs.Cylinder > 1023) - { - printf("LBA-Transfer error : cylinder %u > 1023\n", chs.Cylinder); - return 1; - } - - error_code = (mode == LBA_READ ? fl_read : - mode == LBA_VERIFY ? fl_verify : - mode == LBA_FORMAT ? fl_format : fl_write)( - pddt->ddt_driveno, - chs.Head, (UWORD)chs.Cylinder, chs.Sector, - count, transfer_address); - - if (error_code == 0 && - mode == LBA_WRITE_VERIFY) - { - error_code = fl_verify( - pddt->ddt_driveno, - chs.Head, (UWORD)chs.Cylinder, chs.Sector, - count, transfer_address); - } - } - if (error_code == 0) - break; - - fl_reset(pddt->ddt_driveno); - - } /* end of retries */ - - if (error_code) - { - return error_code; - } + dap.buffer_address = transfer_address; - /* copy to user buffer if nesessary */ - if (transfer_address == DiskTransferBuffer && - (mode & 0xff00) == (LBA_READ & 0xff00)) - { - fmemcpy(buffer,DiskTransferBuffer,512); - } + dap.block_address_high = 0; /* clear high part */ + dap.block_address = LBA_address; /* clear high part */ - *transferred += count; - LBA_address += count; - totaltodo -= count; - - buffer = add_far(buffer,count*512); + /* Load the registers and call the interrupt. */ + + if (pddt->ddt_WriteVerifySupported || mode != LBA_WRITE_VERIFY) + { + + error_code = fl_lba_ReadWrite(pddt->ddt_driveno, mode, &dap); + } + else + { + /* verify requested, but not supported */ + error_code = + fl_lba_ReadWrite(pddt->ddt_driveno, LBA_WRITE, &dap); + + if (error_code == 0) + { + error_code = + fl_lba_ReadWrite(pddt->ddt_driveno, LBA_VERIFY, &dap); + } + } + } + else + { /* transfer data, using old bios functions */ + + LBA_to_CHS(&chs, LBA_address, pddt); + + /* avoid overflow at end of track */ + + if (chs.Sector + count > pddt->ddt_bpb.bpb_nsecs + 1) + { + count = pddt->ddt_bpb.bpb_nsecs + 1 - chs.Sector; } - return(error_code); + if (chs.Cylinder > 1023) + { + printf("LBA-Transfer error : cylinder %u > 1023\n", + chs.Cylinder); + return 1; + } + + error_code = (mode == LBA_READ ? fl_read : + mode == LBA_VERIFY ? fl_verify : + mode == + LBA_FORMAT ? fl_format : fl_write) (pddt-> + ddt_driveno, + chs.Head, + (UWORD) chs. + Cylinder, + chs.Sector, + count, + transfer_address); + + if (error_code == 0 && mode == LBA_WRITE_VERIFY) + { + error_code = fl_verify(pddt->ddt_driveno, + chs.Head, (UWORD) chs.Cylinder, + chs.Sector, count, transfer_address); + } + } + if (error_code == 0) + break; + + fl_reset(pddt->ddt_driveno); + + } /* end of retries */ + + if (error_code) + { + return error_code; + } + + /* copy to user buffer if nesessary */ + if (transfer_address == DiskTransferBuffer && + (mode & 0xff00) == (LBA_READ & 0xff00)) + { + fmemcpy(buffer, DiskTransferBuffer, 512); + } + + *transferred += count; + LBA_address += count; + totaltodo -= count; + + buffer = add_far(buffer, count * 512); + } + + return (error_code); } /* diff --git a/kernel/dyndata.c b/kernel/dyndata.c index 63888960..30f46d6b 100644 --- a/kernel/dyndata.c +++ b/kernel/dyndata.c @@ -5,9 +5,9 @@ alll data herein goes to special segment DYN_DATA AFTER BSS, but immediately before HMA_TEXT -*/ +*/ #include "portab.h" #include "init-mod.h" #include "dyndata.h" -struct DynS Dyn = {0}; +struct DynS Dyn = { 0 }; diff --git a/kernel/dyndata.h b/kernel/dyndata.h index fa306168..e980a2c4 100644 --- a/kernel/dyndata.h +++ b/kernel/dyndata.h @@ -14,6 +14,6 @@ void far *DynLast(void); void DynFree(void *ptr); struct DynS { - unsigned Allocated; - char Buffer[1]; - }; + unsigned Allocated; + char Buffer[1]; +}; diff --git a/kernel/dyninit.c b/kernel/dyninit.c index a6bb222e..02355d87 100644 --- a/kernel/dyninit.c +++ b/kernel/dyninit.c @@ -4,7 +4,6 @@ this serves requests from the INIT modules to allocate dynamic data. - kernel layout: 00000H 000FFH 00100H PSP PSP 00100H 004E1H 003E2H _TEXT CODE @@ -28,7 +27,6 @@ kernel layout: 122E0H 12AA5H 007C6H ID ID 12AA6H 12CBFH 0021AH IB IB - purpose is to move the HMA_TEXT = resident kernel around, so that below it - after BSS, there is data addressable near by the kernel, to hold some arrays @@ -36,62 +34,61 @@ kernel layout: making f_nodes near saves ~2.150 code in HMA -*/ +*/ #include "portab.h" #include "init-mod.h" -#include "dyndata.h" +#include "dyndata.h" #if defined(DEBUG) - #define DebugPrintf(x) printf x +#define DebugPrintf(x) printf x #else - #define DebugPrintf(x) +#define DebugPrintf(x) #endif - /*extern struct DynS FAR Dyn;*/ #ifndef __TURBOC__ - #include "init-dat.h" - extern struct DynS DOSFAR Dyn; +#include "init-dat.h" +extern struct DynS DOSFAR Dyn; #else - extern struct DynS FAR Dyn; -#endif - - +extern struct DynS FAR Dyn; +#endif void far *DynAlloc(char *what, unsigned num, unsigned size) { - void far *now; - unsigned total = num * size; + void far *now; + unsigned total = num * size; #ifndef DEBUG - UNREFERENCED_PARAMETER(what); + UNREFERENCED_PARAMETER(what); #endif - if ((ULONG)total + Dyn.Allocated > 0xffff) - { - printf("PANIC:Dyn %lu\n", (ULONG)total + Dyn.Allocated); - for (;;); - } - - DebugPrintf(("DYNDATA:allocating %s - %u * %u bytes, total %u, %u..%u\n", - what, num, size, total, Dyn.Allocated,Dyn.Allocated+total)); - - now = (void far *)&Dyn.Buffer[Dyn.Allocated]; - fmemset(now, 0, total); - - Dyn.Allocated += total; - - return now; -} + if ((ULONG) total + Dyn.Allocated > 0xffff) + { + printf("PANIC:Dyn %lu\n", (ULONG) total + Dyn.Allocated); + for (;;) ; + } + + DebugPrintf(("DYNDATA:allocating %s - %u * %u bytes, total %u, %u..%u\n", + what, num, size, total, Dyn.Allocated, + Dyn.Allocated + total)); + + now = (void far *)&Dyn.Buffer[Dyn.Allocated]; + fmemset(now, 0, total); + + Dyn.Allocated += total; + + return now; +} void DynFree(void *ptr) { - Dyn.Allocated = (char *)ptr - (char *)Dyn.Buffer; + Dyn.Allocated = (char *)ptr - (char *)Dyn.Buffer; } void FAR *DynLast() { - DebugPrintf(("dynamic data end at %p\n",(void FAR *)(Dyn.Buffer+Dyn.Allocated))); + DebugPrintf(("dynamic data end at %p\n", + (void FAR *)(Dyn.Buffer + Dyn.Allocated))); - return Dyn.Buffer+Dyn.Allocated; -} + return Dyn.Buffer + Dyn.Allocated; +} diff --git a/kernel/error.c b/kernel/error.c index 8a6df37c..52131a6d 100644 --- a/kernel/error.c +++ b/kernel/error.c @@ -29,7 +29,8 @@ #include "portab.h" #ifdef VERSION_STRINGS -static BYTE *errorRcsId = "$Id$"; +static BYTE *errorRcsId = + "$Id$"; #endif #include "globals.h" @@ -39,19 +40,11 @@ static BYTE *errorRcsId = "$Id$"; VOID dump(void) { printf("Register Dump [AH = %02x CS:IP = %04x:%04x]\n", - error_regs.AH, - error_regs.CS, - error_regs.IP); + error_regs.AH, error_regs.CS, error_regs.IP); printf("AX:%04x BX:%04x CX:%04x DX:%04x\n", - error_regs.AX, - error_regs.BX, - error_regs.CX, - error_regs.DX); + error_regs.AX, error_regs.BX, error_regs.CX, error_regs.DX); printf("SI:%04x DI:%04x DS:%04x ES:%04x\n", - error_regs.SI, - error_regs.DI, - error_regs.DS, - error_regs.ES); + error_regs.SI, error_regs.DI, error_regs.DS, error_regs.ES); } #endif @@ -82,21 +75,15 @@ VOID fatal(BYTE * err_msg) /* Abort, retry or fail for character devices */ COUNT char_error(request * rq, struct dhdr FAR * lpDevice) { - return CriticalError( - EFLG_CHAR | EFLG_ABORT | EFLG_RETRY | EFLG_IGNORE, - 0, - rq->r_status & S_MASK, - lpDevice); + return CriticalError(EFLG_CHAR | EFLG_ABORT | EFLG_RETRY | EFLG_IGNORE, + 0, rq->r_status & S_MASK, lpDevice); } /* Abort, retry or fail for block devices */ COUNT block_error(request * rq, COUNT nDrive, struct dhdr FAR * lpDevice) { - return CriticalError( - EFLG_ABORT | EFLG_RETRY | EFLG_IGNORE, - nDrive, - rq->r_status & S_MASK, - lpDevice); + return CriticalError(EFLG_ABORT | EFLG_RETRY | EFLG_IGNORE, + nDrive, rq->r_status & S_MASK, lpDevice); } /* @@ -139,4 +126,3 @@ COUNT block_error(request * rq, COUNT nDrive, struct dhdr FAR * lpDevice) * Rev 1.0 02 Jul 1995 8:06:14 patv * Initial revision. */ - diff --git a/kernel/fatdir.c b/kernel/fatdir.c index 5445558c..89fbf375 100644 --- a/kernel/fatdir.c +++ b/kernel/fatdir.c @@ -31,7 +31,8 @@ #include "globals.h" #ifdef VERSION_STRINGS -static BYTE *fatdirRcsId = "$Id$"; +static BYTE *fatdirRcsId = + "$Id$"; #endif /* Description. @@ -45,24 +46,25 @@ VOID dir_init_fnode(f_node_ptr fnp, CLUSTER dirstart) fnp->f_flags.f_droot = FALSE; fnp->f_flags.f_ddir = TRUE; fnp->f_flags.f_dnew = TRUE; - fnp->f_diroff = fnp->f_offset = fnp->f_cluster_offset = fnp->f_highwater = 0l; + fnp->f_diroff = fnp->f_offset = fnp->f_cluster_offset = + fnp->f_highwater = 0l; /* root directory */ if (dirstart == 0) - { + { #ifdef WITHFAT32 - if (ISFAT32(fnp->f_dpb)) - { - fnp->f_cluster = fnp->f_dirstart = fnp->f_dpb->dpb_xrootclst; - } - else + if (ISFAT32(fnp->f_dpb)) + { + fnp->f_cluster = fnp->f_dirstart = fnp->f_dpb->dpb_xrootclst; + } + else #endif - { - fnp->f_dirstart = 0l; - fnp->f_flags.f_droot = TRUE; - } + { + fnp->f_dirstart = 0l; + fnp->f_flags.f_droot = TRUE; } - else /* non-root */ + } + else /* non-root */ fnp->f_cluster = fnp->f_dirstart = dirstart; } @@ -76,17 +78,18 @@ f_node_ptr dir_open(BYTE * dirname) BYTE *pszPath = dirname + 2; /* Allocate an fnode if possible - error return (0) if not. */ - if ((fnp = get_f_node()) == (f_node_ptr)0) + if ((fnp = get_f_node()) == (f_node_ptr) 0) { - return (f_node_ptr)0; + return (f_node_ptr) 0; } /* Force the fnode into read-write mode */ fnp->f_mode = RDWR; /* determine what drive we are using... */ - if (ParseDosName(dirname, &drive, (BYTE *) 0, (BYTE *) 0, (BYTE *) 0, FALSE) - != SUCCESS) + if (ParseDosName + (dirname, &drive, (BYTE *) 0, (BYTE *) 0, (BYTE *) 0, + FALSE) != SUCCESS) { release_f_node(fnp); return NULL; @@ -104,7 +107,8 @@ f_node_ptr dir_open(BYTE * dirname) { drive = default_drive; } - if (drive >= lastdrive) { + if (drive >= lastdrive) + { release_f_node(fnp); return NULL; } @@ -113,7 +117,7 @@ f_node_ptr dir_open(BYTE * dirname) /* Generate full path name */ /* not necessary anymore, since truename did that already - i = cdsp->cdsJoinOffset; + i = cdsp->cdsJoinOffset; ParseDosPath(dirname, (COUNT *) 0, pszPath, (BYTE FAR *) & cdsp->cdsCurrentPath[i]); */ /* for testing only for now */ @@ -139,7 +143,7 @@ f_node_ptr dir_open(BYTE * dirname) if (media_check(fnp->f_dpb) < 0) { release_f_node(fnp); - return (f_node_ptr)0; + return (f_node_ptr) 0; } /* Walk the directory tree to find the starting cluster */ @@ -161,8 +165,8 @@ f_node_ptr dir_open(BYTE * dirname) /* comparison... */ /* first the file name with trailing spaces... */ - memset(TempBuffer, ' ', FNAME_SIZE+FEXT_SIZE); - + memset(TempBuffer, ' ', FNAME_SIZE + FEXT_SIZE); + for (i = 0; i < FNAME_SIZE; i++) { if (*p != '\0' && *p != '.' && *p != '/' && *p != '\\') @@ -191,9 +195,12 @@ f_node_ptr dir_open(BYTE * dirname) while (dir_read(fnp) == 1) { - if (fnp->f_dir.dir_name[0] != '\0' && fnp->f_dir.dir_name[0] != DELETED) + if (fnp->f_dir.dir_name[0] != '\0' + && fnp->f_dir.dir_name[0] != DELETED) { - if (fcmp(TempBuffer, (BYTE *)fnp->f_dir.dir_name, FNAME_SIZE + FEXT_SIZE)) + if (fcmp + (TempBuffer, (BYTE *) fnp->f_dir.dir_name, + FNAME_SIZE + FEXT_SIZE)) { i = TRUE; break; @@ -205,7 +212,7 @@ f_node_ptr dir_open(BYTE * dirname) { release_f_node(fnp); - return (f_node_ptr)0; + return (f_node_ptr) 0; } else { @@ -250,7 +257,7 @@ COUNT dir_read(REG f_node_ptr fnp) if (fnp->f_flags.f_droot) { - if (new_diroff >= DIRENT_SIZE * (ULONG)fnp->f_dpb->dpb_dirents) + if (new_diroff >= DIRENT_SIZE * (ULONG) fnp->f_dpb->dpb_dirents) return DE_SEEK; bp = getblock((ULONG) (new_diroff / secsize @@ -294,14 +301,15 @@ COUNT dir_read(REG f_node_ptr fnp) bp->b_flag &= ~(BFR_DATA | BFR_FAT); bp->b_flag |= BFR_DIR | BFR_VALID; - getdirent((BYTE FAR *) & bp->b_buffer[((UWORD)new_diroff) % fnp->f_dpb->dpb_secsize], - (struct dirent FAR *)&fnp->f_dir); + getdirent((BYTE FAR *) & bp-> + b_buffer[((UWORD) new_diroff) % fnp->f_dpb->dpb_secsize], + (struct dirent FAR *)&fnp->f_dir); /* Update the fnode's directory info */ fnp->f_flags.f_dmod = FALSE; fnp->f_flags.f_dnew = FALSE; fnp->f_diroff = new_diroff; - + /* and for efficiency, stop when we hit the first */ /* unused entry. */ /* either returns 1 or 0 */ @@ -328,10 +336,9 @@ BOOL dir_write(REG f_node_ptr fnp) /* simple. */ if (fnp->f_flags.f_droot) { - bp = getblock( - (ULONG) ((UWORD)fnp->f_diroff / secsize - + fnp->f_dpb->dpb_dirstrt), - fnp->f_dpb->dpb_unit); + bp = getblock((ULONG) ((UWORD) fnp->f_diroff / secsize + + fnp->f_dpb->dpb_dirstrt), + fnp->f_dpb->dpb_unit); #ifdef DISPLAY_GETBLOCK printf("DIR (dir_write)\n"); #endif @@ -348,7 +355,7 @@ BOOL dir_write(REG f_node_ptr fnp) fnp->f_offset = fnp->f_diroff; fnp->f_back = LONG_LAST_CLUSTER; fnp->f_cluster = fnp->f_dirstart; - fnp->f_cluster_offset = 0l; /*JPP */ + fnp->f_cluster_offset = 0l; /*JPP */ /* Search through the FAT to find the block */ /* that this entry is in. */ @@ -383,11 +390,12 @@ BOOL dir_write(REG f_node_ptr fnp) release_f_node(fnp); return FALSE; } - + if (fnp->f_flags.f_dnew && fnp->f_dir.dir_attrib != D_LFN) - fmemset(&fnp->f_dir.dir_case, 0, 8); + fmemset(&fnp->f_dir.dir_case, 0, 8); putdirent((struct dirent FAR *)&fnp->f_dir, - (VOID FAR *) & bp->b_buffer[(UWORD)fnp->f_diroff % fnp->f_dpb->dpb_secsize]); + (VOID FAR *) & bp->b_buffer[(UWORD) fnp->f_diroff % + fnp->f_dpb->dpb_secsize]); bp->b_flag &= ~(BFR_DATA | BFR_FAT); bp->b_flag |= BFR_DIR | BFR_DIRTY | BFR_VALID; @@ -417,7 +425,7 @@ VOID dir_close(REG f_node_ptr fnp) } #ifndef IPL -COUNT dos_findfirst(UCOUNT attr, BYTE *name) +COUNT dos_findfirst(UCOUNT attr, BYTE * name) { REG f_node_ptr fnp; REG dmatch *dmp = (dmatch *) TempBuffer; @@ -425,8 +433,7 @@ COUNT dos_findfirst(UCOUNT attr, BYTE *name) COUNT nDrive; BYTE *p; - BYTE local_name[FNAME_SIZE + 1], - local_ext[FEXT_SIZE + 1]; + BYTE local_name[FNAME_SIZE + 1], local_ext[FEXT_SIZE + 1]; /* printf("ff %Fs\n", name);*/ @@ -438,7 +445,8 @@ COUNT dos_findfirst(UCOUNT attr, BYTE *name) /* current directory, do a seek and read, then close the fnode. */ /* Parse out the drive, file name and file extension. */ - i = ParseDosName(name, &nDrive, &szDirName[2], local_name, local_ext, TRUE); + i = ParseDosName(name, &nDrive, &szDirName[2], local_name, local_ext, + TRUE); if (i != SUCCESS) return i; /* @@ -453,14 +461,14 @@ COUNT dos_findfirst(UCOUNT attr, BYTE *name) SearchDir.dir_name[i] = *p; for (; i < FNAME_SIZE; ++i) - SearchDir.dir_name[i] = ' '; + SearchDir.dir_name[i] = ' '; /* and the extension (don't forget to add trailing spaces)... */ for (p = local_ext, i = 0; i < FEXT_SIZE && *p; ++p, ++i) SearchDir.dir_ext[i] = *p; for (; i < FEXT_SIZE; ++i) - SearchDir.dir_ext[i] = ' '; + SearchDir.dir_ext[i] = ' '; /* Convert everything to uppercase. */ DosUpFMem(SearchDir.dir_name, FNAME_SIZE + FEXT_SIZE); @@ -471,7 +479,7 @@ COUNT dos_findfirst(UCOUNT attr, BYTE *name) /* name */ szDirName[0] = 'A' + nDrive; szDirName[1] = ':'; - + /* Special handling - the volume id is only in the root */ /* directory and only searched for once. So we need to open */ /* the root and return only the first entry that contains the */ @@ -483,16 +491,16 @@ COUNT dos_findfirst(UCOUNT attr, BYTE *name) } /* Now open this directory so that we can read the */ /* fnode entry and do a match on it. */ - + /* printf("dir_open %s\n", szDirName);*/ if ((fnp = dir_open(szDirName)) == NULL) return DE_PATHNOTFND; /* Now initialize the dirmatch structure. */ - - nDrive=get_verify_drive(name); + + nDrive = get_verify_drive(name); if (nDrive < 0) - return nDrive; + return nDrive; dmp->dm_drive = nDrive; dmp->dm_attr_srch = attr; @@ -507,7 +515,7 @@ COUNT dos_findfirst(UCOUNT attr, BYTE *name) /* Test the attribute and return first found */ if ((fnp->f_dir.dir_attrib & ~(D_RDONLY | D_ARCHIVE)) == D_VOLID) { - dmp->dm_dircluster = fnp->f_dirstart; /* TE */ + dmp->dm_dircluster = fnp->f_dirstart; /* TE */ memcpy(&SearchDir, &fnp->f_dir, sizeof(struct dirent)); dir_close(fnp); return SUCCESS; @@ -531,6 +539,7 @@ COUNT dos_findfirst(UCOUNT attr, BYTE *name) return dos_findnext(); } } + /* BUGFIX TE 06/28/01 @@ -547,11 +556,11 @@ COUNT dos_findnext(void) BOOL found = FALSE; /* Allocate an fnode if possible - error return (0) if not. */ - if ((fnp = get_f_node()) == (f_node_ptr)0) + if ((fnp = get_f_node()) == (f_node_ptr) 0) { return DE_NFILES; } - + memset(fnp, 0, sizeof(*fnp)); /* Force the fnode into read-write mode */ @@ -571,35 +580,38 @@ COUNT dos_findnext(void) /* Search through the directory to find the entry, but do a */ /* seek first. */ if (dmp->dm_entry > 0) - { - fnp->f_diroff = (ULONG)(dmp->dm_entry - 1) * DIRENT_SIZE; + { + fnp->f_diroff = (ULONG) (dmp->dm_entry - 1) * DIRENT_SIZE; fnp->f_flags.f_dnew = FALSE; - } + } else - { + { fnp->f_diroff = 0; fnp->f_flags.f_dnew = TRUE; - } + } /* Loop through the directory */ while (dir_read(fnp) == 1) { ++dmp->dm_entry; if (fnp->f_dir.dir_name[0] != '\0' && fnp->f_dir.dir_name[0] != DELETED - && (fnp->f_dir.dir_attrib & D_VOLID) != D_VOLID ) + && (fnp->f_dir.dir_attrib & D_VOLID) != D_VOLID) { - if (fcmp_wild((BYTE FAR *)dmp->dm_name_pat, (BYTE FAR *)fnp->f_dir.dir_name, FNAME_SIZE + FEXT_SIZE)) + if (fcmp_wild + ((BYTE FAR *) dmp->dm_name_pat, (BYTE FAR *) fnp->f_dir.dir_name, + FNAME_SIZE + FEXT_SIZE)) { /* - MSD Command.com uses FCB FN 11 & 12 with attrib set to 0x16. - Bits 0x21 seem to get set some where in MSD so Rd and Arc - files are returned. - RdOnly + Archive bits are ignored + MSD Command.com uses FCB FN 11 & 12 with attrib set to 0x16. + Bits 0x21 seem to get set some where in MSD so Rd and Arc + files are returned. + RdOnly + Archive bits are ignored */ - + /* Test the attribute as the final step */ if (!(fnp->f_dir.dir_attrib & D_VOLID) && - ((~dmp->dm_attr_srch & fnp->f_dir.dir_attrib & (D_DIR | D_SYSTEM | D_HIDDEN)) == 0)) + ((~dmp->dm_attr_srch & fnp->f_dir. + dir_attrib & (D_DIR | D_SYSTEM | D_HIDDEN)) == 0)) { found = TRUE; break; @@ -612,10 +624,10 @@ COUNT dos_findnext(void) /* If found, transfer it to the dmatch structure */ if (found) - { + { dmp->dm_dircluster = fnp->f_dirstart; memcpy(&SearchDir, &fnp->f_dir, sizeof(struct dirent)); - } + } /* return the result */ release_f_node(fnp); @@ -631,61 +643,57 @@ COUNT dos_findnext(void) "test e", " test .y z",... so we have to work from the last blank backward -*/ -void ConvertName83ToNameSZ(BYTE FAR *destSZ, BYTE FAR *srcFCBName) +*/ +void ConvertName83ToNameSZ(BYTE FAR * destSZ, BYTE FAR * srcFCBName) { - int loop; - int noExtension = FALSE; - - if (*srcFCBName == '.') - { - noExtension = TRUE; - } - - + int loop; + int noExtension = FALSE; - fmemcpy(destSZ,srcFCBName,FNAME_SIZE); + if (*srcFCBName == '.') + { + noExtension = TRUE; + } - srcFCBName += FNAME_SIZE; - - for (loop = FNAME_SIZE; --loop >= 0; ) - { - if (destSZ[loop] != ' ') - break; - } - destSZ += loop + 1; - - - - if (!noExtension) /* not for ".", ".." */ + fmemcpy(destSZ, srcFCBName, FNAME_SIZE); + + srcFCBName += FNAME_SIZE; + + for (loop = FNAME_SIZE; --loop >= 0;) + { + if (destSZ[loop] != ' ') + break; + } + destSZ += loop + 1; + + if (!noExtension) /* not for ".", ".." */ + { + + for (loop = FEXT_SIZE; --loop >= 0;) { - - for (loop = FEXT_SIZE; --loop >= 0; ) - { - if (srcFCBName[loop] != ' ') - break; - } - if (loop >= 0) - { - *destSZ++ = '.'; - fmemcpy(destSZ,srcFCBName,loop+1); - destSZ += loop+1; - } + if (srcFCBName[loop] != ' ') + break; + } + if (loop >= 0) + { + *destSZ++ = '.'; + fmemcpy(destSZ, srcFCBName, loop + 1); + destSZ += loop + 1; } - *destSZ = '\0'; + } + *destSZ = '\0'; } /* returns the asciiSZ length of a 8.3 filename -*/ +*/ -int FileName83Length(BYTE *filename83) +int FileName83Length(BYTE * filename83) { - BYTE buff[13]; + BYTE buff[13]; - ConvertName83ToNameSZ(buff, filename83); - - return strlen(buff); + ConvertName83ToNameSZ(buff, filename83); + + return strlen(buff); } /* @@ -777,4 +785,3 @@ int FileName83Length(BYTE *filename83) * Rev 1.0 02 Jul 1995 8:04:34 patv * Initial revision. */ - diff --git a/kernel/fatfs.c b/kernel/fatfs.c index e4068ae9..5114fa0e 100644 --- a/kernel/fatfs.c +++ b/kernel/fatfs.c @@ -59,18 +59,16 @@ BOOL first_fat(f_node_ptr); COUNT map_cluster(f_node_ptr, COUNT); STATIC VOID shrink_file(f_node_ptr fnp); -ULONG clus2phys(CLUSTER cl_no, struct dpb FAR *dpbp) +ULONG clus2phys(CLUSTER cl_no, struct dpb FAR * dpbp) { - CLUSTER data = + CLUSTER data = #ifdef WITHFAT32 - ISFAT32(dpbp) ? - dpbp->dpb_xdata : + ISFAT32(dpbp) ? dpbp->dpb_xdata : #endif dpbp->dpb_data; - return ((ULONG)(cl_no - 2) << dpbp->dpb_shftcnt) + data; + return ((ULONG) (cl_no - 2) << dpbp->dpb_shftcnt) + data; } - /************************************************************************/ /* */ /* Internal file handlers - open, create, read, write, close, etc. */ @@ -118,9 +116,9 @@ COUNT dos_open(BYTE * path, COUNT flag) fnp->f_flags.f_dnew = FALSE; fnp->f_flags.f_ddir = FALSE; - merge_file_changes(fnp, TRUE); /* /// Added - Ron Cemer */ + merge_file_changes(fnp, TRUE); /* /// Added - Ron Cemer */ - /* /// Moved from above. - Ron Cemer */ + /* /// Moved from above. - Ron Cemer */ fnp->f_cluster = getdstart(fnp->f_dir); fnp->f_cluster_offset = 0l; /*JPP */ @@ -160,7 +158,7 @@ COUNT dos_close(COUNT fd) /* If the fd was invalid because it was out of range or the */ /* requested file was not open, tell the caller and exit */ /* note: an invalid fd is indicated by a 0 return */ - if (fnp == (f_node_ptr)0 || fnp->f_count <= 0) + if (fnp == (f_node_ptr) 0 || fnp->f_count <= 0) return DE_INVLDHNDL; if (fnp->f_flags.f_dmod) @@ -170,10 +168,10 @@ COUNT dos_close(COUNT fd) { fnp->f_dir.dir_time = dos_gettime(); fnp->f_dir.dir_date = dos_getdate(); - } + } fnp->f_dir.dir_size = fnp->f_highwater; - merge_file_changes(fnp, FALSE); /* /// Added - Ron Cemer */ + merge_file_changes(fnp, FALSE); /* /// Added - Ron Cemer */ } fnp->f_flags.f_ddir = TRUE; @@ -184,8 +182,7 @@ COUNT dos_close(COUNT fd) /* */ /* split a path into it's component directory and file name */ /* */ -f_node_ptr - split_path(BYTE * path, BYTE * fname, BYTE * fext) +f_node_ptr split_path(BYTE * path, BYTE * fname, BYTE * fext) { REG f_node_ptr fnp; COUNT nDrive; @@ -194,7 +191,7 @@ f_node_ptr /* Start off by parsing out the components. */ if (ParseDosName(path, &nDrive, &szDirName[2], fname, fext, FALSE) != SUCCESS) - return (f_node_ptr)0; + return (f_node_ptr) 0; if (nDrive < 0) nDrive = default_drive; @@ -205,8 +202,9 @@ f_node_ptr SpacePad(fname, FNAME_SIZE); SpacePad(fext, FEXT_SIZE); - if (nDrive >= lastdrive) { - return (f_node_ptr)0; + if (nDrive >= lastdrive) + { + return (f_node_ptr) 0; } cdsp = &CDSp->cds_table[nDrive]; @@ -229,10 +227,11 @@ f_node_ptr */ #ifdef DEBUG - if (cdsp->cdsFlags & CDSNETWDRV) { + if (cdsp->cdsFlags & CDSNETWDRV) + { printf("split path called for redirected file: `%s.%s'\n", - fname, fext); - return (f_node_ptr)0; + fname, fext); + return (f_node_ptr) 0; } #endif @@ -242,10 +241,10 @@ f_node_ptr /* If the fd was invalid because it was out of range or the */ /* requested file was not open, tell the caller and exit... */ /* note: an invalid fd is indicated by a 0 return */ - if (fnp == (f_node_ptr)0 || fnp->f_count <= 0) + if (fnp == (f_node_ptr) 0 || fnp->f_count <= 0) { dir_close(fnp); - return (f_node_ptr)0; + return (f_node_ptr) 0; } /* Convert the name into an absolute name for comparison... */ @@ -267,8 +266,8 @@ STATIC BOOL find_fname(f_node_ptr fnp, BYTE * fname, BYTE * fext) if (fnp->f_dir.dir_name[0] == DELETED) continue; - if (fcmp(fname, (BYTE *)fnp->f_dir.dir_name, FNAME_SIZE) - && fcmp(fext, (BYTE *)fnp->f_dir.dir_ext, FEXT_SIZE) + if (fcmp(fname, (BYTE *) fnp->f_dir.dir_name, FNAME_SIZE) + && fcmp(fext, (BYTE *) fnp->f_dir.dir_ext, FEXT_SIZE) && ((fnp->f_dir.dir_attrib & D_VOLID) == 0)) { found = TRUE; @@ -292,10 +291,12 @@ COUNT remove_lfn_entries(f_node_ptr fnp) { ULONG original_diroff = fnp->f_diroff; COUNT rc; - - while (TRUE) { - if(fnp->f_diroff == 0) break; - fnp->f_diroff -= 2*DIRENT_SIZE; + + while (TRUE) + { + if (fnp->f_diroff == 0) + break; + fnp->f_diroff -= 2 * DIRENT_SIZE; /* it cannot / should not get below 0 because of '.' and '..' */ if ((rc = dir_read(fnp)) < 0) return rc; @@ -310,6 +311,7 @@ COUNT remove_lfn_entries(f_node_ptr fnp) return rc; return SUCCESS; } + /* /// Added - Ron Cemer */ /* If more than one f_node has a file open, and a write occurs, this function must be called to propagate the @@ -319,65 +321,74 @@ COUNT remove_lfn_entries(f_node_ptr fnp) reasons, since DOS without SHARE does not share changes between two or more open instances of the same file unless these instances were generated by dup() or dup2(). */ -STATIC void merge_file_changes(f_node_ptr fnp, int collect) { - f_node_ptr fnp2; - int i; - - if (!IsShareInstalled()) return; - for (i = 0; i < f_nodes_cnt; i++) { - fnp2 = (f_node_ptr)&f_nodes[i]; - if ( (fnp != (f_node_ptr)0) - && (fnp != fnp2) - && (fnp->f_count > 0) - && (is_same_file(fnp, fnp2)) ) { - if (collect) { - /* We're collecting file changes from any other - f_node which refers to this file. */ - if (fnp2->f_mode != RDONLY) { - fnp2->f_dir.dir_size = fnp2->f_highwater; - copy_file_changes(fnp2, fnp); - break; - } - } else { - /* We just made changes to this file, so we are - distributing these changes to the other f_nodes - which refer to this file. */ - if (fnp->f_mode != RDONLY) - fnp->f_dir.dir_size = fnp->f_highwater; - copy_file_changes(fnp, fnp2); - } +STATIC void merge_file_changes(f_node_ptr fnp, int collect) +{ + f_node_ptr fnp2; + int i; + + if (!IsShareInstalled()) + return; + for (i = 0; i < f_nodes_cnt; i++) + { + fnp2 = (f_node_ptr) & f_nodes[i]; + if ((fnp != (f_node_ptr) 0) + && (fnp != fnp2) + && (fnp->f_count > 0) && (is_same_file(fnp, fnp2))) + { + if (collect) + { + /* We're collecting file changes from any other + f_node which refers to this file. */ + if (fnp2->f_mode != RDONLY) + { + fnp2->f_dir.dir_size = fnp2->f_highwater; + copy_file_changes(fnp2, fnp); + break; } + } + else + { + /* We just made changes to this file, so we are + distributing these changes to the other f_nodes + which refer to this file. */ + if (fnp->f_mode != RDONLY) + fnp->f_dir.dir_size = fnp->f_highwater; + copy_file_changes(fnp, fnp2); + } } + } } /* /// Added - Ron Cemer */ -STATIC int is_same_file(f_node_ptr fnp1, f_node_ptr fnp2) { - return - (fnp1->f_dpb->dpb_unit == fnp2->f_dpb->dpb_unit) - && (fnp1->f_dpb->dpb_subunit == fnp2->f_dpb->dpb_subunit) - && (fcmp - ((BYTE *)fnp1->f_dir.dir_name, - (BYTE *)fnp2->f_dir.dir_name, FNAME_SIZE)) - && (fcmp - ((BYTE *)fnp1->f_dir.dir_ext, - (BYTE *)fnp2->f_dir.dir_ext, FEXT_SIZE)) - && ((fnp1->f_dir.dir_attrib & D_VOLID) == 0) - && ((fnp2->f_dir.dir_attrib & D_VOLID) == 0) - && (fnp1->f_diroff == fnp2->f_diroff) - && (fnp1->f_dirstart == fnp2->f_dirstart) - && (fnp1->f_dpb == fnp2->f_dpb); +STATIC int is_same_file(f_node_ptr fnp1, f_node_ptr fnp2) +{ + return + (fnp1->f_dpb->dpb_unit == fnp2->f_dpb->dpb_unit) + && (fnp1->f_dpb->dpb_subunit == fnp2->f_dpb->dpb_subunit) + && (fcmp + ((BYTE *) fnp1->f_dir.dir_name, + (BYTE *) fnp2->f_dir.dir_name, FNAME_SIZE)) + && (fcmp + ((BYTE *) fnp1->f_dir.dir_ext, + (BYTE *) fnp2->f_dir.dir_ext, FEXT_SIZE)) + && ((fnp1->f_dir.dir_attrib & D_VOLID) == 0) + && ((fnp2->f_dir.dir_attrib & D_VOLID) == 0) + && (fnp1->f_diroff == fnp2->f_diroff) + && (fnp1->f_dirstart == fnp2->f_dirstart) + && (fnp1->f_dpb == fnp2->f_dpb); } /* /// Added - Ron Cemer */ -STATIC void copy_file_changes(f_node_ptr src, f_node_ptr dst) { - dst->f_highwater = src->f_highwater; - dst->f_dir.dir_start = src->f_dir.dir_start; +STATIC void copy_file_changes(f_node_ptr src, f_node_ptr dst) +{ + dst->f_highwater = src->f_highwater; + dst->f_dir.dir_start = src->f_dir.dir_start; #ifdef WITHFAT32 - dst->f_dir.dir_start_high = src->f_dir.dir_start_high; + dst->f_dir.dir_start_high = src->f_dir.dir_start_high; #endif - dst->f_dir.dir_size = src->f_dir.dir_size; - dst->f_dir.dir_date = src->f_dir.dir_date; - dst->f_dir.dir_time = src->f_dir.dir_time; + dst->f_dir.dir_size = src->f_dir.dir_size; + dst->f_dir.dir_date = src->f_dir.dir_date; + dst->f_dir.dir_time = src->f_dir.dir_time; } COUNT dos_creat(BYTE * path, COUNT attrib) @@ -477,7 +488,7 @@ COUNT dos_creat(BYTE * path, COUNT attrib) fnp->f_flags.f_dnew = FALSE; fnp->f_flags.f_ddir = FALSE; - merge_file_changes(fnp, FALSE); /* /// Added - Ron Cemer */ + merge_file_changes(fnp, FALSE); /* /// Added - Ron Cemer */ return xlt_fnp(fnp); } @@ -485,11 +496,11 @@ COUNT dos_creat(BYTE * path, COUNT attrib) STATIC COUNT delete_dir_entry(f_node_ptr fnp) { COUNT rc; - + /* Ok, so we can delete. Start out by */ /* clobbering all FAT entries for this file */ /* (or, in English, truncate the FAT). */ - if ((rc=remove_lfn_entries(fnp)) < 0) + if ((rc = remove_lfn_entries(fnp)) < 0) return rc; wipe_out(fnp); @@ -568,11 +579,11 @@ COUNT dos_rmdir(BYTE * path) /* check for any other bit set. If it is, give */ /* an access error. */ /* if (fnp->f_dir.dir_attrib & ~D_DIR) */ - + /* directories may have attributes, too. at least my WinNT disk has many 'archive' directories - we still don't allow RDONLY directories to be deleted TE*/ - + we still don't allow RDONLY directories to be deleted TE */ + /* if (fnp->f_dir.dir_attrib & ~(D_DIR |D_HIDDEN|D_ARCHIVE|D_SYSTEM)) { dir_close(fnp); @@ -604,7 +615,8 @@ COUNT dos_rmdir(BYTE * path) { if (fnp1->f_dir.dir_name[0] == '\0') break; - if (fnp1->f_dir.dir_name[0] == DELETED || fnp1->f_dir.dir_attrib == D_LFN) + if (fnp1->f_dir.dir_name[0] == DELETED + || fnp1->f_dir.dir_attrib == D_LFN) continue; else { @@ -693,7 +705,7 @@ COUNT dos_rename(BYTE * path1, BYTE * path2) } } - if ((ret=remove_lfn_entries(fnp1)) < 0) + if ((ret = remove_lfn_entries(fnp1)) < 0) return ret; /* put the fnode's name into the directory. */ @@ -731,10 +743,10 @@ COUNT dos_rename(BYTE * path1, BYTE * path2) /* */ /* wipe out all FAT entries starting from st for create, delete, etc. */ /* */ -STATIC VOID wipe_out_clusters(struct dpb FAR *dpbp, CLUSTER st) +STATIC VOID wipe_out_clusters(struct dpb FAR * dpbp, CLUSTER st) { REG CLUSTER next; - + /* Loop from start until either a FREE entry is */ /* encountered (due to a fractured file system) of the */ /* last cluster is encountered. */ @@ -754,20 +766,20 @@ STATIC VOID wipe_out_clusters(struct dpb FAR *dpbp, CLUSTER st) #ifdef WITHFAT32 if (ISFAT32(dpbp)) { - if ((dpbp->dpb_xcluster == UNKNCLUSTER) - || (dpbp->dpb_xcluster > st)) + if ((dpbp->dpb_xcluster == UNKNCLUSTER) || (dpbp->dpb_xcluster > st)) dpbp->dpb_xcluster = st; - } else + } + else #endif - if ((dpbp->dpb_cluster == UNKNCLUSTER) - || (dpbp->dpb_cluster > st)) + if ((dpbp->dpb_cluster == UNKNCLUSTER) || (dpbp->dpb_cluster > st)) dpbp->dpb_cluster = st; /* and just follow the linked list */ st = next; } #ifdef WITHFAT32 - if (ISFAT32(dpbp)) write_fsinfo(dpbp); + if (ISFAT32(dpbp)) + write_fsinfo(dpbp); #endif } @@ -786,7 +798,7 @@ STATIC VOID wipe_out(f_node_ptr fnp) STATIC BOOL find_free(f_node_ptr fnp) { COUNT rc; - + while ((rc = dir_read(fnp)) == 1) if (fnp->f_dir.dir_name[0] == DELETED) return TRUE; @@ -799,9 +811,7 @@ STATIC BOOL find_free(f_node_ptr fnp) date dos_getdate() { #ifndef NOTIME - BYTE WeekDay, - Month, - MonthDay; + BYTE WeekDay, Month, MonthDay; COUNT Year; date Date; @@ -809,8 +819,7 @@ date dos_getdate() /* on start-up or the CMOS clock */ DosGetDate((BYTE FAR *) & WeekDay, (BYTE FAR *) & Month, - (BYTE FAR *) & MonthDay, - (COUNT FAR *) & Year); + (BYTE FAR *) & MonthDay, (COUNT FAR *) & Year); Date = DT_ENCODE(Month, MonthDay, Year - EPOCH_YEAR); return Date; @@ -827,18 +836,14 @@ date dos_getdate() time dos_gettime() { #ifndef NOTIME - BYTE Hour, - Minute, - Second, - Hundredth; + BYTE Hour, Minute, Second, Hundredth; /* First - get the system time set by either the user */ /* on start-up or the CMOS clock */ DosGetTime((BYTE FAR *) & Hour, (BYTE FAR *) & Minute, - (BYTE FAR *) & Second, - (BYTE FAR *) & Hundredth); - return TM_ENCODE(Hour, Minute, Second/2); + (BYTE FAR *) & Second, (BYTE FAR *) & Hundredth); + return TM_ENCODE(Hour, Minute, Second / 2); #else return 0; #endif @@ -858,7 +863,7 @@ COUNT dos_getftime(COUNT fd, date FAR * dp, time FAR * tp) /* If the fd was invalid because it was out of range or the */ /* requested file was not open, tell the caller and exit */ /* note: an invalid fd is indicated by a 0 return */ - if (fnp == (f_node_ptr)0 || fnp->f_count <= 0) + if (fnp == (f_node_ptr) 0 || fnp->f_count <= 0) return DE_INVLDHNDL; /* Get the date and time from the fnode and return */ @@ -882,14 +887,14 @@ COUNT dos_setftime(COUNT fd, date dp, time tp) /* If the fd was invalid because it was out of range or the */ /* requested file was not open, tell the caller and exit */ /* note: an invalid fd is indicated by a 0 return */ - if (fnp == (f_node_ptr)0 || fnp->f_count <= 0) + if (fnp == (f_node_ptr) 0 || fnp->f_count <= 0) return DE_INVLDHNDL; /* Set the date and time from the fnode and return */ fnp->f_dir.dir_date = dp; fnp->f_dir.dir_time = tp; - fnp->f_flags.f_dmod = TRUE; /* mark file as modified */ - fnp->f_flags.f_ddate = TRUE; /* set this date upon closing */ + fnp->f_flags.f_dmod = TRUE; /* mark file as modified */ + fnp->f_flags.f_ddate = TRUE; /* set this date upon closing */ return SUCCESS; } @@ -908,7 +913,7 @@ LONG dos_getcufsize(COUNT fd) /* If the fd was invalid because it was out of range or the */ /* requested file was not open, tell the caller and exit */ /* note: an invalid fd is indicated by a 0 return */ - if (fnp == (f_node_ptr)0 || fnp->f_count <= 0) + if (fnp == (f_node_ptr) 0 || fnp->f_count <= 0) return -1l; /* Return the file size */ @@ -929,7 +934,7 @@ LONG dos_getfsize(COUNT fd) /* If the fd was invalid because it was out of range or the */ /* requested file was not open, tell the caller and exit */ /* note: an invalid fd is indicated by a 0 return */ - if (fnp == (f_node_ptr)0 || fnp->f_count <= 0) + if (fnp == (f_node_ptr) 0 || fnp->f_count <= 0) return -1l; /* Return the file size */ @@ -950,14 +955,14 @@ BOOL dos_setfsize(COUNT fd, LONG size) /* If the fd was invalid because it was out of range or the */ /* requested file was not open, tell the caller and exit */ /* note: an invalid fd is indicated by a 0 return */ - if (fnp == (f_node_ptr)0 || fnp->f_count <= 0) + if (fnp == (f_node_ptr) 0 || fnp->f_count <= 0) return FALSE; /* Change the file size */ fnp->f_dir.dir_size = size; fnp->f_highwater = size; - merge_file_changes(fnp, FALSE); /* /// Added - Ron Cemer */ + merge_file_changes(fnp, FALSE); /* /// Added - Ron Cemer */ return TRUE; } @@ -983,8 +988,9 @@ STATIC CLUSTER find_fat_free(f_node_ptr fnp) { if (dpbp->dpb_xcluster != UNKNCLUSTER) idx = dpbp->dpb_xcluster; - size = dpbp->dpb_xsize; - } else + size = dpbp->dpb_xsize; + } + else #endif if (dpbp->dpb_cluster != UNKNCLUSTER) idx = dpbp->dpb_cluster; @@ -1003,20 +1009,20 @@ STATIC CLUSTER find_fat_free(f_node_ptr fnp) { if (idx > dpbp->dpb_xsize) { - dpbp->dpb_xcluster = UNKNCLUSTER; + dpbp->dpb_xcluster = UNKNCLUSTER; write_fsinfo(dpbp); dir_close(fnp); return LONG_LAST_CLUSTER; } if (dpbp->dpb_xnfreeclst != XUNKNCLSTFREE) - dpbp->dpb_xnfreeclst--; /* TE: moved from link_fat() */ + dpbp->dpb_xnfreeclst--; /* TE: moved from link_fat() */ /* return the free entry */ dpbp->dpb_xcluster = idx; write_fsinfo(dpbp); return idx; } -#endif +#endif if (idx > dpbp->dpb_size) { @@ -1026,7 +1032,7 @@ STATIC CLUSTER find_fat_free(f_node_ptr fnp) } if (dpbp->dpb_nfreeclst != UNKNCLSTFREE) - dpbp->dpb_nfreeclst--; /* TE: moved from link_fat() */ + dpbp->dpb_nfreeclst--; /* TE: moved from link_fat() */ /* return the free entry */ dpbp->dpb_cluster = idx; @@ -1052,16 +1058,16 @@ COUNT dos_mkdir(BYTE * dir) { return DE_PATHNOTFND; } - + /* check that the resulting combined path does not exceed the 64 PARSE_MAX limit. this leeds to problems: A) you can't CD to this directory later B) you can't create files in this subdirectory C) the created dir will not be found later, so you - can create an unlimited amount of same dirs. this space - is lost forever - */ - if (strlen(dir) > PARSE_MAX+2) /* dir is already output of "truename" */ + can create an unlimited amount of same dirs. this space + is lost forever + */ + if (strlen(dir) > PARSE_MAX + 2) /* dir is already output of "truename" */ { dir_close(fnp); return DE_PATHNOTFND; @@ -1075,68 +1081,65 @@ COUNT dos_mkdir(BYTE * dir) return DE_ACCESS; } - /* Reset the directory by a close followed by */ - /* an open */ - fnp->f_flags.f_dmod = FALSE; - parent = fnp->f_dirstart; - dir_close(fnp); - fnp = split_path(dir, szFileName, szFileExt); + /* Reset the directory by a close followed by */ + /* an open */ + fnp->f_flags.f_dmod = FALSE; + parent = fnp->f_dirstart; + dir_close(fnp); + fnp = split_path(dir, szFileName, szFileExt); - /* Get a free f_node pointer so that we can use */ - /* it in building the new file. */ - /* Note that if we're in the root and we don't */ - /* find an empty slot, we need to abort. */ - if (find_free(fnp) == 0) + /* Get a free f_node pointer so that we can use */ + /* it in building the new file. */ + /* Note that if we're in the root and we don't */ + /* find an empty slot, we need to abort. */ + if (find_free(fnp) == 0) + { + if (fnp->f_flags.f_droot) { - if (fnp->f_flags.f_droot) - { - fnp->f_flags.f_dmod = FALSE; - dir_close(fnp); - return DE_TOOMANY; - } + fnp->f_flags.f_dmod = FALSE; + dir_close(fnp); + return DE_TOOMANY; + } /* Otherwise just expand the directory */ - if ((ret = extend_dir(fnp)) != SUCCESS) - return ret; - } + if ((ret = extend_dir(fnp)) != SUCCESS) + return ret; + } - - /* get an empty cluster, so that we make it into a */ - /* directory. */ - /* TE this has to be done (and failed) BEFORE the dir entry */ - /* is changed */ - free_fat = find_fat_free(fnp); - - /* No empty clusters, disk is FULL! Translate into a */ - /* useful error message. */ - if (free_fat == LONG_LAST_CLUSTER) - { - dir_close(fnp); - return DE_HNDLDSKFULL; - } - + /* get an empty cluster, so that we make it into a */ + /* directory. */ + /* TE this has to be done (and failed) BEFORE the dir entry */ + /* is changed */ + free_fat = find_fat_free(fnp); - /* put the fnode's name into the directory. */ - memcpy(fnp->f_dir.dir_name, szFileName, FNAME_SIZE); - memcpy(fnp->f_dir.dir_ext, szFileExt, FEXT_SIZE); + /* No empty clusters, disk is FULL! Translate into a */ + /* useful error message. */ + if (free_fat == LONG_LAST_CLUSTER) + { + dir_close(fnp); + return DE_HNDLDSKFULL; + } - /* Set the fnode to the desired mode */ - fnp->f_mode = WRONLY; - fnp->f_back = LONG_LAST_CLUSTER; + /* put the fnode's name into the directory. */ + memcpy(fnp->f_dir.dir_name, szFileName, FNAME_SIZE); + memcpy(fnp->f_dir.dir_ext, szFileExt, FEXT_SIZE); - fnp->f_dir.dir_size = 0l; - fnp->f_dir.dir_attrib = D_DIR; - fnp->f_dir.dir_time = dos_gettime(); - fnp->f_dir.dir_date = dos_getdate(); + /* Set the fnode to the desired mode */ + fnp->f_mode = WRONLY; + fnp->f_back = LONG_LAST_CLUSTER; - fnp->f_flags.f_dmod = TRUE; - fnp->f_flags.f_dnew = FALSE; - fnp->f_flags.f_ddir = TRUE; + fnp->f_dir.dir_size = 0l; + fnp->f_dir.dir_attrib = D_DIR; + fnp->f_dir.dir_time = dos_gettime(); + fnp->f_dir.dir_date = dos_getdate(); - fnp->f_highwater = 0l; - fnp->f_offset = 0l; + fnp->f_flags.f_dmod = TRUE; + fnp->f_flags.f_dnew = FALSE; + fnp->f_flags.f_ddir = TRUE; + fnp->f_highwater = 0l; + fnp->f_offset = 0l; /* Mark the cluster in the FAT as used */ fnp->f_cluster = free_fat; @@ -1147,8 +1150,7 @@ COUNT dos_mkdir(BYTE * dir) /* Craft the new directory. Note that if we're in a new */ /* directory just under the root, ".." pointer is 0. */ /* as we are overwriting it completely, don't read first */ - bp = getblockOver(clus2phys(free_fat, dpbp), - dpbp->dpb_unit); + bp = getblockOver(clus2phys(free_fat, dpbp), dpbp->dpb_unit); #ifdef DISPLAY_GETBLOCK printf("FAT (dos_mkdir)\n"); #endif @@ -1173,17 +1175,19 @@ COUNT dos_mkdir(BYTE * dir) /* create the ".." entry */ memcpy(DirEntBuffer.dir_name, ".. ", FNAME_SIZE); #ifdef WITHFAT32 - if (ISFAT32(dpbp) && parent == dpbp->dpb_xrootclst) { - parent = 0; + if (ISFAT32(dpbp) && parent == dpbp->dpb_xrootclst) + { + parent = 0; } #endif setdstart(DirEntBuffer, parent); /* and put it out */ - putdirent((struct dirent FAR *)&DirEntBuffer, (BYTE FAR *) & bp->b_buffer[DIRENT_SIZE]); + putdirent((struct dirent FAR *)&DirEntBuffer, + (BYTE FAR *) & bp->b_buffer[DIRENT_SIZE]); /* fill the rest of the block with zeros */ - fmemset( & bp->b_buffer[2 * DIRENT_SIZE],0, BUFFERSIZE - 2 * DIRENT_SIZE); + fmemset(&bp->b_buffer[2 * DIRENT_SIZE], 0, BUFFERSIZE - 2 * DIRENT_SIZE); /* Mark the block to be written out */ bp->b_flag |= BFR_DIRTY | BFR_VALID; @@ -1192,7 +1196,7 @@ COUNT dos_mkdir(BYTE * dir) for (idx = 1; idx <= dpbp->dpb_clsmask; idx++) { - /* as we are overwriting it completely, don't read first */ + /* as we are overwriting it completely, don't read first */ bp = getblockOver(clus2phys(getdstart(fnp->f_dir), dpbp) + idx, dpbp->dpb_unit); #ifdef DISPLAY_GETBLOCK @@ -1205,7 +1209,7 @@ COUNT dos_mkdir(BYTE * dir) } fmemset(bp->b_buffer, 0, BUFFERSIZE); bp->b_flag |= BFR_DIRTY | BFR_VALID; - bp->b_flag |= BFR_UNCACHE; /* need not be cached */ + bp->b_flag |= BFR_UNCACHE; /* need not be cached */ } /* flush the drive buffers so that all info is written */ @@ -1270,15 +1274,16 @@ STATIC COUNT extend_dir(f_node_ptr fnp) #ifdef DISPLAY_GETBLOCK printf("DIR (extend_dir)\n"); #endif - if (bp == NULL) { + if (bp == NULL) + { dir_close(fnp); return DE_BLKINVLD; } fmemset(bp->b_buffer, 0, BUFFERSIZE); bp->b_flag |= BFR_DIRTY | BFR_VALID; - + if (idx != 0) - bp->b_flag |= BFR_UNCACHE; /* needs not be cached */ + bp->b_flag |= BFR_UNCACHE; /* needs not be cached */ } if (!find_free(fnp)) @@ -1351,7 +1356,7 @@ COUNT map_cluster(REG f_node_ptr fnp, COUNT mode) #endif /* The variable clssize will be used later. */ - clssize = (ULONG)fnp->f_dpb->dpb_secsize << fnp->f_dpb->dpb_shftcnt; + clssize = (ULONG) fnp->f_dpb->dpb_secsize << fnp->f_dpb->dpb_shftcnt; /* If someone did a seek, but no writes have occured, we will */ /* need to initialize the fnode. */ @@ -1365,7 +1370,7 @@ COUNT map_cluster(REG f_node_ptr fnp, COUNT mode) } } - if (fnp->f_offset >= fnp->f_cluster_offset) /*JPP */ + if (fnp->f_offset >= fnp->f_cluster_offset) /*JPP */ { /* Set internal index and cluster size. */ idx = fnp->f_offset - fnp->f_cluster_offset; @@ -1400,13 +1405,13 @@ COUNT map_cluster(REG f_node_ptr fnp, COUNT mode) if (!extend(fnp)) { dir_close(fnp); - return DE_HNDLDSKFULL; + return DE_HNDLDSKFULL; } } if (idx < clssize) break; - + fnp->f_back = fnp->f_cluster; /* get next cluster in the chain */ @@ -1414,7 +1419,7 @@ COUNT map_cluster(REG f_node_ptr fnp, COUNT mode) fnp->f_cluster_offset += clssize; idx -= clssize; } - + #ifdef DISPLAY_GETBLOCK printf("done.\n"); #endif @@ -1461,7 +1466,6 @@ COUNT map_cluster(REG f_node_ptr fnp, COUNT mode) the same should be done for writes as well - the time to compile the complete kernel (on some P200) is reduced from 67 to 56 seconds - in an otherwise identical configuration. @@ -1487,7 +1491,6 @@ COUNT map_cluster(REG f_node_ptr fnp, COUNT mode) */ - /* Read block from disk */ UCOUNT readblock(COUNT fd, VOID FAR * buffer, UCOUNT count, COUNT * err) { @@ -1497,7 +1500,7 @@ UCOUNT readblock(COUNT fd, VOID FAR * buffer, UCOUNT count, COUNT * err) UCOUNT ret_cnt = 0; UWORD secsize; UCOUNT to_xfer = count; - ULONG currentblock; + ULONG currentblock; #if defined( DEBUG ) && 0 if (bDumpRdWrParms) @@ -1513,7 +1516,7 @@ UCOUNT readblock(COUNT fd, VOID FAR * buffer, UCOUNT count, COUNT * err) /* If the fd was invalid because it was out of range or the */ /* requested file was not open, tell the caller and exit */ /* note: an invalid fd is indicated by a 0 return */ - if (fnp == (f_node_ptr)0 || fnp->f_count <= 0) + if (fnp == (f_node_ptr) 0 || fnp->f_count <= 0) { *err = DE_INVLDHNDL; return 0; @@ -1556,8 +1559,7 @@ UCOUNT readblock(COUNT fd, VOID FAR * buffer, UCOUNT count, COUNT * err) { /* Do an EOF test and return whatever was transferred */ /* but only for regular files. */ - if (!(fnp->f_flags.f_ddir) - && (fnp->f_offset >= fnp->f_highwater)) + if (!(fnp->f_flags.f_ddir) && (fnp->f_offset >= fnp->f_highwater)) { *err = SUCCESS; return ret_cnt; @@ -1596,96 +1598,90 @@ UCOUNT readblock(COUNT fd, VOID FAR * buffer, UCOUNT count, COUNT * err) } /* Compute the block within the cluster and the offset */ - /* within the block. */ + /* within the block. */ fnp->f_sector = (fnp->f_offset / secsize) & fnp->f_dpb->dpb_clsmask; fnp->f_boff = fnp->f_offset & (secsize - 1); currentblock = clus2phys(fnp->f_cluster, fnp->f_dpb) + fnp->f_sector; /* see comments above */ - - if (!fnp->f_flags.f_ddir && /* don't experiment with directories yet */ - fnp->f_boff == 0 ) /* complete sectors only */ + + if (!fnp->f_flags.f_ddir && /* don't experiment with directories yet */ + fnp->f_boff == 0) /* complete sectors only */ { - static ULONG startoffset; - UCOUNT sectors_to_read,sectors_wanted; - - - startoffset = fnp->f_offset; - - /* avoid EOF problems */ - sectors_wanted = ((UCOUNT) min(fnp->f_highwater - fnp->f_offset, to_xfer)) / - secsize; - - if (sectors_wanted < 2) - goto normal_read; - - sectors_to_read = fnp->f_dpb->dpb_clsmask + 1 - fnp->f_sector; + static ULONG startoffset; + UCOUNT sectors_to_read, sectors_wanted; - sectors_to_read = min(sectors_to_read, sectors_wanted); + startoffset = fnp->f_offset; - fnp->f_offset += sectors_to_read*secsize; - - while (sectors_to_read < sectors_wanted) - { - if (map_cluster(fnp, XFR_READ) != SUCCESS) - break; - - if (clus2phys(fnp->f_cluster, fnp->f_dpb) != currentblock + sectors_to_read) - break; + /* avoid EOF problems */ + sectors_wanted = + ((UCOUNT) min(fnp->f_highwater - fnp->f_offset, to_xfer)) / + secsize; - sectors_to_read += fnp->f_dpb->dpb_clsmask + 1; - - sectors_to_read = min(sectors_to_read, sectors_wanted); + if (sectors_wanted < 2) + goto normal_read; - fnp->f_offset = startoffset + sectors_to_read*secsize; + sectors_to_read = fnp->f_dpb->dpb_clsmask + 1 - fnp->f_sector; - } - - xfr_cnt = sectors_to_read * secsize; + sectors_to_read = min(sectors_to_read, sectors_wanted); - /* avoid caching trouble */ - - DeleteBlockInBufferCache(currentblock, - currentblock + sectors_to_read - 1, - fnp->f_dpb->dpb_unit); - - if (dskxfer(fnp->f_dpb->dpb_unit, - currentblock, - (VOID FAR *) buffer, sectors_to_read, DSKREAD)) - { - fnp->f_offset = startoffset; - *err = DE_BLKINVLD; - return ret_cnt; - } - + fnp->f_offset += sectors_to_read * secsize; - goto update_pointers; - } + while (sectors_to_read < sectors_wanted) + { + if (map_cluster(fnp, XFR_READ) != SUCCESS) + break; + + if (clus2phys(fnp->f_cluster, fnp->f_dpb) != + currentblock + sectors_to_read) + break; + + sectors_to_read += fnp->f_dpb->dpb_clsmask + 1; + + sectors_to_read = min(sectors_to_read, sectors_wanted); + + fnp->f_offset = startoffset + sectors_to_read * secsize; + + } + xfr_cnt = sectors_to_read * secsize; + /* avoid caching trouble */ + DeleteBlockInBufferCache(currentblock, + currentblock + sectors_to_read - 1, + fnp->f_dpb->dpb_unit); + + if (dskxfer(fnp->f_dpb->dpb_unit, + currentblock, + (VOID FAR *) buffer, sectors_to_read, DSKREAD)) + { + fnp->f_offset = startoffset; + *err = DE_BLKINVLD; + return ret_cnt; + } - - /* normal read: just the old, buffer = sector based read */ -normal_read: + goto update_pointers; + } + /* normal read: just the old, buffer = sector based read */ + normal_read: #ifdef DSK_DEBUG printf("read %d links; dir offset %ld, cluster %lx\n", - fnp->f_count, - fnp->f_diroff, - fnp->f_cluster); + fnp->f_count, fnp->f_diroff, fnp->f_cluster); #endif /* Get the block we need from cache */ - bp = getblock(currentblock /*clus2phys(fnp->f_cluster, fnp->f_dpb) + fnp->f_sector*/, - fnp->f_dpb->dpb_unit); + bp = getblock(currentblock + /*clus2phys(fnp->f_cluster, fnp->f_dpb) + fnp->f_sector */ + , fnp->f_dpb->dpb_unit); #ifdef DISPLAY_GETBLOCK printf("DATA (readblock)\n"); #endif - if (bp == NULL) /* (struct buffer *)0 --> DS:0 !! */ + if (bp == NULL) /* (struct buffer *)0 --> DS:0 !! */ { *err = DE_BLKINVLD; return ret_cnt; @@ -1699,25 +1695,24 @@ UCOUNT readblock(COUNT fd, VOID FAR * buffer, UCOUNT count, COUNT * err) if (fnp->f_flags.f_ddir) xfr_cnt = min(to_xfer, secsize - fnp->f_boff); else - xfr_cnt = (UWORD)min(min(to_xfer, secsize - fnp->f_boff), - fnp->f_highwater - fnp->f_offset); + xfr_cnt = (UWORD) min(min(to_xfer, secsize - fnp->f_boff), + fnp->f_highwater - fnp->f_offset); fmemcpy(buffer, &bp->b_buffer[fnp->f_boff], xfr_cnt); - /* complete buffer read ? - probably not reused later - */ + /* complete buffer read ? + probably not reused later + */ if (xfr_cnt == sizeof(bp->b_buffer) || - fnp->f_offset + xfr_cnt == fnp->f_highwater ) - { - bp->b_flag |= BFR_UNCACHE; - } - + fnp->f_offset + xfr_cnt == fnp->f_highwater) + { + bp->b_flag |= BFR_UNCACHE; + } /* update pointers and counters */ fnp->f_offset += xfr_cnt; -update_pointers: + update_pointers: ret_cnt += xfr_cnt; to_xfer -= xfr_cnt; buffer = add_far((VOID FAR *) buffer, (ULONG) xfr_cnt); @@ -1735,78 +1730,74 @@ UCOUNT readblock(COUNT fd, VOID FAR * buffer, UCOUNT count, COUNT * err) /* default */ STATIC COUNT dos_extend(f_node_ptr fnp) { -#ifdef WRITEZEROS +#ifdef WRITEZEROS struct buffer FAR *bp; UCOUNT xfr_cnt = 0; /* The variable secsize will be used later. */ UWORD secsize = fnp->f_dpb->dpb_secsize; ULONG count; -#endif +#endif if (fnp->f_offset <= fnp->f_highwater) return SUCCESS; -#ifdef WRITEZEROS +#ifdef WRITEZEROS count = fnp->f_offset - fnp->f_highwater; fnp->f_offset = fnp->f_highwater; while (count > 0) +#endif { -#endif if (map_cluster(fnp, XFR_WRITE) != SUCCESS) return DE_HNDLDSKFULL; #ifdef WRITEZEROS /* Compute the block within the cluster and the offset */ /* within the block. */ - fnp->f_sector = - (fnp->f_offset / secsize) & fnp->f_dpb->dpb_clsmask; + fnp->f_sector = (fnp->f_offset / secsize) & fnp->f_dpb->dpb_clsmask; fnp->f_boff = fnp->f_offset & (secsize - 1); #ifdef DSK_DEBUG printf("write %d links; dir offset %ld, cluster %d\n", - fnp->f_count, - fnp->f_diroff, - fnp->f_cluster); + fnp->f_count, fnp->f_diroff, fnp->f_cluster); #endif - xfr_cnt = count < (ULONG)secsize - fnp->f_boff ? - (UWORD) count : - secsize - fnp->f_boff; + xfr_cnt = count < (ULONG) secsize - fnp->f_boff ? + (UWORD) count : secsize - fnp->f_boff; /* get a buffer to store the block in */ - if ( (fnp->f_boff == 0) && (xfr_cnt == secsize) ) { - bp = getblockOver(clus2phys(fnp->f_cluster, fnp->f_dpb) + fnp->f_sector, + if ((fnp->f_boff == 0) && (xfr_cnt == secsize)) + { + bp = getblockOver(clus2phys(fnp->f_cluster, fnp->f_dpb) + + fnp->f_sector, fnp->f_dpb->dpb_unit); + + } + else + { + bp = getblock(clus2phys(fnp->f_cluster, fnp->f_dpb) + fnp->f_sector, fnp->f_dpb->dpb_unit); - - } else { - bp = getblock(clus2phys(fnp->f_cluster, fnp->f_dpb) + fnp->f_sector, - fnp->f_dpb->dpb_unit); } - if (bp == NULL) { + if (bp == NULL) + { return DE_BLKINVLD; - } - + } /* set a block to zero */ fmemset((BYTE FAR *) & bp->b_buffer[fnp->f_boff], 0, xfr_cnt); bp->b_flag |= BFR_DIRTY | BFR_VALID; - if (xfr_cnt == sizeof(bp->b_buffer)) /* probably not used later */ - { - bp->b_flag |= BFR_UNCACHE; - } + if (xfr_cnt == sizeof(bp->b_buffer)) /* probably not used later */ + { + bp->b_flag |= BFR_UNCACHE; + } /* update pointers and counters */ count -= xfr_cnt; fnp->f_offset += xfr_cnt; + fnp->f_dir.dir_size = fnp->f_offset; +#endif fnp->f_highwater = fnp->f_offset; - fnp->f_dir.dir_size = fnp->f_highwater; - merge_file_changes(fnp, FALSE); /* /// Added - Ron Cemer */ + merge_file_changes(fnp, FALSE); /* /// Added - Ron Cemer */ } -#else - fnp->f_highwater = fnp->f_offset; - merge_file_changes(fnp, FALSE); /* /// Added - Ron Cemer */ -#endif return SUCCESS; } @@ -1835,7 +1826,7 @@ UCOUNT writeblock(COUNT fd, VOID FAR * buffer, UCOUNT count, COUNT * err) /* If the fd was invalid because it was out of range or the */ /* requested file was not open, tell the caller and exit */ /* note: an invalid fd is indicated by a 0 return */ - if (fnp == (f_node_ptr)0 || fnp->f_count <= 0) + if (fnp == (f_node_ptr) 0 || fnp->f_count <= 0) { *err = DE_INVLDHNDL; return 0; @@ -1848,14 +1839,14 @@ UCOUNT writeblock(COUNT fd, VOID FAR * buffer, UCOUNT count, COUNT * err) return 0; } - fnp->f_flags.f_dmod = TRUE; /* mark file as modified */ - fnp->f_flags.f_ddate = FALSE; /* set date not valid any more */ + fnp->f_flags.f_dmod = TRUE; /* mark file as modified */ + fnp->f_flags.f_ddate = FALSE; /* set date not valid any more */ - /* extend file from fnp->f_highwater to fnp->f_offset */ + /* extend file from fnp->f_highwater to fnp->f_offset */ *err = dos_extend(fnp); if (*err != SUCCESS) return 0; - + /* Test that we are really about to do a data transfer. If the */ /* count is zero and the mode is XFR_READ, just exit. (Any */ /* read with a count of zero is a nop). */ @@ -1864,13 +1855,13 @@ UCOUNT writeblock(COUNT fd, VOID FAR * buffer, UCOUNT count, COUNT * err) /* file length to the current length (truncates it). */ /* */ /* NOTE: doing this up front saves a lot of headaches later. */ - + if (count == 0) { - /* NOTE: doing this up front made a lot of headaches later :-( TE */ + /* NOTE: doing this up front made a lot of headaches later :-( TE */ /* FAT allocation has to be extended if necessary TE */ /* Now done in dos_extend BO */ - /* remove all the following allocated clusters in shrink_file */ + /* remove all the following allocated clusters in shrink_file */ fnp->f_highwater = fnp->f_offset; shrink_file(fnp); return 0; @@ -1948,15 +1939,12 @@ UCOUNT writeblock(COUNT fd, VOID FAR * buffer, UCOUNT count, COUNT * err) /* Compute the block within the cluster and the offset */ /* within the block. */ - fnp->f_sector = - (fnp->f_offset / secsize) & fnp->f_dpb->dpb_clsmask; + fnp->f_sector = (fnp->f_offset / secsize) & fnp->f_dpb->dpb_clsmask; fnp->f_boff = fnp->f_offset & (secsize - 1); #ifdef DSK_DEBUG printf("write %d links; dir offset %ld, cluster %d\n", - fnp->f_count, - fnp->f_diroff, - fnp->f_cluster); + fnp->f_count, fnp->f_diroff, fnp->f_cluster); #endif /* /// Moved xfr_cnt calculation from below so we can @@ -1970,29 +1958,32 @@ UCOUNT writeblock(COUNT fd, VOID FAR * buffer, UCOUNT count, COUNT * err) /* get a buffer to store the block in */ /* /// BUG!!! Added conditional to only use getbuf() if we're going - to write the entire block, which is faster because it does - not first read the block from disk. However, if we are - going to only write part of the block, we MUST use the - getblock() call, which first reads the block from disk. - Without this modification, the kernel was writing garbage - to the file when sequential writes were attempted at less - than the block size. This was causing problems with - piping and redirection in FreeCOM, as well as many other - potential problems. - - Ron Cemer */ - if ( (fnp->f_boff == 0) && (xfr_cnt == secsize) ) { - bp = getblockOver(clus2phys(fnp->f_cluster, fnp->f_dpb) + fnp->f_sector, - fnp->f_dpb->dpb_unit); - - } else { - bp = getblock(clus2phys(fnp->f_cluster, fnp->f_dpb) + fnp->f_sector, - fnp->f_dpb->dpb_unit); + to write the entire block, which is faster because it does + not first read the block from disk. However, if we are + going to only write part of the block, we MUST use the + getblock() call, which first reads the block from disk. + Without this modification, the kernel was writing garbage + to the file when sequential writes were attempted at less + than the block size. This was causing problems with + piping and redirection in FreeCOM, as well as many other + potential problems. + - Ron Cemer */ + if ((fnp->f_boff == 0) && (xfr_cnt == secsize)) + { + bp = getblockOver(clus2phys(fnp->f_cluster, fnp->f_dpb) + + fnp->f_sector, fnp->f_dpb->dpb_unit); + } - if (bp == NULL) { + else + { + bp = getblock(clus2phys(fnp->f_cluster, fnp->f_dpb) + + fnp->f_sector, fnp->f_dpb->dpb_unit); + } + if (bp == NULL) + { *err = DE_BLKINVLD; return ret_cnt; - } - + } /* transfer a block */ /* Transfer size as either a full block size, or the */ @@ -2007,11 +1998,10 @@ UCOUNT writeblock(COUNT fd, VOID FAR * buffer, UCOUNT count, COUNT * err) fmemcpy(&bp->b_buffer[fnp->f_boff], buffer, xfr_cnt); bp->b_flag |= BFR_DIRTY | BFR_VALID; - if (xfr_cnt == sizeof(bp->b_buffer)) /* probably not used later */ - { - bp->b_flag |= BFR_UNCACHE; - } - + if (xfr_cnt == sizeof(bp->b_buffer)) /* probably not used later */ + { + bp->b_flag |= BFR_UNCACHE; + } /* update pointers and counters */ ret_cnt += xfr_cnt; @@ -2023,7 +2013,7 @@ UCOUNT writeblock(COUNT fd, VOID FAR * buffer, UCOUNT count, COUNT * err) fnp->f_highwater = fnp->f_offset; fnp->f_dir.dir_size = fnp->f_highwater; } - merge_file_changes(fnp, FALSE); /* /// Added - Ron Cemer */ + merge_file_changes(fnp, FALSE); /* /// Added - Ron Cemer */ } *err = SUCCESS; return ret_cnt; @@ -2043,7 +2033,7 @@ LONG dos_lseek(COUNT fd, LONG foffset, COUNT origin) /* requested file was not open, tell the caller and exit */ /* note: an invalid fd is indicated by a 0 return */ - if (fnp == (f_node_ptr)0 || fnp->f_count <= 0) + if (fnp == (f_node_ptr) 0 || fnp->f_count <= 0) return (LONG) DE_INVLDHNDL; /* now do the actual lseek adjustment to the file poitner */ @@ -2069,7 +2059,7 @@ LONG dos_lseek(COUNT fd, LONG foffset, COUNT origin) } /* returns the number of unused clusters */ -CLUSTER dos_free(struct dpb FAR *dpbp) +CLUSTER dos_free(struct dpb FAR * dpbp) { /* There's an unwritten rule here. All fs */ /* cluster start at 2 and run to max_cluster+2 */ @@ -2079,23 +2069,24 @@ CLUSTER dos_free(struct dpb FAR *dpbp) #ifdef WITHFAT32 if (ISFAT32(dpbp)) - { + { if (dpbp->dpb_xnfreeclst != XUNKNCLSTFREE) return dpbp->dpb_xnfreeclst; max_cluster = dpbp->dpb_xsize + 1; - } - else -#endif - if (dpbp->dpb_nfreeclst != UNKNCLSTFREE) - return dpbp->dpb_nfreeclst; - + } + else +#endif + if (dpbp->dpb_nfreeclst != UNKNCLSTFREE) + return dpbp->dpb_nfreeclst; + for (i = 2; i < max_cluster; i++) { if (next_cluster(dpbp, i) == 0) ++cnt; } #ifdef WITHFAT32 - if (ISFAT32(dpbp)) { + if (ISFAT32(dpbp)) + { dpbp->dpb_xnfreeclst = cnt; write_fsinfo(dpbp); return cnt; @@ -2105,19 +2096,17 @@ CLUSTER dos_free(struct dpb FAR *dpbp) return cnt; } - - #ifndef IPL -COUNT dos_cd(struct cds FAR * cdsp, BYTE *PathName) +COUNT dos_cd(struct cds FAR * cdsp, BYTE * PathName) { f_node_ptr fnp; /* first check for valid drive */ if (cdsp->cdsDpb == 0) - return DE_INVLDDRV; + return DE_INVLDDRV; if ((media_check(cdsp->cdsDpb) < 0)) - return DE_INVLDDRV; + return DE_INVLDDRV; /* now test for its existance. If it doesn't, return an error. */ if ((fnp = dir_open(PathName)) == NULL) @@ -2143,7 +2132,7 @@ f_node_ptr get_f_node(void) return &f_nodes[i]; } } - return (f_node_ptr)0; + return (f_node_ptr) 0; } VOID release_f_node(f_node_ptr fnp) @@ -2171,7 +2160,7 @@ COUNT dos_getfattr(BYTE * name) return DE_FILENOTFND; /* note: an invalid fd is indicated by a 0 return */ - if ((fnp = xlt_fd(fd)) == (f_node_ptr)0) + if ((fnp = xlt_fd(fd)) == (f_node_ptr) 0) return DE_TOOMANY; /* If the fd was invalid because it was out of range or the */ @@ -2199,7 +2188,7 @@ COUNT dos_setfattr(BYTE * name, UWORD attrp) return DE_FILENOTFND; /* note: an invalid fd is indicated by a 0 return */ - if ((fnp = xlt_fd(fd)) == (f_node_ptr)0) + if ((fnp = xlt_fd(fd)) == (f_node_ptr) 0) return DE_TOOMANY; /* If the fd was invalid because it was out of range or the */ @@ -2218,10 +2207,10 @@ COUNT dos_setfattr(BYTE * name, UWORD attrp) /* Set the attribute from the fnode and return */ /* clear all attributes but DIR and VOLID */ - fnp->f_dir.dir_attrib &= (D_VOLID | D_DIR); /* JPP */ + fnp->f_dir.dir_attrib &= (D_VOLID | D_DIR); /* JPP */ /* set attributes that user requested */ - fnp->f_dir.dir_attrib |= attrp; /* JPP */ + fnp->f_dir.dir_attrib |= attrp; /* JPP */ fnp->f_flags.f_dmod = TRUE; fnp->f_flags.f_ddate = TRUE; dos_close(fd); @@ -2230,10 +2219,10 @@ COUNT dos_setfattr(BYTE * name, UWORD attrp) #endif #ifdef WITHFAT32 -VOID bpb_to_dpb(bpb FAR *bpbp, REG struct dpb FAR * dpbp, BOOL extended) +VOID bpb_to_dpb(bpb FAR * bpbp, REG struct dpb FAR * dpbp, BOOL extended) #else -VOID bpb_to_dpb(bpb FAR *bpbp, REG struct dpb FAR * dpbp) -#endif +VOID bpb_to_dpb(bpb FAR * bpbp, REG struct dpb FAR * dpbp) +#endif { ULONG size; REG UWORD shftcnt; @@ -2244,16 +2233,13 @@ VOID bpb_to_dpb(bpb FAR *bpbp, REG struct dpb FAR * dpbp) dpbp->dpb_fatstrt = bpbp->bpb_nreserved; dpbp->dpb_fats = bpbp->bpb_nfat; dpbp->dpb_dirents = bpbp->bpb_ndirent; - size = bpbp->bpb_nsize == 0 ? - bpbp->bpb_huge : - (ULONG) bpbp->bpb_nsize; + size = bpbp->bpb_nsize == 0 ? bpbp->bpb_huge : (ULONG) bpbp->bpb_nsize; dpbp->dpb_fatsize = bpbp->bpb_nfsect; dpbp->dpb_dirstrt = dpbp->dpb_fatstrt + dpbp->dpb_fats * dpbp->dpb_fatsize; dpbp->dpb_data = dpbp->dpb_dirstrt - + ((DIRENT_SIZE * (ULONG)dpbp->dpb_dirents - + (dpbp->dpb_secsize - 1)) - / dpbp->dpb_secsize); + + ((DIRENT_SIZE * (ULONG) dpbp->dpb_dirents + + (dpbp->dpb_secsize - 1)) / dpbp->dpb_secsize); /* Michal Meller patch to jimtabor */ dpbp->dpb_size = ((size - dpbp->dpb_data) / ((ULONG) bpbp->bpb_nsector) + 1); @@ -2266,9 +2252,9 @@ VOID bpb_to_dpb(bpb FAR *bpbp, REG struct dpb FAR * dpbp) if (extended) { dpbp->dpb_xfatsize = bpbp->bpb_nfsect == 0 ? bpbp->bpb_xnfsect - : bpbp->bpb_nfsect; + : bpbp->bpb_nfsect; dpbp->dpb_xcluster = UNKNCLUSTER; - dpbp->dpb_xnfreeclst = XUNKNCLSTFREE; /* number of free clusters */ + dpbp->dpb_xnfreeclst = XUNKNCLSTFREE; /* number of free clusters */ dpbp->dpb_xflags = 0; dpbp->dpb_xfsinfosec = 0xffff; @@ -2276,8 +2262,8 @@ VOID bpb_to_dpb(bpb FAR *bpbp, REG struct dpb FAR * dpbp) dpbp->dpb_xrootclst = 0; dpbp->dpb_xdata = dpbp->dpb_data; dpbp->dpb_xsize = dpbp->dpb_size; - - if (ISFAT32(dpbp)) + + if (ISFAT32(dpbp)) { dpbp->dpb_xflags = bpbp->bpb_xflags; dpbp->dpb_xfsinfosec = bpbp->bpb_xfsinfosec; @@ -2285,13 +2271,14 @@ VOID bpb_to_dpb(bpb FAR *bpbp, REG struct dpb FAR * dpbp) dpbp->dpb_dirents = 0; dpbp->dpb_dirstrt = 0xffff; dpbp->dpb_size = 0; - dpbp->dpb_xdata = dpbp->dpb_fatstrt + dpbp->dpb_fats * dpbp->dpb_xfatsize; - dpbp->dpb_xsize = ((size - dpbp->dpb_xdata) - / ((ULONG) bpbp->bpb_nsector) + 1); + dpbp->dpb_xdata = + dpbp->dpb_fatstrt + dpbp->dpb_fats * dpbp->dpb_xfatsize; + dpbp->dpb_xsize = + ((size - dpbp->dpb_xdata) / ((ULONG) bpbp->bpb_nsector) + 1); dpbp->dpb_xrootclst = bpbp->bpb_xrootclst; read_fsinfo(dpbp); - } - } + } + } #endif for (shftcnt = 0; (bpbp->bpb_nsector >> shftcnt) > 1; shftcnt++) @@ -2310,7 +2297,8 @@ COUNT media_check(REG struct dpb FAR * dpbp) MediaReqHdr.r_mcmdesc = dpbp->dpb_mdb; MediaReqHdr.r_status = 0; execrh((request FAR *) & MediaReqHdr, dpbp->dpb_device); - if (!(MediaReqHdr.r_status & S_ERROR) && (MediaReqHdr.r_status & S_DONE)) + if (!(MediaReqHdr.r_status & S_ERROR) + && (MediaReqHdr.r_status & S_DONE)) break; else { @@ -2357,12 +2345,14 @@ COUNT media_check(REG struct dpb FAR * dpbp) MediaReqHdr.r_mcmdesc = dpbp->dpb_mdb; MediaReqHdr.r_status = 0; execrh((request FAR *) & MediaReqHdr, dpbp->dpb_device); - if (!(MediaReqHdr.r_status & S_ERROR) && (MediaReqHdr.r_status & S_DONE)) + if (!(MediaReqHdr.r_status & S_ERROR) + && (MediaReqHdr.r_status & S_DONE)) break; else { loop2: - switch (block_error(&MediaReqHdr, dpbp->dpb_unit, dpbp->dpb_device)) + switch (block_error + (&MediaReqHdr, dpbp->dpb_unit, dpbp->dpb_device)) { case ABORT: case FAIL: @@ -2391,13 +2381,13 @@ COUNT media_check(REG struct dpb FAR * dpbp) /* translate the fd into an f_node pointer */ f_node_ptr xlt_fd(COUNT fd) { - return fd >= f_nodes_cnt ? (f_node_ptr)0 : &f_nodes[fd]; + return fd >= f_nodes_cnt ? (f_node_ptr) 0 : &f_nodes[fd]; } /* translate the f_node pointer into an fd */ COUNT xlt_fnp(f_node_ptr fnp) { - return (COUNT)(fnp - f_nodes); + return (COUNT) (fnp - f_nodes); } #if 0 @@ -2406,12 +2396,11 @@ struct dhdr FAR *select_unit(COUNT drive) /* Just get the header from the dhdr array */ /* return blk_devices[drive].dpb_device; */ - return (struct dhdr FAR *)CDSp->cds_table[drive].cdsDpb; + return (struct dhdr FAR *)CDSp->cds_table[drive].cdsDpb; } #endif - /* TE if the current filesize in FAT is larger then the dir_size it's truncated here. @@ -2430,45 +2419,45 @@ struct dhdr FAR *select_unit(COUNT drive) STATIC VOID shrink_file(f_node_ptr fnp) { - ULONG lastoffset = fnp->f_offset; /* has to be saved */ - CLUSTER next,st; - struct dpb FAR *dpbp = fnp->f_dpb; + ULONG lastoffset = fnp->f_offset; /* has to be saved */ + CLUSTER next, st; + struct dpb FAR *dpbp = fnp->f_dpb; - fnp->f_offset = fnp->f_highwater; /* end of file */ + fnp->f_offset = fnp->f_highwater; /* end of file */ - if (fnp->f_offset) fnp->f_offset--; /* last existing cluster */ - - if (map_cluster(fnp, XFR_READ) != SUCCESS) /* error, don't truncate */ - goto done; - - st = fnp->f_cluster; + if (fnp->f_offset) + fnp->f_offset--; /* last existing cluster */ - next = next_cluster(dpbp, st); + if (map_cluster(fnp, XFR_READ) != SUCCESS) /* error, don't truncate */ + goto done; - if (next == LONG_LAST_CLUSTER) /* last cluster found */ - goto done; + st = fnp->f_cluster; - /* Loop from start until either a FREE entry is */ - /* encountered (due to a damaged file system) or the */ - /* last cluster is encountered. */ - /* zap the FAT pointed to */ + next = next_cluster(dpbp, st); - - if (fnp->f_highwater == 0) - { - setdstart(fnp->f_dir, FREE); - link_fat(dpbp, st, FREE); - } - else - { - link_fat(dpbp, st,LONG_LAST_CLUSTER); - } + if (next == LONG_LAST_CLUSTER) /* last cluster found */ + goto done; + + /* Loop from start until either a FREE entry is */ + /* encountered (due to a damaged file system) or the */ + /* last cluster is encountered. */ + /* zap the FAT pointed to */ + + if (fnp->f_highwater == 0) + { + setdstart(fnp->f_dir, FREE); + link_fat(dpbp, st, FREE); + } + else + { + link_fat(dpbp, st, LONG_LAST_CLUSTER); + } + + wipe_out_clusters(dpbp, next); - wipe_out_clusters(dpbp, next); - done: - fnp->f_offset = lastoffset; /* has to be restored */ - + fnp->f_offset = lastoffset; /* has to be restored */ + } /* @@ -2617,4 +2606,3 @@ STATIC VOID shrink_file(f_node_ptr fnp) * Rev 1.0 02 Jul 1995 8:04:46 patv * Initial revision. */ - diff --git a/kernel/fattab.c b/kernel/fattab.c index ce510d4b..b6a05c29 100644 --- a/kernel/fattab.c +++ b/kernel/fattab.c @@ -30,7 +30,8 @@ #include "globals.h" #ifdef VERSION_STRINGS -static BYTE *RcsId = "$Id$"; +static BYTE *RcsId = + "$Id$"; #endif #ifdef PROTO @@ -56,43 +57,43 @@ CLUSTER next_cl32(); /************************************************************************/ #ifndef ISFAT32 -int ISFAT32(struct dpb FAR *dpbp) +int ISFAT32(struct dpb FAR * dpbp) { - return _ISFAT32(dpbp); + return _ISFAT32(dpbp); } #endif - -struct buffer FAR *getFATblock(CLUSTER cluster, struct dpb FAR *dpbp) +struct buffer FAR *getFATblock(CLUSTER cluster, struct dpb FAR * dpbp) { - ULONG sector; + ULONG sector; struct buffer FAR *bp; if (ISFAT12(dpbp)) - { - sector = ((cluster << 1) + cluster) >> 1; - } + { + sector = ((cluster << 1) + cluster) >> 1; + } #ifdef WITHFAT32 else if (ISFAT32(dpbp)) - { - sector = (ULONG)cluster * SIZEOF_CLST32; - } + { + sector = (ULONG) cluster *SIZEOF_CLST32; + } #endif else - { - sector = (ULONG)cluster * SIZEOF_CLST16; - } - sector = sector / dpbp->dpb_secsize + dpbp->dpb_fatstrt; + { + sector = (ULONG) cluster *SIZEOF_CLST16; + } + sector = sector / dpbp->dpb_secsize + dpbp->dpb_fatstrt; #ifdef WITHFAT32 - if (ISFAT32(dpbp) && (dpbp->dpb_xflags & FAT_NO_MIRRORING)) { + if (ISFAT32(dpbp) && (dpbp->dpb_xflags & FAT_NO_MIRRORING)) + { /* we must modify the active fat, it's number is in the 0-3 bits of dpb_xflags */ sector += (dpbp->dpb_xflags & 0xf) * dpbp->dpb_xfatsize; } #endif - + bp = getblock(sector, dpbp->dpb_unit); - + if (bp) { bp->b_flag &= ~(BFR_DATA | BFR_DIR); @@ -108,11 +109,11 @@ struct buffer FAR *getFATblock(CLUSTER cluster, struct dpb FAR *dpbp) } #endif } - return bp; + return bp; } #ifdef WITHFAT32 -void read_fsinfo(struct dpb FAR *dpbp) +void read_fsinfo(struct dpb FAR * dpbp) { struct buffer FAR *bp; struct fsinfo FAR *fip; @@ -121,12 +122,12 @@ void read_fsinfo(struct dpb FAR *dpbp) bp->b_flag &= ~(BFR_DATA | BFR_DIR | BFR_FAT | BFR_DIRTY); bp->b_flag |= BFR_VALID; - fip = (struct fsinfo FAR *) & bp->b_buffer[0x1e4]; + fip = (struct fsinfo FAR *)&bp->b_buffer[0x1e4]; dpbp->dpb_xnfreeclst = fip->fi_nfreeclst; dpbp->dpb_xcluster = fip->fi_cluster; } -void write_fsinfo(struct dpb FAR *dpbp) +void write_fsinfo(struct dpb FAR * dpbp) { struct buffer FAR *bp; struct fsinfo FAR *fip; @@ -135,7 +136,7 @@ void write_fsinfo(struct dpb FAR *dpbp) bp->b_flag &= ~(BFR_DATA | BFR_DIR | BFR_FAT); bp->b_flag |= BFR_VALID | BFR_DIRTY; - fip = (struct fsinfo FAR *) & bp->b_buffer[0x1e4]; + fip = (struct fsinfo FAR *)&bp->b_buffer[0x1e4]; fip->fi_nfreeclst = dpbp->dpb_xnfreeclst; fip->fi_cluster = dpbp->dpb_xcluster; } @@ -157,10 +158,11 @@ void write_fsinfo(struct dpb FAR *dpbp) /* 12 bytes are compressed to 9 bytes */ /* */ -UCOUNT link_fat(struct dpb FAR *dpbp, CLUSTER Cluster1, REG CLUSTER Cluster2) +UCOUNT link_fat(struct dpb FAR * dpbp, CLUSTER Cluster1, + REG CLUSTER Cluster2) { UCOUNT res; - + if (ISFAT12(dpbp)) res = link_fat12(dpbp, Cluster1, Cluster2); else if (ISFAT16(dpbp)) @@ -172,7 +174,6 @@ UCOUNT link_fat(struct dpb FAR *dpbp, CLUSTER Cluster1, REG CLUSTER Cluster2) else return DE_BLKINVLD; - /* update the free space count */ if (res == SUCCESS && Cluster2 == FREE) @@ -181,36 +182,38 @@ UCOUNT link_fat(struct dpb FAR *dpbp, CLUSTER Cluster1, REG CLUSTER Cluster2) if (ISFAT32(dpbp) && dpbp->dpb_xnfreeclst != XUNKNCLSTFREE) { /* update the free space count for returned */ - /* cluster */ + /* cluster */ ++dpbp->dpb_xnfreeclst; write_fsinfo(dpbp); - } else + } + else #endif if (dpbp->dpb_nfreeclst != UNKNCLSTFREE) ++dpbp->dpb_nfreeclst; } - /*if (Cluster2 == FREE) - { */ - /* update the free space count for returned */ - /* cluster */ - /* ++dpbp->dpb_nfreeclst; - }*/ - - /* update the free space count for removed */ - /* cluster */ - /* BUG: was counted twice for 2nd,.. cluster. moved to find_fat_free() */ - /* BO: don't completely understand this yet - leave here for now as - a comment */ - /* else - { - --dpbp->dpb_nfreeclst; - } */ - return res; + /*if (Cluster2 == FREE) + { */ + /* update the free space count for returned */ + /* cluster */ + /* ++dpbp->dpb_nfreeclst; + } */ + + /* update the free space count for removed */ + /* cluster */ + /* BUG: was counted twice for 2nd,.. cluster. moved to find_fat_free() */ + /* BO: don't completely understand this yet - leave here for now as + a comment */ + /* else + { + --dpbp->dpb_nfreeclst; + } */ + return res; } #ifdef WITHFAT32 -UCOUNT link_fat32(struct dpb FAR *dpbp, CLUSTER Cluster1, CLUSTER Cluster2) +UCOUNT link_fat32(struct dpb FAR * dpbp, CLUSTER Cluster1, + CLUSTER Cluster2) { UCOUNT idx; struct buffer FAR *bp; @@ -223,7 +226,7 @@ UCOUNT link_fat32(struct dpb FAR *dpbp, CLUSTER Cluster1, CLUSTER Cluster2) /* form an index so that we can read the block as a */ /* byte array */ - idx = (UWORD)((Cluster1 * SIZEOF_CLST32) % dpbp->dpb_secsize); + idx = (UWORD) ((Cluster1 * SIZEOF_CLST32) % dpbp->dpb_secsize); /* Finally, put the word into the buffer and mark the */ /* buffer as dirty. */ @@ -237,7 +240,8 @@ UCOUNT link_fat32(struct dpb FAR *dpbp, CLUSTER Cluster1, CLUSTER Cluster2) #endif -UCOUNT link_fat16(struct dpb FAR *dpbp, CLUSTER Cluster1, CLUSTER Cluster2) +UCOUNT link_fat16(struct dpb FAR * dpbp, CLUSTER Cluster1, + CLUSTER Cluster2) { UCOUNT idx; struct buffer FAR *bp; @@ -250,7 +254,7 @@ UCOUNT link_fat16(struct dpb FAR *dpbp, CLUSTER Cluster1, CLUSTER Cluster2) /* form an index so that we can read the block as a */ /* byte array */ - idx = (UWORD)(( Cluster1 * SIZEOF_CLST16) % dpbp->dpb_secsize); + idx = (UWORD) ((Cluster1 * SIZEOF_CLST16) % dpbp->dpb_secsize); /* Finally, put the word into the buffer and mark the */ /* buffer as dirty. */ @@ -262,22 +266,21 @@ UCOUNT link_fat16(struct dpb FAR *dpbp, CLUSTER Cluster1, CLUSTER Cluster2) return SUCCESS; } -UCOUNT link_fat12(struct dpb FAR *dpbp, CLUSTER Cluster1, CLUSTER Cluster2) +UCOUNT link_fat12(struct dpb FAR * dpbp, CLUSTER Cluster1, + CLUSTER Cluster2) { - REG UBYTE FAR *fbp0, - FAR * fbp1; + REG UBYTE FAR *fbp0, FAR * fbp1; UCOUNT idx; - struct buffer FAR *bp, - FAR * bp1; + struct buffer FAR *bp, FAR * bp1; /* Get the block that this cluster is in */ - bp = getFATblock(Cluster1 , dpbp); + bp = getFATblock(Cluster1, dpbp); if (bp == NULL) return DE_BLKINVLD; /* form an index so that we can read the block as a */ /* byte array */ - idx = (UCOUNT)(((Cluster1 << 1) + Cluster1) >> 1) % dpbp->dpb_secsize; + idx = (UCOUNT) (((Cluster1 << 1) + Cluster1) >> 1) % dpbp->dpb_secsize; /* Test to see if the cluster straddles the block. If */ /* it does, get the next block and use both to form the */ @@ -285,7 +288,7 @@ UCOUNT link_fat12(struct dpb FAR *dpbp, CLUSTER Cluster1, CLUSTER Cluster2) /* block. */ if (idx >= dpbp->dpb_secsize - 1) { - bp1 = getFATblock(Cluster1 + 1,dpbp); + bp1 = getFATblock(Cluster1 + 1, dpbp); if (bp1 == 0) return DE_BLKINVLD; @@ -315,12 +318,14 @@ UCOUNT link_fat12(struct dpb FAR *dpbp, CLUSTER Cluster1, CLUSTER Cluster2) /* Given the disk parameters, and a cluster number, this function looks at the FAT, and returns the next cluster in the clain. */ -CLUSTER next_cluster(struct dpb FAR *dpbp, CLUSTER ClusterNum) +CLUSTER next_cluster(struct dpb FAR * dpbp, CLUSTER ClusterNum) { struct buffer FAR *bp; #ifdef DEBUG - if (ClusterNum == LONG_LAST_CLUSTER) printf("fatal error: trying to do next_cluster(dpbp, EOC)!\n"); - if (ClusterNum == 0) printf("fatal error: trying to do next_cluster(dpbp, 0)!\n"); + if (ClusterNum == LONG_LAST_CLUSTER) + printf("fatal error: trying to do next_cluster(dpbp, EOC)!\n"); + if (ClusterNum == 0) + printf("fatal error: trying to do next_cluster(dpbp, 0)!\n"); #endif /* Get the block that this cluster is in */ @@ -332,20 +337,22 @@ CLUSTER next_cluster(struct dpb FAR *dpbp, CLUSTER ClusterNum) if (ISFAT12(dpbp)) { union { - UBYTE bytes[2]; - UCOUNT word; + UBYTE bytes[2]; + UCOUNT word; } clusterbuff; - + UCOUNT idx; /* form an index so that we can read the block as a */ /* byte array */ - idx = (UCOUNT)(((ClusterNum << 1) + ClusterNum) >> 1) % dpbp->dpb_secsize; + idx = + (UCOUNT) (((ClusterNum << 1) + + ClusterNum) >> 1) % dpbp->dpb_secsize; clusterbuff.bytes[0] = bp->b_buffer[idx]; - clusterbuff.bytes[1] = bp->b_buffer[idx+1]; /* next byte, will be overwritten, - if not valid */ + clusterbuff.bytes[1] = bp->b_buffer[idx + 1]; /* next byte, will be overwritten, + if not valid */ /* Test to see if the cluster straddles the block. If it */ /* does, get the next block and use both to form the */ @@ -353,7 +360,7 @@ CLUSTER next_cluster(struct dpb FAR *dpbp, CLUSTER ClusterNum) /* block. */ if (idx >= dpbp->dpb_secsize - 1) { - bp = getFATblock(ClusterNum +1, dpbp); + bp = getFATblock(ClusterNum + 1, dpbp); if (bp == 0) return LONG_BAD; @@ -363,19 +370,20 @@ CLUSTER next_cluster(struct dpb FAR *dpbp, CLUSTER ClusterNum) /* Now to unpack the contents of the FAT entry. Odd and */ /* even bytes are packed differently. */ - -#ifndef I86 /* the latter assumes byte ordering */ + +#ifndef I86 /* the latter assumes byte ordering */ if (ClusterNum & 0x01) - idx = ((clusterbuff.byte[0] & 0xf0) >> 4) | (clusterbuff.byte[1] << 4); + idx = + ((clusterbuff.byte[0] & 0xf0) >> 4) | (clusterbuff.byte[1] << 4); else idx = clusterbuff.byte[0] | ((clusterbuff.byte[0] & 0x0f) << 8); #else - + if (ClusterNum & 0x01) idx = (unsigned short)clusterbuff.word >> 4; else - idx = clusterbuff.word & 0x0fff; -#endif + idx = clusterbuff.word & 0x0fff; +#endif if (idx >= MASK12) return LONG_LAST_CLUSTER; @@ -384,7 +392,7 @@ CLUSTER next_cluster(struct dpb FAR *dpbp, CLUSTER ClusterNum) return idx; } else if (ISFAT16(dpbp)) - { + { UWORD res; #ifndef I86 @@ -395,16 +403,22 @@ CLUSTER next_cluster(struct dpb FAR *dpbp, CLUSTER ClusterNum) idx = (ClusterNum * SIZEOF_CLST16) % dpbp->dpb_secsize; /* Get the cluster number, */ - + fgetword((VOID FAR *) & (bp->b_buffer[idx]), (WORD FAR *) & res); #else /* this saves 2 WORDS of stack :-) */ - - res = *(UWORD FAR *)&(bp->b_buffer[(UCOUNT)((ClusterNum * SIZEOF_CLST16) % dpbp->dpb_secsize)]); -#endif - if (res >= MASK16) return LONG_LAST_CLUSTER; - if (res == BAD16) return LONG_BAD; + + res = + *(UWORD FAR *) & (bp-> + b_buffer[(UCOUNT) + ((ClusterNum * SIZEOF_CLST16) % + dpbp->dpb_secsize)]); +#endif + if (res >= MASK16) + return LONG_LAST_CLUSTER; + if (res == BAD16) + return LONG_BAD; return res; } @@ -413,10 +427,15 @@ CLUSTER next_cluster(struct dpb FAR *dpbp, CLUSTER ClusterNum) { UDWORD res; - res = *(UDWORD FAR *)&(bp->b_buffer[(UCOUNT)((ClusterNum * SIZEOF_CLST32) % dpbp->dpb_secsize)]); - if (res > LONG_BAD) return LONG_LAST_CLUSTER; + res = + *(UDWORD FAR *) & (bp-> + b_buffer[(UCOUNT) + ((ClusterNum * SIZEOF_CLST32) % + dpbp->dpb_secsize)]); + if (res > LONG_BAD) + return LONG_LAST_CLUSTER; - return res; + return res; } #endif return LONG_LAST_CLUSTER; @@ -477,6 +496,3 @@ CLUSTER next_cluster(struct dpb FAR *dpbp, CLUSTER ClusterNum) * Rev 1.0 02 Jul 1995 8:04:56 patv * Initial revision. */ - - - diff --git a/kernel/fcbfns.c b/kernel/fcbfns.c index ff8969d2..2988b462 100644 --- a/kernel/fcbfns.c +++ b/kernel/fcbfns.c @@ -30,7 +30,8 @@ #include "globals.h" #ifdef VERSION_STRINGS -static BYTE *RcsId = "$Id$"; +static BYTE *RcsId = + "$Id$"; #endif #define FCB_SUCCESS 0 @@ -41,7 +42,8 @@ static BYTE *RcsId = "$Id$"; #ifdef PROTO fcb FAR *ExtFcbToFcb(xfcb FAR * lpExtFcb); -fcb FAR *CommonFcbInit(xfcb FAR * lpExtFcb, BYTE * pszBuffer, COUNT * pCurDrive); +fcb FAR *CommonFcbInit(xfcb FAR * lpExtFcb, BYTE * pszBuffer, + COUNT * pCurDrive); void FcbNameInit(fcb FAR * lpFcb, BYTE * pszBuffer, COUNT * pCurDrive); VOID FcbNextRecord(fcb FAR * lpFcb); BOOL FcbCalcRec(xfcb FAR * lpXfcb); @@ -53,9 +55,8 @@ VOID FcbNextRecord(); BOOL FcbCalcRec(); #endif -#define TestCmnSeps(lpFileName) (strchr(":<|>+=,", *lpFileName) != NULL) -#define TestFieldSeps(lpFileName) (*(lpFileName) <= ' ' || strchr("/\"[]<>|.", *lpFileName) != NULL) - +#define TestCmnSeps(lpFileName) (strchr(":<|>+=,", *lpFileName) != NULL) +#define TestFieldSeps(lpFileName) (*(lpFileName) <= ' ' || strchr("/\"[]<>|.", *lpFileName) != NULL) static dmatch Dmatch; @@ -63,12 +64,12 @@ VOID FatGetDrvData(UCOUNT drive, UCOUNT FAR * spc, UCOUNT FAR * bps, UCOUNT FAR * nc, BYTE FAR ** mdp) { UCOUNT navc; - + /* get the data available from dpb */ - *nc = 0xffff; /* pass 0xffff to skip free count */ - if (DosGetFree((UBYTE)drive, spc, &navc, bps, nc)) - /* Point to the media desctriptor for this drive */ - *mdp = (BYTE FAR*)&(CDSp->cds_table[drive].cdsDpb->dpb_mdb); + *nc = 0xffff; /* pass 0xffff to skip free count */ + if (DosGetFree((UBYTE) drive, spc, &navc, bps, nc)) + /* Point to the media desctriptor for this drive */ + *mdp = (BYTE FAR *) & (CDSp->cds_table[drive].cdsDpb->dpb_mdb); } #define PARSE_SEP_STOP 0x01 @@ -84,7 +85,7 @@ VOID FatGetDrvData(UCOUNT drive, UCOUNT FAR * spc, UCOUNT FAR * bps, WORD FcbParseFname(int wTestMode, BYTE FAR ** lpFileName, fcb FAR * lpFcb) { COUNT nIndex; - WORD wRetCodeName,wRetCodeExt; + WORD wRetCodeName, wRetCodeExt; /* pjv -- ExtFcbToFcb? */ /* Start out with some simple stuff first. Check if we are */ @@ -131,24 +132,28 @@ WORD FcbParseFname(int wTestMode, BYTE FAR ** lpFileName, fcb FAR * lpFcb) /* special cases: '.' and '..' */ if (**lpFileName == '.') { - lpFcb->fcb_fname[0]='.'; + lpFcb->fcb_fname[0] = '.'; + ++*lpFileName; + if (**lpFileName == '.') + { + lpFcb->fcb_fname[1] = '.'; ++*lpFileName; - if (**lpFileName == '.') - { - lpFcb->fcb_fname[1]='.'; - ++*lpFileName; - } - return PARSE_RET_NOWILD; + } + return PARSE_RET_NOWILD; } - + /* Now to format the file name into the string */ - *lpFileName = GetNameField(*lpFileName, (BYTE FAR *) lpFcb->fcb_fname, FNAME_SIZE, (BOOL *) & wRetCodeName); + *lpFileName = + GetNameField(*lpFileName, (BYTE FAR *) lpFcb->fcb_fname, FNAME_SIZE, + (BOOL *) & wRetCodeName); /* Do we have an extension? If do, format it else return */ if (**lpFileName == '.') - *lpFileName = GetNameField(++*lpFileName, (BYTE FAR *) lpFcb->fcb_fext, FEXT_SIZE, (BOOL *) & wRetCodeExt); + *lpFileName = + GetNameField(++*lpFileName, (BYTE FAR *) lpFcb->fcb_fext, + FEXT_SIZE, (BOOL *) & wRetCodeExt); - return (wRetCodeName|wRetCodeExt) ? PARSE_RET_WILD : PARSE_RET_NOWILD; + return (wRetCodeName | wRetCodeExt) ? PARSE_RET_WILD : PARSE_RET_NOWILD; } BYTE FAR *ParseSkipWh(BYTE FAR * lpFileName) @@ -158,24 +163,22 @@ BYTE FAR *ParseSkipWh(BYTE FAR * lpFileName) return lpFileName; } -#if 0 /* defined above */ +#if 0 /* defined above */ BOOL TestCmnSeps(BYTE FAR * lpFileName) { - BYTE *pszTest, - *pszCmnSeps = ":<|>+=,"; + BYTE *pszTest, *pszCmnSeps = ":<|>+=,"; for (pszTest = pszCmnSeps; *pszTest != '\0'; ++pszTest) if (*lpFileName == *pszTest) return TRUE; return FALSE; } -#endif +#endif #if 0 BOOL TestFieldSeps(BYTE FAR * lpFileName) { - BYTE *pszTest, - *pszCmnSeps = "/\"[]<>|."; + BYTE *pszTest, *pszCmnSeps = "/\"[]<>|."; /* Another non-portable construct */ if (*lpFileName <= ' ') @@ -188,7 +191,6 @@ BOOL TestFieldSeps(BYTE FAR * lpFileName) } #endif - BYTE FAR *GetNameField(BYTE FAR * lpFileName, BYTE FAR * lpDestField, COUNT nFieldSize, BOOL * pbWildCard) { @@ -196,7 +198,8 @@ BYTE FAR *GetNameField(BYTE FAR * lpFileName, BYTE FAR * lpDestField, BYTE cFill = ' '; *pbWildCard = FALSE; - while (*lpFileName != '\0' && !TestFieldSeps(lpFileName) && nIndex < nFieldSize) + while (*lpFileName != '\0' && !TestFieldSeps(lpFileName) + && nIndex < nFieldSize) { if (*lpFileName == ' ') break; @@ -231,8 +234,8 @@ static VOID FcbNextRecord(fcb FAR * lpFcb) static ULONG FcbRec(VOID) { UWORD tmp = 128; - - return ((ULONG)lpFcb->fcb_cublock * tmp) + lpFcb->fcb_curec; + + return ((ULONG) lpFcb->fcb_cublock * tmp) + lpFcb->fcb_curec; } BOOL FcbRead(xfcb FAR * lpXfcb, COUNT * nErrorCode) @@ -395,7 +398,8 @@ BOOL FcbCalcRec(xfcb FAR * lpXfcb) return TRUE; } -BOOL FcbRandomBlockRead(xfcb FAR * lpXfcb, COUNT nRecords, COUNT * nErrorCode) +BOOL FcbRandomBlockRead(xfcb FAR * lpXfcb, COUNT nRecords, + COUNT * nErrorCode) { FcbCalcRec(lpXfcb); @@ -412,7 +416,8 @@ BOOL FcbRandomBlockRead(xfcb FAR * lpXfcb, COUNT nRecords, COUNT * nErrorCode) return TRUE; } -BOOL FcbRandomBlockWrite(xfcb FAR * lpXfcb, COUNT nRecords, COUNT * nErrorCode) +BOOL FcbRandomBlockWrite(xfcb FAR * lpXfcb, COUNT nRecords, + COUNT * nErrorCode) { FcbCalcRec(lpXfcb); @@ -430,7 +435,7 @@ BOOL FcbRandomBlockWrite(xfcb FAR * lpXfcb, COUNT nRecords, COUNT * nErrorCode) } BOOL FcbRandomIO(xfcb FAR * lpXfcb, COUNT * nErrorCode, - BOOL (*FcbFunc)(xfcb FAR *, COUNT *)) + BOOL(*FcbFunc) (xfcb FAR *, COUNT *)) { UWORD uwCurrentBlock; UBYTE ucCurrentRecord; @@ -443,7 +448,7 @@ BOOL FcbRandomIO(xfcb FAR * lpXfcb, COUNT * nErrorCode, uwCurrentBlock = lpFcb->fcb_cublock; ucCurrentRecord = lpFcb->fcb_curec; - (*FcbFunc)(lpXfcb, nErrorCode); + (*FcbFunc) (lpXfcb, nErrorCode); lpFcb->fcb_cublock = uwCurrentBlock; lpFcb->fcb_curec = ucCurrentRecord; @@ -466,7 +471,7 @@ BOOL FcbCreate(xfcb FAR * lpXfcb) sft_idx = DosCreatSft(PriPathName, 0); if (sft_idx < 0) - return FALSE; + return FALSE; sftp = idx_to_sft(sft_idx); sftp->sft_mode |= SFT_MFCB; @@ -476,7 +481,8 @@ BOOL FcbCreate(xfcb FAR * lpXfcb) lpFcb->fcb_sftno = sft_idx; lpFcb->fcb_curec = 0; lpFcb->fcb_recsiz = (dhp ? 0 : 128); - if (!dhp) lpFcb->fcb_drive = FcbDrive; + if (!dhp) + lpFcb->fcb_drive = FcbDrive; lpFcb->fcb_fsize = 0; lpFcb->fcb_date = dos_getdate(); lpFcb->fcb_time = dos_gettime(); @@ -509,9 +515,9 @@ STATIC fcb FAR *CommonFcbInit(xfcb FAR * lpExtFcb, BYTE * pszBuffer, void FcbNameInit(fcb FAR * lpFcb, BYTE * szBuffer, COUNT * pCurDrive) { - BYTE loc_szBuffer[2+FNAME_SIZE+1+FEXT_SIZE+1]; /* 'A:' + '.' + '\0' */ + BYTE loc_szBuffer[2 + FNAME_SIZE + 1 + FEXT_SIZE + 1]; /* 'A:' + '.' + '\0' */ BYTE *pszBuffer = loc_szBuffer; - + /* Build a traditional DOS file name */ if (lpFcb->fcb_drive != 0) { @@ -540,30 +546,30 @@ BOOL FcbOpen(xfcb FAR * lpXfcb) sft_idx = DosOpenSft(PriPathName, O_RDWR); if (sft_idx < 0) - return FALSE; - + return FALSE; + sftp = idx_to_sft(sft_idx); sftp->sft_mode |= SFT_MFCB; - + /* check for a device */ lpFcb->fcb_curec = 0; lpFcb->fcb_rndm = 0; lpFcb->fcb_sftno = sft_idx; dhp = IsDevice(PriPathName); - if (dhp ) + if (dhp) { - lpFcb->fcb_recsiz = 0; - lpFcb->fcb_fsize = 0; - lpFcb->fcb_date = dos_getdate(); - lpFcb->fcb_time = dos_gettime(); + lpFcb->fcb_recsiz = 0; + lpFcb->fcb_fsize = 0; + lpFcb->fcb_date = dos_getdate(); + lpFcb->fcb_time = dos_gettime(); } else { - lpFcb->fcb_drive = FcbDrive; - lpFcb->fcb_recsiz = 128; - lpFcb->fcb_fsize = sftp->sft_size; - lpFcb->fcb_date = sftp->sft_date; - lpFcb->fcb_time = sftp->sft_time; + lpFcb->fcb_drive = FcbDrive; + lpFcb->fcb_recsiz = 128; + lpFcb->fcb_fsize = sftp->sft_size; + lpFcb->fcb_date = sftp->sft_date; + lpFcb->fcb_time = sftp->sft_time; } return TRUE; } @@ -586,7 +592,9 @@ BOOL FcbDelete(xfcb FAR * lpXfcb) dmatch Dmatch; dta = (BYTE FAR *) & Dmatch; - if (DosFindFirst(D_ALL, SecPathName[1] == ':' ? &SecPathName[2] : SecPathName) != SUCCESS) + if (DosFindFirst + (D_ALL, + SecPathName[1] == ':' ? &SecPathName[2] : SecPathName) != SUCCESS) { dta = lpOldDta; return FALSE; @@ -625,7 +633,9 @@ BOOL FcbRename(xfcb FAR * lpXfcb) dmatch Dmatch; dta = (BYTE FAR *) & Dmatch; - if (DosFindFirst(D_ALL, SecPathName[1] == ':' ? &SecPathName[2] : SecPathName) != SUCCESS) + if (DosFindFirst + (D_ALL, + SecPathName[1] == ':' ? &SecPathName[2] : SecPathName) != SUCCESS) { dta = lpOldDta; return FALSE; @@ -634,8 +644,7 @@ BOOL FcbRename(xfcb FAR * lpXfcb) do { fcb LocalFcb; - BYTE *pToName, - *pszFrom; + BYTE *pToName, *pszFrom; BYTE FAR *pFromPattern; COUNT nIndex; @@ -718,7 +727,7 @@ BOOL FcbClose(xfcb FAR * lpXfcb) lpFcb = ExtFcbToFcb(lpXfcb); /* An already closed FCB can be closed again without error */ - if (lpFcb->fcb_sftno == (BYTE)0xff) + if (lpFcb->fcb_sftno == (BYTE) 0xff) return TRUE; /* Get the SFT block that contains the SFT */ @@ -730,8 +739,9 @@ BOOL FcbClose(xfcb FAR * lpXfcb) if (!(s->sft_flags & SFT_FSHARED)) dos_setfsize(s->sft_status, lpFcb->fcb_fsize); DosSetFtimeSft(lpFcb->fcb_sftno, lpFcb->fcb_date, lpFcb->fcb_time); - if (DosCloseSft(lpFcb->fcb_sftno) == SUCCESS) { - lpFcb->fcb_sftno = (BYTE)0xff; + if (DosCloseSft(lpFcb->fcb_sftno) == SUCCESS) + { + lpFcb->fcb_sftno = (BYTE) 0xff; return TRUE; } return FALSE; @@ -743,7 +753,7 @@ VOID FcbCloseAll() COUNT idx = 0; sft FAR *sftp; - for (idx = 0; (sftp = idx_to_sft(idx)) != (sft FAR *) -1; idx++) + for (idx = 0; (sftp = idx_to_sft(idx)) != (sft FAR *) - 1; idx++) if ((sftp->sft_mode & SFT_MFCB) && sftp->sft_psp == cu_psp) DosCloseSft(idx); } @@ -764,8 +774,8 @@ BOOL FcbFindFirst(xfcb FAR * lpXfcb) if (lpXfcb->xfcb_flag == 0xff) { wAttr = lpXfcb->xfcb_attrib; - fmemcpy(lpDir, lpXfcb, 7); - lpDir += 7; + fmemcpy(lpDir, lpXfcb, 7); + lpDir += 7; } else wAttr = D_ALL; @@ -776,10 +786,10 @@ BOOL FcbFindFirst(xfcb FAR * lpXfcb) return FALSE; } - *lpDir++ = FcbDrive; + *lpDir++ = FcbDrive; fmemcpy(lpDir, &SearchDir, sizeof(struct dirent)); - lpFcb->fcb_dirclst = (UWORD)Dmatch.dm_dircluster; + lpFcb->fcb_dirclst = (UWORD) Dmatch.dm_dircluster; lpFcb->fcb_strtclst = Dmatch.dm_entry; /* @@ -787,7 +797,7 @@ BOOL FcbFindFirst(xfcb FAR * lpXfcb) The First byte is the current directory count and the second seems to be the attribute byte. */ - lpFcb->fcb_sftno = Dmatch.dm_drive; /* MSD seems to save this @ fcb_date.*/ + lpFcb->fcb_sftno = Dmatch.dm_drive; /* MSD seems to save this @ fcb_date. */ #if 0 lpFcb->fcb_cublock = Dmatch.dm_entry; lpFcb->fcb_cublock *= 0x100; @@ -838,10 +848,10 @@ BOOL FcbFindNext(xfcb FAR * lpXfcb) return FALSE; } - *lpDir++ = FcbDrive; + *lpDir++ = FcbDrive; fmemcpy((struct dirent FAR *)lpDir, &SearchDir, sizeof(struct dirent)); - lpFcb->fcb_dirclst = (UWORD)Dmatch.dm_dircluster; + lpFcb->fcb_dirclst = (UWORD) Dmatch.dm_dircluster; lpFcb->fcb_strtclst = Dmatch.dm_entry; lpFcb->fcb_sftno = Dmatch.dm_drive; @@ -917,5 +927,3 @@ BOOL FcbFindNext(xfcb FAR * lpXfcb) * Rev 1.0 02 Jul 1995 8:06:06 patv * Initial revision. */ - - diff --git a/kernel/globals.h b/kernel/globals.h index 6baac315..28291068 100644 --- a/kernel/globals.h +++ b/kernel/globals.h @@ -29,11 +29,11 @@ #ifdef VERSION_STRINGS #ifdef MAIN -static BYTE *Globals_hRcsId = "$Id$"; +static BYTE *Globals_hRcsId = + "$Id$"; #endif #endif - #include "device.h" #include "mcb.h" #include "pcb.h" @@ -86,7 +86,7 @@ static BYTE *Globals_hRcsId = "$Id$"; /* */ /* Defaults and limits - System wide */ #define PARSE_MAX MAX_CDSPATH /* maximum # of bytes in path */ -#define NAMEMAX PARSE_MAX /* Maximum path for CDS */ +#define NAMEMAX PARSE_MAX /* Maximum path for CDS */ /* internal error from failure or aborted operation */ #define ERROR -1 @@ -127,8 +127,6 @@ static BYTE *Globals_hRcsId = "$Id$"; #define DSKWRITEINT26 3 #define DSKREADINT25 4 - - /* FAT cluster special flags */ #define FREE 0x000 @@ -162,86 +160,79 @@ FAR clk_dev, /* Clock device driver */ FAR prn_dev, /* Generic printer device driver */ FAR aux_dev, /* Generic aux device driver */ FAR blk_dev; /* Block device (Disk) driver */ -extern UWORD - ram_top; /* How much ram in Kbytes */ -extern COUNT * - error_tos, /* error stack */ +extern UWORD ram_top; /* How much ram in Kbytes */ +extern COUNT *error_tos, /* error stack */ disk_api_tos, /* API handler stack - disk fns */ char_api_tos; /* API handler stack - char fns */ -extern BYTE - FAR _InitTextStart; /* first available byte of ram */ -extern BYTE - FAR _HMATextAvailable, /* first byte of available CODE area */ +extern BYTE FAR _InitTextStart; /* first available byte of ram */ +extern BYTE FAR _HMATextAvailable, /* first byte of available CODE area */ FAR _HMATextStart[], /* first byte of HMAable CODE area */ FAR _HMATextEnd[]; /* and the last byte of it */ -extern - BYTE DosLoadedInHMA; /* if InitHMA has moved DOS up */ - +extern +BYTE DosLoadedInHMA; /* if InitHMA has moved DOS up */ + extern struct ClockRecord ClkRecord; /* */ /* Global variables */ /* */ -GLOBAL BYTE - os_major, /* major version number */ +GLOBAL BYTE os_major, /* major version number */ os_minor, /* minor version number */ - rev_number /* minor version number */ #ifdef MAIN -= REV_NUMBER, + = REV_NUMBER, #else , #endif - version_flags /* minor version number */ #ifdef MAIN -= 0; + = 0; #else - ; + ; #endif #ifdef DEBUG GLOBAL WORD bDumpRegs #ifdef MAIN -= FALSE; + = FALSE; #else ; #endif GLOBAL WORD bDumpRdWrParms #ifdef MAIN -= FALSE; + = FALSE; #else ; #endif #endif -#if 0 /* defined in MAIN.C now to save low memory */ +#if 0 /* defined in MAIN.C now to save low memory */ -GLOBAL BYTE copyright[] = +GLOBAL BYTE copyright[] = "(C) Copyright 1995-2001 Pasquale J. Villani and The FreeDOS Project.\n" "All Rights Reserved. This is free software and comes with ABSOLUTELY NO\n" "WARRANTY; you can redistribute it and/or modify it under the terms of the\n" "GNU General Public License as published by the Free Software Foundation;\n" "either version 2, or (at your option) any later version.\n"; - + #endif GLOBAL BYTE os_release[] #ifdef MAIN #if 0 -= "DOS-C version %d.%d Beta %d [FreeDOS Release] (Build %d).\n" + = "DOS-C version %d.%d Beta %d [FreeDOS Release] (Build %d).\n" #endif -= "FreeDOS kernel version " KERNEL_VERSION_STRING \ - " (Build " KERNEL_BUILD_STRING ") [" __DATE__ " " __TIME__ "]\n" + = "FreeDOS kernel version " KERNEL_VERSION_STRING + " (Build " KERNEL_BUILD_STRING ") [" __DATE__ " " __TIME__ "]\n" #if 0 -"For technical information and description of the DOS-C operating system\n\ + "For technical information and description of the DOS-C operating system\n\ consult \"FreeDOS Kernel\" by Pat Villani, published by Miller\n\ Freeman Publishing, Lawrence KS, USA (ISBN 0-87930-436-7).\n\ \n" #endif #endif -; + ; /* Globally referenced variables - WARNING: ORDER IS DEFINED IN */ /* KERNAL.ASM AND MUST NOT BE CHANGED. DO NOT CHANGE ORDER BECAUSE THEY */ @@ -251,109 +242,81 @@ Freeman Publishing, Lawrence KS, USA (ISBN 0-87930-436-7).\n\ extern UWORD NetBios; extern BYTE *net_name; extern BYTE net_set_count; -extern BYTE NetDelay, - NetRetry; - -extern UWORD - first_mcb, /* Start of user memory */ - UMB_top, - umb_start, - uppermem_root; /* Start of umb chain ? */ +extern BYTE NetDelay, NetRetry; + +extern UWORD first_mcb, /* Start of user memory */ + UMB_top, umb_start, uppermem_root; /* Start of umb chain ? */ extern struct dpb FAR *DPBp; /* First drive Parameter Block */ -extern sfttbl - FAR * sfthead; /* System File Table head */ +extern sfttbl FAR * sfthead; /* System File Table head */ extern struct dhdr FAR *clock, /* CLOCK$ device */ FAR * syscon; /* console device */ -extern WORD - maxbksize; /* Number of Drives in system */ +extern WORD maxbksize; /* Number of Drives in system */ extern struct buffer FAR *firstbuf; /* head of buffers linked list */ -extern cdstbl - FAR * CDSp; /* Current Directory Structure */ +extern cdstbl FAR * CDSp; /* Current Directory Structure */ extern struct cds FAR *current_ldt; extern LONG current_filepos; /* current file position */ -extern sfttbl - FAR * FCBp; /* FCB table pointer */ -extern WORD - nprotfcb; /* number of protected fcbs */ -extern UBYTE - nblkdev, /* number of block devices */ +extern sfttbl FAR * FCBp; /* FCB table pointer */ +extern WORD nprotfcb; /* number of protected fcbs */ +extern UBYTE nblkdev, /* number of block devices */ lastdrive, /* value of last drive */ uppermem_link, /* UMB Link flag */ - PrinterEcho; /* Printer Echo Flag */ + PrinterEcho; /* Printer Echo Flag */ + +extern UWORD LoL_nbuffers; /* Number of buffers */ -extern UWORD - LoL_nbuffers; /* Number of buffers */ - extern struct dhdr nul_dev; -extern UBYTE - mem_access_mode; /* memory allocation scheme */ -extern BYTE - ErrorMode, /* Critical error flag */ +extern UBYTE mem_access_mode; /* memory allocation scheme */ +extern BYTE ErrorMode, /* Critical error flag */ InDOS, /* In DOS critical section */ OpenMode, /* File Open Attributes */ SAttr, /* Attrib Mask for Dir Search */ - dosidle_flag, - Server_Call, - CritErrLocus, - CritErrAction, - CritErrClass, - VgaSet, - njoined; /* number of joined devices */ + dosidle_flag, Server_Call, CritErrLocus, CritErrAction, CritErrClass, VgaSet, njoined; /* number of joined devices */ extern UWORD Int21AX; extern COUNT CritErrCode; -extern BYTE FAR * CritErrDev; +extern BYTE FAR *CritErrDev; extern struct dirent SearchDir; -extern struct -{ +extern struct { COUNT nDrive; BYTE szName[FNAME_SIZE + 1]; BYTE szExt[FEXT_SIZE + 1]; -} -FcbSearchBuffer; +} FcbSearchBuffer; -extern struct /* Path name parsing buffer */ +extern struct /* Path name parsing buffer */ { BYTE _PriPathName[128]; -} -_PriPathBuffer; +} _PriPathBuffer; -extern struct -{ +extern struct { BYTE _fname[FNAME_SIZE]; - BYTE _fext[FEXT_SIZE+1]; /* space for 0 */ -} -szNames; + BYTE _fext[FEXT_SIZE + 1]; /* space for 0 */ +} szNames; #define PriPathName _PriPathBuffer._PriPathName #define szDirName TempCDS.cdsCurrentPath #define szFileName szNames._fname #define szFileExt szNames._fext -extern struct /* Alternate path name parsing buffer */ +extern struct /* Alternate path name parsing buffer */ { BYTE _SecPathName[128]; -} -_SecPathBuffer; +} _SecPathBuffer; #define SecPathName _SecPathBuffer._SecPathName -extern UWORD - wAttr; +extern UWORD wAttr; -extern BYTE - default_drive; /* default drive for dos */ +extern BYTE default_drive; /* default drive for dos */ -extern BYTE - TempBuffer[], /* Temporary general purpose buffer */ +extern BYTE TempBuffer[], /* Temporary general purpose buffer */ FAR internal_data[], /* sda areas */ FAR swap_always[], /* " " */ FAR swap_indos[], /* " " */ @@ -361,57 +324,46 @@ extern BYTE break_flg, /* true if break was detected */ break_ena, /* break enabled flag */ FAR * dta; /* Disk transfer area (kludge) */ -extern seg - cu_psp; /* current psp segment */ -extern iregs - FAR * user_r; /* User registers for int 21h call */ +extern seg cu_psp; /* current psp segment */ +extern iregs FAR * user_r; /* User registers for int 21h call */ extern struct dirent /* Temporary directory entry */ DirEntBuffer; extern request /* I/O Request packets */ - CharReqHdr, - IoReqHdr, - MediaReqHdr; + CharReqHdr, IoReqHdr, MediaReqHdr; -extern fcb - FAR * lpFcb; /* Pointer to users fcb */ +extern fcb FAR * lpFcb; /* Pointer to users fcb */ -extern sft - FAR * lpCurSft; +extern sft FAR * lpCurSft; -extern BYTE - verify_ena, /* verify enabled flag */ +extern BYTE verify_ena, /* verify enabled flag */ switchar, /* switch char */ return_mode, /* Process termination rets */ return_code; /* " " " */ -extern BYTE - BootDrive, /* Drive we came up from */ +extern BYTE BootDrive, /* Drive we came up from */ scr_pos; /* screen position for bs, ht, etc */ /*extern WORD - NumFloppies; !!*/ /* How many floppies we have */ + NumFloppies; !!*//* How many floppies we have */ -extern keyboard - kb_buf; +extern keyboard kb_buf; extern struct cds TempCDS; /* start of uncontrolled variables */ -GLOBAL seg - RootPsp; /* Root process -- do not abort */ +GLOBAL seg RootPsp; /* Root process -- do not abort */ /* don't know what it should do, but its no longer in use TE GLOBAL struct f_node *pDirFileNode; -*/ +*/ #ifdef DEBUG GLOBAL iregs error_regs; /* registers for dump */ -GLOBAL WORD - dump_regs; /* dump registers of bad call */ +GLOBAL WORD dump_regs; /* dump registers of bad call */ #endif @@ -421,7 +373,7 @@ GLOBAL UWORD f_nodes_cnt; /* number of allocated f_nodes */ /*!! GLOBAL iregs FAR * ustackp, /* user stack */ -/*!! FAR * kstackp; */ /* kernel stack */ +/*!! FAR * kstackp; *//* kernel stack */ /* */ /* Function prototypes - automatically generated */ @@ -430,21 +382,18 @@ GLOBAL UWORD f_nodes_cnt; /* number of allocated f_nodes */ /* Process related functions - not under automatic generation. */ /* Typically, these are in ".asm" files. */ -VOID -FAR ASMCFUNC cpm_entry(VOID) +VOID FAR ASMCFUNC cpm_entry(VOID) /*INRPT FAR handle_break(VOID) */ ; -VOID -enable(VOID), -disable(VOID); +VOID enable(VOID), disable(VOID); COUNT -ASMCFUNC CriticalError( - COUNT nFlag, COUNT nDrive, COUNT nError, struct dhdr FAR * lpDevice); + ASMCFUNC CriticalError(COUNT nFlag, COUNT nDrive, COUNT nError, + struct dhdr FAR * lpDevice); #ifdef PROTO VOID FAR ASMCFUNC CharMapSrvc(VOID); VOID FAR ASMCFUNC set_stack(VOID); VOID FAR ASMCFUNC restore_stack(VOID); -WORD ASMCFUNC execrh(request FAR *, struct dhdr FAR *); +WORD ASMCFUNC execrh(request FAR *, struct dhdr FAR *); VOID exit(COUNT); /*VOID INRPT FAR handle_break(VOID); */ VOID ASMCFUNC tmark(VOID); @@ -515,14 +464,13 @@ VOID fputbyte(); /*#define is_leap_year(y) ((y) & 3 ? 0 : (y) % 100 ? 1 : (y) % 400 ? 0 : 1) */ /* ^Break handling */ -void ASMCFUNC spawn_int23(void); /* procsupt.asm */ +void ASMCFUNC spawn_int23(void); /* procsupt.asm */ int control_break(void); /* break.c */ void handle_break(void); /* break.c */ - GLOBAL BYTE ReturnAnyDosVersionExpected; -GLOBAL COUNT UnusedRetVal; /* put unused errors here (to save stack space) */ +GLOBAL COUNT UnusedRetVal; /* put unused errors here (to save stack space) */ /* * Log: globals.h,v diff --git a/kernel/init-dat.h b/kernel/init-dat.h index ea6e79d3..e51d1df5 100644 --- a/kernel/init-dat.h +++ b/kernel/init-dat.h @@ -1,31 +1,27 @@ /* Included by initialisation functions */ #if _MSC_VER != 0 - extern __segment DosDataSeg;/* serves for all references to the DOS DATA segment - necessary for MSC+our funny linking model - */ +extern __segment DosDataSeg; /* serves for all references to the DOS DATA segment + necessary for MSC+our funny linking model + */ - extern __segment DosTextSeg; +extern __segment DosTextSeg; - #define DOSFAR __based(DosDataSeg) - #define DOSTEXTFAR __based(DosTextSeg) +#define DOSFAR __based(DosDataSeg) +#define DOSTEXTFAR __based(DosTextSeg) #elif defined(__TURBOC__) - #define DOSFAR FAR - #define DOSTEXTFAR FAR +#define DOSFAR FAR +#define DOSTEXTFAR FAR #elif defined(__WATCOMC__) - #define DOSFAR FAR - #define DOSTEXTFAR FAR +#define DOSFAR FAR +#define DOSTEXTFAR FAR #else - #pragma error("unknown compiler - please adjust") - this should simply not compile !! -#endif - - - -extern BYTE DOSFAR version_flags; /* minor version number */ - +#pragma error("unknown compiler - please adjust") +this should simply not compile ! ! +#endif +extern BYTE DOSFAR version_flags; /* minor version number */ diff --git a/kernel/init-mod.h b/kernel/init-mod.h index c1c1e29c..de6e7cf0 100644 --- a/kernel/init-mod.h +++ b/kernel/init-mod.h @@ -22,8 +22,7 @@ #include "buffer.h" #include "KConfig.h" -extern struct _KernelConfig InitKernelConfig; - +extern struct _KernelConfig InitKernelConfig; /* * The null macro `INIT' can be used to allow the reader to differentiate @@ -58,7 +57,7 @@ COUNT ASMCFUNC strlen(REG BYTE * s); /*inithma.c*/ extern BYTE DosLoadedInHMA; -extern fmemcmp(BYTE far *s1, BYTE FAR *s2, unsigned len); +extern fmemcmp(BYTE far * s1, BYTE FAR * s2, unsigned len); #define setvec(n, isr) (void)(*(VOID (FAR * FAR *)())(MK_FP(0,4 * (n))) = (isr)) @@ -75,46 +74,43 @@ extern fmemcmp(BYTE far *s1, BYTE FAR *s2, unsigned len); #define MAX_HARD_DRIVE 8 #define NDEV 26 /* up to Z: */ - - /* Start of configuration variables */ -struct config -{ - BYTE cfgBuffers; - /* number of buffers in the system */ - UBYTE cfgFiles; - /* number of available files */ - UBYTE cfgFcbs; - /* number of available FCBs */ - UBYTE cfgProtFcbs; - /* number of protected FCBs */ - BYTE cfgInit[NAMEMAX]; - /* init of command.com */ - BYTE cfgInitTail[NAMEMAX]; - /* command.com's tail */ - UBYTE cfgLastdrive; - /* last drive */ - BYTE cfgStacks; - /* number of stacks */ - UWORD cfgStackSize; - /* stacks size for each stack */ - /* COUNTRY= - In Pass #1 these information is collected and in PostConfig() - the NLS package is loaded into memory. - -- 2000/06/11 ska*/ - WORD cfgCSYS_cntry; - /* country ID to be loaded */ - WORD cfgCSYS_cp; - /* requested codepage; NLS_DEFAULT if default */ - BYTE cfgCSYS_fnam[NAMEMAX]; - /* filename of COUNTRY= */ - WORD cfgCSYS_memory; - /* number of bytes required for the NLS pkg; - 0 if none */ - VOID FAR *cfgCSYS_data; - /* where the loaded data is for PostConfig() */ - UBYTE cfgP_0_startmode; - /* load command.com high or not */ +struct config { + BYTE cfgBuffers; + /* number of buffers in the system */ + UBYTE cfgFiles; + /* number of available files */ + UBYTE cfgFcbs; + /* number of available FCBs */ + UBYTE cfgProtFcbs; + /* number of protected FCBs */ + BYTE cfgInit[NAMEMAX]; + /* init of command.com */ + BYTE cfgInitTail[NAMEMAX]; + /* command.com's tail */ + UBYTE cfgLastdrive; + /* last drive */ + BYTE cfgStacks; + /* number of stacks */ + UWORD cfgStackSize; + /* stacks size for each stack */ + /* COUNTRY= + In Pass #1 these information is collected and in PostConfig() + the NLS package is loaded into memory. + -- 2000/06/11 ska */ + WORD cfgCSYS_cntry; + /* country ID to be loaded */ + WORD cfgCSYS_cp; + /* requested codepage; NLS_DEFAULT if default */ + BYTE cfgCSYS_fnam[NAMEMAX]; + /* filename of COUNTRY= */ + WORD cfgCSYS_memory; + /* number of bytes required for the NLS pkg; + 0 if none */ + VOID FAR *cfgCSYS_data; + /* where the loaded data is for PostConfig() */ + UBYTE cfgP_0_startmode; + /* load command.com high or not */ }; extern struct config Config; @@ -134,7 +130,7 @@ INIT VOID mcb_init(UCOUNT seg, UWORD size); INIT VOID strcat(REG BYTE * d, REG BYTE * s); INIT BYTE FAR *KernelAlloc(WORD nBytes); INIT COUNT ASMCFUNC Umb_Test(void); -INIT COUNT ASMCFUNC UMB_get_largest(UCOUNT *seg, UCOUNT *size); +INIT COUNT ASMCFUNC UMB_get_largest(UCOUNT * seg, UCOUNT * size); INIT BYTE *GetStringArg(BYTE * pLine, BYTE * pszString); /* diskinit.c */ @@ -152,27 +148,28 @@ UWORD init_oem(void); /* intr.asm */ -void ASMCFUNC init_call_intr(int nr, iregs *rp); -UCOUNT ASMCFUNC read(int fd, void *buf, UCOUNT count); +void ASMCFUNC init_call_intr(int nr, iregs * rp); +UCOUNT ASMCFUNC read(int fd, void *buf, UCOUNT count); int ASMCFUNC open(const char *pathname, int flags); int ASMCFUNC close(int fd); int ASMCFUNC dup2(int oldfd, int newfd); -int ASMCFUNC allocmem(UWORD size, seg *segp); +int ASMCFUNC allocmem(UWORD size, seg * segp); INIT VOID ASMCFUNC init_PSPInit(seg psp_seg); INIT VOID ASMCFUNC init_PSPSet(seg psp_seg); INIT COUNT ASMCFUNC init_DosExec(COUNT mode, exec_blk * ep, BYTE * lp); INIT VOID ASMCFUNC keycheck(VOID); /* irqstack.asm */ -VOID ASMCFUNC init_stacks(VOID FAR * stack_base, COUNT nStacks, WORD stackSize); +VOID ASMCFUNC init_stacks(VOID FAR * stack_base, COUNT nStacks, + WORD stackSize); /* inthndlr.c */ -VOID far ASMCFUNC int21_entry(iregs UserRegs); -VOID ASMCFUNC int21_service(iregs far * r); +VOID far ASMCFUNC int21_entry(iregs UserRegs); +VOID ASMCFUNC int21_service(iregs far * r); VOID FAR ASMCFUNC int0_handler(void); VOID FAR ASMCFUNC int6_handler(void); VOID FAR ASMCFUNC empty_handler(void); -VOID far ASMCFUNC got_cbreak(void); /* procsupt.asm */ +VOID far ASMCFUNC got_cbreak(void); /* procsupt.asm */ VOID far ASMCFUNC int20_handler(iregs UserRegs); VOID far ASMCFUNC int21_handler(iregs UserRegs); VOID FAR ASMCFUNC int22_handler(void); @@ -187,21 +184,22 @@ VOID FAR ASMCFUNC int2f_handler(void); /* main.c */ INIT VOID ASMCFUNC FreeDOSmain(void); -INIT BOOL init_device(struct dhdr FAR * dhp, BYTE FAR * cmdLine, COUNT mode, COUNT top); +INIT BOOL init_device(struct dhdr FAR * dhp, BYTE FAR * cmdLine, + COUNT mode, COUNT top); INIT VOID init_fatal(BYTE * err_msg); /* prf.c */ -WORD init_printf(CONST BYTE * fmt,...); +WORD init_printf(CONST BYTE * fmt, ...); WORD init_sprintf(BYTE * buff, CONST BYTE * fmt, ...); void MoveKernel(unsigned NewKernelSegment); -extern WORD HMAFree; /* first byte in HMA not yet used */ +extern WORD HMAFree; /* first byte in HMA not yet used */ extern unsigned CurrentKernelSegment; #if defined(WATCOM) && 0 -ULONG FAR ASMCFUNC MULULUS(ULONG mul1, UWORD mul2); /* MULtiply ULong by UShort */ -ULONG FAR ASMCFUNC MULULUL(ULONG mul1, ULONG mul2); /* MULtiply ULong by ULong */ -ULONG FAR ASMCFUNC DIVULUS(ULONG mul1, UWORD mul2); /* DIVide ULong by UShort */ -ULONG FAR ASMCFUNC DIVMODULUS(ULONG mul1, UWORD mul2,UWORD *rem); /* DIVide ULong by UShort */ +ULONG FAR ASMCFUNC MULULUS(ULONG mul1, UWORD mul2); /* MULtiply ULong by UShort */ +ULONG FAR ASMCFUNC MULULUL(ULONG mul1, ULONG mul2); /* MULtiply ULong by ULong */ +ULONG FAR ASMCFUNC DIVULUS(ULONG mul1, UWORD mul2); /* DIVide ULong by UShort */ +ULONG FAR ASMCFUNC DIVMODULUS(ULONG mul1, UWORD mul2, UWORD * rem); /* DIVide ULong by UShort */ #endif diff --git a/kernel/initdisk.c b/kernel/initdisk.c index 358ff26c..f2bf01db 100644 --- a/kernel/initdisk.c +++ b/kernel/initdisk.c @@ -29,12 +29,13 @@ #include "init-dat.h" #include "dyndata.h" #ifdef VERSION_STRINGS -static BYTE *dskRcsId = "$Id$"; +static BYTE *dskRcsId = + "$Id$"; #endif /* data shared between DSK.C and INITDISK.C -*/ +*/ extern UBYTE DOSFAR DiskTransferBuffer[1 * SEC_SIZE]; extern COUNT DOSFAR nUnits; @@ -157,22 +158,20 @@ extern UWORD DOSFAR LBA_WRITE_VERIFY; /* #define DEBUG */ -#define _BETA_ /* messages for initial phase only */ - +#define _BETA_ /* messages for initial phase only */ #if defined(DEBUG) - #define DebugPrintf(x) printf x +#define DebugPrintf(x) printf x #else - #define DebugPrintf(x) +#define DebugPrintf(x) #endif #if defined(_BETA_) - #define BetaPrintf(x) printf x +#define BetaPrintf(x) printf x #else - #define BetaPrintf(x) +#define BetaPrintf(x) #endif - #define LBA_to_CHS init_LBA_to_CHS /* @@ -184,25 +183,24 @@ extern UWORD DOSFAR LBA_WRITE_VERIFY; #define SCAN_EXTENDED 0x02 #define SCAN_PRIMARY2 0x03 - #define FAT12 0x01 #define FAT16SMALL 0x04 #define EXTENDED 0x05 #define FAT16LARGE 0x06 -#define FAT32 0x0b /* FAT32 partition that ends before the 8.4 */ +#define FAT32 0x0b /* FAT32 partition that ends before the 8.4 */ /* GB boundary */ -#define FAT32_LBA 0x0c /* FAT32 partition that ends after the 8.4GB */ +#define FAT32_LBA 0x0c /* FAT32 partition that ends after the 8.4GB */ /* boundary. LBA is needed to access this. */ -#define FAT16_LBA 0x0e /* like 0x06, but it is supposed to end past */ +#define FAT16_LBA 0x0e /* like 0x06, but it is supposed to end past */ /* the 8.4GB boundary */ -#define FAT12_LBA 0xff /* fake FAT12 LBA entry for internal use */ -#define EXTENDED_LBA 0x0f /* like 0x05, but it is supposed to end past */ +#define FAT12_LBA 0xff /* fake FAT12 LBA entry for internal use */ +#define EXTENDED_LBA 0x0f /* like 0x05, but it is supposed to end past */ /* Let's play it safe and do not allow partitions with clusters above * * or equal to 0xff0/0xfff0/0xffffff0 to be created * * the problem with fff0-fff6 is that they might be interpreted as BAD * * even though the standard BAD value is ...ff7 */ - + #define FAT12MAX (FAT_MAGIC-7) #define FAT16MAX (FAT_MAGIC16-7) #define FAT32MAX (FAT_MAGIC32-7) @@ -228,48 +226,46 @@ extern UWORD DOSFAR LBA_WRITE_VERIFY; (parttyp) == FAT16_LBA) #endif -#define MSDOS_EXT_SIGN 0x29 /* extended boot sector signature */ +#define MSDOS_EXT_SIGN 0x29 /* extended boot sector signature */ #define MSDOS_FAT12_SIGN "FAT12 " /* FAT12 filesystem signature */ #define MSDOS_FAT16_SIGN "FAT16 " /* FAT16 filesystem signature */ #define MSDOS_FAT32_SIGN "FAT32 " /* FAT32 filesystem signature */ /* local - returned and used for BIOS interface INT 13, AH=48*/ struct _bios_LBA_disk_parameterS { - UWORD size; - UWORD information; - ULONG cylinders; - ULONG heads; - ULONG sectors; - - ULONG totalSect; - ULONG totalSectHigh; - UWORD BytesPerSector; + UWORD size; + UWORD information; + ULONG cylinders; + ULONG heads; + ULONG sectors; - ULONG eddparameters; - } ; + ULONG totalSect; + ULONG totalSectHigh; + UWORD BytesPerSector; + ULONG eddparameters; +}; /* physical characteristics of a drive */ -struct DriveParamS -{ - UBYTE driveno; /* = 0x8x */ - BITS LBA_supported:1; /* set, if INT13 extensions enabled */ - BITS WriteVerifySupported:1; /* */ - ULONG total_sectors; +struct DriveParamS { + UBYTE driveno; /* = 0x8x */ + BITS LBA_supported:1; /* set, if INT13 extensions enabled */ + BITS WriteVerifySupported:1; /* */ + ULONG total_sectors; - struct CHS chs; /* for normal INT 13 */ + struct CHS chs; /* for normal INT 13 */ }; -struct PartTableEntry /* INTERNAL representation of partition table entry */ - { - UBYTE Bootable; - UBYTE FileSystem; - struct CHS Begin; - struct CHS End; - ULONG RelSect; - ULONG NumSect; - }; +struct PartTableEntry /* INTERNAL representation of partition table entry */ +{ + UBYTE Bootable; + UBYTE FileSystem; + struct CHS Begin; + struct CHS End; + ULONG RelSect; + ULONG NumSect; +}; /* internal global data @@ -277,23 +273,23 @@ struct PartTableEntry /* INTERNAL representation of partition table entry */ COUNT init_readdasd(UBYTE drive) { - static iregs regs; - - regs.a.b.h = 0x15; - regs.d.b.l = drive; - init_call_intr(0x13,®s); - if ((regs.flags & 1) == 0) switch (regs.a.b.h) + static iregs regs; + + regs.a.b.h = 0x15; + regs.d.b.l = drive; + init_call_intr(0x13, ®s); + if ((regs.flags & 1) == 0) + switch (regs.a.b.h) { - case 2: - return DF_CHANGELINE; - case 3: - return DF_FIXED; + case 2: + return DF_CHANGELINE; + case 3: + return DF_FIXED; } - return 0; + return 0; } -typedef struct -{ +typedef struct { UWORD bpb_nbyte; /* Bytes per Sector */ UBYTE bpb_nsector; /* Sectors per Allocation Unit */ UWORD bpb_nreserved; /* # Reserved Sectors */ @@ -307,42 +303,42 @@ typedef struct } floppy_bpb; floppy_bpb floppy_bpbs[5] = { -/* copied from Brian Reifsnyder's FORMAT, bpb.h */ - {SEC_SIZE,2,1,2,112, 720,0xfd,2, 9,2}, /* FD360 5.25 DS */ - {SEC_SIZE,1,1,2,224,2400,0xf9,7,15,2}, /* FD1200 5.25 HD */ - {SEC_SIZE,2,1,2,112,1440,0xf9,3, 9,2}, /* FD720 3.5 LD */ - {SEC_SIZE,1,1,2,224,2880,0xf0,9,18,2}, /* FD1440 3.5 HD */ - {SEC_SIZE,2,1,2,240,5760,0xf0,9,36,2} /* FD2880 3.5 ED */ +/* copied from Brian Reifsnyder's FORMAT, bpb.h */ + {SEC_SIZE, 2, 1, 2, 112, 720, 0xfd, 2, 9, 2}, /* FD360 5.25 DS */ + {SEC_SIZE, 1, 1, 2, 224, 2400, 0xf9, 7, 15, 2}, /* FD1200 5.25 HD */ + {SEC_SIZE, 2, 1, 2, 112, 1440, 0xf9, 3, 9, 2}, /* FD720 3.5 LD */ + {SEC_SIZE, 1, 1, 2, 224, 2880, 0xf0, 9, 18, 2}, /* FD1440 3.5 HD */ + {SEC_SIZE, 2, 1, 2, 240, 5760, 0xf0, 9, 36, 2} /* FD2880 3.5 ED */ }; -COUNT init_getdriveparm(UBYTE drive, bpb FAR *pbpbarray) +COUNT init_getdriveparm(UBYTE drive, bpb FAR * pbpbarray) { - static iregs regs; - REG UBYTE type; - - if (drive & 0x80) - return 5; - regs.a.b.h = 0x08; - regs.d.b.l = drive; - init_call_intr(0x13,®s); - type = regs.b.b.l - 1; - if (regs.flags & 1) - type = 0; /* return 320-360 for XTs */ - else if (type > 6) - type = 8; /* any odd ball drives get 8&7=0: the 320-360 table */ - else if (type == 5) - type = 4; /* 5 and 4 are both 2.88 MB */ - - fmemcpy(pbpbarray, &floppy_bpbs[type & 7], sizeof(floppy_bpb)); - - if (type == 3) - return 7; /* 1.44 MB */ - - if (type == 4) - return 9; /* 2.88 almost forgot this one*/ - - /* 0=320-360kB, 1=1.2MB, 2=720kB, 8=any odd ball drives */ - return type; + static iregs regs; + REG UBYTE type; + + if (drive & 0x80) + return 5; + regs.a.b.h = 0x08; + regs.d.b.l = drive; + init_call_intr(0x13, ®s); + type = regs.b.b.l - 1; + if (regs.flags & 1) + type = 0; /* return 320-360 for XTs */ + else if (type > 6) + type = 8; /* any odd ball drives get 8&7=0: the 320-360 table */ + else if (type == 5) + type = 4; /* 5 and 4 are both 2.88 MB */ + + fmemcpy(pbpbarray, &floppy_bpbs[type & 7], sizeof(floppy_bpb)); + + if (type == 3) + return 7; /* 1.44 MB */ + + if (type == 4) + return 9; /* 2.88 almost forgot this one */ + + /* 0=320-360kB, 1=1.2MB, 2=720kB, 8=any odd ball drives */ + return type; } /* @@ -350,21 +346,22 @@ COUNT init_getdriveparm(UBYTE drive, bpb FAR *pbpbarray) copied and pasted from dsk.c! */ -void init_LBA_to_CHS(struct CHS *chs, ULONG LBA_address, struct DriveParamS *driveparam) +void init_LBA_to_CHS(struct CHS *chs, ULONG LBA_address, + struct DriveParamS *driveparam) { - chs->Sector = LBA_address% driveparam->chs.Sector + 1; + chs->Sector = LBA_address % driveparam->chs.Sector + 1; - LBA_address /= driveparam->chs.Sector; + LBA_address /= driveparam->chs.Sector; - chs->Head = LBA_address % driveparam->chs.Head; - chs->Cylinder = LBA_address / driveparam->chs.Head; + chs->Head = LBA_address % driveparam->chs.Head; + chs->Cylinder = LBA_address / driveparam->chs.Head; } -void printCHS(char *title,struct CHS *chs) +void printCHS(char *title, struct CHS *chs) { - printf("%s",title); - printf("%4lu-%u-%u",chs->Cylinder, chs->Head, chs->Sector); -} + printf("%s", title); + printf("%4lu-%u-%u", chs->Cylinder, chs->Head, chs->Sector); +} /* reason for this modules existence: @@ -384,759 +381,751 @@ void printCHS(char *title,struct CHS *chs) Portions copyright 1992, 1993 Remy Card and 1991 Linus Torvalds */ -VOID CalculateFATData(ddt FAR *pddt, ULONG NumSectors, UBYTE FileSystem) +VOID CalculateFATData(ddt FAR * pddt, ULONG NumSectors, UBYTE FileSystem) { - ULONG fatlength, maxclust, clust; - UBYTE maxclustsize; - ULONG fatdata; - - bpb FAR *defbpb = &pddt->ddt_defbpb; - - /* FAT related items */ - defbpb->bpb_nfat = 2; - defbpb->bpb_ndirent = (FileSystem == FAT32 || FileSystem == FAT32_LBA) ? 0 : 512; - /* normal value of number of entries in root dir */ - defbpb->bpb_nreserved = (FileSystem == FAT32 || FileSystem == FAT32_LBA) ? 0x20 : 1; - - fatdata = NumSectors - cdiv (defbpb->bpb_ndirent * DIRENT_SIZE, defbpb->bpb_nbyte) - - defbpb->bpb_nreserved; - maxclustsize = 128; -#ifdef DEBUG - if (FileSystem!=FAT12) - DebugPrintf(( "%ld sectors for FAT+data, starting with %d sectors/cluster\n", - fatdata, defbpb->bpb_nsector )); -#endif - switch(FileSystem) { + ULONG fatlength, maxclust, clust; + UBYTE maxclustsize; + ULONG fatdata; + + bpb FAR *defbpb = &pddt->ddt_defbpb; + + /* FAT related items */ + defbpb->bpb_nfat = 2; + defbpb->bpb_ndirent = (FileSystem == FAT32 + || FileSystem == FAT32_LBA) ? 0 : 512; + /* normal value of number of entries in root dir */ + defbpb->bpb_nreserved = (FileSystem == FAT32 + || FileSystem == FAT32_LBA) ? 0x20 : 1; + + fatdata = + NumSectors - cdiv(defbpb->bpb_ndirent * DIRENT_SIZE, + defbpb->bpb_nbyte) - defbpb->bpb_nreserved; + maxclustsize = 128; +#ifdef DEBUG + if (FileSystem != FAT12) + DebugPrintf(("%ld sectors for FAT+data, starting with %d sectors/cluster\n", fatdata, defbpb->bpb_nsector)); +#endif + switch (FileSystem) + { case FAT12: - case FAT12_LBA: - /* in DOS, FAT12 defaults to 4096kb (8 sector) - clusters. */ - defbpb->bpb_nsector = 8; - /* Force maximal fatdata=32696 sectors since with our only possible sector - size (512 bytes) this is the maximum for 4k clusters. - #clus*secperclus+#fats*fatlength= 4077 * 8 + 2 * 12 = 32640. - max FAT12 size for FreeDOS = 16,728,064 bytes */ - if (fatdata > 32640) - fatdata = 32640; - /* The factor 2 below avoids cut-off errors for nr_fats == 1. - * The "defbpb->bpb_nfat*3" is for the reserved first two FAT entries */ - clust = 2*((ULONG) fatdata * defbpb->bpb_nbyte + defbpb->bpb_nfat*3) / - (2*(ULONG) defbpb->bpb_nsector * defbpb->bpb_nbyte + defbpb->bpb_nfat*3); - fatlength = cdiv (((clust+2) * 3 + 1) >> 1, defbpb->bpb_nbyte); + case FAT12_LBA: + /* in DOS, FAT12 defaults to 4096kb (8 sector) - clusters. */ + defbpb->bpb_nsector = 8; + /* Force maximal fatdata=32696 sectors since with our only possible sector + size (512 bytes) this is the maximum for 4k clusters. + #clus*secperclus+#fats*fatlength= 4077 * 8 + 2 * 12 = 32640. + max FAT12 size for FreeDOS = 16,728,064 bytes */ + if (fatdata > 32640) + fatdata = 32640; + /* The factor 2 below avoids cut-off errors for nr_fats == 1. + * The "defbpb->bpb_nfat*3" is for the reserved first two FAT entries */ + clust = + 2 * ((ULONG) fatdata * defbpb->bpb_nbyte + + defbpb->bpb_nfat * 3) / (2 * (ULONG) defbpb->bpb_nsector * + defbpb->bpb_nbyte + + defbpb->bpb_nfat * 3); + fatlength = cdiv(((clust + 2) * 3 + 1) >> 1, defbpb->bpb_nbyte); + /* Need to recalculate number of clusters, since the unused parts of the + * FATS and data area together could make up space for an additional, + * not really present cluster. */ + clust = + (fatdata - defbpb->bpb_nfat * fatlength) / defbpb->bpb_nsector; + maxclust = (fatlength * 2 * defbpb->bpb_nbyte) / 3; + if (maxclust > FAT12MAX) + maxclust = FAT12MAX; + DebugPrintf(("FAT12: #clu=%lu, fatlen=%lu, maxclu=%lu, limit=%u\n", + clust, fatlength, maxclust, FATMAX12)); + if (clust > maxclust - 2) + { + clust = maxclust - 2; + DebugPrintf(("FAT12: too many clusters: setting to maxclu-2\n")); + } + defbpb->bpb_nfsect = fatlength; + fmemcpy(pddt->ddt_fstype, MSDOS_FAT12_SIGN, 8); + break; + + case FAT16SMALL: + case FAT16LARGE: + case FAT16_LBA: + /* FAT16: start at 4 sectors per cluster */ + defbpb->bpb_nsector = 4; + /* Force maximal fatdata=8387584 sectors (NumSectors=8387617) + since with our only possible sectorsize (512 bytes) this is the + maximum we can address with 64k clusters + #clus*secperclus+#fats*fatlength=65517 * 128 + 2 * 256=8386688. + max FAT16 size for FreeDOS = 4,293,984,256 bytes = 4GiB-983,040 */ + if (fatdata > 8386688ul) + fatdata = 8386688ul; + do + { + DebugPrintf(("Trying with %d sectors/cluster:\n", + defbpb->bpb_nsector)); + + clust = + ((ULONG) fatdata * defbpb->bpb_nbyte + + defbpb->bpb_nfat * 4) / ((ULONG) defbpb->bpb_nsector * + defbpb->bpb_nbyte + + defbpb->bpb_nfat * 2); + fatlength = cdiv((clust + 2) * 2, defbpb->bpb_nbyte); /* Need to recalculate number of clusters, since the unused parts of the * FATS and data area together could make up space for an additional, * not really present cluster. */ - clust = (fatdata - defbpb->bpb_nfat*fatlength)/defbpb->bpb_nsector; - maxclust = (fatlength * 2 * defbpb->bpb_nbyte) / 3; - if (maxclust > FAT12MAX) - maxclust = FAT12MAX; - DebugPrintf(( "FAT12: #clu=%lu, fatlen=%lu, maxclu=%lu, limit=%u\n", - clust, fatlength, maxclust, FATMAX12 )); - if (clust > maxclust-2) { - clust = maxclust-2; - DebugPrintf(( "FAT12: too many clusters: setting to maxclu-2\n" )); + clust = + (fatdata - defbpb->bpb_nfat * fatlength) / defbpb->bpb_nsector; + maxclust = (fatlength * defbpb->bpb_nbyte) / 2; + if (maxclust > FAT16MAX) + maxclust = FAT16MAX; + DebugPrintf(("FAT16: #clu=%lu, fatlen=%lu, maxclu=%lu, limit=%u\n", + clust, fatlength, maxclust, FAT_MAGIC16)); + if (clust > maxclust - 2) + { + DebugPrintf(("FAT16: too many clusters\n")); + clust = 0; } - defbpb->bpb_nfsect = fatlength; - fmemcpy(pddt->ddt_fstype, MSDOS_FAT12_SIGN, 8); - break; - - case FAT16SMALL: - case FAT16LARGE: - case FAT16_LBA: - /* FAT16: start at 4 sectors per cluster */ - defbpb->bpb_nsector = 4; - /* Force maximal fatdata=8387584 sectors (NumSectors=8387617) - since with our only possible sectorsize (512 bytes) this is the - maximum we can address with 64k clusters - #clus*secperclus+#fats*fatlength=65517 * 128 + 2 * 256=8386688. - max FAT16 size for FreeDOS = 4,293,984,256 bytes = 4GiB-983,040 */ - if (fatdata > 8386688ul) - fatdata = 8386688ul; - do { - DebugPrintf(( "Trying with %d sectors/cluster:\n", defbpb->bpb_nsector )); - - clust = ((ULONG) fatdata *defbpb->bpb_nbyte + defbpb->bpb_nfat*4) / - ((ULONG) defbpb->bpb_nsector * defbpb->bpb_nbyte + defbpb->bpb_nfat*2); - fatlength = cdiv ((clust+2) * 2, defbpb->bpb_nbyte); - /* Need to recalculate number of clusters, since the unused parts of the - * FATS and data area together could make up space for an additional, - * not really present cluster. */ - clust = (fatdata - defbpb->bpb_nfat*fatlength)/defbpb->bpb_nsector; - maxclust = (fatlength * defbpb->bpb_nbyte) / 2; - if (maxclust > FAT16MAX) - maxclust = FAT16MAX; - DebugPrintf(( "FAT16: #clu=%lu, fatlen=%lu, maxclu=%lu, limit=%u\n", - clust, fatlength, maxclust, FAT_MAGIC16 )); - if (clust > maxclust-2) { - DebugPrintf(( "FAT16: too many clusters\n" )); - clust = 0; - } else if (clust <= FAT_MAGIC) { - /* The <= 4086 avoids that the filesystem will be misdetected as having a - * 12 bit FAT. */ - DebugPrintf(("FAT16: would be misdetected as FAT12\n")); - clust = 0; - } - if (clust) - break; - defbpb->bpb_nsector <<= 1; + else if (clust <= FAT_MAGIC) + { + /* The <= 4086 avoids that the filesystem will be misdetected as having a + * 12 bit FAT. */ + DebugPrintf(("FAT16: would be misdetected as FAT12\n")); + clust = 0; } - while (defbpb->bpb_nsector && defbpb->bpb_nsector <= maxclustsize); - defbpb->bpb_nfsect = fatlength; - fmemcpy(pddt->ddt_fstype, MSDOS_FAT16_SIGN, 8); - break; - + if (clust) + break; + defbpb->bpb_nsector <<= 1; + } + while (defbpb->bpb_nsector && defbpb->bpb_nsector <= maxclustsize); + defbpb->bpb_nfsect = fatlength; + fmemcpy(pddt->ddt_fstype, MSDOS_FAT16_SIGN, 8); + break; + #ifdef WITHFAT32 case FAT32: case FAT32_LBA: - /* For FAT32, use 4k clusters on sufficiently large file systems, - * otherwise 1 sector per cluster. This is also what M$'s format - * command does for FAT32. */ - defbpb->bpb_nsector = (NumSectors >= 512*1024ul ? 8 : 1); - do { - /* simple calculation - no long long available */ - clust = (ULONG)fatdata / defbpb->bpb_nsector; - /* this calculation below yields a smaller value - the above is non-optimal - but should not be dangerous */ - /* clust = ((long long) fatdata *defbpb->bpb_nbyte + defbpb->bpb_nfat*8) / - ((int) defbpb->bpb_nsector * defbpb->bpb_nbyte + defbpb->bpb_nfat*4); */ - fatlength = cdiv ((clust+2) * 4, defbpb->bpb_nbyte); - /* Need to recalculate number of clusters, since the unused parts of the - * FATS and data area together could make up space for an additional, - * not really present cluster. */ - clust = (fatdata - defbpb->bpb_nfat*fatlength)/defbpb->bpb_nsector; - maxclust = (fatlength * defbpb->bpb_nbyte) / 4; - if (maxclust > FAT32MAX) - maxclust = FAT32MAX; - DebugPrintf(( "FAT32: #clu=%u, fatlen=%u, maxclu=%u, limit=%u\n", - clust, fatlength, maxclust, FATMAX32 )); - if (clust > maxclust-2) - { - clust = 0; - DebugPrintf(( "FAT32: too many clusters\n" )); - } - if (clust) - break; - defbpb->bpb_nsector <<= 1; - } while (defbpb->bpb_nsector && defbpb->bpb_nsector <= maxclustsize); - defbpb->bpb_nfsect = 0; - defbpb->bpb_xnfsect = fatlength; - /* set up additional FAT32 fields */ - defbpb->bpb_xflags = 0; - defbpb->bpb_xfsversion = 0; - defbpb->bpb_xrootclst = 2; - defbpb->bpb_xfsinfosec = 1; - defbpb->bpb_xbackupsec = 6; - fmemcpy(pddt->ddt_fstype, MSDOS_FAT32_SIGN, 8); - break; -#endif - } - pddt->ddt_fstype[8] = '\0'; -} - - -void DosDefinePartition(struct DriveParamS *driveParam, - ULONG StartSector, struct PartTableEntry *pEntry, int extendedPartNo, int PrimaryNum) -{ - ddt FAR *pddt = DynAlloc("ddt", 1, sizeof(ddt)); - struct CHS chs; - - if ( nUnits >= NDEV) + /* For FAT32, use 4k clusters on sufficiently large file systems, + * otherwise 1 sector per cluster. This is also what M$'s format + * command does for FAT32. */ + defbpb->bpb_nsector = (NumSectors >= 512 * 1024ul ? 8 : 1); + do + { + /* simple calculation - no long long available */ + clust = (ULONG) fatdata / defbpb->bpb_nsector; + /* this calculation below yields a smaller value - the above is non-optimal + but should not be dangerous */ + /* clust = ((long long) fatdata *defbpb->bpb_nbyte + defbpb->bpb_nfat*8) / + ((int) defbpb->bpb_nsector * defbpb->bpb_nbyte + defbpb->bpb_nfat*4); */ + fatlength = cdiv((clust + 2) * 4, defbpb->bpb_nbyte); + /* Need to recalculate number of clusters, since the unused parts of the + * FATS and data area together could make up space for an additional, + * not really present cluster. */ + clust = + (fatdata - defbpb->bpb_nfat * fatlength) / defbpb->bpb_nsector; + maxclust = (fatlength * defbpb->bpb_nbyte) / 4; + if (maxclust > FAT32MAX) + maxclust = FAT32MAX; + DebugPrintf(("FAT32: #clu=%u, fatlen=%u, maxclu=%u, limit=%u\n", + clust, fatlength, maxclust, FATMAX32)); + if (clust > maxclust - 2) { - printf("more Partitions detected then possible, max = %d\n", NDEV); - return; /* we are done */ + clust = 0; + DebugPrintf(("FAT32: too many clusters\n")); } - - pddt->ddt_driveno = driveParam->driveno; - pddt->ddt_logdriveno = nUnits; - pddt->ddt_LBASupported = driveParam->LBA_supported; - /* Turn of LBA if not forced and the partition is within 1023 cyls and of the right type */ - /* the FileSystem type was internally converted to LBA_xxxx if a non-LBA partition - above cylinder 1023 was found */ - if (!InitKernelConfig.ForceLBA && !IsLBAPartition(pEntry->FileSystem)) - pddt->ddt_LBASupported = FALSE; - pddt->ddt_WriteVerifySupported = driveParam->WriteVerifySupported; - pddt->ddt_ncyl = driveParam->chs.Cylinder; - - if (pddt->ddt_LBASupported) - DebugPrintf(("LBA enabled for drive %c:\n", 'A'+nUnits)); - - pddt->ddt_offset = StartSector; - - pddt->ddt_defbpb.bpb_nbyte = SEC_SIZE; - pddt->ddt_defbpb.bpb_mdesc = 0xf8; - pddt->ddt_defbpb.bpb_nheads = driveParam->chs.Head; - pddt->ddt_defbpb.bpb_nsecs = driveParam->chs.Sector; - pddt->ddt_defbpb.bpb_nsize = 0; - pddt->ddt_defbpb.bpb_hidden = pEntry->RelSect; - if (pEntry->NumSect > 0xffff) - pddt->ddt_defbpb.bpb_huge = pEntry->NumSect; - else - pddt->ddt_defbpb.bpb_nsize = (UWORD)(pEntry->NumSect); - - /* sectors per cluster, sectors per FAT etc. */ - CalculateFATData(pddt, pEntry->NumSect, pEntry->FileSystem); - - pddt->ddt_serialno = 0x12345678l; - /* drive inaccessible until bldbpb successful */ - pddt->ddt_descflags = init_readdasd(pddt->ddt_driveno) | DF_NOACCESS; - pddt->ddt_type = 5; - fmemcpy(&pddt->ddt_bpb, &pddt->ddt_defbpb, sizeof(bpb)); - - /* Alain whishes to keep this in later versions, too - Tom likes this too, so he made it configurable by SYS CONFIG ... - */ - - if (InitKernelConfig.InitDiskShowDriveAssignment) - { - LBA_to_CHS(&chs,StartSector,driveParam); - - printf("%c: HD%d", - 'A' + nUnits, - (driveParam->driveno & 0x7f)+1); - - if (extendedPartNo) printf(" Ext:%d", extendedPartNo); - else printf(" Pri:%d", PrimaryNum + 1); - - printCHS(" CHS= ",&chs); - - printf(" start = %5luMB,size =%5lu", - StartSector/2048,pEntry->NumSect/2048); - - printf("\n"); - } - - - - nUnits++; + if (clust) + break; + defbpb->bpb_nsector <<= 1; + } + while (defbpb->bpb_nsector && defbpb->bpb_nsector <= maxclustsize); + defbpb->bpb_nfsect = 0; + defbpb->bpb_xnfsect = fatlength; + /* set up additional FAT32 fields */ + defbpb->bpb_xflags = 0; + defbpb->bpb_xfsversion = 0; + defbpb->bpb_xrootclst = 2; + defbpb->bpb_xfsinfosec = 1; + defbpb->bpb_xbackupsec = 6; + fmemcpy(pddt->ddt_fstype, MSDOS_FAT32_SIGN, 8); + break; +#endif + } + pddt->ddt_fstype[8] = '\0'; } - -/* Get the parameters of the hard disk */ -int LBA_Get_Drive_Parameters(int drive,struct DriveParamS *driveParam) +void DosDefinePartition(struct DriveParamS *driveParam, + ULONG StartSector, struct PartTableEntry *pEntry, + int extendedPartNo, int PrimaryNum) { - iregs regs; - - struct _bios_LBA_disk_parameterS lba_bios_parameters; - - if (driveParam->driveno) - return driveParam->driveno; + ddt FAR *pddt = DynAlloc("ddt", 1, sizeof(ddt)); + struct CHS chs; - driveParam->LBA_supported = FALSE; - - - drive |= 0x80; - - /* for tests - disable LBA support, - even if exists */ - if (!InitKernelConfig.GlobalEnableLBAsupport) - { - goto StandardBios; - } - /* check for LBA support */ - regs.b.x = 0x55aa; - regs.a.b.h = 0x41; - regs.d.b.l = drive; - - init_call_intr(0x13,®s); + if (nUnits >= NDEV) + { + printf("more Partitions detected then possible, max = %d\n", NDEV); + return; /* we are done */ + } + + pddt->ddt_driveno = driveParam->driveno; + pddt->ddt_logdriveno = nUnits; + pddt->ddt_LBASupported = driveParam->LBA_supported; + /* Turn of LBA if not forced and the partition is within 1023 cyls and of the right type */ + /* the FileSystem type was internally converted to LBA_xxxx if a non-LBA partition + above cylinder 1023 was found */ + if (!InitKernelConfig.ForceLBA && !IsLBAPartition(pEntry->FileSystem)) + pddt->ddt_LBASupported = FALSE; + pddt->ddt_WriteVerifySupported = driveParam->WriteVerifySupported; + pddt->ddt_ncyl = driveParam->chs.Cylinder; + + if (pddt->ddt_LBASupported) + DebugPrintf(("LBA enabled for drive %c:\n", 'A' + nUnits)); + + pddt->ddt_offset = StartSector; + + pddt->ddt_defbpb.bpb_nbyte = SEC_SIZE; + pddt->ddt_defbpb.bpb_mdesc = 0xf8; + pddt->ddt_defbpb.bpb_nheads = driveParam->chs.Head; + pddt->ddt_defbpb.bpb_nsecs = driveParam->chs.Sector; + pddt->ddt_defbpb.bpb_nsize = 0; + pddt->ddt_defbpb.bpb_hidden = pEntry->RelSect; + if (pEntry->NumSect > 0xffff) + pddt->ddt_defbpb.bpb_huge = pEntry->NumSect; + else + pddt->ddt_defbpb.bpb_nsize = (UWORD) (pEntry->NumSect); + + /* sectors per cluster, sectors per FAT etc. */ + CalculateFATData(pddt, pEntry->NumSect, pEntry->FileSystem); + + pddt->ddt_serialno = 0x12345678l; + /* drive inaccessible until bldbpb successful */ + pddt->ddt_descflags = init_readdasd(pddt->ddt_driveno) | DF_NOACCESS; + pddt->ddt_type = 5; + fmemcpy(&pddt->ddt_bpb, &pddt->ddt_defbpb, sizeof(bpb)); + + /* Alain whishes to keep this in later versions, too + Tom likes this too, so he made it configurable by SYS CONFIG ... + */ + + if (InitKernelConfig.InitDiskShowDriveAssignment) + { + LBA_to_CHS(&chs, StartSector, driveParam); + printf("%c: HD%d", 'A' + nUnits, (driveParam->driveno & 0x7f) + 1); - if (regs.b.x != 0xaa55 || (regs.flags & 0x01) ) - { - goto StandardBios; - } + if (extendedPartNo) + printf(" Ext:%d", extendedPartNo); + else + printf(" Pri:%d", PrimaryNum + 1); - /* by ralph : - if DAP cannot be used, don't use - LBA - */ - if ((regs.c.x & 1) == 0) - { - goto StandardBios; - } - - + printCHS(" CHS= ", &chs); - /* drive supports LBA addressing */ + printf(" start = %5luMB,size =%5lu", + StartSector / 2048, pEntry->NumSect / 2048); - /* version 1.0, 2.0 have different verify */ - if (regs.a.x < 0x2100) - LBA_WRITE_VERIFY = 0x4301; + printf("\n"); + } + nUnits++; +} - memset(&lba_bios_parameters, 0, sizeof(lba_bios_parameters)); - lba_bios_parameters.size = sizeof(lba_bios_parameters); +/* Get the parameters of the hard disk */ +int LBA_Get_Drive_Parameters(int drive, struct DriveParamS *driveParam) +{ + iregs regs; + struct _bios_LBA_disk_parameterS lba_bios_parameters; - regs.si = FP_OFF(&lba_bios_parameters); - regs.ds = FP_SEG(&lba_bios_parameters); - regs.a.b.h = 0x48; - regs.d.b.l = drive; - init_call_intr(0x13,®s); + if (driveParam->driveno) + return driveParam->driveno; + driveParam->LBA_supported = FALSE; - if (regs.flags & 0x01) - { - goto StandardBios; - } + drive |= 0x80; - /* verify maximum settings, we can't handle more */ + /* for tests - disable LBA support, + even if exists */ + if (!InitKernelConfig.GlobalEnableLBAsupport) + { + goto StandardBios; + } + /* check for LBA support */ + regs.b.x = 0x55aa; + regs.a.b.h = 0x41; + regs.d.b.l = drive; - if (lba_bios_parameters.heads > 0xffff || - lba_bios_parameters.sectors > 0xffff || - lba_bios_parameters.totalSectHigh != 0 ) - { - printf("Drive is too large to handle, using only 1'st 8 GB\n" - " drive %02x heads %lu sectors %lu , total=0x%lx-%08lx\n", - drive, - (ULONG)lba_bios_parameters.heads, - (ULONG)lba_bios_parameters.sectors, - (ULONG)lba_bios_parameters.totalSect, - (ULONG)lba_bios_parameters.totalSectHigh); + init_call_intr(0x13, ®s); - goto StandardBios; - } - - if (lba_bios_parameters.information & 8) - { - driveParam->WriteVerifySupported = 1; - } - else - driveParam->WriteVerifySupported = 0; + if (regs.b.x != 0xaa55 || (regs.flags & 0x01)) + { + goto StandardBios; + } + + /* by ralph : + if DAP cannot be used, don't use + LBA + */ + if ((regs.c.x & 1) == 0) + { + goto StandardBios; + } - driveParam->total_sectors = lba_bios_parameters.totalSect; + /* drive supports LBA addressing */ - /* if we arrive here, success */ - driveParam->LBA_supported = TRUE; + /* version 1.0, 2.0 have different verify */ + if (regs.a.x < 0x2100) + LBA_WRITE_VERIFY = 0x4301; + memset(&lba_bios_parameters, 0, sizeof(lba_bios_parameters)); + lba_bios_parameters.size = sizeof(lba_bios_parameters); + regs.si = FP_OFF(&lba_bios_parameters); + regs.ds = FP_SEG(&lba_bios_parameters); + regs.a.b.h = 0x48; + regs.d.b.l = drive; + init_call_intr(0x13, ®s); + if (regs.flags & 0x01) + { + goto StandardBios; + } -StandardBios: /* old way to get parameters */ + /* verify maximum settings, we can't handle more */ + if (lba_bios_parameters.heads > 0xffff || + lba_bios_parameters.sectors > 0xffff || + lba_bios_parameters.totalSectHigh != 0) + { + printf("Drive is too large to handle, using only 1'st 8 GB\n" + " drive %02x heads %lu sectors %lu , total=0x%lx-%08lx\n", + drive, + (ULONG) lba_bios_parameters.heads, + (ULONG) lba_bios_parameters.sectors, + (ULONG) lba_bios_parameters.totalSect, + (ULONG) lba_bios_parameters.totalSectHigh); + + goto StandardBios; + } + + if (lba_bios_parameters.information & 8) + { + driveParam->WriteVerifySupported = 1; + } + else + driveParam->WriteVerifySupported = 0; - regs.a.b.h = 0x08; - regs.d.b.l = drive; + driveParam->total_sectors = lba_bios_parameters.totalSect; - init_call_intr(0x13,®s); + /* if we arrive here, success */ + driveParam->LBA_supported = TRUE; +StandardBios: /* old way to get parameters */ - if (regs.flags & 0x01) - goto ErrorReturn; + regs.a.b.h = 0x08; + regs.d.b.l = drive; + init_call_intr(0x13, ®s); - driveParam->chs.Head = (regs.d.x >> 8) + 1; - driveParam->chs.Sector = (regs.c.x & 0x3f); - driveParam->chs.Cylinder = (regs.c.x >> 8) | ((regs.c.x & 0xc0) << 2); - + if (regs.flags & 0x01) + goto ErrorReturn; - if (!driveParam->LBA_supported) - { - driveParam->total_sectors = - min(driveParam->chs.Cylinder,1023) - * driveParam->chs.Head - * driveParam->chs.Sector; - } + driveParam->chs.Head = (regs.d.x >> 8) + 1; + driveParam->chs.Sector = (regs.c.x & 0x3f); + driveParam->chs.Cylinder = (regs.c.x >> 8) | ((regs.c.x & 0xc0) << 2); - driveParam->driveno = drive; + if (!driveParam->LBA_supported) + { + driveParam->total_sectors = + min(driveParam->chs.Cylinder, 1023) + * driveParam->chs.Head * driveParam->chs.Sector; + } - DebugPrintf(("drive parameters %02x - %04lu-%u-%u", - drive, - driveParam->chs.Cylinder, - driveParam->chs.Head, - driveParam->chs.Sector)); - DebugPrintf((" total size %luMB\n\n",driveParam->total_sectors/2048)); + driveParam->driveno = drive; - + DebugPrintf(("drive parameters %02x - %04lu-%u-%u", + drive, + driveParam->chs.Cylinder, + driveParam->chs.Head, driveParam->chs.Sector)); + DebugPrintf((" total size %luMB\n\n", driveParam->total_sectors / 2048)); ErrorReturn: - return driveParam->driveno; + return driveParam->driveno; } - - - /* converts physical into logical representation of partition entry */ -ConvPartTableEntryToIntern(struct PartTableEntry *pEntry, UBYTE FAR * pDisk) +ConvPartTableEntryToIntern(struct PartTableEntry * pEntry, + UBYTE FAR * pDisk) { - int i; - - if (pDisk[0x1fe] != 0x55 || pDisk[0x1ff] != 0xaa) - { - memset(pEntry,0, 4 * sizeof(struct PartTableEntry)); + int i; - return FALSE; - } + if (pDisk[0x1fe] != 0x55 || pDisk[0x1ff] != 0xaa) + { + memset(pEntry, 0, 4 * sizeof(struct PartTableEntry)); - pDisk += 0x1be; + return FALSE; + } - for (i = 0; i < 4; i++,pDisk += 16,pEntry++) - { + pDisk += 0x1be; - pEntry->Bootable = *(UBYTE FAR*)(pDisk+0); - pEntry->FileSystem = *(UBYTE FAR*)(pDisk+4); + for (i = 0; i < 4; i++, pDisk += 16, pEntry++) + { - pEntry->Begin.Head = *(UBYTE FAR*)(pDisk+1); - pEntry->Begin.Sector = *(UBYTE FAR*)(pDisk+2) & 0x3f; - pEntry->Begin.Cylinder = *(UBYTE FAR*)(pDisk+3) + - ((UWORD) (0xc0 & *(UBYTE FAR*)(pDisk+2)) << 2); + pEntry->Bootable = *(UBYTE FAR *) (pDisk + 0); + pEntry->FileSystem = *(UBYTE FAR *) (pDisk + 4); - pEntry->End.Head = *(UBYTE FAR*)(pDisk+5); - pEntry->End.Sector = *(UBYTE FAR*)(pDisk+6) & 0x3f; - pEntry->End.Cylinder = *(UBYTE FAR*)(pDisk+7) + - ((UWORD) (0xc0 & *(UBYTE FAR*)(pDisk+6)) << 2); + pEntry->Begin.Head = *(UBYTE FAR *) (pDisk + 1); + pEntry->Begin.Sector = *(UBYTE FAR *) (pDisk + 2) & 0x3f; + pEntry->Begin.Cylinder = *(UBYTE FAR *) (pDisk + 3) + + ((UWORD) (0xc0 & *(UBYTE FAR *) (pDisk + 2)) << 2); + pEntry->End.Head = *(UBYTE FAR *) (pDisk + 5); + pEntry->End.Sector = *(UBYTE FAR *) (pDisk + 6) & 0x3f; + pEntry->End.Cylinder = *(UBYTE FAR *) (pDisk + 7) + + ((UWORD) (0xc0 & *(UBYTE FAR *) (pDisk + 6)) << 2); - pEntry->RelSect = *(ULONG FAR*)(pDisk+8); - pEntry->NumSect = *(ULONG FAR*)(pDisk+12); - } - return TRUE; + pEntry->RelSect = *(ULONG FAR *) (pDisk + 8); + pEntry->NumSect = *(ULONG FAR *) (pDisk + 12); + } + return TRUE; } -ScanForPrimaryPartitions(struct DriveParamS *driveParam,int scan_type, - struct PartTableEntry *pEntry, ULONG startSector, - int partitionsToIgnore, int extendedPartNo - ) +ScanForPrimaryPartitions(struct DriveParamS * driveParam, int scan_type, + struct PartTableEntry * pEntry, ULONG startSector, + int partitionsToIgnore, int extendedPartNo) { - int i; - struct CHS chs,end; - ULONG partitionStart; - char partitionName[12]; - - - for (i = 0; i < 4; i++,pEntry++) - { - if (pEntry->FileSystem == 0) - continue; - - if (partitionsToIgnore & (1 << i)) - continue; - - - if (IsExtPartition(pEntry->FileSystem)) - continue; - - if (scan_type == SCAN_PRIMARYBOOT && !pEntry->Bootable) - continue; - - - partitionStart = startSector + pEntry->RelSect; - - if (!IsFATPartition(pEntry->FileSystem)) - { - continue; - } + int i; + struct CHS chs, end; + ULONG partitionStart; + char partitionName[12]; + for (i = 0; i < 4; i++, pEntry++) + { + if (pEntry->FileSystem == 0) + continue; - - if (extendedPartNo) sprintf(partitionName, "Ext:%d", extendedPartNo); - else sprintf(partitionName, "Pri:%d",i+1); + if (partitionsToIgnore & (1 << i)) + continue; + if (IsExtPartition(pEntry->FileSystem)) + continue; - /* - some sanity checks, that partition - structure is OK - */ - LBA_to_CHS(&chs, partitionStart,driveParam); - LBA_to_CHS(&end, partitionStart+pEntry->NumSect-1,driveParam); + if (scan_type == SCAN_PRIMARYBOOT && !pEntry->Bootable) + continue; + partitionStart = startSector + pEntry->RelSect; - /* some FDISK's enter for partitions - > 8 GB cyl = 1023, other (cyl&1023) - */ + if (!IsFATPartition(pEntry->FileSystem)) + { + continue; + } - if ( ((chs.Cylinder & 0x3ff) != pEntry->Begin.Cylinder && - 1023 != pEntry->Begin.Cylinder ) || - chs.Head != pEntry->Begin.Head || - chs.Sector != pEntry->Begin.Sector ) - { - printf("WARNING: using suspect partition %s FS %02x:", - partitionName, pEntry->FileSystem); - printCHS(" with calculated values ",&chs); - printCHS(" instead of ",&pEntry->Begin); - printf("\n"); - fmemcpy(&pEntry->Begin, &chs, sizeof(struct CHS)); + if (extendedPartNo) + sprintf(partitionName, "Ext:%d", extendedPartNo); + else + sprintf(partitionName, "Pri:%d", i + 1); - } + /* + some sanity checks, that partition + structure is OK + */ + LBA_to_CHS(&chs, partitionStart, driveParam); + LBA_to_CHS(&end, partitionStart + pEntry->NumSect - 1, driveParam); + + /* some FDISK's enter for partitions + > 8 GB cyl = 1023, other (cyl&1023) + */ + + if (((chs.Cylinder & 0x3ff) != pEntry->Begin.Cylinder && + 1023 != pEntry->Begin.Cylinder) || + chs.Head != pEntry->Begin.Head || + chs.Sector != pEntry->Begin.Sector) + { + printf("WARNING: using suspect partition %s FS %02x:", + partitionName, pEntry->FileSystem); + printCHS(" with calculated values ", &chs); + printCHS(" instead of ", &pEntry->Begin); + printf("\n"); + fmemcpy(&pEntry->Begin, &chs, sizeof(struct CHS)); + } - if (((end.Cylinder & 0x3ff) != pEntry->End.Cylinder && - 1023 != pEntry->End.Cylinder ) || - end.Head != pEntry->End.Head || - end.Sector != pEntry->End.Sector ) - { - if (pEntry->NumSect == 0) - { - printf("Not using partition %s with 0 sectors\n", partitionName); - continue; - } - - printf("WARNING: using suspect partition %s FS %02x:", - partitionName, pEntry->FileSystem); + if (((end.Cylinder & 0x3ff) != pEntry->End.Cylinder && + 1023 != pEntry->End.Cylinder) || + end.Head != pEntry->End.Head || end.Sector != pEntry->End.Sector) + { + if (pEntry->NumSect == 0) + { + printf("Not using partition %s with 0 sectors\n", partitionName); + continue; + } - printCHS(" with calculated values ",&end); - printCHS(" instead of ",&pEntry->End); - printf("\n"); - fmemcpy(&pEntry->End, &end, sizeof(struct CHS)); + printf("WARNING: using suspect partition %s FS %02x:", + partitionName, pEntry->FileSystem); - } + printCHS(" with calculated values ", &end); + printCHS(" instead of ", &pEntry->End); + printf("\n"); + fmemcpy(&pEntry->End, &end, sizeof(struct CHS)); + } - if (chs.Cylinder > 1023 || end.Cylinder > 1023) - { + if (chs.Cylinder > 1023 || end.Cylinder > 1023) + { - if (!driveParam->LBA_supported) - { - printf("can't use LBA partition without LBA support - part %s FS %02x", - partitionName, pEntry->FileSystem); - - printCHS(" start ",&chs); - printCHS(", end ", &end); - printf("\n"); - - continue; - } - - if (!InitKernelConfig.ForceLBA && !IsLBAPartition(pEntry->FileSystem)) - { - printf("WARNING: Partition ID does not suggest LBA - part %s FS %02x.\n" - "Please run FDISK to correct this - using LBA to access partition.\n", - partitionName, pEntry->FileSystem); - - printCHS(" start ",&chs); - printCHS(", end ", &end); - printf("\n"); - pEntry->FileSystem = (pEntry->FileSystem == FAT12 ? FAT12_LBA : - pEntry->FileSystem == FAT32 ? FAT32_LBA : - /* pEntry->FileSystem == FAT16 ? */ FAT16_LBA); - } - - /* else its a diagnostic message only */ + if (!driveParam->LBA_supported) + { + printf + ("can't use LBA partition without LBA support - part %s FS %02x", + partitionName, pEntry->FileSystem); + + printCHS(" start ", &chs); + printCHS(", end ", &end); + printf("\n"); + + continue; + } + + if (!InitKernelConfig.ForceLBA + && !IsLBAPartition(pEntry->FileSystem)) + { + printf + ("WARNING: Partition ID does not suggest LBA - part %s FS %02x.\n" + "Please run FDISK to correct this - using LBA to access partition.\n", + partitionName, pEntry->FileSystem); + + printCHS(" start ", &chs); + printCHS(", end ", &end); + printf("\n"); + pEntry->FileSystem = (pEntry->FileSystem == FAT12 ? FAT12_LBA : + pEntry->FileSystem == FAT32 ? FAT32_LBA : + /* pEntry->FileSystem == FAT16 ? */ + FAT16_LBA); + } + + /* else its a diagnostic message only */ #ifdef DEBUG - printf("found and using LBA partition %s FS %02x", - partitionName, pEntry->FileSystem); - printCHS(" start ",&chs); - printCHS(", end ", &end); - printf("\n"); -#endif - } + printf("found and using LBA partition %s FS %02x", + partitionName, pEntry->FileSystem); + printCHS(" start ", &chs); + printCHS(", end ", &end); + printf("\n"); +#endif + } + /* + here we have a partition table in our hand !! + */ - /* - here we have a partition table in our hand !! - */ + partitionsToIgnore |= 1 << i; - partitionsToIgnore |= 1 << i; - - DosDefinePartition(driveParam,partitionStart, pEntry, - extendedPartNo, i); + DosDefinePartition(driveParam, partitionStart, pEntry, + extendedPartNo, i); - if (scan_type == SCAN_PRIMARYBOOT || - scan_type == SCAN_PRIMARY ) - { - return partitionsToIgnore; - } - } + if (scan_type == SCAN_PRIMARYBOOT || scan_type == SCAN_PRIMARY) + { + return partitionsToIgnore; + } + } - return partitionsToIgnore; + return partitionsToIgnore; } void BIOS_drive_reset(unsigned drive); -int Read1LBASector(struct DriveParamS *driveParam, unsigned drive, ULONG LBA_address, void FAR *buffer) +int Read1LBASector(struct DriveParamS *driveParam, unsigned drive, + ULONG LBA_address, void FAR * buffer) { - static struct _bios_LBA_address_packet dap = { - 16,0,0,0,0,0,0 - }; - - struct CHS chs; - iregs regs; - int num_retries; + static struct _bios_LBA_address_packet dap = { + 16, 0, 0, 0, 0, 0, 0 + }; + + struct CHS chs; + iregs regs; + int num_retries; /* disabled because this should not happen and if it happens the BIOS should complain; also there are weird disks around with CMOS geometry < real geometry */ #if 0 - if (LBA_address >= driveParam->total_sectors) - { - printf("LBA-Transfer error : address overflow = %lu > %lu max\n",LBA_address+1,driveParam->total_sectors); - return 1; - } + if (LBA_address >= driveParam->total_sectors) + { + printf("LBA-Transfer error : address overflow = %lu > %lu max\n", + LBA_address + 1, driveParam->total_sectors); + return 1; + } #endif - for ( num_retries = 0; num_retries < N_RETRY; num_retries++) - { - regs.d.b.l = drive | 0x80; - if (driveParam->LBA_supported) - { - dap.number_of_blocks = 1; - dap.buffer_address = buffer; - dap.block_address_high = 0; /* clear high part */ - dap.block_address = LBA_address; /* clear high part */ - - /* Load the registers and call the interrupt. */ - regs.a.x = LBA_READ; - regs.si = FP_OFF(&dap); - regs.ds = FP_SEG(&dap); - } - else - { /* transfer data, using old bios functions */ - init_LBA_to_CHS(&chs, LBA_address, driveParam); - /* avoid overflow at end of track */ - - if (chs.Cylinder > 1023) - { - printf("LBA-Transfer error : cylinder %u > 1023\n", chs.Cylinder); - return 1; - } - - regs.a.x = 0x0201; - regs.b.x = FP_OFF(buffer); - regs.c.x = ((chs.Cylinder&0xff) << 8) + ((chs.Cylinder&0x300) >> 2) + chs.Sector; - regs.d.b.h = chs.Head; - regs.es = FP_SEG(buffer); - } /* end of retries */ - init_call_intr(0x13, ®s); - if ((regs.flags & FLG_CARRY) == 0) break; - BIOS_drive_reset(driveParam->driveno); - } + for (num_retries = 0; num_retries < N_RETRY; num_retries++) + { + regs.d.b.l = drive | 0x80; + if (driveParam->LBA_supported) + { + dap.number_of_blocks = 1; + dap.buffer_address = buffer; + dap.block_address_high = 0; /* clear high part */ + dap.block_address = LBA_address; /* clear high part */ + + /* Load the registers and call the interrupt. */ + regs.a.x = LBA_READ; + regs.si = FP_OFF(&dap); + regs.ds = FP_SEG(&dap); + } + else + { /* transfer data, using old bios functions */ + init_LBA_to_CHS(&chs, LBA_address, driveParam); + /* avoid overflow at end of track */ - return regs.flags & FLG_CARRY ? 1 : 0; -} + if (chs.Cylinder > 1023) + { + printf("LBA-Transfer error : cylinder %u > 1023\n", chs.Cylinder); + return 1; + } + + regs.a.x = 0x0201; + regs.b.x = FP_OFF(buffer); + regs.c.x = + ((chs.Cylinder & 0xff) << 8) + ((chs.Cylinder & 0x300) >> 2) + + chs.Sector; + regs.d.b.h = chs.Head; + regs.es = FP_SEG(buffer); + } /* end of retries */ + init_call_intr(0x13, ®s); + if ((regs.flags & FLG_CARRY) == 0) + break; + BIOS_drive_reset(driveParam->driveno); + } + + return regs.flags & FLG_CARRY ? 1 : 0; +} /* Load the Partition Tables and get information on all drives */ int ProcessDisk(int scanType, unsigned drive, int PartitionsToIgnore) { - struct PartTableEntry PTable[4]; - ULONG RelSectorOffset; - ULONG ExtendedPartitionOffset; - int iPart; - int strangeHardwareLoop; - - int num_extended_found = 0; - - struct DriveParamS driveParam; + struct PartTableEntry PTable[4]; + ULONG RelSectorOffset; + ULONG ExtendedPartitionOffset; + int iPart; + int strangeHardwareLoop; - /* Get the hard drive parameters and ensure that the drive exists. */ - /* If there was an error accessing the drive, skip that drive. */ + int num_extended_found = 0; - memset(&driveParam, 0, sizeof(driveParam)); - - if (!LBA_Get_Drive_Parameters(drive,&driveParam)) - { - printf("can't get drive parameters for drive %02x\n",drive); - return PartitionsToIgnore; - } + struct DriveParamS driveParam; - RelSectorOffset = 0; /* boot sector */ - ExtendedPartitionOffset = 0; /* not found yet */ + /* Get the hard drive parameters and ensure that the drive exists. */ + /* If there was an error accessing the drive, skip that drive. */ + memset(&driveParam, 0, sizeof(driveParam)); + if (!LBA_Get_Drive_Parameters(drive, &driveParam)) + { + printf("can't get drive parameters for drive %02x\n", drive); + return PartitionsToIgnore; + } - /* Read the Primary Partition Table. */ + RelSectorOffset = 0; /* boot sector */ + ExtendedPartitionOffset = 0; /* not found yet */ + /* Read the Primary Partition Table. */ ReadNextPartitionTable: - strangeHardwareLoop = 0; + strangeHardwareLoop = 0; strange_restart: + if (Read1LBASector + (&driveParam, drive, RelSectorOffset, DiskTransferBuffer)) + { + printf("Error reading partition table drive %02x sector %lu", drive, + RelSectorOffset); + return PartitionsToIgnore; + } - if (Read1LBASector(&driveParam, drive, RelSectorOffset, DiskTransferBuffer)) - { - printf("Error reading partition table drive %02x sector %lu",drive,RelSectorOffset); - return PartitionsToIgnore; - } + if (!ConvPartTableEntryToIntern(PTable, DiskTransferBuffer)) + { + /* there is some strange hardware out in the world, + which returns OK on first read, but the data are + rubbish. simply retrying works fine. + there is no logic behind this, but it works TE */ - if (!ConvPartTableEntryToIntern(PTable, DiskTransferBuffer)) - { - /* there is some strange hardware out in the world, - which returns OK on first read, but the data are - rubbish. simply retrying works fine. - there is no logic behind this, but it works TE */ - - if (++strangeHardwareLoop < 3) - goto strange_restart; - - printf("illegal partition table - drive %02x sector %lu\n",drive,RelSectorOffset); - return PartitionsToIgnore; - } + if (++strangeHardwareLoop < 3) + goto strange_restart; - if ( scanType==SCAN_PRIMARYBOOT || - scanType==SCAN_PRIMARY || - scanType==SCAN_PRIMARY2 || - num_extended_found !=0 ) - { + printf("illegal partition table - drive %02x sector %lu\n", drive, + RelSectorOffset); + return PartitionsToIgnore; + } - PartitionsToIgnore = ScanForPrimaryPartitions(&driveParam,scanType, - PTable, RelSectorOffset,PartitionsToIgnore,num_extended_found); - } + if (scanType == SCAN_PRIMARYBOOT || + scanType == SCAN_PRIMARY || + scanType == SCAN_PRIMARY2 || num_extended_found != 0) + { - if (scanType != SCAN_EXTENDED) - { - return PartitionsToIgnore; - } + PartitionsToIgnore = ScanForPrimaryPartitions(&driveParam, scanType, + PTable, RelSectorOffset, + PartitionsToIgnore, + num_extended_found); + } - /* scan for extended partitions now */ - PartitionsToIgnore = 0; + if (scanType != SCAN_EXTENDED) + { + return PartitionsToIgnore; + } + /* scan for extended partitions now */ + PartitionsToIgnore = 0; - for (iPart=0; iPart < 4; iPart++) - { - if (IsExtPartition(PTable[iPart].FileSystem)) - { - RelSectorOffset = ExtendedPartitionOffset + PTable[iPart].RelSect; + for (iPart = 0; iPart < 4; iPart++) + { + if (IsExtPartition(PTable[iPart].FileSystem)) + { + RelSectorOffset = ExtendedPartitionOffset + PTable[iPart].RelSect; - if (ExtendedPartitionOffset == 0) - { - ExtendedPartitionOffset = PTable[iPart].RelSect; - } + if (ExtendedPartitionOffset == 0) + { + ExtendedPartitionOffset = PTable[iPart].RelSect; + } - num_extended_found++; + num_extended_found++; - if (num_extended_found > 30) - { - printf("found more then 30 extended partitions, terminated\n"); - return 0; - } + if (num_extended_found > 30) + { + printf("found more then 30 extended partitions, terminated\n"); + return 0; + } - goto ReadNextPartitionTable; - } + goto ReadNextPartitionTable; } + } - return PartitionsToIgnore; + return PartitionsToIgnore; } - int BIOS_nrdrives(void) { - iregs regs; + iregs regs; - regs.a.b.h = 0x08; - regs.d.b.l = 0x80; - init_call_intr(0x13,®s); + regs.a.b.h = 0x08; + regs.d.b.l = 0x80; + init_call_intr(0x13, ®s); - if (regs.flags & 1) - { - printf("no hard disks detected\n"); - return 0; - } + if (regs.flags & 1) + { + printf("no hard disks detected\n"); + return 0; + } - return regs.d.b.l; + return regs.d.b.l; } void BIOS_drive_reset(unsigned drive) { - iregs regs; - - regs.d.b.l = drive | 0x80; - regs.a.b.h = 0; + iregs regs; - init_call_intr(0x13,®s); + regs.d.b.l = drive | 0x80; + regs.a.b.h = 0; + + init_call_intr(0x13, ®s); } /* @@ -1152,13 +1141,11 @@ starting with any active primary partitions (if there is one), otherwise, scan the first primary partition on each drive. Assign next available letter starting with C: - Repeat scan for all fixed hard disks and removable (JAZ, MO) disks and assign drive letters to all logical drives in an extended partition, or the removable disk(s) as enumerated. Assign next available letter starting with C: - Finally, repeat scan for all fixed hard disk drives, and assign drive letters to all remaining primary partitions. Assign next available letter starting with C: @@ -1179,13 +1166,11 @@ to the first physical floppy disk drive that is found. If a second physical floppy disk drive is present, it is assigned drive letter B. If it is not present, a logical drive B is created that uses the first physical floppy disk drive. - Regardless of whether a second floppy disk drive is present, MS-DOS then assigns the drive letter C to the primary MS-DOS partition on the first physical hard disk, and then goes on to check for a second hard disk. - If a second physical hard disk is found, and a primary partition exists on the second physical drive, the primary MS-DOS partition on the second physical hard drive is assigned the letter D. MS-DOS version 5.0, which @@ -1195,12 +1180,10 @@ hard disk is found, and a primary partition exists on the third physical drive, the primary MS-DOS partition on the third physical hard drive is assigned the letter E. - MS-DOS returns to the first physical hard disk drive and assigns drive letters to any additional logical drives (in extended MS-DOS partitions) on that drive in sequence. - MS-DOS repeats this process for the second physical hard disk drive, if present. MS-DOS 5.0 will repeat this process for up to eight physical hard drives, if present. After all logical drives (in extended MS-DOS @@ -1211,7 +1194,6 @@ additional primary MS-DOS partitions. This support for multiple primary MS-DOS partitions was added to version 5.0 for backward compatibility with the previous OEM MS-DOS versions that support multiple primary partitions. - After all logical drives on the hard disk(s) have been assigned drive letters, drive letters are assigned to drives installed using DRIVER.SYS or created using RAMDRIVE.SYS in the order in which the drivers are loaded @@ -1238,112 +1220,109 @@ I don't know, if I did it right, but I tried to do it that way. TE void ReadAllPartitionTables(void) { - UBYTE foundPartitions[MAX_HARD_DRIVE]; - - int HardDrive; - int nHardDisk = BIOS_nrdrives(); - int Unit; - ddt FAR *pddt; - static iregs regs; + UBYTE foundPartitions[MAX_HARD_DRIVE]; - /* Setup media info and BPBs arrays for floppies */ - for (Unit = 0; Unit < nUnits; Unit++) - { - pddt = DynAlloc("ddt", 1, sizeof(ddt)); - - pddt->ddt_driveno = 0; - pddt->ddt_logdriveno = Unit; - pddt->ddt_type = init_getdriveparm(0, &pddt->ddt_defbpb); - pddt->ddt_ncyl = (pddt->ddt_type & 7) ? 80 : 40; - pddt->ddt_LBASupported = FALSE; - pddt->ddt_descflags = init_readdasd(0); - - pddt->ddt_offset = 0l; - pddt->ddt_serialno = 0x12345678l; - fmemcpy(&pddt->ddt_bpb, &pddt->ddt_defbpb, sizeof(bpb)); - } - - /* - this is a quick patch - see if B: exists - test for A: also, need not exist - */ - init_call_intr(0x11,®s); /* get equipment list */ - if ((regs.a.x & 1) && (regs.a.x & 0xc0)) { - pddt->ddt_driveno = 1; - pddt->ddt_type = init_getdriveparm(1, &pddt->ddt_defbpb); - pddt->ddt_descflags = init_readdasd(1); - pddt->ddt_ncyl = (pddt->ddt_type & 7) ? 80 : 40; - /* floppy drives installed and a B: drive */ - /*if ((r.a.x & 1)==0) */ /* no floppy drives installed */ - } else { /* set up the DJ method : multiple logical drives */ - (pddt-1)->ddt_descflags |= DF_CURLOG | DF_MULTLOG; - pddt->ddt_descflags |= DF_MULTLOG; - } + int HardDrive; + int nHardDisk = BIOS_nrdrives(); + int Unit; + ddt FAR *pddt; + static iregs regs; - nHardDisk = min(nHardDisk,MAX_HARD_DRIVE-1); + /* Setup media info and BPBs arrays for floppies */ + for (Unit = 0; Unit < nUnits; Unit++) + { + pddt = DynAlloc("ddt", 1, sizeof(ddt)); + + pddt->ddt_driveno = 0; + pddt->ddt_logdriveno = Unit; + pddt->ddt_type = init_getdriveparm(0, &pddt->ddt_defbpb); + pddt->ddt_ncyl = (pddt->ddt_type & 7) ? 80 : 40; + pddt->ddt_LBASupported = FALSE; + pddt->ddt_descflags = init_readdasd(0); + + pddt->ddt_offset = 0l; + pddt->ddt_serialno = 0x12345678l; + fmemcpy(&pddt->ddt_bpb, &pddt->ddt_defbpb, sizeof(bpb)); + } + + /* + this is a quick patch - see if B: exists + test for A: also, need not exist + */ + init_call_intr(0x11, ®s); /* get equipment list */ + if ((regs.a.x & 1) && (regs.a.x & 0xc0)) + { + pddt->ddt_driveno = 1; + pddt->ddt_type = init_getdriveparm(1, &pddt->ddt_defbpb); + pddt->ddt_descflags = init_readdasd(1); + pddt->ddt_ncyl = (pddt->ddt_type & 7) ? 80 : 40; + /* floppy drives installed and a B: drive */ +/*if ((r.a.x & 1)==0) *//* no floppy drives installed */ + } + else + { /* set up the DJ method : multiple logical drives */ + (pddt - 1)->ddt_descflags |= DF_CURLOG | DF_MULTLOG; + pddt->ddt_descflags |= DF_MULTLOG; + } - memset(foundPartitions,0,sizeof(foundPartitions)); + nHardDisk = min(nHardDisk, MAX_HARD_DRIVE - 1); + memset(foundPartitions, 0, sizeof(foundPartitions)); + DebugPrintf(("DSK init: found %d disk drives\n", nHardDisk)); + /* Reset the drives */ + for (HardDrive = 0; HardDrive < nHardDisk; HardDrive++) + BIOS_drive_reset(HardDrive); - DebugPrintf(("DSK init: found %d disk drives\n",nHardDisk)); + if (InitKernelConfig.DLASortByDriveNo == 0) + { + /* printf("Drive Letter Assignment - DOS order \n"); */ - /* Reset the drives */ + /* Process primary partition table 1 partition only */ for (HardDrive = 0; HardDrive < nHardDisk; HardDrive++) - BIOS_drive_reset(HardDrive); - + { + foundPartitions[HardDrive] = + ProcessDisk(SCAN_PRIMARYBOOT, HardDrive, 0); + if (foundPartitions[HardDrive] == 0) + foundPartitions[HardDrive] = + ProcessDisk(SCAN_PRIMARY, HardDrive, 0); + } - if (InitKernelConfig.DLASortByDriveNo == 0) + /* Process extended partition table */ + for (HardDrive = 0; HardDrive < nHardDisk; HardDrive++) { - /* printf("Drive Letter Assignment - DOS order \n"); */ - - - /* Process primary partition table 1 partition only */ - for (HardDrive = 0; HardDrive < nHardDisk; HardDrive++) - { - foundPartitions[HardDrive] = - ProcessDisk(SCAN_PRIMARYBOOT, HardDrive, 0); - - if (foundPartitions[HardDrive] == 0) - foundPartitions[HardDrive] = ProcessDisk(SCAN_PRIMARY, HardDrive, 0); - } - - /* Process extended partition table */ - for (HardDrive = 0; HardDrive < nHardDisk; HardDrive++) - { - ProcessDisk(SCAN_EXTENDED, HardDrive , 0); - } - - /* Process primary a 2nd time */ - for (HardDrive = 0; HardDrive < nHardDisk; HardDrive++) - { - ProcessDisk(SCAN_PRIMARY2, HardDrive ,foundPartitions[HardDrive]); - } + ProcessDisk(SCAN_EXTENDED, HardDrive, 0); } - else + + /* Process primary a 2nd time */ + for (HardDrive = 0; HardDrive < nHardDisk; HardDrive++) { - printf("Drive Letter Assignment - sorted by drive\n"); - - - /* Process primary partition table 1 partition only */ - for (HardDrive = 0; HardDrive < nHardDisk; HardDrive++) - { - foundPartitions[HardDrive] = - ProcessDisk(SCAN_PRIMARYBOOT, HardDrive, 0); - - if (foundPartitions[HardDrive] == 0) - foundPartitions[HardDrive] = ProcessDisk(SCAN_PRIMARY, HardDrive, 0); - - /* Process extended partition table */ - ProcessDisk(SCAN_EXTENDED, HardDrive , 0); + ProcessDisk(SCAN_PRIMARY2, HardDrive, foundPartitions[HardDrive]); + } + } + else + { + printf("Drive Letter Assignment - sorted by drive\n"); - - /* Process primary a 2nd time */ - ProcessDisk(SCAN_PRIMARY2, HardDrive ,foundPartitions[HardDrive]); - } - } + /* Process primary partition table 1 partition only */ + for (HardDrive = 0; HardDrive < nHardDisk; HardDrive++) + { + foundPartitions[HardDrive] = + ProcessDisk(SCAN_PRIMARYBOOT, HardDrive, 0); + + if (foundPartitions[HardDrive] == 0) + foundPartitions[HardDrive] = + ProcessDisk(SCAN_PRIMARY, HardDrive, 0); + + /* Process extended partition table */ + ProcessDisk(SCAN_EXTENDED, HardDrive, 0); + + /* Process primary a 2nd time */ + ProcessDisk(SCAN_PRIMARY2, HardDrive, foundPartitions[HardDrive]); + } + } } /* disk initialization: returns number of units */ @@ -1352,20 +1331,19 @@ COUNT dsk_init() printf(" - InitDisk\n"); #ifdef DEBUG - { + { iregs regs; - regs.a.x = 0x1112; /* select 43 line mode - more space for partinfo */ + regs.a.x = 0x1112; /* select 43 line mode - more space for partinfo */ regs.b.x = 0; init_call_intr(0x10, ®s); - } + } #endif - + /* Reset the drives */ BIOS_drive_reset(0); /* Initial number of disk units */ nUnits = 2; - ReadAllPartitionTables(); diff --git a/kernel/inithma.c b/kernel/inithma.c index a68fcab7..359285df 100644 --- a/kernel/inithma.c +++ b/kernel/inithma.c @@ -63,89 +63,80 @@ parameter is forced. */ - #include "portab.h" #include "init-mod.h" #include "init-dat.h" - - -extern BYTE - FAR _HMATextAvailable, /* first byte of available CODE area */ - FAR _HMATextStart[], /* first byte of HMAable CODE area */ - FAR _HMATextEnd[]; /* and the last byte of it */ +extern BYTE FAR _HMATextAvailable, /* first byte of available CODE area */ + FAR _HMATextStart[], /* first byte of HMAable CODE area */ + FAR _HMATextEnd[]; /* and the last byte of it */ #ifdef VERSION_STRINGS -static BYTE *RcsId = "$Id$"; +static BYTE *RcsId = + "$Id$"; #endif +BYTE DosLoadedInHMA = FALSE; /* set to TRUE if loaded HIGH */ +BYTE HMAclaimed = FALSE; /* set to TRUE if claimed from HIMEM */ +WORD HMAFree = 0; /* first byte in HMA not yet used */ -BYTE DosLoadedInHMA=FALSE; /* set to TRUE if loaded HIGH */ -BYTE HMAclaimed=FALSE; /* set to TRUE if claimed from HIMEM */ -WORD HMAFree = 0; /* first byte in HMA not yet used */ - - -extern BYTE FAR * DOSTEXTFAR ASMCFUNC XMSDriverAddress; +extern BYTE FAR *DOSTEXTFAR ASMCFUNC XMSDriverAddress; extern FAR ASMCFUNC _EnableA20(VOID); extern FAR ASMCFUNC _DisableA20(VOID); - extern void FAR *ASMCFUNC DetectXMSDriver(VOID); -extern int ASMCFUNC init_call_XMScall( void FAR * driverAddress, UWORD ax, UWORD dx); - -#ifdef DEBUG - #ifdef __TURBOC__ - #define int3() __int__(3); - #else - void int3() - { __asm int 3; - } - #endif -#else - #define int3() -#endif +extern int ASMCFUNC init_call_XMScall(void FAR * driverAddress, UWORD ax, + UWORD dx); +#ifdef DEBUG +#ifdef __TURBOC__ +#define int3() __int__(3); +#else +void int3() +{ + __asm int 3; +} +#endif +#else +#define int3() +#endif #ifdef DEBUG - #define HMAInitPrintf(x) printf x +#define HMAInitPrintf(x) printf x #else - #define HMAInitPrintf(x) -#endif +#define HMAInitPrintf(x) +#endif void MoveKernel(unsigned NewKernelSegment); - #ifdef DEBUG -VOID hdump(BYTE FAR *p) +VOID hdump(BYTE FAR * p) { - int loop; - HMAInitPrintf(("%p", p)); - - for (loop = 0; loop < 16; loop++) - HMAInitPrintf(("%02x ", p[loop])); - - printf("\n"); -} + int loop; + HMAInitPrintf(("%p", p)); + + for (loop = 0; loop < 16; loop++) + HMAInitPrintf(("%02x ", p[loop])); + + printf("\n"); +} #else - #define hdump(ptr) -#endif - +#define hdump(ptr) +#endif #define KeyboardShiftState() (*(BYTE FAR *)(MK_FP(0x40,0x17))) - /* of course, this should go to ASMSUPT */ -fmemcmp(BYTE far *s1, BYTE FAR *s2, unsigned len) +fmemcmp(BYTE far * s1, BYTE FAR * s2, unsigned len) { - for ( ; len ; s1++,s2++,--len) - { - if (*s1 - *s2) - return *s1-*s2; - } - return 0; + for (; len; s1++, s2++, --len) + { + if (*s1 - *s2) + return *s1 - *s2; + } + return 0; } - /* this tests, if the HMA area can be enabled. if so, it simply leaves it on @@ -153,38 +144,34 @@ fmemcmp(BYTE far *s1, BYTE FAR *s2, unsigned len) int EnableHMA(VOID) { - - _EnableA20(); - if (fmemcmp(MK_FP(0x0000,0x0000), MK_FP(0xffff,0x0010),128) == 0) - { - printf("HMA can't be enabled\n"); - return FALSE; - } - + _EnableA20(); - _DisableA20(); - - if (fmemcmp(MK_FP(0x0000,0x0000), MK_FP(0xffff,0x0010),128) != 0) - { - printf("HMA can't be disabled - no problem for us\n"); - } - - _EnableA20(); - if (fmemcmp(MK_FP(0x0000,0x0000), MK_FP(0xffff,0x0010),128) == 0) - { - printf("HMA can't be enabled second time\n"); - return FALSE; - } - - HMAInitPrintf(("HMA success - leaving enabled\n")); + if (fmemcmp(MK_FP(0x0000, 0x0000), MK_FP(0xffff, 0x0010), 128) == 0) + { + printf("HMA can't be enabled\n"); + return FALSE; + } - return TRUE; - -} + _DisableA20(); + + if (fmemcmp(MK_FP(0x0000, 0x0000), MK_FP(0xffff, 0x0010), 128) != 0) + { + printf("HMA can't be disabled - no problem for us\n"); + } + _EnableA20(); + if (fmemcmp(MK_FP(0x0000, 0x0000), MK_FP(0xffff, 0x0010), 128) == 0) + { + printf("HMA can't be enabled second time\n"); + return FALSE; + } + HMAInitPrintf(("HMA success - leaving enabled\n")); + return TRUE; + +} /* move the kernel up to high memory @@ -196,70 +183,68 @@ int EnableHMA(VOID) #define HMAOFFSET 0x20 #define HMASEGMENT 0xffff - int MoveKernelToHMA() { - - if (DosLoadedInHMA) - { - return TRUE; - } - if ((XMSDriverAddress = DetectXMSDriver()) == NULL) - return FALSE; - + if (DosLoadedInHMA) + { + return TRUE; + } + + if ((XMSDriverAddress = DetectXMSDriver()) == NULL) + return FALSE; + #ifdef DEBUG - /* A) for debugging purpose, suppress this, - if any shift key is pressed - */ - if (KeyboardShiftState() & 0x0f) - { - printf("Keyboard state is %0x, NOT moving to HMA\n",KeyboardShiftState()); - return FALSE; - } + /* A) for debugging purpose, suppress this, + if any shift key is pressed + */ + if (KeyboardShiftState() & 0x0f) + { + printf("Keyboard state is %0x, NOT moving to HMA\n", + KeyboardShiftState()); + return FALSE; + } #endif - - /* B) check out, if we can have HMA */ - if (!EnableHMA()) - { - printf("Can't enable HMA area (the famous A20), NOT moving to HMA\n"); - - return FALSE; - } + /* B) check out, if we can have HMA */ - /* allocate HMA through XMS driver */ + if (!EnableHMA()) + { + printf("Can't enable HMA area (the famous A20), NOT moving to HMA\n"); - if (HMAclaimed == 0 && - (HMAclaimed = init_call_XMScall( XMSDriverAddress, 0x0100, 0xffff)) == 0) - { - printf("Can't reserve HMA area ??\n"); - - return FALSE; - } - - MoveKernel(0xffff); + return FALSE; + } + /* allocate HMA through XMS driver */ - { - /* E) up to now, nothing really bad was done. - but now, we reuse the HMA area. bad things will happen - - to find bugs early, - cause INT 3 on all accesses to this area - */ - - - DosLoadedInHMA = TRUE; - } - - /* report the fact we are running high thorugh int 21, ax=3306 */ - version_flags |= 0x10; - - return TRUE; - -} + if (HMAclaimed == 0 && + (HMAclaimed = + init_call_XMScall(XMSDriverAddress, 0x0100, 0xffff)) == 0) + { + printf("Can't reserve HMA area ??\n"); + + return FALSE; + } + + MoveKernel(0xffff); + + { + /* E) up to now, nothing really bad was done. + but now, we reuse the HMA area. bad things will happen + to find bugs early, + cause INT 3 on all accesses to this area + */ + + DosLoadedInHMA = TRUE; + } + + /* report the fact we are running high thorugh int 21, ax=3306 */ + version_flags |= 0x10; + + return TRUE; + +} /* not necessary anymore : BO */ /* @@ -271,38 +256,39 @@ int MoveKernelToHMA() */ #if 0 void InstallVDISK(VOID) +{ + static struct { /* Boot-Sektor of a RAM-Disk */ + UBYTE dummy1[3]; /* HIMEM.SYS uses 3, but FDXMS uses 2 */ + char Name[5]; + BYTE dummy2[3]; + WORD BpS; + BYTE dummy3[6]; + WORD Sektoren; + BYTE dummy4; + } VDISK_BOOT_SEKTOR = { { - static struct { /* Boot-Sektor of a RAM-Disk */ - UBYTE dummy1[3]; /* HIMEM.SYS uses 3, but FDXMS uses 2 */ - char Name[5]; - BYTE dummy2[3]; - WORD BpS; - BYTE dummy3[6]; - WORD Sektoren; - BYTE dummy4; - } VDISK_BOOT_SEKTOR = - { - { 0xcf, ' ', ' '}, - { 'V', 'D', 'I', 'S', 'K'}, - { ' ', ' ', ' '}, - 512, - { 'F', 'D', 'O', 'S', ' ', ' '}, - 128, /* 128*512 = 64K */ - ' ' - }; - - if (!DosLoadedInHMA) return; - if (HMAclaimed) return; - - - fmemcpy(MK_FP(0xffff,0x0010), &VDISK_BOOT_SEKTOR, sizeof(VDISK_BOOT_SEKTOR)); - - setvec(0x19, MK_FP(0xffff,0x0010)); /* let INT 19 point to VDISK */ - - *(WORD FAR *)MK_FP(0xffff,0x002e) = 1024+64; - } -#endif + 0xcf, ' ', ' '}, + { + 'V', 'D', 'I', 'S', 'K'}, + { + ' ', ' ', ' '}, 512, + { + 'F', 'D', 'O', 'S', ' ', ' '}, 128, /* 128*512 = 64K */ + ' '}; + if (!DosLoadedInHMA) + return; + if (HMAclaimed) + return; + + fmemcpy(MK_FP(0xffff, 0x0010), &VDISK_BOOT_SEKTOR, + sizeof(VDISK_BOOT_SEKTOR)); + + setvec(0x19, MK_FP(0xffff, 0x0010)); /* let INT 19 point to VDISK */ + + *(WORD FAR *) MK_FP(0xffff, 0x002e) = 1024 + 64; +} +#endif /* this should be called, after each device driver @@ -312,204 +298,210 @@ void InstallVDISK(VOID) will try to grab HMA; on finalize, will install a VDISK -*/ - -#if 0 /* not necessary anymore */ +*/ + +#if 0 /* not necessary anymore */ void HMAconfig(int finalize) { - ClaimHMA(); - - if (finalize) - InstallVDISK(); + ClaimHMA(); + + if (finalize) + InstallVDISK(); } #endif /* this allocates some bytes from the HMA area only available if DOS=HIGH was successful -*/ +*/ VOID FAR *HMAalloc(COUNT bytesToAllocate) { - VOID FAR *HMAptr; - - if (!DosLoadedInHMA) return NULL; + VOID FAR *HMAptr; - if (HMAFree >= 0xfff0 - bytesToAllocate) return NULL; - - HMAptr = MK_FP(0xffff, HMAFree); - - /* align on 16 byte boundary */ - HMAFree = (HMAFree + bytesToAllocate + 0xf) & 0xfff0; + if (!DosLoadedInHMA) + return NULL; - /*printf("HMA allocated %d byte at %x\n", bytesToAllocate, HMAptr); */ - - fmemset( HMAptr,0, bytesToAllocate); - - return HMAptr; -} + if (HMAFree >= 0xfff0 - bytesToAllocate) + return NULL; + + HMAptr = MK_FP(0xffff, HMAFree); + + /* align on 16 byte boundary */ + HMAFree = (HMAFree + bytesToAllocate + 0xf) & 0xfff0; + /*printf("HMA allocated %d byte at %x\n", bytesToAllocate, HMAptr); */ + fmemset(HMAptr, 0, bytesToAllocate); + + return HMAptr; +} unsigned CurrentKernelSegment = 0; void MoveKernel(unsigned NewKernelSegment) { - UBYTE FAR *HMADest; - UBYTE FAR *HMASource; - unsigned len; - - int3(); - if (CurrentKernelSegment == 0) - CurrentKernelSegment = FP_SEG(_HMATextEnd); - - if (CurrentKernelSegment == 0xffff) - return; - - - HMASource = MK_FP(CurrentKernelSegment,(FP_OFF(_HMATextStart) & 0xfff0)); - HMADest = MK_FP(NewKernelSegment,0x0000); - - len = (FP_OFF(_HMATextEnd) | 0x000f) - (FP_OFF(_HMATextStart) & 0xfff0); - - if (NewKernelSegment == 0xffff) - { - HMASource += HMAOFFSET; - HMADest += HMAOFFSET; - len -= HMAOFFSET; - } - - HMAInitPrintf(("HMA moving %p up to %p for %04x bytes\n", - HMASource, HMADest, len)); + UBYTE FAR *HMADest; + UBYTE FAR *HMASource; + unsigned len; - if (NewKernelSegment < CurrentKernelSegment || - NewKernelSegment == 0xffff) - { - unsigned i; UBYTE FAR *s,FAR *d; - - for (i = 0, s = HMASource,d = HMADest; i < len; i++) - d[i] = s[i]; - } - else { - /* might overlap */ - unsigned i; UBYTE FAR *s,FAR *d; - - for (i = len, s = HMASource,d = HMADest; i != 0; i--) - d[i] = s[i]; - } - - HMAFree = FP_OFF(HMADest)+len; /* first free byte after HMA_TEXT */ - + int3(); + if (CurrentKernelSegment == 0) + CurrentKernelSegment = FP_SEG(_HMATextEnd); + + if (CurrentKernelSegment == 0xffff) + return; + + HMASource = + MK_FP(CurrentKernelSegment, (FP_OFF(_HMATextStart) & 0xfff0)); + HMADest = MK_FP(NewKernelSegment, 0x0000); + + len = (FP_OFF(_HMATextEnd) | 0x000f) - (FP_OFF(_HMATextStart) & 0xfff0); + + if (NewKernelSegment == 0xffff) + { + HMASource += HMAOFFSET; + HMADest += HMAOFFSET; + len -= HMAOFFSET; + } + + HMAInitPrintf(("HMA moving %p up to %p for %04x bytes\n", + HMASource, HMADest, len)); + + if (NewKernelSegment < CurrentKernelSegment || + NewKernelSegment == 0xffff) + { + unsigned i; + UBYTE FAR *s, FAR * d; + + for (i = 0, s = HMASource, d = HMADest; i < len; i++) + d[i] = s[i]; + } + else + { + /* might overlap */ + unsigned i; + UBYTE FAR *s, FAR * d; + + for (i = len, s = HMASource, d = HMADest; i != 0; i--) + d[i] = s[i]; + } + + HMAFree = FP_OFF(HMADest) + len; /* first free byte after HMA_TEXT */ + + { + /* D) but it only makes sense, if we can relocate + all our entries to make use of HMA + */ + + /* this is for a + call near enableA20 + jmp far kernelentry + style table + */ + + struct RelocationTable { + UBYTE jmpFar; + UWORD jmpOffset; + UWORD jmpSegment; + UBYTE callNear; + UWORD callOffset; + }; + struct RelocatedEntry { + UBYTE callNear; + UWORD callOffset; + UBYTE jmpFar; + UWORD jmpOffset; + UWORD jmpSegment; + }; + extern struct RelocationTable + DOSTEXTFAR _HMARelocationTableStart[], + DOSTEXTFAR _HMARelocationTableEnd[]; + + struct RelocationTable FAR *rp, rtemp; + + /* verify, that all entries are valid */ + + for (rp = _HMARelocationTableStart; rp < _HMARelocationTableEnd; rp++) { - /* D) but it only makes sense, if we can relocate - all our entries to make use of HMA - */ - - /* this is for a - call near enableA20 - jmp far kernelentry - style table - */ - - struct RelocationTable { - UBYTE jmpFar; - UWORD jmpOffset; - UWORD jmpSegment; - UBYTE callNear; - UWORD callOffset; - }; - struct RelocatedEntry { - UBYTE callNear; - UWORD callOffset; - UBYTE jmpFar; - UWORD jmpOffset; - UWORD jmpSegment; - }; - extern struct RelocationTable - DOSTEXTFAR _HMARelocationTableStart[], - DOSTEXTFAR _HMARelocationTableEnd[]; - - struct RelocationTable FAR *rp, rtemp ; - - /* verify, that all entries are valid */ - - for (rp = _HMARelocationTableStart; rp < _HMARelocationTableEnd; rp++) - { - if (rp->jmpFar != 0xea || /* jmp FAR */ - rp->jmpSegment != CurrentKernelSegment || /* will only relocate HMA_TEXT */ - rp->callNear != 0xe8 || /* call NEAR */ - 0) - { - printf("illegal relocation entry # %d\n",(FP_OFF(rp) - FP_OFF(_HMARelocationTableStart))/sizeof(struct RelocationTable)); - int3(); - goto errorReturn; - } - } - - /* OK, all valid, go to relocate*/ - - for (rp = _HMARelocationTableStart; rp < _HMARelocationTableEnd; rp++) - { - if (NewKernelSegment == 0xffff) - { - struct RelocatedEntry FAR *rel = (struct RelocatedEntry FAR *)rp; - - fmemcpy(&rtemp, rp, sizeof(rtemp)); - - rel->jmpFar = rtemp.jmpFar; - rel->jmpSegment = NewKernelSegment; - rel->jmpOffset = rtemp.jmpOffset; - rel->callNear = rtemp.callNear; - rel->callOffset = rtemp.callOffset+5; /* near calls are relative */ - } - else - rp->jmpSegment = NewKernelSegment; - - } + if (rp->jmpFar != 0xea || /* jmp FAR */ + rp->jmpSegment != CurrentKernelSegment || /* will only relocate HMA_TEXT */ + rp->callNear != 0xe8 || /* call NEAR */ + 0) + { + printf("illegal relocation entry # %d\n", + (FP_OFF(rp) - + FP_OFF(_HMARelocationTableStart)) / + sizeof(struct RelocationTable)); + int3(); + goto errorReturn; + } } + + /* OK, all valid, go to relocate */ + + for (rp = _HMARelocationTableStart; rp < _HMARelocationTableEnd; rp++) { - struct initRelocationTable { - UBYTE callNear; - UWORD callOffset; - UBYTE jmpFar; - UWORD jmpOffset; - UWORD jmpSegment; - }; - extern struct initRelocationTable - _HMAinitRelocationTableStart[], - _HMAinitRelocationTableEnd[]; - struct initRelocationTable *rp; - - /* verify, that all entries are valid */ - - for (rp = _HMAinitRelocationTableStart; rp < _HMAinitRelocationTableEnd; rp++) - { - if ( - rp->callNear != 0xe8 || /* call NEAR */ - rp->jmpFar != 0xea || /* jmp FAR */ - rp->jmpSegment != CurrentKernelSegment || /* will only relocate HMA_TEXT */ - 0) - { - printf("illegal init relocation entry # %d\n", - rp - _HMAinitRelocationTableStart); - goto errorReturn; - } - } - - /* OK, all valid, go to relocate*/ - - for (rp = _HMAinitRelocationTableStart; rp < _HMAinitRelocationTableEnd; rp++) - { - rp->jmpSegment = NewKernelSegment; - } + if (NewKernelSegment == 0xffff) + { + struct RelocatedEntry FAR *rel = (struct RelocatedEntry FAR *)rp; + + fmemcpy(&rtemp, rp, sizeof(rtemp)); + + rel->jmpFar = rtemp.jmpFar; + rel->jmpSegment = NewKernelSegment; + rel->jmpOffset = rtemp.jmpOffset; + rel->callNear = rtemp.callNear; + rel->callOffset = rtemp.callOffset + 5; /* near calls are relative */ + } + else + rp->jmpSegment = NewKernelSegment; + } - - CurrentKernelSegment = NewKernelSegment; - return; - + } + { + struct initRelocationTable { + UBYTE callNear; + UWORD callOffset; + UBYTE jmpFar; + UWORD jmpOffset; + UWORD jmpSegment; + }; + extern struct initRelocationTable + _HMAinitRelocationTableStart[], _HMAinitRelocationTableEnd[]; + struct initRelocationTable *rp; + + /* verify, that all entries are valid */ + + for (rp = _HMAinitRelocationTableStart; + rp < _HMAinitRelocationTableEnd; rp++) + { + if (rp->callNear != 0xe8 || /* call NEAR */ + rp->jmpFar != 0xea || /* jmp FAR */ + rp->jmpSegment != CurrentKernelSegment || /* will only relocate HMA_TEXT */ + 0) + { + printf("illegal init relocation entry # %d\n", + rp - _HMAinitRelocationTableStart); + goto errorReturn; + } + } + + /* OK, all valid, go to relocate */ + + for (rp = _HMAinitRelocationTableStart; + rp < _HMAinitRelocationTableEnd; rp++) + { + rp->jmpSegment = NewKernelSegment; + } + } + + CurrentKernelSegment = NewKernelSegment; + return; + errorReturn: - for (;;); + for (;;) ; } /* diff --git a/kernel/initoem.c b/kernel/initoem.c index 7c0112ce..464a2f0b 100644 --- a/kernel/initoem.c +++ b/kernel/initoem.c @@ -31,7 +31,8 @@ #include "init-mod.h" #ifdef VERSION_STRINGS -static BYTE *RcsId = "$Id$"; +static BYTE *RcsId = + "$Id$"; #endif UWORD init_oem(void) @@ -42,7 +43,7 @@ UWORD init_oem(void) asm { int 0x12; - mov top_k,ax; + mov top_k, ax; } #else __int__(0x12); @@ -94,4 +95,3 @@ UWORD init_oem(void) * Rev 1.0 02 Jul 1995 8:31:54 patv * Initial revision. */ - diff --git a/kernel/inthndlr.c b/kernel/inthndlr.c index 00adcfd8..2e24a5f1 100644 --- a/kernel/inthndlr.c +++ b/kernel/inthndlr.c @@ -32,7 +32,8 @@ #include "globals.h" #ifdef VERSION_STRINGS -BYTE *RcsId = "$Id$"; +BYTE *RcsId = + "$Id$"; #endif #ifdef TSC @@ -40,8 +41,8 @@ static VOID StartTrace(VOID); static bTraceNext = FALSE; #endif -#if 0 /* Very suspicious, passing structure by value?? - Deactivated -- 2000/06/16 ska*/ +#if 0 /* Very suspicious, passing structure by value?? + Deactivated -- 2000/06/16 ska */ /* Special entry for far call into the kernel */ #pragma argsused VOID FAR int21_entry(iregs UserRegs) @@ -51,8 +52,7 @@ VOID FAR int21_entry(iregs UserRegs) #endif /* Structures needed for int 25 / int 26 */ -struct HugeSectorBlock -{ +struct HugeSectorBlock { ULONG blkno; WORD nblks; BYTE FAR *buf; @@ -82,13 +82,12 @@ VOID ASMCFUNC int21_syscall(iregs FAR * irp) break_ena = irp->DL != 0; break; - case 0x02: /* andrew schulman: get/set extended control break */ - { - UBYTE tmp = break_ena; - irp->DL = break_ena; - break_ena = tmp != 0; - } - + case 0x02: /* andrew schulman: get/set extended control break */ + { + UBYTE tmp = break_ena; + irp->DL = break_ena; + break_ena = tmp != 0; + } /* Get Boot Drive */ case 0x05: @@ -100,14 +99,14 @@ VOID ASMCFUNC int21_syscall(iregs FAR * irp) irp->BL = os_major; irp->BH = os_minor; irp->DL = rev_number; - irp->DH = version_flags; /* bit3:runs in ROM,bit 4: runs in HMA*/ + irp->DH = version_flags; /* bit3:runs in ROM,bit 4: runs in HMA */ break; - - case 0x03: /* DOS 7 does not set AL */ - case 0x07: /* neither here */ - default: /* set AL=0xFF as error, NOT carry */ - irp->AL = 0xff; + case 0x03: /* DOS 7 does not set AL */ + case 0x07: /* neither here */ + + default: /* set AL=0xFF as error, NOT carry */ + irp->AL = 0xff; break; /* Toggle DOS-C rdwrblock trace dump */ @@ -153,20 +152,18 @@ VOID ASMCFUNC int21_syscall(iregs FAR * irp) } } - VOID ASMCFUNC int21_service(iregs FAR * r) { COUNT rc = 0; - void FAR *FP_DS_DX = MK_FP(r->DS, r->DX); /* this is saved so often, - that this saves ~100 bytes */ + void FAR *FP_DS_DX = MK_FP(r->DS, r->DX); /* this is saved so often, + that this saves ~100 bytes */ - #define CLEAR_CARRY_FLAG() r->FLAGS &= ~FLG_CARRY #define SET_CARRY_FLAG() r->FLAGS |= FLG_CARRY - ((psp FAR *)MK_FP(cu_psp, 0))->ps_stack = (BYTE FAR *) r; + ((psp FAR *) MK_FP(cu_psp, 0))->ps_stack = (BYTE FAR *) r; -#ifdef DEBUG +#ifdef DEBUG if (bDumpRegs) { fmemcpy(&error_regs, user_r, sizeof(iregs)); @@ -176,9 +173,9 @@ VOID ASMCFUNC int21_service(iregs FAR * r) } #endif - if(r->AH >=0x38 && r->AH <= 0x4F) - CLEAR_CARRY_FLAG(); - /* Clear carry by default for these functions */ + if (r->AH >= 0x38 && r->AH <= 0x4F) + CLEAR_CARRY_FLAG(); + /* Clear carry by default for these functions */ dispatch: @@ -212,11 +209,11 @@ VOID ASMCFUNC int21_service(iregs FAR * r) error_exit: r->AX = -rc; error_out: - CritErrCode = r->AX; /* Maybe set */ + CritErrCode = r->AX; /* Maybe set */ SET_CARRY_FLAG(); break; - /* case 0x00: --> Simulate a DOS-4C-00 */ + /* case 0x00: --> Simulate a DOS-4C-00 */ /* Read Keyboard with Echo */ case 0x01: @@ -231,26 +228,27 @@ VOID ASMCFUNC int21_service(iregs FAR * r) /* Auxiliary Input */ case 0x03: - { - COUNT scratch; - GenericRead(STDAUX, 1, (BYTE FAR *) & r->AL, (COUNT FAR *) & scratch, TRUE); - break; - } + { + COUNT scratch; + GenericRead(STDAUX, 1, (BYTE FAR *) & r->AL, + (COUNT FAR *) & scratch, TRUE); + break; + } /* Auxiliary Output */ case 0x04: - { - COUNT scratch; - DosWrite(STDAUX, 1, (BYTE FAR *) & r->DL, (COUNT FAR *) &scratch); - break; - } + { + COUNT scratch; + DosWrite(STDAUX, 1, (BYTE FAR *) & r->DL, (COUNT FAR *) & scratch); + break; + } /* Print Character */ case 0x05: - { - COUNT scratch; - DosWrite(STDPRN, 1, (BYTE FAR *) & r->DL, (COUNT FAR *) &scratch); - break; - } + { + COUNT scratch; + DosWrite(STDPRN, 1, (BYTE FAR *) & r->DL, (COUNT FAR *) & scratch); + break; + } /* Direct Console I/O */ case 0x06: @@ -281,11 +279,12 @@ VOID ASMCFUNC int21_service(iregs FAR * r) /* Display String */ case 0x09: { - BYTE FAR * q; + BYTE FAR *q; q = FP_DS_DX; while (*q != '$') ++q; - DosWrite(STDOUT, FP_OFF(q) - FP_OFF(FP_DS_DX), FP_DS_DX, (COUNT FAR *) & UnusedRetVal); + DosWrite(STDOUT, FP_OFF(q) - FP_OFF(FP_DS_DX), FP_DS_DX, + (COUNT FAR *) & UnusedRetVal); } r->AL = '$'; break; @@ -401,11 +400,11 @@ VOID ASMCFUNC int21_service(iregs FAR * r) default: #ifdef DEBUG - printf("Unsupported INT21 AH = 0x%x, AL = 0x%x.\n", r->AH, r->AL); + printf("Unsupported INT21 AH = 0x%x, AL = 0x%x.\n", r->AH, r->AL); #endif /* Fall through. */ - /* CP/M compatibility functions */ + /* CP/M compatibility functions */ case 0x18: case 0x1d: case 0x1e: @@ -440,8 +439,7 @@ VOID ASMCFUNC int21_service(iregs FAR * r) FatGetDrvData(0, (UCOUNT FAR *) & r->AX, (UCOUNT FAR *) & r->CX, - (UCOUNT FAR *) & r->DX, - (BYTE FAR **) & p); + (UCOUNT FAR *) & r->DX, (BYTE FAR **) & p); r->DS = FP_SEG(p); r->BX = FP_OFF(p); } @@ -455,8 +453,7 @@ VOID ASMCFUNC int21_service(iregs FAR * r) FatGetDrvData(r->DL, (UCOUNT FAR *) & r->AX, (UCOUNT FAR *) & r->CX, - (UCOUNT FAR *) & r->DX, - (BYTE FAR **) & p); + (UCOUNT FAR *) & r->DX, (BYTE FAR **) & p); r->DS = FP_SEG(p); r->BX = FP_OFF(p); } @@ -542,9 +539,7 @@ VOID ASMCFUNC int21_service(iregs FAR * r) BYTE FAR *lpFileName; lpFileName = MK_FP(r->DS, r->SI); - r->AL = FcbParseFname(r->AL, - &lpFileName, - MK_FP(r->ES, r->DI)); + r->AL = FcbParseFname(r->AL, &lpFileName, MK_FP(r->ES, r->DI)); r->DS = FP_SEG(lpFileName); r->SI = FP_OFF(lpFileName); } @@ -552,38 +547,34 @@ VOID ASMCFUNC int21_service(iregs FAR * r) /* Get Date */ case 0x2a: - DosGetDate( - (BYTE FAR *) & (r->AL), /* WeekDay */ - (BYTE FAR *) & (r->DH), /* Month */ - (BYTE FAR *) & (r->DL), /* MonthDay */ - (COUNT FAR *) & (r->CX)); /* Year */ + DosGetDate((BYTE FAR *) & (r->AL), /* WeekDay */ + (BYTE FAR *) & (r->DH), /* Month */ + (BYTE FAR *) & (r->DL), /* MonthDay */ + (COUNT FAR *) & (r->CX)); /* Year */ break; /* Set Date */ case 0x2b: - rc = DosSetDate( - r->DH, /* Month */ - r->DL, /* MonthDay */ - r->CX); /* Year */ + rc = DosSetDate(r->DH, /* Month */ + r->DL, /* MonthDay */ + r->CX); /* Year */ r->AL = (rc != SUCCESS ? 0xff : 0); break; /* Get Time */ case 0x2c: - DosGetTime( - (BYTE FAR *) & (r->CH), /* Hour */ - (BYTE FAR *) & (r->CL), /* Minutes */ - (BYTE FAR *) & (r->DH), /* Seconds */ - (BYTE FAR *) & (r->DL)); /* Hundredths */ + DosGetTime((BYTE FAR *) & (r->CH), /* Hour */ + (BYTE FAR *) & (r->CL), /* Minutes */ + (BYTE FAR *) & (r->DH), /* Seconds */ + (BYTE FAR *) & (r->DL)); /* Hundredths */ break; /* Set Date */ case 0x2d: - rc = DosSetTime( - r->CH, /* Hour */ - r->CL, /* Minutes */ - r->DH, /* Seconds */ - r->DL); /* Hundredths */ + rc = DosSetTime(r->CH, /* Hour */ + r->CL, /* Minutes */ + r->DH, /* Seconds */ + r->DL); /* Hundredths */ r->AL = (rc != SUCCESS ? 0xff : 0); break; @@ -606,34 +597,33 @@ VOID ASMCFUNC int21_service(iregs FAR * r) r->CH = REVISION_MAJOR; /* JPP */ r->CL = REVISION_MINOR; r->BL = REVISION_SEQ; - - if (ReturnAnyDosVersionExpected) + + if (ReturnAnyDosVersionExpected) { - /* TE for testing purpose only and NOT - to be documented: - return programs, who ask for version == XX.YY - exactly this XX.YY. - this makes most MS programs more happy. - */ + /* TE for testing purpose only and NOT + to be documented: + return programs, who ask for version == XX.YY + exactly this XX.YY. + this makes most MS programs more happy. + */ UBYTE FAR *retp = MK_FP(r->cs, r->ip); - - if ( retp[0] == 0x3d && /* cmp ax, xxyy */ - (retp[3] == 0x75 || retp[3] == 0x74)) /* je/jne error */ + + if (retp[0] == 0x3d && /* cmp ax, xxyy */ + (retp[3] == 0x75 || retp[3] == 0x74)) /* je/jne error */ { - r->AL = retp[1]; - r->AH = retp[2]; + r->AL = retp[1]; + r->AH = retp[2]; } - else if(retp[0] == 0x86 && /* xchg al,ah */ - retp[1] == 0xc4 && - retp[2] == 0x3d && /* cmp ax, xxyy */ - (retp[5] == 0x75 || retp[5] == 0x74)) /* je/jne error */ + else if (retp[0] == 0x86 && /* xchg al,ah */ + retp[1] == 0xc4 && retp[2] == 0x3d && /* cmp ax, xxyy */ + (retp[5] == 0x75 || retp[5] == 0x74)) /* je/jne error */ { - r->AL = retp[4]; - r->AH = retp[3]; - } - + r->AL = retp[4]; + r->AH = retp[3]; + } + } - + break; /* Keep Program (Terminate and stay resident) */ @@ -652,43 +642,44 @@ VOID ASMCFUNC int21_service(iregs FAR * r) /* r->DL is NOT changed by MS 6.22 */ /* INT21/32 is documented to reread the DPB */ { - struct dpb FAR *dpb; - UCOUNT drv = r->DL; - - if (drv == 0 || r->AH == 0x1f) drv = default_drive; - else drv--; + struct dpb FAR *dpb; + UCOUNT drv = r->DL; + + if (drv == 0 || r->AH == 0x1f) + drv = default_drive; + else + drv--; + + if (drv >= lastdrive) + { + r->AL = 0xFF; + CritErrCode = 0x0f; + break; + } + + dpb = CDSp->cds_table[drv].cdsDpb; + if (dpb == 0 || CDSp->cds_table[drv].cdsFlags & CDSNETWDRV) + { + r->AL = 0xFF; + CritErrCode = 0x0f; + break; + } + flush_buffers(dpb->dpb_unit); + dpb->dpb_flags = M_CHANGED; /* force flush and reread of drive BPB/DPB */ - if (drv >= lastdrive) - { - r->AL = 0xFF; - CritErrCode = 0x0f; - break; - } - - dpb = CDSp->cds_table[drv].cdsDpb; - if (dpb == 0 || - CDSp->cds_table[drv].cdsFlags & CDSNETWDRV) - { - r->AL = 0xFF; - CritErrCode = 0x0f; - break; - } - flush_buffers(dpb->dpb_unit); - dpb->dpb_flags = M_CHANGED; /* force flush and reread of drive BPB/DPB */ - #ifdef WITHFAT32 - if (media_check(dpb) < 0 || ISFAT32(dpb)) + if (media_check(dpb) < 0 || ISFAT32(dpb)) #else - if (media_check(dpb) < 0) + if (media_check(dpb) < 0) #endif - { + { r->AL = 0xff; CritErrCode = 0x0f; break; - } - r->DS = FP_SEG(dpb); - r->BX = FP_OFF(dpb); - r->AL = 0; + } + r->DS = FP_SEG(dpb); + r->BX = FP_OFF(dpb); + r->AL = 0; } break; @@ -720,12 +711,10 @@ VOID ASMCFUNC int21_service(iregs FAR * r) /* Dos Get Disk Free Space */ case 0x36: - DosGetFree( - r->DL, - (UCOUNT FAR *) & r->AX, - (UCOUNT FAR *) & r->BX, - (UCOUNT FAR *) & r->CX, - (UCOUNT FAR *) & r->DX); + DosGetFree(r->DL, + (UCOUNT FAR *) & r->AX, + (UCOUNT FAR *) & r->BX, + (UCOUNT FAR *) & r->CX, (UCOUNT FAR *) & r->DX); break; /* Undocumented Get/Set Switchar */ @@ -752,26 +741,29 @@ VOID ASMCFUNC int21_service(iregs FAR * r) /* Get/Set Country Info */ case 0x38: { - UWORD cntry = r->AL; - - if(cntry == 0) - cntry = (UWORD)-1; - else if(cntry == 0xff) - cntry = r->BX; - - if (0xffff == r->DX) { - /* Set Country Code */ - if((rc = DosSetCountry(cntry)) < 0) - goto error_invalid; - } else { - /* Get Country Information */ - if((rc = DosGetCountryInformation(cntry, FP_DS_DX)) < 0) - goto error_invalid; - /* HACK FIXME */ - if(cntry == (UWORD)-1) - cntry = 1; - /* END OF HACK */ - r->AX = r->BX = cntry; + UWORD cntry = r->AL; + + if (cntry == 0) + cntry = (UWORD) - 1; + else if (cntry == 0xff) + cntry = r->BX; + + if (0xffff == r->DX) + { + /* Set Country Code */ + if ((rc = DosSetCountry(cntry)) < 0) + goto error_invalid; + } + else + { + /* Get Country Information */ + if ((rc = DosGetCountryInformation(cntry, FP_DS_DX)) < 0) + goto error_invalid; + /* HACK FIXME */ + if (cntry == (UWORD) - 1) + cntry = 1; + /* END OF HACK */ + r->AX = r->BX = cntry; } } break; @@ -842,14 +834,16 @@ VOID ASMCFUNC int21_service(iregs FAR * r) /* Dos Seek */ case 0x42: { - ULONG lrc; - if ((rc = DosSeek(r->BX, (LONG) ((((LONG) (r->CX)) << 16) | r->DX), r->AL, &lrc)) < 0) - goto error_exit; - else - { - r->DX = (lrc >> 16); - r->AX = (UWORD)lrc; - } + ULONG lrc; + if ((rc = + DosSeek(r->BX, (LONG) ((((LONG) (r->CX)) << 16) | r->DX), + r->AL, &lrc)) < 0) + goto error_exit; + else + { + r->DX = (lrc >> 16); + r->AX = (UWORD) lrc; + } } break; @@ -860,7 +854,7 @@ VOID ASMCFUNC int21_service(iregs FAR * r) case 0x00: rc = DosGetFattr((BYTE FAR *) FP_DS_DX); if (rc >= SUCCESS) - r->CX = rc; + r->CX = rc; break; case 0x01: @@ -876,7 +870,7 @@ VOID ASMCFUNC int21_service(iregs FAR * r) /* Device I/O Control */ case 0x44: - rc = DosDevIOctl(r); /* can set critical error code! */ + rc = DosDevIOctl(r); /* can set critical error code! */ if (rc != SUCCESS) { @@ -913,7 +907,8 @@ VOID ASMCFUNC int21_service(iregs FAR * r) /* Allocate memory */ case 0x48: - if ((rc = DosMemAlloc(r->BX, mem_access_mode, &(r->AX), &(r->BX))) < 0) + if ((rc = + DosMemAlloc(r->BX, mem_access_mode, &(r->AX), &(r->BX))) < 0) { DosMemLargest(&(r->BX)); goto error_exit; @@ -958,8 +953,7 @@ VOID ASMCFUNC int21_service(iregs FAR * r) case 0x4b: break_flg = FALSE; - if ((rc = DosExec(r->AL, MK_FP(r->ES, r->BX), FP_DS_DX)) - != SUCCESS) + if ((rc = DosExec(r->AL, MK_FP(r->ES, r->BX), FP_DS_DX)) != SUCCESS) goto error_exit; break; @@ -1038,13 +1032,14 @@ VOID ASMCFUNC int21_service(iregs FAR * r) case 0x53: /* DOS 2+ internal - TRANSLATE BIOS PARAMETER BLOCK TO DRIVE PARAM BLOCK */ - bpb_to_dpb((bpb FAR *)MK_FP(r->DS, r->SI), (struct dpb FAR *)MK_FP(r->ES, r->BP) + bpb_to_dpb((bpb FAR *) MK_FP(r->DS, r->SI), + (struct dpb FAR *)MK_FP(r->ES, r->BP) #ifdef WITHFAT32 - ,(r->CX == 0x4558 && r->DX == 0x4152) + , (r->CX == 0x4558 && r->DX == 0x4152) #endif - ); + ); break; - + /* Get verify state */ case 0x54: r->AL = (verify_ena ? TRUE : FALSE); @@ -1059,7 +1054,8 @@ VOID ASMCFUNC int21_service(iregs FAR * r) /* Dos Rename */ case 0x56: - rc = DosRename((BYTE FAR *) FP_DS_DX, (BYTE FAR *) MK_FP(r->ES, r->DI)); + rc = DosRename((BYTE FAR *) FP_DS_DX, + (BYTE FAR *) MK_FP(r->ES, r->DI)); if (rc < SUCCESS) goto error_exit; else @@ -1072,19 +1068,17 @@ VOID ASMCFUNC int21_service(iregs FAR * r) switch (r->AL) { case 0x00: - rc = DosGetFtime( - (COUNT) r->BX, /* Handle */ - (date FAR *) & r->DX, /* FileDate */ - (time FAR *) & r->CX); /* FileTime */ + rc = DosGetFtime((COUNT) r->BX, /* Handle */ + (date FAR *) & r->DX, /* FileDate */ + (time FAR *) & r->CX); /* FileTime */ if (rc < SUCCESS) goto error_exit; break; case 0x01: - rc = DosSetFtime( - (COUNT) r->BX, /* Handle */ - (date) r->DX, /* FileDate */ - (time) r->CX); /* FileTime */ + rc = DosSetFtime((COUNT) r->BX, /* Handle */ + (date) r->DX, /* FileDate */ + (time) r->CX); /* FileTime */ if (rc < SUCCESS) goto error_exit; break; @@ -1105,38 +1099,38 @@ VOID ASMCFUNC int21_service(iregs FAR * r) break; case 0x01: - { + { switch (r->BL) { - case LAST_FIT: - case LAST_FIT_U: - case LAST_FIT_UO: - case BEST_FIT: - case BEST_FIT_U: - case BEST_FIT_UO: - case FIRST_FIT: - case FIRST_FIT_U: - case FIRST_FIT_UO: + case LAST_FIT: + case LAST_FIT_U: + case LAST_FIT_UO: + case BEST_FIT: + case BEST_FIT_U: + case BEST_FIT_UO: + case FIRST_FIT: + case FIRST_FIT_U: + case FIRST_FIT_UO: mem_access_mode = r->BL; break; - default: + default: goto error_invalid; } - } - break; + } + break; case 0x02: - r->AL = uppermem_link; - break; + r->AL = uppermem_link; + break; case 0x03: - if (uppermem_root) /* always error if not exists */ - { - DosUmbLink(r->BL); - break; - } - /* else fall through */ + if (uppermem_root) /* always error if not exists */ + { + DosUmbLink(r->BL); + break; + } + /* else fall through */ default: goto error_invalid; @@ -1150,13 +1144,13 @@ VOID ASMCFUNC int21_service(iregs FAR * r) /* Get Extended Error */ case 0x59: - r->AX = CritErrCode; - r->ES = FP_SEG(CritErrDev); - r->DI = FP_OFF(CritErrDev); - r->CH = CritErrLocus; - r->BH = CritErrClass; - r->BL = CritErrAction; - CLEAR_CARRY_FLAG(); + r->AX = CritErrCode; + r->ES = FP_SEG(CritErrDev); + r->DI = FP_OFF(CritErrDev); + r->CH = CritErrLocus; + r->BH = CritErrClass; + r->BL = CritErrAction; + CLEAR_CARRY_FLAG(); break; /* Create Temporary File */ @@ -1194,11 +1188,13 @@ VOID ASMCFUNC int21_service(iregs FAR * r) /* Lock/unlock file access */ case 0x5c: if ((rc = DosLockUnlock - (r->BX, - (((unsigned long)r->CX)<<16)|(((unsigned long)r->DX)&0xffffL), - (((unsigned long)r->SI)<<16)|(((unsigned long)r->DI)&0xffffL), - ((r->AX & 0xff) != 0))) != 0) - goto error_exit; + (r->BX, + (((unsigned long)r->CX) << 16) | (((unsigned long)r-> + DX) & 0xffffL), + (((unsigned long)r->SI) << 16) | (((unsigned long)r-> + DI) & 0xffffL), + ((r->AX & 0xff) != 0))) != 0) + goto error_exit; CLEAR_CARRY_FLAG(); break; /* /// End of additions for SHARE. - Ron Cemer */ @@ -1233,8 +1229,8 @@ VOID ASMCFUNC int21_service(iregs FAR * r) case 0x07: case 0x08: case 0x09: - rc = remote_printredir(r->DX, Int21AX); - if (rc != SUCCESS) + rc = remote_printredir(r->DX, Int21AX); + if (rc != SUCCESS) goto error_exit; CLEAR_CARRY_FLAG(); break; @@ -1256,9 +1252,11 @@ VOID ASMCFUNC int21_service(iregs FAR * r) break; default: - rc = remote_printset(r->BX, r->CX, r->DX, (MK_FP(r->ES, r->DI)), r->SI, (MK_FP(r->DS, Int21AX))); - if (rc != SUCCESS) goto error_exit; - r->AX=SUCCESS; + rc = remote_printset(r->BX, r->CX, r->DX, (MK_FP(r->ES, r->DI)), + r->SI, (MK_FP(r->DS, Int21AX))); + if (rc != SUCCESS) + goto error_exit; + r->AX = SUCCESS; break; } break; @@ -1268,15 +1266,17 @@ VOID ASMCFUNC int21_service(iregs FAR * r) switch (r->AL) { case 0x07: - if (r->DL < lastdrive) { + if (r->DL < lastdrive) + { CDSp->cds_table[r->DL].cdsFlags |= 0x100; - } + } break; case 0x08: - if (r->DL < lastdrive) { + if (r->DL < lastdrive) + { CDSp->cds_table[r->DL].cdsFlags &= ~0x100; - } + } break; default: @@ -1286,10 +1286,11 @@ VOID ASMCFUNC int21_service(iregs FAR * r) break;*/ rc = remote_doredirect(r->BX, r->CX, r->DX, - (MK_FP(r->ES, r->DI)), r->SI, (MK_FP(r->DS, Int21AX))); - if (rc != SUCCESS) + (MK_FP(r->ES, r->DI)), r->SI, + (MK_FP(r->DS, Int21AX))); + if (rc != SUCCESS) goto error_exit; - r->AX=SUCCESS; + r->AX = SUCCESS; break; } break; @@ -1297,7 +1298,8 @@ VOID ASMCFUNC int21_service(iregs FAR * r) case 0x60: /* TRUENAME */ CLEAR_CARRY_FLAG(); if ((rc = truename(MK_FP(r->DS, r->SI), - adjust_far(MK_FP(r->ES, r->DI)), FALSE)) != SUCCESS) + adjust_far(MK_FP(r->ES, r->DI)), + FALSE)) != SUCCESS) goto error_exit; break; @@ -1323,96 +1325,96 @@ VOID ASMCFUNC int21_service(iregs FAR * r) #endif /* UNDOCUMENTED: return current psp - case 0x62: is in int21_syscall - r->BX = cu_psp; - break; - */ - + case 0x62: is in int21_syscall + r->BX = cu_psp; + break; + */ + /* UNDOCUMENTED: Double byte and korean tables */ case 0x63: { - static char dbcsTable[4] = - { + static char dbcsTable[4] = { 0, 0, 0, 0 }; r->DS = FP_SEG(&dbcsTable); r->SI = FP_OFF(&dbcsTable); #if 0 /* not really supported, but will pass. */ - r->AL = 0x00; /*jpp: according to interrupt list */ - /*Bart: fails for PQDI and WATCOM utilities: - use the above again */ + r->AL = 0x00; /*jpp: according to interrupt list */ + /*Bart: fails for PQDI and WATCOM utilities: + use the above again */ #endif break; } /* case 0x64: see above (invalid) -*/ +*/ /* Extended country info */ case 0x65: - switch(r->AL) { - case 0x20: /* upcase single character */ - r->DL = DosUpChar(r->DL); - break; - case 0x21: /* upcase memory area */ - DosUpMem(FP_DS_DX, r->CX); - break; - case 0x22: /* upcase ASCIZ */ - DosUpString(FP_DS_DX); - break; - case 0xA0: /* upcase single character of filenames */ - r->DL = DosUpFChar(r->DL); - break; - case 0xA1: /* upcase memory area of filenames */ - DosUpFMem(FP_DS_DX, r->CX); - break; - case 0xA2: /* upcase ASCIZ of filenames */ - DosUpFString(FP_DS_DX); - break; - case 0x23: /* check Yes/No response */ - r->AX = DosYesNo(r->DL); - break; - default: - if ((rc = DosGetData( - r->AL, r->BX, r->DX, r->CX, - MK_FP(r->ES, r->DI))) < 0) { + switch (r->AL) + { + case 0x20: /* upcase single character */ + r->DL = DosUpChar(r->DL); + break; + case 0x21: /* upcase memory area */ + DosUpMem(FP_DS_DX, r->CX); + break; + case 0x22: /* upcase ASCIZ */ + DosUpString(FP_DS_DX); + break; + case 0xA0: /* upcase single character of filenames */ + r->DL = DosUpFChar(r->DL); + break; + case 0xA1: /* upcase memory area of filenames */ + DosUpFMem(FP_DS_DX, r->CX); + break; + case 0xA2: /* upcase ASCIZ of filenames */ + DosUpFString(FP_DS_DX); + break; + case 0x23: /* check Yes/No response */ + r->AX = DosYesNo(r->DL); + break; + default: + if ((rc = DosGetData(r->AL, r->BX, r->DX, r->CX, + MK_FP(r->ES, r->DI))) < 0) + { #ifdef NLS_DEBUG - printf("DosGetData() := %d\n", rc); + printf("DosGetData() := %d\n", rc); #endif - goto error_exit; - } + goto error_exit; + } #ifdef NLS_DEBUG - printf("DosGetData() returned successfully\n", rc); + printf("DosGetData() returned successfully\n", rc); #endif - break; - } - CLEAR_CARRY_FLAG(); + break; + } + CLEAR_CARRY_FLAG(); break; - /* Code Page functions */ - case 0x66: { - int rc; - switch (r->AL) + case 0x66: { - case 1: - rc = DosGetCodepage(&r->BX, &r->DX); - break; - case 2: - rc = DosSetCodepage(r->BX, r->DX); - break; + int rc; + switch (r->AL) + { + case 1: + rc = DosGetCodepage(&r->BX, &r->DX); + break; + case 2: + rc = DosSetCodepage(r->BX, r->DX); + break; - default: - goto error_invalid; + default: + goto error_invalid; + } + if (rc != SUCCESS) + goto error_exit; + CLEAR_CARRY_FLAG(); + break; } - if(rc != SUCCESS) - goto error_exit; - CLEAR_CARRY_FLAG(); - break; - } /* Set Max file handle count */ case 0x67: @@ -1434,17 +1436,19 @@ VOID ASMCFUNC int21_service(iregs FAR * r) if (rc < lastdrive) { UWORD saveCX = r->CX; - if (CDSp->cds_table[rc].cdsFlags & CDSNETWDRV) { + if (CDSp->cds_table[rc].cdsFlags & CDSNETWDRV) + { goto error_invalid; } - switch(r->AL){ - case 0x00: + switch (r->AL) + { + case 0x00: r->AL = 0x0d; r->CX = 0x0866; rc = DosDevIOctl(r); break; - case 0x01: + case 0x01: r->AL = 0x0d; r->CX = 0x0846; rc = DosDevIOctl(r); @@ -1462,136 +1466,140 @@ VOID ASMCFUNC int21_service(iregs FAR * r) /* case 0x6a: see case 0x68 case 0x6b: dummy func: return AL=0 -*/ - /* Extended Open-Creat, not fully functional. (bits 4,5,6 of BH) */ - case 0x6c: +*/ + /* Extended Open-Creat, not fully functional. (bits 4,5,6 of BH) */ + case 0x6c: { COUNT x = 0; - + if (r->AL != 0 || r->DH != 0 || - (r->DL&0x0f) > 0x2 || (r->DL&0xf0) > 0x10) - goto error_invalid; + (r->DL & 0x0f) > 0x2 || (r->DL & 0xf0) > 0x10) + goto error_invalid; CLEAR_CARRY_FLAG(); if ((rc = DosOpen(MK_FP(r->DS, r->SI), - (r->DL&0x0f) == 0x1 ? r->BL : 0)) < 0) + (r->DL & 0x0f) == 0x1 ? r->BL : 0)) < 0) { - if (r->DL < 0x10) - goto error_exit; - /* else try to create below */ - } - else switch (r->DL & 0x0f) - { - case 0x0: - /* fail if file exists */ - DosClose(rc); - rc = DE_FILEEXISTS; + if (r->DL < 0x10) goto error_exit; - case 0x1: - /* file exists and opened: OK */ - r->CX = 0x01; - goto break_out; - case 0x2: - /* file exists: replace/open */ - DosClose(rc); - x = 1; - break; + /* else try to create below */ } + else + switch (r->DL & 0x0f) + { + case 0x0: + /* fail if file exists */ + DosClose(rc); + rc = DE_FILEEXISTS; + goto error_exit; + case 0x1: + /* file exists and opened: OK */ + r->CX = 0x01; + goto break_out; + case 0x2: + /* file exists: replace/open */ + DosClose(rc); + x = 1; + break; + } /* cases 0x00, 0x01 are finished now */ if ((rc = DosCreat(MK_FP(r->DS, r->SI), r->CX)) < 0) - goto error_exit; - - r->CX = x+2; -break_out: + goto error_exit; + + r->CX = x + 2; + break_out: r->AX = rc; break; } - /* case 0x6d and above not implemented : see default; return AL=0 */ + /* case 0x6d and above not implemented : see default; return AL=0 */ #ifdef WITHFAT32 - /* DOS 7.0+ FAT32 extended funcitons */ - case 0x73: - { - switch(r->AL) - { - /* Get extended drive parameter block */ - case 0x02: - { - struct xdpbdata FAR *xddp = (struct xdpbdata FAR *)MK_FP(r->ES, r->DI); - struct dpb FAR *dpb; - - if (r->CX < sizeof(struct xdpbdata)) - { - r->AX = -DE_INVLDBUF; - goto error_out; - } + /* DOS 7.0+ FAT32 extended funcitons */ + case 0x73: + { + switch (r->AL) + { + /* Get extended drive parameter block */ + case 0x02: + { + struct xdpbdata FAR *xddp = + (struct xdpbdata FAR *)MK_FP(r->ES, r->DI); + struct dpb FAR *dpb; + + if (r->CX < sizeof(struct xdpbdata)) + { + r->AX = -DE_INVLDBUF; + goto error_out; + } dpb = GetDriveDPB(r->DL, &rc); - if (rc != SUCCESS) goto error_exit; - - flush_buffers(dpb->dpb_unit); - dpb->dpb_flags = M_CHANGED; /* force reread of drive BPB/DPB */ - - if (media_check(dpb) < 0) - { - r->AX = -DE_INVLDDRV; - goto error_out; - } - - fmemcpy(&xddp->xdd_dpb, dpb, sizeof(struct dpb)); - xddp->xdd_dpbsize = sizeof(struct dpb); + if (rc != SUCCESS) + goto error_exit; + + flush_buffers(dpb->dpb_unit); + dpb->dpb_flags = M_CHANGED; /* force reread of drive BPB/DPB */ + + if (media_check(dpb) < 0) + { + r->AX = -DE_INVLDDRV; + goto error_out; + } + + fmemcpy(&xddp->xdd_dpb, dpb, sizeof(struct dpb)); + xddp->xdd_dpbsize = sizeof(struct dpb); CLEAR_CARRY_FLAG(); - break; - } - /* Get extended free drive space */ + break; + } + /* Get extended free drive space */ case 0x03: - { + { struct xfreespace FAR *xfsp = - (struct xfreespace FAR *)MK_FP(r->ES, r->DI); - if (r->CX < sizeof(struct xfreespace)) - { - r->AX = -DE_INVLDBUF; - goto error_out; - } - CLEAR_CARRY_FLAG(); - rc = DosGetExtFree((BYTE FAR *)FP_DS_DX, xfsp); - if (rc != SUCCESS) - goto error_exit; + (struct xfreespace FAR *)MK_FP(r->ES, r->DI); + if (r->CX < sizeof(struct xfreespace)) + { + r->AX = -DE_INVLDBUF; + goto error_out; + } + CLEAR_CARRY_FLAG(); + rc = DosGetExtFree((BYTE FAR *) FP_DS_DX, xfsp); + if (rc != SUCCESS) + goto error_exit; xfsp->xfs_datasize = sizeof(struct xfreespace); xfsp->xfs_version.actual = 0; - break; - } + break; + } /* Set DPB to use for formatting */ case 0x04: { struct xdpbforformat FAR *xdffp = - (struct xdpbforformat FAR *)MK_FP(r->ES, r->DI); + (struct xdpbforformat FAR *)MK_FP(r->ES, r->DI); struct dpb FAR *dpb; - if (r->CX < sizeof(struct xdpbforformat)) - { - r->AX = -DE_INVLDBUF; - goto error_out; - } + if (r->CX < sizeof(struct xdpbforformat)) + { + r->AX = -DE_INVLDBUF; + goto error_out; + } dpb = GetDriveDPB(r->DL, &rc); - if (rc != SUCCESS) goto error_exit; + if (rc != SUCCESS) + goto error_exit; CLEAR_CARRY_FLAG(); xdffp->xdff_datasize = sizeof(struct xdpbforformat); xdffp->xdff_version.actual = 0; - switch ((UWORD)xdffp->xdff_function) - { + switch ((UWORD) xdffp->xdff_function) + { case 0x00: { DWORD nfreeclst = xdffp->xdff_f.setdpbcounts.nfreeclst; DWORD cluster = xdffp->xdff_f.setdpbcounts.cluster; if (ISFAT32(dpb)) { - if ((dpb->dpb_xfsinfosec == 0xffff && (nfreeclst != 0 || - cluster != 0)) || - nfreeclst == 1 || nfreeclst > dpb->dpb_xsize || - cluster == 1 || cluster > dpb->dpb_xsize) + if ((dpb->dpb_xfsinfosec == 0xffff + && (nfreeclst != 0 || cluster != 0)) + || nfreeclst == 1 || nfreeclst > dpb->dpb_xsize + || cluster == 1 || cluster > dpb->dpb_xsize) { r->AX = -DE_INVLDPARM; goto error_out; @@ -1600,10 +1608,10 @@ VOID ASMCFUNC int21_service(iregs FAR * r) dpb->dpb_xcluster = cluster; write_fsinfo(dpb); } - else + else { if (nfreeclst == 1 || nfreeclst > dpb->dpb_size || - cluster == 1 || cluster > dpb->dpb_size) + cluster == 1 || cluster > dpb->dpb_size) { r->AX = -DE_INVLDPARM; goto error_out; @@ -1617,19 +1625,19 @@ VOID ASMCFUNC int21_service(iregs FAR * r) { ddt *pddt = getddt(r->DL); fmemcpy(&pddt->ddt_bpb, xdffp->xdff_f.rebuilddpb.bpbp, - sizeof(bpb)); + sizeof(bpb)); } case 0x02: { -rebuild_dpb: - flush_buffers(dpb->dpb_unit); + rebuild_dpb: + flush_buffers(dpb->dpb_unit); dpb->dpb_flags = M_CHANGED; - + if (media_check(dpb) < 0) - { - r->AX = -DE_INVLDDRV; - goto error_out; - } + { + r->AX = -DE_INVLDDRV; + goto error_out; + } break; } @@ -1637,22 +1645,26 @@ VOID ASMCFUNC int21_service(iregs FAR * r) { struct buffer FAR *bp; bpb FAR *bpbp; - DWORD newmirroring = xdffp->xdff_f.setmirroring.newmirroring; + DWORD newmirroring = + xdffp->xdff_f.setmirroring.newmirroring; - if (newmirroring != -1 && (ISFAT32(dpb) && (newmirroring & ~(0xf | 0x80)))) - { - r->AX = -DE_INVLDPARM; - goto error_out; - } - xdffp->xdff_f.setmirroring.oldmirroring = (ISFAT32(dpb) ? dpb->dpb_xflags : 0); + if (newmirroring != -1 + && (ISFAT32(dpb) + && (newmirroring & ~(0xf | 0x80)))) + { + r->AX = -DE_INVLDPARM; + goto error_out; + } + xdffp->xdff_f.setmirroring.oldmirroring = + (ISFAT32(dpb) ? dpb->dpb_xflags : 0); if (newmirroring != -1 && ISFAT32(dpb)) - { - bp = getblock(1, dpb->dpb_unit); - bp->b_flag &= ~(BFR_DATA | BFR_DIR | BFR_FAT); - bp->b_flag |= BFR_VALID | BFR_DIRTY; - bpbp = (bpb FAR *)& bp->b_buffer[BT_BPB]; - bpbp->bpb_xflags = newmirroring; - } + { + bp = getblock(1, dpb->dpb_unit); + bp->b_flag &= ~(BFR_DATA | BFR_DIR | BFR_FAT); + bp->b_flag |= BFR_VALID | BFR_DIRTY; + bpbp = (bpb FAR *) & bp->b_buffer[BT_BPB]; + bpbp->bpb_xflags = newmirroring; + } goto rebuild_dpb; } case 0x04: @@ -1660,91 +1672,95 @@ VOID ASMCFUNC int21_service(iregs FAR * r) struct buffer FAR *bp; bpb FAR *bpbp; DWORD rootclst = xdffp->xdff_f.setroot.newrootclst; - if (!ISFAT32(dpb) || (rootclst != -1 && (rootclst == 1 || - rootclst > dpb->dpb_xsize))) - { - r->AX = -DE_INVLDPARM; - goto error_out; - } + if (!ISFAT32(dpb) + || (rootclst != -1 + && (rootclst == 1 + || rootclst > dpb->dpb_xsize))) + { + r->AX = -DE_INVLDPARM; + goto error_out; + } xdffp->xdff_f.setroot.oldrootclst = dpb->dpb_xrootclst; if (rootclst != -1) - { - bp = getblock(1, dpb->dpb_unit); - bp->b_flag &= ~(BFR_DATA | BFR_DIR | BFR_FAT); - bp->b_flag |= BFR_VALID | BFR_DIRTY; - bpbp = (bpb FAR *) & bp->b_buffer[BT_BPB]; - bpbp->bpb_xrootclst = rootclst; - } + { + bp = getblock(1, dpb->dpb_unit); + bp->b_flag &= ~(BFR_DATA | BFR_DIR | BFR_FAT); + bp->b_flag |= BFR_VALID | BFR_DIRTY; + bpbp = (bpb FAR *) & bp->b_buffer[BT_BPB]; + bpbp->bpb_xrootclst = rootclst; + } goto rebuild_dpb; } - } + } - break; + break; } - /* Extended absolute disk read/write */ + /* Extended absolute disk read/write */ /* TODO(vlp) consider using of the 13-14th bits of SI */ case 0x05: - { + { struct HugeSectorBlock FAR *SectorBlock = - (struct HugeSectorBlock FAR *)MK_FP(r->DS, r->BX); + (struct HugeSectorBlock FAR *)MK_FP(r->DS, r->BX); UBYTE mode; - - if (r->CX != 0xffff || ((r->SI & 1) == 0 && r->SI != 0) + + if (r->CX != 0xffff || ((r->SI & 1) == 0 && r->SI != 0) || (r->SI & ~0x6001)) - { - r->AX = -DE_INVLDPARM; - goto error_out; - } - + { + r->AX = -DE_INVLDPARM; + goto error_out; + } + if (r->DL - 1 >= lastdrive || r->DL == 0) - { - r->AX = 0x207; - goto error_out; - } - CLEAR_CARRY_FLAG(); - - if (r->SI == 0) mode = DSKREAD; - else mode = DSKWRITE; + { + r->AX = 0x207; + goto error_out; + } + CLEAR_CARRY_FLAG(); + + if (r->SI == 0) + mode = DSKREAD; + else + mode = DSKWRITE; InDOS++; - r->AX=dskxfer(r->DL - 1, SectorBlock->blkno, SectorBlock->buf, - SectorBlock->nblks, mode); + r->AX = + dskxfer(r->DL - 1, SectorBlock->blkno, SectorBlock->buf, + SectorBlock->nblks, mode); if (mode == DSKWRITE) if (r->AX <= 0) - setinvld(r->DL - 1); + setinvld(r->DL - 1); if (r->AX > 0) - { - r->AX = 0x20c; - r->flags |= FLG_CARRY; - --InDOS; - return; - } - + { + r->AX = 0x20c; + r->flags |= FLG_CARRY; + --InDOS; + return; + } r->AX = 0; r->flags &= ~FLG_CARRY; --InDOS; - break; - } - } + break; + } + } break; - } + } #endif #ifdef WITHLFNAPI /* FreeDOS LFN helper API functions */ case 0x74: { - switch(r->AL) - { + switch (r->AL) + { /* Allocate LFN inode */ case 0x01: { r->AX = lfn_allocate_inode(); break; } - /* Free LFN inode */ + /* Free LFN inode */ case 0x02: { r->AX = lfn_free_inode(r->BX); @@ -1759,7 +1775,7 @@ VOID ASMCFUNC int21_service(iregs FAR * r) /* Create LFN entries */ case 0x04: { - r->AX = lfn_create_entries(r->BX, (lfn_inode_ptr)FP_DS_DX); + r->AX = lfn_create_entries(r->BX, (lfn_inode_ptr) FP_DS_DX); break; } /* Delete LFN entries */ @@ -1771,7 +1787,7 @@ VOID ASMCFUNC int21_service(iregs FAR * r) /* Read next LFN */ case 0x06: { - r->AX = lfn_dir_read(r->BX, (lfn_inode_ptr)FP_DS_DX); + r->AX = lfn_dir_read(r->BX, (lfn_inode_ptr) FP_DS_DX); break; } /* Write SFN pointed by LFN inode */ @@ -1780,26 +1796,28 @@ VOID ASMCFUNC int21_service(iregs FAR * r) r->AX = lfn_dir_write(r->BX); break; } - } + } break; } #endif } #ifdef DEBUG if (bDumpRegs) - { - fmemcpy(&error_regs, user_r, sizeof(iregs)); - dump_regs = TRUE; - dump(); - } + { + fmemcpy(&error_regs, user_r, sizeof(iregs)); + dump_regs = TRUE; + dump(); + } #endif } #if 0 - /* No kernel INT-23 handler required no longer -- 1999/04/15 ska */ + /* No kernel INT-23 handler required no longer -- 1999/04/15 ska */ /* ctrl-Break handler */ #pragma argsused -VOID INRPT FAR int23_handler(int es, int ds, int di, int si, int bp, int sp, int bx, int dx, int cx, int ax, int ip, int cs, int flags) +VOID INRPT FAR int23_handler(int es, int ds, int di, int si, int bp, + int sp, int bx, int dx, int cx, int ax, + int ip, int cs, int flags) { tsr = FALSE; return_mode = 1; @@ -1813,21 +1831,11 @@ VOID INRPT FAR int23_handler(int es, int ds, int di, int si, int bp, int sp, int } #endif -struct int25regs -{ - UWORD es, - ds; - UWORD di, - si, - bp, - sp; - UWORD bx, - dx, - cx, - ax; - UWORD flags, - ip, - cs; +struct int25regs { + UWORD es, ds; + UWORD di, si, bp, sp; + UWORD bx, dx, cx, ax; + UWORD flags, ip, cs; }; /* @@ -1837,12 +1845,14 @@ VOID ASMCFUNC int2526_handler(WORD mode, struct int25regs FAR * r) { ULONG blkno; UWORD nblks; - BYTE FAR *buf; + BYTE FAR *buf; UBYTE drv; - - if (mode == 0x26) mode = DSKWRITEINT26; - else mode = DSKREADINT25; - + + if (mode == 0x26) + mode = DSKWRITEINT26; + else + mode = DSKREADINT25; + drv = r->ax; if (drv >= lastdrive) @@ -1860,29 +1870,28 @@ VOID ASMCFUNC int2526_handler(WORD mode, struct int25regs FAR * r) r->flags |= FLG_CARRY; return; } -#endif +#endif nblks = r->cx; blkno = r->dx; - + buf = MK_FP(r->ds, r->bx); - + if (nblks == 0xFFFF) { - /*struct HugeSectorBlock FAR *lb = MK_FP(r->ds, r->bx);*/ + /*struct HugeSectorBlock FAR *lb = MK_FP(r->ds, r->bx); */ blkno = ((struct HugeSectorBlock FAR *)buf)->blkno; nblks = ((struct HugeSectorBlock FAR *)buf)->nblks; - buf = ((struct HugeSectorBlock FAR *)buf)->buf; + buf = ((struct HugeSectorBlock FAR *)buf)->buf; } - InDOS++; - r->ax=dskxfer(drv, blkno, buf, nblks, mode); + r->ax = dskxfer(drv, blkno, buf, nblks, mode); if (mode == DSKWRITE) if (r->ax <= 0) - setinvld(drv); + setinvld(drv); if (r->ax > 0) { @@ -1891,20 +1900,17 @@ VOID ASMCFUNC int2526_handler(WORD mode, struct int25regs FAR * r) return; } - r->ax = 0; r->flags &= ~FLG_CARRY; --InDOS; - + } + /* VOID int25_handler(struct int25regs FAR * r) { int2526_handler(DSKREAD,r); } VOID int26_handler(struct int25regs FAR * r) { int2526_handler(DSKWRITE,r); } */ - - - #ifdef TSC static VOID StartTrace(VOID) { @@ -1926,188 +1932,186 @@ static VOID StartTrace(VOID) this function is called from an assembler wrapper function and serves the internal dos calls - int2f/12xx */ -struct int2f12regs -{ - UWORD es,ds; - UWORD di,si,bp,bx,dx,cx,ax; - UWORD ip,cs,flags; - UWORD callerARG1; /* used if called from INT2F/12 */ +struct int2f12regs { + UWORD es, ds; + UWORD di, si, bp, bx, dx, cx, ax; + UWORD ip, cs, flags; + UWORD callerARG1; /* used if called from INT2F/12 */ }; VOID ASMCFUNC int2F_12_handler(volatile struct int2f12regs r) -{ - UWORD function = r.ax & 0xff; - - if (function > 0x31) - return; - - switch(function) - { - case 0x00: /* installation check */ - r.ax |= 0x00ff; - break; +{ + UWORD function = r.ax & 0xff; - case 0x03: /* get DOS data segment */ - r.ds = FP_SEG(&nul_dev); - break; + if (function > 0x31) + return; - case 0x06: /* invoke critical error */ + switch (function) + { + case 0x00: /* installation check */ + r.ax |= 0x00ff; + break; - /* code, drive number, error, device header */ - r.ax &= 0xff00; - r.ax |= CriticalError( - r.callerARG1 >> 8, - (r.callerARG1 & (EFLG_CHAR << 8)) ? 0 : r.callerARG1 & 0xff, - r.di, - MK_FP(r.bp,r.si)); - break; - - case 0x08: /* decrease SFT reference count */ - { - sft FAR *p = MK_FP(r.es,r.di); - - r.ax = p->sft_count; - - if (--p->sft_count == 0) --p->sft_count; - } - break; + case 0x03: /* get DOS data segment */ + r.ds = FP_SEG(&nul_dev); + break; - case 0x0c: /* perform "device open" for device, set owner for FCB */ + case 0x06: /* invoke critical error */ - if (lpCurSft->sft_flags & SFT_FDEVICE) - { - request rq; + /* code, drive number, error, device header */ + r.ax &= 0xff00; + r.ax |= CriticalError(r.callerARG1 >> 8, + (r.callerARG1 & (EFLG_CHAR << 8)) ? 0 : r. + callerARG1 & 0xff, r.di, MK_FP(r.bp, r.si)); + break; - rq.r_unit = 0; - rq.r_status = 0; - rq.r_command = C_OPEN; - rq.r_length = sizeof(request); - execrh((request FAR *) & rq, lpCurSft->sft_dev); - } + case 0x08: /* decrease SFT reference count */ + { + sft FAR *p = MK_FP(r.es, r.di); - /* just do it always, not just for FCBs */ - lpCurSft->sft_psp = cu_psp; - break; + r.ax = p->sft_count; - case 0x0d: /* get dos date/time */ + if (--p->sft_count == 0) + --p->sft_count; + } + break; - r.ax = dos_getdate(); - r.dx = dos_gettime(); - break; - - case 0x12: /* get length of asciiz string */ - - r.cx = fstrlen(MK_FP(r.es, r.di))+1; - - break; + case 0x0c: /* perform "device open" for device, set owner for FCB */ + if (lpCurSft->sft_flags & SFT_FDEVICE) + { + request rq; - case 0x16: /* get address of system file table entry - used by NET.EXE - BX system file table entry number ( such as returned from 2F/1220) - returns - ES:DI pointer to SFT entry */ - { - sft FAR *p = get_sft(r.bx); - - r.es = FP_SEG(p); - r.di = FP_OFF(p); - break; - } + rq.r_unit = 0; + rq.r_status = 0; + rq.r_command = C_OPEN; + rq.r_length = sizeof(request); + execrh((request FAR *) & rq, lpCurSft->sft_dev); + } - case 0x17: /* get current directory structure for drive - used by NET.EXE - STACK: drive (0=A:,1=B,...) - ; returns - ; CF set if error - ; DS:SI pointer to CDS for drive - ; - ; called like - ; push 2 (c-drive) - ; mov ax,1217 - ; int 2f - ; - ; probable use: get sizeof(CDSentry) - */ - { - UWORD drv = r.callerARG1 & 0xff; - - if (drv >= lastdrive) - r.flags |= FLG_CARRY; - else - { - r.ds = FP_SEG(CDSp); - r.si = FP_OFF(&CDSp->cds_table[drv]); - r.flags &= ~FLG_CARRY; - } - break; - } + /* just do it always, not just for FCBs */ + lpCurSft->sft_psp = cu_psp; + break; - case 0x18: /* get caller's registers */ - - r.ds = FP_SEG(user_r); - r.si = FP_OFF(user_r); - break; + case 0x0d: /* get dos date/time */ - case 0x1b: /* #days in February - valid until 2099.*/ - - r.ax = (r.ax & 0xff00) | (r.cx & 3 ? 28 : 29); - break; - - case 0x21: /* truename */ - - truename(MK_FP(r.ds,r.si), MK_FP(r.es,r.di),0); - - break; - - case 0x23: /* check if character device */ - { - struct dhdr FAR *dhp; + r.ax = dos_getdate(); + r.dx = dos_gettime(); + break; - dhp = IsDevice((BYTE FAR *)DirEntBuffer.dir_name); + case 0x12: /* get length of asciiz string */ - if (dhp) - { - r.bx = (r.bx & 0xff) | (dhp->dh_attr <<8); - r.flags &= ~FLG_CARRY; - } - else { - r.flags |= FLG_CARRY; - } + r.cx = fstrlen(MK_FP(r.es, r.di)) + 1; - } + break; - break; + case 0x16: /* get address of system file table entry - used by NET.EXE + BX system file table entry number ( such as returned from 2F/1220) + returns + ES:DI pointer to SFT entry */ + { + sft FAR *p = get_sft(r.bx); - case 0x25: /* get length of asciiz string */ - - r.cx = fstrlen(MK_FP(r.ds, r.si))+1; - break; - - - case 0x2a: /* Set FastOpen but does nothing. */ - - r.flags &= ~FLG_CARRY; - break; - - case 0x2c: /* added by James Tabor For Zip Drives - Return Null Device Pointer */ - /* by UDOS+RBIL: get header of SECOND device driver in device chain, - omitting the NUL device TE*/ - r.bx = FP_SEG(nul_dev.dh_next); - r.ax = FP_OFF(nul_dev.dh_next); - - break; + r.es = FP_SEG(p); + r.di = FP_OFF(p); + break; + } - case 0x2e: /* GET or SET error table addresse - ignored - called by MS debug with DS != DOSDS, printf - doesn't work!! */ - break; + case 0x17: /* get current directory structure for drive - used by NET.EXE + STACK: drive (0=A:,1=B,...) + ; returns + ; CF set if error + ; DS:SI pointer to CDS for drive + ; + ; called like + ; push 2 (c-drive) + ; mov ax,1217 + ; int 2f + ; + ; probable use: get sizeof(CDSentry) + */ + { + UWORD drv = r.callerARG1 & 0xff; - default: - printf("unimplemented internal dos function INT2F/12%02x\n",function); - r.flags |= FLG_CARRY; - break; + if (drv >= lastdrive) + r.flags |= FLG_CARRY; + else + { + r.ds = FP_SEG(CDSp); + r.si = FP_OFF(&CDSp->cds_table[drv]); + r.flags &= ~FLG_CARRY; + } + break; + } + + case 0x18: /* get caller's registers */ + + r.ds = FP_SEG(user_r); + r.si = FP_OFF(user_r); + break; + + case 0x1b: /* #days in February - valid until 2099. */ + + r.ax = (r.ax & 0xff00) | (r.cx & 3 ? 28 : 29); + break; + + case 0x21: /* truename */ + + truename(MK_FP(r.ds, r.si), MK_FP(r.es, r.di), 0); + + break; + + case 0x23: /* check if character device */ + { + struct dhdr FAR *dhp; + + dhp = IsDevice((BYTE FAR *) DirEntBuffer.dir_name); + + if (dhp) + { + r.bx = (r.bx & 0xff) | (dhp->dh_attr << 8); + r.flags &= ~FLG_CARRY; + } + else + { + r.flags |= FLG_CARRY; + } - } + } + + break; + + case 0x25: /* get length of asciiz string */ + + r.cx = fstrlen(MK_FP(r.ds, r.si)) + 1; + break; + + case 0x2a: /* Set FastOpen but does nothing. */ + + r.flags &= ~FLG_CARRY; + break; + + case 0x2c: /* added by James Tabor For Zip Drives + Return Null Device Pointer */ + /* by UDOS+RBIL: get header of SECOND device driver in device chain, + omitting the NUL device TE */ + r.bx = FP_SEG(nul_dev.dh_next); + r.ax = FP_OFF(nul_dev.dh_next); + + break; + + case 0x2e: /* GET or SET error table addresse - ignored + called by MS debug with DS != DOSDS, printf + doesn't work!! */ + break; + + default: + printf("unimplemented internal dos function INT2F/12%02x\n", + function); + r.flags |= FLG_CARRY; + break; + + } } diff --git a/kernel/intr.h b/kernel/intr.h index 2b6fd903..5aa624e8 100644 --- a/kernel/intr.h +++ b/kernel/intr.h @@ -2,8 +2,8 @@ */ struct REGPACK { - unsigned r_ax, r_bx, r_cx, r_dx; - unsigned r_bp, r_di, r_si, r_ds, r_es, r_flags; + unsigned r_ax, r_bx, r_cx, r_dx; + unsigned r_bp, r_di, r_si, r_ds, r_es, r_flags; }; extern void ASMCFUNC intr(int intrnr, struct REGPACK *rp); diff --git a/kernel/ioctl.c b/kernel/ioctl.c index d0f876af..f5a8dbe9 100644 --- a/kernel/ioctl.c +++ b/kernel/ioctl.c @@ -30,7 +30,8 @@ #include "globals.h" #ifdef VERSION_STRINGS -static BYTE *RcsId = "$Id$"; +static BYTE *RcsId = + "$Id$"; #endif /* @@ -53,21 +54,18 @@ static BYTE *RcsId = "$Id$"; */ - COUNT DosDevIOctl(iregs FAR * r) { sft FAR *s; struct dpb FAR *dpbp; COUNT nMode; - /* commonly used, shouldn't harm to do front up */ + /* commonly used, shouldn't harm to do front up */ CharReqHdr.r_length = sizeof(request); - CharReqHdr.r_trans = MK_FP(r->DS, r->DX); + CharReqHdr.r_trans = MK_FP(r->DS, r->DX); CharReqHdr.r_status = 0; - CharReqHdr.r_count = r->CX; - - + CharReqHdr.r_count = r->CX; /* Test that the handle is valid */ switch (r->AL) @@ -106,7 +104,7 @@ COUNT DosDevIOctl(iregs FAR * r) /* JPP - changed to use default drive if drive=0 */ /* JT Fixed it */ - CharReqHdr.r_unit = ( r->BL == 0 ? default_drive : r->BL - 1); + CharReqHdr.r_unit = (r->BL == 0 ? default_drive : r->BL - 1); if (CharReqHdr.r_unit >= lastdrive) return DE_INVLDDRV; @@ -133,12 +131,12 @@ COUNT DosDevIOctl(iregs FAR * r) { case 0x00: /* Get the flags from the SFT */ - if (s->sft_flags & SFT_FDEVICE) - r->AX = (s->sft_dev->dh_attr & 0xff00) | s->sft_flags_lo; - else - r->AX = s->sft_flags; + if (s->sft_flags & SFT_FDEVICE) + r->AX = (s->sft_dev->dh_attr & 0xff00) | s->sft_flags_lo; + else + r->AX = s->sft_flags; /* Undocumented result, Ax = Dx seen using Pcwatch */ - r->DX = r->AX; + r->DX = r->AX; break; case 0x01: @@ -165,36 +163,36 @@ COUNT DosDevIOctl(iregs FAR * r) nMode = C_IOCTLOUT; IoCharCommon: if ((s->sft_flags & SFT_FDEVICE) - || ((r->AL == 0x02 ) && (s->sft_dev->dh_attr & SFT_FIOCTL)) - || ((r->AL == 0x03 ) && (s->sft_dev->dh_attr & SFT_FIOCTL)) - || ((r->AL == 0x10) && (s->sft_dev->dh_attr & ATTR_QRYIOCTL)) - || ((r->AL == 0x0c) && (s->sft_dev->dh_attr & ATTR_GENIOCTL))) + || ((r->AL == 0x02) && (s->sft_dev->dh_attr & SFT_FIOCTL)) + || ((r->AL == 0x03) && (s->sft_dev->dh_attr & SFT_FIOCTL)) + || ((r->AL == 0x10) && (s->sft_dev->dh_attr & ATTR_QRYIOCTL)) + || ((r->AL == 0x0c) && (s->sft_dev->dh_attr & ATTR_GENIOCTL))) { - CharReqHdr.r_unit = 0; - CharReqHdr.r_command = nMode; - execrh((request FAR *) & CharReqHdr, s->sft_dev); - - if (CharReqHdr.r_status & S_ERROR) - { - CritErrCode = (CharReqHdr.r_status & S_MASK) + 0x13; - return DE_DEVICE; - } - - if (r->AL == 0x07) - { - r->AL = CharReqHdr.r_status & S_BUSY ? 00 : 0xff; - - } - else if (r->AL == 0x02 || r->AL == 0x03) - { - r->AX = CharReqHdr.r_count; - } - - else if (r->AL == 0x0c || r->AL == 0x10) - { - r->AX = CharReqHdr.r_status; - } - break; + CharReqHdr.r_unit = 0; + CharReqHdr.r_command = nMode; + execrh((request FAR *) & CharReqHdr, s->sft_dev); + + if (CharReqHdr.r_status & S_ERROR) + { + CritErrCode = (CharReqHdr.r_status & S_MASK) + 0x13; + return DE_DEVICE; + } + + if (r->AL == 0x07) + { + r->AL = CharReqHdr.r_status & S_BUSY ? 00 : 0xff; + + } + else if (r->AL == 0x02 || r->AL == 0x03) + { + r->AX = CharReqHdr.r_count; + } + + else if (r->AL == 0x0c || r->AL == 0x10) + { + r->AX = CharReqHdr.r_status; + } + break; } return DE_INVLDFUNC; @@ -210,44 +208,44 @@ COUNT DosDevIOctl(iregs FAR * r) case 0x05: nMode = C_IOCTLOUT; IoBlockCommon: - if(!dpbp) + if (!dpbp) { return DE_INVLDDRV; } - if ( ((r->AL == 0x04 ) && !(dpbp->dpb_device->dh_attr & ATTR_IOCTL)) - || ((r->AL == 0x05 ) && !(dpbp->dpb_device->dh_attr & ATTR_IOCTL)) - || ((r->AL == 0x11) && !(dpbp->dpb_device->dh_attr & ATTR_QRYIOCTL)) - || ((r->AL == 0x0d) && !(dpbp->dpb_device->dh_attr & ATTR_GENIOCTL))) + if (((r->AL == 0x04) && !(dpbp->dpb_device->dh_attr & ATTR_IOCTL)) + || ((r->AL == 0x05) && !(dpbp->dpb_device->dh_attr & ATTR_IOCTL)) + || ((r->AL == 0x11) + && !(dpbp->dpb_device->dh_attr & ATTR_QRYIOCTL)) + || ((r->AL == 0x0d) + && !(dpbp->dpb_device->dh_attr & ATTR_GENIOCTL))) { return DE_INVLDFUNC; } - CharReqHdr.r_command = nMode; - execrh((request FAR *) & CharReqHdr, - dpbp->dpb_device); + execrh((request FAR *) & CharReqHdr, dpbp->dpb_device); - if (CharReqHdr.r_status & S_ERROR) - { - CritErrCode = (CharReqHdr.r_status & S_MASK) + 0x13; - return DE_DEVICE; - } - if (r->AL == 0x08) - { - r->AX = (CharReqHdr.r_status & S_BUSY) ? 1 : 0; + if (CharReqHdr.r_status & S_ERROR) + { + CritErrCode = (CharReqHdr.r_status & S_MASK) + 0x13; + return DE_DEVICE; + } + if (r->AL == 0x08) + { + r->AX = (CharReqHdr.r_status & S_BUSY) ? 1 : 0; - } + } - else if (r->AL == 0x04 || r->AL == 0x05) - { - r->AX = CharReqHdr.r_count; + else if (r->AL == 0x04 || r->AL == 0x05) + { + r->AX = CharReqHdr.r_count; - } - else if (r->AL == 0x0d || r->AL == 0x11) - { - r->AX = CharReqHdr.r_status; - } - break; + } + else if (r->AL == 0x0d || r->AL == 0x11) + { + r->AX = CharReqHdr.r_status; + } + break; case 0x06: if (s->sft_flags & SFT_FDEVICE) @@ -268,7 +266,7 @@ COUNT DosDevIOctl(iregs FAR * r) break; case 0x08: - if(!dpbp) + if (!dpbp) { return DE_INVLDDRV; } @@ -280,21 +278,21 @@ COUNT DosDevIOctl(iregs FAR * r) return DE_INVLDFUNC; case 0x09: - if(CDSp->cds_table[CharReqHdr.r_unit].cdsFlags & CDSNETWDRV) + if (CDSp->cds_table[CharReqHdr.r_unit].cdsFlags & CDSNETWDRV) + { + r->DX = ATTR_REMOTE; + r->AX = S_DONE | S_BUSY; + } + else + { + if (!dpbp) { - r->DX = ATTR_REMOTE ; - r->AX = S_DONE|S_BUSY; + return DE_INVLDDRV; } - else - { - if(!dpbp) - { - return DE_INVLDDRV; - } /* Need to add subst bit 15 */ - r->DX = dpbp->dpb_device->dh_attr; - r->AX = S_DONE|S_BUSY; - } + r->DX = dpbp->dpb_device->dh_attr; + r->AX = S_DONE | S_BUSY; + } break; case 0x0a: @@ -308,17 +306,15 @@ COUNT DosDevIOctl(iregs FAR * r) case 0x0f: nMode = C_SETLDEV; IoLogCommon: - if(!dpbp) + if (!dpbp) { return DE_INVLDDRV; } if ((dpbp->dpb_device->dh_attr & ATTR_GENIOCTL)) { - CharReqHdr.r_command = nMode; - execrh((request FAR *) & CharReqHdr, - dpbp->dpb_device); + execrh((request FAR *) & CharReqHdr, dpbp->dpb_device); if (CharReqHdr.r_status & S_ERROR) { @@ -327,8 +323,8 @@ COUNT DosDevIOctl(iregs FAR * r) } else { - r->AL = CharReqHdr.r_unit; - return SUCCESS; + r->AL = CharReqHdr.r_unit; + return SUCCESS; } } return DE_INVLDFUNC; @@ -391,6 +387,3 @@ COUNT DosDevIOctl(iregs FAR * r) * Rev 1.0 02 Jul 1995 8:32:04 patv * Initial revision. */ - - - diff --git a/kernel/lfnapi.c b/kernel/lfnapi.c index b25b5f08..7a1c40cc 100644 --- a/kernel/lfnapi.c +++ b/kernel/lfnapi.c @@ -10,7 +10,8 @@ #include "globals.h" #ifdef VERSION_STRINGS -static BYTE *lfnaidRcsId = "$Id$"; +static BYTE *lfnaidRcsId = + "$Id$"; #endif #ifdef WITHLFNAPI @@ -27,7 +28,7 @@ static BYTE *lfnaidRcsId = "$Id$"; #define CHARS_IN_LFN_ENTRY 13 #define UNICODE_FILLER 0xffff -COUNT ufstrlen(REG UNICODE FAR *); /* fstrlen for UNICODE strings */ +COUNT ufstrlen(REG UNICODE FAR *); /* fstrlen for UNICODE strings */ UBYTE lfn_checksum(UBYTE *); COUNT extend_dir(f_node_ptr); COUNT remove_lfn_entries(f_node_ptr fnp); @@ -36,23 +37,24 @@ COUNT lfn_allocate_inode(VOID) { f_node_ptr fnp = get_f_node(); struct cds FAR *cdsp; - if (fnp == 0) return LHE_NOFREEHNDL; + if (fnp == 0) + return LHE_NOFREEHNDL; cdsp = &CDSp->cds_table[default_drive]; if (cdsp->cdsDpb == 0) - { - release_f_node(fnp); - return LHE_INVLDDRV; - } + { + release_f_node(fnp); + return LHE_INVLDDRV; + } fnp->f_dpb = cdsp->cdsDpb; if (media_check(fnp->f_dpb) < 0) - { - release_f_node(fnp); - return LHE_INVLDDRV; - } + { + release_f_node(fnp); + return LHE_INVLDDRV; + } return xlt_fnp(fnp); } @@ -60,7 +62,8 @@ COUNT lfn_allocate_inode(VOID) COUNT lfn_free_inode(COUNT handle) { f_node_ptr fnp = xlt_fd(handle); - if (fnp == 0 || fnp->f_count <= 0) return LHE_INVLDHNDL; + if (fnp == 0 || fnp->f_count <= 0) + return LHE_INVLDHNDL; release_f_node(fnp); @@ -70,7 +73,8 @@ COUNT lfn_free_inode(COUNT handle) COUNT lfn_setup_inode(COUNT handle, CLUSTER dirstart, ULONG diroff) { f_node_ptr fnp = xlt_fd(handle); - if (fnp == 0 || fnp->f_count <= 0) return LHE_INVLDHNDL; + if (fnp == 0 || fnp->f_count <= 0) + return LHE_INVLDHNDL; dir_init_fnode(fnp, dirstart); fnp->f_diroff = diroff; @@ -78,39 +82,46 @@ COUNT lfn_setup_inode(COUNT handle, CLUSTER dirstart, ULONG diroff) return SUCCESS; } -BOOL transfer_unicode(UNICODE FAR **dptr, UNICODE FAR **sptr, COUNT count) +BOOL transfer_unicode(UNICODE FAR ** dptr, UNICODE FAR ** sptr, + COUNT count) { COUNT j; BOOL found_zerro = FALSE; for (j = 0; j < count; j++, (*dptr)++, (*sptr)++) - { - if (found_zerro) **dptr = UNICODE_FILLER; - else **dptr = **sptr; - if (**sptr == 0) found_zerro = TRUE; - } + { + if (found_zerro) + **dptr = UNICODE_FILLER; + else + **dptr = **sptr; + if (**sptr == 0) + found_zerro = TRUE; + } return found_zerro; } -BOOL lfn_to_unicode(UNICODE FAR **name, struct lfn_entry FAR *lep) +BOOL lfn_to_unicode(UNICODE FAR ** name, struct lfn_entry FAR * lep) { UNICODE FAR *ptr; - + ptr = lep->lfn_name0_4; - if (!transfer_unicode(name, &ptr, 5)) return FALSE; + if (!transfer_unicode(name, &ptr, 5)) + return FALSE; ptr = lep->lfn_name5_10; - if (!transfer_unicode(name, &ptr, 6)) return FALSE; + if (!transfer_unicode(name, &ptr, 6)) + return FALSE; ptr = lep->lfn_name11_12; - if (!transfer_unicode(name, &ptr, 2)) return FALSE; + if (!transfer_unicode(name, &ptr, 2)) + return FALSE; return TRUE; } -VOID unicode_to_lfn(UNICODE FAR **name, struct lfn_entry FAR *lep) +VOID unicode_to_lfn(UNICODE FAR ** name, struct lfn_entry FAR * lep) { UNICODE FAR *ptr; - + ptr = lep->lfn_name0_4; transfer_unicode(&ptr, name, 5); ptr = lep->lfn_name5_10; @@ -127,45 +138,54 @@ COUNT lfn_dir_read(COUNT handle, lfn_inode_ptr lip) ULONG sfn_diroff; BOOL name_tail = FALSE; f_node_ptr fnp = xlt_fd(handle); - if (fnp == 0 || fnp->f_count <= 0) return LHE_INVLDHNDL; + if (fnp == 0 || fnp->f_count <= 0) + return LHE_INVLDHNDL; while (TRUE) + { + rc = dir_read(fnp); + if (rc == 0) + return SUCCESS; + else if (rc == DE_SEEK) + return LHE_SEEK; + else if (rc == DE_BLKINVLD) + return LHE_IOERROR; + if (fnp->f_dir.dir_name[0] != DELETED + && fnp->f_dir.dir_attrib != D_LFN) { - rc = dir_read(fnp); - if (rc == 0) return SUCCESS; - else if (rc == DE_SEEK) return LHE_SEEK; - else if (rc == DE_BLKINVLD) return LHE_IOERROR; - if (fnp->f_dir.dir_name[0] != DELETED && fnp->f_dir.dir_attrib != D_LFN) - { - fmemcpy(&lip->l_dir, &fnp->f_dir, sizeof(struct dirent)); - sfn_diroff = fnp->f_diroff; - break; - } - } + fmemcpy(&lip->l_dir, &fnp->f_dir, sizeof(struct dirent)); + sfn_diroff = fnp->f_diroff; + break; + } + } fnp->f_diroff = lip->l_diroff; fmemset(lip->name, 0, 256 * sizeof(UNICODE)); while (TRUE) + { + if (fnp->f_diroff == 0) + break; + fnp->f_diroff -= 2 * DIRENT_SIZE; + rc = dir_read(fnp); + if (rc == DE_BLKINVLD) + return LHE_IOERROR; + if (fnp->f_dir.dir_name[0] == DELETED + || fnp->f_dir.dir_attrib != D_LFN) + break; + name_tail = lfn_to_unicode(&lfn_name, lfn(fnp)); + real_id = lfn(fnp)->lfn_id; + if (real_id & 0x40) + { + if ((real_id | 0x40) != id) + return LHE_DAMAGEDFS; + } + else { - if (fnp->f_diroff == 0) break; - fnp->f_diroff -= 2*DIRENT_SIZE; - rc = dir_read(fnp); - if (rc == DE_BLKINVLD) return LHE_IOERROR; - if (fnp->f_dir.dir_name[0] == DELETED - || fnp->f_dir.dir_attrib != D_LFN) break; - name_tail = lfn_to_unicode(&lfn_name, lfn(fnp)); - real_id = lfn(fnp)->lfn_id; - if (real_id & 0x40) - { - if ((real_id | 0x40) != id) return LHE_DAMAGEDFS; - } - else - { - if (name_tail || real_id != id - || lfn(fnp)->lfn_checksum != lfn_checksum(fnp->f_dir.dir_name)) - return LHE_DAMAGEDFS; - } + if (name_tail || real_id != id + || lfn(fnp)->lfn_checksum != lfn_checksum(fnp->f_dir.dir_name)) + return LHE_DAMAGEDFS; } + } fnp->f_diroff = lip->l_diroff = sfn_diroff; fnp->f_flags.f_dnew = TRUE; @@ -176,16 +196,17 @@ COUNT lfn_dir_read(COUNT handle, lfn_inode_ptr lip) COUNT lfn_dir_write(COUNT handle) { f_node_ptr fnp = xlt_fd(handle); - if (fnp == 0 || fnp->f_count <= 0) return LHE_INVLDHNDL; + if (fnp == 0 || fnp->f_count <= 0) + return LHE_INVLDHNDL; if (!dir_write(fnp)) - { - lfn_allocate_inode(); /* protection against dir_write fault - * this must restore things to the state before - * the call */ - /* Yes, it's a hack! */ - return LHE_IOERROR; - } + { + lfn_allocate_inode(); /* protection against dir_write fault + * this must restore things to the state before + * the call */ + /* Yes, it's a hack! */ + return LHE_IOERROR; + } return SUCCESS; } @@ -196,52 +217,58 @@ COUNT lfn_create_entries(COUNT handle, lfn_inode_ptr lip) COUNT entries_needed, free_entries, i, rc; UNICODE FAR *lfn_name = lip->name; ULONG sfn_offset; - if (fnp == 0 || fnp->f_count <= 0) return LHE_INVLDHNDL; + if (fnp == 0 || fnp->f_count <= 0) + return LHE_INVLDHNDL; + + entries_needed = (ufstrlen(lfn_name) + CHARS_IN_LFN_ENTRY - 1) / CHARS_IN_LFN_ENTRY + 1; /* We want to create SFN entry too */ - entries_needed = (ufstrlen(lfn_name) + CHARS_IN_LFN_ENTRY - 1) - / CHARS_IN_LFN_ENTRY + 1; /* We want to create SFN entry too */ - /* Scan the directory from the very begining for the free directory entries */ lfn_setup_inode(handle, fnp->f_dirstart, 0); free_entries = 0; while ((rc = dir_read(fnp)) == 1) + { + if (fnp->f_dir.dir_name[0] == DELETED) { - if (fnp->f_dir.dir_name[0] == DELETED) - { - free_entries++; - if (free_entries == entries_needed) - break; - } - else free_entries = 0; + free_entries++; + if (free_entries == entries_needed) + break; } - if (rc == DE_BLKINVLD) return LHE_IOERROR; + else + free_entries = 0; + } + if (rc == DE_BLKINVLD) + return LHE_IOERROR; /* We have reached the end of the directory here. */ - - if (free_entries != entries_needed) free_entries = 0; + + if (free_entries != entries_needed) + free_entries = 0; while (free_entries != entries_needed) + { + rc = dir_read(fnp); + if (rc == 0) + free_entries++; + else if (rc == DE_BLKINVLD) + return LHE_IOERROR; + else if (rc == DE_SEEK && extend_dir(fnp) != SUCCESS) { - rc = dir_read(fnp); - if (rc == 0) free_entries++; - else if (rc == DE_BLKINVLD) return LHE_IOERROR; - else if (rc == DE_SEEK && extend_dir(fnp) != SUCCESS) - { - lfn_allocate_inode(); /* Another hack. */ - return LHE_IOERROR; - } + lfn_allocate_inode(); /* Another hack. */ + return LHE_IOERROR; } + } sfn_offset = fnp->f_diroff; fnp->f_diroff -= DIRENT_SIZE; for (i = entries_needed - 2; i >= 0; i++) - { - lfn_name = &lip->name[i * CHARS_IN_LFN_ENTRY]; - unicode_to_lfn(&lfn_name, lfn(fnp)); - fnp->f_dir.dir_attrib = D_LFN; - if (!dir_write(fnp)) return LHE_IOERROR; - fnp->f_diroff -= DIRENT_SIZE; - } - + { + lfn_name = &lip->name[i * CHARS_IN_LFN_ENTRY]; + unicode_to_lfn(&lfn_name, lfn(fnp)); + fnp->f_dir.dir_attrib = D_LFN; + if (!dir_write(fnp)) + return LHE_IOERROR; + fnp->f_diroff -= DIRENT_SIZE; + } + fnp->f_diroff = sfn_offset; return SUCCESS; @@ -250,15 +277,17 @@ COUNT lfn_create_entries(COUNT handle, lfn_inode_ptr lip) COUNT lfn_remove_entries(COUNT handle) { f_node_ptr fnp = xlt_fd(handle); - if (fnp == 0 || fnp->f_count <= 0) return LHE_INVLDHNDL; + if (fnp == 0 || fnp->f_count <= 0) + return LHE_INVLDHNDL; + + if (remove_lfn_entries(fnp) < 0) + return LHE_IOERROR; - if(remove_lfn_entries(fnp) < 0) return LHE_IOERROR; - return SUCCESS; } /* Calculate checksum for the 8.3 name */ -UBYTE lfn_checksum(UBYTE *sfn_name) +UBYTE lfn_checksum(UBYTE * sfn_name) { UBYTE sum; COUNT i; @@ -269,7 +298,7 @@ UBYTE lfn_checksum(UBYTE *sfn_name) return sum; } -COUNT ufstrlen(REG UNICODE FAR *s) +COUNT ufstrlen(REG UNICODE FAR * s) { REG COUNT cnt = 0; diff --git a/kernel/main.c b/kernel/main.c index f7d0cb30..322664b8 100644 --- a/kernel/main.c +++ b/kernel/main.c @@ -30,16 +30,15 @@ #include "portab.h" #include "init-mod.h" #include "dyndata.h" -#include "init-dat.h" +#include "init-dat.h" -GLOBAL BYTE copyright[] = +GLOBAL BYTE copyright[] = "(C) Copyright 1995-2001 Pasquale J. Villani and The FreeDOS Project.\n" "All Rights Reserved. This is free software and comes with ABSOLUTELY NO\n" "WARRANTY; you can redistribute it and/or modify it under the terms of the\n" "GNU General Public License as published by the Free Software Foundation;\n" "either version 2, or (at your option) any later version.\n"; - /* These are the far variables from the DOS data segment that we need here. The init procedure uses a different default DS data segment, which is discarded @@ -48,45 +47,41 @@ GLOBAL BYTE copyright[] = -- Bart */ -extern UBYTE DOSFAR nblkdev, - DOSFAR lastdrive; /* value of last drive */ +extern UBYTE DOSFAR nblkdev, DOSFAR lastdrive; /* value of last drive */ -GLOBAL BYTE - DOSFAR os_major, /* major version number */ - DOSFAR os_minor, /* minor version number */ - DOSFAR dosidle_flag, - DOSFAR BootDrive, /* Drive we came up from */ - DOSFAR default_drive; /* default drive for dos */ +GLOBAL BYTE DOSFAR os_major, /* major version number */ + DOSFAR os_minor, /* minor version number */ + DOSFAR dosidle_flag, DOSFAR BootDrive, /* Drive we came up from */ + DOSFAR default_drive; /* default drive for dos */ GLOBAL BYTE DOSFAR os_release[]; /* GLOBAL BYTE DOSFAR copyright[]; */ -GLOBAL seg DOSFAR RootPsp; /* Root process -- do not abort */ - -extern struct dpb FAR * DOSFAR DPBp; /* First drive Parameter Block */ -extern cdstbl FAR * DOSFAR CDSp; /* Current Directory Structure */ - -extern struct dhdr FAR * DOSFAR clock, /* CLOCK$ device */ - FAR * DOSFAR syscon; /* console device */ -extern struct dhdr DOSTEXTFAR con_dev, /* console device drive */ - DOSTEXTFAR clk_dev, /* Clock device driver */ - DOSTEXTFAR blk_dev; /* Block device (Disk) driver */ -extern UWORD - DOSFAR ram_top; /* How much ram in Kbytes */ -extern iregs FAR * DOSFAR user_r; /* User registers for int 21h call */ +GLOBAL seg DOSFAR RootPsp; /* Root process -- do not abort */ + +extern struct dpb FAR *DOSFAR DPBp; /* First drive Parameter Block */ +extern cdstbl FAR *DOSFAR CDSp; /* Current Directory Structure */ + +extern struct dhdr FAR *DOSFAR clock, /* CLOCK$ device */ + FAR * DOSFAR syscon; /* console device */ +extern struct dhdr DOSTEXTFAR con_dev, /* console device drive */ + DOSTEXTFAR clk_dev, /* Clock device driver */ + DOSTEXTFAR blk_dev; /* Block device (Disk) driver */ +extern UWORD DOSFAR ram_top; /* How much ram in Kbytes */ +extern iregs FAR *DOSFAR user_r; /* User registers for int 21h call */ extern BYTE FAR _HMATextEnd[]; #ifdef VERSION_STRINGS -static BYTE *mainRcsId = "$Id$"; +static BYTE *mainRcsId = + "$Id$"; #endif -struct _KernelConfig InitKernelConfig = {"", 0, 0, 0, 0, 0, 0}; - +struct _KernelConfig InitKernelConfig = { "", 0, 0, 0, 0, 0, 0 }; extern WORD days[2][13]; -extern BYTE FAR * lpBase; -extern BYTE FAR * lpOldTop; -extern BYTE FAR * lpTop; -extern BYTE FAR * upBase; +extern BYTE FAR *lpBase; +extern BYTE FAR *lpOldTop; +extern BYTE FAR *lpTop; +extern BYTE FAR *upBase; extern BYTE _ib_start[], _ib_end[], _init_end[]; INIT VOID configDone(VOID); @@ -100,38 +95,36 @@ INIT VOID FsConfig(VOID); INIT VOID InitPrinters(VOID); #ifdef _MSC_VER - BYTE _acrtused = 0; -#endif +BYTE _acrtused = 0; +#endif #ifdef _MSC_VER -__segment DosDataSeg = 0; /* serves for all references to the DOS DATA segment - necessary for MSC+our funny linking model - */ -__segment DosTextSeg = 0; - -#endif +__segment DosDataSeg = 0; /* serves for all references to the DOS DATA segment + necessary for MSC+our funny linking model + */ +__segment DosTextSeg = 0; +#endif INIT VOID ASMCFUNC FreeDOSmain(void) { -#ifdef _MSC_VER - extern FAR DATASTART; - extern FAR prn_dev; - DosDataSeg = (__segment)&DATASTART; - DosTextSeg = (__segment)&prn_dev; -#endif - - fmemcpy(&InitKernelConfig,&LowKernelConfig,sizeof(InitKernelConfig)); - - - setvec(0, int0_handler); /* zero divide */ - setvec(1, empty_handler); /* single step */ - setvec(3, empty_handler); /* debug breakpoint */ - setvec(6, empty_handler); /* invalid opcode */ - - /* clear the Init BSS area (what normally the RTL does */ - memset(_ib_start, 0, _ib_end - _ib_start); - +#ifdef _MSC_VER + extern FAR DATASTART; + extern FAR prn_dev; + DosDataSeg = (__segment) & DATASTART; + DosTextSeg = (__segment) & prn_dev; +#endif + + fmemcpy(&InitKernelConfig, &LowKernelConfig, sizeof(InitKernelConfig)); + + setvec(0, int0_handler); /* zero divide */ + setvec(1, empty_handler); /* single step */ + setvec(3, empty_handler); /* debug breakpoint */ + setvec(6, empty_handler); /* invalid opcode */ + + /* clear the Init BSS area (what normally the RTL does */ + memset(_ib_start, 0, _ib_end - _ib_start); + init_kernel(); #ifdef DEBUG @@ -155,19 +148,19 @@ INIT VOID ASMCFUNC FreeDOSmain(void) void InitializeAllBPBs(VOID) { static char filename[] = "A:-@JUNK@-.TMP"; - int drive,fileno; - for (drive = 'C'; drive < 'A'+nblkdev; drive++) - { - filename[0] = drive; - if ((fileno = open(filename, O_RDONLY)) >= 0) - close(fileno); - } -} + int drive, fileno; + for (drive = 'C'; drive < 'A' + nblkdev; drive++) + { + filename[0] = drive; + if ((fileno = open(filename, O_RDONLY)) >= 0) + close(fileno); + } +} INIT void init_kernel(void) { COUNT i; - + os_major = MAJOR_RELEASE; os_minor = MINOR_RELEASE; @@ -175,14 +168,14 @@ INIT void init_kernel(void) ram_top = init_oem(); /* move kernel to high conventional RAM, just below the init code */ - lpTop = MK_FP(ram_top * 64 - (FP_OFF(_init_end)+15)/16 - - (FP_OFF(_HMATextEnd)+15)/16, 0); - + lpTop = MK_FP(ram_top * 64 - (FP_OFF(_init_end) + 15) / 16 - + (FP_OFF(_HMATextEnd) + 15) / 16, 0); + MoveKernel(FP_SEG(lpTop)); lpOldTop = lpTop = MK_FP(FP_SEG(lpTop) - 0xfff, 0xfff0); /* Fake int 21h stack frame */ - user_r = (iregs FAR *) MK_FP(DOS_PSP,0xD0); + user_r = (iregs FAR *) MK_FP(DOS_PSP, 0xD0); #ifndef KDB for (i = 0x20; i <= 0x3f; i++) @@ -223,7 +216,7 @@ INIT void init_kernel(void) /* Number of units */ if (blk_dev.dh_name[0] > 0) - update_dcb(&blk_dev); + update_dcb(&blk_dev); /* Now config the temporary file system */ FsConfig(); @@ -235,7 +228,7 @@ INIT void init_kernel(void) /* Close all (device) files */ for (i = 0; i < lastdrive; i++) close(i); - + /* and do final buffer allocation. */ PostConfig(); nblkdev = 0; @@ -251,7 +244,7 @@ INIT void init_kernel(void) /* Close all (device) files */ for (i = 0; i < lastdrive; i++) close(i); - + /* Now config the final file system */ FsConfig(); @@ -274,7 +267,7 @@ INIT VOID FsConfig(VOID) dup2(STDIN, STDOUT); /* 2 is /dev/con (stderr) */ - dup2(STDIN, STDERR); + dup2(STDIN, STDERR); /* 3 is /dev/aux */ open("AUX", O_RDWR); @@ -288,15 +281,15 @@ INIT VOID FsConfig(VOID) dpb = DPBp; /* Initialize the current directory structures */ - for (i = 0; i < lastdrive ; i++) + for (i = 0; i < lastdrive; i++) { - struct cds FAR *pcds_table = &CDSp->cds_table[i]; + struct cds FAR *pcds_table = &CDSp->cds_table[i]; fmemcpy(pcds_table->cdsCurrentPath, "A:\\\0", 4); pcds_table->cdsCurrentPath[0] += i; - if (i < nblkdev && (ULONG)dpb != 0xffffffffl) + if (i < nblkdev && (ULONG) dpb != 0xffffffffl) { pcds_table->cdsDpb = dpb; pcds_table->cdsFlags = CDSPHYSDRV; @@ -318,39 +311,36 @@ INIT VOID FsConfig(VOID) INIT VOID signon() { - printf("\n%S" ,(void FAR *)os_release); + printf("\n%S", (void FAR *)os_release); - printf("Kernel compatibility %d.%d", - os_major, os_minor ); + printf("Kernel compatibility %d.%d", os_major, os_minor); #if defined(__TURBOC__) - printf(" - TURBOC"); + printf(" - TURBOC"); #elif defined(_MSC_VER) - printf(" - MSC"); + printf(" - MSC"); #elif defined(__WATCOMC__) - printf(" - WATCOMC"); + printf(" - WATCOMC"); #else - generate some bullshit error here, as the compiler should be known + generate some bullshit error here, as the compiler should be known #endif - #if defined (I386) - printf(" - 80386 CPU required"); + printf(" - 80386 CPU required"); #elif defined (I186) - printf(" - 80186 CPU required"); -#endif + printf(" - 80186 CPU required"); +#endif #ifdef WITHFAT32 - printf(" - FAT32 support"); -#endif - printf("\n\n%S",(void FAR *)copyright); + printf(" - FAT32 support"); +#endif + printf("\n\n%S", (void FAR *)copyright); } INIT void kernel() { -#if 0 - BYTE FAR *ep, - *sp; -#endif +#if 0 + BYTE FAR *ep, *sp; +#endif exec_blk exb; CommandTail Cmd; int rc; @@ -365,7 +355,7 @@ INIT void kernel() #else #if 0 /* create the master environment area */ - + if (allocmem(0x2, &exb.exec.env_seg)) init_fatal("cannot allocate master environment space"); @@ -381,67 +371,60 @@ INIT void kernel() *((int FAR *)ep) = 0; ep += sizeof(int); #else - exb.exec.env_seg = DOS_PSP+8; + exb.exec.env_seg = DOS_PSP + 8; fmemcpy(MK_FP(exb.exec.env_seg, 0), master_env, sizeof(master_env)); -#endif -#endif +#endif +#endif - RootPsp = ~0; - - /* process 0 */ /* Execute command.com /P from the drive we just booted from */ - fstrncpy(Cmd.ctBuffer, Config.cfgInitTail, - sizeof(Config.cfgInitTail)-1); + fstrncpy(Cmd.ctBuffer, Config.cfgInitTail, + sizeof(Config.cfgInitTail) - 1); for (Cmd.ctCount = 0; Cmd.ctCount < 127; Cmd.ctCount++) if (Cmd.ctBuffer[Cmd.ctCount] == '\r') break; + /* if stepping CONFIG.SYS (F5/F8), tell COMMAND.COM about it */ + + if (Cmd.ctCount < 127 - 3) + { + extern int singleStep; + extern int SkipAllConfig; + char *insertString = NULL; + + if (singleStep) + insertString = " /Y"; /* single step AUTOEXEC */ + if (SkipAllConfig) + insertString = " /D"; /* disable AUTOEXEC */ + if (insertString) + { - /* if stepping CONFIG.SYS (F5/F8), tell COMMAND.COM about it */ + /* insert /D, /Y as first argument */ + int cmdEnd, i, slen = strlen(insertString); - if (Cmd.ctCount < 127 - 3) - { - extern int singleStep ; - extern int SkipAllConfig; - char *insertString = NULL; - - if (singleStep) insertString = " /Y"; /* single step AUTOEXEC */ - - if (SkipAllConfig) insertString = " /D"; /* disable AUTOEXEC */ - - if (insertString) + for (cmdEnd = 0; cmdEnd < 127; cmdEnd++) { - - /* insert /D, /Y as first argument */ - int cmdEnd,i,slen = strlen(insertString); - - for (cmdEnd = 0;cmdEnd < 127; cmdEnd++) + if (Cmd.ctBuffer[cmdEnd] == ' ' || + Cmd.ctBuffer[cmdEnd] == '\t' || Cmd.ctBuffer[cmdEnd] == '\r') { - if (Cmd.ctBuffer[cmdEnd] == ' ' || - Cmd.ctBuffer[cmdEnd] == '\t' || - Cmd.ctBuffer[cmdEnd] == '\r') - { - for (i = 127 - slen; i >= cmdEnd; i--) - Cmd.ctBuffer[i+slen] = Cmd.ctBuffer[i]; - - fmemcpy(&Cmd.ctBuffer[cmdEnd], insertString,slen); - - Cmd.ctCount += slen; - - break; - } + for (i = 127 - slen; i >= cmdEnd; i--) + Cmd.ctBuffer[i + slen] = Cmd.ctBuffer[i]; + + fmemcpy(&Cmd.ctBuffer[cmdEnd], insertString, slen); + + Cmd.ctCount += slen; + + break; } - } + } + } } - - exb.exec.cmd_line = (CommandTail FAR *) & Cmd; exb.exec.fcb_1 = exb.exec.fcb_2 = (fcb FAR *) 0; @@ -449,13 +432,17 @@ INIT void kernel() printf("Process 0 starting: %s\n\n", Config.cfgInit); #endif - while ((rc = init_DosExec(Config.cfgP_0_startmode, &exb, Config.cfgInit)) != SUCCESS) + while ((rc = + init_DosExec(Config.cfgP_0_startmode, &exb, + Config.cfgInit)) != SUCCESS) { BYTE *pLine; - printf("\nBad or missing Command Interpreter: %d - %s\n", rc, Cmd.ctBuffer); - printf("\nPlease enter the correct location (for example C:\\COMMAND.COM):\n"); - rc = read(STDIN, Cmd.ctBuffer, sizeof(Cmd.ctBuffer)-1); - Cmd.ctBuffer[rc]='\0'; + printf("\nBad or missing Command Interpreter: %d - %s\n", rc, + Cmd.ctBuffer); + printf + ("\nPlease enter the correct location (for example C:\\COMMAND.COM):\n"); + rc = read(STDIN, Cmd.ctBuffer, sizeof(Cmd.ctBuffer) - 1); + Cmd.ctBuffer[rc] = '\0'; /* Get the string argument that represents the new init pgm */ pLine = GetStringArg(Cmd.ctBuffer, Config.cfgInit); @@ -466,8 +453,8 @@ INIT void kernel() /* and add a DOS new line just to be safe */ strcat(Cmd.ctBuffer, "\r\n"); - - Cmd.ctCount = rc-(pLine-Cmd.ctBuffer); + + Cmd.ctCount = rc - (pLine - Cmd.ctBuffer); #ifdef DEBUG printf("Process 0 starting: %s\n\n", Config.cfgInit); @@ -484,17 +471,20 @@ static VOID update_dcb(struct dhdr FAR * dhp) COUNT nunits = dhp->dh_name[0]; struct dpb FAR *dpb; - if (nblkdev==0) + if (nblkdev == 0) dpb = DPBp; - else { - for (dpb = DPBp; (ULONG)dpb->dpb_next != 0xffffffffl; dpb = dpb->dpb_next) + else + { + for (dpb = DPBp; (ULONG) dpb->dpb_next != 0xffffffffl; + dpb = dpb->dpb_next) ; - dpb = dpb->dpb_next = (struct dpb FAR *)KernelAlloc(nunits*sizeof(struct dpb)); + dpb = dpb->dpb_next = + (struct dpb FAR *)KernelAlloc(nunits * sizeof(struct dpb)); } - for(Index = 0; Index < nunits; Index++) - { - dpb->dpb_next = dpb+1; + for (Index = 0; Index < nunits; Index++) + { + dpb->dpb_next = dpb + 1; dpb->dpb_unit = nblkdev; dpb->dpb_subunit = Index; dpb->dpb_device = dhp; @@ -507,17 +497,17 @@ static VOID update_dcb(struct dhdr FAR * dhp) ++dpb; ++nblkdev; } - (dpb-1)->dpb_next = (void FAR *)0xFFFFFFFFl; + (dpb - 1)->dpb_next = (void FAR *)0xFFFFFFFFl; } - /* If cmdLine is NULL, this is an internal driver */ -BOOL init_device(struct dhdr FAR * dhp, BYTE FAR * cmdLine, COUNT mode, COUNT r_top) +BOOL init_device(struct dhdr FAR * dhp, BYTE FAR * cmdLine, COUNT mode, + COUNT r_top) { request rq; - UCOUNT maxmem = ((UCOUNT)r_top << 6) - FP_SEG(dhp); + UCOUNT maxmem = ((UCOUNT) r_top << 6) - FP_SEG(dhp); if (maxmem >= 0x1000) maxmem = 0xFFFF; @@ -540,25 +530,27 @@ BOOL init_device(struct dhdr FAR * dhp, BYTE FAR * cmdLine, COUNT mode, COUNT r_ if (rq.r_status & S_ERROR) return TRUE; - if(cmdLine){ + if (cmdLine) + { if (mode) { /* Don't link in device drivers which do not take up memory */ - if (rq.r_endaddr == (BYTE FAR *)dhp) + if (rq.r_endaddr == (BYTE FAR *) dhp) return TRUE; else upBase = rq.r_endaddr; } else { - if (rq.r_endaddr == (BYTE FAR *)dhp) + if (rq.r_endaddr == (BYTE FAR *) dhp) return TRUE; else lpBase = rq.r_endaddr; } } - if (!(dhp->dh_attr & ATTR_CHAR) && (rq.r_nunits != 0)) { + if (!(dhp->dh_attr & ATTR_CHAR) && (rq.r_nunits != 0)) + { dhp->dh_name[0] = rq.r_nunits; update_dcb(dhp); } @@ -571,7 +563,6 @@ BOOL init_device(struct dhdr FAR * dhp, BYTE FAR * cmdLine, COUNT mode, COUNT r_ return FALSE; } - INIT static void InitIO(void) { /* Initialize driver chain */ @@ -598,19 +589,19 @@ VOID init_fatal(BYTE * err_msg) INIT VOID InitPrinters(VOID) { - iregs r; - int num_printers,i; + iregs r; + int num_printers, i; - init_call_intr(0x11,&r); /* get equipment list */ + init_call_intr(0x11, &r); /* get equipment list */ - num_printers = (r.a.x >> 14) & 3; /* bits 15-14 */ - - for (i = 0;i < num_printers;i++) - { - r.a.x = 0x0100; /* initialize printer */ - r.d.x = i; - init_call_intr(0x17,&r); - } + num_printers = (r.a.x >> 14) & 3; /* bits 15-14 */ + + for (i = 0; i < num_printers; i++) + { + r.a.x = 0x0100; /* initialize printer */ + r.d.x = i; + init_call_intr(0x17, &r); + } } /* @@ -705,5 +696,3 @@ INIT VOID InitPrinters(VOID) * Rev 1.0 02 Jul 1995 8:33:18 patv * Initial revision. */ - - diff --git a/kernel/memmgr.c b/kernel/memmgr.c index 0eca2097..54e673dd 100644 --- a/kernel/memmgr.c +++ b/kernel/memmgr.c @@ -30,7 +30,8 @@ #include "globals.h" #ifdef VERSION_STRING -static BYTE *memmgrRcsId = "$Id$"; +static BYTE *memmgrRcsId = + "$Id$"; #endif VOID mcb_init(); @@ -40,9 +41,9 @@ VOID show_chain(); /*#define nxtMCBsize(mcb,size) \ MK_FP(far2para((VOID FAR *) (mcb)) + (size) + 1, 0) */ -void FAR *nxtMCBsize(mcb FAR *Mcb, int size) +void FAR *nxtMCBsize(mcb FAR * Mcb, int size) { - return MK_FP(far2para((VOID FAR *) (Mcb)) + (size) + 1, 0); + return MK_FP(far2para((VOID FAR *) (Mcb)) + (size) + 1, 0); } #define nxtMCB(mcb) nxtMCBsize((mcb), (mcb)->m_size) @@ -85,10 +86,10 @@ seg far2para(VOID FAR * p) seg long2para(ULONG size) { - UWORD high = size>>16; - if ((UWORD)size > 0xfff0) - high++; - return (((UWORD)size + 0x0f) >> 4) + (high << 12); + UWORD high = size >> 16; + if ((UWORD) size > 0xfff0) + high++; + return (((UWORD) size + 0x0f) >> 4) + (high << 12); } /* @@ -97,11 +98,12 @@ seg long2para(ULONG size) VOID FAR *add_far(VOID FAR * fp, ULONG off) { UWORD off2; - - if (FP_SEG(fp) == 0xffff) return ((BYTE FAR *)fp) + FP_OFF(off); - + + if (FP_SEG(fp) == 0xffff) + return ((BYTE FAR *) fp) + FP_OFF(off); + off += FP_OFF(fp); - off2 = ((off >> 16) << 12) + ((UWORD)off >> 4); + off2 = ((off >> 16) << 12) + ((UWORD) off >> 4); return MK_FP(FP_SEG(fp) + off2, (UWORD) off & 0xf); } @@ -113,16 +115,17 @@ VOID FAR *adjust_far(VOID FAR * fp) { /* and return an adddress adjusted to the nearest paragraph */ /* boundary. */ - - if (FP_SEG(fp) == 0xffff) return fp; - + + if (FP_SEG(fp) == 0xffff) + return fp; + return MK_FP(FP_SEG(fp) + (FP_OFF(fp) >> 4), FP_OFF(fp) & 0xf); } #undef REG #define REG -#if 1 /* #ifdef KERNEL KERNEL */ +#if 1 /* #ifdef KERNEL KERNEL */ /* Allocate a new memory area. *para is assigned to the segment of the MCB rather then the segment of the data portion */ /* If mode == LARGEST, asize MUST be != NULL and will always recieve the @@ -132,7 +135,8 @@ VOID FAR *adjust_far(VOID FAR * fp) size is the minimum size of the block to search for, even if mode == LARGEST. */ -COUNT DosMemAlloc(UWORD size, COUNT mode, seg FAR * para, UWORD FAR * asize) +COUNT DosMemAlloc(UWORD size, COUNT mode, seg FAR * para, + UWORD FAR * asize) { REG mcb FAR *p; mcb FAR *foundSeg; @@ -140,16 +144,16 @@ COUNT DosMemAlloc(UWORD size, COUNT mode, seg FAR * para, UWORD FAR * asize) /* Initialize */ searchAgain: - + p = para2far(first_mcb); biggestSeg = foundSeg = NULL; /* Hack to the Umb Region direct for now. Save time and program space. */ - if((mode != LARGEST) && (mode & (FIRST_FIT_UO | FIRST_FIT_U)) && - uppermem_link && uppermem_root) - p = para2far(uppermem_root); + if ((mode != LARGEST) && (mode & (FIRST_FIT_UO | FIRST_FIT_U)) && + uppermem_link && uppermem_root) + p = para2far(uppermem_root); /* Search through memory blocks */ FOREVER @@ -157,10 +161,10 @@ COUNT DosMemAlloc(UWORD size, COUNT mode, seg FAR * para, UWORD FAR * asize) /* check for corruption */ if (!mcbValid(p)) return DE_MCBDESTRY; - + if (mcbFree(p)) { /* unused block, check if it applies to the rule */ - if (joinMCBs(p) != SUCCESS) /* join following unused blocks */ + if (joinMCBs(p) != SUCCESS) /* join following unused blocks */ return DE_MCBDESTRY; /* error */ if (!biggestSeg || biggestSeg->m_size < p->m_size) @@ -191,7 +195,7 @@ COUNT DosMemAlloc(UWORD size, COUNT mode, seg FAR * para, UWORD FAR * asize) foundSeg = p; break; - case FIRST_FIT: /* first possible */ + case FIRST_FIT: /* first possible */ case FIRST_FIT_U: case FIRST_FIT_UO: foundSeg = p; @@ -212,11 +216,12 @@ COUNT DosMemAlloc(UWORD size, COUNT mode, seg FAR * para, UWORD FAR * asize) if (!foundSeg || !foundSeg->m_size) { /* no block to fullfill the request */ - if((mode != LARGEST) && (mode & FIRST_FIT_U) && - uppermem_link && uppermem_root) { + if ((mode != LARGEST) && (mode & FIRST_FIT_U) && + uppermem_link && uppermem_root) + { mode &= ~FIRST_FIT_U; goto searchAgain; - } + } if (asize) *asize = biggestSeg ? biggestSeg->m_size : 0; return DE_NOMEM; @@ -230,7 +235,8 @@ COUNT DosMemAlloc(UWORD size, COUNT mode, seg FAR * para, UWORD FAR * asize) /* foundSeg := pointer to allocated block p := pointer to MCB that will form the rest of the block */ - if ((mode == LAST_FIT)||(mode == LAST_FIT_UO)||(mode == LAST_FIT_U)) + if ((mode == LAST_FIT) || (mode == LAST_FIT_UO) + || (mode == LAST_FIT_U)) { /* allocate the block from the end of the found block */ p = foundSeg; @@ -283,9 +289,8 @@ COUNT DosMemLargest(UWORD FAR * size) REG mcb FAR *p; /* Initialize */ - p = ((mem_access_mode & (FIRST_FIT_UO | FIRST_FIT_U)) && uppermem_link && uppermem_root) - ? para2far(uppermem_root) - : para2far(first_mcb); + p = ((mem_access_mode & (FIRST_FIT_UO | FIRST_FIT_U)) && uppermem_link + && uppermem_root) ? para2far(uppermem_root) : para2far(first_mcb); /* Cycle through the whole MCB chain to find the largest unused area. Join all unused areas together. */ @@ -384,8 +389,7 @@ COUNT DosMemFree(UWORD para) */ COUNT DosMemChange(UWORD para, UWORD size, UWORD * maxSize) { - REG mcb FAR *p, - FAR * q; + REG mcb FAR *p, FAR * q; REG COUNT i; /* Initialize */ @@ -435,9 +439,9 @@ COUNT DosMemChange(UWORD para, UWORD size, UWORD * maxSize) /* MS network client NET.EXE: DosMemChange sets the PSP * * not tested, if always, or only on success TE* - * only on success seems more logical to me - Bart */ + * only on success seems more logical to me - Bart */ p->m_psp = cu_psp; - + return SUCCESS; } @@ -457,12 +461,12 @@ COUNT DosMemCheck(void) { /* check for corruption */ if (p->m_type != MCB_NORMAL) - { + { printf("dos mem corrupt, first_mcb=%04x\n", first_mcb); - hexd("prev " ,pprev,16); - hexd("notMZ",p,16); + hexd("prev ", pprev, 16); + hexd("notMZ", p, 16); return DE_MCBDESTRY; - } + } /* not corrupted - but not end, bump the pointer */ pprev = p; @@ -476,31 +480,31 @@ COUNT FreeProcessMem(UWORD ps) mcb FAR *p; BYTE oldumbstate = uppermem_link; - /* link in upper memory to free those , too */ + /* link in upper memory to free those , too */ DosUmbLink(1); /* Search through all memory blocks */ - for (p = para2far(first_mcb);; p = nxtMCB(p)) - { + for (p = para2far(first_mcb);; p = nxtMCB(p)) + { if (!mcbValid(p)) /* check for corruption */ - return DE_MCBDESTRY; + return DE_MCBDESTRY; if (p->m_psp == ps) - DosMemFree(FP_SEG(p)); - + DosMemFree(FP_SEG(p)); + if (p->m_type == MCB_LAST) - break; - } + break; + } + + DosUmbLink(oldumbstate); - DosUmbLink(oldumbstate); - return SUCCESS; } -#if 0 - /* seems to be superceeded by DosMemLargest - -- 1999/04/21 ska */ +#if 0 + /* seems to be superceeded by DosMemLargest + -- 1999/04/21 ska */ COUNT DosGetLargestBlock(UWORD FAR * block) { UWORD sz = 0; @@ -552,60 +556,57 @@ VOID mcb_print(mcb FAR * mcbp) fmemcpy((BYTE FAR *) buff, (BYTE FAR *) (mcbp->m_name), 8); buff[8] = '\0'; - printf("%04x:%04x -> |%s| m_type = 0x%02x '%c'; m_psp = 0x%04x; m_size = 0x%04x\n", - FP_SEG(mcbp), - FP_OFF(mcbp), - *buff == '\0' ? "*NO-ID*" : buff, - mcbp->m_type, mcbp->m_type > ' ' ? mcbp->m_type : ' ', - mcbp->m_psp, - mcbp->m_size); + printf + ("%04x:%04x -> |%s| m_type = 0x%02x '%c'; m_psp = 0x%04x; m_size = 0x%04x\n", + FP_SEG(mcbp), FP_OFF(mcbp), *buff == '\0' ? "*NO-ID*" : buff, + mcbp->m_type, mcbp->m_type > ' ' ? mcbp->m_type : ' ', mcbp->m_psp, + mcbp->m_size); } #endif VOID DosUmbLink(BYTE n) { - REG mcb FAR *p; - REG mcb FAR *q; - mcb FAR *end_of_conv_mem = para2far(ram_top*64-1); - - if (uppermem_root == 0) - return; - - q = p = para2far(first_mcb); + REG mcb FAR *p; + REG mcb FAR *q; + mcb FAR *end_of_conv_mem = para2far(ram_top * 64 - 1); + + if (uppermem_root == 0) + return; + + q = p = para2far(first_mcb); /* like a xor thing! */ - if((uppermem_link == 1) && (n == 0)) + if ((uppermem_link == 1) && (n == 0)) + { + while (p != end_of_conv_mem) { - while ( p != end_of_conv_mem ) - { - if (mcbFree(p)) - joinMCBs(p); - if (!mcbValid(p)) - goto DUL_exit; - q = p; - p = nxtMCB(p); - } - - if(q->m_type == MCB_NORMAL) - q->m_type = MCB_LAST; - uppermem_link = n; - + if (mcbFree(p)) + joinMCBs(p); + if (!mcbValid(p)) + goto DUL_exit; + q = p; + p = nxtMCB(p); } - else - if((uppermem_link == 0) && (n == 1)) - { - while( q->m_type != MCB_LAST) - { - if (!mcbValid(q)) - goto DUL_exit; - q = nxtMCB(q); - } - - if(q->m_type == MCB_LAST) - q->m_type = MCB_NORMAL; - uppermem_link = n; - } + + if (q->m_type == MCB_NORMAL) + q->m_type = MCB_LAST; + uppermem_link = n; + + } + else if ((uppermem_link == 0) && (n == 1)) + { + while (q->m_type != MCB_LAST) + { + if (!mcbValid(q)) + goto DUL_exit; + q = nxtMCB(q); + } + + if (q->m_type == MCB_LAST) + q->m_type = MCB_NORMAL; + uppermem_link = n; + } DUL_exit: - return; + return; } /* @@ -620,44 +621,42 @@ VOID DosUmbLink(BYTE n) */ #if 0 -BYTE INITDataSegmentClaimed = 1; /* must be enabled by CONFIG.SYS */ +BYTE INITDataSegmentClaimed = 1; /* must be enabled by CONFIG.SYS */ extern BYTE _INIT_DATA_START[], _INIT_DATA_END[]; VOID ClaimINITDataSegment() { - unsigned ilow,ihigh; - VOID FAR * p; - - if (INITDataSegmentClaimed) - return; - INITDataSegmentClaimed = 1; - + unsigned ilow, ihigh; + VOID FAR *p; - ilow = (unsigned)_INIT_DATA_START; - ilow = (ilow+0x0f) & ~0x000f; - ihigh = (unsigned)_INIT_DATA_END; - ihigh = ((ihigh + 0x0f) & ~0x000f) - 0x20; + if (INITDataSegmentClaimed) + return; + INITDataSegmentClaimed = 1; - if (ilow +0x10 < ihigh) - { - printf("CLAIMING INIT_DATA memory - %u bytes\n",ihigh - ilow); - } + ilow = (unsigned)_INIT_DATA_START; + ilow = (ilow + 0x0f) & ~0x000f; + ihigh = (unsigned)_INIT_DATA_END; + ihigh = ((ihigh + 0x0f) & ~0x000f) - 0x20; + if (ilow + 0x10 < ihigh) + { + printf("CLAIMING INIT_DATA memory - %u bytes\n", ihigh - ilow); + } - ((mcb*)ilow)->m_type = MCB_NORMAL; /* 'M' */ - ((mcb*)ilow)->m_psp = FREE_PSP; /* '0' */ - ((mcb*)ilow)->m_size = (ihigh-ilow-0x10)>>4; /* '0' */ + ((mcb *) ilow)->m_type = MCB_NORMAL; /* 'M' */ + ((mcb *) ilow)->m_psp = FREE_PSP; /* '0' */ + ((mcb *) ilow)->m_size = (ihigh - ilow - 0x10) >> 4; /* '0' */ - ((mcb*)ihigh)->m_type = MCB_NORMAL; /* 'M' */ - ((mcb*)ihigh)->m_psp = 0x0008; /* system */ + ((mcb *) ihigh)->m_type = MCB_NORMAL; /* 'M' */ + ((mcb *) ihigh)->m_psp = 0x0008; /* system */ - p = (void FAR*)(void*)ihigh; + p = (void FAR *)(void *)ihigh; - ((mcb*)ihigh)->m_size = first_mcb -1 - FP_SEG(p) - (FP_OFF(p) >> 4); + ((mcb *) ihigh)->m_size = first_mcb - 1 - FP_SEG(p) - (FP_OFF(p) >> 4); - p = (void FAR*)(void*)ilow; + p = (void FAR *)(void *)ilow; - first_mcb = FP_SEG(p) + (FP_OFF(p) >> 4); + first_mcb = FP_SEG(p) + (FP_OFF(p) >> 4); } #endif @@ -712,4 +711,3 @@ VOID ClaimINITDataSegment() * Rev 1.0 02 Jul 1995 8:33:08 patv * Initial revision. */ - diff --git a/kernel/misc.c b/kernel/misc.c index e4c4e306..c5f602e6 100644 --- a/kernel/misc.c +++ b/kernel/misc.c @@ -29,7 +29,8 @@ #include "portab.h" #ifdef VERSION_STRINGS -static BYTE *miscRcsId = "$Id$"; +static BYTE *miscRcsId = + "$Id$"; #endif #include "globals.h" @@ -119,4 +120,3 @@ VOID fmemset(REG VOID FAR * s, REG int ch, REG COUNT n) * Rev 1.0 02 Jul 1995 8:06:28 patv * Initial revision. */ - diff --git a/kernel/network.c b/kernel/network.c index 75186d40..e411048b 100644 --- a/kernel/network.c +++ b/kernel/network.c @@ -31,7 +31,8 @@ #include "globals.h" #ifdef VERSION_STRINGS -static BYTE *RcsId = "$Id$"; +static BYTE *RcsId = + "$Id$"; #endif /* see RBIL D-2152 and D-215D06 before attempting @@ -66,4 +67,3 @@ VOID set_machine_name(BYTE FAR * netname, UWORD name_num) * *** empty log message *** * */ - diff --git a/kernel/newstuff.c b/kernel/newstuff.c index 8c4fdd94..c16c5ec7 100644 --- a/kernel/newstuff.c +++ b/kernel/newstuff.c @@ -26,7 +26,8 @@ /****************************************************************/ #ifdef VERSION_STRINGS -static BYTE *mainRcsId = "$Id$"; +static BYTE *mainRcsId = + "$Id$"; #endif #include "portab.h" @@ -39,8 +40,7 @@ static BYTE *mainRcsId = "$Id$"; */ int SetJFTSize(UWORD nHandles) { - UWORD block, - maxBlock; + UWORD block, maxBlock; psp FAR *ppsp = MK_FP(cu_psp, 0); UBYTE FAR *newtab; COUNT i; @@ -51,7 +51,8 @@ int SetJFTSize(UWORD nHandles) return SUCCESS; } - if ((DosMemAlloc((nHandles + 0xf) >> 4, mem_access_mode, &block, &maxBlock)) < 0) + if ((DosMemAlloc + ((nHandles + 0xf) >> 4, mem_access_mode, &block, &maxBlock)) < 0) return DE_NOMEM; ++block; @@ -74,13 +75,8 @@ int DosMkTmp(BYTE FAR * pathname, UWORD attr) { /* create filename from current date and time */ char FAR *ptmp = pathname; - BYTE wd, - month, - day; - BYTE h, - m, - s, - hund; + BYTE wd, month, day; + BYTE h, m, s, hund; WORD sh; WORD year; int rc; @@ -98,40 +94,39 @@ int DosMkTmp(BYTE FAR * pathname, UWORD attr) sh = s * 100 + hund; - for ( loop = 0; loop < 0xfff; loop++) - { - sprintf(name83,"%x%x%x%x%x%03x.%03x", + for (loop = 0; loop < 0xfff; loop++) + { + sprintf(name83, "%x%x%x%x%x%03x.%03x", + year & 0xf, month & 0xf, day & 0xf, h & 0xf, m & 0xf, + sh & 0xfff, loop & 0xfff); - year & 0xf,month & 0xf, day & 0xf,h & 0xf,m & 0xf, sh&0xfff, - loop & 0xfff); + fmemcpy(ptmp, name83, 13); - fmemcpy(ptmp, name83, 13); + if ((rc = DosOpen(pathname, 0)) < 0 && rc != DE_ACCESS /* subdirectory ?? */ + /* todo: sharing collision on + network drive + */ + ) + break; - if ((rc = DosOpen(pathname, 0)) < 0 && - rc != DE_ACCESS /* subdirectory ?? */ - /* todo: sharing collision on - network drive - */ - ) - break; - - if (rc >= 0) DosClose(rc); - } + if (rc >= 0) + DosClose(rc); + } - if (rc == DE_FILENOTFND) - { - rc = DosCreat(pathname, attr); - } - return rc; + if (rc == DE_FILENOTFND) + { + rc = DosCreat(pathname, attr); + } + return rc; } -COUNT get_verify_drive(char FAR *src) +COUNT get_verify_drive(char FAR * src) { UBYTE drive; /* Do we have a drive? */ if (src[1] == ':') - drive = ((src[0]-1) | 0x20) - ('a'-1); + drive = ((src[0] - 1) | 0x20) - ('a' - 1); else return default_drive; if (drive < lastdrive && CDSp->cds_table[drive].cdsFlags & CDSVALID) @@ -147,7 +142,7 @@ COUNT get_verify_drive(char FAR *src) * MSD returns \\D.\A.\????????.??? with SHSUCDX. So, this code is not * compatible MSD Func 60h. */ - + /*TE TODO: experimenting with NUL on MSDOS 7.0 (win95) @@ -161,13 +156,13 @@ COUNT get_verify_drive(char FAR *src) TRUENAME A:NUL A:/NUL OK TRUENAME A:\NUL A:\NUL -*/ - +*/ + COUNT ASMCFUNC truename(char FAR * src, char FAR * dest, COUNT t) { static char buf[128] = "A:\\\0\0\0\0\0\0\0\0\0"; char *bufp = buf + 3; - COUNT i, rootEndPos = 2; /* renamed x to rootEndPos - Ron Cemer */ + COUNT i, rootEndPos = 2; /* renamed x to rootEndPos - Ron Cemer */ struct dhdr FAR *dhp; BYTE FAR *froot; WORD d; @@ -176,10 +171,10 @@ COUNT ASMCFUNC truename(char FAR * src, char FAR * dest, COUNT t) i = get_verify_drive(src); if (i < 0) - return DE_INVLDDRV; - + return DE_INVLDDRV; + buf[0] = i + 'A'; - buf[1] = ':'; /* Just to be sure */ + buf[1] = ':'; /* Just to be sure */ /* First, adjust the source pointer */ src = adjust_far(src); @@ -193,42 +188,51 @@ COUNT ASMCFUNC truename(char FAR * src, char FAR * dest, COUNT t) MSD returns X:/CON for truename con. Not X:\CON */ /* check for a device */ - - if ((*src != '.') && (*src != '\\') && (*src != '/') && ((dhp = IsDevice(src)) != NULL)) - { - + + if ((*src != '.') && (*src != '\\') && (*src != '/') + && ((dhp = IsDevice(src)) != NULL)) + { + froot = get_root(src); /* /// Bugfix: NUL.LST is the same as NUL. This is true for all - devices. On a device name, the extension is irrelevant - as long as the name matches. - - Ron Cemer */ - - buf[2] ='/'; - /* /// Bug: should be only copying up to first space. - - Ron Cemer */ - - for (d = 0; d < FNAME_SIZE && dhp->dh_name[d] != 0 && dhp->dh_name[d] != ' '; d++) - *bufp++ = dhp->dh_name[d]; - /* /// DOS will return C:/NUL.LST if you pass NUL.LST in. - DOS will also return C:/NUL.??? if you pass NUL.* in. - Code added here to support this. - - Ron Cemer */ - while ( (*froot != '.') && (*froot != '\0') ) froot++; - if (*froot) froot++; - if (*froot) { - *bufp++ = '.'; - for (i = 0; i < FEXT_SIZE; i++) { - if ( (*froot == '\0') || (*froot == '.') ) - break; - if (*froot == '*') { - for (; i < FEXT_SIZE; i++) *bufp++ = '?'; - break; - } - *bufp++ = *froot++; + devices. On a device name, the extension is irrelevant + as long as the name matches. + - Ron Cemer */ + + buf[2] = '/'; + /* /// Bug: should be only copying up to first space. + - Ron Cemer */ + + for (d = 0; + d < FNAME_SIZE && dhp->dh_name[d] != 0 && dhp->dh_name[d] != ' '; + d++) + *bufp++ = dhp->dh_name[d]; + /* /// DOS will return C:/NUL.LST if you pass NUL.LST in. + DOS will also return C:/NUL.??? if you pass NUL.* in. + Code added here to support this. + - Ron Cemer */ + while ((*froot != '.') && (*froot != '\0')) + froot++; + if (*froot) + froot++; + if (*froot) + { + *bufp++ = '.'; + for (i = 0; i < FEXT_SIZE; i++) + { + if ((*froot == '\0') || (*froot == '.')) + break; + if (*froot == '*') + { + for (; i < FEXT_SIZE; i++) + *bufp++ = '?'; + break; } + *bufp++ = *froot++; + } } - /* /// End of code additions. - Ron Cemer */ + /* /// End of code additions. - Ron Cemer */ goto exit_tn; } @@ -240,28 +244,33 @@ COUNT ASMCFUNC truename(char FAR * src, char FAR * dest, COUNT t) * path to the executable file. * Jun 11, 2000 - rbc */ /* /// Changed to "while" from "if". - Ron Cemer */ - while ( (src[0] == '.') && (src[1] == '\\') ) src += 2; - + while ((src[0] == '.') && (src[1] == '\\')) + src += 2; + current_ldt = &CDSp->cds_table[i]; /* Always give the redirector a chance to rewrite the filename */ fstrncpy(bufp - 1, src, sizeof(buf) - (bufp - buf)); - if ((t == FALSE) && (QRemote_Fn(buf, dest) == SUCCESS) && (dest[0] != '\0')) { + if ((t == FALSE) && (QRemote_Fn(buf, dest) == SUCCESS) + && (dest[0] != '\0')) + { return SUCCESS; - } else { + } + else + { bufp[-1] = '\\'; } - if (t == FALSE) - { - fstrncpy(buf, current_ldt->cdsCurrentPath, current_ldt->cdsJoinOffset); - bufp = buf + current_ldt->cdsJoinOffset; - rootEndPos = current_ldt->cdsJoinOffset; /* renamed x to rootEndPos - Ron Cemer */ - *bufp++ = '\\'; - } + if (t == FALSE) + { + fstrncpy(buf, current_ldt->cdsCurrentPath, current_ldt->cdsJoinOffset); + bufp = buf + current_ldt->cdsJoinOffset; + rootEndPos = current_ldt->cdsJoinOffset; /* renamed x to rootEndPos - Ron Cemer */ + *bufp++ = '\\'; + } - if (*src != '\\' && *src != '/') /* append current dir */ + if (*src != '\\' && *src != '/') /* append current dir */ { - DosGetCuDir((UBYTE)(i+1), bufp); + DosGetCuDir((UBYTE) (i + 1), bufp); if (*bufp) { while (*bufp) @@ -274,16 +283,16 @@ COUNT ASMCFUNC truename(char FAR * src, char FAR * dest, COUNT t) /*move_name:*/ - /* /// The block inside the "#if (0) ... #endif" is - seriously broken. New code added below to replace it. - This eliminates many serious bugs, specifically - with FreeCOM where truename is required to work - according to the DOS specification in order for - the COPY and other file-related commands to work - properly. - This should be a major improvement to all apps which - use truename. - - Ron Cemer */ + /* /// The block inside the "#if (0) ... #endif" is + seriously broken. New code added below to replace it. + This eliminates many serious bugs, specifically + with FreeCOM where truename is required to work + according to the DOS specification in order for + the COPY and other file-related commands to work + properly. + This should be a major improvement to all apps which + use truename. + - Ron Cemer */ #if (0) /* @@ -291,14 +300,14 @@ COUNT ASMCFUNC truename(char FAR * src, char FAR * dest, COUNT t) * function are operating with in normal parms. * jt */ - n = 9; + n = 9; /* convert all forward slashes to backslashes, and uppercase all characters */ while (*src) { char c; c = *src++; - if(!n) - return DE_PATHNOTFND; /* do this for now */ + if (!n) + return DE_PATHNOTFND; /* do this for now */ n--; switch (c) { @@ -327,9 +336,10 @@ COUNT ASMCFUNC truename(char FAR * src, char FAR * dest, COUNT t) case '/': /* convert to backslash */ case '\\': - if (bufp[-1] != '\\'){ - *bufp++ = '\\'; - n = 9; + if (bufp[-1] != '\\') + { + *bufp++ = '\\'; + n = 9; } break; @@ -343,7 +353,7 @@ COUNT ASMCFUNC truename(char FAR * src, char FAR * dest, COUNT t) for (bufp -= 2; *bufp != '\\'; bufp--) { - if (bufp < buf + rootEndPos) /* '..' illegal in root dir */ + if (bufp < buf + rootEndPos) /* '..' illegal in root dir */ return DE_PATHNOTFND; } src++; @@ -351,20 +361,20 @@ COUNT ASMCFUNC truename(char FAR * src, char FAR * dest, COUNT t) bufp++; } else if (*src == '/' || *src == '\\' || *src == 0) - break; - /* --bufp;*/ - else - return DE_PATHNOTFND; + break; + /* --bufp; */ + else + return DE_PATHNOTFND; + } + else if (*src == '/' || *src == '\\' || *src == 0) + { + break; + } + else + { + n = 4; + *bufp++ = c; } - else if ( *src == '/' || *src == '\\' || *src == 0) - { - break; - } - else - { - n = 4; - *bufp++ = c; - } break; default: @@ -379,110 +389,138 @@ COUNT ASMCFUNC truename(char FAR * src, char FAR * dest, COUNT t) #endif /* /// Beginning of new code. - Ron Cemer */ - bufp--; + bufp--; + { + char c, *bufend = buf + (sizeof(buf) - 1); + int gotAnyWildcards = 0; + int seglen, copylen, state; + while ((*src) && (bufp < bufend)) { - char c, *bufend = buf+(sizeof(buf)-1); - int gotAnyWildcards = 0; - int seglen, copylen, state; - while ( (*src) && (bufp < bufend) ) { - /* Skip duplicated slashes. */ - while ( (*src == '/') || (*src == '\\') ) src++; - if (!(*src)) break; - /* Find the end of this segment in the source string. */ - for (seglen = 0; ; seglen++) { - c = src[seglen]; - if ( (c == '\0') || (c == '/') || (c == '\\') ) - break; + /* Skip duplicated slashes. */ + while ((*src == '/') || (*src == '\\')) + src++; + if (!(*src)) + break; + /* Find the end of this segment in the source string. */ + for (seglen = 0;; seglen++) + { + c = src[seglen]; + if ((c == '\0') || (c == '/') || (c == '\\')) + break; + } + if (seglen > 0) + { + /* Ignore all ".\" or "\." path segments. */ + if ((seglen != 1) || (*src != '.')) + { + /* Apply ".." to the path by removing + last path segment from buf. */ + if ((seglen == 2) && (src[0] == '.') && (src[1] == '.')) + { + if (bufp > (buf + rootEndPos)) + { + bufp--; + while ((bufp > (buf + rootEndPos)) + && (*bufp != '/') && (*bufp != '\\')) + bufp--; } - if (seglen > 0) { - /* Ignore all ".\" or "\." path segments. */ - if ( (seglen != 1) || (*src != '.') ) { - /* Apply ".." to the path by removing - last path segment from buf. */ - if ( (seglen==2) && (src[0] == '.') && (src[1] == '.') ) { - if (bufp > (buf+rootEndPos)) { - bufp--; - while ( (bufp > (buf+rootEndPos)) - && (*bufp != '/') - && (*bufp != '\\') ) - bufp--; - } else { - /* .. in root dir illegal */ - return DE_PATHNOTFND; - } - } else { - /* New segment. If any wildcards in previous - segment(s), this is an invalid path. */ - if (gotAnyWildcards || src[0]=='.') return DE_PATHNOTFND; - /* Append current path segment to result. */ - *(bufp++) = '\\'; - if (bufp >= bufend) break; - copylen = state = 0; - for (i=0; ( (i < seglen) && (bufp < bufend) ); i++) { - c = src[i]; - gotAnyWildcards |= ( (c == '?') || (c == '*') ); - switch (state) { - case 0: /* Copying filename (excl. extension) */ - if (c == '*') { - while (copylen < FNAME_SIZE) { - *(bufp++) = '?'; - if (bufp >= bufend) break; - copylen++; - } - copylen = 0; - state = 1; /* Go wait for dot */ - break; - } - if (c == '.') { - if (src[i+1] != '.' && i+1 < seglen) *(bufp++) = '.'; - copylen = 0; - state = 2; /* Copy extension next */ - break; - } - *(bufp++) = c; - copylen++; - if (copylen >= FNAME_SIZE) { - copylen = 0; - state = 1; /* Go wait for dot */ - break; - } - break; - case 1: /* Looking for dot so we can copy exten */ - if (src[i] == '.' && src[i+1] != '.' && i+1 < seglen) { - *(bufp++) = '.'; - state = 2; - } - break; - case 2: /* Copying extension */ - if (c == '*') { - while (copylen < FEXT_SIZE) { - *(bufp++) = '?'; - if (bufp >= bufend) break; - copylen++; - } - i = seglen; /* Done with segment */ - break; - } - if (c == '.') { - i = seglen; /* Done with segment */ - break; - } - *(bufp++) = c; - copylen++; - if (copylen >= FEXT_SIZE) { - i = seglen; /* Done with segment */ - break; - } - break; - } - } + else + { + /* .. in root dir illegal */ + return DE_PATHNOTFND; + } + } + else + { + /* New segment. If any wildcards in previous + segment(s), this is an invalid path. */ + if (gotAnyWildcards || src[0] == '.') + return DE_PATHNOTFND; + /* Append current path segment to result. */ + *(bufp++) = '\\'; + if (bufp >= bufend) + break; + copylen = state = 0; + for (i = 0; ((i < seglen) && (bufp < bufend)); i++) + { + c = src[i]; + gotAnyWildcards |= ((c == '?') || (c == '*')); + switch (state) + { + case 0: /* Copying filename (excl. extension) */ + if (c == '*') + { + while (copylen < FNAME_SIZE) + { + *(bufp++) = '?'; + if (bufp >= bufend) + break; + copylen++; } - } - } /* if (seglen > 0) */ - src += seglen; - if (*src) src++; - } /* while ( (*src) && (bufp < bufend) ) */ - } + copylen = 0; + state = 1; /* Go wait for dot */ + break; + } + if (c == '.') + { + if (src[i + 1] != '.' && i + 1 < seglen) + *(bufp++) = '.'; + copylen = 0; + state = 2; /* Copy extension next */ + break; + } + *(bufp++) = c; + copylen++; + if (copylen >= FNAME_SIZE) + { + copylen = 0; + state = 1; /* Go wait for dot */ + break; + } + break; + case 1: /* Looking for dot so we can copy exten */ + if (src[i] == '.' && src[i + 1] != '.' && i + 1 < seglen) + { + *(bufp++) = '.'; + state = 2; + } + break; + case 2: /* Copying extension */ + if (c == '*') + { + while (copylen < FEXT_SIZE) + { + *(bufp++) = '?'; + if (bufp >= bufend) + break; + copylen++; + } + i = seglen; /* Done with segment */ + break; + } + if (c == '.') + { + i = seglen; /* Done with segment */ + break; + } + *(bufp++) = c; + copylen++; + if (copylen >= FEXT_SIZE) + { + i = seglen; /* Done with segment */ + break; + } + break; + } + } + } + } + } /* if (seglen > 0) */ + src += seglen; + if (*src) + src++; + } /* while ( (*src) && (bufp < bufend) ) */ + } /* /// End of new code. - Ron Cemer */ if (bufp == buf + 2) @@ -553,4 +591,3 @@ COUNT ASMCFUNC truename(char FAR * src, char FAR * dest, COUNT t) * Rev 1.1 22 Jan 1997 13:21:22 patv * pre-0.92 Svante Frey bug fixes. */ - diff --git a/kernel/nls.c b/kernel/nls.c index bc1cb96d..28de4545 100644 --- a/kernel/nls.c +++ b/kernel/nls.c @@ -39,7 +39,8 @@ #include #ifdef VERSION_STRINGS -static BYTE *RcsId = "$Id$"; +static BYTE *RcsId = + "$Id$"; #endif /* @@ -50,8 +51,10 @@ static BYTE *RcsId = "$Id$"; #ifdef NLS_DEBUG #define assertDSeqSS() if(_DS != _SS) assertDSneSS(); void assertDSneSS(void) -{ panic("DS unequal to SS"); +{ + panic("DS unequal to SS"); } + #define log(a) printf a #define log1(a) printf a #else @@ -64,25 +67,23 @@ void assertDSneSS(void) #endif #endif - struct nlsInfoBlock nlsInfo = { - (char FAR *)0 /* filename to COUNTRY.SYS */ - ,437 /* system code page */ - /* Implementation flags */ - ,0 + (char FAR *)0 /* filename to COUNTRY.SYS */ + , 437 /* system code page */ + /* Implementation flags */ + , 0 #ifdef NLS_MODIFYABLE_DATA - | NLS_CODE_MODIFYABLE_DATA + | NLS_CODE_MODIFYABLE_DATA #endif #ifdef NLS_REORDER_POINTERS - | NLS_CODE_REORDER_POINTERS + | NLS_CODE_REORDER_POINTERS #endif - ,&nlsPackageHardcoded /* hardcoded first package */ - ,&nlsPackageHardcoded /* first item in chain */ + , &nlsPackageHardcoded /* hardcoded first package */ + , &nlsPackageHardcoded /* first item in chain */ }; - - /* getTableX return the pointer to the X'th table; X==subfct */ - /* subfct 2: normal upcase table; 4: filename upcase table */ + /* getTableX return the pointer to the X'th table; X==subfct */ + /* subfct 2: normal upcase table; 4: filename upcase table */ #ifdef NLS_REORDER_POINTERS #define getTable2(nls) ((nls)->nlsPointers[0].pointer) #define getTable4(nls) ((nls)->nlsPointers[1].pointer) @@ -91,74 +92,74 @@ struct nlsInfoBlock nlsInfo = { #define getTable4(nls) getTable(4, (nls)) #define NEED_GET_TABLE #endif - /*== both chartables must be 128 bytes long and lower range is + /*== both chartables must be 128 bytes long and lower range is identical to 7bit-US-ASCII ==ska*/ #define getCharTbl2(nls) \ (((struct nlsCharTbl FAR*)getTable2(nls))->tbl - 0x80) #define getCharTbl4(nls) \ (((struct nlsCharTbl FAR*)getTable4(nls))->tbl - 0x80) - /******************************************************************** ***** MUX calling functions **************************************** ********************************************************************/ /*== DS:SI _always_ points to global NLS info structure <-> no * subfct can use these registers for anything different. ==ska*/ -STATIC COUNT muxGo(int subfct, iregs *rp) +STATIC COUNT muxGo(int subfct, iregs * rp) { -log( ("NLS: muxGo(): subfct=%x, cntry=%u, cp=%u, ES:DI=%04x:%04x\n", subfct - , rp->DX, rp->BX, rp->ES, rp->DI) ); - rp->SI = FP_OFF(&nlsInfo); - rp->DS = FP_SEG(&nlsInfo); - rp->AX = 0x1400 | subfct; - intr(0x2f, rp); -log( ("NLS: muxGo(): return value = %d\n", rp->AX) ); - return rp->AX; + log(("NLS: muxGo(): subfct=%x, cntry=%u, cp=%u, ES:DI=%04x:%04x\n", + subfct, rp->DX, rp->BX, rp->ES, rp->DI)); + rp->SI = FP_OFF(&nlsInfo); + rp->DS = FP_SEG(&nlsInfo); + rp->AX = 0x1400 | subfct; + intr(0x2f, rp); + log(("NLS: muxGo(): return value = %d\n", rp->AX)); + return rp->AX; } /* * Call NLSFUNC to load the NLS package */ COUNT muxLoadPkg(UWORD cp, UWORD cntry) -{ iregs r; - - assertDSeqSS(); /* because "&r" */ - - /* 0x1400 == not installed, ok to install */ - /* 0x1401 == not installed, not ok to install */ - /* 0x14FF == installed */ - - r.BX = 0; /* make sure the NLSFUNC ID is updated */ - if(muxGo(0, &r) != 0x14ff) - return DE_FILENOTFND; /* No NLSFUNC --> no load */ - if(r.BX != NLS_FREEDOS_NLSFUNC_ID) /* FreeDOS NLSFUNC will return */ - return DE_INVLDACC; /* This magic number */ - - /* OK, the correct NLSFUNC is available --> load pkg */ - /* If BX == -1 on entry, NLSFUNC updates BX to the codepage loaded - into memory. The system must then change to this one later */ - r.DX = cntry; - r.BX = cp; - return muxGo(NLSFUNC_LOAD_PKG, &r); +{ + iregs r; + + assertDSeqSS(); /* because "&r" */ + + /* 0x1400 == not installed, ok to install */ + /* 0x1401 == not installed, not ok to install */ + /* 0x14FF == installed */ + + r.BX = 0; /* make sure the NLSFUNC ID is updated */ + if (muxGo(0, &r) != 0x14ff) + return DE_FILENOTFND; /* No NLSFUNC --> no load */ + if (r.BX != NLS_FREEDOS_NLSFUNC_ID) /* FreeDOS NLSFUNC will return */ + return DE_INVLDACC; /* This magic number */ + + /* OK, the correct NLSFUNC is available --> load pkg */ + /* If BX == -1 on entry, NLSFUNC updates BX to the codepage loaded + into memory. The system must then change to this one later */ + r.DX = cntry; + r.BX = cp; + return muxGo(NLSFUNC_LOAD_PKG, &r); } -STATIC int muxBufGo(int subfct, int bp, UWORD cp, UWORD cntry, UWORD bufsize - , VOID FAR *buf) -{ iregs r; +STATIC int muxBufGo(int subfct, int bp, UWORD cp, UWORD cntry, + UWORD bufsize, VOID FAR * buf) +{ + iregs r; - assertDSeqSS(); /* because "&r" */ + assertDSeqSS(); /* because "&r" */ -log( ("NLS: muxBufGo(): subfct=%x, BP=%u, cp=%u, cntry=%u, len=%u, buf=%04x:%04x\n", - subfct, bp, cp, cntry, bufsize, FP_SEG(buf), FP_OFF(buf)) ); + log(("NLS: muxBufGo(): subfct=%x, BP=%u, cp=%u, cntry=%u, len=%u, buf=%04x:%04x\n", subfct, bp, cp, cntry, bufsize, FP_SEG(buf), FP_OFF(buf))); - r.DX = cntry; - r.BX = cp; - r.ES = FP_SEG(buf); - r.DI = FP_OFF(buf); - r.CX = bufsize; - r.BP = bp; - return muxGo(subfct, &r); + r.DX = cntry; + r.BX = cp; + r.ES = FP_SEG(buf); + r.DI = FP_OFF(buf); + r.CX = bufsize; + r.BP = bp; + return muxGo(subfct, &r); } #define mux65(s,cp,cc,bs,b) muxBufGo(2, (s), (cp), (cc), (bs), (b)) @@ -170,40 +171,41 @@ log( ("NLS: muxBufGo(): subfct=%x, BP=%u, cp=%u, cntry=%u, len=%u, buf=%04x:%04x ***** Helper functions********************************************** ********************************************************************/ - /* * Search for the NLS package within the chain * Also resolves the default values (-1) into the currently * active codepage/country code. */ STATIC struct nlsPackage FAR *searchPackage(UWORD cp, UWORD cntry) -{ struct nlsPackage FAR *nls; +{ + struct nlsPackage FAR *nls; - if(cp == NLS_DEFAULT) - cp = nlsInfo.actPkg->cp; - if(cntry == NLS_DEFAULT) - cntry = nlsInfo.actPkg->cntry; + if (cp == NLS_DEFAULT) + cp = nlsInfo.actPkg->cp; + if (cntry == NLS_DEFAULT) + cntry = nlsInfo.actPkg->cntry; - nls = nlsInfo.chain; - while((nls->cp != cp || nls->cntry != cntry) - && (nls = nls->nxt) != NULL); + nls = nlsInfo.chain; + while ((nls->cp != cp || nls->cntry != cntry) + && (nls = nls->nxt) != NULL) ; - return nls; + return nls; } /* For various robustnesses reasons and to simplify the implementation at other places, locateSubfct() returns NULL (== "not found"), if nls == NULL on entry. */ -STATIC VOID FAR *locateSubfct(struct nlsPackage FAR *nls, int subfct) -{ int cnt; - struct nlsPointer FAR *p; +STATIC VOID FAR *locateSubfct(struct nlsPackage FAR * nls, int subfct) +{ + int cnt; + struct nlsPointer FAR *p; - if(nls) for(cnt = nls->numSubfct, p = &nls->nlsPointers[0] - ; cnt--; ++p) - if(p->subfct == (UBYTE)subfct) - return p; + if (nls) + for (cnt = nls->numSubfct, p = &nls->nlsPointers[0]; cnt--; ++p) + if (p->subfct == (UBYTE) subfct) + return p; - return NULL; + return NULL; } #ifdef NEED_GET_TABLE @@ -213,19 +215,23 @@ STATIC VOID FAR *locateSubfct(struct nlsPackage FAR *nls, int subfct) function is guaranteed to return valid pointers, rather than to let the user (some kernel function) deal with non-existing tables -- 2000/02/26 ska*/ -STATIC VOID FAR *getTable(UBYTE subfct, struct nlsPackage FAR *nls) -{ struct nlsPointer FAR *poi; - - if((poi = locateSubfct(nls, subfct)) != NULL) - return poi; - - /* Failed --> return the hardcoded table */ - switch(subfct) { - case 2: return &nlsUpHardcodedTable; - case 4: return &nlsFnameUpHardcodedTable; - /* case 5: return &nlsFnameTermHardcodedTable; */ - /* case 6: return &nlsCollHardcodedTable; */ - } +STATIC VOID FAR *getTable(UBYTE subfct, struct nlsPackage FAR * nls) +{ + struct nlsPointer FAR *poi; + + if ((poi = locateSubfct(nls, subfct)) != NULL) + return poi; + + /* Failed --> return the hardcoded table */ + switch (subfct) + { + case 2: + return &nlsUpHardcodedTable; + case 4: + return &nlsFnameUpHardcodedTable; + /* case 5: return &nlsFnameTermHardcodedTable; */ + /* case 6: return &nlsCollHardcodedTable; */ + } } #endif @@ -239,36 +245,36 @@ STATIC VOID FAR *getTable(UBYTE subfct, struct nlsPackage FAR *nls) * the code to push bufsize, buf, call cpyBuf() and return its result. * The parameter were ordered to allow this code optimization. */ -STATIC COUNT cpyBuf(VOID FAR *dst, UWORD dstlen - , VOID FAR *src, UWORD srclen) +STATIC COUNT cpyBuf(VOID FAR * dst, UWORD dstlen, VOID FAR * src, + UWORD srclen) { - if(srclen <= dstlen) { - fmemcpy(dst, src, srclen); - return SUCCESS; - } - return DE_INVLDFUNC; /* buffer too small */ + if (srclen <= dstlen) + { + fmemcpy(dst, src, srclen); + return SUCCESS; + } + return DE_INVLDFUNC; /* buffer too small */ } - - /* * This function assumes that 'map' is adjusted such that * map[0x80] is the uppercase of character 0x80. *== 128 byte chartables, lower range conform to 7bit-US-ASCII ==ska*/ -STATIC VOID upMMem(UBYTE FAR *map, UBYTE FAR * str, unsigned len) +STATIC VOID upMMem(UBYTE FAR * map, UBYTE FAR * str, unsigned len) { REG unsigned c; #ifdef NLS_DEBUG - UBYTE FAR *oldStr; - unsigned oldLen; - - oldStr = str; - oldLen = len; -log( ("NLS: upMMem(): len=%u, %04x:%04x=\"", len, FP_SEG(str), FP_OFF(str)) ); - for(c = 0; c < len; ++c) - printf("%c", str[c] > 32? str[c]: '.'); - printf("\"\n"); + UBYTE FAR *oldStr; + unsigned oldLen; + + oldStr = str; + oldLen = len; + log(("NLS: upMMem(): len=%u, %04x:%04x=\"", len, FP_SEG(str), + FP_OFF(str))); + for (c = 0; c < len; ++c) + printf("%c", str[c] > 32 ? str[c] : '.'); + printf("\"\n"); #endif if (len) do @@ -281,14 +287,13 @@ log( ("NLS: upMMem(): len=%u, %04x:%04x=\"", len, FP_SEG(str), FP_OFF(str)) ); } while (--len); #ifdef NLS_DEBUG -printf("NLS: upMMem(): result=\""); - for(c = 0; c < oldLen; ++c) - printf("%c", oldStr[c] > 32? oldStr[c]: '.'); - printf("\"\n"); + printf("NLS: upMMem(): result=\""); + for (c = 0; c < oldLen; ++c) + printf("%c", oldStr[c] > 32 ? oldStr[c] : '.'); + printf("\"\n"); #endif } - /******************************************************************** ***** Lowlevel interface ******************************************* ********************************************************************/ @@ -297,52 +302,53 @@ printf("NLS: upMMem(): result=\""); the direct-access interface. subfct == NLS_DOS_38 is a value > 0xff in order to not clash with subfunctions valid to be passed as DOS-65-XX. */ -STATIC int nlsGetData(struct nlsPackage FAR *nls, int subfct, UBYTE FAR *buf - , unsigned bufsize) -{ VOID FAR *poi; - -log( ("NLS: nlsGetData(): subfct=%x, bufsize=%u, cp=%u, cntry=%u\n", - subfct, bufsize, nls->cp, nls->cntry) ); - - /* Theoretically tables 1 and, if NLS_REORDER_POINTERS is enabled, - 2 and 4 could be hard-coded, because their - data is located at predictable (calculatable) locations. - However, 1 and subfct NLS_DOS_38 are to handle the same - data and the "locateSubfct()" call has to be implemented anyway, - in order to handle all subfunctions. - Also, NLS is often NOT used in any case, so this code is more - size than speed optimized. */ - if((poi = locateSubfct(nls, subfct)) != NULL) { -log( ("NLS: nlsGetData(): subfunction found\n") ); - switch(subfct) { - case 1: /* Extended Country Information */ - return cpyBuf(buf, bufsize, poi - , ((struct nlsExtCntryInfo FAR*)poi)->size + 3); - case NLS_DOS_38: /* Normal Country Information */ - return cpyBuf(buf, bufsize - , &(((struct nlsExtCntryInfo FAR*)poi)->dateFmt) - , 24); /* standard cinfo has no more 34 _used_ bytes */ - /* don't copy 34, copy only 0x18 instead, - see comment at DosGetCountryInformation TE */ - default: - /* All other subfunctions just return the found nlsPoinerInf - structure */ - return cpyBuf(buf, bufsize, poi, sizeof(struct nlsPointer)); - } - } - - /* The requested subfunction could not been located within the - NLS pkg --> error. Because the data corresponds to the subfunction - number passed to the API, the failure is the same as that a wrong - API function has been called. */ -log( ("NLS: nlsGetData(): Subfunction not found\n") ); - return DE_INVLDFUNC; +STATIC int nlsGetData(struct nlsPackage FAR * nls, int subfct, + UBYTE FAR * buf, unsigned bufsize) +{ + VOID FAR *poi; + + log(("NLS: nlsGetData(): subfct=%x, bufsize=%u, cp=%u, cntry=%u\n", + subfct, bufsize, nls->cp, nls->cntry)); + + /* Theoretically tables 1 and, if NLS_REORDER_POINTERS is enabled, + 2 and 4 could be hard-coded, because their + data is located at predictable (calculatable) locations. + However, 1 and subfct NLS_DOS_38 are to handle the same + data and the "locateSubfct()" call has to be implemented anyway, + in order to handle all subfunctions. + Also, NLS is often NOT used in any case, so this code is more + size than speed optimized. */ + if ((poi = locateSubfct(nls, subfct)) != NULL) + { + log(("NLS: nlsGetData(): subfunction found\n")); + switch (subfct) + { + case 1: /* Extended Country Information */ + return cpyBuf(buf, bufsize, poi, + ((struct nlsExtCntryInfo FAR *)poi)->size + 3); + case NLS_DOS_38: /* Normal Country Information */ + return cpyBuf(buf, bufsize, &(((struct nlsExtCntryInfo FAR *)poi)->dateFmt), 24); /* standard cinfo has no more 34 _used_ bytes */ + /* don't copy 34, copy only 0x18 instead, + see comment at DosGetCountryInformation TE */ + default: + /* All other subfunctions just return the found nlsPoinerInf + structure */ + return cpyBuf(buf, bufsize, poi, sizeof(struct nlsPointer)); + } + } + + /* The requested subfunction could not been located within the + NLS pkg --> error. Because the data corresponds to the subfunction + number passed to the API, the failure is the same as that a wrong + API function has been called. */ + log(("NLS: nlsGetData(): Subfunction not found\n")); + return DE_INVLDFUNC; } VOID nlsCPchange(UWORD cp) { - UNREFERENCED_PARAMETER(cp); - printf("\7\nchange codepage not yet done ska\n"); + UNREFERENCED_PARAMETER(cp); + printf("\7\nchange codepage not yet done ska\n"); } /* @@ -366,74 +372,75 @@ VOID nlsCPchange(UWORD cp) * appropriate codepage on its own. */ -STATIC COUNT nlsSetPackage(struct nlsPackage FAR *nls) +STATIC COUNT nlsSetPackage(struct nlsPackage FAR * nls) { - if(nls->cp != nlsInfo.actPkg->cp) /* Codepage gets changed --> - inform all character drivers thereabout. - If this fails, it would be possible that the old - NLS pkg had been removed from memory by NLSFUNC. */ - nlsCPchange(nls->cp); + if (nls->cp != nlsInfo.actPkg->cp) /* Codepage gets changed --> + inform all character drivers thereabout. + If this fails, it would be possible that the old + NLS pkg had been removed from memory by NLSFUNC. */ + nlsCPchange(nls->cp); - nlsInfo.actPkg = nls; + nlsInfo.actPkg = nls; - return SUCCESS; + return SUCCESS; } STATIC COUNT DosSetPackage(UWORD cp, UWORD cntry) -{ struct nlsPackage FAR*nls; /* NLS package to use to return the info from */ +{ + struct nlsPackage FAR *nls; /* NLS package to use to return the info from */ - /* nls := NLS package of cntry/codepage */ - if((nls = searchPackage(cp, cntry)) != NULL) - /* OK the NLS pkg is loaded --> activate it */ - return nlsSetPackage(nls); + /* nls := NLS package of cntry/codepage */ + if ((nls = searchPackage(cp, cntry)) != NULL) + /* OK the NLS pkg is loaded --> activate it */ + return nlsSetPackage(nls); - /* not loaded --> invoke NLSFUNC to load it */ - return muxLoadPkg(cp, cntry); + /* not loaded --> invoke NLSFUNC to load it */ + return muxLoadPkg(cp, cntry); } -STATIC void nlsUpMem(struct nlsPackage FAR *nls, VOID FAR *str, int len) +STATIC void nlsUpMem(struct nlsPackage FAR * nls, VOID FAR * str, int len) { -log( ("NLS: nlsUpMem()\n") ); - upMMem(getCharTbl2(nls), (UBYTE FAR*)str, len); + log(("NLS: nlsUpMem()\n")); + upMMem(getCharTbl2(nls), (UBYTE FAR *) str, len); } -STATIC void nlsFUpMem(struct nlsPackage FAR *nls, VOID FAR *str, int len) +STATIC void nlsFUpMem(struct nlsPackage FAR * nls, VOID FAR * str, int len) { -log( ("NLS: nlsFUpMem()\n") ); - upMMem(getCharTbl4(nls), (UBYTE FAR*)str, len); + log(("NLS: nlsFUpMem()\n")); + upMMem(getCharTbl4(nls), (UBYTE FAR *) str, len); } -STATIC VOID xUpMem(struct nlsPackage FAR *nls, VOID FAR * str, unsigned len) +STATIC VOID xUpMem(struct nlsPackage FAR * nls, VOID FAR * str, + unsigned len) /* upcase a memory area */ { -log( ("NLS: xUpMem(): cp=%u, cntry=%u\n", nls->cp, nls->cntry) ); + log(("NLS: xUpMem(): cp=%u, cntry=%u\n", nls->cp, nls->cntry)); - if(nls->flags & NLS_FLAG_DIRECT_UPCASE) - nlsUpMem(nls, str, len); - else - muxBufGo(NLSFUNC_UPMEM, 0, nls->cp, nls->cntry, len, str); + if (nls->flags & NLS_FLAG_DIRECT_UPCASE) + nlsUpMem(nls, str, len); + else + muxBufGo(NLSFUNC_UPMEM, 0, nls->cp, nls->cntry, len, str); } -STATIC int nlsYesNo(struct nlsPackage FAR *nls, unsigned char ch) +STATIC int nlsYesNo(struct nlsPackage FAR * nls, unsigned char ch) { - assertDSeqSS(); /* because "&ch" */ - -log( ("NLS: nlsYesNo(): in ch=%u (%c)\n", ch, ch>32? ch: ' ') ); - - xUpMem(nls, &ch, 1); /* Upcase character */ - /* Cannot use DosUpChar(), because - maybe: nls != current NLS pkg - However: Upcase character within lowlevel - function to allow a yesNo() function - catched by external MUX-14 handler, which - does NOT upcase character. */ -log( ("NLS: nlsYesNo(): upcased ch=%u (%c)\n", ch, ch>32? ch: ' ') ); - if(ch == nls->yeschar) - return 1; - if(ch == nls->nochar) - return 0; - return 2; + assertDSeqSS(); /* because "&ch" */ + + log(("NLS: nlsYesNo(): in ch=%u (%c)\n", ch, ch > 32 ? ch : ' ')); + + xUpMem(nls, &ch, 1); /* Upcase character */ + /* Cannot use DosUpChar(), because + maybe: nls != current NLS pkg + However: Upcase character within lowlevel + function to allow a yesNo() function + catched by external MUX-14 handler, which + does NOT upcase character. */ + log(("NLS: nlsYesNo(): upcased ch=%u (%c)\n", ch, ch > 32 ? ch : ' ')); + if (ch == nls->yeschar) + return 1; + if (ch == nls->nochar) + return 0; + return 2; } - /******************************************************************** ***** DOS API ****************************************************** ********************************************************************/ @@ -441,16 +448,16 @@ log( ("NLS: nlsYesNo(): upcased ch=%u (%c)\n", ch, ch>32? ch: ' ') ); BYTE DosYesNo(unsigned char ch) /* returns: 0: ch == "No", 1: ch == "Yes", 2: ch crap */ { - if(nlsInfo.actPkg->flags & NLS_FLAG_DIRECT_YESNO) - return nlsYesNo(nlsInfo.actPkg, ch); - else - return muxYesNo(ch); + if (nlsInfo.actPkg->flags & NLS_FLAG_DIRECT_YESNO) + return nlsYesNo(nlsInfo.actPkg, ch); + else + return muxYesNo(ch); } - #ifndef DosUpMem VOID DosUpMem(VOID FAR * str, unsigned len) -{ xUpMem(nlsInfo.actPkg, str, len); +{ + xUpMem(nlsInfo.actPkg, str, len); } #endif @@ -463,47 +470,48 @@ VOID DosUpMem(VOID FAR * str, unsigned len) unsigned char ASMCFUNC DosUpChar(unsigned char ch) /* upcase a single character */ { - assertDSeqSS(); /* because "&ch" */ -log( ("NLS: DosUpChar(): in ch=%u (%c)\n", ch, ch>32? ch: ' ') ); - DosUpMem((UBYTE FAR*)&ch, 1); -log( ("NLS: DosUpChar(): upcased ch=%u (%c)\n", ch, ch>32? ch: ' ') ); - return ch; + assertDSeqSS(); /* because "&ch" */ + log(("NLS: DosUpChar(): in ch=%u (%c)\n", ch, ch > 32 ? ch : ' ')); + DosUpMem((UBYTE FAR *) & ch, 1); + log(("NLS: DosUpChar(): upcased ch=%u (%c)\n", ch, ch > 32 ? ch : ' ')); + return ch; } -VOID DosUpString(char FAR *str) +VOID DosUpString(char FAR * str) /* upcase a string */ { - DosUpMem(str, fstrlen(str)); + DosUpMem(str, fstrlen(str)); } -VOID DosUpFMem(VOID FAR *str, unsigned len) +VOID DosUpFMem(VOID FAR * str, unsigned len) /* upcase a memory area for file names */ { #ifdef NLS_DEBUG - unsigned c; -log( ("NLS: DosUpFMem(): len=%u, %04x:%04x=\"", len, FP_SEG(str), FP_OFF(str)) ); - for(c = 0; c < len; ++c) - printf("%c", str[c] > 32? str[c]: '.'); - printf("\"\n"); + unsigned c; + log(("NLS: DosUpFMem(): len=%u, %04x:%04x=\"", len, FP_SEG(str), + FP_OFF(str))); + for (c = 0; c < len; ++c) + printf("%c", str[c] > 32 ? str[c] : '.'); + printf("\"\n"); #endif - if(nlsInfo.actPkg->flags & NLS_FLAG_DIRECT_FUPCASE) - nlsFUpMem(nlsInfo.actPkg, str, len); - else - muxUpMem(NLSFUNC_FILE_UPMEM, str, len); + if (nlsInfo.actPkg->flags & NLS_FLAG_DIRECT_FUPCASE) + nlsFUpMem(nlsInfo.actPkg, str, len); + else + muxUpMem(NLSFUNC_FILE_UPMEM, str, len); } unsigned char DosUpFChar(unsigned char ch) /* upcase a single character for file names */ { - assertDSeqSS(); /* because "&ch" */ - DosUpFMem((UBYTE FAR*)&ch, 1); - return ch; + assertDSeqSS(); /* because "&ch" */ + DosUpFMem((UBYTE FAR *) & ch, 1); + return ch; } -VOID DosUpFString(char FAR *str) +VOID DosUpFString(char FAR * str) /* upcase a string for file names */ { - DosUpFMem(str, fstrlen(str)); + DosUpFMem(str, fstrlen(str)); } /* @@ -514,34 +522,35 @@ VOID DosUpFString(char FAR *str) * loaded, MUX-14 is invoked; otherwise the pkg's NLS_Fct_buf * function is invoked. */ -COUNT DosGetData(int subfct, UWORD cp, UWORD cntry - , UWORD bufsize, VOID FAR * buf) -{ struct nlsPackage FAR*nls; /* NLS package to use to return the info from */ - -log( ("NLS: GetData(): subfct=%x, cp=%u, cntry=%u, bufsize=%u\n", - subfct, cp, cntry, bufsize) ); - - if(!buf || !bufsize) - return DE_INVLDDATA; - if(subfct == 0) /* Currently not supported */ - return DE_INVLDFUNC; - - /* nls := NLS package of cntry/codepage */ - if((nls = searchPackage(cp, cntry)) == NULL - || (nls->flags & NLS_FLAG_DIRECT_GETDATA) == 0) { - /* If the NLS pkg is not loaded into memory or the - direct-access flag is disabled, the request must - be passed through MUX */ - return (subfct == NLS_DOS_38) - ? mux38(nls->cp, nls->cntry, bufsize, buf) - : mux65(subfct, nls->cp, nls->cntry, bufsize, buf); - } - - /* Direct access to the data */ - return nlsGetData(nls, subfct, buf, bufsize); +COUNT DosGetData(int subfct, UWORD cp, UWORD cntry, UWORD bufsize, + VOID FAR * buf) +{ + struct nlsPackage FAR *nls; /* NLS package to use to return the info from */ + + log(("NLS: GetData(): subfct=%x, cp=%u, cntry=%u, bufsize=%u\n", + subfct, cp, cntry, bufsize)); + + if (!buf || !bufsize) + return DE_INVLDDATA; + if (subfct == 0) /* Currently not supported */ + return DE_INVLDFUNC; + + /* nls := NLS package of cntry/codepage */ + if ((nls = searchPackage(cp, cntry)) == NULL + || (nls->flags & NLS_FLAG_DIRECT_GETDATA) == 0) + { + /* If the NLS pkg is not loaded into memory or the + direct-access flag is disabled, the request must + be passed through MUX */ + return (subfct == NLS_DOS_38) + ? mux38(nls->cp, nls->cntry, bufsize, buf) + : mux65(subfct, nls->cp, nls->cntry, bufsize, buf); + } + + /* Direct access to the data */ + return nlsGetData(nls, subfct, buf, bufsize); } - /* * Called for DOS-38 get info * @@ -556,10 +565,11 @@ log( ("NLS: GetData(): subfct=%x, cp=%u, cntry=%u, bufsize=%u\n", * RBIL documents 0x18 bytes and calls 10 bytes 'reserved' * so we change the amount of copied bytes to 0x18 */ - + #ifndef DosGetCountryInformation -COUNT DosGetCountryInformation(UWORD cntry, VOID FAR *buf) -{ return DosGetData(NLS_DOS_38, NLS_DEFAULT, cntry, 0x18, buf); +COUNT DosGetCountryInformation(UWORD cntry, VOID FAR * buf) +{ + return DosGetData(NLS_DOS_38, NLS_DEFAULT, cntry, 0x18, buf); } #endif @@ -568,17 +578,19 @@ COUNT DosGetCountryInformation(UWORD cntry, VOID FAR *buf) */ #ifndef DosSetCountry COUNT DosSetCountry(UWORD cntry) -{ return DosSetPackage(NLS_DEFAULT, cntry); +{ + return DosSetPackage(NLS_DEFAULT, cntry); } #endif /* * Called for DOS-66-01 get CP */ -COUNT DosGetCodepage(UWORD FAR* actCP, UWORD FAR* sysCP) -{ *sysCP = nlsInfo.sysCodePage; - *actCP = nlsInfo.actPkg->cp; - return SUCCESS; +COUNT DosGetCodepage(UWORD FAR * actCP, UWORD FAR * sysCP) +{ + *sysCP = nlsInfo.sysCodePage; + *actCP = nlsInfo.actPkg->cp; + return SUCCESS; } /* @@ -587,9 +599,10 @@ COUNT DosGetCodepage(UWORD FAR* actCP, UWORD FAR* sysCP) * to specify it, is lost to me. (2000/02/13 ska) */ COUNT DosSetCodepage(UWORD actCP, UWORD sysCP) -{ if(sysCP == NLS_DEFAULT || sysCP == nlsInfo.sysCodePage) - return DosSetPackage(actCP, NLS_DEFAULT); - return DE_INVLDDATA; +{ + if (sysCP == NLS_DEFAULT || sysCP == nlsInfo.sysCodePage) + return DosSetPackage(actCP, NLS_DEFAULT); + return DE_INVLDDATA; } /******************************************************************** @@ -608,57 +621,59 @@ COUNT DosSetCodepage(UWORD actCP, UWORD sysCP) if AL == 0, Carry must be cleared, otherwise set */ UWORD ASMCFUNC syscall_MUX14(DIRECT_IREGS) -{ struct nlsPackage FAR*nls; /* addressed NLS package */ - - UNREFERENCED_PARAMETER (flags); - UNREFERENCED_PARAMETER (cs); - UNREFERENCED_PARAMETER (ip); - UNREFERENCED_PARAMETER (ds); - UNREFERENCED_PARAMETER (es); - UNREFERENCED_PARAMETER (si); - -log( ("NLS: MUX14(): subfct=%x, cp=%u, cntry=%u\n", - AL, BX, DX) ); - - if((nls = searchPackage(BX, DX)) == NULL) - return DE_INVLDFUNC; /* no such package */ - -log( ("NLS: MUX14(): NLS pkg found\n") ); - - switch(AL) { - case NLSFUNC_INSTALL_CHECK: - BX = NLS_FREEDOS_NLSFUNC_ID; - return SUCCESS; /* kernel just simulates default functions */ - case NLSFUNC_DOS38: - return nlsGetData(nls, NLS_DOS_38, MK_FP(ES, DI), 34); - case NLSFUNC_GETDATA: - return nlsGetData(nls, BP, MK_FP(ES, DI), CX); - case NLSFUNC_DRDOS_GETDATA: - /* Does not pass buffer length */ - return nlsGetData(nls, CL, MK_FP(ES, DI), 512); - case NLSFUNC_LOAD_PKG: - case NLSFUNC_LOAD_PKG2: - return nlsSetPackage(nls); - case NLSFUNC_YESNO: - return nlsYesNo(nls, CL); - case NLSFUNC_UPMEM: - nlsUpMem(nls, MK_FP(ES, DI), CX); - return SUCCESS; - case NLSFUNC_FILE_UPMEM: +{ + struct nlsPackage FAR *nls; /* addressed NLS package */ + + UNREFERENCED_PARAMETER(flags); + UNREFERENCED_PARAMETER(cs); + UNREFERENCED_PARAMETER(ip); + UNREFERENCED_PARAMETER(ds); + UNREFERENCED_PARAMETER(es); + UNREFERENCED_PARAMETER(si); + + log(("NLS: MUX14(): subfct=%x, cp=%u, cntry=%u\n", AL, BX, DX)); + + if ((nls = searchPackage(BX, DX)) == NULL) + return DE_INVLDFUNC; /* no such package */ + + log(("NLS: MUX14(): NLS pkg found\n")); + + switch (AL) + { + case NLSFUNC_INSTALL_CHECK: + BX = NLS_FREEDOS_NLSFUNC_ID; + return SUCCESS; /* kernel just simulates default functions */ + case NLSFUNC_DOS38: + return nlsGetData(nls, NLS_DOS_38, MK_FP(ES, DI), 34); + case NLSFUNC_GETDATA: + return nlsGetData(nls, BP, MK_FP(ES, DI), CX); + case NLSFUNC_DRDOS_GETDATA: + /* Does not pass buffer length */ + return nlsGetData(nls, CL, MK_FP(ES, DI), 512); + case NLSFUNC_LOAD_PKG: + case NLSFUNC_LOAD_PKG2: + return nlsSetPackage(nls); + case NLSFUNC_YESNO: + return nlsYesNo(nls, CL); + case NLSFUNC_UPMEM: + nlsUpMem(nls, MK_FP(ES, DI), CX); + return SUCCESS; + case NLSFUNC_FILE_UPMEM: #ifdef NLS_DEBUG -{ unsigned j; - BYTE FAR *p; -log( ("NLS: MUX14(FILE_UPMEM): len=%u, %04x:%04x=\"", CX, ES, DI) ); - for(j = 0, p = MK_FP(ES, DI); j < CX; ++j) - printf("%c", p[j] > 32? p[j]: '.'); - printf("\"\n"); -} + { + unsigned j; + BYTE FAR *p; + log(("NLS: MUX14(FILE_UPMEM): len=%u, %04x:%04x=\"", CX, ES, DI)); + for (j = 0, p = MK_FP(ES, DI); j < CX; ++j) + printf("%c", p[j] > 32 ? p[j] : '.'); + printf("\"\n"); + } #endif - nlsFUpMem(nls, MK_FP(ES, DI), CX); - return SUCCESS; - } -log( ("NLS: MUX14(): Invalid function %x\n", AL) ); - return DE_INVLDFUNC; /* no such function */ + nlsFUpMem(nls, MK_FP(ES, DI), CX); + return SUCCESS; + } + log(("NLS: MUX14(): Invalid function %x\n", AL)); + return DE_INVLDFUNC; /* no such function */ } /* @@ -668,4 +683,3 @@ log( ("NLS: MUX14(): Invalid function %x\n", AL) ); * Initial revision * */ - diff --git a/kernel/nls_load.c b/kernel/nls_load.c index 43b7a524..96994fee 100644 --- a/kernel/nls_load.c +++ b/kernel/nls_load.c @@ -28,14 +28,14 @@ /* Cambridge, MA 02139, USA. */ /****************************************************************/ - #include "portab.h" #include "globals.h" //#include "pcb.h" #include #ifdef VERSION_STRINGS -static BYTE *RcsId = "$Id$"; +static BYTE *RcsId = + "$Id$"; #endif #define filename Config.cfgCSYS_fnam @@ -44,79 +44,87 @@ static BYTE *RcsId = "$Id$"; static int err(void) { - printf("Syntax error in or invalid COUNTRY.SYS: \"%s\"\n" - , filename); - return 0; + printf("Syntax error in or invalid COUNTRY.SYS: \"%s\"\n", filename); + return 0; } #define readStruct(s) readStructure(&(s), sizeof(s), fd) static int readStructure(void *buf, int size, COUNT fd) -{ if(DosRead(fd, buf, size) == size) - return 1; +{ + if (DosRead(fd, buf, size) == size) + return 1; - return err(); + return err(); } - /* Evaluate each argument only once */ + + /* Evaluate each argument only once */ #define readFct(p,f) readFct_((p), (f), fd) int readFct_(void *buf, struct csys_function *fct, COUNT fd) -{ if(DosLseek(fd, fct->csys_rpos, 0) >= 0) - return readStructure(buf, fct->csys_length, fd); - return err(); +{ + if (DosLseek(fd, fct->csys_rpos, 0) >= 0) + return readStructure(buf, fct->csys_length, fd); + return err(); } #define seek(n) rseek((LONG)(n), fd) static rseek(LONG rpos, COUNT fd) -{ if(DosLseek(fd, rpos, 1) >= 0) - return 1; +{ + if (DosLseek(fd, rpos, 1) >= 0) + return 1; - return err(); + return err(); } - COUNT csysOpen(void) -{ COUNT fd; - struct nlsCSys_fileHeader header; - - if((fd = DosOpen((BYTE FAR*)filename, 0)) < 0) { - printf("Cannot open: \"%s\"\n", filename); - return 1; - } - - if(DosRead(fd, &header, sizeof(header)) != sizeof(header); - || strcmp(header.csys_idstring, CSYS_FD_IDSTRING) != 0 - || DosLseek(fd, (LONG)sizeof(csys_completeFileHeader), 0) - != (LONG)sizeof(csys_completeFileHeader)) { - printf("No valid COUNTRY.SYS: \"%s\"\n\nTry NLSFUNC /i %s\n" - , filename, filename); - DosClose(fd); - return -1; - } - - return fd; +{ + COUNT fd; + struct nlsCSys_fileHeader header; + + if ((fd = DosOpen((BYTE FAR *) filename, 0)) < 0) + { + printf("Cannot open: \"%s\"\n", filename); + return 1; + } + + if (DosRead(fd, &header, sizeof(header)) != sizeof(header); + ||strcmp(header.csys_idstring, CSYS_FD_IDSTRING) != 0 + || DosLseek(fd, (LONG) sizeof(csys_completeFileHeader), 0) + != (LONG) sizeof(csys_completeFileHeader)) + { + printf("No valid COUNTRY.SYS: \"%s\"\n\nTry NLSFUNC /i %s\n", filename, + filename); + DosClose(fd); + return -1; + } + + return fd; } /* Searches for function definition of table #fctID and moves it at index idx */ -static int chkTable(int idx, int fctID, struct csys_function *fcts - , int numFct) -{ struct csys_function *fct, hfct; - int i; - - for(i = 0, fct = fcts; i < numFct; ++i, ++fct) - if(fct->csys_fctID == fctID) { - /* function found */ - if(i == idx) /* already best place */ - return 1; - /* Swap both places */ - memcpy(&hfct, fct, sizeof(hfct)); - memcpy(fct, &fcts[idx], sizeof(hfct)); - memcpy(&fcts[idx], &hfct, sizeof(hfct)); - return 1; - } - - printf("Mandatory table %u not found.\n", fctID); - return 0; +static int chkTable(int idx, int fctID, struct csys_function *fcts, + int numFct) +{ + struct csys_function *fct, hfct; + int i; + + for (i = 0, fct = fcts; i < numFct; ++i, ++fct) + if (fct->csys_fctID == fctID) + { + /* function found */ + if (i == idx) /* already best place */ + return 1; + /* Swap both places */ + memcpy(&hfct, fct, sizeof(hfct)); + memcpy(fct, &fcts[idx], sizeof(hfct)); + memcpy(&fcts[idx], &hfct, sizeof(hfct)); + return 1; + } + + printf("Mandatory table %u not found.\n", fctID); + return 0; } + /* * Description of the algorithm the COUNTRY= information is loaded. @@ -172,7 +180,6 @@ a) The area containing the S3 structures, and b) probably the last loaded data could be found within the memory already, so the nlsPackage structure is larger than necessary. - 8) But the memory allocation in pass 1 is temporary anyway, because in the PostConfig() phase, all memory allocations are revoked and created anew. At this point -- immediately after revoking all memory and @@ -197,187 +204,208 @@ indicates that the FP_OFF(...) is the offset base-relative to the data offset; which is base-relative to the "nls" pointer. */ int csysLoadPackage(COUNT fd) -{ struct csys_numEntries entries; - struct csys_ccDefinition entry; - struct csys_function *fcts; - struct nlsPackage *nls; - struct nlsPointer *poi; - int highmark, numFct, i, j; - int totalSize; +{ + struct csys_numEntries entries; + struct csys_ccDefinition entry; + struct csys_function *fcts; + struct nlsPackage *nls; + struct nlsPointer *poi; + int highmark, numFct, i, j; + int totalSize; #ifndef NLS_MODIFYABLE_DATA - BYTE FAR * p; + BYTE FAR *p; #endif #define numE entries.csys_entries #define bufp(offset) (((BYTE*)nls) + (offset)) #define fct fcts[numFct] - /* When this function is called, the position of the file is - at offset 128 (number of country/codepage pairs) */ - if(!readStruct(entries)) - return 0; - while(numE--) { - if(!readStruct(entry)) - return 0; - if(entry.csys_cntry == cntry - && (cp == NLS_DEFAULT || entry.csys_cp == cp)) { - /* Requested entry found! */ - if(!seek(entry.csys_rpos) - || !readStruct(entries)) - return 0; - /* Now reading the function definitions at this position */ - if(numE < 5) { - printf("Syntax error in COUNTRY.SYS: Too few subfunctions\n"); - return 0; - } - /* If the file structure is good, each but one entry (0x23) is - one item within nlsPointers[] array */ - fcts = KernelAlloc(sizeof(struct csys_function) * numE); - numFct = 0; /* number of already loaded fct definition */ - totalSize = 0; - { - if(!readStruct(fct)) - return 0; - switch(fct.csys_fctID) { - case 0: case 0x20: case 0x21: case 0x22: - case 0xA0: case 0xA1: case 0xA2: - printf("Invalid subfunction %u ignored", fct.csys_fctID); - continue; - case 0x23: - if(fct.csys_length != 2) { - printf("Pseudo-table 35 length mismatch\n"); - continue; - } - } - /* Search if the subfunction is already there */ - for(j = 0; j < numFcts && fcts[j].csys_fctID != fct.csys_fctID - ; ++j); - if(j != numFct) { - printf("Subfunction %u defined multiple times, ignored\n" - , fct.csys_fctID); - continue; - } - - /* OK --> update the rpos member */ - fct.csys_rpos += DosLtell(fd); - totalSize += fct.csys_length; - ++numFct; - } while(--numE); - - /* i is the number of available function definition */ - /* check if all mandatory tables are loaded, at the same - time re-order the function definitions like that: - 0x23, 1, 2, 4, 5 - */ - - /* That's automatically a check that more than 3 definitions - are available */ - if(!chkTable(0, 0x23, fcts, numFct) /* pseudo-table 0x23 yes/no */ - || !chkTable(1, 1, fcts, numFct) /* ext cntry info */ - || !chkTable(2, 2, fcts, numFct) /* normal upcase */ - || !chkTable(3, 4, fcts, numFct) /* filename upcase */ - || !chkTable(4, 5, fcts, numFct)) /* filename terminator chars */ - return 0; - - /* Begin the loading process by to allocate memory as if - we had to load every byte */ - /* One nlsPointers structure is already part of nlsPackage; - two function definitions need no nlsPointers entry (0x32, 1); - one additional byte is required by table 1, but which is - already within totalSize as the length of pseudo-table - 0x23 has been counted. */ - nls = KernelAlloc((data = sizeof(nlsPackage) - + (numFct - 3) * sizeof(struct nlsPointer)) + totalSize); - /* data := first byte not used by the control area of - the nlsPackage structure; at this point it is the - offset where table #1 is to be loaded to*/ - - /* Install pseudo-table 0x23 */ - if(!readFct((BYTE*)&nls->yeschar, fcts)) - return 0; - nls->numSubfct = numFct - 1; /* pseudo-table 0x23 */ - - /* Install table #1 has it must overlay the last nlsPointers[] - item */ - *bufp(data) = 1; /* table #1 starts with the subfctID - then the data from the file follows */ - if(!readFct(bufp(++data), ++fcts)) - return 0; - data += fcts->csys_length; /* first byte of local data area */ - highmark = data; /* first unused byte */ - - for(j = 0, poi = nls->nlsPointers; j < numFct - 1; ++j, ++poi) { - /* consecutively load all functions */ - if(!readFct(bufp(data), ++fcts)) - return 0; - poi->subfct = fcts->csys_fctID; - /* Now the function data is located at the current top of - used memory and, if allowed, the other memory is - tested, if such image is already loaded */ + /* When this function is called, the position of the file is + at offset 128 (number of country/codepage pairs) */ + if (!readStruct(entries)) + return 0; + while (numE--) + { + if (!readStruct(entry)) + return 0; + if (entry.csys_cntry == cntry + && (cp == NLS_DEFAULT || entry.csys_cp == cp)) + { + /* Requested entry found! */ + if (!seek(entry.csys_rpos) || !readStruct(entries)) + return 0; + /* Now reading the function definitions at this position */ + if (numE < 5) + { + printf("Syntax error in COUNTRY.SYS: Too few subfunctions\n"); + return 0; + } + /* If the file structure is good, each but one entry (0x23) is + one item within nlsPointers[] array */ + fcts = KernelAlloc(sizeof(struct csys_function) * numE); + numFct = 0; /* number of already loaded fct definition */ + totalSize = 0; + { + if (!readStruct(fct)) + return 0; + switch (fct.csys_fctID) + { + case 0: + case 0x20: + case 0x21: + case 0x22: + case 0xA0: + case 0xA1: + case 0xA2: + printf("Invalid subfunction %u ignored", fct.csys_fctID); + continue; + case 0x23: + if (fct.csys_length != 2) + { + printf("Pseudo-table 35 length mismatch\n"); + continue; + } + } + /* Search if the subfunction is already there */ + for (j = 0; j < numFcts && fcts[j].csys_fctID != fct.csys_fctID; + ++j) ; + if (j != numFct) + { + printf("Subfunction %u defined multiple times, ignored\n", + fct.csys_fctID); + continue; + } + + /* OK --> update the rpos member */ + fct.csys_rpos += DosLtell(fd); + totalSize += fct.csys_length; + ++numFct; + } + while (--numE) ; + + /* i is the number of available function definition */ + /* check if all mandatory tables are loaded, at the same + time re-order the function definitions like that: + 0x23, 1, 2, 4, 5 + */ + + /* That's automatically a check that more than 3 definitions + are available */ + if (!chkTable(0, 0x23, fcts, numFct) /* pseudo-table 0x23 yes/no */ + || !chkTable(1, 1, fcts, numFct) /* ext cntry info */ + || !chkTable(2, 2, fcts, numFct) /* normal upcase */ + || !chkTable(3, 4, fcts, numFct) /* filename upcase */ + || !chkTable(4, 5, fcts, numFct)) /* filename terminator chars */ + return 0; + + /* Begin the loading process by to allocate memory as if + we had to load every byte */ + /* One nlsPointers structure is already part of nlsPackage; + two function definitions need no nlsPointers entry (0x32, 1); + one additional byte is required by table 1, but which is + already within totalSize as the length of pseudo-table + 0x23 has been counted. */ + nls = KernelAlloc((data = sizeof(nlsPackage) + + (numFct - 3) * sizeof(struct nlsPointer)) + + totalSize); + /* data := first byte not used by the control area of + the nlsPackage structure; at this point it is the + offset where table #1 is to be loaded to */ + + /* Install pseudo-table 0x23 */ + if (!readFct((BYTE *) & nls->yeschar, fcts)) + return 0; + nls->numSubfct = numFct - 1; /* pseudo-table 0x23 */ + + /* Install table #1 has it must overlay the last nlsPointers[] + item */ + *bufp(data) = 1; /* table #1 starts with the subfctID + then the data from the file follows */ + if (!readFct(bufp(++data), ++fcts)) + return 0; + data += fcts->csys_length; /* first byte of local data area */ + highmark = data; /* first unused byte */ + + for (j = 0, poi = nls->nlsPointers; j < numFct - 1; ++j, ++poi) + { + /* consecutively load all functions */ + if (!readFct(bufp(data), ++fcts)) + return 0; + poi->subfct = fcts->csys_fctID; + /* Now the function data is located at the current top of + used memory and, if allowed, the other memory is + tested, if such image is already loaded */ #ifndef NLS_MODIFYABLE_DATA - /* Try to locate the contents of the buffer */ - /** brute force **/ - /* For the standard tables one need to match tables - 2 and 4 only. */ - for(i = data; i + fcts->csys_length < highmark; ++i) { - if(memcmp(bufp(i), bufp(highmark), fcts->csys_length) - == 0) { - /* found! */ - /* ==> leave highmark untouch, but modify pointer */ - poi->pointer = MK_FP(0, i); - /* the segment portion == 0 identifies this pointer - as local within the current data area */ - goto nxtEntry; - } - } - /* Now try the hardcoded area */ - for(p = hcTablesStart; p < hcTablesEnd - fcts->csys_length - ; ++p) { - if(fmemcmp(p, bufp(highmark), fcts->csys_length) == 0) { - /* found! */ - /* ==> leave highmark untouch, but modify pointer */ - poi->pointer = p; - /* the segment portion != 0 identifies this is an - absolute pointer */ - goto nxtEntry; - } - } + /* Try to locate the contents of the buffer */ + /** brute force **/ + /* For the standard tables one need to match tables + 2 and 4 only. */ + for (i = data; i + fcts->csys_length < highmark; ++i) + { + if (memcmp(bufp(i), bufp(highmark), fcts->csys_length) == 0) + { + /* found! */ + /* ==> leave highmark untouch, but modify pointer */ + poi->pointer = MK_FP(0, i); + /* the segment portion == 0 identifies this pointer + as local within the current data area */ + goto nxtEntry; + } + } + /* Now try the hardcoded area */ + for (p = hcTablesStart; p < hcTablesEnd - fcts->csys_length; ++p) + { + if (fmemcmp(p, bufp(highmark), fcts->csys_length) == 0) + { + /* found! */ + /* ==> leave highmark untouch, but modify pointer */ + poi->pointer = p; + /* the segment portion != 0 identifies this is an + absolute pointer */ + goto nxtEntry; + } + } #endif - /* Either not found or modifyable data allowed */ - poi->pointer = MK_FP(0, highmark); /* local address */ - highmark += fcts->csys_length; /* need to keep the data */ - nxtEntry: - } - /* how many memory is really required */ - Country.cfgCSYS_memory = highmark; - Country.cfgCSYS_data = nls; - return 1; - } - } + /* Either not found or modifyable data allowed */ + poi->pointer = MK_FP(0, highmark); /* local address */ + highmark += fcts->csys_length; /* need to keep the data */ + nxtEntry: + } + /* how many memory is really required */ + Country.cfgCSYS_memory = highmark; + Country.cfgCSYS_data = nls; + return 1; + } + } #undef numE - if(cp == NLS_DEFAULT) - printf("No definition of country ID %u in file \"%s\"\n", - cntry, filename); - else - printf("No definition of country ID %u for codepage %u in file \"%s\"\n", - cntry, cp, filename); - - return 0; + if (cp == NLS_DEFAULT) + printf("No definition of country ID %u in file \"%s\"\n", + cntry, filename); + else + printf + ("No definition of country ID %u for codepage %u in file \"%s\"\n", + cntry, cp, filename); + + return 0; } INIT BOOL LoadCountryInfo(char *fnam) -{ COUNT fd; - int rc; - - if(strlen(fnam) < sizeof(filename)) { - strcpy(filename, fnam); - if((fd = csysOpen()) >= 0) { - rc = csysLoadPackage(fd); - DosClose(fd); - return rc; - } - } else - printf("Filename too long\n"); - return 0; +{ + COUNT fd; + int rc; + + if (strlen(fnam) < sizeof(filename)) + { + strcpy(filename, fnam); + if ((fd = csysOpen()) >= 0) + { + rc = csysLoadPackage(fd); + DosClose(fd); + return rc; + } + } + else + printf("Filename too long\n"); + return 0; } /* @@ -387,4 +415,3 @@ INIT BOOL LoadCountryInfo(char *fnam) * Add new files and update cvs with patches and changes * */ - diff --git a/kernel/prf.c b/kernel/prf.c index 499f1ef8..8e112e0d 100644 --- a/kernel/prf.c +++ b/kernel/prf.c @@ -41,11 +41,11 @@ #define hexd init_hexd #endif -COUNT ASMCFUNC fstrlen (BYTE FAR * s); /* don't want globals.h, sorry */ - +COUNT ASMCFUNC fstrlen(BYTE FAR * s); /* don't want globals.h, sorry */ #ifdef VERSION_STRINGS -static BYTE *prfRcsId = "$Id$"; +static BYTE *prfRcsId = + "$Id$"; #endif static BYTE *charp = 0; @@ -70,45 +70,44 @@ VOID cso(); #endif #ifdef FORSYS -COUNT fstrlen (BYTE FAR * s) /* don't want globals.h, sorry */ +COUNT fstrlen(BYTE FAR * s) /* don't want globals.h, sorry */ { - int i = 0; + int i = 0; - while (*s++) - i++; + while (*s++) + i++; - return i; + return i; } #endif /* special console output routine */ -VOID -put_console(COUNT c) +VOID put_console(COUNT c) { if (c == '\n') put_console('\r'); #ifdef FORSYS - write(1,&c,1); /* write character to stdout */ -#else -#if defined(__TURBOC__) + write(1, &c, 1); /* write character to stdout */ +#else +#if defined(__TURBOC__) _AX = 0x0e00 | c; _BX = 0x0070; __int__(0x10); #else - __asm { - mov al, byte ptr c; - mov ah, 0x0e; - mov bx, 0x0070; - int 0x10; - } -#endif /* __TURBO__*/ -#endif + __asm + { + mov al, byte ptr c; + mov ah, 0x0e; + mov bx, 0x0070; + int 0x10; + } +#endif /* __TURBO__ */ +#endif } /* special handler to switch between sprintf and printf */ -static VOID - handle_char(COUNT c) +static VOID handle_char(COUNT c) { if (charp == 0) put_console(c); @@ -117,34 +116,33 @@ static VOID } /* ltob -- convert an long integer to a string in any base (2-16) */ -BYTE * - ltob(LONG n, BYTE * s, COUNT base) +BYTE *ltob(LONG n, BYTE * s, COUNT base) { ULONG u; BYTE *p, *q; - int c; + int c; - u = n; + u = n; if (base == -10) /* signals signed conversion */ - { + { base = 10; - if (n < 0 ) - { - u = -n; - *s++ = '-'; - } - } - + if (n < 0) + { + u = -n; + *s++ = '-'; + } + } + p = q = s; do { /* generate digits in reverse order */ - static char hexDigits[] = "0123456789abcdef"; - - *p++ = hexDigits[(UWORD)(u % base)]; + static char hexDigits[] = "0123456789abcdef"; + + *p++ = hexDigits[(UWORD) (u % base)]; } while ((u /= base) > 0); - + *p = '\0'; /* terminate the string */ while (q < --p) { /* reverse the digits */ @@ -155,7 +153,6 @@ BYTE * return s; } - #define LEFT 0 #define RIGHT 1 @@ -165,9 +162,9 @@ WORD printf(CONST BYTE * fmt, ...) { WORD ret; - static char buff[80]; /* adjust if necessary */ + static char buff[80]; /* adjust if necessary */ charp = buff; - ret = do_printf(fmt, (BYTE **)&fmt + 1); + ret = do_printf(fmt, (BYTE **) & fmt + 1); handle_char(NULL); _ES = FP_SEG(buff); _DX = FP_OFF(buff); @@ -179,20 +176,20 @@ WORD printf(CONST BYTE * fmt, ...) WORD printf(CONST BYTE * fmt, ...) { charp = 0; - return do_printf(fmt, (BYTE **)&fmt + 1); + return do_printf(fmt, (BYTE **) & fmt + 1); } #endif -WORD -sprintf(BYTE * buff, CONST BYTE * fmt, ...) +WORD sprintf(BYTE * buff, CONST BYTE * fmt, ...) { WORD ret; charp = buff; - ret = do_printf(fmt, (BYTE **)&fmt + 1); + ret = do_printf(fmt, (BYTE **) & fmt + 1); handle_char(NULL); return ret; } + /* ULONG FAR retcs(int i) { @@ -202,19 +199,14 @@ ULONG FAR retcs(int i) return *(ULONG *)p; } */ -COUNT - do_printf(CONST BYTE * fmt, BYTE ** arg) +COUNT do_printf(CONST BYTE * fmt, BYTE ** arg) { int base; - BYTE s[11], - FAR *p; - int c, - flag, - size, - fill; - int longarg; + BYTE s[11], FAR * p; + int c, flag, size, fill; + int longarg; long currentArg; - + /* long cs = retcs(1); put_console("0123456789ABCDEF"[(cs >> 28) & 0x0f]); @@ -235,154 +227,148 @@ COUNT continue; } - longarg = FALSE; - size = 0; + longarg = FALSE; + size = 0; flag = RIGHT; fill = ' '; - if ( *fmt == '-') + if (*fmt == '-') { flag = LEFT; fmt++; } - - if ( *fmt == '0') + + if (*fmt == '0') { fill = '0'; fmt++; } - while (*fmt >= '0' && *fmt <= '9') - { + while (*fmt >= '0' && *fmt <= '9') + { size = size * 10 + (*fmt++ - '0'); - } - - + } if (*fmt == 'l') { - longarg = TRUE; - fmt++; + longarg = TRUE; + fmt++; } - c = *fmt++; switch (c) { - case '\0': - return 0; - + case '\0': + return 0; + case 'c': - handle_char(*(COUNT *) arg++); - continue; + handle_char(*(COUNT *) arg++); + continue; case 'p': - { - UWORD w[2]; - static char pointerFormat[] = "%04x:%04x"; - w[1] = *((UWORD *) arg); - arg += sizeof(UWORD)/sizeof(BYTE *); - w[0] = *((UWORD *) arg); - arg += sizeof(UWORD)/sizeof(BYTE *); - do_printf(pointerFormat,(BYTE**)&w); - continue; - } + { + UWORD w[2]; + static char pointerFormat[] = "%04x:%04x"; + w[1] = *((UWORD *) arg); + arg += sizeof(UWORD) / sizeof(BYTE *); + w[0] = *((UWORD *) arg); + arg += sizeof(UWORD) / sizeof(BYTE *); + do_printf(pointerFormat, (BYTE **) & w); + continue; + } case 's': - p = *arg++; - goto do_outputstring; - + p = *arg++; + goto do_outputstring; + case 'F': - fmt++; - /* we assume %Fs here */ + fmt++; + /* we assume %Fs here */ case 'S': - p = *((BYTE FAR **) arg); - arg += sizeof(BYTE FAR *)/sizeof(BYTE *); - goto do_outputstring; + p = *((BYTE FAR **) arg); + arg += sizeof(BYTE FAR *) / sizeof(BYTE *); + goto do_outputstring; case 'i': case 'd': - base = -10; - goto lprt; + base = -10; + goto lprt; case 'o': - base = 8; - goto lprt; + base = 8; + goto lprt; case 'u': - base = 10; - goto lprt; + base = 10; + goto lprt; case 'X': case 'x': - base = 16; - - lprt: - if (longarg) - { - currentArg = *((LONG *) arg); - arg += sizeof(LONG)/sizeof(BYTE *); - } - else - { - if (base < 0) - { - currentArg = *((int*) arg); - arg += sizeof(int)/sizeof(BYTE *); - } - else - { - currentArg = *((unsigned int*) arg); - arg += sizeof(unsigned int)/sizeof(BYTE *); - } - } - - ltob(currentArg, s, base); - - p = s; -do_outputstring: - - size -= fstrlen(p); - - if (flag == RIGHT ) - { - for ( ; size > 0; size--) - handle_char(fill); - } - for (; *p != '\0'; p++) - handle_char(*p); - - for ( ; size > 0; size--) - handle_char(fill); - - continue; - - default: - handle_char('?'); - - handle_char(c); - break; - + base = 16; + + lprt: + if (longarg) + { + currentArg = *((LONG *) arg); + arg += sizeof(LONG) / sizeof(BYTE *); + } + else + { + if (base < 0) + { + currentArg = *((int *)arg); + arg += sizeof(int) / sizeof(BYTE *); + } + else + { + currentArg = *((unsigned int *)arg); + arg += sizeof(unsigned int) / sizeof(BYTE *); + } + } + + ltob(currentArg, s, base); + + p = s; + do_outputstring: + + size -= fstrlen(p); + + if (flag == RIGHT) + { + for (; size > 0; size--) + handle_char(fill); + } + for (; *p != '\0'; p++) + handle_char(*p); + + for (; size > 0; size--) + handle_char(fill); + + continue; + + default: + handle_char('?'); + + handle_char(c); + break; } } return 0; } -void hexd(char *title,UBYTE FAR *p,COUNT numBytes) +void hexd(char *title, UBYTE FAR * p, COUNT numBytes) { - int loop; - printf("%s%04x|", title, FP_SEG(p)); - for (loop = 0; loop < numBytes; loop++) - printf("%02x ", p[loop]); - printf("|"); - - for (loop = 0; loop < numBytes; loop++) - printf("%c", p[loop] < 0x20 ? '.' : p[loop]); - printf("\n"); -} - - + int loop; + printf("%s%04x|", title, FP_SEG(p)); + for (loop = 0; loop < numBytes; loop++) + printf("%02x ", p[loop]); + printf("|"); + + for (loop = 0; loop < numBytes; loop++) + printf("%c", p[loop] < 0x20 ? '.' : p[loop]); + printf("\n"); +} #ifdef TEST /* @@ -397,83 +383,108 @@ void hexd(char *title,UBYTE FAR *p,COUNT numBytes) */ #include -void cso(char c) { putch(c); } +void cso(char c) +{ + putch(c); +} +struct { + char *should; + char *format; + unsigned lowint; + unsigned highint; + +} testarray[] = { + { + "hello world", "%s %s", (unsigned)"hello", (unsigned)"world"}, + { + "hello", "%3s", (unsigned)"hello", 0}, + { + " hello", "%7s", (unsigned)"hello", 0}, + { + "hello ", "%-7s", (unsigned)"hello", 0}, + { + "hello", "%s", (unsigned)"hello", 0}, + { + "1", "%d", 1, 0}, + { + "-1", "%d", -1, 0}, + { + "65535", "%u", -1, 0}, + { + "-32768", "%d", 0x8000, 0}, + { + "32767", "%d", 0x7fff, 0}, + { + "-32767", "%d", 0x8001, 0}, + { + "8000", "%x", 0x8000, 0}, + { + " 1", "%4x", 1, 0}, + { + "0001", "%04x", 1, 0}, + { + "1 ", "%-4x", 1, 0}, + { + "1000", "%-04x", 1, 0}, + { + "1", "%ld", 1, 0}, + { + "-1", "%ld", -1, -1}, + { + "65535", "%ld", -1, 0}, + { + "65535", "%u", -1, 0}, + { + "8000", "%lx", 0x8000, 0}, + { + "80000000", "%lx", 0, 0x8000}, + { + " 1", "%4lx", 1, 0}, + { + "0001", "%04lx", 1, 0}, + { + "1 ", "%-4lx", 1, 0}, + { + "1000", "%-04lx", 1, 0}, + { + "-2147483648", "%ld", 0, 0x8000}, + { + "2147483648", "%lu", 0, 0x8000}, + { + "2147483649", "%lu", 1, 0x8000}, + { + "-2147483647", "%ld", 1, 0x8000}, + { + "32767", "%ld", 0x7fff, 0}, + { +"ptr 1234:5678", "ptr %p", 0x5678, 0x1234}, 0}; -struct { - char *should; - char *format; - unsigned lowint; - unsigned highint; - -} testarray[] = - { - { "hello world", "%s %s", (unsigned)"hello",(unsigned)"world"}, - { "hello", "%3s", (unsigned)"hello",0}, - { " hello", "%7s", (unsigned)"hello",0}, - { "hello ", "%-7s", (unsigned)"hello",0}, - { "hello", "%s", (unsigned)"hello",0}, - - - - { "1", "%d", 1, 0}, - { "-1", "%d", -1,0}, - { "65535", "%u", -1,0}, - { "-32768", "%d", 0x8000,0}, - { "32767", "%d", 0x7fff,0}, - { "-32767", "%d", 0x8001,0}, - - {"8000", "%x", 0x8000, 0}, - {" 1", "%4x", 1, 0}, - {"0001", "%04x", 1, 0}, - {"1 ", "%-4x", 1, 0}, - {"1000", "%-04x", 1, 0}, - - { "1", "%ld", 1, 0}, - { "-1", "%ld", -1,-1}, - { "65535", "%ld", -1,0}, - { "65535", "%u", -1,0}, - {"8000", "%lx", 0x8000, 0}, - {"80000000", "%lx", 0,0x8000}, - {" 1", "%4lx", 1, 0}, - {"0001", "%04lx", 1, 0}, - {"1 ", "%-4lx", 1, 0}, - {"1000", "%-04lx", 1, 0}, - - { "-2147483648", "%ld", 0,0x8000}, - { "2147483648", "%lu", 0,0x8000}, - { "2147483649", "%lu", 1,0x8000}, - { "-2147483647", "%ld", 1,0x8000}, - { "32767", "%ld", 0x7fff,0}, - - { "ptr 1234:5678", "ptr %p", 0x5678,0x1234}, - - - - 0 - }; - test(char *should, char *format, unsigned lowint, unsigned highint) { - char b[100]; - - sprintf(b, format, lowint,highint); - - printf("'%s' = '%s'\n", should, b); - - if (strcmp(b,should)) { printf("\nhit the ANYKEY\n"); getch(); } -} + char b[100]; + sprintf(b, format, lowint, highint); + + printf("'%s' = '%s'\n", should, b); + + if (strcmp(b, should)) + { + printf("\nhit the ANYKEY\n"); + getch(); + } +} main() { - int i; - printf("hello world\n"); - - for (i = 0; testarray[i].should; i++) - { - test(testarray[i].should,testarray[i].format, testarray[i].lowint, testarray[i].highint); - } + int i; + printf("hello world\n"); + + for (i = 0; testarray[i].should; i++) + { + test(testarray[i].should, testarray[i].format, testarray[i].lowint, + testarray[i].highint); + } } #endif @@ -517,4 +528,3 @@ main() * Rev 1.0 02 Jul 1995 8:05:10 patv * Initial revision. */ - diff --git a/kernel/proto.h b/kernel/proto.h index 9789168c..31ea757b 100644 --- a/kernel/proto.h +++ b/kernel/proto.h @@ -28,15 +28,15 @@ #ifdef MAIN #ifdef VERSION_STRINGS -static BYTE *Proto_hRcsId = "$Id$"; +static BYTE *Proto_hRcsId = + "$Id$"; #endif #endif - /* blockio.c */ ULONG getblkno(struct buffer FAR *); VOID setblkno(struct buffer FAR *, ULONG); -struct buffer FAR *getblock (ULONG blkno, COUNT dsk); +struct buffer FAR *getblock(ULONG blkno, COUNT dsk); struct buffer FAR *getblockOver(ULONG blkno, COUNT dsk); VOID setinvld(REG COUNT dsk); BOOL flush_buffers(REG COUNT dsk); @@ -45,7 +45,8 @@ BOOL flush(void); BOOL fill(REG struct buffer FAR * bp, ULONG blkno, COUNT dsk); BOOL DeleteBlockInBufferCache(ULONG blknolow, ULONG blknohigh, COUNT dsk); /* *** Changed on 9/4/00 BER */ -UWORD dskxfer(COUNT dsk, ULONG blkno, VOID FAR * buf, UWORD numblocks, COUNT mode); +UWORD dskxfer(COUNT dsk, ULONG blkno, VOID FAR * buf, UWORD numblocks, + COUNT mode); /* *** End of change */ /* chario.c */ @@ -66,19 +67,20 @@ sft FAR *get_sft(UCOUNT); /* dosfns.c */ #ifdef WITHFAT32 -struct dpb FAR *GetDriveDPB(UBYTE drive, COUNT *rc); +struct dpb FAR *GetDriveDPB(UBYTE drive, COUNT * rc); #endif BYTE FAR *get_root(BYTE FAR *); BOOL fnmatch(BYTE FAR *, BYTE FAR *, COUNT, COUNT); BOOL check_break(void); -UCOUNT GenericReadSft(sft far *sftp, UCOUNT n, BYTE FAR * bp, COUNT FAR * err, - BOOL force_binary); -COUNT SftSeek(sft FAR *sftp, LONG new_pos, COUNT mode); +UCOUNT GenericReadSft(sft far * sftp, UCOUNT n, BYTE FAR * bp, + COUNT FAR * err, BOOL force_binary); +COUNT SftSeek(sft FAR * sftp, LONG new_pos, COUNT mode); /* COUNT DosRead(COUNT hndl, UCOUNT n, BYTE FAR * bp, COUNT FAR * err); */ #define GenericRead(hndl, n, bp, err, t) GenericReadSft(get_sft(hndl), n, bp, err, t) #define DosRead(hndl, n, bp, err) GenericRead(hndl, n, bp, err, FALSE) #define DosReadSft(sftp, n, bp, err) GenericReadSft(sftp, n, bp, err, FALSE) -UCOUNT DosWriteSft(sft FAR *sftp, UCOUNT n, BYTE FAR * bp, COUNT FAR * err); +UCOUNT DosWriteSft(sft FAR * sftp, UCOUNT n, BYTE FAR * bp, + COUNT FAR * err); #define DosWrite(hndl, n, bp, err) DosWriteSft(get_sft(hndl), n, bp, err) COUNT DosSeek(COUNT hndl, LONG new_pos, COUNT mode, ULONG * set_pos); COUNT DosCreat(BYTE FAR * fname, COUNT attrib); @@ -90,8 +92,9 @@ COUNT DosOpen(BYTE FAR * fname, COUNT mode); COUNT DosOpenSft(BYTE * fname, COUNT mode); COUNT DosClose(COUNT hndl); COUNT DosCloseSft(WORD sft_idx); -BOOL DosGetFree(UBYTE drive, UCOUNT FAR * spc, UCOUNT FAR * navc, UCOUNT FAR * bps, UCOUNT FAR * nc); -COUNT DosGetExtFree(BYTE FAR *DriveString, struct xfreespace FAR *xfsp); +BOOL DosGetFree(UBYTE drive, UCOUNT FAR * spc, UCOUNT FAR * navc, + UCOUNT FAR * bps, UCOUNT FAR * nc); +COUNT DosGetExtFree(BYTE FAR * DriveString, struct xfreespace FAR * xfsp); COUNT DosGetCuDir(UBYTE drive, BYTE FAR * s); COUNT DosChangeDir(BYTE FAR * s); COUNT DosFindFirst(UCOUNT attr, BYTE FAR * name); @@ -102,12 +105,12 @@ COUNT DosSetFtimeSft(WORD sft_idx, date dp, time tp); COUNT DosGetFattr(BYTE FAR * name); COUNT DosSetFattr(BYTE FAR * name, UWORD attrp); UBYTE DosSelectDrv(UBYTE drv); -COUNT DosDelete(BYTE FAR *path); +COUNT DosDelete(BYTE FAR * path); COUNT DosRename(BYTE FAR * path1, BYTE FAR * path2); COUNT DosRenameTrue(BYTE * path1, BYTE * path2); COUNT DosMkdir(BYTE FAR * dir); COUNT DosRmdir(BYTE FAR * dir); -struct dhdr FAR * IsDevice(BYTE FAR * FileName); +struct dhdr FAR *IsDevice(BYTE FAR * FileName); BOOL IsShareInstalled(void); COUNT DosLockUnlock(COUNT hndl, LONG pos, LONG len, COUNT unlock); sft FAR *idx_to_sft(COUNT SftIndex); @@ -140,11 +143,11 @@ BOOL dir_write(REG f_node_ptr fnp); VOID dir_close(REG f_node_ptr fnp); COUNT dos_findfirst(UCOUNT attr, BYTE * name); COUNT dos_findnext(void); -void ConvertName83ToNameSZ(BYTE FAR *destSZ, BYTE FAR *srcFCBName); -int FileName83Length(BYTE *filename83); +void ConvertName83ToNameSZ(BYTE FAR * destSZ, BYTE FAR * srcFCBName); +int FileName83Length(BYTE * filename83); /* fatfs.c */ -ULONG clus2phys(CLUSTER cl_no, struct dpb FAR *dpbp); +ULONG clus2phys(CLUSTER cl_no, struct dpb FAR * dpbp); COUNT dos_open(BYTE * path, COUNT flag); BOOL fcmp(BYTE * s1, BYTE * s2, COUNT n); BOOL fcmp_wild(BYTE FAR * s1, BYTE FAR * s2, COUNT n); @@ -169,7 +172,7 @@ UCOUNT writeblock(COUNT fd, VOID FAR * buffer, UCOUNT count, COUNT * err); COUNT dos_read(COUNT fd, VOID FAR * buffer, UCOUNT count); COUNT dos_write(COUNT fd, VOID FAR * buffer, UCOUNT count); LONG dos_lseek(COUNT fd, LONG foffset, COUNT origin); -CLUSTER dos_free(struct dpb FAR *dpbp); +CLUSTER dos_free(struct dpb FAR * dpbp); VOID trim_path(BYTE FAR * s); @@ -180,27 +183,31 @@ VOID release_f_node(f_node_ptr fnp); VOID dos_setdta(BYTE FAR * newdta); COUNT dos_getfattr(BYTE * name); COUNT dos_setfattr(BYTE * name, UWORD attrp); -COUNT media_check(REG struct dpb FAR *dpbp); +COUNT media_check(REG struct dpb FAR * dpbp); f_node_ptr xlt_fd(COUNT fd); COUNT xlt_fnp(f_node_ptr fnp); struct dhdr FAR *select_unit(COUNT drive); #ifdef WITHFAT32 -VOID bpb_to_dpb(bpb FAR *bpbp, REG struct dpb FAR * dpbp, BOOL extended); +VOID bpb_to_dpb(bpb FAR * bpbp, REG struct dpb FAR * dpbp, BOOL extended); #else -VOID bpb_to_dpb(bpb FAR *bpbp, REG struct dpb FAR * dpbp); +VOID bpb_to_dpb(bpb FAR * bpbp, REG struct dpb FAR * dpbp); #endif /* fattab.c */ -void read_fsinfo(struct dpb FAR *dpbp); -void write_fsinfo(struct dpb FAR *dpbp); -UCOUNT link_fat(struct dpb FAR *dpbp, CLUSTER Cluster1, REG CLUSTER Cluster2); -UCOUNT link_fat32(struct dpb FAR *dpbp, CLUSTER Cluster1, CLUSTER Cluster2); -UCOUNT link_fat16(struct dpb FAR *dpbp, CLUSTER Cluster1, CLUSTER Cluster2); -UCOUNT link_fat12(struct dpb FAR *dpbp, CLUSTER Cluster1, CLUSTER Cluster2); -CLUSTER next_cluster(struct dpb FAR *dpbp, REG CLUSTER ClusterNum); -CLUSTER next_cl32(struct dpb FAR *dpbp, REG CLUSTER ClusterNum); -CLUSTER next_cl16(struct dpb FAR *dpbp, REG CLUSTER ClusterNum); -CLUSTER next_cl12(struct dpb FAR *dpbp, REG CLUSTER ClusterNum); +void read_fsinfo(struct dpb FAR * dpbp); +void write_fsinfo(struct dpb FAR * dpbp); +UCOUNT link_fat(struct dpb FAR * dpbp, CLUSTER Cluster1, + REG CLUSTER Cluster2); +UCOUNT link_fat32(struct dpb FAR * dpbp, CLUSTER Cluster1, + CLUSTER Cluster2); +UCOUNT link_fat16(struct dpb FAR * dpbp, CLUSTER Cluster1, + CLUSTER Cluster2); +UCOUNT link_fat12(struct dpb FAR * dpbp, CLUSTER Cluster1, + CLUSTER Cluster2); +CLUSTER next_cluster(struct dpb FAR * dpbp, REG CLUSTER ClusterNum); +CLUSTER next_cl32(struct dpb FAR * dpbp, REG CLUSTER ClusterNum); +CLUSTER next_cl16(struct dpb FAR * dpbp, REG CLUSTER ClusterNum); +CLUSTER next_cl12(struct dpb FAR * dpbp, REG CLUSTER ClusterNum); /* fcbfns.c */ VOID DosOutputString(BYTE FAR * s); @@ -209,21 +216,25 @@ int DosCharInput(VOID); VOID DosDirectConsoleIO(iregs FAR * r); VOID DosCharOutput(COUNT c); VOID DosDisplayOutput(COUNT c); -VOID FatGetDrvData(UCOUNT drive, UCOUNT FAR * spc, UCOUNT FAR * bps, UCOUNT FAR * nc, BYTE FAR ** mdp); +VOID FatGetDrvData(UCOUNT drive, UCOUNT FAR * spc, UCOUNT FAR * bps, + UCOUNT FAR * nc, BYTE FAR ** mdp); WORD FcbParseFname(int wTestMode, BYTE FAR ** lpFileName, fcb FAR * lpFcb); BYTE FAR *ParseSkipWh(BYTE FAR * lpFileName); BOOL TestCmnSeps(BYTE FAR * lpFileName); BOOL TestFieldSeps(BYTE FAR * lpFileName); -BYTE FAR *GetNameField(BYTE FAR * lpFileName, BYTE FAR * lpDestField, COUNT nFieldSize, BOOL * pbWildCard); +BYTE FAR *GetNameField(BYTE FAR * lpFileName, BYTE FAR * lpDestField, + COUNT nFieldSize, BOOL * pbWildCard); BOOL FcbRead(xfcb FAR * lpXfcb, COUNT * nErrorCode); BOOL FcbWrite(xfcb FAR * lpXfcb, COUNT * nErrorCode); BOOL FcbGetFileSize(xfcb FAR * lpXfcb); BOOL FcbSetRandom(xfcb FAR * lpXfcb); BOOL FcbCalcRec(xfcb FAR * lpXfcb); -BOOL FcbRandomBlockRead(xfcb FAR * lpXfcb, COUNT nRecords, COUNT * nErrorCode); -BOOL FcbRandomBlockWrite(xfcb FAR * lpXfcb, COUNT nRecords, COUNT * nErrorCode); +BOOL FcbRandomBlockRead(xfcb FAR * lpXfcb, COUNT nRecords, + COUNT * nErrorCode); +BOOL FcbRandomBlockWrite(xfcb FAR * lpXfcb, COUNT nRecords, + COUNT * nErrorCode); BOOL FcbRandomIO(xfcb FAR * lpXfcb, COUNT * nErrorCode, - BOOL (*FcbFunc)(xfcb FAR *, COUNT *)); + BOOL(*FcbFunc) (xfcb FAR *, COUNT *)); BOOL FcbCreate(xfcb FAR * lpXfcb); void FcbNameInit(fcb FAR * lpFcb, BYTE * pszBuffer, COUNT * pCurDrive); BOOL FcbOpen(xfcb FAR * lpXfcb); @@ -242,7 +253,8 @@ seg far2para(VOID FAR * p); seg long2para(ULONG size); VOID FAR *add_far(VOID FAR * fp, ULONG off); VOID FAR *adjust_far(VOID FAR * fp); -COUNT DosMemAlloc(UWORD size, COUNT mode, seg FAR * para, UWORD FAR * asize); +COUNT DosMemAlloc(UWORD size, COUNT mode, seg FAR * para, + UWORD FAR * asize); COUNT DosMemLargest(UWORD FAR * size); COUNT DosMemFree(UWORD para); COUNT DosMemChange(UWORD para, UWORD size, UWORD * maxSize); @@ -258,7 +270,7 @@ VOID strcpy(REG BYTE * d, REG BYTE * s); VOID ASMCFUNC fmemcpy(REG VOID FAR * d, REG VOID FAR * s, REG COUNT n); VOID ASMCFUNC fstrcpy(REG BYTE FAR * d, REG BYTE FAR * s); VOID ASMCFUNC fstrcpy(REG BYTE FAR * d, REG BYTE FAR * s); -void ASMCFUNC memcpy(REG void * d, REG VOID * s, REG COUNT n); +void ASMCFUNC memcpy(REG void *d, REG VOID * s, REG COUNT n); void ASMCFUNC fmemset(REG VOID FAR * s, REG int ch, REG COUNT n); void ASMCFUNC memset(REG VOID * s, REG int ch, REG COUNT n); @@ -280,27 +292,27 @@ BYTE DosYesNo(unsigned char ch); VOID DosUpMem(VOID FAR * str, unsigned len); #endif unsigned char ASMCFUNC DosUpChar(unsigned char ch); -VOID DosUpString(char FAR *str); -VOID DosUpFMem(VOID FAR *str, unsigned len); +VOID DosUpString(char FAR * str); +VOID DosUpFMem(VOID FAR * str, unsigned len); unsigned char DosUpFChar(unsigned char ch); -VOID DosUpFString(char FAR *str); -COUNT DosGetData(int subfct, UWORD cp, UWORD cntry - , UWORD bufsize, VOID FAR * buf); +VOID DosUpFString(char FAR * str); +COUNT DosGetData(int subfct, UWORD cp, UWORD cntry, UWORD bufsize, + VOID FAR * buf); #ifndef DosGetCountryInformation -COUNT DosGetCountryInformation(UWORD cntry, VOID FAR *buf); +COUNT DosGetCountryInformation(UWORD cntry, VOID FAR * buf); #endif #ifndef DosSetCountry COUNT DosSetCountry(UWORD cntry); #endif -COUNT DosGetCodepage(UWORD FAR* actCP, UWORD FAR* sysCP); +COUNT DosGetCodepage(UWORD FAR * actCP, UWORD FAR * sysCP); COUNT DosSetCodepage(UWORD actCP, UWORD sysCP); UWORD ASMCFUNC syscall_MUX14(DIRECT_IREGS); /* prf.c */ VOID put_console(COUNT c); -WORD printf(CONST BYTE * fmt,...); +WORD printf(CONST BYTE * fmt, ...); WORD sprintf(BYTE * buff, CONST BYTE * fmt, ...); -VOID hexd(char *title,VOID FAR *p,COUNT numBytes); +VOID hexd(char *title, VOID FAR * p, COUNT numBytes); /* strings.c */ COUNT ASMCFUNC strlen(REG BYTE * s); @@ -318,7 +330,7 @@ void fsncopy(REG BYTE FAR * s, REG BYTE FAR * d, COUNT l); void ASMCFUNC fstrncpy(REG BYTE FAR * d, REG BYTE FAR * s, COUNT l); #define fsncopy(s,d,l) fstrncpy(d,s,l) -BYTE * ASMCFUNC strchr(BYTE * s, BYTE c); +BYTE *ASMCFUNC strchr(BYTE * s, BYTE c); /* sysclk.c */ WORD FAR ASMCFUNC clk_driver(rqptr rp); @@ -341,18 +353,19 @@ WORD con_driver(rqptr rp); VOID break_handler(void); /* systime.c */ -VOID DosGetTime(BYTE FAR * hp, BYTE FAR * mp, BYTE FAR * sp, BYTE FAR * hdp); +VOID DosGetTime(BYTE FAR * hp, BYTE FAR * mp, BYTE FAR * sp, + BYTE FAR * hdp); COUNT DosSetTime(BYTE h, BYTE m, BYTE s, BYTE hd); -VOID DosGetDate(BYTE FAR * wdp, BYTE FAR * mp, BYTE FAR * mdp, COUNT FAR * yp); +VOID DosGetDate(BYTE FAR * wdp, BYTE FAR * mp, BYTE FAR * mdp, + COUNT FAR * yp); COUNT DosSetDate(UWORD Month, UWORD DayOfMonth, UWORD Year); -UWORD *is_leap_year_monthdays(UWORD year); +UWORD *is_leap_year_monthdays(UWORD year); UWORD DaysFromYearMonthDay(UWORD Year, UWORD Month, UWORD DayOfMonth); - - /* task.c */ -COUNT ChildEnv(exec_blk FAR * exp, UWORD * pChildEnvSeg, char far * pathname); +COUNT ChildEnv(exec_blk FAR * exp, UWORD * pChildEnvSeg, + char far * pathname); VOID new_psp(psp FAR * p, int psize); VOID return_user(void); COUNT DosExec(COUNT mode, exec_blk FAR * ep, BYTE FAR * lp); @@ -366,8 +379,10 @@ COUNT get_verify_drive(char FAR * src); COUNT ASMCFUNC truename(char FAR * src, char FAR * dest, COUNT t); /* network.c */ -COUNT ASMCFUNC remote_doredirect(UWORD b, UCOUNT n, UWORD d, VOID FAR * s, UWORD i, VOID FAR * data); -COUNT ASMCFUNC remote_printset(UWORD b, UCOUNT n, UWORD d, VOID FAR * s, UWORD i, VOID FAR * data); +COUNT ASMCFUNC remote_doredirect(UWORD b, UCOUNT n, UWORD d, VOID FAR * s, + UWORD i, VOID FAR * data); +COUNT ASMCFUNC remote_printset(UWORD b, UCOUNT n, UWORD d, VOID FAR * s, + UWORD i, VOID FAR * data); COUNT ASMCFUNC remote_rename(VOID); COUNT ASMCFUNC remote_delete(VOID); COUNT ASMCFUNC remote_chdir(VOID); @@ -376,18 +391,18 @@ COUNT ASMCFUNC remote_rmdir(VOID); COUNT ASMCFUNC remote_close_all(VOID); COUNT ASMCFUNC remote_process_end(VOID); COUNT ASMCFUNC remote_flushall(VOID); -COUNT ASMCFUNC remote_findfirst(VOID FAR *s); -COUNT ASMCFUNC remote_findnext(VOID FAR *s); +COUNT ASMCFUNC remote_findfirst(VOID FAR * s); +COUNT ASMCFUNC remote_findnext(VOID FAR * s); COUNT ASMCFUNC remote_getfattr(VOID); -COUNT ASMCFUNC remote_getfree(VOID FAR *s, VOID *d); -COUNT ASMCFUNC remote_open(sft FAR *s, COUNT mode); -LONG ASMCFUNC remote_lseek(sft FAR *s, LONG new_pos); -UCOUNT ASMCFUNC remote_read(sft FAR *s, UCOUNT n, COUNT * err); -UCOUNT ASMCFUNC remote_write(sft FAR *s, UCOUNT n, COUNT * err); -COUNT ASMCFUNC remote_creat(sft FAR *s, COUNT attr); +COUNT ASMCFUNC remote_getfree(VOID FAR * s, VOID * d); +COUNT ASMCFUNC remote_open(sft FAR * s, COUNT mode); +LONG ASMCFUNC remote_lseek(sft FAR * s, LONG new_pos); +UCOUNT ASMCFUNC remote_read(sft FAR * s, UCOUNT n, COUNT * err); +UCOUNT ASMCFUNC remote_write(sft FAR * s, UCOUNT n, COUNT * err); +COUNT ASMCFUNC remote_creat(sft FAR * s, COUNT attr); COUNT ASMCFUNC remote_setfattr(COUNT attr); COUNT ASMCFUNC remote_printredir(UCOUNT dx, UCOUNT ax); -COUNT ASMCFUNC remote_close(sft FAR *s); +COUNT ASMCFUNC remote_close(sft FAR * s); COUNT ASMCFUNC QRemote_Fn(char FAR * s, char FAR * d); UWORD get_machine_name(BYTE FAR * netname); @@ -399,7 +414,6 @@ VOID ASMCFUNC exec_user(iregs FAR * irp); /* detect.c */ unsigned long FAR is_dosemu(void); - /* new by TE */ /* @@ -413,10 +427,10 @@ unsigned long FAR is_dosemu(void); #define ASSERT_CONST(x) { typedef struct { char _xx[x ? 1 : -1]; } xx ; } #if defined(WATCOM) && 0 -ULONG FAR ASMCFUNC MULULUS(ULONG mul1, UWORD mul2); /* MULtiply ULong by UShort */ -ULONG FAR ASMCFUNC MULULUL(ULONG mul1, ULONG mul2); /* MULtiply ULong by ULong */ -ULONG FAR ASMCFUNC DIVULUS(ULONG mul1, UWORD mul2); /* DIVide ULong by UShort */ -ULONG FAR ASMCFUNC DIVMODULUS(ULONG mul1, UWORD mul2,UWORD *rem); /* DIVide ULong by UShort */ +ULONG FAR ASMCFUNC MULULUS(ULONG mul1, UWORD mul2); /* MULtiply ULong by UShort */ +ULONG FAR ASMCFUNC MULULUL(ULONG mul1, ULONG mul2); /* MULtiply ULong by ULong */ +ULONG FAR ASMCFUNC DIVULUS(ULONG mul1, UWORD mul2); /* DIVide ULong by UShort */ +ULONG FAR ASMCFUNC DIVMODULUS(ULONG mul1, UWORD mul2, UWORD * rem); /* DIVide ULong by UShort */ #endif /* diff --git a/kernel/strings.c b/kernel/strings.c index bf7967cf..3c69f1aa 100644 --- a/kernel/strings.c +++ b/kernel/strings.c @@ -29,7 +29,8 @@ #include "portab.h" #ifdef VERSION_STRINGS -static BYTE *stringsRcsId = "$Id$"; +static BYTE *stringsRcsId = + "$Id$"; #endif #ifndef I86 @@ -187,4 +188,3 @@ BYTE *strchr(BYTE * s, BYTE c) * Rev 1.0 02 Jul 1995 8:33:46 patv * Initial revision. */ - diff --git a/kernel/sysclk.c b/kernel/sysclk.c index 867c7cb4..d7ae4656 100644 --- a/kernel/sysclk.c +++ b/kernel/sysclk.c @@ -30,7 +30,8 @@ #include "globals.h" #ifdef VERSION_STRINGS -static BYTE *RcsId = "$Id$"; +static BYTE *RcsId = + "$Id$"; #endif #ifdef PROTO @@ -54,8 +55,7 @@ VOID DayToBcd(); /* */ /* WARNING - THIS DRIVER IS NON-PORTABLE!!!! */ /* */ -extern UWORD days[2][13]; /* this is defined by SYSTIME.C */ - +extern UWORD days[2][13]; /* this is defined by SYSTIME.C */ static struct ClockRecord clk; @@ -82,42 +82,35 @@ static COUNT BcdToByte(COUNT x) WORD FAR ASMCFUNC clk_driver(rqptr rp) { - COUNT - c; + COUNT c; UWORD *pdays; - BYTE bcd_days[4], - bcd_minutes, - bcd_hours, - bcd_seconds; + BYTE bcd_days[4], bcd_minutes, bcd_hours, bcd_seconds; ULONG Ticks; - UWORD Month, - Day, - Year; - - - + UWORD Month, Day, Year; + switch (rp->r_command) { case C_INIT: /* If AT clock exists, copy AT clock time to system clock */ if (!ReadATClock(bcd_days, &bcd_hours, &bcd_minutes, &bcd_seconds)) { - DaysSinceEpoch = DaysFromYearMonthDay( - 100 * BcdToByte(bcd_days[3]) + BcdToByte(bcd_days[2]), - BcdToByte(bcd_days[1]), - BcdToByte(bcd_days[0]) ); + DaysSinceEpoch = + DaysFromYearMonthDay(100 * BcdToByte(bcd_days[3]) + + BcdToByte(bcd_days[2]), + BcdToByte(bcd_days[1]), + BcdToByte(bcd_days[0])); - /* - * This is a rather tricky calculation. The number of timer ticks per - * second is not exactly 18.2, but rather 0x1800b0 / 86400 = 19663 / 1080 - * (the timer interrupt updates the midnight flag when the tick count - * reaches 0x1800b0). Fortunately, 86400 * 19663 = 1698883200 < ULONG_MAX, - * so we can simply multiply the number of seconds by 19663 without - * worrying about overflow. :) -- ror4 - */ + /* + * This is a rather tricky calculation. The number of timer ticks per + * second is not exactly 18.2, but rather 0x1800b0 / 86400 = 19663 / 1080 + * (the timer interrupt updates the midnight flag when the tick count + * reaches 0x1800b0). Fortunately, 86400 * 19663 = 1698883200 < ULONG_MAX, + * so we can simply multiply the number of seconds by 19663 without + * worrying about overflow. :) -- ror4 + */ Ticks = (3600ul * BcdToByte(bcd_hours) + - 60ul * BcdToByte(bcd_minutes) + - BcdToByte(bcd_seconds)) * 19663ul / 1080ul; + 60ul * BcdToByte(bcd_minutes) + + BcdToByte(bcd_seconds)) * 19663ul / 1080ul; WritePCClock(Ticks); } rp->r_endaddr = device_end(); @@ -126,8 +119,7 @@ WORD FAR ASMCFUNC clk_driver(rqptr rp) case C_INPUT: { - ULONG remainder, - hs; + ULONG remainder, hs; if (ReadPCClock(&Ticks)) ++DaysSinceEpoch; clk.clkDays = DaysSinceEpoch; @@ -138,7 +130,7 @@ WORD FAR ASMCFUNC clk_driver(rqptr rp) * (100 x 86400) / 0x1800b0 = 108000 / 19663. -- ror4 */ hs = 0; -#if 0 +#if 0 if (Ticks >= 64 * 19663ul) { hs += 64 * 108000ul; @@ -175,14 +167,14 @@ WORD FAR ASMCFUNC clk_driver(rqptr rp) Ticks -= 19663ul; } #else - { - UWORD q1 = Ticks/19663ul; + { + UWORD q1 = Ticks / 19663ul; + + Ticks -= q1 * 19663ul; + hs = q1 * 108000ul; + } - Ticks -= q1*19663ul; - hs = q1*108000ul; - } - -#endif +#endif /* * Now Ticks < 19663, so Ticks * 108000 < 2123604000 < ULONG_MAX. * *phew* -- ror4 @@ -195,12 +187,13 @@ WORD FAR ASMCFUNC clk_driver(rqptr rp) clk.clkSeconds = remainder / 100ul; clk.clkHundredths = remainder % 100ul; } - - fmemcpy(rp->r_trans, &clk, min(sizeof(struct ClockRecord),rp->r_count )); + + fmemcpy(rp->r_trans, &clk, + min(sizeof(struct ClockRecord), rp->r_count)); return S_DONE; case C_OUTPUT: - rp->r_count = min(rp->r_count,sizeof(struct ClockRecord)); + rp->r_count = min(rp->r_count, sizeof(struct ClockRecord)); fmemcpy(&clk, rp->r_trans, rp->r_count); /* Set PC Clock first */ @@ -209,10 +202,9 @@ WORD FAR ASMCFUNC clk_driver(rqptr rp) ULONG hs; hs = 360000ul * clk.clkHours + 6000ul * clk.clkMinutes + - 100ul * clk.clkSeconds + - clk.clkHundredths; + 100ul * clk.clkSeconds + clk.clkHundredths; Ticks = 0; -#if 0 +#if 0 if (hs >= 64 * 108000ul) { Ticks += 64 * 19663ul; @@ -248,15 +240,15 @@ WORD FAR ASMCFUNC clk_driver(rqptr rp) Ticks += 19663ul; hs -= 108000ul; } -#else - { - UWORD q1 = hs/108000ul; +#else + { + UWORD q1 = hs / 108000ul; + + hs -= q1 * 108000ul; + Ticks = q1 * 19663ul; + } - hs -= q1*108000ul; - Ticks = q1*19663ul; - } - -#endif +#endif Ticks += hs * 19663ul / 108000ul; } WritePCClock(Ticks); @@ -264,7 +256,7 @@ WORD FAR ASMCFUNC clk_driver(rqptr rp) /* Now set AT clock */ /* Fix year by looping through each year, subtracting */ /* the appropriate number of days for that year. */ - for (Year = 1980, c = clk.clkDays; ;) + for (Year = 1980, c = clk.clkDays;;) { pdays = is_leap_year_monthdays(Year); if (c >= pdays[12]) @@ -286,8 +278,7 @@ WORD FAR ASMCFUNC clk_driver(rqptr rp) break; } } - - + DayToBcd((BYTE *) bcd_days, &Month, &Day, &Year); bcd_minutes = ByteToBcd(clk.clkMinutes); bcd_hours = ByteToBcd(clk.clkHours); @@ -304,7 +295,7 @@ WORD FAR ASMCFUNC clk_driver(rqptr rp) case C_OSTAT: case C_ISTAT: default: - return failure(E_FAILURE); /* general failure */ + return failure(E_FAILURE); /* general failure */ } } @@ -364,4 +355,3 @@ VOID DayToBcd(BYTE * x, UWORD * mon, UWORD * day, UWORD * yr) * Rev 1.0 02 Jul 1995 8:32:30 patv * Initial revision. */ - diff --git a/kernel/syspack.c b/kernel/syspack.c index 41aede48..2e4adefa 100644 --- a/kernel/syspack.c +++ b/kernel/syspack.c @@ -31,7 +31,8 @@ #include "globals.h" #ifdef VERSION_STRINGS -static BYTE *syspackRcsId = "$Id$"; +static BYTE *syspackRcsId = + "$Id$"; #endif #ifdef NONNATIVE @@ -55,7 +56,8 @@ VOID getbyte(VOID * vp, BYTE * bp) VOID fgetword(REG VOID FAR * vp, WORD FAR * wp) { - *wp = (((BYTE FAR *) vp)[0] & 0xff) + ((((BYTE FAR *) vp)[1] & 0xff) << 8); + *wp = + (((BYTE FAR *) vp)[0] & 0xff) + ((((BYTE FAR *) vp)[1] & 0xff) << 8); } VOID fgetlong(REG VOID FAR * vp, LONG FAR * lp) diff --git a/kernel/systime.c b/kernel/systime.c index dd96ab92..e6afc783 100644 --- a/kernel/systime.c +++ b/kernel/systime.c @@ -32,43 +32,43 @@ #include "globals.h" #ifdef VERSION_STRINGS -static BYTE *RcsId = "$Id$"; +static BYTE *RcsId = + "$Id$"; #endif -UWORD days[2][13] = -{ +UWORD days[2][13] = { {0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365}, {0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366} }; -extern request - ClkReqHdr; - +extern request ClkReqHdr; + /* return a pointer to an array with the days for that year -*/ +*/ UWORD *is_leap_year_monthdays(UWORD y) { - /* this is correct in a strict mathematical sense - return ((y) & 3 ? days[0] : (y) % 100 ? days[1] : (y) % 400 ? days[0] : days[1]); */ - - /* this will work until 2200 - long enough for me - and saves 0x1f bytes */ - - if ((y & 3) || y == 2100) return days[0]; - - return days[1]; + /* this is correct in a strict mathematical sense + return ((y) & 3 ? days[0] : (y) % 100 ? days[1] : (y) % 400 ? days[0] : days[1]); */ + + /* this will work until 2200 - long enough for me - and saves 0x1f bytes */ + + if ((y & 3) || y == 2100) + return days[0]; + + return days[1]; } UWORD DaysFromYearMonthDay(UWORD Year, UWORD Month, UWORD DayOfMonth) { - if (Year < 1980) return 0; - + if (Year < 1980) + return 0; + return DayOfMonth - 1 + is_leap_year_monthdays(Year)[Month - 1] - + ((Year - 1980) * 365) - + ((Year - 1980 + 3) / 4); - + + ((Year - 1980) * 365) + ((Year - 1980 + 3) / 4); + } /* common - call the clock driver */ @@ -80,14 +80,13 @@ void ExecuteClockDriverRequest(BYTE command) ClkReqHdr.r_trans = (BYTE FAR *) (&ClkRecord); ClkReqHdr.r_status = 0; execrh((request FAR *) & ClkReqHdr, (struct dhdr FAR *)clock); -} - - +} -VOID DosGetTime(BYTE FAR * hp, BYTE FAR * mp, BYTE FAR * sp, BYTE FAR * hdp) +VOID DosGetTime(BYTE FAR * hp, BYTE FAR * mp, BYTE FAR * sp, + BYTE FAR * hdp) { ExecuteClockDriverRequest(C_INPUT); - + if (ClkReqHdr.r_status & S_ERROR) return; @@ -99,8 +98,9 @@ VOID DosGetTime(BYTE FAR * hp, BYTE FAR * mp, BYTE FAR * sp, BYTE FAR * hdp) COUNT DosSetTime(BYTE h, BYTE m, BYTE s, BYTE hd) { - BYTE Month, DayOfMonth, DayOfWeek; COUNT Year; - + BYTE Month, DayOfMonth, DayOfWeek; + COUNT Year; + DosGetDate((BYTE FAR *) & DayOfWeek, (BYTE FAR *) & Month, (BYTE FAR *) & DayOfMonth, (COUNT FAR *) & Year); @@ -119,21 +119,19 @@ COUNT DosSetTime(BYTE h, BYTE m, BYTE s, BYTE hd) } VOID DosGetDate(wdp, mp, mdp, yp) -BYTE FAR *wdp, - FAR * mp, - FAR * mdp; +BYTE FAR *wdp, FAR * mp, FAR * mdp; COUNT FAR *yp; { UWORD c; - UWORD *pdays; - UWORD Year,Month; + UWORD *pdays; + UWORD Year, Month; ExecuteClockDriverRequest(C_INPUT); if (ClkReqHdr.r_status & S_ERROR) return; - for (Year = 1980, c = ClkRecord.clkDays; ;) + for (Year = 1980, c = ClkRecord.clkDays;;) { pdays = is_leap_year_monthdays(Year); if (c >= pdays[12]) @@ -154,7 +152,7 @@ COUNT FAR *yp; } *mp = Month; - *mdp = c - pdays[Month-1] + 1; + *mdp = c - pdays[Month - 1] + 1; *yp = Year; /* Day of week is simple. Take mod 7, add 2 (for Tuesday */ @@ -164,19 +162,15 @@ COUNT FAR *yp; } COUNT DosSetDate(Month, DayOfMonth, Year) -UWORD Month, - DayOfMonth, - Year; +UWORD Month, DayOfMonth, Year; { UWORD *pdays; - pdays = is_leap_year_monthdays(Year); - + pdays = is_leap_year_monthdays(Year); + if (Year < 1980 || Year > 2099 || Month < 1 || Month > 12 - || DayOfMonth < 1 - || DayOfMonth > pdays[Month] - pdays[Month-1]) + || DayOfMonth < 1 || DayOfMonth > pdays[Month] - pdays[Month - 1]) return DE_INVLDDATA; - DosGetTime((BYTE FAR *) & ClkRecord.clkHours, (BYTE FAR *) & ClkRecord.clkMinutes, diff --git a/kernel/task.c b/kernel/task.c index 214e5ef9..303cd25c 100644 --- a/kernel/task.c +++ b/kernel/task.c @@ -30,7 +30,8 @@ #include "globals.h" #ifdef VERSION_STRINGS -static BYTE *RcsId = "$Id$"; +static BYTE *RcsId = + "$Id$"; #endif #define toupper(c) ((c) >= 'a' && (c) <= 'z' ? (c) + ('A' - 'a') : (c)) @@ -46,11 +47,11 @@ static exe_header header; #define CHUNK 32256 #define MAXENV 32768u #define ENV_KEEPFREE 83 /* keep unallocated by environment variables */ - /* The '65' added to nEnvSize does not cover the additional stuff: - + 2 bytes: number of strings - + 80 bytes: maximum absolute filename - + 1 byte: '\0' - -- 1999/04/21 ska */ + /* The '65' added to nEnvSize does not cover the additional stuff: + + 2 bytes: number of strings + + 80 bytes: maximum absolute filename + + 1 byte: '\0' + -- 1999/04/21 ska */ #ifndef PROTO COUNT ChildEnv(exec_blk FAR *, UWORD *, char far *); @@ -88,7 +89,8 @@ LONG DosGetFsize(COUNT hndl) return dos_getfsize(s->sft_status); } -COUNT ChildEnv(exec_blk FAR * exp, UWORD * pChildEnvSeg, char far * pathname) +COUNT ChildEnv(exec_blk FAR * exp, UWORD * pChildEnvSeg, + char far * pathname) { BYTE FAR *pSrc; BYTE FAR *pDest; @@ -101,14 +103,12 @@ COUNT ChildEnv(exec_blk FAR * exp, UWORD * pChildEnvSeg, char far * pathname) /* copy parent's environment if exec.env_seg == 0 */ pSrc = exp->exec.env_seg ? - MK_FP(exp->exec.env_seg, 0) : - MK_FP(ppsp->ps_environ, 0); + MK_FP(exp->exec.env_seg, 0) : MK_FP(ppsp->ps_environ, 0); #if 0 /* Every process requires an environment because of argv[0] -- 1999/04/21 ska */ - */ - if (!pSrc) /* no environment to copy */ + */if (!pSrc) /* no environment to copy */ { *pChildEnvSeg = 0; return SUCCESS; @@ -120,15 +120,15 @@ COUNT ChildEnv(exec_blk FAR * exp, UWORD * pChildEnvSeg, char far * pathname) -- 1999/04/21 ska */ if (pSrc) { /* if no environment is available, one byte is required */ - - for (nEnvSize = 0; ; nEnvSize++) + + for (nEnvSize = 0;; nEnvSize++) { - /* Test env size and abort if greater than max */ - if (nEnvSize >= MAXENV - ENV_KEEPFREE) - return DE_INVLDENV; - - if (*(UWORD FAR *)(pSrc+nEnvSize) == 0) - break; + /* Test env size and abort if greater than max */ + if (nEnvSize >= MAXENV - ENV_KEEPFREE) + return DE_INVLDENV; + + if (*(UWORD FAR *) (pSrc + nEnvSize) == 0) + break; } nEnvSize += 2; /* account for trailing \0\0 */ } @@ -136,7 +136,7 @@ COUNT ChildEnv(exec_blk FAR * exp, UWORD * pChildEnvSeg, char far * pathname) /* allocate enough space for env + path */ if ((RetCode = DosMemAlloc(long2para(nEnvSize + ENV_KEEPFREE), mem_access_mode, (seg FAR *) pChildEnvSeg, - NULL /*(UWORD FAR *) MaxEnvSize ska */ )) < 0) + NULL /*(UWORD FAR *) MaxEnvSize ska */ )) < 0) return RetCode; pDest = MK_FP(*pChildEnvSeg + 1, 0); @@ -152,12 +152,13 @@ COUNT ChildEnv(exec_blk FAR * exp, UWORD * pChildEnvSeg, char far * pathname) else *pDest++ = '\0'; /* create an empty environment */ - /* initialize 'extra strings' count */ + /* initialize 'extra strings' count */ *((UWORD FAR *) pDest) = 1; - pDest += sizeof(UWORD)/sizeof(BYTE); + pDest += sizeof(UWORD) / sizeof(BYTE); /* copy complete pathname */ - if ((RetCode = truename(pathname, pDest, TRUE)) != SUCCESS) { + if ((RetCode = truename(pathname, pDest, TRUE)) != SUCCESS) + { return RetCode; } @@ -172,7 +173,7 @@ COUNT ChildEnv(exec_blk FAR * exp, UWORD * pChildEnvSeg, char far * pathname) /* The following code is 8086 dependant */ VOID new_psp(psp FAR * p, int psize) { - REG COUNT i; + REG COUNT i; psp FAR *q = MK_FP(cu_psp, 0); /* Clear out new psp first */ @@ -225,7 +226,7 @@ VOID new_psp(psp FAR * p, int psize) p->ps_filetab = p->ps_files; /* clone the file table */ - if (p!=q) + if (p != q) { REG COUNT i; @@ -250,7 +251,7 @@ VOID new_psp(psp FAR * p, int psize) RootPsp = FP_SEG(p); } -STATIC UWORD patchPSP(UWORD pspseg, UWORD envseg, exec_blk FAR *exb, +STATIC UWORD patchPSP(UWORD pspseg, UWORD envseg, exec_blk FAR * exb, BYTE FAR * fnam) { psp FAR *psp; @@ -302,29 +303,33 @@ STATIC UWORD patchPSP(UWORD pspseg, UWORD envseg, exec_blk FAR *exb, pspmcb->m_name[i] = '\0'; /* return value: AX value to be passed based on FCB values */ - return ((psp->ps_fcb1.fcb_drivecds_table[psp->ps_fcb1.fcb_drive].cdsFlags & CDSVALID) ? 0 : 0xff) + - ((psp->ps_fcb2.fcb_drivecds_table[psp->ps_fcb2.fcb_drive].cdsFlags & CDSVALID) ? 0 : 0xff) * 0x100; + return ((psp->ps_fcb1.fcb_drive < lastdrive && + CDSp->cds_table[psp->ps_fcb1.fcb_drive]. + cdsFlags & CDSVALID) ? 0 : 0xff) + ((psp->ps_fcb2.fcb_drive < + lastdrive + && CDSp->cds_table[psp-> + ps_fcb2. + fcb_drive]. + cdsFlags & CDSVALID) ? 0 : + 0xff) * 0x100; } COUNT DosComLoader(BYTE FAR * namep, exec_blk FAR * exp, COUNT mode) { COUNT rc - /* err */ - /*,env_size*/; + /* err */ + /*,env_size */ ; COUNT nread; UWORD mem; - UWORD env, - asize; + UWORD env, asize; BYTE FAR *sp; psp FAR *p; psp FAR *q = MK_FP(cu_psp, 0); iregs FAR *irp; LONG com_size; - int ModeLoadHigh = mode & 0x80; - UBYTE UMBstate = uppermem_link; + int ModeLoadHigh = mode & 0x80; + UBYTE UMBstate = uppermem_link; mode &= 0x7f; @@ -335,9 +340,9 @@ COUNT DosComLoader(BYTE FAR * namep, exec_blk FAR * exp, COUNT mode) { return rc; } - - /* COMFILES will always be loaded in largest area. is that true TE*/ - + + /* COMFILES will always be loaded in largest area. is that true TE */ + /* Now find out how many paragraphs are available */ if ((rc = DosMemLargest((seg FAR *) & asize)) != SUCCESS) { @@ -345,48 +350,49 @@ COUNT DosComLoader(BYTE FAR * namep, exec_blk FAR * exp, COUNT mode) return rc; } com_size = asize; - - if ( ModeLoadHigh ) - { - DosUmbLink(1); /* link in UMB's */ - } - + + if (ModeLoadHigh) + { + DosUmbLink(1); /* link in UMB's */ + } + /* Allocate our memory and pass back any errors */ - if ((rc = DosMemAlloc((seg) com_size, mem_access_mode, (seg FAR *) & mem - ,(UWORD FAR *) & asize)) < 0) + if ((rc = + DosMemAlloc((seg) com_size, mem_access_mode, (seg FAR *) & mem, + (UWORD FAR *) & asize)) < 0) { - if (rc == DE_NOMEM) + if (rc == DE_NOMEM) + { + if ((rc = + DosMemAlloc(0, LARGEST, (seg FAR *) & mem, + (UWORD FAR *) & asize)) < 0) { - if ((rc = DosMemAlloc(0, LARGEST, (seg FAR *) & mem - ,(UWORD FAR *) & asize)) < 0) - { - DosMemFree(env); - return rc; - } - /* This should never happen, but ... */ - if (asize < com_size) - { - DosMemFree(mem); - DosMemFree(env); - return rc; - } + DosMemFree(env); + return rc; } - else + /* This should never happen, but ... */ + if (asize < com_size) { - DosMemFree(env); /* env may be 0 */ - return rc; + DosMemFree(mem); + DosMemFree(env); + return rc; } + } + else + { + DosMemFree(env); /* env may be 0 */ + return rc; + } } ++mem; } else mem = exp->load.load_seg; - - if ( ModeLoadHigh ) - { - DosUmbLink(UMBstate); /* restore link state */ - } - + + if (ModeLoadHigh) + { + DosUmbLink(UMBstate); /* restore link state */ + } /* Now load the executable */ /* If file not found - error */ @@ -401,20 +407,19 @@ COUNT DosComLoader(BYTE FAR * namep, exec_blk FAR * exp, COUNT mode) if (mode == OVERLAY) /* memory already allocated */ sp = MK_FP(mem, 0); else - { /* test the filesize against the allocated memory */ - + { /* test the filesize against the allocated memory */ + sp = MK_FP(mem, sizeof(psp)); /* This is a potential problem, what to do with .COM files larger than the allocated memory? MS DOS always only loads the very first 64KB - sizeof(psp) bytes. -- 1999/04/21 ska */ - - /* BUG !! in case of LH, memory may be smaller then 64K TE*/ - - - if (com_size > ((LONG)asize << 4)) /* less memory than the .COM file has */ - com_size = (LONG)asize << 4; + + /* BUG !! in case of LH, memory may be smaller then 64K TE */ + + if (com_size > ((LONG) asize << 4)) /* less memory than the .COM file has */ + com_size = (LONG) asize << 4; } do { @@ -433,7 +438,7 @@ COUNT DosComLoader(BYTE FAR * namep, exec_blk FAR * exp, COUNT mode) setvec(0x22, (VOID(INRPT FAR *) (VOID)) MK_FP(user_r->CS, user_r->IP)); new_psp(p, mem + asize); - asize = patchPSP(mem - 1, env, exp, namep); /* asize=fcbcode for ax */ + asize = patchPSP(mem - 1, env, exp, namep); /* asize=fcbcode for ax */ /* Transfer control to the executable */ p->ps_parent = cu_psp; @@ -447,14 +452,13 @@ COUNT DosComLoader(BYTE FAR * namep, exec_blk FAR * exp, COUNT mode) { case LOADNGO: { - /* BUG !! - this works only, if COMSIZE >= 64K - in case of LH, this is not necessarily true - */ - - + /* BUG !! + this works only, if COMSIZE >= 64K + in case of LH, this is not necessarily true + */ + *((UWORD FAR *) MK_FP(mem, 0xfffe)) = (UWORD) 0; - + /* build the user area on the stack */ irp = MK_FP(mem, (0xfffe - sizeof(iregs))); @@ -462,13 +466,8 @@ COUNT DosComLoader(BYTE FAR * namep, exec_blk FAR * exp, COUNT mode) irp->ES = irp->DS = mem; irp->CS = mem; irp->IP = 0x100; - irp->AX = asize; /* fcbcode */ - irp->BX = - irp->CX = - irp->DX = - irp->SI = - irp->DI = - irp->BP = 0; + irp->AX = asize; /* fcbcode */ + irp->BX = irp->CX = irp->DX = irp->SI = irp->DI = irp->BP = 0; irp->FLAGS = 0x200; if (InDOS) @@ -476,12 +475,12 @@ COUNT DosComLoader(BYTE FAR * namep, exec_blk FAR * exp, COUNT mode) exec_user(irp); /* We should never be here - fatal("KERNEL RETURNED!!!"); */ + fatal("KERNEL RETURNED!!!"); */ break; } case LOAD: exp->exec.stack = MK_FP(mem, 0xfffe); - *((UWORD FAR *)exp->exec.stack) = asize; + *((UWORD FAR *) exp->exec.stack) = asize; exp->exec.start_addr = MK_FP(mem, 0x100); return SUCCESS; } @@ -491,8 +490,7 @@ COUNT DosComLoader(BYTE FAR * namep, exec_blk FAR * exp, COUNT mode) VOID return_user(void) { - psp FAR *p, - FAR * q; + psp FAR *p, FAR * q; REG COUNT i; iregs FAR *irp; /* long j;*/ @@ -506,8 +504,8 @@ VOID return_user(void) setvec(0x24, p->ps_isv24); /* And free all process memory if not a TSR return */ - remote_process_end(); /* might be a good idea to do that after closing - but doesn't help NET either TE */ + remote_process_end(); /* might be a good idea to do that after closing + but doesn't help NET either TE */ if (!tsr) { remote_close_all(); @@ -518,7 +516,6 @@ VOID return_user(void) FcbCloseAll(); FreeProcessMem(cu_psp); } - cu_psp = p->ps_parent; q = MK_FP(cu_psp, 0); @@ -536,20 +533,16 @@ VOID return_user(void) COUNT DosExeLoader(BYTE FAR * namep, exec_blk FAR * exp, COUNT mode) { - COUNT rc; - /*err, */ - /*env_size,*/ - - UWORD mem, - env, - asize, - start_seg; - - int ModeLoadHigh = mode & 0x80; + COUNT rc; + /*err, */ + /*env_size, */ + + UWORD mem, env, asize, start_seg; + + int ModeLoadHigh = mode & 0x80; UBYTE UMBstate = uppermem_link; mode &= 0x7f; - /* Clone the environement and create a memory arena */ if (mode != OVERLAY) @@ -559,126 +552,123 @@ COUNT DosExeLoader(BYTE FAR * namep, exec_blk FAR * exp, COUNT mode) } else mem = exp->load.load_seg; - { - ULONG image_size; - ULONG image_offset; - LONG exe_size; - mcb FAR *mp; - - - /* compute image offset from the header */ - image_offset = (ULONG)header.exHeaderSize * 16; - - /* compute image size by removing the offset from the */ - /* number pages scaled to bytes plus the remainder and */ - /* the psp */ - /* First scale the size */ - image_size = (ULONG)header.exPages * 512; - /* remove the offset */ - image_size -= image_offset; - - /* and finally add in the psp size */ - if (mode != OVERLAY) - image_size += sizeof(psp); /*TE 03/20/01*/ - - if (mode != OVERLAY) - { - if ( ModeLoadHigh ) - { - DosUmbLink(1); /* link in UMB's */ - mem_access_mode |= ModeLoadHigh; - } - - /* Now find out how many paragraphs are available */ - if ((rc = DosMemLargest((seg FAR *) & asize)) != SUCCESS) - { - DosMemFree(env); - return rc; - } + ULONG image_size; + ULONG image_offset; + LONG exe_size; + mcb FAR *mp; + + /* compute image offset from the header */ + image_offset = (ULONG) header.exHeaderSize * 16; + + /* compute image size by removing the offset from the */ + /* number pages scaled to bytes plus the remainder and */ + /* the psp */ + /* First scale the size */ + image_size = (ULONG) header.exPages * 512; + /* remove the offset */ + image_size -= image_offset; + + /* and finally add in the psp size */ + if (mode != OVERLAY) + image_size += sizeof(psp); /*TE 03/20/01 */ - exe_size = (LONG) long2para(image_size) + header.exMinAlloc; - - - /* + long2para((LONG) sizeof(psp)); ?? see above - image_size += sizeof(psp) -- 1999/04/21 ska */ - if (exe_size > asize && (mem_access_mode & 0x80)) + if (mode != OVERLAY) { - /* First try low memory */ - mem_access_mode &= ~0x80; - rc = DosMemLargest((seg FAR *) & asize); - mem_access_mode |= 0x80; - if (rc != SUCCESS) + if (ModeLoadHigh) + { + DosUmbLink(1); /* link in UMB's */ + mem_access_mode |= ModeLoadHigh; + } + + /* Now find out how many paragraphs are available */ + if ((rc = DosMemLargest((seg FAR *) & asize)) != SUCCESS) { DosMemFree(env); return rc; } - } - if (exe_size > asize) - { - DosMemFree(env); - return DE_NOMEM; - } - exe_size = (LONG) long2para(image_size) + header.exMaxAlloc; - /* + long2para((LONG) sizeof(psp)); ?? -- 1999/04/21 ska */ - if (exe_size > asize) - exe_size = asize; - - /* TE if header.exMinAlloc == header.exMaxAlloc == 0, - DOS will allocate the largest possible memory area - and load the image as high as possible into it. - discovered (and after that found in RBIL), when testing NET */ - - if ((header.exMinAlloc | header.exMaxAlloc ) == 0) - exe_size = asize; - - - /* /// Removed closing curly brace. We should not attempt to allocate - memory if we are overlaying the current process, because the new - process will simply re-use the block we already have allocated. - This was causing execl() to fail in applications which use it to - overlay (replace) the current exe file with a new one. - Jun 11, 2000 - rbc - } */ + exe_size = (LONG) long2para(image_size) + header.exMinAlloc; - /* Allocate our memory and pass back any errors */ - /* We can still get an error on first fit if the above */ - /* returned size was a bet fit case */ - /* ModeLoadHigh = 80 = try high, then low */ - if ((rc = DosMemAlloc((seg) exe_size, mem_access_mode | ModeLoadHigh, (seg FAR *) & mem - ,(UWORD FAR *) & asize)) < 0) - { - if (rc == DE_NOMEM) - { - if ((rc = DosMemAlloc(0, LARGEST, (seg FAR *) & mem - ,(UWORD FAR *) & asize)) < 0) + /* + long2para((LONG) sizeof(psp)); ?? see above + image_size += sizeof(psp) -- 1999/04/21 ska */ + if (exe_size > asize && (mem_access_mode & 0x80)) { - DosMemFree(env); - return rc; + /* First try low memory */ + mem_access_mode &= ~0x80; + rc = DosMemLargest((seg FAR *) & asize); + mem_access_mode |= 0x80; + if (rc != SUCCESS) + { + DosMemFree(env); + return rc; + } } - /* This should never happen, but ... */ - if (asize < exe_size) + if (exe_size > asize) { - DosMemFree(mem); DosMemFree(env); - return rc; + return DE_NOMEM; } - } - else - { - DosMemFree(env); - return rc; - } - } - else - /* with no error, we got exactly what we asked for */ - asize = exe_size; + exe_size = (LONG) long2para(image_size) + header.exMaxAlloc; + /* + long2para((LONG) sizeof(psp)); ?? -- 1999/04/21 ska */ + if (exe_size > asize) + exe_size = asize; + + /* TE if header.exMinAlloc == header.exMaxAlloc == 0, + DOS will allocate the largest possible memory area + and load the image as high as possible into it. + discovered (and after that found in RBIL), when testing NET */ + + if ((header.exMinAlloc | header.exMaxAlloc) == 0) + exe_size = asize; + + /* /// Removed closing curly brace. We should not attempt to allocate + memory if we are overlaying the current process, because the new + process will simply re-use the block we already have allocated. + This was causing execl() to fail in applications which use it to + overlay (replace) the current exe file with a new one. + Jun 11, 2000 - rbc + } */ + + /* Allocate our memory and pass back any errors */ + /* We can still get an error on first fit if the above */ + /* returned size was a bet fit case */ + /* ModeLoadHigh = 80 = try high, then low */ + if ((rc = + DosMemAlloc((seg) exe_size, mem_access_mode | ModeLoadHigh, + (seg FAR *) & mem, (UWORD FAR *) & asize)) < 0) + { + if (rc == DE_NOMEM) + { + if ((rc = + DosMemAlloc(0, LARGEST, (seg FAR *) & mem, + (UWORD FAR *) & asize)) < 0) + { + DosMemFree(env); + return rc; + } + /* This should never happen, but ... */ + if (asize < exe_size) + { + DosMemFree(mem); + DosMemFree(env); + return rc; + } + } + else + { + DosMemFree(env); + return rc; + } + } + else + /* with no error, we got exactly what we asked for */ + asize = exe_size; -#ifdef DEBUG - printf("loading '%S' at %04x\n", namep, mem); -#endif +#ifdef DEBUG + printf("loading '%S' at %04x\n", namep, mem); +#endif /* /// Added open curly brace and "else" clause. We should not attempt to allocate memory if we are overlaying the current process, because @@ -686,114 +676,118 @@ COUNT DosExeLoader(BYTE FAR * namep, exec_blk FAR * exp, COUNT mode) This was causing execl() to fail in applications which use it to overlay (replace) the current exe file with a new one. Jun 11, 2000 - rbc */ - } - else - asize = exe_size; + } + else + asize = exe_size; /* /// End of additions. Jun 11, 2000 - rbc */ - if ( ModeLoadHigh ) + if (ModeLoadHigh) { - mem_access_mode &= ~ModeLoadHigh; /* restore old situation */ - DosUmbLink(UMBstate); /* restore link state */ + mem_access_mode &= ~ModeLoadHigh; /* restore old situation */ + DosUmbLink(UMBstate); /* restore link state */ } - - if (mode != OVERLAY) - { - /* memory found large enough - continue processing */ - mp = MK_FP(mem, 0); - ++mem; - } - else - mem = exp->load.load_seg; - - /* create the start seg for later computations */ - if (mode == OVERLAY) - start_seg = mem; - else - { - start_seg = mem + long2para((LONG) sizeof(psp)); - } - - /* Now load the executable */ - /* If file not found - error */ - /* NOTE - this is fatal because we lost it in transit */ - /* from DosExec! */ - if ((rc = DosOpen(namep, 0)) < 0) - { - fatal("(DosExeLoader) exe file lost in transit"); - } - /* offset to start of image */ - if (doslseek(rc, image_offset, 0) != image_offset) - { if (mode != OVERLAY) { - DosMemFree(--mem); - DosMemFree(env); + /* memory found large enough - continue processing */ + mp = MK_FP(mem, 0); + ++mem; } - return DE_INVLDDATA; - } - - /* read in the image in 32K chunks */ - if (mode != OVERLAY) - { - exe_size = image_size - sizeof(psp); - } - else - exe_size = image_size; + else + mem = exp->load.load_seg; - if (exe_size > 0) - { - UCOUNT nBytesRead; - BYTE FAR *sp; - - if (mode != OVERLAY) + /* create the start seg for later computations */ + if (mode == OVERLAY) + start_seg = mem; + else { - if ((header.exMinAlloc == 0) && (header.exMaxAlloc == 0)) - { - /* then the image should be placed as high as possible */ - start_seg = start_seg + mp->m_size - (image_size + 15) / 16; - } + start_seg = mem + long2para((LONG) sizeof(psp)); } - sp = MK_FP(start_seg, 0x0); - - do + /* Now load the executable */ + /* If file not found - error */ + /* NOTE - this is fatal because we lost it in transit */ + /* from DosExec! */ + if ((rc = DosOpen(namep, 0)) < 0) { - nBytesRead = DosRead((COUNT) rc, (COUNT) (exe_size < CHUNK ? exe_size : CHUNK), (VOID FAR *) sp, &UnusedRetVal); - sp = add_far((VOID FAR *) sp, (ULONG) nBytesRead); - exe_size -= nBytesRead; + fatal("(DosExeLoader) exe file lost in transit"); } - while (nBytesRead && exe_size > 0); - } - } - - { /* relocate the image for new segment */ - COUNT i; - UWORD reloc[2]; - seg FAR *spot; - - doslseek(rc, (LONG) header.exRelocTable, 0); - for (i = 0; i < header.exRelocItems; i++) - { - if (DosRead(rc, sizeof(reloc), (VOID FAR *) & reloc[0], &UnusedRetVal) != sizeof(reloc)) + /* offset to start of image */ + if (doslseek(rc, image_offset, 0) != image_offset) { + if (mode != OVERLAY) + { + DosMemFree(--mem); + DosMemFree(env); + } return DE_INVLDDATA; } - if (mode == OVERLAY) + + /* read in the image in 32K chunks */ + if (mode != OVERLAY) { - spot = MK_FP(reloc[1] + mem, reloc[0]); - *spot += exp->load.reloc; + exe_size = image_size - sizeof(psp); } else + exe_size = image_size; + + if (exe_size > 0) { - /* spot = MK_FP(reloc[1] + mem + 0x10, reloc[0]); */ - spot = MK_FP(reloc[1] + start_seg, reloc[0]); - *spot += start_seg; + UCOUNT nBytesRead; + BYTE FAR *sp; + + if (mode != OVERLAY) + { + if ((header.exMinAlloc == 0) && (header.exMaxAlloc == 0)) + { + /* then the image should be placed as high as possible */ + start_seg = start_seg + mp->m_size - (image_size + 15) / 16; + } + } + + sp = MK_FP(start_seg, 0x0); + + do + { + nBytesRead = + DosRead((COUNT) rc, + (COUNT) (exe_size < CHUNK ? exe_size : CHUNK), + (VOID FAR *) sp, &UnusedRetVal); + sp = add_far((VOID FAR *) sp, (ULONG) nBytesRead); + exe_size -= nBytesRead; + } + while (nBytesRead && exe_size > 0); } } + + { /* relocate the image for new segment */ + COUNT i; + UWORD reloc[2]; + seg FAR *spot; + + doslseek(rc, (LONG) header.exRelocTable, 0); + for (i = 0; i < header.exRelocItems; i++) + { + if (DosRead + (rc, sizeof(reloc), (VOID FAR *) & reloc[0], + &UnusedRetVal) != sizeof(reloc)) + { + return DE_INVLDDATA; + } + if (mode == OVERLAY) + { + spot = MK_FP(reloc[1] + mem, reloc[0]); + *spot += exp->load.reloc; + } + else + { + /* spot = MK_FP(reloc[1] + mem + 0x10, reloc[0]); */ + spot = MK_FP(reloc[1] + start_seg, reloc[0]); + *spot += start_seg; + } + } } - + /* and finally close the file */ DosClose(rc); @@ -801,64 +795,61 @@ COUNT DosExeLoader(BYTE FAR * namep, exec_blk FAR * exp, COUNT mode) if (mode == OVERLAY) return SUCCESS; - { - psp FAR *p; - psp FAR *q = MK_FP(cu_psp, 0); + psp FAR *p; + psp FAR *q = MK_FP(cu_psp, 0); - /* point to the PSP so we can build it */ - p = MK_FP(mem, 0); - setvec(0x22, (VOID(INRPT FAR *) (VOID)) MK_FP(user_r->CS, user_r->IP)); - new_psp(p, mem + asize); + /* point to the PSP so we can build it */ + p = MK_FP(mem, 0); + setvec(0x22, (VOID(INRPT FAR *) (VOID)) MK_FP(user_r->CS, user_r->IP)); + new_psp(p, mem + asize); - asize = patchPSP(mem - 1, env, exp, namep); /* asize = fcbcode */ + asize = patchPSP(mem - 1, env, exp, namep); /* asize = fcbcode */ - /* Transfer control to the executable */ - p->ps_parent = cu_psp; - p->ps_prevpsp = (BYTE FAR *) MK_FP(cu_psp, 0); - q->ps_stack = (BYTE FAR *) user_r; - user_r->FLAGS &= ~FLG_CARRY; + /* Transfer control to the executable */ + p->ps_parent = cu_psp; + p->ps_prevpsp = (BYTE FAR *) MK_FP(cu_psp, 0); + q->ps_stack = (BYTE FAR *) user_r; + user_r->FLAGS &= ~FLG_CARRY; - switch (mode) - { - case LOADNGO: + switch (mode) { - /* build the user area on the stack */ - iregs FAR *irp = MK_FP(header.exInitSS + start_seg, - ((header.exInitSP - sizeof(iregs)) & 0xffff)); - - /* start allocating REGs */ - /* Note: must match es & ds memory segment */ - irp->ES = irp->DS = mem; - irp->CS = header.exInitCS + start_seg; - irp->IP = header.exInitIP; - irp->AX = asize; /* asize = fcbcode */ - irp->BX = - irp->CX = - irp->DX = - irp->SI = - irp->DI = - irp->BP = 0; - irp->FLAGS = 0x200; - - cu_psp = mem; - dta = p->ps_dta; - - if (InDOS) - --InDOS; - exec_user(irp); - /* We should never be here - fatal("KERNEL RETURNED!!!"); */ - break; - } + case LOADNGO: + { + /* build the user area on the stack */ + iregs FAR *irp = MK_FP(header.exInitSS + start_seg, + ((header.exInitSP - + sizeof(iregs)) & 0xffff)); + + /* start allocating REGs */ + /* Note: must match es & ds memory segment */ + irp->ES = irp->DS = mem; + irp->CS = header.exInitCS + start_seg; + irp->IP = header.exInitIP; + irp->AX = asize; /* asize = fcbcode */ + irp->BX = irp->CX = irp->DX = irp->SI = irp->DI = irp->BP = 0; + irp->FLAGS = 0x200; + + cu_psp = mem; + dta = p->ps_dta; + + if (InDOS) + --InDOS; + exec_user(irp); + /* We should never be here + fatal("KERNEL RETURNED!!!"); */ + break; + } - case LOAD: - cu_psp = mem; - exp->exec.stack = MK_FP(header.exInitSS + start_seg, header.exInitSP); - *((UWORD FAR *) exp->exec.stack) = asize; /* fcbcode */ - exp->exec.start_addr = MK_FP(header.exInitCS + start_seg, header.exInitIP); - return SUCCESS; - } + case LOAD: + cu_psp = mem; + exp->exec.stack = + MK_FP(header.exInitSS + start_seg, header.exInitSP); + *((UWORD FAR *) exp->exec.stack) = asize; /* fcbcode */ + exp->exec.start_addr = + MK_FP(header.exInitCS + start_seg, header.exInitIP); + return SUCCESS; + } } return DE_INVLDFMT; } @@ -885,7 +876,6 @@ COUNT DosExec(COUNT mode, exec_blk FAR * ep, BYTE FAR * lp) return DE_FILENOTFND; } - if (DosRead(rc, sizeof(exe_header), (VOID FAR *) & header, &UnusedRetVal) != sizeof(exe_header)) { @@ -995,4 +985,3 @@ COUNT DosExec(COUNT mode, exec_blk FAR * ep, BYTE FAR * lp) * Rev 1.0 02 Jul 1995 8:34:06 patv * Initial revision. */ - diff --git a/sys/bin2c.c b/sys/bin2c.c index f53b3a74..eb70f4a1 100644 --- a/sys/bin2c.c +++ b/sys/bin2c.c @@ -8,7 +8,8 @@ int main(int argc, char **argv) if (argc < 4) { - fprintf(stderr, "Usage: bin2c \n"); + fprintf(stderr, + "Usage: bin2c \n"); return 1; } diff --git a/sys/fdkrncfg.c b/sys/fdkrncfg.c index d1dd706c..21f2d65f 100644 --- a/sys/fdkrncfg.c +++ b/sys/fdkrncfg.c @@ -15,11 +15,9 @@ /* This source compiled & tested with Borland C/C++ 3.1 + TC 2.01*/ - char VERSION[] = "v1.00"; char PROGRAM[] = "SYS CONFIG"; -char KERNEL[] = "KERNEL.SYS"; - +char KERNEL[] = "KERNEL.SYS"; #include #include @@ -30,8 +28,7 @@ char KERNEL[] = "KERNEL.SYS"; #define FAR far #include "kconfig.h" -KernelConfig cfg = {0}; - +KernelConfig cfg = { 0 }; typedef unsigned char byte; typedef signed char sbyte; @@ -40,45 +37,39 @@ typedef signed short sword; typedef unsigned long dword; typedef signed long sdword; - /* These structures need to be byte packed, if your compiler does not do this by default, add the appropriate command, such as #pragma pack(1) here, protected with #ifdefs of course. */ - - /* Displays command line syntax */ void showUsage(void) { printf("Usage: \n" - " %s \n" - " %s [/help | /?]\n" - " %s [ [drive:][path]%s] [option=value ...] \n", - PROGRAM, PROGRAM, PROGRAM, KERNEL); + " %s \n" + " %s [/help | /?]\n" + " %s [ [drive:][path]%s] [option=value ...] \n", + PROGRAM, PROGRAM, PROGRAM, KERNEL); printf("\n"); printf(" If no options are given, the current values are shown.\n"); printf(" /help or /? displays this usage information.\n" - " [drive:][path]KERNEL.SYS specifies the kernel file to\n" - " modify, if not given defaults to %s\n", - KERNEL); + " [drive:][path]KERNEL.SYS specifies the kernel file to\n" + " modify, if not given defaults to %s\n", KERNEL); printf("\n"); - printf(" option=value ... specifies one or more options and the values\n" - " to set each to. If an option is given multiple times,\n" - " the value set will be the rightmost one.\n"); + printf + (" option=value ... specifies one or more options and the values\n" + " to set each to. If an option is given multiple times,\n" + " the value set will be the rightmost one.\n"); printf(" Current Options are: DLASORT=0|1, SHOWDRIVEASSIGNMENT=0|1\n" " SKIPCONFIGSECONDS=#, FORCELBA=0|1\n" " GLOBALENABLELBASUPPORT=0|1\n"); } - - /* simply reads in current configuration values, exiting program with an error message and error code unable to, otherwise cfg & kfile are valid on return. */ - /* Reads in the current kernel configuration settings, return 0 on success, nonzero on error. If there was an actual error the return value is positive, if there @@ -92,35 +83,34 @@ void showUsage(void) not point to allocated memory on entry, as that memory will not be used, and will likely not be freed as a result). */ -int readConfigSettings(int kfile, char *kfilename, KernelConfig *cfg) +int readConfigSettings(int kfile, char *kfilename, KernelConfig * cfg) { int ch; int configBlkFound; word cfgSize; - /* Seek to start of kernel file */ - if (lseek(kfile, 2, SEEK_SET) != 2) - printf("can't seek to offset 2\n"),exit(1); - - if (read(kfile,cfg,sizeof(KernelConfig)) != sizeof(KernelConfig)) - printf("can't read %u bytes\n",sizeof(KernelConfig)),exit(1); + if (lseek(kfile, 2, SEEK_SET) != 2) + printf("can't seek to offset 2\n"), exit(1); - if (memcmp(cfg->CONFIG, "CONFIG", 6) != 0) - { - printf("Error: no CONFIG section found in kernel file <%s>\n", kfilename); - printf("Only FreeDOS kernels after 2025 contain a CONFIG section!\n"); - exit(1); - } + if (read(kfile, cfg, sizeof(KernelConfig)) != sizeof(KernelConfig)) + printf("can't read %u bytes\n", sizeof(KernelConfig)), exit(1); - return 1; -} + if (memcmp(cfg->CONFIG, "CONFIG", 6) != 0) + { + printf("Error: no CONFIG section found in kernel file <%s>\n", + kfilename); + printf("Only FreeDOS kernels after 2025 contain a CONFIG section!\n"); + exit(1); + } + return 1; +} /* Writes config values out to file. Returns 0 on success, nonzero on error. */ -int writeConfigSettings(int kfile, KernelConfig *cfg) +int writeConfigSettings(int kfile, KernelConfig * cfg) { /* Seek to CONFIG section at start of options of kernel file */ @@ -135,53 +125,59 @@ int writeConfigSettings(int kfile, KernelConfig *cfg) return 0; } - /* Displays kernel configuration information */ -void displayConfigSettings(KernelConfig *cfg) +void displayConfigSettings(KernelConfig * cfg) { /* print known options and current value - only if available */ if (cfg->ConfigSize >= 1) { - printf("DLASORT=0x%02X Sort disks by drive order: *0=no, 1=yes\n", - cfg->DLASortByDriveNo); + printf + ("DLASORT=0x%02X Sort disks by drive order: *0=no, 1=yes\n", + cfg->DLASortByDriveNo); } if (cfg->ConfigSize >= 2) { - printf("SHOWDRIVEASSIGNMENT=0x%02X Show how drives assigned: *1=yes 0=no\n", - cfg->InitDiskShowDriveAssignment); + printf + ("SHOWDRIVEASSIGNMENT=0x%02X Show how drives assigned: *1=yes 0=no\n", + cfg->InitDiskShowDriveAssignment); } if (cfg->ConfigSize >= 3) { - printf("SKIPCONFIGSECONDS=%-3d time to wait for F5/F8 : *2 sec (skip < 0)\n", - cfg->SkipConfigSeconds); + printf + ("SKIPCONFIGSECONDS=%-3d time to wait for F5/F8 : *2 sec (skip < 0)\n", + cfg->SkipConfigSeconds); } if (cfg->ConfigSize >= 4) { - printf("FORCELBA=0x%02X Always use LBA if possible: *0=no, 1=yes\n", - cfg->ForceLBA); + printf + ("FORCELBA=0x%02X Always use LBA if possible: *0=no, 1=yes\n", + cfg->ForceLBA); } if (cfg->ConfigSize >= 5) { - printf("GLOBALENABLELBASUPPORT=0x%02X Enable LBA support: *1=yes, 0=no\n", - cfg->GlobalEnableLBAsupport); + printf + ("GLOBALENABLELBASUPPORT=0x%02X Enable LBA support: *1=yes, 0=no\n", + cfg->GlobalEnableLBAsupport); } -#if 0 /* we assume that SYS is as current as the kernel */ +#if 0 /* we assume that SYS is as current as the kernel */ /* Print value any options added that are unknown as hex dump */ if (cfg->configHdr.configSize > sizeof(ConfigData)) { printf("Additional options are available, they are not currently\n" - "supported by this tool. The current extra values are (in Hex):\n"); - for (i = 0; i < (cfg->configSize-sizeof(ConfigData)); i++) + "supported by this tool. The current extra values are (in Hex):\n"); + for (i = 0; i < (cfg->configSize - sizeof(ConfigData)); i++) { - if ((i%32) == 0) printf("\n"); - else if ((i%4) == 0) printf(" "); + if ((i % 32) == 0) + printf("\n"); + else if ((i % 4) == 0) + printf(" "); printf("%02X", (unsigned int)cfg->extra[i]); } printf("\n"); @@ -190,8 +186,6 @@ void displayConfigSettings(KernelConfig *cfg) printf("\n"); } - - /* Note: The setXXXOption functions will set the config option of type XXX to the value given. It will display a warning, but allow probably invalid values to be used (cause I believe in @@ -205,7 +199,8 @@ void displayConfigSettings(KernelConfig *cfg) /* Sets the given location to an unsigned byte value if different, displays warning if values exceeds max */ -void setByteOption(byte *option, char *value, word max, int *updated, char *name) +void setByteOption(byte * option, char *value, word max, int *updated, + char *name) { unsigned long optionValue; @@ -215,17 +210,17 @@ void setByteOption(byte *option, char *value, word max, int *updated, char *name if (optionValue > 255) { printf("Warning: Option %s: Value <0x%02lX> will be truncated!\n", - name, optionValue); + name, optionValue); } - if ((byte)optionValue > max) + if ((byte) optionValue > max) { printf("Warning: Option %s: Value <0x%02X> may be invalid!\n", - name, (unsigned int)((byte)optionValue)); + name, (unsigned int)((byte) optionValue)); } /* Don't bother updating if same value */ - if ((byte)optionValue != *option) + if ((byte) optionValue != *option) { - *option = (byte)optionValue; + *option = (byte) optionValue; *updated = 1; } } @@ -233,36 +228,38 @@ void setByteOption(byte *option, char *value, word max, int *updated, char *name /* Sets the given location to a signed byte value if different, displays warning if values exceeds max or is less than min */ -void setSByteOption(sbyte *option, char *value, sword min, sword max, int *updated, char *name) +void setSByteOption(sbyte * option, char *value, sword min, sword max, + int *updated, char *name) { signed long optionValue; /* optionValue = atoi(value); Use strtol instead of atoi/atol as it detects base */ optionValue = strtol(value, NULL, 0); - if ( (optionValue < -128) || (optionValue > 127) ) + if ((optionValue < -128) || (optionValue > 127)) { printf("Warning: Option %s: Value <0x%02lX> will be truncated!\n", - name, optionValue); + name, optionValue); } - if ( ((sbyte)optionValue > max) || ((sbyte)optionValue < min) ) + if (((sbyte) optionValue > max) || ((sbyte) optionValue < min)) { printf("Warning: Option %s: Value <0x%02X> may be invalid!\n", - name, (signed int)((byte)optionValue)); + name, (signed int)((byte) optionValue)); } /* Don't bother updating if same value */ - if ((sbyte)optionValue != *option) + if ((sbyte) optionValue != *option) { - *option = (sbyte)optionValue; + *option = (sbyte) optionValue; *updated = 1; } } -#if 0 /* disable until there are (un)signed word configuration values */ +#if 0 /* disable until there are (un)signed word configuration values */ /* Sets the given location to an unsigned word value if different, displays warning if values exceeds max */ -void setWordOption(word *option, char *value, dword max, int *updated, char *name) +void setWordOption(word * option, char *value, dword max, int *updated, + char *name) { unsigned long optionValue; @@ -272,17 +269,17 @@ void setWordOption(word *option, char *value, dword max, int *updated, char *nam if (optionValue > 65535) { printf("Warning: Option %s: Value <0x%02lX> will be truncated!\n", - name, optionValue); + name, optionValue); } - if ((word)optionValue > max) + if ((word) optionValue > max) { printf("Warning: Option %s: Value <0x%02X> may be invalid!\n", - name, (unsigned int)optionValue); + name, (unsigned int)optionValue); } /* Don't bother updating if same value */ - if ((word)optionValue != *option) + if ((word) optionValue != *option) { - *option = (word)optionValue; + *option = (word) optionValue; *updated = 1; } } @@ -290,174 +287,166 @@ void setWordOption(word *option, char *value, dword max, int *updated, char *nam /* Sets the given location to a signed byte value if different, displays warning if values exceeds max or is less than min */ -void setSWordOption(sword *option, char *value, sdword min, sdword max, int *updated, char *name) +void setSWordOption(sword * option, char *value, sdword min, sdword max, + int *updated, char *name) { signed long optionValue; /* optionValue = atol(value); Use strtol instead of atoi/atol as it allows 0xFF and 255 */ optionValue = strtol(value, NULL, 0); - if ( (optionValue < -32768) || (optionValue > 32767) ) + if ((optionValue < -32768) || (optionValue > 32767)) { printf("Warning: Option %s: Value <0x%02lX> will be truncated!\n", - name, optionValue); + name, optionValue); } - if ( ((sword)optionValue > max) || ((sword)optionValue < min) ) + if (((sword) optionValue > max) || ((sword) optionValue < min)) { printf("Warning: Option %s: Value <0x%02X> may be invalid!\n", - name, (signed int)optionValue); + name, (signed int)optionValue); } /* Don't bother updating if same value */ - if ((sword)optionValue != *option) + if ((sword) optionValue != *option) { - *option = (sword)optionValue; + *option = (sword) optionValue; *updated = 1; } } #endif - /* Main, processes command line options and calls above functions as required. */ -int FDKrnConfigMain(int argc,char **argv) +int FDKrnConfigMain(int argc, char **argv) { - char *kfilename = KERNEL; + char *kfilename = KERNEL; int kfile; - int updates = 0; /* flag used to indicate if we need to update kernel */ - int argstart,i; + int updates = 0; /* flag used to indicate if we need to update kernel */ + int argstart, i; char *cptr; char *argptr; printf("FreeDOS Kernel Configuration %s\n", VERSION); - /* 1st go through and just process arguments (help/filename/etc) */ - for (i = 2; i < argc; i++) + for (i = 2; i < argc; i++) + { + argptr = argv[i]; + + /* is it an argument or an option specifier */ + if (argptr[0] == '-' || argptr[0] == '/') { - argptr = argv[i]; - - /* is it an argument or an option specifier */ - if (argptr[0] == '-' || argptr[0] == '/') - { - switch(argptr[1]) - { - case 'H': - case 'h': - case '?': - showUsage(); - exit(0); - - default: - printf("Invalid argument found <%s>.\nUse %s /help for usage.\n", - argptr, PROGRAM); - exit(1); - } - } - } - - argstart = 2; - - argptr = argv[argstart]; - -#if 0 /* No arguments is acceptable, just displays current settings using default kernel file */ - if (argptr == 0) - { - showUsage(); - exit(1); - } + switch (argptr[1]) + { + case 'H': + case 'h': + case '?': + showUsage(); + exit(0); + + default: + printf("Invalid argument found <%s>.\nUse %s /help for usage.\n", + argptr, PROGRAM); + exit(1); + } + } + } + + argstart = 2; + + argptr = argv[argstart]; + +#if 0 /* No arguments is acceptable, just displays current settings using default kernel file */ + if (argptr == 0) + { + showUsage(); + exit(1); + } #endif - /* the first argument may be the kernel name */ - if ( (argstart < argc) && (strchr(argptr, '=') == NULL) ) - { - kfilename = argptr; - argstart++; - } - - - kfile = open(kfilename, O_RDWR | O_BINARY); - - if (kfile < 0) - printf("Error: unable to open kernel file <%s>\n", kfilename),exit(1); - - - /* now that we know the filename (default or given) get config info */ - readConfigSettings(kfile, kfilename, &cfg); - - for (i = argstart; i < argc; i++) - { - argptr = argv[i]; - - if ((cptr = strchr(argptr,'=')) == NULL) - goto illegal_arg; - - /* split argptr into 2 pieces and make cptr point to 2nd one */ - *cptr = '\0'; - cptr++; - - /* allow 3 valid characters */ - if (memicmp(argptr, "DLASORT",3) == 0) - { - setByteOption(&(cfg.DLASortByDriveNo), - cptr, 1, &updates, "DLASORT"); - } - else if (memicmp(argptr, "SHOWDRIVEASSIGNMENT",3) == 0) - { - setByteOption(&(cfg.InitDiskShowDriveAssignment), - cptr, 1, &updates, "SHOWDRIVEASSIGNMENT"); - } - else if (memicmp(argptr, "SKIPCONFIGSECONDS",3) == 0) - { - setSByteOption(&(cfg.SkipConfigSeconds), - cptr, -128, 127, &updates, "SKIPCONFIGSECONDS"); - } - else if (memicmp(argptr, "FORCELBA",3) == 0) - { - setByteOption(&(cfg.ForceLBA), - cptr, 1, &updates, "FORCELBA"); - } - else if (memicmp(argptr, "GLOBALENABLELBASUPPORT",3) == 0) - { - setByteOption(&(cfg.GlobalEnableLBAsupport), - cptr, 1, &updates, "GLOBALENABLELBASUPPORT"); - } - else - { -illegal_arg: - printf("Unknown option found <%s>.\nUse %s /help for usage.\n", - argptr, PROGRAM); - exit(1); - } + /* the first argument may be the kernel name */ + if ((argstart < argc) && (strchr(argptr, '=') == NULL)) + { + kfilename = argptr; + argstart++; + } + + kfile = open(kfilename, O_RDWR | O_BINARY); + + if (kfile < 0) + printf("Error: unable to open kernel file <%s>\n", kfilename), exit(1); + + /* now that we know the filename (default or given) get config info */ + readConfigSettings(kfile, kfilename, &cfg); + + for (i = argstart; i < argc; i++) + { + argptr = argv[i]; + + if ((cptr = strchr(argptr, '=')) == NULL) + goto illegal_arg; + + /* split argptr into 2 pieces and make cptr point to 2nd one */ + *cptr = '\0'; + cptr++; + + /* allow 3 valid characters */ + if (memicmp(argptr, "DLASORT", 3) == 0) + { + setByteOption(&(cfg.DLASortByDriveNo), cptr, 1, &updates, "DLASORT"); + } + else if (memicmp(argptr, "SHOWDRIVEASSIGNMENT", 3) == 0) + { + setByteOption(&(cfg.InitDiskShowDriveAssignment), + cptr, 1, &updates, "SHOWDRIVEASSIGNMENT"); + } + else if (memicmp(argptr, "SKIPCONFIGSECONDS", 3) == 0) + { + setSByteOption(&(cfg.SkipConfigSeconds), + cptr, -128, 127, &updates, "SKIPCONFIGSECONDS"); + } + else if (memicmp(argptr, "FORCELBA", 3) == 0) + { + setByteOption(&(cfg.ForceLBA), cptr, 1, &updates, "FORCELBA"); + } + else if (memicmp(argptr, "GLOBALENABLELBASUPPORT", 3) == 0) + { + setByteOption(&(cfg.GlobalEnableLBAsupport), + cptr, 1, &updates, "GLOBALENABLELBASUPPORT"); + } + else + { + illegal_arg: + printf("Unknown option found <%s>.\nUse %s /help for usage.\n", + argptr, PROGRAM); + exit(1); } + } /* write out new config values if modified */ - if (updates) + if (updates) + { + /* update it */ + if (writeConfigSettings(kfile, &cfg)) { - /* update it */ - if (writeConfigSettings(kfile, &cfg)) - { - printf("Error: Unable to write configuration changes to kernel!\n"); - printf(" <%s>\n", kfilename); - close(kfile); - exit(1); - } - - - /* display new settings */ - printf("\nUpdated Kernel settings.\n"); + printf("Error: Unable to write configuration changes to kernel!\n"); + printf(" <%s>\n", kfilename); + close(kfile); + exit(1); } - else - printf("\nCurrent Kernel settings.\n"); + /* display new settings */ + printf("\nUpdated Kernel settings.\n"); + } + else + printf("\nCurrent Kernel settings.\n"); /* display current settings */ - displayConfigSettings(&cfg); + displayConfigSettings(&cfg); - /* and done */ - close(kfile); + /* and done */ + close(kfile); - return 0; + return 0; } - diff --git a/sys/sys.c b/sys/sys.c index 53929044..37f52a84 100644 --- a/sys/sys.c +++ b/sys/sys.c @@ -46,9 +46,9 @@ #include #include #ifdef __TURBOC__ - #include +#include #else - #include +#include #endif #include /*#include */ @@ -69,16 +69,14 @@ BOOL copy(COUNT drive, BYTE * srcPath, BYTE * rootPath, BYTE * file); COUNT DiskRead(WORD, WORD, WORD, WORD, WORD, BYTE FAR *); COUNT DiskWrite(WORD, WORD, WORD, WORD, WORD, BYTE FAR *); - #define SEC_SIZE 512 #define COPY_SIZE 32768u #ifdef _MSC_VER - #pragma pack(1) +#pragma pack(1) #endif -struct bootsectortype -{ +struct bootsectortype { UBYTE bsJump[3]; char OemName[8]; UWORD bsBytesPerSec; @@ -106,8 +104,7 @@ struct bootsectortype ULONG sysDataStart; /* first data sector */ }; -struct bootsectortype32 -{ +struct bootsectortype32 { UBYTE bsJump[3]; char OemName[8]; UWORD bsBytesPerSec; @@ -134,7 +131,7 @@ struct bootsectortype32 UBYTE bsReserved3; UBYTE bsExtendedSignature; ULONG bsSerialNumber; - char bsVolumeLabel[11]; + char bsVolumeLabel[11]; char bsFileSystemID[8]; ULONG sysFatStart; ULONG sysDataStart; @@ -144,19 +141,17 @@ struct bootsectortype32 UBYTE newboot[SEC_SIZE], oldboot[SEC_SIZE]; - #define SBOFFSET 11 #define SBSIZE (sizeof(struct bootsectortype) - SBOFFSET) #define SBSIZE32 (sizeof(struct bootsectortype32) - SBOFFSET) /* essentially - verify alignment on byte boundaries at compile time */ -struct VerifyBootSectorSize -{ - char failure1[sizeof(struct bootsectortype) == 78 ? 1 : -1]; - char failure2[sizeof(struct bootsectortype) == 78 ? 1 : 0]; +struct VerifyBootSectorSize { + char failure1[sizeof(struct bootsectortype) == 78 ? 1 : -1]; + char failure2[sizeof(struct bootsectortype) == 78 ? 1 : 0]; }; -int FDKrnConfigMain(int argc,char **argv); +int FDKrnConfigMain(int argc, char **argv); int main(int argc, char **argv) { @@ -169,26 +164,26 @@ int main(int argc, char **argv) WORD slen; printf("FreeDOS System Installer " SYS_VERSION "\n\n"); - - if (argc > 1 && memicmp(argv[1],"CONFIG",6) == 0) - { - exit(FDKrnConfigMain(argc,argv)); - } + + if (argc > 1 && memicmp(argv[1], "CONFIG", 6) == 0) + { + exit(FDKrnConfigMain(argc, argv)); + } srcPath[0] = '\0'; if (argc > 1 && argv[1][1] == ':' && argv[1][2] == '\0') drivearg = 1; - + if (argc > 2 && argv[2][1] == ':' && argv[2][2] == '\0') { drivearg = 2; - strncpy(srcPath, argv[1], MAXPATH-12); + strncpy(srcPath, argv[1], MAXPATH - 12); /* leave room for COMMAND.COM\0 */ - srcPath[MAXPATH-13] = '\0'; + srcPath[MAXPATH - 13] = '\0'; /* make sure srcPath + "file" is a valid path */ slen = strlen(srcPath); - if ( (srcPath[slen-1] != ':') && - ((srcPath[slen-1] != '\\') || (srcPath[slen-1] != '/')) ) + if ((srcPath[slen - 1] != ':') && + ((srcPath[slen - 1] != '\\') || (srcPath[slen - 1] != '/'))) { srcPath[slen] = '\\'; slen++; @@ -199,48 +194,52 @@ int main(int argc, char **argv) if (drivearg == 0) { printf("Usage: %s [source] drive: [bootsect [BOTH]]\n", pgm); - printf(" source = A:,B:,C:\\KERNEL\\BIN\\,etc., or current directory if not given\n"); + printf + (" source = A:,B:,C:\\KERNEL\\BIN\\,etc., or current directory if not given\n"); printf(" drive = A,B,etc.\n"); - printf(" bootsect = name of 512-byte boot sector file image for drive:\n"); + printf + (" bootsect = name of 512-byte boot sector file image for drive:\n"); printf(" to write to instead of real boot sector\n"); - printf(" BOTH : write to both the real boot sector and the image file\n"); - printf("%s CONFIG /help\n",pgm); + printf + (" BOTH : write to both the real boot sector and the image file\n"); + printf("%s CONFIG /help\n", pgm); exit(1); } drive = toupper(argv[drivearg][0]) - 'A'; if (drive < 0 || drive >= 26) { - printf( "%s: drive %c must be A:..Z:\n", pgm,*argv[(argc == 3 ? 2 : 1)]); + printf("%s: drive %c must be A:..Z:\n", pgm, + *argv[(argc == 3 ? 2 : 1)]); exit(1); } - /* Get source drive */ - if ((strlen(srcPath) > 1) && (srcPath[1] == ':')) /* src specifies drive */ + /* Get source drive */ + if ((strlen(srcPath) > 1) && (srcPath[1] == ':')) /* src specifies drive */ srcDrive = toupper(*srcPath) - 'A'; - else /* src doesn't specify drive, so assume current drive */ - { + else /* src doesn't specify drive, so assume current drive */ + { #ifdef __TURBOC__ srcDrive = getdisk(); -#else +#else _dos_getdrive(&srcDrive); -#endif - } +#endif + } /* Don't try root if src==dst drive or source path given */ - if ( (drive == srcDrive) || (*srcPath && ((srcPath[1] != ':') || ((srcPath[1] == ':') && srcPath[2]))) ) + if ((drive == srcDrive) + || (*srcPath + && ((srcPath[1] != ':') || ((srcPath[1] == ':') && srcPath[2])))) *rootPath = '\0'; else sprintf(rootPath, "%c:\\", 'A' + srcDrive); - if (!check_space(drive, oldboot)) { printf("%s: Not enough space to transfer system files\n", pgm); exit(1); } - printf("\nCopying KERNEL.SYS...\n"); if (!copy(drive, srcPath, rootPath, "kernel.sys")) { @@ -255,13 +254,14 @@ int main(int argc, char **argv) exit(1); } - if (argc > drivearg+1) - bsFile = argv[drivearg+1]; - + if (argc > drivearg + 1) + bsFile = argv[drivearg + 1]; + printf("\nWriting boot sector...\n"); put_boot(drive, bsFile, - (argc > drivearg+2) && memicmp(argv[drivearg+2], "BOTH", 4) == 0); - + (argc > drivearg + 2) + && memicmp(argv[drivearg + 2], "BOTH", 4) == 0); + printf("\nSystem transferred.\n"); return 0; } @@ -269,78 +269,77 @@ int main(int argc, char **argv) #ifdef DDEBUG VOID dump_sector(unsigned char far * sec) { - COUNT x, y; - char c; + COUNT x, y; + char c; - for (x = 0; x < 32; x++) + for (x = 0; x < 32; x++) + { + printf("%03X ", x * 16); + for (y = 0; y < 16; y++) { - printf("%03X ", x * 16); - for (y = 0; y < 16; y++) - { - printf("%02X ", sec[x * 16 + y]); - } - for (y = 0; y < 16; y++) - { - c = oldboot[x * 16 + y]; - if (isprint(c)) - printf( "%c", c); - else - printf( "."); - } - printf( "\n"); - } + printf("%02X ", sec[x * 16 + y]); + } + for (y = 0; y < 16; y++) + { + c = oldboot[x * 16 + y]; + if (isprint(c)) + printf("%c", c); + else + printf("."); + } + printf("\n"); + } - printf( "\n"); + printf("\n"); } #endif - /* TC absRead not functional on MSDOS 6.2, large disks MSDOS requires int25, CX=ffff for drives > 32MB */ -int MyAbsReadWrite(int DosDrive, int count, ULONG sector, void *buffer, unsigned intno) +int MyAbsReadWrite(int DosDrive, int count, ULONG sector, void *buffer, + unsigned intno) { - struct { - unsigned long sectorNumber; - unsigned short count; - void far *address; - } diskReadPacket; - int retval; - union REGS regs; + struct { + unsigned long sectorNumber; + unsigned short count; + void far *address; + } diskReadPacket; + int retval; + union REGS regs; + + diskReadPacket.sectorNumber = sector; + diskReadPacket.count = count; + diskReadPacket.address = buffer; + + regs.h.al = (BYTE) DosDrive; + regs.x.bx = (short)&diskReadPacket; + regs.x.cx = 0xffff; + if (intno != 0x25 && intno != 0x26) + return 0xff; - diskReadPacket.sectorNumber = sector; - diskReadPacket.count = count; - diskReadPacket.address = buffer; + int86(intno, ®s, ®s); - regs.h.al = (BYTE)DosDrive; +#ifdef WITHFAT32 + if (regs.x.cflag) + { + regs.x.ax = 0x7305; + regs.h.dl = DosDrive + 1; regs.x.bx = (short)&diskReadPacket; regs.x.cx = 0xffff; - - if (intno != 0x25 && intno != 0x26) return 0xff; - - int86(intno,®s,®s); - -#ifdef WITHFAT32 - if (regs.x.cflag) - { - regs.x.ax = 0x7305; - regs.h.dl = DosDrive + 1; - regs.x.bx = (short)&diskReadPacket; - regs.x.cx = 0xffff; - regs.x.si = intno - 0x25; - int86(0x21, ®s, ®s); - } + regs.x.si = intno - 0x25; + int86(0x21, ®s, ®s); + } #endif - return regs.x.cflag ? 0xff : 0; -} - + return regs.x.cflag ? 0xff : 0; +} -VOID put_boot(COUNT drive, BYTE *bsFile, BOOL both) +VOID put_boot(COUNT drive, BYTE * bsFile, BOOL both) { COUNT i, z; WORD head, track, sector, ret; @@ -355,25 +354,23 @@ VOID put_boot(COUNT drive, BYTE *bsFile, BOOL both) struct SREGS sregs; char drivename[] = "A:\\"; unsigned char x[0x40]; - #ifdef DEBUG - printf("Reading old bootsector from drive %c:\n",drive+'A'); -#endif + printf("Reading old bootsector from drive %c:\n", drive + 'A'); +#endif - if (MyAbsReadWrite(drive, 1, 0, oldboot,0x25) != 0) - { - printf("can't read old boot sector for drive %c:\n", drive +'A'); + if (MyAbsReadWrite(drive, 1, 0, oldboot, 0x25) != 0) + { + printf("can't read old boot sector for drive %c:\n", drive + 'A'); exit(1); - } - + } #ifdef DDEBUG printf("Old Boot Sector:\n"); dump_sector(oldboot); #endif - bs = (struct bootsectortype *) & oldboot; + bs = (struct bootsectortype *)&oldboot; if ((bs->bsFileSysType[4] == '6') && (bs->bsBootSignature == 0x29)) { fs = 16; @@ -388,78 +385,81 @@ VOID put_boot(COUNT drive, BYTE *bsFile, BOOL both) FS detection method to GetFreeDiskSpace(). this should work, as the disk was writeable, so GetFreeDiskSpace should work. */ - - regs.h.ah = 0x36; /* get drive free space */ - regs.h.dl = drive+1; /* 1 = 'A',... */ - int86(0x21,®s,®s); - - if (regs.x.ax == 0xffff) - { - printf("can't get free disk space for %c:\n", drive+'A'); - exit(1); - } - - if (regs.x.dx <= 0xff6) - { - if (fs != 12) printf("warning : new detection overrides old detection\a\n"); - fs = 12; - } - else { - - if (fs != 16) printf("warning : new detection overrides old detection\a\n"); - fs = 16; - - /* fs = 16/32. - we don't want to crash a FAT32 drive - */ - - segread(&sregs); - sregs.es = sregs.ds; - - regs.x.ax = 0x7303; /* get extended drive free space */ - - drivename[0] = 'A' + drive; - regs.x.dx = (unsigned)&drivename; - regs.x.di = (unsigned)&x; - regs.x.cx = sizeof(x); - - int86x(0x21,®s,®s,&sregs); - - if (regs.x.cflag) /* error --> no Win98 --> no FAT32 */ - { - printf("get extended drive space not supported --> no FAT32\n"); - } - else { - if (*(unsigned long *)(x+0x2c) /* total number of clusters */ - > (unsigned)65526l) - { - fs = 32; - } - } - } - - - if (fs == 16) - { - memcpy(newboot, b_fat16, SEC_SIZE); /* copy FAT16 boot sector */ - printf("FAT type: FAT16\n"); - } - else if (fs == 12) - { - memcpy(newboot, b_fat12, SEC_SIZE); /* copy FAT12 boot sector */ - printf("FAT type: FAT12\n"); - } + + regs.h.ah = 0x36; /* get drive free space */ + regs.h.dl = drive + 1; /* 1 = 'A',... */ + int86(0x21, ®s, ®s); + + if (regs.x.ax == 0xffff) + { + printf("can't get free disk space for %c:\n", drive + 'A'); + exit(1); + } + + if (regs.x.dx <= 0xff6) + { + if (fs != 12) + printf("warning : new detection overrides old detection\a\n"); + fs = 12; + } + else + { + + if (fs != 16) + printf("warning : new detection overrides old detection\a\n"); + fs = 16; + + /* fs = 16/32. + we don't want to crash a FAT32 drive + */ + + segread(&sregs); + sregs.es = sregs.ds; + + regs.x.ax = 0x7303; /* get extended drive free space */ + + drivename[0] = 'A' + drive; + regs.x.dx = (unsigned)&drivename; + regs.x.di = (unsigned)&x; + regs.x.cx = sizeof(x); + + int86x(0x21, ®s, ®s, &sregs); + + if (regs.x.cflag) /* error --> no Win98 --> no FAT32 */ + { + printf("get extended drive space not supported --> no FAT32\n"); + } else - { - printf("FAT type: FAT32\n"); + { + if (*(unsigned long *)(x + 0x2c) /* total number of clusters */ + > (unsigned)65526l) + { + fs = 32; + } + } + } + + if (fs == 16) + { + memcpy(newboot, b_fat16, SEC_SIZE); /* copy FAT16 boot sector */ + printf("FAT type: FAT16\n"); + } + else if (fs == 12) + { + memcpy(newboot, b_fat12, SEC_SIZE); /* copy FAT12 boot sector */ + printf("FAT type: FAT12\n"); + } + else + { + printf("FAT type: FAT32\n"); #ifdef WITHFAT32 - memcpy(newboot, b_fat32, SEC_SIZE); /* copy FAT32 boot sector */ + memcpy(newboot, b_fat32, SEC_SIZE); /* copy FAT32 boot sector */ #else - printf("SYS hasn't been compiled with FAT32 support."); - printf("Consider using -DWITHFAT32 option.\n"); - exit(1); + printf("SYS hasn't been compiled with FAT32 support."); + printf("Consider using -DWITHFAT32 option.\n"); + exit(1); #endif - } + } /* Copy disk parameter from old sector to new sector */ #ifdef WITHFAT32 @@ -469,31 +469,32 @@ VOID put_boot(COUNT drive, BYTE *bsFile, BOOL both) #endif memcpy(&newboot[SBOFFSET], &oldboot[SBOFFSET], SBSIZE); - bs = (struct bootsectortype *) & newboot; - - memcpy(bs->OemName, "FreeDOS ",8); + bs = (struct bootsectortype *)&newboot; + + memcpy(bs->OemName, "FreeDOS ", 8); #ifdef WITHFAT32 if (fs == 32) - { - bs32 = (struct bootsectortype32 *) & newboot; - - temp = bs32->bsHiddenSecs + bs32->bsResSectors; - bs32->sysFatStart = temp; - - bs32->sysDataStart = temp + bs32->bsBigFatSize * bs32->bsFATs; - bs32->sysFatSecMask = bs32->bsBytesPerSec / 4 - 1; - - temp = bs32->sysFatSecMask + 1; - for (bs32->sysFatSecShift = 0; temp != 1; bs32->sysFatSecShift++, temp >>= 1); - } + { + bs32 = (struct bootsectortype32 *)&newboot; + + temp = bs32->bsHiddenSecs + bs32->bsResSectors; + bs32->sysFatStart = temp; + + bs32->sysDataStart = temp + bs32->bsBigFatSize * bs32->bsFATs; + bs32->sysFatSecMask = bs32->bsBytesPerSec / 4 - 1; + + temp = bs32->sysFatSecMask + 1; + for (bs32->sysFatSecShift = 0; temp != 1; + bs32->sysFatSecShift++, temp >>= 1) ; + } #ifdef DEBUG if (fs == 32) - { - printf( "FAT starts at sector %lx = (%lx + %x)\n", bs32->sysFatStart, - bs32->bsHiddenSecs, bs32->bsResSectors); - printf("DATA starts at sector %lx\n", bs32->sysDataStart); - } + { + printf("FAT starts at sector %lx = (%lx + %x)\n", bs32->sysFatStart, + bs32->bsHiddenSecs, bs32->bsResSectors); + printf("DATA starts at sector %lx\n", bs32->sysDataStart); + } #endif else #endif @@ -502,39 +503,39 @@ VOID put_boot(COUNT drive, BYTE *bsFile, BOOL both) /* TE thinks : never, see above */ /* temporary HACK for the load segment (0x0060): it is in unused */ /* only needed for older kernels */ - *((UWORD *)(bs->unused)) = *((UWORD *)(((struct bootsectortype *)&b_fat16)->unused)); + *((UWORD *) (bs->unused)) = + *((UWORD *) (((struct bootsectortype *)&b_fat16)->unused)); /* end of HACK */ - /* root directory sectors */ + /* root directory sectors */ bs->sysRootDirSecs = bs->bsRootDirEnts / 16; - /* sector FAT starts on */ + /* sector FAT starts on */ temp = bs->bsHiddenSecs + bs->bsResSectors; bs->sysFatStart = temp; - - /* sector root directory starts on */ + + /* sector root directory starts on */ temp = temp + bs->bsFATsecs * bs->bsFATs; bs->sysRootDirStart = temp; - - /* sector data starts on */ + + /* sector data starts on */ temp = temp + bs->sysRootDirSecs; bs->sysDataStart = temp; } - + #ifdef DEBUG printf("Root dir entries = %u\n", bs->bsRootDirEnts); printf("Root dir sectors = %u\n", bs->sysRootDirSecs); - printf( "FAT starts at sector %lu = (%lu + %u)\n", bs->sysFatStart, - bs->bsHiddenSecs, bs->bsResSectors); + printf("FAT starts at sector %lu = (%lu + %u)\n", bs->sysFatStart, + bs->bsHiddenSecs, bs->bsResSectors); printf("Root directory starts at sector %lu = (PREVIOUS + %u * %u)\n", - bs->sysRootDirStart, bs->bsFATsecs, bs->bsFATs); + bs->sysRootDirStart, bs->bsFATsecs, bs->bsFATs); printf("DATA starts at sector %lu = (PREVIOUS + %u)\n", bs->sysDataStart, - bs->sysRootDirSecs); + bs->sysRootDirSecs); #endif #endif - #ifdef DDEBUG printf("\nNew Boot Sector:\n"); dump_sector(newboot); @@ -542,30 +543,32 @@ VOID put_boot(COUNT drive, BYTE *bsFile, BOOL both) if ((bsFile == NULL) || both) { - + #ifdef DEBUG - printf("writing new bootsector to drive %c:\n",drive+'A'); -#endif + printf("writing new bootsector to drive %c:\n", drive + 'A'); +#endif - if (MyAbsReadWrite(drive, 1, 0, newboot,0x26) != 0) + if (MyAbsReadWrite(drive, 1, 0, newboot, 0x26) != 0) { - printf("Can't write new boot sector to drive %c:\n", drive +'A'); + printf("Can't write new boot sector to drive %c:\n", drive + 'A'); exit(1); } } - + if (bsFile != NULL) { int fd; - + #ifdef DEBUG printf("writing new bootsector to file %s\n", bsFile); -#endif +#endif /* write newboot to bsFile */ - if ((fd = open(bsFile, O_RDWR | O_TRUNC | O_CREAT | O_BINARY,S_IREAD|S_IWRITE)) < 0) + if ((fd = + open(bsFile, O_RDWR | O_TRUNC | O_CREAT | O_BINARY, + S_IREAD | S_IWRITE)) < 0) { - printf( " %s: can't create\"%s\"\nDOS errnum %d", pgm, bsFile, errno); + printf(" %s: can't create\"%s\"\nDOS errnum %d", pgm, bsFile, errno); exit(1); } if (write(fd, newboot, SEC_SIZE) != SEC_SIZE) @@ -579,15 +582,13 @@ VOID put_boot(COUNT drive, BYTE *bsFile, BOOL both) } } - BOOL check_space(COUNT drive, BYTE * BlkBuffer) { - /* this should check, if on destination is enough space - to hold command.com+ kernel.sys */ - - UNREFERENCED_PARAMETER(drive); - UNREFERENCED_PARAMETER(BlkBuffer); - + /* this should check, if on destination is enough space + to hold command.com+ kernel.sys */ + + UNREFERENCED_PARAMETER(drive); + UNREFERENCED_PARAMETER(BlkBuffer); return TRUE; } @@ -602,13 +603,13 @@ BOOL copy(COUNT drive, BYTE * srcPath, BYTE * rootPath, BYTE * file) int fdin, fdout; ULONG copied = 0; struct stat fstatbuf; - + sprintf(dest, "%c:\\%s", 'A' + drive, file); sprintf(source, "%s%s", srcPath, file); if (stat(source, &fstatbuf)) { - printf( "%s: \"%s\" not found\n", pgm, source); + printf("%s: \"%s\" not found\n", pgm, source); if ((rootPath != NULL) && (*rootPath) /* && (errno == ENOENT) */ ) { @@ -616,38 +617,40 @@ BOOL copy(COUNT drive, BYTE * srcPath, BYTE * rootPath, BYTE * file) printf("%s: Trying \"%s\"\n", pgm, source); if (stat(source, &fstatbuf)) { - printf( "%s: \"%s\" not found\n", pgm, source); + printf("%s: \"%s\" not found\n", pgm, source); return FALSE; } } else return FALSE; } - - if ((fdin = open(source, O_RDONLY|O_BINARY)) < 0) + + if ((fdin = open(source, O_RDONLY | O_BINARY)) < 0) { - printf( "%s: failed to open \"%s\"\n", pgm, source); + printf("%s: failed to open \"%s\"\n", pgm, source); return FALSE; } - if ((fdout = open(dest, O_RDWR | O_TRUNC | O_CREAT | O_BINARY,S_IREAD|S_IWRITE)) < 0) + if ((fdout = + open(dest, O_RDWR | O_TRUNC | O_CREAT | O_BINARY, + S_IREAD | S_IWRITE)) < 0) { - printf( " %s: can't create\"%s\"\nDOS errnum %d", pgm, dest, errno); + printf(" %s: can't create\"%s\"\nDOS errnum %d", pgm, dest, errno); close(fdin); return FALSE; } - while ((ret = read(fdin, copybuffer,COPY_SIZE)) > 0) + while ((ret = read(fdin, copybuffer, COPY_SIZE)) > 0) + { + if (write(fdout, copybuffer, ret) != ret) { - if (write(fdout, copybuffer, ret) != ret) - { - printf("Can't write %u bytes to %s\n", ret, dest); - close(fdout); - unlink(dest); - break; - } - copied += ret; - } + printf("Can't write %u bytes to %s\n", ret, dest); + close(fdout); + unlink(dest); + break; + } + copied += ret; + } #ifdef __TURBOC__ { @@ -655,24 +658,23 @@ BOOL copy(COUNT drive, BYTE * srcPath, BYTE * rootPath, BYTE * file) getftime(fdin, &ftime); setftime(fdout, &ftime); } -#endif +#endif close(fdin); close(fdout); - + #ifdef _MSV_VER { - #include - struct utimbuf utimb; +#include + struct utimbuf utimb; - utimb.actime = /* access time */ - utimb.modtime = fstatbuf.st_mtime; /* modification time */ - utime(dest,&utimb); + utimb.actime = /* access time */ + utimb.modtime = fstatbuf.st_mtime; /* modification time */ + utime(dest, &utimb); }; #endif - printf("%lu Bytes transferred", copied); return TRUE; @@ -755,4 +757,3 @@ BOOL copy(COUNT drive, BYTE * srcPath, BYTE * rootPath, BYTE * file) * it create a .COM file. * */ - diff --git a/utils/patchobj.c b/utils/patchobj.c index 478f5718..92eeee8b 100644 --- a/utils/patchobj.c +++ b/utils/patchobj.c @@ -16,200 +16,188 @@ #include #include -#ifndef TRUE - #define TRUE (1==1) - #define FALSE (0==1) -#endif - +#ifndef TRUE +#define TRUE (1==1) +#define FALSE (0==1) +#endif struct { - char *sin,*sout; - } repl[100]; + char *sin, *sout; +} repl[100]; int repl_count; - -void quit(char *s,...) +void quit(char *s, ...) { - vprintf(s,(void*)((char *)&s+sizeof(s))); - exit(1); + vprintf(s, (void *)((char *)&s + sizeof(s))); + exit(1); } void define_replace(char *sin) { - char *s; - - if (repl_count >= 99) - quit("too many replacements"); - - if ((s = strchr(sin, '=')) == NULL) - quit("illegal replacement <%s>, missing '='", sin); - - *s = 0; - repl[repl_count].sin = sin; - repl[repl_count].sout = s+1; - - repl_count++; + char *s; + + if (repl_count >= 99) + quit("too many replacements"); + + if ((s = strchr(sin, '=')) == NULL) + quit("illegal replacement <%s>, missing '='", sin); + + *s = 0; + repl[repl_count].sin = sin; + repl[repl_count].sout = s + 1; + + repl_count++; } int main(int argc, char *argv[]) { - char *argptr; - int argloop; - int cont; - int file = 0; - FILE *fd,*fdo; - char *inname=0,*outname= "~patchob.tmp"; - - int use_temp_file = TRUE; - - argc--,argv++; - - for (; argc != 0; argc--,argv++) - { - argptr = *argv; - - if (*argptr != '-' && *argptr != '-') - { - if (inname == 0) { inname = argptr; continue;} - define_replace(argptr); - continue; - } - switch (toupper(argptr[1])) - { - case 'O': - outname = argptr+2; - use_temp_file = FALSE; - break; - default: - quit("illegal argument <%s>\n",argptr); - break; - } - } - - - - if (inname == 0) - quit("Inputfile must be specified\n"); - - if (repl_count == 0) - quit("no replacements defined"); - - - if ((fd = fopen(inname,"rb")) == NULL) /* open for READ/WRITE */ - quit("can't read %s\n",inname); - - if ((fdo = fopen(outname,"wb")) == NULL) /* open for READ/WRITE */ - quit("can't write %s\n",outname); - - go_records(fd,fdo); - - fclose(fd); - fclose(fdo); - if (use_temp_file) - { - unlink(inname); - rename(outname,inname); - } - - return 0; + char *argptr; + int argloop; + int cont; + int file = 0; + FILE *fd, *fdo; + char *inname = 0, *outname = "~patchob.tmp"; + + int use_temp_file = TRUE; + + argc--, argv++; + + for (; argc != 0; argc--, argv++) + { + argptr = *argv; + + if (*argptr != '-' && *argptr != '-') + { + if (inname == 0) + { + inname = argptr; + continue; + } + define_replace(argptr); + continue; + } + switch (toupper(argptr[1])) + { + case 'O': + outname = argptr + 2; + use_temp_file = FALSE; + break; + default: + quit("illegal argument <%s>\n", argptr); + break; + } + } + + if (inname == 0) + quit("Inputfile must be specified\n"); + + if (repl_count == 0) + quit("no replacements defined"); + + if ((fd = fopen(inname, "rb")) == NULL) /* open for READ/WRITE */ + quit("can't read %s\n", inname); + + if ((fdo = fopen(outname, "wb")) == NULL) /* open for READ/WRITE */ + quit("can't write %s\n", outname); + + go_records(fd, fdo); + + fclose(fd); + fclose(fdo); + if (use_temp_file) + { + unlink(inname); + rename(outname, inname); + } + + return 0; } usage() { - fputs( - "DELSYM V1.0 5'95by tom ehlert, SIG Aachen\n" - " delete symbolic info in object files\n" - "usage:\n" - " DELSYM infile [outfile]\n" - ,stderr); - exit(1); + fputs("DELSYM V1.0 5'95by tom ehlert, SIG Aachen\n" + " delete symbolic info in object files\n" + "usage:\n" " DELSYM infile [outfile]\n", stderr); + exit(1); } -struct record - { - unsigned char rectyp; - unsigned datalen; - unsigned char buffer[0x2000]; - } Record,Outrecord; - - -go_records(FILE *fdin,FILE *fdo) -{ - unsigned char stringlen; - unsigned char *string,*s; - int i,j; - unsigned char chksum; - -do { - if (fread(&Record,1,3,fdin) != 3) { /* read type and reclen*/ - /* printf("end of fdin read\n"); */ - break; - } - if (Record.datalen > sizeof(Record.buffer)) - quit ("record to large : length %u Bytes \n",Record.datalen); - - if (fread(Record.buffer,1,Record.datalen,fdin) != Record.datalen) - { - printf("invalid record format\n"); - quit ("can't continue\n"); - } - - - - if (Record.rectyp != 0x96) /* we are only interested in LNAMES */ - { - fwrite(&Record,1,3+Record.datalen,fdo); - continue; - } - - Outrecord.rectyp = 0x96; - Outrecord.datalen= 0; - - - - - - - for (i = 0; i < Record.datalen-1; ) - { - stringlen = Record.buffer[i]; - i++; - - string = &Record.buffer[i]; - i += stringlen; - - - if (i > Record.datalen) - quit("invalid lnames record"); - - - for (j = 0; j < repl_count; j++) - if (memcmp(string,repl[j].sin,stringlen) == 0 - && strlen(repl[j].sin) == stringlen) - { - string = repl[j].sout; - stringlen = strlen(repl[j].sout); - } - Outrecord.buffer[Outrecord.datalen] = stringlen; - Outrecord.datalen++; - memcpy(Outrecord.buffer+Outrecord.datalen,string,stringlen); - Outrecord.datalen += stringlen; - } - - chksum = 0; - for (s = (unsigned char *)&Outrecord; s < &Outrecord.buffer[Outrecord.datalen]; s++) - chksum += *s; - - Outrecord.buffer[Outrecord.datalen] = ~chksum; - Outrecord.datalen++; - - /* printf("^sum = %02x - %02x\n",chksum,~chksum); */ - - - fwrite(&Outrecord,1,3+Outrecord.datalen,fdo); - - } while (Record.rectyp != 0x00 /*ENDFIL*/); - -printf("\n"); +struct record { + unsigned char rectyp; + unsigned datalen; + unsigned char buffer[0x2000]; +} Record, Outrecord; + +go_records(FILE * fdin, FILE * fdo) +{ + unsigned char stringlen; + unsigned char *string, *s; + int i, j; + unsigned char chksum; + + do + { + if (fread(&Record, 1, 3, fdin) != 3) + { /* read type and reclen */ + /* printf("end of fdin read\n"); */ + break; + } + if (Record.datalen > sizeof(Record.buffer)) + quit("record to large : length %u Bytes \n", Record.datalen); + + if (fread(Record.buffer, 1, Record.datalen, fdin) != Record.datalen) + { + printf("invalid record format\n"); + quit("can't continue\n"); + } + + if (Record.rectyp != 0x96) /* we are only interested in LNAMES */ + { + fwrite(&Record, 1, 3 + Record.datalen, fdo); + continue; + } + + Outrecord.rectyp = 0x96; + Outrecord.datalen = 0; + + for (i = 0; i < Record.datalen - 1;) + { + stringlen = Record.buffer[i]; + i++; + + string = &Record.buffer[i]; + i += stringlen; + + if (i > Record.datalen) + quit("invalid lnames record"); + + for (j = 0; j < repl_count; j++) + if (memcmp(string, repl[j].sin, stringlen) == 0 + && strlen(repl[j].sin) == stringlen) + { + string = repl[j].sout; + stringlen = strlen(repl[j].sout); + } + Outrecord.buffer[Outrecord.datalen] = stringlen; + Outrecord.datalen++; + memcpy(Outrecord.buffer + Outrecord.datalen, string, stringlen); + Outrecord.datalen += stringlen; + } + + chksum = 0; + for (s = (unsigned char *)&Outrecord; + s < &Outrecord.buffer[Outrecord.datalen]; s++) + chksum += *s; + + Outrecord.buffer[Outrecord.datalen] = ~chksum; + Outrecord.datalen++; + + /* printf("^sum = %02x - %02x\n",chksum,~chksum); */ + + fwrite(&Outrecord, 1, 3 + Outrecord.datalen, fdo); + + } + while (Record.rectyp != 0x00 /*ENDFIL*/); + + printf("\n"); } diff --git a/utils/relocinf.c b/utils/relocinf.c index 1de577ef..89d778f0 100644 --- a/utils/relocinf.c +++ b/utils/relocinf.c @@ -18,23 +18,19 @@ ** *****************************************************************************/ - -*/ - +* / #include #include #include - typedef unsigned short UWORD; -typedef unsigned long ULONG; +typedef unsigned long ULONG; #ifndef _MSC_VER - #define const - #define __cdecl cdecl +#define const +#define __cdecl cdecl #endif /* from EXE.H */ -typedef struct -{ +typedef struct { UWORD exSignature; UWORD exExtraBytes; UWORD exPages; @@ -49,115 +45,118 @@ typedef struct UWORD exInitCS; UWORD exRelocTable; UWORD exOverlay; -} -exe_header; +} exe_header; #define MAGIC 0x5a4d -struct relocEntry{ - UWORD off; - UWORD seg; - UWORD refseg; - }; +struct relocEntry { + UWORD off; + UWORD seg; + UWORD refseg; +}; int __cdecl compReloc(const void *p1, const void *p2) - { - struct relocEntry *r1 = (struct relocEntry*)p1; - struct relocEntry *r2 = (struct relocEntry*)p2; - - if (r1->refseg > r2->refseg) return 1; - if (r1->refseg < r2->refseg) return -1; - - if (r1->seg > r2->seg) return 1; - if (r1->seg < r2->seg) return -1; +{ + struct relocEntry *r1 = (struct relocEntry *)p1; + struct relocEntry *r2 = (struct relocEntry *)p2; - if (r1->off > r2->off) return 1; - if (r1->off < r2->off) return -1; + if (r1->refseg > r2->refseg) + return 1; + if (r1->refseg < r2->refseg) + return -1; - return 0; - } + if (r1->seg > r2->seg) + return 1; + if (r1->seg < r2->seg) + return -1; + if (r1->off > r2->off) + return 1; + if (r1->off < r2->off) + return -1; + return 0; +} -main(int argc,char *argv[]) +main(int argc, char *argv[]) { - FILE *fdin; - exe_header header; - struct relocEntry *reloc; - - int i; - ULONG image_offset; - - - if (argc < 2 || (fdin = fopen(argv[1],"rb")) == NULL) - { - printf("can't open %s\n",argv[1]); - exit(1); - } - - if (fread(&header, sizeof(header),1,fdin) != 1 || - header.exSignature != MAGIC) - { - printf("%s is no EXE file\n"); - exit(1); - } - - printf("%u relocation entries found\n", header.exRelocItems); - - if (header.exRelocItems > 0x8000/sizeof(*reloc)) - { - printf("too many relocation entries \n"); - exit(1); - } - - if ((reloc = malloc(header.exRelocItems*sizeof(*reloc))) == NULL) - { - printf("can't alloc memory\n"); - exit(1); - } - - if (fseek(fdin, header.exRelocTable, 0)) - { - printf("can't seek\n"); - exit(1); - } - - for (i = 0; i < header.exRelocItems; i++) - if (fread(reloc+i, 4,1,fdin) != 1) - { - printf("can't read reloc info\n"); - exit(1); - } - - for (i = 0; i < header.exRelocItems; i++) - { - image_offset = (ULONG)header.exHeaderSize * 16; - - image_offset += ((ULONG)reloc[i].seg << 4) + reloc[i].off; - - if (fseek(fdin, image_offset, 0)) - { - printf("can't seek reloc data\n"); - exit(1); - } - - if (fread(&reloc[i].refseg, 2,1,fdin) != 1) - { - printf("can't read rel data for item %d\n",i); - exit(1); - } - /* printf("%04x:%04x -> %04x\n", reloc[i].seg, reloc[i].off, reloc[i].refseg); */ - } - - /* sort reloc entries */ - - qsort(reloc, header.exRelocItems, sizeof(*reloc), compReloc); - - for (i = 0; i < header.exRelocItems; i++) - { - if (i == 0) - printf("# seg:off references data in -->\n"); - printf("%3d %04x:%04x -> %04x\n", i,reloc[i].seg, reloc[i].off, reloc[i].refseg); - } - -} \ No newline at end of file + FILE *fdin; + exe_header header; + struct relocEntry *reloc; + + int i; + ULONG image_offset; + + if (argc < 2 || (fdin = fopen(argv[1], "rb")) == NULL) + { + printf("can't open %s\n", argv[1]); + exit(1); + } + + if (fread(&header, sizeof(header), 1, fdin) != 1 || + header.exSignature != MAGIC) + { + printf("%s is no EXE file\n"); + exit(1); + } + + printf("%u relocation entries found\n", header.exRelocItems); + + if (header.exRelocItems > 0x8000 / sizeof(*reloc)) + { + printf("too many relocation entries \n"); + exit(1); + } + + if ((reloc = malloc(header.exRelocItems * sizeof(*reloc))) == NULL) + { + printf("can't alloc memory\n"); + exit(1); + } + + if (fseek(fdin, header.exRelocTable, 0)) + { + printf("can't seek\n"); + exit(1); + } + + for (i = 0; i < header.exRelocItems; i++) + if (fread(reloc + i, 4, 1, fdin) != 1) + { + printf("can't read reloc info\n"); + exit(1); + } + + for (i = 0; i < header.exRelocItems; i++) + { + image_offset = (ULONG) header.exHeaderSize * 16; + + image_offset += ((ULONG) reloc[i].seg << 4) + reloc[i].off; + + if (fseek(fdin, image_offset, 0)) + { + printf("can't seek reloc data\n"); + exit(1); + } + + if (fread(&reloc[i].refseg, 2, 1, fdin) != 1) + { + printf("can't read rel data for item %d\n", i); + exit(1); + } + /* printf("%04x:%04x -> %04x\n", reloc[i].seg, reloc[i].off, reloc[i].refseg); */ + } + + /* sort reloc entries */ + + qsort(reloc, header.exRelocItems, sizeof(*reloc), compReloc); + + for (i = 0; i < header.exRelocItems; i++) + { + if (i == 0) + printf("# seg:off references data in -->\n"); + printf("%3d %04x:%04x -> %04x\n", i, reloc[i].seg, reloc[i].off, + reloc[i].refseg); + } + +} From 5e568fa679364e0b29bc055b316497669bf0305c Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sun, 18 Nov 2001 14:13:51 +0000 Subject: [PATCH 112/671] Updated history, (re)moved some doc files git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@330 6ac86273-5f31-0410-b378-82cca8765d1b --- bin/copying | 339 ----------------------------------------------- bin/mkboot.txt | 11 -- docs/contrib.txt | 3 + docs/history.txt | 6 + fdkernel.lsm | 2 +- hdr/version.h | 6 +- readme.txt | 25 ---- 7 files changed, 13 insertions(+), 379 deletions(-) delete mode 100644 bin/copying delete mode 100644 bin/mkboot.txt delete mode 100644 readme.txt diff --git a/bin/copying b/bin/copying deleted file mode 100644 index a43ea212..00000000 --- a/bin/copying +++ /dev/null @@ -1,339 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 - - Copyright (C) 1989, 1991 Free Software Foundation, Inc. - 675 Mass Ave, Cambridge, MA 02139, USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software--to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Library General Public License instead.) You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -this service if you wish), that you receive source code or can get it -if you want it, that you can change the software or use pieces of it -in new free programs; and that you know you can do these things. - - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must show them these terms so they know their -rights. - - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. - - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. - - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. - - The precise terms and conditions for copying, distribution and -modification follow. - - GNU GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The "Program", below, -refers to any such program or work, and a "work based on the Program" -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term "modification".) Each licensee is addressed as "you". - -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. - - 1. You may copy and distribute verbatim copies of the Program's -source code as you receive it, in any medium, provided that you -conspicuously and appropriately publish on each copy an appropriate -copyright notice and disclaimer of warranty; keep intact all the -notices that refer to this License and to the absence of any warranty; -and give any other recipients of the Program a copy of this License -along with the Program. - -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a fee. - - 2. You may modify your copy or copies of the Program or any portion -of it, thus forming a work based on the Program, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) You must cause the modified files to carry prominent notices - stating that you changed the files and the date of any change. - - b) You must cause any work that you distribute or publish, that in - whole or in part contains or is derived from the Program or any - part thereof, to be licensed as a whole at no charge to all third - parties under the terms of this License. - - c) If the modified program normally reads commands interactively - when run, you must cause it, when started running for such - interactive use in the most ordinary way, to print or display an - announcement including an appropriate copyright notice and a - notice that there is no warranty (or else, saying that you provide - a warranty) and that users may redistribute the program under - these conditions, and telling the user how to view a copy of this - License. (Exception: if the Program itself is interactive but - does not normally print such an announcement, your work based on - the Program is not required to print an announcement.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Program, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Program. - -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: - - a) Accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of Sections - 1 and 2 above on a medium customarily used for software interchange; or, - - b) Accompany it with a written offer, valid for at least three - years, to give any third party, for a charge no more than your - cost of physically performing source distribution, a complete - machine-readable copy of the corresponding source code, to be - distributed under the terms of Sections 1 and 2 above on a medium - customarily used for software interchange; or, - - c) Accompany it with the information you received as to the offer - to distribute corresponding source code. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form with such - an offer, in accord with Subsection b above.) - -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, complete source -code means all the source code for all modules it contains, plus any -associated interface definition files, plus the scripts used to -control compilation and installation of the executable. However, as a -special exception, the source code distributed need not include -anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component -itself accompanies the executable. - -If distribution of executable or object code is made by offering -access to copy from a designated place, then offering equivalent -access to copy the source code from the same place counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. - - 4. You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program is -void, and will automatically terminate your rights under this License. -However, parties who have received copies, or rights, from you under -this License will not have their licenses terminated so long as such -parties remain in full compliance. - - 5. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. - - 6. Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program subject to -these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to -this License. - - 7. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system, which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 8. If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program under this License -may add an explicit geographical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - - 9. The Free Software Foundation may publish revised and/or new versions -of the General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - -Each version is given a distinguishing version number. If the Program -specifies a version number of this License which applies to it and "any -later version", you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. - - 10. If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. - - NO WARRANTY - - 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. - - 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING -OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED -TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY -YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER -PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGES. - - END OF TERMS AND CONDITIONS - - Appendix: How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) 19yy - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - -Also add information on how to contact you by electronic and paper mail. - -If the program is interactive, make it output a short notice like this -when it starts in an interactive mode: - - Gnomovision version 69, Copyright (C) 19yy name of author - Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, the commands you use may -be called something other than `show w' and `show c'; they could even be -mouse-clicks or menu items--whatever suits your program. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the program, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the program - `Gnomovision' (which makes passes at compilers) written by James Hacker. - - , 1 April 1989 - Ty Coon, President of Vice - -This General Public License does not permit incorporating your program into -proprietary programs. If your program is a subroutine library, you may -consider it more useful to permit linking proprietary applications with the -library. If this is what you want to do, use the GNU Library General -Public License instead of this License. diff --git a/bin/mkboot.txt b/bin/mkboot.txt deleted file mode 100644 index 73be5d66..00000000 --- a/bin/mkboot.txt +++ /dev/null @@ -1,11 +0,0 @@ -To create a bootable floppy suitable for copying the system to -another drive: - -1. Change directory (if necessary) to where the FreeDOS Kernel BIN -directory. - -3. Enter the command "install" to transfer the system files to the -diskette in drive A. If you want to install on drive B, type -"install b:" - -4. Write protect this disk and use it to boot from. diff --git a/docs/contrib.txt b/docs/contrib.txt index 7244a993..42ac8445 100644 --- a/docs/contrib.txt +++ b/docs/contrib.txt @@ -12,6 +12,9 @@ Steve Miller (SMiller@dsfx.com) Jens Horstmeier (Jens.Horstmeier@Abg1.SIEMENS.DE) James Tabor (jimtabor@infohwy.com) Eric Biederman (ebiederm+eric@ccr.net) +Tom Ehlert (tom.ehlert@ginko.de) +Victor Vlasenko (victor_vlasenko@hotbox.ru) +Bart Oldeman (bart@dosemu.org) And last, but not least, a big thanx to Pasquale J. Villani (patv@iop.com), who was the original author of DOS-C, in which the diff --git a/docs/history.txt b/docs/history.txt index 7d0d4ba7..07608984 100644 --- a/docs/history.txt +++ b/docs/history.txt @@ -1,3 +1,9 @@ +2001 Nov 18 - Build 2025c +-------- Bart Oldeman (bart@dosemu.org) ++ Changes Bart + * ran source code .c and .h files through "indent" + * fixed new printf bug + * removed some duplicate documents 2001 Nov 17 - Build 2025b -------- Bart Oldeman (bart@dosemu.org) + Changes Tom diff --git a/fdkernel.lsm b/fdkernel.lsm index 3492e897..80dae646 100644 --- a/fdkernel.lsm +++ b/fdkernel.lsm @@ -1,6 +1,6 @@ Begin3 Title: The FreeDOS Kernel -Version: 2.0.25.b +Version: 2.0.25.c Entered-date: 17 Nov 2001 Description: The FreeDOS Kernel. Keywords: kernel freedos dos msdos diff --git a/hdr/version.h b/hdr/version.h index f98d5423..5ebc1fea 100644 --- a/hdr/version.h +++ b/hdr/version.h @@ -45,6 +45,6 @@ static BYTE *date_hRcsId = #define REVISION_MINOR 1 #define REVISION_SEQ 25 #define BUILD "2025" -#define SUB_BUILD "b" -#define KERNEL_VERSION_STRING "1.1.25b" /*#REVISION_MAJOR "." #REVISION_MINOR "." #REVISION_SEQ */ -#define KERNEL_BUILD_STRING "2025b" /*#BUILD SUB_BUILD */ +#define SUB_BUILD "c" +#define KERNEL_VERSION_STRING "1.1.25c" /*#REVISION_MAJOR "." #REVISION_MINOR "." #REVISION_SEQ */ +#define KERNEL_BUILD_STRING "2025c" /*#BUILD SUB_BUILD */ diff --git a/readme.txt b/readme.txt deleted file mode 100644 index 3d52068c..00000000 --- a/readme.txt +++ /dev/null @@ -1,25 +0,0 @@ -INTRODUCTION ------------- -This archive contains the current FreeDOS Kernel, also -known as DOS-C, originally written by Pasquale J. Villani. - -The FreeDOS Kernel is available from http://freedos.sourceforge.net. -It's also available from http://www.dosemu.org (somewhere on there). - -The FreeDOS Kernel is also available through the FreeDOS Project at -http://www.freedos.org. - -See the DOCS directory for more documentation and information about -the FreeDOS Kernel. - - -BUG REPORTS ------------ -If you have found a bug, think you have found a bug, or would just -like to make a suggestion, go to the bug tracking web page at -http://www.freedos.org/bugs/ - -Copyright ---------- -DOS-C is (c) Copyright 1995, 1996 by Pasquale J. Villani -All Rights Reserved. From 9696fd8bfba8440aaa13a73ca3ca4443f75047ee Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sun, 18 Nov 2001 14:18:09 +0000 Subject: [PATCH 113/671] Moved some more files. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@331 6ac86273-5f31-0410-b378-82cca8765d1b --- fdkernel.lsm => docs/fdkernel.lsm | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename fdkernel.lsm => docs/fdkernel.lsm (100%) diff --git a/fdkernel.lsm b/docs/fdkernel.lsm similarity index 100% rename from fdkernel.lsm rename to docs/fdkernel.lsm From a628dadd6dc0d6c90b58a7e350f0f86e284a0db4 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sun, 18 Nov 2001 14:19:30 +0000 Subject: [PATCH 114/671] Moved readme.txt to docs/ git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@332 6ac86273-5f31-0410-b378-82cca8765d1b --- docs/readme.txt | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 docs/readme.txt diff --git a/docs/readme.txt b/docs/readme.txt new file mode 100644 index 00000000..3d52068c --- /dev/null +++ b/docs/readme.txt @@ -0,0 +1,25 @@ +INTRODUCTION +------------ +This archive contains the current FreeDOS Kernel, also +known as DOS-C, originally written by Pasquale J. Villani. + +The FreeDOS Kernel is available from http://freedos.sourceforge.net. +It's also available from http://www.dosemu.org (somewhere on there). + +The FreeDOS Kernel is also available through the FreeDOS Project at +http://www.freedos.org. + +See the DOCS directory for more documentation and information about +the FreeDOS Kernel. + + +BUG REPORTS +----------- +If you have found a bug, think you have found a bug, or would just +like to make a suggestion, go to the bug tracking web page at +http://www.freedos.org/bugs/ + +Copyright +--------- +DOS-C is (c) Copyright 1995, 1996 by Pasquale J. Villani +All Rights Reserved. From 0ddf436c887322eb7fc032dd80d7c8a365f53317 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sun, 18 Nov 2001 17:48:20 +0000 Subject: [PATCH 115/671] Fixed bug in sys.c and remove *.err files with clean/clobber git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@333 6ac86273-5f31-0410-b378-82cca8765d1b --- docs/history.txt | 2 ++ drivers/makefile | 2 +- kernel/makefile | 2 +- sys/makefile | 2 +- sys/sys.c | 2 +- utils/makefile | 2 +- 6 files changed, 7 insertions(+), 5 deletions(-) diff --git a/docs/history.txt b/docs/history.txt index 07608984..2fdf27e5 100644 --- a/docs/history.txt +++ b/docs/history.txt @@ -4,6 +4,8 @@ * ran source code .c and .h files through "indent" * fixed new printf bug * removed some duplicate documents ++ Changes Victor & Bart + * fixed sys.c fat32 detection bug (offset 0x10, not 0x2c) 2001 Nov 17 - Build 2025b -------- Bart Oldeman (bart@dosemu.org) + Changes Tom diff --git a/drivers/makefile b/drivers/makefile index 17f28055..8a88e631 100644 --- a/drivers/makefile +++ b/drivers/makefile @@ -42,7 +42,7 @@ clobber: clean -$(RM) device.lib status.me ..\lib\device.lib clean: - -$(RM) *.obj *.bak *.crf *.xrf *.map *.lst *.cod + -$(RM) *.obj *.bak *.crf *.xrf *.map *.lst *.cod *.err device.lib : $(OBJS) -$(RM) device.lib diff --git a/kernel/makefile b/kernel/makefile index 4e4316b7..f0b22fe3 100644 --- a/kernel/makefile +++ b/kernel/makefile @@ -100,7 +100,7 @@ clobber: clean -$(RM) kernel.exe kernel.sys status.me clean: - -$(RM) *.obj *.bak *.crf *.xrf *.map *.lst *.cod + -$(RM) *.obj *.bak *.crf *.xrf *.map *.lst *.cod *.err # XXX: This is a very ugly way of linking the kernel, forced upon us by the # inability of Turbo `make' 2.0 to perform command line redirection. -- ror4 diff --git a/sys/makefile b/sys/makefile index 08ba3304..14c11ac7 100644 --- a/sys/makefile +++ b/sys/makefile @@ -49,7 +49,7 @@ clobber: clean -$(RM) bin2c.com sys.com b_fat12.h b_fat16.h b_fat32.h clean: - -$(RM) *.obj *.bak *.crf *.xrf *.map *.lst *.las *.cod status.me + -$(RM) *.obj *.bak *.crf *.xrf *.map *.lst *.las *.cod *.err status.me # *Individual File Dependencies* bin2c.obj: bin2c.c diff --git a/sys/sys.c b/sys/sys.c index 37f52a84..e117a170 100644 --- a/sys/sys.c +++ b/sys/sys.c @@ -431,7 +431,7 @@ VOID put_boot(COUNT drive, BYTE * bsFile, BOOL both) } else { - if (*(unsigned long *)(x + 0x2c) /* total number of clusters */ + if (*(unsigned long *)(x + 0x10) /* total number of clusters */ > (unsigned)65526l) { fs = 32; diff --git a/utils/makefile b/utils/makefile index 20b628b4..584fe6ea 100644 --- a/utils/makefile +++ b/utils/makefile @@ -15,5 +15,5 @@ clobber: clean $(RM) bin2c.com exeflat.exe patchobj.exe clean: - $(RM) *.obj *.bak *.crf *.xrf *.map *.lst *.las *.cod status.me + $(RM) *.obj *.bak *.crf *.xrf *.map *.lst *.las *.cod *.err status.me From 2e46486b3f2023bd7d0dff17c49d6134450affdb Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sun, 18 Nov 2001 18:18:13 +0000 Subject: [PATCH 116/671] Updated indent.ini to new situation. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@334 6ac86273-5f31-0410-b378-82cca8765d1b --- utils/indent.ini | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/utils/indent.ini b/utils/indent.ini index 3f253c22..2828df89 100644 --- a/utils/indent.ini +++ b/utils/indent.ini @@ -12,6 +12,7 @@ -ci4 -nce -sob --ts80 +-nut -nbad -cli2 +-hnl From 0e8b739c4c0f79727d1c91f77a572b821dabef09 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Wed, 23 Jan 2002 22:29:41 +0000 Subject: [PATCH 117/671] kernel 2026 test changes (see history.txt) git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@343 6ac86273-5f31-0410-b378-82cca8765d1b --- boot/boot.asm | 45 +++-- boot/boot32.asm | 40 ++-- build.bat | 44 +++-- config.b | 10 +- docs/config.txt | 119 ++++++++++++ docs/history.txt | 34 ++++ docs/intfns.txt | 8 +- docs/lfnapi.txt | 5 +- drivers/makefile | 4 +- drivers/rdpcclk.asm | 8 +- drivers/timer.asm | 144 -------------- hdr/device.h | 16 ++ hdr/fat.h | 22 +-- hdr/fnode.h | 23 +-- hdr/kconfig.h | 1 - hdr/nls.h | 2 +- hdr/portab.h | 13 +- hdr/process.h | 8 +- hdr/version.h | 10 +- hdr/xstructs.h | 2 + kernel/blockio.c | 31 +-- kernel/chario.c | 7 +- kernel/config.c | 420 +++++++++++++++++++++++++++++------------ kernel/dosfns.c | 133 ++++++++----- kernel/dsk.c | 173 +++++++++-------- kernel/dyndata.c | 13 -- kernel/dyninit.c | 6 +- kernel/error.c | 4 +- kernel/execrh.asm | 5 +- kernel/fatdir.c | 18 +- kernel/fatfs.c | 42 ++++- kernel/fattab.c | 4 +- kernel/fcbfns.c | 133 ++++++------- kernel/globals.h | 185 +++++++++--------- kernel/init-mod.h | 105 +++++------ kernel/initdisk.c | 19 +- kernel/inithma.c | 28 +-- kernel/int2f.asm | 16 ++ kernel/inthndlr.c | 100 ++++------ kernel/intr.h | 2 +- kernel/io.asm | 12 +- kernel/kernel.asm | 43 ++++- kernel/lfnapi.c | 436 ++++++++++++++++++++++++------------------- kernel/ludivmul.inc | 144 ++++++++++++++ kernel/main.c | 132 +++++++------ kernel/makefile | 72 ++++--- kernel/memmgr.c | 6 +- kernel/newstuff.c | 3 +- kernel/nls_load.c | 6 +- kernel/prf.c | 83 ++++---- kernel/proto.h | 74 ++------ kernel/rtlsupt.asm | 65 ------- kernel/segs.inc | 25 ++- kernel/sysclk.c | 11 +- kernel/systime.c | 2 +- kernel/task.c | 17 +- mkfiles/bc5.mak | 3 +- mkfiles/generic.mak | 8 +- mkfiles/mscl8.mak | 10 +- mkfiles/tc2.mak | 3 +- mkfiles/tc3.mak | 3 +- mkfiles/turbocpp.mak | 3 +- mkfiles/watcom.mak | 12 +- sys/sys.c | 17 +- utils/exeflat.c | 102 ++++++++-- utils/makefile | 2 +- utils/patchobj.c | 26 ++- utils/rmfiles.bat | 2 +- 68 files changed, 1899 insertions(+), 1425 deletions(-) create mode 100644 docs/config.txt delete mode 100644 drivers/timer.asm delete mode 100644 kernel/dyndata.c create mode 100644 kernel/ludivmul.inc delete mode 100644 kernel/rtlsupt.asm diff --git a/boot/boot.asm b/boot/boot.asm index 68f8444d..2bb35083 100644 --- a/boot/boot.asm +++ b/boot/boot.asm @@ -307,7 +307,7 @@ fat_12: add si, si ; multiply cluster number by 3... shr ax, cl ; shift the cluster number fat_even: and ah, 0x0f ; mask off the highest 4 bits - cmp ax, 0x0fff ; check for EOF + cmp ax, 0x0ff8 ; check for EOF jb next_clust ; continue if not EOF %endif @@ -412,35 +412,34 @@ read_next: push dx ; + head * sectPerTrack offset in cylinder ; + track * sectPerTrack * nHeads offset in platter ; - ; t1 = abs / sectPerTrack (ax has t1) - ; sector = abs mod sectPerTrack (cx has sector) - ; - div word [sectPerTrack] + xchg ax, cx + mov al, [sectPerTrack] + mul byte [nHeads] + xchg ax, cx + ; cx = nHeads * sectPerTrack <= 255*63 + ; dx:ax = abs + div cx + ; ax = track, dx = sector + head * sectPertrack + xchg ax, dx + ; dx = track, ax = sector + head * sectPertrack + div byte [sectPerTrack] + ; dx = track, al = head, ah = sector mov cx, dx - - ; - ; t1 = head + track * nHeads - ; - ; track = t1 / nHeads (ax has track) - ; head = t1 mod nHeads (dl has head) - ; - xor dx, dx - div word [nHeads] + ; cx = track, al = head, ah = sector ; the following manipulations are necessary in order to ; properly place parameters into registers. ; ch = cylinder number low 8 bits ; cl = 7-6: cylinder high two bits ; 5-0: sector - mov dh, dl ; save head into dh for bios - ror ah, 1 ; move track high bits into - ror ah, 1 ; bits 7-6 (assumes top = 0) - xchg al, ah ; swap for later - mov dl, byte [sectPerTrack] - sub dl, cl - inc cl ; sector offset from 1 - or cx, ax ; merge cylinder into sector - mov al, dl ; al has # of sectors left + mov dh, al ; save head into dh for bios + xchg ch, cl ; set cyl no low 8 bits + ror cl, 1 ; move track high bits into + ror cl, 1 ; bits 7-6 (assumes top = 0) + mov al, byte [sectPerTrack] + sub al, ah ; al has # of sectors left + inc ah ; sector offset from 1 + or cl, ah ; merge sector into cylinder %ifdef MULTI_SEC_READ ; Calculate how many sectors can be transfered in this read diff --git a/boot/boot32.asm b/boot/boot32.asm index 51973f07..ba827d6e 100644 --- a/boot/boot32.asm +++ b/boot/boot32.asm @@ -299,34 +299,32 @@ read_next: push dx ; + head * sectPerTrack offset in cylinder ; + track * sectPerTrack * nHeads offset in platter ; - ; t1 = abs / sectPerTrack (ax has t1) - ; sector = abs mod sectPerTrack (cx has sector) - ; - div word [sectPerTrack] + xchg ax, cx + mov al, [sectPerTrack] + mul byte [nHeads] + xchg ax, cx + ; cx = nHeads * sectPerTrack <= 255*63 + ; dx:ax = abs + div cx + ; ax = track, dx = sector + head * sectPertrack + xchg ax, dx + ; dx = track, ax = sector + head * sectPertrack + div byte [sectPerTrack] + ; dx = track, al = head, ah = sector mov cx, dx - - ; - ; t1 = head + track * nHeads - ; - ; track = t1 / nHeads (ax has track) - ; head = t1 mod nHeads (dl has head) - ; - xor dx, dx - div word [nHeads] + ; cx = track, al = head, ah = sector ; the following manipulations are necessary in order to ; properly place parameters into registers. ; ch = cylinder number low 8 bits ; cl = 7-6: cylinder high two bits ; 5-0: sector - mov dh, dl ; save head into dh for bios - ror ah, 1 ; move track high bits into - ror ah, 1 ; bits 7-6 (assumes top = 0) - xchg al, ah ; swap for later - mov dl, byte [sectPerTrack] - sub dl, cl - inc cl ; sector offset from 1 - or cx, ax ; merge cylinder into sector + mov dh, al ; save head into dh for bios + xchg ch, cl ; set cyl no low 8 bits + ror cl, 1 ; move track high bits into + ror cl, 1 ; bits 7-6 (assumes top = 0) + inc ah ; sector offset from 1 + or cl, ah ; merge sector into cylinder mov ax, 0x0201 mov dl, [drive] diff --git a/build.bat b/build.bat index c4686014..e5fe55fd 100644 --- a/build.bat +++ b/build.bat @@ -18,21 +18,6 @@ set XERROR= call config.bat call getmake.bat -@if not "%XLINK%" == "" goto link_set - -@if \%COMPILER% == \TC2 set XLINK=%TC2_BASE%\tlink /m/c -@if \%COMPILER% == \TURBOCPP set XLINK=%TP1_BASE%\bin\tlink /m/c -@if \%COMPILER% == \TC3 set XLINK=%TC3_BASE%\bin\tlink /m/c -@if \%COMPILER% == \BC5 set XLINK=%BC5_BASE%\bin\tlink /m/c -@if \%COMPILER% == \WATCOM goto watcom_problem -@if \%COMPILER% == \MSCL8 set XLINK=%MS_BASE%\link /ONERROR:NOEXE /ma /nologo -goto link_set - -:watcom_problem -@echo you MUST set XLINK for Watcom in config.bat as WLINK is not suitable -goto end - -:link_set @set XERROR= @@ -72,6 +57,35 @@ goto loop_commandline if \%COMPILER% == \ echo you MUST define a COMPILER variable in CONFIG.BAT if \%COMPILER% == \ goto end + +@if not "%XLINK%" == "" goto link_set + +@if \%COMPILER% == \TC2 set XLINK=%TC2_BASE%\tlink /m/c +@if \%COMPILER% == \TURBOCPP set XLINK=%TP1_BASE%\bin\tlink /m/c +@if \%COMPILER% == \TC3 set XLINK=%TC3_BASE%\bin\tlink /m/c +@if \%COMPILER% == \BC5 set XLINK=%BC5_BASE%\bin\tlink /m/c +@if \%COMPILER% == \WATCOM goto watcom_problem +@if \%COMPILER% == \MSCL8 set XLINK=%MS_BASE%\bin\link /ONERROR:NOEXE /ma /nologo +goto link_set + +:watcom_problem +@echo you MUST set XLINK for Watcom in config.bat as WLINK is not suitable +goto end + +:link_set + +echo linker ist %XLINK% + +@if not "%XUPX%" == "" goto upx_set +@set XUPX=@rem +@set UPXOPT= +goto compile + +:upx_set +@set UPXOPT=-U + +:compile + :************************************************************************ :* finally - we are going to compile :************************************************************************ diff --git a/config.b b/config.b index 029dcc32..1ec4f1de 100644 --- a/config.b +++ b/config.b @@ -54,11 +54,18 @@ set TC2_BASE=c:\tc201 :- if WATCOM maybe you need to set your WATCOM environment variables :- and path -:- if not %WATCOM% == \ goto watcom_defined +:- if not \%WATCOM% == \ goto watcom_defined :- set WATCOM=c:\watcom :- set PATH=%PATH%;%WATCOM%\binw :watcom_defined +:-********************************************************************** +:- where is UPX and which options to use? +:-********************************************************************** +set XUPX=upx --8086 +:- or use set XUPX= +:- if you don't want to use it + :-********************************************************************** :- (optionally) which linker to use: :- (otherwise will be determined automatically) @@ -108,6 +115,7 @@ set XFAT=16 :- Give extra compiler DEFINE flags here :- such as -DDEBUG : extra DEBUG output :- -DDOSEMU : printf output goes to dosemu log +:- -p : use PASCAL calling convention with Turbo C :- set ALLCFLAGS=-DDEBUG diff --git a/docs/config.txt b/docs/config.txt new file mode 100644 index 00000000..88691924 --- /dev/null +++ b/docs/config.txt @@ -0,0 +1,119 @@ +advanced CONFIG.SYS processing + +a new command ECHO +ECHO does ECHO it's argument (surprised ?-) and is executed at +the time the DEVICE= lines are executed. +use it similar to + + ECHO loading driver 1 + device=Driver1.sys + ECHO driver1 successfully loaded + + + + + +the following advanced config.sys processing options are available: + +normal + FILES=20 + DEVICE=MyNetWorkDriver.sys + +'?' - ALWAYS ask if a single line shall be executed + + FILES=20 + ?DEVICE=MyNetWorkDriver.sys + + +'!' - NEVER ask if a single line shall be executed, even if single stepping + + !FILES=20 + !DOS=HIGH,UMB + !BUFFERS=30 + DEVICE=MyNetWorkDriver.sys + + + +configuration management - you may compose several configurations, +using following special commands: + +MENU +MENU select your configuration +MENU +MENU use (0) for basic configuration +MENU use (1) for CDROM operation +MENU use (2) for NETWORK configuration +MENU +MENUDEFAULT=0,1 ( configuration 0, wait 1 second) + + +1? rem CDROM +1? device=CDROM.SYS + +2? rem NETWORK +2? device=MyNetworkDriver.SYS + + +Although this is definitively worse then MSDOS menuing possibilities, +IMHO it's better then nothing + + + +thus my config.sys now looks like + + +!files=20 +!dos=high,umb +!break=off +!buffers=30 +!screen=0x12 +!lastdrive=z + +MENU +MENU +MENU 0 - SoftIce+HIMEM+Network (default) +MENU 1 - SoftIce+HIMEM +MENU 2 - HIMEM+EMM386 +MENU +MENUDEFAULT=0,0 + + +0? DEVICE=C:\NUMEGA\S-ICE.EXE /TRA 3000 /SYM 400 +0? DEVICE=himem.exe +0? DEVICE=UMBPCI.SYS + +0?device=c:\ntclient\ifshlp.sys +0?device=c:\ntclient\protman.dos /i:c:\ntclient +0?device=c:\ntclient\dm9pci.dos +0?device=c:\ntclient\ndishlp.sys +0?device=c:\ntclient\nemm.dos +0?device=c:\ntclient\tcpdrv.dos + + + +1? DEVICE=C:\NUMEGA\S-ICE.EXE /TRA 3000 /SYM 400 +1? DEVICE=himem.exe +1? DEVICE=UMBPCI.SYS + + + +2? DEVICE=himem.exe +2? DEVICE=emm386.exe NOEMS + + +rem DEVICE=CDROM.SYS /D:MSCD000 + +shellhigh=a:\command.com /p /e:512 /MSG + + + + + +12/14/01 - tom ehlert + + + + + + + diff --git a/docs/history.txt b/docs/history.txt index 2fdf27e5..682f986e 100644 --- a/docs/history.txt +++ b/docs/history.txt @@ -1,3 +1,37 @@ +2002 Feb xx - Build 2026test +-------- Bart Oldeman (bart@dosemu.org) ++ Changes Tom + * FCB clean-ups and fixes + * initial config.sys menus (see config.txt) + * execrh + * make kernel UPX-able + * cleaned up midnight flag, dates + * tmark() and friends are floppy specific and implemented in C + instead of ASM (parts by Bart) ++ Changes Victor + * lfn fixes + * FAT32 fixes + * dosemu log nicer ++ Changes Martin + * log output + * warning fixes for sys, patchobj and prf.c ++ Changes Bart + * FCB clean-ups and fixes + * make Watcom compiled kernel runnable + * make compilation with Pascal style calling conventions + for Borland compilers (-p) possible + * initialize CDS before opening devices + * implement lock/unlock for remote drives + * implement commit file (int21/ah=68,6a) + * implement ioctl get/set logical drive map (int21/ax=440E--F) + * implement get drive data table (int2f/ax=0803) + * fix "get SDA" (int21/ax=5d06) + * do not use CHS if the root extended partition of the relevant + logical partition is labelled LBA + * boot sector fixes: + enable booting beyond cylinder x where x * number of heads >= 65536. + still uses CHS to boot (not able to boot beyond cylinder 1023) + recognize FF8-FFF as FAT12 ending (was only FFF) 2001 Nov 18 - Build 2025c -------- Bart Oldeman (bart@dosemu.org) + Changes Bart diff --git a/docs/intfns.txt b/docs/intfns.txt index d694952f..732b867b 100644 --- a/docs/intfns.txt +++ b/docs/intfns.txt @@ -104,7 +104,7 @@ int 21 Description State Ver Status 50h Set PSP Address active 2.00 supported 51h Get PSP Address active 2.00 supported 52h Get List of Lists undocumented 2.00 supported -53h undocumented not supported +53h Translate BPB to DPB undocumented supported 54h Get Verify State active 2.00 supported 55h Create New Psp undocumented 2.00 supported 56h Rename File active 2.00 supported @@ -139,11 +139,11 @@ int 21 Description State Ver Status 65h NLS Functions active 3.30 supported 66h Code Page Functions active 3.30 supported 67h Set Maximum Handle Count active 3.30 supported -68h Commit File active 3.30 dummy func +68h Commit File active 3.30 supported 69h GET/SET DISK SERIAL NUMBER active 4.00 supported -6ah COMMIT FILE (same as 68h) active 4.00 not supported +6ah COMMIT FILE (same as 68h) active 4.00 supported 6bh NULL FUNCTION active 5.00 supported -6ch Extended Open/Create active 4.00 planned +6ch Extended Open/Create active 4.00 supported 71h LONG FILENAME FUNCTIONS active 7.00 not supported int 22: Program Termination Address. diff --git a/docs/lfnapi.txt b/docs/lfnapi.txt index a2e8d57c..2a323041 100644 --- a/docs/lfnapi.txt +++ b/docs/lfnapi.txt @@ -2,7 +2,7 @@ struct lfn_inode { - UNICODE name[256]; + UNICODE name[261]; struct dirent l_dir; /* this file's dir entry image */ @@ -13,10 +13,9 @@ typedef struct lfn_inode FAR * lfn_inode_ptr; COUNT lfn_allocate_inode(VOID); COUNT lfn_free_inode(COUNT handle); -COUNT lfn_setup_inode(COUNT handle, CLUSTER dirstart, ULONG diroff); +COUNT lfn_setup_inode(COUNT handle, ULONG dirstart, ULONG diroff); COUNT lfn_create_entries(COUNT handle, lfn_inode_ptr lip); -COUNT lfn_remove_entries(COUNT handle); COUNT lfn_dir_read(COUNT handle, lfn_inode_ptr lip); COUNT lfn_dir_write(COUNT handle); diff --git a/drivers/makefile b/drivers/makefile index 8a88e631..50fe8b3f 100644 --- a/drivers/makefile +++ b/drivers/makefile @@ -22,10 +22,10 @@ #AFLAGS = /Mx /Dmem$(MODEL)=1 #LIBFLAGS = /c -OBJS = devend.obj floppy.obj getvec.obj timer.obj rdpcclk.obj rdatclk.obj \ +OBJS = devend.obj floppy.obj getvec.obj rdpcclk.obj rdatclk.obj \ wrpcclk.obj wratclk.obj -LIBOBJS= +devend +floppy +getvec +timer +rdpcclk +rdatclk +wrpcclk +wratclk +LIBOBJS= +devend +floppy +getvec +rdpcclk +rdatclk +wrpcclk +wratclk diff --git a/drivers/rdpcclk.asm b/drivers/rdpcclk.asm index 29d71fd6..ffb8d88c 100644 --- a/drivers/rdpcclk.asm +++ b/drivers/rdpcclk.asm @@ -44,7 +44,13 @@ _ReadPCClock: mov bx,[bx+2] mov [bx],dx mov [bx+2],cx - cbw + extern _DaysSinceEpoch ; ; update days if necessary + + mov ah,0 + + add word [_DaysSinceEpoch ],ax ; *some* BIOS's accumulate several days + adc word [_DaysSinceEpoch+2],0 ; + ret ; Log: rdpcclk.asm,v diff --git a/drivers/timer.asm b/drivers/timer.asm deleted file mode 100644 index 849272c0..00000000 --- a/drivers/timer.asm +++ /dev/null @@ -1,144 +0,0 @@ -; -; File: -; timer.asm -; Description: -; Set a single timer and check when expired -; -; Copyright (c) 1995 -; Pasquale J. Villani -; All Rights Reserved -; -; This file is part of DOS-C. -; -; DOS-C is free software; you can redistribute it and/or -; modify it under the terms of the GNU General Public License -; as published by the Free Software Foundation; either version -; 2, or (at your option) any later version. -; -; DOS-C is distributed in the hope that it will be useful, but -; WITHOUT ANY WARRANTY; without even the implied warranty of -; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See -; the GNU General Public License for more details. -; -; You should have received a copy of the GNU General Public -; License along with DOS-C; see the file COPYING. If not, -; write to the Free Software Foundation, 675 Mass Ave, -; Cambridge, MA 02139, USA. -; -; $Header$ -; - - %include "..\kernel\segs.inc" - -segment HMA_TEXT - -; -; void tmark() -; - global _tmark -_tmark: - xor ah,ah - int 01aH ; get current time in ticks - xor ah,ah - mov word [LastTime],dx ; and store it - mov word [LastTime+2],cx - ret - - -; -; int tdelay(Ticks) -; - global _tdelay -_tdelay: - push bp - mov bp,sp - xor ah,ah - int 01aH ; get current time in ticks - xor ah,ah - mov word bx,dx ; and save it to a local variable - ; "Ticks" (cx:bx) -; -; Do a c equivalent of: -; -; return Now >= (LastTime + Ticks); -; - mov ax,word [LastTime+2] - mov dx,word [LastTime] - add dx,word [bp+4] - adc ax,word [bp+6] - cmp ax,cx - mov ax,0 ; mov does not affect flags - ja short tdel_1 - jne short tdel_2 - cmp dx,bx - ja short tdel_1 -tdel_2: - inc ax ; True return -tdel_1: - pop bp ; False return - ret - - -; -; void twait(Ticks) -; - global _twait -_twait: - push bp - mov bp,sp - call _tmark ; mark a start -; -; c equivalent -; do -; GetNowTime(&Now); -; while((LastTime + Ticks) < Now); -twait_1: - xor ah,ah - int 01aH - xor ah,ah ; do GetNowTime - mov bx,dx ; and save it to "Now" (cx:bx) -; -; do comparison -; - mov ax,word [LastTime+2] - mov dx,word [LastTime] - add dx,word [bp+4] - adc ax,word [bp+6] - cmp ax,cx - jb short twait_1 - jne short twait_2 - cmp dx,bx - jb short twait_1 -twait_2: - pop bp - ret - -segment _BSS -LastTime: resd 1 - -; Log: timer.asm,v -; Revision 1.3 1999/08/10 17:21:08 jprice -; ror4 2011-01 patch -; -; Revision 1.2 1999/03/29 17:08:31 jprice -; ror4 changes -; -; Revision 1.1.1.1 1999/03/29 15:40:34 jprice -; New version without IPL.SYS -; -; Revision 1.2 1999/01/22 04:16:39 jprice -; Formating -; -; Revision 1.1.1.1 1999/01/20 05:51:00 jprice -; Imported sources -; -; -; Rev 1.2 29 Aug 1996 13:07:12 patv -;Bug fixes for v0.91b -; -; Rev 1.1 01 Sep 1995 18:50:42 patv -;Initial GPL release. -; -; Rev 1.0 02 Jul 1995 8:01:04 patv -;Initial revision. -; diff --git a/hdr/device.h b/hdr/device.h index 1de1e928..aabb3c3a 100644 --- a/hdr/device.h +++ b/hdr/device.h @@ -455,6 +455,22 @@ typedef bpb FAR *bpbptr; typedef BYTE FAR *byteptr; typedef struct dhdr FAR *dhdrptr; +extern request /* I/O Request packets */ + ASM CharReqHdr, ASM IoReqHdr, ASM MediaReqHdr; + +/* dsk.c */ +COUNT ASMCFUNC FAR blk_driver(rqptr rp); +ddt * getddt(int dev); + +/* error.c */ +COUNT char_error(request * rq, struct dhdr FAR * lpDevice); +COUNT block_error(request * rq, COUNT nDrive, struct dhdr FAR * lpDevice); +/* sysclk.c */ +WORD ASMCFUNC FAR clk_driver(rqptr rp); + +/* execrh.asm */ +WORD ASMCFUNC execrh(request FAR *, struct dhdr FAR *); + /* * end of device.h */ diff --git a/hdr/fat.h b/hdr/fat.h index 164079d6..7ddf5927 100644 --- a/hdr/fat.h +++ b/hdr/fat.h @@ -97,14 +97,14 @@ struct dirent { }; struct lfn_entry { - UBYTE lfn_id; - UNICODE lfn_name0_4[5]; - UBYTE lfn_attrib; + UBYTE lfn_id; /* Sequence number for this LFN entry */ + UNICODE lfn_name0_4[5]; /* First 5 characters of LFN */ + UBYTE lfn_attrib; /* LFN attribute, should be D_LFN == 0x0f */ UBYTE lfn_reserved1; - UBYTE lfn_checksum; - UNICODE lfn_name5_10[6]; + UBYTE lfn_checksum; /* Checksum for the corresponding 8.3 name */ + UNICODE lfn_name5_10[6]; /* Next 6 characters of LFN */ UWORD lfn_reserved2; - UNICODE lfn_name11_12[2]; + UNICODE lfn_name11_12[2]; /* Last 2 characters of LFN */ }; /* */ @@ -140,16 +140,6 @@ struct lfn_entry { #define DIRENT_SIZE 32 -struct lfn_inode { - UNICODE name[256]; - - struct dirent l_dir; - - ULONG l_diroff; /* offset of the dir entry */ -}; - -typedef struct lfn_inode FAR *lfn_inode_ptr; - /* * Log: fat.h,v * diff --git a/hdr/fnode.h b/hdr/fnode.h index 21bac170..97048ca7 100644 --- a/hdr/fnode.h +++ b/hdr/fnode.h @@ -63,22 +63,17 @@ struct f_node { UWORD f_boff; /* the byte in the cluster */ }; -#if 0 -struct lfn_inode { - UNICODE name[255]; - - struct dirent l_dir; /* this file's dir entry image */ - - ULONG l_diroff; /* offset of the dir entry */ - CLUSTER l_dirstart; /* the starting cluster of dir */ - /* when dir is not root */ -}; - -typedef struct lfn_inode FAR *lfn_inode_ptr; -#endif - typedef struct f_node *f_node_ptr; +struct lfn_inode { + UNICODE l_name[261]; /* Long file name string */ + /* If the string is empty, */ + /* then file has the 8.3 name */ + struct dirent l_dir; /* Directory entry image */ + ULONG l_diroff; /* Current directory entry offset */ +}; + +typedef struct lfn_inode FAR * lfn_inode_ptr; /* * Log: fnode.h,v * diff --git a/hdr/kconfig.h b/hdr/kconfig.h index f08506e8..56fccbb8 100644 --- a/hdr/kconfig.h +++ b/hdr/kconfig.h @@ -24,4 +24,3 @@ typedef struct _KernelConfig { unsigned char ForceLBA; unsigned char GlobalEnableLBAsupport; /* = 0 --> disable LBA support */ } KernelConfig; -extern struct _KernelConfig FAR LowKernelConfig; diff --git a/hdr/nls.h b/hdr/nls.h index a8d1b37b..3a9af629 100644 --- a/hdr/nls.h +++ b/hdr/nls.h @@ -450,7 +450,7 @@ struct nlsInfoBlock { /* This block contains all information }; extern struct nlsInfoBlock nlsInfo; -extern struct nlsPackage nlsPackageHardcoded; +extern struct nlsPackage ASM nlsPackageHardcoded; /* These are the "must have" tables within the hard coded NLS pkg */ extern struct nlsFnamTerm nlsFnameTermHardcoded; extern struct nlsDBCS nlsDBCSHardcoded; diff --git a/hdr/portab.h b/hdr/portab.h index 5a202982..0bcb781f 100644 --- a/hdr/portab.h +++ b/hdr/portab.h @@ -99,6 +99,7 @@ anyone knows a _portable_ way to create nice errors ? ? have a certain calling standard. These are declared as 'ASMCFUNC', and is (and will be ?-) cdecl */ #define ASMCFUNC cdecl +#define ASM ASMCFUNC #ifdef MC68K #define far /* No far type */ #define interrupt /* No interrupt type */ @@ -174,7 +175,11 @@ typedef unsigned short CLUSTER; #endif typedef unsigned short UNICODE; -#define STATIC /* local calls inside module */ +#ifdef STATICS +#define STATIC static /* local calls inside module */ +#else +#define STATIC +#endif #ifdef UNIX typedef char FAR *ADDRESS; @@ -191,7 +196,11 @@ typedef signed long LONG; /* General far pointer macros */ #ifdef I86 #ifndef MK_FP +#ifdef __WATCOMC__ +#define MK_FP(__s,__o) (((unsigned short)(__s)):>((void __near *)(__o))) +#else #define MK_FP(seg,ofs) ((VOID far *)(((ULONG)(seg)<<16)|(UWORD)(ofs))) +#endif #define FP_SEG(fp) ((UWORD)((ULONG)(VOID FAR *)(fp)>>16)) #define FP_OFF(fp) ((UWORD)(fp)) #endif @@ -203,6 +212,8 @@ typedef signed long LONG; #define FP_OFF(fp) (fp) #endif +typedef VOID (FAR ASMCFUNC * intvec) (); + /* this suppresses the warning unreferenced parameter 'x' diff --git a/hdr/process.h b/hdr/process.h index 5cd99cf3..6a241a1d 100644 --- a/hdr/process.h +++ b/hdr/process.h @@ -68,10 +68,10 @@ typedef struct { /* CP/M-like entry point */ UBYTE ps_farcall; /* 05 far call opcode */ - VOID(FAR * ps_reentry) (); /* 06 re-entry point */ - VOID(interrupt FAR * ps_isv22) (), /* 0a terminate address */ - (interrupt FAR * ps_isv23) (), /* 0e break address */ - (interrupt FAR * ps_isv24) (); /* 12 critical error address */ + VOID(FAR ASMCFUNC * ps_reentry) (); /* 06 re-entry point */ + intvec ps_isv22, /* 0a terminate address */ + ps_isv23, /* 0e break address */ + ps_isv24; /* 12 critical error address */ UWORD ps_parent; /* 16 parent psp segment */ UBYTE ps_files[20]; /* 18 file table - 0xff is unused */ UWORD ps_environ; /* 2c environment paragraph */ diff --git a/hdr/version.h b/hdr/version.h index 5ebc1fea..e63510e3 100644 --- a/hdr/version.h +++ b/hdr/version.h @@ -43,8 +43,8 @@ static BYTE *date_hRcsId = #define REVISION_MAJOR 1 #define REVISION_MINOR 1 -#define REVISION_SEQ 25 -#define BUILD "2025" -#define SUB_BUILD "c" -#define KERNEL_VERSION_STRING "1.1.25c" /*#REVISION_MAJOR "." #REVISION_MINOR "." #REVISION_SEQ */ -#define KERNEL_BUILD_STRING "2025c" /*#BUILD SUB_BUILD */ +#define REVISION_SEQ 26 +#define BUILD "2026" +#define SUB_BUILD "test" +#define KERNEL_VERSION_STRING "1.1.26test" /*#REVISION_MAJOR "." #REVISION_MINOR "." #REVISION_SEQ */ +#define KERNEL_BUILD_STRING "2026test" /*#BUILD SUB_BUILD */ diff --git a/hdr/xstructs.h b/hdr/xstructs.h index 90310a58..42d2ab7c 100644 --- a/hdr/xstructs.h +++ b/hdr/xstructs.h @@ -80,3 +80,5 @@ struct xdpbforformat { } setroot; } xdff_f; }; + +COUNT DosGetExtFree(BYTE FAR * DriveString, struct xfreespace FAR * xfsp); diff --git a/kernel/blockio.c b/kernel/blockio.c index 7a78e7ba..0b5e172a 100644 --- a/kernel/blockio.c +++ b/kernel/blockio.c @@ -46,36 +46,11 @@ static BYTE *blockioRcsId = /* */ /* Initialize the buffer structure */ /* */ -/* XXX: This should go into `INIT_TEXT'. -- ror4 */ -/* this code moved to CONFIG.C -VOID FAR reloc_call_init_buffers(void) -{ - REG WORD i; - REG WORD count; - - printf("init_buffers %d buffers at %p\n",Config.cfgBuffers, (void FAR*)&buffers[0]); - - for (i = 0; i < Config.cfgBuffers; ++i) - { - struct buffer FAR *pbuffer = &buffers[i]; - - pbuffer->b_unit = 0; - pbuffer->b_flag = 0; - pbuffer->b_blkno = 0; - pbuffer->b_copies = 0; - pbuffer->b_offset = 0; - if (i < (Config.cfgBuffers - 1)) - pbuffer->b_next = pbuffer + 1; - else - pbuffer->b_next = NULL; - } - firstbuf = &buffers[0]; -} -*/ /* Extract the block number from a buffer structure. */ + #if 0 /*TE*/ - ULONG getblkno(struct buffer FAR * bp) +STATIC ULONG getblkno(struct buffer FAR * bp) { if (bp->b_blkno == 0xffffu) return bp->b_huge_blkno; @@ -89,7 +64,7 @@ VOID FAR reloc_call_init_buffers(void) /* Set the block number of a buffer structure. (The caller should */ /* set the unit number before calling this function.) */ #if 0 /*TE*/ - VOID setblkno(struct buffer FAR * bp, ULONG blkno) +STATIC VOID setblkno(struct buffer FAR * bp, ULONG blkno) { if (blkno >= 0xffffu) { diff --git a/kernel/chario.c b/kernel/chario.c index d8b45b63..1cef021e 100644 --- a/kernel/chario.c +++ b/kernel/chario.c @@ -38,11 +38,10 @@ static BYTE *charioRcsId = #include "globals.h" #ifdef PROTO -static VOID kbfill(keyboard FAR *, UCOUNT, BOOL, UWORD *); +STATIC VOID kbfill(keyboard FAR *, UCOUNT, BOOL, UWORD *); struct dhdr FAR *finddev(UWORD attr_mask); - #else -static VOID kbfill(); +STATIC VOID kbfill(); struct dhdr FAR *finddev(); #endif @@ -267,7 +266,7 @@ VOID KbdFlush(void) execrh((request FAR *) & CharReqHdr, syscon); } -static VOID kbfill(keyboard FAR * kp, UCOUNT c, BOOL ctlf, UWORD * vp) +STATIC VOID kbfill(keyboard FAR * kp, UCOUNT c, BOOL ctlf, UWORD * vp) { if (kp->kb_count >= kp->kb_size) { diff --git a/kernel/config.c b/kernel/config.c index 3c9daf80..16a2456a 100644 --- a/kernel/config.c +++ b/kernel/config.c @@ -59,35 +59,35 @@ static BYTE *RcsId = */ extern f_node_ptr DOSFAR f_nodes; /* pointer to the array */ extern UWORD DOSFAR f_nodes_cnt, /* number of allocated f_nodes */ - DOSFAR first_mcb; /* Start of user memory */ + DOSFAR ASM first_mcb; /* Start of user memory */ -extern UBYTE DOSFAR lastdrive, DOSFAR nblkdev, DOSFAR mem_access_mode, - DOSFAR uppermem_link; +extern UBYTE DOSFAR ASM lastdrive, DOSFAR ASM nblkdev, DOSFAR ASM mem_access_mode, + DOSFAR ASM uppermem_link; extern struct dhdr -DOSTEXTFAR blk_dev, /* Block device (Disk) driver */ - DOSFAR nul_dev; -extern struct buffer FAR *DOSFAR firstbuf; /* head of buffers linked list */ +DOSTEXTFAR ASM blk_dev, /* Block device (Disk) driver */ + DOSFAR ASM nul_dev; +extern struct buffer FAR *DOSFAR ASM firstbuf; /* head of buffers linked list */ -extern struct dpb FAR *DOSFAR DPBp; +extern struct dpb FAR *DOSFAR ASM DPBp; /* First drive Parameter Block */ -extern cdstbl FAR *DOSFAR CDSp; +extern cdstbl FAR *DOSFAR ASM CDSp; /* Current Directory Structure */ -extern sfttbl FAR *DOSFAR sfthead; +extern sfttbl FAR *DOSFAR ASM sfthead; /* System File Table head */ -extern sfttbl FAR *DOSFAR FCBp; +extern sfttbl FAR *DOSFAR ASM FCBp; -extern BYTE DOSFAR VgaSet, DOSFAR _HMATextAvailable, /* first byte of available CODE area */ +extern BYTE DOSFAR ASM VgaSet, DOSFAR _HMATextAvailable, /* first byte of available CODE area */ FAR _HMATextStart[], /* first byte of HMAable CODE area */ - FAR _HMATextEnd[], DOSFAR break_ena, /* break enabled flag */ + FAR _HMATextEnd[], DOSFAR ASM break_ena, /* break enabled flag */ DOSFAR os_major, /* major version number */ DOSFAR os_minor, /* minor version number */ - DOSFAR switchar, DOSFAR _InitTextStart, /* first available byte of ram */ + DOSFAR ASM switchar, DOSFAR _InitTextStart, /* first available byte of ram */ DOSFAR ReturnAnyDosVersionExpected; -extern UWORD DOSFAR ram_top, /* How much ram in Kbytes */ +extern UWORD DOSFAR ASM ram_top, /* How much ram in Kbytes */ - DOSFAR UMB_top, - DOSFAR umb_start, DOSFAR uppermem_root, DOSFAR LoL_nbuffers; + DOSFAR ASM UMB_top, + DOSFAR ASM umb_start, DOSFAR ASM uppermem_root, DOSFAR ASM LoL_nbuffers; struct config Config = { NUMBUFF, @@ -124,71 +124,87 @@ STATIC BYTE szBuf[256] = { 0 }; BYTE singleStep = FALSE; /* F8 processing */ BYTE SkipAllConfig = FALSE; /* F5 processing */ -BYTE askThisSingleCommand = FALSE; /* ?device= device?= */ - -INIT VOID zumcb_init(UCOUNT seg, UWORD size); -INIT VOID mumcb_init(UCOUNT seg, UWORD size); - -INIT VOID Config_Buffers(BYTE * pLine); -INIT VOID sysScreenMode(BYTE * pLine); -INIT VOID sysVersion(BYTE * pLine); -INIT VOID CfgBreak(BYTE * pLine); -INIT VOID Device(BYTE * pLine); -INIT VOID DeviceHigh(BYTE * pLine); -INIT VOID Files(BYTE * pLine); -INIT VOID Fcbs(BYTE * pLine); -INIT VOID CfgLastdrive(BYTE * pLine); -INIT BOOL LoadDevice(BYTE * pLine, COUNT top, COUNT mode); -INIT VOID Dosmem(BYTE * pLine); -INIT VOID Country(BYTE * pLine); -INIT VOID InitPgm(BYTE * pLine); -INIT VOID InitPgmHigh(BYTE * pLine); -INIT VOID CfgSwitchar(BYTE * pLine); -INIT VOID CfgFailure(BYTE * pLine); -INIT VOID Stacks(BYTE * pLine); -INIT VOID SetAnyDos(BYTE * pLine); -INIT VOID Numlock(BYTE * pLine); -INIT BYTE *GetNumArg(BYTE * pLine, COUNT * pnArg); -INIT BYTE *GetStringArg(BYTE * pLine, BYTE * pszString); -INIT struct dhdr FAR *linkdev(struct dhdr FAR * dhp); -INIT UWORD initdev(struct dhdr FAR * dhp, BYTE FAR * cmdTail); -INIT int SkipLine(char *pLine); -INIT char *stristr(char *s1, char *s2); -INIT COUNT strcasecmp(REG BYTE * d, REG BYTE * s); - -extern void HMAconfig(int finalize); +BYTE askThisSingleCommand = FALSE; /* ?device= device?= */ +BYTE DontAskThisSingleCommand = FALSE; /* !files= */ + +COUNT MenuTimeout = -1; +BYTE MenuSelected = '2'; +BYTE MenuLine = 0; +UCOUNT Menus = 0; + +STATIC VOID zumcb_init(UCOUNT seg, UWORD size); +STATIC VOID mumcb_init(UCOUNT seg, UWORD size); + +STATIC VOID Config_Buffers(BYTE * pLine); +STATIC VOID sysScreenMode(BYTE * pLine); +STATIC VOID sysVersion(BYTE * pLine); +STATIC VOID CfgBreak(BYTE * pLine); +STATIC VOID Device(BYTE * pLine); +STATIC VOID DeviceHigh(BYTE * pLine); +STATIC VOID Files(BYTE * pLine); +STATIC VOID Fcbs(BYTE * pLine); +STATIC VOID CfgLastdrive(BYTE * pLine); +STATIC BOOL LoadDevice(BYTE * pLine, COUNT top, COUNT mode); +STATIC VOID Dosmem(BYTE * pLine); +STATIC VOID Country(BYTE * pLine); +STATIC VOID InitPgm(BYTE * pLine); +STATIC VOID InitPgmHigh(BYTE * pLine); +STATIC VOID CfgSwitchar(BYTE * pLine); +STATIC VOID CfgFailure(BYTE * pLine); +STATIC VOID CfgIgnore(BYTE * pLine); +STATIC VOID CfgMenu(BYTE * pLine); +STATIC VOID DoMenu(void); +STATIC VOID CfgMenuDefault(BYTE * pLine); + +STATIC VOID Stacks(BYTE * pLine); +STATIC VOID SetAnyDos(BYTE * pLine); +STATIC VOID Numlock(BYTE * pLine); +STATIC BYTE * GetNumArg(BYTE * pLine, COUNT * pnArg); +BYTE *GetStringArg(BYTE * pLine, BYTE * pszString); +STATIC int SkipLine(char *pLine); +#if 0 +STATIC char * stristr(char *s1, char *s2); +#endif +STATIC COUNT strcasecmp(REG BYTE * d, REG BYTE * s); + +void HMAconfig(int finalize); VOID config_init_buffers(COUNT anzBuffers); /* from BLOCKIO.C */ -INIT STATIC VOID FAR *AlignParagraph(VOID FAR * lpPtr); +STATIC VOID FAR * AlignParagraph(VOID FAR * lpPtr); #ifndef I86 #define AlignParagraph(x) (x) #endif #define EOF 0x1a -INIT struct table *LookUp(struct table *p, BYTE * token); +STATIC struct table * LookUp(struct table *p, BYTE * token); + +typedef void config_sys_func_t(BYTE * pLine); struct table { BYTE *entry; BYTE pass; - VOID(*func) (BYTE * pLine); + config_sys_func_t *func; }; STATIC struct table commands[] = { + /* rem is never executed by locking out pass */ + {"REM", 0, CfgIgnore}, + {";", 0, CfgIgnore}, + + {"MENUDEFAULT", 0, CfgMenuDefault}, + {"MENU", 0, CfgMenu}, /* lines to print in pass 0 */ + {"ECHO", 2, CfgMenu}, /* lines to print in pass 2 - when devices are loaded */ + {"BREAK", 1, CfgBreak}, {"BUFFERS", 1, Config_Buffers}, {"COMMAND", 1, InitPgm}, {"COUNTRY", 1, Country}, - {"DEVICE", 2, Device}, - {"DEVICEHIGH", 2, DeviceHigh}, {"DOS", 1, Dosmem}, {"FCBS", 1, Fcbs}, {"FILES", 1, Files}, {"LASTDRIVE", 1, CfgLastdrive}, {"NUMLOCK", 1, Numlock}, - /* rem is never executed by locking out pass */ - {"REM", 0, CfgFailure}, - {";", 0, CfgFailure}, {"SHELL", 1, InitPgm}, {"SHELLHIGH", 1, InitPgmHigh}, {"STACKS", 1, Stacks}, @@ -196,13 +212,17 @@ STATIC struct table commands[] = { {"SCREEN", 1, sysScreenMode}, /* JPP */ {"VERSION", 1, sysVersion}, /* JPP */ {"ANYDOS", 1, SetAnyDos}, /* JPP */ + + {"DEVICE", 2, Device}, + {"DEVICEHIGH", 2, DeviceHigh}, + /* {"INSTALL", 3, install}, would go here */ + /* default action */ {"", -1, CfgFailure} }; #ifndef KDB -INIT BYTE FAR *KernelAlloc(WORD nBytes); -INIT BYTE FAR *KernelAllocDma(WORD); +BYTE FAR * KernelAlloc(WORD nBytes); #endif BYTE *pLineStart = 0; @@ -213,7 +233,7 @@ BYTE HMAState = 0; #define HMA_DONE 2 /* Moved kernel to HMA */ #define HMA_LOW 3 /* Definitely LOW */ -void FAR *ConfigAlloc(COUNT bytes) +STATIC void FAR* ConfigAlloc(COUNT bytes) { VOID FAR *p; @@ -229,10 +249,8 @@ void FAR *ConfigAlloc(COUNT bytes) /* Do first time initialization. Store last so that we can reset it */ /* later. */ -INIT void PreConfig(void) +void PreConfig(void) { - /* Set pass number */ - nPass = 0; VgaSet = 0; UmbState = 0; @@ -240,7 +258,7 @@ INIT void PreConfig(void) #ifdef DEBUG { - extern BYTE FAR internal_data[]; + extern BYTE FAR ASM internal_data[]; printf("SDA located at 0x%p\n", internal_data); } #endif @@ -307,17 +325,14 @@ INIT void PreConfig(void) /* We expect ram_top as Kbytes, so convert to paragraphs */ mcb_init(first_mcb, ram_top * 64 - first_mcb - 1); - nPass = 1; } /* Do second pass initialization. */ /* Also, run config.sys to load drivers. */ -INIT void PostConfig(void) +void PostConfig(void) { /* close all (device) files */ - /* Set pass number */ - nPass = 2; /* compute lastdrive ... */ lastdrive = Config.cfgLastdrive; if (lastdrive < nblkdev) @@ -387,7 +402,7 @@ INIT void PostConfig(void) } /* This code must be executed after device drivers has been loaded */ -INIT VOID configDone(VOID) +VOID configDone(VOID) { if (HMAState != HMA_DONE) { @@ -423,20 +438,21 @@ INIT VOID configDone(VOID) if (UmbState == 1) { + UCOUNT umr_new = FP_SEG(upBase) + ((FP_OFF(upBase) + 0x0f) >> 4); + mumcb_init(ram_top * 64 - 1, umb_start - 64 * ram_top); /* Check if any devices were loaded in umb */ if (umb_start != FP_SEG(upBase)) { /* make last block normal with SC for the devices */ - UCOUNT umr_new = FP_SEG(upBase) + ((FP_OFF(upBase) + 0x0f) >> 4); - mumcb_init(uppermem_root, umr_new - uppermem_root - 1); - uppermem_root = umr_new; - zumcb_init(uppermem_root, (umb_start + UMB_top) - uppermem_root - 1); + zumcb_init(umr_new, (umb_start + UMB_top) - umr_new - 1); upBase += 16; } + else + umr_new = FP_SEG(upBase); { /* are there any more UMB's ?? @@ -454,12 +470,12 @@ INIT VOID configDone(VOID) UCOUNT umb_seg, umb_size, umbz_root; - umbz_root = uppermem_root; + umbz_root = umr_new; if (UMB_get_largest(&umb_seg, &umb_size)) { - mcb_init(umbz_root, (umb_start + UMB_top) - uppermem_root - 1); + mcb_init(umbz_root, (umb_start + UMB_top) - umr_new - 1); /* change UMB 'Z' to 'M' */ ((mcb FAR *) MK_FP(umbz_root, 0))->m_type = 'M'; @@ -488,12 +504,16 @@ INIT VOID configDone(VOID) } -INIT VOID DoConfig(VOID) +VOID DoConfig(int pass) { COUNT nFileDesc; BYTE *pLine; BOOL bEof; + + /* Set pass number */ + nPass = pass; + /* Check to see if we have a config.sys file. If not, just */ /* exit since we don't force the user to have one. */ if ((nFileDesc = open("fdconfig.sys", 0)) >= 0) @@ -570,9 +590,17 @@ INIT VOID DoConfig(VOID) if (pEntry->pass >= 0 && pEntry->pass != nPass) continue; - - if (SkipLine(pLineStart)) /* F5/F8 processing */ + + if (nPass == 0) /* pass 0 always executed (rem Menu prompt) */ + { + (*(pEntry->func)) (pLine); continue; + } + else + { + if (SkipLine(pLineStart)) /* F5/F8 processing */ + continue; + } pLine = skipwh(pLine); @@ -603,10 +631,15 @@ INIT VOID DoConfig(VOID) } } - close(nFileDesc); + close(nFileDesc); + + if (nPass == 0) + { + DoMenu(); + } } -INIT struct table *LookUp(struct table *p, BYTE * token) +STATIC struct table * LookUp(struct table *p, BYTE * token) { while (*(p->entry) != '\0') { @@ -665,7 +698,7 @@ UWORD GetBiosKey(int timeout) return 0xffff; } -INIT BOOL SkipLine(char *pLine) +STATIC BOOL SkipLine(char *pLine) { short key; @@ -702,6 +735,16 @@ INIT BOOL SkipLine(char *pLine) if (SkipAllConfig) return TRUE; + /* 1?device=CDROM.SYS */ + /* 2?device=OAKROM.SYS */ + /* 3?device=EMM386.EXE NOEMS */ + if (MenuLine != 0 && + MenuSelected != MenuLine) + return TRUE; + + if (DontAskThisSingleCommand) /* !files=30 */ + return FALSE; + if (!askThisSingleCommand && !singleStep) return FALSE; @@ -743,7 +786,7 @@ INIT BOOL SkipLine(char *pLine) } -INIT BYTE *GetNumArg(BYTE * pLine, COUNT * pnArg) +STATIC BYTE * GetNumArg(BYTE * pLine, COUNT * pnArg) { /* look for NUMBER */ pLine = skipwh(pLine); @@ -755,7 +798,7 @@ INIT BYTE *GetNumArg(BYTE * pLine, COUNT * pnArg) return GetNumber(pLine, pnArg); } -INIT BYTE *GetStringArg(BYTE * pLine, BYTE * pszString) +BYTE *GetStringArg(BYTE * pLine, BYTE * pszString) { /* look for STRING */ pLine = skipwh(pLine); @@ -764,7 +807,7 @@ INIT BYTE *GetStringArg(BYTE * pLine, BYTE * pszString) return scan(pLine, pszString); } -INIT void Config_Buffers(BYTE * pLine) +STATIC void Config_Buffers(BYTE * pLine) { COUNT nBuffers; @@ -777,7 +820,7 @@ INIT void Config_Buffers(BYTE * pLine) (nBuffers < 0 ? nBuffers : max(Config.cfgBuffers, nBuffers)); } -INIT STATIC VOID sysScreenMode(BYTE * pLine) +STATIC VOID sysScreenMode(BYTE * pLine) { COUNT nMode; @@ -808,7 +851,7 @@ INIT STATIC VOID sysScreenMode(BYTE * pLine) #endif } -INIT STATIC VOID sysVersion(BYTE * pLine) +STATIC VOID sysVersion(BYTE * pLine) { COUNT major, minor; char *p; @@ -834,7 +877,7 @@ INIT STATIC VOID sysVersion(BYTE * pLine) os_minor = minor; } -INIT STATIC VOID Files(BYTE * pLine) +STATIC VOID Files(BYTE * pLine) { COUNT nFiles; @@ -846,7 +889,7 @@ INIT STATIC VOID Files(BYTE * pLine) Config.cfgFiles = max(Config.cfgFiles, nFiles); } -INIT STATIC VOID CfgLastdrive(BYTE * pLine) +STATIC VOID CfgLastdrive(BYTE * pLine) { /* Format: LASTDRIVE = letter */ BYTE drv; @@ -868,7 +911,7 @@ INIT STATIC VOID CfgLastdrive(BYTE * pLine) UmbState of confidence, 1 is sure, 2 maybe, 4 unknown and 0 no way. */ -INIT STATIC VOID Dosmem(BYTE * pLine) +STATIC VOID Dosmem(BYTE * pLine) { BYTE *pTmp; BYTE UMBwanted = FALSE; @@ -915,7 +958,7 @@ INIT STATIC VOID Dosmem(BYTE * pLine) } } -INIT STATIC VOID CfgSwitchar(BYTE * pLine) +STATIC VOID CfgSwitchar(BYTE * pLine) { /* Format: SWITCHAR = character */ @@ -923,7 +966,7 @@ INIT STATIC VOID CfgSwitchar(BYTE * pLine) switchar = *szBuf; } -INIT STATIC VOID Fcbs(BYTE * pLine) +STATIC VOID Fcbs(BYTE * pLine) { /* Format: FCBS = totalFcbs [,protectedFcbs] */ COUNT fcbs; @@ -953,7 +996,7 @@ INIT STATIC VOID Fcbs(BYTE * pLine) * Returns TRUE if successful, FALSE if not. */ -INIT BOOL LoadCountryInfo(char *filename, UWORD ctryCode, UWORD codePage) +STATIC BOOL LoadCountryInfo(char *filename, UWORD ctryCode, UWORD codePage) { /* printf("cntry: %u, CP%u, file=\"%s\"\n", ctryCode, codePage, filename); */ printf("Sorry, the COUNTRY= statement has been temporarily disabled\n"); @@ -965,7 +1008,7 @@ INIT BOOL LoadCountryInfo(char *filename, UWORD ctryCode, UWORD codePage) return FALSE; } -INIT STATIC VOID Country(BYTE * pLine) +STATIC VOID Country(BYTE * pLine) { /* Format: COUNTRY = countryCode, [codePage], filename */ COUNT ctryCode; @@ -1001,7 +1044,7 @@ INIT STATIC VOID Country(BYTE * pLine) CfgFailure(pLine); } -INIT STATIC VOID Stacks(BYTE * pLine) +STATIC VOID Stacks(BYTE * pLine) { COUNT stacks; @@ -1028,13 +1071,13 @@ INIT STATIC VOID Stacks(BYTE * pLine) } } -INIT STATIC VOID InitPgmHigh(BYTE * pLine) +STATIC VOID InitPgmHigh(BYTE * pLine) { InitPgm(pLine); Config.cfgP_0_startmode = 0x80; } -INIT STATIC VOID InitPgm(BYTE * pLine) +STATIC VOID InitPgm(BYTE * pLine) { /* Get the string argument that represents the new init pgm */ pLine = GetStringArg(pLine, Config.cfgInit); @@ -1049,14 +1092,14 @@ INIT STATIC VOID InitPgm(BYTE * pLine) Config.cfgP_0_startmode = 0; } -INIT STATIC VOID CfgBreak(BYTE * pLine) +STATIC VOID CfgBreak(BYTE * pLine) { /* Format: BREAK = (ON | OFF) */ GetStringArg(pLine, szBuf); break_ena = strcasecmp(szBuf, "OFF") ? 1 : 0; } -INIT STATIC VOID Numlock(BYTE * pLine) +STATIC VOID Numlock(BYTE * pLine) { extern VOID ASMCFUNC keycheck(); @@ -1070,7 +1113,7 @@ INIT STATIC VOID Numlock(BYTE * pLine) keycheck(); } -INIT STATIC VOID DeviceHigh(BYTE * pLine) +STATIC VOID DeviceHigh(BYTE * pLine) { if (UmbState == 1) { @@ -1087,12 +1130,12 @@ INIT STATIC VOID DeviceHigh(BYTE * pLine) } } -INIT void Device(BYTE * pLine) +STATIC void Device(BYTE * pLine) { LoadDevice(pLine, ram_top, FALSE); } -INIT BOOL LoadDevice(BYTE * pLine, COUNT top, COUNT mode) +STATIC BOOL LoadDevice(BYTE * pLine, COUNT top, COUNT mode) { exec_blk eb; struct dhdr FAR *dhp; @@ -1159,10 +1202,20 @@ INIT BOOL LoadDevice(BYTE * pLine, COUNT top, COUNT mode) return result; } -INIT STATIC VOID CfgFailure(BYTE * pLine) +STATIC VOID CfgFailure(BYTE * pLine) { BYTE *pTmp = pLineStart; + static UBYTE ErrorAlreadyPrinted[128]; + + /* suppress multiple printing of same unrecognized lines */ + if (nCfgLine < sizeof(ErrorAlreadyPrinted)*8) + { + if (ErrorAlreadyPrinted[nCfgLine/8] & (1 << (nCfgLine%8))) + return; + + ErrorAlreadyPrinted[nCfgLine/8] |= (1 << (nCfgLine%8)); + } printf("CONFIG.SYS error in line %d\n", nCfgLine); printf(">>>%s\n ", pTmp); while (++pTmp != pLine) @@ -1171,7 +1224,7 @@ INIT STATIC VOID CfgFailure(BYTE * pLine) } #ifndef KDB -INIT BYTE FAR *KernelAlloc(WORD nBytes) +BYTE FAR * KernelAlloc(WORD nBytes) { BYTE FAR *lpAllocated; @@ -1195,7 +1248,8 @@ INIT BYTE FAR *KernelAlloc(WORD nBytes) #endif #ifdef I86 -INIT BYTE FAR *KernelAllocDma(WORD bytes) +/* +STATIC BYTE FAR * KernelAllocDma(WORD bytes) { BYTE FAR *allocated; @@ -1206,8 +1260,9 @@ INIT BYTE FAR *KernelAllocDma(WORD bytes) lpBase += bytes; return allocated; } +*/ -INIT void FAR *AlignParagraph(VOID FAR * lpPtr) +STATIC void FAR * AlignParagraph(VOID FAR * lpPtr) { UWORD uSegVal; @@ -1223,18 +1278,38 @@ INIT void FAR *AlignParagraph(VOID FAR * lpPtr) } #endif -INIT BYTE *skipwh(BYTE * s) +STATIC BYTE * skipwh(BYTE * s) { while (*s && (*s == 0x0d || *s == 0x0a || *s == ' ' || *s == '\t')) ++s; return s; } -INIT BYTE *scan(BYTE * s, BYTE * d) +STATIC BYTE * scan(BYTE * s, BYTE * d) { askThisSingleCommand = FALSE; + DontAskThisSingleCommand = FALSE; s = skipwh(s); + + MenuLine = 0; + + /* does the line start with "1?" */ + + if (s[1] == '?' && s[0] >= '0' && s[0] <= '9') + { + MenuLine = s[0]; + Menus |= 1 << (MenuLine - '0'); + s = skipwh(s+2); + } + + /* !dos=high,umb ?? */ + if (*s == '!') + { + DontAskThisSingleCommand = TRUE; + s = skipwh(s+1); + } + if (*s == ';') { /* semicolon is a synonym for rem */ @@ -1258,7 +1333,7 @@ INIT BYTE *scan(BYTE * s, BYTE * d) } /* -INIT BYTE *scan_seperator(BYTE * s, BYTE * d) +BYTE *scan_seperator(BYTE * s, BYTE * d) { s = skipwh(s); if (*s) @@ -1268,13 +1343,13 @@ INIT BYTE *scan_seperator(BYTE * s, BYTE * d) } */ -INIT BOOL isnum(BYTE * pLine) +STATIC BOOL isnum(BYTE * pLine) { return (*pLine >= '0' && *pLine <= '9'); } /* JPP - changed so will accept hex number. */ -INIT BYTE *GetNumber(REG BYTE * pszString, REG COUNT * pnNum) +STATIC BYTE * GetNumber(REG BYTE * pszString, REG COUNT * pnNum) { BYTE Base = 10; BOOL Sign = FALSE; @@ -1303,7 +1378,7 @@ INIT BYTE *GetNumber(REG BYTE * pszString, REG COUNT * pnNum) /* Yet another change for true portability (WDL) */ #if 0 -INIT COUNT tolower(COUNT c) +STATIC COUNT tolower(COUNT c) { if (c >= 'A' && c <= 'Z') return (c + ('a' - 'A')); @@ -1313,7 +1388,7 @@ INIT COUNT tolower(COUNT c) #endif /* Yet another change for true portability (PJV) */ -INIT COUNT toupper(COUNT c) +STATIC COUNT toupper(COUNT c) { if (c >= 'a' && c <= 'z') return (c - ('a' - 'A')); @@ -1324,7 +1399,7 @@ INIT COUNT toupper(COUNT c) /* The following code is 8086 dependant */ #if 1 /* ifdef KERNEL */ -INIT VOID mcb_init(UCOUNT seg, UWORD size) +STATIC VOID mcb_init(UCOUNT seg, UWORD size) { COUNT i; @@ -1344,7 +1419,7 @@ INIT VOID mcb_init(UCOUNT seg, UWORD size) mem_access_mode = FIRST_FIT; } -INIT VOID zumcb_init(UCOUNT seg, UWORD size) +STATIC VOID zumcb_init(UCOUNT seg, UWORD size) { COUNT i; mcb FAR *mcbp = MK_FP(seg, 0); @@ -1357,7 +1432,7 @@ INIT VOID zumcb_init(UCOUNT seg, UWORD size) } -INIT VOID mumcb_init(UCOUNT seg, UWORD size) +STATIC VOID mumcb_init(UCOUNT seg, UWORD size) { COUNT i; mcb FAR *mcbp = MK_FP(seg, 0); @@ -1372,15 +1447,16 @@ INIT VOID mumcb_init(UCOUNT seg, UWORD size) } #endif -INIT VOID strcat(REG BYTE * d, REG BYTE * s) +VOID strcat(REG BYTE * d, REG BYTE * s) { while (*d != 0) ++d; strcpy(d, s); } +#if 0 /* see if the second string is contained in the first one, ignoring case */ -char *stristr(char *s1, char *s2) +STATIC char * stristr(char *s1, char *s2) { int loop; @@ -1397,9 +1473,10 @@ char *stristr(char *s1, char *s2) return NULL; } +#endif /* compare two ASCII strings ignoring case */ -INIT COUNT strcasecmp(REG BYTE * d, REG BYTE * s) +STATIC COUNT strcasecmp(REG BYTE * d, REG BYTE * s) { while (*s != '\0' && *d != '\0') { @@ -1513,12 +1590,117 @@ VOID config_init_buffers(COUNT anzBuffers) they expect. be careful with it! */ -INIT VOID SetAnyDos(BYTE * pLine) +STATIC VOID SetAnyDos(BYTE * pLine) { UNREFERENCED_PARAMETER(pLine); ReturnAnyDosVersionExpected = TRUE; } +STATIC VOID CfgIgnore(BYTE * pLine) +{ + UNREFERENCED_PARAMETER(pLine); +} + +/* + 'MENU'ing stuff + + although it's worse then MSDOS's , its better then nothing + +*/ + +STATIC VOID CfgMenu(BYTE * pLine) +{ + printf("%s\n",pLine); +} + +STATIC VOID DoMenu(void) +{ + if (Menus == 0) + return; + + Menus |= 1 << 0; /* '0' Menu always allowed */ + + printf("\n\n"); + + for (;;) + { + int key,i; + + printf("\rSinglestepping (F8) is :%s - ", singleStep ? "ON " : "OFF"); + + printf("please select a Menu["); + + for (i = 0; i <= 9; i++) + if (Menus & (1 << i)) + printf("%c", '0' + i); + printf("]"); + + key = GetBiosKey(MenuTimeout); + + MenuTimeout = -1; + + if (key == -1) /* timeout, take default */ + { + break; + } + + if (key == 0x3f00) /* F5 */ + { + SkipAllConfig = TRUE; + break; + } + if (key == 0x4200) /* F8 */ + { + singleStep = !singleStep; + } + + key &= 0xff; + + if (key == '\r') /* CR - use default */ + { + break; + } + if (key == 0x1b) /* ESC - use default */ + { + break; + } + + printf("%c", key); + + if (key >= '0' && key <= '9') + if (Menus & (1 << (key - '0'))) + { + MenuSelected = key; break; + } + } + printf("\n"); +} + +STATIC VOID CfgMenuDefault(BYTE * pLine) +{ + COUNT num = 0; + + pLine = skipwh(pLine); + + if ('=' != *pLine) + { + CfgFailure(pLine); + return; + } + pLine = skipwh(pLine + 1); + + /* Format: STACKS = stacks [, stackSize] */ + pLine = GetNumArg(pLine, &num); + MenuSelected = '0' + num; + pLine = skipwh(pLine); + + if (*pLine == ',') + { + GetNumArg(++pLine, &MenuTimeout); + } +} + + /* * Log: config.c,v - for newer log entries see "cvs log config.c" * diff --git a/kernel/dosfns.c b/kernel/dosfns.c index ae286847..0ea550d4 100644 --- a/kernel/dosfns.c +++ b/kernel/dosfns.c @@ -36,7 +36,7 @@ static BYTE *dosfnsRcsId = #include "globals.h" COUNT get_free_hndl(VOID); -sft FAR *get_free_sft(COUNT *); +sft FAR * get_free_sft(COUNT *); BOOL cmatch(COUNT, COUNT, COUNT); f_node_ptr xlt_fd(COUNT); @@ -51,14 +51,14 @@ BYTE share_installed = 0; error. If < 0 is returned, it is the negated error return code, so DOS simply negates this value and returns it in AX. */ -static int share_open_check(char far * filename, /* far pointer to fully qualified filename */ +STATIC int share_open_check(char far * filename, /* far pointer to fully qualified filename */ unsigned short pspseg, /* psp segment address of owner process */ int openmode, /* 0=read-only, 1=write-only, 2=read-write */ int sharemode); /* SHARE_COMPAT, etc... */ /* DOS calls this to record the fact that it has successfully closed a file, or the fact that the open for this file failed. */ -static void share_close_file(int fileno); /* file_table entry number */ +STATIC void share_close_file(int fileno); /* file_table entry number */ /* DOS calls this to determine whether it can access (read or write) a specific section of a file. We call it internally @@ -71,7 +71,7 @@ static void share_close_file(int fileno); /* file_table entry number */ generates a critical error (if allowcriter is non-zero). If non-zero is returned, it is the negated return value for the DOS call. */ -static int share_access_check(unsigned short pspseg, /* psp segment address of owner process */ +STATIC int share_access_check(unsigned short pspseg, /* psp segment address of owner process */ int fileno, /* file_table entry number */ unsigned long ofs, /* offset into file */ unsigned long len, /* length (in bytes) of region to access */ @@ -82,7 +82,7 @@ static int share_access_check(unsigned short pspseg, /* psp segment address o returns non-zero. If the return value is non-zero, it is the negated error return code for the DOS 0x5c call. */ -static int share_lock_unlock(unsigned short pspseg, /* psp segment address of owner process */ +STATIC int share_lock_unlock(unsigned short pspseg, /* psp segment address of owner process */ int fileno, /* file_table entry number */ unsigned long ofs, /* offset into file */ unsigned long len, /* length (in bytes) of region to lock or unlock */ @@ -90,8 +90,14 @@ static int share_lock_unlock(unsigned short pspseg, /* psp segment address o /* /// End of additions for SHARE. - Ron Cemer */ +STATIC int remote_lock_unlock(sft FAR *sftp, /* SFT for file */ + unsigned long ofs, /* offset into file */ + unsigned long len, /* length (in bytes) of region to lock or unlock */ + int unlock); /* non-zero to unlock; zero to lock */ + + #ifdef WITHFAT32 -struct dpb FAR *GetDriveDPB(UBYTE drive, COUNT * rc) +struct dpb FAR * GetDriveDPB(UBYTE drive, COUNT * rc) { struct dpb FAR *dpb; drive = drive == 0 ? default_drive : drive - 1; @@ -114,7 +120,7 @@ struct dpb FAR *GetDriveDPB(UBYTE drive, COUNT * rc) } #endif -static VOID DosGetFile(BYTE * lpszPath, BYTE FAR * lpszDosFileName) +STATIC VOID DosGetFile(BYTE * lpszPath, BYTE FAR * lpszDosFileName) { BYTE szLclName[FNAME_SIZE + 1]; BYTE szLclExt[FEXT_SIZE + 1]; @@ -127,7 +133,7 @@ static VOID DosGetFile(BYTE * lpszPath, BYTE FAR * lpszDosFileName) fmemcpy(&lpszDosFileName[FNAME_SIZE], (BYTE FAR *) szLclExt, FEXT_SIZE); } -sft FAR *idx_to_sft(COUNT SftIndex) +sft FAR * idx_to_sft(COUNT SftIndex) { sfttbl FAR *sp; @@ -151,7 +157,7 @@ sft FAR *idx_to_sft(COUNT SftIndex) return (sft FAR *) - 1; } -STATIC COUNT get_sft_idx(UCOUNT hndl) +COUNT get_sft_idx(UCOUNT hndl) { psp FAR *p = MK_FP(cu_psp, 0); @@ -595,7 +601,7 @@ sft FAR *get_free_sft(COUNT * sft_idx) /* MS NET uses this on open/creat TE */ { - extern WORD current_sft_idx; + extern WORD ASM current_sft_idx; current_sft_idx = sys_idx; } @@ -622,7 +628,7 @@ BYTE FAR *get_root(BYTE FAR * fname) } /* Ascii only file name match routines */ -static BOOL cmatch(COUNT s, COUNT d, COUNT mode) +STATIC BOOL cmatch(COUNT s, COUNT d, COUNT mode) { if (s >= 'a' && s <= 'z') s -= 'a' - 'A'; @@ -669,7 +675,7 @@ COUNT DosCreatSft(BYTE * fname, COUNT attrib) sftp->sft_mode = SFT_MRDWR; sftp->sft_attrib = attrib; sftp->sft_psp = cu_psp; - + /* check for a device */ dhp = IsDevice(fname); if (dhp) @@ -681,6 +687,8 @@ COUNT DosCreatSft(BYTE * fname, COUNT attrib) fmemcpy(sftp->sft_name, (BYTE FAR *) SecPathName, FNAME_SIZE + FEXT_SIZE); sftp->sft_dev = dhp; + sftp->sft_date = dos_getdate(); + sftp->sft_time = dos_gettime(); return sft_idx; } @@ -717,6 +725,9 @@ COUNT DosCreatSft(BYTE * fname, COUNT attrib) sftp->sft_count += 1; sftp->sft_flags = drive; DosGetFile(fname, sftp->sft_name); + dos_getftime(sftp->sft_status, + (date FAR *) & sftp->sft_date, + (time FAR *) & sftp->sft_time); return sft_idx; } else @@ -843,16 +854,6 @@ COUNT DosOpenSft(BYTE * fname, COUNT mode) struct dhdr FAR *dhp; COUNT drive, result; - OpenMode = (BYTE) mode; - - /* test if mode is in range */ - if ((mode & ~SFT_OMASK) != 0) - return DE_INVLDACC; - - mode &= 3; - - OpenMode = (BYTE) mode; - /* now get a free system file table entry */ if ((sftp = get_free_sft(&sft_idx)) == (sft FAR *) - 1) return DE_TOOMANY; @@ -860,7 +861,8 @@ COUNT DosOpenSft(BYTE * fname, COUNT mode) fmemset(sftp, 0, sizeof(sft)); sftp->sft_psp = cu_psp; sftp->sft_mode = mode; - + OpenMode = (BYTE) mode; + /* check for a device */ dhp = IsDevice(fname); if (dhp) @@ -954,6 +956,10 @@ COUNT DosOpen(BYTE FAR * fname, COUNT mode) psp FAR *p = MK_FP(cu_psp, 0); COUNT sft_idx, result, hndl; + /* test if mode is in range */ + if ((mode & ~SFT_OMASK) != 0) + return DE_INVLDACC; + /* get a free handle */ if ((hndl = get_free_hndl()) < 0) return hndl; @@ -964,7 +970,7 @@ COUNT DosOpen(BYTE FAR * fname, COUNT mode) return result; } - sft_idx = DosOpenSft(PriPathName, mode); + sft_idx = DosOpenSft(PriPathName, mode & 3); if (sft_idx < SUCCESS) return sft_idx; @@ -973,7 +979,7 @@ COUNT DosOpen(BYTE FAR * fname, COUNT mode) return hndl; } -COUNT DosCloseSft(WORD sft_idx) +COUNT DosCloseSft(WORD sft_idx, BOOL commitonly) { sft FAR *sftp = idx_to_sft(sft_idx); @@ -991,31 +997,32 @@ COUNT DosCloseSft(WORD sft_idx) if (sftp->sft_flags & SFT_FSHARED) { /* printf("closing SFT %d = %p\n",sft_idx,sftp); */ - return remote_close(sftp); + return (commitonly ? remote_commit(sftp) : remote_close(sftp)); } /* now just drop the count if a device, else */ /* call file system handler */ - sftp->sft_count -= 1; + if (!commitonly) + sftp->sft_count -= 1; + if (sftp->sft_flags & SFT_FDEVICE) return SUCCESS; - else - { - if (sftp->sft_count > 0) - return SUCCESS; - else - { + + if (commitonly) + return dos_commit(sftp->sft_status); + + if (sftp->sft_count > 0) + return SUCCESS; + /* /// Added for SHARE *** CURLY BRACES ADDED ALSO!!! ***. - Ron Cemer */ - if (IsShareInstalled()) - { - if (sftp->sft_shroff >= 0) - share_close_file(sftp->sft_shroff); - sftp->sft_shroff = -1; - } -/* /// End of additions for SHARE. - Ron Cemer */ - return dos_close(sftp->sft_status); - } + if (IsShareInstalled()) + { + if (sftp->sft_shroff >= 0) + share_close_file(sftp->sft_shroff); + sftp->sft_shroff = -1; } +/* /// End of additions for SHARE. - Ron Cemer */ + return dos_close(sftp->sft_status); } COUNT DosClose(COUNT hndl) @@ -1024,7 +1031,7 @@ COUNT DosClose(COUNT hndl) COUNT ret; /* Get the SFT block that contains the SFT */ - ret = DosCloseSft(get_sft_idx(hndl)); + ret = DosCloseSft(get_sft_idx(hndl), FALSE); if (ret != DE_INVLDHNDL && ret != DE_ACCESS) p->ps_filetab[hndl] = 0xff; return ret; @@ -1705,14 +1712,17 @@ COUNT DosLockUnlock(COUNT hndl, LONG pos, LONG len, COUNT unlock) { sft FAR *s; - /* Invalid function unless SHARE is installed. */ - if (!IsShareInstalled()) - return DE_INVLDFUNC; - /* Get the SFT block that contains the SFT */ if ((s = get_sft(hndl)) == (sft FAR *) - 1) return DE_INVLDHNDL; + if (s->sft_flags & SFT_FSHARED) + return remote_lock_unlock(s, pos, len, unlock); + + /* Invalid function unless SHARE is installed or remote. */ + if (!IsShareInstalled()) + return DE_INVLDFUNC; + /* Lock violation if this SFT entry does not support locking. */ if (s->sft_shroff < 0) return DE_LOCK; @@ -1806,7 +1816,7 @@ BOOL IsShareInstalled(void) error. If < 0 is returned, it is the negated error return code, so DOS simply negates this value and returns it in AX. */ -static int share_open_check(char far * filename, /* far pointer to fully qualified filename */ +STATIC int share_open_check(char far * filename, /* far pointer to fully qualified filename */ unsigned short pspseg, /* psp segment address of owner process */ int openmode, /* 0=read-only, 1=write-only, 2=read-write */ int sharemode) @@ -1825,7 +1835,7 @@ static int share_open_check(char far * filename, /* far pointer to fully /* DOS calls this to record the fact that it has successfully closed a file, or the fact that the open for this file failed. */ -static void share_close_file(int fileno) +STATIC void share_close_file(int fileno) { /* file_table entry number */ iregs regs; @@ -1845,7 +1855,7 @@ static void share_close_file(int fileno) generates a critical error (if allowcriter is non-zero). If non-zero is returned, it is the negated return value for the DOS call. */ -static int share_access_check(unsigned short pspseg, /* psp segment address of owner process */ +STATIC int share_access_check(unsigned short pspseg, /* psp segment address of owner process */ int fileno, /* file_table entry number */ unsigned long ofs, /* offset into file */ unsigned long len, /* length (in bytes) of region to access */ @@ -1869,7 +1879,7 @@ static int share_access_check(unsigned short pspseg, /* psp segment address o returns non-zero. If the return value is non-zero, it is the negated error return code for the DOS 0x5c call. */ -static int share_lock_unlock(unsigned short pspseg, /* psp segment address of owner process */ +STATIC int share_lock_unlock(unsigned short pspseg, /* psp segment address of owner process */ int fileno, /* file_table entry number */ unsigned long ofs, /* offset into file */ unsigned long len, /* length (in bytes) of region to lock or unlock */ @@ -1889,6 +1899,27 @@ static int share_lock_unlock(unsigned short pspseg, /* psp segment address o } /* /// End of additions for SHARE. - Ron Cemer */ +STATIC int remote_lock_unlock(sft FAR *sftp, /* SFT for file */ + unsigned long ofs, /* offset into file */ + unsigned long len, /* length (in bytes) of region to lock or unlock */ + int unlock) +{ /* non-zero to unlock; zero to lock */ + iregs regs; + unsigned long param_block[2]; + param_block[0] = ofs; + param_block[1] = len; + + regs.a.x = 0x110a; + regs.b.b.l = (unlock ? 0x01 : 0x00); + regs.c.x = 1; + regs.ds = FP_SEG(param_block); + regs.d.x = FP_OFF(param_block); + regs.es = FP_SEG(sftp); + regs.di = FP_OFF(sftp); + intr(0x2f, ®s); + return ((regs.flags & 1) ? -(int)regs.a.b.l : 0); +} + /* * diff --git a/kernel/dsk.c b/kernel/dsk.c index be89ccbe..dbdc2fa3 100644 --- a/kernel/dsk.c +++ b/kernel/dsk.c @@ -59,28 +59,24 @@ extern COUNT ASMCFUNC fl_lba_ReadWrite(BYTE drive, WORD mode, struct _bios_LBA_address_packet FAR * dap_p); -int LBA_Transfer(ddt * pddt, UWORD mode, VOID FAR * buffer, +STATIC int LBA_Transfer(ddt * pddt, UWORD mode, VOID FAR * buffer, ULONG LBA_address, unsigned total, UWORD * transferred); #else -BOOL fl_reset(); -COUNT fl_readdasd(); -COUNT fl_diskchanged(); -COUNT fl_rd_status(); -COUNT fl_format(); -COUNT fl_read(); -COUNT fl_write(); -COUNT fl_verify(); -VOID fl_readkey(); -COUNT fl_setmediatype(); -COUNT fl_setdisktype(); +BOOL ASMCFUNC fl_reset(); +COUNT ASMCFUNC fl_readdasd(); +COUNT ASMCFUNC fl_diskchanged(); +COUNT ASMCFUNC fl_rd_status(); +COUNT ASMCFUNC fl_format(); +COUNT ASMCFUNC fl_read(); +COUNT ASMCFUNC fl_write(); +COUNT ASMCFUNC fl_verify(); +VOID ASMCFUNC fl_readkey(); +COUNT ASMCFUNC fl_setmediatype(); +COUNT ASMCFUNC fl_setdisktype(); #endif #define NENTRY 26 /* total size of dispatch table */ -extern BYTE FAR nblk_rel; - -extern int FAR ASMCFUNC Get_nblk_rel(void); - #define LBA_READ 0x4200 #define LBA_WRITE 0x4300 UWORD LBA_WRITE_VERIFY = 0x4302; @@ -106,7 +102,7 @@ struct FS_info { BYTE fstype[8]; }; -extern struct DynS Dyn; +extern struct DynS ASM Dyn; /*TE - array access functions */ ddt *getddt(int dev) @@ -114,6 +110,20 @@ ddt *getddt(int dev) return &(((ddt *) Dyn.Buffer)[dev]); } +ULONG dsk_lasttime = 0; + +STATIC VOID tmark(ddt *pddt) +{ + ReadPCClock(&pddt->ddt_fh.ddt_lasttime); +} + +STATIC BOOL tdelay(ddt *pddt, ULONG ticks) +{ + ULONG now; + ReadPCClock(&now); + return now - pddt->ddt_fh.ddt_lasttime >= ticks; +} + #define N_PART 4 /* number of partitions per table partition */ @@ -122,44 +132,26 @@ COUNT nUnits; /* number of returned units */ #define PARTOFF 0x1be #ifdef PROTO -WORD -_dsk_init(rqptr rq, ddt * pddt), -mediachk(rqptr rq, ddt * pddt), -bldbpb(rqptr rq, ddt * pddt), -blockio(rqptr rq, ddt * pddt), -IoctlQueblk(rqptr rq, ddt * pddt), -Genblkdev(rqptr rq, ddt * pddt), -Getlogdev(rqptr rq, ddt * pddt), -Setlogdev(rqptr rq, ddt * pddt), -blk_Open(rqptr rq, ddt * pddt), -blk_Close(rqptr rq, ddt * pddt), -blk_Media(rqptr rq, ddt * pddt), -blk_noerr(rqptr rq, ddt * pddt), -blk_nondr(rqptr rq, ddt * pddt), blk_error(rqptr rq, ddt * pddt); -WORD dskerr(COUNT); +typedef WORD dsk_proc(rqptr rq, ddt * pddt); #else -WORD _dsk_init(), -mediachk(), -bldbpb(), -blockio(), -IoctlQueblk(), -Genblkdev(), -Getlogdev(), -Setlogdev(), -blk_Open(), -blk_Close(), blk_Media(), blk_noerr(), blk_nondr(), blk_error(); -WORD dskerr(); +typedef WORD dsk_proc(); #endif -/* */ -/* the function dispatch table */ -/* */ +STATIC dsk_proc _dsk_init, mediachk, bldbpb, blockio, IoctlQueblk, + Genblkdev, Getlogdev, Setlogdev, blk_Open, blk_Close, + blk_Media, blk_noerr, blk_nondr, blk_error; #ifdef PROTO -static WORD(*dispatch[NENTRY]) (rqptr rq, ddt * pddt) = +STATIC WORD dskerr(COUNT); #else -static WORD(*dispatch[NENTRY]) () = +STATIC WORD dskerr(); #endif + +/* */ +/* the function dispatch table */ +/* */ + +static dsk_proc (*dispatch[NENTRY]) = { _dsk_init, /* Initialize */ mediachk, /* Media Check */ @@ -195,7 +187,7 @@ static WORD(*dispatch[NENTRY]) () = /* F U N C T I O N S --------------------------------------------------- */ /* ----------------------------------------------------------------------- */ -COUNT FAR ASMCFUNC blk_driver(rqptr rp) +COUNT ASMCFUNC FAR blk_driver(rqptr rp) { if (rp->r_unit >= nUnits && rp->r_command != C_INIT) return failure(E_UNIT); @@ -208,7 +200,7 @@ COUNT FAR ASMCFUNC blk_driver(rqptr rp) } /* disk init is done in diskinit.c, so this should never be called */ -WORD _dsk_init(rqptr rp, ddt * pddt) +STATIC WORD _dsk_init(rqptr rp, ddt * pddt) { UNREFERENCED_PARAMETER(rp); UNREFERENCED_PARAMETER(pddt); @@ -267,10 +259,10 @@ STATIC WORD diskchange(ddt * pddt) } /* can not detect or error... */ - return tdelay((LONG) 37) ? M_DONT_KNOW : M_NOT_CHANGED; + return tdelay(pddt, 37ul) ? M_DONT_KNOW : M_NOT_CHANGED; } -WORD mediachk(rqptr rp, ddt * pddt) +STATIC WORD mediachk(rqptr rp, ddt * pddt) { /* check floppy status */ if (pddt->ddt_descflags & DF_REFORMAT) @@ -306,29 +298,53 @@ STATIC WORD RWzero(ddt * pddt, UWORD mode) 0 if not set, 1 = a, 2 = b, etc, assume set. page 424 MS Programmer's Ref. */ -static WORD Getlogdev(rqptr rp, ddt * pddt) +STATIC WORD Getlogdev(rqptr rp, ddt * pddt) { - BYTE x = rp->r_unit; + int i; + ddt *pddt2 = getddt(0); - UNREFERENCED_PARAMETER(pddt); + if (!(pddt->ddt_descflags & DF_MULTLOG)) { + rp->r_unit = 0; + return S_DONE; + } - x++; - if (x > Get_nblk_rel()) - return failure(E_UNIT); + for (i = 0; i < nUnits; i++, pddt2++) + { + if (pddt->ddt_driveno == pddt2->ddt_driveno && + (pddt2->ddt_descflags & (DF_MULTLOG | DF_CURLOG)) == + (DF_MULTLOG | DF_CURLOG)) + break; + } - rp->r_unit = x; + rp->r_unit = i+1; return S_DONE; } -static WORD Setlogdev(rqptr rp, ddt * pddt) +STATIC WORD Setlogdev(rqptr rp, ddt * pddt) { - UNREFERENCED_PARAMETER(rp); - UNREFERENCED_PARAMETER(pddt); + int i; + ddt *pddt2 = getddt(0); + if (!(pddt->ddt_descflags & DF_MULTLOG)) { + rp->r_unit = 0; + return S_DONE; + } + + for (i = 0; i < nUnits; i++, pddt2++) + { + if (pddt->ddt_driveno == pddt2->ddt_driveno && + (pddt2->ddt_descflags & (DF_MULTLOG | DF_CURLOG)) == + (DF_MULTLOG | DF_CURLOG)) + break; + } + + pddt2->ddt_descflags &= ~DF_CURLOG; + pddt->ddt_descflags |= DF_CURLOG; + rp->r_unit++; return S_DONE; } -static WORD blk_Open(rqptr rp, ddt * pddt) +STATIC WORD blk_Open(rqptr rp, ddt * pddt) { UNREFERENCED_PARAMETER(rp); @@ -336,7 +352,7 @@ static WORD blk_Open(rqptr rp, ddt * pddt) return S_DONE; } -static WORD blk_Close(rqptr rp, ddt * pddt) +STATIC WORD blk_Close(rqptr rp, ddt * pddt) { UNREFERENCED_PARAMETER(rp); @@ -344,7 +360,7 @@ static WORD blk_Close(rqptr rp, ddt * pddt) return S_DONE; } -static WORD blk_nondr(rqptr rp, ddt * pddt) +STATIC WORD blk_nondr(rqptr rp, ddt * pddt) { UNREFERENCED_PARAMETER(rp); UNREFERENCED_PARAMETER(pddt); @@ -352,7 +368,7 @@ static WORD blk_nondr(rqptr rp, ddt * pddt) return S_BUSY | S_DONE; } -static WORD blk_Media(rqptr rp, ddt * pddt) +STATIC WORD blk_Media(rqptr rp, ddt * pddt) { UNREFERENCED_PARAMETER(rp); @@ -362,13 +378,16 @@ static WORD blk_Media(rqptr rp, ddt * pddt) return S_DONE; /* Floppy */ } -static WORD getbpb(ddt * pddt) +STATIC WORD getbpb(ddt * pddt) { ULONG count; bpb *pbpbarray = &pddt->ddt_bpb; WORD head, /*track, */ sector, ret; - pddt->ddt_descflags |= DF_NOACCESS; /* set drive to not accessible and changed */ + /* pddt->ddt_descflags |= DF_NOACCESS; + * disabled for now - problems with FORMAT ?? */ + + /* set drive to not accessible and changed */ if (diskchange(pddt) != M_NOT_CHANGED) pddt->ddt_descflags |= DF_DISKCHANGE; @@ -447,12 +466,12 @@ static WORD getbpb(ddt * pddt) if (head == 0 || sector == 0) { - tmark(); + tmark(pddt); return failure(E_FAILURE); } pddt->ddt_ncyl = (count + head * sector - 1) / (head * sector); - tmark(); + tmark(pddt); #ifdef DSK_DEBUG printf("BPB_NSECS = %04x\n", sector); @@ -475,7 +494,7 @@ STATIC WORD bldbpb(rqptr rp, ddt * pddt) return S_DONE; } -static WORD IoctlQueblk(rqptr rp, ddt * pddt) +STATIC WORD IoctlQueblk(rqptr rp, ddt * pddt) { UNREFERENCED_PARAMETER(pddt); @@ -494,7 +513,7 @@ static WORD IoctlQueblk(rqptr rp, ddt * pddt) } -COUNT Genblockio(ddt * pddt, UWORD mode, WORD head, WORD track, +STATIC COUNT Genblockio(ddt * pddt, UWORD mode, WORD head, WORD track, WORD sector, WORD count, VOID FAR * buffer) { UWORD transferred; @@ -753,7 +772,7 @@ STATIC WORD Genblkdev(rqptr rp, ddt * pddt) return S_DONE; } -WORD blockio(rqptr rp, ddt * pddt) +STATIC WORD blockio(rqptr rp, ddt * pddt) { ULONG start, size; WORD ret; @@ -776,10 +795,10 @@ WORD blockio(rqptr rp, ddt * pddt) return failure(E_FAILURE); } - if (pddt->ddt_descflags & 0x200) /* drive inaccessible */ + if (pddt->ddt_descflags & DF_NOACCESS) /* drive inaccessible */ return failure(E_FAILURE); - tmark(); + tmark(pddt); start = (rp->r_start != HUGECOUNT ? rp->r_start : rp->r_huge); pbpb = hd(pddt->ddt_descflags) ? &pddt->ddt_defbpb : &pddt->ddt_bpb; size = (pbpb->bpb_nsize ? pbpb->bpb_nsize : pbpb->bpb_huge); @@ -854,7 +873,7 @@ STATIC WORD dskerr(COUNT code) translate LBA sectors into CHS addressing */ -void LBA_to_CHS(struct CHS *chs, ULONG LBA_address, ddt * pddt) +STATIC void LBA_to_CHS(struct CHS *chs, ULONG LBA_address, ddt * pddt) { /* we need the defbpb values since those are taken from the BIOS, not from some random boot sector, except when @@ -916,7 +935,7 @@ STATIC unsigned DMA_max_transfer(void FAR * buffer, unsigned count) */ -int LBA_Transfer(ddt * pddt, UWORD mode, VOID FAR * buffer, +STATIC int LBA_Transfer(ddt * pddt, UWORD mode, VOID FAR * buffer, ULONG LBA_address, unsigned totaltodo, UWORD * transferred) { diff --git a/kernel/dyndata.c b/kernel/dyndata.c deleted file mode 100644 index 30f46d6b..00000000 --- a/kernel/dyndata.c +++ /dev/null @@ -1,13 +0,0 @@ -/* - DYNDATA.C - - this serves as a placeholder in the near data segment - - alll data herein goes to special segment - DYN_DATA AFTER BSS, but immediately before HMA_TEXT -*/ -#include "portab.h" -#include "init-mod.h" -#include "dyndata.h" - -struct DynS Dyn = { 0 }; diff --git a/kernel/dyninit.c b/kernel/dyninit.c index 02355d87..94aebd0e 100644 --- a/kernel/dyninit.c +++ b/kernel/dyninit.c @@ -49,9 +49,9 @@ kernel layout: #ifndef __TURBOC__ #include "init-dat.h" -extern struct DynS DOSFAR Dyn; +extern struct DynS DOSFAR ASM Dyn; #else -extern struct DynS FAR Dyn; +extern struct DynS FAR ASM Dyn; #endif void far *DynAlloc(char *what, unsigned num, unsigned size) @@ -85,7 +85,7 @@ void DynFree(void *ptr) Dyn.Allocated = (char *)ptr - (char *)Dyn.Buffer; } -void FAR *DynLast() +void FAR * DynLast() { DebugPrintf(("dynamic data end at %p\n", (void FAR *)(Dyn.Buffer + Dyn.Allocated))); diff --git a/kernel/error.c b/kernel/error.c index 52131a6d..cbfdd09c 100644 --- a/kernel/error.c +++ b/kernel/error.c @@ -39,8 +39,8 @@ static BYTE *errorRcsId = /* error registers */ VOID dump(void) { - printf("Register Dump [AH = %02x CS:IP = %04x:%04x]\n", - error_regs.AH, error_regs.CS, error_regs.IP); + printf("Register Dump [AH = %02x CS:IP = %04x:%04x FLAGS = %04x]\n", + error_regs.AH, error_regs.CS, error_regs.IP, error_regs.FLAGS); printf("AX:%04x BX:%04x CX:%04x DX:%04x\n", error_regs.AX, error_regs.BX, error_regs.CX, error_regs.DX); printf("SI:%04x DI:%04x DS:%04x ES:%04x\n", diff --git a/kernel/execrh.asm b/kernel/execrh.asm index 3654e975..42868a2d 100644 --- a/kernel/execrh.asm +++ b/kernel/execrh.asm @@ -55,11 +55,10 @@ _execrh: mov ax, [si+6] ; construct strategy address mov [bp+8], ax - mov si, [si+8] ; save 'interrupt' address - call far[bp+8] ; call far the strategy - mov [bp+8],si ; construct interrupt address + mov ax,[si+8] ; construct 'interrupt' address + mov [bp+8],ax ; construct interrupt address call far[bp+8] ; call far the interrupt sti ; damm driver turn off ints diff --git a/kernel/fatdir.c b/kernel/fatdir.c index 89fbf375..a239069a 100644 --- a/kernel/fatdir.c +++ b/kernel/fatdir.c @@ -196,7 +196,8 @@ f_node_ptr dir_open(BYTE * dirname) while (dir_read(fnp) == 1) { if (fnp->f_dir.dir_name[0] != '\0' - && fnp->f_dir.dir_name[0] != DELETED) + && fnp->f_dir.dir_name[0] != DELETED + && !(fnp->f_dir.dir_attrib & D_VOLID)) { if (fcmp (TempBuffer, (BYTE *) fnp->f_dir.dir_name, @@ -319,6 +320,11 @@ COUNT dir_read(REG f_node_ptr fnp) /* Description. * Writes directory entry pointed by fnp to disk. In case of erroneous * situation fnode is released. + * The caller should set + * 1. f_dmod flag if original directory entry was modified. + * 2. f_dmod & f_dnew flags if new directory entry is created. In this + * case the reserved fields is cleared, but only if new dentry isn't + * a LFN entry (has D_LFN attribute). * Return value. * TRUE - all OK. * FALSE - error occured (fnode is released). @@ -406,8 +412,6 @@ BOOL dir_write(REG f_node_ptr fnp) VOID dir_close(REG f_node_ptr fnp) { - REG COUNT disk = fnp->f_dpb->dpb_unit; - /* Test for invalid f_nodes */ if (fnp == NULL) return; @@ -418,7 +422,7 @@ VOID dir_close(REG f_node_ptr fnp) #endif /* Clear buffers after release */ - flush_buffers(disk); + flush_buffers(fnp->f_dpb->dpb_unit); /* and release this instance of the fnode */ release_f_node(fnp); @@ -517,6 +521,9 @@ COUNT dos_findfirst(UCOUNT attr, BYTE * name) { dmp->dm_dircluster = fnp->f_dirstart; /* TE */ memcpy(&SearchDir, &fnp->f_dir, sizeof(struct dirent)); +#ifdef DEBUG + printf("dos_findfirst: %11s\n", fnp->f_dir.dir_name); +#endif dir_close(fnp); return SUCCESS; } @@ -629,6 +636,9 @@ COUNT dos_findnext(void) memcpy(&SearchDir, &fnp->f_dir, sizeof(struct dirent)); } +#ifdef DEBUG + printf("dos_findnext: %11s\n", fnp->f_dir.dir_name); +#endif /* return the result */ release_f_node(fnp); diff --git a/kernel/fatfs.c b/kernel/fatfs.c index 5114fa0e..fb6750fd 100644 --- a/kernel/fatfs.c +++ b/kernel/fatfs.c @@ -179,6 +179,28 @@ COUNT dos_close(COUNT fd) return SUCCESS; } +COUNT dos_commit(COUNT fd) +{ + f_node_ptr fnp, fnp2; + + /* Translate the fd into a useful pointer */ + fnp = xlt_fd(fd); + + /* If the fd was invalid because it was out of range or the */ + /* requested file was not open, tell the caller and exit */ + /* note: an invalid fd is indicated by a 0 return */ + if (fnp == (f_node_ptr) 0 || fnp->f_count <= 0) + return DE_INVLDHNDL; + fnp2 = get_f_node(); + if (fnp2 == (f_node_ptr) 0) + return DE_INVLDHNDL; + + /* a copy of the fnode is closed meaning that the directory info + is updated etc, but we keep our old info */ + memcpy(fnp2, fnp, sizeof(*fnp)); + return dos_close(xlt_fnp(fnp2)); +} + /* */ /* split a path into it's component directory and file name */ /* */ @@ -282,15 +304,14 @@ STATIC BOOL find_fname(f_node_ptr fnp, BYTE * fname, BYTE * fext) * Remove entries with D_LFN attribute preceeding the directory entry * pointed by fnp, fnode isn't modified (I hope). * Return value. - * SUCCESS - completed successfully. - * ERROR - error occured. + * SUCCESS - completed successfully. + * DE_BLKINVLD - error occured, fnode is released. * input: fnp with valid non-LFN directory entry, not equal to '..' or * '.' */ COUNT remove_lfn_entries(f_node_ptr fnp) { ULONG original_diroff = fnp->f_diroff; - COUNT rc; while (TRUE) { @@ -298,17 +319,22 @@ COUNT remove_lfn_entries(f_node_ptr fnp) break; fnp->f_diroff -= 2 * DIRENT_SIZE; /* it cannot / should not get below 0 because of '.' and '..' */ - if ((rc = dir_read(fnp)) < 0) - return rc; + if (dir_read(fnp) <= 0) { + dir_close(fnp); + return DE_BLKINVLD; + } if (fnp->f_dir.dir_attrib != D_LFN) break; fnp->f_dir.dir_name[0] = DELETED; fnp->f_flags.f_dmod = TRUE; - dir_write(fnp); + if (!dir_write(fnp)) return DE_BLKINVLD; } fnp->f_diroff = original_diroff - DIRENT_SIZE; - if ((rc = dir_read(fnp)) < 0) - return rc; + if (dir_read(fnp) <= 0) { + dir_close(fnp); + return DE_BLKINVLD; + } + return SUCCESS; } diff --git a/kernel/fattab.c b/kernel/fattab.c index b6a05c29..4f44015e 100644 --- a/kernel/fattab.c +++ b/kernel/fattab.c @@ -240,7 +240,7 @@ UCOUNT link_fat32(struct dpb FAR * dpbp, CLUSTER Cluster1, #endif -UCOUNT link_fat16(struct dpb FAR * dpbp, CLUSTER Cluster1, +STATIC UCOUNT link_fat16(struct dpb FAR * dpbp, CLUSTER Cluster1, CLUSTER Cluster2) { UCOUNT idx; @@ -266,7 +266,7 @@ UCOUNT link_fat16(struct dpb FAR * dpbp, CLUSTER Cluster1, return SUCCESS; } -UCOUNT link_fat12(struct dpb FAR * dpbp, CLUSTER Cluster1, +STATIC UCOUNT link_fat12(struct dpb FAR * dpbp, CLUSTER Cluster1, CLUSTER Cluster2) { REG UBYTE FAR *fbp0, FAR * fbp1; diff --git a/kernel/fcbfns.c b/kernel/fcbfns.c index 2988b462..0cca2eb4 100644 --- a/kernel/fcbfns.c +++ b/kernel/fcbfns.c @@ -85,7 +85,7 @@ VOID FatGetDrvData(UCOUNT drive, UCOUNT FAR * spc, UCOUNT FAR * bps, WORD FcbParseFname(int wTestMode, BYTE FAR ** lpFileName, fcb FAR * lpFcb) { COUNT nIndex; - WORD wRetCodeName, wRetCodeExt; + WORD wRetCodeName = FALSE, wRetCodeExt = FALSE; /* pjv -- ExtFcbToFcb? */ /* Start out with some simple stuff first. Check if we are */ @@ -156,7 +156,7 @@ WORD FcbParseFname(int wTestMode, BYTE FAR ** lpFileName, fcb FAR * lpFcb) return (wRetCodeName | wRetCodeExt) ? PARSE_RET_WILD : PARSE_RET_NOWILD; } -BYTE FAR *ParseSkipWh(BYTE FAR * lpFileName) +BYTE FAR * ParseSkipWh(BYTE FAR * lpFileName) { while (*lpFileName == ' ' || *lpFileName == '\t') ++lpFileName; @@ -191,13 +191,12 @@ BOOL TestFieldSeps(BYTE FAR * lpFileName) } #endif -BYTE FAR *GetNameField(BYTE FAR * lpFileName, BYTE FAR * lpDestField, +BYTE FAR * GetNameField(BYTE FAR * lpFileName, BYTE FAR * lpDestField, COUNT nFieldSize, BOOL * pbWildCard) { COUNT nIndex = 0; BYTE cFill = ' '; - *pbWildCard = FALSE; while (*lpFileName != '\0' && !TestFieldSeps(lpFileName) && nIndex < nFieldSize) { @@ -222,7 +221,7 @@ BYTE FAR *GetNameField(BYTE FAR * lpFileName, BYTE FAR * lpDestField, return lpFileName; } -static VOID FcbNextRecord(fcb FAR * lpFcb) +STATIC VOID FcbNextRecord(fcb FAR * lpFcb) { if (++lpFcb->fcb_curec > 128) { @@ -231,19 +230,17 @@ static VOID FcbNextRecord(fcb FAR * lpFcb) } } -static ULONG FcbRec(VOID) +STATIC ULONG FcbRec(VOID) { - UWORD tmp = 128; - - return ((ULONG) lpFcb->fcb_cublock * tmp) + lpFcb->fcb_curec; + return ((ULONG) lpFcb->fcb_cublock * 128) + lpFcb->fcb_curec; } -BOOL FcbRead(xfcb FAR * lpXfcb, COUNT * nErrorCode) +BOOL FcbRead(xfcb FAR * lpXfcb, COUNT * nErrorCode, UCOUNT recno) { sft FAR *s; - LONG lPosit; + ULONG lPosit; COUNT nRead; - psp FAR *p = MK_FP(cu_psp, 0); + BYTE far * FcbIoPtr = dta + recno * lpFcb->fcb_recsiz; /* Convert to fcb if necessary */ lpFcb = ExtFcbToFcb(lpXfcb); @@ -266,7 +263,7 @@ BOOL FcbRead(xfcb FAR * lpXfcb, COUNT * nErrorCode) } /* Do the read */ - nRead = DosReadSft(s, lpFcb->fcb_recsiz, p->ps_dta, nErrorCode); + nRead = DosReadSft(s, lpFcb->fcb_recsiz, FcbIoPtr, nErrorCode); /* Now find out how we will return and do it. */ if (nRead == lpFcb->fcb_recsiz) @@ -287,19 +284,19 @@ BOOL FcbRead(xfcb FAR * lpXfcb, COUNT * nErrorCode) } else { - fmemset(&p->ps_dta[nRead], 0, lpFcb->fcb_recsiz - nRead); + fmemset(FcbIoPtr + nRead, 0, lpFcb->fcb_recsiz - nRead); *nErrorCode = FCB_ERR_EOF; FcbNextRecord(lpFcb); return FALSE; } } -BOOL FcbWrite(xfcb FAR * lpXfcb, COUNT * nErrorCode) +BOOL FcbWrite(xfcb FAR * lpXfcb, COUNT * nErrorCode, UCOUNT recno) { sft FAR *s; - LONG lPosit; + ULONG lPosit; COUNT nWritten; - psp FAR *p = MK_FP(cu_psp, 0); + BYTE far * FcbIoPtr = dta + recno * lpFcb->fcb_recsiz; /* Convert to fcb if necessary */ lpFcb = ExtFcbToFcb(lpXfcb); @@ -321,7 +318,7 @@ BOOL FcbWrite(xfcb FAR * lpXfcb, COUNT * nErrorCode) return FALSE; } - nWritten = DosWriteSft(s, lpFcb->fcb_recsiz, p->ps_dta, nErrorCode); + nWritten = DosWriteSft(s, lpFcb->fcb_recsiz, FcbIoPtr, nErrorCode); /* Now find out how we will return and do it. */ if (nWritten == lpFcb->fcb_recsiz) @@ -355,7 +352,7 @@ BOOL FcbGetFileSize(xfcb FAR * lpXfcb) hndl = DosOpen(SecPathName, O_RDONLY); if (hndl >= 0) { - LONG fsize; + ULONG fsize; /* Get the size */ fsize = DosGetFsize(hndl); @@ -401,13 +398,15 @@ BOOL FcbCalcRec(xfcb FAR * lpXfcb) BOOL FcbRandomBlockRead(xfcb FAR * lpXfcb, COUNT nRecords, COUNT * nErrorCode) { + UCOUNT recno = 0; + FcbCalcRec(lpXfcb); /* Convert to fcb if necessary */ lpFcb = ExtFcbToFcb(lpXfcb); do - FcbRead(lpXfcb, nErrorCode); + FcbRead(lpXfcb, nErrorCode, recno++); while ((--nRecords > 0) && (*nErrorCode == 0)); /* Now update the fcb */ @@ -419,13 +418,15 @@ BOOL FcbRandomBlockRead(xfcb FAR * lpXfcb, COUNT nRecords, BOOL FcbRandomBlockWrite(xfcb FAR * lpXfcb, COUNT nRecords, COUNT * nErrorCode) { + UCOUNT recno = 0; + FcbCalcRec(lpXfcb); /* Convert to fcb if necessary */ lpFcb = ExtFcbToFcb(lpXfcb); do - FcbWrite(lpXfcb, nErrorCode); + FcbWrite(lpXfcb, nErrorCode, recno++); while ((--nRecords > 0) && (*nErrorCode == 0)); /* Now update the fcb */ @@ -434,8 +435,7 @@ BOOL FcbRandomBlockWrite(xfcb FAR * lpXfcb, COUNT nRecords, return TRUE; } -BOOL FcbRandomIO(xfcb FAR * lpXfcb, COUNT * nErrorCode, - BOOL(*FcbFunc) (xfcb FAR *, COUNT *)) +BOOL FcbRandomIO(xfcb FAR * lpXfcb, COUNT * nErrorCode, FcbFunc_t *FcbFunc) { UWORD uwCurrentBlock; UBYTE ucCurrentRecord; @@ -448,48 +448,58 @@ BOOL FcbRandomIO(xfcb FAR * lpXfcb, COUNT * nErrorCode, uwCurrentBlock = lpFcb->fcb_cublock; ucCurrentRecord = lpFcb->fcb_curec; - (*FcbFunc) (lpXfcb, nErrorCode); + (*FcbFunc) (lpXfcb, nErrorCode, 0); lpFcb->fcb_cublock = uwCurrentBlock; lpFcb->fcb_curec = ucCurrentRecord; return TRUE; } -/* -static sft FAR *FcbGetFreeSft(COUNT * sft_idx) -see get_free_sft in dosfns.c -*/ - -BOOL FcbCreate(xfcb FAR * lpXfcb) +/* merged fcbOpen and FcbCreate - saves ~200 byte */ +BOOL FcbOpenCreate(xfcb FAR * lpXfcb, BOOL Create) { sft FAR *sftp; COUNT sft_idx, FcbDrive; - struct dhdr FAR *dhp; /* Build a traditional DOS file name */ lpFcb = CommonFcbInit(lpXfcb, PriPathName, &FcbDrive); - sft_idx = DosCreatSft(PriPathName, 0); + if (Create) + { + sft_idx = DosCreatSft(PriPathName, 0); + } + else + { + sft_idx = DosOpenSft(PriPathName, O_RDWR | SFT_MFCB); + + /* if file is RDONLY, try to open rdonly */ + if (sft_idx == DE_ACCESS) + sft_idx = DosOpenSft(PriPathName, O_RDONLY | SFT_MFCB); + } + if (sft_idx < 0) return FALSE; sftp = idx_to_sft(sft_idx); sftp->sft_mode |= SFT_MFCB; - /* check for a device */ - dhp = IsDevice(PriPathName); lpFcb->fcb_sftno = sft_idx; lpFcb->fcb_curec = 0; - lpFcb->fcb_recsiz = (dhp ? 0 : 128); - if (!dhp) - lpFcb->fcb_drive = FcbDrive; - lpFcb->fcb_fsize = 0; - lpFcb->fcb_date = dos_getdate(); - lpFcb->fcb_time = dos_gettime(); lpFcb->fcb_rndm = 0; + + lpFcb->fcb_recsiz = 0; /* true for devices */ + if (sftp->sft_flags & SFT_FDEVICE) /* check for a device */ + { + lpFcb->fcb_drive = FcbDrive; + lpFcb->fcb_recsiz = 128; + } + lpFcb->fcb_fsize = sftp->sft_size; + lpFcb->fcb_date = sftp->sft_date; + lpFcb->fcb_time = sftp->sft_time; return TRUE; } + STATIC fcb FAR *ExtFcbToFcb(xfcb FAR * lpExtFcb) { if (*((UBYTE FAR *) lpExtFcb) == 0xff) @@ -535,45 +545,6 @@ void FcbNameInit(fcb FAR * lpFcb, BYTE * szBuffer, COUNT * pCurDrive) /* XXX fix truename error handling */ } -BOOL FcbOpen(xfcb FAR * lpXfcb) -{ - sft FAR *sftp; - struct dhdr FAR *dhp; - COUNT FcbDrive, sft_idx; - - /* Build a traditional DOS file name */ - lpFcb = CommonFcbInit(lpXfcb, PriPathName, &FcbDrive); - - sft_idx = DosOpenSft(PriPathName, O_RDWR); - if (sft_idx < 0) - return FALSE; - - sftp = idx_to_sft(sft_idx); - sftp->sft_mode |= SFT_MFCB; - - /* check for a device */ - lpFcb->fcb_curec = 0; - lpFcb->fcb_rndm = 0; - lpFcb->fcb_sftno = sft_idx; - dhp = IsDevice(PriPathName); - if (dhp) - { - lpFcb->fcb_recsiz = 0; - lpFcb->fcb_fsize = 0; - lpFcb->fcb_date = dos_getdate(); - lpFcb->fcb_time = dos_gettime(); - } - else - { - lpFcb->fcb_drive = FcbDrive; - lpFcb->fcb_recsiz = 128; - lpFcb->fcb_fsize = sftp->sft_size; - lpFcb->fcb_date = sftp->sft_date; - lpFcb->fcb_time = sftp->sft_time; - } - return TRUE; -} - BOOL FcbDelete(xfcb FAR * lpXfcb) { COUNT FcbDrive; @@ -739,7 +710,7 @@ BOOL FcbClose(xfcb FAR * lpXfcb) if (!(s->sft_flags & SFT_FSHARED)) dos_setfsize(s->sft_status, lpFcb->fcb_fsize); DosSetFtimeSft(lpFcb->fcb_sftno, lpFcb->fcb_date, lpFcb->fcb_time); - if (DosCloseSft(lpFcb->fcb_sftno) == SUCCESS) + if (DosCloseSft(lpFcb->fcb_sftno, FALSE) == SUCCESS) { lpFcb->fcb_sftno = (BYTE) 0xff; return TRUE; @@ -755,7 +726,7 @@ VOID FcbCloseAll() for (idx = 0; (sftp = idx_to_sft(idx)) != (sft FAR *) - 1; idx++) if ((sftp->sft_mode & SFT_MFCB) && sftp->sft_psp == cu_psp) - DosCloseSft(idx); + DosCloseSft(idx, FALSE); } BOOL FcbFindFirst(xfcb FAR * lpXfcb) diff --git a/kernel/globals.h b/kernel/globals.h index 28291068..98a21bb8 100644 --- a/kernel/globals.h +++ b/kernel/globals.h @@ -43,7 +43,6 @@ static BYTE *Globals_hRcsId = #include "fcb.h" #include "tail.h" #include "process.h" -#include "dcb.h" #include "sft.h" #include "cds.h" #include "exe.h" @@ -57,8 +56,24 @@ static BYTE *Globals_hRcsId = #include "network.h" #include "config.h" #include "buffer.h" +#include "dcb.h" #include "xstructs.h" +/* fatfs.c */ +#ifdef WITHFAT32 +VOID bpb_to_dpb(bpb FAR * bpbp, REG struct dpb FAR * dpbp, BOOL extended); +#else +VOID bpb_to_dpb(bpb FAR * bpbp, REG struct dpb FAR * dpbp); +#endif + +#ifdef WITHFAT32 +struct dpb FAR *GetDriveDPB(UBYTE drive, COUNT * rc); +#endif + +extern struct dpb +FAR * ASM DPBp; /* First drive Parameter Block */ + + /* JPP: for testing/debuging disk IO */ /*#define DISPLAY_GETBLOCK */ @@ -155,12 +170,12 @@ typedef BYTE *UPMAP; /* External Assembly variables */ /* */ extern struct dhdr -FAR clk_dev, /* Clock device driver */ - FAR con_dev, /* Console device driver */ - FAR prn_dev, /* Generic printer device driver */ - FAR aux_dev, /* Generic aux device driver */ - FAR blk_dev; /* Block device (Disk) driver */ -extern UWORD ram_top; /* How much ram in Kbytes */ +FAR ASM clk_dev, /* Clock device driver */ + FAR ASM con_dev, /* Console device driver */ + FAR ASM prn_dev, /* Generic printer device driver */ + FAR ASM aux_dev, /* Generic aux device driver */ + FAR ASM blk_dev; /* Block device (Disk) driver */ +extern UWORD ASM ram_top; /* How much ram in Kbytes */ extern COUNT *error_tos, /* error stack */ disk_api_tos, /* API handler stack - disk fns */ char_api_tos; /* API handler stack - char fns */ @@ -172,7 +187,7 @@ extern BYTE DosLoadedInHMA; /* if InitHMA has moved DOS up */ extern struct ClockRecord - ClkRecord; + ASM ClkRecord; /* */ /* Global variables */ @@ -239,66 +254,64 @@ Freeman Publishing, Lawrence KS, USA (ISBN 0-87930-436-7).\n\ /* ARE DOCUMENTED AS UNDOCUMENTED (?) AND HAVE MANY PROGRAMS AND TSR'S */ /* ACCESSING THEM */ -extern UWORD NetBios; -extern BYTE *net_name; -extern BYTE net_set_count; -extern BYTE NetDelay, NetRetry; +extern UWORD ASM NetBios; +extern BYTE * ASM net_name; +extern BYTE ASM net_set_count; +extern BYTE ASM NetDelay, ASM NetRetry; -extern UWORD first_mcb, /* Start of user memory */ - UMB_top, umb_start, uppermem_root; /* Start of umb chain ? */ -extern struct dpb -FAR *DPBp; /* First drive Parameter Block */ -extern sfttbl FAR * sfthead; /* System File Table head */ +extern UWORD ASM first_mcb, /* Start of user memory */ + ASM UMB_top, ASM umb_start, ASM uppermem_root; /* Start of umb chain ? */ +extern sfttbl FAR * ASM sfthead; /* System File Table head */ extern struct dhdr -FAR *clock, /* CLOCK$ device */ - FAR * syscon; /* console device */ -extern WORD maxbksize; /* Number of Drives in system */ +FAR * ASM clock, /* CLOCK$ device */ + FAR * ASM syscon; /* console device */ +extern WORD ASM maxbksize; /* Number of Drives in system */ extern struct buffer -FAR *firstbuf; /* head of buffers linked list */ -extern cdstbl FAR * CDSp; /* Current Directory Structure */ +FAR *ASM firstbuf; /* head of buffers linked list */ +extern cdstbl FAR * ASM CDSp; /* Current Directory Structure */ extern -struct cds FAR *current_ldt; -extern LONG current_filepos; /* current file position */ -extern sfttbl FAR * FCBp; /* FCB table pointer */ -extern WORD nprotfcb; /* number of protected fcbs */ -extern UBYTE nblkdev, /* number of block devices */ - lastdrive, /* value of last drive */ - uppermem_link, /* UMB Link flag */ - PrinterEcho; /* Printer Echo Flag */ +struct cds FAR * ASM current_ldt; +extern LONG ASM current_filepos; /* current file position */ +extern sfttbl FAR * ASM FCBp; /* FCB table pointer */ +extern WORD ASM nprotfcb; /* number of protected fcbs */ +extern UBYTE ASM nblkdev, /* number of block devices */ + ASM lastdrive, /* value of last drive */ + ASM uppermem_link, /* UMB Link flag */ + ASM PrinterEcho; /* Printer Echo Flag */ -extern UWORD LoL_nbuffers; /* Number of buffers */ +extern UWORD ASM LoL_nbuffers; /* Number of buffers */ extern struct dhdr - nul_dev; -extern UBYTE mem_access_mode; /* memory allocation scheme */ -extern BYTE ErrorMode, /* Critical error flag */ - InDOS, /* In DOS critical section */ - OpenMode, /* File Open Attributes */ - SAttr, /* Attrib Mask for Dir Search */ - dosidle_flag, Server_Call, CritErrLocus, CritErrAction, CritErrClass, VgaSet, njoined; /* number of joined devices */ - -extern UWORD Int21AX; -extern COUNT CritErrCode; -extern BYTE FAR *CritErrDev; + ASM nul_dev; +extern UBYTE ASM mem_access_mode; /* memory allocation scheme */ +extern BYTE ASM ErrorMode, /* Critical error flag */ + ASM InDOS, /* In DOS critical section */ + ASM OpenMode, /* File Open Attributes */ + ASM SAttr, /* Attrib Mask for Dir Search */ + ASM dosidle_flag, ASM Server_Call, ASM CritErrLocus, ASM CritErrAction, ASM CritErrClass, VgaSet, njoined; /* number of joined devices */ + +extern UWORD ASM Int21AX; +extern COUNT ASM CritErrCode; +extern BYTE FAR * ASM CritErrDev; extern struct dirent - SearchDir; + ASM SearchDir; extern struct { COUNT nDrive; BYTE szName[FNAME_SIZE + 1]; BYTE szExt[FEXT_SIZE + 1]; -} FcbSearchBuffer; +} ASM FcbSearchBuffer; extern struct /* Path name parsing buffer */ { BYTE _PriPathName[128]; -} _PriPathBuffer; +} ASM _PriPathBuffer; extern struct { BYTE _fname[FNAME_SIZE]; BYTE _fext[FEXT_SIZE + 1]; /* space for 0 */ -} szNames; +} ASM szNames; #define PriPathName _PriPathBuffer._PriPathName #define szDirName TempCDS.cdsCurrentPath @@ -308,49 +321,46 @@ extern struct { extern struct /* Alternate path name parsing buffer */ { BYTE _SecPathName[128]; -} _SecPathBuffer; +} ASM _SecPathBuffer; #define SecPathName _SecPathBuffer._SecPathName -extern UWORD wAttr; +extern UWORD ASM wAttr; -extern BYTE default_drive; /* default drive for dos */ +extern BYTE ASM default_drive; /* default drive for dos */ -extern BYTE TempBuffer[], /* Temporary general purpose buffer */ - FAR internal_data[], /* sda areas */ - FAR swap_always[], /* " " */ - FAR swap_indos[], /* " " */ - tsr, /* true if program is TSR */ - break_flg, /* true if break was detected */ - break_ena, /* break enabled flag */ - FAR * dta; /* Disk transfer area (kludge) */ -extern seg cu_psp; /* current psp segment */ -extern iregs FAR * user_r; /* User registers for int 21h call */ +extern BYTE ASM TempBuffer[], /* Temporary general purpose buffer */ + FAR ASM internal_data[], /* sda areas */ + FAR ASM swap_always[], /* " " */ + FAR ASM swap_indos[], /* " " */ + ASM tsr, /* true if program is TSR */ + ASM break_flg, /* true if break was detected */ + ASM break_ena, /* break enabled flag */ + FAR * ASM dta; /* Disk transfer area (kludge) */ +extern seg ASM cu_psp; /* current psp segment */ +extern iregs FAR * ASM user_r; /* User registers for int 21h call */ extern struct dirent /* Temporary directory entry */ - DirEntBuffer; - -extern request /* I/O Request packets */ - CharReqHdr, IoReqHdr, MediaReqHdr; + ASM DirEntBuffer; -extern fcb FAR * lpFcb; /* Pointer to users fcb */ +extern fcb FAR * ASM lpFcb; /* Pointer to users fcb */ -extern sft FAR * lpCurSft; +extern sft FAR * ASM lpCurSft; -extern BYTE verify_ena, /* verify enabled flag */ - switchar, /* switch char */ - return_mode, /* Process termination rets */ - return_code; /* " " " */ +extern BYTE ASM verify_ena, /* verify enabled flag */ + ASM switchar, /* switch char */ + ASM return_mode, /* Process termination rets */ + ASM return_code; /* " " " */ -extern BYTE BootDrive, /* Drive we came up from */ - scr_pos; /* screen position for bs, ht, etc */ +extern BYTE ASM BootDrive, /* Drive we came up from */ + ASM scr_pos; /* screen position for bs, ht, etc */ /*extern WORD NumFloppies; !!*//* How many floppies we have */ -extern keyboard kb_buf; +extern keyboard ASM kb_buf; extern struct cds - TempCDS; + ASM TempCDS; /* start of uncontrolled variables */ GLOBAL seg RootPsp; /* Root process -- do not abort */ @@ -382,28 +392,25 @@ GLOBAL UWORD f_nodes_cnt; /* number of allocated f_nodes */ /* Process related functions - not under automatic generation. */ /* Typically, these are in ".asm" files. */ -VOID FAR ASMCFUNC cpm_entry(VOID) +VOID ASMCFUNC FAR cpm_entry(VOID) /*INRPT FAR handle_break(VOID) */ ; VOID enable(VOID), disable(VOID); -COUNT - ASMCFUNC CriticalError(COUNT nFlag, COUNT nDrive, COUNT nError, +COUNT ASMCFUNC + CriticalError(COUNT nFlag, COUNT nDrive, COUNT nError, struct dhdr FAR * lpDevice); #ifdef PROTO -VOID FAR ASMCFUNC CharMapSrvc(VOID); -VOID FAR ASMCFUNC set_stack(VOID); -VOID FAR ASMCFUNC restore_stack(VOID); -WORD ASMCFUNC execrh(request FAR *, struct dhdr FAR *); -VOID exit(COUNT); +VOID ASMCFUNC FAR CharMapSrvc(VOID); +VOID ASMCFUNC FAR set_stack(VOID); +VOID ASMCFUNC FAR restore_stack(VOID); /*VOID INRPT FAR handle_break(VOID); */ -VOID ASMCFUNC tmark(VOID); -BOOL ASMCFUNC tdelay(LONG); -BYTE FAR *ASMCFUNC device_end(VOID); +VOID ASMCFUNC ReadPCClock(ULONG *); +BYTE FAR * ASMCFUNC device_end(VOID); COUNT ASMCFUNC kb_data(VOID); COUNT ASMCFUNC kb_input(VOID); COUNT ASMCFUNC kb_init(VOID); -VOID ASMCFUNC setvec(UWORD, VOID(INRPT FAR *) ()); -BYTE FAR *ASMCFUNC getvec(UWORD); +VOID ASMCFUNC setvec(UWORD, intvec); +intvec ASMCFUNC getvec(UWORD); COUNT con(COUNT); #else VOID FAR CharMapSrvc(); @@ -412,14 +419,12 @@ VOID FAR restore_stack(); WORD execrh(); VOID exit(); /*VOID INRPT FAR handle_break(); */ -VOID tmark(); -BOOL tdelay(); BYTE FAR *device_end(); COUNT kb_data(); COUNT kb_input(); COUNT kb_init(); VOID setvec(); -BYTE FAR *getvec(); +intvec getvec(); COUNT con(); #endif @@ -459,7 +464,7 @@ VOID fputbyte(); #endif #ifdef I86 -#define setvec(n, isr) (void)(*(VOID (INRPT FAR * FAR *)())(MK_FP(0,4 * (n))) = (isr)) +#define setvec(n, isr) (void)(*(intvec FAR *)MK_FP(0,4 * (n)) = (isr)) #endif /*#define is_leap_year(y) ((y) & 3 ? 0 : (y) % 100 ? 1 : (y) % 400 ? 0 : 1) */ diff --git a/kernel/init-mod.h b/kernel/init-mod.h index de6e7cf0..1705c534 100644 --- a/kernel/init-mod.h +++ b/kernel/init-mod.h @@ -9,7 +9,6 @@ #include "fat.h" #include "fnode.h" #include "file.h" -#include "dcb.h" #include "cds.h" #include "device.h" #include "kbd.h" @@ -20,15 +19,11 @@ #include "pcb.h" #include "nls.h" #include "buffer.h" +#include "dcb.h" #include "KConfig.h" extern struct _KernelConfig InitKernelConfig; -/* - * The null macro `INIT' can be used to allow the reader to differentiate - * between functions defined in `INIT_TEXT' and those defined in `_TEXT'. - */ -#define INIT /* * Functions in `INIT_TEXT' may need to call functions in `_TEXT'. The entry * calls for the latter functions therefore need to be wrapped up with far @@ -57,9 +52,9 @@ COUNT ASMCFUNC strlen(REG BYTE * s); /*inithma.c*/ extern BYTE DosLoadedInHMA; -extern fmemcmp(BYTE far * s1, BYTE FAR * s2, unsigned len); +int fmemcmp(BYTE far * s1, BYTE FAR * s2, unsigned len); -#define setvec(n, isr) (void)(*(VOID (FAR * FAR *)())(MK_FP(0,4 * (n))) = (isr)) +#define setvec(n, isr) (void)(*(intvec FAR *)MK_FP(0,4 * (n)) = (isr)) #define fbcopy(s, d, n) fmemcpy(d,s,n) #define GLOBAL extern @@ -69,7 +64,7 @@ extern fmemcmp(BYTE far * s1, BYTE FAR * s2, unsigned len); #define NFCBS 16 /* number of fcbs */ #define NSTACKS 8 /* number of stacks */ #define NLAST 5 /* last drive */ -#define NUMBUFF 6 /* Number of track buffers */ +#define NUMBUFF 20 /* Number of track buffers at INIT time */ /* -- must be at least 3 */ #define MAX_HARD_DRIVE 8 #define NDEV 26 /* up to Z: */ @@ -116,22 +111,22 @@ struct config { extern struct config Config; /* config.c */ -INIT VOID PreConfig(VOID); -INIT VOID DoConfig(VOID); -INIT VOID PostConfig(VOID); -INIT BYTE FAR *KernelAlloc(WORD nBytes); -INIT BYTE *skipwh(BYTE * s); -INIT BYTE *scan(BYTE * s, BYTE * d); -INIT BOOL isnum(BYTE * pszString); -INIT BYTE *GetNumber(REG BYTE * pszString, REG COUNT * pnNum); -INIT COUNT tolower(COUNT c); -INIT COUNT toupper(COUNT c); -INIT VOID mcb_init(UCOUNT seg, UWORD size); -INIT VOID strcat(REG BYTE * d, REG BYTE * s); -INIT BYTE FAR *KernelAlloc(WORD nBytes); -INIT COUNT ASMCFUNC Umb_Test(void); -INIT COUNT ASMCFUNC UMB_get_largest(UCOUNT * seg, UCOUNT * size); -INIT BYTE *GetStringArg(BYTE * pLine, BYTE * pszString); +VOID PreConfig(VOID); +VOID DoConfig(int pass); +VOID PostConfig(VOID); +BYTE FAR * KernelAlloc(WORD nBytes); +BYTE * skipwh(BYTE * s); +BYTE * scan(BYTE * s, BYTE * d); +BOOL isnum(BYTE * pszString); +BYTE * GetNumber(REG BYTE * pszString, REG COUNT * pnNum); +COUNT tolower(COUNT c); +COUNT toupper(COUNT c); +VOID mcb_init(UCOUNT seg, UWORD size); +VOID strcat(REG BYTE * d, REG BYTE * s); +BYTE FAR * KernelAlloc(WORD nBytes); +COUNT ASMCFUNC Umb_Test(void); +COUNT ASMCFUNC UMB_get_largest(UCOUNT * seg, UCOUNT * size); +BYTE * GetStringArg(BYTE * pLine, BYTE * pszString); /* diskinit.c */ COUNT dsk_init(VOID); @@ -141,7 +136,7 @@ COUNT ASMCFUNC Umb_Test(void); /* inithma.c */ int MoveKernelToHMA(void); -VOID FAR *HMAalloc(COUNT bytesToAllocate); +VOID FAR * HMAalloc(COUNT bytesToAllocate); /* initoem.c */ UWORD init_oem(void); @@ -154,43 +149,43 @@ int ASMCFUNC open(const char *pathname, int flags); int ASMCFUNC close(int fd); int ASMCFUNC dup2(int oldfd, int newfd); int ASMCFUNC allocmem(UWORD size, seg * segp); -INIT VOID ASMCFUNC init_PSPInit(seg psp_seg); -INIT VOID ASMCFUNC init_PSPSet(seg psp_seg); -INIT COUNT ASMCFUNC init_DosExec(COUNT mode, exec_blk * ep, BYTE * lp); -INIT VOID ASMCFUNC keycheck(VOID); +VOID ASMCFUNC init_PSPInit(seg psp_seg); +VOID ASMCFUNC init_PSPSet(seg psp_seg); +COUNT ASMCFUNC init_DosExec(COUNT mode, exec_blk * ep, BYTE * lp); +VOID ASMCFUNC keycheck(VOID); /* irqstack.asm */ VOID ASMCFUNC init_stacks(VOID FAR * stack_base, COUNT nStacks, WORD stackSize); /* inthndlr.c */ -VOID far ASMCFUNC int21_entry(iregs UserRegs); +VOID ASMCFUNC FAR int21_entry(iregs UserRegs); VOID ASMCFUNC int21_service(iregs far * r); -VOID FAR ASMCFUNC int0_handler(void); -VOID FAR ASMCFUNC int6_handler(void); -VOID FAR ASMCFUNC empty_handler(void); -VOID far ASMCFUNC got_cbreak(void); /* procsupt.asm */ -VOID far ASMCFUNC int20_handler(iregs UserRegs); -VOID far ASMCFUNC int21_handler(iregs UserRegs); -VOID FAR ASMCFUNC int22_handler(void); -VOID FAR ASMCFUNC int24_handler(void); -VOID FAR ASMCFUNC low_int25_handler(void); -VOID FAR ASMCFUNC low_int26_handler(void); -VOID FAR ASMCFUNC int27_handler(void); -VOID FAR ASMCFUNC int28_handler(void); -VOID FAR ASMCFUNC int29_handler(void); -VOID FAR ASMCFUNC int2a_handler(void); -VOID FAR ASMCFUNC int2f_handler(void); +VOID CDECL FAR int0_handler(void); +VOID ASMCFUNC FAR int6_handler(void); +VOID ASMCFUNC FAR empty_handler(void); +VOID ASMCFUNC FAR got_cbreak(void); /* procsupt.asm */ +VOID ASMCFUNC FAR int20_handler(iregs UserRegs); +VOID ASMCFUNC FAR int21_handler(iregs UserRegs); +VOID ASMCFUNC FAR int22_handler(void); +VOID ASMCFUNC FAR int24_handler(void); +VOID ASMCFUNC FAR low_int25_handler(void); +VOID ASMCFUNC FAR low_int26_handler(void); +VOID ASMCFUNC FAR int27_handler(void); +VOID ASMCFUNC FAR int28_handler(void); +VOID ASMCFUNC FAR int29_handler(void); +VOID ASMCFUNC FAR int2a_handler(void); +VOID ASMCFUNC FAR int2f_handler(void); /* main.c */ -INIT VOID ASMCFUNC FreeDOSmain(void); -INIT BOOL init_device(struct dhdr FAR * dhp, BYTE FAR * cmdLine, +VOID ASMCFUNC FreeDOSmain(void); +BOOL init_device(struct dhdr FAR * dhp, BYTE FAR * cmdLine, COUNT mode, COUNT top); -INIT VOID init_fatal(BYTE * err_msg); +VOID init_fatal(BYTE * err_msg); /* prf.c */ -WORD init_printf(CONST BYTE * fmt, ...); -WORD init_sprintf(BYTE * buff, CONST BYTE * fmt, ...); +WORD ASMCFUNC init_printf(CONST BYTE * fmt, ...); +WORD ASMCFUNC init_sprintf(BYTE * buff, CONST BYTE * fmt, ...); void MoveKernel(unsigned NewKernelSegment); extern WORD HMAFree; /* first byte in HMA not yet used */ @@ -198,8 +193,8 @@ extern WORD HMAFree; /* first byte in HMA not yet used */ extern unsigned CurrentKernelSegment; #if defined(WATCOM) && 0 -ULONG FAR ASMCFUNC MULULUS(ULONG mul1, UWORD mul2); /* MULtiply ULong by UShort */ -ULONG FAR ASMCFUNC MULULUL(ULONG mul1, ULONG mul2); /* MULtiply ULong by ULong */ -ULONG FAR ASMCFUNC DIVULUS(ULONG mul1, UWORD mul2); /* DIVide ULong by UShort */ -ULONG FAR ASMCFUNC DIVMODULUS(ULONG mul1, UWORD mul2, UWORD * rem); /* DIVide ULong by UShort */ +ULONG ASMCFUNC FAR MULULUS(ULONG mul1, UWORD mul2); /* MULtiply ULong by UShort */ +ULONG ASMCFUNC FAR MULULUL(ULONG mul1, ULONG mul2); /* MULtiply ULong by ULong */ +ULONG ASMCFUNC FAR DIVULUS(ULONG mul1, UWORD mul2); /* DIVide ULong by UShort */ +ULONG ASMCFUNC FAR DIVMODULUS(ULONG mul1, UWORD mul2, UWORD * rem); /* DIVide ULong by UShort */ #endif diff --git a/kernel/initdisk.c b/kernel/initdisk.c index f2bf01db..177af566 100644 --- a/kernel/initdisk.c +++ b/kernel/initdisk.c @@ -271,6 +271,8 @@ struct PartTableEntry /* INTERNAL representation of partition table en internal global data */ +BOOL ExtLBAForce = FALSE; + COUNT init_readdasd(UBYTE drive) { static iregs regs; @@ -435,7 +437,7 @@ VOID CalculateFATData(ddt FAR * pddt, ULONG NumSectors, UBYTE FileSystem) if (maxclust > FAT12MAX) maxclust = FAT12MAX; DebugPrintf(("FAT12: #clu=%lu, fatlen=%lu, maxclu=%lu, limit=%u\n", - clust, fatlength, maxclust, FATMAX12)); + clust, fatlength, maxclust, FAT12MAX)); if (clust > maxclust - 2) { clust = maxclust - 2; @@ -524,7 +526,7 @@ VOID CalculateFATData(ddt FAR * pddt, ULONG NumSectors, UBYTE FileSystem) if (maxclust > FAT32MAX) maxclust = FAT32MAX; DebugPrintf(("FAT32: #clu=%u, fatlen=%u, maxclu=%u, limit=%u\n", - clust, fatlength, maxclust, FATMAX32)); + clust, fatlength, maxclust, FAT32MAX)); if (clust > maxclust - 2) { clust = 0; @@ -563,13 +565,15 @@ void DosDefinePartition(struct DriveParamS *driveParam, return; /* we are done */ } + (pddt-1)->ddt_next = pddt; + pddt->ddt_next = MK_FP(0, 0xffff); pddt->ddt_driveno = driveParam->driveno; pddt->ddt_logdriveno = nUnits; pddt->ddt_LBASupported = driveParam->LBA_supported; /* Turn of LBA if not forced and the partition is within 1023 cyls and of the right type */ /* the FileSystem type was internally converted to LBA_xxxx if a non-LBA partition above cylinder 1023 was found */ - if (!InitKernelConfig.ForceLBA && !IsLBAPartition(pEntry->FileSystem)) + if (!InitKernelConfig.ForceLBA && !ExtLBAForce && !IsLBAPartition(pEntry->FileSystem)) pddt->ddt_LBASupported = FALSE; pddt->ddt_WriteVerifySupported = driveParam->WriteVerifySupported; pddt->ddt_ncyl = driveParam->chs.Cylinder; @@ -681,6 +685,7 @@ int LBA_Get_Drive_Parameters(int drive, struct DriveParamS *driveParam) regs.d.b.l = drive; init_call_intr(0x13, ®s); + /* error or DMA boundary errors not handled transparently */ if (regs.flags & 0x01) { goto StandardBios; @@ -885,7 +890,7 @@ ScanForPrimaryPartitions(struct DriveParamS * driveParam, int scan_type, continue; } - if (!InitKernelConfig.ForceLBA + if (!InitKernelConfig.ForceLBA && !ExtLBAForce && !IsLBAPartition(pEntry->FileSystem)) { printf @@ -1012,6 +1017,8 @@ int ProcessDisk(int scanType, unsigned drive, int PartitionsToIgnore) struct DriveParamS driveParam; + ExtLBAForce = FALSE; + /* Get the hard drive parameters and ensure that the drive exists. */ /* If there was an error accessing the drive, skip that drive. */ @@ -1084,6 +1091,8 @@ int ProcessDisk(int scanType, unsigned drive, int PartitionsToIgnore) if (ExtendedPartitionOffset == 0) { ExtendedPartitionOffset = PTable[iPart].RelSect; + /* grand parent LBA -> all children and grandchildren LBA */ + ExtLBAForce = (PTable[iPart].FileSystem == EXTENDED_LBA); } num_extended_found++; @@ -1233,6 +1242,8 @@ void ReadAllPartitionTables(void) { pddt = DynAlloc("ddt", 1, sizeof(ddt)); + if (Unit > 0) (pddt-1)->ddt_next = pddt; + pddt->ddt_next = MK_FP(0, 0xffff); pddt->ddt_driveno = 0; pddt->ddt_logdriveno = Unit; pddt->ddt_type = init_getdriveparm(0, &pddt->ddt_defbpb); diff --git a/kernel/inithma.c b/kernel/inithma.c index 359285df..d9061224 100644 --- a/kernel/inithma.c +++ b/kernel/inithma.c @@ -67,9 +67,9 @@ #include "init-mod.h" #include "init-dat.h" -extern BYTE FAR _HMATextAvailable, /* first byte of available CODE area */ - FAR _HMATextStart[], /* first byte of HMAable CODE area */ - FAR _HMATextEnd[]; /* and the last byte of it */ +extern BYTE FAR ASM _HMATextAvailable, /* first byte of available CODE area */ + FAR ASM _HMATextStart[], /* first byte of HMAable CODE area */ + FAR ASM _HMATextEnd[]; /* and the last byte of it */ #ifdef VERSION_STRINGS static BYTE *RcsId = @@ -78,14 +78,14 @@ static BYTE *RcsId = BYTE DosLoadedInHMA = FALSE; /* set to TRUE if loaded HIGH */ BYTE HMAclaimed = FALSE; /* set to TRUE if claimed from HIMEM */ -WORD HMAFree = 0; /* first byte in HMA not yet used */ +WORD HMAFree = 0; /* first byte in HMA not yet used */ -extern BYTE FAR *DOSTEXTFAR ASMCFUNC XMSDriverAddress; -extern FAR ASMCFUNC _EnableA20(VOID); -extern FAR ASMCFUNC _DisableA20(VOID); +extern void FAR *DOSTEXTFAR ASM XMSDriverAddress; +VOID ASMCFUNC FAR _EnableA20(VOID); +VOID ASMCFUNC FAR _DisableA20(VOID); -extern void FAR *ASMCFUNC DetectXMSDriver(VOID); -extern int ASMCFUNC init_call_XMScall(void FAR * driverAddress, UWORD ax, +void FAR * ASMCFUNC DetectXMSDriver(VOID); +int ASMCFUNC init_call_XMScall(void FAR * driverAddress, UWORD ax, UWORD dx); #ifdef DEBUG @@ -127,7 +127,7 @@ VOID hdump(BYTE FAR * p) #define KeyboardShiftState() (*(BYTE FAR *)(MK_FP(0x40,0x17))) /* of course, this should go to ASMSUPT */ -fmemcmp(BYTE far * s1, BYTE FAR * s2, unsigned len) +int fmemcmp(BYTE far * s1, BYTE FAR * s2, unsigned len) { for (; len; s1++, s2++, --len) { @@ -316,7 +316,7 @@ void HMAconfig(int finalize) only available if DOS=HIGH was successful */ -VOID FAR *HMAalloc(COUNT bytesToAllocate) +VOID FAR * HMAalloc(COUNT bytesToAllocate) { VOID FAR *HMAptr; @@ -416,8 +416,8 @@ void MoveKernel(unsigned NewKernelSegment) UWORD jmpSegment; }; extern struct RelocationTable - DOSTEXTFAR _HMARelocationTableStart[], - DOSTEXTFAR _HMARelocationTableEnd[]; + DOSTEXTFAR ASM _HMARelocationTableStart[], + DOSTEXTFAR ASM _HMARelocationTableEnd[]; struct RelocationTable FAR *rp, rtemp; @@ -469,7 +469,7 @@ void MoveKernel(unsigned NewKernelSegment) UWORD jmpSegment; }; extern struct initRelocationTable - _HMAinitRelocationTableStart[], _HMAinitRelocationTableEnd[]; + ASM _HMAinitRelocationTableStart[], ASM _HMAinitRelocationTableEnd[]; struct initRelocationTable *rp; /* verify, that all entries are valid */ diff --git a/kernel/int2f.asm b/kernel/int2f.asm index 4a0cd059..5f0cea4e 100644 --- a/kernel/int2f.asm +++ b/kernel/int2f.asm @@ -58,6 +58,8 @@ Int2f3: je IntDosCal ; Dos Internal calls cmp ah,10h ; SHARE.EXE interrupt? je Int2f1 ; yes, do installation check + cmp ah,08h + je DriverSysCal ; DRIVER.SYS calls cmp ah,14h ; NLSFUNC.EXE interrupt? jne Int2f?iret ; yes, do installation check Int2f?14: ;; MUX-14 -- NLSFUNC API @@ -81,6 +83,15 @@ Int2f?14?1: or BYTE [bp-6], 1 Int2f?iret: iret +; DRIVER.SYS calls - now only 0803. +DriverSysCal: + extern _Dyn:wrt DGROUP + cmp al, 3 + jne Int2f?iret + mov di, seg _Dyn + mov ds, di + mov di, _Dyn+2 + jmp short Int2f?iret ;*********************************************************** @@ -151,6 +162,11 @@ _remote_close: mov al, 06h jmp short call_int2f + global _remote_commit +_remote_commit: + mov al, 07h + jmp short call_int2f + global _remote_read _remote_read: mov al, 08h jmp short call_int2f diff --git a/kernel/inthndlr.c b/kernel/inthndlr.c index 2e24a5f1..a0f0a734 100644 --- a/kernel/inthndlr.c +++ b/kernel/inthndlr.c @@ -37,7 +37,7 @@ BYTE *RcsId = #endif #ifdef TSC -static VOID StartTrace(VOID); +STATIC VOID StartTrace(VOID); static bTraceNext = FALSE; #endif @@ -368,7 +368,7 @@ VOID ASMCFUNC int21_service(iregs FAR * r) case 0x14: { - if (FcbRead(FP_DS_DX, &CritErrCode)) + if (FcbRead(FP_DS_DX, &CritErrCode, 0)) r->AL = 0; else r->AL = CritErrCode; @@ -377,7 +377,7 @@ VOID ASMCFUNC int21_service(iregs FAR * r) case 0x15: { - if (FcbWrite(FP_DS_DX, &CritErrCode)) + if (FcbWrite(FP_DS_DX, &CritErrCode, 0)) r->AL = 0; else r->AL = CritErrCode; @@ -497,11 +497,7 @@ VOID ASMCFUNC int21_service(iregs FAR * r) /* Set Interrupt Vector */ case 0x25: - { - VOID(INRPT FAR * p) () = FP_DS_DX; - - setvec(r->AL, p); - } + setvec(r->AL, FP_DS_DX); break; /* Dos Create New Psp */ @@ -701,9 +697,7 @@ VOID ASMCFUNC int21_service(iregs FAR * r) /* Get Interrupt Vector */ case 0x35: { - BYTE FAR *p; - - p = getvec((COUNT) r->AL); + intvec p = getvec((COUNT) r->AL); r->ES = FP_SEG(p); r->BX = FP_OFF(p); } @@ -1221,8 +1215,8 @@ VOID ASMCFUNC int21_service(iregs FAR * r) case 0x06: r->DS = FP_SEG(internal_data); r->SI = FP_OFF(internal_data); - r->CX = swap_always - internal_data; - r->DX = swap_indos - internal_data; + r->CX = swap_indos - internal_data; + r->DX = swap_always - internal_data; CLEAR_CARRY_FLAG(); break; @@ -1427,7 +1421,10 @@ VOID ASMCFUNC int21_service(iregs FAR * r) /* Flush file buffer -- COMMIT FILE -- dummy function right now. */ case 0x68: case 0x6a: - CLEAR_CARRY_FLAG(); + if ((rc = DosCommit(r->BX)) < 0) + goto error_exit; + else + CLEAR_CARRY_FLAG(); break; /* Get/Set Serial Number */ @@ -1718,16 +1715,15 @@ VOID ASMCFUNC int21_service(iregs FAR * r) CLEAR_CARRY_FLAG(); if (r->SI == 0) - mode = DSKREAD; + mode = DSKREADINT25; else - mode = DSKWRITE; - InDOS++; + mode = DSKWRITEINT26; r->AX = dskxfer(r->DL - 1, SectorBlock->blkno, SectorBlock->buf, SectorBlock->nblks, mode); - if (mode == DSKWRITE) + if (mode == DSKWRITEINT26) if (r->AX <= 0) setinvld(r->DL - 1); @@ -1735,15 +1731,12 @@ VOID ASMCFUNC int21_service(iregs FAR * r) { r->AX = 0x20c; r->flags |= FLG_CARRY; - --InDOS; return; } - - r->AX = 0; - r->flags &= ~FLG_CARRY; - --InDOS; break; } + default: + goto error_invalid; } break; } @@ -1754,49 +1747,36 @@ VOID ASMCFUNC int21_service(iregs FAR * r) { switch (r->AL) { - /* Allocate LFN inode */ + /* Allocate LFN inode */ case 0x01: - { - r->AX = lfn_allocate_inode(); - break; - } - /* Free LFN inode */ + rc = lfn_allocate_inode(); + break; + /* Free LFN inode */ case 0x02: - { - r->AX = lfn_free_inode(r->BX); - break; - } - /* Setup LFN inode */ + rc = lfn_free_inode(r->BX); + break; + /* Setup LFN inode */ case 0x03: - { - r->AX = lfn_setup_inode(r->BX, r->CX, r->DX); - break; - } - /* Create LFN entries */ + rc = lfn_setup_inode(r->BX, ((ULONG)r->CX << 16) | r->DX, ((ULONG)r->SI << 16) | r->DI); + break; + /* Create LFN entries */ case 0x04: - { - r->AX = lfn_create_entries(r->BX, (lfn_inode_ptr) FP_DS_DX); - break; - } - /* Delete LFN entries */ + rc = lfn_create_entries(r->BX, (lfn_inode_ptr)FP_DS_DX); + break; + /* Read next LFN */ case 0x05: - { - r->AX = lfn_remove_entries(r->BX); - break; - } - /* Read next LFN */ + rc = lfn_dir_read(r->BX, (lfn_inode_ptr)FP_DS_DX); + break; + /* Write SFN pointed by LFN inode */ case 0x06: - { - r->AX = lfn_dir_read(r->BX, (lfn_inode_ptr) FP_DS_DX); - break; - } - /* Write SFN pointed by LFN inode */ - case 0x07: - { - r->AX = lfn_dir_write(r->BX); - break; - } + rc = lfn_dir_write(r->BX); + break; + default: + goto error_invalid; } + r->AX = rc; + if (rc < 0) goto error_out; + else CLEAR_CARRY_FLAG(); break; } #endif @@ -1912,7 +1892,7 @@ VOID int26_handler(struct int25regs FAR * r) { int2526_handler(DSKWRITE,r); } */ #ifdef TSC -static VOID StartTrace(VOID) +STATIC VOID StartTrace(VOID) { if (bTraceNext) { diff --git a/kernel/intr.h b/kernel/intr.h index 5aa624e8..94f3f49c 100644 --- a/kernel/intr.h +++ b/kernel/intr.h @@ -6,4 +6,4 @@ struct REGPACK { unsigned r_bp, r_di, r_si, r_ds, r_es, r_flags; }; -extern void ASMCFUNC intr(int intrnr, struct REGPACK *rp); +void ASMCFUNC intr(int intrnr, struct REGPACK *rp); diff --git a/kernel/io.asm b/kernel/io.asm index 031f8fb8..347c33c5 100644 --- a/kernel/io.asm +++ b/kernel/io.asm @@ -170,19 +170,9 @@ _blk_dev equ $ dw 08c2h ; block device with ioctl dw GenStrategy dw blk_entry - global _nblk_rel -_nblk_rel db 4 + db 4 db 0,0,0,0,0,0,0 -; quick hack for MSC - global _Get_nblk_rel -_Get_nblk_rel: - mov ah,0 - mov al,[cs:_nblk_rel] - retf -;end of hack - - ; ; Temporary table until next release diff --git a/kernel/kernel.asm b/kernel/kernel.asm index d1c225ea..8ca501f2 100644 --- a/kernel/kernel.asm +++ b/kernel/kernel.asm @@ -29,6 +29,7 @@ ; %include "segs.inc" + %include "ludivmul.inc" segment PSP @@ -98,9 +99,9 @@ realentry: ; execution continues here beyond_entry: resb 256-(beyond_entry-entry) ; scratch area for data (DOS_PSP) -segment INIT_TEXT +segment INIT_TEXT - extern _FreeDOSmain:wrt IGROUP + extern _FreeDOSmain:wrt I_GROUP ; ; kernel start-up @@ -117,7 +118,7 @@ kernel_start: pop bx pop ax - mov ax,IGROUP + mov ax,I_GROUP cli mov ss,ax mov sp,init_tos @@ -170,7 +171,7 @@ cont: ; inititalize api stacks for high water tests popf pop bx pop ax - + inc bl jns floppy add bl,3-1-128 @@ -182,11 +183,21 @@ floppy: mov byte [_BootDrive],bl ; tell where we came from ;!! inc al ;!! mov byte [_NumFloppies],al ; and how many - mov ax,cs + mov ax,ss mov ds,ax mov es,ax jmp _FreeDOSmain +%ifdef WATCOM +global _IU4M +_IU4M: + LMULU +global _IU4D +_IU4D: + LDIVMODU +%endif + + segment INIT_TEXT_END @@ -621,7 +632,7 @@ __ib_end: ;; do not clear the other init BSS variables + STACK: too late. retoff resw 1 ; return offset to jump to from HMA_TEXT - + ; kernel startup stack global init_tos resw 512 @@ -651,6 +662,16 @@ clk_stk_top: global __bssend __bssend: + +; Dynamic data: +; member of the DOS DATA GROUP +; and marks definitive end of all used data in kernel data segment +; + +segment DYN_DATA + global _Dyn +_Dyn: + DynAllocated dw 0 segment ID_B global __INIT_DATA_START @@ -684,6 +705,16 @@ begin_hma: times 20h db 0 db 0 +%ifdef WATCOM +; 32 bit multiplication + division +global __U4M +__U4M: + LMULU +global __U4D +__U4D: + LDIVMODU +%endif + init_ret_np: push ds push word [retoff] retf ; return from init_calls. diff --git a/kernel/lfnapi.c b/kernel/lfnapi.c index 7a1c40cc..c4aea26d 100644 --- a/kernel/lfnapi.c +++ b/kernel/lfnapi.c @@ -16,278 +16,332 @@ static BYTE *lfnaidRcsId = #ifdef WITHLFNAPI -#define LHE_INVLDHNDL -1 -#define LHE_NOFREEHNDL -2 -#define LHE_IOERROR -3 -#define LHE_INVLDDRV -4 -#define LHE_DAMAGEDFS -5 -#define LHE_NOSPACE -6 -#define LHE_SEEK -7 +#define RESERVED_FNODES 3 /* # of reserved fnodes for the kernel internal * + * usage. If something wrong happens with the * + * driver using helper API and it grabs all * + * possible fnodes, the kernel doesn't hang. */ + +/* All possible error codes, returned by directory access functions */ +/* Note. SUCCESS is returned if all OK. */ +#define LHE_INVLDHNDL -1 /* Invalid inode handle passed. */ +#define LHE_NOFREEHNDL -2 /* Couldn't allocate another inode handle. */ +#define LHE_IOERROR -3 /* Couldn't do I/O because of the lack of * + * memory or due to a physical damage. */ +#define LHE_INVLDDRV -4 /* Invalid drive chosen. */ +#define LHE_DAMAGEDFS -5 /* Damaged file system encountered. */ +#define LHE_NOSPACE -6 /* There are no free clusters on drive. */ +#define LHE_SEEK -7 /* Attempt to read beyound the end of the dir. */ #define lfn(fnp) ((struct lfn_entry FAR *)&(fnp->f_dir)) #define CHARS_IN_LFN_ENTRY 13 #define UNICODE_FILLER 0xffff -COUNT ufstrlen(REG UNICODE FAR *); /* fstrlen for UNICODE strings */ -UBYTE lfn_checksum(UBYTE *); +COUNT ufstrlen(REG UNICODE FAR *); /* fstrlen for UNICODE strings */ +UBYTE lfn_checksum(UBYTE FAR *); COUNT extend_dir(f_node_ptr); -COUNT remove_lfn_entries(f_node_ptr fnp); - +BOOL lfn_to_unicode(UNICODE FAR **name, struct lfn_entry FAR *lep); +VOID unicode_to_lfn(UNICODE FAR **name, struct lfn_entry FAR *lep); + +/* Description. + * Allocates internal fnode and returns it's handle. + * Return value. + * LHE_NOFREEHNDL, LHE_INVLDDRV + * >= 0 - handle of the allocated fnode. + */ COUNT lfn_allocate_inode(VOID) { f_node_ptr fnp = get_f_node(); struct cds FAR *cdsp; - if (fnp == 0) - return LHE_NOFREEHNDL; + COUNT handle; + if (fnp == 0) return LHE_NOFREEHNDL; + + handle = xlt_fnp(fnp); + /* Check if there is at least # RESERVED_FNODES left for the kernel */ + if (f_nodes_cnt - handle < RESERVED_FNODES) + { + release_f_node(fnp); + return LHE_NOFREEHNDL; + } + /* Check that default drive is a block device */ cdsp = &CDSp->cds_table[default_drive]; if (cdsp->cdsDpb == 0) - { - release_f_node(fnp); - return LHE_INVLDDRV; - } + { + release_f_node(fnp); + return LHE_INVLDDRV; + } fnp->f_dpb = cdsp->cdsDpb; if (media_check(fnp->f_dpb) < 0) - { - release_f_node(fnp); - return LHE_INVLDDRV; - } + { + release_f_node(fnp); + return LHE_INVLDDRV; + } - return xlt_fnp(fnp); + return handle; } +/* Description. + * Free allocated internal fnode. + * Return value. + * SUCCESS, LHE_INVLDHNDL + */ COUNT lfn_free_inode(COUNT handle) { f_node_ptr fnp = xlt_fd(handle); - if (fnp == 0 || fnp->f_count <= 0) - return LHE_INVLDHNDL; + if (fnp == 0 || fnp->f_count <= 0) return LHE_INVLDHNDL; - release_f_node(fnp); + dir_close(fnp); return SUCCESS; } -COUNT lfn_setup_inode(COUNT handle, CLUSTER dirstart, ULONG diroff) +/* Description. + * Initialize internal fnode, so that it'll point to the directory entry + * at "diroff" byte offset from the start of the directory with the "dirstart" + * starting cluster. + * Return value. + * SUCCESS, LHE_INVLDHNDL + */ +COUNT lfn_setup_inode(COUNT handle, ULONG dirstart, ULONG diroff) { f_node_ptr fnp = xlt_fd(handle); - if (fnp == 0 || fnp->f_count <= 0) - return LHE_INVLDHNDL; + if (fnp == 0 || fnp->f_count <= 0) return LHE_INVLDHNDL; - dir_init_fnode(fnp, dirstart); + dir_init_fnode(fnp, (CLUSTER)dirstart); fnp->f_diroff = diroff; return SUCCESS; } -BOOL transfer_unicode(UNICODE FAR ** dptr, UNICODE FAR ** sptr, - COUNT count) -{ - COUNT j; - BOOL found_zerro = FALSE; - - for (j = 0; j < count; j++, (*dptr)++, (*sptr)++) - { - if (found_zerro) - **dptr = UNICODE_FILLER; - else - **dptr = **sptr; - if (**sptr == 0) - found_zerro = TRUE; - } - - return found_zerro; -} - -BOOL lfn_to_unicode(UNICODE FAR ** name, struct lfn_entry FAR * lep) +/* Description. + * Create LFN directory entries for the long name "lip->l_name", followed + * by the SFN entry with raw image "lip->l_dir". The "lip->l_diroff" points + * to the SFN entry on return. + * The internal fnode is released on fatal error, except LHE_INVLDHNDL of + * course. + * Return value. + * SUCCESS, LHE_INVLDHNDL, LHE_IOERROR, LHE_NOSPACE + */ +COUNT lfn_create_entries(COUNT handle, lfn_inode_ptr lip) { - UNICODE FAR *ptr; + f_node_ptr fnp = xlt_fd(handle); + COUNT entries_needed, free_entries, i, rc; + UNICODE FAR *lfn_name = lip->l_name; + UBYTE id = 1, sfn_checksum = lfn_checksum(lip->l_dir.dir_name); + ULONG sfn_offset; + if (fnp == 0 || fnp->f_count <= 0) return LHE_INVLDHNDL; - ptr = lep->lfn_name0_4; - if (!transfer_unicode(name, &ptr, 5)) - return FALSE; - ptr = lep->lfn_name5_10; - if (!transfer_unicode(name, &ptr, 6)) - return FALSE; - ptr = lep->lfn_name11_12; - if (!transfer_unicode(name, &ptr, 2)) - return FALSE; + entries_needed = (ufstrlen(lfn_name) + CHARS_IN_LFN_ENTRY - 1) + / CHARS_IN_LFN_ENTRY + 1; /* We want to create SFN entry too */ + + /* Scan the directory from the very begining for the free directory entries */ + lfn_setup_inode(handle, fnp->f_dirstart, 0); - return TRUE; -} + free_entries = 0; + while (TRUE) + { + rc = dir_read(fnp); + if (rc == 0 || fnp->f_dir.dir_name[0] == DELETED) + { + free_entries++; + if (free_entries == entries_needed) + break; + } + else if (rc == DE_BLKINVLD) + { + dir_close(fnp); + return LHE_IOERROR; + } + else if (rc == DE_SEEK) + { + if (extend_dir(fnp) != SUCCESS) return LHE_NOSPACE; + /* fnp points to the first free dir entry on return from extend_dir, + * so we go to previous entry to read this free entry on next cycle */ + fnp->f_diroff -= DIRENT_SIZE; + } + else free_entries = 0; /* rc == 1 here => we've read some sfn entry */ + } + sfn_offset = fnp->f_diroff; -VOID unicode_to_lfn(UNICODE FAR ** name, struct lfn_entry FAR * lep) -{ - UNICODE FAR *ptr; + fnp->f_flags.f_dmod = TRUE; + /* Write SFN entry */ + fmemcpy(&fnp->f_dir, &lip->l_dir, sizeof(struct dirent)); + dir_write(fnp); + + fnp->f_diroff -= DIRENT_SIZE; + /* Go in the reverse direction and create LFN entries */ + for (i = 0; i < entries_needed - 1; i++, id++) + { + /* If this is the last LFN entry mark it's as those (6th bit is on) */ + if (i == (entries_needed - 2)) id |= 0x40; + lfn_name = &lip->l_name[i * CHARS_IN_LFN_ENTRY]; + unicode_to_lfn(&lfn_name, lfn(fnp)); + lfn(fnp)->lfn_checksum = sfn_checksum; + lfn(fnp)->lfn_id = id; + fnp->f_dir.dir_attrib = D_LFN; + if (!dir_write(fnp)) return LHE_IOERROR; + fnp->f_diroff -= DIRENT_SIZE; + } + fnp->f_flags.f_dmod = FALSE; + + fnp->f_diroff = sfn_offset; - ptr = lep->lfn_name0_4; - transfer_unicode(&ptr, name, 5); - ptr = lep->lfn_name5_10; - transfer_unicode(&ptr, name, 6); - ptr = lep->lfn_name11_12; - transfer_unicode(&ptr, name, 2); + return SUCCESS; } +/* Description. + * Read next consequitve long file name. The LFN is stored into the + * "lip->l_name" in unicode and the corresponding SFN entry raw image into the + * "lip->l_dir". If directory entry being read is a 8.3 file name, then + * it's image is stored into the "lip->l_dir" and "lip->l_name" has zero + * length, i.e. "lip->l_name[0]" == 0. + * Return value. + * SUCCESS, LHE_INVLDHNDL, LHE_IOERROR, LHE_SEEK, LHE_DAMAGEDFS + */ COUNT lfn_dir_read(COUNT handle, lfn_inode_ptr lip) { COUNT rc; UBYTE id = 1, real_id; - UNICODE FAR *lfn_name = lip->name; + UNICODE FAR *lfn_name = lip->l_name; ULONG sfn_diroff; - BOOL name_tail = FALSE; + BOOL name_tail; f_node_ptr fnp = xlt_fd(handle); - if (fnp == 0 || fnp->f_count <= 0) - return LHE_INVLDHNDL; + if (fnp == 0 || fnp->f_count <= 0) return LHE_INVLDHNDL; + /* Scan a directory for the next valid SFN entry */ while (TRUE) - { - rc = dir_read(fnp); - if (rc == 0) - return SUCCESS; - else if (rc == DE_SEEK) - return LHE_SEEK; - else if (rc == DE_BLKINVLD) - return LHE_IOERROR; - if (fnp->f_dir.dir_name[0] != DELETED - && fnp->f_dir.dir_attrib != D_LFN) { - fmemcpy(&lip->l_dir, &fnp->f_dir, sizeof(struct dirent)); - sfn_diroff = fnp->f_diroff; - break; - } - } - fnp->f_diroff = lip->l_diroff; - - fmemset(lip->name, 0, 256 * sizeof(UNICODE)); + rc = dir_read(fnp); + if (rc == DE_SEEK) return LHE_SEEK; + else if (rc == DE_BLKINVLD) return LHE_IOERROR; + if (fnp->f_dir.dir_name[0] != DELETED && fnp->f_dir.dir_attrib != D_LFN) + { + fmemcpy(&lip->l_dir, &fnp->f_dir, sizeof(struct dirent)); + sfn_diroff = fnp->f_diroff; + break; + } + } + + /* Go in the reverse direction and find the LFN entries corresponding to + * the found SFN entry */ while (TRUE) - { - if (fnp->f_diroff == 0) - break; - fnp->f_diroff -= 2 * DIRENT_SIZE; - rc = dir_read(fnp); - if (rc == DE_BLKINVLD) - return LHE_IOERROR; - if (fnp->f_dir.dir_name[0] == DELETED - || fnp->f_dir.dir_attrib != D_LFN) - break; - name_tail = lfn_to_unicode(&lfn_name, lfn(fnp)); - real_id = lfn(fnp)->lfn_id; - if (real_id & 0x40) - { - if ((real_id | 0x40) != id) - return LHE_DAMAGEDFS; - } - else { - if (name_tail || real_id != id - || lfn(fnp)->lfn_checksum != lfn_checksum(fnp->f_dir.dir_name)) - return LHE_DAMAGEDFS; + if (fnp->f_diroff == 0) break; + fnp->f_diroff -= 2*DIRENT_SIZE; + rc = dir_read(fnp); + if (rc == DE_BLKINVLD) return LHE_IOERROR; + if (fnp->f_dir.dir_name[0] == DELETED + || fnp->f_dir.dir_attrib != D_LFN) break; + real_id = lfn(fnp)->lfn_id; + if ((real_id & 0x3f) > 20) return LHE_DAMAGEDFS; + name_tail = lfn_to_unicode(&lfn_name, lfn(fnp)); + if (real_id & 0x40) + { + if ((id | 0x40) != real_id) return LHE_DAMAGEDFS; + break; + } + else + { + if (name_tail || real_id != id + || lfn(fnp)->lfn_checksum != lfn_checksum(lip->l_dir.dir_name)) + return LHE_DAMAGEDFS; + } + id++; } - } + + *lfn_name = 0; /* Terminate LFN string */ fnp->f_diroff = lip->l_diroff = sfn_diroff; - fnp->f_flags.f_dnew = TRUE; return SUCCESS; } +/* Description. + * Writes directory entry pointed by internal fnode to disk. + * The fnode is released on error. + * Return value. + * SUCCESS, LHE_INVLDHNDL, LHE_IOERROR. + */ COUNT lfn_dir_write(COUNT handle) { f_node_ptr fnp = xlt_fd(handle); - if (fnp == 0 || fnp->f_count <= 0) - return LHE_INVLDHNDL; - - if (!dir_write(fnp)) - { - lfn_allocate_inode(); /* protection against dir_write fault - * this must restore things to the state before - * the call */ - /* Yes, it's a hack! */ - return LHE_IOERROR; - } + if (fnp == 0 || fnp->f_count <= 0) return LHE_INVLDHNDL; + + fnp->f_flags.f_dmod = TRUE; + if (!dir_write(fnp)) return LHE_IOERROR; + fnp->f_flags.f_dmod = FALSE; return SUCCESS; } -COUNT lfn_create_entries(COUNT handle, lfn_inode_ptr lip) +/*********************************************************************/ +/* Miscellaneous functions. These functions are not part of the API. */ +/*********************************************************************/ + +/* Description. + * Copy the block of "count" unicode characters from source pointed by + * "sptr" to destination pointed by "dptr". The trailing characters of + * destination are filled with "UNICODE_FILLER". + * Return value. + * TRUE - The source string is too short, trailing characters are filled + * with "UNICODE_FILLER". + * FALSE - The unicode strings have the same size, no filling occured. + */ +BOOL transfer_unicode(UNICODE FAR **dptr, UNICODE FAR **sptr, COUNT count) { - f_node_ptr fnp = xlt_fd(handle); - COUNT entries_needed, free_entries, i, rc; - UNICODE FAR *lfn_name = lip->name; - ULONG sfn_offset; - if (fnp == 0 || fnp->f_count <= 0) - return LHE_INVLDHNDL; - - entries_needed = (ufstrlen(lfn_name) + CHARS_IN_LFN_ENTRY - 1) / CHARS_IN_LFN_ENTRY + 1; /* We want to create SFN entry too */ - - /* Scan the directory from the very begining for the free directory entries */ - lfn_setup_inode(handle, fnp->f_dirstart, 0); + COUNT j; + BOOL found_zerro = FALSE; - free_entries = 0; - while ((rc = dir_read(fnp)) == 1) - { - if (fnp->f_dir.dir_name[0] == DELETED) - { - free_entries++; - if (free_entries == entries_needed) - break; - } - else - free_entries = 0; - } - if (rc == DE_BLKINVLD) - return LHE_IOERROR; - /* We have reached the end of the directory here. */ - - if (free_entries != entries_needed) - free_entries = 0; - while (free_entries != entries_needed) - { - rc = dir_read(fnp); - if (rc == 0) - free_entries++; - else if (rc == DE_BLKINVLD) - return LHE_IOERROR; - else if (rc == DE_SEEK && extend_dir(fnp) != SUCCESS) + for (j = 0; j < count; j++, (*dptr)++, (*sptr)++) { - lfn_allocate_inode(); /* Another hack. */ - return LHE_IOERROR; + if (found_zerro) **dptr = UNICODE_FILLER; + else **dptr = **sptr; + if (**sptr == 0) found_zerro = TRUE; } - } - sfn_offset = fnp->f_diroff; - fnp->f_diroff -= DIRENT_SIZE; - - for (i = entries_needed - 2; i >= 0; i++) - { - lfn_name = &lip->name[i * CHARS_IN_LFN_ENTRY]; - unicode_to_lfn(&lfn_name, lfn(fnp)); - fnp->f_dir.dir_attrib = D_LFN; - if (!dir_write(fnp)) - return LHE_IOERROR; - fnp->f_diroff -= DIRENT_SIZE; - } - fnp->f_diroff = sfn_offset; - - return SUCCESS; + return found_zerro; } -COUNT lfn_remove_entries(COUNT handle) +/* Description. + * Retrieve the LFN string chunk from the directory entry "lep" and store it + * to the "name" unicode string. + * Return value. + * TRUE - The LFN string chunk contains zero character. + * FALSE - Doesn't terminate with zero. + */ +BOOL lfn_to_unicode(UNICODE FAR **name, struct lfn_entry FAR *lep) { - f_node_ptr fnp = xlt_fd(handle); - if (fnp == 0 || fnp->f_count <= 0) - return LHE_INVLDHNDL; + UNICODE FAR *ptr; + + ptr = lep->lfn_name0_4; + if (transfer_unicode(name, &ptr, 5)) return TRUE; + ptr = lep->lfn_name5_10; + if (transfer_unicode(name, &ptr, 6)) return TRUE; + ptr = lep->lfn_name11_12; + if (transfer_unicode(name, &ptr, 2)) return TRUE; - if (remove_lfn_entries(fnp) < 0) - return LHE_IOERROR; + return FALSE; +} - return SUCCESS; +/* Description. + */ +VOID unicode_to_lfn(UNICODE FAR **name, struct lfn_entry FAR *lep) +{ + UNICODE FAR *ptr; + + ptr = lep->lfn_name0_4; + transfer_unicode(&ptr, name, 5); + ptr = lep->lfn_name5_10; + transfer_unicode(&ptr, name, 6); + ptr = lep->lfn_name11_12; + transfer_unicode(&ptr, name, 2); } /* Calculate checksum for the 8.3 name */ -UBYTE lfn_checksum(UBYTE * sfn_name) +UBYTE lfn_checksum(UBYTE FAR *sfn_name) { UBYTE sum; COUNT i; @@ -298,7 +352,7 @@ UBYTE lfn_checksum(UBYTE * sfn_name) return sum; } -COUNT ufstrlen(REG UNICODE FAR * s) +COUNT ufstrlen(REG UNICODE FAR *s) { REG COUNT cnt = 0; diff --git a/kernel/ludivmul.inc b/kernel/ludivmul.inc new file mode 100644 index 00000000..fd60406f --- /dev/null +++ b/kernel/ludivmul.inc @@ -0,0 +1,144 @@ +; these are adapted from elks, http://elks.sourceforge.net +; multiply cx:bx * dx:ax, result in dx:ax + +%macro LMULU 0 + + push si + push cx + mov si,ax ; save _ax in si + mov ax,bx ; cx:ax = _cx:_bx + mul dx ; dx:ax = _bx*_dx (forget dx) + xchg cx,ax ; cx = low(_dx*_bx) + mul si ; dx:ax = _cx*_ax (forget dx) + add cx,ax ; cx = low(_cx*_ax + _dx*_bx) + mov ax,si ; restore _ax + mul bx ; dx:ax = _bx*_ax + add dx,cx ; dx = high(_bx*_ax)+low(_cx*_ax + _dx*_bx) + pop cx + pop si + ret + +%endmacro + +; divide dx:ax / cx:bx, quotient in dx:ax, remainder in cx:bx + +%macro LDIVMODU 0 +; ldivmod.s - 32 over 32 to 32 bit division and remainder for 8086 + +; ludivmod( dividend bx:ax, divisor di:cx ) [ unsigned quot di:cx, rem bx:ax ] + +; dx is not preserved + + +; NB negatives are handled correctly, unlike by the processor +; divison by zero does not trap + + +; let dividend = a, divisor = b, quotient = q, remainder = r +; a = b * q + r mod 2^32 +; where: + +; if b = 0, q = 0 and r = a + +; otherwise, q and r are uniquely determined by the requirements: +; r has the same sign as b and absolute value smaller than that of b, i.e. +; 0 <= r < b + + push di + mov di,cx + mov cx,bx + mov bx,dx + + push bp + push si + mov bp,sp + push di ; remember b + push cx + +%assign b0 -4 +%assign b16 -2 + + test di,di + jne %%divlarge + test cx,cx + je %%return ; divzero: return q = 0 and r = a + cmp bx,cx + jae %%divlarge ; would overflow + mov dx,bx ; a in dx:ax + div cx + xchg cx,ax ; q in di:cx, junk in ax + xchg ax,dx ; r in ax, junk in dx + mov bx,di ; r in bx:ax + jmp %%return + +%%divlarge: + mov si,di ; w in si:dx, initially b from di:cx + mov dx,cx + xor cx,cx ; q in di:cx, initially 0 + mov di,cx + +; r in bx:ax, initially a +; use di:cx rather than dx:cx in order to +; have dx free for a byte pair later + + cmp si,bx + jb %%loop1 + ja %%return ; finished if b > r + cmp dx,ax + ja %%return + +; rotate w (= b) to greatest dyadic multiple of b <= r + +%%loop1: + shl dx,1 ; w = 2*w + rcl si,1 + jc %%loop1_exit ; w was > r counting overflow (unsigned) + cmp si,bx ; while w <= r (unsigned) + jb %%loop1 + ja %%loop1_exit + cmp dx,ax + jbe %%loop1 ; else exit with carry clear for rcr + +%%loop1_exit: + rcr si,1 + rcr dx,1 + +%%loop2: + shl cx,1 ; q = 2*q + rcl di,1 + cmp si,bx ; if w <= r + jb %%loop2_over + ja %%loop2_test + cmp dx,ax + ja %%loop2_test + +%%loop2_over: + add cx,1 ; q++ + adc di,0 + sub ax,dx ; r = r-w + sbb bx,si + +%%loop2_test: + shr si,1 ; w = w/2 + rcr dx,1 + cmp si,[bp+b16] ; while w >= b + ja %%loop2 + jb %%return + cmp dx,[bp+b0] + jae %%loop2 + +%%return: + mov sp,bp + pop si + pop bp + + mov dx,bx + mov bx,ax + mov ax,cx + mov cx,dx + mov dx,di + pop di + + ret + +%endmacro \ No newline at end of file diff --git a/kernel/main.c b/kernel/main.c index 322664b8..4a0bc652 100644 --- a/kernel/main.c +++ b/kernel/main.c @@ -47,28 +47,30 @@ GLOBAL BYTE copyright[] = -- Bart */ -extern UBYTE DOSFAR nblkdev, DOSFAR lastdrive; /* value of last drive */ +extern UBYTE DOSFAR ASM nblkdev, DOSFAR ASM lastdrive; /* value of last drive */ GLOBAL BYTE DOSFAR os_major, /* major version number */ DOSFAR os_minor, /* minor version number */ - DOSFAR dosidle_flag, DOSFAR BootDrive, /* Drive we came up from */ - DOSFAR default_drive; /* default drive for dos */ + DOSFAR dosidle_flag, DOSFAR ASM BootDrive, /* Drive we came up from */ + DOSFAR ASM default_drive; /* default drive for dos */ GLOBAL BYTE DOSFAR os_release[]; /* GLOBAL BYTE DOSFAR copyright[]; */ GLOBAL seg DOSFAR RootPsp; /* Root process -- do not abort */ -extern struct dpb FAR *DOSFAR DPBp; /* First drive Parameter Block */ -extern cdstbl FAR *DOSFAR CDSp; /* Current Directory Structure */ +extern struct dpb FAR *DOSFAR ASM DPBp; /* First drive Parameter Block */ +extern cdstbl FAR *DOSFAR ASM CDSp; /* Current Directory Structure */ -extern struct dhdr FAR *DOSFAR clock, /* CLOCK$ device */ - FAR * DOSFAR syscon; /* console device */ -extern struct dhdr DOSTEXTFAR con_dev, /* console device drive */ - DOSTEXTFAR clk_dev, /* Clock device driver */ - DOSTEXTFAR blk_dev; /* Block device (Disk) driver */ -extern UWORD DOSFAR ram_top; /* How much ram in Kbytes */ -extern iregs FAR *DOSFAR user_r; /* User registers for int 21h call */ -extern BYTE FAR _HMATextEnd[]; +extern struct dhdr FAR *DOSFAR ASM clock, /* CLOCK$ device */ + FAR * DOSFAR ASM syscon; /* console device */ +extern struct dhdr ASM DOSTEXTFAR con_dev, /* console device drive */ + DOSTEXTFAR ASM clk_dev, /* Clock device driver */ + DOSTEXTFAR ASM blk_dev; /* Block device (Disk) driver */ +extern UWORD DOSFAR ASM ram_top; /* How much ram in Kbytes */ +extern iregs FAR *DOSFAR ASM user_r; /* User registers for int 21h call */ +extern BYTE FAR ASM _HMATextEnd[]; + +extern struct _KernelConfig FAR ASM LowKernelConfig; #ifdef VERSION_STRINGS static BYTE *mainRcsId = @@ -82,17 +84,17 @@ extern BYTE FAR *lpBase; extern BYTE FAR *lpOldTop; extern BYTE FAR *lpTop; extern BYTE FAR *upBase; -extern BYTE _ib_start[], _ib_end[], _init_end[]; +extern BYTE ASM _ib_start[], ASM _ib_end[], ASM _init_end[]; -INIT VOID configDone(VOID); -INIT static void InitIO(void); +VOID configDone(VOID); +STATIC VOID InitIO(void); -INIT static VOID update_dcb(struct dhdr FAR *); -INIT static VOID init_kernel(VOID); -INIT static VOID signon(VOID); -INIT VOID kernel(VOID); -INIT VOID FsConfig(VOID); -INIT VOID InitPrinters(VOID); +STATIC VOID update_dcb(struct dhdr FAR *); +STATIC VOID init_kernel(VOID); +STATIC VOID signon(VOID); +STATIC VOID kernel(VOID); +STATIC VOID FsConfig(VOID); +STATIC VOID InitPrinters(VOID); #ifdef _MSC_VER BYTE _acrtused = 0; @@ -106,7 +108,7 @@ __segment DosTextSeg = 0; #endif -INIT VOID ASMCFUNC FreeDOSmain(void) +VOID ASMCFUNC FreeDOSmain(void) { #ifdef _MSC_VER extern FAR DATASTART; @@ -115,7 +117,33 @@ INIT VOID ASMCFUNC FreeDOSmain(void) DosTextSeg = (__segment) & prn_dev; #endif - fmemcpy(&InitKernelConfig, &LowKernelConfig, sizeof(InitKernelConfig)); + + /* if the kernel has been UPX'ed, + CONFIG info is stored at 50:e2 ..fc + and the bootdrive (passed from BIOS) + at 50:e0 + */ + + if (fmemcmp(MK_FP(0x50,0xe0+2),"CONFIG",6) == 0) /* UPX */ + { + fmemcpy(&InitKernelConfig, MK_FP(0x50,0xe0+2), sizeof(InitKernelConfig)); + + BootDrive = *(BYTE FAR *)MK_FP(0x50,0xe0); + + BootDrive ++; + + if ((unsigned)BootDrive >= 0x80) + BootDrive += 3-1-128; + + + *(DWORD FAR *)MK_FP(0x50,0xe0+2) = 0; + + } + else + { + + fmemcpy(&InitKernelConfig, &LowKernelConfig, sizeof(InitKernelConfig)); + } setvec(0, int0_handler); /* zero divide */ setvec(1, empty_handler); /* single step */ @@ -157,7 +185,7 @@ void InitializeAllBPBs(VOID) } } -INIT void init_kernel(void) +STATIC void init_kernel(void) { COUNT i; @@ -223,7 +251,8 @@ INIT void init_kernel(void) #ifndef KDB /* Now process CONFIG.SYS */ - DoConfig(); + DoConfig(0); + DoConfig(1); /* Close all (device) files */ for (i = 0; i < lastdrive; i++) @@ -238,7 +267,7 @@ INIT void init_kernel(void) FsConfig(); /* and process CONFIG.SYS one last time to load device drivers. */ - DoConfig(); + DoConfig(2); configDone(); /* Close all (device) files */ @@ -252,29 +281,11 @@ INIT void init_kernel(void) InitializeAllBPBs(); } -INIT VOID FsConfig(VOID) +STATIC VOID FsConfig(VOID) { REG COUNT i; struct dpb FAR *dpb; - /* The system file tables need special handling and are "hand */ - /* built. Included is the stdin, stdout, stdaux and stdprn. */ - - /* 0 is /dev/con (stdin) */ - open("CON", O_RDWR); - - /* 1 is /dev/con (stdout) */ - dup2(STDIN, STDOUT); - - /* 2 is /dev/con (stderr) */ - dup2(STDIN, STDERR); - - /* 3 is /dev/aux */ - open("AUX", O_RDWR); - - /* 4 is /dev/prn */ - open("PRN", O_WRONLY); - /* Log-in the default drive. */ /* Get the boot drive from the ipl and use it for default. */ default_drive = BootDrive - 1; @@ -305,11 +316,29 @@ INIT VOID FsConfig(VOID) pcds_table->cdsJoinOffset = 2; } + /* The system file tables need special handling and are "hand */ + /* built. Included is the stdin, stdout, stdaux and stdprn. */ + + /* 0 is /dev/con (stdin) */ + open("CON", O_RDWR); + + /* 1 is /dev/con (stdout) */ + dup2(STDIN, STDOUT); + + /* 2 is /dev/con (stderr) */ + dup2(STDIN, STDERR); + + /* 3 is /dev/aux */ + open("AUX", O_RDWR); + + /* 4 is /dev/prn */ + open("PRN", O_WRONLY); + /* Initialize the disk buffer management functions */ /* init_call_init_buffers(); done from CONFIG.C */ } -INIT VOID signon() +STATIC VOID signon() { printf("\n%S", (void FAR *)os_release); @@ -336,7 +365,7 @@ INIT VOID signon() printf("\n\n%S", (void FAR *)copyright); } -INIT void kernel() +STATIC void kernel() { #if 0 BYTE FAR *ep, *sp; @@ -465,7 +494,7 @@ INIT void kernel() } /* check for a block device and update device control block */ -static VOID update_dcb(struct dhdr FAR * dhp) +STATIC VOID update_dcb(struct dhdr FAR * dhp) { REG COUNT Index; COUNT nunits = dhp->dh_name[0]; @@ -563,10 +592,9 @@ BOOL init_device(struct dhdr FAR * dhp, BYTE FAR * cmdLine, COUNT mode, return FALSE; } -INIT static void InitIO(void) +STATIC void InitIO(void) { /* Initialize driver chain */ - setvec(0x29, int29_handler); /* Requires Fast Con Driver */ init_device(&con_dev, NULL, NULL, ram_top); init_device(&clk_dev, NULL, NULL, ram_top); @@ -587,7 +615,7 @@ VOID init_fatal(BYTE * err_msg) I usually much more often reset my system, then I print :-) */ -INIT VOID InitPrinters(VOID) +STATIC VOID InitPrinters(VOID) { iregs r; int num_printers, i; diff --git a/kernel/makefile b/kernel/makefile index f0b22fe3..3fd72247 100644 --- a/kernel/makefile +++ b/kernel/makefile @@ -26,15 +26,14 @@ HDR=../hdr/ # 'standard' compiles .c.obj : - $(CC) $(CFLAGS) -c $*.c - $(PATCHOBJ) $*.obj $(STDPATCH) + $(CC) $(CFLAGS) -c $< + $(STDPATCH) $*.obj # *List Macros* EXE_dependencies = \ apisupt.obj \ - rtlsupt.obj \ asmsupt.obj \ blockio.obj \ break.obj \ @@ -81,7 +80,6 @@ EXE_dependencies = \ systime.obj \ task.obj \ inithma.obj \ - dyndata.obj \ dyninit.obj # *Explicit Rules* @@ -94,7 +92,8 @@ production: ..\bin\kernel.sys copy kernel.map ..\bin\$(THETARGET).map kernel.sys: kernel.exe ..\utils\exeflat.exe - ..\utils\exeflat kernel.exe kernel.sys 0x60 -S0x10 -S0x8B + $(XUPX) kernel.exe + ..\utils\exeflat kernel.exe kernel.sys 0x60 -S0x10 -S0x8B $(UPXOPT) clobber: clean -$(RM) kernel.exe kernel.sys status.me @@ -113,9 +112,9 @@ kernel.exe: $(EXE_dependencies) $(LIBS) $(LIBUTIL) kernel.lib $(LIBPLUS)dosnames.obj $(LIBPLUS)prf.obj $(LIBPLUS)strings.obj $(LIBPLUS)network.obj $(LIBPLUS)sysclk.obj $(LIBPLUS)syspack.obj$(LIBTERM) $(LIBUTIL) kernel.lib $(LIBPLUS)systime.obj $(LIBPLUS)task.obj $(LIBPLUS)int2f.obj $(LIBPLUS)irqstack.obj $(LIBPLUS)apisupt.obj$(LIBTERM) $(LIBUTIL) kernel.lib $(LIBPLUS)asmsupt.obj $(LIBPLUS)execrh.obj $(LIBPLUS)nlssupt.obj $(LIBPLUS)procsupt.obj $(LIBPLUS)break.obj$(LIBTERM) - $(LIBUTIL) kernel.lib $(LIBPLUS)dosidle.obj $(LIBPLUS)dyndata.obj $(LIBPLUS)dyninit.obj $(LIBPLUS)rtlsupt.obj $(LIBTERM) + $(LIBUTIL) kernel.lib $(LIBPLUS)dosidle.obj $(LIBPLUS)dyninit.obj $(LIBPLUS)lfnapi.obj $(LIBTERM) -$(RM) kernel.bak - $(LINK) kernel iprf,kernel,kernel,kernel+$(LIBS); + $(LINK) kernel iprf,kernel,kernel,kernel+$(LIBS)+..\lib\libm.lib; -$(RM) kernel.lib # *Individual File Dependencies* @@ -131,8 +130,6 @@ entry.obj: entry.asm segs.inc $(HDR)stacks.inc apisupt.obj: apisupt.asm segs.inc -rtlsupt.obj: rtlsupt.asm segs.inc - execrh.obj: execrh.asm segs.inc int2f.obj: int2f.asm segs.inc @@ -168,43 +165,43 @@ HEADERS=\ # XXX: I generated these using `gcc -MM' and `sed', so they may not be # completely correct... -- ror4 -blockio.obj: blockio.c $(HEADERS) $(CONFIGURATION) +#blockio.obj: blockio.c $(HEADERS) $(CONFIGURATION) -break.obj: break.c $(HEADERS) $(CONFIGURATION) +#break.obj: break.c $(HEADERS) $(CONFIGURATION) -chario.obj: chario.c $(HEADERS) $(CONFIGURATION) +#chario.obj: chario.c $(HEADERS) $(CONFIGURATION) -dosfns.obj: dosfns.c $(HEADERS) $(CONFIGURATION) +#dosfns.obj: dosfns.c $(HEADERS) $(CONFIGURATION) -dosnames.obj: dosnames.c $(HEADERS) $(CONFIGURATION) +#dosnames.obj: dosnames.c $(HEADERS) $(CONFIGURATION) -dsk.obj: dsk.c $(HEADERS) $(CONFIGURATION) +#dsk.obj: dsk.c $(HEADERS) $(CONFIGURATION) -error.obj: error.c $(HEADERS) $(CONFIGURATION) +#error.obj: error.c $(HEADERS) $(CONFIGURATION) -fatdir.obj: fatdir.c $(HEADERS) $(CONFIGURATION) +#fatdir.obj: fatdir.c $(HEADERS) $(CONFIGURATION) -fatfs.obj: fatfs.c $(HEADERS) $(CONFIGURATION) +#fatfs.obj: fatfs.c $(HEADERS) $(CONFIGURATION) -fattab.obj: fattab.c $(HEADERS) $(CONFIGURATION) +#fattab.obj: fattab.c $(HEADERS) $(CONFIGURATION) -fcbfns.obj: fcbfns.c $(HEADERS) $(CONFIGURATION) +#fcbfns.obj: fcbfns.c $(HEADERS) $(CONFIGURATION) -inthndlr.obj: inthndlr.c $(HEADERS) $(CONFIGURATION) +#inthndlr.obj: inthndlr.c $(HEADERS) $(CONFIGURATION) -ioctl.obj: ioctl.c $(HEADERS) $(CONFIGURATION) +#ioctl.obj: ioctl.c $(HEADERS) $(CONFIGURATION) -memmgr.obj: memmgr.c $(HEADERS) $(CONFIGURATION) +#memmgr.obj: memmgr.c $(HEADERS) $(CONFIGURATION) -misc.obj: misc.c $(HEADERS) $(CONFIGURATION) +#misc.obj: misc.c $(HEADERS) $(CONFIGURATION) -lfnapi.obj: lfnapi.c $(HEADERS) $(CONFIGURATION) +#lfnapi.obj: lfnapi.c $(HEADERS) $(CONFIGURATION) -newstuff.obj: newstuff.c $(HEADERS) $(CONFIGURATION) +#newstuff.obj: newstuff.c $(HEADERS) $(CONFIGURATION) -network.obj: network.c $(HEADERS) $(CONFIGURATION) +#network.obj: network.c $(HEADERS) $(CONFIGURATION) -nls.obj: nls.c $(HEADERS) $(CONFIGURATION) +#nls.obj: nls.c $(HEADERS) $(CONFIGURATION) # \ # 001-437.nls @@ -229,37 +226,32 @@ task.obj: task.c $(HEADERS) $(CONFIGURATION) config.obj: config.c $(INITHEADERS) $(HEADERS) $(CONFIGURATION) $(CC) $(INITCFLAGS) -c $*.c - $(PATCHOBJ) $*.obj $(INITPATCH) + $(INITPATCH) $*.obj initoem.obj: initoem.c $(INITHEADERS) $(HEADERS) $(CONFIGURATION) $(CC) $(INITCFLAGS) -c $*.c - $(PATCHOBJ) $*.obj $(INITPATCH) + $(INITPATCH) $*.obj main.obj: main.c $(INITHEADERS) $(HEADERS) $(CONFIGURATION) $(CC) $(INITCFLAGS) -c $*.c - $(PATCHOBJ) $*.obj $(INITPATCH) + $(INITPATCH) $*.obj inithma.obj: inithma.c $(INITHEADERS) $(HEADERS) $(CONFIGURATION) $(CC) $(INITCFLAGS) -c $*.c - $(PATCHOBJ) $*.obj $(INITPATCH) + $(INITPATCH) $*.obj dyninit.obj: dyninit.c $(INITHEADERS) $(HEADERS) $(CONFIGURATION) $(CC) $(INITCFLAGS) -c $*.c - $(PATCHOBJ) $*.obj $(INITPATCH) + $(INITPATCH) $*.obj initdisk.obj: initdisk.c $(INITHEADERS) $(HEADERS) $(CONFIGURATION) $(CC) $(INITCFLAGS) -c $*.c - $(PATCHOBJ) $*.obj $(INITPATCH) + $(INITPATCH) $*.obj #the printf for INIT_TEXT - yet another special case, this file includes prf.c iprf.obj: iprf.c prf.c $(HDR)\portab.h $(CONFIGURATION) $(CC) $(INITCFLAGS) -c $*.c - $(PATCHOBJ) $*.obj $(INITPATCH) - -#dynamic NEAR data -dyndata.obj: dyndata.c dyndata.h - $(CC) $(DYNCFLAGS) -c $*.c - $(PATCHOBJ) $*.obj $(DYNPATCH) + $(INITPATCH) $*.obj # Log: makefile,v # diff --git a/kernel/memmgr.c b/kernel/memmgr.c index 54e673dd..6edaf5ef 100644 --- a/kernel/memmgr.c +++ b/kernel/memmgr.c @@ -60,7 +60,7 @@ void FAR *nxtMCBsize(mcb FAR * Mcb, int size) * SUCCESS: on success * else: error number <> */ -static COUNT joinMCBs(mcb FAR * p) +STATIC COUNT joinMCBs(mcb FAR * p) { mcb FAR *q; @@ -95,7 +95,7 @@ seg long2para(ULONG size) /* * Add a displacement to a far pointer and return the result normalized. */ -VOID FAR *add_far(VOID FAR * fp, ULONG off) +VOID FAR * add_far(VOID FAR * fp, ULONG off) { UWORD off2; @@ -111,7 +111,7 @@ VOID FAR *add_far(VOID FAR * fp, ULONG off) /* * Return a normalized far pointer */ -VOID FAR *adjust_far(VOID FAR * fp) +VOID FAR * adjust_far(VOID FAR * fp) { /* and return an adddress adjusted to the nearest paragraph */ /* boundary. */ diff --git a/kernel/newstuff.c b/kernel/newstuff.c index c16c5ec7..f00070f9 100644 --- a/kernel/newstuff.c +++ b/kernel/newstuff.c @@ -32,7 +32,6 @@ static BYTE *mainRcsId = #include "portab.h" #include "globals.h" -#include "proto.h" /* TE-TODO: if called repeatedly by same process, @@ -158,7 +157,7 @@ COUNT get_verify_drive(char FAR * src) */ -COUNT ASMCFUNC truename(char FAR * src, char FAR * dest, COUNT t) +COUNT truename(char FAR * src, char FAR * dest, COUNT t) { static char buf[128] = "A:\\\0\0\0\0\0\0\0\0\0"; char *bufp = buf + 3; diff --git a/kernel/nls_load.c b/kernel/nls_load.c index 96994fee..add643a2 100644 --- a/kernel/nls_load.c +++ b/kernel/nls_load.c @@ -42,14 +42,14 @@ static BYTE *RcsId = #define cntry Config.cfgCSYS_cntry #define cp Config.cfgCSYS_cp -static int err(void) +STATIC int err(void) { printf("Syntax error in or invalid COUNTRY.SYS: \"%s\"\n", filename); return 0; } #define readStruct(s) readStructure(&(s), sizeof(s), fd) -static int readStructure(void *buf, int size, COUNT fd) +STATIC int readStructure(void *buf, int size, COUNT fd) { if (DosRead(fd, buf, size) == size) return 1; @@ -102,7 +102,7 @@ COUNT csysOpen(void) /* Searches for function definition of table #fctID and moves it at index idx */ -static int chkTable(int idx, int fctID, struct csys_function *fcts, +STATIC int chkTable(int idx, int fctID, struct csys_function *fcts, int numFct) { struct csys_function *fct, hfct; diff --git a/kernel/prf.c b/kernel/prf.c index 8e112e0d..cef1a4f9 100644 --- a/kernel/prf.c +++ b/kernel/prf.c @@ -28,10 +28,21 @@ #include "portab.h" -/*#define DOSEMU*/ +#ifdef FORSYS +#include +#endif + +/*#define DOSEMU */ + +#ifdef DOSEMU +#define MAX_BUFSIZE 80 /* adjust if necessary */ +static int buff_offset = 0; +static char buff[MAX_BUFSIZE]; +#endif #ifdef _INIT #define fstrlen reloc_call_fstrlen +#define handle_char init_handle_char #define put_console init_put_console #define ltob init_ltob #define do_printf init_do_printf @@ -50,24 +61,14 @@ static BYTE *prfRcsId = static BYTE *charp = 0; -#ifdef PROTO -VOID handle_char(COUNT); -VOID put_console(COUNT); -BYTE *ltob(LONG, BYTE *, COUNT); -COUNT do_printf(CONST BYTE *, REG BYTE **); -#else -VOID handle_char(); -VOID put_console(); -BYTE *ltob(); -COUNT do_printf(); -#endif +STATIC VOID handle_char(COUNT); +STATIC VOID put_console(COUNT); +STATIC BYTE * ltob(LONG, BYTE *, COUNT); +STATIC COUNT do_printf(CONST BYTE *, REG BYTE **); +WORD CDECL printf(CONST BYTE * fmt, ...); /* The following is user supplied and must match the following prototype */ -#ifdef PROTO VOID cso(COUNT); -#else -VOID cso(); -#endif #ifdef FORSYS COUNT fstrlen(BYTE FAR * s) /* don't want globals.h, sorry */ @@ -82,6 +83,30 @@ COUNT fstrlen(BYTE FAR * s) /* don't want globals.h, sorry */ #endif /* special console output routine */ +#ifdef DOSEMU +VOID put_console(COUNT c) +{ + if (buff_offset >= MAX_BUFSIZE) + { + buff_offset = 0; + printf("Printf buffer overflow!\n"); + } + if (c == '\n') + { + buff[buff_offset] = 0; + buff_offset = 0; + _ES = FP_SEG(buff); + _DX = FP_OFF(buff); + _AX = 0x13; + __int__(0xe6); + } + else + { + buff[buff_offset] = c; + buff_offset++; + } +} +#else VOID put_console(COUNT c) { if (c == '\n') @@ -103,11 +128,12 @@ VOID put_console(COUNT c) int 0x10; } #endif /* __TURBO__ */ -#endif +#endif /* FORSYS */ } +#endif /* DOSEMU */ /* special handler to switch between sprintf and printf */ -static VOID handle_char(COUNT c) +STATIC VOID handle_char(COUNT c) { if (charp == 0) put_console(c); @@ -157,30 +183,13 @@ BYTE *ltob(LONG n, BYTE * s, COUNT base) #define RIGHT 1 /* printf -- short version of printf to conserve space */ -#ifdef DOSEMU -WORD printf(CONST BYTE * fmt, ...) -{ - WORD ret; - - static char buff[80]; /* adjust if necessary */ - charp = buff; - ret = do_printf(fmt, (BYTE **) & fmt + 1); - handle_char(NULL); - _ES = FP_SEG(buff); - _DX = FP_OFF(buff); - _AX = 0x13; - __int__(0xe6); - return ret; -} -#else -WORD printf(CONST BYTE * fmt, ...) +WORD CDECL printf(CONST BYTE * fmt, ...) { charp = 0; return do_printf(fmt, (BYTE **) & fmt + 1); } -#endif -WORD sprintf(BYTE * buff, CONST BYTE * fmt, ...) +WORD CDECL sprintf(BYTE * buff, CONST BYTE * fmt, ...) { WORD ret; diff --git a/kernel/proto.h b/kernel/proto.h index 31ea757b..ec81fd7d 100644 --- a/kernel/proto.h +++ b/kernel/proto.h @@ -66,16 +66,13 @@ UCOUNT sti(keyboard * kp); sft FAR *get_sft(UCOUNT); /* dosfns.c */ -#ifdef WITHFAT32 -struct dpb FAR *GetDriveDPB(UBYTE drive, COUNT * rc); -#endif BYTE FAR *get_root(BYTE FAR *); BOOL fnmatch(BYTE FAR *, BYTE FAR *, COUNT, COUNT); BOOL check_break(void); UCOUNT GenericReadSft(sft far * sftp, UCOUNT n, BYTE FAR * bp, COUNT FAR * err, BOOL force_binary); COUNT SftSeek(sft FAR * sftp, LONG new_pos, COUNT mode); -/* COUNT DosRead(COUNT hndl, UCOUNT n, BYTE FAR * bp, COUNT FAR * err); */ +/*COUNT DosRead(COUNT hndl, UCOUNT n, BYTE FAR * bp, COUNT FAR * err); */ #define GenericRead(hndl, n, bp, err, t) GenericReadSft(get_sft(hndl), n, bp, err, t) #define DosRead(hndl, n, bp, err) GenericRead(hndl, n, bp, err, FALSE) #define DosReadSft(sftp, n, bp, err) GenericReadSft(sftp, n, bp, err, FALSE) @@ -91,10 +88,10 @@ COUNT DosForceDup(COUNT OldHandle, COUNT NewHandle); COUNT DosOpen(BYTE FAR * fname, COUNT mode); COUNT DosOpenSft(BYTE * fname, COUNT mode); COUNT DosClose(COUNT hndl); -COUNT DosCloseSft(WORD sft_idx); +COUNT DosCloseSft(WORD sft_idx, BOOL commitonly); +#define DosCommit(hndl) DosCloseSft(get_sft_idx(hndl), TRUE) BOOL DosGetFree(UBYTE drive, UCOUNT FAR * spc, UCOUNT FAR * navc, UCOUNT FAR * bps, UCOUNT FAR * nc); -COUNT DosGetExtFree(BYTE FAR * DriveString, struct xfreespace FAR * xfsp); COUNT DosGetCuDir(UBYTE drive, BYTE FAR * s); COUNT DosChangeDir(BYTE FAR * s); COUNT DosFindFirst(UCOUNT attr, BYTE FAR * name); @@ -122,18 +119,12 @@ VOID ASMCFUNC DosIdle_int(void); /* dosnames.c */ VOID SpacePad(BYTE *, COUNT); COUNT ParseDosName(BYTE *, COUNT *, BYTE *, BYTE *, BYTE *, BOOL); -/* COUNT ParseDosPath(BYTE *, COUNT *, BYTE *, BYTE FAR *); */ - -/* dsk.c */ -COUNT FAR ASMCFUNC blk_driver(rqptr rp); -ddt *getddt(int dev); +/*COUNT ParseDosPath(BYTE *, COUNT *, BYTE *, BYTE FAR *); */ /* error.c */ VOID dump(void); VOID panic(BYTE * s); VOID fatal(BYTE * err_msg); -COUNT char_error(request * rq, struct dhdr FAR * lpDevice); -COUNT block_error(request * rq, COUNT nDrive, struct dhdr FAR * lpDevice); /* fatdir.c */ VOID dir_init_fnode(f_node_ptr fnp, CLUSTER dirstart); @@ -153,6 +144,7 @@ BOOL fcmp(BYTE * s1, BYTE * s2, COUNT n); BOOL fcmp_wild(BYTE FAR * s1, BYTE FAR * s2, COUNT n); VOID touc(BYTE * s, COUNT n); COUNT dos_close(COUNT fd); +COUNT dos_commit(COUNT fd); COUNT dos_creat(BYTE * path, COUNT attrib); COUNT dos_delete(BYTE * path); COUNT dos_rmdir(BYTE * path); @@ -186,12 +178,7 @@ COUNT dos_setfattr(BYTE * name, UWORD attrp); COUNT media_check(REG struct dpb FAR * dpbp); f_node_ptr xlt_fd(COUNT fd); COUNT xlt_fnp(f_node_ptr fnp); -struct dhdr FAR *select_unit(COUNT drive); -#ifdef WITHFAT32 -VOID bpb_to_dpb(bpb FAR * bpbp, REG struct dpb FAR * dpbp, BOOL extended); -#else -VOID bpb_to_dpb(bpb FAR * bpbp, REG struct dpb FAR * dpbp); -#endif +struct dhdr FAR * select_unit(COUNT drive); /* fattab.c */ void read_fsinfo(struct dpb FAR * dpbp); @@ -224,20 +211,20 @@ BOOL TestCmnSeps(BYTE FAR * lpFileName); BOOL TestFieldSeps(BYTE FAR * lpFileName); BYTE FAR *GetNameField(BYTE FAR * lpFileName, BYTE FAR * lpDestField, COUNT nFieldSize, BOOL * pbWildCard); -BOOL FcbRead(xfcb FAR * lpXfcb, COUNT * nErrorCode); -BOOL FcbWrite(xfcb FAR * lpXfcb, COUNT * nErrorCode); +typedef BOOL FcbFunc_t (xfcb FAR *, COUNT *, UCOUNT); +FcbFunc_t FcbRead, FcbWrite; BOOL FcbGetFileSize(xfcb FAR * lpXfcb); BOOL FcbSetRandom(xfcb FAR * lpXfcb); BOOL FcbCalcRec(xfcb FAR * lpXfcb); BOOL FcbRandomBlockRead(xfcb FAR * lpXfcb, COUNT nRecords, COUNT * nErrorCode); BOOL FcbRandomBlockWrite(xfcb FAR * lpXfcb, COUNT nRecords, - COUNT * nErrorCode); -BOOL FcbRandomIO(xfcb FAR * lpXfcb, COUNT * nErrorCode, - BOOL(*FcbFunc) (xfcb FAR *, COUNT *)); -BOOL FcbCreate(xfcb FAR * lpXfcb); + COUNT * nErrorCode); +BOOL FcbRandomIO(xfcb FAR * lpXfcb, COUNT * nErrorCode, FcbFunc_t *FcbFunc); +BOOL FcbOpenCreate(xfcb FAR * lpXfcb, BOOL Create); +#define FcbOpen(fcb) FcbOpenCreate(fcb, FALSE) +#define FcbCreate(fcb) FcbOpenCreate(fcb, TRUE) void FcbNameInit(fcb FAR * lpFcb, BYTE * pszBuffer, COUNT * pCurDrive); -BOOL FcbOpen(xfcb FAR * lpXfcb); BOOL FcbDelete(xfcb FAR * lpXfcb); BOOL FcbRename(xfcb FAR * lpXfcb); BOOL FcbClose(xfcb FAR * lpXfcb); @@ -266,10 +253,9 @@ VOID DosUmbLink(BYTE n); VOID mcb_print(mcb FAR * mcbp); /* misc.c */ -VOID strcpy(REG BYTE * d, REG BYTE * s); +VOID ASMCFUNC strcpy(REG BYTE * d, REG BYTE * s); VOID ASMCFUNC fmemcpy(REG VOID FAR * d, REG VOID FAR * s, REG COUNT n); VOID ASMCFUNC fstrcpy(REG BYTE FAR * d, REG BYTE FAR * s); -VOID ASMCFUNC fstrcpy(REG BYTE FAR * d, REG BYTE FAR * s); void ASMCFUNC memcpy(REG void *d, REG VOID * s, REG COUNT n); void ASMCFUNC fmemset(REG VOID FAR * s, REG int ch, REG COUNT n); void ASMCFUNC memset(REG VOID * s, REG int ch, REG COUNT n); @@ -278,7 +264,7 @@ void ASMCFUNC memset(REG VOID * s, REG int ch, REG COUNT n); COUNT lfn_allocate_inode(VOID); COUNT lfn_free_inode(COUNT handle); -COUNT lfn_setup_inode(COUNT handle, CLUSTER dirstart, ULONG diroff); +COUNT lfn_setup_inode(COUNT handle, ULONG dirstart, ULONG diroff); COUNT lfn_create_entries(COUNT handle, lfn_inode_ptr lip); COUNT lfn_remove_entries(COUNT handle); @@ -310,8 +296,8 @@ UWORD ASMCFUNC syscall_MUX14(DIRECT_IREGS); /* prf.c */ VOID put_console(COUNT c); -WORD printf(CONST BYTE * fmt, ...); -WORD sprintf(BYTE * buff, CONST BYTE * fmt, ...); +WORD CDECL printf(CONST BYTE * fmt, ...); +WORD CDECL sprintf(BYTE * buff, CONST BYTE * fmt, ...); VOID hexd(char *title, VOID FAR * p, COUNT numBytes); /* strings.c */ @@ -323,17 +309,10 @@ COUNT ASMCFUNC strcmp(REG BYTE * d, REG BYTE * s); COUNT ASMCFUNC fstrcmp(REG BYTE FAR * d, REG BYTE FAR * s); COUNT ASMCFUNC fstrncmp(REG BYTE FAR * d, REG BYTE FAR * s, COUNT l); COUNT ASMCFUNC strncmp(REG BYTE * d, REG BYTE * s, COUNT l); -/* -void fsncopy(REG BYTE FAR * s, REG BYTE FAR * d, COUNT l); -#define fstrncpy(d,s,l) fsncopy(s,d,l) -*/ void ASMCFUNC fstrncpy(REG BYTE FAR * d, REG BYTE FAR * s, COUNT l); -#define fsncopy(s,d,l) fstrncpy(d,s,l) - -BYTE *ASMCFUNC strchr(BYTE * s, BYTE c); +BYTE * ASMCFUNC strchr(BYTE * s, BYTE c); /* sysclk.c */ -WORD FAR ASMCFUNC clk_driver(rqptr rp); COUNT BcdToByte(COUNT x); COUNT BcdToWord(BYTE * x, UWORD * mon, UWORD * day, UWORD * yr); COUNT ByteToBcd(COUNT x); @@ -348,10 +327,6 @@ VOID putdirent(struct dirent FAR * dp, BYTE FAR * vp); #define putdirent(dp, vp) fmemcpy(vp, dp, sizeof(struct dirent)) #endif -/* syscon.c */ -WORD con_driver(rqptr rp); -VOID break_handler(void); - /* systime.c */ VOID DosGetTime(BYTE FAR * hp, BYTE FAR * mp, BYTE FAR * sp, BYTE FAR * hdp); @@ -376,7 +351,7 @@ VOID InitPSP(VOID); int SetJFTSize(UWORD nHandles); int DosMkTmp(BYTE FAR * pathname, UWORD attr); COUNT get_verify_drive(char FAR * src); -COUNT ASMCFUNC truename(char FAR * src, char FAR * dest, COUNT t); +COUNT truename(char FAR * src, char FAR * dest, COUNT t); /* network.c */ COUNT ASMCFUNC remote_doredirect(UWORD b, UCOUNT n, UWORD d, VOID FAR * s, @@ -402,6 +377,7 @@ UCOUNT ASMCFUNC remote_write(sft FAR * s, UCOUNT n, COUNT * err); COUNT ASMCFUNC remote_creat(sft FAR * s, COUNT attr); COUNT ASMCFUNC remote_setfattr(COUNT attr); COUNT ASMCFUNC remote_printredir(UCOUNT dx, UCOUNT ax); +COUNT ASMCFUNC remote_commit(sft FAR * s); COUNT ASMCFUNC remote_close(sft FAR * s); COUNT ASMCFUNC QRemote_Fn(char FAR * s, char FAR * d); @@ -411,9 +387,6 @@ VOID set_machine_name(BYTE FAR * netname, UWORD name_num); /* procsupt.asm */ VOID ASMCFUNC exec_user(iregs FAR * irp); -/* detect.c */ -unsigned long FAR is_dosemu(void); - /* new by TE */ /* @@ -426,13 +399,6 @@ unsigned long FAR is_dosemu(void); #define ASSERT_CONST(x) { typedef struct { char _xx[x ? 1 : -1]; } xx ; } -#if defined(WATCOM) && 0 -ULONG FAR ASMCFUNC MULULUS(ULONG mul1, UWORD mul2); /* MULtiply ULong by UShort */ -ULONG FAR ASMCFUNC MULULUL(ULONG mul1, ULONG mul2); /* MULtiply ULong by ULong */ -ULONG FAR ASMCFUNC DIVULUS(ULONG mul1, UWORD mul2); /* DIVide ULong by UShort */ -ULONG FAR ASMCFUNC DIVMODULUS(ULONG mul1, UWORD mul2, UWORD * rem); /* DIVide ULong by UShort */ -#endif - /* * Log: proto.h,v * diff --git a/kernel/rtlsupt.asm b/kernel/rtlsupt.asm deleted file mode 100644 index 0c7111df..00000000 --- a/kernel/rtlsupt.asm +++ /dev/null @@ -1,65 +0,0 @@ -; File: -; rtlsupt.asm -; Description: -; Assembly support routines for long mul/div -; was forced to do that for WATCOM C, which has _near -; LMUL/LDIV routines. shouldn't harm for others -; -; Copyright (c) 2001 -; tom ehlert -; All Rights Reserved -; -; This file is part of DOS-C. -; -; DOS-C is free software; you can redistribute it and/or -; modify it under the terms of the GNU General Public License -; as published by the Free Software Foundation; either version -; 2, or (at your option) any later version. -; -; DOS-C is distributed in the hope that it will be useful, but -; WITHOUT ANY WARRANTY; without even the implied warranty of -; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See -; the GNU General Public License for more details. -; -; You should have received a copy of the GNU General Public -; License along with DOS-C; see the file COPYING. If not, -; write to the Free Software Foundation, 675 Mass Ave, -; Cambridge, MA 02139, USA. -; -; $Id$ -; -; - - %include "segs.inc" - - -segment _TEXT - -; -; cdecl calling conventions -; -; ULONG FAR MULULUS(ULONG mul1, USHORT mul2) - MULtiply ULong by UShort -; -%IFNDEF I386 -P8086 -%ELSE -P386 ; Turn on 386 instructions. -%ENDIF ; I386 - - - global _MULULUS -_MULULUS: - - push bp - mov bp,sp - mov bx,[bp+6+4] ; short mul2 - mov ax,[bp+6+2] ; high part of mul1 - mul bx - mov cx,ax - mov ax,[bp+6+0] ; low part of mul1 - mul bx - add dx,cx ; add in high part of result - - pop bp - retf - diff --git a/kernel/segs.inc b/kernel/segs.inc index e1dd76e0..a3599d3a 100644 --- a/kernel/segs.inc +++ b/kernel/segs.inc @@ -28,10 +28,10 @@ ; group PGROUP PSP -group TGROUP _TEXT _IO_TEXT _IO_FIXED_DATA -group DGROUP _FIXED_DATA _DATA _BSSSTART _BSS _BSSEND DYN_DATA DCONST -group HGROUP HMA_TEXT_START HMA_TEXT HMA_TEXT_END -group IGROUP INIT_TEXT_START INIT_TEXT INIT_TEXT_END ID_B ID ID_E IB_B IB IB_E IC IDATA +group TGROUP _TEXT _IO_TEXT _IO_FIXED_DATA +group DGROUP _FIXED_DATA _DATA _BSSSTART _BSS _BSSEND DYN_DATA DCONST +group I_GROUP INIT_TEXT_START INIT_TEXT INIT_TEXT_END ID_B ID ID_E IC IDATA ICONST ICONST2 I_DATA I_BSS IB_B IB IB_E +group HGROUP HMA_TEXT_START HMA_TEXT HMA_TEXT_END segment PSP class=PSP segment _TEXT class=CODE @@ -44,21 +44,28 @@ segment _BSS class=BSS align=2 segment _BSSEND class=BSS ;for MSC segment DCONST class=DCONST align=2 -segment DYN_DATA class=DYN_DATA +segment DYN_DATA class=DYN_DATA segment HMA_TEXT_START class=HMA align=16 segment HMA_TEXT class=HMA -segment HMA_TEXT_END class=HMA -segment INIT_TEXT_START class=INIT align=16 +segment HMA_TEXT_END class=HMA +segment INIT_TEXT_START class=INIT align=16 segment INIT_TEXT class=INIT -segment INIT_TEXT_END class=INIT +segment INIT_TEXT_END class=INIT segment ID_B class=ID align=2 segment ID class=ID align=2 segment ID_E class=ID align=2 segment IDATA class=ID align=2 +segment IC class=IC align=2 + +;for Watcom +segment ICONST class=FAR_DATA align=2 +segment ICONST2 class=FAR_DATA align=2 +segment I_DATA class=FAR_DATA align=2 +segment I_BSS class=FAR_DATA align=2 + segment IB_B class=IB align=2 segment IB class=IB align=2 segment IB_E class=IB align=2 -segment IC class=IC align=2 ; Log: segs.inc,v ; diff --git a/kernel/sysclk.c b/kernel/sysclk.c index d7ae4656..f2f73c77 100644 --- a/kernel/sysclk.c +++ b/kernel/sysclk.c @@ -35,7 +35,6 @@ static BYTE *RcsId = #endif #ifdef PROTO -BOOL ASMCFUNC ReadPCClock(ULONG *); VOID ASMCFUNC WriteATClock(BYTE *, BYTE, BYTE, BYTE); VOID ASMCFUNC WritePCClock(ULONG); COUNT BcdToByte(COUNT); @@ -43,7 +42,6 @@ COUNT BcdToWord(BYTE *, UWORD *, UWORD *, UWORD *); COUNT ByteToBcd(COUNT); VOID DayToBcd(BYTE *, UWORD *, UWORD *, UWORD *); #else -BOOL ReadPCClock(); VOID WriteATClock(); VOID WritePCClock(); COUNT BcdToByte(); @@ -71,16 +69,16 @@ static BYTE bcdSeconds; static ULONG Ticks; */ -UWORD DaysSinceEpoch = 0; +UWORD ASM DaysSinceEpoch = 0; BOOL ASMCFUNC ReadATClock(BYTE *, BYTE *, BYTE *, BYTE *); -static COUNT BcdToByte(COUNT x) +STATIC COUNT BcdToByte(COUNT x) { return ((((x) >> 4) & 0xf) * 10 + ((x) & 0xf)); } -WORD FAR ASMCFUNC clk_driver(rqptr rp) +WORD ASMCFUNC FAR clk_driver(rqptr rp) { COUNT c; UWORD *pdays; @@ -120,8 +118,7 @@ WORD FAR ASMCFUNC clk_driver(rqptr rp) case C_INPUT: { ULONG remainder, hs; - if (ReadPCClock(&Ticks)) - ++DaysSinceEpoch; + ReadPCClock(&Ticks); clk.clkDays = DaysSinceEpoch; /* * Another tricky calculation (after the one in `main.c'). This time diff --git a/kernel/systime.c b/kernel/systime.c index e6afc783..15a217f1 100644 --- a/kernel/systime.c +++ b/kernel/systime.c @@ -41,7 +41,7 @@ UWORD days[2][13] = { {0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366} }; -extern request ClkReqHdr; +extern request ASM ClkReqHdr; /* return a pointer to an array with the days for that year diff --git a/kernel/task.c b/kernel/task.c index 303cd25c..44d2ce07 100644 --- a/kernel/task.c +++ b/kernel/task.c @@ -185,7 +185,7 @@ VOID new_psp(psp FAR * p, int psize) /* CP/M-like entry point - jump to special entry */ p->ps_farcall = 0xea; - p->ps_reentry = (VOID(FAR *) ())cpm_entry; + p->ps_reentry = cpm_entry; /* unix style call - 0xcd 0x21 0xcb (int 21, retf) */ p->ps_unix[0] = 0xcd; p->ps_unix[1] = 0x21; @@ -206,11 +206,11 @@ VOID new_psp(psp FAR * p, int psize) p->ps_dta = (BYTE FAR *) (&p->ps_cmd_count); /* terminate address */ - p->ps_isv22 = (VOID(INRPT FAR *) (void))getvec(0x22); + p->ps_isv22 = getvec(0x22); /* break address */ - p->ps_isv23 = (VOID(INRPT FAR *) (void))getvec(0x23); + p->ps_isv23 = getvec(0x23); /* critical error address */ - p->ps_isv24 = (VOID(INRPT FAR *) (void))getvec(0x24); + p->ps_isv24 = getvec(0x24); /* File System parameters */ /* user stack pointer - int 21 */ @@ -394,6 +394,9 @@ COUNT DosComLoader(BYTE FAR * namep, exec_blk FAR * exp, COUNT mode) DosUmbLink(UMBstate); /* restore link state */ } +#ifdef DEBUG + printf("DosComLoader. Loading '%S' at %04x\n", namep, mem); +#endif /* Now load the executable */ /* If file not found - error */ /* NOTE - this is fatal because we lost it in transit */ @@ -435,7 +438,7 @@ COUNT DosComLoader(BYTE FAR * namep, exec_blk FAR * exp, COUNT mode) /* point to the PSP so we can build it */ p = MK_FP(mem, 0); - setvec(0x22, (VOID(INRPT FAR *) (VOID)) MK_FP(user_r->CS, user_r->IP)); + setvec(0x22, MK_FP(user_r->CS, user_r->IP)); new_psp(p, mem + asize); asize = patchPSP(mem - 1, env, exp, namep); /* asize=fcbcode for ax */ @@ -667,7 +670,7 @@ COUNT DosExeLoader(BYTE FAR * namep, exec_blk FAR * exp, COUNT mode) asize = exe_size; #ifdef DEBUG - printf("loading '%S' at %04x\n", namep, mem); + printf("DosExeLoader. Loading '%S' at %04x\n", namep, mem); #endif /* /// Added open curly brace and "else" clause. We should not attempt @@ -801,7 +804,7 @@ COUNT DosExeLoader(BYTE FAR * namep, exec_blk FAR * exp, COUNT mode) /* point to the PSP so we can build it */ p = MK_FP(mem, 0); - setvec(0x22, (VOID(INRPT FAR *) (VOID)) MK_FP(user_r->CS, user_r->IP)); + setvec(0x22, MK_FP(user_r->CS, user_r->IP)); new_psp(p, mem + asize); asize = patchPSP(mem - 1, env, exp, namep); /* asize = fcbcode */ diff --git a/mkfiles/bc5.mak b/mkfiles/bc5.mak index 13a3c8a9..98655335 100644 --- a/mkfiles/bc5.mak +++ b/mkfiles/bc5.mak @@ -47,6 +47,5 @@ MATH_INSERT=+H_LDIV +H_LLSH +H_LURSH +N_LXMUL +F_LXMUL +H_LRSH # ALLCFLAGS specified by turbo.cfg and config.mak # ALLCFLAGS=$(TARGETOPT) $(ALLCFLAGS) -INITCFLAGS=$(ALLCFLAGS) -zAINIT -zCINIT_TEXT -zDIB -zRID -zTID -zPIGROUP -zBIB -zGIGROUP -zSIGROUP +INITCFLAGS=$(ALLCFLAGS) -zAINIT -zCINIT_TEXT -zDIB -zRID -zTID -zPI_GROUP -zBIB -zGI_GROUP -zSI_GROUP CFLAGS=$(ALLCFLAGS) -zAHMA -zCHMA_TEXT -DYNCFLAGS=$(ALLCFLAGS) -zRDYN_DATA -zTDYN_DATA -zDDYN_DATA -zBDYN_DATA diff --git a/mkfiles/generic.mak b/mkfiles/generic.mak index 486e70a9..c73026c3 100644 --- a/mkfiles/generic.mak +++ b/mkfiles/generic.mak @@ -27,10 +27,8 @@ NASMFLAGS = $(NASMFLAGS) -i../hdr/ LINK=$(XLINK) -PATCHOBJ=@rem -INITPATCH = CODE=INIT _DATA=IDATA DATA=ID BSS=ID DGROUP=IGROUP CONST=IC -STDPATCH = CODE=HMA CONST=DCONST -DYNPATCH = _DATA=DYN_DATA DATA=DYN_DATA CODE=HMA CONST=DCONST +STDPATCH=@rem +INITPATCH=@rem !include "..\mkfiles\$(COMPILER).mak" @@ -38,7 +36,7 @@ THETARGET=$(TARGET)$(XCPU)$(XFAT) RM=..\utils\rmfiles .asm.obj : - $(NASM) $(NASMFLAGS) -f obj $*.asm + $(NASM) -D$(COMPILER) $(NASMFLAGS) -f obj $*.asm # *Implicit Rules* .c.obj : diff --git a/mkfiles/mscl8.mak b/mkfiles/mscl8.mak index b606102c..92f9bb15 100644 --- a/mkfiles/mscl8.mak +++ b/mkfiles/mscl8.mak @@ -7,8 +7,8 @@ COMPILERPATH=$(MS_BASE) COMPILERBIN=$(COMPILERPATH)\bin INCLUDEPATH=$(COMPILERPATH)\include CC=$(COMPILERBIN)\cl -CFLAGST=/Fm /AT /Os -CFLAGSC=/Fm /AL /Os +CFLAGST=/Fm /AT /Os /Zp1 +CFLAGSC=/Fm /AL /Os /Zp1 LIBPATH=$(COMPILERPATH)\lib LIB=$(COMPILERPATH)\lib INCLUDE=$(COMPILERPATH)\include @@ -38,9 +38,9 @@ TARGET=KMS # heavy stuff - building -ALLCFLAGS=-I..\hdr $(TARGETOPT) $(ALLCFLAGS) -nologo -Zl -Fc -Zp1 -WX -Gr -f- -Os -Gs -Ob1 -OV4 -Gy -Oe +ALLCFLAGS=-I..\hdr $(TARGETOPT) $(ALLCFLAGS) -nologo -Zl -Fc -WX -Gr -f- -Os -Gs -Ob1 -OV4 -Gy -Oe -Zp1 INITCFLAGS=$(ALLCFLAGS) -NTINIT_TEXT -AT CFLAGS=$(ALLCFLAGS) -NTHMA_TEXT -DYNCFLAGS=$(ALLCFLAGS) -NTHMA_TEXT -PATCHOBJ=patchobj +INITPATCH = ..\utils\patchobj CODE=INIT _DATA=IDATA DATA=ID BSS=ID DGROUP=I_GROUP CONST=IC +STDPATCH = ..\utils\patchobj CODE=HMA CONST=DCONST diff --git a/mkfiles/tc2.mak b/mkfiles/tc2.mak index 290d97b4..c57c5c5e 100644 --- a/mkfiles/tc2.mak +++ b/mkfiles/tc2.mak @@ -47,6 +47,5 @@ MATH_INSERT=+LDIV +LXMUL +LURSH +LLSH +LRSH # ALLCFLAGS specified by turbo.cfg and config.mak # ALLCFLAGS=$(TARGETOPT) $(ALLCFLAGS) -INITCFLAGS=$(ALLCFLAGS) -zAINIT -zCINIT_TEXT -zDIB -zRID -zTID -zPIGROUP -zBIB -zGIGROUP -zSIGROUP +INITCFLAGS=$(ALLCFLAGS) -zAINIT -zCINIT_TEXT -zDIB -zRID -zTID -zPI_GROUP -zBIB -zGI_GROUP -zSI_GROUP CFLAGS=$(ALLCFLAGS) -zAHMA -zCHMA_TEXT -DYNCFLAGS=$(ALLCFLAGS) -zRDYN_DATA -zTDYN_DATA -zDDYN_DATA -zBDYN_DATA diff --git a/mkfiles/tc3.mak b/mkfiles/tc3.mak index 18c1850f..0dedd6b6 100644 --- a/mkfiles/tc3.mak +++ b/mkfiles/tc3.mak @@ -47,6 +47,5 @@ MATH_INSERT=+H_LDIV +H_LLSH +H_LURSH +N_LXMUL +F_LXMUL +H_LRSH # ALLCFLAGS specified by turbo.cfg and config.mak # ALLCFLAGS=$(TARGETOPT) $(ALLCFLAGS) -INITCFLAGS=$(ALLCFLAGS) -zAINIT -zCINIT_TEXT -zDIB -zRID -zTID -zPIGROUP -zBIB -zGIGROUP -zSIGROUP +INITCFLAGS=$(ALLCFLAGS) -zAINIT -zCINIT_TEXT -zDIB -zRID -zTID -zPI_GROUP -zBIB -zGI_GROUP -zSI_GROUP CFLAGS=$(ALLCFLAGS) -zAHMA -zCHMA_TEXT -DYNCFLAGS=$(ALLCFLAGS) -zRDYN_DATA -zTDYN_DATA -zDDYN_DATA -zBDYN_DATA diff --git a/mkfiles/turbocpp.mak b/mkfiles/turbocpp.mak index 7187111e..ee996ea4 100644 --- a/mkfiles/turbocpp.mak +++ b/mkfiles/turbocpp.mak @@ -47,6 +47,5 @@ MATH_INSERT=+H_LDIV +F_LXMUL +H_LURSH +H_LLSH +H_LRSH # ALLCFLAGS specified by turbo.cfg and config.mak # ALLCFLAGS=$(TARGETOPT) $(ALLCFLAGS) -INITCFLAGS=$(ALLCFLAGS) -zAINIT -zCINIT_TEXT -zDIB -zRID -zTID -zPIGROUP -zBIB -zGIGROUP -zSIGROUP +INITCFLAGS=$(ALLCFLAGS) -zAINIT -zCINIT_TEXT -zDIB -zRID -zTID -zPI_GROUP -zBIB -zGI_GROUP -zSI_GROUP CFLAGS=$(ALLCFLAGS) -zAHMA -zCHMA_TEXT -DYNCFLAGS=$(ALLCFLAGS) -zRDYN_DATA -zTDYN_DATA -zDDYN_DATA -zBDYN_DATA diff --git a/mkfiles/watcom.mak b/mkfiles/watcom.mak index 4cf2d292..23729ab2 100644 --- a/mkfiles/watcom.mak +++ b/mkfiles/watcom.mak @@ -28,7 +28,7 @@ TARGET=KWC # used for building the library -CLIB=$(COMPILERPATH)\lib286\dos\clibs.lib +CLIB=$(COMPILERPATH)\lib286\dos\clibm.lib # #MATH_EXTRACT=*i4d *i4m @@ -37,11 +37,9 @@ CLIB=$(COMPILERPATH)\lib286\dos\clibs.lib # these are NOT usable, as they are called NEAR, and are in TEXT segment. # so we can't use them, when moving the kernel. called ~15 times # -# so I include 1 dummy library routine (stridup()), to make lib happy +# we use our own ones, which override these ones when linking. # -MATH_EXTRACT=*_icstrdu -MATH_INSERT= +_icstrdu MATH_EXTRACT=*i4d *i4m MATH_INSERT= +i4d +i4m @@ -69,8 +67,8 @@ MATH_INSERT= +i4d +i4m # -3 optimization for 386 - given in CONFIG.MAK, not here # -ALLCFLAGS=-I..\hdr $(TARGETOPT) $(ALLCFLAGS) -zq -os -ms -s -e=5 -j -zl -zp=1 -we -INITCFLAGS=$(ALLCFLAGS) -nt=INIT_TEXT -nc=INIT -g=IGROUP +ALLCFLAGS=-I..\hdr $(TARGETOPT) $(ALLCFLAGS) -zq -os -s -e=5 -j -zl -zp=1 -we +INITCFLAGS=$(ALLCFLAGS) -nt=INIT_TEXT -nc=INIT -nd=I -g=I_GROUP CFLAGS=$(ALLCFLAGS) -nt=HMA_TEXT -nc=HMA -g=HGROUP -DYNCFLAGS=$(ALLCFLAGS) +INITPATCH=..\utils\patchobj __U4D=_IU4D __U4M=_IU4M diff --git a/sys/sys.c b/sys/sys.c index e117a170..ca2cae6f 100644 --- a/sys/sys.c +++ b/sys/sys.c @@ -38,7 +38,7 @@ #define SYS_VERSION "v2.3" -#include +/* #include */ #include #include #include @@ -51,9 +51,10 @@ #include #endif #include -/*#include */ -#define MAXPATH 260 +#include +#define SYS_MAXPATH 260 #include "portab.h" +extern WORD CDECL printf(CONST BYTE * fmt, ...); #include "b_fat12.h" #include "b_fat16.h" @@ -70,7 +71,7 @@ COUNT DiskRead(WORD, WORD, WORD, WORD, WORD, BYTE FAR *); COUNT DiskWrite(WORD, WORD, WORD, WORD, WORD, BYTE FAR *); #define SEC_SIZE 512 -#define COPY_SIZE 32768u +#define COPY_SIZE 24576u #ifdef _MSC_VER #pragma pack(1) @@ -159,7 +160,7 @@ int main(int argc, char **argv) COUNT drivearg = 0; /* drive argument position */ BYTE *bsFile = NULL; /* user specified destination boot sector */ COUNT srcDrive; /* source drive */ - BYTE srcPath[MAXPATH]; /* user specified source drive and/or path */ + BYTE srcPath[SYS_MAXPATH]; /* user specified source drive and/or path */ BYTE rootPath[4]; /* alternate source path to try if not '\0' */ WORD slen; @@ -177,9 +178,9 @@ int main(int argc, char **argv) if (argc > 2 && argv[2][1] == ':' && argv[2][2] == '\0') { drivearg = 2; - strncpy(srcPath, argv[1], MAXPATH - 12); + strncpy(srcPath, argv[1], SYS_MAXPATH - 12); /* leave room for COMMAND.COM\0 */ - srcPath[MAXPATH - 13] = '\0'; + srcPath[SYS_MAXPATH - 13] = '\0'; /* make sure srcPath + "file" is a valid path */ slen = strlen(srcPath); if ((srcPath[slen - 1] != ':') && @@ -597,7 +598,7 @@ BYTE copybuffer[COPY_SIZE]; BOOL copy(COUNT drive, BYTE * srcPath, BYTE * rootPath, BYTE * file) { - BYTE dest[MAXPATH], source[MAXPATH]; + BYTE dest[SYS_MAXPATH], source[SYS_MAXPATH]; COUNT ifd, ofd; unsigned ret; int fdin, fdout; diff --git a/utils/exeflat.c b/utils/exeflat.c index 779505b9..f6ae4495 100644 --- a/utils/exeflat.c +++ b/utils/exeflat.c @@ -34,6 +34,16 @@ large portions copied from task.c */ +/* history + + 10/??/01 - Bart Oldeman + primary release + + 11/28/01 - tom ehlert + added -UPX option to make the kernel compressable with UPX + +*/ + #include "portab.h" #include "exe.h" #include @@ -68,7 +78,7 @@ void usage() printf("usage: exeflat (src.exe) (dest.sys) (relocation-factor)\n"); printf (" -S10 - Silent relocate segment 10 (down list)\n"); - + exit(1); } @@ -84,19 +94,23 @@ int main(int argc, char **argv) UBYTE **curbuf; FILE *src, *dest; short silentSegments[20], silentcount = 0, silentdone = 0; + int UPX = FALSE; /* do optional argument processing here */ for (i = 4; i < argc; i++) { char *argptr = argv[i]; - + if (argptr[0] != '-' && argptr[0] != '/') usage(); - + argptr++; switch (toupper(argptr[0])) { + case 'U': + UPX = TRUE; + break; case 'S': if (silentcount >= LENGTH(silentSegments)) { @@ -104,10 +118,10 @@ int main(int argc, char **argv) LENGTH(silentSegments)); exit(1); } - + silentSegments[silentcount++] = strtol(argptr + 1, NULL, 0); break; - + default: usage(); } @@ -115,7 +129,7 @@ int main(int argc, char **argv) /* arguments left : infile outfile relocation offset */ - + if ((src = fopen(argv[1], "rb")) == NULL) { printf("Source file %s could not be opened\n", argv[1]); @@ -195,23 +209,56 @@ int main(int argc, char **argv) UBYTE *spot0 = &buffers[spot / BUFSIZE][spot % BUFSIZE]; UBYTE *spot1 = &buffers[(spot + 1) / BUFSIZE][(spot + 1) % BUFSIZE]; UWORD segment = ((UWORD) * spot1 << 8) + *spot0; - + for (j = 0; j < silentcount; j++) if (segment == silentSegments[j]) { silentdone++; goto dontPrint; } - + printf("relocation at 0x%04x:0x%04x ->%04x\n", reloc[i].seg, reloc[i].off, segment); - + dontPrint: - + segment += start_seg; *spot0 = segment & 0xff; *spot1 = segment >> 8; } + + if (UPX) + { + /* UPX HEADER jump $+2+size */ + static char JumpBehindCode[] = { + /* kernel config header - 32 bytes */ + 0xeb, 0x1b, /* jmp short realentry */ + 'C', 'O', 'N', 'F', 'I', 'G', 32 - 2 - 6 - 2 - 3, 0, /* WORD */ + 0, /* DLASortByDriveNo db 0 */ + 1, /* InitDiskShowDriveAssignment db 1 */ + 2, /* SkipConfigSeconds db 2 */ + 0, /* ForceLBA db 0 */ + 1, /* GlobalEnableLBAsupport db 1 */ + 'u', 'n', 'u', 's', 'e', 'd', /* unused filler bytes */ + 8, 7, 6, 5, 4, 3, 2, 1, + /* real-entry: jump over the 'real' image do the trailer */ + 0xe9, 0, 0 /* 100: jmp 103 */ + }; + + struct x { + char y[sizeof(JumpBehindCode) == 0x20 ? 1 : -1]; + }; + + if (size >= 0xfe00u) + { + printf("kernel; size too large - must be <= 0xfe00\n"); + exit(1); + } + + /* this assumes <= 0xfe00 code in kernel */ + *(short *)&JumpBehindCode[0x1e] += size; + fwrite(JumpBehindCode, 1, 0x20, dest); + } /* write dest file from memory chunks */ bufsize = BUFSIZE; @@ -227,9 +274,38 @@ int main(int argc, char **argv) return 1; } } - + + if (UPX) + { + /* UPX trailer */ + /* hand assembled - so this reamins ANSI C ;-) */ + static char trailer[] = { /* shift down everything by sizeof JumpBehindCode */ + 0xE8, 0x00, 0x00, /* call 103 */ + 0x59, /* pop cx */ + 0x0E, /* push cs */ + 0x1F, /* pop ds */ + 0x8c, 0xc8, /* mov ax,cs */ + 0x48, /* dec ax */ + 0x48, /* dec ax */ + 0x8e, 0xc0, /* mov es,ax */ + 0x31, 0xFF, /* xor di,di */ + 0xBE, 0x00, 0x00, /* mov si,0x00 */ + 0xFC, /* cld */ + 0xF3, 0xA4, /* rep movsb */ + 0x26, 0x88, 0x1e, 0x00, 0x00, /* mov es:[0],bl */ + 0xB8, 0x00, 0x00, /* mov ax,0000h */ + 0x8E, 0xD0, /* mov ss,ax */ + 0xBC, 0x00, 0x00, /* mov sp,0000h */ + 0x31, 0xC0, /* xor ax,ax */ + 0x50, /* push ax */ + 0xC3 /* ret */ + }; + *(short *)&trailer[26] = start_seg + header.exInitSS; + *(short *)&trailer[31] = header.exInitSP; + fwrite(trailer, 1, sizeof(trailer), dest); + } fclose(dest); - printf("\nProcessed %d relocations, %d not shown\n", header.exRelocItems, - silentdone); + printf("\nProcessed %d relocations, %d not shown\n", + header.exRelocItems, silentdone); return 0; } diff --git a/utils/makefile b/utils/makefile index 584fe6ea..6a18eaee 100644 --- a/utils/makefile +++ b/utils/makefile @@ -12,7 +12,7 @@ exeflat.exe: exeflat.c ..\hdr\exe.h clobber: clean - $(RM) bin2c.com exeflat.exe patchobj.exe + $(RM) bin2c.com exeflat.exe patchobj.exe patchobj.com clean: $(RM) *.obj *.bak *.crf *.xrf *.map *.lst *.las *.cod *.err status.me diff --git a/utils/patchobj.c b/utils/patchobj.c index 92eeee8b..4c1200d1 100644 --- a/utils/patchobj.c +++ b/utils/patchobj.c @@ -15,6 +15,7 @@ #include #include #include +#include #ifndef TRUE #define TRUE (1==1) @@ -26,6 +27,8 @@ struct { } repl[100]; int repl_count; +void go_records(FILE * fdin, FILE * fdo); + void quit(char *s, ...) { vprintf(s, (void *)((char *)&s + sizeof(s))); @@ -54,7 +57,6 @@ int main(int argc, char *argv[]) char *argptr; int argloop; int cont; - int file = 0; FILE *fd, *fdo; char *inname = 0, *outname = "~patchob.tmp"; @@ -66,9 +68,9 @@ int main(int argc, char *argv[]) { argptr = *argv; - if (*argptr != '-' && *argptr != '-') + if (*argptr != '-' && *argptr != '/') { - if (inname == 0) + if (argc == 1) { inname = argptr; continue; @@ -114,21 +116,15 @@ int main(int argc, char *argv[]) } -usage() -{ - fputs("DELSYM V1.0 5'95by tom ehlert, SIG Aachen\n" - " delete symbolic info in object files\n" - "usage:\n" " DELSYM infile [outfile]\n", stderr); - exit(1); -} - struct record { unsigned char rectyp; unsigned datalen; unsigned char buffer[0x2000]; } Record, Outrecord; -go_records(FILE * fdin, FILE * fdo) +struct verify_pack1 { char x[ sizeof(struct record) == 0x2003 ? 1 : -1];}; + +void go_records(FILE * fdin, FILE * fdo) { unsigned char stringlen; unsigned char *string, *s; @@ -151,13 +147,15 @@ go_records(FILE * fdin, FILE * fdo) quit("can't continue\n"); } - if (Record.rectyp != 0x96) /* we are only interested in LNAMES */ + if (Record.rectyp != 0x96 && Record.rectyp != 0x8c) /* we are only interested in LNAMES */ { fwrite(&Record, 1, 3 + Record.datalen, fdo); continue; } - Outrecord.rectyp = 0x96; + /* printf("at %lx - record type %x len %x\n",ftell(fdin)-3,Record.rectyp, + Record.datalen);*/ + Outrecord.rectyp = Record.rectyp; Outrecord.datalen = 0; for (i = 0; i < Record.datalen - 1;) diff --git a/utils/rmfiles.bat b/utils/rmfiles.bat index 5633e425..efaa4fa8 100644 --- a/utils/rmfiles.bat +++ b/utils/rmfiles.bat @@ -2,7 +2,7 @@ :loop_commandline if \%1 == \ goto done_with_commandline -del %1 +if exist %1 del %1 shift goto loop_commandline From df1651b5a4d93a0cfca2528e880543c8431d0b87 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sun, 27 Jan 2002 01:13:07 +0000 Subject: [PATCH 118/671] Small clean-ups for ke2026-test. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@344 6ac86273-5f31-0410-b378-82cca8765d1b --- build.bat | 10 +- config.b | 16 ++-- docs/build.txt | 12 +-- docs/history.txt | 15 ++- drivers/makefile | 4 +- kernel/apisupt.asm | 5 +- kernel/fatfs.c | 28 +++--- kernel/globals.h | 8 +- kernel/kernel.asm | 22 ++--- kernel/ludivmul.inc | 218 +++++++++++++++++++------------------------- kernel/makefile | 29 +++--- kernel/segs.inc | 12 ++- kernel/sysclk.c | 2 +- mkfiles/watcom.mak | 11 +-- sys/fdkrncfg.c | 9 +- sys/sys.c | 21 +++-- utils/echoto.bat | 1 + utils/patchobj.c | 2 - utils/wlinker.bat | 1 + 19 files changed, 191 insertions(+), 235 deletions(-) create mode 100755 utils/echoto.bat create mode 100755 utils/wlinker.bat diff --git a/build.bat b/build.bat index e5fe55fd..e6474887 100644 --- a/build.bat +++ b/build.bat @@ -64,17 +64,13 @@ if \%COMPILER% == \ goto end @if \%COMPILER% == \TURBOCPP set XLINK=%TP1_BASE%\bin\tlink /m/c @if \%COMPILER% == \TC3 set XLINK=%TC3_BASE%\bin\tlink /m/c @if \%COMPILER% == \BC5 set XLINK=%BC5_BASE%\bin\tlink /m/c -@if \%COMPILER% == \WATCOM goto watcom_problem +@if \%COMPILER% == \WATCOM set XLINK=..\utils\wlinker /ma/nologo @if \%COMPILER% == \MSCL8 set XLINK=%MS_BASE%\bin\link /ONERROR:NOEXE /ma /nologo goto link_set -:watcom_problem -@echo you MUST set XLINK for Watcom in config.bat as WLINK is not suitable -goto end - :link_set -echo linker ist %XLINK% +echo linker is %XLINK% @if not "%XUPX%" == "" goto upx_set @set XUPX=@rem @@ -150,6 +146,8 @@ set XERROR=1 @set MS_BASE= @set XNASM= @set XERROR= +@set XUPX= +@set UPXOPT= :- Log: build.bat,v :- diff --git a/config.b b/config.b index 1ec4f1de..c2c28da0 100644 --- a/config.b +++ b/config.b @@ -38,8 +38,7 @@ set COMPILER=TC2 :- set COMPILER=BC5 :- Microsoft C :- set COMPILER=MSCL8 - -:- warning: watcom can compile but the result does not work yet. +:- Watcom C :- set COMPILER=WATCOM :-********************************************************************** @@ -63,26 +62,23 @@ set TC2_BASE=c:\tc201 :- where is UPX and which options to use? :-********************************************************************** set XUPX=upx --8086 -:- or use set XUPX= +:- or use set XUPX= :- if you don't want to use it :-********************************************************************** :- (optionally) which linker to use: :- (otherwise will be determined automatically) -:- WATCOM wlink is not (yet) suitable for linking -:- (the map file and syntax are not compatible) -:- Turbo C 2.01 TLINK 2.0 can't link WATCOM (but can link TC2) -:- Turbo C++ 1.01 and higher TLINK 3.01+ are ok -:- or get TLINK 4 (creates nice map file) from simtel at -:- ftp://ftp.simtel.net/pub/simtelnet/msdos/borland/tlink4.zip :- :- WARNING TLINK needs to be in your PATH! :-********************************************************************** :- Turbo Link -:- set XLINK=%TC2_BASE%\tlink /m/c +:- set XLINK=tlink /m/c/s/l :- Microsoft Link +:- set XLINK=d:\qb\link /ma :- set XLINK=%MS_BASE%\bin\link /ONERROR:NOEXE /ma /nologo +:- WATCOM Link (wlinker is a batch file calling ms2wlink and wlink) +:- set XLINK=..\utils\wlinker /ma /nologo :- set path for Turbo Link - use OLDPATH to restore normal path :- set OLDPATH=%PATH% diff --git a/docs/build.txt b/docs/build.txt index e8752e3a..3de6f96b 100644 --- a/docs/build.txt +++ b/docs/build.txt @@ -3,17 +3,14 @@ to make life easier. This file is in the FDKERNEL directory of the distribution. In addition, there is a corresponding batch file (CLEAN.BAT) to clean up the source directories. -There is a CONFIG.M file that specifies all the paths and names of +There is a CONFIG.B file that specifies all the paths and names of the compiler, assembler, etc. that you want to use. You MUST copy -it to CONFIG.MAK first, then edit it to reflect your setup. - -Likewise, there is a CONFIG.B file that should be copied to -CONFIG.BAT, and then edited to reflect your setup. +it to CONFIG.BAT first, then edit it to reflect your setup. The reason for this copying of files is that when new releases of the kernel come out, you can extract them over your previous source, and not have to worry about resetting up your configuration because your -CONFIG.BAT and CONFIG.MAK files will not get replaced! +CONFIG.BAT file will not get replaced! You will also need to download the latest version of NASM and Turbo C 2.01. Install Turbo C and NASM somewhere (it doesn't really matter @@ -32,8 +29,7 @@ or a mirror of ftp.kernel.org. This program will now compile with Turbo C 2.01 (now freely available!), Turbo C 3.0, Borland C 4.51 & 5.01. It should work with -other Borland compilers and Microsoft C as well. Watcom C can compile -it but the result does not work yet. +other Borland compilers, Microsoft C and Watcom C. If you feel hardy, read on to understand the directory structure. A more complete description of the build environment is contained in a diff --git a/docs/history.txt b/docs/history.txt index 682f986e..df9ea833 100644 --- a/docs/history.txt +++ b/docs/history.txt @@ -1,7 +1,7 @@ 2002 Feb xx - Build 2026test -------- Bart Oldeman (bart@dosemu.org) + Changes Tom - * FCB clean-ups and fixes + * FCB clean-ups and fixes (CYRUS CHESS, bug #1014) * initial config.sys menus (see config.txt) * execrh * make kernel UPX-able @@ -24,14 +24,19 @@ * implement lock/unlock for remote drives * implement commit file (int21/ah=68,6a) * implement ioctl get/set logical drive map (int21/ax=440E--F) - * implement get drive data table (int2f/ax=0803) - * fix "get SDA" (int21/ax=5d06) + * implement get address of drive data table (int2f/ax=0803) + * fix "get address of SDA" (int21/ax=5d06) * do not use CHS if the root extended partition of the relevant - logical partition is labelled LBA + logical partition is labelled LBA (bug #1011) + * hopefully avoid format problem (bug #1030) by not setting drive + to "non-accessible" while reading the bpb. * boot sector fixes: enable booting beyond cylinder x where x * number of heads >= 65536. still uses CHS to boot (not able to boot beyond cylinder 1023) - recognize FF8-FFF as FAT12 ending (was only FFF) + recognize FF8-FFF as FAT12 ending (was only FFF) (bug #1021) + * avoid using LIB when linking the kernel by echo-ing to a linker + resource file. Use a batch file to bypass Borlands Make 2.0 + unwillingness to redirect stdout. 2001 Nov 18 - Build 2025c -------- Bart Oldeman (bart@dosemu.org) + Changes Bart diff --git a/drivers/makefile b/drivers/makefile index 50fe8b3f..e71bf45f 100644 --- a/drivers/makefile +++ b/drivers/makefile @@ -22,10 +22,10 @@ #AFLAGS = /Mx /Dmem$(MODEL)=1 #LIBFLAGS = /c -OBJS = devend.obj floppy.obj getvec.obj rdpcclk.obj rdatclk.obj \ +OBJS = floppy.obj getvec.obj rdpcclk.obj rdatclk.obj \ wrpcclk.obj wratclk.obj -LIBOBJS= +devend +floppy +getvec +rdpcclk +rdatclk +wrpcclk +wratclk +LIBOBJS= +floppy +getvec +rdpcclk +rdatclk +wrpcclk +wratclk diff --git a/kernel/apisupt.asm b/kernel/apisupt.asm index 113828f2..e51d21ed 100644 --- a/kernel/apisupt.asm +++ b/kernel/apisupt.asm @@ -29,13 +29,14 @@ %include "segs.inc" +segment HMA_TEXT +%if 0 + extern _api_sp:wrt DGROUP ; api stacks - for context extern _api_ss:wrt DGROUP ; switching extern _usr_sp:wrt DGROUP ; user stacks extern _usr_ss:wrt DGROUP -segment HMA_TEXT -%if 0 global _set_stack ; ; void set_stack(void) - diff --git a/kernel/fatfs.c b/kernel/fatfs.c index fb6750fd..7e757d5d 100644 --- a/kernel/fatfs.c +++ b/kernel/fatfs.c @@ -1626,7 +1626,7 @@ UCOUNT readblock(COUNT fd, VOID FAR * buffer, UCOUNT count, COUNT * err) /* Compute the block within the cluster and the offset */ /* within the block. */ fnp->f_sector = (fnp->f_offset / secsize) & fnp->f_dpb->dpb_clsmask; - fnp->f_boff = fnp->f_offset & (secsize - 1); + fnp->f_boff = fnp->f_offset % secsize; currentblock = clus2phys(fnp->f_cluster, fnp->f_dpb) + fnp->f_sector; @@ -1780,7 +1780,7 @@ STATIC COUNT dos_extend(f_node_ptr fnp) /* Compute the block within the cluster and the offset */ /* within the block. */ fnp->f_sector = (fnp->f_offset / secsize) & fnp->f_dpb->dpb_clsmask; - fnp->f_boff = fnp->f_offset & (secsize - 1); + fnp->f_boff = fnp->f_offset % secsize; #ifdef DSK_DEBUG printf("write %d links; dir offset %ld, cluster %d\n", @@ -1966,7 +1966,7 @@ UCOUNT writeblock(COUNT fd, VOID FAR * buffer, UCOUNT count, COUNT * err) /* Compute the block within the cluster and the offset */ /* within the block. */ fnp->f_sector = (fnp->f_offset / secsize) & fnp->f_dpb->dpb_clsmask; - fnp->f_boff = fnp->f_offset & (secsize - 1); + fnp->f_boff = fnp->f_offset % secsize; #ifdef DSK_DEBUG printf("write %d links; dir offset %ld, cluster %d\n", @@ -2253,6 +2253,10 @@ VOID bpb_to_dpb(bpb FAR * bpbp, REG struct dpb FAR * dpbp) ULONG size; REG UWORD shftcnt; + for (shftcnt = 0; (bpbp->bpb_nsector >> shftcnt) > 1; shftcnt++) + ; + dpbp->dpb_shftcnt = shftcnt; + dpbp->dpb_mdb = bpbp->bpb_mdesc; dpbp->dpb_secsize = bpbp->bpb_nbyte; dpbp->dpb_clsmask = bpbp->bpb_nsector - 1; @@ -2261,14 +2265,11 @@ VOID bpb_to_dpb(bpb FAR * bpbp, REG struct dpb FAR * dpbp) dpbp->dpb_dirents = bpbp->bpb_ndirent; size = bpbp->bpb_nsize == 0 ? bpbp->bpb_huge : (ULONG) bpbp->bpb_nsize; dpbp->dpb_fatsize = bpbp->bpb_nfsect; - dpbp->dpb_dirstrt = dpbp->dpb_fatstrt - + dpbp->dpb_fats * dpbp->dpb_fatsize; + dpbp->dpb_dirstrt = dpbp->dpb_fatstrt + dpbp->dpb_fats * dpbp->dpb_fatsize; dpbp->dpb_data = dpbp->dpb_dirstrt - + ((DIRENT_SIZE * (ULONG) dpbp->dpb_dirents - + (dpbp->dpb_secsize - 1)) / dpbp->dpb_secsize); -/* Michal Meller patch to jimtabor */ - dpbp->dpb_size = ((size - dpbp->dpb_data) - / ((ULONG) bpbp->bpb_nsector) + 1); + + (dpbp->dpb_dirents + dpbp->dpb_secsize/DIRENT_SIZE - 1) / + (dpbp->dpb_secsize/DIRENT_SIZE); + dpbp->dpb_size = ((size - dpbp->dpb_data) >> shftcnt) + 1; dpbp->dpb_flags = 0; dpbp->dpb_cluster = UNKNCLUSTER; /* number of free clusters */ @@ -2299,17 +2300,12 @@ VOID bpb_to_dpb(bpb FAR * bpbp, REG struct dpb FAR * dpbp) dpbp->dpb_size = 0; dpbp->dpb_xdata = dpbp->dpb_fatstrt + dpbp->dpb_fats * dpbp->dpb_xfatsize; - dpbp->dpb_xsize = - ((size - dpbp->dpb_xdata) / ((ULONG) bpbp->bpb_nsector) + 1); + dpbp->dpb_xsize = ((size - dpbp->dpb_xdata) >> shftcnt) + 1; dpbp->dpb_xrootclst = bpbp->bpb_xrootclst; read_fsinfo(dpbp); } } #endif - - for (shftcnt = 0; (bpbp->bpb_nsector >> shftcnt) > 1; shftcnt++) - ; - dpbp->dpb_shftcnt = shftcnt; } COUNT media_check(REG struct dpb FAR * dpbp) diff --git a/kernel/globals.h b/kernel/globals.h index 98a21bb8..54bedec3 100644 --- a/kernel/globals.h +++ b/kernel/globals.h @@ -335,8 +335,8 @@ extern BYTE ASM TempBuffer[], /* Temporary general purpose buffer */ FAR ASM swap_indos[], /* " " */ ASM tsr, /* true if program is TSR */ ASM break_flg, /* true if break was detected */ - ASM break_ena, /* break enabled flag */ - FAR * ASM dta; /* Disk transfer area (kludge) */ + ASM break_ena; /* break enabled flag */ +extern BYTE FAR * ASM dta; /* Disk transfer area (kludge) */ extern seg ASM cu_psp; /* current psp segment */ extern iregs FAR * ASM user_r; /* User registers for int 21h call */ @@ -381,10 +381,6 @@ GLOBAL f_node_ptr f_nodes; /* pointer to the array */ GLOBAL UWORD f_nodes_cnt; /* number of allocated f_nodes */ -/*!! GLOBAL iregs - FAR * ustackp, /* user stack */ -/*!! FAR * kstackp; *//* kernel stack */ - /* */ /* Function prototypes - automatically generated */ /* */ diff --git a/kernel/kernel.asm b/kernel/kernel.asm index 8ca501f2..082b82e8 100644 --- a/kernel/kernel.asm +++ b/kernel/kernel.asm @@ -603,7 +603,6 @@ _VirtOpen db 0 ;782 - virtual open flag ; controlled variables end at offset 78Ch so pad to end times (78ch - ($ - _internal_data)) db 0 -_swap_indos: ; ; end of controlled variables @@ -643,7 +642,7 @@ init_tos: __init_end: init_end: -segment _BSSEND +segment _DATA ; blockdev private stack global blk_stk_top times 192 dw 0 @@ -654,21 +653,22 @@ blk_stk_top: times 64 dw 0 clk_stk_top: -; this is nowhere needed -; interrupt stack -; global intr_stk_top -; times 256 dw 0 -;intr_stk_top: - -global __bssend -__bssend: - ; Dynamic data: ; member of the DOS DATA GROUP ; and marks definitive end of all used data in kernel data segment ; +segment _DATAEND + +_swap_indos: +; we don't know precisely what needs to be swapped before this, so set it here. +; this is just after FIXED_DATA+BSS+DATA and before (D)CONST+BSS +; probably, the clock and block stacks and disktransferbuffer should go past +; _swap_indos but only if int2a ah=80/81 (critical section start/end) +; are called upon entry and exit of the device drivers + segment DYN_DATA + global _Dyn _Dyn: DynAllocated dw 0 diff --git a/kernel/ludivmul.inc b/kernel/ludivmul.inc index fd60406f..decf7792 100644 --- a/kernel/ludivmul.inc +++ b/kernel/ludivmul.inc @@ -1,19 +1,19 @@ -; these are adapted from elks, http://elks.sourceforge.net +; this one adapted from elks, http://elks.sourceforge.net ; multiply cx:bx * dx:ax, result in dx:ax %macro LMULU 0 push si push cx - mov si,ax ; save _ax in si - mov ax,bx ; cx:ax = _cx:_bx - mul dx ; dx:ax = _bx*_dx (forget dx) - xchg cx,ax ; cx = low(_dx*_bx) - mul si ; dx:ax = _cx*_ax (forget dx) - add cx,ax ; cx = low(_cx*_ax + _dx*_bx) - mov ax,si ; restore _ax - mul bx ; dx:ax = _bx*_ax - add dx,cx ; dx = high(_bx*_ax)+low(_cx*_ax + _dx*_bx) + mov si, ax ; save _ax in si + mov ax, bx ; cx:ax = _cx:_bx + mul dx ; dx:ax = _bx*_dx (forget dx) + xchg cx, ax ; cx = low(_dx*_bx) + mul si ; dx:ax = _cx*_ax (forget dx) + add cx, ax ; cx = low(_cx*_ax + _dx*_bx) + mov ax, si ; restore _ax + mul bx ; dx:ax = _bx*_ax + add dx, cx ; dx = high(_bx*_ax)+low(_cx*_ax + _dx*_bx) pop cx pop si ret @@ -23,122 +23,88 @@ ; divide dx:ax / cx:bx, quotient in dx:ax, remainder in cx:bx %macro LDIVMODU 0 -; ldivmod.s - 32 over 32 to 32 bit division and remainder for 8086 - -; ludivmod( dividend bx:ax, divisor di:cx ) [ unsigned quot di:cx, rem bx:ax ] - -; dx is not preserved - - -; NB negatives are handled correctly, unlike by the processor -; divison by zero does not trap - - -; let dividend = a, divisor = b, quotient = q, remainder = r -; a = b * q + r mod 2^32 -; where: - -; if b = 0, q = 0 and r = a - -; otherwise, q and r are uniquely determined by the requirements: -; r has the same sign as b and absolute value smaller than that of b, i.e. -; 0 <= r < b - - push di - mov di,cx - mov cx,bx - mov bx,dx - - push bp - push si - mov bp,sp - push di ; remember b - push cx - -%assign b0 -4 -%assign b16 -2 - - test di,di - jne %%divlarge - test cx,cx - je %%return ; divzero: return q = 0 and r = a - cmp bx,cx - jae %%divlarge ; would overflow - mov dx,bx ; a in dx:ax - div cx - xchg cx,ax ; q in di:cx, junk in ax - xchg ax,dx ; r in ax, junk in dx - mov bx,di ; r in bx:ax - jmp %%return - -%%divlarge: - mov si,di ; w in si:dx, initially b from di:cx - mov dx,cx - xor cx,cx ; q in di:cx, initially 0 - mov di,cx - -; r in bx:ax, initially a -; use di:cx rather than dx:cx in order to -; have dx free for a byte pair later - - cmp si,bx - jb %%loop1 - ja %%return ; finished if b > r - cmp dx,ax - ja %%return - -; rotate w (= b) to greatest dyadic multiple of b <= r - -%%loop1: - shl dx,1 ; w = 2*w - rcl si,1 - jc %%loop1_exit ; w was > r counting overflow (unsigned) - cmp si,bx ; while w <= r (unsigned) - jb %%loop1 - ja %%loop1_exit - cmp dx,ax - jbe %%loop1 ; else exit with carry clear for rcr - -%%loop1_exit: - rcr si,1 - rcr dx,1 - -%%loop2: - shl cx,1 ; q = 2*q - rcl di,1 - cmp si,bx ; if w <= r - jb %%loop2_over - ja %%loop2_test - cmp dx,ax - ja %%loop2_test - -%%loop2_over: - add cx,1 ; q++ - adc di,0 - sub ax,dx ; r = r-w - sbb bx,si - -%%loop2_test: - shr si,1 ; w = w/2 - rcr dx,1 - cmp si,[bp+b16] ; while w >= b - ja %%loop2 - jb %%return - cmp dx,[bp+b0] - jae %%loop2 - -%%return: - mov sp,bp - pop si - pop bp - - mov dx,bx - mov bx,ax - mov ax,cx - mov cx,dx - mov dx,di - pop di +; this one is adapted from an assembly gem: +; gem writer: Norbert Juffa, norbert.juffa@amd.com + +; Dividing 64-bit unsigned integers Assembler / 80386 + +; Here is a division routine for dividing two 64-bit unsigned integers. +; I derived it by modifying some old +; 16-bit code for dividing 32-bit integers that I did several years ago for a +; Turbo-Pascal replacement library. +; If a 64-bit signed integer division is needed, appropriate shell code for +; this routine can easily be written. +; +; (adapted back to 32-bit by Bart Oldeman ;-)) +; +; __U4D divides two unsigned long numbers, the dividend and the divisor +; resulting in a quotient and a remainder. +; +; input: +; dx:ax = dividend +; cx:bx = divisor +; +; output: +; dx:ax = quotient of division of dividend by divisor +; cx:bx = remainder of division of dividend by divisor +; +; destroys: +; flags +; + + test cx, cx ; divisor > 2^32-1 ? + jnz %%big_divisor ; yes, divisor > 32^32-1 + cmp dx, bx ; only one division needed ? (ecx = 0) + jb %%one_div ; yes, one division sufficient + + + xchg cx, ax ; save dividend-lo in cx, ax=0 + xchg ax, dx ; get dividend-hi in ax, dx=0 + div bx ; quotient-hi in eax + xchg ax, cx ; cx = quotient-hi, ax =dividend-lo + +%%one_div: + div bx ; ax = quotient-lo + mov bx, dx ; bx = remainder-lo + mov dx, cx ; dx = quotient-hi(quotient in dx:ax) + xor cx, cx ; cx = remainder-hi (rem. in cx:bx) + ret +%%big_divisor: + push si ; save temp + push di ; variables + push dx ; save + push ax ; dividend + mov si, bx ; divisor now in + mov di, cx ; di:bx and cx:si +%%shift_loop: + shr dx, 1 ; shift both + rcr ax, 1 ; divisor and + shr di, 1 ; and dividend + rcr bx, 1 ; right by 1 bit + jnz %%shift_loop ; loop if di non-zero (rcr does not touch ZF) + mov di, cx ; restore original divisor (di:si) + div bx ; compute quotient + pop bx ; get dividend lo-word + mov cx, ax ; save quotient + mul di ; quotient * divisor hi-word (low only) + xchg ax, di ; save in di + mov ax, cx ; ax=quotient + mul si ; quotient * divisor lo-word + add dx, di ; dx:ax = quotient * divisor + sub bx, ax ; dividend-lo - (quot.*divisor)-lo + mov ax, cx ; get quotient + pop cx ; restore dividend hi-word + sbb cx, dx ; subtract divisor * quot. from dividend + sbb dx, dx ; 0 if remainder > 0, else FFFFFFFFh + and si, dx ; nothing to add + and di, dx ; back if remainder positive + add bx, si ; correct remaider + adc cx, di ; and quotient if + add ax, dx ; necessary + xor dx, dx ; clear hi-word of quot (ax<=FFFFFFFFh) + pop di ; restore temp + pop si ; variables ret -%endmacro \ No newline at end of file +%endmacro \ No newline at end of file diff --git a/kernel/makefile b/kernel/makefile index 3fd72247..636ebfd4 100644 --- a/kernel/makefile +++ b/kernel/makefile @@ -104,21 +104,24 @@ clean: # XXX: This is a very ugly way of linking the kernel, forced upon us by the # inability of Turbo `make' 2.0 to perform command line redirection. -- ror4 kernel.exe: $(EXE_dependencies) $(LIBS) - -$(RM) kernel.lib - $(LIBUTIL) kernel.lib $(LIBPLUS)entry.obj $(LIBPLUS)io.obj $(LIBPLUS)blockio.obj $(LIBPLUS)chario.obj $(LIBPLUS)dosfns.obj $(LIBPLUS)console.obj$(LIBTERM) - $(LIBUTIL) kernel.lib $(LIBPLUS)printer.obj $(LIBPLUS)serial.obj $(LIBPLUS)dsk.obj $(LIBPLUS)initdisk.obj $(LIBPLUS)error.obj $(LIBPLUS)fatdir.obj $(LIBPLUS)fatfs.obj$(LIBTERM) - $(LIBUTIL) kernel.lib $(LIBPLUS)fattab.obj $(LIBPLUS)fcbfns.obj $(LIBPLUS)initoem.obj $(LIBPLUS)initHMA.obj $(LIBPLUS)inthndlr.obj $(LIBPLUS)ioctl.obj $(LIBPLUS)nls_hc.obj$(LIBTERM) - $(LIBUTIL) kernel.lib $(LIBPLUS)main.obj $(LIBPLUS)config.obj $(LIBPLUS)memmgr.obj $(LIBPLUS)misc.obj $(LIBPLUS)newstuff.obj $(LIBPLUS)nls.obj $(LIBPLUS)intr.obj$(LIBTERM) - $(LIBUTIL) kernel.lib $(LIBPLUS)dosnames.obj $(LIBPLUS)prf.obj $(LIBPLUS)strings.obj $(LIBPLUS)network.obj $(LIBPLUS)sysclk.obj $(LIBPLUS)syspack.obj$(LIBTERM) - $(LIBUTIL) kernel.lib $(LIBPLUS)systime.obj $(LIBPLUS)task.obj $(LIBPLUS)int2f.obj $(LIBPLUS)irqstack.obj $(LIBPLUS)apisupt.obj$(LIBTERM) - $(LIBUTIL) kernel.lib $(LIBPLUS)asmsupt.obj $(LIBPLUS)execrh.obj $(LIBPLUS)nlssupt.obj $(LIBPLUS)procsupt.obj $(LIBPLUS)break.obj$(LIBTERM) - $(LIBUTIL) kernel.lib $(LIBPLUS)dosidle.obj $(LIBPLUS)dyninit.obj $(LIBPLUS)lfnapi.obj $(LIBTERM) - -$(RM) kernel.bak - $(LINK) kernel iprf,kernel,kernel,kernel+$(LIBS)+..\lib\libm.lib; - -$(RM) kernel.lib + -$(RM) kernel.res + ..\utils\echoto kernel.res kernel.obj iprf.obj+ + ..\utils\echoto kernel.res entry.obj io.obj blockio.obj chario.obj dosfns.obj console.obj+ + ..\utils\echoto kernel.res printer.obj serial.obj dsk.obj initdisk.obj error.obj fatdir.obj fatfs.obj+ + ..\utils\echoto kernel.res fattab.obj fcbfns.obj initoem.obj initHMA.obj inthndlr.obj ioctl.obj nls_hc.obj+ + ..\utils\echoto kernel.res main.obj config.obj memmgr.obj misc.obj newstuff.obj nls.obj intr.obj+ + ..\utils\echoto kernel.res dosnames.obj prf.obj strings.obj network.obj sysclk.obj syspack.obj+ + ..\utils\echoto kernel.res systime.obj task.obj int2f.obj irqstack.obj apisupt.obj+ + ..\utils\echoto kernel.res asmsupt.obj execrh.obj nlssupt.obj procsupt.obj break.obj+ + ..\utils\echoto kernel.res dosidle.obj dyninit.obj lfnapi.obj + ..\utils\echoto kernel.res kernel.exe + ..\utils\echoto kernel.res kernel.map + ..\utils\echoto kernel.res ..\lib\libm.lib ..\lib\device.lib + $(LINK) @kernel.res; + -$(RM) kernel.res # *Individual File Dependencies* -kernel.obj: kernel.asm segs.inc +kernel.obj: kernel.asm segs.inc ludivmul.inc console.obj: console.asm io.inc diff --git a/kernel/segs.inc b/kernel/segs.inc index a3599d3a..9fdeee2c 100644 --- a/kernel/segs.inc +++ b/kernel/segs.inc @@ -29,7 +29,7 @@ group PGROUP PSP group TGROUP _TEXT _IO_TEXT _IO_FIXED_DATA -group DGROUP _FIXED_DATA _DATA _BSSSTART _BSS _BSSEND DYN_DATA DCONST +group DGROUP _FIXED_DATA _BSS _DATA _DATAEND CONST CONST2 DCONST DYN_DATA group I_GROUP INIT_TEXT_START INIT_TEXT INIT_TEXT_END ID_B ID ID_E IC IDATA ICONST ICONST2 I_DATA I_BSS IB_B IB IB_E group HGROUP HMA_TEXT_START HMA_TEXT HMA_TEXT_END @@ -37,11 +37,13 @@ segment PSP class=PSP segment _TEXT class=CODE segment _IO_TEXT class=CODE segment _IO_FIXED_DATA class=CODE align=2 -segment _FIXED_DATA class=DATA align=16 -segment _DATA class=DATA align=2 -segment _BSSSTART class=BSS align=2 +segment _FIXED_DATA class=FDATA align=16 segment _BSS class=BSS align=2 -segment _BSSEND class=BSS +segment _DATA class=DATA align=2 +segment _DATAEND class=DATA align=1 +;for WATCOM +segment CONST class=DATA align=2 +segment CONST2 class=DATA align=2 ;for MSC segment DCONST class=DCONST align=2 segment DYN_DATA class=DYN_DATA diff --git a/kernel/sysclk.c b/kernel/sysclk.c index f2f73c77..fb6b0847 100644 --- a/kernel/sysclk.c +++ b/kernel/sysclk.c @@ -111,7 +111,7 @@ WORD ASMCFUNC FAR clk_driver(rqptr rp) BcdToByte(bcd_seconds)) * 19663ul / 1080ul; WritePCClock(Ticks); } - rp->r_endaddr = device_end(); + /* rp->r_endaddr = device_end(); not needed - bart */ rp->r_nunits = 0; return S_DONE; diff --git a/mkfiles/watcom.mak b/mkfiles/watcom.mak index 23729ab2..05f5f2a3 100644 --- a/mkfiles/watcom.mak +++ b/mkfiles/watcom.mak @@ -21,8 +21,8 @@ LIBUTIL=$(COMPILERBIN)\wlib LIBPLUS= LIBTERM= -CFLAGST=-zp=1 -mt -CFLAGSC=-zp=1 -mc +CFLAGST=-zp=1 -mt -os -s -we -e=3 -w=2 +CFLAGSC=-zp=1 -mc -os -s -we -e=3 -w=2 TARGET=KWC @@ -30,13 +30,6 @@ TARGET=KWC CLIB=$(COMPILERPATH)\lib286\dos\clibm.lib -# -#MATH_EXTRACT=*i4d *i4m -#MATH_INSERT= +i4d +i4m -# -# these are NOT usable, as they are called NEAR, and are in TEXT segment. -# so we can't use them, when moving the kernel. called ~15 times -# # we use our own ones, which override these ones when linking. # diff --git a/sys/fdkrncfg.c b/sys/fdkrncfg.c index 21f2d65f..b2d44717 100644 --- a/sys/fdkrncfg.c +++ b/sys/fdkrncfg.c @@ -20,11 +20,14 @@ char PROGRAM[] = "SYS CONFIG"; char KERNEL[] = "KERNEL.SYS"; #include -#include #include #include #include +#include "portab.h" +extern WORD CDECL printf(CONST BYTE * fmt, ...); +extern WORD CDECL sprintf(BYTE * buff, CONST BYTE * fmt, ...); + #define FAR far #include "kconfig.h" @@ -85,10 +88,6 @@ void showUsage(void) */ int readConfigSettings(int kfile, char *kfilename, KernelConfig * cfg) { - int ch; - int configBlkFound; - word cfgSize; - /* Seek to start of kernel file */ if (lseek(kfile, 2, SEEK_SET) != 2) printf("can't seek to offset 2\n"), exit(1); diff --git a/sys/sys.c b/sys/sys.c index ca2cae6f..34806916 100644 --- a/sys/sys.c +++ b/sys/sys.c @@ -51,10 +51,13 @@ #include #endif #include +#ifdef __TURBOC__ #include +#endif #define SYS_MAXPATH 260 #include "portab.h" extern WORD CDECL printf(CONST BYTE * fmt, ...); +extern WORD CDECL sprintf(BYTE * buff, CONST BYTE * fmt, ...); #include "b_fat12.h" #include "b_fat16.h" @@ -71,7 +74,7 @@ COUNT DiskRead(WORD, WORD, WORD, WORD, WORD, BYTE FAR *); COUNT DiskWrite(WORD, WORD, WORD, WORD, WORD, BYTE FAR *); #define SEC_SIZE 512 -#define COPY_SIZE 24576u +#define COPY_SIZE 32768u #ifdef _MSC_VER #pragma pack(1) @@ -159,7 +162,7 @@ int main(int argc, char **argv) COUNT drive; /* destination drive */ COUNT drivearg = 0; /* drive argument position */ BYTE *bsFile = NULL; /* user specified destination boot sector */ - COUNT srcDrive; /* source drive */ + unsigned srcDrive; /* source drive */ BYTE srcPath[SYS_MAXPATH]; /* user specified source drive and/or path */ BYTE rootPath[4]; /* alternate source path to try if not '\0' */ WORD slen; @@ -221,7 +224,7 @@ int main(int argc, char **argv) else /* src doesn't specify drive, so assume current drive */ { #ifdef __TURBOC__ - srcDrive = getdisk(); + srcDrive = (unsigned) getdisk(); #else _dos_getdrive(&srcDrive); #endif @@ -309,7 +312,6 @@ int MyAbsReadWrite(int DosDrive, int count, ULONG sector, void *buffer, unsigned short count; void far *address; } diskReadPacket; - int retval; union REGS regs; diskReadPacket.sectorNumber = sector; @@ -342,9 +344,6 @@ int MyAbsReadWrite(int DosDrive, int count, ULONG sector, void *buffer, VOID put_boot(COUNT drive, BYTE * bsFile, BOOL both) { - COUNT i, z; - WORD head, track, sector, ret; - WORD count; ULONG temp; struct bootsectortype *bs; #ifdef WITHFAT32 @@ -599,7 +598,6 @@ BYTE copybuffer[COPY_SIZE]; BOOL copy(COUNT drive, BYTE * srcPath, BYTE * rootPath, BYTE * file) { BYTE dest[SYS_MAXPATH], source[SYS_MAXPATH]; - COUNT ifd, ofd; unsigned ret; int fdin, fdout; ULONG copied = 0; @@ -660,6 +658,13 @@ BOOL copy(COUNT drive, BYTE * srcPath, BYTE * rootPath, BYTE * file) setftime(fdout, &ftime); } #endif +#ifdef __WATCOMC__ + { + unsigned short date, time; + _dos_getftime(fdin, &date, &time); + _dos_setftime(fdout, date, time); + } +#endif close(fdin); close(fdout); diff --git a/utils/echoto.bat b/utils/echoto.bat new file mode 100755 index 00000000..31758d9e --- /dev/null +++ b/utils/echoto.bat @@ -0,0 +1 @@ +@echo %2 %3 %4 %5 %6 %7 %8 %9 >> %1 \ No newline at end of file diff --git a/utils/patchobj.c b/utils/patchobj.c index 4c1200d1..c811852b 100644 --- a/utils/patchobj.c +++ b/utils/patchobj.c @@ -55,8 +55,6 @@ void define_replace(char *sin) int main(int argc, char *argv[]) { char *argptr; - int argloop; - int cont; FILE *fd, *fdo; char *inname = 0, *outname = "~patchob.tmp"; diff --git a/utils/wlinker.bat b/utils/wlinker.bat new file mode 100755 index 00000000..47a065c7 --- /dev/null +++ b/utils/wlinker.bat @@ -0,0 +1 @@ +@ms2wlink %1 %2 %3 %4 %5 %6 %7 %8 %9 ,,,, | wlink \ No newline at end of file From 3644d8c22271ad7f090b7ed12808e88b207440b9 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sun, 3 Feb 2002 22:40:24 +0000 Subject: [PATCH 119/671] final changes for kernel 2026 test git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@345 6ac86273-5f31-0410-b378-82cca8765d1b --- build.bat | 2 +- docs/history.txt | 7 +- drivers/devend.asm | 70 --------------- hdr/portab.h | 6 +- kernel/config.c | 18 ++-- kernel/dosnames.c | 2 +- kernel/dsk.c | 24 ++--- kernel/globals.h | 5 +- kernel/init-mod.h | 6 +- kernel/inthndlr.c | 8 +- kernel/kernel.asm | 15 +--- kernel/main.c | 3 +- kernel/memmgr.c | 59 +----------- kernel/nls_hc.asm | 2 +- kernel/prf.c | 8 +- kernel/proto.h | 4 +- kernel/sysclk.c | 2 +- kernel/systime.c | 8 +- sys/fdkrncfg.c | 20 ++++- sys/sys.c | 217 ++++++++++++++++++++++++++++++++++++--------- 20 files changed, 244 insertions(+), 242 deletions(-) delete mode 100644 drivers/devend.asm diff --git a/build.bat b/build.bat index e6474887..6c353f60 100644 --- a/build.bat +++ b/build.bat @@ -113,7 +113,7 @@ cd ..\kernel %MAKE% production if errorlevel 1 goto abort -cd.. +cd .. :- if you like, put some finalizing commands (like copy to floppy) :- into build2.bat diff --git a/docs/history.txt b/docs/history.txt index df9ea833..d3c2bc15 100644 --- a/docs/history.txt +++ b/docs/history.txt @@ -8,6 +8,8 @@ * cleaned up midnight flag, dates * tmark() and friends are floppy specific and implemented in C instead of ASM (parts by Bart) + * DMA boundary checking gives the right number of sectors if + the start sector is 512-bytes-aligned. + Changes Victor * lfn fixes * FAT32 fixes @@ -36,7 +38,10 @@ recognize FF8-FFF as FAT12 ending (was only FFF) (bug #1021) * avoid using LIB when linking the kernel by echo-ing to a linker resource file. Use a batch file to bypass Borlands Make 2.0 - unwillingness to redirect stdout. + unwillingness to redirect stdout. + * UMB variable clean-up + * use of "const" for constant global variables + * reduced size of Watcom-compiled SYS binary 2001 Nov 18 - Build 2025c -------- Bart Oldeman (bart@dosemu.org) + Changes Bart diff --git a/drivers/devend.asm b/drivers/devend.asm deleted file mode 100644 index 8b12b8c3..00000000 --- a/drivers/devend.asm +++ /dev/null @@ -1,70 +0,0 @@ -; -; File: -; devend.asm -; Description: -; get end of device driver primitive -; -; Copyright (c) 1995 -; Pasquale J. Villani -; All Rights Reserved -; -; This file is part of DOS-C. -; -; DOS-C is free software; you can redistribute it and/or -; modify it under the terms of the GNU General Public License -; as published by the Free Software Foundation; either version -; 2, or (at your option) any later version. -; -; DOS-C is distributed in the hope that it will be useful, but -; WITHOUT ANY WARRANTY; without even the implied warranty of -; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See -; the GNU General Public License for more details. -; -; You should have received a copy of the GNU General Public -; License along with DOS-C; see the file COPYING. If not, -; write to the Free Software Foundation, 675 Mass Ave, -; Cambridge, MA 02139, USA. -; -; $Header$ -; - - %include "..\kernel\segs.inc" - - - extern __bssend:wrt DGROUP - -segment HMA_TEXT - - global _device_end - -_device_end: - mov ax,__bssend - mov dx,DGROUP - ret - -; Log: devend.asm,v -; Revision 1.3 1999/08/10 17:21:08 jprice -; ror4 2011-01 patch -; -; Revision 1.2 1999/03/29 17:08:31 jprice -; ror4 changes -; -; Revision 1.1.1.1 1999/03/29 15:40:22 jprice -; New version without IPL.SYS -; -; Revision 1.2 1999/01/22 04:16:39 jprice -; Formating -; -; Revision 1.1.1.1 1999/01/20 05:51:00 jprice -; Imported sources -; -; -; Rev 1.2 29 Aug 1996 13:07:14 patv -;Bug fixes for v0.91b -; -; Rev 1.1 01 Sep 1995 18:50:34 patv -;Initial GPL release. -; -; Rev 1.0 02 Jul 1995 7:56:50 patv -;Initial revision. -; diff --git a/hdr/portab.h b/hdr/portab.h index 0bcb781f..e8d4ea8a 100644 --- a/hdr/portab.h +++ b/hdr/portab.h @@ -197,12 +197,12 @@ typedef signed long LONG; #ifdef I86 #ifndef MK_FP #ifdef __WATCOMC__ -#define MK_FP(__s,__o) (((unsigned short)(__s)):>((void __near *)(__o))) +#define MK_FP(seg,ofs) (((UWORD)(seg)):>((VOID *)(ofs))) #else #define MK_FP(seg,ofs) ((VOID far *)(((ULONG)(seg)<<16)|(UWORD)(ofs))) #endif -#define FP_SEG(fp) ((UWORD)((ULONG)(VOID FAR *)(fp)>>16)) -#define FP_OFF(fp) ((UWORD)(fp)) +#define FP_SEG(fp) ((unsigned)(UWORD)((ULONG)(VOID FAR *)(fp)>>16)) +#define FP_OFF(fp) ((unsigned)(UWORD)(fp)) #endif #endif diff --git a/kernel/config.c b/kernel/config.c index 16a2456a..f05ccce2 100644 --- a/kernel/config.c +++ b/kernel/config.c @@ -84,10 +84,10 @@ extern BYTE DOSFAR ASM VgaSet, DOSFAR _HMATextAvailable, /* first byte of ava DOSFAR ASM switchar, DOSFAR _InitTextStart, /* first available byte of ram */ DOSFAR ReturnAnyDosVersionExpected; -extern UWORD DOSFAR ASM ram_top, /* How much ram in Kbytes */ - - DOSFAR ASM UMB_top, - DOSFAR ASM umb_start, DOSFAR ASM uppermem_root, DOSFAR ASM LoL_nbuffers; +extern UWORD DOSFAR ASM uppermem_root, DOSFAR ASM LoL_nbuffers; + +UWORD umb_start = 0, UMB_top = 0; +UWORD ram_top = 0; /* How much ram in Kbytes */ struct config Config = { NUMBUFF, @@ -446,7 +446,7 @@ VOID configDone(VOID) { /* make last block normal with SC for the devices */ - mumcb_init(uppermem_root, umr_new - uppermem_root - 1); + mumcb_init(umb_start, umr_new - umb_start - 1); zumcb_init(umr_new, (umb_start + UMB_top) - umr_new - 1); upBase += 16; @@ -623,7 +623,7 @@ VOID DoConfig(int pass) umb_start = umb_seg; /* reset root */ - uppermem_root = umb_seg; + uppermem_root = ram_top * 64 - 1; /* setup the real mcb for the devicehigh block */ zumcb_init(umb_seg, UMB_top - 1); upBase += 16; @@ -1408,12 +1408,8 @@ STATIC VOID mcb_init(UCOUNT seg, UWORD size) mcbp->m_type = MCB_LAST; mcbp->m_psp = FREE_PSP; -/* if(UmbState == 1)*/ + mcbp->m_size = (UmbState > 0 ? size - 1 : size); - mcbp->m_size = (size - 1); -/* - mcbp->m_size = size; -*/ for (i = 0; i < 8; i++) mcbp->m_name[i] = '\0'; mem_access_mode = FIRST_FIT; diff --git a/kernel/dosnames.c b/kernel/dosnames.c index eceff6ce..3a67d998 100644 --- a/kernel/dosnames.c +++ b/kernel/dosnames.c @@ -37,7 +37,7 @@ static BYTE *dosnamesRcsId = #include "globals.h" -char _DirWildNameChars[] = "*?./\\\"[]:|<>+=;,"; +const char _DirWildNameChars[] = "*?./\\\"[]:|<>+=;,"; #define PathSep(c) ((c)=='/'||(c)=='\\') #define DriveChar(c) (((c)>='A'&&(c)<='Z')||((c)>='a'&&(c)<='z')) diff --git a/kernel/dsk.c b/kernel/dsk.c index dbdc2fa3..7ee28160 100644 --- a/kernel/dsk.c +++ b/kernel/dsk.c @@ -151,7 +151,7 @@ STATIC WORD dskerr(); /* the function dispatch table */ /* */ -static dsk_proc (*dispatch[NENTRY]) = +static dsk_proc * const dispatch[NENTRY] = { _dsk_init, /* Initialize */ mediachk, /* Media Check */ @@ -893,18 +893,12 @@ STATIC void LBA_to_CHS(struct CHS *chs, ULONG LBA_address, ddt * pddt) STATIC unsigned DMA_max_transfer(void FAR * buffer, unsigned count) { - UWORD utemp = (((UWORD) FP_SEG(buffer) << 4) + FP_OFF(buffer)); + unsigned dma_off = (UWORD)((FP_SEG(buffer) << 4) + FP_OFF(buffer)); + unsigned sectors_to_dma_boundary = (dma_off == 0 ? + 0xffff / SEC_SIZE : + (UWORD)(-dma_off) / SEC_SIZE); -#define SEC_SHIFT 9 /* = 0x200 = 512 */ - - utemp >>= SEC_SHIFT; - - if (count > (0xffff >> SEC_SHIFT) - utemp) - { - count = (0xffff >> SEC_SHIFT) - utemp; - } - - return count; + return min(count, sectors_to_dma_boundary); } /* @@ -968,12 +962,8 @@ STATIC int LBA_Transfer(ddt * pddt, UWORD mode, VOID FAR * buffer, for (; totaltodo != 0;) { - count = totaltodo; - - count = min(count, 0x7f); - /* avoid overflowing 64K DMA boundary */ - count = DMA_max_transfer(buffer, count); + count = DMA_max_transfer(buffer, totaltodo); if (FP_SEG(buffer) >= 0xa000 || count == 0) { diff --git a/kernel/globals.h b/kernel/globals.h index 54bedec3..b780284c 100644 --- a/kernel/globals.h +++ b/kernel/globals.h @@ -175,7 +175,6 @@ FAR ASM clk_dev, /* Clock device driver */ FAR ASM prn_dev, /* Generic printer device driver */ FAR ASM aux_dev, /* Generic aux device driver */ FAR ASM blk_dev; /* Block device (Disk) driver */ -extern UWORD ASM ram_top; /* How much ram in Kbytes */ extern COUNT *error_tos, /* error stack */ disk_api_tos, /* API handler stack - disk fns */ char_api_tos; /* API handler stack - char fns */ @@ -233,7 +232,7 @@ GLOBAL BYTE copyright[] = #endif -GLOBAL BYTE os_release[] +GLOBAL const BYTE os_release[] #ifdef MAIN #if 0 = "DOS-C version %d.%d Beta %d [FreeDOS Release] (Build %d).\n" @@ -260,7 +259,7 @@ extern BYTE ASM net_set_count; extern BYTE ASM NetDelay, ASM NetRetry; extern UWORD ASM first_mcb, /* Start of user memory */ - ASM UMB_top, ASM umb_start, ASM uppermem_root; /* Start of umb chain ? */ + ASM uppermem_root; /* Start of umb chain (usually 9fff) */ extern sfttbl FAR * ASM sfthead; /* System File Table head */ extern struct dhdr FAR * ASM clock, /* CLOCK$ device */ diff --git a/kernel/init-mod.h b/kernel/init-mod.h index 1705c534..83121062 100644 --- a/kernel/init-mod.h +++ b/kernel/init-mod.h @@ -161,7 +161,7 @@ VOID ASMCFUNC init_stacks(VOID FAR * stack_base, COUNT nStacks, /* inthndlr.c */ VOID ASMCFUNC FAR int21_entry(iregs UserRegs); VOID ASMCFUNC int21_service(iregs far * r); -VOID CDECL FAR int0_handler(void); +VOID ASMCFUNC FAR int0_handler(void); VOID ASMCFUNC FAR int6_handler(void); VOID ASMCFUNC FAR empty_handler(void); VOID ASMCFUNC FAR got_cbreak(void); /* procsupt.asm */ @@ -184,8 +184,8 @@ BOOL init_device(struct dhdr FAR * dhp, BYTE FAR * cmdLine, VOID init_fatal(BYTE * err_msg); /* prf.c */ -WORD ASMCFUNC init_printf(CONST BYTE * fmt, ...); -WORD ASMCFUNC init_sprintf(BYTE * buff, CONST BYTE * fmt, ...); +WORD CDECL init_printf(CONST BYTE * fmt, ...); +WORD CDECL init_sprintf(BYTE * buff, CONST BYTE * fmt, ...); void MoveKernel(unsigned NewKernelSegment); extern WORD HMAFree; /* first byte in HMA not yet used */ diff --git a/kernel/inthndlr.c b/kernel/inthndlr.c index a0f0a734..73744bc3 100644 --- a/kernel/inthndlr.c +++ b/kernel/inthndlr.c @@ -1327,11 +1327,9 @@ VOID ASMCFUNC int21_service(iregs FAR * r) /* UNDOCUMENTED: Double byte and korean tables */ case 0x63: { - static char dbcsTable[4] = { - 0, 0, 0, 0 - }; - r->DS = FP_SEG(&dbcsTable); - r->SI = FP_OFF(&dbcsTable); + static char *dbcsTable = "\0\0\0\0"; + r->DS = FP_SEG(dbcsTable); + r->SI = FP_OFF(dbcsTable); #if 0 /* not really supported, but will pass. */ r->AL = 0x00; /*jpp: according to interrupt list */ diff --git a/kernel/kernel.asm b/kernel/kernel.asm index 082b82e8..f46f87c4 100644 --- a/kernel/kernel.asm +++ b/kernel/kernel.asm @@ -340,12 +340,11 @@ _VgaSet db 0 ; 0060 unknown dw 0 ; 0061 unknown global _uppermem_link _uppermem_link db 0 ; 0063 upper memory link flag - global _UMB_top -_UMB_top dw 0 ; 0064 unknown UMB_top will do for now +_min_pars dw 0 ; 0064 minimum paragraphs of memory + ; required by program being EXECed global _uppermem_root -_uppermem_root dw 0 ; 0066 dmd_upper_root - global _umb_start -_umb_start dw 0 ; 0068 para of last mem search +_uppermem_root dw 0 ; 0066 dmd_upper_root (usually 9fff) +_last_para dw 0 ; 0068 para of last mem search SysVarEnd: ;; The first 5 sft entries appear to have to be at DS:00cc @@ -615,12 +614,6 @@ segment _BSS ;!!intr_dos_seg resw 1 - global _ram_top -_ram_top dw 0 - - - -; ; mark front and end of bss area to clear segment IB_B global __ib_start diff --git a/kernel/main.c b/kernel/main.c index 4a0bc652..88cd488a 100644 --- a/kernel/main.c +++ b/kernel/main.c @@ -55,7 +55,6 @@ GLOBAL BYTE DOSFAR os_major, /* major version number */ DOSFAR ASM default_drive; /* default drive for dos */ GLOBAL BYTE DOSFAR os_release[]; -/* GLOBAL BYTE DOSFAR copyright[]; */ GLOBAL seg DOSFAR RootPsp; /* Root process -- do not abort */ extern struct dpb FAR *DOSFAR ASM DPBp; /* First drive Parameter Block */ @@ -66,7 +65,6 @@ extern struct dhdr FAR *DOSFAR ASM clock, /* CLOCK$ device extern struct dhdr ASM DOSTEXTFAR con_dev, /* console device drive */ DOSTEXTFAR ASM clk_dev, /* Clock device driver */ DOSTEXTFAR ASM blk_dev; /* Block device (Disk) driver */ -extern UWORD DOSFAR ASM ram_top; /* How much ram in Kbytes */ extern iregs FAR *DOSFAR ASM user_r; /* User registers for int 21h call */ extern BYTE FAR ASM _HMATextEnd[]; @@ -85,6 +83,7 @@ extern BYTE FAR *lpOldTop; extern BYTE FAR *lpTop; extern BYTE FAR *upBase; extern BYTE ASM _ib_start[], ASM _ib_end[], ASM _init_end[]; +extern UWORD ram_top; /* How much ram in Kbytes */ VOID configDone(VOID); STATIC VOID InitIO(void); diff --git a/kernel/memmgr.c b/kernel/memmgr.c index 6edaf5ef..ab8b795b 100644 --- a/kernel/memmgr.c +++ b/kernel/memmgr.c @@ -568,7 +568,6 @@ VOID DosUmbLink(BYTE n) { REG mcb FAR *p; REG mcb FAR *q; - mcb FAR *end_of_conv_mem = para2far(ram_top * 64 - 1); if (uppermem_root == 0) return; @@ -577,7 +576,7 @@ VOID DosUmbLink(BYTE n) /* like a xor thing! */ if ((uppermem_link == 1) && (n == 0)) { - while (p != end_of_conv_mem) + while (FP_SEG(p) != uppermem_root) { if (mcbFree(p)) joinMCBs(p); @@ -587,7 +586,7 @@ VOID DosUmbLink(BYTE n) p = nxtMCB(p); } - if (q->m_type == MCB_NORMAL) + if (q->m_type == MCB_NORMAL) q->m_type = MCB_LAST; uppermem_link = n; @@ -601,65 +600,13 @@ VOID DosUmbLink(BYTE n) q = nxtMCB(q); } - if (q->m_type == MCB_LAST) - q->m_type = MCB_NORMAL; + q->m_type = MCB_NORMAL; uppermem_link = n; } DUL_exit: return; } -/* - if we arrive here the first time, it's just - before jumping to COMMAND.COM - - so we are done initializing, and can claim the IMIT_DATA segment, - as these data/strings/buffers are no longer in use. - - we carve a free memory block out of it and hope that - it will be useful (maybe for storing environments) - -*/ -#if 0 -BYTE INITDataSegmentClaimed = 1; /* must be enabled by CONFIG.SYS */ -extern BYTE _INIT_DATA_START[], _INIT_DATA_END[]; - -VOID ClaimINITDataSegment() -{ - unsigned ilow, ihigh; - VOID FAR *p; - - if (INITDataSegmentClaimed) - return; - INITDataSegmentClaimed = 1; - - ilow = (unsigned)_INIT_DATA_START; - ilow = (ilow + 0x0f) & ~0x000f; - ihigh = (unsigned)_INIT_DATA_END; - ihigh = ((ihigh + 0x0f) & ~0x000f) - 0x20; - - if (ilow + 0x10 < ihigh) - { - printf("CLAIMING INIT_DATA memory - %u bytes\n", ihigh - ilow); - } - - ((mcb *) ilow)->m_type = MCB_NORMAL; /* 'M' */ - ((mcb *) ilow)->m_psp = FREE_PSP; /* '0' */ - ((mcb *) ilow)->m_size = (ihigh - ilow - 0x10) >> 4; /* '0' */ - - ((mcb *) ihigh)->m_type = MCB_NORMAL; /* 'M' */ - ((mcb *) ihigh)->m_psp = 0x0008; /* system */ - - p = (void FAR *)(void *)ihigh; - - ((mcb *) ihigh)->m_size = first_mcb - 1 - FP_SEG(p) - (FP_OFF(p) >> 4); - - p = (void FAR *)(void *)ilow; - - first_mcb = FP_SEG(p) + (FP_OFF(p) >> 4); - -} -#endif #endif /* diff --git a/kernel/nls_hc.asm b/kernel/nls_hc.asm index c963ee47..c511443c 100644 --- a/kernel/nls_hc.asm +++ b/kernel/nls_hc.asm @@ -7,7 +7,7 @@ ;; ==> Reordering tables 1, 2, 4 and 5 %include "segs.inc" -segment _DATA +segment CONST2 GLOBAL _nlsPackageHardcoded _nlsPackageHardcoded: diff --git a/kernel/prf.c b/kernel/prf.c index cef1a4f9..aa978fbe 100644 --- a/kernel/prf.c +++ b/kernel/prf.c @@ -50,6 +50,7 @@ static char buff[MAX_BUFSIZE]; #define sprintf init_sprintf #define charp init_charp #define hexd init_hexd +#define hexDigits init_hexDigits #endif COUNT ASMCFUNC fstrlen(BYTE FAR * s); /* don't want globals.h, sorry */ @@ -163,9 +164,7 @@ BYTE *ltob(LONG n, BYTE * s, COUNT base) p = q = s; do { /* generate digits in reverse order */ - static char hexDigits[] = "0123456789abcdef"; - - *p++ = hexDigits[(UWORD) (u % base)]; + *p++ = "0123456789abcdef"[(UWORD) (u % base)]; } while ((u /= base) > 0); @@ -277,12 +276,11 @@ COUNT do_printf(CONST BYTE * fmt, BYTE ** arg) case 'p': { UWORD w[2]; - static char pointerFormat[] = "%04x:%04x"; w[1] = *((UWORD *) arg); arg += sizeof(UWORD) / sizeof(BYTE *); w[0] = *((UWORD *) arg); arg += sizeof(UWORD) / sizeof(BYTE *); - do_printf(pointerFormat, (BYTE **) & w); + do_printf("%04x:%04x", (BYTE **) & w); continue; } diff --git a/kernel/proto.h b/kernel/proto.h index ec81fd7d..3eb8fa99 100644 --- a/kernel/proto.h +++ b/kernel/proto.h @@ -310,7 +310,7 @@ COUNT ASMCFUNC fstrcmp(REG BYTE FAR * d, REG BYTE FAR * s); COUNT ASMCFUNC fstrncmp(REG BYTE FAR * d, REG BYTE FAR * s, COUNT l); COUNT ASMCFUNC strncmp(REG BYTE * d, REG BYTE * s, COUNT l); void ASMCFUNC fstrncpy(REG BYTE FAR * d, REG BYTE FAR * s, COUNT l); -BYTE * ASMCFUNC strchr(BYTE * s, BYTE c); +BYTE * ASMCFUNC strchr(const BYTE * s, BYTE c); /* sysclk.c */ COUNT BcdToByte(COUNT x); @@ -335,7 +335,7 @@ VOID DosGetDate(BYTE FAR * wdp, BYTE FAR * mp, BYTE FAR * mdp, COUNT FAR * yp); COUNT DosSetDate(UWORD Month, UWORD DayOfMonth, UWORD Year); -UWORD *is_leap_year_monthdays(UWORD year); +const UWORD *is_leap_year_monthdays(UWORD year); UWORD DaysFromYearMonthDay(UWORD Year, UWORD Month, UWORD DayOfMonth); /* task.c */ diff --git a/kernel/sysclk.c b/kernel/sysclk.c index fb6b0847..ffc07cc1 100644 --- a/kernel/sysclk.c +++ b/kernel/sysclk.c @@ -81,7 +81,7 @@ STATIC COUNT BcdToByte(COUNT x) WORD ASMCFUNC FAR clk_driver(rqptr rp) { COUNT c; - UWORD *pdays; + const UWORD *pdays; BYTE bcd_days[4], bcd_minutes, bcd_hours, bcd_seconds; ULONG Ticks; UWORD Month, Day, Year; diff --git a/kernel/systime.c b/kernel/systime.c index 15a217f1..b73281dc 100644 --- a/kernel/systime.c +++ b/kernel/systime.c @@ -36,7 +36,7 @@ static BYTE *RcsId = "$Id$"; #endif -UWORD days[2][13] = { +const UWORD days[2][13] = { {0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365}, {0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366} }; @@ -47,7 +47,7 @@ extern request ASM ClkReqHdr; return a pointer to an array with the days for that year */ -UWORD *is_leap_year_monthdays(UWORD y) +const UWORD *is_leap_year_monthdays(UWORD y) { /* this is correct in a strict mathematical sense return ((y) & 3 ? days[0] : (y) % 100 ? days[1] : (y) % 400 ? days[0] : days[1]); */ @@ -123,7 +123,7 @@ BYTE FAR *wdp, FAR * mp, FAR * mdp; COUNT FAR *yp; { UWORD c; - UWORD *pdays; + const UWORD *pdays; UWORD Year, Month; ExecuteClockDriverRequest(C_INPUT); @@ -164,7 +164,7 @@ COUNT FAR *yp; COUNT DosSetDate(Month, DayOfMonth, Year) UWORD Month, DayOfMonth, Year; { - UWORD *pdays; + const UWORD *pdays; pdays = is_leap_year_monthdays(Year); if (Year < 1980 || Year > 2099 diff --git a/sys/fdkrncfg.c b/sys/fdkrncfg.c index b2d44717..d7541fea 100644 --- a/sys/fdkrncfg.c +++ b/sys/fdkrncfg.c @@ -21,13 +21,30 @@ char KERNEL[] = "KERNEL.SYS"; #include #include -#include #include #include "portab.h" extern WORD CDECL printf(CONST BYTE * fmt, ...); extern WORD CDECL sprintf(BYTE * buff, CONST BYTE * fmt, ...); +#ifdef __WATCOMC__ +#define close _dos_close +#define SEEK_SET 0 +int open(const char *pathname, int flags, ...); +int read(int fd, void *buf, unsigned count); +int write(int fd, const void *buf, unsigned count); +int stat(const char *file_name, struct stat *buf); +unsigned long lseek(int fildes, unsigned long offset, int whence); +#pragma aux lseek = \ + "mov ah, 0x42" \ + "int 0x21" \ + parm [bx] [dx cx] [ax] \ + value [dx ax]; + +#else +#include +#endif + #define FAR far #include "kconfig.h" @@ -111,7 +128,6 @@ int readConfigSettings(int kfile, char *kfilename, KernelConfig * cfg) */ int writeConfigSettings(int kfile, KernelConfig * cfg) { - /* Seek to CONFIG section at start of options of kernel file */ if (lseek(kfile, 2, SEEK_SET) != 2) return 1; diff --git a/sys/sys.c b/sys/sys.c index 34806916..fdbc2c60 100644 --- a/sys/sys.c +++ b/sys/sys.c @@ -36,15 +36,13 @@ #define DEBUG /* #define DDEBUG */ -#define SYS_VERSION "v2.3" +#define SYS_VERSION "v2.4" -/* #include */ #include -#include -#include -#include #include #include +#include +#include #ifdef __TURBOC__ #include #else @@ -65,6 +63,48 @@ extern WORD CDECL sprintf(BYTE * buff, CONST BYTE * fmt, ...); #include "b_fat32.h" #endif +#ifndef __WATCOMC__ +#include +#else +/* some non-conforming functions to make the executable smaller */ +int open(const char *pathname, int flags, ...) +{ + int handle; + int result = (flags & O_CREAT ? + _dos_creat(pathname, _A_NORMAL, &handle) : + _dos_open(pathname, flags & (O_RDONLY | O_WRONLY | O_RDWR), + &handle)); + + return (result == 0 ? handle : -1); +} + +int read(int fd, void *buf, unsigned count) +{ + unsigned bytes; + int result = _dos_read(fd, buf, count, &bytes); + + return (result == 0 ? bytes : -1); +} + +int write(int fd, const void *buf, unsigned count) +{ + unsigned bytes; + int result = _dos_write(fd, buf, count, &bytes); + + return (result == 0 ? bytes : -1); +} + +#define close _dos_close + +int stat(const char *file_name, struct stat *buf) +{ + struct find_t find_tbuf; + UNREFERENCED_PARAMETER(buf); + + return _dos_findfirst(file_name, _A_NORMAL | _A_HIDDEN | _A_SYSTEM, &find_tbuf); +} +#endif + BYTE pgm[] = "SYS"; void put_boot(COUNT, BYTE *, BOOL); @@ -74,7 +114,7 @@ COUNT DiskRead(WORD, WORD, WORD, WORD, WORD, BYTE FAR *); COUNT DiskWrite(WORD, WORD, WORD, WORD, WORD, BYTE FAR *); #define SEC_SIZE 512 -#define COPY_SIZE 32768u +#define COPY_SIZE 0x7e00 #ifdef _MSC_VER #pragma pack(1) @@ -304,6 +344,66 @@ VOID dump_sector(unsigned char far * sec) MSDOS requires int25, CX=ffff for drives > 32MB */ +#ifdef __WATCOMC__ +unsigned int2526readwrite(int DosDrive, void *diskReadPacket, unsigned intno); +#pragma aux int2526readwrite = \ + "mov cx, 0xffff" \ + "cmp si, 0x26" \ + "je int26" \ + "int 0x25" \ + "jmp short cfltest" \ + "int26:" \ + "int 0x26" \ + "cfltest:" \ + "mov ax, 0" \ + "adc ax, ax" \ + parm [ax] [bx] [si] \ + modify [cx] \ + value [ax]; + +fat32readwrite(int DosDrive, void *diskReadPacket, unsigned intno); +#pragma aux fat32readwrite = \ + "mov ax, 0x7305" \ + "mov cx, 0xffff" \ + "inc dx" \ + "sub si, 0x25" \ + "int 0x21" \ + "mov ax, 0" \ + "adc ax, ax" \ + parm [dx] [bx] [si] \ + modify [cx dx si] \ + value [ax]; + +#else +int2526readwrite(int DosDrive, void *diskReadPacket, unsigned intno) +{ + union REGS regs; + + regs.h.al = (BYTE) DosDrive; + regs.x.bx = (short)&diskReadPacket; + regs.x.cx = 0xffff; + + int86(intno, ®s, ®s); + + return regs.x.cflag; +} + + +fat32readwrite(int DosDrive, void *diskReadPacket, unsigned intno) +{ + union REGS regs; + + regs.x.ax = 0x7305; + regs.h.dl = DosDrive + 1; + regs.x.bx = (short)&diskReadPacket; + regs.x.cx = 0xffff; + regs.x.si = intno - 0x25; + int86(0x21, ®s, ®s); + + return regs.x.cflag; +} +#endif + int MyAbsReadWrite(int DosDrive, int count, ULONG sector, void *buffer, unsigned intno) { @@ -312,36 +412,82 @@ int MyAbsReadWrite(int DosDrive, int count, ULONG sector, void *buffer, unsigned short count; void far *address; } diskReadPacket; - union REGS regs; diskReadPacket.sectorNumber = sector; diskReadPacket.count = count; diskReadPacket.address = buffer; - regs.h.al = (BYTE) DosDrive; - regs.x.bx = (short)&diskReadPacket; - regs.x.cx = 0xffff; - if (intno != 0x25 && intno != 0x26) return 0xff; - int86(intno, ®s, ®s); - -#ifdef WITHFAT32 - if (regs.x.cflag) + if (int2526readwrite(DosDrive, &diskReadPacket, intno)) { - regs.x.ax = 0x7305; - regs.h.dl = DosDrive + 1; - regs.x.bx = (short)&diskReadPacket; - regs.x.cx = 0xffff; - regs.x.si = intno - 0x25; - int86(0x21, ®s, ®s); - } +#ifdef WITHFAT32 + return fat32readwrite(DosDrive, &diskReadPacket, intno); +#else + return 0xff; #endif + } + return 0; +} + +#ifdef __WATCOMC__ + +unsigned getdrivespace(COUNT drive, unsigned *total_clusters); +#pragma aux getdrivespace = \ + "mov ah, 0x36" \ + "inc dx" \ + "int 0x21" \ + "mov [si], dx" \ + parm [dx] [si] \ + modify [bx cx dx] \ + value [ax]; + +unsigned getextdrivespace(void *drivename, void *buf, unsigned buf_size); +#pragma aux getextdrivespace = \ + "mov ax, 0x7303" \ + "push ds" \ + "pop es" \ + "int 0x21" \ + "mov ax, 0" \ + "adc ax, ax" \ + parm [dx] [di] [cx] \ + modify [es] \ + value [ax]; - return regs.x.cflag ? 0xff : 0; +#else + +unsigned getdrivespace(COUNT drive, unsigned *total_clusters) +{ + union REGS regs; + + regs.h.ah = 0x36; /* get drive free space */ + regs.h.dl = drive + 1; /* 1 = 'A',... */ + int86(0x21, ®s, ®s); + *total_clusters = regs.x.dx; + return regs.x.ax; +} + +unsigned getextdrivespace(void *drivename, void *buf, unsigned buf_size) +{ + union REGS regs; + struct SREGS sregs; + + regs.x.ax = 0x7303; /* get extended drive free space */ + + sregs.es = FP_SEG(buf); + regs.x.di = FP_OFF(buf); + sregs.ds = FP_SEG(drivename); + regs.x.dx = FP_OFF(drivename); + + regs.x.cx = buf_size; + + int86x(0x21, ®s, ®s, &sregs); + return regs.x.cflag; } +#endif + VOID put_boot(COUNT drive, BYTE * bsFile, BOOL both) { ULONG temp; @@ -350,10 +496,9 @@ VOID put_boot(COUNT drive, BYTE * bsFile, BOOL both) struct bootsectortype32 *bs32; #endif int fs; - union REGS regs; - struct SREGS sregs; char drivename[] = "A:\\"; unsigned char x[0x40]; + unsigned total_clusters; #ifdef DEBUG printf("Reading old bootsector from drive %c:\n", drive + 'A'); @@ -386,17 +531,13 @@ VOID put_boot(COUNT drive, BYTE * bsFile, BOOL both) this should work, as the disk was writeable, so GetFreeDiskSpace should work. */ - regs.h.ah = 0x36; /* get drive free space */ - regs.h.dl = drive + 1; /* 1 = 'A',... */ - int86(0x21, ®s, ®s); - - if (regs.x.ax == 0xffff) + if (getdrivespace(drive, &total_clusters) == 0xffff) { printf("can't get free disk space for %c:\n", drive + 'A'); exit(1); } - if (regs.x.dx <= 0xff6) + if (total_clusters <= 0xff6) { if (fs != 12) printf("warning : new detection overrides old detection\a\n"); @@ -413,19 +554,9 @@ VOID put_boot(COUNT drive, BYTE * bsFile, BOOL both) we don't want to crash a FAT32 drive */ - segread(&sregs); - sregs.es = sregs.ds; - - regs.x.ax = 0x7303; /* get extended drive free space */ - drivename[0] = 'A' + drive; - regs.x.dx = (unsigned)&drivename; - regs.x.di = (unsigned)&x; - regs.x.cx = sizeof(x); - - int86x(0x21, ®s, ®s, &sregs); - - if (regs.x.cflag) /* error --> no Win98 --> no FAT32 */ + if (getextdrivespace(drivename, x, sizeof(x))) + /* error --> no Win98 --> no FAT32 */ { printf("get extended drive space not supported --> no FAT32\n"); } From 9502a97d91a3865117a2c2dc8f053ec51ea65c12 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Thu, 7 Feb 2002 22:30:58 +0000 Subject: [PATCH 120/671] FAT32 detection fixes git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@347 6ac86273-5f31-0410-b378-82cca8765d1b --- sys/sys.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sys/sys.c b/sys/sys.c index fdbc2c60..be66869f 100644 --- a/sys/sys.c +++ b/sys/sys.c @@ -448,6 +448,7 @@ unsigned getextdrivespace(void *drivename, void *buf, unsigned buf_size); "mov ax, 0x7303" \ "push ds" \ "pop es" \ + "stc" \ "int 0x21" \ "mov ax, 0" \ "adc ax, ax" \ @@ -483,7 +484,7 @@ unsigned getextdrivespace(void *drivename, void *buf, unsigned buf_size) regs.x.cx = buf_size; int86x(0x21, ®s, ®s, &sregs); - return regs.x.cflag; + return regs.x.ax == 0x7300 || regs.x.cflag; } #endif @@ -497,7 +498,8 @@ VOID put_boot(COUNT drive, BYTE * bsFile, BOOL both) #endif int fs; char drivename[] = "A:\\"; - unsigned char x[0x40]; + static unsigned char x[0x40]; /* we make this static to be 0 by default - + this avoids FAT misdetections */ unsigned total_clusters; #ifdef DEBUG From f7fb74424811dc6baea91a874b0a644ffbc25df1 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sat, 9 Feb 2002 00:40:33 +0000 Subject: [PATCH 121/671] kernel 2026 final changes git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@348 6ac86273-5f31-0410-b378-82cca8765d1b --- docs/build.txt | 16 ++++++++++- docs/history.txt | 23 ++++++++++++--- docs/sys.txt | 4 +-- hdr/version.h | 14 +++++---- kernel/config.c | 9 +++--- kernel/execrh.asm | 13 ++++++++- kernel/init-mod.h | 24 ++++++---------- kernel/inithma.c | 36 ------------------------ kernel/inthndlr.c | 2 +- kernel/kernel.asm | 72 +---------------------------------------------- kernel/main.c | 41 ++++++++++++++++++++++----- kernel/memmgr.c | 8 +++--- kernel/prf.c | 8 +++--- sys/fdkrncfg.c | 1 + 14 files changed, 116 insertions(+), 155 deletions(-) diff --git a/docs/build.txt b/docs/build.txt index 3de6f96b..e7700fdc 100644 --- a/docs/build.txt +++ b/docs/build.txt @@ -27,10 +27,24 @@ ftp://ftp.kernel.org/pub/software/devel/nasm or a mirror of ftp.kernel.org. -This program will now compile with Turbo C 2.01 (now freely +This kernel will now compile with Turbo C 2.01 (now freely available!), Turbo C 3.0, Borland C 4.51 & 5.01. It should work with other Borland compilers, Microsoft C and Watcom C. +The Watcom C 11.0c beta compiler for DOS can now be downloaded at +www.openwatcom.org: you need at least the following zips from +ftp://ftp.openwatcom.org/watcom/zips/ + +core_all - Core binaries (All hosts) +clib_hdr - C runtime library header files +clib_a16 - C runtime libraries (16-bit all targets) +clib_d16 - C runtime libraries (16-bit DOS) +core_binw - Core binaries (DOS host) +c_binw - C compiler (DOS host) + +Replace binw by binnt for an NT host or binp for an OS/2 host. +The host needs to be a 386+ with at least 8MB of memory. + If you feel hardy, read on to understand the directory structure. A more complete description of the build environment is contained in a companion book, "The FreeDOS Kernel" (ISBN: 0-87930-436-7) published diff --git a/docs/history.txt b/docs/history.txt index d3c2bc15..9530274b 100644 --- a/docs/history.txt +++ b/docs/history.txt @@ -1,9 +1,24 @@ -2002 Feb xx - Build 2026test +2002 Feb 9 - Build 2026 -------- Bart Oldeman (bart@dosemu.org) + Changes Tom - * FCB clean-ups and fixes (CYRUS CHESS, bug #1014) + * fixed various typos, #includes ++ Changes Bart + * fixed ECHO in config.sys + * made passing parameters to command.com more robust: + zero commandline before use, fixed buffer overflow for F5+F8 + * "uppermem_root" in the List of Lists is now FFFF if no UMBs + available, as documented in RBIL + * removed all direct hooks from init_text to hma_text; duplicated + the remaining functions (memset, memcpy and friends). + * bumped up default DOS version of FAT32 enabled kernel to 7.10 +2002 Feb 3 - Build 2026test +-------- Bart Oldeman (bart@dosemu.org) ++ Changes Tom + * FCB clean-ups and fixes (bug in FCB Random IO, + CYRUS CHESS, bug #1014) * initial config.sys menus (see config.txt) - * execrh + * execrh.asm: construct 'interrupt' address after strategy to avoid + some issues with non-trivial 'strategy' routines. * make kernel UPX-able * cleaned up midnight flag, dates * tmark() and friends are floppy specific and implemented in C @@ -11,7 +26,7 @@ * DMA boundary checking gives the right number of sectors if the start sector is 512-bytes-aligned. + Changes Victor - * lfn fixes + * lfn fixes (lfn is only a place holder, does not work yet) * FAT32 fixes * dosemu log nicer + Changes Martin diff --git a/docs/sys.txt b/docs/sys.txt index 1782b0b5..d7e15b56 100644 --- a/docs/sys.txt +++ b/docs/sys.txt @@ -134,7 +134,7 @@ file (CONFIG.SYS) processing). A 0 means you must have pressed the key precisely for when the kernel checks for it - essentially skipping, though a well timed finger will still get to use it. And any value -greater than 0 I belive is the seconds the kernel will +greater than 0 is the number of seconds the kernel will display the prompt and wait for you to press the key before assuming you didn't. @@ -143,7 +143,7 @@ FORCELBA=0 or FORCELBA=1 If 1 then the kernel will use LBA (extended INT13) techniques to address all partitions if possible, even if these have a non-LBA partition type and -are completely below cylinder 1023 (usually the 8MB +are completely below cylinder 1023 (usually the 8GB boundary). This is 0 by default, for compatibility reasons. Setting this to 1 may bypass some buggy BIOSes and gives slightly better performance. diff --git a/hdr/version.h b/hdr/version.h index e63510e3..fc088498 100644 --- a/hdr/version.h +++ b/hdr/version.h @@ -33,10 +33,14 @@ static BYTE *date_hRcsId = #endif #endif -/* This Kernel is at a min Dos Ver. 5.00 */ - +/* This Kernel is at a min Dos Ver. 5.00 or 7.10 with FAT32 support */ +#ifdef WITHFAT32 +#define MAJOR_RELEASE 7 +#define MINOR_RELEASE 10 +#else #define MAJOR_RELEASE 5 #define MINOR_RELEASE 00 +#endif #define REV_NUMBER 0 #define OEM_ID 0xfd /* FreeDos version */ @@ -45,6 +49,6 @@ static BYTE *date_hRcsId = #define REVISION_MINOR 1 #define REVISION_SEQ 26 #define BUILD "2026" -#define SUB_BUILD "test" -#define KERNEL_VERSION_STRING "1.1.26test" /*#REVISION_MAJOR "." #REVISION_MINOR "." #REVISION_SEQ */ -#define KERNEL_BUILD_STRING "2026test" /*#BUILD SUB_BUILD */ +#define SUB_BUILD "" +#define KERNEL_VERSION_STRING "1.1.26" /*#REVISION_MAJOR "." #REVISION_MINOR "." #REVISION_SEQ */ +#define KERNEL_BUILD_STRING "2026" /*#BUILD SUB_BUILD */ diff --git a/kernel/config.c b/kernel/config.c index f05ccce2..7556830d 100644 --- a/kernel/config.c +++ b/kernel/config.c @@ -591,7 +591,7 @@ VOID DoConfig(int pass) if (pEntry->pass >= 0 && pEntry->pass != nPass) continue; - if (nPass == 0) /* pass 0 always executed (rem Menu prompt) */ + if (nPass == 0) /* pass 0 always executed (rem Menu prompt) */ { (*(pEntry->func)) (pLine); continue; @@ -602,9 +602,10 @@ VOID DoConfig(int pass) continue; } - pLine = skipwh(pLine); + if (pEntry->func != CfgMenu) + pLine = skipwh(pLine); - if ('=' != *pLine) + if ('=' != *pLine && pEntry->func != CfgMenu) CfgFailure(pLine); else /* YES. DO IT */ (*(pEntry->func)) (skipwh(pLine + 1)); @@ -948,7 +949,7 @@ STATIC VOID Dosmem(BYTE * pLine) if (UmbState == 0) { uppermem_link = 0; - uppermem_root = 0; + uppermem_root = 0xffff; UmbState = UMBwanted ? 2 : 0; } /* Check if HMA is available straight away */ diff --git a/kernel/execrh.asm b/kernel/execrh.asm index 42868a2d..d3e79efe 100644 --- a/kernel/execrh.asm +++ b/kernel/execrh.asm @@ -42,7 +42,9 @@ segment HMA_TEXT ; The stack is very critical in here. ; global _execrh -_execrh: + global _init_execrh + +%macro EXECRH 0 push bp ; perform c entry mov bp,sp push si @@ -67,6 +69,15 @@ _execrh: pop si pop bp ret +%endmacro + +_execrh: + EXECRH + +segment INIT_TEXT + +_init_execrh: + EXECRH ; Log: execrh.asm,v ; Revision 1.3 2000/03/09 06:07:11 kernel diff --git a/kernel/init-mod.h b/kernel/init-mod.h index 83121062..82d94d50 100644 --- a/kernel/init-mod.h +++ b/kernel/init-mod.h @@ -31,21 +31,16 @@ extern struct _KernelConfig InitKernelConfig; */ #define printf init_printf #define sprintf init_sprintf -#define execrh reloc_call_execrh -#define fmemcpy reloc_call_fmemcpy -#define fmemset reloc_call_fmemset -#define memset reloc_call_memset -#define fstrncpy reloc_call_fstrncpy -#define strcpy reloc_call_strcpy -#define strlen reloc_call_strlen +#define execrh init_execrh +#define fmemcpy init_fmemcpy +#define fmemset init_fmemset +#define memset init_memset +#define strcpy init_strcpy WORD ASMCFUNC execrh(request FAR *, struct dhdr FAR *); -VOID ASMCFUNC fmemcpy(REG VOID FAR * d, REG VOID FAR * s, REG COUNT n); -void ASMCFUNC fmemset(REG VOID FAR * s, REG int ch, REG COUNT n); -void ASMCFUNC memset(REG VOID * s, REG int ch, REG COUNT n); -VOID ASMCFUNC strcpy(REG BYTE * d, REG BYTE * s); -VOID ASMCFUNC fstrncpy(REG BYTE FAR * d, REG BYTE FAR * s, REG COUNT n); -COUNT ASMCFUNC fstrlen(REG BYTE FAR * s); -COUNT ASMCFUNC strlen(REG BYTE * s); +void fmemcpy(void far *d, const void far *s, unsigned n); +void fmemset(void far *s, int ch, unsigned n); +void memset(void *s, int ch, unsigned n); +void strcpy(char *dest, const char *src); #undef LINESIZE #define LINESIZE KBD_MAXLENGTH @@ -56,7 +51,6 @@ int fmemcmp(BYTE far * s1, BYTE FAR * s2, unsigned len); #define setvec(n, isr) (void)(*(intvec FAR *)MK_FP(0,4 * (n)) = (isr)) -#define fbcopy(s, d, n) fmemcpy(d,s,n) #define GLOBAL extern #define NAMEMAX MAX_CDSPATH /* Maximum path for CDS */ #define PARSE_MAX MAX_CDSPATH /* maximum # of bytes in path */ diff --git a/kernel/inithma.c b/kernel/inithma.c index d9061224..3f5d9a83 100644 --- a/kernel/inithma.c +++ b/kernel/inithma.c @@ -460,42 +460,6 @@ void MoveKernel(unsigned NewKernelSegment) } } - { - struct initRelocationTable { - UBYTE callNear; - UWORD callOffset; - UBYTE jmpFar; - UWORD jmpOffset; - UWORD jmpSegment; - }; - extern struct initRelocationTable - ASM _HMAinitRelocationTableStart[], ASM _HMAinitRelocationTableEnd[]; - struct initRelocationTable *rp; - - /* verify, that all entries are valid */ - - for (rp = _HMAinitRelocationTableStart; - rp < _HMAinitRelocationTableEnd; rp++) - { - if (rp->callNear != 0xe8 || /* call NEAR */ - rp->jmpFar != 0xea || /* jmp FAR */ - rp->jmpSegment != CurrentKernelSegment || /* will only relocate HMA_TEXT */ - 0) - { - printf("illegal init relocation entry # %d\n", - rp - _HMAinitRelocationTableStart); - goto errorReturn; - } - } - - /* OK, all valid, go to relocate */ - - for (rp = _HMAinitRelocationTableStart; - rp < _HMAinitRelocationTableEnd; rp++) - { - rp->jmpSegment = NewKernelSegment; - } - } CurrentKernelSegment = NewKernelSegment; return; diff --git a/kernel/inthndlr.c b/kernel/inthndlr.c index 73744bc3..882968f7 100644 --- a/kernel/inthndlr.c +++ b/kernel/inthndlr.c @@ -1119,7 +1119,7 @@ VOID ASMCFUNC int21_service(iregs FAR * r) break; case 0x03: - if (uppermem_root) /* always error if not exists */ + if (uppermem_root != 0xffff) /* always error if not exists */ { DosUmbLink(r->BL); break; diff --git a/kernel/kernel.asm b/kernel/kernel.asm index f46f87c4..02969ebb 100644 --- a/kernel/kernel.asm +++ b/kernel/kernel.asm @@ -343,7 +343,7 @@ _uppermem_link db 0 ; 0063 upper memory link flag _min_pars dw 0 ; 0064 minimum paragraphs of memory ; required by program being EXECed global _uppermem_root -_uppermem_root dw 0 ; 0066 dmd_upper_root (usually 9fff) +_uppermem_root dw 0ffffh ; 0066 dmd_upper_root (usually 9fff) _last_para dw 0 ; 0068 para of last mem search SysVarEnd: @@ -623,8 +623,6 @@ segment IB_E __ib_end: ;; do not clear the other init BSS variables + STACK: too late. - retoff resw 1 ; return offset to jump to from HMA_TEXT - ; kernel startup stack global init_tos resw 512 @@ -708,10 +706,6 @@ __U4D: LDIVMODU %endif -init_ret_np: push ds - push word [retoff] - retf ; return from init_calls. - ;End of HMA segment segment HMA_TEXT_END global __HMATextEnd @@ -748,70 +742,6 @@ _DGROUP_: dw DGROUP -segment INIT_TEXT - - call far initforceEnableA20 ; first enable A20 or not -manip_stack_A20: - pop dx ; get last ret address - pop word [retoff] ; get near ret address of init caller - mov ax, init_ret_np ; new init caller ret address - push ax - jmp dx ; and back to the relocation entry - - global __HMAinitRelocationTableStart -__HMAinitRelocationTableStart: - - extern _execrh - global _reloc_call_execrh -_reloc_call_execrh: - call manip_stack_A20 - jmp far _execrh - - extern _fmemcpy - global _reloc_call_fmemcpy -_reloc_call_fmemcpy: - call manip_stack_A20 - jmp far _fmemcpy - - extern _strcpy - global _reloc_call_strcpy -_reloc_call_strcpy: - call manip_stack_A20 - jmp far _strcpy - - extern _fstrncpy - global _reloc_call_fstrncpy -_reloc_call_fstrncpy: - call manip_stack_A20 - jmp far _fstrncpy - - extern _strlen - global _reloc_call_strlen -_reloc_call_strlen: - call manip_stack_A20 - jmp far _strlen - - extern _fstrlen - global _reloc_call_fstrlen -_reloc_call_fstrlen: - call manip_stack_A20 - jmp far _fstrlen - - extern _fmemset - global _reloc_call_fmemset -_reloc_call_fmemset: - call manip_stack_A20 - jmp far _fmemset - - extern _memset - global _reloc_call_memset -_reloc_call_memset: - call manip_stack_A20 - jmp far _memset - - global __HMAinitRelocationTableEnd -__HMAinitRelocationTableEnd: - segment _TEXT global _initforceEnableA20 diff --git a/kernel/main.c b/kernel/main.c index 88cd488a..f4e85716 100644 --- a/kernel/main.c +++ b/kernel/main.c @@ -107,6 +107,33 @@ __segment DosTextSeg = 0; #endif +/* little functions - could be ASM but does not really matter in this context */ +void memset(void *s, int c, unsigned n) +{ + char *t = s; + while(n--) *t++ = c; +} + +void fmemset(void far *s, int c, unsigned n) +{ + char far *t = s; + while(n--) *t++ = c; +} + +void strcpy(char *dest, const char *src) +{ + while(*src) + *dest++ = *src++; + *dest = '\0'; +} + +void fmemcpy(void far *dest, const void far *src, unsigned n) +{ + char far *d = dest; + const char far *s = src; + while(n--) *d++ = *s++; +} + VOID ASMCFUNC FreeDOSmain(void) { #ifdef _MSC_VER @@ -408,16 +435,16 @@ STATIC void kernel() /* process 0 */ /* Execute command.com /P from the drive we just booted from */ - fstrncpy(Cmd.ctBuffer, Config.cfgInitTail, - sizeof(Config.cfgInitTail) - 1); + memset(Cmd.ctBuffer, 0, sizeof(Cmd.ctBuffer)); + fmemcpy(Cmd.ctBuffer, Config.cfgInitTail, sizeof(Config.cfgInitTail)); - for (Cmd.ctCount = 0; Cmd.ctCount < 127; Cmd.ctCount++) + for (Cmd.ctCount = 0; Cmd.ctCount < sizeof(Cmd.ctBuffer); Cmd.ctCount++) if (Cmd.ctBuffer[Cmd.ctCount] == '\r') break; /* if stepping CONFIG.SYS (F5/F8), tell COMMAND.COM about it */ - if (Cmd.ctCount < 127 - 3) + if (Cmd.ctCount < sizeof(Cmd.ctBuffer) - 3) { extern int singleStep; extern int SkipAllConfig; @@ -433,14 +460,14 @@ STATIC void kernel() { /* insert /D, /Y as first argument */ - int cmdEnd, i, slen = strlen(insertString); + int cmdEnd, i, slen = 3; /* strlen(insertString); */ - for (cmdEnd = 0; cmdEnd < 127; cmdEnd++) + for (cmdEnd = 0; cmdEnd < sizeof(Cmd.ctBuffer); cmdEnd++) { if (Cmd.ctBuffer[cmdEnd] == ' ' || Cmd.ctBuffer[cmdEnd] == '\t' || Cmd.ctBuffer[cmdEnd] == '\r') { - for (i = 127 - slen; i >= cmdEnd; i--) + for (i = sizeof(Cmd.ctBuffer) - slen - 1; i >= cmdEnd; i--) Cmd.ctBuffer[i + slen] = Cmd.ctBuffer[i]; fmemcpy(&Cmd.ctBuffer[cmdEnd], insertString, slen); diff --git a/kernel/memmgr.c b/kernel/memmgr.c index ab8b795b..f39f7c91 100644 --- a/kernel/memmgr.c +++ b/kernel/memmgr.c @@ -152,7 +152,7 @@ COUNT DosMemAlloc(UWORD size, COUNT mode, seg FAR * para, Hack to the Umb Region direct for now. Save time and program space. */ if ((mode != LARGEST) && (mode & (FIRST_FIT_UO | FIRST_FIT_U)) && - uppermem_link && uppermem_root) + uppermem_link && uppermem_root != 0xffff) p = para2far(uppermem_root); /* Search through memory blocks */ @@ -217,7 +217,7 @@ COUNT DosMemAlloc(UWORD size, COUNT mode, seg FAR * para, if (!foundSeg || !foundSeg->m_size) { /* no block to fullfill the request */ if ((mode != LARGEST) && (mode & FIRST_FIT_U) && - uppermem_link && uppermem_root) + uppermem_link && uppermem_root != 0xffff) { mode &= ~FIRST_FIT_U; goto searchAgain; @@ -290,7 +290,7 @@ COUNT DosMemLargest(UWORD FAR * size) /* Initialize */ p = ((mem_access_mode & (FIRST_FIT_UO | FIRST_FIT_U)) && uppermem_link - && uppermem_root) ? para2far(uppermem_root) : para2far(first_mcb); + && uppermem_root != 0xffff) ? para2far(uppermem_root) : para2far(first_mcb); /* Cycle through the whole MCB chain to find the largest unused area. Join all unused areas together. */ @@ -569,7 +569,7 @@ VOID DosUmbLink(BYTE n) REG mcb FAR *p; REG mcb FAR *q; - if (uppermem_root == 0) + if (uppermem_root == 0xffff) return; q = p = para2far(first_mcb); diff --git a/kernel/prf.c b/kernel/prf.c index aa978fbe..fa6c36b4 100644 --- a/kernel/prf.c +++ b/kernel/prf.c @@ -41,7 +41,7 @@ static char buff[MAX_BUFSIZE]; #endif #ifdef _INIT -#define fstrlen reloc_call_fstrlen +#define fstrlen init_fstrlen #define handle_char init_handle_char #define put_console init_put_console #define ltob init_ltob @@ -53,8 +53,6 @@ static char buff[MAX_BUFSIZE]; #define hexDigits init_hexDigits #endif -COUNT ASMCFUNC fstrlen(BYTE FAR * s); /* don't want globals.h, sorry */ - #ifdef VERSION_STRINGS static BYTE *prfRcsId = "$Id$"; @@ -71,7 +69,7 @@ WORD CDECL printf(CONST BYTE * fmt, ...); /* The following is user supplied and must match the following prototype */ VOID cso(COUNT); -#ifdef FORSYS +#if defined(FORSYS) || defined(_INIT) COUNT fstrlen(BYTE FAR * s) /* don't want globals.h, sorry */ { int i = 0; @@ -81,6 +79,8 @@ COUNT fstrlen(BYTE FAR * s) /* don't want globals.h, sorry */ return i; } +#else +COUNT ASMCFUNC fstrlen(BYTE FAR * s); /* don't want globals.h, sorry */ #endif /* special console output routine */ diff --git a/sys/fdkrncfg.c b/sys/fdkrncfg.c index d7541fea..e75f7ef3 100644 --- a/sys/fdkrncfg.c +++ b/sys/fdkrncfg.c @@ -43,6 +43,7 @@ unsigned long lseek(int fildes, unsigned long offset, int whence); #else #include +#include #endif #define FAR far From 9d94f57f47157692a5ebd6ff56ddd59b7434384a Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sat, 9 Feb 2002 01:02:11 +0000 Subject: [PATCH 122/671] last kernel 2026 final changes git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@349 6ac86273-5f31-0410-b378-82cca8765d1b --- sys/fdkrncfg.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sys/fdkrncfg.c b/sys/fdkrncfg.c index e75f7ef3..4dfdbaf8 100644 --- a/sys/fdkrncfg.c +++ b/sys/fdkrncfg.c @@ -24,8 +24,8 @@ char KERNEL[] = "KERNEL.SYS"; #include #include "portab.h" -extern WORD CDECL printf(CONST BYTE * fmt, ...); -extern WORD CDECL sprintf(BYTE * buff, CONST BYTE * fmt, ...); +extern int CDECL printf(CONST BYTE * fmt, ...); +extern int CDECL sprintf(BYTE * buff, CONST BYTE * fmt, ...); #ifdef __WATCOMC__ #define close _dos_close From 251fa291819ee15e299d6d7df7171ace5909ee34 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sat, 9 Feb 2002 15:39:35 +0000 Subject: [PATCH 123/671] Some small post 2026 fixes - fix SYS, FCBs and redirector git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@351 6ac86273-5f31-0410-b378-82cca8765d1b --- docs/history.txt | 6 ++++++ kernel/dosfns.c | 2 +- kernel/fcbfns.c | 2 +- kernel/int2f.asm | 12 ++++++------ sys/sys.c | 4 ++-- 5 files changed, 16 insertions(+), 10 deletions(-) diff --git a/docs/history.txt b/docs/history.txt index 9530274b..dde2afba 100644 --- a/docs/history.txt +++ b/docs/history.txt @@ -1,3 +1,9 @@ ++ Changes Martin + * fixed SYS for non-Watcom compilers ++ Changes Bart + * FCB and network redirector fixes + (FCBOpen was broken; it appears that clearing CF before calling + the redirector is safer then setting CF) 2002 Feb 9 - Build 2026 -------- Bart Oldeman (bart@dosemu.org) + Changes Tom diff --git a/kernel/dosfns.c b/kernel/dosfns.c index 0ea550d4..0109827a 100644 --- a/kernel/dosfns.c +++ b/kernel/dosfns.c @@ -861,7 +861,7 @@ COUNT DosOpenSft(BYTE * fname, COUNT mode) fmemset(sftp, 0, sizeof(sft)); sftp->sft_psp = cu_psp; sftp->sft_mode = mode; - OpenMode = (BYTE) mode; + mode = OpenMode = (BYTE) mode; /* check for a device */ dhp = IsDevice(fname); diff --git a/kernel/fcbfns.c b/kernel/fcbfns.c index 0cca2eb4..940669b3 100644 --- a/kernel/fcbfns.c +++ b/kernel/fcbfns.c @@ -488,7 +488,7 @@ BOOL FcbOpenCreate(xfcb FAR * lpXfcb, BOOL Create) lpFcb->fcb_rndm = 0; lpFcb->fcb_recsiz = 0; /* true for devices */ - if (sftp->sft_flags & SFT_FDEVICE) /* check for a device */ + if (!(sftp->sft_flags & SFT_FDEVICE)) /* check for a device */ { lpFcb->fcb_drive = FcbDrive; lpFcb->fcb_recsiz = 128; diff --git a/kernel/int2f.asm b/kernel/int2f.asm index 5f0cea4e..fac1a58e 100644 --- a/kernel/int2f.asm +++ b/kernel/int2f.asm @@ -291,7 +291,7 @@ call_int2f: int2f_call_push: push word [bp+8] ; very fakey, HaHa ;) int2f_call: - stc ; set to fail + clc ; set to succeed int 2fh pop bx jc no_clear_ax @@ -315,7 +315,7 @@ lseekeof: jmp int2f_call_push remote_getfattr: - stc ; set to fail + clc ; set to succeed int 2fh jc no_clear_ax jmp short no_neg_ax @@ -334,7 +334,7 @@ print_doredir: mov ds, [bp+18] push word [bp+16] ; very fakey, HaHa ;) - stc ; set to fail + clc ; set to succeed int 2fh pop bx pop ds @@ -342,7 +342,7 @@ print_doredir: jmp short clear_ax remote_getfree: - stc ; set to fail + clc ; set to succeed int 2fh jc no_clear_ax mov di,[bp+8] @@ -360,14 +360,14 @@ remote_printredir: qremote_fn: lds si,[bp+4] les di,[bp+8] - stc + clc int 2fh mov ax,0xffff jc no_neg_ax jmp short clear_ax remote_rw: mov cx, [bp+8] - stc ; set to fail + clc ; set to succeed int 2fh jc int2f_carry xor ax, ax diff --git a/sys/sys.c b/sys/sys.c index be66869f..6aef7034 100644 --- a/sys/sys.c +++ b/sys/sys.c @@ -380,7 +380,7 @@ int2526readwrite(int DosDrive, void *diskReadPacket, unsigned intno) union REGS regs; regs.h.al = (BYTE) DosDrive; - regs.x.bx = (short)&diskReadPacket; + regs.x.bx = (short)diskReadPacket; regs.x.cx = 0xffff; int86(intno, ®s, ®s); @@ -395,7 +395,7 @@ fat32readwrite(int DosDrive, void *diskReadPacket, unsigned intno) regs.x.ax = 0x7305; regs.h.dl = DosDrive + 1; - regs.x.bx = (short)&diskReadPacket; + regs.x.bx = (short)diskReadPacket; regs.x.cx = 0xffff; regs.x.si = intno - 0x25; int86(0x21, ®s, ®s); From b2496a6fbd194c6c0aede38efb51d03e3b61a955 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sat, 16 Feb 2002 19:20:20 +0000 Subject: [PATCH 124/671] kernel 2026a final changes (mainly FCB fixes) git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@353 6ac86273-5f31-0410-b378-82cca8765d1b --- docs/config.txt | 4 ++ docs/history.txt | 14 ++++- hdr/fat.h | 1 + hdr/version.h | 6 +- kernel/config.c | 2 +- kernel/dosfns.c | 150 +++++++++++++++++++--------------------------- kernel/fatdir.c | 3 +- kernel/fatfs.c | 38 ++++++------ kernel/fcbfns.c | 92 ++++++++++------------------ kernel/inthndlr.c | 8 +-- kernel/main.c | 39 ++++-------- kernel/proto.h | 31 +++++----- 12 files changed, 163 insertions(+), 225 deletions(-) diff --git a/docs/config.txt b/docs/config.txt index 88691924..d279ce01 100644 --- a/docs/config.txt +++ b/docs/config.txt @@ -57,6 +57,10 @@ MENUDEFAULT=0,1 ( configuration 0, wait 1 second) Although this is definitively worse then MSDOS menuing possibilities, IMHO it's better then nothing +the selected configuration can be determined in AUTOEXEC.BAT in the +environment variable CONFIG like + + if %CONFIG% == 0 echo configuration 0 selected thus my config.sys now looks like diff --git a/docs/history.txt b/docs/history.txt index dde2afba..bc3619a4 100644 --- a/docs/history.txt +++ b/docs/history.txt @@ -1,9 +1,17 @@ +2002 Feb 17 - Build 2026a +-------- Bart Oldeman (bart@dosemu.org) + Changes Martin * fixed SYS for non-Watcom compilers ++ Changes Tom + * set CONFIG environment variable to selected number of CONFIG.SYS + menu entry, for example for use in AUTOEXEC.BAT. + Changes Bart - * FCB and network redirector fixes - (FCBOpen was broken; it appears that clearing CF before calling - the redirector is safer then setting CF) + * fixed FCBOpen + * network redirector fixes ; it appears that clearing CF before calling + the redirector is safer than setting CF + * allow creating, renaming and deleting volume labels using FCBs + * fix renaming with wildcards using FCBs + * some dosfns.c and fcbfns.c clean-ups 2002 Feb 9 - Build 2026 -------- Bart Oldeman (bart@dosemu.org) + Changes Tom diff --git a/hdr/fat.h b/hdr/fat.h index 7ddf5927..97703f69 100644 --- a/hdr/fat.h +++ b/hdr/fat.h @@ -47,6 +47,7 @@ static BYTE *fat_hRcsId = #define D_DEVICE 0x40 /* device bit */ #define D_LFN (D_RDONLY | D_HIDDEN | D_SYSTEM | D_VOLID) +#define D_ALL (D_RDONLY | D_HIDDEN | D_SYSTEM | D_DIR | D_ARCHIVE) /* FAT file name constants */ #define FNAME_SIZE 8 diff --git a/hdr/version.h b/hdr/version.h index fc088498..b2dcf758 100644 --- a/hdr/version.h +++ b/hdr/version.h @@ -49,6 +49,6 @@ static BYTE *date_hRcsId = #define REVISION_MINOR 1 #define REVISION_SEQ 26 #define BUILD "2026" -#define SUB_BUILD "" -#define KERNEL_VERSION_STRING "1.1.26" /*#REVISION_MAJOR "." #REVISION_MINOR "." #REVISION_SEQ */ -#define KERNEL_BUILD_STRING "2026" /*#BUILD SUB_BUILD */ +#define SUB_BUILD "a" +#define KERNEL_VERSION_STRING "1.1.26a" /*#REVISION_MAJOR "." #REVISION_MINOR "." #REVISION_SEQ */ +#define KERNEL_BUILD_STRING "2026a" /*#BUILD SUB_BUILD */ diff --git a/kernel/config.c b/kernel/config.c index 7556830d..0c62c1d5 100644 --- a/kernel/config.c +++ b/kernel/config.c @@ -128,7 +128,7 @@ BYTE askThisSingleCommand = FALSE; /* ?device= device?= */ BYTE DontAskThisSingleCommand = FALSE; /* !files= */ COUNT MenuTimeout = -1; -BYTE MenuSelected = '2'; +BYTE MenuSelected = 0; BYTE MenuLine = 0; UCOUNT Menus = 0; diff --git a/kernel/dosfns.c b/kernel/dosfns.c index 0109827a..7a3abd11 100644 --- a/kernel/dosfns.c +++ b/kernel/dosfns.c @@ -37,7 +37,6 @@ static BYTE *dosfnsRcsId = COUNT get_free_hndl(VOID); sft FAR * get_free_sft(COUNT *); -BOOL cmatch(COUNT, COUNT, COUNT); f_node_ptr xlt_fd(COUNT); @@ -306,7 +305,7 @@ UCOUNT DosRead(COUNT hndl, UCOUNT n, BYTE FAR * bp, COUNT FAR * err) } #endif -UCOUNT DosWriteSft(sft FAR * s, UCOUNT n, BYTE FAR * bp, COUNT FAR * err) +UCOUNT DosWriteSft(sft FAR * s, UCOUNT n, const BYTE FAR * bp, COUNT FAR * err) { UCOUNT WriteCount; @@ -334,7 +333,7 @@ UCOUNT DosWriteSft(sft FAR * s, UCOUNT n, BYTE FAR * bp, COUNT FAR * err) save_dta = dta; lpCurSft = s; current_filepos = s->sft_posit; /* needed for MSCDEX */ - dta = bp; + dta = (BYTE FAR *)bp; WriteCount = remote_write(s, n, &rc); dta = save_dta; *err = rc; @@ -412,7 +411,7 @@ UCOUNT DosWriteSft(sft FAR * s, UCOUNT n, BYTE FAR * bp, COUNT FAR * err) rq.r_length = sizeof(request); rq.r_command = C_OUTPUT; rq.r_count = 1; - rq.r_trans = bp; + rq.r_trans = (BYTE FAR *)bp; rq.r_status = 0; execrh((request FAR *) & rq, s->sft_dev); if (!(rq.r_status & S_ERROR)) @@ -627,26 +626,27 @@ BYTE FAR *get_root(BYTE FAR * fname) return ++froot; } -/* Ascii only file name match routines */ -STATIC BOOL cmatch(COUNT s, COUNT d, COUNT mode) +/* initialize SFT fields (for open/creat) for character devices */ +STATIC void DeviceOpenSft(struct dhdr FAR *dhp, sft FAR *sftp) { - if (s >= 'a' && s <= 'z') - s -= 'a' - 'A'; - if (d >= 'a' && d <= 'z') - d -= 'a' - 'A'; - if (mode && s == '?' && (d >= 'A' && s <= 'Z')) - return TRUE; - return s == d; -} + int i; -BOOL fnmatch(BYTE FAR * s, BYTE FAR * d, COUNT n, COUNT mode) -{ - while (n--) - { - if (!cmatch(*s++, *d++, mode)) - return FALSE; - } - return TRUE; + sftp->sft_shroff = -1; /* /// Added for SHARE - Ron Cemer */ + sftp->sft_count += 1; + sftp->sft_flags = + ((dhp-> + dh_attr & ~SFT_MASK) & ~SFT_FSHARED) | SFT_FDEVICE | SFT_FEOF; + fmemcpy(sftp->sft_name, dhp->dh_name, FNAME_SIZE); + + /* pad with spaces */ + for (i = FNAME_SIZE + FEXT_SIZE - 1; sftp->sft_name[i] == '\0'; i--) + sftp->sft_name[i] = ' '; + /* and uppercase */ + DosUpFMem(sftp->sft_name, FNAME_SIZE + FEXT_SIZE); + + sftp->sft_dev = dhp; + sftp->sft_date = dos_getdate(); + sftp->sft_time = dos_gettime(); } COUNT DosCreatSft(BYTE * fname, COUNT attrib) @@ -657,13 +657,6 @@ COUNT DosCreatSft(BYTE * fname, COUNT attrib) WORD result; COUNT drive; - /* NEVER EVER allow directories to be created */ - attrib &= 0xff; - if (attrib & ~(D_RDONLY | D_HIDDEN | D_SYSTEM | D_ARCHIVE)) - { - return DE_ACCESS; - } - /* now get a free system file table entry */ if ((sftp = get_free_sft(&sft_idx)) == (sft FAR *) - 1) return DE_TOOMANY; @@ -674,21 +667,12 @@ COUNT DosCreatSft(BYTE * fname, COUNT attrib) sftp->sft_psp = cu_psp; sftp->sft_mode = SFT_MRDWR; sftp->sft_attrib = attrib; - sftp->sft_psp = cu_psp; /* check for a device */ dhp = IsDevice(fname); if (dhp) { - sftp->sft_count += 1; - sftp->sft_flags = - ((dhp-> - dh_attr & ~SFT_MASK) & ~SFT_FSHARED) | SFT_FDEVICE | SFT_FEOF; - fmemcpy(sftp->sft_name, (BYTE FAR *) SecPathName, - FNAME_SIZE + FEXT_SIZE); - sftp->sft_dev = dhp; - sftp->sft_date = dos_getdate(); - sftp->sft_time = dos_gettime(); + DeviceOpenSft(dhp, sftp); return sft_idx; } @@ -727,7 +711,7 @@ COUNT DosCreatSft(BYTE * fname, COUNT attrib) DosGetFile(fname, sftp->sft_name); dos_getftime(sftp->sft_status, (date FAR *) & sftp->sft_date, - (time FAR *) & sftp->sft_time); + (time FAR *) & sftp->sft_time); return sft_idx; } else @@ -748,6 +732,13 @@ COUNT DosCreat(BYTE FAR * fname, COUNT attrib) psp FAR *p = MK_FP(cu_psp, 0); COUNT sft_idx, hndl, result; + /* NEVER EVER allow directories to be created */ + attrib = (BYTE) attrib; + if (attrib & ~(D_RDONLY | D_HIDDEN | D_SYSTEM | D_ARCHIVE)) + { + return DE_ACCESS; + } + /* get a free handle */ if ((hndl = get_free_hndl()) < 0) return hndl; @@ -867,17 +858,7 @@ COUNT DosOpenSft(BYTE * fname, COUNT mode) dhp = IsDevice(fname); if (dhp) { - sftp->sft_shroff = -1; /* /// Added for SHARE - Ron Cemer */ - - sftp->sft_count += 1; - sftp->sft_flags = - ((dhp-> - dh_attr & ~SFT_MASK) & ~SFT_FSHARED) | SFT_FDEVICE | SFT_FEOF; - fmemcpy(sftp->sft_name, (BYTE FAR *) SecPathName, - FNAME_SIZE + FEXT_SIZE); - sftp->sft_dev = dhp; - sftp->sft_date = dos_getdate(); - sftp->sft_time = dos_gettime(); + DeviceOpenSft(dhp, sftp); return sft_idx; } @@ -1260,8 +1241,8 @@ COUNT DosChangeDir(BYTE FAR * s) Copy the path to the current directory structure. - Some redirectors do not write back to the CDS. - SHSUCdX needs this. jt + Some redirectors do not write back to the CDS. + SHSUCdX needs this. jt */ fstrcpy(current_ldt->cdsCurrentPath, PriPathName); if (PriPathName[7] == 0) @@ -1571,7 +1552,7 @@ UBYTE DosSelectDrv(UBYTE drv) return lastdrive; } -COUNT DosDelete(BYTE FAR * path) +COUNT DosDelete(BYTE FAR * path, int attrib) { COUNT result, drive; @@ -1597,11 +1578,11 @@ COUNT DosDelete(BYTE FAR * path) } else { - return dos_delete(PriPathName); + return dos_delete(PriPathName, attrib); } } -COUNT DosRenameTrue(BYTE * path1, BYTE * path2) +COUNT DosRenameTrue(BYTE * path1, BYTE * path2, int attrib) { COUNT drive1, drive2; @@ -1623,7 +1604,7 @@ COUNT DosRenameTrue(BYTE * path1, BYTE * path2) } else { - return dos_rename(PriPathName, SecPathName); + return dos_rename(PriPathName, SecPathName, attrib); } } @@ -1643,7 +1624,7 @@ COUNT DosRename(BYTE FAR * path1, BYTE FAR * path2) return result; } - return DosRenameTrue(PriPathName, SecPathName); + return DosRenameTrue(PriPathName, SecPathName, D_ALL); } COUNT DosMkdir(BYTE FAR * dir) @@ -1737,27 +1718,12 @@ COUNT DosLockUnlock(COUNT hndl, LONG pos, LONG len, COUNT unlock) * This seems to work well. */ +/* check for a device */ struct dhdr FAR *IsDevice(BYTE FAR * fname) { struct dhdr FAR *dhp; - BYTE FAR *froot; - WORD i; - BYTE tmpPathName[FNAME_SIZE + 1]; - - /* check for a device */ - froot = get_root(fname); - for (i = 0; i < FNAME_SIZE; i++) - { - if (*froot != '\0' && *froot != '.') - tmpPathName[i] = *froot++; - else - break; - } - - for (; i < FNAME_SIZE; i++) - tmpPathName[i] = ' '; - - tmpPathName[i] = 0; + char FAR *froot = get_root(fname); + int i; /* /// BUG!!! This is absolutely wrong. A filename of "NUL.LST" must be treated EXACTLY the same as a filename of "NUL". The existence or @@ -1775,24 +1741,28 @@ struct dhdr FAR *IsDevice(BYTE FAR * fname) /* BUGFIX: MSCD000<00> should be handled like MSCD000<20> TE */ - char dev_name_buff[FNAME_SIZE]; - - int namelen = fstrlen(dhp->dh_name); - - memset(dev_name_buff, ' ', FNAME_SIZE); - - fmemcpy(dev_name_buff, dhp->dh_name, min(namelen, FNAME_SIZE)); - - if (fnmatch - ((BYTE FAR *) tmpPathName, (BYTE FAR *) dev_name_buff, FNAME_SIZE, - FALSE)) + for (i = 0; i < FNAME_SIZE; i++) { - memcpy(SecPathName, tmpPathName, i + 1); - return dhp; + char c1 = froot[i]; + if (c1 == '.' || c1 == '\0') + { + /* check if remainder of device name consists of spaces or nulls */ + for (; i < FNAME_SIZE; i++) + { + char c2 = dhp->dh_name[i]; + if (c2 != ' ' && c2 != '\0') + break; + } + break; + } + if (DosUpFChar(c1) != DosUpFChar(dhp->dh_name[i])) + break; } + if (i == FNAME_SIZE) + return dhp; } - return (struct dhdr FAR *)0; + return NULL; } /* /// Added for SHARE. - Ron Cemer */ diff --git a/kernel/fatdir.c b/kernel/fatdir.c index a239069a..804f631e 100644 --- a/kernel/fatdir.c +++ b/kernel/fatdir.c @@ -517,7 +517,8 @@ COUNT dos_findfirst(UCOUNT attr, BYTE * name) while (dir_read(fnp) == 1) { /* Test the attribute and return first found */ - if ((fnp->f_dir.dir_attrib & ~(D_RDONLY | D_ARCHIVE)) == D_VOLID) + if ((fnp->f_dir.dir_attrib & ~(D_RDONLY | D_ARCHIVE)) == D_VOLID && + fnp->f_dir.dir_name[0] != DELETED) { dmp->dm_dircluster = fnp->f_dirstart; /* TE */ memcpy(&SearchDir, &fnp->f_dir, sizeof(struct dirent)); diff --git a/kernel/fatfs.c b/kernel/fatfs.c index 7e757d5d..05e851e6 100644 --- a/kernel/fatfs.c +++ b/kernel/fatfs.c @@ -40,7 +40,7 @@ BYTE *RcsId = "$Id$"; f_node_ptr xlt_fd(COUNT); COUNT xlt_fnp(f_node_ptr); f_node_ptr split_path(BYTE *, BYTE *, BYTE *); -BOOL find_fname(f_node_ptr, BYTE *, BYTE *); +BOOL find_fname(f_node_ptr, BYTE *, BYTE *, int); /* /// Added - Ron Cemer */ STATIC void merge_file_changes(f_node_ptr fnp, int collect); /* /// Added - Ron Cemer */ @@ -97,7 +97,7 @@ COUNT dos_open(BYTE * path, COUNT flag) /* Look for the file. If we can't find it, just return a not */ /* found error. */ - if (!find_fname(fnp, szFileName, szFileExt)) + if (!find_fname(fnp, szFileName, szFileExt, D_ALL)) { dir_close(fnp); return DE_FILENOTFND; @@ -277,7 +277,7 @@ f_node_ptr split_path(BYTE * path, BYTE * fname, BYTE * fext) return fnp; } -STATIC BOOL find_fname(f_node_ptr fnp, BYTE * fname, BYTE * fext) +STATIC BOOL find_fname(f_node_ptr fnp, BYTE * fname, BYTE * fext, int attr) { BOOL found = FALSE; @@ -290,7 +290,7 @@ STATIC BOOL find_fname(f_node_ptr fnp, BYTE * fname, BYTE * fext) if (fcmp(fname, (BYTE *) fnp->f_dir.dir_name, FNAME_SIZE) && fcmp(fext, (BYTE *) fnp->f_dir.dir_ext, FEXT_SIZE) - && ((fnp->f_dir.dir_attrib & D_VOLID) == 0)) + && (fnp->f_dir.dir_attrib & ~(D_RDONLY | D_ARCHIVE | attr)) == 0) { found = TRUE; break; @@ -417,7 +417,7 @@ STATIC void copy_file_changes(f_node_ptr src, f_node_ptr dst) dst->f_dir.dir_time = src->f_dir.dir_time; } -COUNT dos_creat(BYTE * path, COUNT attrib) +COUNT dos_creat(BYTE * path, int attrib) { REG f_node_ptr fnp; @@ -430,7 +430,7 @@ COUNT dos_creat(BYTE * path, COUNT attrib) /* Check that we don't have a duplicate name, so if we */ /* find one, truncate it. */ - if (find_fname(fnp, szFileName, szFileExt)) + if (find_fname(fnp, szFileName, szFileExt, D_ALL | attrib)) { /* The only permissable attribute is archive, */ /* check for any other bit set. If it is, give */ @@ -542,7 +542,7 @@ STATIC COUNT delete_dir_entry(f_node_ptr fnp) return SUCCESS; } -COUNT dos_delete(BYTE * path) +COUNT dos_delete(BYTE * path, int attrib) { REG f_node_ptr fnp; @@ -555,13 +555,13 @@ COUNT dos_delete(BYTE * path) /* Check that we don't have a duplicate name, so if we */ /* find one, it's an error. */ - if (find_fname(fnp, szFileName, szFileExt)) + if (find_fname(fnp, szFileName, szFileExt, attrib)) { - /* The only permissable attribute is archive, */ - /* TE +hidden + system */ - /* check for any other bit set. If it is, give */ - /* an access error. */ - if (fnp->f_dir.dir_attrib & ~(D_ARCHIVE | D_HIDDEN | D_SYSTEM)) + /* Do not delete directories or r/o files */ + /* lfn entries and volume labels are only found */ + /* by find_fname() if attrib is set to a */ + /* special value */ + if (fnp->f_dir.dir_attrib & (D_RDONLY | D_DIR)) { dir_close(fnp); return DE_ACCESS; @@ -599,7 +599,7 @@ COUNT dos_rmdir(BYTE * path) /* Check that we don't have a duplicate name, so if we */ /* find one, it's an error. */ - if (find_fname(fnp, szFileName, szFileExt)) + if (find_fname(fnp, szFileName, szFileExt, D_ALL)) { /* The only permissable attribute is directory, */ /* check for any other bit set. If it is, give */ @@ -668,7 +668,7 @@ COUNT dos_rmdir(BYTE * path) } } -COUNT dos_rename(BYTE * path1, BYTE * path2) +COUNT dos_rename(BYTE * path1, BYTE * path2, int attrib) { REG f_node_ptr fnp1; REG f_node_ptr fnp2; @@ -684,7 +684,7 @@ COUNT dos_rename(BYTE * path1, BYTE * path2) /* Check that we don't have a duplicate name, so if we find */ /* one, it's an error. */ - if (find_fname(fnp2, szFileName, szFileExt)) + if (find_fname(fnp2, szFileName, szFileExt, attrib)) { dir_close(fnp2); return DE_ACCESS; @@ -698,7 +698,7 @@ COUNT dos_rename(BYTE * path1, BYTE * path2) return DE_PATHNOTFND; } - if (!find_fname(fnp1, szFileName, szFileExt)) + if (!find_fname(fnp1, szFileName, szFileExt, attrib)) { /* No such file, return the error */ dir_close(fnp1); @@ -1101,7 +1101,7 @@ COUNT dos_mkdir(BYTE * dir) /* Check that we don't have a duplicate name, so if we */ /* find one, it's an error. */ - if (find_fname(fnp, szFileName, szFileExt)) + if (find_fname(fnp, szFileName, szFileExt, D_ALL)) { dir_close(fnp); return DE_ACCESS; @@ -1828,7 +1828,7 @@ STATIC COUNT dos_extend(f_node_ptr fnp) } /* Write block to disk */ -UCOUNT writeblock(COUNT fd, VOID FAR * buffer, UCOUNT count, COUNT * err) +UCOUNT writeblock(COUNT fd, const VOID FAR * buffer, UCOUNT count, COUNT * err) { REG f_node_ptr fnp; struct buffer FAR *bp; diff --git a/kernel/fcbfns.c b/kernel/fcbfns.c index 940669b3..e8f6730b 100644 --- a/kernel/fcbfns.c +++ b/kernel/fcbfns.c @@ -38,7 +38,6 @@ static BYTE *RcsId = #define FCB_ERR_NODATA 1 #define FCB_ERR_EOF 3 #define FCB_ERR_WRITE 1 -#define D_ALL D_NORMAL | D_RDONLY | D_HIDDEN | D_SYSTEM | D_DIR | D_ARCHIVE #ifdef PROTO fcb FAR *ExtFcbToFcb(xfcb FAR * lpExtFcb); @@ -82,7 +81,7 @@ VOID FatGetDrvData(UCOUNT drive, UCOUNT FAR * spc, UCOUNT FAR * bps, #define PARSE_RET_BADDRIVE 0xff #ifndef IPL -WORD FcbParseFname(int wTestMode, BYTE FAR ** lpFileName, fcb FAR * lpFcb) +WORD FcbParseFname(int wTestMode, const BYTE FAR ** lpFileName, fcb FAR * lpFcb) { COUNT nIndex; WORD wRetCodeName = FALSE, wRetCodeExt = FALSE; @@ -156,7 +155,7 @@ WORD FcbParseFname(int wTestMode, BYTE FAR ** lpFileName, fcb FAR * lpFcb) return (wRetCodeName | wRetCodeExt) ? PARSE_RET_WILD : PARSE_RET_NOWILD; } -BYTE FAR * ParseSkipWh(BYTE FAR * lpFileName) +const BYTE FAR * ParseSkipWh(const BYTE FAR * lpFileName) { while (*lpFileName == ' ' || *lpFileName == '\t') ++lpFileName; @@ -191,7 +190,7 @@ BOOL TestFieldSeps(BYTE FAR * lpFileName) } #endif -BYTE FAR * GetNameField(BYTE FAR * lpFileName, BYTE FAR * lpDestField, +const BYTE FAR * GetNameField(const BYTE FAR * lpFileName, BYTE FAR * lpDestField, COUNT nFieldSize, BOOL * pbWildCard) { COUNT nIndex = 0; @@ -466,7 +465,9 @@ BOOL FcbOpenCreate(xfcb FAR * lpXfcb, BOOL Create) if (Create) { - sft_idx = DosCreatSft(PriPathName, 0); + /* pass attribute without constraints (dangerous for directories) */ + int attr = (lpXfcb->xfcb_flag == 0xff ? lpXfcb->xfcb_attrib : 0); + sft_idx = DosCreatSft(PriPathName, attr); } else { @@ -559,21 +560,22 @@ BOOL FcbDelete(xfcb FAR * lpXfcb) } else { + int attr = (lpXfcb->xfcb_flag == 0xff ? lpXfcb->xfcb_attrib : D_ALL); BYTE FAR *lpOldDta = dta; dmatch Dmatch; dta = (BYTE FAR *) & Dmatch; - if (DosFindFirst - (D_ALL, - SecPathName[1] == ':' ? &SecPathName[2] : SecPathName) != SUCCESS) + if (DosFindFirst(attr, SecPathName) != SUCCESS) { dta = lpOldDta; return FALSE; } do { - truename(Dmatch.dm_name, SecPathName, FALSE); - if (DosDelete(SecPathName) != SUCCESS) + SecPathName[0] = 'A' + FcbDrive - 1; + SecPathName[1] = ':'; + strcpy(&SecPathName[2], Dmatch.dm_name); + if (DosDelete(SecPathName, attr) != SUCCESS) { dta = lpOldDta; return FALSE; @@ -592,7 +594,8 @@ BOOL FcbRename(xfcb FAR * lpXfcb) /* Build a traditional DOS file name */ lpRenameFcb = (rfcb FAR *) CommonFcbInit(lpXfcb, SecPathName, &FcbDrive); - + wAttr = (lpXfcb->xfcb_flag == 0xff ? lpXfcb->xfcb_attrib : D_ALL); + /* check for a device */ if (IsDevice(SecPathName)) { @@ -604,9 +607,7 @@ BOOL FcbRename(xfcb FAR * lpXfcb) dmatch Dmatch; dta = (BYTE FAR *) & Dmatch; - if (DosFindFirst - (D_ALL, - SecPathName[1] == ':' ? &SecPathName[2] : SecPathName) != SUCCESS) + if (DosFindFirst(wAttr, SecPathName) != SUCCESS) { dta = lpOldDta; return FALSE; @@ -615,65 +616,34 @@ BOOL FcbRename(xfcb FAR * lpXfcb) do { fcb LocalFcb; - BYTE *pToName, *pszFrom; - BYTE FAR *pFromPattern; - COUNT nIndex; - - /* First, expand the find match into fcb style */ - /* file name entry */ - /* Fill with blanks first */ - memset(LocalFcb.fcb_fname, ' ', FNAME_SIZE); - memset(LocalFcb.fcb_fext, ' ', FEXT_SIZE); - - /* next move in the file name while overwriting */ - /* the filler blanks */ - pszFrom = Dmatch.dm_name; - pToName = LocalFcb.fcb_fname; - for (nIndex = 0; nIndex < FNAME_SIZE; nIndex++) - { - if (*pszFrom != 0 && *pszFrom != '.') - *pToName++ = *pszFrom++; - else if (*pszFrom == '.') - { - ++pszFrom; - break; - } - else - break; - } - - if (*pszFrom != '\0') - { - pToName = LocalFcb.fcb_fext; - for (nIndex = 0; nIndex < FEXT_SIZE; nIndex++) - { - if (*pszFrom != '\0') - *pToName++ = *pszFrom++; - else - break; - } - } + BYTE *pToName; + const BYTE FAR *pFromPattern = Dmatch.dm_name; + int i; + FcbParseFname(0, &pFromPattern, &LocalFcb); /* Overlay the pattern, skipping '?' */ /* I'm cheating because this assumes that the */ /* struct alignments are on byte boundaries */ pToName = LocalFcb.fcb_fname; - for (pFromPattern = lpRenameFcb->renNewName, - nIndex = 0; nIndex < FNAME_SIZE + FEXT_SIZE; nIndex++) + pFromPattern = lpRenameFcb->renNewName; + for (i = 0; i < FNAME_SIZE + FEXT_SIZE; i++) { if (*pFromPattern != '?') - *pToName++ = *pFromPattern++; - else - ++pFromPattern; + *pToName = *pFromPattern; + pToName++; + pFromPattern++; } + SecPathName[0] = 'A' + FcbDrive - 1; + SecPathName[1] = ':'; + strcpy(&SecPathName[2], Dmatch.dm_name); + truename(SecPathName, PriPathName, FALSE); + /* now to build a dos name again */ - LocalFcb.fcb_drive = 0; + LocalFcb.fcb_drive = FcbDrive; FcbNameInit((fcb FAR *) & LocalFcb, SecPathName, &FcbDrive); - truename(Dmatch.dm_name, PriPathName, FALSE); - - if (DosRenameTrue(PriPathName, SecPathName) != SUCCESS) + if (DosRenameTrue(PriPathName, SecPathName, wAttr) != SUCCESS) { dta = lpOldDta; return FALSE; diff --git a/kernel/inthndlr.c b/kernel/inthndlr.c index 882968f7..0b6240c2 100644 --- a/kernel/inthndlr.c +++ b/kernel/inthndlr.c @@ -532,9 +532,7 @@ VOID ASMCFUNC int21_service(iregs FAR * r) /* Parse File Name */ case 0x29: { - BYTE FAR *lpFileName; - - lpFileName = MK_FP(r->DS, r->SI); + const BYTE FAR *lpFileName = MK_FP(r->DS, r->SI); r->AL = FcbParseFname(r->AL, &lpFileName, MK_FP(r->ES, r->DI)); r->DS = FP_SEG(lpFileName); r->SI = FP_OFF(lpFileName); @@ -820,7 +818,7 @@ VOID ASMCFUNC int21_service(iregs FAR * r) /* Dos Delete File */ case 0x41: - rc = DosDelete((BYTE FAR *) FP_DS_DX); + rc = DosDelete((BYTE FAR *) FP_DS_DX, D_ALL); if (rc < 0) goto error_exit; break; @@ -1416,7 +1414,7 @@ VOID ASMCFUNC int21_service(iregs FAR * r) CLEAR_CARRY_FLAG(); break; - /* Flush file buffer -- COMMIT FILE -- dummy function right now. */ + /* Flush file buffer -- COMMIT FILE. */ case 0x68: case 0x6a: if ((rc = DosCommit(r->BX)) < 0) diff --git a/kernel/main.c b/kernel/main.c index f4e85716..bdf0f950 100644 --- a/kernel/main.c +++ b/kernel/main.c @@ -393,43 +393,30 @@ STATIC VOID signon() STATIC void kernel() { -#if 0 - BYTE FAR *ep, *sp; -#endif exec_blk exb; CommandTail Cmd; int rc; -#ifndef KDB - static BYTE master_env[] = "PATH=.\0\0\0\0\0"; -/* static BYTE *path = "PATH=.";*/ -#endif + extern char MenuSelected; -#ifdef KDB - kdb(); -#else -#if 0 - /* create the master environment area */ + BYTE master_env[32]; + char *masterenv_ptr = master_env; - if (allocmem(0x2, &exb.exec.env_seg)) - init_fatal("cannot allocate master environment space"); + /* build the startup environment */ - /* populate it with the minimum environment */ - ++exb.exec.env_seg; - ep = MK_FP(exb.exec.env_seg, 0); + memset(master_env,0,sizeof(master_env)); - for (sp = path; *sp != 0;) - *ep++ = *sp++; + /* initial path setting. is this useful ?? */ + masterenv_ptr += sprintf(masterenv_ptr, "PATH=."); + + /* export the current selected config menu */ + if (MenuSelected) + { + masterenv_ptr += sprintf(masterenv_ptr, "CONFIG=%c", MenuSelected); + } - *ep++ = '\0'; - *ep++ = '\0'; - *((int FAR *)ep) = 0; - ep += sizeof(int); -#else exb.exec.env_seg = DOS_PSP + 8; fmemcpy(MK_FP(exb.exec.env_seg, 0), master_env, sizeof(master_env)); -#endif -#endif RootPsp = ~0; diff --git a/kernel/proto.h b/kernel/proto.h index 3eb8fa99..2c466840 100644 --- a/kernel/proto.h +++ b/kernel/proto.h @@ -67,7 +67,6 @@ sft FAR *get_sft(UCOUNT); /* dosfns.c */ BYTE FAR *get_root(BYTE FAR *); -BOOL fnmatch(BYTE FAR *, BYTE FAR *, COUNT, COUNT); BOOL check_break(void); UCOUNT GenericReadSft(sft far * sftp, UCOUNT n, BYTE FAR * bp, COUNT FAR * err, BOOL force_binary); @@ -76,7 +75,7 @@ COUNT SftSeek(sft FAR * sftp, LONG new_pos, COUNT mode); #define GenericRead(hndl, n, bp, err, t) GenericReadSft(get_sft(hndl), n, bp, err, t) #define DosRead(hndl, n, bp, err) GenericRead(hndl, n, bp, err, FALSE) #define DosReadSft(sftp, n, bp, err) GenericReadSft(sftp, n, bp, err, FALSE) -UCOUNT DosWriteSft(sft FAR * sftp, UCOUNT n, BYTE FAR * bp, +UCOUNT DosWriteSft(sft FAR * sftp, UCOUNT n, const BYTE FAR * bp, COUNT FAR * err); #define DosWrite(hndl, n, bp, err) DosWriteSft(get_sft(hndl), n, bp, err) COUNT DosSeek(COUNT hndl, LONG new_pos, COUNT mode, ULONG * set_pos); @@ -102,9 +101,9 @@ COUNT DosSetFtimeSft(WORD sft_idx, date dp, time tp); COUNT DosGetFattr(BYTE FAR * name); COUNT DosSetFattr(BYTE FAR * name, UWORD attrp); UBYTE DosSelectDrv(UBYTE drv); -COUNT DosDelete(BYTE FAR * path); +COUNT DosDelete(BYTE FAR * path, int attrib); COUNT DosRename(BYTE FAR * path1, BYTE FAR * path2); -COUNT DosRenameTrue(BYTE * path1, BYTE * path2); +COUNT DosRenameTrue(BYTE * path1, BYTE * path2, int attrib); COUNT DosMkdir(BYTE FAR * dir); COUNT DosRmdir(BYTE FAR * dir); struct dhdr FAR *IsDevice(BYTE FAR * FileName); @@ -145,10 +144,10 @@ BOOL fcmp_wild(BYTE FAR * s1, BYTE FAR * s2, COUNT n); VOID touc(BYTE * s, COUNT n); COUNT dos_close(COUNT fd); COUNT dos_commit(COUNT fd); -COUNT dos_creat(BYTE * path, COUNT attrib); -COUNT dos_delete(BYTE * path); +COUNT dos_creat(BYTE * path, int attrib); +COUNT dos_delete(BYTE * path, int attrib); COUNT dos_rmdir(BYTE * path); -COUNT dos_rename(BYTE * path1, BYTE * path2); +COUNT dos_rename(BYTE * path1, BYTE * path2, int attrib); date dos_getdate(void); time dos_gettime(void); COUNT dos_getftime(COUNT fd, date FAR * dp, time FAR * tp); @@ -160,9 +159,9 @@ COUNT dos_mkdir(BYTE * dir); BOOL last_link(f_node_ptr fnp); COUNT map_cluster(REG f_node_ptr fnp, COUNT mode); UCOUNT readblock(COUNT fd, VOID FAR * buffer, UCOUNT count, COUNT * err); -UCOUNT writeblock(COUNT fd, VOID FAR * buffer, UCOUNT count, COUNT * err); +UCOUNT writeblock(COUNT fd, const VOID FAR * buffer, UCOUNT count, COUNT * err); COUNT dos_read(COUNT fd, VOID FAR * buffer, UCOUNT count); -COUNT dos_write(COUNT fd, VOID FAR * buffer, UCOUNT count); +COUNT dos_write(COUNT fd, const VOID FAR * buffer, UCOUNT count); LONG dos_lseek(COUNT fd, LONG foffset, COUNT origin); CLUSTER dos_free(struct dpb FAR * dpbp); @@ -205,11 +204,11 @@ VOID DosCharOutput(COUNT c); VOID DosDisplayOutput(COUNT c); VOID FatGetDrvData(UCOUNT drive, UCOUNT FAR * spc, UCOUNT FAR * bps, UCOUNT FAR * nc, BYTE FAR ** mdp); -WORD FcbParseFname(int wTestMode, BYTE FAR ** lpFileName, fcb FAR * lpFcb); -BYTE FAR *ParseSkipWh(BYTE FAR * lpFileName); +WORD FcbParseFname(int wTestMode, const BYTE FAR ** lpFileName, fcb FAR * lpFcb); +const BYTE FAR *ParseSkipWh(const BYTE FAR * lpFileName); BOOL TestCmnSeps(BYTE FAR * lpFileName); BOOL TestFieldSeps(BYTE FAR * lpFileName); -BYTE FAR *GetNameField(BYTE FAR * lpFileName, BYTE FAR * lpDestField, +const BYTE FAR *GetNameField(const BYTE FAR * lpFileName, BYTE FAR * lpDestField, COUNT nFieldSize, BOOL * pbWildCard); typedef BOOL FcbFunc_t (xfcb FAR *, COUNT *, UCOUNT); FcbFunc_t FcbRead, FcbWrite; @@ -253,10 +252,10 @@ VOID DosUmbLink(BYTE n); VOID mcb_print(mcb FAR * mcbp); /* misc.c */ -VOID ASMCFUNC strcpy(REG BYTE * d, REG BYTE * s); -VOID ASMCFUNC fmemcpy(REG VOID FAR * d, REG VOID FAR * s, REG COUNT n); -VOID ASMCFUNC fstrcpy(REG BYTE FAR * d, REG BYTE FAR * s); -void ASMCFUNC memcpy(REG void *d, REG VOID * s, REG COUNT n); +VOID ASMCFUNC strcpy(REG BYTE * d, REG const BYTE * s); +VOID ASMCFUNC fmemcpy(REG VOID FAR * d, REG const VOID FAR * s, REG COUNT n); +VOID ASMCFUNC fstrcpy(REG BYTE FAR * d, REG const BYTE FAR * s); +void ASMCFUNC memcpy(REG void *d, REG const VOID * s, REG COUNT n); void ASMCFUNC fmemset(REG VOID FAR * s, REG int ch, REG COUNT n); void ASMCFUNC memset(REG VOID * s, REG int ch, REG COUNT n); From bbbd0ce42f0b358923d7b279c75fbaf713f95bed Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sun, 17 Feb 2002 10:39:35 +0000 Subject: [PATCH 125/671] * booting from hard disk now always sets the default drive to C:, not D: if booting from the second physical hard disk, etc (bug #1062). git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@354 6ac86273-5f31-0410-b378-82cca8765d1b --- docs/history.txt | 2 ++ kernel/kernel.asm | 2 +- kernel/main.c | 25 ++++++++++--------------- 3 files changed, 13 insertions(+), 16 deletions(-) diff --git a/docs/history.txt b/docs/history.txt index bc3619a4..1012007d 100644 --- a/docs/history.txt +++ b/docs/history.txt @@ -12,6 +12,8 @@ * allow creating, renaming and deleting volume labels using FCBs * fix renaming with wildcards using FCBs * some dosfns.c and fcbfns.c clean-ups + * booting from hard disk now always sets the default drive to C:, + not D: if booting from the second physical hard disk, etc (bug #1062). 2002 Feb 9 - Build 2026 -------- Bart Oldeman (bart@dosemu.org) + Changes Tom diff --git a/kernel/kernel.asm b/kernel/kernel.asm index 02969ebb..19a87c45 100644 --- a/kernel/kernel.asm +++ b/kernel/kernel.asm @@ -174,7 +174,7 @@ cont: ; inititalize api stacks for high water tests inc bl jns floppy - add bl,3-1-128 + mov bl,3 ; set to C: if hard disk floppy: mov byte [_BootDrive],bl ; tell where we came from ;!! int 11h diff --git a/kernel/main.c b/kernel/main.c index bdf0f950..671fcb12 100644 --- a/kernel/main.c +++ b/kernel/main.c @@ -151,26 +151,21 @@ VOID ASMCFUNC FreeDOSmain(void) */ if (fmemcmp(MK_FP(0x50,0xe0+2),"CONFIG",6) == 0) /* UPX */ - { - fmemcpy(&InitKernelConfig, MK_FP(0x50,0xe0+2), sizeof(InitKernelConfig)); + { + fmemcpy(&InitKernelConfig, MK_FP(0x50,0xe0+2), sizeof(InitKernelConfig)); - BootDrive = *(BYTE FAR *)MK_FP(0x50,0xe0); - - BootDrive ++; + BootDrive = *(BYTE FAR *)MK_FP(0x50,0xe0) + 1; if ((unsigned)BootDrive >= 0x80) - BootDrive += 3-1-128; + BootDrive = 3; /* C: */ - - *(DWORD FAR *)MK_FP(0x50,0xe0+2) = 0; - - } + *(DWORD FAR *)MK_FP(0x50,0xe0+2) = 0; + } else - { - - fmemcpy(&InitKernelConfig, &LowKernelConfig, sizeof(InitKernelConfig)); - } - + { + fmemcpy(&InitKernelConfig, &LowKernelConfig, sizeof(InitKernelConfig)); + } + setvec(0, int0_handler); /* zero divide */ setvec(1, empty_handler); /* single step */ setvec(3, empty_handler); /* debug breakpoint */ From 2098578b1b251f074722f77a5140a3d181196b29 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Wed, 8 May 2002 22:49:35 +0000 Subject: [PATCH 126/671] kernel 2026b changes git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@382 6ac86273-5f31-0410-b378-82cca8765d1b --- boot/boot.asm | 4 +- boot/boot32.asm | 2 +- drivers/rdpcclk.asm | 7 +- getmake.bat | 4 +- hdr/buffer.h | 2 +- hdr/process.h | 8 +- hdr/version.h | 6 +- kernel/config.c | 53 ++-- kernel/dosfns.c | 58 ++--- kernel/dsk.c | 29 ++- kernel/fatfs.c | 579 +++++++++++++++----------------------------- kernel/fattab.c | 93 +++---- kernel/fcbfns.c | 16 +- kernel/globals.h | 39 +-- kernel/initdisk.c | 15 +- kernel/initoem.c | 2 +- kernel/inthndlr.c | 5 +- kernel/kernel.asm | 4 +- kernel/main.c | 17 +- kernel/makefile | 38 +-- kernel/memmgr.c | 9 +- kernel/newstuff.c | 48 ++-- kernel/prf.c | 23 +- kernel/procsupt.asm | 2 +- kernel/proto.h | 12 +- kernel/sysclk.c | 317 ++++++++---------------- kernel/syspack.c | 87 ++++--- kernel/systime.c | 14 +- kernel/task.c | 9 +- mkfiles/watcom.mak | 11 +- sys/fdkrncfg.c | 1 + sys/sys.c | 3 +- utils/patchobj.c | 1 + 33 files changed, 600 insertions(+), 918 deletions(-) diff --git a/boot/boot.asm b/boot/boot.asm index 2bb35083..8ff7296f 100644 --- a/boot/boot.asm +++ b/boot/boot.asm @@ -206,7 +206,7 @@ cont: mov ds, ax mov [drive], dl ; BIOS passes drive number in DL call print - db "Loading FreeDOS...",13,10,"ROOT",0 + db "Loading FreeDOS ",0 %ifdef CALCPARAMS GETDRIVEPARMS @@ -370,7 +370,7 @@ boot_error: call print int 0x19 ; reboot the machine boot_success: call print - db " GO!",13,10,0 + db " GO! ",0 mov bl, [drive] jmp word LOADSEG:0 diff --git a/boot/boot32.asm b/boot/boot32.asm index ba827d6e..3bdc9b2d 100644 --- a/boot/boot32.asm +++ b/boot/boot32.asm @@ -99,7 +99,7 @@ cont: mov ds, ax mov [drive], dl ; BIOS passes drive number in DL call print - db "Loading FreeDOS...",13,10,0 + db "Loading FreeDOS ",0 ; FINDFILE: Searches for the file in the root directory. ; diff --git a/drivers/rdpcclk.asm b/drivers/rdpcclk.asm index ffb8d88c..8790a5d0 100644 --- a/drivers/rdpcclk.asm +++ b/drivers/rdpcclk.asm @@ -40,10 +40,6 @@ segment HMA_TEXT _ReadPCClock: xor ah,ah int 1ah - mov bx,sp - mov bx,[bx+2] - mov [bx],dx - mov [bx+2],cx extern _DaysSinceEpoch ; ; update days if necessary mov ah,0 @@ -51,6 +47,9 @@ _ReadPCClock: add word [_DaysSinceEpoch ],ax ; *some* BIOS's accumulate several days adc word [_DaysSinceEpoch+2],0 ; + mov ax,dx ; set return value + mov dx,cx + ret ; Log: rdpcclk.asm,v diff --git a/getmake.bat b/getmake.bat index ca53831e..2ee93383 100644 --- a/getmake.bat +++ b/getmake.bat @@ -4,7 +4,7 @@ @if \%COMPILER% == \TURBOCPP set MAKE=%TP1_BASE%\bin\make @if \%COMPILER% == \TC3 set MAKE=%TC3_BASE%\bin\make @if \%COMPILER% == \BC5 set MAKE=%BC5_BASE%\bin\make -@if \%COMPILER% == \WATCOM set MAKE=%WATCOM%\binw\wmake /ms -@if \%COMPILER% == \MSCL8 set MAKE=%MS_BASE%\nmake /nologo +@if \%COMPILER% == \WATCOM set MAKE=wmake /ms +@if \%COMPILER% == \MSCL8 set MAKE=%MS_BASE%\bin\nmake /nologo :make_set diff --git a/hdr/buffer.h b/hdr/buffer.h index 36c1ebe6..2cfe1adb 100644 --- a/hdr/buffer.h +++ b/hdr/buffer.h @@ -58,7 +58,7 @@ struct buffer { LONG _b_huge_blkno; /* DOS-C: actual block number if >= 0xffff */ } _b; #endif - BYTE b_buffer[BUFFERSIZE]; /* 512 byte sectors for now */ + UBYTE b_buffer[BUFFERSIZE]; /* 512 byte sectors for now */ }; #define b_dpbp _b._b_dpbp diff --git a/hdr/process.h b/hdr/process.h index 6a241a1d..33e6ec98 100644 --- a/hdr/process.h +++ b/hdr/process.h @@ -80,12 +80,12 @@ typedef struct { UBYTE FAR *ps_filetab; /* 34 open file table pointer */ VOID FAR *ps_prevpsp; /* 38 previous psp pointer */ BYTE FAR *ps_dta; /* 3c process dta address */ - BYTE ps_fill2[16]; - UBYTE ps_unix[3]; /* unix style call - 0xcd 0x21 0xcb */ - BYTE ps_fill3[9]; + BYTE ps_fill2[16]; /* 40 */ + UBYTE ps_unix[3]; /* 50 unix style call - 0xcd 0x21 0xcb */ + BYTE ps_fill3[9]; /* 53 */ union { struct { - fcb _ps_fcb1; /* first command line argument */ + fcb _ps_fcb1; /* 5c first command line argument */ } _u1; struct { BYTE fill4[16]; diff --git a/hdr/version.h b/hdr/version.h index b2dcf758..0f5340c5 100644 --- a/hdr/version.h +++ b/hdr/version.h @@ -49,6 +49,6 @@ static BYTE *date_hRcsId = #define REVISION_MINOR 1 #define REVISION_SEQ 26 #define BUILD "2026" -#define SUB_BUILD "a" -#define KERNEL_VERSION_STRING "1.1.26a" /*#REVISION_MAJOR "." #REVISION_MINOR "." #REVISION_SEQ */ -#define KERNEL_BUILD_STRING "2026a" /*#BUILD SUB_BUILD */ +#define SUB_BUILD "b" +#define KERNEL_VERSION_STRING "1.1.26b" /*#REVISION_MAJOR "." #REVISION_MINOR "." #REVISION_SEQ */ +#define KERNEL_BUILD_STRING "2026b" /*#BUILD SUB_BUILD */ diff --git a/kernel/config.c b/kernel/config.c index 0c62c1d5..769d1c67 100644 --- a/kernel/config.c +++ b/kernel/config.c @@ -128,8 +128,8 @@ BYTE askThisSingleCommand = FALSE; /* ?device= device?= */ BYTE DontAskThisSingleCommand = FALSE; /* !files= */ COUNT MenuTimeout = -1; -BYTE MenuSelected = 0; -BYTE MenuLine = 0; +BYTE MenuSelected = 0; +UCOUNT MenuLine = 0; UCOUNT Menus = 0; STATIC VOID zumcb_init(UCOUNT seg, UWORD size); @@ -633,7 +633,7 @@ VOID DoConfig(int pass) } close(nFileDesc); - + if (nPass == 0) { DoMenu(); @@ -703,20 +703,15 @@ STATIC BOOL SkipLine(char *pLine) { short key; - static char initialized = FALSE; - - if (!initialized) + if (InitKernelConfig.SkipConfigSeconds >= 0) { - initialized = TRUE; - - if (InitKernelConfig.SkipConfigSeconds < 0) - return FALSE; - if (InitKernelConfig.SkipConfigSeconds > 0) printf("Press F8 to trace or F5 to skip CONFIG.SYS/AUTOEXEC.BAT"); key = GetBiosKey(InitKernelConfig.SkipConfigSeconds); /* wait 2 seconds */ + + InitKernelConfig.SkipConfigSeconds = -1; if (key == 0x3f00) /* F5 */ { @@ -737,10 +732,10 @@ STATIC BOOL SkipLine(char *pLine) return TRUE; /* 1?device=CDROM.SYS */ - /* 2?device=OAKROM.SYS */ - /* 3?device=EMM386.EXE NOEMS */ - if (MenuLine != 0 && - MenuSelected != MenuLine) + /* 12?device=OAKROM.SYS */ + /* 123?device=EMM386.EXE NOEMS */ + if ( MenuLine != 0 && + (MenuLine & (1 << MenuSelected)) == 0) return TRUE; if (DontAskThisSingleCommand) /* !files=30 */ @@ -924,7 +919,7 @@ STATIC VOID Dosmem(BYTE * pLine) for (pTmp = szBuf; *pTmp != '\0'; pTmp++) *pTmp = toupper(*pTmp); - printf("DOS called with %s\n", szBuf); + /* printf("DOS called with %s\n", szBuf); */ for (pTmp = szBuf;;) { @@ -1295,14 +1290,22 @@ STATIC BYTE * scan(BYTE * s, BYTE * d) MenuLine = 0; - /* does the line start with "1?" */ + /* does the line start with "123?" */ - if (s[1] == '?' && s[0] >= '0' && s[0] <= '9') + if (isnum(s)) { - MenuLine = s[0]; - Menus |= 1 << (MenuLine - '0'); - s = skipwh(s+2); + unsigned numbers = 0; + for ( ; isnum(s); s++) + numbers |= 1 << (*s -'0'); + + if (*s == '?') + { + MenuLine = numbers; + Menus |= numbers; + s = skipwh(s+1); + } } + /* !dos=high,umb ?? */ if (*s == '!') @@ -1613,7 +1616,9 @@ STATIC VOID CfgMenu(BYTE * pLine) STATIC VOID DoMenu(void) { if (Menus == 0) - return; + return; + + InitKernelConfig.SkipConfigSeconds = -1; Menus |= 1 << 0; /* '0' Menu always allowed */ @@ -1667,7 +1672,7 @@ STATIC VOID DoMenu(void) if (key >= '0' && key <= '9') if (Menus & (1 << (key - '0'))) { - MenuSelected = key; break; + MenuSelected = key - '0'; break; } } printf("\n"); @@ -1688,7 +1693,7 @@ STATIC VOID CfgMenuDefault(BYTE * pLine) /* Format: STACKS = stacks [, stackSize] */ pLine = GetNumArg(pLine, &num); - MenuSelected = '0' + num; + MenuSelected = num; pLine = skipwh(pLine); if (*pLine == ',') diff --git a/kernel/dosfns.c b/kernel/dosfns.c index 7a3abd11..371297f1 100644 --- a/kernel/dosfns.c +++ b/kernel/dosfns.c @@ -269,8 +269,6 @@ UCOUNT GenericReadSft(sft FAR * s, UCOUNT n, BYTE FAR * bp, else /* a block read */ { - COUNT rc; - /* /// Added for SHARE - Ron Cemer */ if (IsShareInstalled()) { @@ -290,9 +288,9 @@ UCOUNT GenericReadSft(sft FAR * s, UCOUNT n, BYTE FAR * bp, } /* /// End of additions for SHARE - Ron Cemer */ - ReadCount = readblock(s->sft_status, bp, n, &rc); - *err = rc; - return (rc == SUCCESS ? ReadCount : 0); + ReadCount = rwblock(s->sft_status, bp, n, XFR_READ); + *err = SUCCESS; + return ReadCount; } *err = SUCCESS; return 0; @@ -445,8 +443,6 @@ UCOUNT DosWriteSft(sft FAR * s, UCOUNT n, const BYTE FAR * bp, COUNT FAR * err) else /* a block write */ { - COUNT rc; - /* /// Added for SHARE - Ron Cemer */ if (IsShareInstalled()) { @@ -466,20 +462,10 @@ UCOUNT DosWriteSft(sft FAR * s, UCOUNT n, const BYTE FAR * bp, COUNT FAR * err) } /* /// End of additions for SHARE - Ron Cemer */ - WriteCount = writeblock(s->sft_status, bp, n, &rc); + WriteCount = rwblock(s->sft_status, (BYTE FAR *)bp, n, XFR_WRITE); s->sft_size = dos_getcufsize(s->sft_status); -/* if (rc < SUCCESS) */ - if (rc == DE_ACCESS || /* -5 Access denied */ - rc == DE_INVLDHNDL) /* -6 Invalid handle */ - { - *err = rc; - return 0; - } - else - { - *err = SUCCESS; - return WriteCount; - } + *err = SUCCESS; + return WriteCount; } *err = SUCCESS; return 0; @@ -1041,20 +1027,26 @@ BOOL DosGetFree(UBYTE drive, UCOUNT FAR * spc, UCOUNT FAR * navc, if (cdsp->cdsFlags & CDSNETWDRV) { - if (*nc == 0xffff) - { - /* Undoc DOS says, its not supported for - network drives. so it's probably OK */ - /*printf("FatGetDrvData not yet supported over network drives\n"); */ + if (remote_getfree(cdsp, rg) != SUCCESS) return FALSE; - } - remote_getfree(cdsp, rg); + /* for int21/ah=1c: + Undoc DOS says, its not supported for + network drives. so it's probably OK */ + /* some programs such as RHIDE want it though and + the redirector can provide all info + - Bart, 2002 Apr 1 */ + + if (*nc != 0xffff) + { + *navc = (COUNT) rg[3]; + rg[0] &= 0xff; + /* zero media ID (high part) */ + } *spc = (COUNT) rg[0]; *nc = (COUNT) rg[1]; *bps = (COUNT) rg[2]; - *navc = (COUNT) rg[3]; return TRUE; } @@ -1187,6 +1179,15 @@ COUNT DosGetCuDir(UBYTE drive, BYTE FAR * s) current_ldt = &CDSp->cds_table[drive]; + if ((current_ldt->cdsFlags & CDSNETWDRV) == 0) + { + if (current_ldt->cdsDpb == 0) + return DE_INVLDDRV; + + if ((media_check(current_ldt->cdsDpb) < 0)) + return DE_INVLDDRV; + } + cp = ¤t_ldt->cdsCurrentPath[current_ldt->cdsJoinOffset]; if (*cp == '\0') s[0] = '\0'; @@ -1361,6 +1362,7 @@ COUNT DosFindNext(void) fmemset(dta, 0, sizeof(dmatch)); p = dta; dta = (BYTE FAR *) TempBuffer; + current_ldt = &CDSp->cds_table[((dmatch *) TempBuffer)->dm_drive]; rc = (((dmatch *) TempBuffer)->dm_drive & 0x80) ? remote_findnext((VOID FAR *) current_ldt) : dos_findnext(); diff --git a/kernel/dsk.c b/kernel/dsk.c index 7ee28160..67c958c7 100644 --- a/kernel/dsk.c +++ b/kernel/dsk.c @@ -114,14 +114,12 @@ ULONG dsk_lasttime = 0; STATIC VOID tmark(ddt *pddt) { - ReadPCClock(&pddt->ddt_fh.ddt_lasttime); + pddt->ddt_fh.ddt_lasttime = ReadPCClock(); } STATIC BOOL tdelay(ddt *pddt, ULONG ticks) { - ULONG now; - ReadPCClock(&now); - return now - pddt->ddt_fh.ddt_lasttime >= ticks; + return ReadPCClock() - pddt->ddt_fh.ddt_lasttime >= ticks; } #define N_PART 4 /* number of partitions per @@ -141,6 +139,7 @@ STATIC dsk_proc _dsk_init, mediachk, bldbpb, blockio, IoctlQueblk, Genblkdev, Getlogdev, Setlogdev, blk_Open, blk_Close, blk_Media, blk_noerr, blk_nondr, blk_error; +STATIC WORD getbpb(ddt * pddt); #ifdef PROTO STATIC WORD dskerr(COUNT); #else @@ -278,6 +277,16 @@ STATIC WORD mediachk(rqptr rp, ddt * pddt) else { rp->r_mcretcode = diskchange(pddt); + if (rp->r_mcretcode == M_DONT_KNOW) + { + /* don't know but can check serial number ... */ + ULONG serialno = pddt->ddt_serialno; + COUNT result = getbpb(pddt); + if (result != 0) + return (result); + if (serialno != pddt->ddt_serialno) + rp->r_mcretcode = M_CHANGED; + } } return S_DONE; } @@ -395,8 +404,7 @@ STATIC WORD getbpb(ddt * pddt) if (ret != 0) return (dskerr(ret)); - getword(&((((BYTE *) & DiskTransferBuffer[BT_BPB]))[0]), - &pbpbarray->bpb_nbyte); + pbpbarray->bpb_nbyte = getword(&DiskTransferBuffer[BT_BPB]); if (DiskTransferBuffer[0x1fe] != 0x55 || DiskTransferBuffer[0x1ff] != 0xaa || pbpbarray->bpb_nbyte != 512) @@ -426,23 +434,20 @@ STATIC WORD getbpb(ddt * pddt) if (pbpbarray->bpb_nfsect != 0) { /* FAT16/FAT12 boot sector */ - getlong(&((((BYTE *) & DiskTransferBuffer[0x27])[0])), - &pddt->ddt_serialno); + pddt->ddt_serialno = getlong(&DiskTransferBuffer[0x27]); memcpy(pddt->ddt_volume, &DiskTransferBuffer[0x2B], 11); memcpy(pddt->ddt_fstype, &DiskTransferBuffer[0x36], 8); } else { /* FAT32 boot sector */ - getlong(&((((BYTE *) & DiskTransferBuffer[0x43])[0])), - &pddt->ddt_serialno); + pddt->ddt_serialno = getlong(&DiskTransferBuffer[0x43]); memcpy(pddt->ddt_volume, &DiskTransferBuffer[0x47], 11); memcpy(pddt->ddt_fstype, &DiskTransferBuffer[0x52], 8); pbpbarray->bpb_ndirent = 512; } #else - getlong(&((((BYTE *) & DiskTransferBuffer[0x27])[0])), - &pddt->ddt_serialno); + pddt->ddt_serialno = getlong(&DiskTransferBuffer[0x27]); memcpy(pddt->ddt_volume, &DiskTransferBuffer[0x2B], 11); memcpy(pddt->ddt_fstype, &DiskTransferBuffer[0x36], 8); #endif diff --git a/kernel/fatfs.c b/kernel/fatfs.c index 05e851e6..c2b1228c 100644 --- a/kernel/fatfs.c +++ b/kernel/fatfs.c @@ -163,7 +163,6 @@ COUNT dos_close(COUNT fd) if (fnp->f_flags.f_dmod) { - fnp->f_dir.dir_attrib |= D_ARCHIVE; if (fnp->f_flags.f_ddate == FALSE) { fnp->f_dir.dir_time = dos_gettime(); @@ -279,25 +278,17 @@ f_node_ptr split_path(BYTE * path, BYTE * fname, BYTE * fext) STATIC BOOL find_fname(f_node_ptr fnp, BYTE * fname, BYTE * fext, int attr) { - BOOL found = FALSE; - while (dir_read(fnp) == 1) { - if (fnp->f_dir.dir_name[0] != '\0') + if (fnp->f_dir.dir_name[0] != DELETED + && fcmp(fname, (BYTE *) fnp->f_dir.dir_name, FNAME_SIZE) + && fcmp(fext, (BYTE *) fnp->f_dir.dir_ext, FEXT_SIZE) + && (fnp->f_dir.dir_attrib & ~(D_RDONLY | D_ARCHIVE | attr)) == 0) { - if (fnp->f_dir.dir_name[0] == DELETED) - continue; - - if (fcmp(fname, (BYTE *) fnp->f_dir.dir_name, FNAME_SIZE) - && fcmp(fext, (BYTE *) fnp->f_dir.dir_ext, FEXT_SIZE) - && (fnp->f_dir.dir_attrib & ~(D_RDONLY | D_ARCHIVE | attr)) == 0) - { - found = TRUE; - break; - } + return TRUE; } } - return found; + return FALSE; } /* Description. @@ -836,7 +827,6 @@ STATIC BOOL find_free(f_node_ptr fnp) /* */ date dos_getdate() { -#ifndef NOTIME BYTE WeekDay, Month, MonthDay; COUNT Year; date Date; @@ -848,12 +838,6 @@ date dos_getdate() (BYTE FAR *) & MonthDay, (COUNT FAR *) & Year); Date = DT_ENCODE(Month, MonthDay, Year - EPOCH_YEAR); return Date; - -#else - - return 0; - -#endif } /* */ @@ -861,7 +845,6 @@ date dos_getdate() /* */ time dos_gettime() { -#ifndef NOTIME BYTE Hour, Minute, Second, Hundredth; /* First - get the system time set by either the user */ @@ -870,9 +853,6 @@ time dos_gettime() (BYTE FAR *) & Minute, (BYTE FAR *) & Second, (BYTE FAR *) & Hundredth); return TM_ENCODE(Hour, Minute, Second / 2); -#else - return 0; -#endif } /* */ @@ -1391,7 +1371,6 @@ COUNT map_cluster(REG f_node_ptr fnp, COUNT mode) /* If there are no more free fat entries, then we are full! */ if (!first_fat(fnp)) { - dir_close(fnp); return DE_HNDLDSKFULL; } } @@ -1453,6 +1432,86 @@ COUNT map_cluster(REG f_node_ptr fnp, COUNT mode) return SUCCESS; } +/* extends a file from f_highwater to f_offset */ +/* Proper OS's write zeros in between, but DOS just adds */ +/* garbage sectors, and lets the caller do the zero filling */ +/* if you prefer you can have this enabled using */ +/* #define WRITEZEROS 1 */ +/* but because we want to be compatible, we don't do this by */ +/* default */ +STATIC COUNT dos_extend(f_node_ptr fnp) +{ +#ifdef WRITEZEROS + struct buffer FAR *bp; + UCOUNT xfr_cnt = 0; + /* The variable secsize will be used later. */ + UWORD secsize = fnp->f_dpb->dpb_secsize; + ULONG count; +#endif + + if (fnp->f_offset <= fnp->f_highwater) + return SUCCESS; + +#ifdef WRITEZEROS + count = fnp->f_offset - fnp->f_highwater; + fnp->f_offset = fnp->f_highwater; + while (count > 0) +#endif + { + if (map_cluster(fnp, XFR_WRITE) != SUCCESS) + return DE_HNDLDSKFULL; + +#ifdef WRITEZEROS + /* Compute the block within the cluster and the offset */ + /* within the block. */ + fnp->f_sector = (fnp->f_offset / secsize) & fnp->f_dpb->dpb_clsmask; + fnp->f_boff = fnp->f_offset % secsize; + +#ifdef DSK_DEBUG + printf("write %d links; dir offset %ld, cluster %d\n", + fnp->f_count, fnp->f_diroff, fnp->f_cluster); +#endif + + xfr_cnt = count < (ULONG) secsize - fnp->f_boff ? + (UWORD) count : secsize - fnp->f_boff; + + /* get a buffer to store the block in */ + if ((fnp->f_boff == 0) && (xfr_cnt == secsize)) + { + bp = getblockOver(clus2phys(fnp->f_cluster, fnp->f_dpb) + + fnp->f_sector, fnp->f_dpb->dpb_unit); + + } + else + { + bp = getblock(clus2phys(fnp->f_cluster, fnp->f_dpb) + fnp->f_sector, + fnp->f_dpb->dpb_unit); + } + if (bp == NULL) + { + return DE_BLKINVLD; + } + + /* set a block to zero */ + fmemset((BYTE FAR *) & bp->b_buffer[fnp->f_boff], 0, xfr_cnt); + bp->b_flag |= BFR_DIRTY | BFR_VALID; + + if (xfr_cnt == sizeof(bp->b_buffer)) /* probably not used later */ + { + bp->b_flag |= BFR_UNCACHE; + } + + /* update pointers and counters */ + count -= xfr_cnt; + fnp->f_offset += xfr_cnt; + fnp->f_dir.dir_size = fnp->f_offset; +#endif + fnp->f_highwater = fnp->f_offset; + merge_file_changes(fnp, FALSE); /* /// Added - Ron Cemer */ + } + return SUCCESS; +} + /* comments read optimization for large reads: read total clusters in one piece @@ -1517,8 +1576,10 @@ COUNT map_cluster(REG f_node_ptr fnp, COUNT mode) */ -/* Read block from disk */ -UCOUNT readblock(COUNT fd, VOID FAR * buffer, UCOUNT count, COUNT * err) +/* Read/write block from disk */ +/* checking for valid access was already done by the functions in + dosfns.c */ +UCOUNT rwblock(COUNT fd, VOID FAR * buffer, UCOUNT count, int mode) { REG f_node_ptr fnp; REG struct buffer FAR *bp; @@ -1528,10 +1589,10 @@ UCOUNT readblock(COUNT fd, VOID FAR * buffer, UCOUNT count, COUNT * err) UCOUNT to_xfer = count; ULONG currentblock; -#if defined( DEBUG ) && 0 +#if 0 /*DSK_DEBUG*/ if (bDumpRdWrParms) { - printf("readblock:fd %02x buffer %04x:%04x count %x\n", + printf("rwblock:fd %02x buffer %04x:%04x count %x\n", fd, FP_SEG(buffer), FP_OFF(buffer), count); } #endif @@ -1544,32 +1605,39 @@ UCOUNT readblock(COUNT fd, VOID FAR * buffer, UCOUNT count, COUNT * err) /* note: an invalid fd is indicated by a 0 return */ if (fnp == (f_node_ptr) 0 || fnp->f_count <= 0) { - *err = DE_INVLDHNDL; - return 0; - } - - /* Test that we are really about to do a data transfer. If the - count is zero, just exit. (Any read with a count of zero is a nop). */ - - /* NOTE: doing this up front saves a lot of headaches later. */ - if (count == 0) - { - *err = SUCCESS; return 0; } - /* Another test is to check for a seek past EOF */ -/* if (!fnp->f_flags.f_ddir && (fnp->f_offset >= fnp->f_dir.dir_size)) BUG :-< */ - if (!fnp->f_flags.f_ddir && (fnp->f_offset >= fnp->f_highwater)) + if (mode==XFR_WRITE) { - *err = SUCCESS; - return 0; + fnp->f_dir.dir_attrib |= D_ARCHIVE; + fnp->f_flags.f_dmod = TRUE; /* mark file as modified */ + fnp->f_flags.f_ddate = FALSE; /* set date not valid any more */ + + if (dos_extend(fnp) != SUCCESS) + return 0; } + + /* Test that we are really about to do a data transfer. If the */ + /* count is zero and the mode is XFR_READ, just exit. (Any */ + /* read with a count of zero is a nop). */ + /* */ + /* A write (mode is XFR_WRITE) is a special case. It sets the */ + /* file length to the current length (truncates it). */ + /* */ + /* NOTE: doing this up front saves a lot of headaches later. */ - /* test that we have a valid mode for this fnode */ - if (fnp->f_mode != RDONLY && fnp->f_mode != RDWR) + if (count == 0) { - *err = DE_INVLDACC; + /* NOTE: doing this up front made a lot of headaches later :-( TE */ + /* FAT allocation has to be extended if necessary TE */ + /* Now done in dos_extend BO */ + /* remove all the following allocated clusters in shrink_file */ + if (mode == XFR_WRITE) + { + fnp->f_highwater = fnp->f_offset; + shrink_file(fnp); + } return 0; } @@ -1585,16 +1653,15 @@ UCOUNT readblock(COUNT fd, VOID FAR * buffer, UCOUNT count, COUNT * err) { /* Do an EOF test and return whatever was transferred */ /* but only for regular files. */ - if (!(fnp->f_flags.f_ddir) && (fnp->f_offset >= fnp->f_highwater)) + if (mode == XFR_READ && !(fnp->f_flags.f_ddir) && (fnp->f_offset >= fnp->f_highwater)) { - *err = SUCCESS; return ret_cnt; } /* Position the file to the fnode's pointer position. This is */ /* done by updating the fnode's cluster, block (sector) and */ - /* byte offset so that read becomes a simple data move */ - /* out of the block data buffer. */ + /* byte offset so that read or write becomes a simple data move */ + /* into or out of the block data buffer. */ /* The more difficult scenario is the (more common) */ /* file offset case. Here, we need to take the fnode's */ @@ -1614,14 +1681,16 @@ UCOUNT readblock(COUNT fd, VOID FAR * buffer, UCOUNT count, COUNT * err) /* the blockio block buffering scheme to simplify the */ /* task. */ #ifdef DISPLAY_GETBLOCK - printf("readblock: "); + printf("rwblock: "); #endif - if (map_cluster(fnp, XFR_READ) != SUCCESS) + if (map_cluster(fnp, mode) != SUCCESS) { - *err = DE_SEEK; - dir_close(fnp); return ret_cnt; } + if (mode == XFR_WRITE) + { + merge_file_changes(fnp, FALSE); /* /// Added - Ron Cemer */ + } /* Compute the block within the cluster and the offset */ /* within the block. */ @@ -1636,55 +1705,57 @@ UCOUNT readblock(COUNT fd, VOID FAR * buffer, UCOUNT count, COUNT * err) fnp->f_boff == 0) /* complete sectors only */ { static ULONG startoffset; - UCOUNT sectors_to_read, sectors_wanted; + UCOUNT sectors_to_xfer, sectors_wanted; startoffset = fnp->f_offset; + sectors_wanted = to_xfer; /* avoid EOF problems */ - sectors_wanted = - ((UCOUNT) min(fnp->f_highwater - fnp->f_offset, to_xfer)) / - secsize; + if (mode == XFR_READ && to_xfer > fnp->f_highwater - fnp->f_offset) + sectors_wanted = (UCOUNT)(fnp->f_highwater - fnp->f_offset); + + sectors_wanted /= secsize; - if (sectors_wanted < 2) - goto normal_read; + if (sectors_wanted == 0) + goto normal_xfer; - sectors_to_read = fnp->f_dpb->dpb_clsmask + 1 - fnp->f_sector; + sectors_to_xfer = fnp->f_dpb->dpb_clsmask + 1 - fnp->f_sector; - sectors_to_read = min(sectors_to_read, sectors_wanted); + sectors_to_xfer = min(sectors_to_xfer, sectors_wanted); - fnp->f_offset += sectors_to_read * secsize; + fnp->f_offset += sectors_to_xfer * secsize; - while (sectors_to_read < sectors_wanted) + while (sectors_to_xfer < sectors_wanted) { - if (map_cluster(fnp, XFR_READ) != SUCCESS) + if (map_cluster(fnp, mode) != SUCCESS) break; if (clus2phys(fnp->f_cluster, fnp->f_dpb) != - currentblock + sectors_to_read) + currentblock + sectors_to_xfer) break; - sectors_to_read += fnp->f_dpb->dpb_clsmask + 1; + sectors_to_xfer += fnp->f_dpb->dpb_clsmask + 1; - sectors_to_read = min(sectors_to_read, sectors_wanted); + sectors_to_xfer = min(sectors_to_xfer, sectors_wanted); - fnp->f_offset = startoffset + sectors_to_read * secsize; + fnp->f_offset = startoffset + sectors_to_xfer * secsize; } - xfr_cnt = sectors_to_read * secsize; + xfr_cnt = sectors_to_xfer * secsize; /* avoid caching trouble */ DeleteBlockInBufferCache(currentblock, - currentblock + sectors_to_read - 1, + currentblock + sectors_to_xfer - 1, fnp->f_dpb->dpb_unit); if (dskxfer(fnp->f_dpb->dpb_unit, currentblock, - (VOID FAR *) buffer, sectors_to_read, DSKREAD)) + (VOID FAR *) buffer, sectors_to_xfer, + mode == XFR_READ ? DSKREAD : DSKWRITE)) { fnp->f_offset = startoffset; - *err = DE_BLKINVLD; return ret_cnt; } @@ -1692,24 +1763,23 @@ UCOUNT readblock(COUNT fd, VOID FAR * buffer, UCOUNT count, COUNT * err) } /* normal read: just the old, buffer = sector based read */ - normal_read: + normal_xfer: #ifdef DSK_DEBUG - printf("read %d links; dir offset %ld, cluster %lx\n", - fnp->f_count, fnp->f_diroff, fnp->f_cluster); + printf("r/w %d links; dir offset %ld, cluster %d, mode %x\n", + fnp->f_count, fnp->f_diroff, fnp->f_cluster, mode); #endif /* Get the block we need from cache */ bp = getblock(currentblock - /*clus2phys(fnp->f_cluster, fnp->f_dpb) + fnp->f_sector */ - , fnp->f_dpb->dpb_unit); - + /*clus2phys(fnp->f_cluster, fnp->f_dpb) + fnp->f_sector */ + , fnp->f_dpb->dpb_unit); + #ifdef DISPLAY_GETBLOCK - printf("DATA (readblock)\n"); + printf("DATA (rwblock)\n"); #endif if (bp == NULL) /* (struct buffer *)0 --> DS:0 !! */ { - *err = DE_BLKINVLD; return ret_cnt; } @@ -1718,19 +1788,30 @@ UCOUNT readblock(COUNT fd, VOID FAR * buffer, UCOUNT count, COUNT * err) /* requested transfer size, whichever is smaller. */ /* Then compare to what is left, since we can transfer */ /* a maximum of what is left. */ - if (fnp->f_flags.f_ddir) - xfr_cnt = min(to_xfer, secsize - fnp->f_boff); - else - xfr_cnt = (UWORD) min(min(to_xfer, secsize - fnp->f_boff), - fnp->f_highwater - fnp->f_offset); + xfr_cnt = min(to_xfer, secsize - fnp->f_boff); + if (!fnp->f_flags.f_ddir && mode == XFR_READ) + xfr_cnt = (UWORD) min(xfr_cnt, fnp->f_highwater - fnp->f_offset); - fmemcpy(buffer, &bp->b_buffer[fnp->f_boff], xfr_cnt); + /* transfer a block */ + /* Transfer size as either a full block size, or the */ + /* requested transfer size, whichever is smaller. */ + /* Then compare to what is left, since we can transfer */ + /* a maximum of what is left. */ + if (mode == XFR_WRITE) + { + fmemcpy(&bp->b_buffer[fnp->f_boff], buffer, xfr_cnt); + bp->b_flag |= BFR_DIRTY | BFR_VALID; + } + else + { + fmemcpy(buffer, &bp->b_buffer[fnp->f_boff], xfr_cnt); + } - /* complete buffer read ? + /* complete buffer transferred ? probably not reused later */ if (xfr_cnt == sizeof(bp->b_buffer) || - fnp->f_offset + xfr_cnt == fnp->f_highwater) + (mode == XFR_READ && fnp->f_offset + xfr_cnt == fnp->f_highwater)) { bp->b_flag |= BFR_UNCACHE; } @@ -1742,306 +1823,16 @@ UCOUNT readblock(COUNT fd, VOID FAR * buffer, UCOUNT count, COUNT * err) ret_cnt += xfr_cnt; to_xfer -= xfr_cnt; buffer = add_far((VOID FAR *) buffer, (ULONG) xfr_cnt); - } - *err = SUCCESS; - return ret_cnt; -} - -/* extends a file from f_highwater to f_offset */ -/* Proper OS's write zeros in between, but DOS just adds */ -/* garbage sectors, and lets the caller do the zero filling */ -/* if you prefer you can have this enabled using */ -/* #define WRITEZEROS 1 */ -/* but because we want to be compatible, we don't do this by */ -/* default */ -STATIC COUNT dos_extend(f_node_ptr fnp) -{ -#ifdef WRITEZEROS - struct buffer FAR *bp; - UCOUNT xfr_cnt = 0; - /* The variable secsize will be used later. */ - UWORD secsize = fnp->f_dpb->dpb_secsize; - ULONG count; -#endif - - if (fnp->f_offset <= fnp->f_highwater) - return SUCCESS; - -#ifdef WRITEZEROS - count = fnp->f_offset - fnp->f_highwater; - fnp->f_offset = fnp->f_highwater; - while (count > 0) -#endif - { - if (map_cluster(fnp, XFR_WRITE) != SUCCESS) - return DE_HNDLDSKFULL; - -#ifdef WRITEZEROS - /* Compute the block within the cluster and the offset */ - /* within the block. */ - fnp->f_sector = (fnp->f_offset / secsize) & fnp->f_dpb->dpb_clsmask; - fnp->f_boff = fnp->f_offset % secsize; - -#ifdef DSK_DEBUG - printf("write %d links; dir offset %ld, cluster %d\n", - fnp->f_count, fnp->f_diroff, fnp->f_cluster); -#endif - - xfr_cnt = count < (ULONG) secsize - fnp->f_boff ? - (UWORD) count : secsize - fnp->f_boff; - - /* get a buffer to store the block in */ - if ((fnp->f_boff == 0) && (xfr_cnt == secsize)) - { - bp = getblockOver(clus2phys(fnp->f_cluster, fnp->f_dpb) + - fnp->f_sector, fnp->f_dpb->dpb_unit); - - } - else + if (mode == XFR_WRITE) { - bp = getblock(clus2phys(fnp->f_cluster, fnp->f_dpb) + fnp->f_sector, - fnp->f_dpb->dpb_unit); - } - if (bp == NULL) - { - return DE_BLKINVLD; - } - - /* set a block to zero */ - fmemset((BYTE FAR *) & bp->b_buffer[fnp->f_boff], 0, xfr_cnt); - bp->b_flag |= BFR_DIRTY | BFR_VALID; - - if (xfr_cnt == sizeof(bp->b_buffer)) /* probably not used later */ - { - bp->b_flag |= BFR_UNCACHE; - } - - /* update pointers and counters */ - count -= xfr_cnt; - fnp->f_offset += xfr_cnt; - fnp->f_dir.dir_size = fnp->f_offset; -#endif - fnp->f_highwater = fnp->f_offset; - merge_file_changes(fnp, FALSE); /* /// Added - Ron Cemer */ - } - return SUCCESS; -} - -/* Write block to disk */ -UCOUNT writeblock(COUNT fd, const VOID FAR * buffer, UCOUNT count, COUNT * err) -{ - REG f_node_ptr fnp; - struct buffer FAR *bp; - UCOUNT xfr_cnt = 0; - UCOUNT ret_cnt = 0; - UWORD secsize; - UCOUNT to_xfer = count; - -#ifdef DEBUG - if (bDumpRdWrParms) - { - printf("writeblock: fd %02d buffer %04x:%04x count %d\n", - fd, (COUNT) FP_SEG(buffer), (COUNT) FP_OFF(buffer), count); - } -#endif - - /* Translate the fd into an fnode pointer, since all internal */ - /* operations are achieved through fnodes. */ - fnp = xlt_fd(fd); - - /* If the fd was invalid because it was out of range or the */ - /* requested file was not open, tell the caller and exit */ - /* note: an invalid fd is indicated by a 0 return */ - if (fnp == (f_node_ptr) 0 || fnp->f_count <= 0) - { - *err = DE_INVLDHNDL; - return 0; - } - - /* test that we have a valid mode for this fnode */ - if (fnp->f_mode != WRONLY && fnp->f_mode != RDWR) - { - *err = DE_INVLDACC; - return 0; - } - - fnp->f_flags.f_dmod = TRUE; /* mark file as modified */ - fnp->f_flags.f_ddate = FALSE; /* set date not valid any more */ - - /* extend file from fnp->f_highwater to fnp->f_offset */ - *err = dos_extend(fnp); - if (*err != SUCCESS) - return 0; - - /* Test that we are really about to do a data transfer. If the */ - /* count is zero and the mode is XFR_READ, just exit. (Any */ - /* read with a count of zero is a nop). */ - /* */ - /* A write (mode is XFR_WRITE) is a special case. It sets the */ - /* file length to the current length (truncates it). */ - /* */ - /* NOTE: doing this up front saves a lot of headaches later. */ - - if (count == 0) - { - /* NOTE: doing this up front made a lot of headaches later :-( TE */ - /* FAT allocation has to be extended if necessary TE */ - /* Now done in dos_extend BO */ - /* remove all the following allocated clusters in shrink_file */ - fnp->f_highwater = fnp->f_offset; - shrink_file(fnp); - return 0; - } - - /* The variable secsize will be used later. */ - secsize = fnp->f_dpb->dpb_secsize; - - /* Adjust the far pointer from user space to supervisor space */ - buffer = adjust_far((VOID FAR *) buffer); - - /* Do the data transfer. Use block transfer methods so that we */ - /* can utilize memory management in future DOS-C versions. */ - while (ret_cnt < count) - { - /* Position the file to the fnode's pointer position. This is */ - /* done by updating the fnode's cluster, block (sector) and */ - /* byte offset so that read or write becomes a simple data move */ - /* into or out of the block data buffer. */ - if (fnp->f_offset == 0l) - { - /* For the write case, a newly created file */ - /* will have a start cluster of FREE. If we're */ - /* doing a write and this is the first time */ - /* through, allocate a new cluster to the file. */ - if (checkdstart(fnp->f_dir, FREE)) - if (!first_fat(fnp)) /* get a free cluster */ - { /* error means disk full */ - dir_close(fnp); - *err = DE_HNDLDSKFULL; - return ret_cnt; - } - /* complete the common operations of */ - /* initializing to the starting cluster and */ - /* setting all offsets to zero. */ - fnp->f_cluster = fnp->f_flags.f_ddir ? fnp->f_dirstart : - getdstart(fnp->f_dir); - - fnp->f_cluster_offset = 0l; - fnp->f_back = LONG_LAST_CLUSTER; - fnp->f_sector = 0; - fnp->f_boff = 0; - merge_file_changes(fnp, FALSE); /* /// Added - Ron Cemer */ - } - - /* The more difficult scenario is the (more common) */ - /* file offset case. Here, we need to take the fnode's */ - /* offset pointer (f_offset) and translate it into a */ - /* relative cluster position, cluster block (sector) */ - /* offset (f_sector) and byte offset (f_boff). Once we */ - /* have this information, we need to translate the */ - /* relative cluster position into an absolute cluster */ - /* position (f_cluster). This is unfortunate because it */ - /* requires a linear search through the file's FAT */ - /* entries. It made sense when DOS was originally */ - /* designed as a simple floppy disk operating system */ - /* where the FAT was contained in core, but now */ - /* requires a search through the FAT blocks. */ - /* */ - /* The algorithm in this function takes advantage of */ - /* the blockio block buffering scheme to simplify the */ - /* task. */ - else - { -#ifdef DISPLAY_GETBLOCK - printf("writeblock: "); -#endif - if (map_cluster(fnp, XFR_WRITE) != SUCCESS) + if (fnp->f_offset > fnp->f_highwater) { - *err = DE_HNDLDSKFULL; - return ret_cnt; + fnp->f_highwater = fnp->f_offset; + fnp->f_dir.dir_size = fnp->f_highwater; } - merge_file_changes(fnp, FALSE); /* /// Added - Ron Cemer */ + merge_file_changes(fnp, FALSE); /* /// Added - Ron Cemer */ } - - /* Compute the block within the cluster and the offset */ - /* within the block. */ - fnp->f_sector = (fnp->f_offset / secsize) & fnp->f_dpb->dpb_clsmask; - fnp->f_boff = fnp->f_offset % secsize; - -#ifdef DSK_DEBUG - printf("write %d links; dir offset %ld, cluster %d\n", - fnp->f_count, fnp->f_diroff, fnp->f_cluster); -#endif - -/* /// Moved xfr_cnt calculation from below so we can - use it to help decide how to get the block: - read-modify-write using getblock() if we are only - going to write part of the block, or - write using getbuf() if we are going to write - the entire block. - - Ron Cemer */ - xfr_cnt = min(to_xfer, secsize - fnp->f_boff); - - /* get a buffer to store the block in */ - /* /// BUG!!! Added conditional to only use getbuf() if we're going - to write the entire block, which is faster because it does - not first read the block from disk. However, if we are - going to only write part of the block, we MUST use the - getblock() call, which first reads the block from disk. - Without this modification, the kernel was writing garbage - to the file when sequential writes were attempted at less - than the block size. This was causing problems with - piping and redirection in FreeCOM, as well as many other - potential problems. - - Ron Cemer */ - if ((fnp->f_boff == 0) && (xfr_cnt == secsize)) - { - bp = getblockOver(clus2phys(fnp->f_cluster, fnp->f_dpb) + - fnp->f_sector, fnp->f_dpb->dpb_unit); - - } - else - { - bp = getblock(clus2phys(fnp->f_cluster, fnp->f_dpb) + - fnp->f_sector, fnp->f_dpb->dpb_unit); - } - if (bp == NULL) - { - *err = DE_BLKINVLD; - return ret_cnt; - } - - /* transfer a block */ - /* Transfer size as either a full block size, or the */ - /* requested transfer size, whichever is smaller. */ - /* Then compare to what is left, since we can transfer */ - /* a maximum of what is left. */ -/* /// Moved xfr_cnt calculation to above getbuf/getblock calls so we can - use it to help decide which one to call. - - Ron Cemer - xfr_cnt = min(to_xfer, secsize - fnp->f_boff); -*/ - fmemcpy(&bp->b_buffer[fnp->f_boff], buffer, xfr_cnt); - bp->b_flag |= BFR_DIRTY | BFR_VALID; - - if (xfr_cnt == sizeof(bp->b_buffer)) /* probably not used later */ - { - bp->b_flag |= BFR_UNCACHE; - } - - /* update pointers and counters */ - ret_cnt += xfr_cnt; - to_xfer -= xfr_cnt; - fnp->f_offset += xfr_cnt; - buffer = add_far((VOID FAR *) buffer, (ULONG) xfr_cnt); - if (fnp->f_offset > fnp->f_highwater) - { - fnp->f_highwater = fnp->f_offset; - fnp->f_dir.dir_size = fnp->f_highwater; - } - merge_file_changes(fnp, FALSE); /* /// Added - Ron Cemer */ } - *err = SUCCESS; return ret_cnt; } @@ -2310,6 +2101,8 @@ VOID bpb_to_dpb(bpb FAR * bpbp, REG struct dpb FAR * dpbp) COUNT media_check(REG struct dpb FAR * dpbp) { + BYTE status; + /* First test if anyone has changed the removable media */ FOREVER { @@ -2343,7 +2136,8 @@ COUNT media_check(REG struct dpb FAR * dpbp) } } - switch (MediaReqHdr.r_mcretcode | dpbp->dpb_flags) + status = MediaReqHdr.r_mcretcode | dpbp->dpb_flags; + switch (status) { case M_NOT_CHANGED: /* It was definitely not changed, so ignore it */ @@ -2392,10 +2186,15 @@ COUNT media_check(REG struct dpb FAR * dpbp) } } #ifdef WITHFAT32 - bpb_to_dpb(MediaReqHdr.r_bpptr, dpbp, TRUE); + /* extend dpb only for internal or FAT32 devices */ + bpb_to_dpb(MediaReqHdr.r_bpptr, dpbp, + ISFAT32(dpbp) || FP_SEG(dpbp) == FP_SEG(&os_major)); #else bpb_to_dpb(MediaReqHdr.r_bpptr, dpbp); #endif + /* need to change to root directory if changed */ + if (status == M_CHANGED) + CDSp->cds_table[dpbp->dpb_unit].cdsCurrentPath[3] = '\0'; return SUCCESS; } } diff --git a/kernel/fattab.c b/kernel/fattab.c index 4f44015e..4586b6b9 100644 --- a/kernel/fattab.c +++ b/kernel/fattab.c @@ -34,21 +34,9 @@ static BYTE *RcsId = "$Id$"; #endif -#ifdef PROTO -UCOUNT link_fat12(struct dpb FAR *, CLUSTER, CLUSTER); -UCOUNT link_fat16(struct dpb FAR *, CLUSTER, CLUSTER); -UCOUNT link_fat32(struct dpb FAR *, CLUSTER, CLUSTER); -CLUSTER next_cl12(struct dpb FAR *, CLUSTER); -CLUSTER next_cl16(struct dpb FAR *, CLUSTER); -CLUSTER next_cl32(struct dpb FAR *, CLUSTER); -#else -UCOUNT link_fat12(); -UCOUNT link_fat16(); -UCOUNT link_fat32(); -CLUSTER next_cl12(); -CLUSTER next_cl16(); -CLUSTER next_cl32(); -#endif +STATIC unsigned link_fat12(struct dpb FAR *, unsigned, unsigned); +STATIC unsigned link_fat16(struct dpb FAR *, unsigned, unsigned); +STATIC unsigned link_fat32(struct dpb FAR *, CLUSTER, CLUSTER); /************************************************************************/ /* */ @@ -158,15 +146,15 @@ void write_fsinfo(struct dpb FAR * dpbp) /* 12 bytes are compressed to 9 bytes */ /* */ -UCOUNT link_fat(struct dpb FAR * dpbp, CLUSTER Cluster1, +unsigned link_fat(struct dpb FAR * dpbp, CLUSTER Cluster1, REG CLUSTER Cluster2) { - UCOUNT res; + unsigned res; if (ISFAT12(dpbp)) - res = link_fat12(dpbp, Cluster1, Cluster2); + res = link_fat12(dpbp, (unsigned)Cluster1, (unsigned)Cluster2); else if (ISFAT16(dpbp)) - res = link_fat16(dpbp, Cluster1, Cluster2); + res = link_fat16(dpbp, (unsigned)Cluster1, (unsigned)Cluster2); #ifdef WITHFAT32 else if (ISFAT32(dpbp)) res = link_fat32(dpbp, Cluster1, Cluster2); @@ -212,10 +200,10 @@ UCOUNT link_fat(struct dpb FAR * dpbp, CLUSTER Cluster1, } #ifdef WITHFAT32 -UCOUNT link_fat32(struct dpb FAR * dpbp, CLUSTER Cluster1, +STATIC unsigned link_fat32(struct dpb FAR * dpbp, CLUSTER Cluster1, CLUSTER Cluster2) { - UCOUNT idx; + unsigned idx; struct buffer FAR *bp; /* Get the block that this cluster is in */ @@ -230,7 +218,7 @@ UCOUNT link_fat32(struct dpb FAR * dpbp, CLUSTER Cluster1, /* Finally, put the word into the buffer and mark the */ /* buffer as dirty. */ - fputlong((DWORD FAR *) & Cluster2, (VOID FAR *) & (bp->b_buffer[idx])); + fputlong(&bp->b_buffer[idx], Cluster2); bp->b_flag |= BFR_DIRTY | BFR_VALID; /* Return successful. */ @@ -240,10 +228,10 @@ UCOUNT link_fat32(struct dpb FAR * dpbp, CLUSTER Cluster1, #endif -STATIC UCOUNT link_fat16(struct dpb FAR * dpbp, CLUSTER Cluster1, - CLUSTER Cluster2) +STATIC unsigned link_fat16(struct dpb FAR * dpbp, unsigned Cluster1, + unsigned Cluster2) { - UCOUNT idx; + unsigned idx; struct buffer FAR *bp; /* Get the block that this cluster is in */ @@ -254,11 +242,11 @@ STATIC UCOUNT link_fat16(struct dpb FAR * dpbp, CLUSTER Cluster1, /* form an index so that we can read the block as a */ /* byte array */ - idx = (UWORD) ((Cluster1 * SIZEOF_CLST16) % dpbp->dpb_secsize); + idx = (Cluster1 * SIZEOF_CLST16) % dpbp->dpb_secsize; /* Finally, put the word into the buffer and mark the */ /* buffer as dirty. */ - fputword((WORD FAR *) & Cluster2, (VOID FAR *) & (bp->b_buffer[idx])); + fputword(&bp->b_buffer[idx], Cluster2); bp->b_flag |= BFR_DIRTY | BFR_VALID; /* Return successful. */ @@ -266,11 +254,11 @@ STATIC UCOUNT link_fat16(struct dpb FAR * dpbp, CLUSTER Cluster1, return SUCCESS; } -STATIC UCOUNT link_fat12(struct dpb FAR * dpbp, CLUSTER Cluster1, - CLUSTER Cluster2) +STATIC unsigned link_fat12(struct dpb FAR * dpbp, unsigned Cluster1, + unsigned Cluster2) { REG UBYTE FAR *fbp0, FAR * fbp1; - UCOUNT idx; + unsigned idx; struct buffer FAR *bp, FAR * bp1; /* Get the block that this cluster is in */ @@ -280,12 +268,15 @@ STATIC UCOUNT link_fat12(struct dpb FAR * dpbp, CLUSTER Cluster1, /* form an index so that we can read the block as a */ /* byte array */ - idx = (UCOUNT) (((Cluster1 << 1) + Cluster1) >> 1) % dpbp->dpb_secsize; + idx = (unsigned) (((Cluster1 << 1) + Cluster1) >> 1) % dpbp->dpb_secsize; /* Test to see if the cluster straddles the block. If */ /* it does, get the next block and use both to form the */ /* the FAT word. Otherwise, just point to the next */ /* block. */ + fbp0 = &bp->b_buffer[idx]; + fbp1 = fbp0 + 1; + if (idx >= dpbp->dpb_secsize - 1) { bp1 = getFATblock(Cluster1 + 1, dpbp); @@ -294,11 +285,8 @@ STATIC UCOUNT link_fat12(struct dpb FAR * dpbp, CLUSTER Cluster1, bp1->b_flag |= BFR_DIRTY | BFR_VALID; - fbp1 = (UBYTE FAR *) & (bp1->b_buffer[0]); + fbp1 = &bp1->b_buffer[0]; } - else - fbp1 = (UBYTE FAR *) & (bp->b_buffer[idx + 1]); - fbp0 = (UBYTE FAR *) & (bp->b_buffer[idx]); bp->b_flag |= BFR_DIRTY | BFR_VALID; /* Now pack the value in */ @@ -338,16 +326,15 @@ CLUSTER next_cluster(struct dpb FAR * dpbp, CLUSTER ClusterNum) { union { UBYTE bytes[2]; - UCOUNT word; + unsigned word; } clusterbuff; - UCOUNT idx; + unsigned idx; /* form an index so that we can read the block as a */ /* byte array */ - idx = - (UCOUNT) (((ClusterNum << 1) + - ClusterNum) >> 1) % dpbp->dpb_secsize; + idx = ((((unsigned)ClusterNum << 1) + (unsigned)ClusterNum) >> 1) % + dpbp->dpb_secsize; clusterbuff.bytes[0] = bp->b_buffer[idx]; @@ -395,26 +382,13 @@ CLUSTER next_cluster(struct dpb FAR * dpbp, CLUSTER ClusterNum) { UWORD res; -#ifndef I86 - UCOUNT idx; - /* form an index so that we can read the block as a */ /* byte array */ - idx = (ClusterNum * SIZEOF_CLST16) % dpbp->dpb_secsize; - - /* Get the cluster number, */ + /* and get the cluster number */ - fgetword((VOID FAR *) & (bp->b_buffer[idx]), (WORD FAR *) & res); + res = fgetword(&bp->b_buffer[((unsigned)ClusterNum * SIZEOF_CLST16) % + dpbp->dpb_secsize]); -#else - /* this saves 2 WORDS of stack :-) */ - - res = - *(UWORD FAR *) & (bp-> - b_buffer[(UCOUNT) - ((ClusterNum * SIZEOF_CLST16) % - dpbp->dpb_secsize)]); -#endif if (res >= MASK16) return LONG_LAST_CLUSTER; if (res == BAD16) @@ -427,11 +401,8 @@ CLUSTER next_cluster(struct dpb FAR * dpbp, CLUSTER ClusterNum) { UDWORD res; - res = - *(UDWORD FAR *) & (bp-> - b_buffer[(UCOUNT) - ((ClusterNum * SIZEOF_CLST32) % - dpbp->dpb_secsize)]); + res = fgetlong(&bp->b_buffer[((unsigned)ClusterNum * SIZEOF_CLST32) % + dpbp->dpb_secsize]); if (res > LONG_BAD) return LONG_LAST_CLUSTER; diff --git a/kernel/fcbfns.c b/kernel/fcbfns.c index e8f6730b..08cbdc0b 100644 --- a/kernel/fcbfns.c +++ b/kernel/fcbfns.c @@ -62,13 +62,27 @@ static dmatch Dmatch; VOID FatGetDrvData(UCOUNT drive, UCOUNT FAR * spc, UCOUNT FAR * bps, UCOUNT FAR * nc, BYTE FAR ** mdp) { + static BYTE mdb; UCOUNT navc; /* get the data available from dpb */ *nc = 0xffff; /* pass 0xffff to skip free count */ if (DosGetFree((UBYTE) drive, spc, &navc, bps, nc)) + { + struct cds FAR *cdsp = + &CDSp->cds_table[(drive == 0 ? default_drive : drive - 1)]; /* Point to the media desctriptor for this drive */ - *mdp = (BYTE FAR *) & (CDSp->cds_table[drive].cdsDpb->dpb_mdb); + if (cdsp->cdsFlags & CDSNETWDRV) + { + mdb = *spc >> 8; + *mdp = &mdb; + *spc &= 0xff; + } + else + { + *mdp = (BYTE FAR *) & (cdsp->cdsDpb->dpb_mdb); + } + } } #define PARSE_SEP_STOP 0x01 diff --git a/kernel/globals.h b/kernel/globals.h index b780284c..2ab20132 100644 --- a/kernel/globals.h +++ b/kernel/globals.h @@ -399,7 +399,10 @@ VOID ASMCFUNC FAR CharMapSrvc(VOID); VOID ASMCFUNC FAR set_stack(VOID); VOID ASMCFUNC FAR restore_stack(VOID); /*VOID INRPT FAR handle_break(VOID); */ -VOID ASMCFUNC ReadPCClock(ULONG *); +BOOL ASMCFUNC ReadATClock(BYTE *, BYTE *, BYTE *, BYTE *); +ULONG ASMCFUNC ReadPCClock(VOID); +VOID ASMCFUNC WriteATClock(BYTE *, BYTE, BYTE, BYTE); +VOID ASMCFUNC WritePCClock(ULONG); BYTE FAR * ASMCFUNC device_end(VOID); COUNT ASMCFUNC kb_data(VOID); COUNT ASMCFUNC kb_input(VOID); @@ -427,25 +430,25 @@ COUNT con(); /* special word packing prototypes */ /* */ #ifdef NATIVE -#define getlong(vp, lp) (*(LONG *)(lp)=*(LONG *)(vp)) -#define getword(vp, wp) (*(WORD *)(wp)=*(WORD *)(vp)) -#define getbyte(vp, bp) (*(BYTE *)(bp)=*(BYTE *)(vp)) -#define fgetlong(vp, lp) (*(LONG FAR *)(lp)=*(LONG FAR *)(vp)) -#define fgetword(vp, wp) (*(WORD FAR *)(wp)=*(WORD FAR *)(vp)) -#define fgetbyte(vp, bp) (*(BYTE FAR *)(bp)=*(BYTE FAR *)(vp)) -#define fputlong(lp, vp) (*(LONG FAR *)(vp)=*(LONG FAR *)(lp)) -#define fputword(wp, vp) (*(WORD FAR *)(vp)=*(WORD FAR *)(wp)) -#define fputbyte(bp, vp) (*(BYTE FAR *)(vp)=*(BYTE FAR *)(bp)) +#define getlong(vp) (*(UDWORD *)(vp)) +#define getword(vp) (*(UWORD *)(vp)) +#define getbyte(vp) (*(UBYTE *)(vp)) +#define fgetlong(vp) (*(UDWORD FAR *)(vp)) +#define fgetword(vp) (*(UWORD FAR *)(vp)) +#define fgetbyte(vp) (*(UBYTE FAR *)(vp)) +#define fputlong(vp, l) (*(UDWORD FAR *)(vp)=l) +#define fputword(vp, w) (*(UWORD FAR *)(vp)=w) +#define fputbyte(vp, b) (*(UBYTE FAR *)(vp)=b) #else #ifdef PROTO -VOID getword(VOID *, WORD *); -VOID getbyte(VOID *, BYTE *); -VOID fgetlong(VOID FAR *, LONG FAR *); -VOID fgetword(VOID FAR *, WORD FAR *); -VOID fgetbyte(VOID FAR *, BYTE FAR *); -VOID fputlong(LONG FAR *, VOID FAR *); -VOID fputword(WORD FAR *, VOID FAR *); -VOID fputbyte(BYTE FAR *, VOID FAR *); +WORD getword(VOID *); +BYTE getbyte(VOID *); +LONG fgetlong(VOID FAR *); +WORD fgetword(VOID FAR *); +BYTE fgetbyte(VOID FAR *); +VOID fputlong(VOID FAR *, UDWORD); +VOID fputword(VOID FAR *, UWORD); +VOID fputbyte(VOID FAR *, UBYTE); #else VOID getword(); VOID getbyte(); diff --git a/kernel/initdisk.c b/kernel/initdisk.c index 177af566..7a90ee7b 100644 --- a/kernel/initdisk.c +++ b/kernel/initdisk.c @@ -42,6 +42,9 @@ extern COUNT DOSFAR nUnits; extern UWORD DOSFAR LBA_WRITE_VERIFY; +/* floppy parameter table, at 70:xxxx */ +extern unsigned char DOSTEXTFAR int1e_table[0xe]; + /* * Rev 1.0 13 May 2001 tom ehlert * Initial revision. @@ -611,7 +614,7 @@ void DosDefinePartition(struct DriveParamS *driveParam, { LBA_to_CHS(&chs, StartSector, driveParam); - printf("%c: HD%d", 'A' + nUnits, (driveParam->driveno & 0x7f) + 1); + printf("\r%c: HD%d", 'A' + nUnits, (driveParam->driveno & 0x7f) + 1); if (extendedPartNo) printf(" Ext:%d", extendedPartNo); @@ -1237,6 +1240,14 @@ void ReadAllPartitionTables(void) ddt FAR *pddt; static iregs regs; + /* quick adjustment of diskette parameter table */ + fmemcpy(int1e_table, *(char FAR * FAR *)MK_FP(0, 0x1e*4), sizeof(int1e_table)); + /* enforce min. 9 sectors per track */ + if (int1e_table[4] < 9) + int1e_table[4] = 9; + /* and adjust int1e */ + setvec(0x1e, (intvec)int1e_table); + /* Setup media info and BPBs arrays for floppies */ for (Unit = 0; Unit < nUnits; Unit++) { @@ -1339,7 +1350,7 @@ void ReadAllPartitionTables(void) /* disk initialization: returns number of units */ COUNT dsk_init() { - printf(" - InitDisk\n"); + printf(" - InitDisk"); #ifdef DEBUG { diff --git a/kernel/initoem.c b/kernel/initoem.c index 464a2f0b..b9dbfbfa 100644 --- a/kernel/initoem.c +++ b/kernel/initoem.c @@ -37,7 +37,7 @@ static BYTE *RcsId = UWORD init_oem(void) { - UWORD top_k; + UWORD top_k = 0; #ifndef __TURBOC__ asm diff --git a/kernel/inthndlr.c b/kernel/inthndlr.c index 0b6240c2..f420ba51 100644 --- a/kernel/inthndlr.c +++ b/kernel/inthndlr.c @@ -58,6 +58,10 @@ struct HugeSectorBlock { BYTE FAR *buf; }; +/* must be global/file scope, Turbo C uses the wrong segment for + * function scope */ +STATIC const char dbcsTable[] = {0, 0, 0, 0}; + /* Normal entry. This minimizes user stack usage by avoiding local */ /* variables needed for the rest of the handler. */ /* this here works on the users stack !! and only very few functions @@ -1325,7 +1329,6 @@ VOID ASMCFUNC int21_service(iregs FAR * r) /* UNDOCUMENTED: Double byte and korean tables */ case 0x63: { - static char *dbcsTable = "\0\0\0\0"; r->DS = FP_SEG(dbcsTable); r->SI = FP_OFF(dbcsTable); #if 0 diff --git a/kernel/kernel.asm b/kernel/kernel.asm index 19a87c45..610d8a83 100644 --- a/kernel/kernel.asm +++ b/kernel/kernel.asm @@ -230,7 +230,9 @@ _nul_intr: pop es retf - + ; floppy parameter table + global _int1e_table +_int1e_table: times 0eh db 0 ;************************************************************ ; KERNEL FIXED DATA AREA diff --git a/kernel/main.c b/kernel/main.c index 671fcb12..d7d590c0 100644 --- a/kernel/main.c +++ b/kernel/main.c @@ -33,7 +33,7 @@ #include "init-dat.h" GLOBAL BYTE copyright[] = - "(C) Copyright 1995-2001 Pasquale J. Villani and The FreeDOS Project.\n" + "(C) Copyright 1995-2002 Pasquale J. Villani and The FreeDOS Project.\n" "All Rights Reserved. This is free software and comes with ABSOLUTELY NO\n" "WARRANTY; you can redistribute it and/or modify it under the terms of the\n" "GNU General Public License as published by the Free Software Foundation;\n" @@ -174,13 +174,13 @@ VOID ASMCFUNC FreeDOSmain(void) /* clear the Init BSS area (what normally the RTL does */ memset(_ib_start, 0, _ib_end - _ib_start); + signon(); init_kernel(); #ifdef DEBUG /* Non-portable message kludge alert! */ printf("KERNEL: Boot drive = %c\n", 'A' + BootDrive - 1); #endif - signon(); kernel(); } @@ -361,9 +361,9 @@ STATIC VOID FsConfig(VOID) STATIC VOID signon() { - printf("\n%S", (void FAR *)os_release); + printf("\r%S", (void FAR *)os_release); - printf("Kernel compatibility %d.%d", os_major, os_minor); + printf("Kernel compatibility %d.%d", MAJOR_RELEASE, MINOR_RELEASE); #if defined(__TURBOC__) printf(" - TURBOC"); @@ -393,6 +393,7 @@ STATIC void kernel() int rc; extern char MenuSelected; + extern unsigned Menus; BYTE master_env[32]; char *masterenv_ptr = master_env; @@ -405,9 +406,9 @@ STATIC void kernel() masterenv_ptr += sprintf(masterenv_ptr, "PATH=."); /* export the current selected config menu */ - if (MenuSelected) + if (Menus) { - masterenv_ptr += sprintf(masterenv_ptr, "CONFIG=%c", MenuSelected); + masterenv_ptr += sprintf(masterenv_ptr, "CONFIG=%c", MenuSelected+'0'); } exb.exec.env_seg = DOS_PSP + 8; @@ -463,8 +464,8 @@ STATIC void kernel() } exb.exec.cmd_line = (CommandTail FAR *) & Cmd; - exb.exec.fcb_1 = exb.exec.fcb_2 = (fcb FAR *) 0; - + exb.exec.fcb_1 = exb.exec.fcb_2 = (fcb FAR *) 0xfffffffful; + #ifdef DEBUG printf("Process 0 starting: %s\n\n", Config.cfgInit); #endif diff --git a/kernel/makefile b/kernel/makefile index 636ebfd4..10aea3e7 100644 --- a/kernel/makefile +++ b/kernel/makefile @@ -168,43 +168,43 @@ HEADERS=\ # XXX: I generated these using `gcc -MM' and `sed', so they may not be # completely correct... -- ror4 -#blockio.obj: blockio.c $(HEADERS) $(CONFIGURATION) +blockio.obj: blockio.c $(HEADERS) $(CONFIGURATION) -#break.obj: break.c $(HEADERS) $(CONFIGURATION) +break.obj: break.c $(HEADERS) $(CONFIGURATION) -#chario.obj: chario.c $(HEADERS) $(CONFIGURATION) +chario.obj: chario.c $(HEADERS) $(CONFIGURATION) -#dosfns.obj: dosfns.c $(HEADERS) $(CONFIGURATION) +dosfns.obj: dosfns.c $(HEADERS) $(CONFIGURATION) -#dosnames.obj: dosnames.c $(HEADERS) $(CONFIGURATION) +dosnames.obj: dosnames.c $(HEADERS) $(CONFIGURATION) -#dsk.obj: dsk.c $(HEADERS) $(CONFIGURATION) +dsk.obj: dsk.c $(HEADERS) $(CONFIGURATION) -#error.obj: error.c $(HEADERS) $(CONFIGURATION) +error.obj: error.c $(HEADERS) $(CONFIGURATION) -#fatdir.obj: fatdir.c $(HEADERS) $(CONFIGURATION) +fatdir.obj: fatdir.c $(HEADERS) $(CONFIGURATION) -#fatfs.obj: fatfs.c $(HEADERS) $(CONFIGURATION) +fatfs.obj: fatfs.c $(HEADERS) $(CONFIGURATION) -#fattab.obj: fattab.c $(HEADERS) $(CONFIGURATION) +fattab.obj: fattab.c $(HEADERS) $(CONFIGURATION) -#fcbfns.obj: fcbfns.c $(HEADERS) $(CONFIGURATION) +fcbfns.obj: fcbfns.c $(HEADERS) $(CONFIGURATION) -#inthndlr.obj: inthndlr.c $(HEADERS) $(CONFIGURATION) +inthndlr.obj: inthndlr.c $(HEADERS) $(CONFIGURATION) -#ioctl.obj: ioctl.c $(HEADERS) $(CONFIGURATION) +ioctl.obj: ioctl.c $(HEADERS) $(CONFIGURATION) -#memmgr.obj: memmgr.c $(HEADERS) $(CONFIGURATION) +memmgr.obj: memmgr.c $(HEADERS) $(CONFIGURATION) -#misc.obj: misc.c $(HEADERS) $(CONFIGURATION) +misc.obj: misc.c $(HEADERS) $(CONFIGURATION) -#lfnapi.obj: lfnapi.c $(HEADERS) $(CONFIGURATION) +lfnapi.obj: lfnapi.c $(HEADERS) $(CONFIGURATION) -#newstuff.obj: newstuff.c $(HEADERS) $(CONFIGURATION) +newstuff.obj: newstuff.c $(HEADERS) $(CONFIGURATION) -#network.obj: network.c $(HEADERS) $(CONFIGURATION) +network.obj: network.c $(HEADERS) $(CONFIGURATION) -#nls.obj: nls.c $(HEADERS) $(CONFIGURATION) +nls.obj: nls.c $(HEADERS) $(CONFIGURATION) # \ # 001-437.nls diff --git a/kernel/memmgr.c b/kernel/memmgr.c index f39f7c91..ecacaf72 100644 --- a/kernel/memmgr.c +++ b/kernel/memmgr.c @@ -286,8 +286,13 @@ COUNT DosMemAlloc(UWORD size, COUNT mode, seg FAR * para, */ COUNT DosMemLargest(UWORD FAR * size) { - REG mcb FAR *p; + seg dummy; + *size = 0; + DosMemAlloc(0xffff, LARGEST, &dummy, size); + return *size ? SUCCESS : DE_NOMEM; +#if 0 + REG mcb FAR *p; /* Initialize */ p = ((mem_access_mode & (FIRST_FIT_UO | FIRST_FIT_U)) && uppermem_link && uppermem_root != 0xffff) ? para2far(uppermem_root) : para2far(first_mcb); @@ -320,7 +325,7 @@ COUNT DosMemLargest(UWORD FAR * size) /* If *size is still zero, aka nothing had changed, either no unused block was found at all or a zero-length block only. Both is considered as a failure */ - return *size ? SUCCESS : DE_NOMEM; +#endif } /* diff --git a/kernel/newstuff.c b/kernel/newstuff.c index f00070f9..1bab38f0 100644 --- a/kernel/newstuff.c +++ b/kernel/newstuff.c @@ -393,6 +393,7 @@ COUNT truename(char FAR * src, char FAR * dest, COUNT t) char c, *bufend = buf + (sizeof(buf) - 1); int gotAnyWildcards = 0; int seglen, copylen, state; + int error = DE_PATHNOTFND; while ((*src) && (bufp < bufend)) { /* Skip duplicated slashes. */ @@ -404,7 +405,12 @@ COUNT truename(char FAR * src, char FAR * dest, COUNT t) for (seglen = 0;; seglen++) { c = src[seglen]; - if ((c == '\0') || (c == '/') || (c == '\\')) + if (c == '\0') + { + error = DE_FILENOTFND; + break; + } + else if ((c == '/') || (c == '\\')) break; } if (seglen > 0) @@ -426,7 +432,7 @@ COUNT truename(char FAR * src, char FAR * dest, COUNT t) else { /* .. in root dir illegal */ - return DE_PATHNOTFND; + return error; } } else @@ -434,7 +440,7 @@ COUNT truename(char FAR * src, char FAR * dest, COUNT t) /* New segment. If any wildcards in previous segment(s), this is an invalid path. */ if (gotAnyWildcards || src[0] == '.') - return DE_PATHNOTFND; + return error; /* Append current path segment to result. */ *(bufp++) = '\\'; if (bufp >= bufend) @@ -456,8 +462,6 @@ COUNT truename(char FAR * src, char FAR * dest, COUNT t) break; copylen++; } - copylen = 0; - state = 1; /* Go wait for dot */ break; } if (c == '.') @@ -465,26 +469,17 @@ COUNT truename(char FAR * src, char FAR * dest, COUNT t) if (src[i + 1] != '.' && i + 1 < seglen) *(bufp++) = '.'; copylen = 0; - state = 2; /* Copy extension next */ + state = 1; /* Copy extension next */ break; } - *(bufp++) = c; - copylen++; - if (copylen >= FNAME_SIZE) + if (copylen < FNAME_SIZE) { - copylen = 0; - state = 1; /* Go wait for dot */ + *(bufp++) = c; + copylen++; break; } break; - case 1: /* Looking for dot so we can copy exten */ - if (src[i] == '.' && src[i + 1] != '.' && i + 1 < seglen) - { - *(bufp++) = '.'; - state = 2; - } - break; - case 2: /* Copying extension */ + case 1: /* Copying extension */ if (c == '*') { while (copylen < FEXT_SIZE) @@ -494,20 +489,13 @@ COUNT truename(char FAR * src, char FAR * dest, COUNT t) break; copylen++; } - i = seglen; /* Done with segment */ - break; } if (c == '.') + return error; + if (copylen < FEXT_SIZE) { - i = seglen; /* Done with segment */ - break; - } - *(bufp++) = c; - copylen++; - if (copylen >= FEXT_SIZE) - { - i = seglen; /* Done with segment */ - break; + *(bufp++) = c; + copylen++; } break; } diff --git a/kernel/prf.c b/kernel/prf.c index fa6c36b4..bacef8e1 100644 --- a/kernel/prf.c +++ b/kernel/prf.c @@ -366,15 +366,20 @@ COUNT do_printf(CONST BYTE * fmt, BYTE ** arg) void hexd(char *title, UBYTE FAR * p, COUNT numBytes) { - int loop; - printf("%s%04x|", title, FP_SEG(p)); - for (loop = 0; loop < numBytes; loop++) - printf("%02x ", p[loop]); - printf("|"); - - for (loop = 0; loop < numBytes; loop++) - printf("%c", p[loop] < 0x20 ? '.' : p[loop]); - printf("\n"); + int loop, start = 0; + printf("%s", title); + if (numBytes > 16) + printf("\n"); + + for (start = 0; start < numBytes; start += 16) + { + printf("%p|", p+start); + for (loop = start; loop < numBytes && loop < start+16;loop++) + printf("%02x ", p[loop]); + for (loop = start; loop < numBytes && loop < start+16;loop++) + printf("%c", p[loop] < 0x20 ? '.' : p[loop]); + printf("\n"); + } } #ifdef TEST diff --git a/kernel/procsupt.asm b/kernel/procsupt.asm index 05fffaf1..f89c7e5a 100644 --- a/kernel/procsupt.asm +++ b/kernel/procsupt.asm @@ -177,7 +177,7 @@ _spawn_int23: ;; complete the jump to INT-23 via RETF and restore BP xchg word [bp-4], bp - stc ;; set default action --> terminate + clc ;; set default action --> resume ; invoke the int 23 handler its address has been constructed ;; on the stack retf diff --git a/kernel/proto.h b/kernel/proto.h index 2c466840..5d042934 100644 --- a/kernel/proto.h +++ b/kernel/proto.h @@ -158,8 +158,7 @@ BOOL dos_setfsize(COUNT fd, LONG size); COUNT dos_mkdir(BYTE * dir); BOOL last_link(f_node_ptr fnp); COUNT map_cluster(REG f_node_ptr fnp, COUNT mode); -UCOUNT readblock(COUNT fd, VOID FAR * buffer, UCOUNT count, COUNT * err); -UCOUNT writeblock(COUNT fd, const VOID FAR * buffer, UCOUNT count, COUNT * err); +UCOUNT rwblock(COUNT fd, VOID FAR * buffer, UCOUNT count, int mode); COUNT dos_read(COUNT fd, VOID FAR * buffer, UCOUNT count); COUNT dos_write(COUNT fd, const VOID FAR * buffer, UCOUNT count); LONG dos_lseek(COUNT fd, LONG foffset, COUNT origin); @@ -184,16 +183,7 @@ void read_fsinfo(struct dpb FAR * dpbp); void write_fsinfo(struct dpb FAR * dpbp); UCOUNT link_fat(struct dpb FAR * dpbp, CLUSTER Cluster1, REG CLUSTER Cluster2); -UCOUNT link_fat32(struct dpb FAR * dpbp, CLUSTER Cluster1, - CLUSTER Cluster2); -UCOUNT link_fat16(struct dpb FAR * dpbp, CLUSTER Cluster1, - CLUSTER Cluster2); -UCOUNT link_fat12(struct dpb FAR * dpbp, CLUSTER Cluster1, - CLUSTER Cluster2); CLUSTER next_cluster(struct dpb FAR * dpbp, REG CLUSTER ClusterNum); -CLUSTER next_cl32(struct dpb FAR * dpbp, REG CLUSTER ClusterNum); -CLUSTER next_cl16(struct dpb FAR * dpbp, REG CLUSTER ClusterNum); -CLUSTER next_cl12(struct dpb FAR * dpbp, REG CLUSTER ClusterNum); /* fcbfns.c */ VOID DosOutputString(BYTE FAR * s); diff --git a/kernel/sysclk.c b/kernel/sysclk.c index ffc07cc1..1e0bce4c 100644 --- a/kernel/sysclk.c +++ b/kernel/sysclk.c @@ -30,61 +30,37 @@ #include "globals.h" #ifdef VERSION_STRINGS -static BYTE *RcsId = +static char *RcsId = "$Id$"; #endif -#ifdef PROTO -VOID ASMCFUNC WriteATClock(BYTE *, BYTE, BYTE, BYTE); -VOID ASMCFUNC WritePCClock(ULONG); -COUNT BcdToByte(COUNT); -COUNT BcdToWord(BYTE *, UWORD *, UWORD *, UWORD *); -COUNT ByteToBcd(COUNT); -VOID DayToBcd(BYTE *, UWORD *, UWORD *, UWORD *); -#else -VOID WriteATClock(); -VOID WritePCClock(); -COUNT BcdToByte(); -COUNT BcdToWord(); -COUNT ByteToBcd(); -VOID DayToBcd(); -#endif - /* */ /* WARNING - THIS DRIVER IS NON-PORTABLE!!!! */ /* */ -extern UWORD days[2][13]; /* this is defined by SYSTIME.C */ - -static struct ClockRecord clk; - -/* -static BYTE bcdDays[4]; -static UWORD Month, - Day, - Year; -static BYTE bcdMinutes; -static BYTE bcdHours; -/ ** static BYTE bcdHundredths;* / -static BYTE bcdSeconds; - -static ULONG Ticks; -*/ UWORD ASM DaysSinceEpoch = 0; +typedef UDWORD ticks_t; -BOOL ASMCFUNC ReadATClock(BYTE *, BYTE *, BYTE *, BYTE *); +STATIC int ByteToBcd(int x) +{ + return ((x / 10) << 4) | (x % 10); +} -STATIC COUNT BcdToByte(COUNT x) +STATIC int BcdToByte(int x) { - return ((((x) >> 4) & 0xf) * 10 + ((x) & 0xf)); + return ((x >> 4) & 0xf) * 10 + (x & 0xf); +} + +STATIC void DayToBcd(BYTE * x, unsigned mon, unsigned day, unsigned yr) +{ + x[1] = ByteToBcd(mon); + x[0] = ByteToBcd(day); + x[3] = ByteToBcd(yr / 100); + x[2] = ByteToBcd(yr % 100); } WORD ASMCFUNC FAR clk_driver(rqptr rp) { - COUNT c; - const UWORD *pdays; BYTE bcd_days[4], bcd_minutes, bcd_hours, bcd_seconds; - ULONG Ticks; - UWORD Month, Day, Year; switch (rp->r_command) { @@ -92,6 +68,8 @@ WORD ASMCFUNC FAR clk_driver(rqptr rp) /* If AT clock exists, copy AT clock time to system clock */ if (!ReadATClock(bcd_days, &bcd_hours, &bcd_minutes, &bcd_seconds)) { + ticks_t seconds; + DaysSinceEpoch = DaysFromYearMonthDay(100 * BcdToByte(bcd_days[3]) + BcdToByte(bcd_days[2]), @@ -100,16 +78,16 @@ WORD ASMCFUNC FAR clk_driver(rqptr rp) /* * This is a rather tricky calculation. The number of timer ticks per - * second is not exactly 18.2, but rather 0x1800b0 / 86400 = 19663 / 1080 - * (the timer interrupt updates the midnight flag when the tick count - * reaches 0x1800b0). Fortunately, 86400 * 19663 = 1698883200 < ULONG_MAX, - * so we can simply multiply the number of seconds by 19663 without - * worrying about overflow. :) -- ror4 + * second is not exactly 18.2, but rather 1193180 / 65536 + * where 1193180 = 0x1234dc + * The timer interrupt updates the midnight flag when the tick count + * reaches 0x1800b0 -- ror4. */ - Ticks = (3600ul * BcdToByte(bcd_hours) + - 60ul * BcdToByte(bcd_minutes) + - BcdToByte(bcd_seconds)) * 19663ul / 1080ul; - WritePCClock(Ticks); + + seconds = + 60 * (ticks_t)(60 * BcdToByte(bcd_hours) + BcdToByte(bcd_minutes)) + + BcdToByte(bcd_seconds); + WritePCClock(seconds * 0x12 + ((seconds * 0x34dc) >> 16)); } /* rp->r_endaddr = device_end(); not needed - bart */ rp->r_nunits = 0; @@ -117,170 +95,86 @@ WORD ASMCFUNC FAR clk_driver(rqptr rp) case C_INPUT: { - ULONG remainder, hs; - ReadPCClock(&Ticks); + struct ClockRecord clk; + int tmp; + ticks_t ticks; + clk.clkDays = DaysSinceEpoch; - /* - * Another tricky calculation (after the one in `main.c'). This time - * we do have a problem with overflow, because we need to extract the - * 1/100s portion too. The scaling factor is now - * (100 x 86400) / 0x1800b0 = 108000 / 19663. -- ror4 - */ - hs = 0; -#if 0 - if (Ticks >= 64 * 19663ul) - { - hs += 64 * 108000ul; - Ticks -= 64 * 19663ul; - } - if (Ticks >= 32 * 19663ul) - { - hs += 32 * 108000ul; - Ticks -= 32 * 19663ul; - } - if (Ticks >= 16 * 19663ul) - { - hs += 16 * 108000ul; - Ticks -= 16 * 19663ul; - } - if (Ticks >= 8 * 19663ul) - { - hs += 8 * 108000ul; - Ticks -= 8 * 19663ul; - } - if (Ticks >= 4 * 19663ul) - { - hs += 4 * 108000ul; - Ticks -= 4 * 19663ul; - } - if (Ticks >= 2 * 19663ul) - { - hs += 2 * 108000ul; - Ticks -= 2 * 19663ul; - } - if (Ticks >= 19663ul) - { - hs += 108000ul; - Ticks -= 19663ul; - } -#else - { - UWORD q1 = Ticks / 19663ul; - - Ticks -= q1 * 19663ul; - hs = q1 * 108000ul; - } - -#endif - /* - * Now Ticks < 19663, so Ticks * 108000 < 2123604000 < ULONG_MAX. - * *phew* -- ror4 - */ - hs += Ticks * 108000ul / 19663ul; - clk.clkHours = hs / 360000ul; - remainder = hs % 360000ul; - clk.clkMinutes = remainder / 6000ul; - remainder %= 6000ul; - clk.clkSeconds = remainder / 100ul; - clk.clkHundredths = remainder % 100ul; - } - - fmemcpy(rp->r_trans, &clk, - min(sizeof(struct ClockRecord), rp->r_count)); + + /* The scaling factor is now + 6553600/1193180 = 327680/59659 = 65536*5/59659 */ + + ticks = 5 * ReadPCClock(); + ticks = ((ticks / 59659u) << 16) + ((ticks % 59659u) << 16) / 59659u; + + tmp = (int)(ticks / 6000); + clk.clkHours = tmp / 60; + clk.clkMinutes = tmp % 60; + + tmp = (int)(ticks % 6000); + clk.clkSeconds = tmp / 100; + clk.clkHundredths = tmp % 100; + + fmemcpy(rp->r_trans, &clk, + min(sizeof(struct ClockRecord), rp->r_count)); + } return S_DONE; case C_OUTPUT: - rp->r_count = min(rp->r_count, sizeof(struct ClockRecord)); - fmemcpy(&clk, rp->r_trans, rp->r_count); - - /* Set PC Clock first */ - DaysSinceEpoch = clk.clkDays; { - ULONG hs; - hs = 360000ul * clk.clkHours + - 6000ul * clk.clkMinutes + - 100ul * clk.clkSeconds + clk.clkHundredths; - Ticks = 0; -#if 0 - if (hs >= 64 * 108000ul) - { - Ticks += 64 * 19663ul; - hs -= 64 * 108000ul; - } - if (hs >= 32 * 108000ul) - { - Ticks += 32 * 19663ul; - hs -= 32 * 108000ul; - } - if (hs >= 16 * 108000ul) - { - Ticks += 16 * 19663ul; - hs -= 16 * 108000ul; - } - if (hs >= 8 * 108000ul) - { - Ticks += 8 * 19663ul; - hs -= 8 * 108000ul; - } - if (hs >= 4 * 108000ul) - { - Ticks += 4 * 19663ul; - hs -= 4 * 108000ul; - } - if (hs >= 2 * 108000ul) - { - Ticks += 2 * 19663ul; - hs -= 2 * 108000ul; - } - if (hs >= 108000ul) - { - Ticks += 19663ul; - hs -= 108000ul; - } -#else - { - UWORD q1 = hs / 108000ul; - - hs -= q1 * 108000ul; - Ticks = q1 * 19663ul; - } + int c; + const unsigned short *pdays; + unsigned Month, Day, Year; + struct ClockRecord clk; + ticks_t hs, Ticks; + + rp->r_count = min(rp->r_count, sizeof(struct ClockRecord)); + fmemcpy(&clk, rp->r_trans, rp->r_count); + + /* Set PC Clock first */ + DaysSinceEpoch = clk.clkDays; + hs = 6000 * (ticks_t)(60 * clk.clkHours + clk.clkMinutes) + + (ticks_t)(100 * clk.clkSeconds + clk.clkHundredths); + + /* The scaling factor is now + 1193180/6553600 = 59659/327680 = 59659/65536/5 */ + + Ticks = ((hs >> 16) * 59659u + (((hs & 0xffff) * 59659u) >> 16)) / 5; -#endif - Ticks += hs * 19663ul / 108000ul; - } - WritePCClock(Ticks); + WritePCClock(Ticks); - /* Now set AT clock */ - /* Fix year by looping through each year, subtracting */ - /* the appropriate number of days for that year. */ - for (Year = 1980, c = clk.clkDays;;) - { - pdays = is_leap_year_monthdays(Year); - if (c >= pdays[12]) - { - ++Year; - c -= pdays[12]; - } - else - break; + /* Now set AT clock */ + /* Fix year by looping through each year, subtracting */ + /* the appropriate number of days for that year. */ + for (Year = 1980, c = clk.clkDays;;) + { + pdays = is_leap_year_monthdays(Year); + if (c >= pdays[12]) + { + ++Year; + c -= pdays[12]; + } + else + break; + } + + /* c contains the days left and count the number of */ + /* days for that year. Use this to index the table. */ + for (Month = 1; Month < 13; ++Month) + { + if (pdays[Month] > c) + { + Day = c - pdays[Month - 1] + 1; + break; + } + } + + DayToBcd(bcd_days, Month, Day, Year); + bcd_minutes = ByteToBcd(clk.clkMinutes); + bcd_hours = ByteToBcd(clk.clkHours); + bcd_seconds = ByteToBcd(clk.clkSeconds); + WriteATClock(bcd_days, bcd_hours, bcd_minutes, bcd_seconds); } - - /* c contains the days left and count the number of */ - /* days for that year. Use this to index the table. */ - for (Month = 1; Month < 13; ++Month) - { - if (pdays[Month] > c) - { - Day = c - pdays[Month - 1] + 1; - break; - } - } - - DayToBcd((BYTE *) bcd_days, &Month, &Day, &Year); - bcd_minutes = ByteToBcd(clk.clkMinutes); - bcd_hours = ByteToBcd(clk.clkHours); - bcd_seconds = ByteToBcd(clk.clkSeconds); - WriteATClock(bcd_days, bcd_hours, bcd_minutes, bcd_seconds); return S_DONE; case C_OFLUSH: @@ -296,19 +190,6 @@ WORD ASMCFUNC FAR clk_driver(rqptr rp) } } -COUNT ByteToBcd(COUNT x) -{ - return ((x / 10) << 4) | (x % 10); -} - -VOID DayToBcd(BYTE * x, UWORD * mon, UWORD * day, UWORD * yr) -{ - x[1] = ByteToBcd(*mon); - x[0] = ByteToBcd(*day); - x[3] = ByteToBcd(*yr / 100); - x[2] = ByteToBcd(*yr % 100); -} - /* * Log: sysclk.c,v - for newer entries do "cvs log sysclk.c" * diff --git a/kernel/syspack.c b/kernel/syspack.c index 2e4adefa..681b0c33 100644 --- a/kernel/syspack.c +++ b/kernel/syspack.c @@ -36,90 +36,89 @@ static BYTE *syspackRcsId = #endif #ifdef NONNATIVE -VOID getlong(REG VOID * vp, LONG * lp) +UDWORD getlong(REG VOID * vp) { - *lp = (((BYTE *) vp)[0] & 0xff) + - ((((BYTE *) vp)[1] & 0xff) << 8) + - ((((BYTE *) vp)[2] & 0xff) << 16) + - ((((BYTE *) vp)[3] & 0xff) << 24); + return (((UBYTE *) vp)[0] & 0xff) + + ((((UBYTE *) vp)[1] & 0xff) << 8) + + ((((UBYTE *) vp)[2] & 0xff) << 16) + + ((((UBYTE *) vp)[3] & 0xff) << 24); } -VOID getword(REG VOID * vp, WORD * wp) +UWORD getword(REG VOID * vp) { - *wp = (((BYTE *) vp)[0] & 0xff) + ((((BYTE *) vp)[1] & 0xff) << 8); + return (((UBYTE *) vp)[0] & 0xff) + ((((UBYTE *) vp)[1] & 0xff) << 8); } -VOID getbyte(VOID * vp, BYTE * bp) +UBYTE getbyte(VOID * vp) { - *bp = *((BYTE *) vp); + return *((BYTE *) vp); } -VOID fgetword(REG VOID FAR * vp, WORD FAR * wp) +UWORD fgetword(REG VOID FAR * vp) { - *wp = - (((BYTE FAR *) vp)[0] & 0xff) + ((((BYTE FAR *) vp)[1] & 0xff) << 8); + return (((UBYTE FAR *) vp)[0] & 0xff) + ((((UBYTE FAR *) vp)[1] & 0xff) << 8); } -VOID fgetlong(REG VOID FAR * vp, LONG FAR * lp) +UDWORD fgetlong(REG VOID FAR * vp) { - *lp = (((BYTE *) vp)[0] & 0xff) + - ((((BYTE *) vp)[1] & 0xff) << 8) + - ((((BYTE *) vp)[2] & 0xff) << 16) + - ((((BYTE *) vp)[3] & 0xff) << 24); + return (((UBYTE *) vp)[0] & 0xff) + + ((((UBYTE *) vp)[1] & 0xff) << 8) + + ((((UBYTE *) vp)[2] & 0xff) << 16) + + ((((UBYTE *) vp)[3] & 0xff) << 24); } -VOID fgetbyte(VOID FAR * vp, BYTE FAR * bp) +UBYTE fgetbyte(VOID FAR * vp) { - *bp = *((BYTE FAR *) vp); + return *((UBYTE FAR *) vp); } -VOID fputlong(LONG FAR * lp, VOID FAR * vp) +VOID fputlong(VOID FAR * vp, UDWORD l) { - REG BYTE FAR *bp = (BYTE FAR *) vp; + REG UBYTE FAR *bp = (UBYTE FAR *) vp; - bp[0] = *lp & 0xff; - bp[1] = (*lp >> 8) & 0xff; - bp[2] = (*lp >> 16) & 0xff; - bp[3] = (*lp >> 24) & 0xff; + bp[0] = l & 0xff; + bp[1] = (l >> 8) & 0xff; + bp[2] = (l >> 16) & 0xff; + bp[3] = (l >> 24) & 0xff; } -VOID fputword(WORD FAR * wp, VOID FAR * vp) +VOID fputword(VOID FAR * vp, UWORD w) { - REG BYTE FAR *bp = (BYTE FAR *) vp; + REG UBYTE FAR *bp = (UBYTE FAR *) vp; - bp[0] = *wp & 0xff; - bp[1] = (*wp >> 8) & 0xff; + bp[0] = w & 0xff; + bp[1] = (w >> 8) & 0xff; } -VOID fputbyte(BYTE FAR * bp, VOID FAR * vp) +VOID fputbyte(VOID FAR * vp, UBYTE b) { - *(BYTE FAR *) vp = *bp; + *(UBYTE FAR *) vp = b; } -VOID getdirent(BYTE FAR * vp, struct dirent FAR * dp) +VOID getdirent(UBYTE FAR * vp, struct dirent FAR * dp) { fmemcpy(dp->dir_name, &vp[DIR_NAME], FNAME_SIZE); fmemcpy(dp->dir_ext, &vp[DIR_EXT], FEXT_SIZE); - fgetbyte(&vp[DIR_ATTRIB], (BYTE FAR *) & dp->dir_attrib); - fgetword(&vp[DIR_TIME], (WORD FAR *) & dp->dir_time); - fgetword(&vp[DIR_DATE], (WORD FAR *) & dp->dir_date); - fgetword(&vp[DIR_START], (WORD FAR *) & dp->dir_start); - fgetlong(&vp[DIR_SIZE], (LONG FAR *) & dp->dir_size); + dp->dir_attrib = fgetbyte(&vp[DIR_ATTRIB]); + dp->dir_time = fgetword(&vp[DIR_TIME]); + dp->dir_date = fgetword(&vp[DIR_DATE]); + dp->dir_start = fgetword(&vp[DIR_START]); + dp->dir_size = fgetlong(&vp[DIR_SIZE]); } -VOID putdirent(struct dirent FAR * dp, BYTE FAR * vp) +VOID putdirent(struct dirent FAR * dp, UBYTE FAR * vp) { REG COUNT i; REG BYTE FAR *p; fmemcpy(&vp[DIR_NAME], dp->dir_name, FNAME_SIZE); fmemcpy(&vp[DIR_EXT], dp->dir_ext, FEXT_SIZE); - fputbyte((BYTE FAR *) & dp->dir_attrib, &vp[DIR_ATTRIB]); - fputword((WORD FAR *) & dp->dir_time, &vp[DIR_TIME]); - fputword((WORD FAR *) & dp->dir_date, &vp[DIR_DATE]); - fputword((WORD FAR *) & dp->dir_start, &vp[DIR_START]); - fputlong((LONG FAR *) & dp->dir_size, &vp[DIR_SIZE]); - for (i = 0, p = (BYTE FAR *) & vp[DIR_RESERVED]; i < 10; i++) + fputbyte(&vp[DIR_ATTRIB], dp->dir_attrib); + fputword(&vp[DIR_TIME], dp->dir_time); + fputword(&vp[DIR_DATE], dp->dir_date); + fputword(&vp[DIR_START], dp->dir_start); + fputlong(&vp[DIR_SIZE], dp->dir_size); + for (i = 0, p = (UBYTE FAR *) & vp[DIR_RESERVED]; i < 10; i++) *p++ = NULL; } #endif diff --git a/kernel/systime.c b/kernel/systime.c index b73281dc..4dd90c2a 100644 --- a/kernel/systime.c +++ b/kernel/systime.c @@ -98,19 +98,14 @@ VOID DosGetTime(BYTE FAR * hp, BYTE FAR * mp, BYTE FAR * sp, COUNT DosSetTime(BYTE h, BYTE m, BYTE s, BYTE hd) { - BYTE Month, DayOfMonth, DayOfWeek; - COUNT Year; - - DosGetDate((BYTE FAR *) & DayOfWeek, (BYTE FAR *) & Month, - (BYTE FAR *) & DayOfMonth, (COUNT FAR *) & Year); + /* for ClkRecord.clkDays */ + ExecuteClockDriverRequest(C_INPUT); ClkRecord.clkHours = h; ClkRecord.clkMinutes = m; ClkRecord.clkSeconds = s; ClkRecord.clkHundredths = hd; - ClkRecord.clkDays = DaysFromYearMonthDay(Year, Month, DayOfMonth); - ExecuteClockDriverRequest(C_OUTPUT); if (ClkReqHdr.r_status & S_ERROR) @@ -172,10 +167,7 @@ UWORD Month, DayOfMonth, Year; || DayOfMonth < 1 || DayOfMonth > pdays[Month] - pdays[Month - 1]) return DE_INVLDDATA; - DosGetTime((BYTE FAR *) & ClkRecord.clkHours, - (BYTE FAR *) & ClkRecord.clkMinutes, - (BYTE FAR *) & ClkRecord.clkSeconds, - (BYTE FAR *) & ClkRecord.clkHundredths); + ExecuteClockDriverRequest(C_INPUT); ClkRecord.clkDays = DaysFromYearMonthDay(Year, Month, DayOfMonth); diff --git a/kernel/task.c b/kernel/task.c index 44d2ce07..f6096520 100644 --- a/kernel/task.c +++ b/kernel/task.c @@ -241,8 +241,10 @@ VOID new_psp(psp FAR * p, int psize) /* first command line argument */ p->ps_fcb1.fcb_drive = 0; + fmemset(p->ps_fcb1.fcb_fname, ' ', FNAME_SIZE + FEXT_SIZE); /* second command line argument */ p->ps_fcb2.fcb_drive = 0; + fmemset(p->ps_fcb2.fcb_fname, ' ', FNAME_SIZE + FEXT_SIZE); /* local command line */ p->ps_cmd_count = 0; /* command tail */ @@ -265,8 +267,11 @@ STATIC UWORD patchPSP(UWORD pspseg, UWORD envseg, exec_blk FAR * exb, /* complete the psp by adding the command line and FCBs */ fmemcpy(psp->ps_cmd, exb->exec.cmd_line->ctBuffer, 127); - fmemcpy(&psp->ps_fcb1, exb->exec.fcb_1, 16); - fmemcpy(&psp->ps_fcb2, exb->exec.fcb_2, 16); + if (FP_OFF(exb->exec.fcb_1) != 0xffff) + { + fmemcpy(&psp->ps_fcb1, exb->exec.fcb_1, 16); + fmemcpy(&psp->ps_fcb2, exb->exec.fcb_2, 16); + } psp->ps_cmd_count = exb->exec.cmd_line->ctCount; /* identify the mcb as this functions' */ diff --git a/mkfiles/watcom.mak b/mkfiles/watcom.mak index 05f5f2a3..2d07ea6a 100644 --- a/mkfiles/watcom.mak +++ b/mkfiles/watcom.mak @@ -4,8 +4,7 @@ # Use these for WATCOM 11.0c COMPILERPATH=$(WATCOM) -COMPILERBIN=$(WATCOM)\binw -CC=$(COMPILERBIN)\wcl +CC=wcl INCLUDEPATH=$(COMPILERPATH)\H INCLUDE=$(COMPILERPATH)\h EDPATH=$(COMPILERPATH)\EDDAT @@ -17,12 +16,12 @@ TARGETOPT=-0 !endif LIBPATH=$(COMPILERPATH)\lib286 -LIBUTIL=$(COMPILERBIN)\wlib +LIBUTIL=wlib LIBPLUS= LIBTERM= -CFLAGST=-zp=1 -mt -os -s -we -e=3 -w=2 -CFLAGSC=-zp=1 -mc -os -s -we -e=3 -w=2 +CFLAGST=-zp=1 -mt -os -s -we -e=3 -wx +CFLAGSC=-zp=1 -mc -os -s -we -e=3 -wx TARGET=KWC @@ -60,7 +59,7 @@ MATH_INSERT= +i4d +i4m # -3 optimization for 386 - given in CONFIG.MAK, not here # -ALLCFLAGS=-I..\hdr $(TARGETOPT) $(ALLCFLAGS) -zq -os -s -e=5 -j -zl -zp=1 -we +ALLCFLAGS=-I..\hdr $(TARGETOPT) $(ALLCFLAGS) -zq -os -s -e=5 -j -zl -zp=1 -wx -we INITCFLAGS=$(ALLCFLAGS) -nt=INIT_TEXT -nc=INIT -nd=I -g=I_GROUP CFLAGS=$(ALLCFLAGS) -nt=HMA_TEXT -nc=HMA -g=HGROUP INITPATCH=..\utils\patchobj __U4D=_IU4D __U4M=_IU4M diff --git a/sys/fdkrncfg.c b/sys/fdkrncfg.c index 4dfdbaf8..33a46d92 100644 --- a/sys/fdkrncfg.c +++ b/sys/fdkrncfg.c @@ -28,6 +28,7 @@ extern int CDECL printf(CONST BYTE * fmt, ...); extern int CDECL sprintf(BYTE * buff, CONST BYTE * fmt, ...); #ifdef __WATCOMC__ +unsigned _dos_close(int handle); #define close _dos_close #define SEEK_SET 0 int open(const char *pathname, int flags, ...); diff --git a/sys/sys.c b/sys/sys.c index 6aef7034..bdd2cffc 100644 --- a/sys/sys.c +++ b/sys/sys.c @@ -66,6 +66,7 @@ extern WORD CDECL sprintf(BYTE * buff, CONST BYTE * fmt, ...); #ifndef __WATCOMC__ #include #else +int unlink(const char *pathname); /* some non-conforming functions to make the executable smaller */ int open(const char *pathname, int flags, ...) { @@ -819,7 +820,7 @@ BOOL copy(COUNT drive, BYTE * srcPath, BYTE * rootPath, BYTE * file) return TRUE; } -/* Log: sys.c,v see "cvs log sys.c" for newer entries. +/* Log: sys.c,v see "cvs log sys.c" for newer entries. */ /* version 2.2 jeremyd 2001/9/20 Changed so if no source given or only source drive (no path) diff --git a/utils/patchobj.c b/utils/patchobj.c index c811852b..30a9c3b9 100644 --- a/utils/patchobj.c +++ b/utils/patchobj.c @@ -13,6 +13,7 @@ *****************************************************************************/ #include +#include #include #include #include From e5ecc591db421878e7d66a252d997750c8b396b8 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Wed, 8 May 2002 23:29:08 +0000 Subject: [PATCH 127/671] kernel 2026b changes git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@383 6ac86273-5f31-0410-b378-82cca8765d1b --- docs/history.txt | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/docs/history.txt b/docs/history.txt index 1012007d..248a5ecb 100644 --- a/docs/history.txt +++ b/docs/history.txt @@ -1,3 +1,30 @@ +2002 May 9 - Build 2026b +-------- Bart Oldeman (bart@dosemu.org) ++ Changes Tom + * limit output at boot time somewhat + * GetCurrentDirectory should fail, if drive is accessible + * fixed some minor config.sys parser bugs and have the possibility + of things like 123?device=EMM386.EXE NOEMS + * shorter version of DosMemLargest() ++ Changes Bart + * repaired makefile dependencies + * implemented multi-sector writes, and re-merged + readblock()/writeblock() into rwblock () + * implemented int21/ah=1c for network drives (RHIDE needs this) + * initialize current_ldt for findnext (hinted by Steffen) + * check serial number for floppy disk changes where the drive + does not feature a changeline + * reset to root directory when floppy has changed + * cleaned up endian helpers {get,put}{byte,word,long} + * don't close file if disk is full + * enforce minimum of 9 sectors per track for INT1E (necessary for + some floppies on some XTs) + * clear carry when calling INT23 (ctrl-break handler) as per RBIL + * don't copy FCBs on exec if they are pointed to by FFFF:FFFF. + * resolved warnings for Watcom (now compiles with -wx -we) + * truename fix (return DE_FILENOTFND for foo.bar.foo) ++ Changes Tom and Bart + * cleaned up fatfs.c, fattab.c, sysclk.c (CLOCK$ driver), systime.c 2002 Feb 17 - Build 2026a -------- Bart Oldeman (bart@dosemu.org) + Changes Martin From 8320afcb825af900d841b0637031c74e0868c6e0 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Wed, 8 May 2002 23:57:58 +0000 Subject: [PATCH 128/671] kernel 2026b changes git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@384 6ac86273-5f31-0410-b378-82cca8765d1b --- docs/history.txt | 2 ++ sys/sys.c | 1 + 2 files changed, 3 insertions(+) diff --git a/docs/history.txt b/docs/history.txt index 248a5ecb..e93b709b 100644 --- a/docs/history.txt +++ b/docs/history.txt @@ -23,6 +23,8 @@ * don't copy FCBs on exec if they are pointed to by FFFF:FFFF. * resolved warnings for Watcom (now compiles with -wx -we) * truename fix (return DE_FILENOTFND for foo.bar.foo) ++ Changes Jeremy + * fixed SYS _dos_getdrive for non-Borland compilers + Changes Tom and Bart * cleaned up fatfs.c, fattab.c, sysclk.c (CLOCK$ driver), systime.c 2002 Feb 17 - Build 2026a diff --git a/sys/sys.c b/sys/sys.c index bdd2cffc..f26a4563 100644 --- a/sys/sys.c +++ b/sys/sys.c @@ -268,6 +268,7 @@ int main(int argc, char **argv) srcDrive = (unsigned) getdisk(); #else _dos_getdrive(&srcDrive); + srcDrive--; #endif } From f8c1206a51d9a2962ce6d3b7f3be6b41a2154fb9 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Fri, 2 Aug 2002 21:45:18 +0000 Subject: [PATCH 129/671] Use stdarg.h style functions for printf() git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@394 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/prf.c | 86 ++++++++++++++++++++++++++++------------------------ 1 file changed, 47 insertions(+), 39 deletions(-) diff --git a/kernel/prf.c b/kernel/prf.c index bacef8e1..6bfa7b16 100644 --- a/kernel/prf.c +++ b/kernel/prf.c @@ -30,6 +30,13 @@ #ifdef FORSYS #include +#include +#else +/* copied from bcc (Bruce's C compiler) stdarg.h */ +typedef char *va_list; +#define va_start(arg, last) ((arg) = (char *) (&(last)+1)) +#define va_arg(arg, type) (((type *)(arg+=sizeof(type)))[-1]) +#define va_end(arg) #endif /*#define DOSEMU */ @@ -49,7 +56,6 @@ static char buff[MAX_BUFSIZE]; #define printf init_printf #define sprintf init_sprintf #define charp init_charp -#define hexd init_hexd #define hexDigits init_hexDigits #endif @@ -63,8 +69,8 @@ static BYTE *charp = 0; STATIC VOID handle_char(COUNT); STATIC VOID put_console(COUNT); STATIC BYTE * ltob(LONG, BYTE *, COUNT); -STATIC COUNT do_printf(CONST BYTE *, REG BYTE **); -WORD CDECL printf(CONST BYTE * fmt, ...); +STATIC COUNT do_printf(CONST BYTE *, REG va_list); +int CDECL printf(CONST BYTE * fmt, ...); /* The following is user supplied and must match the following prototype */ VOID cso(COUNT); @@ -96,10 +102,21 @@ VOID put_console(COUNT c) { buff[buff_offset] = 0; buff_offset = 0; +#ifdef __TURBOC__ _ES = FP_SEG(buff); _DX = FP_OFF(buff); _AX = 0x13; __int__(0xe6); +#elif defined(I86) + asm + { + push ds; + pop es; + mov dx, offset buff; + mov ax, 0x13; + int 0xe6; + } +#endif } else { @@ -120,7 +137,7 @@ VOID put_console(COUNT c) _AX = 0x0e00 | c; _BX = 0x0070; __int__(0x10); -#else +#elif defined(I86) __asm { mov al, byte ptr c; @@ -182,18 +199,22 @@ BYTE *ltob(LONG n, BYTE * s, COUNT base) #define RIGHT 1 /* printf -- short version of printf to conserve space */ -WORD CDECL printf(CONST BYTE * fmt, ...) +int CDECL printf(CONST BYTE * fmt, ...) { + va_list arg; + va_start(arg, fmt); charp = 0; - return do_printf(fmt, (BYTE **) & fmt + 1); + return do_printf(fmt, arg); } -WORD CDECL sprintf(BYTE * buff, CONST BYTE * fmt, ...) +int CDECL sprintf(BYTE * buff, CONST BYTE * fmt, ...) { WORD ret; + va_list arg; + va_start(arg, fmt); charp = buff; - ret = do_printf(fmt, (BYTE **) & fmt + 1); + ret = do_printf(fmt, arg); handle_char(NULL); return ret; } @@ -207,7 +228,7 @@ ULONG FAR retcs(int i) return *(ULONG *)p; } */ -COUNT do_printf(CONST BYTE * fmt, BYTE ** arg) +COUNT do_printf(CONST BYTE * fmt, va_list arg) { int base; BYTE s[11], FAR * p; @@ -269,31 +290,29 @@ COUNT do_printf(CONST BYTE * fmt, BYTE ** arg) case '\0': return 0; - case 'c': - handle_char(*(COUNT *) arg++); + case 'c': + handle_char(va_arg(arg, int)); continue; case 'p': { - UWORD w[2]; - w[1] = *((UWORD *) arg); - arg += sizeof(UWORD) / sizeof(BYTE *); - w[0] = *((UWORD *) arg); - arg += sizeof(UWORD) / sizeof(BYTE *); - do_printf("%04x:%04x", (BYTE **) & w); - continue; + UWORD w0 = va_arg(arg, UWORD); + char *tmp = charp; + sprintf(s, "%04x:%04x", va_arg(arg, UWORD), w0); + p = s; + charp = tmp; + goto do_outputstring; } case 's': - p = *arg++; + p = va_arg(arg, char *); goto do_outputstring; case 'F': fmt++; /* we assume %Fs here */ case 'S': - p = *((BYTE FAR **) arg); - arg += sizeof(BYTE FAR *) / sizeof(BYTE *); + p = va_arg(arg, char FAR *); goto do_outputstring; case 'i': @@ -315,24 +334,10 @@ COUNT do_printf(CONST BYTE * fmt, BYTE ** arg) lprt: if (longarg) - { - currentArg = *((LONG *) arg); - arg += sizeof(LONG) / sizeof(BYTE *); - } + currentArg = va_arg(arg, long); else - { - if (base < 0) - { - currentArg = *((int *)arg); - arg += sizeof(int) / sizeof(BYTE *); - } - else - { - currentArg = *((unsigned int *)arg); - arg += sizeof(unsigned int) / sizeof(BYTE *); - } - } - + currentArg = base < 0 ? (long)va_arg(arg, int) : + (long)va_arg(arg, unsigned int); ltob(currentArg, s, base); p = s; @@ -361,9 +366,11 @@ COUNT do_printf(CONST BYTE * fmt, BYTE ** arg) } } + va_end(arg); return 0; } +#ifndef _INIT void hexd(char *title, UBYTE FAR * p, COUNT numBytes) { int loop, start = 0; @@ -381,6 +388,7 @@ void hexd(char *title, UBYTE FAR * p, COUNT numBytes) printf("\n"); } } +#endif #ifdef TEST /* @@ -394,7 +402,7 @@ void hexd(char *title, UBYTE FAR * p, COUNT numBytes) and run. if strings are wrong, the program will wait for the ANYKEY */ -#include +#include void cso(char c) { putch(c); From 78e7cee01c07fc4e98f741b33418a34061a76313 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Fri, 2 Aug 2002 21:53:00 +0000 Subject: [PATCH 130/671] Update makefiles to deal with CC and CL git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@395 6ac86273-5f31-0410-b378-82cca8765d1b --- mkfiles/bc5.mak | 6 ++++-- mkfiles/generic.mak | 4 ++-- mkfiles/mscl8.mak | 2 ++ mkfiles/tc2.mak | 6 ++++-- mkfiles/tc3.mak | 6 ++++-- mkfiles/turbocpp.mak | 6 ++++-- mkfiles/watcom.mak | 16 +++++++++------- 7 files changed, 29 insertions(+), 17 deletions(-) diff --git a/mkfiles/bc5.mak b/mkfiles/bc5.mak index 98655335..e2dc7f93 100644 --- a/mkfiles/bc5.mak +++ b/mkfiles/bc5.mak @@ -6,14 +6,16 @@ COMPILERPATH=$(BC5_BASE) COMPILERBIN=$(COMPILERPATH)\bin -CC=$(COMPILERBIN)\bcc +CC=$(COMPILERBIN)\bcc -c +CL=$(COMPILERBIN)\bcc INCLUDEPATH=$(COMPILERPATH)\include LIBUTIL=$(COMPILERBIN)\tlib LIBPATH=$(COMPILERPATH)\lib LIBTERM= LIBPLUS=+ -CFLAGST=-L$(LIBPATH) -mt -lt -a- -k- -f- -ff- -O -Z -d +TINY=-lt +CFLAGSS=-L$(LIBPATH) -mt -a- -k- -f- -ff- -O -Z -d CFLAGSC=-L$(LIBPATH) -a- -mc TARGET=KBC diff --git a/mkfiles/generic.mak b/mkfiles/generic.mak index c73026c3..71e0db8e 100644 --- a/mkfiles/generic.mak +++ b/mkfiles/generic.mak @@ -40,8 +40,8 @@ RM=..\utils\rmfiles # *Implicit Rules* .c.obj : - $(CC) $(CFLAGS) -c $*.c + $(CC) $(CFLAGS) $*.c .cpp.obj : - $(CC) $(CFLAGS) -c $*.cpp + $(CC) $(CFLAGS) $*.cpp diff --git a/mkfiles/mscl8.mak b/mkfiles/mscl8.mak index 92f9bb15..328c1c17 100644 --- a/mkfiles/mscl8.mak +++ b/mkfiles/mscl8.mak @@ -6,7 +6,9 @@ COMPILERPATH=$(MS_BASE) COMPILERBIN=$(COMPILERPATH)\bin INCLUDEPATH=$(COMPILERPATH)\include +CC=$(COMPILERBIN)\cl -c CC=$(COMPILERBIN)\cl +TINY= CFLAGST=/Fm /AT /Os /Zp1 CFLAGSC=/Fm /AL /Os /Zp1 LIBPATH=$(COMPILERPATH)\lib diff --git a/mkfiles/tc2.mak b/mkfiles/tc2.mak index c57c5c5e..121fd0f6 100644 --- a/mkfiles/tc2.mak +++ b/mkfiles/tc2.mak @@ -6,14 +6,16 @@ COMPILERPATH=$(TC2_BASE) COMPILERBIN=$(COMPILERPATH) -CC=$(COMPILERBIN)\tcc +CC=$(COMPILERBIN)\tcc -c +CL=$(COMPILERBIN)\tcc INCLUDEPATH=$(COMPILERPATH)\include LIBUTIL=$(COMPILERBIN)\tlib LIBPATH=$(COMPILERPATH)\lib LIBTERM= LIBPLUS=+ -CFLAGST=-L$(LIBPATH) -mt -lt -a- -k- -f- -ff- -O -Z -d +TINY=-lt +CFLAGST=-L$(LIBPATH) -mt -a- -k- -f- -ff- -O -Z -d CFLAGSC=-L$(LIBPATH) -a- -mc TARGET=KTC diff --git a/mkfiles/tc3.mak b/mkfiles/tc3.mak index 0dedd6b6..22ecbd07 100644 --- a/mkfiles/tc3.mak +++ b/mkfiles/tc3.mak @@ -6,14 +6,16 @@ COMPILERPATH=$(TC3_BASE) COMPILERBIN=$(COMPILERPATH)\bin -CC=$(COMPILERBIN)\tcc +CC=$(COMPILERBIN)\tcc -c +CL=$(COMPILERBIN)\tcc INCLUDEPATH=$(COMPILERPATH)\include LIBUTIL=$(COMPILERBIN)\tlib LIBPATH=$(COMPILERPATH)\lib LIBTERM= LIBPLUS=+ -CFLAGST=-L$(LIBPATH) -mt -lt -a- -k- -f- -ff- -O -Z -d +TINY=-lt +CFLAGST=-L$(LIBPATH) -mt -a- -k- -f- -ff- -O -Z -d CFLAGSC=-L$(LIBPATH) -a- -mc TARGET=KT3 diff --git a/mkfiles/turbocpp.mak b/mkfiles/turbocpp.mak index ee996ea4..40b382ea 100644 --- a/mkfiles/turbocpp.mak +++ b/mkfiles/turbocpp.mak @@ -6,14 +6,16 @@ COMPILERPATH=$(TP1_BASE) COMPILERBIN=$(COMPILERPATH)\bin -CC=$(COMPILERBIN)\tcc +CC=$(COMPILERBIN)\tcc -c +CL=$(COMPILERBIN)\tcc INCLUDEPATH=$(COMPILERPATH)\include LIBUTIL=$(COMPILERBIN)\tlib LIBPATH=$(COMPILERPATH)\lib LIBTERM= LIBPLUS=+ -CFLAGST=-L$(LIBPATH) -mt -lt -a- -k- -f- -ff- -O -Z -d +TINY=-lt +CFLAGST=-L$(LIBPATH) -mt -a- -k- -f- -ff- -O -Z -d CFLAGSC=-L$(LIBPATH) -a- -mc TARGET=KTP diff --git a/mkfiles/watcom.mak b/mkfiles/watcom.mak index 2d07ea6a..baa204ae 100644 --- a/mkfiles/watcom.mak +++ b/mkfiles/watcom.mak @@ -4,7 +4,8 @@ # Use these for WATCOM 11.0c COMPILERPATH=$(WATCOM) -CC=wcl +CC=wcc +CL=wcl INCLUDEPATH=$(COMPILERPATH)\H INCLUDE=$(COMPILERPATH)\h EDPATH=$(COMPILERPATH)\EDDAT @@ -16,12 +17,13 @@ TARGETOPT=-0 !endif LIBPATH=$(COMPILERPATH)\lib286 -LIBUTIL=wlib +LIBUTIL=wlib /q LIBPLUS= LIBTERM= -CFLAGST=-zp=1 -mt -os -s -we -e=3 -wx -CFLAGSC=-zp=1 -mc -os -s -we -e=3 -wx +TINY=-mt +CFLAGST=-zq-zp1-os-s-we-e3-wx +CFLAGSC=-mc-zq-zp1-os-s-we-e3-wx TARGET=KWC @@ -59,8 +61,8 @@ MATH_INSERT= +i4d +i4m # -3 optimization for 386 - given in CONFIG.MAK, not here # -ALLCFLAGS=-I..\hdr $(TARGETOPT) $(ALLCFLAGS) -zq -os -s -e=5 -j -zl -zp=1 -wx -we -INITCFLAGS=$(ALLCFLAGS) -nt=INIT_TEXT -nc=INIT -nd=I -g=I_GROUP -CFLAGS=$(ALLCFLAGS) -nt=HMA_TEXT -nc=HMA -g=HGROUP +ALLCFLAGS=-I..\hdr $(TARGETOPT) $(ALLCFLAGS)-zq-os-s-e5-j-zl-zp1-wx-we-zgf-zff +INITCFLAGS=$(ALLCFLAGS)-ntINIT_TEXT-ncINIT-ndI-gI_GROUP +CFLAGS=$(ALLCFLAGS)-ntHMA_TEXT-ncHMA-gHGROUP INITPATCH=..\utils\patchobj __U4D=_IU4D __U4M=_IU4M From 11be0d22e4dc3f1eec6d11d97dbe6b3a58a4c647 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Fri, 2 Aug 2002 21:55:14 +0000 Subject: [PATCH 131/671] Added protection for FS:, GS:, update makefiles to use CC and CL. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@396 6ac86273-5f31-0410-b378-82cca8765d1b --- docs/history.txt | 7 +++++++ getmake.bat | 2 +- hdr/stacks.inc | 20 ++++++++++++++++---- kernel/entry.asm | 18 +++++++++--------- kernel/int2f.asm | 4 +++- kernel/io.asm | 2 ++ kernel/makefile | 16 ++++++++-------- kernel/nlssupt.asm | 3 +++ sys/makefile | 16 +++++----------- utils/makefile | 10 +++++----- 10 files changed, 59 insertions(+), 39 deletions(-) diff --git a/docs/history.txt b/docs/history.txt index e93b709b..2555b8b4 100644 --- a/docs/history.txt +++ b/docs/history.txt @@ -1,3 +1,10 @@ +2002 Aug xx - Build 2027 +-------- Bart Oldeman (bart@dosemu.org) ++ Changes Tom + ++ Changes Bart + * patchobj makefile correction + * printf uses va_list etc. 2002 May 9 - Build 2026b -------- Bart Oldeman (bart@dosemu.org) + Changes Tom diff --git a/getmake.bat b/getmake.bat index 2ee93383..9306aa97 100644 --- a/getmake.bat +++ b/getmake.bat @@ -4,7 +4,7 @@ @if \%COMPILER% == \TURBOCPP set MAKE=%TP1_BASE%\bin\make @if \%COMPILER% == \TC3 set MAKE=%TC3_BASE%\bin\make @if \%COMPILER% == \BC5 set MAKE=%BC5_BASE%\bin\make -@if \%COMPILER% == \WATCOM set MAKE=wmake /ms +@if \%COMPILER% == \WATCOM set MAKE=wmake /ms /h @if \%COMPILER% == \MSCL8 set MAKE=%MS_BASE%\bin\nmake /nologo :make_set diff --git a/hdr/stacks.inc b/hdr/stacks.inc index d54819e6..70a87634 100644 --- a/hdr/stacks.inc +++ b/hdr/stacks.inc @@ -130,16 +130,17 @@ irp_hi equ 26 ; no need to save/restore anything ; error 1 2 3 - %macro ProtectHighPartOfRegistersOn386 0 + %macro Protect386Registers 0 %endmacro - %macro RestoreHighPartOfRegistersOn386 0 + %macro Restore386Registers 0 %endmacro %ELSE - %macro ProtectHighPartOfRegistersOn386 0 + %macro Protect386Registers 0 + %ifdef WATCOM ror eax,16 push ax ror eax,16 @@ -152,10 +153,16 @@ irp_hi equ 26 ror edx,16 push dx ror edx,16 + %else + push fs + push gs + %endif %endmacro - %macro RestoreHighPartOfRegistersOn386 0 + %macro Restore386Registers 0 + + %ifdef WATCOM ror edx,16 pop dx ror edx,16 @@ -168,6 +175,11 @@ irp_hi equ 26 ror eax,16 pop ax ror eax,16 + %else + pop gs + pop fs + %endif + %endmacro %ENDIF diff --git a/kernel/entry.asm b/kernel/entry.asm index 97e97949..059637e6 100644 --- a/kernel/entry.asm +++ b/kernel/entry.asm @@ -244,9 +244,7 @@ reloc_call_int21_handler: sti PUSH$ALL mov bp,sp - - ProtectHighPartOfRegistersOn386 - + Protect386Registers ; ; Create kernel reference frame. ; @@ -378,17 +376,16 @@ int21_exit_nodec: pop si %IFDEF I386 - sub bp,8 + sub bp,8 %endif cli mov ss,si mov sp,bp -int21_ret: - RestoreHighPartOfRegistersOn386 - - POP$ALL +int21_ret: + Restore386Registers + POP$ALL ; ; ... and return. @@ -452,7 +449,6 @@ int2526: push ds push es - mov cx, sp ; save stack frame mov dx, ss @@ -466,6 +462,8 @@ int2526: mov sp,_disk_api_tos sti + Protect386Registers + push dx push cx ; save user stack @@ -478,6 +476,8 @@ int2526: pop cx pop dx ; restore user stack + Restore386Registers + ; restore foreground stack here cli mov ss, dx diff --git a/kernel/int2f.asm b/kernel/int2f.asm index fac1a58e..112f5404 100644 --- a/kernel/int2f.asm +++ b/kernel/int2f.asm @@ -106,6 +106,7 @@ IntDosCal: ; UWORD ip,cs,flags; ; UWORD callerARG1; ;}; + Protect386Registers push ax push cx push dx @@ -118,7 +119,7 @@ IntDosCal: mov ax,DGROUP mov ds,ax - extern _int2F_12_handler:wrt HGROUP + extern _int2F_12_handler:wrt HGROUP call _int2F_12_handler pop es @@ -130,6 +131,7 @@ IntDosCal: pop dx pop cx pop ax + Restore386Registers iret diff --git a/kernel/io.asm b/kernel/io.asm index 347c33c5..23e35f77 100644 --- a/kernel/io.asm +++ b/kernel/io.asm @@ -559,6 +559,7 @@ clk_and_blk_common: push si push di push es + Protect386Registers mov ds,[cs:_TEXT_DGROUP] ; @@ -573,6 +574,7 @@ clk_and_blk_common: mov word [es:bx+status],ax ; mark operation complete + Restore386Registers pop es pop di pop si diff --git a/kernel/makefile b/kernel/makefile index 10aea3e7..200103a5 100644 --- a/kernel/makefile +++ b/kernel/makefile @@ -26,7 +26,7 @@ HDR=../hdr/ # 'standard' compiles .c.obj : - $(CC) $(CFLAGS) -c $< + $(CC) $(CFLAGS) $< $(STDPATCH) $*.obj # *List Macros* @@ -228,32 +228,32 @@ task.obj: task.c $(HEADERS) $(CONFIGURATION) # patchobj $*.obj $(INITPATCH) config.obj: config.c $(INITHEADERS) $(HEADERS) $(CONFIGURATION) - $(CC) $(INITCFLAGS) -c $*.c + $(CC) $(INITCFLAGS) $*.c $(INITPATCH) $*.obj initoem.obj: initoem.c $(INITHEADERS) $(HEADERS) $(CONFIGURATION) - $(CC) $(INITCFLAGS) -c $*.c + $(CC) $(INITCFLAGS) $*.c $(INITPATCH) $*.obj main.obj: main.c $(INITHEADERS) $(HEADERS) $(CONFIGURATION) - $(CC) $(INITCFLAGS) -c $*.c + $(CC) $(INITCFLAGS) $*.c $(INITPATCH) $*.obj inithma.obj: inithma.c $(INITHEADERS) $(HEADERS) $(CONFIGURATION) - $(CC) $(INITCFLAGS) -c $*.c + $(CC) $(INITCFLAGS) $*.c $(INITPATCH) $*.obj dyninit.obj: dyninit.c $(INITHEADERS) $(HEADERS) $(CONFIGURATION) - $(CC) $(INITCFLAGS) -c $*.c + $(CC) $(INITCFLAGS) $*.c $(INITPATCH) $*.obj initdisk.obj: initdisk.c $(INITHEADERS) $(HEADERS) $(CONFIGURATION) - $(CC) $(INITCFLAGS) -c $*.c + $(CC) $(INITCFLAGS) $*.c $(INITPATCH) $*.obj #the printf for INIT_TEXT - yet another special case, this file includes prf.c iprf.obj: iprf.c prf.c $(HDR)\portab.h $(CONFIGURATION) - $(CC) $(INITCFLAGS) -c $*.c + $(CC) $(INITCFLAGS) $*.c $(INITPATCH) $*.obj # Log: makefile,v diff --git a/kernel/nlssupt.asm b/kernel/nlssupt.asm index eb3c92e4..8fca40f2 100644 --- a/kernel/nlssupt.asm +++ b/kernel/nlssupt.asm @@ -39,6 +39,8 @@ segment HMA_TEXT ; Part of Function 38h ; _reloc_call_CharMapSrvc: + + Protect386Registers push ds push es push bp @@ -68,6 +70,7 @@ _reloc_call_CharMapSrvc: pop bp pop es pop ds + Restore386Registers retf ; Return far ; Log: nlssupt.asm,v ; diff --git a/sys/makefile b/sys/makefile index 14c11ac7..bcb815a8 100644 --- a/sys/makefile +++ b/sys/makefile @@ -11,9 +11,6 @@ NASMFLAGS = -DSYS=1 # *List Macros* -BIN2C_EXE_dependencies = \ - bin2c.obj - SYS_EXE_dependencies = \ sys.obj \ fdkrncfg.obj \ @@ -22,8 +19,8 @@ SYS_EXE_dependencies = \ # *Explicit Rules* production: bin2c.com ..\bin\sys.com -bin2c.com: $(BIN2C_EXE_dependencies) - $(CC) $(CFLAGST) $(BIN2C_EXE_dependencies) +bin2c.com: bin2c.c + $(CL) $(CFLAGST) $(TINY) bin2c.c ..\bin\sys.com: sys.com copy sys.com ..\bin @@ -38,12 +35,12 @@ b_fat32.h: ..\boot\b_fat32.bin bin2c.com .\bin2c ..\boot\b_fat32.bin b_fat32.h b_fat32 prf.obj: ..\kernel\prf.c - $(CC) $(CFLAGS) -c ..\kernel\prf.c + $(CC) $(CFLAGS) ..\kernel\prf.c fdkrncfg.obj: fdkrncfg.c ..\hdr\kconfig.h sys.com: $(SYS_EXE_dependencies) - $(CC) $(CFLAGST) $(SYS_EXE_dependencies) + $(CL) $(CFLAGST) $(TINY) $(SYS_EXE_dependencies) clobber: clean -$(RM) bin2c.com sys.com b_fat12.h b_fat16.h b_fat32.h @@ -52,11 +49,8 @@ clean: -$(RM) *.obj *.bak *.crf *.xrf *.map *.lst *.las *.cod *.err status.me # *Individual File Dependencies* -bin2c.obj: bin2c.c - $(CC) $(CFLAGS) -c $*.c - sys.obj: sys.c ..\hdr\portab.h ..\hdr\device.h b_fat12.h b_fat16.h b_fat32.h - $(CC) $(CFLAGS) -c $*.c + $(CC) $(CFLAGS) $*.c # Log: makefile,v # diff --git a/utils/makefile b/utils/makefile index 6a18eaee..de2c2b4b 100644 --- a/utils/makefile +++ b/utils/makefile @@ -2,17 +2,17 @@ CFLAGS = -I$(INCLUDEPATH) -I..\hdr -production: patchobj.exe exeflat.exe +production: patchobj.com exeflat.exe -patchobj.exe: patchobj.c - $(CC) $(CFLAGST) $(CFLAGS) patchobj.c +patchobj.com: patchobj.c + $(CL) $(CFLAGST) $(TINY) $(CFLAGS) patchobj.c exeflat.exe: exeflat.c ..\hdr\exe.h - $(CC) $(CFLAGSC) $(CFLAGS) exeflat.c + $(CL) $(CFLAGSC) $(CFLAGS) exeflat.c clobber: clean - $(RM) bin2c.com exeflat.exe patchobj.exe patchobj.com + $(RM) bin2c.com exeflat.exe patchobj.com clean: $(RM) *.obj *.bak *.crf *.xrf *.map *.lst *.las *.cod *.err status.me From cbad615e0b12cddb7c12564ef8a7c189b4eb9e2f Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Fri, 2 Aug 2002 22:27:58 +0000 Subject: [PATCH 132/671] Enable LBA booting for FAT16 and workaround for floppies where DL is not passed. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@397 6ac86273-5f31-0410-b378-82cca8765d1b --- boot/boot.asm | 92 ++++++++++++++++++++++++++++++++++++++++++++------- sys/sys.c | 6 ++++ 2 files changed, 86 insertions(+), 12 deletions(-) diff --git a/boot/boot.asm b/boot/boot.asm index 8ff7296f..d6d393e6 100644 --- a/boot/boot.asm +++ b/boot/boot.asm @@ -178,15 +178,21 @@ Entry: jmp short real_start ; ENTRY ;----------------------------------------------------------------------- -real_start: cli - cld +real_start: cli + cld xor ax, ax - mov ss, ax ; initialize stack + mov ss, ax ; initialize stack mov ds, ax - mov bp, 0x7c00 - lea sp, [bp-0x20] - sti - int 0x13 ; reset drive + mov bp, 0x7c00 + lea sp, [bp-0x20] + sti + cmp byte [drive], 0xff ; BIOS bug ?? + jne dont_use_dl + mov [drive], dl ; BIOS passes drive number in DL + ; a reset should not be needed here +dont_use_dl: +; int 0x13 ; reset drive + ; int 0x12 ; get memory available in AX ; mov ax, 0x01e0 ; mov cl, 6 ; move boot sector to higher memory @@ -203,10 +209,9 @@ real_start: cli cont: mov ds, ax mov ss, ax - mov [drive], dl ; BIOS passes drive number in DL call print - db "Loading FreeDOS ",0 + db "FreeDOS",0 %ifdef CALCPARAMS GETDRIVEPARMS @@ -337,7 +342,8 @@ finished: ; Mark end of FAT chain with 0, so we have a single pop ds call print - db " KERNEL",0 + db " Kernel",0 ; "KERNEL" + ; loadFile: Loads the file into memory, one cluster at a time. @@ -403,6 +409,64 @@ readDisk: push si read_next: push dx push ax +;******************** LBA_READ ******************************* + + ; check for LBA support + push bx + + mov ah,041h ; + mov bx,055aah ; + mov dl, [drive] + int 0x13 + jc read_normal_BIOS + + sub bx,0aa55h + jne read_normal_BIOS + + shr cx,1 ; CX must have 1 bit set + jnc read_normal_BIOS + + ; OK, drive seems to support LBA addressing + + lea si,[LBA_DISK_PARAMETER_BLOCK] + + ; setup LBA disk block + mov [si+12],bx + mov [si+14],bx + + pop bx + + pop ax + pop dx + push dx + push ax + mov [si+ 8],ax + mov [si+10],dx + mov [si+4],bx + mov [si+6],es + + + mov ah,042h + jmp short do_int13_read + +LBA_DISK_PARAMETER_BLOCK: + db 10h ; constant size of block + db 0 + dw 1 ; 1 sector read + ; and overflow into code !!! + + + +read_normal_BIOS: + pop bx + + pop ax + pop dx + push dx + push ax +;******************** END OF LBA_READ ************************ + + ; ; translate sector number to BIOS parameters ; @@ -480,14 +544,18 @@ ax_min_2: push ax pop ax %else mov ax, 0x0201 +do_int13_read: mov dl, [drive] int 0x13 %endif + +read_finished: jnc read_ok ; jump if no error xor ah, ah ; else, reset floppy int 0x13 pop ax pop dx ; and... +read_next_chained: jmp short read_next ; read the same sector again read_ok: @@ -512,10 +580,10 @@ no_incr_es: pop ax sub di,si ; if there is anything left to read, jg read_next ; continue %else - add ax, 1 + add ax, byte 1 adc dx, byte 0 ; DX:AX = next sector to read dec di ; if there is anything left to read, - jnz read_next ; continue + jnz read_next_chained ; continue %endif clc diff --git a/sys/sys.c b/sys/sys.c index f26a4563..45f243d8 100644 --- a/sys/sys.c +++ b/sys/sys.c @@ -622,6 +622,9 @@ VOID put_boot(COUNT drive, BYTE * bsFile, BOOL both) temp = bs32->sysFatSecMask + 1; for (bs32->sysFatSecShift = 0; temp != 1; bs32->sysFatSecShift++, temp >>= 1) ; + + /* use fixed drive for A:, B: and DL otherwise */ + bs32->bsDriveNumber = drive < 2 ? 0 : 0xff; } #ifdef DEBUG if (fs == 32) @@ -656,6 +659,9 @@ VOID put_boot(COUNT drive, BYTE * bsFile, BOOL both) /* sector data starts on */ temp = temp + bs->sysRootDirSecs; bs->sysDataStart = temp; + + /* use fixed BIOS drive 0 for A:, B: and DL otherwise */ + bs32->bsDriveNumber = drive < 2 ? 0 : 0xff; } #ifdef DEBUG From 93bc26d0d51be74358d51ac850b6a031255409eb Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sat, 3 Aug 2002 01:48:49 +0000 Subject: [PATCH 133/671] Added more functions (memchr, memcmp, strcmp) to asmsupt.asm. Removed strncpy git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@398 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/asmsupt.asm | 118 +++++++++++++++++++++++++++++++++++++++------ kernel/dosfns.c | 4 +- kernel/fatfs.c | 7 --- kernel/newstuff.c | 4 +- 4 files changed, 109 insertions(+), 24 deletions(-) diff --git a/kernel/asmsupt.asm b/kernel/asmsupt.asm index 5a1abd0a..5174f827 100644 --- a/kernel/asmsupt.asm +++ b/kernel/asmsupt.asm @@ -47,20 +47,25 @@ segment HMA_TEXT ; ; currently done: ; +; fmemcpyBack(void FAR *dest, void FAR *src, int count) ; memcpy(void *dest, void *src, int count) ; fmemcpy(void FAR *dest, void FAR *src, int count) -; _fmemcpy(void FAR *dest, void FAR *src, int count) +; memset(void *dest, int ch, int count); ; fmemset(void FAR *dest, int ch, int count); ; fstrncpy(void FAR*dest, void FAR *src, int count); ; strcpy (void *dest, void *src); ; fstrcpy (void FAR*dest, void FAR *src, int count); ; strlen (void *dest); ; fstrlen (void FAR*dest); -; strchr (BYTE *src , BYTE ch); +; fmemchr (BYTE FAR *src , int ch); +; fstrchr (BYTE FAR *src , int ch); +; strchr (BYTE *src , int ch); ; fstrcmp (BYTE FAR *s1 , BYTE FAR *s2); ; strcmp (BYTE *s1 , BYTE *s2); ; fstrncmp(BYTE FAR *s1 , BYTE FAR *s2, int count); ; strncmp(BYTE *s1 , BYTE *s2, int count); +; fmemcmp(BYTE FAR *s1 , BYTE FAR *s2, int count); +; memcmp(BYTE *s1 , BYTE *s2, int count); ;*********************************************** ; common_setup - set up the standard calling frame for C-functions @@ -116,15 +121,17 @@ domemcpy: ; whenever possible. shr cx,1 rep movsw - jnc common_return + jnc memcpy_return movsb +memcpy_return: + cld ; ; common_return - pop saved registers and do return ; common_return: - pop ds + pop ds pop es pop di pop si @@ -136,11 +143,15 @@ common_return: ;************************************************************ ; ; VOID fmemcpy(REG BYTE FAR *d, REG BYTE FAR *s,REG COUNT n); +; VOID fmemcpyBack(REG BYTE FAR *d, REG BYTE FAR *s,REG COUNT n); ; - global __fmemcpy global _fmemcpy +%if 0 + global _fmemcpyBack +_fmemcpyBack: + std ; force to copy the string in reverse order +%endif _fmemcpy: -__fmemcpy: call common_setup ; Get the far source pointer, s @@ -205,7 +216,7 @@ _memset: ;*************************************************************** - +%if 0 global _fstrncpy _fstrncpy: call common_setup @@ -233,7 +244,7 @@ store_one_byte: xor al,al stosb jmp short common_return - +%endif ;***************************************************************** @@ -270,7 +281,7 @@ strcpy_loop: test al,al jne strcpy_loop - jmp short common_return + jmp short common_return ;****************************************************************** @@ -319,14 +330,56 @@ strchr_loop: test al,al jne strchr_loop - mov si,1 ; return NULL if not found +strchr_retzero: + xor ax, ax ; return NULL if not found + mov dx, ax ; for fstrchr() + jmp common_return + strchr_found: - mov ax,si + mov ax, si + mov dx, ds ; for fstrchr() +strchr_found1: dec ax jmp common_return +;****** +%if 0 + global _fmemchr +_fmemchr: + call common_setup + + ; Get the source pointer, ss + les di, [bp+4] + + ; and the search value + mov al, [bp+8] + + ; and the length + mov cx, [bp+10] + + repne scasb + jne strchr_retzero + mov dx, es + mov ax, di + dec ax + jmp short strchr_found1 +%endif + + global _fstrchr +_fstrchr: + call common_setup + + ; Get the source pointer, ss + lds si, [bp+4] + + ; and the destination pointer, d + mov bx, [bp+8] + + jmp short strchr_loop + ;********************************************************************** +%if 0 global _fstrcmp _fstrcmp: call common_setup @@ -337,7 +390,7 @@ _fstrcmp: ; and the destination pointer, d les di,[bp+8] - jmp dostrcmp + jmp short dostrcmp ;****** global _strcmp @@ -395,14 +448,51 @@ strncmp_loop: jne strncmp_done test al,al loopne strncmp_loop +%endif strncmp_retzero: xor ax, ax jmp short strncmp_done2 strncmp_done: - sbb ax,ax - or al,1 + lahf + ror ah,1 strncmp_done2: jmp common_return + +;********************************************************************** + global _fmemcmp +_fmemcmp: + call common_setup + + ; Get the source pointer, ss + lds si,[bp+4] + + ; and the destination pointer, d + les di,[bp+8] + + ; the length + mov cx, [bp+12] + + jmp short domemcmp + +;****** + global _memcmp +_memcmp: + call common_setup + + ; Get the source pointer, ss + ;mov si,[bp+6] + + ; and the destination pointer, d + ;mov di,[bp+4] + ;mov cx,[bp+8] + xchg si,di + +domemcmp: + jcxz strncmp_retzero + repe cmpsb + jne strncmp_done + jmp short strncmp_retzero + ; Log: asmsupt.asm,v ; ; Revision 1.3 1999/08/10 17:57:12 jprice diff --git a/kernel/dosfns.c b/kernel/dosfns.c index 371297f1..06194d17 100644 --- a/kernel/dosfns.c +++ b/kernel/dosfns.c @@ -1178,6 +1178,8 @@ COUNT DosGetCuDir(UBYTE drive, BYTE FAR * s) } current_ldt = &CDSp->cds_table[drive]; + /* ensure termination of fstrcpy */ + cp[MAX_CDSPATH - 1] = '\0'; if ((current_ldt->cdsFlags & CDSNETWDRV) == 0) { @@ -1192,7 +1194,7 @@ COUNT DosGetCuDir(UBYTE drive, BYTE FAR * s) if (*cp == '\0') s[0] = '\0'; else - fstrncpy(s, cp + 1, 64); + fstrcpy(s, cp + 1, 64); return SUCCESS; } diff --git a/kernel/fatfs.c b/kernel/fatfs.c index c2b1228c..8a032933 100644 --- a/kernel/fatfs.c +++ b/kernel/fatfs.c @@ -229,13 +229,6 @@ f_node_ptr split_path(BYTE * path, BYTE * fname, BYTE * fext) } cdsp = &CDSp->cds_table[nDrive]; - /* If the path is null, we to default to the current */ - /* directory... */ - if (!szDirName[2]) - { - fstrncpy(szDirName, cdsp->cdsCurrentPath, PARSE_MAX); - } - /* 11/29/99 jt * Networking and Cdroms. You can put in here a return. * Maybe a return of 0xDEADBEEF or something for Split or Dir_open. diff --git a/kernel/newstuff.c b/kernel/newstuff.c index 1bab38f0..2d3cc759 100644 --- a/kernel/newstuff.c +++ b/kernel/newstuff.c @@ -249,7 +249,7 @@ COUNT truename(char FAR * src, char FAR * dest, COUNT t) current_ldt = &CDSp->cds_table[i]; /* Always give the redirector a chance to rewrite the filename */ - fstrncpy(bufp - 1, src, sizeof(buf) - (bufp - buf)); + fmemcpy(bufp - 1, src, sizeof(buf) - (bufp - buf)); if ((t == FALSE) && (QRemote_Fn(buf, dest) == SUCCESS) && (dest[0] != '\0')) { @@ -261,7 +261,7 @@ COUNT truename(char FAR * src, char FAR * dest, COUNT t) } if (t == FALSE) { - fstrncpy(buf, current_ldt->cdsCurrentPath, current_ldt->cdsJoinOffset); + fmemcpy(buf, current_ldt->cdsCurrentPath, current_ldt->cdsJoinOffset); bufp = buf + current_ldt->cdsJoinOffset; rootEndPos = current_ldt->cdsJoinOffset; /* renamed x to rootEndPos - Ron Cemer */ *bufp++ = '\\'; From 0cdcac335965b349268c3ae2938bdb52306dd1c7 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sat, 3 Aug 2002 01:51:15 +0000 Subject: [PATCH 134/671] Fix small typo in fstrcpy git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@399 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/dosfns.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/dosfns.c b/kernel/dosfns.c index 06194d17..0533e585 100644 --- a/kernel/dosfns.c +++ b/kernel/dosfns.c @@ -1194,7 +1194,7 @@ COUNT DosGetCuDir(UBYTE drive, BYTE FAR * s) if (*cp == '\0') s[0] = '\0'; else - fstrcpy(s, cp + 1, 64); + fstrcpy(s, cp + 1); return SUCCESS; } From 0bd919fdd4e3aa680cf2e3616dab1dcb75eabaa9 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sat, 3 Aug 2002 01:54:43 +0000 Subject: [PATCH 135/671] Fixed a typo and disabled fatal() git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@400 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/break.c | 2 +- kernel/error.c | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/kernel/break.c b/kernel/break.c index c9e1c555..c41b72b6 100644 --- a/kernel/break.c +++ b/kernel/break.c @@ -44,7 +44,7 @@ static BYTE *RcsId = * Two sources are available: * 1) flag at 40:71 bit 7 - * 2) STDIN str‘am via con_break() + * 2) STDIN stream via con_break() */ int control_break(void) { diff --git a/kernel/error.c b/kernel/error.c index cbfdd09c..8139f0fe 100644 --- a/kernel/error.c +++ b/kernel/error.c @@ -64,12 +64,13 @@ VOID fatal(BYTE * err_msg) } #else /* issue an internal error message */ +#if 0 VOID fatal(BYTE * err_msg) { printf("\nInternal kernel error - \n"); panic(err_msg); } - +#endif #endif /* Abort, retry or fail for character devices */ From 00258e0fb0db77756342893c1320e5118fd3ceaa Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sat, 3 Aug 2002 01:59:21 +0000 Subject: [PATCH 136/671] Fix prototypes and cleanup support functions a little bit. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@401 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/misc.c | 27 +++++++++++++++++---------- kernel/nls.c | 2 +- kernel/nls_load.c | 37 ++++++++++++++++++------------------- kernel/strings.c | 41 ++++++++++++++++++++++++++++------------- kernel/syspack.c | 6 ++---- 5 files changed, 66 insertions(+), 47 deletions(-) diff --git a/kernel/misc.c b/kernel/misc.c index c5f602e6..e056a702 100644 --- a/kernel/misc.c +++ b/kernel/misc.c @@ -36,40 +36,47 @@ static BYTE *miscRcsId = #include "globals.h" #ifndef I86 -VOID strcpy(REG BYTE * d, REG BYTE * s) +char *strcpy(REG BYTE * d, REG CONST BYTE * s) { - while (*s) - *d++ = *s++; - *d = '\0'; + char *tmp = d; + + while ((*d++ = *s++) != '\0') + ; + + return tmp; } -VOID fstrcpy(REG BYTE FAR * d, REG BYTE FAR * s) +VOID fstrcpy(REG BYTE FAR * d, REG CONST BYTE FAR * s) { while (*s) *d++ = *s++; *d = '\0'; } -VOID fstrncpy(BYTE FAR * d, BYTE FAR * s, REG COUNT n) +VOID fstrncpy(BYTE FAR * d, BYTE CONST FAR * s, REG size_t n) { while (*s && n--) *d++ = *s++; *d = '\0'; } -VOID memcpy(REG VOID * d, REG VOID * s, REG COUNT n) +VOID * memcpy(REG VOID * d, REG CONST VOID * s, REG size_t n) { + char *cd = d; + CONST char *cs = s; + while (n--) - *d++ = *s++; + *cd++ = *cs++; + return d; } -VOID fmemcpy(REG VOID FAR * d, REG VOID FAR * s, REG COUNT n) +VOID fmemcpy(REG VOID FAR * d, REG CONST VOID FAR * s, REG size_t n) { while (n--) *((BYTE FAR *) d)++ = *((BYTE FAR *) s)++; } -VOID fmemset(REG VOID FAR * s, REG int ch, REG COUNT n) +VOID fmemset(REG VOID FAR * s, REG int ch, REG size_t n) { while (n--) *((BYTE FAR *) s)++ = ch; diff --git a/kernel/nls.c b/kernel/nls.c index 28de4545..80ec6416 100644 --- a/kernel/nls.c +++ b/kernel/nls.c @@ -586,7 +586,7 @@ COUNT DosSetCountry(UWORD cntry) /* * Called for DOS-66-01 get CP */ -COUNT DosGetCodepage(UWORD FAR * actCP, UWORD FAR * sysCP) +COUNT DosGetCodepage(UWORD * actCP, UWORD * sysCP) { *sysCP = nlsInfo.sysCodePage; *actCP = nlsInfo.actPkg->cp; diff --git a/kernel/nls_load.c b/kernel/nls_load.c index add643a2..6ab83106 100644 --- a/kernel/nls_load.c +++ b/kernel/nls_load.c @@ -29,9 +29,8 @@ /****************************************************************/ #include "portab.h" -#include "globals.h" +#include "init-mod.h" //#include "pcb.h" -#include #ifdef VERSION_STRINGS static BYTE *RcsId = @@ -49,9 +48,9 @@ STATIC int err(void) } #define readStruct(s) readStructure(&(s), sizeof(s), fd) -STATIC int readStructure(void *buf, int size, COUNT fd) +STATIC int readStructure(void *buf, unsigned size, COUNT fd) { - if (DosRead(fd, buf, size) == size) + if (read(fd, buf, size) == size) return 1; return err(); @@ -61,15 +60,15 @@ STATIC int readStructure(void *buf, int size, COUNT fd) #define readFct(p,f) readFct_((p), (f), fd) int readFct_(void *buf, struct csys_function *fct, COUNT fd) { - if (DosLseek(fd, fct->csys_rpos, 0) >= 0) + if (lseek(fd, fct->csys_rpos, 0) >= 0) return readStructure(buf, fct->csys_length, fd); return err(); } #define seek(n) rseek((LONG)(n), fd) -static rseek(LONG rpos, COUNT fd) +static int rseek(LONG rpos, COUNT fd) { - if (DosLseek(fd, rpos, 1) >= 0) + if (lseek(fd, rpos, 1) >= 0) return 1; return err(); @@ -80,20 +79,20 @@ COUNT csysOpen(void) COUNT fd; struct nlsCSys_fileHeader header; - if ((fd = DosOpen((BYTE FAR *) filename, 0)) < 0) + if ((fd = open(filename, 0)) < 0) { printf("Cannot open: \"%s\"\n", filename); return 1; } - if (DosRead(fd, &header, sizeof(header)) != sizeof(header); + if ((read(fd, &header, sizeof(header)) != sizeof(header)) ||strcmp(header.csys_idstring, CSYS_FD_IDSTRING) != 0 - || DosLseek(fd, (LONG) sizeof(csys_completeFileHeader), 0) - != (LONG) sizeof(csys_completeFileHeader)) + || lseek(fd, (LONG) sizeof(struct csys_completeFileHeader), 0) + != (LONG) sizeof(struct csys_completeFileHeader)) { printf("No valid COUNTRY.SYS: \"%s\"\n\nTry NLSFUNC /i %s\n", filename, filename); - DosClose(fd); + close(fd); return -1; } @@ -115,9 +114,9 @@ STATIC int chkTable(int idx, int fctID, struct csys_function *fcts, if (i == idx) /* already best place */ return 1; /* Swap both places */ - memcpy(&hfct, fct, sizeof(hfct)); - memcpy(fct, &fcts[idx], sizeof(hfct)); - memcpy(&fcts[idx], &hfct, sizeof(hfct)); + fmemcpy(&hfct, fct, sizeof(hfct)); + fmemcpy(fct, &fcts[idx], sizeof(hfct)); + fmemcpy(&fcts[idx], &hfct, sizeof(hfct)); return 1; } @@ -266,7 +265,7 @@ int csysLoadPackage(COUNT fd) } } /* Search if the subfunction is already there */ - for (j = 0; j < numFcts && fcts[j].csys_fctID != fct.csys_fctID; + for (j = 0; j < numFct && fcts[j].csys_fctID != fct.csys_fctID; ++j) ; if (j != numFct) { @@ -304,7 +303,7 @@ int csysLoadPackage(COUNT fd) one additional byte is required by table 1, but which is already within totalSize as the length of pseudo-table 0x23 has been counted. */ - nls = KernelAlloc((data = sizeof(nlsPackage) + nls = KernelAlloc((data = sizeof(struct nlsPackage) + (numFct - 3) * sizeof(struct nlsPointer)) + totalSize); /* data := first byte not used by the control area of @@ -388,7 +387,7 @@ int csysLoadPackage(COUNT fd) return 0; } -INIT BOOL LoadCountryInfo(char *fnam) +BOOL LoadCountryInfo(char *fnam) { COUNT fd; int rc; @@ -399,7 +398,7 @@ INIT BOOL LoadCountryInfo(char *fnam) if ((fd = csysOpen()) >= 0) { rc = csysLoadPackage(fd); - DosClose(fd); + close(fd); return rc; } } diff --git a/kernel/strings.c b/kernel/strings.c index 3c69f1aa..349f9368 100644 --- a/kernel/strings.c +++ b/kernel/strings.c @@ -34,18 +34,18 @@ static BYTE *stringsRcsId = #endif #ifndef I86 -COUNT strlen(REG BYTE * s) +size_t strlen(REG CONST BYTE * s) { - REG WORD cnt = 0; + REG size_t cnt = 0; while (*s++ != 0) ++cnt; return cnt; } -COUNT fstrlen(REG BYTE FAR * s) +size_t fstrlen(REG CONST BYTE FAR * s) { - REG WORD cnt = 0; + REG size_t cnt = 0; while (*s++ != 0) ++cnt; @@ -59,15 +59,17 @@ VOID _fstrcpy(REG BYTE FAR * d, REG BYTE FAR * s) *d = 0; } -VOID strncpy(REG BYTE * d, REG BYTE * s, COUNT l) +char *strncpy(register char *d, register const char *s, size_t l) { - COUNT idx = 1; + size_t idx = 1; + char *tmp = d; while (*s != 0 && idx++ <= l) *d++ = *s++; *d = 0; + return tmp; } -COUNT strcmp(REG BYTE * d, REG BYTE * s) +int strcmp(REG CONST BYTE * d, REG CONST BYTE * s) { while (*s != '\0' && *d != '\0') { @@ -91,9 +93,9 @@ COUNT fstrcmp(REG BYTE FAR * d, REG BYTE FAR * s) return *d - *s; } -COUNT strncmp(REG BYTE * d, REG BYTE * s, COUNT l) +int strncmp(register const char *d, register const char *s, size_t l) { - COUNT index = 1; + size_t index = 1; while (*s != '\0' && *d != '\0' && index++ <= l) { if (*d == *s) @@ -125,14 +127,27 @@ VOID fstrncpy(REG BYTE FAR * d, REG BYTE FAR * s, COUNT l) *d = 0; } -BYTE *strchr(BYTE * s, BYTE c) +char *strchr(const char * s, int c) { - REG BYTE *p; + REG CONST BYTE *p; p = s - 1; do { - if (*++p == c) - return p; + if (*++p == (char)c) + return (char *)p; + } + while (*p); + return 0; +} + +void *memchr(const void * s, int c) +{ + REG unsigned char *p; + p = (unsigned char *)s - 1; + do + { + if (*++p == (unsigned char)c) + return (void *)p; } while (*p); return 0; diff --git a/kernel/syspack.c b/kernel/syspack.c index 681b0c33..40b967e4 100644 --- a/kernel/syspack.c +++ b/kernel/syspack.c @@ -97,8 +97,7 @@ VOID fputbyte(VOID FAR * vp, UBYTE b) VOID getdirent(UBYTE FAR * vp, struct dirent FAR * dp) { - fmemcpy(dp->dir_name, &vp[DIR_NAME], FNAME_SIZE); - fmemcpy(dp->dir_ext, &vp[DIR_EXT], FEXT_SIZE); + fmemcpy(dp->dir_name, &vp[DIR_NAME], FNAME_SIZE + FEXT_SIZE); dp->dir_attrib = fgetbyte(&vp[DIR_ATTRIB]); dp->dir_time = fgetword(&vp[DIR_TIME]); dp->dir_date = fgetword(&vp[DIR_DATE]); @@ -111,8 +110,7 @@ VOID putdirent(struct dirent FAR * dp, UBYTE FAR * vp) REG COUNT i; REG BYTE FAR *p; - fmemcpy(&vp[DIR_NAME], dp->dir_name, FNAME_SIZE); - fmemcpy(&vp[DIR_EXT], dp->dir_ext, FEXT_SIZE); + fmemcpy(&vp[DIR_NAME], dp->dir_name, FNAME_SIZE + FEXT_SIZE); fputbyte(&vp[DIR_ATTRIB], dp->dir_attrib); fputword(&vp[DIR_TIME], dp->dir_time); fputword(&vp[DIR_DATE], dp->dir_date); From 17d50fff3b9ce81003a923f915f12ae471b0083a Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sat, 3 Aug 2002 02:02:15 +0000 Subject: [PATCH 137/671] Disable the A20 line upon exec (int21/ah=4B). This is necessary for some brain-dead exepacked programs. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@402 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/kernel.asm | 36 ++++++++++++++++++++++++++++-------- kernel/procsupt.asm | 3 ++- 2 files changed, 30 insertions(+), 9 deletions(-) diff --git a/kernel/kernel.asm b/kernel/kernel.asm index 610d8a83..030937ed 100644 --- a/kernel/kernel.asm +++ b/kernel/kernel.asm @@ -574,6 +574,15 @@ _prev_user_r: prev_int21regs_off dw 0 ;2D0 - pointer to prev int 21 frame prev_int21regs_seg dw 0 + ; Pad to 02ddh + times (2ddh - ($ - _internal_data)) db 0 + global _ext_open_action + global _ext_open_attrib + global _ext_open_mode +_ext_open_action dw 0 ;2DD - extended open action +_ext_open_attrib dw 0 ;2DF - extended open attrib +_ext_open_mode dw 0 ;2E1 - extended open mode + ; Pad to 0620h times (300h - ($ - _internal_data)) db 0 global _szNames @@ -883,14 +892,7 @@ forceEnableA20retry: ; ; ok, we have to enable A20 )at least seems so ; - ; some debug first - ; push bx - ; mov ah, 0eh - ; mov al, 'H' - ; mov bx, 0007h - ; int 10h - ; pop bx - + call far __EnableA20 jmp short forceEnableA20retry @@ -903,9 +905,27 @@ forceEnableA20success: pop ds ret +; +; global f*cking compatibility issues: +; +; very old brain dead software (PKLITE, copyright 1990) +; forces us to execute with A20 disabled +; +global _ExecUserDisableA20 +_ExecUserDisableA20: + cmp word [cs:_XMSDriverAddress],0 + jne NeedToDisable + cmp word [cs:_XMSDriverAddress+2],0 + je noNeedToDisable +NeedToDisable: + push ax + call far __DisableA20 + pop ax +noNeedToDisable: + iret segment _TEXT diff --git a/kernel/procsupt.asm b/kernel/procsupt.asm index f89c7e5a..582b1b86 100644 --- a/kernel/procsupt.asm +++ b/kernel/procsupt.asm @@ -67,7 +67,8 @@ _exec_user: sti ; POP$ALL - iret + extern _ExecUserDisableA20 + jmp far _ExecUserDisableA20 segment _TEXT From c6aa00cce56caf4d2259c8454f8cb339979c1c39 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sat, 3 Aug 2002 02:13:51 +0000 Subject: [PATCH 138/671] Remove unnecessary buffer fields and clean-up prototypes. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@403 6ac86273-5f31-0410-b378-82cca8765d1b --- hdr/buffer.h | 17 +---------------- kernel/blockio.c | 33 ++++++++++++++++++--------------- kernel/config.c | 43 ++++++++++++++++++------------------------- 3 files changed, 37 insertions(+), 56 deletions(-) diff --git a/hdr/buffer.h b/hdr/buffer.h index 2cfe1adb..0d641ea4 100644 --- a/hdr/buffer.h +++ b/hdr/buffer.h @@ -45,25 +45,10 @@ struct buffer { BYTE b_unit; /* disk for this buffer */ BYTE b_flag; /* buffer flags */ ULONG b_blkno; /* block for this buffer */ - /* DOS-C: 0xffff for huge block numbers */ - BYTE b_copies; /* number of copies to write */ -#ifdef WITHFAT32 - ULONG b_offset; /* span between copies */ -#else - UWORD b_offset; /* span between copies */ -#endif -#if 0 /*TE*/ - union { - struct dpb FAR *_b_dpbp; /* pointer to DPB */ - LONG _b_huge_blkno; /* DOS-C: actual block number if >= 0xffff */ - } _b; -#endif + struct dpb FAR *b_dpbp; /* pointer to DPB */ UBYTE b_buffer[BUFFERSIZE]; /* 512 byte sectors for now */ }; -#define b_dpbp _b._b_dpbp -#define b_huge_blkno _b._b_huge_blkno - #define BFR_UNCACHE 0x80 /* indication, not really used */ #define BFR_DIRTY 0x40 /* buffer modified */ #define BFR_VALID 0x20 /* buffer contains valid data */ diff --git a/kernel/blockio.c b/kernel/blockio.c index 0b5e172a..1add9dc5 100644 --- a/kernel/blockio.c +++ b/kernel/blockio.c @@ -201,6 +201,7 @@ BOOL DeleteBlockInBufferCache(ULONG blknolow, ULONG blknohigh, COUNT dsk) return FALSE; } +#if TOM void dumpBufferCache(void) { struct buffer FAR *bp; @@ -217,7 +218,7 @@ void dumpBufferCache(void) } printf("\n"); } - +#endif /* */ /* Return the address of a buffer structure containing the */ /* requested block. */ @@ -347,13 +348,22 @@ BOOL flush1(struct buffer FAR * bp) result = dskxfer(bp->b_unit, getblkno(bp), (VOID FAR *) bp->b_buffer, 1, DSKWRITE); /* BER 9/4/00 */ if (bp->b_flag & BFR_FAT) { - int i = bp->b_copies; + struct dpb FAR *dpbp = bp->b_dpbp; + UWORD b_copies = dpbp->dpb_fats; + ULONG b_offset = dpbp->dpb_fatsize; ULONG blkno = getblkno(bp); - - while (--i > 0) +#ifdef WITHFAT32 + if (ISFAT32(dpbp)) + { + if (dpbp->dpb_xflags & FAT_NO_MIRRORING) + b_copies = 1; + b_offset = dpbp->dpb_xfatsize; + } +#endif + while (--b_copies > 0) { - blkno += bp->b_offset; - result = dskxfer(bp->b_unit, blkno, (VOID FAR *) bp->b_buffer, 1, DSKWRITE); /* BER 9/4/00 */ + blkno += b_offset; + result = dskxfer(bp->b_unit, blkno, bp->b_buffer, 1, DSKWRITE); /* BER 9/4/00 */ } } } @@ -412,7 +422,7 @@ UWORD dskxfer(COUNT dsk, ULONG blkno, VOID FAR * buf, UWORD numblocks, { return 0x0201; /* illegal command */ } - if (!(CDSp->cds_table[dsk].cdsFlags & CDSPHYSDRV)) + if ((CDSp->cds_table[dsk].cdsFlags & (CDSPHYSDRV | CDSNETWDRV)) != CDSPHYSDRV) { return 0x0201; /* illegal command */ } @@ -480,13 +490,6 @@ UWORD dskxfer(COUNT dsk, ULONG blkno, VOID FAR * buf, UWORD numblocks, if (mode >= DSKWRITEINT26) return (IoReqHdr.r_status); -/* Changed 9/4/00 BER - return (IoReqHdr.r_status); -*/ - - /* Skip the abort, retry, fail code...it needs fixed...BER */ -/* End of change */ - loop: switch (block_error(&IoReqHdr, dpbp->dpb_unit, dpbp->dpb_device)) { @@ -503,7 +506,7 @@ UWORD dskxfer(COUNT dsk, ULONG blkno, VOID FAR * buf, UWORD numblocks, default: goto loop; } - + break; } /* retry loop */ /* *** Changed 9/4/00 BER */ return 0; /* Success! Return 0 for a successful operation. */ diff --git a/kernel/config.c b/kernel/config.c index 769d1c67..46df25d1 100644 --- a/kernel/config.c +++ b/kernel/config.c @@ -70,7 +70,7 @@ extern struct buffer FAR *DOSFAR ASM firstbuf; /* head of buffers linked li extern struct dpb FAR *DOSFAR ASM DPBp; /* First drive Parameter Block */ -extern cdstbl FAR *DOSFAR ASM CDSp; +extern struct cds FAR *DOSFAR ASM CDSp; /* Current Directory Structure */ extern sfttbl FAR *DOSFAR ASM sfthead; /* System File Table head */ @@ -116,7 +116,7 @@ BYTE FAR *lpBase = 0; BYTE FAR *upBase = 0; BYTE FAR *lpTop = 0; BYTE FAR *lpOldTop = 0; -STATIC COUNT nCfgLine = 0; +STATIC unsigned nCfgLine = 0; STATIC COUNT nPass = 0; COUNT UmbState = 0; STATIC BYTE szLine[256] = { 0 }; @@ -172,7 +172,7 @@ VOID config_init_buffers(COUNT anzBuffers); /* from BLOCKIO.C */ STATIC VOID FAR * AlignParagraph(VOID FAR * lpPtr); #ifndef I86 -#define AlignParagraph(x) (x) +#define AlignParagraph(x) ((VOID *)x) #endif #define EOF 0x1a @@ -221,10 +221,6 @@ STATIC struct table commands[] = { {"", -1, CfgFailure} }; -#ifndef KDB -BYTE FAR * KernelAlloc(WORD nBytes); -#endif - BYTE *pLineStart = 0; BYTE HMAState = 0; @@ -297,10 +293,9 @@ void PreConfig(void) sfthead->sftt_next->sftt_next = (sfttbl FAR *) - 1; sfthead->sftt_next->sftt_count = Config.cfgFiles - 5; - CDSp = (cdstbl FAR *) KernelAlloc(0x58 * lastdrive); + CDSp = KernelAlloc(sizeof(struct cds) * lastdrive); - DPBp = (struct dpb FAR *) - KernelAlloc(blk_dev.dh_name[0] * sizeof(struct dpb)); + DPBp = KernelAlloc(blk_dev.dh_name[0] * sizeof(struct dpb)); #ifdef DEBUG printf("Preliminary:\n f_node 0x%x", f_nodes); @@ -369,18 +364,16 @@ void PostConfig(void) /* sfthead = (sfttbl FAR *)&basesft; */ /* FCBp = (sfttbl FAR *)&FcbSft; */ - /* FCBp = (sfttbl FAR *) - KernelAlloc(sizeof(sftheader) + /* FCBp = KernelAlloc(sizeof(sftheader) + Config.cfgFiles * sizeof(sft)); */ - sfthead->sftt_next = (sfttbl FAR *) + sfthead->sftt_next = KernelAlloc(sizeof(sftheader) + (Config.cfgFiles - 5) * sizeof(sft)); sfthead->sftt_next->sftt_next = (sfttbl FAR *) - 1; sfthead->sftt_next->sftt_count = Config.cfgFiles - 5; - CDSp = (cdstbl FAR *) KernelAlloc(0x58 * lastdrive); + CDSp = KernelAlloc(sizeof(struct cds) * lastdrive); - DPBp = (struct dpb FAR *) - KernelAlloc(blk_dev.dh_name[0] * sizeof(struct dpb)); + DPBp = KernelAlloc(blk_dev.dh_name[0] * sizeof(struct dpb)); #ifdef DEBUG printf("Final: \n f_node 0x%x\n", f_nodes); @@ -428,7 +421,7 @@ VOID configDone(VOID) lastdrive + 'A', nblkdev + 'A' - 1)); lastdrive = nblkdev; - CDSp = (cdstbl FAR *) KernelAlloc(0x58 * lastdrive); + CDSp = KernelAlloc(sizeof(struct cds) * lastdrive); } first_mcb = FP_SEG(lpBase) + ((FP_OFF(lpBase) + 0x0f) >> 4); @@ -693,7 +686,7 @@ UWORD GetBiosKey(int timeout) if (timeout < 0) continue; - if (GetBiosTime() - startTime >= timeout * 18) + if (GetBiosTime() - startTime >= (unsigned)timeout * 18) break; } return 0xffff; @@ -836,7 +829,7 @@ STATIC VOID sysScreenMode(BYTE * pLine) _AX = (0x11 << 8) + nMode; _BL = 0; __int__(0x10); -#else +#elif defined(I86) asm { mov al, byte ptr nMode; @@ -1097,7 +1090,7 @@ STATIC VOID CfgBreak(BYTE * pLine) STATIC VOID Numlock(BYTE * pLine) { - extern VOID ASMCFUNC keycheck(); + extern VOID ASMCFUNC keycheck(void); /* Format: NUMLOCK = (ON | OFF) */ BYTE FAR *keyflags = (BYTE FAR *) MK_FP(0x40, 0x17); @@ -1220,7 +1213,7 @@ STATIC VOID CfgFailure(BYTE * pLine) } #ifndef KDB -BYTE FAR * KernelAlloc(WORD nBytes) +void FAR * KernelAlloc(size_t nBytes) { BYTE FAR *lpAllocated; @@ -1447,11 +1440,13 @@ STATIC VOID mumcb_init(UCOUNT seg, UWORD size) } #endif -VOID strcat(REG BYTE * d, REG BYTE * s) +char *strcat(register char * d, register const char * s) { + char *tmp = d; while (*d != 0) ++d; strcpy(d, s); + return tmp; } #if 0 @@ -1528,7 +1523,7 @@ VOID config_init_buffers(COUNT anzBuffers) pbuffer = firstbuf; - DebugPrintf(("init_buffers at")); + DebugPrintf(("init_buffers (size %u) at", sizeof(struct buffer))); for (i = 0;; ++i) { @@ -1539,8 +1534,6 @@ VOID config_init_buffers(COUNT anzBuffers) pbuffer->b_unit = 0; pbuffer->b_flag = 0; pbuffer->b_blkno = 0; - pbuffer->b_copies = 0; - pbuffer->b_offset = 0; pbuffer->b_next = NULL; DebugPrintf((" (%d,%p)", i, pbuffer)); From a1c16f81bd6993fe0d881bbd586590090dd42628 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sat, 3 Aug 2002 02:17:27 +0000 Subject: [PATCH 139/671] Fix init (config.c) prototypes. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@404 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/init-mod.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/kernel/init-mod.h b/kernel/init-mod.h index 82d94d50..b1d28b1c 100644 --- a/kernel/init-mod.h +++ b/kernel/init-mod.h @@ -21,7 +21,7 @@ #include "buffer.h" #include "dcb.h" -#include "KConfig.h" +#include "kconfig.h" extern struct _KernelConfig InitKernelConfig; /* @@ -34,6 +34,7 @@ extern struct _KernelConfig InitKernelConfig; #define execrh init_execrh #define fmemcpy init_fmemcpy #define fmemset init_fmemset +#define fmemcmp init_fmemcmp #define memset init_memset #define strcpy init_strcpy WORD ASMCFUNC execrh(request FAR *, struct dhdr FAR *); @@ -89,7 +90,7 @@ struct config { -- 2000/06/11 ska */ WORD cfgCSYS_cntry; /* country ID to be loaded */ - WORD cfgCSYS_cp; + UWORD cfgCSYS_cp; /* requested codepage; NLS_DEFAULT if default */ BYTE cfgCSYS_fnam[NAMEMAX]; /* filename of COUNTRY= */ @@ -108,7 +109,7 @@ extern struct config Config; VOID PreConfig(VOID); VOID DoConfig(int pass); VOID PostConfig(VOID); -BYTE FAR * KernelAlloc(WORD nBytes); +VOID FAR * KernelAlloc(size_t nBytes); BYTE * skipwh(BYTE * s); BYTE * scan(BYTE * s, BYTE * d); BOOL isnum(BYTE * pszString); @@ -116,8 +117,7 @@ BYTE * GetNumber(REG BYTE * pszString, REG COUNT * pnNum); COUNT tolower(COUNT c); COUNT toupper(COUNT c); VOID mcb_init(UCOUNT seg, UWORD size); -VOID strcat(REG BYTE * d, REG BYTE * s); -BYTE FAR * KernelAlloc(WORD nBytes); +char *strcat(char * d, const char * s); COUNT ASMCFUNC Umb_Test(void); COUNT ASMCFUNC UMB_get_largest(UCOUNT * seg, UCOUNT * size); BYTE * GetStringArg(BYTE * pLine, BYTE * pszString); @@ -159,8 +159,8 @@ VOID ASMCFUNC FAR int0_handler(void); VOID ASMCFUNC FAR int6_handler(void); VOID ASMCFUNC FAR empty_handler(void); VOID ASMCFUNC FAR got_cbreak(void); /* procsupt.asm */ -VOID ASMCFUNC FAR int20_handler(iregs UserRegs); -VOID ASMCFUNC FAR int21_handler(iregs UserRegs); +VOID ASMCFUNC FAR int20_handler(void); +VOID ASMCFUNC FAR int21_handler(void); VOID ASMCFUNC FAR int22_handler(void); VOID ASMCFUNC FAR int24_handler(void); VOID ASMCFUNC FAR low_int25_handler(void); From 0b5ac953f05f37f1d4745f8babe96ec5bc925d6a Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sat, 3 Aug 2002 02:20:07 +0000 Subject: [PATCH 140/671] Allow compilation with gcc (non-working result); define size_t. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@405 6ac86273-5f31-0410-b378-82cca8765d1b --- hdr/portab.h | 36 ++++++++++++++++++++++++++---------- 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/hdr/portab.h b/hdr/portab.h index e8d4ea8a..9f399aa7 100644 --- a/hdr/portab.h +++ b/hdr/portab.h @@ -91,15 +91,15 @@ void __int__(int); #define MC68K +#elif defined(__GNUC__) +/* for warnings only ! */ +#define MC68K + #else anyone knows a _portable_ way to create nice errors ? ? at least this causes the compiler not to compile : -) #endif - /* functions, that are shared between C and ASM _must_ - have a certain calling standard. These are declared - as 'ASMCFUNC', and is (and will be ?-) cdecl */ -#define ASMCFUNC cdecl -#define ASM ASMCFUNC + #ifdef MC68K #define far /* No far type */ #define interrupt /* No interrupt type */ @@ -107,11 +107,19 @@ anyone knows a _portable_ way to create nice errors ? ? #define FAR /* linear architecture */ #define NEAR /* " " */ #define INRPT interrupt -#define CONST #define REG register #define API int /* linear architecture */ #define NONNATIVE #define PARASIZE 4096 /* "paragraph" size */ +#define CDECL +#ifdef __GNUC__ +#define CONST const +#define PROTO +typedef __SIZE_TYPE__ size_t; +#else +#define CONST +typedef unsigned size_t; +#endif #endif #ifdef I86 #define VOID void @@ -123,7 +131,13 @@ anyone knows a _portable_ way to create nice errors ? ? #define API int far pascal /* segment architecture */ #define NATIVE #define PARASIZE 16 /* "paragraph" size */ +typedef unsigned size_t; #endif + /* functions, that are shared between C and ASM _must_ + have a certain calling standard. These are declared + as 'ASMCFUNC', and is (and will be ?-) cdecl */ +#define ASMCFUNC CDECL +#define ASM ASMCFUNC /* */ /* Boolean type & definitions of TRUE and FALSE boolean values */ /* */ @@ -199,7 +213,7 @@ typedef signed long LONG; #ifdef __WATCOMC__ #define MK_FP(seg,ofs) (((UWORD)(seg)):>((VOID *)(ofs))) #else -#define MK_FP(seg,ofs) ((VOID far *)(((ULONG)(seg)<<16)|(UWORD)(ofs))) +#define MK_FP(seg,ofs) ((void FAR *)(((ULONG)(seg)<<16)|(UWORD)(ofs))) #endif #define FP_SEG(fp) ((unsigned)(UWORD)((ULONG)(VOID FAR *)(fp)>>16)) #define FP_OFF(fp) ((unsigned)(UWORD)(fp)) @@ -207,12 +221,12 @@ typedef signed long LONG; #endif #ifdef MC68K -#define MK_FP(seg,ofs) ((VOID *)(&(((BYTE *)(seg))[(ofs)]))) +#define MK_FP(seg,ofs) ((VOID *)(&(((BYTE *)(size_t)(seg))[(ofs)]))) #define FP_SEG(fp) (0) -#define FP_OFF(fp) (fp) +#define FP_OFF(fp) ((size_t)(fp)) #endif -typedef VOID (FAR ASMCFUNC * intvec) (); +typedef VOID (FAR ASMCFUNC * intvec) (void); /* this suppresses the warning @@ -222,6 +236,8 @@ typedef VOID (FAR ASMCFUNC * intvec) (); #if defined(__TURBOC__) #define UNREFERENCED_PARAMETER(x) if (x); +#elif defined(__GNUC__) +#define UNREFERENCED_PARAMETER(x) x = 0; #else #define UNREFERENCED_PARAMETER(x) x; #endif From 8290c26aa358c2ad489750e132de1361132773bd Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sat, 3 Aug 2002 02:25:17 +0000 Subject: [PATCH 141/671] Inlined functions, fixed non-native bug and reduced buffer structure. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@406 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/fattab.c | 215 ++++++++++++++++++------------------------------ 1 file changed, 78 insertions(+), 137 deletions(-) diff --git a/kernel/fattab.c b/kernel/fattab.c index 4586b6b9..fed0c8fa 100644 --- a/kernel/fattab.c +++ b/kernel/fattab.c @@ -34,10 +34,6 @@ static BYTE *RcsId = "$Id$"; #endif -STATIC unsigned link_fat12(struct dpb FAR *, unsigned, unsigned); -STATIC unsigned link_fat16(struct dpb FAR *, unsigned, unsigned); -STATIC unsigned link_fat32(struct dpb FAR *, CLUSTER, CLUSTER); - /************************************************************************/ /* */ /* cluster/sector routines */ @@ -51,51 +47,41 @@ int ISFAT32(struct dpb FAR * dpbp) } #endif -struct buffer FAR *getFATblock(CLUSTER cluster, struct dpb FAR * dpbp) +struct buffer FAR *getFATblock(ULONG clussec, struct dpb FAR * dpbp) { - ULONG sector; struct buffer FAR *bp; if (ISFAT12(dpbp)) { - sector = ((cluster << 1) + cluster) >> 1; + clussec = (((unsigned)clussec << 1) + (unsigned)clussec) >> 1; } #ifdef WITHFAT32 else if (ISFAT32(dpbp)) { - sector = (ULONG) cluster *SIZEOF_CLST32; + clussec = clussec * SIZEOF_CLST32; } #endif else { - sector = (ULONG) cluster *SIZEOF_CLST16; + clussec = clussec * SIZEOF_CLST16; } - sector = sector / dpbp->dpb_secsize + dpbp->dpb_fatstrt; + clussec = clussec / dpbp->dpb_secsize + dpbp->dpb_fatstrt; #ifdef WITHFAT32 if (ISFAT32(dpbp) && (dpbp->dpb_xflags & FAT_NO_MIRRORING)) { /* we must modify the active fat, it's number is in the 0-3 bits of dpb_xflags */ - sector += (dpbp->dpb_xflags & 0xf) * dpbp->dpb_xfatsize; + clussec += (dpbp->dpb_xflags & 0xf) * dpbp->dpb_xfatsize; } #endif - bp = getblock(sector, dpbp->dpb_unit); + bp = getblock(clussec, dpbp->dpb_unit); if (bp) { bp->b_flag &= ~(BFR_DATA | BFR_DIR); bp->b_flag |= BFR_FAT | BFR_VALID; - bp->b_copies = dpbp->dpb_fats; - bp->b_offset = dpbp->dpb_fatsize; -#ifdef WITHFAT32 - if (ISFAT32(dpbp)) - { - if (dpbp->dpb_xflags & FAT_NO_MIRRORING) - bp->b_copies = 1; - bp->b_offset = dpbp->dpb_xfatsize; - } -#endif + bp->b_dpbp = dpbp; } return bp; } @@ -149,28 +135,88 @@ void write_fsinfo(struct dpb FAR * dpbp) unsigned link_fat(struct dpb FAR * dpbp, CLUSTER Cluster1, REG CLUSTER Cluster2) { - unsigned res; + struct buffer FAR *bp; + + /* Get the block that this cluster is in */ + bp = getFATblock(Cluster1, dpbp); + + if (bp == NULL) + return DE_BLKINVLD; if (ISFAT12(dpbp)) - res = link_fat12(dpbp, (unsigned)Cluster1, (unsigned)Cluster2); + { + unsigned idx; + REG UBYTE FAR *fbp0, FAR * fbp1; + struct buffer FAR * bp1; + + /* form an index so that we can read the block as a */ + /* byte array */ + idx = (unsigned) (((Cluster1 << 1) + Cluster1) >> 1) % dpbp->dpb_secsize; + + /* Test to see if the cluster straddles the block. If */ + /* it does, get the next block and use both to form the */ + /* the FAT word. Otherwise, just point to the next */ + /* block. */ + fbp0 = &bp->b_buffer[idx]; + fbp1 = fbp0 + 1; + + if (idx >= (unsigned)dpbp->dpb_secsize - 1) + { + bp1 = getFATblock(Cluster1 + 1, dpbp); + if (bp1 == 0) + return DE_BLKINVLD; + + bp1->b_flag |= BFR_DIRTY | BFR_VALID; + + fbp1 = &bp1->b_buffer[0]; + } + + /* Now pack the value in */ + if (Cluster1 & 0x01) + { + *fbp0 = (*fbp0 & 0x0f) | ((Cluster2 & 0x0f) << 4); + *fbp1 = (Cluster2 >> 4) & 0xff; + } + else + { + *fbp0 = Cluster2 & 0xff; + *fbp1 = (*fbp1 & 0xf0) | ((Cluster2 >> 8) & 0x0f); + } + } else if (ISFAT16(dpbp)) - res = link_fat16(dpbp, (unsigned)Cluster1, (unsigned)Cluster2); + { + /* form an index so that we can read the block as a */ + /* byte array */ + /* Finally, put the word into the buffer and mark the */ + /* buffer as dirty. */ + fputword( + &bp->b_buffer[((unsigned)Cluster1 * SIZEOF_CLST16) % dpbp->dpb_secsize], + (UWORD)Cluster2); + } #ifdef WITHFAT32 else if (ISFAT32(dpbp)) - res = link_fat32(dpbp, Cluster1, Cluster2); + { + /* form an index so that we can read the block as a */ + /* byte array */ + /* Finally, put the word into the buffer and mark the */ + /* buffer as dirty. */ + fputlong( + &bp->b_buffer[(UWORD) ((Cluster1 * SIZEOF_CLST32) % dpbp->dpb_secsize)], + Cluster2); + } #endif else return DE_BLKINVLD; /* update the free space count */ - - if (res == SUCCESS && Cluster2 == FREE) + bp->b_flag |= BFR_DIRTY | BFR_VALID; + if (Cluster2 == FREE) { #ifdef WITHFAT32 if (ISFAT32(dpbp) && dpbp->dpb_xnfreeclst != XUNKNCLSTFREE) { /* update the free space count for returned */ - /* cluster */ + /* cluster */ ++dpbp->dpb_xnfreeclst; write_fsinfo(dpbp); } @@ -196,111 +242,6 @@ unsigned link_fat(struct dpb FAR * dpbp, CLUSTER Cluster1, { --dpbp->dpb_nfreeclst; } */ - return res; -} - -#ifdef WITHFAT32 -STATIC unsigned link_fat32(struct dpb FAR * dpbp, CLUSTER Cluster1, - CLUSTER Cluster2) -{ - unsigned idx; - struct buffer FAR *bp; - - /* Get the block that this cluster is in */ - bp = getFATblock(Cluster1, dpbp); - - if (bp == NULL) - return DE_BLKINVLD; - - /* form an index so that we can read the block as a */ - /* byte array */ - idx = (UWORD) ((Cluster1 * SIZEOF_CLST32) % dpbp->dpb_secsize); - - /* Finally, put the word into the buffer and mark the */ - /* buffer as dirty. */ - fputlong(&bp->b_buffer[idx], Cluster2); - bp->b_flag |= BFR_DIRTY | BFR_VALID; - - /* Return successful. */ - - return SUCCESS; -} - -#endif - -STATIC unsigned link_fat16(struct dpb FAR * dpbp, unsigned Cluster1, - unsigned Cluster2) -{ - unsigned idx; - struct buffer FAR *bp; - - /* Get the block that this cluster is in */ - bp = getFATblock(Cluster1, dpbp); - - if (bp == NULL) - return DE_BLKINVLD; - - /* form an index so that we can read the block as a */ - /* byte array */ - idx = (Cluster1 * SIZEOF_CLST16) % dpbp->dpb_secsize; - - /* Finally, put the word into the buffer and mark the */ - /* buffer as dirty. */ - fputword(&bp->b_buffer[idx], Cluster2); - bp->b_flag |= BFR_DIRTY | BFR_VALID; - - /* Return successful. */ - - return SUCCESS; -} - -STATIC unsigned link_fat12(struct dpb FAR * dpbp, unsigned Cluster1, - unsigned Cluster2) -{ - REG UBYTE FAR *fbp0, FAR * fbp1; - unsigned idx; - struct buffer FAR *bp, FAR * bp1; - - /* Get the block that this cluster is in */ - bp = getFATblock(Cluster1, dpbp); - if (bp == NULL) - return DE_BLKINVLD; - - /* form an index so that we can read the block as a */ - /* byte array */ - idx = (unsigned) (((Cluster1 << 1) + Cluster1) >> 1) % dpbp->dpb_secsize; - - /* Test to see if the cluster straddles the block. If */ - /* it does, get the next block and use both to form the */ - /* the FAT word. Otherwise, just point to the next */ - /* block. */ - fbp0 = &bp->b_buffer[idx]; - fbp1 = fbp0 + 1; - - if (idx >= dpbp->dpb_secsize - 1) - { - bp1 = getFATblock(Cluster1 + 1, dpbp); - if (bp1 == 0) - return DE_BLKINVLD; - - bp1->b_flag |= BFR_DIRTY | BFR_VALID; - - fbp1 = &bp1->b_buffer[0]; - } - bp->b_flag |= BFR_DIRTY | BFR_VALID; - - /* Now pack the value in */ - if (Cluster1 & 0x01) - { - *fbp0 = (*fbp0 & 0x0f) | ((Cluster2 & 0x0f) << 4); - *fbp1 = (Cluster2 >> 4) & 0xff; - } - else - { - *fbp0 = Cluster2 & 0xff; - *fbp1 = (*fbp1 & 0xf0) | ((Cluster2 >> 8) & 0x0f); - } - return SUCCESS; } @@ -345,7 +286,7 @@ CLUSTER next_cluster(struct dpb FAR * dpbp, CLUSTER ClusterNum) /* does, get the next block and use both to form the */ /* the FAT word. Otherwise, just point to the next */ /* block. */ - if (idx >= dpbp->dpb_secsize - 1) + if (idx >= (unsigned)dpbp->dpb_secsize - 1) { bp = getFATblock(ClusterNum + 1, dpbp); @@ -361,9 +302,9 @@ CLUSTER next_cluster(struct dpb FAR * dpbp, CLUSTER ClusterNum) #ifndef I86 /* the latter assumes byte ordering */ if (ClusterNum & 0x01) idx = - ((clusterbuff.byte[0] & 0xf0) >> 4) | (clusterbuff.byte[1] << 4); + ((clusterbuff.bytes[0] & 0xf0) >> 4) | (clusterbuff.bytes[1] << 4); else - idx = clusterbuff.byte[0] | ((clusterbuff.byte[0] & 0x0f) << 8); + idx = clusterbuff.bytes[0] | ((clusterbuff.bytes[1] & 0x0f) << 8); #else if (ClusterNum & 0x01) From 2969ad676402ab36720c5c134569585d35cce84c Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sat, 3 Aug 2002 02:28:04 +0000 Subject: [PATCH 142/671] Disabled fatal() and fixed nls prototypes. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@407 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/dsk.c | 2 +- kernel/nls.c | 2 +- kernel/task.c | 6 ++++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/kernel/dsk.c b/kernel/dsk.c index 67c958c7..b0cc21d9 100644 --- a/kernel/dsk.c +++ b/kernel/dsk.c @@ -203,7 +203,7 @@ STATIC WORD _dsk_init(rqptr rp, ddt * pddt) { UNREFERENCED_PARAMETER(rp); UNREFERENCED_PARAMETER(pddt); - fatal("No disk init!"); + /*fatal("No disk init!");*/ return S_DONE; /* to keep the compiler happy */ } diff --git a/kernel/nls.c b/kernel/nls.c index 80ec6416..28de4545 100644 --- a/kernel/nls.c +++ b/kernel/nls.c @@ -586,7 +586,7 @@ COUNT DosSetCountry(UWORD cntry) /* * Called for DOS-66-01 get CP */ -COUNT DosGetCodepage(UWORD * actCP, UWORD * sysCP) +COUNT DosGetCodepage(UWORD FAR * actCP, UWORD FAR * sysCP) { *sysCP = nlsInfo.sysCodePage; *actCP = nlsInfo.actPkg->cp; diff --git a/kernel/task.c b/kernel/task.c index f6096520..c6442745 100644 --- a/kernel/task.c +++ b/kernel/task.c @@ -406,8 +406,8 @@ COUNT DosComLoader(BYTE FAR * namep, exec_blk FAR * exp, COUNT mode) /* If file not found - error */ /* NOTE - this is fatal because we lost it in transit */ /* from DosExec! */ - if ((rc = DosOpen(namep, 0)) < 0) - fatal("(DosComLoader) com file lost in transit"); + /* if ((rc = DosOpen(namep, 0)) < 0) + fatal("(DosComLoader) com file lost in transit");*/ /* do it in 32K chunks */ if ((com_size = DosGetFsize(rc)) != 0) @@ -716,10 +716,12 @@ COUNT DosExeLoader(BYTE FAR * namep, exec_blk FAR * exp, COUNT mode) /* If file not found - error */ /* NOTE - this is fatal because we lost it in transit */ /* from DosExec! */ +#if 0 if ((rc = DosOpen(namep, 0)) < 0) { fatal("(DosExeLoader) exe file lost in transit"); } +#endif /* offset to start of image */ if (doslseek(rc, image_offset, 0) != image_offset) { From e77a22ead975047437f9f86c9666d637bbf44cac Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sat, 3 Aug 2002 02:32:26 +0000 Subject: [PATCH 143/671] Optimize some copying and adjust the int 1e table. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@408 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/dsk.c | 73 ++++++++++++++++++++++++---------------------------- 1 file changed, 34 insertions(+), 39 deletions(-) diff --git a/kernel/dsk.c b/kernel/dsk.c index b0cc21d9..53df579a 100644 --- a/kernel/dsk.c +++ b/kernel/dsk.c @@ -91,7 +91,7 @@ UWORD LBA_WRITE_VERIFY = 0x4302; */ UBYTE DiskTransferBuffer[1 * SEC_SIZE]; -static struct Access_info { +struct Access_info { BYTE AI_spec; BYTE AI_Flag; }; @@ -135,7 +135,7 @@ typedef WORD dsk_proc(rqptr rq, ddt * pddt); typedef WORD dsk_proc(); #endif -STATIC dsk_proc _dsk_init, mediachk, bldbpb, blockio, IoctlQueblk, +STATIC dsk_proc mediachk, bldbpb, blockio, IoctlQueblk, Genblkdev, Getlogdev, Setlogdev, blk_Open, blk_Close, blk_Media, blk_noerr, blk_nondr, blk_error; @@ -152,7 +152,8 @@ STATIC WORD dskerr(); static dsk_proc * const dispatch[NENTRY] = { - _dsk_init, /* Initialize */ + /* disk init is done in diskinit.c, so this should never be called */ + blk_error, /* Initialize */ mediachk, /* Media Check */ bldbpb, /* Build BPB */ blk_error, /* Ioctl In */ @@ -198,15 +199,6 @@ COUNT ASMCFUNC FAR blk_driver(rqptr rp) return ((*dispatch[rp->r_command]) (rp, getddt(rp->r_unit))); } -/* disk init is done in diskinit.c, so this should never be called */ -STATIC WORD _dsk_init(rqptr rp, ddt * pddt) -{ - UNREFERENCED_PARAMETER(rp); - UNREFERENCED_PARAMETER(pddt); - /*fatal("No disk init!");*/ - return S_DONE; /* to keep the compiler happy */ -} - STATIC WORD play_dj(ddt * pddt) { /* play the DJ ... */ @@ -419,8 +411,7 @@ STATIC WORD getbpb(ddt * pddt) /*TE ~ 200 bytes*/ fmemcpy(pbpbarray, &DiskTransferBuffer[BT_BPB], sizeof(bpb)); - -#ifdef WITHFAT32 + /*?? */ /* 2b is fat16 volume label. if memcmp, then offset 0x36. if (fstrncmp((BYTE *) & DiskTransferBuffer[0x36], "FAT16",5) == 0 || @@ -430,27 +421,21 @@ STATIC WORD getbpb(ddt * pddt) The number of sectors per FAT. Note: This member will always be zero in a FAT32 BPB. Use the values from A_BF_BPB_BigSectorsPerFat... - */ - if (pbpbarray->bpb_nfsect != 0) - { - /* FAT16/FAT12 boot sector */ - pddt->ddt_serialno = getlong(&DiskTransferBuffer[0x27]); - memcpy(pddt->ddt_volume, &DiskTransferBuffer[0x2B], 11); - memcpy(pddt->ddt_fstype, &DiskTransferBuffer[0x36], 8); - } - else + */ { - /* FAT32 boot sector */ - pddt->ddt_serialno = getlong(&DiskTransferBuffer[0x43]); - memcpy(pddt->ddt_volume, &DiskTransferBuffer[0x47], 11); - memcpy(pddt->ddt_fstype, &DiskTransferBuffer[0x52], 8); - pbpbarray->bpb_ndirent = 512; + struct FS_info *fs = (struct FS_info *)&DiskTransferBuffer[0x27]; +#ifdef WITHFAT32 + if (pbpbarray->bpb_nfsect == 0) + { + /* FAT32 boot sector */ + fs = (struct FS_info *)&DiskTransferBuffer[0x43]; + pbpbarray->bpb_ndirent = 512; + } +#endif + pddt->ddt_serialno = getlong(&fs->serialno); + memcpy(pddt->ddt_volume, fs->volume, sizeof fs->volume); + memcpy(pddt->ddt_fstype, fs->fstype, sizeof fs->fstype); } -#else - pddt->ddt_serialno = getlong(&DiskTransferBuffer[0x27]); - memcpy(pddt->ddt_volume, &DiskTransferBuffer[0x2B], 11); - memcpy(pddt->ddt_fstype, &DiskTransferBuffer[0x36], 8); -#endif #ifdef DSK_DEBUG printf("BPB_NBYTE = %04x\n", pbpbarray->bpb_nbyte); @@ -698,13 +683,13 @@ STATIC WORD Genblkdev(rqptr rp, ddt * pddt) case 0x46: /* set volume serial number */ { struct Gioc_media FAR *gioc = (struct Gioc_media FAR *)rp->r_trans; - struct FS_info FAR *fs; + struct FS_info *fs; ret = getbpb(pddt); if (ret != 0) return (ret); - fs = (struct FS_info FAR *)&DiskTransferBuffer + fs = (struct FS_info *)&DiskTransferBuffer [(pddt->ddt_bpb.bpb_nfsect != 0 ? 0x27 : 0x43)]; fs->serialno = gioc->ioc_serialno; pddt->ddt_serialno = fs->serialno; @@ -943,7 +928,7 @@ STATIC int LBA_Transfer(ddt * pddt, UWORD mode, VOID FAR * buffer, }; unsigned count; - unsigned error_code; + unsigned error_code = 0; struct CHS chs; void FAR *transfer_address; @@ -956,6 +941,17 @@ STATIC int LBA_Transfer(ddt * pddt, UWORD mode, VOID FAR * buffer, /* optionally change from A: to B: or back */ play_dj(pddt); + if (!hd(pddt->ddt_descflags)) + { + UBYTE FAR *int1e_ptr = (UBYTE FAR *)getvec(0x1e); + + if (int1e_ptr[4] != pddt->ddt_bpb.bpb_nsecs) + { + int1e_ptr[4] = pddt->ddt_bpb.bpb_nsecs; + fl_reset(pddt->ddt_driveno); + } + } + *transferred = 0; /* if (LBA_address+totaltodo > pddt->total_sectors) @@ -1000,7 +996,6 @@ STATIC int LBA_Transfer(ddt * pddt, UWORD mode, VOID FAR * buffer, if (pddt->ddt_WriteVerifySupported || mode != LBA_WRITE_VERIFY) { - error_code = fl_lba_ReadWrite(pddt->ddt_driveno, mode, &dap); } else @@ -1023,14 +1018,14 @@ STATIC int LBA_Transfer(ddt * pddt, UWORD mode, VOID FAR * buffer, /* avoid overflow at end of track */ - if (chs.Sector + count > pddt->ddt_bpb.bpb_nsecs + 1) + if (chs.Sector + count > (unsigned)pddt->ddt_bpb.bpb_nsecs + 1) { count = pddt->ddt_bpb.bpb_nsecs + 1 - chs.Sector; } if (chs.Cylinder > 1023) { - printf("LBA-Transfer error : cylinder %u > 1023\n", + printf("LBA-Transfer error : cylinder %lu > 1023\n", chs.Cylinder); return 1; } From 31661b437d7fc44747fc05cd555fdaf4efd50a60 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sat, 3 Aug 2002 02:37:59 +0000 Subject: [PATCH 144/671] Small cleanups; initialize a VDISK in inithma.c. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@409 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/initdisk.c | 16 +++++++++------- kernel/inithma.c | 40 +++++++++------------------------------- kernel/initoem.c | 8 ++++---- 3 files changed, 22 insertions(+), 42 deletions(-) diff --git a/kernel/initdisk.c b/kernel/initdisk.c index 7a90ee7b..5b1b5d78 100644 --- a/kernel/initdisk.c +++ b/kernel/initdisk.c @@ -581,8 +581,10 @@ void DosDefinePartition(struct DriveParamS *driveParam, pddt->ddt_WriteVerifySupported = driveParam->WriteVerifySupported; pddt->ddt_ncyl = driveParam->chs.Cylinder; +#ifdef DEBUG if (pddt->ddt_LBASupported) DebugPrintf(("LBA enabled for drive %c:\n", 'A' + nUnits)); +#endif pddt->ddt_offset = StartSector; @@ -761,8 +763,8 @@ int LBA_Get_Drive_Parameters(int drive, struct DriveParamS *driveParam) converts physical into logical representation of partition entry */ -ConvPartTableEntryToIntern(struct PartTableEntry * pEntry, - UBYTE FAR * pDisk) +BOOL ConvPartTableEntryToIntern(struct PartTableEntry * pEntry, + UBYTE FAR * pDisk) { int i; @@ -797,7 +799,7 @@ ConvPartTableEntryToIntern(struct PartTableEntry * pEntry, return TRUE; } -ScanForPrimaryPartitions(struct DriveParamS * driveParam, int scan_type, +BOOL ScanForPrimaryPartitions(struct DriveParamS * driveParam, int scan_type, struct PartTableEntry * pEntry, ULONG startSector, int partitionsToIgnore, int extendedPartNo) { @@ -1249,7 +1251,7 @@ void ReadAllPartitionTables(void) setvec(0x1e, (intvec)int1e_table); /* Setup media info and BPBs arrays for floppies */ - for (Unit = 0; Unit < nUnits; Unit++) + for (Unit = 0; Unit < 2; Unit++) { pddt = DynAlloc("ddt", 1, sizeof(ddt)); @@ -1267,6 +1269,9 @@ void ReadAllPartitionTables(void) fmemcpy(&pddt->ddt_bpb, &pddt->ddt_defbpb, sizeof(bpb)); } + /* Initial number of disk units */ + nUnits = 2; + /* this is a quick patch - see if B: exists test for A: also, need not exist @@ -1364,9 +1369,6 @@ COUNT dsk_init() /* Reset the drives */ BIOS_drive_reset(0); - /* Initial number of disk units */ - nUnits = 2; - ReadAllPartitionTables(); return nUnits; diff --git a/kernel/inithma.c b/kernel/inithma.c index 3f5d9a83..5ba62965 100644 --- a/kernel/inithma.c +++ b/kernel/inithma.c @@ -87,6 +87,7 @@ VOID ASMCFUNC FAR _DisableA20(VOID); void FAR * ASMCFUNC DetectXMSDriver(VOID); int ASMCFUNC init_call_XMScall(void FAR * driverAddress, UWORD ax, UWORD dx); +STATIC void InstallVDISK(void); #ifdef DEBUG #ifdef __TURBOC__ @@ -239,14 +240,19 @@ int MoveKernelToHMA() DosLoadedInHMA = TRUE; } - /* report the fact we are running high thorugh int 21, ax=3306 */ + /* + on finalize, will install a VDISK + */ + + InstallVDISK(); + + /* report the fact we are running high through int 21, ax=3306 */ version_flags |= 0x10; return TRUE; } -/* not necessary anymore : BO */ /* now protect against HIMEM/FDXMS/... by simulating a VDISK FDXMS should detect us and not give HMA access to ohers @@ -254,8 +260,7 @@ int MoveKernelToHMA() so: we install this after all drivers have been loaded */ -#if 0 -void InstallVDISK(VOID) +STATIC void InstallVDISK(void) { static struct { /* Boot-Sektor of a RAM-Disk */ UBYTE dummy1[3]; /* HIMEM.SYS uses 3, but FDXMS uses 2 */ @@ -278,38 +283,12 @@ void InstallVDISK(VOID) if (!DosLoadedInHMA) return; - if (HMAclaimed) - return; fmemcpy(MK_FP(0xffff, 0x0010), &VDISK_BOOT_SEKTOR, sizeof(VDISK_BOOT_SEKTOR)); - setvec(0x19, MK_FP(0xffff, 0x0010)); /* let INT 19 point to VDISK */ - *(WORD FAR *) MK_FP(0xffff, 0x002e) = 1024 + 64; } -#endif - -/* - this should be called, after each device driver - has been loaded with FALSE - and on finished CONFIG processing with TRUE. - - will try to grab HMA; - - on finalize, will install a VDISK -*/ - -#if 0 /* not necessary anymore */ - -void HMAconfig(int finalize) -{ - ClaimHMA(); - - if (finalize) - InstallVDISK(); -} -#endif /* this allocates some bytes from the HMA area @@ -346,7 +325,6 @@ void MoveKernel(unsigned NewKernelSegment) UBYTE FAR *HMASource; unsigned len; - int3(); if (CurrentKernelSegment == 0) CurrentKernelSegment = FP_SEG(_HMATextEnd); diff --git a/kernel/initoem.c b/kernel/initoem.c index b9dbfbfa..220b705d 100644 --- a/kernel/initoem.c +++ b/kernel/initoem.c @@ -39,15 +39,15 @@ UWORD init_oem(void) { UWORD top_k = 0; -#ifndef __TURBOC__ +#ifdef __TURBOC__ + __int__(0x12); + top_k = _AX; +#elif defined(I86) asm { int 0x12; mov top_k, ax; } -#else - __int__(0x12); - top_k = _AX; #endif return top_k; } From c874cbfbbd1ed64983a0cb32a953d0caacc2710d Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sat, 3 Aug 2002 02:39:20 +0000 Subject: [PATCH 145/671] Small size optimization. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@410 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/sysclk.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/kernel/sysclk.c b/kernel/sysclk.c index 1e0bce4c..6a517a6b 100644 --- a/kernel/sysclk.c +++ b/kernel/sysclk.c @@ -122,9 +122,8 @@ WORD ASMCFUNC FAR clk_driver(rqptr rp) case C_OUTPUT: { - int c; const unsigned short *pdays; - unsigned Month, Day, Year; + unsigned Day, Month, Year; struct ClockRecord clk; ticks_t hs, Ticks; @@ -146,25 +145,25 @@ WORD ASMCFUNC FAR clk_driver(rqptr rp) /* Now set AT clock */ /* Fix year by looping through each year, subtracting */ /* the appropriate number of days for that year. */ - for (Year = 1980, c = clk.clkDays;;) + for (Year = 1980, Day = clk.clkDays;;) { pdays = is_leap_year_monthdays(Year); - if (c >= pdays[12]) + if (Day >= pdays[12]) { ++Year; - c -= pdays[12]; + Day -= pdays[12]; } else break; } - /* c contains the days left and count the number of */ + /* Day contains the days left and count the number of */ /* days for that year. Use this to index the table. */ for (Month = 1; Month < 13; ++Month) { - if (pdays[Month] > c) + if (pdays[Month] > Day) { - Day = c - pdays[Month - 1] + 1; + Day -= pdays[Month - 1] + 1; break; } } From 8567cb9ed590f89590949f466aaf3e5e256d2600 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sat, 3 Aug 2002 03:50:32 +0000 Subject: [PATCH 146/671] Commented out the wrong parts of task.c for now :-( git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@411 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/task.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/kernel/task.c b/kernel/task.c index c6442745..8644ab86 100644 --- a/kernel/task.c +++ b/kernel/task.c @@ -406,8 +406,11 @@ COUNT DosComLoader(BYTE FAR * namep, exec_blk FAR * exp, COUNT mode) /* If file not found - error */ /* NOTE - this is fatal because we lost it in transit */ /* from DosExec! */ - /* if ((rc = DosOpen(namep, 0)) < 0) - fatal("(DosComLoader) com file lost in transit");*/ + if ((rc = DosOpen(namep, 0)) < 0) +#if 0 + fatal("(DosComLoader) com file lost in transit") +#endif + ; /* do it in 32K chunks */ if ((com_size = DosGetFsize(rc)) != 0) @@ -716,12 +719,12 @@ COUNT DosExeLoader(BYTE FAR * namep, exec_blk FAR * exp, COUNT mode) /* If file not found - error */ /* NOTE - this is fatal because we lost it in transit */ /* from DosExec! */ -#if 0 if ((rc = DosOpen(namep, 0)) < 0) { +#if 0 fatal("(DosExeLoader) exe file lost in transit"); - } #endif + } /* offset to start of image */ if (doslseek(rc, image_offset, 0) != image_offset) { From 3b5e79890eef806ef0cd41cc7de1ee6ca028f21c Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sat, 3 Aug 2002 04:08:58 +0000 Subject: [PATCH 147/671] Fix some prototypes and add definitions for "extended open" support. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@412 6ac86273-5f31-0410-b378-82cca8765d1b --- hdr/device.h | 4 ++-- hdr/dirmatch.h | 2 +- hdr/exe.h | 1 + hdr/fcb.h | 2 +- hdr/file.h | 15 +++++++++++++++ hdr/nls.h | 12 ++++++------ hdr/pcb.h | 6 ++++++ hdr/process.h | 4 ++-- 8 files changed, 34 insertions(+), 12 deletions(-) diff --git a/hdr/device.h b/hdr/device.h index aabb3c3a..d2d3ac8e 100644 --- a/hdr/device.h +++ b/hdr/device.h @@ -126,8 +126,8 @@ struct dhdr { struct dhdr FAR *dh_next; UWORD dh_attr; - VOID(*dh_strategy) (); - VOID(*dh_interrupt) (); + VOID(*dh_strategy) (void); + VOID(*dh_interrupt) (void); BYTE dh_name[8]; }; diff --git a/hdr/dirmatch.h b/hdr/dirmatch.h index b8e55d1a..7a327237 100644 --- a/hdr/dirmatch.h +++ b/hdr/dirmatch.h @@ -36,7 +36,7 @@ static BYTE *dirmatch_hRcsId = #endif typedef struct { - BYTE dm_drive; + UBYTE dm_drive; BYTE dm_name_pat[FNAME_SIZE + FEXT_SIZE]; BYTE dm_attr_srch; UWORD dm_entry; diff --git a/hdr/exe.h b/hdr/exe.h index c895db0d..8d236201 100644 --- a/hdr/exe.h +++ b/hdr/exe.h @@ -53,6 +53,7 @@ typedef struct { } exe_header; #define MAGIC 0x5a4d +#define OLD_MAGIC 0x4d5a /* * Log: exe.h,v diff --git a/hdr/fcb.h b/hdr/fcb.h index 1253b721..092f28ed 100644 --- a/hdr/fcb.h +++ b/hdr/fcb.h @@ -78,7 +78,7 @@ static BYTE *fcb_hRcsId = /* File Control Block (FCB) */ typedef struct { - BYTE fcb_drive; /* Drive number 0=default, 1=A, etc */ + UBYTE fcb_drive; /* Drive number 0=default, 1=A, etc */ BYTE fcb_fname[FNAME_SIZE]; /* File name */ BYTE fcb_fext[FEXT_SIZE]; /* File name Extension */ UWORD fcb_cublock; /* Current block number of */ diff --git a/hdr/file.h b/hdr/file.h index e143e43a..c3ef7577 100644 --- a/hdr/file.h +++ b/hdr/file.h @@ -51,6 +51,21 @@ static BYTE *file_hRcsId = #define O_WRONLY SFT_MWRITE #define O_RDWR SFT_MRDWR +/* bits 2, 3 reserved */ +/* bits 4, 5, 6 sharing modes */ +#define O_NOINHERIT 0x0080 +#define O_OPEN 0x0100 /* not */ +#define O_TRUNC 0x0200 /* both */ +#define O_CREAT 0x0400 +#define O_LEGACY 0x0800 +#define O_LARGEFILE 0x1000 +#define O_NOCRIT 0x2000 +#define O_SYNC 0x4000 +#define O_FCB 0x8000 + +/* status for extended open */ +enum {S_OPENED = 1, S_CREATED = 2, S_REPLACED = 3}; + /* * Log: file.h,v * diff --git a/hdr/nls.h b/hdr/nls.h index 3a9af629..d5915410 100644 --- a/hdr/nls.h +++ b/hdr/nls.h @@ -175,7 +175,7 @@ * * Performance tweaks: * When the system -- This word applies to the combination of kernel and - * any loaded MUX-14 extension   la NLSFUNC here. -- uppercases + * any loaded MUX-14 extension á la NLSFUNC here. -- uppercases * _filenames_, it must perform a DOS-65-A2 internally. In the basic * implementation this request would be channeled through MUX-14, even * if there is no external NLSFUNC at all. Also, when a NLS pkg had @@ -517,22 +517,22 @@ extern BYTE FAR hcTablesStart[], hcTablesEnd[]; #define CSYS_FD_IDSTRING "FreeDOS COUNTRY.SYS v1.0\r\n" -struct nlsCSys_function { /* S3: function definition */ +struct csys_function { /* S3: function definition */ UDWORD csys_rpos; /* relative position to actual data */ UWORD csys_length; UBYTE csys_fctID; /* As passed to DOS-65-XX */ UBYTE csys_reserved1; /* always 0, reserved for future use */ }; -struct nlsCSys_ccDefinition { /* S1: country/codepage reference */ +struct csys_ccDefinition { /* S1: country/codepage reference */ UDWORD csys_rpos; /* moving the 4byte value to the front can increase performance */ UWORD csys_cp; UWORD csys_cntry; }; -struct nlsCSys_numEntries { /* helper structure for "number of entries" */ - UWORD csys_numEntries; +struct csys_numEntries { /* helper structure for "number of entries" */ + UWORD csys_entries; }; /* Actually, this structure is never really used */ @@ -541,7 +541,7 @@ struct nlsCSys_fileHeader { /* S0: primary structure */ /* decrement by 1 to cut off \0 from IDString -- ska */ }; -struct nlsCSys_completeFileHeader { /* as S0, but full 128 bytes */ +struct csys_completeFileHeader { /* as S0, but full 128 bytes */ unsigned char csys_idstring[sizeof(CSYS_FD_IDSTRING) - 1]; unsigned char csys_padbytes[128 - (sizeof(CSYS_FD_IDSTRING) - 1)]; }; diff --git a/hdr/pcb.h b/hdr/pcb.h index 87a37859..657a1b36 100644 --- a/hdr/pcb.h +++ b/hdr/pcb.h @@ -81,6 +81,12 @@ typedef struct _iregss { UWORD ip, cs, flags; } iregs; +/* struct used for local copy of registers */ +typedef struct { + xreg a, b, c, d; + UWORD si, di, ds, es; +} lregs; + /* Registers directly passed to syscall; must be the same order as iregs! Is used to define parameters. */ diff --git a/hdr/process.h b/hdr/process.h index 33e6ec98..f25347c1 100644 --- a/hdr/process.h +++ b/hdr/process.h @@ -68,7 +68,7 @@ typedef struct { /* CP/M-like entry point */ UBYTE ps_farcall; /* 05 far call opcode */ - VOID(FAR ASMCFUNC * ps_reentry) (); /* 06 re-entry point */ + VOID(FAR ASMCFUNC * ps_reentry) (void); /* 06 re-entry point */ intvec ps_isv22, /* 0a terminate address */ ps_isv23, /* 0e break address */ ps_isv24; /* 12 critical error address */ @@ -76,7 +76,7 @@ typedef struct { UBYTE ps_files[20]; /* 18 file table - 0xff is unused */ UWORD ps_environ; /* 2c environment paragraph */ BYTE FAR *ps_stack; /* 2e user stack pointer - int 21 */ - WORD ps_maxfiles; /* 32 maximum open files */ + UWORD ps_maxfiles; /* 32 maximum open files */ UBYTE FAR *ps_filetab; /* 34 open file table pointer */ VOID FAR *ps_prevpsp; /* 38 previous psp pointer */ BYTE FAR *ps_dta; /* 3c process dta address */ From 511bf63d16eda02ef30d614256cf23561f2c723d Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sat, 3 Aug 2002 16:54:09 +0000 Subject: [PATCH 148/671] Cleaned up task.c (merged much of DOSExe/ComLoader); transform the CDS into a proper array. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@413 6ac86273-5f31-0410-b378-82cca8765d1b --- docs/history.txt | 31 +- drivers/floppy.asm | 8 +- hdr/cds.h | 47 ++- hdr/version.h | 10 +- kernel/blockio.c | 6 +- kernel/dosfns.c | 36 +-- kernel/fatdir.c | 4 +- kernel/fatfs.c | 6 +- kernel/fattab.c | 2 +- kernel/fcbfns.c | 2 +- kernel/globals.h | 2 +- kernel/inthndlr.c | 16 +- kernel/ioctl.c | 6 +- kernel/lfnapi.c | 2 +- kernel/main.c | 31 +- kernel/memmgr.c | 64 ++-- kernel/newstuff.c | 4 +- kernel/proto.h | 6 +- kernel/task.c | 718 +++++++++++++++++++-------------------------- 19 files changed, 454 insertions(+), 547 deletions(-) diff --git a/docs/history.txt b/docs/history.txt index 2555b8b4..9bb943d0 100644 --- a/docs/history.txt +++ b/docs/history.txt @@ -1,10 +1,39 @@ 2002 Aug xx - Build 2027 -------- Bart Oldeman (bart@dosemu.org) + Changes Tom - + * enable LBA FAT16 booting + * workaround for redirectors that do/do not set the opencount + * int25/26 should fail for redirectors + * set the number of sectors per track in the INT 1E table when + reading/writing floppies + * disabled fatal() in error.c + * Disable the A20 line upon exec (int21/ah=4B). This is necessary for some + brain-dead exepacked programs. + * removed unnecessary buffer fields + * proper check for network/non-existing drive for int25/26. + * save more bytes on the stack at various places + Changes Bart * patchobj makefile correction * printf uses va_list etc. + * quicker and more robust Watcom build + * use FS: and GS: for Watcom 386. + * workaround: don't use DL for floppy boots, but fixed A: + * disable unused functions in floppy.asm + * cleaner prototypes (thanks to gcc) + * reorganized ioctl.c; there was an uninitialized variable. + * inlined some functions of fattab.c + * added (f)strcmp, (f)memcmp and (f)memchr to asmsupt.asm + * initially suggested by Arkady: dsk.c FS_info copy optimization + * initialize a VDISK signature in the HMA + * sysclk.c: small size optimization + * small UMB fixes + * made the CDS into a proper array instead of a structure with + one member + * large task.c cleanups - + merge as much as possible from DosExeLoader and DosComLoader + (from Tom:) eliminate some structures in low memory + * main.c: slightly cleanup "SHELL=" line parsing. + 2002 May 9 - Build 2026b -------- Bart Oldeman (bart@dosemu.org) + Changes Tom diff --git a/drivers/floppy.asm b/drivers/floppy.asm index ca7bb1e5..aa65841b 100644 --- a/drivers/floppy.asm +++ b/drivers/floppy.asm @@ -72,7 +72,7 @@ fl_rst1: xor ax,ax ; FALSE on error ; 2 Drive present, can detect disk change ; 3 Fixed disk ; - +%if 0 global _fl_readdasd _fl_readdasd: push bp @@ -93,7 +93,7 @@ fl_rdasd1: mov ah,0 ; BIOS reset disketter & fixed disk mov ax,0FFh ; 0xFF on error pop bp ; C exit ret - +%endif ; ; @@ -138,7 +138,7 @@ fl_dc_error: mov ax,0FFh ; 0xFF on error ; ; See Phoenix Bios Book for error code meanings ; - +%if 0 global _fl_rd_status _fl_rd_status: push bp ; C entry @@ -153,7 +153,7 @@ _fl_rd_status: pop bp ; C exit ret - +%endif ; ; Format Sectors diff --git a/hdr/cds.h b/hdr/cds.h index c7b6522b..dc88e05d 100644 --- a/hdr/cds.h +++ b/hdr/cds.h @@ -37,20 +37,29 @@ static BYTE *Cds_hRcsId = struct cds { BYTE cdsCurrentPath[MAX_CDSPATH]; - UWORD cdsFlags; - struct dpb FAR *cdsDpb; + UWORD cdsFlags; /* see below */ + struct dpb FAR *cdsDpb; /* if != 0, associated DPB */ union { - BYTE FAR *_cdsRedirRec; + BYTE FAR *_cdsRedirRec; /* IFS record */ struct { - UWORD _cdsStrtClst; + UWORD _cdsStrtClst; /* if local path (Flags & CDSPHYSDRV): + start cluster of CWD; root == 0, + never access == 0xFFFF */ UWORD _cdsParam; } _cdsRedir; } _cdsUnion; UWORD cdsStoreUData; - WORD cdsJoinOffset; +#define cdsJoinOffset cdsBackslashOffset + WORD cdsBackslashOffset; /* Position of "root directory" backslash for + this drive within CurrentPath[] + prerequisites: + + ofs <= strlen(currentPath) + + if UNC: ofs > share component + if local path: ofs > colon + */ BYTE cdsNetFlag1; BYTE FAR *cdsIfs; @@ -62,17 +71,29 @@ struct cds { #define cdsRedirRec _cdsUnion._cdsRedirRec #define cdsParam _cdsUnion._cdsRedir._cdsParam -typedef struct _cdstbl { - struct cds cds_table[26]; -} cdstbl; - -/* Bits for cdsFlags */ +/* Bits for cdsFlags (OR combination) */ #define CDSNETWDRV 0x8000 #define CDSPHYSDRV 0x4000 -#define CDSJOINED 0x2000 -#define CDSSUBST 0x1000 -#define CDSVALID (CDSNETWDRV | CDSPHYSDRV) +#define CDSJOINED 0x2000 /* not in combination with NETWDRV or SUBST */ +#define CDSSUBST 0x1000 /* not in combination with NETWDRV or JOINED */ +#define CDS_HIDDEN (1 << 7) /* hide drive from redirector's list */ + +/* NETWORK PHYSICAL meaning + 0 0 drive not accessable + 0 1 local file system + 1 0 networked file system (UNC naming convention) + 1 1 installable file system (IFS) +*/ +#define CDSMODEMASK (CDSNETWDRV | CDSPHYSDRV) + +/* #define CDSVALID (CDSNETWDRV | CDSPHYSDRV) */ +#define CDSVALID CDSMODEMASK + +#define IS_DEVICE 0x20 +#define IS_NETWORK 0x40 +#define CDS_MODE_SKIP_PHYSICAL 0x01 /* don't resolve SUBST, JOIN, NETW */ +#define CDS_MODE_CHECK_DEV_PATH 0x02 /* check for existence of device path */ /* * Log: cds.h,v * Revision 1.2 2000/03/09 06:06:38 kernel diff --git a/hdr/version.h b/hdr/version.h index 0f5340c5..3a9a8663 100644 --- a/hdr/version.h +++ b/hdr/version.h @@ -47,8 +47,8 @@ static BYTE *date_hRcsId = #define REVISION_MAJOR 1 #define REVISION_MINOR 1 -#define REVISION_SEQ 26 -#define BUILD "2026" -#define SUB_BUILD "b" -#define KERNEL_VERSION_STRING "1.1.26b" /*#REVISION_MAJOR "." #REVISION_MINOR "." #REVISION_SEQ */ -#define KERNEL_BUILD_STRING "2026b" /*#BUILD SUB_BUILD */ +#define REVISION_SEQ 27 +#define BUILD "2027" +#define SUB_BUILD "test" +#define KERNEL_VERSION_STRING "1.1.27" /*#REVISION_MAJOR "." #REVISION_MINOR "." #REVISION_SEQ */ +#define KERNEL_BUILD_STRING "2027test" /*#BUILD SUB_BUILD */ diff --git a/kernel/blockio.c b/kernel/blockio.c index 1add9dc5..faa71eaa 100644 --- a/kernel/blockio.c +++ b/kernel/blockio.c @@ -76,7 +76,7 @@ STATIC VOID setblkno(struct buffer FAR * bp, ULONG blkno) bp->b_blkno = blkno; /* bp->b_dpbp = &blk_devices[bp->b_unit]; */ - bp->b_dpbp = CDSp->cds_table[bp->b_unit].cdsDpb; + bp->b_dpbp = CDSp[bp->b_unit].cdsDpb; } } @@ -416,13 +416,13 @@ UWORD dskxfer(COUNT dsk, ULONG blkno, VOID FAR * buf, UWORD numblocks, { /* REG struct dpb *dpbp = &blk_devices[dsk]; */ - REG struct dpb FAR *dpbp = CDSp->cds_table[dsk].cdsDpb; + REG struct dpb FAR *dpbp = CDSp[dsk].cdsDpb; if ((UCOUNT) dsk >= lastdrive) { return 0x0201; /* illegal command */ } - if ((CDSp->cds_table[dsk].cdsFlags & (CDSPHYSDRV | CDSNETWDRV)) != CDSPHYSDRV) + if ((CDSp[dsk].cdsFlags & (CDSPHYSDRV | CDSNETWDRV)) != CDSPHYSDRV) { return 0x0201; /* illegal command */ } diff --git a/kernel/dosfns.c b/kernel/dosfns.c index 0533e585..04159e5f 100644 --- a/kernel/dosfns.c +++ b/kernel/dosfns.c @@ -107,8 +107,8 @@ struct dpb FAR * GetDriveDPB(UBYTE drive, COUNT * rc) return 0; } - dpb = CDSp->cds_table[drive].cdsDpb; - if (dpb == 0 || CDSp->cds_table[drive].cdsFlags & CDSNETWDRV) + dpb = CDSp[drive].cdsDpb; + if (dpb == 0 || CDSp[drive].cdsFlags & CDSNETWDRV) { *rc = DE_INVLDDRV; return 0; @@ -1020,7 +1020,7 @@ BOOL DosGetFree(UBYTE drive, UCOUNT FAR * spc, UCOUNT FAR * navc, if (drive >= lastdrive) return FALSE; - cdsp = &CDSp->cds_table[drive]; + cdsp = &CDSp[drive]; if (!(cdsp->cdsFlags & CDSVALID)) return FALSE; @@ -1050,7 +1050,7 @@ BOOL DosGetFree(UBYTE drive, UCOUNT FAR * spc, UCOUNT FAR * navc, return TRUE; } - dpbp = CDSp->cds_table[drive].cdsDpb; + dpbp = CDSp[drive].cdsDpb; if (dpbp == NULL) return FALSE; @@ -1127,7 +1127,7 @@ COUNT DosGetExtFree(BYTE FAR * DriveString, struct xfreespace FAR * xfsp) if (drive >= lastdrive) return DE_INVLDDRV; - cdsp = &CDSp->cds_table[drive]; + cdsp = &CDSp[drive]; if (!(cdsp->cdsFlags & CDSVALID)) return DE_INVLDDRV; @@ -1143,7 +1143,7 @@ COUNT DosGetExtFree(BYTE FAR * DriveString, struct xfreespace FAR * xfsp) } else { - dpbp = CDSp->cds_table[drive].cdsDpb; + dpbp = CDSp[drive].cdsDpb; if (dpbp == NULL || media_check(dpbp) < 0) return DE_INVLDDRV; xfsp->xfs_secsize = dpbp->dpb_secsize; @@ -1172,12 +1172,12 @@ COUNT DosGetCuDir(UBYTE drive, BYTE FAR * s) drive = (drive == 0 ? default_drive : drive - 1); /* first check for valid drive */ - if (drive >= lastdrive || !(CDSp->cds_table[drive].cdsFlags & CDSVALID)) + if (drive >= lastdrive || !(CDSp[drive].cdsFlags & CDSVALID)) { return DE_INVLDDRV; } - current_ldt = &CDSp->cds_table[drive]; + current_ldt = &CDSp[drive]; /* ensure termination of fstrcpy */ cp[MAX_CDSPATH - 1] = '\0'; @@ -1223,7 +1223,7 @@ COUNT DosChangeDir(BYTE FAR * s) return result; } - current_ldt = &CDSp->cds_table[drive]; + current_ldt = &CDSp[drive]; if (strlen(PriPathName) > sizeof(current_ldt->cdsCurrentPath) - 1) return DE_PATHNOTFND; @@ -1364,7 +1364,7 @@ COUNT DosFindNext(void) fmemset(dta, 0, sizeof(dmatch)); p = dta; dta = (BYTE FAR *) TempBuffer; - current_ldt = &CDSp->cds_table[((dmatch *) TempBuffer)->dm_drive]; + current_ldt = &CDSp[((dmatch *) TempBuffer)->dm_drive]; rc = (((dmatch *) TempBuffer)->dm_drive & 0x80) ? remote_findnext((VOID FAR *) current_ldt) : dos_findnext(); @@ -1457,7 +1457,7 @@ COUNT DosGetFattr(BYTE FAR * name) return 0x10; } - current_ldt = &CDSp->cds_table[drive]; + current_ldt = &CDSp[drive]; if (current_ldt->cdsFlags & CDSNETWDRV) { return remote_getfattr(); @@ -1518,7 +1518,7 @@ COUNT DosSetFattr(BYTE FAR * name, UWORD attrp) return result; } - current_ldt = &CDSp->cds_table[drive]; + current_ldt = &CDSp[drive]; if (current_ldt->cdsFlags & CDSNETWDRV) { return remote_setfattr(attrp); @@ -1543,7 +1543,7 @@ COUNT DosSetFattr(BYTE FAR * name, UWORD attrp) UBYTE DosSelectDrv(UBYTE drv) { - current_ldt = &CDSp->cds_table[drv]; + current_ldt = &CDSp[drv]; if ((drv < lastdrive) && (current_ldt->cdsFlags & CDSVALID)) /* @@ -1575,7 +1575,7 @@ COUNT DosDelete(BYTE FAR * path, int attrib) { return result; } - current_ldt = &CDSp->cds_table[drive]; + current_ldt = &CDSp[drive]; if (current_ldt->cdsFlags & CDSNETWDRV) { return remote_delete(); @@ -1601,7 +1601,7 @@ COUNT DosRenameTrue(BYTE * path1, BYTE * path2, int attrib) { return DE_INVLDDRV; } - current_ldt = &CDSp->cds_table[drive1]; + current_ldt = &CDSp[drive1]; if (current_ldt->cdsFlags & CDSNETWDRV) { return remote_rename(); @@ -1650,7 +1650,7 @@ COUNT DosMkdir(BYTE FAR * dir) { return result; } - current_ldt = &CDSp->cds_table[drive]; + current_ldt = &CDSp[drive]; if (current_ldt->cdsFlags & CDSNETWDRV) { return remote_mkdir(); @@ -1680,8 +1680,8 @@ COUNT DosRmdir(BYTE FAR * dir) { return result; } - current_ldt = &CDSp->cds_table[drive]; - if (CDSp->cds_table[drive].cdsFlags & CDSNETWDRV) + current_ldt = &CDSp[drive]; + if (CDSp[drive].cdsFlags & CDSNETWDRV) { return remote_rmdir(); } diff --git a/kernel/fatdir.c b/kernel/fatdir.c index 804f631e..a95897b8 100644 --- a/kernel/fatdir.c +++ b/kernel/fatdir.c @@ -113,7 +113,7 @@ f_node_ptr dir_open(BYTE * dirname) return NULL; } - cdsp = &CDSp->cds_table[drive]; + cdsp = &CDSp[drive]; /* Generate full path name */ /* not necessary anymore, since truename did that already @@ -576,7 +576,7 @@ COUNT dos_findnext(void) /* Select the default to help non-drive specified path */ /* searches... */ - fnp->f_dpb = CDSp->cds_table[dmp->dm_drive].cdsDpb; + fnp->f_dpb = CDSp[dmp->dm_drive].cdsDpb; if (media_check(fnp->f_dpb) < 0) { release_f_node(fnp); diff --git a/kernel/fatfs.c b/kernel/fatfs.c index 8a032933..6c2db6c0 100644 --- a/kernel/fatfs.c +++ b/kernel/fatfs.c @@ -227,7 +227,7 @@ f_node_ptr split_path(BYTE * path, BYTE * fname, BYTE * fext) { return (f_node_ptr) 0; } - cdsp = &CDSp->cds_table[nDrive]; + cdsp = &CDSp[nDrive]; /* 11/29/99 jt * Networking and Cdroms. You can put in here a return. @@ -2187,7 +2187,7 @@ COUNT media_check(REG struct dpb FAR * dpbp) #endif /* need to change to root directory if changed */ if (status == M_CHANGED) - CDSp->cds_table[dpbp->dpb_unit].cdsCurrentPath[3] = '\0'; + CDSp[dpbp->dpb_unit].cdsCurrentPath[3] = '\0'; return SUCCESS; } } @@ -2210,7 +2210,7 @@ struct dhdr FAR *select_unit(COUNT drive) /* Just get the header from the dhdr array */ /* return blk_devices[drive].dpb_device; */ - return (struct dhdr FAR *)CDSp->cds_table[drive].cdsDpb; + return (struct dhdr FAR *)CDSp[drive].cdsDpb; } #endif diff --git a/kernel/fattab.c b/kernel/fattab.c index fed0c8fa..a54c6569 100644 --- a/kernel/fattab.c +++ b/kernel/fattab.c @@ -261,7 +261,7 @@ CLUSTER next_cluster(struct dpb FAR * dpbp, CLUSTER ClusterNum) bp = getFATblock(ClusterNum, dpbp); if (bp == NULL) - return DE_BLKINVLD; + return 1; /* the only error code possible here */ if (ISFAT12(dpbp)) { diff --git a/kernel/fcbfns.c b/kernel/fcbfns.c index 08cbdc0b..a575a973 100644 --- a/kernel/fcbfns.c +++ b/kernel/fcbfns.c @@ -70,7 +70,7 @@ VOID FatGetDrvData(UCOUNT drive, UCOUNT FAR * spc, UCOUNT FAR * bps, if (DosGetFree((UBYTE) drive, spc, &navc, bps, nc)) { struct cds FAR *cdsp = - &CDSp->cds_table[(drive == 0 ? default_drive : drive - 1)]; + &CDSp[(drive == 0 ? default_drive : drive - 1)]; /* Point to the media desctriptor for this drive */ if (cdsp->cdsFlags & CDSNETWDRV) { diff --git a/kernel/globals.h b/kernel/globals.h index 2ab20132..e753166d 100644 --- a/kernel/globals.h +++ b/kernel/globals.h @@ -267,7 +267,7 @@ FAR * ASM clock, /* CLOCK$ device */ extern WORD ASM maxbksize; /* Number of Drives in system */ extern struct buffer FAR *ASM firstbuf; /* head of buffers linked list */ -extern cdstbl FAR * ASM CDSp; /* Current Directory Structure */ +extern struct cds FAR * ASM CDSp; /* Current Directory Structure */ extern struct cds FAR * ASM current_ldt; extern LONG ASM current_filepos; /* current file position */ diff --git a/kernel/inthndlr.c b/kernel/inthndlr.c index f420ba51..bbcfff3f 100644 --- a/kernel/inthndlr.c +++ b/kernel/inthndlr.c @@ -655,8 +655,8 @@ VOID ASMCFUNC int21_service(iregs FAR * r) break; } - dpb = CDSp->cds_table[drv].cdsDpb; - if (dpb == 0 || CDSp->cds_table[drv].cdsFlags & CDSNETWDRV) + dpb = CDSp[drv].cdsDpb; + if (dpb == 0 || CDSp[drv].cdsFlags & CDSNETWDRV) { r->AL = 0xFF; CritErrCode = 0x0f; @@ -1264,14 +1264,14 @@ VOID ASMCFUNC int21_service(iregs FAR * r) case 0x07: if (r->DL < lastdrive) { - CDSp->cds_table[r->DL].cdsFlags |= 0x100; + CDSp[r->DL].cdsFlags |= 0x100; } break; case 0x08: if (r->DL < lastdrive) { - CDSp->cds_table[r->DL].cdsFlags &= ~0x100; + CDSp[r->DL].cdsFlags &= ~0x100; } break; @@ -1432,7 +1432,7 @@ VOID ASMCFUNC int21_service(iregs FAR * r) if (rc < lastdrive) { UWORD saveCX = r->CX; - if (CDSp->cds_table[rc].cdsFlags & CDSNETWDRV) + if (CDSp[rc].cdsFlags & CDSNETWDRV) { goto error_invalid; } @@ -1842,8 +1842,8 @@ VOID ASMCFUNC int2526_handler(WORD mode, struct int25regs FAR * r) } #ifdef WITHFAT32 - if (!(CDSp->cds_table[drv].cdsFlags & CDSNETWDRV) && - ISFAT32(CDSp->cds_table[drv].cdsDpb)) + if (!(CDSp[drv].cdsFlags & CDSNETWDRV) && + ISFAT32(CDSp[drv].cdsDpb)) { r->ax = 0x207; r->flags |= FLG_CARRY; @@ -2017,7 +2017,7 @@ VOID ASMCFUNC int2F_12_handler(volatile struct int2f12regs r) else { r.ds = FP_SEG(CDSp); - r.si = FP_OFF(&CDSp->cds_table[drv]); + r.si = FP_OFF(&CDSp[drv]); r.flags &= ~FLG_CARRY; } break; diff --git a/kernel/ioctl.c b/kernel/ioctl.c index f5a8dbe9..d22a85a0 100644 --- a/kernel/ioctl.c +++ b/kernel/ioctl.c @@ -110,8 +110,8 @@ COUNT DosDevIOctl(iregs FAR * r) return DE_INVLDDRV; else { -/* cdsp = &CDSp->cds_table[CharReqHdr.r_unit]; */ - dpbp = CDSp->cds_table[CharReqHdr.r_unit].cdsDpb; +/* cdsp = &CDSp[CharReqHdr.r_unit]; */ + dpbp = CDSp[CharReqHdr.r_unit].cdsDpb; } break; @@ -278,7 +278,7 @@ COUNT DosDevIOctl(iregs FAR * r) return DE_INVLDFUNC; case 0x09: - if (CDSp->cds_table[CharReqHdr.r_unit].cdsFlags & CDSNETWDRV) + if (CDSp[CharReqHdr.r_unit].cdsFlags & CDSNETWDRV) { r->DX = ATTR_REMOTE; r->AX = S_DONE | S_BUSY; diff --git a/kernel/lfnapi.c b/kernel/lfnapi.c index c4aea26d..ca8d25d0 100644 --- a/kernel/lfnapi.c +++ b/kernel/lfnapi.c @@ -64,7 +64,7 @@ COUNT lfn_allocate_inode(VOID) } /* Check that default drive is a block device */ - cdsp = &CDSp->cds_table[default_drive]; + cdsp = &CDSp[default_drive]; if (cdsp->cdsDpb == 0) { diff --git a/kernel/main.c b/kernel/main.c index d7d590c0..153ff9d0 100644 --- a/kernel/main.c +++ b/kernel/main.c @@ -32,7 +32,7 @@ #include "dyndata.h" #include "init-dat.h" -GLOBAL BYTE copyright[] = +char copyright[] = "(C) Copyright 1995-2002 Pasquale J. Villani and The FreeDOS Project.\n" "All Rights Reserved. This is free software and comes with ABSOLUTELY NO\n" "WARRANTY; you can redistribute it and/or modify it under the terms of the\n" @@ -58,7 +58,7 @@ GLOBAL BYTE DOSFAR os_release[]; GLOBAL seg DOSFAR RootPsp; /* Root process -- do not abort */ extern struct dpb FAR *DOSFAR ASM DPBp; /* First drive Parameter Block */ -extern cdstbl FAR *DOSFAR ASM CDSp; /* Current Directory Structure */ +extern struct cds FAR *DOSFAR ASM CDSp; /* Current Directory Structure */ extern struct dhdr FAR *DOSFAR ASM clock, /* CLOCK$ device */ FAR * DOSFAR ASM syscon; /* console device */ @@ -169,7 +169,7 @@ VOID ASMCFUNC FreeDOSmain(void) setvec(0, int0_handler); /* zero divide */ setvec(1, empty_handler); /* single step */ setvec(3, empty_handler); /* debug breakpoint */ - setvec(6, empty_handler); /* invalid opcode */ + setvec(6, int6_handler); /* invalid opcode */ /* clear the Init BSS area (what normally the RTL does */ memset(_ib_start, 0, _ib_end - _ib_start); @@ -315,7 +315,7 @@ STATIC VOID FsConfig(VOID) /* Initialize the current directory structures */ for (i = 0; i < lastdrive; i++) { - struct cds FAR *pcds_table = &CDSp->cds_table[i]; + struct cds FAR *pcds_table = &CDSp[i]; fmemcpy(pcds_table->cdsCurrentPath, "A:\\\0", 4); @@ -371,6 +371,8 @@ STATIC VOID signon() printf(" - MSC"); #elif defined(__WATCOMC__) printf(" - WATCOMC"); +#elif defined(__GNUC__) + printf(" - GNUC"); /* this is hypothetical only */ #else generate some bullshit error here, as the compiler should be known #endif @@ -443,20 +445,19 @@ STATIC void kernel() { /* insert /D, /Y as first argument */ - int cmdEnd, i, slen = 3; /* strlen(insertString); */ + char *p, *q; - for (cmdEnd = 0; cmdEnd < sizeof(Cmd.ctBuffer); cmdEnd++) + for (p = Cmd.ctBuffer; p < &Cmd.ctBuffer[Cmd.ctCount]; p++) { - if (Cmd.ctBuffer[cmdEnd] == ' ' || - Cmd.ctBuffer[cmdEnd] == '\t' || Cmd.ctBuffer[cmdEnd] == '\r') + if (*p == ' ' || *p == '\t' || *p == '\r') { - for (i = sizeof(Cmd.ctBuffer) - slen - 1; i >= cmdEnd; i--) - Cmd.ctBuffer[i + slen] = Cmd.ctBuffer[i]; + for (q = &Cmd.ctBuffer[Cmd.ctCount - 1]; q >= p; q--) + q[3] = q[0]; - fmemcpy(&Cmd.ctBuffer[cmdEnd], insertString, slen); - - Cmd.ctCount += slen; + fmemcpy(p, insertString, 3); + Cmd.ctCount += 3; + printf("%d %s\n", Cmd.ctCount, Cmd.ctBuffer); break; } } @@ -529,8 +530,8 @@ STATIC VOID update_dcb(struct dhdr FAR * dhp) dpb->dpb_flags = M_CHANGED; if ((CDSp != 0) && (nblkdev < lastdrive)) { - CDSp->cds_table[nblkdev].cdsDpb = dpb; - CDSp->cds_table[nblkdev].cdsFlags = CDSPHYSDRV; + CDSp[nblkdev].cdsDpb = dpb; + CDSp[nblkdev].cdsFlags = CDSPHYSDRV; } ++dpb; ++nblkdev; diff --git a/kernel/memmgr.c b/kernel/memmgr.c index ecacaf72..05d5fe96 100644 --- a/kernel/memmgr.c +++ b/kernel/memmgr.c @@ -34,10 +34,6 @@ static BYTE *memmgrRcsId = "$Id$"; #endif -VOID mcb_init(); -VOID mcb_print(); -VOID show_chain(); - /*#define nxtMCBsize(mcb,size) \ MK_FP(far2para((VOID FAR *) (mcb)) + (size) + 1, 0) */ @@ -102,6 +98,11 @@ VOID FAR * add_far(VOID FAR * fp, ULONG off) if (FP_SEG(fp) == 0xffff) return ((BYTE FAR *) fp) + FP_OFF(off); +#ifndef I86 + if (FP_SEG(fp) == 0) + return ((BYTE FAR *) fp) + FP_OFF(off); +#endif + off += FP_OFF(fp); off2 = ((off >> 16) << 12) + ((UWORD) off >> 4); @@ -111,13 +112,18 @@ VOID FAR * add_far(VOID FAR * fp, ULONG off) /* * Return a normalized far pointer */ -VOID FAR * adjust_far(VOID FAR * fp) +void FAR * adjust_far(const void FAR * fp) { /* and return an adddress adjusted to the nearest paragraph */ /* boundary. */ if (FP_SEG(fp) == 0xffff) - return fp; + return (void FAR *)fp; + +#ifndef I86 + if (FP_SEG(fp) == 0) + return (void FAR *)fp; +#endif return MK_FP(FP_SEG(fp) + (FP_OFF(fp) >> 4), FP_OFF(fp) & 0xf); } @@ -151,9 +157,13 @@ COUNT DosMemAlloc(UWORD size, COUNT mode, seg FAR * para, /* Hack to the Umb Region direct for now. Save time and program space. */ - if ((mode != LARGEST) && (mode & (FIRST_FIT_UO | FIRST_FIT_U)) && - uppermem_link && uppermem_root != 0xffff) - p = para2far(uppermem_root); + if (uppermem_link && uppermem_root != 0xffff) + { + COUNT tmpmode = (mode == LARGEST ? mem_access_mode : mode); + if ((mode != LARGEST || size == 0xffff) && + (tmpmode & (FIRST_FIT_UO | FIRST_FIT_U))) + p = para2far(uppermem_root); + } /* Search through memory blocks */ FOREVER @@ -290,42 +300,6 @@ COUNT DosMemLargest(UWORD FAR * size) *size = 0; DosMemAlloc(0xffff, LARGEST, &dummy, size); return *size ? SUCCESS : DE_NOMEM; - -#if 0 - REG mcb FAR *p; - /* Initialize */ - p = ((mem_access_mode & (FIRST_FIT_UO | FIRST_FIT_U)) && uppermem_link - && uppermem_root != 0xffff) ? para2far(uppermem_root) : para2far(first_mcb); - - /* Cycle through the whole MCB chain to find the largest unused - area. Join all unused areas together. */ - *size = 0; /* nothing found */ - FOREVER - { - if (!mcbValid(p)) /* corrupted MCB chain */ - return DE_MCBDESTRY; - - if (mcbFree(p)) - { /* test if this is the largest block */ - /* first join this unused block with all following unused - blocks */ - if (joinMCBs(p) != SUCCESS) - return DE_MCBDESTRY; - - /* Now test */ - if (*size < p->m_size) - *size = p->m_size; - } - - if (p->m_type == MCB_LAST) /* that was last one in chain */ - break; - p = nxtMCB(p); - } - - /* If *size is still zero, aka nothing had changed, either no unused - block was found at all or a zero-length block only. - Both is considered as a failure */ -#endif } /* diff --git a/kernel/newstuff.c b/kernel/newstuff.c index 2d3cc759..ce6c5d74 100644 --- a/kernel/newstuff.c +++ b/kernel/newstuff.c @@ -128,7 +128,7 @@ COUNT get_verify_drive(char FAR * src) drive = ((src[0] - 1) | 0x20) - ('a' - 1); else return default_drive; - if (drive < lastdrive && CDSp->cds_table[drive].cdsFlags & CDSVALID) + if (drive < lastdrive && CDSp[drive].cdsFlags & CDSVALID) return drive; else return DE_INVLDDRV; @@ -246,7 +246,7 @@ COUNT truename(char FAR * src, char FAR * dest, COUNT t) while ((src[0] == '.') && (src[1] == '\\')) src += 2; - current_ldt = &CDSp->cds_table[i]; + current_ldt = &CDSp[i]; /* Always give the redirector a chance to rewrite the filename */ fmemcpy(bufp - 1, src, sizeof(buf) - (bufp - buf)); diff --git a/kernel/proto.h b/kernel/proto.h index 5d042934..5330aba1 100644 --- a/kernel/proto.h +++ b/kernel/proto.h @@ -228,7 +228,7 @@ COUNT DosDevIOctl(iregs FAR * r); seg far2para(VOID FAR * p); seg long2para(ULONG size); VOID FAR *add_far(VOID FAR * fp, ULONG off); -VOID FAR *adjust_far(VOID FAR * fp); +void FAR *adjust_far(const void FAR * fp); COUNT DosMemAlloc(UWORD size, COUNT mode, seg FAR * para, UWORD FAR * asize); COUNT DosMemLargest(UWORD FAR * size); @@ -328,12 +328,10 @@ const UWORD *is_leap_year_monthdays(UWORD year); UWORD DaysFromYearMonthDay(UWORD Year, UWORD Month, UWORD DayOfMonth); /* task.c */ -COUNT ChildEnv(exec_blk FAR * exp, UWORD * pChildEnvSeg, - char far * pathname); VOID new_psp(psp FAR * p, int psize); VOID return_user(void); COUNT DosExec(COUNT mode, exec_blk FAR * ep, BYTE FAR * lp); -LONG DosGetFsize(COUNT hndl); +ULONG DosGetFsize(COUNT hndl); VOID InitPSP(VOID); /* newstuff.c */ diff --git a/kernel/task.c b/kernel/task.c index 8644ab86..4bd5c7f8 100644 --- a/kernel/task.c +++ b/kernel/task.c @@ -42,7 +42,12 @@ static BYTE *RcsId = #define LOAD_HIGH 0x80 -static exe_header header; +/* static exe_header ExeHeader; + to save some bytes, both static and on stack, + we recycle SecPathBuffer TE */ + +#define ExeHeader (*(exe_header *)(SecPathName + 0)) +#define TempExeBlock (*(exec_blk *)(SecPathName + sizeof(exe_header))) #define CHUNK 32256 #define MAXENV 32768u @@ -53,20 +58,7 @@ static exe_header header; + 1 byte: '\0' -- 1999/04/21 ska */ -#ifndef PROTO -COUNT ChildEnv(exec_blk FAR *, UWORD *, char far *); -#else -COUNT ChildEnv(); -#endif - -LONG doslseek(COUNT fd, LONG foffset, COUNT origin) -{ - LONG set_pos; - DosSeek(fd, foffset, origin, (ULONG *) & set_pos); - return set_pos; -} - -LONG DosGetFsize(COUNT hndl) +ULONG DosGetFsize(COUNT hndl) { sft FAR *s; /* sfttbl FAR *sp;*/ @@ -89,8 +81,7 @@ LONG DosGetFsize(COUNT hndl) return dos_getfsize(s->sft_status); } -COUNT ChildEnv(exec_blk FAR * exp, UWORD * pChildEnvSeg, - char far * pathname) +STATIC COUNT ChildEnv(exec_blk * exp, UWORD * pChildEnvSeg, char far * pathname) { BYTE FAR *pSrc; BYTE FAR *pDest; @@ -157,10 +148,11 @@ COUNT ChildEnv(exec_blk FAR * exp, UWORD * pChildEnvSeg, pDest += sizeof(UWORD) / sizeof(BYTE); /* copy complete pathname */ - if ((RetCode = truename(pathname, pDest, TRUE)) != SUCCESS) + if ((RetCode = truename(pathname, PriPathName, CDS_MODE_SKIP_PHYSICAL)) < SUCCESS) { return RetCode; } + fstrcpy(pDest, PriPathName); /* Theoretically one could either: + resize the already allocated block to best-fit behind the pathname, or @@ -309,194 +301,209 @@ STATIC UWORD patchPSP(UWORD pspseg, UWORD envseg, exec_blk FAR * exb, /* return value: AX value to be passed based on FCB values */ return ((psp->ps_fcb1.fcb_drive < lastdrive && - CDSp->cds_table[psp->ps_fcb1.fcb_drive]. - cdsFlags & CDSVALID) ? 0 : 0xff) + ((psp->ps_fcb2.fcb_drive < - lastdrive - && CDSp->cds_table[psp-> - ps_fcb2. - fcb_drive]. - cdsFlags & CDSVALID) ? 0 : - 0xff) * 0x100; + CDSp[psp->ps_fcb1.fcb_drive].cdsFlags & CDSVALID) ? 0 : 0xff) + + ((psp->ps_fcb2.fcb_drive < lastdrive && + CDSp[psp->ps_fcb2.fcb_drive].cdsFlags & CDSVALID) ? 0 : 0xff) * 0x100; } -COUNT DosComLoader(BYTE FAR * namep, exec_blk FAR * exp, COUNT mode) +int load_transfer(UWORD ds, exec_blk *exp, UWORD fcbcode, COUNT mode) { - COUNT rc - /* err */ - /*,env_size */ ; - COUNT nread; - UWORD mem; - UWORD env, asize; - BYTE FAR *sp; - psp FAR *p; + psp FAR *p = MK_FP(ds, 0); psp FAR *q = MK_FP(cu_psp, 0); - iregs FAR *irp; - LONG com_size; + + /* Transfer control to the executable */ + p->ps_parent = cu_psp; + p->ps_prevpsp = q; + q->ps_stack = (BYTE FAR *)user_r; + user_r->FLAGS &= ~FLG_CARRY; + + cu_psp = ds; + dta = p->ps_dta; + + if (mode == LOADNGO) + { + iregs FAR *irp; + + /* build the user area on the stack */ + irp = (iregs FAR *)(exp->exec.stack - sizeof(iregs)); + + /* start allocating REGs */ + irp->ES = irp->DS = ds; + irp->CS = FP_SEG(exp->exec.start_addr); + irp->IP = FP_OFF(exp->exec.start_addr); + irp->AX = fcbcode; + irp->BX = irp->CX = irp->DX = irp->SI = irp->DI = irp->BP = 0; + irp->FLAGS = 0x200; + + if (InDOS) + --InDOS; + exec_user(irp); + + /* We should never be here + fatal("KERNEL RETURNED!!!"); */ + } + /* mode == LOAD */ + return SUCCESS; +} - int ModeLoadHigh = mode & 0x80; - UBYTE UMBstate = uppermem_link; +/* Now find out how many paragraphs are available + considering a threshold, trying HIGH then LOW */ +STATIC int ExecMemLargest(UWORD *asize, UWORD threshold) +{ + int rc = DosMemLargest(asize); + /* less memory than the .COM/.EXE file has: + try low memory first */ + if ((mem_access_mode & 0x80) && + (rc != SUCCESS || *asize < threshold)) + { + mem_access_mode &= ~0x80; + rc = DosMemLargest(asize); + mem_access_mode |= 0x80; + } + return (*asize < threshold ? DE_NOMEM : rc); +} - mode &= 0x7f; +STATIC int ExecMemAlloc(UWORD size, seg *para, UWORD *asize) +{ + /* We can still get an error on first fit if the above */ + /* returned size was a best fit case */ + /* ModeLoadHigh = 80 = try high, then low */ + int rc = DosMemAlloc(size, mem_access_mode, para, asize); - if (mode != OVERLAY) + if (rc != SUCCESS) { - - if ((rc = ChildEnv(exp, &env, namep)) != SUCCESS) + if (rc == DE_NOMEM) { - return rc; + rc = DosMemAlloc(0, LARGEST, para, asize); + if ((mem_access_mode & 0x80) && (rc != SUCCESS)) + { + mem_access_mode &= ~0x80; + rc = DosMemAlloc(0, LARGEST, para, asize); + mem_access_mode |= 0x80; + } } + } + else + { + /* with no error, we got exactly what we asked for */ + *asize = size; + } - /* COMFILES will always be loaded in largest area. is that true TE */ - - /* Now find out how many paragraphs are available */ - if ((rc = DosMemLargest((seg FAR *) & asize)) != SUCCESS) - { - DosMemFree(env); - return rc; - } - com_size = asize; + /* This should never happen, but ... */ + if (rc == SUCCESS && *asize < size) + { + DosMemFree(*para); + return DE_NOMEM; + } + return rc; +} - if (ModeLoadHigh) +COUNT DosComLoader(BYTE FAR * namep, exec_blk * exp, COUNT mode, COUNT fd) +{ + UWORD mem; + UWORD env, asize = 0; + + { + UWORD com_size; { - DosUmbLink(1); /* link in UMB's */ + ULONG com_size_long = DosGetFsize(fd); + /* maximally 64k - 256 bytes stack - + 256 bytes psp */ + com_size = (min(com_size_long, 0xfe00u) >> 4) + 0x10; } - /* Allocate our memory and pass back any errors */ - if ((rc = - DosMemAlloc((seg) com_size, mem_access_mode, (seg FAR *) & mem, - (UWORD FAR *) & asize)) < 0) + if ((mode & 0x7f) != OVERLAY) { - if (rc == DE_NOMEM) + COUNT rc; + UBYTE UMBstate = uppermem_link; + UBYTE orig_mem_access = mem_access_mode; + + if (mode & 0x80) { - if ((rc = - DosMemAlloc(0, LARGEST, (seg FAR *) & mem, - (UWORD FAR *) & asize)) < 0) - { - DosMemFree(env); - return rc; - } - /* This should never happen, but ... */ - if (asize < com_size) - { - DosMemFree(mem); - DosMemFree(env); - return rc; - } + mem_access_mode |= 0x80; + DosUmbLink(1); /* link in UMB's */ } - else + + rc = ChildEnv(exp, &env, namep); + + /* COMFILES will always be loaded in largest area. is that true TE */ + /* yes, see RBIL, int21/ah=48 -- Bart */ + + if (rc == SUCCESS) + rc = ExecMemLargest(&asize, com_size); + + if (rc == SUCCESS) + /* Allocate our memory and pass back any errors */ + rc = ExecMemAlloc(asize, &mem, &asize); + + if (rc != SUCCESS) + DosMemFree(env); + + if (mode & 0x80) { - DosMemFree(env); /* env may be 0 */ - return rc; + DosUmbLink(UMBstate); /* restore link state */ + mem_access_mode = orig_mem_access; + mode &= 0x7f; } - } - ++mem; - } - else - mem = exp->load.load_seg; - if (ModeLoadHigh) - { - DosUmbLink(UMBstate); /* restore link state */ + if (rc != SUCCESS) + return rc; + + ++mem; + } + else + mem = exp->load.load_seg; } #ifdef DEBUG printf("DosComLoader. Loading '%S' at %04x\n", namep, mem); #endif /* Now load the executable */ - /* If file not found - error */ - /* NOTE - this is fatal because we lost it in transit */ - /* from DosExec! */ - if ((rc = DosOpen(namep, 0)) < 0) -#if 0 - fatal("(DosComLoader) com file lost in transit") -#endif - ; - - /* do it in 32K chunks */ - if ((com_size = DosGetFsize(rc)) != 0) { - if (mode == OVERLAY) /* memory already allocated */ - sp = MK_FP(mem, 0); - else - { /* test the filesize against the allocated memory */ + BYTE FAR *sp; + ULONG tmp; + if (mode == OVERLAY) /* memory already allocated */ + sp = MK_FP(mem, 0); + else /* test the filesize against the allocated memory */ sp = MK_FP(mem, sizeof(psp)); - /* This is a potential problem, what to do with .COM files larger than - the allocated memory? - MS DOS always only loads the very first 64KB - sizeof(psp) bytes. - -- 1999/04/21 ska */ + /* MS DOS always only loads the very first 64KB - sizeof(psp) bytes. + -- 1999/04/21 ska */ - /* BUG !! in case of LH, memory may be smaller then 64K TE */ - - if (com_size > ((LONG) asize << 4)) /* less memory than the .COM file has */ - com_size = (LONG) asize << 4; - } - do - { - nread = DosRead(rc, CHUNK, sp, &UnusedRetVal); - sp = add_far((VOID FAR *) sp, (ULONG) nread); - } - while ((com_size -= nread) > 0 && nread == CHUNK); + /* rewind to start */ + DosSeek(fd, 0, 0, &tmp); + /* read everything, but at most 64K - sizeof(PSP) */ + DosRead(fd, 0xff00, sp, &UnusedRetVal); + DosClose(fd); } - DosClose(rc); if (mode == OVERLAY) return SUCCESS; - - /* point to the PSP so we can build it */ - p = MK_FP(mem, 0); - setvec(0x22, MK_FP(user_r->CS, user_r->IP)); - new_psp(p, mem + asize); - - asize = patchPSP(mem - 1, env, exp, namep); /* asize=fcbcode for ax */ - - /* Transfer control to the executable */ - p->ps_parent = cu_psp; - p->ps_prevpsp = (BYTE FAR *) MK_FP(cu_psp, 0); - q->ps_stack = (BYTE FAR *) user_r; - user_r->FLAGS &= ~FLG_CARRY; - cu_psp = mem; - dta = p->ps_dta; - - switch (mode) + { - case LOADNGO: - { - /* BUG !! - this works only, if COMSIZE >= 64K - in case of LH, this is not necessarily true - */ - - *((UWORD FAR *) MK_FP(mem, 0xfffe)) = (UWORD) 0; - - /* build the user area on the stack */ - irp = MK_FP(mem, (0xfffe - sizeof(iregs))); - - /* start allocating REGs */ - irp->ES = irp->DS = mem; - irp->CS = mem; - irp->IP = 0x100; - irp->AX = asize; /* fcbcode */ - irp->BX = irp->CX = irp->DX = irp->SI = irp->DI = irp->BP = 0; - irp->FLAGS = 0x200; - - if (InDOS) - --InDOS; - exec_user(irp); - - /* We should never be here - fatal("KERNEL RETURNED!!!"); */ - break; - } - case LOAD: - exp->exec.stack = MK_FP(mem, 0xfffe); - *((UWORD FAR *) exp->exec.stack) = asize; - exp->exec.start_addr = MK_FP(mem, 0x100); - return SUCCESS; + UWORD fcbcode; + + /* point to the PSP so we can build it */ + setvec(0x22, MK_FP(user_r->CS, user_r->IP)); + new_psp(MK_FP(mem, 0), mem + asize); + + fcbcode = patchPSP(mem - 1, env, exp, namep); + /* set asize to end of segment */ + if (asize < 0x1000) + asize = (asize << 4) - 2; + else + asize = 0xfffe; + /* TODO: worry about PSP+6: + CP/M compatibility--size of first segment for .COM files, + while preserving the far call */ + + exp->exec.stack = MK_FP(mem, asize); + exp->exec.start_addr = MK_FP(mem, 0x100); + *((UWORD FAR *) MK_FP(mem, asize)) = (UWORD) 0; + load_transfer(mem, exp, fcbcode, mode); } - - return DE_INVLDFMT; + return SUCCESS; } VOID return_user(void) @@ -542,191 +549,105 @@ VOID return_user(void) exec_user((iregs FAR *) q->ps_stack); } -COUNT DosExeLoader(BYTE FAR * namep, exec_blk FAR * exp, COUNT mode) +COUNT DosExeLoader(BYTE FAR * namep, exec_blk * exp, COUNT mode, COUNT fd) { - COUNT rc; - /*err, */ - /*env_size, */ - - UWORD mem, env, asize, start_seg; - - int ModeLoadHigh = mode & 0x80; - UBYTE UMBstate = uppermem_link; - - mode &= 0x7f; - - /* Clone the environement and create a memory arena */ - if (mode != OVERLAY) - { - if ((rc = ChildEnv(exp, &env, namep)) != SUCCESS) - return rc; - } - else - mem = exp->load.load_seg; - + UWORD mem, env, start_seg, asize = 0; + ULONG exe_size, tmp; { ULONG image_size; ULONG image_offset; - LONG exe_size; - mcb FAR *mp; - - /* compute image offset from the header */ - image_offset = (ULONG) header.exHeaderSize * 16; + + /* compute image offset from the ExeHeader */ + image_offset = (ULONG) ExeHeader.exHeaderSize * 16; /* compute image size by removing the offset from the */ /* number pages scaled to bytes plus the remainder and */ /* the psp */ /* First scale the size */ - image_size = (ULONG) header.exPages * 512; + image_size = (ULONG) ExeHeader.exPages * 512; /* remove the offset */ image_size -= image_offset; - - /* and finally add in the psp size */ - if (mode != OVERLAY) - image_size += sizeof(psp); /*TE 03/20/01 */ - - if (mode != OVERLAY) + + /* We should not attempt to allocate + memory if we are overlaying the current process, because the new + process will simply re-use the block we already have allocated. + Jun 11, 2000 - rbc */ + + if ((mode & 0x7f) != OVERLAY) { - if (ModeLoadHigh) + UBYTE UMBstate = uppermem_link; + UBYTE orig_mem_access = mem_access_mode; + COUNT rc; + + /* and finally add in the psp size */ + image_size += sizeof(psp); /*TE 03/20/01 */ + exe_size = (ULONG) long2para(image_size) + ExeHeader.exMinAlloc; + + /* Clone the environement and create a memory arena */ + if ((mode & 0x7f) != OVERLAY && (mode & 0x80)) { DosUmbLink(1); /* link in UMB's */ - mem_access_mode |= ModeLoadHigh; - } - - /* Now find out how many paragraphs are available */ - if ((rc = DosMemLargest((seg FAR *) & asize)) != SUCCESS) - { - DosMemFree(env); - return rc; - } - - exe_size = (LONG) long2para(image_size) + header.exMinAlloc; - - /* + long2para((LONG) sizeof(psp)); ?? see above - image_size += sizeof(psp) -- 1999/04/21 ska */ - if (exe_size > asize && (mem_access_mode & 0x80)) - { - /* First try low memory */ - mem_access_mode &= ~0x80; - rc = DosMemLargest((seg FAR *) & asize); mem_access_mode |= 0x80; - if (rc != SUCCESS) - { - DosMemFree(env); - return rc; - } - } - if (exe_size > asize) - { - DosMemFree(env); - return DE_NOMEM; } - exe_size = (LONG) long2para(image_size) + header.exMaxAlloc; - /* + long2para((LONG) sizeof(psp)); ?? -- 1999/04/21 ska */ + + rc = ChildEnv(exp, &env, namep); + + if (rc == SUCCESS) + /* Now find out how many paragraphs are available */ + rc = ExecMemLargest(&asize, (UWORD)exe_size); + + exe_size = (ULONG) long2para(image_size) + ExeHeader.exMaxAlloc; if (exe_size > asize) exe_size = asize; - - /* TE if header.exMinAlloc == header.exMaxAlloc == 0, + + /* TE if ExeHeader.exMinAlloc == ExeHeader.exMaxAlloc == 0, DOS will allocate the largest possible memory area and load the image as high as possible into it. discovered (and after that found in RBIL), when testing NET */ - - if ((header.exMinAlloc | header.exMaxAlloc) == 0) + + if ((ExeHeader.exMinAlloc | ExeHeader.exMaxAlloc) == 0) exe_size = asize; - - /* /// Removed closing curly brace. We should not attempt to allocate - memory if we are overlaying the current process, because the new - process will simply re-use the block we already have allocated. - This was causing execl() to fail in applications which use it to - overlay (replace) the current exe file with a new one. - Jun 11, 2000 - rbc - } */ - + /* Allocate our memory and pass back any errors */ - /* We can still get an error on first fit if the above */ - /* returned size was a bet fit case */ - /* ModeLoadHigh = 80 = try high, then low */ - if ((rc = - DosMemAlloc((seg) exe_size, mem_access_mode | ModeLoadHigh, - (seg FAR *) & mem, (UWORD FAR *) & asize)) < 0) + if (rc == SUCCESS) + rc = ExecMemAlloc((UWORD)exe_size, &mem, &asize); + + if (rc != SUCCESS) + DosMemFree(env); + + if (mode & 0x80) { - if (rc == DE_NOMEM) - { - if ((rc = - DosMemAlloc(0, LARGEST, (seg FAR *) & mem, - (UWORD FAR *) & asize)) < 0) - { - DosMemFree(env); - return rc; - } - /* This should never happen, but ... */ - if (asize < exe_size) - { - DosMemFree(mem); - DosMemFree(env); - return rc; - } - } - else - { - DosMemFree(env); - return rc; - } + mem_access_mode = orig_mem_access; /* restore old situation */ + DosUmbLink(UMBstate); /* restore link state */ } - else - /* with no error, we got exactly what we asked for */ - asize = exe_size; - + if (rc != SUCCESS) + return rc; + + mode &= 0x7f; /* forget about high loading from now on */ + #ifdef DEBUG printf("DosExeLoader. Loading '%S' at %04x\n", namep, mem); #endif - -/* /// Added open curly brace and "else" clause. We should not attempt - to allocate memory if we are overlaying the current process, because - the new process will simply re-use the block we already have allocated. - This was causing execl() to fail in applications which use it to - overlay (replace) the current exe file with a new one. - Jun 11, 2000 - rbc */ - } - else - asize = exe_size; -/* /// End of additions. Jun 11, 2000 - rbc */ - - if (ModeLoadHigh) - { - mem_access_mode &= ~ModeLoadHigh; /* restore old situation */ - DosUmbLink(UMBstate); /* restore link state */ - } - - if (mode != OVERLAY) - { + /* memory found large enough - continue processing */ - mp = MK_FP(mem, 0); ++mem; + +/* /// Added open curly brace and "else" clause. We should not attempt + to allocate memory if we are overlaying the current process, because + the new process will simply re-use the block we already have allocated. + This was causing execl() to fail in applications which use it to + overlay (replace) the current exe file with a new one. + Jun 11, 2000 - rbc */ } - else - mem = exp->load.load_seg; - - /* create the start seg for later computations */ - if (mode == OVERLAY) - start_seg = mem; - else + else /* !!OVERLAY */ { - start_seg = mem + long2para((LONG) sizeof(psp)); + mem = exp->load.load_seg; } /* Now load the executable */ - /* If file not found - error */ - /* NOTE - this is fatal because we lost it in transit */ - /* from DosExec! */ - if ((rc = DosOpen(namep, 0)) < 0) - { -#if 0 - fatal("(DosExeLoader) exe file lost in transit"); -#endif - } /* offset to start of image */ - if (doslseek(rc, image_offset, 0) != image_offset) + DosSeek(fd, image_offset, 0, &tmp); + if (tmp != image_offset) { if (mode != OVERLAY) { @@ -735,41 +656,39 @@ COUNT DosExeLoader(BYTE FAR * namep, exec_blk FAR * exp, COUNT mode) } return DE_INVLDDATA; } - - /* read in the image in 32K chunks */ + + /* create the start seg for later computations */ + start_seg = mem; + exe_size = image_size; if (mode != OVERLAY) { - exe_size = image_size - sizeof(psp); - } - else - exe_size = image_size; - - if (exe_size > 0) - { - UCOUNT nBytesRead; - BYTE FAR *sp; - - if (mode != OVERLAY) + exe_size -= sizeof(psp); + start_seg += long2para(sizeof(psp)); + if (exe_size > 0 && (ExeHeader.exMinAlloc == 0) && (ExeHeader.exMaxAlloc == 0)) { - if ((header.exMinAlloc == 0) && (header.exMaxAlloc == 0)) - { - /* then the image should be placed as high as possible */ - start_seg = start_seg + mp->m_size - (image_size + 15) / 16; - } + mcb FAR *mp = MK_FP(mem - 1, 0); + + /* then the image should be placed as high as possible */ + start_seg = start_seg + mp->m_size - (image_size + 15) / 16; } + } + } - sp = MK_FP(start_seg, 0x0); - - do - { - nBytesRead = - DosRead((COUNT) rc, - (COUNT) (exe_size < CHUNK ? exe_size : CHUNK), - (VOID FAR *) sp, &UnusedRetVal); - sp = add_far((VOID FAR *) sp, (ULONG) nBytesRead); - exe_size -= nBytesRead; - } - while (nBytesRead && exe_size > 0); + /* read in the image in 32K chunks */ + { + UCOUNT nBytesRead; + BYTE FAR *sp = MK_FP(start_seg, 0x0); + + while (exe_size > 0) + { + nBytesRead = + DosRead(fd, + (COUNT) (exe_size < CHUNK ? exe_size : CHUNK), + (VOID FAR *) sp, &UnusedRetVal); + if (nBytesRead == 0) + break; + sp = add_far((VOID FAR *) sp, nBytesRead); + exe_size -= nBytesRead; } } @@ -777,12 +696,13 @@ COUNT DosExeLoader(BYTE FAR * namep, exec_blk FAR * exp, COUNT mode) COUNT i; UWORD reloc[2]; seg FAR *spot; + ULONG tmp; - doslseek(rc, (LONG) header.exRelocTable, 0); - for (i = 0; i < header.exRelocItems; i++) + DosSeek(fd, ExeHeader.exRelocTable, 0, &tmp); + for (i = 0; i < ExeHeader.exRelocItems; i++) { if (DosRead - (rc, sizeof(reloc), (VOID FAR *) & reloc[0], + (fd, sizeof(reloc), (VOID FAR *) & reloc[0], &UnusedRetVal) != sizeof(reloc)) { return DE_INVLDDATA; @@ -802,69 +722,29 @@ COUNT DosExeLoader(BYTE FAR * namep, exec_blk FAR * exp, COUNT mode) } /* and finally close the file */ - DosClose(rc); + DosClose(fd); /* exit here for overlay */ if (mode == OVERLAY) return SUCCESS; { - psp FAR *p; - psp FAR *q = MK_FP(cu_psp, 0); + UWORD fcbcode; /* point to the PSP so we can build it */ - p = MK_FP(mem, 0); setvec(0x22, MK_FP(user_r->CS, user_r->IP)); - new_psp(p, mem + asize); + new_psp(MK_FP(mem, 0), mem + asize); - asize = patchPSP(mem - 1, env, exp, namep); /* asize = fcbcode */ + fcbcode = patchPSP(mem - 1, env, exp, namep); + exp->exec.stack = + MK_FP(ExeHeader.exInitSS + start_seg, ExeHeader.exInitSP); + exp->exec.start_addr = + MK_FP(ExeHeader.exInitCS + start_seg, ExeHeader.exInitIP); /* Transfer control to the executable */ - p->ps_parent = cu_psp; - p->ps_prevpsp = (BYTE FAR *) MK_FP(cu_psp, 0); - q->ps_stack = (BYTE FAR *) user_r; - user_r->FLAGS &= ~FLG_CARRY; - - switch (mode) - { - case LOADNGO: - { - /* build the user area on the stack */ - iregs FAR *irp = MK_FP(header.exInitSS + start_seg, - ((header.exInitSP - - sizeof(iregs)) & 0xffff)); - - /* start allocating REGs */ - /* Note: must match es & ds memory segment */ - irp->ES = irp->DS = mem; - irp->CS = header.exInitCS + start_seg; - irp->IP = header.exInitIP; - irp->AX = asize; /* asize = fcbcode */ - irp->BX = irp->CX = irp->DX = irp->SI = irp->DI = irp->BP = 0; - irp->FLAGS = 0x200; - - cu_psp = mem; - dta = p->ps_dta; - - if (InDOS) - --InDOS; - exec_user(irp); - /* We should never be here - fatal("KERNEL RETURNED!!!"); */ - break; - } - - case LOAD: - cu_psp = mem; - exp->exec.stack = - MK_FP(header.exInitSS + start_seg, header.exInitSP); - *((UWORD FAR *) exp->exec.stack) = asize; /* fcbcode */ - exp->exec.start_addr = - MK_FP(header.exInitCS + start_seg, header.exInitIP); - return SUCCESS; - } + load_transfer(mem, exp, fcbcode, mode); } - return DE_INVLDFMT; + return SUCCESS; } /* mode = LOAD or EXECUTE @@ -876,36 +756,40 @@ COUNT DosExeLoader(BYTE FAR * namep, exec_blk FAR * exp, COUNT mode) COUNT DosExec(COUNT mode, exec_blk FAR * ep, BYTE FAR * lp) { COUNT rc; - exec_blk leb; + COUNT fd; -/* BYTE FAR *cp;*/ - BOOL bIsCom = FALSE; + if ((mode & 0x7f) > 3 || (mode & 0x7f) == 2) + return DE_INVLDFMT; - fmemcpy(&leb, ep, sizeof(exec_blk)); + fmemcpy(&TempExeBlock, ep, sizeof(exec_blk)); /* If file not found - free ram and return error */ - if ((rc = DosOpen(lp, 0)) < 0) + if (IsDevice(lp) || /* we don't want to execute C:>NUL */ +#if 0 + (fd = (short)DosOpen(lp, O_LEGACY | O_OPEN | O_RDONLY, 0)) < 0) +#else + (fd = (short)DosOpen(lp, 0)) < 0) +#endif { return DE_FILENOTFND; } + + rc = DosRead(fd, sizeof(exe_header), (BYTE FAR *)&ExeHeader, &UnusedRetVal); - if (DosRead(rc, sizeof(exe_header), (VOID FAR *) & header, &UnusedRetVal) - != sizeof(exe_header)) - { - bIsCom = TRUE; - } - DosClose(rc); - - if (bIsCom || header.exSignature != MAGIC) + if (rc == sizeof(exe_header) && + (ExeHeader.exSignature == MAGIC || ExeHeader.exSignature == OLD_MAGIC)) { - rc = DosComLoader(lp, &leb, mode); + rc = DosExeLoader(lp, &TempExeBlock, mode, fd); } - else + else if (rc != 0) { - rc = DosExeLoader(lp, &leb, mode); + rc = DosComLoader(lp, &TempExeBlock, mode, fd); } + + DosClose(fd); + if (mode == LOAD && rc == SUCCESS) - fmemcpy(ep, &leb, sizeof(exec_blk)); + fmemcpy(ep, &TempExeBlock, sizeof(exec_blk)); return rc; } From dfeb595f8e292679239de71a842a5f8ad96d5832 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sun, 4 Aug 2002 01:14:18 +0000 Subject: [PATCH 149/671] Last changes for kernel 2027 test. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@414 6ac86273-5f31-0410-b378-82cca8765d1b --- docs/contrib.txt | 2 + docs/fdkernel.lsm | 4 +- docs/history.txt | 24 +- hdr/fat.h | 6 +- hdr/sft.h | 2 +- hdr/stacks.inc | 18 +- kernel/chario.c | 63 ++- kernel/dosfns.c | 1137 +++++++++++++++------------------------ kernel/dosnames.c | 311 ++--------- kernel/entry.asm | 6 +- kernel/fatdir.c | 172 +++--- kernel/fatfs.c | 507 ++++++++---------- kernel/fcbfns.c | 474 +++++++---------- kernel/globals.h | 30 +- kernel/init-dat.h | 6 + kernel/int2f.asm | 42 +- kernel/inthndlr.c | 1283 +++++++++++++++++++++------------------------ kernel/ioctl.c | 420 ++++++++------- kernel/main.c | 1 - kernel/newstuff.c | 875 +++++++++++++++++++------------ kernel/nls.c | 2 +- kernel/proto.h | 166 +++--- kernel/systime.c | 14 +- kernel/task.c | 15 +- sys/makefile | 2 +- sys/sys.c | 8 +- 26 files changed, 2465 insertions(+), 3125 deletions(-) diff --git a/docs/contrib.txt b/docs/contrib.txt index 42ac8445..923014d5 100644 --- a/docs/contrib.txt +++ b/docs/contrib.txt @@ -14,6 +14,8 @@ James Tabor (jimtabor@infohwy.com) Eric Biederman (ebiederm+eric@ccr.net) Tom Ehlert (tom.ehlert@ginko.de) Victor Vlasenko (victor_vlasenko@hotbox.ru) +Jeremy Davis (jeremyd@computer.org) +Martin Stromberg (ams@ludd.luth.se) Bart Oldeman (bart@dosemu.org) And last, but not least, a big thanx to Pasquale J. Villani diff --git a/docs/fdkernel.lsm b/docs/fdkernel.lsm index 80dae646..df316802 100644 --- a/docs/fdkernel.lsm +++ b/docs/fdkernel.lsm @@ -1,7 +1,7 @@ Begin3 Title: The FreeDOS Kernel -Version: 2.0.25.c -Entered-date: 17 Nov 2001 +Version: 2.0.27 +Entered-date: xx Aug 2002 Description: The FreeDOS Kernel. Keywords: kernel freedos dos msdos Author: (developers) diff --git a/docs/history.txt b/docs/history.txt index 9bb943d0..600928bd 100644 --- a/docs/history.txt +++ b/docs/history.txt @@ -9,10 +9,31 @@ * disabled fatal() in error.c * Disable the A20 line upon exec (int21/ah=4B). This is necessary for some brain-dead exepacked programs. - * removed unnecessary buffer fields + * removed unnecessary "BUFFERS" fields * proper check for network/non-existing drive for int25/26. * save more bytes on the stack at various places + * made the local registers for inthndlr.c "near" instead of "far". + * fix bug in strchr handling for fcbfns.c (FcbParseFname) ++ Changes Steffen (but changed a lot by Bart) + * new truename (Bart: but without mapPath() style struct) + * merge open/create functions into one extended open function + * also honor the sharing bits better for "open" + * use local 8+3 path names in fatfs.c; merge name+extension + into one array + * take care of filenames that start with ASCII 5: they should be + treated as starting with 0xe5 + * exploit the fact that the filenames are already "truenames", + i.e., fully qualified in fatfs.c. This simplifies parsing a lot. + Changes Bart + * make "if exist c:\dir\nul" working + * honor "do not inherit handle on exec" flag for "open". + * improve the FCB functions so that they set the critical error code + properly + * next_cluster returns "1" instead of DE_xxx in case of failure. + * create one function to do binary character IO (used for CLOCK$ + driver and character drivers such as CON) + * better handling of ABORT/FAIL + * merge all read and write functions * patchobj makefile correction * printf uses va_list etc. * quicker and more robust Watcom build @@ -33,7 +54,6 @@ merge as much as possible from DosExeLoader and DosComLoader (from Tom:) eliminate some structures in low memory * main.c: slightly cleanup "SHELL=" line parsing. - 2002 May 9 - Build 2026b -------- Bart Oldeman (bart@dosemu.org) + Changes Tom diff --git a/hdr/fat.h b/hdr/fat.h index 97703f69..4f4fabaf 100644 --- a/hdr/fat.h +++ b/hdr/fat.h @@ -54,7 +54,8 @@ static BYTE *fat_hRcsId = #define FEXT_SIZE 3 /* FAT deleted flag */ -#define DELETED 0xe5 /* if first char, delete file */ +#define DELETED '\x5' /* if first char, delete file */ +#define EXT_DELETED '\xe5' /* external deleted flag */ /* FAT cluster to physical conversion macros */ #define clus_add(cl_no) ((ULONG) (((ULONG) cl_no - 2L) \ @@ -81,8 +82,7 @@ static BYTE *fat_hRcsId = /* FAT file system directory entry */ struct dirent { - UBYTE dir_name[FNAME_SIZE]; /* Filename */ - UBYTE dir_ext[FEXT_SIZE]; /* Filename extension */ + char dir_name[FNAME_SIZE + FEXT_SIZE]; /* Filename + extension in FCB format */ UBYTE dir_attrib; /* File Attribute */ UBYTE dir_case; /* File case */ UBYTE dir_crtimems; /* Milliseconds */ diff --git a/hdr/sft.h b/hdr/sft.h index 98c5dcc4..e1c1c35b 100644 --- a/hdr/sft.h +++ b/hdr/sft.h @@ -106,7 +106,7 @@ typedef struct _sfttbl { #define SFT_MRDWR 0x0002 /* read/write bit */ #define SFT_MWRITE 0x0001 /* write bit */ #define SFT_MREAD 0x0000 /* ~ write bit */ -#define SFT_OMASK 0x00f3 /* valid open mask */ +#define SFT_OMASK 0xfff3 /* valid open mask */ /* flag bits */ diff --git a/hdr/stacks.inc b/hdr/stacks.inc index 70a87634..383a2217 100644 --- a/hdr/stacks.inc +++ b/hdr/stacks.inc @@ -117,13 +117,15 @@ irp_hi equ 26 ; later ; ; assumption: -; we have never seen MSVC (our only I386 compiler) to use -; anything but eax,ecx, edx +; we have never seen MSVC to use anything but eax,ecx, edx ; so we only protect eax, ebx, ecx, edx to conserve stack space ; ; to save even more stack space, we save only HIGH part of regs ; at some expense of slower execution. it's easier anyway :-) ; +; WATCOM only uses FS: and GS: (using -zff and -zgf) and never +; any high part of the 386 registers +; %IFNDEF I386 @@ -141,6 +143,9 @@ irp_hi equ 26 %macro Protect386Registers 0 %ifdef WATCOM + push fs + push gs + %else ror eax,16 push ax ror eax,16 @@ -153,9 +158,6 @@ irp_hi equ 26 ror edx,16 push dx ror edx,16 - %else - push fs - push gs %endif %endmacro @@ -163,6 +165,9 @@ irp_hi equ 26 %macro Restore386Registers 0 %ifdef WATCOM + pop gs + pop fs + %else ror edx,16 pop dx ror edx,16 @@ -175,9 +180,6 @@ irp_hi equ 26 ror eax,16 pop ax ror eax,16 - %else - pop gs - pop fs %endif %endmacro diff --git a/kernel/chario.c b/kernel/chario.c index 1cef021e..3f3f53c3 100644 --- a/kernel/chario.c +++ b/kernel/chario.c @@ -65,6 +65,40 @@ struct dhdr FAR *finddev(UWORD attr_mask) } #endif +UCOUNT BinaryCharIO(struct dhdr FAR * dev, UCOUNT n, void FAR * bp, unsigned command, COUNT *err) +{ + *err = SUCCESS; + + FOREVER + { + CharReqHdr.r_length = sizeof(request); + CharReqHdr.r_command = command; + CharReqHdr.r_count = n; + CharReqHdr.r_trans = bp; + CharReqHdr.r_status = 0; + execrh(&CharReqHdr, dev); + if (CharReqHdr.r_status & S_ERROR) + { + charloop: + switch (char_error(&CharReqHdr, dev)) + { + case ABORT: + case FAIL: + *err = DE_INVLDACC; + return 0; + case CONTINUE: + break; + case RETRY: + continue; + default: + goto charloop; + } + } + break; + } + return CharReqHdr.r_count; +} + VOID _cso(COUNT c) { if (syscon->dh_attr & ATTR_FASTCON) @@ -72,7 +106,7 @@ VOID _cso(COUNT c) #if defined(__TURBOC__) _AL = c; __int__(0x29); -#else +#elif defined(I86) asm { mov al, byte ptr c; @@ -81,14 +115,7 @@ VOID _cso(COUNT c) #endif return; } - CharReqHdr.r_length = sizeof(request); - CharReqHdr.r_command = C_OUTPUT; - CharReqHdr.r_count = 1; - CharReqHdr.r_trans = (BYTE FAR *) (&c); - CharReqHdr.r_status = 0; - execrh((request FAR *) & CharReqHdr, syscon); - if (CharReqHdr.r_status & S_ERROR) - char_error(&CharReqHdr, syscon); + BinaryCharIO(syscon, 1, &c, C_OUTPUT, &UnusedRetVal); } VOID cso(COUNT c) @@ -97,7 +124,7 @@ VOID cso(COUNT c) con_hold(); if (PrinterEcho) - DosWrite(STDPRN, 1, (BYTE FAR *) & c, (COUNT FAR *) & UnusedRetVal); + DosWrite(STDPRN, 1, (BYTE FAR *) & c, & UnusedRetVal); switch (c) { @@ -125,7 +152,7 @@ VOID cso(COUNT c) VOID sto(COUNT c) { - DosWrite(STDOUT, 1, (BYTE FAR *) & c, (COUNT FAR *) & UnusedRetVal); + DosWrite(STDOUT, 1, (BYTE FAR *) & c, & UnusedRetVal); } VOID mod_cso(REG UCOUNT c) @@ -176,14 +203,7 @@ COUNT con_read(void) { BYTE c; - CharReqHdr.r_length = sizeof(request); - CharReqHdr.r_command = C_INPUT; - CharReqHdr.r_count = 1; - CharReqHdr.r_trans = (BYTE FAR *) & c; - CharReqHdr.r_status = 0; - execrh((request FAR *) & CharReqHdr, syscon); - if (CharReqHdr.r_status & S_ERROR) - char_error(&CharReqHdr, syscon); + BinaryCharIO(syscon, 1, &c, C_INPUT, &UnusedRetVal); if (c == CTL_C) handle_break(); return c; @@ -216,9 +236,8 @@ UCOUNT _sti(BOOL check_break) Do_DosIdle_loop(); if (check_break) con_hold(); - while (GenericRead - (STDIN, 1, (BYTE FAR *) & c, (COUNT FAR *) & UnusedRetVal, - TRUE) != 1) ; + while (BinaryRead(STDIN, &c, & UnusedRetVal) != 1) + ; return c; } diff --git a/kernel/dosfns.c b/kernel/dosfns.c index 04159e5f..c2d3803f 100644 --- a/kernel/dosfns.c +++ b/kernel/dosfns.c @@ -35,11 +35,6 @@ static BYTE *dosfnsRcsId = #include "globals.h" -COUNT get_free_hndl(VOID); -sft FAR * get_free_sft(COUNT *); - -f_node_ptr xlt_fd(COUNT); - /* /// Added for SHARE. - Ron Cemer */ BYTE share_installed = 0; @@ -50,7 +45,7 @@ BYTE share_installed = 0; error. If < 0 is returned, it is the negated error return code, so DOS simply negates this value and returns it in AX. */ -STATIC int share_open_check(char far * filename, /* far pointer to fully qualified filename */ +STATIC int share_open_check(char * filename, /* pointer to fully qualified filename */ unsigned short pspseg, /* psp segment address of owner process */ int openmode, /* 0=read-only, 1=write-only, 2=read-write */ int sharemode); /* SHARE_COMPAT, etc... */ @@ -119,17 +114,13 @@ struct dpb FAR * GetDriveDPB(UBYTE drive, COUNT * rc) } #endif +/* Construct dir-style filename for ASCIIZ 8.3 name */ STATIC VOID DosGetFile(BYTE * lpszPath, BYTE FAR * lpszDosFileName) { - BYTE szLclName[FNAME_SIZE + 1]; - BYTE szLclExt[FEXT_SIZE + 1]; - - ParseDosName(lpszPath, (COUNT *) 0, (BYTE *) 0, - szLclName, szLclExt, FALSE); - SpacePad(szLclName, FNAME_SIZE); - SpacePad(szLclExt, FEXT_SIZE); - fmemcpy(lpszDosFileName, (BYTE FAR *) szLclName, FNAME_SIZE); - fmemcpy(&lpszDosFileName[FNAME_SIZE], (BYTE FAR *) szLclExt, FEXT_SIZE); + char fcbname[FNAME_SIZE + FEXT_SIZE]; + + ParseDosName(lpszPath, fcbname, FALSE); + fmemcpy(lpszDosFileName, fcbname, FNAME_SIZE + FEXT_SIZE); } sft FAR * idx_to_sft(COUNT SftIndex) @@ -146,6 +137,10 @@ sft FAR * idx_to_sft(COUNT SftIndex) { lpCurSft = (sft FAR *) & (sp->sftt_table[SftIndex]); + /* if not opened, the SFT is useless */ + if (lpCurSft->sft_count == 0) + return (sft FAR *) - 1; + /* finally, point to the right entry */ return lpCurSft; } @@ -153,6 +148,7 @@ sft FAR * idx_to_sft(COUNT SftIndex) SftIndex -= sp->sftt_count; } /* If not found, return an error */ + return (sft FAR *) - 1; } @@ -172,303 +168,173 @@ sft FAR *get_sft(UCOUNT hndl) return idx_to_sft(get_sft_idx(hndl)); } -/* - * The `force_binary' parameter is a hack to allow functions 0x01, 0x06, 0x07, - * and function 0x40 to use the same code for performing reads, even though the - * two classes of functions behave quite differently: 0x01 etc. always do - * binary reads, while for 0x40 the type of read (binary/text) depends on what - * the SFT says. -- ror4 - */ -UCOUNT GenericReadSft(sft FAR * s, UCOUNT n, BYTE FAR * bp, - COUNT FAR * err, BOOL force_binary) +UCOUNT DosRWSft(sft FAR * s, UCOUNT n, void FAR * bp, COUNT * err, int mode) { - UCOUNT ReadCount; - - /* Get the SFT block that contains the SFT */ - if (s == (sft FAR *) - 1) + *err = SUCCESS; + if (FP_OFF(s) == (size_t) - 1) { *err = DE_INVLDHNDL; return 0; } - - /* If not open or write permission - exit */ - if (s->sft_count == 0 || (s->sft_mode & SFT_MWRITE)) + /* If for read and write-only or for write and read-only then exit */ + if((mode == XFR_READ && (s->sft_mode & SFT_MWRITE)) || + (mode == XFR_WRITE && !(s->sft_mode & (SFT_MWRITE | SFT_MRDWR)))) { - *err = DE_INVLDACC; + *err = DE_ACCESS; return 0; } - + /* * Do remote first or return error. * must have been opened from remote. */ if (s->sft_flags & SFT_FSHARED) { - COUNT rc; + UCOUNT XferCount; BYTE FAR *save_dta; save_dta = dta; lpCurSft = s; current_filepos = s->sft_posit; /* needed for MSCDEX */ dta = bp; - ReadCount = remote_read(s, n, &rc); + XferCount = (mode == XFR_READ ? remote_read : remote_write)(s, n, err); dta = save_dta; - *err = rc; - return rc == SUCCESS ? ReadCount : 0; + return *err == SUCCESS ? XferCount : 0; } - /* Do a device read if device */ + + /* Do a device transfer if device */ if (s->sft_flags & SFT_FDEVICE) { - request rq; - - /* First test for eof and exit */ - /* immediately if it is */ - if (!(s->sft_flags & SFT_FEOF) || (s->sft_flags & SFT_FNUL)) - { - s->sft_flags &= ~SFT_FEOF; - *err = SUCCESS; - return 0; - } - - /* Now handle raw and cooked modes */ - if (force_binary || (s->sft_flags & SFT_FBINARY)) + if (mode==XFR_READ) { - rq.r_length = sizeof(request); - rq.r_command = C_INPUT; - rq.r_count = n; - rq.r_trans = (BYTE FAR *) bp; - rq.r_status = 0; - execrh((request FAR *) & rq, s->sft_dev); - if (rq.r_status & S_ERROR) + /* First test for eof and exit */ + /* immediately if it is */ + if (!(s->sft_flags & SFT_FEOF) || (s->sft_flags & SFT_FNUL)) { - char_error(&rq, s->sft_dev); + s->sft_flags &= ~SFT_FEOF; + return 0; } - else + + /* Now handle raw and cooked modes */ + if (s->sft_flags & SFT_FBINARY) + return BinaryCharIO(s->sft_dev, n, bp, C_INPUT, err); + if (s->sft_flags & SFT_FCONIN) { - *err = SUCCESS; - return rq.r_count; + UCOUNT ReadCount; + + kb_buf.kb_size = LINESIZE - 1; + ReadCount = sti(&kb_buf); + if (ReadCount < kb_buf.kb_count) + s->sft_flags &= ~SFT_FEOF; + fmemcpy(bp, kb_buf.kb_buf, kb_buf.kb_count); + return ReadCount; } - } - else if (s->sft_flags & SFT_FCONIN) - { - kb_buf.kb_size = LINESIZE - 1; - ReadCount = sti(&kb_buf); - if (ReadCount < kb_buf.kb_count) - s->sft_flags &= ~SFT_FEOF; - fmemcpy(bp, (BYTE FAR *) kb_buf.kb_buf, kb_buf.kb_count); - *err = SUCCESS; - return ReadCount; - } - else - { - *bp = _sti(FALSE); - *err = SUCCESS; + *(char FAR *)bp = _sti(FALSE); return 1; } - } - else - /* a block read */ - { - /* /// Added for SHARE - Ron Cemer */ - if (IsShareInstalled()) + else { - if (s->sft_shroff >= 0) - { - int share_result = share_access_check(cu_psp, - s->sft_shroff, - s->sft_posit, - (unsigned long)n, - 1); - if (share_result != 0) - { - *err = share_result; - return 0; - } - } - } - /* /// End of additions for SHARE - Ron Cemer */ - - ReadCount = rwblock(s->sft_status, bp, n, XFR_READ); - *err = SUCCESS; - return ReadCount; - } - *err = SUCCESS; - return 0; -} - -#if 0 -UCOUNT DosRead(COUNT hndl, UCOUNT n, BYTE FAR * bp, COUNT FAR * err) -{ - return GenericRead(hndl, n, bp, err, FALSE); -} -#endif + /* set to no EOF */ + s->sft_flags |= SFT_FEOF; -UCOUNT DosWriteSft(sft FAR * s, UCOUNT n, const BYTE FAR * bp, COUNT FAR * err) -{ - UCOUNT WriteCount; + /* if null just report full transfer */ + if (s->sft_flags & SFT_FNUL) + return n; - /* Get the SFT block that contains the SFT */ - if (s == (sft FAR *) - 1) - { - *err = DE_INVLDHNDL; - return 0; - } - - /* If this is not opened and it's not a write */ - /* another error */ - if (s->sft_count == 0 || - (!(s->sft_mode & SFT_MWRITE) && !(s->sft_mode & SFT_MRDWR))) - { - *err = DE_ACCESS; - return 0; - } - - if (s->sft_flags & SFT_FSHARED) - { - COUNT rc; - BYTE FAR *save_dta; - - save_dta = dta; - lpCurSft = s; - current_filepos = s->sft_posit; /* needed for MSCDEX */ - dta = (BYTE FAR *)bp; - WriteCount = remote_write(s, n, &rc); - dta = save_dta; - *err = rc; - return rc == SUCCESS ? WriteCount : 0; - } - - /* Do a device write if device */ - if (s->sft_flags & SFT_FDEVICE) - { - request rq; - - /* set to no EOF */ - s->sft_flags |= SFT_FEOF; - - /* if null just report full transfer */ - if (s->sft_flags & SFT_FNUL) - { - *err = SUCCESS; - return n; - } - - /* Now handle raw and cooked modes */ - if (s->sft_flags & SFT_FBINARY) - { - rq.r_length = sizeof(request); - rq.r_command = C_OUTPUT; - rq.r_count = n; - rq.r_trans = (BYTE FAR *) bp; - rq.r_status = 0; - execrh((request FAR *) & rq, s->sft_dev); - if (rq.r_status & S_ERROR) + /* Now handle raw and cooked modes */ + if (s->sft_flags & SFT_FBINARY) { - char_error(&rq, s->sft_dev); - } - else - { - if (s->sft_flags & SFT_FCONOUT) + n = BinaryCharIO(s->sft_dev, n, bp, C_OUTPUT, err); + if (n > 0 && (s->sft_flags & SFT_FCONOUT)) { - WORD cnt = rq.r_count; + UWORD cnt = n; + const char FAR *p = bp; while (cnt--) { - switch (*bp++) + switch (*p++) { - case CR: - scr_pos = 0; - break; - case LF: - case BELL: - break; - case BS: - --scr_pos; - break; - default: - ++scr_pos; + case CR: + scr_pos = 0; + break; + case LF: + case BELL: + break; + case BS: + --scr_pos; + break; + default: + ++scr_pos; } } } - *err = SUCCESS; - return rq.r_count; + return n; } - } - else - { - REG WORD xfer; - - for (xfer = 0; xfer < n && *bp != CTL_Z; bp++, xfer++) + else { - if (s->sft_flags & SFT_FCONOUT) - { - cso(*bp); - } - else - FOREVER + REG UWORD xfer; + const char FAR *p = bp; + + for (xfer = 0; xfer < n && *p != CTL_Z; p++, xfer++) { - rq.r_length = sizeof(request); - rq.r_command = C_OUTPUT; - rq.r_count = 1; - rq.r_trans = (BYTE FAR *)bp; - rq.r_status = 0; - execrh((request FAR *) & rq, s->sft_dev); - if (!(rq.r_status & S_ERROR)) - break; - charloop: - switch (char_error(&rq, s->sft_dev)) + if (s->sft_flags & SFT_FCONOUT) + cso(*p); + else if (BinaryCharIO(s->sft_dev, 1, bp, C_OUTPUT, err) == 0 && + *err != SUCCESS) + return xfer; + if (control_break()) { - case ABORT: - case FAIL: - *err = DE_INVLDACC; - return xfer; - case CONTINUE: - break; - case RETRY: - continue; - default: - goto charloop; + handle_break(); + break; } - break; - } - if (control_break()) - { - handle_break(); - break; } + return xfer; } - *err = SUCCESS; - return xfer; } } - else - /* a block write */ + + /* a block transfer */ + /* /// Added for SHARE - Ron Cemer */ + if (IsShareInstalled() && (s->sft_shroff >= 0)) { - /* /// Added for SHARE - Ron Cemer */ - if (IsShareInstalled()) + *err = share_access_check(cu_psp, s->sft_shroff, s->sft_posit, + (unsigned long)n, 1); + if (*err != SUCCESS) + return 0; + } + /* /// End of additions for SHARE - Ron Cemer */ + { + UCOUNT XferCount; + XferCount = rwblock(s->sft_status, bp, n, mode); + if (mode == XFR_WRITE) + s->sft_size = dos_getfsize(s->sft_status); + return XferCount; + } +} + +UCOUNT BinaryReadSft(sft FAR * s, void *bp, COUNT *err) +{ + if (FP_OFF(s) == (size_t) - 1) + { + *err = DE_INVLDHNDL; + return 0; + } + if (s->sft_mode & SFT_MWRITE) + { + *err = DE_INVLDACC; + return 0; + } + if (s->sft_flags & SFT_FDEVICE) + { + /* First test for eof and exit */ + /* immediately if it is */ + if (!(s->sft_flags & SFT_FEOF) || (s->sft_flags & SFT_FNUL)) { - if (s->sft_shroff >= 0) - { - int share_result = share_access_check(cu_psp, - s->sft_shroff, - s->sft_posit, - (unsigned long)n, - 1); - if (share_result != 0) - { - *err = share_result; - return 0; - } - } + s->sft_flags &= ~SFT_FEOF; + return 0; } - /* /// End of additions for SHARE - Ron Cemer */ - - WriteCount = rwblock(s->sft_status, (BYTE FAR *)bp, n, XFR_WRITE); - s->sft_size = dos_getcufsize(s->sft_status); - *err = SUCCESS; - return WriteCount; + return BinaryCharIO(s->sft_dev, 1, bp, C_INPUT, err); } - *err = SUCCESS; - return 0; + return DosRWSft(s, 1, bp, err, XFR_READ); } COUNT SftSeek(sft FAR * s, LONG new_pos, COUNT mode) @@ -537,27 +403,27 @@ COUNT SftSeek(sft FAR * s, LONG new_pos, COUNT mode) } } -COUNT DosSeek(COUNT hndl, LONG new_pos, COUNT mode, ULONG * set_pos) +ULONG DosSeek(COUNT hndl, LONG new_pos, COUNT mode) { sft FAR *s; COUNT result; /* Get the SFT block that contains the SFT */ if ((s = get_sft(hndl)) == (sft FAR *) - 1) - return DE_INVLDHNDL; + return (ULONG)-1; result = SftSeek(s, new_pos, mode); if (result == SUCCESS) { - *set_pos = s->sft_posit; + return s->sft_posit; } - return result; + return (ULONG)-1; } -STATIC COUNT get_free_hndl(void) +STATIC long get_free_hndl(void) { psp FAR *p = MK_FP(cu_psp, 0); - WORD hndl; + unsigned hndl; for (hndl = 0; hndl < p->ps_maxfiles; hndl++) { @@ -598,18 +464,21 @@ sft FAR *get_free_sft(COUNT * sft_idx) return (sft FAR *) - 1; } -BYTE FAR *get_root(BYTE FAR * fname) +const char FAR *get_root(const char FAR * fname) { - BYTE FAR *froot; - REG WORD length; - /* find the end */ - for (length = 0, froot = fname; *froot != '\0'; ++froot) - ++length; + register unsigned length = fstrlen(fname) - 1; + char c; + /* now back up to first path seperator or start */ - for (--froot; length > 0 && !(*froot == '/' || *froot == '\\'); --froot) + while (length != (unsigned)-1) + { + c = fname[length]; + if (c == '/' || c == '\\' || c == ':') + break; --length; - return ++froot; + } + return fname + length + 1; } /* initialize SFT fields (for open/creat) for character devices */ @@ -633,15 +502,50 @@ STATIC void DeviceOpenSft(struct dhdr FAR *dhp, sft FAR *sftp) sftp->sft_dev = dhp; sftp->sft_date = dos_getdate(); sftp->sft_time = dos_gettime(); + sftp->sft_attrib = D_DEVICE; } -COUNT DosCreatSft(BYTE * fname, COUNT attrib) +/* +extended open codes +0000 0000 always fail +0000 0001 open O_OPEN +0000 0010 replace O_TRUNC + +0001 0000 create new file O_CREAT +0001 0001 create if not exists, open if exists O_CREAT | O_OPEN +0001 0010 create O_CREAT | O_TRUNC + +bits for flags (bits 11-8 are internal FreeDOS bits only) +15 O_FCB called from FCB open +14 O_SYNC commit for each write (not implemented yet) +13 O_NOCRIT do not invoke int23 (not implemented yet) +12 O_LARGEFILE allow files >= 2gb but < 4gb (not implemented yet) +11 O_LEGACY not called from int21/ah=6c: find right fn for redirector +10 O_CREAT if file does not exist, create it +9 O_TRUNC if file exists, truncate and open it \ not both +8 O_OPEN if file exists, open it / +7 O_NOINHERIT do not inherit handle on exec +6 \ +5 - sharing modes +4 / +3 reserved +2 bits 2,1,0 = 100: RDONLY and do not modify file's last access time + (not implemented yet) +1 \ 0=O_RDONLY, 1=O_WRONLY, +0 / 2=O_RDWR, 3=O_EXECCASE (preserve case for redirector EXEC, + (not implemented yet)) +*/ + +long DosOpenSft(char FAR * fname, unsigned flags, unsigned attrib) { COUNT sft_idx; sft FAR *sftp; struct dhdr FAR *dhp; - WORD result; - COUNT drive; + long result; + + result = truename(fname, PriPathName, CDS_MODE_CHECK_DEV_PATH); + if (result < SUCCESS) + return result; /* now get a free system file table entry */ if ((sftp = get_free_sft(&sft_idx)) == (sft FAR *) - 1) @@ -649,56 +553,89 @@ COUNT DosCreatSft(BYTE * fname, COUNT attrib) fmemset(sftp, 0, sizeof(sft)); - sftp->sft_shroff = -1; /* /// Added for SHARE - Ron Cemer */ sftp->sft_psp = cu_psp; - sftp->sft_mode = SFT_MRDWR; - sftp->sft_attrib = attrib; - - /* check for a device */ - dhp = IsDevice(fname); - if (dhp) - { - DeviceOpenSft(dhp, sftp); - return sft_idx; - } + sftp->sft_mode = flags & 0xf0ff; + OpenMode = (BYTE) flags; - if (current_ldt->cdsFlags & CDSNETWDRV) + sftp->sft_shroff = -1; /* /// Added for SHARE - Ron Cemer */ + sftp->sft_attrib = attrib = attrib | D_ARCHIVE; + + if (result & IS_NETWORK) { + int status; + if ((flags & (O_TRUNC | O_CREAT)) == O_CREAT) + attrib |= 0x100; + lpCurSft = sftp; - result = remote_creat(sftp, attrib); - if (result == SUCCESS) + if (!(flags & O_LEGACY)) { - sftp->sft_count += 1; - return sft_idx; + extern UWORD ASM ext_open_mode, ASM ext_open_attrib, ASM ext_open_action; + ext_open_mode = flags & 0x70ff; + ext_open_attrib = attrib & 0xff; + ext_open_action = ((flags & 0x0300) >> 8) | ((flags & O_CREAT) >> 6); + status = remote_extopen(sftp, attrib); } - return result; + else if (flags & O_CREAT) + status = remote_creat(sftp, attrib); + else + status = remote_open(sftp, (BYTE)flags); + if (status >= SUCCESS) + { + if (sftp->sft_count == 0) + sftp->sft_count++; + return sft_idx | ((long)status << 16); + } + return status; } - drive = get_verify_drive(fname); - if (drive < 0) + /* check for a device */ + if ((result & IS_DEVICE) && (dhp = IsDevice(fname)) != NULL) { - return drive; + DeviceOpenSft(dhp, sftp); + return sft_idx; } /* /// Added for SHARE. - Ron Cemer */ if (IsShareInstalled()) { - if ((sftp->sft_shroff = share_open_check((char far *)fname, cu_psp, 0x02, /* read-write */ - 0)) < 0) /* compatibility mode */ + if ((sftp->sft_shroff = + share_open_check(PriPathName, cu_psp, + flags & 0x03, (flags >> 2) & 0x07)) < 0) return sftp->sft_shroff; } + /* /// End of additions for SHARE. - Ron Cemer */ - sftp->sft_status = dos_creat(fname, attrib); - if (sftp->sft_status >= 0) + /* NEVER EVER allow directories to be created */ + /* ... though FCB's are weird :) */ + if (!(flags & O_FCB) && + (attrib & ~(D_RDONLY | D_HIDDEN | D_SYSTEM | D_ARCHIVE | D_VOLID))) + return DE_ACCESS; + + result = dos_open(PriPathName, flags, attrib); + if (result >= 0) { + int status = (int)(result >> 16); + if (status == S_OPENED) + { + sftp->sft_attrib = dos_getfattr_fd((COUNT)result); + /* Check permissions. -- JPP + (do not allow to open volume labels/directories) */ + if (sftp->sft_attrib & (D_DIR | D_VOLID)) + { + dos_close((COUNT)result); + return DE_ACCESS; + } + sftp->sft_size = dos_getfsize((COUNT)result); + } + sftp->sft_status = (COUNT)result; + sftp->sft_flags = PriPathName[0] - 'A'; sftp->sft_count += 1; - sftp->sft_flags = drive; - DosGetFile(fname, sftp->sft_name); + DosGetFile(PriPathName, sftp->sft_name); dos_getftime(sftp->sft_status, (date FAR *) & sftp->sft_date, (time FAR *) & sftp->sft_time); - return sft_idx; + return sft_idx | ((long)status << 16); } else { @@ -709,49 +646,40 @@ COUNT DosCreatSft(BYTE * fname, COUNT attrib) sftp->sft_shroff = -1; } /* /// End of additions for SHARE. - Ron Cemer */ - return sftp->sft_status; - } + return result; + } } -COUNT DosCreat(BYTE FAR * fname, COUNT attrib) +long DosOpen(char FAR * fname, unsigned mode, unsigned attrib) { - psp FAR *p = MK_FP(cu_psp, 0); - COUNT sft_idx, hndl, result; - - /* NEVER EVER allow directories to be created */ - attrib = (BYTE) attrib; - if (attrib & ~(D_RDONLY | D_HIDDEN | D_SYSTEM | D_ARCHIVE)) - { - return DE_ACCESS; - } + long result; + unsigned hndl; + + /* test if mode is in range */ + if ((mode & ~SFT_OMASK) != 0) + return DE_INVLDACC; /* get a free handle */ - if ((hndl = get_free_hndl()) < 0) - return hndl; - - result = truename(fname, PriPathName, FALSE); - if (result != SUCCESS) - { + if ((result = get_free_hndl()) < 0) return result; - } + hndl = (unsigned)result; - sft_idx = DosCreatSft(PriPathName, attrib); - - if (sft_idx < SUCCESS) - return sft_idx; + result = DosOpenSft(fname, mode, attrib); + if (result < SUCCESS) + return result; - p->ps_filetab[hndl] = sft_idx; - return hndl; + ((psp FAR *)MK_FP(cu_psp, 0))->ps_filetab[hndl] = (UBYTE)result; + return hndl | (result & 0xffff0000l); } -COUNT CloneHandle(COUNT hndl) +COUNT CloneHandle(unsigned hndl) { - sft FAR *sftp; - /* now get the system file table entry */ - if ((sftp = get_sft(hndl)) == (sft FAR *) - 1) - return DE_INVLDHNDL; + sft FAR *sftp = get_sft(hndl); + if (sftp == (sft FAR *) -1 || (sftp->sft_mode & O_NOINHERIT)) + return DE_INVLDHNDL; + /* now that we have the system file table entry, get the fnode */ /* index, and increment the count, so that we've effectively */ /* cloned the file. */ @@ -759,37 +687,20 @@ COUNT CloneHandle(COUNT hndl) return SUCCESS; } -COUNT DosDup(COUNT Handle) +long DosDup(unsigned Handle) { - psp FAR *p = MK_FP(cu_psp, 0); - COUNT NewHandle; - sft FAR *Sftp; - - /* Get the SFT block that contains the SFT */ - if ((Sftp = get_sft(Handle)) == (sft FAR *) - 1) - return DE_INVLDHNDL; + long NewHandle; - /* If not open - exit */ - if (Sftp->sft_count <= 0) - return DE_INVLDHNDL; - - /* now get a free handle */ if ((NewHandle = get_free_hndl()) < 0) return NewHandle; - /* If everything looks ok, bump it up. */ - if ((Sftp->sft_flags & (SFT_FDEVICE | SFT_FSHARED)) - || (Sftp->sft_status >= 0)) - { - p->ps_filetab[NewHandle] = p->ps_filetab[Handle]; - Sftp->sft_count += 1; - return NewHandle; - } - else + if (DosForceDup(Handle, (unsigned)NewHandle) < 0) return DE_INVLDHNDL; + else + return NewHandle; } -COUNT DosForceDup(COUNT OldHandle, COUNT NewHandle) +COUNT DosForceDup(unsigned OldHandle, unsigned NewHandle) { psp FAR *p = MK_FP(cu_psp, 0); sft FAR *Sftp; @@ -798,10 +709,6 @@ COUNT DosForceDup(COUNT OldHandle, COUNT NewHandle) if ((Sftp = get_sft(OldHandle)) == (sft FAR *) - 1) return DE_INVLDHNDL; - /* If not open - exit */ - if (Sftp->sft_count <= 0) - return DE_INVLDHNDL; - /* now close the new handle if it's open */ if ((UBYTE) p->ps_filetab[NewHandle] != 0xff) { @@ -816,147 +723,21 @@ COUNT DosForceDup(COUNT OldHandle, COUNT NewHandle) || (Sftp->sft_status >= 0)) { p->ps_filetab[NewHandle] = p->ps_filetab[OldHandle]; - + /* possible hazard: integer overflow ska*/ Sftp->sft_count += 1; - return NewHandle; + return SUCCESS; } else return DE_INVLDHNDL; } -COUNT DosOpenSft(BYTE * fname, COUNT mode) -{ - COUNT sft_idx; - sft FAR *sftp; - struct dhdr FAR *dhp; - COUNT drive, result; - - /* now get a free system file table entry */ - if ((sftp = get_free_sft(&sft_idx)) == (sft FAR *) - 1) - return DE_TOOMANY; - - fmemset(sftp, 0, sizeof(sft)); - sftp->sft_psp = cu_psp; - sftp->sft_mode = mode; - mode = OpenMode = (BYTE) mode; - - /* check for a device */ - dhp = IsDevice(fname); - if (dhp) - { - DeviceOpenSft(dhp, sftp); - return sft_idx; - } - - if (current_ldt->cdsFlags & CDSNETWDRV) - { - lpCurSft = sftp; - result = remote_open(sftp, mode); - /* printf("open SFT %d = %p\n",sft_idx,sftp); */ - if (result == SUCCESS) - { - sftp->sft_count += 1; - return sft_idx; - } - return result; - } - - drive = get_verify_drive(fname); - if (drive < 0) - { - return drive; - } - - sftp->sft_shroff = -1; /* /// Added for SHARE - Ron Cemer */ - - /* /// Added for SHARE. - Ron Cemer */ - if (IsShareInstalled()) - { - if ((sftp->sft_shroff = share_open_check - ((char far *)fname, - (unsigned short)cu_psp, mode & 0x03, (mode >> 2) & 0x07)) < 0) - return sftp->sft_shroff; - } -/* /// End of additions for SHARE. - Ron Cemer */ - - sftp->sft_status = dos_open(fname, mode); - - if (sftp->sft_status >= 0) - { - f_node_ptr fnp = xlt_fd(sftp->sft_status); - - sftp->sft_attrib = fnp->f_dir.dir_attrib; - - /* Check permissions. -- JPP */ - if ((sftp->sft_attrib & (D_DIR | D_VOLID)) || - ((sftp->sft_attrib & D_RDONLY) && (mode != O_RDONLY))) - { - dos_close(sftp->sft_status); - return DE_ACCESS; - } - - sftp->sft_size = dos_getfsize(sftp->sft_status); - dos_getftime(sftp->sft_status, - (date FAR *) & sftp->sft_date, - (time FAR *) & sftp->sft_time); - sftp->sft_count += 1; - sftp->sft_mode = mode; - sftp->sft_flags = drive; - DosGetFile(fname, sftp->sft_name); - return sft_idx; - } - else - { -/* /// Added for SHARE *** CURLY BRACES ADDED ALSO!!! ***. - Ron Cemer */ - if (IsShareInstalled()) - { - share_close_file(sftp->sft_shroff); - sftp->sft_shroff = -1; - } -/* /// End of additions for SHARE. - Ron Cemer */ - return sftp->sft_status; - } -} - -COUNT DosOpen(BYTE FAR * fname, COUNT mode) -{ - psp FAR *p = MK_FP(cu_psp, 0); - COUNT sft_idx, result, hndl; - - /* test if mode is in range */ - if ((mode & ~SFT_OMASK) != 0) - return DE_INVLDACC; - - /* get a free handle */ - if ((hndl = get_free_hndl()) < 0) - return hndl; - - result = truename(fname, PriPathName, FALSE); - if (result != SUCCESS) - { - return result; - } - - sft_idx = DosOpenSft(PriPathName, mode & 3); - - if (sft_idx < SUCCESS) - return sft_idx; - - p->ps_filetab[hndl] = sft_idx; - return hndl; -} - COUNT DosCloseSft(WORD sft_idx, BOOL commitonly) { sft FAR *sftp = idx_to_sft(sft_idx); - if (sftp == (sft FAR *) - 1) + if (FP_OFF(sftp) == (size_t) - 1) return DE_INVLDHNDL; - /* If this is not opened another error */ - if (sftp->sft_count == 0) - return DE_ACCESS; - lpCurSft = sftp; /* remote sub sft_count. @@ -1004,8 +785,8 @@ COUNT DosClose(COUNT hndl) return ret; } -BOOL DosGetFree(UBYTE drive, UCOUNT FAR * spc, UCOUNT FAR * navc, - UCOUNT FAR * bps, UCOUNT FAR * nc) +BOOL DosGetFree(UBYTE drive, UWORD * spc, UWORD * navc, + UWORD * bps, UWORD * nc) { /* *nc==0xffff means: called from FatGetDrvData, fcbfns.c */ struct dpb FAR *dpbp; @@ -1050,12 +831,13 @@ BOOL DosGetFree(UBYTE drive, UCOUNT FAR * spc, UCOUNT FAR * navc, return TRUE; } - dpbp = CDSp[drive].cdsDpb; + dpbp = cdsp->cdsDpb; if (dpbp == NULL) return FALSE; if (*nc == 0xffff) { + /* hazard: no error checking! */ flush_buffers(dpbp->dpb_unit); dpbp->dpb_flags = M_CHANGED; } @@ -1104,8 +886,8 @@ BOOL DosGetFree(UBYTE drive, UCOUNT FAR * spc, UCOUNT FAR * navc, /* fake for 64k clusters do confuse some DOS programs, but let others work without overflowing */ *spc >>= 1; - *navc = (*navc < FAT_MAGIC16 / 2) ? (*navc << 1) : FAT_MAGIC16; - *nc = (*nc < FAT_MAGIC16 / 2) ? (*nc << 1) : FAT_MAGIC16; + *navc = ((unsigned)*navc < FAT_MAGIC16 / 2) ? ((unsigned)*navc << 1) : FAT_MAGIC16; + *nc = ((unsigned)*nc < FAT_MAGIC16 / 2) ? ((unsigned)*nc << 1) : FAT_MAGIC16; } return TRUE; } @@ -1166,31 +948,38 @@ COUNT DosGetExtFree(BYTE FAR * DriveString, struct xfreespace FAR * xfsp) COUNT DosGetCuDir(UBYTE drive, BYTE FAR * s) { - BYTE FAR *cp; + BYTE *cp; + struct cds FAR *cdsp; /* next - "log" in the drive */ drive = (drive == 0 ? default_drive : drive - 1); /* first check for valid drive */ - if (drive >= lastdrive || !(CDSp[drive].cdsFlags & CDSVALID)) - { + if (drive >= lastdrive) + return DE_INVLDDRV; + + cdsp = &CDSp[drive]; + fmemcpy(&TempCDS, cdsp, sizeof(TempCDS)); + if (!(TempCDS.cdsFlags & CDSVALID)) return DE_INVLDDRV; - } - current_ldt = &CDSp[drive]; + cp = TempCDS.cdsCurrentPath; /* ensure termination of fstrcpy */ cp[MAX_CDSPATH - 1] = '\0'; - if ((current_ldt->cdsFlags & CDSNETWDRV) == 0) + if ((TempCDS.cdsFlags & CDSNETWDRV) == 0) { - if (current_ldt->cdsDpb == 0) - return DE_INVLDDRV; - - if ((media_check(current_ldt->cdsDpb) < 0)) - return DE_INVLDDRV; + /* dos_cd ensures that the path exists; if not, we + need to change to the root directory */ + int result = dos_cd(cdsp, cp); + if (result == DE_PATHNOTFND) + cp[TempCDS.cdsBackslashOffset + 1] = + cdsp->cdsCurrentPath[TempCDS.cdsBackslashOffset + 1] = '\0'; + else if (result < SUCCESS) + return result; } - cp = ¤t_ldt->cdsCurrentPath[current_ldt->cdsJoinOffset]; + cp += TempCDS.cdsBackslashOffset; if (*cp == '\0') s[0] = '\0'; else @@ -1202,7 +991,6 @@ COUNT DosGetCuDir(UBYTE drive, BYTE FAR * s) #undef CHDIR_DEBUG COUNT DosChangeDir(BYTE FAR * s) { - REG COUNT drive; COUNT result; BYTE FAR *p; @@ -1211,20 +999,12 @@ COUNT DosChangeDir(BYTE FAR * s) if (*p == '*' || *p == '?') return DE_PATHNOTFND; - drive = get_verify_drive(s); - if (drive < 0) - { - return drive; - } - - result = truename(s, PriPathName, FALSE); - if (result != SUCCESS) + result = truename(s, PriPathName, CDS_MODE_CHECK_DEV_PATH); + if (result < SUCCESS) { return result; } - current_ldt = &CDSp[drive]; - if (strlen(PriPathName) > sizeof(current_ldt->cdsCurrentPath) - 1) return DE_PATHNOTFND; @@ -1233,8 +1013,8 @@ COUNT DosChangeDir(BYTE FAR * s) #endif /* now get fs to change to new */ /* directory */ - result = (current_ldt->cdsFlags & CDSNETWDRV) ? remote_chdir() : - dos_cd(current_ldt, PriPathName); + result = (result & IS_NETWORK ? remote_chdir() : + dos_cd(current_ldt, PriPathName)); #if defined(CHDIR_DEBUG) printf("status = %04x, new_path='%Fs'\n", result, cdsd->cdsCurrentPath); #endif @@ -1266,7 +1046,10 @@ COUNT DosFindFirst(UCOUNT attr, BYTE FAR * name) { COUNT rc; REG dmatch FAR *dmp = (dmatch FAR *) dta; - BYTE FAR *p; + + rc = truename(name, PriPathName, CDS_MODE_CHECK_DEV_PATH); + if (rc < SUCCESS) + return rc; /* /// Added code here to do matching against device names. DOS findfirst will match exact device names if the @@ -1276,58 +1059,52 @@ COUNT DosFindFirst(UCOUNT attr, BYTE FAR * name) in newstuff.c. - Ron Cemer */ - fmemset(dta, 0, sizeof(dmatch)); + fmemset(dmp, 0, sizeof(dmatch)); /* initially mark the dta as invalid for further findnexts */ - ((dmatch FAR *) dta)->dm_attr_fnd = D_DEVICE; + dmp->dm_attr_fnd = D_DEVICE; memset(&SearchDir, 0, sizeof(struct dirent)); - rc = truename(name, PriPathName, FALSE); - if (rc != SUCCESS) - return rc; + SAttr = (BYTE) attr; - if (IsDevice(PriPathName)) +#if defined(FIND_DEBUG) + printf("Remote Find: n='%Fs\n", PriPathName); +#endif + + fmemcpy(TempBuffer, dta, 21); + dta = TempBuffer; + + if (rc & IS_NETWORK) + rc = remote_findfirst(current_ldt); + else if (rc & IS_DEVICE) { + const char *p; COUNT i; /* Found a matching device. Hence there cannot be wildcards. */ SearchDir.dir_attrib = D_DEVICE; SearchDir.dir_time = dos_gettime(); SearchDir.dir_date = dos_getdate(); - p = get_root(PriPathName); + p = (char *)FP_OFF(get_root(PriPathName)); memset(SearchDir.dir_name, ' ', FNAME_SIZE + FEXT_SIZE); for (i = 0; i < FNAME_SIZE && *p && *p != '.'; i++) SearchDir.dir_name[i] = *p++; if (*p == '.') p++; - for (i = 0; i < FEXT_SIZE && *p && *p != '.'; i++) - SearchDir.dir_ext[i] = *p++; - pop_dmp(dmp); - return SUCCESS; + for (i = FNAME_SIZE; i < FNAME_SIZE + FEXT_SIZE && *p && *p != '.'; i++) + SearchDir.dir_name[i] = *p++; + rc = SUCCESS; + /* /// End of additions. - Ron Cemer ; heavily edited - Bart Oldeman */ } - /* /// End of additions. - Ron Cemer ; heavily edited - Bart Oldeman */ - - SAttr = (BYTE) attr; - -#if defined(FIND_DEBUG) - printf("Remote Find: n='%Fs\n", PriPathName); -#endif - - fmemcpy(TempBuffer, dta, 21); - p = dta; - dta = (BYTE FAR *) TempBuffer; - - rc = current_ldt->cdsFlags & CDSNETWDRV ? - remote_findfirst((VOID FAR *) current_ldt) : - dos_findfirst(attr, PriPathName); - - dta = p; + else + rc = dos_findfirst(attr, PriPathName); + dta = (char FAR *) dmp; fmemcpy(dta, TempBuffer, 21); - pop_dmp((dmatch FAR *) dta); + pop_dmp(dmp); if (rc != SUCCESS) - ((dmatch FAR *) dta)->dm_attr_fnd = D_DEVICE; /* mark invalid */ + dmp->dm_attr_fnd = D_DEVICE; /* mark invalid */ return rc; } @@ -1374,19 +1151,15 @@ COUNT DosFindNext(void) return rc; } -COUNT DosGetFtime(COUNT hndl, date FAR * dp, time FAR * tp) +COUNT DosGetFtime(COUNT hndl, date * dp, time * tp) { sft FAR *s; /*sfttbl FAR *sp;*/ /* Get the SFT block that contains the SFT */ - if ((s = get_sft(hndl)) == (sft FAR *) - 1) + if (FP_OFF(s = get_sft(hndl)) == (size_t) - 1) return DE_INVLDHNDL; - /* If this is not opened another error */ - if (s->sft_count == 0) - return DE_ACCESS; - /* If SFT entry refers to a device, return the date and time of opening */ if (s->sft_flags & (SFT_FDEVICE | SFT_FSHARED)) { @@ -1404,13 +1177,9 @@ COUNT DosSetFtimeSft(WORD sft_idx, date dp, time tp) /* Get the SFT block that contains the SFT */ sft FAR *s = idx_to_sft(sft_idx); - if (s == (sft FAR *) - 1) + if (FP_OFF(s) == (size_t) - 1) return DE_INVLDHNDL; - /* If this is not opened another error */ - if (s->sft_count == 0) - return DE_ACCESS; - /* If SFT entry refers to a device, do nothing */ if (s->sft_flags & SFT_FDEVICE) return SUCCESS; @@ -1428,42 +1197,30 @@ COUNT DosSetFtimeSft(WORD sft_idx, date dp, time tp) COUNT DosGetFattr(BYTE FAR * name) { - COUNT result, drive; - - if (IsDevice(name)) - { - return DE_FILENOTFND; - } - - drive = get_verify_drive(name); - if (drive < 0) - { - return drive; - } + COUNT result; - result = truename(name, PriPathName, FALSE); - if (result != SUCCESS) - { + result = truename(name, PriPathName, CDS_MODE_CHECK_DEV_PATH); + if (result < SUCCESS) return result; - } - + /* /// Added check for "d:\", which returns 0x10 (subdirectory) under DOS. - Ron Cemer */ - if ((PriPathName[0] != '\0') - && (PriPathName[1] == ':') - && ((PriPathName[2] == '/') || (PriPathName[2] == '\\')) - && (PriPathName[3] == '\0')) - { + /* Theoretically: If the redirectory's qualify function + doesn't return nonsense this check can be reduced to + PriPathname[3] == 0, because local path names always + have the three-byte string ?:\ and UNC path shouldn't + validy consist of just two slashes. + -- 2001/09/03 ska*/ + + if (PriPathName[3] == '\0') return 0x10; - } - current_ldt = &CDSp[drive]; - if (current_ldt->cdsFlags & CDSNETWDRV) - { + if (result & IS_NETWORK) return remote_getfattr(); - } - else - { + + if (result & IS_DEVICE) + return DE_FILENOTFND; + /* /// Use truename()'s result, which we already have in PriPathName. I copy it to tmp_name because PriPathName is global and seems to get trashed somewhere in transit. @@ -1492,39 +1249,26 @@ COUNT DosGetFattr(BYTE FAR * name) shit. tom */ - return dos_getfattr(PriPathName); - - } + return dos_getfattr(PriPathName); } +/* This function is almost identical to DosGetFattr(). + Maybe it is nice to join both functions. + -- 2001/09/03 ska*/ COUNT DosSetFattr(BYTE FAR * name, UWORD attrp) { - COUNT result, drive; - - if (IsDevice(name)) - { - return DE_FILENOTFND; - } - - drive = get_verify_drive(name); - if (drive < 0) - { - return drive; - } + COUNT result; - result = truename(name, PriPathName, FALSE); - if (result != SUCCESS) - { + result = truename(name, PriPathName, CDS_MODE_CHECK_DEV_PATH); + if (result < SUCCESS) return result; - } - current_ldt = &CDSp[drive]; - if (current_ldt->cdsFlags & CDSNETWDRV) - { + if (result & IS_NETWORK) return remote_setfattr(attrp); - } - else - { + + if (result & IS_DEVICE) + return DE_FILENOTFND; + /* /// Use truename()'s result, which we already have in PriPathName. I copy it to tmp_name because PriPathName is global and seems to get trashed somewhere in transit. @@ -1536,9 +1280,7 @@ COUNT DosSetFattr(BYTE FAR * name, UWORD attrp) see DosGetAttr() */ - return dos_setfattr(PriPathName, attrp); - - } + return dos_setfattr(PriPathName, attrp); } UBYTE DosSelectDrv(UBYTE drv) @@ -1558,137 +1300,90 @@ UBYTE DosSelectDrv(UBYTE drv) COUNT DosDelete(BYTE FAR * path, int attrib) { - COUNT result, drive; - - if (IsDevice(path)) - { - return DE_FILENOTFND; - } + COUNT result; - drive = get_verify_drive(path); - if (drive < 0) - { - return drive; - } - result = truename(path, PriPathName, FALSE); - if (result != SUCCESS) - { + result = truename(path, PriPathName, CDS_MODE_CHECK_DEV_PATH); + if (result < SUCCESS) return result; - } - current_ldt = &CDSp[drive]; - if (current_ldt->cdsFlags & CDSNETWDRV) - { + + if (result & IS_NETWORK) return remote_delete(); - } - else - { - return dos_delete(PriPathName, attrib); - } + + if (result & IS_DEVICE) + return DE_FILENOTFND; + + return dos_delete(PriPathName, attrib); } COUNT DosRenameTrue(BYTE * path1, BYTE * path2, int attrib) { - COUNT drive1, drive2; - - if (IsDevice(path1) || IsDevice(path2)) - { - return DE_FILENOTFND; - } - - drive1 = get_verify_drive(path1); - drive2 = get_verify_drive(path2); - if ((drive1 != drive2) || (drive1 < 0)) + if (path1[0] != path2[0]) { return DE_INVLDDRV; } - current_ldt = &CDSp[drive1]; if (current_ldt->cdsFlags & CDSNETWDRV) - { return remote_rename(); - } - else - { - return dos_rename(PriPathName, SecPathName, attrib); - } + + return dos_rename(path1, path2, attrib); } COUNT DosRename(BYTE FAR * path1, BYTE FAR * path2) { COUNT result; - result = truename(path1, PriPathName, FALSE); - if (result != SUCCESS) - { + result = truename(path2, SecPathName, CDS_MODE_CHECK_DEV_PATH); + if (result < SUCCESS) return result; - } - result = truename(path2, SecPathName, FALSE); - if (result != SUCCESS) - { + if (!(result & IS_NETWORK) && (result & IS_DEVICE)) + return DE_FILENOTFND; + + result = truename(path1, PriPathName, CDS_MODE_CHECK_DEV_PATH); + if (result < SUCCESS) return result; - } + + if (!(result & IS_NETWORK) && (result & IS_DEVICE)) + return DE_FILENOTFND; return DosRenameTrue(PriPathName, SecPathName, D_ALL); } -COUNT DosMkdir(BYTE FAR * dir) +COUNT DosMkdir(const char FAR * dir) { - COUNT result, drive; - - if (IsDevice(dir)) - { - return DE_PATHNOTFND; - } + COUNT result; - drive = get_verify_drive(dir); - if (drive < 0) - { - return drive; - } - result = truename(dir, PriPathName, FALSE); - if (result != SUCCESS) - { + result = truename(dir, PriPathName, CDS_MODE_CHECK_DEV_PATH); + if (result < SUCCESS) return result; - } - current_ldt = &CDSp[drive]; - if (current_ldt->cdsFlags & CDSNETWDRV) - { + + if (result & IS_NETWORK) return remote_mkdir(); - } - else - { - return dos_mkdir(PriPathName); - } + + if (result & IS_DEVICE) + return DE_ACCESS; + + return dos_mkdir(PriPathName); } -COUNT DosRmdir(BYTE FAR * dir) +/* This function is almost identical to DosMkdir(). + Maybe it would be nice to merge both functions. + -- 2001/09/03 ska*/ +COUNT DosRmdir(const char FAR * dir) { - COUNT result, drive; + COUNT result; - if (IsDevice(dir)) - { - return DE_PATHNOTFND; - } + result = truename(dir, PriPathName, CDS_MODE_CHECK_DEV_PATH); - drive = get_verify_drive(dir); - if (drive < 0) - { - return drive; - } - result = truename(dir, PriPathName, FALSE); - if (result != SUCCESS) - { + if (result < SUCCESS) return result; - } - current_ldt = &CDSp[drive]; - if (CDSp[drive].cdsFlags & CDSNETWDRV) - { + + if (result & IS_NETWORK) return remote_rmdir(); - } - else - { - return dos_rmdir(PriPathName); - } + + if (result & IS_DEVICE) + return DE_ACCESS; + + return dos_rmdir(PriPathName); } /* /// Added for SHARE. - Ron Cemer */ @@ -1698,7 +1393,7 @@ COUNT DosLockUnlock(COUNT hndl, LONG pos, LONG len, COUNT unlock) sft FAR *s; /* Get the SFT block that contains the SFT */ - if ((s = get_sft(hndl)) == (sft FAR *) - 1) + if (FP_OFF(s = get_sft(hndl)) == (size_t) - 1) return DE_INVLDHNDL; if (s->sft_flags & SFT_FSHARED) @@ -1723,10 +1418,10 @@ COUNT DosLockUnlock(COUNT hndl, LONG pos, LONG len, COUNT unlock) */ /* check for a device */ -struct dhdr FAR *IsDevice(BYTE FAR * fname) +struct dhdr FAR *IsDevice(const char FAR * fname) { struct dhdr FAR *dhp; - char FAR *froot = get_root(fname); + const char FAR *froot = get_root(fname); int i; /* /// BUG!!! This is absolutely wrong. A filename of "NUL.LST" must be @@ -1790,7 +1485,7 @@ BOOL IsShareInstalled(void) error. If < 0 is returned, it is the negated error return code, so DOS simply negates this value and returns it in AX. */ -STATIC int share_open_check(char far * filename, /* far pointer to fully qualified filename */ +STATIC int share_open_check(char * filename, /* pointer to fully qualified filename */ unsigned short pspseg, /* psp segment address of owner process */ int openmode, /* 0=read-only, 1=write-only, 2=read-write */ int sharemode) @@ -1894,6 +1589,18 @@ STATIC int remote_lock_unlock(sft FAR *sftp, /* SFT for file */ return ((regs.flags & 1) ? -(int)regs.a.b.l : 0); } +COUNT DosTruename(const char FAR *src, char FAR *dest) +{ + /* RBIL: The buffer has be unchanged, if the call fails. + Therefore, the name is created in an internal buffer + and copied into the user buffer only on success. + */ + COUNT rc = truename(src, PriPathName, 0); + if (rc >= SUCCESS) + fstrcpy(dest, PriPathName); + return rc; +} + /* * diff --git a/kernel/dosnames.c b/kernel/dosnames.c index 3a67d998..099d82dd 100644 --- a/kernel/dosnames.c +++ b/kernel/dosnames.c @@ -41,9 +41,12 @@ const char _DirWildNameChars[] = "*?./\\\"[]:|<>+=;,"; #define PathSep(c) ((c)=='/'||(c)=='\\') #define DriveChar(c) (((c)>='A'&&(c)<='Z')||((c)>='a'&&(c)<='z')) -#define DirChar(c) (!strchr(_DirWildNameChars+5, (c))) -#define WildChar(c) (!strchr(_DirWildNameChars+2, (c))) -#define NameChar(c) (!strchr(_DirWildNameChars, (c))) +#define DirChar(c) (((unsigned char)(c)) >= ' ' && \ + !strchr(_DirWildNameChars+5, (c))) +#define WildChar(c) (((unsigned char)(c)) >= ' ' && \ + !strchr(_DirWildNameChars+2, (c))) +#define NameChar(c) (((unsigned char)(c)) >= ' ' && \ + !strchr(_DirWildNameChars, (c))) VOID XlateLcase(BYTE * szFname, COUNT nChars); VOID DosTrimPath(BYTE * lpszPathNamep); @@ -61,14 +64,6 @@ VOID XlateLcase(BYTE * szFname, COUNT nChars) } #endif -VOID SpacePad(BYTE * szString, COUNT nChars) -{ - REG COUNT i; - - for (i = strlen(szString); i < nChars; i++) - szString[i] = ' '; -} - /* MSD durring an FindFirst search string looks like this; (*), & (.) == Current directory *.* @@ -76,90 +71,73 @@ VOID SpacePad(BYTE * szString, COUNT nChars) (..) == Back one directory *.* This always has a "truename" as input, so we may do some shortcuts + + returns number of characters in the directory component (up to the + last backslash, including d:) or negative if error */ -COUNT ParseDosName(BYTE * lpszFileName, - COUNT * pnDrive, - BYTE * pszDir, - BYTE * pszFile, BYTE * pszExt, BOOL bAllowWildcards) +int ParseDosName(const char *filename, char *fcbname, BOOL bAllowWildcards) { - COUNT nDirCnt, nFileCnt, nExtCnt; - BYTE *lpszLclDir, *lpszLclFile, *lpszLclExt; + int nDirCnt, nFileCnt, nExtCnt; + const char *lpszLclDir, *lpszLclFile, *lpszLclExt; /* Initialize the users data fields */ - if (pszDir) - *pszDir = '\0'; - if (pszFile) - *pszFile = '\0'; - if (pszExt) - *pszExt = '\0'; - lpszLclFile = lpszLclExt = lpszLclDir = 0; nDirCnt = nFileCnt = nExtCnt = 0; - /* found a drive, fetch it and bump pointer past drive */ /* NB: this code assumes ASCII */ - if (pnDrive) - *pnDrive = *lpszFileName - 'A'; - lpszFileName += 2; - if (!pszDir && !pszFile && !pszExt) - return SUCCESS; /* Now see how long a directory component we have. */ - lpszLclDir = lpszLclFile = lpszFileName; - while (DirChar(*lpszFileName)) + lpszLclDir = lpszLclFile = filename; + filename += 2; + + while (DirChar(*filename)) { - if (*lpszFileName == '\\') - lpszLclFile = lpszFileName + 1; - ++lpszFileName; + if (*filename == '\\') + lpszLclFile = filename + 1; + ++filename; } - nDirCnt = FP_OFF(lpszLclFile) - FP_OFF(lpszLclDir); + nDirCnt = lpszLclFile - lpszLclDir; /* Fix lengths to maximums allowed by MS-DOS. */ if (nDirCnt > PARSE_MAX - 1) nDirCnt = PARSE_MAX - 1; /* Parse out the file name portion. */ - lpszFileName = lpszLclFile; - while (bAllowWildcards ? WildChar(*lpszFileName) : - NameChar(*lpszFileName)) + filename = lpszLclFile; + while (bAllowWildcards ? WildChar(*filename) : + NameChar(*filename)) { ++nFileCnt; - ++lpszFileName; + ++filename; } if (nFileCnt == 0) + { /* Lixing Yuan Patch */ if (bAllowWildcards) /* for find first */ { - if (*lpszFileName != '\0') + if (*filename != '\0') return DE_FILENOTFND; if (nDirCnt == 1) /* for d:\ */ return DE_NFILES; - if (pszDir) - { - memcpy(pszDir, lpszLclDir, nDirCnt); - pszDir[nDirCnt] = '\0'; - } - if (pszFile) - memcpy(pszFile, "????????", FNAME_SIZE + 1); - if (pszExt) - memcpy(pszExt, "???", FEXT_SIZE + 1); - return SUCCESS; + memset(fcbname, '?', FNAME_SIZE + FEXT_SIZE); + return nDirCnt; } else return DE_FILENOTFND; - + } + /* Now we have pointers set to the directory portion and the */ /* file portion. Now determine the existance of an extension. */ - lpszLclExt = lpszFileName; - if ('.' == *lpszFileName) + lpszLclExt = filename; + if ('.' == *filename) { - lpszLclExt = ++lpszFileName; - while (*lpszFileName) + lpszLclExt = ++filename; + while (*filename) { - if (bAllowWildcards ? WildChar(*lpszFileName) : - NameChar(*lpszFileName)) + if (bAllowWildcards ? WildChar(*filename) : + NameChar(*filename)) { ++nExtCnt; - ++lpszFileName; + ++filename; } else { @@ -167,225 +145,20 @@ COUNT ParseDosName(BYTE * lpszFileName, } } } - else if (*lpszFileName) + else if (*filename) return DE_FILENOTFND; /* Finally copy whatever the user wants extracted to the user's */ /* buffers. */ - if (pszDir) - { - memcpy(pszDir, lpszLclDir, nDirCnt); - pszDir[nDirCnt] = '\0'; - } - if (pszFile) - { - memcpy(pszFile, lpszLclFile, nFileCnt); - pszFile[nFileCnt] = '\0'; - } - if (pszExt) - { - memcpy(pszExt, lpszLclExt, nExtCnt); - pszExt[nExtCnt] = '\0'; - } + memset(fcbname, ' ', FNAME_SIZE + FEXT_SIZE); + memcpy(fcbname, lpszLclFile, nFileCnt); + memcpy(&fcbname[FNAME_SIZE], lpszLclExt, nExtCnt); /* Clean up before leaving */ - return SUCCESS; + return nDirCnt; } -#if 0 -/* not necessary anymore because of truename */ -COUNT ParseDosPath(BYTE * lpszFileName, - COUNT * pnDrive, BYTE * pszDir, BYTE * pszCurPath) -{ - COUNT nDirCnt, nPathCnt; - BYTE *lpszLclDir, *pszBase = pszDir; - - /* Initialize the users data fields */ - *pszDir = '\0'; - lpszLclDir = 0; - nDirCnt = nPathCnt = 0; - - /* Start by cheking for a drive specifier ... */ - if (DriveChar(*lpszFileName) && ':' == lpszFileName[1]) - { - /* found a drive, fetch it and bump pointer past drive */ - /* NB: this code assumes ASCII */ - if (pnDrive) - { - *pnDrive = *lpszFileName - 'A'; - if (*pnDrive > 26) - *pnDrive -= ('a' - 'A'); - } - lpszFileName += 2; - } - else - { - if (pnDrive) - { - *pnDrive = -1; - } - } - - lpszLclDir = lpszFileName; - if (!PathSep(*lpszLclDir)) - { - fstrncpy(pszDir, pszCurPath, PARSE_MAX - 1); - /*TE*/ nPathCnt = fstrlen(pszCurPath); - if (!PathSep(pszDir[nPathCnt - 1]) && nPathCnt < PARSE_MAX - 1) - /*TE*/ pszDir[nPathCnt++] = '\\'; - if (nPathCnt > PARSE_MAX) - nPathCnt = PARSE_MAX; - pszDir += nPathCnt; - } - - /* Now see how long a directory component we have. */ - while (NameChar(*lpszFileName) - || PathSep(*lpszFileName) || '.' == *lpszFileName) - { - ++nDirCnt; - ++lpszFileName; - } - - /* Fix lengths to maximums allowed by MS-DOS. */ - if ((nDirCnt + nPathCnt) > PARSE_MAX - 1) - /*TE*/ nDirCnt = PARSE_MAX - 1 - nPathCnt; - - /* Finally copy whatever the user wants extracted to the user's */ - /* buffers. */ - if (pszDir) - { - memcpy(pszDir, lpszLclDir, nDirCnt); - pszDir[nDirCnt] = '\0'; - } - - /* Clean up before leaving */ - DosTrimPath(pszBase); - - /* Before returning to the user, eliminate any useless */ - /* trailing "\\." since the path prior to this is sufficient. */ - nPathCnt = strlen(pszBase); - if (2 == nPathCnt) /* Special case, root */ - { - if (!strcmp(pszBase, "\\.")) - pszBase[1] = '\0'; - } - else if (2 < nPathCnt) - { - if (!strcmp(&pszBase[nPathCnt - 2], "\\.")) - pszBase[nPathCnt - 2] = '\0'; - } - - return SUCCESS; -} - -VOID DosTrimPath(BYTE * lpszPathNamep) -{ - BYTE *lpszLast, *lpszNext, *lpszRoot = NULL; - COUNT nChars, flDotDot; - - /* First, convert all '/' to '\'. Look for root as we scan */ - if (*lpszPathNamep == '\\') - lpszRoot = lpszPathNamep; - for (lpszNext = lpszPathNamep; *lpszNext; ++lpszNext) - { - if (*lpszNext == '/') - *lpszNext = '\\'; - if (!lpszRoot && *lpszNext == ':' && *(lpszNext + 1) == '\\') - lpszRoot = lpszNext + 1; - } - - /* NAMEMAX + 2, must include C: TE */ - for (lpszLast = lpszNext = lpszPathNamep, nChars = 0; - *lpszNext != '\0' && nChars < NAMEMAX + 2;) - { - /* Initialize flag for loop. */ - flDotDot = FALSE; - - /* If we are at a path seperator, check for extra path */ - /* seperator, '.' and '..' to reduce. */ - if (*lpszNext == '\\') - { - /* If it's '\', just move everything down one. */ - if (*(lpszNext + 1) == '\\') - fstrncpy(lpszNext, lpszNext + 1, NAMEMAX); - /* also check for '.' and '..' and move down */ - /* as appropriate. */ - else if (*(lpszNext + 1) == '.') - { - if (*(lpszNext + 2) == '.' && !(*(lpszNext + 3))) - { - /* At the end, just truncate */ - /* and exit. */ - if (lpszLast == lpszRoot) - *(lpszLast + 1) = '\0'; - else - *lpszLast = '\0'; - return; - } - - if (*(lpszNext + 2) == '.' && *(lpszNext + 3) == '\\') - { - fstrncpy(lpszLast, lpszNext + 3, NAMEMAX); - /* bump back to the last */ - /* seperator. */ - lpszNext = lpszLast; - /* set lpszLast to the last one */ - if (lpszLast <= lpszPathNamep) - continue; - do - { - --lpszLast; - } - while (lpszLast != lpszPathNamep && *lpszLast != '\\'); - flDotDot = TRUE; - } - /* Note: we skip strange stuff that */ - /* starts with '.' */ - else if (*(lpszNext + 2) == '\\') - { - fstrncpy(lpszNext, lpszNext + 2, NAMEMAX); - flDotDot = TRUE; - } - /* If we're at the end of a string, */ - /* just exit. */ - else if (*(lpszNext + 2) == NULL) - { - return; - } - /* - Added this "else" because otherwise we might not pass - any of the foregoing tests, as in the case where the - incoming string refers to a suffix only, like ".bat" - - -SRM - */ - else - { - lpszLast = lpszNext++; - } - } - else - { - /* No '.' or '\' so mark it and bump */ - /* past */ - lpszLast = lpszNext++; - continue; - } - - /* Done. Now set last to next to mark this */ - /* instance of path seperator. */ - if (!flDotDot) - lpszLast = lpszNext; - } - else - /* For all other cases, bump lpszNext for the */ - /* next check */ - ++lpszNext; - } -} -#endif - /* * Log: dosnames.c,v - for newer log entries do "cvs log dosnames.c" * diff --git a/kernel/entry.asm b/kernel/entry.asm index 059637e6..24243686 100644 --- a/kernel/entry.asm +++ b/kernel/entry.asm @@ -376,7 +376,11 @@ int21_exit_nodec: pop si %IFDEF I386 - sub bp,8 +%ifdef WATCOM + sub bp, 4 ; for fs and gs only +%else + sub bp, 8 ; high parts of eax, ebx, ecx, edx +%endif %endif cli diff --git a/kernel/fatdir.c b/kernel/fatdir.c index a95897b8..25ca4ef0 100644 --- a/kernel/fatdir.c +++ b/kernel/fatdir.c @@ -68,14 +68,10 @@ VOID dir_init_fnode(f_node_ptr fnp, CLUSTER dirstart) fnp->f_cluster = fnp->f_dirstart = dirstart; } -f_node_ptr dir_open(BYTE * dirname) +f_node_ptr dir_open(register const char *dirname) { f_node_ptr fnp; - COUNT drive; - BYTE *p; - WORD i; - struct cds FAR *cdsp; - BYTE *pszPath = dirname + 2; + int i; /* Allocate an fnode if possible - error return (0) if not. */ if ((fnp = get_f_node()) == (f_node_ptr) 0) @@ -86,57 +82,23 @@ f_node_ptr dir_open(BYTE * dirname) /* Force the fnode into read-write mode */ fnp->f_mode = RDWR; - /* determine what drive we are using... */ - if (ParseDosName - (dirname, &drive, (BYTE *) 0, (BYTE *) 0, (BYTE *) 0, - FALSE) != SUCCESS) + /* determine what drive and dpb we are using... */ + fnp->f_dpb = CDSp[dirname[0]-'A'].cdsDpb; + if (fnp->f_dpb == 0) { release_f_node(fnp); return NULL; } - /* If the drive was specified, drive is non-negative and */ - /* corresponds to the one passed in, i.e., 0 = A, 1 = B, etc. */ - /* We use that and skip the "D:" part of the string. */ - /* Otherwise, just use the default drive */ - if (drive >= 0) - { - dirname += 2; /* Assume FAT style drive */ - } - else - { - drive = default_drive; - } - if (drive >= lastdrive) - { - release_f_node(fnp); - return NULL; - } - - cdsp = &CDSp[drive]; - - /* Generate full path name */ - /* not necessary anymore, since truename did that already - i = cdsp->cdsJoinOffset; - ParseDosPath(dirname, (COUNT *) 0, pszPath, (BYTE FAR *) & cdsp->cdsCurrentPath[i]); */ - /* for testing only for now */ #if 0 - if ((cdsp->cdsFlags & CDSNETWDRV)) + if ((CDSp[dirname[0]-'A'].cdsFlags & CDSNETWDRV)) { printf("FailSafe %x \n", Int21AX); return fnp; } #endif - if (cdsp->cdsDpb == 0) - { - release_f_node(fnp); - return NULL; - } - - fnp->f_dpb = cdsp->cdsDpb; - /* Perform all directory common handling after all special */ /* handling has been performed. */ @@ -150,15 +112,21 @@ f_node_ptr dir_open(BYTE * dirname) /* */ /* Start from the root directory (dirstart = 0) */ + /* The CDS's cdsStartCls may be used to shorten the search + beginning at the CWD, see mapPath() and CDS.H in order + to enable this behaviour there. + -- 2001/09/04 ska*/ + dir_init_fnode(fnp, 0); - for (p = pszPath; *p != '\0';) + dirname += 2; /* Assume FAT style drive */ + while(*dirname != '\0') { /* skip all path seperators */ - while (*p == '\\') - ++p; + while (*dirname == '\\') + ++dirname; /* don't continue if we're at the end */ - if (*p == '\0') + if (*dirname == '\0') break; /* Convert the name into an absolute name for */ @@ -169,20 +137,22 @@ f_node_ptr dir_open(BYTE * dirname) for (i = 0; i < FNAME_SIZE; i++) { - if (*p != '\0' && *p != '.' && *p != '/' && *p != '\\') - TempBuffer[i] = *p++; + if (*dirname != '\0' && *dirname != '.' && *dirname != '/' && + *dirname != '\\') + TempBuffer[i] = *dirname++; else break; } /* and the extension (don't forget to */ /* add trailing spaces)... */ - if (*p == '.') - ++p; + if (*dirname == '.') + ++dirname; for (i = 0; i < FEXT_SIZE; i++) { - if (*p != '\0' && *p != '.' && *p != '/' && *p != '\\') - TempBuffer[i + FNAME_SIZE] = *p++; + if (*dirname != '\0' && *dirname != '.' && *dirname != '/' && + *dirname != '\\') + TempBuffer[i + FNAME_SIZE] = *dirname++; else break; } @@ -191,27 +161,18 @@ f_node_ptr dir_open(BYTE * dirname) /* find the entry... */ i = FALSE; - DosUpFMem((BYTE FAR *) TempBuffer, FNAME_SIZE + FEXT_SIZE); - while (dir_read(fnp) == 1) { - if (fnp->f_dir.dir_name[0] != '\0' - && fnp->f_dir.dir_name[0] != DELETED - && !(fnp->f_dir.dir_attrib & D_VOLID)) + if (!(fnp->f_dir.dir_attrib & D_VOLID) && + fcbmatch(TempBuffer, fnp->f_dir.dir_name)) { - if (fcmp - (TempBuffer, (BYTE *) fnp->f_dir.dir_name, - FNAME_SIZE + FEXT_SIZE)) - { - i = TRUE; - break; - } + i = TRUE; + break; } } if (!i || !(fnp->f_dir.dir_attrib & D_DIR)) { - release_f_node(fnp); return (f_node_ptr) 0; } @@ -225,6 +186,15 @@ f_node_ptr dir_open(BYTE * dirname) return fnp; } +/* swap internal and external delete flags */ +STATIC void swap_deleted(char *name) +{ + if (name[0] == DELETED) + name[0] = EXT_DELETED; + else if (name[0] == EXT_DELETED) + name[0] = DELETED; +} + /* Description. * Read next consequitive directory entry, pointed by fnp. * If some error occures the other critical @@ -306,6 +276,8 @@ COUNT dir_read(REG f_node_ptr fnp) b_buffer[((UWORD) new_diroff) % fnp->f_dpb->dpb_secsize], (struct dirent FAR *)&fnp->f_dir); + swap_deleted(fnp->f_dir.dir_name); + /* Update the fnode's directory info */ fnp->f_flags.f_dmod = FALSE; fnp->f_flags.f_dnew = FALSE; @@ -399,10 +371,15 @@ BOOL dir_write(REG f_node_ptr fnp) if (fnp->f_flags.f_dnew && fnp->f_dir.dir_attrib != D_LFN) fmemset(&fnp->f_dir.dir_case, 0, 8); + + swap_deleted(fnp->f_dir.dir_name); + putdirent((struct dirent FAR *)&fnp->f_dir, (VOID FAR *) & bp->b_buffer[(UWORD) fnp->f_diroff % fnp->f_dpb->dpb_secsize]); + swap_deleted(fnp->f_dir.dir_name); + bp->b_flag &= ~(BFR_DATA | BFR_FAT); bp->b_flag |= BFR_DIR | BFR_DIRTY | BFR_VALID; } @@ -422,6 +399,7 @@ VOID dir_close(REG f_node_ptr fnp) #endif /* Clear buffers after release */ + /* hazard: no error checking! */ flush_buffers(fnp->f_dpb->dpb_unit); /* and release this instance of the fnode */ @@ -434,10 +412,6 @@ COUNT dos_findfirst(UCOUNT attr, BYTE * name) REG f_node_ptr fnp; REG dmatch *dmp = (dmatch *) TempBuffer; REG COUNT i; - COUNT nDrive; - BYTE *p; - - BYTE local_name[FNAME_SIZE + 1], local_ext[FEXT_SIZE + 1]; /* printf("ff %Fs\n", name);*/ @@ -449,63 +423,37 @@ COUNT dos_findfirst(UCOUNT attr, BYTE * name) /* current directory, do a seek and read, then close the fnode. */ /* Parse out the drive, file name and file extension. */ - i = ParseDosName(name, &nDrive, &szDirName[2], local_name, local_ext, - TRUE); - if (i != SUCCESS) + i = ParseDosName(name, SearchDir.dir_name, TRUE); + if (i < SUCCESS) return i; /* printf("\nff %s", Tname); - printf("ff %s", local_name); - printf("ff %s\n", local_ext); + printf("ff %s", fcbname); */ - /* Build the match pattern out of the passed string */ - /* copy the part of the pattern which belongs to the filename and is fixed */ - for (p = local_name, i = 0; i < FNAME_SIZE && *p; ++p, ++i) - SearchDir.dir_name[i] = *p; - - for (; i < FNAME_SIZE; ++i) - SearchDir.dir_name[i] = ' '; - - /* and the extension (don't forget to add trailing spaces)... */ - for (p = local_ext, i = 0; i < FEXT_SIZE && *p; ++p, ++i) - SearchDir.dir_ext[i] = *p; - - for (; i < FEXT_SIZE; ++i) - SearchDir.dir_ext[i] = ' '; - - /* Convert everything to uppercase. */ - DosUpFMem(SearchDir.dir_name, FNAME_SIZE + FEXT_SIZE); - /* Now search through the directory to find the entry... */ - /* Complete building the directory from the passed in */ - /* name */ - szDirName[0] = 'A' + nDrive; - szDirName[1] = ':'; - /* Special handling - the volume id is only in the root */ /* directory and only searched for once. So we need to open */ /* the root and return only the first entry that contains the */ /* volume id bit set. */ if (attr == D_VOLID) - { - szDirName[2] = '\\'; - szDirName[3] = '\0'; - } + i = 3; /* Now open this directory so that we can read the */ /* fnode entry and do a match on it. */ /* printf("dir_open %s\n", szDirName);*/ - if ((fnp = dir_open(szDirName)) == NULL) - return DE_PATHNOTFND; + { + char tmp = name[i]; + name[i] = '\0'; + if ((fnp = dir_open(name)) == NULL) + return DE_PATHNOTFND; + name[i] = tmp; + } /* Now initialize the dirmatch structure. */ - nDrive = get_verify_drive(name); - if (nDrive < 0) - return nDrive; - dmp->dm_drive = nDrive; + dmp->dm_drive = name[0] - 'A'; dmp->dm_attr_srch = attr; /* Copy the raw pattern from our data segment to the DTA. */ @@ -605,9 +553,7 @@ COUNT dos_findnext(void) if (fnp->f_dir.dir_name[0] != '\0' && fnp->f_dir.dir_name[0] != DELETED && (fnp->f_dir.dir_attrib & D_VOLID) != D_VOLID) { - if (fcmp_wild - ((BYTE FAR *) dmp->dm_name_pat, (BYTE FAR *) fnp->f_dir.dir_name, - FNAME_SIZE + FEXT_SIZE)) + if (fcmp_wild(dmp->dm_name_pat, fnp->f_dir.dir_name, FNAME_SIZE + FEXT_SIZE)) { /* MSD Command.com uses FCB FN 11 & 12 with attrib set to 0x16. @@ -694,6 +640,7 @@ void ConvertName83ToNameSZ(BYTE FAR * destSZ, BYTE FAR * srcFCBName) *destSZ = '\0'; } +#if 0 /* returns the asciiSZ length of a 8.3 filename */ @@ -706,6 +653,7 @@ int FileName83Length(BYTE * filename83) return strlen(buff); } +#endif /* * Log: fatdir.c,v - for newer log entries do a "cvs log fatdir.c" diff --git a/kernel/fatfs.c b/kernel/fatfs.c index 6c2db6c0..d733bc5b 100644 --- a/kernel/fatfs.c +++ b/kernel/fatfs.c @@ -39,8 +39,8 @@ BYTE *RcsId = "$Id$"; /* */ f_node_ptr xlt_fd(COUNT); COUNT xlt_fnp(f_node_ptr); -f_node_ptr split_path(BYTE *, BYTE *, BYTE *); -BOOL find_fname(f_node_ptr, BYTE *, BYTE *, int); +STATIC f_node_ptr split_path(char *, char *); +BOOL find_fname(f_node_ptr, char *, int); /* /// Added - Ron Cemer */ STATIC void merge_file_changes(f_node_ptr fnp, int collect); /* /// Added - Ron Cemer */ @@ -77,63 +77,158 @@ ULONG clus2phys(CLUSTER cl_no, struct dpb FAR * dpbp) /* Open a file given the path. Flags is 0 for read, 1 for write and 2 */ /* for update. */ -/* Returns an integer file desriptor or a negative error code */ +/* Returns an long where the high word is a status code and the low */ +/* word is an integer file descriptor or a negative error code */ +/* see DosOpenSft(), dosfns.c for an explanation of the flags bits */ +/* directory opens are allowed here; these are not allowed by DosOpenSft*/ -COUNT dos_open(BYTE * path, COUNT flag) +long dos_open(char *path, unsigned flags, unsigned attrib) { REG f_node_ptr fnp; + char fcbname[FNAME_SIZE + FEXT_SIZE]; + int status = S_OPENED; - /* First test the flag to see if the user has passed a valid */ + /* First test the flags to see if the user has passed a valid */ /* file mode... */ - if (flag < 0 || flag > 2) + if ((flags & 3) > 2) return DE_INVLDACC; /* first split the passed dir into comopnents (i.e. - path to */ /* new directory and name of new directory. */ - if ((fnp = split_path(path, szFileName, szFileExt)) == NULL) - { + if ((fnp = split_path(path, fcbname)) == NULL) return DE_PATHNOTFND; + + /* Check that we don't have a duplicate name, so if we */ + /* find one, truncate it (O_CREAT). */ + if (find_fname(fnp, fcbname, D_ALL | attrib)) + { + if (flags & O_TRUNC) + { + /* The only permissable attribute is archive, */ + /* check for any other bit set. If it is, give */ + /* an access error. */ + if ((fnp->f_dir.dir_attrib & (D_RDONLY | D_DIR | D_VOLID)) + || (fnp->f_dir.dir_attrib & ~D_ARCHIVE & ~attrib)) + { + dir_close(fnp); + return DE_ACCESS; + } + + /* Release the existing files FAT and set the */ + /* length to zero, effectively truncating the */ + /* file to zero. */ + wipe_out(fnp); + status = S_REPLACED; + } + else if (!(flags & O_OPEN)) + { + dir_close(fnp); + return DE_FILEEXISTS; + } } + else if (flags & O_CREAT) + { + BOOL is_free; - /* Look for the file. If we can't find it, just return a not */ - /* found error. */ - if (!find_fname(fnp, szFileName, szFileExt, D_ALL)) + /* Reset the directory by a close followed by */ + /* an open */ + fnp->f_flags.f_dmod = FALSE; + dir_close(fnp); + fnp = split_path(path, fcbname); + + /* Get a free f_node pointer so that we can use */ + /* it in building the new file. */ + /* Note that if we're in the root and we don't */ + /* find an empty slot, we need to abort. */ + if (((is_free = find_free(fnp)) == 0) && (fnp->f_flags.f_droot)) + { + fnp->f_flags.f_dmod = FALSE; + dir_close(fnp); + return DE_TOOMANY; + } + + /* Otherwise just expand the directory */ + else if (!is_free && !(fnp->f_flags.f_droot)) + { + COUNT ret; + + if ((ret = extend_dir(fnp)) != SUCCESS) + /* fnp already closed in extend_dir */ + return ret; + } + + /* put the fnode's name into the directory. */ + memcpy(fnp->f_dir.dir_name, fcbname, FNAME_SIZE + FEXT_SIZE); + status = S_CREATED; + } + else { + /* open: If we can't find the file, just return a not */ + /* found error. */ dir_close(fnp); return DE_FILENOTFND; } + + /* Set the fnode to the desired mode */ + /* Updating the directory entry first. */ + fnp->f_mode = flags & 3; + + if (status != S_OPENED) + { + fnp->f_dir.dir_size = 0l; + setdstart(fnp->f_dir, FREE); + fnp->f_dir.dir_attrib = attrib; + fnp->f_dir.dir_time = dos_gettime(); + fnp->f_dir.dir_date = dos_getdate(); + + fnp->f_flags.f_dmod = TRUE; + fnp->f_flags.f_ddate = FALSE; + fnp->f_flags.f_dnew = FALSE; + fnp->f_flags.f_ddir = TRUE; + if (!dir_write(fnp)) + { + release_f_node(fnp); + return DE_ACCESS; + } + } - /* Set the fnode to the desired mode */ - fnp->f_mode = flag; + /* force r/o open for FCBs if the file is read-only */ + if ((flags & O_FCB) && (fnp->f_dir.dir_attrib & D_RDONLY)) + fnp->f_mode = O_RDONLY; - /* Initialize the rest of the fnode. */ + /* Check permissions. -- JPP */ + if ((fnp->f_dir.dir_attrib & D_RDONLY) && (fnp->f_mode != O_RDONLY)) + { + dir_close(fnp); + return DE_ACCESS; + } + + /* Now change to file */ fnp->f_offset = 0l; fnp->f_highwater = fnp->f_dir.dir_size; - + fnp->f_back = LONG_LAST_CLUSTER; - - fnp->f_flags.f_dmod = FALSE; + if (status != S_OPENED) + { + fnp->f_cluster = FREE; + setdstart(fnp->f_dir, FREE); + fnp->f_cluster_offset = 0l; /*JPP */ + } + + fnp->f_flags.f_dmod = (status != S_OPENED); + fnp->f_flags.f_ddate = FALSE; fnp->f_flags.f_dnew = FALSE; fnp->f_flags.f_ddir = FALSE; - - merge_file_changes(fnp, TRUE); /* /// Added - Ron Cemer */ - + + merge_file_changes(fnp, status == S_OPENED); /* /// Added - Ron Cemer */ /* /// Moved from above. - Ron Cemer */ fnp->f_cluster = getdstart(fnp->f_dir); fnp->f_cluster_offset = 0l; /*JPP */ - return xlt_fnp(fnp); -} - -BOOL fcmp(BYTE * s1, BYTE * s2, COUNT n) -{ - while (n--) - if (*s1++ != *s2++) - return FALSE; - return TRUE; + return xlt_fnp(fnp) | ((long)status << 16); } -BOOL fcmp_wild(BYTE FAR * s1, BYTE FAR * s2, COUNT n) +BOOL fcmp_wild(const char * s1, const char * s2, unsigned n) { while (n--) { @@ -203,31 +298,15 @@ COUNT dos_commit(COUNT fd) /* */ /* split a path into it's component directory and file name */ /* */ -f_node_ptr split_path(BYTE * path, BYTE * fname, BYTE * fext) +f_node_ptr split_path(char * path, char * fcbname) { REG f_node_ptr fnp; - COUNT nDrive; - struct cds FAR *cdsp; - /* Start off by parsing out the components. */ - if (ParseDosName(path, &nDrive, &szDirName[2], fname, fext, FALSE) - != SUCCESS) - return (f_node_ptr) 0; - if (nDrive < 0) - nDrive = default_drive; - - szDirName[0] = 'A' + nDrive; - szDirName[1] = ':'; + /* Start off by parsing out the components. */ + int dirlength = ParseDosName(path, fcbname, FALSE); - /* Add trailing spaces to the file name and extension */ - SpacePad(fname, FNAME_SIZE); - SpacePad(fext, FEXT_SIZE); - - if (nDrive >= lastdrive) - { + if (dirlength < SUCCESS) return (f_node_ptr) 0; - } - cdsp = &CDSp[nDrive]; /* 11/29/99 jt * Networking and Cdroms. You can put in here a return. @@ -241,7 +320,7 @@ f_node_ptr split_path(BYTE * path, BYTE * fname, BYTE * fext) */ #ifdef DEBUG - if (cdsp->cdsFlags & CDSNETWDRV) + if (CDSp[path[0]-'A'].cdsFlags & CDSNETWDRV) { printf("split path called for redirected file: `%s.%s'\n", fname, fext); @@ -250,7 +329,12 @@ f_node_ptr split_path(BYTE * path, BYTE * fname, BYTE * fext) #endif /* Translate the path into a useful pointer */ - fnp = dir_open(szDirName); + { + char tmp = path[dirlength]; + path[dirlength] = '\0'; + fnp = dir_open(path); + path[dirlength] = tmp; + } /* If the fd was invalid because it was out of range or the */ /* requested file was not open, tell the caller and exit... */ @@ -261,21 +345,32 @@ f_node_ptr split_path(BYTE * path, BYTE * fname, BYTE * fext) return (f_node_ptr) 0; } - /* Convert the name into an absolute name for comparison... */ - DosUpFString((BYTE FAR *) szDirName); - DosUpFMem((BYTE FAR *) fname, FNAME_SIZE); - DosUpFMem((BYTE FAR *) fext, FEXT_SIZE); - return fnp; } -STATIC BOOL find_fname(f_node_ptr fnp, BYTE * fname, BYTE * fext, int attr) +/* checks whether directory part of path exists */ +BOOL dir_exists(char * path) +{ + REG f_node_ptr fnp; + char fcbname[FNAME_SIZE + FEXT_SIZE]; + + if ((fnp = split_path(path, fcbname)) == NULL) + return FALSE; + + dir_close(fnp); + return TRUE; +} + +BOOL fcbmatch(const char *fcbname1, const char *fcbname2) +{ + return memcmp(fcbname1, fcbname2, FNAME_SIZE + FEXT_SIZE) == 0; +} + +STATIC BOOL find_fname(f_node_ptr fnp, char *fcbname, int attr) { while (dir_read(fnp) == 1) { - if (fnp->f_dir.dir_name[0] != DELETED - && fcmp(fname, (BYTE *) fnp->f_dir.dir_name, FNAME_SIZE) - && fcmp(fext, (BYTE *) fnp->f_dir.dir_ext, FEXT_SIZE) + if (fcbmatch(fnp->f_dir.dir_name, fcbname) && (fnp->f_dir.dir_attrib & ~(D_RDONLY | D_ARCHIVE | attr)) == 0) { return TRUE; @@ -375,12 +470,7 @@ STATIC int is_same_file(f_node_ptr fnp1, f_node_ptr fnp2) return (fnp1->f_dpb->dpb_unit == fnp2->f_dpb->dpb_unit) && (fnp1->f_dpb->dpb_subunit == fnp2->f_dpb->dpb_subunit) - && (fcmp - ((BYTE *) fnp1->f_dir.dir_name, - (BYTE *) fnp2->f_dir.dir_name, FNAME_SIZE)) - && (fcmp - ((BYTE *) fnp1->f_dir.dir_ext, - (BYTE *) fnp2->f_dir.dir_ext, FEXT_SIZE)) + && (fcbmatch(fnp1->f_dir.dir_name, fnp2->f_dir.dir_name)) && ((fnp1->f_dir.dir_attrib & D_VOLID) == 0) && ((fnp2->f_dir.dir_attrib & D_VOLID) == 0) && (fnp1->f_diroff == fnp2->f_diroff) @@ -401,108 +491,6 @@ STATIC void copy_file_changes(f_node_ptr src, f_node_ptr dst) dst->f_dir.dir_time = src->f_dir.dir_time; } -COUNT dos_creat(BYTE * path, int attrib) -{ - REG f_node_ptr fnp; - - /* first split the passed dir into components (i.e. - */ - /* path to new directory and name of new directory */ - if ((fnp = split_path(path, szFileName, szFileExt)) == NULL) - { - return DE_PATHNOTFND; - } - - /* Check that we don't have a duplicate name, so if we */ - /* find one, truncate it. */ - if (find_fname(fnp, szFileName, szFileExt, D_ALL | attrib)) - { - /* The only permissable attribute is archive, */ - /* check for any other bit set. If it is, give */ - /* an access error. */ - if ((fnp->f_dir.dir_attrib & (D_RDONLY | D_DIR | D_VOLID)) - || (fnp->f_dir.dir_attrib & ~D_ARCHIVE & ~attrib)) - { - dir_close(fnp); - return DE_ACCESS; - } - - /* Release the existing files FAT and set the */ - /* length to zero, effectively truncating the */ - /* file to zero. */ - wipe_out(fnp); - } - else - { - BOOL is_free; - - /* Reset the directory by a close followed by */ - /* an open */ - fnp->f_flags.f_dmod = FALSE; - dir_close(fnp); - fnp = split_path(path, szFileName, szFileExt); - - /* Get a free f_node pointer so that we can use */ - /* it in building the new file. */ - /* Note that if we're in the root and we don't */ - /* find an empty slot, we need to abort. */ - if (((is_free = find_free(fnp)) == 0) && (fnp->f_flags.f_droot)) - { - fnp->f_flags.f_dmod = FALSE; - dir_close(fnp); - return DE_TOOMANY; - } - - /* Otherwise just expand the directory */ - else if (!is_free && !(fnp->f_flags.f_droot)) - { - COUNT ret; - - if ((ret = extend_dir(fnp)) != SUCCESS) - return ret; - } - - /* put the fnode's name into the directory. */ - memcpy(fnp->f_dir.dir_name, szFileName, FNAME_SIZE); - memcpy(fnp->f_dir.dir_ext, szFileExt, FEXT_SIZE); - } - /* Set the fnode to the desired mode */ - /* Updating the directory entry first. */ - fnp->f_mode = RDWR; - - fnp->f_dir.dir_size = 0l; - setdstart(fnp->f_dir, FREE); - fnp->f_dir.dir_attrib = attrib | D_ARCHIVE; - fnp->f_dir.dir_time = dos_gettime(); - fnp->f_dir.dir_date = dos_getdate(); - - fnp->f_flags.f_dmod = TRUE; - fnp->f_flags.f_ddate = FALSE; - fnp->f_flags.f_dnew = FALSE; - fnp->f_flags.f_ddir = TRUE; - if (!dir_write(fnp)) - { - release_f_node(fnp); - return DE_ACCESS; - } - - /* Now change to file */ - fnp->f_offset = 0l; - fnp->f_highwater = 0l; - - fnp->f_back = LONG_LAST_CLUSTER; - fnp->f_cluster = FREE; - setdstart(fnp->f_dir, FREE); - fnp->f_cluster_offset = 0l; /*JPP */ - fnp->f_flags.f_dmod = TRUE; - fnp->f_flags.f_ddate = FALSE; - fnp->f_flags.f_dnew = FALSE; - fnp->f_flags.f_ddir = FALSE; - - merge_file_changes(fnp, FALSE); /* /// Added - Ron Cemer */ - - return xlt_fnp(fnp); -} - STATIC COUNT delete_dir_entry(f_node_ptr fnp) { COUNT rc; @@ -529,17 +517,18 @@ STATIC COUNT delete_dir_entry(f_node_ptr fnp) COUNT dos_delete(BYTE * path, int attrib) { REG f_node_ptr fnp; + char fcbname[FNAME_SIZE + FEXT_SIZE]; /* first split the passed dir into components (i.e. - */ /* path to new directory and name of new directory */ - if ((fnp = split_path(path, szFileName, szFileExt)) == NULL) + if ((fnp = split_path(path, fcbname)) == NULL) { return DE_PATHNOTFND; } /* Check that we don't have a duplicate name, so if we */ /* find one, it's an error. */ - if (find_fname(fnp, szFileName, szFileExt, attrib)) + if (find_fname(fnp, fcbname, attrib)) { /* Do not delete directories or r/o files */ /* lfn entries and volume labels are only found */ @@ -566,10 +555,11 @@ COUNT dos_rmdir(BYTE * path) REG f_node_ptr fnp; REG f_node_ptr fnp1; BOOL found; + char fcbname[FNAME_SIZE + FEXT_SIZE]; /* first split the passed dir into comopnents (i.e. - */ /* path to new directory and name of new directory */ - if ((fnp = split_path(path, szFileName, szFileExt)) == NULL) + if ((fnp = split_path(path, fcbname)) == NULL) { return DE_PATHNOTFND; } @@ -583,7 +573,7 @@ COUNT dos_rmdir(BYTE * path) /* Check that we don't have a duplicate name, so if we */ /* find one, it's an error. */ - if (find_fname(fnp, szFileName, szFileExt, D_ALL)) + if (find_fname(fnp, fcbname, D_ALL)) { /* The only permissable attribute is directory, */ /* check for any other bit set. If it is, give */ @@ -658,17 +648,18 @@ COUNT dos_rename(BYTE * path1, BYTE * path2, int attrib) REG f_node_ptr fnp2; BOOL is_free; COUNT ret; + char fcbname[FNAME_SIZE + FEXT_SIZE]; /* first split the passed target into compnents (i.e. - path to */ /* new file name and name of new file name */ - if ((fnp2 = split_path(path2, szFileName, szFileExt)) == NULL) + if ((fnp2 = split_path(path2, fcbname)) == NULL) { return DE_PATHNOTFND; } /* Check that we don't have a duplicate name, so if we find */ /* one, it's an error. */ - if (find_fname(fnp2, szFileName, szFileExt, attrib)) + if (find_fname(fnp2, fcbname, attrib)) { dir_close(fnp2); return DE_ACCESS; @@ -676,13 +667,13 @@ COUNT dos_rename(BYTE * path1, BYTE * path2, int attrib) /* next split the passed source into compnents (i.e. - path to */ /* old file name and name of old file name */ - if ((fnp1 = split_path(path1, szFileName, szFileExt)) == NULL) + if ((fnp1 = split_path(path1, fcbname)) == NULL) { dir_close(fnp2); return DE_PATHNOTFND; } - if (!find_fname(fnp1, szFileName, szFileExt, attrib)) + if (!find_fname(fnp1, fcbname, attrib)) { /* No such file, return the error */ dir_close(fnp1); @@ -693,7 +684,7 @@ COUNT dos_rename(BYTE * path1, BYTE * path2, int attrib) /* Reset the directory by a close followed by an open */ fnp2->f_flags.f_dmod = FALSE; dir_close(fnp2); - fnp2 = split_path(path2, szFileName, szFileExt); + fnp2 = split_path(path2, fcbname); /* Now find a free slot to put the file into. */ /* If it's the root and we don't have room, return an error. */ @@ -719,8 +710,7 @@ COUNT dos_rename(BYTE * path1, BYTE * path2, int attrib) return ret; /* put the fnode's name into the directory. */ - memcpy(fnp2->f_dir.dir_name, szFileName, FNAME_SIZE); - memcpy(fnp2->f_dir.dir_ext, szFileExt, FEXT_SIZE); + memcpy(fnp2->f_dir.dir_name, fcbname, FNAME_SIZE + FEXT_SIZE); /* Set the fnode to the desired mode */ fnp2->f_dir.dir_size = fnp1->f_dir.dir_size; @@ -766,7 +756,7 @@ STATIC VOID wipe_out_clusters(struct dpb FAR * dpbp, CLUSTER st) next = next_cluster(dpbp, st); /* just exit if a damaged file system exists */ - if (next == FREE) + if (next == FREE || next == 1) return; /* zap the FAT pointed to */ @@ -820,15 +810,13 @@ STATIC BOOL find_free(f_node_ptr fnp) /* */ date dos_getdate() { - BYTE WeekDay, Month, MonthDay; - COUNT Year; + UBYTE WeekDay, Month, MonthDay; + UWORD Year; date Date; /* First - get the system date set by either the user */ /* on start-up or the CMOS clock */ - DosGetDate((BYTE FAR *) & WeekDay, - (BYTE FAR *) & Month, - (BYTE FAR *) & MonthDay, (COUNT FAR *) & Year); + DosGetDate(&WeekDay, &Month, &MonthDay, &Year); Date = DT_ENCODE(Month, MonthDay, Year - EPOCH_YEAR); return Date; } @@ -838,13 +826,11 @@ date dos_getdate() /* */ time dos_gettime() { - BYTE Hour, Minute, Second, Hundredth; + UBYTE Hour, Minute, Second, Hundredth; /* First - get the system time set by either the user */ /* on start-up or the CMOS clock */ - DosGetTime((BYTE FAR *) & Hour, - (BYTE FAR *) & Minute, - (BYTE FAR *) & Second, (BYTE FAR *) & Hundredth); + DosGetTime(&Hour, &Minute, &Second, &Hundredth); return TM_ENCODE(Hour, Minute, Second / 2); } @@ -901,7 +887,7 @@ COUNT dos_setftime(COUNT fd, date dp, time tp) /* */ /* dos_getfsize for the file time */ /* */ -LONG dos_getcufsize(COUNT fd) +ULONG dos_getfsize(COUNT fd) { f_node_ptr fnp; @@ -913,33 +899,12 @@ LONG dos_getcufsize(COUNT fd) /* requested file was not open, tell the caller and exit */ /* note: an invalid fd is indicated by a 0 return */ if (fnp == (f_node_ptr) 0 || fnp->f_count <= 0) - return -1l; + return (ULONG)-1l; /* Return the file size */ return fnp->f_highwater; } -/* */ -/* dos_getfsize for the file time */ -/* */ -LONG dos_getfsize(COUNT fd) -{ - f_node_ptr fnp; - - /* Translate the fd into an fnode pointer, since all internal */ - /* operations are achieved through fnodes. */ - fnp = xlt_fd(fd); - - /* If the fd was invalid because it was out of range or the */ - /* requested file was not open, tell the caller and exit */ - /* note: an invalid fd is indicated by a 0 return */ - if (fnp == (f_node_ptr) 0 || fnp->f_count <= 0) - return -1l; - - /* Return the file size */ - return fnp->f_dir.dir_size; -} - /* */ /* dos_setfsize for the file time */ /* */ @@ -1050,10 +1015,11 @@ COUNT dos_mkdir(BYTE * dir) struct dpb FAR *dpbp; CLUSTER free_fat, parent; COUNT ret; - + char fcbname[FNAME_SIZE + FEXT_SIZE]; + /* first split the passed dir into comopnents (i.e. - */ /* path to new directory and name of new directory */ - if ((fnp = split_path(dir, szFileName, szFileExt)) == NULL) + if ((fnp = split_path(dir, fcbname)) == NULL) { return DE_PATHNOTFND; } @@ -1074,7 +1040,7 @@ COUNT dos_mkdir(BYTE * dir) /* Check that we don't have a duplicate name, so if we */ /* find one, it's an error. */ - if (find_fname(fnp, szFileName, szFileExt, D_ALL)) + if (find_fname(fnp, fcbname, D_ALL)) { dir_close(fnp); return DE_ACCESS; @@ -1085,7 +1051,7 @@ COUNT dos_mkdir(BYTE * dir) fnp->f_flags.f_dmod = FALSE; parent = fnp->f_dirstart; dir_close(fnp); - fnp = split_path(dir, szFileName, szFileExt); + fnp = split_path(dir, fcbname); /* Get a free f_node pointer so that we can use */ /* it in building the new file. */ @@ -1121,8 +1087,7 @@ COUNT dos_mkdir(BYTE * dir) } /* put the fnode's name into the directory. */ - memcpy(fnp->f_dir.dir_name, szFileName, FNAME_SIZE); - memcpy(fnp->f_dir.dir_ext, szFileExt, FEXT_SIZE); + memcpy(fnp->f_dir.dir_name, fcbname, FNAME_SIZE + FEXT_SIZE); /* Set the fnode to the desired mode */ fnp->f_mode = WRONLY; @@ -1160,8 +1125,8 @@ COUNT dos_mkdir(BYTE * dir) } /* Create the "." entry */ - memcpy(DirEntBuffer.dir_name, ". ", FNAME_SIZE); - memcpy(DirEntBuffer.dir_ext, " ", FEXT_SIZE); + DirEntBuffer.dir_name[0] = '.'; + memset(DirEntBuffer.dir_name + 1, ' ', FNAME_SIZE + FEXT_SIZE - 1); DirEntBuffer.dir_attrib = D_DIR; DirEntBuffer.dir_time = dos_gettime(); DirEntBuffer.dir_date = dos_getdate(); @@ -1169,10 +1134,10 @@ COUNT dos_mkdir(BYTE * dir) DirEntBuffer.dir_size = 0l; /* And put it out */ - putdirent((struct dirent FAR *)&DirEntBuffer, (BYTE FAR *) bp->b_buffer); + putdirent(&DirEntBuffer, bp->b_buffer); /* create the ".." entry */ - memcpy(DirEntBuffer.dir_name, ".. ", FNAME_SIZE); + DirEntBuffer.dir_name[1] = '.'; #ifdef WITHFAT32 if (ISFAT32(dpbp) && parent == dpbp->dpb_xrootclst) { @@ -1182,8 +1147,7 @@ COUNT dos_mkdir(BYTE * dir) setdstart(DirEntBuffer, parent); /* and put it out */ - putdirent((struct dirent FAR *)&DirEntBuffer, - (BYTE FAR *) & bp->b_buffer[DIRENT_SIZE]); + putdirent(&DirEntBuffer, &bp->b_buffer[DIRENT_SIZE]); /* fill the rest of the block with zeros */ fmemset(&bp->b_buffer[2 * DIRENT_SIZE], 0, BUFFERSIZE - 2 * DIRENT_SIZE); @@ -1212,6 +1176,7 @@ COUNT dos_mkdir(BYTE * dir) } /* flush the drive buffers so that all info is written */ + /* hazard: no error checking! */ flush_buffers((COUNT) (dpbp->dpb_unit)); /* Close the directory so that the entry is updated */ @@ -1292,6 +1257,7 @@ STATIC COUNT extend_dir(f_node_ptr fnp) } /* flush the drive buffers so that all info is written */ + /* hazard: no error checking! */ flush_buffers((COUNT) (fnp->f_dpb->dpb_unit)); return SUCCESS; @@ -1416,6 +1382,8 @@ COUNT map_cluster(REG f_node_ptr fnp, COUNT mode) fnp->f_cluster = next_cluster(fnp->f_dpb, fnp->f_cluster); fnp->f_cluster_offset += clssize; idx -= clssize; + if (fnp->f_cluster == 1) + return DE_SEEK; } #ifdef DISPLAY_GETBLOCK @@ -1578,8 +1546,8 @@ UCOUNT rwblock(COUNT fd, VOID FAR * buffer, UCOUNT count, int mode) REG struct buffer FAR *bp; UCOUNT xfr_cnt = 0; UCOUNT ret_cnt = 0; - UWORD secsize; - UCOUNT to_xfer = count; + unsigned secsize; + unsigned to_xfer = count; ULONG currentblock; #if 0 /*DSK_DEBUG*/ @@ -1932,7 +1900,7 @@ COUNT dos_cd(struct cds FAR * cdsp, BYTE * PathName) f_node_ptr get_f_node(void) { - REG i; + REG int i; for (i = 0; i < f_nodes_cnt; i++) { @@ -1959,66 +1927,54 @@ VOID dos_setdta(BYTE FAR * newdta) dta = newdta; } -COUNT dos_getfattr(BYTE * name) +COUNT dos_getfattr_fd(COUNT fd) { - f_node_ptr fnp; - COUNT fd, result; - - /* Translate the fd into an fnode pointer, since all internal */ - /* operations are achieved through fnodes. */ - if ((fd = dos_open(name, O_RDONLY)) < SUCCESS) - return DE_FILENOTFND; + f_node_ptr fnp = xlt_fd(fd); /* note: an invalid fd is indicated by a 0 return */ - if ((fnp = xlt_fd(fd)) == (f_node_ptr) 0) + if (fnp == (f_node_ptr) 0) return DE_TOOMANY; /* If the fd was invalid because it was out of range or the */ /* requested file was not open, tell the caller and exit */ if (fnp->f_count <= 0) - { - dos_close(fd); return DE_FILENOTFND; - } - /* Get the attribute from the fnode and return */ - result = fnp->f_dir.dir_attrib; + return fnp->f_dir.dir_attrib; +} + +COUNT dos_getfattr(BYTE * name) +{ + COUNT result, fd; + + fd = (short)dos_open(name, O_RDONLY | O_OPEN, 0); + if (fd < SUCCESS) + return fd; + + result = dos_getfattr_fd(fd); dos_close(fd); return result; } COUNT dos_setfattr(BYTE * name, UWORD attrp) { - f_node_ptr fnp; COUNT fd; + f_node_ptr fnp; - /* Translate the fd into an fnode pointer, since all internal */ - /* operations are achieved through fnodes. */ - if ((fd = dos_open(name, O_RDONLY)) < SUCCESS) - return DE_FILENOTFND; - - /* note: an invalid fd is indicated by a 0 return */ - if ((fnp = xlt_fd(fd)) == (f_node_ptr) 0) - return DE_TOOMANY; - - /* If the fd was invalid because it was out of range or the */ - /* requested file was not open, tell the caller and exit */ - if (fnp->f_count <= 0) - { - dos_close(fd); - return DE_FILENOTFND; - } /* JPP-If user tries to set VOLID or DIR bits, return error */ if ((attrp & (D_VOLID | D_DIR | 0xC0)) != 0) - { - dos_close(fd); return DE_ACCESS; - } + fd = (short)dos_open(name, O_RDONLY | O_OPEN, 0); + if (fd < SUCCESS) + return fd; + + fnp = xlt_fd(fd); + /* Set the attribute from the fnode and return */ /* clear all attributes but DIR and VOLID */ fnp->f_dir.dir_attrib &= (D_VOLID | D_DIR); /* JPP */ - + /* set attributes that user requested */ fnp->f_dir.dir_attrib |= attrp; /* JPP */ fnp->f_flags.f_dmod = TRUE; @@ -2094,8 +2050,6 @@ VOID bpb_to_dpb(bpb FAR * bpbp, REG struct dpb FAR * dpbp) COUNT media_check(REG struct dpb FAR * dpbp) { - BYTE status; - /* First test if anyone has changed the removable media */ FOREVER { @@ -2105,10 +2059,8 @@ COUNT media_check(REG struct dpb FAR * dpbp) MediaReqHdr.r_mcmdesc = dpbp->dpb_mdb; MediaReqHdr.r_status = 0; execrh((request FAR *) & MediaReqHdr, dpbp->dpb_device); - if (!(MediaReqHdr.r_status & S_ERROR) - && (MediaReqHdr.r_status & S_DONE)) - break; - else + if ((MediaReqHdr.r_status & S_ERROR) + || !(MediaReqHdr.r_status & S_DONE)) { loop1: switch (block_error(&MediaReqHdr, dpbp->dpb_unit, dpbp->dpb_device)) @@ -2127,10 +2079,10 @@ COUNT media_check(REG struct dpb FAR * dpbp) goto loop1; } } + break; } - status = MediaReqHdr.r_mcretcode | dpbp->dpb_flags; - switch (status) + switch (MediaReqHdr.r_mcretcode | dpbp->dpb_flags) { case M_NOT_CHANGED: /* It was definitely not changed, so ignore it */ @@ -2139,6 +2091,7 @@ COUNT media_check(REG struct dpb FAR * dpbp) /* If it is forced or the media may have changed, */ /* rebuild the bpb */ case M_DONT_KNOW: + /* hazard: no error checking! */ flush_buffers(dpbp->dpb_unit); /* If it definitely changed, don't know (falls through) */ @@ -2154,10 +2107,8 @@ COUNT media_check(REG struct dpb FAR * dpbp) MediaReqHdr.r_mcmdesc = dpbp->dpb_mdb; MediaReqHdr.r_status = 0; execrh((request FAR *) & MediaReqHdr, dpbp->dpb_device); - if (!(MediaReqHdr.r_status & S_ERROR) - && (MediaReqHdr.r_status & S_DONE)) - break; - else + if ((MediaReqHdr.r_status & S_ERROR) + || !(MediaReqHdr.r_status & S_DONE)) { loop2: switch (block_error @@ -2177,6 +2128,7 @@ COUNT media_check(REG struct dpb FAR * dpbp) goto loop2; } } + break; } #ifdef WITHFAT32 /* extend dpb only for internal or FAT32 devices */ @@ -2185,9 +2137,6 @@ COUNT media_check(REG struct dpb FAR * dpbp) #else bpb_to_dpb(MediaReqHdr.r_bpptr, dpbp); #endif - /* need to change to root directory if changed */ - if (status == M_CHANGED) - CDSp[dpbp->dpb_unit].cdsCurrentPath[3] = '\0'; return SUCCESS; } } @@ -2249,7 +2198,7 @@ STATIC VOID shrink_file(f_node_ptr fnp) next = next_cluster(dpbp, st); - if (next == LONG_LAST_CLUSTER) /* last cluster found */ + if (next == 1 || next == LONG_LAST_CLUSTER) /* error last cluster found */ goto done; /* Loop from start until either a FREE entry is */ diff --git a/kernel/fcbfns.c b/kernel/fcbfns.c index a575a973..c010ff62 100644 --- a/kernel/fcbfns.c +++ b/kernel/fcbfns.c @@ -36,38 +36,30 @@ static BYTE *RcsId = #define FCB_SUCCESS 0 #define FCB_ERR_NODATA 1 +#define FCB_ERR_SEGMENT_WRAP 2 #define FCB_ERR_EOF 3 -#define FCB_ERR_WRITE 1 +#define FCB_ERROR 0xff -#ifdef PROTO -fcb FAR *ExtFcbToFcb(xfcb FAR * lpExtFcb); -fcb FAR *CommonFcbInit(xfcb FAR * lpExtFcb, BYTE * pszBuffer, +STATIC fcb FAR *ExtFcbToFcb(xfcb FAR * lpExtFcb); +STATIC fcb FAR *CommonFcbInit(xfcb FAR * lpExtFcb, BYTE * pszBuffer, COUNT * pCurDrive); -void FcbNameInit(fcb FAR * lpFcb, BYTE * pszBuffer, COUNT * pCurDrive); -VOID FcbNextRecord(fcb FAR * lpFcb); -BOOL FcbCalcRec(xfcb FAR * lpXfcb); -#else -fcb FAR *ExtFcbToFcb(); -fcb FAR *CommonFcbInit(); -void FcbNameInit(); -VOID FcbNextRecord(); -BOOL FcbCalcRec(); -#endif +STATIC int FcbNameInit(fcb FAR * lpFcb, BYTE * pszBuffer, COUNT * pCurDrive); +STATIC void FcbNextRecord(fcb FAR * lpFcb); +STATIC void FcbCalcRec(xfcb FAR * lpXfcb); -#define TestCmnSeps(lpFileName) (strchr(":<|>+=,", *lpFileName) != NULL) -#define TestFieldSeps(lpFileName) (*(lpFileName) <= ' ' || strchr("/\"[]<>|.", *lpFileName) != NULL) +#define TestCmnSeps(lpFileName) (*lpFileName && strchr(":<|>+=,", *lpFileName) != NULL) +#define TestFieldSeps(lpFileName) ((unsigned char)*lpFileName <= ' ' || strchr("/\"[]<>|.", *lpFileName) != NULL) static dmatch Dmatch; -VOID FatGetDrvData(UCOUNT drive, UCOUNT FAR * spc, UCOUNT FAR * bps, - UCOUNT FAR * nc, BYTE FAR ** mdp) +BYTE FAR *FatGetDrvData(UBYTE drive, UWORD * spc, UWORD * bps, UWORD * nc) { static BYTE mdb; - UCOUNT navc; + UWORD navc; /* get the data available from dpb */ *nc = 0xffff; /* pass 0xffff to skip free count */ - if (DosGetFree((UBYTE) drive, spc, &navc, bps, nc)) + if (DosGetFree(drive, spc, &navc, bps, nc)) { struct cds FAR *cdsp = &CDSp[(drive == 0 ? default_drive : drive - 1)]; @@ -75,14 +67,15 @@ VOID FatGetDrvData(UCOUNT drive, UCOUNT FAR * spc, UCOUNT FAR * bps, if (cdsp->cdsFlags & CDSNETWDRV) { mdb = *spc >> 8; - *mdp = &mdb; *spc &= 0xff; + return &mdb; } else { - *mdp = (BYTE FAR *) & (cdsp->cdsDpb->dpb_mdb); + return (BYTE FAR *) & (cdsp->cdsDpb->dpb_mdb); } } + return NULL; } #define PARSE_SEP_STOP 0x01 @@ -95,78 +88,81 @@ VOID FatGetDrvData(UCOUNT drive, UCOUNT FAR * spc, UCOUNT FAR * bps, #define PARSE_RET_BADDRIVE 0xff #ifndef IPL -WORD FcbParseFname(int wTestMode, const BYTE FAR ** lpFileName, fcb FAR * lpFcb) +UWORD FcbParseFname(int *wTestMode, const BYTE FAR * lpFileName, fcb FAR * lpFcb) { - COUNT nIndex; WORD wRetCodeName = FALSE, wRetCodeExt = FALSE; + const BYTE FAR * lpFileName2 = lpFileName; /* pjv -- ExtFcbToFcb? */ /* Start out with some simple stuff first. Check if we are */ /* going to use a default drive specificaton. */ - if (!(wTestMode & PARSE_DFLT_DRIVE)) + if (!(*wTestMode & PARSE_DFLT_DRIVE)) lpFcb->fcb_drive = FDFLT_DRIVE; - if (!(wTestMode & PARSE_BLNK_FNAME)) + if (!(*wTestMode & PARSE_BLNK_FNAME)) { - for (nIndex = 0; nIndex < FNAME_SIZE; ++nIndex) - lpFcb->fcb_fname[nIndex] = ' '; + fmemset(lpFcb->fcb_fname, ' ', FNAME_SIZE); } - if (!(wTestMode & PARSE_BLNK_FEXT)) + if (!(*wTestMode & PARSE_BLNK_FEXT)) { - for (nIndex = 0; nIndex < FEXT_SIZE; ++nIndex) - lpFcb->fcb_fext[nIndex] = ' '; + fmemset(lpFcb->fcb_fext, ' ', FEXT_SIZE); } /* Undocumented behavior, set record number & record size to 0 */ lpFcb->fcb_cublock = lpFcb->fcb_recsiz = 0; - if (!(wTestMode & PARSE_SEP_STOP)) + if (!(*wTestMode & PARSE_SEP_STOP)) { - *lpFileName = ParseSkipWh(*lpFileName); - if (TestCmnSeps(*lpFileName)) - ++ * lpFileName; + lpFileName2 = ParseSkipWh(lpFileName2); + if (TestCmnSeps(lpFileName2)) + ++lpFileName2; } /* Undocumented "feature," we skip white space anyway */ - *lpFileName = ParseSkipWh(*lpFileName); + lpFileName2 = ParseSkipWh(lpFileName2); /* Now check for drive specification */ - if (*(*lpFileName + 1) == ':') + if (*(lpFileName2 + 1) == ':') { /* non-portable construct to be changed */ - REG UBYTE Drive = DosUpFChar(**lpFileName) - 'A'; + REG UBYTE Drive = DosUpFChar(*lpFileName2) - 'A'; if (Drive >= lastdrive) - return PARSE_RET_BADDRIVE; + { + *wTestMode = PARSE_RET_BADDRIVE; + return lpFileName2 - lpFileName; + } lpFcb->fcb_drive = Drive + 1; - *lpFileName += 2; + lpFileName2 += 2; } /* special cases: '.' and '..' */ - if (**lpFileName == '.') + if (*lpFileName2 == '.') { lpFcb->fcb_fname[0] = '.'; - ++*lpFileName; - if (**lpFileName == '.') + ++lpFileName2; + if (*lpFileName2 == '.') { lpFcb->fcb_fname[1] = '.'; - ++*lpFileName; + ++lpFileName2; } - return PARSE_RET_NOWILD; + *wTestMode = PARSE_RET_NOWILD; + return lpFileName2 - lpFileName; } /* Now to format the file name into the string */ - *lpFileName = - GetNameField(*lpFileName, (BYTE FAR *) lpFcb->fcb_fname, FNAME_SIZE, + lpFileName2 = + GetNameField(lpFileName2, (BYTE FAR *) lpFcb->fcb_fname, FNAME_SIZE, (BOOL *) & wRetCodeName); /* Do we have an extension? If do, format it else return */ - if (**lpFileName == '.') - *lpFileName = - GetNameField(++*lpFileName, (BYTE FAR *) lpFcb->fcb_fext, + if (*lpFileName2 == '.') + lpFileName2 = + GetNameField(++lpFileName2, (BYTE FAR *) lpFcb->fcb_fext, FEXT_SIZE, (BOOL *) & wRetCodeExt); - return (wRetCodeName | wRetCodeExt) ? PARSE_RET_WILD : PARSE_RET_NOWILD; + *wTestMode = (wRetCodeName | wRetCodeExt) ? PARSE_RET_WILD : PARSE_RET_NOWILD; + return lpFileName2 - lpFileName; } const BYTE FAR * ParseSkipWh(const BYTE FAR * lpFileName) @@ -229,8 +225,7 @@ const BYTE FAR * GetNameField(const BYTE FAR * lpFileName, BYTE FAR * lpDestFiel } /* Blank out remainder of field on exit */ - for (; nIndex < nFieldSize; ++nIndex) - *lpDestField++ = cFill; + fmemset(lpDestField, cFill, nFieldSize - nIndex); return lpFileName; } @@ -248,109 +243,55 @@ STATIC ULONG FcbRec(VOID) return ((ULONG) lpFcb->fcb_cublock * 128) + lpFcb->fcb_curec; } -BOOL FcbRead(xfcb FAR * lpXfcb, COUNT * nErrorCode, UCOUNT recno) +UBYTE FcbReadWrite(xfcb FAR * lpXfcb, UCOUNT recno, int mode) { sft FAR *s; ULONG lPosit; - COUNT nRead; + UCOUNT nTransfer; BYTE far * FcbIoPtr = dta + recno * lpFcb->fcb_recsiz; + if ((ULONG)recno * lpFcb->fcb_recsiz >= 0x10000ul || + FP_OFF(FcbIoPtr) < FP_OFF(dta)) + return FCB_ERR_SEGMENT_WRAP; + /* Convert to fcb if necessary */ lpFcb = ExtFcbToFcb(lpXfcb); - + /* Get the SFT block that contains the SFT */ if ((s = idx_to_sft(lpFcb->fcb_sftno)) == (sft FAR *) - 1) - return FALSE; + return FCB_ERR_NODATA; /* If this is not opened another error */ if (s->sft_count == 0) - return FALSE; - + return FCB_ERR_NODATA; + /* Now update the fcb and compute where we need to position */ /* to. */ lPosit = FcbRec() * lpFcb->fcb_recsiz; - if (SftSeek(s, lPosit, 0) != SUCCESS) - { - *nErrorCode = FCB_ERR_EOF; - return FALSE; - } + if ((CritErrCode = -SftSeek(s, lPosit, 0)) != SUCCESS) + return FCB_ERR_NODATA; /* Do the read */ - nRead = DosReadSft(s, lpFcb->fcb_recsiz, FcbIoPtr, nErrorCode); - + nTransfer = DosRWSft(s, lpFcb->fcb_recsiz, FcbIoPtr, &CritErrCode, mode); + CritErrCode = -CritErrCode; + /* Now find out how we will return and do it. */ - if (nRead == lpFcb->fcb_recsiz) - { - *nErrorCode = FCB_SUCCESS; - FcbNextRecord(lpFcb); - return TRUE; - } - else if (nRead < 0) - { - *nErrorCode = FCB_ERR_EOF; - return TRUE; - } - else if (nRead == 0) + if (nTransfer == lpFcb->fcb_recsiz) { - *nErrorCode = FCB_ERR_NODATA; - return FALSE; - } - else - { - fmemset(FcbIoPtr + nRead, 0, lpFcb->fcb_recsiz - nRead); - *nErrorCode = FCB_ERR_EOF; + if (mode == XFR_WRITE) lpFcb->fcb_fsize = s->sft_size; FcbNextRecord(lpFcb); - return FALSE; - } -} - -BOOL FcbWrite(xfcb FAR * lpXfcb, COUNT * nErrorCode, UCOUNT recno) -{ - sft FAR *s; - ULONG lPosit; - COUNT nWritten; - BYTE far * FcbIoPtr = dta + recno * lpFcb->fcb_recsiz; - - /* Convert to fcb if necessary */ - lpFcb = ExtFcbToFcb(lpXfcb); - - /* Get the SFT block that contains the SFT */ - if ((s = idx_to_sft(lpFcb->fcb_sftno)) == (sft FAR *) - 1) - return FALSE; - - /* If this is not opened another error */ - if (s->sft_count == 0) - return FALSE; - - /* Now update the fcb and compute where we need to position */ - /* to. */ - lPosit = FcbRec() * lpFcb->fcb_recsiz; - if (SftSeek(s, lPosit, 0) != SUCCESS) - { - *nErrorCode = FCB_ERR_EOF; - return FALSE; + return FCB_SUCCESS; } - - nWritten = DosWriteSft(s, lpFcb->fcb_recsiz, FcbIoPtr, nErrorCode); - - /* Now find out how we will return and do it. */ - if (nWritten == lpFcb->fcb_recsiz) + if (mode == XFR_READ && nTransfer > 0) { - lpFcb->fcb_fsize = s->sft_size; + fmemset(FcbIoPtr + nTransfer, 0, lpFcb->fcb_recsiz - nTransfer); FcbNextRecord(lpFcb); - *nErrorCode = FCB_SUCCESS; - return TRUE; + return FCB_ERR_EOF; } - else if (nWritten <= 0) - { - *nErrorCode = FCB_ERR_WRITE; - return TRUE; - } - *nErrorCode = FCB_ERR_WRITE; - return FALSE; + return FCB_ERR_NODATA; } -BOOL FcbGetFileSize(xfcb FAR * lpXfcb) +UBYTE FcbGetFileSize(xfcb FAR * lpXfcb) { COUNT FcbDrive, hndl; @@ -358,11 +299,10 @@ BOOL FcbGetFileSize(xfcb FAR * lpXfcb) lpFcb = CommonFcbInit(lpXfcb, SecPathName, &FcbDrive); /* check for a device */ - if (IsDevice(SecPathName) || (lpFcb->fcb_recsiz == 0)) - { - return FALSE; - } - hndl = DosOpen(SecPathName, O_RDONLY); + if (!lpFcb || IsDevice(SecPathName) || (lpFcb->fcb_recsiz == 0)) + return FCB_ERROR; + + hndl = (short)DosOpen(SecPathName, O_LEGACY | O_RDONLY | O_OPEN, 0); if (hndl >= 0) { ULONG fsize; @@ -376,13 +316,15 @@ BOOL FcbGetFileSize(xfcb FAR * lpXfcb) ++lpFcb->fcb_rndm; /* close the file and leave */ - return DosClose(hndl) == SUCCESS; + if ((CritErrCode = -DosClose(hndl)) == SUCCESS) + return FCB_SUCCESS; } else - return FALSE; + CritErrCode = -hndl; + return FCB_ERROR; } -BOOL FcbSetRandom(xfcb FAR * lpXfcb) +void FcbSetRandom(xfcb FAR * lpXfcb) { /* Convert to fcb if necessary */ lpFcb = ExtFcbToFcb(lpXfcb); @@ -390,11 +332,9 @@ BOOL FcbSetRandom(xfcb FAR * lpXfcb) /* Now update the fcb and compute where we need to position */ /* to. */ lpFcb->fcb_rndm = FcbRec(); - - return TRUE; } -BOOL FcbCalcRec(xfcb FAR * lpXfcb) +void FcbCalcRec(xfcb FAR * lpXfcb) { /* Convert to fcb if necessary */ @@ -404,14 +344,12 @@ BOOL FcbCalcRec(xfcb FAR * lpXfcb) /* to. */ lpFcb->fcb_cublock = lpFcb->fcb_rndm / 128; lpFcb->fcb_curec = lpFcb->fcb_rndm & 127; - - return TRUE; } -BOOL FcbRandomBlockRead(xfcb FAR * lpXfcb, COUNT nRecords, - COUNT * nErrorCode) +UBYTE FcbRandomBlockIO(xfcb FAR * lpXfcb, COUNT nRecords, int mode) { UCOUNT recno = 0; + UBYTE nErrorCode; FcbCalcRec(lpXfcb); @@ -419,39 +357,20 @@ BOOL FcbRandomBlockRead(xfcb FAR * lpXfcb, COUNT nRecords, lpFcb = ExtFcbToFcb(lpXfcb); do - FcbRead(lpXfcb, nErrorCode, recno++); - while ((--nRecords > 0) && (*nErrorCode == 0)); - - /* Now update the fcb */ - lpFcb->fcb_rndm = FcbRec(); - - return TRUE; -} - -BOOL FcbRandomBlockWrite(xfcb FAR * lpXfcb, COUNT nRecords, - COUNT * nErrorCode) -{ - UCOUNT recno = 0; - - FcbCalcRec(lpXfcb); - - /* Convert to fcb if necessary */ - lpFcb = ExtFcbToFcb(lpXfcb); - - do - FcbWrite(lpXfcb, nErrorCode, recno++); - while ((--nRecords > 0) && (*nErrorCode == 0)); + nErrorCode = FcbReadWrite(lpXfcb, recno++, mode); + while ((--nRecords > 0) && (nErrorCode == 0)); /* Now update the fcb */ lpFcb->fcb_rndm = FcbRec(); - return TRUE; + return nErrorCode; } -BOOL FcbRandomIO(xfcb FAR * lpXfcb, COUNT * nErrorCode, FcbFunc_t *FcbFunc) +UBYTE FcbRandomIO(xfcb FAR * lpXfcb, int mode) { UWORD uwCurrentBlock; UBYTE ucCurrentRecord; + UBYTE nErrorCode; FcbCalcRec(lpXfcb); @@ -461,39 +380,35 @@ BOOL FcbRandomIO(xfcb FAR * lpXfcb, COUNT * nErrorCode, FcbFunc_t *FcbFunc) uwCurrentBlock = lpFcb->fcb_cublock; ucCurrentRecord = lpFcb->fcb_curec; - (*FcbFunc) (lpXfcb, nErrorCode, 0); + nErrorCode = FcbReadWrite(lpXfcb, 0, mode); lpFcb->fcb_cublock = uwCurrentBlock; lpFcb->fcb_curec = ucCurrentRecord; - return TRUE; + return nErrorCode; } /* merged fcbOpen and FcbCreate - saves ~200 byte */ -BOOL FcbOpenCreate(xfcb FAR * lpXfcb, BOOL Create) +UBYTE FcbOpen(xfcb FAR * lpXfcb, unsigned flags) { sft FAR *sftp; COUNT sft_idx, FcbDrive; + unsigned attr = 0; /* Build a traditional DOS file name */ - lpFcb = CommonFcbInit(lpXfcb, PriPathName, &FcbDrive); + lpFcb = CommonFcbInit(lpXfcb, SecPathName, &FcbDrive); + if (lpFcb == NULL) + return FCB_ERROR; - if (Create) - { + if ((flags & O_CREAT) && lpXfcb->xfcb_flag == 0xff) /* pass attribute without constraints (dangerous for directories) */ - int attr = (lpXfcb->xfcb_flag == 0xff ? lpXfcb->xfcb_attrib : 0); - sft_idx = DosCreatSft(PriPathName, attr); - } - else - { - sft_idx = DosOpenSft(PriPathName, O_RDWR | SFT_MFCB); - - /* if file is RDONLY, try to open rdonly */ - if (sft_idx == DE_ACCESS) - sft_idx = DosOpenSft(PriPathName, O_RDONLY | SFT_MFCB); - } + attr = lpXfcb->xfcb_attrib; + sft_idx = (short)DosOpenSft(SecPathName, flags, attr); if (sft_idx < 0) - return FALSE; + { + CritErrCode = -sft_idx; + return FCB_ERROR; + } sftp = idx_to_sft(sft_idx); sftp->sft_mode |= SFT_MFCB; @@ -511,7 +426,7 @@ BOOL FcbOpenCreate(xfcb FAR * lpXfcb, BOOL Create) lpFcb->fcb_fsize = sftp->sft_size; lpFcb->fcb_date = sftp->sft_date; lpFcb->fcb_time = sftp->sft_time; - return TRUE; + return FCB_SUCCESS; } @@ -532,13 +447,14 @@ STATIC fcb FAR *CommonFcbInit(xfcb FAR * lpExtFcb, BYTE * pszBuffer, lpFcb = ExtFcbToFcb(lpExtFcb); /* Build a traditional DOS file name */ - FcbNameInit(lpFcb, pszBuffer, pCurDrive); + if (FcbNameInit(lpFcb, pszBuffer, pCurDrive) < SUCCESS) + return NULL; /* and return the fcb pointer */ return lpFcb; } -void FcbNameInit(fcb FAR * lpFcb, BYTE * szBuffer, COUNT * pCurDrive) +int FcbNameInit(fcb FAR * lpFcb, BYTE * szBuffer, COUNT * pCurDrive) { BYTE loc_szBuffer[2 + FNAME_SIZE + 1 + FEXT_SIZE + 1]; /* 'A:' + '.' + '\0' */ BYTE *pszBuffer = loc_szBuffer; @@ -556,85 +472,83 @@ void FcbNameInit(fcb FAR * lpFcb, BYTE * szBuffer, COUNT * pCurDrive) *pCurDrive = default_drive + 1; } ConvertName83ToNameSZ(pszBuffer, (BYTE FAR *) lpFcb->fcb_fname); - truename(loc_szBuffer, szBuffer, FALSE); - /* XXX fix truename error handling */ + return truename(loc_szBuffer, szBuffer, CDS_MODE_CHECK_DEV_PATH); } -BOOL FcbDelete(xfcb FAR * lpXfcb) +UBYTE FcbDelete(xfcb FAR * lpXfcb) { COUNT FcbDrive; + UBYTE result = FCB_SUCCESS; + BYTE FAR *lpOldDta = dta; /* Build a traditional DOS file name */ CommonFcbInit(lpXfcb, SecPathName, &FcbDrive); - /* check for a device */ - if (IsDevice(SecPathName)) + if (lpFcb == NULL || IsDevice(SecPathName)) { - return FALSE; + result = FCB_ERROR; } else { - int attr = (lpXfcb->xfcb_flag == 0xff ? lpXfcb->xfcb_attrib : D_ALL); - BYTE FAR *lpOldDta = dta; + int attr = (lpXfcb->xfcb_flag == 0xff ? lpXfcb->xfcb_attrib : D_ALL); dmatch Dmatch; dta = (BYTE FAR *) & Dmatch; - if (DosFindFirst(attr, SecPathName) != SUCCESS) + if ((CritErrCode = -DosFindFirst(attr, SecPathName)) != SUCCESS) { - dta = lpOldDta; - return FALSE; + result = FCB_ERROR; } - do + else do { SecPathName[0] = 'A' + FcbDrive - 1; SecPathName[1] = ':'; strcpy(&SecPathName[2], Dmatch.dm_name); if (DosDelete(SecPathName, attr) != SUCCESS) { - dta = lpOldDta; - return FALSE; + result = FCB_ERROR; + break; } } - while (DosFindNext() == SUCCESS); - dta = lpOldDta; - return TRUE; + while ((CritErrCode = -DosFindNext()) == SUCCESS); } + dta = lpOldDta; + return result; } -BOOL FcbRename(xfcb FAR * lpXfcb) +UBYTE FcbRename(xfcb FAR * lpXfcb) { rfcb FAR *lpRenameFcb; COUNT FcbDrive; + UBYTE result = FCB_SUCCESS; + BYTE FAR *lpOldDta = dta; /* Build a traditional DOS file name */ lpRenameFcb = (rfcb FAR *) CommonFcbInit(lpXfcb, SecPathName, &FcbDrive); - wAttr = (lpXfcb->xfcb_flag == 0xff ? lpXfcb->xfcb_attrib : D_ALL); - + /* check for a device */ - if (IsDevice(SecPathName)) + if (lpRenameFcb == NULL || IsDevice(SecPathName)) { - return FALSE; + result = FCB_ERROR; } else { - BYTE FAR *lpOldDta = dta; dmatch Dmatch; + COUNT result; + wAttr = (lpXfcb->xfcb_flag == 0xff ? lpXfcb->xfcb_attrib : D_ALL); dta = (BYTE FAR *) & Dmatch; - if (DosFindFirst(wAttr, SecPathName) != SUCCESS) + if ((CritErrCode = -DosFindFirst(wAttr, SecPathName)) != SUCCESS) { - dta = lpOldDta; - return FALSE; + result = FCB_ERROR; } - - do + else do { fcb LocalFcb; BYTE *pToName; const BYTE FAR *pFromPattern = Dmatch.dm_name; - int i; + int i = 0; - FcbParseFname(0, &pFromPattern, &LocalFcb); + FcbParseFname(&i, pFromPattern, &LocalFcb); /* Overlay the pattern, skipping '?' */ /* I'm cheating because this assumes that the */ /* struct alignments are on byte boundaries */ @@ -651,22 +565,32 @@ BOOL FcbRename(xfcb FAR * lpXfcb) SecPathName[0] = 'A' + FcbDrive - 1; SecPathName[1] = ':'; strcpy(&SecPathName[2], Dmatch.dm_name); - truename(SecPathName, PriPathName, FALSE); + result = truename(SecPathName, PriPathName, 0); + if (result < SUCCESS || (result & IS_DEVICE)) + { + result = FCB_ERROR; + break; + } /* now to build a dos name again */ LocalFcb.fcb_drive = FcbDrive; - FcbNameInit((fcb FAR *) & LocalFcb, SecPathName, &FcbDrive); + result = FcbNameInit((fcb FAR *) & LocalFcb, SecPathName, &FcbDrive); + if (result < SUCCESS || (!(result & IS_NETWORK) && (result & IS_DEVICE))) + { + result = FCB_ERROR; + break; + } if (DosRenameTrue(PriPathName, SecPathName, wAttr) != SUCCESS) { - dta = lpOldDta; - return FALSE; + result = FCB_ERROR; + break; } } - while (DosFindNext() == SUCCESS); - dta = lpOldDta; - return TRUE; + while ((CritErrCode = -DosFindNext()) == SUCCESS); } + dta = lpOldDta; + return result; } /* TE:the MoveDirInfo() is now done by simply copying the dirEntry into the FCB @@ -674,7 +598,7 @@ BOOL FcbRename(xfcb FAR * lpXfcb) BO:use global SearchDir, as produced by FindFirst/Next */ -BOOL FcbClose(xfcb FAR * lpXfcb) +UBYTE FcbClose(xfcb FAR * lpXfcb) { sft FAR *s; @@ -683,23 +607,23 @@ BOOL FcbClose(xfcb FAR * lpXfcb) /* An already closed FCB can be closed again without error */ if (lpFcb->fcb_sftno == (BYTE) 0xff) - return TRUE; + return FCB_SUCCESS; /* Get the SFT block that contains the SFT */ if ((s = idx_to_sft(lpFcb->fcb_sftno)) == (sft FAR *) - 1) - return FALSE; + return FCB_ERROR; /* change time and set file size */ s->sft_size = lpFcb->fcb_fsize; if (!(s->sft_flags & SFT_FSHARED)) dos_setfsize(s->sft_status, lpFcb->fcb_fsize); DosSetFtimeSft(lpFcb->fcb_sftno, lpFcb->fcb_date, lpFcb->fcb_time); - if (DosCloseSft(lpFcb->fcb_sftno, FALSE) == SUCCESS) + if ((CritErrCode = -DosCloseSft(lpFcb->fcb_sftno, FALSE)) == SUCCESS) { lpFcb->fcb_sftno = (BYTE) 0xff; - return TRUE; + return FCB_SUCCESS; } - return FALSE; + return FCB_ERROR; } /* close all files the current process opened by FCBs */ @@ -713,57 +637,7 @@ VOID FcbCloseAll() DosCloseSft(idx, FALSE); } -BOOL FcbFindFirst(xfcb FAR * lpXfcb) -{ - BYTE FAR *lpDir; - COUNT FcbDrive; - psp FAR *lpPsp = MK_FP(cu_psp, 0); - - /* First, move the dta to a local and change it around to match */ - /* our functions. */ - lpDir = (BYTE FAR *) dta; - dta = (BYTE FAR *) & Dmatch; - - /* Next initialze local variables by moving them from the fcb */ - lpFcb = CommonFcbInit(lpXfcb, SecPathName, &FcbDrive); - if (lpXfcb->xfcb_flag == 0xff) - { - wAttr = lpXfcb->xfcb_attrib; - fmemcpy(lpDir, lpXfcb, 7); - lpDir += 7; - } - else - wAttr = D_ALL; - - if (DosFindFirst(wAttr, SecPathName) != SUCCESS) - { - dta = lpPsp->ps_dta; - return FALSE; - } - - *lpDir++ = FcbDrive; - fmemcpy(lpDir, &SearchDir, sizeof(struct dirent)); - - lpFcb->fcb_dirclst = (UWORD) Dmatch.dm_dircluster; - lpFcb->fcb_strtclst = Dmatch.dm_entry; - -/* - This is undocumented and seen using Pcwatch and Ramview. - The First byte is the current directory count and the second seems - to be the attribute byte. - */ - lpFcb->fcb_sftno = Dmatch.dm_drive; /* MSD seems to save this @ fcb_date. */ -#if 0 - lpFcb->fcb_cublock = Dmatch.dm_entry; - lpFcb->fcb_cublock *= 0x100; - lpFcb->fcb_cublock += wAttr; -#endif - - dta = lpPsp->ps_dta; - return TRUE; -} - -BOOL FcbFindNext(xfcb FAR * lpXfcb) +UBYTE FcbFindFirstNext(xfcb FAR * lpXfcb, BOOL First) { BYTE FAR *lpDir; COUNT FcbDrive; @@ -776,48 +650,54 @@ BOOL FcbFindNext(xfcb FAR * lpXfcb) /* Next initialze local variables by moving them from the fcb */ lpFcb = CommonFcbInit(lpXfcb, SecPathName, &FcbDrive); + if (lpFcb == NULL) + return FCB_ERROR; - /* Reconstrct the dirmatch structure from the fcb */ + /* Reconstrct the dirmatch structure from the fcb - doesn't hurt for first */ Dmatch.dm_drive = lpFcb->fcb_sftno; fmemcpy(Dmatch.dm_name_pat, lpFcb->fcb_fname, FNAME_SIZE + FEXT_SIZE); DosUpFMem((BYTE FAR *) Dmatch.dm_name_pat, FNAME_SIZE + FEXT_SIZE); - + Dmatch.dm_attr_srch = wAttr; Dmatch.dm_entry = lpFcb->fcb_strtclst; Dmatch.dm_dircluster = lpFcb->fcb_dirclst; + wAttr = D_ALL; + if ((xfcb FAR *) lpFcb != lpXfcb) { wAttr = lpXfcb->xfcb_attrib; fmemcpy(lpDir, lpXfcb, 7); lpDir += 7; } - else - wAttr = D_ALL; - if (DosFindNext() != SUCCESS) + CritErrCode = -(First ? DosFindFirst(wAttr, SecPathName) : DosFindNext()); + if (CritErrCode != SUCCESS) { dta = lpPsp->ps_dta; - CritErrCode = 0x12; - return FALSE; + return FCB_ERROR; } *lpDir++ = FcbDrive; - fmemcpy((struct dirent FAR *)lpDir, &SearchDir, sizeof(struct dirent)); - + fmemcpy(lpDir, &SearchDir, sizeof(struct dirent)); + lpFcb->fcb_dirclst = (UWORD) Dmatch.dm_dircluster; lpFcb->fcb_strtclst = Dmatch.dm_entry; - - lpFcb->fcb_sftno = Dmatch.dm_drive; + +/* + This is undocumented and seen using Pcwatch and Ramview. + The First byte is the current directory count and the second seems + to be the attribute byte. + */ + lpFcb->fcb_sftno = Dmatch.dm_drive; /* MSD seems to save this @ fcb_date. */ #if 0 lpFcb->fcb_cublock = Dmatch.dm_entry; lpFcb->fcb_cublock *= 0x100; lpFcb->fcb_cublock += wAttr; #endif - dta = lpPsp->ps_dta; - return TRUE; + return FCB_SUCCESS; } #endif diff --git a/kernel/globals.h b/kernel/globals.h index e753166d..91891e38 100644 --- a/kernel/globals.h +++ b/kernel/globals.h @@ -307,15 +307,7 @@ extern struct /* Path name parsing buffer */ BYTE _PriPathName[128]; } ASM _PriPathBuffer; -extern struct { - BYTE _fname[FNAME_SIZE]; - BYTE _fext[FEXT_SIZE + 1]; /* space for 0 */ -} ASM szNames; - #define PriPathName _PriPathBuffer._PriPathName -#define szDirName TempCDS.cdsCurrentPath -#define szFileName szNames._fname -#define szFileExt szNames._fext extern struct /* Alternate path name parsing buffer */ { @@ -440,25 +432,15 @@ COUNT con(); #define fputword(vp, w) (*(UWORD FAR *)(vp)=w) #define fputbyte(vp, b) (*(UBYTE FAR *)(vp)=b) #else -#ifdef PROTO -WORD getword(VOID *); -BYTE getbyte(VOID *); -LONG fgetlong(VOID FAR *); -WORD fgetword(VOID FAR *); -BYTE fgetbyte(VOID FAR *); +UDWORD getlong(VOID *); +UWORD getword(VOID *); +UBYTE getbyte(VOID *); +UDWORD fgetlong(VOID FAR *); +UWORD fgetword(VOID FAR *); +UBYTE fgetbyte(VOID FAR *); VOID fputlong(VOID FAR *, UDWORD); VOID fputword(VOID FAR *, UWORD); VOID fputbyte(VOID FAR *, UBYTE); -#else -VOID getword(); -VOID getbyte(); -VOID fgetlong(); -VOID fgetword(); -VOID fgetbyte(); -VOID fputlong(); -VOID fputword(); -VOID fputbyte(); -#endif #endif #ifdef I86 diff --git a/kernel/init-dat.h b/kernel/init-dat.h index e51d1df5..d9ae9b60 100644 --- a/kernel/init-dat.h +++ b/kernel/init-dat.h @@ -20,7 +20,13 @@ extern __segment DosTextSeg; #define DOSFAR FAR #define DOSTEXTFAR FAR +#elif !defined(I86) + +#define DOSFAR +#define DOSTEXTFAR + #else + #pragma error("unknown compiler - please adjust") this should simply not compile ! ! #endif diff --git a/kernel/int2f.asm b/kernel/int2f.asm index 112f5404..cc336596 100644 --- a/kernel/int2f.asm +++ b/kernel/int2f.asm @@ -106,7 +106,7 @@ IntDosCal: ; UWORD ip,cs,flags; ; UWORD callerARG1; ;}; - Protect386Registers + Protect386Registers push ax push cx push dx @@ -131,7 +131,7 @@ IntDosCal: pop dx pop cx pop ax - Restore386Registers + Restore386Registers iret @@ -255,6 +255,11 @@ _QRemote_Fn global _remote_printredir _remote_printredir: mov al, 25h + jmp short call_int2f + + global _remote_extopen +_remote_extopen: + mov al, 2eh call_int2f: mov ah, 11h @@ -263,7 +268,6 @@ call_int2f: push es push si push di - push dx push cx push bx @@ -275,10 +279,6 @@ call_int2f: je print_doredir cmp al, 1fh je print_doredir - cmp al, 21h ; 21h, Lseek from eof - je lseekeof - cmp al, 23h - je qremote_fn cmp al, 25h je remote_printredir @@ -289,22 +289,27 @@ call_int2f: je remote_rw cmp al, 0ch je remote_getfree + cmp al, 21h ; 21h, Lseek from eof + je lseekeof + cmp al, 23h + je qremote_fn int2f_call_push: push word [bp+8] ; very fakey, HaHa ;) int2f_call: - clc ; set to succeed + xor cx, cx ; set to succeed; clear carry and CX int 2fh pop bx jc no_clear_ax clear_ax: - xor ax,ax + mov ax, cx ; extended open -> status from CX in AX + ; otherwise CX was set to zero above + jmp short no_neg_ax no_clear_ax: neg ax no_neg_ax: pop bx pop cx - pop dx pop di pop si pop es @@ -314,8 +319,8 @@ no_neg_ax: lseekeof: mov dx, [bp+8] mov cx, [bp+10] - jmp int2f_call_push - + ; "fall through" + remote_getfattr: clc ; set to succeed int 2fh @@ -358,17 +363,20 @@ remote_printredir: mov dx, [bp+4] push word [bp+6] jmp short int2f_call + +remote_rw: jmp short remote_rw1 -qremote_fn: - lds si,[bp+4] - les di,[bp+8] +qremote_fn: + push ds + lds si,[bp+8] clc int 2fh + pop ds mov ax,0xffff jc no_neg_ax jmp short clear_ax -remote_rw: mov cx, [bp+8] +remote_rw1: mov cx, [bp+8] clc ; set to succeed int 2fh jc int2f_carry @@ -377,7 +385,7 @@ int2f_carry: neg ax mov di, [bp+10] mov [di], ax mov ax, cx - jmp short no_neg_ax + jmp no_neg_ax global _remote_process_end _remote_process_end: ; Terminate process diff --git a/kernel/inthndlr.c b/kernel/inthndlr.c index bbcfff3f..d33ab91e 100644 --- a/kernel/inthndlr.c +++ b/kernel/inthndlr.c @@ -30,6 +30,7 @@ #include "portab.h" #include "globals.h" +#include "nls.h" #ifdef VERSION_STRINGS BYTE *RcsId = @@ -58,10 +59,6 @@ struct HugeSectorBlock { BYTE FAR *buf; }; -/* must be global/file scope, Turbo C uses the wrong segment for - * function scope */ -STATIC const char dbcsTable[] = {0, 0, 0, 0}; - /* Normal entry. This minimizes user stack usage by avoiding local */ /* variables needed for the rest of the handler. */ /* this here works on the users stack !! and only very few functions @@ -156,17 +153,237 @@ VOID ASMCFUNC int21_syscall(iregs FAR * irp) } } +#ifdef WITHFAT32 + /* DOS 7.0+ FAT32 extended functions */ +int int21_fat32(lregs *r) +{ + COUNT rc; + + switch (r->AL) + { + /* Get extended drive parameter block */ + case 0x02: + { + struct dpb FAR *dpb; + struct xdpbdata FAR *xddp; + + if (r->CX < sizeof(struct xdpbdata)) + return DE_INVLDBUF; + + dpb = GetDriveDPB(r->DL, &rc); + if (rc != SUCCESS) + return rc; + + /* hazard: no error checking! */ + flush_buffers(dpb->dpb_unit); + dpb->dpb_flags = M_CHANGED; /* force reread of drive BPB/DPB */ + + if (media_check(dpb) < 0) + return DE_INVLDDRV; + + xddp = MK_FP(r->ES, r->DI); + + fmemcpy(&xddp->xdd_dpb, dpb, sizeof(struct dpb)); + xddp->xdd_dpbsize = sizeof(struct dpb); + break; + } + /* Get extended free drive space */ + case 0x03: + { + struct xfreespace FAR *xfsp = MK_FP(r->ES, r->DI); + + if (r->CX < sizeof(struct xfreespace)) + return DE_INVLDBUF; + + rc = DosGetExtFree(MK_FP(r->DS, r->DX), xfsp); + if (rc != SUCCESS) + return rc; + xfsp->xfs_datasize = sizeof(struct xfreespace); + xfsp->xfs_version.actual = 0; + break; + } + /* Set DPB to use for formatting */ + case 0x04: + { + struct xdpbforformat FAR *xdffp = MK_FP(r->ES, r->DI); + struct dpb FAR *dpb; + if (r->CX < sizeof(struct xdpbforformat)) + { + return DE_INVLDBUF; + } + dpb = GetDriveDPB(r->DL, &rc); + if (rc != SUCCESS) + return rc; + + xdffp->xdff_datasize = sizeof(struct xdpbforformat); + xdffp->xdff_version.actual = 0; + + switch ((UWORD) xdffp->xdff_function) + { + case 0x00: + { + DWORD nfreeclst = xdffp->xdff_f.setdpbcounts.nfreeclst; + DWORD cluster = xdffp->xdff_f.setdpbcounts.cluster; + if (ISFAT32(dpb)) + { + if ((dpb->dpb_xfsinfosec == 0xffff + && (nfreeclst != 0 || cluster != 0)) + || nfreeclst == 1 || nfreeclst > dpb->dpb_xsize + || cluster == 1 || cluster > dpb->dpb_xsize) + { + return DE_INVLDPARM; + } + dpb->dpb_xnfreeclst = nfreeclst; + dpb->dpb_xcluster = cluster; + write_fsinfo(dpb); + } + else + { + if (nfreeclst == 1 || nfreeclst > dpb->dpb_size || + cluster == 1 || cluster > dpb->dpb_size) + { + return DE_INVLDPARM; + } + dpb->dpb_nfreeclst = nfreeclst; + dpb->dpb_cluster = cluster; + } + break; + } + case 0x01: + { + ddt *pddt = getddt(r->DL); + fmemcpy(&pddt->ddt_bpb, xdffp->xdff_f.rebuilddpb.bpbp, + sizeof(bpb)); + } + case 0x02: + { + rebuild_dpb: + /* hazard: no error checking! */ + flush_buffers(dpb->dpb_unit); + dpb->dpb_flags = M_CHANGED; + + if (media_check(dpb) < 0) + return DE_INVLDDRV; + break; + } + case 0x03: + { + struct buffer FAR *bp; + bpb FAR *bpbp; + DWORD newmirroring = + xdffp->xdff_f.setmirroring.newmirroring; + + if (newmirroring != -1 + && (ISFAT32(dpb) + && (newmirroring & ~(0xf | 0x80)))) + { + return DE_INVLDPARM; + } + xdffp->xdff_f.setmirroring.oldmirroring = + (ISFAT32(dpb) ? dpb->dpb_xflags : 0); + if (newmirroring != -1 && ISFAT32(dpb)) + { + bp = getblock(1, dpb->dpb_unit); + bp->b_flag &= ~(BFR_DATA | BFR_DIR | BFR_FAT); + bp->b_flag |= BFR_VALID | BFR_DIRTY; + bpbp = (bpb FAR *) & bp->b_buffer[BT_BPB]; + bpbp->bpb_xflags = newmirroring; + } + goto rebuild_dpb; + } + case 0x04: + { + struct buffer FAR *bp; + bpb FAR *bpbp; + DWORD rootclst = xdffp->xdff_f.setroot.newrootclst; + if (!ISFAT32(dpb) + || (rootclst != -1 + && (rootclst == 1 + || rootclst > dpb->dpb_xsize))) + { + return DE_INVLDPARM; + } + xdffp->xdff_f.setroot.oldrootclst = dpb->dpb_xrootclst; + if (rootclst != -1) + { + bp = getblock(1, dpb->dpb_unit); + bp->b_flag &= ~(BFR_DATA | BFR_DIR | BFR_FAT); + bp->b_flag |= BFR_VALID | BFR_DIRTY; + bpbp = (bpb FAR *) & bp->b_buffer[BT_BPB]; + bpbp->bpb_xrootclst = rootclst; + } + goto rebuild_dpb; + } + } + + break; + } + /* Extended absolute disk read/write */ + /* TODO(vlp) consider using of the 13-14th bits of SI */ + case 0x05: + { + struct HugeSectorBlock FAR *SectorBlock = + (struct HugeSectorBlock FAR *)MK_FP(r->DS, r->BX); + UBYTE mode; + + if (r->CX != 0xffff || ((r->SI & 1) == 0 && r->SI != 0) + || (r->SI & ~0x6001)) + { + return DE_INVLDPARM; + } + + if (r->DL - 1 >= lastdrive || r->DL == 0) + return -0x207; + + if (r->SI == 0) + mode = DSKREADINT25; + else + mode = DSKWRITEINT26; + + r->AX = + dskxfer(r->DL - 1, SectorBlock->blkno, SectorBlock->buf, + SectorBlock->nblks, mode); + + if (mode == DSKWRITEINT26) + if (r->AX <= 0) + setinvld(r->DL - 1); + + if (r->AX > 0) + return -0x20c; + break; + } + default: + return DE_INVLDFUNC; + } + return SUCCESS; +} +#endif + VOID ASMCFUNC int21_service(iregs FAR * r) { COUNT rc = 0; - void FAR *FP_DS_DX = MK_FP(r->DS, r->DX); /* this is saved so often, - that this saves ~100 bytes */ + lregs lr; /* 8 local registers (ax, bx, cx, dx, si, di, ds, es) */ + +#define FP_DS_DX (MK_FP(lr.DS, lr.DX)) +#define FP_ES_DI (MK_FP(lr.ES, lr.DI)) + #define CLEAR_CARRY_FLAG() r->FLAGS &= ~FLG_CARRY #define SET_CARRY_FLAG() r->FLAGS |= FLG_CARRY ((psp FAR *) MK_FP(cu_psp, 0))->ps_stack = (BYTE FAR *) r; + lr.AX = r->AX; + lr.BX = r->BX; + lr.CX = r->CX; + lr.DX = r->DX; + lr.SI = r->SI; + lr.DI = r->DI; + lr.DS = r->DS; + lr.ES = r->ES; + +dispatch: + #ifdef DEBUG if (bDumpRegs) { @@ -177,14 +394,13 @@ VOID ASMCFUNC int21_service(iregs FAR * r) } #endif - if (r->AH >= 0x38 && r->AH <= 0x4F) + if ((lr.AH >= 0x38 && lr.AH <= 0x4F) || (lr.AH >= 0x56 && lr.AH <= 0x5c)) CLEAR_CARRY_FLAG(); /* Clear carry by default for these functions */ -dispatch: /* Check for Ctrl-Break */ - switch (r->AH) + switch (lr.AH) { default: if (!break_ena) @@ -203,94 +419,78 @@ VOID ASMCFUNC int21_service(iregs FAR * r) } /* The dispatch handler */ - switch (r->AH) + switch (lr.AH) { /* int 21h common error handler */ case 0x64: - error_invalid: - r->AX = -DE_INVLDFUNC; - goto error_out; - error_exit: - r->AX = -rc; - error_out: - CritErrCode = r->AX; /* Maybe set */ - SET_CARRY_FLAG(); - break; + goto error_invalid; /* case 0x00: --> Simulate a DOS-4C-00 */ /* Read Keyboard with Echo */ case 0x01: - r->AL = _sti(TRUE); - sto(r->AL); + lr.AL = _sti(TRUE); + sto(lr.AL); break; /* Display Character */ case 0x02: - sto(r->DL); + sto(lr.DL); break; /* Auxiliary Input */ case 0x03: - { - COUNT scratch; - GenericRead(STDAUX, 1, (BYTE FAR *) & r->AL, - (COUNT FAR *) & scratch, TRUE); - break; - } + BinaryRead(STDAUX, &lr.AL, &UnusedRetVal); + break; /* Auxiliary Output */ case 0x04: - { - COUNT scratch; - DosWrite(STDAUX, 1, (BYTE FAR *) & r->DL, (COUNT FAR *) & scratch); - break; - } + DosWrite(STDAUX, 1, (BYTE FAR *) & lr.DL, & UnusedRetVal); + break; /* Print Character */ case 0x05: - { - COUNT scratch; - DosWrite(STDPRN, 1, (BYTE FAR *) & r->DL, (COUNT FAR *) & scratch); - break; - } + DosWrite(STDPRN, 1, (BYTE FAR *) & lr.DL, & UnusedRetVal); + break; /* Direct Console I/O */ case 0x06: - if (r->DL != 0xff) - sto(r->DL); + if (lr.DL != 0xff) + sto(lr.DL); else if (StdinBusy()) { - r->AL = 0x00; + lr.AL = 0x00; r->FLAGS |= FLG_ZERO; } else { r->FLAGS &= ~FLG_ZERO; - r->AL = _sti(FALSE); + lr.AL = _sti(FALSE); } break; /* Direct Console Input */ case 0x07: - r->AL = _sti(FALSE); + lr.AL = _sti(FALSE); break; /* Read Keyboard Without Echo */ case 0x08: - r->AL = _sti(TRUE); + lr.AL = _sti(TRUE); break; /* Display String */ case 0x09: - { - BYTE FAR *q; - q = FP_DS_DX; - while (*q != '$') - ++q; - DosWrite(STDOUT, FP_OFF(q) - FP_OFF(FP_DS_DX), FP_DS_DX, - (COUNT FAR *) & UnusedRetVal); + { + unsigned count; + + for (count = 0; ; count++) + if (((UBYTE FAR *)FP_DS_DX)[count] == '$') + break; + + DosWrite(STDOUT, count, FP_DS_DX, + & UnusedRetVal); } - r->AL = '$'; + lr.AL = '$'; break; /* Buffered Keyboard Input */ @@ -301,26 +501,26 @@ VOID ASMCFUNC int21_service(iregs FAR * r) /* Check Stdin Status */ case 0x0b: if (StdinBusy()) - r->AL = 0x00; + lr.AL = 0x00; else - r->AL = 0xFF; + lr.AL = 0xFF; break; /* Flush Buffer, Read Keayboard */ case 0x0c: KbdFlush(); - switch (r->AL) + switch (lr.AL) { case 0x01: case 0x06: case 0x07: case 0x08: case 0x0a: - r->AH = r->AL; + lr.AH = lr.AL; goto dispatch; default: - r->AL = 0x00; + lr.AL = 0x00; break; } break; @@ -332,79 +532,50 @@ VOID ASMCFUNC int21_service(iregs FAR * r) /* Set Default Drive */ case 0x0e: - r->AL = DosSelectDrv(r->DL); + lr.AL = DosSelectDrv(lr.DL); break; case 0x0f: - if (FcbOpen(FP_DS_DX)) - r->AL = 0; - else - r->AL = 0xff; + lr.AL = FcbOpen(FP_DS_DX, O_FCB | O_LEGACY | O_OPEN | O_RDWR); break; case 0x10: - if (FcbClose(FP_DS_DX)) - r->AL = 0; - else - r->AL = 0xff; + lr.AL = FcbClose(FP_DS_DX); break; case 0x11: - if (FcbFindFirst(FP_DS_DX)) - r->AL = 0; - else - r->AL = 0xff; + lr.AL = FcbFindFirstNext(FP_DS_DX, TRUE); break; case 0x12: - if (FcbFindNext(FP_DS_DX)) - r->AL = 0; - else - r->AL = 0xff; + lr.AL = FcbFindFirstNext(FP_DS_DX, FALSE); break; case 0x13: - if (FcbDelete(FP_DS_DX)) - r->AL = 0; - else - r->AL = 0xff; + lr.AL = FcbDelete(FP_DS_DX); break; case 0x14: - { - if (FcbRead(FP_DS_DX, &CritErrCode, 0)) - r->AL = 0; - else - r->AL = CritErrCode; - break; - } + /* FCB read */ + lr.AL = FcbReadWrite(FP_DS_DX, 0, XFR_READ); + break; case 0x15: - { - if (FcbWrite(FP_DS_DX, &CritErrCode, 0)) - r->AL = 0; - else - r->AL = CritErrCode; - break; - } + /* FCB write */ + lr.AL = FcbReadWrite(FP_DS_DX, 0, XFR_WRITE); + break; case 0x16: - if (FcbCreate(FP_DS_DX)) - r->AL = 0; - else - r->AL = 0xff; + lr.AL = FcbOpen(FP_DS_DX, O_FCB | O_LEGACY | O_CREAT | O_TRUNC | O_RDWR); break; case 0x17: - if (FcbRename(FP_DS_DX)) - r->AL = 0; - else - r->AL = 0xff; + lr.AL = FcbRename(FP_DS_DX); break; default: #ifdef DEBUG - printf("Unsupported INT21 AH = 0x%x, AL = 0x%x.\n", r->AH, r->AL); + printf("Unsupported INT21 AH = 0x%x, AL = 0x%x.\n", lr.AH, lr.AL); #endif /* Fall through. */ @@ -417,12 +588,12 @@ VOID ASMCFUNC int21_service(iregs FAR * r) case 0x61: #endif case 0x6b: - r->AL = 0; + lr.AL = 0; break; /* Get Default Drive */ case 0x19: - r->AL = default_drive; + lr.AL = default_drive; break; /* Set DTA */ @@ -437,29 +608,20 @@ VOID ASMCFUNC int21_service(iregs FAR * r) /* Get Default Drive Data */ case 0x1b: - { - BYTE FAR *p; - - FatGetDrvData(0, - (UCOUNT FAR *) & r->AX, - (UCOUNT FAR *) & r->CX, - (UCOUNT FAR *) & r->DX, (BYTE FAR **) & p); - r->DS = FP_SEG(p); - r->BX = FP_OFF(p); - } - break; + lr.DL = 0; + /* fall through */ /* Get Drive Data */ case 0x1c: { BYTE FAR *p; - FatGetDrvData(r->DL, - (UCOUNT FAR *) & r->AX, - (UCOUNT FAR *) & r->CX, - (UCOUNT FAR *) & r->DX, (BYTE FAR **) & p); - r->DS = FP_SEG(p); - r->BX = FP_OFF(p); + p = FatGetDrvData(lr.DL, &lr.AX, &lr.CX, &lr.DX); + lr.DS = FP_SEG(p); + lr.BX = FP_OFF(p); + lr.CX = lr.CX; + lr.DX = lr.DX; + lr.AX = lr.AX; } break; @@ -468,30 +630,17 @@ VOID ASMCFUNC int21_service(iregs FAR * r) /* Random read using FCB */ case 0x21: - { - if (FcbRandomIO(FP_DS_DX, &CritErrCode, FcbRead)) - r->AL = 0; - else - r->AL = CritErrCode; - break; - } + lr.AL = FcbRandomIO(FP_DS_DX, XFR_READ); + break; /* Random write using FCB */ case 0x22: - { - if (FcbRandomIO(FP_DS_DX, &CritErrCode, FcbWrite)) - r->AL = 0; - else - r->AL = CritErrCode; - break; - } + lr.AL = FcbRandomIO(FP_DS_DX, XFR_WRITE); + break; /* Get file size in records using FCB */ case 0x23: - if (FcbGetFileSize(FP_DS_DX)) - r->AL = 0; - else - r->AL = 0xff; + lr.AL = FcbGetFileSize(FP_DS_DX); break; /* Set random record field in FCB */ @@ -501,7 +650,7 @@ VOID ASMCFUNC int21_service(iregs FAR * r) /* Set Interrupt Vector */ case 0x25: - setvec(r->AL, FP_DS_DX); + setvec(lr.AL, FP_DS_DX); break; /* Dos Create New Psp */ @@ -509,92 +658,81 @@ VOID ASMCFUNC int21_service(iregs FAR * r) { psp FAR *p = MK_FP(cu_psp, 0); - new_psp((psp FAR *) MK_FP(r->DX, 0), p->ps_size); + new_psp((psp FAR *) MK_FP(lr.DX, 0), p->ps_size); } break; /* Read random record(s) using FCB */ case 0x27: - { - if (FcbRandomBlockRead(FP_DS_DX, r->CX, &CritErrCode)) - r->AL = 0; - else - r->AL = CritErrCode; - break; - } + lr.AL = FcbRandomBlockIO(FP_DS_DX, lr.CX, XFR_READ); + break; /* Write random record(s) using FCB */ case 0x28: - { - if (FcbRandomBlockWrite(FP_DS_DX, r->CX, &CritErrCode)) - r->AL = 0; - else - r->AL = CritErrCode; - break; - } + lr.AL = FcbRandomBlockIO(FP_DS_DX, lr.CX, XFR_WRITE); + break; /* Parse File Name */ case 0x29: { - const BYTE FAR *lpFileName = MK_FP(r->DS, r->SI); - r->AL = FcbParseFname(r->AL, &lpFileName, MK_FP(r->ES, r->DI)); - r->DS = FP_SEG(lpFileName); - r->SI = FP_OFF(lpFileName); + UWORD offset = FcbParseFname(&rc, MK_FP(lr.DS, lr.SI), FP_ES_DI); + lr.AL = rc; + lr.SI += offset; } break; /* Get Date */ case 0x2a: - DosGetDate((BYTE FAR *) & (r->AL), /* WeekDay */ - (BYTE FAR *) & (r->DH), /* Month */ - (BYTE FAR *) & (r->DL), /* MonthDay */ - (COUNT FAR *) & (r->CX)); /* Year */ + DosGetDate(&lr.AL, /* WeekDay */ + &lr.DH, /* Month */ + &lr.DL, /* MonthDay */ + &lr.CX); /* Year */ break; /* Set Date */ case 0x2b: - rc = DosSetDate(r->DH, /* Month */ - r->DL, /* MonthDay */ - r->CX); /* Year */ - r->AL = (rc != SUCCESS ? 0xff : 0); + rc = DosSetDate(lr.DH, /* Month */ + lr.DL, /* MonthDay */ + lr.CX); /* Year */ + lr.AL = (rc != SUCCESS ? 0xff : 0); break; /* Get Time */ case 0x2c: - DosGetTime((BYTE FAR *) & (r->CH), /* Hour */ - (BYTE FAR *) & (r->CL), /* Minutes */ - (BYTE FAR *) & (r->DH), /* Seconds */ - (BYTE FAR *) & (r->DL)); /* Hundredths */ + DosGetTime(&lr.CH, /* Hour */ + &lr.CL, /* Minutes */ + &lr.DH, /* Seconds */ + &lr.DL); /* Hundredths */ break; /* Set Date */ case 0x2d: - rc = DosSetTime(r->CH, /* Hour */ - r->CL, /* Minutes */ - r->DH, /* Seconds */ - r->DL); /* Hundredths */ - r->AL = (rc != SUCCESS ? 0xff : 0); + rc = DosSetTime(lr.CH, /* Hour */ + lr.CL, /* Minutes */ + lr.DH, /* Seconds */ + lr.DL); /* Hundredths */ + lr.AL = (rc != SUCCESS ? 0xff : 0); break; /* Set verify flag */ case 0x2e: - verify_ena = (r->AL ? TRUE : FALSE); + verify_ena = (lr.AL ? TRUE : FALSE); break; /* Get DTA */ case 0x2f: - r->ES = FP_SEG(dta); - r->BX = FP_OFF(dta); + lr.ES = FP_SEG(dta); + lr.BX = FP_OFF(dta); break; /* Get DOS Version */ case 0x30: - r->AL = os_major; - r->AH = os_minor; - r->BH = OEM_ID; - r->CH = REVISION_MAJOR; /* JPP */ - r->CL = REVISION_MINOR; - r->BL = REVISION_SEQ; + lr.AL = os_major; + lr.AH = os_minor; + lr.BH = OEM_ID; + lr.CH = REVISION_MAJOR; /* JPP */ + lr.CL = REVISION_MINOR; + lr.BL = REVISION_SEQ; if (ReturnAnyDosVersionExpected) { @@ -609,15 +747,15 @@ VOID ASMCFUNC int21_service(iregs FAR * r) if (retp[0] == 0x3d && /* cmp ax, xxyy */ (retp[3] == 0x75 || retp[3] == 0x74)) /* je/jne error */ { - r->AL = retp[1]; - r->AH = retp[2]; + lr.AL = retp[1]; + lr.AH = retp[2]; } else if (retp[0] == 0x86 && /* xchg al,ah */ retp[1] == 0xc4 && retp[2] == 0x3d && /* cmp ax, xxyy */ (retp[5] == 0x75 || retp[5] == 0x74)) /* je/jne error */ { - r->AL = retp[4]; - r->AH = retp[3]; + lr.AL = retp[4]; + lr.AH = retp[3]; } } @@ -626,9 +764,9 @@ VOID ASMCFUNC int21_service(iregs FAR * r) /* Keep Program (Terminate and stay resident) */ case 0x31: - DosMemChange(cu_psp, r->DX < 6 ? 6 : r->DX, 0); + DosMemChange(cu_psp, lr.DX < 6 ? 6 : lr.DX, 0); return_mode = 3; - return_code = r->AL; + return_code = lr.AL; tsr = TRUE; return_user(); break; @@ -641,16 +779,16 @@ VOID ASMCFUNC int21_service(iregs FAR * r) /* INT21/32 is documented to reread the DPB */ { struct dpb FAR *dpb; - UCOUNT drv = r->DL; + UCOUNT drv = lr.DL; - if (drv == 0 || r->AH == 0x1f) + if (drv == 0 || lr.AH == 0x1f) drv = default_drive; else drv--; if (drv >= lastdrive) { - r->AL = 0xFF; + lr.AL = 0xFF; CritErrCode = 0x0f; break; } @@ -658,10 +796,11 @@ VOID ASMCFUNC int21_service(iregs FAR * r) dpb = CDSp[drv].cdsDpb; if (dpb == 0 || CDSp[drv].cdsFlags & CDSNETWDRV) { - r->AL = 0xFF; + lr.AL = 0xFF; CritErrCode = 0x0f; break; } + /* hazard: no error checking! */ flush_buffers(dpb->dpb_unit); dpb->dpb_flags = M_CHANGED; /* force flush and reread of drive BPB/DPB */ @@ -671,13 +810,13 @@ VOID ASMCFUNC int21_service(iregs FAR * r) if (media_check(dpb) < 0) #endif { - r->AL = 0xff; + lr.AL = 0xff; CritErrCode = 0x0f; break; } - r->DS = FP_SEG(dpb); - r->BX = FP_OFF(dpb); - r->AL = 0; + lr.DS = FP_SEG(dpb); + lr.BX = FP_OFF(dpb); + lr.AL = 0; } break; @@ -687,46 +826,38 @@ VOID ASMCFUNC int21_service(iregs FAR * r) */ /* Get InDOS flag */ case 0x34: - { - BYTE FAR *p; - - p = (BYTE FAR *) ((BYTE *) & InDOS); - r->ES = FP_SEG(p); - r->BX = FP_OFF(p); - } + lr.ES = FP_SEG(&InDOS); + lr.BX = FP_OFF(&InDOS); break; /* Get Interrupt Vector */ - case 0x35: - { - intvec p = getvec((COUNT) r->AL); - r->ES = FP_SEG(p); - r->BX = FP_OFF(p); + case 0x35: + { + intvec p = getvec((COUNT) lr.AL); + lr.ES = FP_SEG(p); + lr.BX = FP_OFF(p); } break; /* Dos Get Disk Free Space */ case 0x36: - DosGetFree(r->DL, - (UCOUNT FAR *) & r->AX, - (UCOUNT FAR *) & r->BX, - (UCOUNT FAR *) & r->CX, (UCOUNT FAR *) & r->DX); + DosGetFree(lr.DL, &lr.AX, &lr.BX, &lr.CX, &lr.DX); break; /* Undocumented Get/Set Switchar */ case 0x37: - switch (r->AL) + switch (lr.AL) { /* Get switch character */ case 0x00: - r->DL = switchar; - r->AL = 0x00; + lr.DL = switchar; + lr.AL = 0x00; break; /* Set switch character */ case 0x01: - switchar = r->DL; - r->AL = 0x00; + switchar = lr.DL; + lr.AL = 0x00; break; default: @@ -737,14 +868,14 @@ VOID ASMCFUNC int21_service(iregs FAR * r) /* Get/Set Country Info */ case 0x38: { - UWORD cntry = r->AL; + UWORD cntry = lr.AL; if (cntry == 0) cntry = (UWORD) - 1; else if (cntry == 0xff) - cntry = r->BX; + cntry = lr.BX; - if (0xffff == r->DX) + if (0xffff == lr.DX) { /* Set Country Code */ if ((rc = DosSetCountry(cntry)) < 0) @@ -759,7 +890,7 @@ VOID ASMCFUNC int21_service(iregs FAR * r) if (cntry == (UWORD) - 1) cntry = 1; /* END OF HACK */ - r->AX = r->BX = cntry; + lr.AX = lr.BX = cntry; } } break; @@ -786,36 +917,48 @@ VOID ASMCFUNC int21_service(iregs FAR * r) /* Dos Create File */ case 0x3c: - if ((rc = DosCreat(FP_DS_DX, r->CX)) < 0) - goto error_exit; - else - r->AX = rc; - break; + { + long lrc = DosOpen(FP_DS_DX, O_LEGACY | O_RDWR | O_CREAT | O_TRUNC, lr.CL); + + if (lrc < 0) + { + rc = (COUNT)lrc; + goto error_exit; + } + lr.AX = (UWORD)lrc; + break; + } /* Dos Open */ case 0x3d: - if ((rc = DosOpen(FP_DS_DX, r->AL)) < 0) - goto error_exit; - else - r->AX = rc; - break; + { + long lrc = DosOpen(FP_DS_DX, O_LEGACY | O_OPEN | lr.AL, 0); + + if (lrc < 0) + { + rc = (COUNT)lrc; + goto error_exit; + } + lr.AX = (UWORD)lrc; + break; + } /* Dos Close */ case 0x3e: - if ((rc = DosClose(r->BX)) < 0) + if ((rc = DosClose(lr.BX)) < 0) goto error_exit; break; /* Dos Read */ case 0x3f: - r->AX = DosRead(r->BX, r->CX, FP_DS_DX, (COUNT FAR *) & rc); + lr.AX = DosRead(lr.BX, lr.CX, FP_DS_DX, & rc); if (rc != SUCCESS) goto error_exit; break; /* Dos Write */ case 0x40: - r->AX = DosWrite(r->BX, r->CX, FP_DS_DX, (COUNT FAR *) & rc); + lr.AX = DosWrite(lr.BX, lr.CX, FP_DS_DX, & rc); if (rc != SUCCESS) goto error_exit; break; @@ -831,30 +974,34 @@ VOID ASMCFUNC int21_service(iregs FAR * r) case 0x42: { ULONG lrc; - if ((rc = - DosSeek(r->BX, (LONG) ((((LONG) (r->CX)) << 16) | r->DX), - r->AL, &lrc)) < 0) + if (lr.AL > 2) + goto error_invalid; + lrc = DosSeek(lr.BX, (LONG)((((ULONG) (lr.CX)) << 16) | lr.DX), lr.AL); + if (lrc == (ULONG)-1) + { + rc = -DE_INVLDHNDL; goto error_exit; + } else { - r->DX = (lrc >> 16); - r->AX = (UWORD) lrc; + lr.DX = (lrc >> 16); + lr.AX = (UWORD) lrc; } } break; /* Get/Set File Attributes */ case 0x43: - switch (r->AL) + switch (lr.AL) { case 0x00: rc = DosGetFattr((BYTE FAR *) FP_DS_DX); if (rc >= SUCCESS) - r->CX = rc; + lr.CX = rc; break; case 0x01: - rc = DosSetFattr((BYTE FAR *) FP_DS_DX, r->CX); + rc = DosSetFattr((BYTE FAR *) FP_DS_DX, lr.CX); break; default: @@ -866,96 +1013,92 @@ VOID ASMCFUNC int21_service(iregs FAR * r) /* Device I/O Control */ case 0x44: - rc = DosDevIOctl(r); /* can set critical error code! */ + rc = DosDevIOctl(&lr); /* can set critical error code! */ if (rc != SUCCESS) { - r->AX = -rc; + lr.AX = -rc; if (rc != DE_DEVICE && rc != DE_ACCESS) CritErrCode = -rc; - SET_CARRY_FLAG(); + goto error_carry; } break; /* Duplicate File Handle */ case 0x45: - rc = DosDup(r->BX); - if (rc < SUCCESS) - goto error_exit; - else - r->AX = rc; + { + long lrc = DosDup(lr.BX); + if (lrc < SUCCESS) + { + rc = (COUNT)lrc; + goto error_exit; + } + lr.AX = (UWORD)lrc; + } break; /* Force Duplicate File Handle */ case 0x46: - rc = DosForceDup(r->BX, r->CX); + rc = DosForceDup(lr.BX, lr.CX); if (rc < SUCCESS) goto error_exit; break; /* Get Current Directory */ case 0x47: - if ((rc = DosGetCuDir(r->DL, MK_FP(r->DS, r->SI))) < 0) + if ((rc = DosGetCuDir(lr.DL, MK_FP(lr.DS, lr.SI))) < 0) goto error_exit; else - r->AX = 0x0100; /*jpp: from interrupt list */ + lr.AX = 0x0100; /*jpp: from interrupt list */ break; /* Allocate memory */ case 0x48: if ((rc = - DosMemAlloc(r->BX, mem_access_mode, &(r->AX), &(r->BX))) < 0) + DosMemAlloc(lr.BX, mem_access_mode, &(lr.AX), &(lr.BX))) < 0) { - DosMemLargest(&(r->BX)); + DosMemLargest(&(lr.BX)); goto error_exit; } else - ++(r->AX); /* DosMemAlloc() returns seg of MCB rather than data */ + ++(lr.AX); /* DosMemAlloc() returns seg of MCB rather than data */ break; /* Free memory */ case 0x49: - if ((rc = DosMemFree((r->ES) - 1)) < 0) + if ((rc = DosMemFree((lr.ES) - 1)) < 0) goto error_exit; break; /* Set memory block size */ case 0x4a: + if ((rc = DosMemChange(lr.ES, lr.BX, &lr.BX)) < 0) { - UWORD maxSize; - - if ((rc = DosMemChange(r->ES, r->BX, &maxSize)) < 0) - { - if (rc == DE_NOMEM) - r->BX = maxSize; - #if 0 - if (cu_psp == r->ES) - { - - psp FAR *p; + if (cu_psp == lr.ES) + { - p = MK_FP(cu_psp, 0); - p->ps_size = r->BX + cu_psp; - } -#endif - goto error_exit; + psp FAR *p; + + p = MK_FP(cu_psp, 0); + p->ps_size = lr.BX + cu_psp; } - - break; +#endif + goto error_exit; } + break; /* Load and Execute Program */ case 0x4b: break_flg = FALSE; - if ((rc = DosExec(r->AL, MK_FP(r->ES, r->BX), FP_DS_DX)) != SUCCESS) + if ((rc = DosExec(lr.AL, MK_FP(lr.ES, lr.BX), FP_DS_DX)) != SUCCESS) goto error_exit; break; /* Terminate Program */ case 0x00: - r->AX = 0x4c00; + lr.AX = 0x4c00; /* End Program */ case 0x4c: @@ -977,7 +1120,7 @@ VOID ASMCFUNC int21_service(iregs FAR * r) { return_mode = 0; } - return_code = r->AL; + return_code = lr.AL; if (DosMemCheck() != SUCCESS) panic("MCB chain corrupted"); #ifdef TSC @@ -988,17 +1131,17 @@ VOID ASMCFUNC int21_service(iregs FAR * r) /* Get Child-program Return Value */ case 0x4d: - r->AL = return_code; - r->AH = return_mode; + lr.AL = return_code; + lr.AH = return_mode; break; /* Dos Find First */ case 0x4e: /* dta for this call is set on entry. This */ /* needs to be changed for new versions. */ - if ((rc = DosFindFirst((UCOUNT) r->CX, (BYTE FAR *) FP_DS_DX)) < 0) + if ((rc = DosFindFirst((UCOUNT) lr.CX, (BYTE FAR *) FP_DS_DX)) < 0) goto error_exit; - r->AX = 0; + lr.AX = 0; break; /* Dos Find Next */ @@ -1007,7 +1150,7 @@ VOID ASMCFUNC int21_service(iregs FAR * r) /* needs to be changed for new versions. */ if ((rc = DosFindNext()) < 0) goto error_exit; - r->AX = -SUCCESS; + lr.AX = -SUCCESS; break; /* case 0x50: @@ -1017,64 +1160,56 @@ VOID ASMCFUNC int21_service(iregs FAR * r) /* ************UNDOCUMENTED************************************* */ /* Get List of Lists */ case 0x52: - { - BYTE FAR *p; - - p = (BYTE FAR *) & DPBp; - r->ES = FP_SEG(p); - r->BX = FP_OFF(p); - } + lr.ES = FP_SEG(&DPBp); + lr.BX = FP_OFF(&DPBp); break; case 0x53: /* DOS 2+ internal - TRANSLATE BIOS PARAMETER BLOCK TO DRIVE PARAM BLOCK */ - bpb_to_dpb((bpb FAR *) MK_FP(r->DS, r->SI), - (struct dpb FAR *)MK_FP(r->ES, r->BP) + bpb_to_dpb((bpb FAR *) MK_FP(lr.DS, lr.SI), + (struct dpb FAR *)MK_FP(lr.ES, r->BP) #ifdef WITHFAT32 - , (r->CX == 0x4558 && r->DX == 0x4152) + , (lr.CX == 0x4558 && lr.DX == 0x4152) #endif ); break; /* Get verify state */ case 0x54: - r->AL = (verify_ena ? TRUE : FALSE); + lr.AL = (verify_ena ? TRUE : FALSE); break; /* ************UNDOCUMENTED************************************* */ /* Dos Create New Psp & set p_size */ case 0x55: - new_psp((psp FAR *) MK_FP(r->DX, 0), r->SI); - cu_psp = r->DX; + new_psp((psp FAR *) MK_FP(lr.DX, 0), lr.SI); + cu_psp = lr.DX; break; /* Dos Rename */ case 0x56: rc = DosRename((BYTE FAR *) FP_DS_DX, - (BYTE FAR *) MK_FP(r->ES, r->DI)); + (BYTE FAR *) FP_ES_DI); if (rc < SUCCESS) goto error_exit; - else - CLEAR_CARRY_FLAG(); break; /* Get/Set File Date and Time */ case 0x57: - CLEAR_CARRY_FLAG(); - switch (r->AL) + switch (lr.AL) { case 0x00: - rc = DosGetFtime((COUNT) r->BX, /* Handle */ - (date FAR *) & r->DX, /* FileDate */ - (time FAR *) & r->CX); /* FileTime */ + rc = DosGetFtime((COUNT) lr.BX, /* Handle */ + &lr.DX, /* FileDate */ + &lr.CX); /* FileTime */ if (rc < SUCCESS) goto error_exit; break; case 0x01: - rc = DosSetFtime((COUNT) r->BX, /* Handle */ - (date) r->DX, /* FileDate */ - (time) r->CX); /* FileTime */ + rc = DosSetFtime((COUNT) lr.BX, /* Handle */ + (date) lr.DX, /* FileDate */ + (time) lr.CX); /* FileTime */ if (rc < SUCCESS) goto error_exit; break; @@ -1086,17 +1221,16 @@ VOID ASMCFUNC int21_service(iregs FAR * r) /* Get/Set Allocation Strategy */ case 0x58: - CLEAR_CARRY_FLAG(); - switch (r->AL) + switch (lr.AL) { case 0x00: - r->AL = mem_access_mode; - r->AH = 0; + lr.AL = mem_access_mode; + lr.AH = 0; break; case 0x01: { - switch (r->BL) + switch (lr.BL) { case LAST_FIT: case LAST_FIT_U: @@ -1107,7 +1241,7 @@ VOID ASMCFUNC int21_service(iregs FAR * r) case FIRST_FIT: case FIRST_FIT_U: case FIRST_FIT_UO: - mem_access_mode = r->BL; + mem_access_mode = lr.BL; break; default: @@ -1117,13 +1251,13 @@ VOID ASMCFUNC int21_service(iregs FAR * r) break; case 0x02: - r->AL = uppermem_link; + lr.AL = uppermem_link; break; case 0x03: if (uppermem_root != 0xffff) /* always error if not exists */ { - DosUmbLink(r->BL); + DosUmbLink(lr.BL); break; } /* else fall through */ @@ -1140,92 +1274,67 @@ VOID ASMCFUNC int21_service(iregs FAR * r) /* Get Extended Error */ case 0x59: - r->AX = CritErrCode; - r->ES = FP_SEG(CritErrDev); - r->DI = FP_OFF(CritErrDev); - r->CH = CritErrLocus; - r->BH = CritErrClass; - r->BL = CritErrAction; - CLEAR_CARRY_FLAG(); + lr.AX = CritErrCode; + lr.ES = FP_SEG(CritErrDev); + lr.DI = FP_OFF(CritErrDev); + lr.CH = CritErrLocus; + lr.BH = CritErrClass; + lr.BL = CritErrAction; break; /* Create Temporary File */ case 0x5a: - if ((rc = DosMkTmp(FP_DS_DX, r->CX)) < 0) + if ((rc = DosMkTmp(FP_DS_DX, lr.CX)) < 0) goto error_exit; - else - { - r->AX = rc; - CLEAR_CARRY_FLAG(); - } + lr.AX = rc; break; /* Create New File */ case 0x5b: - if (!IsDevice(FP_DS_DX) && (rc = DosOpen(FP_DS_DX, 0)) >= 0) - { - DosClose(rc); - r->AX = 80; - goto error_out; - } - else { - if ((rc = DosCreat(FP_DS_DX, r->CX)) < 0) - goto error_exit; - else + long lrc = DosOpen(FP_DS_DX, O_LEGACY | O_RDWR | O_CREAT, lr.CX); + if (lrc < 0) { - r->AX = rc; - CLEAR_CARRY_FLAG(); + rc = (COUNT)lrc; + goto error_exit; } + lr.AX = (UWORD)lrc; + break; } - break; /* /// Added for SHARE. - Ron Cemer */ /* Lock/unlock file access */ case 0x5c: if ((rc = DosLockUnlock - (r->BX, - (((unsigned long)r->CX) << 16) | (((unsigned long)r-> - DX) & 0xffffL), - (((unsigned long)r->SI) << 16) | (((unsigned long)r-> - DI) & 0xffffL), - ((r->AX & 0xff) != 0))) != 0) + (lr.BX, + (((unsigned long)lr.CX) << 16) | (((unsigned long)lr.DX) ), + (((unsigned long)lr.SI) << 16) | (((unsigned long)lr.DI) ), + ((lr.AX & 0xff) != 0))) != 0) goto error_exit; - CLEAR_CARRY_FLAG(); break; /* /// End of additions for SHARE. - Ron Cemer */ /* UNDOCUMENTED: server, share.exe and sda function */ case 0x5d: - switch (r->AL) + switch (lr.AL) { /* Remote Server Call */ case 0x00: - { - UWORD FAR *x = FP_DS_DX; - r->AX = x[0]; - r->BX = x[1]; - r->CX = x[2]; - r->DX = x[3]; - r->SI = x[4]; - r->DI = x[5]; - r->DS = x[6]; - r->ES = x[7]; - } + fmemcpy(&lr, FP_DS_DX, sizeof(lr)); goto dispatch; case 0x06: - r->DS = FP_SEG(internal_data); - r->SI = FP_OFF(internal_data); - r->CX = swap_indos - internal_data; - r->DX = swap_always - internal_data; + lr.DS = FP_SEG(internal_data); + lr.SI = FP_OFF(internal_data); + lr.CX = swap_indos - internal_data; + lr.DX = swap_always - internal_data; CLEAR_CARRY_FLAG(); break; case 0x07: case 0x08: case 0x09: - rc = remote_printredir(r->DX, Int21AX); + rc = remote_printredir(lr.DX, Int21AX); if (rc != SUCCESS) goto error_exit; CLEAR_CARRY_FLAG(); @@ -1237,41 +1346,41 @@ VOID ASMCFUNC int21_service(iregs FAR * r) case 0x5e: CLEAR_CARRY_FLAG(); - switch (r->AL) + switch (lr.AL) { case 0x00: - r->CX = get_machine_name(FP_DS_DX); + lr.CX = get_machine_name(FP_DS_DX); break; case 0x01: - set_machine_name(FP_DS_DX, r->CX); + set_machine_name(FP_DS_DX, lr.CX); break; default: - rc = remote_printset(r->BX, r->CX, r->DX, (MK_FP(r->ES, r->DI)), - r->SI, (MK_FP(r->DS, Int21AX))); + rc = remote_printset(lr.BX, lr.CX, lr.DX, (FP_ES_DI), + lr.SI, (MK_FP(lr.DS, Int21AX))); if (rc != SUCCESS) goto error_exit; - r->AX = SUCCESS; + lr.AX = SUCCESS; break; } break; case 0x5f: CLEAR_CARRY_FLAG(); - switch (r->AL) + switch (lr.AL) { case 0x07: - if (r->DL < lastdrive) + if (lr.DL < lastdrive) { - CDSp[r->DL].cdsFlags |= 0x100; + CDSp[lr.DL].cdsFlags |= 0x100; } break; case 0x08: - if (r->DL < lastdrive) + if (lr.DL < lastdrive) { - CDSp[r->DL].cdsFlags &= ~0x100; + CDSp[lr.DL].cdsFlags &= ~0x100; } break; @@ -1281,21 +1390,24 @@ VOID ASMCFUNC int21_service(iregs FAR * r) int_2f_111e_call(r); break;*/ - rc = remote_doredirect(r->BX, r->CX, r->DX, - (MK_FP(r->ES, r->DI)), r->SI, - (MK_FP(r->DS, Int21AX))); + rc = remote_doredirect(lr.BX, lr.CX, lr.DX, + (FP_ES_DI), lr.SI, + (MK_FP(lr.DS, Int21AX))); + /* the remote function manipulates *r directly !, + so we should not copy lr to r here */ if (rc != SUCCESS) - goto error_exit; - r->AX = SUCCESS; - break; + { + CritErrCode = -rc; /* Maybe set */ + SET_CARRY_FLAG(); + } + r->AX = -rc; + goto real_exit; } break; case 0x60: /* TRUENAME */ CLEAR_CARRY_FLAG(); - if ((rc = truename(MK_FP(r->DS, r->SI), - adjust_far(MK_FP(r->ES, r->DI)), - FALSE)) != SUCCESS) + if ((rc = DosTruename(MK_FP(lr.DS, lr.SI), adjust_far(FP_ES_DI))) < SUCCESS) goto error_exit; break; @@ -1305,7 +1417,7 @@ VOID ASMCFUNC int21_service(iregs FAR * r) /* DOS-C: tsc support */ case 0x61: #ifdef DEBUG - switch (r->AL) + switch (lr.AL) { case 0x01: bTraceNext = TRUE; @@ -1316,24 +1428,24 @@ VOID ASMCFUNC int21_service(iregs FAR * r) break; } #endif - r->AL = 0x00; + lr.AL = 0x00; break; #endif /* UNDOCUMENTED: return current psp case 0x62: is in int21_syscall - r->BX = cu_psp; + lr.BX = cu_psp; break; */ /* UNDOCUMENTED: Double byte and korean tables */ case 0x63: { - r->DS = FP_SEG(dbcsTable); - r->SI = FP_OFF(dbcsTable); + lr.DS = FP_SEG(&nlsDBCSHardcoded); + lr.SI = FP_OFF(&nlsDBCSHardcoded); #if 0 /* not really supported, but will pass. */ - r->AL = 0x00; /*jpp: according to interrupt list */ + lr.AL = 0x00; /*jpp: according to interrupt list */ /*Bart: fails for PQDI and WATCOM utilities: use the above again */ #endif @@ -1346,32 +1458,32 @@ VOID ASMCFUNC int21_service(iregs FAR * r) /* Extended country info */ case 0x65: - switch (r->AL) + switch (lr.AL) { case 0x20: /* upcase single character */ - r->DL = DosUpChar(r->DL); + lr.DL = DosUpChar(lr.DL); break; case 0x21: /* upcase memory area */ - DosUpMem(FP_DS_DX, r->CX); + DosUpMem(FP_DS_DX, lr.CX); break; case 0x22: /* upcase ASCIZ */ DosUpString(FP_DS_DX); break; case 0xA0: /* upcase single character of filenames */ - r->DL = DosUpFChar(r->DL); + lr.DL = DosUpFChar(lr.DL); break; case 0xA1: /* upcase memory area of filenames */ - DosUpFMem(FP_DS_DX, r->CX); + DosUpFMem(FP_DS_DX, lr.CX); break; case 0xA2: /* upcase ASCIZ of filenames */ DosUpFString(FP_DS_DX); break; case 0x23: /* check Yes/No response */ - r->AX = DosYesNo(r->DL); + lr.AX = DosYesNo(lr.DL); break; default: - if ((rc = DosGetData(r->AL, r->BX, r->DX, r->CX, - MK_FP(r->ES, r->DI))) < 0) + if ((rc = DosGetData(lr.AL, lr.BX, lr.DX, lr.CX, + FP_ES_DI)) < 0) { #ifdef NLS_DEBUG printf("DosGetData() := %d\n", rc); @@ -1389,15 +1501,14 @@ VOID ASMCFUNC int21_service(iregs FAR * r) /* Code Page functions */ case 0x66: - { - int rc; - switch (r->AL) + CLEAR_CARRY_FLAG(); + switch (lr.AL) { case 1: - rc = DosGetCodepage(&r->BX, &r->DX); + rc = DosGetCodepage(&lr.BX, &lr.DX); break; case 2: - rc = DosSetCodepage(r->BX, r->DX); + rc = DosSetCodepage(lr.BX, lr.DX); break; default: @@ -1405,59 +1516,55 @@ VOID ASMCFUNC int21_service(iregs FAR * r) } if (rc != SUCCESS) goto error_exit; - CLEAR_CARRY_FLAG(); break; - } /* Set Max file handle count */ case 0x67: - if ((rc = SetJFTSize(r->BX)) != SUCCESS) + CLEAR_CARRY_FLAG(); + if ((rc = SetJFTSize(lr.BX)) != SUCCESS) goto error_exit; - else - CLEAR_CARRY_FLAG(); break; /* Flush file buffer -- COMMIT FILE. */ case 0x68: case 0x6a: - if ((rc = DosCommit(r->BX)) < 0) + CLEAR_CARRY_FLAG(); + if ((rc = DosCommit(lr.BX)) < 0) goto error_exit; - else - CLEAR_CARRY_FLAG(); break; /* Get/Set Serial Number */ case 0x69: - rc = (r->BL == 0 ? default_drive : r->BL - 1); + CLEAR_CARRY_FLAG(); + rc = (lr.BL == 0 ? default_drive : lr.BL - 1); if (rc < lastdrive) { - UWORD saveCX = r->CX; + UWORD saveCX = lr.CX; if (CDSp[rc].cdsFlags & CDSNETWDRV) { goto error_invalid; } - switch (r->AL) + switch (lr.AL) { case 0x00: - r->AL = 0x0d; - r->CX = 0x0866; - rc = DosDevIOctl(r); + lr.AL = 0x0d; + lr.CX = 0x0866; + rc = DosDevIOctl(&lr); break; case 0x01: - r->AL = 0x0d; - r->CX = 0x0846; - rc = DosDevIOctl(r); + lr.AL = 0x0d; + lr.CX = 0x0846; + rc = DosDevIOctl(&lr); break; } - r->CX = saveCX; + lr.CX = saveCX; if (rc != SUCCESS) goto error_exit; - CLEAR_CARRY_FLAG(); break; } else - r->AL = 0xFF; + lr.AL = 0xFF; break; /* case 0x6a: see case 0x68 @@ -1466,285 +1573,46 @@ VOID ASMCFUNC int21_service(iregs FAR * r) /* Extended Open-Creat, not fully functional. (bits 4,5,6 of BH) */ case 0x6c: { - COUNT x = 0; - - if (r->AL != 0 || r->DH != 0 || - (r->DL & 0x0f) > 0x2 || (r->DL & 0xf0) > 0x10) - goto error_invalid; + long lrc; CLEAR_CARRY_FLAG(); - if ((rc = DosOpen(MK_FP(r->DS, r->SI), - (r->DL & 0x0f) == 0x1 ? r->BL : 0)) < 0) + + if (lr.AL != 0 || lr.DH != 0 || + (lr.DL & 0x0f) > 0x2 || (lr.DL & 0xf0) > 0x10) + goto error_invalid; + lrc = DosOpen(MK_FP(lr.DS, lr.SI), + (lr.BX & 0x7000) | ((lr.DL & 3) << 8) | + ((lr.DL & 0x10) << 6), lr.CL); + if (lrc < 0) { - if (r->DL < 0x10) - goto error_exit; - /* else try to create below */ + rc = (COUNT)lrc; + goto error_exit; } else - switch (r->DL & 0x0f) - { - case 0x0: - /* fail if file exists */ - DosClose(rc); - rc = DE_FILEEXISTS; - goto error_exit; - case 0x1: - /* file exists and opened: OK */ - r->CX = 0x01; - goto break_out; - case 0x2: - /* file exists: replace/open */ - DosClose(rc); - x = 1; - break; - } - /* cases 0x00, 0x01 are finished now */ - if ((rc = DosCreat(MK_FP(r->DS, r->SI), r->CX)) < 0) - goto error_exit; - - r->CX = x + 2; - break_out: - r->AX = rc; + { + lr.AX = (UWORD)lrc; + /* action */ + lr.CX = lrc >> 16; + } break; } /* case 0x6d and above not implemented : see default; return AL=0 */ #ifdef WITHFAT32 - /* DOS 7.0+ FAT32 extended funcitons */ + /* DOS 7.0+ FAT32 extended functions */ case 0x73: - { - switch (r->AL) - { - /* Get extended drive parameter block */ - case 0x02: - { - struct xdpbdata FAR *xddp = - (struct xdpbdata FAR *)MK_FP(r->ES, r->DI); - struct dpb FAR *dpb; - - if (r->CX < sizeof(struct xdpbdata)) - { - r->AX = -DE_INVLDBUF; - goto error_out; - } - - dpb = GetDriveDPB(r->DL, &rc); - if (rc != SUCCESS) - goto error_exit; - - flush_buffers(dpb->dpb_unit); - dpb->dpb_flags = M_CHANGED; /* force reread of drive BPB/DPB */ - - if (media_check(dpb) < 0) - { - r->AX = -DE_INVLDDRV; - goto error_out; - } - - fmemcpy(&xddp->xdd_dpb, dpb, sizeof(struct dpb)); - xddp->xdd_dpbsize = sizeof(struct dpb); - CLEAR_CARRY_FLAG(); - - break; - } - /* Get extended free drive space */ - case 0x03: - { - struct xfreespace FAR *xfsp = - (struct xfreespace FAR *)MK_FP(r->ES, r->DI); - if (r->CX < sizeof(struct xfreespace)) - { - r->AX = -DE_INVLDBUF; - goto error_out; - } - CLEAR_CARRY_FLAG(); - rc = DosGetExtFree((BYTE FAR *) FP_DS_DX, xfsp); - if (rc != SUCCESS) - goto error_exit; - xfsp->xfs_datasize = sizeof(struct xfreespace); - xfsp->xfs_version.actual = 0; - break; - } - /* Set DPB to use for formatting */ - case 0x04: - { - struct xdpbforformat FAR *xdffp = - (struct xdpbforformat FAR *)MK_FP(r->ES, r->DI); - struct dpb FAR *dpb; - if (r->CX < sizeof(struct xdpbforformat)) - { - r->AX = -DE_INVLDBUF; - goto error_out; - } - dpb = GetDriveDPB(r->DL, &rc); - if (rc != SUCCESS) - goto error_exit; - - CLEAR_CARRY_FLAG(); - xdffp->xdff_datasize = sizeof(struct xdpbforformat); - xdffp->xdff_version.actual = 0; - - switch ((UWORD) xdffp->xdff_function) - { - case 0x00: - { - DWORD nfreeclst = xdffp->xdff_f.setdpbcounts.nfreeclst; - DWORD cluster = xdffp->xdff_f.setdpbcounts.cluster; - if (ISFAT32(dpb)) - { - if ((dpb->dpb_xfsinfosec == 0xffff - && (nfreeclst != 0 || cluster != 0)) - || nfreeclst == 1 || nfreeclst > dpb->dpb_xsize - || cluster == 1 || cluster > dpb->dpb_xsize) - { - r->AX = -DE_INVLDPARM; - goto error_out; - } - dpb->dpb_xnfreeclst = nfreeclst; - dpb->dpb_xcluster = cluster; - write_fsinfo(dpb); - } - else - { - if (nfreeclst == 1 || nfreeclst > dpb->dpb_size || - cluster == 1 || cluster > dpb->dpb_size) - { - r->AX = -DE_INVLDPARM; - goto error_out; - } - dpb->dpb_nfreeclst = nfreeclst; - dpb->dpb_cluster = cluster; - } - break; - } - case 0x01: - { - ddt *pddt = getddt(r->DL); - fmemcpy(&pddt->ddt_bpb, xdffp->xdff_f.rebuilddpb.bpbp, - sizeof(bpb)); - } - case 0x02: - { - rebuild_dpb: - flush_buffers(dpb->dpb_unit); - dpb->dpb_flags = M_CHANGED; - - if (media_check(dpb) < 0) - { - r->AX = -DE_INVLDDRV; - goto error_out; - } - - break; - } - case 0x03: - { - struct buffer FAR *bp; - bpb FAR *bpbp; - DWORD newmirroring = - xdffp->xdff_f.setmirroring.newmirroring; - - if (newmirroring != -1 - && (ISFAT32(dpb) - && (newmirroring & ~(0xf | 0x80)))) - { - r->AX = -DE_INVLDPARM; - goto error_out; - } - xdffp->xdff_f.setmirroring.oldmirroring = - (ISFAT32(dpb) ? dpb->dpb_xflags : 0); - if (newmirroring != -1 && ISFAT32(dpb)) - { - bp = getblock(1, dpb->dpb_unit); - bp->b_flag &= ~(BFR_DATA | BFR_DIR | BFR_FAT); - bp->b_flag |= BFR_VALID | BFR_DIRTY; - bpbp = (bpb FAR *) & bp->b_buffer[BT_BPB]; - bpbp->bpb_xflags = newmirroring; - } - goto rebuild_dpb; - } - case 0x04: - { - struct buffer FAR *bp; - bpb FAR *bpbp; - DWORD rootclst = xdffp->xdff_f.setroot.newrootclst; - if (!ISFAT32(dpb) - || (rootclst != -1 - && (rootclst == 1 - || rootclst > dpb->dpb_xsize))) - { - r->AX = -DE_INVLDPARM; - goto error_out; - } - xdffp->xdff_f.setroot.oldrootclst = dpb->dpb_xrootclst; - if (rootclst != -1) - { - bp = getblock(1, dpb->dpb_unit); - bp->b_flag &= ~(BFR_DATA | BFR_DIR | BFR_FAT); - bp->b_flag |= BFR_VALID | BFR_DIRTY; - bpbp = (bpb FAR *) & bp->b_buffer[BT_BPB]; - bpbp->bpb_xrootclst = rootclst; - } - goto rebuild_dpb; - } - } - - break; - } - /* Extended absolute disk read/write */ - /* TODO(vlp) consider using of the 13-14th bits of SI */ - case 0x05: - { - struct HugeSectorBlock FAR *SectorBlock = - (struct HugeSectorBlock FAR *)MK_FP(r->DS, r->BX); - UBYTE mode; - - if (r->CX != 0xffff || ((r->SI & 1) == 0 && r->SI != 0) - || (r->SI & ~0x6001)) - { - r->AX = -DE_INVLDPARM; - goto error_out; - } - - if (r->DL - 1 >= lastdrive || r->DL == 0) - { - r->AX = 0x207; - goto error_out; - } - CLEAR_CARRY_FLAG(); - - if (r->SI == 0) - mode = DSKREADINT25; - else - mode = DSKWRITEINT26; - - r->AX = - dskxfer(r->DL - 1, SectorBlock->blkno, SectorBlock->buf, - SectorBlock->nblks, mode); - - if (mode == DSKWRITEINT26) - if (r->AX <= 0) - setinvld(r->DL - 1); - - if (r->AX > 0) - { - r->AX = 0x20c; - r->flags |= FLG_CARRY; - return; - } - break; - } - default: - goto error_invalid; - } - break; - } + CLEAR_CARRY_FLAG(); + rc = int21_fat32(&lr); + if (rc != SUCCESS) + goto error_exit; + break; #endif + #ifdef WITHLFNAPI /* FreeDOS LFN helper API functions */ case 0x74: { - switch (r->AL) + switch (lr.AL) { /* Allocate LFN inode */ case 0x01: @@ -1752,34 +1620,54 @@ VOID ASMCFUNC int21_service(iregs FAR * r) break; /* Free LFN inode */ case 0x02: - rc = lfn_free_inode(r->BX); + rc = lfn_free_inode(lr.BX); break; /* Setup LFN inode */ case 0x03: - rc = lfn_setup_inode(r->BX, ((ULONG)r->CX << 16) | r->DX, ((ULONG)r->SI << 16) | r->DI); + rc = lfn_setup_inode(lr.BX, ((ULONG)lr.CX << 16) | lr.DX, ((ULONG)lr.SI << 16) | lr.DI); break; /* Create LFN entries */ case 0x04: - rc = lfn_create_entries(r->BX, (lfn_inode_ptr)FP_DS_DX); + rc = lfn_create_entries(lr.BX, (lfn_inode_ptr)FP_DS_DX); break; /* Read next LFN */ case 0x05: - rc = lfn_dir_read(r->BX, (lfn_inode_ptr)FP_DS_DX); + rc = lfn_dir_read(lr.BX, (lfn_inode_ptr)FP_DS_DX); break; /* Write SFN pointed by LFN inode */ case 0x06: - rc = lfn_dir_write(r->BX); + rc = lfn_dir_write(lr.BX); break; default: goto error_invalid; } - r->AX = rc; - if (rc < 0) goto error_out; + lr.AX = rc; + if (rc < 0) goto error_exit; else CLEAR_CARRY_FLAG(); break; } #endif } + goto exit_dispatch; + +error_invalid: + rc = DE_INVLDFUNC; +error_exit: + lr.AX = -rc; + CritErrCode = lr.AX; /* Maybe set */ +error_carry: + SET_CARRY_FLAG(); +exit_dispatch: + r->AX = lr.AX; + r->BX = lr.BX; + r->CX = lr.CX; + r->DX = lr.DX; + r->SI = lr.SI; + r->DI = lr.DI; + r->DS = lr.DS; + r->ES = lr.ES; +real_exit: + #ifdef DEBUG if (bDumpRegs) { @@ -1788,6 +1676,7 @@ VOID ASMCFUNC int21_service(iregs FAR * r) dump(); } #endif + return; } #if 0 @@ -2036,7 +1925,7 @@ VOID ASMCFUNC int2F_12_handler(volatile struct int2f12regs r) case 0x21: /* truename */ - truename(MK_FP(r.ds, r.si), MK_FP(r.es, r.di), 0); + DosTruename(MK_FP(r.ds, r.si), MK_FP(r.es, r.di)); break; diff --git a/kernel/ioctl.c b/kernel/ioctl.c index d22a85a0..1a591a59 100644 --- a/kernel/ioctl.c +++ b/kernel/ioctl.c @@ -54,7 +54,7 @@ static BYTE *RcsId = */ -COUNT DosDevIOctl(iregs FAR * r) +COUNT DosDevIOctl(lregs * r) { sft FAR *s; struct dpb FAR *dpbp; @@ -78,10 +78,106 @@ COUNT DosDevIOctl(iregs FAR * r) case 0x07: case 0x0a: case 0x0c: + case 0x10: /* Get the SFT block that contains the SFT */ if ((s = get_sft(r->BX)) == (sft FAR *) - 1) return DE_INVLDHNDL; + + switch (r->AL) + { + case 0x00: + /* Get the flags from the SFT */ + if (s->sft_flags & SFT_FDEVICE) + r->AX = (s->sft_dev->dh_attr & 0xff00) | s->sft_flags_lo; + else + r->AX = s->sft_flags; + /* Undocumented result, Ax = Dx seen using Pcwatch */ + r->DX = r->AX; + break; + + case 0x01: + /* sft_flags is a file, return an error because you */ + /* can't set the status of a file. */ + if (!(s->sft_flags & SFT_FDEVICE)) + return DE_INVLDFUNC; + + /* Set it to what we got in the DL register from the */ + /* user. */ + r->AL = s->sft_flags_lo = SFT_FDEVICE | r->DL; + break; + + case 0x02: + nMode = C_IOCTLIN; + goto IoCharCommon; + + case 0x03: + nMode = C_IOCTLOUT; + goto IoCharCommon; + + case 0x06: + if (s->sft_flags & SFT_FDEVICE) + r->AL = s->sft_flags & SFT_FEOF ? 0xFF : 0; + else + r->AL = s->sft_posit >= s->sft_size ? 0xFF : 0; + break; + + case 0x07: + if (s->sft_flags & SFT_FDEVICE) + { + nMode = C_OSTAT; + goto IoCharCommon; + } + r->AL = 0; + break; + + case 0x0a: + r->DX = s->sft_flags; + r->AX = 0; + break; + + case 0x0c: + nMode = C_GENIOCTL; + goto IoCharCommon; + + case 0x10: + nMode = C_IOCTLQRY; + IoCharCommon: + if ((s->sft_flags & SFT_FDEVICE) + || ((r->AL == 0x02) && (s->sft_dev->dh_attr & SFT_FIOCTL)) + || ((r->AL == 0x03) && (s->sft_dev->dh_attr & SFT_FIOCTL)) + || ((r->AL == 0x10) && (s->sft_dev->dh_attr & ATTR_QRYIOCTL)) + || ((r->AL == 0x0c) && (s->sft_dev->dh_attr & ATTR_GENIOCTL))) + { + CharReqHdr.r_unit = 0; + CharReqHdr.r_command = nMode; + execrh((request FAR *) & CharReqHdr, s->sft_dev); + + if (CharReqHdr.r_status & S_ERROR) + { + CritErrCode = (CharReqHdr.r_status & S_MASK) + 0x13; + return DE_DEVICE; + } + + if (r->AL == 0x07) + { + r->AL = CharReqHdr.r_status & S_BUSY ? 00 : 0xff; + } + else if (r->AL == 0x02 || r->AL == 0x03) + { + r->AX = CharReqHdr.r_count; + } + + else if (r->AL == 0x0c || r->AL == 0x10) + { + r->AX = CharReqHdr.r_status; + } + break; + } + /* fall through */ + default: + return DE_INVLDFUNC; + } break; case 0x04: @@ -91,7 +187,6 @@ COUNT DosDevIOctl(iregs FAR * r) case 0x0d: case 0x0e: case 0x0f: - case 0x10: case 0x11: /* @@ -113,222 +208,125 @@ COUNT DosDevIOctl(iregs FAR * r) /* cdsp = &CDSp[CharReqHdr.r_unit]; */ dpbp = CDSp[CharReqHdr.r_unit].cdsDpb; } - break; + switch (r->AL) + { + case 0x04: + nMode = C_IOCTLIN; + goto IoBlockCommon; + case 0x05: + nMode = C_IOCTLOUT; + goto IoBlockCommon; + case 0x08: + if (!dpbp) + { + return DE_INVLDDRV; + } + if (dpbp->dpb_device->dh_attr & ATTR_EXCALLS) + { + nMode = C_REMMEDIA; + goto IoBlockCommon; + } + return DE_INVLDFUNC; + case 0x09: + if (CDSp[CharReqHdr.r_unit].cdsFlags & CDSNETWDRV) + { + r->DX = ATTR_REMOTE; + r->AX = S_DONE | S_BUSY; + } + else + { + if (!dpbp) + { + return DE_INVLDDRV; + } +/* Need to add subst bit 15 */ + r->DX = dpbp->dpb_device->dh_attr; + r->AX = S_DONE | S_BUSY; + } + break; + case 0x0d: + nMode = C_GENIOCTL; + goto IoBlockCommon; + case 0x11: + nMode = C_IOCTLQRY; + IoBlockCommon: + if (!dpbp) + { + return DE_INVLDDRV; + } + if (((r->AL == 0x04) && !(dpbp->dpb_device->dh_attr & ATTR_IOCTL)) + || ((r->AL == 0x05) && !(dpbp->dpb_device->dh_attr & ATTR_IOCTL)) + || ((r->AL == 0x11) + && !(dpbp->dpb_device->dh_attr & ATTR_QRYIOCTL)) + || ((r->AL == 0x0d) + && !(dpbp->dpb_device->dh_attr & ATTR_GENIOCTL))) + { + return DE_INVLDFUNC; + } + + CharReqHdr.r_command = nMode; + execrh((request FAR *) & CharReqHdr, dpbp->dpb_device); + + if (CharReqHdr.r_status & S_ERROR) + { + CritErrCode = (CharReqHdr.r_status & S_MASK) + 0x13; + return DE_DEVICE; + } + if (r->AL == 0x08) + { + r->AX = (CharReqHdr.r_status & S_BUSY) ? 1 : 0; + } + + else if (r->AL == 0x04 || r->AL == 0x05) + { + r->AX = CharReqHdr.r_count; + } + else if (r->AL == 0x0d || r->AL == 0x11) + { + r->AX = CharReqHdr.r_status; + } + break; + + case 0x0e: + nMode = C_GETLDEV; + goto IoLogCommon; + case 0x0f: + nMode = C_SETLDEV; + IoLogCommon: + if (!dpbp) + { + return DE_INVLDDRV; + } + if ((dpbp->dpb_device->dh_attr & ATTR_GENIOCTL)) + { + + CharReqHdr.r_command = nMode; + execrh((request FAR *) & CharReqHdr, dpbp->dpb_device); + + if (CharReqHdr.r_status & S_ERROR) + { + CritErrCode = (CharReqHdr.r_status & S_MASK) + 0x13; + return DE_ACCESS; + } + else + { + r->AL = CharReqHdr.r_unit; + return SUCCESS; + } + } /* fall through */ + default: + return DE_INVLDFUNC; + } + break; + case 0x0b: /* skip, it's a special case. */ - NetDelay = r->CX; if (!r->DX) NetRetry = r->DX; break; - - default: - return DE_INVLDFUNC; - } - - switch (r->AL) - { - case 0x00: - /* Get the flags from the SFT */ - if (s->sft_flags & SFT_FDEVICE) - r->AX = (s->sft_dev->dh_attr & 0xff00) | s->sft_flags_lo; - else - r->AX = s->sft_flags; -/* Undocumented result, Ax = Dx seen using Pcwatch */ - r->DX = r->AX; - break; - - case 0x01: - /* sft_flags is a file, return an error because you */ - /* can't set the status of a file. */ - if (!(s->sft_flags & SFT_FDEVICE)) - return DE_INVLDFUNC; - - /* Set it to what we got in the DL register from the */ - /* user. */ - r->AL = s->sft_flags_lo = SFT_FDEVICE | r->DL; - break; - - case 0x0c: - nMode = C_GENIOCTL; - goto IoCharCommon; - case 0x02: - nMode = C_IOCTLIN; - goto IoCharCommon; - case 0x10: - nMode = C_IOCTLQRY; - goto IoCharCommon; - case 0x03: - nMode = C_IOCTLOUT; - IoCharCommon: - if ((s->sft_flags & SFT_FDEVICE) - || ((r->AL == 0x02) && (s->sft_dev->dh_attr & SFT_FIOCTL)) - || ((r->AL == 0x03) && (s->sft_dev->dh_attr & SFT_FIOCTL)) - || ((r->AL == 0x10) && (s->sft_dev->dh_attr & ATTR_QRYIOCTL)) - || ((r->AL == 0x0c) && (s->sft_dev->dh_attr & ATTR_GENIOCTL))) - { - CharReqHdr.r_unit = 0; - CharReqHdr.r_command = nMode; - execrh((request FAR *) & CharReqHdr, s->sft_dev); - - if (CharReqHdr.r_status & S_ERROR) - { - CritErrCode = (CharReqHdr.r_status & S_MASK) + 0x13; - return DE_DEVICE; - } - - if (r->AL == 0x07) - { - r->AL = CharReqHdr.r_status & S_BUSY ? 00 : 0xff; - - } - else if (r->AL == 0x02 || r->AL == 0x03) - { - r->AX = CharReqHdr.r_count; - } - - else if (r->AL == 0x0c || r->AL == 0x10) - { - r->AX = CharReqHdr.r_status; - } - break; - } - return DE_INVLDFUNC; - - case 0x0d: - nMode = C_GENIOCTL; - goto IoBlockCommon; - case 0x04: - nMode = C_IOCTLIN; - goto IoBlockCommon; - case 0x11: - nMode = C_IOCTLQRY; - goto IoBlockCommon; - case 0x05: - nMode = C_IOCTLOUT; - IoBlockCommon: - if (!dpbp) - { - return DE_INVLDDRV; - } - if (((r->AL == 0x04) && !(dpbp->dpb_device->dh_attr & ATTR_IOCTL)) - || ((r->AL == 0x05) && !(dpbp->dpb_device->dh_attr & ATTR_IOCTL)) - || ((r->AL == 0x11) - && !(dpbp->dpb_device->dh_attr & ATTR_QRYIOCTL)) - || ((r->AL == 0x0d) - && !(dpbp->dpb_device->dh_attr & ATTR_GENIOCTL))) - { - return DE_INVLDFUNC; - } - - CharReqHdr.r_command = nMode; - execrh((request FAR *) & CharReqHdr, dpbp->dpb_device); - - if (CharReqHdr.r_status & S_ERROR) - { - CritErrCode = (CharReqHdr.r_status & S_MASK) + 0x13; - return DE_DEVICE; - } - if (r->AL == 0x08) - { - r->AX = (CharReqHdr.r_status & S_BUSY) ? 1 : 0; - - } - - else if (r->AL == 0x04 || r->AL == 0x05) - { - r->AX = CharReqHdr.r_count; - - } - else if (r->AL == 0x0d || r->AL == 0x11) - { - r->AX = CharReqHdr.r_status; - } - break; - - case 0x06: - if (s->sft_flags & SFT_FDEVICE) - { - r->AL = s->sft_flags & SFT_FEOF ? 0xFF : 0; - } - else - r->AL = s->sft_posit >= s->sft_size ? 0xFF : 0; - break; - - case 0x07: - if (s->sft_flags & SFT_FDEVICE) - { - nMode = C_OSTAT; - goto IoCharCommon; - } - r->AL = 0; - break; - - case 0x08: - if (!dpbp) - { - return DE_INVLDDRV; - } - if (dpbp->dpb_device->dh_attr & ATTR_EXCALLS) - { - nMode = C_REMMEDIA; - goto IoBlockCommon; - } - return DE_INVLDFUNC; - - case 0x09: - if (CDSp[CharReqHdr.r_unit].cdsFlags & CDSNETWDRV) - { - r->DX = ATTR_REMOTE; - r->AX = S_DONE | S_BUSY; - } - else - { - if (!dpbp) - { - return DE_INVLDDRV; - } -/* Need to add subst bit 15 */ - r->DX = dpbp->dpb_device->dh_attr; - r->AX = S_DONE | S_BUSY; - } - break; - - case 0x0a: - r->DX = s->sft_flags; - r->AX = 0; - break; - - case 0x0e: - nMode = C_GETLDEV; - goto IoLogCommon; - case 0x0f: - nMode = C_SETLDEV; - IoLogCommon: - if (!dpbp) - { - return DE_INVLDDRV; - } - if ((dpbp->dpb_device->dh_attr & ATTR_GENIOCTL)) - { - - CharReqHdr.r_command = nMode; - execrh((request FAR *) & CharReqHdr, dpbp->dpb_device); - - if (CharReqHdr.r_status & S_ERROR) - { - CritErrCode = (CharReqHdr.r_status & S_MASK) + 0x13; - return DE_ACCESS; - } - else - { - r->AL = CharReqHdr.r_unit; - return SUCCESS; - } - } - return DE_INVLDFUNC; - + default: return DE_INVLDFUNC; } diff --git a/kernel/main.c b/kernel/main.c index 153ff9d0..df6602fc 100644 --- a/kernel/main.c +++ b/kernel/main.c @@ -457,7 +457,6 @@ STATIC void kernel() fmemcpy(p, insertString, 3); Cmd.ctCount += 3; - printf("%d %s\n", Cmd.ctCount, Cmd.ctBuffer); break; } } diff --git a/kernel/newstuff.c b/kernel/newstuff.c index ce6c5d74..de926e27 100644 --- a/kernel/newstuff.c +++ b/kernel/newstuff.c @@ -74,13 +74,13 @@ int DosMkTmp(BYTE FAR * pathname, UWORD attr) { /* create filename from current date and time */ char FAR *ptmp = pathname; - BYTE wd, month, day; - BYTE h, m, s, hund; - WORD sh; - WORD year; + UBYTE wd, month, day; + UBYTE h, m, s, hund; + UWORD sh; + UWORD year; int rc; char name83[13]; - int loop; + int loop = 0; while (*ptmp) ptmp++; @@ -88,52 +88,153 @@ int DosMkTmp(BYTE FAR * pathname, UWORD attr) if (ptmp == pathname || (ptmp[-1] != '\\' && ptmp[-1] != '/')) *ptmp++ = '\\'; - DosGetDate(&wd, &month, &day, (COUNT FAR *) & year); + DosGetDate(&wd, &month, &day, &year); DosGetTime(&h, &m, &s, &hund); sh = s * 100 + hund; - for (loop = 0; loop < 0xfff; loop++) - { + do { sprintf(name83, "%x%x%x%x%x%03x.%03x", year & 0xf, month & 0xf, day & 0xf, h & 0xf, m & 0xf, sh & 0xfff, loop & 0xfff); fmemcpy(ptmp, name83, 13); - if ((rc = DosOpen(pathname, 0)) < 0 && rc != DE_ACCESS /* subdirectory ?? */ - /* todo: sharing collision on - network drive - */ - ) - break; - - if (rc >= 0) - DosClose(rc); - } + /* only create new file -- 2001/09/22 ska*/ + rc = (short)DosOpen(pathname, O_LEGACY | O_CREAT | O_RDWR, attr); + } while (rc == DE_FILEEXISTS && loop++ < 0xfff); - if (rc == DE_FILENOTFND) - { - rc = DosCreat(pathname, attr); - } return rc; } -COUNT get_verify_drive(char FAR * src) +#ifdef DEBUG +#define DEBUG_TRUENAME +#endif + +#define drLetterToNr(dr) ((dr) - 'A') +/* Convert an uppercased drive letter into the drive index */ +#define drNrToLetter(dr) ((dr) + 'A') +/* the other direction */ + + /* In DOS there are no free-standing UNC paths, therefore there + is always a logical drive letter associated with a path + spec. This letter is also the index into the CDS */ + +COUNT get_verify_drive(const char FAR * src) { UBYTE drive; + unsigned flags; /* Do we have a drive? */ if (src[1] == ':') - drive = ((src[0] - 1) | 0x20) - ('a' - 1); - else - return default_drive; - if (drive < lastdrive && CDSp[drive].cdsFlags & CDSVALID) - return drive; + drive = drLetterToNr(DosUpFChar(src[0])); else + drive = default_drive; + + if (drive >= lastdrive) return DE_INVLDDRV; + + /* Entry is disabled or JOINed drives are accessable by the path only */ + flags = CDSp[drive].cdsFlags; + if ((flags & CDSMODEMASK) == 0 || (flags & CDSJOINED) != 0) + return DE_INVLDDRV; + + return drive; } +/* + Definition of functions for the handling of the Current + Directory Structure. + + MUX-11-23: Qualify Remote Filename + DOS-0x60 calls this MUX functions to let the Network Redirector + qualify the filename. According INTRSPY MS DOS 6 does not pre- + process the passed in filename in any way (see attached transcripts). + + The DOS-60 interface TRUENAME looks like this: + + DosTruename(src, dest) { + if (MUX-11-23(src, dest) != Error) + return SUCCESS + return local_truename(src, dest); + } + + The CDS has the following entries: + + char cdsPath[CDSPATHLEN]; + The fully-qualified current working directory of this drive. + The format is DOS :\[{\}] + or UNC \\[{\}]. + The drive indicates the physical drive letter and is the + index into the blk_device[]. + + UWORD cdsFlags; + Indicates what kind this logical drive is: + NETWORK: drive is NOT local \ If both are set, drive is IFS + PHYSICAL: drive is local / If none is set, drive is non-existant + JOIN: drive is joined in as the path cdsPath. This Flag uses the + index into the CDS table to indicate the physical drive. + SUBST: drive substitutes the path cdsPath. + HIDDEN: drive is not included into the redirector's list. + + struct dpb FAR *cdsDpb; + Pointer to the DPB driving the physical drive. In DOS-C, the physical + drive letter is the index into the DPB[]. But for compatibly reason + this field will be set correctly. + + UWORD cdsStartCluster; + For local drives only: This holds the cluster number of + the start of the current working directory of this + logical drive. If 0000h, it's the root directory; if + 0ffffh, the drive was never accessed and has to be read + again. + + void FAR *cdsIFSrecord; + UWORD cdsIFSparameter; + For networked drives only: Holds pointer/parameters to/for IFS + driver. (Well, I don't know.) + + UWORD cdsPathOff; + Number of characters of the cdsPath[], which are hidden. The + logical path is combined by the logical drive letter and the + cdsPath[] part, which is not hidden. + + IFS FAR *cdsIFSdrv; + Will be zeroed for local drives. + + Revision 1.2 1995/12/03 22:17:41 ska + bugfix: Scanning of file name in 8.3 failed on "." and on longer names. + + Revision 1.1 1995/11/09 07:43:30 ska + # + +*/ + +#define PATH_ERROR goto errRet +#define PATHLEN 128 + + +/* Map a logical path into a physical one. + + 1) Uppercasing path. + 2) Flipping '/' -> '\\'. + 3) Removing empty directory components & ".". + 4) Processing ".." components. + 5) Convert path components into 8.3 convention. + 6) Make it fully-qualified. + 7) Map it to SUBST/UNC. + 8) Map to JOIN. + + Return: + *cdsItem will be point to the appropriate CDS entry. This will allow + the caller to aquire the DPB or the IFS informtion of this entry. + error number + Return value: + DE_FILENOTFND, or DE_PATHNOTFND (as described in RBIL) + If the output path pnfo->physPath exceeds the length MAX_PATH, the error + DE_FILENOTFND will be returned. +*/ + /* * Added support for external and internal calls. * Clean buffer before use. Make the true path and expand file names. @@ -157,27 +258,127 @@ COUNT get_verify_drive(char FAR * src) */ -COUNT truename(char FAR * src, char FAR * dest, COUNT t) -{ - static char buf[128] = "A:\\\0\0\0\0\0\0\0\0\0"; - char *bufp = buf + 3; - COUNT i, rootEndPos = 2; /* renamed x to rootEndPos - Ron Cemer */ - struct dhdr FAR *dhp; - BYTE FAR *froot; - WORD d; +#ifdef DEBUG_TRUENAME +#define tn_printf(x) printf x +#else +#define tn_printf(x) +#endif - dest[0] = '\0'; +#define PNE_WILDCARD 1 +#define PNE_DOT 2 - i = get_verify_drive(src); - if (i < 0) - return DE_INVLDDRV; +#define addChar(c) \ +{ \ + if (p - dest >= SFTMAX) PATH_ERROR; /* path too long */ \ + *p++ = c; \ +} + +/* helper for truename: parses either name or extension */ +STATIC int parse_name_ext(int i, const char FAR **src, char **cp, char *dest) +{ + int retval = SUCCESS; + char *p = *cp; + char c; + + while(1) switch(c=*(*src)++) + { + case '.': + retval |= PNE_DOT; + /* fall through */ + case '/': + case '\\': + case '\0': + *cp = p; + return retval; + case '*': + retval |= PNE_WILDCARD; + /* register the wildcard, even if no '?' is appended */ + if (i) do + { + addChar('?'); + } while(--i); + /** Alternative implementation: + if (i) + { + if (dest + SFTMAX - *p < i) + PATH_ERROR; + fmemset(p, '?', i); + p += i; + } **/ + break; + case '?': + retval |= PNE_WILDCARD; + /* fall through */ + default: + if (i) { /* name length in limits */ + --i; + addChar(c); + } + } + + errRet: + return -1; +} - buf[0] = i + 'A'; - buf[1] = ':'; /* Just to be sure */ +COUNT truename(const char FAR * src, char * dest, COUNT mode) +{ + COUNT i; + struct dhdr FAR *dhp; + const char FAR *froot; + COUNT result; + int gotAnyWildcards = 0; + struct cds FAR *cdsEntry; + char *p = dest; /* dynamic pointer into dest */ + char *rootPos; + enum { DONT_ADD, ADD, ADD_UNLESS_LAST } addSep; + + tn_printf(("truename(%S)\n", src)); /* First, adjust the source pointer */ src = adjust_far(src); + /* In opposite of the TRUENAME shell command, an empty string is + rejected by MS DOS 6 */ + if (src[0] == '\0') + return DE_FILENOTFND; + + result = get_verify_drive(src); + if (result < SUCCESS) + return result; + + cdsEntry = &CDSp[result]; + tn_printf(("CDS entry: #%u @%p (%u) '%S'\n", result, cdsEntry, + cdsEntry->cdsBackslashOffset, cdsEntry->cdsCurrentPath)); + /* is the current_ldt thing necessary for compatibly?? + -- 2001/09/03 ska*/ + current_ldt = cdsEntry; + if (cdsEntry->cdsFlags & CDSNETWDRV) + result |= IS_NETWORK; + + dhp = IsDevice(src); + if (dhp) + result |= IS_DEVICE; + + /* Try if the Network redirector wants to do it */ + dest[0] = '\0'; /* better probable for sanity check below -- + included by original truename() */ + /* MUX succeeded and really something */ + if (QRemote_Fn(dest, src) && dest[0] != '\0') + { + tn_printf(("QRemoteFn() returned: \"%S\"\n", dest)); +#ifdef DEBUG_TRUENAME + if (strlen(dest) >= SFTMAX) + panic("Truename: QRemote_Fn() overflowed output buffer"); +#endif + if (dest[2] == '/' && (result & IS_DEVICE)) + result &= ~IS_NETWORK; + return result; + } + + /* Redirector interface failed --> proceed with local mapper */ + dest[0] = drNrToLetter(result & 0x1f); + dest[1] = ':'; + /* Do we have a drive? */ if (src[1] == ':') src += 2; @@ -188,343 +389,319 @@ COUNT truename(char FAR * src, char FAR * dest, COUNT t) */ /* check for a device */ - if ((*src != '.') && (*src != '\\') && (*src != '/') - && ((dhp = IsDevice(src)) != NULL)) + dest[2] = '\\'; + if (result & IS_DEVICE) { - froot = get_root(src); - - /* /// Bugfix: NUL.LST is the same as NUL. This is true for all - devices. On a device name, the extension is irrelevant - as long as the name matches. - - Ron Cemer */ - - buf[2] = '/'; - /* /// Bug: should be only copying up to first space. - - Ron Cemer */ - - for (d = 0; - d < FNAME_SIZE && dhp->dh_name[d] != 0 && dhp->dh_name[d] != ' '; - d++) - *bufp++ = dhp->dh_name[d]; - /* /// DOS will return C:/NUL.LST if you pass NUL.LST in. - DOS will also return C:/NUL.??? if you pass NUL.* in. - Code added here to support this. - - Ron Cemer */ - while ((*froot != '.') && (*froot != '\0')) - froot++; - if (*froot) - froot++; - if (*froot) + if (froot == src || froot == src + 5) { - *bufp++ = '.'; - for (i = 0; i < FEXT_SIZE; i++) + if (froot == src + 5) { - if ((*froot == '\0') || (*froot == '.')) - break; - if (*froot == '*') - { - for (; i < FEXT_SIZE; i++) - *bufp++ = '?'; - break; - } - *bufp++ = *froot++; + fmemcpy(dest + 3, src, 5); + DosUpMem(dest + 3, 5); + if (dest[3] == '/') dest[3] = '\\'; + if (dest[7] == '/') dest[7] = '\\'; + } + if (froot == src || memcmp(dest + 3, "\\DEV\\", 5) == 0) + { + /* /// Bugfix: NUL.LST is the same as NUL. This is true for all + devices. On a device name, the extension is irrelevant + as long as the name matches. + - Ron Cemer */ + dest[2] = '/'; + result &= ~IS_NETWORK; + /* /// DOS will return C:/NUL.LST if you pass NUL.LST in. + DOS will also return C:/NUL.??? if you pass NUL.* in. + Code added here to support this. + - Ron Cemer */ + src = froot; } } - /* /// End of code additions. - Ron Cemer */ - goto exit_tn; - } - - /* /// Added to adjust for filenames which begin with ".\" - * The problem was manifesting itself in the inability - * to run an program whose filename (without the extension) - * was longer than six characters and the PATH variable - * contained ".", unless you explicitly specified the full - * path to the executable file. - * Jun 11, 2000 - rbc */ - /* /// Changed to "while" from "if". - Ron Cemer */ - while ((src[0] == '.') && (src[1] == '\\')) - src += 2; - - current_ldt = &CDSp[i]; - - /* Always give the redirector a chance to rewrite the filename */ - fmemcpy(bufp - 1, src, sizeof(buf) - (bufp - buf)); - if ((t == FALSE) && (QRemote_Fn(buf, dest) == SUCCESS) - && (dest[0] != '\0')) - { - return SUCCESS; - } - else - { - bufp[-1] = '\\'; - } - if (t == FALSE) - { - fmemcpy(buf, current_ldt->cdsCurrentPath, current_ldt->cdsJoinOffset); - bufp = buf + current_ldt->cdsJoinOffset; - rootEndPos = current_ldt->cdsJoinOffset; /* renamed x to rootEndPos - Ron Cemer */ - *bufp++ = '\\'; } - - if (*src != '\\' && *src != '/') /* append current dir */ + + /* Make fully-qualified logical path */ + /* register these two used characters and the \0 terminator byte */ + /* we always append the current dir to stat the drive; + the only exceptions are devices without paths */ + rootPos = p = dest + 2; + if (*p != '/') /* i.e., it's a backslash! */ { - DosGetCuDir((UBYTE) (i + 1), bufp); - if (*bufp) + if (!(mode & CDS_MODE_SKIP_PHYSICAL)) { - while (*bufp) - bufp++; - *bufp++ = '\\'; + tn_printf(("SUBSTing from: %S\n", cdsEntry->cdsCurrentPath)); +/* What to do now: the logical drive letter will be replaced by the hidden + portion of the associated path. This is necessary for NETWORK and + SUBST drives. For local drives it should not harm. + This is actually the reverse mechanism of JOINED drives. */ + + fmemcpy(dest, cdsEntry->cdsCurrentPath, cdsEntry->cdsBackslashOffset); + if (cdsEntry->cdsFlags & CDSSUBST) + { + /* The drive had been changed --> update the CDS pointer */ + if (dest[1] == ':') + { /* sanity check if this really is a local drive still */ + unsigned i = drLetterToNr(dest[0]); + + if (i < lastdrive) /* sanity check #2 */ + result = (result & 0xffe0) | i; + } + } + rootPos = p = dest + current_ldt->cdsBackslashOffset; + *p = '\\'; /* force backslash! */ } + p++; + DosGetCuDir((result & 0x1f) + 1, p); + if (*src != '\\' && *src != '/') + p += strlen(p); + else /* skip the absolute path marker */ + src++; + /* remove trailing separator */ + if (p[-1] == '\\') p--; } - else - src++; - -/*move_name:*/ - - /* /// The block inside the "#if (0) ... #endif" is - seriously broken. New code added below to replace it. - This eliminates many serious bugs, specifically - with FreeCOM where truename is required to work - according to the DOS specification in order for - the COPY and other file-related commands to work - properly. - This should be a major improvement to all apps which - use truename. - - Ron Cemer */ - -#if (0) -/* - * The code here is brain dead. It works long as the calling - * function are operating with in normal parms. - * jt - */ - n = 9; - /* convert all forward slashes to backslashes, and uppercase all characters */ - while (*src) - { - char c; - c = *src++; - if (!n) - return DE_PATHNOTFND; /* do this for now */ - n--; - switch (c) - { - case '*': - if (*src == '.') - { - while (n--) - *bufp++ = '?'; - break; - } - else - { - if (src[-2] == '.') - { - while (n--) - *bufp++ = '?'; - break; - } - else - { - while (n--) - *bufp++ = '?'; - break; - } - } - case '/': /* convert to backslash */ - case '\\': - if (bufp[-1] != '\\') - { - *bufp++ = '\\'; - n = 9; - } - break; + /* append the path specified in src */ + addSep = ADD; /* add separator */ - /* look for '.' and '..' dir entries */ - case '.': - if (bufp[-1] == '\\') + while(*src) + { + /* New segment. If any wildcards in previous + segment(s), this is an invalid path. */ + if (gotAnyWildcards) + return DE_PATHNOTFND; + switch(*src++) + { + case '/': + case '\\': /* skip multiple separators (duplicated slashes) */ + addSep = ADD; + break; + case '.': /* special directory component */ + switch(*src) { - if (*src == '.' && (src[1] == '/' || src[1] == '\\' || !src[1])) - { - /* '..' dir entry: rewind bufp to last backslash */ - - for (bufp -= 2; *bufp != '\\'; bufp--) + case '/': + case '\\': + case '\0': + /* current path -> ignore */ + addSep = ADD_UNLESS_LAST; + /* If (/ or \) && no ++src + --> addSep = ADD next turn */ + continue; /* next char */ + case '.': /* maybe ".." entry */ + switch(src[1]) { - if (bufp < buf + rootEndPos) /* '..' illegal in root dir */ - return DE_PATHNOTFND; + case '/': + case '\\': + case '\0': + /* remove last path component */ + while(*--p != '\\') + if (p <= rootPos) /* already on root */ + return DE_PATHNOTFND; + /* the separator was removed -> add it again */ + ++src; /* skip the second dot */ + /* If / or \, next turn will find them and + assign addSep = ADD */ + addSep = ADD_UNLESS_LAST; + continue; /* next char */ } - src++; - if (bufp[-1] == ':') - bufp++; - } - else if (*src == '/' || *src == '\\' || *src == 0) - break; - /* --bufp; */ - else - return DE_PATHNOTFND; } - else if (*src == '/' || *src == '\\' || *src == 0) - { - break; + + /* ill-formed .* or ..* entries => return error */ + errRet: + /* The error is either PATHNOTFND or FILENOTFND + depending on if it is not the last component */ + return fstrchr(src, '/') == 0 && fstrchr(src, '\\') == 0 + ? DE_FILENOTFND + : DE_PATHNOTFND; + default: /* normal component */ + if (addSep != DONT_ADD) + { /* append backslash */ + addChar(*rootPos); + addSep = DONT_ADD; } - else + + /* append component in 8.3 convention */ + --src; + /* first character skipped in switch() */ + i = parse_name_ext(FNAME_SIZE, &src, &p, dest); + if (i == -1) + PATH_ERROR; + if (i & PNE_WILDCARD) + gotAnyWildcards = TRUE; + /* strip trailing dot */ + if ((i & PNE_DOT) && *src != '/' && *src != '\\' && *src != '\0') { - n = 4; - *bufp++ = c; - } - break; - - default: - *bufp++ = c; + /* we arrive here only when an extension-dot has been found */ + addChar('.'); + i = parse_name_ext(FEXT_SIZE, &src, &p, dest); + if (i == -1 || i & PNE_DOT) /* multiple dots are ill-formed */ + PATH_ERROR; + if (i & PNE_WILDCARD) + gotAnyWildcards = TRUE; + } + --src; /* terminator or separator was skipped */ break; } } - - /* remove trailing backslashes */ - while (bufp[-1] == '\\') - --bufp; -#endif - -/* /// Beginning of new code. - Ron Cemer */ - bufp--; + if (addSep == ADD) { - char c, *bufend = buf + (sizeof(buf) - 1); - int gotAnyWildcards = 0; - int seglen, copylen, state; - int error = DE_PATHNOTFND; - while ((*src) && (bufp < bufend)) + /* MS DOS preserves a trailing '\\', so an access to "C:\\DOS\\" + or "CDS.C\\" fails. */ + /* But don't add the separator, if the last component was ".." */ + addChar('\\'); + } + + *p = '\0'; /* add the string terminator */ + DosUpFString(rootPos); /* upcase the file/path name */ + +/** Note: + Only the portions passed in by the user are upcased, because it is + assumed that the CDS is configured correctly and if it contains + lower case letters, it is required so **/ + + tn_printf(("Absolute logical path: \"%s\"\n", dest)); + + /* Now, all the steps 1) .. 7) are fullfilled. Join now */ + /* search, if this path is a joined drive */ + + if (dest[2] != '/' && (!(mode & CDS_MODE_SKIP_PHYSICAL)) && njoined) + { + for(i = 0; i < lastdrive; ++i) { - /* Skip duplicated slashes. */ - while ((*src == '/') || (*src == '\\')) - src++; - if (!(*src)) - break; - /* Find the end of this segment in the source string. */ - for (seglen = 0;; seglen++) - { - c = src[seglen]; - if (c == '\0') - { - error = DE_FILENOTFND; - break; + /* How many bytes must match */ + size_t j = fstrlen(CDSp[i].cdsCurrentPath); + /* the last component must end before the backslash offset and */ + /* the path the drive is joined to leads the logical path */ + if ((CDSp[i].cdsFlags & CDSJOINED) && (dest[j] == '\\' || dest[j] == '\0') + && fmemcmp(dest, CDSp[i].cdsCurrentPath, j) == 0) + { /* JOINed drive found */ + dest[0] = drNrToLetter(i); /* index is physical here */ + dest[1] = ':'; + if (dest[j] == '\0') + { /* Reduce to root direc */ + dest[2] = '\\'; + dest[3] = 0; + /* move the relative path right behind the drive letter */ } - else if ((c == '/') || (c == '\\')) - break; - } - if (seglen > 0) - { - /* Ignore all ".\" or "\." path segments. */ - if ((seglen != 1) || (*src != '.')) + else if (j != 2) { - /* Apply ".." to the path by removing - last path segment from buf. */ - if ((seglen == 2) && (src[0] == '.') && (src[1] == '.')) - { - if (bufp > (buf + rootEndPos)) - { - bufp--; - while ((bufp > (buf + rootEndPos)) - && (*bufp != '/') && (*bufp != '\\')) - bufp--; - } - else - { - /* .. in root dir illegal */ - return error; - } - } - else - { - /* New segment. If any wildcards in previous - segment(s), this is an invalid path. */ - if (gotAnyWildcards || src[0] == '.') - return error; - /* Append current path segment to result. */ - *(bufp++) = '\\'; - if (bufp >= bufend) - break; - copylen = state = 0; - for (i = 0; ((i < seglen) && (bufp < bufend)); i++) - { - c = src[i]; - gotAnyWildcards |= ((c == '?') || (c == '*')); - switch (state) - { - case 0: /* Copying filename (excl. extension) */ - if (c == '*') - { - while (copylen < FNAME_SIZE) - { - *(bufp++) = '?'; - if (bufp >= bufend) - break; - copylen++; - } - break; - } - if (c == '.') - { - if (src[i + 1] != '.' && i + 1 < seglen) - *(bufp++) = '.'; - copylen = 0; - state = 1; /* Copy extension next */ - break; - } - if (copylen < FNAME_SIZE) - { - *(bufp++) = c; - copylen++; - break; - } - break; - case 1: /* Copying extension */ - if (c == '*') - { - while (copylen < FEXT_SIZE) - { - *(bufp++) = '?'; - if (bufp >= bufend) - break; - copylen++; - } - } - if (c == '.') - return error; - if (copylen < FEXT_SIZE) - { - *(bufp++) = c; - copylen++; - } - break; - } - } - } + strcpy(dest + 2, dest + j); } - } /* if (seglen > 0) */ - src += seglen; - if (*src) - src++; - } /* while ( (*src) && (bufp < bufend) ) */ + result = (result & 0xffe0) | i; + current_ldt = &CDSp[i]; + result &= ~IS_NETWORK; + if (current_ldt->cdsFlags & CDSNETWDRV) + result |= IS_NETWORK; + tn_printf(("JOINed path: \"%S\"\n", dest)); + return result; + } + } + /* nothing found => continue normally */ } -/* /// End of new code. - Ron Cemer */ - - if (bufp == buf + 2) - ++bufp; - -exit_tn: - - *bufp++ = 0; - - /* finally, uppercase everything */ - DosUpString(buf); + if ((mode & CDS_MODE_CHECK_DEV_PATH) && (result & IS_DEVICE) && + !(result & IS_NETWORK) && dest[2] != '/' && !dir_exists(dest)) + return DE_PATHNOTFND; + + tn_printf(("Physical path: \"%s\"\n", dest)); + return result; +} - /* copy to user's buffer */ - fmemcpy(dest, buf, bufp - buf); +#if 0 +/********************************************** + Result of INTRSPY + + Calling RBIL's INT.COM in MS DOS v6.22 + +=== Script: MUX.SCR + +intercept 2fh + function 11h ; network redirector + subfunction 23h ; Qualify path and filename + on_entry + output "1123: IN: " (ds:SI->byte,asciiz,64) + on_exit + if (cflag == 1) + sameline " [FAIL " ax "]" + output "1123: OUT: " (es:dI->byte,asciiz,64) + output "1123: orig buffer: " (ds:sI->byte,asciiz,64) + function 12h + subfunction 21h + on_entry + output "1221: IN: " (ds:SI->byte,asciiz,64) + on_exit + if (cflag == 1) + sameline " [FAIL " ax "]" + output "1221: OUT: " (es:dI->byte,asciiz,64) + +=== Batch file: SPY_INT.BAT +@echo off +if exist report.out del report.out +cmdspy stop +cmdspy flush +cmdspy restart +int ax=0x6000 -buf ds:si="abcöflkgsxkf\0" -buf es:di="%256s" -int 0x21 -d es:di:128 >spy_int.out +cmdspy stop +cmdspy report report.out +more report.out +=== Intspy report file: REPORT.OUT +1123: IN: C:\INTRSPY\SPY_INT.BAT [FAIL 0001] +1123: OUT:  +1123: orig buffer: C:\INTRSPY\SPY_INT.BAT +1123: IN: int.??? [FAIL 0001] +1123: OUT: C:\INTRSPY +1123: orig buffer: int.??? +1123: IN: C:\TOOL\int.??? [FAIL 0001] +1123: OUT: C:\INTRSPY +1123: orig buffer: C:\TOOL\int.??? +1123: IN: spy_int.out [FAIL 0001] +1123: OUT: C:\TOOL\INT.??? +1123: orig buffer: spy_int.out +1123: IN: C:\TOOL\INT.COM [FAIL 0001] +1123: OUT: C:\INTRSPY\SPY_INT.OUT +1123: orig buffer: C:\TOOL\INT.COM +1123: IN: abcöflkgsxkf [FAIL 0001] +1123: OUT: C:\TOOL\INT.COM +1123: orig buffer: abcöflkgsxkf +1123: IN: C:\INTRSPY\SPY_INT.BAT [FAIL 0001] +1123: OUT: C:\INTRSPY\ABCÖFLKG +1123: orig buffer: C:\INTRSPY\SPY_INT.BAT +1123: IN: cmdspy.??? [FAIL 0001] +1123: OUT: C:\INTRSPY +1123: orig buffer: cmdspy.??? +1123: IN: C:\INTRSPY\CMDSPY.EXE [FAIL 0001] +1123: OUT: C:\INTRSPY +1123: orig buffer: C:\INTRSPY\CMDSPY.EXE +=== INT.COM output: SPY_INT.OUT + 000 CX=0000 DX=0000 +SI=4A5E DI=4A76 BP=FF70 SP=FF64 +CS=0000 DS=279D ES=279D SS=0000 CPU Flags: 0n00oditsz0a0p1c + +INT: 0x21 + +AX=0059 BX=0000 CX=0000 DX=0000 +SI=4A5E DI=4A76 BP=FF70 SP=FF64 +CS=0000 DS=279D ES=279D SS=0000 CPU Flags: 0N11odItSz0A0P1c +DOSERR: 0000 (0) + +* { +43(C) 3A(:) 5C(\) 49(I) 4E(N) 54(T) 52(R) 53(S) 50(P) 59(Y) 5C(\) 41(A) +42(B) 43(C) 99(Ö) 46(F) 4C(L) 4B(K) 47(G) 00(.) 3D(=) 30(0) 30(0) 30(0) +30(0) 20( ) 20( ) 20( ) 43(C) 58(X) 3D(=) 30(0) 30(0) 30(0) 30(0) 28(() +30(0) 29()) 20( ) 32(2) 38(8) 28(() 28(() 29()) 20( ) 33(3) 30(0) 28(() +30(0) 29()) 20( ) 32(2) 39(9) 28(() 29()) 29()) 20( ) 32(2) 30(0) 28(() +20( ) 29()) 20( ) 33(3) 32(2) 28(() 32(2) 29()) 20( ) 33(3) 38(8) 28(() +38(8) 29()) 20( ) 32(2) 38(8) 28(() 28(() 29()) 20( ) 32(2) 38(8) 28(() +28(() 29()) 20( ) 32(2) 39(9) 28(() 29()) 29()) 20( ) 32(2) 30(0) 28(() +20( ) 29()) 20( ) 33(3) 33(3) 28(() 33(3) 29()) 20( ) 33(3) 30(0) 28(() +30(0) 29()) 20( ) 32(2) 38(8) 28(() 28(() 29()) 20( ) 33(3) 30(0) 28(() +30(0) 29()) 20( ) 32(2) 39(9) 28(() 29()) 29()) } +=== + +The actual interesting lines are the 6th "IN:" of the report file. +The DOS interface passed _exactly_ the same string to MUX-11-23 as +written on command line, the same applied to "con\0", a device driver. + +***************************************/ - return SUCCESS; -} +#endif /* * Log: newstuff.c,v - for newer entries see "cvs log newstuff.c" diff --git a/kernel/nls.c b/kernel/nls.c index 28de4545..80ec6416 100644 --- a/kernel/nls.c +++ b/kernel/nls.c @@ -586,7 +586,7 @@ COUNT DosSetCountry(UWORD cntry) /* * Called for DOS-66-01 get CP */ -COUNT DosGetCodepage(UWORD FAR * actCP, UWORD FAR * sysCP) +COUNT DosGetCodepage(UWORD * actCP, UWORD * sysCP) { *sysCP = nlsInfo.sysCodePage; *actCP = nlsInfo.actPkg->cp; diff --git a/kernel/proto.h b/kernel/proto.h index 5330aba1..512f59bb 100644 --- a/kernel/proto.h +++ b/kernel/proto.h @@ -50,6 +50,7 @@ UWORD dskxfer(COUNT dsk, ULONG blkno, VOID FAR * buf, UWORD numblocks, /* *** End of change */ /* chario.c */ +UCOUNT BinaryCharIO(struct dhdr FAR * dev, UCOUNT n, void FAR * bp, unsigned command, COUNT *err); VOID sto(COUNT c); VOID cso(COUNT c); VOID mod_cso(REG UCOUNT c); @@ -66,36 +67,33 @@ UCOUNT sti(keyboard * kp); sft FAR *get_sft(UCOUNT); /* dosfns.c */ -BYTE FAR *get_root(BYTE FAR *); +const char FAR *get_root(const char FAR *); BOOL check_break(void); -UCOUNT GenericReadSft(sft far * sftp, UCOUNT n, BYTE FAR * bp, - COUNT FAR * err, BOOL force_binary); +UCOUNT GenericReadSft(sft far * sftp, UCOUNT n, void FAR * bp, + COUNT * err, BOOL force_binary); COUNT SftSeek(sft FAR * sftp, LONG new_pos, COUNT mode); /*COUNT DosRead(COUNT hndl, UCOUNT n, BYTE FAR * bp, COUNT FAR * err); */ -#define GenericRead(hndl, n, bp, err, t) GenericReadSft(get_sft(hndl), n, bp, err, t) -#define DosRead(hndl, n, bp, err) GenericRead(hndl, n, bp, err, FALSE) -#define DosReadSft(sftp, n, bp, err) GenericReadSft(sftp, n, bp, err, FALSE) -UCOUNT DosWriteSft(sft FAR * sftp, UCOUNT n, const BYTE FAR * bp, - COUNT FAR * err); -#define DosWrite(hndl, n, bp, err) DosWriteSft(get_sft(hndl), n, bp, err) -COUNT DosSeek(COUNT hndl, LONG new_pos, COUNT mode, ULONG * set_pos); -COUNT DosCreat(BYTE FAR * fname, COUNT attrib); -COUNT DosCreatSft(BYTE * fname, COUNT attrib); -COUNT CloneHandle(COUNT hndl); -COUNT DosDup(COUNT Handle); -COUNT DosForceDup(COUNT OldHandle, COUNT NewHandle); -COUNT DosOpen(BYTE FAR * fname, COUNT mode); -COUNT DosOpenSft(BYTE * fname, COUNT mode); +UCOUNT BinaryReadSft(sft FAR * s, void *bp, COUNT *err); +#define BinaryRead(hndl, bp, err) BinaryReadSft(get_sft(hndl), bp, err) +UCOUNT DosRWSft(sft FAR * s, UCOUNT n, void FAR * bp, COUNT *err, int mode); +#define DosRead(hndl, n, bp, err) DosRWSft(get_sft(hndl), n, bp, err, XFR_READ) +#define DosWrite(hndl, n, bp, err) DosRWSft(get_sft(hndl), n, bp, err, XFR_WRITE) +ULONG DosSeek(COUNT hndl, LONG new_pos, COUNT mode); +long DosOpen(char FAR * fname, unsigned flags, unsigned attrib); +COUNT CloneHandle(unsigned hndl); +long DosDup(unsigned Handle); +COUNT DosForceDup(unsigned OldHandle, unsigned NewHandle); +long DosOpenSft(char FAR * fname, unsigned flags, unsigned attrib); COUNT DosClose(COUNT hndl); COUNT DosCloseSft(WORD sft_idx, BOOL commitonly); #define DosCommit(hndl) DosCloseSft(get_sft_idx(hndl), TRUE) -BOOL DosGetFree(UBYTE drive, UCOUNT FAR * spc, UCOUNT FAR * navc, - UCOUNT FAR * bps, UCOUNT FAR * nc); +BOOL DosGetFree(UBYTE drive, UWORD * spc, UWORD * navc, + UWORD * bps, UWORD * nc); COUNT DosGetCuDir(UBYTE drive, BYTE FAR * s); COUNT DosChangeDir(BYTE FAR * s); COUNT DosFindFirst(UCOUNT attr, BYTE FAR * name); COUNT DosFindNext(void); -COUNT DosGetFtime(COUNT hndl, date FAR * dp, time FAR * tp); +COUNT DosGetFtime(COUNT hndl, date * dp, time * tp); COUNT DosSetFtimeSft(WORD sft_idx, date dp, time tp); #define DosSetFtime(hndl, dp, tp) DosSetFtimeSft(get_sft_idx(hndl), (dp), (tp)) COUNT DosGetFattr(BYTE FAR * name); @@ -104,21 +102,20 @@ UBYTE DosSelectDrv(UBYTE drv); COUNT DosDelete(BYTE FAR * path, int attrib); COUNT DosRename(BYTE FAR * path1, BYTE FAR * path2); COUNT DosRenameTrue(BYTE * path1, BYTE * path2, int attrib); -COUNT DosMkdir(BYTE FAR * dir); -COUNT DosRmdir(BYTE FAR * dir); -struct dhdr FAR *IsDevice(BYTE FAR * FileName); +COUNT DosMkdir(const char FAR * dir); +COUNT DosRmdir(const char FAR * dir); +struct dhdr FAR *IsDevice(const char FAR * FileName); BOOL IsShareInstalled(void); COUNT DosLockUnlock(COUNT hndl, LONG pos, LONG len, COUNT unlock); sft FAR *idx_to_sft(COUNT SftIndex); COUNT get_sft_idx(UCOUNT hndl); +COUNT DosTruename(const char FAR * src, char FAR * dest); /*dosidle.asm */ VOID ASMCFUNC DosIdle_int(void); /* dosnames.c */ -VOID SpacePad(BYTE *, COUNT); -COUNT ParseDosName(BYTE *, COUNT *, BYTE *, BYTE *, BYTE *, BOOL); -/*COUNT ParseDosPath(BYTE *, COUNT *, BYTE *, BYTE FAR *); */ +int ParseDosName(const char *, char *, BOOL); /* error.c */ VOID dump(void); @@ -127,7 +124,7 @@ VOID fatal(BYTE * err_msg); /* fatdir.c */ VOID dir_init_fnode(f_node_ptr fnp, CLUSTER dirstart); -f_node_ptr dir_open(BYTE * dirname); +f_node_ptr dir_open(const char *dirname); COUNT dir_read(REG f_node_ptr fnp); BOOL dir_write(REG f_node_ptr fnp); VOID dir_close(REG f_node_ptr fnp); @@ -138,13 +135,12 @@ int FileName83Length(BYTE * filename83); /* fatfs.c */ ULONG clus2phys(CLUSTER cl_no, struct dpb FAR * dpbp); -COUNT dos_open(BYTE * path, COUNT flag); -BOOL fcmp(BYTE * s1, BYTE * s2, COUNT n); -BOOL fcmp_wild(BYTE FAR * s1, BYTE FAR * s2, COUNT n); +long dos_open(char * path, unsigned flag, unsigned attrib); +BOOL fcbmatch(const char *fcbname1, const char *fcbname2); +BOOL fcmp_wild(const char * s1, const char * s2, unsigned n); VOID touc(BYTE * s, COUNT n); COUNT dos_close(COUNT fd); COUNT dos_commit(COUNT fd); -COUNT dos_creat(BYTE * path, int attrib); COUNT dos_delete(BYTE * path, int attrib); COUNT dos_rmdir(BYTE * path); COUNT dos_rename(BYTE * path1, BYTE * path2, int attrib); @@ -152,8 +148,7 @@ date dos_getdate(void); time dos_gettime(void); COUNT dos_getftime(COUNT fd, date FAR * dp, time FAR * tp); COUNT dos_setftime(COUNT fd, date dp, time tp); -LONG dos_getcufsize(COUNT fd); -LONG dos_getfsize(COUNT fd); +ULONG dos_getfsize(COUNT fd); BOOL dos_setfsize(COUNT fd, LONG size); COUNT dos_mkdir(BYTE * dir); BOOL last_link(f_node_ptr fnp); @@ -163,6 +158,7 @@ COUNT dos_read(COUNT fd, VOID FAR * buffer, UCOUNT count); COUNT dos_write(COUNT fd, const VOID FAR * buffer, UCOUNT count); LONG dos_lseek(COUNT fd, LONG foffset, COUNT origin); CLUSTER dos_free(struct dpb FAR * dpbp); +BOOL dir_exists(char * path); VOID trim_path(BYTE FAR * s); @@ -171,6 +167,7 @@ COUNT dos_cd(struct cds FAR * cdsp, BYTE * PathName); f_node_ptr get_f_node(void); VOID release_f_node(f_node_ptr fnp); VOID dos_setdta(BYTE FAR * newdta); +COUNT dos_getfattr_fd(COUNT fd); COUNT dos_getfattr(BYTE * name); COUNT dos_setfattr(BYTE * name, UWORD attrp); COUNT media_check(REG struct dpb FAR * dpbp); @@ -192,43 +189,35 @@ int DosCharInput(VOID); VOID DosDirectConsoleIO(iregs FAR * r); VOID DosCharOutput(COUNT c); VOID DosDisplayOutput(COUNT c); -VOID FatGetDrvData(UCOUNT drive, UCOUNT FAR * spc, UCOUNT FAR * bps, - UCOUNT FAR * nc, BYTE FAR ** mdp); -WORD FcbParseFname(int wTestMode, const BYTE FAR ** lpFileName, fcb FAR * lpFcb); +BYTE FAR *FatGetDrvData(UBYTE drive, UWORD * spc, UWORD * bps, + UWORD * nc); +UWORD FcbParseFname(int *wTestMode, const BYTE FAR *lpFileName, fcb FAR * lpFcb); const BYTE FAR *ParseSkipWh(const BYTE FAR * lpFileName); BOOL TestCmnSeps(BYTE FAR * lpFileName); BOOL TestFieldSeps(BYTE FAR * lpFileName); const BYTE FAR *GetNameField(const BYTE FAR * lpFileName, BYTE FAR * lpDestField, COUNT nFieldSize, BOOL * pbWildCard); -typedef BOOL FcbFunc_t (xfcb FAR *, COUNT *, UCOUNT); -FcbFunc_t FcbRead, FcbWrite; -BOOL FcbGetFileSize(xfcb FAR * lpXfcb); -BOOL FcbSetRandom(xfcb FAR * lpXfcb); -BOOL FcbCalcRec(xfcb FAR * lpXfcb); -BOOL FcbRandomBlockRead(xfcb FAR * lpXfcb, COUNT nRecords, - COUNT * nErrorCode); -BOOL FcbRandomBlockWrite(xfcb FAR * lpXfcb, COUNT nRecords, - COUNT * nErrorCode); -BOOL FcbRandomIO(xfcb FAR * lpXfcb, COUNT * nErrorCode, FcbFunc_t *FcbFunc); -BOOL FcbOpenCreate(xfcb FAR * lpXfcb, BOOL Create); -#define FcbOpen(fcb) FcbOpenCreate(fcb, FALSE) -#define FcbCreate(fcb) FcbOpenCreate(fcb, TRUE) -void FcbNameInit(fcb FAR * lpFcb, BYTE * pszBuffer, COUNT * pCurDrive); -BOOL FcbDelete(xfcb FAR * lpXfcb); -BOOL FcbRename(xfcb FAR * lpXfcb); -BOOL FcbClose(xfcb FAR * lpXfcb); -VOID FcbCloseAll(VOID); -BOOL FcbFindFirst(xfcb FAR * lpXfcb); -BOOL FcbFindNext(xfcb FAR * lpXfcb); +UBYTE FcbReadWrite(xfcb FAR *, UCOUNT, int); +UBYTE FcbGetFileSize(xfcb FAR * lpXfcb); +void FcbSetRandom(xfcb FAR * lpXfcb); +UBYTE FcbRandomBlockIO(xfcb FAR * lpXfcb, COUNT nRecords, int mode); +UBYTE FcbRandomIO(xfcb FAR * lpXfcb, int mode); +UBYTE FcbOpen(xfcb FAR * lpXfcb, unsigned flags); +int FcbNameInit(fcb FAR * lpFcb, BYTE * pszBuffer, COUNT * pCurDrive); +UBYTE FcbDelete(xfcb FAR * lpXfcb); +UBYTE FcbRename(xfcb FAR * lpXfcb); +UBYTE FcbClose(xfcb FAR * lpXfcb); +void FcbCloseAll(void); +UBYTE FcbFindFirstNext(xfcb FAR * lpXfcb, BOOL First); /* ioctl.c */ -COUNT DosDevIOctl(iregs FAR * r); +COUNT DosDevIOctl(lregs * r); /* memmgr.c */ seg far2para(VOID FAR * p); seg long2para(ULONG size); VOID FAR *add_far(VOID FAR * fp, ULONG off); -void FAR *adjust_far(const void FAR * fp); +VOID FAR *adjust_far(const void FAR * fp); COUNT DosMemAlloc(UWORD size, COUNT mode, seg FAR * para, UWORD FAR * asize); COUNT DosMemLargest(UWORD FAR * size); @@ -242,12 +231,16 @@ VOID DosUmbLink(BYTE n); VOID mcb_print(mcb FAR * mcbp); /* misc.c */ -VOID ASMCFUNC strcpy(REG BYTE * d, REG const BYTE * s); -VOID ASMCFUNC fmemcpy(REG VOID FAR * d, REG const VOID FAR * s, REG COUNT n); -VOID ASMCFUNC fstrcpy(REG BYTE FAR * d, REG const BYTE FAR * s); -void ASMCFUNC memcpy(REG void *d, REG const VOID * s, REG COUNT n); -void ASMCFUNC fmemset(REG VOID FAR * s, REG int ch, REG COUNT n); -void ASMCFUNC memset(REG VOID * s, REG int ch, REG COUNT n); +char * ASMCFUNC strcpy(char * d, const char * s); +void ASMCFUNC fmemcpyBack(void FAR * d, const void FAR * s, size_t n); +void ASMCFUNC fmemcpy(void FAR * d, const void FAR * s, size_t n); +void ASMCFUNC fstrcpy(char FAR * d, const char FAR * s); +void * ASMCFUNC memcpy(void *d, const void * s, size_t n); +void ASMCFUNC fmemset(void FAR * s, int ch, size_t n); +void * ASMCFUNC memset(void * s, int ch, size_t n); + +int ASMCFUNC memcmp(const void *m1, const void *m2, size_t n); +int ASMCFUNC fmemcmp(const void FAR *m1, const void FAR *m2, size_t n); /* lfnapi.c */ COUNT lfn_allocate_inode(VOID); @@ -279,27 +272,29 @@ COUNT DosGetCountryInformation(UWORD cntry, VOID FAR * buf); #ifndef DosSetCountry COUNT DosSetCountry(UWORD cntry); #endif -COUNT DosGetCodepage(UWORD FAR * actCP, UWORD FAR * sysCP); +COUNT DosGetCodepage(UWORD * actCP, UWORD * sysCP); COUNT DosSetCodepage(UWORD actCP, UWORD sysCP); UWORD ASMCFUNC syscall_MUX14(DIRECT_IREGS); /* prf.c */ VOID put_console(COUNT c); -WORD CDECL printf(CONST BYTE * fmt, ...); -WORD CDECL sprintf(BYTE * buff, CONST BYTE * fmt, ...); +int CDECL printf(CONST BYTE * fmt, ...); +int CDECL sprintf(BYTE * buff, CONST BYTE * fmt, ...); VOID hexd(char *title, VOID FAR * p, COUNT numBytes); /* strings.c */ -COUNT ASMCFUNC strlen(REG BYTE * s); -COUNT ASMCFUNC fstrlen(REG BYTE FAR * s); -VOID ASMCFUNC _fstrcpy(REG BYTE FAR * d, REG BYTE FAR * s); -VOID ASMCFUNC strncpy(REG BYTE * d, REG BYTE * s, COUNT l); -COUNT ASMCFUNC strcmp(REG BYTE * d, REG BYTE * s); -COUNT ASMCFUNC fstrcmp(REG BYTE FAR * d, REG BYTE FAR * s); -COUNT ASMCFUNC fstrncmp(REG BYTE FAR * d, REG BYTE FAR * s, COUNT l); -COUNT ASMCFUNC strncmp(REG BYTE * d, REG BYTE * s, COUNT l); -void ASMCFUNC fstrncpy(REG BYTE FAR * d, REG BYTE FAR * s, COUNT l); -BYTE * ASMCFUNC strchr(const BYTE * s, BYTE c); +size_t ASMCFUNC strlen(const char * s); +size_t ASMCFUNC fstrlen(const char FAR * s); +char FAR * ASMCFUNC _fstrcpy(char FAR * d, const char FAR * s); +char * ASMCFUNC strncpy(char * d, const char * s, size_t l); +int ASMCFUNC strcmp(const char * d, const char * s); +int ASMCFUNC fstrcmp(const char FAR * d, const char FAR * s); +int ASMCFUNC fstrncmp(const char FAR * d, const char FAR * s, size_t l); +int ASMCFUNC strncmp(const char * d, const char * s, size_t l); +void ASMCFUNC fstrncpy(char FAR * d, const char FAR * s, size_t l); +char * ASMCFUNC strchr(const char * s, int c); +char FAR * ASMCFUNC fstrchr(const char FAR * s, int c); +void FAR * ASMCFUNC fmemchr(const void FAR * s, int c, size_t n); /* sysclk.c */ COUNT BcdToByte(COUNT x); @@ -309,19 +304,17 @@ LONG WordToBcd(BYTE * x, UWORD * mon, UWORD * day, UWORD * yr); /* syspack.c */ #ifdef NONNATIVE -VOID getdirent(BYTE FAR * vp, struct dirent FAR * dp); -VOID putdirent(struct dirent FAR * dp, BYTE FAR * vp); +VOID getdirent(UBYTE FAR * vp, struct dirent FAR * dp); +VOID putdirent(struct dirent FAR * dp, UBYTE FAR * vp); #else #define getdirent(vp, dp) fmemcpy(dp, vp, sizeof(struct dirent)) #define putdirent(dp, vp) fmemcpy(vp, dp, sizeof(struct dirent)) #endif /* systime.c */ -VOID DosGetTime(BYTE FAR * hp, BYTE FAR * mp, BYTE FAR * sp, - BYTE FAR * hdp); +VOID DosGetTime(UBYTE * hp, UBYTE * mp, UBYTE * sp, UBYTE * hdp); COUNT DosSetTime(BYTE h, BYTE m, BYTE s, BYTE hd); -VOID DosGetDate(BYTE FAR * wdp, BYTE FAR * mp, BYTE FAR * mdp, - COUNT FAR * yp); +VOID DosGetDate(UBYTE * wdp, UBYTE * mp, UBYTE * mdp, UWORD * yp); COUNT DosSetDate(UWORD Month, UWORD DayOfMonth, UWORD Year); const UWORD *is_leap_year_monthdays(UWORD year); @@ -337,8 +330,8 @@ VOID InitPSP(VOID); /* newstuff.c */ int SetJFTSize(UWORD nHandles); int DosMkTmp(BYTE FAR * pathname, UWORD attr); -COUNT get_verify_drive(char FAR * src); -COUNT truename(char FAR * src, char FAR * dest, COUNT t); +COUNT get_verify_drive(const char FAR * src); +COUNT truename(const char FAR * src, char * dest, COUNT t); /* network.c */ COUNT ASMCFUNC remote_doredirect(UWORD b, UCOUNT n, UWORD d, VOID FAR * s, @@ -358,6 +351,7 @@ COUNT ASMCFUNC remote_findnext(VOID FAR * s); COUNT ASMCFUNC remote_getfattr(VOID); COUNT ASMCFUNC remote_getfree(VOID FAR * s, VOID * d); COUNT ASMCFUNC remote_open(sft FAR * s, COUNT mode); +int ASMCFUNC remote_extopen(sft FAR * s, unsigned attr); LONG ASMCFUNC remote_lseek(sft FAR * s, LONG new_pos); UCOUNT ASMCFUNC remote_read(sft FAR * s, UCOUNT n, COUNT * err); UCOUNT ASMCFUNC remote_write(sft FAR * s, UCOUNT n, COUNT * err); @@ -366,7 +360,7 @@ COUNT ASMCFUNC remote_setfattr(COUNT attr); COUNT ASMCFUNC remote_printredir(UCOUNT dx, UCOUNT ax); COUNT ASMCFUNC remote_commit(sft FAR * s); COUNT ASMCFUNC remote_close(sft FAR * s); -COUNT ASMCFUNC QRemote_Fn(char FAR * s, char FAR * d); +COUNT ASMCFUNC QRemote_Fn(char FAR * d, const char FAR * s); UWORD get_machine_name(BYTE FAR * netname); VOID set_machine_name(BYTE FAR * netname, UWORD name_num); diff --git a/kernel/systime.c b/kernel/systime.c index 4dd90c2a..a73711b1 100644 --- a/kernel/systime.c +++ b/kernel/systime.c @@ -74,16 +74,10 @@ UWORD DaysFromYearMonthDay(UWORD Year, UWORD Month, UWORD DayOfMonth) /* common - call the clock driver */ void ExecuteClockDriverRequest(BYTE command) { - ClkReqHdr.r_length = sizeof(request); - ClkReqHdr.r_command = command; - ClkReqHdr.r_count = sizeof(struct ClockRecord); - ClkReqHdr.r_trans = (BYTE FAR *) (&ClkRecord); - ClkReqHdr.r_status = 0; - execrh((request FAR *) & ClkReqHdr, (struct dhdr FAR *)clock); + BinaryCharIO(clock, sizeof(struct ClockRecord), &ClkRecord, command, &UnusedRetVal); } -VOID DosGetTime(BYTE FAR * hp, BYTE FAR * mp, BYTE FAR * sp, - BYTE FAR * hdp) +VOID DosGetTime(UBYTE * hp, UBYTE * mp, UBYTE * sp, UBYTE * hdp) { ExecuteClockDriverRequest(C_INPUT); @@ -113,9 +107,7 @@ COUNT DosSetTime(BYTE h, BYTE m, BYTE s, BYTE hd) return SUCCESS; } -VOID DosGetDate(wdp, mp, mdp, yp) -BYTE FAR *wdp, FAR * mp, FAR * mdp; -COUNT FAR *yp; +VOID DosGetDate(UBYTE *wdp, UBYTE *mp, UBYTE *mdp, UWORD *yp) { UWORD c; const UWORD *pdays; diff --git a/kernel/task.c b/kernel/task.c index 4bd5c7f8..3fcc09b5 100644 --- a/kernel/task.c +++ b/kernel/task.c @@ -461,7 +461,6 @@ COUNT DosComLoader(BYTE FAR * namep, exec_blk * exp, COUNT mode, COUNT fd) /* Now load the executable */ { BYTE FAR *sp; - ULONG tmp; if (mode == OVERLAY) /* memory already allocated */ sp = MK_FP(mem, 0); @@ -472,7 +471,7 @@ COUNT DosComLoader(BYTE FAR * namep, exec_blk * exp, COUNT mode, COUNT fd) -- 1999/04/21 ska */ /* rewind to start */ - DosSeek(fd, 0, 0, &tmp); + DosSeek(fd, 0, 0); /* read everything, but at most 64K - sizeof(PSP) */ DosRead(fd, 0xff00, sp, &UnusedRetVal); DosClose(fd); @@ -552,7 +551,7 @@ VOID return_user(void) COUNT DosExeLoader(BYTE FAR * namep, exec_blk * exp, COUNT mode, COUNT fd) { UWORD mem, env, start_seg, asize = 0; - ULONG exe_size, tmp; + ULONG exe_size; { ULONG image_size; ULONG image_offset; @@ -646,8 +645,7 @@ COUNT DosExeLoader(BYTE FAR * namep, exec_blk * exp, COUNT mode, COUNT fd) /* Now load the executable */ /* offset to start of image */ - DosSeek(fd, image_offset, 0, &tmp); - if (tmp != image_offset) + if (DosSeek(fd, image_offset, 0) != image_offset) { if (mode != OVERLAY) { @@ -696,9 +694,8 @@ COUNT DosExeLoader(BYTE FAR * namep, exec_blk * exp, COUNT mode, COUNT fd) COUNT i; UWORD reloc[2]; seg FAR *spot; - ULONG tmp; - DosSeek(fd, ExeHeader.exRelocTable, 0, &tmp); + DosSeek(fd, ExeHeader.exRelocTable, 0); for (i = 0; i < ExeHeader.exRelocItems; i++) { if (DosRead @@ -765,11 +762,7 @@ COUNT DosExec(COUNT mode, exec_blk FAR * ep, BYTE FAR * lp) /* If file not found - free ram and return error */ if (IsDevice(lp) || /* we don't want to execute C:>NUL */ -#if 0 (fd = (short)DosOpen(lp, O_LEGACY | O_OPEN | O_RDONLY, 0)) < 0) -#else - (fd = (short)DosOpen(lp, 0)) < 0) -#endif { return DE_FILENOTFND; } diff --git a/sys/makefile b/sys/makefile index bcb815a8..7acff455 100644 --- a/sys/makefile +++ b/sys/makefile @@ -20,7 +20,7 @@ SYS_EXE_dependencies = \ production: bin2c.com ..\bin\sys.com bin2c.com: bin2c.c - $(CL) $(CFLAGST) $(TINY) bin2c.c + $(CL) $(CFLAGS) $(TINY) bin2c.c ..\bin\sys.com: sys.com copy sys.com ..\bin diff --git a/sys/sys.c b/sys/sys.c index 45f243d8..9046ce0c 100644 --- a/sys/sys.c +++ b/sys/sys.c @@ -622,8 +622,7 @@ VOID put_boot(COUNT drive, BYTE * bsFile, BOOL both) temp = bs32->sysFatSecMask + 1; for (bs32->sysFatSecShift = 0; temp != 1; bs32->sysFatSecShift++, temp >>= 1) ; - - /* use fixed drive for A:, B: and DL otherwise */ + /* put 0 for A: or B: (force booting from A:), otherwise use DL */ bs32->bsDriveNumber = drive < 2 ? 0 : 0xff; } #ifdef DEBUG @@ -659,9 +658,8 @@ VOID put_boot(COUNT drive, BYTE * bsFile, BOOL both) /* sector data starts on */ temp = temp + bs->sysRootDirSecs; bs->sysDataStart = temp; - - /* use fixed BIOS drive 0 for A:, B: and DL otherwise */ - bs32->bsDriveNumber = drive < 2 ? 0 : 0xff; + /* put 0 for A: or B: (force booting from A:), otherwise use DL */ + bs->bsDriveNumber = drive < 2 ? 0 : 0xff; } #ifdef DEBUG From 2c6dbdf194118324d2b7e7a875db6dda439ab5fe Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sun, 4 Aug 2002 10:26:31 +0000 Subject: [PATCH 150/671] Fix compilation using -p or -DDEBUG git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@415 6ac86273-5f31-0410-b378-82cca8765d1b --- bin/config.sys | 2 ++ hdr/nls.h | 2 +- kernel/fatfs.c | 4 ++-- kernel/globals.h | 4 +++- kernel/initdisk.c | 2 +- 5 files changed, 9 insertions(+), 5 deletions(-) diff --git a/bin/config.sys b/bin/config.sys index b3c420cd..1810c89d 100644 --- a/bin/config.sys +++ b/bin/config.sys @@ -1,3 +1,5 @@ +rem dos=high +rem device=fdxms.sys (or himem.sys) files=20 buffers=20 rem screen=0x12 diff --git a/hdr/nls.h b/hdr/nls.h index d5915410..cf9c8492 100644 --- a/hdr/nls.h +++ b/hdr/nls.h @@ -453,7 +453,7 @@ extern struct nlsInfoBlock nlsInfo; extern struct nlsPackage ASM nlsPackageHardcoded; /* These are the "must have" tables within the hard coded NLS pkg */ extern struct nlsFnamTerm nlsFnameTermHardcoded; -extern struct nlsDBCS nlsDBCSHardcoded; +extern struct nlsDBCS ASM nlsDBCSHardcoded; extern struct nlsCharTbl nlsUpcaseHardcoded; extern struct nlsCharTbl nlsFUpcaseHardcoded; extern struct nlsCharTbl nlsCollHardcoded; diff --git a/kernel/fatfs.c b/kernel/fatfs.c index d733bc5b..a9d9b9e7 100644 --- a/kernel/fatfs.c +++ b/kernel/fatfs.c @@ -322,8 +322,8 @@ f_node_ptr split_path(char * path, char * fcbname) #ifdef DEBUG if (CDSp[path[0]-'A'].cdsFlags & CDSNETWDRV) { - printf("split path called for redirected file: `%s.%s'\n", - fname, fext); + printf("split path called for redirected file: `%s'\n", + fcbname); return (f_node_ptr) 0; } #endif diff --git a/kernel/globals.h b/kernel/globals.h index 91891e38..392d51d8 100644 --- a/kernel/globals.h +++ b/kernel/globals.h @@ -287,7 +287,9 @@ extern BYTE ASM ErrorMode, /* Critical error flag */ ASM InDOS, /* In DOS critical section */ ASM OpenMode, /* File Open Attributes */ ASM SAttr, /* Attrib Mask for Dir Search */ - ASM dosidle_flag, ASM Server_Call, ASM CritErrLocus, ASM CritErrAction, ASM CritErrClass, VgaSet, njoined; /* number of joined devices */ + ASM dosidle_flag, ASM Server_Call, ASM CritErrLocus, ASM CritErrAction, + ASM CritErrClass, ASM VgaSet, + ASM njoined; /* number of joined devices */ extern UWORD ASM Int21AX; extern COUNT ASM CritErrCode; diff --git a/kernel/initdisk.c b/kernel/initdisk.c index 5b1b5d78..f054c3ed 100644 --- a/kernel/initdisk.c +++ b/kernel/initdisk.c @@ -43,7 +43,7 @@ extern COUNT DOSFAR nUnits; extern UWORD DOSFAR LBA_WRITE_VERIFY; /* floppy parameter table, at 70:xxxx */ -extern unsigned char DOSTEXTFAR int1e_table[0xe]; +extern unsigned char DOSTEXTFAR ASM int1e_table[0xe]; /* * Rev 1.0 13 May 2001 tom ehlert From 31591f162ce845f5a5e2a43779cae29844cc8662 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Mon, 5 Aug 2002 19:56:38 +0000 Subject: [PATCH 151/671] Improved line character input; exExtraBytes fix. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@416 6ac86273-5f31-0410-b378-82cca8765d1b --- hdr/kbd.h | 4 +- hdr/tail.h | 6 +- kernel/chario.c | 235 ++++++++++++++++++++++++++-------------------- kernel/dosfns.c | 33 ++++--- kernel/globals.h | 15 +-- kernel/kernel.asm | 10 +- kernel/proto.h | 6 +- utils/exeflat.c | 4 +- 8 files changed, 180 insertions(+), 133 deletions(-) diff --git a/hdr/kbd.h b/hdr/kbd.h index 4894665a..faa4914f 100644 --- a/hdr/kbd.h +++ b/hdr/kbd.h @@ -35,7 +35,9 @@ static BYTE *kbd_hRcsId = #endif #endif -#define KBD_MAXLENGTH 256 +#define LINEBUFSIZECON 128 +#define KBD_MAXLENGTH LINEBUFSIZECON+1 /* the above + LF */ +#define LINEBUFSIZE0A 256 /* maximum length for int21/ah=0a */ /* Keyboard buffer */ typedef struct { diff --git a/hdr/tail.h b/hdr/tail.h index 2b36d281..e093ccc6 100644 --- a/hdr/tail.h +++ b/hdr/tail.h @@ -35,13 +35,11 @@ static BYTE *tail_hRcsId = #endif #endif -#ifndef LINESIZE -#define LINESIZE 127 -#endif +#define CTBUFFERSIZE 127 typedef struct { UBYTE ctCount; /* number of bytes returned */ - BYTE ctBuffer[LINESIZE]; /* the buffer itself */ + char ctBuffer[CTBUFFERSIZE]; /* the buffer itself */ } CommandTail; /* diff --git a/kernel/chario.c b/kernel/chario.c index 3f3f53c3..004d2279 100644 --- a/kernel/chario.c +++ b/kernel/chario.c @@ -37,14 +37,6 @@ static BYTE *charioRcsId = #include "globals.h" -#ifdef PROTO -STATIC VOID kbfill(keyboard FAR *, UCOUNT, BOOL, UWORD *); -struct dhdr FAR *finddev(UWORD attr_mask); -#else -STATIC VOID kbfill(); -struct dhdr FAR *finddev(); -#endif - /* Return a pointer to the first driver in the chain that * matches the attributes. * not necessary because we have the syscon pointer. @@ -155,7 +147,7 @@ VOID sto(COUNT c) DosWrite(STDOUT, 1, (BYTE FAR *) & c, & UnusedRetVal); } -VOID mod_cso(REG UCOUNT c) +unsigned mod_cso(register unsigned c) { if (c < ' ' && c != HT) { @@ -164,6 +156,7 @@ VOID mod_cso(REG UCOUNT c) } else cso(c); + return c; } VOID destr_bs(void) @@ -285,47 +278,25 @@ VOID KbdFlush(void) execrh((request FAR *) & CharReqHdr, syscon); } -STATIC VOID kbfill(keyboard FAR * kp, UCOUNT c, BOOL ctlf, UWORD * vp) +/* reads a line */ +void sti_0a(keyboard FAR * kp) { - if (kp->kb_count >= kp->kb_size) - { - cso(BELL); + REG UWORD c, cu_pos = scr_pos; + unsigned count = 0, stored_pos = 0, size = kp->kb_size, stored_size = kp->kb_count; + BOOL insert = FALSE; + + if (size == 0) return; - } - kp->kb_buf[kp->kb_count++] = c; - if (!ctlf) - { - mod_cso(c); - *vp += 2; - } - else + + /* the stored line is invalid unless it ends with a CR */ + if (kp->kb_buf[stored_size] != CR) { - cso(c); - if (c != HT) - ++ * vp; - else - *vp = (*vp + 8) & -8; + stored_size = 0; } -} - -/* return number of characters before EOF if there is one, else just the total */ -UCOUNT sti_0a(keyboard FAR * kp) -{ - REG UWORD c, cu_pos = scr_pos; - UWORD virt_pos = scr_pos; - UWORD init_count = 0; /* kp->kb_count; */ - BOOL eof = FALSE; -#ifndef NOSPCL - static BYTE local_buffer[LINESIZE]; -#endif - - if (kp->kb_size == 0) - return eof; - /* if (kp->kb_size <= kp->kb_count || kp->kb_buf[kp->kb_count] != CR) */ - kp->kb_count = 0; - FOREVER + + while ((c = _sti(TRUE)) != CR) { - switch (c = _sti(TRUE)) + switch (c) { case CTL_C: handle_break(); @@ -339,23 +310,53 @@ UCOUNT sti_0a(keyboard FAR * kp) case LEFT: goto backspace; - case F3: + case RIGHT: + case F1: + if (stored_pos < stored_size && count < size - 1) + local_buffer[count++] = mod_cso(kp->kb_buf[stored_pos++]); + break; + + case F2: + c = _sti(TRUE); + /* insert up to character c */ + insert_to_c: + while (stored_pos < stored_size && count < size - 1) { - REG COUNT i; - - for (i = kp->kb_count; local_buffer[i] != '\0'; i++) - { - c = local_buffer[kp->kb_count]; - kbfill(kp, c, FALSE, &virt_pos); - } - break; + char c2 = kp->kb_buf[stored_pos]; + if (c2 == c) + break; + stored_pos++; + local_buffer[count++] = mod_cso(c2); } - - case F1: - case RIGHT: - c = local_buffer[kp->kb_count]; - if (c) - kbfill(kp, c, FALSE, &virt_pos); + break; + + case F3: + c = (unsigned)-1; + goto insert_to_c; + + case F4: + c = _sti(TRUE); + /* delete up to character c */ + while (stored_pos < stored_size && c != kp->kb_buf[stored_pos]) + stored_pos++; + break; + + case F5: + fmemcpy(kp->kb_buf, local_buffer, count); + stored_size = count; + cso('@'); + goto start_new_line; + + case F6: + c = CTL_Z; + goto default_case; + + case INS: + insert = !insert; + break; + + case DEL: + stored_pos++; break; } break; @@ -364,79 +365,109 @@ UCOUNT sti_0a(keyboard FAR * kp) case CTL_BS: case BS: backspace: - if (kp->kb_count > 0) + if (count > 0) { - if (kp->kb_buf[kp->kb_count - 1] >= ' ') - { - destr_bs(); - --virt_pos; - } - else if ((kp->kb_buf[kp->kb_count - 1] < ' ') - && (kp->kb_buf[kp->kb_count - 1] != HT)) + unsigned new_pos; + c = local_buffer[--count]; + if (c == HT) { - destr_bs(); - destr_bs(); - virt_pos -= 2; + unsigned i; + new_pos = cu_pos; + for (i = 0; i < count; i++) + { + if (local_buffer[i] == HT) + new_pos = (new_pos + 8) & ~7; + else if (local_buffer[i] < ' ') + new_pos += 2; + else + new_pos++; + } + do + destr_bs(); + while (scr_pos > new_pos); } - else if (kp->kb_buf[kp->kb_count - 1] == HT) + else { - do - { + if (c < ' ') destr_bs(); - --virt_pos; - } - while ((virt_pos > cu_pos) && (virt_pos & 7)); + destr_bs(); } - --kp->kb_count; } + if (stored_pos > 0 && !insert) + stored_pos--; break; - case CR: -#ifndef NOSPCL - fmemcpy(local_buffer, kp->kb_buf, (COUNT) kp->kb_count); - local_buffer[kp->kb_count] = '\0'; -#endif - kbfill(kp, CR, TRUE, &virt_pos); - if (eof) - return eof; - else - return kp->kb_count--; - case LF: + cso(CR); + cso(LF); break; case ESC: cso('\\'); + start_new_line: cso(CR); cso(LF); for (c = 0; c < cu_pos; c++) cso(' '); - kp->kb_count = init_count; - eof = FALSE; + count = 0; + stored_pos = 0; + insert = FALSE; break; - case CTL_Z: - eof = kp->kb_count; /* fall through */ default: - kbfill(kp, c, FALSE, &virt_pos); + default_case: + if (count < size - 1) + local_buffer[count++] = mod_cso(c); + else + cso(BELL); + if (stored_pos < stored_size && !insert) + stored_pos++; break; } } + local_buffer[count] = CR; + cso(CR); + fmemcpy(kp->kb_buf, local_buffer, count + 1); + /* if local_buffer overflows into the CON default buffer we + must invalidate it */ + if (count > LINEBUFSIZECON) + kb_buf.kb_size = 0; + kp->kb_count = count; } -UCOUNT sti(keyboard * kp) +unsigned sti(unsigned n, char FAR * bp) { - UCOUNT ReadCount = sti_0a(kp); - kp->kb_count++; - - if (ReadCount >= kp->kb_count && kp->kb_count < kp->kb_size) + char *bufend = &kb_buf.kb_buf[kb_buf.kb_count + 2]; + + if (inputptr == NULL) { - kp->kb_buf[kp->kb_count++] = LF; + /* can we reuse kb_buf or was it overwritten? */ + if (kb_buf.kb_size != LINEBUFSIZECON) + { + kb_buf.kb_count = 0; + kb_buf.kb_size = LINEBUFSIZECON; + } + sti_0a(&kb_buf); + bufend = &kb_buf.kb_buf[kb_buf.kb_count + 2]; + bufend[-1] = LF; cso(LF); - ReadCount++; + inputptr = kb_buf.kb_buf; + if (*inputptr == CTL_Z) + { + inputptr = NULL; + return 0; + } } - return ReadCount; + + if (inputptr > bufend - n) + n = bufend - inputptr; + + fmemcpy(bp, inputptr, n); + inputptr += n; + if (inputptr == bufend) + inputptr = NULL; + return n; } /* diff --git a/kernel/dosfns.c b/kernel/dosfns.c index c2d3803f..0de7c08d 100644 --- a/kernel/dosfns.c +++ b/kernel/dosfns.c @@ -207,11 +207,12 @@ UCOUNT DosRWSft(sft FAR * s, UCOUNT n, void FAR * bp, COUNT * err, int mode) { if (mode==XFR_READ) { + char c; + /* First test for eof and exit */ /* immediately if it is */ if (!(s->sft_flags & SFT_FEOF) || (s->sft_flags & SFT_FNUL)) { - s->sft_flags &= ~SFT_FEOF; return 0; } @@ -220,21 +221,28 @@ UCOUNT DosRWSft(sft FAR * s, UCOUNT n, void FAR * bp, COUNT * err, int mode) return BinaryCharIO(s->sft_dev, n, bp, C_INPUT, err); if (s->sft_flags & SFT_FCONIN) { - UCOUNT ReadCount; - - kb_buf.kb_size = LINESIZE - 1; - ReadCount = sti(&kb_buf); - if (ReadCount < kb_buf.kb_count) - s->sft_flags &= ~SFT_FEOF; - fmemcpy(bp, kb_buf.kb_buf, kb_buf.kb_count); - return ReadCount; + n = sti(n, bp); + if (n == 0) + c = CTL_Z; + } + else + { + n = 1; + Do_DosIdle_loop(); + BinaryReadSft(s, &c, err); + if (c != CTL_Z) + *(char FAR *)bp = c; + } + if (c == CTL_Z) + { + n = 0; + s->sft_flags &= ~SFT_FEOF; } - *(char FAR *)bp = _sti(FALSE); - return 1; + return n; } else { - /* set to no EOF */ + /* reset EOF state (set to no EOF) */ s->sft_flags |= SFT_FEOF; /* if null just report full transfer */ @@ -329,7 +337,6 @@ UCOUNT BinaryReadSft(sft FAR * s, void *bp, COUNT *err) /* immediately if it is */ if (!(s->sft_flags & SFT_FEOF) || (s->sft_flags & SFT_FNUL)) { - s->sft_flags &= ~SFT_FEOF; return 0; } return BinaryCharIO(s->sft_dev, 1, bp, C_INPUT, err); diff --git a/kernel/globals.h b/kernel/globals.h index 392d51d8..9d4289c8 100644 --- a/kernel/globals.h +++ b/kernel/globals.h @@ -131,8 +131,15 @@ FAR * ASM DPBp; /* First drive Parameter Block */ #define ESC 0x1b #define CTL_BS 0x7f +#define INS 0x52 +#define DEL 0x53 + #define F1 0x3b +#define F2 0x3c #define F3 0x3d +#define F4 0x3e +#define F5 0x3f +#define F6 0x40 #define LEFT 0x4b #define RIGHT 0x4d @@ -157,12 +164,6 @@ FAR * ASM DPBp; /* First drive Parameter Block */ #define MASK12 0xFF8 #define BAD12 0xFF0 -/* Keyboard buffer maximum size */ -#ifdef LINESIZE -#undef LINESIZE -#endif -#define LINESIZE KBD_MAXLENGTH - /* NLS character table type */ typedef BYTE *UPMAP; @@ -260,6 +261,7 @@ extern BYTE ASM NetDelay, ASM NetRetry; extern UWORD ASM first_mcb, /* Start of user memory */ ASM uppermem_root; /* Start of umb chain (usually 9fff) */ +extern char * ASM inputptr; /* pointer to unread CON input */ extern sfttbl FAR * ASM sfthead; /* System File Table head */ extern struct dhdr FAR * ASM clock, /* CLOCK$ device */ @@ -351,6 +353,7 @@ extern BYTE ASM BootDrive, /* Drive we came up from */ NumFloppies; !!*//* How many floppies we have */ extern keyboard ASM kb_buf; +extern char ASM local_buffer[LINEBUFSIZE0A]; extern struct cds ASM TempCDS; diff --git a/kernel/kernel.asm b/kernel/kernel.asm index 030937ed..810bddec 100644 --- a/kernel/kernel.asm +++ b/kernel/kernel.asm @@ -268,7 +268,8 @@ _NetRetry dw 3 ;-000c network retry count _NetDelay dw 1 ;-000a network delay count global _DskBuffer _DskBuffer dd -1 ;-0008 current dos disk buffer - dw 0 ;-0004 Unread con input + global _inputptr +_inputptr dw 0 ;-0004 Unread con input global _first_mcb _first_mcb dw 0 ;-0002 Start of user memory global _DPBp @@ -362,9 +363,12 @@ _firstsftt: global MARK01FBH MARK01FBH equ $ - times 128 db 0 + global _local_buffer ; local_buffer is 256 bytes long + ; so it overflows into kb_buf!! + ; only when kb_buf is used, local_buffer is limited to 128 bytes. +_local_buffer: times 128 db 0 global _kb_buf -_kb_buf db 129,0 ; initialise buffer to empty +_kb_buf db 128,0 ; initialise buffer to empty times 128+1 db 0 ; room for 128 byte readline + LF ; ; Variables that follow are documented as part of the DOS 4.0-6.X swappable diff --git a/kernel/proto.h b/kernel/proto.h index 512f59bb..3021b441 100644 --- a/kernel/proto.h +++ b/kernel/proto.h @@ -53,7 +53,7 @@ UWORD dskxfer(COUNT dsk, ULONG blkno, VOID FAR * buf, UWORD numblocks, UCOUNT BinaryCharIO(struct dhdr FAR * dev, UCOUNT n, void FAR * bp, unsigned command, COUNT *err); VOID sto(COUNT c); VOID cso(COUNT c); -VOID mod_cso(REG UCOUNT c); +unsigned mod_cso(unsigned c); VOID destr_bs(void); UCOUNT _sti(BOOL check_break); VOID con_hold(void); @@ -61,8 +61,8 @@ BOOL con_break(void); BOOL StdinBusy(void); VOID KbdFlush(void); VOID Do_DosIdle_loop(void); -UCOUNT sti_0a(keyboard FAR * kp); -UCOUNT sti(keyboard * kp); +void sti_0a(keyboard FAR * kp); +unsigned sti(unsigned n, char FAR * bp); sft FAR *get_sft(UCOUNT); diff --git a/utils/exeflat.c b/utils/exeflat.c index f6ae4495..d2c8503a 100644 --- a/utils/exeflat.c +++ b/utils/exeflat.c @@ -153,6 +153,8 @@ int main(int argc, char **argv) return 1; } start_seg = strtol(argv[3], NULL, 0); + if (header.exExtraBytes == 0) + header.exExtraBytes = 0x200; printf("header len = %lu = 0x%lx\n", header.exHeaderSize * 16UL, header.exHeaderSize * 16UL); size = @@ -278,7 +280,7 @@ int main(int argc, char **argv) if (UPX) { /* UPX trailer */ - /* hand assembled - so this reamins ANSI C ;-) */ + /* hand assembled - so this remains ANSI C ;-) */ static char trailer[] = { /* shift down everything by sizeof JumpBehindCode */ 0xE8, 0x00, 0x00, /* call 103 */ 0x59, /* pop cx */ From 83b77cbb1bd93b91f945bdeabe787584f5f350d8 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Tue, 22 Oct 2002 02:40:19 +0000 Subject: [PATCH 152/671] Changes for kernel 2027rc. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@427 6ac86273-5f31-0410-b378-82cca8765d1b --- boot/boot.asm | 6 +- docs/contrib.txt | 9 +- docs/history.txt | 37 ++- hdr/device.h | 4 +- hdr/portab.h | 19 +- hdr/process.h | 11 +- hdr/time.h | 13 +- hdr/version.h | 4 +- kernel/asmsupt.asm | 304 +++++++++++++----------- kernel/blockio.c | 21 +- kernel/break.c | 7 +- kernel/chario.c | 566 +++++++++++++++++++++++++------------------- kernel/config.c | 28 ++- kernel/dosfns.c | 328 +++++++++++-------------- kernel/dosidle.asm | 12 +- kernel/dsk.c | 49 ++-- kernel/entry.asm | 43 +--- kernel/error.c | 4 +- kernel/fatdir.c | 32 +-- kernel/fatfs.c | 100 ++++---- kernel/fcbfns.c | 71 +++--- kernel/globals.h | 43 ++-- kernel/init-mod.h | 10 +- kernel/initdisk.c | 26 +- kernel/int2f.asm | 48 +++- kernel/inthndlr.c | 286 +++++++++++----------- kernel/ioctl.c | 10 +- kernel/kernel.asm | 24 +- kernel/lfnapi.c | 10 +- kernel/main.c | 41 ++-- kernel/makefile | 8 +- kernel/memmgr.c | 19 +- kernel/newstuff.c | 65 +++-- kernel/nls.c | 2 +- kernel/nlssupt.asm | 16 +- kernel/prf.c | 72 +++++- kernel/procsupt.asm | 6 +- kernel/proto.h | 121 +++++----- kernel/systime.c | 46 ++-- kernel/task.c | 130 +++++----- mkfiles/bc5.mak | 2 +- mkfiles/mscl8.mak | 2 +- mkfiles/watcom.mak | 2 +- sys/sys.c | 30 ++- 44 files changed, 1416 insertions(+), 1271 deletions(-) diff --git a/boot/boot.asm b/boot/boot.asm index d6d393e6..75362647 100644 --- a/boot/boot.asm +++ b/boot/boot.asm @@ -369,7 +369,7 @@ cluster_next: lodsw ; AX = next cluster to read boot_error: call print - db 13,10,"BOOT error!",13,10,0 + db 13,10,"BOOT err!",0 xor ah,ah int 0x16 ; wait for a key @@ -417,6 +417,10 @@ read_next: push dx mov ah,041h ; mov bx,055aah ; mov dl, [drive] + test dl,dl ; don't use LBA addressing on A: + jz read_normal_BIOS ; might be a (buggy) + ; CDROM-BOOT floppy emulation + int 0x13 jc read_normal_BIOS diff --git a/docs/contrib.txt b/docs/contrib.txt index 923014d5..ba77e2d4 100644 --- a/docs/contrib.txt +++ b/docs/contrib.txt @@ -1,8 +1,8 @@ These are the know contributors of the FreeDOS kernel. If you have contributed in any way to the kernel, but are not on this list, -please email me at linux-guru@gcfl.net so I can add you to the list! +please email me at bart@dosemu.org so I can add you to the list! -Thanx to all the following for contributing to the FreeDOS kernel: +Thanks to all the following for contributing to the FreeDOS kernel: ror4 (ror4@angelfire.com) Steffen Kaiser (Steffen.Kaiser@fh-rhein-sieg.de) @@ -18,6 +18,9 @@ Jeremy Davis (jeremyd@computer.org) Martin Stromberg (ams@ludd.luth.se) Bart Oldeman (bart@dosemu.org) -And last, but not least, a big thanx to Pasquale J. Villani +At this place we should also thank Ralf Brown for his interrupt list. +It is a truely invaluable resource for us. + +And last, but not least, a big thanks to Pasquale J. Villani (patv@iop.com), who was the original author of DOS-C, in which the FreeDOS kernel was based. diff --git a/docs/history.txt b/docs/history.txt index 600928bd..7b10ecd8 100644 --- a/docs/history.txt +++ b/docs/history.txt @@ -1,4 +1,39 @@ -2002 Aug xx - Build 2027 +2002 Oct xx - Build 2027rc +-------- Bart Oldeman (bart@dosemu.org) ++ Changes Bart + * reorganized chario.c, got F1-F6, Ins, Del, etc working + * fixed bug in extended open + * fixed bug in memory manager (realloc should try to defragment; + UMB fixes) + * consistently pass sft_idx around for all SFT functions (instead of + the far pointer) + * lpUserStack is gone :) + * Idle interrupt: now uses disk i/o stack instead of error stack if it + re-enters DOS; can not be called from int21/ah=3f. It also checks + InDos now (as documented in "undocumented dos"). + * int21/ah=59 should use the disk i/o stack, not the character stack. + * get_cds: a uniform way to get the CDS for drive X which can do error + checking too. get_dpb: similar. + * task.c uses mid-level system file handles instead of PSP handles. + * SFT sequence is MS/DR DOS like: 0=AUX 1=CON 2=PRN + * int21/ah=4d needs to clear the return code after returning it. + * Removed need for unusedretval because some functions return a long int + now. + * Do not warn for some additional LBA partition layouts (begin/end + cylinder=1023) in initdisk.c. + * support int2f/ax=1213 (uppercase character) (ASCII only for now). + * fix for top of memory parameter to device driver - fixes problem + with DRDOS emm386 + * eliminated printf for non-init code -- use put_unsigned and + put_string instead + * better MK_FP for Turbo C++ 1.01 and later + * PSP related task.c cleanups + Changes Tom and Bart: + * Use Pascal calling convention for memcpy and friends in asmsupt.asm + * Fixed make temp file + * fix bug in DosFindNext + * misc makefile fixes +2002 Aug xx - Build 2027test -------- Bart Oldeman (bart@dosemu.org) + Changes Tom * enable LBA FAT16 booting diff --git a/hdr/device.h b/hdr/device.h index d2d3ac8e..022d33ff 100644 --- a/hdr/device.h +++ b/hdr/device.h @@ -204,7 +204,7 @@ struct _bios_LBA_address_packet }; struct CHS { - ULONG Cylinder; + UWORD Cylinder; UWORD Head; UWORD Sector; }; @@ -365,7 +365,7 @@ typedef struct { LONG _r_huge; /* for > 32Mb drives */ } _r_rw; struct { - BYTE _r_ndbyte; /* Byte Read From Device */ + unsigned char _r_ndbyte; /* Byte Read From Device */ } _r_nd; } _r_x; } request; diff --git a/hdr/portab.h b/hdr/portab.h index 9f399aa7..de95912c 100644 --- a/hdr/portab.h +++ b/hdr/portab.h @@ -63,12 +63,14 @@ static char *portab_hRcsId = #define I86 #define CDECL cdecl +#define PASCAL pascal void __int__(int); #elif defined (_MSC_VER) #define I86 #define CDECL _cdecl +#define PASCAL pascal #define __int__(intno) asm int intno; #if defined(M_I286) /* /G3 doesn't set M_I386, but sets M_I286 TE */ @@ -82,6 +84,7 @@ void __int__(int); #define asm __asm #define far __far #define CDECL __cdecl +#define PASCAL pascal #if _M_IX86 >= 300 #define I386 @@ -112,6 +115,7 @@ anyone knows a _portable_ way to create nice errors ? ? #define NONNATIVE #define PARASIZE 4096 /* "paragraph" size */ #define CDECL +#define PASCAL #ifdef __GNUC__ #define CONST const #define PROTO @@ -137,6 +141,7 @@ typedef unsigned size_t; have a certain calling standard. These are declared as 'ASMCFUNC', and is (and will be ?-) cdecl */ #define ASMCFUNC CDECL +#define ASMPASCAL PASCAL #define ASM ASMCFUNC /* */ /* Boolean type & definitions of TRUE and FALSE boolean values */ @@ -210,13 +215,23 @@ typedef signed long LONG; /* General far pointer macros */ #ifdef I86 #ifndef MK_FP + #ifdef __WATCOMC__ #define MK_FP(seg,ofs) (((UWORD)(seg)):>((VOID *)(ofs))) +#elif defined(__TURBOC__) && (__TURBOC__ > 0x202) +#define MK_FP(seg,ofs) ((void _seg *)(seg) + (void near *)(ofs)) #else #define MK_FP(seg,ofs) ((void FAR *)(((ULONG)(seg)<<16)|(UWORD)(ofs))) #endif -#define FP_SEG(fp) ((unsigned)(UWORD)((ULONG)(VOID FAR *)(fp)>>16)) -#define FP_OFF(fp) ((unsigned)(UWORD)(fp)) + +#if defined(__TURBOC__) && (__TURBOC__ > 0x202) +#define FP_SEG(fp) ((unsigned)(void _seg *)(void far *)(fp)) +#else +#define FP_SEG(fp) ((unsigned)((ULONG)(VOID FAR *)(fp)>>16)) +#endif + +#define FP_OFF(fp) ((unsigned)(fp)) + #endif #endif diff --git a/hdr/process.h b/hdr/process.h index f25347c1..f6cd3c45 100644 --- a/hdr/process.h +++ b/hdr/process.h @@ -79,8 +79,7 @@ typedef struct { UWORD ps_maxfiles; /* 32 maximum open files */ UBYTE FAR *ps_filetab; /* 34 open file table pointer */ VOID FAR *ps_prevpsp; /* 38 previous psp pointer */ - BYTE FAR *ps_dta; /* 3c process dta address */ - BYTE ps_fill2[16]; /* 40 */ + BYTE ps_fill2[20]; /* 3c */ UBYTE ps_unix[3]; /* 50 unix style call - 0xcd 0x21 0xcb */ BYTE ps_fill3[9]; /* 53 */ union { @@ -93,18 +92,14 @@ typedef struct { } _u2; struct { BYTE fill5[36]; - struct { - BYTE _ps_cmd_count; - BYTE _ps_cmd[127]; /* command tail */ - } _u4; + CommandTail _ps_cmd; } _u3; } _u; } psp; #define ps_fcb1 _u._u1._ps_fcb1 #define ps_fcb2 _u._u2._ps_fcb2 -#define ps_cmd _u._u3._u4._ps_cmd -#define ps_cmd_count _u._u3._u4._ps_cmd_count +#define ps_cmd _u._u3._ps_cmd /* * Log: process.h,v diff --git a/hdr/time.h b/hdr/time.h index 951450a5..867e5bdc 100644 --- a/hdr/time.h +++ b/hdr/time.h @@ -45,10 +45,21 @@ static BYTE *time_hRcsId = #define TM_MIN(t) (((t)>>5)&0x3f) #define TM_DEC(t) ((t)&0x1f) -#define TM_ENCODE(h,m,d) ((((h&0x1f))<<11)|(((m)&0x3f)<<5)|((d)&0x1f)) +#define TM_ENCODE(h,m,d) ((((h)&0x1f)<<11)|(((m)&0x3f)<<5)|((d)&0x1f)) typedef UWORD time; +struct dostime +{ + unsigned char minute, hour, hundredth, second; +}; + +struct dosdate +{ + unsigned short year; + unsigned char monthday, month; +}; + #endif /* diff --git a/hdr/version.h b/hdr/version.h index 3a9a8663..5f38bab0 100644 --- a/hdr/version.h +++ b/hdr/version.h @@ -49,6 +49,6 @@ static BYTE *date_hRcsId = #define REVISION_MINOR 1 #define REVISION_SEQ 27 #define BUILD "2027" -#define SUB_BUILD "test" +#define SUB_BUILD "rc" #define KERNEL_VERSION_STRING "1.1.27" /*#REVISION_MAJOR "." #REVISION_MINOR "." #REVISION_SEQ */ -#define KERNEL_BUILD_STRING "2027test" /*#BUILD SUB_BUILD */ +#define KERNEL_BUILD_STRING "2027rc" /*#BUILD SUB_BUILD */ diff --git a/kernel/asmsupt.asm b/kernel/asmsupt.asm index 5174f827..1410f5c3 100644 --- a/kernel/asmsupt.asm +++ b/kernel/asmsupt.asm @@ -54,7 +54,7 @@ segment HMA_TEXT ; fmemset(void FAR *dest, int ch, int count); ; fstrncpy(void FAR*dest, void FAR *src, int count); ; strcpy (void *dest, void *src); -; fstrcpy (void FAR*dest, void FAR *src, int count); +; fstrcpy (void FAR*dest, void FAR *src); ; strlen (void *dest); ; fstrlen (void FAR*dest); ; fmemchr (BYTE FAR *src , int ch); @@ -68,52 +68,51 @@ segment HMA_TEXT ; memcmp(BYTE *s1 , BYTE *s2, int count); ;*********************************************** -; common_setup - set up the standard calling frame for C-functions +; pascal_setup - set up the standard calling frame for C-functions ; and save registers needed later ; also preload the args for the near functions ; di=arg1 ; si=arg2 ; cx=arg3 ; -common_setup: - pop bx ; get return address +pascal_setup: + pop ax ; get return address push bp ; Standard C entry mov bp,sp push si push di - push es push ds ; Set both ds and es to same segment (for near copy) - pop es push ds + pop es ; Set direction to autoincrement cld - ; to conserve even some more bytes, - ; the registers for the near routines - ; are preloaded here + mov bl,6 ; majority (4) wants that + mov cx,[4+bp] ; majority (8) wants that (near and far) + mov si,[6+bp] ; majority (3) wants that (near) + mov di,[8+bp] ; majority (3) wants that (near) - ; the destination pointer, d = arg1 - mov di,[bp+4] - - ; Get the source pointer, s = arg2 - mov si,[bp+6] - - ; Get the repitition count, n = arg3 - mov cx,[bp+8] + jmp ax - jmp bx + ;*********************************************** ; ; VOID memcpy(REG BYTE *s, REG BYTE *d, REG COUNT n); ; - global _memcpy -_memcpy: - call common_setup + global MEMCPY +MEMCPY: + call pascal_setup + + ;mov cx,[4+bp] - preset above + ;mov si,[6+bp] - preset above + ;mov di,[8+bp] - preset above + + ;mov bl,6 - preset above domemcpy: @@ -124,19 +123,15 @@ domemcpy: jnc memcpy_return movsb memcpy_return: +%if 0 ; only needed for fmemcpyback cld +%endif ; -; common_return - pop saved registers and do return +; pascal_return - pop saved registers and do return ; - -common_return: - pop ds - pop es - pop di - pop si - pop bp - ret + + jmp short pascal_return @@ -145,24 +140,24 @@ common_return: ; VOID fmemcpy(REG BYTE FAR *d, REG BYTE FAR *s,REG COUNT n); ; VOID fmemcpyBack(REG BYTE FAR *d, REG BYTE FAR *s,REG COUNT n); ; - global _fmemcpy + global FMEMCPY %if 0 - global _fmemcpyBack -_fmemcpyBack: + global FMEMCPYBACK +FMEMCPYBACK: std ; force to copy the string in reverse order %endif -_fmemcpy: - call common_setup +FMEMCPY: + call pascal_setup + + ; Get the repetition count, n preset above + ; mov cx,[bp+4] ; Get the far source pointer, s - lds si,[bp+8] + lds si,[bp+6] ; Get the far destination pointer d - les di,[bp+4] - - ; Get the repetition count, n - mov cx,[bp+12] - + les di,[bp+10] + mov bl,10 jmp short domemcpy @@ -170,56 +165,69 @@ _fmemcpy: ; ; VOID fmemset(REG VOID FAR *d, REG BYTE ch, REG COUNT n); ; - global _fmemset -_fmemset: - call common_setup + global FMEMSET +FMEMSET: + call pascal_setup - ; Get the repetition count, n - mov cx,[bp+10] + ; Get the repetition count, n - preset above + ; mov cx,[bp+4] + ; Get the fill byte ch + mov ax,[bp+6] + ; Get the far source pointer, s - les di,[bp+4] + les di,[bp+8] + mov bl,8 - ; Get the far destination pointer ch - mov al,[bp+8] - domemset: mov ah, al shr cx,1 rep stosw - jnc common_return + jnc pascal_return stosb - jmp short common_return + jmp short pascal_return ;*************************************************************** ; ; VOID memset(REG VOID *d, REG BYTE ch, REG COUNT n); ; - global _memset -_memset: - call common_setup + global MEMSET +MEMSET: + call pascal_setup - ; Get the far source pointer, s - ; mov di,[bp+4] + ; Get the repitition count, n - preset above + ; mov cx,[bp+4] ; Get the char ch - mov ax,si ; mov al, [bp+6] + mov ax, [bp+6] - ; Get the repititon count, n - ; mov cx,[bp+8] + ; Get the far source pointer, d - preset above + ; mov di,[bp+8] + + ;mov bl, 6 ; preset above jmp short domemset +;***** +pascal_return: + pop ds + pop di + pop si + pop bp - + pop cx + sub bh,bh + add sp,bx + jmp cx ;*************************************************************** -%if 0 +%if 0 +nix pascal - still untested global _fstrncpy _fstrncpy: - call common_setup + call pascal_setup ; Get the source pointer, ss lds si,[bp+8] @@ -229,7 +237,7 @@ _fstrncpy: mov cx,[bp+12] - jcxz common_return + jcxz pascal_return ;; dec cx ; jcxz store_one_byte strncpy_loop: lodsb @@ -243,35 +251,39 @@ store_one_byte: xor al,al ; to fill remaining part of buffer stosb - jmp short common_return + jmp short pascal_return %endif ;***************************************************************** +; fstrcpy (void FAR*dest, void FAR *src); - global _fstrcpy -_fstrcpy: - call common_setup + global FSTRCPY +FSTRCPY: + call pascal_setup ; Get the source pointer, ss - lds si,[bp+8] + lds si,[bp+4] ; and the destination pointer, d - les di,[bp+4] + les di,[bp+8] + + mov bl,8 jmp short dostrcpy ;****** - global _strcpy -_strcpy: - call common_setup + global STRCPY +STRCPY: + call pascal_setup ; Get the source pointer, ss - ;mov si,[bp+6] + mov si,[bp+4] ; and the destination pointer, d - ;mov di,[bp+4] + mov di,[bp+6] + mov bl,4 dostrcpy: @@ -281,25 +293,27 @@ strcpy_loop: test al,al jne strcpy_loop - jmp short common_return + jmp short pascal_return ;****************************************************************** - global _fstrlen -_fstrlen: - call common_setup + global FSTRLEN +FSTRLEN: + call pascal_setup ; Get the source pointer, ss - les di,[bp+4] + les di,[bp+4] + mov bl,4 jmp short dostrlen ;********************************************** - global _strlen -_strlen: - call common_setup - - ; The source pointer, ss, arg1 was loaded as di + global STRLEN +STRLEN: + call pascal_setup + ; Get the source pointer, ss + mov di,[bp+4] + mov bl,2 dostrlen: mov al,0 @@ -310,22 +324,23 @@ dostrlen: not ax dec ax - jmp short common_return + jmp short pascal_return ;************************************************************ - global _strchr -_strchr: - call common_setup +; strchr (BYTE *src , int ch); + + global STRCHR +STRCHR: + call pascal_setup ; Get the source pointer, ss - ; mov si,[bp+4] - ; mov bx,[bp+6] - mov bx,si - mov si,di + ; mov cx,[bp+4] - preset above + ; mov si,[bp+6] - preset above + mov bl,4 strchr_loop: lodsb - cmp al,bl + cmp al,cl je strchr_found test al,al jne strchr_loop @@ -333,7 +348,7 @@ strchr_loop: strchr_retzero: xor ax, ax ; return NULL if not found mov dx, ax ; for fstrchr() - jmp common_return + jmp short pascal_return strchr_found: mov ax, si @@ -341,22 +356,40 @@ strchr_found: strchr_found1: dec ax - jmp common_return + jmp short pascal_return + + +;***** +; fstrchr (BYTE far *src , int ch); + global FSTRCHR +FSTRCHR: + call pascal_setup + + ; Get ch (preset above) + ;mov cx, [bp+4] + + ;and the source pointer, src + lds si, [bp+6] + + ;mov bl, 6 - preset above + + jmp short strchr_loop ;****** -%if 0 - global _fmemchr -_fmemchr: - call common_setup + global FMEMCHR +FMEMCHR: + call pascal_setup - ; Get the source pointer, ss - les di, [bp+4] + ; Get the length - preset above + ; mov cx, [bp+4] ; and the search value - mov al, [bp+8] + mov ax, [bp+6] + + ; and the source pointer, ss + les di, [bp+8] - ; and the length - mov cx, [bp+10] + mov bl, 8 repne scasb jne strchr_retzero @@ -364,25 +397,13 @@ _fmemchr: mov ax, di dec ax jmp short strchr_found1 -%endif - - global _fstrchr -_fstrchr: - call common_setup - - ; Get the source pointer, ss - lds si, [bp+4] - - ; and the destination pointer, d - mov bx, [bp+8] - - jmp short strchr_loop ;********************************************************************** %if 0 +nix pascal - still untested global _fstrcmp _fstrcmp: - call common_setup + call pascal_setup ; Get the source pointer, ss lds si,[bp+4] @@ -395,7 +416,7 @@ _fstrcmp: ;****** global _strcmp _strcmp: - call common_setup + call pascal_setup ; Get the source pointer, ss @@ -413,9 +434,9 @@ dostrcmp: ;********************************************************************** - global _fstrncmp -_fstrncmp: - call common_setup + global FSTRNCMP +FSTRNCMP: + call pascal_setup ; Get the source pointer, ss lds si,[bp+4] @@ -429,7 +450,7 @@ _fstrncmp: ;****** global _strncmp _strncmp: - call common_setup + call pascal_setup ; Get the source pointer, ss ;mov si,[bp+4] @@ -455,36 +476,41 @@ strncmp_retzero: strncmp_done: lahf ror ah,1 -strncmp_done2: jmp common_return +strncmp_done2: jmp pascal_return ;********************************************************************** - global _fmemcmp -_fmemcmp: - call common_setup +; fmemcmp(BYTE FAR *s1 , BYTE FAR *s2, int count); + global FMEMCMP +FMEMCMP: + call pascal_setup + ; the length - preset above + ; mov cx, [bp+4] + ; Get the source pointer, ss - lds si,[bp+4] + les di,[bp+6] ; and the destination pointer, d - les di,[bp+8] + lds si,[bp+10] + + mov bl,10 - ; the length - mov cx, [bp+12] - jmp short domemcmp ;****** - global _memcmp -_memcmp: - call common_setup +; memcmp(BYTE *s1 , BYTE *s2, int count); + global MEMCMP +MEMCMP: + call pascal_setup - ; Get the source pointer, ss + ; all preset: Get the source pointer, ss ;mov si,[bp+6] ; and the destination pointer, d - ;mov di,[bp+4] - ;mov cx,[bp+8] + ;mov di,[bp+8] + ;mov cx,[bp+4] + ;mov bl,6 xchg si,di domemcmp: diff --git a/kernel/blockio.c b/kernel/blockio.c index faa71eaa..ff91dbc3 100644 --- a/kernel/blockio.c +++ b/kernel/blockio.c @@ -43,6 +43,8 @@ static BYTE *blockioRcsId = /************************************************************************/ /* #define DISPLAY_GETBLOCK */ +STATIC BOOL flush1(struct buffer FAR * bp); + /* */ /* Initialize the buffer structure */ /* */ @@ -76,7 +78,7 @@ STATIC VOID setblkno(struct buffer FAR * bp, ULONG blkno) bp->b_blkno = blkno; /* bp->b_dpbp = &blk_devices[bp->b_unit]; */ - bp->b_dpbp = CDSp[bp->b_unit].cdsDpb; + bp->b_dpbp = get_cds(bp->b_unit)->cdsDpb; } } @@ -101,7 +103,7 @@ STATIC VOID setblkno(struct buffer FAR * bp, ULONG blkno) */ -BOOL searchblock(ULONG blkno, COUNT dsk, struct buffer FAR ** pBuffp) +STATIC BOOL searchblock(ULONG blkno, COUNT dsk, struct buffer FAR ** pBuffp) { int fat_count = 0; struct buffer FAR *bp; @@ -337,7 +339,7 @@ BOOL flush_buffers(REG COUNT dsk) /* */ /* Write one disk buffer */ /* */ -BOOL flush1(struct buffer FAR * bp) +STATIC BOOL flush1(struct buffer FAR * bp) { /* All lines with changes on 9/4/00 by BER marked below */ @@ -409,20 +411,11 @@ BOOL flush(void) /* Transfer one or more blocks to/from disk */ /* */ -/* Changed to UWORD 9/4/00 BER */ UWORD dskxfer(COUNT dsk, ULONG blkno, VOID FAR * buf, UWORD numblocks, COUNT mode) -/* End of change */ { -/* REG struct dpb *dpbp = &blk_devices[dsk]; */ - - REG struct dpb FAR *dpbp = CDSp[dsk].cdsDpb; - - if ((UCOUNT) dsk >= lastdrive) - { - return 0x0201; /* illegal command */ - } - if ((CDSp[dsk].cdsFlags & (CDSPHYSDRV | CDSNETWDRV)) != CDSPHYSDRV) + register struct dpb FAR *dpbp = get_dpb(dsk); + if (dpbp == NULL) { return 0x0201; /* illegal command */ } diff --git a/kernel/break.c b/kernel/break.c index c41b72b6..1cbcb066 100644 --- a/kernel/break.c +++ b/kernel/break.c @@ -29,6 +29,7 @@ #include "portab.h" #include "globals.h" +#include "proto.h" extern void ASMCFUNC spawn_int23(void); @@ -60,11 +61,11 @@ int control_break(void) * 3) decrease the InDOS flag as the kernel drops back to user space * 4) invoke INT-23 and never come back */ -void handle_break(void) +void handle_break(int sft_idx) { - mod_cso(CTL_C); + echo_char_stdin(CTL_C); CB_FLG &= ~CB_MSK; /* reset the ^Break flag */ - KbdFlush(); /* Er, this is con_flush() */ + KbdFlush(sft_idx); /* Er, this is con_flush() */ if (!ErrorMode) /* within int21_handler, InDOS is not incremented */ if (InDOS) --InDOS; /* fail-safe */ diff --git a/kernel/chario.c b/kernel/chario.c index 004d2279..5290f6f0 100644 --- a/kernel/chario.c +++ b/kernel/chario.c @@ -37,86 +37,190 @@ static BYTE *charioRcsId = #include "globals.h" -/* Return a pointer to the first driver in the chain that - * matches the attributes. - * not necessary because we have the syscon pointer. - */ -#if 0 -struct dhdr FAR *finddev(UWORD attr_mask) +STATIC int CharRequest(struct dhdr FAR *dev) { - struct dhdr far *dh; - - for (dh = nul_dev.dh_next; FP_OFF(dh) != 0xFFFF; dh = dh->dh_next) + CharReqHdr.r_unit = 0; + CharReqHdr.r_status = 0; + CharReqHdr.r_length = sizeof(request); + execrh(&CharReqHdr, dev); + if (CharReqHdr.r_status & S_ERROR) { - if (dh->dh_attr & attr_mask) - return dh; + charloop: + switch (char_error(&CharReqHdr, dev)) + { + case ABORT: + case FAIL: + return DE_INVLDACC; + case CONTINUE: + CharReqHdr.r_count = 0; + return 0; + case RETRY: + return 1; + default: + goto charloop; + } } - - /* return dev/null if no matching driver found */ - return &nul_dev; + return 0; } -#endif -UCOUNT BinaryCharIO(struct dhdr FAR * dev, UCOUNT n, void FAR * bp, unsigned command, COUNT *err) +long BinaryCharIO(struct dhdr FAR * dev, size_t n, void FAR * bp, unsigned command) { - *err = SUCCESS; - - FOREVER + int err = SUCCESS; + do { - CharReqHdr.r_length = sizeof(request); CharReqHdr.r_command = command; CharReqHdr.r_count = n; CharReqHdr.r_trans = bp; - CharReqHdr.r_status = 0; - execrh(&CharReqHdr, dev); - if (CharReqHdr.r_status & S_ERROR) - { - charloop: - switch (char_error(&CharReqHdr, dev)) - { - case ABORT: - case FAIL: - *err = DE_INVLDACC; - return 0; - case CONTINUE: - break; - case RETRY: - continue; - default: - goto charloop; - } - } - break; + } while ((err = CharRequest(dev)) == 1); + return err == SUCCESS ? CharReqHdr.r_count : err; +} + +/* STATE FUNCTIONS */ + +STATIC struct dhdr FAR *idx_to_dev(int sft_idx) +{ + sft FAR *s = idx_to_sft(sft_idx); + if (FP_OFF(s) == (size_t)-1 || (s->sft_mode & SFT_MWRITE) || + !(s->sft_flags & SFT_FDEVICE)) + return syscon; + else + return s->sft_dev; +} + +/* if sft_idx is invalid, then we just monitor syscon */ +STATIC BOOL Busy(int sft_idx) +{ + sft FAR *s = idx_to_sft(sft_idx); + + if (s->sft_flags & SFT_FDEVICE) + { + struct dhdr FAR *dev = idx_to_dev(sft_idx); + do { + CharReqHdr.r_command = C_ISTAT; + } while(CharRequest(dev) == 1); + if (CharReqHdr.r_status & S_BUSY) + return TRUE; + else + return FALSE; } - return CharReqHdr.r_count; + else + return s->sft_posit >= s->sft_size; } -VOID _cso(COUNT c) +BOOL StdinBusy(void) +{ + return Busy(get_sft_idx(STDIN)); +} + +STATIC void Do_DosIdle_loop(int sft_idx) +{ + /* the idle loop is only safe if we're using the character stack */ + if (user_r->AH < 0xd) + while (Busy(sft_idx)) + DosIdle_int(); +} + +/* get character from the console - this is how DOS gets + CTL_C/CTL_S/CTL_P when outputting */ +STATIC int ndread(int sft_idx) { - if (syscon->dh_attr & ATTR_FASTCON) + struct dhdr FAR *dev = idx_to_dev(sft_idx); + do { + CharReqHdr.r_command = C_NDREAD; + } while(CharRequest(dev) == 1); + if (CharReqHdr.r_status & S_BUSY) + return -1; + return CharReqHdr.r_ndbyte; +} + +STATIC int con_get_char(int sft_idx) +{ + unsigned char c; + BinaryCharIO(idx_to_dev(sft_idx), 1, &c, C_INPUT); + if (c == CTL_C) + handle_break(sft_idx); + return c; +} + +STATIC void con_hold(int sft_idx) +{ + int c; + if (control_break()) + handle_break(-1); + c = ndread(sft_idx); + if (c == CTL_S) + { + con_get_char(sft_idx); + Do_DosIdle_loop(sft_idx); + /* just wait */ + c = con_get_char(sft_idx); + } + if (c == CTL_C) + { + con_get_char(sft_idx); + handle_break(sft_idx); + } +} + +BOOL con_break(void) +{ + if (ndread(-1) == CTL_C) + { + con_get_char(-1); + return TRUE; + } + else + return FALSE; +} + +/* OUTPUT FUNCTIONS */ + +#ifdef __WATCOMC__ +void int29(char c); +#pragma aux int29 = "int 29h" parm[al] modify exact [bx] +#endif + +/* writes a character in raw mode; use int29 if possible + for speed */ +STATIC int raw_put_char(int sft_idx, int c) +{ + struct dhdr FAR *dev = idx_to_dev(sft_idx); + unsigned char ch = (unsigned char)c; + + if (PrinterEcho) + DosWrite(STDPRN, 1, &ch); + + if (dev->dh_attr & ATTR_FASTCON) { #if defined(__TURBOC__) - _AL = c; + _AL = ch; __int__(0x29); +#elif defined(__WATCOMC__) + int29(ch); #elif defined(I86) asm { - mov al, byte ptr c; + mov al, byte ptr ch; int 0x29; } #endif - return; + return 0; } - BinaryCharIO(syscon, 1, &c, C_OUTPUT, &UnusedRetVal); + c = (int)BinaryCharIO(dev, 1, &ch, C_OUTPUT); + if (c < 0) + return c; + else + return ch; } -VOID cso(COUNT c) +/* writes a character in cooked mode; maybe with printer echo; + handles TAB expansion */ +STATIC int cooked_put_char(int sft_idx, int c) { + int err = 0; + /* Test for hold char */ - con_hold(); - - if (PrinterEcho) - DosWrite(STDPRN, 1, (BYTE FAR *) & c, & UnusedRetVal); + con_hold(sft_idx); switch (c) { @@ -132,157 +236,139 @@ VOID cso(COUNT c) break; case HT: do - _cso(' '); - while ((++scr_pos) & 7); + err = raw_put_char(sft_idx, ' '); + while (err >= 0 && ((++scr_pos) & 7)); break; default: scr_pos++; } if (c != HT) - _cso(c); + err = raw_put_char(sft_idx, c); + return err; } -VOID sto(COUNT c) +long cooked_write(int sft_idx, size_t n, char FAR *bp) { - DosWrite(STDOUT, 1, (BYTE FAR *) & c, & UnusedRetVal); + size_t xfer; + int err = SUCCESS; + + for (xfer = 0; err >= SUCCESS && xfer < n && *bp != CTL_Z; bp++, xfer++) + err = cooked_put_char(sft_idx, *bp); + return err < SUCCESS ? err : xfer; } -unsigned mod_cso(register unsigned c) +/* writes character for disk file or device */ +void write_char(int c, int sft_idx) { - if (c < ' ' && c != HT) - { - cso('^'); - cso(c + '@'); - } - else - cso(c); - return c; + unsigned char ch = (unsigned char)c; + DosRWSft(sft_idx, 1, &ch, XFR_FORCE_WRITE); } -VOID destr_bs(void) +void write_char_stdin(int c) { - cso(BS); - cso(' '); - cso(BS); + write_char(c, get_sft_idx(STDIN)); } -VOID Do_DosIdle_loop(void) +#define iscntrl(c) ((unsigned char)(c) < ' ') + +/* this is for handling things like ^C, mostly used in echoed input */ +STATIC int echo_char(int c, int sft_idx) { - FOREVER + if (iscntrl(c) && c != HT && c != LF && c != CR) { - if (!StdinBusy()) - return; - else - { - DosIdle_int(); - continue; - } + write_char('^', sft_idx); + write_char(c + '@', sft_idx); } + else + write_char(c, sft_idx); + return c; } -COUNT ndread(void) +int echo_char_stdin(int c) { - CharReqHdr.r_unit = 0; - CharReqHdr.r_status = 0; - CharReqHdr.r_command = C_NDREAD; - CharReqHdr.r_length = sizeof(request); - execrh((request FAR *) & CharReqHdr, syscon); - if (CharReqHdr.r_status & S_BUSY) - return -1; - return CharReqHdr.r_ndbyte; + return echo_char(get_sft_idx(STDIN), c); } -COUNT con_read(void) +STATIC void destr_bs(int sft_idx) { - BYTE c; + write_char(BS, sft_idx); + write_char(' ', sft_idx); + write_char(BS, sft_idx); +} - BinaryCharIO(syscon, 1, &c, C_INPUT, &UnusedRetVal); - if (c == CTL_C) - handle_break(); - return c; +/* READ FUNCTIONS */ + +STATIC int raw_get_char(int sft_idx, BOOL check_break) +{ + unsigned char c; + int err; + + Do_DosIdle_loop(sft_idx); + if (check_break) + con_hold(sft_idx); + + err = (int)BinaryCharIO(idx_to_dev(sft_idx), 1, &c, C_INPUT); + return err < 0 ? err : c; } -VOID con_hold(void) +long cooked_read(int sft_idx, size_t n, char FAR *bp) { - UBYTE c = ndread(); - if (c == CTL_S) - { - con_read(); - Do_DosIdle_loop(); - /* just wait */ - c = con_read(); - } - if (c == CTL_C) + unsigned xfer = 0; + int c; + while(n--) { - con_read(); - handle_break(); + c = raw_get_char(sft_idx, TRUE); + if (c < 0) + return c; + *bp++ = c; + xfer++; + if (bp[-1] == CTL_Z) + break; } + return xfer; } -UCOUNT _sti(BOOL check_break) +unsigned char read_char(int sft_idx, BOOL check_break) { - UBYTE c; - /* - * XXX: If there's a read error, this will just keep retrying the read until - * the error disappears. Maybe it should do something else instead. -- ror4 - */ - Do_DosIdle_loop(); - if (check_break) - con_hold(); - while (BinaryRead(STDIN, &c, & UnusedRetVal) != 1) - ; + unsigned char c; + sft FAR *s = idx_to_sft(sft_idx); + + if ((FP_OFF(s) == (size_t) -1) || (s->sft_flags & SFT_FDEVICE)) + return raw_get_char(sft_idx, check_break); + + DosRWSft(sft_idx, 1, &c, XFR_READ); return c; } -BOOL con_break(void) +STATIC unsigned char read_char_check_break(int sft_idx) { - if (ndread() == CTL_C) - { - con_read(); - return TRUE; - } - else - return FALSE; + return read_char(sft_idx, TRUE); } -BOOL StdinBusy(void) +unsigned char read_char_stdin(BOOL check_break) { - sft FAR *s; + return read_char(get_sft_idx(STDIN), check_break); +} - if ((s = get_sft(STDIN)) == (sft FAR *) - 1) - return FALSE; /* XXX */ - if (s->sft_count == 0 || (s->sft_mode & SFT_MWRITE)) - return FALSE; /* XXX */ - if (s->sft_flags & SFT_FDEVICE) - { +void KbdFlush(int sft_idx) +{ + struct dhdr FAR *dev = idx_to_dev(sft_idx); + + do { CharReqHdr.r_unit = 0; CharReqHdr.r_status = 0; - CharReqHdr.r_command = C_ISTAT; + CharReqHdr.r_command = C_IFLUSH; CharReqHdr.r_length = sizeof(request); - execrh((request FAR *) & CharReqHdr, s->sft_dev); - if (CharReqHdr.r_status & S_BUSY) - return TRUE; - else - return FALSE; - } - else - return FALSE; /* XXX */ -} - -VOID KbdFlush(void) -{ - CharReqHdr.r_unit = 0; - CharReqHdr.r_status = 0; - CharReqHdr.r_command = C_IFLUSH; - CharReqHdr.r_length = sizeof(request); - execrh((request FAR *) & CharReqHdr, syscon); + } while (CharRequest(dev) == 1); } -/* reads a line */ -void sti_0a(keyboard FAR * kp) +/* reads a line (buffered, called by int21/ah=0ah, 3fh) */ +void read_line(int sft_in, int sft_out, keyboard FAR * kp) { - REG UWORD c, cu_pos = scr_pos; - unsigned count = 0, stored_pos = 0, size = kp->kb_size, stored_size = kp->kb_count; + unsigned c; + unsigned cu_pos = scr_pos; + unsigned count = 0, stored_pos = 0; + unsigned size = kp->kb_size, stored_size = kp->kb_count; BOOL insert = FALSE; if (size == 0) @@ -290,86 +376,76 @@ void sti_0a(keyboard FAR * kp) /* the stored line is invalid unless it ends with a CR */ if (kp->kb_buf[stored_size] != CR) - { stored_size = 0; - } - while ((c = _sti(TRUE)) != CR) + do { + unsigned new_pos = stored_size; + + c = read_char_check_break(sft_in); + if (c == 0) + c = (unsigned)read_char_check_break(sft_in) << 8; switch (c) { - case CTL_C: - handle_break(); case CTL_F: continue; -#ifndef NOSPCL - case SPCL: - switch (c = _sti(TRUE)) - { - case LEFT: - goto backspace; - - case RIGHT: - case F1: - if (stored_pos < stored_size && count < size - 1) - local_buffer[count++] = mod_cso(kp->kb_buf[stored_pos++]); - break; - - case F2: - c = _sti(TRUE); - /* insert up to character c */ - insert_to_c: - while (stored_pos < stored_size && count < size - 1) - { - char c2 = kp->kb_buf[stored_pos]; - if (c2 == c) - break; - stored_pos++; - local_buffer[count++] = mod_cso(c2); - } - break; - - case F3: - c = (unsigned)-1; - goto insert_to_c; - - case F4: - c = _sti(TRUE); - /* delete up to character c */ - while (stored_pos < stored_size && c != kp->kb_buf[stored_pos]) - stored_pos++; - break; - - case F5: - fmemcpy(kp->kb_buf, local_buffer, count); - stored_size = count; - cso('@'); - goto start_new_line; - - case F6: - c = CTL_Z; - goto default_case; - - case INS: - insert = !insert; - break; + case RIGHT: + case F1: + if (stored_pos < stored_size && count < size - 1) + local_buffer[count++] = echo_char(kp->kb_buf[stored_pos++], sft_out); + break; - case DEL: - stored_pos++; - break; + case F2: + case F4: + /* insert/delete up to character c */ + { + unsigned char c2 = read_char_check_break(sft_in); + new_pos = stored_pos; + if (c2 == 0) + { + read_char_check_break(sft_in); + } + else + { + char FAR *sp = fmemchr(&kp->kb_buf[stored_pos], + c2, stored_size - stored_pos); + if (sp != NULL) + new_pos = (FP_OFF(sp) - FP_OFF(&kp->kb_buf[stored_pos])) + 1; + } + } + /* fall through */ + case F3: + if (c != F4) /* not delete */ + { + while (stored_pos < new_pos && count < size - 1) + local_buffer[count++] = echo_char(kp->kb_buf[stored_pos++], sft_out); } + stored_pos = new_pos; + break; + + case F5: + fmemcpy(kp->kb_buf, local_buffer, count); + stored_size = count; + write_char('@', sft_out); + goto start_new_line; + + case INS: + insert = !insert; + break; + + case DEL: + stored_pos++; break; -#endif + case LEFT: case CTL_BS: case BS: - backspace: if (count > 0) { unsigned new_pos; - c = local_buffer[--count]; - if (c == HT) + char c2 = local_buffer[--count]; + if (c2 == HT) { unsigned i; new_pos = cu_pos; @@ -377,66 +453,63 @@ void sti_0a(keyboard FAR * kp) { if (local_buffer[i] == HT) new_pos = (new_pos + 8) & ~7; - else if (local_buffer[i] < ' ') + else if (iscntrl(local_buffer[i])) new_pos += 2; else new_pos++; } do - destr_bs(); + destr_bs(sft_out); while (scr_pos > new_pos); } else { - if (c < ' ') - destr_bs(); - destr_bs(); + if (iscntrl(c2)) + destr_bs(sft_out); + destr_bs(sft_out); } } - if (stored_pos > 0 && !insert) + if (stored_pos > 0) stored_pos--; break; - case LF: - cso(CR); - cso(LF); - break; - case ESC: - cso('\\'); + write_char('\\', sft_out); start_new_line: - cso(CR); - cso(LF); - for (c = 0; c < cu_pos; c++) - cso(' '); + write_char(CR, sft_out); + write_char(LF, sft_out); + for (count = 0; count < cu_pos; count++) + write_char(' ', sft_out); count = 0; stored_pos = 0; insert = FALSE; break; + case F6: + c = CTL_Z; /* fall through */ + default: - default_case: - if (count < size - 1) - local_buffer[count++] = mod_cso(c); + if (count < size - 1 || c == CR) + local_buffer[count++] = echo_char(c, sft_out); else - cso(BELL); + write_char(BELL, sft_out); if (stored_pos < stored_size && !insert) stored_pos++; break; } - } - local_buffer[count] = CR; - cso(CR); - fmemcpy(kp->kb_buf, local_buffer, count + 1); + } while (c != CR); + fmemcpy(kp->kb_buf, local_buffer, count); /* if local_buffer overflows into the CON default buffer we must invalidate it */ if (count > LINEBUFSIZECON) kb_buf.kb_size = 0; - kp->kb_count = count; + /* kb_count does not include the final CR */ + kp->kb_count = count - 1; } -unsigned sti(unsigned n, char FAR * bp) +/* called by handle func READ (int21/ah=3f) */ +size_t read_line_handle(int sft_idx, size_t n, char FAR * bp) { char *bufend = &kb_buf.kb_buf[kb_buf.kb_count + 2]; @@ -448,10 +521,9 @@ unsigned sti(unsigned n, char FAR * bp) kb_buf.kb_count = 0; kb_buf.kb_size = LINEBUFSIZECON; } - sti_0a(&kb_buf); + read_line(sft_idx, sft_idx, &kb_buf); bufend = &kb_buf.kb_buf[kb_buf.kb_count + 2]; - bufend[-1] = LF; - cso(LF); + bufend[-1] = echo_char(LF, sft_idx); inputptr = kb_buf.kb_buf; if (*inputptr == CTL_Z) { diff --git a/kernel/config.c b/kernel/config.c index 46df25d1..82a7e7b6 100644 --- a/kernel/config.c +++ b/kernel/config.c @@ -144,7 +144,7 @@ STATIC VOID DeviceHigh(BYTE * pLine); STATIC VOID Files(BYTE * pLine); STATIC VOID Fcbs(BYTE * pLine); STATIC VOID CfgLastdrive(BYTE * pLine); -STATIC BOOL LoadDevice(BYTE * pLine, COUNT top, COUNT mode); +STATIC BOOL LoadDevice(BYTE * pLine, char FAR *top, COUNT mode); STATIC VOID Dosmem(BYTE * pLine); STATIC VOID Country(BYTE * pLine); STATIC VOID InitPgm(BYTE * pLine); @@ -155,6 +155,15 @@ STATIC VOID CfgIgnore(BYTE * pLine); STATIC VOID CfgMenu(BYTE * pLine); STATIC VOID DoMenu(void); STATIC VOID CfgMenuDefault(BYTE * pLine); +STATIC BYTE * skipwh(BYTE * s); +STATIC BYTE * scan(BYTE * s, BYTE * d); +STATIC BOOL isnum(BYTE * pszString); +STATIC BYTE * GetNumber(REG BYTE * pszString, REG COUNT * pnNum); +#if 0 +STATIC COUNT tolower(COUNT c); +#endif +STATIC COUNT toupper(COUNT c); +STATIC VOID mcb_init(UCOUNT seg, UWORD size); STATIC VOID Stacks(BYTE * pLine); STATIC VOID SetAnyDos(BYTE * pLine); @@ -170,8 +179,9 @@ STATIC COUNT strcasecmp(REG BYTE * d, REG BYTE * s); void HMAconfig(int finalize); VOID config_init_buffers(COUNT anzBuffers); /* from BLOCKIO.C */ +#ifdef I86 STATIC VOID FAR * AlignParagraph(VOID FAR * lpPtr); -#ifndef I86 +#else #define AlignParagraph(x) ((VOID *)x) #endif @@ -659,12 +669,12 @@ STATIC struct table * LookUp(struct table *p, BYTE * token) 0x..LL : asciicode in lower half */ -ULONG GetBiosTime(VOID) +STATIC ULONG GetBiosTime(VOID) { return *(ULONG FAR *) (MK_FP(0x40, 0x6c)); } -UWORD GetBiosKey(int timeout) +STATIC UWORD GetBiosKey(int timeout) { iregs r; @@ -1106,25 +1116,25 @@ STATIC VOID DeviceHigh(BYTE * pLine) { if (UmbState == 1) { - if (LoadDevice(pLine, UMB_top, TRUE) == DE_NOMEM) + if (LoadDevice(pLine, MK_FP(umb_start + UMB_top, 0), TRUE) == DE_NOMEM) { printf("Not enough free memory in UMB's: loading low\n"); - LoadDevice(pLine, ram_top, FALSE); + LoadDevice(pLine, lpTop, FALSE); } } else { printf("UMB's unavailable!\n"); - LoadDevice(pLine, ram_top, FALSE); + LoadDevice(pLine, lpTop, FALSE); } } STATIC void Device(BYTE * pLine) { - LoadDevice(pLine, ram_top, FALSE); + LoadDevice(pLine, lpTop, FALSE); } -STATIC BOOL LoadDevice(BYTE * pLine, COUNT top, COUNT mode) +STATIC BOOL LoadDevice(BYTE * pLine, char FAR *top, COUNT mode) { exec_blk eb; struct dhdr FAR *dhp; diff --git a/kernel/dosfns.c b/kernel/dosfns.c index 0de7c08d..d0f18b85 100644 --- a/kernel/dosfns.c +++ b/kernel/dosfns.c @@ -89,21 +89,41 @@ STATIC int remote_lock_unlock(sft FAR *sftp, /* SFT for file */ unsigned long len, /* length (in bytes) of region to lock or unlock */ int unlock); /* non-zero to unlock; zero to lock */ +/* get current directory structure for drive + return NULL if the CDS is not valid or the + drive is not within range */ +struct cds FAR *get_cds(int drive) +{ + struct cds FAR *cdsp; + unsigned flags; + + if (drive >= lastdrive) + return NULL; + cdsp = &CDSp[drive]; + flags = cdsp->cdsFlags; + /* Entry is disabled or JOINed drives are accessable by the path only */ + if (!(flags & CDSVALID) || (flags & CDSJOINED) != 0) + return NULL; + if (!(flags & CDSNETWDRV) && cdsp->cdsDpb == NULL) + return NULL; + return cdsp; +} #ifdef WITHFAT32 struct dpb FAR * GetDriveDPB(UBYTE drive, COUNT * rc) { struct dpb FAR *dpb; - drive = drive == 0 ? default_drive : drive - 1; - - if (drive >= lastdrive) + struct cds FAR *cdsp; + + cdsp = get_cds(drive == 0 ? default_drive : drive - 1); + + if (cdsp == NULL) { *rc = DE_INVLDDRV; return 0; } - - dpb = CDSp[drive].cdsDpb; - if (dpb == 0 || CDSp[drive].cdsFlags & CDSNETWDRV) + dpb = cdsp->cdsDpb; + if (dpb == 0 || cdsp->cdsFlags & CDSNETWDRV) { *rc = DE_INVLDDRV; return 0; @@ -123,7 +143,7 @@ STATIC VOID DosGetFile(BYTE * lpszPath, BYTE FAR * lpszDosFileName) fmemcpy(lpszDosFileName, fcbname, FNAME_SIZE + FEXT_SIZE); } -sft FAR * idx_to_sft(COUNT SftIndex) +sft FAR * idx_to_sft(int SftIndex) { sfttbl FAR *sp; @@ -152,14 +172,16 @@ sft FAR * idx_to_sft(COUNT SftIndex) return (sft FAR *) - 1; } -COUNT get_sft_idx(UCOUNT hndl) +int get_sft_idx(unsigned hndl) { psp FAR *p = MK_FP(cu_psp, 0); + int idx; if (hndl >= p->ps_maxfiles) return DE_INVLDHNDL; - return p->ps_filetab[hndl] == 0xff ? DE_INVLDHNDL : p->ps_filetab[hndl]; + idx = p->ps_filetab[hndl]; + return idx == 0xff ? DE_INVLDHNDL : idx; } sft FAR *get_sft(UCOUNT hndl) @@ -168,21 +190,23 @@ sft FAR *get_sft(UCOUNT hndl) return idx_to_sft(get_sft_idx(hndl)); } -UCOUNT DosRWSft(sft FAR * s, UCOUNT n, void FAR * bp, COUNT * err, int mode) +long DosRWSft(int sft_idx, size_t n, void FAR * bp, int mode) { - *err = SUCCESS; + /* Get the SFT block that contains the SFT */ + sft FAR *s = idx_to_sft(sft_idx); + if (FP_OFF(s) == (size_t) - 1) { - *err = DE_INVLDHNDL; - return 0; + return DE_INVLDHNDL; } /* If for read and write-only or for write and read-only then exit */ if((mode == XFR_READ && (s->sft_mode & SFT_MWRITE)) || (mode == XFR_WRITE && !(s->sft_mode & (SFT_MWRITE | SFT_MRDWR)))) { - *err = DE_ACCESS; - return 0; + return DE_ACCESS; } + if (mode == XFR_FORCE_WRITE) + mode = XFR_WRITE; /* * Do remote first or return error. @@ -191,54 +215,68 @@ UCOUNT DosRWSft(sft FAR * s, UCOUNT n, void FAR * bp, COUNT * err, int mode) if (s->sft_flags & SFT_FSHARED) { UCOUNT XferCount; - BYTE FAR *save_dta; + VOID FAR *save_dta; + int err; save_dta = dta; lpCurSft = s; current_filepos = s->sft_posit; /* needed for MSCDEX */ dta = bp; - XferCount = (mode == XFR_READ ? remote_read : remote_write)(s, n, err); + XferCount = (mode == XFR_READ ? remote_read : remote_write)(s, n, &err); dta = save_dta; - return *err == SUCCESS ? XferCount : 0; + return err == SUCCESS ? XferCount : err; } /* Do a device transfer if device */ if (s->sft_flags & SFT_FDEVICE) { + /* Now handle raw and cooked modes */ + if (s->sft_flags & SFT_FBINARY) + { + long rc = BinaryCharIO(s->sft_dev, n, bp, + mode == XFR_READ ? C_INPUT : C_OUTPUT); + if (mode == XFR_WRITE && rc > 0 && (s->sft_flags & SFT_FCONOUT)) + { + size_t cnt = (size_t)rc; + const char FAR *p = bp; + while (cnt--) + { + switch (*p++) + { + case CR: + scr_pos = 0; + break; + case LF: + case BELL: + break; + case BS: + --scr_pos; + break; + default: + ++scr_pos; + } + } + } + return rc; + } + + /* cooked mode */ if (mode==XFR_READ) { - char c; - - /* First test for eof and exit */ + long rc; + + /* Test for eof and exit */ /* immediately if it is */ if (!(s->sft_flags & SFT_FEOF) || (s->sft_flags & SFT_FNUL)) - { return 0; - } - /* Now handle raw and cooked modes */ - if (s->sft_flags & SFT_FBINARY) - return BinaryCharIO(s->sft_dev, n, bp, C_INPUT, err); if (s->sft_flags & SFT_FCONIN) - { - n = sti(n, bp); - if (n == 0) - c = CTL_Z; - } + rc = read_line_handle(sft_idx, n, bp); else - { - n = 1; - Do_DosIdle_loop(); - BinaryReadSft(s, &c, err); - if (c != CTL_Z) - *(char FAR *)bp = c; - } - if (c == CTL_Z) - { - n = 0; + rc = cooked_read(sft_idx, n, bp); + if (*(char *)bp == CTL_Z) s->sft_flags &= ~SFT_FEOF; - } - return n; + return rc; } else { @@ -248,55 +286,8 @@ UCOUNT DosRWSft(sft FAR * s, UCOUNT n, void FAR * bp, COUNT * err, int mode) /* if null just report full transfer */ if (s->sft_flags & SFT_FNUL) return n; - - /* Now handle raw and cooked modes */ - if (s->sft_flags & SFT_FBINARY) - { - n = BinaryCharIO(s->sft_dev, n, bp, C_OUTPUT, err); - if (n > 0 && (s->sft_flags & SFT_FCONOUT)) - { - UWORD cnt = n; - const char FAR *p = bp; - while (cnt--) - { - switch (*p++) - { - case CR: - scr_pos = 0; - break; - case LF: - case BELL: - break; - case BS: - --scr_pos; - break; - default: - ++scr_pos; - } - } - } - return n; - } else - { - REG UWORD xfer; - const char FAR *p = bp; - - for (xfer = 0; xfer < n && *p != CTL_Z; p++, xfer++) - { - if (s->sft_flags & SFT_FCONOUT) - cso(*p); - else if (BinaryCharIO(s->sft_dev, 1, bp, C_OUTPUT, err) == 0 && - *err != SUCCESS) - return xfer; - if (control_break()) - { - handle_break(); - break; - } - } - return xfer; - } + return cooked_write(sft_idx, n, bp); } } @@ -304,10 +295,10 @@ UCOUNT DosRWSft(sft FAR * s, UCOUNT n, void FAR * bp, COUNT * err, int mode) /* /// Added for SHARE - Ron Cemer */ if (IsShareInstalled() && (s->sft_shroff >= 0)) { - *err = share_access_check(cu_psp, s->sft_shroff, s->sft_posit, - (unsigned long)n, 1); - if (*err != SUCCESS) - return 0; + int rc = share_access_check(cu_psp, s->sft_shroff, s->sft_posit, + (unsigned long)n, 1); + if (rc != SUCCESS) + return rc; } /* /// End of additions for SHARE - Ron Cemer */ { @@ -315,37 +306,17 @@ UCOUNT DosRWSft(sft FAR * s, UCOUNT n, void FAR * bp, COUNT * err, int mode) XferCount = rwblock(s->sft_status, bp, n, mode); if (mode == XFR_WRITE) s->sft_size = dos_getfsize(s->sft_status); + s->sft_posit += XferCount; return XferCount; } } -UCOUNT BinaryReadSft(sft FAR * s, void *bp, COUNT *err) -{ - if (FP_OFF(s) == (size_t) - 1) - { - *err = DE_INVLDHNDL; - return 0; - } - if (s->sft_mode & SFT_MWRITE) - { - *err = DE_INVLDACC; - return 0; - } - if (s->sft_flags & SFT_FDEVICE) - { - /* First test for eof and exit */ - /* immediately if it is */ - if (!(s->sft_flags & SFT_FEOF) || (s->sft_flags & SFT_FNUL)) - { - return 0; - } - return BinaryCharIO(s->sft_dev, 1, bp, C_INPUT, err); - } - return DosRWSft(s, 1, bp, err, XFR_READ); -} - -COUNT SftSeek(sft FAR * s, LONG new_pos, COUNT mode) +COUNT SftSeek(int sft_idx, LONG new_pos, COUNT mode) { + sft FAR *s = idx_to_sft(sft_idx); + if (FP_OFF(s) == (size_t) -1) + return DE_INVLDHNDL; + /* Test for invalid mode */ if (mode < 0 || mode > 2) return DE_INVLDFUNC; @@ -410,19 +381,16 @@ COUNT SftSeek(sft FAR * s, LONG new_pos, COUNT mode) } } -ULONG DosSeek(COUNT hndl, LONG new_pos, COUNT mode) +ULONG DosSeek(unsigned hndl, LONG new_pos, COUNT mode) { - sft FAR *s; + int sft_idx = get_sft_idx(hndl); COUNT result; /* Get the SFT block that contains the SFT */ - if ((s = get_sft(hndl)) == (sft FAR *) - 1) - return (ULONG)-1; - - result = SftSeek(s, new_pos, mode); + result = SftSeek(sft_idx, new_pos, mode); if (result == SUCCESS) { - return s->sft_posit; + return idx_to_sft(sft_idx)->sft_posit; } return (ULONG)-1; } @@ -440,7 +408,7 @@ STATIC long get_free_hndl(void) return DE_TOOMANY; } -sft FAR *get_free_sft(COUNT * sft_idx) +STATIC sft FAR *get_free_sft(COUNT * sft_idx) { COUNT sys_idx = 0; sfttbl FAR *sp; @@ -738,7 +706,7 @@ COUNT DosForceDup(unsigned OldHandle, unsigned NewHandle) return DE_INVLDHNDL; } -COUNT DosCloseSft(WORD sft_idx, BOOL commitonly) +COUNT DosCloseSft(int sft_idx, BOOL commitonly) { sft FAR *sftp = idx_to_sft(sft_idx); @@ -795,7 +763,7 @@ COUNT DosClose(COUNT hndl) BOOL DosGetFree(UBYTE drive, UWORD * spc, UWORD * navc, UWORD * bps, UWORD * nc) { - /* *nc==0xffff means: called from FatGetDrvData, fcbfns.c */ + /* navc==NULL means: called from FatGetDrvData, fcbfns.c */ struct dpb FAR *dpbp; struct cds FAR *cdsp; COUNT rg[4]; @@ -805,12 +773,9 @@ BOOL DosGetFree(UBYTE drive, UWORD * spc, UWORD * navc, /* first check for valid drive */ *spc = -1; - if (drive >= lastdrive) - return FALSE; - - cdsp = &CDSp[drive]; + cdsp = get_cds(drive); - if (!(cdsp->cdsFlags & CDSVALID)) + if (cdsp == NULL) return FALSE; if (cdsp->cdsFlags & CDSNETWDRV) @@ -825,11 +790,10 @@ BOOL DosGetFree(UBYTE drive, UWORD * spc, UWORD * navc, the redirector can provide all info - Bart, 2002 Apr 1 */ - if (*nc != 0xffff) + if (navc != NULL) { *navc = (COUNT) rg[3]; - rg[0] &= 0xff; - /* zero media ID (high part) */ + *spc &= 0xff; /* zero out media ID byte */ } *spc = (COUNT) rg[0]; @@ -842,7 +806,7 @@ BOOL DosGetFree(UBYTE drive, UWORD * spc, UWORD * navc, if (dpbp == NULL) return FALSE; - if (*nc == 0xffff) + if (navc == NULL) { /* hazard: no error checking! */ flush_buffers(dpbp->dpb_unit); @@ -852,7 +816,7 @@ BOOL DosGetFree(UBYTE drive, UWORD * spc, UWORD * navc, if (media_check(dpbp) < 0) return FALSE; /* get the data available from dpb */ - *spc = dpbp->dpb_clsmask + 1; + *spc = (dpbp->dpb_clsmask + 1); *bps = dpbp->dpb_secsize; /* now tell fs to give us free cluster */ @@ -865,7 +829,7 @@ BOOL DosGetFree(UBYTE drive, UWORD * spc, UWORD * navc, /* we shift ntotal until it is equal to or below 0xfff6 */ cluster_size = (ULONG) dpbp->dpb_secsize << dpbp->dpb_shftcnt; ntotal = dpbp->dpb_xsize - 1; - if (*nc != 0xffff) + if (navc != NULL) nfree = dos_free(dpbp); while (ntotal > FAT_MAGIC16 && cluster_size < 0x8000) { @@ -879,7 +843,8 @@ BOOL DosGetFree(UBYTE drive, UWORD * spc, UWORD * navc, /* now tell fs to give us free cluster */ /* count */ - *navc = nfree > FAT_MAGIC16 ? FAT_MAGIC16 : (UCOUNT) nfree; + if (navc != NULL) + *navc = nfree > FAT_MAGIC16 ? FAT_MAGIC16 : (UCOUNT) nfree; return TRUE; } #endif @@ -906,19 +871,15 @@ COUNT DosGetExtFree(BYTE FAR * DriveString, struct xfreespace FAR * xfsp) { struct dpb FAR *dpbp; struct cds FAR *cdsp; - UBYTE drive; UCOUNT rg[4]; if (IS_SLASH(DriveString[0]) || !IS_SLASH(DriveString[2]) || DriveString[1] != ':') return DE_INVLDDRV; - drive = DosUpFChar(*DriveString) - 'A'; - if (drive >= lastdrive) - return DE_INVLDDRV; - cdsp = &CDSp[drive]; + cdsp = get_cds(DosUpFChar(*DriveString) - 'A'); - if (!(cdsp->cdsFlags & CDSVALID)) + if (cdsp == NULL) return DE_INVLDDRV; if (cdsp->cdsFlags & CDSNETWDRV) @@ -932,7 +893,7 @@ COUNT DosGetExtFree(BYTE FAR * DriveString, struct xfreespace FAR * xfsp) } else { - dpbp = CDSp[drive].cdsDpb; + dpbp = cdsp->cdsDpb; if (dpbp == NULL || media_check(dpbp) < 0) return DE_INVLDDRV; xfsp->xfs_secsize = dpbp->dpb_secsize; @@ -959,17 +920,12 @@ COUNT DosGetCuDir(UBYTE drive, BYTE FAR * s) struct cds FAR *cdsp; /* next - "log" in the drive */ - drive = (drive == 0 ? default_drive : drive - 1); - /* first check for valid drive */ - if (drive >= lastdrive) + cdsp = get_cds(drive == 0 ? default_drive : drive - 1); + if (cdsp == NULL) return DE_INVLDDRV; - cdsp = &CDSp[drive]; fmemcpy(&TempCDS, cdsp, sizeof(TempCDS)); - if (!(TempCDS.cdsFlags & CDSVALID)) - return DE_INVLDDRV; - cp = TempCDS.cdsCurrentPath; /* ensure termination of fstrcpy */ cp[MAX_CDSPATH - 1] = '\0'; @@ -978,7 +934,7 @@ COUNT DosGetCuDir(UBYTE drive, BYTE FAR * s) { /* dos_cd ensures that the path exists; if not, we need to change to the root directory */ - int result = dos_cd(cdsp, cp); + int result = dos_cd(cp); if (result == DE_PATHNOTFND) cp[TempCDS.cdsBackslashOffset + 1] = cdsp->cdsCurrentPath[TempCDS.cdsBackslashOffset + 1] = '\0'; @@ -1020,8 +976,7 @@ COUNT DosChangeDir(BYTE FAR * s) #endif /* now get fs to change to new */ /* directory */ - result = (result & IS_NETWORK ? remote_chdir() : - dos_cd(current_ldt, PriPathName)); + result = (result & IS_NETWORK ? remote_chdir() : dos_cd(PriPathName)); #if defined(CHDIR_DEBUG) printf("status = %04x, new_path='%Fs'\n", result, cdsd->cdsCurrentPath); #endif @@ -1051,8 +1006,8 @@ STATIC VOID pop_dmp(dmatch FAR * dmp) COUNT DosFindFirst(UCOUNT attr, BYTE FAR * name) { - COUNT rc; - REG dmatch FAR *dmp = (dmatch FAR *) dta; + int rc; + register dmatch FAR *dmp = dta; rc = truename(name, PriPathName, CDS_MODE_CHECK_DEV_PATH); if (rc < SUCCESS) @@ -1079,8 +1034,8 @@ COUNT DosFindFirst(UCOUNT attr, BYTE FAR * name) printf("Remote Find: n='%Fs\n", PriPathName); #endif - fmemcpy(TempBuffer, dta, 21); - dta = TempBuffer; + fmemcpy(&sda_tmp_dm, dta, 21); + dta = &sda_tmp_dm; if (rc & IS_NETWORK) rc = remote_findfirst(current_ldt); @@ -1097,18 +1052,14 @@ COUNT DosFindFirst(UCOUNT attr, BYTE FAR * name) memset(SearchDir.dir_name, ' ', FNAME_SIZE + FEXT_SIZE); for (i = 0; i < FNAME_SIZE && *p && *p != '.'; i++) SearchDir.dir_name[i] = *p++; - if (*p == '.') - p++; - for (i = FNAME_SIZE; i < FNAME_SIZE + FEXT_SIZE && *p && *p != '.'; i++) - SearchDir.dir_name[i] = *p++; rc = SUCCESS; /* /// End of additions. - Ron Cemer ; heavily edited - Bart Oldeman */ } else rc = dos_findfirst(attr, PriPathName); - dta = (char FAR *) dmp; - fmemcpy(dta, TempBuffer, 21); + dta = dmp; + fmemcpy(dta, &sda_tmp_dm, 21); pop_dmp(dmp); if (rc != SUCCESS) dmp->dm_attr_fnd = D_DEVICE; /* mark invalid */ @@ -1118,10 +1069,10 @@ COUNT DosFindFirst(UCOUNT attr, BYTE FAR * name) COUNT DosFindNext(void) { COUNT rc; - BYTE FAR *p; + register dmatch FAR *dmp = dta; /* /// findnext will always fail on a device name. - Ron Cemer */ - if (((dmatch FAR *) dta)->dm_attr_fnd == D_DEVICE) + if (dmp->dm_attr_fnd == D_DEVICE) return DE_NFILES; /* @@ -1142,19 +1093,17 @@ COUNT DosFindNext(void) * (12h, DE_NFILES) */ #if 0 - printf("findnext: %d\n", ((dmatch FAR *) dta)->dm_drive); + printf("findnext: %d\n", dmp->dm_drive); #endif - fmemcpy(TempBuffer, dta, 21); - fmemset(dta, 0, sizeof(dmatch)); - p = dta; - dta = (BYTE FAR *) TempBuffer; - current_ldt = &CDSp[((dmatch *) TempBuffer)->dm_drive]; - rc = (((dmatch *) TempBuffer)->dm_drive & 0x80) ? - remote_findnext((VOID FAR *) current_ldt) : dos_findnext(); - - dta = p; - fmemcpy(dta, TempBuffer, 21); - pop_dmp((dmatch FAR *) dta); + fmemcpy(&sda_tmp_dm, dmp, 21); + fmemset(dmp, 0, sizeof(*dmp)); + dta = &sda_tmp_dm; + rc = (sda_tmp_dm.dm_drive & 0x80) ? + remote_findnext(&sda_tmp_dm) : dos_findnext(); + + dta = dmp; + fmemcpy(dmp, &sda_tmp_dm, 21); + pop_dmp(dmp); return rc; } @@ -1179,7 +1128,7 @@ COUNT DosGetFtime(COUNT hndl, date * dp, time * tp) return dos_getftime(s->sft_status, dp, tp); } -COUNT DosSetFtimeSft(WORD sft_idx, date dp, time tp) +COUNT DosSetFtimeSft(int sft_idx, date dp, time tp) { /* Get the SFT block that contains the SFT */ sft FAR *s = idx_to_sft(sft_idx); @@ -1292,14 +1241,9 @@ COUNT DosSetFattr(BYTE FAR * name, UWORD attrp) UBYTE DosSelectDrv(UBYTE drv) { - current_ldt = &CDSp[drv]; + current_ldt = get_cds(drv); - if ((drv < lastdrive) && (current_ldt->cdsFlags & CDSVALID)) -/* - && - ((cdsp->cdsFlags & CDSNETWDRV) || - (cdsp->cdsDpb!=NULL && media_check(cdsp->cdsDpb)==SUCCESS))) -*/ + if (current_ldt != NULL) default_drive = drv; return lastdrive; diff --git a/kernel/dosidle.asm b/kernel/dosidle.asm index bbcdf479..e0e4cab3 100644 --- a/kernel/dosidle.asm +++ b/kernel/dosidle.asm @@ -40,9 +40,7 @@ segment HMA_TEXT extern _cu_psp:wrt DGROUP extern _MachineId:wrt DGROUP extern critical_sp:wrt DGROUP - extern _lpUserStack:wrt DGROUP extern _user_r:wrt DGROUP - extern _dosidle_flag:wrt DGROUP ; ; _DosIdle_int: @@ -51,22 +49,19 @@ _DosIdle_int: mov ax, DGROUP mov ds,ax pop ax - cmp byte [_dosidle_flag],0 - jnz DosId1 + cmp byte [_InDOS],1 + ja DosId1 call Do_DosI DosId1: pop ds retn Do_DosI: - inc byte [_dosidle_flag] push ax push es push word [_MachineId] push word [_user_r] push word [_user_r+2] - push word [_lpUserStack] - push word [_lpUserStack+2] mov es,word [_cu_psp] push word [es:PSP_USERSS] push word [es:PSP_USERSP] @@ -76,13 +71,10 @@ Do_DosI: mov es,word [_cu_psp] pop word [es:PSP_USERSP] pop word [es:PSP_USERSS] - pop word [_lpUserStack+2] - pop word [_lpUserStack] pop word [_user_r+2] pop word [_user_r] pop word [_MachineId] pop es pop ax - dec byte [_dosidle_flag] ret diff --git a/kernel/dsk.c b/kernel/dsk.c index 53df579a..0efb8df8 100644 --- a/kernel/dsk.c +++ b/kernel/dsk.c @@ -199,6 +199,9 @@ COUNT ASMCFUNC FAR blk_driver(rqptr rp) return ((*dispatch[rp->r_command]) (rp, getddt(rp->r_unit))); } +STATIC char template_string[] = "XXXXXX diskette in drive X:\n"; +#define DRIVE_POS (sizeof(template_string) - 2) + STATIC WORD play_dj(ddt * pddt) { /* play the DJ ... */ @@ -215,12 +218,16 @@ STATIC WORD play_dj(ddt * pddt) } if (i == nUnits) { - printf("Error in the DJ mechanism!\n"); /* should not happen! */ + put_string("Error in the DJ mechanism!\n"); /* should not happen! */ return M_CHANGED; } - printf("Remove diskette in drive %c:\n", 'A' + pddt2->ddt_logdriveno); - printf("Insert diskette in drive %c:\n", 'A' + pddt->ddt_logdriveno); - printf("Press the any key to continue ... \n"); + memcpy(template_string, "Remove", 6); + template_string[DRIVE_POS] = 'A' + pddt2->ddt_logdriveno; + put_string(template_string); + memcpy(template_string, "Insert", 6); + template_string[DRIVE_POS] = 'A' + pddt->ddt_logdriveno; + put_string(template_string); + put_string("Press the any key to continue ... \n"); fl_readkey(); pddt2->ddt_descflags &= ~DF_CURLOG; pddt->ddt_descflags |= DF_CURLOG; @@ -863,11 +870,13 @@ STATIC WORD dskerr(COUNT code) translate LBA sectors into CHS addressing */ -STATIC void LBA_to_CHS(struct CHS *chs, ULONG LBA_address, ddt * pddt) +STATIC int LBA_to_CHS(struct CHS *chs, ULONG LBA_address, ddt * pddt) { /* we need the defbpb values since those are taken from the BIOS, not from some random boot sector, except when we're dealing with a floppy */ + unsigned long cylinder; + bpb *pbpb = hd(pddt->ddt_descflags) ? &pddt->ddt_defbpb : &pddt->ddt_bpb; chs->Sector = LBA_address % pbpb->bpb_nsecs + 1; @@ -875,7 +884,20 @@ STATIC void LBA_to_CHS(struct CHS *chs, ULONG LBA_address, ddt * pddt) LBA_address /= pbpb->bpb_nsecs; chs->Head = LBA_address % pbpb->bpb_nheads; - chs->Cylinder = LBA_address / pbpb->bpb_nheads; + + cylinder = LBA_address / pbpb->bpb_nheads; + + if (cylinder > 1023ul) + { +#ifdef DEBUG + printf("LBA-Transfer error : cylinder %lu > 1023\n", cylinder); +#else + put_string("LBA-Transfer error : cylinder > 1023\n"); +#endif + return 1; + } + chs->Cylinder = cylinder; + return 0; } /* Test for 64K boundary crossing and return count small */ @@ -1014,7 +1036,8 @@ STATIC int LBA_Transfer(ddt * pddt, UWORD mode, VOID FAR * buffer, else { /* transfer data, using old bios functions */ - LBA_to_CHS(&chs, LBA_address, pddt); + if (LBA_to_CHS(&chs, LBA_address, pddt)) + return 1; /* avoid overflow at end of track */ @@ -1023,21 +1046,13 @@ STATIC int LBA_Transfer(ddt * pddt, UWORD mode, VOID FAR * buffer, count = pddt->ddt_bpb.bpb_nsecs + 1 - chs.Sector; } - if (chs.Cylinder > 1023) - { - printf("LBA-Transfer error : cylinder %lu > 1023\n", - chs.Cylinder); - return 1; - } - error_code = (mode == LBA_READ ? fl_read : mode == LBA_VERIFY ? fl_verify : mode == LBA_FORMAT ? fl_format : fl_write) (pddt-> ddt_driveno, chs.Head, - (UWORD) chs. - Cylinder, + chs.Cylinder, chs.Sector, count, transfer_address); @@ -1045,7 +1060,7 @@ STATIC int LBA_Transfer(ddt * pddt, UWORD mode, VOID FAR * buffer, if (error_code == 0 && mode == LBA_WRITE_VERIFY) { error_code = fl_verify(pddt->ddt_driveno, - chs.Head, (UWORD) chs.Cylinder, + chs.Head, chs.Cylinder, chs.Sector, count, transfer_address); } } diff --git a/kernel/entry.asm b/kernel/entry.asm index 24243686..92cd25af 100644 --- a/kernel/entry.asm +++ b/kernel/entry.asm @@ -38,7 +38,6 @@ segment HMA_TEXT extern _error_tos:wrt DGROUP extern _char_api_tos:wrt DGROUP extern _disk_api_tos:wrt DGROUP - extern _lpUserStack:wrt DGROUP extern _user_r:wrt DGROUP extern _ErrorMode:wrt DGROUP extern _InDOS:wrt DGROUP @@ -49,7 +48,6 @@ segment HMA_TEXT extern int21regs_seg:wrt DGROUP extern int21regs_off:wrt DGROUP - extern _dosidle_flag:wrt DGROUP extern _Int21AX:wrt DGROUP @@ -116,28 +114,6 @@ reloc_call_cpm_entry: cpm_error: mov al,0 iret -; -; Restart the int 21h system call. Call never returns. -; -; VOID -; RestartSysCall(VOID); -; -; NOTE: On exit, DS must point to kernel stack, SS:SP user stack after -; PUSH$ALL and BP == SP. -; -%if 0 ; this is dead code now -_RestartSysCall: - cli ; no interrupts - mov bp,word [_lpUserStack+2] ;Get frame - mov ss,bp - mov bp,word [_lpUserStack] - mov sp,bp - sti - POP$ALL ; get the original regs - jmp short int21_reentry ; restart the system call -%endif - - ; ; interrupt zero divide handler: ; print a message 'Interrupt divide by zero' @@ -203,6 +179,9 @@ stack_loop: mov ax,04c7fh ; terminate with errorlevel 127 int 21h + sti +thats_it: hlt + jmp short thats_it ; it might be command.com that nukes invalid_opcode_message db 0dh,0ah,'Invalid Opcode at ',0 @@ -272,7 +251,7 @@ int21_user: call _int21_syscall pop cx pop cx - jmp int21_ret + jmp short int21_ret ; ; normal entry, use one of our 4 stacks @@ -292,9 +271,7 @@ int21_1: ; ; I don't know who needs that, but ... (TE) ; - mov word [_lpUserStack+2],ss mov word [_user_r+2],ss - mov word [_lpUserStack],bp ; store and init mov word [_user_r],bp ; store and init ; @@ -311,16 +288,12 @@ int21_1: ; call number. Finally, all others run on the disk stack. ; They are evaluated in that order. - - cmp byte [_InDOS],0 - jne int21_onerrorstack - cmp byte [_ErrorMode],0 je int21_2 int21_onerrorstack: mov cx,_error_tos - + cli mov ss,dx @@ -332,16 +305,14 @@ int21_onerrorstack: call _int21_service jmp short int21_exit_nodec - + int21_2: inc byte [_InDOS] mov cx,_char_api_tos or ah,ah jz int21_3 cmp ah,0ch jle int21_normalentry - cmp ah,59h - je int21_normalentry int21_3: call dos_crit_sect @@ -436,7 +407,7 @@ reloc_call_low_int26_handler: pushf push ax mov ax,026h - jmp int2526 + jmp short int2526 reloc_call_low_int25_handler: sti pushf diff --git a/kernel/error.c b/kernel/error.c index 8139f0fe..88457df8 100644 --- a/kernel/error.c +++ b/kernel/error.c @@ -51,7 +51,9 @@ VOID dump(void) /* issue a panic message for corrupted data structures */ VOID panic(BYTE * s) { - printf("\nPANIC: %s\nSystem halted\n", s); + put_string("\nPANIC: "); + put_string(s); + put_string("\nSystem halted"); for (;;) ; } diff --git a/kernel/fatdir.c b/kernel/fatdir.c index 25ca4ef0..225a8b0a 100644 --- a/kernel/fatdir.c +++ b/kernel/fatdir.c @@ -72,6 +72,7 @@ f_node_ptr dir_open(register const char *dirname) { f_node_ptr fnp; int i; + char fcbname[FNAME_SIZE + FEXT_SIZE]; /* Allocate an fnode if possible - error return (0) if not. */ if ((fnp = get_f_node()) == (f_node_ptr) 0) @@ -83,22 +84,7 @@ f_node_ptr dir_open(register const char *dirname) fnp->f_mode = RDWR; /* determine what drive and dpb we are using... */ - fnp->f_dpb = CDSp[dirname[0]-'A'].cdsDpb; - if (fnp->f_dpb == 0) - { - release_f_node(fnp); - return NULL; - } - -/* for testing only for now */ -#if 0 - if ((CDSp[dirname[0]-'A'].cdsFlags & CDSNETWDRV)) - { - printf("FailSafe %x \n", Int21AX); - return fnp; - } -#endif - + fnp->f_dpb = get_dpb(dirname[0]-'A'); /* Perform all directory common handling after all special */ /* handling has been performed. */ @@ -133,13 +119,13 @@ f_node_ptr dir_open(register const char *dirname) /* comparison... */ /* first the file name with trailing spaces... */ - memset(TempBuffer, ' ', FNAME_SIZE + FEXT_SIZE); + memset(fcbname, ' ', FNAME_SIZE + FEXT_SIZE); for (i = 0; i < FNAME_SIZE; i++) { if (*dirname != '\0' && *dirname != '.' && *dirname != '/' && *dirname != '\\') - TempBuffer[i] = *dirname++; + fcbname[i] = *dirname++; else break; } @@ -152,7 +138,7 @@ f_node_ptr dir_open(register const char *dirname) { if (*dirname != '\0' && *dirname != '.' && *dirname != '/' && *dirname != '\\') - TempBuffer[i + FNAME_SIZE] = *dirname++; + fcbname[i + FNAME_SIZE] = *dirname++; else break; } @@ -164,7 +150,7 @@ f_node_ptr dir_open(register const char *dirname) while (dir_read(fnp) == 1) { if (!(fnp->f_dir.dir_attrib & D_VOLID) && - fcbmatch(TempBuffer, fnp->f_dir.dir_name)) + fcbmatch(fcbname, fnp->f_dir.dir_name)) { i = TRUE; break; @@ -410,7 +396,7 @@ VOID dir_close(REG f_node_ptr fnp) COUNT dos_findfirst(UCOUNT attr, BYTE * name) { REG f_node_ptr fnp; - REG dmatch *dmp = (dmatch *) TempBuffer; + REG dmatch *dmp = &sda_tmp_dm; REG COUNT i; /* printf("ff %Fs\n", name);*/ @@ -507,9 +493,9 @@ COUNT dos_findfirst(UCOUNT attr, BYTE * name) COUNT dos_findnext(void) { - REG dmatch *dmp = (dmatch *) TempBuffer; REG f_node_ptr fnp; BOOL found = FALSE; + REG dmatch *dmp = &sda_tmp_dm; /* Allocate an fnode if possible - error return (0) if not. */ if ((fnp = get_f_node()) == (f_node_ptr) 0) @@ -524,7 +510,7 @@ COUNT dos_findnext(void) /* Select the default to help non-drive specified path */ /* searches... */ - fnp->f_dpb = CDSp[dmp->dm_drive].cdsDpb; + fnp->f_dpb = get_dpb(dmp->dm_drive); if (media_check(fnp->f_dpb) < 0) { release_f_node(fnp); diff --git a/kernel/fatfs.c b/kernel/fatfs.c index a9d9b9e7..0872fb41 100644 --- a/kernel/fatfs.c +++ b/kernel/fatfs.c @@ -47,8 +47,6 @@ STATIC void merge_file_changes(f_node_ptr fnp, int collect); STATIC int is_same_file(f_node_ptr fnp1, f_node_ptr fnp2); /* /// Added - Ron Cemer */ STATIC void copy_file_changes(f_node_ptr src, f_node_ptr dst); -date dos_getdate(VOID); -time dos_gettime(VOID); BOOL find_free(f_node_ptr); CLUSTER find_fat_free(f_node_ptr); VOID wipe_out(f_node_ptr); @@ -69,6 +67,37 @@ ULONG clus2phys(CLUSTER cl_no, struct dpb FAR * dpbp) return ((ULONG) (cl_no - 2) << dpbp->dpb_shftcnt) + data; } +struct dpb FAR *get_dpb(COUNT dsk) +{ + register struct cds FAR *cdsp = get_cds(dsk); + + if (cdsp == NULL || cdsp->cdsFlags & CDSNETWDRV) + return NULL; + return cdsp->cdsDpb; +} + +/* initialize all direntry fields except for the name */ +STATIC void init_direntry(struct dirent *dentry, unsigned attrib, + CLUSTER cluster) +{ + struct dostime dt; + + dentry->dir_size = 0l; +#ifndef WITHFAT32 + dentry->dir_start_high = 0; +#endif + setdstart((*dentry), cluster); + dentry->dir_attrib = attrib; + dentry->dir_case = 0; + DosGetTime(&dt); + dentry->dir_crtimems = dt.hundredth; + if (dt.second & 1) + dentry->dir_crtimems += 100; + dentry->dir_time = dentry->dir_crtime = + TM_ENCODE(dt.hour, dt.minute, dt.second >> 1); + dentry->dir_date = dentry->dir_crdate = dentry->dir_accdate = dos_getdate(); +} + /************************************************************************/ /* */ /* Internal file handlers - open, create, read, write, close, etc. */ @@ -174,13 +203,8 @@ long dos_open(char *path, unsigned flags, unsigned attrib) fnp->f_mode = flags & 3; if (status != S_OPENED) - { - fnp->f_dir.dir_size = 0l; - setdstart(fnp->f_dir, FREE); - fnp->f_dir.dir_attrib = attrib; - fnp->f_dir.dir_time = dos_gettime(); - fnp->f_dir.dir_date = dos_getdate(); - + { + init_direntry(&fnp->f_dir, attrib, FREE); fnp->f_flags.f_dmod = TRUE; fnp->f_flags.f_ddate = FALSE; fnp->f_flags.f_dnew = FALSE; @@ -320,7 +344,7 @@ f_node_ptr split_path(char * path, char * fcbname) */ #ifdef DEBUG - if (CDSp[path[0]-'A'].cdsFlags & CDSNETWDRV) + if (get_cds(path[0]-'A')->cdsFlags & CDSNETWDRV) { printf("split path called for redirected file: `%s'\n", fcbname); @@ -808,30 +832,27 @@ STATIC BOOL find_free(f_node_ptr fnp) /* */ /* dos_getdate for the file date */ /* */ -date dos_getdate() +date dos_getdate(void) { - UBYTE WeekDay, Month, MonthDay; - UWORD Year; - date Date; + struct dosdate dd; /* First - get the system date set by either the user */ /* on start-up or the CMOS clock */ - DosGetDate(&WeekDay, &Month, &MonthDay, &Year); - Date = DT_ENCODE(Month, MonthDay, Year - EPOCH_YEAR); - return Date; + DosGetDate(&dd); + return DT_ENCODE(dd.month, dd.monthday, dd.year - EPOCH_YEAR); } /* */ /* dos_gettime for the file time */ /* */ -time dos_gettime() +time dos_gettime(void) { - UBYTE Hour, Minute, Second, Hundredth; + struct dostime dt; /* First - get the system time set by either the user */ /* on start-up or the CMOS clock */ - DosGetTime(&Hour, &Minute, &Second, &Hundredth); - return TM_ENCODE(Hour, Minute, Second / 2); + DosGetTime(&dt); + return TM_ENCODE(dt.hour, dt.minute, dt.second >> 1); } /* */ @@ -1093,10 +1114,7 @@ COUNT dos_mkdir(BYTE * dir) fnp->f_mode = WRONLY; fnp->f_back = LONG_LAST_CLUSTER; - fnp->f_dir.dir_size = 0l; - fnp->f_dir.dir_attrib = D_DIR; - fnp->f_dir.dir_time = dos_gettime(); - fnp->f_dir.dir_date = dos_getdate(); + init_direntry(&fnp->f_dir, D_DIR, free_fat); fnp->f_flags.f_dmod = TRUE; fnp->f_flags.f_dnew = FALSE; @@ -1107,7 +1125,6 @@ COUNT dos_mkdir(BYTE * dir) /* Mark the cluster in the FAT as used */ fnp->f_cluster = free_fat; - setdstart(fnp->f_dir, free_fat); dpbp = fnp->f_dpb; link_fat(dpbp, free_fat, LONG_LAST_CLUSTER); @@ -1127,11 +1144,7 @@ COUNT dos_mkdir(BYTE * dir) /* Create the "." entry */ DirEntBuffer.dir_name[0] = '.'; memset(DirEntBuffer.dir_name + 1, ' ', FNAME_SIZE + FEXT_SIZE - 1); - DirEntBuffer.dir_attrib = D_DIR; - DirEntBuffer.dir_time = dos_gettime(); - DirEntBuffer.dir_date = dos_getdate(); - setdstart(DirEntBuffer, free_fat); - DirEntBuffer.dir_size = 0l; + init_direntry(&DirEntBuffer, D_DIR, free_fat); /* And put it out */ putdirent(&DirEntBuffer, bp->b_buffer); @@ -1177,7 +1190,7 @@ COUNT dos_mkdir(BYTE * dir) /* flush the drive buffers so that all info is written */ /* hazard: no error checking! */ - flush_buffers((COUNT) (dpbp->dpb_unit)); + flush_buffers(dpbp->dpb_unit); /* Close the directory so that the entry is updated */ fnp->f_flags.f_dmod = TRUE; @@ -1258,7 +1271,7 @@ STATIC COUNT extend_dir(f_node_ptr fnp) /* flush the drive buffers so that all info is written */ /* hazard: no error checking! */ - flush_buffers((COUNT) (fnp->f_dpb->dpb_unit)); + flush_buffers(fnp->f_dpb->dpb_unit); return SUCCESS; @@ -1875,13 +1888,10 @@ CLUSTER dos_free(struct dpb FAR * dpbp) } #ifndef IPL -COUNT dos_cd(struct cds FAR * cdsp, BYTE * PathName) +int dos_cd(char * PathName) { f_node_ptr fnp; - - /* first check for valid drive */ - if (cdsp->cdsDpb == 0) - return DE_INVLDDRV; + struct cds FAR *cdsp = get_cds(PathName[0] - 'A'); if ((media_check(cdsp->cdsDpb) < 0)) return DE_INVLDDRV; @@ -2050,6 +2060,9 @@ VOID bpb_to_dpb(bpb FAR * bpbp, REG struct dpb FAR * dpbp) COUNT media_check(REG struct dpb FAR * dpbp) { + if (dpbp == NULL) + return DE_INVLDDRV; + /* First test if anyone has changed the removable media */ FOREVER { @@ -2153,17 +2166,6 @@ COUNT xlt_fnp(f_node_ptr fnp) return (COUNT) (fnp - f_nodes); } -#if 0 -struct dhdr FAR *select_unit(COUNT drive) -{ - /* Just get the header from the dhdr array */ -/* return blk_devices[drive].dpb_device; */ - - return (struct dhdr FAR *)CDSp[drive].cdsDpb; - -} -#endif - /* TE if the current filesize in FAT is larger then the dir_size it's truncated here. diff --git a/kernel/fcbfns.c b/kernel/fcbfns.c index c010ff62..c2180579 100644 --- a/kernel/fcbfns.c +++ b/kernel/fcbfns.c @@ -55,16 +55,13 @@ static dmatch Dmatch; BYTE FAR *FatGetDrvData(UBYTE drive, UWORD * spc, UWORD * bps, UWORD * nc) { static BYTE mdb; - UWORD navc; /* get the data available from dpb */ - *nc = 0xffff; /* pass 0xffff to skip free count */ - if (DosGetFree(drive, spc, &navc, bps, nc)) + if (DosGetFree(drive, spc, NULL, bps, nc)) { - struct cds FAR *cdsp = - &CDSp[(drive == 0 ? default_drive : drive - 1)]; + struct dpb FAR *dpbp = get_dpb(drive == 0 ? default_drive : drive - 1); /* Point to the media desctriptor for this drive */ - if (cdsp->cdsFlags & CDSNETWDRV) + if (dpbp == NULL) { mdb = *spc >> 8; *spc &= 0xff; @@ -72,7 +69,7 @@ BYTE FAR *FatGetDrvData(UBYTE drive, UWORD * spc, UWORD * bps, UWORD * nc) } else { - return (BYTE FAR *) & (cdsp->cdsDpb->dpb_mdb); + return (BYTE FAR *) & (dpbp->dpb_mdb); } } return NULL; @@ -231,7 +228,7 @@ const BYTE FAR * GetNameField(const BYTE FAR * lpFileName, BYTE FAR * lpDestFiel STATIC VOID FcbNextRecord(fcb FAR * lpFcb) { - if (++lpFcb->fcb_curec > 128) + if (++lpFcb->fcb_curec >= 128) { lpFcb->fcb_curec = 0; ++lpFcb->fcb_cublock; @@ -245,10 +242,11 @@ STATIC ULONG FcbRec(VOID) UBYTE FcbReadWrite(xfcb FAR * lpXfcb, UCOUNT recno, int mode) { - sft FAR *s; ULONG lPosit; - UCOUNT nTransfer; - BYTE far * FcbIoPtr = dta + recno * lpFcb->fcb_recsiz; + long nTransfer; + BYTE FAR * FcbIoPtr = dta; + + FcbIoPtr += recno * lpFcb->fcb_recsiz; if ((ULONG)recno * lpFcb->fcb_recsiz >= 0x10000ul || FP_OFF(FcbIoPtr) < FP_OFF(dta)) @@ -257,34 +255,27 @@ UBYTE FcbReadWrite(xfcb FAR * lpXfcb, UCOUNT recno, int mode) /* Convert to fcb if necessary */ lpFcb = ExtFcbToFcb(lpXfcb); - /* Get the SFT block that contains the SFT */ - if ((s = idx_to_sft(lpFcb->fcb_sftno)) == (sft FAR *) - 1) - return FCB_ERR_NODATA; - - /* If this is not opened another error */ - if (s->sft_count == 0) - return FCB_ERR_NODATA; - /* Now update the fcb and compute where we need to position */ /* to. */ lPosit = FcbRec() * lpFcb->fcb_recsiz; - if ((CritErrCode = -SftSeek(s, lPosit, 0)) != SUCCESS) + if ((CritErrCode = -SftSeek(lpFcb->fcb_sftno, lPosit, 0)) != SUCCESS) return FCB_ERR_NODATA; /* Do the read */ - nTransfer = DosRWSft(s, lpFcb->fcb_recsiz, FcbIoPtr, &CritErrCode, mode); - CritErrCode = -CritErrCode; + nTransfer = DosRWSft(lpFcb->fcb_sftno, lpFcb->fcb_recsiz, FcbIoPtr, mode); + if (nTransfer < 0) + CritErrCode = -(int)nTransfer; /* Now find out how we will return and do it. */ if (nTransfer == lpFcb->fcb_recsiz) { - if (mode == XFR_WRITE) lpFcb->fcb_fsize = s->sft_size; + if (mode == XFR_WRITE) lpFcb->fcb_fsize = SftGetFsize(lpFcb->fcb_sftno); FcbNextRecord(lpFcb); return FCB_SUCCESS; } if (mode == XFR_READ && nTransfer > 0) { - fmemset(FcbIoPtr + nTransfer, 0, lpFcb->fcb_recsiz - nTransfer); + fmemset(FcbIoPtr + (unsigned)nTransfer, 0, lpFcb->fcb_recsiz - (unsigned)nTransfer); FcbNextRecord(lpFcb); return FCB_ERR_EOF; } @@ -293,7 +284,7 @@ UBYTE FcbReadWrite(xfcb FAR * lpXfcb, UCOUNT recno, int mode) UBYTE FcbGetFileSize(xfcb FAR * lpXfcb) { - COUNT FcbDrive, hndl; + int FcbDrive, sft_idx; /* Build a traditional DOS file name */ lpFcb = CommonFcbInit(lpXfcb, SecPathName, &FcbDrive); @@ -302,13 +293,13 @@ UBYTE FcbGetFileSize(xfcb FAR * lpXfcb) if (!lpFcb || IsDevice(SecPathName) || (lpFcb->fcb_recsiz == 0)) return FCB_ERROR; - hndl = (short)DosOpen(SecPathName, O_LEGACY | O_RDONLY | O_OPEN, 0); - if (hndl >= 0) + sft_idx = (short)DosOpenSft(SecPathName, O_LEGACY | O_RDONLY | O_OPEN, 0); + if (sft_idx >= 0) { ULONG fsize; /* Get the size */ - fsize = DosGetFsize(hndl); + fsize = SftGetFsize(sft_idx); /* compute the size and update the fcb */ lpFcb->fcb_rndm = fsize / lpFcb->fcb_recsiz; @@ -316,11 +307,11 @@ UBYTE FcbGetFileSize(xfcb FAR * lpXfcb) ++lpFcb->fcb_rndm; /* close the file and leave */ - if ((CritErrCode = -DosClose(hndl)) == SUCCESS) + if ((CritErrCode = -DosCloseSft(sft_idx, FALSE)) == SUCCESS) return FCB_SUCCESS; } else - CritErrCode = -hndl; + CritErrCode = -sft_idx; return FCB_ERROR; } @@ -471,7 +462,7 @@ int FcbNameInit(fcb FAR * lpFcb, BYTE * szBuffer, COUNT * pCurDrive) { *pCurDrive = default_drive + 1; } - ConvertName83ToNameSZ(pszBuffer, (BYTE FAR *) lpFcb->fcb_fname); + ConvertName83ToNameSZ(pszBuffer, lpFcb->fcb_fname); return truename(loc_szBuffer, szBuffer, CDS_MODE_CHECK_DEV_PATH); } @@ -479,7 +470,7 @@ UBYTE FcbDelete(xfcb FAR * lpXfcb) { COUNT FcbDrive; UBYTE result = FCB_SUCCESS; - BYTE FAR *lpOldDta = dta; + void FAR *lpOldDta = dta; /* Build a traditional DOS file name */ CommonFcbInit(lpXfcb, SecPathName, &FcbDrive); @@ -493,7 +484,7 @@ UBYTE FcbDelete(xfcb FAR * lpXfcb) int attr = (lpXfcb->xfcb_flag == 0xff ? lpXfcb->xfcb_attrib : D_ALL); dmatch Dmatch; - dta = (BYTE FAR *) & Dmatch; + dta = &Dmatch; if ((CritErrCode = -DosFindFirst(attr, SecPathName)) != SUCCESS) { result = FCB_ERROR; @@ -520,7 +511,7 @@ UBYTE FcbRename(xfcb FAR * lpXfcb) rfcb FAR *lpRenameFcb; COUNT FcbDrive; UBYTE result = FCB_SUCCESS; - BYTE FAR *lpOldDta = dta; + void FAR *lpOldDta = dta; /* Build a traditional DOS file name */ lpRenameFcb = (rfcb FAR *) CommonFcbInit(lpXfcb, SecPathName, &FcbDrive); @@ -536,7 +527,7 @@ UBYTE FcbRename(xfcb FAR * lpXfcb) COUNT result; wAttr = (lpXfcb->xfcb_flag == 0xff ? lpXfcb->xfcb_attrib : D_ALL); - dta = (BYTE FAR *) & Dmatch; + dta = &Dmatch; if ((CritErrCode = -DosFindFirst(wAttr, SecPathName)) != SUCCESS) { result = FCB_ERROR; @@ -639,14 +630,14 @@ VOID FcbCloseAll() UBYTE FcbFindFirstNext(xfcb FAR * lpXfcb, BOOL First) { + void FAR *orig_dta = dta; BYTE FAR *lpDir; COUNT FcbDrive; - psp FAR *lpPsp = MK_FP(cu_psp, 0); /* First, move the dta to a local and change it around to match */ /* our functions. */ - lpDir = (BYTE FAR *) dta; - dta = (BYTE FAR *) & Dmatch; + lpDir = dta; + dta = &Dmatch; /* Next initialze local variables by moving them from the fcb */ lpFcb = CommonFcbInit(lpXfcb, SecPathName, &FcbDrive); @@ -675,7 +666,7 @@ UBYTE FcbFindFirstNext(xfcb FAR * lpXfcb, BOOL First) CritErrCode = -(First ? DosFindFirst(wAttr, SecPathName) : DosFindNext()); if (CritErrCode != SUCCESS) { - dta = lpPsp->ps_dta; + dta = orig_dta; return FCB_ERROR; } @@ -696,7 +687,7 @@ UBYTE FcbFindFirstNext(xfcb FAR * lpXfcb, BOOL First) lpFcb->fcb_cublock *= 0x100; lpFcb->fcb_cublock += wAttr; #endif - dta = lpPsp->ps_dta; + dta = orig_dta; return FCB_SUCCESS; } #endif diff --git a/kernel/globals.h b/kernel/globals.h index 9d4289c8..3165df9c 100644 --- a/kernel/globals.h +++ b/kernel/globals.h @@ -110,6 +110,7 @@ FAR * ASM DPBp; /* First drive Parameter Block */ /* internal transfer direction flags */ #define XFR_READ 1 #define XFR_WRITE 2 +#define XFR_FORCE_WRITE 3 #define RDONLY 0 #define WRONLY 1 @@ -131,17 +132,17 @@ FAR * ASM DPBp; /* First drive Parameter Block */ #define ESC 0x1b #define CTL_BS 0x7f -#define INS 0x52 -#define DEL 0x53 +#define INS 0x5200 +#define DEL 0x5300 -#define F1 0x3b -#define F2 0x3c -#define F3 0x3d -#define F4 0x3e -#define F5 0x3f -#define F6 0x40 -#define LEFT 0x4b -#define RIGHT 0x4d +#define F1 0x3b00 +#define F2 0x3c00 +#define F3 0x3d00 +#define F4 0x3e00 +#define F5 0x3f00 +#define F6 0x4000 +#define LEFT 0x4b00 +#define RIGHT 0x4d00 /* Blockio constants */ #define DSKWRITE 1 /* dskxfr function parameters */ @@ -324,14 +325,15 @@ extern UWORD ASM wAttr; extern BYTE ASM default_drive; /* default drive for dos */ -extern BYTE ASM TempBuffer[], /* Temporary general purpose buffer */ +extern dmatch ASM sda_tmp_dm; /* Temporary directory match buffer */ +extern BYTE FAR ASM internal_data[], /* sda areas */ FAR ASM swap_always[], /* " " */ FAR ASM swap_indos[], /* " " */ ASM tsr, /* true if program is TSR */ ASM break_flg, /* true if break was detected */ ASM break_ena; /* break enabled flag */ -extern BYTE FAR * ASM dta; /* Disk transfer area (kludge) */ +extern void FAR * ASM dta; /* Disk transfer area (kludge) */ extern seg ASM cu_psp; /* current psp segment */ extern iregs FAR * ASM user_r; /* User registers for int 21h call */ @@ -343,11 +345,10 @@ extern fcb FAR * ASM lpFcb; /* Pointer to users fcb */ extern sft FAR * ASM lpCurSft; extern BYTE ASM verify_ena, /* verify enabled flag */ - ASM switchar, /* switch char */ - ASM return_mode, /* Process termination rets */ - ASM return_code; /* " " " */ + ASM switchar; /* switch char */ +extern UWORD ASM return_code; /* Process termination rets */ -extern BYTE ASM BootDrive, /* Drive we came up from */ +extern UBYTE ASM BootDrive, /* Drive we came up from */ ASM scr_pos; /* screen position for bs, ht, etc */ /*extern WORD NumFloppies; !!*//* How many floppies we have */ @@ -359,12 +360,6 @@ extern struct cds ASM TempCDS; /* start of uncontrolled variables */ -GLOBAL seg RootPsp; /* Root process -- do not abort */ - -/* don't know what it should do, but its no longer in use TE -GLOBAL struct f_node - *pDirFileNode; -*/ #ifdef DEBUG GLOBAL iregs error_regs; /* registers for dump */ @@ -455,13 +450,9 @@ VOID fputbyte(VOID FAR *, UBYTE); /* ^Break handling */ void ASMCFUNC spawn_int23(void); /* procsupt.asm */ -int control_break(void); /* break.c */ -void handle_break(void); /* break.c */ GLOBAL BYTE ReturnAnyDosVersionExpected; -GLOBAL COUNT UnusedRetVal; /* put unused errors here (to save stack space) */ - /* * Log: globals.h,v * diff --git a/kernel/init-mod.h b/kernel/init-mod.h index b1d28b1c..1f2d82e8 100644 --- a/kernel/init-mod.h +++ b/kernel/init-mod.h @@ -109,14 +109,8 @@ extern struct config Config; VOID PreConfig(VOID); VOID DoConfig(int pass); VOID PostConfig(VOID); +VOID configDone(VOID); VOID FAR * KernelAlloc(size_t nBytes); -BYTE * skipwh(BYTE * s); -BYTE * scan(BYTE * s, BYTE * d); -BOOL isnum(BYTE * pszString); -BYTE * GetNumber(REG BYTE * pszString, REG COUNT * pnNum); -COUNT tolower(COUNT c); -COUNT toupper(COUNT c); -VOID mcb_init(UCOUNT seg, UWORD size); char *strcat(char * d, const char * s); COUNT ASMCFUNC Umb_Test(void); COUNT ASMCFUNC UMB_get_largest(UCOUNT * seg, UCOUNT * size); @@ -174,7 +168,7 @@ VOID ASMCFUNC FAR int2f_handler(void); /* main.c */ VOID ASMCFUNC FreeDOSmain(void); BOOL init_device(struct dhdr FAR * dhp, BYTE FAR * cmdLine, - COUNT mode, COUNT top); + COUNT mode, char FAR *top); VOID init_fatal(BYTE * err_msg); /* prf.c */ diff --git a/kernel/initdisk.c b/kernel/initdisk.c index f054c3ed..430db648 100644 --- a/kernel/initdisk.c +++ b/kernel/initdisk.c @@ -354,18 +354,21 @@ COUNT init_getdriveparm(UBYTE drive, bpb FAR * pbpbarray) void init_LBA_to_CHS(struct CHS *chs, ULONG LBA_address, struct DriveParamS *driveparam) { + unsigned long cylinder; + chs->Sector = LBA_address % driveparam->chs.Sector + 1; LBA_address /= driveparam->chs.Sector; chs->Head = LBA_address % driveparam->chs.Head; - chs->Cylinder = LBA_address / driveparam->chs.Head; + cylinder = LBA_address / driveparam->chs.Head; + chs->Cylinder = cylinder >= 0x10000ul ? 0xffffu : cylinder; } void printCHS(char *title, struct CHS *chs) { printf("%s", title); - printf("%4lu-%u-%u", chs->Cylinder, chs->Head, chs->Sector); + printf("%4u-%u-%u", chs->Cylinder, chs->Head, chs->Sector); } /* @@ -845,10 +848,11 @@ BOOL ScanForPrimaryPartitions(struct DriveParamS * driveParam, int scan_type, > 8 GB cyl = 1023, other (cyl&1023) */ - if (((chs.Cylinder & 0x3ff) != pEntry->Begin.Cylinder && - 1023 != pEntry->Begin.Cylinder) || - chs.Head != pEntry->Begin.Head || - chs.Sector != pEntry->Begin.Sector) + if (!((chs.Cylinder & 0x3ff) == pEntry->Begin.Cylinder || + 1023 == pEntry->Begin.Cylinder || + (chs.Cylinder == pEntry->Begin.Cylinder && + chs.Head == pEntry->Begin.Head && + chs.Sector == pEntry->Begin.Sector))) { printf("WARNING: using suspect partition %s FS %02x:", partitionName, pEntry->FileSystem); @@ -859,9 +863,11 @@ BOOL ScanForPrimaryPartitions(struct DriveParamS * driveParam, int scan_type, } - if (((end.Cylinder & 0x3ff) != pEntry->End.Cylinder && - 1023 != pEntry->End.Cylinder) || - end.Head != pEntry->End.Head || end.Sector != pEntry->End.Sector) + if (!((end.Cylinder & 0x3ff) == pEntry->End.Cylinder || + 1023 == pEntry->End.Cylinder || + (end.Cylinder == pEntry->End.Cylinder && + end.Head == pEntry->End.Head && + end.Sector == pEntry->End.Sector))) { if (pEntry->NumSect == 0) { @@ -982,7 +988,7 @@ int Read1LBASector(struct DriveParamS *driveParam, unsigned drive, } else { /* transfer data, using old bios functions */ - init_LBA_to_CHS(&chs, LBA_address, driveParam); + LBA_to_CHS(&chs, LBA_address, driveParam); /* avoid overflow at end of track */ if (chs.Cylinder > 1023) diff --git a/kernel/int2f.asm b/kernel/int2f.asm index cc336596..c9025245 100644 --- a/kernel/int2f.asm +++ b/kernel/int2f.asm @@ -101,12 +101,12 @@ IntDosCal: ; set up register frame ;struct int2f12regs ;{ +; [space for 386 regs] ; UWORD es,ds; ; UWORD di,si,bp,bx,dx,cx,ax; ; UWORD ip,cs,flags; ; UWORD callerARG1; -;}; - Protect386Registers +;} push ax push cx push dx @@ -117,10 +117,30 @@ IntDosCal: push ds push es + cld + +%IFDEF I386 + %ifdef WATCOM + mov si,fs + mov di,gs + %else + Protect386Registers + %endif +%endif + mov ax,DGROUP mov ds,ax extern _int2F_12_handler:wrt HGROUP call _int2F_12_handler + +%IFDEF I386 + %ifdef WATCOM + mov fs,si + mov gs,di + %else + Restore386Registers + %endif +%endif pop es pop ds @@ -131,7 +151,6 @@ IntDosCal: pop dx pop cx pop ax - Restore386Registers iret @@ -346,6 +365,7 @@ print_doredir: pop bx pop ds jc no_clear_ax + xor cx, cx jmp short clear_ax remote_getfree: @@ -357,6 +377,7 @@ remote_getfree: mov [di+2],bx mov [di+4],cx mov [di+6],dx + xor cx, cx jmp short clear_ax remote_printredir: @@ -374,6 +395,7 @@ qremote_fn: pop ds mov ax,0xffff jc no_neg_ax + xor cx, cx jmp short clear_ax remote_rw1: mov cx, [bp+8] @@ -534,23 +556,23 @@ _UMB_get_largest: cmp ax,1 jne umbt_error - ; now return the segment - ; and the size + ; now return the segment + ; and the size - mov cx,bx ; *seg = segment - mov bx, [bp+4] - mov [bx],cx + mov cx,bx ; *seg = segment + mov bx, [bp+4] + mov [bx],cx - mov bx, [bp+6] ; *size = size - mov [bx],dx + mov bx, [bp+6] ; *size = size + mov [bx],dx umbt_ret: mov sp,bp pop bp - ret ; this was called NEAR!! + ret ; this was called NEAR!! -umbt_error: xor ax,ax - jmp umbt_ret +umbt_error: xor ax,ax + jmp short umbt_ret ; Log: int2f.asm,v ; Revision 1.4 2000/03/31 05:40:09 jtabor diff --git a/kernel/inthndlr.c b/kernel/inthndlr.c index d33ab91e..7015208a 100644 --- a/kernel/inthndlr.c +++ b/kernel/inthndlr.c @@ -415,7 +415,7 @@ VOID ASMCFUNC int21_service(iregs FAR * r) case 0x0a: case 0x0b: if (control_break()) - handle_break(); + handle_break(-1); } /* The dispatch handler */ @@ -429,33 +429,33 @@ VOID ASMCFUNC int21_service(iregs FAR * r) /* Read Keyboard with Echo */ case 0x01: - lr.AL = _sti(TRUE); - sto(lr.AL); + lr.AL = read_char_stdin(TRUE); + write_char_stdin(lr.AL); break; /* Display Character */ case 0x02: - sto(lr.DL); + write_char_stdin(lr.DL); break; /* Auxiliary Input */ case 0x03: - BinaryRead(STDAUX, &lr.AL, &UnusedRetVal); + lr.AL = read_char(get_sft_idx(STDAUX), TRUE); break; /* Auxiliary Output */ case 0x04: - DosWrite(STDAUX, 1, (BYTE FAR *) & lr.DL, & UnusedRetVal); + write_char(get_sft_idx(STDAUX), lr.DL); break; /* Print Character */ case 0x05: - DosWrite(STDPRN, 1, (BYTE FAR *) & lr.DL, & UnusedRetVal); + write_char(get_sft_idx(STDPRN), lr.DL); break; /* Direct Console I/O */ case 0x06: if (lr.DL != 0xff) - sto(lr.DL); + write_char_stdin(lr.DL); else if (StdinBusy()) { lr.AL = 0x00; @@ -464,38 +464,37 @@ VOID ASMCFUNC int21_service(iregs FAR * r) else { r->FLAGS &= ~FLG_ZERO; - lr.AL = _sti(FALSE); + lr.AL = read_char_stdin(FALSE); } break; /* Direct Console Input */ case 0x07: - lr.AL = _sti(FALSE); + lr.AL = read_char_stdin(FALSE); break; /* Read Keyboard Without Echo */ case 0x08: - lr.AL = _sti(TRUE); + lr.AL = read_char_stdin(TRUE); break; /* Display String */ case 0x09: - { - unsigned count; - - for (count = 0; ; count++) - if (((UBYTE FAR *)FP_DS_DX)[count] == '$') - break; + { + size_t count = 0; + char FAR *bp = FP_DS_DX; + + while (bp[count] != '$') + count++; - DosWrite(STDOUT, count, FP_DS_DX, - & UnusedRetVal); + DosWrite(STDOUT, count, bp); + lr.AL = '$'; } - lr.AL = '$'; break; /* Buffered Keyboard Input */ case 0x0a: - sti_0a((keyboard FAR *) FP_DS_DX); + read_line(get_sft_idx(STDIN), get_sft_idx(STDOUT), FP_DS_DX); break; /* Check Stdin Status */ @@ -506,9 +505,9 @@ VOID ASMCFUNC int21_service(iregs FAR * r) lr.AL = 0xFF; break; - /* Flush Buffer, Read Keayboard */ + /* Flush Buffer, Read Keyboard */ case 0x0c: - KbdFlush(); + KbdFlush(get_sft_idx(STDIN)); switch (lr.AL) { case 0x01: @@ -598,12 +597,7 @@ VOID ASMCFUNC int21_service(iregs FAR * r) /* Set DTA */ case 0x1a: - { - psp FAR *p = MK_FP(cu_psp, 0); - - p->ps_dta = FP_DS_DX; - dos_setdta(p->ps_dta); - } + dos_setdta(FP_DS_DX); break; /* Get Default Drive Data */ @@ -658,7 +652,7 @@ VOID ASMCFUNC int21_service(iregs FAR * r) { psp FAR *p = MK_FP(cu_psp, 0); - new_psp((psp FAR *) MK_FP(lr.DX, 0), p->ps_size); + new_psp(lr.DX, p->ps_size); } break; @@ -683,34 +677,23 @@ VOID ASMCFUNC int21_service(iregs FAR * r) /* Get Date */ case 0x2a: - DosGetDate(&lr.AL, /* WeekDay */ - &lr.DH, /* Month */ - &lr.DL, /* MonthDay */ - &lr.CX); /* Year */ + lr.AL = DosGetDate((struct dosdate *)&lr.CX); break; /* Set Date */ case 0x2b: - rc = DosSetDate(lr.DH, /* Month */ - lr.DL, /* MonthDay */ - lr.CX); /* Year */ + rc = DosSetDate((struct dosdate *)&lr.CX); lr.AL = (rc != SUCCESS ? 0xff : 0); break; /* Get Time */ case 0x2c: - DosGetTime(&lr.CH, /* Hour */ - &lr.CL, /* Minutes */ - &lr.DH, /* Seconds */ - &lr.DL); /* Hundredths */ + DosGetTime((struct dostime *)&lr.CL); break; /* Set Date */ case 0x2d: - rc = DosSetTime(lr.CH, /* Hour */ - lr.CL, /* Minutes */ - lr.DH, /* Seconds */ - lr.DL); /* Hundredths */ + rc = DosSetTime((struct dostime *)&lr.CL); lr.AL = (rc != SUCCESS ? 0xff : 0); break; @@ -765,8 +748,7 @@ VOID ASMCFUNC int21_service(iregs FAR * r) /* Keep Program (Terminate and stay resident) */ case 0x31: DosMemChange(cu_psp, lr.DX < 6 ? 6 : lr.DX, 0); - return_mode = 3; - return_code = lr.AL; + return_code = lr.AL | 0x300; tsr = TRUE; return_user(); break; @@ -778,23 +760,10 @@ VOID ASMCFUNC int21_service(iregs FAR * r) /* r->DL is NOT changed by MS 6.22 */ /* INT21/32 is documented to reread the DPB */ { - struct dpb FAR *dpb; - UCOUNT drv = lr.DL; - - if (drv == 0 || lr.AH == 0x1f) - drv = default_drive; - else - drv--; - - if (drv >= lastdrive) - { - lr.AL = 0xFF; - CritErrCode = 0x0f; - break; - } - - dpb = CDSp[drv].cdsDpb; - if (dpb == 0 || CDSp[drv].cdsFlags & CDSNETWDRV) + int drv = (lr.DL == 0 || lr.AH == 0x1f) ? default_drive : lr.DL - 1; + struct dpb FAR *dpb = get_dpb(drv); + + if (dpb == NULL) { lr.AL = 0xFF; CritErrCode = 0x0f; @@ -950,17 +919,29 @@ VOID ASMCFUNC int21_service(iregs FAR * r) break; /* Dos Read */ - case 0x3f: - lr.AX = DosRead(lr.BX, lr.CX, FP_DS_DX, & rc); - if (rc != SUCCESS) - goto error_exit; + case 0x3f: + { + long lrc = DosRead(lr.BX, lr.CX, FP_DS_DX); + if (lrc < SUCCESS) + { + rc = (int)lrc; + goto error_exit; + } + lr.AX = (UWORD)lrc; + } break; /* Dos Write */ case 0x40: - lr.AX = DosWrite(lr.BX, lr.CX, FP_DS_DX, & rc); - if (rc != SUCCESS) - goto error_exit; + { + long lrc = DosWrite(lr.BX, lr.CX, FP_DS_DX); + if (lrc < SUCCESS) + { + rc = (int)lrc; + goto error_exit; + } + lr.AX = (UWORD)lrc; + } break; /* Dos Delete File */ @@ -1002,6 +983,8 @@ VOID ASMCFUNC int21_service(iregs FAR * r) case 0x01: rc = DosSetFattr((BYTE FAR *) FP_DS_DX, lr.CX); + if (rc >= SUCCESS) + lr.AX = lr.CX; break; default: @@ -1058,6 +1041,10 @@ VOID ASMCFUNC int21_service(iregs FAR * r) DosMemAlloc(lr.BX, mem_access_mode, &(lr.AX), &(lr.BX))) < 0) { DosMemLargest(&(lr.BX)); + { + if (DosMemCheck() != SUCCESS) + panic("MCB chain corrupted"); + } goto error_exit; } else @@ -1067,11 +1054,18 @@ VOID ASMCFUNC int21_service(iregs FAR * r) /* Free memory */ case 0x49: if ((rc = DosMemFree((lr.ES) - 1)) < 0) - goto error_exit; + { + if (DosMemCheck() != SUCCESS) + panic("MCB chain corrupted"); + goto error_exit; + } break; /* Set memory block size */ case 0x4a: + if (DosMemCheck() != SUCCESS) + panic("before 4a: MCB chain corrupted"); + if ((rc = DosMemChange(lr.ES, lr.BX, &lr.BX)) < 0) { #if 0 @@ -1084,6 +1078,8 @@ VOID ASMCFUNC int21_service(iregs FAR * r) p->ps_size = lr.BX + cu_psp; } #endif + if (DosMemCheck() != SUCCESS) + panic("after 4a: MCB chain corrupted"); goto error_exit; } break; @@ -1102,25 +1098,24 @@ VOID ASMCFUNC int21_service(iregs FAR * r) /* End Program */ case 0x4c: - if (cu_psp == RootPsp - || ((psp FAR *) (MK_FP(cu_psp, 0)))->ps_parent == cu_psp) + if (((psp FAR *)MK_FP(cu_psp, 0))->ps_parent == cu_psp) break; tsr = FALSE; if (ErrorMode) { ErrorMode = FALSE; - return_mode = 2; + rc = 2; } else if (break_flg) { break_flg = FALSE; - return_mode = 1; + rc = 1; } else { - return_mode = 0; + rc = 0; } - return_code = lr.AL; + return_code = lr.AL | (rc << 8); if (DosMemCheck() != SUCCESS) panic("MCB chain corrupted"); #ifdef TSC @@ -1131,8 +1126,9 @@ VOID ASMCFUNC int21_service(iregs FAR * r) /* Get Child-program Return Value */ case 0x4d: - lr.AL = return_code; - lr.AH = return_mode; + lr.AX = return_code; + /* needs to be cleared (RBIL) */ + return_code = 0; break; /* Dos Find First */ @@ -1182,7 +1178,7 @@ VOID ASMCFUNC int21_service(iregs FAR * r) /* ************UNDOCUMENTED************************************* */ /* Dos Create New Psp & set p_size */ case 0x55: - new_psp((psp FAR *) MK_FP(lr.DX, 0), lr.SI); + new_psp(lr.DX, lr.SI); cu_psp = lr.DX; break; @@ -1368,40 +1364,46 @@ VOID ASMCFUNC int21_service(iregs FAR * r) case 0x5f: CLEAR_CARRY_FLAG(); - switch (lr.AL) + if (lr.AL == 7 || lr.AL == 8) { - case 0x07: - if (lr.DL < lastdrive) + struct cds FAR *cdsp; + if (lr.DL < lastdrive) + { + rc = DE_INVLDDRV; + goto error_exit; + } + else + { + cdsp = &CDSp[lr.DL]; + if (lr.AL == 7) { - CDSp[lr.DL].cdsFlags |= 0x100; + cdsp->cdsFlags |= 0x100; } - break; - - case 0x08: - if (lr.DL < lastdrive) + else { - CDSp[lr.DL].cdsFlags &= ~0x100; + cdsp->cdsFlags &= ~0x100; } - break; - - default: + } + } + else + { /* void int_2f_111e_call(iregs FAR *r); int_2f_111e_call(r); break;*/ - rc = remote_doredirect(lr.BX, lr.CX, lr.DX, + rc = remote_doredirect(lr.BX, lr.CX, lr.DX, (FP_ES_DI), lr.SI, (MK_FP(lr.DS, Int21AX))); - /* the remote function manipulates *r directly !, - so we should not copy lr to r here */ - if (rc != SUCCESS) - { - CritErrCode = -rc; /* Maybe set */ - SET_CARRY_FLAG(); - } - r->AX = -rc; - goto real_exit; + /* the remote function manipulates *r directly !, + so we should not copy lr to r here */ + if (rc != SUCCESS) + { + CritErrCode = -rc; /* Maybe set */ + SET_CARRY_FLAG(); + } + r->AX = -rc; + goto real_exit; } break; @@ -1537,34 +1539,26 @@ VOID ASMCFUNC int21_service(iregs FAR * r) case 0x69: CLEAR_CARRY_FLAG(); rc = (lr.BL == 0 ? default_drive : lr.BL - 1); - if (rc < lastdrive) + if (lr.AL == 0 || lr.AL == 1) { UWORD saveCX = lr.CX; - if (CDSp[rc].cdsFlags & CDSNETWDRV) - { + if (get_cds(rc) == NULL) + rc = DE_INVLDDRV; + else if (get_dpb(rc) == NULL) goto error_invalid; - } - switch (lr.AL) + else { - case 0x00: - lr.AL = 0x0d; - lr.CX = 0x0866; - rc = DosDevIOctl(&lr); - break; - - case 0x01: - lr.AL = 0x0d; - lr.CX = 0x0846; - rc = DosDevIOctl(&lr); - break; + lr.CX = lr.AL == 0 ? 0x0866 : 0x0846; + lr.AL = 0x0d; + rc = DosDevIOctl(&lr); + lr.CX = saveCX; + if (rc != SUCCESS) + goto error_exit; + break; } - lr.CX = saveCX; - if (rc != SUCCESS) - goto error_exit; - break; } else - lr.AL = 0xFF; + goto error_invalid; break; /* case 0x6a: see case 0x68 @@ -1580,7 +1574,7 @@ VOID ASMCFUNC int21_service(iregs FAR * r) (lr.DL & 0x0f) > 0x2 || (lr.DL & 0xf0) > 0x10) goto error_invalid; lrc = DosOpen(MK_FP(lr.DS, lr.SI), - (lr.BX & 0x7000) | ((lr.DL & 3) << 8) | + (lr.BX & 0x70ff) | ((lr.DL & 3) << 8) | ((lr.DL & 0x10) << 6), lr.CL); if (lrc < 0) { @@ -1731,12 +1725,14 @@ VOID ASMCFUNC int2526_handler(WORD mode, struct int25regs FAR * r) } #ifdef WITHFAT32 - if (!(CDSp[drv].cdsFlags & CDSNETWDRV) && - ISFAT32(CDSp[drv].cdsDpb)) { - r->ax = 0x207; - r->flags |= FLG_CARRY; - return; + struct dpb FAR *dpbp = get_dpb(drv); + if (dpbp != NULL && ISFAT32(dpbp)) + { + r->ax = 0x207; + r->flags |= FLG_CARRY; + return; + } } #endif @@ -1801,13 +1797,20 @@ STATIC VOID StartTrace(VOID) and serves the internal dos calls - int2f/12xx */ struct int2f12regs { +#ifdef I386 +#ifdef __WATCOMC__ + /* UWORD gs, fs; ** GS/FS are protected through SI/DI */ +#else + UWORD high_edx, high_ecx, high_ebx, high_eax; +#endif +#endif UWORD es, ds; UWORD di, si, bp, bx, dx, cx, ax; UWORD ip, cs, flags; UWORD callerARG1; /* used if called from INT2F/12 */ }; -VOID ASMCFUNC int2F_12_handler(volatile struct int2f12regs r) +VOID ASMCFUNC int2F_12_handler(struct int2f12regs r) { UWORD function = r.ax & 0xff; @@ -1873,6 +1876,14 @@ VOID ASMCFUNC int2F_12_handler(volatile struct int2f12regs r) break; + case 0x13: + /* uppercase character */ + /* for now, ASCII only because nls.c cannot handle DS!=SS */ + r.ax = (unsigned char)r.callerARG1; + if (r.ax >= 'a' && r.ax <= 'z') + r.ax -= 'a' - 'A'; + break; + case 0x16: /* get address of system file table entry - used by NET.EXE BX system file table entry number ( such as returned from 2F/1220) returns @@ -1899,14 +1910,14 @@ VOID ASMCFUNC int2F_12_handler(volatile struct int2f12regs r) ; probable use: get sizeof(CDSentry) */ { - UWORD drv = r.callerARG1 & 0xff; + struct cds FAR *cdsp = get_cds(r.callerARG1 & 0xff); - if (drv >= lastdrive) + if (cdsp == NULL) r.flags |= FLG_CARRY; else { - r.ds = FP_SEG(CDSp); - r.si = FP_OFF(&CDSp[drv]); + r.ds = FP_SEG(cdsp); + r.si = FP_OFF(cdsp); r.flags &= ~FLG_CARRY; } break; @@ -1974,8 +1985,9 @@ VOID ASMCFUNC int2F_12_handler(volatile struct int2f12regs r) break; default: - printf("unimplemented internal dos function INT2F/12%02x\n", - function); + put_string("unimplemented internal dos function INT2F/12"); + put_unsigned(function, 16, 2); + put_string("\n"); r.flags |= FLG_CARRY; break; diff --git a/kernel/ioctl.c b/kernel/ioctl.c index 1a591a59..1a68c624 100644 --- a/kernel/ioctl.c +++ b/kernel/ioctl.c @@ -201,13 +201,7 @@ COUNT DosDevIOctl(lregs * r) CharReqHdr.r_unit = (r->BL == 0 ? default_drive : r->BL - 1); - if (CharReqHdr.r_unit >= lastdrive) - return DE_INVLDDRV; - else - { -/* cdsp = &CDSp[CharReqHdr.r_unit]; */ - dpbp = CDSp[CharReqHdr.r_unit].cdsDpb; - } + dpbp = get_dpb(CharReqHdr.r_unit); switch (r->AL) { @@ -229,7 +223,7 @@ COUNT DosDevIOctl(lregs * r) } return DE_INVLDFUNC; case 0x09: - if (CDSp[CharReqHdr.r_unit].cdsFlags & CDSNETWDRV) + if (get_cds(CharReqHdr.r_unit) != NULL && dpbp == NULL) { r->DX = ATTR_REMOTE; r->AX = S_DONE | S_BUSY; diff --git a/kernel/kernel.asm b/kernel/kernel.asm index 810bddec..f93babc7 100644 --- a/kernel/kernel.asm +++ b/kernel/kernel.asm @@ -420,7 +420,7 @@ _net_name db ' ' ;-27 - 15 Character Network Name global _dta global _cu_psp, _default_drive global _break_ena - global _return_code, _return_mode + global _return_code global _internal_data global _CritPatch @@ -439,12 +439,11 @@ _CritErrCode dw 0 ; 04 - DOS format error Code _CritErrAction db 0 ; 06 - Error Action Code _CritErrClass db 0 ; 07 - Error Class _CritErrDev dd 0 ; 08 - Failing Device Address -_dta dw _TempBuffer, seg _TempBuffer +_dta dw _sda_tmp_dm, seg _sda_tmp_dm ; 0C - current DTA, initialize to TempBuffer. _cu_psp dw 0 ; 10 - Current PSP break_sp dw 0 ; 12 - used in int 23 -_return_code db 0 ; 14 - return code from process -_return_mode db 0 ; 15 - reason for process terminate +_return_code dw 0 ; 14 - return code from process _default_drive db 0 ; 16 - Current Drive _break_ena db 1 ; 17 - Break Flag (default TRUE) db 0 ; 18 - flag, code page switching @@ -481,10 +480,10 @@ daysSince1980 dw 0FFFFh ; 34 - number of days since epoch ; force rebuild on first clock read global _DayOfWeek _DayOfWeek db 2 ; 36 - day of week - global _Year -_Year dw 1980 ; 37 - year - global _dosidle_flag -_dosidle_flag db 0 ; 39 - unknown *no more* +_console_swap db 0 ; 37 console swapped during read from dev + global _dosidle_flag +_dosidle_flag db 1 ; 38 - safe to call int28 if nonzero +_abort_progress db 0 ; 39 - abort in progress global _CharReqHdr _CharReqHdr: global _ClkReqHdr @@ -502,8 +501,8 @@ _ClkRecord times 6 db 0 ; 96 - CLOCK$ transfer record __PriPathBuffer times 80h db 0 ; 9E - buffer for file name global __SecPathBuffer __SecPathBuffer times 80h db 0 ;11E - buffer for file name - global _TempBuffer -_TempBuffer times 21 db 0 ;19E - 21 byte srch state + global _sda_tmp_dm +_sda_tmp_dm times 21 db 0 ;19E - 21 byte srch state global _SearchDir _SearchDir times 32 db 0 ;1B3 - 32 byte dir entry global _TempCDS @@ -523,10 +522,7 @@ _OpenMode db 0 ;24E - File Open Attribute global _Server_Call _Server_Call db 0 ;252 - Server call Func 5D sub 0 db 0 - global _lpUserStack -_lpUserStack dd 0 ;254 - pointer to user stack frame - - ; Pad to 057Ch + ; Pad to 05CCh times (25ch - ($ - _internal_data)) db 0 global _tsr ; used by break and critical error diff --git a/kernel/lfnapi.c b/kernel/lfnapi.c index ca8d25d0..89a5fbdb 100644 --- a/kernel/lfnapi.c +++ b/kernel/lfnapi.c @@ -51,7 +51,7 @@ VOID unicode_to_lfn(UNICODE FAR **name, struct lfn_entry FAR *lep); COUNT lfn_allocate_inode(VOID) { f_node_ptr fnp = get_f_node(); - struct cds FAR *cdsp; + struct dpb FAR *dpbp; COUNT handle; if (fnp == 0) return LHE_NOFREEHNDL; @@ -64,17 +64,17 @@ COUNT lfn_allocate_inode(VOID) } /* Check that default drive is a block device */ - cdsp = &CDSp[default_drive]; + dpbp = get_dpb(default_drive); - if (cdsp->cdsDpb == 0) + if (dpbp == 0) { release_f_node(fnp); return LHE_INVLDDRV; } - fnp->f_dpb = cdsp->cdsDpb; + fnp->f_dpb = dpbp; - if (media_check(fnp->f_dpb) < 0) + if (media_check(dpbp) < 0) { release_f_node(fnp); return LHE_INVLDDRV; diff --git a/kernel/main.c b/kernel/main.c index df6602fc..0c50120b 100644 --- a/kernel/main.c +++ b/kernel/main.c @@ -51,11 +51,10 @@ extern UBYTE DOSFAR ASM nblkdev, DOSFAR ASM lastdrive; /* value of last drive GLOBAL BYTE DOSFAR os_major, /* major version number */ DOSFAR os_minor, /* minor version number */ - DOSFAR dosidle_flag, DOSFAR ASM BootDrive, /* Drive we came up from */ DOSFAR ASM default_drive; /* default drive for dos */ +GLOBAL UBYTE DOSFAR ASM BootDrive; /* Drive we came up from */ GLOBAL BYTE DOSFAR os_release[]; -GLOBAL seg DOSFAR RootPsp; /* Root process -- do not abort */ extern struct dpb FAR *DOSFAR ASM DPBp; /* First drive Parameter Block */ extern struct cds FAR *DOSFAR ASM CDSp; /* Current Directory Structure */ @@ -85,7 +84,6 @@ extern BYTE FAR *upBase; extern BYTE ASM _ib_start[], ASM _ib_end[], ASM _init_end[]; extern UWORD ram_top; /* How much ram in Kbytes */ -VOID configDone(VOID); STATIC VOID InitIO(void); STATIC VOID update_dcb(struct dhdr FAR *); @@ -156,7 +154,7 @@ VOID ASMCFUNC FreeDOSmain(void) BootDrive = *(BYTE FAR *)MK_FP(0x50,0xe0) + 1; - if ((unsigned)BootDrive >= 0x80) + if (BootDrive >= 0x80) BootDrive = 3; /* C: */ *(DWORD FAR *)MK_FP(0x50,0xe0+2) = 0; @@ -339,18 +337,22 @@ STATIC VOID FsConfig(VOID) /* The system file tables need special handling and are "hand */ /* built. Included is the stdin, stdout, stdaux and stdprn. */ + /* a little bit of shuffling is necessary for compatibility */ - /* 0 is /dev/con (stdin) */ + /* sft_idx=0 is /dev/aux */ + open("AUX", O_RDWR); + + /* handle 1, sft_idx=1 is /dev/con (stdout) */ open("CON", O_RDWR); - /* 1 is /dev/con (stdout) */ - dup2(STDIN, STDOUT); + /* 3 is /dev/aux */ + dup2(STDIN, STDAUX); - /* 2 is /dev/con (stderr) */ - dup2(STDIN, STDERR); + /* 0 is /dev/con (stdin) */ + dup2(STDOUT, STDIN); - /* 3 is /dev/aux */ - open("AUX", O_RDWR); + /* 2 is /dev/con (stdin) */ + dup2(STDOUT, STDERR); /* 4 is /dev/prn */ open("PRN", O_WRONLY); @@ -416,8 +418,6 @@ STATIC void kernel() exb.exec.env_seg = DOS_PSP + 8; fmemcpy(MK_FP(exb.exec.env_seg, 0), master_env, sizeof(master_env)); - RootPsp = ~0; - /* process 0 */ /* Execute command.com /P from the drive we just booted from */ memset(Cmd.ctBuffer, 0, sizeof(Cmd.ctBuffer)); @@ -541,22 +541,15 @@ STATIC VOID update_dcb(struct dhdr FAR * dhp) /* If cmdLine is NULL, this is an internal driver */ BOOL init_device(struct dhdr FAR * dhp, BYTE FAR * cmdLine, COUNT mode, - COUNT r_top) + char FAR *r_top) { request rq; - UCOUNT maxmem = ((UCOUNT) r_top << 6) - FP_SEG(dhp); - - if (maxmem >= 0x1000) - maxmem = 0xFFFF; - else - maxmem <<= 4; - rq.r_unit = 0; rq.r_status = 0; rq.r_command = C_INIT; rq.r_length = sizeof(request); - rq.r_endaddr = MK_FP(FP_SEG(dhp), maxmem); + rq.r_endaddr = r_top; rq.r_bpbptr = (void FAR *)(cmdLine ? cmdLine : "\n"); rq.r_firstunit = nblkdev; @@ -605,8 +598,8 @@ STATIC void InitIO(void) { /* Initialize driver chain */ setvec(0x29, int29_handler); /* Requires Fast Con Driver */ - init_device(&con_dev, NULL, NULL, ram_top); - init_device(&clk_dev, NULL, NULL, ram_top); + init_device(&con_dev, NULL, NULL, lpTop); + init_device(&clk_dev, NULL, NULL, lpTop); } /* issue an internal error message */ diff --git a/kernel/makefile b/kernel/makefile index 200103a5..97cceeac 100644 --- a/kernel/makefile +++ b/kernel/makefile @@ -99,11 +99,12 @@ clobber: clean -$(RM) kernel.exe kernel.sys status.me clean: - -$(RM) *.obj *.bak *.crf *.xrf *.map *.lst *.cod *.err + -$(RM) *.res *.obj *.bak *.crf *.xrf *.map *.lst *.cod *.err # XXX: This is a very ugly way of linking the kernel, forced upon us by the # inability of Turbo `make' 2.0 to perform command line redirection. -- ror4 -kernel.exe: $(EXE_dependencies) $(LIBS) + +kernel.res: $(EXE_dependencies) $(LIBS) -$(RM) kernel.res ..\utils\echoto kernel.res kernel.obj iprf.obj+ ..\utils\echoto kernel.res entry.obj io.obj blockio.obj chario.obj dosfns.obj console.obj+ @@ -117,8 +118,9 @@ kernel.exe: $(EXE_dependencies) $(LIBS) ..\utils\echoto kernel.res kernel.exe ..\utils\echoto kernel.res kernel.map ..\utils\echoto kernel.res ..\lib\libm.lib ..\lib\device.lib + +kernel.exe: kernel.res $(EXE_dependencies) $(LIBS) $(LINK) @kernel.res; - -$(RM) kernel.res # *Individual File Dependencies* kernel.obj: kernel.asm segs.inc ludivmul.inc diff --git a/kernel/memmgr.c b/kernel/memmgr.c index 05d5fe96..b8ff513a 100644 --- a/kernel/memmgr.c +++ b/kernel/memmgr.c @@ -299,6 +299,15 @@ COUNT DosMemLargest(UWORD FAR * size) seg dummy; *size = 0; DosMemAlloc(0xffff, LARGEST, &dummy, size); + if (mem_access_mode & 0x80) /* then the largest block is probably low! */ + { + UWORD lowsize = 0; + mem_access_mode &= ~0x80; + DosMemAlloc(0xffff, LARGEST, &dummy, &lowsize); + mem_access_mode |= 0x80; + if (lowsize > *size) + *size = lowsize; + } return *size ? SUCCESS : DE_NOMEM; } @@ -395,7 +404,6 @@ COUNT DosMemChange(UWORD para, UWORD size, UWORD * maxSize) } /* shrink it down */ - /* From here on, nothing can fail */ if (size < p->m_size) { /* make q a pointer to the new next block */ @@ -414,6 +422,10 @@ COUNT DosMemChange(UWORD para, UWORD size, UWORD * maxSize) q->m_psp = FREE_PSP; for (i = 0; i < 8; i++) q->m_name[i] = '\0'; + + /* try to join q with the free mcb's following it if possible */ + if (joinMCBs(q) != SUCCESS) + return DE_MCBDESTRY; } /* MS network client NET.EXE: DosMemChange sets the PSP * @@ -441,8 +453,9 @@ COUNT DosMemCheck(void) /* check for corruption */ if (p->m_type != MCB_NORMAL) { - printf("dos mem corrupt, first_mcb=%04x\n", first_mcb); - hexd("prev ", pprev, 16); + put_string("dos mem corrupt, first_mcb="); + put_unsigned(first_mcb, 16, 4); + hexd("\nprev ", pprev, 16); hexd("notMZ", p, 16); return DE_MCBDESTRY; } diff --git a/kernel/newstuff.c b/kernel/newstuff.c index de926e27..325bc19d 100644 --- a/kernel/newstuff.c +++ b/kernel/newstuff.c @@ -69,36 +69,33 @@ int SetJFTSize(UWORD nHandles) return SUCCESS; } -/* this is the same, is shorter (~170)and slightly easier to understand TE*/ int DosMkTmp(BYTE FAR * pathname, UWORD attr) { /* create filename from current date and time */ - char FAR *ptmp = pathname; - UBYTE wd, month, day; - UBYTE h, m, s, hund; - UWORD sh; - UWORD year; + char FAR *ptmp; + unsigned long randvar; int rc; - char name83[13]; - int loop = 0; - - while (*ptmp) - ptmp++; + int loop; + ptmp = pathname + fstrlen(pathname); if (ptmp == pathname || (ptmp[-1] != '\\' && ptmp[-1] != '/')) *ptmp++ = '\\'; + ptmp[8] = '\0'; - DosGetDate(&wd, &month, &day, &year); - DosGetTime(&h, &m, &s, &hund); - - sh = s * 100 + hund; + randvar = ((unsigned long)dos_getdate() << 16) | dos_gettime(); + loop = 0; do { - sprintf(name83, "%x%x%x%x%x%03x.%03x", - year & 0xf, month & 0xf, day & 0xf, h & 0xf, m & 0xf, - sh & 0xfff, loop & 0xfff); + unsigned long tmp = randvar++; + int i; + for(i = 7; i >= 0; tmp >>= 4, i--) + ptmp[i] = (tmp & 0xf) + 'A'; - fmemcpy(ptmp, name83, 13); + /* DOS versions: > 5: characters A - P + < 5: hex digits */ + if (os_major < 5) + for (i = 0; i < 8; i++) + ptmp[i] -= (ptmp[i] < 'A' + 10) ? '0' - 'A' : 10; /* only create new file -- 2001/09/22 ska*/ rc = (short)DosOpen(pathname, O_LEGACY | O_CREAT | O_RDWR, attr); @@ -122,8 +119,7 @@ int DosMkTmp(BYTE FAR * pathname, UWORD attr) COUNT get_verify_drive(const char FAR * src) { - UBYTE drive; - unsigned flags; + int drive; /* Do we have a drive? */ if (src[1] == ':') @@ -131,14 +127,9 @@ COUNT get_verify_drive(const char FAR * src) else drive = default_drive; - if (drive >= lastdrive) + if (get_cds(drive) == NULL) return DE_INVLDDRV; - /* Entry is disabled or JOINed drives are accessable by the path only */ - flags = CDSp[drive].cdsFlags; - if ((flags & CDSMODEMASK) == 0 || (flags & CDSJOINED) != 0) - return DE_INVLDDRV; - return drive; } @@ -363,7 +354,7 @@ COUNT truename(const char FAR * src, char * dest, COUNT mode) dest[0] = '\0'; /* better probable for sanity check below -- included by original truename() */ /* MUX succeeded and really something */ - if (QRemote_Fn(dest, src) && dest[0] != '\0') + if (QRemote_Fn(dest, src) == SUCCESS && dest[0] != '\0') { tn_printf(("QRemoteFn() returned: \"%S\"\n", dest)); #ifdef DEBUG_TRUENAME @@ -450,7 +441,7 @@ COUNT truename(const char FAR * src, char * dest, COUNT mode) *p = '\\'; /* force backslash! */ } p++; - DosGetCuDir((result & 0x1f) + 1, p); + DosGetCuDir((UBYTE)((result & 0x1f) + 1), p); if (*src != '\\' && *src != '/') p += strlen(p); else /* skip the absolute path marker */ @@ -541,11 +532,12 @@ COUNT truename(const char FAR * src, char * dest, COUNT mode) break; } } - if (addSep == ADD) + if (addSep == ADD || p == dest + 2) { /* MS DOS preserves a trailing '\\', so an access to "C:\\DOS\\" or "CDS.C\\" fails. */ /* But don't add the separator, if the last component was ".." */ + /* we must also add a seperator if dest = "c:" */ addChar('\\'); } @@ -564,14 +556,15 @@ COUNT truename(const char FAR * src, char * dest, COUNT mode) if (dest[2] != '/' && (!(mode & CDS_MODE_SKIP_PHYSICAL)) && njoined) { - for(i = 0; i < lastdrive; ++i) + struct cds FAR *cdsp = CDSp; + for(i = 0; i < lastdrive; ++i, ++cdsp) { /* How many bytes must match */ - size_t j = fstrlen(CDSp[i].cdsCurrentPath); + size_t j = fstrlen(cdsp->cdsCurrentPath); /* the last component must end before the backslash offset and */ /* the path the drive is joined to leads the logical path */ - if ((CDSp[i].cdsFlags & CDSJOINED) && (dest[j] == '\\' || dest[j] == '\0') - && fmemcmp(dest, CDSp[i].cdsCurrentPath, j) == 0) + if ((cdsp->cdsFlags & CDSJOINED) && (dest[j] == '\\' || dest[j] == '\0') + && fmemcmp(dest, cdsp->cdsCurrentPath, j) == 0) { /* JOINed drive found */ dest[0] = drNrToLetter(i); /* index is physical here */ dest[1] = ':'; @@ -586,9 +579,9 @@ COUNT truename(const char FAR * src, char * dest, COUNT mode) strcpy(dest + 2, dest + j); } result = (result & 0xffe0) | i; - current_ldt = &CDSp[i]; + current_ldt = cdsp; result &= ~IS_NETWORK; - if (current_ldt->cdsFlags & CDSNETWDRV) + if (cdsp->cdsFlags & CDSNETWDRV) result |= IS_NETWORK; tn_printf(("JOINed path: \"%S\"\n", dest)); return result; diff --git a/kernel/nls.c b/kernel/nls.c index 80ec6416..0736abf6 100644 --- a/kernel/nls.c +++ b/kernel/nls.c @@ -348,7 +348,7 @@ STATIC int nlsGetData(struct nlsPackage FAR * nls, int subfct, VOID nlsCPchange(UWORD cp) { UNREFERENCED_PARAMETER(cp); - printf("\7\nchange codepage not yet done ska\n"); + put_string("\7\nchange codepage not yet done ska\n"); } /* diff --git a/kernel/nlssupt.asm b/kernel/nlssupt.asm index 8fca40f2..50e1df5e 100644 --- a/kernel/nlssupt.asm +++ b/kernel/nlssupt.asm @@ -43,18 +43,18 @@ _reloc_call_CharMapSrvc: Protect386Registers push ds push es - push bp - push si - push di +; push bp +; push si +; push di push dx push cx push bx push ax ; arg of _upChar - push ax +; push ax mov ax,DGROUP mov ds, ax - pop ax +; pop ax call _DosUpChar ;add sp, byte 2 // next POP retrieves orig AX @@ -65,9 +65,9 @@ _reloc_call_CharMapSrvc: pop bx pop cx pop dx - pop di - pop si - pop bp +; pop di +; pop si +; pop bp pop es pop ds Restore386Registers diff --git a/kernel/prf.c b/kernel/prf.c index 6bfa7b16..647f535d 100644 --- a/kernel/prf.c +++ b/kernel/prf.c @@ -28,6 +28,8 @@ #include "portab.h" +#if defined(DEBUG) || defined(FORSYS) || defined(_INIT) + #ifdef FORSYS #include #include @@ -86,7 +88,7 @@ COUNT fstrlen(BYTE FAR * s) /* don't want globals.h, sorry */ return i; } #else -COUNT ASMCFUNC fstrlen(BYTE FAR * s); /* don't want globals.h, sorry */ +COUNT /*ASMCFUNC*/ pascal fstrlen(BYTE FAR * s); /* don't want globals.h, sorry */ #endif /* special console output routine */ @@ -370,24 +372,78 @@ COUNT do_printf(CONST BYTE * fmt, va_list arg) return 0; } -#ifndef _INIT +#else +void put_console(int c) +{ + if (c == '\n') + put_console('\r'); + +#if defined(__TURBOC__) + _AX = 0x0e00 | c; + _BX = 0x0070; + __int__(0x10); +#elif defined(I86) + __asm + { + mov al, byte ptr c; + mov ah, 0x0e; + mov bx, 0x0070; + int 0x10; + } +#endif /* __TURBO__ */ +} + +extern void put_string(const char *); +extern void put_unsigned(unsigned, int, int); + void hexd(char *title, UBYTE FAR * p, COUNT numBytes) { int loop, start = 0; - printf("%s", title); + put_string(title); if (numBytes > 16) - printf("\n"); + put_console('\n'); for (start = 0; start < numBytes; start += 16) { - printf("%p|", p+start); + put_unsigned(FP_SEG(p), 16, 4); + put_console(':'); + put_unsigned(FP_OFF(p + start), 16, 4); + put_console('|'); for (loop = start; loop < numBytes && loop < start+16;loop++) - printf("%02x ", p[loop]); + { + put_unsigned(p[loop], 16, 2); + put_console(' '); + } for (loop = start; loop < numBytes && loop < start+16;loop++) - printf("%c", p[loop] < 0x20 ? '.' : p[loop]); - printf("\n"); + put_console(p[loop] < 0x20 ? '.' : p[loop]); + put_console('\n'); + } +} + +/* put_unsigned -- print unsigned int in base 2--16 */ +void put_unsigned(unsigned n, int base, int width) +{ + char s[6]; + int i; + + for (i = 0; i < width; i++) + { /* generate digits in reverse order */ + s[i] = "0123456789abcdef"[(UWORD) (n % base)]; + n /= base; + } + + while(i != 0) + { /* print digits in reverse order */ + put_console(s[--i]); } } + +void put_string(const char *s) +{ + while(*s != '\0') + put_console(*s++); +} + #endif #ifdef TEST diff --git a/kernel/procsupt.asm b/kernel/procsupt.asm index 582b1b86..28d4d6b2 100644 --- a/kernel/procsupt.asm +++ b/kernel/procsupt.asm @@ -31,7 +31,7 @@ %include "segs.inc" - extern _lpUserStack:wrt DGROUP + extern _user_r:wrt DGROUP extern _break_flg:wrt DGROUP ; break detected flag extern _int21_handler:wrt TGROUP ; far call system services @@ -140,8 +140,8 @@ _spawn_int23: ; ; this patch helps FreeDos to survive CtrlC, ; but should clearly be done somehow else. - mov ss, [_lpUserStack+2] - mov sp, [_lpUserStack] + mov ss, [_user_r+2] + mov sp, [_user_r] sti diff --git a/kernel/proto.h b/kernel/proto.h index 3021b441..27f098db 100644 --- a/kernel/proto.h +++ b/kernel/proto.h @@ -40,7 +40,6 @@ struct buffer FAR *getblock(ULONG blkno, COUNT dsk); struct buffer FAR *getblockOver(ULONG blkno, COUNT dsk); VOID setinvld(REG COUNT dsk); BOOL flush_buffers(REG COUNT dsk); -BOOL flush1(struct buffer FAR * bp); BOOL flush(void); BOOL fill(REG struct buffer FAR * bp, ULONG blkno, COUNT dsk); BOOL DeleteBlockInBufferCache(ULONG blknolow, ULONG blknohigh, COUNT dsk); @@ -49,20 +48,24 @@ UWORD dskxfer(COUNT dsk, ULONG blkno, VOID FAR * buf, UWORD numblocks, COUNT mode); /* *** End of change */ +/* break.c */ +int control_break(void); +void handle_break(int sft_idx); + /* chario.c */ -UCOUNT BinaryCharIO(struct dhdr FAR * dev, UCOUNT n, void FAR * bp, unsigned command, COUNT *err); -VOID sto(COUNT c); -VOID cso(COUNT c); -unsigned mod_cso(unsigned c); -VOID destr_bs(void); -UCOUNT _sti(BOOL check_break); -VOID con_hold(void); +long BinaryCharIO(struct dhdr FAR * dev, size_t n, void FAR * bp, unsigned command); +int echo_char_stdin(int c); BOOL con_break(void); BOOL StdinBusy(void); -VOID KbdFlush(void); -VOID Do_DosIdle_loop(void); -void sti_0a(keyboard FAR * kp); -unsigned sti(unsigned n, char FAR * bp); +void KbdFlush(int sft_idx); +unsigned char read_char(int sft_idx, BOOL check_break); +unsigned char read_char_stdin(BOOL check_break); +long cooked_read(int sft_idx, size_t n, char FAR *bp); +void read_line(int sft_in, int sft_out, keyboard FAR * kp); +size_t read_line_handle(int sft_idx, size_t n, char FAR * bp); +void write_char(int c, int sft_idx); +void write_char_stdin(int c); +long cooked_write(int sft_idx, size_t n, char FAR *bp); sft FAR *get_sft(UCOUNT); @@ -71,21 +74,21 @@ const char FAR *get_root(const char FAR *); BOOL check_break(void); UCOUNT GenericReadSft(sft far * sftp, UCOUNT n, void FAR * bp, COUNT * err, BOOL force_binary); -COUNT SftSeek(sft FAR * sftp, LONG new_pos, COUNT mode); +COUNT SftSeek(int sft_idx, LONG new_pos, COUNT mode); /*COUNT DosRead(COUNT hndl, UCOUNT n, BYTE FAR * bp, COUNT FAR * err); */ -UCOUNT BinaryReadSft(sft FAR * s, void *bp, COUNT *err); -#define BinaryRead(hndl, bp, err) BinaryReadSft(get_sft(hndl), bp, err) -UCOUNT DosRWSft(sft FAR * s, UCOUNT n, void FAR * bp, COUNT *err, int mode); -#define DosRead(hndl, n, bp, err) DosRWSft(get_sft(hndl), n, bp, err, XFR_READ) -#define DosWrite(hndl, n, bp, err) DosRWSft(get_sft(hndl), n, bp, err, XFR_WRITE) -ULONG DosSeek(COUNT hndl, LONG new_pos, COUNT mode); +void BinarySftIO(int sft_idx, void *bp, int mode); +#define BinaryIO(hndl, bp, mode) BinarySftIO(get_sft_idx(hndl), bp, mode) +long DosRWSft(int sft_idx, size_t n, void FAR * bp, int mode); +#define DosRead(hndl, n, bp) DosRWSft(get_sft_idx(hndl), n, bp, XFR_READ) +#define DosWrite(hndl, n, bp) DosRWSft(get_sft_idx(hndl), n, bp, XFR_WRITE) +ULONG DosSeek(unsigned hndl, LONG new_pos, COUNT mode); long DosOpen(char FAR * fname, unsigned flags, unsigned attrib); COUNT CloneHandle(unsigned hndl); long DosDup(unsigned Handle); COUNT DosForceDup(unsigned OldHandle, unsigned NewHandle); long DosOpenSft(char FAR * fname, unsigned flags, unsigned attrib); COUNT DosClose(COUNT hndl); -COUNT DosCloseSft(WORD sft_idx, BOOL commitonly); +COUNT DosCloseSft(int sft_idx, BOOL commitonly); #define DosCommit(hndl) DosCloseSft(get_sft_idx(hndl), TRUE) BOOL DosGetFree(UBYTE drive, UWORD * spc, UWORD * navc, UWORD * bps, UWORD * nc); @@ -94,7 +97,7 @@ COUNT DosChangeDir(BYTE FAR * s); COUNT DosFindFirst(UCOUNT attr, BYTE FAR * name); COUNT DosFindNext(void); COUNT DosGetFtime(COUNT hndl, date * dp, time * tp); -COUNT DosSetFtimeSft(WORD sft_idx, date dp, time tp); +COUNT DosSetFtimeSft(int sft_idx, date dp, time tp); #define DosSetFtime(hndl, dp, tp) DosSetFtimeSft(get_sft_idx(hndl), (dp), (tp)) COUNT DosGetFattr(BYTE FAR * name); COUNT DosSetFattr(BYTE FAR * name, UWORD attrp); @@ -107,8 +110,9 @@ COUNT DosRmdir(const char FAR * dir); struct dhdr FAR *IsDevice(const char FAR * FileName); BOOL IsShareInstalled(void); COUNT DosLockUnlock(COUNT hndl, LONG pos, LONG len, COUNT unlock); -sft FAR *idx_to_sft(COUNT SftIndex); -COUNT get_sft_idx(UCOUNT hndl); +sft FAR *idx_to_sft(int SftIndex); +int get_sft_idx(UCOUNT hndl); +struct cds FAR *get_cds(int dsk); COUNT DosTruename(const char FAR * src, char FAR * dest); /*dosidle.asm */ @@ -134,6 +138,7 @@ void ConvertName83ToNameSZ(BYTE FAR * destSZ, BYTE FAR * srcFCBName); int FileName83Length(BYTE * filename83); /* fatfs.c */ +struct dpb FAR *get_dpb(COUNT dsk); ULONG clus2phys(CLUSTER cl_no, struct dpb FAR * dpbp); long dos_open(char * path, unsigned flag, unsigned attrib); BOOL fcbmatch(const char *fcbname1, const char *fcbname2); @@ -162,7 +167,7 @@ BOOL dir_exists(char * path); VOID trim_path(BYTE FAR * s); -COUNT dos_cd(struct cds FAR * cdsp, BYTE * PathName); +int dos_cd(char * PathName); f_node_ptr get_f_node(void); VOID release_f_node(f_node_ptr fnp); @@ -230,18 +235,6 @@ VOID show_chain(void); VOID DosUmbLink(BYTE n); VOID mcb_print(mcb FAR * mcbp); -/* misc.c */ -char * ASMCFUNC strcpy(char * d, const char * s); -void ASMCFUNC fmemcpyBack(void FAR * d, const void FAR * s, size_t n); -void ASMCFUNC fmemcpy(void FAR * d, const void FAR * s, size_t n); -void ASMCFUNC fstrcpy(char FAR * d, const char FAR * s); -void * ASMCFUNC memcpy(void *d, const void * s, size_t n); -void ASMCFUNC fmemset(void FAR * s, int ch, size_t n); -void * ASMCFUNC memset(void * s, int ch, size_t n); - -int ASMCFUNC memcmp(const void *m1, const void *m2, size_t n); -int ASMCFUNC fmemcmp(const void FAR *m1, const void FAR *m2, size_t n); - /* lfnapi.c */ COUNT lfn_allocate_inode(VOID); COUNT lfn_free_inode(COUNT handle); @@ -277,24 +270,42 @@ COUNT DosSetCodepage(UWORD actCP, UWORD sysCP); UWORD ASMCFUNC syscall_MUX14(DIRECT_IREGS); /* prf.c */ -VOID put_console(COUNT c); +#ifdef DEBUG int CDECL printf(CONST BYTE * fmt, ...); int CDECL sprintf(BYTE * buff, CONST BYTE * fmt, ...); +#endif +VOID put_console(COUNT c); VOID hexd(char *title, VOID FAR * p, COUNT numBytes); +void put_unsigned(unsigned n, int base, int width); +void put_string(const char *s); /* strings.c */ -size_t ASMCFUNC strlen(const char * s); -size_t ASMCFUNC fstrlen(const char FAR * s); -char FAR * ASMCFUNC _fstrcpy(char FAR * d, const char FAR * s); -char * ASMCFUNC strncpy(char * d, const char * s, size_t l); -int ASMCFUNC strcmp(const char * d, const char * s); -int ASMCFUNC fstrcmp(const char FAR * d, const char FAR * s); -int ASMCFUNC fstrncmp(const char FAR * d, const char FAR * s, size_t l); -int ASMCFUNC strncmp(const char * d, const char * s, size_t l); -void ASMCFUNC fstrncpy(char FAR * d, const char FAR * s, size_t l); -char * ASMCFUNC strchr(const char * s, int c); -char FAR * ASMCFUNC fstrchr(const char FAR * s, int c); -void FAR * ASMCFUNC fmemchr(const void FAR * s, int c, size_t n); +size_t /* ASMCFUNC */ ASMPASCAL strlen(const char * s); +size_t /* ASMCFUNC */ ASMPASCAL fstrlen(const char FAR * s); +char FAR * /*ASMCFUNC*/ ASMPASCAL _fstrcpy(char FAR * d, const char FAR * s); +char * /*ASMCFUNC*/ ASMPASCAL strncpy(char * d, const char * s, size_t l); +int /*ASMCFUNC*/ ASMPASCAL strcmp(const char * d, const char * s); +int /*ASMCFUNC*/ ASMPASCAL fstrcmp(const char FAR * d, const char FAR * s); +int /*ASMCFUNC*/ ASMPASCAL fstrncmp(const char FAR * d, const char FAR * s, size_t l); +int /*ASMCFUNC*/ ASMPASCAL strncmp(const char * d, const char * s, size_t l); +void /*ASMCFUNC*/ ASMPASCAL fstrncpy(char FAR * d, const char FAR * s, size_t l); +char * /*ASMCFUNC*/ ASMPASCAL strchr(const char * s, int c); +char FAR * /*ASMCFUNC*/ ASMPASCAL fstrchr(const char FAR * s, int c); +void FAR * /*ASMCFUNC*/ ASMPASCAL fmemchr(const void FAR * s, int c, size_t n); + +/* misc.c */ +char * /*ASMCFUNC*/ ASMPASCAL strcpy(char * d, const char * s); +void /*ASMCFUNC*/ ASMPASCAL fmemcpyBack(void FAR * d, const void FAR * s, size_t n); +void /*ASMCFUNC*/ ASMPASCAL fmemcpy(void FAR * d, const void FAR * s, size_t n); +void /*ASMCFUNC*/ ASMPASCAL fstrcpy(char FAR * d, const char FAR * s); +void * /*ASMCFUNC*/ ASMPASCAL memcpy(void *d, const void * s, size_t n); +void * /*ASMCFUNC*/ ASMPASCAL fmemset(void FAR * s, int ch, size_t n); +void * /*ASMCFUNC*/ ASMPASCAL memset(void * s, int ch, size_t n); + +int /*ASMCFUNC*/ ASMPASCAL memcmp(const void *m1, const void *m2, size_t n); +int /*ASMCFUNC*/ ASMPASCAL fmemcmp(const void FAR *m1, const void FAR *m2, size_t n); + + /* sysclk.c */ COUNT BcdToByte(COUNT x); @@ -312,19 +323,19 @@ VOID putdirent(struct dirent FAR * dp, UBYTE FAR * vp); #endif /* systime.c */ -VOID DosGetTime(UBYTE * hp, UBYTE * mp, UBYTE * sp, UBYTE * hdp); -COUNT DosSetTime(BYTE h, BYTE m, BYTE s, BYTE hd); -VOID DosGetDate(UBYTE * wdp, UBYTE * mp, UBYTE * mdp, UWORD * yp); -COUNT DosSetDate(UWORD Month, UWORD DayOfMonth, UWORD Year); +void DosGetTime(struct dostime *dt); +int DosSetTime(const struct dostime *dt); +unsigned char DosGetDate(struct dosdate *dd); +int DosSetDate(const struct dosdate *dd); const UWORD *is_leap_year_monthdays(UWORD year); UWORD DaysFromYearMonthDay(UWORD Year, UWORD Month, UWORD DayOfMonth); /* task.c */ -VOID new_psp(psp FAR * p, int psize); +VOID new_psp(seg para, int psize); VOID return_user(void); COUNT DosExec(COUNT mode, exec_blk FAR * ep, BYTE FAR * lp); -ULONG DosGetFsize(COUNT hndl); +ULONG SftGetFsize(int sft_idx); VOID InitPSP(VOID); /* newstuff.c */ diff --git a/kernel/systime.c b/kernel/systime.c index a73711b1..ed2e7161 100644 --- a/kernel/systime.c +++ b/kernel/systime.c @@ -74,31 +74,31 @@ UWORD DaysFromYearMonthDay(UWORD Year, UWORD Month, UWORD DayOfMonth) /* common - call the clock driver */ void ExecuteClockDriverRequest(BYTE command) { - BinaryCharIO(clock, sizeof(struct ClockRecord), &ClkRecord, command, &UnusedRetVal); + BinaryCharIO(clock, sizeof(struct ClockRecord), &ClkRecord, command); } -VOID DosGetTime(UBYTE * hp, UBYTE * mp, UBYTE * sp, UBYTE * hdp) +void DosGetTime(struct dostime *dt) { ExecuteClockDriverRequest(C_INPUT); if (ClkReqHdr.r_status & S_ERROR) return; - *hp = ClkRecord.clkHours; - *mp = ClkRecord.clkMinutes; - *sp = ClkRecord.clkSeconds; - *hdp = ClkRecord.clkHundredths; + dt->hour = ClkRecord.clkHours; + dt->minute = ClkRecord.clkMinutes; + dt->second = ClkRecord.clkSeconds; + dt->hundredth = ClkRecord.clkHundredths; } -COUNT DosSetTime(BYTE h, BYTE m, BYTE s, BYTE hd) +int DosSetTime(const struct dostime *dt) { /* for ClkRecord.clkDays */ ExecuteClockDriverRequest(C_INPUT); - ClkRecord.clkHours = h; - ClkRecord.clkMinutes = m; - ClkRecord.clkSeconds = s; - ClkRecord.clkHundredths = hd; + ClkRecord.clkHours = dt->hour; + ClkRecord.clkMinutes = dt->minute; + ClkRecord.clkSeconds = dt->second; + ClkRecord.clkHundredths = dt->hundredth; ExecuteClockDriverRequest(C_OUTPUT); @@ -107,7 +107,7 @@ COUNT DosSetTime(BYTE h, BYTE m, BYTE s, BYTE hd) return SUCCESS; } -VOID DosGetDate(UBYTE *wdp, UBYTE *mp, UBYTE *mdp, UWORD *yp) +unsigned char DosGetDate(struct dosdate *dd) { UWORD c; const UWORD *pdays; @@ -116,7 +116,7 @@ VOID DosGetDate(UBYTE *wdp, UBYTE *mp, UBYTE *mdp, UWORD *yp) ExecuteClockDriverRequest(C_INPUT); if (ClkReqHdr.r_status & S_ERROR) - return; + return 0; for (Year = 1980, c = ClkRecord.clkDays;;) { @@ -138,25 +138,27 @@ VOID DosGetDate(UBYTE *wdp, UBYTE *mp, UBYTE *mdp, UWORD *yp) ++Month; } - *mp = Month; - *mdp = c - pdays[Month - 1] + 1; - *yp = Year; + dd->year = Year; + dd->month = Month; + dd->monthday = c - pdays[Month - 1] + 1; /* Day of week is simple. Take mod 7, add 2 (for Tuesday */ /* 1-1-80) and take mod again */ - *wdp = (ClkRecord.clkDays + 2) % 7; + return (ClkRecord.clkDays + 2) % 7; } -COUNT DosSetDate(Month, DayOfMonth, Year) -UWORD Month, DayOfMonth, Year; +int DosSetDate(const struct dosdate *dd) { - const UWORD *pdays; - pdays = is_leap_year_monthdays(Year); + UWORD Year = dd->year; + UWORD Month = dd->month; + UWORD DayOfMonth = dd->monthday; + const UWORD *pdays = is_leap_year_monthdays(Year); if (Year < 1980 || Year > 2099 || Month < 1 || Month > 12 - || DayOfMonth < 1 || DayOfMonth > pdays[Month] - pdays[Month - 1]) + || DayOfMonth < 1 + || DayOfMonth > pdays[Month] - pdays[Month - 1]) return DE_INVLDDATA; ExecuteClockDriverRequest(C_INPUT); diff --git a/kernel/task.c b/kernel/task.c index 3fcc09b5..ecc5dc82 100644 --- a/kernel/task.c +++ b/kernel/task.c @@ -58,19 +58,14 @@ static BYTE *RcsId = + 1 byte: '\0' -- 1999/04/21 ska */ -ULONG DosGetFsize(COUNT hndl) +ULONG SftGetFsize(int sft_idx) { - sft FAR *s; -/* sfttbl FAR *sp;*/ + sft FAR *s = idx_to_sft(sft_idx); /* Get the SFT block that contains the SFT */ - if ((s = get_sft(hndl)) == (sft FAR *) - 1) + if (FP_OFF(s) == (size_t) -1) return DE_INVLDHNDL; - /* If this is not opened another error */ - if (s->sft_count == 0) - return DE_ACCESS; - /* If SFT entry refers to a device, return the date and time of opening */ if (s->sft_flags & (SFT_FDEVICE | SFT_FSHARED)) { @@ -163,11 +158,12 @@ STATIC COUNT ChildEnv(exec_blk * exp, UWORD * pChildEnvSeg, char far * pathname) } /* The following code is 8086 dependant */ -VOID new_psp(psp FAR * p, int psize) +void new_psp(seg para, int psize) { - REG COUNT i; + psp FAR *p = MK_FP(para, 0); psp FAR *q = MK_FP(cu_psp, 0); - + int i; + /* Clear out new psp first */ fmemset(p, 0, sizeof(psp)); @@ -193,10 +189,7 @@ VOID new_psp(psp FAR * p, int psize) /* memory size in paragraphs */ p->ps_size = psize; /* environment paragraph */ - p->ps_environ = 0; - /* process dta */ - p->ps_dta = (BYTE FAR *) (&p->ps_cmd_count); - + /* p->ps_environ = 0; cleared above */ /* terminate address */ p->ps_isv22 = getvec(0x22); /* break address */ @@ -204,45 +197,32 @@ VOID new_psp(psp FAR * p, int psize) /* critical error address */ p->ps_isv24 = getvec(0x24); - /* File System parameters */ /* user stack pointer - int 21 */ p->ps_stack = q->ps_stack; - /* file table - 0xff is unused */ - - for (i = 0; i < 20; i++) - p->ps_files[i] = 0xff; + /* File System parameters */ /* maximum open files */ p->ps_maxfiles = 20; + fmemset(p->ps_files, 0xff, 20); + /* open file table pointer */ p->ps_filetab = p->ps_files; - /* clone the file table */ - if (p != q) - { - REG COUNT i; - - for (i = 0; i < 20; i++) - { - if (q->ps_filetab[i] != 0xff && CloneHandle(i) >= 0) - p->ps_filetab[i] = q->ps_filetab[i]; - else - p->ps_filetab[i] = 0xff; - } - } + /* clone the file table -- 0xff is unused */ + for (i = 0; i < 20; i++) + if (CloneHandle(i) >= 0) + p->ps_files[i] = q->ps_filetab[i]; /* first command line argument */ - p->ps_fcb1.fcb_drive = 0; + /* p->ps_fcb1.fcb_drive = 0; already set */ fmemset(p->ps_fcb1.fcb_fname, ' ', FNAME_SIZE + FEXT_SIZE); /* second command line argument */ - p->ps_fcb2.fcb_drive = 0; + /* p->ps_fcb2.fcb_drive = 0; already set */ fmemset(p->ps_fcb2.fcb_fname, ' ', FNAME_SIZE + FEXT_SIZE); /* local command line */ - p->ps_cmd_count = 0; /* command tail */ - p->ps_cmd[0] = 0; /* command tail */ - if (RootPsp == (seg) ~ 0) - RootPsp = FP_SEG(p); + /* p->ps_cmd.ctCount = 0; command tail, already set */ + p->ps_cmd.ctBuffer[0] = 0xd; /* command tail */ } STATIC UWORD patchPSP(UWORD pspseg, UWORD envseg, exec_blk FAR * exb, @@ -258,24 +238,22 @@ STATIC UWORD patchPSP(UWORD pspseg, UWORD envseg, exec_blk FAR * exb, psp = MK_FP(pspseg, 0); /* complete the psp by adding the command line and FCBs */ - fmemcpy(psp->ps_cmd, exb->exec.cmd_line->ctBuffer, 127); + fmemcpy(&psp->ps_cmd, exb->exec.cmd_line, sizeof(CommandTail)); if (FP_OFF(exb->exec.fcb_1) != 0xffff) { fmemcpy(&psp->ps_fcb1, exb->exec.fcb_1, 16); fmemcpy(&psp->ps_fcb2, exb->exec.fcb_2, 16); } - psp->ps_cmd_count = exb->exec.cmd_line->ctCount; /* identify the mcb as this functions' */ pspmcb->m_psp = pspseg; /* Patch in environment segment, if present, also adjust its MCB */ if (envseg) { - psp->ps_environ = envseg + 1; ((mcb FAR *) MK_FP(envseg, 0))->m_psp = pspseg; + envseg++; } - else - psp->ps_environ = 0; + psp->ps_environ = envseg; /* use the file name less extension - left adjusted and */ np = fnam; @@ -300,10 +278,8 @@ STATIC UWORD patchPSP(UWORD pspseg, UWORD envseg, exec_blk FAR * exb, pspmcb->m_name[i] = '\0'; /* return value: AX value to be passed based on FCB values */ - return ((psp->ps_fcb1.fcb_drive < lastdrive && - CDSp[psp->ps_fcb1.fcb_drive].cdsFlags & CDSVALID) ? 0 : 0xff) + - ((psp->ps_fcb2.fcb_drive < lastdrive && - CDSp[psp->ps_fcb2.fcb_drive].cdsFlags & CDSVALID) ? 0 : 0xff) * 0x100; + return (get_cds(psp->ps_fcb1.fcb_drive) ? 0 : 0xff) | + (get_cds(psp->ps_fcb2.fcb_drive) ? 0 : 0xff00); } int load_transfer(UWORD ds, exec_blk *exp, UWORD fcbcode, COUNT mode) @@ -318,7 +294,8 @@ int load_transfer(UWORD ds, exec_blk *exp, UWORD fcbcode, COUNT mode) user_r->FLAGS &= ~FLG_CARRY; cu_psp = ds; - dta = p->ps_dta; + /* process dta */ + dta = &p->ps_cmd; if (mode == LOADNGO) { @@ -350,16 +327,21 @@ int load_transfer(UWORD ds, exec_blk *exp, UWORD fcbcode, COUNT mode) considering a threshold, trying HIGH then LOW */ STATIC int ExecMemLargest(UWORD *asize, UWORD threshold) { - int rc = DosMemLargest(asize); - /* less memory than the .COM/.EXE file has: - try low memory first */ - if ((mem_access_mode & 0x80) && - (rc != SUCCESS || *asize < threshold)) + int rc; + if (mem_access_mode & 0x80) { mem_access_mode &= ~0x80; + mem_access_mode |= 0x40; rc = DosMemLargest(asize); + mem_access_mode &= ~0x40; + /* less memory than the .COM/.EXE file has: + try low memory first */ + if (rc != SUCCESS || *asize < threshold) + rc = DosMemLargest(asize); mem_access_mode |= 0x80; } + else + rc = DosMemLargest(asize); return (*asize < threshold ? DE_NOMEM : rc); } @@ -406,7 +388,7 @@ COUNT DosComLoader(BYTE FAR * namep, exec_blk * exp, COUNT mode, COUNT fd) { UWORD com_size; { - ULONG com_size_long = DosGetFsize(fd); + ULONG com_size_long = SftGetFsize(fd); /* maximally 64k - 256 bytes stack - 256 bytes psp */ com_size = (min(com_size_long, 0xfe00u) >> 4) + 0x10; @@ -471,10 +453,10 @@ COUNT DosComLoader(BYTE FAR * namep, exec_blk * exp, COUNT mode, COUNT fd) -- 1999/04/21 ska */ /* rewind to start */ - DosSeek(fd, 0, 0); + SftSeek(fd, 0, 0); /* read everything, but at most 64K - sizeof(PSP) */ - DosRead(fd, 0xff00, sp, &UnusedRetVal); - DosClose(fd); + DosRWSft(fd, 0xff00, sp, XFR_READ); + DosCloseSft(fd, FALSE); } if (mode == OVERLAY) @@ -485,7 +467,7 @@ COUNT DosComLoader(BYTE FAR * namep, exec_blk * exp, COUNT mode, COUNT fd) /* point to the PSP so we can build it */ setvec(0x22, MK_FP(user_r->CS, user_r->IP)); - new_psp(MK_FP(mem, 0), mem + asize); + new_psp(mem, mem + asize); fcbcode = patchPSP(mem - 1, env, exp, namep); /* set asize to end of segment */ @@ -536,7 +518,6 @@ VOID return_user(void) cu_psp = p->ps_parent; q = MK_FP(cu_psp, 0); - dta = q->ps_dta; irp = (iregs FAR *) q->ps_stack; @@ -583,7 +564,7 @@ COUNT DosExeLoader(BYTE FAR * namep, exec_blk * exp, COUNT mode, COUNT fd) exe_size = (ULONG) long2para(image_size) + ExeHeader.exMinAlloc; /* Clone the environement and create a memory arena */ - if ((mode & 0x7f) != OVERLAY && (mode & 0x80)) + if (mode & 0x80) { DosUmbLink(1); /* link in UMB's */ mem_access_mode |= 0x80; @@ -645,7 +626,7 @@ COUNT DosExeLoader(BYTE FAR * namep, exec_blk * exp, COUNT mode, COUNT fd) /* Now load the executable */ /* offset to start of image */ - if (DosSeek(fd, image_offset, 0) != image_offset) + if (SftSeek(fd, image_offset, 0) != SUCCESS) { if (mode != OVERLAY) { @@ -674,16 +655,16 @@ COUNT DosExeLoader(BYTE FAR * namep, exec_blk * exp, COUNT mode, COUNT fd) /* read in the image in 32K chunks */ { - UCOUNT nBytesRead; + int nBytesRead; BYTE FAR *sp = MK_FP(start_seg, 0x0); while (exe_size > 0) { nBytesRead = - DosRead(fd, + (int)DosRWSft(fd, (COUNT) (exe_size < CHUNK ? exe_size : CHUNK), - (VOID FAR *) sp, &UnusedRetVal); - if (nBytesRead == 0) + (VOID FAR *) sp, XFR_READ); + if (nBytesRead <= 0) break; sp = add_far((VOID FAR *) sp, nBytesRead); exe_size -= nBytesRead; @@ -695,12 +676,11 @@ COUNT DosExeLoader(BYTE FAR * namep, exec_blk * exp, COUNT mode, COUNT fd) UWORD reloc[2]; seg FAR *spot; - DosSeek(fd, ExeHeader.exRelocTable, 0); + SftSeek(fd, ExeHeader.exRelocTable, 0); for (i = 0; i < ExeHeader.exRelocItems; i++) { - if (DosRead - (fd, sizeof(reloc), (VOID FAR *) & reloc[0], - &UnusedRetVal) != sizeof(reloc)) + if (DosRWSft + (fd, sizeof(reloc), (VOID FAR *) & reloc[0], XFR_READ) != sizeof(reloc)) { return DE_INVLDDATA; } @@ -719,7 +699,7 @@ COUNT DosExeLoader(BYTE FAR * namep, exec_blk * exp, COUNT mode, COUNT fd) } /* and finally close the file */ - DosClose(fd); + DosCloseSft(fd, FALSE); /* exit here for overlay */ if (mode == OVERLAY) @@ -730,7 +710,7 @@ COUNT DosExeLoader(BYTE FAR * namep, exec_blk * exp, COUNT mode, COUNT fd) /* point to the PSP so we can build it */ setvec(0x22, MK_FP(user_r->CS, user_r->IP)); - new_psp(MK_FP(mem, 0), mem + asize); + new_psp(mem, mem + asize); fcbcode = patchPSP(mem - 1, env, exp, namep); exp->exec.stack = @@ -762,12 +742,12 @@ COUNT DosExec(COUNT mode, exec_blk FAR * ep, BYTE FAR * lp) /* If file not found - free ram and return error */ if (IsDevice(lp) || /* we don't want to execute C:>NUL */ - (fd = (short)DosOpen(lp, O_LEGACY | O_OPEN | O_RDONLY, 0)) < 0) + (fd = (short)DosOpenSft(lp, O_LEGACY | O_OPEN | O_RDONLY, 0)) < 0) { return DE_FILENOTFND; } - rc = DosRead(fd, sizeof(exe_header), (BYTE FAR *)&ExeHeader, &UnusedRetVal); + rc = (int)DosRWSft(fd, sizeof(exe_header), (BYTE FAR *)&ExeHeader, XFR_READ); if (rc == sizeof(exe_header) && (ExeHeader.exSignature == MAGIC || ExeHeader.exSignature == OLD_MAGIC)) @@ -779,7 +759,7 @@ COUNT DosExec(COUNT mode, exec_blk FAR * ep, BYTE FAR * lp) rc = DosComLoader(lp, &TempExeBlock, mode, fd); } - DosClose(fd); + DosCloseSft(fd, FALSE); if (mode == LOAD && rc == SUCCESS) fmemcpy(ep, &TempExeBlock, sizeof(exec_blk)); diff --git a/mkfiles/bc5.mak b/mkfiles/bc5.mak index e2dc7f93..699dc476 100644 --- a/mkfiles/bc5.mak +++ b/mkfiles/bc5.mak @@ -15,7 +15,7 @@ LIBTERM= LIBPLUS=+ TINY=-lt -CFLAGSS=-L$(LIBPATH) -mt -a- -k- -f- -ff- -O -Z -d +CFLAGST=-L$(LIBPATH) -mt -a- -k- -f- -ff- -O -Z -d CFLAGSC=-L$(LIBPATH) -a- -mc TARGET=KBC diff --git a/mkfiles/mscl8.mak b/mkfiles/mscl8.mak index 328c1c17..35b21b6b 100644 --- a/mkfiles/mscl8.mak +++ b/mkfiles/mscl8.mak @@ -7,7 +7,7 @@ COMPILERPATH=$(MS_BASE) COMPILERBIN=$(COMPILERPATH)\bin INCLUDEPATH=$(COMPILERPATH)\include CC=$(COMPILERBIN)\cl -c -CC=$(COMPILERBIN)\cl +CL=$(COMPILERBIN)\cl TINY= CFLAGST=/Fm /AT /Os /Zp1 CFLAGSC=/Fm /AL /Os /Zp1 diff --git a/mkfiles/watcom.mak b/mkfiles/watcom.mak index baa204ae..64a83cbe 100644 --- a/mkfiles/watcom.mak +++ b/mkfiles/watcom.mak @@ -4,7 +4,7 @@ # Use these for WATCOM 11.0c COMPILERPATH=$(WATCOM) -CC=wcc +CC=*wcc CL=wcl INCLUDEPATH=$(COMPILERPATH)\H INCLUDE=$(COMPILERPATH)\h diff --git a/sys/sys.c b/sys/sys.c index 9046ce0c..352c423b 100644 --- a/sys/sys.c +++ b/sys/sys.c @@ -36,7 +36,7 @@ #define DEBUG /* #define DDEBUG */ -#define SYS_VERSION "v2.4" +#define SYS_VERSION "v2.5" #include #include @@ -293,13 +293,6 @@ int main(int argc, char **argv) exit(1); } - printf("\nCopying COMMAND.COM...\n"); - if (!copy(drive, srcPath, rootPath, "command.com")) - { - printf("\n%s: cannot copy \"COMMAND.COM\"\n", pgm); - exit(1); - } - if (argc > drivearg + 1) bsFile = argv[drivearg + 1]; @@ -308,6 +301,23 @@ int main(int argc, char **argv) (argc > drivearg + 2) && memicmp(argv[drivearg + 2], "BOTH", 4) == 0); + printf("\nCopying COMMAND.COM...\n"); + if (!copy(drive, srcPath, rootPath, "COMMAND.COM")) + { + char *comspec = getenv("COMSPEC"); + if (comspec != NULL) + { + printf("%s: Trying \"%s\"\n", pgm, comspec); + if (!copy(drive, comspec, NULL, "COMMAND.COM")) + comspec = NULL; + } + if (comspec == NULL) + { + printf("\n%s: cannot copy \"COMMAND.COM\"\n", pgm); + exit(1); + } + } + printf("\nSystem transferred.\n"); return 0; } @@ -743,7 +753,9 @@ BOOL copy(COUNT drive, BYTE * srcPath, BYTE * rootPath, BYTE * file) struct stat fstatbuf; sprintf(dest, "%c:\\%s", 'A' + drive, file); - sprintf(source, "%s%s", srcPath, file); + strcpy(source, srcPath); + if (rootPath != NULL) /* trick for comspec */ + strcat(source, file); if (stat(source, &fstatbuf)) { From 2364b9834def281f2cfe1a83d0b5155af92b3e7b Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Mon, 28 Oct 2002 02:56:47 +0000 Subject: [PATCH 153/671] Final changes for 2027rc git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@431 6ac86273-5f31-0410-b378-82cca8765d1b --- config.b | 2 +- docs/history.txt | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/config.b b/config.b index c2c28da0..2f9f43e0 100644 --- a/config.b +++ b/config.b @@ -61,7 +61,7 @@ set TC2_BASE=c:\tc201 :-********************************************************************** :- where is UPX and which options to use? :-********************************************************************** -set XUPX=upx --8086 +set XUPX=upx --8086 --best :- or use set XUPX= :- if you don't want to use it diff --git a/docs/history.txt b/docs/history.txt index 7b10ecd8..4fbeb30a 100644 --- a/docs/history.txt +++ b/docs/history.txt @@ -1,7 +1,7 @@ -2002 Oct xx - Build 2027rc +2002 Oct 27 - Build 2027rc -------- Bart Oldeman (bart@dosemu.org) + Changes Bart - * reorganized chario.c, got F1-F6, Ins, Del, etc working + * reorganized chario.c, got F1-F6, Ins, Del, etc. working * fixed bug in extended open * fixed bug in memory manager (realloc should try to defragment; UMB fixes) @@ -17,7 +17,7 @@ * task.c uses mid-level system file handles instead of PSP handles. * SFT sequence is MS/DR DOS like: 0=AUX 1=CON 2=PRN * int21/ah=4d needs to clear the return code after returning it. - * Removed need for unusedretval because some functions return a long int + * Removed need for "unusedretval" because some functions return a long int now. * Do not warn for some additional LBA partition layouts (begin/end cylinder=1023) in initdisk.c. @@ -28,12 +28,13 @@ put_string instead * better MK_FP for Turbo C++ 1.01 and later * PSP related task.c cleanups + * use --best and new upx (1.23) for binary build Changes Tom and Bart: * Use Pascal calling convention for memcpy and friends in asmsupt.asm * Fixed make temp file * fix bug in DosFindNext * misc makefile fixes -2002 Aug xx - Build 2027test +2002 Aug 3 - Build 2027test -------- Bart Oldeman (bart@dosemu.org) + Changes Tom * enable LBA FAT16 booting From bf8d11a9a6212042a945d08917280cbca9e5c9dd Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Mon, 28 Oct 2002 03:16:49 +0000 Subject: [PATCH 154/671] Change to get this to compile with TC 2.01 git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@432 6ac86273-5f31-0410-b378-82cca8765d1b --- hdr/portab.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hdr/portab.h b/hdr/portab.h index de95912c..cffb5427 100644 --- a/hdr/portab.h +++ b/hdr/portab.h @@ -216,7 +216,7 @@ typedef signed long LONG; #ifdef I86 #ifndef MK_FP -#ifdef __WATCOMC__ +#if defined(__WATCOMC__) #define MK_FP(seg,ofs) (((UWORD)(seg)):>((VOID *)(ofs))) #elif defined(__TURBOC__) && (__TURBOC__ > 0x202) #define MK_FP(seg,ofs) ((void _seg *)(seg) + (void near *)(ofs)) From 04e8d7a5c6773a157e835d510223754d1a83c9ec Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sat, 9 Nov 2002 19:07:11 +0000 Subject: [PATCH 155/671] Fix winnt+ problem with int26 by resetting the drive. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@457 6ac86273-5f31-0410-b378-82cca8765d1b --- sys/sys.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/sys/sys.c b/sys/sys.c index 352c423b..e6e02c11 100644 --- a/sys/sys.c +++ b/sys/sys.c @@ -386,6 +386,17 @@ fat32readwrite(int DosDrive, void *diskReadPacket, unsigned intno); modify [cx dx si] \ value [ax]; +void reset_drive(int DosDrive); +#pragma aux reset_drive = \ + "push ds" \ + "inc dx" \ + "mov ah, 0xd" \ + "int 0x21" \ + "mov ah,0x32" \ + "int 0x21" \ + "pop ds" \ + parm [dx] \ + modify [ax bx]; #else int2526readwrite(int DosDrive, void *diskReadPacket, unsigned intno) { @@ -414,6 +425,18 @@ fat32readwrite(int DosDrive, void *diskReadPacket, unsigned intno) return regs.x.cflag; } + +void reset_drive(int DosDrive) +{ + union REGS regs; + + regs.h.ah = 0xd; + int86(0x21, ®s, ®s); + regs.h.ah = 0x32; + regs.h.dl = DosDrive + 1; + int86(0x21, ®s, ®s); +} + #endif int MyAbsReadWrite(int DosDrive, int count, ULONG sector, void *buffer, @@ -518,6 +541,7 @@ VOID put_boot(COUNT drive, BYTE * bsFile, BOOL both) printf("Reading old bootsector from drive %c:\n", drive + 'A'); #endif + reset_drive(drive); if (MyAbsReadWrite(drive, 1, 0, oldboot, 0x25) != 0) { printf("can't read old boot sector for drive %c:\n", drive + 'A'); @@ -729,6 +753,7 @@ VOID put_boot(COUNT drive, BYTE * bsFile, BOOL both) } close(fd); } + reset_drive(drive); } BOOL check_space(COUNT drive, BYTE * BlkBuffer) From 807602f895e5f3018330a265fb2008269e65d8f9 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sat, 9 Nov 2002 19:10:11 +0000 Subject: [PATCH 156/671] Properly initialize the ErrorAlreadyPrinted array. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@458 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/config.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/kernel/config.c b/kernel/config.c index 82a7e7b6..8bf58731 100644 --- a/kernel/config.c +++ b/kernel/config.c @@ -89,6 +89,9 @@ extern UWORD DOSFAR ASM uppermem_root, DOSFAR ASM LoL_nbuffers; UWORD umb_start = 0, UMB_top = 0; UWORD ram_top = 0; /* How much ram in Kbytes */ +static UBYTE ErrorAlreadyPrinted[128]; + + struct config Config = { NUMBUFF, NFILES, @@ -258,7 +261,10 @@ STATIC void FAR* ConfigAlloc(COUNT bytes) void PreConfig(void) { VgaSet = 0; - UmbState = 0; + UmbState = 0; + + memset(ErrorAlreadyPrinted,0,sizeof(ErrorAlreadyPrinted)); + /* Initialize the base memory pointers */ @@ -1204,7 +1210,6 @@ STATIC BOOL LoadDevice(BYTE * pLine, char FAR *top, COUNT mode) STATIC VOID CfgFailure(BYTE * pLine) { BYTE *pTmp = pLineStart; - static UBYTE ErrorAlreadyPrinted[128]; /* suppress multiple printing of same unrecognized lines */ From dce580f3bcb84273304f27be25bf43f727817d22 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sat, 9 Nov 2002 19:11:26 +0000 Subject: [PATCH 157/671] Properly propagate sharing bits. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@459 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/dosfns.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/dosfns.c b/kernel/dosfns.c index d0f18b85..a08d22ea 100644 --- a/kernel/dosfns.c +++ b/kernel/dosfns.c @@ -575,7 +575,7 @@ long DosOpenSft(char FAR * fname, unsigned flags, unsigned attrib) { if ((sftp->sft_shroff = share_open_check(PriPathName, cu_psp, - flags & 0x03, (flags >> 2) & 0x07)) < 0) + flags & 0x03, (flags >> 4) & 0x07)) < 0) return sftp->sft_shroff; } From 4c2538b79e49adf2094059c55115955e281bbd08 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sat, 9 Nov 2002 19:13:56 +0000 Subject: [PATCH 158/671] Return DE_NFILES instead of DE_FILE_NOT_FOUND for missing volume labels; search for volume labels too if the attribute just ands with 8. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@460 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/fatdir.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/kernel/fatdir.c b/kernel/fatdir.c index 225a8b0a..60815861 100644 --- a/kernel/fatdir.c +++ b/kernel/fatdir.c @@ -423,7 +423,7 @@ COUNT dos_findfirst(UCOUNT attr, BYTE * name) /* directory and only searched for once. So we need to open */ /* the root and return only the first entry that contains the */ /* volume id bit set. */ - if (attr == D_VOLID) + if (attr & D_VOLID) i = 3; /* Now open this directory so that we can read the */ /* fnode entry and do a match on it. */ @@ -445,7 +445,7 @@ COUNT dos_findfirst(UCOUNT attr, BYTE * name) /* Copy the raw pattern from our data segment to the DTA. */ fmemcpy(dmp->dm_name_pat, SearchDir.dir_name, FNAME_SIZE + FEXT_SIZE); - if (attr == D_VOLID) + if (attr & D_VOLID) { /* Now do the search */ while (dir_read(fnp) == 1) @@ -467,7 +467,7 @@ COUNT dos_findfirst(UCOUNT attr, BYTE * name) /* Now that we've done our failed search, close it and */ /* return an error. */ dir_close(fnp); - return DE_FILENOTFND; + return DE_NFILES; } /* Otherwise just do a normal find next */ else From 74ed5eea00d99052498eb42b3365cf71847d216f Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sat, 9 Nov 2002 19:21:09 +0000 Subject: [PATCH 159/671] Move NULL device code from _TEXT to CONST to prevent a crash git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@461 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/kernel.asm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/kernel.asm b/kernel/kernel.asm index f93babc7..655c50dc 100644 --- a/kernel/kernel.asm +++ b/kernel/kernel.asm @@ -206,7 +206,7 @@ segment INIT_TEXT_END ; the NUL device ;************************************************************ -segment _TEXT +segment CONST ; ; NUL device strategy From c7eef88bac365f91db14fa4aec145c07bbeddfa9 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sat, 9 Nov 2002 19:22:48 +0000 Subject: [PATCH 160/671] * initialize the critical error code to 0 in inthndlr.c * ignore value of DH for extended open int21/ah=6c git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@462 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/inthndlr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/inthndlr.c b/kernel/inthndlr.c index 7015208a..02af4e19 100644 --- a/kernel/inthndlr.c +++ b/kernel/inthndlr.c @@ -1570,7 +1570,7 @@ VOID ASMCFUNC int21_service(iregs FAR * r) long lrc; CLEAR_CARRY_FLAG(); - if (lr.AL != 0 || lr.DH != 0 || + if (lr.AL != 0 || (lr.DL & 0x0f) > 0x2 || (lr.DL & 0xf0) > 0x10) goto error_invalid; lrc = DosOpen(MK_FP(lr.DS, lr.SI), From bca3ec21758ca9016aa4fb6f09f00e7f3da42782 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sat, 9 Nov 2002 19:34:04 +0000 Subject: [PATCH 161/671] * Hopefully innocent hack to deal with NDN in ioctl.c (ignore upper bits of the drive number) * use subst bit 15 for int21/ax=4409. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@463 6ac86273-5f31-0410-b378-82cca8765d1b --- hdr/device.h | 1 + kernel/ioctl.c | 20 ++++++++++++++++---- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/hdr/device.h b/hdr/device.h index 022d33ff..6a5e7638 100644 --- a/hdr/device.h +++ b/hdr/device.h @@ -131,6 +131,7 @@ struct dhdr { BYTE dh_name[8]; }; +#define ATTR_SUBST 0x8000 #define ATTR_CHAR 0x8000 #define ATTR_IOCTL 0x4000 #define ATTR_BLDFAT 0x2000 diff --git a/kernel/ioctl.c b/kernel/ioctl.c index 1a68c624..c4937e4a 100644 --- a/kernel/ioctl.c +++ b/kernel/ioctl.c @@ -199,7 +199,14 @@ COUNT DosDevIOctl(lregs * r) /* JPP - changed to use default drive if drive=0 */ /* JT Fixed it */ +#define NDN_HACK +/* NDN feeds the actual ASCII drive letter to this function */ +#ifdef NDN_HACK + CharReqHdr.r_unit = ((r->BL & 0x1f) == 0 ? default_drive : + (r->BL & 0x1f) - 1); +#else CharReqHdr.r_unit = (r->BL == 0 ? default_drive : r->BL - 1); +#endif dpbp = get_dpb(CharReqHdr.r_unit); @@ -223,10 +230,12 @@ COUNT DosDevIOctl(lregs * r) } return DE_INVLDFUNC; case 0x09: - if (get_cds(CharReqHdr.r_unit) != NULL && dpbp == NULL) + { + struct cds FAR *cdsp = get_cds(CharReqHdr.r_unit); + r->AX = S_DONE | S_BUSY; + if (cdsp != NULL && dpbp == NULL) { r->DX = ATTR_REMOTE; - r->AX = S_DONE | S_BUSY; } else { @@ -234,11 +243,14 @@ COUNT DosDevIOctl(lregs * r) { return DE_INVLDDRV; } -/* Need to add subst bit 15 */ r->DX = dpbp->dpb_device->dh_attr; - r->AX = S_DONE | S_BUSY; + } + if (cdsp->cdsFlags & CDSSUBST) + { + r->DX |= ATTR_SUBST; } break; + } case 0x0d: nMode = C_GENIOCTL; goto IoBlockCommon; From de171a27886accba97efe3d9748e00bb0d13fe53 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sat, 9 Nov 2002 19:38:25 +0000 Subject: [PATCH 162/671] Updates for kernel 2027 git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@464 6ac86273-5f31-0410-b378-82cca8765d1b --- docs/history.txt | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/docs/history.txt b/docs/history.txt index 4fbeb30a..0c61cf23 100644 --- a/docs/history.txt +++ b/docs/history.txt @@ -1,3 +1,18 @@ +2002 Nov 9 - Build 2027 +-------- Bart Oldeman (bart@dosemu.org) ++ Changes Tom + * memset ErrorAlreadyPrinted to 0 in config.c ++ Changes Bart + * reset drive before and after int26 in SYS for winnt compatibility + * propagate sharing bits correctly in DosOpen + * return DE_NFILES if a volume label is not found; search for volume + label if attr & 8 not just if attr==8 + * initialize the critical error code to 0 in inthndlr.c + * ignore value of DH for extended open int21/ah=6c + * fix problem with NULL device code being in the wrong segment + * Hopefully innocent hack to deal with NDN in ioctl.c (ignore upper bits + of the drive number) + * use subst bit 15 for int21/ax=4409(IOCTL-CHECK IF BLOCK DEVICE REMOTE). 2002 Oct 27 - Build 2027rc -------- Bart Oldeman (bart@dosemu.org) + Changes Bart From 894c9ebd7a6b25e189fd4af0d7369e2d29d93d26 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sat, 9 Nov 2002 19:47:49 +0000 Subject: [PATCH 163/671] Bump up version to 2027 git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@465 6ac86273-5f31-0410-b378-82cca8765d1b --- hdr/version.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hdr/version.h b/hdr/version.h index 5f38bab0..1f2d904b 100644 --- a/hdr/version.h +++ b/hdr/version.h @@ -49,6 +49,6 @@ static BYTE *date_hRcsId = #define REVISION_MINOR 1 #define REVISION_SEQ 27 #define BUILD "2027" -#define SUB_BUILD "rc" +#define SUB_BUILD "" #define KERNEL_VERSION_STRING "1.1.27" /*#REVISION_MAJOR "." #REVISION_MINOR "." #REVISION_SEQ */ -#define KERNEL_BUILD_STRING "2027rc" /*#BUILD SUB_BUILD */ +#define KERNEL_BUILD_STRING "2027" /*#BUILD SUB_BUILD */ From a126dce6763522c87be1a3176e91d6459e4171f8 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Mon, 11 Nov 2002 08:41:28 +0000 Subject: [PATCH 164/671] Fix bug in the output redirection of the character i/o routines. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@466 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/chario.c | 4 ++-- kernel/inthndlr.c | 6 +++--- kernel/proto.h | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/kernel/chario.c b/kernel/chario.c index 5290f6f0..09b9c422 100644 --- a/kernel/chario.c +++ b/kernel/chario.c @@ -264,9 +264,9 @@ void write_char(int c, int sft_idx) DosRWSft(sft_idx, 1, &ch, XFR_FORCE_WRITE); } -void write_char_stdin(int c) +void write_char_stdout(int c) { - write_char(c, get_sft_idx(STDIN)); + write_char(c, get_sft_idx(STDOUT)); } #define iscntrl(c) ((unsigned char)(c) < ' ') diff --git a/kernel/inthndlr.c b/kernel/inthndlr.c index 02af4e19..361dd668 100644 --- a/kernel/inthndlr.c +++ b/kernel/inthndlr.c @@ -430,12 +430,12 @@ VOID ASMCFUNC int21_service(iregs FAR * r) /* Read Keyboard with Echo */ case 0x01: lr.AL = read_char_stdin(TRUE); - write_char_stdin(lr.AL); + write_char_stdout(lr.AL); break; /* Display Character */ case 0x02: - write_char_stdin(lr.DL); + write_char_stdout(lr.DL); break; /* Auxiliary Input */ @@ -455,7 +455,7 @@ VOID ASMCFUNC int21_service(iregs FAR * r) /* Direct Console I/O */ case 0x06: if (lr.DL != 0xff) - write_char_stdin(lr.DL); + write_char_stdout(lr.DL); else if (StdinBusy()) { lr.AL = 0x00; diff --git a/kernel/proto.h b/kernel/proto.h index 27f098db..af1f04fc 100644 --- a/kernel/proto.h +++ b/kernel/proto.h @@ -64,7 +64,7 @@ long cooked_read(int sft_idx, size_t n, char FAR *bp); void read_line(int sft_in, int sft_out, keyboard FAR * kp); size_t read_line_handle(int sft_idx, size_t n, char FAR * bp); void write_char(int c, int sft_idx); -void write_char_stdin(int c); +void write_char_stdout(int c); long cooked_write(int sft_idx, size_t n, char FAR *bp); sft FAR *get_sft(UCOUNT); From a28e0043231d2722ea4397c45fd1af50770f3268 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Mon, 11 Nov 2002 17:42:17 +0000 Subject: [PATCH 165/671] Change ch to chr to fix the inline asm. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@467 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/chario.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/kernel/chario.c b/kernel/chario.c index 09b9c422..ae3bef51 100644 --- a/kernel/chario.c +++ b/kernel/chario.c @@ -185,32 +185,32 @@ void int29(char c); STATIC int raw_put_char(int sft_idx, int c) { struct dhdr FAR *dev = idx_to_dev(sft_idx); - unsigned char ch = (unsigned char)c; + unsigned char chr = (unsigned char)c; if (PrinterEcho) - DosWrite(STDPRN, 1, &ch); + DosWrite(STDPRN, 1, &chr); if (dev->dh_attr & ATTR_FASTCON) { #if defined(__TURBOC__) - _AL = ch; + _AL = chr; __int__(0x29); #elif defined(__WATCOMC__) - int29(ch); + int29(chr); #elif defined(I86) asm { - mov al, byte ptr ch; + mov al, byte ptr chr; int 0x29; } #endif return 0; } - c = (int)BinaryCharIO(dev, 1, &ch, C_OUTPUT); + c = (int)BinaryCharIO(dev, 1, &chr, C_OUTPUT); if (c < 0) return c; else - return ch; + return chr; } /* writes a character in cooked mode; maybe with printer echo; From ed6b46719c8e1b01d987cf7f01b34dc3cbed4e28 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Mon, 18 Nov 2002 22:48:37 +0000 Subject: [PATCH 166/671] Removed old log entries. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@481 6ac86273-5f31-0410-b378-82cca8765d1b --- boot/boot.asm | 64 --------------------------------------------------- boot/makefile | 34 --------------------------- 2 files changed, 98 deletions(-) diff --git a/boot/boot.asm b/boot/boot.asm index 75362647..558f9332 100644 --- a/boot/boot.asm +++ b/boot/boot.asm @@ -599,67 +599,3 @@ filename db "KERNEL SYS" times 0x01fe-$+$$ db 0 sign dw 0xAA55 - -; Log: boot.asm,v -; -; Revision 1.12 1999/09/25 06:42:18 jprice -; Optimize boot loader. Documentation. -; -; Revision 1.11 1999/09/24 19:04:55 jprice -; Added changes recommended by Jens Horstmeier - -; to make their bootable CD work. -; -; Revision 1.10 1999/09/23 04:39:02 jprice -; *** empty log message *** -; -; Revision 1.7 1999/04/23 03:43:46 jprice -; Ported to NASM by ror4 -; -; Revision 1.6 1999/04/17 19:14:03 jprice -; Fixed multi-sector code -; -; Revision 1.5 1999/04/17 06:23:26 jprice -; Changed so multi-sector IO is optional. -; -; Revision 1.4 1999/04/13 15:52:22 jprice -; Moves boot sector to top of mem -; -; Revision 1.3 1999/04/06 22:53:36 jprice -; Put back code to read multiple sectors at a time. -; -; Revision 1.2 1999/04/01 07:23:20 jprice -; New boot loader -; -; Revision 1.1.1.1 1999/03/29 15:39:39 jprice -; New version without IPL.SYS -; -; Revision 1.3 1999/03/02 06:57:14 jprice -; Added entry address for more recent versions of TLINK -; -; Revision 1.2 1999/01/21 05:03:58 jprice -; Formating. -; -; Revision 1.1.1.1 1999/01/20 05:51:00 jprice -; Imported sources -; -; -; Rev 1.5 10 Jan 1997 4:58:06 patv -; Corrected copyright -; -; Rev 1.4 10 Jan 1997 4:52:50 patv -; Re-written to support C drive and eliminate restrictions on IPL.SYS -; -; Rev 1.3 29 Aug 1996 13:06:50 patv -; Bug fixes for v0.91b -; -; Rev 1.2 01 Sep 1995 17:56:44 patv -; First GPL release. -; -; Rev 1.1 30 Jul 1995 20:37:38 patv -; Initialized stack before use. -; -; Rev 1.0 02 Jul 1995 10:57:52 patv -; Initial revision. -; - diff --git a/boot/makefile b/boot/makefile index b4dc6b3a..8fd492d4 100644 --- a/boot/makefile +++ b/boot/makefile @@ -24,37 +24,3 @@ clobber: clean clean: -$(RM) *.lst *.map *.bak *.obj - -# Log: makefile,v -# -# Revision 1.3 1999/04/23 03:44:17 jprice -# Ported to NASM by ror4. Improvements -# -# Revision 1.2 1999/04/01 07:23:20 jprice -# New boot loader -# -# Revision 1.1.1.1 1999/03/29 15:39:39 jprice -# New version without IPL.SYS -# -# Revision 1.3 1999/02/09 04:49:17 jprice -# Make makefile use common config.mak file -# -# Revision 1.2 1999/01/21 05:03:58 jprice -# Formating. -# -# Revision 1.1.1.1 1999/01/20 05:51:00 jprice -# Imported sources -# -# -# Rev 1.3 10 Jan 1997 4:51:54 patv -#Changed to use FreeDOS exe2bin and support new boot code -# -# Rev 1.2 17 Dec 1996 12:52:32 patv -#Converted to FreeDOS exe2bin. -# -# Rev 1.1 29 Aug 1996 13:06:50 patv -#Bug fixes for v0.91b -# -# Rev 1.0 02 Jul 1995 9:11:26 patv -#Initial revision. -# From 865158138302499cb94def59a844245883d84cd8 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Mon, 18 Nov 2002 22:51:27 +0000 Subject: [PATCH 167/671] Remove old log entries. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@482 6ac86273-5f31-0410-b378-82cca8765d1b --- build.bat | 28 ------------------- clean.bat | 17 ------------ clobber.bat | 13 --------- config.b | 10 ------- lib/makefile | 14 ---------- sys/makefile | 14 ---------- sys/sys.c | 77 ---------------------------------------------------- 7 files changed, 173 deletions(-) diff --git a/build.bat b/build.bat index 6c353f60..1c9517aa 100644 --- a/build.bat +++ b/build.bat @@ -148,31 +148,3 @@ set XERROR=1 @set XERROR= @set XUPX= @set UPXOPT= - -:- Log: build.bat,v -:- -:- Revision 1.5 1999/08/25 03:59:14 jprice -:- New build batch files. -:- -:- Revision 1.4 1999/08/25 03:38:16 jprice -:- New build config -:- -:- Revision 1.3 1999/04/23 03:46:02 jprice -:- Improved by jprice -:- -:- Revision 1.2 1999/04/17 19:13:29 jprice -:- ror4 patches -:- -:- Revision 1.1.1.1 1999/03/29 15:39:13 jprice -:- New version without IPL.SYS -:- -:- Revision 1.5 1999/02/09 04:47:54 jprice -:- Make makefile use common config.mak file -:- -:- Revision 1.4 1999/01/30 08:29:10 jprice -:- Clean up -:- -:- Revision 1.3 1999/01/30 07:49:16 jprice -:- Clean up -:- - diff --git a/clean.bat b/clean.bat index c6af6d17..fbc63369 100644 --- a/clean.bat +++ b/clean.bat @@ -43,20 +43,3 @@ del *.bak :end set MAKE= set COMPILER= - -rem Log: clean.bat,v -rem Revision 1.3 1999/08/25 03:59:14 jprice -rem New build batch files. -rem -rem Revision 1.2 1999/04/23 03:46:02 jprice -rem Improved by jprice -rem -rem Revision 1.1.1.1 1999/03/29 15:39:15 jprice -rem New version without IPL.SYS -rem -rem Revision 1.4 1999/02/09 04:47:54 jprice -rem Make makefile use common config.mak file -rem -rem Revision 1.3 1999/01/30 08:29:10 jprice -rem Clean up -rem diff --git a/clobber.bat b/clobber.bat index 9fd173c6..344a6601 100644 --- a/clobber.bat +++ b/clobber.bat @@ -44,16 +44,3 @@ del status.me :end set MAKE= set COMPILER= - -rem Log: clobber.bat,v -rem -rem Revision 1.3 1999/08/25 03:59:14 jprice -rem New build batch files. -rem -rem Revision 1.2 1999/08/10 18:34:06 jprice -rem case -rem -rem Revision 1.1 1999/04/23 03:47:19 jprice -rem Initial include -rem - diff --git a/config.b b/config.b index 2f9f43e0..4c051428 100644 --- a/config.b +++ b/config.b @@ -118,13 +118,3 @@ set XFAT=16 :- :- $Id$ :- -:- Log: config.b,v -:- -:- Revision 1.3 1999/09/13 20:40:17 jprice -:- Added COMPILER variable -:- -:- Revision 1.2 1999/08/25 03:59:14 jprice -:- New build batch files. -:- -:- Revision 1.1 1999/08/25 03:20:39 jprice -:- ror4 patches to allow TC 2.01 compile. diff --git a/lib/makefile b/lib/makefile index 0abc5315..3da926be 100644 --- a/lib/makefile +++ b/lib/makefile @@ -21,17 +21,3 @@ clobber: clean clean: -$(RM) *.obj *.bak -# Log: makefile,v -# -# Revision 1.6 1999/09/14 17:32:20 jprice -# no message -# -# Revision 1.5 1999/09/13 20:13:15 jprice -# Added !if so we can use TC2 or TC3 to compile. -# -# Revision 1.4 1999/08/25 03:19:22 jprice -# ror4 patches to allow TC 2.01 compile. -# -# Revision 1.3 1999/04/23 03:45:18 jprice -# Improved by jprice -# diff --git a/sys/makefile b/sys/makefile index 7acff455..9f340158 100644 --- a/sys/makefile +++ b/sys/makefile @@ -52,17 +52,3 @@ clean: sys.obj: sys.c ..\hdr\portab.h ..\hdr\device.h b_fat12.h b_fat16.h b_fat32.h $(CC) $(CFLAGS) $*.c -# Log: makefile,v -# -# Revision 1.6 1999/09/20 18:34:40 jprice -# *** empty log message *** -# -# Revision 1.5 1999/08/25 03:19:51 jprice -# ror4 patches to allow TC 2.01 compile. -# -# Revision 1.4 1999/05/03 05:01:38 jprice -# no message -# -# Revision 1.3 1999/04/23 03:45:33 jprice -# Improved by jprice -# diff --git a/sys/sys.c b/sys/sys.c index e6e02c11..c101c91a 100644 --- a/sys/sys.c +++ b/sys/sys.c @@ -862,80 +862,3 @@ BOOL copy(COUNT drive, BYTE * srcPath, BYTE * rootPath, BYTE * file) return TRUE; } -/* Log: sys.c,v see "cvs log sys.c" for newer entries. */ - -/* version 2.2 jeremyd 2001/9/20 - Changed so if no source given or only source drive (no path) - given, then checks for kernel.sys & command.com in current - path (of current drive or given drive) and if not there - uses root (but only if source & destination drive are different). - Fix printf to include count(ret) if copy can't write all requested bytes -*/ -/* version 2.1a jeremyd 2001/8/19 - modified so takes optional 2nd parameter (similar to PC DOS) - where if only 1 argument is given, assume to be destination drive, - but if two arguments given, 1st is source (drive and/or path) - and second is destination drive -*/ - -/* Revision 2.1 tomehlert 2001/4/26 - - changed the file system detection code. - - -*/ - -/* Revision 2.0 tomehlert 2001/4/26 - - no direct access to the disk any more, this is FORMAT's job - no floppy.asm anymore, no segmentation problems. - no access to partition tables - - instead copy boot sector using int25/int26 = absdiskread()/write - - if xxDOS is able to handle the disk, SYS should work - - additionally some space savers: - - replaced fopen() by open() - - included (slighly modified) PRF.c from kernel - - size is no ~7500 byte vs. ~13690 before - - * Revision 1.10 2000/03/31 06:59:10 jprice - * Added discription of program. - * - * Revision 1.9 1999/09/20 18:34:40 jprice - * *** empty log message *** - * - * Revision 1.8 1999/09/20 18:27:19 jprice - * Changed open/creat to fopen to make TC2 happy. - * - * Revision 1.7 1999/09/15 05:39:02 jprice - * Changed boot sector writing code so easier to read. - * - * Revision 1.6 1999/09/14 17:30:44 jprice - * Added debug log creation to sys.com. - * - * Revision 1.5 1999/08/25 03:19:51 jprice - * ror4 patches to allow TC 2.01 compile. - * - * Revision 1.4 1999/04/17 19:14:44 jprice - * Fixed multi-sector code - * - * Revision 1.3 1999/04/01 07:24:05 jprice - * SYS modified for new boot loader - * - * Revision 1.2 1999/03/29 16:24:48 jprice - * Fixed error message - * - * Revision 1.1.1.1 1999/03/29 15:43:15 jprice - * New version without IPL.SYS - * Revision 1.3 1999/01/21 04:35:21 jprice Fixed comments. - * Added indent program - * - * Revision 1.2 1999/01/21 04:13:52 jprice Added messages to sys. Also made - * it create a .COM file. - * - */ From c1eab8c5ce770f612985c49a7c081d3a680b2cb1 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Mon, 18 Nov 2002 22:54:03 +0000 Subject: [PATCH 168/671] Removed old log entries. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@483 6ac86273-5f31-0410-b378-82cca8765d1b --- bin/install.bat | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/bin/install.bat b/bin/install.bat index e959074e..259d09b6 100644 --- a/bin/install.bat +++ b/bin/install.bat @@ -34,23 +34,3 @@ echo Floppy creation aborted :done set D= -rem Log: install.bat,v -rem Revision 1.4 2001/11/04 21:46:53 bartoldeman -rem Text files need to be LF ended at the server. So be it... -rem -rem Revision 1.3 2001/03/22 04:12:43 bartoldeman -rem Change LF to CR/LF in batch files. -rem -rem Revision 1.2 2000/05/11 03:51:37 jimtabor -rem Clean up and Release -rem -rem Revision 1.3 1999/08/25 03:15:33 jprice -rem ror4 patches to allow TC 2.01 compile. -rem -rem Revision 1.2 1999/04/01 07:22:58 jprice -rem no message -rem -rem Revision 1.1.1.1 1999/03/29 15:40:21 jprice -rem New version without IPL.SYS -rem -rem From ed2036e13915ef46c7fe2b8d388d3eda06dff940 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Mon, 18 Nov 2002 23:02:07 +0000 Subject: [PATCH 169/671] Removed old log messages. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@484 6ac86273-5f31-0410-b378-82cca8765d1b --- drivers/floppy.asm | 39 --------------------------------------- drivers/getvec.asm | 32 -------------------------------- drivers/makefile | 39 --------------------------------------- drivers/rdatclk.asm | 27 --------------------------- drivers/rdpcclk.asm | 29 ----------------------------- drivers/wratclk.asm | 27 --------------------------- drivers/wrpcclk.asm | 27 --------------------------- 7 files changed, 220 deletions(-) diff --git a/drivers/floppy.asm b/drivers/floppy.asm index aa65841b..9929c5e3 100644 --- a/drivers/floppy.asm +++ b/drivers/floppy.asm @@ -449,42 +449,3 @@ skipint1e: pop bp ret - -; Log: floppy.asm,v -; -; Revision 1.4 1999/08/10 17:21:08 jprice -; ror4 2011-01 patch -; -; Revision 1.3 1999/04/16 21:29:17 jprice -; ror4 multi-sector IO -; -; Revision 1.2 1999/03/29 17:08:31 jprice -; ror4 changes -; -; Revision 1.1.1.1 1999/03/29 15:40:24 jprice -; New version without IPL.SYS -; -; Revision 1.4 1999/02/14 04:25:16 jprice -; Added functions to check if a floppy disk has been changed. -; -; Revision 1.3 1999/02/08 05:49:47 jprice -; Added Pat's 1937 kernel patches -; -; Revision 1.2 1999/01/22 04:16:39 jprice -; Formating -; -; Revision 1.1.1.1 1999/01/20 05:51:00 jprice -; Imported sources -; -; Rev 1.3 06 Dec 1998 8:43:00 patv -;New floppy support functions. -; -; Rev 1.2 29 Aug 1996 13:07:14 patv -;Bug fixes for v0.91b -; -; Rev 1.1 01 Sep 1995 18:50:34 patv -;Initial GPL release. -; -; Rev 1.0 02 Jul 1995 7:57:02 patv -;Initial revision. -; diff --git a/drivers/getvec.asm b/drivers/getvec.asm index 3821d7d2..153b20ac 100644 --- a/drivers/getvec.asm +++ b/drivers/getvec.asm @@ -55,35 +55,3 @@ getvec: mov dx,[es:bx+2] popf ; Pop flags ret - -; Log: getvec.asm,v -; -; Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 -; The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with -; MS-DOS. Distributed under the GNU GPL. -; -; Revision 1.3 1999/08/10 17:21:08 jprice -; ror4 2011-01 patch -; -; Revision 1.2 1999/03/29 17:08:31 jprice -; ror4 changes -; -; Revision 1.1.1.1 1999/03/29 15:40:27 jprice -; New version without IPL.SYS -; -; Revision 1.2 1999/01/22 04:16:39 jprice -; Formating -; -; Revision 1.1.1.1 1999/01/20 05:51:00 jprice -; Imported sources -; -; -; Rev 1.2 29 Aug 1996 13:07:10 patv -;Bug fixes for v0.91b -; -; Rev 1.1 01 Sep 1995 18:50:40 patv -;Initial GPL release. -; -; Rev 1.0 02 Jul 1995 8:00:36 patv -;Initial revision. -; diff --git a/drivers/makefile b/drivers/makefile index e71bf45f..426b8c3b 100644 --- a/drivers/makefile +++ b/drivers/makefile @@ -48,42 +48,3 @@ device.lib : $(OBJS) -$(RM) device.lib $(LIBUTIL) $(LIBFLAGS) device $(LIBOBJS) $(LIBTERM) -# Log: makefile,v -# -# Revision 1.6 1999/08/25 03:16:36 jprice -# ror4 patches to allow TC 2.01 compile. -# -# Revision 1.5 1999/08/10 17:21:08 jprice -# ror4 2011-01 patch -# -# Revision 1.4 1999/04/23 03:44:52 jprice -# Improved by jprice -# -# Revision 1.3 1999/04/13 15:47:07 jprice -# no message -# -# Revision 1.2 1999/03/29 17:08:31 jprice -# ror4 changes -# -# Revision 1.1.1.1 1999/03/29 15:40:23 jprice -# New version without IPL.SYS -# -# Revision 1.3 1999/02/09 04:49:25 jprice -# Make makefile use common config.mak file -# -# Revision 1.2 1999/01/22 04:16:39 jprice -# Formating -# -# Revision 1.1.1.1 1999/01/20 05:51:00 jprice -# Imported sources -# -# -# Rev 1.2 29 Aug 1996 13:07:12 patv -#Bug fixes for v0.91b -# -# Rev 1.1 19 Feb 1996 3:19:26 patv -#Added NLS, int2f and config.sys processing -# -# Rev 1.0 02 Jul 1995 7:54:52 patv -#Initial revision. -# diff --git a/drivers/rdatclk.asm b/drivers/rdatclk.asm index ed0766bf..8abd5b77 100644 --- a/drivers/rdatclk.asm +++ b/drivers/rdatclk.asm @@ -85,30 +85,3 @@ _ReadATClock: pop bp ret -; Log: rdatclk.asm,v -; -; Revision 1.3 1999/04/12 03:19:44 jprice -; more ror4 patches -; -; Revision 1.2 1999/03/29 17:08:31 jprice -; ror4 changes -; -; Revision 1.1.1.1 1999/03/29 15:40:31 jprice -; New version without IPL.SYS -; -; Revision 1.2 1999/01/22 04:16:39 jprice -; Formating -; -; Revision 1.1.1.1 1999/01/20 05:51:00 jprice -; Imported sources -; -; -; Rev 1.2 29 Aug 1996 13:07:10 patv -;Bug fixes for v0.91b -; -; Rev 1.1 01 Sep 1995 18:50:40 patv -;Initial GPL release. -; -; Rev 1.0 02 Jul 1995 8:00:16 patv -;Initial revision. -; diff --git a/drivers/rdpcclk.asm b/drivers/rdpcclk.asm index 8790a5d0..81ed79e0 100644 --- a/drivers/rdpcclk.asm +++ b/drivers/rdpcclk.asm @@ -52,32 +52,3 @@ _ReadPCClock: ret -; Log: rdpcclk.asm,v -; Revision 1.4 1999/08/10 17:21:08 jprice -; ror4 2011-01 patch -; -; Revision 1.3 1999/04/12 03:19:44 jprice -; more ror4 patches -; -; Revision 1.2 1999/03/29 17:08:31 jprice -; ror4 changes -; -; Revision 1.1.1.1 1999/03/29 15:40:32 jprice -; New version without IPL.SYS -; -; Revision 1.2 1999/01/22 04:16:39 jprice -; Formating -; -; Revision 1.1.1.1 1999/01/20 05:51:00 jprice -; Imported sources -; -; -; Rev 1.2 29 Aug 1996 13:07:10 patv -;Bug fixes for v0.91b -; -; Rev 1.1 01 Sep 1995 18:50:40 patv -;Initial GPL release. -; -; Rev 1.0 02 Jul 1995 8:00:26 patv -;Initial revision. -; diff --git a/drivers/wratclk.asm b/drivers/wratclk.asm index 1c59d74d..ab9071b2 100644 --- a/drivers/wratclk.asm +++ b/drivers/wratclk.asm @@ -61,30 +61,3 @@ _WriteATClock: pop bp ret -; Log: wratclk.asm,v -; -; Revision 1.3 1999/08/10 17:21:08 jprice -; ror4 2011-01 patch -; -; Revision 1.2 1999/03/29 17:08:31 jprice -; ror4 changes -; -; Revision 1.1.1.1 1999/03/29 15:40:34 jprice -; New version without IPL.SYS -; -; Revision 1.2 1999/01/22 04:16:40 jprice -; Formating -; -; Revision 1.1.1.1 1999/01/20 05:51:00 jprice -; Imported sources -; -; -; Rev 1.2 29 Aug 1996 13:07:12 patv -;Bug fixes for v0.91b -; -; Rev 1.1 01 Sep 1995 18:50:42 patv -;Initial GPL release. -; -; Rev 1.0 02 Jul 1995 8:01:18 patv -;Initial revision. -; diff --git a/drivers/wrpcclk.asm b/drivers/wrpcclk.asm index 989de394..7e6f7354 100644 --- a/drivers/wrpcclk.asm +++ b/drivers/wrpcclk.asm @@ -46,30 +46,3 @@ _WritePCClock: int 1ah ret -; Log: wrpcclk.asm,v -; -; Revision 1.3 1999/08/10 17:21:08 jprice -; ror4 2011-01 patch -; -; Revision 1.2 1999/03/29 17:08:31 jprice -; ror4 changes -; -; Revision 1.1.1.1 1999/03/29 15:40:35 jprice -; New version without IPL.SYS -; -; Revision 1.2 1999/01/22 04:16:40 jprice -; Formating -; -; Revision 1.1.1.1 1999/01/20 05:51:00 jprice -; Imported sources -; -; -; Rev 1.2 29 Aug 1996 13:07:12 patv -;Bug fixes for v0.91b -; -; Rev 1.1 01 Sep 1995 18:50:42 patv -;Initial GPL release. -; -; Rev 1.0 02 Jul 1995 8:01:30 patv -;Initial revision. -; From e67a8f505851dc5e84eb64f401db2eaffdc8b6f4 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Mon, 9 Dec 2002 00:17:15 +0000 Subject: [PATCH 170/671] Changes for kernel 2028 (see history.txt) git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@485 6ac86273-5f31-0410-b378-82cca8765d1b --- docs/build.txt | 13 - docs/fdkernel.lsm | 7 +- docs/history.txt | 27 ++ docs/intfns.txt | 15 - docs/oldhist.txt | 931 +++++++++++++++++++++++++++++++++++++++++++ drivers/floppy.asm | 2 +- drivers/getvec.asm | 2 +- drivers/rdatclk.asm | 2 +- drivers/rdpcclk.asm | 2 +- drivers/wratclk.asm | 2 +- drivers/wrpcclk.asm | 2 +- hdr/buffer.h | 18 +- hdr/cds.h | 27 -- hdr/clock.h | 37 -- hdr/date.h | 37 -- hdr/dcb.h | 40 -- hdr/device.h | 58 --- hdr/dirmatch.h | 43 -- hdr/dosnames.h | 33 -- hdr/error.h | 43 -- hdr/exe.h | 34 -- hdr/fat.h | 67 ++-- hdr/fcb.h | 40 -- hdr/file.h | 34 -- hdr/fnode.h | 45 +-- hdr/kbd.h | 34 -- hdr/mcb.h | 37 -- hdr/pcb.h | 37 -- hdr/portab.h | 39 +- hdr/process.h | 40 -- hdr/sft.h | 43 -- hdr/stacks.inc | 25 -- hdr/tail.h | 34 -- hdr/time.h | 37 -- hdr/version.h | 8 +- kernel/apisupt.asm | 39 +- kernel/asmsupt.asm | 42 +- kernel/blockio.c | 371 ++++++----------- kernel/break.c | 10 - kernel/chario.c | 68 ---- kernel/config.c | 150 ++----- kernel/console.asm | 31 +- kernel/dosfns.c | 88 ---- kernel/dosidle.asm | 2 +- kernel/dosnames.c | 59 --- kernel/dsk.c | 140 +------ kernel/entry.asm | 68 +--- kernel/error.c | 40 -- kernel/execrh.asm | 39 +- kernel/fatdir.c | 95 +---- kernel/fatfs.c | 163 +------- kernel/fattab.c | 68 +--- kernel/fcbfns.c | 61 --- kernel/globals.h | 128 +----- kernel/init-dat.h | 3 +- kernel/initclk.c | 102 +++++ kernel/initdisk.c | 19 +- kernel/inithma.c | 10 +- kernel/initoem.c | 43 -- kernel/int2f.asm | 61 +-- kernel/inthndlr.c | 200 ++-------- kernel/intr.asm | 2 +- kernel/io.asm | 50 +-- kernel/io.inc | 36 +- kernel/ioctl.c | 52 --- kernel/irqstack.asm | 44 +- kernel/kernel.asm | 103 +---- kernel/main.c | 96 +---- kernel/makefile | 101 +---- kernel/memmgr.c | 49 --- kernel/misc.c | 43 -- kernel/network.c | 16 - kernel/newstuff.c | 52 --- kernel/nls.c | 8 +- kernel/nls_hc.asm | 2 +- kernel/nls_load.c | 8 - kernel/nlssupt.asm | 40 +- kernel/prf.c | 41 -- kernel/printer.asm | 15 - kernel/procsupt.asm | 53 +-- kernel/proto.h | 98 +---- kernel/segs.inc | 37 +- kernel/serial.asm | 2 +- kernel/strings.c | 49 --- kernel/sysclk.c | 54 +-- kernel/syspack.c | 31 -- kernel/systime.c | 49 --- kernel/task.c | 90 +---- mkfiles/bc5.mak | 2 +- mkfiles/mscl8.mak | 4 +- mkfiles/tc2.mak | 2 +- mkfiles/tc3.mak | 2 +- mkfiles/turbocpp.mak | 2 +- mkfiles/watcom.mak | 2 +- sys/sys.c | 40 ++ 95 files changed, 1522 insertions(+), 3748 deletions(-) create mode 100644 docs/oldhist.txt create mode 100644 kernel/initclk.c diff --git a/docs/build.txt b/docs/build.txt index e7700fdc..a8b56388 100644 --- a/docs/build.txt +++ b/docs/build.txt @@ -85,17 +85,4 @@ component. Study the makefile to better understand this. $Id$ -Log: build.txt,v -Revision 1.3 2000/08/15 03:42:17 jhall1 -update to the build.txt file to remove references to the now-defunct - web site at gcfl.net (John's old site). - -Revision 1.2 2000/05/08 04:27:48 jimtabor -Update CVS to 2020 - -Revision 1.2 1999/08/25 04:12:31 jprice -update - -Revision 1.1 1999/08/25 03:46:41 jprice -New build config diff --git a/docs/fdkernel.lsm b/docs/fdkernel.lsm index df316802..ce090672 100644 --- a/docs/fdkernel.lsm +++ b/docs/fdkernel.lsm @@ -1,13 +1,12 @@ Begin3 Title: The FreeDOS Kernel -Version: 2.0.27 -Entered-date: xx Aug 2002 +Version: 2.0.28 +Entered-date: 09 Dec 2002 Description: The FreeDOS Kernel. Keywords: kernel freedos dos msdos Author: (developers) -Maintained-by: bart@dosemu.org +Maintained-by: bartoldeman@users.sourceforge.net Primary-site: http://freedos.sourceforge.net -Alternate-site: www.dosemu.org/~bart Original-site: http://www.gcfl.net/pub/FreeDOS/kernel Platforms: dos dosemu Copying-policy: GPL diff --git a/docs/history.txt b/docs/history.txt index 0c61cf23..7dc0a1aa 100644 --- a/docs/history.txt +++ b/docs/history.txt @@ -1,3 +1,30 @@ +2002 Dec 9 - Build 2028 +-------- Bart Oldeman (bart@dosemu.org) ++ Changes Tom + * move clock driver initialization to inittext + * new ELSE_ISFAT16 macro to save some bytes + * use _TEXT for old HMA_TEXT, _LOWTEXT for old _TEXT to get + a slightly less complicated memory model from the C compiler's + point of view. + * add support for int2f/4a01,4a02: query/allocate HMA space. ++ Changes Arkady V. Belousov + * slightly improved asm for print_hex and int2f clear_ax stuff + * use #error for unknown compilers + * remove hexDigits reference + * correct comment in kernel.asm (pad to 05fdh) ++ Changes Bart + * fix ss:sp init bug for int21/ax=4b01 (visible in DEBUG) + * fix redirection problem for character output routines + * fix press the any key message for floppy swaps + * correct cluster value for BAD cluster + * correct FAT12/16/32 cutoff magic values as per the MS spec + * the BUFFERS structure is now the same as in MSDOS 5+ and uses + a circular double-linked list using near pointers. + * move all old RCS log messages into one seperate file + * divide the fnode f_cluster_offset field by the size of a cluster: + this gives a more efficient map_cluster(). + * point the CharMapSrvc pointer to the DOS DS for AARD compliance. + * nls.c: set CX to cooperate with load_unf.exe 2002 Nov 9 - Build 2027 -------- Bart Oldeman (bart@dosemu.org) + Changes Tom diff --git a/docs/intfns.txt b/docs/intfns.txt index 732b867b..024b09ca 100644 --- a/docs/intfns.txt +++ b/docs/intfns.txt @@ -193,18 +193,3 @@ See COPYING in DOS-C root directory for license. --------------------------------------------------------------------- $Id$ - -Log: intfns.txt,v - -Revision 1.2 2000/03/18 05:51:55 kernel -changes in supported functions - -Revision 1.1 1999/08/25 03:46:42 jprice -New build config - -Revision 1.1.1.1 1999/03/29 15:39:16 jprice -New version without IPL.SYS - -Revision 1.2 1999/03/02 06:55:51 jprice -Updated interrupt list - diff --git a/docs/oldhist.txt b/docs/oldhist.txt new file mode 100644 index 00000000..6dbb87b8 --- /dev/null +++ b/docs/oldhist.txt @@ -0,0 +1,931 @@ +13 Nov 2002 tom +initclk.c: +Initial revision + +2001/11/04 bartoldeman +install.bat: +Text files need to be LF ended at the server. So be it... + +2001/04/29 brianreifsnyder +dsk.c: +Added phase 1 support for LBA hard drives + +20 Apr 2001 Bart Oldeman +buffer.h: +Initial revision. + +2001/04/16 bartoldeman +dsk.c: +Fixed handles, config.sys drivers, warnings. Enabled INT21/AH=6C, printf %S/%Fs + +2001/04/15 bartoldeman +dsk.c: +See history.txt for the list of fixes. + +2001/03/27 bartoldeman +dsk.c: +dsk.c (reported by Nagy Daniel), inthndlr and int25/26 fixes by Tom Ehlert. + +2001/03/24 bartoldeman +dsk.c: +See history.txt: dsk.c changes, warning removal and int21 entry handling. + +2001/03/22 bartoldeman +install.bat: +Change LF to CR/LF in batch files. + +2001/03/21 bartoldeman +dsk.c: +See history.txt for changes. Bug fixes and HMA support are the main ones. + +2001/03/16 tom ehlert +inithma.c: +initial creation + +2001/03/08 bartoldeman +dsk.c: +Space saving fixes from Tom Ehlert + +2001/03/07 10:00:00 tomehlert +prf.c: +recoded for smaller object footprint, added main() for testing+QA + +2000/10/29 jimtabor +inthndlr.c: +Adding Share Support by Ron Cemer + +2000/08/15 jhall1 +build.txt: +update to the build.txt file to remove references to the now-defunct +web site at gcfl.net (John's old site). + +2000/08/06 jimtabor +inthndlr.c, nls_load.c: +Add new files and update cvs with patches and changes + +2000/06/21 jimtabor +dsk.c, inthndlr.c: +Add UMB code, patch, and code fixes + +2000/06/01 jimtabor +dsk.c: +Read History for Changes + +2000/05/26 jimtabor +dsk.c: +Read History file for Change info + +2000/05/25 jimtabor +dsk.c, inthndlr.c: +Fixed project history + +2000/05/17 jimtabor +dsk.c, inthndlr.c: +Cleanup, add and fix source. + +2000/05/11 jimtabor +inthndlr.c: +Removed #if statement + +2000/05/11 jimtabor +dsk.c, inthndlr.c: +Added code for DOS FN 69 & 6C + +2000/05/11 jimtabor +install.bat, inthndlr.c: +Clean up and Release + +2000/05/08 jimtabor +inthndlr.c, dosnames.c, dsk.c, dosnames.h, build.txt: +Update CVS to 2020 + +2000/05/06 jhall1 +getvec.asm, dsk.c, inthndlr.c: +The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with +MS-DOS. Distributed under the GNU GPL. + +2000/04/29 jtabor +device.h, blockio.c, dsk.c, fatfs.c, inthndlr.c, ioctl.c: +Added new functions and clean up code + +2000/04/02 jtabor +newstuff.c: +Fix ChgDir Code + +2000/04/02 jtabor +dosfns.c: +Replaced ChgDir Code + +2000/04/02 jtabor +dosfns.c: +Fix to DosChgDir + +2000/03/31 jprice +sys.c: +Added discription of program. + +2000/03/31 jtabor +config.c, dosfns.c, dosnames.c, fatdir.c, fcbfns.c, int2f.asm, main.c, +makefile, network.c, newstuff.c, proto.h, task.c: +Added Eric W. Biederman Patches + +2000/03/23 ska +nls.c: +Initial revision + +2000/03/20 kernel +entry.asm: +Change in Entry.asm + +2000/03/18 kernel +intfns.txt: +changes in supported functions + +2000/03/17 kernel +config.c, fatdir.c, fatfs.c, fcbfns.c, inthndlr.c, makefile, +network.c, nlssupt.asm, proto.h: +Steffen Kaiser's NLS changes + +2000/03/17 kernel +inthndlr.c: +Fixed Func 0x32 + +2000/03/17 kernel +fatfs.c: +Added Change for media_check + +2000/03/16 kernel +globals.h, inthndlr.c: +*** empty log message *** + +2000/03/09 kernel +dosfns.c, dosnames.c, dsk.c, error.c, execrh.asm, fatdir.c, fatfs.c, +fcbfns.c, globals.h, initoem.c, int2f.asm, inthndlr.c, io.asm, +ioctl.c, kernel.asm, main.c, makefile, memmgr.c, misc.c, network.c, +newstuff.c, prf.c, proto.h, strings.c, sysclk.c, task.c, blockio.c, +break.c, chario.c, config.c, console.asm, cds.h, dcb.h, device.h, +dirmatch.h, fnode.h, mcb.h, sft.h, stacks.inc: +2017f updates by James Tabor + +1999/09/25 jprice +boot.asm: +Optimize boot loader. Documentation. + +1999/09/24 jprice +boot.asm: +Added changes recommended by Jens Horstmeier +to make their bootable CD work. + +1999/09/23 jprice +main.c, network.c, proto.h, globals.h, inthndlr.c, kernel.asm, +makefile, config.c, console.asm, dosfns.c, entry.asm, fatfs.c, +fcbfns.c, chario.c, boot.asm, fcb.h, sys/makefile, sys.c: +*** empty log message *** + +1999/09/20 jprice +sys.c: +Changed open/creat to fopen to make TC2 happy. + +1999/09/15 jprice +sys.c: +Changed boot sector writing code so easier to read. + +1999/09/14 jprice +lib/makefile: +no message + +1999/09/14 jprice +sys.c: +Added debug log creation to sys.com. + +1999/09/14 jprice +console.asm: +no message + +1999/09/14 jprice +inthndlr.c: +ror4: fix int25 & 26 are not cached. + +1999/09/14 jprice +fatfs.c, dosfns.c: +Fixed bug where you could write over directories. + +1999/09/13 jprice +inthndlr.c, console.asm: +Fix 210B function + +1999/09/13 jprice +console.asm: +Changes from Helmut Fritsch to fix INT21 func B + +1999/09/13 jprice +makefile: +Some clean up. + +1999/09/13 jprice +config.b, config.b: +Added COMPILER variable + +1999/09/13 jprice +lib/makefile: +Added !if so we can use TC2 or TC3 to compile. + +1999/08/25 jprice +build.txt: +update + +1999/08/25 jprice +config.b, clobber.bat, clean.bat, config.b, build.bat: +New build batch files. + +1999/08/25 jprice +intfns.txt, build.txt, build.bat: +New build config + +1999/08/25 jprice +config.b, sys/makefile, sys.c, lib/makefile, task.c, main.c, makefile, +memmgr.c, newstuff.c, proto.h, strings.c, fatfs.c, globals.h, +initoem.c, inthndlr.c, blockio.c, chario.c, config.c, dosfns.c, +fatdir.c, date.h, dirmatch.h, portab.h, time.h, drivers/makefile, +install.bat: +ror4 patches to allow TC 2.01 compile. + +1999/08/10 jprice +clobber.bat: +case + +1999/08/10 jprice +dsk.c, inthndlr.c: +ror4 2011-04 patch + +1999/08/10 jprice +globals.h, inthndlr.c, fatfs.c, fattab.c, blockio.c: +ror4 2011-03 patch + +1999/08/10 jprice +irqstack.asm, kernel.asm, makefile, nlssupt.asm, printer.asm, +procsupt.asm, segs.inc, apisupt.asm, asmsupt.asm, console.asm, entry.asm, execrh.asm, fatdir.c, +int2f.asm, io.asm, io.inc, stacks.inc: +ror4 2011-02 patch + +1999/08/10 jprice +wrpcclk.asm, wratclk.asm, rdpcclk.asm, drivers/makefile, getvec.asm, floppy.asm: +ror4 2011-01 patch + +1999/05/04 jprice +systime.c: +ror4 date fix + +1999/05/03 jprice +fat.h: +Changed some variables from signed to unsigned. + +1999/05/03 jprice +blockio.c, config.c, dosfns.c, fatdir.c, fatfs.c, fattab.c, globals.h, +inthndlr.c, misc.c, proto.h: +Patches from ror4 and many changed of signed to unsigned variables. + +1999/05/03 jprice +sys/makefile: +no message + +1999/05/03 jprice +fatfs.c: +Fixed bug in map_cluster function + +1999/05/03 jprice +blockio.c: +Changed getblock & getbuf so that they leave at least 3 buffer for FAT data. + +1999/04/23 jprice +procsupt.asm: +Fixed got_cbreak function. + +1999/04/23 jprice +makefile: +no message + +1999/04/23 jprice +asmsupt.asm, inthndlr.c, memmgr.c, misc.c, proto.h, task.c: +Memory manager changes made by ska + +1999/04/23 jprice +clobber.bat: +Initial include + +1999/04/23 jprice +clean.bat, build.bat, sys/makefile, lib/makefile, makefile, drivers/makefile: +Improved by jprice + +1999/04/23 jprice +boot/makefile: +Ported to NASM by ror4. Improvements + +1999/04/23 jprice +boot.asm: +Ported to NASM by ror4 + +1999/04/21 jprice +blockio.c: +no message + +1999/04/18 jprice +blockio.c: +no message + +1999/04/17 jprice +sys.c, boot.asm: +Fixed multi-sector code + +1999/04/17 jprice +build.bat: +ror4 patches + +1999/04/17 jprice +boot.asm: +Changed so multi-sector IO is optional. + +1999/04/16 jprice +blockio.c, config.c, dsk.c, globals.h, main.c, proto.h, floppy.asm: +ror4 multi-sector IO + +1999/04/16 jprice +break.c: +Steffen contributed. + +1999/04/16 jprice +dosfns.c, globals.h, inthndlr.c, irqstack.asm, main.c, makefile, procsupt.asm, +proto.h, chario.c, config.c: +Steffen c-break handler changes + +1999/04/16 jprice +fatfs.c, fattab.c, globals.h, main.c, task.c, blockio.c, config.c, +dsk.c, fatdir.c, fnode.h, dcb.h: +Optimized FAT handling + +1999/04/13 jprice +kernel.asm: +changes for boot loader + +1999/04/13 jprice +boot.asm: +Moves boot sector to top of mem + +1999/04/13 jprice +makefile, fatdir.c, drivers/makefile: +no message + +1999/04/12 jprice +fatfs.c, blockio.c: +Using getbuf to write data instead of getblock +using getblock made it read the block before it wrote it + +1999/04/12 jprice +systime.c, config.c, dosfns.c, fatfs.c, globals.h, main.c, proto.h, +sysclk.c: +more ror4 patches. Changes for multi-block IO + +1999/04/12 jprice +rdpcclk.asm, rdatclk.asm: +more ror4 patches + +1999/04/11 jprice +blockio.c: +Working on multi-block IO + +1999/04/11 jprice +globals.h, inthndlr.c, main.c, newstuff.c, proto.h, task.c, blockio.c, +config.c, dosfns.c, fatdir.c, fatfs.c, fattab.c: +ror4 patches + +1999/04/06 jprice +boot.asm: +Put back code to read multiple sectors at a time. + +1999/04/04 jprice +config.c, globals.h, inthndlr.c, main.c, dosfns.c, dosnames.c, +fatdir.c, fatfs.c, fcbfns.c, globals.h, inthndlr.c, ioctl.c, main.c, +newstuff.c, prf.c, proto.h, strings.c, chario.c, sft.h, device.h: +no message + +1999/04/01 jprice +sys.c: +SYS modified for new boot loader + +1999/04/01 jprice +boot/makefile, boot.asm: +New boot loader + +1999/04/01 jprice +install.bat: +no message + +1999/03/29 jprice +wrpcclk.asm, wratclk.asm, rdpcclk.asm, rdatclk.asm, drivers/makefile, +getvec.asm, floppy.asm, globals.h, io.inc, task.c: +ror4 changes + +1999/03/29 jprice +sys.c: +Fixed error message + +1999/03/29 jprice +sys.c, syspack.c, prf.c, misc.c, fcbfns.c, fattab.c, fatfs.c, +fatdir.c, error.c, dosnames.c, dosfns.c, chario.c, blockio.c, task.c, +systime.c, sysclk.c, strings.c, proto.h, segs.inc, procsupt.asm, +printer.asm, nlssupt.asm, newstuff.c, memmgr.c, main.c, makefile, +kernel.asm, irqstack.asm, ioctl.c, io.inc, io.asm, inthndlr.c, +int2f.asm, globals.h, initoem.c, execrh.asm, entry.asm, dsk.c, +console.asm, config.c, asmsupt.asm, apisupt.asm, wrpcclk.asm, +wratclk.asm, rdpcclk.asm, rdatclk.asm, getvec.asm, floppy.asm, +drivers/makefile, install.bat, boot/makefile, boot.asm, tail.h, +time.h, sft.h, stacks.inc, process.h, portab.h, pcb.h, kbd.h, mcb.h, +file.h, fnode.h, fcb.h, exe.h, fat.h, dosnames.h, error.h, device.h, +date.h, dcb.h, cds.h, clock.h, dirmatch.h, intfns.txt, clean.bat, +build.bat: +New version without IPL.SYS + +1999/03/25 jprice +fatdir.c: +Fixed findfirst & findnext functions to treat the attributes like MSDOS does. + +1999/03/23 jprice +inthndlr.c: +Now sets carry when we don't support a function + +1999/03/23 jprice +config.c: +Now checks for a reads fdconfig.sys file, if exists + +1999/03/23 jprice +fatfs.c: +Fixed mkdir DOS function so it will create a directory with same name as the volument label + +1999/03/02 jprice +inthndlr.c: +Added some comments. Fixed some minor bugs. + +1999/03/02 jprice +fatfs.c: +Fixed bugs with dos set attribute function. Now returns correct +error code, and errors if user tries to set bits 6 & 7. + +1999/03/02 jprice +boot.asm: +Added entry address for more recent versions of TLINK + +1999/03/02 jprice +intfns.txt: +Updated interrupt list + +1999/03/01 jprice +makefile: +Fixed so it'll work with config.mak + +1999/03/01 jprice +makefile: +Turned off DEBUG define. + +1999/03/01 jprice +inthndlr.c: +Added some DEBUG ifdef's so that it will compile without DEBUG defined. + +1999/02/14 jprice +fatdir.c, dsk.c: +Changed check media so that it checks if a floppy disk has been changed. + +1999/02/14 jprice +floppy.asm: +Added functions to check if a floppy disk has been changed. + +1999/02/09 jprice +makefile, drivers/makefile, boot/makefile, clean.bat, build.bat: +Make makefile use common config.mak file + +1999/02/09 jprice +blockio.c, chario.c, dosfns.c, error.c, fatdir.c, fatfs.c, fattab.c, +fcbfns.c, device.h, error.h, sysclk.c, systime.c, task.c, apisupt.asm, +asmsupt.asm, config.c, console.asm, dsk.c, entry.asm, execrh.asm, +globals.h, initoem.c, int2f.asm, inthndlr.c, io.asm, io.inc, ioctl.c, +irqstack.asm, kernel.asm, main.c, makefile, memmgr.c, newstuff.c, +nlssupt.asm, printer.asm, procsupt.asm, proto.h, segs.inc, floppy.asm: +Added Pat's 1937 kernel patches + +1999/02/04 jprice +chario.c, fatfs.c, fcbfns.c, strings.c, sysclk.c, systime.c, task.c: +Formating. Added comments. + +1999/02/04 jprice +inthndlr.c: +Formating + +1999/02/04 jprice +makefile: +Added option to share constants (-d). + +1999/02/04 jprice +device.h: +no message + +1999/02/02 jprice +dosnames.c: +Steve Miller fixed a bug with doing "cd ." would lock the machine. + +1999/02/01 jprice +apisupt.asm, asmsupt.asm, config.c, dsk.c, entry.asm, execrh.asm, globals.h, +initoem.c, int2f.asm, inthndlr.c, ioctl.c, irqstack.asm, kernel.asm, +main.c, memmgr.c, newstuff.c, nlssupt.asm, procsupt.asm, proto.h, +strings.c, sysclk.c, systime.c, task.c: +Clean up; Now you can use hex numbers in config.sys. added config.sys screen function to change screen mode (28 or 43/50 lines) + +1999/02/01 jprice +chario.c, dosfns.c, dosnames.c, error.c, fatdir.c, fatfs.c, fattab.c, +fcbfns.c, misc.c, prf.c, syspack.c, blockio.c: +Fixed findfirst function to find volume label with Windows long filenames + +1999/02/01 jprice +cds.h, clock.h, date.h, dcb.h, device.h, dirmatch.h, dosnames.h, error.h, +exe.h, fat.h, fcb.h, file.h, fnode.h, kbd.h, mcb.h, pcb.h, portab.h, process.h, +sft.h, stacks.inc, tail.h, time.h: +Clean up + +1999/01/30 jprice +clean.bat, build.bat: +Clean up + +1999/01/30 jprice +main.c, config.c, initoem.c, inthndlr.c: +Clean up; Fixed bug with set attribute function. + +1999/01/30 jprice +globals.h: +Clean up; commented out copyright messages while we debug. + +1999/01/30 jprice +blockio.c, fatdir.c, fatfs.c: +Clean up; Fixed bug with set attribute function. If you tried to +change the attributes of a directory, it would erase it. + +1999/01/30 jprice +cds.h, clock.h, error.h, fat.h, fnode.h, build.bat: +Clean up + +1999/01/22 jprice +cds.h, clock.h, date.h, dcb.h, device.h, dirmatch.h, dosnames.h, error.h, +exe.h, fat.h, fcb.h, file.h, fnode.h, kbd.h, mcb.h, pcb.h, portab.h, process.h, +sft.h, stacks.inc, tail.h, time.h, wrpcclk.asm, wratclk.asm, +rdpcclk.asm, rdatclk.asm, drivers/makefile, getvec.asm, floppy.asm, +blockio.c, chario.c, dosfns.c, dosnames.c, error.c, fatdir.c, fatfs.c, +fattab.c, fcbfns.c, misc.c, prf.c, syspack.c, procsupt.asm, proto.h, +strings.c, sysclk.c, systime.c, task.c, globals.h, initoem.c, +int2f.asm, inthndlr.c, ioctl.c, irqstack.asm, kernel.asm, main.c, +makefile, memmgr.c, newstuff.c, nlssupt.asm, apisupt.asm, asmsupt.asm, +config.c, dsk.c, entry.asm, execrh.asm, boot/makefile, boot.asm: +Formating. + +1999/01/21 jprice Fixed comments. +sys.c: +Added indent program + +1999/01/21 jprice Added messages to sys. Also made +sys.c: +it create a .COM file. + +1999/01/20 jprice +cds.h, clock.h, date.h, dcb.h, device.h, dirmatch.h, dosnames.h, error.h, +exe.h, fat.h, fcb.h, file.h, fnode.h, kbd.h, mcb.h, pcb.h, portab.h, process.h, +sft.h, stacks.inc, tail.h, time.h, apisupt.asm, asmsupt.asm, config.c, dsk.c, +entry.asm, execrh.asm, globals.h, initoem.c, int2f.asm, ioctl.c, irqstack.asm, +kernel.asm, main.c, makefile, memmgr.c, newstuff.c, nlssupt.asm, +procsupt.asm, proto.h, strings.c, sysclk.c, systime.c, task.c: +Imported sources + +1999/01/20 jprice +wrpcclk.asm, wratclk.asm, rdpcclk.asm, rdatclk.asm, drivers/makefile, +getvec.asm, floppy.asm, boot/makefile, boot.asm, blockio.c, chario.c, dosfns.c, +dosnames.c, error.c, fatdir.c, fatfs.c, fattab.c, fcbfns.c, +inthndlr.c, misc.c, prf.c, syspack.c: +Imported sources + +10 Jan 1999 SRM +makefile: +Took out "/P-" from TLINK +Changed "bcc" to "tcc" + +06 Dec 1998 patv +entry.asm: +New int 21h handler code. + +06 Dec 1998 patv +inthndlr.c: +Expanded due to improved int 21h handler code. + +06 Dec 1998 patv +ioctl.c, proto.h, apisupt.asm, globals.h: +Expanded due to new I/O subsystem. + +06 Dec 1998 patv +makefile: +Added new files for I/O subsystem. + +06 Dec 1998 patv +main.c, dsk.c: +Changed due to new I/O subsystem. + +06 Dec 1998 patv +irqstack.asm, newstuff.c, int2f.asm, kernel.asm, systime.c, +nlssupt.asm, asmsupt.asm, procsupt.asm, task.c, execrh.asm, fatdir.c, +fatfs.c: +Bug fixes. + +06 Dec 1998 patv +dosfns.c: +Expanded dos functions due to new I/O subsystem. + +06 Dec 1998 patv +fcbfns.c: +Expanded fcb functions for new I/O subsystem. + +06 Dec 1998 patv +error.c: +Now handles errors like MS-DOS. + +06 Dec 1998 patv +chario.c: +changes in character I/O because of new I/O subsystem. + +06 Dec 1998 patv +blockio.c: +Changes in block I/O because of new I/O subsystem. + +06 Dec 1998 patv +floppy.asm: +New floppy support functions. + +06 Dec 1998 patv +device.h: +Changed for new I/O subsystem + +06 Dec 1998 patv +error.h: +Added new errors for new I/O subsystem. + +06 Dec 1998 patv +io.inc, segs.inc: +Initial revision. + +09 Feb 1998 patv +fatfs.c, fattab.c: +Eliminated FAT12 EOF and error returns. + +07 Feb 1998 patv +stacks.inc, pcb.h, entry.asm, procsupt.asm, inthndlr.c, task.c, +globals.h, proto.h: +Modified stack fram to match DOS standard + +03 Feb 1998 patv +kernel.asm: +Added a start-up stack for loadable device drivers. Need the separate +stack so that all int 21h functions can be called. + +03 Feb 1998 patv +fatfs.c: +Fixed lseek bug. + +02 Feb 1998 patv +globals.h: +Fixed size of default_drive. Caused failures when break_ena was not zero. + +31 Jan 1998 patv +task.c: +Corrected type in load high code. + +31 Jan 1998 patv +task.c: +Added load high in memory option in DosExeLoader. + +22 Jan 1998 patv +task.c: +Eliminated warnings. + +22 Jan 1998 patv +process.h: +Had to change ps_prevps to VOID FAR * due to BC++ error. + +22 Jan 1998 patv +process.h: +Corrected ps_prevpsp declaration. + +22 Jan 1998 patv +task.c: +Corrected short .COM problem. + +22 Jan 1998 patv +makefile: +Outdated stacks.asm. + +22 Jan 1998 patv +fatfs.c: +Corrected remaining file name and extension copies that did not +account for far file nodes due to allocated FILES= spec. + +22 Jan 1998 patv +inthndlr.c, proto.h, config.c, globals.h, kernel.asm, main.c, +blockio.c, dosnames.c, fatdir.c, fatfs.c: +Fixed pointer problems affecting SDA + +11 Jan 1998 patv +ioctl.c, proto.h, chario.c, device.h: +Added functionality to ioctl. + +08 Jan 1998 patv +chario.c: +Changed automatic requestic packets to static to save stack space. + +06 Jan 1998 patv +inthndlr.c: +Broke apart int21_system from int21_handler. + +06 Jan 1998 patv +kernel.asm: +Reduced device driver stack sizes. + +04 Jan 1998 patv +globals.h, proto.h, inthndlr.c, newstuff.c, systime.c, main.c, +config.c, ioctl.c, memmgr.c, dsk.c, initoem.c, strings.c, sysclk.c, +task.c, fatfs.c, chario.c, dosfns.c, dosnames.c, fattab.c, fcbfns.c, +prf.c, syspack.c, blockio.c, error.c, fatdir.c, misc.c, device.h, +cds.h, clock.h, date.h, dcb.h, fat.h, file.h, fnode.h, kbd.h, mcb.h, +pcb.h, sft.h, dirmatch.h, error.h, exe.h, fcb.h, portab.h, process.h, +tail.h, time.h: +Changed Log for strip utility + +04 Jan 1998 patv +kernel.asm, inthndlr.c, main.c, config.c, newstuff.c, fatfs.c: +Corrected subdirectory bug + +03 Jan 1998 patv +globals.h, kernel.asm, makefile, systime.c, inthndlr.c, main.c, +proto.h, asmsupt.asm, dosfns.c, dosnames.c, fatfs.c, blockio.c, +fatdir.c, fcbfns.c: +Converted data area to SDA format + +31 Dec 1997 patv +strings.c: +Added new far string functions. + +30 Dec 1997 patv +chario.c: +Modified to support SDA + +01 Aug 1997 patv +inthndlr.c: +COMPATIBILITY: Added return '$' in AL for function int 21h fn 09h + +06 Feb 1997 patv +kernel.asm: +Reduced stack sizes for block and clock devices. + +06 Feb 1997 patv +globals.h: +Changed version format string + +06 Feb 1997 patv +main.c: +Modified to support new version format and changed debug message to +output drive letter instead of number. + +06 Feb 1997 patv +globals.h: +Modified to support new version format + +06 Feb 1997 patv +inthndlr.c, kernel.asm: +Added hooks for tsc command + +30 Jan 1997 patv +makefile: +Added TSC flag for trace support. + +22 Jan 1997 patv +newstuff.c, inthndlr.c, task.c, irqstack.asm: +pre-0.92 Svante Frey bug fixes. + +22 Jan 1997 patv +globals.h: +Changed to support version.h and pre-0.92 Svante Frey bug fixes. + +22 Jan 1997 patv +main.c: +Now does correct default drive initialization. + +22 Jan 1997 patv +fatfs.c, dosfns.c: +pre-0.92 bug fixes + +16 Jan 1997 patv +irqstack.asm: +Initial revision. + +16 Jan 1997 patv +globals.h, main.c, memmgr.c, task.c, ioctl.c, config.c, inthndlr.c, +apisupt.asm, nlssupt.asm, proto.h, makefile, fcbfns.c, chario.c, +dosnames.c, blockio.c, dosfns.c, fatdir.c, fatfs.c, fattab.c, +device.h, fcb.h, sft.h, dsk.c, boot.asm: +Corrected copyright + +10 Jan 1997 patv +boot.asm: +Re-written to support C drive and eliminate restrictions on IPL.SYS + +10 Jan 1997 patv +boot/makefile: +Changed to use FreeDOS exe2bin and support new boot code + +17 Dec 1996 patv +boot/makefile: +Converted to FreeDOS exe2bin. + +13 Sep 1996 patv +globals.h: +Fixed boot for hard drive + +29 Aug 1996 patv +makefile, globals.h, task.c, floppy.asm, wrpcclk.asm, wratclk.asm, +drivers/makefile, rdpcclk.asm, rdatclk.asm, getvec.asm, boot/makefile, +boot.asm: +Bug fixes for v0.91b + +29 May 1996 patv +clock.h, date.h, dcb.h, kbd.h, dirmatch.h, error.h, exe.h, sft.h, +tail.h, time.h, fnode.h, mcb.h, pcb.h, portab.h, process.h, +dosnames.h, fat.h, fcb.h, file.h, device.h, dosfns.c, fatdir.c, +misc.c, fatfs.c, fattab.c, fcbfns.c, chario.c, dosnames.c, syspack.c, +blockio.c, error.c, prf.c, initoem.c, sysclk.c, int2f.asm, config.c, +kernel.asm, inthndlr.c, proto.h, systime.c, apisupt.asm, asmsupt.asm, +nlssupt.asm, procsupt.asm, task.c, globals.h, memmgr.c, dsk.c, main.c, +makefile, execrh.asm, ioctl.c, strings.c: +bug fixes for v0.91a + +19 Feb 1996 patv +int2f.asm: +Initial revision. + +19 Feb 1996 patv +makefile, kernel.asm, nlssupt.asm, proto.h, globals.h, config.c, +inthndlr.c, task.c, dsk.c, main.c, memmgr.c, strings.c, initoem.c, +ioctl.c, sysclk.c, systime.c, fatdir.c, misc.c, fatfs.c, dosfns.c, +dosnames.c, fattab.c, drivers/makefile, cds.h, dirmatch.h, exe.h, +sft.h, tail.h, time.h, fcb.h, file.h, fnode.h, mcb.h, pcb.h, portab.h, +process.h, clock.h, date.h, dcb.h, device.h, dosnames.h, fat.h, +error.h, kbd.h: +Added NLS, int2f and config.sys processing + +01 Sep 1995 patv +wrpcclk.asm, wratclk.asm, rdpcclk.asm, rdatclk.asm, getvec.asm, +floppy.asm, boot.asm, apisupt.asm, asmsupt.asm, proto.h, kernel.asm, +procsupt.asm, execrh.asm, strings.c, task.c, inthndlr.c, memmgr.c, +dsk.c, main.c, sysclk.c, globals.h, initoem.c, ioctl.c, systime.c, +dosfns.c, blockio.c, error.c, misc.c, dosnames.c, fcbfns.c, chario.c, +fattab.c, prf.c, syspack.c, fatfs.c, fatdir.c, time.h, pcb.h, +portab.h, process.h, sft.h, tail.h, fat.h, fcb.h, file.h, fnode.h, +mcb.h, date.h, dcb.h, device.h, dirmatch.h, dosnames.h, clock.h, +error.h, exe.h, kbd.h: +First GPL release. + +30 Jul 1995 patv +dsk.c, memmgr.c, proto.h, strings.c, task.c, blockio.c, misc.c, chario.c, +dosnames.c, error.c, fattab.c, fcbfns.c, prf.c, syspack.c, dosfns.c, +fatdir.c, fatfs.c, mcb.h, pcb.h, portab.h, process.h, sft.h, tail.h, +time.h, date.h, dcb.h, device.h, dirmatch.h, dosnames.h, fat.h, fcb.h, +file.h, fnode.h, clock.h: +Eliminated version strings in ipl + +30 Jul 1995 patv +error.h, kbd.h, exe.h: +Fixed ipl + +30 Jul 1995 patv +boot.asm: +Initialized stack before use. + +05 Jul 1995 patv +asmsupt.asm, proto.h: +Initial revision. + +02 Jul 1995 patv +boot.asm, time.h, tail.h, process.h, sft.h, portab.h, pcb.h, kbd.h, +mcb.h, fnode.h, file.h, fat.h, fcb.h, exe.h, error.h, dirmatch.h, +dosnames.h, dcb.h, device.h, date.h, clock.h, boot/makefile, +procsupt.asm, kernel.asm, execrh.asm, apisupt.asm, task.c, strings.c, +inthndlr.c, main.c, memmgr.c, dsk.c, sysclk.c, systime.c, ioctl.c, +initoem.c, globals.h, makefile, misc.c, error.c, fcbfns.c, dosnames.c, +chario.c, syspack.c, prf.c, fattab.c, fatfs.c, fatdir.c, dosfns.c, +blockio.c, wrpcclk.asm, wratclk.asm, getvec.asm, rdpcclk.asm, +rdatclk.asm, floppy.asm, drivers/makefile: +Initial revision. + +25 May 1993 patv +dirmatch.h: +Initial revision. + diff --git a/drivers/floppy.asm b/drivers/floppy.asm index 9929c5e3..3ce10373 100644 --- a/drivers/floppy.asm +++ b/drivers/floppy.asm @@ -30,7 +30,7 @@ %ifndef SYS %include "..\kernel\segs.inc" - segment HMA_TEXT + segment _TEXT %else segment _TEXT class=CODE %endif diff --git a/drivers/getvec.asm b/drivers/getvec.asm index 153b20ac..0acd3f72 100644 --- a/drivers/getvec.asm +++ b/drivers/getvec.asm @@ -30,7 +30,7 @@ %include "..\kernel\segs.inc" -segment HMA_TEXT +segment _TEXT global _getvec _getvec: diff --git a/drivers/rdatclk.asm b/drivers/rdatclk.asm index 8abd5b77..81c026f3 100644 --- a/drivers/rdatclk.asm +++ b/drivers/rdatclk.asm @@ -32,7 +32,7 @@ %include "..\kernel\segs.inc" -segment HMA_TEXT +segment _TEXT ; ;COUNT ReadATClock(bcdDays, bcdHours, bcdMinutes, bcdSeconds) diff --git a/drivers/rdpcclk.asm b/drivers/rdpcclk.asm index 81ed79e0..e202bec2 100644 --- a/drivers/rdpcclk.asm +++ b/drivers/rdpcclk.asm @@ -30,7 +30,7 @@ %include "..\kernel\segs.inc" -segment HMA_TEXT +segment _TEXT ; ; BOOL ReadPCClock(Ticks) diff --git a/drivers/wratclk.asm b/drivers/wratclk.asm index ab9071b2..d539e7ef 100644 --- a/drivers/wratclk.asm +++ b/drivers/wratclk.asm @@ -30,7 +30,7 @@ %include "..\kernel\segs.inc" -segment HMA_TEXT +segment _TEXT ; ; VOID WriteATClock(bcdDays, bcdHours, bcdMinutes, bcdSeconds) diff --git a/drivers/wrpcclk.asm b/drivers/wrpcclk.asm index 7e6f7354..c7ba2467 100644 --- a/drivers/wrpcclk.asm +++ b/drivers/wrpcclk.asm @@ -29,7 +29,7 @@ ; %include "..\kernel\segs.inc" -segment HMA_TEXT +segment _TEXT ; diff --git a/hdr/buffer.h b/hdr/buffer.h index 0d641ea4..539df2be 100644 --- a/hdr/buffer.h +++ b/hdr/buffer.h @@ -39,26 +39,24 @@ static BYTE *buffer_hRcsId = #define BUFFERSIZE 512 struct buffer { - WORD b_dummy; /* dummy self pointing word to keep MFT from crashing */ - struct buffer - FAR *b_next; /* form linked list for LRU */ + UWORD b_next; /* next buffer in LRU list */ + UWORD b_prev; /* previous buffer in LRU list */ BYTE b_unit; /* disk for this buffer */ BYTE b_flag; /* buffer flags */ ULONG b_blkno; /* block for this buffer */ + UBYTE b_copies; /* number of copies to write */ + UWORD b_offset; /* offset in sectors between copies + to write for FAT sectors */ struct dpb FAR *b_dpbp; /* pointer to DPB */ + UWORD b_remotesz; /* size of remote buffer if remote */ + BYTE b_padding; UBYTE b_buffer[BUFFERSIZE]; /* 512 byte sectors for now */ }; -#define BFR_UNCACHE 0x80 /* indication, not really used */ #define BFR_DIRTY 0x40 /* buffer modified */ #define BFR_VALID 0x20 /* buffer contains valid data */ #define BFR_DATA 0x08 /* buffer is from data area */ #define BFR_DIR 0x04 /* buffer is from dir area */ #define BFR_FAT 0x02 /* buffer is from fat area */ -#define BFR_BOOT 0x01 /* buffer is boot disk */ +#define BFR_UNCACHE 0x01 /* buffer to be released ASAP */ -/* - * Log: buffer.h,v - * Rev 1.0 20 Apr 2001 17:30:00 Bart Oldeman - * Initial revision. - */ diff --git a/hdr/cds.h b/hdr/cds.h index dc88e05d..8f8b7b17 100644 --- a/hdr/cds.h +++ b/hdr/cds.h @@ -94,30 +94,3 @@ struct cds { #define CDS_MODE_SKIP_PHYSICAL 0x01 /* don't resolve SUBST, JOIN, NETW */ #define CDS_MODE_CHECK_DEV_PATH 0x02 /* check for existence of device path */ -/* - * Log: cds.h,v - * Revision 1.2 2000/03/09 06:06:38 kernel - * 2017f updates by James Tabor - * - * Revision 1.1.1.1 1999/03/29 15:39:22 jprice - * New version without IPL.SYS - * - * Revision 1.4 1999/02/01 01:40:06 jprice - * Clean up - * - * Revision 1.3 1999/01/30 08:21:43 jprice - * Clean up - * - * Revision 1.2 1999/01/22 04:17:40 jprice - * Formating - * - * Revision 1.1.1.1 1999/01/20 05:51:01 jprice - * Imported sources - * - - Rev 1.1 04 Jan 1998 23:14:18 patv - Changed Log for strip utility - - Rev 1.0 19 Feb 1996 3:15:52 patv - Added NLS, int2f and config.sys processing - */ diff --git a/hdr/clock.h b/hdr/clock.h index 45cd9964..c8b41db3 100644 --- a/hdr/clock.h +++ b/hdr/clock.h @@ -45,40 +45,3 @@ struct ClockRecord { UBYTE clkSeconds; /* residual seconds. */ }; -/* - * Log: clock.h,v - * - * Revision 1.1.1.1 1999/03/29 15:39:22 jprice - * New version without IPL.SYS - * - * Revision 1.4 1999/02/01 01:40:06 jprice - * Clean up - * - * Revision 1.3 1999/01/30 08:21:43 jprice - * Clean up - * - * Revision 1.2 1999/01/22 04:17:40 jprice - * Formating - * - * Revision 1.1.1.1 1999/01/20 05:51:01 jprice - * Imported sources - * - * - * Rev 1.5 04 Jan 1998 23:14:18 patv - * Changed Log for strip utility - * - * Rev 1.4 29 May 1996 21:25:20 patv - * bug fixes for v0.91a - * - * Rev 1.3 19 Feb 1996 3:15:30 patv - * Added NLS, int2f and config.sys processing - * - * Rev 1.2 01 Sep 1995 17:35:38 patv - * First GPL release. - * - * Rev 1.1 30 Jul 1995 20:43:46 patv - * Eliminated version strings in ipl - * - * Rev 1.0 02 Jul 1995 10:39:26 patv - * Initial revision. - */ diff --git a/hdr/date.h b/hdr/date.h index 03a7d930..4bfa8e78 100644 --- a/hdr/date.h +++ b/hdr/date.h @@ -55,40 +55,3 @@ typedef UWORD date; #endif -/* - * Log: date.h,v - * - * Revision 1.2 1999/08/25 03:17:11 jprice - * ror4 patches to allow TC 2.01 compile. - * - * Revision 1.1.1.1 1999/03/29 15:39:23 jprice - * New version without IPL.SYS - * - * Revision 1.3 1999/02/01 01:40:06 jprice - * Clean up - * - * Revision 1.2 1999/01/22 04:17:40 jprice - * Formating - * - * Revision 1.1.1.1 1999/01/20 05:51:01 jprice - * Imported sources - * - * - * Rev 1.5 04 Jan 1998 23:14:18 patv - * Changed Log for strip utility - * - * Rev 1.4 29 May 1996 21:25:20 patv - * bug fixes for v0.91a - * - * Rev 1.3 19 Feb 1996 3:15:30 patv - * Added NLS, int2f and config.sys processing - * - * Rev 1.2 01 Sep 1995 17:35:40 patv - * First GPL release. - * - * Rev 1.1 30 Jul 1995 20:43:48 patv - * Eliminated version strings in ipl - * - * Rev 1.0 02 Jul 1995 10:39:28 patv - * Initial revision. - */ diff --git a/hdr/dcb.h b/hdr/dcb.h index 23ccfbb9..32031e37 100644 --- a/hdr/dcb.h +++ b/hdr/dcb.h @@ -90,43 +90,3 @@ struct dpb { #define XUNKNCLSTFREE 0xffffffffl /* unknown for DOS */ #define UNKNCLSTFREE 0xffff /* unknown for DOS */ -/* - * Log: dcb.h,v - * - * Revision 1.3 2000/03/09 06:06:38 kernel - * 2017f updates by James Tabor - * - * Revision 1.2 1999/04/16 00:52:09 jprice - * Optimized FAT handling - * - * Revision 1.1.1.1 1999/03/29 15:39:23 jprice - * New version without IPL.SYS - * - * Revision 1.3 1999/02/01 01:40:06 jprice - * Clean up - * - * Revision 1.2 1999/01/22 04:17:40 jprice - * Formating - * - * Revision 1.1.1.1 1999/01/20 05:51:01 jprice - * Imported sources - * - * - * Rev 1.5 04 Jan 1998 23:14:18 patv - * Changed Log for strip utility - * - * Rev 1.4 29 May 1996 21:25:20 patv - * bug fixes for v0.91a - * - * Rev 1.3 19 Feb 1996 3:15:30 patv - * Added NLS, int2f and config.sys processing - * - * Rev 1.2 01 Sep 1995 17:35:40 patv - * First GPL release. - * - * Rev 1.1 30 Jul 1995 20:43:48 patv - * Eliminated version strings in ipl - * - * Rev 1.0 02 Jul 1995 10:39:30 patv - * Initial revision. - */ diff --git a/hdr/device.h b/hdr/device.h index 6a5e7638..a13479bd 100644 --- a/hdr/device.h +++ b/hdr/device.h @@ -476,61 +476,3 @@ WORD ASMCFUNC execrh(request FAR *, struct dhdr FAR *); * end of device.h */ -/* - * Log: device.h,v - * - * Revision 1.4 2000/04/29 05:13:16 jtabor - * Added new functions and clean up code - * - * Revision 1.3 2000/03/09 06:06:38 kernel - * 2017f updates by James Tabor - * - * Revision 1.2 1999/04/04 18:50:14 jprice - * no message - * - * Revision 1.1.1.1 1999/03/29 15:39:26 jprice - * New version without IPL.SYS - * - * Revision 1.5 1999/02/08 05:58:24 jprice - * Added Pat's 1937 kernel patches - * - * Revision 1.4 1999/02/04 03:08:47 jprice - * no message - * - * Revision 1.3 1999/02/01 01:40:06 jprice - * Clean up - * - * Revision 1.2 1999/01/22 04:17:40 jprice - * Formating - * - * Revision 1.1.1.1 1999/01/20 05:51:01 jprice - * Imported sources - * - * - * Rev 1.8 06 Dec 1998 8:41:30 patv - * Changed for new I/O subsystem - * - * Rev 1.7 11 Jan 1998 2:05:54 patv - * Added functionality to ioctl. - * - * Rev 1.6 04 Jan 1998 23:14:20 patv - * Changed Log for strip utility - * - * Rev 1.5 16 Jan 1997 12:46:06 patv - * pre-Release 0.92 feature additions - * - * Rev 1.4 29 May 1996 21:25:12 patv - * bug fixes for v0.91a - * - * Rev 1.3 19 Feb 1996 3:15:30 patv - * Added NLS, int2f and config.sys processing - * - * Rev 1.2 01 Sep 1995 17:35:40 patv - * First GPL release. - * - * Rev 1.1 30 Jul 1995 20:43:48 patv - * Eliminated version strings in ipl - * - * Rev 1.0 02 Jul 1995 10:39:30 patv - * Initial revision. - */ diff --git a/hdr/dirmatch.h b/hdr/dirmatch.h index 7a327237..c5878270 100644 --- a/hdr/dirmatch.h +++ b/hdr/dirmatch.h @@ -67,46 +67,3 @@ typedef struct { BYTE dm_name[FNAME_SIZE + FEXT_SIZE + 2]; /* file name */ } dmatch; -/* - * Log: dirmatch.h,v - * Revision 1.3 2000/03/09 06:06:38 kernel - * 2017f updates by James Tabor - * - * Revision 1.2 1999/08/25 03:17:11 jprice - * ror4 patches to allow TC 2.01 compile. - * - * Revision 1.1.1.1 1999/03/29 15:39:21 jprice - * New version without IPL.SYS - * - * Revision 1.3 1999/02/01 01:40:06 jprice - * Clean up - * - * Revision 1.2 1999/01/22 04:17:40 jprice - * Formating - * - * Revision 1.1.1.1 1999/01/20 05:51:01 jprice - * Imported sources - * - * - * Rev 1.5 04 Jan 1998 23:14:16 patv - * Changed Log for strip utility - * - * Rev 1.4 29 May 1996 21:25:18 patv - * bug fixes for v0.91a - * - * Rev 1.3 19 Feb 1996 3:15:34 patv - * Added NLS, int2f and config.sys processing - * - * Rev 1.2 01 Sep 1995 17:35:40 patv - * First GPL release. - * - * Rev 1.1 30 Jul 1995 20:43:48 patv - * Eliminated version strings in ipl - * - * Rev 1.0 02 Jul 1995 10:39:34 patv - * Initial revision. - * - * Rev 1.0 25 May 1993 23:30:26 patv - * Initial revision. - * - */ diff --git a/hdr/dosnames.h b/hdr/dosnames.h index e06cc622..aa975c1e 100644 --- a/hdr/dosnames.h +++ b/hdr/dosnames.h @@ -44,36 +44,3 @@ struct dosnames { UBYTE dn_name[FNAME_SIZE + FEXT_SIZE + 1]; /* the file name */ }; -/* - * Log: dosnames.h,v - * Revision 1.2 2000/05/08 04:28:22 jimtabor - * Update CVS to 2020 - * - * Revision 1.1.1.1 1999/03/29 15:39:27 jprice - * New version without IPL.SYS - * - * Revision 1.3 1999/02/01 01:40:06 jprice - * Clean up - * - * Revision 1.2 1999/01/22 04:17:40 jprice - * Formating - * - * Revision 1.1.1.1 1999/01/20 05:51:01 jprice - * Imported sources - * - * - * Rev 1.4 29 May 1996 21:25:14 patv - * bug fixes for v0.91a - * - * Rev 1.3 19 Feb 1996 3:15:30 patv - * Added NLS, int2f and config.sys processing - * - * Rev 1.2 01 Sep 1995 17:35:40 patv - * First GPL release. - * - * Rev 1.1 30 Jul 1995 20:43:48 patv - * Eliminated version strings in ipl - * - * Rev 1.0 02 Jul 1995 10:39:34 patv - * Initial revision. - */ diff --git a/hdr/error.h b/hdr/error.h index 984df3f8..1aba1b0f 100644 --- a/hdr/error.h +++ b/hdr/error.h @@ -86,46 +86,3 @@ static BYTE *error_hRcsId = #define ABORT 2 #define FAIL 3 -/* - * Log: error.h,v - * - * Revision 1.1.1.1 1999/03/29 15:39:27 jprice - * New version without IPL.SYS - * - * Revision 1.5 1999/02/08 05:58:24 jprice - * Added Pat's 1937 kernel patches - * - * Revision 1.4 1999/02/01 01:40:06 jprice - * Clean up - * - * Revision 1.3 1999/01/30 08:21:43 jprice - * Clean up - * - * Revision 1.2 1999/01/22 04:17:40 jprice - * Formating - * - * Revision 1.1.1.1 1999/01/20 05:51:01 jprice - * Imported sources - * - * - * Rev 1.6 06 Dec 1998 8:41:00 patv - * Added new errors for new I/O subsystem. - * - * Rev 1.5 04 Jan 1998 23:14:16 patv - * Changed Log for strip utility - * - * Rev 1.4 29 May 1996 21:25:18 patv - * bug fixes for v0.91a - * - * Rev 1.3 19 Feb 1996 3:15:28 patv - * Added NLS, int2f and config.sys processing - * - * Rev 1.2 01 Sep 1995 17:35:38 patv - * First GPL release. - * - * Rev 1.1 30 Jul 1995 20:42:28 patv - * fixed ipl - * - * Rev 1.0 02 Jul 1995 10:39:36 patv - * Initial revision. - */ diff --git a/hdr/exe.h b/hdr/exe.h index 8d236201..cc434b26 100644 --- a/hdr/exe.h +++ b/hdr/exe.h @@ -55,37 +55,3 @@ typedef struct { #define MAGIC 0x5a4d #define OLD_MAGIC 0x4d5a -/* - * Log: exe.h,v - * - * Revision 1.1.1.1 1999/03/29 15:39:28 jprice - * New version without IPL.SYS - * - * Revision 1.3 1999/02/01 01:40:06 jprice - * Clean up - * - * Revision 1.2 1999/01/22 04:17:40 jprice - * Formating - * - * Revision 1.1.1.1 1999/01/20 05:51:01 jprice - * Imported sources - * - * - * Rev 1.5 04 Jan 1998 23:14:16 patv - * Changed Log for strip utility - * - * Rev 1.4 29 May 1996 21:25:18 patv - * bug fixes for v0.91a - * - * Rev 1.3 19 Feb 1996 3:15:34 patv - * Added NLS, int2f and config.sys processing - * - * Rev 1.2 01 Sep 1995 17:35:38 patv - * First GPL release. - * - * Rev 1.1 30 Jul 1995 20:41:56 patv - * Fixed ipl - * - * Rev 1.0 02 Jul 1995 10:39:38 patv - * Initial revision. - */ diff --git a/hdr/fat.h b/hdr/fat.h index 4f4fabaf..7286ac6e 100644 --- a/hdr/fat.h +++ b/hdr/fat.h @@ -65,9 +65,29 @@ static BYTE *fat_hRcsId = /* Test for 16 bit or 12 bit FAT */ #define SIZEOF_CLST16 2 #define SIZEOF_CLST32 4 -#define FAT_MAGIC 4086 -#define FAT_MAGIC16 ((unsigned)65526l) -#define FAT_MAGIC32 268435456l + +/* FAT cluster special flags */ +#define FREE 0x000 + +#ifdef WITHFAT32 +#define LONG_LAST_CLUSTER 0x0FFFFFFFl +#define LONG_BAD 0x0FFFFFF7l +#else +#define LONG_LAST_CLUSTER 0xFFFF +#define LONG_BAD 0xFFF7 +#endif +#define MASK16 0xFFF8 +#define BAD16 0xFFF7 +#define MASK12 0xFF8 +#define BAD12 0xFF7 + +/* magic constants: even though FF7 is BAD so FF6 could be a valid cluster + no., MS docs specify that FF5 is the maximal possible cluster number + for FAT12; similar for 16 and 32 */ + +#define FAT_MAGIC 4085 +#define FAT_MAGIC16 ((unsigned)65525l) +#define FAT_MAGIC32 268435455l /* int ISFAT32(struct dpb FAR *dpbp);*/ #define ISFAT32(x) _ISFAT32(x) @@ -77,6 +97,7 @@ static BYTE *fat_hRcsId = */ #define _ISFAT32(dpbp) (((dpbp)->dpb_fatsize)==0) #define ISFAT16(dpbp) (((dpbp)->dpb_size)>FAT_MAGIC && ((dpbp)->dpb_size)<=FAT_MAGIC16 ) +#define ELSE_ISFAT16(dpbp) (((dpbp)->dpb_size)<=FAT_MAGIC16 ) #define ISFAT12(dpbp) ((((dpbp)->dpb_size)-1)b_next))) +#define b_prev(bp) ((struct buffer FAR *)(MK_FP(FP_SEG(bp), bp->b_prev))) +#define bufptr(fbp) ((struct buffer FAR *)(MK_FP(FP_SEG(bp), fbp))) + /************************************************************************/ /* */ /* block cache routines */ @@ -45,71 +49,43 @@ static BYTE *blockioRcsId = STATIC BOOL flush1(struct buffer FAR * bp); -/* */ -/* Initialize the buffer structure */ -/* */ - -/* Extract the block number from a buffer structure. */ - -#if 0 /*TE*/ -STATIC ULONG getblkno(struct buffer FAR * bp) -{ - if (bp->b_blkno == 0xffffu) - return bp->b_huge_blkno; - else - return bp->b_blkno; -} -#else -#define getblkno(bp) (bp)->b_blkno -#endif - -/* Set the block number of a buffer structure. (The caller should */ -/* set the unit number before calling this function.) */ -#if 0 /*TE*/ -STATIC VOID setblkno(struct buffer FAR * bp, ULONG blkno) -{ - if (blkno >= 0xffffu) - { - bp->b_blkno = 0xffffu; - bp->b_huge_blkno = blkno; - } - else - { - bp->b_blkno = blkno; -/* bp->b_dpbp = &blk_devices[bp->b_unit]; */ - - bp->b_dpbp = get_cds(bp->b_unit)->cdsDpb; - - } -} -#else -#define setblkno(bp, blkno) (bp)->b_blkno = (blkno) -#endif - /* this searches the buffer list for the given disk/block. returns: - TRUE: - the buffer is found - FALSE: - the buffer is not found - *Buffp contains a block to flush and reuse later + a far pointer to the buffer. + + If the buffer is found the UNCACHE bit is not set and else it is set. new: upper layer may set UNCACHE attribute UNCACHE buffers are recycled first. - intended to be used for full sector reads into application buffer - + intended to be used for full sector reads into application buffer + resets UNCACHE upon a "HIT" -- so then this buffer will not be + recycled anymore. */ -STATIC BOOL searchblock(ULONG blkno, COUNT dsk, struct buffer FAR ** pBuffp) +STATIC void move_buffer(struct buffer FAR *bp, size_t firstbp) +{ + /* connect bp->b_prev and bp->b_next */ + b_next(bp)->b_prev = bp->b_prev; + b_prev(bp)->b_next = bp->b_next; + + /* insert bp between firstbp and firstbp->b_prev */ + bp->b_prev = bufptr(firstbp)->b_prev; + bp->b_next = firstbp; + b_next(bp)->b_prev = FP_OFF(bp); + b_prev(bp)->b_next = FP_OFF(bp); +} + +STATIC struct buffer FAR *searchblock(ULONG blkno, COUNT dsk) { int fat_count = 0; struct buffer FAR *bp; - struct buffer FAR *lbp = NULL; - struct buffer FAR *lastNonFat = NULL; - struct buffer FAR *uncacheBuf = NULL; + size_t lastNonFat = 0; + size_t uncacheBuf = 0; + seg bufseg = FP_SEG(firstbuf); + size_t firstbp = FP_OFF(firstbuf); #ifdef DISPLAY_GETBLOCK printf("[searchblock %d, blk %ld, buf ", dsk, blkno); @@ -118,33 +94,34 @@ STATIC BOOL searchblock(ULONG blkno, COUNT dsk, struct buffer FAR ** pBuffp) /* Search through buffers to see if the required block */ /* is already in a buffer */ - for (bp = firstbuf; bp != NULL; lbp = bp, bp = bp->b_next) + bp = MK_FP(bufseg, firstbp); + do { - if ((getblkno(bp) == blkno) && + if ((bp->b_blkno == blkno) && (bp->b_flag & BFR_VALID) && (bp->b_unit == dsk)) { /* found it -- rearrange LRU links */ - if (lbp != NULL) - { - lbp->b_next = bp->b_next; - bp->b_next = firstbuf; - firstbuf = bp; - } #ifdef DISPLAY_GETBLOCK printf("HIT %04x:%04x]\n", FP_SEG(bp), FP_OFF(bp)); #endif - *pBuffp = bp; - return TRUE; + bp->b_flag &= ~BFR_UNCACHE; /* reset uncache attribute */ + if (FP_OFF(bp) != firstbp) + { + *(UWORD *)&firstbuf = FP_OFF(bp); + move_buffer(bp, firstbp); + } + return bp; } if (bp->b_flag & BFR_UNCACHE) - uncacheBuf = bp; + uncacheBuf = FP_OFF(bp); if (bp->b_flag & BFR_FAT) fat_count++; else - lastNonFat = bp; - } + lastNonFat = FP_OFF(bp); + bp = b_next(bp); + } while (FP_OFF(bp) != firstbp); /* now take either the last buffer in chain (not used recently) @@ -153,52 +130,49 @@ STATIC BOOL searchblock(ULONG blkno, COUNT dsk, struct buffer FAR ** pBuffp) if (uncacheBuf) { - lbp = uncacheBuf; + bp = bufptr(uncacheBuf); + } + else if (bp->b_flag & BFR_FAT && fat_count < 3 && lastNonFat) + { + bp = bufptr(lastNonFat); } else { - if (lbp->b_flag & BFR_FAT && fat_count < 3 && lastNonFat) - { - lbp = lastNonFat; - } + bp = b_prev(bufptr(firstbp)); } - lbp->b_flag &= ~BFR_UNCACHE; /* reset uncache attribute */ - - *pBuffp = lbp; + bp->b_flag |= BFR_UNCACHE; /* set uncache attribute */ #ifdef DISPLAY_GETBLOCK - printf("MISS, replace %04x:%04x]\n", FP_SEG(lbp), FP_OFF(lbp)); + printf("MISS, replace %04x:%04x]\n", FP_SEG(bp), FP_OFF(bp)); #endif - if (lbp != firstbuf) /* move to front */ + if (FP_OFF(bp) != firstbp) /* move to front */ { - for (bp = firstbuf; bp->b_next != lbp; bp = bp->b_next) - ; - bp->b_next = bp->b_next->b_next; - lbp->b_next = firstbuf; - firstbuf = lbp; + move_buffer(bp, firstbp); + *(UWORD *)&firstbuf = FP_OFF(bp); } - - return FALSE; + return bp; } BOOL DeleteBlockInBufferCache(ULONG blknolow, ULONG blknohigh, COUNT dsk) { - struct buffer FAR *bp; - + struct buffer FAR *bp = firstbuf; + /* Search through buffers to see if the required block */ /* is already in a buffer */ - for (bp = firstbuf; bp != NULL; bp = bp->b_next) + do { - if (blknolow <= getblkno(bp) && - getblkno(bp) <= blknohigh && + if (blknolow <= bp->b_blkno && + bp->b_blkno <= blknohigh && (bp->b_flag & BFR_VALID) && (bp->b_unit == dsk)) { flush1(bp); } + bp = b_next(bp); } + while (FP_OFF(bp) != FP_OFF(firstbuf)); return FALSE; } @@ -206,40 +180,43 @@ BOOL DeleteBlockInBufferCache(ULONG blknolow, ULONG blknohigh, COUNT dsk) #if TOM void dumpBufferCache(void) { - struct buffer FAR *bp; + struct buffer FAR *bp = firstbuf; int printed = 0; /* Search through buffers to see if the required block */ /* is already in a buffer */ - for (bp = firstbuf; bp != NULL; bp = bp->b_next) + do { - printf("%8lx %02x ", getblkno(bp), bp->b_flag); + printf("%8lx %02x ", bp->b_blkno, bp->b_flag); if (++printed % 6 == 0) printf("\n"); + bp = b_next(bp); } + while (FP_OFF(bp) != FP_OFF(firstbuf)); printf("\n"); } #endif /* */ /* Return the address of a buffer structure containing the */ /* requested block. */ +/* if overwrite is set, then no need to read first */ /* */ /* returns: */ /* requested block with data */ /* failure: */ /* returns NULL */ /* */ -struct buffer FAR *getblock(ULONG blkno, COUNT dsk) +struct buffer FAR *getblk(ULONG blkno, COUNT dsk, BOOL overwrite) { - struct buffer FAR *bp; - /* Search through buffers to see if the required block */ /* is already in a buffer */ - if (searchblock(blkno, dsk, &bp)) + struct buffer FAR *bp = searchblock(blkno, dsk); + + if (!(bp->b_flag & BFR_UNCACHE)) { - return (bp); + return bp; } /* The block we need is not in a buffer, we must make a buffer */ @@ -251,51 +228,16 @@ struct buffer FAR *getblock(ULONG blkno, COUNT dsk) /* Fill the indicated disk buffer with the current track and sector */ - if (dskxfer(dsk, blkno, (VOID FAR *) bp->b_buffer, 1, DSKREAD)) + if (!overwrite && dskxfer(dsk, blkno, bp->b_buffer, 1, DSKREAD)) { return NULL; } bp->b_flag = BFR_VALID | BFR_DATA; bp->b_unit = dsk; - setblkno(bp, blkno); + bp->b_blkno = blkno; return bp; - -} - -/* - exactly the same as getblock(), but the data will be completely - overwritten. so there is no need to read from disk first - */ -struct buffer FAR *getblockOver(ULONG blkno, COUNT dsk) -{ - struct buffer FAR *bp; - - /* Search through buffers to see if the required block */ - /* is already in a buffer */ - - if (searchblock(blkno, dsk, &bp)) - { - return bp; - } - - /* The block we need is not in a buffer, we must make a buffer */ - /* available. */ - - /* take the buffer than lbp points to and flush it, then make it available. */ - if (flush1(bp)) /* success */ - { - bp->b_flag = 0; - bp->b_unit = dsk; - setblkno(bp, blkno); - return bp; - } - else - /* failure */ - { - return NULL; - } } /* */ @@ -303,15 +245,15 @@ struct buffer FAR *getblockOver(ULONG blkno, COUNT dsk) /* */ VOID setinvld(REG COUNT dsk) { - REG struct buffer FAR *bp; + struct buffer FAR *bp = firstbuf; - bp = firstbuf; - while (bp) + do { if (bp->b_unit == dsk) bp->b_flag = 0; - bp = bp->b_next; + bp = b_next(bp); } + while (FP_OFF(bp) != FP_OFF(firstbuf)); } /* */ @@ -322,17 +264,18 @@ VOID setinvld(REG COUNT dsk) /* */ BOOL flush_buffers(REG COUNT dsk) { - REG struct buffer FAR *bp; + struct buffer FAR *bp = firstbuf; REG BOOL ok = TRUE; bp = firstbuf; - while (bp) + do { if (bp->b_unit == dsk) if (!flush1(bp)) ok = FALSE; - bp = bp->b_next; + bp = b_next(bp); } + while (FP_OFF(bp) != FP_OFF(firstbuf)); return ok; } @@ -347,25 +290,24 @@ STATIC BOOL flush1(struct buffer FAR * bp) if ((bp->b_flag & BFR_VALID) && (bp->b_flag & BFR_DIRTY)) { - result = dskxfer(bp->b_unit, getblkno(bp), (VOID FAR *) bp->b_buffer, 1, DSKWRITE); /* BER 9/4/00 */ + /* BER 9/4/00 */ + result = dskxfer(bp->b_unit, bp->b_blkno, bp->b_buffer, 1, DSKWRITE); if (bp->b_flag & BFR_FAT) { - struct dpb FAR *dpbp = bp->b_dpbp; - UWORD b_copies = dpbp->dpb_fats; - ULONG b_offset = dpbp->dpb_fatsize; - ULONG blkno = getblkno(bp); + UWORD b_copies = bp->b_copies; + ULONG blkno = bp->b_blkno; #ifdef WITHFAT32 - if (ISFAT32(dpbp)) - { - if (dpbp->dpb_xflags & FAT_NO_MIRRORING) - b_copies = 1; - b_offset = dpbp->dpb_xfatsize; - } + ULONG b_offset = bp->b_offset; + if (b_offset == 0) /* FAT32 FS */ + b_offset = bp->b_dpbp->dpb_xfatsize; +#else + UWORD b_offset = bp->b_offset; #endif while (--b_copies > 0) { blkno += b_offset; - result = dskxfer(bp->b_unit, blkno, bp->b_buffer, 1, DSKWRITE); /* BER 9/4/00 */ + /* BER 9/4/00 */ + result = dskxfer(bp->b_unit, blkno, bp->b_buffer, 1, DSKWRITE); } } } @@ -384,18 +326,18 @@ STATIC BOOL flush1(struct buffer FAR * bp) /* */ BOOL flush(void) { - REG struct buffer FAR *bp; + REG struct buffer FAR *bp = firstbuf; REG BOOL ok; ok = TRUE; - bp = firstbuf; - while (bp) + do { if (!flush1(bp)) ok = FALSE; bp->b_flag &= ~BFR_VALID; - bp = bp->b_next; + bp = b_next(bp); } + while (FP_OFF(bp) != FP_OFF(firstbuf)); remote_flushall(); @@ -508,98 +450,29 @@ UWORD dskxfer(COUNT dsk, ULONG blkno, VOID FAR * buf, UWORD numblocks, } /* - * 2000/9/04 Brian Reifsnyder - * Modified dskxfer() such that error codes are now returned. - * Functions that rely on dskxfer() have also been modified accordingly. - */ + this removes any (additionally allocated) buffers + from the HMA buffer chain, because they get allocated to the 'user' +*/ + +void AllocateHMASpace (size_t lowbuffer, size_t highbuffer) +{ + REG struct buffer FAR *bp = firstbuf; + int n = LoL_nbuffers; -/* - * Log: blockio.c,v - for newer entries do "cvs log blockio.c" - * - * Revision 1.15 2000/04/29 05:13:16 jtabor - * Added new functions and clean up code - * - * Revision 1.14 2000/03/09 06:07:10 kernel - * 2017f updates by James Tabor - * - * Revision 1.13 1999/08/25 03:18:07 jprice - * ror4 patches to allow TC 2.01 compile. - * - * Revision 1.12 1999/08/10 18:03:39 jprice - * ror4 2011-03 patch - * - * Revision 1.11 1999/05/03 06:25:45 jprice - * Patches from ror4 and many changed of signed to unsigned variables. - * - * Revision 1.10 1999/05/03 04:55:35 jprice - * Changed getblock & getbuf so that they leave at least 3 buffer for FAT data. - * - * Revision 1.9 1999/04/21 01:44:40 jprice - * no message - * - * Revision 1.8 1999/04/18 05:28:39 jprice - * no message - * - * Revision 1.7 1999/04/16 21:43:40 jprice - * ror4 multi-sector IO - * - * Revision 1.6 1999/04/16 00:53:32 jprice - * Optimized FAT handling - * - * Revision 1.5 1999/04/12 23:41:53 jprice - * Using getbuf to write data instead of getblock - * using getblock made it read the block before it wrote it - * - * Revision 1.4 1999/04/11 05:28:10 jprice - * Working on multi-block IO - * - * Revision 1.3 1999/04/11 04:33:38 jprice - * ror4 patches - * - * Revision 1.1.1.1 1999/03/29 15:41:43 jprice - * New version without IPL.SYS - * - * Revision 1.5 1999/02/09 02:54:23 jprice - * Added Pat's 1937 kernel patches - * - * Revision 1.4 1999/02/01 01:43:27 jprice - * Fixed findfirst function to find volume label with Windows long filenames - * - * Revision 1.3 1999/01/30 08:25:34 jprice - * Clean up; Fixed bug with set attribute function. If you tried to - * change the attributes of a directory, it would erase it. - * - * Revision 1.2 1999/01/22 04:15:28 jprice - * Formating - * - * Revision 1.1.1.1 1999/01/20 05:51:00 jprice - * Imported sources - * - * - * Rev 1.8 06 Dec 1998 8:43:16 patv - * Changes in block I/O because of new I/O subsystem. - * - * Rev 1.7 22 Jan 1998 4:09:00 patv - * Fixed pointer problems affecting SDA - * - * Rev 1.6 04 Jan 1998 23:14:36 patv - * Changed Log for strip utility - * - * Rev 1.5 03 Jan 1998 8:36:02 patv - * Converted data area to SDA format - * - * Rev 1.4 16 Jan 1997 12:46:34 patv - * pre-Release 0.92 feature additions - * - * Rev 1.3 29 May 1996 21:15:10 patv - * bug fixes for v0.91a - * - * Rev 1.2 01 Sep 1995 17:48:46 patv - * First GPL release. - * - * Rev 1.1 30 Jul 1995 20:50:28 patv - * Eliminated version strings in ipl - * - * Rev 1.0 02 Jul 1995 8:04:06 patv - * Initial revision. - */ + do + { + if (FP_OFF(bp) < highbuffer && FP_OFF(bp+1) >= lowbuffer) + { + flush1(bp); + /* unlink bp from buffer chain */ + + b_prev(bp)->b_next = bp->b_next; + b_next(bp)->b_prev = bp->b_prev; + if (bp == firstbuf) + firstbuf = b_next(bp); + LoL_nbuffers--; + } + bp = b_next(bp); + } + while (n--); +} diff --git a/kernel/break.c b/kernel/break.c index 1cbcb066..b02c02a3 100644 --- a/kernel/break.c +++ b/kernel/break.c @@ -73,13 +73,3 @@ void handle_break(int sft_idx) spawn_int23(); /* invoke user INT-23 and never come back */ } -/* - * Log: break.c,v - for newer entries see "cvs log break.c" - * - * Revision 1.2 2000/03/09 06:07:10 kernel - * 2017f updates by James Tabor - * - * Revision 1.1 1999/04/16 21:18:17 jprice - * Steffen contributed. - * - */ diff --git a/kernel/chario.c b/kernel/chario.c index ae3bef51..2d7ec4b5 100644 --- a/kernel/chario.c +++ b/kernel/chario.c @@ -542,71 +542,3 @@ size_t read_line_handle(int sft_idx, size_t n, char FAR * bp) return n; } -/* - * Log: chario.c,v - for newer logs do "cvs log chario.c" - * - * Revision 1.7 2000/03/09 06:07:10 kernel - * 2017f updates by James Tabor - * - * Revision 1.6 1999/09/23 04:40:45 jprice - * *** empty log message *** - * - * Revision 1.4 1999/08/25 03:18:07 jprice - * ror4 patches to allow TC 2.01 compile. - * - * Revision 1.3 1999/04/16 12:21:21 jprice - * Steffen c-break handler changes - * - * Revision 1.2 1999/04/04 18:51:42 jprice - * no message - * - * Revision 1.1.1.1 1999/03/29 15:41:45 jprice - * New version without IPL.SYS - * - * Revision 1.5 1999/02/09 02:54:23 jprice - * Added Pat's 1937 kernel patches - * - * Revision 1.4 1999/02/04 03:18:37 jprice - * Formating. Added comments. - * - * Revision 1.3 1999/02/01 01:43:28 jprice - * Fixed findfirst function to find volume label with Windows long filenames - * - * Revision 1.2 1999/01/22 04:15:28 jprice - * Formating - * - * Revision 1.1.1.1 1999/01/20 05:51:00 jprice - * Imported sources - * - * - * Rev 1.9 06 Dec 1998 8:43:36 patv - * changes in character I/O because of new I/O subsystem. - * - * Rev 1.8 11 Jan 1998 2:06:08 patv - * Added functionality to ioctl. - * - * Rev 1.7 08 Jan 1998 21:36:40 patv - * Changed automatic requestic packets to static to save stack space. - * - * Rev 1.6 04 Jan 1998 23:14:38 patv - * Changed Log for strip utility - * - * Rev 1.5 30 Dec 1997 4:00:20 patv - * Modified to support SDA - * - * Rev 1.4 16 Jan 1997 12:46:36 patv - * pre-Release 0.92 feature additions - * - * Rev 1.3 29 May 1996 21:15:12 patv - * bug fixes for v0.91a - * - * Rev 1.2 01 Sep 1995 17:48:42 patv - * First GPL release. - * - * Rev 1.1 30 Jul 1995 20:50:26 patv - * Eliminated version strings in ipl - * - * Rev 1.0 02 Jul 1995 8:05:44 patv - * Initial revision. - * - */ diff --git a/kernel/config.c b/kernel/config.c index 8bf58731..9fb644b6 100644 --- a/kernel/config.c +++ b/kernel/config.c @@ -67,7 +67,7 @@ extern struct dhdr DOSTEXTFAR ASM blk_dev, /* Block device (Disk) driver */ DOSFAR ASM nul_dev; extern struct buffer FAR *DOSFAR ASM firstbuf; /* head of buffers linked list */ - +extern struct buffer FAR *DOSFAR firstAvailableBuf; /* first 'available' buffer */ extern struct dpb FAR *DOSFAR ASM DPBp; /* First drive Parameter Block */ extern struct cds FAR *DOSFAR ASM CDSp; @@ -1511,14 +1511,16 @@ VOID config_init_buffers(COUNT anzBuffers) { REG WORD i; struct buffer FAR *pbuffer; - int HMAcount = 0; BYTE FAR *tmplpBase = lpBase; - BOOL fillhma = TRUE; + unsigned wantedbuffers = anzBuffers; if (anzBuffers < 0) { - anzBuffers = -anzBuffers; - fillhma = FALSE; + wantedbuffers = anzBuffers = -anzBuffers; + } + else if (HMAState == HMA_DONE) + { + anzBuffers = (0xfff0 - HMAFree) / sizeof(struct buffer); } anzBuffers = max(anzBuffers, 6); @@ -1528,63 +1530,42 @@ VOID config_init_buffers(COUNT anzBuffers) anzBuffers = 99; } LoL_nbuffers = anzBuffers; - + lpTop = lpOldTop; if (HMAState == HMA_NONE || HMAState == HMA_REQ) - lpTop = lpBase = lpTop - anzBuffers * (sizeof(struct buffer) + 0xf); - - firstbuf = ConfigAlloc(sizeof(struct buffer)); - + lpTop = lpBase = lpTop - (anzBuffers * sizeof(struct buffer) + 0xf); + + firstbuf = ConfigAlloc(sizeof(struct buffer) * anzBuffers); pbuffer = firstbuf; DebugPrintf(("init_buffers (size %u) at", sizeof(struct buffer))); + DebugPrintf((" (%p)", firstbuf)); - for (i = 0;; ++i) + pbuffer->b_prev = FP_OFF(pbuffer + (anzBuffers-1)); + for (i = 1; i < anzBuffers; ++i) { - if (FP_SEG(pbuffer) == 0xffff) - HMAcount++; - - pbuffer->b_dummy = FP_OFF(pbuffer); - pbuffer->b_unit = 0; - pbuffer->b_flag = 0; - pbuffer->b_blkno = 0; - pbuffer->b_next = NULL; - - DebugPrintf((" (%d,%p)", i, pbuffer)); + if (i == wantedbuffers) + { + firstAvailableBuf = pbuffer; + } + pbuffer->b_next = FP_OFF(pbuffer + 1); + pbuffer++; + pbuffer->b_prev = FP_OFF(pbuffer - 1); + } + pbuffer->b_next = FP_OFF(pbuffer - (anzBuffers-1)); /* now, we can have quite some buffers in HMA - -- up to 37 for KE38616. + -- up to 50 for KE38616. so we fill the HMA with buffers but not if the BUFFERS count is negative ;-) */ - if (i < (anzBuffers - 1)) - { - pbuffer->b_next = HMAalloc(sizeof(struct buffer)); - - if (pbuffer->b_next == NULL) - { - /* if more buffer requested then fit into HMA, allocate - some from low memory as rewuested - */ - pbuffer->b_next = ConfigAlloc(sizeof(struct buffer)); - } - } - else if (fillhma) - pbuffer->b_next = HMAalloc(sizeof(struct buffer)); - - if (pbuffer->b_next == NULL) - break; - - pbuffer = pbuffer->b_next; - } - DebugPrintf((" done\n")); - if (HMAcount) + if (FP_SEG(pbuffer) == 0xffff) printf("Kernel: allocated %d Diskbuffers = %u Bytes in HMA\n", - HMAcount, HMAcount * sizeof(struct buffer)); + anzBuffers, anzBuffers * sizeof(struct buffer)); if (HMAState == HMA_NONE || HMAState == HMA_REQ) lpBase = tmplpBase; @@ -1711,82 +1692,3 @@ STATIC VOID CfgMenuDefault(BYTE * pLine) } -/* - * Log: config.c,v - for newer log entries see "cvs log config.c" - * - * Revision 1.15 2000/03/31 05:40:09 jtabor - * Added Eric W. Biederman Patches - * - * Revision 1.14 2000/03/17 22:59:04 kernel - * Steffen Kaiser's NLS changes - * - * Revision 1.13 2000/03/09 06:07:10 kernel - * 2017f updates by James Tabor - * - * Revision 1.12 1999/09/23 04:40:46 jprice - * *** empty log message *** - * - * Revision 1.10 1999/08/25 03:18:07 jprice - * ror4 patches to allow TC 2.01 compile. - * - * Revision 1.9 1999/05/03 06:25:45 jprice - * Patches from ror4 and many changed of signed to unsigned variables. - * - * Revision 1.8 1999/04/16 21:43:40 jprice - * ror4 multi-sector IO - * - * Revision 1.7 1999/04/16 12:21:21 jprice - * Steffen c-break handler changes - * - * Revision 1.6 1999/04/16 00:53:32 jprice - * Optimized FAT handling - * - * Revision 1.5 1999/04/12 03:21:17 jprice - * more ror4 patches. Changes for multi-block IO - * - * Revision 1.4 1999/04/11 04:33:38 jprice - * ror4 patches - * - * Revision 1.2 1999/04/04 22:57:47 jprice - * no message - * - * Revision 1.1.1.1 1999/03/29 15:40:46 jprice - * New version without IPL.SYS - * - * Revision 1.6 1999/03/23 23:38:15 jprice - * Now checks for a reads fdconfig.sys file, if exists - * - * Revision 1.5 1999/02/08 05:55:57 jprice - * Added Pat's 1937 kernel patches - * - * Revision 1.4 1999/02/01 01:48:41 jprice - * Clean up; Now you can use hex numbers in config.sys. added config.sys screen function to change screen mode (28 or 43/50 lines) - * - * Revision 1.3 1999/01/30 08:28:11 jprice - * Clean up; Fixed bug with set attribute function. - * - * Revision 1.2 1999/01/22 04:13:25 jprice - * Formating - * - * Revision 1.1.1.1 1999/01/20 05:51:01 jprice - * Imported sources - * - * - * Rev 1.6 22 Jan 1998 4:09:24 patv - * Fixed pointer problems affecting SDA - * - * Rev 1.5 04 Jan 1998 23:15:18 patv - * Changed Log for strip utility - * - * Rev 1.4 04 Jan 1998 17:26:14 patv - * Corrected subdirectory bug - * - * Rev 1.3 16 Jan 1997 12:46:50 patv - * pre-Release 0.92 feature additions - * - * Rev 1.1 29 May 1996 21:03:44 patv - * bug fixes for v0.91a - * - * Rev 1.0 19 Feb 1996 3:22:16 patv - * Added NLS, int2f and config.sys processing - */ diff --git a/kernel/console.asm b/kernel/console.asm index 93e41267..234f1961 100644 --- a/kernel/console.asm +++ b/kernel/console.asm @@ -50,7 +50,7 @@ ConTable db 0Ah PRT_SCREEN equ 7200h CTL_P equ 10h -segment _TEXT +segment _LOWTEXT uScanCode db 0 ; Scan code for con: device @@ -246,32 +246,3 @@ ConCharReady: ConNoChar: jmp _IODone ; no key ready (busy=1) - -; Log: console.asm,v -; -; Revision 1.8 2000/03/09 06:07:10 kernel -; 2017f updates by James Tabor -; -; Revision 1.7 1999/09/23 04:40:46 jprice -; *** empty log message *** -; -; Revision 1.5 1999/09/14 16:31:38 jprice -; no message -; -; Revision 1.4 1999/09/13 22:16:14 jprice -; Fix 210B function -; -; Revision 1.3 1999/09/13 21:00:19 jprice -; Changes from Helmut Fritsch to fix INT21 func B -; -; Revision 1.2 1999/08/10 17:57:12 jprice -; ror4 2011-02 patch -; -; Revision 1.1.1.1 1999/03/29 15:40:47 jprice -; New version without IPL.SYS -; -; Revision 1.1 1999/02/08 05:55:57 jprice -; Added Pat's 1937 kernel patches -; -; EndLog -; diff --git a/kernel/dosfns.c b/kernel/dosfns.c index a08d22ea..09a480f5 100644 --- a/kernel/dosfns.c +++ b/kernel/dosfns.c @@ -1552,91 +1552,3 @@ COUNT DosTruename(const char FAR *src, char FAR *dest) return rc; } - -/* - * - * /// Added SHARE support. 2000/09/04 Ron Cemer - * - * Log: dosfns.c,v - for newer log entries do a "cvs log dosfns.c" - * - * Revision 1.14 2000/04/02 05:01:08 jtabor - * Replaced ChgDir Code - * - * Revision 1.13 2000/04/02 04:53:56 jtabor - * Fix to DosChgDir - * - * Revision 1.12 2000/03/31 05:40:09 jtabor - * Added Eric W. Biederman Patches - * - * Revision 1.11 2000/03/09 06:07:11 kernel - * 2017f updates by James Tabor - * - * Revision 1.10 1999/09/23 04:40:46 jprice - * *** empty log message *** - * - * Revision 1.8 1999/09/14 01:01:53 jprice - * Fixed bug where you could write over directories. - * - * Revision 1.7 1999/08/25 03:18:07 jprice - * ror4 patches to allow TC 2.01 compile. - * - * Revision 1.6 1999/05/03 06:25:45 jprice - * Patches from ror4 and many changed of signed to unsigned variables. - * - * Revision 1.5 1999/04/16 12:21:22 jprice - * Steffen c-break handler changes - * - * Revision 1.4 1999/04/12 03:21:17 jprice - * more ror4 patches. Changes for multi-block IO - * - * Revision 1.3 1999/04/11 04:33:38 jprice - * ror4 patches - * - * Revision 1.2 1999/04/04 18:51:43 jprice - * no message - * - * Revision 1.1.1.1 1999/03/29 15:41:52 jprice - * New version without IPL.SYS - * - * Revision 1.4 1999/02/09 02:54:23 jprice - * Added Pat's 1937 kernel patches - * - * Revision 1.3 1999/02/01 01:43:28 jprice - * Fixed findfirst function to find volume label with Windows long filenames - * - * Revision 1.2 1999/01/22 04:15:28 jprice - * Formating - * - * Revision 1.1.1.1 1999/01/20 05:51:00 jprice - * Imported sources - * - * Rev 1.10 06 Dec 1998 8:44:42 patv - * Expanded dos functions due to new I/O subsystem. - * - * Rev 1.9 04 Jan 1998 23:14:38 patv - * Changed Log for strip utility - * - * Rev 1.8 03 Jan 1998 8:36:04 patv - * Converted data area to SDA format - * - * Rev 1.7 22 Jan 1997 12:59:56 patv - * pre-0.92 bug fixes - * - * Rev 1.6 16 Jan 1997 12:46:32 patv - * pre-Release 0.92 feature additions - * - * Rev 1.5 29 May 1996 21:15:20 patv - * bug fixes for v0.91a - * - * Rev 1.4 19 Feb 1996 3:20:08 patv - * Added NLS, int2f and config.sys processing - * - * Rev 1.2 01 Sep 1995 17:48:48 patv - * First GPL release. - * - * Rev 1.1 30 Jul 1995 20:50:24 patv - * Eliminated version strings in ipl - * - * Rev 1.0 02 Jul 1995 8:04:20 patv - * Initial revision. - */ diff --git a/kernel/dosidle.asm b/kernel/dosidle.asm index e0e4cab3..9bdcd70b 100644 --- a/kernel/dosidle.asm +++ b/kernel/dosidle.asm @@ -31,7 +31,7 @@ PSP_USERSP equ 2eh PSP_USERSS equ 30h -segment HMA_TEXT +segment _TEXT global _DosIdle_int diff --git a/kernel/dosnames.c b/kernel/dosnames.c index 099d82dd..9fa11084 100644 --- a/kernel/dosnames.c +++ b/kernel/dosnames.c @@ -159,62 +159,3 @@ int ParseDosName(const char *filename, char *fcbname, BOOL bAllowWildcards) return nDirCnt; } -/* - * Log: dosnames.c,v - for newer log entries do "cvs log dosnames.c" - * - * Revision 1.2 2000/05/08 04:29:59 jimtabor - * Update CVS to 2020 - * - * Revision 1.4 2000/03/31 05:40:09 jtabor - * Added Eric W. Biederman Patches - * - * Revision 1.3 2000/03/09 06:07:11 kernel - * 2017f updates by James Tabor - * - * Revision 1.2 1999/04/04 18:51:43 jprice - * no message - * - * Revision 1.1.1.1 1999/03/29 15:41:54 jprice - * New version without IPL.SYS - * - * Revision 1.4 1999/02/02 04:40:49 jprice - * Steve Miller fixed a bug with doing "cd ." would lock the machine. - * - * Revision 1.3 1999/02/01 01:43:28 jprice - * Fixed findfirst function to find volume label with Windows long filenames - * - * Revision 1.2 1999/01/22 04:15:28 jprice - * Formating - * - * Revision 1.1.1.1 1999/01/20 05:51:00 jprice - * Imported sources - * - * - * Rev 1.8 22 Jan 1998 4:09:00 patv - * Fixed pointer problems affecting SDA - * - * Rev 1.7 04 Jan 1998 23:14:38 patv - * Changed Log for strip utility - * - * Rev 1.6 03 Jan 1998 8:36:04 patv - * Converted data area to SDA format - * - * Rev 1.5 16 Jan 1997 12:46:36 patv - * pre-Release 0.92 feature additions - * - * Rev 1.4 29 May 1996 21:15:12 patv - * bug fixes for v0.91a - * - * Rev 1.3 19 Feb 1996 3:20:08 patv - * Added NLS, int2f and config.sys processing - * - * Rev 1.2 01 Sep 1995 17:48:44 patv - * First GPL release. - * - * Rev 1.1 30 Jul 1995 20:50:26 patv - * Eliminated version strings in ipl - * - * Rev 1.0 02 Jul 1995 8:05:56 patv - * Initial revision. - * - */ diff --git a/kernel/dsk.c b/kernel/dsk.c index 0efb8df8..d7d4c10c 100644 --- a/kernel/dsk.c +++ b/kernel/dsk.c @@ -110,8 +110,6 @@ ddt *getddt(int dev) return &(((ddt *) Dyn.Buffer)[dev]); } -ULONG dsk_lasttime = 0; - STATIC VOID tmark(ddt *pddt) { pddt->ddt_fh.ddt_lasttime = ReadPCClock(); @@ -200,7 +198,7 @@ COUNT ASMCFUNC FAR blk_driver(rqptr rp) } STATIC char template_string[] = "XXXXXX diskette in drive X:\n"; -#define DRIVE_POS (sizeof(template_string) - 2) +#define DRIVE_POS (sizeof(template_string) - 4) STATIC WORD play_dj(ddt * pddt) { @@ -870,33 +868,31 @@ STATIC WORD dskerr(COUNT code) translate LBA sectors into CHS addressing */ -STATIC int LBA_to_CHS(struct CHS *chs, ULONG LBA_address, ddt * pddt) +STATIC int LBA_to_CHS(ULONG LBA_address, struct CHS *chs, const ddt * pddt) { /* we need the defbpb values since those are taken from the BIOS, not from some random boot sector, except when we're dealing with a floppy */ - unsigned long cylinder; - - bpb *pbpb = hd(pddt->ddt_descflags) ? &pddt->ddt_defbpb : &pddt->ddt_bpb; - - chs->Sector = LBA_address % pbpb->bpb_nsecs + 1; - LBA_address /= pbpb->bpb_nsecs; + const bpb *pbpb = hd(pddt->ddt_descflags) ? &pddt->ddt_defbpb : &pddt->ddt_bpb; + unsigned hs = pbpb->bpb_nsecs * pbpb->bpb_nheads; + unsigned hsrem = (unsigned)(LBA_address % hs); - chs->Head = LBA_address % pbpb->bpb_nheads; + LBA_address /= hs; - cylinder = LBA_address / pbpb->bpb_nheads; - - if (cylinder > 1023ul) + if (LBA_address > 1023ul) { #ifdef DEBUG - printf("LBA-Transfer error : cylinder %lu > 1023\n", cylinder); + printf("LBA-Transfer error : cylinder %lu > 1023\n", LBA_address); #else put_string("LBA-Transfer error : cylinder > 1023\n"); #endif return 1; } - chs->Cylinder = cylinder; + + chs->Cylinder = LBA_address; + chs->Head = hsrem / pbpb->bpb_nsecs; + chs->Sector = hsrem % pbpb->bpb_nsecs + 1; return 0; } @@ -956,6 +952,8 @@ STATIC int LBA_Transfer(ddt * pddt, UWORD mode, VOID FAR * buffer, int num_retries; + *transferred = 0; + /* only low-level format floppies for now ! */ if (mode == LBA_FORMAT && hd(pddt->ddt_descflags)) return 0; @@ -974,7 +972,6 @@ STATIC int LBA_Transfer(ddt * pddt, UWORD mode, VOID FAR * buffer, } } - *transferred = 0; /* if (LBA_address+totaltodo > pddt->total_sectors) { @@ -1036,7 +1033,7 @@ STATIC int LBA_Transfer(ddt * pddt, UWORD mode, VOID FAR * buffer, else { /* transfer data, using old bios functions */ - if (LBA_to_CHS(&chs, LBA_address, pddt)) + if (LBA_to_CHS(LBA_address, &chs, pddt)) return 1; /* avoid overflow at end of track */ @@ -1099,110 +1096,3 @@ STATIC int LBA_Transfer(ddt * pddt, UWORD mode, VOID FAR * buffer, * initcode moved (mostly) to initdisk.c * lower interface partly redesigned */ - -/* Log: dsk.c,v - for newer log entries: "cvs log dsk.c" - * - * Revision 1.16 2001/04/29 brianreifsnyder - * Added phase 1 support for LBA hard drives - * - * Revision 1.15 2001/04/16 01:45:26 bartoldeman - * Fixed handles, config.sys drivers, warnings. Enabled INT21/AH=6C, printf %S/%Fs - * - * Revision 1.14 2001/04/15 03:21:50 bartoldeman - * See history.txt for the list of fixes. - * - * Revision 1.13 2001/03/27 20:27:43 bartoldeman - * dsk.c (reported by Nagy Daniel), inthndlr and int25/26 fixes by Tom Ehlert. - * - * Revision 1.12 2001/03/24 22:13:05 bartoldeman - * See history.txt: dsk.c changes, warning removal and int21 entry handling. - * - * Revision 1.11 2001/03/21 02:56:25 bartoldeman - * See history.txt for changes. Bug fixes and HMA support are the main ones. - * - * Revision 1.9 2001/03/08 21:15:00 bartoldeman - * Space saving fixes from Tom Ehlert - * - * Revision 1.8 2000/06/21 18:16:46 jimtabor - * Add UMB code, patch, and code fixes - * - * Revision 1.7 2000/06/01 06:37:38 jimtabor - * Read History for Changes - * - * Revision 1.6 2000/05/26 19:25:19 jimtabor - * Read History file for Change info - * - * Revision 1.5 2000/05/25 20:56:21 jimtabor - * Fixed project history - * - * Revision 1.4 2000/05/17 19:15:12 jimtabor - * Cleanup, add and fix source. - * - * Revision 1.3 2000/05/11 04:26:26 jimtabor - * Added code for DOS FN 69 & 6C - * - * Revision 1.2 2000/05/08 04:29:59 jimtabor - * Update CVS to 2020 - * - * Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 - * The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with - * MS-DOS. Distributed under the GNU GPL. - * - * Revision 1.6 2000/04/29 05:13:16 jtabor - * Added new functions and clean up code - * - * Revision 1.5 2000/03/09 06:07:11 kernel - * 2017f updates by James Tabor - * - * Revision 1.4 1999/08/10 18:07:57 jprice - * ror4 2011-04 patch - * - * Revision 1.3 1999/04/16 21:43:40 jprice - * ror4 multi-sector IO - * - * Revision 1.2 1999/04/16 00:53:32 jprice - * Optimized FAT handling - * - * Revision 1.1.1.1 1999/03/29 15:40:51 jprice - * New version without IPL.SYS - * - * Revision 1.5 1999/02/14 04:26:46 jprice - * Changed check media so that it checks if a floppy disk has been changed. - * - * Revision 1.4 1999/02/08 05:55:57 jprice - * Added Pat's 1937 kernel patches - * - * Revision 1.3 1999/02/01 01:48:41 jprice - * Clean up; Now you can use hex numbers in config.sys. added config.sys screen function to change screen mode (28 or 43/50 lines) - * - * Revision 1.2 1999/01/22 04:13:25 jprice - * Formating - * - * Revision 1.1.1.1 1999/01/20 05:51:01 jprice - * Imported sources - * - * - * Rev 1.7 06 Dec 1998 8:45:18 patv - * Changed due to new I/O subsystem. - * - * Rev 1.6 04 Jan 1998 23:15:16 patv - * Changed Log for strip utility - * - * Rev 1.5 10 Jan 1997 5:41:48 patv - * Modified for extended partition support - * - * Rev 1.4 29 May 1996 21:03:32 patv - * bug fixes for v0.91a - * - * Rev 1.3 19 Feb 1996 3:21:36 patv - * Added NLS, int2f and config.sys processing - * - * Rev 1.2 01 Sep 1995 17:54:18 patv - * First GPL release. - * - * Rev 1.1 30 Jul 1995 20:52:00 patv - * Eliminated version strings in ipl - * - * Rev 1.0 02 Jul 1995 8:32:42 patv - * Initial revision. - */ diff --git a/kernel/entry.asm b/kernel/entry.asm index 92cd25af..1a487163 100644 --- a/kernel/entry.asm +++ b/kernel/entry.asm @@ -31,10 +31,10 @@ %include "segs.inc" %include "stacks.inc" -segment HMA_TEXT - extern _int21_syscall:wrt HGROUP - extern _int21_service:wrt HGROUP - extern _int2526_handler:wrt HGROUP +segment _TEXT + extern _int21_syscall:wrt TGROUP + extern _int21_service:wrt TGROUP + extern _int2526_handler:wrt TGROUP extern _error_tos:wrt DGROUP extern _char_api_tos:wrt DGROUP extern _disk_api_tos:wrt DGROUP @@ -123,21 +123,19 @@ cpm_error: mov al,0 ; int20_handler(iregs UserRegs) ; -print_hex: mov cx, 404h -hex_loop: - rol dx, cl - mov al, dl - and al, 0fh - add al, 30h - cmp al, 39h - jbe no_letter - add al, 7 -no_letter: - mov bx, 0070h - mov ah, 0eh - int 10h - dec ch - jnz hex_loop +print_hex: mov cl, 12 +hex_loop: + mov ax, dx + shr ax, cl + and al, 0fh + cmp al, 10 + sbb al, 69h + das + mov bx, 0070h + mov ah, 0eh + int 10h + sub cl, 4 + jae hex_loop ret divide_by_zero_message db 0dh,0ah,'Interrupt divide by zero, stack:',0dh,0ah,0 @@ -639,35 +637,3 @@ CritErrAbort: mov [bp+reg_ax],ax sti jmp int21_reentry ; restart the system call - -; Log: entry.asm,v -; Revision 1.5 2000/03/20 03:15:49 kernel -; Change in Entry.asm -; -; Revision 1.4 1999/09/23 04:40:46 jprice -; *** empty log message *** -; -; Revision 1.2 1999/08/10 17:57:12 jprice -; ror4 2011-02 patch -; -; Revision 1.1.1.1 1999/03/29 15:40:53 jprice -; New version without IPL.SYS -; -; Revision 1.4 1999/02/08 05:55:57 jprice -; Added Pat's 1937 kernel patches -; -; Revision 1.3 1999/02/01 01:48:41 jprice -; Clean up; Now you can use hex numbers in config.sys. added config.sys screen function to change screen mode (28 or 43/50 lines) -; -; Revision 1.2 1999/01/22 04:13:25 jprice -; Formating -; -; Revision 1.1.1.1 1999/01/20 05:51:01 jprice -; Imported sources -; -; Rev 1.1 06 Dec 1998 8:48:40 patv -; New int 21h handler code. -; -; Rev 1.0 07 Feb 1998 20:42:08 patv -; Modified stack frame to match DOS standard -; EndLog diff --git a/kernel/error.c b/kernel/error.c index 88457df8..89c8d9d6 100644 --- a/kernel/error.c +++ b/kernel/error.c @@ -89,43 +89,3 @@ COUNT block_error(request * rq, COUNT nDrive, struct dhdr FAR * lpDevice) nDrive, rq->r_status & S_MASK, lpDevice); } -/* - * Log: error.c,v - for newer entries do "cvs log error.c" - * - * Revision 1.2 2000/03/09 06:07:11 kernel - * 2017f updates by James Tabor - * - * Revision 1.1.1.1 1999/03/29 15:41:55 jprice - * New version without IPL.SYS - * - * Revision 1.4 1999/02/09 02:54:23 jprice - * Added Pat's 1937 kernel patches - * - * Revision 1.3 1999/02/01 01:43:28 jprice - * Fixed findfirst function to find volume label with Windows long filenames - * - * Revision 1.2 1999/01/22 04:15:28 jprice - * Formating - * - * Revision 1.1.1.1 1999/01/20 05:51:00 jprice - * Imported sources - * - * - * Rev 1.5 06 Dec 1998 8:43:54 patv - * Now handles errors like MS-DOS. - * - * Rev 1.4 04 Jan 1998 23:14:36 patv - * Changed Log for strip utility - * - * Rev 1.3 29 May 1996 21:15:10 patv - * bug fixes for v0.91a - * - * Rev 1.2 01 Sep 1995 17:48:46 patv - * First GPL release. - * - * Rev 1.1 30 Jul 1995 20:50:26 patv - * Eliminated version strings in ipl - * - * Rev 1.0 02 Jul 1995 8:06:14 patv - * Initial revision. - */ diff --git a/kernel/execrh.asm b/kernel/execrh.asm index d3e79efe..cbd89524 100644 --- a/kernel/execrh.asm +++ b/kernel/execrh.asm @@ -30,7 +30,7 @@ %include "segs.inc" -segment HMA_TEXT +segment _TEXT ; _execrh ; Execute Device Request ; @@ -78,40 +78,3 @@ segment INIT_TEXT _init_execrh: EXECRH - -; Log: execrh.asm,v -; Revision 1.3 2000/03/09 06:07:11 kernel -; 2017f updates by James Tabor -; -; Revision 1.2 1999/08/10 17:57:12 jprice -; ror4 2011-02 patch -; -; Revision 1.1.1.1 1999/03/29 15:40:54 jprice -; New version without IPL.SYS -; -; Revision 1.4 1999/02/08 05:55:57 jprice -; Added Pat's 1937 kernel patches -; -; Revision 1.3 1999/02/01 01:48:41 jprice -; Clean up; Now you can use hex numbers in config.sys. added config.sys screen function to change screen mode (28 or 43/50 lines) -; -; Revision 1.2 1999/01/22 04:13:25 jprice -; Formating -; -; Revision 1.1.1.1 1999/01/20 05:51:01 jprice -; Imported sources -; -; -; Rev 1.3 06 Dec 1998 8:45:06 patv -;Bug fixes. -; -; Rev 1.2 29 May 1996 21:03:30 patv -;bug fixes for v0.91a -; -; Rev 1.1 01 Sep 1995 17:54:22 patv -;First GPL release. -; -; Rev 1.0 02 Jul 1995 9:05:34 patv -;Initial revision. -; EndLog -; diff --git a/kernel/fatdir.c b/kernel/fatdir.c index 60815861..14a1ace9 100644 --- a/kernel/fatdir.c +++ b/kernel/fatdir.c @@ -46,8 +46,8 @@ VOID dir_init_fnode(f_node_ptr fnp, CLUSTER dirstart) fnp->f_flags.f_droot = FALSE; fnp->f_flags.f_ddir = TRUE; fnp->f_flags.f_dnew = TRUE; - fnp->f_diroff = fnp->f_offset = fnp->f_cluster_offset = - fnp->f_highwater = 0l; + fnp->f_diroff = fnp->f_offset = fnp->f_highwater = 0l; + fnp->f_cluster_offset = 0; /* root directory */ if (dirstart == 0) @@ -319,7 +319,7 @@ BOOL dir_write(REG f_node_ptr fnp) fnp->f_offset = fnp->f_diroff; fnp->f_back = LONG_LAST_CLUSTER; fnp->f_cluster = fnp->f_dirstart; - fnp->f_cluster_offset = 0l; /*JPP */ + fnp->f_cluster_offset = 0; /* Search through the FAT to find the block */ /* that this entry is in. */ @@ -641,92 +641,3 @@ int FileName83Length(BYTE * filename83) } #endif -/* - * Log: fatdir.c,v - for newer log entries do a "cvs log fatdir.c" - * - * Revision 1.12 2000/03/31 05:40:09 jtabor - * Added Eric W. Biederman Patches - * - * Revision 1.11 2000/03/17 22:59:04 kernel - * Steffen Kaiser's NLS changes - * - * Revision 1.10 2000/03/09 06:07:11 kernel - * 2017f updates by James Tabor - * - * Revision 1.9 1999/08/25 03:18:07 jprice - * ror4 patches to allow TC 2.01 compile. - * - * Revision 1.8 1999/08/10 17:57:12 jprice - * ror4 2011-02 patch - * - * Revision 1.7 1999/05/03 06:25:45 jprice - * Patches from ror4 and many changed of signed to unsigned variables. - * - * Revision 1.6 1999/04/16 00:53:32 jprice - * Optimized FAT handling - * - * Revision 1.5 1999/04/13 15:48:20 jprice - * no message - * - * Revision 1.4 1999/04/11 04:33:38 jprice - * ror4 patches - * - * Revision 1.2 1999/04/04 18:51:43 jprice - * no message - * - * Revision 1.1.1.1 1999/03/29 15:41:58 jprice - * New version without IPL.SYS - * - * Revision 1.7 1999/03/25 05:06:57 jprice - * Fixed findfirst & findnext functions to treat the attributes like MSDOS does. - * - * Revision 1.6 1999/02/14 04:27:09 jprice - * Changed check media so that it checks if a floppy disk has been changed. - * - * Revision 1.5 1999/02/09 02:54:23 jprice - * Added Pat's 1937 kernel patches - * - * Revision 1.4 1999/02/01 01:43:28 jprice - * Fixed findfirst function to find volume label with Windows long filenames - * - * Revision 1.3 1999/01/30 08:25:34 jprice - * Clean up; Fixed bug with set attribute function. If you tried to - * change the attributres of a directory, it would erase it. - * - * Revision 1.2 1999/01/22 04:15:28 jprice - * Formating - * - * Revision 1.1.1.1 1999/01/20 05:51:00 jprice - * Imported sources - * - * - * Rev 1.10 06 Dec 1998 8:44:36 patv - * Bug fixes. - * - * Rev 1.9 22 Jan 1998 4:09:00 patv - * Fixed pointer problems affecting SDA - * - * Rev 1.8 04 Jan 1998 23:14:36 patv - * Changed Log for strip utility - * - * Rev 1.7 03 Jan 1998 8:36:02 patv - * Converted data area to SDA format - * - * Rev 1.6 16 Jan 1997 12:46:30 patv - * pre-Release 0.92 feature additions - * - * Rev 1.5 29 May 1996 21:15:18 patv - * bug fixes for v0.91a - * - * Rev 1.4 19 Feb 1996 3:20:12 patv - * Added NLS, int2f and config.sys processing - * - * Rev 1.2 01 Sep 1995 17:48:38 patv - * First GPL release. - * - * Rev 1.1 30 Jul 1995 20:50:24 patv - * Eliminated version strings in ipl - * - * Rev 1.0 02 Jul 1995 8:04:34 patv - * Initial revision. - */ diff --git a/kernel/fatfs.c b/kernel/fatfs.c index 0872fb41..b3f47839 100644 --- a/kernel/fatfs.c +++ b/kernel/fatfs.c @@ -236,7 +236,7 @@ long dos_open(char *path, unsigned flags, unsigned attrib) { fnp->f_cluster = FREE; setdstart(fnp->f_dir, FREE); - fnp->f_cluster_offset = 0l; /*JPP */ + fnp->f_cluster_offset = 0; } fnp->f_flags.f_dmod = (status != S_OPENED); @@ -247,7 +247,7 @@ long dos_open(char *path, unsigned flags, unsigned attrib) merge_file_changes(fnp, status == S_OPENED); /* /// Added - Ron Cemer */ /* /// Moved from above. - Ron Cemer */ fnp->f_cluster = getdstart(fnp->f_dir); - fnp->f_cluster_offset = 0l; /*JPP */ + fnp->f_cluster_offset = 0; return xlt_fnp(fnp) | ((long)status << 16); } @@ -1318,24 +1318,21 @@ STATIC BOOL first_fat(f_node_ptr fnp) * DE_SEEK - [XFR_READ mode only] byte at f_offset lies outside of * the FAT chain. The fnode is not released. * Notes. - * JPP: new map_cluster. If we are moving forward, then use the offset + * If we are moving forward, then use the relative cluster number offset * that we are at now (f_cluster_offset) to start, instead of starting * at the beginning. */ COUNT map_cluster(REG f_node_ptr fnp, COUNT mode) { - ULONG idx; - ULONG clssize; /* might be 64K (by WinNT) TE */ + CLUSTER relcluster = (CLUSTER)((fnp->f_offset / fnp->f_dpb->dpb_secsize) >> + fnp->f_dpb->dpb_shftcnt); #ifdef DISPLAY_GETBLOCK printf("map_cluster: current %lu, offset %lu, diff=%lu ", - fnp->f_cluster_offset, fnp->f_offset, + (ULONG)fnp->f_cluster_offset, fnp->f_offset, fnp->f_offset - fnp->f_cluster_offset); #endif - /* The variable clssize will be used later. */ - clssize = (ULONG) fnp->f_dpb->dpb_secsize << fnp->f_dpb->dpb_shftcnt; - /* If someone did a seek, but no writes have occured, we will */ /* need to initialize the fnode. */ if ((mode == XFR_WRITE) && checkdstart(fnp->f_dir, FREE)) @@ -1347,16 +1344,9 @@ COUNT map_cluster(REG f_node_ptr fnp, COUNT mode) } } - if (fnp->f_offset >= fnp->f_cluster_offset) /*JPP */ + if (relcluster < fnp->f_cluster_offset) { /* Set internal index and cluster size. */ - idx = fnp->f_offset - fnp->f_cluster_offset; - } - else - { - /* Set internal index and cluster size. */ - idx = fnp->f_offset; - fnp->f_cluster = fnp->f_flags.f_ddir ? fnp->f_dirstart : getdstart(fnp->f_dir); fnp->f_cluster_offset = 0; @@ -1386,15 +1376,14 @@ COUNT map_cluster(REG f_node_ptr fnp, COUNT mode) } } - if (idx < clssize) + if (fnp->f_cluster_offset == relcluster) break; fnp->f_back = fnp->f_cluster; /* get next cluster in the chain */ fnp->f_cluster = next_cluster(fnp->f_dpb, fnp->f_cluster); - fnp->f_cluster_offset += clssize; - idx -= clssize; + fnp->f_cluster_offset++; if (fnp->f_cluster == 1) return DE_SEEK; } @@ -2236,138 +2225,4 @@ STATIC VOID shrink_file(f_node_ptr fnp) * * the dos_mkdir/extenddir (with getblock() instead of getblockOver) was a real * performance killer on large drives. (~0.5 sec /dos_mkdir) TE - * - * Log: fatfs.c,v - for newer log entries do "cvs log fatfs.c" - * - * /// 2000/08/12 22:49:00 Ron Cemer - * Fixed writeblock() to only use getbuf() if writing a - * complete sector; otherwise use getbloc() and do a - * read-modify-write to prevent writing garbage back - * over pre-existing data in the file. - * This was a major BUG. - * - * Revision 1.23 2000/04/29 05:13:16 jtabor - * Added new functions and clean up code - * - * Revision 1.19 2000/03/17 22:59:04 kernel - * Steffen Kaiser's NLS changes - * - * Revision 1.18 2000/03/17 04:13:12 kernel - * Added Change for media_check - * - * Revision 1.17 2000/03/17 04:01:20 kernel - * Added Change for media_check - * - * Revision 1.16 2000/03/09 06:07:11 kernel - * 2017f updates by James Tabor - * - * Revision 1.15 1999/09/23 04:40:46 jprice - * *** empty log message *** - * - * Revision 1.12 1999/09/14 01:01:54 jprice - * Fixed bug where you could write over directories. - * - * Revision 1.11 1999/08/25 03:18:08 jprice - * ror4 patches to allow TC 2.01 compile. - * - * Revision 1.10 1999/08/10 18:03:42 jprice - * ror4 2011-03 patch - * - * Revision 1.9 1999/05/03 06:25:45 jprice - * Patches from ror4 and many changed of signed to unsigned variables. - * - * Revision 1.8 1999/05/03 05:00:24 jprice - * Fixed bug in map_cluster function - * - * Revision 1.7 1999/04/16 00:53:33 jprice - * Optimized FAT handling - * - * Revision 1.6 1999/04/12 23:41:54 jprice - * Using getbuf to write data instead of getblock - * using getblock made it read the block before it wrote it - * - * Revision 1.5 1999/04/12 03:21:17 jprice - * more ror4 patches. Changes for multi-block IO - * - * Revision 1.4 1999/04/11 04:33:38 jprice - * ror4 patches - * - * Revision 1.2 1999/04/04 18:51:43 jprice - * no message - * - * Revision 1.1.1.1 1999/03/29 15:42:07 jprice - * New version without IPL.SYS - * - * Revision 1.8 1999/03/23 23:37:39 jprice - * Fixed mkdir DOS function so it will create a directory with same name as the volument label - * - * Revision 1.7 1999/03/02 07:00:51 jprice - * Fixed bugs with dos set attribute function. Now returns correct - * error code, and errors if user tries to set bits 6 & 7. - * - * Revision 1.6 1999/02/09 02:54:23 jprice - * Added Pat's 1937 kernel patches - * - * Revision 1.5 1999/02/04 03:18:37 jprice - * Formating. Added comments. - * - * Revision 1.4 1999/02/01 01:43:28 jprice - * Fixed findfirst function to find volume label with Windows long filenames - * - * Revision 1.3 1999/01/30 08:25:34 jprice - * Clean up; Fixed bug with set attribute function. If you tried to - * change the attributes of a directory, it would erase it. - * - * Revision 1.2 1999/01/22 04:15:28 jprice - * Formating - * - * Revision 1.1.1.1 1999/01/20 05:51:00 jprice - * Imported sources - * - * - * Rev 1.14 06 Dec 1998 8:44:26 patv - * Bug fixes. - * - * Rev 1.13 09 Feb 1998 5:43:30 patv - * Eliminated FAT12 EOF and error useage. - * - * Rev 1.12 03 Feb 1998 11:28:04 patv - * Fixed lseek bug. - * - * Rev 1.11 22 Jan 1998 5:38:08 patv - * Corrected remaining file name and extension copies that did not - * account for far file nodes due to allocated FILES= spec. - * - * Rev 1.10 22 Jan 1998 4:09:00 patv - * Fixed pointer problems affecting SDA - * - * Rev 1.9 04 Jan 1998 23:14:40 patv - * Changed Log for strip utility - * - * Rev 1.8 04 Jan 1998 17:24:14 patv - * Corrected subdirectory bug - * - * Rev 1.7 03 Jan 1998 8:36:04 patv - * Converted data area to SDA format - * - * Rev 1.6 22 Jan 1997 13:00:30 patv - * pre-0.92 bug fixes - * - * Rev 1.5 16 Jan 1997 12:46:24 patv - * pre-Release 0.92 feature additions - * - * Rev 1.4 29 May 1996 21:15:16 patv - * bug fixes for v0.91a - * - * Rev 1.3 19 Feb 1996 3:20:10 patv - * Added NLS, int2f and config.sys processing - * - * Rev 1.2 01 Sep 1995 17:48:40 patv - * First GPL release. - * - * Rev 1.1 30 Jul 1995 20:50:24 patv - * Eliminated version strings in ipl - * - * Rev 1.0 02 Jul 1995 8:04:46 patv - * Initial revision. */ diff --git a/kernel/fattab.c b/kernel/fattab.c index a54c6569..f7a2038c 100644 --- a/kernel/fattab.c +++ b/kernel/fattab.c @@ -82,6 +82,15 @@ struct buffer FAR *getFATblock(ULONG clussec, struct dpb FAR * dpbp) bp->b_flag &= ~(BFR_DATA | BFR_DIR); bp->b_flag |= BFR_FAT | BFR_VALID; bp->b_dpbp = dpbp; + bp->b_copies = dpbp->dpb_fats; + bp->b_offset = dpbp->dpb_fatsize; +#ifdef WITHFAT32 + if (ISFAT32(dpbp)) + { + if (dpbp->dpb_xflags & FAT_NO_MIRRORING) + bp->b_copies = 1; + } +#endif } return bp; } @@ -183,7 +192,7 @@ unsigned link_fat(struct dpb FAR * dpbp, CLUSTER Cluster1, *fbp1 = (*fbp1 & 0xf0) | ((Cluster2 >> 8) & 0x0f); } } - else if (ISFAT16(dpbp)) + else if (ELSE_ISFAT16(dpbp)) { /* form an index so that we can read the block as a */ /* byte array */ @@ -319,7 +328,7 @@ CLUSTER next_cluster(struct dpb FAR * dpbp, CLUSTER ClusterNum) return LONG_BAD; return idx; } - else if (ISFAT16(dpbp)) + else if (ELSE_ISFAT16(dpbp)) { UWORD res; @@ -353,58 +362,3 @@ CLUSTER next_cluster(struct dpb FAR * dpbp, CLUSTER ClusterNum) return LONG_LAST_CLUSTER; } -/* - * Log: fattab.c,v - for newer log entries do "cvs log fattab.c" - * - * Revision 1.6 1999/08/10 18:03:42 jprice - * ror4 2011-03 patch - * - * Revision 1.5 1999/05/03 06:25:45 jprice - * Patches from ror4 and many changed of signed to unsigned variables. - * - * Revision 1.4 1999/04/16 00:53:33 jprice - * Optimized FAT handling - * - * Revision 1.3 1999/04/11 04:33:38 jprice - * ror4 patches - * - * Revision 1.1.1.1 1999/03/29 15:42:09 jprice - * New version without IPL.SYS - * - * Revision 1.4 1999/02/09 02:54:23 jprice - * Added Pat's 1937 kernel patches - * - * Revision 1.3 1999/02/01 01:43:28 jprice - * Fixed findfirst function to find volume label with Windows long filenames - * - * Revision 1.2 1999/01/22 04:15:28 jprice - * Formating - * - * Revision 1.1.1.1 1999/01/20 05:51:00 jprice - * Imported sources - * - * - * Rev 1.7 09 Feb 1998 5:41:08 patv - * Eliminated FAT12 EOF and error returns. - * - * Rev 1.6 04 Jan 1998 23:14:38 patv - * Changed Log for strip utility - * - * Rev 1.5 16 Jan 1997 12:46:22 patv - * pre-Release 0.92 feature additions - * - * Rev 1.4 29 May 1996 21:15:14 patv - * bug fixes for v0.91a - * - * Rev 1.3 19 Feb 1996 3:20:08 patv - * Added NLS, int2f and config.sys processing - * - * Rev 1.2 01 Sep 1995 17:48:42 patv - * First GPL release. - * - * Rev 1.1 30 Jul 1995 20:50:26 patv - * Eliminated version strings in ipl - * - * Rev 1.0 02 Jul 1995 8:04:56 patv - * Initial revision. - */ diff --git a/kernel/fcbfns.c b/kernel/fcbfns.c index c2180579..bd566f60 100644 --- a/kernel/fcbfns.c +++ b/kernel/fcbfns.c @@ -692,64 +692,3 @@ UBYTE FcbFindFirstNext(xfcb FAR * lpXfcb, BOOL First) } #endif -/* - * Log: fcbfns.c,v - for newer entries see "cvs log fcbfns.c" - * - * Revision 1.7 2000/03/31 05:40:09 jtabor - * Added Eric W. Biederman Patches - * - * Revision 1.6 2000/03/17 22:59:04 kernel - * Steffen Kaiser's NLS changes - * - * Revision 1.5 2000/03/09 06:07:11 kernel - * 2017f updates by James Tabor - * - * Revision 1.4 1999/09/23 04:40:46 jprice - * *** empty log message *** - * - * Revision 1.2 1999/04/04 18:51:43 jprice - * no message - * - * Revision 1.1.1.1 1999/03/29 15:42:15 jprice - * New version without IPL.SYS - * - * Revision 1.5 1999/02/09 02:54:23 jprice - * Added Pat's 1937 kernel patches - * - * Revision 1.4 1999/02/04 03:18:37 jprice - * Formating. Added comments. - * - * Revision 1.3 1999/02/01 01:43:28 jprice - * Fixed findfirst function to find volume label with Windows long filenames - * - * Revision 1.2 1999/01/22 04:15:28 jprice - * Formating - * - * Revision 1.1.1.1 1999/01/20 05:51:00 jprice - * Imported sources - * - * - * Rev 1.7 06 Dec 1998 8:44:10 patv - * Expanded fcb functions for new I/O subsystem. - * - * Rev 1.6 04 Jan 1998 23:14:38 patv - * Changed Log for strip utility - * - * Rev 1.5 03 Jan 1998 8:36:02 patv - * Converted data area to SDA format - * - * Rev 1.4 16 Jan 1997 12:46:38 patv - * pre-Release 0.92 feature additions - * - * Rev 1.3 29 May 1996 21:15:14 patv - * bug fixes for v0.91a - * - * Rev 1.2 01 Sep 1995 17:48:44 patv - * First GPL release. - * - * Rev 1.1 30 Jul 1995 20:50:26 patv - * Eliminated version strings in ipl - * - * Rev 1.0 02 Jul 1995 8:06:06 patv - * Initial revision. - */ diff --git a/kernel/globals.h b/kernel/globals.h index 3165df9c..2ec43b74 100644 --- a/kernel/globals.h +++ b/kernel/globals.h @@ -150,21 +150,6 @@ FAR * ASM DPBp; /* First drive Parameter Block */ #define DSKWRITEINT26 3 #define DSKREADINT25 4 -/* FAT cluster special flags */ -#define FREE 0x000 - -#ifdef WITHFAT32 -#define LONG_LAST_CLUSTER 0x0FFFFFFFl -#define LONG_BAD 0x0FFFFFF7l -#else -#define LONG_LAST_CLUSTER 0xFFFF -#define LONG_BAD 0xFFF8 -#endif -#define MASK16 0xFFF8 -#define BAD16 0xFFF0 -#define MASK12 0xFF8 -#define BAD12 0xFF0 - /* NLS character table type */ typedef BYTE *UPMAP; @@ -270,6 +255,7 @@ FAR * ASM clock, /* CLOCK$ device */ extern WORD ASM maxbksize; /* Number of Drives in system */ extern struct buffer FAR *ASM firstbuf; /* head of buffers linked list */ +GLOBAL char FAR *firstAvailableBuf; extern struct cds FAR * ASM CDSp; /* Current Directory Structure */ extern struct cds FAR * ASM current_ldt; @@ -453,115 +439,3 @@ void ASMCFUNC spawn_int23(void); /* procsupt.asm */ GLOBAL BYTE ReturnAnyDosVersionExpected; -/* - * Log: globals.h,v - * - * Revision 1.17 2000/03/16 03:28:49 kernel - * *** empty log message *** - * - * Revision 1.16 2000/03/09 06:07:11 kernel - * 2017f updates by James Tabor - * - * Revision 1.15 1999/09/23 04:40:47 jprice - * *** empty log message *** - * - * Revision 1.13 1999/08/25 03:18:08 jprice - * ror4 patches to allow TC 2.01 compile. - * - * Revision 1.12 1999/08/10 18:03:43 jprice - * ror4 2011-03 patch - * - * Revision 1.11 1999/05/03 06:25:45 jprice - * Patches from ror4 and many changed of signed to unsigned variables. - * - * Revision 1.10 1999/04/16 21:43:40 jprice - * ror4 multi-sector IO - * - * Revision 1.9 1999/04/16 12:21:22 jprice - * Steffen c-break handler changes - * - * Revision 1.8 1999/04/16 00:53:33 jprice - * Optimized FAT handling - * - * Revision 1.7 1999/04/12 03:21:17 jprice - * more ror4 patches. Changes for multi-block IO - * - * Revision 1.6 1999/04/11 04:33:39 jprice - * ror4 patches - * - * Revision 1.4 1999/04/04 22:57:47 jprice - * no message - * - * Revision 1.3 1999/04/04 18:51:43 jprice - * no message - * - * Revision 1.2 1999/03/29 17:05:09 jprice - * ror4 changes - * - * Revision 1.1.1.1 1999/03/29 15:40:58 jprice - * New version without IPL.SYS - * - * Revision 1.5 1999/02/08 05:55:57 jprice - * Added Pat's 1937 kernel patches - * - * Revision 1.4 1999/02/01 01:48:41 jprice - * Clean up; Now you can use hex numbers in config.sys. added config.sys screen function to change screen mode (28 or 43/50 lines) - * - * Revision 1.3 1999/01/30 08:26:46 jprice - * Clean up; commented out copyright messages while we debug. - * - * Revision 1.2 1999/01/22 04:13:26 jprice - * Formating - * - * Revision 1.1.1.1 1999/01/20 05:51:01 jprice - * Imported sources - * - - Rev 1.16 06 Dec 1998 8:45:56 patv - Expanded due to new I/O subsystem. - - Rev 1.15 07 Feb 1998 20:38:00 patv - Modified stack fram to match DOS standard - - Rev 1.14 02 Feb 1998 22:33:46 patv - Fixed size of default_drive. Caused failures when break_ena was not zero. - - Rev 1.13 22 Jan 1998 4:09:24 patv - Fixed pointer problems affecting SDA - - Rev 1.12 04 Jan 1998 23:16:22 patv - Changed Log for strip utility - - Rev 1.11 03 Jan 1998 8:36:50 patv - Converted data area to SDA format - - Rev 1.10 06 Feb 1997 21:57:04 patv - Changed version format string - - Rev 1.9 06 Feb 1997 21:35:08 patv - Modified to support new version format - - Rev 1.8 22 Jan 1997 13:17:14 patv - Changed to support version.h and pre-0.92 Svante Frey bug fixes. - - Rev 1.6 16 Jan 1997 12:47:00 patv - pre-Release 0.92 feature additions - - Rev 1.5 13 Sep 1996 19:26:32 patv - Fixed boot for hard drive - - Rev 1.4 29 Aug 1996 13:07:22 patv - Bug fixes for v0.91b - - Rev 1.3 29 May 1996 21:03:34 patv - bug fixes for v0.91a - - Rev 1.2 19 Feb 1996 3:23:04 patv - Added NLS, int2f and config.sys processing - - Rev 1.1 01 Sep 1995 17:54:16 patv - First GPL release. - - Rev 1.0 02 Jul 1995 8:31:00 patv - Initial revision. - */ diff --git a/kernel/init-dat.h b/kernel/init-dat.h index d9ae9b60..7bbde831 100644 --- a/kernel/init-dat.h +++ b/kernel/init-dat.h @@ -27,7 +27,6 @@ extern __segment DosTextSeg; #else -#pragma error("unknown compiler - please adjust") -this should simply not compile ! ! +#error("unknown compiler - please adjust") #endif extern BYTE DOSFAR version_flags; /* minor version number */ diff --git a/kernel/initclk.c b/kernel/initclk.c new file mode 100644 index 00000000..230a2540 --- /dev/null +++ b/kernel/initclk.c @@ -0,0 +1,102 @@ +/****************************************************************/ +/* */ +/* initclk.c */ +/* */ +/* System Clock Driver - initialization */ +/* */ +/* Copyright (c) 1995 */ +/* Pasquale J. Villani */ +/* All Rights Reserved */ +/* */ +/* This file is part of DOS-C. */ +/* */ +/* DOS-C is free software; you can redistribute it and/or */ +/* modify it under the terms of the GNU General Public License */ +/* as published by the Free Software Foundation; either version */ +/* 2, or (at your option) any later version. */ +/* */ +/* DOS-C is distributed in the hope that it will be useful, but */ +/* WITHOUT ANY WARRANTY; without even the implied warranty of */ +/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See */ +/* the GNU General Public License for more details. */ +/* */ +/* You should have received a copy of the GNU General Public */ +/* License along with DOS-C; see the file COPYING. If not, */ +/* write to the Free Software Foundation, 675 Mass Ave, */ +/* Cambridge, MA 02139, USA. */ +/****************************************************************/ + +#include "portab.h" +#include "init-mod.h" +#include "init-dat.h" + +#ifdef VERSION_STRINGS +static char *RcsId = + "$Id$"; +#endif + +/* */ +/* WARNING - THIS DRIVER IS NON-PORTABLE!!!! */ +/* */ + +STATIC int InitByteToBcd(int x) +{ + return ((x / 10) << 4) | (x % 10); +} + +STATIC int InitBcdToByte(int x) +{ + return ((x >> 4) & 0xf) * 10 + (x & 0xf); +} + +STATIC void InitDayToBcd(BYTE * x, unsigned mon, unsigned day, unsigned yr) +{ + x[1] = InitByteToBcd(mon); + x[0] = InitByteToBcd(day); + x[3] = InitByteToBcd(yr / 100); + x[2] = InitByteToBcd(yr % 100); +} + +void Init_clk_driver(void) +{ + iregs regsT, regsD, dosregs; + + regsT.a.b.h = 0x02; + regsT.d.x = regsT.c.x = 0; + regsT.flags = 0; + init_call_intr(0x1a, ®sT); + + if ((regsT.flags & 0x0001) || (regsT.c.x == 0 && regsT.d.x == 0)) + { + goto error; /* error */ + } + + regsD.a.b.h = 0x04; + regsD.d.x = regsD.c.x = 0; + regsD.flags = 0; + init_call_intr(0x1a, ®sD); + + if ((regsD.flags & 0x0001) || regsD.c.x == 0 || regsD.d.x == 0) + { + goto error; + } + + /* DosSetDate */ + dosregs.a.b.h = 0x2b; + dosregs.c.x = 100 * InitBcdToByte(regsD.c.b.h) + + InitBcdToByte(regsD.c.b.l); + dosregs.d.b.h = InitBcdToByte(regsD.d.b.h); /* month */ + dosregs.d.b.l = InitBcdToByte(regsD.d.b.l); /* day */ + init_call_intr(0x21, &dosregs); + + /* DosSetTime */ + dosregs.a.b.h = 0x2d; + dosregs.c.b.l = InitBcdToByte(regsT.c.b.l); /* minutes */ + dosregs.c.b.h = InitBcdToByte(regsT.c.b.h); /* hours */ + dosregs.d.b.h = InitBcdToByte(regsT.d.b.h); /*seconds */ + dosregs.d.b.l = 0; + init_call_intr(0x21, &dosregs); + +error:; + +} diff --git a/kernel/initdisk.c b/kernel/initdisk.c index 430db648..5fc43f31 100644 --- a/kernel/initdisk.c +++ b/kernel/initdisk.c @@ -204,9 +204,9 @@ extern unsigned char DOSTEXTFAR ASM int1e_table[0xe]; * the problem with fff0-fff6 is that they might be interpreted as BAD * * even though the standard BAD value is ...ff7 */ -#define FAT12MAX (FAT_MAGIC-7) -#define FAT16MAX (FAT_MAGIC16-7) -#define FAT32MAX (FAT_MAGIC32-7) +#define FAT12MAX (FAT_MAGIC-6) +#define FAT16MAX (FAT_MAGIC16-6) +#define FAT32MAX (FAT_MAGIC32-6) #define IsExtPartition(parttyp) ((parttyp) == EXTENDED || \ (parttyp) == EXTENDED_LBA ) @@ -354,15 +354,14 @@ COUNT init_getdriveparm(UBYTE drive, bpb FAR * pbpbarray) void init_LBA_to_CHS(struct CHS *chs, ULONG LBA_address, struct DriveParamS *driveparam) { - unsigned long cylinder; + unsigned hs = driveparam->chs.Sector * driveparam->chs.Head; + unsigned hsrem = (unsigned)(LBA_address % hs); - chs->Sector = LBA_address % driveparam->chs.Sector + 1; + LBA_address /= hs; - LBA_address /= driveparam->chs.Sector; - - chs->Head = LBA_address % driveparam->chs.Head; - cylinder = LBA_address / driveparam->chs.Head; - chs->Cylinder = cylinder >= 0x10000ul ? 0xffffu : cylinder; + chs->Cylinder = LBA_address >= 0x10000ul ? 0xffffu : (unsigned)LBA_address; + chs->Head = hsrem / driveparam->chs.Sector; + chs->Sector = hsrem % driveparam->chs.Sector + 1; } void printCHS(char *title, struct CHS *chs) diff --git a/kernel/inithma.c b/kernel/inithma.c index 5ba62965..df94c6d5 100644 --- a/kernel/inithma.c +++ b/kernel/inithma.c @@ -186,7 +186,6 @@ int EnableHMA(VOID) int MoveKernelToHMA() { - if (DosLoadedInHMA) { return TRUE; @@ -366,7 +365,8 @@ void MoveKernel(unsigned NewKernelSegment) d[i] = s[i]; } - HMAFree = FP_OFF(HMADest) + len; /* first free byte after HMA_TEXT */ + HMAFree = (FP_OFF(HMADest) + len + 0xf) & 0xfff0; + /* first free byte after HMA_TEXT on 16 byte boundary */ { /* D) but it only makes sense, if we can relocate @@ -446,9 +446,3 @@ void MoveKernel(unsigned NewKernelSegment) for (;;) ; } -/* - * Log: inithma.c,v - for newer entries do "cvs log inithma.c" - * - * Revision 0.1 2001/03/16 12:00:00 tom ehlert - * initial creation - */ diff --git a/kernel/initoem.c b/kernel/initoem.c index 220b705d..ca0b0949 100644 --- a/kernel/initoem.c +++ b/kernel/initoem.c @@ -52,46 +52,3 @@ UWORD init_oem(void) return top_k; } -/* - * Log: initoem.c,v - for newer entries do "cvs log initoem.c" - * - * Revision 1.3 2000/03/09 06:07:11 kernel - * 2017f updates by James Tabor - * - * Revision 1.2 1999/08/25 03:18:08 jprice - * ror4 patches to allow TC 2.01 compile. - * - * Revision 1.1.1.1 1999/03/29 15:40:58 jprice - * New version without IPL.SYS - * - * Revision 1.5 1999/02/08 05:55:57 jprice - * Added Pat's 1937 kernel patches - * - * Revision 1.4 1999/02/01 01:48:41 jprice - * Clean up; Now you can use hex numbers in config.sys. added config.sys screen function to change screen mode (28 or 43/50 lines) - * - * Revision 1.3 1999/01/30 08:28:11 jprice - * Clean up; Fixed bug with set attribute function. - * - * Revision 1.2 1999/01/22 04:13:26 jprice - * Formating - * - * Revision 1.1.1.1 1999/01/20 05:51:01 jprice - * Imported sources - * - * - * Rev 1.4 04 Jan 1998 23:15:16 patv - * Changed Log for strip utility - * - * Rev 1.3 29 May 1996 21:03:48 patv - * bug fixes for v0.91a - * - * Rev 1.2 19 Feb 1996 3:21:34 patv - * Added NLS, int2f and config.sys processing - * - * Rev 1.1 01 Sep 1995 17:54:16 patv - * First GPL release. - * - * Rev 1.0 02 Jul 1995 8:31:54 patv - * Initial revision. - */ diff --git a/kernel/int2f.asm b/kernel/int2f.asm index c9025245..27fd82a1 100644 --- a/kernel/int2f.asm +++ b/kernel/int2f.asm @@ -31,9 +31,9 @@ %include "segs.inc" %include "stacks.inc" -segment HMA_TEXT +segment _TEXT extern _cu_psp:wrt DGROUP - extern _syscall_MUX14:wrt HMA_TEXT + extern _syscall_MUX14:wrt _TEXT global reloc_call_int2f_handler reloc_call_int2f_handler: @@ -56,6 +56,12 @@ Int2f3: je FarTabRetn ; Win Hook return fast cmp ah,12h je IntDosCal ; Dos Internal calls + + cmp ax,4a01h + je IntDosCal ; Dos Internal calls + cmp ax,4a02h + je IntDosCal ; Dos Internal calls + cmp ah,10h ; SHARE.EXE interrupt? je Int2f1 ; yes, do installation check cmp ah,08h @@ -130,7 +136,7 @@ IntDosCal: mov ax,DGROUP mov ds,ax - extern _int2F_12_handler:wrt HGROUP + extern _int2F_12_handler:wrt TGROUP call _int2F_12_handler %IFDEF I386 @@ -319,14 +325,14 @@ int2f_call: xor cx, cx ; set to succeed; clear carry and CX int 2fh pop bx - jc no_clear_ax -clear_ax: - mov ax, cx ; extended open -> status from CX in AX - ; otherwise CX was set to zero above - jmp short no_neg_ax + jnc clear_ax no_clear_ax: neg ax -no_neg_ax: + xchg cx, ax +clear_ax: + xchg ax, cx ; extended open -> status from CX in AX + ; otherwise CX was set to zero above +no_neg_ax: pop bx pop cx pop di @@ -573,40 +579,3 @@ umbt_ret: umbt_error: xor ax,ax jmp short umbt_ret - -; Log: int2f.asm,v -; Revision 1.4 2000/03/31 05:40:09 jtabor -; Added Eric W. Biederman Patches -; -; Revision 1.3 2000/03/09 06:07:11 kernel -; 2017f updates by James Tabor -; -; Revision 1.2 1999/08/10 17:57:12 jprice -; ror4 2011-02 patch -; -; Revision 1.1.1.1 1999/03/29 15:40:59 jprice -; New version without IPL.SYS -; -; Revision 1.4 1999/02/08 05:55:57 jprice -; Added Pat's 1937 kernel patches -; -; Revision 1.3 1999/02/01 01:48:41 jprice -; Clean up; Now you can use hex numbers in config.sys. added config.sys screen function to change screen mode (28 or 43/50 lines) -; -; Revision 1.2 1999/01/22 04:13:26 jprice -; Formating -; -; Revision 1.1.1.1 1999/01/20 05:51:01 jprice -; Imported sources -; -; -; Rev 1.2 06 Dec 1998 8:48:12 patv -; Bug fixes. -; -; Rev 1.1 29 May 1996 21:03:46 patv -; bug fixes for v0.91a -; -; Rev 1.0 19 Feb 1996 3:34:38 patv -; Initial revision. -; EndLog -; diff --git a/kernel/inthndlr.c b/kernel/inthndlr.c index 361dd668..1239974c 100644 --- a/kernel/inthndlr.c +++ b/kernel/inthndlr.c @@ -1810,9 +1810,48 @@ struct int2f12regs { UWORD callerARG1; /* used if called from INT2F/12 */ }; +extern short AllocateHMASpace (size_t lowbuffer, size_t highbuffer); + VOID ASMCFUNC int2F_12_handler(struct int2f12regs r) { UWORD function = r.ax & 0xff; + + /* dont use + QueryFreeHMASpace(&p); + here; DS !=SS + */ + if ((r.ax & 0xff00) == 0x4a00) + { + size_t wantedBytes = r.bx; + + r.bx = 0; + r.es = FP_SEG(firstAvailableBuf); + r.di = FP_OFF(firstAvailableBuf); + if (FP_SEG(firstAvailableBuf) != 0xffff) + { + return; + } + + if (r.ax == 0x4a01) + { + r.bx = 0 - FP_OFF(firstAvailableBuf); + return; + } + + if (r.ax == 0x4a02) + { + if (wantedBytes > 0 - FP_OFF(firstAvailableBuf)) + { + r.bx = 0; + return; + } + AllocateHMASpace(FP_OFF(firstAvailableBuf), + FP_OFF(firstAvailableBuf)+wantedBytes); + firstAvailableBuf += wantedBytes; + + return; + } + } if (function > 0x31) return; @@ -2000,164 +2039,3 @@ VOID ASMCFUNC int2F_12_handler(struct int2f12regs r) * Modified interrupts 0x25 & 0x26 to return more accurate error codes. */ -/* - * Log: inthndlr.c,v - see "cvs log inthndlr.c" for newer entries. - * - * Revision 1.10 2000/10/29 23:51:56 jimtabor - * Adding Share Support by Ron Cemer - * - * Revision 1.9 2000/08/06 05:50:17 jimtabor - * Add new files and update cvs with patches and changes - * - * Revision 1.8 2000/06/21 18:16:46 jimtabor - * Add UMB code, patch, and code fixes - * - * Revision 1.7 2000/05/25 20:56:21 jimtabor - * Fixed project history - * - * Revision 1.6 2000/05/17 19:15:12 jimtabor - * Cleanup, add and fix source. - * - * Revision 1.5 2000/05/11 06:14:45 jimtabor - * Removed #if statement - * - * Revision 1.4 2000/05/11 04:26:26 jimtabor - * Added code for DOS FN 69 & 6C - * - * Revision 1.3 2000/05/09 00:30:11 jimtabor - * Clean up and Release - * - * Revision 1.2 2000/05/08 04:30:00 jimtabor - * Update CVS to 2020 - * - * Revision 1.1.1.1 2000/05/06 19:34:53 jhall1 - * The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with - * MS-DOS. Distributed under the GNU GPL. - * - * Revision 1.24 2000/04/29 05:13:16 jtabor - * Added new functions and clean up code - * - * Revision 1.22 2000/03/17 22:59:04 kernel - * Steffen Kaiser's NLS changes - * - * Revision 1.21 2000/03/17 05:00:11 kernel - * Fixed Func 0x32 - * - * Revision 1.20 2000/03/16 03:28:49 kernel - * *** empty log message *** - * - * Revision 1.19 2000/03/09 06:07:11 kernel - * 2017f updates by James Tabor - * - * Revision 1.18 1999/09/23 04:40:47 jprice - * *** empty log message *** - * - * Revision 1.13 1999/09/14 01:18:36 jprice - * ror4: fix int25 & 26 are not cached. - * - * Revision 1.12 1999/09/13 22:16:47 jprice - * Fix 210B function - * - * Revision 1.11 1999/08/25 03:18:08 jprice - * ror4 patches to allow TC 2.01 compile. - * - * Revision 1.10 1999/08/10 18:07:57 jprice - * ror4 2011-04 patch - * - * Revision 1.9 1999/08/10 18:03:43 jprice - * ror4 2011-03 patch - * - * Revision 1.8 1999/05/03 06:25:45 jprice - * Patches from ror4 and many changed of signed to unsigned variables. - * - * Revision 1.7 1999/04/23 04:24:39 jprice - * Memory manager changes made by ska - * - * Revision 1.6 1999/04/16 12:21:22 jprice - * Steffen c-break handler changes - * - * Revision 1.5 1999/04/11 04:33:39 jprice - * ror4 patches - * - * Revision 1.3 1999/04/04 22:57:47 jprice - * no message - * - * Revision 1.2 1999/04/04 18:51:43 jprice - * no message - * - * Revision 1.1.1.1 1999/03/29 15:41:04 jprice - * New version without IPL.SYS - * - * Revision 1.9 1999/03/23 23:38:49 jprice - * Now sets carry when we don't support a function - * - * Revision 1.8 1999/03/02 07:02:55 jprice - * Added some comments. Fixed some minor bugs. - * - * Revision 1.7 1999/03/01 05:45:08 jprice - * Added some DEBUG ifdef's so that it will compile without DEBUG defined. - * - * Revision 1.6 1999/02/08 05:55:57 jprice - * Added Pat's 1937 kernel patches - * - * Revision 1.5 1999/02/04 03:11:07 jprice - * Formating - * - * Revision 1.4 1999/02/01 01:48:41 jprice - * Clean up; Now you can use hex numbers in config.sys. added config.sys screen function to change screen mode (28 or 43/50 lines) - * - * Revision 1.3 1999/01/30 08:28:11 jprice - * Clean up; Fixed bug with set attribute function. - * - * Revision 1.2 1999/01/22 04:13:26 jprice - * Formating - * - * Revision 1.1.1.1 1999/01/20 05:51:00 jprice - * Imported sources - * - * - * Rev 1.14 06 Dec 1998 8:47:38 patv - * Expanded due to improved int 21h handler code. - * - * Rev 1.13 07 Feb 1998 20:38:46 patv - * Modified stack fram to match DOS standard - * - * Rev 1.12 22 Jan 1998 4:09:26 patv - * Fixed pointer problems affecting SDA - * - * Rev 1.11 06 Jan 1998 20:13:18 patv - * Broke apart int21_system from int21_handler. - * - * Rev 1.10 04 Jan 1998 23:15:22 patv - * Changed Log for strip utility - * - * Rev 1.9 04 Jan 1998 17:26:16 patv - * Corrected subdirectory bug - * - * Rev 1.8 03 Jan 1998 8:36:48 patv - * Converted data area to SDA format - * - * Rev 1.7 01 Aug 1997 2:00:10 patv - * COMPATIBILITY: Added return '$' in AL for function int 21h fn 09h - * - * Rev 1.6 06 Feb 1997 19:05:54 patv - * Added hooks for tsc command - * - * Rev 1.5 22 Jan 1997 13:18:32 patv - * pre-0.92 Svante Frey bug fixes. - * - * Rev 1.4 16 Jan 1997 12:46:46 patv - * pre-Release 0.92 feature additions - * - * Rev 1.3 29 May 1996 21:03:40 patv - * bug fixes for v0.91a - * - * Rev 1.2 19 Feb 1996 3:21:48 patv - * Added NLS, int2f and config.sys processing - * - * Rev 1.1 01 Sep 1995 17:54:20 patv - * First GPL release. - * - * Rev 1.0 02 Jul 1995 8:33:34 patv - * Initial revision. - */ diff --git a/kernel/intr.asm b/kernel/intr.asm index eebbfb04..88f716e0 100644 --- a/kernel/intr.asm +++ b/kernel/intr.asm @@ -28,7 +28,7 @@ %include "segs.inc" -segment HMA_TEXT +segment _TEXT ; ; void intr(nr, rp) ; REG int nr diff --git a/kernel/io.asm b/kernel/io.asm index 23e35f77..e50f7981 100644 --- a/kernel/io.asm +++ b/kernel/io.asm @@ -30,18 +30,18 @@ %include "segs.inc" - extern ConTable:wrt TGROUP - extern LptTable:wrt TGROUP - extern ComTable:wrt TGROUP - extern uPrtNo:wrt TGROUP - extern CommonNdRdExit:wrt TGROUP + extern ConTable:wrt LGROUP + extern LptTable:wrt LGROUP + extern ComTable:wrt LGROUP + extern uPrtNo:wrt LGROUP + extern CommonNdRdExit:wrt LGROUP ;!! extern _NumFloppies:wrt DGROUP extern blk_stk_top:wrt DGROUP extern clk_stk_top:wrt DGROUP extern _reloc_call_blk_driver extern _reloc_call_clk_driver - extern _TEXT_DGROUP:wrt TGROUP + extern _TEXT_DGROUP:wrt LGROUP ;--------------------------------------------------- ; @@ -81,7 +81,7 @@ segment _IO_FIXED_DATA ; global _con_dev _con_dev equ $ - dw _prn_dev,TGROUP + dw _prn_dev,LGROUP dw 8013h ; con device (stdin & stdout) dw GenStrategy dw ConIntr @@ -91,7 +91,7 @@ _con_dev equ $ ; Generic prn device that can be redirected via mode ; global _prn_dev -_prn_dev dw _aux_dev,TGROUP +_prn_dev dw _aux_dev,LGROUP dw 0A040h dw GenStrategy dw PrnIntr @@ -101,7 +101,7 @@ _prn_dev dw _aux_dev,TGROUP ; Generic aux device that can be redirected via mode ; global _aux_dev -_aux_dev dw _Lpt1Dev,TGROUP +_aux_dev dw _Lpt1Dev,LGROUP dw 8000h dw GenStrategy dw AuxIntr @@ -110,17 +110,17 @@ _aux_dev dw _Lpt1Dev,TGROUP ; ; Printer device drivers ; -_Lpt1Dev dw _Lpt2Dev,TGROUP +_Lpt1Dev dw _Lpt2Dev,LGROUP dw 0A040h dw GenStrategy dw Lpt1Intr db 'LPT1 ' -_Lpt2Dev dw _Lpt3Dev,TGROUP +_Lpt2Dev dw _Lpt3Dev,LGROUP dw 0A040h dw GenStrategy dw Lpt2Intr db 'LPT2 ' -_Lpt3Dev dw _Com1Dev,TGROUP +_Lpt3Dev dw _Com1Dev,LGROUP dw 0A040h dw GenStrategy dw Lpt3Intr @@ -129,22 +129,22 @@ _Lpt3Dev dw _Com1Dev,TGROUP ; ; Com device drivers ; -_Com1Dev dw _Com2Dev,TGROUP +_Com1Dev dw _Com2Dev,LGROUP dw 8000h dw GenStrategy dw AuxIntr db 'COM1 ' -_Com2Dev dw _Com3Dev,TGROUP +_Com2Dev dw _Com3Dev,LGROUP dw 8000h dw GenStrategy dw Com2Intr db 'COM2 ' -_Com3Dev dw _Com4Dev,TGROUP +_Com3Dev dw _Com4Dev,LGROUP dw 8000h dw GenStrategy dw Com3Intr db 'COM3 ' -_Com4Dev dw _clk_dev,TGROUP +_Com4Dev dw _clk_dev,LGROUP dw 8000h dw GenStrategy dw Com4Intr @@ -155,7 +155,7 @@ _Com4Dev dw _clk_dev,TGROUP ; global _clk_dev _clk_dev equ $ - dw _blk_dev,TGROUP + dw _blk_dev,LGROUP dw 8008h ; clock device dw GenStrategy dw clk_entry @@ -596,19 +596,3 @@ clk_and_blk_common: pop bx popf retf - -; Log: io.asm,v -; Revision 1.3 2000/03/09 06:07:11 kernel -; 2017f updates by James Tabor -; -; Revision 1.2 1999/08/10 17:57:12 jprice -; ror4 2011-02 patch -; -; Revision 1.1.1.1 1999/03/29 15:41:07 jprice -; New version without IPL.SYS -; -; Revision 1.1 1999/02/08 05:55:57 jprice -; Added Pat's 1937 kernel patches -; -; EndLog -; diff --git a/kernel/io.inc b/kernel/io.inc index b0afcd7c..5ab1984d 100644 --- a/kernel/io.inc +++ b/kernel/io.inc @@ -49,30 +49,12 @@ %define E_FAILURE 12 ; General Failure - extern _IOExit:wrt TGROUP - extern _IOSuccess:wrt TGROUP - extern _IOErrorExit:wrt TGROUP - extern _IOErrCnt:wrt TGROUP - extern _IODone:wrt TGROUP - extern _IOCommandError:wrt TGROUP - extern GetUnitNum:wrt TGROUP - extern _ReqPktPtr:wrt TGROUP -; Log: io.inc,v -; -; Revision 1.3 1999/08/10 17:57:12 jprice -; ror4 2011-02 patch -; -; Revision 1.2 1999/03/29 17:05:09 jprice -; ror4 changes -; -; Revision 1.1.1.1 1999/03/29 15:41:08 jprice -; New version without IPL.SYS -; -; Revision 1.1 1999/02/08 05:55:57 jprice -; Added Pat's 1937 kernel patches -; -; -; Rev 1.0 06 Dec 1998 8:13:02 patv -; Initial revision. -; EndLog -; + extern _IOExit:wrt LGROUP + extern _IOSuccess:wrt LGROUP + extern _IOErrorExit:wrt LGROUP + extern _IOErrCnt:wrt LGROUP + extern _IODone:wrt LGROUP + extern _IOCommandError:wrt LGROUP + extern GetUnitNum:wrt LGROUP + extern _ReqPktPtr:wrt LGROUP + diff --git a/kernel/ioctl.c b/kernel/ioctl.c index c4937e4a..9dec3721 100644 --- a/kernel/ioctl.c +++ b/kernel/ioctl.c @@ -339,55 +339,3 @@ COUNT DosDevIOctl(lregs * r) return SUCCESS; } -/* - * Log: ioctl.c,v - for newer log entries do "cvs log ioctl.c" - * - * Revision 1.4 2000/04/29 05:13:16 jtabor - * Added new functions and clean up code - * - * Revision 1.3 2000/03/09 06:07:11 kernel - * 2017f updates by James Tabor - * - * Revision 1.2 1999/04/04 18:51:43 jprice - * no message - * - * Revision 1.1.1.1 1999/03/29 15:41:09 jprice - * New version without IPL.SYS - * - * Revision 1.4 1999/02/08 05:55:57 jprice - * Added Pat's 1937 kernel patches - * - * Revision 1.3 1999/02/01 01:48:41 jprice - * Clean up; Now you can use hex numbers in config.sys. added config.sys screen function to change screen mode (28 or 43/50 lines) - * - * Revision 1.2 1999/01/22 04:13:26 jprice - * Formating - * - * Revision 1.1.1.1 1999/01/20 05:51:01 jprice - * Imported sources - * - * - * Rev 1.7 06 Dec 1998 8:48:22 patv - * Expanded due to new I/O subsystem. - * - * Rev 1.6 11 Jan 1998 2:06:22 patv - * Added functionality to ioctl. - * - * Rev 1.5 04 Jan 1998 23:15:18 patv - * Changed Log for strip utility - * - * Rev 1.4 16 Jan 1997 12:46:54 patv - * pre-Release 0.92 feature additions - * - * Rev 1.3 29 May 1996 21:03:30 patv - * bug fixes for v0.91a - * - * Rev 1.2 19 Feb 1996 3:21:34 patv - * Added NLS, int2f and config.sys processing - * - * Rev 1.1 01 Sep 1995 17:54:16 patv - * First GPL release. - * - * Rev 1.0 02 Jul 1995 8:32:04 patv - * Initial revision. - */ diff --git a/kernel/irqstack.asm b/kernel/irqstack.asm index d40d9129..077f5738 100644 --- a/kernel/irqstack.asm +++ b/kernel/irqstack.asm @@ -30,9 +30,9 @@ ; Code for stack switching during hardware interrupts. -group TGROUP _TEXT +group LGROUP _LOWTEXT -segment _TEXT class=CODE +segment _LOWTEXT class=LCODE old_vectors times 16 dd 0 stack_size dw 0 @@ -168,7 +168,7 @@ _init_stacks: push si - mov ax,_TEXT + mov ax,_LOWTEXT mov ds,ax mov bx, [bp+4] @@ -187,7 +187,7 @@ _init_stacks: xor ax, ax mov ds, ax - mov ax, _TEXT + mov ax, _LOWTEXT mov es, ax mov di, old_vectors @@ -221,44 +221,10 @@ set_vect: set_next: mov ax, dx cli stosw - mov ax, _TEXT + mov ax, _LOWTEXT stosw sti add dx, irq_1 - irq_0 loop set_next ret - -; Log: irqstack.asm,v -; Revision 1.3 1999/08/10 17:57:13 jprice -; ror4 2011-02 patch -; -; Revision 1.2 1999/04/16 12:21:22 jprice -; Steffen c-break handler changes -; -; Revision 1.1.1.1 1999/03/29 15:41:10 jprice -; New version without IPL.SYS -; -; Revision 1.4 1999/02/08 05:55:57 jprice -; Added Pat's 1937 kernel patches -; -; Revision 1.3 1999/02/01 01:48:41 jprice -; Clean up; Now you can use hex numbers in config.sys. added config.sys screen function to change screen mode (28 or 43/50 lines) -; -; Revision 1.2 1999/01/22 04:13:26 jprice -; Formating -; -; Revision 1.1.1.1 1999/01/20 05:51:01 jprice -; Imported sources -; -; -; Rev 1.2 06 Dec 1998 8:49:08 patv -; Bug fixes. -; -; Rev 1.1 22 Jan 1997 13:15:34 patv -; pre-0.92 Svante Frey bug fixes -; -; Rev 1.0 16 Jan 1997 21:43:44 patv -; Initial revision. -; EndLog -; diff --git a/kernel/kernel.asm b/kernel/kernel.asm index 655c50dc..d40073c6 100644 --- a/kernel/kernel.asm +++ b/kernel/kernel.asm @@ -34,7 +34,7 @@ segment PSP - extern _ReqPktPtr:wrt TGROUP + extern _ReqPktPtr:wrt LGROUP STACK_SIZE equ 384/2 ; stack allocated in words @@ -300,7 +300,7 @@ _nblkdev db 0 ; 0020 number of block devices _lastdrive db 0 ; 0021 value of last drive global _nul_dev _nul_dev: ; 0022 device chain root - extern _con_dev:wrt TGROUP + extern _con_dev:wrt LGROUP dw _con_dev, seg _con_dev ; next is con_dev at init time. dw 8004h ; attributes = char device, NUL bit set @@ -329,12 +329,11 @@ _BootDrive db 1 ; 0043 drive we booted from buf_info: global _firstbuf _firstbuf dd 0 ; 0047 disk buffer chain - dw 0 ; 004B 0 (DOS 4 = # hashing chains) + dw 0 ; 004B Number of dirty buffers dd 0 ; 004D pre-read buffer - dw 0 ; 0051 # of sectors + dw 0 ; 0051 number of look-ahead buffers db 0 ; 0053 00=conv 01=HMA - dw 0 ; 0054 deblock buf in conv -deblock_seg dw 0 ; 0056 (offset always zero) +deblock_buf dd 0 ; 0054 deblock buffer times 3 db 0 ; 0058 unknown dw 0 ; 005B unknown db 0, 0FFh, 0 ; 005D unknown @@ -574,7 +573,7 @@ _prev_user_r: prev_int21regs_off dw 0 ;2D0 - pointer to prev int 21 frame prev_int21regs_seg dw 0 - ; Pad to 02ddh + ; Pad to 05fdh times (2ddh - ($ - _internal_data)) db 0 global _ext_open_action global _ext_open_attrib @@ -654,6 +653,10 @@ blk_stk_top: global clk_stk_top times 64 dw 0 clk_stk_top: + +; have a jump to the real thing here for AARD compliance + global _CharMapSrvc ; in _DATA (see AARD) +_CharMapSrvc: jmp far CharMapSrvc2 ; Dynamic data: ; member of the DOS DATA GROUP @@ -701,7 +704,7 @@ __HMATextStart: ; the HMA area is filled with 1eh+3(=sizeof VDISK) = 33 byte dummy data, ; so nothing will ever be below 0xffff:0031 ; -segment HMA_TEXT +segment _TEXT begin_hma: times 10h db 0 ; filler [ffff:0..ffff:10] times 20h db 0 @@ -733,7 +736,7 @@ segment _STACK class=STACK stack -segment _TEXT +segment _LOWTEXT ; dummy interrupt return handlers global _int22_handler @@ -753,7 +756,7 @@ _DGROUP_: dw DGROUP -segment _TEXT +segment _LOWTEXT global _initforceEnableA20 initforceEnableA20: @@ -821,13 +824,13 @@ _reloc_call_clk_driver: jmp far _clk_driver call near forceEnableA20 - global _CharMapSrvc +; global _CharMapSrvc ; in _DATA (see AARD) extern _reloc_call_CharMapSrvc -_CharMapSrvc: jmp far _reloc_call_CharMapSrvc +CharMapSrvc2: jmp far _reloc_call_CharMapSrvc call near forceEnableA20 - - global __HMARelocationTableEnd + + global __HMARelocationTableEnd __HMARelocationTableEnd: ; @@ -928,7 +931,7 @@ noNeedToDisable: iret -segment _TEXT +segment _LOWTEXT ; ; Default Int 24h handler -- always returns fail ; so we have not to relocate it (now) @@ -943,7 +946,7 @@ _int24_handler: mov al,FAIL ; this makes some things easier ; -segment _TEXT +segment _LOWTEXT global _TEXT_DGROUP _TEXT_DGROUP dw DGROUP @@ -951,71 +954,3 @@ segment INIT_TEXT global _INIT_DGROUP _INIT_DGROUP dw DGROUP - -; Log: kernel.asm,v -; Revision 1.6 2000/03/09 06:07:11 kernel -; 2017f updates by James Tabor -; -; Revision 1.5 1999/09/23 04:40:47 jprice -; *** empty log message *** -; -; Revision 1.3 1999/08/10 17:57:13 jprice -; ror4 2011-02 patch -; -; Revision 1.2 1999/04/13 15:52:57 jprice -; changes for boot loader -; -; Revision 1.1.1.1 1999/03/29 15:41:14 jprice -; New version without IPL.SYS -; -; Revision 1.4 1999/02/08 05:55:57 jprice -; Added Pat's 1937 kernel patches -; -; Revision 1.3 1999/02/01 01:48:41 jprice -; Clean up; Now you can use hex numbers in config.sys. added config.sys screen function to change screen mode (28 or 43/50 lines) -; -; Revision 1.2 1999/01/22 04:13:26 jprice -; Formating -; -; Revision 1.1.1.1 1999/01/20 05:51:01 jprice -; Imported sources -; -; Rev 1.11 06 Dec 1998 8:48:04 patv -;Bug fixes. -; -; Rev 1.10 03 Feb 1998 23:30:08 patv -;Added a start-up stack for loadable device drivers. Need the separate -;stack so that all int 21h functions can be called. -; -; Rev 1.9 22 Jan 1998 4:09:24 patv -;Fixed pointer problems affecting SDA -; -; Rev 1.8 06 Jan 1998 20:12:32 patv -;Reduced device driver stack sizes. -; -; Rev 1.7 04 Jan 1998 17:26:18 patv -;Corrected subdirectory bug -; -; Rev 1.6 03 Jan 1998 8:36:50 patv -;Converted data area to SDA format -; -; Rev 1.5 06 Feb 1997 22:43:18 patv -;Reduced stack sizes for block and clock devices. -; -; Rev 1.4 06 Feb 1997 19:05:48 patv -;Added hooks for tsc command -; -; Rev 1.3 29 May 1996 21:03:44 patv -;bug fixes for v0.91a -; -; Rev 1.2 19 Feb 1996 3:24:06 patv -;Added NLS, int2f and config.sys processing -; -; Rev 1.1 01 Sep 1995 17:54:24 patv -;First GPL release. -; -; Rev 1.0 02 Jul 1995 9:05:44 patv -;Initial revision. -; -; EndLog -; diff --git a/kernel/main.c b/kernel/main.c index 0c50120b..b40b9390 100644 --- a/kernel/main.c +++ b/kernel/main.c @@ -93,6 +93,8 @@ STATIC VOID kernel(VOID); STATIC VOID FsConfig(VOID); STATIC VOID InitPrinters(VOID); +extern void Init_clk_driver(void); + #ifdef _MSC_VER BYTE _acrtused = 0; #endif @@ -252,6 +254,8 @@ STATIC void init_kernel(void) init_PSPSet(DOS_PSP); init_PSPInit(DOS_PSP); + Init_clk_driver(); + /* Do first initialization of system variable buffers so that */ /* we can read config.sys later. */ lastdrive = Config.cfgLastdrive; @@ -634,95 +638,3 @@ STATIC VOID InitPrinters(VOID) } } -/* - * Log: main.c,v - for newer log entries do "cvs log main.c" - * - * Revision 1.14 2000/03/31 05:40:09 jtabor - * Added Eric W. Biederman Patches - * - * Revision 1.13 2000/03/09 06:07:11 kernel - * 2017f updates by James Tabor - * - * Revision 1.12 1999/09/23 04:40:48 jprice - * *** empty log message *** - * - * Revision 1.10 1999/08/25 03:18:09 jprice - * ror4 patches to allow TC 2.01 compile. - * - * Revision 1.9 1999/04/16 21:43:40 jprice - * ror4 multi-sector IO - * - * Revision 1.8 1999/04/16 12:21:22 jprice - * Steffen c-break handler changes - * - * Revision 1.7 1999/04/16 00:53:33 jprice - * Optimized FAT handling - * - * Revision 1.6 1999/04/12 03:21:17 jprice - * more ror4 patches. Changes for multi-block IO - * - * Revision 1.5 1999/04/11 04:33:39 jprice - * ror4 patches - * - * Revision 1.3 1999/04/04 22:57:47 jprice - * no message - * - * Revision 1.2 1999/04/04 18:51:43 jprice - * no message - * - * Revision 1.1.1.1 1999/03/29 15:41:18 jprice - * New version without IPL.SYS - * - * Revision 1.5 1999/02/08 05:55:57 jprice - * Added Pat's 1937 kernel patches - * - * Revision 1.4 1999/02/01 01:48:41 jprice - * Clean up; Now you can use hex numbers in config.sys. added config.sys screen function to change screen mode (28 or 43/50 lines) - * - * Revision 1.3 1999/01/30 08:28:12 jprice - * Clean up; Fixed bug with set attribute function. - * - * Revision 1.2 1999/01/22 04:13:26 jprice - * Formating - * - * Revision 1.1.1.1 1999/01/20 05:51:01 jprice - * Imported sources - * - * - * Rev 1.12 06 Dec 1998 8:45:30 patv - * Changed due to new I/O subsystem. - * - * Rev 1.11 22 Jan 1998 4:09:24 patv - * Fixed pointer problems affecting SDA - * - * Rev 1.10 04 Jan 1998 23:15:20 patv - * Changed Log for strip utility - * - * Rev 1.9 04 Jan 1998 17:26:16 patv - * Corrected subdirectory bug - * - * Rev 1.8 03 Jan 1998 8:36:48 patv - * Converted data area to SDA format - * - * Rev 1.7 06 Feb 1997 21:35:46 patv - * Modified to support new version format and changed debug message to - * output drive letter instead of number. - * - * Rev 1.6 22 Jan 1997 13:05:02 patv - * Now does correct default drive initialization. - * - * Rev 1.5 16 Jan 1997 12:47:00 patv - * pre-Release 0.92 feature additions - * - * Rev 1.3 29 May 1996 21:03:32 patv - * bug fixes for v0.91a - * - * Rev 1.2 19 Feb 1996 3:21:36 patv - * Added NLS, int2f and config.sys processing - * - * Rev 1.1 01 Sep 1995 17:54:18 patv - * First GPL release. - * - * Rev 1.0 02 Jul 1995 8:33:18 patv - * Initial revision. - */ diff --git a/kernel/makefile b/kernel/makefile index 97cceeac..e2e07ddb 100644 --- a/kernel/makefile +++ b/kernel/makefile @@ -45,6 +45,7 @@ EXE_dependencies = \ dosnames.obj \ dsk.obj \ initdisk.obj \ + initclk.obj \ entry.obj \ error.obj \ execrh.obj \ @@ -108,7 +109,7 @@ kernel.res: $(EXE_dependencies) $(LIBS) -$(RM) kernel.res ..\utils\echoto kernel.res kernel.obj iprf.obj+ ..\utils\echoto kernel.res entry.obj io.obj blockio.obj chario.obj dosfns.obj console.obj+ - ..\utils\echoto kernel.res printer.obj serial.obj dsk.obj initdisk.obj error.obj fatdir.obj fatfs.obj+ + ..\utils\echoto kernel.res printer.obj serial.obj dsk.obj initdisk.obj initclk.obj error.obj fatdir.obj fatfs.obj+ ..\utils\echoto kernel.res fattab.obj fcbfns.obj initoem.obj initHMA.obj inthndlr.obj ioctl.obj nls_hc.obj+ ..\utils\echoto kernel.res main.obj config.obj memmgr.obj misc.obj newstuff.obj nls.obj intr.obj+ ..\utils\echoto kernel.res dosnames.obj prf.obj strings.obj network.obj sysclk.obj syspack.obj+ @@ -253,101 +254,11 @@ initdisk.obj: initdisk.c $(INITHEADERS) $(HEADERS) $(CONFIGURATION) $(CC) $(INITCFLAGS) $*.c $(INITPATCH) $*.obj +initclk.obj: initclk.c $(INITHEADERS) $(HEADERS) $(CONFIGURATION) + $(CC) $(INITCFLAGS) $*.c + $(INITPATCH) $*.obj + #the printf for INIT_TEXT - yet another special case, this file includes prf.c iprf.obj: iprf.c prf.c $(HDR)\portab.h $(CONFIGURATION) $(CC) $(INITCFLAGS) $*.c $(INITPATCH) $*.obj - -# Log: makefile,v -# -# Revision 1.14 2000/03/31 05:40:09 jtabor -# Added Eric W. Biederman Patches -# -# Revision 1.13 2000/03/17 22:59:04 kernel -# Steffen Kaiser's NLS changes -# -# Revision 1.12 2000/03/09 06:07:11 kernel -# 2017f updates by James Tabor -# -# Revision 1.11 1999/09/23 04:40:47 jprice -# *** empty log message *** -# -# Revision 1.8 1999/09/13 20:41:41 jprice -# Some clean up. -# -# Revision 1.7 1999/08/25 03:18:09 jprice -# ror4 patches to allow TC 2.01 compile. -# -# Revision 1.6 1999/08/10 17:57:13 jprice -# ror4 2011-02 patch -# -# Revision 1.5 1999/04/23 04:25:15 jprice -# no message -# -# Revision 1.4 1999/04/23 03:45:11 jprice -# Improved by jprice -# -# Revision 1.3 1999/04/16 12:21:22 jprice -# Steffen c-break handler changes -# -# Revision 1.2 1999/04/13 15:48:21 jprice -# no message -# -# Revision 1.1.1.1 1999/03/29 15:41:15 jprice -# New version without IPL.SYS -# -# Revision 1.7 1999/03/01 06:04:37 jprice -# Fixed so it'll work with config.mak -# -# Revision 1.6 1999/03/01 05:46:43 jprice -# Turned off DEBUG define. -# -# Revision 1.5 1999/02/09 04:49:43 jprice -# Make makefile use common config.mak file -# -# Revision 1.4 1999/02/08 05:55:57 jprice -# Added Pat's 1937 kernel patches -# -# Revision 1.3 1999/02/04 03:09:59 jprice -# Added option to share constants (-d). -# -# Revision 1.2 1999/01/22 04:13:26 jprice -# Formating -# -# Revision 1.1.1.1 1999/01/20 05:51:01 jprice -# Imported sources -# -# -# Rev 1.8.1 10 Jan 1999 SRM -#Took out "/P-" from TLINK -#Changed "bcc" to "tcc" -# -# Rev 1.9 06 Dec 1998 8:45:40 patv -#Added new files for I/O subsystem. -# -# Rev 1.8 22 Jan 1998 14:50:06 patv -#Outdated stacks.asm. -# -# Rev 1.6 03 Jan 1998 8:36:50 patv -#Converted data area to SDA format -# -# Rev 1.5 30 Jan 1997 7:55:54 patv -#Added TSC flag for trace support. -# -# Rev 1.4 16 Jan 1997 12:46:42 patv -#pre-Release 0.92 feature additions -# -# Rev 1.3 29 Aug 1996 13:07:34 patv -#Bug fixes for v0.91b -# -# Rev 1.2 29 May 1996 21:03:32 patv -#bug fixes for v0.91a -# -# Rev 1.1 19 Feb 1996 3:35:38 patv -#Added NLS, int2f and config.sys processing -# -# Rev 1.0 02 Jul 1995 8:30:22 patv -#Initial revision. -# -# EndLog -# diff --git a/kernel/memmgr.c b/kernel/memmgr.c index b8ff513a..76ad9a8d 100644 --- a/kernel/memmgr.c +++ b/kernel/memmgr.c @@ -601,52 +601,3 @@ VOID DosUmbLink(BYTE n) #endif -/* - * Log: memmgr.c,v - for newer log entries do "cvs log memmgr.c" - * - * Revision 1.4 2000/03/09 06:07:11 kernel - * 2017f updates by James Tabor - * - * Revision 1.3 1999/08/25 03:18:09 jprice - * ror4 patches to allow TC 2.01 compile. - * - * Revision 1.2 1999/04/23 04:24:39 jprice - * Memory manager changes made by ska - * - * Revision 1.1.1.1 1999/03/29 15:41:20 jprice - * New version without IPL.SYS - * - * Revision 1.4 1999/02/08 05:55:57 jprice - * Added Pat's 1937 kernel patches - * - * Revision 1.3 1999/02/01 01:48:41 jprice - * Clean up; Now you can use hex numbers in config.sys. added config.sys screen function to change screen mode (28 or 43/50 lines) - * - * Revision 1.2 1999/01/22 04:13:26 jprice - * Formating - * - * Revision 1.1.1.1 1999/01/20 05:51:01 jprice - * Imported sources - * - * - * Rev 1.6 04 Jan 1998 23:15:18 patv - * Changed Log for strip utility - * - * Rev 1.5 16 Jan 1997 12:47:00 patv - * pre-Release 0.92 feature additions - * - * Rev 1.4 29 May 1996 21:03:34 patv - * bug fixes for v0.91a - * - * Rev 1.3 19 Feb 1996 3:21:36 patv - * Added NLS, int2f and config.sys processing - * - * Rev 1.2 01 Sep 1995 17:54:20 patv - * First GPL release. - * - * Rev 1.1 30 Jul 1995 20:51:58 patv - * Eliminated version strings in ipl - * - * Rev 1.0 02 Jul 1995 8:33:08 patv - * Initial revision. - */ diff --git a/kernel/misc.c b/kernel/misc.c index e056a702..d76a4d58 100644 --- a/kernel/misc.c +++ b/kernel/misc.c @@ -84,46 +84,3 @@ VOID fmemset(REG VOID FAR * s, REG int ch, REG size_t n) #endif -/* - * Log: misc.c,v - for newer entries see "cvs log misc.c" - * - * Revision 1.4 2000/03/09 06:07:11 kernel - * 2017f updates by James Tabor - * - * Revision 1.3 1999/05/03 06:25:45 jprice - * Patches from ror4 and many changed of signed to unsigned variables. - * - * Revision 1.2 1999/04/23 04:24:39 jprice - * Memory manager changes made by ska - * - * Revision 1.1.1.1 1999/03/29 15:42:19 jprice - * New version without IPL.SYS - * - * Revision 1.3 1999/02/01 01:43:28 jprice - * Fixed findfirst function to find volume label with Windows long filenames - * - * Revision 1.2 1999/01/22 04:15:28 jprice - * Formating - * - * Revision 1.1.1.1 1999/01/20 05:51:00 jprice - * Imported sources - * - * - * Rev 1.5 04 Jan 1998 23:14:36 patv - * Changed Log for strip utility - * - * Rev 1.4 29 May 1996 21:15:18 patv - * bug fixes for v0.91a - * - * Rev 1.3 19 Feb 1996 3:20:12 patv - * Added NLS, int2f and config.sys processing - * - * Rev 1.2 01 Sep 1995 17:48:46 patv - * First GPL release. - * - * Rev 1.1 30 Jul 1995 20:50:28 patv - * Eliminated version strings in ipl - * - * Rev 1.0 02 Jul 1995 8:06:28 patv - * Initial revision. - */ diff --git a/kernel/network.c b/kernel/network.c index e411048b..094299af 100644 --- a/kernel/network.c +++ b/kernel/network.c @@ -51,19 +51,3 @@ VOID set_machine_name(BYTE FAR * netname, UWORD name_num) net_set_count++; } -/* - * Log: network.c,v - for newer entries see "cvs log network.c" - * - * Revision 1.5 2000/03/31 05:40:09 jtabor - * Added Eric W. Biederman Patches - * - * Revision 1.4 2000/03/17 22:59:04 kernel - * Steffen Kaiser's NLS changes - * - * Revision 1.3 2000/03/09 06:07:11 kernel - * 2017f updates by James Tabor - * - * Revision 1.2 1999/09/23 04:40:48 jprice - * *** empty log message *** - * - */ diff --git a/kernel/newstuff.c b/kernel/newstuff.c index 325bc19d..b6b20a4a 100644 --- a/kernel/newstuff.c +++ b/kernel/newstuff.c @@ -696,55 +696,3 @@ written on command line, the same applied to "con\0", a device driver. #endif -/* - * Log: newstuff.c,v - for newer entries see "cvs log newstuff.c" - * - * Revision 1.8 2000/04/02 06:11:35 jtabor - * Fix ChgDir Code - * - * Revision 1.7 2000/04/02 05:30:48 jtabor - * Fix ChgDir Code - * - * Revision 1.6 2000/03/31 05:40:09 jtabor - * Added Eric W. Biederman Patches - * - * Revision 1.5 2000/03/09 06:07:11 kernel - * 2017f updates by James Tabor - * - * Revision 1.4 1999/08/25 03:18:09 jprice - * ror4 patches to allow TC 2.01 compile. - * - * Revision 1.3 1999/04/11 04:33:39 jprice - * ror4 patches - * - * Revision 1.2 1999/04/04 18:51:43 jprice - * no message - * - * Revision 1.1.1.1 1999/03/29 15:41:22 jprice - * New version without IPL.SYS - * - * Revision 1.4 1999/02/08 05:55:57 jprice - * Added Pat's 1937 kernel patches - * - * Revision 1.3 1999/02/01 01:48:41 jprice - * Clean up; Now you can use hex numbers in config.sys. added config.sys screen function to change screen mode (28 or 43/50 lines) - * - * Revision 1.2 1999/01/22 04:13:26 jprice - * Formating - * - * Revision 1.1.1.1 1999/01/20 05:51:01 jprice - * Imported sources - * - * - * Rev 1.4 06 Dec 1998 8:49:02 patv - * Bug fixes. - * - * Rev 1.3 04 Jan 1998 23:15:22 patv - * Changed Log for strip utility - * - * Rev 1.2 04 Jan 1998 17:26:14 patv - * Corrected subdirectory bug - * - * Rev 1.1 22 Jan 1997 13:21:22 patv - * pre-0.92 Svante Frey bug fixes. - */ diff --git a/kernel/nls.c b/kernel/nls.c index 0736abf6..5b8b7f32 100644 --- a/kernel/nls.c +++ b/kernel/nls.c @@ -131,6 +131,7 @@ COUNT muxLoadPkg(UWORD cp, UWORD cntry) /* 0x14FF == installed */ r.BX = 0; /* make sure the NLSFUNC ID is updated */ + r.CX = NLS_FREEDOS_NLSFUNC_ID; if (muxGo(0, &r) != 0x14ff) return DE_FILENOTFND; /* No NLSFUNC --> no load */ if (r.BX != NLS_FREEDOS_NLSFUNC_ID) /* FreeDOS NLSFUNC will return */ @@ -676,10 +677,3 @@ UWORD ASMCFUNC syscall_MUX14(DIRECT_IREGS) return DE_INVLDFUNC; /* no such function */ } -/* - * Log: nls.c,v - for newer log entries see "cvs log nls.c" - * - * Revision 1.1 2000/03/23 02:44:21 ska - * Initial revision - * - */ diff --git a/kernel/nls_hc.asm b/kernel/nls_hc.asm index c511443c..adf04bc9 100644 --- a/kernel/nls_hc.asm +++ b/kernel/nls_hc.asm @@ -30,7 +30,7 @@ _nlsCountryInfoHardcoded: DB 01ch, 000h, 001h, 000h, 0b5h, 001h, 000h, 000h DB 024h, 000h, 000h, 000h, 000h, 02ch, 000h, 02eh DB 000h, 02dh, 000h, 03ah, 000h, 000h, 002h, 000h -extern _CharMapSrvc:wrt TGROUP +extern _CharMapSrvc:wrt DGROUP DW _CharMapSrvc, SEG _CharMapSrvc DB 02ch, 000h GLOBAL _hcTablesStart diff --git a/kernel/nls_load.c b/kernel/nls_load.c index 6ab83106..16d5122c 100644 --- a/kernel/nls_load.c +++ b/kernel/nls_load.c @@ -30,7 +30,6 @@ #include "portab.h" #include "init-mod.h" -//#include "pcb.h" #ifdef VERSION_STRINGS static BYTE *RcsId = @@ -407,10 +406,3 @@ BOOL LoadCountryInfo(char *fnam) return 0; } -/* - * Log: nls_load.c,v for newer entries do "cvs log nls_load.c" - * - * Revision 1.1 2000/08/06 05:50:17 jimtabor - * Add new files and update cvs with patches and changes - * - */ diff --git a/kernel/nlssupt.asm b/kernel/nlssupt.asm index 50e1df5e..284bbe91 100644 --- a/kernel/nlssupt.asm +++ b/kernel/nlssupt.asm @@ -30,9 +30,9 @@ %include "segs.inc" -segment HMA_TEXT +segment _TEXT global _reloc_call_CharMapSrvc - extern _DosUpChar:wrt HGROUP + extern _DosUpChar:wrt TGROUP ; ; CharMapSrvc: ; User callable character mapping service. @@ -72,39 +72,3 @@ _reloc_call_CharMapSrvc: pop ds Restore386Registers retf ; Return far -; Log: nlssupt.asm,v -; -; Revision 1.3 2000/03/17 22:59:04 kernel -; Steffen Kaiser's NLS changes -; -; Revision 1.2 1999/08/10 17:57:13 jprice -; ror4 2011-02 patch -; -; Revision 1.1.1.1 1999/03/29 15:41:25 jprice -; New version without IPL.SYS -; -; Revision 1.4 1999/02/08 05:55:57 jprice -; Added Pat's 1937 kernel patches -; -; Revision 1.3 1999/02/01 01:48:41 jprice -; Clean up; Now you can use hex numbers in config.sys. added config.sys screen function to change screen mode (28 or 43/50 lines) -; -; Revision 1.2 1999/01/22 04:13:26 jprice -; Formating -; -; Revision 1.1.1.1 1999/01/20 05:51:01 jprice -; Imported sources -; -; Rev 1.3 06 Dec 1998 8:46:56 patv -; Bug fixes. -; -; Rev 1.2 16 Jan 1997 12:46:44 patv -; pre-Release 0.92 feature additions -; -; Rev 1.1 29 May 1996 21:03:38 patv -; bug fixes for v0.91a -; -; Rev 1.0 19 Feb 1996 3:24:04 patv -; Added NLS, int2f and config.sys processing -; EndLog -; diff --git a/kernel/prf.c b/kernel/prf.c index 647f535d..48944c24 100644 --- a/kernel/prf.c +++ b/kernel/prf.c @@ -58,7 +58,6 @@ static char buff[MAX_BUFSIZE]; #define printf init_printf #define sprintf init_sprintf #define charp init_charp -#define hexDigits init_hexDigits #endif #ifdef VERSION_STRINGS @@ -564,43 +563,3 @@ main() } #endif -/* - * Log: prf.c,v - see "cvs log prf.c" for newer entries - * - * Revision 1.4 2001/03/07 10:00:00 tomehlert - * recoded for smaller object footprint, added main() for testing+QA - * - * Revision 1.3 2000/03/09 06:07:11 kernel - * 2017f updates by James Tabor - * - * Revision 1.2 1999/04/04 18:51:43 jprice - * no message - * - * Revision 1.1.1.1 1999/03/29 15:42:20 jprice - * New version without IPL.SYS - * - * Revision 1.3 1999/02/01 01:43:28 jprice - * Fixed findfirst function to find volume label with Windows long filenames - * - * Revision 1.2 1999/01/22 04:15:28 jprice - * Formating - * - * Revision 1.1.1.1 1999/01/20 05:51:00 jprice - * Imported sources - * - * - * Rev 1.4 04 Jan 1998 23:14:38 patv - * Changed Log for strip utility - * - * Rev 1.3 29 May 1996 21:15:10 patv - * bug fixes for v0.91a - * - * Rev 1.2 01 Sep 1995 17:48:42 patv - * First GPL release. - * - * Rev 1.1 30 Jul 1995 20:50:26 patv - * Eliminated version strings in ipl - * - * Rev 1.0 02 Jul 1995 8:05:10 patv - * Initial revision. - */ diff --git a/kernel/printer.asm b/kernel/printer.asm index f007f18b..c979323b 100644 --- a/kernel/printer.asm +++ b/kernel/printer.asm @@ -242,18 +242,3 @@ PrtGnIoctl3: ; you must not simply print without asking for status ; as the BIOS has a LARGE timeout before aborting ; - -; Log: printer.asm,v -; -; Revision 1.2 1999/08/10 17:57:13 jprice -; ror4 2011-02 patch -; -; Revision 1.1.1.1 1999/03/29 15:41:26 jprice -; New version without IPL.SYS -; -; Revision 1.1 1999/02/08 05:55:57 jprice -; Added Pat's 1937 kernel patches -; -; EndLog -; - diff --git a/kernel/procsupt.asm b/kernel/procsupt.asm index 28d4d6b2..00a77bf7 100644 --- a/kernel/procsupt.asm +++ b/kernel/procsupt.asm @@ -34,13 +34,13 @@ extern _user_r:wrt DGROUP extern _break_flg:wrt DGROUP ; break detected flag - extern _int21_handler:wrt TGROUP ; far call system services + extern _int21_handler:wrt LGROUP ; far call system services %include "stacks.inc" -segment HMA_TEXT +segment _TEXT - extern _DGROUP_:wrt TGROUP + extern _DGROUP_:wrt LGROUP ; ; Special call for switching processes @@ -70,7 +70,7 @@ _exec_user: extern _ExecUserDisableA20 jmp far _ExecUserDisableA20 -segment _TEXT +segment _LOWTEXT ;; Called whenever the BIOS detects a ^Break state @@ -85,7 +85,7 @@ _got_cbreak: pop ds iret -segment HMA_TEXT +segment _TEXT ; ; Special call for switching processes during break handling @@ -273,46 +273,3 @@ _spawn_int23: ; cli ; ret ;_disable endp - -; Log: procsupt.asm,v -; Revision 1.4 1999/08/10 17:57:13 jprice -; ror4 2011-02 patch -; -; Revision 1.3 1999/04/23 22:38:36 jprice -; Fixed got_cbreak function. -; -; Revision 1.2 1999/04/16 12:21:22 jprice -; Steffen c-break handler changes -; -; Revision 1.1.1.1 1999/03/29 15:41:27 jprice -; New version without IPL.SYS -; -; Revision 1.4 1999/02/08 05:55:57 jprice -; Added Pat's 1937 kernel patches -; -; Revision 1.3 1999/02/01 01:48:41 jprice -; Clean up; Now you can use hex numbers in config.sys. added config.sys screen function to change screen mode (28 or 43/50 lines) -; -; Revision 1.2 1999/01/22 04:13:27 jprice -; Formating -; -; Revision 1.1.1.1 1999/01/20 05:51:01 jprice -; Imported sources -; -; Rev 1.4 06 Dec 1998 8:46:44 patv -;Bug fixes. -; -; Rev 1.3 07 Feb 1998 20:42:08 patv -;Modified stack fram to match DOS standard -; -; Rev 1.2 29 May 1996 21:03:36 patv -;bug fixes for v0.91a -; -; Rev 1.1 01 Sep 1995 17:54:24 patv -;First GPL release. -; -; Rev 1.0 02 Jul 1995 9:05:58 patv -;Initial revision. -; EndLog -; - diff --git a/kernel/proto.h b/kernel/proto.h index af1f04fc..791ffc1d 100644 --- a/kernel/proto.h +++ b/kernel/proto.h @@ -34,10 +34,9 @@ static BYTE *Proto_hRcsId = #endif /* blockio.c */ -ULONG getblkno(struct buffer FAR *); -VOID setblkno(struct buffer FAR *, ULONG); -struct buffer FAR *getblock(ULONG blkno, COUNT dsk); -struct buffer FAR *getblockOver(ULONG blkno, COUNT dsk); +struct buffer FAR *getblk(ULONG blkno, COUNT dsk, BOOL overwrite); +#define getblock(blkno, dsk) getblk(blkno, dsk, FALSE); +#define getblockOver(blkno, dsk) getblk(blkno, dsk, TRUE); VOID setinvld(REG COUNT dsk); BOOL flush_buffers(REG COUNT dsk); BOOL flush(void); @@ -391,94 +390,3 @@ VOID ASMCFUNC exec_user(iregs FAR * irp); #define ASSERT_CONST(x) { typedef struct { char _xx[x ? 1 : -1]; } xx ; } -/* - * Log: proto.h,v - * - * Revision 1.17 2000/03/31 05:40:09 jtabor - * Added Eric W. Biederman Patches - * - * Revision 1.16 2000/03/17 22:59:04 kernel - * Steffen Kaiser's NLS changes - * - * Revision 1.15 2000/03/09 06:07:11 kernel - * 2017f updates by James Tabor - * - * Revision 1.14 1999/09/23 04:40:48 jprice - * *** empty log message *** - * - * Revision 1.10 1999/08/25 03:18:09 jprice - * ror4 patches to allow TC 2.01 compile. - * - * Revision 1.9 1999/05/03 06:25:45 jprice - * Patches from ror4 and many changed of signed to unsigned variables. - * - * Revision 1.8 1999/04/23 04:24:39 jprice - * Memory manager changes made by ska - * - * Revision 1.7 1999/04/16 21:43:40 jprice - * ror4 multi-sector IO - * - * Revision 1.6 1999/04/16 12:21:22 jprice - * Steffen c-break handler changes - * - * Revision 1.5 1999/04/12 03:21:17 jprice - * more ror4 patches. Changes for multi-block IO - * - * Revision 1.4 1999/04/11 04:33:39 jprice - * ror4 patches - * - * Revision 1.2 1999/04/04 18:51:43 jprice - * no message - * - * Revision 1.1.1.1 1999/03/29 15:41:30 jprice - * New version without IPL.SYS - * - * Revision 1.4 1999/02/08 05:55:57 jprice - * Added Pat's 1937 kernel patches - * - * Revision 1.3 1999/02/01 01:48:41 jprice - * Clean up; Now you can use hex numbers in config.sys. added config.sys screen function to change screen mode (28 or 43/50 lines) - * - * Revision 1.2 1999/01/22 04:13:27 jprice - * Formating - * - * Revision 1.1.1.1 1999/01/20 05:51:01 jprice - * Imported sources - * - * - * Rev 1.11 06 Dec 1998 8:47:18 patv - *Expanded due to new I/O subsystem. - * - * Rev 1.10 07 Feb 1998 20:38:00 patv - *Modified stack fram to match DOS standard - * - * Rev 1.9 22 Jan 1998 4:09:26 patv - *Fixed pointer problems affecting SDA - * - * Rev 1.8 11 Jan 1998 2:06:22 patv - *Added functionality to ioctl. - * - * Rev 1.7 04 Jan 1998 23:16:22 patv - *Changed Log for strip utility - * - * Rev 1.6 03 Jan 1998 8:36:48 patv - *Converted data area to SDA format - * - * Rev 1.5 16 Jan 1997 12:46:44 patv - *pre-Release 0.92 feature additions - * - * Rev 1.4 29 May 1996 21:03:40 patv - *bug fixes for v0.91a - * - * Rev 1.3 19 Feb 1996 3:23:06 patv - *Added NLS, int2f and config.sys processing - * - * Rev 1.2 01 Sep 1995 17:54:26 patv - *First GPL release. - * - * Rev 1.1 30 Jul 1995 20:51:58 patv - *Eliminated version strings in ipl - * - * Rev 1.0 05 Jul 1995 11:32:16 patv - *Initial revision. - */ diff --git a/kernel/segs.inc b/kernel/segs.inc index 9fdeee2c..6646a18d 100644 --- a/kernel/segs.inc +++ b/kernel/segs.inc @@ -28,15 +28,15 @@ ; group PGROUP PSP -group TGROUP _TEXT _IO_TEXT _IO_FIXED_DATA +group LGROUP _LOWTEXT _IO_TEXT _IO_FIXED_DATA group DGROUP _FIXED_DATA _BSS _DATA _DATAEND CONST CONST2 DCONST DYN_DATA -group I_GROUP INIT_TEXT_START INIT_TEXT INIT_TEXT_END ID_B ID ID_E IC IDATA ICONST ICONST2 I_DATA I_BSS IB_B IB IB_E -group HGROUP HMA_TEXT_START HMA_TEXT HMA_TEXT_END +group I_GROUP INIT_TEXT_START INIT_TEXT INIT_TEXT_END ID_B ID ID_E IC IDATA ICONST ICONST2 I_DATA IB_B I_BSS IB IB_E +group TGROUP HMA_TEXT_START _TEXT HMA_TEXT_END segment PSP class=PSP -segment _TEXT class=CODE -segment _IO_TEXT class=CODE -segment _IO_FIXED_DATA class=CODE align=2 +segment _LOWTEXT class=LCODE +segment _IO_TEXT class=LCODE +segment _IO_FIXED_DATA class=LCODE align=2 segment _FIXED_DATA class=FDATA align=16 segment _BSS class=BSS align=2 segment _DATA class=DATA align=2 @@ -47,9 +47,9 @@ segment CONST2 class=DATA align=2 ;for MSC segment DCONST class=DCONST align=2 segment DYN_DATA class=DYN_DATA -segment HMA_TEXT_START class=HMA align=16 -segment HMA_TEXT class=HMA -segment HMA_TEXT_END class=HMA +segment HMA_TEXT_START class=CODE align=16 +segment _TEXT class=CODE +segment HMA_TEXT_END class=CODE segment INIT_TEXT_START class=INIT align=16 segment INIT_TEXT class=INIT segment INIT_TEXT_END class=INIT @@ -63,25 +63,8 @@ segment IC class=IC align=2 segment ICONST class=FAR_DATA align=2 segment ICONST2 class=FAR_DATA align=2 segment I_DATA class=FAR_DATA align=2 -segment I_BSS class=FAR_DATA align=2 segment IB_B class=IB align=2 +segment I_BSS class=FAR_DATA align=2 segment IB class=IB align=2 segment IB_E class=IB align=2 - -; Log: segs.inc,v -; -; Revision 1.2 1999/08/10 17:57:13 jprice -; ror4 2011-02 patch -; -; Revision 1.1.1.1 1999/03/29 15:41:30 jprice -; New version without IPL.SYS -; -; Revision 1.1 1999/02/08 05:55:57 jprice -; Added Pat's 1937 kernel patches -; -; -; Rev 1.0 06 Dec 1998 8:12:36 patv -; Initial revision. -; EndLog -; diff --git a/kernel/serial.asm b/kernel/serial.asm index 4916f21a..5ae68aca 100644 --- a/kernel/serial.asm +++ b/kernel/serial.asm @@ -50,7 +50,7 @@ ComTable db 0Ah segment _IO_TEXT - extern CommonNdRdExit:wrt TGROUP + extern CommonNdRdExit:wrt LGROUP ComRead: jcxz ComRd3 diff --git a/kernel/strings.c b/kernel/strings.c index 349f9368..6cfc3698 100644 --- a/kernel/strings.c +++ b/kernel/strings.c @@ -154,52 +154,3 @@ void *memchr(const void * s, int c) } #endif -/* - * Log: strings.c,v - see "cvs log strings.c" for newer entries - * - * Revision 1.4 2000/03/09 06:07:11 kernel - * 2017f updates by James Tabor - * - * Revision 1.3 1999/08/25 03:18:09 jprice - * ror4 patches to allow TC 2.01 compile. - * - * Revision 1.2 1999/04/04 18:51:43 jprice - * no message - * - * Revision 1.1.1.1 1999/03/29 15:41:32 jprice - * New version without IPL.SYS - * - * Revision 1.4 1999/02/04 03:14:07 jprice - * Formating. Added comments. - * - * Revision 1.3 1999/02/01 01:48:41 jprice - * Clean up; Now you can use hex numbers in config.sys. added config.sys screen function to change screen mode (28 or 43/50 lines) - * - * Revision 1.2 1999/01/22 04:13:27 jprice - * Formating - * - * Revision 1.1.1.1 1999/01/20 05:51:01 jprice - * Imported sources - * - * - * Rev 1.6 04 Jan 1998 23:15:16 patv - * Changed Log for strip utility - * - * Rev 1.5 31 Dec 1997 3:59:30 patv - * Added new far string functions. - * - * Rev 1.4 29 May 1996 21:03:30 patv - * bug fixes for v0.91a - * - * Rev 1.3 19 Feb 1996 3:21:36 patv - * Added NLS, int2f and config.sys processing - * - * Rev 1.2 01 Sep 1995 17:54:22 patv - * First GPL release. - * - * Rev 1.1 30 Jul 1995 20:51:58 patv - * Eliminated version strings in ipl - * - * Rev 1.0 02 Jul 1995 8:33:46 patv - * Initial revision. - */ diff --git a/kernel/sysclk.c b/kernel/sysclk.c index 6a517a6b..2bf24825 100644 --- a/kernel/sysclk.c +++ b/kernel/sysclk.c @@ -44,12 +44,12 @@ STATIC int ByteToBcd(int x) { return ((x / 10) << 4) | (x % 10); } - +/* STATIC int BcdToByte(int x) { return ((x >> 4) & 0xf) * 10 + (x & 0xf); } - +*/ STATIC void DayToBcd(BYTE * x, unsigned mon, unsigned day, unsigned yr) { x[1] = ByteToBcd(mon); @@ -65,6 +65,8 @@ WORD ASMCFUNC FAR clk_driver(rqptr rp) switch (rp->r_command) { case C_INIT: + +#if 0 /* If AT clock exists, copy AT clock time to system clock */ if (!ReadATClock(bcd_days, &bcd_hours, &bcd_minutes, &bcd_seconds)) { @@ -89,6 +91,7 @@ WORD ASMCFUNC FAR clk_driver(rqptr rp) BcdToByte(bcd_seconds); WritePCClock(seconds * 0x12 + ((seconds * 0x34dc) >> 16)); } +#endif /* rp->r_endaddr = device_end(); not needed - bart */ rp->r_nunits = 0; return S_DONE; @@ -156,14 +159,14 @@ WORD ASMCFUNC FAR clk_driver(rqptr rp) else break; } - + /* Day contains the days left and count the number of */ /* days for that year. Use this to index the table. */ for (Month = 1; Month < 13; ++Month) { if (pdays[Month] > Day) { - Day -= pdays[Month - 1] + 1; + Day = Day - pdays[Month - 1] + 1; break; } } @@ -189,46 +192,3 @@ WORD ASMCFUNC FAR clk_driver(rqptr rp) } } -/* - * Log: sysclk.c,v - for newer entries do "cvs log sysclk.c" - * - * Revision 1.3 2000/03/09 06:07:11 kernel - * 2017f updates by James Tabor - * - * Revision 1.2 1999/04/12 03:21:17 jprice - * more ror4 patches. Changes for multi-block IO - * - * Revision 1.1.1.1 1999/03/29 15:41:33 jprice - * New version without IPL.SYS - * - * Revision 1.5 1999/02/08 05:55:58 jprice - * Added Pat's 1937 kernel patches - * - * Revision 1.4 1999/02/04 03:14:07 jprice - * Formating. Added comments. - * - * Revision 1.3 1999/02/01 01:48:41 jprice - * Clean up; Now you can use hex numbers in config.sys. added config.sys screen function to change screen mode (28 or 43/50 lines) - * - * Revision 1.2 1999/01/22 04:13:27 jprice - * Formating - * - * Revision 1.1.1.1 1999/01/20 05:51:01 jprice - * Imported sources - * - * - * Rev 1.4 04 Jan 1998 23:15:16 patv - * Changed Log for strip utility - * - * Rev 1.3 29 May 1996 21:03:48 patv - * bug fixes for v0.91a - * - * Rev 1.2 19 Feb 1996 3:21:34 patv - * Added NLS, int2f and config.sys processing - * - * Rev 1.1 01 Sep 1995 17:54:18 patv - * First GPL release. - * - * Rev 1.0 02 Jul 1995 8:32:30 patv - * Initial revision. - */ diff --git a/kernel/syspack.c b/kernel/syspack.c index 40b967e4..c1a91248 100644 --- a/kernel/syspack.c +++ b/kernel/syspack.c @@ -121,34 +121,3 @@ VOID putdirent(struct dirent FAR * dp, UBYTE FAR * vp) } #endif -/* - * Log: syspack.c,v - for newer entries see "cvs log syspack.c" - * - * Revision 1.1.1.1 1999/03/29 15:42:21 jprice - * New version without IPL.SYS - * - * Revision 1.3 1999/02/01 01:43:28 jprice - * Fixed findfirst function to find volume label with Windows long filenames - * - * Revision 1.2 1999/01/22 04:15:28 jprice - * Formating - * - * Revision 1.1.1.1 1999/01/20 05:51:00 jprice - * Imported sources - * - * - * Rev 1.4 04 Jan 1998 23:14:38 patv - * Changed Log for strip utility - * - * Rev 1.3 29 May 1996 21:15:12 patv - * bug fixes for v0.91a - * - * Rev 1.2 01 Sep 1995 17:48:42 patv - * First GPL release. - * - * Rev 1.1 30 Jul 1995 20:50:26 patv - * Eliminated version strings in ipl - * - * Rev 1.0 02 Jul 1995 8:05:34 patv - * Initial revision. - */ diff --git a/kernel/systime.c b/kernel/systime.c index ed2e7161..d32e55a2 100644 --- a/kernel/systime.c +++ b/kernel/systime.c @@ -172,52 +172,3 @@ int DosSetDate(const struct dosdate *dd) return SUCCESS; } -/* - * Log: systime.c,v - see "cvs log systime.c" for newer entries - * - * Revision 1.3 1999/05/04 16:40:30 jprice - * ror4 date fix - * - * Revision 1.2 1999/04/12 03:21:18 jprice - * more ror4 patches. Changes for multi-block IO - * - * Revision 1.1.1.1 1999/03/29 15:41:34 jprice - * New version without IPL.SYS - * - * Revision 1.5 1999/02/08 05:55:58 jprice - * Added Pat's 1937 kernel patches - * - * Revision 1.4 1999/02/04 03:14:07 jprice - * Formating. Added comments. - * - * Revision 1.3 1999/02/01 01:48:41 jprice - * Clean up; Now you can use hex numbers in config.sys. added config.sys screen function to change screen mode (28 or 43/50 lines) - * - * Revision 1.2 1999/01/22 04:13:27 jprice - * Formating - * - * Revision 1.1.1.1 1999/01/20 05:51:01 jprice - * Imported sources - * - * - * Rev 1.6 06 Dec 1998 8:47:30 patv - * Bug fixes. - * - * Rev 1.5 04 Jan 1998 23:15:22 patv - * Changed Log for strip utility - * - * Rev 1.4 03 Jan 1998 8:36:50 patv - * Converted data area to SDA format - * - * Rev 1.3 29 May 1996 21:03:40 patv - * bug fixes for v0.91a - * - * Rev 1.2 19 Feb 1996 3:21:34 patv - * Added NLS, int2f and config.sys processing - * - * Rev 1.1 01 Sep 1995 17:54:16 patv - * First GPL release. - * - * Rev 1.0 02 Jul 1995 8:32:20 patv - * Initial revision. - */ diff --git a/kernel/task.c b/kernel/task.c index ecc5dc82..3c3f6c72 100644 --- a/kernel/task.c +++ b/kernel/task.c @@ -320,6 +320,8 @@ int load_transfer(UWORD ds, exec_blk *exp, UWORD fcbcode, COUNT mode) fatal("KERNEL RETURNED!!!"); */ } /* mode == LOAD */ + exp->exec.stack -= 2; + *((UWORD FAR *)(exp->exec.stack)) = fcbcode; return SUCCESS; } @@ -767,91 +769,3 @@ COUNT DosExec(COUNT mode, exec_blk FAR * ep, BYTE FAR * lp) return rc; } -/* - * Log: task.c,v - for newer log entries do "cvs log task.c" - * - * Revision 1.8 2000/03/31 05:40:09 jtabor - * Added Eric W. Biederman Patches - * - * Revision 1.7 2000/03/09 06:07:11 kernel - * 2017f updates by James Tabor - * - * Revision 1.6 1999/08/25 03:18:10 jprice - * ror4 patches to allow TC 2.01 compile. - * - * Revision 1.5 1999/04/23 04:24:39 jprice - * Memory manager changes made by ska - * - * Revision 1.4 1999/04/16 00:53:33 jprice - * Optimized FAT handling - * - * Revision 1.3 1999/04/11 04:33:39 jprice - * ror4 patches - * - * Revision 1.2 1999/03/29 17:05:09 jprice - * ror4 changes - * - * Revision 1.1.1.1 1999/03/29 15:41:41 jprice - * New version without IPL.SYS - * - * Revision 1.5 1999/02/08 05:55:58 jprice - * Added Pat's 1937 kernel patches - * - * Revision 1.4 1999/02/04 03:14:07 jprice - * Formating. Added comments. - * - * Revision 1.3 1999/02/01 01:48:41 jprice - * Clean up; Now you can use hex numbers in config.sys. added config.sys screen function to change screen mode (28 or 43/50 lines) - * - * Revision 1.2 1999/01/22 04:13:27 jprice - * Formating - * - * Revision 1.1.1.1 1999/01/20 05:51:01 jprice - * Imported sources - * - * - * Rev 1.15 06 Dec 1998 8:46:28 patv - * Bug fixes. - * - * Rev 1.14 07 Feb 1998 20:38:32 patv - * Modified stack fram to match DOS standard - * - * Rev 1.13 31 Jan 1998 14:39:20 patv - * Corrected type in load high code. - * - * Rev 1.12 31 Jan 1998 14:02:52 patv - * Added load high in memory option in DosExeLoader. - * - * Rev 1.11 22 Jan 1998 22:17:14 patv - * Eliminated warnings. - * - * Rev 1.10 22 Jan 1998 21:31:36 patv - * Corrected short .COM problem. - * - * Rev 1.9 04 Jan 1998 23:15:16 patv - * Changed Log for strip utility - * - * Rev 1.8 22 Jan 1997 13:18:14 patv - * pre-0.92 Svante Frey bug fixes. - * - * Rev 1.7 16 Jan 1997 12:46:56 patv - * pre-Release 0.92 feature additions - * - * Rev 1.5 29 Aug 1996 13:07:22 patv - * Bug fixes for v0.91b - * - * Rev 1.4 29 May 1996 21:03:36 patv - * bug fixes for v0.91a - * - * Rev 1.3 19 Feb 1996 3:21:48 patv - * Added NLS, int2f and config.sys processing - * - * Rev 1.2 01 Sep 1995 17:54:22 patv - * First GPL release. - * - * Rev 1.1 30 Jul 1995 20:51:58 patv - * Eliminated version strings in ipl - * - * Rev 1.0 02 Jul 1995 8:34:06 patv - * Initial revision. - */ diff --git a/mkfiles/bc5.mak b/mkfiles/bc5.mak index 699dc476..8f448e6e 100644 --- a/mkfiles/bc5.mak +++ b/mkfiles/bc5.mak @@ -50,4 +50,4 @@ MATH_INSERT=+H_LDIV +H_LLSH +H_LURSH +N_LXMUL +F_LXMUL +H_LRSH # ALLCFLAGS=$(TARGETOPT) $(ALLCFLAGS) INITCFLAGS=$(ALLCFLAGS) -zAINIT -zCINIT_TEXT -zDIB -zRID -zTID -zPI_GROUP -zBIB -zGI_GROUP -zSI_GROUP -CFLAGS=$(ALLCFLAGS) -zAHMA -zCHMA_TEXT +CFLAGS=$(ALLCFLAGS) diff --git a/mkfiles/mscl8.mak b/mkfiles/mscl8.mak index 35b21b6b..9c195e53 100644 --- a/mkfiles/mscl8.mak +++ b/mkfiles/mscl8.mak @@ -43,6 +43,6 @@ TARGET=KMS ALLCFLAGS=-I..\hdr $(TARGETOPT) $(ALLCFLAGS) -nologo -Zl -Fc -WX -Gr -f- -Os -Gs -Ob1 -OV4 -Gy -Oe -Zp1 INITCFLAGS=$(ALLCFLAGS) -NTINIT_TEXT -AT -CFLAGS=$(ALLCFLAGS) -NTHMA_TEXT +CFLAGS=$(ALLCFLAGS) INITPATCH = ..\utils\patchobj CODE=INIT _DATA=IDATA DATA=ID BSS=ID DGROUP=I_GROUP CONST=IC -STDPATCH = ..\utils\patchobj CODE=HMA CONST=DCONST +STDPATCH = ..\utils\patchobj CONST=DCONST diff --git a/mkfiles/tc2.mak b/mkfiles/tc2.mak index 121fd0f6..b527c088 100644 --- a/mkfiles/tc2.mak +++ b/mkfiles/tc2.mak @@ -50,4 +50,4 @@ MATH_INSERT=+LDIV +LXMUL +LURSH +LLSH +LRSH # ALLCFLAGS=$(TARGETOPT) $(ALLCFLAGS) INITCFLAGS=$(ALLCFLAGS) -zAINIT -zCINIT_TEXT -zDIB -zRID -zTID -zPI_GROUP -zBIB -zGI_GROUP -zSI_GROUP -CFLAGS=$(ALLCFLAGS) -zAHMA -zCHMA_TEXT +CFLAGS=$(ALLCFLAGS) diff --git a/mkfiles/tc3.mak b/mkfiles/tc3.mak index 22ecbd07..3761f898 100644 --- a/mkfiles/tc3.mak +++ b/mkfiles/tc3.mak @@ -50,4 +50,4 @@ MATH_INSERT=+H_LDIV +H_LLSH +H_LURSH +N_LXMUL +F_LXMUL +H_LRSH # ALLCFLAGS=$(TARGETOPT) $(ALLCFLAGS) INITCFLAGS=$(ALLCFLAGS) -zAINIT -zCINIT_TEXT -zDIB -zRID -zTID -zPI_GROUP -zBIB -zGI_GROUP -zSI_GROUP -CFLAGS=$(ALLCFLAGS) -zAHMA -zCHMA_TEXT +CFLAGS=$(ALLCFLAGS) diff --git a/mkfiles/turbocpp.mak b/mkfiles/turbocpp.mak index 40b382ea..1122f2d1 100644 --- a/mkfiles/turbocpp.mak +++ b/mkfiles/turbocpp.mak @@ -50,4 +50,4 @@ MATH_INSERT=+H_LDIV +F_LXMUL +H_LURSH +H_LLSH +H_LRSH # ALLCFLAGS=$(TARGETOPT) $(ALLCFLAGS) INITCFLAGS=$(ALLCFLAGS) -zAINIT -zCINIT_TEXT -zDIB -zRID -zTID -zPI_GROUP -zBIB -zGI_GROUP -zSI_GROUP -CFLAGS=$(ALLCFLAGS) -zAHMA -zCHMA_TEXT +CFLAGS=$(ALLCFLAGS) diff --git a/mkfiles/watcom.mak b/mkfiles/watcom.mak index 64a83cbe..d4e5ed52 100644 --- a/mkfiles/watcom.mak +++ b/mkfiles/watcom.mak @@ -63,6 +63,6 @@ MATH_INSERT= +i4d +i4m ALLCFLAGS=-I..\hdr $(TARGETOPT) $(ALLCFLAGS)-zq-os-s-e5-j-zl-zp1-wx-we-zgf-zff INITCFLAGS=$(ALLCFLAGS)-ntINIT_TEXT-ncINIT-ndI-gI_GROUP -CFLAGS=$(ALLCFLAGS)-ntHMA_TEXT-ncHMA-gHGROUP +CFLAGS=$(ALLCFLAGS) INITPATCH=..\utils\patchobj __U4D=_IU4D __U4M=_IU4M diff --git a/sys/sys.c b/sys/sys.c index c101c91a..2c69d097 100644 --- a/sys/sys.c +++ b/sys/sys.c @@ -862,3 +862,43 @@ BOOL copy(COUNT drive, BYTE * srcPath, BYTE * rootPath, BYTE * file) return TRUE; } +/* version 2.2 jeremyd 2001/9/20 + Changed so if no source given or only source drive (no path) + given, then checks for kernel.sys & command.com in current + path (of current drive or given drive) and if not there + uses root (but only if source & destination drive are different). + Fix printf to include count(ret) if copy can't write all requested bytes +*/ +/* version 2.1a jeremyd 2001/8/19 + modified so takes optional 2nd parameter (similar to PC DOS) + where if only 1 argument is given, assume to be destination drive, + but if two arguments given, 1st is source (drive and/or path) + and second is destination drive +*/ + +/* Revision 2.1 tomehlert 2001/4/26 + + changed the file system detection code. + + +*/ + +/* Revision 2.0 tomehlert 2001/4/26 + + no direct access to the disk any more, this is FORMAT's job + no floppy.asm anymore, no segmentation problems. + no access to partition tables + + instead copy boot sector using int25/int26 = absdiskread()/write + + if xxDOS is able to handle the disk, SYS should work + + additionally some space savers: + + replaced fopen() by open() + + included (slighly modified) PRF.c from kernel + + size is no ~7500 byte vs. ~13690 before + +*/ From 9ce3be1d444f415c48aa13cc5f7eb49449b3a78c Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Mon, 9 Dec 2002 00:20:55 +0000 Subject: [PATCH 171/671] Fix off-by-one error git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@486 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/blockio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/blockio.c b/kernel/blockio.c index df4e3062..168148b3 100644 --- a/kernel/blockio.c +++ b/kernel/blockio.c @@ -474,5 +474,5 @@ void AllocateHMASpace (size_t lowbuffer, size_t highbuffer) } bp = b_next(bp); } - while (n--); + while (--n); } From 1ac28e0fe1ef3dee2be4d31fbae9a8dee8e45699 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Tue, 10 Dec 2002 02:53:08 +0000 Subject: [PATCH 172/671] Updated config.sys menu instructions. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@487 6ac86273-5f31-0410-b378-82cca8765d1b --- docs/config.txt | 71 ++++++++++++++++++++++++++----------------------- 1 file changed, 37 insertions(+), 34 deletions(-) diff --git a/docs/config.txt b/docs/config.txt index d279ce01..574f177f 100644 --- a/docs/config.txt +++ b/docs/config.txt @@ -1,15 +1,19 @@ -advanced CONFIG.SYS processing +Advanced - FreeDOS specific - CONFIG.SYS processing a new command ECHO -ECHO does ECHO it's argument (surprised ?-) and is executed at -the time the DEVICE= lines are executed. -use it similar to +ECHO does ECHO its argument (surprised ?-) and is executed at +the time the DEVICE= lines are executed. +use it similarly to ECHO loading driver 1 device=Driver1.sys ECHO driver1 successfully loaded - +an undocumented command SCREEN=xx +SCREEN= switches into videomode xxx (INT10/11xx/000) +useful + SCREEN=0x11 -- 28 lines + SCREEN=0x12 -- 43/50 lines (on EGA/VGA) @@ -37,13 +41,13 @@ normal configuration management - you may compose several configurations, using following special commands: -MENU +MENU MENU select your configuration -MENU +MENU MENU use (0) for basic configuration MENU use (1) for CDROM operation MENU use (2) for NETWORK configuration -MENU +MENU MENUDEFAULT=0,1 ( configuration 0, wait 1 second) @@ -55,13 +59,29 @@ MENUDEFAULT=0,1 ( configuration 0, wait 1 second) Although this is definitively worse then MSDOS menuing possibilities, -IMHO it's better then nothing +IMHO it's better then nothing. Unfortunately your MENU text gets completely +uppercase.. + +It's also possible to combine menu options, to avoid writing thing every +time again. +constructions like 0?devicehigh?=cdrom.sys are also possible +("if menu option 0 chosen, ask if you want to load this driver") the selected configuration can be determined in AUTOEXEC.BAT in the environment variable CONFIG like if %CONFIG% == 0 echo configuration 0 selected +however, if you have no menu's in config.sys, then %config% has no value, +thus resulting in "IF == 0 echo configuration 0 selected." +(which causes syntax errors as there's nothing on the left side of == ) + +That's why you better use something like: +if [%config%]==[0] echo configuration 0 selected. -or- +if "%config%"=="0" echo configuration 0 selected. + +then if there is no menu you have: "IF []==[0] echo configuration 0 selected." +(which will of course output nothing) thus my config.sys now looks like @@ -72,48 +92,31 @@ thus my config.sys now looks like !buffers=30 !screen=0x12 !lastdrive=z +!shellhigh=a:\command.com /p /e:512 /MSG -MENU MENU MENU 0 - SoftIce+HIMEM+Network (default) MENU 1 - SoftIce+HIMEM -MENU 2 - HIMEM+EMM386 +MENU 2 - HIMEM+EMM386 MENU MENUDEFAULT=0,0 -0? DEVICE=C:\NUMEGA\S-ICE.EXE /TRA 3000 /SYM 400 -0? DEVICE=himem.exe -0? DEVICE=UMBPCI.SYS +01? DEVICE=C:\NUMEGA\S-ICE.EXE /TRA 3000 /SYM 400 +012?DEVICE=himem.exe +01? DEVICE=UMBPCI.SYS +2? DEVICE=EMM386.EXE NOEMS 0?device=c:\ntclient\ifshlp.sys -0?device=c:\ntclient\protman.dos /i:c:\ntclient -0?device=c:\ntclient\dm9pci.dos -0?device=c:\ntclient\ndishlp.sys -0?device=c:\ntclient\nemm.dos -0?device=c:\ntclient\tcpdrv.dos - - - -1? DEVICE=C:\NUMEGA\S-ICE.EXE /TRA 3000 /SYM 400 -1? DEVICE=himem.exe -1? DEVICE=UMBPCI.SYS - - - -2? DEVICE=himem.exe -2? DEVICE=emm386.exe NOEMS - -rem DEVICE=CDROM.SYS /D:MSCD000 +DEVICE=CDROM.SYS /D:MSCD000 -shellhigh=a:\command.com /p /e:512 /MSG -12/14/01 - tom ehlert +2002-11-28 - Tom Ehlert From 5b83f4df0cc4fcf29b7c9a8c20f13ec8b6d8bdc9 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Tue, 10 Dec 2002 02:59:34 +0000 Subject: [PATCH 173/671] Update for kernel 2028 git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@488 6ac86273-5f31-0410-b378-82cca8765d1b --- docs/history.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/history.txt b/docs/history.txt index 7dc0a1aa..748652be 100644 --- a/docs/history.txt +++ b/docs/history.txt @@ -7,6 +7,7 @@ a slightly less complicated memory model from the C compiler's point of view. * add support for int2f/4a01,4a02: query/allocate HMA space. + * updated config.txt + Changes Arkady V. Belousov * slightly improved asm for print_hex and int2f clear_ax stuff * use #error for unknown compilers From 43bee4de3aa9ed184374fbcf9c205773d48b4353 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Tue, 10 Dec 2002 03:01:19 +0000 Subject: [PATCH 174/671] Adjustments to #error for pre-ANSI compilers. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@489 6ac86273-5f31-0410-b378-82cca8765d1b --- hdr/portab.h | 1 + kernel/init-dat.h | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/hdr/portab.h b/hdr/portab.h index ae9a23bd..7c965f17 100644 --- a/hdr/portab.h +++ b/hdr/portab.h @@ -100,6 +100,7 @@ void __int__(int); #else #error Unknown compiler +We might even deal with a pre-ANSI compiler. This will certainly not compile. #endif #ifdef MC68K diff --git a/kernel/init-dat.h b/kernel/init-dat.h index 7bbde831..96727dd8 100644 --- a/kernel/init-dat.h +++ b/kernel/init-dat.h @@ -27,6 +27,7 @@ extern __segment DosTextSeg; #else -#error("unknown compiler - please adjust") +#error unknown compiler - please adjust +We might even deal with a pre-ANSI compiler. This will certainly not compile. #endif extern BYTE DOSFAR version_flags; /* minor version number */ From b43f271014bc6c88c53b3cb70e5504b9391bb261 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Thu, 20 Feb 2003 20:51:42 +0000 Subject: [PATCH 175/671] "rmdir" and FAT32 fixes from Tom. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@499 6ac86273-5f31-0410-b378-82cca8765d1b --- hdr/fat.h | 1 - hdr/portab.h | 1 + kernel/fatfs.c | 6 ++++++ kernel/fattab.c | 4 ++-- 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/hdr/fat.h b/hdr/fat.h index 7286ac6e..bba790f5 100644 --- a/hdr/fat.h +++ b/hdr/fat.h @@ -97,7 +97,6 @@ static BYTE *fat_hRcsId = */ #define _ISFAT32(dpbp) (((dpbp)->dpb_fatsize)==0) #define ISFAT16(dpbp) (((dpbp)->dpb_size)>FAT_MAGIC && ((dpbp)->dpb_size)<=FAT_MAGIC16 ) -#define ELSE_ISFAT16(dpbp) (((dpbp)->dpb_size)<=FAT_MAGIC16 ) #define ISFAT12(dpbp) ((((dpbp)->dpb_size)-1)f_flags.f_dmod = FALSE; fnp1 = dir_open(path); + if (fnp1 == NULL) + { + dir_close(fnp); + return DE_ACCESS; + } + dir_read(fnp1); if (fnp1->f_dir.dir_name[0] != '.') { diff --git a/kernel/fattab.c b/kernel/fattab.c index f7a2038c..be26c7eb 100644 --- a/kernel/fattab.c +++ b/kernel/fattab.c @@ -192,7 +192,7 @@ unsigned link_fat(struct dpb FAR * dpbp, CLUSTER Cluster1, *fbp1 = (*fbp1 & 0xf0) | ((Cluster2 >> 8) & 0x0f); } } - else if (ELSE_ISFAT16(dpbp)) + else if (ISFAT16(dpbp)) { /* form an index so that we can read the block as a */ /* byte array */ @@ -328,7 +328,7 @@ CLUSTER next_cluster(struct dpb FAR * dpbp, CLUSTER ClusterNum) return LONG_BAD; return idx; } - else if (ELSE_ISFAT16(dpbp)) + else if (ISFAT16(dpbp)) { UWORD res; From 522634bd0663d54ed6153b990a429b5ccb97cfec Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Wed, 12 Mar 2003 06:24:37 +0000 Subject: [PATCH 176/671] merge oldhist.txt git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@529 6ac86273-5f31-0410-b378-82cca8765d1b --- docs/history.txt | 934 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 934 insertions(+) diff --git a/docs/history.txt b/docs/history.txt index 748652be..a0e3345b 100644 --- a/docs/history.txt +++ b/docs/history.txt @@ -1518,3 +1518,937 @@ bugfix: DosOpen(): dito * Fixed so that if you call an INT 21 function with AH containing a unsupported function, the carry flag is set. + +----- older history, from rcs logs. + +13 Nov 2002 tom +initclk.c: +Initial revision + +2001/11/04 bartoldeman +install.bat: +Text files need to be LF ended at the server. So be it... + +2001/04/29 brianreifsnyder +dsk.c: +Added phase 1 support for LBA hard drives + +20 Apr 2001 Bart Oldeman +buffer.h: +Initial revision. + +2001/04/16 bartoldeman +dsk.c: +Fixed handles, config.sys drivers, warnings. Enabled INT21/AH=6C, printf %S/%Fs + +2001/04/15 bartoldeman +dsk.c: +See history.txt for the list of fixes. + +2001/03/27 bartoldeman +dsk.c: +dsk.c (reported by Nagy Daniel), inthndlr and int25/26 fixes by Tom Ehlert. + +2001/03/24 bartoldeman +dsk.c: +See history.txt: dsk.c changes, warning removal and int21 entry handling. + +2001/03/22 bartoldeman +install.bat: +Change LF to CR/LF in batch files. + +2001/03/21 bartoldeman +dsk.c: +See history.txt for changes. Bug fixes and HMA support are the main ones. + +2001/03/16 tom ehlert +inithma.c: +initial creation + +2001/03/08 bartoldeman +dsk.c: +Space saving fixes from Tom Ehlert + +2001/03/07 10:00:00 tomehlert +prf.c: +recoded for smaller object footprint, added main() for testing+QA + +2000/10/29 jimtabor +inthndlr.c: +Adding Share Support by Ron Cemer + +2000/08/15 jhall1 +build.txt: +update to the build.txt file to remove references to the now-defunct +web site at gcfl.net (John's old site). + +2000/08/06 jimtabor +inthndlr.c, nls_load.c: +Add new files and update cvs with patches and changes + +2000/06/21 jimtabor +dsk.c, inthndlr.c: +Add UMB code, patch, and code fixes + +2000/06/01 jimtabor +dsk.c: +Read History for Changes + +2000/05/26 jimtabor +dsk.c: +Read History file for Change info + +2000/05/25 jimtabor +dsk.c, inthndlr.c: +Fixed project history + +2000/05/17 jimtabor +dsk.c, inthndlr.c: +Cleanup, add and fix source. + +2000/05/11 jimtabor +inthndlr.c: +Removed #if statement + +2000/05/11 jimtabor +dsk.c, inthndlr.c: +Added code for DOS FN 69 & 6C + +2000/05/11 jimtabor +install.bat, inthndlr.c: +Clean up and Release + +2000/05/08 jimtabor +inthndlr.c, dosnames.c, dsk.c, dosnames.h, build.txt: +Update CVS to 2020 + +2000/05/06 jhall1 +getvec.asm, dsk.c, inthndlr.c: +The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with +MS-DOS. Distributed under the GNU GPL. + +2000/04/29 jtabor +device.h, blockio.c, dsk.c, fatfs.c, inthndlr.c, ioctl.c: +Added new functions and clean up code + +2000/04/02 jtabor +newstuff.c: +Fix ChgDir Code + +2000/04/02 jtabor +dosfns.c: +Replaced ChgDir Code + +2000/04/02 jtabor +dosfns.c: +Fix to DosChgDir + +2000/03/31 jprice +sys.c: +Added discription of program. + +2000/03/31 jtabor +config.c, dosfns.c, dosnames.c, fatdir.c, fcbfns.c, int2f.asm, main.c, +makefile, network.c, newstuff.c, proto.h, task.c: +Added Eric W. Biederman Patches + +2000/03/23 ska +nls.c: +Initial revision + +2000/03/20 kernel +entry.asm: +Change in Entry.asm + +2000/03/18 kernel +intfns.txt: +changes in supported functions + +2000/03/17 kernel +config.c, fatdir.c, fatfs.c, fcbfns.c, inthndlr.c, makefile, +network.c, nlssupt.asm, proto.h: +Steffen Kaiser's NLS changes + +2000/03/17 kernel +inthndlr.c: +Fixed Func 0x32 + +2000/03/17 kernel +fatfs.c: +Added Change for media_check + +2000/03/16 kernel +globals.h, inthndlr.c: +*** empty log message *** + +2000/03/09 kernel +dosfns.c, dosnames.c, dsk.c, error.c, execrh.asm, fatdir.c, fatfs.c, +fcbfns.c, globals.h, initoem.c, int2f.asm, inthndlr.c, io.asm, +ioctl.c, kernel.asm, main.c, makefile, memmgr.c, misc.c, network.c, +newstuff.c, prf.c, proto.h, strings.c, sysclk.c, task.c, blockio.c, +break.c, chario.c, config.c, console.asm, cds.h, dcb.h, device.h, +dirmatch.h, fnode.h, mcb.h, sft.h, stacks.inc: +2017f updates by James Tabor + +1999/09/25 jprice +boot.asm: +Optimize boot loader. Documentation. + +1999/09/24 jprice +boot.asm: +Added changes recommended by Jens Horstmeier +to make their bootable CD work. + +1999/09/23 jprice +main.c, network.c, proto.h, globals.h, inthndlr.c, kernel.asm, +makefile, config.c, console.asm, dosfns.c, entry.asm, fatfs.c, +fcbfns.c, chario.c, boot.asm, fcb.h, sys/makefile, sys.c: +*** empty log message *** + +1999/09/20 jprice +sys.c: +Changed open/creat to fopen to make TC2 happy. + +1999/09/15 jprice +sys.c: +Changed boot sector writing code so easier to read. + +1999/09/14 jprice +lib/makefile: +no message + +1999/09/14 jprice +sys.c: +Added debug log creation to sys.com. + +1999/09/14 jprice +console.asm: +no message + +1999/09/14 jprice +inthndlr.c: +ror4: fix int25 & 26 are not cached. + +1999/09/14 jprice +fatfs.c, dosfns.c: +Fixed bug where you could write over directories. + +1999/09/13 jprice +inthndlr.c, console.asm: +Fix 210B function + +1999/09/13 jprice +console.asm: +Changes from Helmut Fritsch to fix INT21 func B + +1999/09/13 jprice +makefile: +Some clean up. + +1999/09/13 jprice +config.b, config.b: +Added COMPILER variable + +1999/09/13 jprice +lib/makefile: +Added !if so we can use TC2 or TC3 to compile. + +1999/08/25 jprice +build.txt: +update + +1999/08/25 jprice +config.b, clobber.bat, clean.bat, config.b, build.bat: +New build batch files. + +1999/08/25 jprice +intfns.txt, build.txt, build.bat: +New build config + +1999/08/25 jprice +config.b, sys/makefile, sys.c, lib/makefile, task.c, main.c, makefile, +memmgr.c, newstuff.c, proto.h, strings.c, fatfs.c, globals.h, +initoem.c, inthndlr.c, blockio.c, chario.c, config.c, dosfns.c, +fatdir.c, date.h, dirmatch.h, portab.h, time.h, drivers/makefile, +install.bat: +ror4 patches to allow TC 2.01 compile. + +1999/08/10 jprice +clobber.bat: +case + +1999/08/10 jprice +dsk.c, inthndlr.c: +ror4 2011-04 patch + +1999/08/10 jprice +globals.h, inthndlr.c, fatfs.c, fattab.c, blockio.c: +ror4 2011-03 patch + +1999/08/10 jprice +irqstack.asm, kernel.asm, makefile, nlssupt.asm, printer.asm, +procsupt.asm, segs.inc, apisupt.asm, asmsupt.asm, console.asm, entry.asm, execrh.asm, fatdir.c, +int2f.asm, io.asm, io.inc, stacks.inc: +ror4 2011-02 patch + +1999/08/10 jprice +wrpcclk.asm, wratclk.asm, rdpcclk.asm, drivers/makefile, getvec.asm, floppy.asm: +ror4 2011-01 patch + +1999/05/04 jprice +systime.c: +ror4 date fix + +1999/05/03 jprice +fat.h: +Changed some variables from signed to unsigned. + +1999/05/03 jprice +blockio.c, config.c, dosfns.c, fatdir.c, fatfs.c, fattab.c, globals.h, +inthndlr.c, misc.c, proto.h: +Patches from ror4 and many changed of signed to unsigned variables. + +1999/05/03 jprice +sys/makefile: +no message + +1999/05/03 jprice +fatfs.c: +Fixed bug in map_cluster function + +1999/05/03 jprice +blockio.c: +Changed getblock & getbuf so that they leave at least 3 buffer for FAT data. + +1999/04/23 jprice +procsupt.asm: +Fixed got_cbreak function. + +1999/04/23 jprice +makefile: +no message + +1999/04/23 jprice +asmsupt.asm, inthndlr.c, memmgr.c, misc.c, proto.h, task.c: +Memory manager changes made by ska + +1999/04/23 jprice +clobber.bat: +Initial include + +1999/04/23 jprice +clean.bat, build.bat, sys/makefile, lib/makefile, makefile, drivers/makefile: +Improved by jprice + +1999/04/23 jprice +boot/makefile: +Ported to NASM by ror4. Improvements + +1999/04/23 jprice +boot.asm: +Ported to NASM by ror4 + +1999/04/21 jprice +blockio.c: +no message + +1999/04/18 jprice +blockio.c: +no message + +1999/04/17 jprice +sys.c, boot.asm: +Fixed multi-sector code + +1999/04/17 jprice +build.bat: +ror4 patches + +1999/04/17 jprice +boot.asm: +Changed so multi-sector IO is optional. + +1999/04/16 jprice +blockio.c, config.c, dsk.c, globals.h, main.c, proto.h, floppy.asm: +ror4 multi-sector IO + +1999/04/16 jprice +break.c: +Steffen contributed. + +1999/04/16 jprice +dosfns.c, globals.h, inthndlr.c, irqstack.asm, main.c, makefile, procsupt.asm, +proto.h, chario.c, config.c: +Steffen c-break handler changes + +1999/04/16 jprice +fatfs.c, fattab.c, globals.h, main.c, task.c, blockio.c, config.c, +dsk.c, fatdir.c, fnode.h, dcb.h: +Optimized FAT handling + +1999/04/13 jprice +kernel.asm: +changes for boot loader + +1999/04/13 jprice +boot.asm: +Moves boot sector to top of mem + +1999/04/13 jprice +makefile, fatdir.c, drivers/makefile: +no message + +1999/04/12 jprice +fatfs.c, blockio.c: +Using getbuf to write data instead of getblock +using getblock made it read the block before it wrote it + +1999/04/12 jprice +systime.c, config.c, dosfns.c, fatfs.c, globals.h, main.c, proto.h, +sysclk.c: +more ror4 patches. Changes for multi-block IO + +1999/04/12 jprice +rdpcclk.asm, rdatclk.asm: +more ror4 patches + +1999/04/11 jprice +blockio.c: +Working on multi-block IO + +1999/04/11 jprice +globals.h, inthndlr.c, main.c, newstuff.c, proto.h, task.c, blockio.c, +config.c, dosfns.c, fatdir.c, fatfs.c, fattab.c: +ror4 patches + +1999/04/06 jprice +boot.asm: +Put back code to read multiple sectors at a time. + +1999/04/04 jprice +config.c, globals.h, inthndlr.c, main.c, dosfns.c, dosnames.c, +fatdir.c, fatfs.c, fcbfns.c, globals.h, inthndlr.c, ioctl.c, main.c, +newstuff.c, prf.c, proto.h, strings.c, chario.c, sft.h, device.h: +no message + +1999/04/01 jprice +sys.c: +SYS modified for new boot loader + +1999/04/01 jprice +boot/makefile, boot.asm: +New boot loader + +1999/04/01 jprice +install.bat: +no message + +1999/03/29 jprice +wrpcclk.asm, wratclk.asm, rdpcclk.asm, rdatclk.asm, drivers/makefile, +getvec.asm, floppy.asm, globals.h, io.inc, task.c: +ror4 changes + +1999/03/29 jprice +sys.c: +Fixed error message + +1999/03/29 jprice +sys.c, syspack.c, prf.c, misc.c, fcbfns.c, fattab.c, fatfs.c, +fatdir.c, error.c, dosnames.c, dosfns.c, chario.c, blockio.c, task.c, +systime.c, sysclk.c, strings.c, proto.h, segs.inc, procsupt.asm, +printer.asm, nlssupt.asm, newstuff.c, memmgr.c, main.c, makefile, +kernel.asm, irqstack.asm, ioctl.c, io.inc, io.asm, inthndlr.c, +int2f.asm, globals.h, initoem.c, execrh.asm, entry.asm, dsk.c, +console.asm, config.c, asmsupt.asm, apisupt.asm, wrpcclk.asm, +wratclk.asm, rdpcclk.asm, rdatclk.asm, getvec.asm, floppy.asm, +drivers/makefile, install.bat, boot/makefile, boot.asm, tail.h, +time.h, sft.h, stacks.inc, process.h, portab.h, pcb.h, kbd.h, mcb.h, +file.h, fnode.h, fcb.h, exe.h, fat.h, dosnames.h, error.h, device.h, +date.h, dcb.h, cds.h, clock.h, dirmatch.h, intfns.txt, clean.bat, +build.bat: +New version without IPL.SYS + +1999/03/25 jprice +fatdir.c: +Fixed findfirst & findnext functions to treat the attributes like MSDOS does. + +1999/03/23 jprice +inthndlr.c: +Now sets carry when we don't support a function + +1999/03/23 jprice +config.c: +Now checks for a reads fdconfig.sys file, if exists + +1999/03/23 jprice +fatfs.c: +Fixed mkdir DOS function so it will create a directory with same name as the volument label + +1999/03/02 jprice +inthndlr.c: +Added some comments. Fixed some minor bugs. + +1999/03/02 jprice +fatfs.c: +Fixed bugs with dos set attribute function. Now returns correct +error code, and errors if user tries to set bits 6 & 7. + +1999/03/02 jprice +boot.asm: +Added entry address for more recent versions of TLINK + +1999/03/02 jprice +intfns.txt: +Updated interrupt list + +1999/03/01 jprice +makefile: +Fixed so it'll work with config.mak + +1999/03/01 jprice +makefile: +Turned off DEBUG define. + +1999/03/01 jprice +inthndlr.c: +Added some DEBUG ifdef's so that it will compile without DEBUG defined. + +1999/02/14 jprice +fatdir.c, dsk.c: +Changed check media so that it checks if a floppy disk has been changed. + +1999/02/14 jprice +floppy.asm: +Added functions to check if a floppy disk has been changed. + +1999/02/09 jprice +makefile, drivers/makefile, boot/makefile, clean.bat, build.bat: +Make makefile use common config.mak file + +1999/02/09 jprice +blockio.c, chario.c, dosfns.c, error.c, fatdir.c, fatfs.c, fattab.c, +fcbfns.c, device.h, error.h, sysclk.c, systime.c, task.c, apisupt.asm, +asmsupt.asm, config.c, console.asm, dsk.c, entry.asm, execrh.asm, +globals.h, initoem.c, int2f.asm, inthndlr.c, io.asm, io.inc, ioctl.c, +irqstack.asm, kernel.asm, main.c, makefile, memmgr.c, newstuff.c, +nlssupt.asm, printer.asm, procsupt.asm, proto.h, segs.inc, floppy.asm: +Added Pat's 1937 kernel patches + +1999/02/04 jprice +chario.c, fatfs.c, fcbfns.c, strings.c, sysclk.c, systime.c, task.c: +Formating. Added comments. + +1999/02/04 jprice +inthndlr.c: +Formating + +1999/02/04 jprice +makefile: +Added option to share constants (-d). + +1999/02/04 jprice +device.h: +no message + +1999/02/02 jprice +dosnames.c: +Steve Miller fixed a bug with doing "cd ." would lock the machine. + +1999/02/01 jprice +apisupt.asm, asmsupt.asm, config.c, dsk.c, entry.asm, execrh.asm, globals.h, +initoem.c, int2f.asm, inthndlr.c, ioctl.c, irqstack.asm, kernel.asm, +main.c, memmgr.c, newstuff.c, nlssupt.asm, procsupt.asm, proto.h, +strings.c, sysclk.c, systime.c, task.c: +Clean up; Now you can use hex numbers in config.sys. added config.sys screen function to change screen mode (28 or 43/50 lines) + +1999/02/01 jprice +chario.c, dosfns.c, dosnames.c, error.c, fatdir.c, fatfs.c, fattab.c, +fcbfns.c, misc.c, prf.c, syspack.c, blockio.c: +Fixed findfirst function to find volume label with Windows long filenames + +1999/02/01 jprice +cds.h, clock.h, date.h, dcb.h, device.h, dirmatch.h, dosnames.h, error.h, +exe.h, fat.h, fcb.h, file.h, fnode.h, kbd.h, mcb.h, pcb.h, portab.h, process.h, +sft.h, stacks.inc, tail.h, time.h: +Clean up + +1999/01/30 jprice +clean.bat, build.bat: +Clean up + +1999/01/30 jprice +main.c, config.c, initoem.c, inthndlr.c: +Clean up; Fixed bug with set attribute function. + +1999/01/30 jprice +globals.h: +Clean up; commented out copyright messages while we debug. + +1999/01/30 jprice +blockio.c, fatdir.c, fatfs.c: +Clean up; Fixed bug with set attribute function. If you tried to +change the attributes of a directory, it would erase it. + +1999/01/30 jprice +cds.h, clock.h, error.h, fat.h, fnode.h, build.bat: +Clean up + +1999/01/22 jprice +cds.h, clock.h, date.h, dcb.h, device.h, dirmatch.h, dosnames.h, error.h, +exe.h, fat.h, fcb.h, file.h, fnode.h, kbd.h, mcb.h, pcb.h, portab.h, process.h, +sft.h, stacks.inc, tail.h, time.h, wrpcclk.asm, wratclk.asm, +rdpcclk.asm, rdatclk.asm, drivers/makefile, getvec.asm, floppy.asm, +blockio.c, chario.c, dosfns.c, dosnames.c, error.c, fatdir.c, fatfs.c, +fattab.c, fcbfns.c, misc.c, prf.c, syspack.c, procsupt.asm, proto.h, +strings.c, sysclk.c, systime.c, task.c, globals.h, initoem.c, +int2f.asm, inthndlr.c, ioctl.c, irqstack.asm, kernel.asm, main.c, +makefile, memmgr.c, newstuff.c, nlssupt.asm, apisupt.asm, asmsupt.asm, +config.c, dsk.c, entry.asm, execrh.asm, boot/makefile, boot.asm: +Formating. + +1999/01/21 jprice Fixed comments. +sys.c: +Added indent program + +1999/01/21 jprice Added messages to sys. Also made +sys.c: +it create a .COM file. + +1999/01/20 jprice +cds.h, clock.h, date.h, dcb.h, device.h, dirmatch.h, dosnames.h, error.h, +exe.h, fat.h, fcb.h, file.h, fnode.h, kbd.h, mcb.h, pcb.h, portab.h, process.h, +sft.h, stacks.inc, tail.h, time.h, apisupt.asm, asmsupt.asm, config.c, dsk.c, +entry.asm, execrh.asm, globals.h, initoem.c, int2f.asm, ioctl.c, irqstack.asm, +kernel.asm, main.c, makefile, memmgr.c, newstuff.c, nlssupt.asm, +procsupt.asm, proto.h, strings.c, sysclk.c, systime.c, task.c: +Imported sources + +1999/01/20 jprice +wrpcclk.asm, wratclk.asm, rdpcclk.asm, rdatclk.asm, drivers/makefile, +getvec.asm, floppy.asm, boot/makefile, boot.asm, blockio.c, chario.c, dosfns.c, +dosnames.c, error.c, fatdir.c, fatfs.c, fattab.c, fcbfns.c, +inthndlr.c, misc.c, prf.c, syspack.c: +Imported sources + +10 Jan 1999 SRM +makefile: +Took out "/P-" from TLINK +Changed "bcc" to "tcc" + +06 Dec 1998 patv +entry.asm: +New int 21h handler code. + +06 Dec 1998 patv +inthndlr.c: +Expanded due to improved int 21h handler code. + +06 Dec 1998 patv +ioctl.c, proto.h, apisupt.asm, globals.h: +Expanded due to new I/O subsystem. + +06 Dec 1998 patv +makefile: +Added new files for I/O subsystem. + +06 Dec 1998 patv +main.c, dsk.c: +Changed due to new I/O subsystem. + +06 Dec 1998 patv +irqstack.asm, newstuff.c, int2f.asm, kernel.asm, systime.c, +nlssupt.asm, asmsupt.asm, procsupt.asm, task.c, execrh.asm, fatdir.c, +fatfs.c: +Bug fixes. + +06 Dec 1998 patv +dosfns.c: +Expanded dos functions due to new I/O subsystem. + +06 Dec 1998 patv +fcbfns.c: +Expanded fcb functions for new I/O subsystem. + +06 Dec 1998 patv +error.c: +Now handles errors like MS-DOS. + +06 Dec 1998 patv +chario.c: +changes in character I/O because of new I/O subsystem. + +06 Dec 1998 patv +blockio.c: +Changes in block I/O because of new I/O subsystem. + +06 Dec 1998 patv +floppy.asm: +New floppy support functions. + +06 Dec 1998 patv +device.h: +Changed for new I/O subsystem + +06 Dec 1998 patv +error.h: +Added new errors for new I/O subsystem. + +06 Dec 1998 patv +io.inc, segs.inc: +Initial revision. + +09 Feb 1998 patv +fatfs.c, fattab.c: +Eliminated FAT12 EOF and error returns. + +07 Feb 1998 patv +stacks.inc, pcb.h, entry.asm, procsupt.asm, inthndlr.c, task.c, +globals.h, proto.h: +Modified stack fram to match DOS standard + +03 Feb 1998 patv +kernel.asm: +Added a start-up stack for loadable device drivers. Need the separate +stack so that all int 21h functions can be called. + +03 Feb 1998 patv +fatfs.c: +Fixed lseek bug. + +02 Feb 1998 patv +globals.h: +Fixed size of default_drive. Caused failures when break_ena was not zero. + +31 Jan 1998 patv +task.c: +Corrected type in load high code. + +31 Jan 1998 patv +task.c: +Added load high in memory option in DosExeLoader. + +22 Jan 1998 patv +task.c: +Eliminated warnings. + +22 Jan 1998 patv +process.h: +Had to change ps_prevps to VOID FAR * due to BC++ error. + +22 Jan 1998 patv +process.h: +Corrected ps_prevpsp declaration. + +22 Jan 1998 patv +task.c: +Corrected short .COM problem. + +22 Jan 1998 patv +makefile: +Outdated stacks.asm. + +22 Jan 1998 patv +fatfs.c: +Corrected remaining file name and extension copies that did not +account for far file nodes due to allocated FILES= spec. + +22 Jan 1998 patv +inthndlr.c, proto.h, config.c, globals.h, kernel.asm, main.c, +blockio.c, dosnames.c, fatdir.c, fatfs.c: +Fixed pointer problems affecting SDA + +11 Jan 1998 patv +ioctl.c, proto.h, chario.c, device.h: +Added functionality to ioctl. + +08 Jan 1998 patv +chario.c: +Changed automatic requestic packets to static to save stack space. + +06 Jan 1998 patv +inthndlr.c: +Broke apart int21_system from int21_handler. + +06 Jan 1998 patv +kernel.asm: +Reduced device driver stack sizes. + +04 Jan 1998 patv +globals.h, proto.h, inthndlr.c, newstuff.c, systime.c, main.c, +config.c, ioctl.c, memmgr.c, dsk.c, initoem.c, strings.c, sysclk.c, +task.c, fatfs.c, chario.c, dosfns.c, dosnames.c, fattab.c, fcbfns.c, +prf.c, syspack.c, blockio.c, error.c, fatdir.c, misc.c, device.h, +cds.h, clock.h, date.h, dcb.h, fat.h, file.h, fnode.h, kbd.h, mcb.h, +pcb.h, sft.h, dirmatch.h, error.h, exe.h, fcb.h, portab.h, process.h, +tail.h, time.h: +Changed Log for strip utility + +04 Jan 1998 patv +kernel.asm, inthndlr.c, main.c, config.c, newstuff.c, fatfs.c: +Corrected subdirectory bug + +03 Jan 1998 patv +globals.h, kernel.asm, makefile, systime.c, inthndlr.c, main.c, +proto.h, asmsupt.asm, dosfns.c, dosnames.c, fatfs.c, blockio.c, +fatdir.c, fcbfns.c: +Converted data area to SDA format + +31 Dec 1997 patv +strings.c: +Added new far string functions. + +30 Dec 1997 patv +chario.c: +Modified to support SDA + +01 Aug 1997 patv +inthndlr.c: +COMPATIBILITY: Added return '$' in AL for function int 21h fn 09h + +06 Feb 1997 patv +kernel.asm: +Reduced stack sizes for block and clock devices. + +06 Feb 1997 patv +globals.h: +Changed version format string + +06 Feb 1997 patv +main.c: +Modified to support new version format and changed debug message to +output drive letter instead of number. + +06 Feb 1997 patv +globals.h: +Modified to support new version format + +06 Feb 1997 patv +inthndlr.c, kernel.asm: +Added hooks for tsc command + +30 Jan 1997 patv +makefile: +Added TSC flag for trace support. + +22 Jan 1997 patv +newstuff.c, inthndlr.c, task.c, irqstack.asm: +pre-0.92 Svante Frey bug fixes. + +22 Jan 1997 patv +globals.h: +Changed to support version.h and pre-0.92 Svante Frey bug fixes. + +22 Jan 1997 patv +main.c: +Now does correct default drive initialization. + +22 Jan 1997 patv +fatfs.c, dosfns.c: +pre-0.92 bug fixes + +16 Jan 1997 patv +irqstack.asm: +Initial revision. + +16 Jan 1997 patv +globals.h, main.c, memmgr.c, task.c, ioctl.c, config.c, inthndlr.c, +apisupt.asm, nlssupt.asm, proto.h, makefile, fcbfns.c, chario.c, +dosnames.c, blockio.c, dosfns.c, fatdir.c, fatfs.c, fattab.c, +device.h, fcb.h, sft.h, dsk.c, boot.asm: +Corrected copyright + +10 Jan 1997 patv +boot.asm: +Re-written to support C drive and eliminate restrictions on IPL.SYS + +10 Jan 1997 patv +boot/makefile: +Changed to use FreeDOS exe2bin and support new boot code + +17 Dec 1996 patv +boot/makefile: +Converted to FreeDOS exe2bin. + +13 Sep 1996 patv +globals.h: +Fixed boot for hard drive + +29 Aug 1996 patv +makefile, globals.h, task.c, floppy.asm, wrpcclk.asm, wratclk.asm, +drivers/makefile, rdpcclk.asm, rdatclk.asm, getvec.asm, boot/makefile, +boot.asm: +Bug fixes for v0.91b + +29 May 1996 patv +clock.h, date.h, dcb.h, kbd.h, dirmatch.h, error.h, exe.h, sft.h, +tail.h, time.h, fnode.h, mcb.h, pcb.h, portab.h, process.h, +dosnames.h, fat.h, fcb.h, file.h, device.h, dosfns.c, fatdir.c, +misc.c, fatfs.c, fattab.c, fcbfns.c, chario.c, dosnames.c, syspack.c, +blockio.c, error.c, prf.c, initoem.c, sysclk.c, int2f.asm, config.c, +kernel.asm, inthndlr.c, proto.h, systime.c, apisupt.asm, asmsupt.asm, +nlssupt.asm, procsupt.asm, task.c, globals.h, memmgr.c, dsk.c, main.c, +makefile, execrh.asm, ioctl.c, strings.c: +bug fixes for v0.91a + +19 Feb 1996 patv +int2f.asm: +Initial revision. + +19 Feb 1996 patv +makefile, kernel.asm, nlssupt.asm, proto.h, globals.h, config.c, +inthndlr.c, task.c, dsk.c, main.c, memmgr.c, strings.c, initoem.c, +ioctl.c, sysclk.c, systime.c, fatdir.c, misc.c, fatfs.c, dosfns.c, +dosnames.c, fattab.c, drivers/makefile, cds.h, dirmatch.h, exe.h, +sft.h, tail.h, time.h, fcb.h, file.h, fnode.h, mcb.h, pcb.h, portab.h, +process.h, clock.h, date.h, dcb.h, device.h, dosnames.h, fat.h, +error.h, kbd.h: +Added NLS, int2f and config.sys processing + +01 Sep 1995 patv +wrpcclk.asm, wratclk.asm, rdpcclk.asm, rdatclk.asm, getvec.asm, +floppy.asm, boot.asm, apisupt.asm, asmsupt.asm, proto.h, kernel.asm, +procsupt.asm, execrh.asm, strings.c, task.c, inthndlr.c, memmgr.c, +dsk.c, main.c, sysclk.c, globals.h, initoem.c, ioctl.c, systime.c, +dosfns.c, blockio.c, error.c, misc.c, dosnames.c, fcbfns.c, chario.c, +fattab.c, prf.c, syspack.c, fatfs.c, fatdir.c, time.h, pcb.h, +portab.h, process.h, sft.h, tail.h, fat.h, fcb.h, file.h, fnode.h, +mcb.h, date.h, dcb.h, device.h, dirmatch.h, dosnames.h, clock.h, +error.h, exe.h, kbd.h: +First GPL release. + +30 Jul 1995 patv +dsk.c, memmgr.c, proto.h, strings.c, task.c, blockio.c, misc.c, chario.c, +dosnames.c, error.c, fattab.c, fcbfns.c, prf.c, syspack.c, dosfns.c, +fatdir.c, fatfs.c, mcb.h, pcb.h, portab.h, process.h, sft.h, tail.h, +time.h, date.h, dcb.h, device.h, dirmatch.h, dosnames.h, fat.h, fcb.h, +file.h, fnode.h, clock.h: +Eliminated version strings in ipl + +30 Jul 1995 patv +error.h, kbd.h, exe.h: +Fixed ipl + +30 Jul 1995 patv +boot.asm: +Initialized stack before use. + +05 Jul 1995 patv +asmsupt.asm, proto.h: +Initial revision. + +02 Jul 1995 patv +boot.asm, time.h, tail.h, process.h, sft.h, portab.h, pcb.h, kbd.h, +mcb.h, fnode.h, file.h, fat.h, fcb.h, exe.h, error.h, dirmatch.h, +dosnames.h, dcb.h, device.h, date.h, clock.h, boot/makefile, +procsupt.asm, kernel.asm, execrh.asm, apisupt.asm, task.c, strings.c, +inthndlr.c, main.c, memmgr.c, dsk.c, sysclk.c, systime.c, ioctl.c, +initoem.c, globals.h, makefile, misc.c, error.c, fcbfns.c, dosnames.c, +chario.c, syspack.c, prf.c, fattab.c, fatfs.c, fatdir.c, dosfns.c, +blockio.c, wrpcclk.asm, wratclk.asm, getvec.asm, rdpcclk.asm, +rdatclk.asm, floppy.asm, drivers/makefile: +Initial revision. + +25 May 1993 patv +dirmatch.h: +Initial revision. + From 080d1dd8837b29f74043f11de8fcc8ca7e69c97c Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Wed, 12 Mar 2003 06:27:52 +0000 Subject: [PATCH 177/671] Remove obsolete oldhist.txt git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@530 6ac86273-5f31-0410-b378-82cca8765d1b --- docs/oldhist.txt | 931 ----------------------------------------------- 1 file changed, 931 deletions(-) delete mode 100644 docs/oldhist.txt diff --git a/docs/oldhist.txt b/docs/oldhist.txt deleted file mode 100644 index 6dbb87b8..00000000 --- a/docs/oldhist.txt +++ /dev/null @@ -1,931 +0,0 @@ -13 Nov 2002 tom -initclk.c: -Initial revision - -2001/11/04 bartoldeman -install.bat: -Text files need to be LF ended at the server. So be it... - -2001/04/29 brianreifsnyder -dsk.c: -Added phase 1 support for LBA hard drives - -20 Apr 2001 Bart Oldeman -buffer.h: -Initial revision. - -2001/04/16 bartoldeman -dsk.c: -Fixed handles, config.sys drivers, warnings. Enabled INT21/AH=6C, printf %S/%Fs - -2001/04/15 bartoldeman -dsk.c: -See history.txt for the list of fixes. - -2001/03/27 bartoldeman -dsk.c: -dsk.c (reported by Nagy Daniel), inthndlr and int25/26 fixes by Tom Ehlert. - -2001/03/24 bartoldeman -dsk.c: -See history.txt: dsk.c changes, warning removal and int21 entry handling. - -2001/03/22 bartoldeman -install.bat: -Change LF to CR/LF in batch files. - -2001/03/21 bartoldeman -dsk.c: -See history.txt for changes. Bug fixes and HMA support are the main ones. - -2001/03/16 tom ehlert -inithma.c: -initial creation - -2001/03/08 bartoldeman -dsk.c: -Space saving fixes from Tom Ehlert - -2001/03/07 10:00:00 tomehlert -prf.c: -recoded for smaller object footprint, added main() for testing+QA - -2000/10/29 jimtabor -inthndlr.c: -Adding Share Support by Ron Cemer - -2000/08/15 jhall1 -build.txt: -update to the build.txt file to remove references to the now-defunct -web site at gcfl.net (John's old site). - -2000/08/06 jimtabor -inthndlr.c, nls_load.c: -Add new files and update cvs with patches and changes - -2000/06/21 jimtabor -dsk.c, inthndlr.c: -Add UMB code, patch, and code fixes - -2000/06/01 jimtabor -dsk.c: -Read History for Changes - -2000/05/26 jimtabor -dsk.c: -Read History file for Change info - -2000/05/25 jimtabor -dsk.c, inthndlr.c: -Fixed project history - -2000/05/17 jimtabor -dsk.c, inthndlr.c: -Cleanup, add and fix source. - -2000/05/11 jimtabor -inthndlr.c: -Removed #if statement - -2000/05/11 jimtabor -dsk.c, inthndlr.c: -Added code for DOS FN 69 & 6C - -2000/05/11 jimtabor -install.bat, inthndlr.c: -Clean up and Release - -2000/05/08 jimtabor -inthndlr.c, dosnames.c, dsk.c, dosnames.h, build.txt: -Update CVS to 2020 - -2000/05/06 jhall1 -getvec.asm, dsk.c, inthndlr.c: -The FreeDOS Kernel. A DOS kernel that aims to be 100% compatible with -MS-DOS. Distributed under the GNU GPL. - -2000/04/29 jtabor -device.h, blockio.c, dsk.c, fatfs.c, inthndlr.c, ioctl.c: -Added new functions and clean up code - -2000/04/02 jtabor -newstuff.c: -Fix ChgDir Code - -2000/04/02 jtabor -dosfns.c: -Replaced ChgDir Code - -2000/04/02 jtabor -dosfns.c: -Fix to DosChgDir - -2000/03/31 jprice -sys.c: -Added discription of program. - -2000/03/31 jtabor -config.c, dosfns.c, dosnames.c, fatdir.c, fcbfns.c, int2f.asm, main.c, -makefile, network.c, newstuff.c, proto.h, task.c: -Added Eric W. Biederman Patches - -2000/03/23 ska -nls.c: -Initial revision - -2000/03/20 kernel -entry.asm: -Change in Entry.asm - -2000/03/18 kernel -intfns.txt: -changes in supported functions - -2000/03/17 kernel -config.c, fatdir.c, fatfs.c, fcbfns.c, inthndlr.c, makefile, -network.c, nlssupt.asm, proto.h: -Steffen Kaiser's NLS changes - -2000/03/17 kernel -inthndlr.c: -Fixed Func 0x32 - -2000/03/17 kernel -fatfs.c: -Added Change for media_check - -2000/03/16 kernel -globals.h, inthndlr.c: -*** empty log message *** - -2000/03/09 kernel -dosfns.c, dosnames.c, dsk.c, error.c, execrh.asm, fatdir.c, fatfs.c, -fcbfns.c, globals.h, initoem.c, int2f.asm, inthndlr.c, io.asm, -ioctl.c, kernel.asm, main.c, makefile, memmgr.c, misc.c, network.c, -newstuff.c, prf.c, proto.h, strings.c, sysclk.c, task.c, blockio.c, -break.c, chario.c, config.c, console.asm, cds.h, dcb.h, device.h, -dirmatch.h, fnode.h, mcb.h, sft.h, stacks.inc: -2017f updates by James Tabor - -1999/09/25 jprice -boot.asm: -Optimize boot loader. Documentation. - -1999/09/24 jprice -boot.asm: -Added changes recommended by Jens Horstmeier -to make their bootable CD work. - -1999/09/23 jprice -main.c, network.c, proto.h, globals.h, inthndlr.c, kernel.asm, -makefile, config.c, console.asm, dosfns.c, entry.asm, fatfs.c, -fcbfns.c, chario.c, boot.asm, fcb.h, sys/makefile, sys.c: -*** empty log message *** - -1999/09/20 jprice -sys.c: -Changed open/creat to fopen to make TC2 happy. - -1999/09/15 jprice -sys.c: -Changed boot sector writing code so easier to read. - -1999/09/14 jprice -lib/makefile: -no message - -1999/09/14 jprice -sys.c: -Added debug log creation to sys.com. - -1999/09/14 jprice -console.asm: -no message - -1999/09/14 jprice -inthndlr.c: -ror4: fix int25 & 26 are not cached. - -1999/09/14 jprice -fatfs.c, dosfns.c: -Fixed bug where you could write over directories. - -1999/09/13 jprice -inthndlr.c, console.asm: -Fix 210B function - -1999/09/13 jprice -console.asm: -Changes from Helmut Fritsch to fix INT21 func B - -1999/09/13 jprice -makefile: -Some clean up. - -1999/09/13 jprice -config.b, config.b: -Added COMPILER variable - -1999/09/13 jprice -lib/makefile: -Added !if so we can use TC2 or TC3 to compile. - -1999/08/25 jprice -build.txt: -update - -1999/08/25 jprice -config.b, clobber.bat, clean.bat, config.b, build.bat: -New build batch files. - -1999/08/25 jprice -intfns.txt, build.txt, build.bat: -New build config - -1999/08/25 jprice -config.b, sys/makefile, sys.c, lib/makefile, task.c, main.c, makefile, -memmgr.c, newstuff.c, proto.h, strings.c, fatfs.c, globals.h, -initoem.c, inthndlr.c, blockio.c, chario.c, config.c, dosfns.c, -fatdir.c, date.h, dirmatch.h, portab.h, time.h, drivers/makefile, -install.bat: -ror4 patches to allow TC 2.01 compile. - -1999/08/10 jprice -clobber.bat: -case - -1999/08/10 jprice -dsk.c, inthndlr.c: -ror4 2011-04 patch - -1999/08/10 jprice -globals.h, inthndlr.c, fatfs.c, fattab.c, blockio.c: -ror4 2011-03 patch - -1999/08/10 jprice -irqstack.asm, kernel.asm, makefile, nlssupt.asm, printer.asm, -procsupt.asm, segs.inc, apisupt.asm, asmsupt.asm, console.asm, entry.asm, execrh.asm, fatdir.c, -int2f.asm, io.asm, io.inc, stacks.inc: -ror4 2011-02 patch - -1999/08/10 jprice -wrpcclk.asm, wratclk.asm, rdpcclk.asm, drivers/makefile, getvec.asm, floppy.asm: -ror4 2011-01 patch - -1999/05/04 jprice -systime.c: -ror4 date fix - -1999/05/03 jprice -fat.h: -Changed some variables from signed to unsigned. - -1999/05/03 jprice -blockio.c, config.c, dosfns.c, fatdir.c, fatfs.c, fattab.c, globals.h, -inthndlr.c, misc.c, proto.h: -Patches from ror4 and many changed of signed to unsigned variables. - -1999/05/03 jprice -sys/makefile: -no message - -1999/05/03 jprice -fatfs.c: -Fixed bug in map_cluster function - -1999/05/03 jprice -blockio.c: -Changed getblock & getbuf so that they leave at least 3 buffer for FAT data. - -1999/04/23 jprice -procsupt.asm: -Fixed got_cbreak function. - -1999/04/23 jprice -makefile: -no message - -1999/04/23 jprice -asmsupt.asm, inthndlr.c, memmgr.c, misc.c, proto.h, task.c: -Memory manager changes made by ska - -1999/04/23 jprice -clobber.bat: -Initial include - -1999/04/23 jprice -clean.bat, build.bat, sys/makefile, lib/makefile, makefile, drivers/makefile: -Improved by jprice - -1999/04/23 jprice -boot/makefile: -Ported to NASM by ror4. Improvements - -1999/04/23 jprice -boot.asm: -Ported to NASM by ror4 - -1999/04/21 jprice -blockio.c: -no message - -1999/04/18 jprice -blockio.c: -no message - -1999/04/17 jprice -sys.c, boot.asm: -Fixed multi-sector code - -1999/04/17 jprice -build.bat: -ror4 patches - -1999/04/17 jprice -boot.asm: -Changed so multi-sector IO is optional. - -1999/04/16 jprice -blockio.c, config.c, dsk.c, globals.h, main.c, proto.h, floppy.asm: -ror4 multi-sector IO - -1999/04/16 jprice -break.c: -Steffen contributed. - -1999/04/16 jprice -dosfns.c, globals.h, inthndlr.c, irqstack.asm, main.c, makefile, procsupt.asm, -proto.h, chario.c, config.c: -Steffen c-break handler changes - -1999/04/16 jprice -fatfs.c, fattab.c, globals.h, main.c, task.c, blockio.c, config.c, -dsk.c, fatdir.c, fnode.h, dcb.h: -Optimized FAT handling - -1999/04/13 jprice -kernel.asm: -changes for boot loader - -1999/04/13 jprice -boot.asm: -Moves boot sector to top of mem - -1999/04/13 jprice -makefile, fatdir.c, drivers/makefile: -no message - -1999/04/12 jprice -fatfs.c, blockio.c: -Using getbuf to write data instead of getblock -using getblock made it read the block before it wrote it - -1999/04/12 jprice -systime.c, config.c, dosfns.c, fatfs.c, globals.h, main.c, proto.h, -sysclk.c: -more ror4 patches. Changes for multi-block IO - -1999/04/12 jprice -rdpcclk.asm, rdatclk.asm: -more ror4 patches - -1999/04/11 jprice -blockio.c: -Working on multi-block IO - -1999/04/11 jprice -globals.h, inthndlr.c, main.c, newstuff.c, proto.h, task.c, blockio.c, -config.c, dosfns.c, fatdir.c, fatfs.c, fattab.c: -ror4 patches - -1999/04/06 jprice -boot.asm: -Put back code to read multiple sectors at a time. - -1999/04/04 jprice -config.c, globals.h, inthndlr.c, main.c, dosfns.c, dosnames.c, -fatdir.c, fatfs.c, fcbfns.c, globals.h, inthndlr.c, ioctl.c, main.c, -newstuff.c, prf.c, proto.h, strings.c, chario.c, sft.h, device.h: -no message - -1999/04/01 jprice -sys.c: -SYS modified for new boot loader - -1999/04/01 jprice -boot/makefile, boot.asm: -New boot loader - -1999/04/01 jprice -install.bat: -no message - -1999/03/29 jprice -wrpcclk.asm, wratclk.asm, rdpcclk.asm, rdatclk.asm, drivers/makefile, -getvec.asm, floppy.asm, globals.h, io.inc, task.c: -ror4 changes - -1999/03/29 jprice -sys.c: -Fixed error message - -1999/03/29 jprice -sys.c, syspack.c, prf.c, misc.c, fcbfns.c, fattab.c, fatfs.c, -fatdir.c, error.c, dosnames.c, dosfns.c, chario.c, blockio.c, task.c, -systime.c, sysclk.c, strings.c, proto.h, segs.inc, procsupt.asm, -printer.asm, nlssupt.asm, newstuff.c, memmgr.c, main.c, makefile, -kernel.asm, irqstack.asm, ioctl.c, io.inc, io.asm, inthndlr.c, -int2f.asm, globals.h, initoem.c, execrh.asm, entry.asm, dsk.c, -console.asm, config.c, asmsupt.asm, apisupt.asm, wrpcclk.asm, -wratclk.asm, rdpcclk.asm, rdatclk.asm, getvec.asm, floppy.asm, -drivers/makefile, install.bat, boot/makefile, boot.asm, tail.h, -time.h, sft.h, stacks.inc, process.h, portab.h, pcb.h, kbd.h, mcb.h, -file.h, fnode.h, fcb.h, exe.h, fat.h, dosnames.h, error.h, device.h, -date.h, dcb.h, cds.h, clock.h, dirmatch.h, intfns.txt, clean.bat, -build.bat: -New version without IPL.SYS - -1999/03/25 jprice -fatdir.c: -Fixed findfirst & findnext functions to treat the attributes like MSDOS does. - -1999/03/23 jprice -inthndlr.c: -Now sets carry when we don't support a function - -1999/03/23 jprice -config.c: -Now checks for a reads fdconfig.sys file, if exists - -1999/03/23 jprice -fatfs.c: -Fixed mkdir DOS function so it will create a directory with same name as the volument label - -1999/03/02 jprice -inthndlr.c: -Added some comments. Fixed some minor bugs. - -1999/03/02 jprice -fatfs.c: -Fixed bugs with dos set attribute function. Now returns correct -error code, and errors if user tries to set bits 6 & 7. - -1999/03/02 jprice -boot.asm: -Added entry address for more recent versions of TLINK - -1999/03/02 jprice -intfns.txt: -Updated interrupt list - -1999/03/01 jprice -makefile: -Fixed so it'll work with config.mak - -1999/03/01 jprice -makefile: -Turned off DEBUG define. - -1999/03/01 jprice -inthndlr.c: -Added some DEBUG ifdef's so that it will compile without DEBUG defined. - -1999/02/14 jprice -fatdir.c, dsk.c: -Changed check media so that it checks if a floppy disk has been changed. - -1999/02/14 jprice -floppy.asm: -Added functions to check if a floppy disk has been changed. - -1999/02/09 jprice -makefile, drivers/makefile, boot/makefile, clean.bat, build.bat: -Make makefile use common config.mak file - -1999/02/09 jprice -blockio.c, chario.c, dosfns.c, error.c, fatdir.c, fatfs.c, fattab.c, -fcbfns.c, device.h, error.h, sysclk.c, systime.c, task.c, apisupt.asm, -asmsupt.asm, config.c, console.asm, dsk.c, entry.asm, execrh.asm, -globals.h, initoem.c, int2f.asm, inthndlr.c, io.asm, io.inc, ioctl.c, -irqstack.asm, kernel.asm, main.c, makefile, memmgr.c, newstuff.c, -nlssupt.asm, printer.asm, procsupt.asm, proto.h, segs.inc, floppy.asm: -Added Pat's 1937 kernel patches - -1999/02/04 jprice -chario.c, fatfs.c, fcbfns.c, strings.c, sysclk.c, systime.c, task.c: -Formating. Added comments. - -1999/02/04 jprice -inthndlr.c: -Formating - -1999/02/04 jprice -makefile: -Added option to share constants (-d). - -1999/02/04 jprice -device.h: -no message - -1999/02/02 jprice -dosnames.c: -Steve Miller fixed a bug with doing "cd ." would lock the machine. - -1999/02/01 jprice -apisupt.asm, asmsupt.asm, config.c, dsk.c, entry.asm, execrh.asm, globals.h, -initoem.c, int2f.asm, inthndlr.c, ioctl.c, irqstack.asm, kernel.asm, -main.c, memmgr.c, newstuff.c, nlssupt.asm, procsupt.asm, proto.h, -strings.c, sysclk.c, systime.c, task.c: -Clean up; Now you can use hex numbers in config.sys. added config.sys screen function to change screen mode (28 or 43/50 lines) - -1999/02/01 jprice -chario.c, dosfns.c, dosnames.c, error.c, fatdir.c, fatfs.c, fattab.c, -fcbfns.c, misc.c, prf.c, syspack.c, blockio.c: -Fixed findfirst function to find volume label with Windows long filenames - -1999/02/01 jprice -cds.h, clock.h, date.h, dcb.h, device.h, dirmatch.h, dosnames.h, error.h, -exe.h, fat.h, fcb.h, file.h, fnode.h, kbd.h, mcb.h, pcb.h, portab.h, process.h, -sft.h, stacks.inc, tail.h, time.h: -Clean up - -1999/01/30 jprice -clean.bat, build.bat: -Clean up - -1999/01/30 jprice -main.c, config.c, initoem.c, inthndlr.c: -Clean up; Fixed bug with set attribute function. - -1999/01/30 jprice -globals.h: -Clean up; commented out copyright messages while we debug. - -1999/01/30 jprice -blockio.c, fatdir.c, fatfs.c: -Clean up; Fixed bug with set attribute function. If you tried to -change the attributes of a directory, it would erase it. - -1999/01/30 jprice -cds.h, clock.h, error.h, fat.h, fnode.h, build.bat: -Clean up - -1999/01/22 jprice -cds.h, clock.h, date.h, dcb.h, device.h, dirmatch.h, dosnames.h, error.h, -exe.h, fat.h, fcb.h, file.h, fnode.h, kbd.h, mcb.h, pcb.h, portab.h, process.h, -sft.h, stacks.inc, tail.h, time.h, wrpcclk.asm, wratclk.asm, -rdpcclk.asm, rdatclk.asm, drivers/makefile, getvec.asm, floppy.asm, -blockio.c, chario.c, dosfns.c, dosnames.c, error.c, fatdir.c, fatfs.c, -fattab.c, fcbfns.c, misc.c, prf.c, syspack.c, procsupt.asm, proto.h, -strings.c, sysclk.c, systime.c, task.c, globals.h, initoem.c, -int2f.asm, inthndlr.c, ioctl.c, irqstack.asm, kernel.asm, main.c, -makefile, memmgr.c, newstuff.c, nlssupt.asm, apisupt.asm, asmsupt.asm, -config.c, dsk.c, entry.asm, execrh.asm, boot/makefile, boot.asm: -Formating. - -1999/01/21 jprice Fixed comments. -sys.c: -Added indent program - -1999/01/21 jprice Added messages to sys. Also made -sys.c: -it create a .COM file. - -1999/01/20 jprice -cds.h, clock.h, date.h, dcb.h, device.h, dirmatch.h, dosnames.h, error.h, -exe.h, fat.h, fcb.h, file.h, fnode.h, kbd.h, mcb.h, pcb.h, portab.h, process.h, -sft.h, stacks.inc, tail.h, time.h, apisupt.asm, asmsupt.asm, config.c, dsk.c, -entry.asm, execrh.asm, globals.h, initoem.c, int2f.asm, ioctl.c, irqstack.asm, -kernel.asm, main.c, makefile, memmgr.c, newstuff.c, nlssupt.asm, -procsupt.asm, proto.h, strings.c, sysclk.c, systime.c, task.c: -Imported sources - -1999/01/20 jprice -wrpcclk.asm, wratclk.asm, rdpcclk.asm, rdatclk.asm, drivers/makefile, -getvec.asm, floppy.asm, boot/makefile, boot.asm, blockio.c, chario.c, dosfns.c, -dosnames.c, error.c, fatdir.c, fatfs.c, fattab.c, fcbfns.c, -inthndlr.c, misc.c, prf.c, syspack.c: -Imported sources - -10 Jan 1999 SRM -makefile: -Took out "/P-" from TLINK -Changed "bcc" to "tcc" - -06 Dec 1998 patv -entry.asm: -New int 21h handler code. - -06 Dec 1998 patv -inthndlr.c: -Expanded due to improved int 21h handler code. - -06 Dec 1998 patv -ioctl.c, proto.h, apisupt.asm, globals.h: -Expanded due to new I/O subsystem. - -06 Dec 1998 patv -makefile: -Added new files for I/O subsystem. - -06 Dec 1998 patv -main.c, dsk.c: -Changed due to new I/O subsystem. - -06 Dec 1998 patv -irqstack.asm, newstuff.c, int2f.asm, kernel.asm, systime.c, -nlssupt.asm, asmsupt.asm, procsupt.asm, task.c, execrh.asm, fatdir.c, -fatfs.c: -Bug fixes. - -06 Dec 1998 patv -dosfns.c: -Expanded dos functions due to new I/O subsystem. - -06 Dec 1998 patv -fcbfns.c: -Expanded fcb functions for new I/O subsystem. - -06 Dec 1998 patv -error.c: -Now handles errors like MS-DOS. - -06 Dec 1998 patv -chario.c: -changes in character I/O because of new I/O subsystem. - -06 Dec 1998 patv -blockio.c: -Changes in block I/O because of new I/O subsystem. - -06 Dec 1998 patv -floppy.asm: -New floppy support functions. - -06 Dec 1998 patv -device.h: -Changed for new I/O subsystem - -06 Dec 1998 patv -error.h: -Added new errors for new I/O subsystem. - -06 Dec 1998 patv -io.inc, segs.inc: -Initial revision. - -09 Feb 1998 patv -fatfs.c, fattab.c: -Eliminated FAT12 EOF and error returns. - -07 Feb 1998 patv -stacks.inc, pcb.h, entry.asm, procsupt.asm, inthndlr.c, task.c, -globals.h, proto.h: -Modified stack fram to match DOS standard - -03 Feb 1998 patv -kernel.asm: -Added a start-up stack for loadable device drivers. Need the separate -stack so that all int 21h functions can be called. - -03 Feb 1998 patv -fatfs.c: -Fixed lseek bug. - -02 Feb 1998 patv -globals.h: -Fixed size of default_drive. Caused failures when break_ena was not zero. - -31 Jan 1998 patv -task.c: -Corrected type in load high code. - -31 Jan 1998 patv -task.c: -Added load high in memory option in DosExeLoader. - -22 Jan 1998 patv -task.c: -Eliminated warnings. - -22 Jan 1998 patv -process.h: -Had to change ps_prevps to VOID FAR * due to BC++ error. - -22 Jan 1998 patv -process.h: -Corrected ps_prevpsp declaration. - -22 Jan 1998 patv -task.c: -Corrected short .COM problem. - -22 Jan 1998 patv -makefile: -Outdated stacks.asm. - -22 Jan 1998 patv -fatfs.c: -Corrected remaining file name and extension copies that did not -account for far file nodes due to allocated FILES= spec. - -22 Jan 1998 patv -inthndlr.c, proto.h, config.c, globals.h, kernel.asm, main.c, -blockio.c, dosnames.c, fatdir.c, fatfs.c: -Fixed pointer problems affecting SDA - -11 Jan 1998 patv -ioctl.c, proto.h, chario.c, device.h: -Added functionality to ioctl. - -08 Jan 1998 patv -chario.c: -Changed automatic requestic packets to static to save stack space. - -06 Jan 1998 patv -inthndlr.c: -Broke apart int21_system from int21_handler. - -06 Jan 1998 patv -kernel.asm: -Reduced device driver stack sizes. - -04 Jan 1998 patv -globals.h, proto.h, inthndlr.c, newstuff.c, systime.c, main.c, -config.c, ioctl.c, memmgr.c, dsk.c, initoem.c, strings.c, sysclk.c, -task.c, fatfs.c, chario.c, dosfns.c, dosnames.c, fattab.c, fcbfns.c, -prf.c, syspack.c, blockio.c, error.c, fatdir.c, misc.c, device.h, -cds.h, clock.h, date.h, dcb.h, fat.h, file.h, fnode.h, kbd.h, mcb.h, -pcb.h, sft.h, dirmatch.h, error.h, exe.h, fcb.h, portab.h, process.h, -tail.h, time.h: -Changed Log for strip utility - -04 Jan 1998 patv -kernel.asm, inthndlr.c, main.c, config.c, newstuff.c, fatfs.c: -Corrected subdirectory bug - -03 Jan 1998 patv -globals.h, kernel.asm, makefile, systime.c, inthndlr.c, main.c, -proto.h, asmsupt.asm, dosfns.c, dosnames.c, fatfs.c, blockio.c, -fatdir.c, fcbfns.c: -Converted data area to SDA format - -31 Dec 1997 patv -strings.c: -Added new far string functions. - -30 Dec 1997 patv -chario.c: -Modified to support SDA - -01 Aug 1997 patv -inthndlr.c: -COMPATIBILITY: Added return '$' in AL for function int 21h fn 09h - -06 Feb 1997 patv -kernel.asm: -Reduced stack sizes for block and clock devices. - -06 Feb 1997 patv -globals.h: -Changed version format string - -06 Feb 1997 patv -main.c: -Modified to support new version format and changed debug message to -output drive letter instead of number. - -06 Feb 1997 patv -globals.h: -Modified to support new version format - -06 Feb 1997 patv -inthndlr.c, kernel.asm: -Added hooks for tsc command - -30 Jan 1997 patv -makefile: -Added TSC flag for trace support. - -22 Jan 1997 patv -newstuff.c, inthndlr.c, task.c, irqstack.asm: -pre-0.92 Svante Frey bug fixes. - -22 Jan 1997 patv -globals.h: -Changed to support version.h and pre-0.92 Svante Frey bug fixes. - -22 Jan 1997 patv -main.c: -Now does correct default drive initialization. - -22 Jan 1997 patv -fatfs.c, dosfns.c: -pre-0.92 bug fixes - -16 Jan 1997 patv -irqstack.asm: -Initial revision. - -16 Jan 1997 patv -globals.h, main.c, memmgr.c, task.c, ioctl.c, config.c, inthndlr.c, -apisupt.asm, nlssupt.asm, proto.h, makefile, fcbfns.c, chario.c, -dosnames.c, blockio.c, dosfns.c, fatdir.c, fatfs.c, fattab.c, -device.h, fcb.h, sft.h, dsk.c, boot.asm: -Corrected copyright - -10 Jan 1997 patv -boot.asm: -Re-written to support C drive and eliminate restrictions on IPL.SYS - -10 Jan 1997 patv -boot/makefile: -Changed to use FreeDOS exe2bin and support new boot code - -17 Dec 1996 patv -boot/makefile: -Converted to FreeDOS exe2bin. - -13 Sep 1996 patv -globals.h: -Fixed boot for hard drive - -29 Aug 1996 patv -makefile, globals.h, task.c, floppy.asm, wrpcclk.asm, wratclk.asm, -drivers/makefile, rdpcclk.asm, rdatclk.asm, getvec.asm, boot/makefile, -boot.asm: -Bug fixes for v0.91b - -29 May 1996 patv -clock.h, date.h, dcb.h, kbd.h, dirmatch.h, error.h, exe.h, sft.h, -tail.h, time.h, fnode.h, mcb.h, pcb.h, portab.h, process.h, -dosnames.h, fat.h, fcb.h, file.h, device.h, dosfns.c, fatdir.c, -misc.c, fatfs.c, fattab.c, fcbfns.c, chario.c, dosnames.c, syspack.c, -blockio.c, error.c, prf.c, initoem.c, sysclk.c, int2f.asm, config.c, -kernel.asm, inthndlr.c, proto.h, systime.c, apisupt.asm, asmsupt.asm, -nlssupt.asm, procsupt.asm, task.c, globals.h, memmgr.c, dsk.c, main.c, -makefile, execrh.asm, ioctl.c, strings.c: -bug fixes for v0.91a - -19 Feb 1996 patv -int2f.asm: -Initial revision. - -19 Feb 1996 patv -makefile, kernel.asm, nlssupt.asm, proto.h, globals.h, config.c, -inthndlr.c, task.c, dsk.c, main.c, memmgr.c, strings.c, initoem.c, -ioctl.c, sysclk.c, systime.c, fatdir.c, misc.c, fatfs.c, dosfns.c, -dosnames.c, fattab.c, drivers/makefile, cds.h, dirmatch.h, exe.h, -sft.h, tail.h, time.h, fcb.h, file.h, fnode.h, mcb.h, pcb.h, portab.h, -process.h, clock.h, date.h, dcb.h, device.h, dosnames.h, fat.h, -error.h, kbd.h: -Added NLS, int2f and config.sys processing - -01 Sep 1995 patv -wrpcclk.asm, wratclk.asm, rdpcclk.asm, rdatclk.asm, getvec.asm, -floppy.asm, boot.asm, apisupt.asm, asmsupt.asm, proto.h, kernel.asm, -procsupt.asm, execrh.asm, strings.c, task.c, inthndlr.c, memmgr.c, -dsk.c, main.c, sysclk.c, globals.h, initoem.c, ioctl.c, systime.c, -dosfns.c, blockio.c, error.c, misc.c, dosnames.c, fcbfns.c, chario.c, -fattab.c, prf.c, syspack.c, fatfs.c, fatdir.c, time.h, pcb.h, -portab.h, process.h, sft.h, tail.h, fat.h, fcb.h, file.h, fnode.h, -mcb.h, date.h, dcb.h, device.h, dirmatch.h, dosnames.h, clock.h, -error.h, exe.h, kbd.h: -First GPL release. - -30 Jul 1995 patv -dsk.c, memmgr.c, proto.h, strings.c, task.c, blockio.c, misc.c, chario.c, -dosnames.c, error.c, fattab.c, fcbfns.c, prf.c, syspack.c, dosfns.c, -fatdir.c, fatfs.c, mcb.h, pcb.h, portab.h, process.h, sft.h, tail.h, -time.h, date.h, dcb.h, device.h, dirmatch.h, dosnames.h, fat.h, fcb.h, -file.h, fnode.h, clock.h: -Eliminated version strings in ipl - -30 Jul 1995 patv -error.h, kbd.h, exe.h: -Fixed ipl - -30 Jul 1995 patv -boot.asm: -Initialized stack before use. - -05 Jul 1995 patv -asmsupt.asm, proto.h: -Initial revision. - -02 Jul 1995 patv -boot.asm, time.h, tail.h, process.h, sft.h, portab.h, pcb.h, kbd.h, -mcb.h, fnode.h, file.h, fat.h, fcb.h, exe.h, error.h, dirmatch.h, -dosnames.h, dcb.h, device.h, date.h, clock.h, boot/makefile, -procsupt.asm, kernel.asm, execrh.asm, apisupt.asm, task.c, strings.c, -inthndlr.c, main.c, memmgr.c, dsk.c, sysclk.c, systime.c, ioctl.c, -initoem.c, globals.h, makefile, misc.c, error.c, fcbfns.c, dosnames.c, -chario.c, syspack.c, prf.c, fattab.c, fatfs.c, fatdir.c, dosfns.c, -blockio.c, wrpcclk.asm, wratclk.asm, getvec.asm, rdpcclk.asm, -rdatclk.asm, floppy.asm, drivers/makefile: -Initial revision. - -25 May 1993 patv -dirmatch.h: -Initial revision. - From faf982adc163520da7f91f0724170da7d7e086be Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Wed, 12 Mar 2003 06:28:32 +0000 Subject: [PATCH 178/671] Remove obsolete file relnotes.txt git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@531 6ac86273-5f31-0410-b378-82cca8765d1b --- docs/relnotes.txt | 177 ---------------------------------------------- 1 file changed, 177 deletions(-) delete mode 100644 docs/relnotes.txt diff --git a/docs/relnotes.txt b/docs/relnotes.txt deleted file mode 100644 index 787c31bf..00000000 --- a/docs/relnotes.txt +++ /dev/null @@ -1,177 +0,0 @@ -Release notes for kernel 2024d and its development predecessors -2024BL,M,N: we think that by now we have ironed out most of these -bugs, but be careful nonetheless. - -About KE2024BL: - - ********************************************************* - * * - * THIS IS A BETA RELEASE * - * * - * BE CAREFUL * - * * - * SAVE YOUR DATA. SAVE OFTEN. * - * * - * THIS RELEASE MAY DESTROY YOUR DISK COMPLETELY * - * * - ********************************************************* - - -KE2024BL introduced full LBA support; i.e. disk may be up to -2^32 * 512 bytes = 2000 GB large. - -also new is the working of 64K FAT clustersize for a max -logical disksize of 2^16 * 64K = ~4 GB. - -KE2024BM is its follower, with some more bugfixes. - - -How dangerous is it? - -The KE2024BL kernel has been send by private mail to some of us, -has been tested on 7 maschines with and without LBA support. - -No errors (other then the known bugs) were reported. -And KE2024BM is pretty conservativ, before it accepts and uses -a disk. - -the main problem may be, that a disk recognized by an older -kernel, will no longer work with the new one, because strange -partitioning scemes, although nothing like that has been reported. - -So, if after booting you see all your drives, containing resonable -data, it should be pretty save to use. - -Be a bit careful, nevertheless. - - - - - - -full LBA support and 64K FAT clustersize for a max -logical disksize of 2^16 * 64K = ~4 GB - - -were have been tested in the following way: - -on my 30GB disk, a partition with 1.7 GB for 32K clusters and -3.5 GB for 64K clusters created. the 3.5 GB partition was created, -using Win2K. - -my WINNT directory (~350MB) was copied there - (using VC) -once for 32K, -for 64K, - xcopy c:\WINNT j:\WINNT /s - xcopy j:\WINNT j:\WINN1 /s - xcopy j:\WINN1 j:\WINN2 /s - xcopy j:\WINN2 j:\WINN3 /s - xcopy j:\WINN3 j:\WINN4 /s -to fill the disk. - - -the 350 MB files (WINNT for 32K, WINN4 for 64K) were then -compared to the original file. they were identical. - -no, not all files were copied due to restrictions in MAX_PATH_SIZE, -but the files, that were copied, compared ok. - -the files were also readable with WinNT, and they were identical, too. -WinNT chkdsk was content with the disk. - - -next, the kernel source was copied to this drive, compiled, -and verified. - -so, it _seems_ to work for me. - -known issues: - * VC will say, that the disk has size of 0 byte, with 0 byte free. - this is not a kernel bug. - VC simply multiplies BytesPerSec*SecPerCluster, gets - 128*512 = 0x10000, and saves the low part, which is 0. - - * the behaviour for filesize at or above 2GB (where the sign - gets negative) is completely untested. test it, if you like - - * there are some bugs, when the pathlength is around 64. - this may lead to incontinent (sorry, inconsistent) behaviour, - like - you can MKDIR a directory, but not CHDIR to it - and similiar things. - some of them found and removed, but there are probably more - to be found yet. fortunately, none lead to data loss :-) - - - ********************************************************* - * * - * BE CAREFUL * - * AND SAVE YOUR DATA. SAVE OFTEN. * - * * - ********************************************************* - - -Bugs and fixes in the FAT filesystem (tested on KE2024BN) - ---------------------------------------------------------- -KE2024BM: -Disk Full not detected in a compatible way. -it was possible to create a directory(pointing to nowhere), -even if disk was full. - ---------------------------------------------------------- -DosGetFreeSpace is wrong (verified on KE2022, too): - -when creating files, the 2nd and following clusters are -counted twice when created. - -simply copy one file to another, delete 2nd file; -watch free space before and after. -corrected in KE2024BP - ---------------------------------------------------------- -#include -#include -main() -{ - FILE *fd = fopen("test.dat","w"); - int fdn = fileno(fd); - - lseek(fdn,10000,SEEK_CUR); - write(fdn,"hello world",10); -} - -creates file of DirSize 10010 bytes, but reserves -a single FAT entry cluster - -this is obviously nonsense. - -and there is no "hello world" in it :-( - -cured by FATFS.C, - /* Now that we've found a free FAT entry, mark it as the last */ - /* entry and save it. */ - /* BUG!! this caused wrong allocation, if file was created, - then seeked, then written */ -+ fnp->f_cluster = - fnp->f_dir.dir_start = free_fat; - - - - --------------------------------------------------------------- -when a big file is created, and cut afterward, the filespace is NOT freed -try: - copy command.com xx - dir - echo >xx - dir -and compare disk free info. -the space is freed, however, if xx is deleted after that. --------------------------------------------------------------- - - - - -regards -tom ehlert (tom.ehlert@ginko.de) From e8239ebb38b93fc8a5f52f75060ad3efa999ef2b Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Wed, 12 Mar 2003 06:29:02 +0000 Subject: [PATCH 179/671] Add comments about zip file contents. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@532 6ac86273-5f31-0410-b378-82cca8765d1b --- docs/readme.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/readme.txt b/docs/readme.txt index 3d52068c..e7d331af 100644 --- a/docs/readme.txt +++ b/docs/readme.txt @@ -12,6 +12,10 @@ http://www.freedos.org. See the DOCS directory for more documentation and information about the FreeDOS Kernel. +Contents of zip files: +ke20xx_16.zip : binaries for 8086, FAT16 +ke20xx_32.zip : binaries for 80386, FAT16,FAT32 +ke20xxsrc.zip : sources for the kernel BUG REPORTS ----------- From ee958bad3b9b46096101129bbd47beac09b1157f Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Wed, 12 Mar 2003 06:30:16 +0000 Subject: [PATCH 180/671] Remove unused intr.h git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@533 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/intr.h | 9 --------- kernel/makefile | 2 +- 2 files changed, 1 insertion(+), 10 deletions(-) delete mode 100644 kernel/intr.h diff --git a/kernel/intr.h b/kernel/intr.h deleted file mode 100644 index 94f3f49c..00000000 --- a/kernel/intr.h +++ /dev/null @@ -1,9 +0,0 @@ -/* -*/ - -struct REGPACK { - unsigned r_ax, r_bx, r_cx, r_dx; - unsigned r_bp, r_di, r_si, r_ds, r_es, r_flags; -}; - -void ASMCFUNC intr(int intrnr, struct REGPACK *rp); diff --git a/kernel/makefile b/kernel/makefile index e2e07ddb..ead55cd2 100644 --- a/kernel/makefile +++ b/kernel/makefile @@ -140,7 +140,7 @@ execrh.obj: execrh.asm segs.inc int2f.obj: int2f.asm segs.inc -intr.obj: intr.asm segs.inc intr.h +intr.obj: intr.asm segs.inc io.obj: io.asm segs.inc From 4dcb3f332cadd5c37b955f5ae7563d8f4f671ef0 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Wed, 12 Mar 2003 06:32:03 +0000 Subject: [PATCH 181/671] Fix for TC RTL math routines -- they need to be in the low text now. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@534 6ac86273-5f31-0410-b378-82cca8765d1b --- lib/makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/makefile b/lib/makefile index 3da926be..b4876460 100644 --- a/lib/makefile +++ b/lib/makefile @@ -11,6 +11,7 @@ libm.lib: $(CLIB) -$(RM) libm.lib $(LIBUTIL) $(CLIB) $(MATH_EXTRACT) $(LIBTERM) + for %i in (*.obj) do ..\utils\patchobj CODE=LCODE TEXT=_LOWTEXT %i $(LIBUTIL) libm $(MATH_INSERT) $(LIBTERM) -$(RM) *.OBJ From ec8b97be3870df0f578c04e1661c9ba781058827 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Wed, 12 Mar 2003 06:36:00 +0000 Subject: [PATCH 182/671] Preserve si and di for strategy handlers. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@535 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/execrh.asm | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/kernel/execrh.asm b/kernel/execrh.asm index cbd89524..1bb85453 100644 --- a/kernel/execrh.asm +++ b/kernel/execrh.asm @@ -57,8 +57,15 @@ segment _TEXT mov ax, [si+6] ; construct strategy address mov [bp+8], ax + push si ; the bloody fucking RTSND.DOS + push di ; driver destroys SI,DI (tom 14.2.03) + call far[bp+8] ; call far the strategy + pop di + pop si + + mov ax,[si+8] ; construct 'interrupt' address mov [bp+8],ax ; construct interrupt address call far[bp+8] ; call far the interrupt From 9bcd6b125ae8d3b276ea5afd9fc314fdee3f7c43 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Wed, 12 Mar 2003 06:50:33 +0000 Subject: [PATCH 183/671] Don't allow wildcards for internal truename processing, except for DosFindfirst and DosTruename. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@536 6ac86273-5f31-0410-b378-82cca8765d1b --- hdr/cds.h | 1 + kernel/dosfns.c | 5 +++-- kernel/newstuff.c | 2 ++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/hdr/cds.h b/hdr/cds.h index 8f8b7b17..149f5905 100644 --- a/hdr/cds.h +++ b/hdr/cds.h @@ -94,3 +94,4 @@ struct cds { #define CDS_MODE_SKIP_PHYSICAL 0x01 /* don't resolve SUBST, JOIN, NETW */ #define CDS_MODE_CHECK_DEV_PATH 0x02 /* check for existence of device path */ +#define CDS_MODE_ALLOW_WILDCARDS 0x04 /* allow wildcards in "truename" */ diff --git a/kernel/dosfns.c b/kernel/dosfns.c index 09a480f5..74fa0bd6 100644 --- a/kernel/dosfns.c +++ b/kernel/dosfns.c @@ -1009,7 +1009,8 @@ COUNT DosFindFirst(UCOUNT attr, BYTE FAR * name) int rc; register dmatch FAR *dmp = dta; - rc = truename(name, PriPathName, CDS_MODE_CHECK_DEV_PATH); + rc = truename(name, PriPathName, + CDS_MODE_CHECK_DEV_PATH | CDS_MODE_ALLOW_WILDCARDS); if (rc < SUCCESS) return rc; @@ -1546,7 +1547,7 @@ COUNT DosTruename(const char FAR *src, char FAR *dest) Therefore, the name is created in an internal buffer and copied into the user buffer only on success. */ - COUNT rc = truename(src, PriPathName, 0); + COUNT rc = truename(src, PriPathName, CDS_MODE_ALLOW_WILDCARDS); if (rc >= SUCCESS) fstrcpy(dest, PriPathName); return rc; diff --git a/kernel/newstuff.c b/kernel/newstuff.c index b6b20a4a..e69136fb 100644 --- a/kernel/newstuff.c +++ b/kernel/newstuff.c @@ -532,6 +532,8 @@ COUNT truename(const char FAR * src, char * dest, COUNT mode) break; } } + if (gotAnyWildcards && !(mode & CDS_MODE_ALLOW_WILDCARDS)) + return DE_PATHNOTFND; if (addSep == ADD || p == dest + 2) { /* MS DOS preserves a trailing '\\', so an access to "C:\\DOS\\" From 50a39d18802a891a32b879dbff5603efba518f8c Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Wed, 12 Mar 2003 06:53:16 +0000 Subject: [PATCH 184/671] Some FCB functions need wildcards too. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@537 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/fcbfns.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/fcbfns.c b/kernel/fcbfns.c index bd566f60..7ea27f27 100644 --- a/kernel/fcbfns.c +++ b/kernel/fcbfns.c @@ -463,7 +463,7 @@ int FcbNameInit(fcb FAR * lpFcb, BYTE * szBuffer, COUNT * pCurDrive) *pCurDrive = default_drive + 1; } ConvertName83ToNameSZ(pszBuffer, lpFcb->fcb_fname); - return truename(loc_szBuffer, szBuffer, CDS_MODE_CHECK_DEV_PATH); + return truename(loc_szBuffer, szBuffer, CDS_MODE_CHECK_DEV_PATH|CDS_MODE_ALLOW_WILDCARDS); } UBYTE FcbDelete(xfcb FAR * lpXfcb) From 5a7a27df703becf14a976f4d90bd3052b0e262b2 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Wed, 12 Mar 2003 22:43:53 +0000 Subject: [PATCH 185/671] Use HMA_TEXT instead of _TEXT again. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@538 6ac86273-5f31-0410-b378-82cca8765d1b --- drivers/floppy.asm | 2 +- drivers/getvec.asm | 2 +- drivers/rdatclk.asm | 2 +- drivers/rdpcclk.asm | 2 +- drivers/wratclk.asm | 2 +- drivers/wrpcclk.asm | 2 +- kernel/apisupt.asm | 2 +- kernel/asmsupt.asm | 2 +- kernel/dosidle.asm | 2 +- kernel/entry.asm | 2 +- kernel/execrh.asm | 2 +- kernel/int2f.asm | 4 ++-- kernel/intr.asm | 2 +- kernel/kernel.asm | 2 +- kernel/nlssupt.asm | 2 +- kernel/procsupt.asm | 4 ++-- kernel/segs.inc | 4 ++-- mkfiles/bc5.mak | 6 +++--- mkfiles/tc2.mak | 2 +- mkfiles/tc3.mak | 6 +++--- mkfiles/turbocpp.mak | 6 +++--- mkfiles/watcom.mak | 2 +- 22 files changed, 31 insertions(+), 31 deletions(-) diff --git a/drivers/floppy.asm b/drivers/floppy.asm index 3ce10373..9929c5e3 100644 --- a/drivers/floppy.asm +++ b/drivers/floppy.asm @@ -30,7 +30,7 @@ %ifndef SYS %include "..\kernel\segs.inc" - segment _TEXT + segment HMA_TEXT %else segment _TEXT class=CODE %endif diff --git a/drivers/getvec.asm b/drivers/getvec.asm index 0acd3f72..153b20ac 100644 --- a/drivers/getvec.asm +++ b/drivers/getvec.asm @@ -30,7 +30,7 @@ %include "..\kernel\segs.inc" -segment _TEXT +segment HMA_TEXT global _getvec _getvec: diff --git a/drivers/rdatclk.asm b/drivers/rdatclk.asm index 81c026f3..8abd5b77 100644 --- a/drivers/rdatclk.asm +++ b/drivers/rdatclk.asm @@ -32,7 +32,7 @@ %include "..\kernel\segs.inc" -segment _TEXT +segment HMA_TEXT ; ;COUNT ReadATClock(bcdDays, bcdHours, bcdMinutes, bcdSeconds) diff --git a/drivers/rdpcclk.asm b/drivers/rdpcclk.asm index e202bec2..81ed79e0 100644 --- a/drivers/rdpcclk.asm +++ b/drivers/rdpcclk.asm @@ -30,7 +30,7 @@ %include "..\kernel\segs.inc" -segment _TEXT +segment HMA_TEXT ; ; BOOL ReadPCClock(Ticks) diff --git a/drivers/wratclk.asm b/drivers/wratclk.asm index d539e7ef..ab9071b2 100644 --- a/drivers/wratclk.asm +++ b/drivers/wratclk.asm @@ -30,7 +30,7 @@ %include "..\kernel\segs.inc" -segment _TEXT +segment HMA_TEXT ; ; VOID WriteATClock(bcdDays, bcdHours, bcdMinutes, bcdSeconds) diff --git a/drivers/wrpcclk.asm b/drivers/wrpcclk.asm index c7ba2467..7e6f7354 100644 --- a/drivers/wrpcclk.asm +++ b/drivers/wrpcclk.asm @@ -29,7 +29,7 @@ ; %include "..\kernel\segs.inc" -segment _TEXT +segment HMA_TEXT ; diff --git a/kernel/apisupt.asm b/kernel/apisupt.asm index 8d5271b6..914fd6c8 100644 --- a/kernel/apisupt.asm +++ b/kernel/apisupt.asm @@ -29,7 +29,7 @@ %include "segs.inc" -segment _TEXT +segment HMA_TEXT %if 0 extern _api_sp:wrt DGROUP ; api stacks - for context diff --git a/kernel/asmsupt.asm b/kernel/asmsupt.asm index 4986c321..55525ad3 100644 --- a/kernel/asmsupt.asm +++ b/kernel/asmsupt.asm @@ -36,7 +36,7 @@ %include "segs.inc" -segment _TEXT +segment HMA_TEXT ;********************************************************************* ; this implements some of the common string handling functions diff --git a/kernel/dosidle.asm b/kernel/dosidle.asm index 9bdcd70b..e0e4cab3 100644 --- a/kernel/dosidle.asm +++ b/kernel/dosidle.asm @@ -31,7 +31,7 @@ PSP_USERSP equ 2eh PSP_USERSS equ 30h -segment _TEXT +segment HMA_TEXT global _DosIdle_int diff --git a/kernel/entry.asm b/kernel/entry.asm index 1a487163..45b353f8 100644 --- a/kernel/entry.asm +++ b/kernel/entry.asm @@ -31,7 +31,7 @@ %include "segs.inc" %include "stacks.inc" -segment _TEXT +segment HMA_TEXT extern _int21_syscall:wrt TGROUP extern _int21_service:wrt TGROUP extern _int2526_handler:wrt TGROUP diff --git a/kernel/execrh.asm b/kernel/execrh.asm index 1bb85453..91740820 100644 --- a/kernel/execrh.asm +++ b/kernel/execrh.asm @@ -30,7 +30,7 @@ %include "segs.inc" -segment _TEXT +segment HMA_TEXT ; _execrh ; Execute Device Request ; diff --git a/kernel/int2f.asm b/kernel/int2f.asm index 27fd82a1..7d1c1522 100644 --- a/kernel/int2f.asm +++ b/kernel/int2f.asm @@ -31,9 +31,9 @@ %include "segs.inc" %include "stacks.inc" -segment _TEXT +segment HMA_TEXT extern _cu_psp:wrt DGROUP - extern _syscall_MUX14:wrt _TEXT + extern _syscall_MUX14:wrt HMA_TEXT global reloc_call_int2f_handler reloc_call_int2f_handler: diff --git a/kernel/intr.asm b/kernel/intr.asm index 88f716e0..eebbfb04 100644 --- a/kernel/intr.asm +++ b/kernel/intr.asm @@ -28,7 +28,7 @@ %include "segs.inc" -segment _TEXT +segment HMA_TEXT ; ; void intr(nr, rp) ; REG int nr diff --git a/kernel/kernel.asm b/kernel/kernel.asm index d40073c6..1dbe4284 100644 --- a/kernel/kernel.asm +++ b/kernel/kernel.asm @@ -704,7 +704,7 @@ __HMATextStart: ; the HMA area is filled with 1eh+3(=sizeof VDISK) = 33 byte dummy data, ; so nothing will ever be below 0xffff:0031 ; -segment _TEXT +segment HMA_TEXT begin_hma: times 10h db 0 ; filler [ffff:0..ffff:10] times 20h db 0 diff --git a/kernel/nlssupt.asm b/kernel/nlssupt.asm index 284bbe91..d41d2570 100644 --- a/kernel/nlssupt.asm +++ b/kernel/nlssupt.asm @@ -30,7 +30,7 @@ %include "segs.inc" -segment _TEXT +segment HMA_TEXT global _reloc_call_CharMapSrvc extern _DosUpChar:wrt TGROUP ; diff --git a/kernel/procsupt.asm b/kernel/procsupt.asm index 00a77bf7..fc02bb90 100644 --- a/kernel/procsupt.asm +++ b/kernel/procsupt.asm @@ -38,7 +38,7 @@ %include "stacks.inc" -segment _TEXT +segment HMA_TEXT extern _DGROUP_:wrt LGROUP @@ -85,7 +85,7 @@ _got_cbreak: pop ds iret -segment _TEXT +segment HMA_TEXT ; ; Special call for switching processes during break handling diff --git a/kernel/segs.inc b/kernel/segs.inc index 6646a18d..1ec3eb3a 100644 --- a/kernel/segs.inc +++ b/kernel/segs.inc @@ -31,7 +31,7 @@ group PGROUP PSP group LGROUP _LOWTEXT _IO_TEXT _IO_FIXED_DATA group DGROUP _FIXED_DATA _BSS _DATA _DATAEND CONST CONST2 DCONST DYN_DATA group I_GROUP INIT_TEXT_START INIT_TEXT INIT_TEXT_END ID_B ID ID_E IC IDATA ICONST ICONST2 I_DATA IB_B I_BSS IB IB_E -group TGROUP HMA_TEXT_START _TEXT HMA_TEXT_END +group TGROUP HMA_TEXT_START HMA_TEXT HMA_TEXT_END segment PSP class=PSP segment _LOWTEXT class=LCODE @@ -48,7 +48,7 @@ segment CONST2 class=DATA align=2 segment DCONST class=DCONST align=2 segment DYN_DATA class=DYN_DATA segment HMA_TEXT_START class=CODE align=16 -segment _TEXT class=CODE +segment HMA_TEXT class=CODE segment HMA_TEXT_END class=CODE segment INIT_TEXT_START class=INIT align=16 segment INIT_TEXT class=INIT diff --git a/mkfiles/bc5.mak b/mkfiles/bc5.mak index 8f448e6e..60831f8a 100644 --- a/mkfiles/bc5.mak +++ b/mkfiles/bc5.mak @@ -23,8 +23,8 @@ TARGET=KBC # used for building the library CLIB=$(COMPILERPATH)\lib\cs.lib -MATH_EXTRACT=*H_LDIV *H_LLSH *H_LURSH *N_LXMUL *F_LXMUL *H_LRSH -MATH_INSERT=+H_LDIV +H_LLSH +H_LURSH +N_LXMUL +F_LXMUL +H_LRSH +MATH_EXTRACT=*H_LDIV *H_LLSH *H_LURSH *F_LXMUL +MATH_INSERT=+H_LDIV +H_LLSH +H_LURSH +F_LXMUL # # heavy stuff - building the kernel @@ -48,6 +48,6 @@ MATH_INSERT=+H_LDIV +H_LLSH +H_LURSH +N_LXMUL +F_LXMUL +H_LRSH # # ALLCFLAGS specified by turbo.cfg and config.mak # -ALLCFLAGS=$(TARGETOPT) $(ALLCFLAGS) +ALLCFLAGS=$(TARGETOPT) -zCHMA_TEXT $(ALLCFLAGS) INITCFLAGS=$(ALLCFLAGS) -zAINIT -zCINIT_TEXT -zDIB -zRID -zTID -zPI_GROUP -zBIB -zGI_GROUP -zSI_GROUP CFLAGS=$(ALLCFLAGS) diff --git a/mkfiles/tc2.mak b/mkfiles/tc2.mak index b527c088..d9fd5576 100644 --- a/mkfiles/tc2.mak +++ b/mkfiles/tc2.mak @@ -48,6 +48,6 @@ MATH_INSERT=+LDIV +LXMUL +LURSH +LLSH +LRSH # # ALLCFLAGS specified by turbo.cfg and config.mak # -ALLCFLAGS=$(TARGETOPT) $(ALLCFLAGS) +ALLCFLAGS=$(TARGETOPT) -zCHMA_TEXT $(ALLCFLAGS) INITCFLAGS=$(ALLCFLAGS) -zAINIT -zCINIT_TEXT -zDIB -zRID -zTID -zPI_GROUP -zBIB -zGI_GROUP -zSI_GROUP CFLAGS=$(ALLCFLAGS) diff --git a/mkfiles/tc3.mak b/mkfiles/tc3.mak index 3761f898..57b3cc85 100644 --- a/mkfiles/tc3.mak +++ b/mkfiles/tc3.mak @@ -23,8 +23,8 @@ TARGET=KT3 # used for building the library CLIB=$(COMPILERPATH)\lib\cs.lib -MATH_EXTRACT=*H_LDIV *H_LLSH *H_LURSH *N_LXMUL *F_LXMUL *H_LRSH -MATH_INSERT=+H_LDIV +H_LLSH +H_LURSH +N_LXMUL +F_LXMUL +H_LRSH +MATH_EXTRACT=*H_LDIV *H_LLSH *H_LURSH *F_LXMUL +MATH_INSERT=+H_LDIV +H_LLSH +H_LURSH +F_LXMUL # # heavy stuff - building the kernel @@ -48,6 +48,6 @@ MATH_INSERT=+H_LDIV +H_LLSH +H_LURSH +N_LXMUL +F_LXMUL +H_LRSH # # ALLCFLAGS specified by turbo.cfg and config.mak # -ALLCFLAGS=$(TARGETOPT) $(ALLCFLAGS) +ALLCFLAGS=$(TARGETOPT) -zCHMA_TEXT $(ALLCFLAGS) INITCFLAGS=$(ALLCFLAGS) -zAINIT -zCINIT_TEXT -zDIB -zRID -zTID -zPI_GROUP -zBIB -zGI_GROUP -zSI_GROUP CFLAGS=$(ALLCFLAGS) diff --git a/mkfiles/turbocpp.mak b/mkfiles/turbocpp.mak index 1122f2d1..d1716824 100644 --- a/mkfiles/turbocpp.mak +++ b/mkfiles/turbocpp.mak @@ -23,8 +23,8 @@ TARGET=KTP # used for building the library CLIB=$(COMPILERPATH)\lib\cs.lib -MATH_EXTRACT=*H_LDIV *F_LXMUL *H_LURSH *H_LLSH *H_LRSH -MATH_INSERT=+H_LDIV +F_LXMUL +H_LURSH +H_LLSH +H_LRSH +MATH_EXTRACT=*H_LDIV *H_LLSH *H_LURSH *F_LXMUL +MATH_INSERT=+H_LDIV +H_LLSH +H_LURSH +F_LXMUL # # heavy stuff - building the kernel @@ -48,6 +48,6 @@ MATH_INSERT=+H_LDIV +F_LXMUL +H_LURSH +H_LLSH +H_LRSH # # ALLCFLAGS specified by turbo.cfg and config.mak # -ALLCFLAGS=$(TARGETOPT) $(ALLCFLAGS) +ALLCFLAGS=$(TARGETOPT) -zCHMA_TEXT $(ALLCFLAGS) INITCFLAGS=$(ALLCFLAGS) -zAINIT -zCINIT_TEXT -zDIB -zRID -zTID -zPI_GROUP -zBIB -zGI_GROUP -zSI_GROUP CFLAGS=$(ALLCFLAGS) diff --git a/mkfiles/watcom.mak b/mkfiles/watcom.mak index d4e5ed52..10f1884c 100644 --- a/mkfiles/watcom.mak +++ b/mkfiles/watcom.mak @@ -63,6 +63,6 @@ MATH_INSERT= +i4d +i4m ALLCFLAGS=-I..\hdr $(TARGETOPT) $(ALLCFLAGS)-zq-os-s-e5-j-zl-zp1-wx-we-zgf-zff INITCFLAGS=$(ALLCFLAGS)-ntINIT_TEXT-ncINIT-ndI-gI_GROUP -CFLAGS=$(ALLCFLAGS) +CFLAGS=$(ALLCFLAGS)-ntHMA_TEXT INITPATCH=..\utils\patchobj __U4D=_IU4D __U4M=_IU4M From a4cf00919842a8ab5e91f0bb94127dcbe6b00e88 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Wed, 12 Mar 2003 23:06:48 +0000 Subject: [PATCH 186/671] Adding COUNTRY= and INSTALL(HIGH) config.sys support (by Tom Ehlert) git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@539 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/config.c | 748 ++++++++++++++++++++++++++++++++++++++++++---- kernel/init-mod.h | 1 + kernel/main.c | 3 + 3 files changed, 691 insertions(+), 61 deletions(-) diff --git a/kernel/config.c b/kernel/config.c index 9fb644b6..2932527c 100644 --- a/kernel/config.c +++ b/kernel/config.c @@ -127,8 +127,8 @@ STATIC BYTE szBuf[256] = { 0 }; BYTE singleStep = FALSE; /* F8 processing */ BYTE SkipAllConfig = FALSE; /* F5 processing */ -BYTE askThisSingleCommand = FALSE; /* ?device= device?= */ -BYTE DontAskThisSingleCommand = FALSE; /* !files= */ +BYTE askThisSingleCommand = FALSE; /* ?device= device?= */ +BYTE DontAskThisSingleCommand = FALSE; /* !files= */ COUNT MenuTimeout = -1; BYTE MenuSelected = 0; @@ -152,6 +152,10 @@ STATIC VOID Dosmem(BYTE * pLine); STATIC VOID Country(BYTE * pLine); STATIC VOID InitPgm(BYTE * pLine); STATIC VOID InitPgmHigh(BYTE * pLine); +STATIC VOID CmdInstall(BYTE * pLine); +STATIC VOID CmdInstallHigh(BYTE * pLine); + + STATIC VOID CfgSwitchar(BYTE * pLine); STATIC VOID CfgFailure(BYTE * pLine); STATIC VOID CfgIgnore(BYTE * pLine); @@ -178,6 +182,7 @@ STATIC int SkipLine(char *pLine); STATIC char * stristr(char *s1, char *s2); #endif STATIC COUNT strcasecmp(REG BYTE * d, REG BYTE * s); +STATIC int LoadCountryInfoHardCoded(char *filename, COUNT ctryCode, COUNT codePage); void HMAconfig(int finalize); VOID config_init_buffers(COUNT anzBuffers); /* from BLOCKIO.C */ @@ -205,9 +210,9 @@ STATIC struct table commands[] = { {"REM", 0, CfgIgnore}, {";", 0, CfgIgnore}, - {"MENUDEFAULT", 0, CfgMenuDefault}, - {"MENU", 0, CfgMenu}, /* lines to print in pass 0 */ - {"ECHO", 2, CfgMenu}, /* lines to print in pass 2 - when devices are loaded */ + {"MENUDEFAULT", 0, CfgMenuDefault}, + {"MENU", 0, CfgMenu}, /* lines to print in pass 0 */ + {"ECHO", 2, CfgMenu}, /* lines to print in pass 2 - when devices are loaded */ {"BREAK", 1, CfgBreak}, {"BUFFERS", 1, Config_Buffers}, @@ -224,11 +229,12 @@ STATIC struct table commands[] = { {"SWITCHAR", 1, CfgSwitchar}, {"SCREEN", 1, sysScreenMode}, /* JPP */ {"VERSION", 1, sysVersion}, /* JPP */ - {"ANYDOS", 1, SetAnyDos}, /* JPP */ + {"ANYDOS", 1, SetAnyDos}, /* tom */ {"DEVICE", 2, Device}, {"DEVICEHIGH", 2, DeviceHigh}, - /* {"INSTALL", 3, install}, would go here */ + {"INSTALL", 2, CmdInstall}, + {"INSTALLHIGH", 2, CmdInstallHigh}, /* default action */ {"", -1, CfgFailure} @@ -522,7 +528,7 @@ VOID DoConfig(int pass) /* Set pass number */ nPass = pass; - + /* Check to see if we have a config.sys file. If not, just */ /* exit since we don't force the user to have one. */ if ((nFileDesc = open("fdconfig.sys", 0)) >= 0) @@ -600,7 +606,7 @@ VOID DoConfig(int pass) if (pEntry->pass >= 0 && pEntry->pass != nPass) continue; - if (nPass == 0) /* pass 0 always executed (rem Menu prompt) */ + if (nPass == 0) /* pass 0 always executed (rem Menu prompt) */ { (*(pEntry->func)) (pLine); continue; @@ -609,7 +615,7 @@ VOID DoConfig(int pass) { if (SkipLine(pLineStart)) /* F5/F8 processing */ continue; - } + } if (pEntry->func != CfgMenu) pLine = skipwh(pLine); @@ -747,7 +753,7 @@ STATIC BOOL SkipLine(char *pLine) (MenuLine & (1 << MenuSelected)) == 0) return TRUE; - if (DontAskThisSingleCommand) /* !files=30 */ + if (DontAskThisSingleCommand) /* !files=30 */ return FALSE; if (!askThisSingleCommand && !singleStep) @@ -1001,9 +1007,9 @@ STATIC VOID Fcbs(BYTE * pLine) * Returns TRUE if successful, FALSE if not. */ +#if 0 STATIC BOOL LoadCountryInfo(char *filename, UWORD ctryCode, UWORD codePage) { -/* printf("cntry: %u, CP%u, file=\"%s\"\n", ctryCode, codePage, filename); */ printf("Sorry, the COUNTRY= statement has been temporarily disabled\n"); UNREFERENCED_PARAMETER(codePage); @@ -1011,41 +1017,46 @@ STATIC BOOL LoadCountryInfo(char *filename, UWORD ctryCode, UWORD codePage) UNREFERENCED_PARAMETER(filename); return FALSE; -} +} +#endif STATIC VOID Country(BYTE * pLine) { - /* Format: COUNTRY = countryCode, [codePage], filename */ + /* Format: COUNTRY = countryCode, [codePage], filename */ COUNT ctryCode; - COUNT codePage; + COUNT codePage = NLS_DEFAULT; + char *filename = ""; if ((pLine = GetNumArg(pLine, &ctryCode)) == 0) - return; + goto error; + + + /* currently 'implemented' + COUNTRY=49 */ +#if 0 pLine = skipwh(pLine); if (*pLine == ',') { pLine = skipwh(pLine + 1); - if (*pLine == ',') - { - codePage = NLS_DEFAULT; - } - else - { + if (*pLine != ',') if ((pLine = GetNumArg(pLine, &codePage)) == 0) - return; - } + goto error; pLine = skipwh(pLine); if (*pLine == ',') { GetStringArg(++pLine, szBuf); - - if (LoadCountryInfo(szBuf, ctryCode, codePage)) - return; + filename = szBuf; } - } + } +#endif + + if (!LoadCountryInfoHardCoded(filename, ctryCode, codePage)) + return; + +error: CfgFailure(pLine); } @@ -1252,7 +1263,7 @@ void FAR * KernelAlloc(size_t nBytes) #endif #ifdef I86 -/* +#if 0 STATIC BYTE FAR * KernelAllocDma(WORD bytes) { BYTE FAR *allocated; @@ -1264,7 +1275,7 @@ STATIC BYTE FAR * KernelAllocDma(WORD bytes) lpBase += bytes; return allocated; } -*/ +#endif STATIC void FAR * AlignParagraph(VOID FAR * lpPtr) { @@ -1302,14 +1313,14 @@ STATIC BYTE * scan(BYTE * s, BYTE * d) if (isnum(s)) { - unsigned numbers = 0; - for ( ; isnum(s); s++) - numbers |= 1 << (*s -'0'); - - if (*s == '?') - { - MenuLine = numbers; - Menus |= numbers; + unsigned numbers = 0; + for ( ; isnum(s); s++) + numbers |= 1 << (*s -'0'); + + if (*s == '?') + { + MenuLine = numbers; + Menus |= numbers; s = skipwh(s+1); } } @@ -1344,7 +1355,7 @@ STATIC BYTE * scan(BYTE * s, BYTE * d) return s; } -/* +#if 0 BYTE *scan_seperator(BYTE * s, BYTE * d) { s = skipwh(s); @@ -1353,7 +1364,7 @@ BYTE *scan_seperator(BYTE * s, BYTE * d) *d = '\0'; return s; } -*/ +#endif STATIC BOOL isnum(BYTE * pLine) { @@ -1609,14 +1620,15 @@ STATIC VOID DoMenu(void) InitKernelConfig.SkipConfigSeconds = -1; - Menus |= 1 << 0; /* '0' Menu always allowed */ + Menus |= 1 << 0; /* '0' Menu always allowed */ printf("\n\n"); - + for (;;) { int key,i; - + +RestartInput: printf("\rSinglestepping (F8) is :%s - ", singleStep ? "ON " : "OFF"); printf("please select a Menu["); @@ -1624,17 +1636,29 @@ STATIC VOID DoMenu(void) for (i = 0; i <= 9; i++) if (Menus & (1 << i)) printf("%c", '0' + i); - printf("]"); + printf("]"); - key = GetBiosKey(MenuTimeout); - - MenuTimeout = -1; - - if (key == -1) /* timeout, take default */ - { - break; - } + printf(" (default=%d)", MenuSelected); + if (MenuTimeout >= 0) + printf(" - %d \b", MenuTimeout); + else + printf(" \b\b\b\b\b"); + + key = GetBiosKey(MenuTimeout >= 0 ? 1 : -1); + + if (key == -1) /* timeout, take default */ + { + if (MenuTimeout > 0) + { + MenuTimeout--; + goto RestartInput; + } + break; + } + else + MenuTimeout = -1; + if (key == 0x3f00) /* F5 */ { SkipAllConfig = TRUE; @@ -1647,23 +1671,23 @@ STATIC VOID DoMenu(void) key &= 0xff; - if (key == '\r') /* CR - use default */ - { - break; + if (key == '\r') /* CR - use default */ + { + break; } - if (key == 0x1b) /* ESC - use default */ - { - break; + if (key == 0x1b) /* ESC - use default */ + { + break; } printf("%c", key); if (key >= '0' && key <= '9') if (Menus & (1 << (key - '0'))) - { - MenuSelected = key - '0'; break; + { + MenuSelected = key - '0'; break; } - } + } printf("\n"); } @@ -1692,3 +1716,605 @@ STATIC VOID CfgMenuDefault(BYTE * pLine) } + + + +/********************************************************************************* + National specific things. + this handles only Date/Time/Currency, and NOT codepage things. + Some may consider this a hack, but I like to see 24 Hour support. tom. +*********************************************************************************/ + + +struct CountrySpecificInfo { + short CountryID; /* = W1 W437 # Country ID & Codepage */ + short CodePage; + short DateFormat; /* Date format: 0/1/2: U.S.A./Europe/Japan */ + char CurrencyString[5]; /* '$' ,'EUR' */ + char ThousandSeparator[2]; /* ',' # Thousand's separator */ + char DecimalPoint[2]; /* '.' # Decimal point */ + char DateSeparator[2]; /* '-' */ + char TimeSeparator[2]; /* ':' */ + char CurrencyFormat; /* = 0 # Currency format (bit array) + 0Fh BYTE currency format + bit 2 = set if currency symbol replaces decimal point + bit 1 = number of spaces between value and currency symbol + bit 0 = 0 if currency symbol precedes value + 1 if currency symbol follows value + */ + char CurrencyPrecision; /* = 2 # Currency precision */ + char TimeFormat; /* = 0 # time format: 0/1: 12/24 houres */ +}; + + +#define _DATE_MDY 0 /* mm/dd/yy */ +#define _DATE_DMY 1 /* dd.mm.yy */ +#define _DATE_YMD 2 /* yy/mm/dd */ + +#define _TIME_12 0 +#define _TIME_24 1 + +struct CountrySpecificInfo specificCountriesSupported[] = { + + /* US */ { + 1, /* = W1 W437 # Country ID & Codepage */ + 437, + _DATE_MDY, /* Date format: 0/1/2: U.S.A./Europe/Japan */ + "$", /* '$' ,'EUR' */ + ",", /* ',' # Thousand's separator */ + ".", /* '.' # Decimal point */ + "/", /* '-' DateSeparator */ + ":", /* ':' TimeSeparator */ + 0, /* = 0 # Currency format (bit array) */ + 2, /* = 2 # Currency precision */ + _TIME_12 /* = 0 # time format: 0/1: 12/24 houres */ + } + + /* Canadian French */ ,{ + 2, /* = W1 W437 # Country ID & Codepage */ + 863, + _DATE_YMD, /* Date format: 0/1/2: U.S.A./Europe/Japan */ + "$", /* '$' ,'EUR' */ + ",", /* ',' # Thousand's separator */ + ".", /* '.' # Decimal point */ + "-", /* '-' DateSeparator */ + ":", /* ':' TimeSeparator */ + 0, /* = 0 # Currency format (bit array) */ + 2, /* = 2 # Currency precision */ + _TIME_24 /* = 0 # time format: 0/1: 12/24 houres */ + } + + /* Latin America */ ,{ + 3, /* = W1 W437 # Country ID & Codepage */ + 850, + _DATE_MDY, /* Date format: 0/1/2: U.S.A./Europe/Japan */ + "$", /* '$' ,'EUR' */ + ",", /* ',' # Thousand's separator */ + ".", /* '.' # Decimal point */ + "/", /* '-' DateSeparator */ + ":", /* ':' TimeSeparator */ + 0, /* = 0 # Currency format (bit array) */ + 2, /* = 2 # Currency precision */ + _TIME_12 /* = 0 # time format: 0/1: 12/24 houres */ + } + + /* Russia - by arkady */ ,{ + 7, /* = W1 W437 # Country ID & Codepage */ + 866, + _DATE_DMY, /* Date format: 0/1/2: U.S.A./Europe/Japan */ + "RUB", /* '$' ,'EUR' */ + /* should be "\xE0", but as no codepage + support exists (yet), better to leave it as 'Rubels' + */ + " ", /* ',' # Thousand's separator */ + ",", /* '.' # Decimal point */ + ".", /* '-' DateSeparator */ + ":", /* ':' TimeSeparator */ + 3, /* Currency format : currency follows, after blank */ + 2, /* = 2 # Currency precision */ + _TIME_24 /* = 0 # time format: 0/1: 12/24 houres */ + } + + /* DUTCH */ ,{ + 31, /* = W1 W437 # Country ID & Codepage */ + 850, + _DATE_DMY, /* Date format: 0/1/2: U.S.A./Europe/Japan */ + "EUR", /* '$' ,'EUR' */ + ".", /* ',' # Thousand's separator */ + ",", /* '.' # Decimal point */ + "-", /* '-' DateSeparator */ + ":", /* ':' TimeSeparator */ + 0, /* = 0 # Currency format (bit array) */ + 2, /* = 2 # Currency precision */ + _TIME_24 /* = 0 # time format: 0/1: 12/24 houres */ + } + + /* Belgium */ ,{ + 32, /* = W1 W437 # Country ID & Codepage */ + 850, + _DATE_DMY, /* Date format: 0/1/2: U.S.A./Europe/Japan */ + "EUR", /* '$' ,'EUR' */ + ".", /* ',' # Thousand's separator */ + ",", /* '.' # Decimal point */ + "-", /* '-' DateSeparator */ + ":", /* ':' TimeSeparator */ + 0, /* = 0 # Currency format (bit array) */ + 2, /* = 2 # Currency precision */ + _TIME_24 /* = 0 # time format: 0/1: 12/24 houres */ + } + + /* France */ ,{ + 33, /* = W1 W437 # Country ID & Codepage */ + 850, + _DATE_DMY, /* Date format: 0/1/2: U.S.A./Europe/Japan */ + "EUR", /* '$' ,'EUR' */ + ".", /* ',' # Thousand's separator */ + ",", /* '.' # Decimal point */ + "-", /* '-' DateSeparator */ + ":", /* ':' TimeSeparator */ + 0, /* = 0 # Currency format (bit array) */ + 2, /* = 2 # Currency precision */ + _TIME_24 /* = 0 # time format: 0/1: 12/24 houres */ + } + + /* Spain */ ,{ + 33, /* = W1 W437 # Country ID & Codepage */ + 850, + _DATE_DMY, /* Date format: 0/1/2: U.S.A./Europe/Japan */ + "EUR", /* '$' ,'EUR' */ + ".", /* ',' # Thousand's separator */ + "'", /* Decimal point - by aitor */ + "-", /* '-' DateSeparator */ + ":", /* ':' TimeSeparator */ + 0, /* = 0 # Currency format (bit array) */ + 2, /* = 2 # Currency precision */ + _TIME_24 /* = 0 # time format: 0/1: 12/24 houres */ + } + + /* Hungary */ ,{ + 36, /* = W1 W437 # Country ID & Codepage */ + 850, + _DATE_DMY, /* Date format: 0/1/2: U.S.A./Europe/Japan */ + "$HU", /* '$' ,'EUR' */ + ".", /* ',' # Thousand's separator */ + ",", /* '.' # Decimal point */ + "-", /* '-' DateSeparator */ + ":", /* ':' TimeSeparator */ + 0, /* = 0 # Currency format (bit array) */ + 2, /* = 2 # Currency precision */ + _TIME_24 /* = 0 # time format: 0/1: 12/24 houres */ + } + + /* Yugoslavia */ ,{ + 38, /* = W1 W437 # Country ID & Codepage */ + 850, + _DATE_DMY, /* Date format: 0/1/2: U.S.A./Europe/Japan */ + "$YU", /* '$' ,'EUR' */ + ".", /* ',' # Thousand's separator */ + ",", /* '.' # Decimal point */ + "-", /* '-' DateSeparator */ + ":", /* ':' TimeSeparator */ + 0, /* = 0 # Currency format (bit array) */ + 2, /* = 2 # Currency precision */ + _TIME_24 /* = 0 # time format: 0/1: 12/24 houres */ + } + + /* Italy */ ,{ + 39, /* = W1 W437 # Country ID & Codepage */ + 850, + _DATE_DMY, /* Date format: 0/1/2: U.S.A./Europe/Japan */ + "EUR", /* '$' ,'EUR' */ + ".", /* ',' # Thousand's separator */ + ",", /* '.' # Decimal point */ + "-", /* '-' DateSeparator */ + ":", /* ':' TimeSeparator */ + 0, /* = 0 # Currency format (bit array) */ + 2, /* = 2 # Currency precision */ + _TIME_24 /* = 0 # time format: 0/1: 12/24 houres */ + } + + /* Switzerland */ ,{ + 41, /* = W1 W437 # Country ID & Codepage */ + 850, + _DATE_DMY, /* Date format: 0/1/2: U.S.A./Europe/Japan */ + "SF", /* '$' ,'EUR' */ + ".", /* ',' # Thousand's separator */ + ",", /* '.' # Decimal point */ + ".", /* '-' DateSeparator */ + ":", /* ':' TimeSeparator */ + 0, /* = 0 # Currency format (bit array) */ + 2, /* = 2 # Currency precision */ + _TIME_24 /* = 0 # time format: 0/1: 12/24 houres */ + } + + /* Czechoslovakia */ ,{ + 42, /* = W1 W437 # Country ID & Codepage */ + 850, + _DATE_YMD, /* Date format: 0/1/2: U.S.A./Europe/Japan */ + "$YU", /* '$' ,'EUR' */ + ".", /* ',' # Thousand's separator */ + ",", /* '.' # Decimal point */ + ".", /* '-' DateSeparator */ + ":", /* ':' TimeSeparator */ + 0, /* = 0 # Currency format (bit array) */ + 2, /* = 2 # Currency precision */ + _TIME_24 /* = 0 # time format: 0/1: 12/24 houres */ + } + + /* UK */ ,{ + 44, /* = W1 W437 # Country ID & Codepage */ + 850, + _DATE_DMY, /* Date format: 0/1/2: U.S.A./Europe/Japan */ + "\x9c", /* Pound sign */ + ".", /* ',' # Thousand's separator */ + ",", /* '.' # Decimal point */ + "/", /* '-' DateSeparator */ + ":", /* ':' TimeSeparator */ + 0, /* = 0 # Currency format (bit array) */ + 2, /* = 2 # Currency precision */ + _TIME_24 /* = 0 # time format: 0/1: 12/24 houres */ + } + + /* Denmark */ ,{ + 45, /* = W1 W437 # Country ID & Codepage */ + 850, + _DATE_DMY, /* Date format: 0/1/2: U.S.A./Europe/Japan */ + "DKK", /* */ + ".", /* ',' # Thousand's separator */ + ",", /* '.' # Decimal point */ + "-", /* '-' DateSeparator */ + ":", /* ':' TimeSeparator */ + 0, /* = 0 # Currency format (bit array) */ + 2, /* = 2 # Currency precision */ + _TIME_24 /* = 0 # time format: 0/1: 12/24 houres */ + } + /* Sweden */ ,{ + 46, /* = W1 W437 # Country ID & Codepage */ + 850, + _DATE_YMD, /* Date format: 0/1/2: U.S.A./Europe/Japan */ + "SEK", /* */ + ",", /* ',' # Thousand's separator */ + ".", /* '.' # Decimal point */ + "-", /* '-' DateSeparator */ + ":", /* ':' TimeSeparator */ + 0, /* = 0 # Currency format (bit array) */ + 2, /* = 2 # Currency precision */ + _TIME_24 /* = 0 # time format: 0/1: 12/24 houres */ + } + + /* Norway */ ,{ + 47, /* = W1 W437 # Country ID & Codepage */ + 850, + _DATE_DMY, /* Date format: 0/1/2: U.S.A./Europe/Japan */ + "NOK", /* */ + ",", /* ',' # Thousand's separator */ + ".", /* '.' # Decimal point */ + ".", /* '-' DateSeparator */ + ":", /* ':' TimeSeparator */ + 0, /* = 0 # Currency format (bit array) */ + 2, /* = 2 # Currency precision */ + _TIME_24 /* = 0 # time format: 0/1: 12/24 houres */ + } + + /* Poland */ ,{ + 48, /* = W1 W437 # Country ID & Codepage */ + 850, + _DATE_YMD, /* Date format: 0/1/2: U.S.A./Europe/Japan */ + "PLN", /* michael tyc: PLN means PoLish New zloty, I think) */ + ",", /* ',' # Thousand's separator */ + ".", /* '.' # Decimal point */ + ".", /* '-' DateSeparator */ + ":", /* ':' TimeSeparator */ + 0, /* = 0 # Currency format (bit array) */ + 2, /* = 2 # Currency precision */ + _TIME_24 /* = 0 # time format: 0/1: 12/24 houres */ + } + + /* GERMAN */ ,{ + 49, /* = W1 W437 # Country ID & Codepage */ + 850, + _DATE_DMY, /* Date format: 0/1/2: U.S.A./Europe/Japan */ + "EUR", /* '$' ,'EUR' */ + ".", /* ',' # Thousand's separator */ + ",", /* '.' # Decimal point */ + ".", /* '-' DateSeparator */ + ":", /* ':' TimeSeparator */ + 1, /* = 0 # Currency format (bit array) */ + 2, /* = 2 # Currency precision */ + _TIME_24 /* = 0 # time format: 0/1: 12/24 houres */ + } + + /* Argentina */ ,{ + 54, /* = W1 W437 # Country ID & Codepage */ + 850, + _DATE_DMY, /* Date format: 0/1/2: U.S.A./Europe/Japan */ + "$ar", /* '$' ,'EUR' */ + ".", /* ',' # Thousand's separator */ + ",", /* '.' # Decimal point */ + "/", /* '-' DateSeparator */ + ":", /* ':' TimeSeparator */ + 1, /* = 0 # Currency format (bit array) */ + 2, /* = 2 # Currency precision */ + _TIME_12 /* = 0 # time format: 0/1: 12/24 houres */ + } + + /* Brazil */ ,{ + 55, /* = W1 W437 # Country ID & Codepage */ + 850, + _DATE_DMY, /* Date format: 0/1/2: U.S.A./Europe/Japan */ + "$ar", /* '$' ,'EUR' */ + ".", /* ',' # Thousand's separator */ + ",", /* '.' # Decimal point */ + "/", /* '-' DateSeparator */ + ":", /* ':' TimeSeparator */ + 1, /* = 0 # Currency format (bit array) */ + 2, /* = 2 # Currency precision */ + _TIME_24 /* = 0 # time format: 0/1: 12/24 houres */ + } + + /* International English */ ,{ + 61, /* = W1 W437 # Country ID & Codepage */ + 850, + _DATE_MDY, /* Date format: 0/1/2: U.S.A./Europe/Japan */ + "$", /* '$' ,'EUR' */ + ".", /* ',' # Thousand's separator */ + ",", /* '.' # Decimal point */ + "/", /* '-' DateSeparator */ + ":", /* ':' TimeSeparator */ + 0, /* = 0 # Currency format (bit array) */ + 2, /* = 2 # Currency precision */ + _TIME_24 /* = 0 # time format: 0/1: 12/24 houres */ + } + + /* Japan - Yuki Mitsui */ ,{ + 81, /* = W1 W437 # Country ID & Codepage */ + 932, + _DATE_YMD, /* Date format: 0/1/2:U.S.A./Europe/Japan */ + "\x81\x8f", /* '$' ,'EUR' */ + ",", /* ',' # Thousand's separator */ + ".", /* '.' # Decimal point */ + "/", /* '-' DateSeparator */ + ":", /* ':' TimeSeparator */ + 0, /* = 0 # Currency format (bit array) */ + 2, /* = 2 # Currency precision */ + _TIME_12 /* = 0 # time format: 0/1: 12/24 houres + */ + } + + /* Portugal */ ,{ + 351, /* = W1 W437 # Country ID & Codepage */ + 850, + _DATE_DMY, /* Date format: 0/1/2: U.S.A./Europe/Japan */ + "EUR", /* '$' ,'EUR' */ + ".", /* ',' # Thousand's separator */ + ",", /* '.' # Decimal point */ + "-", /* '-' DateSeparator */ + ":", /* ':' TimeSeparator */ + 0, /* = 0 # Currency format (bit array) */ + 2, /* = 2 # Currency precision */ + _TIME_24 /* = 0 # time format: 0/1: 12/24 houres */ + } + + /* Finland - by wolf */ ,{ + 358, /* = W1 W437 # Country ID & Codepage */ + 850, + _DATE_DMY, /* Date format: 0/1/2: U.S.A./Europe/Japan */ + "EUR", /* '$' ,'EUR' */ + " ", /* ',' # Thousand's separator */ + ",", /* '.' # Decimal point */ + ".", /* '-' DateSeparator */ + ":", /* ':' TimeSeparator */ + 0x3, /* # Currency format (bit array) */ + 2, /* = 2 # Currency precision */ + _TIME_24 /* = 0 # time format: 0/1: 12/24 hours */ + } + + /* Ukraine - by Oleg Deribas */ ,{ + 380, /* = W380 W848 # Country ID & Codepage */ + 848, + _DATE_DMY, /* Date format: 0/1/2: U.S.A./Europe/Japan */ + "UAH", /* Currency */ + " ", /* ' ' # Thousand's separator */ + ",", /* ',' # Decimal point */ + ".", /* '.' DateSeparator */ + ":", /* ':' TimeSeparator */ + 3, /* = 3 # Currency format (bit array) */ + 2, /* = 2 # Currency precision */ + _TIME_24 /* = 1 # time format: 0/1: 12/24 houres */ + } + +}; + + +/* contributors to above table: + + tom ehlert (GER) + bart oldeman (NL) + wolf (FIN) + Michael H.Tyc (POL) + Oleg Deribas (UKR) + Arkady Belousov (RUS) + Yuki Mitsui (JAP) + Aitor Santamar­a Merino (SP) +*/ + + + +extern struct { + char ThisIsAConstantOne; + short TableSize; + + struct CountrySpecificInfo C; + +} FAR nlsCountryInfoHardcoded; + + + +STATIC int LoadCountryInfoHardCoded(char *filename, COUNT ctryCode, COUNT codePage) +{ + int i; + UNREFERENCED_PARAMETER(codePage); + UNREFERENCED_PARAMETER(filename); + + /* printf("cntry: %u, CP%u, file=\"%s\"\n", ctryCode, codePage, filename); */ + + + + for (i = 0; i < sizeof(specificCountriesSupported)/sizeof(specificCountriesSupported[0]); i++) + { + if (specificCountriesSupported[i].CountryID == ctryCode) + { + int codepagesaved = nlsCountryInfoHardcoded.C.CodePage; + + fmemcpy(&nlsCountryInfoHardcoded.C.CountryID, + &specificCountriesSupported[i], + min(nlsCountryInfoHardcoded.TableSize, sizeof(struct CountrySpecificInfo))); + + nlsCountryInfoHardcoded.C.CodePage = codepagesaved; + + return 0; + } + } + + printf("could not find country info for country ID %u\n", ctryCode); + printf("current supported countries are "); + + for (i = 0; i < sizeof(specificCountriesSupported)/sizeof(specificCountriesSupported[0]); i++) + { + printf("%u ",specificCountriesSupported[i].CountryID); + } + printf("\n"); + + return 1; +} + + +/* **************************************************************** +** implementation of INSTALL=NANSI.COM /P /X /BLA +*/ + +int numInstallCmds = 0; +struct { + char buffer[128]; + int mode; +} InstallCommands[10]; + +#define InstallPrintf(x) +/*#define InstallPrintf(x) printf x*/ + + +STATIC VOID _CmdInstall(BYTE * pLine,int mode) +{ + InstallPrintf(("Installcmd %d:%s\n",numInstallCmds,pLine)); + + if (numInstallCmds > LENGTH(InstallCommands)) + { + printf("Too many Install commands given (%d max)\n",LENGTH(InstallCommands)); + CfgFailure(pLine); + return; + } + fmemcpy(InstallCommands[numInstallCmds].buffer,pLine,127); + InstallCommands[numInstallCmds].buffer[127] = 0; + InstallCommands[numInstallCmds].mode = mode; + numInstallCmds++; +} +STATIC VOID CmdInstall(BYTE * pLine) +{ + _CmdInstall(pLine,0); +} +STATIC VOID CmdInstallHigh(BYTE * pLine) +{ + _CmdInstall(pLine,0x80); /* load high, if possible */ +} + +void InstallExec(char *cmd) +{ + BYTE filename[128],*args,*d; + exec_blk exb; + + InstallPrintf(("installing %s\n",cmd)); + + cmd=skipwh(cmd); + + for (args = cmd, d = filename; ;args++,d++) + { + *d = *args; + if (*d <= 0x020 || *d == '/') + break; + } + *d = 0; + + args--; + *args = 0; + while (args[*args+1]) + ++*args; + args[*args+1] = '\r'; + args[*args+2] = 0; + + exb.exec.env_seg = 0; + exb.exec.cmd_line = (CommandTail FAR *) args; + exb.exec.fcb_1 = exb.exec.fcb_2 = (fcb FAR *) 0xfffffffful; + + + InstallPrintf(("cmd[%s] args [%u,%s]\n",filename,*args,args+1)); + + if (init_DosExec(0, &exb, filename) != SUCCESS) + { + CfgFailure(cmd); + } +} + + +VOID DoInstall(void) +{ + int i; + iregs r; + extern BYTE ASM _init_end[]; + unsigned short installMemory; + + + if (numInstallCmds == 0) + return; + + InstallPrintf(("Installing commands now\n")); + + /* grab memory for this install code + we KNOW, that we are executing somewhere at top of memory + we need to protect the INIT_CODE from other programs + that will be executing soon + */ + + r.a.x = 0x5801; /* set memory allocation strategy */ + r.b.b.l = 0x02; /*low memory, last fit */ + init_call_intr(0x21, &r); + + r.a.b.h = 0x48; /* alloc memory */ + r.b.x = ((unsigned)_init_end+15)/16; + init_call_intr(0x21, &r); + installMemory = r.a.x; + + + InstallPrintf(("allocated memory at %x\n",installMemory)); + + for (i = 0; i < numInstallCmds; i++) + { + InstallPrintf(("%d:%s\n",i,InstallCommands[i].buffer)); + + r.a.x = 0x5801; /* set memory allocation strategy */ + r.b.b.l = InstallCommands[i].mode; + init_call_intr(0x21, &r); + + InstallExec(InstallCommands[i].buffer); + } + + r.a.x = 0x5801; /* set memory allocation strategy */ + r.b.b.l = 0x00; /*low memory, high */ + init_call_intr(0x21, &r); + + r.a.b.h = 0x49; /* alloc memory */ + r.es = installMemory; + init_call_intr(0x21, &r); + + InstallPrintf(("Done with installing commands\n")); + return; +} diff --git a/kernel/init-mod.h b/kernel/init-mod.h index 1f2d82e8..c4962f6b 100644 --- a/kernel/init-mod.h +++ b/kernel/init-mod.h @@ -115,6 +115,7 @@ char *strcat(char * d, const char * s); COUNT ASMCFUNC Umb_Test(void); COUNT ASMCFUNC UMB_get_largest(UCOUNT * seg, UCOUNT * size); BYTE * GetStringArg(BYTE * pLine, BYTE * pszString); +void DoInstall(void); /* diskinit.c */ COUNT dsk_init(VOID); diff --git a/kernel/main.c b/kernel/main.c index b40b9390..b95c07bd 100644 --- a/kernel/main.c +++ b/kernel/main.c @@ -181,6 +181,9 @@ VOID ASMCFUNC FreeDOSmain(void) /* Non-portable message kludge alert! */ printf("KERNEL: Boot drive = %c\n", 'A' + BootDrive - 1); #endif + + DoInstall(); + kernel(); } From 355580dded34352b22b2f904fb6eec21b9603968 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Wed, 12 Mar 2003 23:29:08 +0000 Subject: [PATCH 187/671] Eliminate highwater fnode field. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@540 6ac86273-5f31-0410-b378-82cca8765d1b --- hdr/fnode.h | 1 - kernel/dosfns.c | 4 ++-- kernel/fatdir.c | 2 +- kernel/fatfs.c | 48 ++++++++++++++++++------------------------------ 4 files changed, 21 insertions(+), 34 deletions(-) diff --git a/hdr/fnode.h b/hdr/fnode.h index c9bb939a..9d1e1cc1 100644 --- a/hdr/fnode.h +++ b/hdr/fnode.h @@ -55,7 +55,6 @@ struct f_node { struct dpb FAR *f_dpb; /* the block device for file */ ULONG f_offset; /* byte offset for next op */ - ULONG f_highwater; /* the largest offset ever */ CLUSTER f_back; /* the cluster we were at */ CLUSTER f_cluster_offset; /* relative cluster number within file */ CLUSTER f_cluster; /* the cluster we are at */ diff --git a/kernel/dosfns.c b/kernel/dosfns.c index 74fa0bd6..53a0d7d4 100644 --- a/kernel/dosfns.c +++ b/kernel/dosfns.c @@ -1072,8 +1072,8 @@ COUNT DosFindNext(void) COUNT rc; register dmatch FAR *dmp = dta; - /* /// findnext will always fail on a device name. - Ron Cemer */ - if (dmp->dm_attr_fnd == D_DEVICE) + /* /// findnext will always fail on a device name device name or volume id */ + if (dmp->dm_attr_fnd == D_DEVICE || dmp->dm_attr_fnd & D_VOLID) return DE_NFILES; /* diff --git a/kernel/fatdir.c b/kernel/fatdir.c index 14a1ace9..e76a413c 100644 --- a/kernel/fatdir.c +++ b/kernel/fatdir.c @@ -46,7 +46,7 @@ VOID dir_init_fnode(f_node_ptr fnp, CLUSTER dirstart) fnp->f_flags.f_droot = FALSE; fnp->f_flags.f_ddir = TRUE; fnp->f_flags.f_dnew = TRUE; - fnp->f_diroff = fnp->f_offset = fnp->f_highwater = 0l; + fnp->f_diroff = fnp->f_offset = 0l; fnp->f_cluster_offset = 0; /* root directory */ diff --git a/kernel/fatfs.c b/kernel/fatfs.c index 23b933b0..5fd406e7 100644 --- a/kernel/fatfs.c +++ b/kernel/fatfs.c @@ -229,7 +229,6 @@ long dos_open(char *path, unsigned flags, unsigned attrib) /* Now change to file */ fnp->f_offset = 0l; - fnp->f_highwater = fnp->f_dir.dir_size; fnp->f_back = LONG_LAST_CLUSTER; if (status != S_OPENED) @@ -288,7 +287,6 @@ COUNT dos_close(COUNT fd) fnp->f_dir.dir_date = dos_getdate(); } - fnp->f_dir.dir_size = fnp->f_highwater; merge_file_changes(fnp, FALSE); /* /// Added - Ron Cemer */ } fnp->f_flags.f_ddir = TRUE; @@ -470,7 +468,6 @@ STATIC void merge_file_changes(f_node_ptr fnp, int collect) f_node which refers to this file. */ if (fnp2->f_mode != RDONLY) { - fnp2->f_dir.dir_size = fnp2->f_highwater; copy_file_changes(fnp2, fnp); break; } @@ -480,8 +477,6 @@ STATIC void merge_file_changes(f_node_ptr fnp, int collect) /* We just made changes to this file, so we are distributing these changes to the other f_nodes which refer to this file. */ - if (fnp->f_mode != RDONLY) - fnp->f_dir.dir_size = fnp->f_highwater; copy_file_changes(fnp, fnp2); } } @@ -505,7 +500,6 @@ STATIC int is_same_file(f_node_ptr fnp1, f_node_ptr fnp2) /* /// Added - Ron Cemer */ STATIC void copy_file_changes(f_node_ptr src, f_node_ptr dst) { - dst->f_highwater = src->f_highwater; dst->f_dir.dir_start = src->f_dir.dir_start; #ifdef WITHFAT32 dst->f_dir.dir_start_high = src->f_dir.dir_start_high; @@ -758,8 +752,6 @@ COUNT dos_rename(BYTE * path1, BYTE * path2, int attrib) fnp1->f_flags.f_dnew = fnp2->f_flags.f_dnew = FALSE; fnp1->f_flags.f_ddir = fnp2->f_flags.f_ddir = TRUE; - fnp2->f_highwater = fnp2->f_offset = fnp1->f_dir.dir_size; - /* Ok, so we can delete this one. Save the file info. */ *(fnp1->f_dir.dir_name) = DELETED; @@ -929,7 +921,7 @@ ULONG dos_getfsize(COUNT fd) return (ULONG)-1l; /* Return the file size */ - return fnp->f_highwater; + return fnp->f_dir.dir_size; } /* */ @@ -951,7 +943,6 @@ BOOL dos_setfsize(COUNT fd, LONG size) /* Change the file size */ fnp->f_dir.dir_size = size; - fnp->f_highwater = size; merge_file_changes(fnp, FALSE); /* /// Added - Ron Cemer */ @@ -1126,7 +1117,6 @@ COUNT dos_mkdir(BYTE * dir) fnp->f_flags.f_dnew = FALSE; fnp->f_flags.f_ddir = TRUE; - fnp->f_highwater = 0l; fnp->f_offset = 0l; /* Mark the cluster in the FAT as used */ @@ -1401,7 +1391,7 @@ COUNT map_cluster(REG f_node_ptr fnp, COUNT mode) return SUCCESS; } -/* extends a file from f_highwater to f_offset */ +/* extends a file from f_dir.dir_size to f_offset */ /* Proper OS's write zeros in between, but DOS just adds */ /* garbage sectors, and lets the caller do the zero filling */ /* if you prefer you can have this enabled using */ @@ -1418,12 +1408,12 @@ STATIC COUNT dos_extend(f_node_ptr fnp) ULONG count; #endif - if (fnp->f_offset <= fnp->f_highwater) + if (fnp->f_offset <= fnp->f_dir.dir_size) return SUCCESS; #ifdef WRITEZEROS - count = fnp->f_offset - fnp->f_highwater; - fnp->f_offset = fnp->f_highwater; + count = fnp->f_offset - fnp->f_dir.dir_size; + fnp->f_offset = fnp->f_dir.dir_size; while (count > 0) #endif { @@ -1473,9 +1463,8 @@ STATIC COUNT dos_extend(f_node_ptr fnp) /* update pointers and counters */ count -= xfr_cnt; fnp->f_offset += xfr_cnt; - fnp->f_dir.dir_size = fnp->f_offset; #endif - fnp->f_highwater = fnp->f_offset; + fnp->f_dir.dir_size = fnp->f_offset; merge_file_changes(fnp, FALSE); /* /// Added - Ron Cemer */ } return SUCCESS; @@ -1536,7 +1525,7 @@ STATIC COUNT dos_extend(f_node_ptr fnp) better for the people, that complain about slow floppy access the - fnp->f_offset +to_xfer < fnp->f_highwater && avoid EOF problems + fnp->f_offset +to_xfer < fnp->f_dir.dir_size && avoid EOF problems condition can probably _carefully_ be dropped @@ -1604,7 +1593,7 @@ UCOUNT rwblock(COUNT fd, VOID FAR * buffer, UCOUNT count, int mode) /* remove all the following allocated clusters in shrink_file */ if (mode == XFR_WRITE) { - fnp->f_highwater = fnp->f_offset; + fnp->f_dir.dir_size = fnp->f_offset; shrink_file(fnp); } return 0; @@ -1622,7 +1611,7 @@ UCOUNT rwblock(COUNT fd, VOID FAR * buffer, UCOUNT count, int mode) { /* Do an EOF test and return whatever was transferred */ /* but only for regular files. */ - if (mode == XFR_READ && !(fnp->f_flags.f_ddir) && (fnp->f_offset >= fnp->f_highwater)) + if (mode == XFR_READ && !(fnp->f_flags.f_ddir) && (fnp->f_offset >= fnp->f_dir.dir_size)) { return ret_cnt; } @@ -1680,8 +1669,8 @@ UCOUNT rwblock(COUNT fd, VOID FAR * buffer, UCOUNT count, int mode) sectors_wanted = to_xfer; /* avoid EOF problems */ - if (mode == XFR_READ && to_xfer > fnp->f_highwater - fnp->f_offset) - sectors_wanted = (UCOUNT)(fnp->f_highwater - fnp->f_offset); + if (mode == XFR_READ && to_xfer > fnp->f_dir.dir_size - fnp->f_offset) + sectors_wanted = (UCOUNT)(fnp->f_dir.dir_size - fnp->f_offset); sectors_wanted /= secsize; @@ -1759,7 +1748,7 @@ UCOUNT rwblock(COUNT fd, VOID FAR * buffer, UCOUNT count, int mode) /* a maximum of what is left. */ xfr_cnt = min(to_xfer, secsize - fnp->f_boff); if (!fnp->f_flags.f_ddir && mode == XFR_READ) - xfr_cnt = (UWORD) min(xfr_cnt, fnp->f_highwater - fnp->f_offset); + xfr_cnt = (UWORD) min(xfr_cnt, fnp->f_dir.dir_size - fnp->f_offset); /* transfer a block */ /* Transfer size as either a full block size, or the */ @@ -1780,7 +1769,7 @@ UCOUNT rwblock(COUNT fd, VOID FAR * buffer, UCOUNT count, int mode) probably not reused later */ if (xfr_cnt == sizeof(bp->b_buffer) || - (mode == XFR_READ && fnp->f_offset + xfr_cnt == fnp->f_highwater)) + (mode == XFR_READ && fnp->f_offset + xfr_cnt == fnp->f_dir.dir_size)) { bp->b_flag |= BFR_UNCACHE; } @@ -1794,10 +1783,9 @@ UCOUNT rwblock(COUNT fd, VOID FAR * buffer, UCOUNT count, int mode) buffer = add_far((VOID FAR *) buffer, (ULONG) xfr_cnt); if (mode == XFR_WRITE) { - if (fnp->f_offset > fnp->f_highwater) + if (fnp->f_offset > fnp->f_dir.dir_size) { - fnp->f_highwater = fnp->f_offset; - fnp->f_dir.dir_size = fnp->f_highwater; + fnp->f_dir.dir_size = fnp->f_offset; } merge_file_changes(fnp, FALSE); /* /// Added - Ron Cemer */ } @@ -1836,7 +1824,7 @@ LONG dos_lseek(COUNT fd, LONG foffset, COUNT origin) /* offset from eof */ case 2: - return fnp->f_offset = fnp->f_highwater + foffset; + return fnp->f_offset = fnp->f_dir.dir_size + foffset; /* default to an invalid function */ default: @@ -2183,7 +2171,7 @@ STATIC VOID shrink_file(f_node_ptr fnp) CLUSTER next, st; struct dpb FAR *dpbp = fnp->f_dpb; - fnp->f_offset = fnp->f_highwater; /* end of file */ + fnp->f_offset = fnp->f_dir.dir_size; /* end of file */ if (fnp->f_offset) fnp->f_offset--; /* last existing cluster */ @@ -2203,7 +2191,7 @@ STATIC VOID shrink_file(f_node_ptr fnp) /* last cluster is encountered. */ /* zap the FAT pointed to */ - if (fnp->f_highwater == 0) + if (fnp->f_dir.dir_size == 0) { setdstart(fnp->f_dir, FREE); link_fat(dpbp, st, FREE); From 3cd84d893efa26b20c31ea9b8c4872207694d440 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Wed, 12 Mar 2003 23:29:50 +0000 Subject: [PATCH 188/671] bump up to 2029 git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@541 6ac86273-5f31-0410-b378-82cca8765d1b --- hdr/version.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/hdr/version.h b/hdr/version.h index b31718f6..8afa7921 100644 --- a/hdr/version.h +++ b/hdr/version.h @@ -47,8 +47,8 @@ static BYTE *date_hRcsId = #define REVISION_MAJOR 1 #define REVISION_MINOR 1 -#define REVISION_SEQ 28 -#define BUILD "2028" +#define REVISION_SEQ 29 +#define BUILD "2029" #define SUB_BUILD "" -#define KERNEL_VERSION_STRING "1.1.28" /*#REVISION_MAJOR "." #REVISION_MINOR "." #REVISION_SEQ */ -#define KERNEL_BUILD_STRING "2028" /*#BUILD SUB_BUILD */ +#define KERNEL_VERSION_STRING "1.1.29" /*#REVISION_MAJOR "." #REVISION_MINOR "." #REVISION_SEQ */ +#define KERNEL_BUILD_STRING "2029" /*#BUILD SUB_BUILD */ From a54e7ab2bf150b77a1a69d223ca8ee87ffd8bf6f Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Wed, 12 Mar 2003 23:31:18 +0000 Subject: [PATCH 189/671] Bump up to 2029 git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@542 6ac86273-5f31-0410-b378-82cca8765d1b --- docs/fdkernel.lsm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/fdkernel.lsm b/docs/fdkernel.lsm index ce090672..26dde02d 100644 --- a/docs/fdkernel.lsm +++ b/docs/fdkernel.lsm @@ -1,7 +1,7 @@ Begin3 Title: The FreeDOS Kernel -Version: 2.0.28 -Entered-date: 09 Dec 2002 +Version: 2.0.29 +Entered-date: 14 Mar 2003 Description: The FreeDOS Kernel. Keywords: kernel freedos dos msdos Author: (developers) From bf5d83c016f38ef13dc48234f9e277ede87ab090 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sat, 15 Mar 2003 04:18:09 +0000 Subject: [PATCH 190/671] Final changes for kernel 2029 git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@543 6ac86273-5f31-0410-b378-82cca8765d1b --- docs/build.txt | 41 ++++++++++-------- docs/history.txt | 19 +++++++++ docs/readme.txt | 2 +- hdr/algnbyte.h | 2 +- hdr/algndflt.h | 2 +- kernel/prf.c | 104 +++++++++++++++++++-------------------------- lib/makefile | 2 +- mkfiles/watcom.mak | 6 +-- utils/patchobj.c | 8 +++- 9 files changed, 99 insertions(+), 87 deletions(-) diff --git a/docs/build.txt b/docs/build.txt index a8b56388..bc1e1815 100644 --- a/docs/build.txt +++ b/docs/build.txt @@ -17,32 +17,37 @@ You will also need to download the latest version of NASM and Turbo C where) and then be sure to edit the CONFIG.MAK file to reflect where you put the tools. -*TE******* Make sure to use the NASMR version, as the DosExtender version - _seems_ to produce wrong code. the tested version is - NASM98R, 06/04/99, 202.606 bytes. -*Bart***** This is probably only true for Windows NT/2k/XP; In that - case you could use the Win32 version anyway. -Look at -ftp://ftp.kernel.org/pub/software/devel/nasm -or a mirror of ftp.kernel.org. - - -This kernel will now compile with Turbo C 2.01 (now freely +You can find NASM at http://nasm.sourceforge.net. Version 0.98.36 is +strongly recommended. The older 0.98 will also work fine, but +any version in between is likely to fail. It's best to use a NASM +that is native to your host; that is, when compiling in Windows, use +the win32 version. The DJGPP version is less likely to run out of +memory than the DOS version. + +Optionally, the kernel can be compressed using UPX. You can find +UPX at http://upx.sourceforge.net. Simply adjust config.bat to +enable it. + +This kernel will now compile with Turbo C 2.01, Turbo C++ 1.01 (now freely available!), Turbo C 3.0, Borland C 4.51 & 5.01. It should work with -other Borland compilers, Microsoft C and Watcom C. +other Borland compilers, Microsoft C and (Open)Watcom C. -The Watcom C 11.0c beta compiler for DOS can now be downloaded at +The OpenWatcom 1.0 compiler for DOS can now be downloaded at www.openwatcom.org: you need at least the following zips from ftp://ftp.openwatcom.org/watcom/zips/ -core_all - Core binaries (All hosts) -clib_hdr - C runtime library header files +cm_core_all - Core binaries (All hosts) +cm_clib_hdr - C runtime library header files +cm_clib_a16 - C runtime libraries (16-bit all targets) clib_a16 - C runtime libraries (16-bit all targets) +cm_clib_d16 - C runtime libraries (16-bit DOS) clib_d16 - C runtime libraries (16-bit DOS) -core_binw - Core binaries (DOS host) -c_binw - C compiler (DOS host) +cm_core_dos - Core binaries (DOS host) +core_doswin - Core binaries (DOS & Win16 hosts) +c_doswin - C compiler (DOS & Win16 hosts) +ext_dos4gw - DOS/4GW DOS extender -Replace binw by binnt for an NT host or binp for an OS/2 host. +Replace "dos" by "nt" for an NT/Win9x host or "os2" for an OS/2 host. The host needs to be a 386+ with at least 8MB of memory. If you feel hardy, read on to understand the directory structure. A diff --git a/docs/history.txt b/docs/history.txt index a0e3345b..62e29faf 100644 --- a/docs/history.txt +++ b/docs/history.txt @@ -1,3 +1,22 @@ +2002 Mar 14 - Build 2029 +-------- Bart Oldeman (bart@dosemu.org) ++ Changes Tom + * fattab.c, fat.h removed the wrong ELSE_ISFAT32() + * fatfs.c: rmdir would crash if you rmdir'ed an existing file + * config.c, main.c, portab.h + implement INSTALL and INSTALLHIGH for config.sys + basic COUNTRY=xxx support (with a little help from others, + mentioned in config.c) + * execrh.asm: save si, di for strategy device driver handler + * (adjusted by Bart): the internal "truename" has to reject + wildcards for all commands except for the exposed "truename" + (DosTrueName, int21/ah=60), FindFirst and FCB functions. ++ Changes Bart + * add top level makefile with list of files to zip for releases + * remove obsolete documentation and intr.h + * eliminated the "f_highwater" fnode field. + * reintroduced HMA_TEXT segment and adjust segments in libm.lib + to solve problems with Borland compilers. 2002 Dec 9 - Build 2028 -------- Bart Oldeman (bart@dosemu.org) + Changes Tom diff --git a/docs/readme.txt b/docs/readme.txt index e7d331af..215b3441 100644 --- a/docs/readme.txt +++ b/docs/readme.txt @@ -14,7 +14,7 @@ the FreeDOS Kernel. Contents of zip files: ke20xx_16.zip : binaries for 8086, FAT16 -ke20xx_32.zip : binaries for 80386, FAT16,FAT32 +ke20xx_32.zip : binaries for 8086, FAT16, FAT32 ke20xxsrc.zip : sources for the kernel BUG REPORTS diff --git a/hdr/algnbyte.h b/hdr/algnbyte.h index 4040b415..721339b3 100644 --- a/hdr/algnbyte.h +++ b/hdr/algnbyte.h @@ -5,7 +5,7 @@ #pragma warning(disable:4103) #endif #pragma pack(1) -#elif defined(_QC) || defined(__WATCOM__) +#elif defined(_QC) || defined(__WATCOM__) || defined(__GNUC__) #pragma pack(1) #elif defined(__ZTC__) #pragma ZTC align 1 diff --git a/hdr/algndflt.h b/hdr/algndflt.h index 58c07cd8..5c36f11e 100644 --- a/hdr/algndflt.h +++ b/hdr/algndflt.h @@ -1,4 +1,4 @@ -#if defined (_MSC_VER) || defined(_QC) || defined(__WATCOMC__) +#if defined (_MSC_VER) || defined(_QC) || defined(__WATCOMC__) || defined(__GNUC__) #pragma pack() #elif defined (__ZTC__) #pragma ZTC align diff --git a/kernel/prf.c b/kernel/prf.c index 48944c24..c9d1491b 100644 --- a/kernel/prf.c +++ b/kernel/prf.c @@ -28,25 +28,9 @@ #include "portab.h" -#if defined(DEBUG) || defined(FORSYS) || defined(_INIT) - #ifdef FORSYS #include #include -#else -/* copied from bcc (Bruce's C compiler) stdarg.h */ -typedef char *va_list; -#define va_start(arg, last) ((arg) = (char *) (&(last)+1)) -#define va_arg(arg, type) (((type *)(arg+=sizeof(type)))[-1]) -#define va_end(arg) -#endif - -/*#define DOSEMU */ - -#ifdef DOSEMU -#define MAX_BUFSIZE 80 /* adjust if necessary */ -static int buff_offset = 0; -static char buff[MAX_BUFSIZE]; #endif #ifdef _INIT @@ -65,33 +49,14 @@ static BYTE *prfRcsId = "$Id$"; #endif -static BYTE *charp = 0; - -STATIC VOID handle_char(COUNT); -STATIC VOID put_console(COUNT); -STATIC BYTE * ltob(LONG, BYTE *, COUNT); -STATIC COUNT do_printf(CONST BYTE *, REG va_list); -int CDECL printf(CONST BYTE * fmt, ...); - -/* The following is user supplied and must match the following prototype */ -VOID cso(COUNT); - -#if defined(FORSYS) || defined(_INIT) -COUNT fstrlen(BYTE FAR * s) /* don't want globals.h, sorry */ -{ - int i = 0; - - while (*s++) - i++; - - return i; -} -#else -COUNT /*ASMCFUNC*/ pascal fstrlen(BYTE FAR * s); /* don't want globals.h, sorry */ -#endif - /* special console output routine */ +/*#define DOSEMU */ #ifdef DOSEMU + +#define MAX_BUFSIZE 80 /* adjust if necessary */ +static int buff_offset = 0; +static char buff[MAX_BUFSIZE]; + VOID put_console(COUNT c) { if (buff_offset >= MAX_BUFSIZE) @@ -151,6 +116,41 @@ VOID put_console(COUNT c) } #endif /* DOSEMU */ +#if defined(DEBUG) || defined(FORSYS) || defined(_INIT) + +#ifndef FORSYS +/* copied from bcc (Bruce's C compiler) stdarg.h */ +typedef char *va_list; +#define va_start(arg, last) ((arg) = (char *) (&(last)+1)) +#define va_arg(arg, type) (((type *)(arg+=sizeof(type)))[-1]) +#define va_end(arg) +#endif + +static BYTE *charp = 0; + +STATIC VOID handle_char(COUNT); +STATIC VOID put_console(COUNT); +STATIC BYTE * ltob(LONG, BYTE *, COUNT); +STATIC COUNT do_printf(CONST BYTE *, REG va_list); +int CDECL printf(CONST BYTE * fmt, ...); + +/* The following is user supplied and must match the following prototype */ +VOID cso(COUNT); + +#if defined(FORSYS) || defined(_INIT) +COUNT fstrlen(BYTE FAR * s) /* don't want globals.h, sorry */ +{ + int i = 0; + + while (*s++) + i++; + + return i; +} +#else +COUNT /*ASMCFUNC*/ pascal fstrlen(BYTE FAR * s); /* don't want globals.h, sorry */ +#endif + /* special handler to switch between sprintf and printf */ STATIC VOID handle_char(COUNT c) { @@ -371,26 +371,8 @@ COUNT do_printf(CONST BYTE * fmt, va_list arg) return 0; } -#else -void put_console(int c) -{ - if (c == '\n') - put_console('\r'); - -#if defined(__TURBOC__) - _AX = 0x0e00 | c; - _BX = 0x0070; - __int__(0x10); -#elif defined(I86) - __asm - { - mov al, byte ptr c; - mov ah, 0x0e; - mov bx, 0x0070; - int 0x10; - } -#endif /* __TURBO__ */ -} +#endif +#if !defined(FORSYS) && !defined(_INIT) extern void put_string(const char *); extern void put_unsigned(unsigned, int, int); diff --git a/lib/makefile b/lib/makefile index b4876460..174d6d76 100644 --- a/lib/makefile +++ b/lib/makefile @@ -11,7 +11,7 @@ libm.lib: $(CLIB) -$(RM) libm.lib $(LIBUTIL) $(CLIB) $(MATH_EXTRACT) $(LIBTERM) - for %i in (*.obj) do ..\utils\patchobj CODE=LCODE TEXT=_LOWTEXT %i + for %i in (*.obj) do if exist %i ..\utils\patchobj CODE=LCODE TEXT=_LOWTEXT %i $(LIBUTIL) libm $(MATH_INSERT) $(LIBTERM) -$(RM) *.OBJ diff --git a/mkfiles/watcom.mak b/mkfiles/watcom.mak index 10f1884c..d96fec4c 100644 --- a/mkfiles/watcom.mak +++ b/mkfiles/watcom.mak @@ -17,7 +17,7 @@ TARGETOPT=-0 !endif LIBPATH=$(COMPILERPATH)\lib286 -LIBUTIL=wlib /q +LIBUTIL=wlib -q -n LIBPLUS= LIBTERM= @@ -34,8 +34,8 @@ CLIB=$(COMPILERPATH)\lib286\dos\clibm.lib # we use our own ones, which override these ones when linking. # -MATH_EXTRACT=*i4d *i4m -MATH_INSERT= +i4d +i4m +MATH_EXTRACT= +MATH_INSERT= # diff --git a/utils/patchobj.c b/utils/patchobj.c index 30a9c3b9..5cd65b83 100644 --- a/utils/patchobj.c +++ b/utils/patchobj.c @@ -13,7 +13,11 @@ *****************************************************************************/ #include +#ifdef __GNUC__ +#include +#else #include +#endif #include #include #include @@ -115,11 +119,13 @@ int main(int argc, char *argv[]) } +#include "algnbyte.h" struct record { unsigned char rectyp; - unsigned datalen; + unsigned short datalen; unsigned char buffer[0x2000]; } Record, Outrecord; +#include "algndflt.h" struct verify_pack1 { char x[ sizeof(struct record) == 0x2003 ? 1 : -1];}; From bb533c614c14ec831abaf285e25a0ed09951a0bd Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sat, 15 Mar 2003 04:32:37 +0000 Subject: [PATCH 191/671] Cannot use if exist and for together... git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@544 6ac86273-5f31-0410-b378-82cca8765d1b --- lib/makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/makefile b/lib/makefile index 174d6d76..b4876460 100644 --- a/lib/makefile +++ b/lib/makefile @@ -11,7 +11,7 @@ libm.lib: $(CLIB) -$(RM) libm.lib $(LIBUTIL) $(CLIB) $(MATH_EXTRACT) $(LIBTERM) - for %i in (*.obj) do if exist %i ..\utils\patchobj CODE=LCODE TEXT=_LOWTEXT %i + for %i in (*.obj) do ..\utils\patchobj CODE=LCODE TEXT=_LOWTEXT %i $(LIBUTIL) libm $(MATH_INSERT) $(LIBTERM) -$(RM) *.OBJ From 683ed6c729e392299135ef0f3cd0f9869f18f5bf Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sat, 15 Mar 2003 04:36:42 +0000 Subject: [PATCH 192/671] "Use" at least one (unnecessary) math obj to not disturb the build process. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@545 6ac86273-5f31-0410-b378-82cca8765d1b --- mkfiles/watcom.mak | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mkfiles/watcom.mak b/mkfiles/watcom.mak index d96fec4c..273845dc 100644 --- a/mkfiles/watcom.mak +++ b/mkfiles/watcom.mak @@ -17,7 +17,7 @@ TARGETOPT=-0 !endif LIBPATH=$(COMPILERPATH)\lib286 -LIBUTIL=wlib -q -n +LIBUTIL=wlib -q LIBPLUS= LIBTERM= @@ -34,8 +34,8 @@ CLIB=$(COMPILERPATH)\lib286\dos\clibm.lib # we use our own ones, which override these ones when linking. # -MATH_EXTRACT= -MATH_INSERT= +MATH_EXTRACT=*i4m +MATH_INSERT=+i4m # From 3ab767c4a81524663918be0fabbd9afe6fa1a327 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sat, 15 Mar 2003 04:48:25 +0000 Subject: [PATCH 193/671] Add file list and top level makefile to the CVS for kernel 2029 git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@546 6ac86273-5f31-0410-b378-82cca8765d1b --- filelist | 156 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ makefile | 48 +++++++++++++++++ 2 files changed, 204 insertions(+) create mode 100644 filelist create mode 100644 makefile diff --git a/filelist b/filelist new file mode 100644 index 00000000..8cb8fe6b --- /dev/null +++ b/filelist @@ -0,0 +1,156 @@ +*/*/build.bat +*/*/buildall.bat +*/*/clean.bat +*/*/clobber.bat +*/*/config.b +*/*/filelist +*/*/getmake.bat +*/*/makefile +*/*/bin/autoexec.bat +*/*/bin/config.sys +*/*/bin/install.bat +*/*/boot/boot.asm +*/*/boot/boot32.asm +*/*/boot/makefile +*/*/docs/bugs.txt +*/*/docs/build.txt +*/*/docs/config.txt +*/*/docs/contrib.txt +*/*/docs/copying +*/*/docs/fdkernel.lsm +*/*/docs/history.txt +*/*/docs/intfns.txt +*/*/docs/lfnapi.txt +*/*/docs/mkboot.txt +*/*/docs/nls.txt +*/*/docs/readme.cvs +*/*/docs/readme.txt +*/*/docs/sys.txt +*/*/drivers/floppy.asm +*/*/drivers/getvec.asm +*/*/drivers/makefile +*/*/drivers/rdatclk.asm +*/*/drivers/rdpcclk.asm +*/*/drivers/wratclk.asm +*/*/drivers/wrpcclk.asm +*/*/hdr/algnbyte.h +*/*/hdr/algndflt.h +*/*/hdr/buffer.h +*/*/hdr/cds.h +*/*/hdr/clock.h +*/*/hdr/date.h +*/*/hdr/dcb.h +*/*/hdr/device.h +*/*/hdr/dirmatch.h +*/*/hdr/dosnames.h +*/*/hdr/error.h +*/*/hdr/exe.h +*/*/hdr/fat.h +*/*/hdr/fcb.h +*/*/hdr/file.h +*/*/hdr/fnode.h +*/*/hdr/kbd.h +*/*/hdr/kconfig.h +*/*/hdr/mcb.h +*/*/hdr/network.h +*/*/hdr/nls.h +*/*/hdr/pcb.h +*/*/hdr/portab.h +*/*/hdr/process.h +*/*/hdr/sft.h +*/*/hdr/stacks.inc +*/*/hdr/tail.h +*/*/hdr/time.h +*/*/hdr/version.h +*/*/hdr/xstructs.h +*/*/kernel/nls/001-437.hc +*/*/kernel/nls/001-437.unf +*/*/kernel/nls/001-437.up +*/*/kernel/nls/049-850.hc +*/*/kernel/nls/049-850.unf +*/*/kernel/nls/049-850.up +*/*/kernel/nls/files +*/*/kernel/apisupt.asm +*/*/kernel/asmsupt.asm +*/*/kernel/blockio.c +*/*/kernel/break.c +*/*/kernel/chario.c +*/*/kernel/config.c +*/*/kernel/config.h +*/*/kernel/console.asm +*/*/kernel/dosfns.c +*/*/kernel/dosidle.asm +*/*/kernel/dosnames.c +*/*/kernel/dsk.c +*/*/kernel/dyndata.h +*/*/kernel/dyninit.c +*/*/kernel/entry.asm +*/*/kernel/error.c +*/*/kernel/execrh.asm +*/*/kernel/fatdir.c +*/*/kernel/fatfs.c +*/*/kernel/fattab.c +*/*/kernel/fcbfns.c +*/*/kernel/globals.h +*/*/kernel/init-dat.h +*/*/kernel/init-mod.h +*/*/kernel/initclk.c +*/*/kernel/initdisk.c +*/*/kernel/inithma.c +*/*/kernel/initoem.c +*/*/kernel/int2f.asm +*/*/kernel/inthndlr.c +*/*/kernel/intr.asm +*/*/kernel/makefile +*/*/kernel/io.asm +*/*/kernel/io.inc +*/*/kernel/ioctl.c +*/*/kernel/iprf.c +*/*/kernel/irqstack.asm +*/*/kernel/kernel.asm +*/*/kernel/kernel.cfg +*/*/kernel/lfnapi.c +*/*/kernel/ludivmul.inc +*/*/kernel/main.c +*/*/kernel/memmgr.c +*/*/kernel/misc.c +*/*/kernel/network.c +*/*/kernel/newstuff.c +*/*/kernel/nls.c +*/*/kernel/nls_hc.asm +*/*/kernel/nls_load.c +*/*/kernel/nlssupt.asm +*/*/kernel/prf.c +*/*/kernel/printer.asm +*/*/kernel/procsupt.asm +*/*/kernel/proto.h +*/*/kernel/segs.inc +*/*/kernel/serial.asm +*/*/kernel/strings.c +*/*/kernel/sysclk.c +*/*/kernel/syspack.c +*/*/kernel/systime.c +*/*/kernel/task.c +*/*/kernel/turboc.cfg +*/*/lib/makefile +*/*/mkfiles/generic.mak +*/*/mkfiles/bc5.mak +*/*/mkfiles/mscl8.mak +*/*/mkfiles/tc2.mak +*/*/mkfiles/tc3.mak +*/*/mkfiles/turbocpp.mak +*/*/mkfiles/watcom.mak +*/*/sys/fdkrncfg.c +*/*/sys/bin2c.c +*/*/sys/makefile +*/*/sys/sys.c +*/*/utils/echoto.bat +*/*/utils/exeflat.c +*/*/utils/indent.ini +*/*/utils/makefile +*/*/utils/patchobj.c +*/*/utils/proto.bat +*/*/utils/relocinf.c +*/*/utils/rmfiles.bat +*/*/utils/wlinker.bat +*/*/utils/patchobj diff --git a/makefile b/makefile new file mode 100644 index 00000000..c87a2856 --- /dev/null +++ b/makefile @@ -0,0 +1,48 @@ +#just in case somebody likes make better than build... +all: + build + +bin\kwc8616.zip: + build -r wc 86 fat16 + +bin\kwc8632.zip: + build -r wc 86 fat32 + +#use as follows: wmake -ms zip VERSION=2029 +zip_src: + cd ..\.. + zip -9 -r -k source/ke$(VERSION)src.zip source/ke$(VERSION) -i@source/ke$(VERSION)/filelist + cd source\ke$(VERSION) + +BINLIST1 = doc bin/kernel.sys bin/sys.com bin/command.com bin/config.sys +BINLIST2 = bin/autoexec.bat bin/command.com bin/install.bat + +zipfat16: bin\kwc8616.zip + mkdir doc + copy docs\*.txt doc + copy docs\*.cvs doc + copy docs\copying doc + copy docs\*.lsm doc + del doc\build.txt + del doc\lfnapi.txt + copy bin\kwc8616.zip bin\kernel.sys + zip -9 -r -k ../ke$(VERSION)_16.zip $(BINLIST1) + zip -9 -r -k ../ke$(VERSION)_16.zip $(BINLIST2) + utils\rmfiles doc\*.txt doc\*.cvs doc\*.lsm doc\copying + rmdir doc + +zipfat32: bin\kwc8632.zip + mkdir doc + copy docs\*.txt doc + copy docs\*.cvs doc + copy docs\copying doc + copy docs\*.lsm doc + del doc\build.txt + del doc\lfnapi.txt + copy bin\kwc8632.zip bin\kernel.sys + zip -9 -r -k ../ke$(VERSION)_32.zip $(BINLIST1) + zip -9 -r -k ../ke$(VERSION)_32.zip $(BINLIST2) + utils\rmfiles doc\*.txt doc\*.cvs doc\*.lsm doc\copying + rmdir doc + +zip: zip_src zipfat16 zipfat32 \ No newline at end of file From 16b16b185bc255bcf6440fe679eee2fd49b0aec4 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sun, 16 Mar 2003 06:14:40 +0000 Subject: [PATCH 194/671] Remove patchobj binary. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@548 6ac86273-5f31-0410-b378-82cca8765d1b --- filelist | 1 - 1 file changed, 1 deletion(-) diff --git a/filelist b/filelist index 8cb8fe6b..90872796 100644 --- a/filelist +++ b/filelist @@ -153,4 +153,3 @@ */*/utils/relocinf.c */*/utils/rmfiles.bat */*/utils/wlinker.bat -*/*/utils/patchobj From 484f700bbae2e993574290bf6a5ffb8eea50733f Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sun, 23 Mar 2003 18:41:36 +0000 Subject: [PATCH 195/671] DE_INVLDDRV should be DE_DEVICE for rename and DE_PATHNOTFND for truename git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@563 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/dosfns.c | 2 +- kernel/newstuff.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/dosfns.c b/kernel/dosfns.c index 53a0d7d4..1a077436 100644 --- a/kernel/dosfns.c +++ b/kernel/dosfns.c @@ -1271,7 +1271,7 @@ COUNT DosRenameTrue(BYTE * path1, BYTE * path2, int attrib) { if (path1[0] != path2[0]) { - return DE_INVLDDRV; + return DE_DEVICE; /* not same device */ } if (current_ldt->cdsFlags & CDSNETWDRV) return remote_rename(); diff --git a/kernel/newstuff.c b/kernel/newstuff.c index e69136fb..505642c8 100644 --- a/kernel/newstuff.c +++ b/kernel/newstuff.c @@ -128,7 +128,7 @@ COUNT get_verify_drive(const char FAR * src) drive = default_drive; if (get_cds(drive) == NULL) - return DE_INVLDDRV; + return DE_PATHNOTFND; return drive; } From 80a6dd82af16f69d4948a0bb2a1a31a71cafc1ca Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Wed, 30 Apr 2003 15:42:06 +0000 Subject: [PATCH 196/671] Fix problem with "truename wildcard." git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@576 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/newstuff.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/kernel/newstuff.c b/kernel/newstuff.c index 505642c8..789bfd15 100644 --- a/kernel/newstuff.c +++ b/kernel/newstuff.c @@ -527,8 +527,9 @@ COUNT truename(const char FAR * src, char * dest, COUNT mode) PATH_ERROR; if (i & PNE_WILDCARD) gotAnyWildcards = TRUE; - } - --src; /* terminator or separator was skipped */ + } + if (*src != '\0') + --src; /* terminator or separator was skipped */ break; } } From 5626d2891902356b0bc5784d57f198f08773426d Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sun, 15 Jun 2003 11:46:51 +0000 Subject: [PATCH 197/671] Flip slashes to enable cross assembly from Linux git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@585 6ac86273-5f31-0410-b378-82cca8765d1b --- drivers/floppy.asm | 2 +- drivers/getvec.asm | 2 +- drivers/rdatclk.asm | 2 +- drivers/rdpcclk.asm | 2 +- drivers/wratclk.asm | 2 +- drivers/wrpcclk.asm | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/floppy.asm b/drivers/floppy.asm index 9929c5e3..9c5fa9fa 100644 --- a/drivers/floppy.asm +++ b/drivers/floppy.asm @@ -29,7 +29,7 @@ ; %ifndef SYS - %include "..\kernel\segs.inc" + %include "../kernel/segs.inc" segment HMA_TEXT %else segment _TEXT class=CODE diff --git a/drivers/getvec.asm b/drivers/getvec.asm index 153b20ac..d53efc19 100644 --- a/drivers/getvec.asm +++ b/drivers/getvec.asm @@ -28,7 +28,7 @@ ; $Header$ ; - %include "..\kernel\segs.inc" + %include "../kernel/segs.inc" segment HMA_TEXT diff --git a/drivers/rdatclk.asm b/drivers/rdatclk.asm index 8abd5b77..b5ca6a87 100644 --- a/drivers/rdatclk.asm +++ b/drivers/rdatclk.asm @@ -30,7 +30,7 @@ ; $Header$ ; - %include "..\kernel\segs.inc" + %include "../kernel/segs.inc" segment HMA_TEXT diff --git a/drivers/rdpcclk.asm b/drivers/rdpcclk.asm index 81ed79e0..11e01b91 100644 --- a/drivers/rdpcclk.asm +++ b/drivers/rdpcclk.asm @@ -28,7 +28,7 @@ ; $Header$ ; - %include "..\kernel\segs.inc" + %include "../kernel/segs.inc" segment HMA_TEXT diff --git a/drivers/wratclk.asm b/drivers/wratclk.asm index ab9071b2..64897844 100644 --- a/drivers/wratclk.asm +++ b/drivers/wratclk.asm @@ -28,7 +28,7 @@ ; $Header$ ; - %include "..\kernel\segs.inc" + %include "../kernel/segs.inc" segment HMA_TEXT diff --git a/drivers/wrpcclk.asm b/drivers/wrpcclk.asm index 7e6f7354..135be0ce 100644 --- a/drivers/wrpcclk.asm +++ b/drivers/wrpcclk.asm @@ -27,7 +27,7 @@ ; ; $Header$ ; - %include "..\kernel\segs.inc" + %include "../kernel/segs.inc" segment HMA_TEXT From a1209a55429a4d19791ba2def5a25000cfef1e26 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sun, 15 Jun 2003 11:51:38 +0000 Subject: [PATCH 198/671] Remove superfluous printf("\n"); git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@586 6ac86273-5f31-0410-b378-82cca8765d1b --- utils/patchobj.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/utils/patchobj.c b/utils/patchobj.c index 5cd65b83..9d0eb6c9 100644 --- a/utils/patchobj.c +++ b/utils/patchobj.c @@ -201,6 +201,4 @@ void go_records(FILE * fdin, FILE * fdo) } while (Record.rectyp != 0x00 /*ENDFIL*/); - - printf("\n"); } From 03e234af3c4f3e3ad1002a08a1378ed385f8ed5d Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sun, 15 Jun 2003 11:53:00 +0000 Subject: [PATCH 199/671] WATCOM needs to be WATCOMC git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@587 6ac86273-5f31-0410-b378-82cca8765d1b --- hdr/algnbyte.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hdr/algnbyte.h b/hdr/algnbyte.h index 721339b3..adb0e5d4 100644 --- a/hdr/algnbyte.h +++ b/hdr/algnbyte.h @@ -5,7 +5,7 @@ #pragma warning(disable:4103) #endif #pragma pack(1) -#elif defined(_QC) || defined(__WATCOM__) || defined(__GNUC__) +#elif defined(_QC) || defined(__WATCOMC__) || defined(__GNUC__) #pragma pack(1) #elif defined(__ZTC__) #pragma ZTC align 1 From aa352cc5485ca0fe8b11a8e91c71e7ead83039de Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sun, 15 Jun 2003 12:56:57 +0000 Subject: [PATCH 200/671] * combine the INIT class with the CODE class (classes can span multiple physical segments) * re-add _TEXT to LGROUP to be able to simplify the patchobj magic * don't specify -zPI_GROUP for the init code in Borland compilers (unnecessary, it will be put there because of segs.inc) * remove STDPATCH; it is no longer necessary git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@588 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/irqstack.asm | 6 +++--- kernel/makefile | 1 - kernel/segs.inc | 11 ++++++----- mkfiles/bc5.mak | 2 +- mkfiles/generic.mak | 1 - mkfiles/mscl8.mak | 3 +-- mkfiles/tc2.mak | 2 +- mkfiles/tc3.mak | 2 +- mkfiles/turbocpp.mak | 2 +- mkfiles/watcom.mak | 2 +- 10 files changed, 15 insertions(+), 17 deletions(-) diff --git a/kernel/irqstack.asm b/kernel/irqstack.asm index 077f5738..63dc3c7e 100644 --- a/kernel/irqstack.asm +++ b/kernel/irqstack.asm @@ -30,9 +30,9 @@ ; Code for stack switching during hardware interrupts. -group LGROUP _LOWTEXT +%include "segs.inc" -segment _LOWTEXT class=LCODE +segment _LOWTEXT old_vectors times 16 dd 0 stack_size dw 0 @@ -155,7 +155,7 @@ dont_switch: pushf iret -segment INIT_TEXT class=INIT +segment INIT_TEXT global _init_stacks ; VOID init_stacks(VOID FAR *stack_base, COUNT nStacks, WORD stackSize); diff --git a/kernel/makefile b/kernel/makefile index ead55cd2..42410db5 100644 --- a/kernel/makefile +++ b/kernel/makefile @@ -27,7 +27,6 @@ HDR=../hdr/ .c.obj : $(CC) $(CFLAGS) $< - $(STDPATCH) $*.obj # *List Macros* diff --git a/kernel/segs.inc b/kernel/segs.inc index 1ec3eb3a..5f3624b7 100644 --- a/kernel/segs.inc +++ b/kernel/segs.inc @@ -28,15 +28,16 @@ ; group PGROUP PSP -group LGROUP _LOWTEXT _IO_TEXT _IO_FIXED_DATA +group LGROUP _LOWTEXT _IO_TEXT _IO_FIXED_DATA _TEXT group DGROUP _FIXED_DATA _BSS _DATA _DATAEND CONST CONST2 DCONST DYN_DATA -group I_GROUP INIT_TEXT_START INIT_TEXT INIT_TEXT_END ID_B ID ID_E IC IDATA ICONST ICONST2 I_DATA IB_B I_BSS IB IB_E group TGROUP HMA_TEXT_START HMA_TEXT HMA_TEXT_END +group I_GROUP INIT_TEXT_START INIT_TEXT INIT_TEXT_END ID_B ID ID_E IC IDATA ICONST ICONST2 I_DATA IB_B I_BSS IB IB_E segment PSP class=PSP segment _LOWTEXT class=LCODE segment _IO_TEXT class=LCODE segment _IO_FIXED_DATA class=LCODE align=2 +segment _TEXT class=LCODE segment _FIXED_DATA class=FDATA align=16 segment _BSS class=BSS align=2 segment _DATA class=DATA align=2 @@ -50,9 +51,9 @@ segment DYN_DATA class=DYN_DATA segment HMA_TEXT_START class=CODE align=16 segment HMA_TEXT class=CODE segment HMA_TEXT_END class=CODE -segment INIT_TEXT_START class=INIT align=16 -segment INIT_TEXT class=INIT -segment INIT_TEXT_END class=INIT +segment INIT_TEXT_START class=CODE align=16 +segment INIT_TEXT class=CODE +segment INIT_TEXT_END class=CODE segment ID_B class=ID align=2 segment ID class=ID align=2 segment ID_E class=ID align=2 diff --git a/mkfiles/bc5.mak b/mkfiles/bc5.mak index 60831f8a..64408fd6 100644 --- a/mkfiles/bc5.mak +++ b/mkfiles/bc5.mak @@ -49,5 +49,5 @@ MATH_INSERT=+H_LDIV +H_LLSH +H_LURSH +F_LXMUL # ALLCFLAGS specified by turbo.cfg and config.mak # ALLCFLAGS=$(TARGETOPT) -zCHMA_TEXT $(ALLCFLAGS) -INITCFLAGS=$(ALLCFLAGS) -zAINIT -zCINIT_TEXT -zDIB -zRID -zTID -zPI_GROUP -zBIB -zGI_GROUP -zSI_GROUP +INITCFLAGS=$(ALLCFLAGS) -zCINIT_TEXT -zDIB -zRID -zTID -zBIB -zGI_GROUP -zSI_GROUP CFLAGS=$(ALLCFLAGS) diff --git a/mkfiles/generic.mak b/mkfiles/generic.mak index 71e0db8e..34a3ea0c 100644 --- a/mkfiles/generic.mak +++ b/mkfiles/generic.mak @@ -27,7 +27,6 @@ NASMFLAGS = $(NASMFLAGS) -i../hdr/ LINK=$(XLINK) -STDPATCH=@rem INITPATCH=@rem !include "..\mkfiles\$(COMPILER).mak" diff --git a/mkfiles/mscl8.mak b/mkfiles/mscl8.mak index 9c195e53..c6d392b2 100644 --- a/mkfiles/mscl8.mak +++ b/mkfiles/mscl8.mak @@ -44,5 +44,4 @@ ALLCFLAGS=-I..\hdr $(TARGETOPT) $(ALLCFLAGS) -nologo -Zl -Fc -WX -Gr -f- -Os -Gs INITCFLAGS=$(ALLCFLAGS) -NTINIT_TEXT -AT CFLAGS=$(ALLCFLAGS) -INITPATCH = ..\utils\patchobj CODE=INIT _DATA=IDATA DATA=ID BSS=ID DGROUP=I_GROUP CONST=IC -STDPATCH = ..\utils\patchobj CONST=DCONST +INITPATCH = ..\utils\patchobj _DATA=IDATA DATA=ID BSS=ID DGROUP=I_GROUP CONST=IC diff --git a/mkfiles/tc2.mak b/mkfiles/tc2.mak index d9fd5576..373b3575 100644 --- a/mkfiles/tc2.mak +++ b/mkfiles/tc2.mak @@ -49,5 +49,5 @@ MATH_INSERT=+LDIV +LXMUL +LURSH +LLSH +LRSH # ALLCFLAGS specified by turbo.cfg and config.mak # ALLCFLAGS=$(TARGETOPT) -zCHMA_TEXT $(ALLCFLAGS) -INITCFLAGS=$(ALLCFLAGS) -zAINIT -zCINIT_TEXT -zDIB -zRID -zTID -zPI_GROUP -zBIB -zGI_GROUP -zSI_GROUP +INITCFLAGS=$(ALLCFLAGS) -zCINIT_TEXT -zDIB -zRID -zTID -zBIB -zGI_GROUP -zSI_GROUP CFLAGS=$(ALLCFLAGS) diff --git a/mkfiles/tc3.mak b/mkfiles/tc3.mak index 57b3cc85..1ac6986e 100644 --- a/mkfiles/tc3.mak +++ b/mkfiles/tc3.mak @@ -49,5 +49,5 @@ MATH_INSERT=+H_LDIV +H_LLSH +H_LURSH +F_LXMUL # ALLCFLAGS specified by turbo.cfg and config.mak # ALLCFLAGS=$(TARGETOPT) -zCHMA_TEXT $(ALLCFLAGS) -INITCFLAGS=$(ALLCFLAGS) -zAINIT -zCINIT_TEXT -zDIB -zRID -zTID -zPI_GROUP -zBIB -zGI_GROUP -zSI_GROUP +INITCFLAGS=$(ALLCFLAGS) -zCINIT_TEXT -zDIB -zRID -zTID -zBIB -zGI_GROUP -zSI_GROUP CFLAGS=$(ALLCFLAGS) diff --git a/mkfiles/turbocpp.mak b/mkfiles/turbocpp.mak index d1716824..db331184 100644 --- a/mkfiles/turbocpp.mak +++ b/mkfiles/turbocpp.mak @@ -49,5 +49,5 @@ MATH_INSERT=+H_LDIV +H_LLSH +H_LURSH +F_LXMUL # ALLCFLAGS specified by turbo.cfg and config.mak # ALLCFLAGS=$(TARGETOPT) -zCHMA_TEXT $(ALLCFLAGS) -INITCFLAGS=$(ALLCFLAGS) -zAINIT -zCINIT_TEXT -zDIB -zRID -zTID -zPI_GROUP -zBIB -zGI_GROUP -zSI_GROUP +INITCFLAGS=$(ALLCFLAGS) -zCINIT_TEXT -zDIB -zRID -zTID -zBIB -zGI_GROUP -zSI_GROUP CFLAGS=$(ALLCFLAGS) diff --git a/mkfiles/watcom.mak b/mkfiles/watcom.mak index 273845dc..8e111ca8 100644 --- a/mkfiles/watcom.mak +++ b/mkfiles/watcom.mak @@ -62,7 +62,7 @@ MATH_INSERT=+i4m # ALLCFLAGS=-I..\hdr $(TARGETOPT) $(ALLCFLAGS)-zq-os-s-e5-j-zl-zp1-wx-we-zgf-zff -INITCFLAGS=$(ALLCFLAGS)-ntINIT_TEXT-ncINIT-ndI-gI_GROUP +INITCFLAGS=$(ALLCFLAGS)-ntINIT_TEXT-ndI CFLAGS=$(ALLCFLAGS)-ntHMA_TEXT INITPATCH=..\utils\patchobj __U4D=_IU4D __U4M=_IU4M From 439cc495e4b9221140bef5786e1b95285c696a23 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sun, 15 Jun 2003 13:24:53 +0000 Subject: [PATCH 201/671] * add FILESHIGH, LASTDRIVEHIGH, and STACKSHIGH and DOSDATA=UMB to load these structures into UMBs * make DOS sub-MCBs visible (seen by MEM) * preliminary allocation of FILES etc. now takes place at the top of conventional memory, and device drivers are loaded before the final allocation takes place. * handle multiple UMBs more correctly (but config.sys can use only one UMB for devicehigh -- /Ln,xxxx is not yet implemented) git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@589 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/config.c | 543 +++++++++++++++++++++++++++------------------- kernel/init-mod.h | 12 +- kernel/inithma.c | 2 +- kernel/main.c | 61 +++--- 4 files changed, 358 insertions(+), 260 deletions(-) diff --git a/kernel/config.c b/kernel/config.c index 2932527c..63241aa8 100644 --- a/kernel/config.c +++ b/kernel/config.c @@ -42,12 +42,7 @@ static BYTE *RcsId = #else #define DebugPrintf(x) #endif - -#ifdef KDB -#include - -#define KernelAlloc(x) adjust_far((void far *)malloc((unsigned long)(x))) -#endif +#define para2far(seg) ((mcb FAR *)MK_FP((seg), 0)) /* These are the far variables from the DOS data segment that we need here. The @@ -61,8 +56,7 @@ extern f_node_ptr DOSFAR f_nodes; /* pointer to the array extern UWORD DOSFAR f_nodes_cnt, /* number of allocated f_nodes */ DOSFAR ASM first_mcb; /* Start of user memory */ -extern UBYTE DOSFAR ASM lastdrive, DOSFAR ASM nblkdev, DOSFAR ASM mem_access_mode, - DOSFAR ASM uppermem_link; +extern UBYTE DOSFAR ASM lastdrive, DOSFAR ASM nblkdev, DOSFAR ASM uppermem_link; extern struct dhdr DOSTEXTFAR ASM blk_dev, /* Block device (Disk) driver */ DOSFAR ASM nul_dev; @@ -76,7 +70,7 @@ extern sfttbl FAR *DOSFAR ASM sfthead; /* System File Table head */ extern sfttbl FAR *DOSFAR ASM FCBp; -extern BYTE DOSFAR ASM VgaSet, DOSFAR _HMATextAvailable, /* first byte of available CODE area */ +extern BYTE DOSFAR _HMATextAvailable, /* first byte of available CODE area */ FAR _HMATextStart[], /* first byte of HMAable CODE area */ FAR _HMATextEnd[], DOSFAR ASM break_ena, /* break enabled flag */ DOSFAR os_major, /* major version number */ @@ -93,14 +87,18 @@ static UBYTE ErrorAlreadyPrinted[128]; struct config Config = { + 0, NUMBUFF, NFILES, + 0, NFCBS, 0, "command.com", " /P /E:256\r\n", NLAST, + 0, NSTACKS, + 0, 128 /* COUNTRY= is initialized within DoConfig() */ , 0 /* country ID */ @@ -115,8 +113,8 @@ struct config Config = { in INIT code. please make sure, that ALL data in INIT is initialized !! */ -BYTE FAR *lpBase = 0; -BYTE FAR *upBase = 0; +STATIC seg base_seg = 0; +STATIC seg umb_base_seg = 0; BYTE FAR *lpTop = 0; BYTE FAR *lpOldTop = 0; STATIC unsigned nCfgLine = 0; @@ -135,9 +133,6 @@ BYTE MenuSelected = 0; UCOUNT MenuLine = 0; UCOUNT Menus = 0; -STATIC VOID zumcb_init(UCOUNT seg, UWORD size); -STATIC VOID mumcb_init(UCOUNT seg, UWORD size); - STATIC VOID Config_Buffers(BYTE * pLine); STATIC VOID sysScreenMode(BYTE * pLine); STATIC VOID sysVersion(BYTE * pLine); @@ -145,10 +140,13 @@ STATIC VOID CfgBreak(BYTE * pLine); STATIC VOID Device(BYTE * pLine); STATIC VOID DeviceHigh(BYTE * pLine); STATIC VOID Files(BYTE * pLine); +STATIC VOID FilesHigh(BYTE * pLine); STATIC VOID Fcbs(BYTE * pLine); STATIC VOID CfgLastdrive(BYTE * pLine); +STATIC VOID CfgLastdriveHigh(BYTE * pLine); STATIC BOOL LoadDevice(BYTE * pLine, char FAR *top, COUNT mode); STATIC VOID Dosmem(BYTE * pLine); +STATIC VOID DosData(BYTE * pLine); STATIC VOID Country(BYTE * pLine); STATIC VOID InitPgm(BYTE * pLine); STATIC VOID InitPgmHigh(BYTE * pLine); @@ -171,8 +169,10 @@ STATIC COUNT tolower(COUNT c); #endif STATIC COUNT toupper(COUNT c); STATIC VOID mcb_init(UCOUNT seg, UWORD size); +STATIC VOID mumcb_init(UCOUNT seg, UWORD size); STATIC VOID Stacks(BYTE * pLine); +STATIC VOID StacksHigh(BYTE * pLine); STATIC VOID SetAnyDos(BYTE * pLine); STATIC VOID Numlock(BYTE * pLine); STATIC BYTE * GetNumArg(BYTE * pLine, COUNT * pnArg); @@ -183,6 +183,7 @@ STATIC char * stristr(char *s1, char *s2); #endif STATIC COUNT strcasecmp(REG BYTE * d, REG BYTE * s); STATIC int LoadCountryInfoHardCoded(char *filename, COUNT ctryCode, COUNT codePage); +STATIC unsigned alloc(size_t size); void HMAconfig(int finalize); VOID config_init_buffers(COUNT anzBuffers); /* from BLOCKIO.C */ @@ -212,20 +213,24 @@ STATIC struct table commands[] = { {"MENUDEFAULT", 0, CfgMenuDefault}, {"MENU", 0, CfgMenu}, /* lines to print in pass 0 */ - {"ECHO", 2, CfgMenu}, /* lines to print in pass 2 - when devices are loaded */ + {"ECHO", 2, CfgMenu}, /* lines to print in pass 2 - install(high) */ {"BREAK", 1, CfgBreak}, {"BUFFERS", 1, Config_Buffers}, {"COMMAND", 1, InitPgm}, {"COUNTRY", 1, Country}, {"DOS", 1, Dosmem}, + {"DOSDATA", 1, DosData}, {"FCBS", 1, Fcbs}, {"FILES", 1, Files}, + {"FILESHIGH", 1, FilesHigh}, {"LASTDRIVE", 1, CfgLastdrive}, + {"LASTDRIVEHIGH", 1, CfgLastdriveHigh}, {"NUMLOCK", 1, Numlock}, {"SHELL", 1, InitPgm}, {"SHELLHIGH", 1, InitPgmHigh}, {"STACKS", 1, Stacks}, + {"STACKSHIGH", 1, StacksHigh}, {"SWITCHAR", 1, CfgSwitchar}, {"SCREEN", 1, sysScreenMode}, /* JPP */ {"VERSION", 1, sysVersion}, /* JPP */ @@ -248,14 +253,14 @@ BYTE HMAState = 0; #define HMA_DONE 2 /* Moved kernel to HMA */ #define HMA_LOW 3 /* Definitely LOW */ -STATIC void FAR* ConfigAlloc(COUNT bytes) +STATIC void FAR* ConfigAlloc(COUNT bytes, char type) { VOID FAR *p; p = HMAalloc(bytes); if (p == NULL) - p = KernelAlloc(bytes); + p = KernelAlloc(bytes, type, 0); /* printf("ConfigAlloc %d at %p\n", bytes, p); */ @@ -266,12 +271,8 @@ STATIC void FAR* ConfigAlloc(COUNT bytes) /* later. */ void PreConfig(void) { - VgaSet = 0; - UmbState = 0; - memset(ErrorAlreadyPrinted,0,sizeof(ErrorAlreadyPrinted)); - /* Initialize the base memory pointers */ #ifdef DEBUG @@ -306,18 +307,16 @@ void PreConfig(void) KernelAlloc(sizeof(sftheader) + Config.cfgFiles * sizeof(sft)); */ - lpBase = AlignParagraph((BYTE FAR *) DynLast() + 0x0f); - config_init_buffers(Config.cfgBuffers); - sfthead->sftt_next = (sfttbl FAR *) - KernelAlloc(sizeof(sftheader) + (Config.cfgFiles - 5) * sizeof(sft)); + sfthead->sftt_next = + KernelAlloc(sizeof(sftheader) + (Config.cfgFiles - 5) * sizeof(sft), 'F', 0); sfthead->sftt_next->sftt_next = (sfttbl FAR *) - 1; sfthead->sftt_next->sftt_count = Config.cfgFiles - 5; - CDSp = KernelAlloc(sizeof(struct cds) * lastdrive); + CDSp = KernelAlloc(sizeof(struct cds) * lastdrive, 'L', 0); - DPBp = KernelAlloc(blk_dev.dh_name[0] * sizeof(struct dpb)); + DPBp = KernelAlloc(blk_dev.dh_name[0] * sizeof(struct dpb), 'E', 0); #ifdef DEBUG printf("Preliminary:\n f_node 0x%x", f_nodes); @@ -330,31 +329,13 @@ void PreConfig(void) /* Done. Now initialize the MCB structure */ /* This next line is 8086 and 80x86 real mode specific */ #ifdef DEBUG - printf("Preliminary allocation completed: top at 0x%p\n", lpBase); -#endif - -#ifdef KDB - lpBase = malloc(4096); - first_mcb = FP_SEG(lpBase) + ((FP_OFF(lpBase) + 0x0f) >> 4); -#else - first_mcb = FP_SEG(lpBase) + ((FP_OFF(lpBase) + 0x0f) >> 4); + printf("Preliminary allocation completed: top at %p\n", lpTop); #endif - - /* We expect ram_top as Kbytes, so convert to paragraphs */ - mcb_init(first_mcb, ram_top * 64 - first_mcb - 1); } -/* Do second pass initialization. */ -/* Also, run config.sys to load drivers. */ -void PostConfig(void) +/* Do second pass initialization: near allocation and MCBs */ +void PreConfig2(void) { - /* close all (device) files */ - - /* compute lastdrive ... */ - lastdrive = Config.cfgLastdrive; - if (lastdrive < nblkdev) - lastdrive = nblkdev; - /* initialize NEAR allocated things */ /* Initialize the file table */ @@ -372,9 +353,37 @@ void PostConfig(void) and allocation starts after the kernel. */ - lpBase = AlignParagraph((BYTE FAR *) DynLast() + 0x0f); + base_seg = first_mcb = FP_SEG(AlignParagraph((BYTE FAR *) DynLast() + 0x0f)); + + /* We expect ram_top as Kbytes, so convert to paragraphs */ + mcb_init(first_mcb, ram_top * 64 - first_mcb - 1); + if (UmbState == 2) + umb_init(); +} + +/* Do third pass initialization. */ +/* Also, run config.sys to load drivers. */ +void PostConfig(void) +{ + /* We could just have loaded FDXMS or HIMEM */ + if (HMAState == HMA_REQ && MoveKernelToHMA()) + HMAState = HMA_DONE; + + if (Config.cfgDosDataUmb) + { + Config.cfgFilesHigh = TRUE; + Config.cfgLastdriveHigh = TRUE; + Config.cfgStacksHigh = TRUE; + } + + /* close all (device) files */ + + /* compute lastdrive ... */ + lastdrive = Config.cfgLastdrive; + if (lastdrive < nblkdev) + lastdrive = nblkdev; - DebugPrintf(("starting FAR allocations at %p\n", lpBase)); + DebugPrintf(("starting FAR allocations at %x\n", base_seg)); /* Begin by initializing our system buffers */ /* dma_scratch = (BYTE FAR *) KernelAllocDma(BUFFERSIZE); */ @@ -388,14 +397,16 @@ void PostConfig(void) /* FCBp = (sfttbl FAR *)&FcbSft; */ /* FCBp = KernelAlloc(sizeof(sftheader) + Config.cfgFiles * sizeof(sft)); */ - sfthead->sftt_next = - KernelAlloc(sizeof(sftheader) + (Config.cfgFiles - 5) * sizeof(sft)); + sfthead->sftt_next = (sfttbl FAR *) + KernelAlloc(sizeof(sftheader) + (Config.cfgFiles - 5) * sizeof(sft), 'F', + Config.cfgFilesHigh); sfthead->sftt_next->sftt_next = (sfttbl FAR *) - 1; sfthead->sftt_next->sftt_count = Config.cfgFiles - 5; - CDSp = KernelAlloc(sizeof(struct cds) * lastdrive); + CDSp = KernelAlloc(sizeof(struct cds) * lastdrive, 'L', Config.cfgLastdriveHigh); - DPBp = KernelAlloc(blk_dev.dh_name[0] * sizeof(struct dpb)); + DPBp = KernelAlloc(blk_dev.dh_name[0] * sizeof(struct dpb), 'E', + Config.cfgDosDataUmb); #ifdef DEBUG printf("Final: \n f_node 0x%x\n", f_nodes); @@ -407,116 +418,136 @@ void PostConfig(void) if (Config.cfgStacks) { VOID FAR *stackBase = - KernelAlloc(Config.cfgStacks * Config.cfgStackSize); + KernelAlloc(Config.cfgStacks * Config.cfgStackSize, 'S', + Config.cfgStacksHigh); init_stacks(stackBase, Config.cfgStacks, Config.cfgStackSize); DebugPrintf(("Stacks allocated at %p\n", stackBase)); } - DebugPrintf(("Allocation completed: top at 0x%p\n", lpBase)); + DebugPrintf(("Allocation completed: top at 0x%x\n", base_seg)); } /* This code must be executed after device drivers has been loaded */ VOID configDone(VOID) { + if (UmbState == 1) + para2far(base_seg)->m_type = MCB_LAST; + if (HMAState != HMA_DONE) { - lpBase = AlignParagraph(lpBase); - - DebugPrintf(("HMA not available, moving text to %x\n", - FP_SEG(lpBase))); - MoveKernel(FP_SEG(lpBase)); + seg kernel_seg = alloc((HMAFree+0xf)/16); + mcb FAR *p = para2far(kernel_seg - 1); + + p->m_name[0] = 'S'; + p->m_name[1] = 'C'; + p->m_psp = 8; - lpBase = AlignParagraph((BYTE FAR *) lpBase + HMAFree + 0x0f); + DebugPrintf(("HMA not available, moving text to %x\n", kernel_seg)); + MoveKernel(kernel_seg); - DebugPrintf(("kernel is low, start alloc at %p", lpBase)); + kernel_seg += (HMAFree + 0x0f)/16 + 1; - /* final buffer processing, now upwards */ - HMAState = HMA_LOW; - config_init_buffers(Config.cfgBuffers); + DebugPrintf(("kernel is low, start alloc at %x", kernel_seg)); } - if (lastdrive < nblkdev) - { - - DebugPrintf(("lastdrive %c too small upping it to: %c\n", - lastdrive + 'A', nblkdev + 'A' - 1)); + /* The standard handles should be reopened here, because + we may have loaded new console or printer drivers in CONFIG.SYS */ +} - lastdrive = nblkdev; - CDSp = KernelAlloc(sizeof(struct cds) * lastdrive); +STATIC seg prev_mcb(seg cur_mcb, seg start) +{ + /* determine prev mcb */ + seg mcb_prev, mcb_next; + mcb_prev = mcb_next = start; + while (mcb_next < cur_mcb && para2far(mcb_next)->m_type == MCB_NORMAL) + { + mcb_prev = mcb_next; + mcb_next += para2far(mcb_prev)->m_size + 1; } - first_mcb = FP_SEG(lpBase) + ((FP_OFF(lpBase) + 0x0f) >> 4); + return mcb_prev; +} - /* We expect ram_top as Kbytes, so convert to paragraphs */ - mcb_init(first_mcb, ram_top * 64 - first_mcb - 1); +STATIC void umb_init(void) +{ + UCOUNT umb_seg, umb_size; + seg umb_max; - if (UmbState == 1) + if (UMB_get_largest(&umb_seg, &umb_size)) { + mcb FAR *p; - UCOUNT umr_new = FP_SEG(upBase) + ((FP_OFF(upBase) + 0x0f) >> 4); - - mumcb_init(ram_top * 64 - 1, umb_start - 64 * ram_top); -/* Check if any devices were loaded in umb */ - if (umb_start != FP_SEG(upBase)) - { -/* make last block normal with SC for the devices */ - - mumcb_init(umb_start, umr_new - umb_start - 1); - - zumcb_init(umr_new, (umb_start + UMB_top) - umr_new - 1); - upBase += 16; - } - else - umr_new = FP_SEG(upBase); + UmbState = 1; - { - /* are there any more UMB's ?? - this happens, if memory mapped devces are in between - like UMB memory c800..c8ff, d8ff..efff with device at d000..d7ff - */ + /* reset root */ + uppermem_root = ram_top * 64 - 1; - /* TE - this code - a) isn't the best I ever wrote :-( - b) works for 2 memory areas (no while(), use of UMB_top,...) - and the first discovered is the larger one. - no idea what happens, if the larger one is higher in memory. - might work, though - */ + /* create link mcb (below) */ + para2far(base_seg)->m_type = MCB_NORMAL; + para2far(base_seg)->m_size--; + mumcb_init(uppermem_root, umb_seg - uppermem_root - 1); - UCOUNT umb_seg, umb_size, umbz_root; + /* setup the real mcb for the devicehigh block */ + mcb_init(umb_seg, umb_size - 2); + p = para2far(umb_seg); + p->m_type = MCB_NORMAL; + p->m_psp = FREE_PSP; - umbz_root = umr_new; + umb_base_seg = umb_max = umb_start = umb_seg; + UMB_top = umb_size; - if (UMB_get_largest(&umb_seg, &umb_size)) - { + /* there can be more UMB's ! + this happens, if memory mapped devces are in between + like UMB memory c800..c8ff, d8ff..efff with device at d000..d7ff + However some of the xxxHIGH commands still only work with + the first UMB. + */ - mcb_init(umbz_root, (umb_start + UMB_top) - umr_new - 1); + while (UMB_get_largest(&umb_seg, &umb_size)) + { + seg umb_prev, umb_next; - /* change UMB 'Z' to 'M' */ - ((mcb FAR *) MK_FP(umbz_root, 0))->m_type = 'M'; + /* setup the real mcb for the devicehigh block */ + mcb_init(umb_seg, umb_size - 2); - /* move to end */ - umbz_root += ((mcb FAR *) MK_FP(umbz_root, 0))->m_size + 1; + /* determine prev and next umbs */ + umb_prev = prev_mcb(umb_seg, uppermem_root); + umb_next = umb_prev + para2far(umb_prev)->m_size + 1; + para2far(umb_seg)->m_type = MCB_NORMAL; - /* create link mcb */ - mumcb_init(umbz_root, umb_seg - umbz_root - 1); + if (umb_seg < umb_max) + { + if (umb_next - umb_seg - umb_size == 0) + { + /* should the UMB driver return + adjacent memory in several pieces */ + umb_size += para2far(umb_next)->m_size + 1; + para2far(umb_seg)->m_size = umb_size; + } + else + { + /* create link mcb (above) */ + mumcb_init(umb_seg + umb_size - 1, umb_next - umb_seg - umb_size); + } + } + if (umb_seg - umb_prev - 1 == 0) /* should the UMB driver return adjacent memory in several pieces */ - if (umb_seg - umbz_root - 1 == 0) - ((mcb FAR *) MK_FP(umbz_root, 0))->m_psp = FREE_PSP; - - /* create new 'Z' mcb */ - zumcb_init(umb_seg, umb_size - 1); + para2far(umb_prev)->m_size += umb_size; + else + { + /* create link mcb (below) */ + mumcb_init(umb_prev, umb_seg - umb_prev - 1); } + + if (umb_seg > umb_max) + umb_max = umb_seg; } + para2far(umb_max)->m_size++; + para2far(umb_max)->m_type = MCB_LAST; + DebugPrintf(("UMB Allocation completed: start at 0x%x\n", umb_base_seg)); } - - DebugPrintf(("UMB Allocation completed: top at 0x%p\n", upBase)); - - /* The standard handles should be reopened here, because - we may have loaded new console or printer drivers in CONFIG.SYS */ - } VOID DoConfig(int pass) @@ -624,28 +655,6 @@ VOID DoConfig(int pass) CfgFailure(pLine); else /* YES. DO IT */ (*(pEntry->func)) (skipwh(pLine + 1)); - - /* might have been the UMB driver */ - if (UmbState == 2) - { - - UCOUNT umb_seg, umb_size; - - if (UMB_get_largest(&umb_seg, &umb_size)) - { - UmbState = 1; - upBase = MK_FP(umb_seg, 0); - UMB_top = umb_size; - umb_start = umb_seg; - -/* reset root */ - uppermem_root = ram_top * 64 - 1; -/* setup the real mcb for the devicehigh block */ - zumcb_init(umb_seg, UMB_top - 1); - upBase += 16; - } - } - } close(nFileDesc); @@ -898,6 +907,13 @@ STATIC VOID Files(BYTE * pLine) /* Got the value, assign either default or new value */ Config.cfgFiles = max(Config.cfgFiles, nFiles); + Config.cfgFilesHigh = 0; +} + +STATIC VOID FilesHigh(BYTE * pLine) +{ + Files(pLine); + Config.cfgFilesHigh = 1; } STATIC VOID CfgLastdrive(BYTE * pLine) @@ -916,6 +932,14 @@ STATIC VOID CfgLastdrive(BYTE * pLine) drv -= 'A'; drv++; /* Make real number */ Config.cfgLastdrive = max(Config.cfgLastdrive, drv); + Config.cfgLastdriveHigh = 0; +} + +STATIC VOID CfgLastdriveHigh(BYTE * pLine) +{ + /* Format: LASTDRIVEHIGH = letter */ + CfgLastdrive(pLine); + Config.cfgLastdriveHigh = 1; } /* @@ -969,6 +993,21 @@ STATIC VOID Dosmem(BYTE * pLine) } } +STATIC VOID DosData(BYTE * pLine) +{ + BYTE *pTmp; + +/* extern BYTE FAR INITDataSegmentClaimed; */ + + pLine = GetStringArg(pLine, szBuf); + + for (pTmp = szBuf; *pTmp != '\0'; pTmp++) + *pTmp = toupper(*pTmp); + + if (fmemcmp(szBuf, "UMB", 3) == 0) + Config.cfgDosDataUmb = TRUE; +} + STATIC VOID CfgSwitchar(BYTE * pLine) { /* Format: SWITCHAR = character */ @@ -1085,6 +1124,13 @@ STATIC VOID Stacks(BYTE * pLine) if (Config.cfgStacks > 64) Config.cfgStacks = 64; } + Config.cfgStacksHigh = 0; +} + +STATIC VOID StacksHigh(BYTE * pLine) +{ + Stacks(pLine); + Config.cfgStacksHigh = 1; } STATIC VOID InitPgmHigh(BYTE * pLine) @@ -1157,21 +1203,32 @@ STATIC BOOL LoadDevice(BYTE * pLine, char FAR *top, COUNT mode) struct dhdr FAR *dhp; struct dhdr FAR *next_dhp; BOOL result; + seg base, start; if (mode) - dhp = AlignParagraph(upBase); + { + base = umb_base_seg; + start = umb_start; + } else - dhp = AlignParagraph(lpBase); + { + base = base_seg; + start = first_mcb; + } + if (base == start) + base++; + base++; + /* Get the device driver name */ GetStringArg(pLine, szBuf); /* The driver is loaded at the top of allocated memory. */ /* The device driver is paragraph aligned. */ - eb.load.reloc = eb.load.load_seg = FP_SEG(dhp); + eb.load.reloc = eb.load.load_seg = base; #ifdef DEBUG - printf("Loading device driver %s at segment %04x\n", szBuf, FP_SEG(dhp)); + printf("Loading device driver %s at segment %04x\n", szBuf, base); #endif if ((result = init_DosExec(3, &eb, szBuf)) != SUCCESS) @@ -1189,6 +1246,8 @@ STATIC BOOL LoadDevice(BYTE * pLine, char FAR *top, COUNT mode) /* add \r\n to the command line */ strcat(szBuf, "\r\n"); + dhp = MK_FP(base, 0); + for (next_dhp = NULL; FP_OFF(next_dhp) != 0xffff && (result = init_device(dhp, szBuf, mode, top)) == SUCCESS; dhp = next_dhp) @@ -1206,14 +1265,10 @@ STATIC BOOL LoadDevice(BYTE * pLine, char FAR *top, COUNT mode) dhp->dh_next = nul_dev.dh_next; nul_dev.dh_next = dhp; } - /* We could just have loaded FDXMS or HIMEM */ - if (HMAState == HMA_REQ && MoveKernelToHMA()) - { - /* final HMA processing: */ - /* final buffer processing, now upwards */ - HMAState = HMA_DONE; - config_init_buffers(Config.cfgBuffers); - } + + /* might have been the UMB driver or DOS=UMB */ + if (UmbState == 2) + umb_init(); return result; } @@ -1238,42 +1293,96 @@ STATIC VOID CfgFailure(BYTE * pLine) printf("^\n"); } -#ifndef KDB -void FAR * KernelAlloc(size_t nBytes) +struct submcb { - BYTE FAR *lpAllocated; + char type; + unsigned short start; + unsigned short size; + char unused[3]; + char name[8]; +}; - lpBase = AlignParagraph(lpBase); - lpAllocated = lpBase; +void FAR * KernelAllocPara(size_t nPara, char type, char *name, int mode) +{ + seg base, start; + struct submcb FAR *p; - if (0xffff - FP_OFF(lpBase) <= nBytes) - { - UWORD newOffs = (FP_OFF(lpBase) + nBytes) & 0xFFFF; - UWORD newSeg = FP_SEG(lpBase) + 0x1000; + if (UmbState != 1) + mode = 0; - lpBase = MK_FP(newSeg, newOffs); + if (mode) + { + base = umb_base_seg; + start = umb_start; } else - lpBase += nBytes; + { + base = base_seg; + start = first_mcb; + } - fmemset(lpAllocated, 0, nBytes); + /* create the special DOS data MCB if it doesn't exist yet */ + DebugPrintf(("kernelallocpara: %x %x %x %c %d\n", start, base, nPara, type, mode)); - return lpAllocated; + if (base == start) + { + mcb FAR *p = para2far(base); + mcb_init(base + 1, p->m_size - 1); + para2far(base+1)->m_type = p->m_type; + p->m_type = MCB_NORMAL; + p->m_psp = 8; + p->m_size = 0; + p->m_name[0] = 'S'; + p->m_name[1] = 'D'; + base++; + } + + mcb_init(base + nPara + 1, para2far(base)->m_size - nPara - 1); + para2far(base + nPara + 1)->m_type = para2far(base)->m_type; + para2far(start)->m_size += nPara + 1; + + p = (struct submcb FAR *)para2far(base); + p->type = type; + p->start = FP_SEG(p)+1; + p->size = nPara; + if (name) + fmemcpy(p->name, name, 8); + base += nPara + 1; + if (mode) + umb_base_seg = base; + else + base_seg = base; + return MK_FP(FP_SEG(p)+1, 0); +} + +void FAR * KernelAlloc(size_t nBytes, char type, int mode) +{ + void FAR *p; + size_t nPara = (nBytes + 15)/16; + + if (first_mcb == 0) + { + /* prealloc */ + lpTop = MK_FP(FP_SEG(lpTop) - nPara, FP_OFF(lpTop)); + return AlignParagraph(lpTop); + + } + else + { + p = KernelAllocPara((nBytes + 15)/16, type, NULL, mode); + } + fmemset(p, 0, nBytes); + return p; } -#endif #ifdef I86 #if 0 -STATIC BYTE FAR * KernelAllocDma(WORD bytes) +STATIC BYTE FAR * KernelAllocDma(WORD bytes, char type) { - BYTE FAR *allocated; - - lpBase = AlignParagraph(lpBase); - if ((FP_SEG(lpBase) & 0x0fff) + (bytes >> 4) > 0x1000) - lpBase = MK_FP((FP_SEG(lpBase) + 0x0fff) & 0xf000, 0); - allocated = lpBase; - lpBase += bytes; - return allocated; + if ((base_seg & 0x0fff) + (bytes >> 4) > 0x1000) { + KernelAllocPara((base_seg + 0x0fff) & 0xf000 - base_seg, type, NULL, 0); + } + return KernelAlloc(bytes, type); } #endif @@ -1426,35 +1535,21 @@ STATIC VOID mcb_init(UCOUNT seg, UWORD size) { COUNT i; - mcb FAR *mcbp = MK_FP(seg, 0); + mcb FAR *mcbp = para2far(seg); mcbp->m_type = MCB_LAST; mcbp->m_psp = FREE_PSP; - mcbp->m_size = (UmbState > 0 ? size - 1 : size); - for (i = 0; i < 8; i++) mcbp->m_name[i] = '\0'; - mem_access_mode = FIRST_FIT; -} - -STATIC VOID zumcb_init(UCOUNT seg, UWORD size) -{ - COUNT i; - mcb FAR *mcbp = MK_FP(seg, 0); - - mcbp->m_type = MCB_LAST; - mcbp->m_psp = FREE_PSP; + mcbp->m_size = size; - for (i = 0; i < 8; i++) - mcbp->m_name[i] = '\0'; - } STATIC VOID mumcb_init(UCOUNT seg, UWORD size) { COUNT i; - mcb FAR *mcbp = MK_FP(seg, 0); + mcb FAR *mcbp = para2far(seg); static char name[8] = "SC\0\0\0\0\0\0"; @@ -1522,7 +1617,6 @@ VOID config_init_buffers(COUNT anzBuffers) { REG WORD i; struct buffer FAR *pbuffer; - BYTE FAR *tmplpBase = lpBase; unsigned wantedbuffers = anzBuffers; if (anzBuffers < 0) @@ -1544,10 +1638,8 @@ VOID config_init_buffers(COUNT anzBuffers) lpTop = lpOldTop; - if (HMAState == HMA_NONE || HMAState == HMA_REQ) - lpTop = lpBase = lpTop - (anzBuffers * sizeof(struct buffer) + 0xf); - - firstbuf = ConfigAlloc(sizeof(struct buffer) * anzBuffers); + firstbuf = ConfigAlloc(sizeof(struct buffer) * anzBuffers, 'B'); + pbuffer = firstbuf; DebugPrintf(("init_buffers (size %u) at", sizeof(struct buffer))); @@ -1577,9 +1669,6 @@ VOID config_init_buffers(COUNT anzBuffers) if (FP_SEG(pbuffer) == 0xffff) printf("Kernel: allocated %d Diskbuffers = %u Bytes in HMA\n", anzBuffers, anzBuffers * sizeof(struct buffer)); - - if (HMAState == HMA_NONE || HMAState == HMA_REQ) - lpBase = tmplpBase; } /* @@ -2199,9 +2288,11 @@ struct { int mode; } InstallCommands[10]; +#ifdef DEBUG +#define InstallPrintf(x) printf x +#else #define InstallPrintf(x) -/*#define InstallPrintf(x) printf x*/ - +#endif STATIC VOID _CmdInstall(BYTE * pLine,int mode) { @@ -2212,12 +2303,12 @@ STATIC VOID _CmdInstall(BYTE * pLine,int mode) printf("Too many Install commands given (%d max)\n",LENGTH(InstallCommands)); CfgFailure(pLine); return; - } + } fmemcpy(InstallCommands[numInstallCmds].buffer,pLine,127); InstallCommands[numInstallCmds].buffer[127] = 0; InstallCommands[numInstallCmds].mode = mode; numInstallCmds++; -} +} STATIC VOID CmdInstall(BYTE * pLine) { _CmdInstall(pLine,0); @@ -2264,6 +2355,24 @@ void InstallExec(char *cmd) } } +STATIC unsigned alloc(size_t size) +{ + iregs r; + + r.a.b.h = 0x48; /* alloc memory */ + r.b.x = size; + init_call_intr(0x21, &r); + return r.a.x; +} + +STATIC void free(seg segment) +{ + iregs r; + + r.a.b.h = 0x49; /* free memory */ + r.es = segment; + init_call_intr(0x21, &r); +} VOID DoInstall(void) { @@ -2288,11 +2397,7 @@ VOID DoInstall(void) r.b.b.l = 0x02; /*low memory, last fit */ init_call_intr(0x21, &r); - r.a.b.h = 0x48; /* alloc memory */ - r.b.x = ((unsigned)_init_end+15)/16; - init_call_intr(0x21, &r); - installMemory = r.a.x; - + installMemory = alloc(((unsigned)_init_end+15)/16); InstallPrintf(("allocated memory at %x\n",installMemory)); @@ -2311,9 +2416,7 @@ VOID DoInstall(void) r.b.b.l = 0x00; /*low memory, high */ init_call_intr(0x21, &r); - r.a.b.h = 0x49; /* alloc memory */ - r.es = installMemory; - init_call_intr(0x21, &r); + free(installMemory); InstallPrintf(("Done with installing commands\n")); return; diff --git a/kernel/init-mod.h b/kernel/init-mod.h index c4962f6b..7e7d8ecf 100644 --- a/kernel/init-mod.h +++ b/kernel/init-mod.h @@ -66,9 +66,11 @@ int fmemcmp(BYTE far * s1, BYTE FAR * s2, unsigned len); /* Start of configuration variables */ struct config { + UBYTE cfgDosDataUmb; BYTE cfgBuffers; /* number of buffers in the system */ UBYTE cfgFiles; + UBYTE cfgFilesHigh; /* number of available files */ UBYTE cfgFcbs; /* number of available FCBs */ @@ -79,8 +81,10 @@ struct config { BYTE cfgInitTail[NAMEMAX]; /* command.com's tail */ UBYTE cfgLastdrive; + UBYTE cfgLastdriveHigh; /* last drive */ BYTE cfgStacks; + BYTE cfgStacksHigh; /* number of stacks */ UWORD cfgStackSize; /* stacks size for each stack */ @@ -107,10 +111,12 @@ extern struct config Config; /* config.c */ VOID PreConfig(VOID); +VOID PreConfig2(VOID); VOID DoConfig(int pass); VOID PostConfig(VOID); VOID configDone(VOID); -VOID FAR * KernelAlloc(size_t nBytes); +VOID FAR * KernelAlloc(size_t nBytes, char type, int mode); +void FAR * KernelAllocPara(size_t nPara, char type, char *name, int mode); char *strcat(char * d, const char * s); COUNT ASMCFUNC Umb_Test(void); COUNT ASMCFUNC UMB_get_largest(UCOUNT * seg, UCOUNT * size); @@ -168,7 +174,7 @@ VOID ASMCFUNC FAR int2f_handler(void); /* main.c */ VOID ASMCFUNC FreeDOSmain(void); -BOOL init_device(struct dhdr FAR * dhp, BYTE FAR * cmdLine, +BOOL init_device(struct dhdr FAR * dhp, char * cmdLine, COUNT mode, char FAR *top); VOID init_fatal(BYTE * err_msg); @@ -177,7 +183,7 @@ WORD CDECL init_printf(CONST BYTE * fmt, ...); WORD CDECL init_sprintf(BYTE * buff, CONST BYTE * fmt, ...); void MoveKernel(unsigned NewKernelSegment); -extern WORD HMAFree; /* first byte in HMA not yet used */ +extern UWORD HMAFree; /* first byte in HMA not yet used */ extern unsigned CurrentKernelSegment; diff --git a/kernel/inithma.c b/kernel/inithma.c index df94c6d5..5b5ea9d4 100644 --- a/kernel/inithma.c +++ b/kernel/inithma.c @@ -78,7 +78,7 @@ static BYTE *RcsId = BYTE DosLoadedInHMA = FALSE; /* set to TRUE if loaded HIGH */ BYTE HMAclaimed = FALSE; /* set to TRUE if claimed from HIMEM */ -WORD HMAFree = 0; /* first byte in HMA not yet used */ +UWORD HMAFree = 0; /* first byte in HMA not yet used */ extern void FAR *DOSTEXTFAR ASM XMSDriverAddress; VOID ASMCFUNC FAR _EnableA20(VOID); diff --git a/kernel/main.c b/kernel/main.c index b95c07bd..f7dd49c7 100644 --- a/kernel/main.c +++ b/kernel/main.c @@ -33,7 +33,7 @@ #include "init-dat.h" char copyright[] = - "(C) Copyright 1995-2002 Pasquale J. Villani and The FreeDOS Project.\n" + "(C) Copyright 1995-2003 Pasquale J. Villani and The FreeDOS Project.\n" "All Rights Reserved. This is free software and comes with ABSOLUTELY NO\n" "WARRANTY; you can redistribute it and/or modify it under the terms of the\n" "GNU General Public License as published by the Free Software Foundation;\n" @@ -77,10 +77,8 @@ static BYTE *mainRcsId = struct _KernelConfig InitKernelConfig = { "", 0, 0, 0, 0, 0, 0 }; extern WORD days[2][13]; -extern BYTE FAR *lpBase; extern BYTE FAR *lpOldTop; extern BYTE FAR *lpTop; -extern BYTE FAR *upBase; extern BYTE ASM _ib_start[], ASM _ib_end[], ASM _init_end[]; extern UWORD ram_top; /* How much ram in Kbytes */ @@ -229,16 +227,13 @@ STATIC void init_kernel(void) /* Fake int 21h stack frame */ user_r = (iregs FAR *) MK_FP(DOS_PSP, 0xD0); -#ifndef KDB for (i = 0x20; i <= 0x3f; i++) setvec(i, empty_handler); -#endif /* Initialize IO subsystem */ InitIO(); InitPrinters(); -#ifndef KDB /* set interrupt vectors */ setvec(0x1b, got_cbreak); setvec(0x20, int20_handler); @@ -252,7 +247,6 @@ STATIC void init_kernel(void) setvec(0x28, int28_handler); setvec(0x2a, int2a_handler); setvec(0x2f, int2f_handler); -#endif init_PSPSet(DOS_PSP); init_PSPInit(DOS_PSP); @@ -275,11 +269,15 @@ STATIC void init_kernel(void) /* Now config the temporary file system */ FsConfig(); -#ifndef KDB /* Now process CONFIG.SYS */ DoConfig(0); DoConfig(1); + /* initialize near data and MCBs */ + PreConfig2(); + /* and process CONFIG.SYS one last time for device drivers */ + DoConfig(2); + /* Close all (device) files */ for (i = 0; i < lastdrive; i++) close(i); @@ -292,18 +290,8 @@ STATIC void init_kernel(void) /* Init the file system one more time */ FsConfig(); - /* and process CONFIG.SYS one last time to load device drivers. */ - DoConfig(2); configDone(); - /* Close all (device) files */ - for (i = 0; i < lastdrive; i++) - close(i); - - /* Now config the final file system */ - FsConfig(); - -#endif InitializeAllBPBs(); } @@ -524,7 +512,7 @@ STATIC VOID update_dcb(struct dhdr FAR * dhp) dpb = dpb->dpb_next) ; dpb = dpb->dpb_next = - (struct dpb FAR *)KernelAlloc(nunits * sizeof(struct dpb)); + KernelAlloc(nunits * sizeof(struct dpb), 'E', Config.cfgDosDataUmb); } for (Index = 0; Index < nunits; Index++) @@ -547,11 +535,21 @@ STATIC VOID update_dcb(struct dhdr FAR * dhp) /* If cmdLine is NULL, this is an internal driver */ -BOOL init_device(struct dhdr FAR * dhp, BYTE FAR * cmdLine, COUNT mode, +BOOL init_device(struct dhdr FAR * dhp, char *cmdLine, COUNT mode, char FAR *r_top) { request rq; - + int i; + char name[8]; + char *p; + + fmemset(name, 0, 8); + for (p = cmdLine; *p && *p != ' ' && *p != '\t'; p++); + while (p >= cmdLine && *p != '\\' && *p != '/' && *p != ':') p--; + p++; + for (i = 0; i < 8 && p[i] && p[i] != '.'; i++) + name[i] = p[i]; + rq.r_unit = 0; rq.r_status = 0; rq.r_command = C_INIT; @@ -570,21 +568,12 @@ BOOL init_device(struct dhdr FAR * dhp, BYTE FAR * cmdLine, COUNT mode, if (cmdLine) { - if (mode) - { - /* Don't link in device drivers which do not take up memory */ - if (rq.r_endaddr == (BYTE FAR *) dhp) - return TRUE; - else - upBase = rq.r_endaddr; - } - else - { - if (rq.r_endaddr == (BYTE FAR *) dhp) - return TRUE; - else - lpBase = rq.r_endaddr; - } + /* Don't link in device drivers which do not take up memory */ + if (rq.r_endaddr == (BYTE FAR *) dhp) + return TRUE; + + KernelAllocPara(FP_SEG(rq.r_endaddr) + (FP_OFF(rq.r_endaddr) + 15)/16 + - FP_SEG(dhp), 'D', name, mode); } if (!(dhp->dh_attr & ATTR_CHAR) && (rq.r_nunits != 0)) From 52109658314d9edb847f09011de88e813d39c3e0 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sun, 15 Jun 2003 14:21:49 +0000 Subject: [PATCH 202/671] * minor size optimizations in chario.c, dosfns.c; asmsupt.asm: correct fmemchr (all n's) and *memset/*memcpy (n==0) git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@590 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/asmsupt.asm | 10 ++++++---- kernel/chario.c | 12 +++++++----- kernel/dosfns.c | 30 ++++++++++++++---------------- 3 files changed, 27 insertions(+), 25 deletions(-) diff --git a/kernel/asmsupt.asm b/kernel/asmsupt.asm index 55525ad3..0be40242 100644 --- a/kernel/asmsupt.asm +++ b/kernel/asmsupt.asm @@ -119,6 +119,7 @@ domemcpy: ; And do the built-in byte copy, but do a 16-bit transfer ; whenever possible. shr cx,1 + jcxz memcpy_return rep movsw jnc memcpy_return movsb @@ -180,9 +181,10 @@ FMEMSET: mov bl,8 domemset: - mov ah, al + mov ah, al - shr cx,1 + shr cx,1 + jcxz pascal_return rep stosw jnc pascal_return stosb @@ -390,12 +392,12 @@ FMEMCHR: les di, [bp+8] mov bl, 8 - + + jcxz strchr_retzero repne scasb jne strchr_retzero mov dx, es mov ax, di - dec ax jmp short strchr_found1 ;********************************************************************** diff --git a/kernel/chario.c b/kernel/chario.c index 2d7ec4b5..85a04fe8 100644 --- a/kernel/chario.c +++ b/kernel/chario.c @@ -218,6 +218,7 @@ STATIC int raw_put_char(int sft_idx, int c) STATIC int cooked_put_char(int sft_idx, int c) { int err = 0; + unsigned char scrpos = scr_pos; /* Test for hold char */ con_hold(sft_idx); @@ -225,23 +226,24 @@ STATIC int cooked_put_char(int sft_idx, int c) switch (c) { case CR: - scr_pos = 0; + scrpos = 0; break; case LF: case BELL: break; case BS: - if (scr_pos > 0) - scr_pos--; + if (scrpos > 0) + scrpos--; break; case HT: do err = raw_put_char(sft_idx, ' '); - while (err >= 0 && ((++scr_pos) & 7)); + while (err >= 0 && ((++scrpos) & 7)); break; default: - scr_pos++; + scrpos++; } + scr_pos = scrpos; if (c != HT) err = raw_put_char(sft_idx, c); return err; diff --git a/kernel/dosfns.c b/kernel/dosfns.c index 1a077436..3357bb88 100644 --- a/kernel/dosfns.c +++ b/kernel/dosfns.c @@ -239,23 +239,25 @@ long DosRWSft(int sft_idx, size_t n, void FAR * bp, int mode) { size_t cnt = (size_t)rc; const char FAR *p = bp; + unsigned char scrpos = scr_pos; while (cnt--) { switch (*p++) { case CR: - scr_pos = 0; + scrpos = 0; break; case LF: case BELL: break; case BS: - --scr_pos; + --scrpos; break; default: - ++scr_pos; + ++scrpos; } } + scr_pos = scrpos; } return rc; } @@ -398,14 +400,9 @@ ULONG DosSeek(unsigned hndl, LONG new_pos, COUNT mode) STATIC long get_free_hndl(void) { psp FAR *p = MK_FP(cu_psp, 0); - unsigned hndl; - - for (hndl = 0; hndl < p->ps_maxfiles; hndl++) - { - if (p->ps_filetab[hndl] == 0xff) - return hndl; - } - return DE_TOOMANY; + UBYTE FAR *q = p->ps_filetab; + UBYTE FAR *r = fmemchr(q, 0xff, p->ps_maxfiles); + return FP_OFF(r) == 0 ? DE_TOOMANY : r - q; } STATIC sft FAR *get_free_sft(COUNT * sft_idx) @@ -442,18 +439,19 @@ STATIC sft FAR *get_free_sft(COUNT * sft_idx) const char FAR *get_root(const char FAR * fname) { /* find the end */ - register unsigned length = fstrlen(fname) - 1; + register unsigned length = fstrlen(fname); char c; /* now back up to first path seperator or start */ - while (length != (unsigned)-1) + fname += length; + while (length) { - c = fname[length]; + length--; + c = *--fname; if (c == '/' || c == '\\' || c == ':') break; - --length; } - return fname + length + 1; + return fname; } /* initialize SFT fields (for open/creat) for character devices */ From 05df4d89f4e911610b640268fd77e510eb227497 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sun, 15 Jun 2003 14:38:13 +0000 Subject: [PATCH 203/671] if user left accidentally floppy or CD in drive, give him a chance to continue to boot from HD. disabled by default, enablable by SYS CONFIG (Tom Ehlert) git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@591 6ac86273-5f31-0410-b378-82cca8765d1b --- docs/history.txt | 30 +++++++++++++- hdr/kconfig.h | 12 +++++- kernel/config.c | 3 +- kernel/main.c | 101 ++++++++++++++++++++++++++++++++++++++++++++++- lib/makefile | 2 +- sys/fdkrncfg.c | 12 ++++++ utils/exeflat.c | 4 +- 7 files changed, 158 insertions(+), 6 deletions(-) diff --git a/docs/history.txt b/docs/history.txt index 62e29faf..1c1b88ff 100644 --- a/docs/history.txt +++ b/docs/history.txt @@ -1,4 +1,32 @@ -2002 Mar 14 - Build 2029 +2003 Jun xx - Build 2030 +-------- Bart Oldeman (bart@dosemu.org) ++ Changes Tom +if user left accidentally floppy or CD in drive, +give him a chance to continue to boot from HD. +disabled by default, enablable by SYS CONFIG + ++ Changes Bart + * flip some slashes in drivers/*.asm + (enables cross-assembly on Linux) + * remove superfluous printf("\n") in patchobj.c + * combine the INIT class with the CODE class (classes can span + multiple physical segments) + * re-add _TEXT to LGROUP to be able to simplify the patchobj magic + * don't specify -zPI_GROUP for the init code in Borland compilers + (unnecessary, it will be put there because of segs.inc) + * remove STDPATCH; it is no longer necessary + * add FILESHIGH, LASTDRIVEHIGH, and STACKSHIGH and DOSDATA=UMB + to load these structures into UMBs + * make DOS sub-MCBs visible (seen by MEM) + * preliminary allocation of FILES etc. now takes place at the + top of conventional memory, and device drivers are loaded before + the final allocation takes place. + * handle multiple UMBs more correctly (but config.sys can use + only one UMB for devicehigh -- /Ln,xxxx is not yet implemented) + * minor size optimizations in chario.c, dosfns.c; + asmsupt.asm: correct fmemchr (all n's) and *memset/*memcpy (n==0) + 185 relocs, 54 not shown +2003 Mar 14 - Build 2029 -------- Bart Oldeman (bart@dosemu.org) + Changes Tom * fattab.c, fat.h removed the wrong ELSE_ISFAT32() diff --git a/hdr/kconfig.h b/hdr/kconfig.h index 56fccbb8..b6a4faed 100644 --- a/hdr/kconfig.h +++ b/hdr/kconfig.h @@ -12,7 +12,16 @@ SkipConfigSeconds: < 0 : not possible to skip config.sys = 0 : only possible if already pressed before, no message - > 0 : wait so long for F5/F8 + > 0 : wait so long for F5/F8 + + BootHarddiskSeconds: boots by default - and without user interaction - from HD + <= 0: normal + > 0: + display message + ' hit any key to continue to boot from 'diskette or CD' + wait ## seconds + if no key hit, boot from HD + */ typedef struct _KernelConfig { char CONFIG[6]; /* "CONFIG" */ @@ -23,4 +32,5 @@ typedef struct _KernelConfig { signed char SkipConfigSeconds; unsigned char ForceLBA; unsigned char GlobalEnableLBAsupport; /* = 0 --> disable LBA support */ + signed char BootHarddiskSeconds; } KernelConfig; diff --git a/kernel/config.c b/kernel/config.c index 63241aa8..32cbe8a6 100644 --- a/kernel/config.c +++ b/kernel/config.c @@ -695,7 +695,7 @@ STATIC ULONG GetBiosTime(VOID) return *(ULONG FAR *) (MK_FP(0x40, 0x6c)); } -STATIC UWORD GetBiosKey(int timeout) +UWORD GetBiosKey(int timeout) { iregs r; @@ -2421,3 +2421,4 @@ VOID DoInstall(void) InstallPrintf(("Done with installing commands\n")); return; } + diff --git a/kernel/main.c b/kernel/main.c index f7dd49c7..e585ef33 100644 --- a/kernel/main.c +++ b/kernel/main.c @@ -74,7 +74,7 @@ static BYTE *mainRcsId = "$Id$"; #endif -struct _KernelConfig InitKernelConfig = { "", 0, 0, 0, 0, 0, 0 }; +struct _KernelConfig InitKernelConfig = { "", 0, 0, 0, 0, 0, 0, 0 }; extern WORD days[2][13]; extern BYTE FAR *lpOldTop; @@ -90,6 +90,7 @@ STATIC VOID signon(VOID); STATIC VOID kernel(VOID); STATIC VOID FsConfig(VOID); STATIC VOID InitPrinters(VOID); +void CheckContinueBootFromHarddisk(); extern void Init_clk_driver(void); @@ -132,6 +133,8 @@ void fmemcpy(void far *dest, const void far *src, unsigned n) while(n--) *d++ = *s++; } +void CheckContinueBootFromHarddisk(void); + VOID ASMCFUNC FreeDOSmain(void) { #ifdef _MSC_VER @@ -164,11 +167,20 @@ VOID ASMCFUNC FreeDOSmain(void) fmemcpy(&InitKernelConfig, &LowKernelConfig, sizeof(InitKernelConfig)); } + + + + setvec(0, int0_handler); /* zero divide */ setvec(1, empty_handler); /* single step */ setvec(3, empty_handler); /* debug breakpoint */ setvec(6, int6_handler); /* invalid opcode */ + + CheckContinueBootFromHarddisk(); + + + /* clear the Init BSS area (what normally the RTL does */ memset(_ib_start, 0, _ib_end - _ib_start); @@ -630,3 +642,90 @@ STATIC VOID InitPrinters(VOID) } } +/***************************************************************** + if kernel.config.BootHarddiskSeconds is set, + the default is to boot from harddisk, because + the user is assumed to just have forgotten to + remove the floppy/bootable CD from the drive. + + user has some seconds to hit ANY key to continue + to boot from floppy/cd, else the system is + booted from HD +*/ + +extern UWORD GetBiosKey(int timeout); + +EmulatedDriveStatus(int drive,char statusOnly) +{ + iregs r; + char buffer[13]; + buffer[0] = 0x13; + + r.a.b.h = 0x4b; /* bootable CDROM - get status */ + r.a.b.l = statusOnly; + r.d.b.l = (char)drive; + r.si = (int)buffer; + init_call_intr(0x13, &r); + + if (r.flags & 1) + return FALSE; + + return TRUE; +} + +void CheckContinueBootFromHarddisk(void) +{ + char *bootedFrom = "CD"; + iregs r; + + if (InitKernelConfig.BootHarddiskSeconds == 0) + return; + + if (BootDrive >= 3) + { + if (!EmulatedDriveStatus(0x80,1)) + { + /* already booted from HD */ + return; + } + } + else { + if (!EmulatedDriveStatus(0x00,1)) + bootedFrom = "Floppy"; + } + + printf("\n" + "\n" + "\n" + " Hit any key within %d seconds to continue booot from %s\n" + " else continue to boot from Harddisk\n", + InitKernelConfig.BootHarddiskSeconds, + bootedFrom + ); + + if (GetBiosKey(InitKernelConfig.BootHarddiskSeconds) != -1) + { + /* user has hit a key, continue to boot from floppy/CD */ + printf("\n"); + return; + } + + /* reboot from harddisk */ + EmulatedDriveStatus(0x00,0); + EmulatedDriveStatus(0x80,0); + + /* now jump and run */ + r.a.x = 0x0201; + r.c.x = 0x0001; + r.d.x = 0x0080; + r.b.x = 0x7c00; + r.es = 0; + + init_call_intr(0x13, &r); + + { + void (far *reboot)() = (void (far*)()) MK_FP(0x0,0x7c00); + + (*reboot)(); + } +} diff --git a/lib/makefile b/lib/makefile index b4876460..6eaa3d39 100644 --- a/lib/makefile +++ b/lib/makefile @@ -11,7 +11,7 @@ libm.lib: $(CLIB) -$(RM) libm.lib $(LIBUTIL) $(CLIB) $(MATH_EXTRACT) $(LIBTERM) - for %i in (*.obj) do ..\utils\patchobj CODE=LCODE TEXT=_LOWTEXT %i + for %i in (*.obj) do ..\utils\patchobj CODE=LCODE %i $(LIBUTIL) libm $(MATH_INSERT) $(LIBTERM) -$(RM) *.OBJ diff --git a/sys/fdkrncfg.c b/sys/fdkrncfg.c index 33a46d92..48b3aa33 100644 --- a/sys/fdkrncfg.c +++ b/sys/fdkrncfg.c @@ -182,6 +182,13 @@ void displayConfigSettings(KernelConfig * cfg) cfg->GlobalEnableLBAsupport); } + if (cfg->ConfigSize >= 6) + { + printf + ("BootHarddiskSeconds=%d : *0=no else seconds to wait for key\n", + cfg->BootHarddiskSeconds); + } + #if 0 /* we assume that SYS is as current as the kernel */ /* Print value any options added that are unknown as hex dump */ @@ -432,6 +439,11 @@ int FDKrnConfigMain(int argc, char **argv) setByteOption(&(cfg.GlobalEnableLBAsupport), cptr, 1, &updates, "GLOBALENABLELBASUPPORT"); } + else if (memicmp(argptr, "BootHarddiskSeconds", 3) == 0) + { + setSByteOption(&(cfg.BootHarddiskSeconds), + cptr, 0, 127, &updates, "BootHarddiskSeconds"); + } else { illegal_arg: diff --git a/utils/exeflat.c b/utils/exeflat.c index d2c8503a..8e93b0d4 100644 --- a/utils/exeflat.c +++ b/utils/exeflat.c @@ -241,7 +241,9 @@ int main(int argc, char **argv) 2, /* SkipConfigSeconds db 2 */ 0, /* ForceLBA db 0 */ 1, /* GlobalEnableLBAsupport db 1 */ - 'u', 'n', 'u', 's', 'e', 'd', /* unused filler bytes */ + 0, /* BootHarddiskSeconds */ + + 'n', 'u', 's', 'e', 'd', /* unused filler bytes */ 8, 7, 6, 5, 4, 3, 2, 1, /* real-entry: jump over the 'real' image do the trailer */ 0xe9, 0, 0 /* 100: jmp 103 */ From ed78089e0b01e4aad8e2be9fecbeb9f163f6d96b Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sun, 15 Jun 2003 15:53:58 +0000 Subject: [PATCH 204/671] introduce lol structure for list of lists; avoid lots of relocations git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@592 6ac86273-5f31-0410-b378-82cca8765d1b --- docs/copying | 11 ++-- hdr/lol.h | 82 ++++++++++++++++++++++++ hdr/sft.h | 6 +- kernel/config.c | 157 ++++++++++++++++++++-------------------------- kernel/init-dat.h | 1 - kernel/init-mod.h | 6 ++ kernel/inithma.c | 8 ++- kernel/intr.asm | 28 +++++++++ kernel/kernel.asm | 93 +++++++++++++-------------- kernel/main.c | 87 ++++++++++--------------- 10 files changed, 276 insertions(+), 203 deletions(-) create mode 100644 hdr/lol.h diff --git a/docs/copying b/docs/copying index a43ea212..5b6e7c66 100644 --- a/docs/copying +++ b/docs/copying @@ -2,7 +2,7 @@ Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. - 675 Mass Ave, Cambridge, MA 02139, USA + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. @@ -279,7 +279,7 @@ POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS - Appendix: How to Apply These Terms to Your New Programs + How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it @@ -291,7 +291,7 @@ convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. - Copyright (C) 19yy + Copyright (C) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -305,14 +305,15 @@ the "copyright" line and a pointer to where the full notice is found. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: - Gnomovision version 69, Copyright (C) 19yy name of author + Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. diff --git a/hdr/lol.h b/hdr/lol.h new file mode 100644 index 00000000..eac928ed --- /dev/null +++ b/hdr/lol.h @@ -0,0 +1,82 @@ +/****************************************************************/ +/* */ +/* lol.h */ +/* */ +/* DOS List of Lists structure */ +/* */ +/* Copyright (c) 2003 */ +/* Bart Oldeman */ +/* All Rights Reserved */ +/* */ +/* This file is part of DOS-C. */ +/* */ +/* DOS-C is free software; you can redistribute it and/or */ +/* modify it under the terms of the GNU General Public License */ +/* as published by the Free Software Foundation; either version */ +/* 2, or (at your option) any later version. */ +/* */ +/* DOS-C is distributed in the hope that it will be useful, but */ +/* WITHOUT ANY WARRANTY; without even the implied warranty of */ +/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See */ +/* the GNU General Public License for more details. */ +/* */ +/* You should have received a copy of the GNU General Public */ +/* License along with DOS-C; if not, write to the Free Software */ +/* Foundation, Inc., 59 Temple Place, Suite 330, */ +/* Boston, MA 02111-1307 USA. */ +/****************************************************************/ + +/* note: we start at DOSDS:0, but the "official" list of lists starts a + little later at DOSDS:26 (this is what is returned by int21/ah=52) */ + +struct lol { + char filler[0x22]; + char *inputptr; /* -4 Pointer to unread CON input */ + unsigned short first_mcb; /* -2 Start of user memory */ + struct dpb far *DPBp; /* 0 First drive Parameter Block */ + struct sfttbl far *sfthead; /* 4 System File Table head */ + struct dhdr far *clock; /* 8 CLOCK$ device */ + struct dhdr far *syscon; /* c console device */ + unsigned short maxsecbytes; /* 10 max bytes per sector for any blkdev */ + void far *inforecptr; /* 12 pointer to disk buffer info record */ + struct cds far *CDSp; /* 16 Current Directory Structure */ + struct sfttbl far *FCBp; /* 1a FCB table pointer */ + unsigned short nprotfcb; /* 1e number of protected fcbs */ + unsigned char nblkdev; /* 20 number of block devices */ + unsigned char lastdrive; /* 21 value of last drive */ + struct dhdr nul_dev; /* 22 NUL device driver header(no pointer!)*/ + unsigned char njoined; /* 34 number of joined devices */ + unsigned short specialptr; /* 35 pointer to list of spec. prog(unused)*/ + void far *setverPtr; /* 37 pointer to SETVER list */ + void (*a20ptr)(void); /* 3b pointer to fix A20 ctrl */ + unsigned short recentpsp; /* 3d PSP of most recently exec'ed prog */ + unsigned short nbuffers; /* 3f Number of buffers */ + unsigned short nlookahead; /* 41 Number of lookahead buffers */ + unsigned char BootDrive; /* 43 bootdrive (1=A:) */ + unsigned char dwordmoves; /* 44 use dword moves (unused) */ + unsigned short xmssize; /* 45 extended memory size in KB */ + struct buffer far *firstbuf; /* 47 head of buffers linked list */ + unsigned short dirtybuf; /* 4b number of dirty buffers */ + struct buffer far *lookahead;/* 4d pointer to lookahead buffer */ + unsigned short slookahead; /* 51 number of lookahead sectors */ + unsigned char bufloc; /* 53 BUFFERS loc (1=HMA) */ + struct buffer far *deblock; /* 54 pointer to workspace buffer */ + char filler2[5]; /* 58 ???/unused */ + unsigned char int24fail; /* 5d int24 fail while making i/o stat call*/ + unsigned char memstrat; /* 5e memory allocation strat during exec */ + unsigned char a20count; /* 5f nr. of int21 calls for which a20 off */ + unsigned char VgaSet; /* 60 bitflags switches=/w, int21/4b05 */ + unsigned short unpack; /* 61 offset of unpack code start */ + unsigned char uppermem_link; /* 63 UMB Link flag */ + unsigned short min_pars; /* 64 minimum para req by program execed */ + unsigned short uppermem_root;/* 66 Start of umb chain (usually 9fff) */ + unsigned short last_para; /* 68 para: start scanning during memalloc */ + /* FreeDOS specific entries */ + unsigned char os_minor; /* 6a minor DOS version */ + unsigned char os_major; /* 6b major DOS version */ + unsigned char rev_number; /* 6c minor DOS version */ + unsigned char version_flags; /* 6d DOS version flags */ + f_node_ptr f_nodes; /* 6e pointer to the array */ + unsigned short f_nodes_cnt; /* 70 number of allocated f_nodes */ + char *os_release; /* 72 near pointer to os_release string */ +}; diff --git a/hdr/sft.h b/hdr/sft.h index 9b222892..c6842c11 100644 --- a/hdr/sft.h +++ b/hdr/sft.h @@ -76,15 +76,15 @@ typedef struct { /* SFT Table header definition */ typedef struct _sftheader { - struct _sfttbl FAR * /* link to next table in list */ + struct sfttbl FAR * /* link to next table in list */ sftt_next; WORD sftt_count; /* # of handle definition */ /* entries, this table */ } sftheader; /* System File Definition List */ -typedef struct _sfttbl { - struct _sfttbl FAR * /* link to next table in list */ +typedef struct sfttbl { + struct sfttbl FAR * /* link to next table in list */ sftt_next; WORD sftt_count; /* # of handle definition */ /* entries, this table */ diff --git a/kernel/config.c b/kernel/config.c index 32cbe8a6..a78f21a6 100644 --- a/kernel/config.c +++ b/kernel/config.c @@ -31,6 +31,7 @@ #include "init-mod.h" #include "init-dat.h" #include "dyndata.h" +#include "lol.h" #ifdef VERSION_STRINGS static BYTE *RcsId = @@ -52,34 +53,19 @@ static BYTE *RcsId = -- Bart */ -extern f_node_ptr DOSFAR f_nodes; /* pointer to the array */ -extern UWORD DOSFAR f_nodes_cnt, /* number of allocated f_nodes */ - DOSFAR ASM first_mcb; /* Start of user memory */ -extern UBYTE DOSFAR ASM lastdrive, DOSFAR ASM nblkdev, DOSFAR ASM uppermem_link; extern struct dhdr -DOSTEXTFAR ASM blk_dev, /* Block device (Disk) driver */ - DOSFAR ASM nul_dev; -extern struct buffer FAR *DOSFAR ASM firstbuf; /* head of buffers linked list */ +DOSTEXTFAR ASM blk_dev; /* Block device (Disk) driver */ extern struct buffer FAR *DOSFAR firstAvailableBuf; /* first 'available' buffer */ -extern struct dpb FAR *DOSFAR ASM DPBp; -/* First drive Parameter Block */ -extern struct cds FAR *DOSFAR ASM CDSp; -/* Current Directory Structure */ -extern sfttbl FAR *DOSFAR ASM sfthead; -/* System File Table head */ -extern sfttbl FAR *DOSFAR ASM FCBp; +extern struct lol ASM DOSFAR DATASTART; +struct lol FAR *LoL = &DATASTART; extern BYTE DOSFAR _HMATextAvailable, /* first byte of available CODE area */ FAR _HMATextStart[], /* first byte of HMAable CODE area */ FAR _HMATextEnd[], DOSFAR ASM break_ena, /* break enabled flag */ - DOSFAR os_major, /* major version number */ - DOSFAR os_minor, /* minor version number */ - DOSFAR ASM switchar, DOSFAR _InitTextStart, /* first available byte of ram */ + DOSFAR _InitTextStart, /* first available byte of ram */ DOSFAR ReturnAnyDosVersionExpected; -extern UWORD DOSFAR ASM uppermem_root, DOSFAR ASM LoL_nbuffers; - UWORD umb_start = 0, UMB_top = 0; UWORD ram_top = 0; /* How much ram in Kbytes */ @@ -183,7 +169,7 @@ STATIC char * stristr(char *s1, char *s2); #endif STATIC COUNT strcasecmp(REG BYTE * d, REG BYTE * s); STATIC int LoadCountryInfoHardCoded(char *filename, COUNT ctryCode, COUNT codePage); -STATIC unsigned alloc(size_t size); +STATIC void umb_init(void); void HMAconfig(int finalize); VOID config_init_buffers(COUNT anzBuffers); /* from BLOCKIO.C */ @@ -297,33 +283,33 @@ void PreConfig(void) /* f_nodes = (f_node_ptr) KernelAlloc(Config.cfgFiles * sizeof(struct f_node));*/ - f_nodes = (f_node_ptr) + LoL->f_nodes = (f_node_ptr) DynAlloc("f_nodes", Config.cfgFiles, sizeof(struct f_node)); - f_nodes_cnt = Config.cfgFiles; - /* sfthead = (sfttbl FAR *)&basesft; */ - /* FCBp = (sfttbl FAR *)&FcbSft; */ - /* FCBp = (sfttbl FAR *) + LoL->f_nodes_cnt = Config.cfgFiles; + LoL->sfthead = MK_FP(FP_SEG(LoL), 0xcc); /* &(LoL->firstsftt) */ + /* LoL->FCBp = (sfttbl FAR *)&FcbSft; */ + /* LoL->FCBp = (sfttbl FAR *) KernelAlloc(sizeof(sftheader) + Config.cfgFiles * sizeof(sft)); */ config_init_buffers(Config.cfgBuffers); - sfthead->sftt_next = + LoL->sfthead->sftt_next = KernelAlloc(sizeof(sftheader) + (Config.cfgFiles - 5) * sizeof(sft), 'F', 0); - sfthead->sftt_next->sftt_next = (sfttbl FAR *) - 1; - sfthead->sftt_next->sftt_count = Config.cfgFiles - 5; + LoL->sfthead->sftt_next->sftt_next = (sfttbl FAR *) - 1; + LoL->sfthead->sftt_next->sftt_count = Config.cfgFiles - 5; - CDSp = KernelAlloc(sizeof(struct cds) * lastdrive, 'L', 0); + LoL->CDSp = KernelAlloc(sizeof(struct cds) * LoL->lastdrive, 'L', 0); - DPBp = KernelAlloc(blk_dev.dh_name[0] * sizeof(struct dpb), 'E', 0); + LoL->DPBp = KernelAlloc(blk_dev.dh_name[0] * sizeof(struct dpb), 'E', 0); #ifdef DEBUG - printf("Preliminary:\n f_node 0x%x", f_nodes); -/* printf(" FCB table 0x%p\n",FCBp);*/ - printf(" sft table 0x%p\n", sfthead->sftt_next); - printf(" CDS table 0x%p\n", CDSp); - printf(" DPB table 0x%p\n", DPBp); + printf("Preliminary:\n f_node 0x%x", LoL->f_nodes); +/* printf(" FCB table 0x%p\n",LoL->FCBp);*/ + printf(" sft table 0x%p\n", LoL->sfthead->sftt_next); + printf(" CDS table 0x%p\n", LoL->CDSp); + printf(" DPB table 0x%p\n", LoL->DPBp); #endif /* Done. Now initialize the MCB structure */ @@ -339,11 +325,11 @@ void PreConfig2(void) /* initialize NEAR allocated things */ /* Initialize the file table */ - DynFree(f_nodes); - f_nodes = (f_node_ptr) + DynFree(LoL->f_nodes); + LoL->f_nodes = (f_node_ptr) DynAlloc("f_nodes", Config.cfgFiles, sizeof(struct f_node)); - f_nodes_cnt = Config.cfgFiles; /* and the number of allocated files */ + LoL->f_nodes_cnt = Config.cfgFiles; /* and the number of allocated files */ /* Initialize the base memory pointers from last time. */ /* @@ -353,10 +339,10 @@ void PreConfig2(void) and allocation starts after the kernel. */ - base_seg = first_mcb = FP_SEG(AlignParagraph((BYTE FAR *) DynLast() + 0x0f)); + base_seg = LoL->first_mcb = FP_SEG(AlignParagraph((BYTE FAR *) DynLast() + 0x0f)); /* We expect ram_top as Kbytes, so convert to paragraphs */ - mcb_init(first_mcb, ram_top * 64 - first_mcb - 1); + mcb_init(LoL->first_mcb, ram_top * 64 - LoL->first_mcb - 1); if (UmbState == 2) umb_init(); } @@ -379,9 +365,9 @@ void PostConfig(void) /* close all (device) files */ /* compute lastdrive ... */ - lastdrive = Config.cfgLastdrive; - if (lastdrive < nblkdev) - lastdrive = nblkdev; + LoL->lastdrive = Config.cfgLastdrive; + if (LoL->lastdrive < LoL->nblkdev) + LoL->lastdrive = LoL->nblkdev; DebugPrintf(("starting FAR allocations at %x\n", base_seg)); @@ -393,27 +379,27 @@ void PostConfig(void) config_init_buffers(Config.cfgBuffers); -/* sfthead = (sfttbl FAR *)&basesft; */ - /* FCBp = (sfttbl FAR *)&FcbSft; */ - /* FCBp = KernelAlloc(sizeof(sftheader) +/* LoL->sfthead = (sfttbl FAR *)&basesft; */ + /* LoL->FCBp = (sfttbl FAR *)&FcbSft; */ + /* LoL->FCBp = KernelAlloc(sizeof(sftheader) + Config.cfgFiles * sizeof(sft)); */ - sfthead->sftt_next = (sfttbl FAR *) + LoL->sfthead->sftt_next = (sfttbl FAR *) KernelAlloc(sizeof(sftheader) + (Config.cfgFiles - 5) * sizeof(sft), 'F', Config.cfgFilesHigh); - sfthead->sftt_next->sftt_next = (sfttbl FAR *) - 1; - sfthead->sftt_next->sftt_count = Config.cfgFiles - 5; + LoL->sfthead->sftt_next->sftt_next = (sfttbl FAR *) - 1; + LoL->sfthead->sftt_next->sftt_count = Config.cfgFiles - 5; - CDSp = KernelAlloc(sizeof(struct cds) * lastdrive, 'L', Config.cfgLastdriveHigh); + LoL->CDSp = KernelAlloc(sizeof(struct cds) * LoL->lastdrive, 'L', Config.cfgLastdriveHigh); - DPBp = KernelAlloc(blk_dev.dh_name[0] * sizeof(struct dpb), 'E', + LoL->DPBp = KernelAlloc(blk_dev.dh_name[0] * sizeof(struct dpb), 'E', Config.cfgDosDataUmb); #ifdef DEBUG - printf("Final: \n f_node 0x%x\n", f_nodes); -/* printf(" FCB table 0x%p\n",FCBp);*/ - printf(" sft table 0x%p\n", sfthead->sftt_next); - printf(" CDS table 0x%p\n", CDSp); - printf(" DPB table 0x%p\n", DPBp); + printf("Final: \n f_node 0x%x\n", LoL->f_nodes); +/* printf(" FCB table 0x%p\n",LoL->FCBp);*/ + printf(" sft table 0x%p\n", LoL->sfthead->sftt_next); + printf(" CDS table 0x%p\n", LoL->CDSp); + printf(" DPB table 0x%p\n", LoL->DPBp); #endif if (Config.cfgStacks) { @@ -436,9 +422,12 @@ VOID configDone(VOID) if (HMAState != HMA_DONE) { - seg kernel_seg = alloc((HMAFree+0xf)/16); - mcb FAR *p = para2far(kernel_seg - 1); - + mcb FAR *p; + unsigned short kernel_seg; + + allocmem((HMAFree+0xf)/16, &kernel_seg); + p = para2far(kernel_seg - 1); + p->m_name[0] = 'S'; p->m_name[1] = 'C'; p->m_psp = 8; @@ -480,12 +469,12 @@ STATIC void umb_init(void) UmbState = 1; /* reset root */ - uppermem_root = ram_top * 64 - 1; + LoL->uppermem_root = ram_top * 64 - 1; /* create link mcb (below) */ para2far(base_seg)->m_type = MCB_NORMAL; para2far(base_seg)->m_size--; - mumcb_init(uppermem_root, umb_seg - uppermem_root - 1); + mumcb_init(LoL->uppermem_root, umb_seg - LoL->uppermem_root - 1); /* setup the real mcb for the devicehigh block */ mcb_init(umb_seg, umb_size - 2); @@ -511,7 +500,7 @@ STATIC void umb_init(void) mcb_init(umb_seg, umb_size - 2); /* determine prev and next umbs */ - umb_prev = prev_mcb(umb_seg, uppermem_root); + umb_prev = prev_mcb(umb_seg, LoL->uppermem_root); umb_next = umb_prev + para2far(umb_prev)->m_size + 1; para2far(umb_seg)->m_type = MCB_NORMAL; @@ -893,8 +882,8 @@ STATIC VOID sysVersion(BYTE * pLine) printf("Changing reported version to %d.%d\n", major, minor); - os_major = major; - os_minor = minor; + LoL->os_major = major; + LoL->os_minor = minor; } STATIC VOID Files(BYTE * pLine) @@ -982,8 +971,8 @@ STATIC VOID Dosmem(BYTE * pLine) if (UmbState == 0) { - uppermem_link = 0; - uppermem_root = 0xffff; + LoL->uppermem_link = 0; + LoL->uppermem_root = 0xffff; UmbState = UMBwanted ? 2 : 0; } /* Check if HMA is available straight away */ @@ -1013,7 +1002,7 @@ STATIC VOID CfgSwitchar(BYTE * pLine) /* Format: SWITCHAR = character */ GetStringArg(pLine, szBuf); - switchar = *szBuf; + init_switchar(*szBuf); } STATIC VOID Fcbs(BYTE * pLine) @@ -1213,7 +1202,7 @@ STATIC BOOL LoadDevice(BYTE * pLine, char FAR *top, COUNT mode) else { base = base_seg; - start = first_mcb; + start = LoL->first_mcb; } if (base == start) @@ -1261,9 +1250,9 @@ STATIC BOOL LoadDevice(BYTE * pLine, char FAR *top, COUNT mode) printf("multisegmented device driver found, next %p\n", next_dhp); /* give warning message */ #endif - /* Link in device driver and save nul_dev pointer to next */ - dhp->dh_next = nul_dev.dh_next; - nul_dev.dh_next = dhp; + /* Link in device driver and save LoL->nul_dev pointer to next */ + dhp->dh_next = LoL->nul_dev.dh_next; + LoL->nul_dev.dh_next = dhp; } /* might have been the UMB driver or DOS=UMB */ @@ -1318,7 +1307,7 @@ void FAR * KernelAllocPara(size_t nPara, char type, char *name, int mode) else { base = base_seg; - start = first_mcb; + start = LoL->first_mcb; } /* create the special DOS data MCB if it doesn't exist yet */ @@ -1360,7 +1349,7 @@ void FAR * KernelAlloc(size_t nBytes, char type, int mode) void FAR *p; size_t nPara = (nBytes + 15)/16; - if (first_mcb == 0) + if (LoL->first_mcb == 0) { /* prealloc */ lpTop = MK_FP(FP_SEG(lpTop) - nPara, FP_OFF(lpTop)); @@ -1634,16 +1623,17 @@ VOID config_init_buffers(COUNT anzBuffers) printf("BUFFERS=%u not supported, reducing to 99\n", anzBuffers); anzBuffers = 99; } - LoL_nbuffers = anzBuffers; + LoL->nbuffers = anzBuffers; lpTop = lpOldTop; - firstbuf = ConfigAlloc(sizeof(struct buffer) * anzBuffers, 'B'); + LoL->inforecptr = &LoL->firstbuf; + LoL->firstbuf = ConfigAlloc(sizeof(struct buffer) * anzBuffers, 'B'); - pbuffer = firstbuf; + pbuffer = LoL->firstbuf; DebugPrintf(("init_buffers (size %u) at", sizeof(struct buffer))); - DebugPrintf((" (%p)", firstbuf)); + DebugPrintf((" (%p)", LoL->firstbuf)); pbuffer->b_prev = FP_OFF(pbuffer + (anzBuffers-1)); for (i = 1; i < anzBuffers; ++i) @@ -2355,16 +2345,6 @@ void InstallExec(char *cmd) } } -STATIC unsigned alloc(size_t size) -{ - iregs r; - - r.a.b.h = 0x48; /* alloc memory */ - r.b.x = size; - init_call_intr(0x21, &r); - return r.a.x; -} - STATIC void free(seg segment) { iregs r; @@ -2397,7 +2377,7 @@ VOID DoInstall(void) r.b.b.l = 0x02; /*low memory, last fit */ init_call_intr(0x21, &r); - installMemory = alloc(((unsigned)_init_end+15)/16); + allocmem(((unsigned)_init_end+15)/16, &installMemory); InstallPrintf(("allocated memory at %x\n",installMemory)); @@ -2421,4 +2401,3 @@ VOID DoInstall(void) InstallPrintf(("Done with installing commands\n")); return; } - diff --git a/kernel/init-dat.h b/kernel/init-dat.h index 96727dd8..cda5e055 100644 --- a/kernel/init-dat.h +++ b/kernel/init-dat.h @@ -30,4 +30,3 @@ extern __segment DosTextSeg; #error unknown compiler - please adjust We might even deal with a pre-ANSI compiler. This will certainly not compile. #endif -extern BYTE DOSFAR version_flags; /* minor version number */ diff --git a/kernel/init-mod.h b/kernel/init-mod.h index 7e7d8ecf..9bf571f2 100644 --- a/kernel/init-mod.h +++ b/kernel/init-mod.h @@ -147,7 +147,10 @@ int ASMCFUNC allocmem(UWORD size, seg * segp); VOID ASMCFUNC init_PSPInit(seg psp_seg); VOID ASMCFUNC init_PSPSet(seg psp_seg); COUNT ASMCFUNC init_DosExec(COUNT mode, exec_blk * ep, BYTE * lp); +int ASMCFUNC init_setdrive(int drive); +int ASMCFUNC init_switchar(int chr); VOID ASMCFUNC keycheck(VOID); +void ASMCFUNC set_DTA(void far *dta); /* irqstack.asm */ VOID ASMCFUNC init_stacks(VOID FAR * stack_base, COUNT nStacks, @@ -193,3 +196,6 @@ ULONG ASMCFUNC FAR MULULUL(ULONG mul1, ULONG mul2); /* MULtiply ULong by ULo ULONG ASMCFUNC FAR DIVULUS(ULONG mul1, UWORD mul2); /* DIVide ULong by UShort */ ULONG ASMCFUNC FAR DIVMODULUS(ULONG mul1, UWORD mul2, UWORD * rem); /* DIVide ULong by UShort */ #endif + +extern struct lol FAR *LoL; + diff --git a/kernel/inithma.c b/kernel/inithma.c index 5b5ea9d4..9db01d87 100644 --- a/kernel/inithma.c +++ b/kernel/inithma.c @@ -66,6 +66,7 @@ #include "portab.h" #include "init-mod.h" #include "init-dat.h" +#include "lol.h" extern BYTE FAR ASM _HMATextAvailable, /* first byte of available CODE area */ FAR ASM _HMATextStart[], /* first byte of HMAable CODE area */ @@ -246,7 +247,7 @@ int MoveKernelToHMA() InstallVDISK(); /* report the fact we are running high through int 21, ax=3306 */ - version_flags |= 0x10; + LoL->version_flags |= 0x10; return TRUE; @@ -323,7 +324,8 @@ void MoveKernel(unsigned NewKernelSegment) UBYTE FAR *HMADest; UBYTE FAR *HMASource; unsigned len; - + unsigned jmpseg = CurrentKernelSegment; + if (CurrentKernelSegment == 0) CurrentKernelSegment = FP_SEG(_HMATextEnd); @@ -404,7 +406,7 @@ void MoveKernel(unsigned NewKernelSegment) for (rp = _HMARelocationTableStart; rp < _HMARelocationTableEnd; rp++) { if (rp->jmpFar != 0xea || /* jmp FAR */ - rp->jmpSegment != CurrentKernelSegment || /* will only relocate HMA_TEXT */ + rp->jmpSegment != jmpseg || /* will only relocate HMA_TEXT */ rp->callNear != 0xe8 || /* call NEAR */ 0) { diff --git a/kernel/intr.asm b/kernel/intr.asm index eebbfb04..06ab82a5 100644 --- a/kernel/intr.asm +++ b/kernel/intr.asm @@ -285,6 +285,24 @@ _init_DosExec: exec_no_error ret +;; int init_setdrive(int drive) + global _init_setdrive +_init_setdrive: + mov ah, 0x0e + mov bx, sp + mov dl, [bx+2] + int 21h + ret + +;; int init_switchar(int char) + global _init_switchar +_init_switchar: + mov ax, 0x3701 + mov bx, sp + mov dl, [bx+2] + int 21h + ret + ;; int allocmem(UWORD size, seg *segp) global _allocmem _allocmem: @@ -299,3 +317,13 @@ _allocmem: xor ax, ax ret +;; void set_DTA(void far *dta) + global _set_DTA +_set_DTA + mov ah, 1ah + mov bx, sp + push ds + lds dx, [bx+2] + int 21h + pop ds + ret diff --git a/kernel/kernel.asm b/kernel/kernel.asm index 1dbe4284..1d49d85f 100644 --- a/kernel/kernel.asm +++ b/kernel/kernel.asm @@ -101,7 +101,7 @@ beyond_entry: resb 256-(beyond_entry-entry) segment INIT_TEXT - extern _FreeDOSmain:wrt I_GROUP + extern _FreeDOSmain ; ; kernel start-up @@ -118,7 +118,7 @@ kernel_start: pop bx pop ax - mov ax,I_GROUP + mov ax,cs cli mov ss,ax mov sp,init_tos @@ -142,23 +142,10 @@ kernel_start: mov ax,cont push ax retf -cont: ; inititalize api stacks for high water tests - mov ax,cs +cont: mov ax,cs mov ss,ax - mov di,seg apistk_bottom - mov es,di - mov di,apistk_bottom - mov ax,apistk_top - sub ax,di - sar ax,1 - mov cx,ax - mov ax,09090h - cld - rep stosw ; Now set up call frame - mov ax,DGROUP - mov ds,ax - mov es,ax + mov ds,[cs:_INIT_DGROUP] mov bp,sp ; and set up stack frame for c sti ; now enable them @@ -230,6 +217,7 @@ _nul_intr: pop es retf +segment _LOWTEXT ; floppy parameter table global _int1e_table _int1e_table: times 0eh db 0 @@ -278,16 +266,14 @@ _first_mcb dw 0 ;-0002 Start of user memory MARK0026H equ $ _DPBp dd 0 ; 0000 First drive Parameter Block global _sfthead -_sfthead dw _firstsftt ; 0004 System File Table head - dw seg _firstsftt +_sfthead dd 0 ; 0004 System File Table head global _clock _clock dd 0 ; 0008 CLOCK$ device global _syscon _syscon dw _con_dev,seg _con_dev ; 000c console device global _maxbksize _maxbksize dw 512 ; 0010 maximum bytes/sector of any block device - dw buf_info ; 0012 pointer to buffers info structure - dw seg buf_info + dd 0 ; 0012 pointer to buffers info structure global _CDSp _CDSp dd 0 ; 0016 Current Directory Structure global _FCBp @@ -348,6 +334,22 @@ _min_pars dw 0 ; 0064 minimum paragraphs of memory _uppermem_root dw 0ffffh ; 0066 dmd_upper_root (usually 9fff) _last_para dw 0 ; 0068 para of last mem search SysVarEnd: +;; FreeDOS specific entries + global _os_minor +_os_minor db 0 + global _os_major +_os_major db 5 + global _rev_number +_rev_number db 0 + global _version_flags +_version_flags db 0 + global _f_nodes +_f_nodes dw 0 + global _f_nodes_cnt +_f_nodes_cnt dw 0 + global os_release + extern _os_release +os_release dw _os_release ;; The first 5 sft entries appear to have to be at DS:00cc times (0cch - ($ - DATASTART)) db 0 @@ -438,8 +440,7 @@ _CritErrCode dw 0 ; 04 - DOS format error Code _CritErrAction db 0 ; 06 - Error Action Code _CritErrClass db 0 ; 07 - Error Class _CritErrDev dd 0 ; 08 - Failing Device Address -_dta dw _sda_tmp_dm, seg _sda_tmp_dm - ; 0C - current DTA, initialize to TempBuffer. +_dta dd 0 ; 0C - current DTA _cu_psp dw 0 ; 10 - Current PSP break_sp dw 0 ; 12 - used in int 23 _return_code dw 0 ; 14 - return code from process @@ -596,13 +597,13 @@ _FcbSearchBuffer: ; of error stack as scratch buffer global apistk_bottom apistk_bottom: - times STACK_SIZE dw 0 ;300 - Error Processing Stack + times STACK_SIZE dw 0x9090 ;300 - Error Processing Stack global _error_tos _error_tos: - times STACK_SIZE dw 0 ;480 - Disk Function Stack + times STACK_SIZE dw 0x9090 ;480 - Disk Function Stack global _disk_api_tos _disk_api_tos: - times STACK_SIZE dw 0 ;600 - Char Function Stack + times STACK_SIZE dw 0x9090 ;600 - Char Function Stack global _char_api_tos _char_api_tos: apistk_top: @@ -656,7 +657,7 @@ clk_stk_top: ; have a jump to the real thing here for AARD compliance global _CharMapSrvc ; in _DATA (see AARD) -_CharMapSrvc: jmp far CharMapSrvc2 +_CharMapSrvc: jmp 0x70:CharMapSrvc2 ; Dynamic data: ; member of the DOS DATA GROUP @@ -750,14 +751,6 @@ _empty_handler: iret -; to minimize relocations - global _DGROUP_ -_DGROUP_: - dw DGROUP - - -segment _LOWTEXT - global _initforceEnableA20 initforceEnableA20: call near forceEnableA20 @@ -768,65 +761,65 @@ __HMARelocationTableStart: global _int2f_handler extern reloc_call_int2f_handler -_int2f_handler: jmp far reloc_call_int2f_handler +_int2f_handler: jmp 0:reloc_call_int2f_handler call near forceEnableA20 global _int20_handler extern reloc_call_int20_handler -_int20_handler: jmp far reloc_call_int20_handler +_int20_handler: jmp 0:reloc_call_int20_handler call near forceEnableA20 global _int21_handler extern reloc_call_int21_handler -_int21_handler: jmp far reloc_call_int21_handler +_int21_handler: jmp 0:reloc_call_int21_handler call near forceEnableA20 global _low_int25_handler extern reloc_call_low_int25_handler -_low_int25_handler: jmp far reloc_call_low_int25_handler +_low_int25_handler: jmp 0:reloc_call_low_int25_handler call near forceEnableA20 global _low_int26_handler extern reloc_call_low_int26_handler -_low_int26_handler: jmp far reloc_call_low_int26_handler +_low_int26_handler: jmp 0:reloc_call_low_int26_handler call near forceEnableA20 global _int27_handler extern reloc_call_int27_handler -_int27_handler: jmp far reloc_call_int27_handler +_int27_handler: jmp 0:reloc_call_int27_handler call near forceEnableA20 global _int0_handler extern reloc_call_int0_handler -_int0_handler: jmp far reloc_call_int0_handler +_int0_handler: jmp 0:reloc_call_int0_handler call near forceEnableA20 global _int6_handler extern reloc_call_int6_handler -_int6_handler: jmp far reloc_call_int6_handler +_int6_handler: jmp 0:reloc_call_int6_handler call near forceEnableA20 global _cpm_entry extern reloc_call_cpm_entry -_cpm_entry: jmp far reloc_call_cpm_entry +_cpm_entry: jmp 0:reloc_call_cpm_entry call near forceEnableA20 global _reloc_call_blk_driver extern _blk_driver _reloc_call_blk_driver: - jmp far _blk_driver + jmp 0:_blk_driver call near forceEnableA20 global _reloc_call_clk_driver extern _clk_driver _reloc_call_clk_driver: - jmp far _clk_driver + jmp 0:_clk_driver call near forceEnableA20 ; global _CharMapSrvc ; in _DATA (see AARD) extern _reloc_call_CharMapSrvc -CharMapSrvc2: jmp far _reloc_call_CharMapSrvc +CharMapSrvc2: jmp 0:_reloc_call_CharMapSrvc call near forceEnableA20 @@ -946,6 +939,11 @@ _int24_handler: mov al,FAIL ; this makes some things easier ; +; to minimize relocations +segment HMA_TEXT + global _DGROUP_ +_DGROUP_ dw DGROUP + segment _LOWTEXT global _TEXT_DGROUP _TEXT_DGROUP dw DGROUP @@ -953,4 +951,3 @@ _TEXT_DGROUP dw DGROUP segment INIT_TEXT global _INIT_DGROUP _INIT_DGROUP dw DGROUP - diff --git a/kernel/main.c b/kernel/main.c index e585ef33..16ab8056 100644 --- a/kernel/main.c +++ b/kernel/main.c @@ -31,6 +31,7 @@ #include "init-mod.h" #include "dyndata.h" #include "init-dat.h" +#include "lol.h" char copyright[] = "(C) Copyright 1995-2003 Pasquale J. Villani and The FreeDOS Project.\n" @@ -47,24 +48,10 @@ char copyright[] = -- Bart */ -extern UBYTE DOSFAR ASM nblkdev, DOSFAR ASM lastdrive; /* value of last drive */ -GLOBAL BYTE DOSFAR os_major, /* major version number */ - DOSFAR os_minor, /* minor version number */ - DOSFAR ASM default_drive; /* default drive for dos */ -GLOBAL UBYTE DOSFAR ASM BootDrive; /* Drive we came up from */ - -GLOBAL BYTE DOSFAR os_release[]; - -extern struct dpb FAR *DOSFAR ASM DPBp; /* First drive Parameter Block */ -extern struct cds FAR *DOSFAR ASM CDSp; /* Current Directory Structure */ - -extern struct dhdr FAR *DOSFAR ASM clock, /* CLOCK$ device */ - FAR * DOSFAR ASM syscon; /* console device */ extern struct dhdr ASM DOSTEXTFAR con_dev, /* console device drive */ DOSTEXTFAR ASM clk_dev, /* Clock device driver */ DOSTEXTFAR ASM blk_dev; /* Block device (Disk) driver */ -extern iregs FAR *DOSFAR ASM user_r; /* User registers for int 21h call */ extern BYTE FAR ASM _HMATextEnd[]; extern struct _KernelConfig FAR ASM LowKernelConfig; @@ -90,7 +77,7 @@ STATIC VOID signon(VOID); STATIC VOID kernel(VOID); STATIC VOID FsConfig(VOID); STATIC VOID InitPrinters(VOID); -void CheckContinueBootFromHarddisk(); +void CheckContinueBootFromHarddisk(void); extern void Init_clk_driver(void); @@ -133,8 +120,6 @@ void fmemcpy(void far *dest, const void far *src, unsigned n) while(n--) *d++ = *s++; } -void CheckContinueBootFromHarddisk(void); - VOID ASMCFUNC FreeDOSmain(void) { #ifdef _MSC_VER @@ -155,10 +140,10 @@ VOID ASMCFUNC FreeDOSmain(void) { fmemcpy(&InitKernelConfig, MK_FP(0x50,0xe0+2), sizeof(InitKernelConfig)); - BootDrive = *(BYTE FAR *)MK_FP(0x50,0xe0) + 1; + LoL->BootDrive = *(BYTE FAR *)MK_FP(0x50,0xe0) + 1; - if (BootDrive >= 0x80) - BootDrive = 3; /* C: */ + if (LoL->BootDrive >= 0x80) + LoL->BootDrive = 3; /* C: */ *(DWORD FAR *)MK_FP(0x50,0xe0+2) = 0; } @@ -167,10 +152,6 @@ VOID ASMCFUNC FreeDOSmain(void) fmemcpy(&InitKernelConfig, &LowKernelConfig, sizeof(InitKernelConfig)); } - - - - setvec(0, int0_handler); /* zero divide */ setvec(1, empty_handler); /* single step */ setvec(3, empty_handler); /* debug breakpoint */ @@ -189,7 +170,7 @@ VOID ASMCFUNC FreeDOSmain(void) #ifdef DEBUG /* Non-portable message kludge alert! */ - printf("KERNEL: Boot drive = %c\n", 'A' + BootDrive - 1); + printf("KERNEL: Boot drive = %c\n", 'A' + LoL->BootDrive - 1); #endif DoInstall(); @@ -211,7 +192,7 @@ void InitializeAllBPBs(VOID) { static char filename[] = "A:-@JUNK@-.TMP"; int drive, fileno; - for (drive = 'C'; drive < 'A' + nblkdev; drive++) + for (drive = 'C'; drive < 'A' + LoL->nblkdev; drive++) { filename[0] = drive; if ((fileno = open(filename, O_RDONLY)) >= 0) @@ -223,8 +204,8 @@ STATIC void init_kernel(void) { COUNT i; - os_major = MAJOR_RELEASE; - os_minor = MINOR_RELEASE; + LoL->os_major = MAJOR_RELEASE; + LoL->os_minor = MINOR_RELEASE; /* Init oem hook - returns memory size in KB */ ram_top = init_oem(); @@ -236,9 +217,6 @@ STATIC void init_kernel(void) MoveKernel(FP_SEG(lpTop)); lpOldTop = lpTop = MK_FP(FP_SEG(lpTop) - 0xfff, 0xfff0); -/* Fake int 21h stack frame */ - user_r = (iregs FAR *) MK_FP(DOS_PSP, 0xD0); - for (i = 0x20; i <= 0x3f; i++) setvec(i, empty_handler); @@ -260,6 +238,7 @@ STATIC void init_kernel(void) setvec(0x2a, int2a_handler); setvec(0x2f, int2f_handler); + set_DTA(MK_FP(DOS_PSP, 0x80)); init_PSPSet(DOS_PSP); init_PSPInit(DOS_PSP); @@ -267,7 +246,7 @@ STATIC void init_kernel(void) /* Do first initialization of system variable buffers so that */ /* we can read config.sys later. */ - lastdrive = Config.cfgLastdrive; + LoL->lastdrive = Config.cfgLastdrive; /* init_device((struct dhdr FAR *)&blk_dev, NULL, NULL, ram_top); */ blk_dev.dh_name[0] = dsk_init(); @@ -291,12 +270,12 @@ STATIC void init_kernel(void) DoConfig(2); /* Close all (device) files */ - for (i = 0; i < lastdrive; i++) + for (i = 0; i < LoL->lastdrive; i++) close(i); /* and do final buffer allocation. */ PostConfig(); - nblkdev = 0; + LoL->nblkdev = 0; update_dcb(&blk_dev); /* Init the file system one more time */ @@ -312,21 +291,18 @@ STATIC VOID FsConfig(VOID) REG COUNT i; struct dpb FAR *dpb; - /* Log-in the default drive. */ - /* Get the boot drive from the ipl and use it for default. */ - default_drive = BootDrive - 1; - dpb = DPBp; + dpb = LoL->DPBp; /* Initialize the current directory structures */ - for (i = 0; i < lastdrive; i++) + for (i = 0; i < LoL->lastdrive; i++) { - struct cds FAR *pcds_table = &CDSp[i]; + struct cds FAR *pcds_table = &LoL->CDSp[i]; fmemcpy(pcds_table->cdsCurrentPath, "A:\\\0", 4); pcds_table->cdsCurrentPath[0] += i; - if (i < nblkdev && (ULONG) dpb != 0xffffffffl) + if (i < LoL->nblkdev && (ULONG) dpb != 0xffffffffl) { pcds_table->cdsDpb = dpb; pcds_table->cdsFlags = CDSPHYSDRV; @@ -342,6 +318,9 @@ STATIC VOID FsConfig(VOID) pcds_table->cdsJoinOffset = 2; } + /* Log-in the default drive. */ + init_setdrive(LoL->BootDrive - 1); + /* The system file tables need special handling and are "hand */ /* built. Included is the stdin, stdout, stdaux and stdprn. */ /* a little bit of shuffling is necessary for compatibility */ @@ -370,7 +349,7 @@ STATIC VOID FsConfig(VOID) STATIC VOID signon() { - printf("\r%S", (void FAR *)os_release); + printf("\r%S", MK_FP(FP_SEG(LoL), FP_OFF(LoL->os_release))); printf("Kernel compatibility %d.%d", MAJOR_RELEASE, MINOR_RELEASE); @@ -516,11 +495,11 @@ STATIC VOID update_dcb(struct dhdr FAR * dhp) COUNT nunits = dhp->dh_name[0]; struct dpb FAR *dpb; - if (nblkdev == 0) - dpb = DPBp; + if (LoL->nblkdev == 0) + dpb = LoL->DPBp; else { - for (dpb = DPBp; (ULONG) dpb->dpb_next != 0xffffffffl; + for (dpb = LoL->DPBp; (ULONG) dpb->dpb_next != 0xffffffffl; dpb = dpb->dpb_next) ; dpb = dpb->dpb_next = @@ -530,17 +509,17 @@ STATIC VOID update_dcb(struct dhdr FAR * dhp) for (Index = 0; Index < nunits; Index++) { dpb->dpb_next = dpb + 1; - dpb->dpb_unit = nblkdev; + dpb->dpb_unit = LoL->nblkdev; dpb->dpb_subunit = Index; dpb->dpb_device = dhp; dpb->dpb_flags = M_CHANGED; - if ((CDSp != 0) && (nblkdev < lastdrive)) + if ((LoL->CDSp != 0) && (LoL->nblkdev < LoL->lastdrive)) { - CDSp[nblkdev].cdsDpb = dpb; - CDSp[nblkdev].cdsFlags = CDSPHYSDRV; + LoL->CDSp[LoL->nblkdev].cdsDpb = dpb; + LoL->CDSp[LoL->nblkdev].cdsFlags = CDSPHYSDRV; } ++dpb; - ++nblkdev; + ++LoL->nblkdev; } (dpb - 1)->dpb_next = (void FAR *)0xFFFFFFFFl; } @@ -568,7 +547,7 @@ BOOL init_device(struct dhdr FAR * dhp, char *cmdLine, COUNT mode, rq.r_length = sizeof(request); rq.r_endaddr = r_top; rq.r_bpbptr = (void FAR *)(cmdLine ? cmdLine : "\n"); - rq.r_firstunit = nblkdev; + rq.r_firstunit = LoL->nblkdev; execrh((request FAR *) & rq, dhp); @@ -595,9 +574,9 @@ BOOL init_device(struct dhdr FAR * dhp, char *cmdLine, COUNT mode, } if (dhp->dh_attr & ATTR_CONIN) - syscon = dhp; + LoL->syscon = dhp; else if (dhp->dh_attr & ATTR_CLOCK) - clock = dhp; + LoL->clock = dhp; return FALSE; } @@ -681,7 +660,7 @@ void CheckContinueBootFromHarddisk(void) if (InitKernelConfig.BootHarddiskSeconds == 0) return; - if (BootDrive >= 3) + if (LoL->BootDrive >= 3) { if (!EmulatedDriveStatus(0x80,1)) { From 0abf2824ef48e59aae6693278e91f4caff5e1f7e Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sun, 15 Jun 2003 16:21:26 +0000 Subject: [PATCH 205/671] Avoid relocations in the .asm files. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@593 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/dosidle.asm | 6 ++---- kernel/entry.asm | 14 +++++++------- kernel/int2f.asm | 12 ++++++------ kernel/io.asm | 10 ++-------- kernel/nlssupt.asm | 8 +++----- kernel/procsupt.asm | 8 +++----- 6 files changed, 23 insertions(+), 35 deletions(-) diff --git a/kernel/dosidle.asm b/kernel/dosidle.asm index e0e4cab3..aa5326d6 100644 --- a/kernel/dosidle.asm +++ b/kernel/dosidle.asm @@ -41,14 +41,12 @@ segment HMA_TEXT extern _MachineId:wrt DGROUP extern critical_sp:wrt DGROUP extern _user_r:wrt DGROUP + extern _DGROUP_:wrt HMA_TEXT ; ; _DosIdle_int: push ds - push ax - mov ax, DGROUP - mov ds,ax - pop ax + mov ds, [cs:_DGROUP_] cmp byte [_InDOS],1 ja DosId1 call Do_DosI diff --git a/kernel/entry.asm b/kernel/entry.asm index 45b353f8..e33ccaad 100644 --- a/kernel/entry.asm +++ b/kernel/entry.asm @@ -32,9 +32,9 @@ %include "stacks.inc" segment HMA_TEXT - extern _int21_syscall:wrt TGROUP - extern _int21_service:wrt TGROUP - extern _int2526_handler:wrt TGROUP + extern _int21_syscall + extern _int21_service + extern _int2526_handler extern _error_tos:wrt DGROUP extern _char_api_tos:wrt DGROUP extern _disk_api_tos:wrt DGROUP @@ -50,6 +50,7 @@ segment HMA_TEXT extern _Int21AX:wrt DGROUP + extern _DGROUP_ global reloc_call_cpm_entry global reloc_call_int20_handler @@ -58,7 +59,6 @@ segment HMA_TEXT global reloc_call_low_int26_handler global reloc_call_int27_handler - ; ; MS-DOS CP/M style entry point ; @@ -229,7 +229,7 @@ reloc_call_int21_handler: ; until later when which stack to run on is determined. ; int21_reentry: - mov dx,DGROUP + mov dx,[cs:_DGROUP_] mov ds,dx cmp ah,33h @@ -426,7 +426,7 @@ int2526: mov dx, ss cld - mov bx, DGROUP + mov bx, [cs:_DGROUP_] mov ds, bx ; setup our local stack @@ -557,7 +557,7 @@ CritErr05: ; cld cli - mov bp, DGROUP + mov bp, [cs:_DGROUP_] mov ds,bp mov ss,bp mov sp,[critical_sp] diff --git a/kernel/int2f.asm b/kernel/int2f.asm index 7d1c1522..f89295f5 100644 --- a/kernel/int2f.asm +++ b/kernel/int2f.asm @@ -33,7 +33,9 @@ segment HMA_TEXT extern _cu_psp:wrt DGROUP - extern _syscall_MUX14:wrt HMA_TEXT + extern _syscall_MUX14 + + extern _DGROUP_ global reloc_call_int2f_handler reloc_call_int2f_handler: @@ -94,8 +96,7 @@ DriverSysCal: extern _Dyn:wrt DGROUP cmp al, 3 jne Int2f?iret - mov di, seg _Dyn - mov ds, di + mov ds, [cs:_DGROUP_] mov di, _Dyn+2 jmp short Int2f?iret @@ -134,9 +135,8 @@ IntDosCal: %endif %endif - mov ax,DGROUP - mov ds,ax - extern _int2F_12_handler:wrt TGROUP + mov ds,[cs:_DGROUP_] + extern _int2F_12_handler call _int2F_12_handler %IFDEF I386 diff --git a/kernel/io.asm b/kernel/io.asm index e50f7981..662d753a 100644 --- a/kernel/io.asm +++ b/kernel/io.asm @@ -381,10 +381,7 @@ DiskIntrEntry: push ds push bx mov bp,sp - push ax - mov ax,DGROUP - mov ds,ax - pop ax + mov ds,[cs:_TEXT_DGROUP] cld call word [cs:si+1] pop cx @@ -405,10 +402,7 @@ AsmType: mov al,[bx+unit] xchg di,ax les di,[bx+trans] - push ax - mov ax, DGROUP - mov ds,ax - pop ax + mov ds,[cs:_TEXT_DGROUP] cld jmp word [cs:si+1] diff --git a/kernel/nlssupt.asm b/kernel/nlssupt.asm index d41d2570..233ea65f 100644 --- a/kernel/nlssupt.asm +++ b/kernel/nlssupt.asm @@ -32,7 +32,8 @@ segment HMA_TEXT global _reloc_call_CharMapSrvc - extern _DosUpChar:wrt TGROUP + extern _DosUpChar + extern _DGROUP_ ; ; CharMapSrvc: ; User callable character mapping service. @@ -51,10 +52,7 @@ _reloc_call_CharMapSrvc: push bx push ax ; arg of _upChar -; push ax - mov ax,DGROUP - mov ds, ax -; pop ax + mov ds,[cs:_DGROUP_] call _DosUpChar ;add sp, byte 2 // next POP retrieves orig AX diff --git a/kernel/procsupt.asm b/kernel/procsupt.asm index fc02bb90..ecf25b7d 100644 --- a/kernel/procsupt.asm +++ b/kernel/procsupt.asm @@ -40,7 +40,7 @@ segment HMA_TEXT - extern _DGROUP_:wrt LGROUP + extern _DGROUP_ ; ; Special call for switching processes @@ -123,8 +123,7 @@ segment HMA_TEXT _spawn_int23: ;; 1999/03/27 ska - comments: see cmt1.txt - mov ax, DGROUP ;; Make sure DS is OK - mov ds, ax + mov ds, [cs:_DGROUP_] ;; Make sure DS is OK ; restore to user stack cli ;; Pre-8086 don't disable INT autom. @@ -248,8 +247,7 @@ _spawn_int23: ;; AH value, which is passed to the _respawn_ call ;; into 0, which is "Terminate program". push ds ;; we need DGROUP - mov bp, DGROUP - mov ds, bp + mov ds, [cs:_DGROUP_] inc byte [_break_flg] pop ds From fc294ddce9d387acb93d90681c5ddc44afa47d0f Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sun, 15 Jun 2003 16:40:15 +0000 Subject: [PATCH 206/671] Remove some duplicates in globals.h git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@594 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/globals.h | 27 ++++++++------------------- 1 file changed, 8 insertions(+), 19 deletions(-) diff --git a/kernel/globals.h b/kernel/globals.h index 2ec43b74..b67a8c5f 100644 --- a/kernel/globals.h +++ b/kernel/globals.h @@ -178,20 +178,10 @@ extern struct ClockRecord /* */ /* Global variables */ /* */ -GLOBAL BYTE os_major, /* major version number */ +extern BYTE os_major, /* major version number */ os_minor, /* minor version number */ - rev_number /* minor version number */ -#ifdef MAIN - = REV_NUMBER, -#else - , -#endif - version_flags /* minor version number */ -#ifdef MAIN - = 0; -#else - ; -#endif + rev_number, /* minor version number */ + version_flags; /* minor version number */ #ifdef DEBUG GLOBAL WORD bDumpRegs @@ -313,9 +303,9 @@ extern BYTE ASM default_drive; /* default drive for dos */ extern dmatch ASM sda_tmp_dm; /* Temporary directory match buffer */ extern BYTE - FAR ASM internal_data[], /* sda areas */ - FAR ASM swap_always[], /* " " */ - FAR ASM swap_indos[], /* " " */ + ASM internal_data[], /* sda areas */ + ASM swap_always[], /* " " */ + ASM swap_indos[], /* " " */ ASM tsr, /* true if program is TSR */ ASM break_flg, /* true if break was detected */ ASM break_ena; /* break enabled flag */ @@ -354,9 +344,8 @@ GLOBAL WORD dump_regs; /* dump registers of bad call */ #endif -GLOBAL f_node_ptr f_nodes; /* pointer to the array */ - -GLOBAL UWORD f_nodes_cnt; /* number of allocated f_nodes */ +extern f_node_ptr f_nodes; /* pointer to the array */ +extern UWORD f_nodes_cnt; /* number of allocated f_nodes */ /* */ /* Function prototypes - automatically generated */ From 542b0c1b892b04175a78b4ac60346e5a09875bc0 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sun, 15 Jun 2003 18:15:06 +0000 Subject: [PATCH 207/671] Correct shr/jcxz sequence. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@595 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/asmsupt.asm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/asmsupt.asm b/kernel/asmsupt.asm index 0be40242..eea2c7bb 100644 --- a/kernel/asmsupt.asm +++ b/kernel/asmsupt.asm @@ -118,8 +118,8 @@ MEMCPY: domemcpy: ; And do the built-in byte copy, but do a 16-bit transfer ; whenever possible. - shr cx,1 jcxz memcpy_return + shr cx,1 rep movsw jnc memcpy_return movsb @@ -183,8 +183,8 @@ FMEMSET: domemset: mov ah, al - shr cx,1 jcxz pascal_return + shr cx,1 rep stosw jnc pascal_return stosb From 056fded527d76fa4a4a431c0b480a2140310a816 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sun, 15 Jun 2003 18:40:03 +0000 Subject: [PATCH 208/671] Eliminate relocations in initdisk.c + dyninit.c. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@596 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/dsk.c | 12 +++++------- kernel/dyninit.c | 23 ++++++++++++++--------- kernel/initdisk.c | 14 +++++++------- 3 files changed, 26 insertions(+), 23 deletions(-) diff --git a/kernel/dsk.c b/kernel/dsk.c index d7d4c10c..78aee3ae 100644 --- a/kernel/dsk.c +++ b/kernel/dsk.c @@ -123,8 +123,6 @@ STATIC BOOL tdelay(ddt *pddt, ULONG ticks) #define N_PART 4 /* number of partitions per table partition */ -COUNT nUnits; /* number of returned units */ - #define PARTOFF 0x1be #ifdef PROTO @@ -187,7 +185,7 @@ static dsk_proc * const dispatch[NENTRY] = COUNT ASMCFUNC FAR blk_driver(rqptr rp) { - if (rp->r_unit >= nUnits && rp->r_command != C_INIT) + if (rp->r_unit >= blk_dev.dh_name[0] && rp->r_command != C_INIT) return failure(E_UNIT); if (rp->r_command > NENTRY) { @@ -207,14 +205,14 @@ STATIC WORD play_dj(ddt * pddt) { int i; ddt *pddt2 = getddt(0); - for (i = 0; i < nUnits; i++, pddt2++) + for (i = 0; i < blk_dev.dh_name[0]; i++, pddt2++) { if (pddt->ddt_driveno == pddt2->ddt_driveno && (pddt2->ddt_descflags & (DF_MULTLOG | DF_CURLOG)) == (DF_MULTLOG | DF_CURLOG)) break; } - if (i == nUnits) + if (i == blk_dev.dh_name[0]) { put_string("Error in the DJ mechanism!\n"); /* should not happen! */ return M_CHANGED; @@ -314,7 +312,7 @@ STATIC WORD Getlogdev(rqptr rp, ddt * pddt) return S_DONE; } - for (i = 0; i < nUnits; i++, pddt2++) + for (i = 0; i < blk_dev.dh_name[0]; i++, pddt2++) { if (pddt->ddt_driveno == pddt2->ddt_driveno && (pddt2->ddt_descflags & (DF_MULTLOG | DF_CURLOG)) == @@ -336,7 +334,7 @@ STATIC WORD Setlogdev(rqptr rp, ddt * pddt) return S_DONE; } - for (i = 0; i < nUnits; i++, pddt2++) + for (i = 0; i < blk_dev.dh_name[0]; i++, pddt2++) { if (pddt->ddt_driveno == pddt2->ddt_driveno && (pddt2->ddt_descflags & (DF_MULTLOG | DF_CURLOG)) == diff --git a/kernel/dyninit.c b/kernel/dyninit.c index 94aebd0e..417488d4 100644 --- a/kernel/dyninit.c +++ b/kernel/dyninit.c @@ -38,6 +38,7 @@ kernel layout: #include "portab.h" #include "init-mod.h" #include "dyndata.h" +#include "lol.h" #if defined(DEBUG) #define DebugPrintf(x) printf x @@ -58,37 +59,41 @@ void far *DynAlloc(char *what, unsigned num, unsigned size) { void far *now; unsigned total = num * size; + struct DynS far *Dynp = MK_FP(FP_SEG(LoL), FP_OFF(&Dyn)); + #ifndef DEBUG UNREFERENCED_PARAMETER(what); #endif - if ((ULONG) total + Dyn.Allocated > 0xffff) + if ((ULONG) total + Dynp->Allocated > 0xffff) { - printf("PANIC:Dyn %lu\n", (ULONG) total + Dyn.Allocated); + printf("PANIC:Dyn %lu\n", (ULONG) total + Dynp->Allocated); for (;;) ; } DebugPrintf(("DYNDATA:allocating %s - %u * %u bytes, total %u, %u..%u\n", - what, num, size, total, Dyn.Allocated, - Dyn.Allocated + total)); + what, num, size, total, Dynp->Allocated, + Dynp->Allocated + total)); - now = (void far *)&Dyn.Buffer[Dyn.Allocated]; + now = (void far *)&Dynp->Buffer[Dynp->Allocated]; fmemset(now, 0, total); - Dyn.Allocated += total; + Dynp->Allocated += total; return now; } void DynFree(void *ptr) { - Dyn.Allocated = (char *)ptr - (char *)Dyn.Buffer; + struct DynS far *Dynp = MK_FP(FP_SEG(LoL), FP_OFF(&Dyn)); + Dynp->Allocated = (char *)ptr - (char *)Dynp->Buffer; } void FAR * DynLast() { + struct DynS far *Dynp = MK_FP(FP_SEG(LoL), FP_OFF(&Dyn)); DebugPrintf(("dynamic data end at %p\n", - (void FAR *)(Dyn.Buffer + Dyn.Allocated))); + (void FAR *)(Dynp->Buffer + Dynp->Allocated))); - return Dyn.Buffer + Dyn.Allocated; + return Dynp->Buffer + Dynp->Allocated; } diff --git a/kernel/initdisk.c b/kernel/initdisk.c index 5fc43f31..534101ef 100644 --- a/kernel/initdisk.c +++ b/kernel/initdisk.c @@ -33,12 +33,12 @@ static BYTE *dskRcsId = "$Id$"; #endif +UBYTE InitDiskTransferBuffer[SEC_SIZE]; +COUNT nUnits; + /* data shared between DSK.C and INITDISK.C */ -extern UBYTE DOSFAR DiskTransferBuffer[1 * SEC_SIZE]; - -extern COUNT DOSFAR nUnits; extern UWORD DOSFAR LBA_WRITE_VERIFY; @@ -766,7 +766,7 @@ int LBA_Get_Drive_Parameters(int drive, struct DriveParamS *driveParam) */ BOOL ConvPartTableEntryToIntern(struct PartTableEntry * pEntry, - UBYTE FAR * pDisk) + UBYTE * pDisk) { int i; @@ -948,7 +948,7 @@ BOOL ScanForPrimaryPartitions(struct DriveParamS * driveParam, int scan_type, void BIOS_drive_reset(unsigned drive); int Read1LBASector(struct DriveParamS *driveParam, unsigned drive, - ULONG LBA_address, void FAR * buffer) + ULONG LBA_address, void * buffer) { static struct _bios_LBA_address_packet dap = { 16, 0, 0, 0, 0, 0, 0 @@ -1051,14 +1051,14 @@ int ProcessDisk(int scanType, unsigned drive, int PartitionsToIgnore) strange_restart: if (Read1LBASector - (&driveParam, drive, RelSectorOffset, DiskTransferBuffer)) + (&driveParam, drive, RelSectorOffset, InitDiskTransferBuffer)) { printf("Error reading partition table drive %02x sector %lu", drive, RelSectorOffset); return PartitionsToIgnore; } - if (!ConvPartTableEntryToIntern(PTable, DiskTransferBuffer)) + if (!ConvPartTableEntryToIntern(PTable, InitDiskTransferBuffer)) { /* there is some strange hardware out in the world, which returns OK on first read, but the data are From f83c09df154b3da55951d775d7c7d5ee2b284040 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sun, 15 Jun 2003 18:47:25 +0000 Subject: [PATCH 209/671] Fix problem with volume label findnexts. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@597 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/fatdir.c | 33 ++++++++++++--------------------- 1 file changed, 12 insertions(+), 21 deletions(-) diff --git a/kernel/fatdir.c b/kernel/fatdir.c index e76a413c..6acdfc9e 100644 --- a/kernel/fatdir.c +++ b/kernel/fatdir.c @@ -423,7 +423,7 @@ COUNT dos_findfirst(UCOUNT attr, BYTE * name) /* directory and only searched for once. So we need to open */ /* the root and return only the first entry that contains the */ /* volume id bit set. */ - if (attr & D_VOLID) + if ((attr & (D_VOLID|D_DIR))==D_VOLID) i = 3; /* Now open this directory so that we can read the */ /* fnode entry and do a match on it. */ @@ -445,7 +445,7 @@ COUNT dos_findfirst(UCOUNT attr, BYTE * name) /* Copy the raw pattern from our data segment to the DTA. */ fmemcpy(dmp->dm_name_pat, SearchDir.dir_name, FNAME_SIZE + FEXT_SIZE); - if (attr & D_VOLID) + if ((attr & (D_VOLID|D_DIR))==D_VOLID) { /* Now do the search */ while (dir_read(fnp) == 1) @@ -494,7 +494,6 @@ COUNT dos_findfirst(UCOUNT attr, BYTE * name) COUNT dos_findnext(void) { REG f_node_ptr fnp; - BOOL found = FALSE; REG dmatch *dmp = &sda_tmp_dm; /* Allocate an fnode if possible - error return (0) if not. */ @@ -521,16 +520,12 @@ COUNT dos_findnext(void) /* Search through the directory to find the entry, but do a */ /* seek first. */ + fnp->f_flags.f_dnew = TRUE; if (dmp->dm_entry > 0) { fnp->f_diroff = (ULONG) (dmp->dm_entry - 1) * DIRENT_SIZE; fnp->f_flags.f_dnew = FALSE; } - else - { - fnp->f_diroff = 0; - fnp->f_flags.f_dnew = TRUE; - } /* Loop through the directory */ while (dir_read(fnp) == 1) @@ -550,24 +545,20 @@ COUNT dos_findnext(void) /* Test the attribute as the final step */ if (!(fnp->f_dir.dir_attrib & D_VOLID) && - ((~dmp->dm_attr_srch & fnp->f_dir. - dir_attrib & (D_DIR | D_SYSTEM | D_HIDDEN)) == 0)) + !(~dmp->dm_attr_srch & (D_DIR | D_SYSTEM | D_HIDDEN) & + fnp->f_dir.dir_attrib)) { - found = TRUE; - break; + /* If found, transfer it to the dmatch structure */ + dmp->dm_dircluster = fnp->f_dirstart; + memcpy(&SearchDir, &fnp->f_dir, sizeof(struct dirent)); + /* return the result */ + release_f_node(fnp); + return SUCCESS; } - else - continue; } } } - /* If found, transfer it to the dmatch structure */ - if (found) - { - dmp->dm_dircluster = fnp->f_dirstart; - memcpy(&SearchDir, &fnp->f_dir, sizeof(struct dirent)); - } #ifdef DEBUG printf("dos_findnext: %11s\n", fnp->f_dir.dir_name); @@ -575,7 +566,7 @@ COUNT dos_findnext(void) /* return the result */ release_f_node(fnp); - return found ? SUCCESS : DE_NFILES; + return DE_NFILES; } #endif /* From bdc63c1ff08f0ee1f11ece243445349c0d9d8c45 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sun, 15 Jun 2003 18:57:02 +0000 Subject: [PATCH 210/671] Fixes from Lixing Yuan: dosnames cleanup, fix for truename with wildcards and trailing dots. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@598 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/dosnames.c | 2 -- kernel/newstuff.c | 4 +++- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/kernel/dosnames.c b/kernel/dosnames.c index 9fa11084..18e27358 100644 --- a/kernel/dosnames.c +++ b/kernel/dosnames.c @@ -116,8 +116,6 @@ int ParseDosName(const char *filename, char *fcbname, BOOL bAllowWildcards) { if (*filename != '\0') return DE_FILENOTFND; - if (nDirCnt == 1) /* for d:\ */ - return DE_NFILES; memset(fcbname, '?', FNAME_SIZE + FEXT_SIZE); return nDirCnt; } diff --git a/kernel/newstuff.c b/kernel/newstuff.c index 789bfd15..72191779 100644 --- a/kernel/newstuff.c +++ b/kernel/newstuff.c @@ -518,8 +518,10 @@ COUNT truename(const char FAR * src, char * dest, COUNT mode) if (i & PNE_WILDCARD) gotAnyWildcards = TRUE; /* strip trailing dot */ - if ((i & PNE_DOT) && *src != '/' && *src != '\\' && *src != '\0') + if ((i & PNE_DOT) && *src != '/' && *src != '\\') { + if (*src == '\0') + continue; /* we arrive here only when an extension-dot has been found */ addChar('.'); i = parse_name_ext(FEXT_SIZE, &src, &p, dest); From 1c5db2e4823726a9824a1f496b5c5dbbd6e53712 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sun, 15 Jun 2003 19:00:39 +0000 Subject: [PATCH 211/671] Small size optimization. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@599 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/fcbfns.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/kernel/fcbfns.c b/kernel/fcbfns.c index 7ea27f27..6942b133 100644 --- a/kernel/fcbfns.c +++ b/kernel/fcbfns.c @@ -451,6 +451,7 @@ int FcbNameInit(fcb FAR * lpFcb, BYTE * szBuffer, COUNT * pCurDrive) BYTE *pszBuffer = loc_szBuffer; /* Build a traditional DOS file name */ + *pCurDrive = default_drive + 1; if (lpFcb->fcb_drive != 0) { *pCurDrive = lpFcb->fcb_drive; @@ -458,10 +459,6 @@ int FcbNameInit(fcb FAR * lpFcb, BYTE * szBuffer, COUNT * pCurDrive) pszBuffer[1] = ':'; pszBuffer += 2; } - else - { - *pCurDrive = default_drive + 1; - } ConvertName83ToNameSZ(pszBuffer, lpFcb->fcb_fname); return truename(loc_szBuffer, szBuffer, CDS_MODE_CHECK_DEV_PATH|CDS_MODE_ALLOW_WILDCARDS); } From 123adb9145f63eb1f2a6f7608167135b060f4de4 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sun, 15 Jun 2003 19:05:43 +0000 Subject: [PATCH 212/671] Force "for" to be executed by command.com to work around broken "make" utilities. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@600 6ac86273-5f31-0410-b378-82cca8765d1b --- lib/makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/makefile b/lib/makefile index 6eaa3d39..b19c19c7 100644 --- a/lib/makefile +++ b/lib/makefile @@ -11,7 +11,7 @@ libm.lib: $(CLIB) -$(RM) libm.lib $(LIBUTIL) $(CLIB) $(MATH_EXTRACT) $(LIBTERM) - for %i in (*.obj) do ..\utils\patchobj CODE=LCODE %i + $(COMSPEC) /c for %i in (*.obj) do ..\utils\patchobj CODE=LCODE %i $(LIBUTIL) libm $(MATH_INSERT) $(LIBTERM) -$(RM) *.OBJ From faaff5006a3586640b9752010ca47cc949e31f14 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sun, 15 Jun 2003 19:26:49 +0000 Subject: [PATCH 213/671] + Changes Eric Auer * add sanity check to initdisk.c for (driveParam->chs.Sector == 0) + some display tweaks * add ANYDOS, KBDRATE, VIDMODE, MENUCOLOR and EECHO support to the config.sys parser. * distinguish between the builtin DOS version and the settable DOS version. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@601 6ac86273-5f31-0410-b378-82cca8765d1b --- docs/history.txt | 30 ++++++-- hdr/lol.h | 16 ++-- kernel/config.c | 183 ++++++++++++++++++++++++++++++++++++++++++++-- kernel/globals.h | 4 +- kernel/initdisk.c | 17 +++-- kernel/inthndlr.c | 14 +++- kernel/kernel.asm | 4 + kernel/main.c | 4 +- 8 files changed, 239 insertions(+), 33 deletions(-) diff --git a/docs/history.txt b/docs/history.txt index 1c1b88ff..28d29ef2 100644 --- a/docs/history.txt +++ b/docs/history.txt @@ -1,10 +1,20 @@ 2003 Jun xx - Build 2030 -------- Bart Oldeman (bart@dosemu.org) + Changes Tom -if user left accidentally floppy or CD in drive, -give him a chance to continue to boot from HD. -disabled by default, enablable by SYS CONFIG - + * if user left accidentally floppy or CD in drive, + give him a chance to continue to boot from HD. + disabled by default, enablable by SYS CONFIG + (BOOTHARDDISKSECONDS) ++ Changes Lixing Yuan + * dosnames.c cleanup, fix for truename if the filename + contains wildcards and a trailing dot. ++ Changes Eric Auer + * add sanity check to initdisk.c for (driveParam->chs.Sector == 0) + + some display tweaks + * add ANYDOS, KBDRATE, VIDMODE, MENUCOLOR and EECHO support to the + config.sys parser. + * distinguish between the builtin DOS version and the settable + DOS version. + Changes Bart * flip some slashes in drivers/*.asm (enables cross-assembly on Linux) @@ -23,9 +33,15 @@ disabled by default, enablable by SYS CONFIG the final allocation takes place. * handle multiple UMBs more correctly (but config.sys can use only one UMB for devicehigh -- /Ln,xxxx is not yet implemented) - * minor size optimizations in chario.c, dosfns.c; - asmsupt.asm: correct fmemchr (all n's) and *memset/*memcpy (n==0) - 185 relocs, 54 not shown + * minor size optimizations in newstuff.c, chario.c, dosfns.c and fcbfns.c. + asmsupt.asm: correct fmemchr (all n's) and *memset/*memcpy + (n==0) + * introduce lol structure for list of lists; avoid lots of + relocations + * avoid more relocations in the asm files by loading ds from + [cs:_DGROUP_] + * Fix problem with attributes with the volume label bit + findnext + * 2003 Mar 14 - Build 2029 -------- Bart Oldeman (bart@dosemu.org) + Changes Tom diff --git a/hdr/lol.h b/hdr/lol.h index eac928ed..97f75d74 100644 --- a/hdr/lol.h +++ b/hdr/lol.h @@ -72,11 +72,13 @@ struct lol { unsigned short uppermem_root;/* 66 Start of umb chain (usually 9fff) */ unsigned short last_para; /* 68 para: start scanning during memalloc */ /* FreeDOS specific entries */ - unsigned char os_minor; /* 6a minor DOS version */ - unsigned char os_major; /* 6b major DOS version */ - unsigned char rev_number; /* 6c minor DOS version */ - unsigned char version_flags; /* 6d DOS version flags */ - f_node_ptr f_nodes; /* 6e pointer to the array */ - unsigned short f_nodes_cnt; /* 70 number of allocated f_nodes */ - char *os_release; /* 72 near pointer to os_release string */ + unsigned char os_setver_minor;/*6a settable minor DOS version */ + unsigned char os_setver_major;/*6b settable major DOS version */ + unsigned char os_minor; /* 6c minor DOS version */ + unsigned char os_major; /* 6d major DOS version */ + unsigned char rev_number; /* 6e minor DOS version */ + unsigned char version_flags; /* 6f DOS version flags */ + f_node_ptr f_nodes; /* 70 pointer to the array */ + unsigned short f_nodes_cnt; /* 72 number of allocated f_nodes */ + char *os_release; /* 74 near pointer to os_release string */ }; diff --git a/kernel/config.c b/kernel/config.c index a78f21a6..5147af09 100644 --- a/kernel/config.c +++ b/kernel/config.c @@ -144,6 +144,9 @@ STATIC VOID CfgSwitchar(BYTE * pLine); STATIC VOID CfgFailure(BYTE * pLine); STATIC VOID CfgIgnore(BYTE * pLine); STATIC VOID CfgMenu(BYTE * pLine); + +STATIC VOID CfgMenuEsc(BYTE * pLine); + STATIC VOID DoMenu(void); STATIC VOID CfgMenuDefault(BYTE * pLine); STATIC BYTE * skipwh(BYTE * s); @@ -159,6 +162,12 @@ STATIC VOID mumcb_init(UCOUNT seg, UWORD size); STATIC VOID Stacks(BYTE * pLine); STATIC VOID StacksHigh(BYTE * pLine); + +STATIC VOID sysKbdRate(BYTE * pLine); +STATIC VOID sysKbdBuf(BYTE * pLine); +STATIC VOID sysVidMode(BYTE * pLine); +STATIC VOID sysMenuColor(BYTE * pLine); + STATIC VOID SetAnyDos(BYTE * pLine); STATIC VOID Numlock(BYTE * pLine); STATIC BYTE * GetNumArg(BYTE * pLine, COUNT * pnArg); @@ -218,9 +227,13 @@ STATIC struct table commands[] = { {"STACKS", 1, Stacks}, {"STACKSHIGH", 1, StacksHigh}, {"SWITCHAR", 1, CfgSwitchar}, - {"SCREEN", 1, sysScreenMode}, /* JPP */ - {"VERSION", 1, sysVersion}, /* JPP */ - {"ANYDOS", 1, SetAnyDos}, /* tom */ + {"SCREEN", 1, sysScreenMode}, /* JPP */ + {"VERSION", 1, sysVersion}, /* JPP */ + {"ANYDOS", 1, SetAnyDos}, /* tom */ + {"KBDRATE", 1, sysKbdRate}, /* ea */ + {"KBDBUF", 1, sysKbdBuf}, /* ea */ + {"VIDMODE", 1, sysVidMode}, /* ea */ + {"MENUCOLOR", 1, sysMenuColor}, /* ea */ {"DEVICE", 2, Device}, {"DEVICEHIGH", 2, DeviceHigh}, @@ -637,10 +650,10 @@ VOID DoConfig(int pass) continue; } - if (pEntry->func != CfgMenu) + if ((pEntry->func != CfgMenu) && (pEntry->func != CfgMenuEsc)) pLine = skipwh(pLine); - if ('=' != *pLine && pEntry->func != CfgMenu) + if ('=' != *pLine && pEntry->func != CfgMenu && pEntry->func != CfgMenuEsc) CfgFailure(pLine); else /* YES. DO IT */ (*(pEntry->func)) (skipwh(pLine + 1)); @@ -1122,6 +1135,148 @@ STATIC VOID StacksHigh(BYTE * pLine) Config.cfgStacksHigh = 1; } +STATIC VOID sysKbdRate(BYTE * pLine) +{ + COUNT krate = 16; /* default: medium rate */ + COUNT kdelay = 3; /* default: maximum delay */ + + /* Format: KBDRATE = ratecode [, delay] */ + pLine = GetNumArg(pLine, &krate); + + pLine = skipwh(pLine); + + if (*pLine == ',') + GetNumArg(++pLine, &kdelay); + + if (krate < 0 || krate > 31 || kdelay < 0 || kdelay > 3) { + printf("KBDRATE arguments must be 0..31, 0..3 for rate, delay\n"); + CfgFailure(pLine); + return; + } + + /* could check if int 16.9 returns AL and 4 NZ before setting rates */ + +#if defined(__TURBOC__) + _AX = 0x0305; + _BH = kdelay; + _BL = krate; + __int__(0x16); +#elif defined(I86) + asm + { + mov ax, 0x0305; + mov bh, byte ptr kdelay; + mov bl, byte ptr krate; + int 0x16; + } +#endif + + printf("Set keyboard repeat rate=%d (0=fastest, 31=slowest), delay=%d\n", + krate, kdelay); +} + +STATIC VOID sysKbdBuf(BYTE * pLine) +{ + COUNT kbuf1 = 0xb0; /* default - okay if no EDD/... BIOS */ + COUNT kbuf2 = 0xfe; /* default - end of BIOS data */ + WORD FAR *kbufstart = MK_FP(0x40, 0x80); + WORD FAR *kbufend = MK_FP(0x40, 0x82); + WORD FAR *kbufptr1 = MK_FP(0x40, 0x1a); + WORD FAR *kbufptr2 = MK_FP(0x40, 0x1c); + + /* Format: KBDBUF = start [, end] */ + pLine = GetNumArg(pLine, &kbuf1); + + pLine = skipwh(pLine); + + if (*pLine == ',') + GetNumArg(++pLine, &kbuf2); + kbuf1 &= 0xfffe; + kbuf2 &= 0xfffe; + + if ((kbuf1 >= kbuf2) || (kbuf1 < 0xac) || (kbuf2 > 0xfe)) { + printf("KBDBUF start [, end] must be in BIOS data, not %x..%x\n", + kbuf1, kbuf2); + CfgFailure(pLine); + return; + } + + printf("KBDBUF: setting buffer to 0x40:%2x..%2x\n", kbuf1, kbuf2); + /* CLI !? */ + kbufstart[0] = kbufptr1[0] = kbufptr2[0] = kbuf1; + kbufend[0] = kbuf2; + /* STI !? */ +} + +STATIC VOID sysVidMode(BYTE * pLine) +{ + COUNT vmode = 3; /* default: 80x25 */ + + /* Format: VIDMODE = modenumber */ + pLine = GetNumArg(pLine, &vmode); + + if (vmode < 0 || vmode > 0x10c || (vmode < 0x108 && vmode >= 0x100)) { + printf("VIDMODE argument must be 0..0xff or 0x108..0x10c\n"); + /* 0x108..0x10c are normal VESA text modes. */ + /* 0..0xff are all kinds of normal video modes, no sanity checks! */ + CfgFailure(pLine); + return; + } + + if (vmode < 0x100) { +#if defined(__TURBOC__) + _AX = 0x0000 + vmode; /* CLASSIC video mode set */ + __int__(0x10); +#elif defined(I86) + asm + { + mov ah, 0; + mov al, byte ptr vmode + int 0x10; + } +#endif + } else { +#if defined(__TURBOC__) + _AX = 0x4f02; /* VESA video mode set */ + _BX = vmode; + __int__(0x10); /* if AL not 4f now, no VESA. if AH 1 now, failed */ +#elif defined(I86) + asm + { + mov ax, 0x4f02; + mov bx, word ptr vmode + int 0x10; + } +#endif + } + printf("Set video mode to %x (0x1??: VESA 0x0?? normal)\n", vmode); +} + +STATIC VOID sysMenuColor(BYTE * pLine) +{ + COUNT fgcolor = 7; /* default grey */ + COUNT bgcolor = 0; /* default black */ + + /* Format: MENUCOLOR = foreground [, background] */ + pLine = GetNumArg(pLine, &fgcolor); + + pLine = skipwh(pLine); + + if (*pLine == ',') + GetNumArg(++pLine, &bgcolor); + + if (fgcolor < 0 || fgcolor > 15 || bgcolor < 0 || bgcolor > 15) { + printf("MENUCOLOR fgcolor [, bgcolor] have 0..15 limit\n"); + CfgFailure(pLine); + return; + } + + printf("Not yet used: foreground=%d background=%d\n", fgcolor, bgcolor); + /* *** TODO: Either print ANSI sequence or make int 29h *** */ + /* *** use colored int 10.02/09 (not 0e)...??? or only *** */ + /* *** use int 10.2/3/8/9 loop to recolor current text *** */ +} + STATIC VOID InitPgmHigh(BYTE * pLine) { InitPgm(pLine); @@ -1470,6 +1625,7 @@ STATIC BOOL isnum(BYTE * pLine) } /* JPP - changed so will accept hex number. */ +/* ea - changed to accept hex digits in hex numbers */ STATIC BYTE * GetNumber(REG BYTE * pszString, REG COUNT * pnNum) { BYTE Base = 10; @@ -1482,15 +1638,20 @@ STATIC BYTE * GetNumber(REG BYTE * pszString, REG COUNT * pnNum) Sign = TRUE; } - while (isnum(pszString) || toupper(*pszString) == 'X') + while ( isnum(pszString) || toupper(*pszString) == 'X' || + ( Base==16 && (toupper(*pszString)<='F') && (toupper(*pszString)>='A') ) ) { if (toupper(*pszString) == 'X') { Base = 16; pszString++; } - else + else if (isnum(pszString)) { *pnNum = *pnNum * Base + (*pszString++ - '0'); + } + else { + *pnNum = *pnNum * Base + (10 + toupper(*pszString++) - 'A'); + } } if (Sign) *pnNum = -*pnNum; @@ -1692,6 +1853,14 @@ STATIC VOID CfgMenu(BYTE * pLine) printf("%s\n",pLine); } +STATIC VOID CfgMenuEsc(BYTE * pLine) +{ + BYTE * check; + for (check = pLine; check[0]; check++) + if (check[0] == '$') check[0] = 27; /* translate $ to ESC */ + printf("%s\n",pLine); +} + STATIC VOID DoMenu(void) { if (Menus == 0) diff --git a/kernel/globals.h b/kernel/globals.h index b67a8c5f..1aee9064 100644 --- a/kernel/globals.h +++ b/kernel/globals.h @@ -178,7 +178,9 @@ extern struct ClockRecord /* */ /* Global variables */ /* */ -extern BYTE os_major, /* major version number */ +extern BYTE os_setver_major, /* editable major version number */ + os_setver_minor, /* editable minor version number */ + os_major, /* major version number */ os_minor, /* minor version number */ rev_number, /* minor version number */ version_flags; /* minor version number */ diff --git a/kernel/initdisk.c b/kernel/initdisk.c index 534101ef..f8d71d92 100644 --- a/kernel/initdisk.c +++ b/kernel/initdisk.c @@ -367,6 +367,7 @@ void init_LBA_to_CHS(struct CHS *chs, ULONG LBA_address, void printCHS(char *title, struct CHS *chs) { printf("%s", title); + /* has no fixed size for head/sect: is often 1/1 in our context */ printf("%4u-%u-%u", chs->Cylinder, chs->Head, chs->Sector); } @@ -621,13 +622,13 @@ void DosDefinePartition(struct DriveParamS *driveParam, printf("\r%c: HD%d", 'A' + nUnits, (driveParam->driveno & 0x7f) + 1); if (extendedPartNo) - printf(" Ext:%d", extendedPartNo); + printf(", Ext[%2d]", extendedPartNo); else - printf(" Pri:%d", PrimaryNum + 1); + printf(", Pri[%2d]", PrimaryNum + 1); - printCHS(" CHS= ", &chs); + printCHS(", CHS= ", &chs); - printf(" start = %5luMB,size =%5lu", + printf(", start=%6lu MB, size=%6lu MB", StartSector / 2048, pEntry->NumSect / 2048); printf("\n"); @@ -704,7 +705,7 @@ int LBA_Get_Drive_Parameters(int drive, struct DriveParamS *driveParam) lba_bios_parameters.sectors > 0xffff || lba_bios_parameters.totalSectHigh != 0) { - printf("Drive is too large to handle, using only 1'st 8 GB\n" + printf("Drive is too large to handle, using only 1st 8 GB\n" " drive %02x heads %lu sectors %lu , total=0x%lx-%08lx\n", drive, (ULONG) lba_bios_parameters.heads, @@ -740,6 +741,12 @@ int LBA_Get_Drive_Parameters(int drive, struct DriveParamS *driveParam) driveParam->chs.Head = (regs.d.x >> 8) + 1; driveParam->chs.Sector = (regs.c.x & 0x3f); driveParam->chs.Cylinder = (regs.c.x >> 8) | ((regs.c.x & 0xc0) << 2); + + if (driveParam->chs.Sector == 0) { + /* happens e.g. with Bochs 1.x if no harddisk defined */ + driveParam->chs.Sector = 63; /* avoid division by zero...! */ + printf("BIOS reported 0 sectors/track, assuming 63!\n"); + } if (!driveParam->LBA_supported) { diff --git a/kernel/inthndlr.c b/kernel/inthndlr.c index 1239974c..865c043e 100644 --- a/kernel/inthndlr.c +++ b/kernel/inthndlr.c @@ -95,7 +95,7 @@ VOID ASMCFUNC int21_syscall(iregs FAR * irp) irp->DL = BootDrive; break; - /* Get DOS-C version */ + /* Get (real) DOS-C version */ case 0x06: irp->BL = os_major; irp->BH = os_minor; @@ -110,6 +110,12 @@ VOID ASMCFUNC int21_syscall(iregs FAR * irp) irp->AL = 0xff; break; + /* set FreeDOS returned version for int 21.30 from BX */ + case 0xfc: /* 0xfc ... 0xff are FreeDOS extensions */ + os_setver_major = irp->BL; + os_setver_minor = irp->BH; + break; + /* Toggle DOS-C rdwrblock trace dump */ case 0xfd: #ifdef DEBUG @@ -708,10 +714,10 @@ VOID ASMCFUNC int21_service(iregs FAR * r) lr.BX = FP_OFF(dta); break; - /* Get DOS Version */ + /* Get (editable) DOS Version */ case 0x30: - lr.AL = os_major; - lr.AH = os_minor; + lr.AL = os_setver_major; + lr.AH = os_setver_minor; lr.BH = OEM_ID; lr.CH = REVISION_MAJOR; /* JPP */ lr.CL = REVISION_MINOR; diff --git a/kernel/kernel.asm b/kernel/kernel.asm index 1d49d85f..0755dc67 100644 --- a/kernel/kernel.asm +++ b/kernel/kernel.asm @@ -335,6 +335,10 @@ _uppermem_root dw 0ffffh ; 0066 dmd_upper_root (usually 9fff) _last_para dw 0 ; 0068 para of last mem search SysVarEnd: ;; FreeDOS specific entries + global _os_setver_minor +_os_setver_minor db 0 + global _os_setver_major +_os_setver_major db 5 global _os_minor _os_minor db 0 global _os_major diff --git a/kernel/main.c b/kernel/main.c index 16ab8056..82c6fc1b 100644 --- a/kernel/main.c +++ b/kernel/main.c @@ -204,8 +204,8 @@ STATIC void init_kernel(void) { COUNT i; - LoL->os_major = MAJOR_RELEASE; - LoL->os_minor = MINOR_RELEASE; + LoL->os_setver_major = LoL->os_major = MAJOR_RELEASE; + LoL->os_setver_minor = LoL->os_minor = MINOR_RELEASE; /* Init oem hook - returns memory size in KB */ ram_top = init_oem(); From 5a5df818962b2b7e78e543dc21ef00130b4930a0 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sun, 15 Jun 2003 20:37:56 +0000 Subject: [PATCH 214/671] Support extended keyboards in console.asm git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@602 6ac86273-5f31-0410-b378-82cca8765d1b --- docs/history.txt | 1 + kernel/console.asm | 90 +++++++++++++++++++++++++++++++++++----------- 2 files changed, 71 insertions(+), 20 deletions(-) diff --git a/docs/history.txt b/docs/history.txt index 28d29ef2..15865e59 100644 --- a/docs/history.txt +++ b/docs/history.txt @@ -15,6 +15,7 @@ config.sys parser. * distinguish between the builtin DOS version and the settable DOS version. + * console.asm now accepts extended scancodes (modified by Bart) + Changes Bart * flip some slashes in drivers/*.asm (enables cross-assembly on Linux) diff --git a/kernel/console.asm b/kernel/console.asm index 234f1961..0791fa25 100644 --- a/kernel/console.asm +++ b/kernel/console.asm @@ -35,7 +35,7 @@ segment _IO_FIXED_DATA global ConTable ConTable db 0Ah - dw _IOExit + dw ConInit dw _IOExit dw _IOExit dw _IOCommandError @@ -47,13 +47,41 @@ ConTable db 0Ah dw ConWrite dw _IOExit -PRT_SCREEN equ 7200h +CTL_PRT_SCREEN equ 7200h CTL_P equ 10h segment _LOWTEXT uScanCode db 0 ; Scan code for con: device +kbdType db 0 ; 00 for 84key, 10h for 102key + +; +; (taken from nansi.sys) +; + global ConInit +ConInit: + ; Jam special test code into keyboard buffer + mov ah,5 + mov cx,0ffffh + int 16h + ; Try to read special test code from keyboard buffer + mov cx, 10h +kbdLoop: + ; Get keystroke using extended keyboard read + mov ah, 10h + int 16h + ; Is it our special test code? + cmp ax, 0ffffh + ; Yes; Set flag saying that the extended keyboard BIOS is supported + je kbdExtended + loop kbdLoop + jmp short kbdSimple +kbdExtended: + mov byte[cs:kbdType],10h +kbdSimple: + jmp _IOExit + ; ; Name: ; ConRead @@ -86,9 +114,10 @@ ConRead2: ; Read a character from the keyboard. ; ; Description: -; This subroutine reads a character fromthe keyboard. It also handles -; a couple of special functions. It converts the print screen key to -; a control-P. It also accounts for extended scan codes by saving off +; This subroutine reads a character from the keyboard. It also handles +; a couple of special functions. +; It converts ctrl-printscreen to a control-P. +; It also accounts for extended scan codes by saving off ; the high byte of the return and returning it if it was non-zero on ; the previous read. ; @@ -96,12 +125,15 @@ ConRead2: KbdRdChar: xor ax,ax ; Zero the scratch register xchg [cs:uScanCode],al ; and swap with scan code + ; now AL is set if previous key was extended, + ; and previous is erased in any case or al,al ; Test to see if it was set jnz KbdRdRtn ; Exit if it was, returning it + mov ah, [cs:kbdType] int 16h ; get keybd char in al, ah=scan or ax,ax ; Zero ? jz KbdRdChar ; Loop if it is - cmp ax,PRT_SCREEN ; Print screen? + cmp ax,CTL_PRT_SCREEN ; Ctrl-Print screen? jne KbdRd1 ; Nope, keep going mov al,CTL_P ; Yep, make it ^P KbdRd1: @@ -114,26 +146,31 @@ KbdRdRtn: global CommonNdRdExit -CommonNdRdExit: +CommonNdRdExit: ; *** tell if key waiting and return its ASCII if yes mov al,[cs:uScanCode] ; Test for last scan code + ; now AL is set if previous key was extended, or al,al ; Was it zero ? jnz ConNdRd2 ; Jump if there's a char waiting mov ah,1 + add ah,[cs:kbdType] int 16h ; Get status, if zf=0 al=char jz ConNdRd4 ; Jump if no char available or ax,ax ; Zero ? jnz ConNdRd1 ; Jump if not zero + mov ah,[cs:kbdType] int 16h ; get status, if zf=0 al=char jmp short CommonNdRdExit + ; if char was there but 0, fetch and retry... + ; (why do we check uScanCode here?) ConNdRd1: - cmp ax,PRT_SCREEN ; Was print screen key pressed? + cmp ax,CTL_PRT_SCREEN ; Was ctl+prntscrn key pressed? jne ConNdRd2 ; Jump if not mov al,CTL_P ConNdRd2: lds bx,[cs:_ReqPktPtr] ; Set the status - mov [bx+0Dh],al + mov [bx+0Dh],al ; return the ASCII of that key ConNdRd3: jmp _IOExit @@ -144,21 +181,28 @@ ConNdRd4: global ConInpFlush -ConInpFlush: - call KbdInpChar - jmp _IOExit +ConInpFlush: ; *** flush that keyboard queue + call KbdInpChar ; get all available keys + jmp _IOExit ; do not even remember the last one -KbdInpChar: - mov byte [cs:uScanCode],0 -KbdInpCh1: +KbdInpChar: ; *** get ??00 or the last waiting key after flushing the queue + xor ax,ax + mov byte [cs:uScanCode],al +KbdInpCh1: mov ah,1 + add ah,[cs:kbdType] int 16h ; get status, if zf=0 al=char - jz KbdInpRtn ; Jump if zero - xor ah,ah ; Zero register + jz KbdInpRtnZero ; Jump if zero + ; returns 0 or the last key that was waiting in AL + mov ah,[cs:kbdType] int 16h ; get keybd char in al, ah=scan jmp short KbdInpCh1 + ; just read any key that is waiting, then check if + ; more keys are waiting. if not, return AL of this + ; key (which is its ASCII). AH (scan) discarded! +KbdInpRtnZero: mov ah,1 ; if anybody wants "1 if no key was waiting"! KbdInpRtn: retn @@ -221,26 +265,32 @@ _int29_handler: ; global ConInStat ConInStat: + mov ah,0 ; just in case ... mov al,[cs:uScanCode] ; Test for last scan code or al,al ; Was it zero ? jnz ConCharReady ; Jump if there's a char waiting + ; return previously cached ext char if any mov ah,1 + add ah,[cs:kbdType] int 16h ; get status, if zf=0 al=char jz ConNoChar ; Jump if zero + ; if no key waiting, return AL=0 / "none waiting" or ax,ax ; Zero ? jnz ConIS1 ; Jump if not zero + ; if non-zero key waiting, take it + mov ah,[cs:kbdType] int 16h ; get status, if zf=0 al=char jmp short ConInStat + ; if zero key was waiting, fetch 2nd part etc. (???) ConIS1: - cmp ax,PRT_SCREEN ; Was print screen key pressed? + cmp ax,CTL_PRT_SCREEN ; Was ctl+prntscrn key pressed? jne ConIS2 ; Jump if not mov al,CTL_P - ConIS2: lds bx,[cs:_ReqPktPtr] ; Set the status - mov [bx+0Dh],al + mov [bx+0Dh],al ; return the ASCII of the key ConCharReady: jmp _IOExit ; key ready (busy=0) ConNoChar: From d56013c88586fa2a527e90976bc882f352a86396 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sun, 15 Jun 2003 22:01:45 +0000 Subject: [PATCH 215/671] BOOTONLY support for SYS git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@603 6ac86273-5f31-0410-b378-82cca8765d1b --- sys/sys.c | 209 +++++++++++++++++++++++++++++++----------------------- 1 file changed, 122 insertions(+), 87 deletions(-) diff --git a/sys/sys.c b/sys/sys.c index 2c69d097..0538c06f 100644 --- a/sys/sys.c +++ b/sys/sys.c @@ -28,7 +28,6 @@ /* TE thinks, that the boot info storage should be done by FORMAT, noone else - unfortunately, that doesn't work ??? */ #define STORE_BOOT_INFO @@ -64,8 +63,11 @@ extern WORD CDECL sprintf(BYTE * buff, CONST BYTE * fmt, ...); #endif #ifndef __WATCOMC__ + #include + #else + int unlink(const char *pathname); /* some non-conforming functions to make the executable smaller */ int open(const char *pathname, int flags, ...) @@ -105,6 +107,26 @@ int stat(const char *file_name, struct stat *buf) return _dos_findfirst(file_name, _A_NORMAL | _A_HIDDEN | _A_SYSTEM, &find_tbuf); } #endif +char *getenv(const char *name) +{ + char **envp, *ep; + const char *np; + char ec, nc; + + for (envp = environ; (ep = *envp) != NULL; envp++) { + np = name; + do { + ec = *ep++; + nc = *np++; + if (nc == 0) { + if (ec == '=') + return ep; + break; + } + } while (ec == nc); + } + return NULL; +} BYTE pgm[] = "SYS"; @@ -238,15 +260,17 @@ int main(int argc, char **argv) if (drivearg == 0) { - printf("Usage: %s [source] drive: [bootsect [BOTH]]\n", pgm); + printf("Usage: %s [source] drive: [bootsect [BOTH|BOOTONLY]]\n", pgm); printf (" source = A:,B:,C:\\KERNEL\\BIN\\,etc., or current directory if not given\n"); printf(" drive = A,B,etc.\n"); printf (" bootsect = name of 512-byte boot sector file image for drive:\n"); - printf(" to write to instead of real boot sector\n"); + printf(" to write to *instead* of real boot sector\n"); + printf + (" BOTH : write to *both* the real boot sector and the image file\n"); printf - (" BOTH : write to both the real boot sector and the image file\n"); + (" BOOTONLY : do *not* copy kernel / shell, only update boot sector or image\n"); printf("%s CONFIG /help\n", pgm); exit(1); } @@ -280,43 +304,51 @@ int main(int argc, char **argv) else sprintf(rootPath, "%c:\\", 'A' + srcDrive); - if (!check_space(drive, oldboot)) + if ((argc <= drivearg + 2) + || (memicmp(argv[drivearg + 2], "BOOTONLY", 8) != 0)) { - printf("%s: Not enough space to transfer system files\n", pgm); - exit(1); - } + if (!check_space(drive, oldboot)) + { + printf("%s: Not enough space to transfer system files\n", pgm); + exit(1); + } - printf("\nCopying KERNEL.SYS...\n"); - if (!copy(drive, srcPath, rootPath, "kernel.sys")) - { - printf("\n%s: cannot copy \"KERNEL.SYS\"\n", pgm); - exit(1); - } + printf("\nCopying KERNEL.SYS...\n"); + if (!copy(drive, srcPath, rootPath, "kernel.sys")) + { + printf("\n%s: cannot copy \"KERNEL.SYS\"\n", pgm); + exit(1); + } + } /* copy kernel */ if (argc > drivearg + 1) bsFile = argv[drivearg + 1]; - + printf("\nWriting boot sector...\n"); put_boot(drive, bsFile, (argc > drivearg + 2) && memicmp(argv[drivearg + 2], "BOTH", 4) == 0); - printf("\nCopying COMMAND.COM...\n"); - if (!copy(drive, srcPath, rootPath, "COMMAND.COM")) + if ((argc <= drivearg + 2) + || (memicmp(argv[drivearg + 2], "BOOTONLY", 8) != 0)) { - char *comspec = getenv("COMSPEC"); - if (comspec != NULL) - { - printf("%s: Trying \"%s\"\n", pgm, comspec); - if (!copy(drive, comspec, NULL, "COMMAND.COM")) - comspec = NULL; - } - if (comspec == NULL) + printf("\nCopying COMMAND.COM...\n"); + if (!copy(drive, srcPath, rootPath, "COMMAND.COM")) { - printf("\n%s: cannot copy \"COMMAND.COM\"\n", pgm); - exit(1); + char *comspec = getenv("COMSPEC"); + if (comspec != NULL) + { + printf("%s: Trying \"%s\"\n", pgm, comspec); + if (!copy(drive, comspec, NULL, "COMMAND.COM")) + comspec = NULL; + } + if (comspec == NULL) + { + printf("\n%s: cannot copy \"COMMAND.COM\"\n", pgm); + exit(1); + } } - } + } /* copy shell */ printf("\nSystem transferred.\n"); return 0; @@ -351,37 +383,30 @@ VOID dump_sector(unsigned char far * sec) #endif -/* - TC absRead not functional on MSDOS 6.2, large disks - MSDOS requires int25, CX=ffff for drives > 32MB -*/ - #ifdef __WATCOMC__ -unsigned int2526readwrite(int DosDrive, void *diskReadPacket, unsigned intno); -#pragma aux int2526readwrite = \ - "mov cx, 0xffff" \ - "cmp si, 0x26" \ - "je int26" \ + +int absread(int DosDrive, int nsects, int foo, void *diskReadPacket); +#pragma aux absread = \ "int 0x25" \ - "jmp short cfltest" \ - "int26:" \ + "sbb ax, ax" \ + parm [ax] [cx] [dx] [bx] \ + modify [si di bp] \ + value [ax]; + +int abswrite(int DosDrive, int nsects, int foo, void *diskReadPacket); +#pragma aux abswrite = \ "int 0x26" \ - "cfltest:" \ - "mov ax, 0" \ - "adc ax, ax" \ - parm [ax] [bx] [si] \ - modify [cx] \ + "sbb ax, ax" \ + parm [ax] [cx] [dx] [bx] \ + modify [si di bp] \ value [ax]; fat32readwrite(int DosDrive, void *diskReadPacket, unsigned intno); #pragma aux fat32readwrite = \ "mov ax, 0x7305" \ "mov cx, 0xffff" \ - "inc dx" \ - "sub si, 0x25" \ "int 0x21" \ - "mov ax, 0" \ - "adc ax, ax" \ + "sbb ax, ax" \ parm [dx] [bx] [si] \ modify [cx dx si] \ value [ax]; @@ -397,7 +422,11 @@ void reset_drive(int DosDrive); "pop ds" \ parm [dx] \ modify [ax bx]; + #else + +#ifndef __TURBOC__ + int2526readwrite(int DosDrive, void *diskReadPacket, unsigned intno) { union REGS regs; @@ -411,36 +440,43 @@ int2526readwrite(int DosDrive, void *diskReadPacket, unsigned intno) return regs.x.cflag; } +#define absread(int DosDrive, int foo, int cx, void *diskReadPacket) \ +int2526readwrite(DosDrive, diskReadPacket, 0x25) + +#define abswrite(int DosDrive, int foo, int cx, void *diskReadPacket) \ +int2526readwrite(DosDrive, diskReadPacket, 0x26) + +#endif fat32readwrite(int DosDrive, void *diskReadPacket, unsigned intno) { union REGS regs; regs.x.ax = 0x7305; - regs.h.dl = DosDrive + 1; + regs.h.dl = DosDrive; regs.x.bx = (short)diskReadPacket; regs.x.cx = 0xffff; - regs.x.si = intno - 0x25; - int86(0x21, ®s, ®s); + regs.x.si = intno; + intdos(®s, ®s); return regs.x.cflag; -} +} /* fat32readwrite */ void reset_drive(int DosDrive) { union REGS regs; regs.h.ah = 0xd; - int86(0x21, ®s, ®s); + intdos(®s, ®s); regs.h.ah = 0x32; regs.h.dl = DosDrive + 1; - int86(0x21, ®s, ®s); -} + intdos(®s, ®s); +} /* reset_drive */ #endif int MyAbsReadWrite(int DosDrive, int count, ULONG sector, void *buffer, - unsigned intno) + int write) { struct { unsigned long sectorNumber; @@ -452,19 +488,17 @@ int MyAbsReadWrite(int DosDrive, int count, ULONG sector, void *buffer, diskReadPacket.count = count; diskReadPacket.address = buffer; - if (intno != 0x25 && intno != 0x26) - return 0xff; - - if (int2526readwrite(DosDrive, &diskReadPacket, intno)) + if ((!write && absread(DosDrive, -1, -1, &diskReadPacket) == -1) + || (write && abswrite(DosDrive, -1, -1, &diskReadPacket) == -1)) { #ifdef WITHFAT32 - return fat32readwrite(DosDrive, &diskReadPacket, intno); + return fat32readwrite(DosDrive + 1, &diskReadPacket, write); #else return 0xff; #endif } return 0; -} +} /* MyAbsReadWrite */ #ifdef __WATCOMC__ @@ -478,17 +512,13 @@ unsigned getdrivespace(COUNT drive, unsigned *total_clusters); modify [bx cx dx] \ value [ax]; -unsigned getextdrivespace(void *drivename, void *buf, unsigned buf_size); +unsigned getextdrivespace(void far *drivename, void *buf, unsigned buf_size); #pragma aux getextdrivespace = \ "mov ax, 0x7303" \ - "push ds" \ - "pop es" \ "stc" \ "int 0x21" \ - "mov ax, 0" \ - "adc ax, ax" \ - parm [dx] [di] [cx] \ - modify [es] \ + "sbb ax, ax" \ + parm [es dx] [di] [cx] \ value [ax]; #else @@ -499,10 +529,10 @@ unsigned getdrivespace(COUNT drive, unsigned *total_clusters) regs.h.ah = 0x36; /* get drive free space */ regs.h.dl = drive + 1; /* 1 = 'A',... */ - int86(0x21, ®s, ®s); + intdos(®s, ®s); *total_clusters = regs.x.dx; return regs.x.ax; -} +} /* getdrivespace */ unsigned getextdrivespace(void *drivename, void *buf, unsigned buf_size) { @@ -518,9 +548,9 @@ unsigned getextdrivespace(void *drivename, void *buf, unsigned buf_size) regs.x.cx = buf_size; - int86x(0x21, ®s, ®s, &sregs); + intdosx(®s, ®s, &sregs); return regs.x.ax == 0x7300 || regs.x.cflag; -} +} /* getextdrivespace */ #endif @@ -532,7 +562,7 @@ VOID put_boot(COUNT drive, BYTE * bsFile, BOOL both) struct bootsectortype32 *bs32; #endif int fs; - char drivename[] = "A:\\"; + char *drivename = "A:\\"; static unsigned char x[0x40]; /* we make this static to be 0 by default - this avoids FAT misdetections */ unsigned total_clusters; @@ -542,7 +572,8 @@ VOID put_boot(COUNT drive, BYTE * bsFile, BOOL both) #endif reset_drive(drive); - if (MyAbsReadWrite(drive, 1, 0, oldboot, 0x25) != 0) + /* suggestion: allow reading from a boot sector or image file here */ + if (MyAbsReadWrite(drive, 1, 0, oldboot, 0) != 0) { printf("can't read old boot sector for drive %c:\n", drive + 'A'); exit(1); @@ -569,6 +600,7 @@ VOID put_boot(COUNT drive, BYTE * bsFile, BOOL both) this should work, as the disk was writeable, so GetFreeDiskSpace should work. */ + /* would work different when reading from an image */ if (getdrivespace(drive, &total_clusters) == 0xffff) { printf("can't get free disk space for %c:\n", drive + 'A'); @@ -593,6 +625,7 @@ VOID put_boot(COUNT drive, BYTE * bsFile, BOOL both) */ drivename[0] = 'A' + drive; + /* would also work different when reading from an image */ if (getextdrivespace(drivename, x, sizeof(x))) /* error --> no Win98 --> no FAT32 */ { @@ -696,7 +729,7 @@ VOID put_boot(COUNT drive, BYTE * bsFile, BOOL both) bs->bsDriveNumber = drive < 2 ? 0 : 0xff; } -#ifdef DEBUG +#ifdef DEBUG /* add an option to display this on user request? */ printf("Root dir entries = %u\n", bs->bsRootDirEnts); printf("Root dir sectors = %u\n", bs->sysRootDirSecs); @@ -721,12 +754,13 @@ VOID put_boot(COUNT drive, BYTE * bsFile, BOOL both) printf("writing new bootsector to drive %c:\n", drive + 'A'); #endif - if (MyAbsReadWrite(drive, 1, 0, newboot, 0x26) != 0) + /* write newboot to a drive */ + if (MyAbsReadWrite(drive, 1, 0, newboot, 1) != 0) { printf("Can't write new boot sector to drive %c:\n", drive + 'A'); exit(1); } - } + } /* if write boot sector */ if (bsFile != NULL) { @@ -737,7 +771,7 @@ VOID put_boot(COUNT drive, BYTE * bsFile, BOOL both) #endif /* write newboot to bsFile */ - if ((fd = + if ((fd = /* suggestion: do not trunc - allows to write to images */ open(bsFile, O_RDWR | O_TRUNC | O_CREAT | O_BINARY, S_IREAD | S_IWRITE)) < 0) { @@ -752,9 +786,10 @@ VOID put_boot(COUNT drive, BYTE * bsFile, BOOL both) exit(1); } close(fd); - } + } /* if write boot sector file */ reset_drive(drive); -} +} /* put_boot */ + BOOL check_space(COUNT drive, BYTE * BlkBuffer) { @@ -765,7 +800,8 @@ BOOL check_space(COUNT drive, BYTE * BlkBuffer) UNREFERENCED_PARAMETER(BlkBuffer); return TRUE; -} +} /* check_space */ + BYTE copybuffer[COPY_SIZE]; @@ -860,7 +896,8 @@ BOOL copy(COUNT drive, BYTE * srcPath, BYTE * rootPath, BYTE * file) printf("%lu Bytes transferred", copied); return TRUE; -} +} /* copy */ + /* version 2.2 jeremyd 2001/9/20 Changed so if no source given or only source drive (no path) @@ -869,6 +906,7 @@ BOOL copy(COUNT drive, BYTE * srcPath, BYTE * rootPath, BYTE * file) uses root (but only if source & destination drive are different). Fix printf to include count(ret) if copy can't write all requested bytes */ + /* version 2.1a jeremyd 2001/8/19 modified so takes optional 2nd parameter (similar to PC DOS) where if only 1 argument is given, assume to be destination drive, @@ -879,8 +917,6 @@ BOOL copy(COUNT drive, BYTE * srcPath, BYTE * rootPath, BYTE * file) /* Revision 2.1 tomehlert 2001/4/26 changed the file system detection code. - - */ /* Revision 2.0 tomehlert 2001/4/26 @@ -900,5 +936,4 @@ BOOL copy(COUNT drive, BYTE * srcPath, BYTE * rootPath, BYTE * file) included (slighly modified) PRF.c from kernel size is no ~7500 byte vs. ~13690 before - */ From 4c88863f2418199ee204442544034887c824132a Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sun, 15 Jun 2003 22:06:03 +0000 Subject: [PATCH 216/671] Add support for UNC style paths (David Bolen) git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@604 6ac86273-5f31-0410-b378-82cca8765d1b --- docs/history.txt | 3 +++ kernel/dosfns.c | 15 ++++++++----- kernel/newstuff.c | 54 +++++++++++++++++++++++++++-------------------- kernel/proto.h | 3 +-- kernel/systime.c | 4 ++++ 5 files changed, 49 insertions(+), 30 deletions(-) diff --git a/docs/history.txt b/docs/history.txt index 15865e59..b1183be5 100644 --- a/docs/history.txt +++ b/docs/history.txt @@ -16,6 +16,9 @@ * distinguish between the builtin DOS version and the settable DOS version. * console.asm now accepts extended scancodes (modified by Bart) + * added BOOTONLY option to SYS (modified by Bart) ++ Changes David Bolen + * add support for UNC-style paths (that start with "\\") + Changes Bart * flip some slashes in drivers/*.asm (enables cross-assembly on Linux) diff --git a/kernel/dosfns.c b/kernel/dosfns.c index 3357bb88..032bb133 100644 --- a/kernel/dosfns.c +++ b/kernel/dosfns.c @@ -92,7 +92,7 @@ STATIC int remote_lock_unlock(sft FAR *sftp, /* SFT for file */ /* get current directory structure for drive return NULL if the CDS is not valid or the drive is not within range */ -struct cds FAR *get_cds(int drive) +struct cds FAR *get_cds(unsigned drive) { struct cds FAR *cdsp; unsigned flags; @@ -966,7 +966,8 @@ COUNT DosChangeDir(BYTE FAR * s) return result; } - if (strlen(PriPathName) > sizeof(current_ldt->cdsCurrentPath) - 1) + if ((FP_OFF(current_ldt) != 0xFFFF) && + (strlen(PriPathName) > sizeof(current_ldt->cdsCurrentPath) - 1)) return DE_PATHNOTFND; #if defined(CHDIR_DEBUG) @@ -988,8 +989,12 @@ COUNT DosChangeDir(BYTE FAR * s) SHSUCdX needs this. jt */ fstrcpy(current_ldt->cdsCurrentPath, PriPathName); - if (PriPathName[7] == 0) - current_ldt->cdsCurrentPath[8] = 0; /* Need two Zeros at the end */ + if (FP_OFF(current_ldt) != 0xFFFF) + { + fstrcpy(current_ldt->cdsCurrentPath, PriPathName); + if (PriPathName[7] == 0) + current_ldt->cdsCurrentPath[8] = 0; /* Need two Zeros at the end */ + } return SUCCESS; } @@ -1271,7 +1276,7 @@ COUNT DosRenameTrue(BYTE * path1, BYTE * path2, int attrib) { return DE_DEVICE; /* not same device */ } - if (current_ldt->cdsFlags & CDSNETWDRV) + if (FP_OFF(current_ldt) == 0xFFFF || (current_ldt->cdsFlags & CDSNETWDRV)) return remote_rename(); return dos_rename(path1, path2, attrib); diff --git a/kernel/newstuff.c b/kernel/newstuff.c index 72191779..28a75e52 100644 --- a/kernel/newstuff.c +++ b/kernel/newstuff.c @@ -108,7 +108,7 @@ int DosMkTmp(BYTE FAR * pathname, UWORD attr) #define DEBUG_TRUENAME #endif -#define drLetterToNr(dr) ((dr) - 'A') +#define drLetterToNr(dr) ((unsigned char)((dr) - 'A')) /* Convert an uppercased drive letter into the drive index */ #define drNrToLetter(dr) ((dr) + 'A') /* the other direction */ @@ -117,22 +117,6 @@ int DosMkTmp(BYTE FAR * pathname, UWORD attr) is always a logical drive letter associated with a path spec. This letter is also the index into the CDS */ -COUNT get_verify_drive(const char FAR * src) -{ - int drive; - - /* Do we have a drive? */ - if (src[1] == ':') - drive = drLetterToNr(DosUpFChar(src[0])); - else - drive = default_drive; - - if (get_cds(drive) == NULL) - return DE_PATHNOTFND; - - return drive; -} - /* Definition of functions for the handling of the Current Directory Structure. @@ -260,7 +244,7 @@ COUNT get_verify_drive(const char FAR * src) #define addChar(c) \ { \ - if (p - dest >= SFTMAX) PATH_ERROR; /* path too long */ \ + if (p >= dest + SFTMAX) PATH_ERROR; /* path too long */ \ *p++ = c; \ } @@ -321,6 +305,7 @@ COUNT truename(const char FAR * src, char * dest, COUNT mode) struct cds FAR *cdsEntry; char *p = dest; /* dynamic pointer into dest */ char *rootPos; + char src0; enum { DONT_ADD, ADD, ADD_UNLESS_LAST } addSep; tn_printf(("truename(%S)\n", src)); @@ -330,14 +315,37 @@ COUNT truename(const char FAR * src, char * dest, COUNT mode) /* In opposite of the TRUENAME shell command, an empty string is rejected by MS DOS 6 */ - if (src[0] == '\0') + src0 = src[0]; + if (src0 == '\0') return DE_FILENOTFND; - result = get_verify_drive(src); - if (result < SUCCESS) - return result; + if (src0 == '\\' && src[1] == '\\') { + const char FAR *unc_src = src; + /* Flag UNC paths and short circuit processing. Set current LDT */ + /* to sentinel (offset 0xFFFF) for redirector processing. */ + tn_printf(("Truename: UNC detected\n")); + do { + src0 = unc_src[0]; + addChar(src0); + unc_src++; + } while (src0); + current_ldt = (struct cds FAR *)MK_FP(0xFFFF,0xFFFF); + tn_printf(("Returning path: \"%s\"\n", dest)); + /* Flag as network - drive bits are empty but shouldn't get */ + /* referenced for network with empty current_ldt. */ + return IS_NETWORK; + } + + /* Do we have a drive? */ + if (src[1] == ':') + result = drLetterToNr(DosUpFChar(src0)); + else + result = default_drive; + + cdsEntry = get_cds(result); + if (cdsEntry == NULL) + return DE_PATHNOTFND; - cdsEntry = &CDSp[result]; tn_printf(("CDS entry: #%u @%p (%u) '%S'\n", result, cdsEntry, cdsEntry->cdsBackslashOffset, cdsEntry->cdsCurrentPath)); /* is the current_ldt thing necessary for compatibly?? diff --git a/kernel/proto.h b/kernel/proto.h index 791ffc1d..5ff35bcf 100644 --- a/kernel/proto.h +++ b/kernel/proto.h @@ -111,7 +111,7 @@ BOOL IsShareInstalled(void); COUNT DosLockUnlock(COUNT hndl, LONG pos, LONG len, COUNT unlock); sft FAR *idx_to_sft(int SftIndex); int get_sft_idx(UCOUNT hndl); -struct cds FAR *get_cds(int dsk); +struct cds FAR *get_cds(unsigned dsk); COUNT DosTruename(const char FAR * src, char FAR * dest); /*dosidle.asm */ @@ -340,7 +340,6 @@ VOID InitPSP(VOID); /* newstuff.c */ int SetJFTSize(UWORD nHandles); int DosMkTmp(BYTE FAR * pathname, UWORD attr); -COUNT get_verify_drive(const char FAR * src); COUNT truename(const char FAR * src, char * dest, COUNT t); /* network.c */ diff --git a/kernel/systime.c b/kernel/systime.c index d32e55a2..d7d8394c 100644 --- a/kernel/systime.c +++ b/kernel/systime.c @@ -92,6 +92,10 @@ void DosGetTime(struct dostime *dt) int DosSetTime(const struct dostime *dt) { + if (dt->hour > 23 || dt->minute > 59 || + dt->second > 59 || dt->hundredth > 99) + return DE_INVLDDATA; + /* for ClkRecord.clkDays */ ExecuteClockDriverRequest(C_INPUT); From 7bc5f8b31ee6cdc615b8df6159ff440f9ecb8692 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sun, 15 Jun 2003 22:58:29 +0000 Subject: [PATCH 217/671] Repair arrow keys for console.asm + fixes for Turbo C git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@605 6ac86273-5f31-0410-b378-82cca8765d1b --- hdr/version.h | 8 ++++---- kernel/console.asm | 46 ++++++++++++++++++++++++++-------------------- kernel/initclk.c | 1 + kernel/initdisk.c | 1 + kernel/initoem.c | 1 + kernel/main.c | 4 ++-- 6 files changed, 35 insertions(+), 26 deletions(-) diff --git a/hdr/version.h b/hdr/version.h index 8afa7921..ed4234ec 100644 --- a/hdr/version.h +++ b/hdr/version.h @@ -47,8 +47,8 @@ static BYTE *date_hRcsId = #define REVISION_MAJOR 1 #define REVISION_MINOR 1 -#define REVISION_SEQ 29 -#define BUILD "2029" +#define REVISION_SEQ 30 +#define BUILD "2030" #define SUB_BUILD "" -#define KERNEL_VERSION_STRING "1.1.29" /*#REVISION_MAJOR "." #REVISION_MINOR "." #REVISION_SEQ */ -#define KERNEL_BUILD_STRING "2029" /*#BUILD SUB_BUILD */ +#define KERNEL_VERSION_STRING "1.1.30" /*#REVISION_MAJOR "." #REVISION_MINOR "." #REVISION_SEQ */ +#define KERNEL_BUILD_STRING "2030" /*#BUILD SUB_BUILD */ diff --git a/kernel/console.asm b/kernel/console.asm index 0791fa25..ddbef1d9 100644 --- a/kernel/console.asm +++ b/kernel/console.asm @@ -106,6 +106,26 @@ ConRead2: jmp _IOExit +checkkey: + mov ah,1 + add ah,[cs:kbdType] + int 16h ; Get status, if zf=0 al=char + jz keydone ; Jump if no char available +checke0: cmp al,0xe0 ; must check for 0xe0 scan code + jne .ret + cmp ax,0x00e0 ; check for Greek alpha + je .ret + mov al,0 +.ret: retn + +readkey: + mov ah,[cs:kbdType] + int 16h + jmp short checke0 + +keydone: pop cx + jmp _IODone + ; ; Name: ; KbdRdChar @@ -129,8 +149,7 @@ KbdRdChar: ; and previous is erased in any case or al,al ; Test to see if it was set jnz KbdRdRtn ; Exit if it was, returning it - mov ah, [cs:kbdType] - int 16h ; get keybd char in al, ah=scan + call readkey ; get keybd char in al, ah=scan or ax,ax ; Zero ? jz KbdRdChar ; Loop if it is cmp ax,CTL_PRT_SCREEN ; Ctrl-Print screen? @@ -143,22 +162,16 @@ KbdRd1: KbdRdRtn: retn - - global CommonNdRdExit CommonNdRdExit: ; *** tell if key waiting and return its ASCII if yes mov al,[cs:uScanCode] ; Test for last scan code ; now AL is set if previous key was extended, or al,al ; Was it zero ? jnz ConNdRd2 ; Jump if there's a char waiting - mov ah,1 - add ah,[cs:kbdType] - int 16h ; Get status, if zf=0 al=char - jz ConNdRd4 ; Jump if no char available + call checkkey or ax,ax ; Zero ? jnz ConNdRd1 ; Jump if not zero - mov ah,[cs:kbdType] - int 16h ; get status, if zf=0 al=char + call readkey jmp short CommonNdRdExit ; if char was there but 0, fetch and retry... ; (why do we check uScanCode here?) @@ -196,8 +209,7 @@ KbdInpCh1: int 16h ; get status, if zf=0 al=char jz KbdInpRtnZero ; Jump if zero ; returns 0 or the last key that was waiting in AL - mov ah,[cs:kbdType] - int 16h ; get keybd char in al, ah=scan + call readkey jmp short KbdInpCh1 ; just read any key that is waiting, then check if ; more keys are waiting. if not, return AL of this @@ -270,17 +282,11 @@ ConInStat: or al,al ; Was it zero ? jnz ConCharReady ; Jump if there's a char waiting ; return previously cached ext char if any - mov ah,1 - add ah,[cs:kbdType] - int 16h ; get status, if zf=0 al=char - jz ConNoChar ; Jump if zero - ; if no key waiting, return AL=0 / "none waiting" - + call checkkey or ax,ax ; Zero ? jnz ConIS1 ; Jump if not zero ; if non-zero key waiting, take it - mov ah,[cs:kbdType] - int 16h ; get status, if zf=0 al=char + call readkey jmp short ConInStat ; if zero key was waiting, fetch 2nd part etc. (???) diff --git a/kernel/initclk.c b/kernel/initclk.c index 230a2540..b19a907f 100644 --- a/kernel/initclk.c +++ b/kernel/initclk.c @@ -29,6 +29,7 @@ #include "portab.h" #include "init-mod.h" #include "init-dat.h" +#include "lol.h" #ifdef VERSION_STRINGS static char *RcsId = diff --git a/kernel/initdisk.c b/kernel/initdisk.c index f8d71d92..dda83480 100644 --- a/kernel/initdisk.c +++ b/kernel/initdisk.c @@ -28,6 +28,7 @@ #include "init-mod.h" #include "init-dat.h" #include "dyndata.h" +#include "lol.h" #ifdef VERSION_STRINGS static BYTE *dskRcsId = "$Id$"; diff --git a/kernel/initoem.c b/kernel/initoem.c index ca0b0949..58ef9b91 100644 --- a/kernel/initoem.c +++ b/kernel/initoem.c @@ -29,6 +29,7 @@ #include "portab.h" #include "init-mod.h" +#include "lol.h" #ifdef VERSION_STRINGS static BYTE *RcsId = diff --git a/kernel/main.c b/kernel/main.c index 82c6fc1b..a7ddaaab 100644 --- a/kernel/main.c +++ b/kernel/main.c @@ -682,7 +682,7 @@ void CheckContinueBootFromHarddisk(void) bootedFrom ); - if (GetBiosKey(InitKernelConfig.BootHarddiskSeconds) != -1) + if (GetBiosKey(InitKernelConfig.BootHarddiskSeconds) != (UWORD)-1) { /* user has hit a key, continue to boot from floppy/CD */ printf("\n"); @@ -703,7 +703,7 @@ void CheckContinueBootFromHarddisk(void) init_call_intr(0x13, &r); { - void (far *reboot)() = (void (far*)()) MK_FP(0x0,0x7c00); + void (far *reboot)(void) = (void (far*)(void)) MK_FP(0x0,0x7c00); (*reboot)(); } From 1b2a421f449a46d21a01006cd5d2b82e79dba6ce Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Mon, 16 Jun 2003 11:10:17 +0000 Subject: [PATCH 218/671] Some duplicate code merging and scancode-0xe0 related fixes. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@606 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/console.asm | 81 ++++++++++++++-------------------------------- 1 file changed, 24 insertions(+), 57 deletions(-) diff --git a/kernel/console.asm b/kernel/console.asm index ddbef1d9..546ab06a 100644 --- a/kernel/console.asm +++ b/kernel/console.asm @@ -41,7 +41,7 @@ ConTable db 0Ah dw _IOCommandError dw ConRead dw CommonNdRdExit - dw ConInStat + dw CommonNdRdExit dw ConInpFlush dw ConWrite dw ConWrite @@ -106,26 +106,16 @@ ConRead2: jmp _IOExit -checkkey: - mov ah,1 - add ah,[cs:kbdType] - int 16h ; Get status, if zf=0 al=char - jz keydone ; Jump if no char available +readkey: + mov ah,[cs:kbdType] + int 16h checke0: cmp al,0xe0 ; must check for 0xe0 scan code jne .ret - cmp ax,0x00e0 ; check for Greek alpha - je .ret - mov al,0 + or ah,ah ; check for Greek alpha + jz .ret + mov al,0 ; otherwise destroy the 0xe0 .ret: retn -readkey: - mov ah,[cs:kbdType] - int 16h - jmp short checke0 - -keydone: pop cx - jmp _IODone - ; ; Name: ; KbdRdChar @@ -162,13 +152,27 @@ KbdRd1: KbdRdRtn: retn +; +; Name: +; ConInStat +; +; Function: +; Checks the keyboard input buffer. +; +; Description: +; Calls int 16 (get status). Sets Busy-Flag in status field. Destroys ax. +; global CommonNdRdExit CommonNdRdExit: ; *** tell if key waiting and return its ASCII if yes mov al,[cs:uScanCode] ; Test for last scan code ; now AL is set if previous key was extended, or al,al ; Was it zero ? jnz ConNdRd2 ; Jump if there's a char waiting - call checkkey + mov ah,1 + add ah,[cs:kbdType] + int 16h ; Get status, if zf=0 al=char + jz ConNdRd4 ; Jump if no char available + call checke0 ; check for e0 scancode or ax,ax ; Zero ? jnz ConNdRd1 ; Jump if not zero call readkey @@ -183,6 +187,8 @@ ConNdRd1: ConNdRd2: lds bx,[cs:_ReqPktPtr] ; Set the status + cmp byte[bx+2],6 ; input status call? + je ConNdRd3 mov [bx+0Dh],al ; return the ASCII of that key ConNdRd3: @@ -263,42 +269,3 @@ _int29_handler: pop si pop ax iret - - -; -; Name: -; ConInStat -; -; Function: -; Checks the keybord input buffer. -; -; Description: -; Calls int 16 (get status). Sets Busy-Flag in status field. Destroys ax. -; - global ConInStat -ConInStat: - mov ah,0 ; just in case ... - mov al,[cs:uScanCode] ; Test for last scan code - or al,al ; Was it zero ? - jnz ConCharReady ; Jump if there's a char waiting - ; return previously cached ext char if any - call checkkey - or ax,ax ; Zero ? - jnz ConIS1 ; Jump if not zero - ; if non-zero key waiting, take it - call readkey - jmp short ConInStat - ; if zero key was waiting, fetch 2nd part etc. (???) - -ConIS1: - cmp ax,CTL_PRT_SCREEN ; Was ctl+prntscrn key pressed? - jne ConIS2 ; Jump if not - mov al,CTL_P -ConIS2: - lds bx,[cs:_ReqPktPtr] ; Set the status - mov [bx+0Dh],al ; return the ASCII of the key -ConCharReady: - jmp _IOExit ; key ready (busy=0) -ConNoChar: - jmp _IODone ; no key ready (busy=1) - From 2a83b111c40f44319efb0856f75c2d3f84d4c9ff Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Mon, 16 Jun 2003 13:33:40 +0000 Subject: [PATCH 219/671] Check if source and destination are identical before copying. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@607 6ac86273-5f31-0410-b378-82cca8765d1b --- sys/sys.c | 40 +++++++++++++++++++++++++++++++++++----- 1 file changed, 35 insertions(+), 5 deletions(-) diff --git a/sys/sys.c b/sys/sys.c index 0538c06f..9ffadca9 100644 --- a/sys/sys.c +++ b/sys/sys.c @@ -35,7 +35,7 @@ #define DEBUG /* #define DDEBUG */ -#define SYS_VERSION "v2.5" +#define SYS_VERSION "v2.6" #include #include @@ -106,7 +106,9 @@ int stat(const char *file_name, struct stat *buf) return _dos_findfirst(file_name, _A_NORMAL | _A_HIDDEN | _A_SYSTEM, &find_tbuf); } -#endif + +/* WATCOM's getenv is case-insensitive which wastes a lot of space + for our purposes. So here's a simple case-sensitive one */ char *getenv(const char *name) { char **envp, *ep; @@ -127,6 +129,7 @@ char *getenv(const char *name) } return NULL; } +#endif BYTE pgm[] = "SYS"; @@ -314,7 +317,7 @@ int main(int argc, char **argv) } printf("\nCopying KERNEL.SYS...\n"); - if (!copy(drive, srcPath, rootPath, "kernel.sys")) + if (!copy(drive, srcPath, rootPath, "KERNEL.SYS")) { printf("\n%s: cannot copy \"KERNEL.SYS\"\n", pgm); exit(1); @@ -423,6 +426,11 @@ void reset_drive(int DosDrive); parm [dx] \ modify [ax bx]; +void truename(char far *dest, const char *src); +#pragma aux truename = \ + "mov ah,0x60" \ + "int 0x21" \ + parm [es di] [si]; #else #ifndef __TURBOC__ @@ -473,6 +481,19 @@ void reset_drive(int DosDrive) intdos(®s, ®s); } /* reset_drive */ +void truename(char *dest, const char *src) +{ + union REGS regs; + struct SREGS sregs; + + regs.h.ah = 0x60; + sregs.es = FP_SEG(dest); + regs.x.di = FP_OFF(dest); + sregs.ds = FP_SEG(src); + regs.x.si = FP_OFF(src); + intdosx(®s, ®s, &sregs); +} /* reset_drive */ + #endif int MyAbsReadWrite(int DosDrive, int count, ULONG sector, void *buffer, @@ -807,13 +828,12 @@ BYTE copybuffer[COPY_SIZE]; BOOL copy(COUNT drive, BYTE * srcPath, BYTE * rootPath, BYTE * file) { - BYTE dest[SYS_MAXPATH], source[SYS_MAXPATH]; + static BYTE dest[SYS_MAXPATH], source[SYS_MAXPATH]; unsigned ret; int fdin, fdout; ULONG copied = 0; struct stat fstatbuf; - sprintf(dest, "%c:\\%s", 'A' + drive, file); strcpy(source, srcPath); if (rootPath != NULL) /* trick for comspec */ strcat(source, file); @@ -836,6 +856,16 @@ BOOL copy(COUNT drive, BYTE * srcPath, BYTE * rootPath, BYTE * file) return FALSE; } + truename(dest, source); + strcpy(source, dest); + sprintf(dest, "%c:\\%s", 'A' + drive, file); + if (strcmp(source, dest) == 0) + { + printf("%s: source and destination are identical: skipping \"%s\"\n", + pgm, source); + return TRUE; + } + if ((fdin = open(source, O_RDONLY | O_BINARY)) < 0) { printf("%s: failed to open \"%s\"\n", pgm, source); From 7c8b87380fe93acfce958a8ddc6e83a79196d1b7 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Mon, 16 Jun 2003 16:36:58 +0000 Subject: [PATCH 220/671] Simple extended keyboard detection using 40:96 git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@608 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/console.asm | 27 +++++---------------------- 1 file changed, 5 insertions(+), 22 deletions(-) diff --git a/kernel/console.asm b/kernel/console.asm index 546ab06a..c50a8e29 100644 --- a/kernel/console.asm +++ b/kernel/console.asm @@ -56,30 +56,13 @@ uScanCode db 0 ; Scan code for con: device kbdType db 0 ; 00 for 84key, 10h for 102key -; -; (taken from nansi.sys) -; global ConInit ConInit: - ; Jam special test code into keyboard buffer - mov ah,5 - mov cx,0ffffh - int 16h - ; Try to read special test code from keyboard buffer - mov cx, 10h -kbdLoop: - ; Get keystroke using extended keyboard read - mov ah, 10h - int 16h - ; Is it our special test code? - cmp ax, 0ffffh - ; Yes; Set flag saying that the extended keyboard BIOS is supported - je kbdExtended - loop kbdLoop - jmp short kbdSimple -kbdExtended: - mov byte[cs:kbdType],10h -kbdSimple: + mov ax,40h + mov ds,ax + mov al,[96h] + and al,10h + mov byte[cs:kbdType],al ; enhanced keyboard if bit 4 set jmp _IOExit ; From 01a6ec02dce8be99a673e546af2983ba1ace504d Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Mon, 16 Jun 2003 16:38:14 +0000 Subject: [PATCH 221/671] update history git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@609 6ac86273-5f31-0410-b378-82cca8765d1b --- docs/history.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/history.txt b/docs/history.txt index b1183be5..d59d6ec9 100644 --- a/docs/history.txt +++ b/docs/history.txt @@ -45,7 +45,8 @@ * avoid more relocations in the asm files by loading ds from [cs:_DGROUP_] * Fix problem with attributes with the volume label bit + findnext - * + * SYS: avoid copying kernel.sys and command.com if the destination + is identical to the source. 2003 Mar 14 - Build 2029 -------- Bart Oldeman (bart@dosemu.org) + Changes Tom From aebf17f9596d72109ece80a40a35e12aa4ec5ea0 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Mon, 16 Jun 2003 16:39:20 +0000 Subject: [PATCH 222/671] Add lol.h git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@610 6ac86273-5f31-0410-b378-82cca8765d1b --- filelist | 1 + 1 file changed, 1 insertion(+) diff --git a/filelist b/filelist index 90872796..7cf5fde2 100644 --- a/filelist +++ b/filelist @@ -51,6 +51,7 @@ */*/hdr/fnode.h */*/hdr/kbd.h */*/hdr/kconfig.h +*/*/hdr/lol.h */*/hdr/mcb.h */*/hdr/network.h */*/hdr/nls.h From a4abd642bfbb01282b5f9966007b490bc55dd2e5 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Tue, 17 Jun 2003 08:38:20 +0000 Subject: [PATCH 223/671] Fix buffer deletion problem with multi-sector writes. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@611 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/blockio.c | 7 +++++-- kernel/fatfs.c | 2 +- kernel/proto.h | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/kernel/blockio.c b/kernel/blockio.c index 168148b3..00b6bd77 100644 --- a/kernel/blockio.c +++ b/kernel/blockio.c @@ -155,7 +155,7 @@ STATIC struct buffer FAR *searchblock(ULONG blkno, COUNT dsk) return bp; } -BOOL DeleteBlockInBufferCache(ULONG blknolow, ULONG blknohigh, COUNT dsk) +BOOL DeleteBlockInBufferCache(ULONG blknolow, ULONG blknohigh, COUNT dsk, int mode) { struct buffer FAR *bp = firstbuf; @@ -168,7 +168,10 @@ BOOL DeleteBlockInBufferCache(ULONG blknolow, ULONG blknohigh, COUNT dsk) bp->b_blkno <= blknohigh && (bp->b_flag & BFR_VALID) && (bp->b_unit == dsk)) { - flush1(bp); + if (mode == XFR_READ) + flush1(bp); + else + bp->b_flag = 0; } bp = b_next(bp); } diff --git a/kernel/fatfs.c b/kernel/fatfs.c index 5fd406e7..fc9813c6 100644 --- a/kernel/fatfs.c +++ b/kernel/fatfs.c @@ -1706,7 +1706,7 @@ UCOUNT rwblock(COUNT fd, VOID FAR * buffer, UCOUNT count, int mode) DeleteBlockInBufferCache(currentblock, currentblock + sectors_to_xfer - 1, - fnp->f_dpb->dpb_unit); + fnp->f_dpb->dpb_unit, mode); if (dskxfer(fnp->f_dpb->dpb_unit, currentblock, diff --git a/kernel/proto.h b/kernel/proto.h index 5ff35bcf..a9f9309a 100644 --- a/kernel/proto.h +++ b/kernel/proto.h @@ -41,7 +41,7 @@ VOID setinvld(REG COUNT dsk); BOOL flush_buffers(REG COUNT dsk); BOOL flush(void); BOOL fill(REG struct buffer FAR * bp, ULONG blkno, COUNT dsk); -BOOL DeleteBlockInBufferCache(ULONG blknolow, ULONG blknohigh, COUNT dsk); +BOOL DeleteBlockInBufferCache(ULONG blknolow, ULONG blknohigh, COUNT dsk, int mode); /* *** Changed on 9/4/00 BER */ UWORD dskxfer(COUNT dsk, ULONG blkno, VOID FAR * buf, UWORD numblocks, COUNT mode); From 2cb828283f7dc64fbda0ad03f590f24c344928f6 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Tue, 17 Jun 2003 08:45:56 +0000 Subject: [PATCH 224/671] Remove my old truename fix. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@612 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/newstuff.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/kernel/newstuff.c b/kernel/newstuff.c index 28a75e52..73f26ffc 100644 --- a/kernel/newstuff.c +++ b/kernel/newstuff.c @@ -538,8 +538,7 @@ COUNT truename(const char FAR * src, char * dest, COUNT mode) if (i & PNE_WILDCARD) gotAnyWildcards = TRUE; } - if (*src != '\0') - --src; /* terminator or separator was skipped */ + --src; /* terminator or separator was skipped */ break; } } From f98fc8640bc1918950e7b32b79f20623d778acda Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Tue, 17 Jun 2003 11:53:37 +0000 Subject: [PATCH 225/671] Removed most of Eric's config.sys stuff -- some are questionable, others unfinished. EECHO works though. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@613 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/config.c | 204 ++++++++++++------------------------------------ 1 file changed, 49 insertions(+), 155 deletions(-) diff --git a/kernel/config.c b/kernel/config.c index 5147af09..37cac52c 100644 --- a/kernel/config.c +++ b/kernel/config.c @@ -141,6 +141,7 @@ STATIC VOID CmdInstallHigh(BYTE * pLine); STATIC VOID CfgSwitchar(BYTE * pLine); +STATIC VOID CfgSwitches(BYTE * pLine); STATIC VOID CfgFailure(BYTE * pLine); STATIC VOID CfgIgnore(BYTE * pLine); STATIC VOID CfgMenu(BYTE * pLine); @@ -163,11 +164,6 @@ STATIC VOID mumcb_init(UCOUNT seg, UWORD size); STATIC VOID Stacks(BYTE * pLine); STATIC VOID StacksHigh(BYTE * pLine); -STATIC VOID sysKbdRate(BYTE * pLine); -STATIC VOID sysKbdBuf(BYTE * pLine); -STATIC VOID sysVidMode(BYTE * pLine); -STATIC VOID sysMenuColor(BYTE * pLine); - STATIC VOID SetAnyDos(BYTE * pLine); STATIC VOID Numlock(BYTE * pLine); STATIC BYTE * GetNumArg(BYTE * pLine, COUNT * pnArg); @@ -202,6 +198,10 @@ struct table { }; STATIC struct table commands[] = { + /* first = switches! this one is special since it is asked for but + also checked before F5/F8 */ + {"SWITCHES", 0, CfgSwitches}, + /* rem is never executed by locking out pass */ {"REM", 0, CfgIgnore}, {";", 0, CfgIgnore}, @@ -209,6 +209,7 @@ STATIC struct table commands[] = { {"MENUDEFAULT", 0, CfgMenuDefault}, {"MENU", 0, CfgMenu}, /* lines to print in pass 0 */ {"ECHO", 2, CfgMenu}, /* lines to print in pass 2 - install(high) */ + {"EECHO", 2, CfgMenuEsc}, /* modified ECHO (ea) */ {"BREAK", 1, CfgBreak}, {"BUFFERS", 1, Config_Buffers}, @@ -230,10 +231,6 @@ STATIC struct table commands[] = { {"SCREEN", 1, sysScreenMode}, /* JPP */ {"VERSION", 1, sysVersion}, /* JPP */ {"ANYDOS", 1, SetAnyDos}, /* tom */ - {"KBDRATE", 1, sysKbdRate}, /* ea */ - {"KBDBUF", 1, sysKbdBuf}, /* ea */ - {"VIDMODE", 1, sysVidMode}, /* ea */ - {"MENUCOLOR", 1, sysMenuColor}, /* ea */ {"DEVICE", 2, Device}, {"DEVICEHIGH", 2, DeviceHigh}, @@ -604,9 +601,6 @@ VOID DoConfig(int pass) break; } - /* immediately convert to upper case */ - *pLine = toupper(*pLine); - if (pLine >= szLine + sizeof(szLine) - 3) { CfgFailure(pLine); @@ -639,7 +633,7 @@ VOID DoConfig(int pass) if (pEntry->pass >= 0 && pEntry->pass != nPass) continue; - if (nPass == 0) /* pass 0 always executed (rem Menu prompt) */ + if (nPass == 0) /* pass 0 always executed (rem Menu prompt switches) */ { (*(pEntry->func)) (pLine); continue; @@ -1018,6 +1012,44 @@ STATIC VOID CfgSwitchar(BYTE * pLine) init_switchar(*szBuf); } +STATIC VOID CfgSwitches(BYTE * pLine) +{ + extern unsigned char FAR kbdType; + pLine = skipwh(pLine); + if (commands[0].pass == 0) { + if ('=' != *pLine) + { + CfgFailure(pLine); + return; + } + pLine = skipwh(pLine + 1); + } + while (*pLine) + { + if (*pLine == '/') { + pLine++; + switch(toupper(*pLine)) { + case 'K': + if (commands[0].pass == 1) + kbdType = 0; /* force conv keyb */ + break; + case 'N': + InitKernelConfig.SkipConfigSeconds = -1; + break; + case 'F': + InitKernelConfig.SkipConfigSeconds = 0; + break; + default: + CfgFailure(pLine); + } + } else { + CfgFailure(pLine); + } + pLine = skipwh(pLine+1); + } + commands[0].pass = 1; +} + STATIC VOID Fcbs(BYTE * pLine) { /* Format: FCBS = totalFcbs [,protectedFcbs] */ @@ -1135,148 +1167,6 @@ STATIC VOID StacksHigh(BYTE * pLine) Config.cfgStacksHigh = 1; } -STATIC VOID sysKbdRate(BYTE * pLine) -{ - COUNT krate = 16; /* default: medium rate */ - COUNT kdelay = 3; /* default: maximum delay */ - - /* Format: KBDRATE = ratecode [, delay] */ - pLine = GetNumArg(pLine, &krate); - - pLine = skipwh(pLine); - - if (*pLine == ',') - GetNumArg(++pLine, &kdelay); - - if (krate < 0 || krate > 31 || kdelay < 0 || kdelay > 3) { - printf("KBDRATE arguments must be 0..31, 0..3 for rate, delay\n"); - CfgFailure(pLine); - return; - } - - /* could check if int 16.9 returns AL and 4 NZ before setting rates */ - -#if defined(__TURBOC__) - _AX = 0x0305; - _BH = kdelay; - _BL = krate; - __int__(0x16); -#elif defined(I86) - asm - { - mov ax, 0x0305; - mov bh, byte ptr kdelay; - mov bl, byte ptr krate; - int 0x16; - } -#endif - - printf("Set keyboard repeat rate=%d (0=fastest, 31=slowest), delay=%d\n", - krate, kdelay); -} - -STATIC VOID sysKbdBuf(BYTE * pLine) -{ - COUNT kbuf1 = 0xb0; /* default - okay if no EDD/... BIOS */ - COUNT kbuf2 = 0xfe; /* default - end of BIOS data */ - WORD FAR *kbufstart = MK_FP(0x40, 0x80); - WORD FAR *kbufend = MK_FP(0x40, 0x82); - WORD FAR *kbufptr1 = MK_FP(0x40, 0x1a); - WORD FAR *kbufptr2 = MK_FP(0x40, 0x1c); - - /* Format: KBDBUF = start [, end] */ - pLine = GetNumArg(pLine, &kbuf1); - - pLine = skipwh(pLine); - - if (*pLine == ',') - GetNumArg(++pLine, &kbuf2); - kbuf1 &= 0xfffe; - kbuf2 &= 0xfffe; - - if ((kbuf1 >= kbuf2) || (kbuf1 < 0xac) || (kbuf2 > 0xfe)) { - printf("KBDBUF start [, end] must be in BIOS data, not %x..%x\n", - kbuf1, kbuf2); - CfgFailure(pLine); - return; - } - - printf("KBDBUF: setting buffer to 0x40:%2x..%2x\n", kbuf1, kbuf2); - /* CLI !? */ - kbufstart[0] = kbufptr1[0] = kbufptr2[0] = kbuf1; - kbufend[0] = kbuf2; - /* STI !? */ -} - -STATIC VOID sysVidMode(BYTE * pLine) -{ - COUNT vmode = 3; /* default: 80x25 */ - - /* Format: VIDMODE = modenumber */ - pLine = GetNumArg(pLine, &vmode); - - if (vmode < 0 || vmode > 0x10c || (vmode < 0x108 && vmode >= 0x100)) { - printf("VIDMODE argument must be 0..0xff or 0x108..0x10c\n"); - /* 0x108..0x10c are normal VESA text modes. */ - /* 0..0xff are all kinds of normal video modes, no sanity checks! */ - CfgFailure(pLine); - return; - } - - if (vmode < 0x100) { -#if defined(__TURBOC__) - _AX = 0x0000 + vmode; /* CLASSIC video mode set */ - __int__(0x10); -#elif defined(I86) - asm - { - mov ah, 0; - mov al, byte ptr vmode - int 0x10; - } -#endif - } else { -#if defined(__TURBOC__) - _AX = 0x4f02; /* VESA video mode set */ - _BX = vmode; - __int__(0x10); /* if AL not 4f now, no VESA. if AH 1 now, failed */ -#elif defined(I86) - asm - { - mov ax, 0x4f02; - mov bx, word ptr vmode - int 0x10; - } -#endif - } - printf("Set video mode to %x (0x1??: VESA 0x0?? normal)\n", vmode); -} - -STATIC VOID sysMenuColor(BYTE * pLine) -{ - COUNT fgcolor = 7; /* default grey */ - COUNT bgcolor = 0; /* default black */ - - /* Format: MENUCOLOR = foreground [, background] */ - pLine = GetNumArg(pLine, &fgcolor); - - pLine = skipwh(pLine); - - if (*pLine == ',') - GetNumArg(++pLine, &bgcolor); - - if (fgcolor < 0 || fgcolor > 15 || bgcolor < 0 || bgcolor > 15) { - printf("MENUCOLOR fgcolor [, bgcolor] have 0..15 limit\n"); - CfgFailure(pLine); - return; - } - - printf("Not yet used: foreground=%d background=%d\n", fgcolor, bgcolor); - /* *** TODO: Either print ANSI sequence or make int 29h *** */ - /* *** use colored int 10.02/09 (not 0e)...??? or only *** */ - /* *** use int 10.2/3/8/9 loop to recolor current text *** */ -} - STATIC VOID InitPgmHigh(BYTE * pLine) { InitPgm(pLine); @@ -1348,6 +1238,7 @@ STATIC BOOL LoadDevice(BYTE * pLine, char FAR *top, COUNT mode) struct dhdr FAR *next_dhp; BOOL result; seg base, start; + char *p; if (mode) { @@ -1382,6 +1273,9 @@ STATIC BOOL LoadDevice(BYTE * pLine, char FAR *top, COUNT mode) } strcpy(szBuf, pLine); + /* uppercase the device driver command */ + for (p = szBuf; *p != '\0'; p++) + *p = toupper(*p); /* TE this fixes the loading of devices drivers with multiple devices in it. NUMEGA's SoftIce is such a beast From 9f15e02db90cc819052aa1ac93040acb0ba26a8a Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Tue, 17 Jun 2003 11:55:44 +0000 Subject: [PATCH 226/671] Correct get_root, make kbdType public, sys config patches from Tom. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@614 6ac86273-5f31-0410-b378-82cca8765d1b --- docs/history.txt | 6 ++++-- kernel/console.asm | 11 ++++++----- kernel/dosfns.c | 4 +++- kernel/main.c | 14 ++++++++++---- sys/fdkrncfg.c | 3 ++- 5 files changed, 25 insertions(+), 13 deletions(-) diff --git a/docs/history.txt b/docs/history.txt index d59d6ec9..64729aed 100644 --- a/docs/history.txt +++ b/docs/history.txt @@ -11,8 +11,7 @@ + Changes Eric Auer * add sanity check to initdisk.c for (driveParam->chs.Sector == 0) + some display tweaks - * add ANYDOS, KBDRATE, VIDMODE, MENUCOLOR and EECHO support to the - config.sys parser. + * add EECHO (echo with $=ESC) support to the config.sys parser. * distinguish between the builtin DOS version and the settable DOS version. * console.asm now accepts extended scancodes (modified by Bart) @@ -47,6 +46,9 @@ * Fix problem with attributes with the volume label bit + findnext * SYS: avoid copying kernel.sys and command.com if the destination is identical to the source. + * Fix bug in DeleteBlockInBufferCache: needs to make the block + invalid, not flush it, if we're writing. + * added switches=/k/n/f support to the config.sys parser. 2003 Mar 14 - Build 2029 -------- Bart Oldeman (bart@dosemu.org) + Changes Tom diff --git a/kernel/console.asm b/kernel/console.asm index c50a8e29..c36a8749 100644 --- a/kernel/console.asm +++ b/kernel/console.asm @@ -54,7 +54,8 @@ segment _LOWTEXT uScanCode db 0 ; Scan code for con: device -kbdType db 0 ; 00 for 84key, 10h for 102key +global _kbdType +_kbdType db 0 ; 00 for 84key, 10h for 102key global ConInit ConInit: @@ -62,7 +63,7 @@ ConInit: mov ds,ax mov al,[96h] and al,10h - mov byte[cs:kbdType],al ; enhanced keyboard if bit 4 set + mov byte[cs:_kbdType],al ; enhanced keyboard if bit 4 set jmp _IOExit ; @@ -90,7 +91,7 @@ ConRead2: readkey: - mov ah,[cs:kbdType] + mov ah,[cs:_kbdType] int 16h checke0: cmp al,0xe0 ; must check for 0xe0 scan code jne .ret @@ -152,7 +153,7 @@ CommonNdRdExit: ; *** tell if key waiting and return its ASCII if yes or al,al ; Was it zero ? jnz ConNdRd2 ; Jump if there's a char waiting mov ah,1 - add ah,[cs:kbdType] + add ah,[cs:_kbdType] int 16h ; Get status, if zf=0 al=char jz ConNdRd4 ; Jump if no char available call checke0 ; check for e0 scancode @@ -194,7 +195,7 @@ KbdInpChar: ; *** get ??00 or the last waiting key after flushing the queue mov byte [cs:uScanCode],al KbdInpCh1: mov ah,1 - add ah,[cs:kbdType] + add ah,[cs:_kbdType] int 16h ; get status, if zf=0 al=char jz KbdInpRtnZero ; Jump if zero ; returns 0 or the last key that was waiting in AL diff --git a/kernel/dosfns.c b/kernel/dosfns.c index 032bb133..76381684 100644 --- a/kernel/dosfns.c +++ b/kernel/dosfns.c @@ -448,8 +448,10 @@ const char FAR *get_root(const char FAR * fname) { length--; c = *--fname; - if (c == '/' || c == '\\' || c == ':') + if (c == '/' || c == '\\' || c == ':') { + fname++; break; + } } return fname; } diff --git a/kernel/main.c b/kernel/main.c index a7ddaaab..f0c29c30 100644 --- a/kernel/main.c +++ b/kernel/main.c @@ -654,8 +654,11 @@ EmulatedDriveStatus(int drive,char statusOnly) void CheckContinueBootFromHarddisk(void) { - char *bootedFrom = "CD"; + char *bootedFrom = "Floppy/CD"; iregs r; + int key; + + __int__(3); /* necessary for some strange reasons ?? (TE) */ if (InitKernelConfig.BootHarddiskSeconds == 0) return; @@ -677,12 +680,15 @@ void CheckContinueBootFromHarddisk(void) "\n" "\n" " Hit any key within %d seconds to continue booot from %s\n" - " else continue to boot from Harddisk\n", + " Hit 'H' or wait %d seconds to boot from Harddisk\n", InitKernelConfig.BootHarddiskSeconds, - bootedFrom + bootedFrom, + InitKernelConfig.BootHarddiskSeconds ); - if (GetBiosKey(InitKernelConfig.BootHarddiskSeconds) != (UWORD)-1) + key = GetBiosKey(InitKernelConfig.BootHarddiskSeconds); + + if (key != (UWORD)-1 && (key & 0xff) != 'h' && (key & 0xff) != 'H' ) { /* user has hit a key, continue to boot from floppy/CD */ printf("\n"); diff --git a/sys/fdkrncfg.c b/sys/fdkrncfg.c index 48b3aa33..28b6c8a9 100644 --- a/sys/fdkrncfg.c +++ b/sys/fdkrncfg.c @@ -84,7 +84,8 @@ void showUsage(void) " the value set will be the rightmost one.\n"); printf(" Current Options are: DLASORT=0|1, SHOWDRIVEASSIGNMENT=0|1\n" " SKIPCONFIGSECONDS=#, FORCELBA=0|1\n" - " GLOBALENABLELBASUPPORT=0|1\n"); + " GLOBALENABLELBASUPPORT=0|1\n" + " BootHarddiskSeconds=0|seconds to wait\n"); } /* simply reads in current configuration values, exiting program From 9d651b53e4848273f1bcdcd2827e093d525b2bd0 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Tue, 17 Jun 2003 15:17:51 +0000 Subject: [PATCH 227/671] Small asm optimization git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@615 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/console.asm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/console.asm b/kernel/console.asm index c36a8749..5425a790 100644 --- a/kernel/console.asm +++ b/kernel/console.asm @@ -59,9 +59,9 @@ _kbdType db 0 ; 00 for 84key, 10h for 102key global ConInit ConInit: - mov ax,40h + xor ax,ax mov ds,ax - mov al,[96h] + mov al,[496h] and al,10h mov byte[cs:_kbdType],al ; enhanced keyboard if bit 4 set jmp _IOExit From a44775630272b867c360886af379af90cb3bde42 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Tue, 17 Jun 2003 15:19:29 +0000 Subject: [PATCH 228/671] Add country support for bulgaria git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@616 6ac86273-5f31-0410-b378-82cca8765d1b --- docs/history.txt | 2 ++ kernel/config.c | 15 +++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/docs/history.txt b/docs/history.txt index 64729aed..6cf39c14 100644 --- a/docs/history.txt +++ b/docs/history.txt @@ -18,6 +18,8 @@ * added BOOTONLY option to SYS (modified by Bart) + Changes David Bolen * add support for UNC-style paths (that start with "\\") ++ Changes Luchezar Georgiev + * add Bulgarian country structure data + Changes Bart * flip some slashes in drivers/*.asm (enables cross-assembly on Linux) diff --git a/kernel/config.c b/kernel/config.c index 37cac52c..bf98a112 100644 --- a/kernel/config.c +++ b/kernel/config.c @@ -2251,6 +2251,20 @@ struct CountrySpecificInfo specificCountriesSupported[] = { _TIME_24 /* = 0 # time format: 0/1: 12/24 hours */ } + /* Bulgaria - by Luchezar Georgiev */ ,{ + 359, /* = W1 W437 # Country ID & Codepage */ + 855, + _DATE_DMY, /* Date format: 0/1/2: U.S.A./Europe/Japan */ + "BGL", /* '$' ,'EUR' */ + " ", /* ',' # Thousand's separator */ + ",", /* '.' # Decimal point */ + ".", /* '-' DateSeparator */ + ":", /* ':' TimeSeparator */ + 3, /* # Currency format (bit array) */ + 2, /* = 2 # Currency precision */ + _TIME_24 /* = 0 # time format: 0/1: 12/24 hours */ + } + /* Ukraine - by Oleg Deribas */ ,{ 380, /* = W380 W848 # Country ID & Codepage */ 848, @@ -2276,6 +2290,7 @@ struct CountrySpecificInfo specificCountriesSupported[] = { Michael H.Tyc (POL) Oleg Deribas (UKR) Arkady Belousov (RUS) + Luchezar Georgiev (BUL) Yuki Mitsui (JAP) Aitor Santamar­a Merino (SP) */ From 51e499be530d59e5a63f3d313f1fe59a334a1d66 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Tue, 17 Jun 2003 15:48:20 +0000 Subject: [PATCH 229/671] update lsm git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@617 6ac86273-5f31-0410-b378-82cca8765d1b --- docs/fdkernel.lsm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/fdkernel.lsm b/docs/fdkernel.lsm index 26dde02d..35c03505 100644 --- a/docs/fdkernel.lsm +++ b/docs/fdkernel.lsm @@ -1,7 +1,7 @@ Begin3 Title: The FreeDOS Kernel -Version: 2.0.29 -Entered-date: 14 Mar 2003 +Version: 2.0.30 +Entered-date: 19 Jun 2003 Description: The FreeDOS Kernel. Keywords: kernel freedos dos msdos Author: (developers) From 9647aa92e55727178f23ff25a09a8a5125573405 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Wed, 18 Jun 2003 19:18:16 +0000 Subject: [PATCH 230/671] .lsm and history.txt updates git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@618 6ac86273-5f31-0410-b378-82cca8765d1b --- docs/fdkernel.lsm | 2 +- docs/history.txt | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/docs/fdkernel.lsm b/docs/fdkernel.lsm index 35c03505..039bec51 100644 --- a/docs/fdkernel.lsm +++ b/docs/fdkernel.lsm @@ -1,7 +1,7 @@ Begin3 Title: The FreeDOS Kernel Version: 2.0.30 -Entered-date: 19 Jun 2003 +Entered-date: 18 Jun 2003 Description: The FreeDOS Kernel. Keywords: kernel freedos dos msdos Author: (developers) diff --git a/docs/history.txt b/docs/history.txt index 6cf39c14..dc05b715 100644 --- a/docs/history.txt +++ b/docs/history.txt @@ -1,4 +1,4 @@ -2003 Jun xx - Build 2030 +2003 Jun 18 - Build 2030 -------- Bart Oldeman (bart@dosemu.org) + Changes Tom * if user left accidentally floppy or CD in drive, @@ -14,7 +14,8 @@ * add EECHO (echo with $=ESC) support to the config.sys parser. * distinguish between the builtin DOS version and the settable DOS version. - * console.asm now accepts extended scancodes (modified by Bart) + * console.asm now accepts extended scancodes (modified by Bart, fixes + bug #1657) * added BOOTONLY option to SYS (modified by Bart) + Changes David Bolen * add support for UNC-style paths (that start with "\\") @@ -47,9 +48,9 @@ [cs:_DGROUP_] * Fix problem with attributes with the volume label bit + findnext * SYS: avoid copying kernel.sys and command.com if the destination - is identical to the source. + is identical to the source (fixes bug #1656). * Fix bug in DeleteBlockInBufferCache: needs to make the block - invalid, not flush it, if we're writing. + invalid, not flush it, if we're writing (bug #1635). * added switches=/k/n/f support to the config.sys parser. 2003 Mar 14 - Build 2029 -------- Bart Oldeman (bart@dosemu.org) From 204382d0010000f7e7201b48459a6db362d52866 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Wed, 18 Jun 2003 19:27:40 +0000 Subject: [PATCH 231/671] Adjustment to compile with Turbo C git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@619 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/main.c b/kernel/main.c index f0c29c30..157d9d88 100644 --- a/kernel/main.c +++ b/kernel/main.c @@ -688,7 +688,7 @@ void CheckContinueBootFromHarddisk(void) key = GetBiosKey(InitKernelConfig.BootHarddiskSeconds); - if (key != (UWORD)-1 && (key & 0xff) != 'h' && (key & 0xff) != 'H' ) + if (key != -1 && (key & 0xff) != 'h' && (key & 0xff) != 'H') { /* user has hit a key, continue to boot from floppy/CD */ printf("\n"); From 50181938f31368bb1b4c89abaded1e2224ba826e Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Wed, 18 Jun 2003 19:40:32 +0000 Subject: [PATCH 232/671] correct extension git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@620 6ac86273-5f31-0410-b378-82cca8765d1b --- makefile | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/makefile b/makefile index c87a2856..2cc1e694 100644 --- a/makefile +++ b/makefile @@ -2,10 +2,10 @@ all: build -bin\kwc8616.zip: +bin\kwc8616.sys: build -r wc 86 fat16 -bin\kwc8632.zip: +bin\kwc8632.sys: build -r wc 86 fat32 #use as follows: wmake -ms zip VERSION=2029 @@ -17,7 +17,7 @@ zip_src: BINLIST1 = doc bin/kernel.sys bin/sys.com bin/command.com bin/config.sys BINLIST2 = bin/autoexec.bat bin/command.com bin/install.bat -zipfat16: bin\kwc8616.zip +zipfat16: bin\kwc8616.sys mkdir doc copy docs\*.txt doc copy docs\*.cvs doc @@ -25,13 +25,13 @@ zipfat16: bin\kwc8616.zip copy docs\*.lsm doc del doc\build.txt del doc\lfnapi.txt - copy bin\kwc8616.zip bin\kernel.sys + copy bin\kwc8616.sys bin\kernel.sys zip -9 -r -k ../ke$(VERSION)_16.zip $(BINLIST1) zip -9 -r -k ../ke$(VERSION)_16.zip $(BINLIST2) utils\rmfiles doc\*.txt doc\*.cvs doc\*.lsm doc\copying rmdir doc -zipfat32: bin\kwc8632.zip +zipfat32: bin\kwc8632.sys mkdir doc copy docs\*.txt doc copy docs\*.cvs doc @@ -39,10 +39,11 @@ zipfat32: bin\kwc8632.zip copy docs\*.lsm doc del doc\build.txt del doc\lfnapi.txt - copy bin\kwc8632.zip bin\kernel.sys + copy bin\kwc8632.sys bin\kernel.sys zip -9 -r -k ../ke$(VERSION)_32.zip $(BINLIST1) zip -9 -r -k ../ke$(VERSION)_32.zip $(BINLIST2) utils\rmfiles doc\*.txt doc\*.cvs doc\*.lsm doc\copying rmdir doc -zip: zip_src zipfat16 zipfat32 \ No newline at end of file +zip: zip_src zipfat16 zipfat32 + From 5bffd69d1d5afdea36a220a62976c0cf16cd4744 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Fri, 20 Jun 2003 00:05:44 +0000 Subject: [PATCH 233/671] Fix bug in block device driver init of DPBs git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@622 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/config.c | 4 ++++ kernel/main.c | 2 -- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/kernel/config.c b/kernel/config.c index bf98a112..c1cf321c 100644 --- a/kernel/config.c +++ b/kernel/config.c @@ -361,6 +361,8 @@ void PreConfig2(void) /* Also, run config.sys to load drivers. */ void PostConfig(void) { + struct dpb FAR *old_dpbp; + /* We could just have loaded FDXMS or HIMEM */ if (HMAState == HMA_REQ && MoveKernelToHMA()) HMAState = HMA_DONE; @@ -401,8 +403,10 @@ void PostConfig(void) LoL->CDSp = KernelAlloc(sizeof(struct cds) * LoL->lastdrive, 'L', Config.cfgLastdriveHigh); + old_dpbp = LoL->DPBp; LoL->DPBp = KernelAlloc(blk_dev.dh_name[0] * sizeof(struct dpb), 'E', Config.cfgDosDataUmb); + fmemcpy(LoL->DPBp, old_dpbp, blk_dev.dh_name[0] * sizeof(struct dpb)); #ifdef DEBUG printf("Final: \n f_node 0x%x\n", LoL->f_nodes); diff --git a/kernel/main.c b/kernel/main.c index 157d9d88..1cf3ff43 100644 --- a/kernel/main.c +++ b/kernel/main.c @@ -275,8 +275,6 @@ STATIC void init_kernel(void) /* and do final buffer allocation. */ PostConfig(); - LoL->nblkdev = 0; - update_dcb(&blk_dev); /* Init the file system one more time */ FsConfig(); From c5c7128a02502ad9258be41e4f0c3a79b5da7ce2 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Fri, 20 Jun 2003 19:54:18 +0000 Subject: [PATCH 234/671] Move externs to header files; sft init cleanup (+3 files need to be low) git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@623 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/config.c | 110 ++++++---------------------------------------- kernel/dyninit.c | 1 - kernel/init-mod.h | 82 ++++++++++++++++++++++++++++++++-- kernel/initclk.c | 2 - kernel/initdisk.c | 11 ----- kernel/inithma.c | 33 -------------- kernel/initoem.c | 1 - kernel/main.c | 70 ++++++++++------------------- 8 files changed, 115 insertions(+), 195 deletions(-) diff --git a/kernel/config.c b/kernel/config.c index c1cf321c..2cd2561d 100644 --- a/kernel/config.c +++ b/kernel/config.c @@ -29,9 +29,7 @@ #include "portab.h" #include "init-mod.h" -#include "init-dat.h" #include "dyndata.h" -#include "lol.h" #ifdef VERSION_STRINGS static BYTE *RcsId = @@ -45,27 +43,6 @@ static BYTE *RcsId = #endif #define para2far(seg) ((mcb FAR *)MK_FP((seg), 0)) -/* - These are the far variables from the DOS data segment that we need here. The - init procedure uses a different default DS data segment, which is discarded - after use. I hope to clean this up to use the DOS List of List and Swappable - Data Area obtained via INT21. - - -- Bart - */ - -extern struct dhdr -DOSTEXTFAR ASM blk_dev; /* Block device (Disk) driver */ -extern struct buffer FAR *DOSFAR firstAvailableBuf; /* first 'available' buffer */ -extern struct lol ASM DOSFAR DATASTART; -struct lol FAR *LoL = &DATASTART; - -extern BYTE DOSFAR _HMATextAvailable, /* first byte of available CODE area */ - FAR _HMATextStart[], /* first byte of HMAable CODE area */ - FAR _HMATextEnd[], DOSFAR ASM break_ena, /* break enabled flag */ - DOSFAR _InitTextStart, /* first available byte of ram */ - DOSFAR ReturnAnyDosVersionExpected; - UWORD umb_start = 0, UMB_top = 0; UWORD ram_top = 0; /* How much ram in Kbytes */ @@ -273,22 +250,17 @@ void PreConfig(void) #ifdef DEBUG { - extern BYTE FAR ASM internal_data[]; printf("SDA located at 0x%p\n", internal_data); } #endif /* Begin by initializing our system buffers */ - /* the dms_scratch buffer is statically allocated - in the DSK module */ - /* dma_scratch = (BYTE FAR *) KernelAllocDma(BUFFERSIZE); */ -/* DebugPrintf(("Preliminary DMA scratchpad allocated at 0x%p\n",dma_scratch));*/ - -/* buffers = (struct buffer FAR *) - KernelAlloc(Config.cfgBuffers * sizeof(struct buffer)); */ #ifdef DEBUG /* printf("Preliminary %d buffers allocated at 0x%p\n", Config.cfgBuffers, buffers);*/ #endif + LoL->DPBp = + DynAlloc("DPBp", blk_dev.dh_name[0], sizeof(struct dpb)); + /* Initialize the file table */ /* f_nodes = (f_node_ptr) KernelAlloc(Config.cfgFiles * sizeof(struct f_node));*/ @@ -305,19 +277,13 @@ void PreConfig(void) config_init_buffers(Config.cfgBuffers); - LoL->sfthead->sftt_next = - KernelAlloc(sizeof(sftheader) + (Config.cfgFiles - 5) * sizeof(sft), 'F', 0); - LoL->sfthead->sftt_next->sftt_next = (sfttbl FAR *) - 1; - LoL->sfthead->sftt_next->sftt_count = Config.cfgFiles - 5; LoL->CDSp = KernelAlloc(sizeof(struct cds) * LoL->lastdrive, 'L', 0); - LoL->DPBp = KernelAlloc(blk_dev.dh_name[0] * sizeof(struct dpb), 'E', 0); - #ifdef DEBUG printf("Preliminary:\n f_node 0x%x", LoL->f_nodes); /* printf(" FCB table 0x%p\n",LoL->FCBp);*/ - printf(" sft table 0x%p\n", LoL->sfthead->sftt_next); + printf(" sft table 0x%p\n", LoL->sfthead); printf(" CDS table 0x%p\n", LoL->CDSp); printf(" DPB table 0x%p\n", LoL->DPBp); #endif @@ -355,13 +321,17 @@ void PreConfig2(void) mcb_init(LoL->first_mcb, ram_top * 64 - LoL->first_mcb - 1); if (UmbState == 2) umb_init(); + + LoL->sfthead->sftt_next = KernelAlloc(sizeof(sftheader) + 3 * sizeof(sft), 'F', 0); + LoL->sfthead->sftt_next->sftt_next = (sfttbl FAR *) - 1; + LoL->sfthead->sftt_next->sftt_count = 3; } /* Do third pass initialization. */ /* Also, run config.sys to load drivers. */ void PostConfig(void) { - struct dpb FAR *old_dpbp; + sfttbl FAR *sp; /* We could just have loaded FDXMS or HIMEM */ if (HMAState == HMA_REQ && MoveKernelToHMA()) @@ -374,8 +344,6 @@ void PostConfig(void) Config.cfgStacksHigh = TRUE; } - /* close all (device) files */ - /* compute lastdrive ... */ LoL->lastdrive = Config.cfgLastdrive; if (LoL->lastdrive < LoL->nblkdev) @@ -395,19 +363,15 @@ void PostConfig(void) /* LoL->FCBp = (sfttbl FAR *)&FcbSft; */ /* LoL->FCBp = KernelAlloc(sizeof(sftheader) + Config.cfgFiles * sizeof(sft)); */ - LoL->sfthead->sftt_next = (sfttbl FAR *) - KernelAlloc(sizeof(sftheader) + (Config.cfgFiles - 5) * sizeof(sft), 'F', + sp = LoL->sfthead->sftt_next; + sp = sp->sftt_next = (sfttbl FAR *) + KernelAlloc(sizeof(sftheader) + (Config.cfgFiles - 8) * sizeof(sft), 'F', Config.cfgFilesHigh); - LoL->sfthead->sftt_next->sftt_next = (sfttbl FAR *) - 1; - LoL->sfthead->sftt_next->sftt_count = Config.cfgFiles - 5; + sp->sftt_next = (sfttbl FAR *) - 1; + sp->sftt_count = Config.cfgFiles - 8; LoL->CDSp = KernelAlloc(sizeof(struct cds) * LoL->lastdrive, 'L', Config.cfgLastdriveHigh); - old_dpbp = LoL->DPBp; - LoL->DPBp = KernelAlloc(blk_dev.dh_name[0] * sizeof(struct dpb), 'E', - Config.cfgDosDataUmb); - fmemcpy(LoL->DPBp, old_dpbp, blk_dev.dh_name[0] * sizeof(struct dpb)); - #ifdef DEBUG printf("Final: \n f_node 0x%x\n", LoL->f_nodes); /* printf(" FCB table 0x%p\n",LoL->FCBp);*/ @@ -951,8 +915,6 @@ STATIC VOID Dosmem(BYTE * pLine) BYTE *pTmp; BYTE UMBwanted = FALSE; -/* extern BYTE FAR INITDataSegmentClaimed; */ - pLine = GetStringArg(pLine, szBuf); for (pTmp = szBuf; *pTmp != '\0'; pTmp++) @@ -997,8 +959,6 @@ STATIC VOID DosData(BYTE * pLine) { BYTE *pTmp; -/* extern BYTE FAR INITDataSegmentClaimed; */ - pLine = GetStringArg(pLine, szBuf); for (pTmp = szBuf; *pTmp != '\0'; pTmp++) @@ -1018,7 +978,6 @@ STATIC VOID CfgSwitchar(BYTE * pLine) STATIC VOID CfgSwitches(BYTE * pLine) { - extern unsigned char FAR kbdType; pLine = skipwh(pLine); if (commands[0].pass == 0) { if ('=' != *pLine) @@ -1201,8 +1160,6 @@ STATIC VOID CfgBreak(BYTE * pLine) STATIC VOID Numlock(BYTE * pLine) { - extern VOID ASMCFUNC keycheck(void); - /* Format: NUMLOCK = (ON | OFF) */ BYTE FAR *keyflags = (BYTE FAR *) MK_FP(0x40, 0x17); @@ -1861,38 +1818,12 @@ STATIC VOID CfgMenuDefault(BYTE * pLine) } } - - - - /********************************************************************************* National specific things. this handles only Date/Time/Currency, and NOT codepage things. Some may consider this a hack, but I like to see 24 Hour support. tom. *********************************************************************************/ - -struct CountrySpecificInfo { - short CountryID; /* = W1 W437 # Country ID & Codepage */ - short CodePage; - short DateFormat; /* Date format: 0/1/2: U.S.A./Europe/Japan */ - char CurrencyString[5]; /* '$' ,'EUR' */ - char ThousandSeparator[2]; /* ',' # Thousand's separator */ - char DecimalPoint[2]; /* '.' # Decimal point */ - char DateSeparator[2]; /* '-' */ - char TimeSeparator[2]; /* ':' */ - char CurrencyFormat; /* = 0 # Currency format (bit array) - 0Fh BYTE currency format - bit 2 = set if currency symbol replaces decimal point - bit 1 = number of spaces between value and currency symbol - bit 0 = 0 if currency symbol precedes value - 1 if currency symbol follows value - */ - char CurrencyPrecision; /* = 2 # Currency precision */ - char TimeFormat; /* = 0 # time format: 0/1: 12/24 houres */ -}; - - #define _DATE_MDY 0 /* mm/dd/yy */ #define _DATE_DMY 1 /* dd.mm.yy */ #define _DATE_YMD 2 /* yy/mm/dd */ @@ -2299,18 +2230,6 @@ struct CountrySpecificInfo specificCountriesSupported[] = { Aitor Santamar­a Merino (SP) */ - - -extern struct { - char ThisIsAConstantOne; - short TableSize; - - struct CountrySpecificInfo C; - -} FAR nlsCountryInfoHardcoded; - - - STATIC int LoadCountryInfoHardCoded(char *filename, COUNT ctryCode, COUNT codePage) { int i; @@ -2440,7 +2359,6 @@ VOID DoInstall(void) { int i; iregs r; - extern BYTE ASM _init_end[]; unsigned short installMemory; diff --git a/kernel/dyninit.c b/kernel/dyninit.c index 417488d4..46acb1a9 100644 --- a/kernel/dyninit.c +++ b/kernel/dyninit.c @@ -38,7 +38,6 @@ kernel layout: #include "portab.h" #include "init-mod.h" #include "dyndata.h" -#include "lol.h" #if defined(DEBUG) #define DebugPrintf(x) printf x diff --git a/kernel/init-mod.h b/kernel/init-mod.h index 9bf571f2..9b71929b 100644 --- a/kernel/init-mod.h +++ b/kernel/init-mod.h @@ -20,6 +20,9 @@ #include "nls.h" #include "buffer.h" #include "dcb.h" +#include "lol.h" + +#include "init-dat.h" #include "kconfig.h" extern struct _KernelConfig InitKernelConfig; @@ -49,6 +52,7 @@ void strcpy(char *dest, const char *src); /*inithma.c*/ extern BYTE DosLoadedInHMA; int fmemcmp(BYTE far * s1, BYTE FAR * s2, unsigned len); +void MoveKernel(unsigned NewKernelSegment); #define setvec(n, isr) (void)(*(intvec FAR *)MK_FP(0,4 * (n)) = (isr)) @@ -122,6 +126,7 @@ COUNT ASMCFUNC Umb_Test(void); COUNT ASMCFUNC UMB_get_largest(UCOUNT * seg, UCOUNT * size); BYTE * GetStringArg(BYTE * pLine, BYTE * pszString); void DoInstall(void); +UWORD GetBiosKey(int timeout); /* diskinit.c */ COUNT dsk_init(VOID); @@ -185,10 +190,83 @@ VOID init_fatal(BYTE * err_msg); WORD CDECL init_printf(CONST BYTE * fmt, ...); WORD CDECL init_sprintf(BYTE * buff, CONST BYTE * fmt, ...); -void MoveKernel(unsigned NewKernelSegment); +/* initclk.c */ +extern void Init_clk_driver(void); + extern UWORD HMAFree; /* first byte in HMA not yet used */ extern unsigned CurrentKernelSegment; +extern struct _KernelConfig FAR ASM LowKernelConfig; +extern WORD days[2][13]; +extern BYTE FAR *lpOldTop; +extern BYTE FAR *lpTop; +extern BYTE ASM _ib_start[], ASM _ib_end[], ASM _init_end[]; +extern UWORD ram_top; /* How much ram in Kbytes */ +extern char MenuSelected; +extern unsigned Menus; +extern char singleStep; +extern char SkipAllConfig; + +extern struct lol FAR *LoL; + +extern struct dhdr DOSTEXTFAR ASM blk_dev; /* Block device (Disk) driver */ + +extern struct buffer FAR *DOSFAR firstAvailableBuf; /* first 'available' buffer */ +extern struct lol ASM DOSFAR DATASTART; + +extern BYTE DOSFAR ASM _HMATextAvailable, /* first byte of available CODE area */ + FAR ASM _HMATextStart[], /* first byte of HMAable CODE area */ + FAR ASM _HMATextEnd[], DOSFAR ASM break_ena, /* break enabled flag */ + DOSFAR _InitTextStart, /* first available byte of ram */ + DOSFAR ReturnAnyDosVersionExpected; + +extern BYTE FAR ASM internal_data[]; +extern unsigned char FAR kbdType; + +extern struct { + char ThisIsAConstantOne; + short TableSize; + + struct CountrySpecificInfo C; + +} FAR nlsCountryInfoHardcoded; + +/* + data shared between DSK.C and INITDISK.C +*/ + +extern UWORD DOSFAR LBA_WRITE_VERIFY; + +/* floppy parameter table, at 70:xxxx */ +extern unsigned char DOSTEXTFAR ASM int1e_table[0xe]; + +struct RelocationTable { + UBYTE jmpFar; + UWORD jmpOffset; + UWORD jmpSegment; + UBYTE callNear; + UWORD callOffset; +}; + +struct RelocatedEntry { + UBYTE callNear; + UWORD callOffset; + UBYTE jmpFar; + UWORD jmpOffset; + UWORD jmpSegment; +}; + +extern struct RelocationTable + DOSTEXTFAR ASM _HMARelocationTableStart[], + DOSTEXTFAR ASM _HMARelocationTableEnd[]; + +extern void FAR *DOSTEXTFAR ASM XMSDriverAddress; +extern VOID ASMCFUNC FAR _EnableA20(VOID); +extern VOID ASMCFUNC FAR _DisableA20(VOID); + +extern void FAR * ASMCFUNC DetectXMSDriver(VOID); +extern int ASMCFUNC init_call_XMScall(void FAR * driverAddress, UWORD ax, + UWORD dx); #if defined(WATCOM) && 0 ULONG ASMCFUNC FAR MULULUS(ULONG mul1, UWORD mul2); /* MULtiply ULong by UShort */ @@ -197,5 +275,3 @@ ULONG ASMCFUNC FAR DIVULUS(ULONG mul1, UWORD mul2); /* DIVide ULong by UShor ULONG ASMCFUNC FAR DIVMODULUS(ULONG mul1, UWORD mul2, UWORD * rem); /* DIVide ULong by UShort */ #endif -extern struct lol FAR *LoL; - diff --git a/kernel/initclk.c b/kernel/initclk.c index b19a907f..b895e74b 100644 --- a/kernel/initclk.c +++ b/kernel/initclk.c @@ -28,8 +28,6 @@ #include "portab.h" #include "init-mod.h" -#include "init-dat.h" -#include "lol.h" #ifdef VERSION_STRINGS static char *RcsId = diff --git a/kernel/initdisk.c b/kernel/initdisk.c index dda83480..02044666 100644 --- a/kernel/initdisk.c +++ b/kernel/initdisk.c @@ -26,9 +26,7 @@ #include "portab.h" #include "init-mod.h" -#include "init-dat.h" #include "dyndata.h" -#include "lol.h" #ifdef VERSION_STRINGS static BYTE *dskRcsId = "$Id$"; @@ -37,15 +35,6 @@ static BYTE *dskRcsId = UBYTE InitDiskTransferBuffer[SEC_SIZE]; COUNT nUnits; -/* - data shared between DSK.C and INITDISK.C -*/ - -extern UWORD DOSFAR LBA_WRITE_VERIFY; - -/* floppy parameter table, at 70:xxxx */ -extern unsigned char DOSTEXTFAR ASM int1e_table[0xe]; - /* * Rev 1.0 13 May 2001 tom ehlert * Initial revision. diff --git a/kernel/inithma.c b/kernel/inithma.c index 9db01d87..77637210 100644 --- a/kernel/inithma.c +++ b/kernel/inithma.c @@ -65,12 +65,6 @@ #include "portab.h" #include "init-mod.h" -#include "init-dat.h" -#include "lol.h" - -extern BYTE FAR ASM _HMATextAvailable, /* first byte of available CODE area */ - FAR ASM _HMATextStart[], /* first byte of HMAable CODE area */ - FAR ASM _HMATextEnd[]; /* and the last byte of it */ #ifdef VERSION_STRINGS static BYTE *RcsId = @@ -81,13 +75,6 @@ BYTE DosLoadedInHMA = FALSE; /* set to TRUE if loaded HIGH */ BYTE HMAclaimed = FALSE; /* set to TRUE if claimed from HIMEM */ UWORD HMAFree = 0; /* first byte in HMA not yet used */ -extern void FAR *DOSTEXTFAR ASM XMSDriverAddress; -VOID ASMCFUNC FAR _EnableA20(VOID); -VOID ASMCFUNC FAR _DisableA20(VOID); - -void FAR * ASMCFUNC DetectXMSDriver(VOID); -int ASMCFUNC init_call_XMScall(void FAR * driverAddress, UWORD ax, - UWORD dx); STATIC void InstallVDISK(void); #ifdef DEBUG @@ -109,8 +96,6 @@ void int3() #define HMAInitPrintf(x) #endif -void MoveKernel(unsigned NewKernelSegment); - #ifdef DEBUG VOID hdump(BYTE FAR * p) { @@ -381,24 +366,6 @@ void MoveKernel(unsigned NewKernelSegment) style table */ - struct RelocationTable { - UBYTE jmpFar; - UWORD jmpOffset; - UWORD jmpSegment; - UBYTE callNear; - UWORD callOffset; - }; - struct RelocatedEntry { - UBYTE callNear; - UWORD callOffset; - UBYTE jmpFar; - UWORD jmpOffset; - UWORD jmpSegment; - }; - extern struct RelocationTable - DOSTEXTFAR ASM _HMARelocationTableStart[], - DOSTEXTFAR ASM _HMARelocationTableEnd[]; - struct RelocationTable FAR *rp, rtemp; /* verify, that all entries are valid */ diff --git a/kernel/initoem.c b/kernel/initoem.c index 58ef9b91..ca0b0949 100644 --- a/kernel/initoem.c +++ b/kernel/initoem.c @@ -29,7 +29,6 @@ #include "portab.h" #include "init-mod.h" -#include "lol.h" #ifdef VERSION_STRINGS static BYTE *RcsId = diff --git a/kernel/main.c b/kernel/main.c index 1cf3ff43..a3029479 100644 --- a/kernel/main.c +++ b/kernel/main.c @@ -30,45 +30,21 @@ #include "portab.h" #include "init-mod.h" #include "dyndata.h" -#include "init-dat.h" -#include "lol.h" -char copyright[] = +#ifdef VERSION_STRINGS +static BYTE *mainRcsId = + "$Id$"; +#endif + +static char copyright[] = "(C) Copyright 1995-2003 Pasquale J. Villani and The FreeDOS Project.\n" "All Rights Reserved. This is free software and comes with ABSOLUTELY NO\n" "WARRANTY; you can redistribute it and/or modify it under the terms of the\n" "GNU General Public License as published by the Free Software Foundation;\n" "either version 2, or (at your option) any later version.\n"; -/* - These are the far variables from the DOS data segment that we need here. The - init procedure uses a different default DS data segment, which is discarded - after use. I hope to clean this up to use the DOS List of List and Swappable - Data Area obtained via INT21. - - -- Bart - */ - -extern struct dhdr ASM DOSTEXTFAR con_dev, /* console device drive */ - DOSTEXTFAR ASM clk_dev, /* Clock device driver */ - DOSTEXTFAR ASM blk_dev; /* Block device (Disk) driver */ -extern BYTE FAR ASM _HMATextEnd[]; - -extern struct _KernelConfig FAR ASM LowKernelConfig; - -#ifdef VERSION_STRINGS -static BYTE *mainRcsId = - "$Id$"; -#endif - struct _KernelConfig InitKernelConfig = { "", 0, 0, 0, 0, 0, 0, 0 }; -extern WORD days[2][13]; -extern BYTE FAR *lpOldTop; -extern BYTE FAR *lpTop; -extern BYTE ASM _ib_start[], ASM _ib_end[], ASM _init_end[]; -extern UWORD ram_top; /* How much ram in Kbytes */ - STATIC VOID InitIO(void); STATIC VOID update_dcb(struct dhdr FAR *); @@ -77,9 +53,7 @@ STATIC VOID signon(VOID); STATIC VOID kernel(VOID); STATIC VOID FsConfig(VOID); STATIC VOID InitPrinters(VOID); -void CheckContinueBootFromHarddisk(void); - -extern void Init_clk_driver(void); +STATIC void CheckContinueBootFromHarddisk(void); #ifdef _MSC_VER BYTE _acrtused = 0; @@ -93,6 +67,8 @@ __segment DosTextSeg = 0; #endif +struct lol FAR *LoL = &DATASTART; + /* little functions - could be ASM but does not really matter in this context */ void memset(void *s, int c, unsigned n) { @@ -269,6 +245,7 @@ STATIC void init_kernel(void) /* and process CONFIG.SYS one last time for device drivers */ DoConfig(2); + /* Close all (device) files */ for (i = 0; i < LoL->lastdrive; i++) close(i); @@ -278,7 +255,7 @@ STATIC void init_kernel(void) /* Init the file system one more time */ FsConfig(); - + configDone(); InitializeAllBPBs(); @@ -286,10 +263,8 @@ STATIC void init_kernel(void) STATIC VOID FsConfig(VOID) { - REG COUNT i; - struct dpb FAR *dpb; - - dpb = LoL->DPBp; + struct dpb FAR *dpb = LoL->DPBp; + int i; /* Initialize the current directory structures */ for (i = 0; i < LoL->lastdrive; i++) @@ -380,9 +355,6 @@ STATIC void kernel() CommandTail Cmd; int rc; - extern char MenuSelected; - extern unsigned Menus; - BYTE master_env[32]; char *masterenv_ptr = master_env; @@ -415,8 +387,6 @@ STATIC void kernel() if (Cmd.ctCount < sizeof(Cmd.ctBuffer) - 3) { - extern int singleStep; - extern int SkipAllConfig; char *insertString = NULL; if (singleStep) @@ -581,10 +551,16 @@ BOOL init_device(struct dhdr FAR * dhp, char *cmdLine, COUNT mode, STATIC void InitIO(void) { + struct dhdr far *device = &LoL->nul_dev; + /* Initialize driver chain */ setvec(0x29, int29_handler); /* Requires Fast Con Driver */ - init_device(&con_dev, NULL, NULL, lpTop); - init_device(&clk_dev, NULL, NULL, lpTop); + device = &LoL->nul_dev; + do { + init_device(device, NULL, NULL, lpTop); + device = device->dh_next; + } + while (FP_OFF(device) != 0xffff); } /* issue an internal error message */ @@ -630,8 +606,6 @@ STATIC VOID InitPrinters(VOID) booted from HD */ -extern UWORD GetBiosKey(int timeout); - EmulatedDriveStatus(int drive,char statusOnly) { iregs r; @@ -650,7 +624,7 @@ EmulatedDriveStatus(int drive,char statusOnly) return TRUE; } -void CheckContinueBootFromHarddisk(void) +STATIC void CheckContinueBootFromHarddisk(void) { char *bootedFrom = "Floppy/CD"; iregs r; From 2fdf99331d62b95df7012940872ac354a87ef72d Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Fri, 20 Jun 2003 20:06:24 +0000 Subject: [PATCH 235/671] Added structure to nls.h; small main.c cleanup. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@624 6ac86273-5f31-0410-b378-82cca8765d1b --- hdr/nls.h | 20 ++++++++++++++++++++ kernel/main.c | 1 - 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/hdr/nls.h b/hdr/nls.h index cf9c8492..a4a7c091 100644 --- a/hdr/nls.h +++ b/hdr/nls.h @@ -332,6 +332,26 @@ /* No codepage / country code given */ #define NLS_DEFAULT ((UWORD)-1) +struct CountrySpecificInfo { + short CountryID; /* = W1 W437 # Country ID & Codepage */ + short CodePage; + short DateFormat; /* Date format: 0/1/2: U.S.A./Europe/Japan */ + char CurrencyString[5]; /* '$' ,'EUR' */ + char ThousandSeparator[2]; /* ',' # Thousand's separator */ + char DecimalPoint[2]; /* '.' # Decimal point */ + char DateSeparator[2]; /* '-' */ + char TimeSeparator[2]; /* ':' */ + char CurrencyFormat; /* = 0 # Currency format (bit array) + 0Fh BYTE currency format + bit 2 = set if currency symbol replaces decimal point + bit 1 = number of spaces between value and currency symbol + bit 0 = 0 if currency symbol precedes value + 1 if currency symbol follows value + */ + char CurrencyPrecision; /* = 2 # Currency precision */ + char TimeFormat; /* = 0 # time format: 0/1: 12/24 houres */ +}; + /* * This is the data in the exact order returned by DOS-65-01 */ diff --git a/kernel/main.c b/kernel/main.c index a3029479..7c87242b 100644 --- a/kernel/main.c +++ b/kernel/main.c @@ -555,7 +555,6 @@ STATIC void InitIO(void) /* Initialize driver chain */ setvec(0x29, int29_handler); /* Requires Fast Con Driver */ - device = &LoL->nul_dev; do { init_device(device, NULL, NULL, lpTop); device = device->dh_next; From 4780a1fc943f22fc672cac7668b47454472669e5 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Fri, 27 Jun 2003 22:02:57 +0000 Subject: [PATCH 236/671] NLS changes from Steffen git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@625 6ac86273-5f31-0410-b378-82cca8765d1b --- hdr/nls.h | 69 +++++++-- kernel/nls.c | 6 +- kernel/nls_load.c | 383 ++-------------------------------------------- 3 files changed, 76 insertions(+), 382 deletions(-) diff --git a/hdr/nls.h b/hdr/nls.h index a4a7c091..4dcf0c71 100644 --- a/hdr/nls.h +++ b/hdr/nls.h @@ -284,8 +284,12 @@ /* * How the kernel and NLSFUNC communicate with each other */ - /* Must be returned by NLSFUNC upon MUX-14-00 */ + /* Must be pased to and returned by NLSFUNC upon MUX-14-00 */ #define NLS_FREEDOS_NLSFUNC_ID 0x534b + /* What version of nlsInfo and accompanying associations + Must be passed to NLSFUNC upon MUX-14-00 to identify the + correct kernel to the tools. */ +#define NLS_FREEDOS_NLSFUNC_VERSION 0xFD01 /* Represents a call to DOS-38 within DOS-65 handlers. Current implementation relys on 0x101! */ #define NLS_DOS_38 0x101 @@ -324,10 +328,10 @@ #define NLS_FLAG_DIRECT_YESNO 0x0004 /* DOS-65-23 */ #define NLS_FLAG_DIRECT_GETDATA 0x0008 /* DOS-65-XX, DOS-38 */ -#define NLS_FLAG_HARDCODED NLS_FLAG_DIRECT_UPCASE \ +#define NLS_FLAG_HARDCODED (NLS_FLAG_DIRECT_UPCASE \ | NLS_FLAG_DIRECT_FUPCASE \ | NLS_FLAG_DIRECT_YESNO \ - | NLS_FLAG_DIRECT_GETDATA + | NLS_FLAG_DIRECT_GETDATA) /* No codepage / country code given */ #define NLS_DEFAULT ((UWORD)-1) @@ -535,8 +539,9 @@ extern BYTE FAR hcTablesStart[], hcTablesEnd[]; COUNTRY.SYS into other files. */ -#define CSYS_FD_IDSTRING "FreeDOS COUNTRY.SYS v1.0\r\n" +#define CSYS_FD_IDSTRING "FreeDOS COUNTRY.SYS v1.0\r\n\x1a" +#if 0 struct csys_function { /* S3: function definition */ UDWORD csys_rpos; /* relative position to actual data */ UWORD csys_length; @@ -550,20 +555,62 @@ struct csys_ccDefinition { /* S1: country/codepage reference */ UWORD csys_cp; UWORD csys_cntry; }; +#endif + +struct csys_ccDefinition { /* country/codepage reference */ + UDWORD csys_pos; /* moving the 4byte value to the front + can increase performance */ + UWORD csys_cntry; + UWORD csys_cp; + UWORD csys_size1; /* size of nlsPackage struct rpos is pointing to */ + +/* initially the object rpos is pointing to conforms to a + struct nlsPackage, where: + struct nlsPackage FAR *nxt; is missing + UWORD cntry, cp; is missing + int flags; is NLS_FLAG_HARDCODED, if the + kernel is to handle the data of its own + UBYTE yeschar; is filled + UBYTE nochar; is filled + unsigned numSubfct; is filled + struct nlsPointer nlsPointers[1]; is filled + the pointer member is the absolute + position of the data within the file + of this structure: + UWORD count + count bytes + The "count" value is not a part + of the data itself. + Also: The data must be ordered corresponding to + NLS_CODE_REORDER_POINTERS. + Also: The last nlsPointer is subfct #1 _incl_ all its + data [is the extended country information: struct nlsExtCntryInfo] +*/ +}; struct csys_numEntries { /* helper structure for "number of entries" */ UWORD csys_entries; }; -/* Actually, this structure is never really used */ -struct nlsCSys_fileHeader { /* S0: primary structure */ - unsigned char csys_idstring[sizeof(CSYS_FD_IDSTRING) - 1]; - /* decrement by 1 to cut off \0 from IDString -- ska */ +/* Header of the COUNTRY.SYS file */ +struct nlsCSys_fileHeader { /* COUNTRY.SYS header */ + unsigned char csys_idstring[sizeof(CSYS_FD_IDSTRING)]; + UWORD csys_maxTotalSize; /* maximal size of the total amount of + any individual definition, that includes + the nlsPackage skeleton and the sum of + all bytes required to load all the + subfunctions individually. + --> The code is to allocate maxTotalSize + and load any country definition of this + file into this buffer without any + overflow. */ + DWORD csys_posIndex; /* absolute position of index table */ }; -struct csys_completeFileHeader { /* as S0, but full 128 bytes */ - unsigned char csys_idstring[sizeof(CSYS_FD_IDSTRING) - 1]; - unsigned char csys_padbytes[128 - (sizeof(CSYS_FD_IDSTRING) - 1)]; +/* Structure created by CountryInfoLoad() */ +struct nlsCSys_loadPackage { + UWORD csys_size; + struct nlsPackage csys_pkg; }; /* standard alignment */ diff --git a/kernel/nls.c b/kernel/nls.c index 5b8b7f32..74a0a39d 100644 --- a/kernel/nls.c +++ b/kernel/nls.c @@ -130,7 +130,11 @@ COUNT muxLoadPkg(UWORD cp, UWORD cntry) /* 0x1401 == not installed, not ok to install */ /* 0x14FF == installed */ - r.BX = 0; /* make sure the NLSFUNC ID is updated */ + r.BX = NLS_FREEDOS_NLSFUNC_VERSION; /* What version of nlsInfo */ +#if NLS_FREEDOS_NLSFUNC_VERSION == NLS_FREEDOS_NLSFUNC_ID + /* make sure the NLSFUNC ID is updated */ +#error "NLS_FREEDOS_NLSFUNC_VERSION == NLS_FREEDOS_NLSFUNC_ID" +#endif r.CX = NLS_FREEDOS_NLSFUNC_ID; if (muxGo(0, &r) != 0x14ff) return DE_FILENOTFND; /* No NLSFUNC --> no load */ diff --git a/kernel/nls_load.c b/kernel/nls_load.c index 16d5122c..0a4fa655 100644 --- a/kernel/nls_load.c +++ b/kernel/nls_load.c @@ -36,373 +36,16 @@ static BYTE *RcsId = "$Id$"; #endif -#define filename Config.cfgCSYS_fnam -#define cntry Config.cfgCSYS_cntry -#define cp Config.cfgCSYS_cp - -STATIC int err(void) -{ - printf("Syntax error in or invalid COUNTRY.SYS: \"%s\"\n", filename); - return 0; -} - -#define readStruct(s) readStructure(&(s), sizeof(s), fd) -STATIC int readStructure(void *buf, unsigned size, COUNT fd) -{ - if (read(fd, buf, size) == size) - return 1; - - return err(); -} - - /* Evaluate each argument only once */ -#define readFct(p,f) readFct_((p), (f), fd) -int readFct_(void *buf, struct csys_function *fct, COUNT fd) -{ - if (lseek(fd, fct->csys_rpos, 0) >= 0) - return readStructure(buf, fct->csys_length, fd); - return err(); -} - -#define seek(n) rseek((LONG)(n), fd) -static int rseek(LONG rpos, COUNT fd) -{ - if (lseek(fd, rpos, 1) >= 0) - return 1; - - return err(); -} - -COUNT csysOpen(void) -{ - COUNT fd; - struct nlsCSys_fileHeader header; - - if ((fd = open(filename, 0)) < 0) - { - printf("Cannot open: \"%s\"\n", filename); - return 1; - } - - if ((read(fd, &header, sizeof(header)) != sizeof(header)) - ||strcmp(header.csys_idstring, CSYS_FD_IDSTRING) != 0 - || lseek(fd, (LONG) sizeof(struct csys_completeFileHeader), 0) - != (LONG) sizeof(struct csys_completeFileHeader)) - { - printf("No valid COUNTRY.SYS: \"%s\"\n\nTry NLSFUNC /i %s\n", filename, - filename); - close(fd); - return -1; - } - - return fd; -} - -/* Searches for function definition of table #fctID and - moves it at index idx */ -STATIC int chkTable(int idx, int fctID, struct csys_function *fcts, - int numFct) -{ - struct csys_function *fct, hfct; - int i; - - for (i = 0, fct = fcts; i < numFct; ++i, ++fct) - if (fct->csys_fctID == fctID) - { - /* function found */ - if (i == idx) /* already best place */ - return 1; - /* Swap both places */ - fmemcpy(&hfct, fct, sizeof(hfct)); - fmemcpy(fct, &fcts[idx], sizeof(hfct)); - fmemcpy(&fcts[idx], &hfct, sizeof(hfct)); - return 1; - } - - printf("Mandatory table %u not found.\n", fctID); - return 0; -} - -/* - * Description of the algorithm the COUNTRY= information is loaded. - -1) LoadCountry() is activated in pass 1, because it offers the functionality -how to upcase characters to the kernel, it should be activated as -soon as possible within processing CONFIG.SYS. - -2) The method to locate the actual data within COUNTRY.SYS is pretty -basic and straight forward; so no detailed description here. - -3) To reduce permanent memory useage the option NLS_MODIFYABLE_DATA -controls whether or not the loaded NLS pkg may be modified. By default, -modifying this data is _not_ supported. -The reason is to allow to re-use already loaded data, e.g. to use the -same physical table for #2 (normal upcase) and #4 (filename upcase). -NLSFUNC even can re-use the data loaded via COUNTRY= and the hardcoded data. - -4) The problem is that even without point 3) it is not easily possible to -pre-judge how many bytes the NLS pkg will allocate in memory, because -this NLS implementation wants to support a wider range of NLS pkgs; because -neither the number of subfunctions nor the size of the data per subfunction -is fixed globally. -Therefore, the package is built-up incrementally: -4.1) First all function definition structures (S3) are read into memory. -While doing so the position field is transformed into the absolute -position within COUNTRY.SYS. -4.2) Then they are checked if a subfunction is defined more than once. -4.3) Then the entries are sorted in that way that tables 0x23, 1, 2, 4 and 5 -lead the table in that order. -4.4) Then the basic nlsPackage with as many entries within nlsPointers[] -is allocated as there are function definitions left (minus one as the -pseudo-table 0x23 does not require an entry). -4.5) Pseudo-table 0x23 is installed. -4.6) Table 1 is installed at the very end of the nlsPointers[] array. -4.7) In the order all remaining function definitions are installed in -the same order as in the other array. - -5) "Installing" means (except table 0x23): -5.1) Enlarge the nlsPackage structure to hold the necessary bytes of the -function definition (member csys_length). -5.2) Only if NLS_MODIFYABLE_DATA is _not_ defined and table is not #1: -The loaded data is compared to already loaded data and if such pattern is -already found in memory, a pointer to that memory area is used and the -loaded data is discarded. -First the local data is searched through, then the area of the hardcoded -NLS pkg. -Efficiency: function definitions with the same file position can automatically -use the same memory area. - -6) When all function definitions are loaded, the nlsPackage structure is -tightly filled without any pad bytes; two areas are wasted: -a) The area containing the S3 structures, and -b) probably the last loaded data could be found within the memory already, -so the nlsPackage structure is larger than necessary. - -8) But the memory allocation in pass 1 is temporary anyway, because in -the PostConfig() phase, all memory allocations are revoked and created -anew. At this point -- immediately after revoking all memory and -_before_ allocating any new memory -- the NLS pkg is located completely -within memory and one knows exactly which bytes to spare, and which data -can share the same physical memory; but if the normal PostConfig() -process would go on, this information would be lost, because it could be -overwritten. -==> Therefore the almost first operation within PostConfig() is to -move the NLS pkg upto the top (base?) of memory, thus, making sure -it is not overwritten and one need not re-load all the structures from -memory and, by doing so, loose the information which memory can be shared. - -9) Once this operation has been completed, the NLS pkg is joined into the -nlsInfo chain of loaded packages and is made active. - -=== - -To ease implementation the value of FP_SEG(nlsPointers[].pointer) != 0, -if the pointer refers to an absolute place, whereas FP_SEG() == 0, -indicates that the FP_OFF(...) is the offset base-relative to the data -offset; which is base-relative to the "nls" pointer. - */ -int csysLoadPackage(COUNT fd) -{ - struct csys_numEntries entries; - struct csys_ccDefinition entry; - struct csys_function *fcts; - struct nlsPackage *nls; - struct nlsPointer *poi; - int highmark, numFct, i, j; - int totalSize; -#ifndef NLS_MODIFYABLE_DATA - BYTE FAR *p; -#endif -#define numE entries.csys_entries -#define bufp(offset) (((BYTE*)nls) + (offset)) -#define fct fcts[numFct] - - /* When this function is called, the position of the file is - at offset 128 (number of country/codepage pairs) */ - if (!readStruct(entries)) - return 0; - while (numE--) - { - if (!readStruct(entry)) - return 0; - if (entry.csys_cntry == cntry - && (cp == NLS_DEFAULT || entry.csys_cp == cp)) - { - /* Requested entry found! */ - if (!seek(entry.csys_rpos) || !readStruct(entries)) - return 0; - /* Now reading the function definitions at this position */ - if (numE < 5) - { - printf("Syntax error in COUNTRY.SYS: Too few subfunctions\n"); - return 0; - } - /* If the file structure is good, each but one entry (0x23) is - one item within nlsPointers[] array */ - fcts = KernelAlloc(sizeof(struct csys_function) * numE); - numFct = 0; /* number of already loaded fct definition */ - totalSize = 0; - { - if (!readStruct(fct)) - return 0; - switch (fct.csys_fctID) - { - case 0: - case 0x20: - case 0x21: - case 0x22: - case 0xA0: - case 0xA1: - case 0xA2: - printf("Invalid subfunction %u ignored", fct.csys_fctID); - continue; - case 0x23: - if (fct.csys_length != 2) - { - printf("Pseudo-table 35 length mismatch\n"); - continue; - } - } - /* Search if the subfunction is already there */ - for (j = 0; j < numFct && fcts[j].csys_fctID != fct.csys_fctID; - ++j) ; - if (j != numFct) - { - printf("Subfunction %u defined multiple times, ignored\n", - fct.csys_fctID); - continue; - } - - /* OK --> update the rpos member */ - fct.csys_rpos += DosLtell(fd); - totalSize += fct.csys_length; - ++numFct; - } - while (--numE) ; - - /* i is the number of available function definition */ - /* check if all mandatory tables are loaded, at the same - time re-order the function definitions like that: - 0x23, 1, 2, 4, 5 - */ - - /* That's automatically a check that more than 3 definitions - are available */ - if (!chkTable(0, 0x23, fcts, numFct) /* pseudo-table 0x23 yes/no */ - || !chkTable(1, 1, fcts, numFct) /* ext cntry info */ - || !chkTable(2, 2, fcts, numFct) /* normal upcase */ - || !chkTable(3, 4, fcts, numFct) /* filename upcase */ - || !chkTable(4, 5, fcts, numFct)) /* filename terminator chars */ - return 0; - - /* Begin the loading process by to allocate memory as if - we had to load every byte */ - /* One nlsPointers structure is already part of nlsPackage; - two function definitions need no nlsPointers entry (0x32, 1); - one additional byte is required by table 1, but which is - already within totalSize as the length of pseudo-table - 0x23 has been counted. */ - nls = KernelAlloc((data = sizeof(struct nlsPackage) - + (numFct - 3) * sizeof(struct nlsPointer)) + - totalSize); - /* data := first byte not used by the control area of - the nlsPackage structure; at this point it is the - offset where table #1 is to be loaded to */ - - /* Install pseudo-table 0x23 */ - if (!readFct((BYTE *) & nls->yeschar, fcts)) - return 0; - nls->numSubfct = numFct - 1; /* pseudo-table 0x23 */ - - /* Install table #1 has it must overlay the last nlsPointers[] - item */ - *bufp(data) = 1; /* table #1 starts with the subfctID - then the data from the file follows */ - if (!readFct(bufp(++data), ++fcts)) - return 0; - data += fcts->csys_length; /* first byte of local data area */ - highmark = data; /* first unused byte */ - - for (j = 0, poi = nls->nlsPointers; j < numFct - 1; ++j, ++poi) - { - /* consecutively load all functions */ - if (!readFct(bufp(data), ++fcts)) - return 0; - poi->subfct = fcts->csys_fctID; - /* Now the function data is located at the current top of - used memory and, if allowed, the other memory is - tested, if such image is already loaded */ -#ifndef NLS_MODIFYABLE_DATA - /* Try to locate the contents of the buffer */ - /** brute force **/ - /* For the standard tables one need to match tables - 2 and 4 only. */ - for (i = data; i + fcts->csys_length < highmark; ++i) - { - if (memcmp(bufp(i), bufp(highmark), fcts->csys_length) == 0) - { - /* found! */ - /* ==> leave highmark untouch, but modify pointer */ - poi->pointer = MK_FP(0, i); - /* the segment portion == 0 identifies this pointer - as local within the current data area */ - goto nxtEntry; - } - } - /* Now try the hardcoded area */ - for (p = hcTablesStart; p < hcTablesEnd - fcts->csys_length; ++p) - { - if (fmemcmp(p, bufp(highmark), fcts->csys_length) == 0) - { - /* found! */ - /* ==> leave highmark untouch, but modify pointer */ - poi->pointer = p; - /* the segment portion != 0 identifies this is an - absolute pointer */ - goto nxtEntry; - } - } -#endif - /* Either not found or modifyable data allowed */ - poi->pointer = MK_FP(0, highmark); /* local address */ - highmark += fcts->csys_length; /* need to keep the data */ - nxtEntry: - } - /* how many memory is really required */ - Country.cfgCSYS_memory = highmark; - Country.cfgCSYS_data = nls; - return 1; - } - } -#undef numE - if (cp == NLS_DEFAULT) - printf("No definition of country ID %u in file \"%s\"\n", - cntry, filename); - else - printf - ("No definition of country ID %u for codepage %u in file \"%s\"\n", - cntry, cp, filename); - - return 0; -} - -BOOL LoadCountryInfo(char *fnam) -{ - COUNT fd; - int rc; - - if (strlen(fnam) < sizeof(filename)) - { - strcpy(filename, fnam); - if ((fd = csysOpen()) >= 0) - { - rc = csysLoadPackage(fd); - close(fd); - return rc; - } - } - else - printf("Filename too long\n"); - return 0; -} - +/** Setup the environment for shared source NLS_LOAD.SRC **/ +/**ska obsoleted #define cfgMemory Config.cfgCSYS_memory */ +/**ska obsoleted #define cfgFilename Config.cfgCSYS_fnam */ +#define cfgFilename nlsInfo.fname /* char FAR * */ +/**ska obsoleted #define cfgCountry Config.cfgCSYS_cntry */ +/**ska obsoleted #define cfgCodepage Config.cfgCSYS_cp */ +#define cfgData Config.cfgCSYS_data /* struct nlsCSys_loadPackage FAR * */ +#define getMem(bytes) KernelAlloc(bytes) +#define openSYSFile(filename) open(filename, 0) /* read-only, binary */ +#define nlsStartOfChain nlsInfo.chain +#define upCaseFct CharMapSrvc + +#include "nls_load.src" From a69548773a60aae1ca9b7a54539a65ad6fa141b1 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Mon, 30 Jun 2003 18:36:30 +0000 Subject: [PATCH 237/671] Use PASCAL calling convention by default for turbo C git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@626 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/turboc.cfg | 1 + 1 file changed, 1 insertion(+) diff --git a/kernel/turboc.cfg b/kernel/turboc.cfg index 73162d23..f07a6c1c 100644 --- a/kernel/turboc.cfg +++ b/kernel/turboc.cfg @@ -11,4 +11,5 @@ -w -g1 -I..\hdr +-p -v- -I. -D__STDC__=0 -DKERNEL -DI86 -DPROTO -DASMSUPT From 18fa8e00914e7ba8bd8dd6460623106dd1425da9 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Mon, 30 Jun 2003 18:39:44 +0000 Subject: [PATCH 238/671] Slash conversion to enable cross compilation. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@627 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/makefile b/kernel/makefile index 42410db5..4317cfae 100644 --- a/kernel/makefile +++ b/kernel/makefile @@ -4,7 +4,7 @@ # $Id$ # -!include "..\mkfiles\generic.mak" +!include "../mkfiles/generic.mak" RELEASE = 1.00 From d60b01e511e7b7de1192774179db9b3ab1e439fc Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Mon, 30 Jun 2003 18:42:51 +0000 Subject: [PATCH 239/671] intr() cleanup and small optimizations. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@628 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/intr.asm | 170 +++++++++++++++++------------------------------- 1 file changed, 58 insertions(+), 112 deletions(-) diff --git a/kernel/intr.asm b/kernel/intr.asm index 06ab82a5..41ac1280 100644 --- a/kernel/intr.asm +++ b/kernel/intr.asm @@ -21,22 +21,14 @@ ; ; You should have received a copy of the GNU General Public ; License along with DOS-C; see the file COPYING. If not, -; write to the Free Software Foundation, 675 Mass Ave, -; Cambridge, MA 02139, USA. +; write to the Free Software Foundation, Inc., +; 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. ; - %include "segs.inc" -segment HMA_TEXT -; -; void intr(nr, rp) -; REG int nr -; REG struct REGPACK *rp -; -; - global _intr -_intr: +%macro INTR 0 + push bp ; Standard C entry mov bp,sp push si @@ -44,51 +36,58 @@ _intr: push ds push es - mov ax, [bp+4] ; interrupt number - mov [CS:intr?1-1], al - jmp short intr?2 ; flush the instruction cache -intr?2 mov bx, [bp+6] ; regpack structure - mov ax, [bx] - mov cx, [bx+4] - mov dx, [bx+6] - mov si, [bx+8] - mov di, [bx+10] - mov bp, [bx+12] - push Word [bx+14] ; ds - mov es, [bx+16] - mov bx, [bx+2] - pop ds - - int 0 -intr?1: + mov ax, [bp+4] ; interrupt number + mov [cs:%%intr_1-1], al + jmp short %%intr_2 ; flush the instruction cache +%%intr_2 mov bx, [bp+6] ; regpack structure + mov ax, [bx] + mov cx, [bx+4] + mov dx, [bx+6] + mov si, [bx+8] + mov di, [bx+10] + mov bp, [bx+12] + push word [bx+14] ; ds + mov es, [bx+16] + mov bx, [bx+2] + pop ds + int 0 +%%intr_1: - pushf - push ds - push bx - mov bx, sp - mov ds, [SS:bx+8] - mov bx, [ss:bx+20] ; address of REGPACK - mov [bx], ax - pop ax - mov [bx+2], ax - mov [bx+4], cx - mov [bx+6], dx - mov [bx+8], si - mov [bx+10], di - mov [bx+12], bp - pop ax - mov [bx+14], ax - mov [bx+16], es - pop ax - mov [bx+22], ax + pushf + push ds + push bx + mov bx, sp + mov ds, [ss:bx+8] + mov bx, [ss:bx+20] ; address of REGPACK + mov [bx], ax + pop word [bx+2] + mov [bx+4], cx + mov [bx+6], dx + mov [bx+8], si + mov [bx+10], di + mov [bx+12], bp + pop word [bx+14] + mov [bx+16], es + pop word [bx+22] - pop es - pop ds - pop di - pop si - pop bp - ret + pop es + pop ds + pop di + pop si + pop bp + ret +%endmacro +segment HMA_TEXT +; +; void intr(nr, rp) +; REG int nr +; REG struct REGPACK *rp +; +; + global _intr +_intr: + INTR segment INIT_TEXT ; @@ -97,60 +96,9 @@ segment INIT_TEXT ; REG struct REGPACK *rp ; ; same stuff as above, but in INIT_SEGMENT - global _init_call_intr + global _init_call_intr _init_call_intr: - push bp ; Standard C entry - mov bp,sp - push si - push di - push ds - push es - - mov ax, [bp+4] ; interrupt number - mov [CS:init_intr?1-1], al - jmp short init_intr?2 ; flush the instruction cache -init_intr?2 mov bx, [bp+6] ; regpack structure - mov ax, [bx] - mov cx, [bx+4] - mov dx, [bx+6] - mov si, [bx+8] - mov di, [bx+10] - mov bp, [bx+12] - push Word [bx+14] ; ds - mov es, [bx+16] - mov bx, [bx+2] - pop ds - - int 0 -init_intr?1: - - pushf - push ds - push bx - mov bx, sp - mov ds, [SS:bx+8] - mov bx, [ss:bx+20] ; address of REGPACK - mov [bx], ax - pop ax - mov [bx+2], ax - mov [bx+4], cx - mov [bx+6], dx - mov [bx+8], si - mov [bx+10], di - mov [bx+12], bp - pop ax - mov [bx+14], ax - mov [bx+16], es - pop ax - mov [bx+22], ax - - pop es - pop ds - pop di - pop si - pop bp - ret - + INTR ; ; int init_call_XMScall( (WORD FAR * driverAddress)(), WORD AX, WORD DX) @@ -282,13 +230,14 @@ _init_DosExec: int 21h jc short exec_no_error xor ax, ax -exec_no_error +exec_no_error: ret ;; int init_setdrive(int drive) global _init_setdrive _init_setdrive: mov ah, 0x0e +common_dl_int21: mov bx, sp mov dl, [bx+2] int 21h @@ -298,10 +247,7 @@ _init_setdrive: global _init_switchar _init_switchar: mov ax, 0x3701 - mov bx, sp - mov dl, [bx+2] - int 21h - ret + jmp short common_dl_int21 ;; int allocmem(UWORD size, seg *segp) global _allocmem From 27ee8b1c74e0a8192d4f57a7c8b2deeae514bc36 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Mon, 30 Jun 2003 18:43:28 +0000 Subject: [PATCH 240/671] Removed unnecessary jcxz's. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@629 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/asmsupt.asm | 2 -- 1 file changed, 2 deletions(-) diff --git a/kernel/asmsupt.asm b/kernel/asmsupt.asm index eea2c7bb..212835a3 100644 --- a/kernel/asmsupt.asm +++ b/kernel/asmsupt.asm @@ -118,7 +118,6 @@ MEMCPY: domemcpy: ; And do the built-in byte copy, but do a 16-bit transfer ; whenever possible. - jcxz memcpy_return shr cx,1 rep movsw jnc memcpy_return @@ -183,7 +182,6 @@ FMEMSET: domemset: mov ah, al - jcxz pascal_return shr cx,1 rep stosw jnc pascal_return From 138afdab72da86f476b339a0d56abfc6bd9cbd6e Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Mon, 30 Jun 2003 18:44:43 +0000 Subject: [PATCH 241/671] Declare more symbols as "ASM" to enable pascal calling conventions by default for turbo compilers. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@630 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/globals.h | 18 +++++++++--------- kernel/init-mod.h | 4 ++-- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/kernel/globals.h b/kernel/globals.h index 1aee9064..7858e55f 100644 --- a/kernel/globals.h +++ b/kernel/globals.h @@ -178,12 +178,12 @@ extern struct ClockRecord /* */ /* Global variables */ /* */ -extern BYTE os_setver_major, /* editable major version number */ - os_setver_minor, /* editable minor version number */ - os_major, /* major version number */ - os_minor, /* minor version number */ - rev_number, /* minor version number */ - version_flags; /* minor version number */ +extern BYTE ASM os_setver_major,/* editable major version number */ + ASM os_setver_minor, /* editable minor version number */ + ASM os_major, /* major version number */ + ASM os_minor, /* minor version number */ + ASM rev_number, /* minor version number */ + ASM version_flags; /* minor version number */ #ifdef DEBUG GLOBAL WORD bDumpRegs @@ -211,7 +211,7 @@ GLOBAL BYTE copyright[] = #endif -GLOBAL const BYTE os_release[] +GLOBAL const BYTE ASM os_release[] #ifdef MAIN #if 0 = "DOS-C version %d.%d Beta %d [FreeDOS Release] (Build %d).\n" @@ -346,8 +346,8 @@ GLOBAL WORD dump_regs; /* dump registers of bad call */ #endif -extern f_node_ptr f_nodes; /* pointer to the array */ -extern UWORD f_nodes_cnt; /* number of allocated f_nodes */ +extern f_node_ptr ASM f_nodes; /* pointer to the array */ +extern UWORD ASM f_nodes_cnt; /* number of allocated f_nodes */ /* */ /* Function prototypes - automatically generated */ diff --git a/kernel/init-mod.h b/kernel/init-mod.h index 9b71929b..2a9be422 100644 --- a/kernel/init-mod.h +++ b/kernel/init-mod.h @@ -221,7 +221,7 @@ extern BYTE DOSFAR ASM _HMATextAvailable, /* first byte of available CODE are DOSFAR ReturnAnyDosVersionExpected; extern BYTE FAR ASM internal_data[]; -extern unsigned char FAR kbdType; +extern unsigned char FAR ASM kbdType; extern struct { char ThisIsAConstantOne; @@ -229,7 +229,7 @@ extern struct { struct CountrySpecificInfo C; -} FAR nlsCountryInfoHardcoded; +} FAR ASM nlsCountryInfoHardcoded; /* data shared between DSK.C and INITDISK.C From c086225a9b25cc5f000454cef4f050402a5f15ed Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Mon, 30 Jun 2003 18:45:37 +0000 Subject: [PATCH 242/671] Correct comment. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@631 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/console.asm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/console.asm b/kernel/console.asm index 5425a790..32c3645f 100644 --- a/kernel/console.asm +++ b/kernel/console.asm @@ -138,7 +138,7 @@ KbdRdRtn: ; ; Name: -; ConInStat +; CommonNdRdExit ; ; Function: ; Checks the keyboard input buffer. From f91f2bac8db820cd59a9147ba6e6ea14283d4e9b Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Mon, 30 Jun 2003 18:46:37 +0000 Subject: [PATCH 243/671] Small size optimizations. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@632 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/main.c | 43 ++++++++++++++++++++++++++----------------- 1 file changed, 26 insertions(+), 17 deletions(-) diff --git a/kernel/main.c b/kernel/main.c index 7c87242b..3aed3ac0 100644 --- a/kernel/main.c +++ b/kernel/main.c @@ -23,8 +23,8 @@ /* */ /* You should have received a copy of the GNU General Public */ /* License along with DOS-C; see the file COPYING. If not, */ -/* write to the Free Software Foundation, 675 Mass Ave, */ -/* Cambridge, MA 02139, USA. */ +/* write to the Free Software Foundation, Inc., */ +/* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ /****************************************************************/ #include "portab.h" @@ -114,14 +114,16 @@ VOID ASMCFUNC FreeDOSmain(void) if (fmemcmp(MK_FP(0x50,0xe0+2),"CONFIG",6) == 0) /* UPX */ { - fmemcpy(&InitKernelConfig, MK_FP(0x50,0xe0+2), sizeof(InitKernelConfig)); - - LoL->BootDrive = *(BYTE FAR *)MK_FP(0x50,0xe0) + 1; - - if (LoL->BootDrive >= 0x80) - LoL->BootDrive = 3; /* C: */ + UBYTE drv; + + fmemcpy(&InitKernelConfig, MK_FP(0,0x5e0+2), sizeof(InitKernelConfig)); + + drv = *(UBYTE FAR *)MK_FP(0,0x5e0) + 1; + if (drv >= 0x80) + drv = 3; /* C: */ + LoL->BootDrive = drv; - *(DWORD FAR *)MK_FP(0x50,0xe0+2) = 0; + *(DWORD FAR *)MK_FP(0,0x5e0+2) = 0; } else { @@ -500,14 +502,21 @@ BOOL init_device(struct dhdr FAR * dhp, char *cmdLine, COUNT mode, request rq; int i; char name[8]; - char *p; - - fmemset(name, 0, 8); - for (p = cmdLine; *p && *p != ' ' && *p != '\t'; p++); - while (p >= cmdLine && *p != '\\' && *p != '/' && *p != ':') p--; - p++; - for (i = 0; i < 8 && p[i] && p[i] != '.'; i++) - name[i] = p[i]; + char *p, *q; + + for (p = q = cmdLine; *p && *p != ' ' && *p != '\t'; p++) + { + if (*p == '\\' || *p == '/' && *p == ':') + q = p + 1; + } + for (i = 0; i < 8; i++) { + char ch = *q; + if (ch != '\0') + q++; + if (ch == '.') + ch = 0; + name[i] = ch; + } rq.r_unit = 0; rq.r_status = 0; From 0971f348b265acc76ae3db7aaf62e3c8f7ff92a1 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Mon, 30 Jun 2003 18:50:38 +0000 Subject: [PATCH 244/671] Small size optimization and INSTALLHIGH correction. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@633 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/config.c | 165 +++++++++++++++++++++++------------------------- 1 file changed, 80 insertions(+), 85 deletions(-) diff --git a/kernel/config.c b/kernel/config.c index 2cd2561d..888dc956 100644 --- a/kernel/config.c +++ b/kernel/config.c @@ -23,8 +23,8 @@ /* */ /* You should have received a copy of the GNU General Public */ /* License along with DOS-C; see the file COPYING. If not, */ -/* write to the Free Software Foundation, 675 Mass Ave, */ -/* Cambridge, MA 02139, USA. */ +/* write to the Free Software Foundation, Inc., */ +/* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ /****************************************************************/ #include "portab.h" @@ -129,13 +129,13 @@ STATIC VOID DoMenu(void); STATIC VOID CfgMenuDefault(BYTE * pLine); STATIC BYTE * skipwh(BYTE * s); STATIC BYTE * scan(BYTE * s, BYTE * d); -STATIC BOOL isnum(BYTE * pszString); -STATIC BYTE * GetNumber(REG BYTE * pszString, REG COUNT * pnNum); +STATIC BOOL isnum(char ch); +STATIC char * GetNumber(REG const char *p, int *num); #if 0 STATIC COUNT tolower(COUNT c); #endif STATIC COUNT toupper(COUNT c); -STATIC VOID mcb_init(UCOUNT seg, UWORD size); +STATIC VOID mcb_init(UCOUNT seg, UWORD size, BYTE type); STATIC VOID mumcb_init(UCOUNT seg, UWORD size); STATIC VOID Stacks(BYTE * pLine); @@ -298,6 +298,8 @@ void PreConfig(void) /* Do second pass initialization: near allocation and MCBs */ void PreConfig2(void) { + struct sfttbl FAR *sp; + /* initialize NEAR allocated things */ /* Initialize the file table */ @@ -318,13 +320,14 @@ void PreConfig2(void) base_seg = LoL->first_mcb = FP_SEG(AlignParagraph((BYTE FAR *) DynLast() + 0x0f)); /* We expect ram_top as Kbytes, so convert to paragraphs */ - mcb_init(LoL->first_mcb, ram_top * 64 - LoL->first_mcb - 1); + mcb_init(base_seg, ram_top * 64 - LoL->first_mcb - 1, MCB_LAST); if (UmbState == 2) umb_init(); - LoL->sfthead->sftt_next = KernelAlloc(sizeof(sftheader) + 3 * sizeof(sft), 'F', 0); - LoL->sfthead->sftt_next->sftt_next = (sfttbl FAR *) - 1; - LoL->sfthead->sftt_next->sftt_count = 3; + sp = LoL->sfthead; + sp = sp->sftt_next = KernelAlloc(sizeof(sftheader) + 3 * sizeof(sft), 'F', 0); + sp->sftt_next = (sfttbl FAR *) - 1; + sp->sftt_count = 3; } /* Do third pass initialization. */ @@ -402,18 +405,19 @@ VOID configDone(VOID) { mcb FAR *p; unsigned short kernel_seg; + unsigned short hma_paras = (HMAFree+0xf)/16; - allocmem((HMAFree+0xf)/16, &kernel_seg); + allocmem(hma_paras, &kernel_seg); p = para2far(kernel_seg - 1); p->m_name[0] = 'S'; p->m_name[1] = 'C'; - p->m_psp = 8; + p->m_psp = 8; DebugPrintf(("HMA not available, moving text to %x\n", kernel_seg)); MoveKernel(kernel_seg); - kernel_seg += (HMAFree + 0x0f)/16 + 1; + kernel_seg += hma_paras + 1; DebugPrintf(("kernel is low, start alloc at %x", kernel_seg)); } @@ -442,8 +446,6 @@ STATIC void umb_init(void) if (UMB_get_largest(&umb_seg, &umb_size)) { - mcb FAR *p; - UmbState = 1; /* reset root */ @@ -455,10 +457,7 @@ STATIC void umb_init(void) mumcb_init(LoL->uppermem_root, umb_seg - LoL->uppermem_root - 1); /* setup the real mcb for the devicehigh block */ - mcb_init(umb_seg, umb_size - 2); - p = para2far(umb_seg); - p->m_type = MCB_NORMAL; - p->m_psp = FREE_PSP; + mcb_init(umb_seg, umb_size - 2, MCB_NORMAL); umb_base_seg = umb_max = umb_start = umb_seg; UMB_top = umb_size; @@ -475,12 +474,11 @@ STATIC void umb_init(void) seg umb_prev, umb_next; /* setup the real mcb for the devicehigh block */ - mcb_init(umb_seg, umb_size - 2); + mcb_init(umb_seg, umb_size - 2, MCB_NORMAL); /* determine prev and next umbs */ umb_prev = prev_mcb(umb_seg, LoL->uppermem_root); umb_next = umb_prev + para2far(umb_prev)->m_size + 1; - para2far(umb_seg)->m_type = MCB_NORMAL; if (umb_seg < umb_max) { @@ -774,12 +772,12 @@ STATIC BYTE * GetNumArg(BYTE * pLine, COUNT * pnArg) { /* look for NUMBER */ pLine = skipwh(pLine); - if (!isnum(pLine) && *pLine != '-') + if (!isnum(*pLine) && *pLine != '-') { CfgFailure(pLine); return (BYTE *) 0; } - return GetNumber(pLine, pnArg); + return (BYTE *)GetNumber(pLine, pnArg); } BYTE *GetStringArg(BYTE * pLine, BYTE * pszString) @@ -980,7 +978,8 @@ STATIC VOID CfgSwitches(BYTE * pLine) { pLine = skipwh(pLine); if (commands[0].pass == 0) { - if ('=' != *pLine) + /* compatibility "device foo.sys" */ + if ('=' != *pLine && ' ' != *pLine && '\t' != *pLine) { CfgFailure(pLine); return; @@ -1326,27 +1325,23 @@ void FAR * KernelAllocPara(size_t nPara, char type, char *name, int mode) if (base == start) { mcb FAR *p = para2far(base); - mcb_init(base + 1, p->m_size - 1); - para2far(base+1)->m_type = p->m_type; - p->m_type = MCB_NORMAL; - p->m_psp = 8; - p->m_size = 0; - p->m_name[0] = 'S'; - p->m_name[1] = 'D'; base++; + mcb_init(base, p->m_size - 1, p->m_type); + mumcb_init(FP_SEG(p), 0); + p->m_name[1] = 'D'; } - mcb_init(base + nPara + 1, para2far(base)->m_size - nPara - 1); - para2far(base + nPara + 1)->m_type = para2far(base)->m_type; - para2far(start)->m_size += nPara + 1; + nPara++; + mcb_init(base + nPara, para2far(base)->m_size - nPara, para2far(base)->m_type); + para2far(start)->m_size += nPara; p = (struct submcb FAR *)para2far(base); p->type = type; p->start = FP_SEG(p)+1; - p->size = nPara; + p->size = nPara-1; if (name) fmemcpy(p->name, name, 8); - base += nPara + 1; + base += nPara; if (mode) umb_base_seg = base; else @@ -1368,7 +1363,7 @@ void FAR * KernelAlloc(size_t nBytes, char type, int mode) } else { - p = KernelAllocPara((nBytes + 15)/16, type, NULL, mode); + p = KernelAllocPara(nPara, type, NULL, mode); } fmemset(p, 0, nBytes); return p; @@ -1419,10 +1414,10 @@ STATIC BYTE * scan(BYTE * s, BYTE * d) /* does the line start with "123?" */ - if (isnum(s)) + if (isnum(*s)) { unsigned numbers = 0; - for ( ; isnum(s); s++) + for ( ; isnum(*s); s++) numbers |= 1 << (*s -'0'); if (*s == '?') @@ -1474,43 +1469,48 @@ BYTE *scan_seperator(BYTE * s, BYTE * d) } #endif -STATIC BOOL isnum(BYTE * pLine) +STATIC BOOL isnum(char ch) { - return (*pLine >= '0' && *pLine <= '9'); + return (ch >= '0' && ch <= '9'); } /* JPP - changed so will accept hex number. */ /* ea - changed to accept hex digits in hex numbers */ -STATIC BYTE * GetNumber(REG BYTE * pszString, REG COUNT * pnNum) +STATIC char * GetNumber(REG const char *p, int *num) { - BYTE Base = 10; - BOOL Sign = FALSE; + unsigned char base = 10; + int sign = 1; + int n = 0; - *pnNum = 0; - if (*pszString == '-') + if (*p == '-') { - pszString++; - Sign = TRUE; + p++; + sign = -1; } - while ( isnum(pszString) || toupper(*pszString) == 'X' || - ( Base==16 && (toupper(*pszString)<='F') && (toupper(*pszString)>='A') ) ) + for(;;p++) { - if (toupper(*pszString) == 'X') + unsigned char ch = toupper((unsigned char)*p); + if (ch == 'X') + { + base = 16; + continue; + } + if (isnum(ch)) { - Base = 16; - pszString++; + n = n * base + ch - '0'; } - else if (isnum(pszString)) { - *pnNum = *pnNum * Base + (*pszString++ - '0'); + else if (base == 16 && (ch<='F') && (ch>='A')) + { + n = n * base + 10 + ch - 'A'; } - else { - *pnNum = *pnNum * Base + (10 + toupper(*pszString++) - 'A'); + else + { + break; } } - if (Sign) - *pnNum = -*pnNum; - return pszString; + *num = n * sign; + return (char *)p; } /* Yet another change for true portability (WDL) */ @@ -1536,33 +1536,28 @@ STATIC COUNT toupper(COUNT c) /* The following code is 8086 dependant */ #if 1 /* ifdef KERNEL */ -STATIC VOID mcb_init(UCOUNT seg, UWORD size) +STATIC VOID mcb_init_copy(UCOUNT seg, UWORD size, mcb *near_mcb) { - COUNT i; - - mcb FAR *mcbp = para2far(seg); - - mcbp->m_type = MCB_LAST; - mcbp->m_psp = FREE_PSP; + near_mcb->m_size = size; + fmemcpy(MK_FP(seg, 0), near_mcb, sizeof(mcb)); +} - for (i = 0; i < 8; i++) - mcbp->m_name[i] = '\0'; - - mcbp->m_size = size; +STATIC VOID mcb_init(UCOUNT seg, UWORD size, BYTE type) +{ + static mcb near_mcb = {0}; + near_mcb.m_type = type; + mcb_init_copy(seg, size, &near_mcb); } STATIC VOID mumcb_init(UCOUNT seg, UWORD size) { - COUNT i; - mcb FAR *mcbp = para2far(seg); - - static char name[8] = "SC\0\0\0\0\0\0"; - - mcbp->m_type = MCB_NORMAL; - mcbp->m_psp = 8; - mcbp->m_size = size; - for (i = 0; i < 8; i++) - mcbp->m_name[i] = name[i]; + static mcb near_mcb = { + MCB_NORMAL, + 8, 0, + {0,0,0}, + {"SC"} + }; + mcb_init_copy(seg, size, &near_mcb); } #endif @@ -2274,7 +2269,7 @@ STATIC int LoadCountryInfoHardCoded(char *filename, COUNT ctryCode, COUNT codePa */ int numInstallCmds = 0; -struct { +struct instCmds { char buffer[128]; int mode; } InstallCommands[10]; @@ -2309,9 +2304,9 @@ STATIC VOID CmdInstallHigh(BYTE * pLine) _CmdInstall(pLine,0x80); /* load high, if possible */ } -void InstallExec(char *cmd) +STATIC VOID InstallExec(struct instCmds *icmd) { - BYTE filename[128],*args,*d; + BYTE filename[128], *args, *d, cmd = icmd->buffer; exec_blk exb; InstallPrintf(("installing %s\n",cmd)); @@ -2340,7 +2335,7 @@ void InstallExec(char *cmd) InstallPrintf(("cmd[%s] args [%u,%s]\n",filename,*args,args+1)); - if (init_DosExec(0, &exb, filename) != SUCCESS) + if (init_DosExec(icmd->mode, &exb, filename) != SUCCESS) { CfgFailure(cmd); } @@ -2389,7 +2384,7 @@ VOID DoInstall(void) r.b.b.l = InstallCommands[i].mode; init_call_intr(0x21, &r); - InstallExec(InstallCommands[i].buffer); + InstallExec(&InstallCommands[i]); } r.a.x = 0x5801; /* set memory allocation strategy */ From 8c2eb41fc6a7312c8e176ad6a71c4f2b7a28c3ec Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Mon, 30 Jun 2003 18:52:43 +0000 Subject: [PATCH 245/671] Correct typo. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@634 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/config.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/config.c b/kernel/config.c index 888dc956..a938a7a4 100644 --- a/kernel/config.c +++ b/kernel/config.c @@ -2306,7 +2306,7 @@ STATIC VOID CmdInstallHigh(BYTE * pLine) STATIC VOID InstallExec(struct instCmds *icmd) { - BYTE filename[128], *args, *d, cmd = icmd->buffer; + BYTE filename[128], *args, *d, *cmd = icmd->buffer; exec_blk exb; InstallPrintf(("installing %s\n",cmd)); From d7f6e1181fd4c04450be9c96eb5d2de6c8f59fde Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Thu, 10 Jul 2003 10:46:31 +0000 Subject: [PATCH 246/671] From Luchezar Georgiev: parameters were in the wrong order... git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@635 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/chario.c | 2 +- kernel/inthndlr.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/kernel/chario.c b/kernel/chario.c index 85a04fe8..50827686 100644 --- a/kernel/chario.c +++ b/kernel/chario.c @@ -288,7 +288,7 @@ STATIC int echo_char(int c, int sft_idx) int echo_char_stdin(int c) { - return echo_char(get_sft_idx(STDIN), c); + return echo_char(c, get_sft_idx(STDIN)); } STATIC void destr_bs(int sft_idx) diff --git a/kernel/inthndlr.c b/kernel/inthndlr.c index 865c043e..ab6b7f3e 100644 --- a/kernel/inthndlr.c +++ b/kernel/inthndlr.c @@ -451,11 +451,11 @@ VOID ASMCFUNC int21_service(iregs FAR * r) /* Auxiliary Output */ case 0x04: - write_char(get_sft_idx(STDAUX), lr.DL); + write_char(lr.DL, get_sft_idx(STDAUX)); break; /* Print Character */ case 0x05: - write_char(get_sft_idx(STDPRN), lr.DL); + write_char(lr.DL, get_sft_idx(STDPRN)); break; /* Direct Console I/O */ From 756c578ca7ebc6310fbb12802e42adf6d629a4d7 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sat, 12 Jul 2003 20:56:11 +0000 Subject: [PATCH 247/671] (joint with Luchezar Georgiev): add extra low disk buffer to avoid HMA problems with certain device driver. Add an extra space for the device driver command line and point to a correct environment for INSTALL= (fixes problems with xmsdsk). git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@636 6ac86273-5f31-0410-b378-82cca8765d1b --- hdr/lol.h | 4 +++- kernel/blockio.c | 25 +++++++++++++++++++++---- kernel/config.c | 34 +++++++++++++++++----------------- kernel/globals.h | 3 +++ kernel/inthndlr.c | 1 + kernel/kernel.asm | 6 ++++-- kernel/main.c | 3 ++- 7 files changed, 51 insertions(+), 25 deletions(-) diff --git a/hdr/lol.h b/hdr/lol.h index 97f75d74..6da4ccbf 100644 --- a/hdr/lol.h +++ b/hdr/lol.h @@ -26,6 +26,8 @@ /* Boston, MA 02111-1307 USA. */ /****************************************************************/ +enum {LOC_CONV=0, LOC_HMA=1}; + /* note: we start at DOSDS:0, but the "official" list of lists starts a little later at DOSDS:26 (this is what is returned by int21/ah=52) */ @@ -60,7 +62,7 @@ struct lol { struct buffer far *lookahead;/* 4d pointer to lookahead buffer */ unsigned short slookahead; /* 51 number of lookahead sectors */ unsigned char bufloc; /* 53 BUFFERS loc (1=HMA) */ - struct buffer far *deblock; /* 54 pointer to workspace buffer */ + char far *deblock_buf; /* 54 pointer to workspace buffer */ char filler2[5]; /* 58 ???/unused */ unsigned char int24fail; /* 5d int24 fail while making i/o stat call*/ unsigned char memstrat; /* 5e memory allocation strat during exec */ diff --git a/kernel/blockio.c b/kernel/blockio.c index 00b6bd77..66038fa5 100644 --- a/kernel/blockio.c +++ b/kernel/blockio.c @@ -291,7 +291,7 @@ STATIC BOOL flush1(struct buffer FAR * bp) UWORD result; /* BER 9/4/00 */ - if ((bp->b_flag & BFR_VALID) && (bp->b_flag & BFR_DIRTY)) + if ((bp->b_flag & (BFR_VALID | BFR_DIRTY)) == (BFR_VALID | BFR_DIRTY)) { /* BER 9/4/00 */ result = dskxfer(bp->b_unit, bp->b_blkno, bp->b_buffer, 1, DSKWRITE); @@ -405,7 +405,6 @@ UWORD dskxfer(COUNT dsk, ULONG blkno, VOID FAR * buf, UWORD numblocks, IoReqHdr.r_status = 0; IoReqHdr.r_meddesc = dpbp->dpb_mdb; - IoReqHdr.r_trans = (BYTE FAR *) buf; IoReqHdr.r_count = numblocks; if (blkno >= MAXSHORT) { @@ -414,8 +413,26 @@ UWORD dskxfer(COUNT dsk, ULONG blkno, VOID FAR * buf, UWORD numblocks, } else IoReqHdr.r_start = blkno; - execrh((request FAR *) & IoReqHdr, dpbp->dpb_device); - if (!(IoReqHdr.r_status & S_ERROR) && (IoReqHdr.r_status & S_DONE)) + /* + * Some drivers normalise transfer address so HMA transfers are disastrous! + * Then transfer block through xferbuf (DiskTransferBuffer doesn't work!) + * (But this won't work for multi-block HMA transfers... are there any?) + */ + if (FP_SEG(buf) >= 0xa000 && numblocks == 1 && bufloc != LOC_CONV) + { + IoReqHdr.r_trans = deblock_buf; + if (mode == DSKWRITE) + fmemcpy(deblock_buf, buf, SEC_SIZE); + execrh((request FAR *) & IoReqHdr, dpbp->dpb_device); + if (mode == DSKREAD) + fmemcpy(buf, deblock_buf, SEC_SIZE); + } + else + { + IoReqHdr.r_trans = (BYTE FAR *) buf; + execrh((request FAR *) & IoReqHdr, dpbp->dpb_device); + } + if ((IoReqHdr.r_status & (S_ERROR | S_DONE)) == S_DONE) break; /* INT25/26 (_SEEMS_ TO) return immediately with 0x8002, diff --git a/kernel/config.c b/kernel/config.c index a938a7a4..edc396cd 100644 --- a/kernel/config.c +++ b/kernel/config.c @@ -226,20 +226,6 @@ BYTE HMAState = 0; #define HMA_DONE 2 /* Moved kernel to HMA */ #define HMA_LOW 3 /* Definitely LOW */ -STATIC void FAR* ConfigAlloc(COUNT bytes, char type) -{ - VOID FAR *p; - - p = HMAalloc(bytes); - - if (p == NULL) - p = KernelAlloc(bytes, type, 0); - - /* printf("ConfigAlloc %d at %p\n", bytes, p); */ - - return p; -} - /* Do first time initialization. Store last so that we can reset it */ /* later. */ void PreConfig(void) @@ -1242,7 +1228,7 @@ STATIC BOOL LoadDevice(BYTE * pLine, char FAR *top, COUNT mode) */ /* add \r\n to the command line */ - strcat(szBuf, "\r\n"); + strcat(szBuf, " \r\n"); dhp = MK_FP(base, 0); @@ -1639,9 +1625,23 @@ VOID config_init_buffers(COUNT anzBuffers) lpTop = lpOldTop; LoL->inforecptr = &LoL->firstbuf; - LoL->firstbuf = ConfigAlloc(sizeof(struct buffer) * anzBuffers, 'B'); + + { + size_t bytes = sizeof(struct buffer) * anzBuffers; + pbuffer = HMAalloc(bytes); + + if (pbuffer == NULL) + { + pbuffer = KernelAlloc(bytes, 'B', 0); + } + else + { + LoL->bufloc = LOC_HMA; + LoL->deblock_buf = KernelAlloc(SEC_SIZE, 'B', 0); + } + } - pbuffer = LoL->firstbuf; + LoL->firstbuf = pbuffer; DebugPrintf(("init_buffers (size %u) at", sizeof(struct buffer))); DebugPrintf((" (%p)", LoL->firstbuf)); diff --git a/kernel/globals.h b/kernel/globals.h index 7858e55f..ae88d1e6 100644 --- a/kernel/globals.h +++ b/kernel/globals.h @@ -247,6 +247,9 @@ FAR * ASM clock, /* CLOCK$ device */ extern WORD ASM maxbksize; /* Number of Drives in system */ extern struct buffer FAR *ASM firstbuf; /* head of buffers linked list */ +enum {LOC_CONV=0, LOC_HMA=1}; +extern unsigned char ASM bufloc; /* 0=conv, 1=HMA */ +extern void far * ASM deblock_buf; /* pointer to workspace buffer */ GLOBAL char FAR *firstAvailableBuf; extern struct cds FAR * ASM CDSp; /* Current Directory Structure */ extern diff --git a/kernel/inthndlr.c b/kernel/inthndlr.c index ab6b7f3e..4bb6f662 100644 --- a/kernel/inthndlr.c +++ b/kernel/inthndlr.c @@ -89,6 +89,7 @@ VOID ASMCFUNC int21_syscall(iregs FAR * irp) irp->DL = break_ena; break_ena = tmp != 0; } + break; /* Get Boot Drive */ case 0x05: diff --git a/kernel/kernel.asm b/kernel/kernel.asm index 0755dc67..f39c4d8c 100644 --- a/kernel/kernel.asm +++ b/kernel/kernel.asm @@ -318,8 +318,10 @@ _firstbuf dd 0 ; 0047 disk buffer chain dw 0 ; 004B Number of dirty buffers dd 0 ; 004D pre-read buffer dw 0 ; 0051 number of look-ahead buffers - db 0 ; 0053 00=conv 01=HMA -deblock_buf dd 0 ; 0054 deblock buffer + global _bufloc +_bufloc db 0 ; 0053 00=conv 01=HMA + global _deblock_buf +_deblock_buf dd 0 ; 0054 deblock buffer times 3 db 0 ; 0058 unknown dw 0 ; 005B unknown db 0, 0FFh, 0 ; 005D unknown diff --git a/kernel/main.c b/kernel/main.c index 3aed3ac0..29deeba9 100644 --- a/kernel/main.c +++ b/kernel/main.c @@ -219,6 +219,7 @@ STATIC void init_kernel(void) set_DTA(MK_FP(DOS_PSP, 0x80)); init_PSPSet(DOS_PSP); init_PSPInit(DOS_PSP); + ((psp far *)MK_FP(DOS_PSP, 0))->ps_environ = DOS_PSP + 8; Init_clk_driver(); @@ -531,7 +532,7 @@ BOOL init_device(struct dhdr FAR * dhp, char *cmdLine, COUNT mode, /* * Added needed Error handle */ - if (rq.r_status & S_ERROR) + if ((rq.r_status & (S_ERROR | S_DONE)) == S_ERROR) return TRUE; if (cmdLine) From 7f210610038c6af31ac7f9296f369fd16e1c20cb Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sat, 12 Jul 2003 20:57:23 +0000 Subject: [PATCH 248/671] Make a message #ifdef DEBUG only. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@637 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/inithma.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/kernel/inithma.c b/kernel/inithma.c index 77637210..5f50b6c4 100644 --- a/kernel/inithma.c +++ b/kernel/inithma.c @@ -142,10 +142,12 @@ int EnableHMA(VOID) _DisableA20(); +#ifdef DEBUG if (fmemcmp(MK_FP(0x0000, 0x0000), MK_FP(0xffff, 0x0010), 128) != 0) { printf("HMA can't be disabled - no problem for us\n"); } +#endif _EnableA20(); if (fmemcmp(MK_FP(0x0000, 0x0000), MK_FP(0xffff, 0x0010), 128) == 0) From dde7ba779176f0634822afb6944c797984290f3e Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Mon, 14 Jul 2003 19:17:01 +0000 Subject: [PATCH 249/671] There aren't lastdrive open file handles but a maximum of 20. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@638 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/main.c b/kernel/main.c index 29deeba9..b1b5db89 100644 --- a/kernel/main.c +++ b/kernel/main.c @@ -250,7 +250,7 @@ STATIC void init_kernel(void) /* Close all (device) files */ - for (i = 0; i < LoL->lastdrive; i++) + for (i = 0; i < 20; i++) close(i); /* and do final buffer allocation. */ From 4a067595fcb765c7c6de76ec1f69900afbf2c0b0 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Tue, 15 Jul 2003 12:30:34 +0000 Subject: [PATCH 250/671] config.txt updates from Bernd Blaauw git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@639 6ac86273-5f31-0410-b378-82cca8765d1b --- docs/config.txt | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/docs/config.txt b/docs/config.txt index 574f177f..1fc7476a 100644 --- a/docs/config.txt +++ b/docs/config.txt @@ -1,5 +1,9 @@ Advanced - FreeDOS specific - CONFIG.SYS processing +a new command DOSDATA=UMB +DOSDATA=UMB loads some FreeDOS specific stuff in Upper Memory Blocks, +like the RAM that FILESHIGH, LASTDRIVEHIGH, and STACKSHIGH occupy + a new command ECHO ECHO does ECHO its argument (surprised ?-) and is executed at the time the DEVICE= lines are executed. @@ -9,6 +13,10 @@ use it similarly to device=Driver1.sys ECHO driver1 successfully loaded +a new command called EECHO is also available, for echo-ing ANSI Escape Sequences +(redefines keyboard input for example). + + an undocumented command SCREEN=xx SCREEN= switches into videomode xxx (INT10/11xx/000) useful @@ -59,8 +67,7 @@ MENUDEFAULT=0,1 ( configuration 0, wait 1 second) Although this is definitively worse then MSDOS menuing possibilities, -IMHO it's better then nothing. Unfortunately your MENU text gets completely -uppercase.. +IMHO it's better then nothing. It's also possible to combine menu options, to avoid writing thing every time again. @@ -109,7 +116,7 @@ MENUDEFAULT=0,0 0?device=c:\ntclient\ifshlp.sys -DEVICE=CDROM.SYS /D:MSCD000 +DEVICE=ATAPICDD.SYS /D:MSCD000 @@ -117,7 +124,7 @@ DEVICE=CDROM.SYS /D:MSCD000 2002-11-28 - Tom Ehlert - +2003-07-15 - Bernd Blaauw From 8a9dcfe8bb4662d7978de7d288d796e5296c19fb Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Tue, 15 Jul 2003 12:32:35 +0000 Subject: [PATCH 251/671] (from Tom) Fix a problem with the 'BootFromHarddiskIfNoKeyHit' option. with some Compaq and Fujitsu/Siemens Highend Equipment git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@640 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/main.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/kernel/main.c b/kernel/main.c index b1b5db89..e4ece8ba 100644 --- a/kernel/main.c +++ b/kernel/main.c @@ -618,7 +618,7 @@ STATIC VOID InitPrinters(VOID) EmulatedDriveStatus(int drive,char statusOnly) { iregs r; - char buffer[13]; + char buffer[0x13]; buffer[0] = 0x13; r.a.b.h = 0x4b; /* bootable CDROM - get status */ @@ -639,21 +639,23 @@ STATIC void CheckContinueBootFromHarddisk(void) iregs r; int key; - __int__(3); /* necessary for some strange reasons ?? (TE) */ - if (InitKernelConfig.BootHarddiskSeconds == 0) return; if (LoL->BootDrive >= 3) { +#if 0 if (!EmulatedDriveStatus(0x80,1)) +#endif { /* already booted from HD */ return; } } else { +#if 0 if (!EmulatedDriveStatus(0x00,1)) +#endif bootedFrom = "Floppy"; } From c672e81012bb6b336e84a0559ef6e4e080dc23d0 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sat, 19 Jul 2003 15:06:55 +0000 Subject: [PATCH 252/671] Correct problem with multiple UMBs git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@641 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/config.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/kernel/config.c b/kernel/config.c index edc396cd..fcb7e444 100644 --- a/kernel/config.c +++ b/kernel/config.c @@ -481,11 +481,15 @@ STATIC void umb_init(void) mumcb_init(umb_seg + umb_size - 1, umb_next - umb_seg - umb_size); } } + else /* umb_seg >= umb_max */ + { + umb_prev = umb_next; + } if (umb_seg - umb_prev - 1 == 0) /* should the UMB driver return adjacent memory in several pieces */ - para2far(umb_prev)->m_size += umb_size; + para2far(prev_mcb(umb_prev, LoL->uppermem_root))->m_size += umb_size; else { /* create link mcb (below) */ From d6e8d403eacdfd2f30e7d74b9c788827a3e85336 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sat, 19 Jul 2003 18:09:07 +0000 Subject: [PATCH 253/671] Update Changelog, version number. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@642 6ac86273-5f31-0410-b378-82cca8765d1b --- docs/history.txt | 33 +++++++++++++++++++++++++++++++++ hdr/version.h | 8 ++++---- 2 files changed, 37 insertions(+), 4 deletions(-) diff --git a/docs/history.txt b/docs/history.txt index dc05b715..a277d899 100644 --- a/docs/history.txt +++ b/docs/history.txt @@ -1,3 +1,36 @@ +2003 Jul 19 - Build 2031 +-------- Bart Oldeman (bart@dosemu.org) ++ Changes Luchezar Georgiev + * (with Bart) add extra low disk buffer to avoid HMA + problems with certain device drivers. + * Add an extra space for the device driver command line + * point to a correct environment for INSTALL= + (fixes problems with xmsdsk). + * change device driver error code check (using S_ERROR | S_DONE) + (fixes problem with the SystemSoft PCMCIA socket services driver) + * correct parameter order in inthndlr.c, chario.c + * INSTALLHIGH correction. ++ Changes Tom + * Fix a problem with the 'BootFromHarddiskIfNoKeyHit' option. + that occurred with some Compaq and Fujitsu/Siemens highend equipment. ++ Changes Bernd Blaauw + * config.txt updates ++ Changes Steffen Kaiser + * NLS adjustments ++ Changes Bart + * Correct problem with multiple UMBs (bug #1671) + * main.c: there aren't lastdrive open file handles but a + maximum of 20. + * Make "unable to disable A20" message #ifdef DEBUG only. + * config.c,main.c: Small size optimizations (some proposed by + Arkady Belousov) + * asmsupt.asm: Removed unnecessary jcxz's (Arkady) + * intr.asm: intr() cleanup and small optimizations (Arkady) + * Use PASCAL calling convention by default for Turbo compilers. + * Move more externs to header files + * SFT init cleanup (+3 files need to be low) + * config.c, main.c: Fix bug in block device driver init of + DPBs (bug #1969, TDSK problem) 2003 Jun 18 - Build 2030 -------- Bart Oldeman (bart@dosemu.org) + Changes Tom diff --git a/hdr/version.h b/hdr/version.h index ed4234ec..cebf97f6 100644 --- a/hdr/version.h +++ b/hdr/version.h @@ -47,8 +47,8 @@ static BYTE *date_hRcsId = #define REVISION_MAJOR 1 #define REVISION_MINOR 1 -#define REVISION_SEQ 30 -#define BUILD "2030" +#define REVISION_SEQ 31 +#define BUILD "2031" #define SUB_BUILD "" -#define KERNEL_VERSION_STRING "1.1.30" /*#REVISION_MAJOR "." #REVISION_MINOR "." #REVISION_SEQ */ -#define KERNEL_BUILD_STRING "2030" /*#BUILD SUB_BUILD */ +#define KERNEL_VERSION_STRING "1.1.31" /*#REVISION_MAJOR "." #REVISION_MINOR "." #REVISION_SEQ */ +#define KERNEL_BUILD_STRING "2031" /*#BUILD SUB_BUILD */ From 7e4774bcfa58e23f8d0a7651796d92bd98113c52 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sat, 19 Jul 2003 18:12:26 +0000 Subject: [PATCH 254/671] "-p" is no longer necessary in config.bat git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@643 6ac86273-5f31-0410-b378-82cca8765d1b --- config.b | 1 - 1 file changed, 1 deletion(-) diff --git a/config.b b/config.b index 4c051428..786b0e9a 100644 --- a/config.b +++ b/config.b @@ -111,7 +111,6 @@ set XFAT=16 :- Give extra compiler DEFINE flags here :- such as -DDEBUG : extra DEBUG output :- -DDOSEMU : printf output goes to dosemu log -:- -p : use PASCAL calling convention with Turbo C :- set ALLCFLAGS=-DDEBUG From 96c1c46d60fd72b0e87534d5d722f4e097d71ccf Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sun, 20 Jul 2003 17:33:45 +0000 Subject: [PATCH 255/671] Fix ctrl-break bug. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@644 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/break.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/kernel/break.c b/kernel/break.c index b02c02a3..6c02dabd 100644 --- a/kernel/break.c +++ b/kernel/break.c @@ -63,8 +63,10 @@ int control_break(void) */ void handle_break(int sft_idx) { - echo_char_stdin(CTL_C); - CB_FLG &= ~CB_MSK; /* reset the ^Break flag */ + if (CB_FLG & CB_MSK) /* Ctrl-Break pressed */ + CB_FLG &= ~CB_MSK; /* reset the ^Break flag */ + else /* Ctrl-C pressed */ + echo_char_stdin(CTL_C); KbdFlush(sft_idx); /* Er, this is con_flush() */ if (!ErrorMode) /* within int21_handler, InDOS is not incremented */ if (InDOS) From 2b0c219e5e41d5c13af3f8be8e7e200113c94193 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sun, 3 Aug 2003 10:44:29 +0000 Subject: [PATCH 256/671] Solve compilation problem with Borland C++ 3.1 git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@649 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/init-mod.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/init-mod.h b/kernel/init-mod.h index 2a9be422..9de51632 100644 --- a/kernel/init-mod.h +++ b/kernel/init-mod.h @@ -216,8 +216,8 @@ extern struct lol ASM DOSFAR DATASTART; extern BYTE DOSFAR ASM _HMATextAvailable, /* first byte of available CODE area */ FAR ASM _HMATextStart[], /* first byte of HMAable CODE area */ - FAR ASM _HMATextEnd[], DOSFAR ASM break_ena, /* break enabled flag */ - DOSFAR _InitTextStart, /* first available byte of ram */ + FAR ASM _HMATextEnd[], DOSFAR ASM break_ena; /* break enabled flag */ +extern BYTE DOSFAR _InitTextStart, /* first available byte of ram */ DOSFAR ReturnAnyDosVersionExpected; extern BYTE FAR ASM internal_data[]; From 3229fe3fc4533dadabdffc263e85fbdec95fec94 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Wed, 6 Aug 2003 19:47:24 +0000 Subject: [PATCH 257/671] From Luchezar: IOCTL 4406 provided reverse AL output on regular files - FF if EOF, 0 if not. It should output 0 if EOF, FF if not. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@651 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/ioctl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/ioctl.c b/kernel/ioctl.c index 9dec3721..dc9b3cc7 100644 --- a/kernel/ioctl.c +++ b/kernel/ioctl.c @@ -119,7 +119,7 @@ COUNT DosDevIOctl(lregs * r) if (s->sft_flags & SFT_FDEVICE) r->AL = s->sft_flags & SFT_FEOF ? 0xFF : 0; else - r->AL = s->sft_posit >= s->sft_size ? 0xFF : 0; + r->AL = s->sft_posit >= s->sft_size ? 0 : 0xFF; break; case 0x07: From 9a3da2b737b86cf2d0b491ce2c1689e79ba31138 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Fri, 8 Aug 2003 15:01:15 +0000 Subject: [PATCH 258/671] Version 2.7 luchezar, tomehlert, ericauer 2003/8/5 boot.asm modified to support non-512 byte sectors (e.g. 1.2 MB NEC diskettes) 512 byte sector size check removed (although Eric's boot32ea.asm does require 512-byte sectors, all LBA FAT32 volumes have 512-byte sectors anyway). boot.asm cleaned up and modified to support Metakern (by Tom, Eric and Lucho) bsDriveNumber updated by SYS even #ifndef STORE_BOOT_INFO (nothing in common) Version 2.7beta, Luchezar Georgiev, 1 August 2003 o Now supports and includes the following new boot sectors: 1) the combined CHS+LBA FAT12/FAT16 boot sector by Tom Ehlert (29 July) 2) the CHS-only FAT32 boot sector -- as patched by Jon Gentle (08 July) 3) the LBA-only FAT32 boot sector by Eric Auer and Jon Gentle (19 July) o The old combined (CHS+LBA), no-CALCPARAMS, no-resizable, non-Ghostable, non-standard FAT32 boot sector and STORE_BOOT_INFO is no longer used. o dump_sector() showed ASCII debug printout for the old sector only - fixed. o Put a boot sector only if sector size = 512 (may it not be so in Japan?!). If non-512 byte sectors encountered, report to the fd-kernel mailing list. o Now puts boot sector before copying kernel/shell so it works in WinNT now. o check_space() now implemented at last (required significant modifications) o New file system (FAT type) detection method according to a MS White Paper. o Now BOOTONLY works even without a preceding boot sector image file name. o Some minor code cleanups. Bart: some cleanups to the above; replaced 386 code for CHS FAT32 by 8088 code. use boot32lb.asm instead of boot32ea.asm git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@652 6ac86273-5f31-0410-b378-82cca8765d1b --- boot/boot.asm | 264 +++++++++++------------------- boot/boot32.asm | 90 +++++++---- boot/boot32lb.asm | 405 ++++++++++++++++++++++++++++++++++++++++++++++ boot/makefile | 19 ++- sys/makefile | 19 ++- sys/sys.c | 398 ++++++++++++++++++++------------------------- 6 files changed, 756 insertions(+), 439 deletions(-) create mode 100644 boot/boot32lb.asm diff --git a/boot/boot.asm b/boot/boot.asm index 558f9332..203fbc82 100644 --- a/boot/boot.asm +++ b/boot/boot.asm @@ -26,31 +26,24 @@ ; Cambridge, MA 02139, USA. ; ; -; +--------+ -; | | -; | | -; |--------| 4000:0000 -; | | -; | FAT | -; | | -; |--------| 2000:0000 +; +--------+ 1FE0:7E00 ; |BOOT SEC| ; |RELOCATE| -; |--------| 1FE0:0000 -; | | +; |--------| 1FE0:7C00 ; | | +; |--------| 1FE0:3000 +; | CLUSTER| +; | LIST | +; |--------| 1FE0:2000 ; | | +; |--------| 0000:7E00 +; |BOOT SEC| overwritten by max 128k FAT buffer +; |ORIGIN | and later by max 134k loaded kernel +; |--------| 0000:7C00 ; | | ; |--------| -; |BOOT SEC| -; |ORIGIN | 07C0:0000 -; |--------| -; | | -; | | -; | | -; |--------| -; |KERNEL | -; |LOADED | +; |KERNEL | also used as max 128k FAT buffer +; |LOADED | before kernel loading starts ; |--------| 0060:0000 ; | | ; +--------+ @@ -58,8 +51,6 @@ ;%define ISFAT12 1 ;%define ISFAT16 1 -;%define CALCPARAMS 1 -;%define MULTI_SEC_READ 1 segment .text @@ -118,7 +109,7 @@ Entry: jmp short real_start mov word [fat_start+2], di mov al, [bsFATs] - xor ah, ah + cbw mul word [sectPerFat] ; DX:AX = total number of FAT sectors add si, ax @@ -148,49 +139,50 @@ Entry: jmp short real_start times 0x3E-$+$$ db 0 -%define tempbuf bp+0x3E +%define loadsegoff_60 bp+0x3E + dw 0 +%define loadseg_60 bp+0x40 dw LOADSEG -%ifdef CALCPARAMS -%define RootDirSecs bp+0x27 ; # of sectors root dir uses +;%define LBA_PACKET bp+0x42 +; db 10h ; size of packet +; db 0 ; const +; dw 1 ; number of sectors to read +%define LBA_PACKET bp-0x40 +%define LBA_SIZE word [LBA_PACKET] +%define LBA_SECNUM word [LBA_PACKET+2] +%define LBA_OFF LBA_PACKET+4 +%define LBA_SEG LBA_PACKET+6 +%define LBA_SECTOR_0 word [LBA_PACKET+8 ] +%define LBA_SECTOR_16 word [LBA_PACKET+10] +%define LBA_SECTOR_32 word [LBA_PACKET+12] +%define LBA_SECTOR_48 word [LBA_PACKET+14] -%define fat_start bp+0x29 ; first FAT sector -%define root_dir_start bp+0x2D ; first root directory sector -%define data_start bp+0x31 ; first data sector +%define PARAMS LBA_PACKET+0x10 +%define RootDirSecs PARAMS+0x0 ; # of sectors root dir uses -%else -%define RootDirSecs bp+0x40 ; # of sectors root dir uses - dw 0 +%define fat_start PARAMS+0x2 ; first FAT sector -%define fat_start bp+0x42 ; first FAT sector - dd 0 +%define root_dir_start PARAMS+0x6 ; first root directory sector -%define root_dir_start bp+0x46 ; first root directory sector - dd 0 +%define data_start PARAMS+0x0a ; first data sector -%define data_start bp+0x4A ; first data sector - dd 0 -%endif ;----------------------------------------------------------------------- ; ENTRY ;----------------------------------------------------------------------- -real_start: cli +real_start: + cli cld xor ax, ax - mov ss, ax ; initialize stack mov ds, ax mov bp, 0x7c00 - lea sp, [bp-0x20] - sti - cmp byte [drive], 0xff ; BIOS bug ?? - jne dont_use_dl - mov [drive], dl ; BIOS passes drive number in DL - ; a reset should not be needed here -dont_use_dl: + + + ; a reset should not be needed here ; int 0x13 ; reset drive ; int 0x12 ; get memory available in AX @@ -207,15 +199,26 @@ dont_use_dl: rep movsw jmp word 0x1FE0:cont -cont: mov ds, ax +cont: + mov ds, ax mov ss, ax + lea sp, [bp-0x60] + sti +; +; Some BIOS don't pass drive number in DL, so don't use it if [drive] is known +; + cmp byte [drive], 0xff ; impossible number written by SYS + jne dont_use_dl ; was SYS drive: other than A or B? + mov [drive], dl ; yes, rely on BIOS drive number in DL +dont_use_dl: ; no, rely on [drive] written by SYS + + mov LBA_SIZE, 10h + mov LBA_SECNUM,1 ; initialise LBA packet constants call print db "FreeDOS",0 -%ifdef CALCPARAMS GETDRIVEPARMS -%endif ; FINDFILE: Searches for the file in the root directory. @@ -229,13 +232,12 @@ cont: mov ds, ax mov ax, word [root_dir_start] mov dx, word [root_dir_start+2] mov di, word [RootDirSecs] - xor bx, bx - mov word [tempbuf], LOADSEG - mov es, [tempbuf] + les bx, [loadsegoff_60] ; es:bx = 60:0 call readDisk jc jmp_boot_error - xor di, di + les di, [loadsegoff_60] ; es:di = 60:0 + ; Search for KERNEL.SYS file name, and find start cluster. @@ -255,8 +257,8 @@ next_entry: mov cx, 11 ffDone: push ax ; store first cluster number - call print - db " FAT",0 +; call print +; db " FAT",0 @@ -275,8 +277,7 @@ ffDone: ; Load the complete FAT into memory. The FAT can't be larger ; than 128 kb, so it should fit in the temporary buffer. - mov es, [tempbuf] - xor bx, bx + les bx, [loadsegoff_60] ; es:bx=60:0 mov di, [sectPerFat] mov ax, word [fat_start] mov dx, word [fat_start+2] @@ -286,9 +287,8 @@ jmp_boot_error: jc boot_error ; Set ES:DI to the temporary storage for the FAT chain. push ds - push es - pop ds pop es + mov ds, [loadseg_60] mov di, FATBUF next_clust: stosw ; store cluster number @@ -308,8 +308,7 @@ fat_12: add si, si ; multiply cluster number by 3... ; the number was odd, CF was set in the last shift instruction. jnc fat_even - mov cl, 4 - shr ax, cl ; shift the cluster number + div word[LBA_PACKET]; luckily 16 !! -- divide the cluster number fat_even: and ah, 0x0f ; mask off the highest 4 bits cmp ax, 0x0ff8 ; check for EOF @@ -320,7 +319,7 @@ fat_even: and ah, 0x0f ; mask off the highest 4 bits ; This is a FAT-16 disk. The maximal size of a 16-bit FAT ; is 128 kb, so it may not fit within a single 64 kb segment. -fat_16: mov dx, [tempbuf] +fat_16: mov dx, [loadseg_60] add si, si ; multiply cluster number by two jnc first_half ; if overflow... add dh, 0x10 ; ...add 64 kb to segment value @@ -341,14 +340,13 @@ finished: ; Mark end of FAT chain with 0, so we have a single push cs pop ds - call print - db " Kernel",0 ; "KERNEL" + ;call print + ;db " Kernel",0 ; "KERNEL" ; loadFile: Loads the file into memory, one cluster at a time. - mov es, [tempbuf] ; set ES:BX to load address - xor bx, bx + les bx, [loadsegoff_60] ; set ES:BX to load address 60:0 mov si, FATBUF ; set DS:SI to the FAT chain @@ -369,16 +367,17 @@ cluster_next: lodsw ; AX = next cluster to read boot_error: call print - db 13,10,"BOOT err!",0 + db " err",0 xor ah,ah int 0x16 ; wait for a key int 0x19 ; reboot the machine -boot_success: call print - db " GO! ",0 +boot_success: + ;call print + ;db " GO! ",0 mov bl, [drive] - jmp word LOADSEG:0 + jmp far [loadsegoff_60] ; prints text after call to this function. @@ -406,13 +405,17 @@ print1: lodsb ; get token ; ES:BX points one byte after the last byte read. readDisk: push si -read_next: push dx - push ax + + mov LBA_SECTOR_0,ax + mov LBA_SECTOR_16,dx + mov word [LBA_SEG],es + mov word [LBA_OFF],bx + +read_next: ;******************** LBA_READ ******************************* ; check for LBA support - push bx mov ah,041h ; mov bx,055aah ; @@ -424,51 +427,30 @@ read_next: push dx int 0x13 jc read_normal_BIOS - sub bx,0aa55h + shr cx,1 ; CX must have 1 bit set + + sbb bx,0aa55h - 1 ; tests for carry (from shr) too! jne read_normal_BIOS - shr cx,1 ; CX must have 1 bit set - jnc read_normal_BIOS ; OK, drive seems to support LBA addressing - lea si,[LBA_DISK_PARAMETER_BLOCK] + lea si,[LBA_PACKET] ; setup LBA disk block - mov [si+12],bx - mov [si+14],bx + mov LBA_SECTOR_32,bx + mov LBA_SECTOR_48,bx - pop bx - - pop ax - pop dx - push dx - push ax - mov [si+ 8],ax - mov [si+10],dx - mov [si+4],bx - mov [si+6],es - - mov ah,042h jmp short do_int13_read -LBA_DISK_PARAMETER_BLOCK: - db 10h ; constant size of block - db 0 - dw 1 ; 1 sector read - ; and overflow into code !!! - read_normal_BIOS: - pop bx - pop ax - pop dx - push dx - push ax ;******************** END OF LBA_READ ************************ + mov ax,LBA_SECTOR_0 + mov dx,LBA_SECTOR_16 ; @@ -509,93 +491,37 @@ read_normal_BIOS: inc ah ; sector offset from 1 or cl, ah ; merge sector into cylinder -%ifdef MULTI_SEC_READ - ; Calculate how many sectors can be transfered in this read - ; due to dma boundary conditions. - push dx - - mov si, di ; temp register save - ; this computes remaining bytes because of modulo 65536 - ; nature of dma boundary condition - mov ax, bx ; get offset pointer - neg ax ; and convert to bytes - jz ax_min_1 ; started at seg:0, skip ahead - - xor dx, dx ; convert to sectors - div word [bsBytesPerSec] - - cmp ax, di ; check remainder vs. asked - jb ax_min_1 ; less, skip ahead - mov si, ax ; transfer only what we can - -ax_min_1: pop dx - - ; Check that request sectors do not exceed track boundary - mov si, [sectPerTrack] - inc si - mov ax, cx ; get the sector/cyl byte - and ax, 0x3f ; and mask out sector - sub si, ax ; si has how many we can read - mov ax, di - cmp si, di ; see if asked <= available - jge ax_min_2 - mov ax, si ; get what can be xfered - -ax_min_2: push ax - mov ah, 2 - mov dl, [drive] - int 0x13 - pop ax -%else + les bx,[LBA_OFF] mov ax, 0x0201 do_int13_read: mov dl, [drive] int 0x13 -%endif read_finished: jnc read_ok ; jump if no error xor ah, ah ; else, reset floppy int 0x13 - pop ax - pop dx ; and... read_next_chained: jmp short read_next ; read the same sector again read_ok: -%ifdef MULTI_SEC_READ - mul word [bsBytesPerSec] ; add number of bytes read to BX - add bx, ax -%else - add bx, word [bsBytesPerSec] -%endif - jnc no_incr_es ; if overflow... - - mov ax, es - add ah, 0x10 ; ...add 1000h to ES - mov es, ax - -no_incr_es: pop ax - pop dx ; DX:AX = last sector number - -%ifdef MULTI_SEC_READ - add ax, si - adc dx, byte 0 ; DX:AX = next sector to read - sub di,si ; if there is anything left to read, - jg read_next ; continue -%else - add ax, byte 1 - adc dx, byte 0 ; DX:AX = next sector to read + mov ax, word [bsBytesPerSec] + div byte[LBA_PACKET] ; luckily 16 !! + add word [LBA_SEG], ax + + add LBA_SECTOR_0, byte 1 + adc LBA_SECTOR_16, byte 0 ; DX:AX = next sector to read dec di ; if there is anything left to read, jnz read_next_chained ; continue -%endif - clc + mov es,word [LBA_SEG] + ; clear carry: unnecessary since adc clears it pop si ret filename db "KERNEL SYS" + times 0x01fe-$+$$ db 0 sign dw 0xAA55 diff --git a/boot/boot32.asm b/boot/boot32.asm index 3bdc9b2d..b5bf2ea0 100644 --- a/boot/boot32.asm +++ b/boot/boot32.asm @@ -57,34 +57,33 @@ Entry: jmp short real_start %define xrootClst bp+0x2c ; Starting cluster of root directory %define drive bp+0x40 ; Drive number + times 0x5a-$+$$ db 0 + %define LOADSEG 0x0060 %define FATSEG 0x2000 %define fat_sector bp+0x48 ; last accessed sector of the FAT - dd 0 - times 0x5a-$+$$ db 0 -%define fat_start bp+0x5a ; first FAT sector - dd 0 -%define data_start bp+0x5e ; first data sector - dd 0 -%define fat_secmask bp+0x62 ; number of clusters in a FAT sector - 1 - dw 0 -%define fat_secshift bp+0x64 ; fat_secmask+1 = 2^fat_secshift +%define loadsegoff_60 bp+0x5a ; FAR pointer = 60:0 dw 0 +%define loadseg_60 bp+0x5c + dw LOADSEG + +%define fat_start bp+0x5e ; first FAT sector +%define data_start bp+0x62 ; first data sector +%define fat_secmask bp+0x66 ; number of clusters in a FAT sector - 1 +%define fat_secshift bp+0x68 ; fat_secmask+1 = 2^fat_secshift ;----------------------------------------------------------------------- ; ENTRY ;----------------------------------------------------------------------- real_start: cld + cli sub ax, ax mov ds, ax mov bp, 0x7c00 - mov ss, ax ; initialize stack - lea sp, [bp-0x20] - int 0x13 ; reset drive mov ax, 0x1FE0 mov es, ax @@ -95,18 +94,59 @@ real_start: cld jmp word 0x1FE0:cont cont: mov ds, ax - mov ss, ax + mov ss, ax + lea sp, [bp-0x20] + sti mov [drive], dl ; BIOS passes drive number in DL - call print - db "Loading FreeDOS ",0 - +; call print +; db "Loading ",0 + +; Calc Params +; Fat_Start + mov si, word [nHidden] + mov di, word [nHidden+2] + add si, word [bsResSectors] + adc di, byte 0 + + mov word [fat_start], si + mov word [fat_start+2], di + ; Data_Start + mov al, [bsFATs] + cbw + push ax + mul word [xsectPerFat+2] + add di, ax + pop ax + mul word [xsectPerFat] + add ax, si + adc dx, di + mov word[data_start], ax + mov word[data_start+2], dx +; fat_secmask + mov ax, word[bsBytesPerSec] + shr ax, 1 + shr ax, 1 + dec ax + mov word [fat_secmask], ax +; fat_secshift +; cx = temp +; ax = fat_secshift + xchg ax, cx ; cx = 0 after movsw + inc cx +secshift: inc ax + shr cx, 1 + cmp cx, 1 + jne secshift + mov byte [fat_secshift], al + dec cx + ; FINDFILE: Searches for the file in the root directory. ; ; Returns: ; DX:AX = first cluster of file - mov word [fat_sector], cx ; CX is 0 after movsw + mov word [fat_sector], cx ; CX is 0 after "dec" mov word [fat_sector + 2], cx mov ax, word [xrootClst] @@ -120,9 +160,7 @@ ff_next_cluster: ff_next_sector: push bx ; save sector count - mov bx, LOADSEG - mov es, bx - sub bx, bx + les bx, [loadsegoff_60] call readDisk push dx ; save sector push ax @@ -171,10 +209,7 @@ c6: call next_cluster jmp c5 - -boot_error: call print - db 13,10,"BOOT error!",13,10,0 - +boot_error: xor ah,ah int 0x16 ; wait for a key int 0x19 ; reboot the machine @@ -230,7 +265,7 @@ cn_exit: boot_success: mov bl, [drive] - jmp word LOADSEG:0 + jmp far [loadsegoff_60] ; Convert cluster to the absolute sector ;input: @@ -263,7 +298,7 @@ c3: add ax, [data_start] adc dx, [data_start + 2] ret - + ; prints text after call to this function. print_1char: @@ -276,8 +311,7 @@ print1: lodsb ; get token cmp al, 0 ; end of string? jne print_1char ; until done ret ; and jump to it - - + ;input: ; DX:AX - 32-bit DOS sector number ; ES:BX - destination buffer diff --git a/boot/boot32lb.asm b/boot/boot32lb.asm new file mode 100644 index 00000000..122d9fe3 --- /dev/null +++ b/boot/boot32lb.asm @@ -0,0 +1,405 @@ +; This is an LBA-enabled FreeDOS FAT32 boot sector (single sector!). +; You can use and copy source code and binaries under the terms of the +; GNU Public License (GPL), version 2 or newer. See www.gnu.org for more. + +; Based on earlier work by FreeDOS kernel hackers, modified heavily by +; Eric Auer and Jon Gentle in 7 / 2003. +; +; Features: Uses LBA and calculates all variables from BPB/EBPB data, +; thus making partition move / resize / image-restore easier. FreeDOS +; can boot from FAT32 partitions which start > 8 GB boundary with this +; boot sector. Disk geometry knowledge is not needed for booting. +; +; Windows uses 2-3 sectors for booting (sector stage, statistics sector, +; filesystem stage). Only using 1 sector for FreeDOS makes multi-booting +; of FreeDOS and Windows on the same filesystem easier. +; +; Requirements: LBA BIOS and 386 or better CPU. Use the older CHS-only +; boot sector if you want FAT32 on really old PCs (problems: you cannot +; boot from > 8 GB boundary, cannot move / resize / ... without applying +; SYS again if you use the CHS-only FAT32 boot sector). +; +; FAT12 / FAT16 hints: Use the older CHS-only boot sector unless you +; have to boot from > 8 GB. The LBA-and-CHS FAT12 / FAT16 boot sector +; needs applying SYS again after move / resize / ... a variant of that +; boot sector without CHS support but with better move / resize / ... +; support would be good for use on LBA harddisks. + + +; Memory layout for the FreeDOS FAT32 single stage boot process: + +; ... +; |-------| 1FE0:7E00 +; |BOOTSEC| +; |RELOC. | +; |-------| 1FE0:7C00 +; ... +; |-------| 2000:0200 +; | FAT | (only 1 sector buffered) +; |-------| 2000:0000 +; ... +; |-------| 0000:7E00 +; |BOOTSEC| overwritten by the kernel, so the +; |ORIGIN | bootsector relocates itself up... +; |-------| 0000:7C00 +; ... +; |-------| +; |KERNEL | maximum size 134k (overwrites bootsec origin) +; |LOADED | (holds 1 sector directory buffer before kernel load) +; |-------| 0060:0000 +; ... + +segment .text + + org 0x7c00 ; this is a boot sector + +Entry: jmp short real_start + nop + +; bp is initialized to 7c00h +; %define bsOemName bp+0x03 ; OEM label (8) +%define bsBytesPerSec bp+0x0b ; bytes/sector (dw) +%define bsSecPerClust bp+0x0d ; sectors/allocation unit (db) +%define bsResSectors bp+0x0e ; # reserved sectors (dw) +%define bsFATs bp+0x10 ; # of fats (db) +; %define bsRootDirEnts bp+0x11 ; # of root dir entries (dw, 0 for FAT32) + ; (FAT32 has root dir in a cluster chain) +; %define bsSectors bp+0x13 ; # sectors total in image (dw, 0 for FAT32) + ; (if 0 use nSectorHuge even if FAT16) +; %define bsMedia bp+0x15 ; media descriptor: fd=2side9sec, etc... (db) +; %define sectPerFat bp+0x16 ; # sectors in a fat (dw, 0 for FAT32) + ; (FAT32 always uses xsectPerFat) +%define sectPerTrack bp+0x18 ; # sectors/track +; %define nHeads bp+0x1a ; # heads (dw) +%define nHidden bp+0x1c ; # hidden sectors (dd) +; %define nSectorHuge bp+0x20 ; # sectors if > 65536 (dd) +%define xsectPerFat bp+0x24 ; Sectors/Fat (dd) + ; +0x28 dw flags (for fat mirroring) + ; +0x2a dw filesystem version (usually 0) +%define xrootClst bp+0x2c ; Starting cluster of root directory (dd) + ; +0x30 dw -1 or sector number of fs.-info sector + ; +0x32 dw -1 or sector number of boot sector backup + ; (+0x34 .. +0x3f reserved) +%define drive bp+0x40 ; Drive number + +%define LOADSEG 0x0060 + +%define FATSEG 0x2000 + +%define fat_secshift fat_afterss-1 ; each fat sector describes 2^?? + ; clusters (db) (selfmodifying) +%define fat_sector bp+0x44 ; last accessed FAT sector (dd) + ; (overwriting unused bytes) +%define fat_start bp+0x48 ; first FAT sector (dd) + ; (overwriting unused bytes) +%define data_start bp+0x4c ; first data sector (dd) + ; (overwriting unused bytes) + + times 0x5a-$+$$ db 0 + ; not used: [0x42] = byte 0x29 (ext boot param flag) + ; [0x43] = dword serial + ; [0x47] = label (padded with 00, 11 bytes) + ; [0x52] = "FAT32",32,32,32 (not used by Windows) + ; ([0x5a] is where FreeDOS parts start) + +;----------------------------------------------------------------------- +; ENTRY +;----------------------------------------------------------------------- + +real_start: cld + sub ax, ax + mov ds, ax + lss sp, [mystack] ; initialize stack + int 0x13 ; reset drive + + mov ax, 0x1FE0 + mov es, ax + mov si, sp + mov di, sp + mov bp, sp ; bp-relative parameter addresses used + mov cx, 0x0100 + rep movsw ; move boot code to the 0x1FE0:0x0000 + jmp word 0x1FE0:cont + +; ------------- + +cont: mov ds, ax + mov ss, ax ; stack and BP-relative moves up, too + mov [drive], dl ; BIOS passes drive number in DL + + mov si, msg_LoadFreeDOS + call print ; modifies AX BX SI + + +; ------------- + +; CALCPARAMS: figure out where FAT and DATA area starts +; (modifies EAX EDX, sets fat_start and data_start variables) + +calc_params: xor eax, eax + mov [fat_sector], eax ; init buffer status + + ; first, find fat_start: + mov ax, [bsResSectors] ; no movzx eax, word... needed + add eax, [nHidden] + mov [fat_start], eax ; first FAT sector + mov [data_start], eax ; (only first part of value) + + ; next, find data_start: + mov eax, [bsFATs] ; no movzx ... byte needed: + ; the 2 dw after the bsFATs db are 0 by FAT32 definition :-). + imul dword [xsectPerFat] ; (also changes edx) + add [data_start], eax ; first DATA sector + ; (adding in RAM is shorter!) + + ; finally, find fat_secshift: + mov ax, 512 ; default sector size (means default shift) + ; shift = log2(secSize) - log2(fatEntrySize) +;--- mov cl, 9-2 ; shift is 7 for 512 bytes per sector +fatss_scan: cmp ax, [bsBytesPerSec] + jz fatss_found + add ax,ax +;--- inc cx + inc word [fat_secshift] ;XXX ; initially 9-2 (byte!) + jmp short fatss_scan ; try other sector sizes +fatss_found: +;--- mov [fat_secshift], cl + +; ------------- + +; FINDFILE: Searches for the file in the root directory. +; Returns: EAX = first cluster of file + + mov eax, [xrootClst] ; root dir cluster + +ff_next_clust: push eax ; save cluster + call convert_cluster + jc boot_error ; EOC encountered + ; EDX is clust/sector, EAX is sector + +ff_next_sector: mov bx, LOADSEG + mov es, bx + sub bx, bx ; load to loadseg:0 + call readDisk +;--- push eax ; save sector + +;--- xor ax, ax ; first dir. entry in this sector + xor di, di ;XXX + + ; Search for KERNEL.SYS file name, and find start cluster. +ff_next_entry: mov cx, 11 + mov si, filename +;--- mov di, ax + repe cmpsb + jz ff_done ; note that di now is at dirent+11 + +;--- add ax, 0x20 ; next directory entry +;--- cmp ax, [bsBytesPerSec] ; end of sector reached? + add di, byte 0x20 ;XXX + and di, byte -0x20 ; 0xffe0 ;XXX + cmp di, [bsBytesPerSec] ;XXX + jnz ff_next_entry + +;--- pop eax ; restore sector + dec dx ; next sector in cluster + jnz ff_next_sector + +ff_walk_fat: pop eax ; restore current cluster + call next_cluster ; find next cluster + jmp ff_next_clust + +ff_done: push word [es:di+0x14-11] ; get cluster number HI + push word [es:di+0x1A-11] ; get cluster number LO + pop eax ; convert to 32bit + + sub bx, bx ; ES points to LOADSEG + ; (kernel -> ES:BX) + +; ------------- + +read_kernel: push eax + call convert_cluster + jc boot_success ; EOC encountered - done + ; EDX is sectors in cluster, EAX is sector + +rk_in_cluster: call readDisk + dec dx + jnz rk_in_cluster ; loop over sect. in cluster + +rk_walk_fat: pop eax + call next_cluster + jmp read_kernel + +;----------------------------------------------------------------------- + +boot_success: mov bl, [drive] + jmp word LOADSEG:0 + +;----------------------------------------------------------------------- + +boot_error: mov si, msg_BootError + call print ; modifies AX BX SI + +wait_key: xor ah,ah + int 0x16 ; wait for a key +reboot: int 0x19 ; reboot the machine + +;----------------------------------------------------------------------- + +; given a cluster number, find the number of the next cluster in +; the FAT chain. Needs fat_secshift and fat_start. +; input: EAX - cluster +; output: EAX - next cluster + +next_cluster: push es + push di + push bx + + mov di, ax + shl di, 2 ; 32bit FAT + + push ax + mov ax, [bsBytesPerSec] + dec ax + and di, ax ; mask to sector size + pop ax + + shr eax, 7 ; e.g. 9-2 for 512 by/sect. +fat_afterss: ; selfmodifying code: previous byte is patched! + ; (to hold the fat_secshift value) + + add eax, [fat_start] ; absolute sector number now + + mov bx, FATSEG + mov es, bx + sub bx, bx + + cmp eax, [fat_sector] ; already buffered? + jz cn_buffered + mov [fat_sector],eax ; number of buffered sector + call readDisk + +cn_buffered: and byte [es:di+3],0x0f ; mask out top 4 bits + mov eax, [es:di] ; read next cluster number + + pop bx + pop di + pop es + ret + + +;----------------------------------------------------------------------- + +; Convert cluster number to the absolute sector number +; ... or return carry if EndOfChain! Needs data_start. +; input: EAX - target cluster +; output: EAX - absolute sector +; EDX - [bsSectPerClust] (byte) +; carry clear +; (if carry set, EAX/EDX unchanged, end of chain) + +convert_cluster: + cmp eax, 0x0ffffff8 ; if end of cluster chain... + jnb end_of_chain + + ; sector = (cluster-2) * clustersize + data_start + dec eax + dec eax + + movzx edx, byte [bsSecPerClust] + push edx + mul edx + pop edx + add eax, [data_start] + ; here, carry is unset (unless parameters are wrong) + ret + +end_of_chain: stc ; indicate EOC by carry + ret + +;----------------------------------------------------------------------- + +; PRINT - prints string DS:SI +; modifies AX BX SI + +printchar: xor bx, bx ; video page 0 + mov ah, 0x0e ; print it + int 0x10 ; via TTY mode +print: lodsb ; get token + cmp al, 0 ; end of string? + jne printchar ; until done + ret ; return to caller + +;----------------------------------------------------------------------- + +; Read a sector from disk, using LBA +; input: EAX - 32-bit DOS sector number +; ES:BX - destination buffer +; (will be filled with 1 sector of data) +; output: ES:BX points one byte after the last byte read. +; EAX - next sector + +readDisk: push dx + push si + push di + +read_next: push eax ; would ax be enough? + mov di, sp ; remember parameter block end + +;--- db 0x66 ; operand size override (push dword) + push byte 0 ;XXX ; other half of the 32 bits at [C] + ; (did not trust "o32 push byte 0" opcode) + push byte 0 ; [C] sector number high 32bit + push eax ; [8] sector number low 32bit + push es ; [6] buffer segment + push bx ; [4] buffer offset + push byte 1 ; [2] 1 sector (word) + push byte 16 ; [0] size of parameter block (word) + mov si, sp + mov dl, [drive] + mov ah, 42h ; disk read + int 0x13 + + mov sp, di ; remove parameter block from stack + ; (without changing flags!) + pop eax ; would ax be enough? + + jnc read_ok ; jump if no error + + push ax ; !! + xor ah, ah ; else, reset and retry + int 0x13 + pop ax ; !! + jmp read_next + +read_ok: inc eax ; next sector + add bx, word [bsBytesPerSec] + jnc no_incr_es ; if overflow... + + mov dx, es + add dh, 0x10 ; ...add 1000h to ES + mov es, dx + +no_incr_es: pop di + pop si + pop dx + ret + +;----------------------------------------------------------------------- + +msg_LoadFreeDOS db "Loading FreeDOS ",0 +msg_BootError db "No " + ; currently, only "kernel.sys not found" gives a message, + ; but read errors in data or root or fat sectors do not. + +filename db "KERNEL SYS" + +msg_BootErrorPart2: + db " ???",0 + + times 0x01fa-$+$$ db 0 + +mystack dw 0x7c00 ; the 0 for SS overlaps into sign! + ; (so we can LSS SP to 0:7c00) +sign dw 0, 0xAA55 + ; Win9x uses all 4 bytes as magic value here. diff --git a/boot/makefile b/boot/makefile index 8fd492d4..a01099e8 100644 --- a/boot/makefile +++ b/boot/makefile @@ -7,19 +7,22 @@ !include "..\mkfiles\generic.mak" -production: b_fat12.bin b_fat16.bin b_fat32.bin +production: fat12com.bin fat16com.bin fat32chs.bin fat32lba.bin -b_fat12.bin: boot.asm - $(NASM) -dISFAT12 boot.asm -ob_fat12.bin +fat12com.bin: boot.asm + $(NASM) -dISFAT12 boot.asm -ofat12com.bin -b_fat16.bin: boot.asm - $(NASM) -dISFAT16 boot.asm -ob_fat16.bin +fat16com.bin: boot.asm + $(NASM) -dISFAT16 boot.asm -ofat16com.bin -b_fat32.bin: boot32.asm - $(NASM) boot32.asm -ob_fat32.bin +fat32chs.bin: boot32.asm + $(NASM) boot32.asm -ofat32chs.bin + +fat32lba.bin: boot32lb.asm + $(NASM) boot32lb.asm -ofat32lba.bin clobber: clean - -$(RM) b_fat12.bin b_fat16.bin b_fat32.bin status.me + -$(RM) *.bin status.me clean: -$(RM) *.lst *.map *.bak *.obj diff --git a/sys/makefile b/sys/makefile index 9f340158..b6199066 100644 --- a/sys/makefile +++ b/sys/makefile @@ -25,14 +25,17 @@ bin2c.com: bin2c.c ..\bin\sys.com: sys.com copy sys.com ..\bin -b_fat12.h: ..\boot\b_fat12.bin bin2c.com - .\bin2c ..\boot\b_fat12.bin b_fat12.h b_fat12 +fat12com.h: ..\boot\fat12com.bin bin2c.com + .\bin2c ..\boot\fat12com.bin fat12com.h fat12com -b_fat16.h: ..\boot\b_fat16.bin bin2c.com - .\bin2c ..\boot\b_fat16.bin b_fat16.h b_fat16 +fat16com.h: ..\boot\fat16com.bin bin2c.com + .\bin2c ..\boot\fat16com.bin fat16com.h fat16com -b_fat32.h: ..\boot\b_fat32.bin bin2c.com - .\bin2c ..\boot\b_fat32.bin b_fat32.h b_fat32 +fat32chs.h: ..\boot\fat32chs.bin bin2c.com + .\bin2c ..\boot\fat32chs.bin fat32chs.h fat32chs + +fat32lba.h: ..\boot\fat32lba.bin bin2c.com + .\bin2c ..\boot\fat32lba.bin fat32lba.h fat32lba prf.obj: ..\kernel\prf.c $(CC) $(CFLAGS) ..\kernel\prf.c @@ -43,12 +46,12 @@ sys.com: $(SYS_EXE_dependencies) $(CL) $(CFLAGST) $(TINY) $(SYS_EXE_dependencies) clobber: clean - -$(RM) bin2c.com sys.com b_fat12.h b_fat16.h b_fat32.h + -$(RM) bin2c.com sys.com fat*.h clean: -$(RM) *.obj *.bak *.crf *.xrf *.map *.lst *.las *.cod *.err status.me # *Individual File Dependencies* -sys.obj: sys.c ..\hdr\portab.h ..\hdr\device.h b_fat12.h b_fat16.h b_fat32.h +sys.obj: sys.c ..\hdr\portab.h ..\hdr\device.h fat12com.h fat16com.h fat32chs.h fat32lba.h $(CC) $(CFLAGS) $*.c diff --git a/sys/sys.c b/sys/sys.c index 9ffadca9..6acd24c9 100644 --- a/sys/sys.c +++ b/sys/sys.c @@ -26,16 +26,10 @@ ***************************************************************/ -/* - TE thinks, that the boot info storage should be done by FORMAT, noone else - unfortunately, that doesn't work ??? -*/ -#define STORE_BOOT_INFO - #define DEBUG /* #define DDEBUG */ -#define SYS_VERSION "v2.6" +#define SYS_VERSION "v2.7" #include #include @@ -53,13 +47,25 @@ #endif #define SYS_MAXPATH 260 #include "portab.h" +#include "algnbyte.h" +#include "device.h" +#include "dcb.h" +#include "xstructs.h" +#include "date.h" +#include "../hdr/time.h" +#include "fat.h" + +/* These definitions deliberately put here instead of + * #including to make executable MUCH smaller + */ extern WORD CDECL printf(CONST BYTE * fmt, ...); extern WORD CDECL sprintf(BYTE * buff, CONST BYTE * fmt, ...); -#include "b_fat12.h" -#include "b_fat16.h" +#include "fat12com.h" +#include "fat16com.h" #ifdef WITHFAT32 -#include "b_fat32.h" +#include "fat32chs.h" +#include "fat32lba.h" #endif #ifndef __WATCOMC__ @@ -68,7 +74,9 @@ extern WORD CDECL sprintf(BYTE * buff, CONST BYTE * fmt, ...); #else -int unlink(const char *pathname); +extern long filelength(int __handle); +extern int unlink(const char *pathname); + /* some non-conforming functions to make the executable smaller */ int open(const char *pathname, int flags, ...) { @@ -134,18 +142,12 @@ char *getenv(const char *name) BYTE pgm[] = "SYS"; void put_boot(COUNT, BYTE *, BOOL); -BOOL check_space(COUNT, BYTE *); +BOOL check_space(COUNT, ULONG); BOOL copy(COUNT drive, BYTE * srcPath, BYTE * rootPath, BYTE * file); -COUNT DiskRead(WORD, WORD, WORD, WORD, WORD, BYTE FAR *); -COUNT DiskWrite(WORD, WORD, WORD, WORD, WORD, BYTE FAR *); #define SEC_SIZE 512 #define COPY_SIZE 0x7e00 -#ifdef _MSC_VER -#pragma pack(1) -#endif - struct bootsectortype { UBYTE bsJump[3]; char OemName[8]; @@ -167,11 +169,6 @@ struct bootsectortype { ULONG bsVolumeID; char bsVolumeLabel[11]; char bsFileSysType[8]; - char unused[2]; - UWORD sysRootDirSecs; /* of sectors root dir uses */ - ULONG sysFatStart; /* first FAT sector */ - ULONG sysRootDirStart; /* first root directory sector */ - ULONG sysDataStart; /* first data sector */ }; struct bootsectortype32 { @@ -203,13 +200,14 @@ struct bootsectortype32 { ULONG bsSerialNumber; char bsVolumeLabel[11]; char bsFileSystemID[8]; - ULONG sysFatStart; - ULONG sysDataStart; - UWORD sysFatSecMask; - UWORD sysFatSecShift; }; -UBYTE newboot[SEC_SIZE], oldboot[SEC_SIZE]; +/* + * globals needed by put_boot & check_space + */ +enum {FAT12 = 12, FAT16 = 16, FAT32 = 32} fs; /* file system type */ +/* static */ struct xfreespace x; /* we make this static to be 0 by default - + this avoids FAT misdetections */ #define SBOFFSET 11 #define SBSIZE (sizeof(struct bootsectortype) - SBOFFSET) @@ -217,8 +215,9 @@ UBYTE newboot[SEC_SIZE], oldboot[SEC_SIZE]; /* essentially - verify alignment on byte boundaries at compile time */ struct VerifyBootSectorSize { - char failure1[sizeof(struct bootsectortype) == 78 ? 1 : -1]; - char failure2[sizeof(struct bootsectortype) == 78 ? 1 : 0]; + char failure1[sizeof(struct bootsectortype) == 62 ? 1 : -1]; + char failure2[sizeof(struct bootsectortype) == 62 ? 1 : 0]; +/* (Watcom has a nice warning for this, by the way) */ }; int FDKrnConfigMain(int argc, char **argv); @@ -233,7 +232,7 @@ int main(int argc, char **argv) BYTE rootPath[4]; /* alternate source path to try if not '\0' */ WORD slen; - printf("FreeDOS System Installer " SYS_VERSION "\n\n"); + printf("FreeDOS System Installer " SYS_VERSION ", " __DATE__ "\n\n"); if (argc > 1 && memicmp(argv[1], "CONFIG", 6) == 0) { @@ -263,18 +262,15 @@ int main(int argc, char **argv) if (drivearg == 0) { - printf("Usage: %s [source] drive: [bootsect [BOTH|BOOTONLY]]\n", pgm); - printf - (" source = A:,B:,C:\\KERNEL\\BIN\\,etc., or current directory if not given\n"); - printf(" drive = A,B,etc.\n"); - printf - (" bootsect = name of 512-byte boot sector file image for drive:\n"); - printf(" to write to *instead* of real boot sector\n"); - printf - (" BOTH : write to *both* the real boot sector and the image file\n"); - printf - (" BOOTONLY : do *not* copy kernel / shell, only update boot sector or image\n"); - printf("%s CONFIG /help\n", pgm); + printf( + "Usage: %s [source] drive: [bootsect [BOTH]] [BOOTONLY]\n" + " source = A:,B:,C:\\KERNEL\\BIN\\,etc., or current directory if not given\n" + " drive = A,B,etc.\n" + " bootsect = name of 512-byte boot sector file image for drive:\n" + " to write to *instead* of real boot sector\n" + " BOTH : write to *both* the real boot sector and the image file\n" + " BOOTONLY : do *not* copy kernel / shell, only update boot sector or image\n" + "%s CONFIG /help\n", pgm, pgm); exit(1); } drive = toupper(argv[drivearg][0]) - 'A'; @@ -307,34 +303,25 @@ int main(int argc, char **argv) else sprintf(rootPath, "%c:\\", 'A' + srcDrive); - if ((argc <= drivearg + 2) - || (memicmp(argv[drivearg + 2], "BOOTONLY", 8) != 0)) - { - if (!check_space(drive, oldboot)) - { - printf("%s: Not enough space to transfer system files\n", pgm); - exit(1); - } - - printf("\nCopying KERNEL.SYS...\n"); - if (!copy(drive, srcPath, rootPath, "KERNEL.SYS")) - { - printf("\n%s: cannot copy \"KERNEL.SYS\"\n", pgm); - exit(1); - } - } /* copy kernel */ - - if (argc > drivearg + 1) - bsFile = argv[drivearg + 1]; + if (argc > drivearg + 1 && memicmp(argv[drivearg + 1], "BOOTONLY", 8) != 0) + bsFile = argv[drivearg + 1]; /* don't write to file "BOOTONLY" */ printf("\nWriting boot sector...\n"); put_boot(drive, bsFile, (argc > drivearg + 2) && memicmp(argv[drivearg + 2], "BOTH", 4) == 0); - if ((argc <= drivearg + 2) - || (memicmp(argv[drivearg + 2], "BOOTONLY", 8) != 0)) + if (argc <= drivearg + (bsFile ? 2 : 1) + || memicmp(argv[drivearg + (bsFile ? 2 : 1)], "BOOTONLY", 8) != 0 + && memicmp(argv[drivearg + (bsFile ? 3 : 2)], "BOOTONLY", 8) != 0) { + printf("\nCopying KERNEL.SYS...\n"); + if (!copy(drive, srcPath, rootPath, "KERNEL.SYS")) + { + printf("\n%s: cannot copy \"KERNEL.SYS\"\n", pgm); + exit(1); + } /* copy kernel */ + printf("\nCopying COMMAND.COM...\n"); if (!copy(drive, srcPath, rootPath, "COMMAND.COM")) { @@ -350,8 +337,8 @@ int main(int argc, char **argv) printf("\n%s: cannot copy \"COMMAND.COM\"\n", pgm); exit(1); } - } - } /* copy shell */ + } /* copy shell */ + } printf("\nSystem transferred.\n"); return 0; @@ -372,7 +359,7 @@ VOID dump_sector(unsigned char far * sec) } for (y = 0; y < 16; y++) { - c = oldboot[x * 16 + y]; + c = sec[x * 16 + y]; if (isprint(c)) printf("%c", c); else @@ -523,16 +510,6 @@ int MyAbsReadWrite(int DosDrive, int count, ULONG sector, void *buffer, #ifdef __WATCOMC__ -unsigned getdrivespace(COUNT drive, unsigned *total_clusters); -#pragma aux getdrivespace = \ - "mov ah, 0x36" \ - "inc dx" \ - "int 0x21" \ - "mov [si], dx" \ - parm [dx] [si] \ - modify [bx cx dx] \ - value [ax]; - unsigned getextdrivespace(void far *drivename, void *buf, unsigned buf_size); #pragma aux getextdrivespace = \ "mov ax, 0x7303" \ @@ -542,18 +519,7 @@ unsigned getextdrivespace(void far *drivename, void *buf, unsigned buf_size); parm [es dx] [di] [cx] \ value [ax]; -#else - -unsigned getdrivespace(COUNT drive, unsigned *total_clusters) -{ - union REGS regs; - - regs.h.ah = 0x36; /* get drive free space */ - regs.h.dl = drive + 1; /* 1 = 'A',... */ - intdos(®s, ®s); - *total_clusters = regs.x.dx; - return regs.x.ax; -} /* getdrivespace */ +#else /* !defined __WATCOMC__ */ unsigned getextdrivespace(void *drivename, void *buf, unsigned buf_size) { @@ -573,20 +539,47 @@ unsigned getextdrivespace(void *drivename, void *buf, unsigned buf_size) return regs.x.ax == 0x7300 || regs.x.cflag; } /* getextdrivespace */ +#endif /* defined __WATCOMC__ */ + +#ifdef __WATCOMC__ +/* + * If BIOS has got LBA extensions, after the Int 13h call BX will be 0xAA55. + * If extended disk access functions are supported, bit 0 of CX will be set. + */ +BOOL haveLBA(void); /* return TRUE if we have LBA BIOS, FALSE otherwise */ +#pragma aux haveLBA = \ + "mov ax, 0x4100" /* IBM/MS Int 13h Extensions - installation check */ \ + "mov bx, 0x55AA" \ + "mov dl, 0x80" \ + "int 0x13" \ + "xor ax, ax" \ + "cmp bx, 0xAA55" \ + "jne quit" \ + "and cx, 1" \ + "xchg cx, ax" \ +"quit:" \ + modify [bx cx] \ + value [ax]; +#else + +BOOL haveLBA(void) +{ + union REGS r; + r.x.ax = 0x4100; + r.x.bx = 0x55AA; + r.h.dl = 0x80; + int86(0x13, &r, &r); + return r.x.bx == 0xAA55 && r.x.cx & 1; +} #endif VOID put_boot(COUNT drive, BYTE * bsFile, BOOL both) { - ULONG temp; - struct bootsectortype *bs; #ifdef WITHFAT32 struct bootsectortype32 *bs32; #endif - int fs; - char *drivename = "A:\\"; - static unsigned char x[0x40]; /* we make this static to be 0 by default - - this avoids FAT misdetections */ - unsigned total_clusters; + struct bootsectortype *bs; + static unsigned char oldboot[SEC_SIZE], newboot[SEC_SIZE]; #ifdef DEBUG printf("Reading old bootsector from drive %c:\n", drive + 'A'); @@ -606,87 +599,58 @@ VOID put_boot(COUNT drive, BYTE * bsFile, BOOL both) #endif bs = (struct bootsectortype *)&oldboot; - if ((bs->bsFileSysType[4] == '6') && (bs->bsBootSignature == 0x29)) - { - fs = 16; - } - else - { - fs = 12; - } - -/* - the above code is not save enough for me (TE), so we change the - FS detection method to GetFreeDiskSpace(). - this should work, as the disk was writeable, so GetFreeDiskSpace should work. -*/ - /* would work different when reading from an image */ - if (getdrivespace(drive, &total_clusters) == 0xffff) { - printf("can't get free disk space for %c:\n", drive + 'A'); - exit(1); - } - - if (total_clusters <= 0xff6) - { - if (fs != 12) - printf("warning : new detection overrides old detection\a\n"); - fs = 12; - } - else - { - - if (fs != 16) - printf("warning : new detection overrides old detection\a\n"); - fs = 16; - - /* fs = 16/32. - we don't want to crash a FAT32 drive - */ - - drivename[0] = 'A' + drive; - /* would also work different when reading from an image */ - if (getextdrivespace(drivename, x, sizeof(x))) - /* error --> no Win98 --> no FAT32 */ - { - printf("get extended drive space not supported --> no FAT32\n"); - } + /* see "FAT: General Overview of On-Disk Format" v1.02, 5.V.1999 + * (http://www.nondot.org/sabre/os/files/FileSystems/FatFormat.pdf) + */ + ULONG fatSize, totalSectors, dataSectors, clusters; + UCOUNT rootDirSectors; + + bs32 = (struct bootsectortype32 *)&oldboot; + rootDirSectors = (bs->bsRootDirEnts * DIRENT_SIZE /* 32 */ + + bs32->bsBytesPerSec - 1) / bs32->bsBytesPerSec; + fatSize = bs32->bsFATsecs ? bs32->bsFATsecs : bs32->bsBigFatSize; + totalSectors = bs32->bsSectors ? bs32->bsSectors : bs32->bsHugeSectors; + dataSectors = totalSectors + - bs32->bsResSectors - (bs32->bsFATs * fatSize) - rootDirSectors; + clusters = dataSectors / bs32->bsSecPerClust; + + if (clusters < FAT_MAGIC) /* < 4085 */ + fs = FAT12; + else if (clusters < FAT_MAGIC16) /* < 65525 */ + fs = FAT16; else - { - if (*(unsigned long *)(x + 0x10) /* total number of clusters */ - > (unsigned)65526l) - { - fs = 32; - } - } + fs = FAT32; } - if (fs == 16) + if (bs->bsBytesPerSec != SEC_SIZE) { - memcpy(newboot, b_fat16, SEC_SIZE); /* copy FAT16 boot sector */ - printf("FAT type: FAT16\n"); + printf("Sector size is not 512 but %d bytes - not currently supported!\n", + bs->bsBytesPerSec); + exit(1); /* Japan?! */ } - else if (fs == 12) - { - memcpy(newboot, b_fat12, SEC_SIZE); /* copy FAT12 boot sector */ - printf("FAT type: FAT12\n"); - } - else + + if (fs == FAT32) { printf("FAT type: FAT32\n"); -#ifdef WITHFAT32 - memcpy(newboot, b_fat32, SEC_SIZE); /* copy FAT32 boot sector */ +#ifdef WITHFAT32 /* copy one of the FAT32 boot sectors */ + memcpy(newboot, haveLBA() ? fat32lba : fat32chs, SEC_SIZE); #else - printf("SYS hasn't been compiled with FAT32 support."); - printf("Consider using -DWITHFAT32 option.\n"); + printf("SYS hasn't been compiled with FAT32 support.\n" + "Consider using -DWITHFAT32 option.\n"); exit(1); #endif } + else + { /* copy the FAT12/16 CHS+LBA boot sector */ + printf("FAT type: FAT1%c\n", fs + '0' - 10); + memcpy(newboot, fs == FAT16 ? fat16com : fat12com, SEC_SIZE); + } /* Copy disk parameter from old sector to new sector */ #ifdef WITHFAT32 - if (fs == 32) + if (fs == FAT32) memcpy(&newboot[SBOFFSET], &oldboot[SBOFFSET], SBSIZE32); else #endif @@ -697,70 +661,30 @@ VOID put_boot(COUNT drive, BYTE * bsFile, BOOL both) memcpy(bs->OemName, "FreeDOS ", 8); #ifdef WITHFAT32 - if (fs == 32) + if (fs == FAT32) { bs32 = (struct bootsectortype32 *)&newboot; - - temp = bs32->bsHiddenSecs + bs32->bsResSectors; - bs32->sysFatStart = temp; - - bs32->sysDataStart = temp + bs32->bsBigFatSize * bs32->bsFATs; - bs32->sysFatSecMask = bs32->bsBytesPerSec / 4 - 1; - - temp = bs32->sysFatSecMask + 1; - for (bs32->sysFatSecShift = 0; temp != 1; - bs32->sysFatSecShift++, temp >>= 1) ; /* put 0 for A: or B: (force booting from A:), otherwise use DL */ bs32->bsDriveNumber = drive < 2 ? 0 : 0xff; - } #ifdef DEBUG - if (fs == 32) - { - printf("FAT starts at sector %lx = (%lx + %x)\n", bs32->sysFatStart, + printf(" FAT starts at sector %lx + %x\n", bs32->bsHiddenSecs, bs32->bsResSectors); - printf("DATA starts at sector %lx\n", bs32->sysDataStart); - } #endif + } else #endif { -#ifdef STORE_BOOT_INFO - /* TE thinks : never, see above */ - /* temporary HACK for the load segment (0x0060): it is in unused */ - /* only needed for older kernels */ - *((UWORD *) (bs->unused)) = - *((UWORD *) (((struct bootsectortype *)&b_fat16)->unused)); - /* end of HACK */ - /* root directory sectors */ - - bs->sysRootDirSecs = bs->bsRootDirEnts / 16; - - /* sector FAT starts on */ - temp = bs->bsHiddenSecs + bs->bsResSectors; - bs->sysFatStart = temp; - - /* sector root directory starts on */ - temp = temp + bs->bsFATsecs * bs->bsFATs; - bs->sysRootDirStart = temp; - - /* sector data starts on */ - temp = temp + bs->sysRootDirSecs; - bs->sysDataStart = temp; /* put 0 for A: or B: (force booting from A:), otherwise use DL */ bs->bsDriveNumber = drive < 2 ? 0 : 0xff; } #ifdef DEBUG /* add an option to display this on user request? */ printf("Root dir entries = %u\n", bs->bsRootDirEnts); - printf("Root dir sectors = %u\n", bs->sysRootDirSecs); - printf("FAT starts at sector %lu = (%lu + %u)\n", bs->sysFatStart, + printf("FAT starts at sector (%lu + %u)\n", bs->bsHiddenSecs, bs->bsResSectors); - printf("Root directory starts at sector %lu = (PREVIOUS + %u * %u)\n", - bs->sysRootDirStart, bs->bsFATsecs, bs->bsFATs); - printf("DATA starts at sector %lu = (PREVIOUS + %u)\n", bs->sysDataStart, - bs->sysRootDirSecs); -#endif + printf("Root directory starts at sector (PREVIOUS + %u * %u)\n", + bs->bsFATsecs, bs->bsFATs); #endif #ifdef DDEBUG @@ -812,15 +736,34 @@ VOID put_boot(COUNT drive, BYTE * bsFile, BOOL both) } /* put_boot */ -BOOL check_space(COUNT drive, BYTE * BlkBuffer) +/* + * Returns TRUE if `drive` has at least `bytes` free space, FALSE otherwise. + * put_sector() must have been already called to determine file system type. + */ +BOOL check_space(COUNT drive, ULONG bytes) { - /* this should check, if on destination is enough space - to hold command.com+ kernel.sys */ - - UNREFERENCED_PARAMETER(drive); - UNREFERENCED_PARAMETER(BlkBuffer); - - return TRUE; +#ifdef WITHFAT32 + if (fs == FAT32) + { + char *drivename = "A:\\"; + drivename[0] = 'A' + drive; + getextdrivespace(drivename, &x, sizeof(x)); + return x.xfs_freeclusters > (bytes / (x.xfs_clussize * x.xfs_secsize)); + } + else +#endif + { +#ifdef __TURBOC__ + struct dfree df; + getdfree(drive + 1, &df); + return (ULONG)df.df_avail * df.df_sclus * df.df_bsec >= bytes; +#else + struct _diskfree_t df; + _dos_getdiskfree(drive + 1, &df); + return (ULONG)df.avail_clusters * df.sectors_per_cluster + * df.bytes_per_sector >= bytes; +#endif + } } /* check_space */ @@ -859,7 +802,7 @@ BOOL copy(COUNT drive, BYTE * srcPath, BYTE * rootPath, BYTE * file) truename(dest, source); strcpy(source, dest); sprintf(dest, "%c:\\%s", 'A' + drive, file); - if (strcmp(source, dest) == 0) + if (stricmp(source, dest) == 0) { printf("%s: source and destination are identical: skipping \"%s\"\n", pgm, source); @@ -872,6 +815,13 @@ BOOL copy(COUNT drive, BYTE * srcPath, BYTE * rootPath, BYTE * file) return FALSE; } + if (!check_space(drive, filelength(fdin))) + { + printf("%s: Not enough space to transfer %s\n", pgm, file); + close(fdin); + exit(1); + } + if ((fdout = open(dest, O_RDWR | O_TRUNC | O_CREAT | O_BINARY, S_IREAD | S_IWRITE)) < 0) @@ -893,25 +843,22 @@ BOOL copy(COUNT drive, BYTE * srcPath, BYTE * rootPath, BYTE * file) copied += ret; } -#ifdef __TURBOC__ { +#if defined __WATCOMC__ || defined _MSC_VER /* || defined __BORLANDC__ */ + unsigned short date, time; + _dos_getftime(fdin, &date, &time); + _dos_setftime(fdout, date, time); +#elif defined __TURBOC__ struct ftime ftime; getftime(fdin, &ftime); setftime(fdout, &ftime); - } #endif -#ifdef __WATCOMC__ - { - unsigned short date, time; - _dos_getftime(fdin, &date, &time); - _dos_setftime(fdout, date, time); } -#endif close(fdin); close(fdout); -#ifdef _MSV_VER +#ifdef __SOME_OTHER_COMPILER__ { #include struct utimbuf utimb; @@ -920,7 +867,6 @@ BOOL copy(COUNT drive, BYTE * srcPath, BYTE * rootPath, BYTE * file) utimb.modtime = fstatbuf.st_mtime; /* modification time */ utime(dest, &utimb); }; - #endif printf("%lu Bytes transferred", copied); From 8a7b83ab63e96c7e3920fdcbd83a27c1f4a31824 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sat, 9 Aug 2003 09:35:18 +0000 Subject: [PATCH 259/671] Remove (unused) strncpy. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@653 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/asmsupt.asm | 32 -------------------------------- kernel/misc.c | 7 ------- kernel/proto.h | 2 -- kernel/strings.c | 18 ------------------ 4 files changed, 59 deletions(-) diff --git a/kernel/asmsupt.asm b/kernel/asmsupt.asm index 212835a3..1b3b2bf1 100644 --- a/kernel/asmsupt.asm +++ b/kernel/asmsupt.asm @@ -52,7 +52,6 @@ segment HMA_TEXT ; fmemcpy(void FAR *dest, void FAR *src, int count) ; memset(void *dest, int ch, int count); ; fmemset(void FAR *dest, int ch, int count); -; fstrncpy(void FAR*dest, void FAR *src, int count); ; strcpy (void *dest, void *src); ; fstrcpy (void FAR*dest, void FAR *src); ; strlen (void *dest); @@ -222,37 +221,6 @@ pascal_return: add sp,bx jmp cx -;*************************************************************** -%if 0 -nix pascal - still untested - global _fstrncpy -_fstrncpy: - call pascal_setup - - ; Get the source pointer, ss - lds si,[bp+8] - - ; and the destination pointer, d - les di,[bp+4] - - mov cx,[bp+12] - - jcxz pascal_return - ;; dec cx - ; jcxz store_one_byte -strncpy_loop: lodsb - stosb - test al,al - loopnz strncpy_loop - -store_one_byte: xor al,al - ; the spec for strncpy() would require - ; rep stosb - ; to fill remaining part of buffer - stosb - - jmp short pascal_return -%endif ;***************************************************************** ; fstrcpy (void FAR*dest, void FAR *src); diff --git a/kernel/misc.c b/kernel/misc.c index d76a4d58..248c0baf 100644 --- a/kernel/misc.c +++ b/kernel/misc.c @@ -53,13 +53,6 @@ VOID fstrcpy(REG BYTE FAR * d, REG CONST BYTE FAR * s) *d = '\0'; } -VOID fstrncpy(BYTE FAR * d, BYTE CONST FAR * s, REG size_t n) -{ - while (*s && n--) - *d++ = *s++; - *d = '\0'; -} - VOID * memcpy(REG VOID * d, REG CONST VOID * s, REG size_t n) { char *cd = d; diff --git a/kernel/proto.h b/kernel/proto.h index a9f9309a..0c99ff06 100644 --- a/kernel/proto.h +++ b/kernel/proto.h @@ -282,12 +282,10 @@ void put_string(const char *s); size_t /* ASMCFUNC */ ASMPASCAL strlen(const char * s); size_t /* ASMCFUNC */ ASMPASCAL fstrlen(const char FAR * s); char FAR * /*ASMCFUNC*/ ASMPASCAL _fstrcpy(char FAR * d, const char FAR * s); -char * /*ASMCFUNC*/ ASMPASCAL strncpy(char * d, const char * s, size_t l); int /*ASMCFUNC*/ ASMPASCAL strcmp(const char * d, const char * s); int /*ASMCFUNC*/ ASMPASCAL fstrcmp(const char FAR * d, const char FAR * s); int /*ASMCFUNC*/ ASMPASCAL fstrncmp(const char FAR * d, const char FAR * s, size_t l); int /*ASMCFUNC*/ ASMPASCAL strncmp(const char * d, const char * s, size_t l); -void /*ASMCFUNC*/ ASMPASCAL fstrncpy(char FAR * d, const char FAR * s, size_t l); char * /*ASMCFUNC*/ ASMPASCAL strchr(const char * s, int c); char FAR * /*ASMCFUNC*/ ASMPASCAL fstrchr(const char FAR * s, int c); void FAR * /*ASMCFUNC*/ ASMPASCAL fmemchr(const void FAR * s, int c, size_t n); diff --git a/kernel/strings.c b/kernel/strings.c index 6cfc3698..8ec16dec 100644 --- a/kernel/strings.c +++ b/kernel/strings.c @@ -59,16 +59,6 @@ VOID _fstrcpy(REG BYTE FAR * d, REG BYTE FAR * s) *d = 0; } -char *strncpy(register char *d, register const char *s, size_t l) -{ - size_t idx = 1; - char *tmp = d; - while (*s != 0 && idx++ <= l) - *d++ = *s++; - *d = 0; - return tmp; -} - int strcmp(REG CONST BYTE * d, REG CONST BYTE * s) { while (*s != '\0' && *d != '\0') @@ -119,14 +109,6 @@ COUNT fstrncmp(REG BYTE FAR * d, REG BYTE FAR * s, COUNT l) return *d - *s; } -VOID fstrncpy(REG BYTE FAR * d, REG BYTE FAR * s, COUNT l) -{ - COUNT idx = 1; - while (*s != 0 && idx++ <= l) - *d++ = *s++; - *d = 0; -} - char *strchr(const char * s, int c) { REG CONST BYTE *p; From 68805961dc4ca2ce98ef213dfd9a6f8148e3dd17 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Thu, 28 Aug 2003 20:25:09 +0000 Subject: [PATCH 260/671] Don't disable a20 for "exit" int21/ah=4c git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@654 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/procsupt.asm | 10 +++++++--- kernel/proto.h | 2 +- kernel/task.c | 4 ++-- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/kernel/procsupt.asm b/kernel/procsupt.asm index ecf25b7d..01fedc4f 100644 --- a/kernel/procsupt.asm +++ b/kernel/procsupt.asm @@ -45,8 +45,7 @@ segment HMA_TEXT ; ; Special call for switching processes ; -; void exec_user(irp) -; iregs far *irp; +; void exec_user(iregs far *irp, int disable_a20) ; global _exec_user _exec_user: @@ -60,15 +59,20 @@ _exec_user: pop ax ; return address (unused) pop ax ; irp (user ss:sp) - pop dx + pop dx + pop cx ; disable A20? cli mov ss,dx mov sp,ax ; set-up user stack sti ; + or cx,cx POP$ALL + jz do_iret extern _ExecUserDisableA20 jmp far _ExecUserDisableA20 +do_iret: + iret segment _LOWTEXT diff --git a/kernel/proto.h b/kernel/proto.h index 0c99ff06..d2b2c098 100644 --- a/kernel/proto.h +++ b/kernel/proto.h @@ -373,7 +373,7 @@ UWORD get_machine_name(BYTE FAR * netname); VOID set_machine_name(BYTE FAR * netname, UWORD name_num); /* procsupt.asm */ -VOID ASMCFUNC exec_user(iregs FAR * irp); +VOID ASMCFUNC exec_user(iregs FAR * irp, int disable_a20); /* new by TE */ diff --git a/kernel/task.c b/kernel/task.c index 3c3f6c72..9fb30fd6 100644 --- a/kernel/task.c +++ b/kernel/task.c @@ -314,7 +314,7 @@ int load_transfer(UWORD ds, exec_blk *exp, UWORD fcbcode, COUNT mode) if (InDOS) --InDOS; - exec_user(irp); + exec_user(irp, 1); /* We should never be here fatal("KERNEL RETURNED!!!"); */ @@ -528,7 +528,7 @@ VOID return_user(void) if (InDOS) --InDOS; - exec_user((iregs FAR *) q->ps_stack); + exec_user((iregs FAR *) q->ps_stack, 0); } COUNT DosExeLoader(BYTE FAR * namep, exec_blk * exp, COUNT mode, COUNT fd) From c444161296b7cc87cf558722cb579f0f4f75b77b Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Thu, 28 Aug 2003 20:30:09 +0000 Subject: [PATCH 261/671] Use near bpb on the stack in bpb_to_dpb. Make sure the number of FAT sectors is actually enough to hold that many clusters. Otherwise back the number of clusters down (LG & AB) git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@655 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/fatfs.c | 51 +++++++++++++++++++++++++++++++++++--------------- 1 file changed, 36 insertions(+), 15 deletions(-) diff --git a/kernel/fatfs.c b/kernel/fatfs.c index fc9813c6..6456c5bc 100644 --- a/kernel/fatfs.c +++ b/kernel/fatfs.c @@ -1985,24 +1985,45 @@ VOID bpb_to_dpb(bpb FAR * bpbp, REG struct dpb FAR * dpbp) { ULONG size; REG UWORD shftcnt; + bpb sbpb; - for (shftcnt = 0; (bpbp->bpb_nsector >> shftcnt) > 1; shftcnt++) + fmemcpy(&sbpb, bpbp, sizeof(sbpb)); + for (shftcnt = 0; (sbpb.bpb_nsector >> shftcnt) > 1; shftcnt++) ; dpbp->dpb_shftcnt = shftcnt; - dpbp->dpb_mdb = bpbp->bpb_mdesc; - dpbp->dpb_secsize = bpbp->bpb_nbyte; - dpbp->dpb_clsmask = bpbp->bpb_nsector - 1; - dpbp->dpb_fatstrt = bpbp->bpb_nreserved; - dpbp->dpb_fats = bpbp->bpb_nfat; - dpbp->dpb_dirents = bpbp->bpb_ndirent; - size = bpbp->bpb_nsize == 0 ? bpbp->bpb_huge : (ULONG) bpbp->bpb_nsize; - dpbp->dpb_fatsize = bpbp->bpb_nfsect; + dpbp->dpb_mdb = sbpb.bpb_mdesc; + dpbp->dpb_secsize = sbpb.bpb_nbyte; + dpbp->dpb_clsmask = sbpb.bpb_nsector - 1; + dpbp->dpb_fatstrt = sbpb.bpb_nreserved; + dpbp->dpb_fats = sbpb.bpb_nfat; + dpbp->dpb_dirents = sbpb.bpb_ndirent; + size = sbpb.bpb_nsize == 0 ? sbpb.bpb_huge : (ULONG) sbpb.bpb_nsize; + dpbp->dpb_fatsize = sbpb.bpb_nfsect; dpbp->dpb_dirstrt = dpbp->dpb_fatstrt + dpbp->dpb_fats * dpbp->dpb_fatsize; dpbp->dpb_data = dpbp->dpb_dirstrt + (dpbp->dpb_dirents + dpbp->dpb_secsize/DIRENT_SIZE - 1) / (dpbp->dpb_secsize/DIRENT_SIZE); dpbp->dpb_size = ((size - dpbp->dpb_data) >> shftcnt) + 1; + { /* Make sure the number of FAT sectors is actually enough to hold that */ + /* many clusters. Otherwise back the number of clusters down (LG & AB) */ + unsigned fatsiz; + ULONG tmp = dpbp->dpb_fatsize * (ULONG)(dpbp->dpb_secsize / 2);/* entries/2 */ + if (tmp >= 0x10000) + goto ckok; + fatsiz = (unsigned) tmp; + if (dpbp->dpb_size > FAT_MAGIC) {/* FAT16 */ + if (fatsiz <= FAT_MAGIC) /* FAT12 - let it pass through rather */ + goto ckok; /* than lose data correcting FAT type */ + } else { /* FAT12 */ + if (fatsiz >= 0x4000) + goto ckok; + fatsiz = fatsiz * 4 / 3; + } + if (dpbp->dpb_size >= fatsiz) /* FAT too short */ + dpbp->dpb_size = fatsiz - 1; /* - 2 reserved entries + 1 */ +ckok:; + } dpbp->dpb_flags = 0; dpbp->dpb_cluster = UNKNCLUSTER; /* number of free clusters */ @@ -2011,8 +2032,8 @@ VOID bpb_to_dpb(bpb FAR * bpbp, REG struct dpb FAR * dpbp) #ifdef WITHFAT32 if (extended) { - dpbp->dpb_xfatsize = bpbp->bpb_nfsect == 0 ? bpbp->bpb_xnfsect - : bpbp->bpb_nfsect; + dpbp->dpb_xfatsize = sbpb.bpb_nfsect == 0 ? sbpb.bpb_xnfsect + : sbpb.bpb_nfsect; dpbp->dpb_xcluster = UNKNCLUSTER; dpbp->dpb_xnfreeclst = XUNKNCLSTFREE; /* number of free clusters */ @@ -2025,16 +2046,16 @@ VOID bpb_to_dpb(bpb FAR * bpbp, REG struct dpb FAR * dpbp) if (ISFAT32(dpbp)) { - dpbp->dpb_xflags = bpbp->bpb_xflags; - dpbp->dpb_xfsinfosec = bpbp->bpb_xfsinfosec; - dpbp->dpb_xbackupsec = bpbp->bpb_xbackupsec; + dpbp->dpb_xflags = sbpb.bpb_xflags; + dpbp->dpb_xfsinfosec = sbpb.bpb_xfsinfosec; + dpbp->dpb_xbackupsec = sbpb.bpb_xbackupsec; dpbp->dpb_dirents = 0; dpbp->dpb_dirstrt = 0xffff; dpbp->dpb_size = 0; dpbp->dpb_xdata = dpbp->dpb_fatstrt + dpbp->dpb_fats * dpbp->dpb_xfatsize; dpbp->dpb_xsize = ((size - dpbp->dpb_xdata) >> shftcnt) + 1; - dpbp->dpb_xrootclst = bpbp->bpb_xrootclst; + dpbp->dpb_xrootclst = sbpb.bpb_xrootclst; read_fsinfo(dpbp); } } From 9b42b520565fb861075bbfd37fb3c03b474572cb Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Thu, 28 Aug 2003 20:32:01 +0000 Subject: [PATCH 262/671] Use "local" (instead of "global") disable/enable A20. This solves the problems with NIOS. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@656 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/kernel.asm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/kernel.asm b/kernel/kernel.asm index f39c4d8c..85b020a2 100644 --- a/kernel/kernel.asm +++ b/kernel/kernel.asm @@ -849,7 +849,7 @@ _XMSDriverAddress: global __EnableA20 __EnableA20: - mov ah,3 + mov ah,5 UsingXMSdriver: push bx call far [cs:_XMSDriverAddress] @@ -858,7 +858,7 @@ UsingXMSdriver: global __DisableA20 __DisableA20: - mov ah,4 + mov ah,6 jmp short UsingXMSdriver dslowmem dw 0 From b0d2219a4cf3049bd1355182e0074061be711bc1 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Thu, 28 Aug 2003 20:33:33 +0000 Subject: [PATCH 263/671] Changelog correction. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@657 6ac86273-5f31-0410-b378-82cca8765d1b --- docs/history.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/history.txt b/docs/history.txt index a277d899..1680e2dd 100644 --- a/docs/history.txt +++ b/docs/history.txt @@ -3,7 +3,8 @@ + Changes Luchezar Georgiev * (with Bart) add extra low disk buffer to avoid HMA problems with certain device drivers. - * Add an extra space for the device driver command line + * Add an extra space character at the end of the command line + for device drivers to prevent wrong behavior at empty command line. * point to a correct environment for INSTALL= (fixes problems with xmsdsk). * change device driver error code check (using S_ERROR | S_DONE) From fa11f8e0c55cb24f851e7483cf8db07fdc971f83 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Thu, 28 Aug 2003 20:36:16 +0000 Subject: [PATCH 264/671] Add lock/unlock drive to SYS (from Lucho). git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@658 6ac86273-5f31-0410-b378-82cca8765d1b --- sys/sys.c | 49 +++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 45 insertions(+), 4 deletions(-) diff --git a/sys/sys.c b/sys/sys.c index 6acd24c9..0b87e95f 100644 --- a/sys/sys.c +++ b/sys/sys.c @@ -57,6 +57,7 @@ /* These definitions deliberately put here instead of * #including to make executable MUCH smaller + * using [s]printf from prf.c! */ extern WORD CDECL printf(CONST BYTE * fmt, ...); extern WORD CDECL sprintf(BYTE * buff, CONST BYTE * fmt, ...); @@ -306,7 +307,7 @@ int main(int argc, char **argv) if (argc > drivearg + 1 && memicmp(argv[drivearg + 1], "BOOTONLY", 8) != 0) bsFile = argv[drivearg + 1]; /* don't write to file "BOOTONLY" */ - printf("\nWriting boot sector...\n"); + printf("Processing boot sector...\n"); put_boot(drive, bsFile, (argc > drivearg + 2) && memicmp(argv[drivearg + 2], "BOTH", 4) == 0); @@ -413,6 +414,23 @@ void reset_drive(int DosDrive); parm [dx] \ modify [ax bx]; +void lock_drive(int DosDrive); +#pragma aux lock_drive = \ + "mov ax,0x440d" \ + "mov cx,0x84a" \ + "xor dx,dx" \ + "inc bx" \ + "int 0x21" \ + parm [bx]; + +void unlock_drive(int DosDrive); +#pragma aux unlock_drive = \ + "mov ax,0x440d" \ + "mov cx,0x86a" \ + "inc bx" \ + "int 0x21" \ + parm [bx]; + void truename(char far *dest, const char *src); #pragma aux truename = \ "mov ah,0x60" \ @@ -435,10 +453,10 @@ int2526readwrite(int DosDrive, void *diskReadPacket, unsigned intno) return regs.x.cflag; } -#define absread(int DosDrive, int foo, int cx, void *diskReadPacket) \ +#define absread(DosDrive, foo, cx, diskReadPacket) \ int2526readwrite(DosDrive, diskReadPacket, 0x25) -#define abswrite(int DosDrive, int foo, int cx, void *diskReadPacket) \ +#define abswrite(DosDrive, foo, cx, diskReadPacket) \ int2526readwrite(DosDrive, diskReadPacket, 0x26) #endif @@ -468,6 +486,27 @@ void reset_drive(int DosDrive) intdos(®s, ®s); } /* reset_drive */ +void lock_drive(int DosDrive) +{ + union REGS regs; + + regs.x.ax = 0x440d; + regs.x.cx = 0x84a; + regs.x.dx = 0; + regs.h.bl = DosDrive + 1; + intdos(®s, ®s); +} /* lock_drive */ + +void unlock_drive(int DosDrive) +{ + union REGS regs; + + regs.x.ax = 0x440d; + regs.x.cx = 0x86a; + regs.h.bl = DosDrive + 1; + intdos(®s, ®s); +} /* unlock_drive */ + void truename(char *dest, const char *src) { union REGS regs; @@ -479,7 +518,7 @@ void truename(char *dest, const char *src) sregs.ds = FP_SEG(src); regs.x.si = FP_OFF(src); intdosx(®s, ®s, &sregs); -} /* reset_drive */ +} /* truename */ #endif @@ -585,6 +624,7 @@ VOID put_boot(COUNT drive, BYTE * bsFile, BOOL both) printf("Reading old bootsector from drive %c:\n", drive + 'A'); #endif + lock_drive(drive); reset_drive(drive); /* suggestion: allow reading from a boot sector or image file here */ if (MyAbsReadWrite(drive, 1, 0, oldboot, 0) != 0) @@ -733,6 +773,7 @@ VOID put_boot(COUNT drive, BYTE * bsFile, BOOL both) close(fd); } /* if write boot sector file */ reset_drive(drive); + unlock_drive(drive); } /* put_boot */ From 517fca72aee69bf02e4586c7bc1b290472626e53 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Thu, 28 Aug 2003 20:37:29 +0000 Subject: [PATCH 265/671] Forgotten HMA_TEXT for MS compilers. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@659 6ac86273-5f31-0410-b378-82cca8765d1b --- mkfiles/mscl8.mak | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mkfiles/mscl8.mak b/mkfiles/mscl8.mak index c6d392b2..d7e38d42 100644 --- a/mkfiles/mscl8.mak +++ b/mkfiles/mscl8.mak @@ -43,5 +43,5 @@ TARGET=KMS ALLCFLAGS=-I..\hdr $(TARGETOPT) $(ALLCFLAGS) -nologo -Zl -Fc -WX -Gr -f- -Os -Gs -Ob1 -OV4 -Gy -Oe -Zp1 INITCFLAGS=$(ALLCFLAGS) -NTINIT_TEXT -AT -CFLAGS=$(ALLCFLAGS) +CFLAGS=$(ALLCFLAGS) -NTHMA_TEXT INITPATCH = ..\utils\patchobj _DATA=IDATA DATA=ID BSS=ID DGROUP=I_GROUP CONST=IC From 4e0c27f01690fc294e1f3355ce770fe027333415 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Thu, 28 Aug 2003 20:47:25 +0000 Subject: [PATCH 266/671] Adjust registers used when starting programs. Some demos expect undocumented values. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@660 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/task.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/kernel/task.c b/kernel/task.c index 9fb30fd6..2039203a 100644 --- a/kernel/task.c +++ b/kernel/task.c @@ -304,12 +304,16 @@ int load_transfer(UWORD ds, exec_blk *exp, UWORD fcbcode, COUNT mode) /* build the user area on the stack */ irp = (iregs FAR *)(exp->exec.stack - sizeof(iregs)); - /* start allocating REGs */ - irp->ES = irp->DS = ds; + /* start allocating REGs (as in MS-DOS - some demos expect them so --LG) */ + /* see http://www.beroset.com/asm/showregs.asm */ + irp->DX = irp->ES = irp->DS = ds; irp->CS = FP_SEG(exp->exec.start_addr); - irp->IP = FP_OFF(exp->exec.start_addr); - irp->AX = fcbcode; - irp->BX = irp->CX = irp->DX = irp->SI = irp->DI = irp->BP = 0; + irp->SI = irp->IP = FP_OFF(exp->exec.start_addr); + irp->DI = FP_OFF(exp->exec.stack); + irp->BP = 0x91e; /* this is more or less random but some programs + expect 0x9 in the high byte of BP!! */ + irp->AX = irp->BX = fcbcode; + irp->CX = 0xFF; irp->FLAGS = 0x200; if (InDOS) From 7471b8f614b1c3af3ba71bf684b7551932ea58f2 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Thu, 28 Aug 2003 20:53:21 +0000 Subject: [PATCH 267/671] && should be || in check for \, / and : git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@661 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/main.c b/kernel/main.c index e4ece8ba..65b23c89 100644 --- a/kernel/main.c +++ b/kernel/main.c @@ -507,7 +507,7 @@ BOOL init_device(struct dhdr FAR * dhp, char *cmdLine, COUNT mode, for (p = q = cmdLine; *p && *p != ' ' && *p != '\t'; p++) { - if (*p == '\\' || *p == '/' && *p == ':') + if (*p == '\\' || *p == '/' || *p == ':') q = p + 1; } for (i = 0; i < 8; i++) { From f5a65b599245b818370c582f506fac10f79cbe63 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Thu, 28 Aug 2003 20:55:34 +0000 Subject: [PATCH 268/671] int21/ax=440d lock/unlock logical/physical volume simulate success for MS-DOS 7+ SCANDISK etc. --LG git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@662 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/ioctl.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/kernel/ioctl.c b/kernel/ioctl.c index dc9b3cc7..87b83ab1 100644 --- a/kernel/ioctl.c +++ b/kernel/ioctl.c @@ -270,6 +270,11 @@ COUNT DosDevIOctl(lregs * r) { return DE_INVLDFUNC; } + if (r->AL == 0x0D && (r->CX & ~(0x486B-0x084A)) == 0x084A) + { /* 084A/484A, 084B/484B, 086A/486A, 086B/486B */ + r->AX = 0; /* (lock/unlock logical/physical volume) */ + break; /* simulate success for MS-DOS 7+ SCANDISK etc. --LG */ + } CharReqHdr.r_command = nMode; execrh((request FAR *) & CharReqHdr, dpbp->dpb_device); From df5776dca7aa89b6a5642d56bc3ab7ed7f450650 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Thu, 28 Aug 2003 21:03:47 +0000 Subject: [PATCH 269/671] Adjustments for MSVC. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@663 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/main.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/kernel/main.c b/kernel/main.c index 65b23c89..0abfc03c 100644 --- a/kernel/main.c +++ b/kernel/main.c @@ -57,17 +57,17 @@ STATIC void CheckContinueBootFromHarddisk(void); #ifdef _MSC_VER BYTE _acrtused = 0; -#endif -#ifdef _MSC_VER __segment DosDataSeg = 0; /* serves for all references to the DOS DATA segment necessary for MSC+our funny linking model */ __segment DosTextSeg = 0; -#endif +struct lol FAR *LoL; +#else struct lol FAR *LoL = &DATASTART; +#endif /* little functions - could be ASM but does not really matter in this context */ void memset(void *s, int c, unsigned n) @@ -99,10 +99,10 @@ void fmemcpy(void far *dest, const void far *src, unsigned n) VOID ASMCFUNC FreeDOSmain(void) { #ifdef _MSC_VER - extern FAR DATASTART; extern FAR prn_dev; DosDataSeg = (__segment) & DATASTART; DosTextSeg = (__segment) & prn_dev; + LoL = &DATASTART; #endif From 1d62201ec7451fe7119520485350f0cb02a48c3f Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Thu, 28 Aug 2003 21:43:14 +0000 Subject: [PATCH 270/671] Move manually added "RCS" entries to the CVS log. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@664 6ac86273-5f31-0410-b378-82cca8765d1b --- sys/sys.c | 39 --------------------------------------- 1 file changed, 39 deletions(-) diff --git a/sys/sys.c b/sys/sys.c index 0b87e95f..ab277161 100644 --- a/sys/sys.c +++ b/sys/sys.c @@ -915,42 +915,3 @@ BOOL copy(COUNT drive, BYTE * srcPath, BYTE * rootPath, BYTE * file) return TRUE; } /* copy */ - -/* version 2.2 jeremyd 2001/9/20 - Changed so if no source given or only source drive (no path) - given, then checks for kernel.sys & command.com in current - path (of current drive or given drive) and if not there - uses root (but only if source & destination drive are different). - Fix printf to include count(ret) if copy can't write all requested bytes -*/ - -/* version 2.1a jeremyd 2001/8/19 - modified so takes optional 2nd parameter (similar to PC DOS) - where if only 1 argument is given, assume to be destination drive, - but if two arguments given, 1st is source (drive and/or path) - and second is destination drive -*/ - -/* Revision 2.1 tomehlert 2001/4/26 - - changed the file system detection code. -*/ - -/* Revision 2.0 tomehlert 2001/4/26 - - no direct access to the disk any more, this is FORMAT's job - no floppy.asm anymore, no segmentation problems. - no access to partition tables - - instead copy boot sector using int25/int26 = absdiskread()/write - - if xxDOS is able to handle the disk, SYS should work - - additionally some space savers: - - replaced fopen() by open() - - included (slighly modified) PRF.c from kernel - - size is no ~7500 byte vs. ~13690 before -*/ From 8f1bbcd45d1dfe9ebdc61108971f73edeb8a239a Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sat, 30 Aug 2003 22:17:42 +0000 Subject: [PATCH 271/671] Set the PSP before the DTA. This solves an interrupt vector table corruption. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@665 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/main.c b/kernel/main.c index 0abfc03c..b8837f84 100644 --- a/kernel/main.c +++ b/kernel/main.c @@ -216,8 +216,8 @@ STATIC void init_kernel(void) setvec(0x2a, int2a_handler); setvec(0x2f, int2f_handler); - set_DTA(MK_FP(DOS_PSP, 0x80)); init_PSPSet(DOS_PSP); + set_DTA(MK_FP(DOS_PSP, 0x80)); init_PSPInit(DOS_PSP); ((psp far *)MK_FP(DOS_PSP, 0))->ps_environ = DOS_PSP + 8; From 648f60b05d85e9ecb12f84041e165adb047cf372 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sun, 31 Aug 2003 10:20:28 +0000 Subject: [PATCH 272/671] Clean cleans a bit more; change () to (void) git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@666 6ac86273-5f31-0410-b378-82cca8765d1b --- lib/makefile | 4 ++-- utils/exeflat.c | 2 +- utils/makefile | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/makefile b/lib/makefile index b19c19c7..0a08d75d 100644 --- a/lib/makefile +++ b/lib/makefile @@ -17,8 +17,8 @@ libm.lib: $(CLIB) clobber: clean - -$(RM) libm.lib status.me + -$(RM) status.me clean: - -$(RM) *.obj *.bak + -$(RM) *.obj *.bak libm.lib diff --git a/utils/exeflat.c b/utils/exeflat.c index 8e93b0d4..f20c1c69 100644 --- a/utils/exeflat.c +++ b/utils/exeflat.c @@ -73,7 +73,7 @@ int compReloc(const void *p1, const void *p2) return 0; } -void usage() +void usage(void) { printf("usage: exeflat (src.exe) (dest.sys) (relocation-factor)\n"); printf diff --git a/utils/makefile b/utils/makefile index de2c2b4b..dde637ac 100644 --- a/utils/makefile +++ b/utils/makefile @@ -12,8 +12,8 @@ exeflat.exe: exeflat.c ..\hdr\exe.h clobber: clean - $(RM) bin2c.com exeflat.exe patchobj.com clean: $(RM) *.obj *.bak *.crf *.xrf *.map *.lst *.las *.cod *.err status.me + $(RM) exeflat.exe patchobj.com From bef6672954136d98439ec24be60f6ffce6417777 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sun, 31 Aug 2003 10:22:32 +0000 Subject: [PATCH 273/671] Use 0x10000UL (avoids Turbo C warning) git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@667 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/fatfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/fatfs.c b/kernel/fatfs.c index 6456c5bc..a72d0dba 100644 --- a/kernel/fatfs.c +++ b/kernel/fatfs.c @@ -2009,7 +2009,7 @@ VOID bpb_to_dpb(bpb FAR * bpbp, REG struct dpb FAR * dpbp) /* many clusters. Otherwise back the number of clusters down (LG & AB) */ unsigned fatsiz; ULONG tmp = dpbp->dpb_fatsize * (ULONG)(dpbp->dpb_secsize / 2);/* entries/2 */ - if (tmp >= 0x10000) + if (tmp >= 0x10000UL) goto ckok; fatsiz = (unsigned) tmp; if (dpbp->dpb_size > FAT_MAGIC) {/* FAT16 */ From 67ef543bae5f4f588bb1ed7cd831e6870cf33ca3 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Mon, 1 Sep 2003 17:49:40 +0000 Subject: [PATCH 274/671] Fix pointer overflow problem for reading line using handle. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@671 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/chario.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/chario.c b/kernel/chario.c index 50827686..0e369bf6 100644 --- a/kernel/chario.c +++ b/kernel/chario.c @@ -534,7 +534,7 @@ size_t read_line_handle(int sft_idx, size_t n, char FAR * bp) } } - if (inputptr > bufend - n) + if (n > bufend - inputptr) n = bufend - inputptr; fmemcpy(bp, inputptr, n); From b88881b8a073903b6b4e9d760e9ccb3df60a5ec7 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Thu, 4 Sep 2003 18:58:01 +0000 Subject: [PATCH 275/671] Add peek and poke #defines git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@672 6ac86273-5f31-0410-b378-82cca8765d1b --- hdr/portab.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/hdr/portab.h b/hdr/portab.h index b659fe63..e777032f 100644 --- a/hdr/portab.h +++ b/hdr/portab.h @@ -224,6 +224,11 @@ typedef signed long LONG; #define MK_FP(seg,ofs) ((void FAR *)(((ULONG)(seg)<<16)|(UWORD)(ofs))) #endif +#define pokeb(seg, ofs, b) (*((unsigned char far *)MK_FP(seg,ofs)) = b) +#define poke(seg, ofs, w) (*((unsigned far *)MK_FP(seg,ofs)) = w) +#define peekb(seg, ofs) (*((unsigned char far *)MK_FP(seg,ofs))) +#define peek(seg, ofs) (*((unsigned far *)MK_FP(seg,ofs))) + #if defined(__TURBOC__) && (__TURBOC__ > 0x202) #define FP_SEG(fp) ((unsigned)(void _seg *)(void far *)(fp)) #else From 1266a13f7f9d42ccac3335182e449a2afada1b61 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Thu, 4 Sep 2003 19:05:27 +0000 Subject: [PATCH 276/671] Add necessary casts to ? : constructions; cleanup read_line_handle a little. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@673 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/chario.c | 18 +++++++++--------- kernel/dosfns.c | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/kernel/chario.c b/kernel/chario.c index 0e369bf6..4584cb58 100644 --- a/kernel/chario.c +++ b/kernel/chario.c @@ -72,7 +72,7 @@ long BinaryCharIO(struct dhdr FAR * dev, size_t n, void FAR * bp, unsigned comma CharReqHdr.r_count = n; CharReqHdr.r_trans = bp; } while ((err = CharRequest(dev)) == 1); - return err == SUCCESS ? CharReqHdr.r_count : err; + return err == SUCCESS ? (long)CharReqHdr.r_count : err; } /* STATE FUNCTIONS */ @@ -256,7 +256,7 @@ long cooked_write(int sft_idx, size_t n, char FAR *bp) for (xfer = 0; err >= SUCCESS && xfer < n && *bp != CTL_Z; bp++, xfer++) err = cooked_put_char(sft_idx, *bp); - return err < SUCCESS ? err : xfer; + return err < SUCCESS ? (long)err : xfer; } /* writes character for disk file or device */ @@ -513,7 +513,7 @@ void read_line(int sft_in, int sft_out, keyboard FAR * kp) /* called by handle func READ (int21/ah=3f) */ size_t read_line_handle(int sft_idx, size_t n, char FAR * bp) { - char *bufend = &kb_buf.kb_buf[kb_buf.kb_count + 2]; + size_t chars_left; if (inputptr == NULL) { @@ -524,22 +524,22 @@ size_t read_line_handle(int sft_idx, size_t n, char FAR * bp) kb_buf.kb_size = LINEBUFSIZECON; } read_line(sft_idx, sft_idx, &kb_buf); - bufend = &kb_buf.kb_buf[kb_buf.kb_count + 2]; - bufend[-1] = echo_char(LF, sft_idx); + kb_buf.kb_buf[kb_buf.kb_count + 1] = echo_char(LF, sft_idx); inputptr = kb_buf.kb_buf; if (*inputptr == CTL_Z) { inputptr = NULL; return 0; - } + } } - if (n > bufend - inputptr) - n = bufend - inputptr; + chars_left = &kb_buf.kb_buf[kb_buf.kb_count + 2] - inputptr; + if (n > chars_left) + n = chars_left; fmemcpy(bp, inputptr, n); inputptr += n; - if (inputptr == bufend) + if (n == chars_left) inputptr = NULL; return n; } diff --git a/kernel/dosfns.c b/kernel/dosfns.c index 76381684..b28464ac 100644 --- a/kernel/dosfns.c +++ b/kernel/dosfns.c @@ -224,7 +224,7 @@ long DosRWSft(int sft_idx, size_t n, void FAR * bp, int mode) dta = bp; XferCount = (mode == XFR_READ ? remote_read : remote_write)(s, n, &err); dta = save_dta; - return err == SUCCESS ? XferCount : err; + return err == SUCCESS ? (long)XferCount : err; } /* Do a device transfer if device */ From d1f48fb2b264841bc802f41bbc26020e08d442cd Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Thu, 4 Sep 2003 19:07:55 +0000 Subject: [PATCH 277/671] Add necessary "BootHardDiskSeconds" for non UPXed kernels. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@674 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/kernel.asm | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/kernel/kernel.asm b/kernel/kernel.asm index 85b020a2..216f5422 100644 --- a/kernel/kernel.asm +++ b/kernel/kernel.asm @@ -57,15 +57,16 @@ _LowKernelConfig: dw configend-configstart; size of config area ; to be checked !!! -configstart: +configstart: DLASortByDriveNo db 0 ; sort disks by drive order -InitDiskShowDriveAssignment db 1 ; -SkipConfigSeconds db 2 ; -ForceLBA db 0 ; -GlobalEnableLBAsupport db 1 ; +InitDiskShowDriveAssignment db 1 ; +SkipConfigSeconds db 2 ; +ForceLBA db 0 ; +GlobalEnableLBAsupport db 1 ; +BootHarddiskSeconds db 0 ; -configend: +configend: ;************************************************************ ; KERNEL CONFIGURATION AREA END From 72c8bf17b841b5bb91851c3a34cbd45d34b10a9c Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Thu, 4 Sep 2003 19:14:16 +0000 Subject: [PATCH 278/671] Support for switches=/e[[:]nnnn] and for moving the EBDA (with Lucho) git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@675 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/config.c | 48 +++++++++++++++++++++++++++++++++++++++-------- kernel/init-mod.h | 6 +++++- kernel/initoem.c | 42 +++++++++++++++++++++++++++++------------ 3 files changed, 75 insertions(+), 21 deletions(-) diff --git a/kernel/config.c b/kernel/config.c index fcb7e444..5c337e37 100644 --- a/kernel/config.c +++ b/kernel/config.c @@ -70,11 +70,12 @@ struct config Config = { , 0 /* amount required memory */ , 0 /* pointer to loaded data */ , 0 /* strategy for command.com is low by default */ + , 0xFFFF /* default value for switches=/E:nnnn */ }; /* MSC places uninitialized data into COMDEF records, - that end up in DATA segment. this can't be tolerated + that end up in DATA segment. this can't be tolerated in INIT code. - please make sure, that ALL data in INIT is initialized !! + please make sure, that ALL data in INIT is initialized !! */ STATIC seg base_seg = 0; STATIC seg umb_base_seg = 0; @@ -285,7 +286,8 @@ void PreConfig(void) void PreConfig2(void) { struct sfttbl FAR *sp; - + unsigned ebda_size; + /* initialize NEAR allocated things */ /* Initialize the file table */ @@ -297,7 +299,7 @@ void PreConfig2(void) /* Initialize the base memory pointers from last time. */ /* - if the kernel could be moved to HMA, everything behind the dynamic + if the kernel could be moved to HMA, everything behind the dynamic near data is free. otherwise, the kernel is moved down - behind the dynamic allocated data, and allocation starts after the kernel. @@ -305,15 +307,24 @@ void PreConfig2(void) base_seg = LoL->first_mcb = FP_SEG(AlignParagraph((BYTE FAR *) DynLast() + 0x0f)); + ebda_size = ebdasize(); + if (ebda_size > Config.ebda2move) + ebda_size = Config.ebda2move; + ram_top += ebda_size / 1024; + /* We expect ram_top as Kbytes, so convert to paragraphs */ mcb_init(base_seg, ram_top * 64 - LoL->first_mcb - 1, MCB_LAST); - if (UmbState == 2) - umb_init(); sp = LoL->sfthead; sp = sp->sftt_next = KernelAlloc(sizeof(sftheader) + 3 * sizeof(sft), 'F', 0); sp->sftt_next = (sfttbl FAR *) - 1; sp->sftt_count = 3; + + if (ebda_size) /* move the Extended BIOS Data Area from top of RAM here */ + movebda(ebda_size, FP_SEG(KernelAlloc(ebda_size, 'I', 0))); + + if (UmbState == 2) + umb_init(); } /* Do third pass initialization. */ @@ -991,6 +1002,28 @@ STATIC VOID CfgSwitches(BYTE * pLine) case 'F': InitKernelConfig.SkipConfigSeconds = 0; break; + case 'E': /* /E[[:]nnnn] Set the desired EBDA amount to move in bytes */ + { /* Note that if there is no EBDA, this will have no effect */ + char *p; + int n = 0; + if (*++pLine == ':') + pLine++; /* skip optional separator */ + if ((p = GetNumArg(pLine, &n)) == 0) { + Config.ebda2move = 0; + break; + } + pLine = p - 1; /* p points past number */ + /* allowed values: [0..1024] bytes, multiples of 16 + * e.g. AwardBIOS: 48, AMIBIOS: 1024 + * (Phoenix, MRBIOS, Unicore = ????) + */ + if (n >= 48 && n <= 1024) + { + Config.ebda2move = (n + 15) & 0xfff0; + break; + } + /* else fall through (failure) */ + } default: CfgFailure(pLine); } @@ -998,7 +1031,7 @@ STATIC VOID CfgSwitches(BYTE * pLine) CfgFailure(pLine); } pLine = skipwh(pLine+1); - } + } commands[0].pass = 1; } @@ -1349,7 +1382,6 @@ void FAR * KernelAlloc(size_t nBytes, char type, int mode) /* prealloc */ lpTop = MK_FP(FP_SEG(lpTop) - nPara, FP_OFF(lpTop)); return AlignParagraph(lpTop); - } else { diff --git a/kernel/init-mod.h b/kernel/init-mod.h index 9de51632..9cc39a59 100644 --- a/kernel/init-mod.h +++ b/kernel/init-mod.h @@ -109,6 +109,8 @@ struct config { /* where the loaded data is for PostConfig() */ UBYTE cfgP_0_startmode; /* load command.com high or not */ + unsigned ebda2move; + /* value for switches=/E:nnnn */ }; extern struct config Config; @@ -139,7 +141,9 @@ int MoveKernelToHMA(void); VOID FAR * HMAalloc(COUNT bytesToAllocate); /* initoem.c */ -UWORD init_oem(void); +unsigned init_oem(void); +void movebda(int bytes, unsigned new_seg); +unsigned ebdasize(void); /* intr.asm */ diff --git a/kernel/initoem.c b/kernel/initoem.c index ca0b0949..d07b3f9a 100644 --- a/kernel/initoem.c +++ b/kernel/initoem.c @@ -35,20 +35,38 @@ static BYTE *RcsId = "$Id$"; #endif -UWORD init_oem(void) +#define EBDASEG 0x40e +#define RAMSIZE 0x413 + +unsigned init_oem(void) +{ + iregs r; + init_call_intr(0x12, &r); + return r.a.x; +} + +void movebda(size_t bytes, unsigned new_seg) +{ + unsigned old_seg = peek(0, EBDASEG); + fmemcpy(MK_FP(new_seg, 0), MK_FP(old_seg, 0), bytes); + poke(0, EBDASEG, new_seg); + poke(0, RAMSIZE, ram_top); +} + +unsigned ebdasize(void) { - UWORD top_k = 0; + unsigned ebdaseg = peek(0, EBDASEG); + unsigned ramsize = ram_top; -#ifdef __TURBOC__ - __int__(0x12); - top_k = _AX; -#elif defined(I86) - asm + if (ramsize * 64 == ebdaseg && ramsize < 640 && peek(0, RAMSIZE) == ramsize) { - int 0x12; - mov top_k, ax; + unsigned ebdasz = peekb(ebdaseg, 0); + + /* sanity check: is there really no more than 63 KB? + * must be at 640k (all other values never seen and are untested) + */ + if (ebdasz <= 63 && ramsize + ebdasz == 640) + return ebdasz * 1024U; } -#endif - return top_k; + return 0; } - From c4235b8fffb1c3000d61a4254f0adac571ba54fa Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Tue, 9 Sep 2003 17:19:10 +0000 Subject: [PATCH 279/671] Remove unused code. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@676 6ac86273-5f31-0410-b378-82cca8765d1b --- drivers/floppy.asm | 193 --------------------------------------------- 1 file changed, 193 deletions(-) diff --git a/drivers/floppy.asm b/drivers/floppy.asm index 9c5fa9fa..c1c6413d 100644 --- a/drivers/floppy.asm +++ b/drivers/floppy.asm @@ -58,43 +58,6 @@ fl_rst1: xor ax,ax ; FALSE on error ret -; -; -; Read DASD Type -; -; COUNT fl_readdasd(WORD drive) -; -; returns 0-3 if successful, 0xFF if error -; -; Code Meaning -; 0 The drive is not present -; 1 Drive present, cannot detect disk change -; 2 Drive present, can detect disk change -; 3 Fixed disk -; -%if 0 - global _fl_readdasd -_fl_readdasd: - push bp - mov bp,sp - - mov dl,[bp+4] ; get the drive number - mov ah,15h ; read DASD type - int 13h - - jc fl_rdasd1 ; cy==1 is error - mov al,ah ; for the return code - xor ah,ah - pop bp ; C exit - ret - -fl_rdasd1: mov ah,0 ; BIOS reset disketter & fixed disk - int 13h - mov ax,0FFh ; 0xFF on error - pop bp ; C exit - ret -%endif - ; ; ; Read disk change line status @@ -129,32 +92,6 @@ fl_dc_error: mov ax,0FFh ; 0xFF on error ret -; -; Read the disk system status -; -; COUNT fl_rd_status(WORD drive) -; -; Returns error codes -; -; See Phoenix Bios Book for error code meanings -; -%if 0 - global _fl_rd_status -_fl_rd_status: - push bp ; C entry - mov bp,sp - - mov dl,[bp+4] ; get the drive number - mov ah,1 ; read status - int 13h - - mov al,ah ; for the return code - xor ah,ah - - pop bp ; C exit - ret -%endif - ; ; Format Sectors ; @@ -238,136 +175,6 @@ fl_error: ret -%if 0 -; -; -; Get number of disks -; -; COUNT fl_nrdrives(VOID) -; -; returns AX = number of harddisks -; - - global _fl_nrdrives -_fl_nrdrives: - push di ; di reserved by C-code ??? - - mov ah,8 ; DISK, get drive parameters - mov dl,80h - int 13h - mov ax,0 ; fake 0 drives on error - jc fl_nrd1 - mov al,dl -fl_nrd1: - pop di - ret -%endif - -; --------------------------------------------------------------------------- -; LBA Specific Code -; -; -; Added by: Brian E. Reifsnyder -; --------------------------------------------------------------------------- - -; -; -; Check for Enhanced Disk Drive support (EDD). If EDD is supported then -; LBA can be utilized to access the hard disk. -; -; unsigned int lba_support(WORD hard_disk_number) -; -; returns TRUE if LBA can be utilized -; -%if 0 - global _fl_lba_support -_fl_lba_support: - push bp ; C entry - mov bp,sp - - mov dl,[bp+4] ; get the drive number - mov ah,41h ; cmd CHECK EXTENSIONS PRESENT - mov bx,55aah - int 13h ; check for int 13h extensions - - jc fl_lba_support_no_lba - ; if carry set, don't use LBA - cmp bx,0aa55h - jne fl_lba_support_no_lba - ; if bx!=0xaa55, don't use LBA - test cl,01h - jz fl_lba_support_no_lba - ; if DAP cannot be used, don't use - ; LBA - mov ax,0001h ; return TRUE (LBA supported) - - pop bp ; C exit - ret - -fl_lba_support_no_lba - xor ax,ax ; return FALSE (LBA not supported) - pop bp ; C exit - ret - -; -; Read Sectors -; -; COUNT fl_lba_read(WORD drive, WORD dap_segment, WORD dap_offset); -; -; Reads one or more sectors. -; -; Returns 0 if successful, error code otherwise. -; -; -; Write Sectors -; -; COUNT fl_lba_write(WORD drive, WORD dap_segment, WORD dap_offset); -; -; Writes one or more sectors. -; -; Returns 0 if successful, error code otherwise. -; - global _fl_lba_read -_fl_lba_read: - mov ah,42h ; cmd READ - jmp short fl_lba_common - - global _fl_lba_write -_fl_lba_write: - mov ax,4300h ; cmd WRITE without verify - jmp short fl_lba_common - - global _fl_lba_write_and_verify -_fl_lba_write_and_verify: - mov ax,4302h ; cmd WRITE with VERIFY - jmp short fl_lba_common ; This has been added for - ; possible future use - - global _fl_lba_verify -_fl_lba_verify: - mov ah,44h ; cmd VERIFY - -fl_lba_common: - push bp ; C entry - mov bp,sp - - push ds - - mov dl,[bp+4] ; get the drive (if or'ed 80h its - ; hard drive. - lds si,[bp+6] ; get far dap pointer - int 13h ; read from/write to drive - - mov al,ah ; place any error code into al - - xor ah,ah ; zero out ah - - pop ds - - pop bp - ret -%endif - ; COUNT fl_lba_ReadWrite(BYTE drive, UWORD mode, VOID FAR *dap_p) ; ; Returns 0 if successful, error code otherwise. From 569f053101e2d6624280c1537ca89c4a6c351550 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Tue, 9 Sep 2003 17:21:08 +0000 Subject: [PATCH 280/671] Change r_status and dh_name to unsigned quantities. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@677 6ac86273-5f31-0410-b378-82cca8765d1b --- hdr/device.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hdr/device.h b/hdr/device.h index a13479bd..0d28abd9 100644 --- a/hdr/device.h +++ b/hdr/device.h @@ -128,7 +128,7 @@ struct dhdr { UWORD dh_attr; VOID(*dh_strategy) (void); VOID(*dh_interrupt) (void); - BYTE dh_name[8]; + UBYTE dh_name[8]; }; #define ATTR_SUBST 0x8000 @@ -338,7 +338,7 @@ typedef struct { UBYTE r_length; /* Request Header length */ UBYTE r_unit; /* Unit Code */ UBYTE r_command; /* Command Code */ - WORD r_status; /* Status */ + UWORD r_status; /* Status */ BYTE r_reserved[8]; /* DOS Reserved Area */ union { struct { From 44c5a93bdbfde19a9d1e31e036f9b0df3982fed1 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Tue, 9 Sep 2003 17:22:03 +0000 Subject: [PATCH 281/671] New UNREFERENCED_PARAMETER macro that appears to work for all compilers. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@678 6ac86273-5f31-0410-b378-82cca8765d1b --- hdr/portab.h | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/hdr/portab.h b/hdr/portab.h index e777032f..6600a896 100644 --- a/hdr/portab.h +++ b/hdr/portab.h @@ -249,18 +249,11 @@ typedef signed long LONG; typedef VOID (FAR ASMCFUNC * intvec) (void); /* - this suppresses the warning + this suppresses the warning unreferenced parameter 'x' and (hopefully) generates no code */ - -#if defined(__TURBOC__) -#define UNREFERENCED_PARAMETER(x) if (x); -#elif defined(__GNUC__) -#define UNREFERENCED_PARAMETER(x) x = 0; -#else -#define UNREFERENCED_PARAMETER(x) x; -#endif +#define UNREFERENCED_PARAMETER(x) (void)x; #ifdef I86 /* commandline overflow - removing /DPROTO TE */ #define PROTO From 6cd84b06d1e1a5cfe41ccbe71f34e30f64ff9ecc Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Tue, 9 Sep 2003 17:29:19 +0000 Subject: [PATCH 282/671] init_device corrections/cleanups (mainly by Arkady) git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@679 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/main.c | 41 ++++++++++++++++++++++++----------------- 1 file changed, 24 insertions(+), 17 deletions(-) diff --git a/kernel/main.c b/kernel/main.c index b8837f84..7f49307e 100644 --- a/kernel/main.c +++ b/kernel/main.c @@ -227,7 +227,7 @@ STATIC void init_kernel(void) /* we can read config.sys later. */ LoL->lastdrive = Config.cfgLastdrive; - /* init_device((struct dhdr FAR *)&blk_dev, NULL, NULL, ram_top); */ + /* init_device((struct dhdr FAR *)&blk_dev, NULL, 0, ram_top); */ blk_dev.dh_name[0] = dsk_init(); PreConfig(); @@ -501,24 +501,31 @@ BOOL init_device(struct dhdr FAR * dhp, char *cmdLine, COUNT mode, char FAR *r_top) { request rq; - int i; char name[8]; - char *p, *q; - for (p = q = cmdLine; *p && *p != ' ' && *p != '\t'; p++) - { - if (*p == '\\' || *p == '/' || *p == ':') - q = p + 1; - } - for (i = 0; i < 8; i++) { - char ch = *q; - if (ch != '\0') - q++; - if (ch == '.') - ch = 0; - name[i] = ch; + if (cmdLine) { + char *p, *q, ch; + int i; + + p = q = cmdLine; + for (;;) + { + ch = *p; + if (ch == '\0' || ch == ' ' || ch == '\t') + break; + p++; + if (ch == '\\' || ch == '/' || ch == ':') + q = p; /* remember position after path */ + } + for (i = 0; i < 8; i++) { + ch = '\0'; + if (p != q && *q != '.') + ch = *q++; + /* copy name, without extension */ + name[i] = ch; + } } - + rq.r_unit = 0; rq.r_status = 0; rq.r_command = C_INIT; @@ -566,7 +573,7 @@ STATIC void InitIO(void) /* Initialize driver chain */ setvec(0x29, int29_handler); /* Requires Fast Con Driver */ do { - init_device(device, NULL, NULL, lpTop); + init_device(device, NULL, 0, lpTop); device = device->dh_next; } while (FP_OFF(device) != 0xffff); From 59484b2fc95fb6bc69992846ecb2e34d4473d4a2 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Tue, 9 Sep 2003 17:30:10 +0000 Subject: [PATCH 283/671] EBDA corrections by Lucho git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@680 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/config.c | 14 +++++++++----- kernel/init-mod.h | 2 +- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/kernel/config.c b/kernel/config.c index 5c337e37..69dd64e1 100644 --- a/kernel/config.c +++ b/kernel/config.c @@ -307,10 +307,14 @@ void PreConfig2(void) base_seg = LoL->first_mcb = FP_SEG(AlignParagraph((BYTE FAR *) DynLast() + 0x0f)); - ebda_size = ebdasize(); - if (ebda_size > Config.ebda2move) - ebda_size = Config.ebda2move; - ram_top += ebda_size / 1024; + ebda_size = 0; + if (Config.ebda2move) + { + ebda_size = ebdasize(); + ram_top += ebda_size / 1024; + if (ebda_size > Config.ebda2move) + ebda_size = Config.ebda2move; + } /* We expect ram_top as Kbytes, so convert to paragraphs */ mcb_init(base_seg, ram_top * 64 - LoL->first_mcb - 1, MCB_LAST); @@ -1013,7 +1017,7 @@ STATIC VOID CfgSwitches(BYTE * pLine) break; } pLine = p - 1; /* p points past number */ - /* allowed values: [0..1024] bytes, multiples of 16 + /* allowed values: [48..1024] bytes, multiples of 16 * e.g. AwardBIOS: 48, AMIBIOS: 1024 * (Phoenix, MRBIOS, Unicore = ????) */ diff --git a/kernel/init-mod.h b/kernel/init-mod.h index 9cc39a59..1f8d36cd 100644 --- a/kernel/init-mod.h +++ b/kernel/init-mod.h @@ -142,7 +142,7 @@ VOID FAR * HMAalloc(COUNT bytesToAllocate); /* initoem.c */ unsigned init_oem(void); -void movebda(int bytes, unsigned new_seg); +void movebda(size_t bytes, unsigned new_seg); unsigned ebdasize(void); /* intr.asm */ From b4bee283f9592f98f0877de7b86869a84499fbf1 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Tue, 9 Sep 2003 17:32:20 +0000 Subject: [PATCH 284/671] (suggestion from Arkady) if sizeof(struct ClockRecord) != rp->r_count error move year init below reading the BIOS remove trailing whitespace git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@681 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/sysclk.c | 65 +++++++++++++++++-------------------------------- 1 file changed, 22 insertions(+), 43 deletions(-) diff --git a/kernel/sysclk.c b/kernel/sysclk.c index 2bf24825..457551dc 100644 --- a/kernel/sysclk.c +++ b/kernel/sysclk.c @@ -65,33 +65,8 @@ WORD ASMCFUNC FAR clk_driver(rqptr rp) switch (rp->r_command) { case C_INIT: - -#if 0 - /* If AT clock exists, copy AT clock time to system clock */ - if (!ReadATClock(bcd_days, &bcd_hours, &bcd_minutes, &bcd_seconds)) - { - ticks_t seconds; - - DaysSinceEpoch = - DaysFromYearMonthDay(100 * BcdToByte(bcd_days[3]) + - BcdToByte(bcd_days[2]), - BcdToByte(bcd_days[1]), - BcdToByte(bcd_days[0])); - - /* - * This is a rather tricky calculation. The number of timer ticks per - * second is not exactly 18.2, but rather 1193180 / 65536 - * where 1193180 = 0x1234dc - * The timer interrupt updates the midnight flag when the tick count - * reaches 0x1800b0 -- ror4. - */ - - seconds = - 60 * (ticks_t)(60 * BcdToByte(bcd_hours) + BcdToByte(bcd_minutes)) + - BcdToByte(bcd_seconds); - WritePCClock(seconds * 0x12 + ((seconds * 0x34dc) >> 16)); - } -#endif + + /* done in initclk.c */ /* rp->r_endaddr = device_end(); not needed - bart */ rp->r_nunits = 0; return S_DONE; @@ -101,26 +76,28 @@ WORD ASMCFUNC FAR clk_driver(rqptr rp) struct ClockRecord clk; int tmp; ticks_t ticks; - - clk.clkDays = DaysSinceEpoch; - + + if (sizeof(struct ClockRecord) != rp->r_count) + return failure(E_LENGTH); + /* The scaling factor is now 6553600/1193180 = 327680/59659 = 65536*5/59659 */ - - ticks = 5 * ReadPCClock(); + + ticks = 5 * ReadPCClock(); ticks = ((ticks / 59659u) << 16) + ((ticks % 59659u) << 16) / 59659u; - + tmp = (int)(ticks / 6000); clk.clkHours = tmp / 60; clk.clkMinutes = tmp % 60; tmp = (int)(ticks % 6000); clk.clkSeconds = tmp / 100; - clk.clkHundredths = tmp % 100; - - fmemcpy(rp->r_trans, &clk, - min(sizeof(struct ClockRecord), rp->r_count)); - } + clk.clkHundredths = tmp % 100; + + clk.clkDays = DaysSinceEpoch; + + fmemcpy(rp->r_trans, &clk, sizeof(struct ClockRecord)); + } return S_DONE; case C_OUTPUT: @@ -129,9 +106,11 @@ WORD ASMCFUNC FAR clk_driver(rqptr rp) unsigned Day, Month, Year; struct ClockRecord clk; ticks_t hs, Ticks; - - rp->r_count = min(rp->r_count, sizeof(struct ClockRecord)); - fmemcpy(&clk, rp->r_trans, rp->r_count); + + if (sizeof(struct ClockRecord) != rp->r_count) + return failure(E_LENGTH); + + fmemcpy(&clk, rp->r_trans, sizeof(struct ClockRecord)); /* Set PC Clock first */ DaysSinceEpoch = clk.clkDays; @@ -140,7 +119,7 @@ WORD ASMCFUNC FAR clk_driver(rqptr rp) /* The scaling factor is now 1193180/6553600 = 59659/327680 = 59659/65536/5 */ - + Ticks = ((hs >> 16) * 59659u + (((hs & 0xffff) * 59659u) >> 16)) / 5; WritePCClock(Ticks); @@ -159,7 +138,7 @@ WORD ASMCFUNC FAR clk_driver(rqptr rp) else break; } - + /* Day contains the days left and count the number of */ /* days for that year. Use this to index the table. */ for (Month = 1; Month < 13; ++Month) From 8c22873b3e3c35c0312104c685977aacb75c9121 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Tue, 9 Sep 2003 17:33:23 +0000 Subject: [PATCH 285/671] Initclk changes (mainly by Lucho) git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@682 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/initclk.c | 47 +++++++++-------------------------------------- 1 file changed, 9 insertions(+), 38 deletions(-) diff --git a/kernel/initclk.c b/kernel/initclk.c index b895e74b..0780843f 100644 --- a/kernel/initclk.c +++ b/kernel/initclk.c @@ -38,52 +38,26 @@ static char *RcsId = /* WARNING - THIS DRIVER IS NON-PORTABLE!!!! */ /* */ -STATIC int InitByteToBcd(int x) -{ - return ((x / 10) << 4) | (x % 10); -} - STATIC int InitBcdToByte(int x) { return ((x >> 4) & 0xf) * 10 + (x & 0xf); } -STATIC void InitDayToBcd(BYTE * x, unsigned mon, unsigned day, unsigned yr) -{ - x[1] = InitByteToBcd(mon); - x[0] = InitByteToBcd(day); - x[3] = InitByteToBcd(yr / 100); - x[2] = InitByteToBcd(yr % 100); -} - void Init_clk_driver(void) { - iregs regsT, regsD, dosregs; + static iregs regsT = {0x200}; /* ah=0x02 */ + static iregs regsD = {0x400, 0, 0x1400, 0x101}; + /* ah=4, ch=20^ ^cl=0, ^dh=dl=1 (2000/1/1) + * (above date will be set on error) */ + iregs dosregs; - regsT.a.b.h = 0x02; - regsT.d.x = regsT.c.x = 0; - regsT.flags = 0; - init_call_intr(0x1a, ®sT); - - if ((regsT.flags & 0x0001) || (regsT.c.x == 0 && regsT.d.x == 0)) - { - goto error; /* error */ - } - - regsD.a.b.h = 0x04; - regsD.d.x = regsD.c.x = 0; - regsD.flags = 0; - init_call_intr(0x1a, ®sD); - - if ((regsD.flags & 0x0001) || regsD.c.x == 0 || regsD.d.x == 0) - { - goto error; - } + init_call_intr(0x1a, ®sT); /* get BIOS time */ + init_call_intr(0x1a, ®sD); /* get BIOS date */ /* DosSetDate */ dosregs.a.b.h = 0x2b; - dosregs.c.x = 100 * InitBcdToByte(regsD.c.b.h) + - InitBcdToByte(regsD.c.b.l); + dosregs.c.x = 100 * InitBcdToByte(regsD.c.b.h) /* century */ + + InitBcdToByte(regsD.c.b.l);/* year */ dosregs.d.b.h = InitBcdToByte(regsD.d.b.h); /* month */ dosregs.d.b.l = InitBcdToByte(regsD.d.b.l); /* day */ init_call_intr(0x21, &dosregs); @@ -95,7 +69,4 @@ void Init_clk_driver(void) dosregs.d.b.h = InitBcdToByte(regsT.d.b.h); /*seconds */ dosregs.d.b.l = 0; init_call_intr(0x21, &dosregs); - -error:; - } From b0e54ff7043529fb0ac6d7112dd724db11364b25 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Tue, 9 Sep 2003 17:43:43 +0000 Subject: [PATCH 286/671] (with a little help from Arkady) inthndler.c, chario.c, break.c simplifications and cleanups. Pass a near pointer to the far pointer that points to the device instead of an SFT index (in general). Make cooked_write much faster by only testing for input every 32 characters. No longer test for ctl_s on syscon if writing to the printer: just read from the printer which will return zero characters. Fix reading/writing zero characters by returning "256" (special code). Adjust interfaces in other files. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@683 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/break.c | 18 +-- kernel/chario.c | 313 +++++++++++++++++++++++----------------------- kernel/dosfns.c | 16 +-- kernel/globals.h | 3 + kernel/inthndlr.c | 121 ++++++++---------- kernel/proto.h | 21 ++-- kernel/systime.c | 2 +- 7 files changed, 244 insertions(+), 250 deletions(-) diff --git a/kernel/break.c b/kernel/break.c index 6c02dabd..8be3b8ee 100644 --- a/kernel/break.c +++ b/kernel/break.c @@ -47,9 +47,14 @@ static BYTE *RcsId = * 1) flag at 40:71 bit 7 * 2) STDIN stream via con_break() */ -int control_break(void) +int check_handle_break(void) { - return (CB_FLG & CB_MSK) || con_break(); + if (CB_FLG & CB_MSK) { + CB_FLG &= ~CB_MSK; /* reset the ^Break flag */ + handle_break(&syscon); + } + /* con_break will call handle_break() for CTL_C */ + return con_break(); } /* @@ -61,13 +66,10 @@ int control_break(void) * 3) decrease the InDOS flag as the kernel drops back to user space * 4) invoke INT-23 and never come back */ -void handle_break(int sft_idx) +void handle_break(struct dhdr FAR **pdev) { - if (CB_FLG & CB_MSK) /* Ctrl-Break pressed */ - CB_FLG &= ~CB_MSK; /* reset the ^Break flag */ - else /* Ctrl-C pressed */ - echo_char_stdin(CTL_C); - KbdFlush(sft_idx); /* Er, this is con_flush() */ + echo_char_stdin(CTL_C); + con_flush(pdev); if (!ErrorMode) /* within int21_handler, InDOS is not incremented */ if (InDOS) --InDOS; /* fail-safe */ diff --git a/kernel/chario.c b/kernel/chario.c index 4584cb58..3263e4a0 100644 --- a/kernel/chario.c +++ b/kernel/chario.c @@ -37,17 +37,19 @@ static BYTE *charioRcsId = #include "globals.h" -STATIC int CharRequest(struct dhdr FAR *dev) +STATIC int CharRequest(struct dhdr FAR **pdev, unsigned command) { + struct dhdr FAR *dev = *pdev; + CharReqHdr.r_command = command; CharReqHdr.r_unit = 0; CharReqHdr.r_status = 0; CharReqHdr.r_length = sizeof(request); execrh(&CharReqHdr, dev); if (CharReqHdr.r_status & S_ERROR) { - charloop: - switch (char_error(&CharReqHdr, dev)) - { + for (;;) { + switch (char_error(&CharReqHdr, dev)) + { case ABORT: case FAIL: return DE_INVLDACC; @@ -56,147 +58,134 @@ STATIC int CharRequest(struct dhdr FAR *dev) return 0; case RETRY: return 1; - default: - goto charloop; + } } } - return 0; + return SUCCESS; } -long BinaryCharIO(struct dhdr FAR * dev, size_t n, void FAR * bp, unsigned command) +long BinaryCharIO(struct dhdr FAR **pdev, size_t n, void FAR * bp, + unsigned command) { - int err = SUCCESS; + int err; do { - CharReqHdr.r_command = command; CharReqHdr.r_count = n; CharReqHdr.r_trans = bp; - } while ((err = CharRequest(dev)) == 1); + err = CharRequest(pdev, command); + } while (err == 1); return err == SUCCESS ? (long)CharReqHdr.r_count : err; } +STATIC int CharIO(struct dhdr FAR **pdev, unsigned char ch, unsigned command) +{ + int err = (int)BinaryCharIO(pdev, 1, &ch, command); + if (err == 0) + return 256; + if (err < 0) + return err; + return ch; +} + /* STATE FUNCTIONS */ -STATIC struct dhdr FAR *idx_to_dev(int sft_idx) +void CharCmd(struct dhdr FAR **pdev, unsigned command) { - sft FAR *s = idx_to_sft(sft_idx); - if (FP_OFF(s) == (size_t)-1 || (s->sft_mode & SFT_MWRITE) || - !(s->sft_flags & SFT_FDEVICE)) - return syscon; - else - return s->sft_dev; + while (CharRequest(pdev, command) == 1); +} + +STATIC int Busy(struct dhdr FAR **pdev) +{ + CharCmd(pdev, C_ISTAT); + return CharReqHdr.r_status & S_BUSY; } -/* if sft_idx is invalid, then we just monitor syscon */ -STATIC BOOL Busy(int sft_idx) +void con_flush(struct dhdr FAR **pdev) { - sft FAR *s = idx_to_sft(sft_idx); + CharCmd(pdev, C_IFLUSH); +} +/* if the sft is invalid, then we just monitor syscon */ +struct dhdr FAR *sft_to_dev(sft FAR *s) +{ + if (FP_OFF(s) == (size_t) -1) + return syscon; if (s->sft_flags & SFT_FDEVICE) - { - struct dhdr FAR *dev = idx_to_dev(sft_idx); - do { - CharReqHdr.r_command = C_ISTAT; - } while(CharRequest(dev) == 1); - if (CharReqHdr.r_status & S_BUSY) - return TRUE; - else - return FALSE; - } - else - return s->sft_posit >= s->sft_size; + return s->sft_dev; + return NULL; } -BOOL StdinBusy(void) +int StdinBusy(void) { - return Busy(get_sft_idx(STDIN)); + sft FAR *s = get_sft(STDIN); + struct dhdr FAR *dev = sft_to_dev(s); + + if (dev) + return Busy(&dev); + + return s->sft_posit >= s->sft_size; } -STATIC void Do_DosIdle_loop(int sft_idx) +STATIC void Do_DosIdle_loop(struct dhdr FAR **pdev) { - /* the idle loop is only safe if we're using the character stack */ + /* the idle loop is only safe if we're using the character stack */ if (user_r->AH < 0xd) - while (Busy(sft_idx)) + while (Busy(pdev) && Busy(&syscon)) DosIdle_int(); } /* get character from the console - this is how DOS gets CTL_C/CTL_S/CTL_P when outputting */ -STATIC int ndread(int sft_idx) +STATIC int ndread(struct dhdr FAR **pdev) { - struct dhdr FAR *dev = idx_to_dev(sft_idx); - do { - CharReqHdr.r_command = C_NDREAD; - } while(CharRequest(dev) == 1); + CharCmd(pdev, C_NDREAD); if (CharReqHdr.r_status & S_BUSY) return -1; return CharReqHdr.r_ndbyte; } -STATIC int con_get_char(int sft_idx) +STATIC void con_skip_char(struct dhdr FAR **pdev) { - unsigned char c; - BinaryCharIO(idx_to_dev(sft_idx), 1, &c, C_INPUT); - if (c == CTL_C) - handle_break(sft_idx); - return c; + if (CharIO(pdev, 0, C_INPUT) == CTL_C) + handle_break(pdev); } -STATIC void con_hold(int sft_idx) +STATIC void con_hold(struct dhdr FAR **pdev) { - int c; - if (control_break()) - handle_break(-1); - c = ndread(sft_idx); - if (c == CTL_S) + int c = check_handle_break(); + if (*pdev != syscon) + c = ndread(pdev); + if (c == CTL_S || c == CTL_C) { - con_get_char(sft_idx); - Do_DosIdle_loop(sft_idx); + con_skip_char(pdev); + Do_DosIdle_loop(pdev); /* just wait */ - c = con_get_char(sft_idx); - } - if (c == CTL_C) - { - con_get_char(sft_idx); - handle_break(sft_idx); + check_handle_break(); + con_skip_char(pdev); } } -BOOL con_break(void) +int con_break(void) { - if (ndread(-1) == CTL_C) - { - con_get_char(-1); - return TRUE; - } - else - return FALSE; + int c = ndread(&syscon); + if (c == CTL_C) + con_skip_char(&syscon); + return c; } /* OUTPUT FUNCTIONS */ #ifdef __WATCOMC__ -void int29(char c); -#pragma aux int29 = "int 29h" parm[al] modify exact [bx] -#endif +void fast_put_char(char c); +#pragma aux fast_put_char = "int 29h" parm[al] modify exact [bx] +#else -/* writes a character in raw mode; use int29 if possible - for speed */ -STATIC int raw_put_char(int sft_idx, int c) +/* writes a character in raw mode using int29 for speed */ +STATIC void fast_put_char(unsigned char chr) { - struct dhdr FAR *dev = idx_to_dev(sft_idx); - unsigned char chr = (unsigned char)c; - - if (PrinterEcho) - DosWrite(STDPRN, 1, &chr); - - if (dev->dh_attr & ATTR_FASTCON) - { #if defined(__TURBOC__) _AL = chr; __int__(0x29); -#elif defined(__WATCOMC__) - int29(chr); #elif defined(I86) asm { @@ -204,59 +193,79 @@ STATIC int raw_put_char(int sft_idx, int c) int 0x29; } #endif - return 0; - } - c = (int)BinaryCharIO(dev, 1, &chr, C_OUTPUT); - if (c < 0) - return c; - else - return chr; } +#endif /* writes a character in cooked mode; maybe with printer echo; handles TAB expansion */ -STATIC int cooked_put_char(int sft_idx, int c) +STATIC int cooked_write_char(struct dhdr FAR **pdev, + unsigned char c, + unsigned char *fast_counter) { - int err = 0; unsigned char scrpos = scr_pos; - - /* Test for hold char */ - con_hold(sft_idx); - - switch (c) - { - case CR: - scrpos = 0; - break; - case LF: - case BELL: - break; - case BS: - if (scrpos > 0) - scrpos--; - break; - case HT: - do - err = raw_put_char(sft_idx, ' '); - while (err >= 0 && ((++scrpos) & 7)); - break; - default: - scrpos++; + unsigned char count = 1; + + if (c == CR) + scrpos = 0; + else if (c == BS) { + if (scrpos > 0) + scrpos--; + } else if (c != LF && c != BELL) { + if (c == HT) { + count = 8 - (scrpos & 7); + c = ' '; + } + scrpos += count; } scr_pos = scrpos; - if (c != HT) - err = raw_put_char(sft_idx, c); - return err; + + do { + + /* if not fast then < 0x80; always check + otherwise check every 32 characters */ + if (*fast_counter <= 0x80) + /* Test for hold char and ctl_c */ + con_hold(pdev); + *fast_counter += 1; + *fast_counter &= 0x9f; + + if (PrinterEcho) + DosWrite(STDPRN, 1, &c); + if (*fast_counter & 0x80) + { + fast_put_char(c); + } + else + { + int err = CharIO(pdev, c, C_OUTPUT); + if (err < 0) + return err; + } + } while (--count > 0); + return SUCCESS; } -long cooked_write(int sft_idx, size_t n, char FAR *bp) +long cooked_write(struct dhdr FAR **pdev, size_t n, char FAR *bp) { - size_t xfer; - int err = SUCCESS; - - for (xfer = 0; err >= SUCCESS && xfer < n && *bp != CTL_Z; bp++, xfer++) - err = cooked_put_char(sft_idx, *bp); - return err < SUCCESS ? (long)err : xfer; + size_t xfer = 0; + unsigned char fast_counter; + + /* bit 7 means fastcon; low 5 bits count number of characters */ + fast_counter = ((*pdev)->dh_attr & ATTR_FASTCON) << 3; + + for (xfer = 0; xfer < n; xfer++) + { + int err; + unsigned char c = *bp++; + + if (c == CTL_Z) + break; + + err = cooked_write_char(pdev, c, &fast_counter); + if (err < 0) + return err; + } + return xfer; } /* writes character for disk file or device */ @@ -276,13 +285,13 @@ void write_char_stdout(int c) /* this is for handling things like ^C, mostly used in echoed input */ STATIC int echo_char(int c, int sft_idx) { + int out = c; if (iscntrl(c) && c != HT && c != LF && c != CR) { write_char('^', sft_idx); - write_char(c + '@', sft_idx); + out += '@'; } - else - write_char(c, sft_idx); + write_char(out, sft_idx); return c; } @@ -300,28 +309,28 @@ STATIC void destr_bs(int sft_idx) /* READ FUNCTIONS */ -STATIC int raw_get_char(int sft_idx, BOOL check_break) +STATIC int raw_get_char(struct dhdr FAR **pdev, BOOL check_break) { - unsigned char c; - int err; - - Do_DosIdle_loop(sft_idx); + Do_DosIdle_loop(pdev); if (check_break) - con_hold(sft_idx); - - err = (int)BinaryCharIO(idx_to_dev(sft_idx), 1, &c, C_INPUT); - return err < 0 ? err : c; + { + con_hold(pdev); + Do_DosIdle_loop(pdev); + } + return CharIO(pdev, 0, C_INPUT); } -long cooked_read(int sft_idx, size_t n, char FAR *bp) +long cooked_read(struct dhdr FAR **pdev, size_t n, char FAR *bp) { unsigned xfer = 0; int c; while(n--) { - c = raw_get_char(sft_idx, TRUE); + c = raw_get_char(pdev, TRUE); if (c < 0) return c; + if (c == 256) + break; *bp++ = c; xfer++; if (bp[-1] == CTL_Z) @@ -333,10 +342,10 @@ long cooked_read(int sft_idx, size_t n, char FAR *bp) unsigned char read_char(int sft_idx, BOOL check_break) { unsigned char c; - sft FAR *s = idx_to_sft(sft_idx); + struct dhdr FAR *dev = sft_to_dev(idx_to_sft(sft_idx)); - if ((FP_OFF(s) == (size_t) -1) || (s->sft_flags & SFT_FDEVICE)) - return raw_get_char(sft_idx, check_break); + if (dev) + return (unsigned char)raw_get_char(&dev, check_break); DosRWSft(sft_idx, 1, &c, XFR_READ); return c; @@ -352,18 +361,6 @@ unsigned char read_char_stdin(BOOL check_break) return read_char(get_sft_idx(STDIN), check_break); } -void KbdFlush(int sft_idx) -{ - struct dhdr FAR *dev = idx_to_dev(sft_idx); - - do { - CharReqHdr.r_unit = 0; - CharReqHdr.r_status = 0; - CharReqHdr.r_command = C_IFLUSH; - CharReqHdr.r_length = sizeof(request); - } while (CharRequest(dev) == 1); -} - /* reads a line (buffered, called by int21/ah=0ah, 3fh) */ void read_line(int sft_in, int sft_out, keyboard FAR * kp) { diff --git a/kernel/dosfns.c b/kernel/dosfns.c index b28464ac..632903d7 100644 --- a/kernel/dosfns.c +++ b/kernel/dosfns.c @@ -230,10 +230,12 @@ long DosRWSft(int sft_idx, size_t n, void FAR * bp, int mode) /* Do a device transfer if device */ if (s->sft_flags & SFT_FDEVICE) { + struct dhdr FAR *dev = s->sft_dev; + /* Now handle raw and cooked modes */ if (s->sft_flags & SFT_FBINARY) { - long rc = BinaryCharIO(s->sft_dev, n, bp, + long rc = BinaryCharIO(&dev, n, bp, mode == XFR_READ ? C_INPUT : C_OUTPUT); if (mode == XFR_WRITE && rc > 0 && (s->sft_flags & SFT_FCONOUT)) { @@ -266,7 +268,7 @@ long DosRWSft(int sft_idx, size_t n, void FAR * bp, int mode) if (mode==XFR_READ) { long rc; - + /* Test for eof and exit */ /* immediately if it is */ if (!(s->sft_flags & SFT_FEOF) || (s->sft_flags & SFT_FNUL)) @@ -275,21 +277,21 @@ long DosRWSft(int sft_idx, size_t n, void FAR * bp, int mode) if (s->sft_flags & SFT_FCONIN) rc = read_line_handle(sft_idx, n, bp); else - rc = cooked_read(sft_idx, n, bp); + rc = cooked_read(&dev, n, bp); if (*(char *)bp == CTL_Z) s->sft_flags &= ~SFT_FEOF; return rc; } else { - /* reset EOF state (set to no EOF) */ + /* reset EOF state (set to no EOF) */ s->sft_flags |= SFT_FEOF; /* if null just report full transfer */ if (s->sft_flags & SFT_FNUL) return n; else - return cooked_write(sft_idx, n, bp); + return cooked_write(&dev, n, bp); } } @@ -1399,13 +1401,13 @@ struct dhdr FAR *IsDevice(const char FAR * fname) for (i = 0; i < FNAME_SIZE; i++) { - char c1 = froot[i]; + unsigned char c1 = (unsigned char)froot[i]; if (c1 == '.' || c1 == '\0') { /* check if remainder of device name consists of spaces or nulls */ for (; i < FNAME_SIZE; i++) { - char c2 = dhp->dh_name[i]; + unsigned char c2 = dhp->dh_name[i]; if (c2 != ' ' && c2 != '\0') break; } diff --git a/kernel/globals.h b/kernel/globals.h index ae88d1e6..b8293044 100644 --- a/kernel/globals.h +++ b/kernel/globals.h @@ -429,6 +429,9 @@ VOID fputbyte(VOID FAR *, UBYTE); /*#define is_leap_year(y) ((y) & 3 ? 0 : (y) % 100 ? 1 : (y) % 400 ? 0 : 1) */ /* ^Break handling */ +#ifdef __WATCOMC__ +#pragma aux (cdecl) spawn_int23 aborts; +#endif void ASMCFUNC spawn_int23(void); /* procsupt.asm */ GLOBAL BYTE ReturnAnyDosVersionExpected; diff --git a/kernel/inthndlr.c b/kernel/inthndlr.c index 4bb6f662..ea974139 100644 --- a/kernel/inthndlr.c +++ b/kernel/inthndlr.c @@ -373,7 +373,6 @@ VOID ASMCFUNC int21_service(iregs FAR * r) #define FP_DS_DX (MK_FP(lr.DS, lr.DX)) #define FP_ES_DI (MK_FP(lr.ES, lr.DI)) - #define CLEAR_CARRY_FLAG() r->FLAGS &= ~FLG_CARRY #define SET_CARRY_FLAG() r->FLAGS |= FLG_CARRY @@ -407,23 +406,8 @@ VOID ASMCFUNC int21_service(iregs FAR * r) /* Check for Ctrl-Break */ - switch (lr.AH) - { - default: - if (!break_ena) - break; - case 0x01: - case 0x02: - case 0x03: - case 0x04: - case 0x05: - case 0x08: - case 0x09: - case 0x0a: - case 0x0b: - if (control_break()) - handle_break(-1); - } + if (break_ena || (lr.AH >= 1 && lr.AH <= 5) || (lr.AH >= 8 && lr.AH <= 0x0b)) + check_handle_break; /* The dispatch handler */ switch (lr.AH) @@ -436,13 +420,16 @@ VOID ASMCFUNC int21_service(iregs FAR * r) /* Read Keyboard with Echo */ case 0x01: + DOS_01: lr.AL = read_char_stdin(TRUE); write_char_stdout(lr.AL); break; /* Display Character */ case 0x02: - write_char_stdout(lr.DL); + DOS_02: + lr.AL = lr.DL; + write_char_stdout(lr.AL); break; /* Auxiliary Input */ @@ -461,27 +448,28 @@ VOID ASMCFUNC int21_service(iregs FAR * r) /* Direct Console I/O */ case 0x06: + DOS_06: if (lr.DL != 0xff) - write_char_stdout(lr.DL); - else if (StdinBusy()) - { - lr.AL = 0x00; - r->FLAGS |= FLG_ZERO; - } - else - { - r->FLAGS &= ~FLG_ZERO; - lr.AL = read_char_stdin(FALSE); - } + goto DOS_02; + + lr.AL = 0x00; + r->FLAGS |= FLG_ZERO; + if (StdinBusy()) + break; + + r->FLAGS &= ~FLG_ZERO; + lr.AL = read_char_stdin(FALSE); break; /* Direct Console Input */ case 0x07: + DOS_07: lr.AL = read_char_stdin(FALSE); break; /* Read Keyboard Without Echo */ case 0x08: + DOS_08: lr.AL = read_char_stdin(TRUE); break; @@ -501,35 +489,34 @@ VOID ASMCFUNC int21_service(iregs FAR * r) /* Buffered Keyboard Input */ case 0x0a: + DOS_0A: read_line(get_sft_idx(STDIN), get_sft_idx(STDOUT), FP_DS_DX); break; /* Check Stdin Status */ case 0x0b: + lr.AL = 0xFF; if (StdinBusy()) lr.AL = 0x00; - else - lr.AL = 0xFF; break; /* Flush Buffer, Read Keyboard */ case 0x0c: - KbdFlush(get_sft_idx(STDIN)); + { + struct dhdr FAR *dev = sft_to_dev(get_sft(STDIN)); + if (dev) + con_flush(&dev); switch (lr.AL) { - case 0x01: - case 0x06: - case 0x07: - case 0x08: - case 0x0a: - lr.AH = lr.AL; - goto dispatch; - - default: - lr.AL = 0x00; - break; + case 0x01: goto DOS_01; + case 0x06: goto DOS_06; + case 0x07: goto DOS_07; + case 0x08: goto DOS_08; + case 0x0a: goto DOS_0A; } + lr.AL = 0x00; break; + } /* Reset Drive */ case 0x0d: @@ -1819,45 +1806,43 @@ struct int2f12regs { extern short AllocateHMASpace (size_t lowbuffer, size_t highbuffer); +/* WARNING: modifications in `r' are used outside of int2F_12_handler() + * On input r.ax==0x12xx, 0x4A01 or 0x4A02 + */ VOID ASMCFUNC int2F_12_handler(struct int2f12regs r) { UWORD function = r.ax & 0xff; - - /* dont use + + /* dont use QueryFreeHMASpace(&p); here; DS !=SS */ if ((r.ax & 0xff00) == 0x4a00) { - size_t wantedBytes = r.bx; - - r.bx = 0; - r.es = FP_SEG(firstAvailableBuf); - r.di = FP_OFF(firstAvailableBuf); - if (FP_SEG(firstAvailableBuf) != 0xffff) - { + size_t wantedBytes, offs; + + if (function != 1 && function != 2) return; - } - - if (r.ax == 0x4a01) - { - r.bx = 0 - FP_OFF(firstAvailableBuf); + + wantedBytes = r.bx; + r.es = r.di = 0xffff; + r.bx = 0; + if (FP_SEG(firstAvailableBuf) != 0xffff) return; - } - - if (r.ax == 0x4a02) + + offs = FP_OFF(firstAvailableBuf); + r.di = offs; + + if (function == 0x02) { - if (wantedBytes > 0 - FP_OFF(firstAvailableBuf)) - { - r.bx = 0; - return; - } + if (wantedBytes > ~offs) + return; AllocateHMASpace(FP_OFF(firstAvailableBuf), FP_OFF(firstAvailableBuf)+wantedBytes); firstAvailableBuf += wantedBytes; - - return; + r.bx = wantedBytes; } + return; } if (function > 0x31) diff --git a/kernel/proto.h b/kernel/proto.h index d2b2c098..3999f1a3 100644 --- a/kernel/proto.h +++ b/kernel/proto.h @@ -48,23 +48,28 @@ UWORD dskxfer(COUNT dsk, ULONG blkno, VOID FAR * buf, UWORD numblocks, /* *** End of change */ /* break.c */ -int control_break(void); -void handle_break(int sft_idx); +#ifdef __WATCOMC__ +#pragma aux handle_break aborts; +#endif +int check_handle_break(void); +void handle_break(struct dhdr FAR **pdev); /* chario.c */ -long BinaryCharIO(struct dhdr FAR * dev, size_t n, void FAR * bp, unsigned command); +struct dhdr FAR *sft_to_dev(sft FAR *sft); +long BinaryCharIO(struct dhdr FAR **pdev, size_t n, void FAR * bp, + unsigned command); int echo_char_stdin(int c); -BOOL con_break(void); -BOOL StdinBusy(void); -void KbdFlush(int sft_idx); +int con_break(void); +int StdinBusy(void); +void con_flush(struct dhdr FAR **pdev); unsigned char read_char(int sft_idx, BOOL check_break); unsigned char read_char_stdin(BOOL check_break); -long cooked_read(int sft_idx, size_t n, char FAR *bp); +long cooked_read(struct dhdr FAR **pdev, size_t n, char FAR *bp); void read_line(int sft_in, int sft_out, keyboard FAR * kp); size_t read_line_handle(int sft_idx, size_t n, char FAR * bp); void write_char(int c, int sft_idx); void write_char_stdout(int c); -long cooked_write(int sft_idx, size_t n, char FAR *bp); +long cooked_write(struct dhdr FAR **pdev, size_t n, char FAR *bp); sft FAR *get_sft(UCOUNT); diff --git a/kernel/systime.c b/kernel/systime.c index d7d8394c..e84bc0ea 100644 --- a/kernel/systime.c +++ b/kernel/systime.c @@ -74,7 +74,7 @@ UWORD DaysFromYearMonthDay(UWORD Year, UWORD Month, UWORD DayOfMonth) /* common - call the clock driver */ void ExecuteClockDriverRequest(BYTE command) { - BinaryCharIO(clock, sizeof(struct ClockRecord), &ClkRecord, command); + BinaryCharIO(&clock, sizeof(struct ClockRecord), &ClkRecord, command); } void DosGetTime(struct dostime *dt) From c418300de4510ea758eb03711068076243d9f87f Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Mon, 15 Sep 2003 10:36:04 +0000 Subject: [PATCH 287/671] Fix warnings reported by Turbo C git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@684 6ac86273-5f31-0410-b378-82cca8765d1b --- utils/exeflat.c | 12 ++++++------ utils/patchobj.c | 10 +++++----- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/utils/exeflat.c b/utils/exeflat.c index f20c1c69..f19fd413 100644 --- a/utils/exeflat.c +++ b/utils/exeflat.c @@ -166,7 +166,7 @@ int main(int argc, char **argv) /* first read file into memory chunks */ fseek(src, header.exHeaderSize * 16UL, SEEK_SET); - buffers = malloc((size + BUFSIZE - 1) / BUFSIZE * sizeof(char *)); + buffers = malloc((size_t)((size + BUFSIZE - 1) / BUFSIZE) * sizeof(char *)); if (buffers == NULL) { printf("Allocation error\n"); @@ -177,7 +177,7 @@ int main(int argc, char **argv) to_xfer -= bufsize, curbuf++) { if (to_xfer < BUFSIZE) - bufsize = to_xfer; + bufsize = (size_t)to_xfer; *curbuf = malloc(bufsize); if (*curbuf == NULL) { @@ -208,10 +208,10 @@ int main(int argc, char **argv) for (i = 0; i < header.exRelocItems; i++) { ULONG spot = ((ULONG) reloc[i].seg << 4) + reloc[i].off; - UBYTE *spot0 = &buffers[spot / BUFSIZE][spot % BUFSIZE]; - UBYTE *spot1 = &buffers[(spot + 1) / BUFSIZE][(spot + 1) % BUFSIZE]; + UBYTE *spot0 = &buffers[(size_t)(spot / BUFSIZE)][(size_t)(spot % BUFSIZE)]; + UBYTE *spot1 = &buffers[(size_t)((spot + 1) / BUFSIZE)][(size_t)((spot + 1) % BUFSIZE)]; UWORD segment = ((UWORD) * spot1 << 8) + *spot0; - + for (j = 0; j < silentcount; j++) if (segment == silentSegments[j]) { @@ -270,7 +270,7 @@ int main(int argc, char **argv) to_xfer -= bufsize, curbuf++) { if (to_xfer < BUFSIZE) - bufsize = to_xfer; + bufsize = (size_t)to_xfer; if (fwrite(*curbuf, sizeof(char), bufsize, dest) != bufsize) { diff --git a/utils/patchobj.c b/utils/patchobj.c index 9d0eb6c9..72d9870b 100644 --- a/utils/patchobj.c +++ b/utils/patchobj.c @@ -123,7 +123,7 @@ int main(int argc, char *argv[]) struct record { unsigned char rectyp; unsigned short datalen; - unsigned char buffer[0x2000]; + char buffer[0x2000]; } Record, Outrecord; #include "algndflt.h" @@ -132,7 +132,7 @@ struct verify_pack1 { char x[ sizeof(struct record) == 0x2003 ? 1 : -1];}; void go_records(FILE * fdin, FILE * fdo) { unsigned char stringlen; - unsigned char *string, *s; + char *string, *s; int i, j; unsigned char chksum; @@ -165,7 +165,7 @@ void go_records(FILE * fdin, FILE * fdo) for (i = 0; i < Record.datalen - 1;) { - stringlen = Record.buffer[i]; + stringlen = (unsigned char)Record.buffer[i]; i++; string = &Record.buffer[i]; @@ -188,9 +188,9 @@ void go_records(FILE * fdin, FILE * fdo) } chksum = 0; - for (s = (unsigned char *)&Outrecord; + for (s = (char *)&Outrecord; s < &Outrecord.buffer[Outrecord.datalen]; s++) - chksum += *s; + chksum += (unsigned char)*s; Outrecord.buffer[Outrecord.datalen] = ~chksum; Outrecord.datalen++; From f8f08915035a5f892a5851e32b3c09a48dcae0f3 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Mon, 15 Sep 2003 10:37:40 +0000 Subject: [PATCH 288/671] More verbose mapfiles for watcom C; some slash preparations to allow cross-building on Linux git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@685 6ac86273-5f31-0410-b378-82cca8765d1b --- utils/makefile | 4 ++-- utils/wlinker.bat | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/utils/makefile b/utils/makefile index dde637ac..7be6ec76 100644 --- a/utils/makefile +++ b/utils/makefile @@ -1,4 +1,4 @@ -!include "..\mkfiles\generic.mak" +!include "../mkfiles/generic.mak" CFLAGS = -I$(INCLUDEPATH) -I..\hdr @@ -7,7 +7,7 @@ production: patchobj.com exeflat.exe patchobj.com: patchobj.c $(CL) $(CFLAGST) $(TINY) $(CFLAGS) patchobj.c -exeflat.exe: exeflat.c ..\hdr\exe.h +exeflat.exe: exeflat.c ../hdr/exe.h $(CL) $(CFLAGSC) $(CFLAGS) exeflat.c diff --git a/utils/wlinker.bat b/utils/wlinker.bat index 47a065c7..36e746ab 100755 --- a/utils/wlinker.bat +++ b/utils/wlinker.bat @@ -1 +1,4 @@ -@ms2wlink %1 %2 %3 %4 %5 %6 %7 %8 %9 ,,,, | wlink \ No newline at end of file +@echo off +ms2wlink %1 %2 %3 %4 %5 %6 %7 %8 %9 ,,,, > kernel.lnk +echo op map,statics,verbose >> kernel.lnk +wlink < kernel.lnk From 0aba4bc7fbaec7fbe27974b43c29c62354c74254 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Mon, 15 Sep 2003 10:40:11 +0000 Subject: [PATCH 289/671] Use STATIC=static for watcom C (statics are in the mapfile); remove some cruft. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@686 6ac86273-5f31-0410-b378-82cca8765d1b --- hdr/device.h | 3 --- hdr/portab.h | 2 +- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/hdr/device.h b/hdr/device.h index 0d28abd9..53167d75 100644 --- a/hdr/device.h +++ b/hdr/device.h @@ -112,9 +112,6 @@ static BYTE *device_hRcsId = #ifndef FALSE #define FALSE 0 #endif -#define mk_offset(far_ptr) ((UWORD)(far_ptr)) -#define mk_segment(far_ptr) ((UWORD)((ULONG)(far_ptr) >> 16)) -#define far_ptr(seg, off) ((VOID FAR *)(((ULONG)(off))+((ULONG)(seg) << 16))) /* * structures diff --git a/hdr/portab.h b/hdr/portab.h index 6600a896..eecd53ae 100644 --- a/hdr/portab.h +++ b/hdr/portab.h @@ -194,7 +194,7 @@ typedef unsigned short CLUSTER; #endif typedef unsigned short UNICODE; -#ifdef STATICS +#if defined(STATICS) || defined(__WATCOMC__) #define STATIC static /* local calls inside module */ #else #define STATIC From 1957583c0e5cde65a467952a48c13cf824f1729b Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Mon, 15 Sep 2003 10:41:27 +0000 Subject: [PATCH 290/671] Fix some typos. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@687 6ac86273-5f31-0410-b378-82cca8765d1b --- docs/build.txt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/build.txt b/docs/build.txt index bc1e1815..880d8c8f 100644 --- a/docs/build.txt +++ b/docs/build.txt @@ -14,11 +14,11 @@ CONFIG.BAT file will not get replaced! You will also need to download the latest version of NASM and Turbo C 2.01. Install Turbo C and NASM somewhere (it doesn't really matter -where) and then be sure to edit the CONFIG.MAK file to reflect where +where) and then be sure to edit the CONFIG.BAT file to reflect where you put the tools. -You can find NASM at http://nasm.sourceforge.net. Version 0.98.36 is -strongly recommended. The older 0.98 will also work fine, but +You can find NASM at http://nasm.sourceforge.net. Version 0.98.36 or +later is strongly recommended. The older 0.98 will also work fine, but any version in between is likely to fail. It's best to use a NASM that is native to your host; that is, when compiling in Windows, use the win32 version. The DJGPP version is less likely to run out of @@ -32,7 +32,7 @@ This kernel will now compile with Turbo C 2.01, Turbo C++ 1.01 (now freely available!), Turbo C 3.0, Borland C 4.51 & 5.01. It should work with other Borland compilers, Microsoft C and (Open)Watcom C. -The OpenWatcom 1.0 compiler for DOS can now be downloaded at +The OpenWatcom 1.0 compiler (or later) for DOS can now be downloaded at www.openwatcom.org: you need at least the following zips from ftp://ftp.openwatcom.org/watcom/zips/ From 178b66e6de48cfd9305eb81f647360a8214f92dc Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Mon, 15 Sep 2003 10:46:24 +0000 Subject: [PATCH 291/671] Flip some slashes for Linux compat; simplifications in kernel/makefile git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@688 6ac86273-5f31-0410-b378-82cca8765d1b --- boot/makefile | 2 +- drivers/makefile | 7 ++-- kernel/makefile | 99 +++++++++++++++--------------------------------- lib/makefile | 2 +- sys/makefile | 2 +- 5 files changed, 37 insertions(+), 75 deletions(-) diff --git a/boot/makefile b/boot/makefile index a01099e8..0299d170 100644 --- a/boot/makefile +++ b/boot/makefile @@ -5,7 +5,7 @@ # -!include "..\mkfiles\generic.mak" +!include "../mkfiles/generic.mak" production: fat12com.bin fat16com.bin fat32chs.bin fat32lba.bin diff --git a/drivers/makefile b/drivers/makefile index 426b8c3b..98647887 100644 --- a/drivers/makefile +++ b/drivers/makefile @@ -5,7 +5,7 @@ # -!include "..\mkfiles\generic.mak" +!include "../mkfiles/generic.mak" # MICROSOFT C @@ -22,10 +22,9 @@ #AFLAGS = /Mx /Dmem$(MODEL)=1 #LIBFLAGS = /c -OBJS = floppy.obj getvec.obj rdpcclk.obj rdatclk.obj \ -wrpcclk.obj wratclk.obj +OBJS = floppy.obj getvec.obj rdpcclk.obj wrpcclk.obj wratclk.obj -LIBOBJS= +floppy +getvec +rdpcclk +rdatclk +wrpcclk +wratclk +LIBOBJS= +floppy +getvec +rdpcclk +wrpcclk +wratclk diff --git a/kernel/makefile b/kernel/makefile index 4317cfae..2522489c 100644 --- a/kernel/makefile +++ b/kernel/makefile @@ -16,7 +16,7 @@ LIB= $(COMPILERBASE)\lib LIBPATH = . #AFLAGS = /Mx /DSTANDALONE=1 /I..\HDR -LIBS =..\LIB\DEVICE.LIB ..\LIB\LIBM.LIB +LIBS =..\lib\device.lib ..\lib\libm.lib #INITCFLAGS =$(ALLCFLAGS) -zAINIT -zCINIT_TEXT -zDIB -zRID -zTID -zPIGROUP -zBIB \ #-zGIGROUP -zSIGROUP #CFLAGS =$(ALLCFLAGS) -zAHMA -zCHMA_TEXT @@ -31,56 +31,19 @@ HDR=../hdr/ # *List Macros* -EXE_dependencies = \ - apisupt.obj \ - asmsupt.obj \ - blockio.obj \ - break.obj \ - chario.obj \ - config.obj \ - console.obj \ - dosidle.obj \ - dosfns.obj \ - dosnames.obj \ - dsk.obj \ - initdisk.obj \ - initclk.obj \ - entry.obj \ - error.obj \ - execrh.obj \ - fatdir.obj \ - fatfs.obj \ - fattab.obj \ - fcbfns.obj \ - initoem.obj \ - int2f.obj \ - inthndlr.obj \ - io.obj \ - intr.obj \ - ioctl.obj \ - irqstack.obj \ - kernel.obj \ - lfnapi.obj \ - main.obj \ - memmgr.obj \ - misc.obj \ - newstuff.obj \ - network.obj \ - nls.obj \ - nls_hc.obj \ - nlssupt.obj \ - prf.obj \ - iprf.obj \ - printer.obj \ - procsupt.obj \ - serial.obj \ - strings.obj \ - sysclk.obj \ - syspack.obj \ - systime.obj \ - task.obj \ - inithma.obj \ - dyninit.obj +OBJS1=kernel.obj entry.obj io.obj console.obj serial.obj printer.obj dsk.obj \ +sysclk.obj +OBJS2=asmsupt.obj execrh.obj nlssupt.obj procsupt.obj dosidle.obj int2f.obj \ +nls_hc.obj +OBJS3= apisupt.obj intr.obj irqstack.obj blockio.obj chario.obj systime.obj \ +error.obj +OBJS4=break.obj dosfns.obj fatdir.obj fatfs.obj fattab.obj fcbfns.obj \ +inthndlr.obj +OBJS5=ioctl.obj dosnames.obj memmgr.obj task.obj newstuff.obj nls.obj network.obj +OBJS6=prf.obj misc.obj strings.obj syspack.obj lfnapi.obj +OBJS7=main.obj config.obj initoem.obj inithma.obj dyninit.obj iprf.obj \ +initdisk.obj initclk.obj +OBJS = $(OBJS1) $(OBJS2) $(OBJS3) $(OBJS4) $(OBJS5) $(OBJS6) $(OBJS7) # *Explicit Rules* @@ -104,22 +67,22 @@ clean: # XXX: This is a very ugly way of linking the kernel, forced upon us by the # inability of Turbo `make' 2.0 to perform command line redirection. -- ror4 -kernel.res: $(EXE_dependencies) $(LIBS) +ECHOTO=..\utils\echoto + +kernel.res: $(OBJS) $(LIBS) -$(RM) kernel.res - ..\utils\echoto kernel.res kernel.obj iprf.obj+ - ..\utils\echoto kernel.res entry.obj io.obj blockio.obj chario.obj dosfns.obj console.obj+ - ..\utils\echoto kernel.res printer.obj serial.obj dsk.obj initdisk.obj initclk.obj error.obj fatdir.obj fatfs.obj+ - ..\utils\echoto kernel.res fattab.obj fcbfns.obj initoem.obj initHMA.obj inthndlr.obj ioctl.obj nls_hc.obj+ - ..\utils\echoto kernel.res main.obj config.obj memmgr.obj misc.obj newstuff.obj nls.obj intr.obj+ - ..\utils\echoto kernel.res dosnames.obj prf.obj strings.obj network.obj sysclk.obj syspack.obj+ - ..\utils\echoto kernel.res systime.obj task.obj int2f.obj irqstack.obj apisupt.obj+ - ..\utils\echoto kernel.res asmsupt.obj execrh.obj nlssupt.obj procsupt.obj break.obj+ - ..\utils\echoto kernel.res dosidle.obj dyninit.obj lfnapi.obj - ..\utils\echoto kernel.res kernel.exe - ..\utils\echoto kernel.res kernel.map - ..\utils\echoto kernel.res ..\lib\libm.lib ..\lib\device.lib - -kernel.exe: kernel.res $(EXE_dependencies) $(LIBS) + $(ECHOTO) kernel.res $(OBJS1)+ + $(ECHOTO) kernel.res $(OBJS2)+ + $(ECHOTO) kernel.res $(OBJS3)+ + $(ECHOTO) kernel.res $(OBJS4)+ + $(ECHOTO) kernel.res $(OBJS5)+ + $(ECHOTO) kernel.res $(OBJS6)+ + $(ECHOTO) kernel.res $(OBJS7) + $(ECHOTO) kernel.res kernel.exe + $(ECHOTO) kernel.res kernel.map + $(ECHOTO) kernel.res $(LIBS) + +kernel.exe: kernel.res $(OBJS) $(LIBS) $(LINK) @kernel.res; # *Individual File Dependencies* @@ -211,7 +174,7 @@ nls.obj: nls.c $(HEADERS) $(CONFIGURATION) # \ # 001-437.nls -prf.obj: prf.c $(HDR)\portab.h $(CONFIGURATION) +prf.obj: prf.c $(HDR)portab.h $(CONFIGURATION) strings.obj: strings.c $(CONFIGURATION) @@ -258,6 +221,6 @@ initclk.obj: initclk.c $(INITHEADERS) $(HEADERS) $(CONFIGURATION) $(INITPATCH) $*.obj #the printf for INIT_TEXT - yet another special case, this file includes prf.c -iprf.obj: iprf.c prf.c $(HDR)\portab.h $(CONFIGURATION) +iprf.obj: iprf.c prf.c $(HDR)portab.h $(CONFIGURATION) $(CC) $(INITCFLAGS) $*.c $(INITPATCH) $*.obj diff --git a/lib/makefile b/lib/makefile index 0a08d75d..91e27928 100644 --- a/lib/makefile +++ b/lib/makefile @@ -5,7 +5,7 @@ # -!include "..\mkfiles\generic.mak" +!include "../mkfiles/generic.mak" libm.lib: $(CLIB) diff --git a/sys/makefile b/sys/makefile index b6199066..4fab1f2c 100644 --- a/sys/makefile +++ b/sys/makefile @@ -4,7 +4,7 @@ # $Id$ # -!include "..\mkfiles\generic.mak" +!include "../mkfiles/generic.mak" CFLAGS = -I$(INCLUDEPATH) -I..\hdr -DFORSYS -DWITHFAT32 $(CFLAGST) NASMFLAGS = -DSYS=1 From 6537b65c85bcd1a6229ccea5edfc7405ba7ec23c Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Mon, 15 Sep 2003 10:48:14 +0000 Subject: [PATCH 292/671] Remove duplicate clobber. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@689 6ac86273-5f31-0410-b378-82cca8765d1b --- clobber.bat | 1 - 1 file changed, 1 deletion(-) diff --git a/clobber.bat b/clobber.bat index 344a6601..4415c2ae 100644 --- a/clobber.bat +++ b/clobber.bat @@ -28,7 +28,6 @@ cd ..\boot cd ..\sys %MAKE% clobber -%MAKE% clobber cd ..\kernel %MAKE% clobber From 9914760949bf9af073176c13f040140a4396e7a6 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Mon, 15 Sep 2003 10:53:09 +0000 Subject: [PATCH 293/671] driver .asm files optimizations (many from Arkady); remove obsolete rdatclk git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@690 6ac86273-5f31-0410-b378-82cca8765d1b --- drivers/floppy.asm | 144 +++++++++++++++++++++----------------------- drivers/getvec.asm | 26 +++----- drivers/rdatclk.asm | 87 -------------------------- drivers/rdpcclk.asm | 10 +-- drivers/wrpcclk.asm | 9 ++- 5 files changed, 87 insertions(+), 189 deletions(-) delete mode 100644 drivers/rdatclk.asm diff --git a/drivers/floppy.asm b/drivers/floppy.asm index c1c6413d..45747f8e 100644 --- a/drivers/floppy.asm +++ b/drivers/floppy.asm @@ -45,16 +45,15 @@ global _fl_reset _fl_reset: - mov bx,sp - mov ah,0 ; BIOS reset disketter & fixed disk - mov dl,[bx+2] + pop ax ; return address + pop dx ; drive + push dx ; restore stack + push ax ; + mov ah,0 ; BIOS reset diskette & fixed disk int 13h - jc fl_rst1 ; cy==1 is error - mov ax,1 ; TRUE on success - ret - -fl_rst1: xor ax,ax ; FALSE on error + sbb ax,ax ; cy==1 is error + inc ax ; TRUE on success, FALSE on failure ret @@ -64,34 +63,30 @@ fl_rst1: xor ax,ax ; FALSE on error ; ; COUNT fl_diskchanged(WORD drive) ; -; returns 1 if disk has changed, 0 if not, 0xFF if error +; returns 1 if disk has changed, 0 if not, 0xFFFF if error ; global _fl_diskchanged _fl_diskchanged: - push bp ; C entry - mov bp,sp + pop ax ; return address + pop dx ; get the drive number + push dx ; restore stack + push ax ; - mov dl,[bp+4] ; get the drive number mov ah,16h ; read change status type int 13h - jc fl_dchanged1 ; cy==1 is error or disk has changed - xor ax,ax ; disk has not changed - pop bp ; C exit - ret + mov al,1 + jnc fl_dc_ret1 ; cy==1 is error or disk has changed -fl_dchanged1: cmp ah,6 - jne fl_dc_error - mov ax,1 - pop bp ; C exit - ret + cmp ah,6 ; ah=6: disk has changed + je fl_dc_ret + dec ax ; 0xFF on error -fl_dc_error: mov ax,0FFh ; 0xFF on error - pop bp ; C exit +fl_dc_ret1: dec ax +fl_dc_ret: cbw ret - ; ; Format Sectors ; @@ -140,37 +135,31 @@ fl_common: push bp ; C entry mov bp,sp - mov dl,[bp+4] ; get the drive (if or'ed 80h its - ; hard drive. - mov dh,[bp+6] ; get the head number - mov bx,[bp+8] ; cylinder number (lo only if hard) + mov cx,[bp+8] ; cylinder number (lo only if hard) mov al,1 ; this should be an error code - cmp bx,3ffh ; this code can't write above 3ff=1023 + cmp ch,3 ; this code can't write above 3ff=1023 ja fl_error - mov ch,bl ; low 8 bits of cyl number - - xor bl,bl ; extract bits 8+9 to cl - shr bx,1 - shr bx,1 - - - mov cl,[bp+0Ah] ; sector number - and cl,03fh ; mask to sector field bits 5-0 - or cl,bl ; or in bits 7-6 + xchg ch,cl ; ch=low 8 bits of cyl number + ror cl,1 ; extract bits 8+9 to cl + ror cl,1 + or cl,[bp+0Ah] ; or in the sector number (bits 0-5) mov al,[bp+0Ch] ; count to read/write les bx,[bp+0Eh] ; Load 32 bit buffer ptr + mov dl,[bp+4] ; get the drive (if or'ed 80h its + ; hard drive. + mov dh,[bp+6] ; get the head number + int 13h ; write sectors from mem es:bx - mov al,ah - jc fl_wr1 ; error, return error code - xor al,al ; Zero transfer count -fl_wr1: + sbb al,al ; carry: al=ff, else al=0 + and al,ah ; carry: error code, else 0 + ; (Zero transfer count) fl_error: - xor ah,ah ; force into < 255 count + mov ah,0 ; force into < 255 count pop bp ret @@ -187,21 +176,24 @@ _fl_lba_ReadWrite: push ds push si ; wasn't in kernel < KE2024Bo6!! - mov dl,[bp+4] ; get the drive (if or'ed 80h its + mov dl,[bp+4] ; get the drive (if ored 80h harddrive) mov ax,[bp+6] ; get the command lds si,[bp+8] ; get far dap pointer int 13h ; read from/write to drive - mov al,ah ; place any error code into al - - xor ah,ah ; zero out ah - pop si pop ds - + pop bp +ret_AH: + mov al,ah ; place any error code into al + mov ah,0 ; zero out ah ret +; +; void fl_readkey (void); +; + global _fl_readkey _fl_readkey: xor ah, ah int 16h @@ -209,50 +201,50 @@ _fl_readkey: xor ah, ah global _fl_setdisktype _fl_setdisktype: - push bp - mov bp, sp - mov dl,[bp+4] ; drive number - mov al,[bp+6] ; disk type + pop bx ; return address + pop dx ; drive number (dl) + pop ax ; disk type (al) + push ax ; restore stack + push dx + push bx mov ah,17h int 13h - mov al,ah - xor ah,ah - pop bp - ret + jmp short ret_AH +; +; COUNT fl_setmediatype (WORD drive, WORD tracks, WORD sectors); +; global _fl_setmediatype _fl_setmediatype: - push bp - mov bp, sp + pop ax ; return address + pop dx ; drive number + pop cx ; number of tracks + pop bx ; sectors/track + push bx ; restore stack + push cx + push dx + push ax push di - - mov dl,[bp+4] ; drive number - mov bx,[bp+6] ; number of tracks - dec bx ; should be highest track - mov ch,bl ; low 8 bits of cyl number + + dec cx ; should be highest track + xchg ch,cl ; low 8 bits of cyl number - xor bl,bl ; extract bits 8+9 to cl - shr bx,1 - shr bx,1 + ror cl,1 ; extract bits 8+9 to cl bit 6+7 + ror cl,1 - mov cl,[bp+8] ; sectors/track - and cl,03fh ; mask to sector field bits 5-0 or cl,bl ; or in bits 7-6 mov ah,18h int 13h - mov al,ah - mov ah,0 jc skipint1e - mov bx,es + push es xor dx,dx mov es,dx cli + pop word [es:0x1e*4+2] ; set int 0x1e table to es:di mov [es:0x1e*4 ], di - mov [es:0x1e*4+2], bx ; set int 0x1e table to es:di (bx:di) sti skipint1e: pop di - pop bp - ret + jmp short ret_AH diff --git a/drivers/getvec.asm b/drivers/getvec.asm index d53efc19..f7b65290 100644 --- a/drivers/getvec.asm +++ b/drivers/getvec.asm @@ -34,24 +34,14 @@ segment HMA_TEXT global _getvec _getvec: - mov bx,sp - mov ax,[ss:bx+2] - -; -; assembler version - ax = vector number -; returns vector in dx:ax -; - - global getvec -getvec: - shl ax,1 ; Multiply by 4 - shl ax,1 + pop ax ; return address + pop bx ; int # + push bx ; restore stack + push ax + add bx,bx + add bx,bx ; Multiply by 4 xor dx,dx ; and set segment to 0 mov es,dx - mov bx,ax - pushf ; Push flags - cli ; Disable interrupts - mov ax,[es:bx] - mov dx,[es:bx+2] - popf ; Pop flags + les ax,[es:bx] + mov dx,es ret diff --git a/drivers/rdatclk.asm b/drivers/rdatclk.asm deleted file mode 100644 index b5ca6a87..00000000 --- a/drivers/rdatclk.asm +++ /dev/null @@ -1,87 +0,0 @@ -; -; File: -; rdatclk.asm -; Description: -; read the AT style clock from bios -; -; Copyright (c) 1995 -; Pasquale J. Villani -; All Rights Reserved -; -; This file is part of DOS-C. -; -; DOS-C is free software; you can redistribute it and/or -; modify it under the terms of the GNU General Public License -; as published by the Free Software Foundation; either version -; 2, or (at your option) any later version. -; -; DOS-C is distributed in the hope that it will be useful, but -; WITHOUT ANY WARRANTY; without even the implied warranty of -; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See -; the GNU General Public License for more details. -; -; You should have received a copy of the GNU General Public -; License along with DOS-C; see the file COPYING. If not, -; write to the Free Software Foundation, 675 Mass Ave, -; Cambridge, MA 02139, USA. -; -; Logfile: C:/dos-c/src/drivers/rdatclk.asv -; -; $Header$ -; - - %include "../kernel/segs.inc" - -segment HMA_TEXT - -; -;COUNT ReadATClock(bcdDays, bcdHours, bcdMinutes, bcdSeconds) -;BYTE *bcdDays; -;BYTE *bcdHours; -;BYTE *bcdMinutes; -;BYTE *bcdSeconds; -; - global _ReadATClock -_ReadATClock: - push bp - mov bp, sp - xor cx, cx ; cx=dx=0 check if present - xor dx, dx ; if it returns non-zero - clc ; necessary according to RBIL - mov ah,4 - int 1ah - jc @RdATerror - - or cx, cx - jnz @RdAT1140 - or dx, dx - jnz @RdAT1140 -@RdATerror: mov ax, 1 - pop bp - ret -@RdAT1140: - clc - mov ah, 2 - int 1ah - jc @RdATerror -; bcdSeconds = 10 -; bcdMinutes = 8 -; bcdHours = 6 -; bcdDays = 4 - mov bx,word [bp+6] ;bcdHours - mov byte [bx],ch ;Hours - mov bx,word [bp+8] ;bcdMinutes - mov byte [bx],cl ;Minutes - mov bx,word [bp+10] ;bcdSeconds - mov byte [bx],dh ;Seconds - clc - mov ah,4 - int 1ah - jc @RdATerror - mov bx,word [bp+4] ;bcdDays - mov word [bx],dx ;Days - mov word [bx+2],cx - sub ax,ax - pop bp - ret - diff --git a/drivers/rdpcclk.asm b/drivers/rdpcclk.asm index 11e01b91..cc51fe70 100644 --- a/drivers/rdpcclk.asm +++ b/drivers/rdpcclk.asm @@ -38,17 +38,17 @@ segment HMA_TEXT ; global _ReadPCClock _ReadPCClock: - xor ah,ah + mov ah,0 int 1ah extern _DaysSinceEpoch ; ; update days if necessary - mov ah,0 - + ; (ah is still 0, al contains midnight flag) add word [_DaysSinceEpoch ],ax ; *some* BIOS's accumulate several days adc word [_DaysSinceEpoch+2],0 ; - mov ax,dx ; set return value - mov dx,cx + ; set return value dx:ax + xchg ax,cx ; ax=_cx, cx=_ax + xchg ax,dx ; dx=_cx, ax=_dx (cx=_ax) ret diff --git a/drivers/wrpcclk.asm b/drivers/wrpcclk.asm index 135be0ce..7c14456c 100644 --- a/drivers/wrpcclk.asm +++ b/drivers/wrpcclk.asm @@ -38,10 +38,13 @@ segment HMA_TEXT ; global _WritePCClock _WritePCClock: - mov bx,sp ; Ticks = 4 - mov cx,word [ss:bx+4] - mov dx,word [ss:bx+2] ;Ticks + pop ax ; return address + pop dx + pop cx ; Ticks + push cx ; restore stack + push dx + push ax mov ah,1 int 1ah ret From 7bcbfa999cd4c30ae227b9a88b285146a27fae90 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Mon, 15 Sep 2003 10:54:43 +0000 Subject: [PATCH 294/671] Add missing (); small optimization for DosGet date/time. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@691 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/inthndlr.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/kernel/inthndlr.c b/kernel/inthndlr.c index ea974139..2e85b9f3 100644 --- a/kernel/inthndlr.c +++ b/kernel/inthndlr.c @@ -407,7 +407,7 @@ VOID ASMCFUNC int21_service(iregs FAR * r) /* Check for Ctrl-Break */ if (break_ena || (lr.AH >= 1 && lr.AH <= 5) || (lr.AH >= 8 && lr.AH <= 0x0b)) - check_handle_break; + check_handle_break(); /* The dispatch handler */ switch (lr.AH) @@ -676,8 +676,7 @@ VOID ASMCFUNC int21_service(iregs FAR * r) /* Set Date */ case 0x2b: - rc = DosSetDate((struct dosdate *)&lr.CX); - lr.AL = (rc != SUCCESS ? 0xff : 0); + lr.AL = DosSetDate ((struct dosdate*)&lr.CX) == SUCCESS ? 0 : 0xFF; break; /* Get Time */ @@ -685,10 +684,9 @@ VOID ASMCFUNC int21_service(iregs FAR * r) DosGetTime((struct dostime *)&lr.CL); break; - /* Set Date */ + /* Set Time */ case 0x2d: - rc = DosSetTime((struct dostime *)&lr.CL); - lr.AL = (rc != SUCCESS ? 0xff : 0); + lr.AL = DosSetTime ((struct dostime*)&lr.CX) == SUCCESS ? 0 : 0xFF; break; /* Set verify flag */ From 81654429d7e5549973641566debb9ca926a5e399 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Mon, 15 Sep 2003 10:55:58 +0000 Subject: [PATCH 295/671] Small optimizations git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@692 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/chario.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/chario.c b/kernel/chario.c index 3263e4a0..12b2e193 100644 --- a/kernel/chario.c +++ b/kernel/chario.c @@ -241,7 +241,7 @@ STATIC int cooked_write_char(struct dhdr FAR **pdev, if (err < 0) return err; } - } while (--count > 0); + } while (--count != 0); return SUCCESS; } @@ -333,7 +333,7 @@ long cooked_read(struct dhdr FAR **pdev, size_t n, char FAR *bp) break; *bp++ = c; xfer++; - if (bp[-1] == CTL_Z) + if ((unsigned char)c == CTL_Z) break; } return xfer; From 7c241c59c6e30df0f5aff9707a8f6ec488fc5489 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Mon, 15 Sep 2003 21:08:22 +0000 Subject: [PATCH 296/671] Always use huge block sectors if the relevant bit is set in the device header. This solves a problem with xmsdsk. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@693 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/blockio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/blockio.c b/kernel/blockio.c index 66038fa5..61a20213 100644 --- a/kernel/blockio.c +++ b/kernel/blockio.c @@ -406,7 +406,7 @@ UWORD dskxfer(COUNT dsk, ULONG blkno, VOID FAR * buf, UWORD numblocks, IoReqHdr.r_status = 0; IoReqHdr.r_meddesc = dpbp->dpb_mdb; IoReqHdr.r_count = numblocks; - if (blkno >= MAXSHORT) + if ((dpbp->dpb_device->dh_attr & ATTR_HUGE) || blkno >= MAXSHORT) { IoReqHdr.r_start = HUGECOUNT; IoReqHdr.r_huge = blkno; From 2f4e2d3a69605a20e9c5ebe3fdbaaafde907010e Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Tue, 16 Sep 2003 12:38:02 +0000 Subject: [PATCH 297/671] * add support for the far jmp at "int 30" (0000:00c0) * mirror it for the HMA (ffff:00d0) * put all DOS int handler (and the CPM entry jumped to from int30) jumpers in the "CONST" portion of DGROUP (instead of LGROUP) This helps Turbo C++ 1.01 make with the -S (swap) switch. * adjustments to set the relevant PSP fields in task.c git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@694 6ac86273-5f31-0410-b378-82cca8765d1b --- hdr/portab.h | 4 ++++ hdr/process.h | 5 +++-- kernel/init-mod.h | 1 + kernel/inithma.c | 7 +++++++ kernel/kernel.asm | 16 +++++++++------- kernel/main.c | 2 ++ kernel/task.c | 31 ++++++++++++++++++------------- 7 files changed, 44 insertions(+), 22 deletions(-) diff --git a/hdr/portab.h b/hdr/portab.h index eecd53ae..ab72e183 100644 --- a/hdr/portab.h +++ b/hdr/portab.h @@ -226,8 +226,12 @@ typedef signed long LONG; #define pokeb(seg, ofs, b) (*((unsigned char far *)MK_FP(seg,ofs)) = b) #define poke(seg, ofs, w) (*((unsigned far *)MK_FP(seg,ofs)) = w) +#define pokew poke +#define pokel(seg, ofs, l) (*((unsigned long far *)MK_FP(seg,ofs)) = l) #define peekb(seg, ofs) (*((unsigned char far *)MK_FP(seg,ofs))) #define peek(seg, ofs) (*((unsigned far *)MK_FP(seg,ofs))) +#define peekw peek +#define peekl(seg, ofs) (*((unsigned long far *)MK_FP(seg,ofs))) #if defined(__TURBOC__) && (__TURBOC__ > 0x202) #define FP_SEG(fp) ((unsigned)(void _seg *)(void far *)(fp)) diff --git a/hdr/process.h b/hdr/process.h index 44f33cdf..2b654d7e 100644 --- a/hdr/process.h +++ b/hdr/process.h @@ -62,8 +62,9 @@ typedef struct { #define load ldata._load typedef struct { - UWORD ps_exit; /* 00 CP/M-like exit poimt */ - UWORD ps_size; /* 02 memory size in paragraphs */ + UWORD ps_exit; /* 00 CP/M-like exit point: int 20 */ + UWORD ps_size; /* 02 segment of first byte beyond */ + /* memory allocated to program */ BYTE ps_fill1; /* 04 single char fill */ /* CP/M-like entry point */ diff --git a/kernel/init-mod.h b/kernel/init-mod.h index 1f8d36cd..45fb1331 100644 --- a/kernel/init-mod.h +++ b/kernel/init-mod.h @@ -183,6 +183,7 @@ VOID ASMCFUNC FAR int28_handler(void); VOID ASMCFUNC FAR int29_handler(void); VOID ASMCFUNC FAR int2a_handler(void); VOID ASMCFUNC FAR int2f_handler(void); +VOID ASMCFUNC FAR cpm_entry(void); /* main.c */ VOID ASMCFUNC FreeDOSmain(void); diff --git a/kernel/inithma.c b/kernel/inithma.c index 5f50b6c4..73aef6eb 100644 --- a/kernel/inithma.c +++ b/kernel/inithma.c @@ -408,6 +408,13 @@ void MoveKernel(unsigned NewKernelSegment) rp->jmpSegment = NewKernelSegment; } + + if (NewKernelSegment == 0xffff) + { + /* jmp far cpm_entry (copy from 0:c0) */ + pokeb(0xffff, 0x30 * 4 + 0x10, 0xea); + pokel(0xffff, 0x30 * 4 + 0x11, (ULONG)cpm_entry); + } } CurrentKernelSegment = NewKernelSegment; diff --git a/kernel/kernel.asm b/kernel/kernel.asm index 216f5422..219760eb 100644 --- a/kernel/kernel.asm +++ b/kernel/kernel.asm @@ -718,6 +718,10 @@ begin_hma: times 20h db 0 db 0 +; to minimize relocations + global _DGROUP_ +_DGROUP_ dw DGROUP + %ifdef WATCOM ; 32 bit multiplication + division global __U4M @@ -728,6 +732,10 @@ __U4D: LDIVMODU %endif + resb 0xd0 - ($-begin_hma) + ; reserve space for far jump to cp/m routine + resb 5 + ;End of HMA segment segment HMA_TEXT_END global __HMATextEnd @@ -744,7 +752,7 @@ segment _STACK class=STACK stack -segment _LOWTEXT +segment CONST ; dummy interrupt return handlers global _int22_handler @@ -931,7 +939,6 @@ noNeedToDisable: iret -segment _LOWTEXT ; ; Default Int 24h handler -- always returns fail ; so we have not to relocate it (now) @@ -946,11 +953,6 @@ _int24_handler: mov al,FAIL ; this makes some things easier ; -; to minimize relocations -segment HMA_TEXT - global _DGROUP_ -_DGROUP_ dw DGROUP - segment _LOWTEXT global _TEXT_DGROUP _TEXT_DGROUP dw DGROUP diff --git a/kernel/main.c b/kernel/main.c index 7f49307e..669f2cc0 100644 --- a/kernel/main.c +++ b/kernel/main.c @@ -215,6 +215,8 @@ STATIC void init_kernel(void) setvec(0x28, int28_handler); setvec(0x2a, int2a_handler); setvec(0x2f, int2f_handler); + pokeb(0, 0x30 * 4, 0xea); + pokel(0, 0x30 * 4 + 1, (ULONG)cpm_entry); init_PSPSet(DOS_PSP); set_DTA(MK_FP(DOS_PSP, 0x80)); diff --git a/kernel/task.c b/kernel/task.c index 2039203a..8581645a 100644 --- a/kernel/task.c +++ b/kernel/task.c @@ -171,9 +171,9 @@ void new_psp(seg para, int psize) /* CP/M-like exit point */ p->ps_exit = 0x20cd; - /* CP/M-like entry point - jump to special entry */ - p->ps_farcall = 0xea; - p->ps_reentry = cpm_entry; + /* CP/M-like entry point - call far to special entry */ + p->ps_farcall = 0x9a; + p->ps_reentry = MK_FP(0, 0x30 * 4); /* unix style call - 0xcd 0x21 0xcb (int 21, retf) */ p->ps_unix[0] = 0xcd; p->ps_unix[1] = 0x21; @@ -470,21 +470,26 @@ COUNT DosComLoader(BYTE FAR * namep, exec_blk * exp, COUNT mode, COUNT fd) { UWORD fcbcode; - + psp FAR *p; + /* point to the PSP so we can build it */ setvec(0x22, MK_FP(user_r->CS, user_r->IP)); new_psp(mem, mem + asize); - + fcbcode = patchPSP(mem - 1, env, exp, namep); /* set asize to end of segment */ - if (asize < 0x1000) - asize = (asize << 4) - 2; - else - asize = 0xfffe; - /* TODO: worry about PSP+6: - CP/M compatibility--size of first segment for .COM files, - while preserving the far call */ - + if (asize > 0x1000) + asize = 0x1000; + if (asize < 0x11) + return DE_NOMEM; + asize -= 0x11; + /* CP/M compatibility--size of first segment for .COM files + while preserving the far call to 0:00c0 + + copy in HMA at ffff:00d0 */ + p = MK_FP(mem, 0); + p->ps_reentry = MK_FP(0xc - asize, asize << 4); + asize <<= 4; + asize += 0x10e; exp->exec.stack = MK_FP(mem, asize); exp->exec.start_addr = MK_FP(mem, 0x100); *((UWORD FAR *) MK_FP(mem, asize)) = (UWORD) 0; From c20f68e73d53ad3e87359d4581945a524e909df6 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Thu, 18 Sep 2003 20:54:21 +0000 Subject: [PATCH 298/671] Free memory if there is an error in the relocation table. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@695 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/task.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/kernel/task.c b/kernel/task.c index 8581645a..444ccbe4 100644 --- a/kernel/task.c +++ b/kernel/task.c @@ -693,6 +693,11 @@ COUNT DosExeLoader(BYTE FAR * namep, exec_blk * exp, COUNT mode, COUNT fd) if (DosRWSft (fd, sizeof(reloc), (VOID FAR *) & reloc[0], XFR_READ) != sizeof(reloc)) { + if (mode != OVERLAY) + { + DosMemFree(--mem); + DosMemFree(env); + } return DE_INVLDDATA; } if (mode == OVERLAY) From f489b1a1b12de6c73ebd3e224e7f31a1f3c9fee2 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Thu, 18 Sep 2003 20:55:41 +0000 Subject: [PATCH 299/671] Full screen config.sys menus (use MENUCOLOR=) git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@696 6ac86273-5f31-0410-b378-82cca8765d1b --- docs/config.txt | 46 +++++- kernel/config.c | 373 +++++++++++++++++++++++++++++++++++++++--------- 2 files changed, 346 insertions(+), 73 deletions(-) diff --git a/docs/config.txt b/docs/config.txt index 1fc7476a..3bd6b1ed 100644 --- a/docs/config.txt +++ b/docs/config.txt @@ -118,16 +118,58 @@ MENUDEFAULT=0,0 DEVICE=ATAPICDD.SYS /D:MSCD000 +Full Screen Menus (thanks to Rune Espeseth) +Use MENUCOLOR=foreground[,background] to obtain a full screen menu +where you can use the arrow keys. Example (note that box drawing +characters are used that look strange in other character sets): +REM *** This is the FreeDos Config.sys *** +REM *** executed before autoexec.bat *** +REM *** Set white foreground, red background *** +menucolor=7,4 +files=20 +buffers=20 -2002-11-28 - Tom Ehlert -2003-07-15 - Bernd Blaauw +REM *** The Menu *** +MENU +MENU ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ» +MENU º My Menu - FreeDOS rules! º +MENU ÌÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͹ +MENU º º +MENU º 1. Test with border º +MENU º º +MENU º 2. Another test... º +MENU º º +MENU º 3. Third choice º +MENU º º +MENU º 4. Fourth choice. º +MENU º º +MENU ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ +MENU + +MENUDEFAULT=1,10 ( configuration 1, wait 10 seconds) + +1? REM 1st choice +1? ECHO You selected menu #1 +2? REM 2nd choice +2? ECHO You selected menu #2 +3? REM 3rd choice +3? ECHO You selected menu #3 +4? REM 4th choice +4? ECHO You selected menu #4 + + + + +2002-11-28 - Tom Ehlert +2003-07-15 - Bernd Blaauw +2003-09-18 - Bart Oldeman \ No newline at end of file diff --git a/kernel/config.c b/kernel/config.c index 69dd64e1..51cb1f25 100644 --- a/kernel/config.c +++ b/kernel/config.c @@ -43,6 +43,94 @@ static BYTE *RcsId = #endif #define para2far(seg) ((mcb FAR *)MK_FP((seg), 0)) +/** + Menu selection bar struct: + x pos, ypos, string +*/ +#define MENULINEMAX 80 +#define MENULINESMAX 10 +struct MenuSelector +{ + int x; + int y; + BYTE bSelected; + BYTE Text[MENULINEMAX]; +}; + +/** Structure below holds the menu-strings */ +STATIC struct MenuSelector MenuStruct[MENULINESMAX] = +{ + {0,0,0,{""}}, + {0,0,0,{""}}, + {0,0,0,{""}}, + {0,0,0,{""}}, + {0,0,0,{""}}, + {0,0,0,{""}}, + {0,0,0,{""}}, + {0,0,0,{""}}, + {0,0,0,{""}}, + {0,0,0,{""}} +}; + +int nMenuLine=0; +BOOL MenuColor = -1; + +STATIC void WriteMenuLine(int MenuSelected) +{ + iregs r; + unsigned char attr = (unsigned char)MenuColor; + char *pText = MenuStruct[MenuSelected].Text; + size_t len = 0; + + if (pText[0] == 0) + return; + + do len++; while (pText[len]); + + if(MenuStruct[MenuSelected].bSelected==1) + attr = ((attr << 4) | (attr >> 4)); + + /* clear line */ + r.a.x = 0x0600; + r.b.b.h = attr; + r.c.b.l = r.d.b.l = MenuStruct[MenuSelected].x; + r.c.b.h = r.d.b.h = MenuStruct[MenuSelected].y; + r.d.b.l += len - 1; + init_call_intr(0x10, &r); + + /* set cursor position: */ + r.a.b.h = 0x02; + r.b.b.h = 0; + r.d.b.l = MenuStruct[MenuSelected].x; + r.d.b.h = MenuStruct[MenuSelected].y; + init_call_intr(0x10, &r); + + printf("%s", pText); +} + +/* Deselect the previously selected line */ +STATIC void DeselectLastLine(void) +{ + int i; + for (i = 0 ; i < MENULINESMAX; i++) + { + if (MenuStruct[i].bSelected == 1) + { + /* deselect it: */ + MenuStruct[i].bSelected = 0; + WriteMenuLine(i); + break; + } + } +} + +STATIC void SelectLine(int MenuSelected) +{ + DeselectLastLine(); /* clear previous selection */ + MenuStruct[MenuSelected].bSelected = 1; /* set selection flag for this one */ + WriteMenuLine(MenuSelected); +} + UWORD umb_start = 0, UMB_top = 0; UWORD ram_top = 0; /* How much ram in Kbytes */ @@ -97,6 +185,8 @@ BYTE MenuSelected = 0; UCOUNT MenuLine = 0; UCOUNT Menus = 0; +STATIC VOID CfgMenuColor(BYTE * pLine); + STATIC VOID Config_Buffers(BYTE * pLine); STATIC VOID sysScreenMode(BYTE * pLine); STATIC VOID sysVersion(BYTE * pLine); @@ -179,12 +269,14 @@ STATIC struct table commands[] = { /* first = switches! this one is special since it is asked for but also checked before F5/F8 */ {"SWITCHES", 0, CfgSwitches}, - + /* rem is never executed by locking out pass */ {"REM", 0, CfgIgnore}, {";", 0, CfgIgnore}, - {"MENUDEFAULT", 0, CfgMenuDefault}, + {"MENUCOLOR",0,CfgMenuColor}, + + {"MENUDEFAULT", 0, CfgMenuDefault}, {"MENU", 0, CfgMenu}, /* lines to print in pass 0 */ {"ECHO", 2, CfgMenu}, /* lines to print in pass 2 - install(high) */ {"EECHO", 2, CfgMenuEsc}, /* modified ECHO (ea) */ @@ -219,6 +311,23 @@ STATIC struct table commands[] = { {"", -1, CfgFailure} }; +/* RE function for menu. */ +int findend(BYTE * s) +{ + int nLen = 0; + /* 'marks' end if at least three spaces, 0, or newline is found. */ + while (*s && (*s != 0x0d || *s != 0x0a) ) + { + BYTE *p= skipwh(s); + /* ah, more than two whitespaces ? We're done here (hrmph!) */ + if((unsigned int)p - (unsigned int)s>=3) + break; + nLen++; + ++s; + } + return nLen; +} + BYTE *pLineStart = 0; BYTE HMAState = 0; @@ -606,22 +715,30 @@ VOID DoConfig(int pass) if (nPass == 0) /* pass 0 always executed (rem Menu prompt switches) */ { - (*(pEntry->func)) (pLine); + pEntry->func(pLine); continue; } else - { + { if (SkipLine(pLineStart)) /* F5/F8 processing */ continue; } if ((pEntry->func != CfgMenu) && (pEntry->func != CfgMenuEsc)) + { + /* compatibility "device foo.sys" */ + if (' ' != *pLine && '\t' != *pLine && '=' != *pLine) + { + CfgFailure(pLine); + continue; + } pLine = skipwh(pLine); + } + if ('=' == *pLine || pEntry->func == CfgMenu || pEntry->func == CfgMenuEsc) + pLine = skipwh(pLine+1); - if ('=' != *pLine && pEntry->func != CfgMenu && pEntry->func != CfgMenuEsc) - CfgFailure(pLine); - else /* YES. DO IT */ - (*(pEntry->func)) (skipwh(pLine + 1)); + /* YES. DO IT */ + pEntry->func(pLine); } close(nFileDesc); @@ -708,7 +825,7 @@ STATIC BOOL SkipLine(char *pLine) { SkipAllConfig = TRUE; } - if (key == 0x4200) /* F8 */ + else if (key == 0x4200) /* F8 */ { singleStep = TRUE; } @@ -725,7 +842,7 @@ STATIC BOOL SkipLine(char *pLine) /* 1?device=CDROM.SYS */ /* 12?device=OAKROM.SYS */ /* 123?device=EMM386.EXE NOEMS */ - if ( MenuLine != 0 && + if ( MenuLine != 0 && (MenuLine & (1 << MenuSelected)) == 0) return TRUE; @@ -807,35 +924,34 @@ STATIC void Config_Buffers(BYTE * pLine) (nBuffers < 0 ? nBuffers : max(Config.cfgBuffers, nBuffers)); } +/** + Set screen mode - rewritten to use init_call_intr() by RE / ICD +*/ STATIC VOID sysScreenMode(BYTE * pLine) { + iregs r; COUNT nMode; + COUNT nFunc = 0x11; /* Get the argument */ if (GetNumArg(pLine, &nMode) == (BYTE *) 0) return; - if ((nMode != 0x11) && (nMode != 0x12) && (nMode != 0x14)) - return; + if(nMode<0x10) + nFunc = 0; /* set lower screenmode */ + else if ((nMode != 0x11) && (nMode != 0x12) && (nMode != 0x14)) + return; /* do nothing; invalid screenmode */ /* Modes 0x11 (17) 28 lines 0x12 (18) 43/50 lines 0x14 (20) 25 lines */ -#if defined(__TURBOC__) - _AX = (0x11 << 8) + nMode; - _BL = 0; - __int__(0x10); -#elif defined(I86) - asm - { - mov al, byte ptr nMode; - mov ah, 0x11; - mov bl, 0; - int 0x10; - } -#endif + /* move cursor to pos 0,0: */ + r.a.b.h = nFunc; /* set videomode */ + r.a.b.l = nMode; + r.b.b.l = 0; + init_call_intr(0x10, &r); } STATIC VOID sysVersion(BYTE * pLine) @@ -982,13 +1098,8 @@ STATIC VOID CfgSwitchar(BYTE * pLine) STATIC VOID CfgSwitches(BYTE * pLine) { pLine = skipwh(pLine); - if (commands[0].pass == 0) { - /* compatibility "device foo.sys" */ - if ('=' != *pLine && ' ' != *pLine && '\t' != *pLine) - { - CfgFailure(pLine); - return; - } + if (*pLine == '=') + { pLine = skipwh(pLine + 1); } while (*pLine) @@ -1008,15 +1119,15 @@ STATIC VOID CfgSwitches(BYTE * pLine) break; case 'E': /* /E[[:]nnnn] Set the desired EBDA amount to move in bytes */ { /* Note that if there is no EBDA, this will have no effect */ - char *p; int n = 0; if (*++pLine == ':') pLine++; /* skip optional separator */ - if ((p = GetNumArg(pLine, &n)) == 0) { + if (!isnum(*pLine)) + { Config.ebda2move = 0; break; } - pLine = p - 1; /* p points past number */ + pLine = GetNumArg(pLine, &n) - 1; /* allowed values: [48..1024] bytes, multiples of 16 * e.g. AwardBIOS: 48, AMIBIOS: 1024 * (Phoenix, MRBIOS, Unicore = ????) @@ -1738,10 +1849,44 @@ STATIC VOID CfgIgnore(BYTE * pLine) */ +STATIC void ClearScreen(unsigned char attr); STATIC VOID CfgMenu(BYTE * pLine) { + int nLen; + BYTE *pNumber = pLine; + printf("%s\n",pLine); -} + if (MenuColor == -1) + return; + + pLine = skipwh(pLine); + + /* skip drawing characters in cp437, which is what we'll have + just after booting! */ + while ((unsigned char)*pLine >= 0xb0 && (unsigned char)*pLine < 0xe0) + pLine++; + + pLine = skipwh(pLine); /* skip more whitespaces... */ + + /* now I'm expecting a number here if this is a menu-choice line. */ + if (pLine[0]>='1' && pLine[0]<='9') + { + int nIndex = pLine[0]-'0'; + + MenuStruct[nIndex].x = (pLine-pNumber); /* xpos is at start of number */ + MenuStruct[nIndex].y = nMenuLine; + /* copy menu text: */ + nLen = findend(pLine); /* length is until cr/lf, null or three spaces */ + + /* max 40 chars including nullterminator + (change struct at top of file if you want more...) */ + if (nLen > MENULINEMAX-1) + nLen = MENULINEMAX-1; + fmemcpy(MenuStruct[nIndex].Text, pLine, nLen); + MenuStruct[nIndex].Text[nLen] = 0; /* nullTerminate */ + } + nMenuLine++; +} STATIC VOID CfgMenuEsc(BYTE * pLine) { @@ -1749,40 +1894,63 @@ STATIC VOID CfgMenuEsc(BYTE * pLine) for (check = pLine; check[0]; check++) if (check[0] == '$') check[0] = 27; /* translate $ to ESC */ printf("%s\n",pLine); -} +} STATIC VOID DoMenu(void) -{ +{ + iregs r; + int key = -1; if (Menus == 0) - return; - - InitKernelConfig.SkipConfigSeconds = -1; + return; + + InitKernelConfig.SkipConfigSeconds = -1; - Menus |= 1 << 0; /* '0' Menu always allowed */ + if (MenuColor == -1) + Menus |= 1 << 0; /* '0' Menu always allowed */ - printf("\n\n"); + nMenuLine+=2; /* use this to position "select menu" text (ypos): */ for (;;) { - int key,i; + int i; + +RestartInput: + + if (MenuColor != -1) + { + SelectLine(MenuSelected); /* select current line. */ + + /* set new cursor position: */ + r.a.b.h = 0x02; + r.b.b.h = 0; + r.d.b.l = 3; + r.d.b.h = nMenuLine; + + init_call_intr(0x10, &r); /* set cursor pos */ + } + + printf("Select from Menu ["); -RestartInput: - printf("\rSinglestepping (F8) is :%s - ", singleStep ? "ON " : "OFF"); - - printf("please select a Menu["); - for (i = 0; i <= 9; i++) if (Menus & (1 << i)) printf("%c", '0' + i); - printf("]"); - - printf(" (default=%d)", MenuSelected); - + printf("], or press [ENTER]"); + + if (MenuColor != -1) + printf(" (Selection=%d)", MenuSelected); + if (MenuTimeout >= 0) printf(" - %d \b", MenuTimeout); - else + else printf(" \b\b\b\b\b"); + if (MenuColor != -1) + printf("\r\n\n "); + else + printf(" -"); + + printf(" Singlestepping (F8) is: %s \r", singleStep ? "ON " : "OFF"); + key = GetBiosKey(MenuTimeout >= 0 ? 1 : -1); if (key == -1) /* timeout, take default */ @@ -1792,9 +1960,9 @@ STATIC VOID DoMenu(void) MenuTimeout--; goto RestartInput; } - break; - } - else + break; + } + else MenuTimeout = -1; if (key == 0x3f00) /* F5 */ @@ -1806,27 +1974,36 @@ STATIC VOID DoMenu(void) { singleStep = !singleStep; } - - key &= 0xff; - - if (key == '\r') /* CR - use default */ + else if(key == 0x4800 && MenuColor != -1) /* arrow up */ { - break; + if(MenuSelected>=0 && (Menus & (1 << (MenuSelected-1))) ) + { + MenuSelected--; + } } - if (key == 0x1b) /* ESC - use default */ + else if(key == 0x5000 && MenuColor != -1) /* arrow down */ { - break; - } - - printf("%c", key); - - if (key >= '0' && key <= '9') - if (Menus & (1 << (key - '0'))) + if(MenuSelected<10 && (Menus & (1 << (MenuSelected+1))) ) { - MenuSelected = key - '0'; break; + MenuSelected++; } + } + + key &= 0xff; + + if (key == '\r' || key == 0x1b) /* CR/ESC - use default */ + break; + + if (key >= '0' && key <= '9' && (Menus & (1 << (key - '0')))) + { + MenuSelected = key - '0'; + break; + } } printf("\n"); + + if (MenuColor != -1) + ClearScreen(0x7); } STATIC VOID CfgMenuDefault(BYTE * pLine) @@ -1853,6 +2030,60 @@ STATIC VOID CfgMenuDefault(BYTE * pLine) } } +STATIC void ClearScreen(unsigned char attr) +{ + /* scroll down (newlines): */ + iregs r; + unsigned char columns, rows; + + /* clear */ + r.a.x = 0x0600; + r.b.b.h = attr; + r.c.x = 0; + columns = peekb(0x40, 0x4a) - 1; + rows = peekb(0x40, 0x84); + if (rows == 0) rows = 24; + r.d.x = rows * 0x100 + columns; + init_call_intr(0x10, &r); + + /* move cursor to pos 0,0: */ + r.a.b.h = 0x02; /* set cursorpos */ + r.b.b.h = 0; /* displaypage: */ + r.d.x = 0; /* pos 0,0 */ + init_call_intr(0x10, &r); + MenuColor = attr; +} + +/** + MENUCOLOR[=] fg[, bg] +*/ +STATIC void CfgMenuColor(BYTE * pLine) +{ + int num = 0; + unsigned char fg, bg = 0; + + pLine = skipwh(pLine); + + if ('=' == *pLine) + pLine = skipwh(pLine + 1); + + pLine = GetNumArg(pLine, &num); + if (pLine == 0) + return; + fg = (unsigned char)num; + + pLine = skipwh(pLine); + + if (*pLine == ',') + { + pLine = GetNumArg(skipwh(pLine+1), &num); + if (pLine == 0) + return; + bg = (unsigned char)num; + } + ClearScreen((bg << 4) | fg); +} + /********************************************************************************* National specific things. this handles only Date/Time/Currency, and NOT codepage things. From d38750a53878689b63ea7cc75e946d0fbf4cab82 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Thu, 18 Sep 2003 20:57:53 +0000 Subject: [PATCH 300/671] From Michal Bakowski : Change the boot drive to always be C: if DLASortByDriveNo==1 git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@697 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/initdisk.c | 24 ++++++++++++++++++++++-- kernel/kernel.asm | 5 +++++ 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/kernel/initdisk.c b/kernel/initdisk.c index 02044666..923b4e6a 100644 --- a/kernel/initdisk.c +++ b/kernel/initdisk.c @@ -1333,12 +1333,32 @@ void ReadAllPartitionTables(void) } else { - printf("Drive Letter Assignment - sorted by drive\n"); + UBYTE bootdrv; + struct DriveParamS driveParam; + + /* printf("Drive Letter Assignment - sorted by drive\n"); */ /* Process primary partition table 1 partition only */ + bootdrv = *(UBYTE FAR *)MK_FP(0,0x5e0); for (HardDrive = 0; HardDrive < nHardDisk; HardDrive++) { - foundPartitions[HardDrive] = + memset(&driveParam, 0, sizeof(driveParam)); + ExtLBAForce = FALSE; + if (LBA_Get_Drive_Parameters(HardDrive, &driveParam)) + { + if (driveParam.driveno == bootdrv) + { + foundPartitions[HardDrive] = + ProcessDisk(SCAN_PRIMARYBOOT, HardDrive, 0); + break; + } + } + } + + for (HardDrive = 0; HardDrive < nHardDisk; HardDrive++) + { + if (foundPartitions[HardDrive] == 0) + foundPartitions[HardDrive] = ProcessDisk(SCAN_PRIMARYBOOT, HardDrive, 0); if (foundPartitions[HardDrive] == 0) diff --git a/kernel/kernel.asm b/kernel/kernel.asm index 219760eb..024968aa 100644 --- a/kernel/kernel.asm +++ b/kernel/kernel.asm @@ -158,6 +158,11 @@ cont: mov ax,cs int 010h popf pop bx + + xor ax,ax + mov es,ax + mov [es:0x5e0], bl ; store orig bootdrive:used by initdisk + pop ax inc bl From df99dd30071f0d27e17f36985d3f6e194c86f14c Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Thu, 18 Sep 2003 21:00:09 +0000 Subject: [PATCH 301/671] Use memcpy instead of fmemcpy; avoid downcasting from far to near. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@698 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/dsk.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/kernel/dsk.c b/kernel/dsk.c index 78aee3ae..d4167925 100644 --- a/kernel/dsk.c +++ b/kernel/dsk.c @@ -413,8 +413,8 @@ STATIC WORD getbpb(ddt * pddt) /*TE ~ 200 bytes*/ - fmemcpy(pbpbarray, &DiskTransferBuffer[BT_BPB], sizeof(bpb)); - + memcpy(pbpbarray, &DiskTransferBuffer[BT_BPB], sizeof(bpb)); + /*?? */ /* 2b is fat16 volume label. if memcmp, then offset 0x36. if (fstrncmp((BYTE *) & DiskTransferBuffer[0x36], "FAT16",5) == 0 || @@ -769,6 +769,7 @@ STATIC WORD blockio(rqptr rp, ddt * pddt) { ULONG start, size; WORD ret; + UWORD done; int action; bpb *pbpb; @@ -804,7 +805,8 @@ STATIC WORD blockio(rqptr rp, ddt * pddt) ret = LBA_Transfer(pddt, action, rp->r_trans, - start, rp->r_count, (UWORD *) & rp->r_count); + start, rp->r_count, &done); + rp->r_count = done; if (ret != 0) { From e5a93602af8880f19ebf8ed65dedf288ed2f8592 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Thu, 18 Sep 2003 21:37:39 +0000 Subject: [PATCH 302/671] Adjust version and history. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@699 6ac86273-5f31-0410-b378-82cca8765d1b --- docs/history.txt | 120 +++++++++++++++++++++++++++++++++++++++++++++++ hdr/version.h | 8 ++-- 2 files changed, 124 insertions(+), 4 deletions(-) diff --git a/docs/history.txt b/docs/history.txt index 1680e2dd..a864717f 100644 --- a/docs/history.txt +++ b/docs/history.txt @@ -1,3 +1,123 @@ +2003 Sep xx - Build 2032 +-------- Bart Oldeman (bart@dosemu.org) ++ Changes Rune Espeseth (modified by Bart) + * config.txt, config.c: Full screen config.sys menus (use MENUCOLOR=) ++ Changes Michal Bakowski (mb@orad.pl) + * initdisk.c, kernel.asm: Change the boot drive to always + be C: if DLASortByDriveNo==1 ++ Changes Arkady + * dsk.c: Use memcpy instead of fmemcpy; avoid downcasting + from far to near. + * sysclk.c: err if sizeof(struct ClockRecord) != rp->r_count + move year init below reading the BIOS + * main.c: init_device corrections/cleanups + * device.h: Change r_status and dh_name to unsigned quantities. + * task.c: Free memory if there is an error in the relocation + table. + * floppy.asm, getvec.asm, rdatclk.asm, rdpcclk.asm, wrpcclk.asm: + driver .asm files optimizations (also from Bart); remove + obsolete rdatclk. + * build.txt: Fix some typos. + * inthndlr.c: Add missing (); small optimization for DosGetdate/time. ++ Changes Lucho + * break.c: Fix ctrl-break bug. + * ioctl.c: IOCTL 4406 provided reverse AL output on regular + files - FF if EOF, 0 if not. It should output 0 if EOF, FF if not. + * initclk.c: Initclk changes + * config.c, init-mod.h, initoem.c: Support for + switches=/e[[:]nnnn] and for moving the EBDA + * fatfs.c: Use 0x10000UL (avoids Turbo C warning) + * sys.c: Move manually added "RCS" entries to the CVS log. + * main.c: Adjustments for MSVC. + * ioctl.c: int21/ax=440d lock/unlock logical/physical volume + simulate success for MS-DOS 7+ SCANDISK etc. --LG + * main.c: && should be || in check for \, / and : + * task.c: Adjust registers used when starting programs. Some + demos expect undocumented values (with Bart). + * mscl8.mak: Forgotten HMA_TEXT for MS compilers. + * sys.c: Add lock/unlock drive to SYS + * history.txt: Changelog correction. + * fatfs.c: Use near bpb on the stack in bpb_to_dpb. Make + sure the number of FAT sectors is actually enough to hold that + many clusters. Otherwise back the number of clusters down + * procsupt.asm, proto.h, task.c: Don't disable a20 for + "exit" int21/ah=4c ++ Changes Lucho, Tom, Eric + * boot.asm, boot32.asm, boot32lb.asm, makefiles, sys.c: + * boot.asm modified to support non-512 byte sectors + (e.g. 1.2 MB NEC diskettes) + * 512 byte sector size check removed (although Eric's boot32ea.asm + does require 512-byte sectors, all LBA FAT32 volumes have + 512-byte sectors anyway). + * boot.asm cleaned up and modified to support Metakern + bsDriveNumber updated by SYS even #ifndef STORE_BOOT_INFO + * (nothing in common) + * SYS Now supports and includes the following new boot sectors: + 1) the combined CHS+LBA FAT12/FAT16 boot sector by Tom Ehlert(29 July) + 2) the CHS-only FAT32 boot sector -- as patched by Jon Gentle(08 July) + 3) the LBA-only FAT32 boot sector by Eric Auer and Jon Gentle (19 July) + * The old combined (CHS+LBA), no-CALCPARAMS, no-resizable, non-Ghostable, + non-standard FAT32 boot sector and STORE_BOOT_INFO is no longer used. + * dump_sector() showed ASCII debug printout for the old sector + only - fixed. + * Put a boot sector only if sector size= 512 (may it not be so in + Japan?!). If non-512 byte sectors encountered, report to the + fd-kernel mailing list. + * Now puts boot sector before copying kernel/shell so it works in + WinNT now. + * check_space() now implemented at last (required significant + modifications) + * New (FAT type) detection method according to a MS White Paper. + * Now BOOTONLY works even without preceding boot sector image file name. + * Some minor code cleanups. + * Bart: some cleanups to the above; replaced 386 code for CHS FAT32 + by 8088 code. Use boot32lb.asm instead of boot32ea.asm ++ Changes Bart + * portab.h, process.h, init-mod.h, inithma.c, kernel.asm, main.c, task.c: + * add support for the far jmp at "int 30" (0000:00c0) + * mirror it for the HMA (ffff:00d0) + * put all DOS int handler (and the CPM entry jumped to from + int30) jumpers in the "CONST" portion of DGROUP (instead of + LGROUP) This helps Turbo C++ 1.01 make with the -S (swap) + switch. + * adjustments to set the relevant PSP fields in task.c + * blockio.c: Always use huge block sectors if the relevant bit is + set in the device header. This solves a problem with xmsdsk. + * chario.c: Small optimizations + * clobber.bat: Remove duplicate clobber. + * Flip some slashes for Linux compat and simplifications in makefiles + * device.h, portab.h: Use STATIC=static for watcom C (statics + are in the mapfile); remove some cruft. + * makefile, wlinker.bat: More verbose mapfiles for watcom + C; some slash preparations to allow cross-building on Linux + * exeflat.c, patchobj.c: Fix warnings reported by Turbo C + * break.c, chario.c, dosfns.c, globals.h, inthndlr.c, + proto.h, systime.c: (with a little help from Arkady) + Simplifications and cleanups. + Pass a near pointer to the far pointer that points to the device + instead of an SFT index (in general). + Make cooked_write much faster by only testing for input every 32 + characters. No longer test for ctl_s on syscon if writing to + the printer: just read from the printer which will return zero + characters. Fix reading/writing zero characters by returning + "256" (special code). Adjust interfaces in other files. + * portab.h: New UNREFERENCED_PARAMETER macro that appears to + work for all compilers. + * floppy.asm: Remove unused code. + * init-mod.h: Solve compilation problem with Borland C++ 3.1 + * config.b: "-p" is no longer necessary in config.bat + * kernel.asm: Add necessary "BootHardDiskSeconds" for non + UPXed kernels. + * chario.c, dosfns.c: Add necessary casts to ? : constructions; + cleanup read_line_handle a little. + * portab.h: Add peek and poke #defines + * chario.c: Fix pointer overflow problem for reading line using handle. + * makefiles, exeflat.c Clean cleans a bit more; change () to (void) + * main.c: Set the PSP before the DTA. This solves an interrupt + vector table corruption. + * kernel.asm: Use "local" (instead of "global") disable/enable + A20. This solves the problems with NIOS. + * asmsupt.asm, misc.c, proto.h, strings.c: Remove (unused) strncpy. 2003 Jul 19 - Build 2031 -------- Bart Oldeman (bart@dosemu.org) + Changes Luchezar Georgiev diff --git a/hdr/version.h b/hdr/version.h index cebf97f6..fd621da7 100644 --- a/hdr/version.h +++ b/hdr/version.h @@ -47,8 +47,8 @@ static BYTE *date_hRcsId = #define REVISION_MAJOR 1 #define REVISION_MINOR 1 -#define REVISION_SEQ 31 -#define BUILD "2031" +#define REVISION_SEQ 32 +#define BUILD "2032" #define SUB_BUILD "" -#define KERNEL_VERSION_STRING "1.1.31" /*#REVISION_MAJOR "." #REVISION_MINOR "." #REVISION_SEQ */ -#define KERNEL_BUILD_STRING "2031" /*#BUILD SUB_BUILD */ +#define KERNEL_VERSION_STRING "1.1.32" /*#REVISION_MAJOR "." #REVISION_MINOR "." #REVISION_SEQ */ +#define KERNEL_BUILD_STRING "2032" /*#BUILD SUB_BUILD */ From 2e45c870ebcfa65c481f687146ea594e22a96ae1 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Thu, 18 Sep 2003 21:40:29 +0000 Subject: [PATCH 303/671] Add boot32lb.asm git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@700 6ac86273-5f31-0410-b378-82cca8765d1b --- filelist | 1 + 1 file changed, 1 insertion(+) diff --git a/filelist b/filelist index 7cf5fde2..9f4f989b 100644 --- a/filelist +++ b/filelist @@ -11,6 +11,7 @@ */*/bin/install.bat */*/boot/boot.asm */*/boot/boot32.asm +*/*/boot/boot32lb.asm */*/boot/makefile */*/docs/bugs.txt */*/docs/build.txt From c4e02e86548fbbc9ab97de48d3cb04f7c87f4697 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Fri, 19 Sep 2003 02:13:35 +0000 Subject: [PATCH 304/671] Correct floppy booting; increase "menu space tolerance" from 3 to 10. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@701 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/config.c | 9 +++++---- kernel/kernel.asm | 10 +--------- kernel/main.c | 25 +++++++++++++------------ 3 files changed, 19 insertions(+), 25 deletions(-) diff --git a/kernel/config.c b/kernel/config.c index 51cb1f25..02e9b05f 100644 --- a/kernel/config.c +++ b/kernel/config.c @@ -315,12 +315,12 @@ STATIC struct table commands[] = { int findend(BYTE * s) { int nLen = 0; - /* 'marks' end if at least three spaces, 0, or newline is found. */ + /* 'marks' end if at least ten spaces, 0, or newline is found. */ while (*s && (*s != 0x0d || *s != 0x0a) ) { BYTE *p= skipwh(s); - /* ah, more than two whitespaces ? We're done here (hrmph!) */ - if((unsigned int)p - (unsigned int)s>=3) + /* ah, more than 9 whitespaces ? We're done here (hrmph!) */ + if(p - s >= 10) break; nLen++; ++s; @@ -1124,6 +1124,7 @@ STATIC VOID CfgSwitches(BYTE * pLine) pLine++; /* skip optional separator */ if (!isnum(*pLine)) { + pLine--; Config.ebda2move = 0; break; } @@ -1983,7 +1984,7 @@ STATIC VOID DoMenu(void) } else if(key == 0x5000 && MenuColor != -1) /* arrow down */ { - if(MenuSelected<10 && (Menus & (1 << (MenuSelected+1))) ) + if(MenuSelected= 0x80) - drv = 3; /* C: */ - LoL->BootDrive = drv; - - *(DWORD FAR *)MK_FP(0,0x5e0+2) = 0; - } + *(DWORD FAR *)MK_FP(0,0x5e0+2) = 0; + } else { + drv = LoL->BootDrive + 1; + *(UBYTE FAR *)MK_FP(0,0x5e0) = drv - 1; fmemcpy(&InitKernelConfig, &LowKernelConfig, sizeof(InitKernelConfig)); } - + + if (drv >= 0x80) + drv = 3; /* C: */ + LoL->BootDrive = drv; + setvec(0, int0_handler); /* zero divide */ setvec(1, empty_handler); /* single step */ setvec(3, empty_handler); /* debug breakpoint */ From c669f3644ce442e08906f09e005e5e07f68b2556 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sun, 21 Sep 2003 16:13:16 +0000 Subject: [PATCH 305/671] + Changes Lucho * boot.asm, boot32.asm, boot32lb.asm, sys.c: add metakern support: sys looks for a file metakern.sys which is a multiple of 512. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@702 6ac86273-5f31-0410-b378-82cca8765d1b --- boot/boot.asm | 5 ++--- boot/boot32.asm | 4 ++-- boot/boot32lb.asm | 13 ++++++------- sys/sys.c | 21 +++++++++++++++++---- 4 files changed, 27 insertions(+), 16 deletions(-) diff --git a/boot/boot.asm b/boot/boot.asm index 203fbc82..afe2473b 100644 --- a/boot/boot.asm +++ b/boot/boot.asm @@ -519,9 +519,8 @@ read_ok: pop si ret -filename db "KERNEL SYS" + times 0x01f1-$+$$ db 0 - - times 0x01fe-$+$$ db 0 +filename db "KERNEL SYS",0,0 sign dw 0xAA55 diff --git a/boot/boot32.asm b/boot/boot32.asm index b5bf2ea0..7dd46994 100644 --- a/boot/boot32.asm +++ b/boot/boot32.asm @@ -384,8 +384,8 @@ no_incr_es: adc dx,byte 0 ret -filename db "KERNEL SYS" + times 0x01f1-$+$$ db 0 - times 0x01fe-$+$$ db 0 +filename db "KERNEL SYS",0,0 sign dw 0xAA55 diff --git a/boot/boot32lb.asm b/boot/boot32lb.asm index 122d9fe3..2795f898 100644 --- a/boot/boot32lb.asm +++ b/boot/boot32lb.asm @@ -388,18 +388,17 @@ no_incr_es: pop di ;----------------------------------------------------------------------- msg_LoadFreeDOS db "Loading FreeDOS ",0 + +mystack dw 0x7c00 ; the 0 for SS overlaps into pad bytes! + ; (so we can LSS SP to 0:7c00) + + times 0x01ee-$+$$ db 0 + msg_BootError db "No " ; currently, only "kernel.sys not found" gives a message, ; but read errors in data or root or fat sectors do not. filename db "KERNEL SYS" -msg_BootErrorPart2: - db " ???",0 - - times 0x01fa-$+$$ db 0 - -mystack dw 0x7c00 ; the 0 for SS overlaps into sign! - ; (so we can LSS SP to 0:7c00) sign dw 0, 0xAA55 ; Win9x uses all 4 bytes as magic value here. diff --git a/sys/sys.c b/sys/sys.c index ab277161..a6dac599 100644 --- a/sys/sys.c +++ b/sys/sys.c @@ -29,7 +29,7 @@ #define DEBUG /* #define DDEBUG */ -#define SYS_VERSION "v2.7" +#define SYS_VERSION "v2.8" #include #include @@ -111,9 +111,10 @@ int write(int fd, const void *buf, unsigned count) int stat(const char *file_name, struct stat *buf) { struct find_t find_tbuf; - UNREFERENCED_PARAMETER(buf); - - return _dos_findfirst(file_name, _A_NORMAL | _A_HIDDEN | _A_SYSTEM, &find_tbuf); + int ret = _dos_findfirst(file_name, _A_NORMAL | _A_HIDDEN | _A_SYSTEM, &find_tbuf); + if (!ret) + buf->st_size = find_tbuf.size; + return ret; } /* WATCOM's getenv is case-insensitive which wastes a lot of space @@ -726,6 +727,18 @@ VOID put_boot(COUNT drive, BYTE * bsFile, BOOL both) printf("Root directory starts at sector (PREVIOUS + %u * %u)\n", bs->bsFATsecs, bs->bsFATs); #endif + { + struct stat sbuf; + static char metakern[] = "A:\\METAKERN.SYS"; + metakern[0] = drive + 'A'; + if (!stat(metakern, &sbuf) && sbuf.st_size && !(sbuf.st_size & SEC_SIZE-1)) + { + memcpy(&newboot[0x1f1], "METAKERNSYS", 11); +#ifdef DEBUG + printf("%s found - boot sector patched to load it!\n", metakern); +#endif + } + } #ifdef DDEBUG printf("\nNew Boot Sector:\n"); From d157b12ef030d347a4986a9b081e0bb92032ca77 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sun, 21 Sep 2003 16:14:23 +0000 Subject: [PATCH 306/671] Update LSM and history git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@703 6ac86273-5f31-0410-b378-82cca8765d1b --- docs/fdkernel.lsm | 4 ++-- docs/history.txt | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/docs/fdkernel.lsm b/docs/fdkernel.lsm index 039bec51..d55324f8 100644 --- a/docs/fdkernel.lsm +++ b/docs/fdkernel.lsm @@ -1,7 +1,7 @@ Begin3 Title: The FreeDOS Kernel -Version: 2.0.30 -Entered-date: 18 Jun 2003 +Version: 2.0.32 +Entered-date: 21 Sep 2003 Description: The FreeDOS Kernel. Keywords: kernel freedos dos msdos Author: (developers) diff --git a/docs/history.txt b/docs/history.txt index a864717f..499f61c2 100644 --- a/docs/history.txt +++ b/docs/history.txt @@ -1,4 +1,4 @@ -2003 Sep xx - Build 2032 +2003 Sep 21 - Build 2032 -------- Bart Oldeman (bart@dosemu.org) + Changes Rune Espeseth (modified by Bart) * config.txt, config.c: Full screen config.sys menus (use MENUCOLOR=) @@ -20,6 +20,8 @@ * build.txt: Fix some typos. * inthndlr.c: Add missing (); small optimization for DosGetdate/time. + Changes Lucho + * boot.asm, boot32.asm, boot32lb.asm, sys.c: add metakern support: + sys looks for a file metakern.sys which is a multiple of 512. * break.c: Fix ctrl-break bug. * ioctl.c: IOCTL 4406 provided reverse AL output on regular files - FF if EOF, 0 if not. It should output 0 if EOF, FF if not. From 22dd4265cfe979281eeb5e1b561313faab5b4aa1 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Mon, 22 Sep 2003 18:57:45 +0000 Subject: [PATCH 307/671] Fix problem with character map service. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@705 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/kernel.asm | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/kernel/kernel.asm b/kernel/kernel.asm index 0f75e151..106ac36e 100644 --- a/kernel/kernel.asm +++ b/kernel/kernel.asm @@ -659,10 +659,6 @@ blk_stk_top: times 64 dw 0 clk_stk_top: -; have a jump to the real thing here for AARD compliance - global _CharMapSrvc ; in _DATA (see AARD) -_CharMapSrvc: jmp 0x70:CharMapSrvc2 - ; Dynamic data: ; member of the DOS DATA GROUP ; and marks definitive end of all used data in kernel data segment @@ -829,9 +825,9 @@ _reloc_call_clk_driver: jmp 0:_clk_driver call near forceEnableA20 -; global _CharMapSrvc ; in _DATA (see AARD) + global _CharMapSrvc ; in _DATA (see AARD) extern _reloc_call_CharMapSrvc -CharMapSrvc2: jmp 0:_reloc_call_CharMapSrvc +_CharMapSrvc: jmp 0:_reloc_call_CharMapSrvc call near forceEnableA20 From a7a6a51adf81a8d7687526a7e10289849a570fea Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Tue, 23 Sep 2003 22:31:32 +0000 Subject: [PATCH 308/671] Improved option handling and a new generic /k option for sys. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@706 6ac86273-5f31-0410-b378-82cca8765d1b --- sys/sys.c | 138 ++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 92 insertions(+), 46 deletions(-) diff --git a/sys/sys.c b/sys/sys.c index a6dac599..09887887 100644 --- a/sys/sys.c +++ b/sys/sys.c @@ -29,7 +29,7 @@ #define DEBUG /* #define DDEBUG */ -#define SYS_VERSION "v2.8" +#define SYS_VERSION "v2.9" #include #include @@ -111,10 +111,9 @@ int write(int fd, const void *buf, unsigned count) int stat(const char *file_name, struct stat *buf) { struct find_t find_tbuf; - int ret = _dos_findfirst(file_name, _A_NORMAL | _A_HIDDEN | _A_SYSTEM, &find_tbuf); - if (!ret) - buf->st_size = find_tbuf.size; - return ret; + UNREFERENCED_PARAMETER(buf); + + return _dos_findfirst(file_name, _A_NORMAL | _A_HIDDEN | _A_SYSTEM, &find_tbuf); } /* WATCOM's getenv is case-insensitive which wastes a lot of space @@ -143,7 +142,7 @@ char *getenv(const char *name) BYTE pgm[] = "SYS"; -void put_boot(COUNT, BYTE *, BOOL); +void put_boot(int, char *, char *, int); BOOL check_space(COUNT, ULONG); BOOL copy(COUNT drive, BYTE * srcPath, BYTE * rootPath, BYTE * file); @@ -228,11 +227,16 @@ int main(int argc, char **argv) { COUNT drive; /* destination drive */ COUNT drivearg = 0; /* drive argument position */ + COUNT srcarg = 0; /* source argument position */ BYTE *bsFile = NULL; /* user specified destination boot sector */ unsigned srcDrive; /* source drive */ BYTE srcPath[SYS_MAXPATH]; /* user specified source drive and/or path */ BYTE rootPath[4]; /* alternate source path to try if not '\0' */ WORD slen; + int argno = 0; + int bootonly = 0; + int both = 0; + char *kernel_name = "KERNEL.SYS"; printf("FreeDOS System Installer " SYS_VERSION ", " __DATE__ "\n\n"); @@ -241,37 +245,55 @@ int main(int argc, char **argv) exit(FDKrnConfigMain(argc, argv)); } - srcPath[0] = '\0'; - if (argc > 1 && argv[1][1] == ':' && argv[1][2] == '\0') - drivearg = 1; - - if (argc > 2 && argv[2][1] == ':' && argv[2][2] == '\0') + for(argno = 1; argno < argc; argno++) { - drivearg = 2; - strncpy(srcPath, argv[1], SYS_MAXPATH - 12); - /* leave room for COMMAND.COM\0 */ - srcPath[SYS_MAXPATH - 13] = '\0'; - /* make sure srcPath + "file" is a valid path */ - slen = strlen(srcPath); - if ((srcPath[slen - 1] != ':') && - ((srcPath[slen - 1] != '\\') || (srcPath[slen - 1] != '/'))) + char *argp = argv[argno]; + + if (argp[1] == ':' && argp[2] == '\0' && drivearg <= srcarg) + drivearg = argno; + + if (srcarg == 0) { - srcPath[slen] = '\\'; - slen++; - srcPath[slen] = '\0'; + srcarg = argno; + } + else if (argp[0] == '/' && toupper(argp[1]) == 'K' && argno + 1 < argc) + { + argno++; + kernel_name = argv[argno]; + } + else if (memicmp(argp, "BOOTONLY", 8) == 0 && !bootonly) + { + bootonly = 1; + } + else if (memicmp(argp, "BOTH", 4) == 0 && !both) + { + both = 1; + } + else if (drivearg != argno) + { + if (bsFile == NULL) + { + bsFile = argp; + } + else + { + drivearg = 0; + break; + } } } if (drivearg == 0) { printf( - "Usage: %s [source] drive: [bootsect [BOTH]] [BOOTONLY]\n" + "Usage: %s [source] drive: [bootsect [BOTH]] [BOOTONLY] [/K name]\n" " source = A:,B:,C:\\KERNEL\\BIN\\,etc., or current directory if not given\n" " drive = A,B,etc.\n" " bootsect = name of 512-byte boot sector file image for drive:\n" " to write to *instead* of real boot sector\n" " BOTH : write to *both* the real boot sector and the image file\n" " BOOTONLY : do *not* copy kernel / shell, only update boot sector or image\n" + " /K name : name of kernel to use instead of KERNEL.SYS\n" "%s CONFIG /help\n", pgm, pgm); exit(1); } @@ -284,6 +306,23 @@ int main(int argc, char **argv) exit(1); } + srcPath[0] = '\0'; + if (drivearg > srcarg && srcarg) + { + strncpy(srcPath, argv[srcarg], SYS_MAXPATH - 12); + /* leave room for COMMAND.COM\0 */ + srcPath[SYS_MAXPATH - 13] = '\0'; + /* make sure srcPath + "file" is a valid path */ + slen = strlen(srcPath); + if ((srcPath[slen - 1] != ':') && + ((srcPath[slen - 1] != '\\') || (srcPath[slen - 1] != '/'))) + { + srcPath[slen] = '\\'; + slen++; + srcPath[slen] = '\0'; + } + } + /* Get source drive */ if ((strlen(srcPath) > 1) && (srcPath[1] == ':')) /* src specifies drive */ srcDrive = toupper(*srcPath) - 'A'; @@ -305,22 +344,15 @@ int main(int argc, char **argv) else sprintf(rootPath, "%c:\\", 'A' + srcDrive); - if (argc > drivearg + 1 && memicmp(argv[drivearg + 1], "BOOTONLY", 8) != 0) - bsFile = argv[drivearg + 1]; /* don't write to file "BOOTONLY" */ - printf("Processing boot sector...\n"); - put_boot(drive, bsFile, - (argc > drivearg + 2) - && memicmp(argv[drivearg + 2], "BOTH", 4) == 0); + put_boot(drive, bsFile, kernel_name, both); - if (argc <= drivearg + (bsFile ? 2 : 1) - || memicmp(argv[drivearg + (bsFile ? 2 : 1)], "BOOTONLY", 8) != 0 - && memicmp(argv[drivearg + (bsFile ? 3 : 2)], "BOOTONLY", 8) != 0) + if (!bootonly) { - printf("\nCopying KERNEL.SYS...\n"); - if (!copy(drive, srcPath, rootPath, "KERNEL.SYS")) + printf("\nCopying %s...\n", kernel_name); + if (!copy(drive, srcPath, rootPath, kernel_name)) { - printf("\n%s: cannot copy \"KERNEL.SYS\"\n", pgm); + printf("\n%s: cannot copy \"%s\"\n", pgm, kernel_name); exit(1); } /* copy kernel */ @@ -336,11 +368,11 @@ int main(int argc, char **argv) } if (comspec == NULL) { - printf("\n%s: cannot copy \"COMMAND.COM\"\n", pgm); + printf("\n%s: cannot copy \"COMMAND.COM\"\n", pgm); exit(1); } } /* copy shell */ - } + } printf("\nSystem transferred.\n"); return 0; @@ -613,7 +645,7 @@ BOOL haveLBA(void) } #endif -VOID put_boot(COUNT drive, BYTE * bsFile, BOOL both) +void put_boot(int drive, char *bsFile, char *kernel_name, int both) { #ifdef WITHFAT32 struct bootsectortype32 *bs32; @@ -728,18 +760,32 @@ VOID put_boot(COUNT drive, BYTE * bsFile, BOOL both) bs->bsFATsecs, bs->bsFATs); #endif { - struct stat sbuf; - static char metakern[] = "A:\\METAKERN.SYS"; - metakern[0] = drive + 'A'; - if (!stat(metakern, &sbuf) && sbuf.st_size && !(sbuf.st_size & SEC_SIZE-1)) + int i = 0; + memset(&newboot[0x1f1], ' ', 11); + while (kernel_name[i] && kernel_name[i] != '.') { - memcpy(&newboot[0x1f1], "METAKERNSYS", 11); -#ifdef DEBUG - printf("%s found - boot sector patched to load it!\n", metakern); -#endif + if (i < 8) + newboot[0x1f1+i] = toupper(kernel_name[i]); + i++; + } + if (kernel_name[i] == '.') + { + /* copy extension */ + int j = 0; + i++; + while (kernel_name[i+j] && j < 3) + { + newboot[0x1f9+j] = toupper(kernel_name[i+j]); + j++; + } } } +#ifdef DEBUG + /* there's a zero past the kernel name in all boot sectors */ + printf("Boot sector kernel name set to %s\n", &newboot[0x1f1]); +#endif + #ifdef DDEBUG printf("\nNew Boot Sector:\n"); dump_sector(newboot); From 9fd4a67e1dfcb1eb7eff506d4bf5c786a3f55844 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Tue, 23 Sep 2003 22:33:45 +0000 Subject: [PATCH 309/671] Correct segment for int21_handler to call for ctrl-c. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@707 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/procsupt.asm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/procsupt.asm b/kernel/procsupt.asm index 01fedc4f..10392384 100644 --- a/kernel/procsupt.asm +++ b/kernel/procsupt.asm @@ -34,7 +34,7 @@ extern _user_r:wrt DGROUP extern _break_flg:wrt DGROUP ; break detected flag - extern _int21_handler:wrt LGROUP ; far call system services + extern _int21_handler:wrt DGROUP ; far call system services %include "stacks.inc" From 6df5c0be61883453487e46178bf0818d2496214c Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Wed, 24 Sep 2003 18:53:44 +0000 Subject: [PATCH 310/671] Fix problem with loading multiple device drivers in one file: the segment part in the header must be ignored. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@708 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/config.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/kernel/config.c b/kernel/config.c index 02e9b05f..2c06d25b 100644 --- a/kernel/config.c +++ b/kernel/config.c @@ -1389,15 +1389,7 @@ STATIC BOOL LoadDevice(BYTE * pLine, char FAR *top, COUNT mode) (result = init_device(dhp, szBuf, mode, top)) == SUCCESS; dhp = next_dhp) { - next_dhp = dhp->dh_next; - if (FP_SEG(next_dhp) == 0xffff) - /* Does this ever occur with FP_OFF(next_dhp) != 0xffff ??? */ - next_dhp = MK_FP(FP_SEG(dhp), FP_OFF(next_dhp)); -#ifdef DEBUG - else if (FP_OFF(next_dhp) != 0xffff) /* end of internal chain */ - printf("multisegmented device driver found, next %p\n", next_dhp); - /* give warning message */ -#endif + next_dhp = MK_FP(FP_SEG(dhp), FP_OFF(dhp->dh_next)); /* Link in device driver and save LoL->nul_dev pointer to next */ dhp->dh_next = LoL->nul_dev.dh_next; LoL->nul_dev.dh_next = dhp; From bdc55699959077d444f27d16cf37933fcff6eaf7 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Wed, 24 Sep 2003 19:34:11 +0000 Subject: [PATCH 311/671] Set the Critical Error number immediately after calling a device driver. This solves problems with int24 handlers that call int21/ah=59. Let truename and blockrw return with an error if there is a critical error. Don't overwrite the critical error # with the DOS error #. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@709 6ac86273-5f31-0410-b378-82cca8765d1b --- hdr/device.h | 2 +- kernel/blockio.c | 2 +- kernel/dosfns.c | 5 +++-- kernel/error.c | 8 ++++++-- kernel/fatfs.c | 8 ++++---- kernel/inthndlr.c | 24 ++++++++++++------------ kernel/newstuff.c | 3 ++- kernel/proto.h | 2 +- 8 files changed, 30 insertions(+), 24 deletions(-) diff --git a/hdr/device.h b/hdr/device.h index 53167d75..156a7372 100644 --- a/hdr/device.h +++ b/hdr/device.h @@ -462,7 +462,7 @@ ddt * getddt(int dev); /* error.c */ COUNT char_error(request * rq, struct dhdr FAR * lpDevice); -COUNT block_error(request * rq, COUNT nDrive, struct dhdr FAR * lpDevice); +COUNT block_error(request * rq, COUNT nDrive, struct dhdr FAR * lpDevice, int mode); /* sysclk.c */ WORD ASMCFUNC FAR clk_driver(rqptr rp); diff --git a/kernel/blockio.c b/kernel/blockio.c index 61a20213..2f0bec7d 100644 --- a/kernel/blockio.c +++ b/kernel/blockio.c @@ -446,7 +446,7 @@ UWORD dskxfer(COUNT dsk, ULONG blkno, VOID FAR * buf, UWORD numblocks, return (IoReqHdr.r_status); loop: - switch (block_error(&IoReqHdr, dpbp->dpb_unit, dpbp->dpb_device)) + switch (block_error(&IoReqHdr, dpbp->dpb_unit, dpbp->dpb_device, mode)) { case ABORT: case FAIL: diff --git a/kernel/dosfns.c b/kernel/dosfns.c index 632903d7..bca962aa 100644 --- a/kernel/dosfns.c +++ b/kernel/dosfns.c @@ -306,8 +306,9 @@ long DosRWSft(int sft_idx, size_t n, void FAR * bp, int mode) } /* /// End of additions for SHARE - Ron Cemer */ { - UCOUNT XferCount; - XferCount = rwblock(s->sft_status, bp, n, mode); + long XferCount = rwblock(s->sft_status, bp, n, mode); + if (XferCount < 0) + return XferCount; if (mode == XFR_WRITE) s->sft_size = dos_getfsize(s->sft_status); s->sft_posit += XferCount; diff --git a/kernel/error.c b/kernel/error.c index 89c8d9d6..84332fda 100644 --- a/kernel/error.c +++ b/kernel/error.c @@ -78,14 +78,18 @@ VOID fatal(BYTE * err_msg) /* Abort, retry or fail for character devices */ COUNT char_error(request * rq, struct dhdr FAR * lpDevice) { + CritErrCode = (rq->r_status & S_MASK) + 0x13; return CriticalError(EFLG_CHAR | EFLG_ABORT | EFLG_RETRY | EFLG_IGNORE, 0, rq->r_status & S_MASK, lpDevice); } /* Abort, retry or fail for block devices */ -COUNT block_error(request * rq, COUNT nDrive, struct dhdr FAR * lpDevice) +COUNT block_error(request * rq, COUNT nDrive, struct dhdr FAR * lpDevice, + int mode) { - return CriticalError(EFLG_ABORT | EFLG_RETRY | EFLG_IGNORE, + CritErrCode = (rq->r_status & S_MASK) + 0x13; + return CriticalError(EFLG_ABORT | EFLG_RETRY | EFLG_IGNORE | + (mode == DSKWRITE ? EFLG_WRITE : 0), nDrive, rq->r_status & S_MASK, lpDevice); } diff --git a/kernel/fatfs.c b/kernel/fatfs.c index a72d0dba..63eb082f 100644 --- a/kernel/fatfs.c +++ b/kernel/fatfs.c @@ -1537,7 +1537,7 @@ STATIC COUNT dos_extend(f_node_ptr fnp) /* Read/write block from disk */ /* checking for valid access was already done by the functions in dosfns.c */ -UCOUNT rwblock(COUNT fd, VOID FAR * buffer, UCOUNT count, int mode) +long rwblock(COUNT fd, VOID FAR * buffer, UCOUNT count, int mode) { REG f_node_ptr fnp; REG struct buffer FAR *bp; @@ -1714,7 +1714,7 @@ UCOUNT rwblock(COUNT fd, VOID FAR * buffer, UCOUNT count, int mode) mode == XFR_READ ? DSKREAD : DSKWRITE)) { fnp->f_offset = startoffset; - return ret_cnt; + return DE_ACCESS; } goto update_pointers; @@ -2080,7 +2080,7 @@ COUNT media_check(REG struct dpb FAR * dpbp) || !(MediaReqHdr.r_status & S_DONE)) { loop1: - switch (block_error(&MediaReqHdr, dpbp->dpb_unit, dpbp->dpb_device)) + switch (block_error(&MediaReqHdr, dpbp->dpb_unit, dpbp->dpb_device, 0)) { case ABORT: case FAIL: @@ -2129,7 +2129,7 @@ COUNT media_check(REG struct dpb FAR * dpbp) { loop2: switch (block_error - (&MediaReqHdr, dpbp->dpb_unit, dpbp->dpb_device)) + (&MediaReqHdr, dpbp->dpb_unit, dpbp->dpb_device, 0)) { case ABORT: case FAIL: diff --git a/kernel/inthndlr.c b/kernel/inthndlr.c index 2e85b9f3..7bc37afd 100644 --- a/kernel/inthndlr.c +++ b/kernel/inthndlr.c @@ -400,8 +400,14 @@ VOID ASMCFUNC int21_service(iregs FAR * r) } #endif - if ((lr.AH >= 0x38 && lr.AH <= 0x4F) || (lr.AH >= 0x56 && lr.AH <= 0x5c)) + if ((lr.AH >= 0x38 && lr.AH <= 0x4F) || (lr.AH >= 0x56 && lr.AH <= 0x5c) || + (lr.AH >= 0x5e && lr.AH <= 0x60) || (lr.AH >= 0x65 && lr.AH <= 0x6a) || + lr.AH == 0x6c) + { CLEAR_CARRY_FLAG(); + if (lr.AH != 0x59) + CritErrCode = SUCCESS; + } /* Clear carry by default for these functions */ @@ -1328,12 +1334,12 @@ VOID ASMCFUNC int21_service(iregs FAR * r) CLEAR_CARRY_FLAG(); break; default: + CritErrCode = SUCCESS; goto error_invalid; } break; case 0x5e: - CLEAR_CARRY_FLAG(); switch (lr.AL) { case 0x00: @@ -1355,7 +1361,6 @@ VOID ASMCFUNC int21_service(iregs FAR * r) break; case 0x5f: - CLEAR_CARRY_FLAG(); if (lr.AL == 7 || lr.AL == 8) { struct cds FAR *cdsp; @@ -1400,7 +1405,6 @@ VOID ASMCFUNC int21_service(iregs FAR * r) break; case 0x60: /* TRUENAME */ - CLEAR_CARRY_FLAG(); if ((rc = DosTruename(MK_FP(lr.DS, lr.SI), adjust_far(FP_ES_DI))) < SUCCESS) goto error_exit; break; @@ -1490,12 +1494,10 @@ VOID ASMCFUNC int21_service(iregs FAR * r) break; } - CLEAR_CARRY_FLAG(); break; /* Code Page functions */ case 0x66: - CLEAR_CARRY_FLAG(); switch (lr.AL) { case 1: @@ -1514,7 +1516,6 @@ VOID ASMCFUNC int21_service(iregs FAR * r) /* Set Max file handle count */ case 0x67: - CLEAR_CARRY_FLAG(); if ((rc = SetJFTSize(lr.BX)) != SUCCESS) goto error_exit; break; @@ -1522,14 +1523,12 @@ VOID ASMCFUNC int21_service(iregs FAR * r) /* Flush file buffer -- COMMIT FILE. */ case 0x68: case 0x6a: - CLEAR_CARRY_FLAG(); if ((rc = DosCommit(lr.BX)) < 0) goto error_exit; break; /* Get/Set Serial Number */ case 0x69: - CLEAR_CARRY_FLAG(); rc = (lr.BL == 0 ? default_drive : lr.BL - 1); if (lr.AL == 0 || lr.AL == 1) { @@ -1560,8 +1559,7 @@ VOID ASMCFUNC int21_service(iregs FAR * r) case 0x6c: { long lrc; - CLEAR_CARRY_FLAG(); - + if (lr.AL != 0 || (lr.DL & 0x0f) > 0x2 || (lr.DL & 0xf0) > 0x10) goto error_invalid; @@ -1588,6 +1586,7 @@ VOID ASMCFUNC int21_service(iregs FAR * r) /* DOS 7.0+ FAT32 extended functions */ case 0x73: CLEAR_CARRY_FLAG(); + CritErrCode = SUCCESS; rc = int21_fat32(&lr); if (rc != SUCCESS) goto error_exit; @@ -1640,7 +1639,8 @@ VOID ASMCFUNC int21_service(iregs FAR * r) rc = DE_INVLDFUNC; error_exit: lr.AX = -rc; - CritErrCode = lr.AX; /* Maybe set */ + if (CritErrCode == SUCCESS) + CritErrCode = lr.AX; /* Maybe set */ error_carry: SET_CARRY_FLAG(); exit_dispatch: diff --git a/kernel/newstuff.c b/kernel/newstuff.c index 73f26ffc..6cd7d4aa 100644 --- a/kernel/newstuff.c +++ b/kernel/newstuff.c @@ -449,7 +449,8 @@ COUNT truename(const char FAR * src, char * dest, COUNT mode) *p = '\\'; /* force backslash! */ } p++; - DosGetCuDir((UBYTE)((result & 0x1f) + 1), p); + if (DosGetCuDir((UBYTE)((result & 0x1f) + 1), p) < 0) + return DE_PATHNOTFND; if (*src != '\\' && *src != '/') p += strlen(p); else /* skip the absolute path marker */ diff --git a/kernel/proto.h b/kernel/proto.h index 3999f1a3..cefd177f 100644 --- a/kernel/proto.h +++ b/kernel/proto.h @@ -162,7 +162,7 @@ BOOL dos_setfsize(COUNT fd, LONG size); COUNT dos_mkdir(BYTE * dir); BOOL last_link(f_node_ptr fnp); COUNT map_cluster(REG f_node_ptr fnp, COUNT mode); -UCOUNT rwblock(COUNT fd, VOID FAR * buffer, UCOUNT count, int mode); +long rwblock(COUNT fd, VOID FAR * buffer, UCOUNT count, int mode); COUNT dos_read(COUNT fd, VOID FAR * buffer, UCOUNT count); COUNT dos_write(COUNT fd, const VOID FAR * buffer, UCOUNT count); LONG dos_lseek(COUNT fd, LONG foffset, COUNT origin); From 20299d364211fa4ed4c55ede0f4700bb6b9a2979 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Wed, 24 Sep 2003 20:47:04 +0000 Subject: [PATCH 312/671] Bump up version number; update changelog. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@710 6ac86273-5f31-0410-b378-82cca8765d1b --- docs/fdkernel.lsm | 4 ++-- docs/history.txt | 13 +++++++++++++ hdr/version.h | 6 +++--- 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/docs/fdkernel.lsm b/docs/fdkernel.lsm index d55324f8..67888046 100644 --- a/docs/fdkernel.lsm +++ b/docs/fdkernel.lsm @@ -1,7 +1,7 @@ Begin3 Title: The FreeDOS Kernel -Version: 2.0.32 -Entered-date: 21 Sep 2003 +Version: 2.0.32a +Entered-date: 24 Sep 2003 Description: The FreeDOS Kernel. Keywords: kernel freedos dos msdos Author: (developers) diff --git a/docs/history.txt b/docs/history.txt index 499f61c2..8406be74 100644 --- a/docs/history.txt +++ b/docs/history.txt @@ -1,3 +1,16 @@ +2003 Sep 24 - Build 2032a +-------- Bart Oldeman (bart@dosemu.org) ++ Changes Bart + * fix segment problems with ctrl-c and character uppercase + handlers + * fix critical error callers to set the critical error code + immediately before calling the handler (in case they call + DOS-59); don't set the critical error in inthndlr.c if + something else already did. Return with an errorcode if + "truename" and "read"/"write" encountered a critical error. + * sys.c: add /k kernname.sys option to and straighten out SYS option + processing; remove the metakern magic. + * config.c: ignore the segment part for multi-part device drivers 2003 Sep 21 - Build 2032 -------- Bart Oldeman (bart@dosemu.org) + Changes Rune Espeseth (modified by Bart) diff --git a/hdr/version.h b/hdr/version.h index fd621da7..c8d9c43e 100644 --- a/hdr/version.h +++ b/hdr/version.h @@ -49,6 +49,6 @@ static BYTE *date_hRcsId = #define REVISION_MINOR 1 #define REVISION_SEQ 32 #define BUILD "2032" -#define SUB_BUILD "" -#define KERNEL_VERSION_STRING "1.1.32" /*#REVISION_MAJOR "." #REVISION_MINOR "." #REVISION_SEQ */ -#define KERNEL_BUILD_STRING "2032" /*#BUILD SUB_BUILD */ +#define SUB_BUILD "a" +#define KERNEL_VERSION_STRING "1.1.32a" /*#REVISION_MAJOR "." #REVISION_MINOR "." #REVISION_SEQ */ +#define KERNEL_BUILD_STRING "2032a" /*#BUILD SUB_BUILD */ From 5f6d47797ec5c410fb34b480bfe4fb66d87ee9b1 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Fri, 3 Oct 2003 13:50:38 +0000 Subject: [PATCH 313/671] Fix problem with FAT12 git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@711 6ac86273-5f31-0410-b378-82cca8765d1b --- boot/boot.asm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/boot/boot.asm b/boot/boot.asm index afe2473b..84829336 100644 --- a/boot/boot.asm +++ b/boot/boot.asm @@ -308,7 +308,8 @@ fat_12: add si, si ; multiply cluster number by 3... ; the number was odd, CF was set in the last shift instruction. jnc fat_even - div word[LBA_PACKET]; luckily 16 !! -- divide the cluster number + mov cl, 4 + shr ax, cl fat_even: and ah, 0x0f ; mask off the highest 4 bits cmp ax, 0x0ff8 ; check for EOF @@ -449,7 +450,7 @@ read_next: read_normal_BIOS: ;******************** END OF LBA_READ ************************ - mov ax,LBA_SECTOR_0 + mov cx,LBA_SECTOR_0 mov dx,LBA_SECTOR_16 @@ -462,7 +463,6 @@ read_normal_BIOS: ; + head * sectPerTrack offset in cylinder ; + track * sectPerTrack * nHeads offset in platter ; - xchg ax, cx mov al, [sectPerTrack] mul byte [nHeads] xchg ax, cx From 3fa044c14946576e71a7f4a35168593d5bbb731e Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sun, 5 Oct 2003 13:30:47 +0000 Subject: [PATCH 314/671] Implement support for int2f/ax=1220. Fix int2f/ax=1216 (needs sft handles, not psp handles, and to return the relative handle in BX, and to deal with carry) git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@712 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/dosfns.c | 32 +++++++++++++++++++------------- kernel/inthndlr.c | 41 ++++++++++++++++++++++++++++++++++------- kernel/proto.h | 1 + 3 files changed, 54 insertions(+), 20 deletions(-) diff --git a/kernel/dosfns.c b/kernel/dosfns.c index bca962aa..152cfd3d 100644 --- a/kernel/dosfns.c +++ b/kernel/dosfns.c @@ -143,35 +143,41 @@ STATIC VOID DosGetFile(BYTE * lpszPath, BYTE FAR * lpszDosFileName) fmemcpy(lpszDosFileName, fcbname, FNAME_SIZE + FEXT_SIZE); } -sft FAR * idx_to_sft(int SftIndex) +int idx_to_sft_(int SftIndex) { + /*called from below and int2f/ax=1216*/ sfttbl FAR *sp; + lpCurSft = (sft FAR *) - 1; if (SftIndex < 0) - return (sft FAR *) - 1; + return -1; /* Get the SFT block that contains the SFT */ for (sp = sfthead; sp != (sfttbl FAR *) - 1; sp = sp->sftt_next) { if (SftIndex < sp->sftt_count) { - lpCurSft = (sft FAR *) & (sp->sftt_table[SftIndex]); - - /* if not opened, the SFT is useless */ - if (lpCurSft->sft_count == 0) - return (sft FAR *) - 1; - /* finally, point to the right entry */ - return lpCurSft; + lpCurSft = (sft FAR *) & (sp->sftt_table[SftIndex]); + return SftIndex; } - else - SftIndex -= sp->sftt_count; + SftIndex -= sp->sftt_count; } - /* If not found, return an error */ - return (sft FAR *) - 1; + /* If not found, return an error */ + return -1; } +sft FAR * idx_to_sft(int SftIndex) +{ + /* called internally only */ + SftIndex = idx_to_sft_(SftIndex); + /* if not opened, the SFT is useless */ + if (SftIndex == -1 || lpCurSft->sft_count == 0) + return (sft FAR *) - 1; + return lpCurSft; +} + int get_sft_idx(unsigned hndl) { psp FAR *p = MK_FP(cu_psp, 0); diff --git a/kernel/inthndlr.c b/kernel/inthndlr.c index 7bc37afd..556ea691 100644 --- a/kernel/inthndlr.c +++ b/kernel/inthndlr.c @@ -1913,15 +1913,24 @@ VOID ASMCFUNC int2F_12_handler(struct int2f12regs r) r.ax -= 'a' - 'A'; break; - case 0x16: /* get address of system file table entry - used by NET.EXE - BX system file table entry number ( such as returned from 2F/1220) - returns - ES:DI pointer to SFT entry */ + case 0x16: + /* get address of system file table entry - used by NET.EXE + BX system file table entry number ( such as returned from 2F/1220) + returns + ES:DI pointer to SFT entry + BX relative entry number within SFT */ { - sft FAR *p = get_sft(r.bx); + int rel_idx = idx_to_sft_(r.bx); - r.es = FP_SEG(p); - r.di = FP_OFF(p); + if (rel_idx == (size_t) - 1) + { + r.flags |= FLG_CARRY; + break; + } + r.flags &= ~FLG_CARRY; + r.bx = rel_idx; + r.es = FP_SEG(lpCurSft); + r.di = FP_OFF(lpCurSft); break; } @@ -1963,6 +1972,24 @@ VOID ASMCFUNC int2F_12_handler(struct int2f12regs r) r.ax = (r.ax & 0xff00) | (r.cx & 3 ? 28 : 29); break; + case 0x20: /* get job file table entry */ + { + psp FAR *p = MK_FP(cu_psp, 0); + unsigned char FAR *idx; + + if (r.bx >= p->ps_maxfiles) + { + r.ax = (r.ax & 0xff00) | (-DE_INVLDHNDL); + r.flags |= FLG_CARRY; + break; + } + idx = &p->ps_filetab[r.bx]; + r.flags &= ~FLG_CARRY; + r.es = FP_SEG(idx); + r.di = FP_OFF(idx); + } + break; + case 0x21: /* truename */ DosTruename(MK_FP(r.ds, r.si), MK_FP(r.es, r.di)); diff --git a/kernel/proto.h b/kernel/proto.h index cefd177f..c28c1ad2 100644 --- a/kernel/proto.h +++ b/kernel/proto.h @@ -114,6 +114,7 @@ COUNT DosRmdir(const char FAR * dir); struct dhdr FAR *IsDevice(const char FAR * FileName); BOOL IsShareInstalled(void); COUNT DosLockUnlock(COUNT hndl, LONG pos, LONG len, COUNT unlock); +int idx_to_sft_(int SftIndex); sft FAR *idx_to_sft(int SftIndex); int get_sft_idx(UCOUNT hndl); struct cds FAR *get_cds(unsigned dsk); From ed77e34c5561f6c58ca12f54bc2ad35ea3229fd7 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sun, 5 Oct 2003 13:34:25 +0000 Subject: [PATCH 315/671] jmp -> jmp short (necessary for nasm 0.98) git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@713 6ac86273-5f31-0410-b378-82cca8765d1b --- boot/boot32.asm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/boot/boot32.asm b/boot/boot32.asm index 7dd46994..06eeae67 100644 --- a/boot/boot32.asm +++ b/boot/boot32.asm @@ -186,7 +186,7 @@ ff_find_next_cluster: pop ax ; restore current cluster pop dx call next_cluster - jmp ff_next_cluster + jmp short ff_next_cluster ff_done: mov ax, [es:di+0x1A-11] ; get cluster number @@ -207,7 +207,7 @@ c6: pop ax pop dx call next_cluster - jmp c5 + jmp short c5 boot_error: xor ah,ah @@ -369,7 +369,7 @@ read_next: push dx jnc read_ok ; jump if no error xor ah, ah ; else, reset floppy int 0x13 - jmp read_next + jmp short read_next read_ok: add bx, word [bsBytesPerSec] From 11e163096d5562d649bb075016a14028cf951b94 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sun, 5 Oct 2003 16:22:57 +0000 Subject: [PATCH 316/671] Added SET support to config.sys + some small cleanups (from Lucho) git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@714 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/config.c | 68 ++++++++++++++++++++++++++++++++++++----------- kernel/init-mod.h | 3 +-- kernel/main.c | 16 ----------- 3 files changed, 54 insertions(+), 33 deletions(-) diff --git a/kernel/config.c b/kernel/config.c index 2c06d25b..544f36d1 100644 --- a/kernel/config.c +++ b/kernel/config.c @@ -137,6 +137,9 @@ UWORD ram_top = 0; /* How much ram in Kbytes */ static UBYTE ErrorAlreadyPrinted[128]; +char master_env[128] = {"PATH="}; /* some shells panic on empty master env. */ +static char *envp = master_env + 6; /* point to the second zero */ + struct config Config = { 0, NUMBUFF, @@ -206,6 +209,7 @@ STATIC VOID InitPgm(BYTE * pLine); STATIC VOID InitPgmHigh(BYTE * pLine); STATIC VOID CmdInstall(BYTE * pLine); STATIC VOID CmdInstallHigh(BYTE * pLine); +STATIC VOID CmdSet(BYTE * pLine); STATIC VOID CfgSwitchar(BYTE * pLine); @@ -226,6 +230,7 @@ STATIC char * GetNumber(REG const char *p, int *num); STATIC COUNT tolower(COUNT c); #endif STATIC COUNT toupper(COUNT c); +STATIC VOID strupr(char *s); STATIC VOID mcb_init(UCOUNT seg, UWORD size, BYTE type); STATIC VOID mumcb_init(UCOUNT seg, UWORD size); @@ -306,6 +311,7 @@ STATIC struct table commands[] = { {"DEVICEHIGH", 2, DeviceHigh}, {"INSTALL", 2, CmdInstall}, {"INSTALLHIGH", 2, CmdInstallHigh}, + {"SET", 2, CmdSet}, /* default action */ {"", -1, CfgFailure} @@ -1036,8 +1042,7 @@ STATIC VOID Dosmem(BYTE * pLine) pLine = GetStringArg(pLine, szBuf); - for (pTmp = szBuf; *pTmp != '\0'; pTmp++) - *pTmp = toupper(*pTmp); + strupr(szBuf); /* printf("DOS called with %s\n", szBuf); */ @@ -1076,12 +1081,8 @@ STATIC VOID Dosmem(BYTE * pLine) STATIC VOID DosData(BYTE * pLine) { - BYTE *pTmp; - pLine = GetStringArg(pLine, szBuf); - - for (pTmp = szBuf; *pTmp != '\0'; pTmp++) - *pTmp = toupper(*pTmp); + strupr(szBuf); if (fmemcmp(szBuf, "UMB", 3) == 0) Config.cfgDosDataUmb = TRUE; @@ -1337,7 +1338,6 @@ STATIC BOOL LoadDevice(BYTE * pLine, char FAR *top, COUNT mode) struct dhdr FAR *next_dhp; BOOL result; seg base, start; - char *p; if (mode) { @@ -1373,8 +1373,7 @@ STATIC BOOL LoadDevice(BYTE * pLine, char FAR *top, COUNT mode) strcpy(szBuf, pLine); /* uppercase the device driver command */ - for (p = szBuf; *p != '\0'; p++) - *p = toupper(*p); + strupr(szBuf); /* TE this fixes the loading of devices drivers with multiple devices in it. NUMEGA's SoftIce is such a beast @@ -1663,6 +1662,13 @@ STATIC COUNT toupper(COUNT c) return c; } +/* Convert string s to uppercase */ +STATIC VOID strupr(char *s) +{ + while (*s) + *s++ = toupper(*s); +} + /* The following code is 8086 dependant */ #if 1 /* ifdef KERNEL */ @@ -1691,13 +1697,18 @@ STATIC VOID mumcb_init(UCOUNT seg, UWORD size) } #endif +static size_t strlen(const char *s) +{ + size_t n = 0; + while (*s++) + n++; + return n; +} + char *strcat(register char * d, register const char * s) { - char *tmp = d; - while (*d != 0) - ++d; - strcpy(d, s); - return tmp; + strcpy(d + strlen(d), s); + return d; } #if 0 @@ -1995,6 +2006,9 @@ STATIC VOID DoMenu(void) } printf("\n"); + /* export the current selected config menu */ + sprintf(envp, "CONFIG=%c", MenuSelected+'0'); + envp += 9; if (MenuColor != -1) ClearScreen(0x7); } @@ -2660,3 +2674,27 @@ VOID DoInstall(void) InstallPrintf(("Done with installing commands\n")); return; } + +STATIC VOID CmdSet(BYTE *pLine) +{ + pLine = GetStringArg(pLine, szBuf); + pLine = skipwh(pLine); /* scan() stops at the equal sign or space */ + if (*pLine == '=') /* equal sign is required */ + { + int size; + strupr(szBuf); /* all environment variables must be uppercase */ + strcat(szBuf, "="); + pLine = skipwh(++pLine); + strcat(szBuf, pLine); /* append the variable value (may include spaces) */ + size = strlen(szBuf); + if (size < master_env + sizeof(master_env) - envp - 1) + { /* must end with two consequtive zeros */ + strcpy(envp, szBuf); + envp += size + 1; /* add next variables starting at the second zero */ + } + else + printf("Master environment is full - can't add \"%s\"\n", szBuf); + } + else + printf("Invalid SET command: \"%s\"\n", szBuf); +} diff --git a/kernel/init-mod.h b/kernel/init-mod.h index 45fb1331..d5452a39 100644 --- a/kernel/init-mod.h +++ b/kernel/init-mod.h @@ -207,10 +207,9 @@ extern BYTE FAR *lpOldTop; extern BYTE FAR *lpTop; extern BYTE ASM _ib_start[], ASM _ib_end[], ASM _init_end[]; extern UWORD ram_top; /* How much ram in Kbytes */ -extern char MenuSelected; -extern unsigned Menus; extern char singleStep; extern char SkipAllConfig; +extern char master_env[128]; extern struct lol FAR *LoL; diff --git a/kernel/main.c b/kernel/main.c index 2cd4fee7..887bc210 100644 --- a/kernel/main.c +++ b/kernel/main.c @@ -361,22 +361,6 @@ STATIC void kernel() CommandTail Cmd; int rc; - BYTE master_env[32]; - char *masterenv_ptr = master_env; - - /* build the startup environment */ - - memset(master_env,0,sizeof(master_env)); - - /* initial path setting. is this useful ?? */ - masterenv_ptr += sprintf(masterenv_ptr, "PATH=."); - - /* export the current selected config menu */ - if (Menus) - { - masterenv_ptr += sprintf(masterenv_ptr, "CONFIG=%c", MenuSelected+'0'); - } - exb.exec.env_seg = DOS_PSP + 8; fmemcpy(MK_FP(exb.exec.env_seg, 0), master_env, sizeof(master_env)); From fdb58291c49f9757f16f85d5fb2d46ab550ff32b Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sat, 11 Oct 2003 23:58:51 +0000 Subject: [PATCH 317/671] Fix FCB problems with int21/ah=27,28 (RandomBlockIO) git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@715 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/fcbfns.c | 19 +++++++++++++------ kernel/inthndlr.c | 4 ++-- kernel/proto.h | 2 +- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/kernel/fcbfns.c b/kernel/fcbfns.c index 6942b133..0c71a955 100644 --- a/kernel/fcbfns.c +++ b/kernel/fcbfns.c @@ -337,19 +337,26 @@ void FcbCalcRec(xfcb FAR * lpXfcb) lpFcb->fcb_curec = lpFcb->fcb_rndm & 127; } -UBYTE FcbRandomBlockIO(xfcb FAR * lpXfcb, COUNT nRecords, int mode) +UBYTE FcbRandomBlockIO(xfcb FAR * lpXfcb, UWORD *nRecords, int mode) { - UCOUNT recno = 0; - UBYTE nErrorCode; + unsigned recno; + UBYTE nErrorCode = FCB_SUCCESS; FcbCalcRec(lpXfcb); /* Convert to fcb if necessary */ lpFcb = ExtFcbToFcb(lpXfcb); - do - nErrorCode = FcbReadWrite(lpXfcb, recno++, mode); - while ((--nRecords > 0) && (nErrorCode == 0)); + for (recno = 0; recno < *nRecords; recno++) + { + nErrorCode = FcbReadWrite(lpXfcb, recno, mode); + /* end-of-file, partial read should count last record */ + if (nErrorCode == FCB_ERR_EOF) + recno++; + if (nErrorCode != FCB_SUCCESS) + break; + } + *nRecords = recno; /* Now update the fcb */ lpFcb->fcb_rndm = FcbRec(); diff --git a/kernel/inthndlr.c b/kernel/inthndlr.c index 556ea691..1290538b 100644 --- a/kernel/inthndlr.c +++ b/kernel/inthndlr.c @@ -658,12 +658,12 @@ VOID ASMCFUNC int21_service(iregs FAR * r) /* Read random record(s) using FCB */ case 0x27: - lr.AL = FcbRandomBlockIO(FP_DS_DX, lr.CX, XFR_READ); + lr.AL = FcbRandomBlockIO(FP_DS_DX, &lr.CX, XFR_READ); break; /* Write random record(s) using FCB */ case 0x28: - lr.AL = FcbRandomBlockIO(FP_DS_DX, lr.CX, XFR_WRITE); + lr.AL = FcbRandomBlockIO(FP_DS_DX, &lr.CX, XFR_WRITE); break; /* Parse File Name */ diff --git a/kernel/proto.h b/kernel/proto.h index c28c1ad2..c82c76a8 100644 --- a/kernel/proto.h +++ b/kernel/proto.h @@ -210,7 +210,7 @@ const BYTE FAR *GetNameField(const BYTE FAR * lpFileName, BYTE FAR * lpDestField UBYTE FcbReadWrite(xfcb FAR *, UCOUNT, int); UBYTE FcbGetFileSize(xfcb FAR * lpXfcb); void FcbSetRandom(xfcb FAR * lpXfcb); -UBYTE FcbRandomBlockIO(xfcb FAR * lpXfcb, COUNT nRecords, int mode); +UBYTE FcbRandomBlockIO(xfcb FAR * lpXfcb, UWORD *nRecords, int mode); UBYTE FcbRandomIO(xfcb FAR * lpXfcb, int mode); UBYTE FcbOpen(xfcb FAR * lpXfcb, unsigned flags); int FcbNameInit(fcb FAR * lpFcb, BYTE * pszBuffer, COUNT * pCurDrive); From 61d87d82bb3caf24a2b41fbf43734c6bf2ec9194 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Thu, 16 Oct 2003 13:01:55 +0000 Subject: [PATCH 318/671] Rename the global lpFcb variable to sda_lpFcb. Then use local lpFcb variables where necessary. This clears up the confusing shadowing. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@716 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/fcbfns.c | 31 ++++++++++++++++++------------- kernel/globals.h | 2 +- kernel/kernel.asm | 4 ++-- 3 files changed, 21 insertions(+), 16 deletions(-) diff --git a/kernel/fcbfns.c b/kernel/fcbfns.c index 0c71a955..6953c222 100644 --- a/kernel/fcbfns.c +++ b/kernel/fcbfns.c @@ -235,7 +235,7 @@ STATIC VOID FcbNextRecord(fcb FAR * lpFcb) } } -STATIC ULONG FcbRec(VOID) +STATIC ULONG FcbRec(fcb FAR *lpFcb) { return ((ULONG) lpFcb->fcb_cublock * 128) + lpFcb->fcb_curec; } @@ -245,6 +245,7 @@ UBYTE FcbReadWrite(xfcb FAR * lpXfcb, UCOUNT recno, int mode) ULONG lPosit; long nTransfer; BYTE FAR * FcbIoPtr = dta; + fcb FAR *lpFcb; FcbIoPtr += recno * lpFcb->fcb_recsiz; @@ -257,7 +258,7 @@ UBYTE FcbReadWrite(xfcb FAR * lpXfcb, UCOUNT recno, int mode) /* Now update the fcb and compute where we need to position */ /* to. */ - lPosit = FcbRec() * lpFcb->fcb_recsiz; + lPosit = FcbRec(lpFcb) * lpFcb->fcb_recsiz; if ((CritErrCode = -SftSeek(lpFcb->fcb_sftno, lPosit, 0)) != SUCCESS) return FCB_ERR_NODATA; @@ -287,7 +288,7 @@ UBYTE FcbGetFileSize(xfcb FAR * lpXfcb) int FcbDrive, sft_idx; /* Build a traditional DOS file name */ - lpFcb = CommonFcbInit(lpXfcb, SecPathName, &FcbDrive); + fcb FAR *lpFcb = CommonFcbInit(lpXfcb, SecPathName, &FcbDrive); /* check for a device */ if (!lpFcb || IsDevice(SecPathName) || (lpFcb->fcb_recsiz == 0)) @@ -318,18 +319,18 @@ UBYTE FcbGetFileSize(xfcb FAR * lpXfcb) void FcbSetRandom(xfcb FAR * lpXfcb) { /* Convert to fcb if necessary */ - lpFcb = ExtFcbToFcb(lpXfcb); + fcb FAR *lpFcb = ExtFcbToFcb(lpXfcb); /* Now update the fcb and compute where we need to position */ /* to. */ - lpFcb->fcb_rndm = FcbRec(); + lpFcb->fcb_rndm = FcbRec(lpFcb); } void FcbCalcRec(xfcb FAR * lpXfcb) { /* Convert to fcb if necessary */ - lpFcb = ExtFcbToFcb(lpXfcb); + fcb FAR *lpFcb = ExtFcbToFcb(lpXfcb); /* Now update the fcb and compute where we need to position */ /* to. */ @@ -341,6 +342,7 @@ UBYTE FcbRandomBlockIO(xfcb FAR * lpXfcb, UWORD *nRecords, int mode) { unsigned recno; UBYTE nErrorCode = FCB_SUCCESS; + fcb FAR *lpFcb; FcbCalcRec(lpXfcb); @@ -359,7 +361,7 @@ UBYTE FcbRandomBlockIO(xfcb FAR * lpXfcb, UWORD *nRecords, int mode) *nRecords = recno; /* Now update the fcb */ - lpFcb->fcb_rndm = FcbRec(); + lpFcb->fcb_rndm = FcbRec(lpFcb); return nErrorCode; } @@ -369,6 +371,7 @@ UBYTE FcbRandomIO(xfcb FAR * lpXfcb, int mode) UWORD uwCurrentBlock; UBYTE ucCurrentRecord; UBYTE nErrorCode; + fcb FAR *lpFcb; FcbCalcRec(lpXfcb); @@ -393,7 +396,7 @@ UBYTE FcbOpen(xfcb FAR * lpXfcb, unsigned flags) unsigned attr = 0; /* Build a traditional DOS file name */ - lpFcb = CommonFcbInit(lpXfcb, SecPathName, &FcbDrive); + fcb FAR *lpFcb = CommonFcbInit(lpXfcb, SecPathName, &FcbDrive); if (lpFcb == NULL) return FCB_ERROR; @@ -431,9 +434,10 @@ UBYTE FcbOpen(xfcb FAR * lpXfcb, unsigned flags) STATIC fcb FAR *ExtFcbToFcb(xfcb FAR * lpExtFcb) { if (*((UBYTE FAR *) lpExtFcb) == 0xff) - return &lpExtFcb->xfcb_fcb; + sda_lpFcb = &lpExtFcb->xfcb_fcb; else - return (fcb FAR *) lpExtFcb; + sda_lpFcb = (fcb FAR *) lpExtFcb; + return sda_lpFcb; } STATIC fcb FAR *CommonFcbInit(xfcb FAR * lpExtFcb, BYTE * pszBuffer, @@ -442,7 +446,7 @@ STATIC fcb FAR *CommonFcbInit(xfcb FAR * lpExtFcb, BYTE * pszBuffer, fcb FAR *lpFcb; /* convert to fcb if needed first */ - lpFcb = ExtFcbToFcb(lpExtFcb); + sda_lpFcb = lpFcb = ExtFcbToFcb(lpExtFcb); /* Build a traditional DOS file name */ if (FcbNameInit(lpFcb, pszBuffer, pCurDrive) < SUCCESS) @@ -477,7 +481,7 @@ UBYTE FcbDelete(xfcb FAR * lpXfcb) void FAR *lpOldDta = dta; /* Build a traditional DOS file name */ - CommonFcbInit(lpXfcb, SecPathName, &FcbDrive); + fcb FAR *lpFcb = CommonFcbInit(lpXfcb, SecPathName, &FcbDrive); /* check for a device */ if (lpFcb == NULL || IsDevice(SecPathName)) { @@ -598,7 +602,7 @@ UBYTE FcbClose(xfcb FAR * lpXfcb) sft FAR *s; /* Convert to fcb if necessary */ - lpFcb = ExtFcbToFcb(lpXfcb); + fcb FAR *lpFcb = ExtFcbToFcb(lpXfcb); /* An already closed FCB can be closed again without error */ if (lpFcb->fcb_sftno == (BYTE) 0xff) @@ -637,6 +641,7 @@ UBYTE FcbFindFirstNext(xfcb FAR * lpXfcb, BOOL First) void FAR *orig_dta = dta; BYTE FAR *lpDir; COUNT FcbDrive; + fcb FAR *lpFcb; /* First, move the dta to a local and change it around to match */ /* our functions. */ diff --git a/kernel/globals.h b/kernel/globals.h index b8293044..5b15fa47 100644 --- a/kernel/globals.h +++ b/kernel/globals.h @@ -321,7 +321,7 @@ extern iregs FAR * ASM user_r; /* User registers for int 21h call */ extern struct dirent /* Temporary directory entry */ ASM DirEntBuffer; -extern fcb FAR * ASM lpFcb; /* Pointer to users fcb */ +extern fcb FAR * ASM sda_lpFcb; /* Pointer to users fcb */ extern sft FAR * ASM lpCurSft; diff --git a/kernel/kernel.asm b/kernel/kernel.asm index 106ac36e..0404a946 100644 --- a/kernel/kernel.asm +++ b/kernel/kernel.asm @@ -553,8 +553,8 @@ current_device times 2 dw 0 ;27A - 0?? _lpCurSft times 2 dw 0 ;27e - Current SFT global _current_ldt _current_ldt times 2 dw 0 ;282 - Current CDS - global _lpFcb -_lpFcb times 2 dw 0 ;286 - pointer to callers FCB + global _sda_lpFcb +_sda_lpFcb times 2 dw 0 ;286 - pointer to callers FCB global _current_sft_idx _current_sft_idx dw 0 ;28A - SFT index for next open ; used by MS NET From dd9df1f3a6f3c9a63e74c15334c8284e30cedc39 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Thu, 16 Oct 2003 14:25:15 +0000 Subject: [PATCH 319/671] Divide optimisation (ceiling) + some small cleanups git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@717 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/fcbfns.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/kernel/fcbfns.c b/kernel/fcbfns.c index 6953c222..e0029886 100644 --- a/kernel/fcbfns.c +++ b/kernel/fcbfns.c @@ -251,11 +251,11 @@ UBYTE FcbReadWrite(xfcb FAR * lpXfcb, UCOUNT recno, int mode) if ((ULONG)recno * lpFcb->fcb_recsiz >= 0x10000ul || FP_OFF(FcbIoPtr) < FP_OFF(dta)) - return FCB_ERR_SEGMENT_WRAP; + return FCB_ERR_SEGMENT_WRAP; /* Convert to fcb if necessary */ lpFcb = ExtFcbToFcb(lpXfcb); - + /* Now update the fcb and compute where we need to position */ /* to. */ lPosit = FcbRec(lpFcb) * lpFcb->fcb_recsiz; @@ -266,7 +266,7 @@ UBYTE FcbReadWrite(xfcb FAR * lpXfcb, UCOUNT recno, int mode) nTransfer = DosRWSft(lpFcb->fcb_sftno, lpFcb->fcb_recsiz, FcbIoPtr, mode); if (nTransfer < 0) CritErrCode = -(int)nTransfer; - + /* Now find out how we will return and do it. */ if (nTransfer == lpFcb->fcb_recsiz) { @@ -286,12 +286,14 @@ UBYTE FcbReadWrite(xfcb FAR * lpXfcb, UCOUNT recno, int mode) UBYTE FcbGetFileSize(xfcb FAR * lpXfcb) { int FcbDrive, sft_idx; + unsigned recsiz; /* Build a traditional DOS file name */ fcb FAR *lpFcb = CommonFcbInit(lpXfcb, SecPathName, &FcbDrive); + recsiz = lpFcb->fcb_recsiz; /* check for a device */ - if (!lpFcb || IsDevice(SecPathName) || (lpFcb->fcb_recsiz == 0)) + if (!lpFcb || IsDevice(SecPathName) || (recsiz == 0)) return FCB_ERROR; sft_idx = (short)DosOpenSft(SecPathName, O_LEGACY | O_RDONLY | O_OPEN, 0); @@ -303,9 +305,7 @@ UBYTE FcbGetFileSize(xfcb FAR * lpXfcb) fsize = SftGetFsize(sft_idx); /* compute the size and update the fcb */ - lpFcb->fcb_rndm = fsize / lpFcb->fcb_recsiz; - if ((fsize % lpFcb->fcb_recsiz) != 0) - ++lpFcb->fcb_rndm; + lpFcb->fcb_rndm = (fsize + (recsiz - 1)) / recsiz; /* close the file and leave */ if ((CritErrCode = -DosCloseSft(sft_idx, FALSE)) == SUCCESS) From 492fef1f7248db12c02c343aa824fe9d8d358f0b Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Thu, 16 Oct 2003 15:03:16 +0000 Subject: [PATCH 320/671] Change FcbReadWrite to handle multiple records at once; this allows for the optimization of FcbRandomBlockIO. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@718 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/fcbfns.c | 58 +++++++++++++++++++++++++---------------------- kernel/globals.h | 2 ++ kernel/inthndlr.c | 11 +++++---- 3 files changed, 39 insertions(+), 32 deletions(-) diff --git a/kernel/fcbfns.c b/kernel/fcbfns.c index e0029886..c2dbbb16 100644 --- a/kernel/fcbfns.c +++ b/kernel/fcbfns.c @@ -244,39 +244,50 @@ UBYTE FcbReadWrite(xfcb FAR * lpXfcb, UCOUNT recno, int mode) { ULONG lPosit; long nTransfer; - BYTE FAR * FcbIoPtr = dta; fcb FAR *lpFcb; - - FcbIoPtr += recno * lpFcb->fcb_recsiz; - - if ((ULONG)recno * lpFcb->fcb_recsiz >= 0x10000ul || - FP_OFF(FcbIoPtr) < FP_OFF(dta)) - return FCB_ERR_SEGMENT_WRAP; + unsigned size; + unsigned long bigsize; + unsigned recsiz; /* Convert to fcb if necessary */ lpFcb = ExtFcbToFcb(lpXfcb); + recsiz = lpFcb->fcb_recsiz; + bigsize = (ULONG)recsiz * recno; + if (bigsize > 0xffff) + return FCB_ERR_SEGMENT_WRAP; + size = (unsigned)bigsize; + + if (FP_OFF(dta) + size < FP_OFF(dta)) + return FCB_ERR_SEGMENT_WRAP; /* Now update the fcb and compute where we need to position */ /* to. */ - lPosit = FcbRec(lpFcb) * lpFcb->fcb_recsiz; + lPosit = FcbRec(lpFcb) * recsiz; if ((CritErrCode = -SftSeek(lpFcb->fcb_sftno, lPosit, 0)) != SUCCESS) return FCB_ERR_NODATA; /* Do the read */ - nTransfer = DosRWSft(lpFcb->fcb_sftno, lpFcb->fcb_recsiz, FcbIoPtr, mode); + nTransfer = DosRWSft(lpFcb->fcb_sftno, size, dta, mode & ~XFR_FCB_RANDOM); if (nTransfer < 0) CritErrCode = -(int)nTransfer; /* Now find out how we will return and do it. */ - if (nTransfer == lpFcb->fcb_recsiz) + if (mode & XFR_WRITE) + lpFcb->fcb_fsize = SftGetFsize(lpFcb->fcb_sftno); + + /* if end-of-file, then partial read should count last record */ + if (mode & XFR_FCB_RANDOM && recsiz > 0) + lpFcb->fcb_rndm += ((unsigned)nTransfer + recsiz - 1) / recsiz; + size -= (unsigned)nTransfer; + if (size == 0) { - if (mode == XFR_WRITE) lpFcb->fcb_fsize = SftGetFsize(lpFcb->fcb_sftno); FcbNextRecord(lpFcb); return FCB_SUCCESS; } - if (mode == XFR_READ && nTransfer > 0) + size %= lpFcb->fcb_recsiz; + if (mode & XFR_READ && size > 0) { - fmemset(FcbIoPtr + (unsigned)nTransfer, 0, lpFcb->fcb_recsiz - (unsigned)nTransfer); + fmemset((char FAR *)dta + (unsigned)nTransfer, 0, size); FcbNextRecord(lpFcb); return FCB_ERR_EOF; } @@ -340,28 +351,21 @@ void FcbCalcRec(xfcb FAR * lpXfcb) UBYTE FcbRandomBlockIO(xfcb FAR * lpXfcb, UWORD *nRecords, int mode) { - unsigned recno; - UBYTE nErrorCode = FCB_SUCCESS; + UBYTE nErrorCode; fcb FAR *lpFcb; + unsigned long old; FcbCalcRec(lpXfcb); /* Convert to fcb if necessary */ lpFcb = ExtFcbToFcb(lpXfcb); - for (recno = 0; recno < *nRecords; recno++) - { - nErrorCode = FcbReadWrite(lpXfcb, recno, mode); - /* end-of-file, partial read should count last record */ - if (nErrorCode == FCB_ERR_EOF) - recno++; - if (nErrorCode != FCB_SUCCESS) - break; - } - *nRecords = recno; + old = lpFcb->fcb_rndm; + nErrorCode = FcbReadWrite(lpXfcb, *nRecords, mode); + *nRecords = lpFcb->fcb_rndm - old; /* Now update the fcb */ - lpFcb->fcb_rndm = FcbRec(lpFcb); + FcbCalcRec(lpXfcb); return nErrorCode; } @@ -381,7 +385,7 @@ UBYTE FcbRandomIO(xfcb FAR * lpXfcb, int mode) uwCurrentBlock = lpFcb->fcb_cublock; ucCurrentRecord = lpFcb->fcb_curec; - nErrorCode = FcbReadWrite(lpXfcb, 0, mode); + nErrorCode = FcbReadWrite(lpXfcb, 1, mode); lpFcb->fcb_cublock = uwCurrentBlock; lpFcb->fcb_curec = ucCurrentRecord; diff --git a/kernel/globals.h b/kernel/globals.h index 5b15fa47..6365b35b 100644 --- a/kernel/globals.h +++ b/kernel/globals.h @@ -111,6 +111,8 @@ FAR * ASM DPBp; /* First drive Parameter Block */ #define XFR_READ 1 #define XFR_WRITE 2 #define XFR_FORCE_WRITE 3 +/* flag to update fcb_rndm field */ +#define XFR_FCB_RANDOM 4 #define RDONLY 0 #define WRONLY 1 diff --git a/kernel/inthndlr.c b/kernel/inthndlr.c index 1290538b..e799738c 100644 --- a/kernel/inthndlr.c +++ b/kernel/inthndlr.c @@ -556,12 +556,12 @@ VOID ASMCFUNC int21_service(iregs FAR * r) case 0x14: /* FCB read */ - lr.AL = FcbReadWrite(FP_DS_DX, 0, XFR_READ); + lr.AL = FcbReadWrite(FP_DS_DX, 1, XFR_READ); break; case 0x15: /* FCB write */ - lr.AL = FcbReadWrite(FP_DS_DX, 0, XFR_WRITE); + lr.AL = FcbReadWrite(FP_DS_DX, 1, XFR_WRITE); break; case 0x16: @@ -622,7 +622,8 @@ VOID ASMCFUNC int21_service(iregs FAR * r) /* Get default DPB */ /* case 0x1f: see case 0x32 */ - /* Random read using FCB */ + /* Random read using FCB: fields not updated + (XFR_RANDOM should not be used here) */ case 0x21: lr.AL = FcbRandomIO(FP_DS_DX, XFR_READ); break; @@ -658,12 +659,12 @@ VOID ASMCFUNC int21_service(iregs FAR * r) /* Read random record(s) using FCB */ case 0x27: - lr.AL = FcbRandomBlockIO(FP_DS_DX, &lr.CX, XFR_READ); + lr.AL = FcbRandomBlockIO(FP_DS_DX, &lr.CX, XFR_READ | XFR_FCB_RANDOM); break; /* Write random record(s) using FCB */ case 0x28: - lr.AL = FcbRandomBlockIO(FP_DS_DX, &lr.CX, XFR_WRITE); + lr.AL = FcbRandomBlockIO(FP_DS_DX, &lr.CX, XFR_WRITE | XFR_FCB_RANDOMXS); break; /* Parse File Name */ From 58808de6c8b69f19aab683d61a045c68fa26422e Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Thu, 16 Oct 2003 15:05:10 +0000 Subject: [PATCH 321/671] Fix typo. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@719 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/inthndlr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/inthndlr.c b/kernel/inthndlr.c index e799738c..9aca604f 100644 --- a/kernel/inthndlr.c +++ b/kernel/inthndlr.c @@ -664,7 +664,7 @@ VOID ASMCFUNC int21_service(iregs FAR * r) /* Write random record(s) using FCB */ case 0x28: - lr.AL = FcbRandomBlockIO(FP_DS_DX, &lr.CX, XFR_WRITE | XFR_FCB_RANDOMXS); + lr.AL = FcbRandomBlockIO(FP_DS_DX, &lr.CX, XFR_WRITE | XFR_FCB_RANDOM); break; /* Parse File Name */ From 8db46073f936df31dde53228eeb79a0232d45df6 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sun, 26 Oct 2003 13:07:49 +0000 Subject: [PATCH 322/671] From: Eric Luttmann Fix for multisegmented device drivers: If there are multiple device drivers in a single driver file, only the END ADDRESS returned by the last INIT call should be the used. It is recommended that all the device drivers in the file return the same address. This fixes a load problem with DUSE. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@721 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/main.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/kernel/main.c b/kernel/main.c index 887bc210..c2c2e49f 100644 --- a/kernel/main.c +++ b/kernel/main.c @@ -535,8 +535,17 @@ BOOL init_device(struct dhdr FAR * dhp, char *cmdLine, COUNT mode, if (rq.r_endaddr == (BYTE FAR *) dhp) return TRUE; - KernelAllocPara(FP_SEG(rq.r_endaddr) + (FP_OFF(rq.r_endaddr) + 15)/16 - - FP_SEG(dhp), 'D', name, mode); + /* Fix for multisegmented device drivers: */ + /* If there are multiple device drivers in a single driver file, */ + /* only the END ADDRESS returned by the last INIT call should be */ + /* the used. It is recommended that all the device drivers in */ + /* the file return the same address */ + + if (FP_OFF(dhp->dh_next) == 0xffff) + { + KernelAllocPara(FP_SEG(rq.r_endaddr) + (FP_OFF(rq.r_endaddr) + 15)/16 + - FP_SEG(dhp), 'D', name, mode); + } } if (!(dhp->dh_attr & ATTR_CHAR) && (rq.r_nunits != 0)) From a0f44650456531918c0132df2e3cdb92521ad150 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Thu, 30 Oct 2003 12:22:06 +0000 Subject: [PATCH 323/671] From Eric Luttmann: fix for multi-segment device drivers; preserve rq_endaddr between init calls for the same driver. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@722 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/config.c | 9 ++++++++- kernel/init-mod.h | 2 +- kernel/main.c | 17 +++++++++++++---- 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/kernel/config.c b/kernel/config.c index 544f36d1..00b84a98 100644 --- a/kernel/config.c +++ b/kernel/config.c @@ -1384,8 +1384,15 @@ STATIC BOOL LoadDevice(BYTE * pLine, char FAR *top, COUNT mode) dhp = MK_FP(base, 0); + /* NOTE - Modification for multisegmented device drivers: */ + /* In order to emulate the functionallity experienced with other */ + /* DOS operating systems, the original 'top' end address is */ + /* updated with the end address returned from the INIT request. */ + /* The updated end address is then used when issuing the next */ + /* INIT request for the following device driver within the file */ + for (next_dhp = NULL; FP_OFF(next_dhp) != 0xffff && - (result = init_device(dhp, szBuf, mode, top)) == SUCCESS; + (result = init_device(dhp, szBuf, mode, &top)) == SUCCESS; dhp = next_dhp) { next_dhp = MK_FP(FP_SEG(dhp), FP_OFF(dhp->dh_next)); diff --git a/kernel/init-mod.h b/kernel/init-mod.h index d5452a39..51c6af91 100644 --- a/kernel/init-mod.h +++ b/kernel/init-mod.h @@ -188,7 +188,7 @@ VOID ASMCFUNC FAR cpm_entry(void); /* main.c */ VOID ASMCFUNC FreeDOSmain(void); BOOL init_device(struct dhdr FAR * dhp, char * cmdLine, - COUNT mode, char FAR *top); + COUNT mode, char FAR **top); VOID init_fatal(BYTE * err_msg); /* prf.c */ diff --git a/kernel/main.c b/kernel/main.c index c2c2e49f..f71d97a4 100644 --- a/kernel/main.c +++ b/kernel/main.c @@ -230,7 +230,7 @@ STATIC void init_kernel(void) /* we can read config.sys later. */ LoL->lastdrive = Config.cfgLastdrive; - /* init_device((struct dhdr FAR *)&blk_dev, NULL, 0, ram_top); */ + /* init_device((struct dhdr FAR *)&blk_dev, NULL, 0, &ram_top); */ blk_dev.dh_name[0] = dsk_init(); PreConfig(); @@ -485,7 +485,7 @@ STATIC VOID update_dcb(struct dhdr FAR * dhp) /* If cmdLine is NULL, this is an internal driver */ BOOL init_device(struct dhdr FAR * dhp, char *cmdLine, COUNT mode, - char FAR *r_top) + char FAR **r_top) { request rq; char name[8]; @@ -517,7 +517,7 @@ BOOL init_device(struct dhdr FAR * dhp, char *cmdLine, COUNT mode, rq.r_status = 0; rq.r_command = C_INIT; rq.r_length = sizeof(request); - rq.r_endaddr = r_top; + rq.r_endaddr = *r_top; rq.r_bpbptr = (void FAR *)(cmdLine ? cmdLine : "\n"); rq.r_firstunit = LoL->nblkdev; @@ -546,6 +546,15 @@ BOOL init_device(struct dhdr FAR * dhp, char *cmdLine, COUNT mode, KernelAllocPara(FP_SEG(rq.r_endaddr) + (FP_OFF(rq.r_endaddr) + 15)/16 - FP_SEG(dhp), 'D', name, mode); } + + /* Another fix for multisegmented device drivers: */ + /* To help emulate the functionallity experienced with other DOS */ + /* operating systems when calling multiple device drivers in a */ + /* single driver file, save the end address returned from the */ + /* last INIT call which will then be passed as the end address */ + /* for the next INIT call. */ + + *r_top = (char FAR *)rq.r_endaddr; } if (!(dhp->dh_attr & ATTR_CHAR) && (rq.r_nunits != 0)) @@ -569,7 +578,7 @@ STATIC void InitIO(void) /* Initialize driver chain */ setvec(0x29, int29_handler); /* Requires Fast Con Driver */ do { - init_device(device, NULL, 0, lpTop); + init_device(device, NULL, 0, &lpTop); device = device->dh_next; } while (FP_OFF(device) != 0xffff); From 0694ff1acbeada95bcd8e5e75a77e3f85f78f5af Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Thu, 30 Oct 2003 13:42:29 +0000 Subject: [PATCH 324/671] (from Lucho) Remove AL=0 check for AH=6c (from Arkady) Optimize DL check. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@723 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/inthndlr.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/inthndlr.c b/kernel/inthndlr.c index 9aca604f..a4db4c6f 100644 --- a/kernel/inthndlr.c +++ b/kernel/inthndlr.c @@ -1561,8 +1561,8 @@ VOID ASMCFUNC int21_service(iregs FAR * r) { long lrc; - if (lr.AL != 0 || - (lr.DL & 0x0f) > 0x2 || (lr.DL & 0xf0) > 0x10) + /* high nibble must be <= 1, low nibble must be <= 2 */ + if ((lr.DL & 0xef) > 0x2) goto error_invalid; lrc = DosOpen(MK_FP(lr.DS, lr.SI), (lr.BX & 0x70ff) | ((lr.DL & 3) << 8) | From 09dca9d2241fdae45617350f0857cbe9ad79b29a Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Thu, 30 Oct 2003 14:34:39 +0000 Subject: [PATCH 325/671] Move common code in media_check() to a new blockio() function. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@724 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/fatfs.c | 90 ++++++++++++++++++-------------------------------- 1 file changed, 33 insertions(+), 57 deletions(-) diff --git a/kernel/fatfs.c b/kernel/fatfs.c index 63eb082f..676ec32b 100644 --- a/kernel/fatfs.c +++ b/kernel/fatfs.c @@ -2062,42 +2062,46 @@ ckok:; #endif } -COUNT media_check(REG struct dpb FAR * dpbp) +STATIC int blockio(unsigned char command, struct dpb FAR * dpbp) { - if (dpbp == NULL) - return DE_INVLDDRV; - - /* First test if anyone has changed the removable media */ - FOREVER + retry: + MediaReqHdr.r_length = sizeof(request); + MediaReqHdr.r_unit = dpbp->dpb_subunit; + MediaReqHdr.r_command = command; + MediaReqHdr.r_mcmdesc = dpbp->dpb_mdb; + MediaReqHdr.r_status = 0; + execrh((request FAR *) & MediaReqHdr, dpbp->dpb_device); + if ((MediaReqHdr.r_status & S_ERROR) || !(MediaReqHdr.r_status & S_DONE)) { - MediaReqHdr.r_length = sizeof(request); - MediaReqHdr.r_unit = dpbp->dpb_subunit; - MediaReqHdr.r_command = C_MEDIACHK; - MediaReqHdr.r_mcmdesc = dpbp->dpb_mdb; - MediaReqHdr.r_status = 0; - execrh((request FAR *) & MediaReqHdr, dpbp->dpb_device); - if ((MediaReqHdr.r_status & S_ERROR) - || !(MediaReqHdr.r_status & S_DONE)) + FOREVER { - loop1: switch (block_error(&MediaReqHdr, dpbp->dpb_unit, dpbp->dpb_device, 0)) { - case ABORT: - case FAIL: - return DE_INVLDDRV; + case ABORT: + case FAIL: + return DE_INVLDDRV; - case RETRY: - continue; + case RETRY: + goto retry; - case CONTINUE: - break; - - default: - goto loop1; + case CONTINUE: + return SUCCESS; } } - break; } + return SUCCESS; +} + +COUNT media_check(REG struct dpb FAR * dpbp) +{ + int ret; + if (dpbp == NULL) + return DE_INVLDDRV; + + /* First test if anyone has changed the removable media */ + ret = blockio(C_MEDIACHK, dpbp); + if (ret < SUCCESS) + return ret; switch (MediaReqHdr.r_mcretcode | dpbp->dpb_flags) { @@ -2116,37 +2120,9 @@ COUNT media_check(REG struct dpb FAR * dpbp) case M_CHANGED: default: setinvld(dpbp->dpb_unit); - FOREVER - { - MediaReqHdr.r_length = sizeof(request); - MediaReqHdr.r_unit = dpbp->dpb_subunit; - MediaReqHdr.r_command = C_BLDBPB; - MediaReqHdr.r_mcmdesc = dpbp->dpb_mdb; - MediaReqHdr.r_status = 0; - execrh((request FAR *) & MediaReqHdr, dpbp->dpb_device); - if ((MediaReqHdr.r_status & S_ERROR) - || !(MediaReqHdr.r_status & S_DONE)) - { - loop2: - switch (block_error - (&MediaReqHdr, dpbp->dpb_unit, dpbp->dpb_device, 0)) - { - case ABORT: - case FAIL: - return DE_INVLDDRV; - - case RETRY: - continue; - - case CONTINUE: - break; - - default: - goto loop2; - } - } - break; - } + ret = blockio(C_BLDBPB, dpbp); + if (ret < SUCCESS) + return ret; #ifdef WITHFAT32 /* extend dpb only for internal or FAT32 devices */ bpb_to_dpb(MediaReqHdr.r_bpptr, dpbp, From 9f2208943c2cd89ba0ea7ce7496e8124f2030ede Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Fri, 14 Nov 2003 21:55:25 +0000 Subject: [PATCH 326/671] From Lucho with some help from Tom: initialize serial ports and retry serial reads on timeout. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@725 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/main.c | 19 +++++++++++++++++++ kernel/serial.asm | 2 ++ 2 files changed, 21 insertions(+) diff --git a/kernel/main.c b/kernel/main.c index f71d97a4..05d6fd83 100644 --- a/kernel/main.c +++ b/kernel/main.c @@ -53,6 +53,7 @@ STATIC VOID signon(VOID); STATIC VOID kernel(VOID); STATIC VOID FsConfig(VOID); STATIC VOID InitPrinters(VOID); +STATIC VOID InitSerialPorts(VOID); STATIC void CheckContinueBootFromHarddisk(void); #ifdef _MSC_VER @@ -202,6 +203,7 @@ STATIC void init_kernel(void) /* Initialize IO subsystem */ InitIO(); InitPrinters(); + InitSerialPorts(); /* set interrupt vectors */ setvec(0x1b, got_cbreak); @@ -616,6 +618,23 @@ STATIC VOID InitPrinters(VOID) } } +STATIC VOID InitSerialPorts(VOID) +{ + iregs r; + int serial_ports, i; + + init_call_intr(0x11, &r); /* get equipment list */ + + serial_ports = (r.a.x >> 9) & 7; /* bits 11-9 */ + + for (i = 0; i < serial_ports; i++) + { + r.a.x = 0xA3; /* initialize serial port to 2400,n,8,1 */ + r.d.x = i; + init_call_intr(0x14, &r); + } +} + /***************************************************************** if kernel.config.BootHarddiskSeconds is set, the default is to boot from harddisk, because diff --git a/kernel/serial.asm b/kernel/serial.asm index 5ae68aca..914bf5f7 100644 --- a/kernel/serial.asm +++ b/kernel/serial.asm @@ -61,6 +61,8 @@ ComRead: jnz ComRd2 ComRd1: call BiosRdCom + or ah,ah ; timeout? + js ComRd1 ; yes, try again ComRd2: stosb loop ComRd1 From 3232712faeeb7da08e32bb187e9247c7a9b82cfb Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sun, 16 Nov 2003 16:21:29 +0000 Subject: [PATCH 327/671] force r/o open for FCB and legacy creat if the file is read-only git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@726 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/fatfs.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/kernel/fatfs.c b/kernel/fatfs.c index 676ec32b..dfaefd5b 100644 --- a/kernel/fatfs.c +++ b/kernel/fatfs.c @@ -216,8 +216,10 @@ long dos_open(char *path, unsigned flags, unsigned attrib) } } - /* force r/o open for FCBs if the file is read-only */ - if ((flags & O_FCB) && (fnp->f_dir.dir_attrib & D_RDONLY)) + /* force r/o open for FCB and legacy creat if the file is read-only */ + if (((flags & O_FCB) + || (flags & (O_CREAT | O_LEGACY)) == (O_CREAT | O_LEGACY)) + && (fnp->f_dir.dir_attrib & D_RDONLY)) fnp->f_mode = O_RDONLY; /* Check permissions. -- JPP */ From a56e592871c0b9e297292e8ca0708ad7355d82df Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sun, 23 Nov 2003 18:03:35 +0000 Subject: [PATCH 328/671] Move permission check to better place (only for necessary for opening existing files), not for creating them -- suggested by Steffen. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@727 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/fatfs.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/kernel/fatfs.c b/kernel/fatfs.c index dfaefd5b..4244f912 100644 --- a/kernel/fatfs.c +++ b/kernel/fatfs.c @@ -149,7 +149,20 @@ long dos_open(char *path, unsigned flags, unsigned attrib) wipe_out(fnp); status = S_REPLACED; } - else if (!(flags & O_OPEN)) + else if (flags & O_OPEN) + { + /* force r/o open for FCB if the file is read-only */ + if ((flags & O_FCB) && (fnp->f_dir.dir_attrib & D_RDONLY)) + flags = (flags & ~3) | O_RDONLY; + + /* Check permissions. -- JPP */ + if ((fnp->f_dir.dir_attrib & D_RDONLY) && ((flags & 3) != O_RDONLY)) + { + dir_close(fnp); + return DE_ACCESS; + } + } + else { dir_close(fnp); return DE_FILEEXISTS; @@ -216,19 +229,6 @@ long dos_open(char *path, unsigned flags, unsigned attrib) } } - /* force r/o open for FCB and legacy creat if the file is read-only */ - if (((flags & O_FCB) - || (flags & (O_CREAT | O_LEGACY)) == (O_CREAT | O_LEGACY)) - && (fnp->f_dir.dir_attrib & D_RDONLY)) - fnp->f_mode = O_RDONLY; - - /* Check permissions. -- JPP */ - if ((fnp->f_dir.dir_attrib & D_RDONLY) && (fnp->f_mode != O_RDONLY)) - { - dir_close(fnp); - return DE_ACCESS; - } - /* Now change to file */ fnp->f_offset = 0l; From 21f2b2ec5e981433e929962d73118345cbcf235b Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sun, 30 Nov 2003 04:08:27 +0000 Subject: [PATCH 329/671] Fix nls upcase problem with SS!=DS. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@728 6ac86273-5f31-0410-b378-82cca8765d1b --- hdr/portab.h | 8 ++++++++ kernel/nls.c | 3 +-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/hdr/portab.h b/hdr/portab.h index ab72e183..3e87e73a 100644 --- a/hdr/portab.h +++ b/hdr/portab.h @@ -72,6 +72,11 @@ void __int__(int); #define CDECL _cdecl #define PASCAL pascal #define __int__(intno) asm int intno; +#define _SS SS() +static unsigned short __inline SS(void) +{ + asm mov ax, ss; +} #if defined(M_I286) /* /G3 doesn't set M_I386, but sets M_I286 TE */ #define I386 @@ -85,6 +90,9 @@ void __int__(int); #define far __far #define CDECL __cdecl #define PASCAL pascal +#define _SS SS() +unsigned short SS(void); +#pragma aux SS = "mov dx,ss" value [dx]; #if _M_IX86 >= 300 #define I386 diff --git a/kernel/nls.c b/kernel/nls.c index 74a0a39d..7aac1274 100644 --- a/kernel/nls.c +++ b/kernel/nls.c @@ -475,9 +475,8 @@ VOID DosUpMem(VOID FAR * str, unsigned len) unsigned char ASMCFUNC DosUpChar(unsigned char ch) /* upcase a single character */ { - assertDSeqSS(); /* because "&ch" */ log(("NLS: DosUpChar(): in ch=%u (%c)\n", ch, ch > 32 ? ch : ' ')); - DosUpMem((UBYTE FAR *) & ch, 1); + DosUpMem(MK_FP(_SS, &ch), 1); log(("NLS: DosUpChar(): upcased ch=%u (%c)\n", ch, ch > 32 ? ch : ' ')); return ch; } From a44981fc3a647b68eb8e93bbd4d599b64208b856 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sun, 30 Nov 2003 15:49:53 +0000 Subject: [PATCH 330/671] FAT32 kernels should fail int21/ah=71 with al=0, carry set. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@729 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/inthndlr.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/kernel/inthndlr.c b/kernel/inthndlr.c index a4db4c6f..094c68b1 100644 --- a/kernel/inthndlr.c +++ b/kernel/inthndlr.c @@ -1584,6 +1584,11 @@ VOID ASMCFUNC int21_service(iregs FAR * r) /* case 0x6d and above not implemented : see default; return AL=0 */ #ifdef WITHFAT32 + /* LFN functions - fail with "function not supported" error code */ + case 0x71: + lr.AL = 00; + goto error_carry; + /* DOS 7.0+ FAT32 extended functions */ case 0x73: CLEAR_CARRY_FLAG(); From 76cb6edf6e07419356044b865f9c636c47ee34d8 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Mon, 1 Dec 2003 00:45:38 +0000 Subject: [PATCH 331/671] Do not clobber the DTA if findfirst or findnext fails. Fixes bug #1712 git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@733 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/dosfns.c | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/kernel/dosfns.c b/kernel/dosfns.c index 152cfd3d..4c20e4da 100644 --- a/kernel/dosfns.c +++ b/kernel/dosfns.c @@ -1036,21 +1036,14 @@ COUNT DosFindFirst(UCOUNT attr, BYTE FAR * name) in newstuff.c. - Ron Cemer */ - fmemset(dmp, 0, sizeof(dmatch)); - - /* initially mark the dta as invalid for further findnexts */ - dmp->dm_attr_fnd = D_DEVICE; - - memset(&SearchDir, 0, sizeof(struct dirent)); - SAttr = (BYTE) attr; #if defined(FIND_DEBUG) printf("Remote Find: n='%Fs\n", PriPathName); #endif - fmemcpy(&sda_tmp_dm, dta, 21); dta = &sda_tmp_dm; + memset(&sda_tmp_dm, 0, sizeof(dmatch)+sizeof(struct dirent)); if (rc & IS_NETWORK) rc = remote_findfirst(current_ldt); @@ -1074,10 +1067,11 @@ COUNT DosFindFirst(UCOUNT attr, BYTE FAR * name) rc = dos_findfirst(attr, PriPathName); dta = dmp; - fmemcpy(dta, &sda_tmp_dm, 21); - pop_dmp(dmp); - if (rc != SUCCESS) - dmp->dm_attr_fnd = D_DEVICE; /* mark invalid */ + if (rc == SUCCESS) + { + fmemcpy(dta, &sda_tmp_dm, 21); + pop_dmp(dmp); + } return rc; } @@ -1111,14 +1105,17 @@ COUNT DosFindNext(void) printf("findnext: %d\n", dmp->dm_drive); #endif fmemcpy(&sda_tmp_dm, dmp, 21); - fmemset(dmp, 0, sizeof(*dmp)); + memset(&SearchDir, 0, sizeof(struct dirent)); dta = &sda_tmp_dm; rc = (sda_tmp_dm.dm_drive & 0x80) ? remote_findnext(&sda_tmp_dm) : dos_findnext(); dta = dmp; - fmemcpy(dmp, &sda_tmp_dm, 21); - pop_dmp(dmp); + if (rc == SUCCESS) + { + fmemcpy(dmp, &sda_tmp_dm, 21); + pop_dmp(dmp); + } return rc; } From ef3e38de7b01b06b1ec695050c8cba625fee2bee Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Tue, 2 Dec 2003 23:34:43 +0000 Subject: [PATCH 332/671] Rename blockio by rqblockio (namespace conflict with dsk.c) git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@734 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/fatfs.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/kernel/fatfs.c b/kernel/fatfs.c index 4244f912..ee691c7f 100644 --- a/kernel/fatfs.c +++ b/kernel/fatfs.c @@ -2064,7 +2064,7 @@ ckok:; #endif } -STATIC int blockio(unsigned char command, struct dpb FAR * dpbp) +STATIC int rqblockio(unsigned char command, struct dpb FAR * dpbp) { retry: MediaReqHdr.r_length = sizeof(request); @@ -2101,7 +2101,7 @@ COUNT media_check(REG struct dpb FAR * dpbp) return DE_INVLDDRV; /* First test if anyone has changed the removable media */ - ret = blockio(C_MEDIACHK, dpbp); + ret = rqblockio(C_MEDIACHK, dpbp); if (ret < SUCCESS) return ret; @@ -2122,7 +2122,7 @@ COUNT media_check(REG struct dpb FAR * dpbp) case M_CHANGED: default: setinvld(dpbp->dpb_unit); - ret = blockio(C_BLDBPB, dpbp); + ret = rqblockio(C_BLDBPB, dpbp); if (ret < SUCCESS) return ret; #ifdef WITHFAT32 From f1f51592ba7f3a689aca38fd33cd5e4a31da38c1 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Tue, 2 Dec 2003 23:46:03 +0000 Subject: [PATCH 333/671] MSC/TurboC compatibility fixes (Luchezar/Bart) git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@735 6ac86273-5f31-0410-b378-82cca8765d1b --- hdr/algnbyte.h | 1 - hdr/portab.h | 3 +++ kernel/inthndlr.c | 2 +- kernel/prf.c | 4 ++-- kernel/proto.h | 1 - 5 files changed, 6 insertions(+), 5 deletions(-) diff --git a/hdr/algnbyte.h b/hdr/algnbyte.h index adb0e5d4..e66c2e30 100644 --- a/hdr/algnbyte.h +++ b/hdr/algnbyte.h @@ -1,6 +1,5 @@ #if defined(_MSC_VER) -#define asm __asm #if _MSC_VER >= 700 #pragma warning(disable:4103) #endif diff --git a/hdr/portab.h b/hdr/portab.h index 3e87e73a..9e41ea2e 100644 --- a/hdr/portab.h +++ b/hdr/portab.h @@ -69,6 +69,9 @@ void __int__(int); #elif defined (_MSC_VER) #define I86 +#define asm __asm +#pragma warning(disable: 4761) /* "integral size mismatch in argument; + conversion supplied" */ #define CDECL _cdecl #define PASCAL pascal #define __int__(intno) asm int intno; diff --git a/kernel/inthndlr.c b/kernel/inthndlr.c index 094c68b1..67594583 100644 --- a/kernel/inthndlr.c +++ b/kernel/inthndlr.c @@ -1928,7 +1928,7 @@ VOID ASMCFUNC int2F_12_handler(struct int2f12regs r) { int rel_idx = idx_to_sft_(r.bx); - if (rel_idx == (size_t) - 1) + if (rel_idx == -1) { r.flags |= FLG_CARRY; break; diff --git a/kernel/prf.c b/kernel/prf.c index c9d1491b..ff0364b8 100644 --- a/kernel/prf.c +++ b/kernel/prf.c @@ -57,7 +57,7 @@ static BYTE *prfRcsId = static int buff_offset = 0; static char buff[MAX_BUFSIZE]; -VOID put_console(COUNT c) +STATIC VOID put_console(COUNT c) { if (buff_offset >= MAX_BUFSIZE) { @@ -91,7 +91,7 @@ VOID put_console(COUNT c) } } #else -VOID put_console(COUNT c) +STATIC VOID put_console(COUNT c) { if (c == '\n') put_console('\r'); diff --git a/kernel/proto.h b/kernel/proto.h index c82c76a8..924d3671 100644 --- a/kernel/proto.h +++ b/kernel/proto.h @@ -279,7 +279,6 @@ UWORD ASMCFUNC syscall_MUX14(DIRECT_IREGS); int CDECL printf(CONST BYTE * fmt, ...); int CDECL sprintf(BYTE * buff, CONST BYTE * fmt, ...); #endif -VOID put_console(COUNT c); VOID hexd(char *title, VOID FAR * p, COUNT numBytes); void put_unsigned(unsigned n, int base, int width); void put_string(const char *s); From b92f552a5701a7b18b8d25a700ebf1a18d5a173c Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sat, 13 Dec 2003 03:07:49 +0000 Subject: [PATCH 334/671] Better (for FAT32) and simpler FAT default value calculations. Also use 16-bit instead of 32-bit quantities where possible to save code size. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@743 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/initdisk.c | 60 +++++++++++++++++++++++------------------------ 1 file changed, 29 insertions(+), 31 deletions(-) diff --git a/kernel/initdisk.c b/kernel/initdisk.c index 923b4e6a..5777ec59 100644 --- a/kernel/initdisk.c +++ b/kernel/initdisk.c @@ -381,7 +381,6 @@ void printCHS(char *title, struct CHS *chs) */ VOID CalculateFATData(ddt FAR * pddt, ULONG NumSectors, UBYTE FileSystem) { - ULONG fatlength, maxclust, clust; UBYTE maxclustsize; ULONG fatdata; @@ -408,31 +407,30 @@ VOID CalculateFATData(ddt FAR * pddt, ULONG NumSectors, UBYTE FileSystem) case FAT12: case FAT12_LBA: + { + unsigned fatdat, fatlength, clust, maxclust; /* in DOS, FAT12 defaults to 4096kb (8 sector) - clusters. */ defbpb->bpb_nsector = 8; /* Force maximal fatdata=32696 sectors since with our only possible sector size (512 bytes) this is the maximum for 4k clusters. #clus*secperclus+#fats*fatlength= 4077 * 8 + 2 * 12 = 32640. max FAT12 size for FreeDOS = 16,728,064 bytes */ + fatdat = (unsigned)fatdata; if (fatdata > 32640) - fatdata = 32640; - /* The factor 2 below avoids cut-off errors for nr_fats == 1. - * The "defbpb->bpb_nfat*3" is for the reserved first two FAT entries */ - clust = - 2 * ((ULONG) fatdata * defbpb->bpb_nbyte + - defbpb->bpb_nfat * 3) / (2 * (ULONG) defbpb->bpb_nsector * - defbpb->bpb_nbyte + - defbpb->bpb_nfat * 3); - fatlength = cdiv(((clust + 2) * 3 + 1) >> 1, defbpb->bpb_nbyte); - /* Need to recalculate number of clusters, since the unused parts of the + fatdat = 32640; + /* The "+2*defbpb->bpb_nsector" is for the reserved first two FAT entries */ + fatlength = cdiv(fatdat + 2 * defbpb->bpb_nsector, + defbpb->bpb_nbyte * 2 * defbpb->bpb_nsector / 3 + + defbpb->bpb_nfat); + /* Need to calculate number of clusters, since the unused parts of the * FATS and data area together could make up space for an additional, * not really present cluster. */ clust = - (fatdata - defbpb->bpb_nfat * fatlength) / defbpb->bpb_nsector; + (fatdat - defbpb->bpb_nfat * fatlength) / defbpb->bpb_nsector; maxclust = (fatlength * 2 * defbpb->bpb_nbyte) / 3; if (maxclust > FAT12MAX) maxclust = FAT12MAX; - DebugPrintf(("FAT12: #clu=%lu, fatlen=%lu, maxclu=%lu, limit=%u\n", + DebugPrintf(("FAT12: #clu=%u, fatlength=%u, maxclu=%u, limit=%u\n", clust, fatlength, maxclust, FAT12MAX)); if (clust > maxclust - 2) { @@ -442,10 +440,13 @@ VOID CalculateFATData(ddt FAR * pddt, ULONG NumSectors, UBYTE FileSystem) defbpb->bpb_nfsect = fatlength; fmemcpy(pddt->ddt_fstype, MSDOS_FAT12_SIGN, 8); break; - + } case FAT16SMALL: case FAT16LARGE: case FAT16_LBA: + { + unsigned fatlength; + unsigned long clust, maxclust; /* FAT16: start at 4 sectors per cluster */ defbpb->bpb_nsector = 4; /* Force maximal fatdata=8387584 sectors (NumSectors=8387617) @@ -460,13 +461,10 @@ VOID CalculateFATData(ddt FAR * pddt, ULONG NumSectors, UBYTE FileSystem) DebugPrintf(("Trying with %d sectors/cluster:\n", defbpb->bpb_nsector)); - clust = - ((ULONG) fatdata * defbpb->bpb_nbyte + - defbpb->bpb_nfat * 4) / ((ULONG) defbpb->bpb_nsector * - defbpb->bpb_nbyte + - defbpb->bpb_nfat * 2); - fatlength = cdiv((clust + 2) * 2, defbpb->bpb_nbyte); - /* Need to recalculate number of clusters, since the unused parts of the + fatlength = (unsigned)cdiv(fatdata + 2 * defbpb->bpb_nsector, + (ULONG)defbpb->bpb_nbyte * defbpb->bpb_nsector / 2 + + defbpb->bpb_nfat); + /* Need to calculate number of clusters, since the unused parts of the * FATS and data area together could make up space for an additional, * not really present cluster. */ clust = @@ -474,7 +472,7 @@ VOID CalculateFATData(ddt FAR * pddt, ULONG NumSectors, UBYTE FileSystem) maxclust = (fatlength * defbpb->bpb_nbyte) / 2; if (maxclust > FAT16MAX) maxclust = FAT16MAX; - DebugPrintf(("FAT16: #clu=%lu, fatlen=%lu, maxclu=%lu, limit=%u\n", + DebugPrintf(("FAT16: #clu=%lu, fatlen=%u, maxclu=%lu, limit=%u\n", clust, fatlength, maxclust, FAT_MAGIC16)); if (clust > maxclust - 2) { @@ -496,24 +494,23 @@ VOID CalculateFATData(ddt FAR * pddt, ULONG NumSectors, UBYTE FileSystem) defbpb->bpb_nfsect = fatlength; fmemcpy(pddt->ddt_fstype, MSDOS_FAT16_SIGN, 8); break; - + } #ifdef WITHFAT32 case FAT32: case FAT32_LBA: + { + unsigned long fatlength, clust, maxclust; + /* For FAT32, use 4k clusters on sufficiently large file systems, * otherwise 1 sector per cluster. This is also what M$'s format * command does for FAT32. */ defbpb->bpb_nsector = (NumSectors >= 512 * 1024ul ? 8 : 1); do { - /* simple calculation - no long long available */ - clust = (ULONG) fatdata / defbpb->bpb_nsector; - /* this calculation below yields a smaller value - the above is non-optimal - but should not be dangerous */ - /* clust = ((long long) fatdata *defbpb->bpb_nbyte + defbpb->bpb_nfat*8) / - ((int) defbpb->bpb_nsector * defbpb->bpb_nbyte + defbpb->bpb_nfat*4); */ - fatlength = cdiv((clust + 2) * 4, defbpb->bpb_nbyte); - /* Need to recalculate number of clusters, since the unused parts of the + fatlength = cdiv(fatdata + 2 * defbpb->bpb_nsector, + (ULONG)defbpb->bpb_nbyte * defbpb->bpb_nsector / 4 + + defbpb->bpb_nfat); + /* Need to calculate number of clusters, since the unused parts of the * FATS and data area together could make up space for an additional, * not really present cluster. */ clust = @@ -543,6 +540,7 @@ VOID CalculateFATData(ddt FAR * pddt, ULONG NumSectors, UBYTE FileSystem) defbpb->bpb_xbackupsec = 6; fmemcpy(pddt->ddt_fstype, MSDOS_FAT32_SIGN, 8); break; + } #endif } pddt->ddt_fstype[8] = '\0'; From 090b5892220c2146b5996b3bebed83893b2701f1 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sat, 17 Jan 2004 17:30:12 +0000 Subject: [PATCH 335/671] Bump version number to 2033. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@744 6ac86273-5f31-0410-b378-82cca8765d1b --- hdr/version.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/hdr/version.h b/hdr/version.h index c8d9c43e..99398dca 100644 --- a/hdr/version.h +++ b/hdr/version.h @@ -47,8 +47,8 @@ static BYTE *date_hRcsId = #define REVISION_MAJOR 1 #define REVISION_MINOR 1 -#define REVISION_SEQ 32 -#define BUILD "2032" -#define SUB_BUILD "a" -#define KERNEL_VERSION_STRING "1.1.32a" /*#REVISION_MAJOR "." #REVISION_MINOR "." #REVISION_SEQ */ -#define KERNEL_BUILD_STRING "2032a" /*#BUILD SUB_BUILD */ +#define REVISION_SEQ 33 +#define BUILD "2033" +#define SUB_BUILD "" +#define KERNEL_VERSION_STRING "1.1.33" /*#REVISION_MAJOR "." #REVISION_MINOR "." #REVISION_SEQ */ +#define KERNEL_BUILD_STRING "2033" /*#BUILD SUB_BUILD */ From 36101b0d51c7ce612b65dff8ebc80677253eca0e Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sun, 25 Jan 2004 17:52:11 +0000 Subject: [PATCH 336/671] Fix missing (unsigned long) cast for multiplication: this fixes the FAT16 calculation for the default bpb. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@745 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/initdisk.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/initdisk.c b/kernel/initdisk.c index 5777ec59..bc9fdebd 100644 --- a/kernel/initdisk.c +++ b/kernel/initdisk.c @@ -469,7 +469,7 @@ VOID CalculateFATData(ddt FAR * pddt, ULONG NumSectors, UBYTE FileSystem) * not really present cluster. */ clust = (fatdata - defbpb->bpb_nfat * fatlength) / defbpb->bpb_nsector; - maxclust = (fatlength * defbpb->bpb_nbyte) / 2; + maxclust = ((unsigned long)fatlength * defbpb->bpb_nbyte) / 2; if (maxclust > FAT16MAX) maxclust = FAT16MAX; DebugPrintf(("FAT16: #clu=%lu, fatlen=%u, maxclu=%lu, limit=%u\n", From 01d58b2836cd95ded651722f0f74bea6aff2b16e Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sun, 25 Jan 2004 21:44:17 +0000 Subject: [PATCH 337/671] ~1K size reduction for sys.com by using Tom's talloc.c malloc/free functions and using our own filelength for watcomc. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@746 6ac86273-5f31-0410-b378-82cca8765d1b --- filelist | 1 + sys/makefile | 5 +- sys/sys.c | 19 ++++- sys/talloc.c | 221 +++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 244 insertions(+), 2 deletions(-) create mode 100644 sys/talloc.c diff --git a/filelist b/filelist index 9f4f989b..2e482878 100644 --- a/filelist +++ b/filelist @@ -146,6 +146,7 @@ */*/sys/bin2c.c */*/sys/makefile */*/sys/sys.c +*/*/sys/talloc.c */*/utils/echoto.bat */*/utils/exeflat.c */*/utils/indent.ini diff --git a/sys/makefile b/sys/makefile index 4fab1f2c..ed4aad9e 100644 --- a/sys/makefile +++ b/sys/makefile @@ -14,7 +14,8 @@ NASMFLAGS = -DSYS=1 SYS_EXE_dependencies = \ sys.obj \ fdkrncfg.obj \ - prf.obj + prf.obj \ + talloc.obj # *Explicit Rules* production: bin2c.com ..\bin\sys.com @@ -42,6 +43,8 @@ prf.obj: ..\kernel\prf.c fdkrncfg.obj: fdkrncfg.c ..\hdr\kconfig.h +talloc.obj: talloc.c + sys.com: $(SYS_EXE_dependencies) $(CL) $(CFLAGST) $(TINY) $(SYS_EXE_dependencies) diff --git a/sys/sys.c b/sys/sys.c index 09887887..a7fa29ff 100644 --- a/sys/sys.c +++ b/sys/sys.c @@ -75,7 +75,24 @@ extern WORD CDECL sprintf(BYTE * buff, CONST BYTE * fmt, ...); #else -extern long filelength(int __handle); +long filelength(int __handle); +#pragma aux filelength = \ + "mov ax, 0x4202" \ + "xor cx, cx" \ + "xor dx, dx" \ + "int 0x21" \ + "push ax" \ + "push dx" \ + "mov ax, 0x4200" \ + "xor cx, cx" \ + "xor dx, dx" \ + "int 0x21" \ + "pop dx" \ + "pop ax" \ + parm [bx] \ + modify [cx] \ + value [dx ax]; + extern int unlink(const char *pathname); /* some non-conforming functions to make the executable smaller */ diff --git a/sys/talloc.c b/sys/talloc.c new file mode 100644 index 00000000..0e3601fe --- /dev/null +++ b/sys/talloc.c @@ -0,0 +1,221 @@ +/** + ** TALLOC.C + ** + ** lean_and_mean malloc()/free implementation + ** by tom ehlert, te@drivesnapshot.de + ** + ** please be careful: + ** + ** this is only slightly tested and has NO ERRORCHECCKING AT ALL + ** no internal checking. no stack checking. nothing !! + ** + ** use it only, if your programs are already debugged !! + **/ + +#include +#include + +#ifdef __TURBOC__ +extern void *__brklvl; +#define sbrk(x) __brklvl +#define brk(newbrk) \ + (((char *)(newbrk) > (char *)(&length) - 0x200) ? \ + -1 : \ + (__brklvl = (newbrk), 0)) +#endif + +#ifdef __WATCOMC__ +#include +#define brk(newbrk) ((int)__brk((unsigned)(newbrk))) +#endif + +#ifdef __GNUC__ +#include +#endif + +#define BUSY (sizeof(size_t)-1) /* Bit set if memory block in use*/ +#define isbusy(x) ((x->length)&BUSY) + + +/** +*** _memavl() +*** return max. memory available +*** Q & D +**/ + +#ifdef DEBUG +extern int printf(const char *x, ...); +#define dbprintf(x) printf x +#else +#define dbprintf(x) +#endif +/*#define printf getch() != ' ' ? exit(0) : printf*/ + +typedef union { + size_t length; + char data[1]; +} block; + +void *malloc(size_t length) +{ + static block *alloc_bottom = NULL; + + block *akt, *next; + block *ltop = sbrk(0); + + if (alloc_bottom == NULL) + alloc_bottom = ltop; + + length = (length + sizeof(size_t) + BUSY) & ~BUSY; + + akt = alloc_bottom; + for (;;) + { + if (akt == ltop) + { + /* end of initialized memory */ + next = (block *)&akt->data[length]; + if (next < akt || brk(next) == -1) + return NULL; + break; + } + dbprintf(("follow [%x] = %x\n",akt, akt->length)); + next = (block *)(&akt->data[akt->length & ~BUSY]); + if (next == ltop || isbusy(akt)) + { + akt = next; /* next block */ + } + else if (isbusy(next)) + { + size_t size = akt->length; + if (size >= length) /* try to split */ + { + if (size > length) /* split */ + { + ((block *)&akt->data[length])->length = + size - length; + } + break; + } + akt = next; /* next block */ + } + else + { + /* merge 2 blocks */ + akt->length += next->length; + } + } + akt->length = length | BUSY; + dbprintf(("set [%x] = %x\n",akt,akt->length)); + return &akt->data[sizeof(size_t)]; +} + +#ifdef __WATCOMC__ +void *_nmalloc(unsigned length) +{ + return malloc(length); +} +#endif + +/** + ** reset busy-bit + **/ + +void free(void *ptr) +{ + if (ptr) + ((char *) ptr)[-sizeof(size_t)] &= ~BUSY; +} + +#ifdef TALLOC_NEED_REALLOC + +/* there isn't often need for realloc ;) + */ + +void* realloc(void *ptr,size_t newlength) +{ + size_t oldlength = ((size_t*)ptr)[-1] & ~BUSY; + void *newptr; + + newptr = malloc(newlength); + + if (newptr == NULL) + { + if (newlength <= oldlength) + return ptr; + } + else + { + memcpy(newptr,ptr,oldlength); + } + + free(ptr); + return newptr; +} +#endif + +#ifdef TEST +#include + +int gallocated = 0; + +void *testalloc(size_t length) +{ + void *p; + + printf("alloc %x bytes - ",length); + + p = malloc(length); + + if (p) gallocated += length,printf("at %x - sum=%x\n",p,gallocated); + else printf("failed\n"); + return p; +} +void testfree(void* p) +{ + gallocated -= ((size_t*)p)[-1] & ~BUSY; + printf("free %x \n",p); + + free(p); +} + + + +main() +{ + char *s1,*s2,*s3,*s4,*s5,*s6; + unsigned size; + + s1 = testalloc(1); + s2 = testalloc(2); + s3 = testalloc(0x10); + s4 = testalloc(0x100); + s5 = testalloc(0x1000); + s6 = testalloc(0xfff0); + + testfree(s3); + s3 = testalloc(6); + testfree(s2); + testalloc(8); + +#ifdef __GNUC__ + for(size = 0xe0000000; size;) +#else + for(size = 0xe000; size;) +#endif + { + if (testalloc(size)) + ; + else + size >>= 1; + } + + + testfree(s1); + testfree(s5); + testfree(s4); + testfree(s6); + + return 1; +} +#endif From ee60fb10b8d6b8636487d8a26c92436b77ac65ba Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sun, 25 Jan 2004 22:12:30 +0000 Subject: [PATCH 338/671] From Lucho: implement --------D-2F1211----------------------------- INT 2F U - DOS 3.0+ internal - NORMALIZE ASCIZ FILENAME git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@747 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/inthndlr.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/kernel/inthndlr.c b/kernel/inthndlr.c index 67594583..e9e9cf8a 100644 --- a/kernel/inthndlr.c +++ b/kernel/inthndlr.c @@ -1905,6 +1905,27 @@ VOID ASMCFUNC int2F_12_handler(struct int2f12regs r) r.dx = dos_gettime(); break; + case 0x11: /* normalise ASCIIZ filename */ + { + char c; + char FAR *s = MK_FP(r.ds, r.si); + char FAR *t = MK_FP(r.es, r.di); + + do + { + c = *s++; + /* uppercase character */ + /* for now, ASCII only because nls.c cannot handle DS!=SS */ + if (c >= 'a' && c <= 'z') + c -= 'a' - 'A'; + else if (c == '/') + c = '\\'; + *t++ = c; + } + while (c); + break; + } + case 0x12: /* get length of asciiz string */ r.cx = fstrlen(MK_FP(r.es, r.di)) + 1; From 6534691f858fb99f3120d9ebb6a8b2f3ed8b7ef1 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sun, 25 Jan 2004 22:20:48 +0000 Subject: [PATCH 339/671] from Lucho: basic implementation of --------D-2F4A33----------------------------- INT 2F - Windows95 - CHECK MS-DOS VERSION 7 necessary for SpinRite (Steve Gibson) git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@748 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/int2f.asm | 8 +++++++- mkfiles/generic.mak | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/kernel/int2f.asm b/kernel/int2f.asm index f89295f5..d73f1a0e 100644 --- a/kernel/int2f.asm +++ b/kernel/int2f.asm @@ -63,7 +63,13 @@ Int2f3: je IntDosCal ; Dos Internal calls cmp ax,4a02h je IntDosCal ; Dos Internal calls - +%ifdef WITHFAT32 + cmp ax,4a33h ; Check DOS version 7 + jne Check4Share + xor ax,ax ; no undocumented shell strings + iret +Check4Share: +%endif cmp ah,10h ; SHARE.EXE interrupt? je Int2f1 ; yes, do installation check cmp ah,08h diff --git a/mkfiles/generic.mak b/mkfiles/generic.mak index 34a3ea0c..f30bdc12 100644 --- a/mkfiles/generic.mak +++ b/mkfiles/generic.mak @@ -16,6 +16,7 @@ TARGETOPT=-3 !if $(XFAT) == 32 ALLCFLAGS=$(ALLCFLAGS) -DWITHFAT32 +NASMFLAGS=$(NASMFLAGS) -DWITHFAT32 !endif NASM=$(XNASM) From c0a292ae04b96e4289dce714d68aaa2b2dc25683 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sun, 25 Jan 2004 22:35:53 +0000 Subject: [PATCH 340/671] From Lucho: the DJ mechanism needs to affect --------D-M00500004-------------------------- MEM 0050h:0004h - MS-DOS - LOGICAL DRIVE FOR SINGLE-FLOPPY SYSTEM (A: / B:) Size: BYTE git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@749 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/dsk.c | 1 + 1 file changed, 1 insertion(+) diff --git a/kernel/dsk.c b/kernel/dsk.c index d4167925..373420c4 100644 --- a/kernel/dsk.c +++ b/kernel/dsk.c @@ -227,6 +227,7 @@ STATIC WORD play_dj(ddt * pddt) fl_readkey(); pddt2->ddt_descflags &= ~DF_CURLOG; pddt->ddt_descflags |= DF_CURLOG; + pokeb(0, 0x504, pddt->ddt_logdriveno); return M_CHANGED; } return M_NOT_CHANGED; From 3819d769a7b97d1feafa9785468de1a2ffab8702 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sun, 25 Jan 2004 22:37:20 +0000 Subject: [PATCH 341/671] From Lucho: clean up *.lnk files for "clean" and "clobber". git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@750 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/makefile b/kernel/makefile index 2522489c..352dab19 100644 --- a/kernel/makefile +++ b/kernel/makefile @@ -62,7 +62,7 @@ clobber: clean -$(RM) kernel.exe kernel.sys status.me clean: - -$(RM) *.res *.obj *.bak *.crf *.xrf *.map *.lst *.cod *.err + -$(RM) *.res *.obj *.bak *.crf *.xrf *.map *.lst *.cod *.err *.lnk # XXX: This is a very ugly way of linking the kernel, forced upon us by the # inability of Turbo `make' 2.0 to perform command line redirection. -- ror4 From 677bac348103d0232813030789e8fd2b1b89f70d Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Mon, 26 Jan 2004 00:40:41 +0000 Subject: [PATCH 342/671] From Lucho: SYS 3.0 changes: added /L parameter to SYS to be able to change the kernel boot segment + a few boot sector changes to get the pointer at the same magic place for all boot sectors. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@751 6ac86273-5f31-0410-b378-82cca8765d1b --- boot/boot.asm | 9 +++++---- boot/boot32.asm | 9 +++++---- boot/boot32lb.asm | 23 +++++++++++------------ sys/sys.c | 25 ++++++++++++++++++++----- 4 files changed, 41 insertions(+), 25 deletions(-) diff --git a/boot/boot.asm b/boot/boot.asm index 84829336..af2c527e 100644 --- a/boot/boot.asm +++ b/boot/boot.asm @@ -139,10 +139,8 @@ Entry: jmp short real_start times 0x3E-$+$$ db 0 -%define loadsegoff_60 bp+0x3E - dw 0 -%define loadseg_60 bp+0x40 - dw LOADSEG +%define loadsegoff_60 bp+loadseg_off-Entry +%define loadseg_60 bp+loadseg_seg-Entry ;%define LBA_PACKET bp+0x42 ; db 10h ; size of packet @@ -199,6 +197,9 @@ real_start: rep movsw jmp word 0x1FE0:cont +loadseg_off dw 0 +loadseg_seg dw LOADSEG + cont: mov ds, ax mov ss, ax diff --git a/boot/boot32.asm b/boot/boot32.asm index 06eeae67..8ac4f3c6 100644 --- a/boot/boot32.asm +++ b/boot/boot32.asm @@ -65,10 +65,8 @@ Entry: jmp short real_start %define fat_sector bp+0x48 ; last accessed sector of the FAT -%define loadsegoff_60 bp+0x5a ; FAR pointer = 60:0 - dw 0 -%define loadseg_60 bp+0x5c - dw LOADSEG +%define loadsegoff_60 bp+loadseg_off-Entry ; FAR pointer = 60:0 +%define loadseg_60 bp+loadseg_seg-Entry %define fat_start bp+0x5e ; first FAT sector %define data_start bp+0x62 ; first data sector @@ -93,6 +91,9 @@ real_start: cld rep movsw ; move boot code to the 0x1FE0:0x0000 jmp word 0x1FE0:cont +loadseg_off dw 0 +loadseg_seg dw LOADSEG + cont: mov ds, ax mov ss, ax lea sp, [bp-0x20] diff --git a/boot/boot32lb.asm b/boot/boot32lb.asm index 2795f898..aa1631bd 100644 --- a/boot/boot32lb.asm +++ b/boot/boot32lb.asm @@ -81,6 +81,7 @@ Entry: jmp short real_start ; +0x32 dw -1 or sector number of boot sector backup ; (+0x34 .. +0x3f reserved) %define drive bp+0x40 ; Drive number +%define loadsegoff_60 bp+loadseg_off-Entry %define LOADSEG 0x0060 @@ -107,24 +108,27 @@ Entry: jmp short real_start ;----------------------------------------------------------------------- real_start: cld + cli sub ax, ax mov ds, ax - lss sp, [mystack] ; initialize stack - int 0x13 ; reset drive + mov bp, 0x7c00 mov ax, 0x1FE0 mov es, ax - mov si, sp - mov di, sp - mov bp, sp ; bp-relative parameter addresses used + mov si, bp + mov di, bp mov cx, 0x0100 rep movsw ; move boot code to the 0x1FE0:0x0000 jmp word 0x1FE0:cont +loadseg_off dw 0, LOADSEG + ; ------------- cont: mov ds, ax mov ss, ax ; stack and BP-relative moves up, too + lea sp, [bp-0x20] + sti mov [drive], dl ; BIOS passes drive number in DL mov si, msg_LoadFreeDOS @@ -177,9 +181,7 @@ ff_next_clust: push eax ; save cluster jc boot_error ; EOC encountered ; EDX is clust/sector, EAX is sector -ff_next_sector: mov bx, LOADSEG - mov es, bx - sub bx, bx ; load to loadseg:0 +ff_next_sector: les bx, [loadsegoff_60] ; load to loadseg:0 call readDisk ;--- push eax ; save sector @@ -233,7 +235,7 @@ rk_walk_fat: pop eax ;----------------------------------------------------------------------- boot_success: mov bl, [drive] - jmp word LOADSEG:0 + jmp far [loadsegoff_60] ;----------------------------------------------------------------------- @@ -389,9 +391,6 @@ no_incr_es: pop di msg_LoadFreeDOS db "Loading FreeDOS ",0 -mystack dw 0x7c00 ; the 0 for SS overlaps into pad bytes! - ; (so we can LSS SP to 0:7c00) - times 0x01ee-$+$$ db 0 msg_BootError db "No " diff --git a/sys/sys.c b/sys/sys.c index a7fa29ff..317b1ac0 100644 --- a/sys/sys.c +++ b/sys/sys.c @@ -29,7 +29,7 @@ #define DEBUG /* #define DDEBUG */ -#define SYS_VERSION "v2.9" +#define SYS_VERSION "v3.0" #include #include @@ -159,7 +159,7 @@ char *getenv(const char *name) BYTE pgm[] = "SYS"; -void put_boot(int, char *, char *, int); +void put_boot(int, char *, char *, int, int); BOOL check_space(COUNT, ULONG); BOOL copy(COUNT drive, BYTE * srcPath, BYTE * rootPath, BYTE * file); @@ -254,6 +254,7 @@ int main(int argc, char **argv) int bootonly = 0; int both = 0; char *kernel_name = "KERNEL.SYS"; + int load_segment = 0x60; printf("FreeDOS System Installer " SYS_VERSION ", " __DATE__ "\n\n"); @@ -278,6 +279,11 @@ int main(int argc, char **argv) argno++; kernel_name = argv[argno]; } + else if (argp[0] == '/' && toupper(argp[1]) == 'L' && argno + 1 < argc) + { + argno++; + load_segment = (int)strtol(argv[argno], NULL, 16); + } else if (memicmp(argp, "BOOTONLY", 8) == 0 && !bootonly) { bootonly = 1; @@ -303,7 +309,7 @@ int main(int argc, char **argv) if (drivearg == 0) { printf( - "Usage: %s [source] drive: [bootsect [BOTH]] [BOOTONLY] [/K name]\n" + "Usage: %s [source] drive: [bootsect [BOTH]] [BOOTONLY] [/K name] [/L segm]\n" " source = A:,B:,C:\\KERNEL\\BIN\\,etc., or current directory if not given\n" " drive = A,B,etc.\n" " bootsect = name of 512-byte boot sector file image for drive:\n" @@ -311,6 +317,7 @@ int main(int argc, char **argv) " BOTH : write to *both* the real boot sector and the image file\n" " BOOTONLY : do *not* copy kernel / shell, only update boot sector or image\n" " /K name : name of kernel to use instead of KERNEL.SYS\n" + " /L segm : hex load segment to use instead of 60\n" "%s CONFIG /help\n", pgm, pgm); exit(1); } @@ -362,7 +369,7 @@ int main(int argc, char **argv) sprintf(rootPath, "%c:\\", 'A' + srcDrive); printf("Processing boot sector...\n"); - put_boot(drive, bsFile, kernel_name, both); + put_boot(drive, bsFile, kernel_name, load_segment, both); if (!bootonly) { @@ -662,7 +669,7 @@ BOOL haveLBA(void) } #endif -void put_boot(int drive, char *bsFile, char *kernel_name, int both) +void put_boot(int drive, char *bsFile, char *kernel_name, int load_seg, int both) { #ifdef WITHFAT32 struct bootsectortype32 *bs32; @@ -756,6 +763,12 @@ void put_boot(int drive, char *bsFile, char *kernel_name, int both) bs32 = (struct bootsectortype32 *)&newboot; /* put 0 for A: or B: (force booting from A:), otherwise use DL */ bs32->bsDriveNumber = drive < 2 ? 0 : 0xff; + /* the location of the "0060" segment portion of the far pointer + in the boot sector is just before cont: in boot*.asm. + This happens to be offset 0x78 (=0x3c * 2) for FAT32 and + offset 0x5c (=0x2e * 2) for FAT16 */ + /* i.e. BE CAREFUL WHEN YOU CHANGE THE BOOT SECTORS !!! */ + ((int *)newboot)[0x3C] = load_seg; #ifdef DEBUG printf(" FAT starts at sector %lx + %x\n", bs32->bsHiddenSecs, bs32->bsResSectors); @@ -766,6 +779,7 @@ void put_boot(int drive, char *bsFile, char *kernel_name, int both) { /* put 0 for A: or B: (force booting from A:), otherwise use DL */ bs->bsDriveNumber = drive < 2 ? 0 : 0xff; + ((int *)newboot)[0x2E] = load_seg; } #ifdef DEBUG /* add an option to display this on user request? */ @@ -801,6 +815,7 @@ void put_boot(int drive, char *bsFile, char *kernel_name, int both) #ifdef DEBUG /* there's a zero past the kernel name in all boot sectors */ printf("Boot sector kernel name set to %s\n", &newboot[0x1f1]); + printf("Boot sector load segment set to %Xh\n", load_seg); #endif #ifdef DDEBUG From dacd24e52495a89a1a13c9052c150a5e362207ce Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Mon, 26 Jan 2004 00:47:56 +0000 Subject: [PATCH 343/671] Make strupr code unambiguous git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@752 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/config.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/kernel/config.c b/kernel/config.c index 00b84a98..001705f1 100644 --- a/kernel/config.c +++ b/kernel/config.c @@ -1672,8 +1672,10 @@ STATIC COUNT toupper(COUNT c) /* Convert string s to uppercase */ STATIC VOID strupr(char *s) { - while (*s) - *s++ = toupper(*s); + while (*s) { + *s = toupper(*s); + s++; + } } /* The following code is 8086 dependant */ From 4f1a1170691b34f541f2e004f317a7e163fafe32 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Mon, 26 Jan 2004 00:51:49 +0000 Subject: [PATCH 344/671] * FAT32 kernels should ignore the upper word of the cluster number for FAT16 partitions (just like FAT16 kernels do) * added extra checks to make sure that invalid FAT entries are never followed * made put_console() public to be able to print a message in case of FAT corruption * some small optimizations and header cleanups (some suggested by Arkady) git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@753 6ac86273-5f31-0410-b378-82cca8765d1b --- hdr/fat.h | 48 +++++++++++++++----------------------- kernel/fatdir.c | 2 +- kernel/fatfs.c | 62 ++++++++++++++++++++++++++++++++++++------------- kernel/fattab.c | 23 +++++++++++++----- kernel/prf.c | 5 ++-- kernel/proto.h | 1 + 6 files changed, 86 insertions(+), 55 deletions(-) diff --git a/hdr/fat.h b/hdr/fat.h index bba790f5..1c4747c4 100644 --- a/hdr/fat.h +++ b/hdr/fat.h @@ -57,11 +57,6 @@ static BYTE *fat_hRcsId = #define DELETED '\x5' /* if first char, delete file */ #define EXT_DELETED '\xe5' /* external deleted flag */ -/* FAT cluster to physical conversion macros */ -#define clus_add(cl_no) ((ULONG) (((ULONG) cl_no - 2L) \ - * (ULONG) cluster_size \ - + (ULONG) data_start)) - /* Test for 16 bit or 12 bit FAT */ #define SIZEOF_CLST16 2 #define SIZEOF_CLST32 4 @@ -70,8 +65,8 @@ static BYTE *fat_hRcsId = #define FREE 0x000 #ifdef WITHFAT32 -#define LONG_LAST_CLUSTER 0x0FFFFFFFl -#define LONG_BAD 0x0FFFFFF7l +#define LONG_LAST_CLUSTER 0x0FFFFFFFUL +#define LONG_BAD 0x0FFFFFF7UL #else #define LONG_LAST_CLUSTER 0xFFFF #define LONG_BAD 0xFFF7 @@ -86,8 +81,8 @@ static BYTE *fat_hRcsId = for FAT12; similar for 16 and 32 */ #define FAT_MAGIC 4085 -#define FAT_MAGIC16 ((unsigned)65525l) -#define FAT_MAGIC32 268435455l +#define FAT_MAGIC16 65525U +#define FAT_MAGIC32 268435455UL /* int ISFAT32(struct dpb FAR *dpbp);*/ #define ISFAT32(x) _ISFAT32(x) @@ -133,31 +128,26 @@ struct lfn_entry { /* */ #ifdef WITHFAT32 -#define getdstart(dentry) \ - (((ULONG)dentry.dir_start_high << 16) | dentry.dir_start) -#define setdstart(dentry, value) \ - dentry.dir_start = (UCOUNT)value; \ - dentry.dir_start_high = (UCOUNT)(value >> 16) -#define checkdstart(dentry, value) \ - (dentry.dir_start == (UCOUNT)value && \ - dentry.dir_start_high == (UCOUNT)(value >> 16)) +CLUSTER getdstart(struct dpb FAR *dpbp, struct dirent *dentry); +void setdstart(struct dpb FAR *dpbp, struct dirent *dentry, CLUSTER value); +BOOL checkdstart(struct dpb FAR *dpbp, struct dirent *dentry, CLUSTER value); #else -#define getdstart(dentry) \ - dentry.dir_start -#define setdstart(dentry, value) \ - dentry.dir_start = (UCOUNT)value -#define checkdstart(dentry, value) \ - (dentry.dir_start == (UCOUNT)value) +#define getdstart(dpbp, dentry) \ + ((dentry)->dir_start) +#define setdstart(dpbp, dentry, value) \ + (((dentry)->dir_start) = (UWORD)(value)) +#define checkdstart(dpbp, dentry, value) \ + (((dentry)->dir_start) == (UWORD)(value)) #endif #define DIR_NAME 0 #define DIR_EXT FNAME_SIZE -#define DIR_ATTRIB FNAME_SIZE+FEXT_SIZE -#define DIR_RESERVED FNAME_SIZE+FEXT_SIZE+1 -#define DIR_TIME FNAME_SIZE+FEXT_SIZE+11 -#define DIR_DATE FNAME_SIZE+FEXT_SIZE+13 -#define DIR_START FNAME_SIZE+FEXT_SIZE+15 -#define DIR_SIZE FNAME_SIZE+FEXT_SIZE+17 +#define DIR_ATTRIB (FNAME_SIZE+FEXT_SIZE) +#define DIR_RESERVED (FNAME_SIZE+FEXT_SIZE+1) +#define DIR_TIME (FNAME_SIZE+FEXT_SIZE+11) +#define DIR_DATE (FNAME_SIZE+FEXT_SIZE+13) +#define DIR_START (FNAME_SIZE+FEXT_SIZE+15) +#define DIR_SIZE (FNAME_SIZE+FEXT_SIZE+17) #define DIRENT_SIZE 32 diff --git a/kernel/fatdir.c b/kernel/fatdir.c index 6acdfc9e..f7239fb9 100644 --- a/kernel/fatdir.c +++ b/kernel/fatdir.c @@ -166,7 +166,7 @@ f_node_ptr dir_open(register const char *dirname) { /* make certain we've moved off */ /* root */ - dir_init_fnode(fnp, getdstart(fnp->f_dir)); + dir_init_fnode(fnp, getdstart(fnp->f_dpb, &fnp->f_dir)); } } return fnp; diff --git a/kernel/fatfs.c b/kernel/fatfs.c index ee691c7f..f04826f1 100644 --- a/kernel/fatfs.c +++ b/kernel/fatfs.c @@ -57,6 +57,34 @@ BOOL first_fat(f_node_ptr); COUNT map_cluster(f_node_ptr, COUNT); STATIC VOID shrink_file(f_node_ptr fnp); +#ifdef WITHFAT32 +CLUSTER getdstart(struct dpb FAR *dpbp, struct dirent *dentry) +{ + if (!ISFAT32(dpbp)) + return dentry->dir_start; + return (((CLUSTER)dentry->dir_start_high << 16) | dentry->dir_start); +} + +void setdstart(struct dpb FAR *dpbp, struct dirent *dentry, CLUSTER value) +{ + if (!ISFAT32(dpbp)) + { + dentry->dir_start = (UWORD)value; + return; + } + dentry->dir_start = (UWORD)value; + dentry->dir_start_high = (UWORD)(value >> 16); +} + +BOOL checkdstart(struct dpb FAR *dpbp, struct dirent *dentry, CLUSTER value) +{ + if (!ISFAT32(dpbp)) + return dentry->dir_start == (UWORD)value; + return (dentry->dir_start == (UWORD)value && + dentry->dir_start_high == (UWORD)(value >> 16)); +} +#endif + ULONG clus2phys(CLUSTER cl_no, struct dpb FAR * dpbp) { CLUSTER data = @@ -83,10 +111,12 @@ STATIC void init_direntry(struct dirent *dentry, unsigned attrib, struct dostime dt; dentry->dir_size = 0l; -#ifndef WITHFAT32 +#ifdef WITHFAT32 + dentry->dir_start_high = (UWORD)(cluster >> 16); +#else dentry->dir_start_high = 0; -#endif - setdstart((*dentry), cluster); +#endif + dentry->dir_start = (UWORD)cluster; dentry->dir_attrib = attrib; dentry->dir_case = 0; DosGetTime(&dt); @@ -236,7 +266,7 @@ long dos_open(char *path, unsigned flags, unsigned attrib) if (status != S_OPENED) { fnp->f_cluster = FREE; - setdstart(fnp->f_dir, FREE); + setdstart(fnp->f_dpb, &fnp->f_dir, FREE); fnp->f_cluster_offset = 0; } @@ -247,7 +277,7 @@ long dos_open(char *path, unsigned flags, unsigned attrib) merge_file_changes(fnp, status == S_OPENED); /* /// Added - Ron Cemer */ /* /// Moved from above. - Ron Cemer */ - fnp->f_cluster = getdstart(fnp->f_dir); + fnp->f_cluster = getdstart(fnp->f_dpb, &fnp->f_dir); fnp->f_cluster_offset = 0; return xlt_fnp(fnp) | ((long)status << 16); @@ -813,10 +843,10 @@ STATIC VOID wipe_out_clusters(struct dpb FAR * dpbp, CLUSTER st) STATIC VOID wipe_out(f_node_ptr fnp) { /* if already free or not valid file, just exit */ - if ((fnp == NULL) || checkdstart(fnp->f_dir, FREE)) + if ((fnp == NULL) || checkdstart(fnp->f_dpb, &fnp->f_dir, FREE)) return; - wipe_out_clusters(fnp->f_dpb, getdstart(fnp->f_dir)); + wipe_out_clusters(fnp->f_dpb, getdstart(fnp->f_dpb, &fnp->f_dir)); } STATIC BOOL find_free(f_node_ptr fnp) @@ -1155,7 +1185,7 @@ COUNT dos_mkdir(BYTE * dir) parent = 0; } #endif - setdstart(DirEntBuffer, parent); + setdstart(dpbp, &DirEntBuffer, parent); /* and put it out */ putdirent(&DirEntBuffer, &bp->b_buffer[DIRENT_SIZE]); @@ -1171,7 +1201,7 @@ COUNT dos_mkdir(BYTE * dir) { /* as we are overwriting it completely, don't read first */ - bp = getblockOver(clus2phys(getdstart(fnp->f_dir), dpbp) + idx, + bp = getblockOver(clus2phys(getdstart(dpbp, &fnp->f_dir), dpbp) + idx, dpbp->dpb_unit); #ifdef DISPLAY_GETBLOCK printf("DIR (dos_mkdir)\n"); @@ -1293,7 +1323,7 @@ STATIC BOOL first_fat(f_node_ptr fnp) /* BUG!! this caused wrong allocation, if file was created, then seeked, then written */ fnp->f_cluster = free_fat; - setdstart(fnp->f_dir, free_fat); + setdstart(fnp->f_dpb, &fnp->f_dir, free_fat); link_fat(fnp->f_dpb, free_fat, LONG_LAST_CLUSTER); /* Mark the directory so that the entry is updated */ @@ -1333,7 +1363,7 @@ COUNT map_cluster(REG f_node_ptr fnp, COUNT mode) /* If someone did a seek, but no writes have occured, we will */ /* need to initialize the fnode. */ - if ((mode == XFR_WRITE) && checkdstart(fnp->f_dir, FREE)) + if ((mode == XFR_WRITE) && checkdstart(fnp->f_dpb, &fnp->f_dir, FREE)) { /* If there are no more free fat entries, then we are full! */ if (!first_fat(fnp)) @@ -1346,7 +1376,7 @@ COUNT map_cluster(REG f_node_ptr fnp, COUNT mode) { /* Set internal index and cluster size. */ fnp->f_cluster = fnp->f_flags.f_ddir ? fnp->f_dirstart : - getdstart(fnp->f_dir); + getdstart(fnp->f_dpb, &fnp->f_dir); fnp->f_cluster_offset = 0; } @@ -1841,21 +1871,21 @@ CLUSTER dos_free(struct dpb FAR * dpbp) /* cluster start at 2 and run to max_cluster+2 */ REG CLUSTER i; REG CLUSTER cnt = 0; - CLUSTER max_cluster = dpbp->dpb_size + 1; + CLUSTER max_cluster = dpbp->dpb_size; #ifdef WITHFAT32 if (ISFAT32(dpbp)) { if (dpbp->dpb_xnfreeclst != XUNKNCLSTFREE) return dpbp->dpb_xnfreeclst; - max_cluster = dpbp->dpb_xsize + 1; + max_cluster = dpbp->dpb_xsize; } else #endif if (dpbp->dpb_nfreeclst != UNKNCLSTFREE) return dpbp->dpb_nfreeclst; - for (i = 2; i < max_cluster; i++) + for (i = 2; i <= max_cluster; i++) { if (next_cluster(dpbp, i) == 0) ++cnt; @@ -2192,7 +2222,7 @@ STATIC VOID shrink_file(f_node_ptr fnp) if (fnp->f_dir.dir_size == 0) { - setdstart(fnp->f_dir, FREE); + setdstart(dpbp, &fnp->f_dir, FREE); link_fat(dpbp, st, FREE); } else diff --git a/kernel/fattab.c b/kernel/fattab.c index be26c7eb..1cf97339 100644 --- a/kernel/fattab.c +++ b/kernel/fattab.c @@ -50,6 +50,23 @@ int ISFAT32(struct dpb FAR * dpbp) struct buffer FAR *getFATblock(ULONG clussec, struct dpb FAR * dpbp) { struct buffer FAR *bp; + CLUSTER max_cluster = dpbp->dpb_size; + +#ifdef WITHFAT32 + if (ISFAT32(dpbp)) + max_cluster = dpbp->dpb_xsize; +#endif + + if (clussec <= 1 || clussec > max_cluster) + { + put_string("run CHKDSK: trying to access invalid cluster 0x"); +#ifdef WITHFAT32 + put_unsigned(clussec >> 16, 16, 4); +#endif + put_unsigned(clussec & 0xffffu, 16, 4); + put_console('\n'); + return NULL; + } if (ISFAT12(dpbp)) { @@ -259,12 +276,6 @@ unsigned link_fat(struct dpb FAR * dpbp, CLUSTER Cluster1, CLUSTER next_cluster(struct dpb FAR * dpbp, CLUSTER ClusterNum) { struct buffer FAR *bp; -#ifdef DEBUG - if (ClusterNum == LONG_LAST_CLUSTER) - printf("fatal error: trying to do next_cluster(dpbp, EOC)!\n"); - if (ClusterNum == 0) - printf("fatal error: trying to do next_cluster(dpbp, 0)!\n"); -#endif /* Get the block that this cluster is in */ bp = getFATblock(ClusterNum, dpbp); diff --git a/kernel/prf.c b/kernel/prf.c index ff0364b8..ce25a37b 100644 --- a/kernel/prf.c +++ b/kernel/prf.c @@ -57,7 +57,7 @@ static BYTE *prfRcsId = static int buff_offset = 0; static char buff[MAX_BUFSIZE]; -STATIC VOID put_console(COUNT c) +void put_console(int c) { if (buff_offset >= MAX_BUFSIZE) { @@ -91,7 +91,7 @@ STATIC VOID put_console(COUNT c) } } #else -STATIC VOID put_console(COUNT c) +void put_console(int c) { if (c == '\n') put_console('\r'); @@ -129,7 +129,6 @@ typedef char *va_list; static BYTE *charp = 0; STATIC VOID handle_char(COUNT); -STATIC VOID put_console(COUNT); STATIC BYTE * ltob(LONG, BYTE *, COUNT); STATIC COUNT do_printf(CONST BYTE *, REG va_list); int CDECL printf(CONST BYTE * fmt, ...); diff --git a/kernel/proto.h b/kernel/proto.h index 924d3671..c2d67c23 100644 --- a/kernel/proto.h +++ b/kernel/proto.h @@ -282,6 +282,7 @@ int CDECL sprintf(BYTE * buff, CONST BYTE * fmt, ...); VOID hexd(char *title, VOID FAR * p, COUNT numBytes); void put_unsigned(unsigned n, int base, int width); void put_string(const char *s); +void put_console(int); /* strings.c */ size_t /* ASMCFUNC */ ASMPASCAL strlen(const char * s); From 3d7d36cf914b1861a9af50c450a3edf4bb408ea8 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Mon, 26 Jan 2004 02:01:34 +0000 Subject: [PATCH 345/671] Using a FAT32 table so that FATs won't be too big for drives <= 64 GB git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@754 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/initdisk.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/kernel/initdisk.c b/kernel/initdisk.c index bc9fdebd..e9986dcf 100644 --- a/kernel/initdisk.c +++ b/kernel/initdisk.c @@ -501,10 +501,20 @@ VOID CalculateFATData(ddt FAR * pddt, ULONG NumSectors, UBYTE FileSystem) { unsigned long fatlength, clust, maxclust; - /* For FAT32, use 4k clusters on sufficiently large file systems, - * otherwise 1 sector per cluster. This is also what M$'s format - * command does for FAT32. */ - defbpb->bpb_nsector = (NumSectors >= 512 * 1024ul ? 8 : 1); + /* For FAT32, use the cluster size table described in the FAT spec: + * http://www.microsoft.com/hwdev/download/hardware/fatgen103.pdf + */ + unsigned sz_gb = (unsigned)(NumSectors / 2097152UL); + unsigned char nsector = 64; /* disks greater than 32 GB, 32K cluster */ + if (sz_gb <= 32) /* disks up to 32 GB, 16K cluster */ + nsector = 32; + if (sz_gb <= 16) /* disks up to 16 GB, 8K cluster */ + nsector = 16; + if (sz_gb <= 8) /* disks up to 8 GB, 4K cluster */ + nsector = 8; + if (NumSectors <= 532480) /* disks up to 260 MB, 0.5K cluster */ + nsector = 1; + defbpb->bpb_nsector = nsector; do { fatlength = cdiv(fatdata + 2 * defbpb->bpb_nsector, From a9c00dcf86d41bf0ab5479a9a775299365ca79c8 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Mon, 26 Jan 2004 13:18:13 +0000 Subject: [PATCH 346/671] Adapted from Chris Rodie's patch (bugzilla #1729): "open" and "close" should call the open/close functions for devices using a device request when appropriate. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@755 6ac86273-5f31-0410-b378-82cca8765d1b --- hdr/sft.h | 1 + kernel/dosfns.c | 32 +++++++++++++++++++++++++++++--- 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/hdr/sft.h b/hdr/sft.h index c6842c11..49bb846c 100644 --- a/hdr/sft.h +++ b/hdr/sft.h @@ -123,6 +123,7 @@ typedef struct sfttbl { /* the following bits are device (char) unique */ #define SFT_FIOCTL 0x4000 /* IOCTL support - device */ +#define SFT_FOCRM 0x0800 /* Open/Close/RM bit in device attribute*/ #define SFT_FEOF 0x0040 /* device eof */ #define SFT_FBINARY 0x0020 /* device binary mode */ #define SFT_FSPECIAL 0x0010 /* int 29 support */ diff --git a/kernel/dosfns.c b/kernel/dosfns.c index 4c20e4da..476dba23 100644 --- a/kernel/dosfns.c +++ b/kernel/dosfns.c @@ -466,7 +466,7 @@ const char FAR *get_root(const char FAR * fname) } /* initialize SFT fields (for open/creat) for character devices */ -STATIC void DeviceOpenSft(struct dhdr FAR *dhp, sft FAR *sftp) +STATIC int DeviceOpenSft(struct dhdr FAR *dhp, sft FAR *sftp) { int i; @@ -487,6 +487,17 @@ STATIC void DeviceOpenSft(struct dhdr FAR *dhp, sft FAR *sftp) sftp->sft_date = dos_getdate(); sftp->sft_time = dos_gettime(); sftp->sft_attrib = D_DEVICE; + + if (sftp->sft_dev->dh_attr & SFT_FOCRM) + { + /* if Open/Close/RM bit in driver's attribute is set + * then issue an Open request to the driver + */ + struct dhdr FAR *dev = sftp->sft_dev; + if (BinaryCharIO(&dev, 0, MK_FP(0x0000, 0x0000), C_OPEN) != SUCCESS) + return DE_ACCESS; + } + return SUCCESS; } /* @@ -575,7 +586,12 @@ long DosOpenSft(char FAR * fname, unsigned flags, unsigned attrib) /* check for a device */ if ((result & IS_DEVICE) && (dhp = IsDevice(fname)) != NULL) { - DeviceOpenSft(dhp, sftp); + int rc = DeviceOpenSft(dhp, sftp); + /* check the status code returned by the + * driver when we tried to open it + */ + if (rc < SUCCESS) + return rc; return sft_idx; } @@ -738,8 +754,18 @@ COUNT DosCloseSft(int sft_idx, BOOL commitonly) sftp->sft_count -= 1; if (sftp->sft_flags & SFT_FDEVICE) + { + if (sftp->sft_dev->dh_attr & SFT_FOCRM) + { + /* if Open/Close/RM bit in driver's attribute is set + * then issue a Close request to the driver + */ + struct dhdr FAR *dev = sftp->sft_dev; + if (BinaryCharIO(&dev, 0, MK_FP(0x0000, 0x0000), C_CLOSE) != SUCCESS) + return DE_ACCESS; + } return SUCCESS; - + } if (commitonly) return dos_commit(sftp->sft_status); From eecbe8439a64a2c21e0a746d694ff7afb6f3b7a5 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Mon, 26 Jan 2004 19:40:13 +0000 Subject: [PATCH 347/671] Adapted from Chris Rodie's patch for bugzilla #1730: do a device input status request for int21/ax=4406 for devices (not for files). git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@756 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/ioctl.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/kernel/ioctl.c b/kernel/ioctl.c index 87b83ab1..7c1fd46a 100644 --- a/kernel/ioctl.c +++ b/kernel/ioctl.c @@ -117,9 +117,11 @@ COUNT DosDevIOctl(lregs * r) case 0x06: if (s->sft_flags & SFT_FDEVICE) - r->AL = s->sft_flags & SFT_FEOF ? 0xFF : 0; - else - r->AL = s->sft_posit >= s->sft_size ? 0 : 0xFF; + { + nMode = C_ISTAT; + goto IoCharCommon; + } + r->AL = s->sft_posit >= s->sft_size ? 0 : 0xFF; break; case 0x07: @@ -143,11 +145,12 @@ COUNT DosDevIOctl(lregs * r) case 0x10: nMode = C_IOCTLQRY; IoCharCommon: - if ((s->sft_flags & SFT_FDEVICE) - || ((r->AL == 0x02) && (s->sft_dev->dh_attr & SFT_FIOCTL)) + if ((s->sft_flags & SFT_FDEVICE) && + ( ((r->AL == 0x02) && (s->sft_dev->dh_attr & SFT_FIOCTL)) || ((r->AL == 0x03) && (s->sft_dev->dh_attr & SFT_FIOCTL)) + || r->AL == 0x06 || r->AL == 0x07 || ((r->AL == 0x10) && (s->sft_dev->dh_attr & ATTR_QRYIOCTL)) - || ((r->AL == 0x0c) && (s->sft_dev->dh_attr & ATTR_GENIOCTL))) + || ((r->AL == 0x0c) && (s->sft_dev->dh_attr & ATTR_GENIOCTL)))) { CharReqHdr.r_unit = 0; CharReqHdr.r_command = nMode; @@ -159,15 +162,14 @@ COUNT DosDevIOctl(lregs * r) return DE_DEVICE; } - if (r->AL == 0x07) + if (r->AL == 0x06 || r->AL == 0x07) { - r->AL = CharReqHdr.r_status & S_BUSY ? 00 : 0xff; + r->AX = CharReqHdr.r_status & S_BUSY ? 0000 : 0x00ff; } else if (r->AL == 0x02 || r->AL == 0x03) { r->AX = CharReqHdr.r_count; } - else if (r->AL == 0x0c || r->AL == 0x10) { r->AX = CharReqHdr.r_status; From 44e4319e930d0049a864cdb98120c0e80463a4c3 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Mon, 26 Jan 2004 19:43:06 +0000 Subject: [PATCH 348/671] Save ~100 bytes by replacing s->sft_flags with flags, s->sft_dev->dh_attr with attr and simplifying the if() statement a bit git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@757 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/ioctl.c | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/kernel/ioctl.c b/kernel/ioctl.c index 7c1fd46a..7c6324a3 100644 --- a/kernel/ioctl.c +++ b/kernel/ioctl.c @@ -85,13 +85,16 @@ COUNT DosDevIOctl(lregs * r) return DE_INVLDHNDL; switch (r->AL) - { + { + unsigned attr = s->sft_dev->dh_attr; + unsigned flags = s->sft_flags; + case 0x00: /* Get the flags from the SFT */ - if (s->sft_flags & SFT_FDEVICE) - r->AX = (s->sft_dev->dh_attr & 0xff00) | s->sft_flags_lo; + if (flags & SFT_FDEVICE) + r->AX = (attr & 0xff00) | (flags & 0xff); else - r->AX = s->sft_flags; + r->AX = flags; /* Undocumented result, Ax = Dx seen using Pcwatch */ r->DX = r->AX; break; @@ -99,7 +102,7 @@ COUNT DosDevIOctl(lregs * r) case 0x01: /* sft_flags is a file, return an error because you */ /* can't set the status of a file. */ - if (!(s->sft_flags & SFT_FDEVICE)) + if (!(flags & SFT_FDEVICE)) return DE_INVLDFUNC; /* Set it to what we got in the DL register from the */ @@ -116,7 +119,7 @@ COUNT DosDevIOctl(lregs * r) goto IoCharCommon; case 0x06: - if (s->sft_flags & SFT_FDEVICE) + if (flags & SFT_FDEVICE) { nMode = C_ISTAT; goto IoCharCommon; @@ -125,7 +128,7 @@ COUNT DosDevIOctl(lregs * r) break; case 0x07: - if (s->sft_flags & SFT_FDEVICE) + if (flags & SFT_FDEVICE) { nMode = C_OSTAT; goto IoCharCommon; @@ -134,7 +137,7 @@ COUNT DosDevIOctl(lregs * r) break; case 0x0a: - r->DX = s->sft_flags; + r->DX = flags; r->AX = 0; break; @@ -145,12 +148,11 @@ COUNT DosDevIOctl(lregs * r) case 0x10: nMode = C_IOCTLQRY; IoCharCommon: - if ((s->sft_flags & SFT_FDEVICE) && - ( ((r->AL == 0x02) && (s->sft_dev->dh_attr & SFT_FIOCTL)) - || ((r->AL == 0x03) && (s->sft_dev->dh_attr & SFT_FIOCTL)) + if ((flags & SFT_FDEVICE) && + ( ((r->AL == 0x02 || r->AL == 0x03) && (attr & ATTR_IOCTL)) || r->AL == 0x06 || r->AL == 0x07 - || ((r->AL == 0x10) && (s->sft_dev->dh_attr & ATTR_QRYIOCTL)) - || ((r->AL == 0x0c) && (s->sft_dev->dh_attr & ATTR_GENIOCTL)))) + || ((r->AL == 0x10) && (attr & ATTR_QRYIOCTL)) + || ((r->AL == 0x0c) && (attr & ATTR_GENIOCTL)))) { CharReqHdr.r_unit = 0; CharReqHdr.r_command = nMode; From 828a125aedb30467f998e46fc1aa051e2123eb93 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Tue, 27 Jan 2004 12:42:45 +0000 Subject: [PATCH 349/671] Have to move attr/flags init before switch, otherwise they won't work! git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@758 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/ioctl.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/kernel/ioctl.c b/kernel/ioctl.c index 7c6324a3..07bc9da3 100644 --- a/kernel/ioctl.c +++ b/kernel/ioctl.c @@ -79,16 +79,18 @@ COUNT DosDevIOctl(lregs * r) case 0x0a: case 0x0c: case 0x10: + { + unsigned attr, flags; /* Get the SFT block that contains the SFT */ if ((s = get_sft(r->BX)) == (sft FAR *) - 1) return DE_INVLDHNDL; - + + attr = s->sft_dev->dh_attr; + flags = s->sft_flags; + switch (r->AL) { - unsigned attr = s->sft_dev->dh_attr; - unsigned flags = s->sft_flags; - case 0x00: /* Get the flags from the SFT */ if (flags & SFT_FDEVICE) @@ -183,6 +185,7 @@ COUNT DosDevIOctl(lregs * r) return DE_INVLDFUNC; } break; + } case 0x04: case 0x05: From b7491eba32da1dc11781a56d7457e42d94b2aa5c Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Tue, 27 Jan 2004 19:26:58 +0000 Subject: [PATCH 350/671] Expand tabs for int21/ah=2,9 even in raw device modes and if stdout is redirected. This solves bug 1737 (grep2msg problem) This copy&paste exercise is to be cleaned up a bit later! git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@759 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/chario.c | 28 +++++++++++++++++++++++++++- kernel/inthndlr.c | 11 +++++------ 2 files changed, 32 insertions(+), 7 deletions(-) diff --git a/kernel/chario.c b/kernel/chario.c index 12b2e193..9864058d 100644 --- a/kernel/chario.c +++ b/kernel/chario.c @@ -277,7 +277,33 @@ void write_char(int c, int sft_idx) void write_char_stdout(int c) { - write_char(c, get_sft_idx(STDOUT)); + unsigned char scrpos = scr_pos; + unsigned char count = 1; + unsigned flags = get_sft(STDOUT)->sft_flags & (SFT_FDEVICE | SFT_FBINARY); + + /* ah=2, ah=9 should expand tabs even for raw devices and disk files */ + if (flags != SFT_FDEVICE) + { + if (c == CR) + scrpos = 0; + else if (c == BS) { + if (scrpos > 0) + scrpos--; + } else if (c != LF && c != BELL) { + if (c == HT) { + count = 8 - (scrpos & 7); + c = ' '; + } + scrpos += count; + } + /* for raw devices already updated in dosfns.c */ + if (!(flags & SFT_FDEVICE)) + scr_pos = scrpos; + } + + do { + write_char(c, get_sft_idx(STDOUT)); + } while (--count != 0); } #define iscntrl(c) ((unsigned char)(c) < ' ') diff --git a/kernel/inthndlr.c b/kernel/inthndlr.c index e9e9cf8a..97f7112e 100644 --- a/kernel/inthndlr.c +++ b/kernel/inthndlr.c @@ -482,14 +482,13 @@ VOID ASMCFUNC int21_service(iregs FAR * r) /* Display String */ case 0x09: { - size_t count = 0; - char FAR *bp = FP_DS_DX; + unsigned char c; + unsigned char FAR *bp = FP_DS_DX; - while (bp[count] != '$') - count++; + while ((c = *bp++) != '$') + write_char_stdout(c); - DosWrite(STDOUT, count, bp); - lr.AL = '$'; + lr.AL = c; } break; From d4f6a7104bb294658311de22103e2bf13656126a Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Tue, 27 Jan 2004 20:07:28 +0000 Subject: [PATCH 351/671] Clean up scr_pos updating routines: combine into update_scr_pos() function instead of 2 copies of the same thing. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@760 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/chario.c | 43 ++++++++++++++++++++----------------------- kernel/dosfns.c | 19 +------------------ kernel/proto.h | 1 + 3 files changed, 22 insertions(+), 41 deletions(-) diff --git a/kernel/chario.c b/kernel/chario.c index 9864058d..93ea5f73 100644 --- a/kernel/chario.c +++ b/kernel/chario.c @@ -196,14 +196,9 @@ STATIC void fast_put_char(unsigned char chr) } #endif -/* writes a character in cooked mode; maybe with printer echo; - handles TAB expansion */ -STATIC int cooked_write_char(struct dhdr FAR **pdev, - unsigned char c, - unsigned char *fast_counter) +void update_scr_pos(unsigned char c, unsigned char count) { unsigned char scrpos = scr_pos; - unsigned char count = 1; if (c == CR) scrpos = 0; @@ -211,13 +206,24 @@ STATIC int cooked_write_char(struct dhdr FAR **pdev, if (scrpos > 0) scrpos--; } else if (c != LF && c != BELL) { - if (c == HT) { - count = 8 - (scrpos & 7); - c = ' '; - } scrpos += count; } scr_pos = scrpos; +} + +/* writes a character in cooked mode; maybe with printer echo; + handles TAB expansion */ +STATIC int cooked_write_char(struct dhdr FAR **pdev, + unsigned char c, + unsigned char *fast_counter) +{ + unsigned char count = 1; + + if (c == HT) { + count = 8 - (scr_pos & 7); + c = ' '; + } + update_scr_pos(c, count); do { @@ -277,28 +283,19 @@ void write_char(int c, int sft_idx) void write_char_stdout(int c) { - unsigned char scrpos = scr_pos; unsigned char count = 1; unsigned flags = get_sft(STDOUT)->sft_flags & (SFT_FDEVICE | SFT_FBINARY); /* ah=2, ah=9 should expand tabs even for raw devices and disk files */ if (flags != SFT_FDEVICE) { - if (c == CR) - scrpos = 0; - else if (c == BS) { - if (scrpos > 0) - scrpos--; - } else if (c != LF && c != BELL) { - if (c == HT) { - count = 8 - (scrpos & 7); - c = ' '; - } - scrpos += count; + if (c == HT) { + count = 8 - (scr_pos & 7); + c = ' '; } /* for raw devices already updated in dosfns.c */ if (!(flags & SFT_FDEVICE)) - scr_pos = scrpos; + update_scr_pos(c, count); } do { diff --git a/kernel/dosfns.c b/kernel/dosfns.c index 476dba23..ba9e7877 100644 --- a/kernel/dosfns.c +++ b/kernel/dosfns.c @@ -247,25 +247,8 @@ long DosRWSft(int sft_idx, size_t n, void FAR * bp, int mode) { size_t cnt = (size_t)rc; const char FAR *p = bp; - unsigned char scrpos = scr_pos; while (cnt--) - { - switch (*p++) - { - case CR: - scrpos = 0; - break; - case LF: - case BELL: - break; - case BS: - --scrpos; - break; - default: - ++scrpos; - } - } - scr_pos = scrpos; + update_scr_pos(*p++, 1); } return rc; } diff --git a/kernel/proto.h b/kernel/proto.h index c2d67c23..46662076 100644 --- a/kernel/proto.h +++ b/kernel/proto.h @@ -69,6 +69,7 @@ void read_line(int sft_in, int sft_out, keyboard FAR * kp); size_t read_line_handle(int sft_idx, size_t n, char FAR * bp); void write_char(int c, int sft_idx); void write_char_stdout(int c); +void update_scr_pos(unsigned char c, unsigned char count); long cooked_write(struct dhdr FAR **pdev, size_t n, char FAR *bp); sft FAR *get_sft(UCOUNT); From 5567aba08be960e8b0777350ba2b4ccbb927d756 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Tue, 27 Jan 2004 23:18:24 +0000 Subject: [PATCH 352/671] Fixed bug #1722: dir_close() was called for normal files (via map_cluster and find_fat_free). This completely messed up rwblock. Removed these calls (for directories they are already covered at a higher level) and added a few sanity checks to dir_close and dir_write. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@761 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/fatdir.c | 5 ++++- kernel/fatfs.c | 12 ++---------- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/kernel/fatdir.c b/kernel/fatdir.c index f7239fb9..8f8e3a7e 100644 --- a/kernel/fatdir.c +++ b/kernel/fatdir.c @@ -293,6 +293,9 @@ BOOL dir_write(REG f_node_ptr fnp) struct buffer FAR *bp; REG UWORD secsize = fnp->f_dpb->dpb_secsize; + if (!fnp->f_flags.f_ddir) + return FALSE; + /* Update the entry if it was modified by a write or create... */ if (fnp->f_flags.f_dmod) { @@ -376,7 +379,7 @@ BOOL dir_write(REG f_node_ptr fnp) VOID dir_close(REG f_node_ptr fnp) { /* Test for invalid f_nodes */ - if (fnp == NULL) + if (fnp == NULL || !fnp->f_flags.f_ddir) return; #ifndef IPL diff --git a/kernel/fatfs.c b/kernel/fatfs.c index f04826f1..b7122036 100644 --- a/kernel/fatfs.c +++ b/kernel/fatfs.c @@ -1025,7 +1025,6 @@ STATIC CLUSTER find_fat_free(f_node_ptr fnp) { dpbp->dpb_xcluster = UNKNCLUSTER; write_fsinfo(dpbp); - dir_close(fnp); return LONG_LAST_CLUSTER; } if (dpbp->dpb_xnfreeclst != XUNKNCLSTFREE) @@ -1041,7 +1040,6 @@ STATIC CLUSTER find_fat_free(f_node_ptr fnp) if (idx > dpbp->dpb_size) { dpbp->dpb_cluster = UNKNCLUSTER; - dir_close(fnp); return LONG_LAST_CLUSTER; } @@ -1395,14 +1393,8 @@ COUNT map_cluster(REG f_node_ptr fnp, COUNT mode) return DE_SEEK; /* expand the list if we're going to write and have run into */ /* the last cluster marker. */ - if ((mode == XFR_WRITE) && (last_link(fnp))) - { - if (!extend(fnp)) - { - dir_close(fnp); - return DE_HNDLDSKFULL; - } - } + if ((mode == XFR_WRITE) && last_link(fnp) && !extend(fnp)) + return DE_HNDLDSKFULL; if (fnp->f_cluster_offset == relcluster) break; From 2b9e17a6806bb1480ebc946945b44805dcaa8de9 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sat, 31 Jan 2004 11:39:50 +0000 Subject: [PATCH 353/671] Only put PATH= in the environment if it's still empty just before executing the shell. This repairs SET PATH=.... in config.sys without confusing anyone. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@762 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/config.c | 4 ++-- kernel/main.c | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/kernel/config.c b/kernel/config.c index 001705f1..d46ca41b 100644 --- a/kernel/config.c +++ b/kernel/config.c @@ -137,8 +137,8 @@ UWORD ram_top = 0; /* How much ram in Kbytes */ static UBYTE ErrorAlreadyPrinted[128]; -char master_env[128] = {"PATH="}; /* some shells panic on empty master env. */ -static char *envp = master_env + 6; /* point to the second zero */ +char master_env[128] = {0}; +static char *envp = master_env; struct config Config = { 0, diff --git a/kernel/main.c b/kernel/main.c index 05d6fd83..079eca52 100644 --- a/kernel/main.c +++ b/kernel/main.c @@ -364,6 +364,8 @@ STATIC void kernel() int rc; exb.exec.env_seg = DOS_PSP + 8; + if (master_env[0] == '\0') /* some shells panic on empty master env. */ + strcpy(master_env, "PATH=."); fmemcpy(MK_FP(exb.exec.env_seg, 0), master_env, sizeof(master_env)); /* process 0 */ From e7f0852dbd8d12a4abe47cb7659acfaefe09ecaa Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sat, 31 Jan 2004 15:01:40 +0000 Subject: [PATCH 354/671] correct sectors/track, head and hidden sector values if the boot sector disagrees with the default bpb (unless the default bpb says that the number of hidden sectors is zero (usual for floppies)). introduce generic_block_ioctl() function to handle all 0x440d ioctls (inclusive locking) git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@763 6ac86273-5f31-0410-b378-82cca8765d1b --- sys/sys.c | 95 ++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 59 insertions(+), 36 deletions(-) diff --git a/sys/sys.c b/sys/sys.c index 317b1ac0..af59665a 100644 --- a/sys/sys.c +++ b/sys/sys.c @@ -29,7 +29,7 @@ #define DEBUG /* #define DDEBUG */ -#define SYS_VERSION "v3.0" +#define SYS_VERSION "v3.1" #include #include @@ -471,28 +471,20 @@ void reset_drive(int DosDrive); parm [dx] \ modify [ax bx]; -void lock_drive(int DosDrive); -#pragma aux lock_drive = \ - "mov ax,0x440d" \ - "mov cx,0x84a" \ - "xor dx,dx" \ - "inc bx" \ - "int 0x21" \ - parm [bx]; - -void unlock_drive(int DosDrive); -#pragma aux unlock_drive = \ - "mov ax,0x440d" \ - "mov cx,0x86a" \ - "inc bx" \ - "int 0x21" \ - parm [bx]; - void truename(char far *dest, const char *src); #pragma aux truename = \ "mov ah,0x60" \ "int 0x21" \ parm [es di] [si]; + +int generic_block_ioctl(unsigned char drive, unsigned cx, unsigned char *par); +#pragma aux generic_block_ioctl = \ + "mov ax, 0x440d" \ + "int 0x21" \ + "sbb ax, ax" \ + value [ax] \ + parm [bl] [cx] [dx]; + #else #ifndef __TURBOC__ @@ -543,26 +535,17 @@ void reset_drive(int DosDrive) intdos(®s, ®s); } /* reset_drive */ -void lock_drive(int DosDrive) -{ - union REGS regs; - - regs.x.ax = 0x440d; - regs.x.cx = 0x84a; - regs.x.dx = 0; - regs.h.bl = DosDrive + 1; - intdos(®s, ®s); -} /* lock_drive */ - -void unlock_drive(int DosDrive) +int generic_block_ioctl(unsigned char drive, unsigned cx, unsigned char *par) { union REGS regs; regs.x.ax = 0x440d; - regs.x.cx = 0x86a; - regs.h.bl = DosDrive + 1; + regs.x.cx = cx; + regs.x.dx = (unsigned)par; + regs.h.bl = drive + 1; intdos(®s, ®s); -} /* unlock_drive */ + return regs.x.cflag; +} /* generic_block_ioctl */ void truename(char *dest, const char *src) { @@ -669,6 +652,26 @@ BOOL haveLBA(void) } #endif +void correct_bpb(struct bootsectortype *default_bpb, + struct bootsectortype *oldboot) +{ + /* don't touch partitions (floppies most likely) that don't have hidden + sectors */ + if (default_bpb->bsHiddenSecs == 0) + return; +#ifdef DEBUG + printf("Old boot sector values: sectors/track: %u, heads: %u, hidden: %lu\n", + oldboot->bsSecPerTrack, oldboot->bsHeads, oldboot->bsHiddenSecs); + printf("Default and new boot sector values: sectors/track: %u, heads: %u, " + "hidden: %lu\n", default_bpb->bsSecPerTrack, default_bpb->bsHeads, + default_bpb->bsHiddenSecs); +#endif + + oldboot->bsSecPerTrack = default_bpb->bsSecPerTrack; + oldboot->bsHeads = default_bpb->bsHeads; + oldboot->bsHiddenSecs = default_bpb->bsHiddenSecs; +} + void put_boot(int drive, char *bsFile, char *kernel_name, int load_seg, int both) { #ifdef WITHFAT32 @@ -676,12 +679,15 @@ void put_boot(int drive, char *bsFile, char *kernel_name, int load_seg, int both #endif struct bootsectortype *bs; static unsigned char oldboot[SEC_SIZE], newboot[SEC_SIZE]; + static unsigned char default_bpb[0x5c]; #ifdef DEBUG printf("Reading old bootsector from drive %c:\n", drive + 'A'); #endif - lock_drive(drive); + /* lock drive */ + generic_block_ioctl((unsigned char)drive + 1, 0x84a, NULL); + reset_drive(drive); /* suggestion: allow reading from a boot sector or image file here */ if (MyAbsReadWrite(drive, 1, 0, oldboot, 0) != 0) @@ -727,10 +733,22 @@ void put_boot(int drive, char *bsFile, char *kernel_name, int load_seg, int both bs->bsBytesPerSec); exit(1); /* Japan?! */ } - + + /* bit 0 set if function to use current BPB, clear if Device + BIOS Parameter Block field contains new default BPB + bit 1 set if function to use track layout fields only + must be clear if CL=60h + bit 2 set if all sectors in track same size (should be set) (RBIL) */ + default_bpb[0] = 4; + if (fs == FAT32) { printf("FAT type: FAT32\n"); + /* get default bpb (but not for floppies) */ + if (drive >= 2 && + generic_block_ioctl((unsigned char)drive + 1, 0x4860, default_bpb) == 0) + correct_bpb((struct bootsectortype *)(default_bpb + 7 - 11), bs); + #ifdef WITHFAT32 /* copy one of the FAT32 boot sectors */ memcpy(newboot, haveLBA() ? fat32lba : fat32chs, SEC_SIZE); #else @@ -742,6 +760,9 @@ void put_boot(int drive, char *bsFile, char *kernel_name, int load_seg, int both else { /* copy the FAT12/16 CHS+LBA boot sector */ printf("FAT type: FAT1%c\n", fs + '0' - 10); + if (drive >= 2 && + generic_block_ioctl((unsigned char)drive + 1, 0x860, default_bpb) == 0) + correct_bpb((struct bootsectortype *)(default_bpb + 7 - 11), bs); memcpy(newboot, fs == FAT16 ? fat16com : fat12com, SEC_SIZE); } @@ -864,7 +885,9 @@ void put_boot(int drive, char *bsFile, char *kernel_name, int load_seg, int both close(fd); } /* if write boot sector file */ reset_drive(drive); - unlock_drive(drive); + + /* unlock_drive */ + generic_block_ioctl((unsigned char)drive + 1, 0x86a, NULL); } /* put_boot */ From 272f86af3d8cba2b403d6092744167862a694e68 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sat, 31 Jan 2004 15:04:09 +0000 Subject: [PATCH 355/671] Corrections to get past turbo c warnings. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@764 6ac86273-5f31-0410-b378-82cca8765d1b --- hdr/fat.h | 1 + kernel/fattab.c | 4 ++-- kernel/initdisk.c | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/hdr/fat.h b/hdr/fat.h index 1c4747c4..8670bbc7 100644 --- a/hdr/fat.h +++ b/hdr/fat.h @@ -128,6 +128,7 @@ struct lfn_entry { /* */ #ifdef WITHFAT32 +struct dpb; CLUSTER getdstart(struct dpb FAR *dpbp, struct dirent *dentry); void setdstart(struct dpb FAR *dpbp, struct dirent *dentry, CLUSTER value); BOOL checkdstart(struct dpb FAR *dpbp, struct dirent *dentry, CLUSTER value); diff --git a/kernel/fattab.c b/kernel/fattab.c index 1cf97339..b7d74937 100644 --- a/kernel/fattab.c +++ b/kernel/fattab.c @@ -61,9 +61,9 @@ struct buffer FAR *getFATblock(ULONG clussec, struct dpb FAR * dpbp) { put_string("run CHKDSK: trying to access invalid cluster 0x"); #ifdef WITHFAT32 - put_unsigned(clussec >> 16, 16, 4); + put_unsigned((unsigned)(clussec >> 16), 16, 4); #endif - put_unsigned(clussec & 0xffffu, 16, 4); + put_unsigned((unsigned)(clussec & 0xffffu), 16, 4); put_console('\n'); return NULL; } diff --git a/kernel/initdisk.c b/kernel/initdisk.c index e9986dcf..33f45623 100644 --- a/kernel/initdisk.c +++ b/kernel/initdisk.c @@ -512,7 +512,7 @@ VOID CalculateFATData(ddt FAR * pddt, ULONG NumSectors, UBYTE FileSystem) nsector = 16; if (sz_gb <= 8) /* disks up to 8 GB, 4K cluster */ nsector = 8; - if (NumSectors <= 532480) /* disks up to 260 MB, 0.5K cluster */ + if (NumSectors <= 532480UL) /* disks up to 260 MB, 0.5K cluster */ nsector = 1; defbpb->bpb_nsector = nsector; do From 42b55cd1acd1ee212271d95f45ee698fef54c090 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sat, 31 Jan 2004 15:06:36 +0000 Subject: [PATCH 356/671] allow "0" in full-screen config menus and plug a few potential related overflows. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@765 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/config.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/kernel/config.c b/kernel/config.c index d46ca41b..8eb1d31b 100644 --- a/kernel/config.c +++ b/kernel/config.c @@ -1882,7 +1882,7 @@ STATIC VOID CfgMenu(BYTE * pLine) pLine = skipwh(pLine); /* skip more whitespaces... */ /* now I'm expecting a number here if this is a menu-choice line. */ - if (pLine[0]>='1' && pLine[0]<='9') + if (pLine[0]>='0' && pLine[0]<='9') { int nIndex = pLine[0]-'0'; @@ -1989,14 +1989,14 @@ STATIC VOID DoMenu(void) } else if(key == 0x4800 && MenuColor != -1) /* arrow up */ { - if(MenuSelected>=0 && (Menus & (1 << (MenuSelected-1))) ) + if(MenuSelected>=1 && (Menus & (1 << (MenuSelected-1))) ) { MenuSelected--; } } else if(key == 0x5000 && MenuColor != -1) /* arrow down */ { - if(MenuSelected Date: Sat, 31 Jan 2004 16:00:16 +0000 Subject: [PATCH 357/671] history.txt and build.txt updates to reflect current situation. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@766 6ac86273-5f31-0410-b378-82cca8765d1b --- docs/build.txt | 15 +++++--- docs/history.txt | 95 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 104 insertions(+), 6 deletions(-) diff --git a/docs/build.txt b/docs/build.txt index 880d8c8f..a5e487b1 100644 --- a/docs/build.txt +++ b/docs/build.txt @@ -12,10 +12,11 @@ kernel come out, you can extract them over your previous source, and not have to worry about resetting up your configuration because your CONFIG.BAT file will not get replaced! -You will also need to download the latest version of NASM and Turbo C -2.01. Install Turbo C and NASM somewhere (it doesn't really matter -where) and then be sure to edit the CONFIG.BAT file to reflect where -you put the tools. +The recommended compiler and assembler at the time of writing (2004/01/31) +are OpenWatcom 1.2 and NASM 0.98.38. + +You may need to download the latest version of NASM and a C compiler +Be sure to edit the CONFIG.BAT file to reflect where you put the tools. You can find NASM at http://nasm.sourceforge.net. Version 0.98.36 or later is strongly recommended. The older 0.98 will also work fine, but @@ -35,14 +36,16 @@ other Borland compilers, Microsoft C and (Open)Watcom C. The OpenWatcom 1.0 compiler (or later) for DOS can now be downloaded at www.openwatcom.org: you need at least the following zips from ftp://ftp.openwatcom.org/watcom/zips/ +(see ftp://ftp.openwatcom.org/watcom/zips/layout.txt) cm_core_all - Core binaries (All hosts) +cm_core_dos - Core binaries (DOS host) +cm_core_doswin - Core binaries (DOS & Win hosts) cm_clib_hdr - C runtime library header files cm_clib_a16 - C runtime libraries (16-bit all targets) -clib_a16 - C runtime libraries (16-bit all targets) cm_clib_d16 - C runtime libraries (16-bit DOS) +clib_a16 - C runtime libraries (16-bit all targets) clib_d16 - C runtime libraries (16-bit DOS) -cm_core_dos - Core binaries (DOS host) core_doswin - Core binaries (DOS & Win16 hosts) c_doswin - C compiler (DOS & Win16 hosts) ext_dos4gw - DOS/4GW DOS extender diff --git a/docs/history.txt b/docs/history.txt index 8406be74..77cf9e4d 100644 --- a/docs/history.txt +++ b/docs/history.txt @@ -1,3 +1,98 @@ +2004 Jan 31 - Build 2033 +-------- Bart Oldeman (bart@dosemu.org) ++ Changes Bart + * config.c: allow "0" in full-screen config menus and plug a + few potential related overflows. + * sys.c: correct sectors/track, head and hidden sector values + if the boot sector disagrees with the default bpb (unless the + default bpb says that the number of hidden sectors is zero (usual + for floppies)). + * config.c, main.c: Only put PATH= in the environment if + it's still empty just before executing the shell. This repairs + SET PATH=.... in config.sys without confusing anyone. + * fatdir.c, fatfs.c: Fixed bug #1722: dir_close() was + called for normal files (via map_cluster and find_fat_free). This + completely messed up rwblock. Removed these calls (for + directories they are already covered at a higher level) and added + a few sanity checks to dir_close and dir_write. + * chario.c, inthndlr.c: Expand tabs for int21/ah=2,9 even + in raw device modes and if stdout is redirected. This solves bug + 1737 (grep2msg problem) + * ioctl.c: Adapted from Chris Rodie's patch for bugzilla + #1730: do a device input status request for int21/ax=4406 for + devices (not for files). Save ~100 bytes by replacing + s->sft_flags with flags, s->sft_dev->dh_attr with attr and + simplifying the if() statement a bit + * hdr/sft.h, dosfns.c: Adapted from Chris Rodie's patch + (bugzilla #1729): "open" and "close" should call the open/close + functions for devices using a device request when appropriate. + * hdr/fat.h, fatdir.c, fatfs.c, fattab.c, prf.c, proto.h: + + FAT32 kernels should ignore the upper word of the cluster + number for FAT16 partitions (just like FAT16 kernels do) + + added extra checks to make sure that invalid FAT entries are + never followed + + print a message in case of FAT corruption + + some small optimizations and header cleanups (some suggested by + Arkady) + * config.c: Make strupr code unambiguous + * filelist, sys/makefile, sys/sys.c, sys/talloc.c: ~1K size + reduction for sys.com by using Tom's talloc.c malloc/free + functions and using our own filelength for watcomc. + * initdisk.c: Better (for FAT32) and simpler FAT default + value calculations. Also use 16-bit instead of 32-bit quantities + where possible to save code size. Use a FAT32 table so that FATs + won't be too big for drives <= 64 GB + * dosfns.c: Do not clobber the DTA if findfirst or findnext fails. + Fixes bug #1712 + * fatfs.c: Rename blockio by rqblockio (namespace conflict with dsk.c) + * inthndlr.c: FAT32 kernels should fail int21/ah=71 with + al=0, carry set. + * hdr/portab.h, nls.c: (as reported by Tom) Fix nls upcase problem + with SS!=DS. + * fatfs.c: Move permission check to better place (only for + necessary for opening existing files), not for creating them -- + suggested by Steffen. Force r/o open for FCB and legacy creat + if the file is read-only + * fatfs.c: Move common code in media_check() to a new + blockio() function. + * fcbfns.c, globals.h, inthndlr.c: Change FcbReadWrite to + handle multiple records at once; this allows for the optimization + of FcbRandomBlockIO. + * fcbfns.c: Divide optimisation (ceiling) + some small cleanups + * fcbfns.c, globals.h, kernel.asm: Rename the global lpFcb + variable to sda_lpFcb. Then use local lpFcb variables where + necessary. This clears up the confusing shadowing. + * fcbfns.c, inthndlr.c, proto.h: Fix FCB problems with + int21/ah=27,28 (RandomBlockIO) + * boot32.asm: jmp -> jmp short (necessary for nasm 0.98) + * dosfns.c, inthndlr.c, proto.h: Implement support for + int2f/ax=1220. Fix int2f/ax=1216 (needs sft handles, not psp + handles, and to return the relative handle in BX, and to deal + with carry) + * boot.asm: Fix problem with FAT12 ++ Changes Eric Luttmann : + * main.c: Fix for multisegmented device drivers: If there are multiple + device drivers in a single driver file, only the END ADDRESS + returned by the last INIT call should be the used. It is + recommended that all the device drivers in the file return the + same address. This fixes a load problem with DUSE. + * config.c, init-mod.h, main.c: fix for multi-segment device + drivers; preserve rq_endaddr between init calls for the same driver. ++ Changes Lucho: + * inthndlr.c: Remove AL=0 check for AH=6c (from Arkady) Optimize DL check. + * main.c, serial.asm: (with some help from Tom): + initialize serial ports and retry serial reads on timeout. + * sys.c, boot.asm, boot32.asm, boot32lb.asm: + SYS 3.0 changes: added /L parameter to SYS to be able to change + the kernel boot segment + a few boot sector changes to get the + pointer at the same magic place for all boot sectors. + * makefile: clean up *.lnk files for "clean" and "clobber". + * dsk.c: the DJ mechanism needs to affect MEM 0050h:0004h - MS-DOS + LOGICAL DRIVE FOR SINGLE-FLOPPY SYSTEM (A: / B:) Size:BYTE + * int2f.asm, generic.mak: basic implementation of INT 2F/ax=4a33 - + CHECK MS-DOS VERSION 7; necessary for SpinRite (Steve Gibson) + * inthndlr.c: implement int2f/ax=1211 NORMALIZE ASCIZ FILENAME + * config.c, init-mod.h, main.c: Added SET support to config.sys 2003 Sep 24 - Build 2032a -------- Bart Oldeman (bart@dosemu.org) + Changes Bart From 8b384359e0b96c14e647672d3aa502ddfa7b02fc Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sat, 31 Jan 2004 16:04:00 +0000 Subject: [PATCH 358/671] Update LSM & copyright year. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@767 6ac86273-5f31-0410-b378-82cca8765d1b --- docs/fdkernel.lsm | 4 ++-- kernel/main.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/fdkernel.lsm b/docs/fdkernel.lsm index 67888046..ca3d0858 100644 --- a/docs/fdkernel.lsm +++ b/docs/fdkernel.lsm @@ -1,7 +1,7 @@ Begin3 Title: The FreeDOS Kernel -Version: 2.0.32a -Entered-date: 24 Sep 2003 +Version: 2.0.33 +Entered-date: 31 Jan 2004 Description: The FreeDOS Kernel. Keywords: kernel freedos dos msdos Author: (developers) diff --git a/kernel/main.c b/kernel/main.c index 079eca52..54c9041d 100644 --- a/kernel/main.c +++ b/kernel/main.c @@ -37,7 +37,7 @@ static BYTE *mainRcsId = #endif static char copyright[] = - "(C) Copyright 1995-2003 Pasquale J. Villani and The FreeDOS Project.\n" + "(C) Copyright 1995-2004 Pasquale J. Villani and The FreeDOS Project.\n" "All Rights Reserved. This is free software and comes with ABSOLUTELY NO\n" "WARRANTY; you can redistribute it and/or modify it under the terms of the\n" "GNU General Public License as published by the Free Software Foundation;\n" From d3447eef6cbe3e1b8c67cc1e23ba41bc71f23a58 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sat, 31 Jan 2004 16:23:50 +0000 Subject: [PATCH 359/671] Remove obsolete rdatclk from filelist. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@768 6ac86273-5f31-0410-b378-82cca8765d1b --- filelist | 1 - 1 file changed, 1 deletion(-) diff --git a/filelist b/filelist index 2e482878..7eef5168 100644 --- a/filelist +++ b/filelist @@ -30,7 +30,6 @@ */*/drivers/floppy.asm */*/drivers/getvec.asm */*/drivers/makefile -*/*/drivers/rdatclk.asm */*/drivers/rdpcclk.asm */*/drivers/wratclk.asm */*/drivers/wrpcclk.asm From 4950f7483b5b02bbc898a3fa0b18a02ce670a3ce Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Fri, 6 Feb 2004 20:55:55 +0000 Subject: [PATCH 360/671] From Lucho: fixes the CHKDSK I: "Invalid drive specification" bug git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@773 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/task.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/kernel/task.c b/kernel/task.c index 444ccbe4..98cce00c 100644 --- a/kernel/task.c +++ b/kernel/task.c @@ -225,6 +225,15 @@ void new_psp(seg para, int psize) p->ps_cmd.ctBuffer[0] = 0xd; /* command tail */ } +STATIC UBYTE chkdrv(unsigned drive) /* from FCB: 0 = default, 1 = A:, ... */ +{ + if (drive) + drive--; /* 0 = A:, 1 = B:, ... */ + else + drive = default_drive; + return get_cds(drive) ? 0 : 0xff; /* return 0 if drive is valid, else 0xff */ +} + STATIC UWORD patchPSP(UWORD pspseg, UWORD envseg, exec_blk FAR * exb, BYTE FAR * fnam) { @@ -278,8 +287,8 @@ STATIC UWORD patchPSP(UWORD pspseg, UWORD envseg, exec_blk FAR * exb, pspmcb->m_name[i] = '\0'; /* return value: AX value to be passed based on FCB values */ - return (get_cds(psp->ps_fcb1.fcb_drive) ? 0 : 0xff) | - (get_cds(psp->ps_fcb2.fcb_drive) ? 0 : 0xff00); + return chkdrv(psp->ps_fcb1.fcb_drive) | + (chkdrv(psp->ps_fcb2.fcb_drive) << 8); } int load_transfer(UWORD ds, exec_blk *exp, UWORD fcbcode, COUNT mode) From 005e8cc35fad469899c2960a72820f402dc08be4 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sat, 7 Feb 2004 17:59:45 +0000 Subject: [PATCH 361/671] talloc won't work with MSC (no sbrk or brk available) git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@774 6ac86273-5f31-0410-b378-82cca8765d1b --- sys/talloc.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/sys/talloc.c b/sys/talloc.c index 0e3601fe..2081aa9c 100644 --- a/sys/talloc.c +++ b/sys/talloc.c @@ -12,6 +12,8 @@ ** use it only, if your programs are already debugged !! **/ +#ifndef _MSC_VER /* MSC has no brk/sbrk */ + #include #include @@ -219,3 +221,5 @@ main() return 1; } #endif + +#endif From 0e0abcd685736da424e02b259fd42b0e7e6ff150 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sat, 7 Feb 2004 18:04:50 +0000 Subject: [PATCH 362/671] Added explicit (UWORD) type casts to avoid compiler warnings and sometimes save a few bytes too. Also changed the FcbParseFname return value: returns offset portion of pointer (SI) instead of the number of bytes to be added to SI. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@775 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/blockio.c | 2 +- kernel/fatdir.c | 32 +++++++++++++++----------------- kernel/fatfs.c | 22 ++++++++++++---------- kernel/fattab.c | 15 ++++++++------- kernel/fcbfns.c | 45 ++++++++++++++++++++++----------------------- kernel/inthndlr.c | 23 +++++++++++------------ kernel/memmgr.c | 4 ++-- kernel/task.c | 4 ++-- utils/exeflat.c | 4 ++-- 9 files changed, 75 insertions(+), 76 deletions(-) diff --git a/kernel/blockio.c b/kernel/blockio.c index 2f0bec7d..395ed0fe 100644 --- a/kernel/blockio.c +++ b/kernel/blockio.c @@ -412,7 +412,7 @@ UWORD dskxfer(COUNT dsk, ULONG blkno, VOID FAR * buf, UWORD numblocks, IoReqHdr.r_huge = blkno; } else - IoReqHdr.r_start = blkno; + IoReqHdr.r_start = (UWORD)blkno; /* * Some drivers normalise transfer address so HMA transfers are disastrous! * Then transfer block through xferbuf (DiskTransferBuffer doesn't work!) diff --git a/kernel/fatdir.c b/kernel/fatdir.c index 8f8e3a7e..fd5881e6 100644 --- a/kernel/fatdir.c +++ b/kernel/fatdir.c @@ -60,7 +60,7 @@ VOID dir_init_fnode(f_node_ptr fnp, CLUSTER dirstart) else #endif { - fnp->f_dirstart = 0l; + fnp->f_dirstart = 0; fnp->f_flags.f_droot = TRUE; } } @@ -181,6 +181,18 @@ STATIC void swap_deleted(char *name) name[0] = DELETED; } +STATIC struct buffer FAR *getblock_from_off(f_node_ptr fnp, unsigned secsize) +{ + /* Compute the block within the cluster and the */ + /* offset within the block. */ + fnp->f_sector = (UBYTE)(fnp->f_offset / secsize) & fnp->f_dpb->dpb_clsmask; + fnp->f_boff = (UWORD)(fnp->f_offset % secsize); + + /* Get the block we need from cache */ + return getblock(clus2phys(fnp->f_cluster, fnp->f_dpb) + fnp->f_sector, + fnp->f_dpb->dpb_unit); +} + /* Description. * Read next consequitive directory entry, pointed by fnp. * If some error occures the other critical @@ -237,14 +249,7 @@ COUNT dir_read(REG f_node_ptr fnp) if (map_cluster(fnp, XFR_READ) != SUCCESS) return DE_SEEK; - /* Compute the block within the cluster and the */ - /* offset within the block. */ - fnp->f_sector = (fnp->f_offset / secsize) & fnp->f_dpb->dpb_clsmask; - fnp->f_boff = fnp->f_offset % secsize; - - /* Get the block we need from cache */ - bp = getblock(clus2phys(fnp->f_cluster, fnp->f_dpb) + fnp->f_sector, - fnp->f_dpb->dpb_unit); + bp = getblock_from_off(fnp, secsize); #ifdef DISPLAY_GETBLOCK printf("DIR (dir_read)\n"); #endif @@ -335,14 +340,7 @@ BOOL dir_write(REG f_node_ptr fnp) return FALSE; } - /* Compute the block within the cluster and the */ - /* offset within the block. */ - fnp->f_sector = (fnp->f_offset / secsize) & fnp->f_dpb->dpb_clsmask; - fnp->f_boff = fnp->f_offset % secsize; - - /* Get the block we need from cache */ - bp = getblock(clus2phys(fnp->f_cluster, fnp->f_dpb) + fnp->f_sector, - fnp->f_dpb->dpb_unit); + bp = getblock_from_off(fnp, secsize); bp->b_flag &= ~(BFR_DATA | BFR_FAT); bp->b_flag |= BFR_DIR | BFR_VALID; #ifdef DISPLAY_GETBLOCK diff --git a/kernel/fatfs.c b/kernel/fatfs.c index b7122036..b89d181e 100644 --- a/kernel/fatfs.c +++ b/kernel/fatfs.c @@ -826,7 +826,7 @@ STATIC VOID wipe_out_clusters(struct dpb FAR * dpbp, CLUSTER st) else #endif if ((dpbp->dpb_cluster == UNKNCLUSTER) || (dpbp->dpb_cluster > st)) - dpbp->dpb_cluster = st; + dpbp->dpb_cluster = (UWORD)st; /* and just follow the linked list */ st = next; @@ -1037,7 +1037,7 @@ STATIC CLUSTER find_fat_free(f_node_ptr fnp) } #endif - if (idx > dpbp->dpb_size) + if ((UWORD)idx > dpbp->dpb_size) { dpbp->dpb_cluster = UNKNCLUSTER; return LONG_LAST_CLUSTER; @@ -1047,7 +1047,7 @@ STATIC CLUSTER find_fat_free(f_node_ptr fnp) dpbp->dpb_nfreeclst--; /* TE: moved from link_fat() */ /* return the free entry */ - dpbp->dpb_cluster = idx; + dpbp->dpb_cluster = (UWORD)idx; return idx; } @@ -1447,8 +1447,8 @@ STATIC COUNT dos_extend(f_node_ptr fnp) #ifdef WRITEZEROS /* Compute the block within the cluster and the offset */ /* within the block. */ - fnp->f_sector = (fnp->f_offset / secsize) & fnp->f_dpb->dpb_clsmask; - fnp->f_boff = fnp->f_offset % secsize; + fnp->f_sector = (UBYTE)(fnp->f_offset / secsize) & fnp->f_dpb->dpb_clsmask; + fnp->f_boff = (UWORD)(fnp->f_offset % secsize); #ifdef DSK_DEBUG printf("write %d links; dir offset %ld, cluster %d\n", @@ -1676,8 +1676,8 @@ long rwblock(COUNT fd, VOID FAR * buffer, UCOUNT count, int mode) /* Compute the block within the cluster and the offset */ /* within the block. */ - fnp->f_sector = (fnp->f_offset / secsize) & fnp->f_dpb->dpb_clsmask; - fnp->f_boff = fnp->f_offset % secsize; + fnp->f_sector = (UBYTE)(fnp->f_offset / secsize) & fnp->f_dpb->dpb_clsmask; + fnp->f_boff = (UWORD)(fnp->f_offset % secsize); currentblock = clus2phys(fnp->f_cluster, fnp->f_dpb) + fnp->f_sector; @@ -1890,7 +1890,7 @@ CLUSTER dos_free(struct dpb FAR * dpbp) return cnt; } #endif - dpbp->dpb_nfreeclst = cnt; + dpbp->dpb_nfreeclst = (UWORD)cnt; return cnt; } @@ -1907,7 +1907,9 @@ int dos_cd(char * PathName) if ((fnp = dir_open(PathName)) == NULL) return DE_PATHNOTFND; - cdsp->cdsStrtClst = fnp->f_dirstart; + /* problem: RBIL table 01643 does not give a FAT32 field for the + CDS start cluster. But we are not using this field ourselves */ + cdsp->cdsStrtClst = (UWORD)fnp->f_dirstart; dir_close(fnp); return SUCCESS; } @@ -2028,7 +2030,7 @@ VOID bpb_to_dpb(bpb FAR * bpbp, REG struct dpb FAR * dpbp) dpbp->dpb_data = dpbp->dpb_dirstrt + (dpbp->dpb_dirents + dpbp->dpb_secsize/DIRENT_SIZE - 1) / (dpbp->dpb_secsize/DIRENT_SIZE); - dpbp->dpb_size = ((size - dpbp->dpb_data) >> shftcnt) + 1; + dpbp->dpb_size = (UWORD)((size - dpbp->dpb_data) >> shftcnt) + 1; { /* Make sure the number of FAT sectors is actually enough to hold that */ /* many clusters. Otherwise back the number of clusters down (LG & AB) */ unsigned fatsiz; diff --git a/kernel/fattab.c b/kernel/fattab.c index b7d74937..66698d45 100644 --- a/kernel/fattab.c +++ b/kernel/fattab.c @@ -177,7 +177,8 @@ unsigned link_fat(struct dpb FAR * dpbp, CLUSTER Cluster1, /* form an index so that we can read the block as a */ /* byte array */ - idx = (unsigned) (((Cluster1 << 1) + Cluster1) >> 1) % dpbp->dpb_secsize; + idx = (unsigned) ((((unsigned)Cluster1 << 1) + (unsigned)Cluster1) >> 1) + % dpbp->dpb_secsize; /* Test to see if the cluster straddles the block. If */ /* it does, get the next block and use both to form the */ @@ -188,7 +189,7 @@ unsigned link_fat(struct dpb FAR * dpbp, CLUSTER Cluster1, if (idx >= (unsigned)dpbp->dpb_secsize - 1) { - bp1 = getFATblock(Cluster1 + 1, dpbp); + bp1 = getFATblock((unsigned)Cluster1 + 1, dpbp); if (bp1 == 0) return DE_BLKINVLD; @@ -198,15 +199,15 @@ unsigned link_fat(struct dpb FAR * dpbp, CLUSTER Cluster1, } /* Now pack the value in */ - if (Cluster1 & 0x01) + if ((unsigned)Cluster1 & 0x01) { - *fbp0 = (*fbp0 & 0x0f) | ((Cluster2 & 0x0f) << 4); - *fbp1 = (Cluster2 >> 4) & 0xff; + *fbp0 = (*fbp0 & 0x0f) | (((UBYTE)Cluster2 & 0x0f) << 4); + *fbp1 = (UBYTE)((unsigned)Cluster2 >> 4); } else { - *fbp0 = Cluster2 & 0xff; - *fbp1 = (*fbp1 & 0xf0) | ((Cluster2 >> 8) & 0x0f); + *fbp0 = (UBYTE)Cluster2; + *fbp1 = (*fbp1 & 0xf0) | ((UBYTE)((unsigned)Cluster2 >> 8) & 0x0f); } } else if (ISFAT16(dpbp)) diff --git a/kernel/fcbfns.c b/kernel/fcbfns.c index c2dbbb16..a33efdf9 100644 --- a/kernel/fcbfns.c +++ b/kernel/fcbfns.c @@ -88,7 +88,6 @@ BYTE FAR *FatGetDrvData(UBYTE drive, UWORD * spc, UWORD * bps, UWORD * nc) UWORD FcbParseFname(int *wTestMode, const BYTE FAR * lpFileName, fcb FAR * lpFcb) { WORD wRetCodeName = FALSE, wRetCodeExt = FALSE; - const BYTE FAR * lpFileName2 = lpFileName; /* pjv -- ExtFcbToFcb? */ /* Start out with some simple stuff first. Check if we are */ @@ -109,57 +108,57 @@ UWORD FcbParseFname(int *wTestMode, const BYTE FAR * lpFileName, fcb FAR * lpFcb if (!(*wTestMode & PARSE_SEP_STOP)) { - lpFileName2 = ParseSkipWh(lpFileName2); - if (TestCmnSeps(lpFileName2)) - ++lpFileName2; + lpFileName = ParseSkipWh(lpFileName); + if (TestCmnSeps(lpFileName)) + ++lpFileName; } /* Undocumented "feature," we skip white space anyway */ - lpFileName2 = ParseSkipWh(lpFileName2); + lpFileName = ParseSkipWh(lpFileName); /* Now check for drive specification */ - if (*(lpFileName2 + 1) == ':') + if (*(lpFileName + 1) == ':') { /* non-portable construct to be changed */ - REG UBYTE Drive = DosUpFChar(*lpFileName2) - 'A'; + REG UBYTE Drive = DosUpFChar(*lpFileName) - 'A'; if (Drive >= lastdrive) { *wTestMode = PARSE_RET_BADDRIVE; - return lpFileName2 - lpFileName; + return FP_OFF(lpFileName); } lpFcb->fcb_drive = Drive + 1; - lpFileName2 += 2; + lpFileName += 2; } /* special cases: '.' and '..' */ - if (*lpFileName2 == '.') + if (*lpFileName == '.') { lpFcb->fcb_fname[0] = '.'; - ++lpFileName2; - if (*lpFileName2 == '.') + ++lpFileName; + if (*lpFileName == '.') { lpFcb->fcb_fname[1] = '.'; - ++lpFileName2; + ++lpFileName; } *wTestMode = PARSE_RET_NOWILD; - return lpFileName2 - lpFileName; + return FP_OFF(lpFileName); } /* Now to format the file name into the string */ - lpFileName2 = - GetNameField(lpFileName2, (BYTE FAR *) lpFcb->fcb_fname, FNAME_SIZE, + lpFileName = + GetNameField(lpFileName, (BYTE FAR *) lpFcb->fcb_fname, FNAME_SIZE, (BOOL *) & wRetCodeName); /* Do we have an extension? If do, format it else return */ - if (*lpFileName2 == '.') - lpFileName2 = - GetNameField(++lpFileName2, (BYTE FAR *) lpFcb->fcb_fext, + if (*lpFileName == '.') + lpFileName = + GetNameField(++lpFileName, (BYTE FAR *) lpFcb->fcb_fext, FEXT_SIZE, (BOOL *) & wRetCodeExt); *wTestMode = (wRetCodeName | wRetCodeExt) ? PARSE_RET_WILD : PARSE_RET_NOWILD; - return lpFileName2 - lpFileName; + return FP_OFF(lpFileName); } const BYTE FAR * ParseSkipWh(const BYTE FAR * lpFileName) @@ -345,8 +344,8 @@ void FcbCalcRec(xfcb FAR * lpXfcb) /* Now update the fcb and compute where we need to position */ /* to. */ - lpFcb->fcb_cublock = lpFcb->fcb_rndm / 128; - lpFcb->fcb_curec = lpFcb->fcb_rndm & 127; + lpFcb->fcb_cublock = (UWORD)(lpFcb->fcb_rndm / 128); + lpFcb->fcb_curec = (UBYTE)lpFcb->fcb_rndm & 127; } UBYTE FcbRandomBlockIO(xfcb FAR * lpXfcb, UWORD *nRecords, int mode) @@ -362,7 +361,7 @@ UBYTE FcbRandomBlockIO(xfcb FAR * lpXfcb, UWORD *nRecords, int mode) old = lpFcb->fcb_rndm; nErrorCode = FcbReadWrite(lpXfcb, *nRecords, mode); - *nRecords = lpFcb->fcb_rndm - old; + *nRecords = (UWORD)(lpFcb->fcb_rndm - old); /* Now update the fcb */ FcbCalcRec(lpXfcb); diff --git a/kernel/inthndlr.c b/kernel/inthndlr.c index 97f7112e..c69cd5fb 100644 --- a/kernel/inthndlr.c +++ b/kernel/inthndlr.c @@ -229,8 +229,8 @@ int int21_fat32(lregs *r) { case 0x00: { - DWORD nfreeclst = xdffp->xdff_f.setdpbcounts.nfreeclst; - DWORD cluster = xdffp->xdff_f.setdpbcounts.cluster; + ULONG nfreeclst = xdffp->xdff_f.setdpbcounts.nfreeclst; + ULONG cluster = xdffp->xdff_f.setdpbcounts.cluster; if (ISFAT32(dpb)) { if ((dpb->dpb_xfsinfosec == 0xffff @@ -246,13 +246,13 @@ int int21_fat32(lregs *r) } else { - if (nfreeclst == 1 || nfreeclst > dpb->dpb_size || - cluster == 1 || cluster > dpb->dpb_size) + if ((unsigned)nfreeclst == 1 || (unsigned)nfreeclst > dpb->dpb_size || + (unsigned)cluster == 1 || (unsigned)cluster > dpb->dpb_size) { return DE_INVLDPARM; } - dpb->dpb_nfreeclst = nfreeclst; - dpb->dpb_cluster = cluster; + dpb->dpb_nfreeclst = (UWORD)nfreeclst; + dpb->dpb_cluster = (UWORD)cluster; } break; } @@ -294,7 +294,7 @@ int int21_fat32(lregs *r) bp->b_flag &= ~(BFR_DATA | BFR_DIR | BFR_FAT); bp->b_flag |= BFR_VALID | BFR_DIRTY; bpbp = (bpb FAR *) & bp->b_buffer[BT_BPB]; - bpbp->bpb_xflags = newmirroring; + bpbp->bpb_xflags = (UWORD)newmirroring; } goto rebuild_dpb; } @@ -306,7 +306,7 @@ int int21_fat32(lregs *r) if (!ISFAT32(dpb) || (rootclst != -1 && (rootclst == 1 - || rootclst > dpb->dpb_xsize))) + || (ULONG)rootclst > dpb->dpb_xsize))) { return DE_INVLDPARM; } @@ -669,9 +669,8 @@ VOID ASMCFUNC int21_service(iregs FAR * r) /* Parse File Name */ case 0x29: { - UWORD offset = FcbParseFname(&rc, MK_FP(lr.DS, lr.SI), FP_ES_DI); + lr.SI = FcbParseFname(&rc, MK_FP(lr.DS, lr.SI), FP_ES_DI); lr.AL = rc; - lr.SI += offset; } break; @@ -963,7 +962,7 @@ VOID ASMCFUNC int21_service(iregs FAR * r) } else { - lr.DX = (lrc >> 16); + lr.DX = (UWORD)(lrc >> 16); lr.AX = (UWORD) lrc; } } @@ -1575,7 +1574,7 @@ VOID ASMCFUNC int21_service(iregs FAR * r) { lr.AX = (UWORD)lrc; /* action */ - lr.CX = lrc >> 16; + lr.CX = (UWORD)(lrc >> 16); } break; } diff --git a/kernel/memmgr.c b/kernel/memmgr.c index 76ad9a8d..8d98cd3a 100644 --- a/kernel/memmgr.c +++ b/kernel/memmgr.c @@ -82,7 +82,7 @@ seg far2para(VOID FAR * p) seg long2para(ULONG size) { - UWORD high = size >> 16; + UWORD high = (UWORD)(size >> 16); if ((UWORD) size > 0xfff0) high++; return (((UWORD) size + 0x0f) >> 4) + (high << 12); @@ -104,7 +104,7 @@ VOID FAR * add_far(VOID FAR * fp, ULONG off) #endif off += FP_OFF(fp); - off2 = ((off >> 16) << 12) + ((UWORD) off >> 4); + off2 = ((UWORD)(off >> 16) << 12) + ((UWORD) off >> 4); return MK_FP(FP_SEG(fp) + off2, (UWORD) off & 0xf); } diff --git a/kernel/task.c b/kernel/task.c index 98cce00c..cbaa5f15 100644 --- a/kernel/task.c +++ b/kernel/task.c @@ -406,7 +406,7 @@ COUNT DosComLoader(BYTE FAR * namep, exec_blk * exp, COUNT mode, COUNT fd) ULONG com_size_long = SftGetFsize(fd); /* maximally 64k - 256 bytes stack - 256 bytes psp */ - com_size = (min(com_size_long, 0xfe00u) >> 4) + 0x10; + com_size = ((UWORD)min(com_size_long, 0xfe00u) >> 4) + 0x10; } if ((mode & 0x7f) != OVERLAY) @@ -668,7 +668,7 @@ COUNT DosExeLoader(BYTE FAR * namep, exec_blk * exp, COUNT mode, COUNT fd) mcb FAR *mp = MK_FP(mem - 1, 0); /* then the image should be placed as high as possible */ - start_seg = start_seg + mp->m_size - (image_size + 15) / 16; + start_seg = start_seg + mp->m_size - (UWORD)((image_size + 15) / 16); } } } diff --git a/utils/exeflat.c b/utils/exeflat.c index f19fd413..91dde711 100644 --- a/utils/exeflat.c +++ b/utils/exeflat.c @@ -119,7 +119,7 @@ int main(int argc, char **argv) exit(1); } - silentSegments[silentcount++] = strtol(argptr + 1, NULL, 0); + silentSegments[silentcount++] = (short)strtol(argptr + 1, NULL, 0); break; default: @@ -152,7 +152,7 @@ int main(int argc, char **argv) printf("Destination file %s could not be created\n", argv[2]); return 1; } - start_seg = strtol(argv[3], NULL, 0); + start_seg = (UWORD)strtol(argv[3], NULL, 0); if (header.exExtraBytes == 0) header.exExtraBytes = 0x200; printf("header len = %lu = 0x%lx\n", header.exHeaderSize * 16UL, From de444743cc93e37a63c5f06794371322961bf612 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sat, 7 Feb 2004 18:16:27 +0000 Subject: [PATCH 363/671] Define I386 and I186 more cleanly. Add (UWORD) casts to silence the compiler. Optimize (head*sector) to secs_per_cyl Add BORLANDC to compiler list and simplify startup printf to one message. #pragma enable_message(130) for Watcom C causes it to behave a little more like Borland in terms of warnings. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@776 6ac86273-5f31-0410-b378-82cca8765d1b --- hdr/portab.h | 16 +++++++++++----- kernel/dsk.c | 18 ++++++++++-------- kernel/main.c | 24 ++++++++++++++---------- kernel/newstuff.c | 9 +++++---- 4 files changed, 40 insertions(+), 27 deletions(-) diff --git a/hdr/portab.h b/hdr/portab.h index 9e41ea2e..733b0bad 100644 --- a/hdr/portab.h +++ b/hdr/portab.h @@ -81,10 +81,6 @@ static unsigned short __inline SS(void) asm mov ax, ss; } -#if defined(M_I286) /* /G3 doesn't set M_I386, but sets M_I286 TE */ -#define I386 -#endif - #elif defined(__WATCOMC__) /* don't know a better way */ #define I86 @@ -96,8 +92,10 @@ static unsigned short __inline SS(void) #define _SS SS() unsigned short SS(void); #pragma aux SS = "mov dx,ss" value [dx]; +/* enable Possible loss of precision warning for compatibility with Borland */ +#pragma enable_message(130) -#if _M_IX86 >= 300 +#if _M_IX86 >= 300 || defined(M_I386) #define I386 #endif @@ -114,6 +112,14 @@ unsigned short SS(void); We might even deal with a pre-ANSI compiler. This will certainly not compile. #endif +#ifdef I86 +#if _M_IX86 >= 300 || defined(M_I386) +#define I386 +#elif _M_IX86 >= 100 || defined(M_I286) +#define I186 +#endif +#endif + #ifdef MC68K #define far /* No far type */ #define interrupt /* No interrupt type */ diff --git a/kernel/dsk.c b/kernel/dsk.c index 373420c4..e3c29892 100644 --- a/kernel/dsk.c +++ b/kernel/dsk.c @@ -387,7 +387,8 @@ STATIC WORD getbpb(ddt * pddt) { ULONG count; bpb *pbpbarray = &pddt->ddt_bpb; - WORD head, /*track, */ sector, ret; + unsigned secs_per_cyl; + WORD ret; /* pddt->ddt_descflags |= DF_NOACCESS; * disabled for now - problems with FORMAT ?? */ @@ -455,21 +456,22 @@ STATIC WORD getbpb(ddt * pddt) count = pbpbarray->bpb_nsize == 0 ? pbpbarray->bpb_huge : pbpbarray->bpb_nsize; - head = pbpbarray->bpb_nheads; - sector = pbpbarray->bpb_nsecs; + secs_per_cyl = pbpbarray->bpb_nheads * pbpbarray->bpb_nsecs; - if (head == 0 || sector == 0) + if (secs_per_cyl == 0) { tmark(pddt); return failure(E_FAILURE); } - pddt->ddt_ncyl = (count + head * sector - 1) / (head * sector); + /* this field is problematic for partitions > 65535 cylinders, + in general > 512 GiB. However: we are not using it ourselves. */ + pddt->ddt_ncyl = (UWORD)((count + (secs_per_cyl - 1)) / secs_per_cyl); tmark(pddt); #ifdef DSK_DEBUG - printf("BPB_NSECS = %04x\n", sector); - printf("BPB_NHEADS = %04x\n", head); + printf("BPB_NSECS = %04x\n", pbpbarray->bpb_nsecs); + printf("BPB_NHEADS = %04x\n", pbpbarray->bpb_nheads); printf("BPB_HIDDEN = %08lx\n", pbpbarray->bpb_hidden); printf("BPB_HUGE = %08lx\n", pbpbarray->bpb_huge); #endif @@ -891,7 +893,7 @@ STATIC int LBA_to_CHS(ULONG LBA_address, struct CHS *chs, const ddt * pddt) return 1; } - chs->Cylinder = LBA_address; + chs->Cylinder = (UWORD)LBA_address; chs->Head = hsrem / pbpb->bpb_nsecs; chs->Sector = hsrem % pbpb->bpb_nsecs + 1; return 0; diff --git a/kernel/main.c b/kernel/main.c index 54c9041d..f4ed9bc6 100644 --- a/kernel/main.c +++ b/kernel/main.c @@ -332,29 +332,33 @@ STATIC VOID signon() { printf("\r%S", MK_FP(FP_SEG(LoL), FP_OFF(LoL->os_release))); - printf("Kernel compatibility %d.%d", MAJOR_RELEASE, MINOR_RELEASE); + printf("Kernel compatibility %d.%d - ", MAJOR_RELEASE, MINOR_RELEASE); -#if defined(__TURBOC__) - printf(" - TURBOC"); + printf( +#if defined(__BORLANDC__) + "BORLANDC" +#elif defined(__TURBOC__) + "TURBOC" #elif defined(_MSC_VER) - printf(" - MSC"); + "MSC" #elif defined(__WATCOMC__) - printf(" - WATCOMC"); + "WATCOMC" #elif defined(__GNUC__) - printf(" - GNUC"); /* this is hypothetical only */ + "GNUC" /* this is hypothetical only */ #else +#error Unknown compiler generate some bullshit error here, as the compiler should be known #endif #if defined (I386) - printf(" - 80386 CPU required"); + " - 80386 CPU required" #elif defined (I186) - printf(" - 80186 CPU required"); + " - 80186 CPU required" #endif #ifdef WITHFAT32 - printf(" - FAT32 support"); + " - FAT32 support" #endif - printf("\n\n%S", (void FAR *)copyright); + "\n\n%S", (void FAR *)copyright); } STATIC void kernel() diff --git a/kernel/newstuff.c b/kernel/newstuff.c index 6cd7d4aa..f8c8064e 100644 --- a/kernel/newstuff.c +++ b/kernel/newstuff.c @@ -89,7 +89,7 @@ int DosMkTmp(BYTE FAR * pathname, UWORD attr) unsigned long tmp = randvar++; int i; for(i = 7; i >= 0; tmp >>= 4, i--) - ptmp[i] = (tmp & 0xf) + 'A'; + ptmp[i] = ((char)tmp & 0xf) + 'A'; /* DOS versions: > 5: characters A - P < 5: hex digits */ @@ -602,10 +602,11 @@ COUNT truename(const char FAR * src, char * dest, COUNT mode) } /* nothing found => continue normally */ } - if ((mode & CDS_MODE_CHECK_DEV_PATH) && (result & IS_DEVICE) && - !(result & IS_NETWORK) && dest[2] != '/' && !dir_exists(dest)) + if ((mode & CDS_MODE_CHECK_DEV_PATH) && + ((result & (IS_DEVICE|IS_NETWORK)) == IS_DEVICE) && + dest[2] != '/' && !dir_exists(dest)) return DE_PATHNOTFND; - + tn_printf(("Physical path: \"%s\"\n", dest)); return result; } From b34b68a26594a813e95eae7ffa95b0630990779b Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sun, 8 Feb 2004 20:58:09 +0000 Subject: [PATCH 364/671] FcbOpen/FcbFindFirstNext: Fix a consequence of truename's funny behaviour: truename(c:nul) = c:/nul and truename(c:/nul) = c:\nul and for FCBs it's still easiest to call truename twice so we have to copy c:/nul back to c:nul to compensate. This fixes the EJECT problem from Lucho. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@777 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/fcbfns.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/kernel/fcbfns.c b/kernel/fcbfns.c index a33efdf9..657e9c91 100644 --- a/kernel/fcbfns.c +++ b/kernel/fcbfns.c @@ -407,6 +407,13 @@ UBYTE FcbOpen(xfcb FAR * lpXfcb, unsigned flags) /* pass attribute without constraints (dangerous for directories) */ attr = lpXfcb->xfcb_attrib; + /* for c:/nul c:nul must be opened instead! + * this is a consequence of truename's funny behaviour: + * truename(c:nul) = c:/nul and truename(c:/nul) = c:\nul + * and for FCBs it's easiest to call truename twice + */ + if (SecPathName[2] == '/') + strcpy(&SecPathName[2], &SecPathName[3]); sft_idx = (short)DosOpenSft(SecPathName, flags, attr); if (sft_idx < 0) { @@ -675,6 +682,9 @@ UBYTE FcbFindFirstNext(xfcb FAR * lpXfcb, BOOL First) lpDir += 7; } + /* for c:/nul c:nul must be opened instead! (see above) */ + if (SecPathName[2] == '/') + strcpy(&SecPathName[2], &SecPathName[3]); CritErrCode = -(First ? DosFindFirst(wAttr, SecPathName) : DosFindNext()); if (CritErrCode != SUCCESS) { From 0081bfe4087820e623a781896ef9f839f7f12760 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Mon, 9 Feb 2004 19:32:22 +0000 Subject: [PATCH 365/671] Don't call truename from FcbNameInit(). It was only necessary for "FcbRename", which can call it itself. This avoids yesterday's hack. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@778 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/fcbfns.c | 37 ++++++++++--------------------------- kernel/proto.h | 1 - 2 files changed, 10 insertions(+), 28 deletions(-) diff --git a/kernel/fcbfns.c b/kernel/fcbfns.c index 657e9c91..5fa50bb5 100644 --- a/kernel/fcbfns.c +++ b/kernel/fcbfns.c @@ -43,7 +43,7 @@ static BYTE *RcsId = STATIC fcb FAR *ExtFcbToFcb(xfcb FAR * lpExtFcb); STATIC fcb FAR *CommonFcbInit(xfcb FAR * lpExtFcb, BYTE * pszBuffer, COUNT * pCurDrive); -STATIC int FcbNameInit(fcb FAR * lpFcb, BYTE * pszBuffer, COUNT * pCurDrive); +STATIC void FcbNameInit(fcb FAR * lpFcb, BYTE * pszBuffer, COUNT * pCurDrive); STATIC void FcbNextRecord(fcb FAR * lpFcb); STATIC void FcbCalcRec(xfcb FAR * lpXfcb); @@ -400,20 +400,10 @@ UBYTE FcbOpen(xfcb FAR * lpXfcb, unsigned flags) /* Build a traditional DOS file name */ fcb FAR *lpFcb = CommonFcbInit(lpXfcb, SecPathName, &FcbDrive); - if (lpFcb == NULL) - return FCB_ERROR; - if ((flags & O_CREAT) && lpXfcb->xfcb_flag == 0xff) /* pass attribute without constraints (dangerous for directories) */ attr = lpXfcb->xfcb_attrib; - /* for c:/nul c:nul must be opened instead! - * this is a consequence of truename's funny behaviour: - * truename(c:nul) = c:/nul and truename(c:/nul) = c:\nul - * and for FCBs it's easiest to call truename twice - */ - if (SecPathName[2] == '/') - strcpy(&SecPathName[2], &SecPathName[3]); sft_idx = (short)DosOpenSft(SecPathName, flags, attr); if (sft_idx < 0) { @@ -459,17 +449,14 @@ STATIC fcb FAR *CommonFcbInit(xfcb FAR * lpExtFcb, BYTE * pszBuffer, sda_lpFcb = lpFcb = ExtFcbToFcb(lpExtFcb); /* Build a traditional DOS file name */ - if (FcbNameInit(lpFcb, pszBuffer, pCurDrive) < SUCCESS) - return NULL; - + FcbNameInit(lpFcb, pszBuffer, pCurDrive); /* and return the fcb pointer */ return lpFcb; } -int FcbNameInit(fcb FAR * lpFcb, BYTE * szBuffer, COUNT * pCurDrive) +STATIC void FcbNameInit(fcb FAR * lpFcb, BYTE * szBuffer, COUNT * pCurDrive) { - BYTE loc_szBuffer[2 + FNAME_SIZE + 1 + FEXT_SIZE + 1]; /* 'A:' + '.' + '\0' */ - BYTE *pszBuffer = loc_szBuffer; + BYTE *pszBuffer = szBuffer; /* Build a traditional DOS file name */ *pCurDrive = default_drive + 1; @@ -481,7 +468,6 @@ int FcbNameInit(fcb FAR * lpFcb, BYTE * szBuffer, COUNT * pCurDrive) pszBuffer += 2; } ConvertName83ToNameSZ(pszBuffer, lpFcb->fcb_fname); - return truename(loc_szBuffer, szBuffer, CDS_MODE_CHECK_DEV_PATH|CDS_MODE_ALLOW_WILDCARDS); } UBYTE FcbDelete(xfcb FAR * lpXfcb) @@ -493,7 +479,7 @@ UBYTE FcbDelete(xfcb FAR * lpXfcb) /* Build a traditional DOS file name */ fcb FAR *lpFcb = CommonFcbInit(lpXfcb, SecPathName, &FcbDrive); /* check for a device */ - if (lpFcb == NULL || IsDevice(SecPathName)) + if (IsDevice(SecPathName)) { result = FCB_ERROR; } @@ -535,7 +521,7 @@ UBYTE FcbRename(xfcb FAR * lpXfcb) lpRenameFcb = (rfcb FAR *) CommonFcbInit(lpXfcb, SecPathName, &FcbDrive); /* check for a device */ - if (lpRenameFcb == NULL || IsDevice(SecPathName)) + if (IsDevice(SecPathName)) { result = FCB_ERROR; } @@ -552,6 +538,8 @@ UBYTE FcbRename(xfcb FAR * lpXfcb) } else do { + /* 'A:' + '.' + '\0' */ + BYTE loc_szBuffer[2 + FNAME_SIZE + 1 + FEXT_SIZE + 1]; fcb LocalFcb; BYTE *pToName; const BYTE FAR *pFromPattern = Dmatch.dm_name; @@ -583,7 +571,8 @@ UBYTE FcbRename(xfcb FAR * lpXfcb) } /* now to build a dos name again */ LocalFcb.fcb_drive = FcbDrive; - result = FcbNameInit((fcb FAR *) & LocalFcb, SecPathName, &FcbDrive); + FcbNameInit(&LocalFcb, loc_szBuffer, &FcbDrive); + result = truename(loc_szBuffer, SecPathName, 0); if (result < SUCCESS || (!(result & IS_NETWORK) && (result & IS_DEVICE))) { result = FCB_ERROR; @@ -660,9 +649,6 @@ UBYTE FcbFindFirstNext(xfcb FAR * lpXfcb, BOOL First) /* Next initialze local variables by moving them from the fcb */ lpFcb = CommonFcbInit(lpXfcb, SecPathName, &FcbDrive); - if (lpFcb == NULL) - return FCB_ERROR; - /* Reconstrct the dirmatch structure from the fcb - doesn't hurt for first */ Dmatch.dm_drive = lpFcb->fcb_sftno; @@ -682,9 +668,6 @@ UBYTE FcbFindFirstNext(xfcb FAR * lpXfcb, BOOL First) lpDir += 7; } - /* for c:/nul c:nul must be opened instead! (see above) */ - if (SecPathName[2] == '/') - strcpy(&SecPathName[2], &SecPathName[3]); CritErrCode = -(First ? DosFindFirst(wAttr, SecPathName) : DosFindNext()); if (CritErrCode != SUCCESS) { diff --git a/kernel/proto.h b/kernel/proto.h index 46662076..4f2acb82 100644 --- a/kernel/proto.h +++ b/kernel/proto.h @@ -214,7 +214,6 @@ void FcbSetRandom(xfcb FAR * lpXfcb); UBYTE FcbRandomBlockIO(xfcb FAR * lpXfcb, UWORD *nRecords, int mode); UBYTE FcbRandomIO(xfcb FAR * lpXfcb, int mode); UBYTE FcbOpen(xfcb FAR * lpXfcb, unsigned flags); -int FcbNameInit(fcb FAR * lpFcb, BYTE * pszBuffer, COUNT * pCurDrive); UBYTE FcbDelete(xfcb FAR * lpXfcb); UBYTE FcbRename(xfcb FAR * lpXfcb); UBYTE FcbClose(xfcb FAR * lpXfcb); From f03eba4e15006b73c00b114ebecf116959bf2179 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Mon, 9 Feb 2004 19:35:50 +0000 Subject: [PATCH 366/671] Remove unused variable lpFcb. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@779 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/fcbfns.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/fcbfns.c b/kernel/fcbfns.c index 5fa50bb5..8f67bccd 100644 --- a/kernel/fcbfns.c +++ b/kernel/fcbfns.c @@ -477,7 +477,7 @@ UBYTE FcbDelete(xfcb FAR * lpXfcb) void FAR *lpOldDta = dta; /* Build a traditional DOS file name */ - fcb FAR *lpFcb = CommonFcbInit(lpXfcb, SecPathName, &FcbDrive); + CommonFcbInit(lpXfcb, SecPathName, &FcbDrive); /* check for a device */ if (IsDevice(SecPathName)) { From decc3f5c37f1d147a32f8f8f8607ae81d9b05839 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Mon, 23 Feb 2004 23:26:01 +0000 Subject: [PATCH 367/671] From Lucho: smaller Protect/Restore 386 register macros. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@785 6ac86273-5f31-0410-b378-82cca8765d1b --- hdr/stacks.inc | 40 ++++++++++++++++------------------------ 1 file changed, 16 insertions(+), 24 deletions(-) diff --git a/hdr/stacks.inc b/hdr/stacks.inc index a74c9f61..1321b55b 100644 --- a/hdr/stacks.inc +++ b/hdr/stacks.inc @@ -146,18 +146,14 @@ irp_hi equ 26 push fs push gs %else - ror eax,16 - push ax - ror eax,16 - ror ebx,16 - push bx - ror ebx,16 - ror ecx,16 - push cx - ror ecx,16 - ror edx,16 - push dx - ror edx,16 + push eax + pop ax + push ebx + pop bx + push ecx + pop cx + push edx + pop dx %endif %endmacro @@ -168,18 +164,14 @@ irp_hi equ 26 pop gs pop fs %else - ror edx,16 - pop dx - ror edx,16 - ror ecx,16 - pop cx - ror ecx,16 - ror ebx,16 - pop bx - ror ebx,16 - ror eax,16 - pop ax - ror eax,16 + push dx + pop edx + push cx + pop ecx + push bx + pop ebx + push ax + pop eax %endif %endmacro From 47ae1ab1d3159aca45f5ec3bfefd5a467a8672f6 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Mon, 23 Feb 2004 23:41:17 +0000 Subject: [PATCH 368/671] From Lucho: fix EBDA problems with INSTALL. This fixes the weird fmemcpy lockup; in reality kernel init code was overwritten. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@786 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/config.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/kernel/config.c b/kernel/config.c index 8eb1d31b..64b74b1a 100644 --- a/kernel/config.c +++ b/kernel/config.c @@ -133,6 +133,7 @@ STATIC void SelectLine(int MenuSelected) UWORD umb_start = 0, UMB_top = 0; UWORD ram_top = 0; /* How much ram in Kbytes */ +size_t ebda_size = 0; static UBYTE ErrorAlreadyPrinted[128]; @@ -401,7 +402,6 @@ void PreConfig(void) void PreConfig2(void) { struct sfttbl FAR *sp; - unsigned ebda_size; /* initialize NEAR allocated things */ @@ -422,7 +422,6 @@ void PreConfig2(void) base_seg = LoL->first_mcb = FP_SEG(AlignParagraph((BYTE FAR *) DynLast() + 0x0f)); - ebda_size = 0; if (Config.ebda2move) { ebda_size = ebdasize(); @@ -2659,7 +2658,7 @@ VOID DoInstall(void) r.b.b.l = 0x02; /*low memory, last fit */ init_call_intr(0x21, &r); - allocmem(((unsigned)_init_end+15)/16, &installMemory); + allocmem(((unsigned)_init_end + ebda_size + 15) / 16, &installMemory); InstallPrintf(("allocated memory at %x\n",installMemory)); From 5214472bf75c367a3a754ed7af8c368e677820f4 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Tue, 24 Feb 2004 00:25:56 +0000 Subject: [PATCH 369/671] Use asmsupt string and mem functions for the init code too. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@787 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/asmsupt.asm | 35 +++++++++++++++++++++++++++++++++-- kernel/config.c | 20 ++++++-------------- kernel/init-mod.h | 30 +++++++++++++++++++++--------- kernel/inithma.c | 11 ----------- kernel/main.c | 31 ++----------------------------- kernel/makefile | 6 +++++- kernel/prf.c | 2 +- 7 files changed, 68 insertions(+), 67 deletions(-) diff --git a/kernel/asmsupt.asm b/kernel/asmsupt.asm index 1b3b2bf1..0b6765c8 100644 --- a/kernel/asmsupt.asm +++ b/kernel/asmsupt.asm @@ -36,7 +36,33 @@ %include "segs.inc" -segment HMA_TEXT +%ifdef _INIT + + segment INIT_TEXT + %define FMEMCPYBACK INIT_FMEMCPYBACK + %define MEMCPY INIT_MEMCPY + %define FMEMCPY INIT_FMEMCPY + %define MEMSET INIT_MEMSET + %define FMEMSET INIT_FMEMSET + %define STRCPY INIT_STRCPY + %define FSTRCPY INIT_FSTRCPY + %define STRLEN INIT_STRLEN + %define FSTRLEN INIT_FSTRLEN + %define FMEMCHR INIT_FMEMCHR + %define FSTRCHR INIT_FSTRCHR + %define STRCHR INIT_STRCHR + %define FSTRCMP INIT_FSTRCMP + %define STRCMP INIT_STRCMP + %define FSTRNCMP INIT_FSTRNCMP + %define STRNCMP INIT_STRNCMP + %define FMEMCMP INIT_FMEMCMP + %define MEMCMP INIT_MEMCMP + +%else + + segment HMA_TEXT + +%endif ;********************************************************************* ; this implements some of the common string handling functions @@ -225,7 +251,7 @@ pascal_return: ; fstrcpy (void FAR*dest, void FAR *src); - +%ifndef _INIT global FSTRCPY FSTRCPY: call pascal_setup @@ -239,6 +265,7 @@ FSTRCPY: mov bl,8 jmp short dostrcpy +%endif ;****** global STRCPY @@ -294,6 +321,8 @@ dostrlen: jmp short pascal_return +%ifndef _INIT + ;************************************************************ ; strchr (BYTE *src , int ch); @@ -366,6 +395,8 @@ FMEMCHR: mov ax, di jmp short strchr_found1 +%endif + ;********************************************************************** %if 0 nix pascal - still untested diff --git a/kernel/config.c b/kernel/config.c index 64b74b1a..419d35c3 100644 --- a/kernel/config.c +++ b/kernel/config.c @@ -1047,17 +1047,17 @@ STATIC VOID Dosmem(BYTE * pLine) for (pTmp = szBuf;;) { - if (fmemcmp(pTmp, "UMB", 3) == 0) + if (memcmp(pTmp, "UMB", 3) == 0) { UMBwanted = TRUE; pTmp += 3; } - if (fmemcmp(pTmp, "HIGH", 4) == 0) + if (memcmp(pTmp, "HIGH", 4) == 0) { HMAState = HMA_REQ; pTmp += 4; } -/* if (fmemcmp(pTmp, "CLAIMINIT",9) == 0) { INITDataSegmentClaimed = 0; pTmp += 9; }*/ +/* if (memcmp(pTmp, "CLAIMINIT",9) == 0) { INITDataSegmentClaimed = 0; pTmp += 9; }*/ pTmp = skipwh(pTmp); if (*pTmp != ',') @@ -1083,7 +1083,7 @@ STATIC VOID DosData(BYTE * pLine) pLine = GetStringArg(pLine, szBuf); strupr(szBuf); - if (fmemcmp(szBuf, "UMB", 3) == 0) + if (memcmp(szBuf, "UMB", 3) == 0) Config.cfgDosDataUmb = TRUE; } @@ -1705,14 +1705,6 @@ STATIC VOID mumcb_init(UCOUNT seg, UWORD size) } #endif -static size_t strlen(const char *s) -{ - size_t n = 0; - while (*s++) - n++; - return n; -} - char *strcat(register char * d, register const char * s) { strcpy(d + strlen(d), s); @@ -1894,7 +1886,7 @@ STATIC VOID CfgMenu(BYTE * pLine) (change struct at top of file if you want more...) */ if (nLen > MENULINEMAX-1) nLen = MENULINEMAX-1; - fmemcpy(MenuStruct[nIndex].Text, pLine, nLen); + memcpy(MenuStruct[nIndex].Text, pLine, nLen); MenuStruct[nIndex].Text[nLen] = 0; /* nullTerminate */ } nMenuLine++; @@ -2576,7 +2568,7 @@ STATIC VOID _CmdInstall(BYTE * pLine,int mode) CfgFailure(pLine); return; } - fmemcpy(InstallCommands[numInstallCmds].buffer,pLine,127); + memcpy(InstallCommands[numInstallCmds].buffer,pLine,127); InstallCommands[numInstallCmds].buffer[127] = 0; InstallCommands[numInstallCmds].mode = mode; numInstallCmds++; diff --git a/kernel/init-mod.h b/kernel/init-mod.h index 51c6af91..4b9b1d56 100644 --- a/kernel/init-mod.h +++ b/kernel/init-mod.h @@ -35,23 +35,35 @@ extern struct _KernelConfig InitKernelConfig; #define printf init_printf #define sprintf init_sprintf #define execrh init_execrh +#define memcpy init_memcpy #define fmemcpy init_fmemcpy #define fmemset init_fmemset #define fmemcmp init_fmemcmp -#define memset init_memset -#define strcpy init_strcpy -WORD ASMCFUNC execrh(request FAR *, struct dhdr FAR *); -void fmemcpy(void far *d, const void far *s, unsigned n); -void fmemset(void far *s, int ch, unsigned n); -void memset(void *s, int ch, unsigned n); -void strcpy(char *dest, const char *src); - +#define memcmp init_memcmp +#define memset init_memset +#define strcpy init_strcpy +#define strlen init_strlen +#define fstrlen init_fstrlen + +/* execrh.asm */ +WORD ASMCFUNC execrh(request FAR *, struct dhdr FAR *); + +/* asmsupt.asm */ +VOID ASMPASCAL memset( void *s, int ch, size_t n); +VOID ASMPASCAL fmemset( void FAR *s, int ch, size_t n); +int ASMPASCAL memcmp(const void *m1, const void *m2, size_t n); +int ASMPASCAL fmemcmp(const void FAR *m1, const void FAR *m2, size_t n); +VOID ASMPASCAL memcpy( void *d, const void *s, size_t n); +VOID ASMPASCAL fmemcpy( void FAR *d, const void FAR *s, size_t n); +VOID ASMPASCAL strcpy(char *d, const char *s); +size_t ASMPASCAL strlen(const char *s); +size_t ASMPASCAL fstrlen(const char FAR *s); + #undef LINESIZE #define LINESIZE KBD_MAXLENGTH /*inithma.c*/ extern BYTE DosLoadedInHMA; -int fmemcmp(BYTE far * s1, BYTE FAR * s2, unsigned len); void MoveKernel(unsigned NewKernelSegment); #define setvec(n, isr) (void)(*(intvec FAR *)MK_FP(0,4 * (n)) = (isr)) diff --git a/kernel/inithma.c b/kernel/inithma.c index 73aef6eb..b943cac0 100644 --- a/kernel/inithma.c +++ b/kernel/inithma.c @@ -113,17 +113,6 @@ VOID hdump(BYTE FAR * p) #define KeyboardShiftState() (*(BYTE FAR *)(MK_FP(0x40,0x17))) -/* of course, this should go to ASMSUPT */ -int fmemcmp(BYTE far * s1, BYTE FAR * s2, unsigned len) -{ - for (; len; s1++, s2++, --len) - { - if (*s1 - *s2) - return *s1 - *s2; - } - return 0; -} - /* this tests, if the HMA area can be enabled. if so, it simply leaves it on diff --git a/kernel/main.c b/kernel/main.c index f4ed9bc6..a909c3f2 100644 --- a/kernel/main.c +++ b/kernel/main.c @@ -70,33 +70,6 @@ struct lol FAR *LoL; struct lol FAR *LoL = &DATASTART; #endif -/* little functions - could be ASM but does not really matter in this context */ -void memset(void *s, int c, unsigned n) -{ - char *t = s; - while(n--) *t++ = c; -} - -void fmemset(void far *s, int c, unsigned n) -{ - char far *t = s; - while(n--) *t++ = c; -} - -void strcpy(char *dest, const char *src) -{ - while(*src) - *dest++ = *src++; - *dest = '\0'; -} - -void fmemcpy(void far *dest, const void far *src, unsigned n) -{ - char far *d = dest; - const char far *s = src; - while(n--) *d++ = *s++; -} - VOID ASMCFUNC FreeDOSmain(void) { unsigned char drv; @@ -375,7 +348,7 @@ STATIC void kernel() /* process 0 */ /* Execute command.com /P from the drive we just booted from */ memset(Cmd.ctBuffer, 0, sizeof(Cmd.ctBuffer)); - fmemcpy(Cmd.ctBuffer, Config.cfgInitTail, sizeof(Config.cfgInitTail)); + memcpy(Cmd.ctBuffer, Config.cfgInitTail, sizeof(Config.cfgInitTail)); for (Cmd.ctCount = 0; Cmd.ctCount < sizeof(Cmd.ctBuffer); Cmd.ctCount++) if (Cmd.ctBuffer[Cmd.ctCount] == '\r') @@ -406,7 +379,7 @@ STATIC void kernel() for (q = &Cmd.ctBuffer[Cmd.ctCount - 1]; q >= p; q--) q[3] = q[0]; - fmemcpy(p, insertString, 3); + memcpy(p, insertString, 3); Cmd.ctCount += 3; break; diff --git a/kernel/makefile b/kernel/makefile index 352dab19..37d424da 100644 --- a/kernel/makefile +++ b/kernel/makefile @@ -40,7 +40,7 @@ error.obj OBJS4=break.obj dosfns.obj fatdir.obj fatfs.obj fattab.obj fcbfns.obj \ inthndlr.obj OBJS5=ioctl.obj dosnames.obj memmgr.obj task.obj newstuff.obj nls.obj network.obj -OBJS6=prf.obj misc.obj strings.obj syspack.obj lfnapi.obj +OBJS6=prf.obj misc.obj strings.obj syspack.obj lfnapi.obj iasmsupt.obj OBJS7=main.obj config.obj initoem.obj inithma.obj dyninit.obj iprf.obj \ initdisk.obj initclk.obj OBJS = $(OBJS1) $(OBJS2) $(OBJS3) $(OBJS4) $(OBJS5) $(OBJS6) $(OBJS7) @@ -220,6 +220,10 @@ initclk.obj: initclk.c $(INITHEADERS) $(HEADERS) $(CONFIGURATION) $(CC) $(INITCFLAGS) $*.c $(INITPATCH) $*.obj +#the string functions for INIT_TEXT +iasmsupt.obj: asmsupt.asm $(CONFIGURATION) + $(NASM) -D$(COMPILER) -D_INIT $(NASMFLAGS) -f obj -o iasmsupt.obj asmsupt.asm + #the printf for INIT_TEXT - yet another special case, this file includes prf.c iprf.obj: iprf.c prf.c $(HDR)portab.h $(CONFIGURATION) $(CC) $(INITCFLAGS) $*.c diff --git a/kernel/prf.c b/kernel/prf.c index ce25a37b..453a0a12 100644 --- a/kernel/prf.c +++ b/kernel/prf.c @@ -136,7 +136,7 @@ int CDECL printf(CONST BYTE * fmt, ...); /* The following is user supplied and must match the following prototype */ VOID cso(COUNT); -#if defined(FORSYS) || defined(_INIT) +#if defined(FORSYS) COUNT fstrlen(BYTE FAR * s) /* don't want globals.h, sorry */ { int i = 0; From 216f51cb659e46fa6e65dddb1f5dc88441637400 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Tue, 24 Feb 2004 13:11:14 +0000 Subject: [PATCH 370/671] Use memcpy instead of fmemcpy where possible. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@788 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/initdisk.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/initdisk.c b/kernel/initdisk.c index 33f45623..ae42fb56 100644 --- a/kernel/initdisk.c +++ b/kernel/initdisk.c @@ -863,7 +863,7 @@ BOOL ScanForPrimaryPartitions(struct DriveParamS * driveParam, int scan_type, printCHS(" with calculated values ", &chs); printCHS(" instead of ", &pEntry->Begin); printf("\n"); - fmemcpy(&pEntry->Begin, &chs, sizeof(struct CHS)); + memcpy(&pEntry->Begin, &chs, sizeof(struct CHS)); } @@ -885,7 +885,7 @@ BOOL ScanForPrimaryPartitions(struct DriveParamS * driveParam, int scan_type, printCHS(" with calculated values ", &end); printCHS(" instead of ", &pEntry->End); printf("\n"); - fmemcpy(&pEntry->End, &end, sizeof(struct CHS)); + memcpy(&pEntry->End, &end, sizeof(struct CHS)); } From d06b147cb0b60a2f9afd33896e840f3f788e6cee Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Tue, 24 Feb 2004 23:24:27 +0000 Subject: [PATCH 371/671] Save a couple bytes by moving the strncmp_retzero block. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@789 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/asmsupt.asm | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/kernel/asmsupt.asm b/kernel/asmsupt.asm index 0b6765c8..5283c4be 100644 --- a/kernel/asmsupt.asm +++ b/kernel/asmsupt.asm @@ -468,15 +468,8 @@ strncmp_loop: jne strncmp_done test al,al loopne strncmp_loop + jmp short strncmp_retzero %endif -strncmp_retzero: - xor ax, ax - jmp short strncmp_done2 -strncmp_done: - lahf - ror ah,1 -strncmp_done2: jmp pascal_return - ;********************************************************************** ; fmemcmp(BYTE FAR *s1 , BYTE FAR *s2, int count); @@ -516,4 +509,11 @@ domemcmp: jcxz strncmp_retzero repe cmpsb jne strncmp_done - jmp short strncmp_retzero +strncmp_retzero: + xor ax, ax + jmp short strncmp_done2 +strncmp_done: + lahf + ror ah,1 +strncmp_done2: jmp pascal_return + From a779a1407066e774ea031c6f476840eecf3df1c3 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Tue, 24 Feb 2004 23:46:04 +0000 Subject: [PATCH 372/671] Merge "suspect partition" copy/paste code into functions. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@790 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/initdisk.c | 51 +++++++++++++++++++++++------------------------ 1 file changed, 25 insertions(+), 26 deletions(-) diff --git a/kernel/initdisk.c b/kernel/initdisk.c index ae42fb56..35cc7383 100644 --- a/kernel/initdisk.c +++ b/kernel/initdisk.c @@ -806,6 +806,25 @@ BOOL ConvPartTableEntryToIntern(struct PartTableEntry * pEntry, return TRUE; } +BOOL is_suspect(struct CHS *chs, struct CHS *pEntry_chs) +{ + return !((chs->Cylinder & 0x3ff) == pEntry_chs->Cylinder || + 1023 == pEntry_chs->Cylinder || + (chs->Cylinder == pEntry_chs->Cylinder && + chs->Head == pEntry_chs->Head && + chs->Sector == pEntry_chs->Sector)); +} + +void print_warning_suspect(char *partitionName, UBYTE fs, struct CHS *chs, + struct CHS *pEntry_chs) +{ + printf("WARNING: using suspect partition %s FS %02x:", partitionName, fs); + printCHS(" with calculated values ", chs); + printCHS(" instead of ", pEntry_chs); + printf("\n"); + memcpy(pEntry_chs, chs, sizeof(struct CHS)); +} + BOOL ScanForPrimaryPartitions(struct DriveParamS * driveParam, int scan_type, struct PartTableEntry * pEntry, ULONG startSector, int partitionsToIgnore, int extendedPartNo) @@ -852,41 +871,21 @@ BOOL ScanForPrimaryPartitions(struct DriveParamS * driveParam, int scan_type, > 8 GB cyl = 1023, other (cyl&1023) */ - if (!((chs.Cylinder & 0x3ff) == pEntry->Begin.Cylinder || - 1023 == pEntry->Begin.Cylinder || - (chs.Cylinder == pEntry->Begin.Cylinder && - chs.Head == pEntry->Begin.Head && - chs.Sector == pEntry->Begin.Sector))) + if (is_suspect(&chs, &pEntry->Begin)) { - printf("WARNING: using suspect partition %s FS %02x:", - partitionName, pEntry->FileSystem); - printCHS(" with calculated values ", &chs); - printCHS(" instead of ", &pEntry->Begin); - printf("\n"); - memcpy(&pEntry->Begin, &chs, sizeof(struct CHS)); - + print_warning_suspect(partitionName, pEntry->FileSystem, &chs, + &pEntry->Begin); } - if (!((end.Cylinder & 0x3ff) == pEntry->End.Cylinder || - 1023 == pEntry->End.Cylinder || - (end.Cylinder == pEntry->End.Cylinder && - end.Head == pEntry->End.Head && - end.Sector == pEntry->End.Sector))) + if (is_suspect(&end, &pEntry->End)) { if (pEntry->NumSect == 0) { printf("Not using partition %s with 0 sectors\n", partitionName); continue; } - - printf("WARNING: using suspect partition %s FS %02x:", - partitionName, pEntry->FileSystem); - - printCHS(" with calculated values ", &end); - printCHS(" instead of ", &pEntry->End); - printf("\n"); - memcpy(&pEntry->End, &end, sizeof(struct CHS)); - + print_warning_suspect(partitionName, pEntry->FileSystem, &end, + &pEntry->End); } if (chs.Cylinder > 1023 || end.Cylinder > 1023) From 9e92e3025b5a66db4dab65b6a165e87b12e716e3 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Tue, 2 Mar 2004 10:46:28 +0000 Subject: [PATCH 373/671] Correct int25/26 pragmas. Need to explicitly preserve bp and pop flags. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@791 6ac86273-5f31-0410-b378-82cca8765d1b --- sys/sys.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/sys/sys.c b/sys/sys.c index af59665a..37e4f65a 100644 --- a/sys/sys.c +++ b/sys/sys.c @@ -435,18 +435,24 @@ VOID dump_sector(unsigned char far * sec) int absread(int DosDrive, int nsects, int foo, void *diskReadPacket); #pragma aux absread = \ + "push bp" \ "int 0x25" \ + "popf" \ + "pop bp" \ "sbb ax, ax" \ parm [ax] [cx] [dx] [bx] \ - modify [si di bp] \ + modify [si di] \ value [ax]; int abswrite(int DosDrive, int nsects, int foo, void *diskReadPacket); #pragma aux abswrite = \ + "push bp" \ "int 0x26" \ + "popf" \ + "pop bp" \ "sbb ax, ax" \ parm [ax] [cx] [dx] [bx] \ - modify [si di bp] \ + modify [si di] \ value [ax]; fat32readwrite(int DosDrive, void *diskReadPacket, unsigned intno); From 1c6f3640a3043e287cd4d771418956b714daacd6 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sun, 7 Mar 2004 11:09:52 +0000 Subject: [PATCH 374/671] Borland C (unlike Turbo C) didn't like this pseudo register use. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@792 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/prf.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/kernel/prf.c b/kernel/prf.c index 453a0a12..e4ed0896 100644 --- a/kernel/prf.c +++ b/kernel/prf.c @@ -100,7 +100,8 @@ void put_console(int c) write(1, &c, 1); /* write character to stdout */ #else #if defined(__TURBOC__) - _AX = 0x0e00 | c; + _AL = c; + _AH = 0x0e; _BX = 0x0070; __int__(0x10); #elif defined(I86) From eaf31bcf801ddcd74021bd1f3ab951743a1dd526 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sun, 7 Mar 2004 11:38:49 +0000 Subject: [PATCH 375/671] From Lucho: update contributors list. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@793 6ac86273-5f31-0410-b378-82cca8765d1b --- docs/contrib.txt | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/docs/contrib.txt b/docs/contrib.txt index ba77e2d4..f5fede2e 100644 --- a/docs/contrib.txt +++ b/docs/contrib.txt @@ -1,22 +1,34 @@ -These are the know contributors of the FreeDOS kernel. If you have +These are the known contributors of the FreeDOS kernel. If you have contributed in any way to the kernel, but are not on this list, please email me at bart@dosemu.org so I can add you to the list! Thanks to all the following for contributing to the FreeDOS kernel: -ror4 (ror4@angelfire.com) -Steffen Kaiser (Steffen.Kaiser@fh-rhein-sieg.de) +Arkady Belousov (ark@mos.ru) +Bart Oldeman (bart@dosemu.org) +Brian Reifsnyder (reifsnyderb@mindspring.com) Charles Dye (raster@highfiber.com) -John Price (linux-guru@gcfl.net) -Steve Miller (SMiller@dsfx.com) -Jens Horstmeier (Jens.Horstmeier@Abg1.SIEMENS.DE) -James Tabor (jimtabor@infohwy.com) +Eric Auer (eric@coli.uni-sb.de) Eric Biederman (ebiederm+eric@ccr.net) -Tom Ehlert (tom.ehlert@ginko.de) -Victor Vlasenko (victor_vlasenko@hotbox.ru) +Eric Luttmann (ecl@users.sourceforge.net) +Helmut Fritsch (helmut.fritsch@gcd-hs.de) +James Tabor (jimtabor@infohwy.com) +Jens Horstmeier (Jens.Horstmeier@abg1.siemens.de) Jeremy Davis (jeremyd@computer.org) +Jim Hall (jhall@freedos.org) +John Price (linux-guru@gcfl.net) +Kolya Ksenev (7207@mx.csd.tsu.ru) +Lixing Yuan (yuanlixg@china.com) +Luchezar Georgiev (lig@linux.tu-varna.acad.bg) Martin Stromberg (ams@ludd.luth.se) -Bart Oldeman (bart@dosemu.org) +Michal Bakowski (mb@orad.pl) +Ron Cemer (roncemer@gte.net) +"ror4" (ror4@angelfire.com) +Rune Espeseth (re@icd.no) +Steffen Kaiser (Steffen.Kaiser@fh-rhein-sieg.de) +Steve Miller (SMiller@dsfx.com) +Tom Ehlert (te@drivesnapshot.de) +Victor Vlasenko (victor_vlasenko@hotbox.ru) At this place we should also thank Ralf Brown for his interrupt list. It is a truely invaluable resource for us. From d61defe941ec706e87067a34e57ed15465663e31 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sun, 7 Mar 2004 11:56:14 +0000 Subject: [PATCH 376/671] From Lucho: move NLS #defines to nls.h. Move config structure to config.h. Some cosmetic changes. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@794 6ac86273-5f31-0410-b378-82cca8765d1b --- hdr/nls.h | 9 ++++++++ kernel/config.h | 34 +++++++++++++++++++++++-------- kernel/globals.h | 1 - kernel/init-mod.h | 52 +++++------------------------------------------ 4 files changed, 40 insertions(+), 56 deletions(-) diff --git a/hdr/nls.h b/hdr/nls.h index 4dcf0c71..2e595cec 100644 --- a/hdr/nls.h +++ b/hdr/nls.h @@ -615,3 +615,12 @@ struct nlsCSys_loadPackage { /* standard alignment */ #include + +#ifdef DEBUG + /* Enable debugging of NLS part */ + + /* Caution: Enabling NLS debugging usually generates + _a_lot_ of noise. */ +/*& #define NLS_DEBUG */ + +#endif diff --git a/kernel/config.h b/kernel/config.h index d06e885b..c55cc52d 100644 --- a/kernel/config.h +++ b/kernel/config.h @@ -27,11 +27,29 @@ /* Cambridge, MA 02139, USA. */ /****************************************************************/ -#ifdef DEBUG - /* Enable debugging of NLS part */ - - /* Caution: Enabling NLS debugging usually generates - _a_lot_ of noise. */ -/*& #define NLS_DEBUG */ - -#endif +struct config { /* Configuration variables */ + UBYTE cfgDosDataUmb; + BYTE cfgBuffers; /* number of buffers in the system */ + UBYTE cfgFiles; /* number of available files */ + UBYTE cfgFilesHigh; + UBYTE cfgFcbs; /* number of available FCBs */ + UBYTE cfgProtFcbs; /* number of protected FCBs */ + BYTE cfgInit[NAMEMAX]; /* init of command.com */ + BYTE cfgInitTail[NAMEMAX]; /* command.com's tail */ + UBYTE cfgLastdrive; /* last drive */ + UBYTE cfgLastdriveHigh; + BYTE cfgStacks; /* number of stacks */ + BYTE cfgStacksHigh; + UWORD cfgStackSize; /* stacks size for each stack */ + /* COUNTRY= + * In Pass #1 these information is collected and in PostConfig() + * the NLS package is loaded into memory. -- 2000/06/11 ska + */ + WORD cfgCSYS_cntry; /* country ID to be loaded */ + UWORD cfgCSYS_cp; /* requested codepage; NLS_DEFAULT if default */ + BYTE cfgCSYS_fnam[NAMEMAX];/* filename of COUNTRY= */ + WORD cfgCSYS_memory; /* # of bytes required for the NLS pkg; 0 if none */ + VOID FAR *cfgCSYS_data; /* where the loaded data is for PostConfig() */ + UBYTE cfgP_0_startmode; /* load command.com high or not */ + unsigned ebda2move; /* value for switches=/E:nnnn */ +}; diff --git a/kernel/globals.h b/kernel/globals.h index 6365b35b..a981c09d 100644 --- a/kernel/globals.h +++ b/kernel/globals.h @@ -54,7 +54,6 @@ static BYTE *Globals_hRcsId = #include "error.h" #include "version.h" #include "network.h" -#include "config.h" #include "buffer.h" #include "dcb.h" #include "xstructs.h" diff --git a/kernel/init-mod.h b/kernel/init-mod.h index 4b9b1d56..9fc3ec26 100644 --- a/kernel/init-mod.h +++ b/kernel/init-mod.h @@ -80,54 +80,10 @@ void MoveKernel(unsigned NewKernelSegment); #define MAX_HARD_DRIVE 8 #define NDEV 26 /* up to Z: */ -/* Start of configuration variables */ -struct config { - UBYTE cfgDosDataUmb; - BYTE cfgBuffers; - /* number of buffers in the system */ - UBYTE cfgFiles; - UBYTE cfgFilesHigh; - /* number of available files */ - UBYTE cfgFcbs; - /* number of available FCBs */ - UBYTE cfgProtFcbs; - /* number of protected FCBs */ - BYTE cfgInit[NAMEMAX]; - /* init of command.com */ - BYTE cfgInitTail[NAMEMAX]; - /* command.com's tail */ - UBYTE cfgLastdrive; - UBYTE cfgLastdriveHigh; - /* last drive */ - BYTE cfgStacks; - BYTE cfgStacksHigh; - /* number of stacks */ - UWORD cfgStackSize; - /* stacks size for each stack */ - /* COUNTRY= - In Pass #1 these information is collected and in PostConfig() - the NLS package is loaded into memory. - -- 2000/06/11 ska */ - WORD cfgCSYS_cntry; - /* country ID to be loaded */ - UWORD cfgCSYS_cp; - /* requested codepage; NLS_DEFAULT if default */ - BYTE cfgCSYS_fnam[NAMEMAX]; - /* filename of COUNTRY= */ - WORD cfgCSYS_memory; - /* number of bytes required for the NLS pkg; - 0 if none */ - VOID FAR *cfgCSYS_data; - /* where the loaded data is for PostConfig() */ - UBYTE cfgP_0_startmode; - /* load command.com high or not */ - unsigned ebda2move; - /* value for switches=/E:nnnn */ -}; - -extern struct config Config; +#include "config.h" /* config structure */ /* config.c */ +extern struct config Config; VOID PreConfig(VOID); VOID PreConfig2(VOID); VOID DoConfig(int pass); @@ -183,7 +139,6 @@ VOID ASMCFUNC int21_service(iregs far * r); VOID ASMCFUNC FAR int0_handler(void); VOID ASMCFUNC FAR int6_handler(void); VOID ASMCFUNC FAR empty_handler(void); -VOID ASMCFUNC FAR got_cbreak(void); /* procsupt.asm */ VOID ASMCFUNC FAR int20_handler(void); VOID ASMCFUNC FAR int21_handler(void); VOID ASMCFUNC FAR int22_handler(void); @@ -207,6 +162,9 @@ VOID init_fatal(BYTE * err_msg); WORD CDECL init_printf(CONST BYTE * fmt, ...); WORD CDECL init_sprintf(BYTE * buff, CONST BYTE * fmt, ...); +/* procsupt.asm */ +VOID ASMCFUNC FAR got_cbreak(void); + /* initclk.c */ extern void Init_clk_driver(void); From 3e3c05ff229571d6ea4513781aa755e7f4964ef0 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sun, 7 Mar 2004 12:19:43 +0000 Subject: [PATCH 377/671] From Lucho: enable interactive re-execution of the SHELL. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@795 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/init-mod.h | 3 +++ kernel/intr.asm | 30 +++++++++++++++++++++++++ kernel/kernel.asm | 9 ++++++++ kernel/main.c | 55 ++++++--------------------------------------- kernel/procsupt.asm | 19 ++++++++++++++++ kernel/proto.h | 4 ++++ kernel/task.c | 50 +++++++++++++++++++++++++++++++++++++++++ 7 files changed, 122 insertions(+), 48 deletions(-) diff --git a/kernel/init-mod.h b/kernel/init-mod.h index 9fc3ec26..3a63973f 100644 --- a/kernel/init-mod.h +++ b/kernel/init-mod.h @@ -152,6 +152,9 @@ VOID ASMCFUNC FAR int2a_handler(void); VOID ASMCFUNC FAR int2f_handler(void); VOID ASMCFUNC FAR cpm_entry(void); +/* kernel.asm */ +VOID ASMCFUNC FAR init_call_p_0(struct config FAR *Config); /* P_0, actually */ + /* main.c */ VOID ASMCFUNC FreeDOSmain(void); BOOL init_device(struct dhdr FAR * dhp, char * cmdLine, diff --git a/kernel/intr.asm b/kernel/intr.asm index 41ac1280..ad08028d 100644 --- a/kernel/intr.asm +++ b/kernel/intr.asm @@ -89,6 +89,36 @@ segment HMA_TEXT _intr: INTR +;; COUNT ASMCFUNC res_DosExec(COUNT mode, exec_blk * ep, BYTE * lp) + global _res_DosExec +_res_DosExec: + mov ah, 4bh + mov bx, sp + mov al, [bx+2] + push ds + pop es + mov dx, [bx+6] ; filename + mov bx, [bx+4] ; exec block + int 21h + jc short no_exec_error + xor ax, ax +no_exec_error: + ret + +;; UCOUNT ASMCFUNC res_read(int fd, void *buf, UCOUNT count); + global _res_read +_res_read: + mov bx, sp + mov cx, [bx+6] + mov dx, [bx+4] + mov bx, [bx+2] + mov ah, 3fh + int 21h + jnc no_read_error + mov ax, -1 +no_read_error: + ret + segment INIT_TEXT ; ; void init_call_intr(nr, rp) diff --git a/kernel/kernel.asm b/kernel/kernel.asm index 0404a946..265b1185 100644 --- a/kernel/kernel.asm +++ b/kernel/kernel.asm @@ -673,6 +673,10 @@ _swap_indos: ; _swap_indos but only if int2a ah=80/81 (critical section start/end) ; are called upon entry and exit of the device drivers + times 96 dw 0x9090 ; Process 0 Stack + global _p_0_tos +_p_0_tos: + segment DYN_DATA global _Dyn @@ -830,6 +834,11 @@ _reloc_call_clk_driver: _CharMapSrvc: jmp 0:_reloc_call_CharMapSrvc call near forceEnableA20 + global _init_call_p_0 + extern reloc_call_p_0 +_init_call_p_0: jmp 0:reloc_call_p_0 + call near forceEnableA20 + global __HMARelocationTableEnd __HMARelocationTableEnd: diff --git a/kernel/main.c b/kernel/main.c index a909c3f2..176500ef 100644 --- a/kernel/main.c +++ b/kernel/main.c @@ -336,17 +336,14 @@ STATIC VOID signon() STATIC void kernel() { - exec_blk exb; CommandTail Cmd; - int rc; - exb.exec.env_seg = DOS_PSP + 8; if (master_env[0] == '\0') /* some shells panic on empty master env. */ strcpy(master_env, "PATH=."); - fmemcpy(MK_FP(exb.exec.env_seg, 0), master_env, sizeof(master_env)); + fmemcpy(MK_FP(DOS_PSP + 8, 0), master_env, sizeof(master_env)); /* process 0 */ - /* Execute command.com /P from the drive we just booted from */ + /* Execute command.com from the drive we just booted from */ memset(Cmd.ctBuffer, 0, sizeof(Cmd.ctBuffer)); memcpy(Cmd.ctBuffer, Config.cfgInitTail, sizeof(Config.cfgInitTail)); @@ -356,7 +353,8 @@ STATIC void kernel() /* if stepping CONFIG.SYS (F5/F8), tell COMMAND.COM about it */ - if (Cmd.ctCount < sizeof(Cmd.ctBuffer) - 3) + /* 3 for string + 2 for "\r\n" */ + if (Cmd.ctCount < sizeof(Cmd.ctBuffer) - 5) { char *insertString = NULL; @@ -376,55 +374,16 @@ STATIC void kernel() { if (*p == ' ' || *p == '\t' || *p == '\r') { - for (q = &Cmd.ctBuffer[Cmd.ctCount - 1]; q >= p; q--) + for (q = &Cmd.ctBuffer[Cmd.ctCount + 1]; q >= p; q--) q[3] = q[0]; - memcpy(p, insertString, 3); - - Cmd.ctCount += 3; break; } } + strcpy(Config.cfgInitTail, Cmd.ctBuffer); /* save buffer */ } } - - exb.exec.cmd_line = (CommandTail FAR *) & Cmd; - exb.exec.fcb_1 = exb.exec.fcb_2 = (fcb FAR *) 0xfffffffful; - -#ifdef DEBUG - printf("Process 0 starting: %s\n\n", Config.cfgInit); -#endif - - while ((rc = - init_DosExec(Config.cfgP_0_startmode, &exb, - Config.cfgInit)) != SUCCESS) - { - BYTE *pLine; - printf("\nBad or missing Command Interpreter: %d - %s\n", rc, - Cmd.ctBuffer); - printf - ("\nPlease enter the correct location (for example C:\\COMMAND.COM):\n"); - rc = read(STDIN, Cmd.ctBuffer, sizeof(Cmd.ctBuffer) - 1); - Cmd.ctBuffer[rc] = '\0'; - - /* Get the string argument that represents the new init pgm */ - pLine = GetStringArg(Cmd.ctBuffer, Config.cfgInit); - - /* Now take whatever tail is left and add it on as a single */ - /* string. */ - strcpy(Cmd.ctBuffer, pLine); - - /* and add a DOS new line just to be safe */ - strcat(Cmd.ctBuffer, "\r\n"); - - Cmd.ctCount = rc - (pLine - Cmd.ctBuffer); - -#ifdef DEBUG - printf("Process 0 starting: %s\n\n", Config.cfgInit); -#endif - } - printf("\nSystem shutdown complete\nReboot now.\n"); - for (;;) ; + init_call_p_0(&Config); /* go execute process 0 (the shell) */ } /* check for a block device and update device control block */ diff --git a/kernel/procsupt.asm b/kernel/procsupt.asm index 10392384..432972c4 100644 --- a/kernel/procsupt.asm +++ b/kernel/procsupt.asm @@ -275,3 +275,22 @@ _spawn_int23: ; cli ; ret ;_disable endp + + extern _p_0_tos,_P_0 + +; prepare to call process 0 (the shell) from P_0() in C + + global reloc_call_p_0 +reloc_call_p_0: + pop ax ; return address (32-bit, unused) + pop ax + pop ax ; fetch parameter 0 (32-bit) from the old stack + pop dx + mov ds,[cs:_DGROUP_] + cli + mov ss,[cs:_DGROUP_] + mov sp,_p_0_tos ; load the dedicated process 0 stack + sti + push dx ; pass parameter 0 onto the new stack + push ax + call _P_0 ; no return, allow parameter fetch from C diff --git a/kernel/proto.h b/kernel/proto.h index 4f2acb82..a7d59e07 100644 --- a/kernel/proto.h +++ b/kernel/proto.h @@ -220,6 +220,10 @@ UBYTE FcbClose(xfcb FAR * lpXfcb); void FcbCloseAll(void); UBYTE FcbFindFirstNext(xfcb FAR * lpXfcb, BOOL First); +/* intr.asm */ +COUNT ASMCFUNC res_DosExec(COUNT mode, exec_blk * ep, BYTE * lp); +UCOUNT ASMCFUNC res_read(int fd, void *buf, UCOUNT count); + /* ioctl.c */ COUNT DosDevIOctl(lregs * r); diff --git a/kernel/task.c b/kernel/task.c index cbaa5f15..11d19a62 100644 --- a/kernel/task.c +++ b/kernel/task.c @@ -48,6 +48,13 @@ static BYTE *RcsId = #define ExeHeader (*(exe_header *)(SecPathName + 0)) #define TempExeBlock (*(exec_blk *)(SecPathName + sizeof(exe_header))) +#define Shell (SecPathName + sizeof(exe_header) + sizeof(exec_blk)) + +#ifdef __TURBOC__ /* this is a Borlandism and doesn't work elsewhere */ + #if sizeof(SecPathName) < sizeof(exe_header) + sizeof(exec_blk) + NAMEMAX + #error No room in SecPathName to be recycled! + #endif +#endif #define CHUNK 32256 #define MAXENV 32768u @@ -792,3 +799,46 @@ COUNT DosExec(COUNT mode, exec_blk FAR * ep, BYTE FAR * lp) return rc; } +#include "config.h" /* config structure definition */ + +/* start process 0 (the shell) */ +VOID ASMCFUNC P_0(struct config FAR *Config) +{ + BYTE *tailp, *endp; + exec_blk exb; + UBYTE mode = Config->cfgP_0_startmode; + + /* build exec block and save all parameters here as init part will vanish! */ + exb.exec.fcb_1 = exb.exec.fcb_2 = (fcb FAR *)-1L; + exb.exec.env_seg = DOS_PSP + 8; + fstrcpy(Shell, Config->cfgInit); + fstrcpy(Shell + strlen(Shell), Config->cfgInitTail); /* join name and tail */ + endp = Shell + strlen(Shell); + + for ( ; ; ) /* endless shell load loop - reboot or shut down to exit it! */ + { + BYTE *p; + /* if there are no parameters, point to end without "\r\n" */ + if((tailp = strchr(Shell,'\t')) == NULL && + (tailp = strchr(Shell, ' ')) == NULL) + tailp = endp - 2; + /* shift tail to right by 2 to make room for '\0', ctCount */ + for (p = endp - 1; p >= tailp; p--) + *(p + 2) = *p; + /* terminate name and tail */ + *tailp = *(endp + 2) = '\0'; + /* ctCount: just past '\0' do not count the "\r\n" */ + exb.exec.cmd_line = (CommandTail *)(tailp + 1); + exb.exec.cmd_line->ctCount = endp - tailp - 2; +#ifdef DEBUG + printf("Process 0 starting: %s%s\n\n", Shell, tailp + 2); +#endif + res_DosExec(mode, &exb, Shell); + put_string("Bad or missing Command Interpreter: "); /* failure _or_ exit */ + put_string(Shell); + put_string(tailp + 2); + put_string(" Enter the full shell command line: "); + endp = Shell + res_read(STDIN, Shell, NAMEMAX); + *endp = '\0'; /* terminate string for strchr */ + } +} From 0d6d0b8523fdd2f9d3319f051922de43d1be48db Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sun, 7 Mar 2004 12:59:38 +0000 Subject: [PATCH 378/671] (with Lucho) -- remove the dosnames path 67 length check. Review the places where it really matters (chdir and mkdir). git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@796 6ac86273-5f31-0410-b378-82cca8765d1b --- filelist | 1 - hdr/dosnames.h | 46 ---------------------------------------------- kernel/dosfns.c | 2 +- kernel/dosnames.c | 3 --- kernel/fatdir.c | 2 +- kernel/fatfs.c | 10 +++++----- kernel/globals.h | 3 +-- kernel/init-mod.h | 1 - 8 files changed, 8 insertions(+), 60 deletions(-) delete mode 100644 hdr/dosnames.h diff --git a/filelist b/filelist index 7eef5168..17405f0a 100644 --- a/filelist +++ b/filelist @@ -42,7 +42,6 @@ */*/hdr/dcb.h */*/hdr/device.h */*/hdr/dirmatch.h -*/*/hdr/dosnames.h */*/hdr/error.h */*/hdr/exe.h */*/hdr/fat.h diff --git a/hdr/dosnames.h b/hdr/dosnames.h deleted file mode 100644 index aa975c1e..00000000 --- a/hdr/dosnames.h +++ /dev/null @@ -1,46 +0,0 @@ -/****************************************************************/ -/* */ -/* dosnames.h */ -/* */ -/* FAT File System Name Parse Structure */ -/* */ -/* March 5, 1995 */ -/* */ -/* Copyright (c) 1995 */ -/* Pasquale J. Villani */ -/* All Rights Reserved */ -/* */ -/* This file is part of DOS-C. */ -/* */ -/* DOS-C is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU General Public License */ -/* as published by the Free Software Foundation; either version */ -/* 2, or (at your option) any later version. */ -/* */ -/* DOS-C is distributed in the hope that it will be useful, but */ -/* WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See */ -/* the GNU General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU General Public */ -/* License along with DOS-C; see the file COPYING. If not, */ -/* write to the Free Software Foundation, 675 Mass Ave, */ -/* Cambridge, MA 02139, USA. */ -/****************************************************************/ - -#ifdef MAIN -#ifdef VERSION_STRINGS -static BYTE *dosnames_hRcsId = - "$Id$"; -#endif -#endif - -#define PARSE_MAX 64 - -struct dosnames { - UBYTE dn_drive; /* the drive that was parsed */ - UBYTE dn_network[PARSE_MAX]; /* specified network */ - UBYTE dn_path[PARSE_MAX]; /* the path */ - UBYTE dn_name[FNAME_SIZE + FEXT_SIZE + 1]; /* the file name */ -}; - diff --git a/kernel/dosfns.c b/kernel/dosfns.c index ba9e7877..a7730c97 100644 --- a/kernel/dosfns.c +++ b/kernel/dosfns.c @@ -987,7 +987,7 @@ COUNT DosChangeDir(BYTE FAR * s) } if ((FP_OFF(current_ldt) != 0xFFFF) && - (strlen(PriPathName) > sizeof(current_ldt->cdsCurrentPath) - 1)) + (strlen(PriPathName) >= sizeof(current_ldt->cdsCurrentPath))) return DE_PATHNOTFND; #if defined(CHDIR_DEBUG) diff --git a/kernel/dosnames.c b/kernel/dosnames.c index 18e27358..807cd107 100644 --- a/kernel/dosnames.c +++ b/kernel/dosnames.c @@ -96,9 +96,6 @@ int ParseDosName(const char *filename, char *fcbname, BOOL bAllowWildcards) ++filename; } nDirCnt = lpszLclFile - lpszLclDir; - /* Fix lengths to maximums allowed by MS-DOS. */ - if (nDirCnt > PARSE_MAX - 1) - nDirCnt = PARSE_MAX - 1; /* Parse out the file name portion. */ filename = lpszLclFile; diff --git a/kernel/fatdir.c b/kernel/fatdir.c index fd5881e6..5f2b5c5d 100644 --- a/kernel/fatdir.c +++ b/kernel/fatdir.c @@ -409,7 +409,7 @@ COUNT dos_findfirst(UCOUNT attr, BYTE * name) /* dirmatch structure and then for every find, we will open the */ /* current directory, do a seek and read, then close the fnode. */ - /* Parse out the drive, file name and file extension. */ + /* Parse out the file name */ i = ParseDosName(name, SearchDir.dir_name, TRUE); if (i < SUCCESS) return i; diff --git a/kernel/fatfs.c b/kernel/fatfs.c index b89d181e..41fa836c 100644 --- a/kernel/fatfs.c +++ b/kernel/fatfs.c @@ -1064,23 +1064,23 @@ COUNT dos_mkdir(BYTE * dir) CLUSTER free_fat, parent; COUNT ret; char fcbname[FNAME_SIZE + FEXT_SIZE]; - - /* first split the passed dir into comopnents (i.e. - */ + + /* first split the passed dir into components (i.e. - */ /* path to new directory and name of new directory */ if ((fnp = split_path(dir, fcbname)) == NULL) { return DE_PATHNOTFND; } - /* check that the resulting combined path does not exceed - the 64 PARSE_MAX limit. this leeds to problems: + /* check that the resulting combined path does not exceed + the 67 MAX_CDSPATH limit. this leads to problems: A) you can't CD to this directory later B) you can't create files in this subdirectory C) the created dir will not be found later, so you can create an unlimited amount of same dirs. this space is lost forever */ - if (strlen(dir) > PARSE_MAX + 2) /* dir is already output of "truename" */ + if (strlen(dir) >= MAX_CDSPATH) /* dir is already output of "truename" */ { dir_close(fnp); return DE_PATHNOTFND; diff --git a/kernel/globals.h b/kernel/globals.h index a981c09d..669fce36 100644 --- a/kernel/globals.h +++ b/kernel/globals.h @@ -99,8 +99,7 @@ FAR * ASM DPBp; /* First drive Parameter Block */ /* Constants and macros */ /* */ /* Defaults and limits - System wide */ -#define PARSE_MAX MAX_CDSPATH /* maximum # of bytes in path */ -#define NAMEMAX PARSE_MAX /* Maximum path for CDS */ +#define NAMEMAX MAX_CDSPATH /* Maximum path for CDS */ /* internal error from failure or aborted operation */ #define ERROR -1 diff --git a/kernel/init-mod.h b/kernel/init-mod.h index 3a63973f..8265503b 100644 --- a/kernel/init-mod.h +++ b/kernel/init-mod.h @@ -70,7 +70,6 @@ void MoveKernel(unsigned NewKernelSegment); #define GLOBAL extern #define NAMEMAX MAX_CDSPATH /* Maximum path for CDS */ -#define PARSE_MAX MAX_CDSPATH /* maximum # of bytes in path */ #define NFILES 16 /* number of files in table */ #define NFCBS 16 /* number of fcbs */ #define NSTACKS 8 /* number of stacks */ From 0f56cb2b3b6c495df9adf5e758476e6bb5301335 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sun, 7 Mar 2004 13:07:05 +0000 Subject: [PATCH 379/671] From Lucho: move the lock/unlock simulation of success before the device GENIOCTL check so that it applies to any device. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@797 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/ioctl.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/kernel/ioctl.c b/kernel/ioctl.c index 07bc9da3..022062a1 100644 --- a/kernel/ioctl.c +++ b/kernel/ioctl.c @@ -268,6 +268,11 @@ COUNT DosDevIOctl(lregs * r) { return DE_INVLDDRV; } + if (r->AL == 0x0D && (r->CX & ~(0x486B-0x084A)) == 0x084A) + { /* 084A/484A, 084B/484B, 086A/486A, 086B/486B */ + r->AX = 0; /* (lock/unlock logical/physical volume) */ + break; /* simulate success for MS-DOS 7+ SCANDISK etc. --LG */ + } if (((r->AL == 0x04) && !(dpbp->dpb_device->dh_attr & ATTR_IOCTL)) || ((r->AL == 0x05) && !(dpbp->dpb_device->dh_attr & ATTR_IOCTL)) || ((r->AL == 0x11) @@ -277,11 +282,6 @@ COUNT DosDevIOctl(lregs * r) { return DE_INVLDFUNC; } - if (r->AL == 0x0D && (r->CX & ~(0x486B-0x084A)) == 0x084A) - { /* 084A/484A, 084B/484B, 086A/486A, 086B/486B */ - r->AX = 0; /* (lock/unlock logical/physical volume) */ - break; /* simulate success for MS-DOS 7+ SCANDISK etc. --LG */ - } CharReqHdr.r_command = nMode; execrh((request FAR *) & CharReqHdr, dpbp->dpb_device); From 77331799bde351dcf6a03555e839c458462752ef Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Wed, 17 Mar 2004 20:32:55 +0000 Subject: [PATCH 380/671] Commit each close, even if the ref count is > 0. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@798 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/dosfns.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/kernel/dosfns.c b/kernel/dosfns.c index a7730c97..b9b11af4 100644 --- a/kernel/dosfns.c +++ b/kernel/dosfns.c @@ -749,11 +749,8 @@ COUNT DosCloseSft(int sft_idx, BOOL commitonly) } return SUCCESS; } - if (commitonly) + if (commitonly || sftp->sft_count > 0) return dos_commit(sftp->sft_status); - - if (sftp->sft_count > 0) - return SUCCESS; /* /// Added for SHARE *** CURLY BRACES ADDED ALSO!!! ***. - Ron Cemer */ if (IsShareInstalled()) From 69faceffe5241058dbd0324bcfba93e2f0d149c9 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Wed, 17 Mar 2004 21:28:54 +0000 Subject: [PATCH 381/671] int21/ah=26: new_psp now copies the old psp and just sets a few fields int21/ah=55: child_psp does the rest init code does the init (fixed values are always copied now) git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@799 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/init-mod.h | 2 +- kernel/inthndlr.c | 8 ++---- kernel/intr.asm | 12 --------- kernel/main.c | 64 +++++++++++++++++++++++++++++++++++++++++++++-- kernel/proto.h | 3 ++- kernel/task.c | 56 ++++++++++++++++++----------------------- 6 files changed, 91 insertions(+), 54 deletions(-) diff --git a/kernel/init-mod.h b/kernel/init-mod.h index 8265503b..2b781ddb 100644 --- a/kernel/init-mod.h +++ b/kernel/init-mod.h @@ -67,6 +67,7 @@ extern BYTE DosLoadedInHMA; void MoveKernel(unsigned NewKernelSegment); #define setvec(n, isr) (void)(*(intvec FAR *)MK_FP(0,4 * (n)) = (isr)) +#define getvec(n) (*(intvec FAR *)MK_FP(0,4 * (n))) #define GLOBAL extern #define NAMEMAX MAX_CDSPATH /* Maximum path for CDS */ @@ -120,7 +121,6 @@ int ASMCFUNC open(const char *pathname, int flags); int ASMCFUNC close(int fd); int ASMCFUNC dup2(int oldfd, int newfd); int ASMCFUNC allocmem(UWORD size, seg * segp); -VOID ASMCFUNC init_PSPInit(seg psp_seg); VOID ASMCFUNC init_PSPSet(seg psp_seg); COUNT ASMCFUNC init_DosExec(COUNT mode, exec_blk * ep, BYTE * lp); int ASMCFUNC init_setdrive(int drive); diff --git a/kernel/inthndlr.c b/kernel/inthndlr.c index c69cd5fb..b27c755f 100644 --- a/kernel/inthndlr.c +++ b/kernel/inthndlr.c @@ -649,11 +649,7 @@ VOID ASMCFUNC int21_service(iregs FAR * r) /* Dos Create New Psp */ case 0x26: - { - psp FAR *p = MK_FP(cu_psp, 0); - - new_psp(lr.DX, p->ps_size); - } + new_psp(lr.DX, r->CS); break; /* Read random record(s) using FCB */ @@ -1175,7 +1171,7 @@ VOID ASMCFUNC int21_service(iregs FAR * r) /* ************UNDOCUMENTED************************************* */ /* Dos Create New Psp & set p_size */ case 0x55: - new_psp(lr.DX, lr.SI); + child_psp(lr.DX, cu_psp, lr.SI); cu_psp = lr.DX; break; diff --git a/kernel/intr.asm b/kernel/intr.asm index ad08028d..cdac2be6 100644 --- a/kernel/intr.asm +++ b/kernel/intr.asm @@ -226,18 +226,6 @@ _dup2: int 21h jmp short common_exit -;; VOID init_PSPInit(seg psp_seg) - global _init_PSPInit -_init_PSPInit: - push si - mov ah, 55h - mov bx, sp - mov dx, [bx+4] - xor si, si - int 21h - pop si - ret - ;; VOID init_PSPSet(seg psp_seg) global _init_PSPSet _init_PSPSet: diff --git a/kernel/main.c b/kernel/main.c index 176500ef..f2ee7380 100644 --- a/kernel/main.c +++ b/kernel/main.c @@ -153,6 +153,67 @@ void InitializeAllBPBs(VOID) } } +STATIC void PSPInit(void) +{ + psp far *p = MK_FP(DOS_PSP, 0); + + /* Clear out new psp first */ + fmemset(p, 0, sizeof(psp)); + + /* initialize all entries and exits */ + /* CP/M-like exit point */ + p->ps_exit = 0x20cd; + + /* CP/M-like entry point - call far to special entry */ + p->ps_farcall = 0x9a; + p->ps_reentry = MK_FP(0, 0x30 * 4); + /* unix style call - 0xcd 0x21 0xcb (int 21, retf) */ + p->ps_unix[0] = 0xcd; + p->ps_unix[1] = 0x21; + p->ps_unix[2] = 0xcb; + + /* Now for parent-child relationships */ + /* parent psp segment */ + p->ps_parent = FP_SEG(p); + /* previous psp pointer */ + p->ps_prevpsp = MK_FP(0xffff,0xffff); + + /* Environment and memory useage parameters */ + /* memory size in paragraphs */ + /* p->ps_size = 0; clear from above */ + /* environment paragraph */ + p->ps_environ = DOS_PSP + 8; + /* terminate address */ + p->ps_isv22 = getvec(0x22); + /* break address */ + p->ps_isv23 = getvec(0x23); + /* critical error address */ + p->ps_isv24 = getvec(0x24); + + /* user stack pointer - int 21 */ + /* p->ps_stack = NULL; clear from above */ + + /* File System parameters */ + /* maximum open files */ + p->ps_maxfiles = 20; + fmemset(p->ps_files, 0xff, 20); + + /* open file table pointer */ + p->ps_filetab = p->ps_files; + + /* first command line argument */ + /* p->ps_fcb1.fcb_drive = 0; already set */ + fmemset(p->ps_fcb1.fcb_fname, ' ', FNAME_SIZE + FEXT_SIZE); + /* second command line argument */ + /* p->ps_fcb2.fcb_drive = 0; already set */ + fmemset(p->ps_fcb2.fcb_fname, ' ', FNAME_SIZE + FEXT_SIZE); + + /* local command line */ + /* p->ps_cmd.ctCount = 0; command tail, already set */ + p->ps_cmd.ctBuffer[0] = 0xd; /* command tail */ +} + + STATIC void init_kernel(void) { COUNT i; @@ -196,8 +257,7 @@ STATIC void init_kernel(void) init_PSPSet(DOS_PSP); set_DTA(MK_FP(DOS_PSP, 0x80)); - init_PSPInit(DOS_PSP); - ((psp far *)MK_FP(DOS_PSP, 0))->ps_environ = DOS_PSP + 8; + PSPInit(); Init_clk_driver(); diff --git a/kernel/proto.h b/kernel/proto.h index a7d59e07..25dbd0da 100644 --- a/kernel/proto.h +++ b/kernel/proto.h @@ -339,7 +339,8 @@ const UWORD *is_leap_year_monthdays(UWORD year); UWORD DaysFromYearMonthDay(UWORD Year, UWORD Month, UWORD DayOfMonth); /* task.c */ -VOID new_psp(seg para, int psize); +VOID new_psp(seg para, seg cur_psp); +VOID child_psp(seg para, seg cur_psp, int psize); VOID return_user(void); COUNT DosExec(COUNT mode, exec_blk FAR * ep, BYTE FAR * lp); ULONG SftGetFsize(int sft_idx); diff --git a/kernel/task.c b/kernel/task.c index 11d19a62..32b69429 100644 --- a/kernel/task.c +++ b/kernel/task.c @@ -165,26 +165,29 @@ STATIC COUNT ChildEnv(exec_blk * exp, UWORD * pChildEnvSeg, char far * pathname) } /* The following code is 8086 dependant */ -void new_psp(seg para, int psize) +void new_psp(seg para, seg cur_psp) { psp FAR *p = MK_FP(para, 0); - psp FAR *q = MK_FP(cu_psp, 0); - int i; - - /* Clear out new psp first */ - fmemset(p, 0, sizeof(psp)); - /* initialize all entries and exits */ - /* CP/M-like exit point */ - p->ps_exit = 0x20cd; + fmemcpy(p, MK_FP(cur_psp, 0), sizeof(psp)); + + /* terminate address */ + p->ps_isv22 = getvec(0x22); + /* break address */ + p->ps_isv23 = getvec(0x23); + /* critical error address */ + p->ps_isv24 = getvec(0x24); + /* parent psp segment set to 0 (see RBIL int21/ah=26) */ + p->ps_parent = 0; +} + +void child_psp(seg para, seg cur_psp, int psize) +{ + psp FAR *p = MK_FP(para, 0); + psp FAR *q = MK_FP(cur_psp, 0); + int i; - /* CP/M-like entry point - call far to special entry */ - p->ps_farcall = 0x9a; - p->ps_reentry = MK_FP(0, 0x30 * 4); - /* unix style call - 0xcd 0x21 0xcb (int 21, retf) */ - p->ps_unix[0] = 0xcd; - p->ps_unix[1] = 0x21; - p->ps_unix[2] = 0xcb; + new_psp(para, cur_psp); /* Now for parent-child relationships */ /* parent psp segment */ @@ -195,17 +198,6 @@ void new_psp(seg para, int psize) /* Environment and memory useage parameters */ /* memory size in paragraphs */ p->ps_size = psize; - /* environment paragraph */ - /* p->ps_environ = 0; cleared above */ - /* terminate address */ - p->ps_isv22 = getvec(0x22); - /* break address */ - p->ps_isv23 = getvec(0x23); - /* critical error address */ - p->ps_isv24 = getvec(0x24); - - /* user stack pointer - int 21 */ - p->ps_stack = q->ps_stack; /* File System parameters */ /* maximum open files */ @@ -221,14 +213,14 @@ void new_psp(seg para, int psize) p->ps_files[i] = q->ps_filetab[i]; /* first command line argument */ - /* p->ps_fcb1.fcb_drive = 0; already set */ + p->ps_fcb1.fcb_drive = 0; fmemset(p->ps_fcb1.fcb_fname, ' ', FNAME_SIZE + FEXT_SIZE); /* second command line argument */ - /* p->ps_fcb2.fcb_drive = 0; already set */ + p->ps_fcb2.fcb_drive = 0; fmemset(p->ps_fcb2.fcb_fname, ' ', FNAME_SIZE + FEXT_SIZE); /* local command line */ - /* p->ps_cmd.ctCount = 0; command tail, already set */ + p->ps_cmd.ctCount = 0; p->ps_cmd.ctBuffer[0] = 0xd; /* command tail */ } @@ -490,7 +482,7 @@ COUNT DosComLoader(BYTE FAR * namep, exec_blk * exp, COUNT mode, COUNT fd) /* point to the PSP so we can build it */ setvec(0x22, MK_FP(user_r->CS, user_r->IP)); - new_psp(mem, mem + asize); + child_psp(mem, cu_psp, mem + asize); fcbcode = patchPSP(mem - 1, env, exp, namep); /* set asize to end of segment */ @@ -742,7 +734,7 @@ COUNT DosExeLoader(BYTE FAR * namep, exec_blk * exp, COUNT mode, COUNT fd) /* point to the PSP so we can build it */ setvec(0x22, MK_FP(user_r->CS, user_r->IP)); - new_psp(mem, mem + asize); + child_psp(mem, cu_psp, mem + asize); fcbcode = patchPSP(mem - 1, env, exp, namep); exp->exec.stack = From 329c7c6e6a9dbf58ed5d496787b53e4c798458aa Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Wed, 17 Mar 2004 22:04:40 +0000 Subject: [PATCH 382/671] Remove wrong automatic "*.*" code from Lixing Yuan -- return DE_PATHNOTFND or D_NFILES instead (mostly from Lucho) git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@800 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/dosnames.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/kernel/dosnames.c b/kernel/dosnames.c index 807cd107..0d53d6a0 100644 --- a/kernel/dosnames.c +++ b/kernel/dosnames.c @@ -108,18 +108,14 @@ int ParseDosName(const char *filename, char *fcbname, BOOL bAllowWildcards) if (nFileCnt == 0) { -/* Lixing Yuan Patch */ - if (bAllowWildcards) /* for find first */ - { - if (*filename != '\0') - return DE_FILENOTFND; - memset(fcbname, '?', FNAME_SIZE + FEXT_SIZE); - return nDirCnt; - } - else - return DE_FILENOTFND; + int err = DE_PATHNOTFND; + if (bAllowWildcards && *filename == '\0' && + (nDirCnt == 3 || filename[-1] != '\\')) + /* D:\ or D:\DOS but not D:\DOS\ */ + err = DE_NFILES; + return err; } - + /* Now we have pointers set to the directory portion and the */ /* file portion. Now determine the existance of an extension. */ lpszLclExt = filename; From aeec36ea4befe7d5bf01936b8c4d99bca960e510 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Wed, 17 Mar 2004 22:06:57 +0000 Subject: [PATCH 383/671] talloc fix from Lucho git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@801 6ac86273-5f31-0410-b378-82cca8765d1b --- sys/talloc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sys/talloc.c b/sys/talloc.c index 2081aa9c..83bcc6d6 100644 --- a/sys/talloc.c +++ b/sys/talloc.c @@ -83,11 +83,11 @@ void *malloc(size_t length) } dbprintf(("follow [%x] = %x\n",akt, akt->length)); next = (block *)(&akt->data[akt->length & ~BUSY]); - if (next == ltop || isbusy(akt)) + if (isbusy(akt)) { akt = next; /* next block */ } - else if (isbusy(next)) + else if (next == ltop || isbusy(next)) { size_t size = akt->length; if (size >= length) /* try to split */ From 28be8284a88c9c169c62db7dadf033727df01b5f Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Fri, 19 Mar 2004 22:33:48 +0000 Subject: [PATCH 384/671] Eliminate intr() from resident code. Saves ~200 bytes of HMA resident code. Also made the nls.c functions SS!=DS safe. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@802 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/dosfns.c | 138 +++++------------------------------------- kernel/int2f.asm | 153 ++++++++++++++++++++++++++++++++++++++++++++++- kernel/intr.asm | 10 ---- kernel/nls.c | 71 +++++++--------------- 4 files changed, 189 insertions(+), 183 deletions(-) diff --git a/kernel/dosfns.c b/kernel/dosfns.c index b9b11af4..564e0035 100644 --- a/kernel/dosfns.c +++ b/kernel/dosfns.c @@ -45,14 +45,16 @@ BYTE share_installed = 0; error. If < 0 is returned, it is the negated error return code, so DOS simply negates this value and returns it in AX. */ -STATIC int share_open_check(char * filename, /* pointer to fully qualified filename */ +extern int ASMPASCAL + share_open_check(char * filename, /* pointer to fully qualified filename */ unsigned short pspseg, /* psp segment address of owner process */ int openmode, /* 0=read-only, 1=write-only, 2=read-write */ int sharemode); /* SHARE_COMPAT, etc... */ /* DOS calls this to record the fact that it has successfully closed a file, or the fact that the open for this file failed. */ -STATIC void share_close_file(int fileno); /* file_table entry number */ +extern void ASMPASCAL + share_close_file(int fileno); /* file_table entry number */ /* DOS calls this to determine whether it can access (read or write) a specific section of a file. We call it internally @@ -65,7 +67,8 @@ STATIC void share_close_file(int fileno); /* file_table entry number */ generates a critical error (if allowcriter is non-zero). If non-zero is returned, it is the negated return value for the DOS call. */ -STATIC int share_access_check(unsigned short pspseg, /* psp segment address of owner process */ +extern int ASMPASCAL + share_access_check(unsigned short pspseg, /* psp segment address of owner process */ int fileno, /* file_table entry number */ unsigned long ofs, /* offset into file */ unsigned long len, /* length (in bytes) of region to access */ @@ -76,18 +79,20 @@ STATIC int share_access_check(unsigned short pspseg, /* psp segment address o returns non-zero. If the return value is non-zero, it is the negated error return code for the DOS 0x5c call. */ -STATIC int share_lock_unlock(unsigned short pspseg, /* psp segment address of owner process */ +extern int ASMPASCAL + share_lock_unlock(unsigned short pspseg, /* psp segment address of owner process */ int fileno, /* file_table entry number */ unsigned long ofs, /* offset into file */ unsigned long len, /* length (in bytes) of region to lock or unlock */ - int unlock); /* non-zero to unlock; zero to lock */ + int unlock); /* one to unlock; zero to lock */ /* /// End of additions for SHARE. - Ron Cemer */ -STATIC int remote_lock_unlock(sft FAR *sftp, /* SFT for file */ +extern int ASMCFUNC + remote_lock_unlock(sft FAR *sftp, /* SFT for file */ unsigned long ofs, /* offset into file */ unsigned long len, /* length (in bytes) of region to lock or unlock */ - int unlock); /* non-zero to unlock; zero to lock */ + int unlock); /* one to unlock; zero to lock */ /* get current directory structure for drive return NULL if the CDS is not valid or the @@ -1437,126 +1442,13 @@ struct dhdr FAR *IsDevice(const char FAR * fname) BOOL IsShareInstalled(void) { - if (!share_installed) - { - iregs regs; - - regs.a.x = 0x1000; - intr(0x2f, ®s); - share_installed = ((regs.a.x & 0xff) == 0xff); - } + extern unsigned char ASMPASCAL share_check(void); + if (!share_installed && share_check() == 0xff) + share_installed = TRUE; return share_installed; } - /* DOS calls this to see if it's okay to open the file. - Returns a file_table entry number to use (>= 0) if okay - to open. Otherwise returns < 0 and may generate a critical - error. If < 0 is returned, it is the negated error return - code, so DOS simply negates this value and returns it in - AX. */ -STATIC int share_open_check(char * filename, /* pointer to fully qualified filename */ - unsigned short pspseg, /* psp segment address of owner process */ - int openmode, /* 0=read-only, 1=write-only, 2=read-write */ - int sharemode) -{ /* SHARE_COMPAT, etc... */ - iregs regs; - - regs.a.x = 0x10a0; - regs.ds = FP_SEG(filename); - regs.si = FP_OFF(filename); - regs.b.x = pspseg; - regs.c.x = openmode; - regs.d.x = sharemode; - intr(0x2f, ®s); - return (int)regs.a.x; -} - - /* DOS calls this to record the fact that it has successfully - closed a file, or the fact that the open for this file failed. */ -STATIC void share_close_file(int fileno) -{ /* file_table entry number */ - iregs regs; - - regs.a.x = 0x10a1; - regs.b.x = fileno; - intr(0x2f, ®s); -} - - /* DOS calls this to determine whether it can access (read or - write) a specific section of a file. We call it internally - from lock_unlock (only when locking) to see if any portion - of the requested region is already locked. If pspseg is zero, - then it matches any pspseg in the lock table. Otherwise, only - locks which DO NOT belong to pspseg will be considered. - Returns zero if okay to access or lock (no portion of the - region is already locked). Otherwise returns non-zero and - generates a critical error (if allowcriter is non-zero). - If non-zero is returned, it is the negated return value for - the DOS call. */ -STATIC int share_access_check(unsigned short pspseg, /* psp segment address of owner process */ - int fileno, /* file_table entry number */ - unsigned long ofs, /* offset into file */ - unsigned long len, /* length (in bytes) of region to access */ - int allowcriter) -{ /* allow a critical error to be generated */ - iregs regs; - - regs.a.x = 0x10a2 | (allowcriter ? 0x01 : 0x00); - regs.b.x = pspseg; - regs.c.x = fileno; - regs.si = (unsigned short)((ofs >> 16) & 0xffffL); - regs.di = (unsigned short)(ofs & 0xffffL); - regs.es = (unsigned short)((len >> 16) & 0xffffL); - regs.d.x = (unsigned short)(len & 0xffffL); - intr(0x2f, ®s); - return (int)regs.a.x; -} - - /* DOS calls this to lock or unlock a specific section of a file. - Returns zero if successfully locked or unlocked. Otherwise - returns non-zero. - If the return value is non-zero, it is the negated error - return code for the DOS 0x5c call. */ -STATIC int share_lock_unlock(unsigned short pspseg, /* psp segment address of owner process */ - int fileno, /* file_table entry number */ - unsigned long ofs, /* offset into file */ - unsigned long len, /* length (in bytes) of region to lock or unlock */ - int unlock) -{ /* non-zero to unlock; zero to lock */ - iregs regs; - - regs.a.x = 0x10a4 | (unlock ? 0x01 : 0x00); - regs.b.x = pspseg; - regs.c.x = fileno; - regs.si = (unsigned short)((ofs >> 16) & 0xffffL); - regs.di = (unsigned short)(ofs & 0xffffL); - regs.es = (unsigned short)((len >> 16) & 0xffffL); - regs.d.x = (unsigned short)(len & 0xffffL); - intr(0x2f, ®s); - return (int)regs.a.x; -} - /* /// End of additions for SHARE. - Ron Cemer */ -STATIC int remote_lock_unlock(sft FAR *sftp, /* SFT for file */ - unsigned long ofs, /* offset into file */ - unsigned long len, /* length (in bytes) of region to lock or unlock */ - int unlock) -{ /* non-zero to unlock; zero to lock */ - iregs regs; - unsigned long param_block[2]; - param_block[0] = ofs; - param_block[1] = len; - - regs.a.x = 0x110a; - regs.b.b.l = (unlock ? 0x01 : 0x00); - regs.c.x = 1; - regs.ds = FP_SEG(param_block); - regs.d.x = FP_OFF(param_block); - regs.es = FP_SEG(sftp); - regs.di = FP_OFF(sftp); - intr(0x2f, ®s); - return ((regs.flags & 1) ? -(int)regs.a.b.l : 0); -} COUNT DosTruename(const char FAR *src, char FAR *dest) { diff --git a/kernel/int2f.asm b/kernel/int2f.asm index d73f1a0e..d58fe6e3 100644 --- a/kernel/int2f.asm +++ b/kernel/int2f.asm @@ -165,7 +165,105 @@ IntDosCal: pop ax iret - + + global SHARE_CHECK +SHARE_CHECK: + mov ax, 0x1000 + int 0x2f + ret + +; DOS calls this to see if it's okay to open the file. +; Returns a file_table entry number to use (>= 0) if okay +; to open. Otherwise returns < 0 and may generate a critical +; error. If < 0 is returned, it is the negated error return +; code, so DOS simply negates this value and returns it in +; AX. +; STATIC int share_open_check(char * filename, +; /* pointer to fully qualified filename */ +; unsigned short pspseg, +; /* psp segment address of owner process */ +; int openmode, +; /* 0=read-only, 1=write-only, 2=read-write */ +; int sharemode) /* SHARE_COMPAT, etc... */ + global SHARE_OPEN_CHECK +SHARE_OPEN_CHECK: + mov es, si ; save si + pop ax ; return address + pop dx ; sharemode; + pop cx ; openmode; + pop bx ; pspseg; + pop si ; filename + push ax ; return address + mov ax, 0x10a0 + int 0x2f ; returns ax + mov si, es ; restore si + ret + +; DOS calls this to record the fact that it has successfully +; closed a file, or the fact that the open for this file failed. +; STATIC void share_close_file(int fileno) /* file_table entry number */ + + global SHARE_CLOSE_FILE +SHARE_CLOSE_FILE: + pop ax + pop bx + push ax + mov ax, 0x10a1 + int 0x2f + ret + +; DOS calls this to determine whether it can access (read or +; write) a specific section of a file. We call it internally +; from lock_unlock (only when locking) to see if any portion +; of the requested region is already locked. If pspseg is zero, +; then it matches any pspseg in the lock table. Otherwise, only +; locks which DO NOT belong to pspseg will be considered. +; Returns zero if okay to access or lock (no portion of the +; region is already locked). Otherwise returns non-zero and +; generates a critical error (if allowcriter is non-zero). +; If non-zero is returned, it is the negated return value for +; the DOS call. +;STATIC int share_access_check(unsigned short pspseg, +; /* psp segment address of owner process */ +; int fileno, /* file_table entry number */ +; unsigned long ofs, /* offset into file */ +; unsigned long len, /* length (in bytes) of region to access */ +; int allowcriter) /* allow a critical error to be generated */ + global SHARE_ACCESS_CHECK +SHARE_ACCESS_CHECK: + mov ax, 0x10a2 +share_common: + push bp + mov bp, sp + push si + push di + mov bx, [bp + 16] ; pspseg + mov cx, [bp + 14] ; fileno + mov si, [bp + 12] ; high word of ofs + mov di, [bp + 10] ; low word of ofs + les dx, [bp + 6] ; len + or ax, [bp + 4] ; allowcriter/unlock + int 0x2f + pop di + pop si + pop bp + ret 14 ; returns ax + +; DOS calls this to lock or unlock a specific section of a file. +; Returns zero if successfully locked or unlocked. Otherwise +; returns non-zero. +; If the return value is non-zero, it is the negated error +; return code for the DOS 0x5c call. */ +;STATIC int share_lock_unlock(unsigned short pspseg, /* psp segment address of owner process */ +; int fileno, /* file_table entry number */ +; unsigned long ofs, /* offset into file */ +; unsigned long len, /* length (in bytes) of region to lock or unlock */ +; int unlock) /* one to unlock; zero to lock */ + global SHARE_LOCK_UNLOCK +SHARE_LOCK_UNLOCK: + mov ax,0x10a4 + jmp short share_common + ; Int 2F Multipurpose Remote System Calls ; ; added by James Tabor jimtabor@infohwy.com @@ -430,6 +528,59 @@ _remote_process_end: ; Terminate process pop ds ret +;STATIC int ASMCFUNC remote_lock_unlock(sft FAR *sftp, /* SFT for file */ +; unsigned long ofs, /* offset into file */ +; unsigned long len, /* length (in bytes) of region to lock or unlock */ +; int unlock) +; one to unlock; zero to lock + global _remote_lock_unlock +_remote_lock_unlock: + push bp + mov bp, sp + push di + les di, [bp + 4] ; sftp + lea dx, [bp + 8] ; parameter block on the stack! + mov bl, [bp + 16] ; unlock + mov ax, 0x110a + mov cx, 1 + int 0x2f + mov ah, 0 + jc lock_error + mov al, 0 +lock_error: + neg al + pop di + pop bp + ret + +; extern UWORD ASMCFUNC call_nls(UWORD subfct, struct nlsInfoBlock *nlsinfo, +; UWORD bp, UWORD cp, UWORD cntry, UWORD bufsize, UWORD FAR *buf, UWORD *id); + + global _call_nls +_call_nls: + push bp + mov bp, sp + push si + mov al, [bp + 4] ; subfct + mov ah, 0x14 + mov si, [bp + 6] ; nlsinfo + mov bx, [bp + 10] ; cp + mov dx, [bp + 12] ; cntry + mov cx, [bp + 14] ; bufsize + les di, [bp + 16] ; buf + push bp + mov bp, [bp + 8] ; bp + int 0x2f + pop bp + mov bp, [bp + 20] ; store id (in SS:) unless it's NULL + or bp, bp + jz nostore + mov [bp], bx +nostore: + pop si + pop bp + ret + %if 0 ; int_2f_111e_call(iregs FAR *iregs) ; diff --git a/kernel/intr.asm b/kernel/intr.asm index cdac2be6..c7c305e7 100644 --- a/kernel/intr.asm +++ b/kernel/intr.asm @@ -79,15 +79,6 @@ %endmacro segment HMA_TEXT -; -; void intr(nr, rp) -; REG int nr -; REG struct REGPACK *rp -; -; - global _intr -_intr: - INTR ;; COUNT ASMCFUNC res_DosExec(COUNT mode, exec_blk * ep, BYTE * lp) global _res_DosExec @@ -125,7 +116,6 @@ segment INIT_TEXT ; REG int nr ; REG struct REGPACK *rp ; -; same stuff as above, but in INIT_SEGMENT global _init_call_intr _init_call_intr: INTR diff --git a/kernel/nls.c b/kernel/nls.c index 7aac1274..ee5455ab 100644 --- a/kernel/nls.c +++ b/kernel/nls.c @@ -43,22 +43,10 @@ static BYTE *RcsId = "$Id$"; #endif -/* - * assertDSeqSS() - test if DS == SS - * Otherwise pointers to local variables (that ones on the stack) will - * be referenced via DS, which will cause to use wrong values. - */ #ifdef NLS_DEBUG -#define assertDSeqSS() if(_DS != _SS) assertDSneSS(); -void assertDSneSS(void) -{ - panic("DS unequal to SS"); -} - #define log(a) printf a #define log1(a) printf a #else -#define assertDSeqSS() #define log(a) #ifdef NDEBUG #define log1(a) @@ -103,18 +91,19 @@ struct nlsInfoBlock nlsInfo = { ***** MUX calling functions **************************************** ********************************************************************/ +extern int ASMCFUNC call_nls(UWORD, struct nlsInfoBlock *, UWORD, UWORD, UWORD, + UWORD, void FAR *, UWORD *); /*== DS:SI _always_ points to global NLS info structure <-> no * subfct can use these registers for anything different. ==ska*/ -STATIC COUNT muxGo(int subfct, iregs * rp) +STATIC COUNT muxGo(int subfct, UWORD bp, UWORD cp, UWORD cntry, UWORD bufsize, + void FAR *buf, UWORD *id) { - log(("NLS: muxGo(): subfct=%x, cntry=%u, cp=%u, ES:DI=%04x:%04x\n", - subfct, rp->DX, rp->BX, rp->ES, rp->DI)); - rp->SI = FP_OFF(&nlsInfo); - rp->DS = FP_SEG(&nlsInfo); - rp->AX = 0x1400 | subfct; - intr(0x2f, rp); - log(("NLS: muxGo(): return value = %d\n", rp->AX)); - return rp->AX; + int ret; + log(("NLS: muxGo(): subfct=%x, cntry=%u, cp=%u, ES:DI=%p\n", + subfct, cntry, cp, buf)); + ret = call_nls(subfct, &nlsInfo, bp, cp, cntry, bufsize, buf, id); + log(("NLS: muxGo(): return value = %d\n", ret)); + return ret; } /* @@ -122,49 +111,36 @@ STATIC COUNT muxGo(int subfct, iregs * rp) */ COUNT muxLoadPkg(UWORD cp, UWORD cntry) { - iregs r; - - assertDSeqSS(); /* because "&r" */ + UWORD id; /* on stack, call_nls in int2f.asm takes care of this + * if DS != SS */ /* 0x1400 == not installed, ok to install */ /* 0x1401 == not installed, not ok to install */ /* 0x14FF == installed */ - r.BX = NLS_FREEDOS_NLSFUNC_VERSION; /* What version of nlsInfo */ #if NLS_FREEDOS_NLSFUNC_VERSION == NLS_FREEDOS_NLSFUNC_ID /* make sure the NLSFUNC ID is updated */ #error "NLS_FREEDOS_NLSFUNC_VERSION == NLS_FREEDOS_NLSFUNC_ID" #endif - r.CX = NLS_FREEDOS_NLSFUNC_ID; - if (muxGo(0, &r) != 0x14ff) + if (muxGo(0, 0, NLS_FREEDOS_NLSFUNC_VERSION, 0, NLS_FREEDOS_NLSFUNC_ID, 0, + (UWORD *)&id) != 0x14ff) return DE_FILENOTFND; /* No NLSFUNC --> no load */ - if (r.BX != NLS_FREEDOS_NLSFUNC_ID) /* FreeDOS NLSFUNC will return */ + if (id != NLS_FREEDOS_NLSFUNC_ID) /* FreeDOS NLSFUNC will return */ return DE_INVLDACC; /* This magic number */ /* OK, the correct NLSFUNC is available --> load pkg */ - /* If BX == -1 on entry, NLSFUNC updates BX to the codepage loaded + /* If cp == -1 on entry, NLSFUNC updates cp to the codepage loaded into memory. The system must then change to this one later */ - r.DX = cntry; - r.BX = cp; - return muxGo(NLSFUNC_LOAD_PKG, &r); + return muxGo(NLSFUNC_LOAD_PKG, 0, cp, cntry, 0, 0, 0); } STATIC int muxBufGo(int subfct, int bp, UWORD cp, UWORD cntry, UWORD bufsize, VOID FAR * buf) { - iregs r; - - assertDSeqSS(); /* because "&r" */ + log(("NLS: muxBufGo(): subfct=%x, BP=%u, cp=%u, cntry=%u, len=%u, buf=%p\n", + subfct, bp, cp, cntry, bufsize, buf)); - log(("NLS: muxBufGo(): subfct=%x, BP=%u, cp=%u, cntry=%u, len=%u, buf=%04x:%04x\n", subfct, bp, cp, cntry, bufsize, FP_SEG(buf), FP_OFF(buf))); - - r.DX = cntry; - r.BX = cp; - r.ES = FP_SEG(buf); - r.DI = FP_OFF(buf); - r.CX = bufsize; - r.BP = bp; - return muxGo(subfct, &r); + return muxGo(subfct, bp, cp, cntry, bufsize, buf, 0); } #define mux65(s,cp,cc,bs,b) muxBufGo(2, (s), (cp), (cc), (bs), (b)) @@ -427,11 +403,9 @@ STATIC VOID xUpMem(struct nlsPackage FAR * nls, VOID FAR * str, STATIC int nlsYesNo(struct nlsPackage FAR * nls, unsigned char ch) { - assertDSeqSS(); /* because "&ch" */ - log(("NLS: nlsYesNo(): in ch=%u (%c)\n", ch, ch > 32 ? ch : ' ')); - xUpMem(nls, &ch, 1); /* Upcase character */ + xUpMem(nls, MK_FP(_SS, &ch), 1); /* Upcase character */ /* Cannot use DosUpChar(), because maybe: nls != current NLS pkg However: Upcase character within lowlevel @@ -507,8 +481,7 @@ VOID DosUpFMem(VOID FAR * str, unsigned len) unsigned char DosUpFChar(unsigned char ch) /* upcase a single character for file names */ { - assertDSeqSS(); /* because "&ch" */ - DosUpFMem((UBYTE FAR *) & ch, 1); + DosUpFMem(MK_FP(_SS, & ch), 1); return ch; } From 7bf976be3ff97f8ba34635651f17ddd424bfcc81 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sat, 20 Mar 2004 10:41:30 +0000 Subject: [PATCH 385/671] Saved ~75 bytes in printf and by elimination of fstrlen. There's only one call and inlining doesn't increase the size. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@803 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/asmsupt.asm | 3 +- kernel/prf.c | 211 +++++++++++++++++++++------------------------ 2 files changed, 101 insertions(+), 113 deletions(-) diff --git a/kernel/asmsupt.asm b/kernel/asmsupt.asm index 5283c4be..e26061be 100644 --- a/kernel/asmsupt.asm +++ b/kernel/asmsupt.asm @@ -291,7 +291,7 @@ strcpy_loop: jmp short pascal_return ;****************************************************************** - +%ifndef _INIT global FSTRLEN FSTRLEN: call pascal_setup @@ -301,6 +301,7 @@ FSTRLEN: mov bl,4 jmp short dostrlen +%endif ;********************************************** global STRLEN diff --git a/kernel/prf.c b/kernel/prf.c index e4ed0896..0f849cb1 100644 --- a/kernel/prf.c +++ b/kernel/prf.c @@ -34,7 +34,6 @@ #endif #ifdef _INIT -#define fstrlen init_fstrlen #define handle_char init_handle_char #define put_console init_put_console #define ltob init_ltob @@ -91,6 +90,17 @@ void put_console(int c) } } #else +#ifdef __WATCOMC__ +void int10_e(char c); +#pragma aux int10_e = \ + "push bp" \ + "mov ah, 0xe" \ + "mov bx, 0x0070" \ + "int 0x10" \ + "pop bp" \ + parm [al] modify [ah bx]; +#endif + void put_console(int c) { if (c == '\n') @@ -104,6 +114,8 @@ void put_console(int c) _AH = 0x0e; _BX = 0x0070; __int__(0x10); +#elif defined(__WATCOMC__) + int10_e(c); #elif defined(I86) __asm { @@ -130,27 +142,10 @@ typedef char *va_list; static BYTE *charp = 0; STATIC VOID handle_char(COUNT); -STATIC BYTE * ltob(LONG, BYTE *, COUNT); -STATIC COUNT do_printf(CONST BYTE *, REG va_list); +STATIC void ltob(LONG, BYTE *, COUNT); +STATIC void do_printf(const char *, REG va_list); int CDECL printf(CONST BYTE * fmt, ...); -/* The following is user supplied and must match the following prototype */ -VOID cso(COUNT); - -#if defined(FORSYS) -COUNT fstrlen(BYTE FAR * s) /* don't want globals.h, sorry */ -{ - int i = 0; - - while (*s++) - i++; - - return i; -} -#else -COUNT /*ASMCFUNC*/ pascal fstrlen(BYTE FAR * s); /* don't want globals.h, sorry */ -#endif - /* special handler to switch between sprintf and printf */ STATIC VOID handle_char(COUNT c) { @@ -161,7 +156,7 @@ STATIC VOID handle_char(COUNT c) } /* ltob -- convert an long integer to a string in any base (2-16) */ -BYTE *ltob(LONG n, BYTE * s, COUNT base) +STATIC void ltob(LONG n, BYTE * s, COUNT base) { ULONG u; BYTE *p, *q; @@ -179,7 +174,7 @@ BYTE *ltob(LONG n, BYTE * s, COUNT base) } } - p = q = s; + p = s; do { /* generate digits in reverse order */ *p++ = "0123456789abcdef"[(UWORD) (u % base)]; @@ -187,17 +182,18 @@ BYTE *ltob(LONG n, BYTE * s, COUNT base) while ((u /= base) > 0); *p = '\0'; /* terminate the string */ - while (q < --p) + for (q = s; q < --p; q++) { /* reverse the digits */ c = *q; - *q++ = *p; + *q = *p; *p = c; } - return s; } #define LEFT 0 #define RIGHT 1 +#define ZEROSFILL 2 +#define LONGARG 4 /* printf -- short version of printf to conserve space */ int CDECL printf(CONST BYTE * fmt, ...) @@ -205,116 +201,97 @@ int CDECL printf(CONST BYTE * fmt, ...) va_list arg; va_start(arg, fmt); charp = 0; - return do_printf(fmt, arg); + do_printf(fmt, arg); + return 0; } int CDECL sprintf(BYTE * buff, CONST BYTE * fmt, ...) { - WORD ret; va_list arg; va_start(arg, fmt); charp = buff; - ret = do_printf(fmt, arg); - handle_char(NULL); - return ret; + do_printf(fmt, arg); + handle_char('\0'); + return 0; } -/* -ULONG FAR retcs(int i) -{ - char *p = (char*)&i; - - p -= 4; - return *(ULONG *)p; -} -*/ -COUNT do_printf(CONST BYTE * fmt, va_list arg) +STATIC void do_printf(CONST BYTE * fmt, va_list arg) { int base; BYTE s[11], FAR * p; - int c, flag, size, fill; - int longarg; - long currentArg; - -/* - long cs = retcs(1); - put_console("0123456789ABCDEF"[(cs >> 28) & 0x0f]); - put_console("0123456789ABCDEF"[(cs >> 24) & 0x0f]); - put_console("0123456789ABCDEF"[(cs >> 20) & 0x0f]); - put_console("0123456789ABCDEF"[(cs >> 16) & 0x0f]); - put_console(':'); - put_console("0123456789ABCDEF"[(cs >> 12) & 0x0f]); - put_console("0123456789ABCDEF"[(cs >> 8) & 0x0f]); - put_console("0123456789ABCDEF"[(cs >> 4) & 0x0f]); - put_console("0123456789ABCDEF"[(cs >> 0) & 0x0f]); -*/ - while ((c = *fmt++) != '\0') + int size; + unsigned char flags; + + for (;*fmt != '\0'; fmt++) { - if (c != '%') + if (*fmt != '%') { - handle_char(c); + handle_char(*fmt); continue; } - longarg = FALSE; - size = 0; - flag = RIGHT; - fill = ' '; + fmt++; + flags = RIGHT; if (*fmt == '-') { - flag = LEFT; + flags = LEFT; fmt++; } if (*fmt == '0') { - fill = '0'; + flags |= ZEROSFILL; fmt++; } - while (*fmt >= '0' && *fmt <= '9') + size = 0; + while (1) { - size = size * 10 + (*fmt++ - '0'); + unsigned c = (unsigned char)(*fmt - '0'); + if (c > 9) + break; + fmt++; + size = size * 10 + c; } if (*fmt == 'l') { - longarg = TRUE; + flags |= LONGARG; fmt++; } - c = *fmt++; - switch (c) + switch (*fmt) { case '\0': - return 0; + va_end(arg); + return; - case 'c': + case 'c': handle_char(va_arg(arg, int)); continue; case 'p': { - UWORD w0 = va_arg(arg, UWORD); + UWORD w0 = va_arg(arg, unsigned); char *tmp = charp; - sprintf(s, "%04x:%04x", va_arg(arg, UWORD), w0); + sprintf(s, "%04x:%04x", va_arg(arg, unsigned), w0); p = s; charp = tmp; - goto do_outputstring; + break; } case 's': p = va_arg(arg, char *); - goto do_outputstring; + break; case 'F': fmt++; /* we assume %Fs here */ case 'S': p = va_arg(arg, char FAR *); - goto do_outputstring; + break; case 'i': case 'd': @@ -333,42 +310,49 @@ COUNT do_printf(CONST BYTE * fmt, va_list arg) case 'x': base = 16; - lprt: - if (longarg) - currentArg = va_arg(arg, long); - else - currentArg = base < 0 ? (long)va_arg(arg, int) : - (long)va_arg(arg, unsigned int); - ltob(currentArg, s, base); - - p = s; - do_outputstring: - - size -= fstrlen(p); - - if (flag == RIGHT) + lprt: { - for (; size > 0; size--) - handle_char(fill); + long currentArg; + if (flags & LONGARG) + currentArg = va_arg(arg, long); + else + { + currentArg = va_arg(arg, int); + if (base >= 0) + currentArg = (long)(unsigned)currentArg; + } + ltob(currentArg, s, base); + p = s; } - for (; *p != '\0'; p++) - handle_char(*p); - - for (; size > 0; size--) - handle_char(fill); - - continue; + break; default: handle_char('?'); - handle_char(c); - break; + handle_char(*fmt); + continue; + + } + { + size_t i = 0; + while(p[i]) i++; + size -= i; + } + if (flags & RIGHT) + { + int ch = ' '; + if (flags & ZEROSFILL) ch = '0'; + for (; size > 0; size--) + handle_char(ch); } + for (; *p != '\0'; p++) + handle_char(*p); + + for (; size > 0; size--) + handle_char(' '); } va_end(arg); - return 0; } #endif @@ -439,10 +423,12 @@ void put_string(const char *s) and run. if strings are wrong, the program will wait for the ANYKEY */ -#include +#include +#include + void cso(char c) { - putch(c); + putchar(c); } struct { @@ -483,7 +469,7 @@ struct { { "1 ", "%-4x", 1, 0}, { - "1000", "%-04x", 1, 0}, + "1 ", "%-04x", 1, 0}, { "1", "%ld", 1, 0}, { @@ -503,7 +489,7 @@ struct { { "1 ", "%-4lx", 1, 0}, { - "1000", "%-04lx", 1, 0}, + "1 ", "%-04lx", 1, 0}, { "-2147483648", "%ld", 0, 0x8000}, { @@ -515,9 +501,9 @@ struct { { "32767", "%ld", 0x7fff, 0}, { -"ptr 1234:5678", "ptr %p", 0x5678, 0x1234}, 0}; +"ptr 1234:5678", "ptr %p", 0x5678, 0x1234}, {0}}; -test(char *should, char *format, unsigned lowint, unsigned highint) +void test(char *should, char *format, unsigned lowint, unsigned highint) { char b[100]; @@ -527,12 +513,12 @@ test(char *should, char *format, unsigned lowint, unsigned highint) if (strcmp(b, should)) { - printf("\nhit the ANYKEY\n"); - getch(); + printf("\nhit ENTER\n"); + getchar(); } } -main() +int main(void) { int i; printf("hello world\n"); @@ -542,6 +528,7 @@ main() test(testarray[i].should, testarray[i].format, testarray[i].lowint, testarray[i].highint); } + return 0; } #endif From 00ef6b1be2249c8de3121cf7ef796494f9565f8a Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sun, 21 Mar 2004 12:36:47 +0000 Subject: [PATCH 386/671] Eliminated long2para and avoided use of "long"s in DosExeLoader, using paragraphs to measure size instead. Saves ~130 bytes together. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@806 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/memmgr.c | 8 ------ kernel/task.c | 67 +++++++++++++++++++++++-------------------------- 2 files changed, 32 insertions(+), 43 deletions(-) diff --git a/kernel/memmgr.c b/kernel/memmgr.c index 8d98cd3a..94c32650 100644 --- a/kernel/memmgr.c +++ b/kernel/memmgr.c @@ -80,14 +80,6 @@ seg far2para(VOID FAR * p) return FP_SEG(p) + (FP_OFF(p) >> 4); } -seg long2para(ULONG size) -{ - UWORD high = (UWORD)(size >> 16); - if ((UWORD) size > 0xfff0) - high++; - return (((UWORD) size + 0x0f) >> 4) + (high << 12); -} - /* * Add a displacement to a far pointer and return the result normalized. */ diff --git a/kernel/task.c b/kernel/task.c index 32b69429..ec03b697 100644 --- a/kernel/task.c +++ b/kernel/task.c @@ -127,8 +127,8 @@ STATIC COUNT ChildEnv(exec_blk * exp, UWORD * pChildEnvSeg, char far * pathname) } /* allocate enough space for env + path */ - if ((RetCode = DosMemAlloc(long2para(nEnvSize + ENV_KEEPFREE), - mem_access_mode, (seg FAR *) pChildEnvSeg, + if ((RetCode = DosMemAlloc((nEnvSize + ENV_KEEPFREE + 15)/16, + mem_access_mode, pChildEnvSeg, NULL /*(UWORD FAR *) MaxEnvSize ska */ )) < 0) return RetCode; pDest = MK_FP(*pChildEnvSeg + 1, 0); @@ -551,22 +551,18 @@ VOID return_user(void) COUNT DosExeLoader(BYTE FAR * namep, exec_blk * exp, COUNT mode, COUNT fd) { UWORD mem, env, start_seg, asize = 0; - ULONG exe_size; + UWORD exe_size; { - ULONG image_size; - ULONG image_offset; - - /* compute image offset from the ExeHeader */ - image_offset = (ULONG) ExeHeader.exHeaderSize * 16; + UWORD image_size; /* compute image size by removing the offset from the */ /* number pages scaled to bytes plus the remainder and */ /* the psp */ - /* First scale the size */ - image_size = (ULONG) ExeHeader.exPages * 512; - /* remove the offset */ - image_size -= image_offset; - + /* First scale the size and remove the offset */ + if (ExeHeader.exPages >= 2048) + return DE_INVLDDATA; /* we're not able to get >=1MB in dos memory */ + image_size = ExeHeader.exPages * 32 - ExeHeader.exHeaderSize; + /* We should not attempt to allocate memory if we are overlaying the current process, because the new process will simply re-use the block we already have allocated. @@ -579,8 +575,8 @@ COUNT DosExeLoader(BYTE FAR * namep, exec_blk * exp, COUNT mode, COUNT fd) COUNT rc; /* and finally add in the psp size */ - image_size += sizeof(psp); /*TE 03/20/01 */ - exe_size = (ULONG) long2para(image_size) + ExeHeader.exMinAlloc; + image_size += sizeof(psp) / 16; /*TE 03/20/01 */ + exe_size = image_size + ExeHeader.exMinAlloc; /* Clone the environement and create a memory arena */ if (mode & 0x80) @@ -593,10 +589,12 @@ COUNT DosExeLoader(BYTE FAR * namep, exec_blk * exp, COUNT mode, COUNT fd) if (rc == SUCCESS) /* Now find out how many paragraphs are available */ - rc = ExecMemLargest(&asize, (UWORD)exe_size); + rc = ExecMemLargest(&asize, exe_size); - exe_size = (ULONG) long2para(image_size) + ExeHeader.exMaxAlloc; - if (exe_size > asize) + exe_size = image_size + ExeHeader.exMaxAlloc; + /* second test is for overflow (avoiding longs) -- + exMaxAlloc can be high */ + if (exe_size > asize || exe_size < image_size) exe_size = asize; /* TE if ExeHeader.exMinAlloc == ExeHeader.exMaxAlloc == 0, @@ -609,7 +607,7 @@ COUNT DosExeLoader(BYTE FAR * namep, exec_blk * exp, COUNT mode, COUNT fd) /* Allocate our memory and pass back any errors */ if (rc == SUCCESS) - rc = ExecMemAlloc((UWORD)exe_size, &mem, &asize); + rc = ExecMemAlloc(exe_size, &mem, &asize); if (rc != SUCCESS) DosMemFree(env); @@ -645,7 +643,7 @@ COUNT DosExeLoader(BYTE FAR * namep, exec_blk * exp, COUNT mode, COUNT fd) /* Now load the executable */ /* offset to start of image */ - if (SftSeek(fd, image_offset, 0) != SUCCESS) + if (SftSeek(fd, ExeHeader.exHeaderSize * 16UL, 0) != SUCCESS) { if (mode != OVERLAY) { @@ -660,33 +658,32 @@ COUNT DosExeLoader(BYTE FAR * namep, exec_blk * exp, COUNT mode, COUNT fd) exe_size = image_size; if (mode != OVERLAY) { - exe_size -= sizeof(psp); - start_seg += long2para(sizeof(psp)); + exe_size -= sizeof(psp) / 16; + start_seg += sizeof(psp) /16; if (exe_size > 0 && (ExeHeader.exMinAlloc == 0) && (ExeHeader.exMaxAlloc == 0)) { mcb FAR *mp = MK_FP(mem - 1, 0); /* then the image should be placed as high as possible */ - start_seg = start_seg + mp->m_size - (UWORD)((image_size + 15) / 16); + start_seg += mp->m_size - image_size; } } } - /* read in the image in 32K chunks */ + /* read in the image in 32256 chunks */ { - int nBytesRead; - BYTE FAR *sp = MK_FP(start_seg, 0x0); - - while (exe_size > 0) + int nBytesRead, toRead = CHUNK; + seg sp = start_seg; + + while (toRead == CHUNK) { - nBytesRead = - (int)DosRWSft(fd, - (COUNT) (exe_size < CHUNK ? exe_size : CHUNK), - (VOID FAR *) sp, XFR_READ); - if (nBytesRead <= 0) + if (exe_size < CHUNK/16) + toRead = exe_size*16; + nBytesRead = (int)DosRWSft(fd, toRead, MK_FP(sp, 0), XFR_READ); + if (nBytesRead < toRead) break; - sp = add_far((VOID FAR *) sp, nBytesRead); - exe_size -= nBytesRead; + sp += CHUNK/16; + exe_size -= CHUNK/16; } } From 82261c0cafb97351c01b7319dac40c0dcf216c34 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sun, 21 Mar 2004 13:56:13 +0000 Subject: [PATCH 387/671] add_far can get away with adding 16 bit offsets only. Saves ~200 bytes! git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@807 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/fatfs.c | 2 +- kernel/memmgr.c | 17 +++++++++-------- kernel/proto.h | 2 +- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/kernel/fatfs.c b/kernel/fatfs.c index 41fa836c..dfe34b34 100644 --- a/kernel/fatfs.c +++ b/kernel/fatfs.c @@ -1804,7 +1804,7 @@ long rwblock(COUNT fd, VOID FAR * buffer, UCOUNT count, int mode) update_pointers: ret_cnt += xfr_cnt; to_xfer -= xfr_cnt; - buffer = add_far((VOID FAR *) buffer, (ULONG) xfr_cnt); + buffer = add_far(buffer, xfr_cnt); if (mode == XFR_WRITE) { if (fnp->f_offset > fnp->f_dir.dir_size) diff --git a/kernel/memmgr.c b/kernel/memmgr.c index 94c32650..c2486a01 100644 --- a/kernel/memmgr.c +++ b/kernel/memmgr.c @@ -83,22 +83,23 @@ seg far2para(VOID FAR * p) /* * Add a displacement to a far pointer and return the result normalized. */ -VOID FAR * add_far(VOID FAR * fp, ULONG off) +void FAR * add_far(void FAR * fp, unsigned off) { - UWORD off2; + unsigned segment, offset; if (FP_SEG(fp) == 0xffff) - return ((BYTE FAR *) fp) + FP_OFF(off); + return ((char FAR *) fp) + off; #ifndef I86 if (FP_SEG(fp) == 0) - return ((BYTE FAR *) fp) + FP_OFF(off); + return ((char FAR *) fp) + off; #endif - off += FP_OFF(fp); - off2 = ((UWORD)(off >> 16) << 12) + ((UWORD) off >> 4); - - return MK_FP(FP_SEG(fp) + off2, (UWORD) off & 0xf); + offset = off + FP_OFF(fp); + segment = FP_SEG(fp) + (offset >> 4); + if (offset < off) /* forward carry without using a long */ + segment += 0x1000; + return MK_FP(segment, offset & 0xf); } /* diff --git a/kernel/proto.h b/kernel/proto.h index 25dbd0da..fc62a747 100644 --- a/kernel/proto.h +++ b/kernel/proto.h @@ -230,7 +230,7 @@ COUNT DosDevIOctl(lregs * r); /* memmgr.c */ seg far2para(VOID FAR * p); seg long2para(ULONG size); -VOID FAR *add_far(VOID FAR * fp, ULONG off); +void FAR *add_far(void FAR * fp, unsigned off); VOID FAR *adjust_far(const void FAR * fp); COUNT DosMemAlloc(UWORD size, COUNT mode, seg FAR * para, UWORD FAR * asize); From 600e02b1b45d7c5bd2b9725f60bf2bd556a8157c Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sun, 21 Mar 2004 15:31:45 +0000 Subject: [PATCH 388/671] A few suggestions from Arkady. Saves 5 bytes. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@808 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/task.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/kernel/task.c b/kernel/task.c index ec03b697..e3d5ed0a 100644 --- a/kernel/task.c +++ b/kernel/task.c @@ -659,8 +659,8 @@ COUNT DosExeLoader(BYTE FAR * namep, exec_blk * exp, COUNT mode, COUNT fd) if (mode != OVERLAY) { exe_size -= sizeof(psp) / 16; - start_seg += sizeof(psp) /16; - if (exe_size > 0 && (ExeHeader.exMinAlloc == 0) && (ExeHeader.exMaxAlloc == 0)) + start_seg += sizeof(psp) / 16; + if (exe_size > 0 && (ExeHeader.exMinAlloc | ExeHeader.exMaxAlloc) == 0) { mcb FAR *mp = MK_FP(mem - 1, 0); @@ -675,12 +675,12 @@ COUNT DosExeLoader(BYTE FAR * namep, exec_blk * exp, COUNT mode, COUNT fd) int nBytesRead, toRead = CHUNK; seg sp = start_seg; - while (toRead == CHUNK) + while (1) { if (exe_size < CHUNK/16) toRead = exe_size*16; nBytesRead = (int)DosRWSft(fd, toRead, MK_FP(sp, 0), XFR_READ); - if (nBytesRead < toRead) + if (nBytesRead < toRead || exe_size <= CHUNK/16) break; sp += CHUNK/16; exe_size -= CHUNK/16; From 43ca8741b014cbac7bda7f3022037c99031382a5 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sun, 21 Mar 2004 22:01:41 +0000 Subject: [PATCH 389/671] echo ^C to stdout, not stdin or stderr. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@809 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/break.c | 2 +- kernel/chario.c | 7 +------ kernel/proto.h | 2 +- 3 files changed, 3 insertions(+), 8 deletions(-) diff --git a/kernel/break.c b/kernel/break.c index 8be3b8ee..d3d24c54 100644 --- a/kernel/break.c +++ b/kernel/break.c @@ -68,7 +68,7 @@ int check_handle_break(void) */ void handle_break(struct dhdr FAR **pdev) { - echo_char_stdin(CTL_C); + echo_char(CTL_C, get_sft_idx(STDOUT)); con_flush(pdev); if (!ErrorMode) /* within int21_handler, InDOS is not incremented */ if (InDOS) diff --git a/kernel/chario.c b/kernel/chario.c index 93ea5f73..eaf3d920 100644 --- a/kernel/chario.c +++ b/kernel/chario.c @@ -306,7 +306,7 @@ void write_char_stdout(int c) #define iscntrl(c) ((unsigned char)(c) < ' ') /* this is for handling things like ^C, mostly used in echoed input */ -STATIC int echo_char(int c, int sft_idx) +int echo_char(int c, int sft_idx) { int out = c; if (iscntrl(c) && c != HT && c != LF && c != CR) @@ -318,11 +318,6 @@ STATIC int echo_char(int c, int sft_idx) return c; } -int echo_char_stdin(int c) -{ - return echo_char(c, get_sft_idx(STDIN)); -} - STATIC void destr_bs(int sft_idx) { write_char(BS, sft_idx); diff --git a/kernel/proto.h b/kernel/proto.h index fc62a747..3471a11a 100644 --- a/kernel/proto.h +++ b/kernel/proto.h @@ -58,7 +58,7 @@ void handle_break(struct dhdr FAR **pdev); struct dhdr FAR *sft_to_dev(sft FAR *sft); long BinaryCharIO(struct dhdr FAR **pdev, size_t n, void FAR * bp, unsigned command); -int echo_char_stdin(int c); +int echo_char(int c, int sft_idx); int con_break(void); int StdinBusy(void); void con_flush(struct dhdr FAR **pdev); From 1285c36f8c3ee5777cff76ebdcbb9e0ed932bbaf Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sun, 21 Mar 2004 23:25:53 +0000 Subject: [PATCH 390/671] Echo input LF as CR-LF unless it's the first character. Never store LF in the buffer. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@810 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/chario.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/kernel/chario.c b/kernel/chario.c index eaf3d920..84a0f275 100644 --- a/kernel/chario.c +++ b/kernel/chario.c @@ -386,7 +386,7 @@ void read_line(int sft_in, int sft_out, keyboard FAR * kp) unsigned cu_pos = scr_pos; unsigned count = 0, stored_pos = 0; unsigned size = kp->kb_size, stored_size = kp->kb_count; - BOOL insert = FALSE; + BOOL insert = FALSE, first = TRUE; if (size == 0) return; @@ -404,8 +404,17 @@ void read_line(int sft_in, int sft_out, keyboard FAR * kp) c = (unsigned)read_char_check_break(sft_in) << 8; switch (c) { + case LF: + /* show LF if it's not the first character. Never store it */ + if (!first) + { + write_char(CR, sft_out); + write_char(LF, sft_out); + } + break; + case CTL_F: - continue; + break; case RIGHT: case F1: @@ -515,6 +524,7 @@ void read_line(int sft_in, int sft_out, keyboard FAR * kp) stored_pos++; break; } + first = FALSE; } while (c != CR); fmemcpy(kp->kb_buf, local_buffer, count); /* if local_buffer overflows into the CON default buffer we From 11a7b69e5c002bea0c831d34378195165670cf26 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Mon, 22 Mar 2004 10:29:26 +0000 Subject: [PATCH 391/671] Make f_diroff an entry offset so it can be 16bits. Enforce the 65536 entry limit in dir_read(). Saves 80 bytes or so + 2 bytes in every f_node. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@811 6ac86273-5f31-0410-b378-82cca8765d1b --- hdr/fnode.h | 2 +- kernel/fatdir.c | 37 ++++++++++++++++++++----------------- kernel/fatfs.c | 8 ++++---- kernel/lfnapi.c | 16 ++++++++-------- 4 files changed, 33 insertions(+), 30 deletions(-) diff --git a/hdr/fnode.h b/hdr/fnode.h index 9d1e1cc1..17e343c0 100644 --- a/hdr/fnode.h +++ b/hdr/fnode.h @@ -49,7 +49,7 @@ struct f_node { struct dirent f_dir; /* this file's dir entry image */ - ULONG f_diroff; /* offset of the dir entry */ + UWORD f_diroff; /* offset/32 of the dir entry */ CLUSTER f_dirstart; /* the starting cluster of dir */ /* when dir is not root */ struct dpb FAR *f_dpb; /* the block device for file */ diff --git a/kernel/fatdir.c b/kernel/fatdir.c index 5f2b5c5d..56b345be 100644 --- a/kernel/fatdir.c +++ b/kernel/fatdir.c @@ -46,7 +46,8 @@ VOID dir_init_fnode(f_node_ptr fnp, CLUSTER dirstart) fnp->f_flags.f_droot = FALSE; fnp->f_flags.f_ddir = TRUE; fnp->f_flags.f_dnew = TRUE; - fnp->f_diroff = fnp->f_offset = 0l; + fnp->f_diroff = 0; + fnp->f_offset = 0l; fnp->f_cluster_offset = 0; /* root directory */ @@ -209,7 +210,11 @@ COUNT dir_read(REG f_node_ptr fnp) { struct buffer FAR *bp; REG UWORD secsize = fnp->f_dpb->dpb_secsize; - ULONG new_diroff = fnp->f_diroff; + unsigned new_diroff = fnp->f_diroff; + + /* can't have more than 65535 directory entries */ + if (new_diroff == 65535) + return DE_SEEK; /* Directories need to point to their current offset, not for */ /* next op. Therefore, if it is anything other than the first */ @@ -217,7 +222,7 @@ COUNT dir_read(REG f_node_ptr fnp) /* than wait until exit. If it was new, clear the special new */ /* flag. */ if (!fnp->f_flags.f_dnew) - new_diroff += DIRENT_SIZE; + new_diroff++; /* Determine if we hit the end of the directory. If we have, */ /* bump the offset back to the end and exit. If not, fill the */ @@ -226,12 +231,11 @@ COUNT dir_read(REG f_node_ptr fnp) if (fnp->f_flags.f_droot) { - if (new_diroff >= DIRENT_SIZE * (ULONG) fnp->f_dpb->dpb_dirents) + if (new_diroff >= fnp->f_dpb->dpb_dirents) return DE_SEEK; - bp = getblock((ULONG) (new_diroff / secsize - + fnp->f_dpb->dpb_dirstrt), - fnp->f_dpb->dpb_unit); + bp = getblock(new_diroff / (secsize / DIRENT_SIZE) + + fnp->f_dpb->dpb_dirstrt, fnp->f_dpb->dpb_unit); #ifdef DISPLAY_GETBLOCK printf("DIR (dir_read)\n"); #endif @@ -239,7 +243,7 @@ COUNT dir_read(REG f_node_ptr fnp) else { /* Do a "seek" to the directory position */ - fnp->f_offset = new_diroff; + fnp->f_offset = new_diroff * (ULONG)DIRENT_SIZE; /* Search through the FAT to find the block */ /* that this entry is in. */ @@ -264,8 +268,8 @@ COUNT dir_read(REG f_node_ptr fnp) bp->b_flag |= BFR_DIR | BFR_VALID; getdirent((BYTE FAR *) & bp-> - b_buffer[((UWORD) new_diroff) % fnp->f_dpb->dpb_secsize], - (struct dirent FAR *)&fnp->f_dir); + b_buffer[(new_diroff * DIRENT_SIZE) % fnp->f_dpb->dpb_secsize], + &fnp->f_dir); swap_deleted(fnp->f_dir.dir_name); @@ -308,8 +312,8 @@ BOOL dir_write(REG f_node_ptr fnp) /* simple. */ if (fnp->f_flags.f_droot) { - bp = getblock((ULONG) ((UWORD) fnp->f_diroff / secsize - + fnp->f_dpb->dpb_dirstrt), + bp = getblock(fnp->f_diroff / (secsize / DIRENT_SIZE) + + fnp->f_dpb->dpb_dirstrt, fnp->f_dpb->dpb_unit); #ifdef DISPLAY_GETBLOCK printf("DIR (dir_write)\n"); @@ -324,7 +328,7 @@ BOOL dir_write(REG f_node_ptr fnp) /* Do a "seek" to the directory position */ /* and convert the fnode to a directory fnode. */ - fnp->f_offset = fnp->f_diroff; + fnp->f_offset = fnp->f_diroff * (ULONG)DIRENT_SIZE; fnp->f_back = LONG_LAST_CLUSTER; fnp->f_cluster = fnp->f_dirstart; fnp->f_cluster_offset = 0; @@ -361,9 +365,8 @@ BOOL dir_write(REG f_node_ptr fnp) swap_deleted(fnp->f_dir.dir_name); - putdirent((struct dirent FAR *)&fnp->f_dir, - (VOID FAR *) & bp->b_buffer[(UWORD) fnp->f_diroff % - fnp->f_dpb->dpb_secsize]); + putdirent(&fnp->f_dir, &bp->b_buffer[(fnp->f_diroff * DIRENT_SIZE) % + fnp->f_dpb->dpb_secsize]); swap_deleted(fnp->f_dir.dir_name); @@ -524,7 +527,7 @@ COUNT dos_findnext(void) fnp->f_flags.f_dnew = TRUE; if (dmp->dm_entry > 0) { - fnp->f_diroff = (ULONG) (dmp->dm_entry - 1) * DIRENT_SIZE; + fnp->f_diroff = dmp->dm_entry - 1; fnp->f_flags.f_dnew = FALSE; } diff --git a/kernel/fatfs.c b/kernel/fatfs.c index dfe34b34..e4110c6c 100644 --- a/kernel/fatfs.c +++ b/kernel/fatfs.c @@ -444,13 +444,13 @@ STATIC BOOL find_fname(f_node_ptr fnp, char *fcbname, int attr) */ COUNT remove_lfn_entries(f_node_ptr fnp) { - ULONG original_diroff = fnp->f_diroff; + unsigned original_diroff = fnp->f_diroff; while (TRUE) { if (fnp->f_diroff == 0) break; - fnp->f_diroff -= 2 * DIRENT_SIZE; + fnp->f_diroff -= 2; /* it cannot / should not get below 0 because of '.' and '..' */ if (dir_read(fnp) <= 0) { dir_close(fnp); @@ -462,7 +462,7 @@ COUNT remove_lfn_entries(f_node_ptr fnp) fnp->f_flags.f_dmod = TRUE; if (!dir_write(fnp)) return DE_BLKINVLD; } - fnp->f_diroff = original_diroff - DIRENT_SIZE; + fnp->f_diroff = original_diroff - 1; if (dir_read(fnp) <= 0) { dir_close(fnp); return DE_BLKINVLD; @@ -1748,7 +1748,7 @@ long rwblock(COUNT fd, VOID FAR * buffer, UCOUNT count, int mode) normal_xfer: #ifdef DSK_DEBUG - printf("r/w %d links; dir offset %ld, cluster %d, mode %x\n", + printf("r/w %d links; dir offset %d, cluster %d, mode %x\n", fnp->f_count, fnp->f_diroff, fnp->f_cluster, mode); #endif diff --git a/kernel/lfnapi.c b/kernel/lfnapi.c index 89a5fbdb..b56fc05d 100644 --- a/kernel/lfnapi.c +++ b/kernel/lfnapi.c @@ -100,12 +100,12 @@ COUNT lfn_free_inode(COUNT handle) /* Description. * Initialize internal fnode, so that it'll point to the directory entry - * at "diroff" byte offset from the start of the directory with the "dirstart" + * at "diroff" entry offset from the start of the directory with the "dirstart" * starting cluster. * Return value. * SUCCESS, LHE_INVLDHNDL */ -COUNT lfn_setup_inode(COUNT handle, ULONG dirstart, ULONG diroff) +COUNT lfn_setup_inode(COUNT handle, ULONG dirstart, UWORD diroff) { f_node_ptr fnp = xlt_fd(handle); if (fnp == 0 || fnp->f_count <= 0) return LHE_INVLDHNDL; @@ -131,7 +131,7 @@ COUNT lfn_create_entries(COUNT handle, lfn_inode_ptr lip) COUNT entries_needed, free_entries, i, rc; UNICODE FAR *lfn_name = lip->l_name; UBYTE id = 1, sfn_checksum = lfn_checksum(lip->l_dir.dir_name); - ULONG sfn_offset; + unsigned sfn_offset; if (fnp == 0 || fnp->f_count <= 0) return LHE_INVLDHNDL; entries_needed = (ufstrlen(lfn_name) + CHARS_IN_LFN_ENTRY - 1) @@ -160,7 +160,7 @@ COUNT lfn_create_entries(COUNT handle, lfn_inode_ptr lip) if (extend_dir(fnp) != SUCCESS) return LHE_NOSPACE; /* fnp points to the first free dir entry on return from extend_dir, * so we go to previous entry to read this free entry on next cycle */ - fnp->f_diroff -= DIRENT_SIZE; + fnp->f_diroff--; } else free_entries = 0; /* rc == 1 here => we've read some sfn entry */ } @@ -171,7 +171,7 @@ COUNT lfn_create_entries(COUNT handle, lfn_inode_ptr lip) fmemcpy(&fnp->f_dir, &lip->l_dir, sizeof(struct dirent)); dir_write(fnp); - fnp->f_diroff -= DIRENT_SIZE; + fnp->f_diroff--; /* Go in the reverse direction and create LFN entries */ for (i = 0; i < entries_needed - 1; i++, id++) { @@ -183,7 +183,7 @@ COUNT lfn_create_entries(COUNT handle, lfn_inode_ptr lip) lfn(fnp)->lfn_id = id; fnp->f_dir.dir_attrib = D_LFN; if (!dir_write(fnp)) return LHE_IOERROR; - fnp->f_diroff -= DIRENT_SIZE; + fnp->f_diroff--; } fnp->f_flags.f_dmod = FALSE; @@ -206,7 +206,7 @@ COUNT lfn_dir_read(COUNT handle, lfn_inode_ptr lip) COUNT rc; UBYTE id = 1, real_id; UNICODE FAR *lfn_name = lip->l_name; - ULONG sfn_diroff; + UWORD sfn_diroff; BOOL name_tail; f_node_ptr fnp = xlt_fd(handle); if (fnp == 0 || fnp->f_count <= 0) return LHE_INVLDHNDL; @@ -230,7 +230,7 @@ COUNT lfn_dir_read(COUNT handle, lfn_inode_ptr lip) while (TRUE) { if (fnp->f_diroff == 0) break; - fnp->f_diroff -= 2*DIRENT_SIZE; + fnp->f_diroff -= 2; rc = dir_read(fnp); if (rc == DE_BLKINVLD) return LHE_IOERROR; if (fnp->f_dir.dir_name[0] == DELETED From c73ee8084ae2f9a56bfc0545d8c9b614fe6db98d Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Mon, 22 Mar 2004 15:43:56 +0000 Subject: [PATCH 392/671] Remove the 65535 check for root directories. It's checked against a different limit later anyway later, and it breaks remove_lfn_entries... git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@812 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/fatdir.c | 8 +++++--- kernel/fatfs.c | 4 +++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/kernel/fatdir.c b/kernel/fatdir.c index 56b345be..551531e9 100644 --- a/kernel/fatdir.c +++ b/kernel/fatdir.c @@ -212,9 +212,11 @@ COUNT dir_read(REG f_node_ptr fnp) REG UWORD secsize = fnp->f_dpb->dpb_secsize; unsigned new_diroff = fnp->f_diroff; - /* can't have more than 65535 directory entries */ - if (new_diroff == 65535) - return DE_SEEK; + /* can't have more than 65535 directory entries + remove lfn entries may call us with new_diroff == -1 + for root directories though */ + if (!fnp->f_flags.f_droot && new_diroff >= 65535U) + return DE_SEEK; /* Directories need to point to their current offset, not for */ /* next op. Therefore, if it is anything other than the first */ diff --git a/kernel/fatfs.c b/kernel/fatfs.c index e4110c6c..0a22f286 100644 --- a/kernel/fatfs.c +++ b/kernel/fatfs.c @@ -451,7 +451,9 @@ COUNT remove_lfn_entries(f_node_ptr fnp) if (fnp->f_diroff == 0) break; fnp->f_diroff -= 2; - /* it cannot / should not get below 0 because of '.' and '..' */ + /* it cannot / should not get below 0 because of '.' and '..' + * except for root directories... but then dir_read() makes it 0 + * again */ if (dir_read(fnp) <= 0) { dir_close(fnp); return DE_BLKINVLD; From b0009452ee18e0b543210b98babd7e115b6b7068 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Mon, 22 Mar 2004 16:38:46 +0000 Subject: [PATCH 393/671] Remove add_far. adjust_far can do the job. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@813 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/dsk.c | 6 +++--- kernel/fatfs.c | 4 ++-- kernel/memmgr.c | 22 ---------------------- 3 files changed, 5 insertions(+), 27 deletions(-) diff --git a/kernel/dsk.c b/kernel/dsk.c index e3c29892..977e6719 100644 --- a/kernel/dsk.c +++ b/kernel/dsk.c @@ -237,8 +237,7 @@ STATIC WORD diskchange(ddt * pddt) { COUNT result; - /* if it's a hard drive, media never changes */ - if (hd(pddt->ddt_descflags)) + if (hd(pddt->ddt_descflags) && !(pddt->ddt_descflags & DF_CHANGELINE)) return M_NOT_CHANGED; if (play_dj(pddt) == M_CHANGED) @@ -983,6 +982,7 @@ STATIC int LBA_Transfer(ddt * pddt, UWORD mode, VOID FAR * buffer, } */ + buffer = adjust_far(buffer); for (; totaltodo != 0;) { /* avoid overflowing 64K DMA boundary */ @@ -1087,7 +1087,7 @@ STATIC int LBA_Transfer(ddt * pddt, UWORD mode, VOID FAR * buffer, LBA_address += count; totaltodo -= count; - buffer = add_far(buffer, count * 512); + buffer = adjust_far((char FAR *)buffer + count * 512); } return (error_code); diff --git a/kernel/fatfs.c b/kernel/fatfs.c index 0a22f286..c4e27bc5 100644 --- a/kernel/fatfs.c +++ b/kernel/fatfs.c @@ -1629,7 +1629,7 @@ long rwblock(COUNT fd, VOID FAR * buffer, UCOUNT count, int mode) secsize = fnp->f_dpb->dpb_secsize; /* Adjust the far pointer from user space to supervisor space */ - buffer = adjust_far((VOID FAR *) buffer); + buffer = adjust_far(buffer); /* Do the data transfer. Use block transfer methods so that we */ /* can utilize memory management in future DOS-C versions. */ @@ -1806,7 +1806,7 @@ long rwblock(COUNT fd, VOID FAR * buffer, UCOUNT count, int mode) update_pointers: ret_cnt += xfr_cnt; to_xfer -= xfr_cnt; - buffer = add_far(buffer, xfr_cnt); + buffer = adjust_far((char FAR *)buffer + xfr_cnt); if (mode == XFR_WRITE) { if (fnp->f_offset > fnp->f_dir.dir_size) diff --git a/kernel/memmgr.c b/kernel/memmgr.c index c2486a01..adeffede 100644 --- a/kernel/memmgr.c +++ b/kernel/memmgr.c @@ -80,28 +80,6 @@ seg far2para(VOID FAR * p) return FP_SEG(p) + (FP_OFF(p) >> 4); } -/* - * Add a displacement to a far pointer and return the result normalized. - */ -void FAR * add_far(void FAR * fp, unsigned off) -{ - unsigned segment, offset; - - if (FP_SEG(fp) == 0xffff) - return ((char FAR *) fp) + off; - -#ifndef I86 - if (FP_SEG(fp) == 0) - return ((char FAR *) fp) + off; -#endif - - offset = off + FP_OFF(fp); - segment = FP_SEG(fp) + (offset >> 4); - if (offset < off) /* forward carry without using a long */ - segment += 0x1000; - return MK_FP(segment, offset & 0xf); -} - /* * Return a normalized far pointer */ From df538bb32a9a8533f99db0c44052b898f7a183a9 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Mon, 22 Mar 2004 16:56:34 +0000 Subject: [PATCH 394/671] Eliminated f_sector and f_boff fields from fnodes. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@814 6ac86273-5f31-0410-b378-82cca8765d1b --- hdr/fnode.h | 2 -- kernel/fatdir.c | 7 ++++--- kernel/fatfs.c | 37 ++++++++++++++++++++----------------- 3 files changed, 24 insertions(+), 22 deletions(-) diff --git a/hdr/fnode.h b/hdr/fnode.h index 17e343c0..f1551189 100644 --- a/hdr/fnode.h +++ b/hdr/fnode.h @@ -58,8 +58,6 @@ struct f_node { CLUSTER f_back; /* the cluster we were at */ CLUSTER f_cluster_offset; /* relative cluster number within file */ CLUSTER f_cluster; /* the cluster we are at */ - UWORD f_sector; /* the sector in the cluster */ - UWORD f_boff; /* the byte in the cluster */ }; typedef struct f_node *f_node_ptr; diff --git a/kernel/fatdir.c b/kernel/fatdir.c index 551531e9..71b9def9 100644 --- a/kernel/fatdir.c +++ b/kernel/fatdir.c @@ -186,11 +186,12 @@ STATIC struct buffer FAR *getblock_from_off(f_node_ptr fnp, unsigned secsize) { /* Compute the block within the cluster and the */ /* offset within the block. */ - fnp->f_sector = (UBYTE)(fnp->f_offset / secsize) & fnp->f_dpb->dpb_clsmask; - fnp->f_boff = (UWORD)(fnp->f_offset % secsize); + unsigned sector; + + sector = (UBYTE)(fnp->f_offset / secsize) & fnp->f_dpb->dpb_clsmask; /* Get the block we need from cache */ - return getblock(clus2phys(fnp->f_cluster, fnp->f_dpb) + fnp->f_sector, + return getblock(clus2phys(fnp->f_cluster, fnp->f_dpb) + sector, fnp->f_dpb->dpb_unit); } diff --git a/kernel/fatfs.c b/kernel/fatfs.c index c4e27bc5..b37dbb6e 100644 --- a/kernel/fatfs.c +++ b/kernel/fatfs.c @@ -1432,6 +1432,7 @@ STATIC COUNT dos_extend(f_node_ptr fnp) /* The variable secsize will be used later. */ UWORD secsize = fnp->f_dpb->dpb_secsize; ULONG count; + unsigned sector, boff; #endif if (fnp->f_offset <= fnp->f_dir.dir_size) @@ -1449,27 +1450,27 @@ STATIC COUNT dos_extend(f_node_ptr fnp) #ifdef WRITEZEROS /* Compute the block within the cluster and the offset */ /* within the block. */ - fnp->f_sector = (UBYTE)(fnp->f_offset / secsize) & fnp->f_dpb->dpb_clsmask; - fnp->f_boff = (UWORD)(fnp->f_offset % secsize); + sector = (UBYTE)(fnp->f_offset / secsize) & fnp->f_dpb->dpb_clsmask; + boff = (UWORD)(fnp->f_offset % secsize); #ifdef DSK_DEBUG printf("write %d links; dir offset %ld, cluster %d\n", fnp->f_count, fnp->f_diroff, fnp->f_cluster); #endif - xfr_cnt = count < (ULONG) secsize - fnp->f_boff ? - (UWORD) count : secsize - fnp->f_boff; + xfr_cnt = count < (ULONG) secsize - boff ? + (UWORD) count : secsize - boff; /* get a buffer to store the block in */ - if ((fnp->f_boff == 0) && (xfr_cnt == secsize)) + if ((boff == 0) && (xfr_cnt == secsize)) { bp = getblockOver(clus2phys(fnp->f_cluster, fnp->f_dpb) + - fnp->f_sector, fnp->f_dpb->dpb_unit); + sector, fnp->f_dpb->dpb_unit); } else { - bp = getblock(clus2phys(fnp->f_cluster, fnp->f_dpb) + fnp->f_sector, + bp = getblock(clus2phys(fnp->f_cluster, fnp->f_dpb) + sector, fnp->f_dpb->dpb_unit); } if (bp == NULL) @@ -1478,7 +1479,7 @@ STATIC COUNT dos_extend(f_node_ptr fnp) } /* set a block to zero */ - fmemset((BYTE FAR *) & bp->b_buffer[fnp->f_boff], 0, xfr_cnt); + fmemset((BYTE FAR *) & bp->b_buffer[boff], 0, xfr_cnt); bp->b_flag |= BFR_DIRTY | BFR_VALID; if (xfr_cnt == sizeof(bp->b_buffer)) /* probably not used later */ @@ -1635,6 +1636,8 @@ long rwblock(COUNT fd, VOID FAR * buffer, UCOUNT count, int mode) /* can utilize memory management in future DOS-C versions. */ while (ret_cnt < count) { + unsigned sector, boff; + /* Do an EOF test and return whatever was transferred */ /* but only for regular files. */ if (mode == XFR_READ && !(fnp->f_flags.f_ddir) && (fnp->f_offset >= fnp->f_dir.dir_size)) @@ -1651,7 +1654,7 @@ long rwblock(COUNT fd, VOID FAR * buffer, UCOUNT count, int mode) /* file offset case. Here, we need to take the fnode's */ /* offset pointer (f_offset) and translate it into a */ /* relative cluster position, cluster block (sector) */ - /* offset (f_sector) and byte offset (f_boff). Once we */ + /* offset (sector) and byte offset (boff). Once we */ /* have this information, we need to translate the */ /* relative cluster position into an absolute cluster */ /* position (f_cluster). This is unfortunate because it */ @@ -1678,15 +1681,15 @@ long rwblock(COUNT fd, VOID FAR * buffer, UCOUNT count, int mode) /* Compute the block within the cluster and the offset */ /* within the block. */ - fnp->f_sector = (UBYTE)(fnp->f_offset / secsize) & fnp->f_dpb->dpb_clsmask; - fnp->f_boff = (UWORD)(fnp->f_offset % secsize); + sector = (UBYTE)(fnp->f_offset / secsize) & fnp->f_dpb->dpb_clsmask; + boff = (UWORD)(fnp->f_offset % secsize); - currentblock = clus2phys(fnp->f_cluster, fnp->f_dpb) + fnp->f_sector; + currentblock = clus2phys(fnp->f_cluster, fnp->f_dpb) + sector; /* see comments above */ if (!fnp->f_flags.f_ddir && /* don't experiment with directories yet */ - fnp->f_boff == 0) /* complete sectors only */ + boff == 0) /* complete sectors only */ { static ULONG startoffset; UCOUNT sectors_to_xfer, sectors_wanted; @@ -1703,7 +1706,7 @@ long rwblock(COUNT fd, VOID FAR * buffer, UCOUNT count, int mode) if (sectors_wanted == 0) goto normal_xfer; - sectors_to_xfer = fnp->f_dpb->dpb_clsmask + 1 - fnp->f_sector; + sectors_to_xfer = fnp->f_dpb->dpb_clsmask + 1 - sector; sectors_to_xfer = min(sectors_to_xfer, sectors_wanted); @@ -1772,7 +1775,7 @@ long rwblock(COUNT fd, VOID FAR * buffer, UCOUNT count, int mode) /* requested transfer size, whichever is smaller. */ /* Then compare to what is left, since we can transfer */ /* a maximum of what is left. */ - xfr_cnt = min(to_xfer, secsize - fnp->f_boff); + xfr_cnt = min(to_xfer, secsize - boff); if (!fnp->f_flags.f_ddir && mode == XFR_READ) xfr_cnt = (UWORD) min(xfr_cnt, fnp->f_dir.dir_size - fnp->f_offset); @@ -1783,12 +1786,12 @@ long rwblock(COUNT fd, VOID FAR * buffer, UCOUNT count, int mode) /* a maximum of what is left. */ if (mode == XFR_WRITE) { - fmemcpy(&bp->b_buffer[fnp->f_boff], buffer, xfr_cnt); + fmemcpy(&bp->b_buffer[boff], buffer, xfr_cnt); bp->b_flag |= BFR_DIRTY | BFR_VALID; } else { - fmemcpy(buffer, &bp->b_buffer[fnp->f_boff], xfr_cnt); + fmemcpy(buffer, &bp->b_buffer[boff], xfr_cnt); } /* complete buffer transferred ? From 7e91d9cf9d8345698094bf7f9728c89250b5824c Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Mon, 22 Mar 2004 17:50:53 +0000 Subject: [PATCH 395/671] Revert accidental "changeline for hard disks" change. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@815 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/dsk.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/kernel/dsk.c b/kernel/dsk.c index 977e6719..4e57b7fc 100644 --- a/kernel/dsk.c +++ b/kernel/dsk.c @@ -237,7 +237,8 @@ STATIC WORD diskchange(ddt * pddt) { COUNT result; - if (hd(pddt->ddt_descflags) && !(pddt->ddt_descflags & DF_CHANGELINE)) + /* if it's a hard drive, media never changes */ + if (hd(pddt->ddt_descflags)) return M_NOT_CHANGED; if (play_dj(pddt) == M_CHANGED) From ce290a033f174a6363fe5e990550b1f856dc035f Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Mon, 22 Mar 2004 22:33:05 +0000 Subject: [PATCH 396/671] Eliminate f_back field. extend() now uses f_cluster instead of f_back, while map_cluster makes sure it's not set to LONG_LAST_CLUSTER (but to the cluster before it) when calling extend(). extend() and first_fat() now return the new cluster number or LONG_LAST_CLUSTER, just like find_fat_free() Hopefully I didn't break anything... Initial testing was successful. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@816 6ac86273-5f31-0410-b378-82cca8765d1b --- hdr/fnode.h | 1 - kernel/fatdir.c | 1 - kernel/fatfs.c | 83 +++++++++++++++++++++++++------------------------ 3 files changed, 42 insertions(+), 43 deletions(-) diff --git a/hdr/fnode.h b/hdr/fnode.h index f1551189..36be8576 100644 --- a/hdr/fnode.h +++ b/hdr/fnode.h @@ -55,7 +55,6 @@ struct f_node { struct dpb FAR *f_dpb; /* the block device for file */ ULONG f_offset; /* byte offset for next op */ - CLUSTER f_back; /* the cluster we were at */ CLUSTER f_cluster_offset; /* relative cluster number within file */ CLUSTER f_cluster; /* the cluster we are at */ }; diff --git a/kernel/fatdir.c b/kernel/fatdir.c index 71b9def9..7a741b66 100644 --- a/kernel/fatdir.c +++ b/kernel/fatdir.c @@ -332,7 +332,6 @@ BOOL dir_write(REG f_node_ptr fnp) /* Do a "seek" to the directory position */ /* and convert the fnode to a directory fnode. */ fnp->f_offset = fnp->f_diroff * (ULONG)DIRENT_SIZE; - fnp->f_back = LONG_LAST_CLUSTER; fnp->f_cluster = fnp->f_dirstart; fnp->f_cluster_offset = 0; diff --git a/kernel/fatfs.c b/kernel/fatfs.c index b37dbb6e..26700069 100644 --- a/kernel/fatfs.c +++ b/kernel/fatfs.c @@ -50,10 +50,9 @@ STATIC void copy_file_changes(f_node_ptr src, f_node_ptr dst); BOOL find_free(f_node_ptr); CLUSTER find_fat_free(f_node_ptr); VOID wipe_out(f_node_ptr); -BOOL last_link(f_node_ptr); -BOOL extend(f_node_ptr); +CLUSTER extend(f_node_ptr); COUNT extend_dir(f_node_ptr); -BOOL first_fat(f_node_ptr); +CLUSTER first_fat(f_node_ptr); COUNT map_cluster(f_node_ptr, COUNT); STATIC VOID shrink_file(f_node_ptr fnp); @@ -261,8 +260,7 @@ long dos_open(char *path, unsigned flags, unsigned attrib) /* Now change to file */ fnp->f_offset = 0l; - - fnp->f_back = LONG_LAST_CLUSTER; + if (status != S_OPENED) { fnp->f_cluster = FREE; @@ -1141,7 +1139,6 @@ COUNT dos_mkdir(BYTE * dir) /* Set the fnode to the desired mode */ fnp->f_mode = WRONLY; - fnp->f_back = LONG_LAST_CLUSTER; init_direntry(&fnp->f_dir, D_DIR, free_fat); @@ -1152,7 +1149,6 @@ COUNT dos_mkdir(BYTE * dir) fnp->f_offset = 0l; /* Mark the cluster in the FAT as used */ - fnp->f_cluster = free_fat; dpbp = fnp->f_dpb; link_fat(dpbp, free_fat, LONG_LAST_CLUSTER); @@ -1227,12 +1223,7 @@ COUNT dos_mkdir(BYTE * dir) return SUCCESS; } -BOOL last_link(f_node_ptr fnp) -{ - return (fnp->f_cluster == LONG_LAST_CLUSTER); -} - -STATIC BOOL extend(f_node_ptr fnp) +STATIC CLUSTER extend(f_node_ptr fnp) { CLUSTER free_fat; @@ -1245,24 +1236,24 @@ STATIC BOOL extend(f_node_ptr fnp) /* No empty clusters, disk is FULL! Translate into a useful */ /* error message. */ if (free_fat == LONG_LAST_CLUSTER) - return FALSE; + return free_fat; /* Now that we've found a free FAT entry, mark it as the last */ /* entry and save. */ - link_fat(fnp->f_dpb, fnp->f_back, free_fat); - fnp->f_cluster = free_fat; + link_fat(fnp->f_dpb, fnp->f_cluster, free_fat); link_fat(fnp->f_dpb, free_fat, LONG_LAST_CLUSTER); /* Mark the directory so that the entry is updated */ fnp->f_flags.f_dmod = TRUE; - return TRUE; + return free_fat; } STATIC COUNT extend_dir(f_node_ptr fnp) { REG COUNT idx; - if (!extend(fnp)) + CLUSTER cluster = extend(fnp); + if (cluster == LONG_LAST_CLUSTER) { dir_close(fnp); return DE_HNDLDSKFULL; @@ -1274,7 +1265,7 @@ STATIC COUNT extend_dir(f_node_ptr fnp) REG struct buffer FAR *bp; /* as we are overwriting it completely, don't read first */ - bp = getblockOver(clus2phys(fnp->f_cluster, fnp->f_dpb) + idx, + bp = getblockOver(clus2phys(cluster, fnp->f_dpb) + idx, fnp->f_dpb->dpb_unit); #ifdef DISPLAY_GETBLOCK printf("DIR (extend_dir)\n"); @@ -1306,7 +1297,7 @@ STATIC COUNT extend_dir(f_node_ptr fnp) } /* JPP: finds the next free cluster in the FAT */ -STATIC BOOL first_fat(f_node_ptr fnp) +STATIC CLUSTER first_fat(f_node_ptr fnp) { CLUSTER free_fat; @@ -1316,19 +1307,18 @@ STATIC BOOL first_fat(f_node_ptr fnp) /* No empty clusters, disk is FULL! Translate into a useful */ /* error message. */ if (free_fat == LONG_LAST_CLUSTER) - return FALSE; + return free_fat; /* Now that we've found a free FAT entry, mark it as the last */ /* entry and save it. */ /* BUG!! this caused wrong allocation, if file was created, then seeked, then written */ - fnp->f_cluster = free_fat; setdstart(fnp->f_dpb, &fnp->f_dir, free_fat); link_fat(fnp->f_dpb, free_fat, LONG_LAST_CLUSTER); /* Mark the directory so that the entry is updated */ fnp->f_flags.f_dmod = TRUE; - return TRUE; + return free_fat; } /* Description. @@ -1352,8 +1342,7 @@ STATIC BOOL first_fat(f_node_ptr fnp) COUNT map_cluster(REG f_node_ptr fnp, COUNT mode) { - CLUSTER relcluster = (CLUSTER)((fnp->f_offset / fnp->f_dpb->dpb_secsize) >> - fnp->f_dpb->dpb_shftcnt); + CLUSTER relcluster, cluster; #ifdef DISPLAY_GETBLOCK printf("map_cluster: current %lu, offset %lu, diff=%lu ", @@ -1366,12 +1355,21 @@ COUNT map_cluster(REG f_node_ptr fnp, COUNT mode) if ((mode == XFR_WRITE) && checkdstart(fnp->f_dpb, &fnp->f_dir, FREE)) { /* If there are no more free fat entries, then we are full! */ - if (!first_fat(fnp)) + cluster = first_fat(fnp); + if (cluster == LONG_LAST_CLUSTER) { return DE_HNDLDSKFULL; } + fnp->f_cluster = cluster; } + /* If this is a read but the file still has zero bytes return */ + /* immediately.... */ + if ((mode == XFR_READ) && (fnp->f_cluster == FREE)) + return DE_SEEK; + + relcluster = (CLUSTER)((fnp->f_offset / fnp->f_dpb->dpb_secsize) >> + fnp->f_dpb->dpb_shftcnt); if (relcluster < fnp->f_cluster_offset) { /* Set internal index and cluster size. */ @@ -1387,27 +1385,30 @@ COUNT map_cluster(REG f_node_ptr fnp, COUNT mode) /* up to the relative cluster position where the index falls */ /* within the cluster. */ - FOREVER + while (fnp->f_cluster_offset != relcluster) { - /* If this is a read and the next is a LAST_CLUSTER, */ - /* then we are going to read past EOF, return zero read */ - if ((mode == XFR_READ) && (last_link(fnp) || fnp->f_cluster == FREE)) + /* get next cluster in the chain */ + cluster = next_cluster(fnp->f_dpb, fnp->f_cluster); + if (cluster == 1) return DE_SEEK; - /* expand the list if we're going to write and have run into */ - /* the last cluster marker. */ - if ((mode == XFR_WRITE) && last_link(fnp) && !extend(fnp)) - return DE_HNDLDSKFULL; - if (fnp->f_cluster_offset == relcluster) - break; + /* If this is a read and the next is a LAST_CLUSTER, */ + /* then we are going to read past EOF, return zero read */ + /* or expand the list if we're going to write and have run into */ + /* the last cluster marker. */ + if (cluster == LONG_LAST_CLUSTER) + { + if (mode == XFR_READ) + return DE_SEEK; - fnp->f_back = fnp->f_cluster; + /* mode == XFR_WRITE */ + cluster = extend(fnp); + if (cluster == LONG_LAST_CLUSTER) + return DE_HNDLDSKFULL; + } - /* get next cluster in the chain */ - fnp->f_cluster = next_cluster(fnp->f_dpb, fnp->f_cluster); + fnp->f_cluster = cluster; fnp->f_cluster_offset++; - if (fnp->f_cluster == 1) - return DE_SEEK; } #ifdef DISPLAY_GETBLOCK From 05cd65a193b4e90ee1a5c51277b45c0eba957a59 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Tue, 23 Mar 2004 00:45:24 +0000 Subject: [PATCH 397/671] Merge find_fat_free() and extend() -- they were almost identical. Have a simplified clause for f_cluster == FREE. Set f_cluster = FREE in shrink_file if the file is set to 0 bytes; in that case we should set the current cluster to FREE even if it is currently a LONG_LAST_CLUSTER. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@818 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/fatfs.c | 58 ++++++++++++++++---------------------------------- 1 file changed, 18 insertions(+), 40 deletions(-) diff --git a/kernel/fatfs.c b/kernel/fatfs.c index 26700069..cfda06d4 100644 --- a/kernel/fatfs.c +++ b/kernel/fatfs.c @@ -48,7 +48,6 @@ STATIC int is_same_file(f_node_ptr fnp1, f_node_ptr fnp2); /* /// Added - Ron Cemer */ STATIC void copy_file_changes(f_node_ptr src, f_node_ptr dst); BOOL find_free(f_node_ptr); -CLUSTER find_fat_free(f_node_ptr); VOID wipe_out(f_node_ptr); CLUSTER extend(f_node_ptr); COUNT extend_dir(f_node_ptr); @@ -1227,9 +1226,6 @@ STATIC CLUSTER extend(f_node_ptr fnp) { CLUSTER free_fat; -#ifdef DISPLAY_GETBLOCK - printf("extend\n"); -#endif /* get an empty cluster, so that we use it to extend the file. */ free_fat = find_fat_free(fnp); @@ -1240,7 +1236,10 @@ STATIC CLUSTER extend(f_node_ptr fnp) /* Now that we've found a free FAT entry, mark it as the last */ /* entry and save. */ - link_fat(fnp->f_dpb, fnp->f_cluster, free_fat); + if (fnp->f_cluster == FREE) + setdstart(fnp->f_dpb, &fnp->f_dir, free_fat); + else + link_fat(fnp->f_dpb, fnp->f_cluster, free_fat); link_fat(fnp->f_dpb, free_fat, LONG_LAST_CLUSTER); /* Mark the directory so that the entry is updated */ @@ -1296,31 +1295,6 @@ STATIC COUNT extend_dir(f_node_ptr fnp) } -/* JPP: finds the next free cluster in the FAT */ -STATIC CLUSTER first_fat(f_node_ptr fnp) -{ - CLUSTER free_fat; - - /* get an empty cluster, so that we make it into a file. */ - free_fat = find_fat_free(fnp); - - /* No empty clusters, disk is FULL! Translate into a useful */ - /* error message. */ - if (free_fat == LONG_LAST_CLUSTER) - return free_fat; - - /* Now that we've found a free FAT entry, mark it as the last */ - /* entry and save it. */ - /* BUG!! this caused wrong allocation, if file was created, - then seeked, then written */ - setdstart(fnp->f_dpb, &fnp->f_dir, free_fat); - link_fat(fnp->f_dpb, free_fat, LONG_LAST_CLUSTER); - - /* Mark the directory so that the entry is updated */ - fnp->f_flags.f_dmod = TRUE; - return free_fat; -} - /* Description. * Finds the cluster which contains byte at the fnp->f_offset offset and * stores its number to the fnp->f_cluster. The search begins from the start of @@ -1350,12 +1324,18 @@ COUNT map_cluster(REG f_node_ptr fnp, COUNT mode) fnp->f_offset - fnp->f_cluster_offset); #endif - /* If someone did a seek, but no writes have occured, we will */ - /* need to initialize the fnode. */ - if ((mode == XFR_WRITE) && checkdstart(fnp->f_dpb, &fnp->f_dir, FREE)) + if (fnp->f_cluster == FREE) { + /* If this is a read but the file still has zero bytes return */ + /* immediately.... */ + if (mode == XFR_READ) + return DE_SEEK; + + /* If someone did a seek, but no writes have occured, we will */ + /* need to initialize the fnode. */ + /* (mode == XFR_WRITE) */ /* If there are no more free fat entries, then we are full! */ - cluster = first_fat(fnp); + cluster = extend(fnp); if (cluster == LONG_LAST_CLUSTER) { return DE_HNDLDSKFULL; @@ -1363,11 +1343,6 @@ COUNT map_cluster(REG f_node_ptr fnp, COUNT mode) fnp->f_cluster = cluster; } - /* If this is a read but the file still has zero bytes return */ - /* immediately.... */ - if ((mode == XFR_READ) && (fnp->f_cluster == FREE)) - return DE_SEEK; - relcluster = (CLUSTER)((fnp->f_offset / fnp->f_dpb->dpb_secsize) >> fnp->f_dpb->dpb_shftcnt); if (relcluster < fnp->f_cluster_offset) @@ -2212,7 +2187,7 @@ STATIC VOID shrink_file(f_node_ptr fnp) next = next_cluster(dpbp, st); - if (next == 1 || next == LONG_LAST_CLUSTER) /* error last cluster found */ + if (next == 1) /* error */ goto done; /* Loop from start until either a FREE entry is */ @@ -2222,11 +2197,14 @@ STATIC VOID shrink_file(f_node_ptr fnp) if (fnp->f_dir.dir_size == 0) { + fnp->f_cluster = FREE; setdstart(dpbp, &fnp->f_dir, FREE); link_fat(dpbp, st, FREE); } else { + if (next == LONG_LAST_CLUSTER) /* nothing to do */ + goto done; link_fat(dpbp, st, LONG_LAST_CLUSTER); } From d39d3a84f40eeb2895d70413f2a0184bc67baddb Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Tue, 23 Mar 2004 01:36:16 +0000 Subject: [PATCH 398/671] Merge three almost identical pieces of code used to allocate a new directory entry in creat, rename, and mkdir, into alloc_find_free. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@819 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/fatfs.c | 119 +++++++++++++++++++------------------------------ 1 file changed, 45 insertions(+), 74 deletions(-) diff --git a/kernel/fatfs.c b/kernel/fatfs.c index cfda06d4..b3f92262 100644 --- a/kernel/fatfs.c +++ b/kernel/fatfs.c @@ -48,6 +48,7 @@ STATIC int is_same_file(f_node_ptr fnp1, f_node_ptr fnp2); /* /// Added - Ron Cemer */ STATIC void copy_file_changes(f_node_ptr src, f_node_ptr dst); BOOL find_free(f_node_ptr); +STATIC int alloc_find_free(f_node_ptr fnp, char *path, char *fcbname); VOID wipe_out(f_node_ptr); CLUSTER extend(f_node_ptr); COUNT extend_dir(f_node_ptr); @@ -198,35 +199,10 @@ long dos_open(char *path, unsigned flags, unsigned attrib) } else if (flags & O_CREAT) { - BOOL is_free; + int ret = alloc_find_free(fnp, path, fcbname); + if (ret != SUCCESS) + return ret; - /* Reset the directory by a close followed by */ - /* an open */ - fnp->f_flags.f_dmod = FALSE; - dir_close(fnp); - fnp = split_path(path, fcbname); - - /* Get a free f_node pointer so that we can use */ - /* it in building the new file. */ - /* Note that if we're in the root and we don't */ - /* find an empty slot, we need to abort. */ - if (((is_free = find_free(fnp)) == 0) && (fnp->f_flags.f_droot)) - { - fnp->f_flags.f_dmod = FALSE; - dir_close(fnp); - return DE_TOOMANY; - } - - /* Otherwise just expand the directory */ - else if (!is_free && !(fnp->f_flags.f_droot)) - { - COUNT ret; - - if ((ret = extend_dir(fnp)) != SUCCESS) - /* fnp already closed in extend_dir */ - return ret; - } - /* put the fnode's name into the directory. */ memcpy(fnp->f_dir.dir_name, fcbname, FNAME_SIZE + FEXT_SIZE); status = S_CREATED; @@ -701,7 +677,6 @@ COUNT dos_rename(BYTE * path1, BYTE * path2, int attrib) { REG f_node_ptr fnp1; REG f_node_ptr fnp2; - BOOL is_free; COUNT ret; char fcbname[FNAME_SIZE + FEXT_SIZE]; @@ -736,29 +711,10 @@ COUNT dos_rename(BYTE * path1, BYTE * path2, int attrib) return DE_FILENOTFND; } - /* Reset the directory by a close followed by an open */ - fnp2->f_flags.f_dmod = FALSE; - dir_close(fnp2); - fnp2 = split_path(path2, fcbname); - - /* Now find a free slot to put the file into. */ - /* If it's the root and we don't have room, return an error. */ - if (((is_free = find_free(fnp2)) == 0) && (fnp2->f_flags.f_droot)) - { - fnp2->f_flags.f_dmod = FALSE; + ret = alloc_find_free(fnp2, path2, fcbname); + if (ret != SUCCESS) { dir_close(fnp1); - dir_close(fnp2); - return DE_TOOMANY; - } - - /* Otherwise just expand the directory */ - else if (!is_free && !(fnp2->f_flags.f_droot)) - { - if ((ret = extend_dir(fnp2)) != SUCCESS) - { - dir_close(fnp1); - return ret; - } + return ret; } if ((ret = remove_lfn_entries(fnp1)) < 0) @@ -858,6 +814,41 @@ STATIC BOOL find_free(f_node_ptr fnp) return rc >= 0; } +/* alloc_find_free: resets the directory by a close followed by */ +/* an open. Then finds a spare directory entry and if not */ +/* available, tries to extend the directory. */ +STATIC int alloc_find_free(f_node_ptr fnp, char *path, char *fcbname) +{ + fnp->f_flags.f_dmod = FALSE; + dir_close(fnp); + fnp = split_path(path, fcbname); + + /* Get a free f_node pointer so that we can use */ + /* it in building the new file. */ + /* Note that if we're in the root and we don't */ + /* find an empty slot, we need to abort. */ + if (find_free(fnp) == 0) + { + if (fnp->f_flags.f_droot) + { + fnp->f_flags.f_dmod = FALSE; + dir_close(fnp); + return DE_TOOMANY; + } + else + { + /* Otherwise just expand the directory */ + int ret; + + if ((ret = extend_dir(fnp)) != SUCCESS) + /* fnp already closed in extend_dir */ + return ret; + } + } + return SUCCESS; +} + + /* */ /* dos_getdate for the file date */ /* */ @@ -1093,31 +1084,11 @@ COUNT dos_mkdir(BYTE * dir) return DE_ACCESS; } - /* Reset the directory by a close followed by */ - /* an open */ - fnp->f_flags.f_dmod = FALSE; parent = fnp->f_dirstart; - dir_close(fnp); - fnp = split_path(dir, fcbname); - /* Get a free f_node pointer so that we can use */ - /* it in building the new file. */ - /* Note that if we're in the root and we don't */ - /* find an empty slot, we need to abort. */ - if (find_free(fnp) == 0) - { - if (fnp->f_flags.f_droot) - { - fnp->f_flags.f_dmod = FALSE; - dir_close(fnp); - return DE_TOOMANY; - } - - /* Otherwise just expand the directory */ - - if ((ret = extend_dir(fnp)) != SUCCESS) - return ret; - } + ret = alloc_find_free(fnp, dir, fcbname); + if (ret != SUCCESS) + return ret; /* get an empty cluster, so that we make it into a */ /* directory. */ From 13ab8971fddd698b41d73babe8c1da60b34ec45b Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Tue, 23 Mar 2004 22:03:20 +0000 Subject: [PATCH 399/671] Code size reduction and dead code removal from Lucho. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@820 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/inthndlr.c | 21 ++++----------------- 1 file changed, 4 insertions(+), 17 deletions(-) diff --git a/kernel/inthndlr.c b/kernel/inthndlr.c index b27c755f..f4233ed0 100644 --- a/kernel/inthndlr.c +++ b/kernel/inthndlr.c @@ -379,14 +379,9 @@ VOID ASMCFUNC int21_service(iregs FAR * r) ((psp FAR *) MK_FP(cu_psp, 0))->ps_stack = (BYTE FAR *) r; - lr.AX = r->AX; - lr.BX = r->BX; - lr.CX = r->CX; - lr.DX = r->DX; - lr.SI = r->SI; - lr.DI = r->DI; - lr.DS = r->DS; - lr.ES = r->ES; + fmemcpy(&lr, r, sizeof(lregs) - 4); + lr.DS = r->DS; + lr.ES = r->ES; dispatch: @@ -612,9 +607,6 @@ VOID ASMCFUNC int21_service(iregs FAR * r) p = FatGetDrvData(lr.DL, &lr.AX, &lr.CX, &lr.DX); lr.DS = FP_SEG(p); lr.BX = FP_OFF(p); - lr.CX = lr.CX; - lr.DX = lr.DX; - lr.AX = lr.AX; } break; @@ -1644,12 +1636,7 @@ VOID ASMCFUNC int21_service(iregs FAR * r) error_carry: SET_CARRY_FLAG(); exit_dispatch: - r->AX = lr.AX; - r->BX = lr.BX; - r->CX = lr.CX; - r->DX = lr.DX; - r->SI = lr.SI; - r->DI = lr.DI; + fmemcpy(r, &lr, sizeof(lregs) - 4); r->DS = lr.DS; r->ES = lr.ES; real_exit: From f63eea565a12756ce88ffb4da3daa1960ba7bc06 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Tue, 23 Mar 2004 22:45:38 +0000 Subject: [PATCH 400/671] Made the main fnodes far so they can be in UMBs. Internally the kernel uses two near fnodes though, to save on codesize and fmemcpy's if necessary. Having memory management on two fnodes is a little silly but I just want to make sure with the panic message that we never accidentally try to use three near fnodes at the same time. (two are used at the same time by rename, commit, and merge_file_changes). This can be cleaned up later. Anyway. 644736 bytes free conv memory isn't bad. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@821 6ac86273-5f31-0410-b378-82cca8765d1b --- hdr/lol.h | 6 +- kernel/config.c | 23 +++---- kernel/fatfs.c | 151 ++++++++++++++++++++++++++++++++++++---------- kernel/globals.h | 4 +- kernel/kernel.asm | 2 +- kernel/proto.h | 1 + 6 files changed, 135 insertions(+), 52 deletions(-) diff --git a/hdr/lol.h b/hdr/lol.h index 6da4ccbf..b0cb59e9 100644 --- a/hdr/lol.h +++ b/hdr/lol.h @@ -80,7 +80,7 @@ struct lol { unsigned char os_major; /* 6d major DOS version */ unsigned char rev_number; /* 6e minor DOS version */ unsigned char version_flags; /* 6f DOS version flags */ - f_node_ptr f_nodes; /* 70 pointer to the array */ - unsigned short f_nodes_cnt; /* 72 number of allocated f_nodes */ - char *os_release; /* 74 near pointer to os_release string */ + struct f_node FAR *f_nodes; /* 70 pointer to the array */ + unsigned short f_nodes_cnt; /* 74 number of allocated f_nodes */ + char *os_release; /* 76 near pointer to os_release string */ }; diff --git a/kernel/config.c b/kernel/config.c index 419d35c3..c02eda22 100644 --- a/kernel/config.c +++ b/kernel/config.c @@ -267,7 +267,7 @@ typedef void config_sys_func_t(BYTE * pLine); struct table { BYTE *entry; - BYTE pass; + signed char pass; config_sys_func_t *func; }; @@ -365,11 +365,8 @@ void PreConfig(void) DynAlloc("DPBp", blk_dev.dh_name[0], sizeof(struct dpb)); /* Initialize the file table */ -/* f_nodes = (f_node_ptr) - KernelAlloc(Config.cfgFiles * sizeof(struct f_node));*/ - - LoL->f_nodes = (f_node_ptr) - DynAlloc("f_nodes", Config.cfgFiles, sizeof(struct f_node)); + LoL->f_nodes = + KernelAlloc(Config.cfgFiles * sizeof(struct f_node), 'F', 0); LoL->f_nodes_cnt = Config.cfgFiles; LoL->sfthead = MK_FP(FP_SEG(LoL), 0xcc); /* &(LoL->firstsftt) */ @@ -384,7 +381,7 @@ void PreConfig(void) LoL->CDSp = KernelAlloc(sizeof(struct cds) * LoL->lastdrive, 'L', 0); #ifdef DEBUG - printf("Preliminary:\n f_node 0x%x", LoL->f_nodes); + printf("Preliminary:\n f_node 0x%p\n", LoL->f_nodes); /* printf(" FCB table 0x%p\n",LoL->FCBp);*/ printf(" sft table 0x%p\n", LoL->sfthead); printf(" CDS table 0x%p\n", LoL->CDSp); @@ -405,13 +402,6 @@ void PreConfig2(void) /* initialize NEAR allocated things */ - /* Initialize the file table */ - DynFree(LoL->f_nodes); - LoL->f_nodes = (f_node_ptr) - DynAlloc("f_nodes", Config.cfgFiles, sizeof(struct f_node)); - - LoL->f_nodes_cnt = Config.cfgFiles; /* and the number of allocated files */ - /* Initialize the base memory pointers from last time. */ /* if the kernel could be moved to HMA, everything behind the dynamic @@ -488,6 +478,11 @@ void PostConfig(void) sp->sftt_next = (sfttbl FAR *) - 1; sp->sftt_count = Config.cfgFiles - 8; + /* Initialize the file table */ + LoL->f_nodes = KernelAlloc(Config.cfgFiles * sizeof(struct f_node), 'F', + Config.cfgFilesHigh); + LoL->f_nodes_cnt = Config.cfgFiles; /* and the number of allocated files */ + LoL->CDSp = KernelAlloc(sizeof(struct cds) * LoL->lastdrive, 'L', Config.cfgLastdriveHigh); #ifdef DEBUG diff --git a/kernel/fatfs.c b/kernel/fatfs.c index b3f92262..ec2f719f 100644 --- a/kernel/fatfs.c +++ b/kernel/fatfs.c @@ -39,6 +39,7 @@ BYTE *RcsId = "$Id$"; /* */ f_node_ptr xlt_fd(COUNT); COUNT xlt_fnp(f_node_ptr); +STATIC f_node_ptr get_near_f_node(void); STATIC f_node_ptr split_path(char *, char *); BOOL find_fname(f_node_ptr, char *, int); /* /// Added - Ron Cemer */ @@ -253,6 +254,7 @@ long dos_open(char *path, unsigned flags, unsigned attrib) fnp->f_cluster = getdstart(fnp->f_dpb, &fnp->f_dir); fnp->f_cluster_offset = 0; + save_far_f_node(fnp); return xlt_fnp(fnp) | ((long)status << 16); } @@ -281,7 +283,7 @@ COUNT dos_close(COUNT fd) /* If the fd was invalid because it was out of range or the */ /* requested file was not open, tell the caller and exit */ /* note: an invalid fd is indicated by a 0 return */ - if (fnp == (f_node_ptr) 0 || fnp->f_count <= 0) + if (fnp == (f_node_ptr) 0) return DE_INVLDHNDL; if (fnp->f_flags.f_dmod) @@ -310,15 +312,19 @@ COUNT dos_commit(COUNT fd) /* If the fd was invalid because it was out of range or the */ /* requested file was not open, tell the caller and exit */ /* note: an invalid fd is indicated by a 0 return */ - if (fnp == (f_node_ptr) 0 || fnp->f_count <= 0) + if (fnp == (f_node_ptr) 0) return DE_INVLDHNDL; fnp2 = get_f_node(); if (fnp2 == (f_node_ptr) 0) + { + release_near_f_node(fnp); return DE_INVLDHNDL; + } /* a copy of the fnode is closed meaning that the directory info is updated etc, but we keep our old info */ memcpy(fnp2, fnp, sizeof(*fnp)); + release_near_f_node(fnp); return dos_close(xlt_fnp(fnp2)); } @@ -458,15 +464,18 @@ COUNT remove_lfn_entries(f_node_ptr fnp) STATIC void merge_file_changes(f_node_ptr fnp, int collect) { f_node_ptr fnp2; - int i; + int i, fd; if (!IsShareInstalled()) return; + + fd = xlt_fnp(fnp); + fnp2 = get_near_f_node(); for (i = 0; i < f_nodes_cnt; i++) { - fnp2 = (f_node_ptr) & f_nodes[i]; + fmemcpy(fnp2, &f_nodes[i], sizeof(*fnp2)); if ((fnp != (f_node_ptr) 0) - && (fnp != fnp2) + && (i != fd) && (fnp->f_count > 0) && (is_same_file(fnp, fnp2))) { if (collect) @@ -485,9 +494,11 @@ STATIC void merge_file_changes(f_node_ptr fnp, int collect) distributing these changes to the other f_nodes which refer to this file. */ copy_file_changes(fnp, fnp2); + fmemcpy(&f_nodes[i], fnp2, sizeof(*fnp2)); } } } + release_near_f_node(fnp2); } /* /// Added - Ron Cemer */ @@ -889,13 +900,14 @@ COUNT dos_getftime(COUNT fd, date FAR * dp, time FAR * tp) /* If the fd was invalid because it was out of range or the */ /* requested file was not open, tell the caller and exit */ /* note: an invalid fd is indicated by a 0 return */ - if (fnp == (f_node_ptr) 0 || fnp->f_count <= 0) + if (fnp == (f_node_ptr) 0) return DE_INVLDHNDL; /* Get the date and time from the fnode and return */ *dp = fnp->f_dir.dir_date; *tp = fnp->f_dir.dir_time; + release_near_f_node(fnp); return SUCCESS; } @@ -913,7 +925,7 @@ COUNT dos_setftime(COUNT fd, date dp, time tp) /* If the fd was invalid because it was out of range or the */ /* requested file was not open, tell the caller and exit */ /* note: an invalid fd is indicated by a 0 return */ - if (fnp == (f_node_ptr) 0 || fnp->f_count <= 0) + if (fnp == (f_node_ptr) 0) return DE_INVLDHNDL; /* Set the date and time from the fnode and return */ @@ -922,6 +934,7 @@ COUNT dos_setftime(COUNT fd, date dp, time tp) fnp->f_flags.f_dmod = TRUE; /* mark file as modified */ fnp->f_flags.f_ddate = TRUE; /* set this date upon closing */ + save_far_f_node(fnp); return SUCCESS; } @@ -939,10 +952,11 @@ ULONG dos_getfsize(COUNT fd) /* If the fd was invalid because it was out of range or the */ /* requested file was not open, tell the caller and exit */ /* note: an invalid fd is indicated by a 0 return */ - if (fnp == (f_node_ptr) 0 || fnp->f_count <= 0) + if (fnp == (f_node_ptr) 0) return (ULONG)-1l; /* Return the file size */ + release_near_f_node(fnp); return fnp->f_dir.dir_size; } @@ -960,13 +974,14 @@ BOOL dos_setfsize(COUNT fd, LONG size) /* If the fd was invalid because it was out of range or the */ /* requested file was not open, tell the caller and exit */ /* note: an invalid fd is indicated by a 0 return */ - if (fnp == (f_node_ptr) 0 || fnp->f_count <= 0) + if (fnp == (f_node_ptr) 0) return FALSE; /* Change the file size */ fnp->f_dir.dir_size = size; merge_file_changes(fnp, FALSE); /* /// Added - Ron Cemer */ + save_far_f_node(fnp); return TRUE; } @@ -1535,7 +1550,7 @@ long rwblock(COUNT fd, VOID FAR * buffer, UCOUNT count, int mode) /* If the fd was invalid because it was out of range or the */ /* requested file was not open, tell the caller and exit */ /* note: an invalid fd is indicated by a 0 return */ - if (fnp == (f_node_ptr) 0 || fnp->f_count <= 0) + if (fnp == (f_node_ptr) 0) { return 0; } @@ -1547,7 +1562,10 @@ long rwblock(COUNT fd, VOID FAR * buffer, UCOUNT count, int mode) fnp->f_flags.f_ddate = FALSE; /* set date not valid any more */ if (dos_extend(fnp) != SUCCESS) + { + save_far_f_node(fnp); return 0; + } } /* Test that we are really about to do a data transfer. If the */ @@ -1570,6 +1588,7 @@ long rwblock(COUNT fd, VOID FAR * buffer, UCOUNT count, int mode) fnp->f_dir.dir_size = fnp->f_offset; shrink_file(fnp); } + save_far_f_node(fnp); return 0; } @@ -1589,6 +1608,7 @@ long rwblock(COUNT fd, VOID FAR * buffer, UCOUNT count, int mode) /* but only for regular files. */ if (mode == XFR_READ && !(fnp->f_flags.f_ddir) && (fnp->f_offset >= fnp->f_dir.dir_size)) { + save_far_f_node(fnp); return ret_cnt; } @@ -1619,6 +1639,7 @@ long rwblock(COUNT fd, VOID FAR * buffer, UCOUNT count, int mode) #endif if (map_cluster(fnp, mode) != SUCCESS) { + save_far_f_node(fnp); return ret_cnt; } if (mode == XFR_WRITE) @@ -1690,6 +1711,7 @@ long rwblock(COUNT fd, VOID FAR * buffer, UCOUNT count, int mode) mode == XFR_READ ? DSKREAD : DSKWRITE)) { fnp->f_offset = startoffset; + save_far_f_node(fnp); return DE_ACCESS; } @@ -1714,6 +1736,7 @@ long rwblock(COUNT fd, VOID FAR * buffer, UCOUNT count, int mode) #endif if (bp == NULL) /* (struct buffer *)0 --> DS:0 !! */ { + save_far_f_node(fnp); return ret_cnt; } @@ -1766,6 +1789,7 @@ long rwblock(COUNT fd, VOID FAR * buffer, UCOUNT count, int mode) merge_file_changes(fnp, FALSE); /* /// Added - Ron Cemer */ } } + save_far_f_node(fnp); return ret_cnt; } @@ -1783,29 +1807,34 @@ LONG dos_lseek(COUNT fd, LONG foffset, COUNT origin) /* requested file was not open, tell the caller and exit */ /* note: an invalid fd is indicated by a 0 return */ - if (fnp == (f_node_ptr) 0 || fnp->f_count <= 0) + if (fnp == (f_node_ptr) 0) return (LONG) DE_INVLDHNDL; /* now do the actual lseek adjustment to the file poitner */ - switch (origin) { /* offset from beginning of file */ case 0: - return fnp->f_offset = (ULONG) foffset; + fnp->f_offset = (ULONG) foffset; + break; /* offset from current location */ case 1: - return fnp->f_offset += foffset; + fnp->f_offset += foffset; + break; /* offset from eof */ case 2: - return fnp->f_offset = fnp->f_dir.dir_size + foffset; + fnp->f_offset = fnp->f_dir.dir_size + foffset; + break; /* default to an invalid function */ default: + release_near_f_node(fnp); return (LONG) DE_INVLDFUNC; } + save_far_f_node(fnp); + return fnp->f_offset; } /* returns the number of unused clusters */ @@ -1867,18 +1896,46 @@ int dos_cd(char * PathName) } #endif +/* try to allocate a near f_node */ +/* (there are just two of them, in the SDA) */ + +f_node_ptr get_near_f_node(void) +{ + f_node_ptr fnp = fnode; + + if (fnp->f_count == 0) + fnp->f_count++; + else + { + fnp++; + if (fnp->f_count == 0) + fnp->f_count++; + else + { + fnp = (f_node_ptr) 0; + panic("more than two near fnodes requested at the same time!\n"); + } + } + return fnp; +} + /* Try to allocate an f_node from the available files array */ f_node_ptr get_f_node(void) { REG int i; + f_node_ptr fnp = get_near_f_node(); - for (i = 0; i < f_nodes_cnt; i++) + if (fnp != (f_node_ptr)0) { - if (f_nodes[i].f_count == 0) + for (i = 0; i < f_nodes_cnt; i++) { - ++f_nodes[i].f_count; - return &f_nodes[i]; + if (f_nodes[i].f_count == 0) + { + ++f_nodes[i].f_count; + fnode_fd[fnp - fnode] = i; + return fnp; + } } } return (f_node_ptr) 0; @@ -1886,10 +1943,13 @@ f_node_ptr get_f_node(void) VOID release_f_node(f_node_ptr fnp) { - if (fnp->f_count > 0) - --fnp->f_count; + struct f_node FAR *fp = &f_nodes[xlt_fnp(fnp)]; + + if (fp->f_count > 0) + --fp->f_count; else - fnp->f_count = 0; + fp->f_count = 0; + release_near_f_node(fnp); } #ifndef IPL @@ -1902,15 +1962,13 @@ COUNT dos_getfattr_fd(COUNT fd) { f_node_ptr fnp = xlt_fd(fd); + /* If the fd was invalid because it was out of range or the */ + /* requested file was not open, tell the caller and exit */ /* note: an invalid fd is indicated by a 0 return */ if (fnp == (f_node_ptr) 0) return DE_TOOMANY; - /* If the fd was invalid because it was out of range or the */ - /* requested file was not open, tell the caller and exit */ - if (fnp->f_count <= 0) - return DE_FILENOTFND; - + release_near_f_node(fnp); return fnp->f_dir.dir_attrib; } @@ -1950,6 +2008,7 @@ COUNT dos_setfattr(BYTE * name, UWORD attrp) fnp->f_dir.dir_attrib |= attrp; /* JPP */ fnp->f_flags.f_dmod = TRUE; fnp->f_flags.f_ddate = TRUE; + save_far_f_node(fnp); dos_close(fd); return SUCCESS; } @@ -2112,16 +2171,42 @@ COUNT media_check(REG struct dpb FAR * dpbp) } } -/* translate the fd into an f_node pointer */ -f_node_ptr xlt_fd(COUNT fd) +/* translate the f_node pointer into an fd */ +COUNT xlt_fnp(f_node_ptr fnp) { - return fd >= f_nodes_cnt ? (f_node_ptr) 0 : &f_nodes[fd]; + return fnode_fd[fnp - fnode]; } -/* translate the f_node pointer into an fd */ -COUNT xlt_fnp(f_node_ptr fnp) +/* allocate a near fnode and copy the far fd fnode to it */ +f_node_ptr xlt_fd(int fd) +{ + f_node_ptr fnp = (f_node_ptr) 0; + + /* If the fd was invalid because it was out of range or the */ + /* requested file was not open, tell the caller and exit */ + /* note: an invalid fd is indicated by a 0 return */ + if (fd < f_nodes_cnt) + { + fnp = get_near_f_node(); + if (fnp != (f_node_ptr)0) + { + fmemcpy(fnp, &f_nodes[fd], sizeof(*fnp)); + if (fnp->f_count <= 0) + { + release_near_f_node(fnp); + fnp = (f_node_ptr) 0; + } else + fnode_fd[fnp - fnode] = fd; + } + } + return fnp; +} + +/* copy a near fnode to the corresponding far one and release it */ +void save_far_f_node(f_node_ptr fnp) { - return (COUNT) (fnp - f_nodes); + fmemcpy(&f_nodes[xlt_fnp(fnp)], fnp, sizeof(*fnp)); + release_near_f_node(fnp); } /* TE diff --git a/kernel/globals.h b/kernel/globals.h index 669fce36..2c66a227 100644 --- a/kernel/globals.h +++ b/kernel/globals.h @@ -349,7 +349,7 @@ GLOBAL WORD dump_regs; /* dump registers of bad call */ #endif -extern f_node_ptr ASM f_nodes; /* pointer to the array */ +extern struct f_node FAR * ASM f_nodes; /* pointer to the array */ extern UWORD ASM f_nodes_cnt; /* number of allocated f_nodes */ /* */ @@ -436,3 +436,5 @@ void ASMCFUNC spawn_int23(void); /* procsupt.asm */ GLOBAL BYTE ReturnAnyDosVersionExpected; +GLOBAL struct f_node fnode[2]; +GLOBAL int fnode_fd[2]; diff --git a/kernel/kernel.asm b/kernel/kernel.asm index 265b1185..acad9be5 100644 --- a/kernel/kernel.asm +++ b/kernel/kernel.asm @@ -348,7 +348,7 @@ _rev_number db 0 global _version_flags _version_flags db 0 global _f_nodes -_f_nodes dw 0 +_f_nodes dd 0 global _f_nodes_cnt _f_nodes_cnt dw 0 global os_release diff --git a/kernel/proto.h b/kernel/proto.h index 3471a11a..8ddd62e8 100644 --- a/kernel/proto.h +++ b/kernel/proto.h @@ -177,6 +177,7 @@ int dos_cd(char * PathName); f_node_ptr get_f_node(void); VOID release_f_node(f_node_ptr fnp); +#define release_near_f_node(fnp) ((fnp)->f_count = 0) VOID dos_setdta(BYTE FAR * newdta); COUNT dos_getfattr_fd(COUNT fd); COUNT dos_getfattr(BYTE * name); From d17f33324366370b8b6d9d33e65c7cfa232049af Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Thu, 25 Mar 2004 00:20:20 +0000 Subject: [PATCH 401/671] From Lucho (and I think Arkady had this as well at some point): save 33 bytes by eliminating a switch for memory/UMB access modes. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@822 6ac86273-5f31-0410-b378-82cca8765d1b --- hdr/mcb.h | 2 ++ kernel/inthndlr.c | 23 ++++------------------- 2 files changed, 6 insertions(+), 19 deletions(-) diff --git a/hdr/mcb.h b/hdr/mcb.h index 0531b4c2..6ff077c2 100644 --- a/hdr/mcb.h +++ b/hdr/mcb.h @@ -45,6 +45,8 @@ static BYTE *mcb_hRcsId = #define FIRST_FIT_U 0x80 #define BEST_FIT_U 0x81 #define LAST_FIT_U 0x82 +#define FIT_U_MASK 0xc0 +#define FIT_MASK 0x3f #define MCB_NORMAL 0x4d #define MCB_LAST 0x5a diff --git a/kernel/inthndlr.c b/kernel/inthndlr.c index f4233ed0..0a7f8152 100644 --- a/kernel/inthndlr.c +++ b/kernel/inthndlr.c @@ -1210,25 +1210,10 @@ VOID ASMCFUNC int21_service(iregs FAR * r) break; case 0x01: - { - switch (lr.BL) - { - case LAST_FIT: - case LAST_FIT_U: - case LAST_FIT_UO: - case BEST_FIT: - case BEST_FIT_U: - case BEST_FIT_UO: - case FIRST_FIT: - case FIRST_FIT_U: - case FIRST_FIT_UO: - mem_access_mode = lr.BL; - break; - - default: - goto error_invalid; - } - } + if ((lr.BL & FIT_U_MASK) > FIRST_FIT_U || /* 0xc0, 0x80 */ + (lr.BL & FIT_MASK) > LAST_FIT) /* 0x3f, 0x02 */ + goto error_invalid; + mem_access_mode = lr.BL; break; case 0x02: From 416e1014cf573f1d5a2d2c16e21b0e462339ad23 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Thu, 25 Mar 2004 00:42:27 +0000 Subject: [PATCH 402/671] Declare save_far_fnode before use. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@823 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/fatfs.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/kernel/fatfs.c b/kernel/fatfs.c index ec2f719f..8901584b 100644 --- a/kernel/fatfs.c +++ b/kernel/fatfs.c @@ -39,6 +39,7 @@ BYTE *RcsId = "$Id$"; /* */ f_node_ptr xlt_fd(COUNT); COUNT xlt_fnp(f_node_ptr); +STATIC void save_far_f_node(f_node_ptr fnp); STATIC f_node_ptr get_near_f_node(void); STATIC f_node_ptr split_path(char *, char *); BOOL find_fname(f_node_ptr, char *, int); @@ -2203,7 +2204,7 @@ f_node_ptr xlt_fd(int fd) } /* copy a near fnode to the corresponding far one and release it */ -void save_far_f_node(f_node_ptr fnp) +STATIC void save_far_f_node(f_node_ptr fnp) { fmemcpy(&f_nodes[xlt_fnp(fnp)], fnp, sizeof(*fnp)); release_near_f_node(fnp); From 9c14e2f86db3e19b3cea8eb59f4e0e952b1faca2 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Fri, 26 Mar 2004 11:26:55 +0000 Subject: [PATCH 403/671] Misc small cleanups. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@824 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/config.c | 60 ++++++++----------------------------------------- 1 file changed, 9 insertions(+), 51 deletions(-) diff --git a/kernel/config.c b/kernel/config.c index c02eda22..19896d9c 100644 --- a/kernel/config.c +++ b/kernel/config.c @@ -1526,9 +1526,14 @@ STATIC void FAR * AlignParagraph(VOID FAR * lpPtr) } #endif +STATIC int iswh(unsigned char c) +{ + return (c == '\r' || c == '\n' || c == '\t' || c == ' '); +} + STATIC BYTE * skipwh(BYTE * s) { - while (*s && (*s == 0x0d || *s == 0x0a || *s == ' ' || *s == '\t')) + while (iswh(*s)) ++s; return s; } @@ -1572,33 +1577,18 @@ STATIC BYTE * scan(BYTE * s, BYTE * d) *d++ = *s++; } else - while (*s && - !(*s == 0x0d - || *s == 0x0a || *s == ' ' || *s == '\t' || *s == '=')) + while (*s && !iswh(*s) && *s != '=') { if (*s == '?') - { askThisSingleCommand = TRUE; - s++; - } else - *d++ = *s++; + *d++ = *s; + s++; } *d = '\0'; return s; } -#if 0 -BYTE *scan_seperator(BYTE * s, BYTE * d) -{ - s = skipwh(s); - if (*s) - *d++ = *s++; - *d = '\0'; - return s; -} -#endif - STATIC BOOL isnum(char ch) { return (ch >= '0' && ch <= '9'); @@ -1643,17 +1633,6 @@ STATIC char * GetNumber(REG const char *p, int *num) return (char *)p; } -/* Yet another change for true portability (WDL) */ -#if 0 -STATIC COUNT tolower(COUNT c) -{ - if (c >= 'A' && c <= 'Z') - return (c + ('a' - 'A')); - else - return c; -} -#endif - /* Yet another change for true portability (PJV) */ STATIC COUNT toupper(COUNT c) { @@ -1706,27 +1685,6 @@ char *strcat(register char * d, register const char * s) return d; } -#if 0 -/* see if the second string is contained in the first one, ignoring case */ -STATIC char * stristr(char *s1, char *s2) -{ - int loop; - - for (; *s1; s1++) - for (loop = 0;; loop++) - { - if (s2[loop] == 0) /* found end of string 2 -> success */ - { - return s1; /* position where s2 was found */ - } - if (toupper(s1[loop]) != toupper(s2[loop])) - break; - } - - return NULL; -} -#endif - /* compare two ASCII strings ignoring case */ STATIC COUNT strcasecmp(REG BYTE * d, REG BYTE * s) { From 9db450a9b74372e45b0b26bf2a4264d225d97433 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Fri, 26 Mar 2004 21:50:12 +0000 Subject: [PATCH 404/671] Remove lpOldTop variable. It is no longer necessary (has not been for some time) and the assignment in config_init_buffers() was wrong (screwed up fnodes, so that buffers overlapped fnodes...). This should fix most of the reported fnode problems. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@825 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/config.c | 3 --- kernel/init-mod.h | 1 - kernel/main.c | 2 +- 3 files changed, 1 insertion(+), 5 deletions(-) diff --git a/kernel/config.c b/kernel/config.c index 19896d9c..69bcb220 100644 --- a/kernel/config.c +++ b/kernel/config.c @@ -172,7 +172,6 @@ struct config Config = { STATIC seg base_seg = 0; STATIC seg umb_base_seg = 0; BYTE FAR *lpTop = 0; -BYTE FAR *lpOldTop = 0; STATIC unsigned nCfgLine = 0; STATIC COUNT nPass = 0; COUNT UmbState = 0; @@ -1729,8 +1728,6 @@ VOID config_init_buffers(COUNT anzBuffers) anzBuffers = 99; } LoL->nbuffers = anzBuffers; - - lpTop = lpOldTop; LoL->inforecptr = &LoL->firstbuf; diff --git a/kernel/init-mod.h b/kernel/init-mod.h index 2b781ddb..92432407 100644 --- a/kernel/init-mod.h +++ b/kernel/init-mod.h @@ -175,7 +175,6 @@ extern UWORD HMAFree; /* first byte in HMA not yet used */ extern unsigned CurrentKernelSegment; extern struct _KernelConfig FAR ASM LowKernelConfig; extern WORD days[2][13]; -extern BYTE FAR *lpOldTop; extern BYTE FAR *lpTop; extern BYTE ASM _ib_start[], ASM _ib_end[], ASM _init_end[]; extern UWORD ram_top; /* How much ram in Kbytes */ diff --git a/kernel/main.c b/kernel/main.c index f2ee7380..be75f833 100644 --- a/kernel/main.c +++ b/kernel/main.c @@ -229,7 +229,7 @@ STATIC void init_kernel(void) (FP_OFF(_HMATextEnd) + 15) / 16, 0); MoveKernel(FP_SEG(lpTop)); - lpOldTop = lpTop = MK_FP(FP_SEG(lpTop) - 0xfff, 0xfff0); + lpTop = MK_FP(FP_SEG(lpTop) - 0xfff, 0xfff0); for (i = 0x20; i <= 0x3f; i++) setvec(i, empty_handler); From ba0b0702226ee08e8aad07ce4b02e98267241c47 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Fri, 26 Mar 2004 23:10:13 +0000 Subject: [PATCH 405/671] Allocate fnodes in the HMA instead of in an UMB git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@826 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/config.c | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/kernel/config.c b/kernel/config.c index 69bcb220..80ea6166 100644 --- a/kernel/config.c +++ b/kernel/config.c @@ -364,10 +364,8 @@ void PreConfig(void) DynAlloc("DPBp", blk_dev.dh_name[0], sizeof(struct dpb)); /* Initialize the file table */ - LoL->f_nodes = - KernelAlloc(Config.cfgFiles * sizeof(struct f_node), 'F', 0); + config_init_fnodes(Config.cfgFiles); - LoL->f_nodes_cnt = Config.cfgFiles; LoL->sfthead = MK_FP(FP_SEG(LoL), 0xcc); /* &(LoL->firstsftt) */ /* LoL->FCBp = (sfttbl FAR *)&FcbSft; */ /* LoL->FCBp = (sfttbl FAR *) @@ -376,7 +374,6 @@ void PreConfig(void) config_init_buffers(Config.cfgBuffers); - LoL->CDSp = KernelAlloc(sizeof(struct cds) * LoL->lastdrive, 'L', 0); #ifdef DEBUG @@ -458,6 +455,9 @@ void PostConfig(void) DebugPrintf(("starting FAR allocations at %x\n", base_seg)); + /* Initialize the file table */ + config_init_fnodes(Config.cfgFiles); + /* Begin by initializing our system buffers */ /* dma_scratch = (BYTE FAR *) KernelAllocDma(BUFFERSIZE); */ #ifdef DEBUG @@ -477,15 +477,10 @@ void PostConfig(void) sp->sftt_next = (sfttbl FAR *) - 1; sp->sftt_count = Config.cfgFiles - 8; - /* Initialize the file table */ - LoL->f_nodes = KernelAlloc(Config.cfgFiles * sizeof(struct f_node), 'F', - Config.cfgFilesHigh); - LoL->f_nodes_cnt = Config.cfgFiles; /* and the number of allocated files */ - LoL->CDSp = KernelAlloc(sizeof(struct cds) * LoL->lastdrive, 'L', Config.cfgLastdriveHigh); #ifdef DEBUG - printf("Final: \n f_node 0x%x\n", LoL->f_nodes); + printf("Final: \n f_node 0x%p\n", LoL->f_nodes); /* printf(" FCB table 0x%p\n",LoL->FCBp);*/ printf(" sft table 0x%p\n", LoL->sfthead->sftt_next); printf(" CDS table 0x%p\n", LoL->CDSp); @@ -1777,6 +1772,21 @@ VOID config_init_buffers(COUNT anzBuffers) anzBuffers, anzBuffers * sizeof(struct buffer)); } +VOID config_init_fnodes(int f_nodes_cnt) +{ + struct f_node FAR *p; + size_t bytes; + + /* number of allocated files */ + LoL->f_nodes_cnt = f_nodes_cnt; + bytes = f_nodes_cnt * sizeof(struct f_node); + + p = HMAalloc(bytes); + if (p == NULL) + p = KernelAlloc(bytes, 'F', 0); + LoL->f_nodes = p; +} + /* Undocumented feature: From 46b58be248d9b46dda25f481fa96b76ebcca9fba Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Fri, 26 Mar 2004 23:15:23 +0000 Subject: [PATCH 406/671] Change default STACKS= size to 256. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@827 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/config.c | 2 +- kernel/init-mod.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/kernel/config.c b/kernel/config.c index 80ea6166..8f9ae42a 100644 --- a/kernel/config.c +++ b/kernel/config.c @@ -154,7 +154,7 @@ struct config Config = { 0, NSTACKS, 0, - 128 + STACKSIZE /* COUNTRY= is initialized within DoConfig() */ , 0 /* country ID */ , 0 /* codepage */ diff --git a/kernel/init-mod.h b/kernel/init-mod.h index 92432407..061c3720 100644 --- a/kernel/init-mod.h +++ b/kernel/init-mod.h @@ -74,6 +74,7 @@ void MoveKernel(unsigned NewKernelSegment); #define NFILES 16 /* number of files in table */ #define NFCBS 16 /* number of fcbs */ #define NSTACKS 8 /* number of stacks */ +#define STACKSIZE 256 /* default stacksize */ #define NLAST 5 /* last drive */ #define NUMBUFF 20 /* Number of track buffers at INIT time */ /* -- must be at least 3 */ From 0f4d6ea6a13dc897fb778482ea42a7605f9fa88c Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Fri, 26 Mar 2004 23:20:55 +0000 Subject: [PATCH 407/671] Define O_ACCMODE and use it instead of "3" for the open access mask. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@828 6ac86273-5f31-0410-b378-82cca8765d1b --- hdr/file.h | 1 + kernel/fatfs.c | 9 +++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/hdr/file.h b/hdr/file.h index 1c205ba6..2a33a427 100644 --- a/hdr/file.h +++ b/hdr/file.h @@ -50,6 +50,7 @@ static BYTE *file_hRcsId = #define O_RDONLY SFT_MREAD #define O_WRONLY SFT_MWRITE #define O_RDWR SFT_MRDWR +#define O_ACCMODE 3 /* bits 2, 3 reserved */ /* bits 4, 5, 6 sharing modes */ diff --git a/kernel/fatfs.c b/kernel/fatfs.c index 8901584b..6adb8fe2 100644 --- a/kernel/fatfs.c +++ b/kernel/fatfs.c @@ -150,7 +150,7 @@ long dos_open(char *path, unsigned flags, unsigned attrib) /* First test the flags to see if the user has passed a valid */ /* file mode... */ - if ((flags & 3) > 2) + if ((flags & O_ACCMODE) > 2) return DE_INVLDACC; /* first split the passed dir into comopnents (i.e. - path to */ @@ -187,7 +187,8 @@ long dos_open(char *path, unsigned flags, unsigned attrib) flags = (flags & ~3) | O_RDONLY; /* Check permissions. -- JPP */ - if ((fnp->f_dir.dir_attrib & D_RDONLY) && ((flags & 3) != O_RDONLY)) + if ((fnp->f_dir.dir_attrib & D_RDONLY) && + ((flags & O_ACCMODE) != O_RDONLY)) { dir_close(fnp); return DE_ACCESS; @@ -219,8 +220,8 @@ long dos_open(char *path, unsigned flags, unsigned attrib) /* Set the fnode to the desired mode */ /* Updating the directory entry first. */ - fnp->f_mode = flags & 3; - + fnp->f_mode = flags & O_ACCMODE; + if (status != S_OPENED) { init_direntry(&fnp->f_dir, attrib, FREE); From 1fb4a30294740ad3a6ab1ad968baeeb792a44d40 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Fri, 26 Mar 2004 23:27:18 +0000 Subject: [PATCH 408/671] Add forward declaration for config_init_fnodes. Made static too. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@829 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/config.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/kernel/config.c b/kernel/config.c index 8f9ae42a..0c5803f2 100644 --- a/kernel/config.c +++ b/kernel/config.c @@ -250,7 +250,8 @@ STATIC int LoadCountryInfoHardCoded(char *filename, COUNT ctryCode, COUNT codePa STATIC void umb_init(void); void HMAconfig(int finalize); -VOID config_init_buffers(COUNT anzBuffers); /* from BLOCKIO.C */ +STATIC void config_init_buffers(int anzBuffers); /* from BLOCKIO.C */ +STATIC void config_init_fnodes(int f_nodes_cnt); #ifdef I86 STATIC VOID FAR * AlignParagraph(VOID FAR * lpPtr); @@ -1701,7 +1702,7 @@ STATIC COUNT strcasecmp(REG BYTE * d, REG BYTE * s) that saves some relocation problems */ -VOID config_init_buffers(COUNT anzBuffers) +STATIC void config_init_buffers(int anzBuffers) { REG WORD i; struct buffer FAR *pbuffer; @@ -1772,7 +1773,7 @@ VOID config_init_buffers(COUNT anzBuffers) anzBuffers, anzBuffers * sizeof(struct buffer)); } -VOID config_init_fnodes(int f_nodes_cnt) +STATIC void config_init_fnodes(int f_nodes_cnt) { struct f_node FAR *p; size_t bytes; From 9aa77bef50fcbaf2d15593143a88e3802a3d94bd Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sat, 27 Mar 2004 00:23:06 +0000 Subject: [PATCH 409/671] Get rid of SFT_M* mode values. O_* values are sufficient. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@830 6ac86273-5f31-0410-b378-82cca8765d1b --- hdr/file.h | 20 ++++++++++++++++---- hdr/sft.h | 14 -------------- kernel/dosfns.c | 8 ++++---- kernel/fcbfns.c | 4 ++-- 4 files changed, 22 insertions(+), 24 deletions(-) diff --git a/hdr/file.h b/hdr/file.h index 2a33a427..7b6c2f28 100644 --- a/hdr/file.h +++ b/hdr/file.h @@ -47,13 +47,25 @@ static BYTE *file_hRcsId = #define STDAUX 3 #define STDPRN 4 -#define O_RDONLY SFT_MREAD -#define O_WRONLY SFT_MWRITE -#define O_RDWR SFT_MRDWR -#define O_ACCMODE 3 +/* mode bits */ +#define O_VALIDMASK 0xfff3 /* valid open mask */ + +#define O_RDONLY 0x0000 +#define O_WRONLY 0x0001 +#define O_RDWR 0x0002 +#define O_ACCMODE 0x0003 /* bits 2, 3 reserved */ + /* bits 4, 5, 6 sharing modes */ +#define O_SHAREMASK 0x0070 /* mask to isolate shared bits */ + +#define O_DENYALL 0x0010 /* " " */ +#define O_DENYWRITE 0x0020 /* " " */ +#define O_DENYREAD 0x0030 /* " " */ +#define O_DENYNONE 0x0040 /* sharing bits */ +#define O_NETFCB 0x0070 /* networked fcb */ + #define O_NOINHERIT 0x0080 #define O_OPEN 0x0100 /* not */ #define O_TRUNC 0x0200 /* both */ diff --git a/hdr/sft.h b/hdr/sft.h index 49bb846c..6a61a606 100644 --- a/hdr/sft.h +++ b/hdr/sft.h @@ -94,20 +94,6 @@ typedef struct sfttbl { /* defines for sft use */ #define SFT_MASK 0x0060 /* splits device data */ -/* mode bits */ -#define SFT_MFCB 0x8000 /* entry is for fcb */ -#define SFT_MDENYNONE 0x0040 /* sharing bits */ -#define SFT_MDENYREAD 0x0030 /* " " */ -#define SFT_MDENYWRITE 0x0020 /* " " */ -#define SFT_MEXCLUSIVE 0x0010 /* " " */ -#define SFT_NOINHERIT 0x0080 /* inhibit inherting of file */ -#define SFT_NETFCB 0x0070 /* networked fcb */ -#define SFT_MSHAREMASK 0x0070 /* mask to isolate shared bits */ -#define SFT_MRDWR 0x0002 /* read/write bit */ -#define SFT_MWRITE 0x0001 /* write bit */ -#define SFT_MREAD 0x0000 /* ~ write bit */ -#define SFT_OMASK 0xfff3 /* valid open mask */ - /* flag bits */ /* the following bit is for redirection */ diff --git a/kernel/dosfns.c b/kernel/dosfns.c index 564e0035..bbbc6dcf 100644 --- a/kernel/dosfns.c +++ b/kernel/dosfns.c @@ -211,8 +211,8 @@ long DosRWSft(int sft_idx, size_t n, void FAR * bp, int mode) return DE_INVLDHNDL; } /* If for read and write-only or for write and read-only then exit */ - if((mode == XFR_READ && (s->sft_mode & SFT_MWRITE)) || - (mode == XFR_WRITE && !(s->sft_mode & (SFT_MWRITE | SFT_MRDWR)))) + if((mode == XFR_READ && (s->sft_mode & O_WRONLY)) || + (mode == XFR_WRITE && (s->sft_mode & O_ACCMODE) == O_RDONLY)) { return DE_ACCESS; } @@ -337,7 +337,7 @@ COUNT SftSeek(int sft_idx, LONG new_pos, COUNT mode) * Lredir via mfs.c from DosEMU works when writing appended files. * Mfs.c looks for these mode bits set, so here is my best guess.;^) */ - if ((s->sft_mode & SFT_MDENYREAD) || (s->sft_mode & SFT_MDENYNONE)) + if ((s->sft_mode & O_DENYREAD) || (s->sft_mode & O_DENYNONE)) { s->sft_posit = remote_lseek(s, new_pos); return SUCCESS; @@ -644,7 +644,7 @@ long DosOpen(char FAR * fname, unsigned mode, unsigned attrib) unsigned hndl; /* test if mode is in range */ - if ((mode & ~SFT_OMASK) != 0) + if ((mode & ~O_VALIDMASK) != 0) return DE_INVLDACC; /* get a free handle */ diff --git a/kernel/fcbfns.c b/kernel/fcbfns.c index 8f67bccd..3fa5fe73 100644 --- a/kernel/fcbfns.c +++ b/kernel/fcbfns.c @@ -412,7 +412,7 @@ UBYTE FcbOpen(xfcb FAR * lpXfcb, unsigned flags) } sftp = idx_to_sft(sft_idx); - sftp->sft_mode |= SFT_MFCB; + sftp->sft_mode |= O_FCB; lpFcb->fcb_sftno = sft_idx; lpFcb->fcb_curec = 0; @@ -631,7 +631,7 @@ VOID FcbCloseAll() sft FAR *sftp; for (idx = 0; (sftp = idx_to_sft(idx)) != (sft FAR *) - 1; idx++) - if ((sftp->sft_mode & SFT_MFCB) && sftp->sft_psp == cu_psp) + if ((sftp->sft_mode & O_FCB) && sftp->sft_psp == cu_psp) DosCloseSft(idx, FALSE); } From d5cb4e950cfd846ebbfa160cbcb4fead5f58768b Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sat, 27 Mar 2004 00:27:11 +0000 Subject: [PATCH 410/671] Fixed screwed up comment sequence. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@831 6ac86273-5f31-0410-b378-82cca8765d1b --- hdr/file.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hdr/file.h b/hdr/file.h index 7b6c2f28..ec63ebd8 100644 --- a/hdr/file.h +++ b/hdr/file.h @@ -60,10 +60,10 @@ static BYTE *file_hRcsId = /* bits 4, 5, 6 sharing modes */ #define O_SHAREMASK 0x0070 /* mask to isolate shared bits */ -#define O_DENYALL 0x0010 /* " " */ +#define O_DENYALL 0x0010 /* sharing bits */ #define O_DENYWRITE 0x0020 /* " " */ #define O_DENYREAD 0x0030 /* " " */ -#define O_DENYNONE 0x0040 /* sharing bits */ +#define O_DENYNONE 0x0040 /* " " */ #define O_NETFCB 0x0070 /* networked fcb */ #define O_NOINHERIT 0x0080 From db1a71bfff3059a33776ce15f661ed300bdf6946 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sat, 27 Mar 2004 00:30:32 +0000 Subject: [PATCH 411/671] Remove wrong "512" value for number of root directory entries on FAT32 partitions. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@832 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/dsk.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/kernel/dsk.c b/kernel/dsk.c index 4e57b7fc..37af64aa 100644 --- a/kernel/dsk.c +++ b/kernel/dsk.c @@ -434,9 +434,8 @@ STATIC WORD getbpb(ddt * pddt) { /* FAT32 boot sector */ fs = (struct FS_info *)&DiskTransferBuffer[0x43]; - pbpbarray->bpb_ndirent = 512; } -#endif +#endif pddt->ddt_serialno = getlong(&fs->serialno); memcpy(pddt->ddt_volume, fs->volume, sizeof fs->volume); memcpy(pddt->ddt_fstype, fs->fstype, sizeof fs->fstype); From 66a756f1a3b01ca70d915452e63f0a331149b5fd Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sat, 27 Mar 2004 00:35:34 +0000 Subject: [PATCH 412/671] Simplify memory access mode check. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@833 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/inthndlr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/inthndlr.c b/kernel/inthndlr.c index 0a7f8152..076907a2 100644 --- a/kernel/inthndlr.c +++ b/kernel/inthndlr.c @@ -1210,7 +1210,7 @@ VOID ASMCFUNC int21_service(iregs FAR * r) break; case 0x01: - if ((lr.BL & FIT_U_MASK) > FIRST_FIT_U || /* 0xc0, 0x80 */ + if (lr.BL > LAST_FIT_U || /* 0x82 */ (lr.BL & FIT_MASK) > LAST_FIT) /* 0x3f, 0x02 */ goto error_invalid; mem_access_mode = lr.BL; From 3fe15616e76771e78ad1d8cfc334150bde858d25 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sat, 27 Mar 2004 01:42:33 +0000 Subject: [PATCH 413/671] .BAT file cleanups from Arkady git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@834 6ac86273-5f31-0410-b378-82cca8765d1b --- build.bat | 168 ++++++++++++++++++++------------------------------- buildall.bat | 79 +++++++++--------------- clean.bat | 26 +++----- clobber.bat | 27 +++------ default.bat | 66 ++++++++++++++++++++ filelist | 2 +- getmake.bat | 10 --- 7 files changed, 181 insertions(+), 197 deletions(-) create mode 100644 default.bat delete mode 100644 getmake.bat diff --git a/build.bat b/build.bat index 1c9517aa..a99ca18e 100644 --- a/build.bat +++ b/build.bat @@ -1,117 +1,93 @@ -:-@echo off - -:- batch file to build everything - -:- $Id$ - -set XERROR= - +@echo off -@if not exist config.bat echo You must copy CONFIG.B to CONFIG.BAT and edit it to reflect your setup! -@if not exist config.bat goto end +:- batch file to build everything +:- $Id$ -@if not \%1 == \-r goto norebuild - call clobber -:norebuild +:- Syntax: BUILD [-r] [fat32|fat16] [msc|wc|tc|tcpp] [86|186|386] +:- option case is significant !! +if "%1" == "-r" call clobber +if "%1" == "-r" shift -call config.bat -call getmake.bat +set XERROR= +if not exist config.bat echo You must copy CONFIG.B to CONFIG.BAT and edit it to reflect your setup! +if not exist config.bat goto abort -@set XERROR= +call config -:********************************************************************** -:* DONE with preferences - following is command line handling -:* -:* options on the commandline overwrite your default settings -:* -:* options handled ( case significant !! ) -:* -:* BUILD [fat32|fat16] [msc|wc|tc|tcpp] [86|186|386] -:* -:********************************************************************** +:----------------------------------------------------------------------- +:- following is command line handling +:- options on the commandline overwrite default settings +:----------------------------------------------------------------------- :loop_commandline -if \%1 == \ goto done_with_commandline +if "%1" == "fat32" set XFAT=32 +if "%1" == "fat16" set XFAT=16 -if %1 == fat32 set XFAT=32 -if %1 == fat16 set XFAT=16 +if "%1" == "msc" set COMPILER=MSCL8 +if "%1" == "wc" set COMPILER=WATCOM +if "%1" == "tc" set COMPILER=TC2 +if "%1" == "tcpp" set COMPILER=TURBOCPP -if %1 == msc set COMPILER=MSCL8 -if %1 == wc set COMPILER=WATCOM -if %1 == tc set COMPILER=TC2 -if %1 == tcpp set COMPILER=TURBOCPP - - -if %1 == 86 set XCPU=86 -if %1 == 186 set XCPU=186 -if %1 == 386 set XCPU=386 +if "%1" == "86" set XCPU=86 +if "%1" == "186" set XCPU=186 +if "%1" == "386" set XCPU=386 shift -goto loop_commandline - -:done_with_commandline - -if \%COMPILER% == \ echo you MUST define a COMPILER variable in CONFIG.BAT -if \%COMPILER% == \ goto end - - -@if not "%XLINK%" == "" goto link_set +if not "%1" == "" goto loop_commandline -@if \%COMPILER% == \TC2 set XLINK=%TC2_BASE%\tlink /m/c -@if \%COMPILER% == \TURBOCPP set XLINK=%TP1_BASE%\bin\tlink /m/c -@if \%COMPILER% == \TC3 set XLINK=%TC3_BASE%\bin\tlink /m/c -@if \%COMPILER% == \BC5 set XLINK=%BC5_BASE%\bin\tlink /m/c -@if \%COMPILER% == \WATCOM set XLINK=..\utils\wlinker /ma/nologo -@if \%COMPILER% == \MSCL8 set XLINK=%MS_BASE%\bin\link /ONERROR:NOEXE /ma /nologo -goto link_set +if "%COMPILER%" == "" echo you MUST define a COMPILER variable in CONFIG.BAT +if "%COMPILER%" == "" goto abort -:link_set +call default -echo linker is %XLINK% - -@if not "%XUPX%" == "" goto upx_set -@set XUPX=@rem -@set UPXOPT= -goto compile - -:upx_set -@set UPXOPT=-U - -:compile - -:************************************************************************ -:* finally - we are going to compile -:************************************************************************ +:----------------------------------------------------------------------- +:- finally - we are going to compile +:----------------------------------------------------------------------- +echo. +echo Process UTILS ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +echo. cd utils %MAKE% production -if errorlevel 1 goto abort +if errorlevel 1 goto abort-cd +echo. +echo Process LIB ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +echo. cd ..\lib %MAKE% -if errorlevel 1 goto abort +if errorlevel 1 goto abort-cd +echo. +echo Process DRIVERS ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +echo. cd ..\drivers %MAKE% production -if errorlevel 1 goto abort - +if errorlevel 1 goto abort-cd +echo. +echo Process BOOT +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +echo. cd ..\boot %MAKE% production -if errorlevel 1 goto abort +if errorlevel 1 goto abort-cd +echo. +echo Process SYS ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +echo. cd ..\sys %MAKE% production -if errorlevel 1 goto abort - -:start +if errorlevel 1 goto abort-cd +echo. +echo Process KERNEL +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +echo. cd ..\kernel %MAKE% production -if errorlevel 1 goto abort +if errorlevel 1 goto abort-cd cd .. @@ -120,31 +96,17 @@ cd .. if exist build2.bat call build2 -@goto end +echo. +echo Processing is done. +goto end -:abort +:----------------------------------------------------------------------- + +:abort-cd cd .. +:abort +echo Compilation was aborted! set XERROR=1 -:end -:***** cleanup ****** -@echo off -@if "%OLDPATH%" == "" goto no_path_change -@set PATH=%OLDPATH% -@set OLDPATH= -:no_path_change - -@set MAKE= -@set COMPILER= -@set XCPU= -@set XFAT= -@set XLINK= -@set TC2_BASE= -@set TP1_BASE= -@set TC3_BASE= -@set BC5_BASE= -@set MS_BASE= -@set XNASM= -@set XERROR= -@set XUPX= -@set UPXOPT= +:end +default clearset diff --git a/buildall.bat b/buildall.bat index 53535488..ebef4b1d 100644 --- a/buildall.bat +++ b/buildall.bat @@ -1,27 +1,21 @@ -:-@echo off - -:- -:- Revision 1.0 2001/09/05 tomehlert -:- +@echo off +:- $Id$ :---------------------------------------------------------- :- batch file to build _many_ KERNELS, hope build works -:- :- takes 3 minutes on my(TE) Win2K/P700. your milage may vary :-) :---------------------------------------------------------- -if \%1 == \$SUMMARY goto summary - -:-goto xsummary +if "%1" == "$SUMMARY" goto summary -set onerror=if not \%XERROR% == \ goto daswarwohlnix +set onerror=if not "%%XERROR%%" == "" goto daswarwohlnix -:***** some MSCL kernels +:***** MSCL kernels call config.bat -if \%MS_BASE% == \ goto no_ms +if "%MS_BASE%" == "" goto no_ms call build -r msc 386 fat16 %ONERROR% call build -r msc 186 fat16 @@ -36,9 +30,9 @@ call build -r msc 86 fat32 %ONERROR% :no_ms -:***** some TC 2.01 kernels +:***** TC 2.01 kernels -if \%TC2_BASE% == \ goto no_tc +if "%TC2_BASE%" == "" goto no_tc call build -r tc 186 fat16 %ONERROR% call build -r tc 86 fat16 @@ -49,60 +43,49 @@ call build -r tc 86 fat32 %ONERROR% :no_tc -:wc - -:***** some WATCOM kernels - just for fun !!! +:***** (Open) Watcom kernels -:- -:- this is definitively only for fun - now -:- hope, this gets better -:- -if \%WATCOM% == \ goto no_wc +if "%WATCOM%" == "" goto no_wc call build -r wc 386 fat32 +%ONERROR% call build -r wc 386 fat16 +%ONERROR% call build -r wc 86 fat32 +%ONERROR% call build -r wc 86 fat16 +%ONERROR% :no_wc -:- the watcom executables will currently NOT RUN -@del bin\kwc*.sys >nul +:***** now rebuild the default kernel - -:***** now rebuild the normal kernel !! call build -r - :************************************************************** :* now we build a summary of all kernels HMA size + total size :* Yes, I know - "mit Linux waer das nicht passiert" :-) :* at least, it's possible with standard DOS tools :************************************************************** -:xsummary - set Sumfile=bin\ksummary.txt set TempSumfile=bin\tsummary.txt -:****@echo >%TempSumfile% Summary of all kernels build -:****@echo.|date >>%TempSumfile% -:****@echo.|time >>%TempSumfile% -:****for %%i in (bin\k*.map) do call %0 $SUMMARY %%i -:****for %%i in (bin\k*.map) do call %0 $SUMMARY %%i +:****echo >%TempSumfile% Summary of all kernels build +:****echo.|date >>%TempSumfile% +:****echo.|time >>%TempSumfile% :****for %%i in (bin\k*.map) do call %0 $SUMMARY %%i -del %Sumfile% -del %TempSumfile% -del ktemp.bat +if exist %Sumfile% del %Sumfile% +if exist %TempSumfile% del %TempSumfile% +>ktemp.bat for %%i in (bin\k*.map) do echo call %0 $SUMMARY %%i >>ktemp.bat sort ktemps.bat call ktemps del ktemp.bat del ktemps.bat - -@echo >>%Sumfile% Summary of all kernels build -@echo.|date >>%Sumfile% -@echo.|time >>%Sumfile% +echo >>%Sumfile% Summary of all kernels build +echo.|date >>%Sumfile% +echo.|time >>%Sumfile% find <%TempSumfile% "H" >>%Sumfile% del %TempSumfile% @@ -111,17 +94,15 @@ set Sumfile= goto end :summary -echo >>%TempSumfile% H************************************************* %2 -type %2| find " HMA_TEXT" |find /V "HMA_TEXT_START" |find /V "HMA_TEXT_END" >>%TempSumfile% -type %2| find " STACK" >>%TempSumfile% +echo H************************************************* %2 >>%TempSumfile% +find<%2 " HMA_TEXT"|find/V "HMA_TEXT_START"|find/V "HMA_TEXT_END">>%TempSumfile% +find<%2 " STACK">>%TempSumfile% goto end :************* done with summary ********************************* - :daswarwohlnix -@echo Sorry, something didn't work as expected :-( -@set ONERROR= -:end - +echo Sorry, something didn't work as expected :-( +set ONERROR= +:end diff --git a/clean.bat b/clean.bat index fbc63369..04752369 100644 --- a/clean.bat +++ b/clean.bat @@ -1,19 +1,13 @@ @echo off -rem batch file to clean everything +:- batch file to clean everything +:- $Id$ -rem $Id$ +if not exist config.bat echo You must copy CONFIG.B to CONFIG.BAT and edit it to reflect your setup! +if not exist config.bat goto end -if not exist config.bat goto noconfigbat -goto start - -:noconfigbat -echo You must copy CONFIG.B to CONFIG.BAT and edit it to reflect your setup! -goto end - -:start -call config.bat -call getmake.bat +call config +call default cd utils %MAKE% clean @@ -34,12 +28,10 @@ cd ..\kernel %MAKE% clean cd ..\hdr -del *.bak +if exist *.bak del *.bak cd .. - -del *.bak +if exist *.bak del *.bak :end -set MAKE= -set COMPILER= +default clearset diff --git a/clobber.bat b/clobber.bat index 4415c2ae..986c436b 100644 --- a/clobber.bat +++ b/clobber.bat @@ -1,18 +1,13 @@ @echo off -rem batch file to clobber everything -rem $Id$ +:- batch file to clobber everything +:- $Id$ -if not exist config.bat goto noconfigbat -goto start +if not exist config.bat echo You must copy CONFIG.B to CONFIG.BAT and edit it to reflect your setup! +if not exist config.bat goto end -:noconfigbat -echo You must copy CONFIG.B to CONFIG.BAT and edit it to reflect your setup! -goto end - -:start -call config.bat -call getmake.bat +call config +call default cd utils %MAKE% clobber @@ -33,13 +28,11 @@ cd ..\kernel %MAKE% clobber cd ..\hdr -del *.bak +if exist *.bak del *.bak cd .. - -del *.bak -del status.me +if exist *.bak del *.bak +if exist status.me del status.me :end -set MAKE= -set COMPILER= +default clearset diff --git a/default.bat b/default.bat new file mode 100644 index 00000000..b1c83808 --- /dev/null +++ b/default.bat @@ -0,0 +1,66 @@ +@echo off + +:- $Id$ + +if "%1" == "clearset" goto clearset + +:----------------------------------------------------------------------- + +if not "%MAKE%" == "" goto skip_make + +if "%COMPILER%" == "TC2" set MAKE=%TC2_BASE%\make +if "%COMPILER%" == "TURBOCPP" set MAKE=%TP1_BASE%\bin\make +if "%COMPILER%" == "TC3" set MAKE=%TC3_BASE%\bin\make +if "%COMPILER%" == "BC5" set MAKE=%BC5_BASE%\bin\make +if "%COMPILER%" == "WATCOM" set MAKE=wmake/ms /h +if "%COMPILER%" == "MSCL8" set MAKE=%MS_BASE%\bin\nmake/nologo + +echo Make is %MAKE%. + +:skip_make + +:----------------------------------------------------------------------- + +if not "%XLINK%" == "" goto skip_xlink + +if "%COMPILER%" == "TC2" set XLINK=%TC2_BASE%\tlink/m/c +if "%COMPILER%" == "TURBOCPP" set XLINK=%TP1_BASE%\bin\tlink/m/c +if "%COMPILER%" == "TC3" set XLINK=%TC3_BASE%\bin\tlink/m/c +if "%COMPILER%" == "BC5" set XLINK=%BC5_BASE%\bin\tlink/m/c +if "%COMPILER%" == "WATCOM" set XLINK=..\utils\wlinker/ma/nologo +if "%COMPILER%" == "MSCL8" set XLINK=%MS_BASE%\bin\link/ONERROR:NOEXE /ma /nologo + +echo Linker is %XLINK%. + +:skip_xlink + +:----------------------------------------------------------------------- + +if not "%XUPX%" == "" set UPXOPT=-U +if "%XUPX%" == "" set UPXOPT= +if "%XUPX%" == "" set XUPX=@rem + +goto end + +:----------------------------------------------------------------------- + +:clearset + +if not "%OLDPATH%" == "" set PATH=%OLDPATH% +if not "%OLDPATH%" == "" set OLDPATH= + +set MAKE= +set COMPILER= +set XCPU= +set XFAT= +set XLINK= +set TC2_BASE= +set TP1_BASE= +set TC3_BASE= +set BC5_BASE= +set MS_BASE= +set XNASM= +set XUPX= +set UPXOPT= + +:end diff --git a/filelist b/filelist index 17405f0a..9b4ed556 100644 --- a/filelist +++ b/filelist @@ -4,7 +4,7 @@ */*/clobber.bat */*/config.b */*/filelist -*/*/getmake.bat +*/*/default.bat */*/makefile */*/bin/autoexec.bat */*/bin/config.sys diff --git a/getmake.bat b/getmake.bat deleted file mode 100644 index 9306aa97..00000000 --- a/getmake.bat +++ /dev/null @@ -1,10 +0,0 @@ -@if not "%MAKE%" == "" goto make_set - -@if \%COMPILER% == \TC2 set MAKE=%TC2_BASE%\make -@if \%COMPILER% == \TURBOCPP set MAKE=%TP1_BASE%\bin\make -@if \%COMPILER% == \TC3 set MAKE=%TC3_BASE%\bin\make -@if \%COMPILER% == \BC5 set MAKE=%BC5_BASE%\bin\make -@if \%COMPILER% == \WATCOM set MAKE=wmake /ms /h -@if \%COMPILER% == \MSCL8 set MAKE=%MS_BASE%\bin\nmake /nologo - -:make_set From 29bcbde334ac385a1797093f3ec8f9928397f827 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sat, 27 Mar 2004 02:36:50 +0000 Subject: [PATCH 414/671] It doesn't work with two * two % (at least in FreeCOM) git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@835 6ac86273-5f31-0410-b378-82cca8765d1b --- buildall.bat | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buildall.bat b/buildall.bat index ebef4b1d..db864b34 100644 --- a/buildall.bat +++ b/buildall.bat @@ -9,7 +9,7 @@ if "%1" == "$SUMMARY" goto summary -set onerror=if not "%%XERROR%%" == "" goto daswarwohlnix +set onerror=if not "%XERROR%" == "" goto daswarwohlnix :***** MSCL kernels From 03138b0ed4251e898a18094cb89470cd018936d6 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sat, 27 Mar 2004 12:13:10 +0000 Subject: [PATCH 415/671] explicitly use .bat for call, etc., otherwise 4DOS doesn't like us... git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@836 6ac86273-5f31-0410-b378-82cca8765d1b --- build.bat | 8 ++++---- buildall.bat | 2 +- clean.bat | 6 +++--- clobber.bat | 6 +++--- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/build.bat b/build.bat index a99ca18e..75a0e225 100644 --- a/build.bat +++ b/build.bat @@ -6,7 +6,7 @@ :- Syntax: BUILD [-r] [fat32|fat16] [msc|wc|tc|tcpp] [86|186|386] :- option case is significant !! -if "%1" == "-r" call clobber +if "%1" == "-r" call clobber.bat if "%1" == "-r" shift set XERROR= @@ -14,7 +14,7 @@ set XERROR= if not exist config.bat echo You must copy CONFIG.B to CONFIG.BAT and edit it to reflect your setup! if not exist config.bat goto abort -call config +call config.bat :----------------------------------------------------------------------- :- following is command line handling @@ -41,7 +41,7 @@ if not "%1" == "" goto loop_commandline if "%COMPILER%" == "" echo you MUST define a COMPILER variable in CONFIG.BAT if "%COMPILER%" == "" goto abort -call default +call default.bat :----------------------------------------------------------------------- :- finally - we are going to compile @@ -109,4 +109,4 @@ echo Compilation was aborted! set XERROR=1 :end -default clearset +default.bat clearset diff --git a/buildall.bat b/buildall.bat index db864b34..a87638b6 100644 --- a/buildall.bat +++ b/buildall.bat @@ -79,7 +79,7 @@ if exist %TempSumfile% del %TempSumfile% >ktemp.bat for %%i in (bin\k*.map) do echo call %0 $SUMMARY %%i >>ktemp.bat sort ktemps.bat -call ktemps +call ktemps.bat del ktemp.bat del ktemps.bat diff --git a/clean.bat b/clean.bat index 04752369..b2028c15 100644 --- a/clean.bat +++ b/clean.bat @@ -6,8 +6,8 @@ if not exist config.bat echo You must copy CONFIG.B to CONFIG.BAT and edit it to reflect your setup! if not exist config.bat goto end -call config -call default +call config.bat +call default.bat cd utils %MAKE% clean @@ -34,4 +34,4 @@ cd .. if exist *.bak del *.bak :end -default clearset +default.bat clearset diff --git a/clobber.bat b/clobber.bat index 986c436b..2fcc81c9 100644 --- a/clobber.bat +++ b/clobber.bat @@ -6,8 +6,8 @@ if not exist config.bat echo You must copy CONFIG.B to CONFIG.BAT and edit it to reflect your setup! if not exist config.bat goto end -call config -call default +call config.bat +call default.bat cd utils %MAKE% clobber @@ -35,4 +35,4 @@ if exist *.bak del *.bak if exist status.me del status.me :end -default clearset +default.bat clearset From eed84806f86d781c32dd01d64c3b53c2f7b01e71 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sat, 27 Mar 2004 17:12:16 +0000 Subject: [PATCH 416/671] dos_commit was missing a save_far_f_node() call. That caused the tar xzvf problem. Also fixed the case when no far fnodes are available anymore. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@837 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/fatfs.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/kernel/fatfs.c b/kernel/fatfs.c index 6adb8fe2..c0d3a2da 100644 --- a/kernel/fatfs.c +++ b/kernel/fatfs.c @@ -326,6 +326,7 @@ COUNT dos_commit(COUNT fd) /* a copy of the fnode is closed meaning that the directory info is updated etc, but we keep our old info */ memcpy(fnp2, fnp, sizeof(*fnp)); + save_far_f_node(fnp2); release_near_f_node(fnp); return dos_close(xlt_fnp(fnp2)); } @@ -1939,6 +1940,7 @@ f_node_ptr get_f_node(void) return fnp; } } + release_near_f_node(fnp); } return (f_node_ptr) 0; } From 8e8046209362ea1783e3749e1aad920a5a8426c4 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Fri, 2 Apr 2004 00:38:24 +0000 Subject: [PATCH 417/671] Be more specific about which registers are clobbered by asmsupt.asm functions. Preserve "ES" for Watcom. Saves ~150 bytes resident, ~90 bytes nonresident, more for 386 kernels. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@839 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/asmsupt.asm | 6 ++++++ kernel/init-mod.h | 17 ++++++++++++++++- kernel/proto.h | 20 +++++++++++++++++++- 3 files changed, 41 insertions(+), 2 deletions(-) diff --git a/kernel/asmsupt.asm b/kernel/asmsupt.asm index e26061be..d13aac93 100644 --- a/kernel/asmsupt.asm +++ b/kernel/asmsupt.asm @@ -105,6 +105,9 @@ pascal_setup: push bp ; Standard C entry mov bp,sp +%ifdef WATCOM + push es +%endif push si push di push ds @@ -240,6 +243,9 @@ pascal_return: pop ds pop di pop si +%ifdef WATCOM + pop es +%endif pop bp pop cx diff --git a/kernel/init-mod.h b/kernel/init-mod.h index 061c3720..c1c1eb3c 100644 --- a/kernel/init-mod.h +++ b/kernel/init-mod.h @@ -58,7 +58,22 @@ VOID ASMPASCAL fmemcpy( void FAR *d, const void FAR *s, size_t n); VOID ASMPASCAL strcpy(char *d, const char *s); size_t ASMPASCAL strlen(const char *s); size_t ASMPASCAL fstrlen(const char FAR *s); - + +#ifdef __WATCOMC__ +/* dx and es not used or clobbered for all asmsupt.asm functions except + (f)memchr/(f)strchr (which preserve es) */ +#pragma aux (pascal) pascal_abc modify exact [ax bx cx] +#pragma aux (pascal_abc) init_memset +#pragma aux (pascal_abc) init_fmemset +#pragma aux (pascal_abc) init_memcpy +#pragma aux (pascal_abc) init_fmemcpy +#pragma aux (pascal_abc) init_memcmp modify nomemory +#pragma aux (pascal_abc) init_fmemcmp modify nomemory +#pragma aux (pascal_abc) init_strcpy +#pragma aux (pascal_abc) init_strlen modify nomemory +#pragma aux (pascal_abc) init_fstrlen modify nomemory +#endif + #undef LINESIZE #define LINESIZE KBD_MAXLENGTH diff --git a/kernel/proto.h b/kernel/proto.h index 8ddd62e8..a60f737c 100644 --- a/kernel/proto.h +++ b/kernel/proto.h @@ -313,7 +313,25 @@ void * /*ASMCFUNC*/ ASMPASCAL memset(void * s, int ch, size_t n); int /*ASMCFUNC*/ ASMPASCAL memcmp(const void *m1, const void *m2, size_t n); int /*ASMCFUNC*/ ASMPASCAL fmemcmp(const void FAR *m1, const void FAR *m2, size_t n); - +#ifdef __WATCOMC__ +/* dx and es not used or clobbered for all asmsupt.asm functions except + (f)memchr/(f)strchr (which preserve es) */ +#pragma aux (pascal) pascal_abc modify exact [ax bx cx] +#pragma aux (pascal_abc) fmemcpy +#pragma aux (pascal_abc) memcpy +#pragma aux (pascal_abc) fmemset +#pragma aux (pascal_abc) memset +#pragma aux (pascal_abc) fmemcmp modify nomemory +#pragma aux (pascal_abc) memcmp modify nomemory +#pragma aux (pascal_abc) fstrcpy +#pragma aux (pascal_abc) strcpy +#pragma aux (pascal_abc) fstrlen modify nomemory +#pragma aux (pascal_abc) strlen modify nomemory +#pragma aux (pascal) memchr modify exact [ax bx cx dx] +#pragma aux (pascal) fmemchr modify exact [ax bx cx dx] +#pragma aux (pascal) strchr modify exact [ax bx cx dx] +#pragma aux (pascal) fstrchr modify exact [ax bx cx dx] +#endif /* sysclk.c */ COUNT BcdToByte(COUNT x); From 8ea4701226d599f639e911200942071916c8868d Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Tue, 6 Apr 2004 16:29:27 +0000 Subject: [PATCH 418/671] Preserve bx and cx for WATCOMC in asmsupt.asm as well. Saves another 200 bytes. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@840 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/asmsupt.asm | 19 +++++++++++++------ kernel/init-mod.h | 20 ++++++++++---------- kernel/proto.h | 34 +++++++++++++++++----------------- 3 files changed, 40 insertions(+), 33 deletions(-) diff --git a/kernel/asmsupt.asm b/kernel/asmsupt.asm index d13aac93..77d304b0 100644 --- a/kernel/asmsupt.asm +++ b/kernel/asmsupt.asm @@ -106,6 +106,8 @@ pascal_setup: push bp ; Standard C entry mov bp,sp %ifdef WATCOM + push bx + push cx push es %endif push si @@ -240,19 +242,24 @@ MEMSET: ;***** pascal_return: - pop ds + lds di, [bp] ; return address in es, saved bp in di + mov bh, 0 + add bp, bx ; point bp to "as if there were 0 args" + mov [bp+2], ds ; put return address at first arg + mov [bp], di ; saved bp below that one + + pop ds pop di pop si %ifdef WATCOM pop es + pop cx + pop bx %endif + mov sp,bp pop bp + ret - pop cx - sub bh,bh - add sp,bx - jmp cx - ;***************************************************************** ; fstrcpy (void FAR*dest, void FAR *src); diff --git a/kernel/init-mod.h b/kernel/init-mod.h index c1c1eb3c..b9b769d8 100644 --- a/kernel/init-mod.h +++ b/kernel/init-mod.h @@ -62,16 +62,16 @@ size_t ASMPASCAL fstrlen(const char FAR *s); #ifdef __WATCOMC__ /* dx and es not used or clobbered for all asmsupt.asm functions except (f)memchr/(f)strchr (which preserve es) */ -#pragma aux (pascal) pascal_abc modify exact [ax bx cx] -#pragma aux (pascal_abc) init_memset -#pragma aux (pascal_abc) init_fmemset -#pragma aux (pascal_abc) init_memcpy -#pragma aux (pascal_abc) init_fmemcpy -#pragma aux (pascal_abc) init_memcmp modify nomemory -#pragma aux (pascal_abc) init_fmemcmp modify nomemory -#pragma aux (pascal_abc) init_strcpy -#pragma aux (pascal_abc) init_strlen modify nomemory -#pragma aux (pascal_abc) init_fstrlen modify nomemory +#pragma aux (pascal) pascal_ax modify exact [ax] +#pragma aux (pascal_ax) init_memset +#pragma aux (pascal_ax) init_fmemset +#pragma aux (pascal_ax) init_memcpy +#pragma aux (pascal_ax) init_fmemcpy +#pragma aux (pascal_ax) init_memcmp modify nomemory +#pragma aux (pascal_ax) init_fmemcmp modify nomemory +#pragma aux (pascal_ax) init_strcpy +#pragma aux (pascal_ax) init_strlen modify nomemory +#pragma aux (pascal_ax) init_fstrlen modify nomemory #endif #undef LINESIZE diff --git a/kernel/proto.h b/kernel/proto.h index a60f737c..44472e11 100644 --- a/kernel/proto.h +++ b/kernel/proto.h @@ -314,23 +314,23 @@ int /*ASMCFUNC*/ ASMPASCAL memcmp(const void *m1, const void *m2, size_t n); int /*ASMCFUNC*/ ASMPASCAL fmemcmp(const void FAR *m1, const void FAR *m2, size_t n); #ifdef __WATCOMC__ -/* dx and es not used or clobbered for all asmsupt.asm functions except - (f)memchr/(f)strchr (which preserve es) */ -#pragma aux (pascal) pascal_abc modify exact [ax bx cx] -#pragma aux (pascal_abc) fmemcpy -#pragma aux (pascal_abc) memcpy -#pragma aux (pascal_abc) fmemset -#pragma aux (pascal_abc) memset -#pragma aux (pascal_abc) fmemcmp modify nomemory -#pragma aux (pascal_abc) memcmp modify nomemory -#pragma aux (pascal_abc) fstrcpy -#pragma aux (pascal_abc) strcpy -#pragma aux (pascal_abc) fstrlen modify nomemory -#pragma aux (pascal_abc) strlen modify nomemory -#pragma aux (pascal) memchr modify exact [ax bx cx dx] -#pragma aux (pascal) fmemchr modify exact [ax bx cx dx] -#pragma aux (pascal) strchr modify exact [ax bx cx dx] -#pragma aux (pascal) fstrchr modify exact [ax bx cx dx] +/* bx, cx, dx and es not used or clobbered for all asmsupt.asm functions except + (f)memchr/(f)strchr (which clobber dx) */ +#pragma aux (pascal) pascal_ax modify exact [ax] +#pragma aux (pascal_ax) fmemcpy +#pragma aux (pascal_ax) memcpy +#pragma aux (pascal_ax) fmemset +#pragma aux (pascal_ax) memset +#pragma aux (pascal_ax) fmemcmp modify nomemory +#pragma aux (pascal_ax) memcmp modify nomemory +#pragma aux (pascal_ax) fstrcpy +#pragma aux (pascal_ax) strcpy +#pragma aux (pascal_ax) fstrlen modify nomemory +#pragma aux (pascal_ax) strlen modify nomemory +#pragma aux (pascal) memchr modify exact [ax dx] nomemory +#pragma aux (pascal) fmemchr modify exact [ax dx] nomemory +#pragma aux (pascal) strchr modify exact [ax dx] nomemory +#pragma aux (pascal) fstrchr modify exact [ax dx] nomemory #endif /* sysclk.c */ From deecf4388290f1abdecfcf42b2a4d4322a898af5 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Tue, 6 Apr 2004 16:38:01 +0000 Subject: [PATCH 419/671] Better to call fmemset than to do things manually. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@841 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/memmgr.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/kernel/memmgr.c b/kernel/memmgr.c index adeffede..7b6670cd 100644 --- a/kernel/memmgr.c +++ b/kernel/memmgr.c @@ -290,7 +290,6 @@ COUNT DosMemLargest(UWORD FAR * size) COUNT DosMemFree(UWORD para) { REG mcb FAR *p; - COUNT i; if (!para) /* let esp. the kernel call this fct with para==0 */ return DE_INVLDMCB; @@ -305,8 +304,7 @@ COUNT DosMemFree(UWORD para) /* Mark the mcb as free so that we can later */ /* merge with other surrounding free mcb's */ p->m_psp = FREE_PSP; - for (i = 0; i < 8; i++) - p->m_name[i] = '\0'; + fmemset(p->m_name, '\0', 8); #if 0 /* Moved into allocating functions -- 1999/04/21 ska */ @@ -349,7 +347,6 @@ COUNT DosMemFree(UWORD para) COUNT DosMemChange(UWORD para, UWORD size, UWORD * maxSize) { REG mcb FAR *p, FAR * q; - REG COUNT i; /* Initialize */ p = para2far(para - 1); /* pointer to MCB */ @@ -391,8 +388,7 @@ COUNT DosMemChange(UWORD para, UWORD size, UWORD * maxSize) /* Mark the mcb as free so that we can later */ /* merge with other surrounding free mcb's */ q->m_psp = FREE_PSP; - for (i = 0; i < 8; i++) - q->m_name[i] = '\0'; + fmemset(q->m_name, '\0', 8); /* try to join q with the free mcb's following it if possible */ if (joinMCBs(q) != SUCCESS) @@ -517,7 +513,7 @@ VOID mcb_print(mcb FAR * mcbp) { static BYTE buff[9]; - fmemcpy((BYTE FAR *) buff, (BYTE FAR *) (mcbp->m_name), 8); + fmemcpy(buff, mcbp->m_name, 8); buff[8] = '\0'; printf ("%04x:%04x -> |%s| m_type = 0x%02x '%c'; m_psp = 0x%04x; m_size = 0x%04x\n", From 83f044fbe0cb45fd08438f328351d48c33196d4a Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Tue, 6 Apr 2004 22:48:12 +0000 Subject: [PATCH 420/671] Use strchr and strlen more often; also use strchr in the init code. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@842 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/asmsupt.asm | 3 +-- kernel/config.c | 21 +++++++-------------- kernel/init-mod.h | 6 ++++-- 3 files changed, 12 insertions(+), 18 deletions(-) diff --git a/kernel/asmsupt.asm b/kernel/asmsupt.asm index 77d304b0..0edc43c0 100644 --- a/kernel/asmsupt.asm +++ b/kernel/asmsupt.asm @@ -335,8 +335,6 @@ dostrlen: jmp short pascal_return -%ifndef _INIT - ;************************************************************ ; strchr (BYTE *src , int ch); @@ -369,6 +367,7 @@ strchr_found1: jmp short pascal_return +%ifndef _INIT ;***** ; fstrchr (BYTE far *src , int ch); diff --git a/kernel/config.c b/kernel/config.c index 0c5803f2..8e284af5 100644 --- a/kernel/config.c +++ b/kernel/config.c @@ -80,13 +80,10 @@ STATIC void WriteMenuLine(int MenuSelected) iregs r; unsigned char attr = (unsigned char)MenuColor; char *pText = MenuStruct[MenuSelected].Text; - size_t len = 0; if (pText[0] == 0) return; - do len++; while (pText[len]); - if(MenuStruct[MenuSelected].bSelected==1) attr = ((attr << 4) | (attr >> 4)); @@ -95,7 +92,7 @@ STATIC void WriteMenuLine(int MenuSelected) r.b.b.h = attr; r.c.b.l = r.d.b.l = MenuStruct[MenuSelected].x; r.c.b.h = r.d.b.h = MenuStruct[MenuSelected].y; - r.d.b.l += len - 1; + r.d.b.l += strlen(pText) - 1; init_call_intr(0x10, &r); /* set cursor position: */ @@ -952,15 +949,13 @@ STATIC VOID sysScreenMode(BYTE * pLine) STATIC VOID sysVersion(BYTE * pLine) { COUNT major, minor; - char *p; - - p = pLine; - while (*p && *p != '.') - p++; + char *p = strchr(pLine, '.'); - if (*p++ == '\0') + if (p == NULL) return; + p++; + /* Get major number */ if (GetNumArg(pLine, &major) == (BYTE *) 0) return; @@ -2561,10 +2556,8 @@ STATIC VOID InstallExec(struct instCmds *icmd) *d = 0; args--; - *args = 0; - while (args[*args+1]) - ++*args; - args[*args+1] = '\r'; + *args = strlen(&args[1]); + args[*args+1] = '\r'; args[*args+2] = 0; exb.exec.env_seg = 0; diff --git a/kernel/init-mod.h b/kernel/init-mod.h index b9b769d8..1acb9da7 100644 --- a/kernel/init-mod.h +++ b/kernel/init-mod.h @@ -58,10 +58,11 @@ VOID ASMPASCAL fmemcpy( void FAR *d, const void FAR *s, size_t n); VOID ASMPASCAL strcpy(char *d, const char *s); size_t ASMPASCAL strlen(const char *s); size_t ASMPASCAL fstrlen(const char FAR *s); +char * ASMPASCAL strchr(const char *s, int ch); #ifdef __WATCOMC__ -/* dx and es not used or clobbered for all asmsupt.asm functions except - (f)memchr/(f)strchr (which preserve es) */ +/* bx, cx, dx and es not used or clobbered for all asmsupt.asm functions except + (f)memchr/(f)strchr (which clobber dx) */ #pragma aux (pascal) pascal_ax modify exact [ax] #pragma aux (pascal_ax) init_memset #pragma aux (pascal_ax) init_fmemset @@ -72,6 +73,7 @@ size_t ASMPASCAL fstrlen(const char FAR *s); #pragma aux (pascal_ax) init_strcpy #pragma aux (pascal_ax) init_strlen modify nomemory #pragma aux (pascal_ax) init_fstrlen modify nomemory +#pragma aux (pascal) init_strchr modify exact [ax dx] nomemory #endif #undef LINESIZE From ab21f9be769947b724fa45f8aee9cf1a3134ddc9 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Tue, 6 Apr 2004 23:03:51 +0000 Subject: [PATCH 421/671] buffer intersection check should use > instead of >= (spotted by Arkady) small optimization -- the segment in bp == firstbuf is always the same so we just need to compare offsets. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@843 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/blockio.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/kernel/blockio.c b/kernel/blockio.c index 395ed0fe..89a8d876 100644 --- a/kernel/blockio.c +++ b/kernel/blockio.c @@ -481,14 +481,15 @@ void AllocateHMASpace (size_t lowbuffer, size_t highbuffer) do { - if (FP_OFF(bp) < highbuffer && FP_OFF(bp+1) >= lowbuffer) + /* check if buffer intersects with requested area */ + if (FP_OFF(bp) < highbuffer && FP_OFF(bp+1) > lowbuffer) { flush1(bp); /* unlink bp from buffer chain */ b_prev(bp)->b_next = bp->b_next; b_next(bp)->b_prev = bp->b_prev; - if (bp == firstbuf) + if (FP_OFF(bp) == FP_OFF(firstbuf)) firstbuf = b_next(bp); LoL_nbuffers--; } From e56f81d6a91730aafc58389274e10c9d44a05a7f Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Tue, 6 Apr 2004 23:51:33 +0000 Subject: [PATCH 422/671] Use xreg struct and macros to optimize the int2f/12,4a handler a bit ~25 bytes (mostly from Arkady) git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@844 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/inthndlr.c | 143 ++++++++++++++++++++++------------------------ 1 file changed, 67 insertions(+), 76 deletions(-) diff --git a/kernel/inthndlr.c b/kernel/inthndlr.c index 076907a2..8fc5b71d 100644 --- a/kernel/inthndlr.c +++ b/kernel/inthndlr.c @@ -1756,9 +1756,8 @@ STATIC VOID StartTrace(VOID) } #endif -/* - this function is called from an assembler wrapper function - and serves the internal dos calls - int2f/12xx +/* this function is called from an assembler wrapper function + and serves the internal dos calls - int2f/12xx and int2f/4a01,4a02. */ struct int2f12regs { #ifdef I386 @@ -1769,7 +1768,8 @@ struct int2f12regs { #endif #endif UWORD es, ds; - UWORD di, si, bp, bx, dx, cx, ax; + UWORD di, si, bp; + xreg b, d, c, a; UWORD ip, cs, flags; UWORD callerARG1; /* used if called from INT2F/12 */ }; @@ -1777,71 +1777,65 @@ struct int2f12regs { extern short AllocateHMASpace (size_t lowbuffer, size_t highbuffer); /* WARNING: modifications in `r' are used outside of int2F_12_handler() - * On input r.ax==0x12xx, 0x4A01 or 0x4A02 + * On input r.AX==0x12xx, 0x4A01 or 0x4A02 */ VOID ASMCFUNC int2F_12_handler(struct int2f12regs r) { - UWORD function = r.ax & 0xff; - /* dont use QueryFreeHMASpace(&p); here; DS !=SS */ - if ((r.ax & 0xff00) == 0x4a00) + if (r.AH == 0x4a) { size_t wantedBytes, offs; - if (function != 1 && function != 2) + if (r.AL != 1 && r.AL != 2) return; - wantedBytes = r.bx; - r.es = r.di = 0xffff; - r.bx = 0; + wantedBytes = r.BX; + r.ES = r.DI = 0xffff; + r.BX = 0; if (FP_SEG(firstAvailableBuf) != 0xffff) return; offs = FP_OFF(firstAvailableBuf); r.di = offs; - if (function == 0x02) + if (r.AL == 0x02) { if (wantedBytes > ~offs) return; AllocateHMASpace(FP_OFF(firstAvailableBuf), FP_OFF(firstAvailableBuf)+wantedBytes); firstAvailableBuf += wantedBytes; - r.bx = wantedBytes; + r.BX = wantedBytes; } return; } - if (function > 0x31) - return; - - switch (function) + switch (r.AL) { case 0x00: /* installation check */ - r.ax |= 0x00ff; + r.AL = 0xff; break; case 0x03: /* get DOS data segment */ - r.ds = FP_SEG(&nul_dev); + r.DS = FP_SEG(&nul_dev); break; case 0x06: /* invoke critical error */ /* code, drive number, error, device header */ - r.ax &= 0xff00; - r.ax |= CriticalError(r.callerARG1 >> 8, - (r.callerARG1 & (EFLG_CHAR << 8)) ? 0 : r. - callerARG1 & 0xff, r.di, MK_FP(r.bp, r.si)); + r.AL = CriticalError(r.callerARG1 >> 8, + (r.callerARG1 & (EFLG_CHAR << 8)) ? 0 : + r.callerARG1 & 0xff, r.DI, MK_FP(r.BP, r.SI)); break; case 0x08: /* decrease SFT reference count */ { - sft FAR *p = MK_FP(r.es, r.di); + sft FAR *p = MK_FP(r.ES, r.DI); - r.ax = p->sft_count; + r.AX = p->sft_count; if (--p->sft_count == 0) --p->sft_count; @@ -1867,15 +1861,15 @@ VOID ASMCFUNC int2F_12_handler(struct int2f12regs r) case 0x0d: /* get dos date/time */ - r.ax = dos_getdate(); - r.dx = dos_gettime(); + r.AX = dos_getdate(); + r.DX = dos_gettime(); break; case 0x11: /* normalise ASCIIZ filename */ { char c; - char FAR *s = MK_FP(r.ds, r.si); - char FAR *t = MK_FP(r.es, r.di); + char FAR *s = MK_FP(r.DS, r.SI); + char FAR *t = MK_FP(r.ES, r.DI); do { @@ -1894,16 +1888,16 @@ VOID ASMCFUNC int2F_12_handler(struct int2f12regs r) case 0x12: /* get length of asciiz string */ - r.cx = fstrlen(MK_FP(r.es, r.di)) + 1; + r.CX = fstrlen(MK_FP(r.ES, r.DI)) + 1; break; case 0x13: /* uppercase character */ /* for now, ASCII only because nls.c cannot handle DS!=SS */ - r.ax = (unsigned char)r.callerARG1; - if (r.ax >= 'a' && r.ax <= 'z') - r.ax -= 'a' - 'A'; + r.AX = (unsigned char)r.callerARG1; + if (r.AX >= 'a' && r.AX <= 'z') + r.AX -= 'a' - 'A'; break; case 0x16: @@ -1913,17 +1907,17 @@ VOID ASMCFUNC int2F_12_handler(struct int2f12regs r) ES:DI pointer to SFT entry BX relative entry number within SFT */ { - int rel_idx = idx_to_sft_(r.bx); + int rel_idx = idx_to_sft_(r.BX); if (rel_idx == -1) { - r.flags |= FLG_CARRY; + r.FLAGS |= FLG_CARRY; break; } - r.flags &= ~FLG_CARRY; - r.bx = rel_idx; - r.es = FP_SEG(lpCurSft); - r.di = FP_OFF(lpCurSft); + r.FLAGS &= ~FLG_CARRY; + r.BX = rel_idx; + r.ES = FP_SEG(lpCurSft); + r.DI = FP_OFF(lpCurSft); break; } @@ -1944,25 +1938,25 @@ VOID ASMCFUNC int2F_12_handler(struct int2f12regs r) struct cds FAR *cdsp = get_cds(r.callerARG1 & 0xff); if (cdsp == NULL) - r.flags |= FLG_CARRY; - else { - r.ds = FP_SEG(cdsp); - r.si = FP_OFF(cdsp); - r.flags &= ~FLG_CARRY; + r.FLAGS |= FLG_CARRY; + break; } + r.DS = FP_SEG(cdsp); + r.SI = FP_OFF(cdsp); + r.FLAGS &= ~FLG_CARRY; break; } case 0x18: /* get caller's registers */ - r.ds = FP_SEG(user_r); - r.si = FP_OFF(user_r); + r.DS = FP_SEG(user_r); + r.SI = FP_OFF(user_r); break; case 0x1b: /* #days in February - valid until 2099. */ - r.ax = (r.ax & 0xff00) | (r.cx & 3 ? 28 : 29); + r.AL = (r.CL & 3) ? 28 : 29; break; case 0x20: /* get job file table entry */ @@ -1970,22 +1964,22 @@ VOID ASMCFUNC int2F_12_handler(struct int2f12regs r) psp FAR *p = MK_FP(cu_psp, 0); unsigned char FAR *idx; - if (r.bx >= p->ps_maxfiles) + if (r.BX >= p->ps_maxfiles) { - r.ax = (r.ax & 0xff00) | (-DE_INVLDHNDL); - r.flags |= FLG_CARRY; + r.AL = -DE_INVLDHNDL; + r.FLAGS |= FLG_CARRY; break; } - idx = &p->ps_filetab[r.bx]; - r.flags &= ~FLG_CARRY; - r.es = FP_SEG(idx); - r.di = FP_OFF(idx); + idx = &p->ps_filetab[r.BX]; + r.FLAGS &= ~FLG_CARRY; + r.ES = FP_SEG(idx); + r.DI = FP_OFF(idx); } break; case 0x21: /* truename */ - DosTruename(MK_FP(r.ds, r.si), MK_FP(r.es, r.di)); + DosTruename(MK_FP(r.DS, r.SI), MK_FP(r.ES, r.DI)); break; @@ -1995,36 +1989,32 @@ VOID ASMCFUNC int2F_12_handler(struct int2f12regs r) dhp = IsDevice((BYTE FAR *) DirEntBuffer.dir_name); - if (dhp) - { - r.bx = (r.bx & 0xff) | (dhp->dh_attr << 8); - r.flags &= ~FLG_CARRY; - } - else + if (dhp == NULL) { - r.flags |= FLG_CARRY; + r.FLAGS |= FLG_CARRY; + break; } - + r.BH = dhp->dh_attr; + r.FLAGS &= ~FLG_CARRY; } - break; case 0x25: /* get length of asciiz string */ - r.cx = fstrlen(MK_FP(r.ds, r.si)) + 1; + r.CX = fstrlen(MK_FP(r.DS, r.SI)) + 1; break; case 0x2a: /* Set FastOpen but does nothing. */ - r.flags &= ~FLG_CARRY; + r.FLAGS &= ~FLG_CARRY; break; case 0x2c: /* added by James Tabor For Zip Drives Return Null Device Pointer */ /* by UDOS+RBIL: get header of SECOND device driver in device chain, omitting the NUL device TE */ - r.bx = FP_SEG(nul_dev.dh_next); - r.ax = FP_OFF(nul_dev.dh_next); + r.BX = FP_SEG(nul_dev.dh_next); + r.AX = FP_OFF(nul_dev.dh_next); break; @@ -2034,14 +2024,15 @@ VOID ASMCFUNC int2F_12_handler(struct int2f12regs r) break; default: - put_string("unimplemented internal dos function INT2F/12"); - put_unsigned(function, 16, 2); - put_string("\n"); - r.flags |= FLG_CARRY; - break; - + if (r.AL <= 0x31) + { + put_string("unimplemented internal dos function INT2F/12"); + put_unsigned(r.AL, 16, 2); + put_string("\n"); + r.FLAGS |= FLG_CARRY; + break; + } } - } /* From 7ae98cee2acce9845b2645b151e72c419cea6e6f Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Wed, 7 Apr 2004 16:13:23 +0000 Subject: [PATCH 423/671] Introduce VA_CDECL: only Turbo C 2.01 needs an explicit cdecl for printf, all other compilers can use it with pascal or "register" calling conventions. Saves ~50 bytes for the init code. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@845 6ac86273-5f31-0410-b378-82cca8765d1b --- hdr/portab.h | 8 ++++++++ kernel/init-mod.h | 4 ++-- kernel/prf.c | 6 +++--- kernel/proto.h | 4 ++-- sys/fdkrncfg.c | 4 ++-- sys/sys.c | 4 ++-- 6 files changed, 19 insertions(+), 11 deletions(-) diff --git a/hdr/portab.h b/hdr/portab.h index 733b0bad..3dc25af4 100644 --- a/hdr/portab.h +++ b/hdr/portab.h @@ -63,6 +63,12 @@ static char *portab_hRcsId = #define I86 #define CDECL cdecl +#if __TURBOC__ > 0x202 +/* printf callers do the right thing for tc++ 1.01 but not tc 2.01 */ +#define VA_CDECL +#else +#define VA_CDECL cdecl +#endif #define PASCAL pascal void __int__(int); @@ -73,6 +79,7 @@ void __int__(int); #pragma warning(disable: 4761) /* "integral size mismatch in argument; conversion supplied" */ #define CDECL _cdecl +#define VA_CDECL #define PASCAL pascal #define __int__(intno) asm int intno; #define _SS SS() @@ -88,6 +95,7 @@ static unsigned short __inline SS(void) #define asm __asm #define far __far #define CDECL __cdecl +#define VA_CDECL #define PASCAL pascal #define _SS SS() unsigned short SS(void); diff --git a/kernel/init-mod.h b/kernel/init-mod.h index 1acb9da7..e77bca6d 100644 --- a/kernel/init-mod.h +++ b/kernel/init-mod.h @@ -179,8 +179,8 @@ BOOL init_device(struct dhdr FAR * dhp, char * cmdLine, VOID init_fatal(BYTE * err_msg); /* prf.c */ -WORD CDECL init_printf(CONST BYTE * fmt, ...); -WORD CDECL init_sprintf(BYTE * buff, CONST BYTE * fmt, ...); +int VA_CDECL init_printf(const char * fmt, ...); +int VA_CDECL init_sprintf(char * buff, const char * fmt, ...); /* procsupt.asm */ VOID ASMCFUNC FAR got_cbreak(void); diff --git a/kernel/prf.c b/kernel/prf.c index 0f849cb1..d882ca4e 100644 --- a/kernel/prf.c +++ b/kernel/prf.c @@ -144,7 +144,7 @@ static BYTE *charp = 0; STATIC VOID handle_char(COUNT); STATIC void ltob(LONG, BYTE *, COUNT); STATIC void do_printf(const char *, REG va_list); -int CDECL printf(CONST BYTE * fmt, ...); +int VA_CDECL printf(const char * fmt, ...); /* special handler to switch between sprintf and printf */ STATIC VOID handle_char(COUNT c) @@ -196,7 +196,7 @@ STATIC void ltob(LONG n, BYTE * s, COUNT base) #define LONGARG 4 /* printf -- short version of printf to conserve space */ -int CDECL printf(CONST BYTE * fmt, ...) +int VA_CDECL printf(const char *fmt, ...) { va_list arg; va_start(arg, fmt); @@ -205,7 +205,7 @@ int CDECL printf(CONST BYTE * fmt, ...) return 0; } -int CDECL sprintf(BYTE * buff, CONST BYTE * fmt, ...) +int VA_CDECL sprintf(char * buff, const char * fmt, ...) { va_list arg; diff --git a/kernel/proto.h b/kernel/proto.h index 44472e11..c6e8c66e 100644 --- a/kernel/proto.h +++ b/kernel/proto.h @@ -281,8 +281,8 @@ UWORD ASMCFUNC syscall_MUX14(DIRECT_IREGS); /* prf.c */ #ifdef DEBUG -int CDECL printf(CONST BYTE * fmt, ...); -int CDECL sprintf(BYTE * buff, CONST BYTE * fmt, ...); +int VA_CDECL printf(const char * fmt, ...); +int VA_CDECL sprintf(char * buff, const char * fmt, ...); #endif VOID hexd(char *title, VOID FAR * p, COUNT numBytes); void put_unsigned(unsigned n, int base, int width); diff --git a/sys/fdkrncfg.c b/sys/fdkrncfg.c index 28b6c8a9..941e1961 100644 --- a/sys/fdkrncfg.c +++ b/sys/fdkrncfg.c @@ -24,8 +24,8 @@ char KERNEL[] = "KERNEL.SYS"; #include #include "portab.h" -extern int CDECL printf(CONST BYTE * fmt, ...); -extern int CDECL sprintf(BYTE * buff, CONST BYTE * fmt, ...); +extern int VA_CDECL printf(const char * fmt, ...); +extern int VA_CDECL sprintf(char * buff, const char * fmt, ...); #ifdef __WATCOMC__ unsigned _dos_close(int handle); diff --git a/sys/sys.c b/sys/sys.c index 37e4f65a..a145f275 100644 --- a/sys/sys.c +++ b/sys/sys.c @@ -59,8 +59,8 @@ * #including to make executable MUCH smaller * using [s]printf from prf.c! */ -extern WORD CDECL printf(CONST BYTE * fmt, ...); -extern WORD CDECL sprintf(BYTE * buff, CONST BYTE * fmt, ...); +extern int VA_CDECL printf(const char * fmt, ...); +extern int VA_CDECL sprintf(char * buff, const char * fmt, ...); #include "fat12com.h" #include "fat16com.h" From 0897ba9b3835e0b2251a4eee6cb72fbd1126c5d3 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Wed, 7 Apr 2004 16:16:07 +0000 Subject: [PATCH 424/671] Use the "-r" switch for Watcom to preserve ES around calls -- saves ~350 bytes. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@846 6ac86273-5f31-0410-b378-82cca8765d1b --- mkfiles/watcom.mak | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mkfiles/watcom.mak b/mkfiles/watcom.mak index 8e111ca8..32b3d49c 100644 --- a/mkfiles/watcom.mak +++ b/mkfiles/watcom.mak @@ -61,7 +61,7 @@ MATH_INSERT=+i4m # -3 optimization for 386 - given in CONFIG.MAK, not here # -ALLCFLAGS=-I..\hdr $(TARGETOPT) $(ALLCFLAGS)-zq-os-s-e5-j-zl-zp1-wx-we-zgf-zff +ALLCFLAGS=-I..\hdr $(TARGETOPT) $(ALLCFLAGS)-zq-os-s-e5-j-zl-zp1-wx-we-zgf-zff-r INITCFLAGS=$(ALLCFLAGS)-ntINIT_TEXT-ndI CFLAGS=$(ALLCFLAGS)-ntHMA_TEXT INITPATCH=..\utils\patchobj __U4D=_IU4D __U4M=_IU4M From 00e9730e32078235630f0de41611576161c01332 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Fri, 9 Apr 2004 11:01:34 +0000 Subject: [PATCH 425/671] Fix typo git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@847 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/asmsupt.asm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/asmsupt.asm b/kernel/asmsupt.asm index 0edc43c0..c661b8a6 100644 --- a/kernel/asmsupt.asm +++ b/kernel/asmsupt.asm @@ -242,7 +242,7 @@ MEMSET: ;***** pascal_return: - lds di, [bp] ; return address in es, saved bp in di + lds di, [bp] ; return address in ds, saved bp in di mov bh, 0 add bp, bx ; point bp to "as if there were 0 args" mov [bp+2], ds ; put return address at first arg From a7ca14c46cfc409af8c1fc12996cfa69768b3e92 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Fri, 9 Apr 2004 11:16:03 +0000 Subject: [PATCH 426/671] Use pascal calling conventions for execrh(). git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@848 6ac86273-5f31-0410-b378-82cca8765d1b --- hdr/device.h | 2 +- kernel/execrh.asm | 30 +++++++++++++++--------------- kernel/init-mod.h | 2 +- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/hdr/device.h b/hdr/device.h index 156a7372..6f07d528 100644 --- a/hdr/device.h +++ b/hdr/device.h @@ -467,7 +467,7 @@ COUNT block_error(request * rq, COUNT nDrive, struct dhdr FAR * lpDevice, int mo WORD ASMCFUNC FAR clk_driver(rqptr rp); /* execrh.asm */ -WORD ASMCFUNC execrh(request FAR *, struct dhdr FAR *); +WORD ASMPASCAL execrh(request FAR *, struct dhdr FAR *); /* * end of device.h diff --git a/kernel/execrh.asm b/kernel/execrh.asm index 91740820..66d0d63b 100644 --- a/kernel/execrh.asm +++ b/kernel/execrh.asm @@ -31,7 +31,7 @@ %include "segs.inc" segment HMA_TEXT - ; _execrh + ; EXECRH ; Execute Device Request ; ; execrh(rhp, dhp) @@ -41,47 +41,47 @@ segment HMA_TEXT ; ; The stack is very critical in here. ; - global _execrh - global _init_execrh + global EXECRH + global INIT_EXECRH -%macro EXECRH 0 +%macro EXECRHM 0 push bp ; perform c entry mov bp,sp push si push ds ; sp=bp-8 - lds si,[bp+8] ; ds:si = device header - les bx,[bp+4] ; es:bx = request header + lds si,[bp+4] ; ds:si = device header + les bx,[bp+8] ; es:bx = request header mov ax, [si+6] ; construct strategy address - mov [bp+8], ax + mov [bp+4], ax push si ; the bloody fucking RTSND.DOS push di ; driver destroys SI,DI (tom 14.2.03) - call far[bp+8] ; call far the strategy + call far[bp+4] ; call far the strategy pop di pop si mov ax,[si+8] ; construct 'interrupt' address - mov [bp+8],ax ; construct interrupt address - call far[bp+8] ; call far the interrupt + mov [bp+4],ax ; construct interrupt address + call far[bp+4] ; call far the interrupt sti ; damm driver turn off ints cld ; has gone backwards pop ds pop si pop bp - ret + ret 8 %endmacro -_execrh: - EXECRH +EXECRH: + EXECRHM segment INIT_TEXT -_init_execrh: - EXECRH +INIT_EXECRH: + EXECRHM diff --git a/kernel/init-mod.h b/kernel/init-mod.h index e77bca6d..71997534 100644 --- a/kernel/init-mod.h +++ b/kernel/init-mod.h @@ -46,7 +46,7 @@ extern struct _KernelConfig InitKernelConfig; #define fstrlen init_fstrlen /* execrh.asm */ -WORD ASMCFUNC execrh(request FAR *, struct dhdr FAR *); +WORD ASMPASCAL execrh(request FAR *, struct dhdr FAR *); /* asmsupt.asm */ VOID ASMPASCAL memset( void *s, int ch, size_t n); From 950078ad08d0cdf6b1c6d7d29a283571284c12f4 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Fri, 9 Apr 2004 11:37:40 +0000 Subject: [PATCH 427/671] Use the pascal calling convention for most intr.asm functions, and let them pop the stack (smaller code than using bx). Tell Watcom which registers are clobbered; save some more registers for intr() -- especially for intr() this helps. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@849 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/init-mod.h | 39 ++++++--- kernel/intr.asm | 213 +++++++++++++++++++++++++--------------------- kernel/proto.h | 40 ++++++++- 3 files changed, 183 insertions(+), 109 deletions(-) diff --git a/kernel/init-mod.h b/kernel/init-mod.h index 71997534..83001707 100644 --- a/kernel/init-mod.h +++ b/kernel/init-mod.h @@ -44,6 +44,7 @@ extern struct _KernelConfig InitKernelConfig; #define strcpy init_strcpy #define strlen init_strlen #define fstrlen init_fstrlen +#define open init_DosOpen /* execrh.asm */ WORD ASMPASCAL execrh(request FAR *, struct dhdr FAR *); @@ -133,18 +134,32 @@ unsigned ebdasize(void); /* intr.asm */ -void ASMCFUNC init_call_intr(int nr, iregs * rp); -UCOUNT ASMCFUNC read(int fd, void *buf, UCOUNT count); -int ASMCFUNC open(const char *pathname, int flags); -int ASMCFUNC close(int fd); -int ASMCFUNC dup2(int oldfd, int newfd); -int ASMCFUNC allocmem(UWORD size, seg * segp); -VOID ASMCFUNC init_PSPSet(seg psp_seg); -COUNT ASMCFUNC init_DosExec(COUNT mode, exec_blk * ep, BYTE * lp); -int ASMCFUNC init_setdrive(int drive); -int ASMCFUNC init_switchar(int chr); -VOID ASMCFUNC keycheck(VOID); -void ASMCFUNC set_DTA(void far *dta); +unsigned ASMPASCAL init_call_intr(int nr, iregs * rp); +unsigned ASMPASCAL read(int fd, void *buf, unsigned count); +int ASMPASCAL open(const char *pathname, int flags); +int ASMPASCAL close(int fd); +int ASMPASCAL dup2(int oldfdk, int newfd); +int ASMPASCAL allocmem(UWORD size, seg * segp); +void ASMPASCAL init_PSPSet(seg psp_seg); +int ASMPASCAL init_DosExec(int mode, exec_blk * ep, char * lp); +int ASMPASCAL init_setdrive(int drive); +int ASMPASCAL init_switchar(int chr); +void ASMPASCAL keycheck(void); +void ASMPASCAL set_DTA(void far *dta); +#ifdef __WATCOMC__ +#pragma aux (pascal) init_call_intr modify exact [ax] +#pragma aux (pascal) read modify exact [ax bx cx dx] +#pragma aux (pascal) init_DosOpen modify exact [ax bx dx] +#pragma aux (pascal) close modify exact [ax bx] +#pragma aux (pascal) dup2 modify exact [ax bx cx] +#pragma aux (pascal) allocmem modify exact [ax bx dx] +#pragma aux (pascal) init_PSPSet modify exact [ax bx] +#pragma aux (pascal) init_DosExec modify exact [ax bx dx es] +#pragma aux (pascal) init_setdrive modify exact [ax bx dx] +#pragma aux (pascal) init_switchar modify exact [ax bx dx] +#pragma aux (pascal) keycheck modify exact [ax] +#pragma aux (pascal) set_DTA modify exact [ax bx dx] +#endif /* irqstack.asm */ VOID ASMCFUNC init_stacks(VOID FAR * stack_base, COUNT nStacks, diff --git a/kernel/intr.asm b/kernel/intr.asm index c7c305e7..57d31413 100644 --- a/kernel/intr.asm +++ b/kernel/intr.asm @@ -33,13 +33,18 @@ mov bp,sp push si push di - push ds +%ifdef WATCOM + push bx + push cx + push dx push es +%endif + push ds - mov ax, [bp+4] ; interrupt number + mov ax, [bp+6] ; interrupt number mov [cs:%%intr_1-1], al jmp short %%intr_2 ; flush the instruction cache -%%intr_2 mov bx, [bp+6] ; regpack structure +%%intr_2 mov bx, [bp+4] ; regpack structure mov ax, [bx] mov cx, [bx+4] mov dx, [bx+6] @@ -57,8 +62,12 @@ push ds push bx mov bx, sp - mov ds, [ss:bx+8] - mov bx, [ss:bx+20] ; address of REGPACK + mov ds, [ss:bx+6] +%ifdef WATCOM + mov bx, [ss:bx+24] ; address of REGPACK +%else + mov bx, [ss:bx+16] ; address of REGPACK +%endif mov [bx], ax pop word [bx+2] mov [bx+4], cx @@ -70,39 +79,46 @@ mov [bx+16], es pop word [bx+22] - pop es pop ds +%ifdef WATCOM + pop es + pop dx + pop cx + pop bx +%endif pop di pop si pop bp - ret + ret 4 %endmacro segment HMA_TEXT -;; COUNT ASMCFUNC res_DosExec(COUNT mode, exec_blk * ep, BYTE * lp) - global _res_DosExec -_res_DosExec: +;; COUNT ASMPASCAL res_DosExec(COUNT mode, exec_blk * ep, BYTE * lp) + global RES_DOSEXEC +RES_DOSEXEC: + pop es ; ret address + pop dx ; filename + pop bx ; exec block + pop ax ; mode + push es ; ret address mov ah, 4bh - mov bx, sp - mov al, [bx+2] - push ds - pop es - mov dx, [bx+6] ; filename - mov bx, [bx+4] ; exec block + push ds + pop es ; es = ds int 21h jc short no_exec_error xor ax, ax no_exec_error: ret -;; UCOUNT ASMCFUNC res_read(int fd, void *buf, UCOUNT count); - global _res_read -_res_read: - mov bx, sp - mov cx, [bx+6] - mov dx, [bx+4] - mov bx, [bx+2] +;; UCOUNT ASMPASCAL res_read(int fd, void *buf, UCOUNT count); + global RES_READ +RES_READ: + pop ax ; ret address + pop cx ; count + pop dx ; buf + pop bx ; fd + push ax ; ret address mov ah, 3fh int 21h jnc no_read_error @@ -116,8 +132,8 @@ segment INIT_TEXT ; REG int nr ; REG struct REGPACK *rp ; - global _init_call_intr -_init_call_intr: + global INIT_CALL_INTR +INIT_CALL_INTR: INTR ; @@ -161,25 +177,25 @@ detected: pop es ret -global _keycheck -_keycheck: +global KEYCHECK +KEYCHECK: mov ah, 1 int 16h ret ;; int open(const char *pathname, int flags); - global _open -_open: - ;; first implementation of init calling DOS through ints: - mov bx, sp + global INIT_DOSOPEN +INIT_DOSOPEN: + ;; init calling DOS through ints: + pop bx ; ret address + pop ax ; flags + pop dx ; pathname + push bx ; ret address mov ah, 3dh - ;; we know that SS=DS during init stage. - mov al, [bx+4] - mov dx, [bx+2] - int 21h - ;; AX has file handle + ;; AX will have the file handle -common_exit: +common_int21: + int 21h jnc common_no_error common_error: mov ax, -1 @@ -187,54 +203,56 @@ common_no_error: ret ;; int close(int fd); - global _close -_close: - mov bx, sp - mov bx, [bx+2] + global CLOSE +CLOSE: + pop ax ; ret address + pop bx ; fd + push ax ; ret address mov ah, 3eh - int 21h - jmp short common_exit + jmp short common_int21 ;; UCOUNT read(int fd, void *buf, UCOUNT count); - global _read -_read: - mov bx, sp - mov cx, [bx+6] - mov dx, [bx+4] - mov bx, [bx+2] + global READ +READ: + pop ax ; ret address + pop cx ; count + pop dx ; buf + pop bx ; fd + push ax ; ret address mov ah, 3fh - int 21h - jmp short common_exit + jmp short common_int21 ;; int dup2(int oldfd, int newfd); - global _dup2 -_dup2: - mov bx, sp - mov cx, [bx+4] - mov bx, [bx+2] + global DUP2 +DUP2: + pop ax ; ret address + pop cx ; newfd + pop bx ; oldfd + push ax ; ret address mov ah, 46h - int 21h - jmp short common_exit + jmp short common_int21 ;; VOID init_PSPSet(seg psp_seg) - global _init_PSPSet -_init_PSPSet: + global INIT_PSPSET +INIT_PSPSET: + pop ax ; ret address + pop bx ; psp_seg + push ax ; ret_address mov ah, 50h - mov bx, sp - mov bx, [bx+2] - int 21h - ret + int 21h + ret ;; COUNT init_DosExec(COUNT mode, exec_blk * ep, BYTE * lp) - global _init_DosExec -_init_DosExec: + global INIT_DOSEXEC +INIT_DOSEXEC: + pop es ; ret address + pop dx ; filename + pop bx ; exec block + pop ax ; mode + push es ; ret address mov ah, 4bh - mov bx, sp - mov al, [bx+2] - push ds - pop es - mov dx, [bx+6] ; filename - mov bx, [bx+4] ; exec block + push ds + pop es ; es = ds int 21h jc short exec_no_error xor ax, ax @@ -242,42 +260,47 @@ exec_no_error: ret ;; int init_setdrive(int drive) - global _init_setdrive -_init_setdrive: + global INIT_SETDRIVE +INIT_SETDRIVE: mov ah, 0x0e common_dl_int21: - mov bx, sp - mov dl, [bx+2] - int 21h - ret + pop bx ; ret address + pop dx ; drive/char + push bx + int 21h + ret ;; int init_switchar(int char) - global _init_switchar -_init_switchar: + global INIT_SWITCHAR +INIT_SWITCHAR: mov ax, 0x3701 jmp short common_dl_int21 ;; int allocmem(UWORD size, seg *segp) - global _allocmem -_allocmem: + global ALLOCMEM +ALLOCMEM: + pop ax ; ret address + pop dx ; segp + pop bx ; size + push ax ; ret address mov ah, 48h - mov bx, sp - mov bx, [bx+2] int 21h jc short common_error - mov bx, sp - mov bx, [bx+4] + mov bx, dx ; segp mov [bx], ax xor ax, ax ret ;; void set_DTA(void far *dta) - global _set_DTA -_set_DTA - mov ah, 1ah - mov bx, sp - push ds - lds dx, [bx+2] - int 21h - pop ds - ret + global SET_DTA +SET_DTA: + pop ax ; ret address + pop bx ; seg(dta) + pop dx ; off(dta) + push ax ; ret address + mov ah, 1ah + push ds + mov ds, bx + int 21h + pop ds + ret diff --git a/kernel/proto.h b/kernel/proto.h index c6e8c66e..421e8c68 100644 --- a/kernel/proto.h +++ b/kernel/proto.h @@ -123,6 +123,9 @@ COUNT DosTruename(const char FAR * src, char FAR * dest); /*dosidle.asm */ VOID ASMCFUNC DosIdle_int(void); +#ifdef __WATCOMC__ +#pragma aux (cdecl) DosIdle_int modify exact [] +#endif /* dosnames.c */ int ParseDosName(const char *, char *, BOOL); @@ -222,8 +225,12 @@ void FcbCloseAll(void); UBYTE FcbFindFirstNext(xfcb FAR * lpXfcb, BOOL First); /* intr.asm */ -COUNT ASMCFUNC res_DosExec(COUNT mode, exec_blk * ep, BYTE * lp); -UCOUNT ASMCFUNC res_read(int fd, void *buf, UCOUNT count); +COUNT ASMPASCAL res_DosExec(COUNT mode, exec_blk * ep, BYTE * lp); +UCOUNT ASMPASCAL res_read(int fd, void *buf, UCOUNT count); +#ifdef __WATCOMC__ +#pragma aux (pascal) res_DosExec modify exact [ax bx dx es] +#pragma aux (pascal) res_read modify exact [ax bx cx dx] +#endif /* ioctl.c */ COUNT DosDevIOctl(lregs * r); @@ -398,6 +405,35 @@ COUNT ASMCFUNC remote_printredir(UCOUNT dx, UCOUNT ax); COUNT ASMCFUNC remote_commit(sft FAR * s); COUNT ASMCFUNC remote_close(sft FAR * s); COUNT ASMCFUNC QRemote_Fn(char FAR * d, const char FAR * s); +#ifdef __WATCOMC__ +/* bx, cx, and es not used or clobbered for all remote functions, + * except lock_unlock and process_end */ +#pragma aux cdecl_axdx "_*" parm caller [] modify exact [ax dx] +#pragma aux (cdecl_axdx) remote_doredirect +#pragma aux (cdecl_axdx) remote_printset +#pragma aux (cdecl_axdx) remote_rename +#pragma aux (cdecl_axdx) remote_delete +#pragma aux (cdecl_axdx) remote_chdir +#pragma aux (cdecl_axdx) remote_mkdir +#pragma aux (cdecl_axdx) remote_rmdir +#pragma aux (cdecl_axdx) remote_close_all +#pragma aux (cdecl_axdx) remote_flushall +#pragma aux (cdecl_axdx) remote_findfirst +#pragma aux (cdecl_axdx) remote_findnext +#pragma aux (cdecl_axdx) remote_getfattr +#pragma aux (cdecl_axdx) remote_getfree +#pragma aux (cdecl_axdx) remote_open +#pragma aux (cdecl_axdx) remote_extopen +#pragma aux (cdecl_axdx) remote_lseek +#pragma aux (cdecl_axdx) remote_read +#pragma aux (cdecl_axdx) remote_write +#pragma aux (cdecl_axdx) remote_creat +#pragma aux (cdecl_axdx) remote_setfattr +#pragma aux (cdecl_axdx) remote_printredir +#pragma aux (cdecl_axdx) remote_commit +#pragma aux (cdecl_axdx) remote_close +#pragma aux (cdecl_axdx) QRemote_Fn +#endif UWORD get_machine_name(BYTE FAR * netname); VOID set_machine_name(BYTE FAR * netname, UWORD name_num); From 7012672d7dda46ba568d5020750f123844b3ac0f Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Fri, 9 Apr 2004 13:11:25 +0000 Subject: [PATCH 428/671] Use pascal calling conventions for floppy asm functions. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@850 6ac86273-5f31-0410-b378-82cca8765d1b --- drivers/floppy.asm | 88 +++++++++++++++++++++------------------------- kernel/dsk.c | 46 ++++++++++-------------- 2 files changed, 58 insertions(+), 76 deletions(-) diff --git a/drivers/floppy.asm b/drivers/floppy.asm index 45747f8e..3d9a5d56 100644 --- a/drivers/floppy.asm +++ b/drivers/floppy.asm @@ -28,12 +28,8 @@ ; $Id$ ; -%ifndef SYS %include "../kernel/segs.inc" segment HMA_TEXT -%else - segment _TEXT class=CODE -%endif ; ; ; Reset both the diskette and hard disk system @@ -43,12 +39,11 @@ ; returns TRUE if successful ; - global _fl_reset -_fl_reset: + global FL_RESET +FL_RESET: pop ax ; return address pop dx ; drive - push dx ; restore stack - push ax ; + push ax ; restore address mov ah,0 ; BIOS reset diskette & fixed disk int 13h @@ -66,14 +61,15 @@ _fl_reset: ; returns 1 if disk has changed, 0 if not, 0xFFFF if error ; - global _fl_diskchanged -_fl_diskchanged: + global FL_DISKCHANGED +FL_DISKCHANGED: pop ax ; return address pop dx ; get the drive number - push dx ; restore stack - push ax ; + push ax ; restore stack + push si ; restore stack mov ah,16h ; read change status type + xor si,si ; RBIL: avoid crash on AT&T 6300 int 13h mov al,1 @@ -85,6 +81,7 @@ _fl_diskchanged: fl_dc_ret1: dec ax fl_dc_ret: cbw + pop si ret ; @@ -95,8 +92,8 @@ fl_dc_ret: cbw ; Formats one or more tracks, sector should be 0. ; ; Returns 0 if successful, error code otherwise. - global _fl_format -_fl_format: + global FL_FORMAT +FL_FORMAT: mov ah, 5 jmp short fl_common ; @@ -117,25 +114,25 @@ _fl_format: ; ; Returns 0 if successful, error code otherwise. ; - global _fl_read -_fl_read: + global FL_READ +FL_READ: mov ah,2 ; cmd READ jmp short fl_common - global _fl_verify -_fl_verify: + global FL_VERIFY +FL_VERIFY: mov ah,4 ; cmd verify jmp short fl_common - global _fl_write -_fl_write: + global FL_WRITE +FL_WRITE: mov ah,3 ; cmd WRITE fl_common: push bp ; C entry mov bp,sp - mov cx,[bp+8] ; cylinder number (lo only if hard) + mov cx,[bp+0Ch] ; cylinder number (lo only if hard) mov al,1 ; this should be an error code cmp ch,3 ; this code can't write above 3ff=1023 @@ -146,12 +143,12 @@ fl_common: ror cl,1 or cl,[bp+0Ah] ; or in the sector number (bits 0-5) - mov al,[bp+0Ch] ; count to read/write - les bx,[bp+0Eh] ; Load 32 bit buffer ptr + mov al,[bp+08h] ; count to read/write + les bx,[bp+04h] ; Load 32 bit buffer ptr - mov dl,[bp+4] ; get the drive (if or'ed 80h its + mov dl,[bp+10h] ; get the drive (if or'ed 80h its ; hard drive. - mov dh,[bp+6] ; get the head number + mov dh,[bp+0Eh] ; get the head number int 13h ; write sectors from mem es:bx @@ -161,24 +158,24 @@ fl_common: fl_error: mov ah,0 ; force into < 255 count pop bp - ret + ret 14 ; COUNT fl_lba_ReadWrite(BYTE drive, UWORD mode, VOID FAR *dap_p) ; ; Returns 0 if successful, error code otherwise. ; - global _fl_lba_ReadWrite -_fl_lba_ReadWrite: + global FL_LBA_READWRITE +FL_LBA_READWRITE: push bp ; C entry mov bp,sp push ds push si ; wasn't in kernel < KE2024Bo6!! - mov dl,[bp+4] ; get the drive (if ored 80h harddrive) - mov ax,[bp+6] ; get the command - lds si,[bp+8] ; get far dap pointer + mov dl,[bp+10] ; get the drive (if ored 80h harddrive) + mov ax,[bp+8] ; get the command + lds si,[bp+4] ; get far dap pointer int 13h ; read from/write to drive pop si @@ -188,25 +185,23 @@ _fl_lba_ReadWrite: ret_AH: mov al,ah ; place any error code into al mov ah,0 ; zero out ah - ret + ret 8 ; ; void fl_readkey (void); ; -global _fl_readkey -_fl_readkey: xor ah, ah +global FL_READKEY +FL_READKEY: xor ah, ah int 16h ret -global _fl_setdisktype -_fl_setdisktype: +global FL_SETDISKTYPE +FL_SETDISKTYPE: pop bx ; return address - pop dx ; drive number (dl) pop ax ; disk type (al) - push ax ; restore stack - push dx - push bx + pop dx ; drive number (dl) + push bx ; restore stack mov ah,17h int 13h jmp short ret_AH @@ -214,16 +209,13 @@ _fl_setdisktype: ; ; COUNT fl_setmediatype (WORD drive, WORD tracks, WORD sectors); ; -global _fl_setmediatype -_fl_setmediatype: +global FL_SETMEDIATYPE +FL_SETMEDIATYPE: pop ax ; return address - pop dx ; drive number - pop cx ; number of tracks pop bx ; sectors/track - push bx ; restore stack - push cx - push dx - push ax + pop cx ; number of tracks + pop dx ; drive number + push ax ; restore stack push di dec cx ; should be highest track diff --git a/kernel/dsk.c b/kernel/dsk.c index 37af64aa..59d6a77c 100644 --- a/kernel/dsk.c +++ b/kernel/dsk.c @@ -41,39 +41,29 @@ static BYTE *dskRcsId = /* #define STATIC */ -#ifdef PROTO -BOOL ASMCFUNC fl_reset(WORD); -COUNT ASMCFUNC fl_readdasd(WORD); -COUNT ASMCFUNC fl_diskchanged(WORD); -COUNT ASMCFUNC fl_rd_status(WORD); - -COUNT ASMCFUNC fl_format(WORD, WORD, WORD, WORD, WORD, UBYTE FAR *); -COUNT ASMCFUNC fl_read(WORD, WORD, WORD, WORD, WORD, UBYTE FAR *); -COUNT ASMCFUNC fl_write(WORD, WORD, WORD, WORD, WORD, UBYTE FAR *); -COUNT ASMCFUNC fl_verify(WORD, WORD, WORD, WORD, WORD, UBYTE FAR *); -COUNT ASMCFUNC fl_setdisktype(WORD, WORD); -COUNT ASMCFUNC fl_setmediatype(WORD, WORD, WORD); -VOID ASMCFUNC fl_readkey(VOID); - -extern COUNT ASMCFUNC fl_lba_ReadWrite(BYTE drive, WORD mode, +BOOL ASMPASCAL fl_reset(WORD); +COUNT ASMPASCAL fl_diskchanged(WORD); + +COUNT ASMPASCAL fl_format(WORD, WORD, WORD, WORD, WORD, UBYTE FAR *); +COUNT ASMPASCAL fl_read(WORD, WORD, WORD, WORD, WORD, UBYTE FAR *); +COUNT ASMPASCAL fl_write(WORD, WORD, WORD, WORD, WORD, UBYTE FAR *); +COUNT ASMPASCAL fl_verify(WORD, WORD, WORD, WORD, WORD, UBYTE FAR *); +COUNT ASMPASCAL fl_setdisktype(WORD, WORD); +COUNT ASMPASCAL fl_setmediatype(WORD, WORD, WORD); +VOID ASMPASCAL fl_readkey(VOID); +extern COUNT ASMPASCAL fl_lba_ReadWrite(BYTE drive, WORD mode, struct _bios_LBA_address_packet FAR * dap_p); +#ifdef __WATCOMC__ +#pragma aux (pascal) fl_reset modify exact [ax dx] +#pragma aux (pascal) fl_diskchanged modify exact [ax dx] +#pragma aux (pascal) fl_setdisktype modify exact [ax bx dx] +#pragma aux (pascal) fl_readkey modify exact [ax] +#pragma aux (pascal) fl_lba_ReadWrite modify exact [ax dx] +#endif STATIC int LBA_Transfer(ddt * pddt, UWORD mode, VOID FAR * buffer, ULONG LBA_address, unsigned total, UWORD * transferred); -#else -BOOL ASMCFUNC fl_reset(); -COUNT ASMCFUNC fl_readdasd(); -COUNT ASMCFUNC fl_diskchanged(); -COUNT ASMCFUNC fl_rd_status(); -COUNT ASMCFUNC fl_format(); -COUNT ASMCFUNC fl_read(); -COUNT ASMCFUNC fl_write(); -COUNT ASMCFUNC fl_verify(); -VOID ASMCFUNC fl_readkey(); -COUNT ASMCFUNC fl_setmediatype(); -COUNT ASMCFUNC fl_setdisktype(); -#endif #define NENTRY 26 /* total size of dispatch table */ From c5f6ed4aa84e0140cfd8a8e73938e367ee3d694a Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Fri, 9 Apr 2004 13:13:06 +0000 Subject: [PATCH 429/671] Use pascal calling conventions for the remaining intr() functions (XMS related) git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@851 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/init-mod.h | 13 +++++++++---- kernel/intr.asm | 26 ++++++++++++++------------ kernel/kernel.asm | 12 ++++++------ 3 files changed, 29 insertions(+), 22 deletions(-) diff --git a/kernel/init-mod.h b/kernel/init-mod.h index 83001707..86cd1f45 100644 --- a/kernel/init-mod.h +++ b/kernel/init-mod.h @@ -269,12 +269,17 @@ extern struct RelocationTable DOSTEXTFAR ASM _HMARelocationTableEnd[]; extern void FAR *DOSTEXTFAR ASM XMSDriverAddress; -extern VOID ASMCFUNC FAR _EnableA20(VOID); -extern VOID ASMCFUNC FAR _DisableA20(VOID); +extern VOID ASMPASCAL FAR _EnableA20(VOID); +extern VOID ASMPASCAL FAR _DisableA20(VOID); -extern void FAR * ASMCFUNC DetectXMSDriver(VOID); -extern int ASMCFUNC init_call_XMScall(void FAR * driverAddress, UWORD ax, +extern void FAR * ASMPASCAL DetectXMSDriver(VOID); +extern int ASMPASCAL init_call_XMScall(void FAR * driverAddress, UWORD ax, UWORD dx); +#ifdef __WATCOMC__ +#pragma aux (pascal) DetectXMSDriver modify exact [ax dx] +#pragma aux (pascal) _EnableA20 modify exact [ax] +#pragma aux (pascal) _DisableA20 modify exact [ax] +#endif #if defined(WATCOM) && 0 ULONG ASMCFUNC FAR MULULUS(ULONG mul1, UWORD mul2); /* MULtiply ULong by UShort */ diff --git a/kernel/intr.asm b/kernel/intr.asm index 57d31413..b6ca61a0 100644 --- a/kernel/intr.asm +++ b/kernel/intr.asm @@ -141,21 +141,23 @@ INIT_CALL_INTR: ; ; this calls HIMEM.SYS ; - global _init_call_XMScall -_init_call_XMScall: - push bp - mov bp,sp - - mov ax,[bp+8] - mov dx,[bp+10] - call far [bp+4] + global INIT_CALL_XMSCALL +INIT_CALL_XMSCALL: + pop bx ; ret address + pop dx + pop ax + pop cx ; driver address + pop es - pop bp - ret + push cs ; ret address + push bx + push es ; driver address ("jmp es:cx") + push cx + retf ; void FAR *DetectXMSDriver(VOID) -global _DetectXMSDriver -_DetectXMSDriver: +global DETECTXMSDRIVER +DETECTXMSDRIVER: mov ax, 4300h int 2fh ; XMS installation check diff --git a/kernel/kernel.asm b/kernel/kernel.asm index acad9be5..01aa7fbc 100644 --- a/kernel/kernel.asm +++ b/kernel/kernel.asm @@ -858,8 +858,8 @@ _XMSDriverAddress: dw 0 ; XMS driver, if detected dw 0 - global __EnableA20 -__EnableA20: + global _ENABLEA20 +_ENABLEA20: mov ah,5 UsingXMSdriver: push bx @@ -867,8 +867,8 @@ UsingXMSdriver: pop bx retf - global __DisableA20 -__DisableA20: + global _DISABLEA20 +_DISABLEA20: mov ah,6 jmp short UsingXMSdriver @@ -906,7 +906,7 @@ forceEnableA20retry: ; ok, we have to enable A20 )at least seems so ; - call far __EnableA20 + call far _ENABLEA20 jmp short forceEnableA20retry @@ -935,7 +935,7 @@ _ExecUserDisableA20: je noNeedToDisable NeedToDisable: push ax - call far __DisableA20 + call far _DISABLEA20 pop ax noNeedToDisable: iret From c415f74ee417b781bf32ac79066c221fb6d2574c Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Fri, 9 Apr 2004 13:47:20 +0000 Subject: [PATCH 430/671] Use pascal calling conventions for all clock related asm functions. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@852 6ac86273-5f31-0410-b378-82cca8765d1b --- drivers/getvec.asm | 7 +++---- drivers/rdpcclk.asm | 7 +++---- drivers/wratclk.asm | 22 +++++++++++----------- drivers/wrpcclk.asm | 8 +++----- kernel/globals.h | 38 ++++++++++++-------------------------- 5 files changed, 32 insertions(+), 50 deletions(-) diff --git a/drivers/getvec.asm b/drivers/getvec.asm index f7b65290..7489fd6c 100644 --- a/drivers/getvec.asm +++ b/drivers/getvec.asm @@ -32,12 +32,11 @@ segment HMA_TEXT - global _getvec -_getvec: + global GETVEC +GETVEC: pop ax ; return address pop bx ; int # - push bx ; restore stack - push ax + push ax ; restore stack add bx,bx add bx,bx ; Multiply by 4 xor dx,dx ; and set segment to 0 diff --git a/drivers/rdpcclk.asm b/drivers/rdpcclk.asm index cc51fe70..fb886c7d 100644 --- a/drivers/rdpcclk.asm +++ b/drivers/rdpcclk.asm @@ -33,11 +33,10 @@ segment HMA_TEXT ; -; BOOL ReadPCClock(Ticks) -; ULONG *Ticks; +; ULONG ReadPCClock(void) ; - global _ReadPCClock -_ReadPCClock: + global READPCCLOCK +READPCCLOCK: mov ah,0 int 1ah extern _DaysSinceEpoch ; ; update days if necessary diff --git a/drivers/wratclk.asm b/drivers/wratclk.asm index 64897844..38a4f800 100644 --- a/drivers/wratclk.asm +++ b/drivers/wratclk.asm @@ -39,25 +39,25 @@ segment HMA_TEXT ; BYTE bcdMinutes; ; BYTE bcdSeconds; ; - global _WriteATClock -_WriteATClock: + global WRITEATCLOCK +WRITEATCLOCK: push bp mov bp,sp -; bcdSeconds = 10 -; bcdMinutes = 8 -; bcdHours = 6 -; bcdDays = 4 - mov ch,byte [bp+6] ;bcdHours - mov cl,byte [bp+8] ;bcdMinutes - mov dh,byte [bp+10] ;bcdSeconds +; bcdSeconds = 4 +; bcdMinutes = 6 +; bcdHours = 8 +; bcdDays = 10 + mov ch,byte [bp+8] ;bcdHours + mov cl,byte [bp+6] ;bcdMinutes + mov dh,byte [bp+4] ;bcdSeconds mov dl,0 mov ah,3 int 1ah - mov bx,word [bp+4] ;bcdDays + mov bx,word [bp+10] ;bcdDays mov dx,word [bx] mov cx,word [bx+2] mov ah,5 int 1ah pop bp - ret + ret 8 diff --git a/drivers/wrpcclk.asm b/drivers/wrpcclk.asm index 7c14456c..051bc259 100644 --- a/drivers/wrpcclk.asm +++ b/drivers/wrpcclk.asm @@ -36,15 +36,13 @@ segment HMA_TEXT ; VOID WritePCClock(Ticks) ; ULONG Ticks; ; - global _WritePCClock -_WritePCClock: + global WRITEPCCLOCK +WRITEPCCLOCK: ; Ticks = 4 pop ax ; return address pop dx pop cx ; Ticks - push cx ; restore stack - push dx - push ax + push ax ; restore stack mov ah,1 int 1ah ret diff --git a/kernel/globals.h b/kernel/globals.h index 2c66a227..3d1c1a68 100644 --- a/kernel/globals.h +++ b/kernel/globals.h @@ -366,36 +366,22 @@ COUNT ASMCFUNC CriticalError(COUNT nFlag, COUNT nDrive, COUNT nError, struct dhdr FAR * lpDevice); -#ifdef PROTO VOID ASMCFUNC FAR CharMapSrvc(VOID); +#if 0 VOID ASMCFUNC FAR set_stack(VOID); VOID ASMCFUNC FAR restore_stack(VOID); +#endif /*VOID INRPT FAR handle_break(VOID); */ -BOOL ASMCFUNC ReadATClock(BYTE *, BYTE *, BYTE *, BYTE *); -ULONG ASMCFUNC ReadPCClock(VOID); -VOID ASMCFUNC WriteATClock(BYTE *, BYTE, BYTE, BYTE); -VOID ASMCFUNC WritePCClock(ULONG); -BYTE FAR * ASMCFUNC device_end(VOID); -COUNT ASMCFUNC kb_data(VOID); -COUNT ASMCFUNC kb_input(VOID); -COUNT ASMCFUNC kb_init(VOID); -VOID ASMCFUNC setvec(UWORD, intvec); -intvec ASMCFUNC getvec(UWORD); -COUNT con(COUNT); -#else -VOID FAR CharMapSrvc(); -VOID FAR set_stack(); -VOID FAR restore_stack(); -WORD execrh(); -VOID exit(); -/*VOID INRPT FAR handle_break(); */ -BYTE FAR *device_end(); -COUNT kb_data(); -COUNT kb_input(); -COUNT kb_init(); -VOID setvec(); -intvec getvec(); -COUNT con(); + +ULONG ASMPASCAL ReadPCClock(VOID); +VOID ASMPASCAL WriteATClock(BYTE *, BYTE, BYTE, BYTE); +VOID ASMPASCAL WritePCClock(ULONG); +intvec ASMPASCAL getvec(UWORD); +#ifdef __WATCOMC__ +#pragma aux (pascal) ReadPCClock modify exact [ax cx dx] +#pragma aux (pascal) WriteATClock modify exact [ax bx cx dx] +#pragma aux (pascal) WritePCClock modify exact [ax cx dx] +#pragma aux (pascal) getvec modify exact [ax bx dx es] #endif /* */ From 4af102b61f2173982eef45669fd794ff5d99e1bc Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Fri, 9 Apr 2004 15:39:56 +0000 Subject: [PATCH 431/671] "Cache" far drive data table near. Enable to eliminate many far pointers in initdisk.c. Also clear up ConvPartTableEntryToIntern -- most of the casts were completely unnecessary. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@853 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/initdisk.c | 63 ++++++++++++++++++++++++++++------------------- 1 file changed, 37 insertions(+), 26 deletions(-) diff --git a/kernel/initdisk.c b/kernel/initdisk.c index 35cc7383..e00a7d7c 100644 --- a/kernel/initdisk.c +++ b/kernel/initdisk.c @@ -306,7 +306,7 @@ floppy_bpb floppy_bpbs[5] = { {SEC_SIZE, 2, 1, 2, 240, 5760, 0xf0, 9, 36, 2} /* FD2880 3.5 ED */ }; -COUNT init_getdriveparm(UBYTE drive, bpb FAR * pbpbarray) +COUNT init_getdriveparm(UBYTE drive, bpb * pbpbarray) { static iregs regs; REG UBYTE type; @@ -324,7 +324,7 @@ COUNT init_getdriveparm(UBYTE drive, bpb FAR * pbpbarray) else if (type == 5) type = 4; /* 5 and 4 are both 2.88 MB */ - fmemcpy(pbpbarray, &floppy_bpbs[type & 7], sizeof(floppy_bpb)); + memcpy(pbpbarray, &floppy_bpbs[type & 7], sizeof(floppy_bpb)); if (type == 3) return 7; /* 1.44 MB */ @@ -379,12 +379,12 @@ void printCHS(char *title, struct CHS *chs) Portions copyright 1992, 1993 Remy Card and 1991 Linus Torvalds */ -VOID CalculateFATData(ddt FAR * pddt, ULONG NumSectors, UBYTE FileSystem) +VOID CalculateFATData(ddt * pddt, ULONG NumSectors, UBYTE FileSystem) { UBYTE maxclustsize; ULONG fatdata; - bpb FAR *defbpb = &pddt->ddt_defbpb; + bpb *defbpb = &pddt->ddt_defbpb; /* FAT related items */ defbpb->bpb_nfat = 2; @@ -560,7 +560,9 @@ void DosDefinePartition(struct DriveParamS *driveParam, ULONG StartSector, struct PartTableEntry *pEntry, int extendedPartNo, int PrimaryNum) { - ddt FAR *pddt = DynAlloc("ddt", 1, sizeof(ddt)); + ddt FAR *fddt; + ddt nddt; + ddt *pddt = &nddt; struct CHS chs; if (nUnits >= NDEV) @@ -569,7 +571,6 @@ void DosDefinePartition(struct DriveParamS *driveParam, return; /* we are done */ } - (pddt-1)->ddt_next = pddt; pddt->ddt_next = MK_FP(0, 0xffff); pddt->ddt_driveno = driveParam->driveno; pddt->ddt_logdriveno = nUnits; @@ -607,7 +608,11 @@ void DosDefinePartition(struct DriveParamS *driveParam, /* drive inaccessible until bldbpb successful */ pddt->ddt_descflags = init_readdasd(pddt->ddt_driveno) | DF_NOACCESS; pddt->ddt_type = 5; - fmemcpy(&pddt->ddt_bpb, &pddt->ddt_defbpb, sizeof(bpb)); + memcpy(&pddt->ddt_bpb, &pddt->ddt_defbpb, sizeof(bpb)); + + fddt = DynAlloc("ddt", 1, sizeof(ddt)); + fmemcpy(fddt, pddt, sizeof(ddt)); + (fddt-1)->ddt_next = fddt; /* Alain whishes to keep this in later versions, too Tom likes this too, so he made it configurable by SYS CONFIG ... @@ -770,6 +775,13 @@ int LBA_Get_Drive_Parameters(int drive, struct DriveParamS *driveParam) converts physical into logical representation of partition entry */ +STATIC void ConvCHSToIntern(struct CHS *chs, UBYTE * pDisk) +{ + chs->Head = pDisk[0]; + chs->Sector = pDisk[1] & 0x3f; + chs->Cylinder = pDisk[2] + ((pDisk[1] & 0xc0) << 2); +} + BOOL ConvPartTableEntryToIntern(struct PartTableEntry * pEntry, UBYTE * pDisk) { @@ -787,21 +799,14 @@ BOOL ConvPartTableEntryToIntern(struct PartTableEntry * pEntry, for (i = 0; i < 4; i++, pDisk += 16, pEntry++) { - pEntry->Bootable = *(UBYTE FAR *) (pDisk + 0); - pEntry->FileSystem = *(UBYTE FAR *) (pDisk + 4); + pEntry->Bootable = pDisk[0]; + pEntry->FileSystem = pDisk[4]; - pEntry->Begin.Head = *(UBYTE FAR *) (pDisk + 1); - pEntry->Begin.Sector = *(UBYTE FAR *) (pDisk + 2) & 0x3f; - pEntry->Begin.Cylinder = *(UBYTE FAR *) (pDisk + 3) + - ((UWORD) (0xc0 & *(UBYTE FAR *) (pDisk + 2)) << 2); + ConvCHSToIntern(&pEntry->Begin, pDisk+1); + ConvCHSToIntern(&pEntry->End, pDisk+5); - pEntry->End.Head = *(UBYTE FAR *) (pDisk + 5); - pEntry->End.Sector = *(UBYTE FAR *) (pDisk + 6) & 0x3f; - pEntry->End.Cylinder = *(UBYTE FAR *) (pDisk + 7) + - ((UWORD) (0xc0 & *(UBYTE FAR *) (pDisk + 6)) << 2); - - pEntry->RelSect = *(ULONG FAR *) (pDisk + 8); - pEntry->NumSect = *(ULONG FAR *) (pDisk + 12); + pEntry->RelSect = *(ULONG *) (pDisk + 8); + pEntry->NumSect = *(ULONG *) (pDisk + 12); } return TRUE; } @@ -1248,7 +1253,9 @@ void ReadAllPartitionTables(void) int HardDrive; int nHardDisk = BIOS_nrdrives(); int Unit; - ddt FAR *pddt; + ddt FAR *fddt; + ddt nddt; + ddt *pddt = &nddt; static iregs regs; /* quick adjustment of diskette parameter table */ @@ -1262,9 +1269,6 @@ void ReadAllPartitionTables(void) /* Setup media info and BPBs arrays for floppies */ for (Unit = 0; Unit < 2; Unit++) { - pddt = DynAlloc("ddt", 1, sizeof(ddt)); - - if (Unit > 0) (pddt-1)->ddt_next = pddt; pddt->ddt_next = MK_FP(0, 0xffff); pddt->ddt_driveno = 0; pddt->ddt_logdriveno = Unit; @@ -1275,7 +1279,12 @@ void ReadAllPartitionTables(void) pddt->ddt_offset = 0l; pddt->ddt_serialno = 0x12345678l; - fmemcpy(&pddt->ddt_bpb, &pddt->ddt_defbpb, sizeof(bpb)); + memcpy(&pddt->ddt_bpb, &pddt->ddt_defbpb, sizeof(bpb)); + + fddt = DynAlloc("ddt", 1, sizeof(ddt)); + if (Unit == 0) { + fmemcpy(fddt, pddt, sizeof(ddt)); + } } /* Initial number of disk units */ @@ -1297,9 +1306,11 @@ void ReadAllPartitionTables(void) } else { /* set up the DJ method : multiple logical drives */ - (pddt - 1)->ddt_descflags |= DF_CURLOG | DF_MULTLOG; + (fddt - 1)->ddt_descflags |= DF_CURLOG | DF_MULTLOG; pddt->ddt_descflags |= DF_MULTLOG; } + (fddt-1)->ddt_next = fddt; + fmemcpy(fddt, pddt, sizeof(ddt)); nHardDisk = min(nHardDisk, MAX_HARD_DRIVE - 1); From 6e6e34024b0fba71c3237c631cecdf181bcb2843 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Fri, 9 Apr 2004 15:43:01 +0000 Subject: [PATCH 432/671] Make UMB_get_largest "pascal". Let it use the xms driver address from the HMA code. Misc small config.c cleanups. The uncompressed 386/fat32 kernel is now below 70000 bytes (69896). git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@854 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/config.c | 14 +++++++------- kernel/init-mod.h | 9 ++++++--- kernel/inithma.c | 8 ++++++-- kernel/int2f.asm | 35 ++++++++++------------------------- 4 files changed, 29 insertions(+), 37 deletions(-) diff --git a/kernel/config.c b/kernel/config.c index 8e284af5..93c3db44 100644 --- a/kernel/config.c +++ b/kernel/config.c @@ -170,7 +170,6 @@ STATIC seg base_seg = 0; STATIC seg umb_base_seg = 0; BYTE FAR *lpTop = 0; STATIC unsigned nCfgLine = 0; -STATIC COUNT nPass = 0; COUNT UmbState = 0; STATIC BYTE szLine[256] = { 0 }; STATIC BYTE szBuf[256] = { 0 }; @@ -545,8 +544,12 @@ STATIC void umb_init(void) { UCOUNT umb_seg, umb_size; seg umb_max; + void far *xms_addr; - if (UMB_get_largest(&umb_seg, &umb_size)) + if ((xms_addr = DetectXMSDriver()) == NULL) + return; + + if (UMB_get_largest(xms_addr, &umb_seg, &umb_size)) { UmbState = 1; @@ -571,7 +574,7 @@ STATIC void umb_init(void) the first UMB. */ - while (UMB_get_largest(&umb_seg, &umb_size)) + while (UMB_get_largest(xms_addr, &umb_seg, &umb_size)) { seg umb_prev, umb_next; @@ -621,16 +624,13 @@ STATIC void umb_init(void) } } -VOID DoConfig(int pass) +VOID DoConfig(int nPass) { COUNT nFileDesc; BYTE *pLine; BOOL bEof; - /* Set pass number */ - nPass = pass; - /* Check to see if we have a config.sys file. If not, just */ /* exit since we don't force the user to have one. */ if ((nFileDesc = open("fdconfig.sys", 0)) >= 0) diff --git a/kernel/init-mod.h b/kernel/init-mod.h index 86cd1f45..0e32ba05 100644 --- a/kernel/init-mod.h +++ b/kernel/init-mod.h @@ -111,8 +111,6 @@ VOID configDone(VOID); VOID FAR * KernelAlloc(size_t nBytes, char type, int mode); void FAR * KernelAllocPara(size_t nPara, char type, char *name, int mode); char *strcat(char * d, const char * s); -COUNT ASMCFUNC Umb_Test(void); -COUNT ASMCFUNC UMB_get_largest(UCOUNT * seg, UCOUNT * size); BYTE * GetStringArg(BYTE * pLine, BYTE * pszString); void DoInstall(void); UWORD GetBiosKey(int timeout); @@ -121,7 +119,12 @@ UWORD GetBiosKey(int timeout); COUNT dsk_init(VOID); /* int2f.asm */ -COUNT ASMCFUNC Umb_Test(void); +COUNT ASMPASCAL Umb_Test(void); +COUNT ASMPASCAL UMB_get_largest(void FAR * driverAddress, + UCOUNT * seg, UCOUNT * size); +#ifdef __WATCOMC__ +#pragma aux (pascal) UMB_get_largest modify exact [ax bx cx dx] +#endif /* inithma.c */ int MoveKernelToHMA(void); diff --git a/kernel/inithma.c b/kernel/inithma.c index b943cac0..0a1019e4 100644 --- a/kernel/inithma.c +++ b/kernel/inithma.c @@ -163,14 +163,18 @@ int EnableHMA(VOID) int MoveKernelToHMA() { + void far *xms_addr; + if (DosLoadedInHMA) { return TRUE; } - if ((XMSDriverAddress = DetectXMSDriver()) == NULL) + if ((xms_addr = DetectXMSDriver()) == NULL) return FALSE; + XMSDriverAddress = xms_addr; + #ifdef DEBUG /* A) for debugging purpose, suppress this, if any shift key is pressed @@ -196,7 +200,7 @@ int MoveKernelToHMA() if (HMAclaimed == 0 && (HMAclaimed = - init_call_XMScall(XMSDriverAddress, 0x0100, 0xffff)) == 0) + init_call_XMScall(xms_addr, 0x0100, 0xffff)) == 0) { printf("Can't reserve HMA area ??\n"); diff --git a/kernel/int2f.asm b/kernel/int2f.asm index d58fe6e3..3dbf06e8 100644 --- a/kernel/int2f.asm +++ b/kernel/int2f.asm @@ -677,34 +677,20 @@ skip5f02: ; B1h no UMB's are available ; B2h UMB segment number is invalid ; -; - segment INIT_TEXT - ; int UMB_get_largest(UCOUNT *seg, UCOUNT *size); - global _UMB_get_largest + ; int ASMPASCAL UMB_get_largest(void FAR * driverAddress, + ; UCOUNT * seg, UCOUNT * size); + global UMB_GET_LARGEST -_UMB_get_largest: +UMB_GET_LARGEST: push bp mov bp,sp - sub sp,4 ; for the far call - - mov ax,4300h ; is there a xms driver installed? - int 2fh - cmp al,80h - jne umbt_error - - mov ax,4310h - int 2fh - - - mov [bp-2],es ; save driver entry point - mov [bp-4],bx - mov dx,0xffff ; go for broke! mov ax,1000h ; get the umb's - call far [bp-4] ; Call the driver + call far [bp+8] ; Call the driver + ; ; bl = 0xB0 and ax = 0 so do it again. ; @@ -715,7 +701,7 @@ _UMB_get_largest: je umbt_error mov ax,1000h ; dx set with largest size - call far [bp-4] ; Call the driver + call far [bp+8] ; Call the driver cmp ax,1 jne umbt_error @@ -723,16 +709,15 @@ _UMB_get_largest: ; and the size mov cx,bx ; *seg = segment - mov bx, [bp+4] + mov bx, [bp+6] mov [bx],cx - mov bx, [bp+6] ; *size = size + mov bx, [bp+4] ; *size = size mov [bx],dx umbt_ret: - mov sp,bp pop bp - ret ; this was called NEAR!! + ret 8 ; this was called NEAR!! umbt_error: xor ax,ax jmp short umbt_ret From 11e57c64dbb7564de423717c1cf59b2eb9daa73f Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Fri, 9 Apr 2004 16:08:57 +0000 Subject: [PATCH 433/671] fmemcpy->memcpy git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@855 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/initdisk.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/kernel/initdisk.c b/kernel/initdisk.c index e00a7d7c..dc9fd3a7 100644 --- a/kernel/initdisk.c +++ b/kernel/initdisk.c @@ -438,7 +438,7 @@ VOID CalculateFATData(ddt * pddt, ULONG NumSectors, UBYTE FileSystem) DebugPrintf(("FAT12: too many clusters: setting to maxclu-2\n")); } defbpb->bpb_nfsect = fatlength; - fmemcpy(pddt->ddt_fstype, MSDOS_FAT12_SIGN, 8); + memcpy(pddt->ddt_fstype, MSDOS_FAT12_SIGN, 8); break; } case FAT16SMALL: @@ -492,7 +492,7 @@ VOID CalculateFATData(ddt * pddt, ULONG NumSectors, UBYTE FileSystem) } while (defbpb->bpb_nsector && defbpb->bpb_nsector <= maxclustsize); defbpb->bpb_nfsect = fatlength; - fmemcpy(pddt->ddt_fstype, MSDOS_FAT16_SIGN, 8); + memcpy(pddt->ddt_fstype, MSDOS_FAT16_SIGN, 8); break; } #ifdef WITHFAT32 @@ -548,7 +548,7 @@ VOID CalculateFATData(ddt * pddt, ULONG NumSectors, UBYTE FileSystem) defbpb->bpb_xrootclst = 2; defbpb->bpb_xfsinfosec = 1; defbpb->bpb_xbackupsec = 6; - fmemcpy(pddt->ddt_fstype, MSDOS_FAT32_SIGN, 8); + memcpy(pddt->ddt_fstype, MSDOS_FAT32_SIGN, 8); break; } #endif From cfed8c6f290baf167429d2c3c71f8b158c2c88de Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Fri, 9 Apr 2004 23:51:44 +0000 Subject: [PATCH 434/671] We must do "sbb ax, ax" *before* "popf" otherwise it won't be predictable! git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@856 6ac86273-5f31-0410-b378-82cca8765d1b --- sys/sys.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/sys/sys.c b/sys/sys.c index a145f275..ee402fe2 100644 --- a/sys/sys.c +++ b/sys/sys.c @@ -29,7 +29,7 @@ #define DEBUG /* #define DDEBUG */ -#define SYS_VERSION "v3.1" +#define SYS_VERSION "v3.2" #include #include @@ -437,9 +437,9 @@ int absread(int DosDrive, int nsects, int foo, void *diskReadPacket); #pragma aux absread = \ "push bp" \ "int 0x25" \ + "sbb ax, ax" \ "popf" \ "pop bp" \ - "sbb ax, ax" \ parm [ax] [cx] [dx] [bx] \ modify [si di] \ value [ax]; @@ -448,9 +448,9 @@ int abswrite(int DosDrive, int nsects, int foo, void *diskReadPacket); #pragma aux abswrite = \ "push bp" \ "int 0x26" \ + "sbb ax, ax" \ "popf" \ "pop bp" \ - "sbb ax, ax" \ parm [ax] [cx] [dx] [bx] \ modify [si di] \ value [ax]; @@ -709,6 +709,13 @@ void put_boot(int drive, char *bsFile, char *kernel_name, int load_seg, int both bs = (struct bootsectortype *)&oldboot; + if (bs->bsBytesPerSec != SEC_SIZE) + { + printf("Sector size is not 512 but %d bytes - not currently supported!\n", + bs->bsBytesPerSec); + exit(1); /* Japan?! */ + } + { /* see "FAT: General Overview of On-Disk Format" v1.02, 5.V.1999 * (http://www.nondot.org/sabre/os/files/FileSystems/FatFormat.pdf) @@ -733,13 +740,6 @@ void put_boot(int drive, char *bsFile, char *kernel_name, int load_seg, int both fs = FAT32; } - if (bs->bsBytesPerSec != SEC_SIZE) - { - printf("Sector size is not 512 but %d bytes - not currently supported!\n", - bs->bsBytesPerSec); - exit(1); /* Japan?! */ - } - /* bit 0 set if function to use current BPB, clear if Device BIOS Parameter Block field contains new default BPB bit 1 set if function to use track layout fields only From 78995ad7cca68c0fe4dd3c5aa2be10d79ed33e82 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sat, 10 Apr 2004 09:37:45 +0000 Subject: [PATCH 435/671] Move some common code into a "push_ddt" function. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@857 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/initdisk.c | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/kernel/initdisk.c b/kernel/initdisk.c index dc9fd3a7..f4f2e49b 100644 --- a/kernel/initdisk.c +++ b/kernel/initdisk.c @@ -556,11 +556,21 @@ VOID CalculateFATData(ddt * pddt, ULONG NumSectors, UBYTE FileSystem) pddt->ddt_fstype[8] = '\0'; } +STATIC void push_ddt(ddt *pddt) +{ + ddt FAR *fddt = DynAlloc("ddt", 1, sizeof(ddt)); + fmemcpy(fddt, pddt, sizeof(ddt)); + if (pddt->ddt_logdriveno != 0) { + (fddt - 1)->ddt_next = fddt; + if (pddt->ddt_driveno == 0 && pddt->ddt_logdriveno == 1) + (fddt - 1)->ddt_descflags |= DF_CURLOG | DF_MULTLOG; + } +} + void DosDefinePartition(struct DriveParamS *driveParam, ULONG StartSector, struct PartTableEntry *pEntry, int extendedPartNo, int PrimaryNum) { - ddt FAR *fddt; ddt nddt; ddt *pddt = &nddt; struct CHS chs; @@ -610,9 +620,7 @@ void DosDefinePartition(struct DriveParamS *driveParam, pddt->ddt_type = 5; memcpy(&pddt->ddt_bpb, &pddt->ddt_defbpb, sizeof(bpb)); - fddt = DynAlloc("ddt", 1, sizeof(ddt)); - fmemcpy(fddt, pddt, sizeof(ddt)); - (fddt-1)->ddt_next = fddt; + push_ddt(pddt); /* Alain whishes to keep this in later versions, too Tom likes this too, so he made it configurable by SYS CONFIG ... @@ -1253,7 +1261,6 @@ void ReadAllPartitionTables(void) int HardDrive; int nHardDisk = BIOS_nrdrives(); int Unit; - ddt FAR *fddt; ddt nddt; ddt *pddt = &nddt; static iregs regs; @@ -1281,10 +1288,8 @@ void ReadAllPartitionTables(void) pddt->ddt_serialno = 0x12345678l; memcpy(&pddt->ddt_bpb, &pddt->ddt_defbpb, sizeof(bpb)); - fddt = DynAlloc("ddt", 1, sizeof(ddt)); - if (Unit == 0) { - fmemcpy(fddt, pddt, sizeof(ddt)); - } + if (Unit == 0) + push_ddt(pddt); } /* Initial number of disk units */ @@ -1306,12 +1311,10 @@ void ReadAllPartitionTables(void) } else { /* set up the DJ method : multiple logical drives */ - (fddt - 1)->ddt_descflags |= DF_CURLOG | DF_MULTLOG; pddt->ddt_descflags |= DF_MULTLOG; } - (fddt-1)->ddt_next = fddt; - fmemcpy(fddt, pddt, sizeof(ddt)); + push_ddt(pddt); nHardDisk = min(nHardDisk, MAX_HARD_DRIVE - 1); memset(foundPartitions, 0, sizeof(foundPartitions)); From 512f48e9627683e781622a430576fa17450b91d5 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sat, 10 Apr 2004 09:38:38 +0000 Subject: [PATCH 436/671] Use pointer to MK_FP(0,0x5e0) to save a bit of code. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@858 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/main.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/kernel/main.c b/kernel/main.c index be75f833..b54e38de 100644 --- a/kernel/main.c +++ b/kernel/main.c @@ -73,6 +73,7 @@ struct lol FAR *LoL = &DATASTART; VOID ASMCFUNC FreeDOSmain(void) { unsigned char drv; + unsigned char FAR *p; #ifdef _MSC_VER extern FAR prn_dev; @@ -87,17 +88,18 @@ VOID ASMCFUNC FreeDOSmain(void) at 50:e0 */ - if (fmemcmp(MK_FP(0x50,0xe0+2),"CONFIG",6) == 0) /* UPX */ + drv = LoL->BootDrive + 1; + p = MK_FP(0, 0x5e0); + if (fmemcmp(p+2,"CONFIG",6) == 0) /* UPX */ { - fmemcpy(&InitKernelConfig, MK_FP(0,0x5e0+2), sizeof(InitKernelConfig)); + fmemcpy(&InitKernelConfig, p+2, sizeof(InitKernelConfig)); - drv = *(UBYTE FAR *)MK_FP(0,0x5e0) + 1; - *(DWORD FAR *)MK_FP(0,0x5e0+2) = 0; + drv = *p + 1; + *(DWORD FAR *)(p+2) = 0; } else { - drv = LoL->BootDrive + 1; - *(UBYTE FAR *)MK_FP(0,0x5e0) = drv - 1; + *p = drv - 1; fmemcpy(&InitKernelConfig, &LowKernelConfig, sizeof(InitKernelConfig)); } From e6e3b7a3a41ee659cd7902dbb9b98138b22b96f7 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sat, 10 Apr 2004 10:59:57 +0000 Subject: [PATCH 437/671] Use the "small" model for the init code (split code/data). This will enable us to use the same CS for resident and init code for Watcom (Borland's too big), and share a bit. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@859 6ac86273-5f31-0410-b378-82cca8765d1b --- hdr/portab.h | 18 +++++++++++++----- kernel/kernel.asm | 20 ++++++++++---------- kernel/main.c | 3 +-- kernel/segs.inc | 5 +++-- 4 files changed, 27 insertions(+), 19 deletions(-) diff --git a/hdr/portab.h b/hdr/portab.h index 3dc25af4..3707ee25 100644 --- a/hdr/portab.h +++ b/hdr/portab.h @@ -82,8 +82,13 @@ void __int__(int); #define VA_CDECL #define PASCAL pascal #define __int__(intno) asm int intno; -#define _SS SS() -static unsigned short __inline SS(void) +#define _CS getCS() +static unsigned short __inline getCS(void) +{ + asm mov ax, cs; +} +#define _SS getSS() +static unsigned short __inline getSS(void) { asm mov ax, ss; } @@ -97,9 +102,12 @@ static unsigned short __inline SS(void) #define CDECL __cdecl #define VA_CDECL #define PASCAL pascal -#define _SS SS() -unsigned short SS(void); -#pragma aux SS = "mov dx,ss" value [dx]; +#define _CS getCS() +unsigned short getCS(void); +#pragma aux getCS = "mov dx,cs" value [dx] modify exact[dx]; +#define _SS getSS() +unsigned short getSS(void); +#pragma aux getSS = "mov dx,ss" value [dx] modify exact[dx]; /* enable Possible loss of precision warning for compatibility with Borland */ #pragma enable_message(130) diff --git a/kernel/kernel.asm b/kernel/kernel.asm index 01aa7fbc..59de502b 100644 --- a/kernel/kernel.asm +++ b/kernel/kernel.asm @@ -119,23 +119,28 @@ kernel_start: pop bx pop ax - mov ax,cs + mov ax,seg init_tos cli mov ss,ax mov sp,init_tos int 12h ; move the init code to higher memory mov cl,6 shl ax,cl - mov dx,init_end+15 + mov dx,15 + init_end wrt INIT_TEXT mov cl,4 shr dx,cl sub ax,dx mov es,ax + mov dx,__INIT_DATA_START wrt INIT_TEXT + shr dx,cl + add ax,dx + mov ss,ax ; set SS to init data segment + sti ; now enable them mov ax,cs mov ds,ax xor si,si xor di,di - mov cx,init_end+1 + mov cx,1 + init_end wrt INIT_TEXT shr cx,1 cld rep movsw @@ -143,14 +148,10 @@ kernel_start: mov ax,cont push ax retf -cont: mov ax,cs - mov ss,ax - ; Now set up call frame +cont: ; Now set up call frame mov ds,[cs:_INIT_DGROUP] mov bp,sp ; and set up stack frame for c - sti ; now enable them - push ax push bx pushf mov ax, 0e33h ; '3' Tracecode - kernel entered @@ -158,7 +159,6 @@ cont: mov ax,cs int 010h popf pop bx - pop ax mov byte [_BootDrive],bl ; tell where we came from @@ -171,7 +171,7 @@ cont: mov ax,cs mov ax,ss mov ds,ax mov es,ax - jmp _FreeDOSmain + jmp _FreeDOSmain %ifdef WATCOM global _IU4M diff --git a/kernel/main.c b/kernel/main.c index b54e38de..a1cd7845 100644 --- a/kernel/main.c +++ b/kernel/main.c @@ -227,8 +227,7 @@ STATIC void init_kernel(void) ram_top = init_oem(); /* move kernel to high conventional RAM, just below the init code */ - lpTop = MK_FP(ram_top * 64 - (FP_OFF(_init_end) + 15) / 16 - - (FP_OFF(_HMATextEnd) + 15) / 16, 0); + lpTop = MK_FP(_CS - (FP_OFF(_HMATextEnd) + 15) / 16, 0); MoveKernel(FP_SEG(lpTop)); lpTop = MK_FP(FP_SEG(lpTop) - 0xfff, 0xfff0); diff --git a/kernel/segs.inc b/kernel/segs.inc index 5f3624b7..649ea8fd 100644 --- a/kernel/segs.inc +++ b/kernel/segs.inc @@ -31,7 +31,8 @@ group PGROUP PSP group LGROUP _LOWTEXT _IO_TEXT _IO_FIXED_DATA _TEXT group DGROUP _FIXED_DATA _BSS _DATA _DATAEND CONST CONST2 DCONST DYN_DATA group TGROUP HMA_TEXT_START HMA_TEXT HMA_TEXT_END -group I_GROUP INIT_TEXT_START INIT_TEXT INIT_TEXT_END ID_B ID ID_E IC IDATA ICONST ICONST2 I_DATA IB_B I_BSS IB IB_E +group IGROUP INIT_TEXT_START INIT_TEXT INIT_TEXT_END +group I_GROUP ID_B ID ID_E IC IDATA ICONST ICONST2 I_DATA IB_B I_BSS IB IB_E segment PSP class=PSP segment _LOWTEXT class=LCODE @@ -54,7 +55,7 @@ segment HMA_TEXT_END class=CODE segment INIT_TEXT_START class=CODE align=16 segment INIT_TEXT class=CODE segment INIT_TEXT_END class=CODE -segment ID_B class=ID align=2 +segment ID_B class=ID align=16 segment ID class=ID align=2 segment ID_E class=ID align=2 segment IDATA class=ID align=2 From 147f4069e45c7b7ced84fd7f52e81c9f5dd06b8e Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sat, 10 Apr 2004 14:18:25 +0000 Subject: [PATCH 438/671] Make CS the same for INIT and HMA text for Watcom. Move HMA text up in kernel.asm. Use std for the memory move: helps if there's overlap (PCs with a very low amount of RAM). git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@860 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/inithma.c | 18 ++---------------- kernel/kernel.asm | 42 +++++++++++++++++++++++++++++++++++------- kernel/main.c | 4 ++++ kernel/segs.inc | 6 +++++- mkfiles/watcom.mak | 2 +- 5 files changed, 47 insertions(+), 25 deletions(-) diff --git a/kernel/inithma.c b/kernel/inithma.c index 0a1019e4..71478ab2 100644 --- a/kernel/inithma.c +++ b/kernel/inithma.c @@ -330,22 +330,8 @@ void MoveKernel(unsigned NewKernelSegment) if (NewKernelSegment < CurrentKernelSegment || NewKernelSegment == 0xffff) - { - unsigned i; - UBYTE FAR *s, FAR * d; - - for (i = 0, s = HMASource, d = HMADest; i < len; i++) - d[i] = s[i]; - } - else - { - /* might overlap */ - unsigned i; - UBYTE FAR *s, FAR * d; - - for (i = len, s = HMASource, d = HMADest; i != 0; i--) - d[i] = s[i]; - } + fmemcpy(HMADest, HMASource, len); + /* else it's the very first relocation: handled by kernel.asm */ HMAFree = (FP_OFF(HMADest) + len + 0xf) & 0xfff0; /* first free byte after HMA_TEXT on 16 byte boundary */ diff --git a/kernel/kernel.asm b/kernel/kernel.asm index 59de502b..8d803d89 100644 --- a/kernel/kernel.asm +++ b/kernel/kernel.asm @@ -109,7 +109,6 @@ segment INIT_TEXT ; kernel_start: - push ax push bx pushf mov ax, 0e32h ; '2' Tracecode - kernel entered @@ -117,13 +116,12 @@ kernel_start: int 010h popf pop bx - pop ax mov ax,seg init_tos cli mov ss,ax mov sp,init_tos - int 12h ; move the init code to higher memory + int 12h ; move init text+data to higher memory mov cl,6 shl ax,cl mov dx,15 + init_end wrt INIT_TEXT @@ -137,13 +135,43 @@ kernel_start: mov ss,ax ; set SS to init data segment sti ; now enable them mov ax,cs + mov dx,__InitTextStart wrt HMA_TEXT +%ifdef WATCOM + mov cx,dx + shr cx,4 + add ax,cx +%endif mov ds,ax - xor si,si - xor di,di - mov cx,1 + init_end wrt INIT_TEXT + mov cx,-2 + init_end wrt INIT_TEXT + mov si,cx + mov di,cx + shr cx,1 + inc cx + std ; if there's overlap only std is safe + rep movsw + + ; move HMA_TEXT to higher memory + mov cx,dx ; cx = __InitTextStart wrt HMA_TEXT + shr dx,4 + + sub ax,dx + mov ds,ax ; ds = HMA_TEXT + mov ax,es + sub ax,dx + mov es,ax ; es = new HMA_TEXT + + mov si,cx + dec si + dec si + mov di,si shr cx,1 - cld rep movsw + + cld +%ifndef WATCOM ; for WATCOM: CS equal for HMA and INIT + add ax,dx + mov es,ax ; otherwise CS -> init_text +%endif push es mov ax,cont push ax diff --git a/kernel/main.c b/kernel/main.c index a1cd7845..8b3ebd3a 100644 --- a/kernel/main.c +++ b/kernel/main.c @@ -227,7 +227,11 @@ STATIC void init_kernel(void) ram_top = init_oem(); /* move kernel to high conventional RAM, just below the init code */ +#ifdef __WATCOMC__ + lpTop = MK_FP(_CS, 0); +#else lpTop = MK_FP(_CS - (FP_OFF(_HMATextEnd) + 15) / 16, 0); +#endif MoveKernel(FP_SEG(lpTop)); lpTop = MK_FP(FP_SEG(lpTop) - 0xfff, 0xfff0); diff --git a/kernel/segs.inc b/kernel/segs.inc index 649ea8fd..592760f1 100644 --- a/kernel/segs.inc +++ b/kernel/segs.inc @@ -30,8 +30,12 @@ group PGROUP PSP group LGROUP _LOWTEXT _IO_TEXT _IO_FIXED_DATA _TEXT group DGROUP _FIXED_DATA _BSS _DATA _DATAEND CONST CONST2 DCONST DYN_DATA +%ifdef WATCOM +group TGROUP HMA_TEXT_START HMA_TEXT HMA_TEXT_END INIT_TEXT_START INIT_TEXT INIT_TEXT_END +%else group TGROUP HMA_TEXT_START HMA_TEXT HMA_TEXT_END group IGROUP INIT_TEXT_START INIT_TEXT INIT_TEXT_END +%endif group I_GROUP ID_B ID ID_E IC IDATA ICONST ICONST2 I_DATA IB_B I_BSS IB IB_E segment PSP class=PSP @@ -54,7 +58,7 @@ segment HMA_TEXT class=CODE segment HMA_TEXT_END class=CODE segment INIT_TEXT_START class=CODE align=16 segment INIT_TEXT class=CODE -segment INIT_TEXT_END class=CODE +segment INIT_TEXT_END class=CODE segment ID_B class=ID align=16 segment ID class=ID align=2 segment ID_E class=ID align=2 diff --git a/mkfiles/watcom.mak b/mkfiles/watcom.mak index 32b3d49c..68283e8f 100644 --- a/mkfiles/watcom.mak +++ b/mkfiles/watcom.mak @@ -62,7 +62,7 @@ MATH_INSERT=+i4m # ALLCFLAGS=-I..\hdr $(TARGETOPT) $(ALLCFLAGS)-zq-os-s-e5-j-zl-zp1-wx-we-zgf-zff-r -INITCFLAGS=$(ALLCFLAGS)-ntINIT_TEXT-ndI +INITCFLAGS=$(ALLCFLAGS)-ntINIT_TEXT-gTGROUP-ndI CFLAGS=$(ALLCFLAGS)-ntHMA_TEXT INITPATCH=..\utils\patchobj __U4D=_IU4D __U4M=_IU4M From dd6ace383afba40a3c37e35c002a1835894e377a Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sat, 10 Apr 2004 15:11:16 +0000 Subject: [PATCH 439/671] No longer include duplicate execrh, asmsupt, and u8m/d functions for the init text in the Watcom compiled kernel, since they can be called "near" in the resident code. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@861 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/asmsupt.asm | 9 +++++++++ kernel/execrh.asm | 4 ++++ kernel/init-mod.h | 22 ++++++++++++---------- kernel/kernel.asm | 9 --------- mkfiles/watcom.mak | 1 - 5 files changed, 25 insertions(+), 20 deletions(-) diff --git a/kernel/asmsupt.asm b/kernel/asmsupt.asm index c661b8a6..92286b3f 100644 --- a/kernel/asmsupt.asm +++ b/kernel/asmsupt.asm @@ -34,6 +34,14 @@ ; $Id$ ; +%ifdef WATCOM +%ifdef _INIT +%define WATCOM_INIT ; no seperate init segment for watcom. +%endif +%endif + +%ifndef WATCOM_INIT + %include "segs.inc" %ifdef _INIT @@ -530,3 +538,4 @@ strncmp_done: ror ah,1 strncmp_done2: jmp pascal_return +%endif diff --git a/kernel/execrh.asm b/kernel/execrh.asm index 66d0d63b..87ce4c9c 100644 --- a/kernel/execrh.asm +++ b/kernel/execrh.asm @@ -81,7 +81,11 @@ segment HMA_TEXT EXECRH: EXECRHM +%ifndef WATCOM + segment INIT_TEXT INIT_EXECRH: EXECRHM + +%endif diff --git a/kernel/init-mod.h b/kernel/init-mod.h index 0e32ba05..6c158146 100644 --- a/kernel/init-mod.h +++ b/kernel/init-mod.h @@ -34,6 +34,7 @@ extern struct _KernelConfig InitKernelConfig; */ #define printf init_printf #define sprintf init_sprintf +#ifndef __WATCOMC__ #define execrh init_execrh #define memcpy init_memcpy #define fmemcpy init_fmemcpy @@ -44,6 +45,7 @@ extern struct _KernelConfig InitKernelConfig; #define strcpy init_strcpy #define strlen init_strlen #define fstrlen init_fstrlen +#endif #define open init_DosOpen /* execrh.asm */ @@ -65,16 +67,16 @@ char * ASMPASCAL strchr(const char *s, int ch); /* bx, cx, dx and es not used or clobbered for all asmsupt.asm functions except (f)memchr/(f)strchr (which clobber dx) */ #pragma aux (pascal) pascal_ax modify exact [ax] -#pragma aux (pascal_ax) init_memset -#pragma aux (pascal_ax) init_fmemset -#pragma aux (pascal_ax) init_memcpy -#pragma aux (pascal_ax) init_fmemcpy -#pragma aux (pascal_ax) init_memcmp modify nomemory -#pragma aux (pascal_ax) init_fmemcmp modify nomemory -#pragma aux (pascal_ax) init_strcpy -#pragma aux (pascal_ax) init_strlen modify nomemory -#pragma aux (pascal_ax) init_fstrlen modify nomemory -#pragma aux (pascal) init_strchr modify exact [ax dx] nomemory +#pragma aux (pascal_ax) memset +#pragma aux (pascal_ax) fmemset +#pragma aux (pascal_ax) memcpy +#pragma aux (pascal_ax) fmemcpy +#pragma aux (pascal_ax) memcmp modify nomemory +#pragma aux (pascal_ax) fmemcmp modify nomemory +#pragma aux (pascal_ax) strcpy +#pragma aux (pascal_ax) strlen modify nomemory +#pragma aux (pascal_ax) fstrlen modify nomemory +#pragma aux (pascal) strchr modify exact [ax dx] nomemory #endif #undef LINESIZE diff --git a/kernel/kernel.asm b/kernel/kernel.asm index 8d803d89..21f399f0 100644 --- a/kernel/kernel.asm +++ b/kernel/kernel.asm @@ -201,15 +201,6 @@ cont: ; Now set up call frame mov es,ax jmp _FreeDOSmain -%ifdef WATCOM -global _IU4M -_IU4M: - LMULU -global _IU4D -_IU4D: - LDIVMODU -%endif - segment INIT_TEXT_END diff --git a/mkfiles/watcom.mak b/mkfiles/watcom.mak index 68283e8f..77a26151 100644 --- a/mkfiles/watcom.mak +++ b/mkfiles/watcom.mak @@ -64,5 +64,4 @@ MATH_INSERT=+i4m ALLCFLAGS=-I..\hdr $(TARGETOPT) $(ALLCFLAGS)-zq-os-s-e5-j-zl-zp1-wx-we-zgf-zff-r INITCFLAGS=$(ALLCFLAGS)-ntINIT_TEXT-gTGROUP-ndI CFLAGS=$(ALLCFLAGS)-ntHMA_TEXT -INITPATCH=..\utils\patchobj __U4D=_IU4D __U4M=_IU4M From 6ad8b415dd997a51e0810cf562b8f84f86643528 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sat, 10 Apr 2004 21:07:06 +0000 Subject: [PATCH 440/671] Applied Arkady's corrections to int2f/ax=4a01/2. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@862 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/inthndlr.c | 40 ++++++++++++++-------------------------- kernel/proto.h | 1 + 2 files changed, 15 insertions(+), 26 deletions(-) diff --git a/kernel/inthndlr.c b/kernel/inthndlr.c index 8fc5b71d..d74e71d0 100644 --- a/kernel/inthndlr.c +++ b/kernel/inthndlr.c @@ -1774,42 +1774,30 @@ struct int2f12regs { UWORD callerARG1; /* used if called from INT2F/12 */ }; -extern short AllocateHMASpace (size_t lowbuffer, size_t highbuffer); - /* WARNING: modifications in `r' are used outside of int2F_12_handler() * On input r.AX==0x12xx, 0x4A01 or 0x4A02 */ VOID ASMCFUNC int2F_12_handler(struct int2f12regs r) { - /* dont use - QueryFreeHMASpace(&p); - here; DS !=SS - */ if (r.AH == 0x4a) { - size_t wantedBytes, offs; - - if (r.AL != 1 && r.AL != 2) - return; - - wantedBytes = r.BX; - r.ES = r.DI = 0xffff; - r.BX = 0; - if (FP_SEG(firstAvailableBuf) != 0xffff) - return; - - offs = FP_OFF(firstAvailableBuf); - r.di = offs; + size_t size = 0, offs = 0xffff; - if (r.AL == 0x02) + r.ES = offs; + if (FP_SEG(firstAvailableBuf) == offs) /* HMA present? */ { - if (wantedBytes > ~offs) - return; - AllocateHMASpace(FP_OFF(firstAvailableBuf), - FP_OFF(firstAvailableBuf)+wantedBytes); - firstAvailableBuf += wantedBytes; - r.BX = wantedBytes; + offs = FP_OFF(firstAvailableBuf); + size = ~offs; /* BX for query HMA */ + if (r.AL == 0x02) /* allocate HMA space */ + { + if (r.BX < size) + size = r.BX; + AllocateHMASpace(offs, offs+size); + firstAvailableBuf += size; + } } + r.DI = offs; + r.BX = size; return; } diff --git a/kernel/proto.h b/kernel/proto.h index 421e8c68..baee0d14 100644 --- a/kernel/proto.h +++ b/kernel/proto.h @@ -46,6 +46,7 @@ BOOL DeleteBlockInBufferCache(ULONG blknolow, ULONG blknohigh, COUNT dsk, int mo UWORD dskxfer(COUNT dsk, ULONG blkno, VOID FAR * buf, UWORD numblocks, COUNT mode); /* *** End of change */ +void AllocateHMASpace (size_t lowbuffer, size_t highbuffer); /* break.c */ #ifdef __WATCOMC__ From ca11edc6fd29d31f59545b5aad0789208b5d6fe7 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sat, 10 Apr 2004 22:48:26 +0000 Subject: [PATCH 441/671] Buffer config fixes from Arkady. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@863 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/config.c | 68 +++++++++++++++++++++++++------------------------ 1 file changed, 35 insertions(+), 33 deletions(-) diff --git a/kernel/config.c b/kernel/config.c index 93c3db44..6c77b37e 100644 --- a/kernel/config.c +++ b/kernel/config.c @@ -908,12 +908,8 @@ STATIC void Config_Buffers(BYTE * pLine) COUNT nBuffers; /* Get the argument */ - if (GetNumArg(pLine, &nBuffers) == (BYTE *) 0) - return; - - /* Got the value, assign either default or new value */ - Config.cfgBuffers = - (nBuffers < 0 ? nBuffers : max(Config.cfgBuffers, nBuffers)); + if (GetNumArg(pLine, &nBuffers)) + Config.cfgBuffers = nBuffers; } /** @@ -1697,43 +1693,45 @@ STATIC COUNT strcasecmp(REG BYTE * d, REG BYTE * s) that saves some relocation problems */ -STATIC void config_init_buffers(int anzBuffers) +STATIC void config_init_buffers(int wantedbuffers) { - REG WORD i; struct buffer FAR *pbuffer; - unsigned wantedbuffers = anzBuffers; + unsigned buffers = 0; - if (anzBuffers < 0) - { - wantedbuffers = anzBuffers = -anzBuffers; - } + /* fill HMA with buffers if BUFFERS count >=0 and DOS in HMA */ + if (wantedbuffers < 0) + wantedbuffers = -wantedbuffers; else if (HMAState == HMA_DONE) - { - anzBuffers = (0xfff0 - HMAFree) / sizeof(struct buffer); - } + buffers = (0xfff0 - HMAFree) / sizeof(struct buffer); - anzBuffers = max(anzBuffers, 6); - if (anzBuffers > 99) + if (wantedbuffers < 6) /* min 6 buffers */ + wantedbuffers = 6; + if (wantedbuffers > 99) /* max 99 buffers */ { - printf("BUFFERS=%u not supported, reducing to 99\n", anzBuffers); - anzBuffers = 99; + printf("BUFFERS=%u not supported, reducing to 99\n", wantedbuffers); + wantedbuffers = 99; } - LoL->nbuffers = anzBuffers; + if (wantedbuffers > buffers) /* more specified than available -> get em */ + buffers = wantedbuffers; + LoL->nbuffers = buffers; LoL->inforecptr = &LoL->firstbuf; - { - size_t bytes = sizeof(struct buffer) * anzBuffers; + size_t bytes = sizeof(struct buffer) * buffers; pbuffer = HMAalloc(bytes); if (pbuffer == NULL) { pbuffer = KernelAlloc(bytes, 'B', 0); + if (HMAState == HMA_DONE) + firstAvailableBuf = MK_FP(0xffff, HMAFree); } else { LoL->bufloc = LOC_HMA; LoL->deblock_buf = KernelAlloc(SEC_SIZE, 'B', 0); + /* space in HMA beyond requested buffers available as user space */ + firstAvailableBuf = pbuffer + wantedbuffers; } } @@ -1742,18 +1740,19 @@ STATIC void config_init_buffers(int anzBuffers) DebugPrintf(("init_buffers (size %u) at", sizeof(struct buffer))); DebugPrintf((" (%p)", LoL->firstbuf)); - pbuffer->b_prev = FP_OFF(pbuffer + (anzBuffers-1)); - for (i = 1; i < anzBuffers; ++i) + buffers--; + pbuffer->b_prev = FP_OFF(pbuffer + buffers); { - if (i == wantedbuffers) + int i = buffers; + do { - firstAvailableBuf = pbuffer; - } - pbuffer->b_next = FP_OFF(pbuffer + 1); - pbuffer++; - pbuffer->b_prev = FP_OFF(pbuffer - 1); + pbuffer->b_next = FP_OFF(pbuffer + 1); + pbuffer++; + pbuffer->b_prev = FP_OFF(pbuffer - 1); + } + while (--i); } - pbuffer->b_next = FP_OFF(pbuffer - (anzBuffers-1)); + pbuffer->b_next = FP_OFF(pbuffer - buffers); /* now, we can have quite some buffers in HMA -- up to 50 for KE38616. @@ -1764,8 +1763,11 @@ STATIC void config_init_buffers(int anzBuffers) DebugPrintf((" done\n")); if (FP_SEG(pbuffer) == 0xffff) + { + buffers++; printf("Kernel: allocated %d Diskbuffers = %u Bytes in HMA\n", - anzBuffers, anzBuffers * sizeof(struct buffer)); + buffers, buffers * sizeof(struct buffer)); + } } STATIC void config_init_fnodes(int f_nodes_cnt) From c6c49e1ec1cc7e9f4b5424ed0e5a741077c3b7ad Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sun, 11 Apr 2004 12:21:25 +0000 Subject: [PATCH 442/671] Some makefile cleanups from Arkady. Also Lucho reported that nmake/nologo doesn't always work in 4dos, but nmake /nologo works. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@864 6ac86273-5f31-0410-b378-82cca8765d1b --- buildall.bat | 2 +- config.b | 2 +- default.bat | 16 +-- kernel/makefile | 230 ++++++++++++++++---------------------------- mkfiles/generic.mak | 2 +- utils/rmfiles.bat | 2 +- utils/wlinker.bat | 2 +- 7 files changed, 96 insertions(+), 160 deletions(-) diff --git a/buildall.bat b/buildall.bat index a87638b6..e347a2be 100644 --- a/buildall.bat +++ b/buildall.bat @@ -3,7 +3,7 @@ :- $Id$ :---------------------------------------------------------- -:- batch file to build _many_ KERNELS, hope build works +:- batch file to build _many_ KERNELS, hope build works. :- takes 3 minutes on my(TE) Win2K/P700. your milage may vary :-) :---------------------------------------------------------- diff --git a/config.b b/config.b index 786b0e9a..b839785a 100644 --- a/config.b +++ b/config.b @@ -17,7 +17,7 @@ :-********************************************************************* :-********************************************************************** -:-- define where to find NASM - remember - it should not be protected +:-- define NASM executable - remember - it should not be protected :- mode DJGPP version if you're using Windows NT/2k/XP to compile :- also: DJGPP-nasm crashes when using protected mode Borland's make :-********************************************************************** diff --git a/default.bat b/default.bat index b1c83808..d3c73cec 100644 --- a/default.bat +++ b/default.bat @@ -12,8 +12,8 @@ if "%COMPILER%" == "TC2" set MAKE=%TC2_BASE%\make if "%COMPILER%" == "TURBOCPP" set MAKE=%TP1_BASE%\bin\make if "%COMPILER%" == "TC3" set MAKE=%TC3_BASE%\bin\make if "%COMPILER%" == "BC5" set MAKE=%BC5_BASE%\bin\make -if "%COMPILER%" == "WATCOM" set MAKE=wmake/ms /h -if "%COMPILER%" == "MSCL8" set MAKE=%MS_BASE%\bin\nmake/nologo +if "%COMPILER%" == "WATCOM" set MAKE=wmake /ms /h +if "%COMPILER%" == "MSCL8" set MAKE=%MS_BASE%\bin\nmake /nologo echo Make is %MAKE%. @@ -23,12 +23,12 @@ echo Make is %MAKE%. if not "%XLINK%" == "" goto skip_xlink -if "%COMPILER%" == "TC2" set XLINK=%TC2_BASE%\tlink/m/c -if "%COMPILER%" == "TURBOCPP" set XLINK=%TP1_BASE%\bin\tlink/m/c -if "%COMPILER%" == "TC3" set XLINK=%TC3_BASE%\bin\tlink/m/c -if "%COMPILER%" == "BC5" set XLINK=%BC5_BASE%\bin\tlink/m/c -if "%COMPILER%" == "WATCOM" set XLINK=..\utils\wlinker/ma/nologo -if "%COMPILER%" == "MSCL8" set XLINK=%MS_BASE%\bin\link/ONERROR:NOEXE /ma /nologo +if "%COMPILER%" == "TC2" set XLINK=%TC2_BASE%\tlink /m/c +if "%COMPILER%" == "TURBOCPP" set XLINK=%TP1_BASE%\bin\tlink /m/c +if "%COMPILER%" == "TC3" set XLINK=%TC3_BASE%\bin\tlink /m/c +if "%COMPILER%" == "BC5" set XLINK=%BC5_BASE%\bin\tlink /m/c +if "%COMPILER%" == "WATCOM" set XLINK=..\utils\wlinker /ma/nologo +if "%COMPILER%" == "MSCL8" set XLINK=%MS_BASE%\bin\link /ONERROR:NOEXE /ma /nologo echo Linker is %XLINK%. diff --git a/kernel/makefile b/kernel/makefile index 37d424da..d35e6501 100644 --- a/kernel/makefile +++ b/kernel/makefile @@ -6,36 +6,18 @@ !include "../mkfiles/generic.mak" -RELEASE = 1.00 - -# Compiler and Options - -INCLUDE=..\hdr -LIB= $(COMPILERBASE)\lib - -LIBPATH = . -#AFLAGS = /Mx /DSTANDALONE=1 /I..\HDR - -LIBS =..\lib\device.lib ..\lib\libm.lib -#INITCFLAGS =$(ALLCFLAGS) -zAINIT -zCINIT_TEXT -zDIB -zRID -zTID -zPIGROUP -zBIB \ -#-zGIGROUP -zSIGROUP -#CFLAGS =$(ALLCFLAGS) -zAHMA -zCHMA_TEXT +LIBS=..\lib\device.lib ..\lib\libm.lib HDR=../hdr/ -# *Implicit Rules* -# 'standard' compiles - -.c.obj : - $(CC) $(CFLAGS) $< - -# *List Macros* - +# *List Macros* +# Only 8 files per definition; this is limitation of DOS batch +# files (only 9 directly accessible parameters). OBJS1=kernel.obj entry.obj io.obj console.obj serial.obj printer.obj dsk.obj \ sysclk.obj OBJS2=asmsupt.obj execrh.obj nlssupt.obj procsupt.obj dosidle.obj int2f.obj \ nls_hc.obj -OBJS3= apisupt.obj intr.obj irqstack.obj blockio.obj chario.obj systime.obj \ +OBJS3=apisupt.obj intr.obj irqstack.obj blockio.obj chario.obj systime.obj \ error.obj OBJS4=break.obj dosfns.obj fatdir.obj fatfs.obj fattab.obj fcbfns.obj \ inthndlr.obj @@ -43,188 +25,142 @@ OBJS5=ioctl.obj dosnames.obj memmgr.obj task.obj newstuff.obj nls.obj network.ob OBJS6=prf.obj misc.obj strings.obj syspack.obj lfnapi.obj iasmsupt.obj OBJS7=main.obj config.obj initoem.obj inithma.obj dyninit.obj iprf.obj \ initdisk.obj initclk.obj -OBJS = $(OBJS1) $(OBJS2) $(OBJS3) $(OBJS4) $(OBJS5) $(OBJS6) $(OBJS7) +OBJS=$(OBJS1) $(OBJS2) $(OBJS3) $(OBJS4) $(OBJS5) $(OBJS6) $(OBJS7) # *Explicit Rules* -production: ..\bin\kernel.sys +production: ..\bin\$(TARGET).sys -..\bin\kernel.sys: kernel.sys +..\bin\$(TARGET).sys: kernel.sys copy kernel.sys ..\bin - copy kernel.sys ..\bin\$(THETARGET).sys - copy kernel.map ..\bin\$(THETARGET).map + copy kernel.sys ..\bin\$(TARGET).sys + copy kernel.map ..\bin\$(TARGET).map kernel.sys: kernel.exe ..\utils\exeflat.exe $(XUPX) kernel.exe ..\utils\exeflat kernel.exe kernel.sys 0x60 -S0x10 -S0x8B $(UPXOPT) +kernel.exe: $(TARGET).lnk $(OBJS) $(LIBS) + $(LINK) @$(TARGET).lnk; + clobber: clean -$(RM) kernel.exe kernel.sys status.me clean: - -$(RM) *.res *.obj *.bak *.crf *.xrf *.map *.lst *.cod *.err *.lnk + -$(RM) *.obj *.bak *.crf *.xrf *.map *.lst *.cod *.err *.lnk # XXX: This is a very ugly way of linking the kernel, forced upon us by the # inability of Turbo `make' 2.0 to perform command line redirection. -- ror4 ECHOTO=..\utils\echoto -kernel.res: $(OBJS) $(LIBS) - -$(RM) kernel.res - $(ECHOTO) kernel.res $(OBJS1)+ - $(ECHOTO) kernel.res $(OBJS2)+ - $(ECHOTO) kernel.res $(OBJS3)+ - $(ECHOTO) kernel.res $(OBJS4)+ - $(ECHOTO) kernel.res $(OBJS5)+ - $(ECHOTO) kernel.res $(OBJS6)+ - $(ECHOTO) kernel.res $(OBJS7) - $(ECHOTO) kernel.res kernel.exe - $(ECHOTO) kernel.res kernel.map - $(ECHOTO) kernel.res $(LIBS) - -kernel.exe: kernel.res $(OBJS) $(LIBS) - $(LINK) @kernel.res; +$(TARGET).lnk: turboc.cfg makefile ..\mkfiles\generic.mak ..\mkfiles\$(COMPILER).mak + -$(RM) *.lnk + $(ECHOTO) $(TARGET).lnk $(OBJS1)+ + $(ECHOTO) $(TARGET).lnk $(OBJS2)+ + $(ECHOTO) $(TARGET).lnk $(OBJS3)+ + $(ECHOTO) $(TARGET).lnk $(OBJS4)+ + $(ECHOTO) $(TARGET).lnk $(OBJS5)+ + $(ECHOTO) $(TARGET).lnk $(OBJS6)+ + $(ECHOTO) $(TARGET).lnk $(OBJS7) + $(ECHOTO) $(TARGET).lnk kernel.exe + $(ECHOTO) $(TARGET).lnk kernel.map + $(ECHOTO) $(TARGET).lnk $(LIBS) # *Individual File Dependencies* -kernel.obj: kernel.asm segs.inc ludivmul.inc - -console.obj: console.asm io.inc - -printer.obj: printer.asm io.inc - -serial.obj: serial.asm io.inc - -entry.obj: entry.asm segs.inc $(HDR)stacks.inc - -apisupt.obj: apisupt.asm segs.inc - -execrh.obj: execrh.asm segs.inc - -int2f.obj: int2f.asm segs.inc - -intr.obj: intr.asm segs.inc - -io.obj: io.asm segs.inc - -irqstack.obj: irqstack.asm - -nls_hc.obj: nls_hc.asm segs.inc - -nlssupt.obj: nlssupt.asm segs.inc - -procsupt.obj: procsupt.asm segs.inc $(HDR)stacks.inc - -dosidle.obj: dosidle.asm segs.inc - -# XXX: Special handling for initialization modules -- this is required because -# TC 2.01 cannot handle `#pragma option' like TC 3 can. -- ror4 +apisupt.obj: apisupt.asm segs.inc $(TARGET).lnk +asmsupt.obj: asmsupt.asm segs.inc $(TARGET).lnk +console.obj: console.asm io.inc $(TARGET).lnk +dosidle.obj: dosidle.asm segs.inc $(TARGET).lnk +entry.obj: entry.asm segs.inc $(HDR)stacksinc $(TARGET).lnk +execrh.obj: execrh.asm segs.inc $(TARGET).lnk +int2f.obj: int2f.asm segs.inc $(HDR)stacksinc $(TARGET).lnk +intr.obj: intr.asm segs.inc $(TARGET).lnk +io.obj: io.asm segs.inc $(TARGET).lnk +irqstack.obj: irqstack.asm segs.inc $(TARGET).lnk +kernel.obj: kernel.asm segs.inc ludivmul.inc $(TARGET).lnk +nls_hc.obj: nls_hc.asm segs.inc $(TARGET).lnk +nlssupt.obj: nlssupt.asm segs.inc $(TARGET).lnk +printer.obj: printer.asm io.inc $(TARGET).lnk +procsupt.obj: procsupt.asm segs.inc $(HDR)stacks.inc $(TARGET).lnk +serial.obj: serial.asm io.inc $(TARGET).lnk INITHEADERS=init-mod.h init-dat.h -CONFIGURATION = turboc.cfg makefile ..\mkfiles\generic.mak ..\mkfiles\$(COMPILER).MAK - -HEADERS=\ +HDRS=\ $(HDR)portab.h $(HDR)device.h $(HDR)mcb.h $(HDR)pcb.h \ $(HDR)fat.h $(HDR)fcb.h $(HDR)tail.h $(HDR)time.h $(HDR)process.h \ $(HDR)dcb.h $(HDR)sft.h $(HDR)cds.h $(HDR)exe.h $(HDR)fnode.h \ $(HDR)dirmatch.h $(HDR)file.h $(HDR)clock.h $(HDR)kbd.h $(HDR)error.h \ - $(HDR)version.h globals.h proto.h dyndata.h - -# XXX: I generated these using `gcc -MM' and `sed', so they may not be -# completely correct... -- ror4 - -blockio.obj: blockio.c $(HEADERS) $(CONFIGURATION) - -break.obj: break.c $(HEADERS) $(CONFIGURATION) - -chario.obj: chario.c $(HEADERS) $(CONFIGURATION) - -dosfns.obj: dosfns.c $(HEADERS) $(CONFIGURATION) - -dosnames.obj: dosnames.c $(HEADERS) $(CONFIGURATION) - -dsk.obj: dsk.c $(HEADERS) $(CONFIGURATION) - -error.obj: error.c $(HEADERS) $(CONFIGURATION) - -fatdir.obj: fatdir.c $(HEADERS) $(CONFIGURATION) - -fatfs.obj: fatfs.c $(HEADERS) $(CONFIGURATION) - -fattab.obj: fattab.c $(HEADERS) $(CONFIGURATION) - -fcbfns.obj: fcbfns.c $(HEADERS) $(CONFIGURATION) - -inthndlr.obj: inthndlr.c $(HEADERS) $(CONFIGURATION) - -ioctl.obj: ioctl.c $(HEADERS) $(CONFIGURATION) - -memmgr.obj: memmgr.c $(HEADERS) $(CONFIGURATION) - -misc.obj: misc.c $(HEADERS) $(CONFIGURATION) - -lfnapi.obj: lfnapi.c $(HEADERS) $(CONFIGURATION) - -newstuff.obj: newstuff.c $(HEADERS) $(CONFIGURATION) - -network.obj: network.c $(HEADERS) $(CONFIGURATION) - -nls.obj: nls.c $(HEADERS) $(CONFIGURATION) - -# \ -# 001-437.nls - -prf.obj: prf.c $(HDR)portab.h $(CONFIGURATION) - -strings.obj: strings.c $(CONFIGURATION) - -sysclk.obj: sysclk.c $(HEADERS) $(CONFIGURATION) - -syspack.obj: syspack.c $(HEADERS) $(CONFIGURATION) - -systime.obj: systime.c $(HEADERS) $(CONFIGURATION) - -task.obj: task.c $(HEADERS) $(CONFIGURATION) + $(HDR)version.h dyndata.h +HEADERS=$(HDRS) globals.h proto.h +INITHEADERS=$(HDRS) init-mod.h init-dat.h + +blockio.obj: blockio.c $(HEADERS) $(TARGET).lnk +break.obj: break.c $(HEADERS) $(TARGET).lnk +chario.obj: chario.c $(HEADERS) $(TARGET).lnk +dosfns.obj: dosfns.c $(HEADERS) $(TARGET).lnk +dosnames.obj: dosnames.c $(HEADERS) $(TARGET).lnk +dsk.obj: dsk.c $(HEADERS) $(TARGET).lnk +error.obj: error.c $(HEADERS) $(TARGET).lnk +fatdir.obj: fatdir.c $(HEADERS) $(TARGET).lnk +fatfs.obj: fatfs.c $(HEADERS) $(TARGET).lnk +fattab.obj: fattab.c $(HEADERS) $(TARGET).lnk +fcbfns.obj: fcbfns.c $(HEADERS) $(TARGET).lnk +inthndlr.obj: inthndlr.c $(HEADERS) $(TARGET).lnk +ioctl.obj: ioctl.c $(HEADERS) $(TARGET).lnk +memmgr.obj: memmgr.c $(HEADERS) $(TARGET).lnk +misc.obj: misc.c $(HEADERS) $(TARGET).lnk +lfnapi.obj: lfnapi.c $(HEADERS) $(TARGET).lnk +newstuff.obj: newstuff.c $(HEADERS) $(TARGET).lnk +network.obj: network.c $(HEADERS) $(TARGET).lnk +nls.obj: nls.c $(HEADERS) $(TARGET).lnk +prf.obj: prf.c $(HDR)portab.h $(TARGET).lnk +strings.obj: strings.c $(TARGET).lnk +sysclk.obj: sysclk.c $(HEADERS) $(TARGET).lnk +syspack.obj: syspack.c $(HEADERS) $(TARGET).lnk +systime.obj: systime.c $(HEADERS) $(TARGET).lnk +task.obj: task.c $(HEADERS) $(TARGET).lnk # now the funny stuff :-) # Files in the INIT segment -# $(CC) $(INITCFLAGS) -c $*.c -# patchobj $*.obj $(INITPATCH) +# XXX: Special handling for initialization modules -- this is required because +# TC 2.01 cannot handle `#pragma option' like TC 3 can. -- ror4 -config.obj: config.c $(INITHEADERS) $(HEADERS) $(CONFIGURATION) +config.obj: config.c $(INITHEADERS) $(TARGET).lnk $(CC) $(INITCFLAGS) $*.c $(INITPATCH) $*.obj -initoem.obj: initoem.c $(INITHEADERS) $(HEADERS) $(CONFIGURATION) +initoem.obj: initoem.c $(INITHEADERS) $(TARGET).lnk $(CC) $(INITCFLAGS) $*.c $(INITPATCH) $*.obj -main.obj: main.c $(INITHEADERS) $(HEADERS) $(CONFIGURATION) +main.obj: main.c $(INITHEADERS) $(TARGET).lnk $(CC) $(INITCFLAGS) $*.c $(INITPATCH) $*.obj -inithma.obj: inithma.c $(INITHEADERS) $(HEADERS) $(CONFIGURATION) +inithma.obj: inithma.c $(INITHEADERS) $(TARGET).lnk $(CC) $(INITCFLAGS) $*.c $(INITPATCH) $*.obj -dyninit.obj: dyninit.c $(INITHEADERS) $(HEADERS) $(CONFIGURATION) +dyninit.obj: dyninit.c $(INITHEADERS) $(TARGET).lnk $(CC) $(INITCFLAGS) $*.c $(INITPATCH) $*.obj -initdisk.obj: initdisk.c $(INITHEADERS) $(HEADERS) $(CONFIGURATION) +initdisk.obj: initdisk.c $(INITHEADERS) $(TARGET).lnk $(CC) $(INITCFLAGS) $*.c $(INITPATCH) $*.obj -initclk.obj: initclk.c $(INITHEADERS) $(HEADERS) $(CONFIGURATION) +initclk.obj: initclk.c $(INITHEADERS) $(TARGET).lnk $(CC) $(INITCFLAGS) $*.c $(INITPATCH) $*.obj #the string functions for INIT_TEXT -iasmsupt.obj: asmsupt.asm $(CONFIGURATION) +iasmsupt.obj: asmsupt.asm $(TARGET).lnk $(NASM) -D$(COMPILER) -D_INIT $(NASMFLAGS) -f obj -o iasmsupt.obj asmsupt.asm #the printf for INIT_TEXT - yet another special case, this file includes prf.c -iprf.obj: iprf.c prf.c $(HDR)portab.h $(CONFIGURATION) +iprf.obj: iprf.c prf.c $(HDR)portab.h $(TARGET).lnk $(CC) $(INITCFLAGS) $*.c $(INITPATCH) $*.obj diff --git a/mkfiles/generic.mak b/mkfiles/generic.mak index f30bdc12..d1071303 100644 --- a/mkfiles/generic.mak +++ b/mkfiles/generic.mak @@ -32,7 +32,7 @@ INITPATCH=@rem !include "..\mkfiles\$(COMPILER).mak" -THETARGET=$(TARGET)$(XCPU)$(XFAT) +TARGET=$(TARGET)$(XCPU)$(XFAT) RM=..\utils\rmfiles .asm.obj : diff --git a/utils/rmfiles.bat b/utils/rmfiles.bat index efaa4fa8..a4a052e9 100644 --- a/utils/rmfiles.bat +++ b/utils/rmfiles.bat @@ -2,7 +2,7 @@ :loop_commandline if \%1 == \ goto done_with_commandline -if exist %1 del %1 +if exist %1 del %1>nul shift goto loop_commandline diff --git a/utils/wlinker.bat b/utils/wlinker.bat index 36e746ab..9d25845e 100755 --- a/utils/wlinker.bat +++ b/utils/wlinker.bat @@ -1,4 +1,4 @@ @echo off ms2wlink %1 %2 %3 %4 %5 %6 %7 %8 %9 ,,,, > kernel.lnk echo op map,statics,verbose >> kernel.lnk -wlink < kernel.lnk +call wlink @kernel.lnk From 46833929f9b0e1d0231497a25df08c40650f4672 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sun, 11 Apr 2004 17:22:18 +0000 Subject: [PATCH 443/671] Some variables need to be DOSFAR now; init code is no longer tiny but small. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@865 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/init-mod.h | 6 +++--- mkfiles/mscl8.mak | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/kernel/init-mod.h b/kernel/init-mod.h index 6c158146..d6cfc31e 100644 --- a/kernel/init-mod.h +++ b/kernel/init-mod.h @@ -270,10 +270,10 @@ struct RelocatedEntry { }; extern struct RelocationTable - DOSTEXTFAR ASM _HMARelocationTableStart[], - DOSTEXTFAR ASM _HMARelocationTableEnd[]; + DOSFAR ASM _HMARelocationTableStart[], + DOSFAR ASM _HMARelocationTableEnd[]; -extern void FAR *DOSTEXTFAR ASM XMSDriverAddress; +extern void FAR *DOSFAR ASM XMSDriverAddress; extern VOID ASMPASCAL FAR _EnableA20(VOID); extern VOID ASMPASCAL FAR _DisableA20(VOID); diff --git a/mkfiles/mscl8.mak b/mkfiles/mscl8.mak index d7e38d42..cd5c53b2 100644 --- a/mkfiles/mscl8.mak +++ b/mkfiles/mscl8.mak @@ -42,6 +42,6 @@ TARGET=KMS ALLCFLAGS=-I..\hdr $(TARGETOPT) $(ALLCFLAGS) -nologo -Zl -Fc -WX -Gr -f- -Os -Gs -Ob1 -OV4 -Gy -Oe -Zp1 -INITCFLAGS=$(ALLCFLAGS) -NTINIT_TEXT -AT +INITCFLAGS=$(ALLCFLAGS) -NTINIT_TEXT CFLAGS=$(ALLCFLAGS) -NTHMA_TEXT INITPATCH = ..\utils\patchobj _DATA=IDATA DATA=ID BSS=ID DGROUP=I_GROUP CONST=IC From 5c72b4a0e9d46f5f1e5c77088d4ecf50c5584587 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Mon, 12 Apr 2004 09:36:07 +0000 Subject: [PATCH 444/671] Fixed some missing dots git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@866 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/makefile | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/kernel/makefile b/kernel/makefile index d35e6501..78dfe291 100644 --- a/kernel/makefile +++ b/kernel/makefile @@ -72,9 +72,9 @@ apisupt.obj: apisupt.asm segs.inc $(TARGET).lnk asmsupt.obj: asmsupt.asm segs.inc $(TARGET).lnk console.obj: console.asm io.inc $(TARGET).lnk dosidle.obj: dosidle.asm segs.inc $(TARGET).lnk -entry.obj: entry.asm segs.inc $(HDR)stacksinc $(TARGET).lnk +entry.obj: entry.asm segs.inc $(HDR)stacks.inc $(TARGET).lnk execrh.obj: execrh.asm segs.inc $(TARGET).lnk -int2f.obj: int2f.asm segs.inc $(HDR)stacksinc $(TARGET).lnk +int2f.obj: int2f.asm segs.inc $(HDR)stacks.inc $(TARGET).lnk intr.obj: intr.asm segs.inc $(TARGET).lnk io.obj: io.asm segs.inc $(TARGET).lnk irqstack.obj: irqstack.asm segs.inc $(TARGET).lnk @@ -85,8 +85,6 @@ printer.obj: printer.asm io.inc $(TARGET).lnk procsupt.obj: procsupt.asm segs.inc $(HDR)stacks.inc $(TARGET).lnk serial.obj: serial.asm io.inc $(TARGET).lnk -INITHEADERS=init-mod.h init-dat.h - HDRS=\ $(HDR)portab.h $(HDR)device.h $(HDR)mcb.h $(HDR)pcb.h \ $(HDR)fat.h $(HDR)fcb.h $(HDR)tail.h $(HDR)time.h $(HDR)process.h \ From 5d712fc2a6790bc75e8633c5d75ae4e62b974cea Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Tue, 13 Apr 2004 10:46:37 +0000 Subject: [PATCH 445/671] Avoid bitfields for fnodes, using flags instead. Replaced droot field by checks for f_dirstart == 0. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@867 6ac86273-5f31-0410-b378-82cca8765d1b --- hdr/fnode.h | 15 ++++++------ kernel/fatdir.c | 53 ++++++++++++++-------------------------- kernel/fatfs.c | 65 +++++++++++++++++++++---------------------------- 3 files changed, 53 insertions(+), 80 deletions(-) diff --git a/hdr/fnode.h b/hdr/fnode.h index 36be8576..f17a7cb7 100644 --- a/hdr/fnode.h +++ b/hdr/fnode.h @@ -39,13 +39,7 @@ struct f_node { UWORD f_count; /* number of uses of this file */ COUNT f_mode; /* read, write, read-write, etc */ - struct { - BITS f_dmod:1; /* directory has been modified */ - BITS f_droot:1; /* directory is the root */ - BITS f_dnew:1; /* fnode is new and needs fill */ - BITS f_ddir:1; /* fnode is assigned to dir */ - BITS f_ddate:1; /* date set using setdate */ - } f_flags; /* file flags */ + UWORD f_flags; /* file flags */ struct dirent f_dir; /* this file's dir entry image */ @@ -59,6 +53,11 @@ struct f_node { CLUSTER f_cluster; /* the cluster we are at */ }; +#define F_DMOD 1 /* directory has been modified */ +#define F_DNEW 2 /* fnode is new and needs fill */ +#define F_DDIR 4 /* fnode is assigned to dir */ +#define F_DDATE 8 /* date set using setdate */ + typedef struct f_node *f_node_ptr; struct lfn_inode { @@ -66,7 +65,7 @@ struct lfn_inode { /* If the string is empty, */ /* then file has the 8.3 name */ struct dirent l_dir; /* Directory entry image */ - ULONG l_diroff; /* Current directory entry offset */ + UWORD l_diroff; /* Current directory entry offset */ }; typedef struct lfn_inode FAR * lfn_inode_ptr; diff --git a/kernel/fatdir.c b/kernel/fatdir.c index 7a741b66..23df2c0d 100644 --- a/kernel/fatdir.c +++ b/kernel/fatdir.c @@ -42,31 +42,18 @@ static BYTE *fatdirRcsId = VOID dir_init_fnode(f_node_ptr fnp, CLUSTER dirstart) { /* reset the directory flags */ - fnp->f_flags.f_dmod = FALSE; - fnp->f_flags.f_droot = FALSE; - fnp->f_flags.f_ddir = TRUE; - fnp->f_flags.f_dnew = TRUE; + fnp->f_flags = F_DDIR | F_DNEW; fnp->f_diroff = 0; fnp->f_offset = 0l; fnp->f_cluster_offset = 0; /* root directory */ - if (dirstart == 0) - { #ifdef WITHFAT32 + if (dirstart == 0) if (ISFAT32(fnp->f_dpb)) - { - fnp->f_cluster = fnp->f_dirstart = fnp->f_dpb->dpb_xrootclst; - } - else + dirstart = fnp->f_dpb->dpb_xrootclst; #endif - { - fnp->f_dirstart = 0; - fnp->f_flags.f_droot = TRUE; - } - } - else /* non-root */ - fnp->f_cluster = fnp->f_dirstart = dirstart; + fnp->f_cluster = fnp->f_dirstart = dirstart; } f_node_ptr dir_open(register const char *dirname) @@ -216,7 +203,7 @@ COUNT dir_read(REG f_node_ptr fnp) /* can't have more than 65535 directory entries remove lfn entries may call us with new_diroff == -1 for root directories though */ - if (!fnp->f_flags.f_droot && new_diroff >= 65535U) + if (fnp->f_dirstart != 0 && new_diroff >= 65535U) return DE_SEEK; /* Directories need to point to their current offset, not for */ @@ -224,7 +211,7 @@ COUNT dir_read(REG f_node_ptr fnp) /* directory entry, we will update the offset on entry rather */ /* than wait until exit. If it was new, clear the special new */ /* flag. */ - if (!fnp->f_flags.f_dnew) + if (!(fnp->f_flags & F_DNEW)) new_diroff++; /* Determine if we hit the end of the directory. If we have, */ @@ -232,7 +219,7 @@ COUNT dir_read(REG f_node_ptr fnp) /* dirent portion of the fnode, clear the f_dmod bit and leave, */ /* but only for root directories */ - if (fnp->f_flags.f_droot) + if (fnp->f_dirstart == 0) { if (new_diroff >= fnp->f_dpb->dpb_dirents) return DE_SEEK; @@ -277,8 +264,7 @@ COUNT dir_read(REG f_node_ptr fnp) swap_deleted(fnp->f_dir.dir_name); /* Update the fnode's directory info */ - fnp->f_flags.f_dmod = FALSE; - fnp->f_flags.f_dnew = FALSE; + fnp->f_flags &= ~(F_DMOD | F_DNEW); fnp->f_diroff = new_diroff; /* and for efficiency, stop when we hit the first */ @@ -291,8 +277,8 @@ COUNT dir_read(REG f_node_ptr fnp) * Writes directory entry pointed by fnp to disk. In case of erroneous * situation fnode is released. * The caller should set - * 1. f_dmod flag if original directory entry was modified. - * 2. f_dmod & f_dnew flags if new directory entry is created. In this + * 1. F_DMOD flag if original directory entry was modified. + * 2. F_DMOD & F_DNEW flags if new directory entry is created. In this * case the reserved fields is cleared, but only if new dentry isn't * a LFN entry (has D_LFN attribute). * Return value. @@ -305,15 +291,15 @@ BOOL dir_write(REG f_node_ptr fnp) struct buffer FAR *bp; REG UWORD secsize = fnp->f_dpb->dpb_secsize; - if (!fnp->f_flags.f_ddir) + if (!(fnp->f_flags & F_DDIR)) return FALSE; /* Update the entry if it was modified by a write or create... */ - if (fnp->f_flags.f_dmod) + if (fnp->f_flags & F_DMOD) { /* Root is a consecutive set of blocks, so handling is */ /* simple. */ - if (fnp->f_flags.f_droot) + if (fnp->f_dirstart == 0) { bp = getblock(fnp->f_diroff / (secsize / DIRENT_SIZE) + fnp->f_dpb->dpb_dirstrt, @@ -362,7 +348,7 @@ BOOL dir_write(REG f_node_ptr fnp) return FALSE; } - if (fnp->f_flags.f_dnew && fnp->f_dir.dir_attrib != D_LFN) + if ((fnp->f_flags & F_DNEW) && fnp->f_dir.dir_attrib != D_LFN) fmemset(&fnp->f_dir.dir_case, 0, 8); swap_deleted(fnp->f_dir.dir_name); @@ -382,7 +368,7 @@ BOOL dir_write(REG f_node_ptr fnp) VOID dir_close(REG f_node_ptr fnp) { /* Test for invalid f_nodes */ - if (fnp == NULL || !fnp->f_flags.f_ddir) + if (fnp == NULL || !(fnp->f_flags & F_DDIR)) return; #ifndef IPL @@ -479,10 +465,7 @@ COUNT dos_findfirst(UCOUNT attr, BYTE * name) else { dmp->dm_entry = 0; - if (!fnp->f_flags.f_droot) - dmp->dm_dircluster = fnp->f_dirstart; - else - dmp->dm_dircluster = 0; + dmp->dm_dircluster = fnp->f_dirstart; dir_close(fnp); return dos_findnext(); } @@ -526,11 +509,11 @@ COUNT dos_findnext(void) /* Search through the directory to find the entry, but do a */ /* seek first. */ - fnp->f_flags.f_dnew = TRUE; + fnp->f_flags |= F_DNEW; if (dmp->dm_entry > 0) { fnp->f_diroff = dmp->dm_entry - 1; - fnp->f_flags.f_dnew = FALSE; + fnp->f_flags &= ~F_DNEW; } /* Loop through the directory */ diff --git a/kernel/fatfs.c b/kernel/fatfs.c index c0d3a2da..174cf029 100644 --- a/kernel/fatfs.c +++ b/kernel/fatfs.c @@ -225,10 +225,7 @@ long dos_open(char *path, unsigned flags, unsigned attrib) if (status != S_OPENED) { init_direntry(&fnp->f_dir, attrib, FREE); - fnp->f_flags.f_dmod = TRUE; - fnp->f_flags.f_ddate = FALSE; - fnp->f_flags.f_dnew = FALSE; - fnp->f_flags.f_ddir = TRUE; + fnp->f_flags = F_DMOD | F_DDIR; if (!dir_write(fnp)) { release_f_node(fnp); @@ -245,12 +242,11 @@ long dos_open(char *path, unsigned flags, unsigned attrib) setdstart(fnp->f_dpb, &fnp->f_dir, FREE); fnp->f_cluster_offset = 0; } - - fnp->f_flags.f_dmod = (status != S_OPENED); - fnp->f_flags.f_ddate = FALSE; - fnp->f_flags.f_dnew = FALSE; - fnp->f_flags.f_ddir = FALSE; - + + fnp->f_flags = 0; + if (status != S_OPENED) + fnp->f_flags = F_DMOD; + merge_file_changes(fnp, status == S_OPENED); /* /// Added - Ron Cemer */ /* /// Moved from above. - Ron Cemer */ fnp->f_cluster = getdstart(fnp->f_dpb, &fnp->f_dir); @@ -288,9 +284,9 @@ COUNT dos_close(COUNT fd) if (fnp == (f_node_ptr) 0) return DE_INVLDHNDL; - if (fnp->f_flags.f_dmod) + if (fnp->f_flags & F_DMOD) { - if (fnp->f_flags.f_ddate == FALSE) + if (!(fnp->f_flags & F_DDATE)) { fnp->f_dir.dir_time = dos_gettime(); fnp->f_dir.dir_date = dos_getdate(); @@ -298,7 +294,7 @@ COUNT dos_close(COUNT fd) merge_file_changes(fnp, FALSE); /* /// Added - Ron Cemer */ } - fnp->f_flags.f_ddir = TRUE; + fnp->f_flags |= F_DDIR; dir_close(fnp); return SUCCESS; @@ -443,7 +439,7 @@ COUNT remove_lfn_entries(f_node_ptr fnp) if (fnp->f_dir.dir_attrib != D_LFN) break; fnp->f_dir.dir_name[0] = DELETED; - fnp->f_flags.f_dmod = TRUE; + fnp->f_flags |= F_DMOD; if (!dir_write(fnp)) return DE_BLKINVLD; } fnp->f_diroff = original_diroff - 1; @@ -546,7 +542,7 @@ STATIC COUNT delete_dir_entry(f_node_ptr fnp) /* The directory has been modified, so set the */ /* bit before closing it, allowing it to be */ /* updated */ - fnp->f_flags.f_dmod = TRUE; + fnp->f_flags |= F_DMOD; dir_close(fnp); /* SUCCESSful completion, return it */ @@ -631,7 +627,7 @@ COUNT dos_rmdir(BYTE * path) /* Check that the directory is empty. Only the */ /* "." and ".." are permissable. */ - fnp->f_flags.f_dmod = FALSE; + fnp->f_flags &= ~F_DMOD; fnp1 = dir_open(path); if (fnp1 == NULL) { @@ -749,9 +745,7 @@ COUNT dos_rename(BYTE * path1, BYTE * path2, int attrib) /* The directory has been modified, so set the bit before */ /* closing it, allowing it to be updated. */ - fnp1->f_flags.f_dmod = fnp2->f_flags.f_dmod = TRUE; - fnp1->f_flags.f_dnew = fnp2->f_flags.f_dnew = FALSE; - fnp1->f_flags.f_ddir = fnp2->f_flags.f_ddir = TRUE; + fnp1->f_flags = fnp2->f_flags = F_DMOD | F_DDIR; /* Ok, so we can delete this one. Save the file info. */ *(fnp1->f_dir.dir_name) = DELETED; @@ -833,7 +827,7 @@ STATIC BOOL find_free(f_node_ptr fnp) /* available, tries to extend the directory. */ STATIC int alloc_find_free(f_node_ptr fnp, char *path, char *fcbname) { - fnp->f_flags.f_dmod = FALSE; + fnp->f_flags &= ~F_DMOD; dir_close(fnp); fnp = split_path(path, fcbname); @@ -843,9 +837,9 @@ STATIC int alloc_find_free(f_node_ptr fnp, char *path, char *fcbname) /* find an empty slot, we need to abort. */ if (find_free(fnp) == 0) { - if (fnp->f_flags.f_droot) + if (fnp->f_dirstart == 0) { - fnp->f_flags.f_dmod = FALSE; + fnp->f_flags &= ~F_DMOD; dir_close(fnp); return DE_TOOMANY; } @@ -934,8 +928,8 @@ COUNT dos_setftime(COUNT fd, date dp, time tp) /* Set the date and time from the fnode and return */ fnp->f_dir.dir_date = dp; fnp->f_dir.dir_time = tp; - fnp->f_flags.f_dmod = TRUE; /* mark file as modified */ - fnp->f_flags.f_ddate = TRUE; /* set this date upon closing */ + /* mark file as modified and set this date upon closing */ + fnp->f_flags |= F_DMOD | F_DDATE; save_far_f_node(fnp); return SUCCESS; @@ -1130,9 +1124,7 @@ COUNT dos_mkdir(BYTE * dir) init_direntry(&fnp->f_dir, D_DIR, free_fat); - fnp->f_flags.f_dmod = TRUE; - fnp->f_flags.f_dnew = FALSE; - fnp->f_flags.f_ddir = TRUE; + fnp->f_flags = F_DMOD | F_DDIR; fnp->f_offset = 0l; @@ -1205,7 +1197,7 @@ COUNT dos_mkdir(BYTE * dir) flush_buffers(dpbp->dpb_unit); /* Close the directory so that the entry is updated */ - fnp->f_flags.f_dmod = TRUE; + fnp->f_flags |= F_DMOD; dir_close(fnp); return SUCCESS; @@ -1232,7 +1224,7 @@ STATIC CLUSTER extend(f_node_ptr fnp) link_fat(fnp->f_dpb, free_fat, LONG_LAST_CLUSTER); /* Mark the directory so that the entry is updated */ - fnp->f_flags.f_dmod = TRUE; + fnp->f_flags |= F_DMOD; return free_fat; } @@ -1337,7 +1329,7 @@ COUNT map_cluster(REG f_node_ptr fnp, COUNT mode) if (relcluster < fnp->f_cluster_offset) { /* Set internal index and cluster size. */ - fnp->f_cluster = fnp->f_flags.f_ddir ? fnp->f_dirstart : + fnp->f_cluster = (fnp->f_flags & F_DDIR) ? fnp->f_dirstart : getdstart(fnp->f_dpb, &fnp->f_dir); fnp->f_cluster_offset = 0; } @@ -1561,8 +1553,8 @@ long rwblock(COUNT fd, VOID FAR * buffer, UCOUNT count, int mode) if (mode==XFR_WRITE) { fnp->f_dir.dir_attrib |= D_ARCHIVE; - fnp->f_flags.f_dmod = TRUE; /* mark file as modified */ - fnp->f_flags.f_ddate = FALSE; /* set date not valid any more */ + fnp->f_flags |= F_DMOD; /* mark file as modified */ + fnp->f_flags &= ~F_DDATE; /* set date not valid any more */ if (dos_extend(fnp) != SUCCESS) { @@ -1609,7 +1601,7 @@ long rwblock(COUNT fd, VOID FAR * buffer, UCOUNT count, int mode) /* Do an EOF test and return whatever was transferred */ /* but only for regular files. */ - if (mode == XFR_READ && !(fnp->f_flags.f_ddir) && (fnp->f_offset >= fnp->f_dir.dir_size)) + if (mode == XFR_READ && !(fnp->f_flags & F_DDIR) && (fnp->f_offset >= fnp->f_dir.dir_size)) { save_far_f_node(fnp); return ret_cnt; @@ -1659,7 +1651,7 @@ long rwblock(COUNT fd, VOID FAR * buffer, UCOUNT count, int mode) /* see comments above */ - if (!fnp->f_flags.f_ddir && /* don't experiment with directories yet */ + if (!(fnp->f_flags & F_DDIR) && /* don't experiment with directories yet */ boff == 0) /* complete sectors only */ { static ULONG startoffset; @@ -1749,7 +1741,7 @@ long rwblock(COUNT fd, VOID FAR * buffer, UCOUNT count, int mode) /* Then compare to what is left, since we can transfer */ /* a maximum of what is left. */ xfr_cnt = min(to_xfer, secsize - boff); - if (!fnp->f_flags.f_ddir && mode == XFR_READ) + if (!(fnp->f_flags & F_DDIR) && mode == XFR_READ) xfr_cnt = (UWORD) min(xfr_cnt, fnp->f_dir.dir_size - fnp->f_offset); /* transfer a block */ @@ -2010,8 +2002,7 @@ COUNT dos_setfattr(BYTE * name, UWORD attrp) /* set attributes that user requested */ fnp->f_dir.dir_attrib |= attrp; /* JPP */ - fnp->f_flags.f_dmod = TRUE; - fnp->f_flags.f_ddate = TRUE; + fnp->f_flags |= F_DMOD | F_DDATE; save_far_f_node(fnp); dos_close(fd); return SUCCESS; From 7eb951437765d2d58e1fd2f41b045ecbad00754b Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Tue, 13 Apr 2004 10:54:33 +0000 Subject: [PATCH 446/671] Move the ddt bitfields to df_descflags. Let SetLogDev call GetLogdev, eliminating common code. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@868 6ac86273-5f31-0410-b378-82cca8765d1b --- hdr/device.h | 5 +++-- kernel/dsk.c | 26 +++++++------------------- kernel/initdisk.c | 32 ++++++++++++-------------------- 3 files changed, 22 insertions(+), 41 deletions(-) diff --git a/hdr/device.h b/hdr/device.h index 6f07d528..f8f2f5e2 100644 --- a/hdr/device.h +++ b/hdr/device.h @@ -242,8 +242,6 @@ typedef struct ddtstruct { ULONG ddt_serialno; /* serial number */ UBYTE ddt_fstype[9]; /* ASCIIZ filesystem type ("FAT12 " or "FAT16 ") */ ULONG ddt_offset; /* relative partition offset */ - BITS ddt_LBASupported:1; /* set, if INT13 extensions enabled */ - BITS ddt_WriteVerifySupported:1; } ddt; /* description flag bits */ @@ -257,6 +255,9 @@ typedef struct ddtstruct { #define DF_DPCHANGED 0x080 #define DF_REFORMAT 0x100 #define DF_NOACCESS 0x200 +/* freedos specific flag bits */ +#define DF_LBA 0x400 +#define DF_WRTVERIFY 0x800 /* typedef struct ddtstruct ddt;*/ diff --git a/kernel/dsk.c b/kernel/dsk.c index 59d6a77c..edc8051e 100644 --- a/kernel/dsk.c +++ b/kernel/dsk.c @@ -317,25 +317,13 @@ STATIC WORD Getlogdev(rqptr rp, ddt * pddt) STATIC WORD Setlogdev(rqptr rp, ddt * pddt) { - int i; - ddt *pddt2 = getddt(0); - - if (!(pddt->ddt_descflags & DF_MULTLOG)) { - rp->r_unit = 0; + unsigned char unit = rp->r_unit; + Getlogdev(rp, pddt); + if (rp->r_unit == 0) return S_DONE; - } - - for (i = 0; i < blk_dev.dh_name[0]; i++, pddt2++) - { - if (pddt->ddt_driveno == pddt2->ddt_driveno && - (pddt2->ddt_descflags & (DF_MULTLOG | DF_CURLOG)) == - (DF_MULTLOG | DF_CURLOG)) - break; - } - - pddt2->ddt_descflags &= ~DF_CURLOG; + (&(getddt(0))[rp->r_unit - 1])->ddt_descflags &= ~DF_CURLOG; pddt->ddt_descflags |= DF_CURLOG; - rp->r_unit++; + rp->r_unit = unit + 1; return S_DONE; } @@ -995,7 +983,7 @@ STATIC int LBA_Transfer(ddt * pddt, UWORD mode, VOID FAR * buffer, for (num_retries = 0; num_retries < N_RETRY; num_retries++) { - if (pddt->ddt_LBASupported && mode != LBA_FORMAT) + if ((pddt->ddt_descflags & DF_LBA) && mode != LBA_FORMAT) { dap.number_of_blocks = count; @@ -1006,7 +994,7 @@ STATIC int LBA_Transfer(ddt * pddt, UWORD mode, VOID FAR * buffer, /* Load the registers and call the interrupt. */ - if (pddt->ddt_WriteVerifySupported || mode != LBA_WRITE_VERIFY) + if ((pddt->ddt_descflags & DF_WRTVERIFY) || mode != LBA_WRITE_VERIFY) { error_code = fl_lba_ReadWrite(pddt->ddt_driveno, mode, &dap); } diff --git a/kernel/initdisk.c b/kernel/initdisk.c index f4f2e49b..e9c7942e 100644 --- a/kernel/initdisk.c +++ b/kernel/initdisk.c @@ -243,8 +243,7 @@ struct _bios_LBA_disk_parameterS { struct DriveParamS { UBYTE driveno; /* = 0x8x */ - BITS LBA_supported:1; /* set, if INT13 extensions enabled */ - BITS WriteVerifySupported:1; /* */ + UWORD descflags; ULONG total_sectors; struct CHS chs; /* for normal INT 13 */ @@ -584,17 +583,16 @@ void DosDefinePartition(struct DriveParamS *driveParam, pddt->ddt_next = MK_FP(0, 0xffff); pddt->ddt_driveno = driveParam->driveno; pddt->ddt_logdriveno = nUnits; - pddt->ddt_LBASupported = driveParam->LBA_supported; + pddt->ddt_descflags |= driveParam->descflags; /* Turn of LBA if not forced and the partition is within 1023 cyls and of the right type */ /* the FileSystem type was internally converted to LBA_xxxx if a non-LBA partition above cylinder 1023 was found */ if (!InitKernelConfig.ForceLBA && !ExtLBAForce && !IsLBAPartition(pEntry->FileSystem)) - pddt->ddt_LBASupported = FALSE; - pddt->ddt_WriteVerifySupported = driveParam->WriteVerifySupported; + pddt->ddt_descflags &= ~DF_LBA; pddt->ddt_ncyl = driveParam->chs.Cylinder; #ifdef DEBUG - if (pddt->ddt_LBASupported) + if (pddt->ddt_descflags & DF_LBA) DebugPrintf(("LBA enabled for drive %c:\n", 'A' + nUnits)); #endif @@ -658,7 +656,7 @@ int LBA_Get_Drive_Parameters(int drive, struct DriveParamS *driveParam) if (driveParam->driveno) return driveParam->driveno; - driveParam->LBA_supported = FALSE; + driveParam->descflags = 0; drive |= 0x80; @@ -727,18 +725,13 @@ int LBA_Get_Drive_Parameters(int drive, struct DriveParamS *driveParam) goto StandardBios; } - if (lba_bios_parameters.information & 8) - { - driveParam->WriteVerifySupported = 1; - } - else - driveParam->WriteVerifySupported = 0; - driveParam->total_sectors = lba_bios_parameters.totalSect; /* if we arrive here, success */ - driveParam->LBA_supported = TRUE; - + driveParam->descflags = DF_LBA; + if (lba_bios_parameters.information & 8) + driveParam->descflags |= DF_WRTVERIFY; + StandardBios: /* old way to get parameters */ regs.a.b.h = 0x08; @@ -759,7 +752,7 @@ int LBA_Get_Drive_Parameters(int drive, struct DriveParamS *driveParam) printf("BIOS reported 0 sectors/track, assuming 63!\n"); } - if (!driveParam->LBA_supported) + if (!(driveParam->descflags & DF_LBA)) { driveParam->total_sectors = min(driveParam->chs.Cylinder, 1023) @@ -904,7 +897,7 @@ BOOL ScanForPrimaryPartitions(struct DriveParamS * driveParam, int scan_type, if (chs.Cylinder > 1023 || end.Cylinder > 1023) { - if (!driveParam->LBA_supported) + if (!(driveParam->descflags & DF_LBA)) { printf ("can't use LBA partition without LBA support - part %s FS %02x", @@ -990,7 +983,7 @@ int Read1LBASector(struct DriveParamS *driveParam, unsigned drive, for (num_retries = 0; num_retries < N_RETRY; num_retries++) { regs.d.b.l = drive | 0x80; - if (driveParam->LBA_supported) + if (driveParam->descflags & DF_LBA) { dap.number_of_blocks = 1; dap.buffer_address = buffer; @@ -1281,7 +1274,6 @@ void ReadAllPartitionTables(void) pddt->ddt_logdriveno = Unit; pddt->ddt_type = init_getdriveparm(0, &pddt->ddt_defbpb); pddt->ddt_ncyl = (pddt->ddt_type & 7) ? 80 : 40; - pddt->ddt_LBASupported = FALSE; pddt->ddt_descflags = init_readdasd(0); pddt->ddt_offset = 0l; From 2aa4789bfc0071cdcd7f7d94e6e29a1d467d64d0 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Tue, 13 Apr 2004 10:58:06 +0000 Subject: [PATCH 447/671] (From Arkady) Avoid "shr cx,4" (it doesn't work on the 8088) git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@869 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/kernel.asm | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/kernel/kernel.asm b/kernel/kernel.asm index 21f399f0..9c330930 100644 --- a/kernel/kernel.asm +++ b/kernel/kernel.asm @@ -137,9 +137,10 @@ kernel_start: mov ax,cs mov dx,__InitTextStart wrt HMA_TEXT %ifdef WATCOM - mov cx,dx - shr cx,4 - add ax,cx + mov si,dx + mov cl,4 + shr si,cl + add ax,si %endif mov ds,ax mov cx,-2 + init_end wrt INIT_TEXT From 46df83483bca72b9da1ff4515c266197a94b3dc6 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Tue, 13 Apr 2004 11:02:36 +0000 Subject: [PATCH 448/671] Make unnecessary far pointers near. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@870 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/memmgr.c | 5 ++--- kernel/proto.h | 9 ++++----- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/kernel/memmgr.c b/kernel/memmgr.c index 7b6670cd..00bbc80e 100644 --- a/kernel/memmgr.c +++ b/kernel/memmgr.c @@ -112,8 +112,7 @@ void FAR * adjust_far(const void FAR * fp) size is the minimum size of the block to search for, even if mode == LARGEST. */ -COUNT DosMemAlloc(UWORD size, COUNT mode, seg FAR * para, - UWORD FAR * asize) +COUNT DosMemAlloc(UWORD size, COUNT mode, seg *para, UWORD *asize) { REG mcb FAR *p; mcb FAR *foundSeg; @@ -265,7 +264,7 @@ COUNT DosMemAlloc(UWORD size, COUNT mode, seg FAR * para, * Known bug: a memory area with a size of the data area of 0 (zero) is * not considered a "largest" block. <> */ -COUNT DosMemLargest(UWORD FAR * size) +COUNT DosMemLargest(UWORD *size) { seg dummy; *size = 0; diff --git a/kernel/proto.h b/kernel/proto.h index baee0d14..cbd2ff14 100644 --- a/kernel/proto.h +++ b/kernel/proto.h @@ -241,14 +241,13 @@ seg far2para(VOID FAR * p); seg long2para(ULONG size); void FAR *add_far(void FAR * fp, unsigned off); VOID FAR *adjust_far(const void FAR * fp); -COUNT DosMemAlloc(UWORD size, COUNT mode, seg FAR * para, - UWORD FAR * asize); -COUNT DosMemLargest(UWORD FAR * size); +COUNT DosMemAlloc(UWORD size, COUNT mode, seg * para, UWORD * asize); +COUNT DosMemLargest(UWORD * size); COUNT DosMemFree(UWORD para); COUNT DosMemChange(UWORD para, UWORD size, UWORD * maxSize); COUNT DosMemCheck(void); COUNT FreeProcessMem(UWORD ps); -COUNT DosGetLargestBlock(UWORD FAR * block); +COUNT DosGetLargestBlock(UWORD * block); VOID show_chain(void); VOID DosUmbLink(BYTE n); VOID mcb_print(mcb FAR * mcbp); @@ -257,7 +256,7 @@ VOID mcb_print(mcb FAR * mcbp); COUNT lfn_allocate_inode(VOID); COUNT lfn_free_inode(COUNT handle); -COUNT lfn_setup_inode(COUNT handle, ULONG dirstart, ULONG diroff); +COUNT lfn_setup_inode(COUNT handle, ULONG dirstart, UWORD diroff); COUNT lfn_create_entries(COUNT handle, lfn_inode_ptr lip); COUNT lfn_remove_entries(COUNT handle); From e5f882f2ec33d36b1a232652b36ce9deeae35678 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Tue, 13 Apr 2004 11:07:59 +0000 Subject: [PATCH 449/671] Use AL, not AX, for int2f/ax=1213, as per RBIL (from Arkady) git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@871 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/inthndlr.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/kernel/inthndlr.c b/kernel/inthndlr.c index d74e71d0..ac4181af 100644 --- a/kernel/inthndlr.c +++ b/kernel/inthndlr.c @@ -1883,9 +1883,9 @@ VOID ASMCFUNC int2F_12_handler(struct int2f12regs r) case 0x13: /* uppercase character */ /* for now, ASCII only because nls.c cannot handle DS!=SS */ - r.AX = (unsigned char)r.callerARG1; - if (r.AX >= 'a' && r.AX <= 'z') - r.AX -= 'a' - 'A'; + r.AL = (unsigned char)r.callerARG1; + if (r.AL >= 'a' && r.AL <= 'z') + r.AL -= 'a' - 'A'; break; case 0x16: From 3e1c1a526f345ece66775c178b4f008c355c2440 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Tue, 13 Apr 2004 11:11:09 +0000 Subject: [PATCH 450/671] AllocateHMASpace needs to check FP_SEG(firstbuf) for 0xffff, since the buffers may not live in the HMA. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@872 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/blockio.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/kernel/blockio.c b/kernel/blockio.c index 89a8d876..9a66fad2 100644 --- a/kernel/blockio.c +++ b/kernel/blockio.c @@ -477,8 +477,12 @@ UWORD dskxfer(COUNT dsk, ULONG blkno, VOID FAR * buf, UWORD numblocks, void AllocateHMASpace (size_t lowbuffer, size_t highbuffer) { REG struct buffer FAR *bp = firstbuf; - int n = LoL_nbuffers; + int n; + if (FP_SEG(bp) != 0xffff) + return; + + n = LoL_nbuffers; do { /* check if buffer intersects with requested area */ From 06de625da2c1b85388f89ab10f08be1c7376c7a0 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Tue, 13 Apr 2004 11:21:29 +0000 Subject: [PATCH 451/671] The screen position (for TABs) is only for raw *CONOUT* devices already updated in dosfns.c git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@873 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/chario.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/kernel/chario.c b/kernel/chario.c index 84a0f275..7471555c 100644 --- a/kernel/chario.c +++ b/kernel/chario.c @@ -284,17 +284,17 @@ void write_char(int c, int sft_idx) void write_char_stdout(int c) { unsigned char count = 1; - unsigned flags = get_sft(STDOUT)->sft_flags & (SFT_FDEVICE | SFT_FBINARY); + unsigned flags = get_sft(STDOUT)->sft_flags; /* ah=2, ah=9 should expand tabs even for raw devices and disk files */ - if (flags != SFT_FDEVICE) + if ((flags & (SFT_FDEVICE|SFT_FBINARY)) != SFT_FDEVICE) { if (c == HT) { count = 8 - (scr_pos & 7); c = ' '; } - /* for raw devices already updated in dosfns.c */ - if (!(flags & SFT_FDEVICE)) + /* for raw CONOUT devices already updated in dosfns.c */ + if ((flags & (SFT_FDEVICE|SFT_FCONOUT)) != (SFT_FDEVICE|SFT_FCONOUT)) update_scr_pos(c, count); } From e9716d990d3f9ba105c01fd1089b1f3f03268ec2 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Tue, 13 Apr 2004 11:54:09 +0000 Subject: [PATCH 452/671] Document the fact the MSCL8 compiled kernels don't work. Don't initialize BSS variables anymore -- now done by the memset in main.c Removed obsolete BYTE cfgCSYS_fnam[NAMEMAX]; config variable. Changed cfgInit and cfgInitTail to pointers, adjusted some code to work with them. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@874 6ac86273-5f31-0410-b378-82cca8765d1b --- docs/build.txt | 7 +++-- kernel/config.c | 76 +++++++++++++++++++---------------------------- kernel/config.h | 5 ++-- kernel/kernel.asm | 6 ++-- kernel/main.c | 5 ++-- kernel/segs.inc | 24 +++++++++------ kernel/task.c | 5 ++-- 7 files changed, 61 insertions(+), 67 deletions(-) diff --git a/docs/build.txt b/docs/build.txt index a5e487b1..b808da68 100644 --- a/docs/build.txt +++ b/docs/build.txt @@ -29,11 +29,12 @@ Optionally, the kernel can be compressed using UPX. You can find UPX at http://upx.sourceforge.net. Simply adjust config.bat to enable it. -This kernel will now compile with Turbo C 2.01, Turbo C++ 1.01 (now freely +This kernel compiles with Turbo C 2.01, Turbo C++ 1.01 (now freely available!), Turbo C 3.0, Borland C 4.51 & 5.01. It should work with -other Borland compilers, Microsoft C and (Open)Watcom C. +other Borland compilers and (Open)Watcom C. Microsoft C and GCC can +compile the kernel but the result does *not* work. -The OpenWatcom 1.0 compiler (or later) for DOS can now be downloaded at +The OpenWatcom 1.0 compiler (or later) for DOS can be downloaded at www.openwatcom.org: you need at least the following zips from ftp://ftp.openwatcom.org/watcom/zips/ (see ftp://ftp.openwatcom.org/watcom/zips/layout.txt) diff --git a/kernel/config.c b/kernel/config.c index 6c77b37e..272e2c2c 100644 --- a/kernel/config.c +++ b/kernel/config.c @@ -58,21 +58,9 @@ struct MenuSelector }; /** Structure below holds the menu-strings */ -STATIC struct MenuSelector MenuStruct[MENULINESMAX] = -{ - {0,0,0,{""}}, - {0,0,0,{""}}, - {0,0,0,{""}}, - {0,0,0,{""}}, - {0,0,0,{""}}, - {0,0,0,{""}}, - {0,0,0,{""}}, - {0,0,0,{""}}, - {0,0,0,{""}}, - {0,0,0,{""}} -}; +STATIC struct MenuSelector MenuStruct[MENULINESMAX]; -int nMenuLine=0; +int nMenuLine; BOOL MenuColor = -1; STATIC void WriteMenuLine(int MenuSelected) @@ -128,14 +116,13 @@ STATIC void SelectLine(int MenuSelected) WriteMenuLine(MenuSelected); } -UWORD umb_start = 0, UMB_top = 0; -UWORD ram_top = 0; /* How much ram in Kbytes */ -size_t ebda_size = 0; +UWORD umb_start, UMB_top; +UWORD ram_top; /* How much ram in Kbytes */ +size_t ebda_size; static UBYTE ErrorAlreadyPrinted[128]; - -char master_env[128] = {0}; +char master_env[128]; static char *envp = master_env; struct config Config = { @@ -155,34 +142,29 @@ struct config Config = { /* COUNTRY= is initialized within DoConfig() */ , 0 /* country ID */ , 0 /* codepage */ - , "" /* filename */ , 0 /* amount required memory */ , 0 /* pointer to loaded data */ , 0 /* strategy for command.com is low by default */ , 0xFFFF /* default value for switches=/E:nnnn */ }; - /* MSC places uninitialized data into COMDEF records, - that end up in DATA segment. this can't be tolerated - in INIT code. - please make sure, that ALL data in INIT is initialized !! - */ -STATIC seg base_seg = 0; -STATIC seg umb_base_seg = 0; -BYTE FAR *lpTop = 0; -STATIC unsigned nCfgLine = 0; -COUNT UmbState = 0; -STATIC BYTE szLine[256] = { 0 }; -STATIC BYTE szBuf[256] = { 0 }; - -BYTE singleStep = FALSE; /* F8 processing */ -BYTE SkipAllConfig = FALSE; /* F5 processing */ -BYTE askThisSingleCommand = FALSE; /* ?device= device?= */ -BYTE DontAskThisSingleCommand = FALSE; /* !files= */ + +STATIC seg base_seg; +STATIC seg umb_base_seg; +BYTE FAR *lpTop; +STATIC unsigned nCfgLine; +COUNT UmbState; +STATIC BYTE szLine[256]; +STATIC BYTE szBuf[256]; + +BYTE singleStep; /* F8 processing */ +BYTE SkipAllConfig; /* F5 processing */ +BYTE askThisSingleCommand; /* ?device= device?= */ +BYTE DontAskThisSingleCommand; /* !files= */ COUNT MenuTimeout = -1; -BYTE MenuSelected = 0; -UCOUNT MenuLine = 0; -UCOUNT Menus = 0; +BYTE MenuSelected; +UCOUNT MenuLine; +UCOUNT Menus; STATIC VOID CfgMenuColor(BYTE * pLine); @@ -331,9 +313,9 @@ int findend(BYTE * s) return nLen; } -BYTE *pLineStart = 0; +BYTE *pLineStart; -BYTE HMAState = 0; +BYTE HMAState; #define HMA_NONE 0 /* do nothing */ #define HMA_REQ 1 /* DOS = HIGH detected */ #define HMA_DONE 2 /* Moved kernel to HMA */ @@ -343,8 +325,6 @@ BYTE HMAState = 0; /* later. */ void PreConfig(void) { - memset(ErrorAlreadyPrinted,0,sizeof(ErrorAlreadyPrinted)); - /* Initialize the base memory pointers */ #ifdef DEBUG @@ -1257,6 +1237,12 @@ STATIC VOID InitPgmHigh(BYTE * pLine) STATIC VOID InitPgm(BYTE * pLine) { + static char init[NAMEMAX]; + static char inittail[NAMEMAX]; + + Config.cfgInit = init; + Config.cfgInitTail = inittail; + /* Get the string argument that represents the new init pgm */ pLine = GetStringArg(pLine, Config.cfgInit); @@ -1648,7 +1634,7 @@ STATIC VOID mcb_init_copy(UCOUNT seg, UWORD size, mcb *near_mcb) STATIC VOID mcb_init(UCOUNT seg, UWORD size, BYTE type) { - static mcb near_mcb = {0}; + static mcb near_mcb; near_mcb.m_type = type; mcb_init_copy(seg, size, &near_mcb); } diff --git a/kernel/config.h b/kernel/config.h index c55cc52d..50dff682 100644 --- a/kernel/config.h +++ b/kernel/config.h @@ -34,8 +34,8 @@ struct config { /* Configuration variables */ UBYTE cfgFilesHigh; UBYTE cfgFcbs; /* number of available FCBs */ UBYTE cfgProtFcbs; /* number of protected FCBs */ - BYTE cfgInit[NAMEMAX]; /* init of command.com */ - BYTE cfgInitTail[NAMEMAX]; /* command.com's tail */ + BYTE *cfgInit; /* init of command.com */ + BYTE *cfgInitTail; /* command.com's tail */ UBYTE cfgLastdrive; /* last drive */ UBYTE cfgLastdriveHigh; BYTE cfgStacks; /* number of stacks */ @@ -47,7 +47,6 @@ struct config { /* Configuration variables */ */ WORD cfgCSYS_cntry; /* country ID to be loaded */ UWORD cfgCSYS_cp; /* requested codepage; NLS_DEFAULT if default */ - BYTE cfgCSYS_fnam[NAMEMAX];/* filename of COUNTRY= */ WORD cfgCSYS_memory; /* # of bytes required for the NLS pkg; 0 if none */ VOID FAR *cfgCSYS_data; /* where the loaded data is for PostConfig() */ UBYTE cfgP_0_startmode; /* load command.com high or not */ diff --git a/kernel/kernel.asm b/kernel/kernel.asm index 9c330930..f5c1126a 100644 --- a/kernel/kernel.asm +++ b/kernel/kernel.asm @@ -129,13 +129,13 @@ kernel_start: shr dx,cl sub ax,dx mov es,ax - mov dx,__INIT_DATA_START wrt INIT_TEXT + mov dx,__INIT_DATA_START wrt INIT_TEXT ; para aligned shr dx,cl add ax,dx mov ss,ax ; set SS to init data segment sti ; now enable them mov ax,cs - mov dx,__InitTextStart wrt HMA_TEXT + mov dx,__InitTextStart wrt HMA_TEXT ; para aligned %ifdef WATCOM mov si,dx mov cl,4 @@ -143,7 +143,7 @@ kernel_start: add ax,si %endif mov ds,ax - mov cx,-2 + init_end wrt INIT_TEXT + mov cx,-2 + init_end wrt INIT_TEXT ; word aligned mov si,cx mov di,cx shr cx,1 diff --git a/kernel/main.c b/kernel/main.c index 8b3ebd3a..79eba2e5 100644 --- a/kernel/main.c +++ b/kernel/main.c @@ -43,7 +43,7 @@ static char copyright[] = "GNU General Public License as published by the Free Software Foundation;\n" "either version 2, or (at your option) any later version.\n"; -struct _KernelConfig InitKernelConfig = { "", 0, 0, 0, 0, 0, 0, 0 }; +struct _KernelConfig InitKernelConfig; STATIC VOID InitIO(void); @@ -445,7 +445,8 @@ STATIC void kernel() break; } } - strcpy(Config.cfgInitTail, Cmd.ctBuffer); /* save buffer */ + /* save buffer -- on the stack it's fine here */ + Config.cfgInitTail = Cmd.ctBuffer; } } init_call_p_0(&Config); /* go execute process 0 (the shell) */ diff --git a/kernel/segs.inc b/kernel/segs.inc index 592760f1..f54100f8 100644 --- a/kernel/segs.inc +++ b/kernel/segs.inc @@ -32,11 +32,12 @@ group LGROUP _LOWTEXT _IO_TEXT _IO_FIXED_DATA _TEXT group DGROUP _FIXED_DATA _BSS _DATA _DATAEND CONST CONST2 DCONST DYN_DATA %ifdef WATCOM group TGROUP HMA_TEXT_START HMA_TEXT HMA_TEXT_END INIT_TEXT_START INIT_TEXT INIT_TEXT_END +group I_GROUP ID_B I_DATA ICONST ICONST2 ID_E IB_B I_BSS IB_E %else group TGROUP HMA_TEXT_START HMA_TEXT HMA_TEXT_END group IGROUP INIT_TEXT_START INIT_TEXT INIT_TEXT_END +group I_GROUP ID_B ID ID_E IC IDATA IB_B IB IB_E %endif -group I_GROUP ID_B ID ID_E IC IDATA ICONST ICONST2 I_DATA IB_B I_BSS IB IB_E segment PSP class=PSP segment _LOWTEXT class=LCODE @@ -59,18 +60,23 @@ segment HMA_TEXT_END class=CODE segment INIT_TEXT_START class=CODE align=16 segment INIT_TEXT class=CODE segment INIT_TEXT_END class=CODE + +%ifdef WATCOM +segment ID_B class=FAR_DATA align=16 +segment I_DATA class=FAR_DATA align=2 +segment ICONST class=FAR_DATA align=2 +segment ICONST2 class=FAR_DATA align=2 +segment ID_E class=FAR_DATA align=2 +segment IB_B class=FAR_DATA align=2 +segment I_BSS class=FAR_DATA align=2 +segment IB_E class=FAR_DATA align=2 +%else segment ID_B class=ID align=16 segment ID class=ID align=2 -segment ID_E class=ID align=2 segment IDATA class=ID align=2 +segment ID_E class=ID align=2 segment IC class=IC align=2 - -;for Watcom -segment ICONST class=FAR_DATA align=2 -segment ICONST2 class=FAR_DATA align=2 -segment I_DATA class=FAR_DATA align=2 - segment IB_B class=IB align=2 -segment I_BSS class=FAR_DATA align=2 segment IB class=IB align=2 segment IB_E class=IB align=2 +%endif diff --git a/kernel/task.c b/kernel/task.c index e3d5ed0a..c4653bf1 100644 --- a/kernel/task.c +++ b/kernel/task.c @@ -800,8 +800,9 @@ VOID ASMCFUNC P_0(struct config FAR *Config) /* build exec block and save all parameters here as init part will vanish! */ exb.exec.fcb_1 = exb.exec.fcb_2 = (fcb FAR *)-1L; exb.exec.env_seg = DOS_PSP + 8; - fstrcpy(Shell, Config->cfgInit); - fstrcpy(Shell + strlen(Shell), Config->cfgInitTail); /* join name and tail */ + fstrcpy(Shell, MK_FP(FP_SEG(Config), Config->cfgInit)); + /* join name and tail */ + fstrcpy(Shell + strlen(Shell), MK_FP(FP_SEG(Config), Config->cfgInitTail)); endp = Shell + strlen(Shell); for ( ; ; ) /* endless shell load loop - reboot or shut down to exit it! */ From c899541e2e78e04fc2170b86356a9999a327599a Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Tue, 13 Apr 2004 12:13:03 +0000 Subject: [PATCH 453/671] Converted nxtMCBsize back to a macro. There is no need to use far2para; FP_SEG works fine since MCBs always have offset 0. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@875 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/memmgr.c | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/kernel/memmgr.c b/kernel/memmgr.c index 00bbc80e..3a0a62db 100644 --- a/kernel/memmgr.c +++ b/kernel/memmgr.c @@ -34,14 +34,7 @@ static BYTE *memmgrRcsId = "$Id$"; #endif -/*#define nxtMCBsize(mcb,size) \ - MK_FP(far2para((VOID FAR *) (mcb)) + (size) + 1, 0) */ - -void FAR *nxtMCBsize(mcb FAR * Mcb, int size) -{ - return MK_FP(far2para((VOID FAR *) (Mcb)) + (size) + 1, 0); -} - +#define nxtMCBsize(mcb,size) MK_FP(FP_SEG(mcb) + (size) + 1, 0) #define nxtMCB(mcb) nxtMCBsize((mcb), (mcb)->m_size) #define mcbFree(mcb) ((mcb)->m_psp == FREE_PSP) @@ -75,11 +68,6 @@ STATIC COUNT joinMCBs(mcb FAR * p) return SUCCESS; } -seg far2para(VOID FAR * p) -{ - return FP_SEG(p) + (FP_OFF(p) >> 4); -} - /* * Return a normalized far pointer */ @@ -252,7 +240,7 @@ COUNT DosMemAlloc(UWORD size, COUNT mode, seg *para, UWORD *asize) foundSeg->m_psp = cu_psp; /* the new block is for current process */ foundSeg->m_name[0] = '\0'; - *para = far2para((VOID FAR *) (BYTE FAR *) foundSeg); + *para = FP_SEG(foundSeg); return SUCCESS; } From 541b994f99496a9fabea5f2d5a2f227ea1c218a8 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Tue, 13 Apr 2004 17:16:39 +0000 Subject: [PATCH 454/671] Correct another shr ...,4 git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@876 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/kernel.asm | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/kernel/kernel.asm b/kernel/kernel.asm index f5c1126a..df51bd1e 100644 --- a/kernel/kernel.asm +++ b/kernel/kernel.asm @@ -152,8 +152,9 @@ kernel_start: rep movsw ; move HMA_TEXT to higher memory - mov cx,dx ; cx = __InitTextStart wrt HMA_TEXT - shr dx,4 + mov si,dx ; si = __InitTextStart wrt HMA_TEXT + mov cl,4 + shr dx,cl sub ax,dx mov ds,ax ; ds = HMA_TEXT @@ -161,7 +162,7 @@ kernel_start: sub ax,dx mov es,ax ; es = new HMA_TEXT - mov si,cx + mov cx,si ; cx = __InitTextStart wrt HMA_TEXT dec si dec si mov di,si From fed4d61e90123c877289c0ec5f10bd97b8e64c00 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Tue, 13 Apr 2004 17:21:30 +0000 Subject: [PATCH 455/671] Fix new LBA problem. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@877 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/initdisk.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/initdisk.c b/kernel/initdisk.c index e9c7942e..fabef307 100644 --- a/kernel/initdisk.c +++ b/kernel/initdisk.c @@ -583,7 +583,7 @@ void DosDefinePartition(struct DriveParamS *driveParam, pddt->ddt_next = MK_FP(0, 0xffff); pddt->ddt_driveno = driveParam->driveno; pddt->ddt_logdriveno = nUnits; - pddt->ddt_descflags |= driveParam->descflags; + pddt->ddt_descflags = driveParam->descflags; /* Turn of LBA if not forced and the partition is within 1023 cyls and of the right type */ /* the FileSystem type was internally converted to LBA_xxxx if a non-LBA partition above cylinder 1023 was found */ @@ -614,7 +614,7 @@ void DosDefinePartition(struct DriveParamS *driveParam, pddt->ddt_serialno = 0x12345678l; /* drive inaccessible until bldbpb successful */ - pddt->ddt_descflags = init_readdasd(pddt->ddt_driveno) | DF_NOACCESS; + pddt->ddt_descflags |= init_readdasd(pddt->ddt_driveno) | DF_NOACCESS; pddt->ddt_type = 5; memcpy(&pddt->ddt_bpb, &pddt->ddt_defbpb, sizeof(bpb)); From 74970d953b3ce42e9e919396782cc4204e554f8a Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Tue, 13 Apr 2004 20:37:30 +0000 Subject: [PATCH 456/671] Correct int21/ax=4401: returned AL = old value, should set CY and DE_INVLDDATA if DH!=0 (RBIL is a little confusing here). git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@878 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/ioctl.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/kernel/ioctl.c b/kernel/ioctl.c index 022062a1..01c6dace 100644 --- a/kernel/ioctl.c +++ b/kernel/ioctl.c @@ -106,10 +106,17 @@ COUNT DosDevIOctl(lregs * r) /* can't set the status of a file. */ if (!(flags & SFT_FDEVICE)) return DE_INVLDFUNC; + /* RBIL says this is only for DOS < 6, but MSDOS 7.10 */ + /* returns this as well... and some buggy program relies*/ + /* on it :( */ + if (r->DH != 0) + return DE_INVLDDATA; + /* Undocumented: AL should get the old value */ + r->AL = s->sft_flags_lo; /* Set it to what we got in the DL register from the */ /* user. */ - r->AL = s->sft_flags_lo = SFT_FDEVICE | r->DL; + s->sft_flags_lo = SFT_FDEVICE | r->DL; break; case 0x02: From 6f6ceadebc0522e957be4e4cf4ea0af89d70994f Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Tue, 13 Apr 2004 20:41:15 +0000 Subject: [PATCH 457/671] As per a suggestion from Arkady: use CPU to enforce 8086 etc instructions. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@879 6ac86273-5f31-0410-b378-82cca8765d1b --- hdr/stacks.inc | 2 +- kernel/entry.asm | 2 +- kernel/int2f.asm | 4 ++-- kernel/kernel.asm | 2 +- kernel/segs.inc | 11 +++++++++++ mkfiles/generic.mak | 6 +----- 6 files changed, 17 insertions(+), 10 deletions(-) diff --git a/hdr/stacks.inc b/hdr/stacks.inc index 1321b55b..cf49d2b8 100644 --- a/hdr/stacks.inc +++ b/hdr/stacks.inc @@ -128,7 +128,7 @@ irp_hi equ 26 ; -%IFNDEF I386 +%IF XCPU < 386 ; no need to save/restore anything ; error 1 2 3 diff --git a/kernel/entry.asm b/kernel/entry.asm index e33ccaad..add900cf 100644 --- a/kernel/entry.asm +++ b/kernel/entry.asm @@ -344,7 +344,7 @@ int21_exit_nodec: pop bp ; get back user stack pop si -%IFDEF I386 +%if XCPU >= 386 %ifdef WATCOM sub bp, 4 ; for fs and gs only %else diff --git a/kernel/int2f.asm b/kernel/int2f.asm index 3dbf06e8..ee12fd16 100644 --- a/kernel/int2f.asm +++ b/kernel/int2f.asm @@ -132,7 +132,7 @@ IntDosCal: cld -%IFDEF I386 +%if XCPU >= 386 %ifdef WATCOM mov si,fs mov di,gs @@ -145,7 +145,7 @@ IntDosCal: extern _int2F_12_handler call _int2F_12_handler -%IFDEF I386 +%if XCPU >= 386 %ifdef WATCOM mov fs,si mov gs,di diff --git a/kernel/kernel.asm b/kernel/kernel.asm index df51bd1e..3a85a89d 100644 --- a/kernel/kernel.asm +++ b/kernel/kernel.asm @@ -324,7 +324,7 @@ _LoL_nbuffers dw 1 ; 003F number of buffers global _BootDrive _BootDrive db 1 ; 0043 drive we booted from -%IFNDEF I386 +%IF XCPU < 386 db 0 ; 0044 cpu type (1 if >=386) %ELSE db 1 ; 0044 cpu type (1 if >=386) diff --git a/kernel/segs.inc b/kernel/segs.inc index f54100f8..ba6e123a 100644 --- a/kernel/segs.inc +++ b/kernel/segs.inc @@ -27,6 +27,17 @@ ; $Header$ ; +; CPU specification -- putting it here because all .asm files include this +; file __NASM_VER__ was introduced in NASM after CPU -- ver 0.98 doesn't +; understand it +%ifdef __NASM_VER__ +%if XCPU == 86 +CPU 8086 +%else +CPU XCPU +%endif +%endif + group PGROUP PSP group LGROUP _LOWTEXT _IO_TEXT _IO_FIXED_DATA _TEXT group DGROUP _FIXED_DATA _BSS _DATA _DATAEND CONST CONST2 DCONST DYN_DATA diff --git a/mkfiles/generic.mak b/mkfiles/generic.mak index d1071303..5e97ea2e 100644 --- a/mkfiles/generic.mak +++ b/mkfiles/generic.mak @@ -20,11 +20,7 @@ NASMFLAGS=$(NASMFLAGS) -DWITHFAT32 !endif NASM=$(XNASM) -!if $(XCPU) == 386 -NASMFLAGS = $(NASMFLAGS) -i../hdr/ -DI386 -!else -NASMFLAGS = $(NASMFLAGS) -i../hdr/ -!endif +NASMFLAGS = $(NASMFLAGS) -i../hdr/ -DXCPU=$(XCPU) LINK=$(XLINK) From 68c3f9ad13cc0edf0fb713fd01e402a9c2a6914d Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Tue, 13 Apr 2004 23:46:25 +0000 Subject: [PATCH 458/671] Lucho reported that MSC compiled kernels now work after all. Let's mark those nasty "BSS" variables explicitly then to try to avoid future problems. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@880 6ac86273-5f31-0410-b378-82cca8765d1b --- docs/build.txt | 4 ++-- kernel/config.c | 48 +++++++++++++++++++++++------------------------ kernel/init-mod.h | 14 ++++++++++++++ kernel/initdisk.c | 4 ++-- kernel/inithma.c | 6 +++--- kernel/main.c | 7 ++----- 6 files changed, 47 insertions(+), 36 deletions(-) diff --git a/docs/build.txt b/docs/build.txt index b808da68..c2f87de6 100644 --- a/docs/build.txt +++ b/docs/build.txt @@ -31,8 +31,8 @@ enable it. This kernel compiles with Turbo C 2.01, Turbo C++ 1.01 (now freely available!), Turbo C 3.0, Borland C 4.51 & 5.01. It should work with -other Borland compilers and (Open)Watcom C. Microsoft C and GCC can -compile the kernel but the result does *not* work. +other Borland and Microsoft compilers and (Open)Watcom C. GCC can +compile the kernel but the result does *not* work (no 16-bit x86 support). The OpenWatcom 1.0 compiler (or later) for DOS can be downloaded at www.openwatcom.org: you need at least the following zips from diff --git a/kernel/config.c b/kernel/config.c index 272e2c2c..b56e4ede 100644 --- a/kernel/config.c +++ b/kernel/config.c @@ -58,9 +58,9 @@ struct MenuSelector }; /** Structure below holds the menu-strings */ -STATIC struct MenuSelector MenuStruct[MENULINESMAX]; +STATIC struct MenuSelector MenuStruct[MENULINESMAX] BSS_INIT({0}); -int nMenuLine; +int nMenuLine BSS_INIT(0); BOOL MenuColor = -1; STATIC void WriteMenuLine(int MenuSelected) @@ -116,13 +116,13 @@ STATIC void SelectLine(int MenuSelected) WriteMenuLine(MenuSelected); } -UWORD umb_start, UMB_top; -UWORD ram_top; /* How much ram in Kbytes */ -size_t ebda_size; +UWORD umb_start BSS_INIT(0), UMB_top BSS_INIT(0); +UWORD ram_top BSS_INIT(0); /* How much ram in Kbytes */ +size_t ebda_size BSS_INIT(0); -static UBYTE ErrorAlreadyPrinted[128]; +static UBYTE ErrorAlreadyPrinted[128] BSS_INIT({0}); -char master_env[128]; +char master_env[128] BSS_INIT({0}); static char *envp = master_env; struct config Config = { @@ -148,23 +148,23 @@ struct config Config = { , 0xFFFF /* default value for switches=/E:nnnn */ }; -STATIC seg base_seg; -STATIC seg umb_base_seg; -BYTE FAR *lpTop; -STATIC unsigned nCfgLine; -COUNT UmbState; -STATIC BYTE szLine[256]; -STATIC BYTE szBuf[256]; +STATIC seg base_seg BSS_INIT(0); +STATIC seg umb_base_seg BSS_INIT(0); +BYTE FAR *lpTop BSS_INIT(0); +STATIC unsigned nCfgLine BSS_INIT(0); +COUNT UmbState BSS_INIT(0); +STATIC BYTE szLine[256] BSS_INIT({0}); +STATIC BYTE szBuf[256] BSS_INIT({0}); -BYTE singleStep; /* F8 processing */ -BYTE SkipAllConfig; /* F5 processing */ -BYTE askThisSingleCommand; /* ?device= device?= */ -BYTE DontAskThisSingleCommand; /* !files= */ +BYTE singleStep BSS_INIT(FALSE); /* F8 processing */ +BYTE SkipAllConfig BSS_INIT(FALSE); /* F5 processing */ +BYTE askThisSingleCommand BSS_INIT(FALSE); /* ?device= device?= */ +BYTE DontAskThisSingleCommand BSS_INIT(FALSE); /* !files= */ COUNT MenuTimeout = -1; -BYTE MenuSelected; -UCOUNT MenuLine; -UCOUNT Menus; +BYTE MenuSelected BSS_INIT(0); +UCOUNT MenuLine BSS_INIT(0); +UCOUNT Menus BSS_INIT(0); STATIC VOID CfgMenuColor(BYTE * pLine); @@ -313,9 +313,9 @@ int findend(BYTE * s) return nLen; } -BYTE *pLineStart; +BYTE *pLineStart BSS_INIT(0); -BYTE HMAState; +BYTE HMAState BSS_INIT(0); #define HMA_NONE 0 /* do nothing */ #define HMA_REQ 1 /* DOS = HIGH detected */ #define HMA_DONE 2 /* Moved kernel to HMA */ @@ -1634,7 +1634,7 @@ STATIC VOID mcb_init_copy(UCOUNT seg, UWORD size, mcb *near_mcb) STATIC VOID mcb_init(UCOUNT seg, UWORD size, BYTE type) { - static mcb near_mcb; + static mcb near_mcb BSS_INIT({0}); near_mcb.m_type = type; mcb_init_copy(seg, size, &near_mcb); } diff --git a/kernel/init-mod.h b/kernel/init-mod.h index d6cfc31e..d597ebcd 100644 --- a/kernel/init-mod.h +++ b/kernel/init-mod.h @@ -25,6 +25,20 @@ #include "init-dat.h" #include "kconfig.h" + +/* MSC places uninitialized data into COMDEF records, + that end up in DATA segment. this can't be tolerated in INIT code. + please make sure, that ALL data in INIT is initialized !! + + These guys are marked BSS_INIT to mark that they really should be BSS + but can't be because of MS +*/ +#ifdef _MSC_VER +#define BSS_INIT(x) = x +#else +#define BSS_INIT(x) +#endif + extern struct _KernelConfig InitKernelConfig; /* diff --git a/kernel/initdisk.c b/kernel/initdisk.c index fabef307..61d8ebf1 100644 --- a/kernel/initdisk.c +++ b/kernel/initdisk.c @@ -32,8 +32,8 @@ static BYTE *dskRcsId = "$Id$"; #endif -UBYTE InitDiskTransferBuffer[SEC_SIZE]; -COUNT nUnits; +UBYTE InitDiskTransferBuffer[SEC_SIZE] BSS_INIT({0}); +COUNT nUnits BSS_INIT(0); /* * Rev 1.0 13 May 2001 tom ehlert diff --git a/kernel/inithma.c b/kernel/inithma.c index 71478ab2..4c16f272 100644 --- a/kernel/inithma.c +++ b/kernel/inithma.c @@ -71,9 +71,9 @@ static BYTE *RcsId = "$Id$"; #endif -BYTE DosLoadedInHMA = FALSE; /* set to TRUE if loaded HIGH */ -BYTE HMAclaimed = FALSE; /* set to TRUE if claimed from HIMEM */ -UWORD HMAFree = 0; /* first byte in HMA not yet used */ +BYTE DosLoadedInHMA BSS_INIT(FALSE); /* set to TRUE if loaded HIGH */ +BYTE HMAclaimed BSS_INIT(0); /* set to TRUE if claimed from HIMEM */ +UWORD HMAFree BSS_INIT(0); /* first byte in HMA not yet used */ STATIC void InstallVDISK(void); diff --git a/kernel/main.c b/kernel/main.c index 79eba2e5..2593fbdf 100644 --- a/kernel/main.c +++ b/kernel/main.c @@ -43,7 +43,7 @@ static char copyright[] = "GNU General Public License as published by the Free Software Foundation;\n" "either version 2, or (at your option) any later version.\n"; -struct _KernelConfig InitKernelConfig; +struct _KernelConfig InitKernelConfig BSS_INIT({0}); STATIC VOID InitIO(void); @@ -64,11 +64,9 @@ __segment DosDataSeg = 0; /* serves for all references to the DOS DATA seg */ __segment DosTextSeg = 0; -struct lol FAR *LoL; +#endif -#else struct lol FAR *LoL = &DATASTART; -#endif VOID ASMCFUNC FreeDOSmain(void) { @@ -79,7 +77,6 @@ VOID ASMCFUNC FreeDOSmain(void) extern FAR prn_dev; DosDataSeg = (__segment) & DATASTART; DosTextSeg = (__segment) & prn_dev; - LoL = &DATASTART; #endif /* if the kernel has been UPX'ed, From 237016c1d0cdcb724bd79ccf23849e4aa7722437 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Wed, 14 Apr 2004 08:50:35 +0000 Subject: [PATCH 459/671] Move memset up a little else it would overwrite too much. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@881 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/main.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/kernel/main.c b/kernel/main.c index 2593fbdf..43178a18 100644 --- a/kernel/main.c +++ b/kernel/main.c @@ -79,6 +79,9 @@ VOID ASMCFUNC FreeDOSmain(void) DosTextSeg = (__segment) & prn_dev; #endif + /* clear the Init BSS area (what normally the RTL does */ + memset(_ib_start, 0, _ib_end - _ib_start); + /* if the kernel has been UPX'ed, CONFIG info is stored at 50:e2 ..fc and the bootdrive (passed from BIOS) @@ -112,11 +115,6 @@ VOID ASMCFUNC FreeDOSmain(void) CheckContinueBootFromHarddisk(); - - - /* clear the Init BSS area (what normally the RTL does */ - memset(_ib_start, 0, _ib_end - _ib_start); - signon(); init_kernel(); From 9c41d97021ce62c94cc14b3647171843ad8e73ed Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Wed, 14 Apr 2004 08:51:46 +0000 Subject: [PATCH 460/671] DATASTART should be FAR and not DOSFAR for MSC git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@882 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/init-mod.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/init-mod.h b/kernel/init-mod.h index d597ebcd..782a0a93 100644 --- a/kernel/init-mod.h +++ b/kernel/init-mod.h @@ -239,7 +239,7 @@ extern struct lol FAR *LoL; extern struct dhdr DOSTEXTFAR ASM blk_dev; /* Block device (Disk) driver */ extern struct buffer FAR *DOSFAR firstAvailableBuf; /* first 'available' buffer */ -extern struct lol ASM DOSFAR DATASTART; +extern struct lol ASM FAR DATASTART; extern BYTE DOSFAR ASM _HMATextAvailable, /* first byte of available CODE area */ FAR ASM _HMATextStart[], /* first byte of HMAable CODE area */ From f94ba5ebe1fff52c660a58a31c40c309c1e72ce0 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Wed, 14 Apr 2004 09:20:08 +0000 Subject: [PATCH 461/671] Improve ^C handling: - ^C didn't work for int21/ah=3f. Corrected -- Do_DosIdle_loop still needs to wait even if it doesn't call the idle int - ^C needs to be echoed to STDOUT for low character functions (ah<0xd) but to the device that is read from for handle functions. So we need to pass either the STDOUT sft or that device on to the ^C echoer. - The ^C echo really should print ^C\r\n. - misc cleanups in break.c. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@883 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/break.c | 65 +++++++++++++++++++------------------- kernel/chario.c | 80 ++++++++++++++++++++++------------------------- kernel/inthndlr.c | 7 +++-- kernel/proto.h | 11 +++---- 4 files changed, 78 insertions(+), 85 deletions(-) diff --git a/kernel/break.c b/kernel/break.c index d3d24c54..7e287884 100644 --- a/kernel/break.c +++ b/kernel/break.c @@ -31,49 +31,48 @@ #include "globals.h" #include "proto.h" -extern void ASMCFUNC spawn_int23(void); - #ifdef VERSION_STRINGS static BYTE *RcsId = "$Id$"; #endif -#define CB_FLG *(UBYTE FAR*)MK_FP(0x40, 0x71) +#define CB_FLG *(UBYTE FAR*)MK_FP(0x0, 0x471) #define CB_MSK 0x80 -/* Check for ^Break. - - * Two sources are available: - * 1) flag at 40:71 bit 7 - * 2) STDIN stream via con_break() +/* Check for ^Break/^C. + * Three sources are available: + * 1) flag at 40:71 bit 7 + * 2) CON stream (if STDIN is redirected somewhere else) + * 3) input stream (most likely STDIN) + * Actions: + * 1) echo ^C + * 2) clear the STDIN stream + * 3) decrease the InDOS flag as the kernel drops back to user space + * 4) invoke INT-23 and never come back */ -int check_handle_break(void) +unsigned char check_handle_break(struct dhdr FAR **pdev, int sft_out) { - if (CB_FLG & CB_MSK) { + unsigned char c = CTL_C; + if (CB_FLG & CB_MSK) CB_FLG &= ~CB_MSK; /* reset the ^Break flag */ - handle_break(&syscon); + else + c = (unsigned char)ndread(&syscon); + if (c == CTL_C) + { + sft_out = -1; + pdev = &syscon; } - /* con_break will call handle_break() for CTL_C */ - return con_break(); -} - -/* - * Handles a ^Break state - * - * Actions: - * 1) clear the ^Break flag - * 2) clear the STDIN stream - * 3) decrease the InDOS flag as the kernel drops back to user space - * 4) invoke INT-23 and never come back - */ -void handle_break(struct dhdr FAR **pdev) -{ - echo_char(CTL_C, get_sft_idx(STDOUT)); - con_flush(pdev); - if (!ErrorMode) /* within int21_handler, InDOS is not incremented */ - if (InDOS) - --InDOS; /* fail-safe */ + else if (*pdev != syscon) + c = (unsigned char)ndread(pdev); + if (c == CTL_C) + { + con_flush(pdev); + echo_ctl_c(pdev, sft_out); + if (!ErrorMode) /* within int21_handler, InDOS is not incremented */ + if (InDOS) + --InDOS; /* fail-safe */ - spawn_int23(); /* invoke user INT-23 and never come back */ + spawn_int23(); /* invoke user INT-23 and never come back */ + } + return c; } - diff --git a/kernel/chario.c b/kernel/chario.c index 7471555c..755310ee 100644 --- a/kernel/chario.c +++ b/kernel/chario.c @@ -128,15 +128,15 @@ int StdinBusy(void) STATIC void Do_DosIdle_loop(struct dhdr FAR **pdev) { - /* the idle loop is only safe if we're using the character stack */ - if (user_r->AH < 0xd) - while (Busy(pdev) && Busy(&syscon)) + /* the idle int is only safe if we're using the character stack */ + while (Busy(pdev) && (*pdev == syscon || Busy(&syscon))) + if (user_r->AH < 0xd) DosIdle_int(); } /* get character from the console - this is how DOS gets CTL_C/CTL_S/CTL_P when outputting */ -STATIC int ndread(struct dhdr FAR **pdev) +int ndread(struct dhdr FAR **pdev) { CharCmd(pdev, C_NDREAD); if (CharReqHdr.r_status & S_BUSY) @@ -144,35 +144,19 @@ STATIC int ndread(struct dhdr FAR **pdev) return CharReqHdr.r_ndbyte; } -STATIC void con_skip_char(struct dhdr FAR **pdev) +STATIC void con_hold(struct dhdr FAR **pdev, int sft_out) { - if (CharIO(pdev, 0, C_INPUT) == CTL_C) - handle_break(pdev); -} - -STATIC void con_hold(struct dhdr FAR **pdev) -{ - int c = check_handle_break(); - if (*pdev != syscon) - c = ndread(pdev); - if (c == CTL_S || c == CTL_C) + unsigned char c = check_handle_break(pdev, sft_out); + if (c == CTL_S) { - con_skip_char(pdev); + CharIO(pdev, 0, C_INPUT); Do_DosIdle_loop(pdev); - /* just wait */ - check_handle_break(); - con_skip_char(pdev); + /* just wait and then skip a character */ + check_handle_break(pdev, sft_out); + CharIO(pdev, 0, C_INPUT); } } -int con_break(void) -{ - int c = ndread(&syscon); - if (c == CTL_C) - con_skip_char(&syscon); - return c; -} - /* OUTPUT FUNCTIONS */ #ifdef __WATCOMC__ @@ -231,7 +215,7 @@ STATIC int cooked_write_char(struct dhdr FAR **pdev, otherwise check every 32 characters */ if (*fast_counter <= 0x80) /* Test for hold char and ctl_c */ - con_hold(pdev); + con_hold(pdev, -1); *fast_counter += 1; *fast_counter &= 0x9f; @@ -306,7 +290,7 @@ void write_char_stdout(int c) #define iscntrl(c) ((unsigned char)(c) < ' ') /* this is for handling things like ^C, mostly used in echoed input */ -int echo_char(int c, int sft_idx) +STATIC int echo_char(int c, int sft_idx) { int out = c; if (iscntrl(c) && c != HT && c != LF && c != CR) @@ -318,6 +302,16 @@ int echo_char(int c, int sft_idx) return c; } +void echo_ctl_c(struct dhdr FAR **pdev, int sft_idx) +{ + char *buf = "^C\r\n"; + + if (sft_idx == -1) + cooked_write(pdev, 4, buf); + else + DosRWSft(sft_idx, 4, buf, XFR_FORCE_WRITE); +} + STATIC void destr_bs(int sft_idx) { write_char(BS, sft_idx); @@ -327,12 +321,12 @@ STATIC void destr_bs(int sft_idx) /* READ FUNCTIONS */ -STATIC int raw_get_char(struct dhdr FAR **pdev, BOOL check_break) +STATIC int raw_get_char(struct dhdr FAR **pdev, int sft_out, BOOL check_break) { Do_DosIdle_loop(pdev); if (check_break) { - con_hold(pdev); + con_hold(pdev, sft_out); Do_DosIdle_loop(pdev); } return CharIO(pdev, 0, C_INPUT); @@ -344,7 +338,7 @@ long cooked_read(struct dhdr FAR **pdev, size_t n, char FAR *bp) int c; while(n--) { - c = raw_get_char(pdev, TRUE); + c = raw_get_char(pdev, -1, TRUE); if (c < 0) return c; if (c == 256) @@ -357,26 +351,26 @@ long cooked_read(struct dhdr FAR **pdev, size_t n, char FAR *bp) return xfer; } -unsigned char read_char(int sft_idx, BOOL check_break) +unsigned char read_char(int sft_in, int sft_out, BOOL check_break) { unsigned char c; - struct dhdr FAR *dev = sft_to_dev(idx_to_sft(sft_idx)); + struct dhdr FAR *dev = sft_to_dev(idx_to_sft(sft_in)); if (dev) - return (unsigned char)raw_get_char(&dev, check_break); + return (unsigned char)raw_get_char(&dev, sft_out, check_break); - DosRWSft(sft_idx, 1, &c, XFR_READ); + DosRWSft(sft_in, 1, &c, XFR_READ); return c; } -STATIC unsigned char read_char_check_break(int sft_idx) +STATIC unsigned char read_char_check_break(int sft_in, int sft_out) { - return read_char(sft_idx, TRUE); + return read_char(sft_in, sft_out, TRUE); } unsigned char read_char_stdin(BOOL check_break) { - return read_char(get_sft_idx(STDIN), check_break); + return read_char(get_sft_idx(STDIN), get_sft_idx(STDOUT), check_break); } /* reads a line (buffered, called by int21/ah=0ah, 3fh) */ @@ -399,9 +393,9 @@ void read_line(int sft_in, int sft_out, keyboard FAR * kp) { unsigned new_pos = stored_size; - c = read_char_check_break(sft_in); + c = read_char_check_break(sft_in, sft_out); if (c == 0) - c = (unsigned)read_char_check_break(sft_in) << 8; + c = (unsigned)read_char_check_break(sft_in, sft_out) << 8; switch (c) { case LF: @@ -426,11 +420,11 @@ void read_line(int sft_in, int sft_out, keyboard FAR * kp) case F4: /* insert/delete up to character c */ { - unsigned char c2 = read_char_check_break(sft_in); + unsigned char c2 = read_char_check_break(sft_in, sft_out); new_pos = stored_pos; if (c2 == 0) { - read_char_check_break(sft_in); + read_char_check_break(sft_in, sft_out); } else { diff --git a/kernel/inthndlr.c b/kernel/inthndlr.c index ac4181af..441d9470 100644 --- a/kernel/inthndlr.c +++ b/kernel/inthndlr.c @@ -408,7 +408,7 @@ VOID ASMCFUNC int21_service(iregs FAR * r) /* Check for Ctrl-Break */ if (break_ena || (lr.AH >= 1 && lr.AH <= 5) || (lr.AH >= 8 && lr.AH <= 0x0b)) - check_handle_break(); + check_handle_break(&syscon, -1); /* The dispatch handler */ switch (lr.AH) @@ -435,8 +435,11 @@ VOID ASMCFUNC int21_service(iregs FAR * r) /* Auxiliary Input */ case 0x03: - lr.AL = read_char(get_sft_idx(STDAUX), TRUE); + { + int sft_idx = get_sft_idx(STDAUX); + lr.AL = read_char(sft_idx, sft_idx, TRUE); break; + } /* Auxiliary Output */ case 0x04: diff --git a/kernel/proto.h b/kernel/proto.h index cbd2ff14..d3421094 100644 --- a/kernel/proto.h +++ b/kernel/proto.h @@ -49,21 +49,18 @@ UWORD dskxfer(COUNT dsk, ULONG blkno, VOID FAR * buf, UWORD numblocks, void AllocateHMASpace (size_t lowbuffer, size_t highbuffer); /* break.c */ -#ifdef __WATCOMC__ -#pragma aux handle_break aborts; -#endif -int check_handle_break(void); -void handle_break(struct dhdr FAR **pdev); +unsigned char check_handle_break(struct dhdr FAR **pdev, int sft_out); /* chario.c */ struct dhdr FAR *sft_to_dev(sft FAR *sft); long BinaryCharIO(struct dhdr FAR **pdev, size_t n, void FAR * bp, unsigned command); int echo_char(int c, int sft_idx); -int con_break(void); +void echo_ctl_c(struct dhdr FAR **pdev, int sft_idx); +int ndread(struct dhdr FAR **pdev); int StdinBusy(void); void con_flush(struct dhdr FAR **pdev); -unsigned char read_char(int sft_idx, BOOL check_break); +unsigned char read_char(int sft_in, int sft_out, BOOL check_break); unsigned char read_char_stdin(BOOL check_break); long cooked_read(struct dhdr FAR **pdev, size_t n, char FAR *bp); void read_line(int sft_in, int sft_out, keyboard FAR * kp); From 6c4fd1228cd0205cd6cb49c567ef7db5177449c6 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Wed, 14 Apr 2004 14:04:04 +0000 Subject: [PATCH 462/671] Two more dangerous INIT BSS variables... git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@884 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/config.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/config.c b/kernel/config.c index b56e4ede..c7a2a7e3 100644 --- a/kernel/config.c +++ b/kernel/config.c @@ -2490,11 +2490,11 @@ STATIC int LoadCountryInfoHardCoded(char *filename, COUNT ctryCode, COUNT codePa ** implementation of INSTALL=NANSI.COM /P /X /BLA */ -int numInstallCmds = 0; +int numInstallCmds BSS_INIT(0); struct instCmds { char buffer[128]; int mode; -} InstallCommands[10]; +} InstallCommands[10] BSS_INIT({0}); #ifdef DEBUG #define InstallPrintf(x) printf x From cf2ed6752b4495de418a86267cbe32d040515a38 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Wed, 14 Apr 2004 15:40:51 +0000 Subject: [PATCH 463/671] Had to change ctrl-c/ctrl-break handling again... Seems to be more consistent now. read_char_sft_dev handles ^C at a fairly high level. So raw_get_char doesn't need to worry about sft's anymore. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@885 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/break.c | 67 +++++++++++++++++++------------ kernel/chario.c | 100 ++++++++++++++++++++++++---------------------- kernel/inthndlr.c | 2 +- kernel/proto.h | 8 +++- 4 files changed, 100 insertions(+), 77 deletions(-) diff --git a/kernel/break.c b/kernel/break.c index 7e287884..be097c52 100644 --- a/kernel/break.c +++ b/kernel/break.c @@ -42,37 +42,52 @@ static BYTE *RcsId = /* Check for ^Break/^C. * Three sources are available: * 1) flag at 40:71 bit 7 - * 2) CON stream (if STDIN is redirected somewhere else) - * 3) input stream (most likely STDIN) - * Actions: - * 1) echo ^C - * 2) clear the STDIN stream - * 3) decrease the InDOS flag as the kernel drops back to user space - * 4) invoke INT-23 and never come back + * 2) syscon stream (usually CON:) + * 3) i/o stream (if unequal to syscon, e.g. AUX) */ -unsigned char check_handle_break(struct dhdr FAR **pdev, int sft_out) + +unsigned char ctrl_break_pressed(void) +{ + return CB_FLG & CB_MSK; +} + +unsigned char check_handle_break(struct dhdr FAR **pdev) { unsigned char c = CTL_C; - if (CB_FLG & CB_MSK) - CB_FLG &= ~CB_MSK; /* reset the ^Break flag */ - else + if (!ctrl_break_pressed()) c = (unsigned char)ndread(&syscon); - if (c == CTL_C) - { - sft_out = -1; - pdev = &syscon; - } - else if (*pdev != syscon) + if (c != CTL_C && *pdev != syscon) c = (unsigned char)ndread(pdev); if (c == CTL_C) - { - con_flush(pdev); - echo_ctl_c(pdev, sft_out); - if (!ErrorMode) /* within int21_handler, InDOS is not incremented */ - if (InDOS) - --InDOS; /* fail-safe */ - - spawn_int23(); /* invoke user INT-23 and never come back */ - } + handle_break(pdev, -1); return c; } + +/* + * Handles a ^Break state + * + * Actions: + * 1) clear the ^Break flag + * 2) clear the STDIN stream + * 3) echo ^C to sft_out or pdev if sft_out==-1 + * 4) decrease the InDOS flag as the kernel drops back to user space + * 5) invoke INT-23 and never come back + */ + +void handle_break(struct dhdr FAR **pdev, int sft_out) +{ + char *buf = "^C\r\n"; + + CB_FLG &= ~CB_MSK; /* reset the ^Break flag */ + con_flush(pdev); + if (sft_out == -1) + cooked_write(pdev, 4, buf); + else + DosRWSft(sft_out, 4, buf, XFR_FORCE_WRITE); + if (!ErrorMode) /* within int21_handler, InDOS is not incremented */ + if (InDOS) + --InDOS; /* fail-safe */ + + spawn_int23(); /* invoke user INT-23 and never come back */ +} + diff --git a/kernel/chario.c b/kernel/chario.c index 755310ee..89de4d3f 100644 --- a/kernel/chario.c +++ b/kernel/chario.c @@ -89,7 +89,7 @@ STATIC int CharIO(struct dhdr FAR **pdev, unsigned char ch, unsigned command) /* STATE FUNCTIONS */ -void CharCmd(struct dhdr FAR **pdev, unsigned command) +STATIC void CharCmd(struct dhdr FAR **pdev, unsigned command) { while (CharRequest(pdev, command) == 1); } @@ -126,14 +126,6 @@ int StdinBusy(void) return s->sft_posit >= s->sft_size; } -STATIC void Do_DosIdle_loop(struct dhdr FAR **pdev) -{ - /* the idle int is only safe if we're using the character stack */ - while (Busy(pdev) && (*pdev == syscon || Busy(&syscon))) - if (user_r->AH < 0xd) - DosIdle_int(); -} - /* get character from the console - this is how DOS gets CTL_C/CTL_S/CTL_P when outputting */ int ndread(struct dhdr FAR **pdev) @@ -144,19 +136,6 @@ int ndread(struct dhdr FAR **pdev) return CharReqHdr.r_ndbyte; } -STATIC void con_hold(struct dhdr FAR **pdev, int sft_out) -{ - unsigned char c = check_handle_break(pdev, sft_out); - if (c == CTL_S) - { - CharIO(pdev, 0, C_INPUT); - Do_DosIdle_loop(pdev); - /* just wait and then skip a character */ - check_handle_break(pdev, sft_out); - CharIO(pdev, 0, C_INPUT); - } -} - /* OUTPUT FUNCTIONS */ #ifdef __WATCOMC__ @@ -213,9 +192,9 @@ STATIC int cooked_write_char(struct dhdr FAR **pdev, /* if not fast then < 0x80; always check otherwise check every 32 characters */ - if (*fast_counter <= 0x80) + if (*fast_counter <= 0x80 && check_handle_break(pdev) == CTL_S) /* Test for hold char and ctl_c */ - con_hold(pdev, -1); + raw_get_char(pdev, TRUE); *fast_counter += 1; *fast_counter &= 0x9f; @@ -302,16 +281,6 @@ STATIC int echo_char(int c, int sft_idx) return c; } -void echo_ctl_c(struct dhdr FAR **pdev, int sft_idx) -{ - char *buf = "^C\r\n"; - - if (sft_idx == -1) - cooked_write(pdev, 4, buf); - else - DosRWSft(sft_idx, 4, buf, XFR_FORCE_WRITE); -} - STATIC void destr_bs(int sft_idx) { write_char(BS, sft_idx); @@ -321,15 +290,13 @@ STATIC void destr_bs(int sft_idx) /* READ FUNCTIONS */ -STATIC int raw_get_char(struct dhdr FAR **pdev, int sft_out, BOOL check_break) +STATIC unsigned char read_char_sft_dev(int sft_in, int sft_out, + struct dhdr FAR **pdev, + BOOL check_break); + +STATIC int raw_get_char(struct dhdr FAR **pdev, BOOL check_break) { - Do_DosIdle_loop(pdev); - if (check_break) - { - con_hold(pdev, sft_out); - Do_DosIdle_loop(pdev); - } - return CharIO(pdev, 0, C_INPUT); + return read_char_sft_dev(-1, -1, pdev, check_break); } long cooked_read(struct dhdr FAR **pdev, size_t n, char FAR *bp) @@ -338,7 +305,7 @@ long cooked_read(struct dhdr FAR **pdev, size_t n, char FAR *bp) int c; while(n--) { - c = raw_get_char(pdev, -1, TRUE); + c = raw_get_char(pdev, TRUE); if (c < 0) return c; if (c == 256) @@ -351,18 +318,55 @@ long cooked_read(struct dhdr FAR **pdev, size_t n, char FAR *bp) return xfer; } -unsigned char read_char(int sft_in, int sft_out, BOOL check_break) +STATIC unsigned char read_char_sft_dev(int sft_in, int sft_out, + struct dhdr FAR **pdev, + BOOL check_break) { unsigned char c; - struct dhdr FAR *dev = sft_to_dev(idx_to_sft(sft_in)); - if (dev) - return (unsigned char)raw_get_char(&dev, sft_out, check_break); + if (pdev) + { + FOREVER + { + if (ctrl_break_pressed()) + { + c = CTL_C; + break; + } + if (!Busy(pdev)) + { + c = CharIO(pdev, 0, C_INPUT); + break; + } + if (check_break && *pdev != syscon) + check_handle_break(&syscon); + /* the idle int is only safe if we're using the character stack */ + if (user_r->AH < 0xd) + DosIdle_int(); + } + } + else + DosRWSft(sft_in, 1, &c, XFR_READ); - DosRWSft(sft_in, 1, &c, XFR_READ); + /* check for break or stop on sft_in, echo to sft_out */ + if (check_break && (c == CTL_C || c == CTL_S)) + { + if (c == CTL_S) + c = read_char_sft_dev(sft_in, sft_out, pdev, FALSE); + if (c == CTL_C) + handle_break(pdev, sft_out); + /* DOS oddity: if you press ^S somekey ^C then ^C does not break */ + c = read_char(sft_in, sft_out, FALSE); + } return c; } +unsigned char read_char(int sft_in, int sft_out, BOOL check_break) +{ + struct dhdr FAR *dev = sft_to_dev(idx_to_sft(sft_in)); + return read_char_sft_dev(sft_in, sft_out, &dev, check_break); +} + STATIC unsigned char read_char_check_break(int sft_in, int sft_out) { return read_char(sft_in, sft_out, TRUE); diff --git a/kernel/inthndlr.c b/kernel/inthndlr.c index 441d9470..fa57db2f 100644 --- a/kernel/inthndlr.c +++ b/kernel/inthndlr.c @@ -408,7 +408,7 @@ VOID ASMCFUNC int21_service(iregs FAR * r) /* Check for Ctrl-Break */ if (break_ena || (lr.AH >= 1 && lr.AH <= 5) || (lr.AH >= 8 && lr.AH <= 0x0b)) - check_handle_break(&syscon, -1); + check_handle_break(&syscon); /* The dispatch handler */ switch (lr.AH) diff --git a/kernel/proto.h b/kernel/proto.h index d3421094..1541a212 100644 --- a/kernel/proto.h +++ b/kernel/proto.h @@ -49,14 +49,18 @@ UWORD dskxfer(COUNT dsk, ULONG blkno, VOID FAR * buf, UWORD numblocks, void AllocateHMASpace (size_t lowbuffer, size_t highbuffer); /* break.c */ -unsigned char check_handle_break(struct dhdr FAR **pdev, int sft_out); +unsigned char ctrl_break_pressed(void); +unsigned char check_handle_break(struct dhdr FAR **pdev); +void handle_break(struct dhdr FAR **pdev, int sft_out); +#ifdef __WATCOMC__ +#pragma aux handle_break aborts; +#endif /* chario.c */ struct dhdr FAR *sft_to_dev(sft FAR *sft); long BinaryCharIO(struct dhdr FAR **pdev, size_t n, void FAR * bp, unsigned command); int echo_char(int c, int sft_idx); -void echo_ctl_c(struct dhdr FAR **pdev, int sft_idx); int ndread(struct dhdr FAR **pdev); int StdinBusy(void); void con_flush(struct dhdr FAR **pdev); From 2734dd94aeaae29e43bfd50ca3d16522ba728e3b Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Wed, 14 Apr 2004 15:53:16 +0000 Subject: [PATCH 464/671] Fix Borland prototype warnings. Use kernel 2034 rc version tag for wider testing. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@886 6ac86273-5f31-0410-b378-82cca8765d1b --- docs/fdkernel.lsm | 4 ++-- hdr/version.h | 10 +++++----- kernel/chario.c | 16 +++++++--------- 3 files changed, 14 insertions(+), 16 deletions(-) diff --git a/docs/fdkernel.lsm b/docs/fdkernel.lsm index ca3d0858..90a4af26 100644 --- a/docs/fdkernel.lsm +++ b/docs/fdkernel.lsm @@ -1,7 +1,7 @@ Begin3 Title: The FreeDOS Kernel -Version: 2.0.33 -Entered-date: 31 Jan 2004 +Version: 2.0.34 +Entered-date: xx Apr 2004 Description: The FreeDOS Kernel. Keywords: kernel freedos dos msdos Author: (developers) diff --git a/hdr/version.h b/hdr/version.h index 99398dca..6370da71 100644 --- a/hdr/version.h +++ b/hdr/version.h @@ -47,8 +47,8 @@ static BYTE *date_hRcsId = #define REVISION_MAJOR 1 #define REVISION_MINOR 1 -#define REVISION_SEQ 33 -#define BUILD "2033" -#define SUB_BUILD "" -#define KERNEL_VERSION_STRING "1.1.33" /*#REVISION_MAJOR "." #REVISION_MINOR "." #REVISION_SEQ */ -#define KERNEL_BUILD_STRING "2033" /*#BUILD SUB_BUILD */ +#define REVISION_SEQ 34 +#define BUILD "2034" +#define SUB_BUILD "rc" +#define KERNEL_VERSION_STRING "1.1.34" /*#REVISION_MAJOR "." #REVISION_MINOR "." #REVISION_SEQ */ +#define KERNEL_BUILD_STRING "2034rc" /*#BUILD SUB_BUILD */ diff --git a/kernel/chario.c b/kernel/chario.c index 89de4d3f..bb905f78 100644 --- a/kernel/chario.c +++ b/kernel/chario.c @@ -174,6 +174,8 @@ void update_scr_pos(unsigned char c, unsigned char count) scr_pos = scrpos; } +STATIC int raw_get_char(struct dhdr FAR **pdev, BOOL check_break); + /* writes a character in cooked mode; maybe with printer echo; handles TAB expansion */ STATIC int cooked_write_char(struct dhdr FAR **pdev, @@ -290,15 +292,6 @@ STATIC void destr_bs(int sft_idx) /* READ FUNCTIONS */ -STATIC unsigned char read_char_sft_dev(int sft_in, int sft_out, - struct dhdr FAR **pdev, - BOOL check_break); - -STATIC int raw_get_char(struct dhdr FAR **pdev, BOOL check_break) -{ - return read_char_sft_dev(-1, -1, pdev, check_break); -} - long cooked_read(struct dhdr FAR **pdev, size_t n, char FAR *bp) { unsigned xfer = 0; @@ -361,6 +354,11 @@ STATIC unsigned char read_char_sft_dev(int sft_in, int sft_out, return c; } +STATIC int raw_get_char(struct dhdr FAR **pdev, BOOL check_break) +{ + return read_char_sft_dev(-1, -1, pdev, check_break); +} + unsigned char read_char(int sft_in, int sft_out, BOOL check_break) { struct dhdr FAR *dev = sft_to_dev(idx_to_sft(sft_in)); From c42277d2598e1c2eb98c964e2cb8fb9e985e128f Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sat, 17 Apr 2004 19:13:20 +0000 Subject: [PATCH 465/671] Update .lsm version.h and changelog. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@887 6ac86273-5f31-0410-b378-82cca8765d1b --- docs/fdkernel.lsm | 2 +- docs/history.txt | 200 ++++++++++++++++++++++++++++++++++++++++++++++ hdr/version.h | 4 +- 3 files changed, 203 insertions(+), 3 deletions(-) diff --git a/docs/fdkernel.lsm b/docs/fdkernel.lsm index 90a4af26..c3b0f54d 100644 --- a/docs/fdkernel.lsm +++ b/docs/fdkernel.lsm @@ -1,7 +1,7 @@ Begin3 Title: The FreeDOS Kernel Version: 2.0.34 -Entered-date: xx Apr 2004 +Entered-date: 17 Apr 2004 Description: The FreeDOS Kernel. Keywords: kernel freedos dos msdos Author: (developers) diff --git a/docs/history.txt b/docs/history.txt index 77cf9e4d..81f149ae 100644 --- a/docs/history.txt +++ b/docs/history.txt @@ -1,3 +1,203 @@ +2004 Apr 17 - Build 2034 +-------- Bart Oldeman (bart@dosemu.org) + * break.c, chario.c, inthndlr.c, proto.h: Improve ctrl-c/ctrl-break + handling: + - read_char_sft_dev handles ^C at a fairly high level. + - ^C didn't work for int21/ah=3f. Corrected + - Do_DosIdle_loop still needs to wait even if it doesn't call the + idle int + - ^C needs to be echoed to STDOUT for low character functions + (ah<0xd) but to the device that is read from for handle + functions. So we need to pass either the STDOUT sft or that + device on to the ^C echoer which now correctly prints ^C\r\n. + - misc cleanups in break.c. + * main.c: Move memset up a little else it would overwrite too much. + * build.txt, config.c, init-mod.h, initdisk.c, inithma.c, main.c: Lucho + reported that MSC compiled kernels now work after all. Let's mark + those nasty "BSS" variables explicitly then to try to avoid + future problems. Also DATASTART should be FAR and not DOSFAR for MSC + * stacks.inc, generic.mak, entry.asm, int2f.asm, kernel.asm, segs.inc: + (suggested by Arkady): use CPU to enforce 8086 etc instructions. + * ioctl.c: Correct int21/ax=4401: returned AL = old value, should + set CY and DE_INVLDDATA if DH!=0 (RBIL is a little confusing here). + * memmgr.c: Converted nxtMCBsize back to a macro. There is no need + to use far2para; FP_SEG works fine since MCBs always have offset 0. + * build.txt, config.c, config.h, kernel.asm, main.c, segs.inc, task.c: + Removed obsolete BYTE cfgCSYS_fnam[NAMEMAX]; config variable. Changed + cfgInit and cfgInitTail to pointers, adjusted some code to cooperate. + * chario.c: The screen position (for TABs) is only for raw + *CONOUT* devices already updated in dosfns.c + * memmgr.c, proto.h: Make unnecessary far pointers near. + * device.h, dsk.c, initdisk.c: Move the ddt bitfields to + df_descflags. Let SetLogDev call GetLogdev, eliminating common code. + * init-mod.h, mscl8.mak: Some vars need to be DOSFAR; + init code is no longer tiny but small. + * segs.inc, inithma.c, main.c, asmsupt.asm, execrh.asm, init-mod.h, + kernel.asm, watcom.mak: + Make CS the same for INIT and HMA text for Watcom. Move HMA text + up in kernel.asm. Use std for the memory move: helps if there's + overlap (PCs with a very low amount of RAM). + No longer include duplicate execrh, asmsupt, and u8m/d functions + for the init text in the Watcom compiled kernel, since they can + be called "near" in the resident code. + * portab.h, kernel.asm, main.c, segs.inc: + Use the "small" model for the init code (split code/data). + * main.c: Use pointer to MK_FP(0,0x5e0) to save a bit of code. + * initdisk.c: Move some common code into a "push_ddt" function. + * sys.c: Correct int25/26 pragmas. Need to explicitly preserve bp + and pop flags. + * initdisk.c: fmemcpy->memcpy where possible + * config.c, init-mod.h, inithma.c, int2f.asm: Make + UMB_get_largest "pascal". Let it use the xms driver address from + the HMA code. Misc small config.c cleanups. + * initdisk.c: "Cache" far drive data table near. Enables elimination + of many far pointers in initdisk.c. Also clear up the + unnecessary casts in ConvPartTableEntryToIntern. + * drivers/getvec.asm, drivers/rdpcclk.asm, drivers/wratclk.asm, + drivers/wrpcclk.asm, globals.h: Use pascal calling + conventions for all clock related asm functions. + * drivers/floppy.asm, dsk.c: Use pascal calling conventions + for floppy asm functions. + * init-mod.h, intr.asm, proto.h, kernel.asm: Use the + pascal calling convention for all intr.asm functions, and let + them pop the stack (smaller code than using bx). Tell Watcom + which registers are clobbered; save some more registers for + intr() -- especially for intr() this helps. + * device.h, execrh.asm, init-mod.h: Use pascal calling conventions + for execrh(). + * mkfiles/watcom.mak: Use the "-r" switch for Watcom to preserve ES + around calls -- saves ~350 bytes. + * sys.c, init-mod.h, fdkrncfg.c, portab.h, prf.c, proto.h: + Introduce VA_CDECL: only Turbo C 2.01 needs an explicit cdecl + for printf, all other compilers can use it with pascal or + "register" calling conventions. Saves ~50 bytes for the init code. + * asmsupt.asm, config.c, init-mod.h: Use strchr and strlen + more often; also use strchr in the init code. + * memmgr.c: Better to call fmemset than to do things manually. + * asmsupt.asm, proto.h, init-mod.h: Be more specific about + which registers are clobbered by asmsupt.asm functions. Preserve + "ES" for Watcom. Saves ~150 bytes resident, ~90 bytes + nonresident, more for 386 kernels. + Preserve bx and cx for WATCOMC as well. Saves another 200 bytes. + * inthndlr.c: Simplify memory access mode check. + * dsk.c: Remove wrong "512" value for number of root directory + entries on FAT32 partitions. + * file.h, sft.h, dosfns.c, fcbfns.c: Get rid of SFT_M* mode + values. O_* values are sufficient. + * file.h, fatfs.c: Define O_ACCMODE and use it instead of "3" for + the open access mask. + * config.c, init-mod.h: Change default STACKS= size to 256. + * config.c, init-mod.h, main.c: Remove lpOldTop variable. + It is no longer necessary (has not been for some time) and the + assignment in config_init_buffers() was wrong (screwed up fnodes, + so that buffers overlapped fnodes...). + * lol.h, config.c, fatfs.c, globals.h, kernel.asm, proto.h: + Made the main fnodes far so they can be in the HMA. + Internally the kernel uses two near fnodes though, to save on + codesize and fmemcpy's if necessary. Having memory management on + two fnodes is a little silly but I just want to make sure with + the panic message that we never accidentally try to use three near + fnodes at the same time (two are used at the same time by rename, + commit, and merge_file_changes). This can be cleaned up later. + * fatfs.c: + - Merge three almost identical pieces of code used to allocate a new + directory entry in creat, rename, and mkdir into alloc_find_free. + - Merge find_fat_free() and extend() -- they were almost + identical. Have a simplified clause for f_cluster == + FREE. Set f_cluster = FREE in shrink_file if the file is set to + 0 bytes; in that case we should set the current cluster to FREE + even if it is currently a LONG_LAST_CLUSTER. + * fnode.h, fatdir.c, fatfs.c, lfnapi.c: + - Eliminate f_back field. extend() now uses f_cluster instead of + f_back, while map_cluster makes sure it's not set to + LONG_LAST_CLUSTER (but to the cluster before it) when calling + extend(). extend() and first_fat() now return the new cluster + number or LONG_LAST_CLUSTER, just like find_fat_free(). + - Eliminated f_sector and f_boff fields from fnodes. + - Avoid bitfields for fnodes, using flags instead. Replaced droot + field by checks for f_dirstart == 0. + - Make f_diroff an entry offset so it can be 16bits. Enforce the + 65536 entry limit in dir_read(), except for root directories. + For root directories it's checked against a different limit + later. Saves 80 bytes or so + 2 bytes in every f_node. + * dsk.c, fatfs.c, memmgr.c: Remove add_far. adjust_far can do the job. + * chario.c: Echo input LF as CR-LF unless it's the first + character. Never store LF in the buffer. + * memmgr.c, task.c: Eliminated long2para and avoided use of "long"s + in DosExeLoader, using paragraphs to measure size instead. Saves + ~130 bytes together. + * prf.c, asmsupt.asm: Saved ~75 bytes in printf and by elimination of + fstrlen. There's only one call; inlining doesn't increase the size. + * dosfns.c, int2f.asm, intr.asm, nls.c: Eliminate intr() + from resident code. Saves ~200 bytes of HMA resident code. Also + made the nls.c functions SS!=DS safe. + * init-mod.h, inthndlr.c, intr.asm, main.c, proto.h, task.c: + int21/ah=26: new_psp now copies the old psp and just sets a few + fields int21/ah=55: child_psp does the rest init code does the + init (fixed values are always copied now) + * dosfns.c: Commit each close, even if the ref count is > 0. + * prf.c: Borland C didn't like one pseudo register use. + * initdisk.c: Merge "suspect partition" copy/paste code into functions. + * asmsupt.asm: Save a couple bytes by moving the strncmp_retzero block. + * fcbfns.c, proto.h: Don't call truename from FcbNameInit(). It + was only necessary for "FcbRename", which can call it itself. + Fixes for FcbOpen/FcbFindFirstNext a consequence of + truename's funny behaviour: truename(c:nul) = c:/nul and + truename(c:/nul) = c:\nul. Fixes the EJECT problem from Lucho. + Remove unused variable lpFcb. + * portab.h, dsk.c, main.c, newstuff.c: Define I386 and I186 more + cleanly. Add (UWORD) casts to silence the compiler. Optimize + (head*sector) to secs_per_cyl. Add BORLANDC to compiler list + and simplify startup printf to one message. + #pragma enable_message(130) for Watcom C causes it to + behave a little more like Borland in terms of warnings. + * exeflat.c, fatfs.c, fattab.c, fcbfns.c, inthndlr.c, + memmgr.c, task.c, blockio.c, fatdir.c: Added explicit + (UWORD) type casts to avoid compiler warnings and sometimes save + a few bytes too. Also changed the FcbParseFname return value: + returns offset portion of pointer (SI) instead of the number of + bytes to be added to SI. ++ Changes Lucho + * task.c: fixes the CHKDSK I: "Invalid drive specification" bug + * mcb.h, inthndlr.c: save 33 bytes by eliminating a switch for + memory/UMB access modes. + * talloc.c: talloc won't work with MSC (no sbrk or brk available) + + fix + * stacks.inc: smaller Protect/Restore 386 register macros. + * inthndlr.c: Code size reduction and dead code removal. + * dosnames.c: Remove wrong automatic "*.*" code from Lixing + Yuan -- return DE_PATHNOTFND or D_NFILES instead + * ioctl.c: move the lock/unlock simulation of success before the + device GENIOCTL check so that it applies to any device. + * filelist, dosnames.h, dosfns.c, dosnames.c, fatdir.c, fatfs.c, + globals.h, init-mod.h: (with Bart) -- remove the dosnames path + 67 length check. Review the places where it really matters (chdir + and mkdir). + * init-mod.h, intr.asm, kernel.asm, main.c, procsupt.asm, + proto.h, task.c: enable interactive re-execution of the SHELL. + * nls.h, config.h, globals.h, init-mod.h: move NLS #defines to + nls.h. Move config structure to config.h. Some cosmetic changes. + * contrib.txt: From Lucho: update contributors list. + * config.c: From Lucho: fix EBDA problems with INSTALL. This + fixes the weird fmemcpy lockup; in reality kernel init code was + overwritten. + * asmsupt.asm, config.c, init-mod.h, inithma.c, main.c, makefile, + prf.c: Use asmsupt string and mem functions for the init code too. ++ Changes Arkady + * task.c: A few suggestions. Saves 5 bytes. + * inthndlr.c: Use AL, not AX, for int2f/ax=1213, as per RBIL + * inthndlr.c: Use xreg struct and macros to optimize the + int2f/12,4a handler a bit ~25 bytes + * config.c: Buffer config fixes. + * inthndlr.c, proto.h: Corrections to int2f/ax=4a01/2. + * blockio.c: buffer intersection check should use > instead + of >=. small optimization -- the segment in bp == firstbuf is + always the same so we just need to compare offsets. + AllocateHMASpace needs to check FP_SEG(firstbuf) for 0xffff, + since the buffers may not live in the HMA. + * *.bat, config.b, kernel/makefile, generic.mak: .BAT file and + makefile cleanups. Also Lucho reported that nmake/nologo doesn't + always work in 4dos, but nmake /nologo works. 2004 Jan 31 - Build 2033 -------- Bart Oldeman (bart@dosemu.org) + Changes Bart diff --git a/hdr/version.h b/hdr/version.h index 6370da71..8199d9fc 100644 --- a/hdr/version.h +++ b/hdr/version.h @@ -49,6 +49,6 @@ static BYTE *date_hRcsId = #define REVISION_MINOR 1 #define REVISION_SEQ 34 #define BUILD "2034" -#define SUB_BUILD "rc" +#define SUB_BUILD "" #define KERNEL_VERSION_STRING "1.1.34" /*#REVISION_MAJOR "." #REVISION_MINOR "." #REVISION_SEQ */ -#define KERNEL_BUILD_STRING "2034rc" /*#BUILD SUB_BUILD */ +#define KERNEL_BUILD_STRING "2034" /*#BUILD SUB_BUILD */ From 545b571c3edc3d74acd8e6886a14014a4f278ada Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Tue, 20 Apr 2004 17:59:35 +0000 Subject: [PATCH 466/671] Finally do the floppy determination type optimization for format -- based on Arkady's suggestions a long time ago. + a few other small optimizations (~70 bytes total). git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@889 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/dsk.c | 107 +++++++++++++++++++++++++-------------------------- 1 file changed, 53 insertions(+), 54 deletions(-) diff --git a/kernel/dsk.c b/kernel/dsk.c index edc8051e..1928e24c 100644 --- a/kernel/dsk.c +++ b/kernel/dsk.c @@ -296,13 +296,14 @@ STATIC WORD RWzero(ddt * pddt, UWORD mode) STATIC WORD Getlogdev(rqptr rp, ddt * pddt) { int i; - ddt *pddt2 = getddt(0); + ddt *pddt2; if (!(pddt->ddt_descflags & DF_MULTLOG)) { rp->r_unit = 0; return S_DONE; } + pddt2 = getddt(0); for (i = 0; i < blk_dev.dh_name[0]; i++, pddt2++) { if (pddt->ddt_driveno == pddt2->ddt_driveno && @@ -321,7 +322,7 @@ STATIC WORD Setlogdev(rqptr rp, ddt * pddt) Getlogdev(rp, pddt); if (rp->r_unit == 0) return S_DONE; - (&(getddt(0))[rp->r_unit - 1])->ddt_descflags &= ~DF_CURLOG; + getddt(rp->r_unit - 1)->ddt_descflags &= ~DF_CURLOG; pddt->ddt_descflags |= DF_CURLOG; rp->r_unit = unit + 1; return S_DONE; @@ -501,7 +502,7 @@ STATIC COUNT Genblockio(ddt * pddt, UWORD mode, WORD head, WORD track, STATIC WORD Genblkdev(rqptr rp, ddt * pddt) { int ret; - bpb *pbpb; + unsigned descflags = pddt->ddt_descflags; #ifdef WITHFAT32 int extended = 0; @@ -517,10 +518,10 @@ STATIC WORD Genblkdev(rqptr rp, ddt * pddt) case 0x40: /* set device parameters */ { struct gblkio FAR *gblp = (struct gblkio FAR *)rp->r_trans; + bpb *pbpb; pddt->ddt_type = gblp->gbio_devtype; - pddt->ddt_descflags &= ~3; - pddt->ddt_descflags |= (gblp->gbio_devattrib & 3) + pddt->ddt_descflags = (descflags & ~3) | (gblp->gbio_devattrib & 3) | (DF_DPCHANGED | DF_REFORMAT); pddt->ddt_ncyl = gblp->gbio_ncyl; /* use default dpb or current bpb? */ @@ -528,11 +529,11 @@ STATIC WORD Genblkdev(rqptr rp, ddt * pddt) (gblp->gbio_spcfunbit & 0x01) == 0 ? &pddt->ddt_defbpb : &pddt->ddt_bpb; #ifdef WITHFAT32 - if (!extended) - fmemcpy(pbpb, &gblp->gbio_bpb, BPB_SIZEOF); - else + fmemcpy(pbpb, &gblp->gbio_bpb, + extended ? sizeof(gblp->gbio_bpb) : BPB_SIZEOF); +#else + fmemcpy(pbpb, &gblp->gbio_bpb, sizeof(gblp->gbio_bpb)); #endif - fmemcpy(pbpb, &gblp->gbio_bpb, sizeof(gblp->gbio_bpb)); /*pbpb->bpb_nsector = gblp->gbio_nsecs; */ break; } @@ -553,17 +554,15 @@ STATIC WORD Genblkdev(rqptr rp, ddt * pddt) UBYTE track, head, sector, type; } *addrfield, afentry; - if (hd(pddt->ddt_descflags)) + pddt->ddt_descflags &= ~DF_DPCHANGED; + if (hd(descflags)) { /* XXX no low-level formatting for hard disks implemented */ fv->gbfv_spcfunbit = 1; /* "not supported by bios" */ - pddt->ddt_descflags &= ~DF_DPCHANGED; return S_DONE; } - if (pddt->ddt_descflags & DF_DPCHANGED) + if (descflags & DF_DPCHANGED) { - pddt->ddt_descflags &= ~DF_DPCHANGED; - /* first try newer setmediatype function */ ret = fl_setmediatype(pddt->ddt_driveno, pddt->ddt_ncyl, pddt->ddt_bpb.bpb_nsecs); @@ -581,7 +580,8 @@ STATIC WORD Genblkdev(rqptr rp, ddt * pddt) else if (ret != 0) /* otherwise, setdisktype */ { - COUNT type = 0; + unsigned char type; + unsigned tracks, secs; if ((fv->gbfv_spcfunbit & 1) && (ret = fl_read(pddt->ddt_driveno, 0, 0, 1, 1, @@ -590,27 +590,25 @@ STATIC WORD Genblkdev(rqptr rp, ddt * pddt) fv->gbfv_spcfunbit = 3; /* no disk in drive */ return dskerr(ret); } - if (pddt->ddt_ncyl == 40 && - (pddt->ddt_bpb.bpb_nsecs == 9 - || pddt->ddt_bpb.bpb_nsecs == 8)) + /* type 1: 320/360K disk in 360K drive */ + /* type 2: 320/360K disk in 1.2M drive */ + tracks = pddt->ddt_ncyl; + secs = pddt->ddt_bpb.bpb_nsecs; + type = pddt->ddt_type + 1; + if (!(tracks == 40 && (secs == 9 || secs == 8) && type < 3)) { - if (pddt->ddt_type == 0) - type = 1; /* 320/360K disk in 360K drive */ - else if (pddt->ddt_type == 1) - type = 2; /* 320/360K disk in 1.2M drive */ - } - else if (pddt->ddt_type == 1 && pddt->ddt_ncyl == 80 && - pddt->ddt_bpb.bpb_nsecs == 15) - type = 3; /* 1.2M disk in 1.2M drive */ - else if ((pddt->ddt_type == 2 || pddt->ddt_type == 7) && - pddt->ddt_ncyl == 80 && pddt->ddt_bpb.bpb_nsecs == 15) - type = 4; /* 720kb disk in 1.44M or 720kb drive */ - - if (type == 0) - { - /* specified tracks, sectors/track not allowed for drive */ - fv->gbfv_spcfunbit = 2; - return dskerr(0xc); + /* type 3: 1.2M disk in 1.2M drive */ + /* type 4: 720kb disk in 1.44M or 720kb drive */ + type++; + if (type == 9) /* 1.44M drive */ + type = 4; + if (!(tracks == 80 && ((secs == 15 && type == 3) || + (secs == 9 && type == 4)))) + { + /* specified tracks, sectors/track not allowed for drive */ + fv->gbfv_spcfunbit = 2; + return dskerr(0xc); + } } fl_setdisktype(pddt->ddt_driveno, type); } @@ -685,16 +683,17 @@ STATIC WORD Genblkdev(rqptr rp, ddt * pddt) case 0x47: /* set access flag */ { struct Access_info FAR *ai = (struct Access_info FAR *)rp->r_trans; - pddt->ddt_descflags &= ~DF_NOACCESS; - pddt->ddt_descflags |= (ai->AI_Flag ? 0 : DF_NOACCESS); + pddt->ddt_descflags = (descflags & ~DF_NOACCESS) | + (ai->AI_Flag ? 0 : DF_NOACCESS); } break; case 0x60: /* get device parameters */ { struct gblkio FAR *gblp = (struct gblkio FAR *)rp->r_trans; + bpb *pbpb; gblp->gbio_devtype = pddt->ddt_type; - gblp->gbio_devattrib = pddt->ddt_descflags & 3; + gblp->gbio_devattrib = descflags & 3; /* 360 kb disk in 1.2 MB drive */ gblp->gbio_media = (pddt->ddt_type == 1) && (pddt->ddt_ncyl == 40); gblp->gbio_ncyl = pddt->ddt_ncyl; @@ -703,11 +702,11 @@ STATIC WORD Genblkdev(rqptr rp, ddt * pddt) (gblp->gbio_spcfunbit & 0x01) == 0 ? &pddt->ddt_defbpb : &pddt->ddt_bpb; #ifdef WITHFAT32 - if (!extended) - fmemcpy(&gblp->gbio_bpb, pbpb, BPB_SIZEOF); - else + fmemcpy(&gblp->gbio_bpb, pbpb, + extended ? sizeof(gblp->gbio_bpb) : BPB_SIZEOF); +#else + fmemcpy(&gblp->gbio_bpb, pbpb, sizeof(gblp->gbio_bpb)); #endif - fmemcpy(&gblp->gbio_bpb, pbpb, sizeof(gblp->gbio_bpb)); /*gblp->gbio_nsecs = pbpb->bpb_nsector; */ break; } @@ -736,7 +735,7 @@ STATIC WORD Genblkdev(rqptr rp, ddt * pddt) case 0x67: /* get access flag */ { struct Access_info FAR *ai = (struct Access_info FAR *)rp->r_trans; - ai->AI_Flag = pddt->ddt_descflags & DF_NOACCESS ? 0 : 1; /* bit 9 */ + ai->AI_Flag = descflags & DF_NOACCESS ? 0 : 1; /* bit 9 */ } break; default: @@ -929,6 +928,7 @@ STATIC int LBA_Transfer(ddt * pddt, UWORD mode, VOID FAR * buffer, unsigned error_code = 0; struct CHS chs; void FAR *transfer_address; + unsigned char driveno = pddt->ddt_driveno; int num_retries; @@ -944,11 +944,12 @@ STATIC int LBA_Transfer(ddt * pddt, UWORD mode, VOID FAR * buffer, if (!hd(pddt->ddt_descflags)) { UBYTE FAR *int1e_ptr = (UBYTE FAR *)getvec(0x1e); + unsigned char nsecs = (unsigned char)(pddt->ddt_bpb.bpb_nsecs); - if (int1e_ptr[4] != pddt->ddt_bpb.bpb_nsecs) + if (int1e_ptr[4] != nsecs) { - int1e_ptr[4] = pddt->ddt_bpb.bpb_nsecs; - fl_reset(pddt->ddt_driveno); + int1e_ptr[4] = nsecs; + fl_reset(driveno); } } @@ -996,18 +997,18 @@ STATIC int LBA_Transfer(ddt * pddt, UWORD mode, VOID FAR * buffer, if ((pddt->ddt_descflags & DF_WRTVERIFY) || mode != LBA_WRITE_VERIFY) { - error_code = fl_lba_ReadWrite(pddt->ddt_driveno, mode, &dap); + error_code = fl_lba_ReadWrite(driveno, mode, &dap); } else { /* verify requested, but not supported */ error_code = - fl_lba_ReadWrite(pddt->ddt_driveno, LBA_WRITE, &dap); + fl_lba_ReadWrite(driveno, LBA_WRITE, &dap); if (error_code == 0) { error_code = - fl_lba_ReadWrite(pddt->ddt_driveno, LBA_VERIFY, &dap); + fl_lba_ReadWrite(driveno, LBA_VERIFY, &dap); } } } @@ -1027,8 +1028,7 @@ STATIC int LBA_Transfer(ddt * pddt, UWORD mode, VOID FAR * buffer, error_code = (mode == LBA_READ ? fl_read : mode == LBA_VERIFY ? fl_verify : mode == - LBA_FORMAT ? fl_format : fl_write) (pddt-> - ddt_driveno, + LBA_FORMAT ? fl_format : fl_write) (driveno, chs.Head, chs.Cylinder, chs.Sector, @@ -1037,15 +1037,14 @@ STATIC int LBA_Transfer(ddt * pddt, UWORD mode, VOID FAR * buffer, if (error_code == 0 && mode == LBA_WRITE_VERIFY) { - error_code = fl_verify(pddt->ddt_driveno, - chs.Head, chs.Cylinder, + error_code = fl_verify(driveno, chs.Head, chs.Cylinder, chs.Sector, count, transfer_address); } } if (error_code == 0) break; - fl_reset(pddt->ddt_driveno); + fl_reset(driveno); } /* end of retries */ From c4e65eb6898b3369fba8bf5d918f400195e43d0a Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Tue, 20 Apr 2004 18:43:03 +0000 Subject: [PATCH 467/671] Start reducing the number of network redirector functions in int2f.asm. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@890 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/blockio.c | 2 +- kernel/dosfns.c | 13 +++++++------ kernel/int2f.asm | 47 ++++++++--------------------------------------- kernel/proto.h | 18 ++---------------- kernel/task.c | 8 +++++--- 5 files changed, 23 insertions(+), 65 deletions(-) diff --git a/kernel/blockio.c b/kernel/blockio.c index 9a66fad2..0c02db14 100644 --- a/kernel/blockio.c +++ b/kernel/blockio.c @@ -342,7 +342,7 @@ BOOL flush(void) } while (FP_OFF(bp) != FP_OFF(firstbuf)); - remote_flushall(); + network_redirector(REM_FLUSHALL); return (ok); } diff --git a/kernel/dosfns.c b/kernel/dosfns.c index bbbc6dcf..c3bbe118 100644 --- a/kernel/dosfns.c +++ b/kernel/dosfns.c @@ -997,7 +997,8 @@ COUNT DosChangeDir(BYTE FAR * s) #endif /* now get fs to change to new */ /* directory */ - result = (result & IS_NETWORK ? remote_chdir() : dos_cd(PriPathName)); + result = (result & IS_NETWORK ? network_redirector(REM_CHDIR) : + dos_cd(PriPathName)); #if defined(CHDIR_DEBUG) printf("status = %04x, new_path='%Fs'\n", result, cdsd->cdsCurrentPath); #endif @@ -1195,7 +1196,7 @@ COUNT DosGetFattr(BYTE FAR * name) return 0x10; if (result & IS_NETWORK) - return remote_getfattr(); + return network_redirector(REM_GETATTRZ); if (result & IS_DEVICE) return DE_FILENOTFND; @@ -1281,7 +1282,7 @@ COUNT DosDelete(BYTE FAR * path, int attrib) return result; if (result & IS_NETWORK) - return remote_delete(); + return network_redirector(REM_DELETE); if (result & IS_DEVICE) return DE_FILENOTFND; @@ -1296,7 +1297,7 @@ COUNT DosRenameTrue(BYTE * path1, BYTE * path2, int attrib) return DE_DEVICE; /* not same device */ } if (FP_OFF(current_ldt) == 0xFFFF || (current_ldt->cdsFlags & CDSNETWDRV)) - return remote_rename(); + return network_redirector(REM_RENAME); return dos_rename(path1, path2, attrib); } @@ -1331,7 +1332,7 @@ COUNT DosMkdir(const char FAR * dir) return result; if (result & IS_NETWORK) - return remote_mkdir(); + return network_redirector(REM_MKDIR); if (result & IS_DEVICE) return DE_ACCESS; @@ -1352,7 +1353,7 @@ COUNT DosRmdir(const char FAR * dir) return result; if (result & IS_NETWORK) - return remote_rmdir(); + return network_redirector(REM_RMDIR); if (result & IS_DEVICE) return DE_ACCESS; diff --git a/kernel/int2f.asm b/kernel/int2f.asm index ee12fd16..adfb1417 100644 --- a/kernel/int2f.asm +++ b/kernel/int2f.asm @@ -273,20 +273,14 @@ SHARE_LOCK_UNLOCK: ; sumtimes return data *ptr is the push stack word ; - global _remote_rmdir -_remote_rmdir: - mov al, 01h - jmp short call_int2f - - global _remote_mkdir -_remote_mkdir: - mov al, 03h - jmp short call_int2f - - global _remote_chdir -_remote_chdir: - mov al, 05h - jmp short call_int2f + global NETWORK_REDIRECTOR +NETWORK_REDIRECTOR: + push bp + mov bp, sp + mov al, [bp+4] + pop bp + call call_int2f + ret 2 global _remote_close _remote_close: @@ -316,21 +310,6 @@ _remote_setfattr: mov al, 0eh jmp short call_int2f - global _remote_getfattr -_remote_getfattr: - mov al, 0fh - jmp short call_int2f - - global _remote_rename -_remote_rename: - mov al, 11h - jmp short call_int2f - - global _remote_delete -_remote_delete: - mov al, 13h - jmp short call_int2f - global _remote_open _remote_open: mov al, 16h @@ -351,11 +330,6 @@ _remote_findnext: mov al, 1ch jmp short call_int2f - global _remote_close_all -_remote_close_all: - mov al, 1dh - jmp short call_int2f - global _remote_doredirect _remote_doredirect: mov al, 1eh @@ -366,11 +340,6 @@ _remote_printset: mov al, 1fh jmp short call_int2f - global _remote_flushall -_remote_flushall: - mov al, 20h - jmp short call_int2f - global _remote_lseek _remote_lseek: mov al, 21h diff --git a/kernel/proto.h b/kernel/proto.h index 1541a212..ba18754e 100644 --- a/kernel/proto.h +++ b/kernel/proto.h @@ -379,21 +379,14 @@ int DosMkTmp(BYTE FAR * pathname, UWORD attr); COUNT truename(const char FAR * src, char * dest, COUNT t); /* network.c */ +COUNT ASMPASCAL network_redirector(unsigned cmd); COUNT ASMCFUNC remote_doredirect(UWORD b, UCOUNT n, UWORD d, VOID FAR * s, UWORD i, VOID FAR * data); COUNT ASMCFUNC remote_printset(UWORD b, UCOUNT n, UWORD d, VOID FAR * s, UWORD i, VOID FAR * data); -COUNT ASMCFUNC remote_rename(VOID); -COUNT ASMCFUNC remote_delete(VOID); -COUNT ASMCFUNC remote_chdir(VOID); -COUNT ASMCFUNC remote_mkdir(VOID); -COUNT ASMCFUNC remote_rmdir(VOID); -COUNT ASMCFUNC remote_close_all(VOID); COUNT ASMCFUNC remote_process_end(VOID); -COUNT ASMCFUNC remote_flushall(VOID); COUNT ASMCFUNC remote_findfirst(VOID FAR * s); COUNT ASMCFUNC remote_findnext(VOID FAR * s); -COUNT ASMCFUNC remote_getfattr(VOID); COUNT ASMCFUNC remote_getfree(VOID FAR * s, VOID * d); COUNT ASMCFUNC remote_open(sft FAR * s, COUNT mode); int ASMCFUNC remote_extopen(sft FAR * s, unsigned attr); @@ -412,16 +405,8 @@ COUNT ASMCFUNC QRemote_Fn(char FAR * d, const char FAR * s); #pragma aux cdecl_axdx "_*" parm caller [] modify exact [ax dx] #pragma aux (cdecl_axdx) remote_doredirect #pragma aux (cdecl_axdx) remote_printset -#pragma aux (cdecl_axdx) remote_rename -#pragma aux (cdecl_axdx) remote_delete -#pragma aux (cdecl_axdx) remote_chdir -#pragma aux (cdecl_axdx) remote_mkdir -#pragma aux (cdecl_axdx) remote_rmdir -#pragma aux (cdecl_axdx) remote_close_all -#pragma aux (cdecl_axdx) remote_flushall #pragma aux (cdecl_axdx) remote_findfirst #pragma aux (cdecl_axdx) remote_findnext -#pragma aux (cdecl_axdx) remote_getfattr #pragma aux (cdecl_axdx) remote_getfree #pragma aux (cdecl_axdx) remote_open #pragma aux (cdecl_axdx) remote_extopen @@ -434,6 +419,7 @@ COUNT ASMCFUNC QRemote_Fn(char FAR * d, const char FAR * s); #pragma aux (cdecl_axdx) remote_commit #pragma aux (cdecl_axdx) remote_close #pragma aux (cdecl_axdx) QRemote_Fn +#pragma aux (pascal) network_redirector modify exact [ax dx] #endif UWORD get_machine_name(BYTE FAR * netname); diff --git a/kernel/task.c b/kernel/task.c index c4653bf1..236b4cc4 100644 --- a/kernel/task.c +++ b/kernel/task.c @@ -522,11 +522,13 @@ VOID return_user(void) setvec(0x24, p->ps_isv24); /* And free all process memory if not a TSR return */ - remote_process_end(); /* might be a good idea to do that after closing - but doesn't help NET either TE */ + network_redirector(REM_PROCESS_END); + /* might be a good idea to do that after closing + but doesn't help NET either TE */ + if (!tsr) { - remote_close_all(); + network_redirector(REM_CLOSEALL); for (i = 0; i < p->ps_maxfiles; i++) { DosClose(i); From ebbd6b833617f861ded203abf4fbb177bdf4682e Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Tue, 20 Apr 2004 20:25:26 +0000 Subject: [PATCH 468/671] Convert next batch of remote_ functions (with one far pointer argument) -- network_redirector() can be a wrapper in C. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@891 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/dosfns.c | 6 +++--- kernel/int2f.asm | 28 ++++------------------------ kernel/network.c | 5 +++++ kernel/proto.h | 13 +++---------- 4 files changed, 15 insertions(+), 37 deletions(-) diff --git a/kernel/dosfns.c b/kernel/dosfns.c index c3bbe118..30410b03 100644 --- a/kernel/dosfns.c +++ b/kernel/dosfns.c @@ -733,7 +733,7 @@ COUNT DosCloseSft(int sft_idx, BOOL commitonly) if (sftp->sft_flags & SFT_FSHARED) { /* printf("closing SFT %d = %p\n",sft_idx,sftp); */ - return (commitonly ? remote_commit(sftp) : remote_close(sftp)); + return network_redirector_fp(commitonly ? REM_FLUSH: REM_CLOSE, sftp); } /* now just drop the count if a device, else */ @@ -1058,7 +1058,7 @@ COUNT DosFindFirst(UCOUNT attr, BYTE FAR * name) memset(&sda_tmp_dm, 0, sizeof(dmatch)+sizeof(struct dirent)); if (rc & IS_NETWORK) - rc = remote_findfirst(current_ldt); + rc = network_redirector_fp(REM_FINDFIRST, current_ldt); else if (rc & IS_DEVICE) { const char *p; @@ -1120,7 +1120,7 @@ COUNT DosFindNext(void) memset(&SearchDir, 0, sizeof(struct dirent)); dta = &sda_tmp_dm; rc = (sda_tmp_dm.dm_drive & 0x80) ? - remote_findnext(&sda_tmp_dm) : dos_findnext(); + network_redirector_fp(REM_FINDNEXT, &sda_tmp_dm) : dos_findnext(); dta = dmp; if (rc == SUCCESS) diff --git a/kernel/int2f.asm b/kernel/int2f.asm index adfb1417..3ad01510 100644 --- a/kernel/int2f.asm +++ b/kernel/int2f.asm @@ -273,24 +273,14 @@ SHARE_LOCK_UNLOCK: ; sumtimes return data *ptr is the push stack word ; - global NETWORK_REDIRECTOR -NETWORK_REDIRECTOR: + global NETWORK_REDIRECTOR_FP +NETWORK_REDIRECTOR_FP: push bp mov bp, sp - mov al, [bp+4] + mov al, [bp+8] pop bp call call_int2f - ret 2 - - global _remote_close -_remote_close: - mov al, 06h - jmp short call_int2f - - global _remote_commit -_remote_commit: - mov al, 07h - jmp short call_int2f + ret 6 global _remote_read _remote_read: mov al, 08h @@ -320,16 +310,6 @@ _remote_creat: mov al, 17h jmp short call_int2f - global _remote_findfirst -_remote_findfirst: - mov al, 1bh - jmp short call_int2f - - global _remote_findnext -_remote_findnext: - mov al, 1ch - jmp short call_int2f - global _remote_doredirect _remote_doredirect: mov al, 1eh diff --git a/kernel/network.c b/kernel/network.c index 094299af..03b2909c 100644 --- a/kernel/network.c +++ b/kernel/network.c @@ -51,3 +51,8 @@ VOID set_machine_name(BYTE FAR * netname, UWORD name_num) net_set_count++; } +int network_redirector(unsigned cmd) +{ + return network_redirector_fp(cmd, NULL); +} + diff --git a/kernel/proto.h b/kernel/proto.h index ba18754e..eb24f7bc 100644 --- a/kernel/proto.h +++ b/kernel/proto.h @@ -379,14 +379,13 @@ int DosMkTmp(BYTE FAR * pathname, UWORD attr); COUNT truename(const char FAR * src, char * dest, COUNT t); /* network.c */ -COUNT ASMPASCAL network_redirector(unsigned cmd); +int network_redirector(unsigned cmd); +int ASMPASCAL network_redirector_fp(unsigned cmd, void far *s); COUNT ASMCFUNC remote_doredirect(UWORD b, UCOUNT n, UWORD d, VOID FAR * s, UWORD i, VOID FAR * data); COUNT ASMCFUNC remote_printset(UWORD b, UCOUNT n, UWORD d, VOID FAR * s, UWORD i, VOID FAR * data); COUNT ASMCFUNC remote_process_end(VOID); -COUNT ASMCFUNC remote_findfirst(VOID FAR * s); -COUNT ASMCFUNC remote_findnext(VOID FAR * s); COUNT ASMCFUNC remote_getfree(VOID FAR * s, VOID * d); COUNT ASMCFUNC remote_open(sft FAR * s, COUNT mode); int ASMCFUNC remote_extopen(sft FAR * s, unsigned attr); @@ -396,8 +395,6 @@ UCOUNT ASMCFUNC remote_write(sft FAR * s, UCOUNT n, COUNT * err); COUNT ASMCFUNC remote_creat(sft FAR * s, COUNT attr); COUNT ASMCFUNC remote_setfattr(COUNT attr); COUNT ASMCFUNC remote_printredir(UCOUNT dx, UCOUNT ax); -COUNT ASMCFUNC remote_commit(sft FAR * s); -COUNT ASMCFUNC remote_close(sft FAR * s); COUNT ASMCFUNC QRemote_Fn(char FAR * d, const char FAR * s); #ifdef __WATCOMC__ /* bx, cx, and es not used or clobbered for all remote functions, @@ -405,8 +402,6 @@ COUNT ASMCFUNC QRemote_Fn(char FAR * d, const char FAR * s); #pragma aux cdecl_axdx "_*" parm caller [] modify exact [ax dx] #pragma aux (cdecl_axdx) remote_doredirect #pragma aux (cdecl_axdx) remote_printset -#pragma aux (cdecl_axdx) remote_findfirst -#pragma aux (cdecl_axdx) remote_findnext #pragma aux (cdecl_axdx) remote_getfree #pragma aux (cdecl_axdx) remote_open #pragma aux (cdecl_axdx) remote_extopen @@ -416,10 +411,8 @@ COUNT ASMCFUNC QRemote_Fn(char FAR * d, const char FAR * s); #pragma aux (cdecl_axdx) remote_creat #pragma aux (cdecl_axdx) remote_setfattr #pragma aux (cdecl_axdx) remote_printredir -#pragma aux (cdecl_axdx) remote_commit -#pragma aux (cdecl_axdx) remote_close #pragma aux (cdecl_axdx) QRemote_Fn -#pragma aux (pascal) network_redirector modify exact [ax dx] +#pragma aux (pascal) network_redirector_fp modify exact [ax dx] #endif UWORD get_machine_name(BYTE FAR * netname); From 4dc4ae8be8f47374e18797117cc0ed13711e45b3 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Wed, 21 Apr 2004 00:53:45 +0000 Subject: [PATCH 469/671] Third stage for int2f callers: split int2f.asm functions, don't let them preserve as many registers, use pascal calling convention for the "open" (but really: multiplex) function. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@892 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/dosfns.c | 19 +++-- kernel/int2f.asm | 197 ++++++++++++++++++++--------------------------- kernel/network.c | 6 +- kernel/proto.h | 28 +------ 4 files changed, 103 insertions(+), 147 deletions(-) diff --git a/kernel/dosfns.c b/kernel/dosfns.c index 30410b03..f7430bec 100644 --- a/kernel/dosfns.c +++ b/kernel/dosfns.c @@ -233,7 +233,8 @@ long DosRWSft(int sft_idx, size_t n, void FAR * bp, int mode) lpCurSft = s; current_filepos = s->sft_posit; /* needed for MSCDEX */ dta = bp; - XferCount = (mode == XFR_READ ? remote_read : remote_write)(s, n, &err); + XferCount = network_redirector_rw(mode == XFR_READ ? REM_READ : REM_WRITE, + s, n, &err); dta = save_dta; return err == SUCCESS ? (long)XferCount : err; } @@ -546,22 +547,26 @@ long DosOpenSft(char FAR * fname, unsigned flags, unsigned attrib) if (result & IS_NETWORK) { int status; + unsigned cmd; if ((flags & (O_TRUNC | O_CREAT)) == O_CREAT) attrib |= 0x100; - + lpCurSft = sftp; + cmd = REM_CREATE; if (!(flags & O_LEGACY)) { extern UWORD ASM ext_open_mode, ASM ext_open_attrib, ASM ext_open_action; ext_open_mode = flags & 0x70ff; ext_open_attrib = attrib & 0xff; ext_open_action = ((flags & 0x0300) >> 8) | ((flags & O_CREAT) >> 6); - status = remote_extopen(sftp, attrib); + cmd = REM_EXTOC; } - else if (flags & O_CREAT) - status = remote_creat(sftp, attrib); - else - status = remote_open(sftp, (BYTE)flags); + else if (!(flags & O_CREAT)) + { + cmd = REM_OPEN; + attrib = (BYTE)flags; + } + status = network_redirector_open(cmd, sftp, attrib); if (status >= SUCCESS) { if (sftp->sft_count == 0) diff --git a/kernel/int2f.asm b/kernel/int2f.asm index 3ad01510..d9926165 100644 --- a/kernel/int2f.asm +++ b/kernel/int2f.asm @@ -271,109 +271,66 @@ SHARE_LOCK_UNLOCK: ; ; assume ss == ds after setup of stack in entry ; sumtimes return data *ptr is the push stack word -; +; - global NETWORK_REDIRECTOR_FP -NETWORK_REDIRECTOR_FP: + global _remote_printredir +_remote_printredir: push bp - mov bp, sp - mov al, [bp+8] - pop bp - call call_int2f - ret 6 - - global _remote_read -_remote_read: mov al, 08h - jmp short call_int2f - - global _remote_write -_remote_write: mov al, 09h - jmp short call_int2f - - global _remote_getfree -_remote_getfree: - mov al, 0ch - jmp short call_int2f + mov bp,sp + push si + push di + mov ax, 1125h + mov dx, [bp+4] + push word [bp+6] + jmp short int2f_call global _remote_setfattr _remote_setfattr: - mov al, 0eh - jmp short call_int2f - - global _remote_open -_remote_open: - mov al, 16h - jmp short call_int2f - - global _remote_creat -_remote_creat: - mov al, 17h - jmp short call_int2f - - global _remote_doredirect -_remote_doredirect: - mov al, 1eh - jmp short call_int2f - - global _remote_printset -_remote_printset: - mov al, 1fh - jmp short call_int2f + push bp + mov bp,sp + push si + push di + mov ax, 110eh + push word [bp+4] + jmp short int2f_call global _remote_lseek _remote_lseek: - mov al, 21h - jmp short call_int2f + push bp + mov bp,sp + push si + push di - global _QRemote_Fn -_QRemote_Fn - mov al, 23h - jmp short call_int2f - - global _remote_printredir -_remote_printredir: - mov al, 25h - jmp short call_int2f + mov ax, 1121h ; 21h, Lseek from eof + les di, [bp+4] + mov dx, [bp+8] + mov cx, [bp+10] + ; "fall through" - global _remote_extopen -_remote_extopen: - mov al, 2eh - +remote_getfattr: + clc ; set to succeed + int 2fh + jc no_clear_ax + jmp short no_neg_ax + +;int ASMPASCAL network_redirector_open(unsigned cmd, void far *s, unsigned arg) + global NETWORK_REDIRECTOR_OPEN +NETWORK_REDIRECTOR_OPEN: + pop bx ; ret address + pop cx ; stack value (arg) + pop dx ; off s + pop es ; seg s + pop ax ; cmd (ax) + push bx ; ret address call_int2f: - mov ah, 11h push bp - mov bp,sp - push es push si push di - push cx - push bx - - cmp al, 0eh - je remote_setfattr + mov di, dx ; es:di -> s cmp al, 0fh je remote_getfattr - cmp al, 1eh - je print_doredir - cmp al, 1fh - je print_doredir - cmp al, 25h - je remote_printredir + push cx ; arg - les di, [bp+4] - cmp al, 08h - je remote_rw - cmp al, 09h - je remote_rw - cmp al, 0ch - je remote_getfree - cmp al, 21h ; 21h, Lseek from eof - je lseekeof - cmp al, 23h - je qremote_fn - -int2f_call_push: - push word [bp+8] ; very fakey, HaHa ;) int2f_call: xor cx, cx ; set to succeed; clear carry and CX int 2fh @@ -386,31 +343,26 @@ clear_ax: xchg ax, cx ; extended open -> status from CX in AX ; otherwise CX was set to zero above no_neg_ax: - pop bx - pop cx pop di pop si - pop es pop bp ret -lseekeof: - mov dx, [bp+8] - mov cx, [bp+10] - ; "fall through" - -remote_getfattr: - clc ; set to succeed - int 2fh - jc no_clear_ax - jmp short no_neg_ax - -remote_setfattr: - push word [bp+4] - jmp short int2f_call + global _remote_doredirect +_remote_doredirect: + mov al, 1eh + jmp short print_doredir + global _remote_printset +_remote_printset: + mov al, 1fh print_doredir: + push bp + mov bp,sp + push si + push di push ds + mov ah, 11h mov si,[bp+14] les di,[bp+10] mov dx,[bp+8] @@ -427,7 +379,14 @@ print_doredir: xor cx, cx jmp short clear_ax -remote_getfree: + global _remote_getfree +_remote_getfree: + push bp + mov bp,sp + push si + push di + mov ax, 110ch + les di, [bp+4] clc ; set to succeed int 2fh jc no_clear_ax @@ -439,15 +398,15 @@ remote_getfree: xor cx, cx jmp short clear_ax -remote_printredir: - mov dx, [bp+4] - push word [bp+6] - jmp short int2f_call - -remote_rw: jmp short remote_rw1 - -qremote_fn: + global _QRemote_Fn +_QRemote_Fn: + push bp + mov bp,sp + push si + push di push ds + mov ax, 1123h + les di, [bp+4] lds si,[bp+8] clc int 2fh @@ -457,13 +416,21 @@ qremote_fn: xor cx, cx jmp short clear_ax -remote_rw1: mov cx, [bp+8] + global _network_redirector_rw +_network_redirector_rw: + push bp + mov bp, sp + push si + push di + mov ax, [bp+4] + les di, [bp+6] + mov cx, [bp+10] clc ; set to succeed int 2fh jc int2f_carry xor ax, ax int2f_carry: neg ax - mov di, [bp+10] + mov di, [bp+12] mov [di], ax mov ax, cx jmp no_neg_ax @@ -471,7 +438,7 @@ int2f_carry: neg ax global _remote_process_end _remote_process_end: ; Terminate process mov ds, [_cu_psp] - mov al, 22h + mov ax, 1122h call call_int2f push ss pop ds diff --git a/kernel/network.c b/kernel/network.c index 03b2909c..57997975 100644 --- a/kernel/network.c +++ b/kernel/network.c @@ -51,8 +51,12 @@ VOID set_machine_name(BYTE FAR * netname, UWORD name_num) net_set_count++; } +int network_redirector_fp(unsigned cmd, void far *s) +{ + return network_redirector_open(cmd, s, 0); +} + int network_redirector(unsigned cmd) { return network_redirector_fp(cmd, NULL); } - diff --git a/kernel/proto.h b/kernel/proto.h index eb24f7bc..015415e3 100644 --- a/kernel/proto.h +++ b/kernel/proto.h @@ -380,40 +380,20 @@ COUNT truename(const char FAR * src, char * dest, COUNT t); /* network.c */ int network_redirector(unsigned cmd); -int ASMPASCAL network_redirector_fp(unsigned cmd, void far *s); +int network_redirector_fp(unsigned cmd, void far *s); +int ASMPASCAL network_redirector_open(unsigned cmd, void far *s, unsigned arg); +unsigned ASMCFUNC network_redirector_rw(unsigned cmd, void far *s, + unsigned n, int *err); COUNT ASMCFUNC remote_doredirect(UWORD b, UCOUNT n, UWORD d, VOID FAR * s, UWORD i, VOID FAR * data); COUNT ASMCFUNC remote_printset(UWORD b, UCOUNT n, UWORD d, VOID FAR * s, UWORD i, VOID FAR * data); COUNT ASMCFUNC remote_process_end(VOID); COUNT ASMCFUNC remote_getfree(VOID FAR * s, VOID * d); -COUNT ASMCFUNC remote_open(sft FAR * s, COUNT mode); -int ASMCFUNC remote_extopen(sft FAR * s, unsigned attr); LONG ASMCFUNC remote_lseek(sft FAR * s, LONG new_pos); -UCOUNT ASMCFUNC remote_read(sft FAR * s, UCOUNT n, COUNT * err); -UCOUNT ASMCFUNC remote_write(sft FAR * s, UCOUNT n, COUNT * err); -COUNT ASMCFUNC remote_creat(sft FAR * s, COUNT attr); COUNT ASMCFUNC remote_setfattr(COUNT attr); COUNT ASMCFUNC remote_printredir(UCOUNT dx, UCOUNT ax); COUNT ASMCFUNC QRemote_Fn(char FAR * d, const char FAR * s); -#ifdef __WATCOMC__ -/* bx, cx, and es not used or clobbered for all remote functions, - * except lock_unlock and process_end */ -#pragma aux cdecl_axdx "_*" parm caller [] modify exact [ax dx] -#pragma aux (cdecl_axdx) remote_doredirect -#pragma aux (cdecl_axdx) remote_printset -#pragma aux (cdecl_axdx) remote_getfree -#pragma aux (cdecl_axdx) remote_open -#pragma aux (cdecl_axdx) remote_extopen -#pragma aux (cdecl_axdx) remote_lseek -#pragma aux (cdecl_axdx) remote_read -#pragma aux (cdecl_axdx) remote_write -#pragma aux (cdecl_axdx) remote_creat -#pragma aux (cdecl_axdx) remote_setfattr -#pragma aux (cdecl_axdx) remote_printredir -#pragma aux (cdecl_axdx) QRemote_Fn -#pragma aux (pascal) network_redirector_fp modify exact [ax dx] -#endif UWORD get_machine_name(BYTE FAR * netname); VOID set_machine_name(BYTE FAR * netname, UWORD name_num); From 01e5973aa090c650e6080d7e2aa7e9af59dc6130 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Wed, 21 Apr 2004 02:01:56 +0000 Subject: [PATCH 470/671] Re-merge parts of network_redirector_rw with network_redirector_open, and let it return a long instead of using a *err pointer. Call the resulting function NETWORK_REDIRECTOR_MX (multiplex) git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@893 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/dosfns.c | 11 +++++------ kernel/int2f.asm | 45 +++++++++++++++++++++------------------------ kernel/network.c | 2 +- kernel/proto.h | 4 +--- 4 files changed, 28 insertions(+), 34 deletions(-) diff --git a/kernel/dosfns.c b/kernel/dosfns.c index f7430bec..b42834e1 100644 --- a/kernel/dosfns.c +++ b/kernel/dosfns.c @@ -225,18 +225,17 @@ long DosRWSft(int sft_idx, size_t n, void FAR * bp, int mode) */ if (s->sft_flags & SFT_FSHARED) { - UCOUNT XferCount; + long XferCount; VOID FAR *save_dta; - int err; save_dta = dta; lpCurSft = s; current_filepos = s->sft_posit; /* needed for MSCDEX */ dta = bp; - XferCount = network_redirector_rw(mode == XFR_READ ? REM_READ : REM_WRITE, - s, n, &err); + XferCount = network_redirector_mx(mode == XFR_READ ? REM_READ : REM_WRITE, + s, n); dta = save_dta; - return err == SUCCESS ? (long)XferCount : err; + return XferCount; } /* Do a device transfer if device */ @@ -566,7 +565,7 @@ long DosOpenSft(char FAR * fname, unsigned flags, unsigned attrib) cmd = REM_OPEN; attrib = (BYTE)flags; } - status = network_redirector_open(cmd, sftp, attrib); + status = (int)network_redirector_mx(cmd, sftp, attrib); if (status >= SUCCESS) { if (sftp->sft_count == 0) diff --git a/kernel/int2f.asm b/kernel/int2f.asm index d9926165..32827a07 100644 --- a/kernel/int2f.asm +++ b/kernel/int2f.asm @@ -313,9 +313,9 @@ remote_getfattr: jc no_clear_ax jmp short no_neg_ax -;int ASMPASCAL network_redirector_open(unsigned cmd, void far *s, unsigned arg) - global NETWORK_REDIRECTOR_OPEN -NETWORK_REDIRECTOR_OPEN: +;long ASMPASCAL network_redirector_mx(unsigned cmd, void far *s, unsigned arg) + global NETWORK_REDIRECTOR_MX +NETWORK_REDIRECTOR_MX: pop bx ; ret address pop cx ; stack value (arg) pop dx ; off s @@ -326,9 +326,14 @@ call_int2f: push bp push si push di - mov di, dx ; es:di -> s cmp al, 0fh je remote_getfattr + + mov di, dx ; es:di -> s + cmp al, 08h + je remote_rw + cmp al, 09h + je remote_rw push cx ; arg int2f_call: @@ -398,6 +403,17 @@ _remote_getfree: xor cx, cx jmp short clear_ax +remote_rw: + clc ; set to succeed + int 2fh + jc int2f_carry + mov ax, cx + xor dx, dx ; dx:ax = bytes read + jmp short no_neg_ax +int2f_carry: neg ax + cwd + jmp short no_neg_ax + global _QRemote_Fn _QRemote_Fn: push bp @@ -414,27 +430,8 @@ _QRemote_Fn: mov ax,0xffff jc no_neg_ax xor cx, cx - jmp short clear_ax + jmp clear_ax - global _network_redirector_rw -_network_redirector_rw: - push bp - mov bp, sp - push si - push di - mov ax, [bp+4] - les di, [bp+6] - mov cx, [bp+10] - clc ; set to succeed - int 2fh - jc int2f_carry - xor ax, ax -int2f_carry: neg ax - mov di, [bp+12] - mov [di], ax - mov ax, cx - jmp no_neg_ax - global _remote_process_end _remote_process_end: ; Terminate process mov ds, [_cu_psp] diff --git a/kernel/network.c b/kernel/network.c index 57997975..5004243e 100644 --- a/kernel/network.c +++ b/kernel/network.c @@ -53,7 +53,7 @@ VOID set_machine_name(BYTE FAR * netname, UWORD name_num) int network_redirector_fp(unsigned cmd, void far *s) { - return network_redirector_open(cmd, s, 0); + return (int)network_redirector_mx(cmd, s, 0); } int network_redirector(unsigned cmd) diff --git a/kernel/proto.h b/kernel/proto.h index 015415e3..68dae7e4 100644 --- a/kernel/proto.h +++ b/kernel/proto.h @@ -381,9 +381,7 @@ COUNT truename(const char FAR * src, char * dest, COUNT t); /* network.c */ int network_redirector(unsigned cmd); int network_redirector_fp(unsigned cmd, void far *s); -int ASMPASCAL network_redirector_open(unsigned cmd, void far *s, unsigned arg); -unsigned ASMCFUNC network_redirector_rw(unsigned cmd, void far *s, - unsigned n, int *err); +long ASMPASCAL network_redirector_mx(unsigned cmd, void far *s, unsigned arg); COUNT ASMCFUNC remote_doredirect(UWORD b, UCOUNT n, UWORD d, VOID FAR * s, UWORD i, VOID FAR * data); COUNT ASMCFUNC remote_printset(UWORD b, UCOUNT n, UWORD d, VOID FAR * s, From 8d1eda45f9fc15d70b90a7043d21a2740c769f76 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Wed, 21 Apr 2004 11:04:08 +0000 Subject: [PATCH 471/671] Further int2f.asm reduction... now using generic void *arg argument to pass the third parameter which can be various things. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@894 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/dosfns.c | 4 +- kernel/int2f.asm | 132 +++++++---------------------------------------- kernel/proto.h | 10 ++-- 3 files changed, 26 insertions(+), 120 deletions(-) diff --git a/kernel/dosfns.c b/kernel/dosfns.c index b42834e1..787fd8e1 100644 --- a/kernel/dosfns.c +++ b/kernel/dosfns.c @@ -233,7 +233,7 @@ long DosRWSft(int sft_idx, size_t n, void FAR * bp, int mode) current_filepos = s->sft_posit; /* needed for MSCDEX */ dta = bp; XferCount = network_redirector_mx(mode == XFR_READ ? REM_READ : REM_WRITE, - s, n); + s, (void *)n); dta = save_dta; return XferCount; } @@ -565,7 +565,7 @@ long DosOpenSft(char FAR * fname, unsigned flags, unsigned attrib) cmd = REM_OPEN; attrib = (BYTE)flags; } - status = (int)network_redirector_mx(cmd, sftp, attrib); + status = (int)network_redirector_mx(cmd, sftp, (void *)attrib); if (status >= SUCCESS) { if (sftp->sft_count == 0) diff --git a/kernel/int2f.asm b/kernel/int2f.asm index 32827a07..07d2e414 100644 --- a/kernel/int2f.asm +++ b/kernel/int2f.asm @@ -284,27 +284,10 @@ _remote_printredir: push word [bp+6] jmp short int2f_call - global _remote_setfattr -_remote_setfattr: - push bp - mov bp,sp - push si - push di - mov ax, 110eh - push word [bp+4] - jmp short int2f_call - - global _remote_lseek -_remote_lseek: - push bp - mov bp,sp - push si - push di - - mov ax, 1121h ; 21h, Lseek from eof - les di, [bp+4] - mov dx, [bp+8] - mov cx, [bp+10] +remote_lseek: ; arg is a pointer to the long seek value + mov bx, cx + mov dx, [bx] + mov cx, [bx+2] ; "fall through" remote_getfattr: @@ -313,11 +296,11 @@ remote_getfattr: jc no_clear_ax jmp short no_neg_ax -;long ASMPASCAL network_redirector_mx(unsigned cmd, void far *s, unsigned arg) +;long ASMPASCAL network_redirector_mx(unsigned cmd, void far *s, void *arg) global NETWORK_REDIRECTOR_MX NETWORK_REDIRECTOR_MX: pop bx ; ret address - pop cx ; stack value (arg) + pop cx ; stack value (arg); cx in remote_rw pop dx ; off s pop es ; seg s pop ax ; cmd (ax) @@ -334,6 +317,12 @@ call_int2f: je remote_rw cmp al, 09h je remote_rw + cmp al, 0ch + je remote_getfree + cmp al, 23h + je qremote_fn + cmp al, 25h + je remote_lseek push cx ; arg int2f_call: @@ -384,18 +373,12 @@ print_doredir: xor cx, cx jmp short clear_ax - global _remote_getfree -_remote_getfree: - push bp - mov bp,sp - push si - push di - mov ax, 110ch - les di, [bp+4] +remote_getfree: clc ; set to succeed + push cx ; pointer arg int 2fh + pop di jc no_clear_ax - mov di,[bp+8] mov [di],ax mov [di+2],bx mov [di+4],cx @@ -414,23 +397,17 @@ int2f_carry: neg ax cwd jmp short no_neg_ax - global _QRemote_Fn -_QRemote_Fn: - push bp - mov bp,sp - push si - push di +qremote_fn: push ds - mov ax, 1123h - les di, [bp+4] - lds si,[bp+8] + mov bx, cx + lds si, [bx] clc int 2fh pop ds mov ax,0xffff jc no_neg_ax xor cx, cx - jmp clear_ax + jmp short clear_ax global _remote_process_end _remote_process_end: ; Terminate process @@ -494,77 +471,6 @@ nostore: pop bp ret -%if 0 -; int_2f_111e_call(iregs FAR *iregs) -; -; set up all registers to the int21 entry registers -; call int2f/111e -; copy returned registers into int21 entry registers back -; -; disabled: does not work better than previous implementation - global _int_2f_111e_call -_int_2f_111e_call: - - push bp - mov bp,sp - push si - push di - push ds - - lds si, [bp+4] ; ds:si -> iregs - - mov ax, [si ] - mov bx, [si+2] - mov cx, [si+4] - mov dx, [si+6] - push word [si+8] ; si - mov di, [si+10] - mov bp, [si+12] - mov es, [si+16] - mov ds, [si+14] - pop si - - push ax - mov ax, 111eh - int 2fh - jc fault - pop ax ; restore orig value of ax if no errors - push ax -fault: - - pushf - push ds - push si - push bp - - mov bp,sp - lds si,[bp+4+6+10] ; 4=fun, 6=si,di,ds, 10 additional bytes on stack - - pop word [si+12] ; bp - pop word [si+ 8] ; si - pop word [si+14] ; ds - pop word [si+22] ; flags - add sp,2 ; pushed function value - - mov [si ],ax - - cmp ax, 5f02h ; 5f02 is special: it manipulates the user stack directly - je skip5f02 - mov [si+2],bx - mov [si+4],cx -skip5f02: - - mov [si+6],dx - mov [si+10],di - mov [si+16],es - - pop ds - pop di - pop si - pop bp - ret -%endif - ; ; Test to see if a umb driver has been loaded. ; if so, retrieve largest available block+size diff --git a/kernel/proto.h b/kernel/proto.h index 68dae7e4..d7416c9e 100644 --- a/kernel/proto.h +++ b/kernel/proto.h @@ -381,17 +381,17 @@ COUNT truename(const char FAR * src, char * dest, COUNT t); /* network.c */ int network_redirector(unsigned cmd); int network_redirector_fp(unsigned cmd, void far *s); -long ASMPASCAL network_redirector_mx(unsigned cmd, void far *s, unsigned arg); +long ASMPASCAL network_redirector_mx(unsigned cmd, void far *s, void *arg); COUNT ASMCFUNC remote_doredirect(UWORD b, UCOUNT n, UWORD d, VOID FAR * s, UWORD i, VOID FAR * data); COUNT ASMCFUNC remote_printset(UWORD b, UCOUNT n, UWORD d, VOID FAR * s, UWORD i, VOID FAR * data); COUNT ASMCFUNC remote_process_end(VOID); -COUNT ASMCFUNC remote_getfree(VOID FAR * s, VOID * d); -LONG ASMCFUNC remote_lseek(sft FAR * s, LONG new_pos); -COUNT ASMCFUNC remote_setfattr(COUNT attr); +#define remote_getfree(s,d) (int)network_redirector_mx(REM_GETSPACE, s, d) +#define remote_lseek(s,new_pos) network_redirector_mx(REM_LSEEK, s, &new_pos) +#define remote_setfattr(attr) (int)network_redirector_mx(REM_SETATTR, NULL, (void *)attr) COUNT ASMCFUNC remote_printredir(UCOUNT dx, UCOUNT ax); -COUNT ASMCFUNC QRemote_Fn(char FAR * d, const char FAR * s); +#define QRemote_Fn(d,s) (int)network_redirector_mx(REM_FILENAME, d, &s) UWORD get_machine_name(BYTE FAR * netname); VOID set_machine_name(BYTE FAR * netname, UWORD name_num); From ea23d33c2c3e9926d3887f8f54a14a4bafcb1b31 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Wed, 21 Apr 2004 17:40:12 +0000 Subject: [PATCH 472/671] Reduced number of global int2f/11 entries into int2f.asm to one. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@895 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/dosfns.c | 22 ++++++++-- kernel/int2f.asm | 107 ++++++++++++++++------------------------------ kernel/inthndlr.c | 12 +----- kernel/network.c | 1 + kernel/proto.h | 7 +-- 5 files changed, 60 insertions(+), 89 deletions(-) diff --git a/kernel/dosfns.c b/kernel/dosfns.c index 787fd8e1..51bfc847 100644 --- a/kernel/dosfns.c +++ b/kernel/dosfns.c @@ -88,8 +88,7 @@ extern int ASMPASCAL /* /// End of additions for SHARE. - Ron Cemer */ -extern int ASMCFUNC - remote_lock_unlock(sft FAR *sftp, /* SFT for file */ +STATIC int remote_lock_unlock(sft FAR *sftp, /* SFT for file */ unsigned long ofs, /* offset into file */ unsigned long len, /* length (in bytes) of region to lock or unlock */ int unlock); /* one to unlock; zero to lock */ @@ -908,7 +907,8 @@ COUNT DosGetExtFree(BYTE FAR * DriveString, struct xfreespace FAR * xfsp) if (cdsp->cdsFlags & CDSNETWDRV) { - remote_getfree(cdsp, rg); + if (remote_getfree(cdsp, rg) != SUCCESS) + return DE_INVLDDRV; xfsp->xfs_clussize = rg[0]; xfsp->xfs_totalclusters = rg[1]; @@ -1467,3 +1467,19 @@ COUNT DosTruename(const char FAR *src, char FAR *dest) return rc; } +STATIC int remote_lock_unlock(sft FAR *sftp, /* SFT for file */ + unsigned long ofs, /* offset into file */ + unsigned long len, /* length (in bytes) of region to lock or unlock */ + int unlock) + /* one to unlock; zero to lock */ +{ + struct + { + unsigned long ofs, len; + int unlock; + } param_block; + param_block.ofs = ofs; + param_block.len = len; + param_block.unlock = unlock; + return (int)network_redirector_mx(REM_LOCK, sftp, ¶m_block); +} diff --git a/kernel/int2f.asm b/kernel/int2f.asm index 07d2e414..d257dfa4 100644 --- a/kernel/int2f.asm +++ b/kernel/int2f.asm @@ -273,17 +273,6 @@ SHARE_LOCK_UNLOCK: ; sumtimes return data *ptr is the push stack word ; - global _remote_printredir -_remote_printredir: - push bp - mov bp,sp - push si - push di - mov ax, 1125h - mov dx, [bp+4] - push word [bp+6] - jmp short int2f_call - remote_lseek: ; arg is a pointer to the long seek value mov bx, cx mov dx, [bx] @@ -296,6 +285,17 @@ remote_getfattr: jc no_clear_ax jmp short no_neg_ax +remote_lock_unlock: + mov dx, cx ; parameter block (dx) in arg + mov bx, cx + mov bl, [bx + 8] ; unlock or not + mov cx, 1 + int 0x2f + mov ah, 0 + jc lock_error + mov al, 0 +lock_error: jmp no_clear_ax + ;long ASMPASCAL network_redirector_mx(unsigned cmd, void far *s, void *arg) global NETWORK_REDIRECTOR_MX NETWORK_REDIRECTOR_MX: @@ -317,13 +317,22 @@ call_int2f: je remote_rw cmp al, 09h je remote_rw - cmp al, 0ch - je remote_getfree + cmp al, 0ah + je remote_lock_unlock + cmp al, 21h + je remote_lseek + cmp al, 22h + je remote_process_end cmp al, 23h je qremote_fn - cmp al, 25h - je remote_lseek + push cx ; arg + cmp al, 0ch + je remote_getfree + cmp al, 1eh + je remote_print_doredir + cmp al, 1fh + je remote_print_doredir int2f_call: xor cx, cx ; set to succeed; clear carry and CX @@ -342,32 +351,18 @@ no_neg_ax: pop bp ret - global _remote_doredirect -_remote_doredirect: - mov al, 1eh - jmp short print_doredir +remote_print_doredir: ; di points to an lregs structure + mov es,[di+0xe] + mov bx,[di+2] + mov cx,[di+4] + mov dx,[di+6] + mov si,[di+8] + lds di,[di+0xa] - global _remote_printset -_remote_printset: - mov al, 1fh -print_doredir: - push bp - mov bp,sp - push si - push di - push ds - mov ah, 11h - mov si,[bp+14] - les di,[bp+10] - mov dx,[bp+8] - mov cx,[bp+6] - mov bx,[bp+4] - - mov ds, [bp+18] - push word [bp+16] ; very fakey, HaHa ;) clc ; set to succeed int 2fh - pop bx + pop bx ; restore stack and ds=ss + push ss pop ds jc no_clear_ax xor cx, cx @@ -375,9 +370,8 @@ print_doredir: remote_getfree: clc ; set to succeed - push cx ; pointer arg int 2fh - pop di + pop di ; retrieve pushed pointer arg jc no_clear_ax mov [di],ax mov [di+2],bx @@ -409,39 +403,12 @@ qremote_fn: xor cx, cx jmp short clear_ax - global _remote_process_end -_remote_process_end: ; Terminate process +remote_process_end: ; Terminate process mov ds, [_cu_psp] - mov ax, 1122h - call call_int2f + int 2fh push ss pop ds - ret - -;STATIC int ASMCFUNC remote_lock_unlock(sft FAR *sftp, /* SFT for file */ -; unsigned long ofs, /* offset into file */ -; unsigned long len, /* length (in bytes) of region to lock or unlock */ -; int unlock) -; one to unlock; zero to lock - global _remote_lock_unlock -_remote_lock_unlock: - push bp - mov bp, sp - push di - les di, [bp + 4] ; sftp - lea dx, [bp + 8] ; parameter block on the stack! - mov bl, [bp + 16] ; unlock - mov ax, 0x110a - mov cx, 1 - int 0x2f - mov ah, 0 - jc lock_error - mov al, 0 -lock_error: - neg al - pop di - pop bp - ret + jmp short no_neg_ax ; extern UWORD ASMCFUNC call_nls(UWORD subfct, struct nlsInfoBlock *nlsinfo, ; UWORD bp, UWORD cp, UWORD cntry, UWORD bufsize, UWORD FAR *buf, UWORD *id); diff --git a/kernel/inthndlr.c b/kernel/inthndlr.c index fa57db2f..055f3d86 100644 --- a/kernel/inthndlr.c +++ b/kernel/inthndlr.c @@ -1326,8 +1326,7 @@ VOID ASMCFUNC int21_service(iregs FAR * r) break; default: - rc = remote_printset(lr.BX, lr.CX, lr.DX, (FP_ES_DI), - lr.SI, (MK_FP(lr.DS, Int21AX))); + rc = (int)network_redirector_mx(REM_PRINTSET, &lr, (void *)Int21AX); if (rc != SUCCESS) goto error_exit; lr.AX = SUCCESS; @@ -1359,14 +1358,7 @@ VOID ASMCFUNC int21_service(iregs FAR * r) } else { -/* - void int_2f_111e_call(iregs FAR *r); - int_2f_111e_call(r); - break;*/ - - rc = remote_doredirect(lr.BX, lr.CX, lr.DX, - (FP_ES_DI), lr.SI, - (MK_FP(lr.DS, Int21AX))); + rc = (int)network_redirector_mx(REM_DOREDIRECT, &lr, (void *)Int21AX); /* the remote function manipulates *r directly !, so we should not copy lr to r here */ if (rc != SUCCESS) diff --git a/kernel/network.c b/kernel/network.c index 5004243e..a29e6ac3 100644 --- a/kernel/network.c +++ b/kernel/network.c @@ -60,3 +60,4 @@ int network_redirector(unsigned cmd) { return network_redirector_fp(cmd, NULL); } + diff --git a/kernel/proto.h b/kernel/proto.h index d7416c9e..0a2b5d3d 100644 --- a/kernel/proto.h +++ b/kernel/proto.h @@ -382,15 +382,10 @@ COUNT truename(const char FAR * src, char * dest, COUNT t); int network_redirector(unsigned cmd); int network_redirector_fp(unsigned cmd, void far *s); long ASMPASCAL network_redirector_mx(unsigned cmd, void far *s, void *arg); -COUNT ASMCFUNC remote_doredirect(UWORD b, UCOUNT n, UWORD d, VOID FAR * s, - UWORD i, VOID FAR * data); -COUNT ASMCFUNC remote_printset(UWORD b, UCOUNT n, UWORD d, VOID FAR * s, - UWORD i, VOID FAR * data); -COUNT ASMCFUNC remote_process_end(VOID); #define remote_getfree(s,d) (int)network_redirector_mx(REM_GETSPACE, s, d) #define remote_lseek(s,new_pos) network_redirector_mx(REM_LSEEK, s, &new_pos) #define remote_setfattr(attr) (int)network_redirector_mx(REM_SETATTR, NULL, (void *)attr) -COUNT ASMCFUNC remote_printredir(UCOUNT dx, UCOUNT ax); +#define remote_printredir(dx,ax) (int)network_redirector_mx(REM_PRINTREDIR, MK_FP(0,dx),(void *)ax) #define QRemote_Fn(d,s) (int)network_redirector_mx(REM_FILENAME, d, &s) UWORD get_machine_name(BYTE FAR * netname); From 2fcbfdb271d371736936dce8022dcfe32006e7f3 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sat, 24 Apr 2004 15:09:34 +0000 Subject: [PATCH 473/671] kernel.asm optimizations from Arkady git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@896 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/kernel.asm | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/kernel/kernel.asm b/kernel/kernel.asm index 3a85a89d..fe01dd56 100644 --- a/kernel/kernel.asm +++ b/kernel/kernel.asm @@ -123,7 +123,7 @@ kernel_start: mov sp,init_tos int 12h ; move init text+data to higher memory mov cl,6 - shl ax,cl + shl ax,cl ; convert kb to para mov dx,15 + init_end wrt INIT_TEXT mov cl,4 shr dx,cl @@ -136,35 +136,27 @@ kernel_start: sti ; now enable them mov ax,cs mov dx,__InitTextStart wrt HMA_TEXT ; para aligned + shr dx,cl %ifdef WATCOM - mov si,dx - mov cl,4 - shr si,cl - add ax,si + add ax,dx %endif mov ds,ax - mov cx,-2 + init_end wrt INIT_TEXT ; word aligned - mov si,cx - mov di,cx + mov si,-2 + init_end wrt INIT_TEXT ; word aligned + lea cx,[si+2] + mov di,si shr cx,1 - inc cx std ; if there's overlap only std is safe rep movsw ; move HMA_TEXT to higher memory - mov si,dx ; si = __InitTextStart wrt HMA_TEXT - mov cl,4 - shr dx,cl - sub ax,dx mov ds,ax ; ds = HMA_TEXT mov ax,es sub ax,dx mov es,ax ; es = new HMA_TEXT - mov cx,si ; cx = __InitTextStart wrt HMA_TEXT - dec si - dec si + mov si,-2 + __InitTextStart wrt HMA_TEXT + lea cx,[si+2] mov di,si shr cx,1 rep movsw From 3227b87d5d720b675cc370e032b6cee543566ccc Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sat, 24 Apr 2004 15:14:43 +0000 Subject: [PATCH 474/671] (Arkady) Make signon one big printf function call. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@897 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/main.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/kernel/main.c b/kernel/main.c index 43178a18..1f3c135d 100644 --- a/kernel/main.c +++ b/kernel/main.c @@ -363,11 +363,8 @@ STATIC VOID FsConfig(VOID) STATIC VOID signon() { - printf("\r%S", MK_FP(FP_SEG(LoL), FP_OFF(LoL->os_release))); - - printf("Kernel compatibility %d.%d - ", MAJOR_RELEASE, MINOR_RELEASE); - - printf( + printf("\r%S" + "Kernel compatibility %d.%d - " #if defined(__BORLANDC__) "BORLANDC" #elif defined(__TURBOC__) @@ -391,7 +388,9 @@ STATIC VOID signon() #ifdef WITHFAT32 " - FAT32 support" #endif - "\n\n%S", (void FAR *)copyright); + "\n\n%S", + MK_FP(FP_SEG(LoL), FP_OFF(LoL->os_release)), + MAJOR_RELEASE, MINOR_RELEASE, copyright); } STATIC void kernel() From 490a27b8575dc44e0ef5b842506eee5ace3d2848 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sat, 24 Apr 2004 15:53:21 +0000 Subject: [PATCH 475/671] Some of Arkady's fattab optimizations -- the others only increase the kernel size for Watcom. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@898 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/fattab.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/kernel/fattab.c b/kernel/fattab.c index 66698d45..327b37bb 100644 --- a/kernel/fattab.c +++ b/kernel/fattab.c @@ -145,9 +145,9 @@ void write_fsinfo(struct dpb FAR * dpbp) /* */ /* The FAT file system is difficult to trace through FAT table. */ /* There are two kinds of FAT's, 12 bit and 16 bit. The 16 bit */ -/* FAT is the easiest, since it is noting more than a series of */ -/* UWORD's. The 12 bit FAT is difficult, because it packs 3 FAT */ -/* entries into two BYTE's. The are packed as follows: */ +/* FAT is the easiest, since it is nothing more than a series */ +/* of UWORD's. The 12 bit FAT is difficult, because it packs 3 */ +/* FAT entries into two BYTE's. These are packed as follows: */ /* */ /* 0x0003 0x0004 0x0005 0x0006 0x0007 0x0008 0x0009 ... */ /* */ @@ -177,9 +177,8 @@ unsigned link_fat(struct dpb FAR * dpbp, CLUSTER Cluster1, /* form an index so that we can read the block as a */ /* byte array */ - idx = (unsigned) ((((unsigned)Cluster1 << 1) + (unsigned)Cluster1) >> 1) - % dpbp->dpb_secsize; - + idx = (((unsigned)Cluster1 << 1) + (unsigned)Cluster1) % dpbp->dpb_secsize; + /* Test to see if the cluster straddles the block. If */ /* it does, get the next block and use both to form the */ /* the FAT word. Otherwise, just point to the next */ @@ -201,13 +200,13 @@ unsigned link_fat(struct dpb FAR * dpbp, CLUSTER Cluster1, /* Now pack the value in */ if ((unsigned)Cluster1 & 0x01) { - *fbp0 = (*fbp0 & 0x0f) | (((UBYTE)Cluster2 & 0x0f) << 4); + *fbp0 = (*fbp0 & 0x0f) | (UBYTE)((UBYTE)Cluster2 << 4); *fbp1 = (UBYTE)((unsigned)Cluster2 >> 4); } else { *fbp0 = (UBYTE)Cluster2; - *fbp1 = (*fbp1 & 0xf0) | ((UBYTE)((unsigned)Cluster2 >> 8) & 0x0f); + *fbp1 = (*fbp1 & 0xf0) | (UBYTE)((unsigned)Cluster2 >> 8); } } else if (ISFAT16(dpbp)) From 6f7b41e25702be884d687a0ae3b5e9171d04d536 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sat, 24 Apr 2004 16:02:39 +0000 Subject: [PATCH 476/671] Fixed silly mistake in cluster index calculation. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@899 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/fattab.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/fattab.c b/kernel/fattab.c index 327b37bb..8e00e0fa 100644 --- a/kernel/fattab.c +++ b/kernel/fattab.c @@ -177,7 +177,7 @@ unsigned link_fat(struct dpb FAR * dpbp, CLUSTER Cluster1, /* form an index so that we can read the block as a */ /* byte array */ - idx = (((unsigned)Cluster1 << 1) + (unsigned)Cluster1) % dpbp->dpb_secsize; + idx = (((unsigned)Cluster1 >> 1) + (unsigned)Cluster1) % dpbp->dpb_secsize; /* Test to see if the cluster straddles the block. If */ /* it does, get the next block and use both to form the */ @@ -294,7 +294,7 @@ CLUSTER next_cluster(struct dpb FAR * dpbp, CLUSTER ClusterNum) /* form an index so that we can read the block as a */ /* byte array */ - idx = ((((unsigned)ClusterNum << 1) + (unsigned)ClusterNum) >> 1) % + idx = (((unsigned)ClusterNum >> 1) + (unsigned)ClusterNum) % dpbp->dpb_secsize; clusterbuff.bytes[0] = bp->b_buffer[idx]; From 935181421cb86328c57889c260c1921d8adbcc83 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sun, 25 Apr 2004 10:11:29 +0000 Subject: [PATCH 477/671] "copyright" is near now so we have to use %s and not %S git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@900 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/main.c b/kernel/main.c index 1f3c135d..a62b5a70 100644 --- a/kernel/main.c +++ b/kernel/main.c @@ -388,7 +388,7 @@ STATIC VOID signon() #ifdef WITHFAT32 " - FAT32 support" #endif - "\n\n%S", + "\n\n%s", MK_FP(FP_SEG(LoL), FP_OFF(LoL->os_release)), MAJOR_RELEASE, MINOR_RELEASE, copyright); } From 82e66852ee96249ffc010049c16052f9154f4ad6 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Mon, 26 Apr 2004 09:46:44 +0000 Subject: [PATCH 478/671] Config.cfgInitTail is a pointer now so sizeof isn't good. Just using strcpy helps F5 and F8. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@901 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/main.c b/kernel/main.c index a62b5a70..f9ffc384 100644 --- a/kernel/main.c +++ b/kernel/main.c @@ -404,7 +404,7 @@ STATIC void kernel() /* process 0 */ /* Execute command.com from the drive we just booted from */ memset(Cmd.ctBuffer, 0, sizeof(Cmd.ctBuffer)); - memcpy(Cmd.ctBuffer, Config.cfgInitTail, sizeof(Config.cfgInitTail)); + strcpy(Cmd.ctBuffer, Config.cfgInitTail); for (Cmd.ctCount = 0; Cmd.ctCount < sizeof(Cmd.ctBuffer); Cmd.ctCount++) if (Cmd.ctBuffer[Cmd.ctCount] == '\r') From bb7f10fafca307b5c1787bee44e710d5d1eae95e Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Mon, 26 Apr 2004 21:23:26 +0000 Subject: [PATCH 479/671] Reverted bad optimization -- (unsigned)Cluster2 may have the high 4 bits set with LONG_LAST_CLUSTER. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@902 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/fattab.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/kernel/fattab.c b/kernel/fattab.c index 8e00e0fa..f2cc0cdd 100644 --- a/kernel/fattab.c +++ b/kernel/fattab.c @@ -206,7 +206,9 @@ unsigned link_fat(struct dpb FAR * dpbp, CLUSTER Cluster1, else { *fbp0 = (UBYTE)Cluster2; - *fbp1 = (*fbp1 & 0xf0) | (UBYTE)((unsigned)Cluster2 >> 8); + /* Cluster2 may be set to LONG_LAST_CLUSTER == 0x0FFFFFFFUL or 0xFFFF */ + /* -- please don't optimize to (UBYTE)((unsigned)Cluster2 >> 8)! */ + *fbp1 = (*fbp1 & 0xf0) | ((UBYTE)((unsigned)Cluster2 >> 8) & 0x0f); } } else if (ISFAT16(dpbp)) From 0afa77330331048fc37a6a6d92c8ca74671573ec Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Tue, 27 Apr 2004 00:40:43 +0000 Subject: [PATCH 480/671] From Lucho: HMAFree == 0xfff0 - bytesToAllocate is valid and may happen if the buffers occupy exactly all HMA space up to and including the last byte at ffff:ffff. Failing caused all buffers to go low ... git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@903 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/inithma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/inithma.c b/kernel/inithma.c index 4c16f272..34b39932 100644 --- a/kernel/inithma.c +++ b/kernel/inithma.c @@ -282,7 +282,7 @@ VOID FAR * HMAalloc(COUNT bytesToAllocate) if (!DosLoadedInHMA) return NULL; - if (HMAFree >= 0xfff0 - bytesToAllocate) + if (HMAFree > 0xfff0 - bytesToAllocate) return NULL; HMAptr = MK_FP(0xffff, HMAFree); From f6716cd74b40030c04352bb10bb6574f76937e9a Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Thu, 29 Apr 2004 12:28:14 +0000 Subject: [PATCH 481/671] "clussec" can be of CLUSTER size if we divide by an adjusted "words per sector"(FAT16), or "dwords per sector"(FAT32) value instead of multiplying it first. For FAT12 the *3/2 works out a little differently: here we first multiply by 3 and then divide by the number of "nibbles per sector". git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@904 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/fattab.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/kernel/fattab.c b/kernel/fattab.c index f2cc0cdd..4940fa88 100644 --- a/kernel/fattab.c +++ b/kernel/fattab.c @@ -47,8 +47,9 @@ int ISFAT32(struct dpb FAR * dpbp) } #endif -struct buffer FAR *getFATblock(ULONG clussec, struct dpb FAR * dpbp) +struct buffer FAR *getFATblock(CLUSTER clussec, struct dpb FAR * dpbp) { + unsigned secdiv; struct buffer FAR *bp; CLUSTER max_cluster = dpbp->dpb_size; @@ -68,21 +69,22 @@ struct buffer FAR *getFATblock(ULONG clussec, struct dpb FAR * dpbp) return NULL; } + secdiv = dpbp->dpb_secsize; if (ISFAT12(dpbp)) { - clussec = (((unsigned)clussec << 1) + (unsigned)clussec) >> 1; + clussec = (unsigned)clussec * 3; + secdiv *= 2; } -#ifdef WITHFAT32 - else if (ISFAT32(dpbp)) + else /* FAT16 or FAT32 */ { - clussec = clussec * SIZEOF_CLST32; - } + secdiv /= 2; +#ifdef WITHFAT32 + if (ISFAT32(dpbp)) + secdiv /= 2; #endif - else - { - clussec = clussec * SIZEOF_CLST16; } - clussec = clussec / dpbp->dpb_secsize + dpbp->dpb_fatstrt; + clussec /= secdiv; + clussec += dpbp->dpb_fatstrt; #ifdef WITHFAT32 if (ISFAT32(dpbp) && (dpbp->dpb_xflags & FAT_NO_MIRRORING)) { From 115b2bf68dd205671d4edc8ecfa35cc6fe7b9b5f Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Thu, 29 Apr 2004 12:48:18 +0000 Subject: [PATCH 482/671] Calculate the nibble/word/dword index of the FAT entry in the sector centrally in getFATblock. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@905 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/fattab.c | 40 +++++++++++++++++++--------------------- 1 file changed, 19 insertions(+), 21 deletions(-) diff --git a/kernel/fattab.c b/kernel/fattab.c index 4940fa88..aae7245b 100644 --- a/kernel/fattab.c +++ b/kernel/fattab.c @@ -47,7 +47,11 @@ int ISFAT32(struct dpb FAR * dpbp) } #endif -struct buffer FAR *getFATblock(CLUSTER clussec, struct dpb FAR * dpbp) +/* idx is a pointer to an index which is the nibble offset of the FAT + entry within the sector for FAT12, or word offset for FAT16, or + dword offset for FAT32 */ +struct buffer FAR *getFATblock(CLUSTER clussec, struct dpb FAR * dpbp, + unsigned *idx) { unsigned secdiv; struct buffer FAR *bp; @@ -83,6 +87,8 @@ struct buffer FAR *getFATblock(CLUSTER clussec, struct dpb FAR * dpbp) secdiv /= 2; #endif } + if (idx) + *idx = (unsigned)(clussec % secdiv); clussec /= secdiv; clussec += dpbp->dpb_fatstrt; #ifdef WITHFAT32 @@ -164,22 +170,22 @@ unsigned link_fat(struct dpb FAR * dpbp, CLUSTER Cluster1, REG CLUSTER Cluster2) { struct buffer FAR *bp; + unsigned idx; /* Get the block that this cluster is in */ - bp = getFATblock(Cluster1, dpbp); + bp = getFATblock(Cluster1, dpbp, &idx); if (bp == NULL) return DE_BLKINVLD; if (ISFAT12(dpbp)) { - unsigned idx; REG UBYTE FAR *fbp0, FAR * fbp1; struct buffer FAR * bp1; /* form an index so that we can read the block as a */ /* byte array */ - idx = (((unsigned)Cluster1 >> 1) + (unsigned)Cluster1) % dpbp->dpb_secsize; + idx /= 2; /* Test to see if the cluster straddles the block. If */ /* it does, get the next block and use both to form the */ @@ -190,7 +196,7 @@ unsigned link_fat(struct dpb FAR * dpbp, CLUSTER Cluster1, if (idx >= (unsigned)dpbp->dpb_secsize - 1) { - bp1 = getFATblock((unsigned)Cluster1 + 1, dpbp); + bp1 = getFATblock((unsigned)Cluster1 + 1, dpbp, NULL); if (bp1 == 0) return DE_BLKINVLD; @@ -219,9 +225,7 @@ unsigned link_fat(struct dpb FAR * dpbp, CLUSTER Cluster1, /* byte array */ /* Finally, put the word into the buffer and mark the */ /* buffer as dirty. */ - fputword( - &bp->b_buffer[((unsigned)Cluster1 * SIZEOF_CLST16) % dpbp->dpb_secsize], - (UWORD)Cluster2); + fputword(&bp->b_buffer[idx * 2], (UWORD)Cluster2); } #ifdef WITHFAT32 else if (ISFAT32(dpbp)) @@ -230,9 +234,7 @@ unsigned link_fat(struct dpb FAR * dpbp, CLUSTER Cluster1, /* byte array */ /* Finally, put the word into the buffer and mark the */ /* buffer as dirty. */ - fputlong( - &bp->b_buffer[(UWORD) ((Cluster1 * SIZEOF_CLST32) % dpbp->dpb_secsize)], - Cluster2); + fputlong(&bp->b_buffer[idx * 4], Cluster2); } #endif else @@ -280,9 +282,10 @@ unsigned link_fat(struct dpb FAR * dpbp, CLUSTER Cluster1, CLUSTER next_cluster(struct dpb FAR * dpbp, CLUSTER ClusterNum) { struct buffer FAR *bp; + unsigned idx; /* Get the block that this cluster is in */ - bp = getFATblock(ClusterNum, dpbp); + bp = getFATblock(ClusterNum, dpbp, &idx); if (bp == NULL) return 1; /* the only error code possible here */ @@ -294,12 +297,9 @@ CLUSTER next_cluster(struct dpb FAR * dpbp, CLUSTER ClusterNum) unsigned word; } clusterbuff; - unsigned idx; - /* form an index so that we can read the block as a */ /* byte array */ - idx = (((unsigned)ClusterNum >> 1) + (unsigned)ClusterNum) % - dpbp->dpb_secsize; + idx /= 2; clusterbuff.bytes[0] = bp->b_buffer[idx]; @@ -312,7 +312,7 @@ CLUSTER next_cluster(struct dpb FAR * dpbp, CLUSTER ClusterNum) /* block. */ if (idx >= (unsigned)dpbp->dpb_secsize - 1) { - bp = getFATblock(ClusterNum + 1, dpbp); + bp = getFATblock(ClusterNum + 1, dpbp, NULL); if (bp == 0) return LONG_BAD; @@ -351,8 +351,7 @@ CLUSTER next_cluster(struct dpb FAR * dpbp, CLUSTER ClusterNum) /* byte array */ /* and get the cluster number */ - res = fgetword(&bp->b_buffer[((unsigned)ClusterNum * SIZEOF_CLST16) % - dpbp->dpb_secsize]); + res = fgetword(&bp->b_buffer[idx * 2]); if (res >= MASK16) return LONG_LAST_CLUSTER; @@ -366,8 +365,7 @@ CLUSTER next_cluster(struct dpb FAR * dpbp, CLUSTER ClusterNum) { UDWORD res; - res = fgetlong(&bp->b_buffer[((unsigned)ClusterNum * SIZEOF_CLST32) % - dpbp->dpb_secsize]); + res = fgetlong(&bp->b_buffer[idx * 4]); if (res > LONG_BAD) return LONG_LAST_CLUSTER; From bfe9252c2bed951e197c35225913978140bf3e3b Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Fri, 30 Apr 2004 13:07:26 +0000 Subject: [PATCH 483/671] Merged next_cluster and link_fat into one function depending on a special Cluster2 value. More optimizations later. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@906 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/fattab.c | 164 +++++++++++++++++++----------------------------- 1 file changed, 66 insertions(+), 98 deletions(-) diff --git a/kernel/fattab.c b/kernel/fattab.c index aae7245b..afcd37a4 100644 --- a/kernel/fattab.c +++ b/kernel/fattab.c @@ -40,6 +40,10 @@ static BYTE *RcsId = /* */ /************************************************************************/ +/* special "impossible" "Cluster2" value of 1 denotes reading the + cluster number rather than overwriting it */ +#define READ_CLUSTER 1 + #ifndef ISFAT32 int ISFAT32(struct dpb FAR * dpbp) { @@ -166,8 +170,8 @@ void write_fsinfo(struct dpb FAR * dpbp) /* 12 bytes are compressed to 9 bytes */ /* */ -unsigned link_fat(struct dpb FAR * dpbp, CLUSTER Cluster1, - REG CLUSTER Cluster2) +CLUSTER link_fat(struct dpb FAR * dpbp, CLUSTER Cluster1, + REG CLUSTER Cluster2) { struct buffer FAR *bp; unsigned idx; @@ -176,12 +180,16 @@ unsigned link_fat(struct dpb FAR * dpbp, CLUSTER Cluster1, bp = getFATblock(Cluster1, dpbp, &idx); if (bp == NULL) - return DE_BLKINVLD; + return 1; /* the only error code possible here */ if (ISFAT12(dpbp)) { REG UBYTE FAR *fbp0, FAR * fbp1; struct buffer FAR * bp1; + union { + UBYTE bytes[2]; + unsigned word; + } clusterbuff; /* form an index so that we can read the block as a */ /* byte array */ @@ -191,6 +199,10 @@ unsigned link_fat(struct dpb FAR * dpbp, CLUSTER Cluster1, /* it does, get the next block and use both to form the */ /* the FAT word. Otherwise, just point to the next */ /* block. */ + clusterbuff.bytes[0] = bp->b_buffer[idx]; + + /* next byte, will be overwritten, if not valid */ + clusterbuff.bytes[1] = bp->b_buffer[idx + 1]; fbp0 = &bp->b_buffer[idx]; fbp1 = fbp0 + 1; @@ -198,11 +210,39 @@ unsigned link_fat(struct dpb FAR * dpbp, CLUSTER Cluster1, { bp1 = getFATblock((unsigned)Cluster1 + 1, dpbp, NULL); if (bp1 == 0) - return DE_BLKINVLD; + return 1; /* the only error code possible here */ - bp1->b_flag |= BFR_DIRTY | BFR_VALID; + if (Cluster2 != READ_CLUSTER) + bp1->b_flag |= BFR_DIRTY | BFR_VALID; fbp1 = &bp1->b_buffer[0]; + clusterbuff.bytes[1] = bp1->b_buffer[0]; + } + + if (Cluster2 == READ_CLUSTER) + { + /* Now to unpack the contents of the FAT entry. Odd and */ + /* even bytes are packed differently. */ + +#ifndef I86 /* the latter assumes byte ordering */ + if (Cluster1 & 0x01) + idx = + ((clusterbuff.bytes[0] & 0xf0) >> 4) | (clusterbuff.bytes[1] << 4); + else + idx = clusterbuff.bytes[0] | ((clusterbuff.bytes[1] & 0x0f) << 8); +#else + + if (Cluster1 & 0x01) + idx = (unsigned short)clusterbuff.word >> 4; + else + idx = clusterbuff.word & 0x0fff; +#endif + + if (idx >= MASK12) + return LONG_LAST_CLUSTER; + if (idx == BAD12) + return LONG_BAD; + return idx; } /* Now pack the value in */ @@ -223,6 +263,17 @@ unsigned link_fat(struct dpb FAR * dpbp, CLUSTER Cluster1, { /* form an index so that we can read the block as a */ /* byte array */ + if (Cluster2 == READ_CLUSTER) + { + /* and get the cluster number */ + UWORD res = fgetword(&bp->b_buffer[idx * 2]); + if (res >= MASK16) + return LONG_LAST_CLUSTER; + if (res == BAD16) + return LONG_BAD; + + return res; + } /* Finally, put the word into the buffer and mark the */ /* buffer as dirty. */ fputword(&bp->b_buffer[idx * 2], (UWORD)Cluster2); @@ -232,13 +283,21 @@ unsigned link_fat(struct dpb FAR * dpbp, CLUSTER Cluster1, { /* form an index so that we can read the block as a */ /* byte array */ + if (Cluster2 == READ_CLUSTER) + { + UDWORD res = fgetlong(&bp->b_buffer[idx * 4]); + if (res > LONG_BAD) + return LONG_LAST_CLUSTER; + + return res; + } /* Finally, put the word into the buffer and mark the */ /* buffer as dirty. */ fputlong(&bp->b_buffer[idx * 4], Cluster2); } #endif else - return DE_BLKINVLD; + return 1; /* update the free space count */ bp->b_flag |= BFR_DIRTY | BFR_VALID; @@ -281,97 +340,6 @@ unsigned link_fat(struct dpb FAR * dpbp, CLUSTER Cluster1, looks at the FAT, and returns the next cluster in the clain. */ CLUSTER next_cluster(struct dpb FAR * dpbp, CLUSTER ClusterNum) { - struct buffer FAR *bp; - unsigned idx; - - /* Get the block that this cluster is in */ - bp = getFATblock(ClusterNum, dpbp, &idx); - - if (bp == NULL) - return 1; /* the only error code possible here */ - - if (ISFAT12(dpbp)) - { - union { - UBYTE bytes[2]; - unsigned word; - } clusterbuff; - - /* form an index so that we can read the block as a */ - /* byte array */ - idx /= 2; - - clusterbuff.bytes[0] = bp->b_buffer[idx]; - - clusterbuff.bytes[1] = bp->b_buffer[idx + 1]; /* next byte, will be overwritten, - if not valid */ - - /* Test to see if the cluster straddles the block. If it */ - /* does, get the next block and use both to form the */ - /* the FAT word. Otherwise, just point to the next */ - /* block. */ - if (idx >= (unsigned)dpbp->dpb_secsize - 1) - { - bp = getFATblock(ClusterNum + 1, dpbp, NULL); - - if (bp == 0) - return LONG_BAD; - - clusterbuff.bytes[1] = bp->b_buffer[0]; - } - - /* Now to unpack the contents of the FAT entry. Odd and */ - /* even bytes are packed differently. */ - -#ifndef I86 /* the latter assumes byte ordering */ - if (ClusterNum & 0x01) - idx = - ((clusterbuff.bytes[0] & 0xf0) >> 4) | (clusterbuff.bytes[1] << 4); - else - idx = clusterbuff.bytes[0] | ((clusterbuff.bytes[1] & 0x0f) << 8); -#else - - if (ClusterNum & 0x01) - idx = (unsigned short)clusterbuff.word >> 4; - else - idx = clusterbuff.word & 0x0fff; -#endif - - if (idx >= MASK12) - return LONG_LAST_CLUSTER; - if (idx == BAD12) - return LONG_BAD; - return idx; - } - else if (ISFAT16(dpbp)) - { - UWORD res; - - /* form an index so that we can read the block as a */ - /* byte array */ - /* and get the cluster number */ - - res = fgetword(&bp->b_buffer[idx * 2]); - - if (res >= MASK16) - return LONG_LAST_CLUSTER; - if (res == BAD16) - return LONG_BAD; - - return res; - } -#ifdef WITHFAT32 - else if (ISFAT32(dpbp)) - { - UDWORD res; - - res = fgetlong(&bp->b_buffer[idx * 4]); - if (res > LONG_BAD) - return LONG_LAST_CLUSTER; - - return res; - } -#endif - return LONG_LAST_CLUSTER; + return link_fat(dpbp, ClusterNum, READ_CLUSTER); } From 126ef5cec91dfb2579d70b042a4afb94d7c9abe5 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Fri, 30 Apr 2004 14:05:14 +0000 Subject: [PATCH 484/671] Inlined much of getFATblock() into link_fat. Saves the idx reference. The second call (for a FAT12 entry that is divided in two sectors) can be much simpler, no need to recalculate. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@907 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/fattab.c | 108 ++++++++++++++++++++++++------------------------ 1 file changed, 53 insertions(+), 55 deletions(-) diff --git a/kernel/fattab.c b/kernel/fattab.c index afcd37a4..82c698b5 100644 --- a/kernel/fattab.c +++ b/kernel/fattab.c @@ -51,60 +51,9 @@ int ISFAT32(struct dpb FAR * dpbp) } #endif -/* idx is a pointer to an index which is the nibble offset of the FAT - entry within the sector for FAT12, or word offset for FAT16, or - dword offset for FAT32 */ -struct buffer FAR *getFATblock(CLUSTER clussec, struct dpb FAR * dpbp, - unsigned *idx) +struct buffer FAR *getFATblock(struct dpb FAR * dpbp, CLUSTER clussec) { - unsigned secdiv; - struct buffer FAR *bp; - CLUSTER max_cluster = dpbp->dpb_size; - -#ifdef WITHFAT32 - if (ISFAT32(dpbp)) - max_cluster = dpbp->dpb_xsize; -#endif - - if (clussec <= 1 || clussec > max_cluster) - { - put_string("run CHKDSK: trying to access invalid cluster 0x"); -#ifdef WITHFAT32 - put_unsigned((unsigned)(clussec >> 16), 16, 4); -#endif - put_unsigned((unsigned)(clussec & 0xffffu), 16, 4); - put_console('\n'); - return NULL; - } - - secdiv = dpbp->dpb_secsize; - if (ISFAT12(dpbp)) - { - clussec = (unsigned)clussec * 3; - secdiv *= 2; - } - else /* FAT16 or FAT32 */ - { - secdiv /= 2; -#ifdef WITHFAT32 - if (ISFAT32(dpbp)) - secdiv /= 2; -#endif - } - if (idx) - *idx = (unsigned)(clussec % secdiv); - clussec /= secdiv; - clussec += dpbp->dpb_fatstrt; -#ifdef WITHFAT32 - if (ISFAT32(dpbp) && (dpbp->dpb_xflags & FAT_NO_MIRRORING)) - { - /* we must modify the active fat, - it's number is in the 0-3 bits of dpb_xflags */ - clussec += (dpbp->dpb_xflags & 0xf) * dpbp->dpb_xfatsize; - } -#endif - - bp = getblock(clussec, dpbp->dpb_unit); + struct buffer FAR *bp = getblock(clussec, dpbp->dpb_unit); if (bp) { @@ -175,9 +124,58 @@ CLUSTER link_fat(struct dpb FAR * dpbp, CLUSTER Cluster1, { struct buffer FAR *bp; unsigned idx; + unsigned secdiv; + CLUSTER clussec = Cluster1; + CLUSTER max_cluster = dpbp->dpb_size; + +#ifdef WITHFAT32 + if (ISFAT32(dpbp)) + max_cluster = dpbp->dpb_xsize; +#endif + + if (clussec <= 1 || clussec > max_cluster) + { + put_string("run CHKDSK: trying to access invalid cluster 0x"); +#ifdef WITHFAT32 + put_unsigned((unsigned)(clussec >> 16), 16, 4); +#endif + put_unsigned((unsigned)(clussec & 0xffffu), 16, 4); + put_console('\n'); + return NULL; + } + + secdiv = dpbp->dpb_secsize; + if (ISFAT12(dpbp)) + { + clussec = (unsigned)clussec * 3; + secdiv *= 2; + } + else /* FAT16 or FAT32 */ + { + secdiv /= 2; +#ifdef WITHFAT32 + if (ISFAT32(dpbp)) + secdiv /= 2; +#endif + } + + /* idx is a pointer to an index which is the nibble offset of the FAT + entry within the sector for FAT12, or word offset for FAT16, or + dword offset for FAT32 */ + idx = (unsigned)(clussec % secdiv); + clussec /= secdiv; + clussec += dpbp->dpb_fatstrt; +#ifdef WITHFAT32 + if (ISFAT32(dpbp) && (dpbp->dpb_xflags & FAT_NO_MIRRORING)) + { + /* we must modify the active fat, + it's number is in the 0-3 bits of dpb_xflags */ + clussec += (dpbp->dpb_xflags & 0xf) * dpbp->dpb_xfatsize; + } +#endif /* Get the block that this cluster is in */ - bp = getFATblock(Cluster1, dpbp, &idx); + bp = getFATblock(dpbp, clussec); if (bp == NULL) return 1; /* the only error code possible here */ @@ -208,7 +206,7 @@ CLUSTER link_fat(struct dpb FAR * dpbp, CLUSTER Cluster1, if (idx >= (unsigned)dpbp->dpb_secsize - 1) { - bp1 = getFATblock((unsigned)Cluster1 + 1, dpbp, NULL); + bp1 = getFATblock(dpbp, (unsigned)clussec + 1); if (bp1 == 0) return 1; /* the only error code possible here */ From 00e1527fc5aac147bf3c7519c96dff1c6ddc37bc Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Fri, 30 Apr 2004 15:28:18 +0000 Subject: [PATCH 485/671] Clean up FAT12 handling -- there's a portable approach that's small too. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@908 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/fattab.c | 46 ++++++++++++++++++---------------------------- 1 file changed, 18 insertions(+), 28 deletions(-) diff --git a/kernel/fattab.c b/kernel/fattab.c index 82c698b5..8eb8bee3 100644 --- a/kernel/fattab.c +++ b/kernel/fattab.c @@ -184,10 +184,7 @@ CLUSTER link_fat(struct dpb FAR * dpbp, CLUSTER Cluster1, { REG UBYTE FAR *fbp0, FAR * fbp1; struct buffer FAR * bp1; - union { - UBYTE bytes[2]; - unsigned word; - } clusterbuff; + unsigned cluster; /* form an index so that we can read the block as a */ /* byte array */ @@ -197,15 +194,14 @@ CLUSTER link_fat(struct dpb FAR * dpbp, CLUSTER Cluster1, /* it does, get the next block and use both to form the */ /* the FAT word. Otherwise, just point to the next */ /* block. */ - clusterbuff.bytes[0] = bp->b_buffer[idx]; - - /* next byte, will be overwritten, if not valid */ - clusterbuff.bytes[1] = bp->b_buffer[idx + 1]; fbp0 = &bp->b_buffer[idx]; + + /* pointer to next byte, will be overwritten, if not valid */ fbp1 = fbp0 + 1; - + if (idx >= (unsigned)dpbp->dpb_secsize - 1) { + /* blockio.c LRU logic ensures that bp != bp1 */ bp1 = getFATblock(dpbp, (unsigned)clussec + 1); if (bp1 == 0) return 1; /* the only error code possible here */ @@ -214,27 +210,17 @@ CLUSTER link_fat(struct dpb FAR * dpbp, CLUSTER Cluster1, bp1->b_flag |= BFR_DIRTY | BFR_VALID; fbp1 = &bp1->b_buffer[0]; - clusterbuff.bytes[1] = bp1->b_buffer[0]; } + idx = *fbp0 | (*fbp1 << 8); if (Cluster2 == READ_CLUSTER) { /* Now to unpack the contents of the FAT entry. Odd and */ /* even bytes are packed differently. */ -#ifndef I86 /* the latter assumes byte ordering */ if (Cluster1 & 0x01) - idx = - ((clusterbuff.bytes[0] & 0xf0) >> 4) | (clusterbuff.bytes[1] << 4); - else - idx = clusterbuff.bytes[0] | ((clusterbuff.bytes[1] & 0x0f) << 8); -#else - - if (Cluster1 & 0x01) - idx = (unsigned short)clusterbuff.word >> 4; - else - idx = clusterbuff.word & 0x0fff; -#endif + idx >>= 4; + idx &= 0x0fff; if (idx >= MASK12) return LONG_LAST_CLUSTER; @@ -243,19 +229,23 @@ CLUSTER link_fat(struct dpb FAR * dpbp, CLUSTER Cluster1, return idx; } + /* Cluster2 may be set to LONG_LAST_CLUSTER == 0x0FFFFFFFUL or 0xFFFF */ + /* -- please don't remove this mask! */ + cluster = (unsigned)Cluster2 & 0x0fff; + /* Now pack the value in */ if ((unsigned)Cluster1 & 0x01) { - *fbp0 = (*fbp0 & 0x0f) | (UBYTE)((UBYTE)Cluster2 << 4); - *fbp1 = (UBYTE)((unsigned)Cluster2 >> 4); + idx &= 0x000f; + cluster <<= 4; } else { - *fbp0 = (UBYTE)Cluster2; - /* Cluster2 may be set to LONG_LAST_CLUSTER == 0x0FFFFFFFUL or 0xFFFF */ - /* -- please don't optimize to (UBYTE)((unsigned)Cluster2 >> 8)! */ - *fbp1 = (*fbp1 & 0xf0) | ((UBYTE)((unsigned)Cluster2 >> 8) & 0x0f); + idx &= 0xf000; } + cluster |= idx; + *fbp0 = (UBYTE)cluster; + *fbp1 = (UBYTE)(cluster >> 8); } else if (ISFAT16(dpbp)) { From 9cbede2ec91c2ad756e0f1628594bae3e8963279 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Fri, 30 Apr 2004 16:49:34 +0000 Subject: [PATCH 486/671] Stop abusing "idx". The OW optimizer likes this better, too. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@909 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/fattab.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/kernel/fattab.c b/kernel/fattab.c index 8eb8bee3..7a9aa222 100644 --- a/kernel/fattab.c +++ b/kernel/fattab.c @@ -184,7 +184,7 @@ CLUSTER link_fat(struct dpb FAR * dpbp, CLUSTER Cluster1, { REG UBYTE FAR *fbp0, FAR * fbp1; struct buffer FAR * bp1; - unsigned cluster; + unsigned cluster, cluster2; /* form an index so that we can read the block as a */ /* byte array */ @@ -212,38 +212,38 @@ CLUSTER link_fat(struct dpb FAR * dpbp, CLUSTER Cluster1, fbp1 = &bp1->b_buffer[0]; } - idx = *fbp0 | (*fbp1 << 8); - if (Cluster2 == READ_CLUSTER) + cluster = *fbp0 | (*fbp1 << 8); + if ((unsigned)Cluster2 == READ_CLUSTER) { /* Now to unpack the contents of the FAT entry. Odd and */ /* even bytes are packed differently. */ if (Cluster1 & 0x01) - idx >>= 4; - idx &= 0x0fff; + cluster >>= 4; + cluster &= 0x0fff; - if (idx >= MASK12) + if (cluster >= MASK12) return LONG_LAST_CLUSTER; - if (idx == BAD12) + if (cluster == BAD12) return LONG_BAD; - return idx; + return cluster; } /* Cluster2 may be set to LONG_LAST_CLUSTER == 0x0FFFFFFFUL or 0xFFFF */ /* -- please don't remove this mask! */ - cluster = (unsigned)Cluster2 & 0x0fff; + cluster2 = (unsigned)Cluster2 & 0x0fff; /* Now pack the value in */ if ((unsigned)Cluster1 & 0x01) { - idx &= 0x000f; - cluster <<= 4; + cluster &= 0x000f; + cluster2 <<= 4; } else { - idx &= 0xf000; + cluster &= 0xf000; } - cluster |= idx; + cluster |= cluster2; *fbp0 = (UBYTE)cluster; *fbp1 = (UBYTE)(cluster >> 8); } @@ -251,7 +251,7 @@ CLUSTER link_fat(struct dpb FAR * dpbp, CLUSTER Cluster1, { /* form an index so that we can read the block as a */ /* byte array */ - if (Cluster2 == READ_CLUSTER) + if ((unsigned)Cluster2 == READ_CLUSTER) { /* and get the cluster number */ UWORD res = fgetword(&bp->b_buffer[idx * 2]); From 976efed7a5dbc830907c7159550b9d50830bc5f2 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Fri, 30 Apr 2004 17:06:45 +0000 Subject: [PATCH 487/671] Need to commit proto.h or things won't compile... git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@910 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/proto.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/proto.h b/kernel/proto.h index 0a2b5d3d..99f0f30b 100644 --- a/kernel/proto.h +++ b/kernel/proto.h @@ -195,8 +195,8 @@ struct dhdr FAR * select_unit(COUNT drive); /* fattab.c */ void read_fsinfo(struct dpb FAR * dpbp); void write_fsinfo(struct dpb FAR * dpbp); -UCOUNT link_fat(struct dpb FAR * dpbp, CLUSTER Cluster1, - REG CLUSTER Cluster2); +CLUSTER link_fat(struct dpb FAR * dpbp, CLUSTER Cluster1, + REG CLUSTER Cluster2); CLUSTER next_cluster(struct dpb FAR * dpbp, REG CLUSTER ClusterNum); /* fcbfns.c */ From ecfcb9be2914facc02a8eb33dae6b63fb10a2dd6 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Fri, 30 Apr 2004 17:14:33 +0000 Subject: [PATCH 488/671] dir_read() no longer updates the diroff counter. This eliminates the NEW field, simplifies remove_lfn_entries(), and avoids a bug if you delete the first entry in the root directory on FAT32. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@911 6ac86273-5f31-0410-b378-82cca8765d1b --- hdr/fnode.h | 5 ++--- kernel/fatdir.c | 44 ++++++++++++-------------------------------- kernel/fatfs.c | 20 +++++++++++--------- 3 files changed, 25 insertions(+), 44 deletions(-) diff --git a/hdr/fnode.h b/hdr/fnode.h index f17a7cb7..5803d4f4 100644 --- a/hdr/fnode.h +++ b/hdr/fnode.h @@ -54,9 +54,8 @@ struct f_node { }; #define F_DMOD 1 /* directory has been modified */ -#define F_DNEW 2 /* fnode is new and needs fill */ -#define F_DDIR 4 /* fnode is assigned to dir */ -#define F_DDATE 8 /* date set using setdate */ +#define F_DDIR 2 /* fnode is assigned to dir */ +#define F_DDATE 4 /* date set using setdate */ typedef struct f_node *f_node_ptr; diff --git a/kernel/fatdir.c b/kernel/fatdir.c index 23df2c0d..1acbde42 100644 --- a/kernel/fatdir.c +++ b/kernel/fatdir.c @@ -42,7 +42,7 @@ static BYTE *fatdirRcsId = VOID dir_init_fnode(f_node_ptr fnp, CLUSTER dirstart) { /* reset the directory flags */ - fnp->f_flags = F_DDIR | F_DNEW; + fnp->f_flags = F_DDIR; fnp->f_diroff = 0; fnp->f_offset = 0l; fnp->f_cluster_offset = 0; @@ -143,6 +143,7 @@ f_node_ptr dir_open(register const char *dirname) i = TRUE; break; } + fnp->f_diroff++; } if (!i || !(fnp->f_dir.dir_attrib & D_DIR)) @@ -198,22 +199,11 @@ COUNT dir_read(REG f_node_ptr fnp) { struct buffer FAR *bp; REG UWORD secsize = fnp->f_dpb->dpb_secsize; - unsigned new_diroff = fnp->f_diroff; - /* can't have more than 65535 directory entries - remove lfn entries may call us with new_diroff == -1 - for root directories though */ - if (fnp->f_dirstart != 0 && new_diroff >= 65535U) + /* can't have more than 65535 directory entries */ + if (fnp->f_diroff >= 65535U) return DE_SEEK; - /* Directories need to point to their current offset, not for */ - /* next op. Therefore, if it is anything other than the first */ - /* directory entry, we will update the offset on entry rather */ - /* than wait until exit. If it was new, clear the special new */ - /* flag. */ - if (!(fnp->f_flags & F_DNEW)) - new_diroff++; - /* Determine if we hit the end of the directory. If we have, */ /* bump the offset back to the end and exit. If not, fill the */ /* dirent portion of the fnode, clear the f_dmod bit and leave, */ @@ -221,10 +211,10 @@ COUNT dir_read(REG f_node_ptr fnp) if (fnp->f_dirstart == 0) { - if (new_diroff >= fnp->f_dpb->dpb_dirents) + if (fnp->f_diroff >= fnp->f_dpb->dpb_dirents) return DE_SEEK; - bp = getblock(new_diroff / (secsize / DIRENT_SIZE) + bp = getblock(fnp->f_diroff / (secsize / DIRENT_SIZE) + fnp->f_dpb->dpb_dirstrt, fnp->f_dpb->dpb_unit); #ifdef DISPLAY_GETBLOCK printf("DIR (dir_read)\n"); @@ -233,7 +223,7 @@ COUNT dir_read(REG f_node_ptr fnp) else { /* Do a "seek" to the directory position */ - fnp->f_offset = new_diroff * (ULONG)DIRENT_SIZE; + fnp->f_offset = fnp->f_diroff * (ULONG)DIRENT_SIZE; /* Search through the FAT to find the block */ /* that this entry is in. */ @@ -258,14 +248,13 @@ COUNT dir_read(REG f_node_ptr fnp) bp->b_flag |= BFR_DIR | BFR_VALID; getdirent((BYTE FAR *) & bp-> - b_buffer[(new_diroff * DIRENT_SIZE) % fnp->f_dpb->dpb_secsize], + b_buffer[(fnp->f_diroff * DIRENT_SIZE) % fnp->f_dpb->dpb_secsize], &fnp->f_dir); swap_deleted(fnp->f_dir.dir_name); /* Update the fnode's directory info */ - fnp->f_flags &= ~(F_DMOD | F_DNEW); - fnp->f_diroff = new_diroff; + fnp->f_flags &= ~F_DMOD; /* and for efficiency, stop when we hit the first */ /* unused entry. */ @@ -278,9 +267,6 @@ COUNT dir_read(REG f_node_ptr fnp) * situation fnode is released. * The caller should set * 1. F_DMOD flag if original directory entry was modified. - * 2. F_DMOD & F_DNEW flags if new directory entry is created. In this - * case the reserved fields is cleared, but only if new dentry isn't - * a LFN entry (has D_LFN attribute). * Return value. * TRUE - all OK. * FALSE - error occured (fnode is released). @@ -348,9 +334,6 @@ BOOL dir_write(REG f_node_ptr fnp) return FALSE; } - if ((fnp->f_flags & F_DNEW) && fnp->f_dir.dir_attrib != D_LFN) - fmemset(&fnp->f_dir.dir_case, 0, 8); - swap_deleted(fnp->f_dir.dir_name); putdirent(&fnp->f_dir, &bp->b_buffer[(fnp->f_diroff * DIRENT_SIZE) % @@ -454,6 +437,7 @@ COUNT dos_findfirst(UCOUNT attr, BYTE * name) dir_close(fnp); return SUCCESS; } + fnp->f_diroff++; } /* Now that we've done our failed search, close it and */ @@ -509,17 +493,13 @@ COUNT dos_findnext(void) /* Search through the directory to find the entry, but do a */ /* seek first. */ - fnp->f_flags |= F_DNEW; - if (dmp->dm_entry > 0) - { - fnp->f_diroff = dmp->dm_entry - 1; - fnp->f_flags &= ~F_DNEW; - } + fnp->f_diroff = dmp->dm_entry; /* Loop through the directory */ while (dir_read(fnp) == 1) { ++dmp->dm_entry; + ++fnp->f_diroff; if (fnp->f_dir.dir_name[0] != '\0' && fnp->f_dir.dir_name[0] != DELETED && (fnp->f_dir.dir_attrib & D_VOLID) != D_VOLID) { diff --git a/kernel/fatfs.c b/kernel/fatfs.c index 174cf029..3fcdb9ba 100644 --- a/kernel/fatfs.c +++ b/kernel/fatfs.c @@ -407,6 +407,7 @@ STATIC BOOL find_fname(f_node_ptr fnp, char *fcbname, int attr) { return TRUE; } + fnp->f_diroff++; } return FALSE; } @@ -428,10 +429,7 @@ COUNT remove_lfn_entries(f_node_ptr fnp) { if (fnp->f_diroff == 0) break; - fnp->f_diroff -= 2; - /* it cannot / should not get below 0 because of '.' and '..' - * except for root directories... but then dir_read() makes it 0 - * again */ + fnp->f_diroff--; if (dir_read(fnp) <= 0) { dir_close(fnp); return DE_BLKINVLD; @@ -442,7 +440,7 @@ COUNT remove_lfn_entries(f_node_ptr fnp) fnp->f_flags |= F_DMOD; if (!dir_write(fnp)) return DE_BLKINVLD; } - fnp->f_diroff = original_diroff - 1; + fnp->f_diroff = original_diroff; if (dir_read(fnp) <= 0) { dir_close(fnp); return DE_BLKINVLD; @@ -642,6 +640,7 @@ COUNT dos_rmdir(BYTE * path) return DE_ACCESS; } + fnp1->f_diroff++; dir_read(fnp1); if (fnp1->f_dir.dir_name[0] != '.') { @@ -652,18 +651,18 @@ COUNT dos_rmdir(BYTE * path) /* Now search through the directory and make certain */ /* that there are no entries. */ found = FALSE; + fnp1->f_diroff++; while (dir_read(fnp1) == 1) { if (fnp1->f_dir.dir_name[0] == '\0') break; - if (fnp1->f_dir.dir_name[0] == DELETED - || fnp1->f_dir.dir_attrib == D_LFN) - continue; - else + if (fnp1->f_dir.dir_name[0] != DELETED + && fnp1->f_dir.dir_attrib != D_LFN) { found = TRUE; break; } + fnp1->f_diroff++; } dir_close(fnp1); @@ -817,8 +816,11 @@ STATIC BOOL find_free(f_node_ptr fnp) COUNT rc; while ((rc = dir_read(fnp)) == 1) + { if (fnp->f_dir.dir_name[0] == DELETED) return TRUE; + fnp->f_diroff++; + } return rc >= 0; } From 859ac24170e1131755167724467317ad660c130b Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sun, 2 May 2004 15:21:35 +0000 Subject: [PATCH 489/671] We have to cast away const to deal with the generic "void *" pointer and some compiler warning. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@912 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/proto.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/proto.h b/kernel/proto.h index 99f0f30b..abe7bb7a 100644 --- a/kernel/proto.h +++ b/kernel/proto.h @@ -386,7 +386,7 @@ long ASMPASCAL network_redirector_mx(unsigned cmd, void far *s, void *arg); #define remote_lseek(s,new_pos) network_redirector_mx(REM_LSEEK, s, &new_pos) #define remote_setfattr(attr) (int)network_redirector_mx(REM_SETATTR, NULL, (void *)attr) #define remote_printredir(dx,ax) (int)network_redirector_mx(REM_PRINTREDIR, MK_FP(0,dx),(void *)ax) -#define QRemote_Fn(d,s) (int)network_redirector_mx(REM_FILENAME, d, &s) +#define QRemote_Fn(d,s) (int)network_redirector_mx(REM_FILENAME, d, (void *)&s) UWORD get_machine_name(BYTE FAR * netname); VOID set_machine_name(BYTE FAR * netname, UWORD name_num); From 6947542a5ee5e62b152e913522b8f395e78e2202 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Tue, 4 May 2004 09:32:16 +0000 Subject: [PATCH 490/671] Initialise all int vectors except the ones at 70:xxxx using a table. Convert setvec into a function that disables/enables ints (init code only for now, resident code will follow later); cli/sti (disable/enable) are now macros (inlined). git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@918 6ac86273-5f31-0410-b378-82cca8765d1b --- hdr/portab.h | 9 +++++++ kernel/globals.h | 1 - kernel/main.c | 68 +++++++++++++++++++++++++++++++----------------- 3 files changed, 53 insertions(+), 25 deletions(-) diff --git a/hdr/portab.h b/hdr/portab.h index 3707ee25..b2745ad2 100644 --- a/hdr/portab.h +++ b/hdr/portab.h @@ -71,6 +71,9 @@ static char *portab_hRcsId = #endif #define PASCAL pascal void __int__(int); +void __emit__(char, ...); +#define disable() __emit__(0xfa) +#define enable() __emit__(0xfb) #elif defined (_MSC_VER) @@ -82,6 +85,8 @@ void __int__(int); #define VA_CDECL #define PASCAL pascal #define __int__(intno) asm int intno; +#define disable() asm cli +#define enable() asm sti #define _CS getCS() static unsigned short __inline getCS(void) { @@ -97,6 +102,10 @@ static unsigned short __inline getSS(void) #define I86 #define __int__(intno) asm int intno; +void disable(void); +#pragma aux disable = "cli" modify exact []; +void enable(void); +#pragma aux enable = "sti" modify exact []; #define asm __asm #define far __far #define CDECL __cdecl diff --git a/kernel/globals.h b/kernel/globals.h index 3d1c1a68..98aa4c7d 100644 --- a/kernel/globals.h +++ b/kernel/globals.h @@ -361,7 +361,6 @@ extern UWORD ASM f_nodes_cnt; /* number of allocated f_nodes */ /* Typically, these are in ".asm" files. */ VOID ASMCFUNC FAR cpm_entry(VOID) /*INRPT FAR handle_break(VOID) */ ; -VOID enable(VOID), disable(VOID); COUNT ASMCFUNC CriticalError(COUNT nFlag, COUNT nDrive, COUNT nError, struct dhdr FAR * lpDevice); diff --git a/kernel/main.c b/kernel/main.c index f9ffc384..98cb798a 100644 --- a/kernel/main.c +++ b/kernel/main.c @@ -55,6 +55,7 @@ STATIC VOID FsConfig(VOID); STATIC VOID InitPrinters(VOID); STATIC VOID InitSerialPorts(VOID); STATIC void CheckContinueBootFromHarddisk(void); +STATIC void setup_int_vectors(void); #ifdef _MSC_VER BYTE _acrtused = 0; @@ -107,11 +108,7 @@ VOID ASMCFUNC FreeDOSmain(void) drv = 3; /* C: */ LoL->BootDrive = drv; - setvec(0, int0_handler); /* zero divide */ - setvec(1, empty_handler); /* single step */ - setvec(3, empty_handler); /* debug breakpoint */ - setvec(6, int6_handler); /* invalid opcode */ - + setup_int_vectors(); CheckContinueBootFromHarddisk(); @@ -210,6 +207,47 @@ STATIC void PSPInit(void) p->ps_cmd.ctBuffer[0] = 0xd; /* command tail */ } +void setvec(unsigned char intno, intvec vector) +{ + disable(); + *(intvec FAR *)MK_FP(0,4 * intno) = vector; + enable(); +} + +STATIC void setup_int_vectors(void) +{ + static struct vec + { + unsigned char intno; + size_t handleroff; + } vectors[] = + { + /* all of these are in the DOS DS */ + { 0x0, FP_OFF(int0_handler) }, /* zero divide */ + { 0x1, FP_OFF(empty_handler) }, /* single step */ + { 0x3, FP_OFF(empty_handler) }, /* debug breakpoint */ + { 0x6, FP_OFF(int6_handler) }, /* invalid opcode */ + { 0x20, FP_OFF(int20_handler) }, + { 0x21, FP_OFF(int21_handler) }, + { 0x22, FP_OFF(int22_handler) }, + { 0x24, FP_OFF(int24_handler) }, + { 0x25, FP_OFF(low_int25_handler) }, + { 0x26, FP_OFF(low_int26_handler) }, + { 0x27, FP_OFF(int27_handler) }, + { 0x28, FP_OFF(int28_handler) }, + { 0x2a, FP_OFF(int2a_handler) }, + { 0x2f, FP_OFF(int2f_handler) } + }; + struct vec *pvec; + int i; + + for (i = 0x23; i <= 0x3f; i++) + setvec(i, empty_handler); + for (pvec = vectors; pvec < vectors + (sizeof vectors/sizeof *pvec); pvec++) + setvec(pvec->intno, MK_FP(FP_SEG(empty_handler), pvec->handleroff)); + pokeb(0, 0x30 * 4, 0xea); + pokel(0, 0x30 * 4 + 1, (ULONG)cpm_entry); +} STATIC void init_kernel(void) { @@ -231,30 +269,11 @@ STATIC void init_kernel(void) MoveKernel(FP_SEG(lpTop)); lpTop = MK_FP(FP_SEG(lpTop) - 0xfff, 0xfff0); - for (i = 0x20; i <= 0x3f; i++) - setvec(i, empty_handler); - /* Initialize IO subsystem */ InitIO(); InitPrinters(); InitSerialPorts(); - /* set interrupt vectors */ - setvec(0x1b, got_cbreak); - setvec(0x20, int20_handler); - setvec(0x21, int21_handler); - setvec(0x22, int22_handler); - setvec(0x23, empty_handler); - setvec(0x24, int24_handler); - setvec(0x25, low_int25_handler); - setvec(0x26, low_int26_handler); - setvec(0x27, int27_handler); - setvec(0x28, int28_handler); - setvec(0x2a, int2a_handler); - setvec(0x2f, int2f_handler); - pokeb(0, 0x30 * 4, 0xea); - pokel(0, 0x30 * 4 + 1, (ULONG)cpm_entry); - init_PSPSet(DOS_PSP); set_DTA(MK_FP(DOS_PSP, 0x80)); PSPInit(); @@ -576,6 +595,7 @@ STATIC void InitIO(void) struct dhdr far *device = &LoL->nul_dev; /* Initialize driver chain */ + setvec(0x1b, got_cbreak); setvec(0x29, int29_handler); /* Requires Fast Con Driver */ do { init_device(device, NULL, 0, &lpTop); From 5a6e1845a8ab83ee02edd990fb6c3904b4608fc3 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Tue, 4 May 2004 09:34:47 +0000 Subject: [PATCH 491/671] Made int21/ah=25,35 reentrant. Solves problem with Intel PRO/1000 driver. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@919 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/entry.asm | 4 ++++ kernel/inthndlr.c | 26 ++++++++++++++++---------- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/kernel/entry.asm b/kernel/entry.asm index add900cf..9a467028 100644 --- a/kernel/entry.asm +++ b/kernel/entry.asm @@ -232,8 +232,12 @@ int21_reentry: mov dx,[cs:_DGROUP_] mov ds,dx + cmp ah,25h + je int21_user cmp ah,33h je int21_user + cmp ah,35h + je int21_user cmp ah,50h je int21_user cmp ah,51h diff --git a/kernel/inthndlr.c b/kernel/inthndlr.c index 055f3d86..535f7b73 100644 --- a/kernel/inthndlr.c +++ b/kernel/inthndlr.c @@ -69,6 +69,11 @@ VOID ASMCFUNC int21_syscall(iregs FAR * irp) switch (irp->AH) { + /* Set Interrupt Vector */ + case 0x25: + setvec(irp->AL, MK_FP(irp->DS, irp->DX)); + break; + /* DosVars - get/set dos variables */ case 0x33: switch (irp->AL) @@ -139,6 +144,15 @@ VOID ASMCFUNC int21_syscall(iregs FAR * irp) } break; + /* Get Interrupt Vector */ + case 0x35: + { + intvec p = getvec(irp->AL); + irp->ES = FP_SEG(p); + irp->BX = FP_OFF(p); + break; + } + /* Set PSP */ case 0x50: cu_psp = irp->BX; @@ -638,9 +652,7 @@ VOID ASMCFUNC int21_service(iregs FAR * r) break; /* Set Interrupt Vector */ - case 0x25: - setvec(lr.AL, FP_DS_DX); - break; + /* case 0x25: handled above (re-entrant) */ /* Dos Create New Psp */ case 0x26: @@ -788,13 +800,7 @@ VOID ASMCFUNC int21_service(iregs FAR * r) break; /* Get Interrupt Vector */ - case 0x35: - { - intvec p = getvec((COUNT) lr.AL); - lr.ES = FP_SEG(p); - lr.BX = FP_OFF(p); - } - break; + /* case 0x35: handled above (reentrant) */ /* Dos Get Disk Free Space */ case 0x36: From 99c40acc8036c6b7dce7991a7caf468a4b7c1700 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Tue, 4 May 2004 09:35:44 +0000 Subject: [PATCH 492/671] Replaced setvec macro by a function. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@920 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/init-mod.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/init-mod.h b/kernel/init-mod.h index 782a0a93..05fae048 100644 --- a/kernel/init-mod.h +++ b/kernel/init-mod.h @@ -100,7 +100,7 @@ char * ASMPASCAL strchr(const char *s, int ch); extern BYTE DosLoadedInHMA; void MoveKernel(unsigned NewKernelSegment); -#define setvec(n, isr) (void)(*(intvec FAR *)MK_FP(0,4 * (n)) = (isr)) +void setvec(unsigned char intno, intvec vector); #define getvec(n) (*(intvec FAR *)MK_FP(0,4 * (n))) #define GLOBAL extern From 99d287bd2c4fa48e00b1eaf61782216ae7665fc8 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Tue, 4 May 2004 09:43:06 +0000 Subject: [PATCH 493/671] fattab.c now remembers if the old FAT entry was free or not, so the free space adjustment could be moved back to fattab.c. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@921 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/fatfs.c | 23 ++++++----------- kernel/fattab.c | 65 ++++++++++++++++++++++++++----------------------- 2 files changed, 43 insertions(+), 45 deletions(-) diff --git a/kernel/fatfs.c b/kernel/fatfs.c index 3fcdb9ba..b7d22f63 100644 --- a/kernel/fatfs.c +++ b/kernel/fatfs.c @@ -1021,37 +1021,30 @@ STATIC CLUSTER find_fat_free(f_node_ptr fnp) break; } - /* No empty clusters, disk is FULL! */ #ifdef WITHFAT32 if (ISFAT32(dpbp)) { - if (idx > dpbp->dpb_xsize) + dpbp->dpb_xcluster = idx; + if (idx > size) { + /* No empty clusters, disk is FULL! */ dpbp->dpb_xcluster = UNKNCLUSTER; - write_fsinfo(dpbp); - return LONG_LAST_CLUSTER; + idx = LONG_LAST_CLUSTER; } - if (dpbp->dpb_xnfreeclst != XUNKNCLSTFREE) - dpbp->dpb_xnfreeclst--; /* TE: moved from link_fat() */ - /* return the free entry */ - dpbp->dpb_xcluster = idx; write_fsinfo(dpbp); return idx; } #endif - if ((UWORD)idx > dpbp->dpb_size) + dpbp->dpb_cluster = (UWORD)idx; + if ((UWORD)idx > (UWORD)size) { + /* No empty clusters, disk is FULL! */ dpbp->dpb_cluster = UNKNCLUSTER; - return LONG_LAST_CLUSTER; + idx = LONG_LAST_CLUSTER; } - - if (dpbp->dpb_nfreeclst != UNKNCLSTFREE) - dpbp->dpb_nfreeclst--; /* TE: moved from link_fat() */ - /* return the free entry */ - dpbp->dpb_cluster = (UWORD)idx; return idx; } diff --git a/kernel/fattab.c b/kernel/fattab.c index 7a9aa222..6083a65d 100644 --- a/kernel/fattab.c +++ b/kernel/fattab.c @@ -125,6 +125,7 @@ CLUSTER link_fat(struct dpb FAR * dpbp, CLUSTER Cluster1, struct buffer FAR *bp; unsigned idx; unsigned secdiv; + unsigned char wasfree; CLUSTER clussec = Cluster1; CLUSTER max_cluster = dpbp->dpb_size; @@ -141,7 +142,7 @@ CLUSTER link_fat(struct dpb FAR * dpbp, CLUSTER Cluster1, #endif put_unsigned((unsigned)(clussec & 0xffffu), 16, 4); put_console('\n'); - return NULL; + return 1; } secdiv = dpbp->dpb_secsize; @@ -213,8 +214,9 @@ CLUSTER link_fat(struct dpb FAR * dpbp, CLUSTER Cluster1, } cluster = *fbp0 | (*fbp1 << 8); - if ((unsigned)Cluster2 == READ_CLUSTER) { + unsigned res = cluster; + /* Now to unpack the contents of the FAT entry. Odd and */ /* even bytes are packed differently. */ @@ -222,11 +224,20 @@ CLUSTER link_fat(struct dpb FAR * dpbp, CLUSTER Cluster1, cluster >>= 4; cluster &= 0x0fff; - if (cluster >= MASK12) - return LONG_LAST_CLUSTER; - if (cluster == BAD12) - return LONG_BAD; - return cluster; + if ((unsigned)Cluster2 == READ_CLUSTER) + { + if (cluster >= MASK12) + return LONG_LAST_CLUSTER; + if (cluster == BAD12) + return LONG_BAD; + return cluster; + } + + wasfree = 0; + if (cluster == FREE) + wasfree = 1; + + cluster = res; } /* Cluster2 may be set to LONG_LAST_CLUSTER == 0x0FFFFFFFUL or 0xFFFF */ @@ -251,10 +262,10 @@ CLUSTER link_fat(struct dpb FAR * dpbp, CLUSTER Cluster1, { /* form an index so that we can read the block as a */ /* byte array */ + /* and get the cluster number */ + UWORD res = fgetword(&bp->b_buffer[idx * 2]); if ((unsigned)Cluster2 == READ_CLUSTER) { - /* and get the cluster number */ - UWORD res = fgetword(&bp->b_buffer[idx * 2]); if (res >= MASK16) return LONG_LAST_CLUSTER; if (res == BAD16) @@ -265,15 +276,18 @@ CLUSTER link_fat(struct dpb FAR * dpbp, CLUSTER Cluster1, /* Finally, put the word into the buffer and mark the */ /* buffer as dirty. */ fputword(&bp->b_buffer[idx * 2], (UWORD)Cluster2); + wasfree = 0; + if (res == FREE) + wasfree = 1; } #ifdef WITHFAT32 else if (ISFAT32(dpbp)) { /* form an index so that we can read the block as a */ /* byte array */ + UDWORD res = fgetlong(&bp->b_buffer[idx * 4]); if (Cluster2 == READ_CLUSTER) { - UDWORD res = fgetlong(&bp->b_buffer[idx * 4]); if (res > LONG_BAD) return LONG_LAST_CLUSTER; @@ -282,6 +296,9 @@ CLUSTER link_fat(struct dpb FAR * dpbp, CLUSTER Cluster1, /* Finally, put the word into the buffer and mark the */ /* buffer as dirty. */ fputlong(&bp->b_buffer[idx * 4], Cluster2); + wasfree = 0; + if (res == FREE) + wasfree = 1; } #endif else @@ -289,38 +306,26 @@ CLUSTER link_fat(struct dpb FAR * dpbp, CLUSTER Cluster1, /* update the free space count */ bp->b_flag |= BFR_DIRTY | BFR_VALID; - if (Cluster2 == FREE) + if (Cluster2 == FREE || wasfree) { + int adjust = 0; + if (!wasfree) + adjust = 1; + else if (Cluster2 != FREE) + adjust = -1; #ifdef WITHFAT32 if (ISFAT32(dpbp) && dpbp->dpb_xnfreeclst != XUNKNCLSTFREE) { /* update the free space count for returned */ /* cluster */ - ++dpbp->dpb_xnfreeclst; + dpbp->dpb_xnfreeclst += adjust; write_fsinfo(dpbp); } else #endif if (dpbp->dpb_nfreeclst != UNKNCLSTFREE) - ++dpbp->dpb_nfreeclst; + dpbp->dpb_nfreeclst += adjust; } - - /*if (Cluster2 == FREE) - { */ - /* update the free space count for returned */ - /* cluster */ - /* ++dpbp->dpb_nfreeclst; - } */ - - /* update the free space count for removed */ - /* cluster */ - /* BUG: was counted twice for 2nd,.. cluster. moved to find_fat_free() */ - /* BO: don't completely understand this yet - leave here for now as - a comment */ - /* else - { - --dpbp->dpb_nfreeclst; - } */ return SUCCESS; } From 02db26383e963cb6aa21ed394012eac0da0568b0 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Tue, 4 May 2004 10:16:45 +0000 Subject: [PATCH 494/671] Clean up int2f assembly a bit (merge some common bits, clarify label names) git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@922 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/int2f.asm | 64 ++++++++++++++++++++++-------------------------- 1 file changed, 29 insertions(+), 35 deletions(-) diff --git a/kernel/int2f.asm b/kernel/int2f.asm index d257dfa4..895e378b 100644 --- a/kernel/int2f.asm +++ b/kernel/int2f.asm @@ -282,8 +282,8 @@ remote_lseek: ; arg is a pointer to the long seek value remote_getfattr: clc ; set to succeed int 2fh - jc no_clear_ax - jmp short no_neg_ax + jc ret_neg_ax + jmp short ret_int2f remote_lock_unlock: mov dx, cx ; parameter block (dx) in arg @@ -291,10 +291,9 @@ remote_lock_unlock: mov bl, [bx + 8] ; unlock or not mov cx, 1 int 0x2f + jnc ret_set_ax_to_carry mov ah, 0 - jc lock_error - mov al, 0 -lock_error: jmp no_clear_ax + jmp short ret_neg_ax ;long ASMPASCAL network_redirector_mx(unsigned cmd, void far *s, void *arg) global NETWORK_REDIRECTOR_MX @@ -312,7 +311,7 @@ call_int2f: cmp al, 0fh je remote_getfattr - mov di, dx ; es:di -> s + mov di, dx ; es:di -> s and dx is used for 1125! cmp al, 08h je remote_rw cmp al, 09h @@ -338,19 +337,20 @@ int2f_call: xor cx, cx ; set to succeed; clear carry and CX int 2fh pop bx - jnc clear_ax -no_clear_ax: + jnc ret_set_ax_to_cx +ret_neg_ax: neg ax - xchg cx, ax -clear_ax: - xchg ax, cx ; extended open -> status from CX in AX - ; otherwise CX was set to zero above -no_neg_ax: +ret_int2f: pop di pop si pop bp ret +ret_set_ax_to_cx: ; ext_open or rw -> status from CX in AX + ; otherwise CX was set to zero above + xchg ax, cx ; set ax:=cx (one byte shorter than mov) + jmp short ret_int2f + remote_print_doredir: ; di points to an lregs structure mov es,[di+0xe] mov bx,[di+2] @@ -364,51 +364,45 @@ remote_print_doredir: ; di points to an lregs structure pop bx ; restore stack and ds=ss push ss pop ds - jc no_clear_ax - xor cx, cx - jmp short clear_ax + jc ret_neg_ax +ret_set_ax_to_carry: ; carry => -1 else 0 (SUCCESS) + sbb ax, ax + jmp short ret_int2f remote_getfree: clc ; set to succeed int 2fh pop di ; retrieve pushed pointer arg - jc no_clear_ax + jc ret_set_ax_to_carry mov [di],ax mov [di+2],bx mov [di+4],cx mov [di+6],dx - xor cx, cx - jmp short clear_ax + jmp short ret_set_ax_to_carry remote_rw: clc ; set to succeed int 2fh - jc int2f_carry - mov ax, cx - xor dx, dx ; dx:ax = bytes read - jmp short no_neg_ax -int2f_carry: neg ax + jc ret_min_dx_ax + xor dx, dx ; dx:ax := dx:cx = bytes read + jmp short ret_set_ax_to_cx +ret_min_dx_ax: neg ax cwd - jmp short no_neg_ax + jmp short ret_int2f qremote_fn: - push ds mov bx, cx lds si, [bx] - clc - int 2fh - pop ds - mov ax,0xffff - jc no_neg_ax - xor cx, cx - jmp short clear_ax + jmp short int2f_restore_ds remote_process_end: ; Terminate process - mov ds, [_cu_psp] + mov ds, [_cu_psp] +int2f_restore_ds: + clc int 2fh push ss pop ds - jmp short no_neg_ax + jmp short ret_set_ax_to_carry ; extern UWORD ASMCFUNC call_nls(UWORD subfct, struct nlsInfoBlock *nlsinfo, ; UWORD bp, UWORD cp, UWORD cntry, UWORD bufsize, UWORD FAR *buf, UWORD *id); From fcaf8682dc865e242e60d53884c6063d6904815e Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Mon, 10 May 2004 00:24:33 +0000 Subject: [PATCH 495/671] Avoid problem with BC declaring __emit__, en/disable twice. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@923 6ac86273-5f31-0410-b378-82cca8765d1b --- hdr/portab.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hdr/portab.h b/hdr/portab.h index b2745ad2..78bb79fa 100644 --- a/hdr/portab.h +++ b/hdr/portab.h @@ -71,9 +71,11 @@ static char *portab_hRcsId = #endif #define PASCAL pascal void __int__(int); +#ifndef FORSYS void __emit__(char, ...); #define disable() __emit__(0xfa) #define enable() __emit__(0xfb) +#endif #elif defined (_MSC_VER) From 92d7f417191c2ae20c942d0f45157158dcd942e4 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Mon, 10 May 2004 01:00:40 +0000 Subject: [PATCH 496/671] Add necessary cast for BC git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@924 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/main.c b/kernel/main.c index 98cb798a..f59593f4 100644 --- a/kernel/main.c +++ b/kernel/main.c @@ -244,7 +244,7 @@ STATIC void setup_int_vectors(void) for (i = 0x23; i <= 0x3f; i++) setvec(i, empty_handler); for (pvec = vectors; pvec < vectors + (sizeof vectors/sizeof *pvec); pvec++) - setvec(pvec->intno, MK_FP(FP_SEG(empty_handler), pvec->handleroff)); + setvec(pvec->intno, (intvec)MK_FP(FP_SEG(empty_handler), pvec->handleroff)); pokeb(0, 0x30 * 4, 0xea); pokel(0, 0x30 * 4 + 1, (ULONG)cpm_entry); } From ece15c38f7eb1ea617d51b7877b8f31dea2d0bf2 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Mon, 10 May 2004 01:36:09 +0000 Subject: [PATCH 497/671] strcasecmp and set_strategy common code optimizations, mostly from Lucho. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@925 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/config.c | 64 ++++++++++++++++++++++--------------------------- 1 file changed, 29 insertions(+), 35 deletions(-) diff --git a/kernel/config.c b/kernel/config.c index c7a2a7e3..e3183fff 100644 --- a/kernel/config.c +++ b/kernel/config.c @@ -207,7 +207,7 @@ STATIC char * GetNumber(REG const char *p, int *num); #if 0 STATIC COUNT tolower(COUNT c); #endif -STATIC COUNT toupper(COUNT c); +STATIC unsigned char toupper(unsigned char c); STATIC VOID strupr(char *s); STATIC VOID mcb_init(UCOUNT seg, UWORD size, BYTE type); STATIC VOID mumcb_init(UCOUNT seg, UWORD size); @@ -223,7 +223,7 @@ STATIC int SkipLine(char *pLine); #if 0 STATIC char * stristr(char *s1, char *s2); #endif -STATIC COUNT strcasecmp(REG BYTE * d, REG BYTE * s); +STATIC int strcasecmp(const char * d, const char * s); STATIC int LoadCountryInfoHardCoded(char *filename, COUNT ctryCode, COUNT codePage); STATIC void umb_init(void); @@ -1582,7 +1582,7 @@ STATIC char * GetNumber(REG const char *p, int *num) for(;;p++) { - unsigned char ch = toupper((unsigned char)*p); + unsigned char ch = toupper(*p); if (ch == 'X') { base = 16; @@ -1606,7 +1606,7 @@ STATIC char * GetNumber(REG const char *p, int *num) } /* Yet another change for true portability (PJV) */ -STATIC COUNT toupper(COUNT c) +STATIC unsigned char toupper(unsigned char c) { if (c >= 'a' && c <= 'z') return (c - ('a' - 'A')); @@ -1658,20 +1658,16 @@ char *strcat(register char * d, register const char * s) } /* compare two ASCII strings ignoring case */ -STATIC COUNT strcasecmp(REG BYTE * d, REG BYTE * s) +STATIC int strcasecmp(const char * d, const char * s) { - while (*s != '\0' && *d != '\0') + int ret; + for (;; s++, d++) { - - if (toupper(*d) == toupper(*s)) - ++s, ++d; - - else - return toupper(*d) - toupper(*s); - + ret = toupper(*d) - toupper(*s); + if (ret != 0 || *d == '\0') + break; } - - return toupper(*d) - toupper(*s); + return ret; } /* @@ -1817,7 +1813,7 @@ STATIC VOID CfgMenu(BYTE * pLine) pLine = skipwh(pLine); /* skip more whitespaces... */ /* now I'm expecting a number here if this is a menu-choice line. */ - if (pLine[0]>='0' && pLine[0]<='9') + if (isnum(pLine[0])) { int nIndex = pLine[0]-'0'; @@ -1942,7 +1938,7 @@ STATIC VOID DoMenu(void) if (key == '\r' || key == 0x1b) /* CR/ESC - use default */ break; - if (key >= '0' && key <= '9' && (Menus & (1 << (key - '0')))) + if (isnum(key) && (Menus & (1 << (key - '0')))) { MenuSelected = key - '0'; break; @@ -2473,8 +2469,8 @@ STATIC int LoadCountryInfoHardCoded(char *filename, COUNT ctryCode, COUNT codePa } } - printf("could not find country info for country ID %u\n", ctryCode); - printf("current supported countries are "); + printf("could not find country info for country ID %u\n" + "current supported countries are ", ctryCode); for (i = 0; i < sizeof(specificCountriesSupported)/sizeof(specificCountriesSupported[0]); i++) { @@ -2570,10 +2566,19 @@ STATIC void free(seg segment) init_call_intr(0x21, &r); } +/* set memory allocation strategy */ +STATIC void set_strategy(unsigned char strat) +{ + iregs r; + + r.a.x = 0x5801; + r.b.b.l = strat; + init_call_intr(0x21, &r); +} + VOID DoInstall(void) { int i; - iregs r; unsigned short installMemory; @@ -2587,11 +2592,8 @@ VOID DoInstall(void) we need to protect the INIT_CODE from other programs that will be executing soon */ - - r.a.x = 0x5801; /* set memory allocation strategy */ - r.b.b.l = 0x02; /*low memory, last fit */ - init_call_intr(0x21, &r); + set_strategy(LAST_FIT); allocmem(((unsigned)_init_end + ebda_size + 15) / 16, &installMemory); InstallPrintf(("allocated memory at %x\n",installMemory)); @@ -2599,18 +2601,10 @@ VOID DoInstall(void) for (i = 0; i < numInstallCmds; i++) { InstallPrintf(("%d:%s\n",i,InstallCommands[i].buffer)); - - r.a.x = 0x5801; /* set memory allocation strategy */ - r.b.b.l = InstallCommands[i].mode; - init_call_intr(0x21, &r); - + set_stragegy(InstallCommands[i].mode); InstallExec(&InstallCommands[i]); - } - - r.a.x = 0x5801; /* set memory allocation strategy */ - r.b.b.l = 0x00; /*low memory, high */ - init_call_intr(0x21, &r); - + } + set_strategy(FIRST_FIT); free(installMemory); InstallPrintf(("Done with installing commands\n")); From c65b5e3b534f55f2f555106c8fcfa74c053465c2 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Mon, 10 May 2004 15:22:21 +0000 Subject: [PATCH 498/671] Correct typo. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@926 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/config.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/config.c b/kernel/config.c index e3183fff..8249066a 100644 --- a/kernel/config.c +++ b/kernel/config.c @@ -2601,7 +2601,7 @@ VOID DoInstall(void) for (i = 0; i < numInstallCmds; i++) { InstallPrintf(("%d:%s\n",i,InstallCommands[i].buffer)); - set_stragegy(InstallCommands[i].mode); + set_strategy(InstallCommands[i].mode); InstallExec(&InstallCommands[i]); } set_strategy(FIRST_FIT); From 258877b44bf2acab3dc7187d2d907ba381967e08 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Mon, 10 May 2004 19:44:52 +0000 Subject: [PATCH 499/671] cntry == 0 doesn't make sense for Set Country Information (by Arkady) git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@927 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/inthndlr.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/kernel/inthndlr.c b/kernel/inthndlr.c index 535f7b73..837e506e 100644 --- a/kernel/inthndlr.c +++ b/kernel/inthndlr.c @@ -833,9 +833,7 @@ VOID ASMCFUNC int21_service(iregs FAR * r) { UWORD cntry = lr.AL; - if (cntry == 0) - cntry = (UWORD) - 1; - else if (cntry == 0xff) + if (cntry == 0xff) cntry = lr.BX; if (0xffff == lr.DX) @@ -846,6 +844,8 @@ VOID ASMCFUNC int21_service(iregs FAR * r) } else { + if (cntry == 0) + cntry--; /* Get Country Information */ if ((rc = DosGetCountryInformation(cntry, FP_DS_DX)) < 0) goto error_invalid; From 7a16abbfb20889029e6864b19d37fb4151f74c65 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Mon, 10 May 2004 20:15:37 +0000 Subject: [PATCH 500/671] Convert setvec into a function for the resident code (mostly from Lucho). git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@928 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/globals.h | 5 +++-- kernel/main.c | 3 +++ kernel/task.c | 7 +++++++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/kernel/globals.h b/kernel/globals.h index 98aa4c7d..c200fdbe 100644 --- a/kernel/globals.h +++ b/kernel/globals.h @@ -408,9 +408,10 @@ VOID fputword(VOID FAR *, UWORD); VOID fputbyte(VOID FAR *, UBYTE); #endif -#ifdef I86 -#define setvec(n, isr) (void)(*(intvec FAR *)MK_FP(0,4 * (n)) = (isr)) +#ifndef __WATCOMC__ +#define setvec setvec_resident #endif +void setvec(unsigned char intno, intvec vector); /*#define is_leap_year(y) ((y) & 3 ? 0 : (y) % 100 ? 1 : (y) % 400 ? 0 : 1) */ /* ^Break handling */ diff --git a/kernel/main.c b/kernel/main.c index f59593f4..1a48a597 100644 --- a/kernel/main.c +++ b/kernel/main.c @@ -207,12 +207,15 @@ STATIC void PSPInit(void) p->ps_cmd.ctBuffer[0] = 0xd; /* command tail */ } +#ifndef __WATCOMC__ +/* for WATCOMC we can use the one in task.c */ void setvec(unsigned char intno, intvec vector) { disable(); *(intvec FAR *)MK_FP(0,4 * intno) = vector; enable(); } +#endif STATIC void setup_int_vectors(void) { diff --git a/kernel/task.c b/kernel/task.c index 236b4cc4..6ad97dcb 100644 --- a/kernel/task.c +++ b/kernel/task.c @@ -65,6 +65,13 @@ static BYTE *RcsId = + 1 byte: '\0' -- 1999/04/21 ska */ +void setvec(unsigned char intno, intvec vector) +{ + disable(); + *(intvec FAR *)MK_FP(0,4 * intno) = vector; + enable(); +} + ULONG SftGetFsize(int sft_idx) { sft FAR *s = idx_to_sft(sft_idx); From e68f66db37a0620991f022f59aa7c6a26b63ae6c Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Mon, 10 May 2004 20:49:43 +0000 Subject: [PATCH 501/671] Convert getvec into a C function. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@929 6ac86273-5f31-0410-b378-82cca8765d1b --- drivers/makefile | 4 ++-- filelist | 1 - kernel/globals.h | 3 +-- kernel/init-mod.h | 5 ++++- kernel/inthndlr.c | 2 +- kernel/main.c | 11 ++++++++++- kernel/task.c | 13 +++++++++++-- 7 files changed, 29 insertions(+), 10 deletions(-) diff --git a/drivers/makefile b/drivers/makefile index 98647887..94bba96e 100644 --- a/drivers/makefile +++ b/drivers/makefile @@ -22,9 +22,9 @@ #AFLAGS = /Mx /Dmem$(MODEL)=1 #LIBFLAGS = /c -OBJS = floppy.obj getvec.obj rdpcclk.obj wrpcclk.obj wratclk.obj +OBJS = floppy.obj rdpcclk.obj wrpcclk.obj wratclk.obj -LIBOBJS= +floppy +getvec +rdpcclk +wrpcclk +wratclk +LIBOBJS= +floppy +rdpcclk +wrpcclk +wratclk diff --git a/filelist b/filelist index 9b4ed556..e86d481c 100644 --- a/filelist +++ b/filelist @@ -28,7 +28,6 @@ */*/docs/readme.txt */*/docs/sys.txt */*/drivers/floppy.asm -*/*/drivers/getvec.asm */*/drivers/makefile */*/drivers/rdpcclk.asm */*/drivers/wratclk.asm diff --git a/kernel/globals.h b/kernel/globals.h index c200fdbe..14898960 100644 --- a/kernel/globals.h +++ b/kernel/globals.h @@ -375,12 +375,11 @@ VOID ASMCFUNC FAR restore_stack(VOID); ULONG ASMPASCAL ReadPCClock(VOID); VOID ASMPASCAL WriteATClock(BYTE *, BYTE, BYTE, BYTE); VOID ASMPASCAL WritePCClock(ULONG); -intvec ASMPASCAL getvec(UWORD); +intvec getvec(unsigned char); #ifdef __WATCOMC__ #pragma aux (pascal) ReadPCClock modify exact [ax cx dx] #pragma aux (pascal) WriteATClock modify exact [ax bx cx dx] #pragma aux (pascal) WritePCClock modify exact [ax cx dx] -#pragma aux (pascal) getvec modify exact [ax bx dx es] #endif /* */ diff --git a/kernel/init-mod.h b/kernel/init-mod.h index 05fae048..0dc72edf 100644 --- a/kernel/init-mod.h +++ b/kernel/init-mod.h @@ -101,7 +101,10 @@ extern BYTE DosLoadedInHMA; void MoveKernel(unsigned NewKernelSegment); void setvec(unsigned char intno, intvec vector); -#define getvec(n) (*(intvec FAR *)MK_FP(0,4 * (n))) +#ifndef __WATCOMC__ +#define getvec init_getvec +#endif +intvec getvec(unsigned char intno); #define GLOBAL extern #define NAMEMAX MAX_CDSPATH /* Maximum path for CDS */ diff --git a/kernel/inthndlr.c b/kernel/inthndlr.c index 837e506e..804d2255 100644 --- a/kernel/inthndlr.c +++ b/kernel/inthndlr.c @@ -71,7 +71,7 @@ VOID ASMCFUNC int21_syscall(iregs FAR * irp) { /* Set Interrupt Vector */ case 0x25: - setvec(irp->AL, MK_FP(irp->DS, irp->DX)); + setvec(irp->AL, (intvec)MK_FP(irp->DS, irp->DX)); break; /* DosVars - get/set dos variables */ diff --git a/kernel/main.c b/kernel/main.c index 1a48a597..fa0dddd1 100644 --- a/kernel/main.c +++ b/kernel/main.c @@ -208,7 +208,16 @@ STATIC void PSPInit(void) } #ifndef __WATCOMC__ -/* for WATCOMC we can use the one in task.c */ +/* for WATCOMC we can use the ones in task.c */ +intvec getvec(unsigned char intno) +{ + intvec iv; + disable(); + iv = *(intvec FAR *)MK_FP(0,4 * (intno)); + enable(); + return iv; +} + void setvec(unsigned char intno, intvec vector) { disable(); diff --git a/kernel/task.c b/kernel/task.c index 6ad97dcb..2a173bb1 100644 --- a/kernel/task.c +++ b/kernel/task.c @@ -65,6 +65,15 @@ static BYTE *RcsId = + 1 byte: '\0' -- 1999/04/21 ska */ +intvec getvec(unsigned char intno) +{ + intvec iv; + disable(); + iv = *(intvec FAR *)MK_FP(0,4 * (intno)); + enable(); + return iv; +} + void setvec(unsigned char intno, intvec vector) { disable(); @@ -488,7 +497,7 @@ COUNT DosComLoader(BYTE FAR * namep, exec_blk * exp, COUNT mode, COUNT fd) psp FAR *p; /* point to the PSP so we can build it */ - setvec(0x22, MK_FP(user_r->CS, user_r->IP)); + setvec(0x22, (intvec)MK_FP(user_r->CS, user_r->IP)); child_psp(mem, cu_psp, mem + asize); fcbcode = patchPSP(mem - 1, env, exp, namep); @@ -739,7 +748,7 @@ COUNT DosExeLoader(BYTE FAR * namep, exec_blk * exp, COUNT mode, COUNT fd) UWORD fcbcode; /* point to the PSP so we can build it */ - setvec(0x22, MK_FP(user_r->CS, user_r->IP)); + setvec(0x22, (intvec)MK_FP(user_r->CS, user_r->IP)); child_psp(mem, cu_psp, mem + asize); fcbcode = patchPSP(mem - 1, env, exp, namep); From aea849152885b6b109d307f5bf34d0dbb79950f9 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Mon, 10 May 2004 20:50:41 +0000 Subject: [PATCH 502/671] Remove getvec.asm git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@930 6ac86273-5f31-0410-b378-82cca8765d1b --- drivers/getvec.asm | 46 ---------------------------------------------- 1 file changed, 46 deletions(-) delete mode 100644 drivers/getvec.asm diff --git a/drivers/getvec.asm b/drivers/getvec.asm deleted file mode 100644 index 7489fd6c..00000000 --- a/drivers/getvec.asm +++ /dev/null @@ -1,46 +0,0 @@ -; -; File: -; getvec.asm -; Description: -; get an interrupt vector - simple version -; -; Copyright (c) 1995 -; Pasquale J. Villani -; All Rights Reserved -; -; This file is part of DOS-C. -; -; DOS-C is free software; you can redistribute it and/or -; modify it under the terms of the GNU General Public License -; as published by the Free Software Foundation; either version -; 2, or (at your option) any later version. -; -; DOS-C is distributed in the hope that it will be useful, but -; WITHOUT ANY WARRANTY; without even the implied warranty of -; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See -; the GNU General Public License for more details. -; -; You should have received a copy of the GNU General Public -; License along with DOS-C; see the file COPYING. If not, -; write to the Free Software Foundation, 675 Mass Ave, -; Cambridge, MA 02139, USA. -; -; $Header$ -; - - %include "../kernel/segs.inc" - -segment HMA_TEXT - - global GETVEC -GETVEC: - pop ax ; return address - pop bx ; int # - push ax ; restore stack - add bx,bx - add bx,bx ; Multiply by 4 - xor dx,dx ; and set segment to 0 - mov es,dx - les ax,[es:bx] - mov dx,es - ret From 5dce77cd3bcc59e1d0e7a000a3321805ffa9da2f Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Mon, 10 May 2004 22:46:41 +0000 Subject: [PATCH 503/671] Do a bit of printf merging. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@931 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/initdisk.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/kernel/initdisk.c b/kernel/initdisk.c index 61d8ebf1..1bfb9b8b 100644 --- a/kernel/initdisk.c +++ b/kernel/initdisk.c @@ -355,9 +355,8 @@ void init_LBA_to_CHS(struct CHS *chs, ULONG LBA_address, void printCHS(char *title, struct CHS *chs) { - printf("%s", title); /* has no fixed size for head/sect: is often 1/1 in our context */ - printf("%4u-%u-%u", chs->Cylinder, chs->Head, chs->Sector); + printf("%s%4u-%u-%u", title, chs->Cylinder, chs->Head, chs->Sector); } /* @@ -626,21 +625,25 @@ void DosDefinePartition(struct DriveParamS *driveParam, if (InitKernelConfig.InitDiskShowDriveAssignment) { - LBA_to_CHS(&chs, StartSector, driveParam); + char *ExtPri; + int num; - printf("\r%c: HD%d", 'A' + nUnits, (driveParam->driveno & 0x7f) + 1); + LBA_to_CHS(&chs, StartSector, driveParam); + ExtPri = "Pri"; + num = PrimaryNum + 1; if (extendedPartNo) - printf(", Ext[%2d]", extendedPartNo); - else - printf(", Pri[%2d]", PrimaryNum + 1); + { + ExtPri = "Ext"; + num = extendedPartNo; + } + printf("\r%c: HD%d, %s[%2d]", 'A' + nUnits, + (driveParam->driveno & 0x7f) + 1, ExtPri, num); printCHS(", CHS= ", &chs); - printf(", start=%6lu MB, size=%6lu MB", + printf(", start=%6lu MB, size=%6lu MB\n", StartSector / 2048, pEntry->NumSect / 2048); - - printf("\n"); } nUnits++; From 6f145e98343cd38753785a485b0f833fa9605224 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Mon, 10 May 2004 23:53:56 +0000 Subject: [PATCH 504/671] inthndlr.c cleanups (merge common code into long_check and short_check), mostly from Lucho. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@932 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/inthndlr.c | 263 ++++++++++++++++------------------------------ 1 file changed, 90 insertions(+), 173 deletions(-) diff --git a/kernel/inthndlr.c b/kernel/inthndlr.c index 804d2255..bf9ebc14 100644 --- a/kernel/inthndlr.c +++ b/kernel/inthndlr.c @@ -383,6 +383,7 @@ int int21_fat32(lregs *r) VOID ASMCFUNC int21_service(iregs FAR * r) { COUNT rc = 0; + long lrc; lregs lr; /* 8 local registers (ax, bx, cx, dx, si, di, ds, es) */ #define FP_DS_DX (MK_FP(lr.DS, lr.DX)) @@ -476,8 +477,7 @@ VOID ASMCFUNC int21_service(iregs FAR * r) break; r->FLAGS &= ~FLG_ZERO; - lr.AL = read_char_stdin(FALSE); - break; + /* fall through */ /* Direct Console Input */ case 0x07: @@ -860,110 +860,64 @@ VOID ASMCFUNC int21_service(iregs FAR * r) /* Dos Create Directory */ case 0x39: - rc = DosMkdir((BYTE FAR *) FP_DS_DX); - if (rc != SUCCESS) - goto error_exit; - break; + rc = DosMkdir(FP_DS_DX); + goto short_check; /* Dos Remove Directory */ case 0x3a: - rc = DosRmdir((BYTE FAR *) FP_DS_DX); - if (rc != SUCCESS) - goto error_exit; - break; + rc = DosRmdir(FP_DS_DX); + goto short_check; /* Dos Change Directory */ case 0x3b: - if ((rc = DosChangeDir((BYTE FAR *) FP_DS_DX)) < 0) - goto error_exit; - break; + rc = DosChangeDir(FP_DS_DX); + goto short_check; /* Dos Create File */ case 0x3c: - { - long lrc = DosOpen(FP_DS_DX, O_LEGACY | O_RDWR | O_CREAT | O_TRUNC, lr.CL); - - if (lrc < 0) - { - rc = (COUNT)lrc; - goto error_exit; - } - lr.AX = (UWORD)lrc; - break; - } + lrc = DosOpen(FP_DS_DX, O_LEGACY | O_RDWR | O_CREAT | O_TRUNC, lr.CL); + goto long_check; /* Dos Open */ case 0x3d: - { - long lrc = DosOpen(FP_DS_DX, O_LEGACY | O_OPEN | lr.AL, 0); - - if (lrc < 0) - { - rc = (COUNT)lrc; - goto error_exit; - } - lr.AX = (UWORD)lrc; - break; - } + lrc = DosOpen(FP_DS_DX, O_LEGACY | O_OPEN | lr.AL, 0); + goto long_check; /* Dos Close */ case 0x3e: - if ((rc = DosClose(lr.BX)) < 0) - goto error_exit; - break; + rc = DosClose(lr.BX); + goto short_check; /* Dos Read */ - case 0x3f: - { - long lrc = DosRead(lr.BX, lr.CX, FP_DS_DX); - if (lrc < SUCCESS) - { - rc = (int)lrc; - goto error_exit; - } - lr.AX = (UWORD)lrc; - } - break; + case 0x3f: + lrc = DosRead(lr.BX, lr.CX, FP_DS_DX); + goto long_check; /* Dos Write */ case 0x40: - { - long lrc = DosWrite(lr.BX, lr.CX, FP_DS_DX); - if (lrc < SUCCESS) - { - rc = (int)lrc; - goto error_exit; - } - lr.AX = (UWORD)lrc; - } - break; + lrc = DosWrite(lr.BX, lr.CX, FP_DS_DX); + goto long_check; /* Dos Delete File */ case 0x41: rc = DosDelete((BYTE FAR *) FP_DS_DX, D_ALL); - if (rc < 0) - goto error_exit; - break; + goto short_check; /* Dos Seek */ case 0x42: + if (lr.AL > 2) + goto error_invalid; + lrc = DosSeek(lr.BX, (LONG)((((ULONG) (lr.CX)) << 16) | lr.DX), lr.AL); + if (lrc == -1) { - ULONG lrc; - if (lr.AL > 2) - goto error_invalid; - lrc = DosSeek(lr.BX, (LONG)((((ULONG) (lr.CX)) << 16) | lr.DX), lr.AL); - if (lrc == (ULONG)-1) - { - rc = -DE_INVLDHNDL; - goto error_exit; - } - else - { - lr.DX = (UWORD)(lrc >> 16); - lr.AX = (UWORD) lrc; - } + lrc = -DE_INVLDHNDL; } - break; + else + { + lr.DX = (UWORD)(lrc >> 16); + lrc = (UWORD) lrc; + } + goto long_check; /* Get/Set File Attributes */ case 0x43: @@ -984,9 +938,7 @@ VOID ASMCFUNC int21_service(iregs FAR * r) default: goto error_invalid; } - if (rc < SUCCESS) - goto error_exit; - break; + goto short_check; /* Device I/O Control */ case 0x44: @@ -1003,31 +955,21 @@ VOID ASMCFUNC int21_service(iregs FAR * r) /* Duplicate File Handle */ case 0x45: - { - long lrc = DosDup(lr.BX); - if (lrc < SUCCESS) - { - rc = (COUNT)lrc; - goto error_exit; - } - lr.AX = (UWORD)lrc; - } - break; + lrc = DosDup(lr.BX); + goto long_check; /* Force Duplicate File Handle */ case 0x46: rc = DosForceDup(lr.BX, lr.CX); - if (rc < SUCCESS) - goto error_exit; + goto short_check; break; /* Get Current Directory */ case 0x47: - if ((rc = DosGetCuDir(lr.DL, MK_FP(lr.DS, lr.SI))) < 0) - goto error_exit; - else + rc = DosGetCuDir(lr.DL, MK_FP(lr.DS, lr.SI)); + if (rc >= SUCCESS) lr.AX = 0x0100; /*jpp: from interrupt list */ - break; + goto short_check; /* Allocate memory */ case 0x48: @@ -1082,9 +1024,8 @@ VOID ASMCFUNC int21_service(iregs FAR * r) case 0x4b: break_flg = FALSE; - if ((rc = DosExec(lr.AL, MK_FP(lr.ES, lr.BX), FP_DS_DX)) != SUCCESS) - goto error_exit; - break; + rc = DosExec(lr.AL, MK_FP(lr.ES, lr.BX), FP_DS_DX); + goto short_check; /* Terminate Program */ case 0x00: @@ -1129,19 +1070,19 @@ VOID ASMCFUNC int21_service(iregs FAR * r) case 0x4e: /* dta for this call is set on entry. This */ /* needs to be changed for new versions. */ - if ((rc = DosFindFirst((UCOUNT) lr.CX, (BYTE FAR *) FP_DS_DX)) < 0) - goto error_exit; - lr.AX = 0; - break; + rc = DosFindFirst(lr.CX, FP_DS_DX); + if (rc >= SUCCESS) + lr.AX = 0; + goto short_check; /* Dos Find Next */ case 0x4f: /* dta for this call is set on entry. This */ /* needs to be changed for new versions. */ - if ((rc = DosFindNext()) < 0) - goto error_exit; - lr.AX = -SUCCESS; - break; + rc = DosFindNext(); + if (rc >= SUCCESS) + lr.AX = 0; + goto short_check; /* case 0x50: case 0x51: @@ -1178,11 +1119,8 @@ VOID ASMCFUNC int21_service(iregs FAR * r) /* Dos Rename */ case 0x56: - rc = DosRename((BYTE FAR *) FP_DS_DX, - (BYTE FAR *) FP_ES_DI); - if (rc < SUCCESS) - goto error_exit; - break; + rc = DosRename(FP_DS_DX, FP_ES_DI); + goto short_check; /* Get/Set File Date and Time */ case 0x57: @@ -1192,22 +1130,18 @@ VOID ASMCFUNC int21_service(iregs FAR * r) rc = DosGetFtime((COUNT) lr.BX, /* Handle */ &lr.DX, /* FileDate */ &lr.CX); /* FileTime */ - if (rc < SUCCESS) - goto error_exit; break; case 0x01: rc = DosSetFtime((COUNT) lr.BX, /* Handle */ (date) lr.DX, /* FileDate */ (time) lr.CX); /* FileTime */ - if (rc < SUCCESS) - goto error_exit; break; default: goto error_invalid; } - break; + goto short_check; /* Get/Set Allocation Strategy */ case 0x58: @@ -1266,16 +1200,8 @@ VOID ASMCFUNC int21_service(iregs FAR * r) /* Create New File */ case 0x5b: - { - long lrc = DosOpen(FP_DS_DX, O_LEGACY | O_RDWR | O_CREAT, lr.CX); - if (lrc < 0) - { - rc = (COUNT)lrc; - goto error_exit; - } - lr.AX = (UWORD)lrc; - break; - } + lrc = DosOpen(FP_DS_DX, O_LEGACY | O_RDWR | O_CREAT, lr.CX); + goto long_check; /* /// Added for SHARE. - Ron Cemer */ /* Lock/unlock file access */ @@ -1378,9 +1304,8 @@ VOID ASMCFUNC int21_service(iregs FAR * r) break; case 0x60: /* TRUENAME */ - if ((rc = DosTruename(MK_FP(lr.DS, lr.SI), adjust_far(FP_ES_DI))) < SUCCESS) - goto error_exit; - break; + rc = DosTruename(MK_FP(lr.DS, lr.SI), adjust_far(FP_ES_DI)); + goto short_check; #ifdef TSC /* UNDOCUMENTED: no-op */ @@ -1453,19 +1378,18 @@ VOID ASMCFUNC int21_service(iregs FAR * r) lr.AX = DosYesNo(lr.DL); break; default: - if ((rc = DosGetData(lr.AL, lr.BX, lr.DX, lr.CX, - FP_ES_DI)) < 0) - { #ifdef NLS_DEBUG + if ((rc = DosGetData(lr.AL, lr.BX, lr.DX, lr.CX, FP_ES_DI)) < 0) + { printf("DosGetData() := %d\n", rc); -#endif goto error_exit; } -#ifdef NLS_DEBUG printf("DosGetData() returned successfully\n", rc); -#endif - break; +#else + rc = DosGetData(lr.AL, lr.BX, lr.DX, lr.CX, FP_ES_DI); + goto short_check; +#endif } break; @@ -1489,16 +1413,14 @@ VOID ASMCFUNC int21_service(iregs FAR * r) /* Set Max file handle count */ case 0x67: - if ((rc = SetJFTSize(lr.BX)) != SUCCESS) - goto error_exit; - break; + rc = SetJFTSize(lr.BX); + goto short_check; /* Flush file buffer -- COMMIT FILE. */ case 0x68: case 0x6a: - if ((rc = DosCommit(lr.BX)) < 0) - goto error_exit; - break; + rc = DosCommit(lr.BX); + goto short_check; /* Get/Set Serial Number */ case 0x69: @@ -1516,9 +1438,7 @@ VOID ASMCFUNC int21_service(iregs FAR * r) lr.AL = 0x0d; rc = DosDevIOctl(&lr); lr.CX = saveCX; - if (rc != SUCCESS) - goto error_exit; - break; + goto short_check; } } else @@ -1530,28 +1450,16 @@ VOID ASMCFUNC int21_service(iregs FAR * r) */ /* Extended Open-Creat, not fully functional. (bits 4,5,6 of BH) */ case 0x6c: - { - long lrc; - - /* high nibble must be <= 1, low nibble must be <= 2 */ - if ((lr.DL & 0xef) > 0x2) - goto error_invalid; - lrc = DosOpen(MK_FP(lr.DS, lr.SI), - (lr.BX & 0x70ff) | ((lr.DL & 3) << 8) | - ((lr.DL & 0x10) << 6), lr.CL); - if (lrc < 0) - { - rc = (COUNT)lrc; - goto error_exit; - } - else - { - lr.AX = (UWORD)lrc; - /* action */ - lr.CX = (UWORD)(lrc >> 16); - } - break; - } + /* high nibble must be <= 1, low nibble must be <= 2 */ + if ((lr.DL & 0xef) > 0x2) + goto error_invalid; + lrc = DosOpen(MK_FP(lr.DS, lr.SI), + (lr.BX & 0x70ff) | ((lr.DL & 3) << 8) | + ((lr.DL & 0x10) << 6), lr.CL); + if (lrc >= SUCCESS) + /* action */ + lr.CX = (UWORD)(lrc >> 16); + goto long_check; /* case 0x6d and above not implemented : see default; return AL=0 */ @@ -1566,11 +1474,9 @@ VOID ASMCFUNC int21_service(iregs FAR * r) CLEAR_CARRY_FLAG(); CritErrCode = SUCCESS; rc = int21_fat32(&lr); - if (rc != SUCCESS) - goto error_exit; - break; + goto short_check; #endif - + #ifdef WITHLFNAPI /* FreeDOS LFN helper API functions */ case 0x74: @@ -1612,7 +1518,18 @@ VOID ASMCFUNC int21_service(iregs FAR * r) #endif } goto exit_dispatch; - +long_check: + if (lrc < SUCCESS) + { + rc = (int)lrc; + goto error_exit; + } + lr.AX = (UWORD)lrc; + goto exit_dispatch; +short_check: + if (rc < SUCCESS) + goto error_exit; + goto exit_dispatch; error_invalid: rc = DE_INVLDFUNC; error_exit: From 5a738a96953530b7b1a33441283bb96818b7889c Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Tue, 11 May 2004 10:33:17 +0000 Subject: [PATCH 505/671] Remove redundant "break". git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@933 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/inthndlr.c | 1 - 1 file changed, 1 deletion(-) diff --git a/kernel/inthndlr.c b/kernel/inthndlr.c index bf9ebc14..764b39ea 100644 --- a/kernel/inthndlr.c +++ b/kernel/inthndlr.c @@ -962,7 +962,6 @@ VOID ASMCFUNC int21_service(iregs FAR * r) case 0x46: rc = DosForceDup(lr.BX, lr.CX); goto short_check; - break; /* Get Current Directory */ case 0x47: From 8703b2574be8e25c5cd6a1671473178a53301837 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Tue, 11 May 2004 10:46:42 +0000 Subject: [PATCH 506/671] Need to define strchr to init_strchr otherwise the wrong one may be called. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@934 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/init-mod.h | 1 + 1 file changed, 1 insertion(+) diff --git a/kernel/init-mod.h b/kernel/init-mod.h index 0dc72edf..15380ea8 100644 --- a/kernel/init-mod.h +++ b/kernel/init-mod.h @@ -56,6 +56,7 @@ extern struct _KernelConfig InitKernelConfig; #define fmemcmp init_fmemcmp #define memcmp init_memcmp #define memset init_memset +#define strchr init_strchr #define strcpy init_strcpy #define strlen init_strlen #define fstrlen init_fstrlen From 090bd524f50766ac96c45c53a51d716bbb0c48b5 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Tue, 11 May 2004 10:57:57 +0000 Subject: [PATCH 507/671] Turbo C really wants unsigned __brklvl. Only shows up if you enable stack checking. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@935 6ac86273-5f31-0410-b378-82cca8765d1b --- sys/talloc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sys/talloc.c b/sys/talloc.c index 83bcc6d6..5b7b64a7 100644 --- a/sys/talloc.c +++ b/sys/talloc.c @@ -18,12 +18,12 @@ #include #ifdef __TURBOC__ -extern void *__brklvl; -#define sbrk(x) __brklvl +extern unsigned __brklvl; +#define sbrk(x) ((void *)__brklvl) #define brk(newbrk) \ (((char *)(newbrk) > (char *)(&length) - 0x200) ? \ -1 : \ - (__brklvl = (newbrk), 0)) + (__brklvl = (unsigned)(newbrk), 0)) #endif #ifdef __WATCOMC__ From 8b66884304b8f03bb4448147b3da6473caff8d4c Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sun, 23 May 2004 14:04:52 +0000 Subject: [PATCH 508/671] Some small optimizations (46 bytes) and dead code removal from Lucho and Bart git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@936 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/memmgr.c | 87 +++++++++---------------------------------------- 1 file changed, 15 insertions(+), 72 deletions(-) diff --git a/kernel/memmgr.c b/kernel/memmgr.c index 3a0a62db..f641b437 100644 --- a/kernel/memmgr.c +++ b/kernel/memmgr.c @@ -34,7 +34,7 @@ static BYTE *memmgrRcsId = "$Id$"; #endif -#define nxtMCBsize(mcb,size) MK_FP(FP_SEG(mcb) + (size) + 1, 0) +#define nxtMCBsize(mcb,size) MK_FP(FP_SEG(mcb) + (size) + 1, FP_OFF(mcb)) #define nxtMCB(mcb) nxtMCBsize((mcb), (mcb)->m_size) #define mcbFree(mcb) ((mcb)->m_psp == FREE_PSP) @@ -49,14 +49,18 @@ static BYTE *memmgrRcsId = * SUCCESS: on success * else: error number <> */ -STATIC COUNT joinMCBs(mcb FAR * p) +STATIC COUNT joinMCBs(seg para) { + mcb FAR *p = para2far(para); mcb FAR *q; /* loop as long as the current MCB is not the last one in the chain and the next MCB is unused */ - while (p->m_type == MCB_NORMAL && mcbFree(q = nxtMCB(p))) + while (p->m_type == MCB_NORMAL) { + q = nxtMCB(p); + if (!mcbFree(q)) + break; if (!mcbValid(q)) return DE_MCBDESTRY; /* join both MCBs */ @@ -132,7 +136,7 @@ COUNT DosMemAlloc(UWORD size, COUNT mode, seg *para, UWORD *asize) if (mcbFree(p)) { /* unused block, check if it applies to the rule */ - if (joinMCBs(p) != SUCCESS) /* join following unused blocks */ + if (joinMCBs(FP_SEG(p)) != SUCCESS) /* join following unused blocks */ return DE_MCBDESTRY; /* error */ if (!biggestSeg || biggestSeg->m_size < p->m_size) @@ -219,10 +223,10 @@ COUNT DosMemAlloc(UWORD size, COUNT mode, seg *para, UWORD *asize) else { /* all other modes allocate from the beginning */ p = nxtMCBsize(foundSeg, size); - p->m_size = foundSeg->m_size - size - 1; /* initialize stuff because p > foundSeg */ p->m_type = foundSeg->m_type; + p->m_size = foundSeg->m_size - size - 1; foundSeg->m_type = MCB_NORMAL; } @@ -293,33 +297,6 @@ COUNT DosMemFree(UWORD para) p->m_psp = FREE_PSP; fmemset(p->m_name, '\0', 8); -#if 0 - /* Moved into allocating functions -- 1999/04/21 ska */ - /* Now merge free blocks */ - - for (p = (mcb FAR *) (MK_FP(first_mcb, 0)); p->m_type != MCB_LAST; p = q) - { - /* make q a pointer to the next block */ - q = nxtMCB(p); - /* and test for corruption */ - if (q->m_type != MCB_NORMAL && q->m_type != MCB_LAST) - return DE_MCBDESTRY; - if (p->m_psp != FREE_PSP) - continue; - - /* test if next is free - if so merge */ - if (q->m_psp == FREE_PSP) - { - /* Always flow type down on free */ - p->m_type = q->m_type; - p->m_size += q->m_size + 1; - /* and make pointers the same */ - /* since the next free is now */ - /* this block */ - q = p; - } - } -#endif return SUCCESS; } @@ -347,7 +324,7 @@ COUNT DosMemChange(UWORD para, UWORD size, UWORD * maxSize) { /* first try to make the MCB larger by joining with any following unused blocks */ - if (joinMCBs(p) != SUCCESS) + if (joinMCBs(FP_SEG(p)) != SUCCESS) return DE_MCBDESTRY; if (size > p->m_size) @@ -364,8 +341,8 @@ COUNT DosMemChange(UWORD para, UWORD size, UWORD * maxSize) /* make q a pointer to the new next block */ q = nxtMCBsize(p, size); /* reduce the size of p and add difference to q */ - q->m_type = p->m_type; q->m_size = p->m_size - size - 1; + q->m_type = p->m_type; p->m_size = size; @@ -378,7 +355,7 @@ COUNT DosMemChange(UWORD para, UWORD size, UWORD * maxSize) fmemset(q->m_name, '\0', 8); /* try to join q with the free mcb's following it if possible */ - if (joinMCBs(q) != SUCCESS) + if (joinMCBs(FP_SEG(q)) != SUCCESS) return DE_MCBDESTRY; } @@ -448,38 +425,6 @@ COUNT FreeProcessMem(UWORD ps) return SUCCESS; } -#if 0 - /* seems to be superceeded by DosMemLargest - -- 1999/04/21 ska */ -COUNT DosGetLargestBlock(UWORD FAR * block) -{ - UWORD sz = 0; - mcb FAR *p; - *block = sz; - - /* Initialize */ - p = (mcb FAR *) (MK_FP(first_mcb, 0)); - - /* Search through memory blocks */ - for (;;) - { - /* check for corruption */ - if (p->m_type != MCB_NORMAL && p->m_type != MCB_LAST) - return DE_MCBDESTRY; - - if (p->m_psp == FREE_PSP && p->m_size > sz) - sz = p->m_size; - - /* not corrupted - if last we're OK! */ - if (p->m_type == MCB_LAST) - break; - p = nxtMCB(p); - } - *block = sz; - return SUCCESS; -} -#endif - #ifdef DEBUG VOID show_chain(void) { @@ -525,9 +470,9 @@ VOID DosUmbLink(BYTE n) while (FP_SEG(p) != uppermem_root) { if (mcbFree(p)) - joinMCBs(p); + joinMCBs(FP_SEG(p)); if (!mcbValid(p)) - goto DUL_exit; + return; q = p; p = nxtMCB(p); } @@ -542,15 +487,13 @@ VOID DosUmbLink(BYTE n) while (q->m_type != MCB_LAST) { if (!mcbValid(q)) - goto DUL_exit; + return; q = nxtMCB(q); } q->m_type = MCB_NORMAL; uppermem_link = n; } -DUL_exit: - return; } #endif From b5e261687723f47085b869dfa81e0c188089ed3f Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sun, 23 May 2004 14:10:39 +0000 Subject: [PATCH 509/671] Merge dosmkdir and dosrmdir (mostly from Lucho) git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@937 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/dosfns.c | 27 +++------------------------ kernel/inthndlr.c | 5 +---- kernel/proto.h | 3 +-- 3 files changed, 5 insertions(+), 30 deletions(-) diff --git a/kernel/dosfns.c b/kernel/dosfns.c index 51bfc847..52b7ca08 100644 --- a/kernel/dosfns.c +++ b/kernel/dosfns.c @@ -1327,7 +1327,7 @@ COUNT DosRename(BYTE FAR * path1, BYTE FAR * path2) return DosRenameTrue(PriPathName, SecPathName, D_ALL); } -COUNT DosMkdir(const char FAR * dir) +COUNT DosMkRmdir(const char FAR * dir, int action) { COUNT result; @@ -1336,33 +1336,12 @@ COUNT DosMkdir(const char FAR * dir) return result; if (result & IS_NETWORK) - return network_redirector(REM_MKDIR); + return network_redirector(action == 0x39 ? REM_MKDIR : REM_RMDIR); if (result & IS_DEVICE) return DE_ACCESS; - return dos_mkdir(PriPathName); -} - -/* This function is almost identical to DosMkdir(). - Maybe it would be nice to merge both functions. - -- 2001/09/03 ska*/ -COUNT DosRmdir(const char FAR * dir) -{ - COUNT result; - - result = truename(dir, PriPathName, CDS_MODE_CHECK_DEV_PATH); - - if (result < SUCCESS) - return result; - - if (result & IS_NETWORK) - return network_redirector(REM_RMDIR); - - if (result & IS_DEVICE) - return DE_ACCESS; - - return dos_rmdir(PriPathName); + return (action == 0x39 ? dos_mkdir : dos_rmdir)(PriPathName); } /* /// Added for SHARE. - Ron Cemer */ diff --git a/kernel/inthndlr.c b/kernel/inthndlr.c index 764b39ea..fcf3d53e 100644 --- a/kernel/inthndlr.c +++ b/kernel/inthndlr.c @@ -860,12 +860,9 @@ VOID ASMCFUNC int21_service(iregs FAR * r) /* Dos Create Directory */ case 0x39: - rc = DosMkdir(FP_DS_DX); - goto short_check; - /* Dos Remove Directory */ case 0x3a: - rc = DosRmdir(FP_DS_DX); + rc = DosMkRmdir(FP_DS_DX, lr.AL); goto short_check; /* Dos Change Directory */ diff --git a/kernel/proto.h b/kernel/proto.h index abe7bb7a..6c2cbb34 100644 --- a/kernel/proto.h +++ b/kernel/proto.h @@ -112,8 +112,7 @@ UBYTE DosSelectDrv(UBYTE drv); COUNT DosDelete(BYTE FAR * path, int attrib); COUNT DosRename(BYTE FAR * path1, BYTE FAR * path2); COUNT DosRenameTrue(BYTE * path1, BYTE * path2, int attrib); -COUNT DosMkdir(const char FAR * dir); -COUNT DosRmdir(const char FAR * dir); +COUNT DosMkRmdir(const char FAR * dir, int action); struct dhdr FAR *IsDevice(const char FAR * FileName); BOOL IsShareInstalled(void); COUNT DosLockUnlock(COUNT hndl, LONG pos, LONG len, COUNT unlock); From 91b35151627d9bb55d87ee37b9b93272de51ffd8 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sun, 23 May 2004 14:17:36 +0000 Subject: [PATCH 510/671] From Lucho: replace loops by fmemset/fmemcpy (43 bytes) git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@938 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/newstuff.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/kernel/newstuff.c b/kernel/newstuff.c index f8c8064e..8a548931 100644 --- a/kernel/newstuff.c +++ b/kernel/newstuff.c @@ -42,7 +42,6 @@ int SetJFTSize(UWORD nHandles) UWORD block, maxBlock; psp FAR *ppsp = MK_FP(cu_psp, 0); UBYTE FAR *newtab; - COUNT i; if (nHandles <= ppsp->ps_maxfiles) { @@ -57,11 +56,8 @@ int SetJFTSize(UWORD nHandles) ++block; newtab = MK_FP(block, 0); - for (i = 0; i < ppsp->ps_maxfiles; i++) - newtab[i] = ppsp->ps_filetab[i]; - - for (; i < nHandles; i++) - newtab[i] = 0xff; + fmemset(newtab, 0xff, nHandles); + fmemcpy(newtab, ppsp->ps_filetab, ppsp->ps_maxfiles); ppsp->ps_maxfiles = nHandles; ppsp->ps_filetab = newtab; From 4c116b0201387794455bb5a845242398f9bb1a75 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sun, 23 May 2004 14:24:32 +0000 Subject: [PATCH 511/671] Pointer-ize MenuStruct[MenuSelected]... (from Lucho). and InstallCommands[i]. (from Bart). Some other small optimizations. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@939 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/config.c | 80 ++++++++++++++++++++++++++----------------------- 1 file changed, 43 insertions(+), 37 deletions(-) diff --git a/kernel/config.c b/kernel/config.c index 8249066a..33b62c70 100644 --- a/kernel/config.c +++ b/kernel/config.c @@ -61,33 +61,33 @@ struct MenuSelector STATIC struct MenuSelector MenuStruct[MENULINESMAX] BSS_INIT({0}); int nMenuLine BSS_INIT(0); -BOOL MenuColor = -1; +int MenuColor = -1; -STATIC void WriteMenuLine(int MenuSelected) +STATIC void WriteMenuLine(struct MenuSelector *menu) { iregs r; unsigned char attr = (unsigned char)MenuColor; - char *pText = MenuStruct[MenuSelected].Text; + char *pText = menu->Text; if (pText[0] == 0) return; - if(MenuStruct[MenuSelected].bSelected==1) + if(menu->bSelected) attr = ((attr << 4) | (attr >> 4)); /* clear line */ r.a.x = 0x0600; r.b.b.h = attr; - r.c.b.l = r.d.b.l = MenuStruct[MenuSelected].x; - r.c.b.h = r.d.b.h = MenuStruct[MenuSelected].y; + r.c.b.l = r.d.b.l = menu->x; + r.c.b.h = r.d.b.h = menu->y; r.d.b.l += strlen(pText) - 1; init_call_intr(0x10, &r); /* set cursor position: */ r.a.b.h = 0x02; r.b.b.h = 0; - r.d.b.l = MenuStruct[MenuSelected].x; - r.d.b.h = MenuStruct[MenuSelected].y; + r.d.b.l = menu->x; + r.d.b.h = menu->y; init_call_intr(0x10, &r); printf("%s", pText); @@ -96,14 +96,14 @@ STATIC void WriteMenuLine(int MenuSelected) /* Deselect the previously selected line */ STATIC void DeselectLastLine(void) { - int i; - for (i = 0 ; i < MENULINESMAX; i++) + struct MenuSelector *menu; + for (menu = MenuStruct; menu < &MenuStruct[MENULINESMAX]; menu++) { - if (MenuStruct[i].bSelected == 1) + if (menu->bSelected) { /* deselect it: */ - MenuStruct[i].bSelected = 0; - WriteMenuLine(i); + menu->bSelected = 0; + WriteMenuLine(menu); break; } } @@ -111,9 +111,12 @@ STATIC void DeselectLastLine(void) STATIC void SelectLine(int MenuSelected) { + struct MenuSelector *menu; + DeselectLastLine(); /* clear previous selection */ - MenuStruct[MenuSelected].bSelected = 1; /* set selection flag for this one */ - WriteMenuLine(MenuSelected); + menu = &MenuStruct[MenuSelected]; + menu->bSelected = 1; /* set selection flag for this one */ + WriteMenuLine(menu); } UWORD umb_start BSS_INIT(0), UMB_top BSS_INIT(0); @@ -1815,10 +1818,10 @@ STATIC VOID CfgMenu(BYTE * pLine) /* now I'm expecting a number here if this is a menu-choice line. */ if (isnum(pLine[0])) { - int nIndex = pLine[0]-'0'; + struct MenuSelector *menu = &MenuStruct[pLine[0]-'0']; - MenuStruct[nIndex].x = (pLine-pNumber); /* xpos is at start of number */ - MenuStruct[nIndex].y = nMenuLine; + menu->x = (pLine-pNumber); /* xpos is at start of number */ + menu->y = nMenuLine; /* copy menu text: */ nLen = findend(pLine); /* length is until cr/lf, null or three spaces */ @@ -1826,8 +1829,8 @@ STATIC VOID CfgMenu(BYTE * pLine) (change struct at top of file if you want more...) */ if (nLen > MENULINEMAX-1) nLen = MENULINEMAX-1; - memcpy(MenuStruct[nIndex].Text, pLine, nLen); - MenuStruct[nIndex].Text[nLen] = 0; /* nullTerminate */ + memcpy(menu->Text, pLine, nLen); + menu->Text[nLen] = 0; /* nullTerminate */ } nMenuLine++; } @@ -1856,7 +1859,7 @@ STATIC VOID DoMenu(void) for (;;) { - int i; + int i, j; RestartInput: @@ -1875,18 +1878,18 @@ STATIC VOID DoMenu(void) printf("Select from Menu ["); - for (i = 0; i <= 9; i++) - if (Menus & (1 << i)) + for (i = 0, j = 1; i <= 9; i++, j<<=1) + if (Menus & j) printf("%c", '0' + i); printf("], or press [ENTER]"); if (MenuColor != -1) - printf(" (Selection=%d)", MenuSelected); + printf(" (Selection=%d) ", MenuSelected); if (MenuTimeout >= 0) - printf(" - %d \b", MenuTimeout); + printf("- %d \b", MenuTimeout); else - printf(" \b\b\b\b\b"); + printf(" \b\b\b\b\b"); if (MenuColor != -1) printf("\r\n\n "); @@ -1981,16 +1984,16 @@ STATIC void ClearScreen(unsigned char attr) { /* scroll down (newlines): */ iregs r; - unsigned char columns, rows; + unsigned char rows; /* clear */ r.a.x = 0x0600; r.b.b.h = attr; r.c.x = 0; - columns = peekb(0x40, 0x4a) - 1; + r.d.b.l = peekb(0x40, 0x4a) - 1; /* columns */ rows = peekb(0x40, 0x84); if (rows == 0) rows = 24; - r.d.x = rows * 0x100 + columns; + r.d.b.h = rows; init_call_intr(0x10, &r); /* move cursor to pos 0,0: */ @@ -2500,6 +2503,8 @@ struct instCmds { STATIC VOID _CmdInstall(BYTE * pLine,int mode) { + struct instCmds *cmd; + InstallPrintf(("Installcmd %d:%s\n",numInstallCmds,pLine)); if (numInstallCmds > LENGTH(InstallCommands)) @@ -2508,9 +2513,10 @@ STATIC VOID _CmdInstall(BYTE * pLine,int mode) CfgFailure(pLine); return; } - memcpy(InstallCommands[numInstallCmds].buffer,pLine,127); - InstallCommands[numInstallCmds].buffer[127] = 0; - InstallCommands[numInstallCmds].mode = mode; + cmd = &InstallCommands[numInstallCmds]; + memcpy(cmd->buffer,pLine,127); + cmd->buffer[127] = 0; + cmd->mode = mode; numInstallCmds++; } STATIC VOID CmdInstall(BYTE * pLine) @@ -2580,7 +2586,7 @@ VOID DoInstall(void) { int i; unsigned short installMemory; - + struct instCmds *cmd; if (numInstallCmds == 0) return; @@ -2598,11 +2604,11 @@ VOID DoInstall(void) InstallPrintf(("allocated memory at %x\n",installMemory)); - for (i = 0; i < numInstallCmds; i++) + for (i = 0, cmd = InstallCommands; i < numInstallCmds; i++, cmd++) { - InstallPrintf(("%d:%s\n",i,InstallCommands[i].buffer)); - set_strategy(InstallCommands[i].mode); - InstallExec(&InstallCommands[i]); + InstallPrintf(("%d:%s\n",i,cmd->buffer)); + set_strategy(cmd->mode); + InstallExec(cmd); } set_strategy(FIRST_FIT); free(installMemory); From 2cdf880b855c7cd4fedf325a3ecdb578b36c2f5b Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sun, 23 May 2004 14:45:27 +0000 Subject: [PATCH 512/671] From Lucho: moved fmemcmp's into a checkHMA function. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@940 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/inithma.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/kernel/inithma.c b/kernel/inithma.c index 34b39932..58e8057f 100644 --- a/kernel/inithma.c +++ b/kernel/inithma.c @@ -118,12 +118,17 @@ VOID hdump(BYTE FAR * p) if so, it simply leaves it on */ +STATIC int checkHMA(void) +{ + return fmemcmp(MK_FP(0, 0), MK_FP(0xffff, 0x0010), 128); +} + int EnableHMA(VOID) { _EnableA20(); - if (fmemcmp(MK_FP(0x0000, 0x0000), MK_FP(0xffff, 0x0010), 128) == 0) + if (!checkHMA()) { printf("HMA can't be enabled\n"); return FALSE; @@ -132,14 +137,14 @@ int EnableHMA(VOID) _DisableA20(); #ifdef DEBUG - if (fmemcmp(MK_FP(0x0000, 0x0000), MK_FP(0xffff, 0x0010), 128) != 0) + if (!checkHMA()) { printf("HMA can't be disabled - no problem for us\n"); } #endif _EnableA20(); - if (fmemcmp(MK_FP(0x0000, 0x0000), MK_FP(0xffff, 0x0010), 128) == 0) + if (!checkHMA()) { printf("HMA can't be enabled second time\n"); return FALSE; From 42c0af3aee5fa11d3935cb252d2f0333b894eddd Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sun, 23 May 2004 14:49:11 +0000 Subject: [PATCH 513/671] Inlined dos_setdta. Various bug fixes and cleanups from Lucho and Arkady. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@941 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/fatfs.c | 5 ----- kernel/inthndlr.c | 56 +++++++++++++++++------------------------------ kernel/proto.h | 1 - 3 files changed, 20 insertions(+), 42 deletions(-) diff --git a/kernel/fatfs.c b/kernel/fatfs.c index b7d22f63..2da302f2 100644 --- a/kernel/fatfs.c +++ b/kernel/fatfs.c @@ -1944,11 +1944,6 @@ VOID release_f_node(f_node_ptr fnp) } #ifndef IPL -VOID dos_setdta(BYTE FAR * newdta) -{ - dta = newdta; -} - COUNT dos_getfattr_fd(COUNT fd) { f_node_ptr fnp = xlt_fd(fd); diff --git a/kernel/inthndlr.c b/kernel/inthndlr.c index fcf3d53e..2d2349a8 100644 --- a/kernel/inthndlr.c +++ b/kernel/inthndlr.c @@ -353,7 +353,7 @@ int int21_fat32(lregs *r) return DE_INVLDPARM; } - if (r->DL - 1 >= lastdrive || r->DL == 0) + if (r->DL > lastdrive || r->DL == 0) return -0x207; if (r->SI == 0) @@ -608,7 +608,7 @@ VOID ASMCFUNC int21_service(iregs FAR * r) /* Set DTA */ case 0x1a: - dos_setdta(FP_DS_DX); + dta = FP_DS_DX; break; /* Get Default Drive Data */ @@ -907,7 +907,7 @@ VOID ASMCFUNC int21_service(iregs FAR * r) lrc = DosSeek(lr.BX, (LONG)((((ULONG) (lr.CX)) << 16) | lr.DX), lr.AL); if (lrc == -1) { - lrc = -DE_INVLDHNDL; + lrc = DE_INVLDHNDL; } else { @@ -1266,23 +1266,16 @@ VOID ASMCFUNC int21_service(iregs FAR * r) if (lr.AL == 7 || lr.AL == 8) { struct cds FAR *cdsp; - if (lr.DL < lastdrive) + if (lr.DL >= lastdrive) { rc = DE_INVLDDRV; goto error_exit; } + cdsp = &CDSp[lr.DL]; + if (lr.AL == 7) + cdsp->cdsFlags |= CDSPHYSDRV; else - { - cdsp = &CDSp[lr.DL]; - if (lr.AL == 7) - { - cdsp->cdsFlags |= 0x100; - } - else - { - cdsp->cdsFlags &= ~0x100; - } - } + cdsp->cdsFlags &= ~CDSPHYSDRV; } else { @@ -1380,7 +1373,7 @@ VOID ASMCFUNC int21_service(iregs FAR * r) printf("DosGetData() := %d\n", rc); goto error_exit; } - printf("DosGetData() returned successfully\n", rc); + printf("DosGetData() returned successfully\n"); break; #else rc = DosGetData(lr.AL, lr.BX, lr.DX, lr.CX, FP_ES_DI); @@ -1421,15 +1414,16 @@ VOID ASMCFUNC int21_service(iregs FAR * r) /* Get/Set Serial Number */ case 0x69: rc = (lr.BL == 0 ? default_drive : lr.BL - 1); - if (lr.AL == 0 || lr.AL == 1) + if (lr.AL < 2) { - UWORD saveCX = lr.CX; if (get_cds(rc) == NULL) + { rc = DE_INVLDDRV; - else if (get_dpb(rc) == NULL) - goto error_invalid; - else + goto error_exit; + } + if (get_dpb(rc) != NULL) { + UWORD saveCX = lr.CX; lr.CX = lr.AL == 0 ? 0x0866 : 0x0846; lr.AL = 0x0d; rc = DosDevIOctl(&lr); @@ -1437,9 +1431,7 @@ VOID ASMCFUNC int21_service(iregs FAR * r) goto short_check; } } - else - goto error_invalid; - break; + goto error_invalid; /* case 0x6a: see case 0x68 case 0x6b: dummy func: return AL=0 @@ -1631,21 +1623,14 @@ VOID ASMCFUNC int2526_handler(WORD mode, struct int25regs FAR * r) r->ax = dskxfer(drv, blkno, buf, nblks, mode); - if (mode == DSKWRITE) - if (r->ax <= 0) - setinvld(drv); - - if (r->ax > 0) + r->flags &= ~FLG_CARRY; + if (r->ax != 0) { r->flags |= FLG_CARRY; - --InDOS; - return; + if (mode == DSKWRITEINT26) + setinvld(drv); } - - r->ax = 0; - r->flags &= ~FLG_CARRY; --InDOS; - } /* @@ -1932,7 +1917,6 @@ VOID ASMCFUNC int2F_12_handler(struct int2f12regs r) put_unsigned(r.AL, 16, 2); put_string("\n"); r.FLAGS |= FLG_CARRY; - break; } } } diff --git a/kernel/proto.h b/kernel/proto.h index 6c2cbb34..7eb70c66 100644 --- a/kernel/proto.h +++ b/kernel/proto.h @@ -182,7 +182,6 @@ int dos_cd(char * PathName); f_node_ptr get_f_node(void); VOID release_f_node(f_node_ptr fnp); #define release_near_f_node(fnp) ((fnp)->f_count = 0) -VOID dos_setdta(BYTE FAR * newdta); COUNT dos_getfattr_fd(COUNT fd); COUNT dos_getfattr(BYTE * name); COUNT dos_setfattr(BYTE * name, UWORD attrp); From de5bed6d289b8008669f65a3de32824377d1fe2c Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sun, 23 May 2004 15:00:37 +0000 Subject: [PATCH 514/671] From Lucho: converted TM_ENCODE into a function. Various cleanups in fatfs.c git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@942 6ac86273-5f31-0410-b378-82cca8765d1b --- hdr/time.h | 8 -------- kernel/fatfs.c | 33 +++++++++++++-------------------- 2 files changed, 13 insertions(+), 28 deletions(-) diff --git a/hdr/time.h b/hdr/time.h index 11d86d89..050105a6 100644 --- a/hdr/time.h +++ b/hdr/time.h @@ -39,14 +39,6 @@ static BYTE *time_hRcsId = #endif #endif -/* FAT Time notation in the form of hhhh hmmm mmmd dddd */ - -#define TM_HOUR(t) (((t)>>11)&0x1f) -#define TM_MIN(t) (((t)>>5)&0x3f) -#define TM_DEC(t) ((t)&0x1f) - -#define TM_ENCODE(h,m,d) ((((h)&0x1f)<<11)|(((m)&0x3f)<<5)|((d)&0x1f)) - typedef UWORD time; struct dostime diff --git a/kernel/fatfs.c b/kernel/fatfs.c index 2da302f2..2da5e1a4 100644 --- a/kernel/fatfs.c +++ b/kernel/fatfs.c @@ -58,6 +58,12 @@ CLUSTER first_fat(f_node_ptr); COUNT map_cluster(f_node_ptr, COUNT); STATIC VOID shrink_file(f_node_ptr fnp); +/* FAT time notation in the form of hhhh hmmm mmmd dddd (d = double second) */ +STATIC time time_encode(struct dostime *t) +{ + return (t->hour << 11) | (t->minute << 5) | (t->second >> 1); +} + #ifdef WITHFAT32 CLUSTER getdstart(struct dpb FAR *dpbp, struct dirent *dentry) { @@ -68,13 +74,9 @@ CLUSTER getdstart(struct dpb FAR *dpbp, struct dirent *dentry) void setdstart(struct dpb FAR *dpbp, struct dirent *dentry, CLUSTER value) { - if (!ISFAT32(dpbp)) - { - dentry->dir_start = (UWORD)value; - return; - } dentry->dir_start = (UWORD)value; - dentry->dir_start_high = (UWORD)(value >> 16); + if (ISFAT32(dpbp)) + dentry->dir_start_high = (UWORD)(value >> 16); } BOOL checkdstart(struct dpb FAR *dpbp, struct dirent *dentry, CLUSTER value) @@ -124,8 +126,7 @@ STATIC void init_direntry(struct dirent *dentry, unsigned attrib, dentry->dir_crtimems = dt.hundredth; if (dt.second & 1) dentry->dir_crtimems += 100; - dentry->dir_time = dentry->dir_crtime = - TM_ENCODE(dt.hour, dt.minute, dt.second >> 1); + dentry->dir_time = dentry->dir_crtime = time_encode(&dt); dentry->dir_date = dentry->dir_crdate = dentry->dir_accdate = dos_getdate(); } @@ -258,16 +259,9 @@ long dos_open(char *path, unsigned flags, unsigned attrib) BOOL fcmp_wild(const char * s1, const char * s2, unsigned n) { - while (n--) - { - if (*s1 == '?') - { - ++s1, ++s2; - continue; - } - if (*s1++ != *s2++) + for ( ; n--; ++s1, ++s2) + if (*s1 != '?' && *s1 != *s2) return FALSE; - } return TRUE; } @@ -882,7 +876,7 @@ time dos_gettime(void) /* First - get the system time set by either the user */ /* on start-up or the CMOS clock */ DosGetTime(&dt); - return TM_ENCODE(dt.hour, dt.minute, dt.second >> 1); + return time_encode(&dt); } /* */ @@ -1183,8 +1177,7 @@ COUNT dos_mkdir(BYTE * dir) return DE_BLKINVLD; } fmemset(bp->b_buffer, 0, BUFFERSIZE); - bp->b_flag |= BFR_DIRTY | BFR_VALID; - bp->b_flag |= BFR_UNCACHE; /* need not be cached */ + bp->b_flag |= BFR_DIRTY | BFR_VALID | BFR_UNCACHE; /* need not be cached */ } /* flush the drive buffers so that all info is written */ From 24d27f2f9b3fd3f54b86edfcaf8885ca5e16359b Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sun, 23 May 2004 15:10:08 +0000 Subject: [PATCH 515/671] From Tom: must set r_bpfat for C_BLDBPB, otherwise USBASPI.SYS, DI1000DD.SYS won't like us. From Lucho: use DiskTransferBuffer for deblock_buf. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@943 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/config.c | 3 +-- kernel/fatfs.c | 3 +++ kernel/globals.h | 1 + kernel/init-mod.h | 2 ++ 4 files changed, 7 insertions(+), 2 deletions(-) diff --git a/kernel/config.c b/kernel/config.c index 33b62c70..9b08cea8 100644 --- a/kernel/config.c +++ b/kernel/config.c @@ -1714,12 +1714,11 @@ STATIC void config_init_buffers(int wantedbuffers) else { LoL->bufloc = LOC_HMA; - LoL->deblock_buf = KernelAlloc(SEC_SIZE, 'B', 0); /* space in HMA beyond requested buffers available as user space */ firstAvailableBuf = pbuffer + wantedbuffers; } } - + LoL->deblock_buf = DiskTransferBuffer; LoL->firstbuf = pbuffer; DebugPrintf(("init_buffers (size %u) at", sizeof(struct buffer))); diff --git a/kernel/fatfs.c b/kernel/fatfs.c index 2da5e1a4..764666ab 100644 --- a/kernel/fatfs.c +++ b/kernel/fatfs.c @@ -2085,6 +2085,9 @@ STATIC int rqblockio(unsigned char command, struct dpb FAR * dpbp) MediaReqHdr.r_command = command; MediaReqHdr.r_mcmdesc = dpbp->dpb_mdb; MediaReqHdr.r_status = 0; + + if (command == C_BLDBPB) /* help USBASPI.SYS & DI1000DD.SYS (TE) */ + MediaReqHdr.r_bpfat = (boot FAR *)DiskTransferBuffer; execrh((request FAR *) & MediaReqHdr, dpbp->dpb_device); if ((MediaReqHdr.r_status & S_ERROR) || !(MediaReqHdr.r_status & S_DONE)) { diff --git a/kernel/globals.h b/kernel/globals.h index 14898960..b99f1950 100644 --- a/kernel/globals.h +++ b/kernel/globals.h @@ -336,6 +336,7 @@ extern UBYTE ASM BootDrive, /* Drive we came up from */ extern keyboard ASM kb_buf; extern char ASM local_buffer[LINEBUFSIZE0A]; +extern UBYTE DiskTransferBuffer[SEC_SIZE]; extern struct cds ASM TempCDS; diff --git a/kernel/init-mod.h b/kernel/init-mod.h index 15380ea8..d9416b0d 100644 --- a/kernel/init-mod.h +++ b/kernel/init-mod.h @@ -271,6 +271,8 @@ extern UWORD DOSFAR LBA_WRITE_VERIFY; /* floppy parameter table, at 70:xxxx */ extern unsigned char DOSTEXTFAR ASM int1e_table[0xe]; +extern char DOSTEXTFAR DiskTransferBuffer[SEC_SIZE]; /* in dsk.c */ + struct RelocationTable { UBYTE jmpFar; UWORD jmpOffset; From c97bc20bf21a0260cd7167bbe7c6ddde0e2bd412 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sun, 23 May 2004 16:21:14 +0000 Subject: [PATCH 516/671] GetNumArg and misc other cleanups from Lucho git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@944 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/config.c | 96 +++++++++++++++++++++---------------------------- 1 file changed, 41 insertions(+), 55 deletions(-) diff --git a/kernel/config.c b/kernel/config.c index 9b08cea8..ae95674a 100644 --- a/kernel/config.c +++ b/kernel/config.c @@ -206,11 +206,10 @@ STATIC VOID CfgMenuDefault(BYTE * pLine); STATIC BYTE * skipwh(BYTE * s); STATIC BYTE * scan(BYTE * s, BYTE * d); STATIC BOOL isnum(char ch); -STATIC char * GetNumber(REG const char *p, int *num); #if 0 STATIC COUNT tolower(COUNT c); #endif -STATIC unsigned char toupper(unsigned char c); +STATIC char toupper(char c); STATIC VOID strupr(char *s); STATIC VOID mcb_init(UCOUNT seg, UWORD size, BYTE type); STATIC VOID mumcb_init(UCOUNT seg, UWORD size); @@ -865,16 +864,43 @@ STATIC BOOL SkipLine(char *pLine) } -STATIC BYTE * GetNumArg(BYTE * pLine, COUNT * pnArg) +/* JPP - changed so will accept hex number. */ +/* ea - changed to accept hex digits in hex numbers */ +STATIC char *GetNumArg(char *p, int *num) { + static char digits[] = "0123456789ABCDEF"; + unsigned char base = 10; + int sign = 1; + int n = 0; + /* look for NUMBER */ - pLine = skipwh(pLine); - if (!isnum(*pLine) && *pLine != '-') + p = skipwh(p); + if (*p == '-') { - CfgFailure(pLine); - return (BYTE *) 0; + p++; + sign = -1; + } + else if (!isnum(*p)) + { + CfgFailure(p); + return NULL; + } + + for( ; *p; p++) + { + char ch = toupper(*p); + if (ch == 'X') + base = 16; + else + { + char *q = strchr(digits, ch); + if (q == NULL) + break; + n = n * base + (q - digits); + } } - return (BYTE *)GetNumber(pLine, pnArg); + *num = n * sign; + return p; } BYTE *GetStringArg(BYTE * pLine, BYTE * pszString) @@ -974,16 +1000,16 @@ STATIC VOID CfgLastdrive(BYTE * pLine) BYTE drv; pLine = skipwh(pLine); - drv = *pLine & ~0x20; + drv = toupper(*pLine); if (drv < 'A' || drv > 'Z') { CfgFailure(pLine); return; } - drv -= 'A'; - drv++; /* Make real number */ - Config.cfgLastdrive = max(Config.cfgLastdrive, drv); + drv -= 'A' - 1; /* Make real number */ + if (drv > Config.cfgLastdrive) + Config.cfgLastdrive = drv; Config.cfgLastdriveHigh = 0; } @@ -1569,52 +1595,12 @@ STATIC BOOL isnum(char ch) return (ch >= '0' && ch <= '9'); } -/* JPP - changed so will accept hex number. */ -/* ea - changed to accept hex digits in hex numbers */ -STATIC char * GetNumber(REG const char *p, int *num) -{ - unsigned char base = 10; - int sign = 1; - int n = 0; - - if (*p == '-') - { - p++; - sign = -1; - } - - for(;;p++) - { - unsigned char ch = toupper(*p); - if (ch == 'X') - { - base = 16; - continue; - } - if (isnum(ch)) - { - n = n * base + ch - '0'; - } - else if (base == 16 && (ch<='F') && (ch>='A')) - { - n = n * base + 10 + ch - 'A'; - } - else - { - break; - } - } - *num = n * sign; - return (char *)p; -} - /* Yet another change for true portability (PJV) */ -STATIC unsigned char toupper(unsigned char c) +STATIC char toupper(char c) { if (c >= 'a' && c <= 'z') - return (c - ('a' - 'A')); - else - return c; + c -= 'a' - 'A'; + return c; } /* Convert string s to uppercase */ From b89c1b7cd3fc439a5788845df52c0bf4c8fcbc9a Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sun, 23 May 2004 16:30:25 +0000 Subject: [PATCH 517/671] Disabled EBDA moves by default. Automatic EBDA moves now happen using switches=/e:-1 git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@945 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/config.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/kernel/config.c b/kernel/config.c index ae95674a..c05f0e81 100644 --- a/kernel/config.c +++ b/kernel/config.c @@ -148,7 +148,7 @@ struct config Config = { , 0 /* amount required memory */ , 0 /* pointer to loaded data */ , 0 /* strategy for command.com is low by default */ - , 0xFFFF /* default value for switches=/E:nnnn */ + , 0 /* default value for switches=/E:nnnn */ }; STATIC seg base_seg BSS_INIT(0); @@ -1115,7 +1115,6 @@ STATIC VOID CfgSwitches(BYTE * pLine) if (!isnum(*pLine)) { pLine--; - Config.ebda2move = 0; break; } pLine = GetNumArg(pLine, &n) - 1; @@ -1123,7 +1122,12 @@ STATIC VOID CfgSwitches(BYTE * pLine) * e.g. AwardBIOS: 48, AMIBIOS: 1024 * (Phoenix, MRBIOS, Unicore = ????) */ - if (n >= 48 && n <= 1024) + if (n == -1) + { + Config.ebda2move = 0xffff; + break; + } + else if (n >= 48 && n <= 1024) { Config.ebda2move = (n + 15) & 0xfff0; break; From fe3a2a1dd55837a1b904f7358c7e2771704c03c1 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sun, 23 May 2004 18:28:18 +0000 Subject: [PATCH 518/671] Some small cleanups from Lucho. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@946 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/dosfns.c | 20 +++++++------------- kernel/fatdir.c | 32 +++++++++----------------------- kernel/fcbfns.c | 9 ++------- kernel/ioctl.c | 6 +++--- 4 files changed, 21 insertions(+), 46 deletions(-) diff --git a/kernel/dosfns.c b/kernel/dosfns.c index 52b7ca08..dbbd8bdb 100644 --- a/kernel/dosfns.c +++ b/kernel/dosfns.c @@ -336,16 +336,11 @@ COUNT SftSeek(int sft_idx, LONG new_pos, COUNT mode) * Lredir via mfs.c from DosEMU works when writing appended files. * Mfs.c looks for these mode bits set, so here is my best guess.;^) */ - if ((s->sft_mode & O_DENYREAD) || (s->sft_mode & O_DENYNONE)) - { + if (s->sft_mode & (O_DENYREAD | O_DENYNONE)) s->sft_posit = remote_lseek(s, new_pos); - return SUCCESS; - } else - { s->sft_posit = s->sft_size + new_pos; - return SUCCESS; - } + return SUCCESS; } if (mode == 0) { @@ -460,8 +455,7 @@ STATIC int DeviceOpenSft(struct dhdr FAR *dhp, sft FAR *sftp) sftp->sft_shroff = -1; /* /// Added for SHARE - Ron Cemer */ sftp->sft_count += 1; sftp->sft_flags = - ((dhp-> - dh_attr & ~SFT_MASK) & ~SFT_FSHARED) | SFT_FDEVICE | SFT_FEOF; + (dhp->dh_attr & ~(SFT_MASK | SFT_FSHARED)) | SFT_FDEVICE | SFT_FEOF; fmemcpy(sftp->sft_name, dhp->dh_name, FNAME_SIZE); /* pad with spaces */ @@ -1096,8 +1090,8 @@ COUNT DosFindNext(void) COUNT rc; register dmatch FAR *dmp = dta; - /* /// findnext will always fail on a device name device name or volume id */ - if (dmp->dm_attr_fnd == D_DEVICE || dmp->dm_attr_fnd & D_VOLID) + /* findnext will always fail on a device name device name or volume id */ + if (dmp->dm_attr_fnd & (D_DEVICE | D_VOLID)) return DE_NFILES; /* @@ -1314,14 +1308,14 @@ COUNT DosRename(BYTE FAR * path1, BYTE FAR * path2) if (result < SUCCESS) return result; - if (!(result & IS_NETWORK) && (result & IS_DEVICE)) + if ((result & (IS_NETWORK | IS_DEVICE)) == IS_DEVICE) return DE_FILENOTFND; result = truename(path1, PriPathName, CDS_MODE_CHECK_DEV_PATH); if (result < SUCCESS) return result; - if (!(result & IS_NETWORK) && (result & IS_DEVICE)) + if ((result & (IS_NETWORK | IS_DEVICE)) == IS_DEVICE) return DE_FILENOTFND; return DosRenameTrue(PriPathName, SecPathName, D_ALL); diff --git a/kernel/fatdir.c b/kernel/fatdir.c index 1acbde42..a8368088 100644 --- a/kernel/fatdir.c +++ b/kernel/fatdir.c @@ -105,28 +105,16 @@ f_node_ptr dir_open(register const char *dirname) /* Convert the name into an absolute name for */ /* comparison... */ - /* first the file name with trailing spaces... */ memset(fcbname, ' ', FNAME_SIZE + FEXT_SIZE); - for (i = 0; i < FNAME_SIZE; i++) + for (i = 0; i < FNAME_SIZE + FEXT_SIZE; i++, dirname++) { - if (*dirname != '\0' && *dirname != '.' && *dirname != '/' && - *dirname != '\\') - fcbname[i] = *dirname++; - else - break; - } - - /* and the extension (don't forget to */ - /* add trailing spaces)... */ - if (*dirname == '.') - ++dirname; - for (i = 0; i < FEXT_SIZE; i++) - { - if (*dirname != '\0' && *dirname != '.' && *dirname != '/' && - *dirname != '\\') - fcbname[i + FNAME_SIZE] = *dirname++; + char c = *dirname; + if (c == '.') + i = FNAME_SIZE - 1; + else if (c != '\0' && c != '\\') + fcbname[i] = c; else break; } @@ -164,10 +152,8 @@ f_node_ptr dir_open(register const char *dirname) /* swap internal and external delete flags */ STATIC void swap_deleted(char *name) { - if (name[0] == DELETED) - name[0] = EXT_DELETED; - else if (name[0] == EXT_DELETED) - name[0] = DELETED; + if (name[0] == DELETED || name[0] == EXT_DELETED) + name[0] ^= EXT_DELETED - DELETED; /* 0xe0 */ } STATIC struct buffer FAR *getblock_from_off(f_node_ptr fnp, unsigned secsize) @@ -501,7 +487,7 @@ COUNT dos_findnext(void) ++dmp->dm_entry; ++fnp->f_diroff; if (fnp->f_dir.dir_name[0] != '\0' && fnp->f_dir.dir_name[0] != DELETED - && (fnp->f_dir.dir_attrib & D_VOLID) != D_VOLID) + && !(fnp->f_dir.dir_attrib & D_VOLID)) { if (fcmp_wild(dmp->dm_name_pat, fnp->f_dir.dir_name, FNAME_SIZE + FEXT_SIZE)) { diff --git a/kernel/fcbfns.c b/kernel/fcbfns.c index 3fa5fe73..253c430e 100644 --- a/kernel/fcbfns.c +++ b/kernel/fcbfns.c @@ -573,13 +573,8 @@ UBYTE FcbRename(xfcb FAR * lpXfcb) LocalFcb.fcb_drive = FcbDrive; FcbNameInit(&LocalFcb, loc_szBuffer, &FcbDrive); result = truename(loc_szBuffer, SecPathName, 0); - if (result < SUCCESS || (!(result & IS_NETWORK) && (result & IS_DEVICE))) - { - result = FCB_ERROR; - break; - } - - if (DosRenameTrue(PriPathName, SecPathName, wAttr) != SUCCESS) + if (result < SUCCESS || (result & (IS_NETWORK|IS_DEVICE) == IS_DEVICE) + || DosRenameTrue(PriPathName, SecPathName, wAttr) != SUCCESS) { result = FCB_ERROR; break; diff --git a/kernel/ioctl.c b/kernel/ioctl.c index 01c6dace..888484b7 100644 --- a/kernel/ioctl.c +++ b/kernel/ioctl.c @@ -172,7 +172,7 @@ COUNT DosDevIOctl(lregs * r) CritErrCode = (CharReqHdr.r_status & S_MASK) + 0x13; return DE_DEVICE; } - + if (r->AL == 0x06 || r->AL == 0x07) { r->AX = CharReqHdr.r_status & S_BUSY ? 0000 : 0x00ff; @@ -280,8 +280,8 @@ COUNT DosDevIOctl(lregs * r) r->AX = 0; /* (lock/unlock logical/physical volume) */ break; /* simulate success for MS-DOS 7+ SCANDISK etc. --LG */ } - if (((r->AL == 0x04) && !(dpbp->dpb_device->dh_attr & ATTR_IOCTL)) - || ((r->AL == 0x05) && !(dpbp->dpb_device->dh_attr & ATTR_IOCTL)) + if (((r->AL == 0x04 || r->AL == 0x05) && + !(dpbp->dpb_device->dh_attr & ATTR_IOCTL)) || ((r->AL == 0x11) && !(dpbp->dpb_device->dh_attr & ATTR_QRYIOCTL)) || ((r->AL == 0x0d) From e0133fe31b8da5ed334050ee6ca65f33a34b278b Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sun, 23 May 2004 18:29:18 +0000 Subject: [PATCH 519/671] Let TC2 warn for the utilities. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@947 6ac86273-5f31-0410-b378-82cca8765d1b --- mkfiles/tc2.mak | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mkfiles/tc2.mak b/mkfiles/tc2.mak index 373b3575..c5e52130 100644 --- a/mkfiles/tc2.mak +++ b/mkfiles/tc2.mak @@ -15,7 +15,7 @@ LIBTERM= LIBPLUS=+ TINY=-lt -CFLAGST=-L$(LIBPATH) -mt -a- -k- -f- -ff- -O -Z -d +CFLAGST=-L$(LIBPATH) -mt -a- -k- -f- -ff- -O -Z -d -w CFLAGSC=-L$(LIBPATH) -a- -mc TARGET=KTC From b723ff9a46e539fe3dbab66f7c6e9ddbb5c96567 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sun, 23 May 2004 19:45:48 +0000 Subject: [PATCH 520/671] inthndler cleanups, mostly from Arkady Bart: made dosmktmp to return a long: consistent with DosOpen et al and avoids the cast. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@948 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/inthndlr.c | 124 ++++++++++++++++++++-------------------------- kernel/newstuff.c | 6 +-- kernel/proto.h | 2 +- 3 files changed, 58 insertions(+), 74 deletions(-) diff --git a/kernel/inthndlr.c b/kernel/inthndlr.c index 2d2349a8..75d145e3 100644 --- a/kernel/inthndlr.c +++ b/kernel/inthndlr.c @@ -382,7 +382,7 @@ int int21_fat32(lregs *r) VOID ASMCFUNC int21_service(iregs FAR * r) { - COUNT rc = 0; + COUNT rc; long lrc; lregs lr; /* 8 local registers (ax, bx, cx, dx, si, di, ds, es) */ @@ -671,10 +671,9 @@ VOID ASMCFUNC int21_service(iregs FAR * r) /* Parse File Name */ case 0x29: - { - lr.SI = FcbParseFname(&rc, MK_FP(lr.DS, lr.SI), FP_ES_DI); - lr.AL = rc; - } + rc = 0; + lr.SI = FcbParseFname(&rc, MK_FP(lr.DS, lr.SI), FP_ES_DI); + lr.AL = rc; break; /* Get Date */ @@ -765,8 +764,8 @@ VOID ASMCFUNC int21_service(iregs FAR * r) if (dpb == NULL) { + CritErrCode = -DE_INVLDDRV; lr.AL = 0xFF; - CritErrCode = 0x0f; break; } /* hazard: no error checking! */ @@ -780,7 +779,7 @@ VOID ASMCFUNC int21_service(iregs FAR * r) #endif { lr.AL = 0xff; - CritErrCode = 0x0f; + CritErrCode = -DE_INVLDDRV; break; } lr.DS = FP_SEG(dpb); @@ -839,21 +838,24 @@ VOID ASMCFUNC int21_service(iregs FAR * r) if (0xffff == lr.DX) { /* Set Country Code */ - if ((rc = DosSetCountry(cntry)) < 0) - goto error_invalid; + rc = DosSetCountry(cntry); + goto short_check; } else { if (cntry == 0) cntry--; /* Get Country Information */ - if ((rc = DosGetCountryInformation(cntry, FP_DS_DX)) < 0) - goto error_invalid; - /* HACK FIXME */ - if (cntry == (UWORD) - 1) - cntry = 1; - /* END OF HACK */ - lr.AX = lr.BX = cntry; + rc = DosGetCountryInformation(cntry, FP_DS_DX); + if (rc >= SUCCESS) + { + /* HACK FIXME */ + if (cntry == (UWORD) - 1) + cntry = 1; + /* END OF HACK */ + lr.AX = lr.BX = cntry; + } + goto short_check; } } break; @@ -928,8 +930,7 @@ VOID ASMCFUNC int21_service(iregs FAR * r) case 0x01: rc = DosSetFattr((BYTE FAR *) FP_DS_DX, lr.CX); - if (rc >= SUCCESS) - lr.AX = lr.CX; + lr.AX = lr.CX; break; default: @@ -941,11 +942,11 @@ VOID ASMCFUNC int21_service(iregs FAR * r) case 0x44: rc = DosDevIOctl(&lr); /* can set critical error code! */ - if (rc != SUCCESS) + if (rc < SUCCESS) { lr.AX = -rc; if (rc != DE_DEVICE && rc != DE_ACCESS) - CritErrCode = -rc; + CritErrCode = lr.AX; goto error_carry; } break; @@ -963,34 +964,29 @@ VOID ASMCFUNC int21_service(iregs FAR * r) /* Get Current Directory */ case 0x47: rc = DosGetCuDir(lr.DL, MK_FP(lr.DS, lr.SI)); - if (rc >= SUCCESS) - lr.AX = 0x0100; /*jpp: from interrupt list */ + lr.AX = 0x0100; /*jpp: from interrupt list */ goto short_check; /* Allocate memory */ case 0x48: - if ((rc = - DosMemAlloc(lr.BX, mem_access_mode, &(lr.AX), &(lr.BX))) < 0) + if ((rc = DosMemAlloc(lr.BX, mem_access_mode, &lr.AX, &lr.BX)) < 0) { - DosMemLargest(&(lr.BX)); - { - if (DosMemCheck() != SUCCESS) - panic("MCB chain corrupted"); - } + DosMemLargest(&lr.BX); + if (DosMemCheck() != SUCCESS) + panic("MCB chain corrupted"); goto error_exit; } - else - ++(lr.AX); /* DosMemAlloc() returns seg of MCB rather than data */ + lr.AX++; /* DosMemAlloc() returns seg of MCB rather than data */ break; /* Free memory */ case 0x49: - if ((rc = DosMemFree((lr.ES) - 1)) < 0) - { - if (DosMemCheck() != SUCCESS) - panic("MCB chain corrupted"); - goto error_exit; - } + if ((rc = DosMemFree(lr.ES - 1)) < SUCCESS) + { + if (DosMemCheck() != SUCCESS) + panic("MCB chain corrupted"); + goto error_exit; + } break; /* Set memory block size */ @@ -1003,10 +999,7 @@ VOID ASMCFUNC int21_service(iregs FAR * r) #if 0 if (cu_psp == lr.ES) { - - psp FAR *p; - - p = MK_FP(cu_psp, 0); + psp FAR *p = MK_FP(cu_psp, 0); p->ps_size = lr.BX + cu_psp; } #endif @@ -1032,21 +1025,18 @@ VOID ASMCFUNC int21_service(iregs FAR * r) if (((psp FAR *)MK_FP(cu_psp, 0))->ps_parent == cu_psp) break; tsr = FALSE; + rc = 0; if (ErrorMode) { ErrorMode = FALSE; - rc = 2; + rc = 0x200; } else if (break_flg) { break_flg = FALSE; - rc = 1; + rc = 0x100; } - else - { - rc = 0; - } - return_code = lr.AL | (rc << 8); + return_code = lr.AL | rc; if (DosMemCheck() != SUCCESS) panic("MCB chain corrupted"); #ifdef TSC @@ -1067,8 +1057,7 @@ VOID ASMCFUNC int21_service(iregs FAR * r) /* dta for this call is set on entry. This */ /* needs to be changed for new versions. */ rc = DosFindFirst(lr.CX, FP_DS_DX); - if (rc >= SUCCESS) - lr.AX = 0; + lr.AX = 0; goto short_check; /* Dos Find Next */ @@ -1076,8 +1065,7 @@ VOID ASMCFUNC int21_service(iregs FAR * r) /* dta for this call is set on entry. This */ /* needs to be changed for new versions. */ rc = DosFindNext(); - if (rc >= SUCCESS) - lr.AX = 0; + lr.AX = 0; goto short_check; /* case 0x50: @@ -1189,10 +1177,8 @@ VOID ASMCFUNC int21_service(iregs FAR * r) /* Create Temporary File */ case 0x5a: - if ((rc = DosMkTmp(FP_DS_DX, lr.CX)) < 0) - goto error_exit; - lr.AX = rc; - break; + lrc = DosMkTmp(FP_DS_DX, lr.CX); + goto long_check; /* Create New File */ case 0x5b: @@ -1202,11 +1188,10 @@ VOID ASMCFUNC int21_service(iregs FAR * r) /* /// Added for SHARE. - Ron Cemer */ /* Lock/unlock file access */ case 0x5c: - if ((rc = DosLockUnlock - (lr.BX, - (((unsigned long)lr.CX) << 16) | (((unsigned long)lr.DX) ), - (((unsigned long)lr.SI) << 16) | (((unsigned long)lr.DI) ), - ((lr.AX & 0xff) != 0))) != 0) + rc = DosLockUnlock + (lr.BX, ((unsigned long)lr.CX << 16) | lr.DX, + ((unsigned long)lr.SI << 16) | lr.DI, lr.AL != 0); + if (rc != SUCCESS) goto error_exit; break; /* /// End of additions for SHARE. - Ron Cemer */ @@ -1232,10 +1217,11 @@ VOID ASMCFUNC int21_service(iregs FAR * r) case 0x08: case 0x09: rc = remote_printredir(lr.DX, Int21AX); + CLEAR_CARRY_FLAG(); if (rc != SUCCESS) goto error_exit; - CLEAR_CARRY_FLAG(); break; + default: CritErrCode = SUCCESS; goto error_invalid; @@ -1499,21 +1485,19 @@ VOID ASMCFUNC int21_service(iregs FAR * r) goto error_invalid; } lr.AX = rc; - if (rc < 0) goto error_exit; - else CLEAR_CARRY_FLAG(); - break; + CLEAR_CARRY_FLAG(); + goto short_check; } #endif } goto exit_dispatch; long_check: - if (lrc < SUCCESS) + if (lrc >= SUCCESS) { - rc = (int)lrc; - goto error_exit; + lr.AX = (UWORD)lrc; + goto exit_dispatch; } - lr.AX = (UWORD)lrc; - goto exit_dispatch; + rc = (int)lrc; short_check: if (rc < SUCCESS) goto error_exit; diff --git a/kernel/newstuff.c b/kernel/newstuff.c index 8a548931..1afb7da0 100644 --- a/kernel/newstuff.c +++ b/kernel/newstuff.c @@ -65,12 +65,12 @@ int SetJFTSize(UWORD nHandles) return SUCCESS; } -int DosMkTmp(BYTE FAR * pathname, UWORD attr) +long DosMkTmp(BYTE FAR * pathname, UWORD attr) { /* create filename from current date and time */ char FAR *ptmp; unsigned long randvar; - int rc; + long rc; int loop; ptmp = pathname + fstrlen(pathname); @@ -94,7 +94,7 @@ int DosMkTmp(BYTE FAR * pathname, UWORD attr) ptmp[i] -= (ptmp[i] < 'A' + 10) ? '0' - 'A' : 10; /* only create new file -- 2001/09/22 ska*/ - rc = (short)DosOpen(pathname, O_LEGACY | O_CREAT | O_RDWR, attr); + rc = DosOpen(pathname, O_LEGACY | O_CREAT | O_RDWR, attr); } while (rc == DE_FILEEXISTS && loop++ < 0xfff); return rc; diff --git a/kernel/proto.h b/kernel/proto.h index 7eb70c66..79bf6f53 100644 --- a/kernel/proto.h +++ b/kernel/proto.h @@ -373,7 +373,7 @@ VOID InitPSP(VOID); /* newstuff.c */ int SetJFTSize(UWORD nHandles); -int DosMkTmp(BYTE FAR * pathname, UWORD attr); +long DosMkTmp(BYTE FAR * pathname, UWORD attr); COUNT truename(const char FAR * src, char * dest, COUNT t); /* network.c */ From 05f3cdd1652276e4685d8692753f9b8761d5e7e1 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sun, 23 May 2004 19:53:33 +0000 Subject: [PATCH 521/671] Arkady: bugfix for INT21/440b (change NetRetry if DX is _non_zero). git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@949 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/ioctl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/ioctl.c b/kernel/ioctl.c index 888484b7..157d6f86 100644 --- a/kernel/ioctl.c +++ b/kernel/ioctl.c @@ -348,7 +348,7 @@ COUNT DosDevIOctl(lregs * r) case 0x0b: /* skip, it's a special case. */ NetDelay = r->CX; - if (!r->DX) + if (r->DX) NetRetry = r->DX; break; From c863987e185d609b0e23b3ba1a9da976ccb9d63f Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sun, 23 May 2004 20:01:30 +0000 Subject: [PATCH 522/671] Arkady changed/optimized allocmem() git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@950 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/config.c | 4 ++-- kernel/init-mod.h | 6 +++--- kernel/intr.asm | 12 +++++------- 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/kernel/config.c b/kernel/config.c index c05f0e81..0d31cf27 100644 --- a/kernel/config.c +++ b/kernel/config.c @@ -490,7 +490,7 @@ VOID configDone(VOID) unsigned short kernel_seg; unsigned short hma_paras = (HMAFree+0xf)/16; - allocmem(hma_paras, &kernel_seg); + kernel_seg = allocmem(hma_paras); p = para2far(kernel_seg - 1); p->m_name[0] = 'S'; @@ -2589,7 +2589,7 @@ VOID DoInstall(void) */ set_strategy(LAST_FIT); - allocmem(((unsigned)_init_end + ebda_size + 15) / 16, &installMemory); + installMemory = allocmem(((unsigned)_init_end + ebda_size + 15) / 16); InstallPrintf(("allocated memory at %x\n",installMemory)); diff --git a/kernel/init-mod.h b/kernel/init-mod.h index d9416b0d..a9dd0811 100644 --- a/kernel/init-mod.h +++ b/kernel/init-mod.h @@ -161,8 +161,8 @@ unsigned ASMPASCAL init_call_intr(int nr, iregs * rp); unsigned ASMPASCAL read(int fd, void *buf, unsigned count); int ASMPASCAL open(const char *pathname, int flags); int ASMPASCAL close(int fd); -int ASMPASCAL dup2(int oldfdk, int newfd); -int ASMPASCAL allocmem(UWORD size, seg * segp); +int ASMPASCAL dup2(int oldfd, int newfd); +seg ASMPASCAL allocmem(UWORD size); void ASMPASCAL init_PSPSet(seg psp_seg); int ASMPASCAL init_DosExec(int mode, exec_blk * ep, char * lp); int ASMPASCAL init_setdrive(int drive); @@ -175,7 +175,7 @@ void ASMPASCAL set_DTA(void far *dta); #pragma aux (pascal) init_DosOpen modify exact [ax bx dx] #pragma aux (pascal) close modify exact [ax bx] #pragma aux (pascal) dup2 modify exact [ax bx cx] -#pragma aux (pascal) allocmem modify exact [ax bx dx] +#pragma aux (pascal) allocmem modify exact [ax bx] #pragma aux (pascal) init_PSPSet modify exact [ax bx] #pragma aux (pascal) init_DosExec modify exact [ax bx dx es] #pragma aux (pascal) init_setdrive modify exact [ax bx dx] diff --git a/kernel/intr.asm b/kernel/intr.asm index b6ca61a0..895ce627 100644 --- a/kernel/intr.asm +++ b/kernel/intr.asm @@ -199,7 +199,6 @@ INIT_DOSOPEN: common_int21: int 21h jnc common_no_error -common_error: mov ax, -1 common_no_error: ret @@ -278,19 +277,18 @@ INIT_SWITCHAR: mov ax, 0x3701 jmp short common_dl_int21 -;; int allocmem(UWORD size, seg *segp) +; +; seg ASMPASCAL allocmem(UWORD size); +; global ALLOCMEM ALLOCMEM: pop ax ; ret address - pop dx ; segp pop bx ; size push ax ; ret address mov ah, 48h int 21h - jc short common_error - mov bx, dx ; segp - mov [bx], ax - xor ax, ax + sbb bx, bx ; carry=1 -> ax=-1 + or ax, bx ; segment ret ;; void set_DTA(void far *dta) From 86a8e9c2d24c12a12db5a5541dbf69da26143524 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sun, 23 May 2004 20:06:51 +0000 Subject: [PATCH 523/671] This was unequal replacement: in new code performed more memory access git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@951 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/newstuff.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/kernel/newstuff.c b/kernel/newstuff.c index 1afb7da0..bc73c9cc 100644 --- a/kernel/newstuff.c +++ b/kernel/newstuff.c @@ -39,7 +39,7 @@ static BYTE *mainRcsId = */ int SetJFTSize(UWORD nHandles) { - UWORD block, maxBlock; + UWORD block, maxBlock, i; psp FAR *ppsp = MK_FP(cu_psp, 0); UBYTE FAR *newtab; @@ -56,8 +56,10 @@ int SetJFTSize(UWORD nHandles) ++block; newtab = MK_FP(block, 0); - fmemset(newtab, 0xff, nHandles); - fmemcpy(newtab, ppsp->ps_filetab, ppsp->ps_maxfiles); + i = ppsp->ps_maxfiles; + /* copy existing part and fill up new part by "no open file" */ + fmemcpy(newtab, ppsp->ps_filetab, i); + fmemset(newtab + i, 0xff, nHandles - i); ppsp->ps_maxfiles = nHandles; ppsp->ps_filetab = newtab; From f8be820925db67015e2643dc643fff855be08eeb Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sun, 23 May 2004 21:18:37 +0000 Subject: [PATCH 524/671] Clear up confusing (void *)n using a macro. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@952 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/dosfns.c | 3 +-- kernel/proto.h | 1 + 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/dosfns.c b/kernel/dosfns.c index dbbd8bdb..ca4639b9 100644 --- a/kernel/dosfns.c +++ b/kernel/dosfns.c @@ -231,8 +231,7 @@ long DosRWSft(int sft_idx, size_t n, void FAR * bp, int mode) lpCurSft = s; current_filepos = s->sft_posit; /* needed for MSCDEX */ dta = bp; - XferCount = network_redirector_mx(mode == XFR_READ ? REM_READ : REM_WRITE, - s, (void *)n); + XferCount = remote_rw(mode == XFR_READ ? REM_READ : REM_WRITE, s, n); dta = save_dta; return XferCount; } diff --git a/kernel/proto.h b/kernel/proto.h index 79bf6f53..079e6b01 100644 --- a/kernel/proto.h +++ b/kernel/proto.h @@ -380,6 +380,7 @@ COUNT truename(const char FAR * src, char * dest, COUNT t); int network_redirector(unsigned cmd); int network_redirector_fp(unsigned cmd, void far *s); long ASMPASCAL network_redirector_mx(unsigned cmd, void far *s, void *arg); +#define remote_rw(cmd,s,arg) (int)network_redirector_mx(cmd, s, (void *)arg) #define remote_getfree(s,d) (int)network_redirector_mx(REM_GETSPACE, s, d) #define remote_lseek(s,new_pos) network_redirector_mx(REM_LSEEK, s, &new_pos) #define remote_setfattr(attr) (int)network_redirector_mx(REM_SETATTR, NULL, (void *)attr) From 99e727b73d51c7c036780eb575a5e5e44c10e736 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sun, 23 May 2004 22:04:42 +0000 Subject: [PATCH 525/671] Use int29 for kernel console output. Enables ansi escape sequences in config.sys once you load nansi.sys. It also saves a couple of bytes. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@953 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/console.asm | 3 +-- kernel/main.c | 6 ++++-- kernel/prf.c | 20 +++++--------------- 3 files changed, 10 insertions(+), 19 deletions(-) diff --git a/kernel/console.asm b/kernel/console.asm index 32c3645f..e4a99440 100644 --- a/kernel/console.asm +++ b/kernel/console.asm @@ -244,8 +244,7 @@ _int29_handler: push bp push bx mov ah,0Eh - mov bh,0 - mov bl,7 + mov bx,7 int 10h ; write char al, teletype mode pop bx pop bp diff --git a/kernel/main.c b/kernel/main.c index fa0dddd1..0e13d42a 100644 --- a/kernel/main.c +++ b/kernel/main.c @@ -259,6 +259,10 @@ STATIC void setup_int_vectors(void) setvec(pvec->intno, (intvec)MK_FP(FP_SEG(empty_handler), pvec->handleroff)); pokeb(0, 0x30 * 4, 0xea); pokel(0, 0x30 * 4 + 1, (ULONG)cpm_entry); + + /* these two are in the device driver area LOWTEXT (0x70) */ + setvec(0x1b, got_cbreak); + setvec(0x29, int29_handler); /* required for printf! */ } STATIC void init_kernel(void) @@ -607,8 +611,6 @@ STATIC void InitIO(void) struct dhdr far *device = &LoL->nul_dev; /* Initialize driver chain */ - setvec(0x1b, got_cbreak); - setvec(0x29, int29_handler); /* Requires Fast Con Driver */ do { init_device(device, NULL, 0, &lpTop); device = device->dh_next; diff --git a/kernel/prf.c b/kernel/prf.c index d882ca4e..b2fc643c 100644 --- a/kernel/prf.c +++ b/kernel/prf.c @@ -91,14 +91,8 @@ void put_console(int c) } #else #ifdef __WATCOMC__ -void int10_e(char c); -#pragma aux int10_e = \ - "push bp" \ - "mov ah, 0xe" \ - "mov bx, 0x0070" \ - "int 0x10" \ - "pop bp" \ - parm [al] modify [ah bx]; +void int29(char c); +#pragma aux int29 = "int 0x29" parm [al] modify exact [bx]; #endif void put_console(int c) @@ -111,18 +105,14 @@ void put_console(int c) #else #if defined(__TURBOC__) _AL = c; - _AH = 0x0e; - _BX = 0x0070; - __int__(0x10); + __int__(0x29); #elif defined(__WATCOMC__) - int10_e(c); + int29(c); #elif defined(I86) __asm { mov al, byte ptr c; - mov ah, 0x0e; - mov bx, 0x0070; - int 0x10; + int 0x29; } #endif /* __TURBO__ */ #endif /* FORSYS */ From 3eac7d3c19bea4750b7127c6b9206e2d60808017 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sun, 23 May 2004 22:53:11 +0000 Subject: [PATCH 526/671] Fix problem with redirected input and int21/ah=0a (debug < foo.txt) -- could get you an invalid opcode! git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@954 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/chario.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/chario.c b/kernel/chario.c index bb905f78..53fdd1a4 100644 --- a/kernel/chario.c +++ b/kernel/chario.c @@ -317,7 +317,7 @@ STATIC unsigned char read_char_sft_dev(int sft_in, int sft_out, { unsigned char c; - if (pdev) + if (*pdev) { FOREVER { From 39e6b427f44ce48933a57c9eef5a2374dfd50fc4 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Mon, 24 May 2004 11:42:28 +0000 Subject: [PATCH 527/671] Fixed new bugs caused by typos. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@955 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/fcbfns.c | 2 +- kernel/inthndlr.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/fcbfns.c b/kernel/fcbfns.c index 253c430e..a74795e9 100644 --- a/kernel/fcbfns.c +++ b/kernel/fcbfns.c @@ -573,7 +573,7 @@ UBYTE FcbRename(xfcb FAR * lpXfcb) LocalFcb.fcb_drive = FcbDrive; FcbNameInit(&LocalFcb, loc_szBuffer, &FcbDrive); result = truename(loc_szBuffer, SecPathName, 0); - if (result < SUCCESS || (result & (IS_NETWORK|IS_DEVICE) == IS_DEVICE) + if (result < SUCCESS || (result & (IS_NETWORK|IS_DEVICE)) == IS_DEVICE || DosRenameTrue(PriPathName, SecPathName, wAttr) != SUCCESS) { result = FCB_ERROR; diff --git a/kernel/inthndlr.c b/kernel/inthndlr.c index 75d145e3..95401db9 100644 --- a/kernel/inthndlr.c +++ b/kernel/inthndlr.c @@ -864,7 +864,7 @@ VOID ASMCFUNC int21_service(iregs FAR * r) case 0x39: /* Dos Remove Directory */ case 0x3a: - rc = DosMkRmdir(FP_DS_DX, lr.AL); + rc = DosMkRmdir(FP_DS_DX, lr.AH); goto short_check; /* Dos Change Directory */ From 195614981a5a1cac77e637eaa3bf80332946e5bc Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Mon, 24 May 2004 17:07:04 +0000 Subject: [PATCH 528/671] Fix problem with #ifdef DEBUG HMA check. Use more descriptive name (EnabledA20). git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@956 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/inithma.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/kernel/inithma.c b/kernel/inithma.c index 58e8057f..0c68f50f 100644 --- a/kernel/inithma.c +++ b/kernel/inithma.c @@ -118,7 +118,7 @@ VOID hdump(BYTE FAR * p) if so, it simply leaves it on */ -STATIC int checkHMA(void) +STATIC int EnabledA20(void) { return fmemcmp(MK_FP(0, 0), MK_FP(0xffff, 0x0010), 128); } @@ -128,7 +128,7 @@ int EnableHMA(VOID) _EnableA20(); - if (!checkHMA()) + if (!EnabledA20()) { printf("HMA can't be enabled\n"); return FALSE; @@ -137,14 +137,14 @@ int EnableHMA(VOID) _DisableA20(); #ifdef DEBUG - if (!checkHMA()) + if (EnabledA20()) { printf("HMA can't be disabled - no problem for us\n"); } #endif _EnableA20(); - if (!checkHMA()) + if (!EnabledA20()) { printf("HMA can't be enabled second time\n"); return FALSE; From c0f1c45d1f87664eec82c1a5a2a8d59a03e3f773 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Mon, 24 May 2004 18:06:04 +0000 Subject: [PATCH 529/671] Use strcaseequal instead of strcasecmp since we never care about order anyway. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@957 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/config.c | 34 ++++++++++++---------------------- 1 file changed, 12 insertions(+), 22 deletions(-) diff --git a/kernel/config.c b/kernel/config.c index 0d31cf27..63971310 100644 --- a/kernel/config.c +++ b/kernel/config.c @@ -225,7 +225,7 @@ STATIC int SkipLine(char *pLine); #if 0 STATIC char * stristr(char *s1, char *s2); #endif -STATIC int strcasecmp(const char * d, const char * s); +STATIC char strcaseequal(const char * d, const char * s); STATIC int LoadCountryInfoHardCoded(char *filename, COUNT ctryCode, COUNT codePage); STATIC void umb_init(void); @@ -665,9 +665,7 @@ VOID DoConfig(int nPass) if (*pLine == '\n' || *pLine == EOF) /* end of line */ break; - if (*pLine == '\r') /* ignore */ - ; - else + if (*pLine != '\r') /* ignore CR */ pLine++; } @@ -724,13 +722,8 @@ VOID DoConfig(int nPass) STATIC struct table * LookUp(struct table *p, BYTE * token) { - while (*(p->entry) != '\0') - { - if (strcasecmp(p->entry, token) == 0) - break; - else - ++p; - } + while (p->entry[0] != '\0' && !strcaseequal(p->entry, token)) + ++p; return p; } @@ -1293,7 +1286,7 @@ STATIC VOID CfgBreak(BYTE * pLine) { /* Format: BREAK = (ON | OFF) */ GetStringArg(pLine, szBuf); - break_ena = strcasecmp(szBuf, "OFF") ? 1 : 0; + break_ena = strcaseequal(szBuf, "OFF") ? 0 : 1; } STATIC VOID Numlock(BYTE * pLine) @@ -1304,7 +1297,7 @@ STATIC VOID Numlock(BYTE * pLine) GetStringArg(pLine, szBuf); *keyflags &= ~32; - *keyflags |= strcasecmp(szBuf, "OFF") ? 32 : 0; + if (!strcaseequal(szBuf, "OFF")) *keyflags |= 32; keycheck(); } @@ -1651,16 +1644,13 @@ char *strcat(register char * d, register const char * s) } /* compare two ASCII strings ignoring case */ -STATIC int strcasecmp(const char * d, const char * s) +STATIC char strcaseequal(const char * d, const char * s) { - int ret; - for (;; s++, d++) - { - ret = toupper(*d) - toupper(*s); - if (ret != 0 || *d == '\0') - break; - } - return ret; + char ch; + while ((ch = toupper(*s++)) == toupper(*d++)) + if (ch == '\0') + return 1; + return 0; } /* From b3a2d6bfde0fe677101aa0fbabcdcedae9fa5e5a Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Mon, 24 May 2004 18:39:49 +0000 Subject: [PATCH 530/671] Reorganized GetBiosKey a bit -- inlining GetBiosTime saves a slight amount of code, converted timeout < 0 to a blocking read instead of polling. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@958 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/config.c | 30 ++++++++++-------------------- 1 file changed, 10 insertions(+), 20 deletions(-) diff --git a/kernel/config.c b/kernel/config.c index 63971310..6a30d0b6 100644 --- a/kernel/config.c +++ b/kernel/config.c @@ -741,10 +741,7 @@ STATIC struct table * LookUp(struct table *p, BYTE * token) 0x..LL : asciicode in lower half */ -STATIC ULONG GetBiosTime(VOID) -{ - return *(ULONG FAR *) (MK_FP(0x40, 0x6c)); -} +#define GetBiosTime() peekl(0, 0x46c) UWORD GetBiosKey(int timeout) { @@ -752,26 +749,19 @@ UWORD GetBiosKey(int timeout) ULONG startTime = GetBiosTime(); - for (;;) + if (timeout >= 0) do { r.a.x = 0x0100; /* are there keys available ? */ init_call_intr(0x16, &r); - - if ((r.flags & 0x40) == 0) /* yes - fetch and return */ - { - r.a.x = 0x0000; - init_call_intr(0x16, &r); - - return r.a.x; - } - - if (timeout < 0) - continue; - - if (GetBiosTime() - startTime >= (unsigned)timeout * 18) - break; + if ((unsigned)(GetBiosTime() - startTime) >= timeout * 18u) + return 0xffff; } - return 0xffff; + while (r.flags & FLG_ZERO); + + /* key available or blocking wait (timeout < 0): fetch it */ + r.a.x = 0x0000; + init_call_intr(0x16, &r); + return r.a.x; } STATIC BOOL SkipLine(char *pLine) From 0c00651565a739e9b80c84e323585e3530e24af1 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Mon, 24 May 2004 23:34:22 +0000 Subject: [PATCH 531/671] Pointer-ise specificCountriesSupported accesses. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@959 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/config.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/kernel/config.c b/kernel/config.c index 6a30d0b6..2654d29c 100644 --- a/kernel/config.c +++ b/kernel/config.c @@ -2418,6 +2418,7 @@ struct CountrySpecificInfo specificCountriesSupported[] = { STATIC int LoadCountryInfoHardCoded(char *filename, COUNT ctryCode, COUNT codePage) { int i; + struct CountrySpecificInfo *country; UNREFERENCED_PARAMETER(codePage); UNREFERENCED_PARAMETER(filename); @@ -2425,30 +2426,34 @@ STATIC int LoadCountryInfoHardCoded(char *filename, COUNT ctryCode, COUNT codePa - for (i = 0; i < sizeof(specificCountriesSupported)/sizeof(specificCountriesSupported[0]); i++) + for (country = specificCountriesSupported; + country < specificCountriesSupported + LENGTH(specificCountriesSupported); + country++) { - if (specificCountriesSupported[i].CountryID == ctryCode) + if (country->CountryID == ctryCode) { int codepagesaved = nlsCountryInfoHardcoded.C.CodePage; - fmemcpy(&nlsCountryInfoHardcoded.C.CountryID, - &specificCountriesSupported[i], - min(nlsCountryInfoHardcoded.TableSize, sizeof(struct CountrySpecificInfo))); + fmemcpy(&nlsCountryInfoHardcoded.C.CountryID, + country, + min(nlsCountryInfoHardcoded.TableSize, sizeof *country)); nlsCountryInfoHardcoded.C.CodePage = codepagesaved; return 0; } } - + printf("could not find country info for country ID %u\n" "current supported countries are ", ctryCode); - for (i = 0; i < sizeof(specificCountriesSupported)/sizeof(specificCountriesSupported[0]); i++) + for (country = specificCountriesSupported; + country < specificCountriesSupported + LENGTH(specificCountriesSupported); + country++) { - printf("%u ",specificCountriesSupported[i].CountryID); + printf("%u ", country->CountryID); } - printf("\n"); + printf("\n"); return 1; } From 9a1418a6c84ec009871753a4c67601ed8c57657d Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Mon, 24 May 2004 23:38:11 +0000 Subject: [PATCH 532/671] cleanups by Lucho git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@960 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/inthndlr.c | 27 ++++++++++----------------- 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/kernel/inthndlr.c b/kernel/inthndlr.c index 95401db9..78c4fe4d 100644 --- a/kernel/inthndlr.c +++ b/kernel/inthndlr.c @@ -123,24 +123,23 @@ VOID ASMCFUNC int21_syscall(iregs FAR * irp) break; /* Toggle DOS-C rdwrblock trace dump */ - case 0xfd: #ifdef DEBUG + case 0xfd: bDumpRdWrParms = !bDumpRdWrParms; -#endif break; +#endif /* Toggle DOS-C syscall trace dump */ - case 0xfe: #ifdef DEBUG + case 0xfe: bDumpRegs = !bDumpRegs; -#endif break; +#endif /* Get DOS-C release string pointer */ case 0xff: irp->DX = FP_SEG(os_release); irp->AX = FP_OFF(os_release); - break; } break; @@ -160,17 +159,13 @@ VOID ASMCFUNC int21_syscall(iregs FAR * irp) /* Get PSP */ case 0x51: - irp->BX = cu_psp; - break; - /* UNDOCUMENTED: return current psp */ case 0x62: irp->BX = cu_psp; break; /* Normal DOS function - DO NOT ARRIVE HERE */ - default: - break; + /* default: */ } } @@ -839,7 +834,6 @@ VOID ASMCFUNC int21_service(iregs FAR * r) { /* Set Country Code */ rc = DosSetCountry(cntry); - goto short_check; } else { @@ -855,10 +849,9 @@ VOID ASMCFUNC int21_service(iregs FAR * r) /* END OF HACK */ lr.AX = lr.BX = cntry; } - goto short_check; } + goto short_check; } - break; /* Dos Create Directory */ case 0x39: @@ -1574,7 +1567,7 @@ VOID ASMCFUNC int2526_handler(WORD mode, struct int25regs FAR * r) if (drv >= lastdrive) { r->ax = 0x201; - r->flags |= FLG_CARRY; + SET_CARRY_FLAG(); return; } @@ -1584,7 +1577,7 @@ VOID ASMCFUNC int2526_handler(WORD mode, struct int25regs FAR * r) if (dpbp != NULL && ISFAT32(dpbp)) { r->ax = 0x207; - r->flags |= FLG_CARRY; + SET_CARRY_FLAG(); return; } } @@ -1607,10 +1600,10 @@ VOID ASMCFUNC int2526_handler(WORD mode, struct int25regs FAR * r) r->ax = dskxfer(drv, blkno, buf, nblks, mode); - r->flags &= ~FLG_CARRY; + CLEAR_CARRY_FLAG(); if (r->ax != 0) { - r->flags |= FLG_CARRY; + SET_CARRY_FLAG(); if (mode == DSKWRITEINT26) setinvld(drv); } From c90e1e3c111f42cebdbd821c58b843f51358aec5 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Tue, 25 May 2004 00:02:46 +0000 Subject: [PATCH 533/671] Fix problem with wrong remote_rw cast and unused variable. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@961 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/config.c | 1 - kernel/proto.h | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/kernel/config.c b/kernel/config.c index 2654d29c..2b8f8d79 100644 --- a/kernel/config.c +++ b/kernel/config.c @@ -2417,7 +2417,6 @@ struct CountrySpecificInfo specificCountriesSupported[] = { STATIC int LoadCountryInfoHardCoded(char *filename, COUNT ctryCode, COUNT codePage) { - int i; struct CountrySpecificInfo *country; UNREFERENCED_PARAMETER(codePage); UNREFERENCED_PARAMETER(filename); diff --git a/kernel/proto.h b/kernel/proto.h index 079e6b01..9b9512c2 100644 --- a/kernel/proto.h +++ b/kernel/proto.h @@ -380,7 +380,7 @@ COUNT truename(const char FAR * src, char * dest, COUNT t); int network_redirector(unsigned cmd); int network_redirector_fp(unsigned cmd, void far *s); long ASMPASCAL network_redirector_mx(unsigned cmd, void far *s, void *arg); -#define remote_rw(cmd,s,arg) (int)network_redirector_mx(cmd, s, (void *)arg) +#define remote_rw(cmd,s,arg) network_redirector_mx(cmd, s, (void *)arg) #define remote_getfree(s,d) (int)network_redirector_mx(REM_GETSPACE, s, d) #define remote_lseek(s,new_pos) network_redirector_mx(REM_LSEEK, s, &new_pos) #define remote_setfattr(attr) (int)network_redirector_mx(REM_SETATTR, NULL, (void *)attr) From e71f6448ab3883e72a7f26b00d8e50ca3f60fb5a Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Tue, 25 May 2004 18:47:43 +0000 Subject: [PATCH 534/671] Fix int21/3302 (the swap was wrong, Lucho & Bart) Made int21/3301,2e,54 consistent with MSDOS behaviour (Lucho) Fix int21/5e02+ (mentioned by Arkady) git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@962 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/inthndlr.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/kernel/inthndlr.c b/kernel/inthndlr.c index 78c4fe4d..331202db 100644 --- a/kernel/inthndlr.c +++ b/kernel/inthndlr.c @@ -85,14 +85,14 @@ VOID ASMCFUNC int21_syscall(iregs FAR * irp) /* Set Ctrl-C flag */ case 0x01: - break_ena = irp->DL != 0; + break_ena = irp->DL & 1; break; case 0x02: /* andrew schulman: get/set extended control break */ { UBYTE tmp = break_ena; - irp->DL = break_ena; - break_ena = tmp != 0; + break_ena = irp->DL & 1; + irp->DL = tmp; } break; @@ -162,7 +162,6 @@ VOID ASMCFUNC int21_syscall(iregs FAR * irp) /* UNDOCUMENTED: return current psp */ case 0x62: irp->BX = cu_psp; - break; /* Normal DOS function - DO NOT ARRIVE HERE */ /* default: */ @@ -693,7 +692,7 @@ VOID ASMCFUNC int21_service(iregs FAR * r) /* Set verify flag */ case 0x2e: - verify_ena = (lr.AL ? TRUE : FALSE); + verify_ena = lr.AL & 1; break; /* Get DTA */ @@ -1084,7 +1083,7 @@ VOID ASMCFUNC int21_service(iregs FAR * r) /* Get verify state */ case 0x54: - lr.AL = (verify_ena ? TRUE : FALSE); + lr.AL = verify_ena; break; /* ************UNDOCUMENTED************************************* */ @@ -1234,10 +1233,7 @@ VOID ASMCFUNC int21_service(iregs FAR * r) default: rc = (int)network_redirector_mx(REM_PRINTSET, &lr, (void *)Int21AX); - if (rc != SUCCESS) - goto error_exit; - lr.AX = SUCCESS; - break; + goto short_check; } break; @@ -1507,7 +1503,7 @@ VOID ASMCFUNC int21_service(iregs FAR * r) fmemcpy(r, &lr, sizeof(lregs) - 4); r->DS = lr.DS; r->ES = lr.ES; -real_exit: +real_exit:; #ifdef DEBUG if (bDumpRegs) @@ -1517,7 +1513,6 @@ VOID ASMCFUNC int21_service(iregs FAR * r) dump(); } #endif - return; } #if 0 From 57bac85ae3a3323da4b6d20d787873637d1454ba Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Tue, 25 May 2004 19:24:55 +0000 Subject: [PATCH 535/671] Applied most of Arkady's initdisk optimizations (65 bytes) and is_suspect fix. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@963 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/initdisk.c | 121 ++++++++++++++++++++++------------------------ 1 file changed, 58 insertions(+), 63 deletions(-) diff --git a/kernel/initdisk.c b/kernel/initdisk.c index 1bfb9b8b..d175f6c0 100644 --- a/kernel/initdisk.c +++ b/kernel/initdisk.c @@ -650,17 +650,14 @@ void DosDefinePartition(struct DriveParamS *driveParam, } /* Get the parameters of the hard disk */ -int LBA_Get_Drive_Parameters(int drive, struct DriveParamS *driveParam) +STATIC int LBA_Get_Drive_Parameters(int drive, struct DriveParamS *driveParam) { iregs regs; - struct _bios_LBA_disk_parameterS lba_bios_parameters; - if (driveParam->driveno) - return driveParam->driveno; - - driveParam->descflags = 0; + ExtLBAForce = FALSE; + memset(driveParam, 0, sizeof *driveParam); drive |= 0x80; /* for tests - disable LBA support, @@ -817,11 +814,18 @@ BOOL ConvPartTableEntryToIntern(struct PartTableEntry * pEntry, BOOL is_suspect(struct CHS *chs, struct CHS *pEntry_chs) { - return !((chs->Cylinder & 0x3ff) == pEntry_chs->Cylinder || - 1023 == pEntry_chs->Cylinder || - (chs->Cylinder == pEntry_chs->Cylinder && - chs->Head == pEntry_chs->Head && - chs->Sector == pEntry_chs->Sector)); + /* Valid entry: + entry == chs || // partition entry equal to computed values + (chs->Cylinder > 1023 && // or LBA partition + (entry->Cylinder == 1023 || + entry->Cylinder == (0x3FF & chs->Cylinder))) + */ + return !((pEntry_chs->Cylinder == chs->Cylinder && + pEntry_chs->Head == chs->Head && + pEntry_chs->Sector == chs->Sector) || + chs->Cylinder > 1023u && + (pEntry_chs->Cylinder == 1023 || + pEntry_chs->Cylinder == (0x3ff & chs->Cylinder))); } void print_warning_suspect(char *partitionName, UBYTE fs, struct CHS *chs, @@ -1040,13 +1044,9 @@ int ProcessDisk(int scanType, unsigned drive, int PartitionsToIgnore) struct DriveParamS driveParam; - ExtLBAForce = FALSE; - /* Get the hard drive parameters and ensure that the drive exists. */ /* If there was an error accessing the drive, skip that drive. */ - memset(&driveParam, 0, sizeof(driveParam)); - if (!LBA_Get_Drive_Parameters(drive, &driveParam)) { printf("can't get drive parameters for drive %02x\n", drive); @@ -1250,15 +1250,28 @@ I don't know, if I did it right, but I tried to do it that way. TE ***********************************************************************/ +STATIC void make_ddt (ddt *pddt, int Unit, int driveno, int flags) +{ + pddt->ddt_next = MK_FP(0, 0xffff); + pddt->ddt_logdriveno = Unit; + pddt->ddt_driveno = driveno; + pddt->ddt_type = init_getdriveparm(driveno, &pddt->ddt_defbpb); + pddt->ddt_ncyl = (pddt->ddt_type & 7) ? 80 : 40; + pddt->ddt_descflags = init_readdasd(driveno) | flags; + + pddt->ddt_offset = 0; + pddt->ddt_serialno = 0x12345678l; + memcpy(&pddt->ddt_bpb, &pddt->ddt_defbpb, sizeof(bpb)); + push_ddt(pddt); +} + void ReadAllPartitionTables(void) { UBYTE foundPartitions[MAX_HARD_DRIVE]; int HardDrive; - int nHardDisk = BIOS_nrdrives(); - int Unit; + int nHardDisk; ddt nddt; - ddt *pddt = &nddt; static iregs regs; /* quick adjustment of diskette parameter table */ @@ -1270,59 +1283,44 @@ void ReadAllPartitionTables(void) setvec(0x1e, (intvec)int1e_table); /* Setup media info and BPBs arrays for floppies */ - for (Unit = 0; Unit < 2; Unit++) - { - pddt->ddt_next = MK_FP(0, 0xffff); - pddt->ddt_driveno = 0; - pddt->ddt_logdriveno = Unit; - pddt->ddt_type = init_getdriveparm(0, &pddt->ddt_defbpb); - pddt->ddt_ncyl = (pddt->ddt_type & 7) ? 80 : 40; - pddt->ddt_descflags = init_readdasd(0); - - pddt->ddt_offset = 0l; - pddt->ddt_serialno = 0x12345678l; - memcpy(&pddt->ddt_bpb, &pddt->ddt_defbpb, sizeof(bpb)); - - if (Unit == 0) - push_ddt(pddt); - } - - /* Initial number of disk units */ - nUnits = 2; + make_ddt(&nddt, 0, 0, 0); /* this is a quick patch - see if B: exists test for A: also, need not exist */ init_call_intr(0x11, ®s); /* get equipment list */ - if ((regs.a.x & 1) && (regs.a.x & 0xc0)) +/*if ((regs.AL & 1)==0)*//* no floppy drives installed */ + if ((regs.AL & 1) && (regs.AL & 0xc0)) { - pddt->ddt_driveno = 1; - pddt->ddt_type = init_getdriveparm(1, &pddt->ddt_defbpb); - pddt->ddt_descflags = init_readdasd(1); - pddt->ddt_ncyl = (pddt->ddt_type & 7) ? 80 : 40; /* floppy drives installed and a B: drive */ -/*if ((r.a.x & 1)==0) *//* no floppy drives installed */ + make_ddt(&nddt, 1, 1, 0); } else - { /* set up the DJ method : multiple logical drives */ - pddt->ddt_descflags |= DF_MULTLOG; + { + /* set up the DJ method : multiple logical drives */ + make_ddt(&nddt, 1, 0, DF_MULTLOG); } - push_ddt(pddt); - nHardDisk = min(nHardDisk, MAX_HARD_DRIVE - 1); + /* Initial number of disk units */ + nUnits = 2; - memset(foundPartitions, 0, sizeof(foundPartitions)); + nHardDisk = BIOS_nrdrives(); + if (nHardDisk > LENGTH(foundPartitions)) + nHardDisk = LENGTH(foundPartitions); DebugPrintf(("DSK init: found %d disk drives\n", nHardDisk)); /* Reset the drives */ for (HardDrive = 0; HardDrive < nHardDisk; HardDrive++) + { BIOS_drive_reset(HardDrive); + foundPartitions[HardDrive] = 0; + } if (InitKernelConfig.DLASortByDriveNo == 0) { - /* printf("Drive Letter Assignment - DOS order \n"); */ + /* printf("Drive Letter Assignment - DOS order\n"); */ /* Process primary partition table 1 partition only */ for (HardDrive = 0; HardDrive < nHardDisk; HardDrive++) @@ -1349,37 +1347,34 @@ void ReadAllPartitionTables(void) } else { - UBYTE bootdrv; - struct DriveParamS driveParam; + UBYTE bootdrv = peekb(0,0x5e0); /* printf("Drive Letter Assignment - sorted by drive\n"); */ /* Process primary partition table 1 partition only */ - bootdrv = *(UBYTE FAR *)MK_FP(0,0x5e0); for (HardDrive = 0; HardDrive < nHardDisk; HardDrive++) { - memset(&driveParam, 0, sizeof(driveParam)); - ExtLBAForce = FALSE; - if (LBA_Get_Drive_Parameters(HardDrive, &driveParam)) + struct DriveParamS driveParam; + if (LBA_Get_Drive_Parameters(HardDrive, &driveParam) && + driveParam.driveno == bootdrv) { - if (driveParam.driveno == bootdrv) - { - foundPartitions[HardDrive] = - ProcessDisk(SCAN_PRIMARYBOOT, HardDrive, 0); - break; - } + foundPartitions[HardDrive] = + ProcessDisk(SCAN_PRIMARYBOOT, HardDrive, 0); + break; } } for (HardDrive = 0; HardDrive < nHardDisk; HardDrive++) { if (foundPartitions[HardDrive] == 0) + { foundPartitions[HardDrive] = ProcessDisk(SCAN_PRIMARYBOOT, HardDrive, 0); - if (foundPartitions[HardDrive] == 0) - foundPartitions[HardDrive] = + if (foundPartitions[HardDrive] == 0) + foundPartitions[HardDrive] = ProcessDisk(SCAN_PRIMARY, HardDrive, 0); + } /* Process extended partition table */ ProcessDisk(SCAN_EXTENDED, HardDrive, 0); From 0168037d73e0f574fdfd6d68d54bc0dab43a47d1 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Fri, 28 May 2004 11:58:18 +0000 Subject: [PATCH 536/671] From Lucho: no need to preserve ebx git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@964 6ac86273-5f31-0410-b378-82cca8765d1b --- hdr/stacks.inc | 9 +++------ kernel/entry.asm | 2 +- kernel/inthndlr.c | 2 +- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/hdr/stacks.inc b/hdr/stacks.inc index cf49d2b8..129f34aa 100644 --- a/hdr/stacks.inc +++ b/hdr/stacks.inc @@ -117,8 +117,9 @@ irp_hi equ 26 ; later ; ; assumption: -; we have never seen MSVC to use anything but eax,ecx, edx -; so we only protect eax, ebx, ecx, edx to conserve stack space +; we have never seen MSVC to use anything but eax, ecx, edx, +; nor have we seen Borland C to use anything but eax, edx, +; so we only protect eax, ecx, edx to conserve stack space ; ; to save even more stack space, we save only HIGH part of regs ; at some expense of slower execution. it's easier anyway :-) @@ -148,8 +149,6 @@ irp_hi equ 26 %else push eax pop ax - push ebx - pop bx push ecx pop cx push edx @@ -168,8 +167,6 @@ irp_hi equ 26 pop edx push cx pop ecx - push bx - pop ebx push ax pop eax %endif diff --git a/kernel/entry.asm b/kernel/entry.asm index 9a467028..f1a39272 100644 --- a/kernel/entry.asm +++ b/kernel/entry.asm @@ -352,7 +352,7 @@ int21_exit_nodec: %ifdef WATCOM sub bp, 4 ; for fs and gs only %else - sub bp, 8 ; high parts of eax, ebx, ecx, edx + sub bp, 6 ; high parts of eax, ecx, edx %endif %endif diff --git a/kernel/inthndlr.c b/kernel/inthndlr.c index 331202db..5902d589 100644 --- a/kernel/inthndlr.c +++ b/kernel/inthndlr.c @@ -1635,7 +1635,7 @@ struct int2f12regs { #ifdef __WATCOMC__ /* UWORD gs, fs; ** GS/FS are protected through SI/DI */ #else - UWORD high_edx, high_ecx, high_ebx, high_eax; + UWORD high_edx, high_ecx, high_eax; #endif #endif UWORD es, ds; From dace548223bd0364e61a1787ec3c4c43cd0799d1 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Fri, 28 May 2004 12:57:41 +0000 Subject: [PATCH 537/671] (mostly from Lucho) deal with the correct structure for generic and query ioctls. Fixes issues with 3rd party device drivers (or ones that use dsk.c) git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@965 6ac86273-5f31-0410-b378-82cca8765d1b --- hdr/device.h | 22 +++++++++++++++++++++ kernel/dsk.c | 52 +++++++++++++++++++++++++++----------------------- kernel/ioctl.c | 18 ++++++++++++++--- 3 files changed, 65 insertions(+), 27 deletions(-) diff --git a/hdr/device.h b/hdr/device.h index f8f2f5e2..6a35f615 100644 --- a/hdr/device.h +++ b/hdr/device.h @@ -366,6 +366,19 @@ typedef struct { struct { unsigned char _r_ndbyte; /* Byte Read From Device */ } _r_nd; + struct { + UBYTE _r_cat; /* Category code */ + UBYTE _r_fun; /* Function code */ + UBYTE unused[4]; /* SI or DI contents or DS:reqhdr */ + union + { + struct gblkio FAR *_r_io; + struct gblkrw FAR *_r_rw; + struct gblkfv FAR *_r_fv; + struct Gioc_media FAR *_r_gioc; + struct Access_info FAR *_r_ai; + } _r_par; /* Pointer to param. block from 440C/440D */ + } _r_gen; } _r_x; } request; @@ -403,6 +416,15 @@ typedef struct { /* ndread packet macros */ #define r_ndbyte _r_x._r_nd._r_ndbyte +/* generic IOCTL and IOCTL query macros */ +#define r_cat _r_x._r_gen._r_cat +#define r_fun _r_x._r_gen._r_fun +#define r_rw _r_x._r_gen._r_par._r_rw +#define r_io _r_x._r_gen._r_par._r_io +#define r_fv _r_x._r_gen._r_par._r_fv +#define r_gioc _r_x._r_gen._r_par._r_gioc +#define r_ai _r_x._r_gen._r_par._r_ai + /* *interrupt support (spl & splx) support - IBM style */ diff --git a/kernel/dsk.c b/kernel/dsk.c index 1928e24c..66d5ed1c 100644 --- a/kernel/dsk.c +++ b/kernel/dsk.c @@ -472,19 +472,23 @@ STATIC WORD IoctlQueblk(rqptr rp, ddt * pddt) { UNREFERENCED_PARAMETER(pddt); - switch (rp->r_count) +#ifdef WITHFAT32 + if (rp->r_cat == 8 || rp->r_cat == 0x48) +#else + if (rp->r_cat == 8) +#endif { - case 0x0846: - case 0x0847: - case 0x0860: - case 0x0866: - case 0x0867: - break; - default: - return failure(E_CMD); + switch (rp->r_fun) + { + case 0x46: + case 0x47: + case 0x60: + case 0x66: + case 0x67: + return S_DONE; + } } - return S_DONE; - + return failure(E_CMD); } STATIC COUNT Genblockio(ddt * pddt, UWORD mode, WORD head, WORD track, @@ -506,18 +510,18 @@ STATIC WORD Genblkdev(rqptr rp, ddt * pddt) #ifdef WITHFAT32 int extended = 0; - if ((rp->r_count >> 8) == 0x48) + if (rp->r_cat == 0x48) extended = 1; else #endif - if ((rp->r_count >> 8) != 8) + if (rp->r_cat != 8) return failure(E_CMD); - switch (rp->r_count & 0xff) + switch (rp->r_fun) { case 0x40: /* set device parameters */ { - struct gblkio FAR *gblp = (struct gblkio FAR *)rp->r_trans; + struct gblkio FAR *gblp = rp->r_io; bpb *pbpb; pddt->ddt_type = gblp->gbio_devtype; @@ -539,7 +543,7 @@ STATIC WORD Genblkdev(rqptr rp, ddt * pddt) } case 0x41: /* write track */ { - struct gblkrw FAR *rw = (struct gblkrw FAR *)rp->r_trans; + struct gblkrw FAR *rw = rp->r_rw; ret = Genblockio(pddt, LBA_WRITE, rw->gbrw_head, rw->gbrw_cyl, rw->gbrw_sector, rw->gbrw_nsecs, rw->gbrw_buffer); if (ret != 0) @@ -548,7 +552,7 @@ STATIC WORD Genblkdev(rqptr rp, ddt * pddt) break; case 0x42: /* format/verify track */ { - struct gblkfv FAR *fv = (struct gblkfv FAR *)rp->r_trans; + struct gblkfv FAR *fv = rp->r_fv; COUNT tracks; struct thst { UBYTE track, head, sector, type; @@ -650,7 +654,7 @@ STATIC WORD Genblkdev(rqptr rp, ddt * pddt) case 0x62: /* verify track */ { - struct gblkfv FAR *fv = (struct gblkfv FAR *)rp->r_trans; + struct gblkfv FAR *fv = rp->r_fv; ret = Genblockio(pddt, LBA_VERIFY, fv->gbfv_head, fv->gbfv_cyl, 0, (fv->gbfv_spcfunbit ? @@ -663,7 +667,7 @@ STATIC WORD Genblkdev(rqptr rp, ddt * pddt) break; case 0x46: /* set volume serial number */ { - struct Gioc_media FAR *gioc = (struct Gioc_media FAR *)rp->r_trans; + struct Gioc_media FAR *gioc = rp->r_gioc; struct FS_info *fs; ret = getbpb(pddt); @@ -682,14 +686,14 @@ STATIC WORD Genblkdev(rqptr rp, ddt * pddt) break; case 0x47: /* set access flag */ { - struct Access_info FAR *ai = (struct Access_info FAR *)rp->r_trans; + struct Access_info FAR *ai = rp->r_ai; pddt->ddt_descflags = (descflags & ~DF_NOACCESS) | (ai->AI_Flag ? 0 : DF_NOACCESS); } break; case 0x60: /* get device parameters */ { - struct gblkio FAR *gblp = (struct gblkio FAR *)rp->r_trans; + struct gblkio FAR *gblp = rp->r_io; bpb *pbpb; gblp->gbio_devtype = pddt->ddt_type; @@ -712,7 +716,7 @@ STATIC WORD Genblkdev(rqptr rp, ddt * pddt) } case 0x61: /* read track */ { - struct gblkrw FAR *rw = (struct gblkrw FAR *)rp->r_trans; + struct gblkrw FAR *rw = rp->r_rw; ret = Genblockio(pddt, LBA_READ, rw->gbrw_head, rw->gbrw_cyl, rw->gbrw_sector, rw->gbrw_nsecs, rw->gbrw_buffer); if (ret != 0) @@ -721,7 +725,7 @@ STATIC WORD Genblkdev(rqptr rp, ddt * pddt) break; case 0x66: /* get volume serial number */ { - struct Gioc_media FAR *gioc = (struct Gioc_media FAR *)rp->r_trans; + struct Gioc_media FAR *gioc = rp->r_gioc; ret = getbpb(pddt); if (ret != 0) @@ -734,7 +738,7 @@ STATIC WORD Genblkdev(rqptr rp, ddt * pddt) break; case 0x67: /* get access flag */ { - struct Access_info FAR *ai = (struct Access_info FAR *)rp->r_trans; + struct Access_info FAR *ai = rp->r_ai; ai->AI_Flag = descflags & DF_NOACCESS ? 0 : 1; /* bit 9 */ } break; diff --git a/kernel/ioctl.c b/kernel/ioctl.c index 157d6f86..38677ad1 100644 --- a/kernel/ioctl.c +++ b/kernel/ioctl.c @@ -59,13 +59,25 @@ COUNT DosDevIOctl(lregs * r) sft FAR *s; struct dpb FAR *dpbp; COUNT nMode; + unsigned char al = r->AL; - /* commonly used, shouldn't harm to do front up */ + if (al > 0x11) + return DE_INVLDFUNC; + /* commonly used, shouldn't harm to do front up */ + if (al == 0x0C || al == 0x0D || al >= 0x10) /* generic or query */ + { + CharReqHdr.r_cat = r->CH; /* category (major) code */ + CharReqHdr.r_fun = r->CL; /* function (minor) code */ + CharReqHdr.r_io = MK_FP(r->DS, r->DX); /* parameter block */ + } + else + { + CharReqHdr.r_count = r->CX; + CharReqHdr.r_trans = MK_FP(r->DS, r->DX); + } CharReqHdr.r_length = sizeof(request); - CharReqHdr.r_trans = MK_FP(r->DS, r->DX); CharReqHdr.r_status = 0; - CharReqHdr.r_count = r->CX; /* Test that the handle is valid */ switch (r->AL) From 4199f4c6c8b96db983962efacf884fc9dd851649 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Fri, 28 May 2004 13:15:22 +0000 Subject: [PATCH 538/671] Cache attr and control flow optimizations from Lucho (~120 bytes) git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@966 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/ioctl.c | 93 ++++++++++++++++++-------------------------------- 1 file changed, 33 insertions(+), 60 deletions(-) diff --git a/kernel/ioctl.c b/kernel/ioctl.c index 38677ad1..115e0dbc 100644 --- a/kernel/ioctl.c +++ b/kernel/ioctl.c @@ -59,6 +59,7 @@ COUNT DosDevIOctl(lregs * r) sft FAR *s; struct dpb FAR *dpbp; COUNT nMode; + unsigned attr; unsigned char al = r->AL; if (al > 0x11) @@ -79,9 +80,15 @@ COUNT DosDevIOctl(lregs * r) CharReqHdr.r_length = sizeof(request); CharReqHdr.r_status = 0; - /* Test that the handle is valid */ switch (r->AL) { + case 0x0b: + /* skip, it's a special case. */ + NetDelay = r->CX; + if (r->DX) + NetRetry = r->DX; + break; + case 0x00: case 0x01: case 0x02: @@ -94,7 +101,8 @@ COUNT DosDevIOctl(lregs * r) { unsigned attr, flags; - /* Get the SFT block that contains the SFT */ + /* Test that the handle is valid and */ + /* get the SFT block that contains the SFT */ if ((s = get_sft(r->BX)) == (sft FAR *) - 1) return DE_INVLDHNDL; @@ -166,14 +174,14 @@ COUNT DosDevIOctl(lregs * r) nMode = C_GENIOCTL; goto IoCharCommon; - case 0x10: + default: /* 0x10 */ nMode = C_IOCTLQRY; IoCharCommon: if ((flags & SFT_FDEVICE) && - ( ((r->AL == 0x02 || r->AL == 0x03) && (attr & ATTR_IOCTL)) - || r->AL == 0x06 || r->AL == 0x07 - || ((r->AL == 0x10) && (attr & ATTR_QRYIOCTL)) - || ((r->AL == 0x0c) && (attr & ATTR_GENIOCTL)))) + ( (r->AL <= 0x03 && (attr & ATTR_IOCTL)) + || r->AL == 0x06 || r->AL == 0x07 + || (r->AL == 0x10 && (attr & ATTR_QRYIOCTL)) + || (r->AL == 0x0c && (attr & ATTR_GENIOCTL)))) { CharReqHdr.r_unit = 0; CharReqHdr.r_command = nMode; @@ -185,35 +193,20 @@ COUNT DosDevIOctl(lregs * r) return DE_DEVICE; } - if (r->AL == 0x06 || r->AL == 0x07) - { - r->AX = CharReqHdr.r_status & S_BUSY ? 0000 : 0x00ff; - } - else if (r->AL == 0x02 || r->AL == 0x03) - { + if (r->AL <= 0x03) r->AX = CharReqHdr.r_count; - } - else if (r->AL == 0x0c || r->AL == 0x10) - { + else if (r->AL == 0x06 || r->AL == 0x07) + r->AX = CharReqHdr.r_status & S_BUSY ? 0000 : 0x00ff; + else /* 0x0c or 0x10 */ r->AX = CharReqHdr.r_status; - } break; } - /* fall through */ - default: return DE_INVLDFUNC; } break; } - case 0x04: - case 0x05: - case 0x08: - case 0x09: - case 0x0d: - case 0x0e: - case 0x0f: - case 0x11: + default: /* block IOCTL: 4, 5, 8, 9, d, e, f, 11 */ /* This line previously returned the deviceheader at r->bl. But, @@ -235,6 +228,7 @@ COUNT DosDevIOctl(lregs * r) #endif dpbp = get_dpb(CharReqHdr.r_unit); + attr = dpbp->dpb_device->dh_attr; switch (r->AL) { @@ -249,7 +243,7 @@ COUNT DosDevIOctl(lregs * r) { return DE_INVLDDRV; } - if (dpbp->dpb_device->dh_attr & ATTR_EXCALLS) + if (attr & ATTR_EXCALLS) { nMode = C_REMMEDIA; goto IoBlockCommon; @@ -269,7 +263,7 @@ COUNT DosDevIOctl(lregs * r) { return DE_INVLDDRV; } - r->DX = dpbp->dpb_device->dh_attr; + r->DX = attr; } if (cdsp->cdsFlags & CDSSUBST) { @@ -292,12 +286,9 @@ COUNT DosDevIOctl(lregs * r) r->AX = 0; /* (lock/unlock logical/physical volume) */ break; /* simulate success for MS-DOS 7+ SCANDISK etc. --LG */ } - if (((r->AL == 0x04 || r->AL == 0x05) && - !(dpbp->dpb_device->dh_attr & ATTR_IOCTL)) - || ((r->AL == 0x11) - && !(dpbp->dpb_device->dh_attr & ATTR_QRYIOCTL)) - || ((r->AL == 0x0d) - && !(dpbp->dpb_device->dh_attr & ATTR_GENIOCTL))) + if ((r->AL <= 0x05 && !(attr & ATTR_IOCTL)) + || (r->AL == 0x11 && !(attr & ATTR_QRYIOCTL)) + || (r->AL == 0x0d && !(attr & ATTR_GENIOCTL))) { return DE_INVLDFUNC; } @@ -310,32 +301,25 @@ COUNT DosDevIOctl(lregs * r) CritErrCode = (CharReqHdr.r_status & S_MASK) + 0x13; return DE_DEVICE; } - if (r->AL == 0x08) - { - r->AX = (CharReqHdr.r_status & S_BUSY) ? 1 : 0; - } - - else if (r->AL == 0x04 || r->AL == 0x05) - { + if (r->AL <= 0x05) r->AX = CharReqHdr.r_count; - } - else if (r->AL == 0x0d || r->AL == 0x11) - { + else if (r->AL == 0x08) + r->AX = (CharReqHdr.r_status & S_BUSY) ? 1 : 0; + else /* 0x0d or 0x11 */ r->AX = CharReqHdr.r_status; - } break; case 0x0e: nMode = C_GETLDEV; goto IoLogCommon; - case 0x0f: + default: /* 0x0f */ nMode = C_SETLDEV; IoLogCommon: if (!dpbp) { return DE_INVLDDRV; } - if ((dpbp->dpb_device->dh_attr & ATTR_GENIOCTL)) + if (attr & ATTR_GENIOCTL) { CharReqHdr.r_command = nMode; @@ -351,21 +335,10 @@ COUNT DosDevIOctl(lregs * r) r->AL = CharReqHdr.r_unit; return SUCCESS; } - } /* fall through */ - default: + } return DE_INVLDFUNC; } break; - - case 0x0b: - /* skip, it's a special case. */ - NetDelay = r->CX; - if (r->DX) - NetRetry = r->DX; - break; - - default: - return DE_INVLDFUNC; } return SUCCESS; } From 3f72bd186544e74748c73031ebea57f0c4609bc5 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Fri, 28 May 2004 13:44:49 +0000 Subject: [PATCH 539/671] DJ mechanism without memcpy. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@967 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/dsk.c | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/kernel/dsk.c b/kernel/dsk.c index 66d5ed1c..08f610c3 100644 --- a/kernel/dsk.c +++ b/kernel/dsk.c @@ -185,7 +185,7 @@ COUNT ASMCFUNC FAR blk_driver(rqptr rp) return ((*dispatch[rp->r_command]) (rp, getddt(rp->r_unit))); } -STATIC char template_string[] = "XXXXXX diskette in drive X:\n"; +STATIC char template_string[] = "Remove diskette in drive X:\n"; #define DRIVE_POS (sizeof(template_string) - 4) STATIC WORD play_dj(ddt * pddt) @@ -205,19 +205,20 @@ STATIC WORD play_dj(ddt * pddt) if (i == blk_dev.dh_name[0]) { put_string("Error in the DJ mechanism!\n"); /* should not happen! */ - return M_CHANGED; } - memcpy(template_string, "Remove", 6); - template_string[DRIVE_POS] = 'A' + pddt2->ddt_logdriveno; - put_string(template_string); - memcpy(template_string, "Insert", 6); - template_string[DRIVE_POS] = 'A' + pddt->ddt_logdriveno; - put_string(template_string); - put_string("Press the any key to continue ... \n"); - fl_readkey(); - pddt2->ddt_descflags &= ~DF_CURLOG; - pddt->ddt_descflags |= DF_CURLOG; - pokeb(0, 0x504, pddt->ddt_logdriveno); + else + { + template_string[DRIVE_POS] = 'A' + pddt2->ddt_logdriveno; + put_string(template_string); + put_string("Insert"); + template_string[DRIVE_POS] = 'A' + pddt->ddt_logdriveno; + put_string(template_string + 6); + put_string("Press the any key to continue ... \n"); + fl_readkey(); + pddt2->ddt_descflags &= ~DF_CURLOG; + pddt->ddt_descflags |= DF_CURLOG; + pokeb(0, 0x504, pddt->ddt_logdriveno); + } return M_CHANGED; } return M_NOT_CHANGED; From 7a9c620d82fa57a96082255d92cbcab94968bd10 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Fri, 28 May 2004 19:08:48 +0000 Subject: [PATCH 540/671] DosUmbLink no longer tries to merge free blocks. Also cleaned up a bit. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@968 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/inthndlr.c | 2 +- kernel/memmgr.c | 51 +++++++++++++++++++---------------------------- kernel/proto.h | 2 +- 3 files changed, 22 insertions(+), 33 deletions(-) diff --git a/kernel/inthndlr.c b/kernel/inthndlr.c index 5902d589..de55c2f3 100644 --- a/kernel/inthndlr.c +++ b/kernel/inthndlr.c @@ -1142,7 +1142,7 @@ VOID ASMCFUNC int21_service(iregs FAR * r) case 0x03: if (uppermem_root != 0xffff) /* always error if not exists */ { - DosUmbLink(lr.BL); + DosUmbLink(lr.BX); break; } /* else fall through */ diff --git a/kernel/memmgr.c b/kernel/memmgr.c index f641b437..987143fc 100644 --- a/kernel/memmgr.c +++ b/kernel/memmgr.c @@ -119,7 +119,7 @@ COUNT DosMemAlloc(UWORD size, COUNT mode, seg *para, UWORD *asize) /* Hack to the Umb Region direct for now. Save time and program space. */ - if (uppermem_link && uppermem_root != 0xffff) + if ((uppermem_link & 1) && uppermem_root != 0xffff) { COUNT tmpmode = (mode == LARGEST ? mem_access_mode : mode); if ((mode != LARGEST || size == 0xffff) && @@ -189,7 +189,7 @@ COUNT DosMemAlloc(UWORD size, COUNT mode, seg *para, UWORD *asize) if (!foundSeg || !foundSeg->m_size) { /* no block to fullfill the request */ if ((mode != LARGEST) && (mode & FIRST_FIT_U) && - uppermem_link && uppermem_root != 0xffff) + (uppermem_link & 1) && uppermem_root != 0xffff) { mode &= ~FIRST_FIT_U; goto searchAgain; @@ -401,7 +401,7 @@ COUNT DosMemCheck(void) COUNT FreeProcessMem(UWORD ps) { mcb FAR *p; - BYTE oldumbstate = uppermem_link; + BYTE oldumbstate = uppermem_link & 1; /* link in upper memory to free those , too */ DosUmbLink(1); @@ -455,7 +455,7 @@ VOID mcb_print(mcb FAR * mcbp) } #endif -VOID DosUmbLink(BYTE n) +void DosUmbLink(unsigned n) { REG mcb FAR *p; REG mcb FAR *q; @@ -463,37 +463,26 @@ VOID DosUmbLink(BYTE n) if (uppermem_root == 0xffff) return; - q = p = para2far(first_mcb); -/* like a xor thing! */ - if ((uppermem_link == 1) && (n == 0)) + p = para2far(first_mcb); + if (n > 1 || (uppermem_link & 1) == n) + return; + while (FP_SEG(p) != uppermem_root && p->m_type != MCB_LAST) { - while (FP_SEG(p) != uppermem_root) - { - if (mcbFree(p)) - joinMCBs(FP_SEG(p)); - if (!mcbValid(p)) - return; - q = p; - p = nxtMCB(p); - } - - if (q->m_type == MCB_NORMAL) - q->m_type = MCB_LAST; - uppermem_link = n; - + if (!mcbValid(p)) + return; + q = p; + p = nxtMCB(p); } - else if ((uppermem_link == 0) && (n == 1)) + if (n == 0) { - while (q->m_type != MCB_LAST) - { - if (!mcbValid(q)) - return; - q = nxtMCB(q); - } - - q->m_type = MCB_NORMAL; - uppermem_link = n; + if (q->m_type == MCB_NORMAL && FP_SEG(p) == uppermem_root) + q->m_type = MCB_LAST; } + else if (p->m_type == MCB_LAST) + p->m_type = MCB_NORMAL; + else + return; + uppermem_link = n; } #endif diff --git a/kernel/proto.h b/kernel/proto.h index 9b9512c2..524d5a8e 100644 --- a/kernel/proto.h +++ b/kernel/proto.h @@ -248,7 +248,7 @@ COUNT DosMemCheck(void); COUNT FreeProcessMem(UWORD ps); COUNT DosGetLargestBlock(UWORD * block); VOID show_chain(void); -VOID DosUmbLink(BYTE n); +void DosUmbLink(unsigned n); VOID mcb_print(mcb FAR * mcbp); /* lfnapi.c */ From 41edf4f6403f01bc60f7537f021209782b11a2d1 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sat, 29 May 2004 01:33:12 +0000 Subject: [PATCH 541/671] Don't take attr if dpbp == NULL! OW does some optimizations assuming that NULL does not point to valid memory, in this case it hurts. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@969 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/ioctl.c | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/kernel/ioctl.c b/kernel/ioctl.c index 115e0dbc..6314be90 100644 --- a/kernel/ioctl.c +++ b/kernel/ioctl.c @@ -228,7 +228,10 @@ COUNT DosDevIOctl(lregs * r) #endif dpbp = get_dpb(CharReqHdr.r_unit); - attr = dpbp->dpb_device->dh_attr; + if (dpbp) + attr = dpbp->dpb_device->dh_attr; + else if (r->AL != 9) + return DE_INVLDDRV; switch (r->AL) { @@ -239,10 +242,6 @@ COUNT DosDevIOctl(lregs * r) nMode = C_IOCTLOUT; goto IoBlockCommon; case 0x08: - if (!dpbp) - { - return DE_INVLDDRV; - } if (attr & ATTR_EXCALLS) { nMode = C_REMMEDIA; @@ -277,10 +276,6 @@ COUNT DosDevIOctl(lregs * r) case 0x11: nMode = C_IOCTLQRY; IoBlockCommon: - if (!dpbp) - { - return DE_INVLDDRV; - } if (r->AL == 0x0D && (r->CX & ~(0x486B-0x084A)) == 0x084A) { /* 084A/484A, 084B/484B, 086A/486A, 086B/486B */ r->AX = 0; /* (lock/unlock logical/physical volume) */ @@ -315,10 +310,6 @@ COUNT DosDevIOctl(lregs * r) default: /* 0x0f */ nMode = C_SETLDEV; IoLogCommon: - if (!dpbp) - { - return DE_INVLDDRV; - } if (attr & ATTR_GENIOCTL) { From 2c8a4b8c34e44f918ba5cc51010d757d0a1dba0a Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sat, 29 May 2004 09:51:47 +0000 Subject: [PATCH 542/671] MSC fixes and small cleanups from Lucho git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@970 6ac86273-5f31-0410-b378-82cca8765d1b --- hdr/device.h | 5 +++++ kernel/dsk.c | 5 ----- kernel/init-mod.h | 2 +- kernel/ioctl.c | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/hdr/device.h b/hdr/device.h index 6a35f615..a01bae54 100644 --- a/hdr/device.h +++ b/hdr/device.h @@ -296,6 +296,11 @@ struct Gioc_media { BYTE ioc_fstype[8]; }; +struct Access_info { + BYTE AI_spec; + BYTE AI_Flag; +}; + /* */ /* Boot Block (Super Block) */ /* */ diff --git a/kernel/dsk.c b/kernel/dsk.c index 08f610c3..96368dc5 100644 --- a/kernel/dsk.c +++ b/kernel/dsk.c @@ -81,11 +81,6 @@ UWORD LBA_WRITE_VERIFY = 0x4302; */ UBYTE DiskTransferBuffer[1 * SEC_SIZE]; -struct Access_info { - BYTE AI_spec; - BYTE AI_Flag; -}; - struct FS_info { ULONG serialno; BYTE volume[11]; diff --git a/kernel/init-mod.h b/kernel/init-mod.h index a9dd0811..aab74761 100644 --- a/kernel/init-mod.h +++ b/kernel/init-mod.h @@ -271,7 +271,7 @@ extern UWORD DOSFAR LBA_WRITE_VERIFY; /* floppy parameter table, at 70:xxxx */ extern unsigned char DOSTEXTFAR ASM int1e_table[0xe]; -extern char DOSTEXTFAR DiskTransferBuffer[SEC_SIZE]; /* in dsk.c */ +extern char DOSFAR DiskTransferBuffer[SEC_SIZE]; /* in dsk.c */ struct RelocationTable { UBYTE jmpFar; diff --git a/kernel/ioctl.c b/kernel/ioctl.c index 6314be90..bb9a753d 100644 --- a/kernel/ioctl.c +++ b/kernel/ioctl.c @@ -99,7 +99,7 @@ COUNT DosDevIOctl(lregs * r) case 0x0c: case 0x10: { - unsigned attr, flags; + unsigned flags; /* Test that the handle is valid and */ /* get the SFT block that contains the SFT */ @@ -195,7 +195,7 @@ COUNT DosDevIOctl(lregs * r) if (r->AL <= 0x03) r->AX = CharReqHdr.r_count; - else if (r->AL == 0x06 || r->AL == 0x07) + else if (r->AL <= 0x07) r->AX = CharReqHdr.r_status & S_BUSY ? 0000 : 0x00ff; else /* 0x0c or 0x10 */ r->AX = CharReqHdr.r_status; From 11e6ccefbfcde58de013c335795a2bc3ce902958 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sun, 30 May 2004 19:31:07 +0000 Subject: [PATCH 543/671] high-part-of register save fixes from Lucho. Bump version to 2035. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@971 6ac86273-5f31-0410-b378-82cca8765d1b --- docs/fdkernel.lsm | 4 ++-- hdr/stacks.inc | 14 ++++++++++++-- hdr/version.h | 8 ++++---- kernel/entry.asm | 2 +- kernel/inthndlr.c | 8 +++++++- kernel/io.asm | 1 + kernel/nlssupt.asm | 1 + 7 files changed, 28 insertions(+), 10 deletions(-) diff --git a/docs/fdkernel.lsm b/docs/fdkernel.lsm index c3b0f54d..d9a21de8 100644 --- a/docs/fdkernel.lsm +++ b/docs/fdkernel.lsm @@ -1,7 +1,7 @@ Begin3 Title: The FreeDOS Kernel -Version: 2.0.34 -Entered-date: 17 Apr 2004 +Version: 2.0.35 +Entered-date: 30 May 2004 Description: The FreeDOS Kernel. Keywords: kernel freedos dos msdos Author: (developers) diff --git a/hdr/stacks.inc b/hdr/stacks.inc index 129f34aa..f3681b8a 100644 --- a/hdr/stacks.inc +++ b/hdr/stacks.inc @@ -118,8 +118,8 @@ irp_hi equ 26 ; ; assumption: ; we have never seen MSVC to use anything but eax, ecx, edx, -; nor have we seen Borland C to use anything but eax, edx, -; so we only protect eax, ecx, edx to conserve stack space +; nor have we seen Borland C to use anything but eax, ebx, edx, +; so we only protect eax, ebx or ecx, edx to conserve stack space ; ; to save even more stack space, we save only HIGH part of regs ; at some expense of slower execution. it's easier anyway :-) @@ -149,8 +149,13 @@ irp_hi equ 26 %else push eax pop ax + %ifdef MSCL8 push ecx pop cx + %else ;BC5 + push ebx + pop bx + %endif push edx pop dx %endif @@ -165,8 +170,13 @@ irp_hi equ 26 %else push dx pop edx + %ifdef MSCL8 push cx pop ecx + %else ;BC5 + push bx + pop ebx + %endif push ax pop eax %endif diff --git a/hdr/version.h b/hdr/version.h index 8199d9fc..98272d74 100644 --- a/hdr/version.h +++ b/hdr/version.h @@ -47,8 +47,8 @@ static BYTE *date_hRcsId = #define REVISION_MAJOR 1 #define REVISION_MINOR 1 -#define REVISION_SEQ 34 -#define BUILD "2034" +#define REVISION_SEQ 35 +#define BUILD "2035" #define SUB_BUILD "" -#define KERNEL_VERSION_STRING "1.1.34" /*#REVISION_MAJOR "." #REVISION_MINOR "." #REVISION_SEQ */ -#define KERNEL_BUILD_STRING "2034" /*#BUILD SUB_BUILD */ +#define KERNEL_VERSION_STRING "1.1.35" /*#REVISION_MAJOR "." #REVISION_MINOR "." #REVISION_SEQ */ +#define KERNEL_BUILD_STRING "2035" /*#BUILD SUB_BUILD */ diff --git a/kernel/entry.asm b/kernel/entry.asm index f1a39272..d0610fd8 100644 --- a/kernel/entry.asm +++ b/kernel/entry.asm @@ -352,7 +352,7 @@ int21_exit_nodec: %ifdef WATCOM sub bp, 4 ; for fs and gs only %else - sub bp, 6 ; high parts of eax, ecx, edx + sub bp, 6 ; high parts of eax, ebx or ecx, edx %endif %endif diff --git a/kernel/inthndlr.c b/kernel/inthndlr.c index de55c2f3..6cf6ab74 100644 --- a/kernel/inthndlr.c +++ b/kernel/inthndlr.c @@ -1635,7 +1635,13 @@ struct int2f12regs { #ifdef __WATCOMC__ /* UWORD gs, fs; ** GS/FS are protected through SI/DI */ #else - UWORD high_edx, high_ecx, high_eax; + UWORD high_edx, +#ifdef _MSC_VER + high_ecx, +#else /* __BORLANDC__ */ + high_ebx, +#endif + high_eax; #endif #endif UWORD es, ds; diff --git a/kernel/io.asm b/kernel/io.asm index 662d753a..32d13afb 100644 --- a/kernel/io.asm +++ b/kernel/io.asm @@ -29,6 +29,7 @@ ; %include "segs.inc" + %include "stacks.inc" extern ConTable:wrt LGROUP extern LptTable:wrt LGROUP diff --git a/kernel/nlssupt.asm b/kernel/nlssupt.asm index 233ea65f..bd375b6e 100644 --- a/kernel/nlssupt.asm +++ b/kernel/nlssupt.asm @@ -29,6 +29,7 @@ %include "segs.inc" + %include "stacks.inc" segment HMA_TEXT global _reloc_call_CharMapSrvc From f93aa599571ef7ae2f89280f3f43a856805a89c8 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sun, 30 May 2004 20:56:29 +0000 Subject: [PATCH 544/671] Update history.txt git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@972 6ac86273-5f31-0410-b378-82cca8765d1b --- docs/history.txt | 124 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 124 insertions(+) diff --git a/docs/history.txt b/docs/history.txt index 81f149ae..f028d193 100644 --- a/docs/history.txt +++ b/docs/history.txt @@ -1,3 +1,127 @@ +2004 May 30 - Build 2035 +-------- Bart Oldeman (bart@dosemu.org) ++ Changes Lucho + Tom + * config.c, fatfs.c, globals.h, init-mod.h: From Tom: must + set r_bpfat for C_BLDBPB, otherwise USBASPI.SYS, DI1000DD.SYS + won't like us. From Lucho: use DiskTransferBuffer for deblock_buf. ++ Changes Lucho + * docs/fdkernel.lsm, stacks.inc, version.h, + entry.asm, inthndlr.c, io.asm, nlssupt.asm: no need to preserve + high part of ecx for Borland, ebx for MSVC + * device.h, dsk.c, init-mod.h, ioctl.c: MSC fixes and small cleanup + * ioctl.c: Cache attr and control flow optimizations (~120 bytes) + * device.h, dsk.c, ioctl.c: deal with the correct + structure for generic and query ioctls. Fixes issues with + 3rd party device drivers (or ones that use dsk.c) + * dosfns.c, inthndlr.c, proto.h: Merge dosmkdir and dosrmdir + * config.c: strcasecmp and set_strategy common code optimizations. + * main.c: Add necessary cast for BC + * portab.h: Avoid problem with BC declaring __emit__, en/disable twice. + * dsk.c: DJ mechanism without memcpy. + * newstuff.c: replace loops by fmemset/fmemcpy (43 bytes) + * dosfns.c, fatdir.c, fcbfns.c, ioctl.c: Some small cleanups. + * config.c: GetNumArg and misc other cleanups + * time.h, fatfs.c: converted TM_ENCODE into a function. + * inthndlr.c, proto.h, fatfs.c: Inlined dos_setdta. + Various bug fixes and cleanups from Lucho and Arkady. + * inithma.c: moved fmemcmp's into a checkHMA function. + * inithma.c: HMAFree == 0xfff0 - bytesToAllocate + is valid and may happen if the buffers occupy exactly all HMA + space up to and including the last byte at ffff:ffff. Failing + caused all buffers to go low ... + * inthndlr.c: cleanups (merge common code into long_check and + short_check). Made int21/3301,2e,54 consistent with MSDOS + behaviour. + * globals.h, task.c, main.c: Convert setvec into a function + for the resident code ++ Changes Arkady + * initdisk.c: initdisk optimizations (65 bytes) and is_suspect fix. + * config.c, init-mod.h, intr.asm: optimized allocmem() + * fattab.c, kernel.asm: optimizations + * main.c: Make signon one big printf function call. + * ioctl.c: bugfix for INT21/440b (change NetRetry if DX is _non_zero). + * inthndlr.c: cntry == 0 doesn't make sense for Set Country + Information. Fix int21/5e02+ + * sys/talloc.c: Turbo C really wants unsigned __brklvl. Only shows + up if you enable stack checking. ++ Changes Bart + * memmgr.c, proto.h, inthndlr.c: DosUmbLink no longer + tries to merge free blocks. Also cleaned up a bit. + * inthndlr.c: Fix int21/3302 (the swap was wrong, Lucho & Bart) + * config.c: Pointer-ise specificCountriesSupported accesses. + * config.c: Reorganized GetBiosKey a bit -- inlining + GetBiosTime saves a slight amount of code, converted timeout < 0 + to a blocking read instead of polling. + * config.c: Use strcaseequal instead of strcasecmp since we + never care about order anyway. + * chario.c: Fix problem with redirected input and + int21/ah=0a (debug < foo.txt) -- could get you an invalid opcode! + * console.asm, main.c, prf.c: Use int29 for kernel console + output. Enables ansi escape sequences in config.sys once you load + nansi.sys. It also saves a couple of bytes. + * newstuff.c, proto.h: made dosmktmp to return a long: + consistent with DosOpen et al and avoids the cast. + * mkfiles/tc2.mak: Let TC2 warn for the utilities. + * config.c: Disabled EBDA moves by default. Automatic EBDA + moves now happen using switches=/e:-1 + * config.c: Pointer-ize MenuStruct[MenuSelected]... (from + Lucho). and InstallCommands[i]. (from Bart). Some other small + optimizations. + * memmgr.c: Some small optimizations (46 bytes) and dead + code removal from Lucho and Bart + * init-mod.h: Need to define strchr to init_strchr otherwise + the wrong one may be called. + * initdisk.c: Do a bit of printf merging. + * filelist, drivers/makefile, init-mod.h, inthndlr.c, + task.c, globals.h, main.c: Convert getvec into a C function. + * int2f.asm: Clean up int2f assembly a bit (merge some + common bits, clarify label names) + * fatfs.c, fattab.c: fattab.c now remembers if the old FAT + entry was free or not, so the free space adjustment could be + moved back to fattab.c. + * init-mod.h: Replaced setvec macro by a function. + * entry.asm, inthndlr.c: Made int21/ah=25,35 reentrant. + Solves problem with Intel PRO/1000 driver. + * portab.h, globals.h, main.c: Initialise all int + vectors except the ones at 70:xxxx using a table. Convert setvec + into a function that disables/enables ints (init code only for + now, resident code will follow later); cli/sti (disable/enable) + are now macros (inlined). + * fnode.h, fatdir.c, fatfs.c: dir_read() no longer updates the + diroff counter. This eliminates the NEW field, + simplifies remove_lfn_entries(), and avoids a bug if you delete + the first entry in the root directory on FAT32. + * fattab.c: Stop abusing "idx". The OW optimizer likes this better,too. + * fattab.c: Clean up FAT12 handling -- there's a portable + approach that's small too. + * fattab.c: Inlined much of getFATblock() into link_fat. + Saves the idx reference. The second call (for a FAT12 entry that + is divided in two sectors) can be much simpler, no need to + recalculate. Merged next_cluster and link_fat into one + function depending on a special Cluster2 value. + * fattab.c: Calculate the nibble/word/dword index of the FAT + entry in the sector centrally in getFATblock. + * fattab.c: "clussec" can be of CLUSTER size if we divide by + an adjusted "words per sector"(FAT16), or "dwords per + sector"(FAT32) value instead of multiplying it first. For FAT12 + the *3/2 works out a little differently: here we first multiply + by 3 and then divide by the number of "nibbles per sector". + * main.c: Config.cfgInitTail is a pointer now so sizeof + isn't good. Just using strcpy helps F5 and F8. + * main.c: "copyright" is near now so we have to use %s and not %S + * blockio.c, dosfns.c, int2f.asm, network.c, proto.h, task.c: + reduced the number of network redirector functions in + int2f.asm. The remote_ functions (with one far pointer + argument) are now called with the help of a + network_redirector() wrapper in C by one multiplex function + using a generic void *arg argument to pass the third + parameter which can be various things. + Split int2f.asm functions, don't let them preserve as many + registers, use pascal calling convention for the "open" + (but really: multiplex) function. + * dsk.c: floppy determination type optimization for format -- + based on Arkady's suggestions a long time ago. + + a few other small optimizations (~70 bytes total). 2004 Apr 17 - Build 2034 -------- Bart Oldeman (bart@dosemu.org) * break.c, chario.c, inthndlr.c, proto.h: Improve ctrl-c/ctrl-break From fe30b5a6989a3555d7c333b25a0d441a010f9de7 Mon Sep 17 00:00:00 2001 From: Bart Oldeman Date: Sun, 30 May 2004 20:59:33 +0000 Subject: [PATCH 545/671] Fix some dependencies. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@973 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/makefile b/kernel/makefile index 78dfe291..0b679488 100644 --- a/kernel/makefile +++ b/kernel/makefile @@ -76,11 +76,11 @@ entry.obj: entry.asm segs.inc $(HDR)stacks.inc $(TARGET).lnk execrh.obj: execrh.asm segs.inc $(TARGET).lnk int2f.obj: int2f.asm segs.inc $(HDR)stacks.inc $(TARGET).lnk intr.obj: intr.asm segs.inc $(TARGET).lnk -io.obj: io.asm segs.inc $(TARGET).lnk +io.obj: io.asm segs.inc $(HDR)stacks.inc $(TARGET).lnk irqstack.obj: irqstack.asm segs.inc $(TARGET).lnk kernel.obj: kernel.asm segs.inc ludivmul.inc $(TARGET).lnk nls_hc.obj: nls_hc.asm segs.inc $(TARGET).lnk -nlssupt.obj: nlssupt.asm segs.inc $(TARGET).lnk +nlssupt.obj: nlssupt.asm segs.inc $(HDR)stacks.inc $(TARGET).lnk printer.obj: printer.asm io.inc $(TARGET).lnk procsupt.obj: procsupt.asm segs.inc $(HDR)stacks.inc $(TARGET).lnk serial.obj: serial.asm io.inc $(TARGET).lnk From b4ec361ab6ee075323a6eb2756950ced40df19c8 Mon Sep 17 00:00:00 2001 From: Kenneth J Davis Date: Fri, 18 Jun 2004 06:57:33 +0000 Subject: [PATCH 546/671] based on floppy.asm patchset from Arkady, use ret instead of ret 8 appropriately; improve comments, including sync with prototypes in dsk.c; small code clean up git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@979 6ac86273-5f31-0410-b378-82cca8765d1b --- drivers/floppy.asm | 178 +++++++++++++++++++++------------------------ hdr/version.h | 4 +- 2 files changed, 85 insertions(+), 97 deletions(-) diff --git a/drivers/floppy.asm b/drivers/floppy.asm index 3d9a5d56..9d9def58 100644 --- a/drivers/floppy.asm +++ b/drivers/floppy.asm @@ -28,129 +28,108 @@ ; $Id$ ; - %include "../kernel/segs.inc" - segment HMA_TEXT -; -; -; Reset both the diskette and hard disk system +%include "../kernel/segs.inc" +segment HMA_TEXT + ; -; BOOL fl_reset(WORD drive) +; BOOL ASMPASCAL fl_reset(WORD drive); ; -; returns TRUE if successful +; Reset both the diskette and hard disk system. +; returns TRUE if successful. ; global FL_RESET FL_RESET: pop ax ; return address - pop dx ; drive + pop dx ; drive, (DL only, bit 7 set resets both floppy & hd) push ax ; restore address - mov ah,0 ; BIOS reset diskette & fixed disk - int 13h + mov ah,0 ; BIOS reset diskette & fixed disk + int 13h - sbb ax,ax ; cy==1 is error - inc ax ; TRUE on success, FALSE on failure - ret + sbb ax,ax ; carry set indicates error, AX=-CF={-1,0} + inc ax ; ...return TRUE (1) on success, + ret ; else FALSE (0) on failure - -; -; -; Read disk change line status ; -; COUNT fl_diskchanged(WORD drive) +; COUNT ASMPASCAL fl_diskchanged(WORD drive); ; -; returns 1 if disk has changed, 0 if not, 0xFFFF if error +; Read disk change line status. +; returns 1 if disk has changed, 0 if not, 0xFFFF if error. ; global FL_DISKCHANGED FL_DISKCHANGED: pop ax ; return address - pop dx ; get the drive number + pop dx ; drive (DL only, 00h-7Fh) push ax ; restore stack - push si ; restore stack - mov ah,16h ; read change status type + push si ; preserve value + mov ah,16h ; read change status type xor si,si ; RBIL: avoid crash on AT&T 6300 - int 13h + int 13h + pop si ; restore - mov al,1 - jnc fl_dc_ret1 ; cy==1 is error or disk has changed + sbb al,al ; AL=-CF={-1,0} where 0==no change + jnc fl_dc ; carry set on error or disk change + cmp ah,6 ; if AH==6 then disk change, else error + jne fl_dc ; if error, return -1 + mov al, 1 ; set change occurred +fl_dc: cbw ; extend AL into AX, AX={1,-1} + ret ; note: AH=0 on no change, AL set above - cmp ah,6 ; ah=6: disk has changed - je fl_dc_ret - dec ax ; 0xFF on error - -fl_dc_ret1: dec ax -fl_dc_ret: cbw - pop si - ret - -; -; Format Sectors -; -; COUNT fl_format(WORD drive, WORD head, WORD track, WORD sector, WORD count, BYTE FAR *buffer); -; -; Formats one or more tracks, sector should be 0. -; -; Returns 0 if successful, error code otherwise. - global FL_FORMAT -FL_FORMAT: - mov ah, 5 - jmp short fl_common -; -; Read Sectors -; -; COUNT fl_read(WORD drive, WORD head, WORD track, WORD sector, WORD count, BYTE FAR *buffer); ; +; Format tracks (sector should be 0). +; COUNT ASMPASCAL fl_format(WORD drive, WORD head, WORD track, WORD sector, WORD count, UBYTE FAR *buffer); ; Reads one or more sectors. -; -; Returns 0 if successful, error code otherwise. -; -; -; Write Sectors -; -; COUNT fl_write(WORD drive, WORD head, WORD track, WORD sector, WORD count, BYTE FAR *buffer); -; +; COUNT ASMPASCAL fl_read (WORD drive, WORD head, WORD track, WORD sector, WORD count, UBYTE FAR *buffer); ; Writes one or more sectors. +; COUNT ASMPASCAL fl_write (WORD drive, WORD head, WORD track, WORD sector, WORD count, UBYTE FAR *buffer); +; COUNT ASMPASCAL fl_verify(WORD drive, WORD head, WORD track, WORD sector, WORD count, UBYTE FAR *buffer); ; ; Returns 0 if successful, error code otherwise. ; + + global FL_FORMAT +FL_FORMAT: + mov ah,5 ; format track + jmp short fl_common + global FL_READ FL_READ: - mov ah,2 ; cmd READ + mov ah,2 ; read sector(s) jmp short fl_common global FL_VERIFY FL_VERIFY: - mov ah,4 ; cmd verify + mov ah,4 ; verify sector(s) jmp short fl_common global FL_WRITE FL_WRITE: - mov ah,3 ; cmd WRITE + mov ah,3 ; write sector(s) fl_common: - push bp ; C entry + push bp ; setup stack frame mov bp,sp mov cx,[bp+0Ch] ; cylinder number (lo only if hard) mov al,1 ; this should be an error code - cmp ch,3 ; this code can't write above 3ff=1023 + cmp ch,3 ; this code can't write above 3FFh=1023 ja fl_error xchg ch,cl ; ch=low 8 bits of cyl number - ror cl,1 ; extract bits 8+9 to cl - ror cl,1 + ror cl,1 ; bits 8-9 of cylinder number... + ror cl,1 ; ...to bits 6-7 in CL or cl,[bp+0Ah] ; or in the sector number (bits 0-5) - mov al,[bp+08h] ; count to read/write - les bx,[bp+04h] ; Load 32 bit buffer ptr + mov al,[bp+08h] ; count to read/write (# of sectors) + les bx,[bp+04h] ; Load 32 bit buffer ptr into ES:BX - mov dl,[bp+10h] ; get the drive (if or'ed 80h its - ; hard drive. + mov dl,[bp+10h] ; drive (if or'ed 80h its a hard drive) mov dh,[bp+0Eh] ; get the head number - int 13h ; write sectors from mem es:bx + int 13h ; process sectors sbb al,al ; carry: al=ff, else al=0 and al,ah ; carry: error code, else 0 @@ -160,75 +139,84 @@ fl_error: pop bp ret 14 - -; COUNT fl_lba_ReadWrite(BYTE drive, UWORD mode, VOID FAR *dap_p) +; +; COUNT ASMPASCAL fl_lba_ReadWrite(BYTE drive, WORD mode, void FAR * dap_p); ; ; Returns 0 if successful, error code otherwise. ; + global FL_LBA_READWRITE FL_LBA_READWRITE: - push bp ; C entry + push bp ; setup stack frame mov bp,sp push ds push si ; wasn't in kernel < KE2024Bo6!! - mov dl,[bp+10] ; get the drive (if ored 80h harddrive) + mov dl,[bp+10] ; drive (if or'ed with 80h a hard drive) mov ax,[bp+8] ; get the command lds si,[bp+4] ; get far dap pointer int 13h ; read from/write to drive - pop si + pop si pop ds pop bp -ret_AH: + mov al,ah ; place any error code into al mov ah,0 ; zero out ah ret 8 ; -; void fl_readkey (void); +; void ASMPASCAL fl_readkey (void); ; -global FL_READKEY + global FL_READKEY FL_READKEY: xor ah, ah int 16h ret -global FL_SETDISKTYPE +; +; COUNT ASMPASCAL fl_setdisktype (WORD drive, WORD type); +; + + global FL_SETDISKTYPE FL_SETDISKTYPE: pop bx ; return address - pop ax ; disk type (al) + pop ax ; disk format type (al) pop dx ; drive number (dl) push bx ; restore stack - mov ah,17h - int 13h - jmp short ret_AH + mov ah,17h ; floppy set disk type for format + int 13h +ret_AH: + mov al,ah ; place any error code into al + mov ah,0 ; zero out ah + ret ; -; COUNT fl_setmediatype (WORD drive, WORD tracks, WORD sectors); +; COUNT ASMPASCAL fl_setmediatype (WORD drive, WORD tracks, WORD sectors); ; -global FL_SETMEDIATYPE + global FL_SETMEDIATYPE FL_SETMEDIATYPE: pop ax ; return address - pop bx ; sectors/track + pop bx ; sectors/track pop cx ; number of tracks pop dx ; drive number push ax ; restore stack - push di + push di - dec cx ; should be highest track - xchg ch,cl ; low 8 bits of cyl number + dec cx ; number of cylinders - 1 (last cyl number) + xchg ch,cl ; CH=low 8 bits of last cyl number + + ror cl,1 ; extract bits 8-9 of cylinder number... + ror cl,1 ; ...into cl bit 6-7 - ror cl,1 ; extract bits 8+9 to cl bit 6+7 - ror cl,1 - - or cl,bl ; or in bits 7-6 + or cl,bl ; sectors/track (bits 0-5) or'd with high cyl bits 7-6 - mov ah,18h - int 13h + mov ah,18h ; disk set media type for format + int 13h jc skipint1e + push es xor dx,dx mov es,dx diff --git a/hdr/version.h b/hdr/version.h index 98272d74..4009ca61 100644 --- a/hdr/version.h +++ b/hdr/version.h @@ -49,6 +49,6 @@ static BYTE *date_hRcsId = #define REVISION_MINOR 1 #define REVISION_SEQ 35 #define BUILD "2035" -#define SUB_BUILD "" +#define SUB_BUILD "a" #define KERNEL_VERSION_STRING "1.1.35" /*#REVISION_MAJOR "." #REVISION_MINOR "." #REVISION_SEQ */ -#define KERNEL_BUILD_STRING "2035" /*#BUILD SUB_BUILD */ +#define KERNEL_BUILD_STRING "2035a" /*#BUILD SUB_BUILD */ From 1d684a4eacffc7428fb02d6dc7f03201ace10eea Mon Sep 17 00:00:00 2001 From: Kenneth J Davis Date: Sat, 19 Jun 2004 19:41:47 +0000 Subject: [PATCH 547/671] minor comment corrections git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/trunk@980 6ac86273-5f31-0410-b378-82cca8765d1b --- drivers/floppy.asm | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/drivers/floppy.asm b/drivers/floppy.asm index 9d9def58..fa2d51e8 100644 --- a/drivers/floppy.asm +++ b/drivers/floppy.asm @@ -41,7 +41,7 @@ segment HMA_TEXT global FL_RESET FL_RESET: pop ax ; return address - pop dx ; drive, (DL only, bit 7 set resets both floppy & hd) + pop dx ; drive (DL only) push ax ; restore address mov ah,0 ; BIOS reset diskette & fixed disk int 13h @@ -74,7 +74,7 @@ FL_DISKCHANGED: cmp ah,6 ; if AH==6 then disk change, else error jne fl_dc ; if error, return -1 mov al, 1 ; set change occurred -fl_dc: cbw ; extend AL into AX, AX={1,-1} +fl_dc: cbw ; extend AL into AX, AX={1,0,-1} ret ; note: AH=0 on no change, AL set above ; @@ -112,18 +112,18 @@ fl_common: push bp ; setup stack frame mov bp,sp - mov cx,[bp+0Ch] ; cylinder number (lo only if hard) + mov cx,[bp+0Ch] ; cylinder number mov al,1 ; this should be an error code cmp ch,3 ; this code can't write above 3FFh=1023 - ja fl_error + ja fl_error ; as cylinder # is limited to 10 bits. xchg ch,cl ; ch=low 8 bits of cyl number ror cl,1 ; bits 8-9 of cylinder number... ror cl,1 ; ...to bits 6-7 in CL or cl,[bp+0Ah] ; or in the sector number (bits 0-5) - mov al,[bp+08h] ; count to read/write (# of sectors) + mov al,[bp+08h] ; count of sectors to read/write/... les bx,[bp+04h] ; Load 32 bit buffer ptr into ES:BX mov dl,[bp+10h] ; drive (if or'ed 80h its a hard drive) @@ -133,9 +133,8 @@ fl_common: sbb al,al ; carry: al=ff, else al=0 and al,ah ; carry: error code, else 0 - ; (Zero transfer count) fl_error: - mov ah,0 ; force into < 255 count + mov ah,0 ; extend AL into AX without sign extension pop bp ret 14 From 38bcefb6e83664775b530dafffec55d290474fab Mon Sep 17 00:00:00 2001 From: Jim Hall Date: Sat, 19 Jun 2004 19:41:47 +0000 Subject: [PATCH 548/671] This commit was manufactured by cvs2svn to create branch 'UNSTABLE'. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/branches/UNSTABLE@981 6ac86273-5f31-0410-b378-82cca8765d1b From 9c94426d7a3b3d88cf64b179b30a3a2c99539e53 Mon Sep 17 00:00:00 2001 From: Kenneth J Davis Date: Fri, 9 Jul 2004 02:16:31 +0000 Subject: [PATCH 549/671] Lucho's kernel with Arkady's changes, initial unstable branch git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/branches/UNSTABLE@988 6ac86273-5f31-0410-b378-82cca8765d1b --- boot/makefile | 28 +- build.bat | 40 +- buildall.bat | 83 +- clean.bat | 30 +- clobber.bat | 39 +- config.b | 183 +-- default.bat | 66 - defaults.bat | 87 ++ drivers/floppy.asm | 200 ++- drivers/makefile | 45 +- filelist | 155 --- hdr/portab.h | 84 +- hdr/stacks.inc | 8 +- hdr/version.h | 6 +- kernel/break.c | 13 +- kernel/config.c | 2999 ++++++++++++++++++------------------------ kernel/config.h | 17 +- kernel/dsk.c | 851 ++++++------ kernel/entry.asm | 2 +- kernel/globals.h | 6 +- kernel/init-mod.h | 65 +- kernel/initoem.c | 72 - kernel/int2f.asm | 7 +- kernel/inthndlr.c | 5 +- kernel/intr.asm | 88 +- kernel/ioctl.c | 378 +++--- kernel/main.c | 438 +++--- kernel/makefile | 213 +-- kernel/msc.cfg | 5 + kernel/nls.c | 24 +- kernel/procsupt.asm | 27 +- kernel/proto.h | 39 +- kernel/segs.inc | 6 +- kernel/task.c | 753 +++++------ kernel/tci.cfg | 7 + kernel/turboc.cfg | 20 +- kernel/vc.cfg | 5 + kernel/wc.cfg | 9 + kernel/wci.cfg | 11 + lib/makefile | 22 +- mkfiles/bc.mak | 10 + mkfiles/bc5.mak | 49 +- mkfiles/generic.mak | 66 +- mkfiles/msc.mak | 31 + mkfiles/mscl8.mak | 54 +- mkfiles/tc.mak | 16 + mkfiles/tc2.mak | 49 +- mkfiles/tc3.mak | 50 +- mkfiles/tcpp.mak | 42 + mkfiles/tcpp3.mak | 7 + mkfiles/turbocpp.mak | 40 +- mkfiles/watcom.mak | 73 +- sys/fdkrncfg.c | 2 +- sys/makefile | 57 +- sys/turboc.cfg | 7 + utils/echoto.bat | 2 +- utils/exeflat.c | 54 +- utils/makefile | 18 +- utils/rmfiles.bat | 1 - utils/turboc.cfg | 7 + utils/wlinker.bat | 6 +- 61 files changed, 3436 insertions(+), 4341 deletions(-) delete mode 100644 default.bat create mode 100644 defaults.bat delete mode 100644 filelist create mode 100644 kernel/msc.cfg create mode 100644 kernel/tci.cfg create mode 100644 kernel/vc.cfg create mode 100644 kernel/wc.cfg create mode 100644 kernel/wci.cfg create mode 100644 mkfiles/bc.mak create mode 100644 mkfiles/msc.mak create mode 100644 mkfiles/tc.mak create mode 100644 mkfiles/tcpp.mak create mode 100644 mkfiles/tcpp3.mak create mode 100644 sys/turboc.cfg create mode 100644 utils/turboc.cfg diff --git a/boot/makefile b/boot/makefile index 0299d170..a2ee0897 100644 --- a/boot/makefile +++ b/boot/makefile @@ -4,26 +4,28 @@ # $Id$ # - !include "../mkfiles/generic.mak" -production: fat12com.bin fat16com.bin fat32chs.bin fat32lba.bin +######################################################################## -fat12com.bin: boot.asm - $(NASM) -dISFAT12 boot.asm -ofat12com.bin +all: fat12.bin fat16.bin fat32chs.bin fat32lba.bin -fat16com.bin: boot.asm - $(NASM) -dISFAT16 boot.asm -ofat16com.bin +fat12.bin: boot.asm $(DEPENDS) + $(NASM) -DISFAT12 boot.asm -o$*.bin -fat32chs.bin: boot32.asm - $(NASM) boot32.asm -ofat32chs.bin +fat16.bin: boot.asm $(DEPENDS) + $(NASM) -DISFAT16 boot.asm -o$*.bin -fat32lba.bin: boot32lb.asm - $(NASM) boot32lb.asm -ofat32lba.bin +fat32chs.bin: boot32.asm $(DEPENDS) + $(NASM) boot32.asm -o$*.bin -clobber: clean - -$(RM) *.bin status.me +fat32lba.bin: boot32lb.asm $(DEPENDS) + $(NASM) boot32lb.asm -o$*.bin + +######################################################################## clean: - -$(RM) *.lst *.map *.bak *.obj + -$(RM) *.bak *.cod *.crf *.err *.las *.lst *.map *.obj *.xrf +clobber: clean + -$(RM) *.bin status.me diff --git a/build.bat b/build.bat index 75a0e225..29eba7a7 100644 --- a/build.bat +++ b/build.bat @@ -3,18 +3,22 @@ :- batch file to build everything :- $Id$ +:----------------------------------------------------------------------- :- Syntax: BUILD [-r] [fat32|fat16] [msc|wc|tc|tcpp] [86|186|386] :- option case is significant !! +:----------------------------------------------------------------------- + +set XERROR=1 +if "%XERROR%" == "" goto noenv if "%1" == "-r" call clobber.bat if "%1" == "-r" shift -set XERROR= - if not exist config.bat echo You must copy CONFIG.B to CONFIG.BAT and edit it to reflect your setup! if not exist config.bat goto abort call config.bat +if "%LAST%" == "" goto noenv :----------------------------------------------------------------------- :- following is command line handling @@ -26,10 +30,10 @@ call config.bat if "%1" == "fat32" set XFAT=32 if "%1" == "fat16" set XFAT=16 -if "%1" == "msc" set COMPILER=MSCL8 +if "%1" == "msc" set COMPILER=MSC if "%1" == "wc" set COMPILER=WATCOM -if "%1" == "tc" set COMPILER=TC2 -if "%1" == "tcpp" set COMPILER=TURBOCPP +if "%1" == "tc" set COMPILER=TC +if "%1" == "tcpp" set COMPILER=TCPP if "%1" == "86" set XCPU=86 if "%1" == "186" set XCPU=186 @@ -41,7 +45,8 @@ if not "%1" == "" goto loop_commandline if "%COMPILER%" == "" echo you MUST define a COMPILER variable in CONFIG.BAT if "%COMPILER%" == "" goto abort -call default.bat +call defaults.bat +if "%LAST%" == "" goto noenv :----------------------------------------------------------------------- :- finally - we are going to compile @@ -51,50 +56,51 @@ echo. echo Process UTILS ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ echo. cd utils -%MAKE% production +call %MAKE% all if errorlevel 1 goto abort-cd echo. echo Process LIB ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ echo. cd ..\lib -%MAKE% +call %MAKE% all if errorlevel 1 goto abort-cd echo. echo Process DRIVERS ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ echo. cd ..\drivers -%MAKE% production +call %MAKE% all if errorlevel 1 goto abort-cd echo. echo Process BOOT +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ echo. cd ..\boot -%MAKE% production +call %MAKE% all if errorlevel 1 goto abort-cd echo. echo Process SYS ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ echo. cd ..\sys -%MAKE% production +call %MAKE% all if errorlevel 1 goto abort-cd echo. echo Process KERNEL +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ echo. cd ..\kernel -%MAKE% production +call %MAKE% all if errorlevel 1 goto abort-cd cd .. -:- if you like, put some finalizing commands (like copy to floppy) -:- into build2.bat +:- if you like, put finalizing commands (like copy to floppy) into build2.bat + +set XERROR= -if exist build2.bat call build2 +if exist build2.bat call build2.bat echo. echo Processing is done. @@ -104,9 +110,9 @@ goto end :abort-cd cd .. +:noenv :abort echo Compilation was aborted! -set XERROR=1 :end -default.bat clearset +defaults.bat clearset diff --git a/buildall.bat b/buildall.bat index e347a2be..9785bb09 100644 --- a/buildall.bat +++ b/buildall.bat @@ -9,56 +9,48 @@ if "%1" == "$SUMMARY" goto summary -set onerror=if not "%XERROR%" == "" goto daswarwohlnix +call config.bat +if "%LAST%" == "" goto end -:***** MSCL kernels +:***** MSVC kernels -call config.bat +if "%MSC_BASE%" == "" goto no_ms + call build.bat -r msc 386 fat16 +if "%XERROR%" == "" call build.bat -r msc 186 fat16 +if "%XERROR%" == "" call build.bat -r msc 86 fat16 +if "%XERROR%" == "" call build.bat -r msc 386 fat32 +if "%XERROR%" == "" call build.bat -r msc 186 fat32 +if "%XERROR%" == "" call build.bat -r msc 86 fat32 -if "%MS_BASE%" == "" goto no_ms -call build -r msc 386 fat16 -%ONERROR% -call build -r msc 186 fat16 -%ONERROR% -call build -r msc 86 fat16 -%ONERROR% -call build -r msc 386 fat32 -%ONERROR% -call build -r msc 186 fat32 -%ONERROR% -call build -r msc 86 fat32 -%ONERROR% +if not "%XERROR%" == "" goto daswarwohlnix :no_ms :***** TC 2.01 kernels -if "%TC2_BASE%" == "" goto no_tc -call build -r tc 186 fat16 -%ONERROR% -call build -r tc 86 fat16 -%ONERROR% -call build -r tc 186 fat32 -%ONERROR% -call build -r tc 86 fat32 -%ONERROR% +if "%TC_BASE%" == "" goto no_tc + call build.bat -r tc 186 fat16 +if "%XERROR%" == "" call build.bat -r tc 86 fat16 +if "%XERROR%" == "" call build.bat -r tc 186 fat32 +if "%XERROR%" == "" call build.bat -r tc 86 fat32 + +if not "%XERROR%" == "" goto daswarwohlnix :no_tc :***** (Open) Watcom kernels if "%WATCOM%" == "" goto no_wc -call build -r wc 386 fat32 -%ONERROR% -call build -r wc 386 fat16 -%ONERROR% -call build -r wc 86 fat32 -%ONERROR% -call build -r wc 86 fat16 -%ONERROR% + call build.bat -r wc 386 fat32 +if "%XERROR%" == "" call build.bat -r wc 386 fat16 +if "%XERROR%" == "" call build.bat -r wc 86 fat32 +if "%XERROR%" == "" call build.bat -r wc 86 fat16 + +if not "%XERROR%" == "" goto daswarwohlnix :no_wc - + :***** now rebuild the default kernel -call build -r +call build.bat -r +if not "%XERROR%" == "" goto daswarwohlnix :************************************************************** :* now we build a summary of all kernels HMA size + total size @@ -70,30 +62,30 @@ set Sumfile=bin\ksummary.txt set TempSumfile=bin\tsummary.txt :****echo >%TempSumfile% Summary of all kernels build -:****echo.|date >>%TempSumfile% -:****echo.|time >>%TempSumfile% +:****echo.|date >>%TempSumfile% +:****echo.|time >>%TempSumfile% :****for %%i in (bin\k*.map) do call %0 $SUMMARY %%i -if exist %Sumfile% del %Sumfile% -if exist %TempSumfile% del %TempSumfile% +if exist %Sumfile% del %Sumfile%>nul +if exist %TempSumfile% del %TempSumfile%>nul >ktemp.bat for %%i in (bin\k*.map) do echo call %0 $SUMMARY %%i >>ktemp.bat sort ktemps.bat call ktemps.bat -del ktemp.bat -del ktemps.bat +del ktemp.bat>nul +del ktemps.bat>nul echo >>%Sumfile% Summary of all kernels build -echo.|date >>%Sumfile% -echo.|time >>%Sumfile% +echo.|date >>%Sumfile% +echo.|time >>%Sumfile% find <%TempSumfile% "H" >>%Sumfile% -del %TempSumfile% +del %TempSumfile%>nul set TempSumfile= set Sumfile= goto end -:summary +:summary echo H************************************************* %2 >>%TempSumfile% find<%2 " HMA_TEXT"|find/V "HMA_TEXT_START"|find/V "HMA_TEXT_END">>%TempSumfile% find<%2 " STACK">>%TempSumfile% @@ -103,6 +95,5 @@ goto end :daswarwohlnix echo Sorry, something didn't work as expected :-( -set ONERROR= :end diff --git a/clean.bat b/clean.bat index b2028c15..ed74cd7a 100644 --- a/clean.bat +++ b/clean.bat @@ -1,37 +1,45 @@ @echo off -:- batch file to clean everything +:- batch file to clean and clobber everything :- $Id$ +if "%1" == "" %0 clean +goto %1 +goto end + +:clean +:clobber if not exist config.bat echo You must copy CONFIG.B to CONFIG.BAT and edit it to reflect your setup! if not exist config.bat goto end call config.bat -call default.bat +if not "%LAST%" == "" call defaults.bat +if "%LAST%" == "" goto end cd utils -%MAKE% clean +call %MAKE% %1 cd ..\lib -%MAKE% clean +call %MAKE% %1 cd ..\drivers -%MAKE% clean +call %MAKE% %1 cd ..\boot -%MAKE% clean +call %MAKE% %1 cd ..\sys -%MAKE% clean +call %MAKE% %1 cd ..\kernel -%MAKE% clean +call %MAKE% %1 cd ..\hdr -if exist *.bak del *.bak +if exist *.bak del *.bak>nul cd .. -if exist *.bak del *.bak +if exist *.bak del *.bak>nul +if "%1"=="clobber" if exist status.me del status.me>nul :end -default.bat clearset +defaults.bat clearset diff --git a/clobber.bat b/clobber.bat index 2fcc81c9..074a6363 100644 --- a/clobber.bat +++ b/clobber.bat @@ -1,38 +1 @@ -@echo off - -:- batch file to clobber everything -:- $Id$ - -if not exist config.bat echo You must copy CONFIG.B to CONFIG.BAT and edit it to reflect your setup! -if not exist config.bat goto end - -call config.bat -call default.bat - -cd utils -%MAKE% clobber - -cd ..\lib -%MAKE% clobber - -cd ..\drivers -%MAKE% clobber - -cd ..\boot -%MAKE% clobber - -cd ..\sys -%MAKE% clobber - -cd ..\kernel -%MAKE% clobber - -cd ..\hdr -if exist *.bak del *.bak - -cd .. -if exist *.bak del *.bak -if exist status.me del status.me - -:end -default.bat clearset +@clean clobber \ No newline at end of file diff --git a/config.b b/config.b index b839785a..5f089180 100644 --- a/config.b +++ b/config.b @@ -1,119 +1,128 @@ -:- +@echo off + :- batch file that is included in all other batch files for configuration -:- +:- $Id$ + +:----------------------------------------------------------------------- +:- NOTICE! You must edit and rename this file to CONFIG.BAT! +:----------------------------------------------------------------------- -:-**************************************************************** -:- NOTICE! You must edit and rename this file to CONFIG.BAT! * -:-**************************************************************** +:- determine compiler(s) settings. +:- +:- you REQUIRED to +:- search for NASM - and set the path to NASM +:- search for COMPILER - and set the default compiler name +:- search for ??_BASE - and set the path to (all) compiler(s) -:-********************************************************************* -:- determine your compiler settings -:- -:- you have to -:- search for XNASM - and set the path for NASM -:- search for COMPILER - and set your compiler -:- search for ??_BASE - and set the path to your compiler -:- -:-********************************************************************* +set LAST= -:-********************************************************************** -:-- define NASM executable - remember - it should not be protected -:- mode DJGPP version if you're using Windows NT/2k/XP to compile -:- also: DJGPP-nasm crashes when using protected mode Borland's make -:-********************************************************************** +:----------------------------------------------------------------------- +:- define NASM executable. It should not be protected mode DJGPP +:- version if you're using Windows NT/2k/XP to compile. also: +:- NASM/DJGPP crashes when using protected mode Borland's make. -set XNASM=c:\bin\nasm16 +set NASM=c:\bin\nasm16 -:********************************************************************** -:- define your COMPILER type here, pick one of them -:********************************************************************** +:----------------------------------------------------------------------- +:- define COMPILER name here, pick one of them. :- Turbo C 2.01 -set COMPILER=TC2 +set COMPILER=TC :- Turbo C++ 1.01 -:- set COMPILER=TURBOCPP -:- Turbo C 3.0 -:- set COMPILER=TC3 +::set COMPILER=TCPP +:- Turbo C++ 3.0 +::set COMPILER=TCPP3 :- Borland C -:- set COMPILER=BC5 +::set COMPILER=BC :- Microsoft C -:- set COMPILER=MSCL8 +::set COMPILER=MSC :- Watcom C -:- set COMPILER=WATCOM - -:-********************************************************************** -:-- where is the BASE dir of your compiler(s) ?? -:-********************************************************************** - -set TC2_BASE=c:\tc201 -:- set TP1_BASE=c:\tcpp -:- set TC3_BASE=c:\tc3 -:- set BC5_BASE=c:\bc5 -:- set MS_BASE=c:\msvc - -:- if WATCOM maybe you need to set your WATCOM environment variables -:- and path -:- if not \%WATCOM% == \ goto watcom_defined -:- set WATCOM=c:\watcom -:- set PATH=%PATH%;%WATCOM%\binw -:watcom_defined - -:-********************************************************************** -:- where is UPX and which options to use? -:-********************************************************************** -set XUPX=upx --8086 --best -:- or use set XUPX= -:- if you don't want to use it +::set COMPILER=WATCOM -:-********************************************************************** -:- (optionally) which linker to use: -:- (otherwise will be determined automatically) -:- -:- WARNING TLINK needs to be in your PATH! -:-********************************************************************** +:----------------------------------------------------------------------- +:- define BASE dir of compiler; +:- may be defined for all installed compilers. + +set TC_BASE=c:\tc +::set TCPP_BASE=c:\tcpp +::set TCPP3_BASE=c:\tcpp3 +::set BC_BASE=c:\bc +::set MSC_BASE=c:\msc +::set WATCOM=c:\watcom + +:----------------------------------------------------------------------- +:- When compiling executable, compilers search linker through PATH; +:- if some linker not in PATH, uncomment OLDPATH and required SETs PATH. + +::set OLDPATH=%PATH% +::set PATH=%TC_BASE%;%PATH% +::set PATH=%TCPP_BASE%\bin;%PATH% +::set PATH=%TCPP3_BASE%\bin;%PATH% +::set PATH=%BC_BASE%\bin;%PATH% +::set PATH=%MSC_BASE%\bin;%PATH% +::set PATH=%WATCOM%\binw;%PATH% + +:- MSC searches libraries only through LIB variable. +::set LIB=%MSC_BASE%\lib + +:----------------------------------------------------------------------- +:- define which linker to use OR it will be determined AUTOMATICALLY. :- Turbo Link -:- set XLINK=tlink /m/c/s/l +::set LINK=tlink /c/m/s/l :- Microsoft Link -:- set XLINK=d:\qb\link /ma -:- set XLINK=%MS_BASE%\bin\link /ONERROR:NOEXE /ma /nologo +::set LINK=link /ONERROR:NOEXE /nologo :- WATCOM Link (wlinker is a batch file calling ms2wlink and wlink) -:- set XLINK=..\utils\wlinker /ma /nologo +::set LINK=..\utils\wlinker /nologo -:- set path for Turbo Link - use OLDPATH to restore normal path -:- set OLDPATH=%PATH% -:- set PATH=%PATH%;%TC2_BASE% +:----------------------------------------------------------------------- +:- define which librarian to use OR it will be determined AUTOMATICALLY. -:********************************************************************** -:* optionally define your MAKE type here, if not then -:* it will be automatically determined, pick one of them -:* use MS nmake if you want to compile with MSCL -:********************************************************************** +:- Turbo Lib +::set LIBUTIL=tlib +::set LIBTERM= +:- Microsoft Lib +::set LIBUTIL=lib /nologo +::set LIBTERM=; +:- WATCOM Lib +::set LIBUTIL=wlib -q +::set LIBTERM= + +:----------------------------------------------------------------------- +:- define which MAKE to use OR it will be determined AUTOMATICALLY. :- Borland MAKE -:- set MAKE=%TC2_BASE%\make +::set MAKE=make +::set MAKE=maker -S :- Watcom MAKE in MS mode -:- set MAKE=%WATCOM%\binw\wmake /ms +::set MAKE=wmake /ms :- Microsoft MAKE -:- set MAKE=%MS_BASE%\bin\nmake /nologo +::set MAKE=nmake /nologo +::set MAKE=nmaker /nologo + +:----------------------------------------------------------------------- +:- where is UPX and which options to use +:- (comment this out if you don't want to use it) -:********************************************************************** -:* select your default target: required CPU and what FAT system to support -:********************************************************************** +set XUPX=upx --8086 --best + +:----------------------------------------------------------------------- +:- select default target: CPU type (default is 86) and +:- what FAT system (default is 32) to support -set XCPU=86 -:- set XCPU=186 -:- set XCPU=386 +::set XCPU=86 +::set XCPU=186 +::set XCPU=386 -set XFAT=16 -:- set XFAT=32 +::set XFAT=16 +::set XFAT=32 :- Give extra compiler DEFINE flags here :- such as -DDEBUG : extra DEBUG output :- -DDOSEMU : printf output goes to dosemu log -:- set ALLCFLAGS=-DDEBUG +::set ALLCFLAGS=-DDEBUG +:----------------------------------------------------------------------- -:- -:- $Id$ -:- +set LAST=1 +if not "%LAST%" == "1" defaults.bat clearset diff --git a/default.bat b/default.bat deleted file mode 100644 index d3c73cec..00000000 --- a/default.bat +++ /dev/null @@ -1,66 +0,0 @@ -@echo off - -:- $Id$ - -if "%1" == "clearset" goto clearset - -:----------------------------------------------------------------------- - -if not "%MAKE%" == "" goto skip_make - -if "%COMPILER%" == "TC2" set MAKE=%TC2_BASE%\make -if "%COMPILER%" == "TURBOCPP" set MAKE=%TP1_BASE%\bin\make -if "%COMPILER%" == "TC3" set MAKE=%TC3_BASE%\bin\make -if "%COMPILER%" == "BC5" set MAKE=%BC5_BASE%\bin\make -if "%COMPILER%" == "WATCOM" set MAKE=wmake /ms /h -if "%COMPILER%" == "MSCL8" set MAKE=%MS_BASE%\bin\nmake /nologo - -echo Make is %MAKE%. - -:skip_make - -:----------------------------------------------------------------------- - -if not "%XLINK%" == "" goto skip_xlink - -if "%COMPILER%" == "TC2" set XLINK=%TC2_BASE%\tlink /m/c -if "%COMPILER%" == "TURBOCPP" set XLINK=%TP1_BASE%\bin\tlink /m/c -if "%COMPILER%" == "TC3" set XLINK=%TC3_BASE%\bin\tlink /m/c -if "%COMPILER%" == "BC5" set XLINK=%BC5_BASE%\bin\tlink /m/c -if "%COMPILER%" == "WATCOM" set XLINK=..\utils\wlinker /ma/nologo -if "%COMPILER%" == "MSCL8" set XLINK=%MS_BASE%\bin\link /ONERROR:NOEXE /ma /nologo - -echo Linker is %XLINK%. - -:skip_xlink - -:----------------------------------------------------------------------- - -if not "%XUPX%" == "" set UPXOPT=-U -if "%XUPX%" == "" set UPXOPT= -if "%XUPX%" == "" set XUPX=@rem - -goto end - -:----------------------------------------------------------------------- - -:clearset - -if not "%OLDPATH%" == "" set PATH=%OLDPATH% -if not "%OLDPATH%" == "" set OLDPATH= - -set MAKE= -set COMPILER= -set XCPU= -set XFAT= -set XLINK= -set TC2_BASE= -set TP1_BASE= -set TC3_BASE= -set BC5_BASE= -set MS_BASE= -set XNASM= -set XUPX= -set UPXOPT= - -:end diff --git a/defaults.bat b/defaults.bat new file mode 100644 index 00000000..2abde5e0 --- /dev/null +++ b/defaults.bat @@ -0,0 +1,87 @@ +@echo off + +:- $Id$ + +set LAST= +if "%1" == "clearset" goto clearset + +:----------------------------------------------------------------------- + +if "%COMPILER%" == "TC" set BASE=%TC_BASE% +if "%COMPILER%" == "TCPP" set BASE=%TCPP_BASE% +if "%COMPILER%" == "TCPP3" set BASE=%TCPP3_BASE% +if "%COMPILER%" == "BC" set BASE=%BC_BASE% +if "%COMPILER%" == "WATCOM" set BASE=%WATCOM% +if "%COMPILER%" == "MSC" set BASE=%MSC_BASE% +if "%BASE%" == "" goto clearset + +:----------------------------------------------------------------------- + +if not "%LINK%" == "" goto skip_link + +set LINK=%BASE%\bin\tlink /c/m +if "%COMPILER%" == "TC" set LINK=%BASE%\tlink /c/m +if "%COMPILER%" == "WATCOM" set LINK=..\utils\wlinker /nologo +if "%COMPILER%" == "MSC" set LINK=%BASE%\bin\link /ONERROR:NOEXE /batch + +echo Linker is %LINK% + +:skip_link + +:----------------------------------------------------------------------- + +if not "%LIBUTIL%" == "" goto skip_lib + +set LIBUTIL=%BASE%\bin\tlib +set LIBTERM= +if "%COMPILER%" == "TC" set LIBUTIL=%BASE%\tlib +if "%COMPILER%" == "WATCOM" set LIBUTIL=%BASE%\binw\wlib -q +if "%COMPILER%" == "MSC" set LIBUTIL=%BASE%\bin\lib /nologo +if "%COMPILER%" == "MSC" set LIBTERM=; + +echo Librarian is %LIBUTIL% + +:skip_lib + +:----------------------------------------------------------------------- + +if not "%MAKE%" == "" goto skip_make + +set MAKE=%BASE%\bin\make +if "%COMPILER%" == "TC" set MAKE=%BASE%\make +if "%COMPILER%" == "WATCOM" set MAKE=%BASE%\binw\wmake /ms /h +if "%COMPILER%" == "MSC" set MAKE=%BASE%\bin\nmake /nologo + +echo Make is %MAKE% + +:skip_make + +:----------------------------------------------------------------------- + +set LAST=1 +if "%LAST%" == "1" goto end + +:----------------------------------------------------------------------- + +:clearset + +set NASM= +set COMPILER= +set BASE= +set TC_BASE= +set TCPP_BASE= +set TCPP3_BASE= +set BC_BASE= +set MSC_BASE= +set LINK= +set LIBUTIL= +set LIBTERM= +set MAKE= +set XUPX= +set XCPU= +set XFAT= + +if not "%OLDPATH%" == "" set PATH=%OLDPATH% +set OLDPATH= + +:end diff --git a/drivers/floppy.asm b/drivers/floppy.asm index fa2d51e8..ae317680 100644 --- a/drivers/floppy.asm +++ b/drivers/floppy.asm @@ -32,7 +32,7 @@ segment HMA_TEXT ; -; BOOL ASMPASCAL fl_reset(WORD drive); +; int ASMPASCAL fl_reset(UBYTE drive); ; ; Reset both the diskette and hard disk system. ; returns TRUE if successful. @@ -41,189 +41,175 @@ segment HMA_TEXT global FL_RESET FL_RESET: pop ax ; return address - pop dx ; drive (DL only) + pop dx ; drive push ax ; restore address - mov ah,0 ; BIOS reset diskette & fixed disk + mov ah,0 ; reset disk int 13h - - sbb ax,ax ; carry set indicates error, AX=-CF={-1,0} + sbb ax,ax ; CF=1: error inc ax ; ...return TRUE (1) on success, - ret ; else FALSE (0) on failure + ret ; FALSE (0) on error ; -; COUNT ASMPASCAL fl_diskchanged(WORD drive); +; int ASMPASCAL fl_diskchanged(UBYTE drive); ; ; Read disk change line status. -; returns 1 if disk has changed, 0 if not, 0xFFFF if error. +; returns 1 if disk has changed, 0 if not, 0xFF if error. ; global FL_DISKCHANGED FL_DISKCHANGED: pop ax ; return address - pop dx ; drive (DL only, 00h-7Fh) + pop dx ; drive push ax ; restore stack - push si ; preserve value - mov ah,16h ; read change status type + push si + mov ah,16h ; read change status type xor si,si ; RBIL: avoid crash on AT&T 6300 int 13h - pop si ; restore + pop si - sbb al,al ; AL=-CF={-1,0} where 0==no change - jnc fl_dc ; carry set on error or disk change - cmp ah,6 ; if AH==6 then disk change, else error - jne fl_dc ; if error, return -1 - mov al, 1 ; set change occurred -fl_dc: cbw ; extend AL into AX, AX={1,0,-1} - ret ; note: AH=0 on no change, AL set above + sbb al,al ; CF=0 (disk has not changed) + jnc ret_AH_0 ; ...return 0 + cmp ah,6 ; ah!=6 (error) + jne ret_AH_0 ; ...return 0xFF + mov al,1 ; ah=6 (disk has changed) + jmp short ret_AH_0 ; ...return 1 ; -; Format tracks (sector should be 0). -; COUNT ASMPASCAL fl_format(WORD drive, WORD head, WORD track, WORD sector, WORD count, UBYTE FAR *buffer); -; Reads one or more sectors. -; COUNT ASMPASCAL fl_read (WORD drive, WORD head, WORD track, WORD sector, WORD count, UBYTE FAR *buffer); -; Writes one or more sectors. -; COUNT ASMPASCAL fl_write (WORD drive, WORD head, WORD track, WORD sector, WORD count, UBYTE FAR *buffer); -; COUNT ASMPASCAL fl_verify(WORD drive, WORD head, WORD track, WORD sector, WORD count, UBYTE FAR *buffer); -; -; Returns 0 if successful, error code otherwise. +; int ASMPASCAL fl_read (UBYTE drive, WORD head, WORD track, WORD sector, WORD count, void FAR *buffer); +; int ASMPASCAL fl_write (UBYTE drive, WORD head, WORD track, WORD sector, WORD count, void FAR *buffer); +; int ASMPASCAL fl_verify(UBYTE drive, WORD head, WORD track, WORD sector, WORD count, void FAR *buffer); +; int ASMPASCAL fl_format(UBYTE drive, WORD head, WORD track, WORD sector, WORD count, void FAR *buffer); ; +; Format tracks (sector should be 0). + global FL_FORMAT FL_FORMAT: - mov ah,5 ; format track - jmp short fl_common + mov ah,5 ; format track + jmp short fl_common - global FL_READ -FL_READ: - mov ah,2 ; read sector(s) - jmp short fl_common - global FL_VERIFY FL_VERIFY: - mov ah,4 ; verify sector(s) - jmp short fl_common - - global FL_WRITE -FL_WRITE: - mov ah,3 ; write sector(s) - -fl_common: - push bp ; setup stack frame - mov bp,sp + mov ah,4 ; verify sector(s) + jmp short fl_common - mov cx,[bp+0Ch] ; cylinder number + global FL_READ +FL_READ: + mov ah,2 ; read sector(s) + jmp short fl_common - mov al,1 ; this should be an error code - cmp ch,3 ; this code can't write above 3FFh=1023 - ja fl_error ; as cylinder # is limited to 10 bits. + global FL_WRITE +FL_WRITE: + mov ah,3 ; write sector(s) - xchg ch,cl ; ch=low 8 bits of cyl number - ror cl,1 ; bits 8-9 of cylinder number... - ror cl,1 ; ...to bits 6-7 in CL - or cl,[bp+0Ah] ; or in the sector number (bits 0-5) +fl_common: + push bp + mov bp,sp - mov al,[bp+08h] ; count of sectors to read/write/... - les bx,[bp+04h] ; Load 32 bit buffer ptr into ES:BX + mov cx,[bp+12] ; cylinder number + mov al,1 ; error code + cmp ch,3 + ja fl_error ; can't write above 3FFh=1023 - mov dl,[bp+10h] ; drive (if or'ed 80h its a hard drive) - mov dh,[bp+0Eh] ; get the head number + xchg ch,cl ; ch=low 8 bits of cylinder number + mov dh,[bp+14] ; head number + ror cl,1 ; bits 8-9 of cylinder number... + ror cl,1 ; ...to bits 6-7 in CL + or cl,[bp+10] ; sector number (bits 0-5) - int 13h ; process sectors + mov al,[bp+8] ; number of sectors + les bx,[bp+4] ; 32-bit buffer ptr + mov dl,[bp+16] ; drive (if or'ed 80h its hard drive) + int 13h ; process sectors sbb al,al ; carry: al=ff, else al=0 and al,ah ; carry: error code, else 0 fl_error: - mov ah,0 ; extend AL into AX without sign extension - pop bp - ret 14 + mov ah,0 + pop bp + ret 14 ; -; COUNT ASMPASCAL fl_lba_ReadWrite(BYTE drive, WORD mode, void FAR * dap_p); +; int ASMPASCAL fl_lba_ReadWrite(UBYTE drive, WORD mode, void FAR * dap); ; ; Returns 0 if successful, error code otherwise. ; - global FL_LBA_READWRITE + global FL_LBA_READWRITE FL_LBA_READWRITE: - push bp ; setup stack frame - mov bp,sp - - push ds - push si ; wasn't in kernel < KE2024Bo6!! - - mov dl,[bp+10] ; drive (if or'ed with 80h a hard drive) - mov ax,[bp+8] ; get the command - lds si,[bp+4] ; get far dap pointer - int 13h ; read from/write to drive - - pop si - pop ds - - pop bp - - mov al,ah ; place any error code into al - mov ah,0 ; zero out ah - ret 8 + push bp + mov bp,sp + push si + push ds + mov dl,[bp+10] ; drive (if or'ed 80h its hard drive) + mov ax,[bp+8] ; command + lds si,[bp+4] ; far dap pointer + int 13h ; process sectors + pop ds + pop si + pop bp + mov al,ah ; place error code into al + mov ah,0 + ret 8 ; ; void ASMPASCAL fl_readkey (void); ; global FL_READKEY -FL_READKEY: xor ah, ah +FL_READKEY: + mov ah,0 int 16h ret ; -; COUNT ASMPASCAL fl_setdisktype (WORD drive, WORD type); +; int ASMPASCAL fl_setdisktype (UBYTE drive, WORD type); ; global FL_SETDISKTYPE FL_SETDISKTYPE: pop bx ; return address - pop ax ; disk format type (al) - pop dx ; drive number (dl) + pop ax ; disk type + pop dx ; drive push bx ; restore stack - mov ah,17h ; floppy set disk type for format + mov ah,17h ; set disk type for format int 13h ret_AH: - mov al,ah ; place any error code into al - mov ah,0 ; zero out ah + mov al,ah ; place error code into al +ret_AH_0: + mov ah,0 ret - + ; -; COUNT ASMPASCAL fl_setmediatype (WORD drive, WORD tracks, WORD sectors); +; int ASMPASCAL fl_setmediatype (UBYTE drive, WORD tracks, WORD sectors); ; + global FL_SETMEDIATYPE FL_SETMEDIATYPE: pop ax ; return address pop bx ; sectors/track pop cx ; number of tracks - pop dx ; drive number + pop dx ; drive push ax ; restore stack push di - dec cx ; number of cylinders - 1 (last cyl number) + dec cx ; last cylinder number xchg ch,cl ; CH=low 8 bits of last cyl number - - ror cl,1 ; extract bits 8-9 of cylinder number... - ror cl,1 ; ...into cl bit 6-7 - - or cl,bl ; sectors/track (bits 0-5) or'd with high cyl bits 7-6 - - mov ah,18h ; disk set media type for format + ror cl,1 ; bits 8-9 of cylinder number... + ror cl,1 ; ...to bits 6-7 in CL + or cl,bl ; sectors/track (bits 0-5) + mov ah,18h ; set media type for format int 13h jc skipint1e push es - xor dx,dx - mov es,dx + xor dx,dx + mov es,dx cli - pop word [es:0x1e*4+2] ; set int 0x1e table to es:di - mov [es:0x1e*4 ], di + mov [es:0x1e*4],di + pop word [es:0x1e*4+2] ; set int 0x1e table to es:di sti -skipint1e: - pop di +skipint1e: + pop di jmp short ret_AH - diff --git a/drivers/makefile b/drivers/makefile index 94bba96e..978f380e 100644 --- a/drivers/makefile +++ b/drivers/makefile @@ -4,46 +4,25 @@ # $Id$ # - !include "../mkfiles/generic.mak" +OBJS=floppy.obj rdpcclk.obj wrpcclk.obj wratclk.obj +LIBOBJS=+floppy +rdpcclk +wrpcclk +wratclk -# MICROSOFT C -# ----------- -#MODEL = s -#CFLAGS = /c /Gs /A$(MODEL) -#AFLAGS = /Mx /Dmem$(MODEL)=1 -#TERM = ; - -# BORLAND C -# ----------- -#MODEL = s -#CFLAGS = -c -m$(MODEL) -#AFLAGS = /Mx /Dmem$(MODEL)=1 -#LIBFLAGS = /c - -OBJS = floppy.obj rdpcclk.obj wrpcclk.obj wratclk.obj - -LIBOBJS= +floppy +rdpcclk +wrpcclk +wratclk +# Build the LIBRARY #################################################### +all: ..\lib\device.lib +..\lib\device.lib: $(OBJS) + -$(RM) $*.lib + $(LIBUTIL) $(LIBFLAGS) $* $(LIBOBJS) $(LIBTERM) -# Build the LIBRARY -# ----------------- -all: production +$(OBJS): $(DEPENDS) -production: ..\lib\device.lib - -..\lib\device.lib: device.lib - copy device.lib ..\lib - -clobber: clean - -$(RM) device.lib status.me ..\lib\device.lib +######################################################################## clean: - -$(RM) *.obj *.bak *.crf *.xrf *.map *.lst *.cod *.err - -device.lib : $(OBJS) - -$(RM) device.lib - $(LIBUTIL) $(LIBFLAGS) device $(LIBOBJS) $(LIBTERM) + -$(RM) *.bak *.cod *.crf *.err *.las *.lst *.map *.obj *.xrf +clobber: clean + -$(RM) ..\lib\device.lib status.me diff --git a/filelist b/filelist deleted file mode 100644 index e86d481c..00000000 --- a/filelist +++ /dev/null @@ -1,155 +0,0 @@ -*/*/build.bat -*/*/buildall.bat -*/*/clean.bat -*/*/clobber.bat -*/*/config.b -*/*/filelist -*/*/default.bat -*/*/makefile -*/*/bin/autoexec.bat -*/*/bin/config.sys -*/*/bin/install.bat -*/*/boot/boot.asm -*/*/boot/boot32.asm -*/*/boot/boot32lb.asm -*/*/boot/makefile -*/*/docs/bugs.txt -*/*/docs/build.txt -*/*/docs/config.txt -*/*/docs/contrib.txt -*/*/docs/copying -*/*/docs/fdkernel.lsm -*/*/docs/history.txt -*/*/docs/intfns.txt -*/*/docs/lfnapi.txt -*/*/docs/mkboot.txt -*/*/docs/nls.txt -*/*/docs/readme.cvs -*/*/docs/readme.txt -*/*/docs/sys.txt -*/*/drivers/floppy.asm -*/*/drivers/makefile -*/*/drivers/rdpcclk.asm -*/*/drivers/wratclk.asm -*/*/drivers/wrpcclk.asm -*/*/hdr/algnbyte.h -*/*/hdr/algndflt.h -*/*/hdr/buffer.h -*/*/hdr/cds.h -*/*/hdr/clock.h -*/*/hdr/date.h -*/*/hdr/dcb.h -*/*/hdr/device.h -*/*/hdr/dirmatch.h -*/*/hdr/error.h -*/*/hdr/exe.h -*/*/hdr/fat.h -*/*/hdr/fcb.h -*/*/hdr/file.h -*/*/hdr/fnode.h -*/*/hdr/kbd.h -*/*/hdr/kconfig.h -*/*/hdr/lol.h -*/*/hdr/mcb.h -*/*/hdr/network.h -*/*/hdr/nls.h -*/*/hdr/pcb.h -*/*/hdr/portab.h -*/*/hdr/process.h -*/*/hdr/sft.h -*/*/hdr/stacks.inc -*/*/hdr/tail.h -*/*/hdr/time.h -*/*/hdr/version.h -*/*/hdr/xstructs.h -*/*/kernel/nls/001-437.hc -*/*/kernel/nls/001-437.unf -*/*/kernel/nls/001-437.up -*/*/kernel/nls/049-850.hc -*/*/kernel/nls/049-850.unf -*/*/kernel/nls/049-850.up -*/*/kernel/nls/files -*/*/kernel/apisupt.asm -*/*/kernel/asmsupt.asm -*/*/kernel/blockio.c -*/*/kernel/break.c -*/*/kernel/chario.c -*/*/kernel/config.c -*/*/kernel/config.h -*/*/kernel/console.asm -*/*/kernel/dosfns.c -*/*/kernel/dosidle.asm -*/*/kernel/dosnames.c -*/*/kernel/dsk.c -*/*/kernel/dyndata.h -*/*/kernel/dyninit.c -*/*/kernel/entry.asm -*/*/kernel/error.c -*/*/kernel/execrh.asm -*/*/kernel/fatdir.c -*/*/kernel/fatfs.c -*/*/kernel/fattab.c -*/*/kernel/fcbfns.c -*/*/kernel/globals.h -*/*/kernel/init-dat.h -*/*/kernel/init-mod.h -*/*/kernel/initclk.c -*/*/kernel/initdisk.c -*/*/kernel/inithma.c -*/*/kernel/initoem.c -*/*/kernel/int2f.asm -*/*/kernel/inthndlr.c -*/*/kernel/intr.asm -*/*/kernel/makefile -*/*/kernel/io.asm -*/*/kernel/io.inc -*/*/kernel/ioctl.c -*/*/kernel/iprf.c -*/*/kernel/irqstack.asm -*/*/kernel/kernel.asm -*/*/kernel/kernel.cfg -*/*/kernel/lfnapi.c -*/*/kernel/ludivmul.inc -*/*/kernel/main.c -*/*/kernel/memmgr.c -*/*/kernel/misc.c -*/*/kernel/network.c -*/*/kernel/newstuff.c -*/*/kernel/nls.c -*/*/kernel/nls_hc.asm -*/*/kernel/nls_load.c -*/*/kernel/nlssupt.asm -*/*/kernel/prf.c -*/*/kernel/printer.asm -*/*/kernel/procsupt.asm -*/*/kernel/proto.h -*/*/kernel/segs.inc -*/*/kernel/serial.asm -*/*/kernel/strings.c -*/*/kernel/sysclk.c -*/*/kernel/syspack.c -*/*/kernel/systime.c -*/*/kernel/task.c -*/*/kernel/turboc.cfg -*/*/lib/makefile -*/*/mkfiles/generic.mak -*/*/mkfiles/bc5.mak -*/*/mkfiles/mscl8.mak -*/*/mkfiles/tc2.mak -*/*/mkfiles/tc3.mak -*/*/mkfiles/turbocpp.mak -*/*/mkfiles/watcom.mak -*/*/sys/fdkrncfg.c -*/*/sys/bin2c.c -*/*/sys/makefile -*/*/sys/sys.c -*/*/sys/talloc.c -*/*/utils/echoto.bat -*/*/utils/exeflat.c -*/*/utils/indent.ini -*/*/utils/makefile -*/*/utils/patchobj.c -*/*/utils/proto.bat -*/*/utils/relocinf.c -*/*/utils/rmfiles.bat -*/*/utils/wlinker.bat diff --git a/hdr/portab.h b/hdr/portab.h index 78bb79fa..e551d6c3 100644 --- a/hdr/portab.h +++ b/hdr/portab.h @@ -35,6 +35,8 @@ static char *portab_hRcsId = #endif #endif +#include + /****************************************************************/ /* */ /* Machine dependant portable types. Note that this section is */ @@ -256,55 +258,105 @@ typedef signed long LONG; #define LONG long #endif +typedef UWORD ofs_t; +typedef UWORD seg_t; + +#define lonibble(v) (0x0f & (v)) +#define hinibble(v) (0xf0 & (v)) + +#if CHAR_BIT == 8 +# define lobyte(v) ((UBYTE)(v)) +#else +# define lobyte(v) ((UBYTE)(0xff & (v))) +#endif +#define hibyte(v) lobyte ((UWORD)(v) >> 8u) + +#if USHRT_MAX == 0xFFFF +# define loword(v) ((unsigned short)(v)) +#else +# define loword(v) (0xFFFF & (unsigned)(v)) +#endif +#define hiword(v) loword ((v) >> 16u) + +#define MK_UWORD(hib,lob) (((UWORD)(hib) << 8u) | (UBYTE)(lob)) +#define MK_ULONG(hiw,low) (((ULONG)(hiw) << 16u) | (UWORD)(low)) + /* General far pointer macros */ #ifdef I86 #ifndef MK_FP -#if defined(__WATCOMC__) +#if defined __WATCOMC__ #define MK_FP(seg,ofs) (((UWORD)(seg)):>((VOID *)(ofs))) -#elif defined(__TURBOC__) && (__TURBOC__ > 0x202) +#elif __TURBOC__ > 0x202 #define MK_FP(seg,ofs) ((void _seg *)(seg) + (void near *)(ofs)) #else -#define MK_FP(seg,ofs) ((void FAR *)(((ULONG)(seg)<<16)|(UWORD)(ofs))) +#define MK_FP(seg,ofs) ((void FAR *)MK_ULONG(seg, ofs)) #endif -#define pokeb(seg, ofs, b) (*((unsigned char far *)MK_FP(seg,ofs)) = b) -#define poke(seg, ofs, w) (*((unsigned far *)MK_FP(seg,ofs)) = w) +#define pokeb(seg, ofs, b) (*(unsigned char far *)MK_FP(seg,ofs) = (b)) +#define poke(seg, ofs, w) (*(unsigned far *)MK_FP(seg,ofs) = (w)) #define pokew poke -#define pokel(seg, ofs, l) (*((unsigned long far *)MK_FP(seg,ofs)) = l) -#define peekb(seg, ofs) (*((unsigned char far *)MK_FP(seg,ofs))) -#define peek(seg, ofs) (*((unsigned far *)MK_FP(seg,ofs))) +#define pokel(seg, ofs, l) (*(unsigned long far *)MK_FP(seg,ofs) = (l)) +#define peekb(seg, ofs) (*(unsigned char far *)MK_FP(seg,ofs)) +#define peek(seg, ofs) (*(unsigned far *)MK_FP(seg,ofs)) #define peekw peek -#define peekl(seg, ofs) (*((unsigned long far *)MK_FP(seg,ofs))) +#define peekl(seg, ofs) (*(unsigned long far *)MK_FP(seg,ofs)) -#if defined(__TURBOC__) && (__TURBOC__ > 0x202) +#if __TURBOC__ > 0x202 #define FP_SEG(fp) ((unsigned)(void _seg *)(void far *)(fp)) #else -#define FP_SEG(fp) ((unsigned)((ULONG)(VOID FAR *)(fp)>>16)) +#define FP_SEG(fp) hiword ((ULONG)(VOID FAR *)(fp)) #endif -#define FP_OFF(fp) ((unsigned)(fp)) +#define FP_OFF(fp) loword (fp) #endif #endif #ifdef MC68K -#define MK_FP(seg,ofs) ((VOID *)(&(((BYTE *)(size_t)(seg))[(ofs)]))) -#define FP_SEG(fp) (0) +#define MK_FP(seg,ofs) ((VOID *)&(((BYTE *)(size_t)(seg))[ofs])) +#define FP_SEG(fp) 0 #define FP_OFF(fp) ((size_t)(fp)) #endif typedef VOID (FAR ASMCFUNC * intvec) (void); +#define MK_PTR(type,seg,ofs) ((type FAR*) MK_FP (seg, ofs)) +#if __TURBOC__ > 0x202 +# define MK_SEG_PTR(type,seg) ((type _seg*) (seg)) +#else +# define _seg FAR +# define MK_SEG_PTR(type,seg) MK_PTR (type, seg, 0) +#endif + /* this suppresses the warning unreferenced parameter 'x' and (hopefully) generates no code */ -#define UNREFERENCED_PARAMETER(x) (void)x; +#define UNREFERENCED_PARAMETER(x) (void)(x) #ifdef I86 /* commandline overflow - removing /DPROTO TE */ #define PROTO #endif -#define LENGTH(x) (sizeof(x)/sizeof(x[0])) +typedef const char CStr[], *PCStr; +typedef char Str[], *PStr; +typedef const void *CVP; +typedef const void FAR *CVFP; +typedef void FAR *VFP; + +#define LENGTH(x) (sizeof (x)/sizeof *(x)) +#define ENDOF(x) ((x) + LENGTH (x)) + +/* (unsigned) modulo arithmetics trick: a<=b<=c equal to b-a<=c-a */ +#define inrange(type,v,lo,hi) ((type)((v) - (lo)) <= (type)((hi) - (lo))) +#define _isdigit(c) inrange(UBYTE, c, '0', '9') +#define _islower(c) inrange(UBYTE, c, 'a', 'z') +#define _isupper(c) inrange(UBYTE, c, 'A', 'Z') + +/* Fast ASCII tolower/toupper */ +#define _fast_lower(ch) ((ch) | 0x20) +#define _fast_dolower(var) ((var) |= 0x20) +#define _fast_upper(ch) ((ch) & ~0x20) +#define _fast_doupper(var) ((var) &= ~0x20) diff --git a/hdr/stacks.inc b/hdr/stacks.inc index f3681b8a..b002738d 100644 --- a/hdr/stacks.inc +++ b/hdr/stacks.inc @@ -149,10 +149,10 @@ irp_hi equ 26 %else push eax pop ax - %ifdef MSCL8 + %ifdef MSC push ecx pop cx - %else ;BC5 + %else ;BC push ebx pop bx %endif @@ -170,10 +170,10 @@ irp_hi equ 26 %else push dx pop edx - %ifdef MSCL8 + %ifdef MSC push cx pop ecx - %else ;BC5 + %else ;BC push bx pop ebx %endif diff --git a/hdr/version.h b/hdr/version.h index 4009ca61..008deeb7 100644 --- a/hdr/version.h +++ b/hdr/version.h @@ -48,7 +48,7 @@ static BYTE *date_hRcsId = #define REVISION_MAJOR 1 #define REVISION_MINOR 1 #define REVISION_SEQ 35 -#define BUILD "2035" -#define SUB_BUILD "a" -#define KERNEL_VERSION_STRING "1.1.35" /*#REVISION_MAJOR "." #REVISION_MINOR "." #REVISION_SEQ */ +#define BUILD "2035a" +#define SUB_BUILD "" +#define KERNEL_VERSION_STRING "1.1.35a" /*#REVISION_MAJOR "." #REVISION_MINOR "." #REVISION_SEQ */ #define KERNEL_BUILD_STRING "2035a" /*#BUILD SUB_BUILD */ diff --git a/kernel/break.c b/kernel/break.c index be097c52..7ad29633 100644 --- a/kernel/break.c +++ b/kernel/break.c @@ -53,13 +53,13 @@ unsigned char ctrl_break_pressed(void) unsigned char check_handle_break(struct dhdr FAR **pdev) { - unsigned char c = CTL_C; - if (!ctrl_break_pressed()) - c = (unsigned char)ndread(&syscon); - if (c != CTL_C && *pdev != syscon) - c = (unsigned char)ndread(pdev); - if (c == CTL_C) + unsigned char c; + if (ctrl_break_pressed() || + (c = (unsigned char)ndread(&syscon)) == CTL_C || + *pdev != syscon && (c = (unsigned char)ndread(pdev)) == CTL_C) + { handle_break(pdev, -1); + } return c; } @@ -90,4 +90,3 @@ void handle_break(struct dhdr FAR **pdev, int sft_out) spawn_int23(); /* invoke user INT-23 and never come back */ } - diff --git a/kernel/config.c b/kernel/config.c index 2b8f8d79..6974e8fd 100644 --- a/kernel/config.c +++ b/kernel/config.c @@ -36,292 +36,217 @@ static BYTE *RcsId = "$Id$"; #endif +#define testbit(v,bit) ((UBYTE)((v) >> (UBYTE)(bit)) & 1) + #ifdef DEBUG #define DebugPrintf(x) printf x #else #define DebugPrintf(x) #endif -#define para2far(seg) ((mcb FAR *)MK_FP((seg), 0)) -/** - Menu selection bar struct: - x pos, ypos, string -*/ -#define MENULINEMAX 80 -#define MENULINESMAX 10 -struct MenuSelector -{ - int x; - int y; - BYTE bSelected; - BYTE Text[MENULINEMAX]; -}; +static UBYTE MenuColor BSS_INIT(0); -/** Structure below holds the menu-strings */ -STATIC struct MenuSelector MenuStruct[MENULINESMAX] BSS_INIT({0}); +static unsigned screenwidth(void) +{ + return peek(0, 0x44a); +} -int nMenuLine BSS_INIT(0); -int MenuColor = -1; +static unsigned screenbottom(void) +{ + UBYTE row = peekb(0, 0x484); + if (row == 0) + row = 24; + return row; +} -STATIC void WriteMenuLine(struct MenuSelector *menu) +static unsigned screeny(void) { iregs r; - unsigned char attr = (unsigned char)MenuColor; - char *pText = menu->Text; - - if (pText[0] == 0) - return; - - if(menu->bSelected) - attr = ((attr << 4) | (attr >> 4)); + r.BH = peekb(0, 0x462); /* active video page */ + r.AH = 0x03; /* get cursor pos */ + init_call_intr(0x10, &r); + return r.DH; +} - /* clear line */ - r.a.x = 0x0600; - r.b.b.h = attr; - r.c.b.l = r.d.b.l = menu->x; - r.c.b.h = r.d.b.h = menu->y; - r.d.b.l += strlen(pText) - 1; +static void gotoxy(unsigned x, unsigned y) +{ + iregs r; + r.BH = peekb(0, 0x462); /* active video page */ + r.DL = x; + r.DH = y; + r.AH = 0x02; /* set cursor pos */ init_call_intr(0x10, &r); +} - /* set cursor position: */ - r.a.b.h = 0x02; - r.b.b.h = 0; - r.d.b.l = menu->x; - r.d.b.h = menu->y; +static void ClearScreenArea(UBYTE attr, unsigned x, unsigned y, unsigned w, unsigned h) +{ + iregs r; + r.BH = attr; + r.CL = x; r.DL = x + w - 1; + r.CH = y; r.DH = y + h - 1; + r.AX = 0x0600; /* clear rectangle */ init_call_intr(0x10, &r); - printf("%s", pText); + gotoxy(x, y); } -/* Deselect the previously selected line */ -STATIC void DeselectLastLine(void) +static void say(PCStr s) { - struct MenuSelector *menu; - for (menu = MenuStruct; menu < &MenuStruct[MENULINESMAX]; menu++) - { - if (menu->bSelected) - { - /* deselect it: */ - menu->bSelected = 0; - WriteMenuLine(menu); - break; - } - } + printf(s); } -STATIC void SelectLine(int MenuSelected) +static void say2(PCStr f, PCStr s) { - struct MenuSelector *menu; - - DeselectLastLine(); /* clear previous selection */ - menu = &MenuStruct[MenuSelected]; - menu->bSelected = 1; /* set selection flag for this one */ - WriteMenuLine(menu); + printf(f, s); } -UWORD umb_start BSS_INIT(0), UMB_top BSS_INIT(0); -UWORD ram_top BSS_INIT(0); /* How much ram in Kbytes */ -size_t ebda_size BSS_INIT(0); - -static UBYTE ErrorAlreadyPrinted[128] BSS_INIT({0}); +static void clearrow(void) +{ + unsigned width; + say("\r"); + for (width = screenwidth(); --width;) + say(" "); + say("\r"); +} -char master_env[128] BSS_INIT({0}); -static char *envp = master_env; +static seg_t umb_base_start BSS_INIT(0); +static size_t ebda_size BSS_INIT(0); struct config Config = { - 0, - NUMBUFF, - NFILES, - 0, - NFCBS, - 0, - "command.com", - " /P /E:256\r\n", - NLAST, - 0, - NSTACKS, - 0, - STACKSIZE - /* COUNTRY= is initialized within DoConfig() */ - , 0 /* country ID */ - , 0 /* codepage */ - , 0 /* amount required memory */ - , 0 /* pointer to loaded data */ - , 0 /* strategy for command.com is low by default */ - , 0 /* default value for switches=/E:nnnn */ + /* UBYTE cfgDosDataUmb; */ 0, + /* BYTE cfgBuffers; */ NUMBUFF, + /* UBYTE cfgFiles; */ NFILES, + /* UBYTE cfgFilesHigh; */ 0, + /* UBYTE cfgFcbs; */ NFCBS, + /* UBYTE cfgProtFcbs; */ 0, + /* char cfgShell[256]; */ "command.com /P /E:256", + /* UBYTE cfgLastdrive; */ NLAST, + /* UBYTE cfgLastdriveHigh; */ 0, + /* BYTE cfgStacks; */ NSTACKS, + /* BYTE cfgStacksHigh; */ 0, + /* UWORD cfgStackSize; */ STACKSIZE, + /* UBYTE cfgP_0_startmode; */ 0, /* load command.com (low by default) */ + /* unsigned ebda2move; */ 0, /* value for SWITCHES=/E:nnnn */ }; -STATIC seg base_seg BSS_INIT(0); -STATIC seg umb_base_seg BSS_INIT(0); -BYTE FAR *lpTop BSS_INIT(0); +STATIC seg_t base_seg BSS_INIT(0); +STATIC seg_t umb_base_seg BSS_INIT(0); +VFP lpTop BSS_INIT(0); STATIC unsigned nCfgLine BSS_INIT(0); -COUNT UmbState BSS_INIT(0); -STATIC BYTE szLine[256] BSS_INIT({0}); -STATIC BYTE szBuf[256] BSS_INIT({0}); - -BYTE singleStep BSS_INIT(FALSE); /* F8 processing */ -BYTE SkipAllConfig BSS_INIT(FALSE); /* F5 processing */ -BYTE askThisSingleCommand BSS_INIT(FALSE); /* ?device= device?= */ -BYTE DontAskThisSingleCommand BSS_INIT(FALSE); /* !files= */ - -COUNT MenuTimeout = -1; -BYTE MenuSelected BSS_INIT(0); -UCOUNT MenuLine BSS_INIT(0); -UCOUNT Menus BSS_INIT(0); - -STATIC VOID CfgMenuColor(BYTE * pLine); - -STATIC VOID Config_Buffers(BYTE * pLine); -STATIC VOID sysScreenMode(BYTE * pLine); -STATIC VOID sysVersion(BYTE * pLine); -STATIC VOID CfgBreak(BYTE * pLine); -STATIC VOID Device(BYTE * pLine); -STATIC VOID DeviceHigh(BYTE * pLine); -STATIC VOID Files(BYTE * pLine); -STATIC VOID FilesHigh(BYTE * pLine); -STATIC VOID Fcbs(BYTE * pLine); -STATIC VOID CfgLastdrive(BYTE * pLine); -STATIC VOID CfgLastdriveHigh(BYTE * pLine); -STATIC BOOL LoadDevice(BYTE * pLine, char FAR *top, COUNT mode); -STATIC VOID Dosmem(BYTE * pLine); -STATIC VOID DosData(BYTE * pLine); -STATIC VOID Country(BYTE * pLine); -STATIC VOID InitPgm(BYTE * pLine); -STATIC VOID InitPgmHigh(BYTE * pLine); -STATIC VOID CmdInstall(BYTE * pLine); -STATIC VOID CmdInstallHigh(BYTE * pLine); -STATIC VOID CmdSet(BYTE * pLine); - - -STATIC VOID CfgSwitchar(BYTE * pLine); -STATIC VOID CfgSwitches(BYTE * pLine); -STATIC VOID CfgFailure(BYTE * pLine); -STATIC VOID CfgIgnore(BYTE * pLine); -STATIC VOID CfgMenu(BYTE * pLine); - -STATIC VOID CfgMenuEsc(BYTE * pLine); + +static unsigned nPass BSS_INIT(0); +static char configfile [] = "FDCONFIG.SYS"; +STATIC char szLine[256] BSS_INIT({0}); +STATIC char szBuf[256] BSS_INIT({0}); + +UBYTE askCommand BSS_INIT(0); + +static int MenuTimeout = -1; +static unsigned last_choice = 10; /* =non existing choice */ +static unsigned line_choices BSS_INIT(0); +static unsigned all_choices BSS_INIT(0); + +STATIC BOOL LoadDevice(PCStr, VFP top, int mode); +STATIC void CfgFailure(PCStr); STATIC VOID DoMenu(void); -STATIC VOID CfgMenuDefault(BYTE * pLine); -STATIC BYTE * skipwh(BYTE * s); -STATIC BYTE * scan(BYTE * s, BYTE * d); -STATIC BOOL isnum(char ch); -#if 0 -STATIC COUNT tolower(COUNT c); -#endif +STATIC PCStr skipwh(PCStr); +STATIC PCStr scanword(PCStr, PStr); +STATIC PCStr scanverb(PCStr, PStr); +#define isdigit(ch) ((UBYTE)((ch) - '0') <= 9) STATIC char toupper(char c); -STATIC VOID strupr(char *s); -STATIC VOID mcb_init(UCOUNT seg, UWORD size, BYTE type); -STATIC VOID mumcb_init(UCOUNT seg, UWORD size); - -STATIC VOID Stacks(BYTE * pLine); -STATIC VOID StacksHigh(BYTE * pLine); - -STATIC VOID SetAnyDos(BYTE * pLine); -STATIC VOID Numlock(BYTE * pLine); -STATIC BYTE * GetNumArg(BYTE * pLine, COUNT * pnArg); -BYTE *GetStringArg(BYTE * pLine, BYTE * pszString); -STATIC int SkipLine(char *pLine); -#if 0 -STATIC char * stristr(char *s1, char *s2); -#endif -STATIC char strcaseequal(const char * d, const char * s); -STATIC int LoadCountryInfoHardCoded(char *filename, COUNT ctryCode, COUNT codePage); +static PStr strupr(PStr); +static PStr strcat(PStr d, PCStr s); +STATIC void mcb_init(seg_t, size_t, BYTE type); +STATIC void mumcb_init(seg_t, size_t); +#define mcb_next(seg) ((seg) + MK_SEG_PTR(mcb, seg)->m_size + 1) + +STATIC PCStr GetNumArg(PCStr); +STATIC BOOL GetNumArg1(PCStr); +STATIC BOOL GetNumArg2(PCStr, int default2); +static void hintSkipAll(void); +static BOOL askSkipLine(void); +STATIC char strcasediff(PCStr, PCStr); +STATIC void LoadCountryInfoHardCoded(CStr filename, int ccode, int cpage); STATIC void umb_init(void); -void HMAconfig(int finalize); STATIC void config_init_buffers(int anzBuffers); /* from BLOCKIO.C */ STATIC void config_init_fnodes(int f_nodes_cnt); -#ifdef I86 -STATIC VOID FAR * AlignParagraph(VOID FAR * lpPtr); -#else -#define AlignParagraph(x) ((VOID *)x) -#endif - #define EOF 0x1a -STATIC struct table * LookUp(struct table *p, BYTE * token); +typedef void config_sys_func_t(PCStr); -typedef void config_sys_func_t(BYTE * pLine); +STATIC config_sys_func_t + CfgSwitches, + CfgMenuColor, CfgMenuDefault, CfgMenu, CfgMenuEsc, + CfgBreak, Config_Buffers, Country, Dosmem, DosData, + Fcbs, Files, FilesHigh, CfgLastdrive, CfgLastdriveHigh, + Numlock, CmdShell, CmdShellHigh, + Stacks, StacksHigh, CfgSwitchar, + sysScreenMode, sysVersion, SetAnyDos, + Device, DeviceHigh, CmdInstall, CmdInstallHigh, CmdSet; -struct table { - BYTE *entry; - signed char pass; - config_sys_func_t *func; -}; +STATIC struct table { + PCStr const entry; + UBYTE pass; + config_sys_func_t *const func; -STATIC struct table commands[] = { - /* first = switches! this one is special since it is asked for but - also checked before F5/F8 */ - {"SWITCHES", 0, CfgSwitches}, +} commands [] = { - /* rem is never executed by locking out pass */ - {"REM", 0, CfgIgnore}, - {";", 0, CfgIgnore}, + /* this one is special since it checked for /N/F before F5/F8 and + asked for /K/E after menu; DoConfig() changes commands[0].pass */ + {"SWITCHES", 0, CfgSwitches}, - {"MENUCOLOR",0,CfgMenuColor}, + {"REM", 100, NULL}, + {"MENUCOLOR", 0, CfgMenuColor}, {"MENUDEFAULT", 0, CfgMenuDefault}, - {"MENU", 0, CfgMenu}, /* lines to print in pass 0 */ - {"ECHO", 2, CfgMenu}, /* lines to print in pass 2 - install(high) */ - {"EECHO", 2, CfgMenuEsc}, /* modified ECHO (ea) */ - - {"BREAK", 1, CfgBreak}, - {"BUFFERS", 1, Config_Buffers}, - {"COMMAND", 1, InitPgm}, - {"COUNTRY", 1, Country}, - {"DOS", 1, Dosmem}, - {"DOSDATA", 1, DosData}, - {"FCBS", 1, Fcbs}, - {"FILES", 1, Files}, - {"FILESHIGH", 1, FilesHigh}, - {"LASTDRIVE", 1, CfgLastdrive}, - {"LASTDRIVEHIGH", 1, CfgLastdriveHigh}, - {"NUMLOCK", 1, Numlock}, - {"SHELL", 1, InitPgm}, - {"SHELLHIGH", 1, InitPgmHigh}, - {"STACKS", 1, Stacks}, - {"STACKSHIGH", 1, StacksHigh}, - {"SWITCHAR", 1, CfgSwitchar}, - {"SCREEN", 1, sysScreenMode}, /* JPP */ - {"VERSION", 1, sysVersion}, /* JPP */ - {"ANYDOS", 1, SetAnyDos}, /* tom */ - - {"DEVICE", 2, Device}, - {"DEVICEHIGH", 2, DeviceHigh}, - {"INSTALL", 2, CmdInstall}, - {"INSTALLHIGH", 2, CmdInstallHigh}, - {"SET", 2, CmdSet}, - - /* default action */ - {"", -1, CfgFailure} + {"MENU", 1, CfgMenu}, /* lines to print in pass 1 */ + {"ECHO", 3, CfgMenu}, /* lines to print in pass 3 */ + {"EECHO", 3, CfgMenuEsc}, /* modified ECHO (ea) */ + + {"BREAK", 2, CfgBreak}, + {"BUFFERS", 2, Config_Buffers}, + {"BUFFERSHIGH", 2, Config_Buffers}, /* currently dummy */ + {"COUNTRY", 2, Country}, + {"DOS", 2, Dosmem}, + {"DOSDATA", 2, DosData}, + {"FCBS", 2, Fcbs}, + {"FILES", 2, Files}, + {"FILESHIGH", 2, FilesHigh}, + {"LASTDRIVE", 2, CfgLastdrive}, + {"LASTDRIVEHIGH", 2, CfgLastdriveHigh}, + {"NUMLOCK", 2, Numlock}, + {"STACKS", 2, Stacks}, + {"STACKSHIGH", 2, StacksHigh}, + {"SWITCHAR", 2, CfgSwitchar}, + {"SCREEN", 2, sysScreenMode}, /* JPP */ + {"VERSION", 2, sysVersion}, /* JPP */ + {"ANYDOS", 2, SetAnyDos}, /* tom */ + + {"DEVICE", 3, Device}, + {"DEVICEHIGH", 3, DeviceHigh}, + + {"INSTALL", 4, CmdInstall}, + {"INSTALLHIGH", 4, CmdInstallHigh}, + {"SET", 4, CmdSet}, + {"SHELL", 4, CmdShell}, + {"SHELLHIGH", 4, CmdShellHigh}, }; -/* RE function for menu. */ -int findend(BYTE * s) -{ - int nLen = 0; - /* 'marks' end if at least ten spaces, 0, or newline is found. */ - while (*s && (*s != 0x0d || *s != 0x0a) ) - { - BYTE *p= skipwh(s); - /* ah, more than 9 whitespaces ? We're done here (hrmph!) */ - if(p - s >= 10) - break; - nLen++; - ++s; - } - return nLen; -} +enum { HMA_NONE, /* do nothing */ + HMA_REQ, /* DOS=HIGH detected */ + HMA_DONE, /* Moved kernel to HMA */ +}; -BYTE *pLineStart BSS_INIT(0); +enum { UMB_NONE, /* do nothing */ + UMB_DONE, /* UMB initialized */ + UMB_REQ, /* DOS=UMB detected */ +}; -BYTE HMAState BSS_INIT(0); -#define HMA_NONE 0 /* do nothing */ -#define HMA_REQ 1 /* DOS = HIGH detected */ -#define HMA_DONE 2 /* Moved kernel to HMA */ -#define HMA_LOW 3 /* Definitely LOW */ +static UBYTE HMAState BSS_INIT(HMA_NONE); +static UBYTE UmbState BSS_INIT(UMB_NONE); /* Do first time initialization. Store last so that we can reset it */ /* later. */ @@ -345,7 +270,7 @@ void PreConfig(void) /* Initialize the file table */ config_init_fnodes(Config.cfgFiles); - LoL->sfthead = MK_FP(FP_SEG(LoL), 0xcc); /* &(LoL->firstsftt) */ + LoL->sfthead = MK_PTR(struct sfttbl, FP_SEG(LoL), 0xcc); /* &(LoL->firstsftt) */ /* LoL->FCBp = (sfttbl FAR *)&FcbSft; */ /* LoL->FCBp = (sfttbl FAR *) KernelAlloc(sizeof(sftheader) @@ -366,17 +291,26 @@ void PreConfig(void) /* Done. Now initialize the MCB structure */ /* This next line is 8086 and 80x86 real mode specific */ #ifdef DEBUG - printf("Preliminary allocation completed: top at %p\n", lpTop); + printf("Preliminary allocation completed: top at %p\n", lpTop); #endif } -/* Do second pass initialization: near allocation and MCBs */ -void PreConfig2(void) +static void KernelAllocSFT(sfttbl FAR *p, unsigned files, int high) { - struct sfttbl FAR *sp; + p = p->sftt_next = (sfttbl FAR *)KernelAlloc(sizeof(sftheader) + + files * sizeof(sft), 'F', high); + p->sftt_count = files; + p->sftt_next = (sfttbl FAR *)-1l; +} - /* initialize NEAR allocated things */ +#define EBDASEG 0x40e +#define RAMSIZE 0x413 +#define RAM_size() peek(0, RAMSIZE) +/* Do pre-drivers initialization: near allocation and MCBs */ +static void PreConfig3(void) +{ + /* initialize NEAR allocated things */ /* Initialize the base memory pointers from last time. */ /* if the kernel could be moved to HMA, everything behind the dynamic @@ -385,52 +319,58 @@ void PreConfig2(void) and allocation starts after the kernel. */ - base_seg = LoL->first_mcb = FP_SEG(AlignParagraph((BYTE FAR *) DynLast() + 0x0f)); - - if (Config.ebda2move) + size_t ram_top = RAM_size(); /* how much conventional RAM, kb */ + seg_t ebdaseg = peek(0, EBDASEG); + size_t ebdasz = peekb(ebdaseg, 0); + if (Config.ebda2move && ram_top * 64 == ebdaseg && ebdasz <= 63) { - ebda_size = ebdasize(); - ram_top += ebda_size / 1024; - if (ebda_size > Config.ebda2move) - ebda_size = Config.ebda2move; + ram_top += ebdasz; + ebdasz *= 1024u; + if (ebdasz > Config.ebda2move) + ebdasz = (Config.ebda2move + 15) & -16; + ebda_size = ebdasz; } /* We expect ram_top as Kbytes, so convert to paragraphs */ - mcb_init(base_seg, ram_top * 64 - LoL->first_mcb - 1, MCB_LAST); + base_seg = LoL->first_mcb = FP_SEG(alignNextPara(DynLast())); + mcb_init(base_seg, ram_top * 64 - base_seg, MCB_LAST); - sp = LoL->sfthead; - sp = sp->sftt_next = KernelAlloc(sizeof(sftheader) + 3 * sizeof(sft), 'F', 0); - sp->sftt_next = (sfttbl FAR *) - 1; - sp->sftt_count = 3; + /* allocate space in low memory for 3 file handles + (SFT) in addition to 5 handles, builtin into LOL */ + KernelAllocSFT(LoL->sfthead, 3, 0); if (ebda_size) /* move the Extended BIOS Data Area from top of RAM here */ - movebda(ebda_size, FP_SEG(KernelAlloc(ebda_size, 'I', 0))); + { + seg_t new_seg = FP_SEG(KernelAlloc(ebda_size, 'I', 0)); + fmemcpy(MK_SEG_PTR(BYTE, new_seg), MK_SEG_PTR(const BYTE, ebdaseg), ebda_size); + poke(0, EBDASEG, new_seg); + poke(0, RAMSIZE, ram_top); + } - if (UmbState == 2) - umb_init(); + umb_init(); } -/* Do third pass initialization. */ -/* Also, run config.sys to load drivers. */ +/* Do last initialization. */ void PostConfig(void) { - sfttbl FAR *sp; - /* We could just have loaded FDXMS or HIMEM */ if (HMAState == HMA_REQ && MoveKernelToHMA()) HMAState = HMA_DONE; - + if (Config.cfgDosDataUmb) { - Config.cfgFilesHigh = TRUE; - Config.cfgLastdriveHigh = TRUE; - Config.cfgStacksHigh = TRUE; + Config.cfgFilesHigh = + Config.cfgStacksHigh = + Config.cfgLastdriveHigh = 1; } - + /* compute lastdrive ... */ - LoL->lastdrive = Config.cfgLastdrive; - if (LoL->lastdrive < LoL->nblkdev) - LoL->lastdrive = LoL->nblkdev; + { + UBYTE drv = Config.cfgLastdrive; + if (drv < LoL->nblkdev) + drv = LoL->nblkdev; + LoL->lastdrive = drv; + } DebugPrintf(("starting FAR allocations at %x\n", base_seg)); @@ -449,12 +389,11 @@ void PostConfig(void) /* LoL->FCBp = (sfttbl FAR *)&FcbSft; */ /* LoL->FCBp = KernelAlloc(sizeof(sftheader) + Config.cfgFiles * sizeof(sft)); */ - sp = LoL->sfthead->sftt_next; - sp = sp->sftt_next = (sfttbl FAR *) - KernelAlloc(sizeof(sftheader) + (Config.cfgFiles - 8) * sizeof(sft), 'F', - Config.cfgFilesHigh); - sp->sftt_next = (sfttbl FAR *) - 1; - sp->sftt_count = Config.cfgFiles - 8; + + /* allocate space for remaining file handles (SFT); 5 are + already builtin and 3 are allocated in PreConfig3() */ + KernelAllocSFT(LoL->sfthead->sftt_next, + Config.cfgFiles - 8, Config.cfgFilesHigh); LoL->CDSp = KernelAlloc(sizeof(struct cds) * LoL->lastdrive, 'L', Config.cfgLastdriveHigh); @@ -465,9 +404,10 @@ void PostConfig(void) printf(" CDS table 0x%p\n", LoL->CDSp); printf(" DPB table 0x%p\n", LoL->DPBp); #endif + if (Config.cfgStacks) { - VOID FAR *stackBase = + void _seg *stackBase = KernelAlloc(Config.cfgStacks * Config.cfgStackSize, 'S', Config.cfgStacksHigh); init_stacks(stackBase, Config.cfgStacks, Config.cfgStackSize); @@ -481,17 +421,18 @@ void PostConfig(void) /* This code must be executed after device drivers has been loaded */ VOID configDone(VOID) { - if (UmbState == 1) - para2far(base_seg)->m_type = MCB_LAST; + if (UmbState == UMB_DONE) + MK_SEG_PTR(mcb, base_seg)->m_type = MCB_LAST; if (HMAState != HMA_DONE) { - mcb FAR *p; - unsigned short kernel_seg; - unsigned short hma_paras = (HMAFree+0xf)/16; - - kernel_seg = allocmem(hma_paras); - p = para2far(kernel_seg - 1); +#ifdef DEBUG + size_t hma_paras = (HMAFree + 15) / 16; + seg_t kernel_seg = allocmem(hma_paras); +#else + seg_t kernel_seg = allocmem((HMAFree + 15) / 16); +#endif + mcb _seg *p = MK_SEG_PTR(mcb, kernel_seg - 1); p->m_name[0] = 'S'; p->m_name[1] = 'C'; @@ -499,357 +440,417 @@ VOID configDone(VOID) DebugPrintf(("HMA not available, moving text to %x\n", kernel_seg)); MoveKernel(kernel_seg); - - kernel_seg += hma_paras + 1; - - DebugPrintf(("kernel is low, start alloc at %x", kernel_seg)); + DebugPrintf(("kernel is low, start alloc at %x\n", + kernel_seg + hma_paras + 1)); } /* The standard handles should be reopened here, because we may have loaded new console or printer drivers in CONFIG.SYS */ } -STATIC seg prev_mcb(seg cur_mcb, seg start) -{ - /* determine prev mcb */ - seg mcb_prev, mcb_next; - mcb_prev = mcb_next = start; - while (mcb_next < cur_mcb && para2far(mcb_next)->m_type == MCB_NORMAL) - { - mcb_prev = mcb_next; - mcb_next += para2far(mcb_prev)->m_size + 1; - } - return mcb_prev; -} - STATIC void umb_init(void) { - UCOUNT umb_seg, umb_size; - seg umb_max; - void far *xms_addr; + CVFP xms_addr; + seg_t umb_seg; + size_t umb_size; - if ((xms_addr = DetectXMSDriver()) == NULL) - return; - - if (UMB_get_largest(xms_addr, &umb_seg, &umb_size)) + if (UmbState == UMB_REQ && + (xms_addr = DetectXMSDriver()) != NULL && + UMB_get_largest(xms_addr, &umb_seg, &umb_size)) { - UmbState = 1; + seg_t umb_furthest = umb_seg; + + /* SAFETY: new block may be too small or below memory top */ + seg_t base_top = RAM_size() * 64 - 1; + if (umb_size < 2 || umb_furthest <= base_top) + return; + + UmbState = UMB_DONE; /* reset root */ - LoL->uppermem_root = ram_top * 64 - 1; + LoL->uppermem_root = base_top; + umb_base_seg = umb_furthest; /* create link mcb (below) */ - para2far(base_seg)->m_type = MCB_NORMAL; - para2far(base_seg)->m_size--; - mumcb_init(LoL->uppermem_root, umb_seg - LoL->uppermem_root - 1); + /* (it prefixes hole between UMBs) */ + MK_SEG_PTR(mcb, base_seg)->m_type = MCB_NORMAL; + MK_SEG_PTR(mcb, base_seg)->m_size--; + mumcb_init(base_top, umb_seg - base_top); /* setup the real mcb for the devicehigh block */ - mcb_init(umb_seg, umb_size - 2, MCB_NORMAL); - - umb_base_seg = umb_max = umb_start = umb_seg; - UMB_top = umb_size; + mcb_init(umb_seg, umb_size, MCB_NORMAL); - /* there can be more UMB's ! - this happens, if memory mapped devces are in between + /* there can be more UMBs ! + this happens, if memory mapped devices are in between like UMB memory c800..c8ff, d8ff..efff with device at d000..d7ff However some of the xxxHIGH commands still only work with the first UMB. */ - while (UMB_get_largest(xms_addr, &umb_seg, &umb_size)) { - seg umb_prev, umb_next; + if (umb_furthest < umb_seg) + { + seg_t umb_hole = mcb_next(umb_furthest); - /* setup the real mcb for the devicehigh block */ - mcb_init(umb_seg, umb_size - 2, MCB_NORMAL); + /* SAFETY: new block may (1) be adjacent to old block, + (2) overlap it or (3) be inside. (2) and (3) are errors + and shouldn't happen, but handle them anyway. */ + if (umb_hole >= umb_seg) + { + size_t overlap = umb_hole - umb_seg; + if (overlap < umb_size) + /* join adjacent/overlapped new block to prev block */ + MK_SEG_PTR(mcb, umb_furthest)->m_size += umb_size - overlap; + continue; + } - /* determine prev and next umbs */ - umb_prev = prev_mcb(umb_seg, LoL->uppermem_root); - umb_next = umb_prev + para2far(umb_prev)->m_size + 1; + /* SAFETY: new block may be too small */ + if (umb_size < 2) + continue; - if (umb_seg < umb_max) + /* create link mcb (below) */ + MK_SEG_PTR(mcb, umb_furthest)->m_size--; + umb_furthest = umb_seg; + umb_hole--; + mumcb_init(umb_hole, umb_seg - umb_hole); + } + else /* umb_seg <= umb_furthest */ { - if (umb_next - umb_seg - umb_size == 0) + seg_t umb_prev, umb_hole, umb_next, umb_cur_next; + + /* SAFETY: umb_seg may point into base memory */ + if (base_top >= umb_seg) + continue; + + /* find previous block */ + for (umb_hole = base_top;;) { - /* should the UMB driver return - adjacent memory in several pieces */ - umb_size += para2far(umb_next)->m_size + 1; - para2far(umb_seg)->m_size = umb_size; + umb_next = mcb_next(umb_hole); + /* ASSUME umb_hole->m_type == 'M' && umb_hole->m_psp == 8 && + umb_next->m_type == 'M' && umb_next->m_psp != 8 && + umb_hole < umb_next <= umb_furthest */ + if (umb_seg <= umb_next) + break; + umb_prev = umb_next; + umb_hole = mcb_next(umb_next); } + /* NOW base_top == umb_hole < umb_seg <= umb_next || + base_top < umb_prev < umb_seg <= umb_next */ + + /* SAFETY: new block may be inside previous block */ + umb_cur_next = umb_seg + umb_size; + if (umb_cur_next <= umb_hole) + continue; + + /* SAFETY: umb_seg may point below hole, + so, use ">=" instead "==" */ + if (umb_hole + 1 >= umb_seg && umb_hole != base_top) + /* join adjacent/overlapped new block to prev block */ + umb_size = umb_cur_next - (umb_seg = umb_prev); else + { + /* SAFETY: new block may be too small */ + if (umb_size < 2 && umb_cur_next < umb_next) + continue; + /* adjust link mcb below */ + MK_SEG_PTR(mcb, umb_hole)->m_size = umb_seg - umb_hole - 1; + } + + /* SAFETY: new block may overlap next block, + so, use ">=" instead "==" */ + if (umb_cur_next >= umb_next) + { + /* join adjacent/overlapped next block to new block */ + if (umb_furthest == umb_next) + umb_furthest = umb_seg; + if (umb_base_seg == umb_next) + umb_base_seg = umb_seg; + umb_size = mcb_next(umb_next) - umb_seg; + } + else /* umb_cur_next < umb_next */ { /* create link mcb (above) */ - mumcb_init(umb_seg + umb_size - 1, umb_next - umb_seg - umb_size); + umb_size--, umb_cur_next--; + mumcb_init(umb_cur_next, umb_next - umb_cur_next); } - } - else /* umb_seg >= umb_max */ - { - umb_prev = umb_next; - } + } /* else */ - if (umb_seg - umb_prev - 1 == 0) - /* should the UMB driver return - adjacent memory in several pieces */ - para2far(prev_mcb(umb_prev, LoL->uppermem_root))->m_size += umb_size; - else - { - /* create link mcb (below) */ - mumcb_init(umb_prev, umb_seg - umb_prev - 1); - } + /* setup the real mcb for the devicehigh block */ + mcb_init(umb_seg, umb_size, MCB_NORMAL); + } /* while */ + + MK_SEG_PTR(mcb, umb_furthest)->m_type = MCB_LAST; + umb_base_start = umb_base_seg; - if (umb_seg > umb_max) - umb_max = umb_seg; - } - para2far(umb_max)->m_size++; - para2far(umb_max)->m_type = MCB_LAST; DebugPrintf(("UMB Allocation completed: start at 0x%x\n", umb_base_seg)); - } + } /* if */ +} + +STATIC const struct table * LookUp(CStr token) +{ + const struct table *p = commands; + do + if (!strcasediff(p->entry, token)) + return p; + while (++p < ENDOF(commands)); + p = NULL; + return p; } -VOID DoConfig(int nPass) +static void DoConfig_(void) { - COUNT nFileDesc; - BYTE *pLine; - BOOL bEof; + int nFileDesc, done; + if (askCommand & ASK_SKIPALL) + return; /* Check to see if we have a config.sys file. If not, just */ /* exit since we don't force the user to have one. */ - if ((nFileDesc = open("fdconfig.sys", 0)) >= 0) - { - DebugPrintf(("Reading FDCONFIG.SYS...\n")); - } - else + /*strcpy (configfile, "FDCONFIG.SYS");*/ + if ((nFileDesc = open(configfile, 0)) < 0) { - DebugPrintf(("FDCONFIG.SYS not found\n")); - if ((nFileDesc = open("config.sys", 0)) < 0) + DebugPrintf(("%s not found\n", configfile)); + strcpy (configfile, "CONFIG.SYS"); + if ((nFileDesc = open(configfile, 0)) < 0) { - DebugPrintf(("CONFIG.SYS not found\n")); + DebugPrintf(("%s not found\n", configfile)); return; } - DebugPrintf(("Reading CONFIG.SYS...\n")); } - - /* Have one -- initialize. */ - nCfgLine = 0; - bEof = 0; - pLine = szLine; + DebugPrintf(("Reading %s...\n", configfile)); /* Read each line into the buffer and then parse the line, */ /* do the table lookup and execute the handler for that */ /* function. */ - - for (; !bEof; nCfgLine++) + done = nCfgLine = 0; + do { - struct table *pEntry; - - pLineStart = szLine; + PStr q; + PCStr p; + const struct table *pEntry; /* read in a single line, \n or ^Z terminated */ - - for (pLine = szLine;;) + nCfgLine++; + for (q = szLine;;) { - if (read(nFileDesc, pLine, 1) <= 0) + if (read(nFileDesc, q, 1) <= 0 || *q == EOF) { - bEof = TRUE; + done++; break; } - if (pLine >= szLine + sizeof(szLine) - 3) - { - CfgFailure(pLine); - printf("error - line overflow line %d \n", nCfgLine); - break; - } - - if (*pLine == '\n' || *pLine == EOF) /* end of line */ + if (*q == '\n') /* end of line */ break; - if (*pLine != '\r') /* ignore CR */ - pLine++; - } - - *pLine = 0; - pLine = szLine; - - /* Skip leading white space and get verb. */ - pLine = scan(pLine, szBuf); - - /* If the line was blank, skip it. Otherwise, look up */ - /* the verb and execute the appropriate function. */ - if (*szBuf == '\0') - continue; + if (*q != '\r') /* ignore CR */ + { + q++; + if (q >= szLine + sizeof szLine - 1) + { + /* *q = 0; */ /* static memory already zeroed */ + CfgFailure(q); + say("error - line overflow\n"); + break; + } + } + } /* for */ + *q = 0; /* terminate line - make ASCIIZ */ - pEntry = LookUp(commands, szBuf); + p = skipwh(szLine); + if (*p == '\0' || *p == ';') + continue; /* skip empty line and comment */ - if (pEntry->pass >= 0 && pEntry->pass != nPass) - continue; - - if (nPass == 0) /* pass 0 always executed (rem Menu prompt switches) */ + p = scanverb(p, szBuf); /* extract verb */ + pEntry = LookUp(szBuf); + if (pEntry == NULL) { - pEntry->func(pLine); + if (nPass == 2) /* only at pass 2 (after menu)... */ + CfgFailure(p); /* ...say error for wrong verb */ continue; } - else - { - if (SkipLine(pLineStart)) /* F5/F8 processing */ - continue; - } - if ((pEntry->func != CfgMenu) && (pEntry->func != CfgMenuEsc)) + if (nPass != pEntry->pass || + nPass > 1 && /* after menu: check "123?device=" */ + !testbit(line_choices, last_choice)) + continue; + + if (pEntry->func != CfgMenu && pEntry->func != CfgMenuEsc) { - /* compatibility "device foo.sys" */ - if (' ' != *pLine && '\t' != *pLine && '=' != *pLine) + if (*p) { - CfgFailure(pLine); - continue; + if (*p != ' ' && *p != '\t' && *p != '=') + { + CfgFailure(p); + continue; + } + p = skipwh(p); + if (*p == '=') /* accept "device foo.sys" without '=' */ + p = skipwh(p + 1); } - pLine = skipwh(pLine); + if (nPass > 1 && askSkipLine()) /* after menu: processing "?" */ + continue; } - if ('=' == *pLine || pEntry->func == CfgMenu || pEntry->func == CfgMenuEsc) - pLine = skipwh(pLine+1); + if (*p == ' ' || *p == '\t') + p++; /* YES. DO IT */ - pEntry->func(pLine); - } - close(nFileDesc); + pEntry->func(p); + } while (!done && !(askCommand & ASK_SKIPALL)); - if (nPass == 0) - { - DoMenu(); - } + close(nFileDesc); + nPass++; } -STATIC struct table * LookUp(struct table *p, BYTE * token) +void DoConfig() { - while (p->entry[0] != '\0' && !strcaseequal(p->entry, token)) - ++p; - return p; + DoConfig_(); /* switches=/f/n, menucolor= */ + hintSkipAll(); + if (!(askCommand & ASK_SKIPALL)) + { + if (MenuColor) /* color defined? */ + ClearScreenArea(MenuColor, 0, 0, screenwidth(), screenbottom() + 1); + DoConfig_(); /* show MENU, find choices */ + if (all_choices) + { + if (!testbit(all_choices, last_choice)) + { + unsigned ac; + last_choice = 0; /* find lowest existing choice */ + for (ac = all_choices; !testbit(ac, 0); ac >>= 1) + last_choice++; + } + if ((all_choices - 1) & all_choices) /* more than one choice? */ + DoMenu(); + if (!(askCommand & ASK_SKIPALL)) + { + static char choice[] = "CONFIG=0"; + choice[7] = (UBYTE)'0' + last_choice; + CmdSet(choice); /* show choice in environment */ + } + } + commands[0].pass = 2; /* switches=/k/e at pass 2 */ + DoConfig_(); /* break=, files=, etc. */ + } + PreConfig3(); + DoConfig_(); /* device= */ } /* get BIOS key with timeout: - - timeout < 0: no timeout + timeout < 0: no timeout, remove returned key from keyboard buffer timeout = 0: poll only once - timeout > 0: timeout in seconds - + timeout > 0: timeout for poll in seconds return - 0xffff : no key hit - + 0 : no key hit (only for timeout >= 0) 0xHH.. : scancode in upper half 0x..LL : asciicode in lower half */ #define GetBiosTime() peekl(0, 0x46c) -UWORD GetBiosKey(int timeout) +#define ESC 27 +#define K_F5 0x3F00 +#define K_F8 0x4200 +#define K_Left 0x4B00 +#define K_Right 0x4D00 +#define K_Up 0x4800 +#define K_Down 0x5000 + +unsigned GetBiosKey(int timeout) { iregs r; - - ULONG startTime = GetBiosTime(); - - if (timeout >= 0) do + if (timeout >= 0) { - r.a.x = 0x0100; /* are there keys available ? */ - init_call_intr(0x16, &r); - if ((unsigned)(GetBiosTime() - startTime) >= timeout * 18u) - return 0xffff; + ULONG startTime = GetBiosTime(); + do + { + r.AH = 0x01; /* are there keys available ? */ + init_call_intr(0x16, &r); + if (!(r.flags & FLG_ZERO)) + return r.AX; + } while ((unsigned)(GetBiosTime() - startTime) < timeout * 18u); + return 0; } - while (r.flags & FLG_ZERO); /* key available or blocking wait (timeout < 0): fetch it */ - r.a.x = 0x0000; + r.AH = 0x00; init_call_intr(0x16, &r); - return r.a.x; + return r.AX; } -STATIC BOOL SkipLine(char *pLine) +static void hintSkipAll(void) { - short key; - - if (InitKernelConfig.SkipConfigSeconds >= 0) + int timeout = InitKernelConfig.SkipConfigSeconds; + if (timeout >= 0) { + unsigned key; - if (InitKernelConfig.SkipConfigSeconds > 0) - printf("Press F8 to trace or F5 to skip CONFIG.SYS/AUTOEXEC.BAT"); + if ((all_choices - 1) & all_choices) /* more than one choice? */ + timeout = 0; - key = GetBiosKey(InitKernelConfig.SkipConfigSeconds); /* wait 2 seconds */ - - InitKernelConfig.SkipConfigSeconds = -1; + if (timeout > 0) + say2("Press F8 to trace or F5 to skip %s/AUTOEXEC.BAT", configfile); + key = GetBiosKey(timeout); + clearrow(); /* clear hint line */ - if (key == 0x3f00) /* F5 */ + if (key == K_F8) /* F8 */ { - SkipAllConfig = TRUE; + askCommand |= ASK_TRACE; + GetBiosKey(-1); /* remove key from buffer */ } - else if (key == 0x4200) /* F8 */ + else if (key == K_F5) /* F5 */ { - singleStep = TRUE; + askCommand |= ASK_SKIPALL; + say2("Bypassing %s and AUTOEXEC.BAT files.\n", configfile); + GetBiosKey(-1); /* remove key from buffer */ } - - printf("\r%79s\r", ""); /* clear line */ - - if (SkipAllConfig) - printf("Skipping CONFIG.SYS/AUTOEXEC.BAT\n"); } +} - if (SkipAllConfig) - return TRUE; - - /* 1?device=CDROM.SYS */ - /* 12?device=OAKROM.SYS */ - /* 123?device=EMM386.EXE NOEMS */ - if ( MenuLine != 0 && - (MenuLine & (1 << MenuSelected)) == 0) - return TRUE; - - if (DontAskThisSingleCommand) /* !files=30 */ - return FALSE; - - if (!askThisSingleCommand && !singleStep) - return FALSE; - - printf("%s[Y,N]?", pLine); +static BOOL askSkipLine(void) +{ + /* !device= never ask / ?device= always ask / device= ask if ASK_TRACE */ + /* "!device?=" will not be asked... */ + if ((askCommand & (ASK_NOASK | ASK_YESALL)) || /* "!" or Esc */ + !(askCommand & (ASK_ASK | ASK_TRACE))) /* not ("?" or trace) */ + return FALSE; /* do not skip, and do not ask either */ + say2("%s[Y,n]?", szLine); for (;;) { - key = GetBiosKey(-1); - - switch (toupper(key & 0x00ff)) + unsigned key = GetBiosKey(-1); /* wait keypress */ + if (key == K_F5) /* YES, you may hit F5 here, too */ + { + askCommand |= ASK_SKIPALL; + key = 'N'; + } + if (key == K_F8) /* F8 */ + key = ESC; + switch (toupper((UBYTE)key)) { case 'N': - case 'n': - printf("N\n"); + say("N\n"); return TRUE; - case 0x1b: /* don't know where documented - ESCAPE answers all following questions - with YES - */ - singleStep = FALSE; /* and fall through */ + case ESC: /* Esc answers all following questions YES */ + askCommand &= ~ASK_TRACE; + askCommand |= ASK_YESALL; + /* and fall through */ case '\r': case '\n': case 'Y': - case 'y': - printf("Y\n"); + say("Y\n"); return FALSE; - } - - if (key == 0x3f00) /* YES, you may hit F5 here, too */ - { - printf("N\n"); - SkipAllConfig = TRUE; - return TRUE; - } - } - + } /* for */ } +static int numarg BSS_INIT(0); + /* JPP - changed so will accept hex number. */ /* ea - changed to accept hex digits in hex numbers */ -STATIC char *GetNumArg(char *p, int *num) +STATIC PCStr GetNumArg(PCStr p) { static char digits[] = "0123456789ABCDEF"; unsigned char base = 10; @@ -858,15 +859,15 @@ STATIC char *GetNumArg(char *p, int *num) /* look for NUMBER */ p = skipwh(p); - if (*p == '-') + if (!isdigit(*p)) { - p++; + if (*p != '-') + { + CfgFailure(p); + return NULL; + } sign = -1; - } - else if (!isnum(*p)) - { - CfgFailure(p); - return NULL; + p++; } for( ; *p; p++) @@ -876,277 +877,274 @@ STATIC char *GetNumArg(char *p, int *num) base = 16; else { - char *q = strchr(digits, ch); + PCStr q = strchr(digits, ch); if (q == NULL) break; n = n * base + (q - digits); } } - *num = n * sign; + numarg = n * sign; return p; } -BYTE *GetStringArg(BYTE * pLine, BYTE * pszString) +STATIC BOOL isEOL(PCStr p) { - /* look for STRING */ - pLine = skipwh(pLine); - - /* just return whatever string is there, including null */ - return scan(pLine, pszString); + if (*p) /* garbage at line end? */ + { + CfgFailure(p); + return FALSE; + } + return TRUE; } -STATIC void Config_Buffers(BYTE * pLine) +/* Format: nnn EOL */ +STATIC BOOL GetNumArg1(PCStr p) { - COUNT nBuffers; - - /* Get the argument */ - if (GetNumArg(pLine, &nBuffers)) - Config.cfgBuffers = nBuffers; + p = GetNumArg(p); + if (p == NULL) + return FALSE; + return isEOL(skipwh(p)); } -/** - Set screen mode - rewritten to use init_call_intr() by RE / ICD -*/ -STATIC VOID sysScreenMode(BYTE * pLine) -{ - iregs r; - COUNT nMode; - COUNT nFunc = 0x11; - - /* Get the argument */ - if (GetNumArg(pLine, &nMode) == (BYTE *) 0) - return; - - if(nMode<0x10) - nFunc = 0; /* set lower screenmode */ - else if ((nMode != 0x11) && (nMode != 0x12) && (nMode != 0x14)) - return; /* do nothing; invalid screenmode */ - -/* Modes - 0x11 (17) 28 lines - 0x12 (18) 43/50 lines - 0x14 (20) 25 lines - */ - /* move cursor to pos 0,0: */ - r.a.b.h = nFunc; /* set videomode */ - r.a.b.l = nMode; - r.b.b.l = 0; - init_call_intr(0x10, &r); -} +static int numarg1 BSS_INIT(0); -STATIC VOID sysVersion(BYTE * pLine) +/* Format: nnn [, nnn] EOL */ +STATIC BOOL GetNumArg2(PCStr p, int default2) { - COUNT major, minor; - char *p = strchr(pLine, '.'); - + p = GetNumArg(p); if (p == NULL) - return; - - p++; - - /* Get major number */ - if (GetNumArg(pLine, &major) == (BYTE *) 0) - return; - - /* Get minor number */ - if (GetNumArg(p, &minor) == (BYTE *) 0) - return; + return FALSE; - printf("Changing reported version to %d.%d\n", major, minor); + numarg1 = numarg; + numarg = default2; + p = skipwh(p); + if (*p == ',') + return GetNumArg1(p + 1); - LoL->os_major = major; - LoL->os_minor = minor; + return isEOL(p); } -STATIC VOID Files(BYTE * pLine) +/* Format: BUFFERS [=] nnn [, nnn] */ +STATIC void Config_Buffers(PCStr p) { - COUNT nFiles; - - /* Get the argument */ - if (GetNumArg(pLine, &nFiles) == (BYTE *) 0) - return; - - /* Got the value, assign either default or new value */ - Config.cfgFiles = max(Config.cfgFiles, nFiles); - Config.cfgFilesHigh = 0; + if (GetNumArg2(p, 0)) + Config.cfgBuffers = (UBYTE)numarg1; + /* Second argument (0..8 buffers for read-ahead) not supported */ } -STATIC VOID FilesHigh(BYTE * pLine) +/* Set screen mode - rewritten to use init_call_intr() by RE / ICD */ +/* Format: SCREEN [=] nnn */ +STATIC void sysScreenMode(PCStr p) { - Files(pLine); - Config.cfgFilesHigh = 1; + if (GetNumArg1(p)) + { + unsigned mode = numarg; + if (mode >= 0x10) + { + /* Modes + 0x11 (17) 28 lines + 0x12 (18) 43/50 lines + 0x14 (20) 25 lines + */ + if (mode != 0x11 && mode != 0x12 && mode != 0x14) + return; /* do nothing; invalid screenmode */ + mode |= 0x1100; + } + { + iregs r; + r.BL = 0; /* block to load for AH=0x11 */ + r.AX = mode; /* set videomode */ + init_call_intr(0x10, &r); + } + } } -STATIC VOID CfgLastdrive(BYTE * pLine) +/* Format: VERSION [=] nn.nn */ +STATIC void sysVersion(PCStr p) { - /* Format: LASTDRIVE = letter */ - BYTE drv; + int major; + p = GetNumArg(p); + major = numarg; + if (p == NULL || *p != '.' || !GetNumArg1(p + 1)) + return; - pLine = skipwh(pLine); - drv = toupper(*pLine); + printf("Changing reported version to %d.%d\n", + LoL->os_setver_major = (UBYTE)major, + LoL->os_setver_minor = (UBYTE)numarg); +} - if (drv < 'A' || drv > 'Z') +/* Format: FILES [=] nnn */ +/* Format: FILESHIGH [=] nnn */ +static void _Files(PCStr p, UBYTE high) +{ + if (GetNumArg1(p)) { - CfgFailure(pLine); - return; + UBYTE nFiles = (UBYTE)numarg; + if (Config.cfgFiles < nFiles) + Config.cfgFiles = nFiles; + Config.cfgFilesHigh = high; } - drv -= 'A' - 1; /* Make real number */ - if (drv > Config.cfgLastdrive) - Config.cfgLastdrive = drv; - Config.cfgLastdriveHigh = 0; } -STATIC VOID CfgLastdriveHigh(BYTE * pLine) -{ - /* Format: LASTDRIVEHIGH = letter */ - CfgLastdrive(pLine); - Config.cfgLastdriveHigh = 1; -} +STATIC void Files(PCStr p) { _Files(p, 0); } -/* - UmbState of confidence, 1 is sure, 2 maybe, 4 unknown and 0 no way. -*/ +STATIC void FilesHigh(PCStr p) { _Files(p, 1); } -STATIC VOID Dosmem(BYTE * pLine) +/* Format: LASTDRIVE [=] letter */ +/* Format: LASTDRIVEHIGH [=] letter */ +static void _CfgLastdrive(PCStr p, UBYTE high) { - BYTE *pTmp; - BYTE UMBwanted = FALSE; + BYTE drv = toupper(*p); + if (drv < 'A' || drv > 'Z' || p[1]) + { + /* no or wrong character or garbage at line end? */ + CfgFailure(p); + return; + } - pLine = GetStringArg(pLine, szBuf); + drv -= 'A' - 1; /* Make real number */ + if (Config.cfgLastdrive < drv) + Config.cfgLastdrive = drv; + Config.cfgLastdriveHigh = high; +} - strupr(szBuf); +STATIC void CfgLastdrive(PCStr p) { _CfgLastdrive(p, 0); } - /* printf("DOS called with %s\n", szBuf); */ +STATIC void CfgLastdriveHigh(PCStr p) { _CfgLastdrive(p, 1); } - for (pTmp = szBuf;;) +/* UmbState of confidence, UMB_DONE is sure, UMB_REQ maybe, UMB_NONE no way. + Transitions: UMB_NONE -> UMB_NONE/UMB_REQ depending on DOS=UMB, try init + (UMB_REQ -> UMB_DONE) after each driver load, as it could have been the + UMB driver. + If UMB really found, state UMB_DONE is reached and MCBs are adjusted. +*/ +/* opt = HIGH | UMB + Format: DOS [=] opt {, opt} +*/ +STATIC void Dosmem(PCStr p) +{ + UBYTE UMBwanted = UMB_NONE, HMAwanted = HMA_NONE; + for (;;) { - if (memcmp(pTmp, "UMB", 3) == 0) + PCStr q = scanword(p, szBuf); + if (!strcasediff(szBuf, "UMB")) + UMBwanted = UMB_REQ; + else if (!strcasediff(szBuf, "HIGH")) + HMAwanted = HMA_REQ; +/* else if (!strcasediff(szBuf, "CLAIMINIT")) + * INITDataSegmentClaimed = 0; + */ + else { - UMBwanted = TRUE; - pTmp += 3; + CfgFailure(p); + return; } - if (memcmp(pTmp, "HIGH", 4) == 0) + p = skipwh(q); + if (*p != ',') { - HMAState = HMA_REQ; - pTmp += 4; + if (*p == '\0') + break; + CfgFailure(p); + return; } -/* if (memcmp(pTmp, "CLAIMINIT",9) == 0) { INITDataSegmentClaimed = 0; pTmp += 9; }*/ - pTmp = skipwh(pTmp); - - if (*pTmp != ',') - break; - pTmp++; - } + p++; + } /* for */ - if (UmbState == 0) + if (UmbState == UMB_NONE) { LoL->uppermem_link = 0; LoL->uppermem_root = 0xffff; - UmbState = UMBwanted ? 2 : 0; + UmbState = UMBwanted; } /* Check if HMA is available straight away */ - if (HMAState == HMA_REQ && MoveKernelToHMA()) - { - HMAState = HMA_DONE; - } + if (HMAwanted == HMA_REQ) + HMAState = MoveKernelToHMA() ? HMA_DONE : HMA_REQ; } -STATIC VOID DosData(BYTE * pLine) +/* Format: DOSDATA [=] UMB */ +STATIC void DosData(PCStr p) { - pLine = GetStringArg(pLine, szBuf); - strupr(szBuf); - - if (memcmp(szBuf, "UMB", 3) == 0) + if (!strcasediff(p, "UMB")) Config.cfgDosDataUmb = TRUE; + else + CfgFailure(p); } -STATIC VOID CfgSwitchar(BYTE * pLine) +/* Format: SWITCHAR [=] character */ +STATIC void CfgSwitchar(PCStr p) { - /* Format: SWITCHAR = character */ - - GetStringArg(pLine, szBuf); - init_switchar(*szBuf); + if (*p == '\0' || p[1]) + { + /* no character or garbage at line end */ + CfgFailure(p); + return; + } + init_switchar(*p); } -STATIC VOID CfgSwitches(BYTE * pLine) +/* Format: SWITCHES [=] { /K | /N | /F | /E[[:]nnn] } */ +STATIC void CfgSwitches(PCStr p) { - pLine = skipwh(pLine); - if (*pLine == '=') - { - pLine = skipwh(pLine + 1); - } - while (*pLine) + do { - if (*pLine == '/') { - pLine++; - switch(toupper(*pLine)) { + if (*p != '/') + { + if (nPass) + CfgFailure(p); + return; + } + switch(toupper(*++p)) + { case 'K': - if (commands[0].pass == 1) + if (nPass) kbdType = 0; /* force conv keyb */ + p++; break; case 'N': InitKernelConfig.SkipConfigSeconds = -1; + p++; break; case 'F': InitKernelConfig.SkipConfigSeconds = 0; + p++; break; case 'E': /* /E[[:]nnnn] Set the desired EBDA amount to move in bytes */ - { /* Note that if there is no EBDA, this will have no effect */ - int n = 0; - if (*++pLine == ':') - pLine++; /* skip optional separator */ - if (!isnum(*pLine)) - { - pLine--; - break; - } - pLine = GetNumArg(pLine, &n) - 1; + /* Note that if there is no EBDA, this will have no effect */ + if (*++p == ':') + p++; /* skip optional separator */ + if (isdigit(*p)) + { + p = GetNumArg(p); + if (p == NULL) + return; /* allowed values: [48..1024] bytes, multiples of 16 * e.g. AwardBIOS: 48, AMIBIOS: 1024 * (Phoenix, MRBIOS, Unicore = ????) */ - if (n == -1) - { - Config.ebda2move = 0xffff; - break; - } - else if (n >= 48 && n <= 1024) - { - Config.ebda2move = (n + 15) & 0xfff0; - break; - } - /* else fall through (failure) */ + if (nPass) + Config.ebda2move = numarg; } + break; default: - CfgFailure(pLine); - } - } else { - CfgFailure(pLine); - } - pLine = skipwh(pLine+1); - } - commands[0].pass = 1; + if (nPass) + CfgFailure(p); + return; + } /* switch */ + p = skipwh(p); + } while (*p); } -STATIC VOID Fcbs(BYTE * pLine) +/* Format: FCBS [=] totalFcbs [, protectedFcbs] */ +STATIC void Fcbs(PCStr p) { - /* Format: FCBS = totalFcbs [,protectedFcbs] */ - COUNT fcbs; - - if ((pLine = GetNumArg(pLine, &fcbs)) == 0) - return; - Config.cfgFcbs = fcbs; - - pLine = skipwh(pLine); - - if (*pLine == ',') + if (GetNumArg2(p, Config.cfgProtFcbs)) { - GetNumArg(++pLine, &fcbs); - Config.cfgProtFcbs = fcbs; + UBYTE fcbs = (UBYTE)numarg1, prot = (UBYTE)numarg; + Config.cfgFcbs = fcbs; + if (prot > fcbs) + prot = fcbs; + Config.cfgProtFcbs = prot; } - - if (Config.cfgProtFcbs > Config.cfgFcbs) - Config.cfgProtFcbs = Config.cfgFcbs; } /* LoadCountryInfo(): @@ -1159,213 +1157,191 @@ STATIC VOID Fcbs(BYTE * pLine) */ #if 0 -STATIC BOOL LoadCountryInfo(char *filename, UWORD ctryCode, UWORD codePage) +STATIC void LoadCountryInfo(CStr filename, int ccode, int cpage) { - printf("Sorry, the COUNTRY= statement has been temporarily disabled\n"); + say("Sorry, the COUNTRY= statement has been temporarily disabled\n"); - UNREFERENCED_PARAMETER(codePage); - UNREFERENCED_PARAMETER(ctryCode); + UNREFERENCED_PARAMETER(cpage); + UNREFERENCED_PARAMETER(ccode); UNREFERENCED_PARAMETER(filename); return FALSE; -} +} #endif -STATIC VOID Country(BYTE * pLine) +/* Format: COUNTRY [=] countryCode [, [codePage] [, filename]] */ +STATIC void Country(PCStr p) { - /* Format: COUNTRY = countryCode, [codePage], filename */ - COUNT ctryCode; - COUNT codePage = NLS_DEFAULT; - char *filename = ""; - - if ((pLine = GetNumArg(pLine, &ctryCode)) == 0) - goto error; + int ccode; + /*PCStr filename = "";*/ + p = GetNumArg(p); + if (p == NULL) + return; - /* currently 'implemented' - COUNTRY=49 */ + ccode = numarg; + /* currently 'implemented' COUNTRY=nnn only */ #if 0 - pLine = skipwh(pLine); - if (*pLine == ',') + numarg = NLS_DEFAULT; + p = skipwh(p); + if (*p == ',') { - pLine = skipwh(pLine + 1); - - if (*pLine != ',') - if ((pLine = GetNumArg(pLine, &codePage)) == 0) - goto error; - - pLine = skipwh(pLine); - if (*pLine == ',') + p = skipwh(p + 1); + if (*p != ',') { - GetStringArg(++pLine, szBuf); - filename = szBuf; + p = GetNumArg(p); + if (p == NULL) + return; + p = skipwh(p); } - } -#endif - - if (!LoadCountryInfoHardCoded(filename, ctryCode, codePage)) - return; - -error: - CfgFailure(pLine); -} - -STATIC VOID Stacks(BYTE * pLine) -{ - COUNT stacks; - - /* Format: STACKS = stacks [, stackSize] */ - pLine = GetNumArg(pLine, &stacks); - Config.cfgStacks = stacks; - - pLine = skipwh(pLine); - - if (*pLine == ',') - { - GetNumArg(++pLine, &stacks); - Config.cfgStackSize = stacks; + if (*p == ',') + filename = p + 1; } - if (Config.cfgStacks) + if (*p && *p != ',') /* garbage at line end? */ { - if (Config.cfgStackSize < 32) - Config.cfgStackSize = 32; - if (Config.cfgStackSize > 512) - Config.cfgStackSize = 512; - if (Config.cfgStacks > 64) - Config.cfgStacks = 64; + CfgFailure(p); + return; } - Config.cfgStacksHigh = 0; -} +#endif -STATIC VOID StacksHigh(BYTE * pLine) -{ - Stacks(pLine); - Config.cfgStacksHigh = 1; + LoadCountryInfoHardCoded(/*filename*/"", ccode, /*numarg*/NLS_DEFAULT); } -STATIC VOID InitPgmHigh(BYTE * pLine) +/* Format: STACKS [=] stacks [, stackSize] */ +/* Format: STACKSHIGH [=] stacks [, stackSize] */ +static void _Stacks(PCStr p, UBYTE high) { - InitPgm(pLine); - Config.cfgP_0_startmode = 0x80; + if (GetNumArg2(p, Config.cfgStackSize)) + { + UBYTE stacks = (UBYTE)numarg1; + UWORD sz = numarg; + if (stacks > 64) + stacks = 64; + if (sz < 32) + sz = 32; + if (sz > 512) + sz = 512; + Config.cfgStacks = stacks; + Config.cfgStackSize = sz; + Config.cfgStacksHigh = high; + } } -STATIC VOID InitPgm(BYTE * pLine) -{ - static char init[NAMEMAX]; - static char inittail[NAMEMAX]; - - Config.cfgInit = init; - Config.cfgInitTail = inittail; - - /* Get the string argument that represents the new init pgm */ - pLine = GetStringArg(pLine, Config.cfgInit); - - /* Now take whatever tail is left and add it on as a single */ - /* string. */ - strcpy(Config.cfgInitTail, pLine); +STATIC void Stacks(PCStr p) { _Stacks(p, 0); } - /* and add a DOS new line just to be safe */ - strcat(Config.cfgInitTail, "\r\n"); +STATIC void StacksHigh(PCStr p) { _Stacks(p, 1); } +/* Format: SHELL [=] command */ +STATIC void CmdShell(PCStr p) +{ Config.cfgP_0_startmode = 0; + /* assume strlen(p)+1 <= sizeof Config.cfgShell */ + strcpy(Config.cfgShell, p); } -STATIC VOID CfgBreak(BYTE * pLine) +/* Format: SHELLHIGH [=] command */ +STATIC void CmdShellHigh(PCStr p) { - /* Format: BREAK = (ON | OFF) */ - GetStringArg(pLine, szBuf); - break_ena = strcaseequal(szBuf, "OFF") ? 0 : 1; + Config.cfgP_0_startmode = 0x80; + /* assume strlen(p)+1 <= sizeof Config.cfgShell */ + strcpy(Config.cfgShell, p); } -STATIC VOID Numlock(BYTE * pLine) +/* Format: BREAK [=] (ON | OFF) */ +STATIC void CfgBreak(PCStr p) { - /* Format: NUMLOCK = (ON | OFF) */ - BYTE FAR *keyflags = (BYTE FAR *) MK_FP(0x40, 0x17); - - GetStringArg(pLine, szBuf); - - *keyflags &= ~32; - if (!strcaseequal(szBuf, "OFF")) *keyflags |= 32; - keycheck(); + if (!strcasediff(p, "ON")) + break_ena = 1; + else if (!strcasediff(p, "OFF")) + break_ena = 0; + else + CfgFailure(p); } -STATIC VOID DeviceHigh(BYTE * pLine) +/* Format: NUMLOCK [=] (ON | OFF) */ +STATIC void Numlock(PCStr p) { - if (UmbState == 1) - { - if (LoadDevice(pLine, MK_FP(umb_start + UMB_top, 0), TRUE) == DE_NOMEM) - { - printf("Not enough free memory in UMB's: loading low\n"); - LoadDevice(pLine, lpTop, FALSE); - } - } + UBYTE FAR *keyflags = MK_PTR(UBYTE, 0, 0x417); + if (!strcasediff(p, "ON")) + *keyflags |= 32; + else if (!strcasediff(p, "OFF")) + *keyflags &= ~32; else { - printf("UMB's unavailable!\n"); - LoadDevice(pLine, lpTop, FALSE); + CfgFailure(p); + return; } + keycheck(); +} + +/* Format: DEVICEHIGH [=] command */ +STATIC void DeviceHigh(PCStr p) +{ + if (UmbState != UMB_DONE || /* UMB not initialized? */ + LoadDevice(p, MK_SEG_PTR(void, mcb_next(umb_base_start)), TRUE) == DE_NOMEM) + Device(p); } -STATIC void Device(BYTE * pLine) +/* Format: DEVICE [=] command */ +STATIC void Device(PCStr p) { - LoadDevice(pLine, lpTop, FALSE); + LoadDevice(p, lpTop, FALSE); } -STATIC BOOL LoadDevice(BYTE * pLine, char FAR *top, COUNT mode) +STATIC BOOL LoadDevice(PCStr p, VFP top, int mode) { - exec_blk eb; - struct dhdr FAR *dhp; - struct dhdr FAR *next_dhp; - BOOL result; - seg base, start; + int ret; + seg_t base = base_seg; + seg_t start = LoL->first_mcb; if (mode) { base = umb_base_seg; - start = umb_start; - } - else - { - base = base_seg; - start = LoL->first_mcb; + start = umb_base_start; } if (base == start) base++; base++; - + /* Get the device driver name */ - GetStringArg(pLine, szBuf); + { + PStr d = szBuf; + PCStr s = p; + for (; (UBYTE)*s > ' '; d++, s++) + *d = *s; + *d = '\0'; + } /* The driver is loaded at the top of allocated memory. */ /* The device driver is paragraph aligned. */ - eb.load.reloc = eb.load.load_seg = base; + { + exec_blk eb; + eb.load.reloc = eb.load.load_seg = base; #ifdef DEBUG - printf("Loading device driver %s at segment %04x\n", szBuf, base); + printf("Loading device driver %s at segment %04x\n", szBuf, base); #endif - if ((result = init_DosExec(3, &eb, szBuf)) != SUCCESS) - { - CfgFailure(pLine); - return result; + ret = init_DosExec(3, &eb, szBuf); + if (ret != SUCCESS) + { + CfgFailure(p); + return ret; + } } - strcpy(szBuf, pLine); + strcpy(szBuf, p); /* uppercase the device driver command */ - strupr(szBuf); + /* add \r\n to the command line */ + strcat(strupr(szBuf), " \r\n"); /* TE this fixes the loading of devices drivers with multiple devices in it. NUMEGA's SoftIce is such a beast */ - /* add \r\n to the command line */ - strcat(szBuf, " \r\n"); - - dhp = MK_FP(base, 0); - /* NOTE - Modification for multisegmented device drivers: */ /* In order to emulate the functionallity experienced with other */ /* DOS operating systems, the original 'top' end address is */ @@ -1373,44 +1349,37 @@ STATIC BOOL LoadDevice(BYTE * pLine, char FAR *top, COUNT mode) /* The updated end address is then used when issuing the next */ /* INIT request for the following device driver within the file */ - for (next_dhp = NULL; FP_OFF(next_dhp) != 0xffff && - (result = init_device(dhp, szBuf, mode, &top)) == SUCCESS; - dhp = next_dhp) { - next_dhp = MK_FP(FP_SEG(dhp), FP_OFF(dhp->dh_next)); - /* Link in device driver and save LoL->nul_dev pointer to next */ - dhp->dh_next = LoL->nul_dev.dh_next; - LoL->nul_dev.dh_next = dhp; + ofs_t next = 0; + do + { + struct dhdr FAR *dhp = MK_PTR(struct dhdr, base, next); + if ((ret = init_device(dhp, szBuf, mode, &top)) != SUCCESS) + break; + + next = FP_OFF(dhp->dh_next); + + /* Link in device driver and save LoL->nul_dev pointer to next */ + dhp->dh_next = LoL->nul_dev.dh_next; + LoL->nul_dev.dh_next = dhp; + } while (next != 0xffff); } - /* might have been the UMB driver or DOS=UMB */ - if (UmbState == 2) - umb_init(); + /* might have been the UMB driver -> try UMB initialization */ + umb_init(); - return result; + return ret; } -STATIC VOID CfgFailure(BYTE * pLine) +STATIC void CfgFailure(PCStr p) { - BYTE *pTmp = pLineStart; - - /* suppress multiple printing of same unrecognized lines */ - - if (nCfgLine < sizeof(ErrorAlreadyPrinted)*8) - { - if (ErrorAlreadyPrinted[nCfgLine/8] & (1 << (nCfgLine%8))) - return; - - ErrorAlreadyPrinted[nCfgLine/8] |= (1 << (nCfgLine%8)); - } - printf("CONFIG.SYS error in line %d\n", nCfgLine); - printf(">>>%s\n ", pTmp); - while (++pTmp != pLine) - printf(" "); - printf("^\n"); + printf("Error in %s line %d:\n" + "%s\n", configfile, nCfgLine, szLine); + gotoxy(p - szLine, screeny()); + say("^\n"); } -struct submcb +struct submcb { char type; unsigned short start; @@ -1419,21 +1388,19 @@ struct submcb char name[8]; }; -void FAR * KernelAllocPara(size_t nPara, char type, char *name, int mode) +void _seg * KernelAllocPara(size_t nPara, UBYTE type, CStr name, int mode) { - seg base, start; - struct submcb FAR *p; - - if (UmbState != 1) - mode = 0; + seg_t base, start; + struct submcb _seg *p; - if (mode) + if (mode && UmbState == UMB_DONE) { base = umb_base_seg; - start = umb_start; + start = umb_base_start; } else { + mode = 0; base = base_seg; start = LoL->first_mcb; } @@ -1443,21 +1410,21 @@ void FAR * KernelAllocPara(size_t nPara, char type, char *name, int mode) if (base == start) { - mcb FAR *p = para2far(base); - base++; - mcb_init(base, p->m_size - 1, p->m_type); - mumcb_init(FP_SEG(p), 0); + mcb _seg *p = MK_SEG_PTR(mcb, base); + mcb_init(++base, p->m_size, p->m_type); + mumcb_init(FP_SEG(p), 1); p->m_name[1] = 'D'; } nPara++; - mcb_init(base + nPara, para2far(base)->m_size - nPara, para2far(base)->m_type); - para2far(start)->m_size += nPara; + mcb_init(base + nPara, MK_SEG_PTR(mcb, base)->m_size - nPara + 1, + MK_SEG_PTR(mcb, base)->m_type); + MK_SEG_PTR(mcb, start)->m_size += nPara; - p = (struct submcb FAR *)para2far(base); + p = MK_SEG_PTR(struct submcb, base); p->type = type; p->start = FP_SEG(p)+1; - p->size = nPara-1; + p->size = nPara - 1; if (name) fmemcpy(p->name, name, 8); base += nPara; @@ -1465,24 +1432,22 @@ void FAR * KernelAllocPara(size_t nPara, char type, char *name, int mode) umb_base_seg = base; else base_seg = base; - return MK_FP(FP_SEG(p)+1, 0); + return MK_SEG_PTR(void, FP_SEG(p) + 1); } -void FAR * KernelAlloc(size_t nBytes, char type, int mode) +void _seg * KernelAlloc(size_t nBytes, UBYTE type, int mode) { - void FAR *p; - size_t nPara = (nBytes + 15)/16; + void _seg *p; + size_t nPara = (nBytes + 15) / 16; if (LoL->first_mcb == 0) { /* prealloc */ - lpTop = MK_FP(FP_SEG(lpTop) - nPara, FP_OFF(lpTop)); - return AlignParagraph(lpTop); - } - else - { - p = KernelAllocPara(nPara, type, NULL, mode); + /* note: lpTop is already para-aligned */ + return alignNextPara(lpTop = MK_FP(FP_SEG(lpTop) - nPara, FP_OFF(lpTop))); } + + p = KernelAllocPara(nPara, type, NULL, mode); fmemset(p, 0, nBytes); return p; } @@ -1498,90 +1463,88 @@ STATIC BYTE FAR * KernelAllocDma(WORD bytes, char type) } #endif -STATIC void FAR * AlignParagraph(VOID FAR * lpPtr) +void _seg * alignNextPara(CVFP p) { - UWORD uSegVal; - /* First, convert the segmented pointer to linear address */ - uSegVal = FP_SEG(lpPtr); - uSegVal += (FP_OFF(lpPtr) + 0xf) >> 4; - if (FP_OFF(lpPtr) > 0xfff0) - uSegVal += 0x1000; /* handle overflow */ + seg_t seg = FP_OFF(p); + if (seg) + seg = (seg - 1) / 16 + 1; + seg += FP_SEG(p); - /* and return an adddress adjusted to the nearest paragraph */ - /* boundary. */ - return MK_FP(uSegVal, 0); + /* return an address adjusted to the nearest paragraph boundary */ + return MK_SEG_PTR(void, seg); } #endif -STATIC int iswh(unsigned char c) +STATIC PCStr skipwh(PCStr s) { - return (c == '\r' || c == '\n' || c == '\t' || c == ' '); + s--; + do + s++; + while (*s == ' ' || *s == '\t'); + return s; } -STATIC BYTE * skipwh(BYTE * s) +STATIC PCStr scanword(PCStr s, PStr d) { - while (iswh(*s)) - ++s; + s = skipwh(s); + while (*s >= 'a' && *s <= 'z' || + *s >= 'A' && *s <= 'Z') + *d++ = *s++; + *d = '\0'; return s; } -STATIC BYTE * scan(BYTE * s, BYTE * d) +STATIC PCStr scanverb(PCStr s, PStr d) { - askThisSingleCommand = FALSE; - DontAskThisSingleCommand = FALSE; + askCommand &= ~(ASK_ASK | ASK_NOASK); + line_choices = 0xffff; /* statement in all menus */ - s = skipwh(s); + for (;; s++) + { + s = skipwh(s); - MenuLine = 0; + if (*s == '!') /* "!dos" ? */ + askCommand |= ASK_NOASK; - /* does the line start with "123?" */ + else if (*s == '?') /* "?device" ? */ + askCommand |= ASK_ASK; - if (isnum(*s)) - { - unsigned numbers = 0; - for ( ; isnum(*s); s++) - numbers |= 1 << (*s -'0'); - - if (*s == '?') + else { - MenuLine = numbers; - Menus |= numbers; - s = skipwh(s+1); - } - } + UBYTE ch = *s - (UBYTE)'0'; + if (ch <= 9) /* "123?device" ? */ + { + PCStr p = s; + unsigned digits = 0; + do + { + digits |= 1 << ch; + ch = *++p - (UBYTE)'0'; + } while (ch <= 9); - - /* !dos=high,umb ?? */ - if (*s == '!') - { - DontAskThisSingleCommand = TRUE; - s = skipwh(s+1); - } + if (*p != '?') + break; + + s = p; + line_choices = digits; + all_choices |= digits; + } + else + break; + } /* else */ + } /* for */ - if (*s == ';') + s = scanword(s, d); + + if (*s == '?') /* "device?" ? */ { - /* semicolon is a synonym for rem */ - *d++ = *s++; + askCommand |= ASK_ASK; + s++; } - else - while (*s && !iswh(*s) && *s != '=') - { - if (*s == '?') - askThisSingleCommand = TRUE; - else - *d++ = *s; - s++; - } - *d = '\0'; return s; } -STATIC BOOL isnum(char ch) -{ - return (ch >= '0' && ch <= '9'); -} - /* Yet another change for true portability (PJV) */ STATIC char toupper(char c) { @@ -1591,31 +1554,36 @@ STATIC char toupper(char c) } /* Convert string s to uppercase */ -STATIC VOID strupr(char *s) +static PStr strupr(PStr s) { - while (*s) { - *s = toupper(*s); - s++; + PStr d = s; + for (;; d++) + { + char ch = *d; + if (ch == '\0') + break; + *d = toupper(ch); } + return s; } /* The following code is 8086 dependant */ #if 1 /* ifdef KERNEL */ -STATIC VOID mcb_init_copy(UCOUNT seg, UWORD size, mcb *near_mcb) +STATIC void mcb_init_copy(seg_t seg, size_t size, mcb *near_mcb) { - near_mcb->m_size = size; - fmemcpy(MK_FP(seg, 0), near_mcb, sizeof(mcb)); + near_mcb->m_size = size - 1; + fmemcpy(MK_SEG_PTR(mcb, seg), near_mcb, sizeof(mcb)); } -STATIC VOID mcb_init(UCOUNT seg, UWORD size, BYTE type) +STATIC void mcb_init(seg_t seg, size_t size, BYTE type) { static mcb near_mcb BSS_INIT({0}); near_mcb.m_type = type; mcb_init_copy(seg, size, &near_mcb); } -STATIC VOID mumcb_init(UCOUNT seg, UWORD size) +STATIC void mumcb_init(seg_t seg, size_t size) { static mcb near_mcb = { MCB_NORMAL, @@ -1627,25 +1595,27 @@ STATIC VOID mumcb_init(UCOUNT seg, UWORD size) } #endif -char *strcat(register char * d, register const char * s) +static PStr strcat(PStr d, PCStr s) { strcpy(d + strlen(d), s); return d; } /* compare two ASCII strings ignoring case */ -STATIC char strcaseequal(const char * d, const char * s) +STATIC char strcasediff(PCStr d, PCStr s) { - char ch; - while ((ch = toupper(*s++)) == toupper(*d++)) - if (ch == '\0') - return 1; - return 0; + while (toupper(*s) == toupper(*d)) + { + if (*s == '\0') + return 0; + s++, d++; + } + return 1; } /* moved from BLOCKIO.C here. - that saves some relocation problems + that saves some relocation problems */ STATIC void config_init_buffers(int wantedbuffers) @@ -1653,29 +1623,27 @@ STATIC void config_init_buffers(int wantedbuffers) struct buffer FAR *pbuffer; unsigned buffers = 0; - /* fill HMA with buffers if BUFFERS count >=0 and DOS in HMA */ + /* fill HMA with buffers if BUFFERS count >=0 and DOS in HMA */ if (wantedbuffers < 0) wantedbuffers = -wantedbuffers; else if (HMAState == HMA_DONE) buffers = (0xfff0 - HMAFree) / sizeof(struct buffer); - if (wantedbuffers < 6) /* min 6 buffers */ + if (wantedbuffers < 6) /* min 6 buffers */ wantedbuffers = 6; - if (wantedbuffers > 99) /* max 99 buffers */ + if (wantedbuffers > 99) /* max 99 buffers */ { printf("BUFFERS=%u not supported, reducing to 99\n", wantedbuffers); wantedbuffers = 99; } - if (wantedbuffers > buffers) /* more specified than available -> get em */ + if (buffers < wantedbuffers) /* not less than requested */ buffers = wantedbuffers; LoL->nbuffers = buffers; LoL->inforecptr = &LoL->firstbuf; { size_t bytes = sizeof(struct buffer) * buffers; - pbuffer = HMAalloc(bytes); - - if (pbuffer == NULL) + if ((pbuffer = HMAalloc(bytes)) == NULL) { pbuffer = KernelAlloc(bytes, 'B', 0); if (HMAState == HMA_DONE) @@ -1684,15 +1652,16 @@ STATIC void config_init_buffers(int wantedbuffers) else { LoL->bufloc = LOC_HMA; - /* space in HMA beyond requested buffers available as user space */ + + /* space in HMA beyond requested buffers available as user space */ firstAvailableBuf = pbuffer + wantedbuffers; } } LoL->deblock_buf = DiskTransferBuffer; LoL->firstbuf = pbuffer; - DebugPrintf(("init_buffers (size %u) at", sizeof(struct buffer))); - DebugPrintf((" (%p)", LoL->firstbuf)); + DebugPrintf(("init_buffers (size %u) at (%p)", + sizeof(struct buffer), pbuffer)); buffers--; pbuffer->b_prev = FP_OFF(pbuffer + buffers); @@ -1703,20 +1672,13 @@ STATIC void config_init_buffers(int wantedbuffers) pbuffer->b_next = FP_OFF(pbuffer + 1); pbuffer++; pbuffer->b_prev = FP_OFF(pbuffer - 1); - } - while (--i); + } while (--i); } pbuffer->b_next = FP_OFF(pbuffer - buffers); - /* now, we can have quite some buffers in HMA - -- up to 50 for KE38616. - so we fill the HMA with buffers - but not if the BUFFERS count is negative ;-) - */ - DebugPrintf((" done\n")); - if (FP_SEG(pbuffer) == 0xffff) + if (FP_SEG(pbuffer) == /*HMASEG*/0xFFFF) { buffers++; printf("Kernel: allocated %d Diskbuffers = %u Bytes in HMA\n", @@ -1740,267 +1702,239 @@ STATIC void config_init_fnodes(int f_nodes_cnt) } /* - Undocumented feature: - - ANYDOS + Undocumented feature: + Format: ANYDOS [=] will report to MSDOS programs just the version number they expect. be careful with it! */ - -STATIC VOID SetAnyDos(BYTE * pLine) +STATIC void SetAnyDos(PCStr p) { - UNREFERENCED_PARAMETER(pLine); + if (*p) /* garbage at line end? */ + { + CfgFailure(p); + return; + } ReturnAnyDosVersionExpected = TRUE; } -STATIC VOID CfgIgnore(BYTE * pLine) +/* Format: EECHO string */ +STATIC void CfgMenuEsc(PCStr p) { - UNREFERENCED_PARAMETER(pLine); + char ch; + do + { + ch = *p; p++; + if (ch == '\0') + ch = '\n'; + if (ch == '$') /* translate $ to ESC */ + ch = ESC; + printf("%c", ch); + } while (ch != '\n'); } /* - 'MENU'ing stuff - - although it's worse then MSDOS's , its better then nothing - + 'MENU'ing stuff + although it's worse then MSDOS's , its better then nothing + Menu selection bar struct: + x pos, y pos, string */ -STATIC void ClearScreen(unsigned char attr); -STATIC VOID CfgMenu(BYTE * pLine) +static struct MenuSelector { - int nLen; - BYTE *pNumber = pLine; + unsigned x, y; + UBYTE len; + char text[80]; +} MenuStruct[10] BSS_INIT({0}); - printf("%s\n",pLine); - if (MenuColor == -1) - return; +static unsigned nextMenuRow BSS_INIT(0); - pLine = skipwh(pLine); - - /* skip drawing characters in cp437, which is what we'll have - just after booting! */ - while ((unsigned char)*pLine >= 0xb0 && (unsigned char)*pLine < 0xe0) - pLine++; +/* Format: MENU string */ +/* Format: ECHO string */ +STATIC void CfgMenu(PCStr p) +{ + struct MenuSelector *menu; + UBYTE ch; + unsigned len; + int spaces; - pLine = skipwh(pLine); /* skip more whitespaces... */ + say2("%s\n", p); + nextMenuRow++; - /* now I'm expecting a number here if this is a menu-choice line. */ - if (isnum(pLine[0])) + /* find digit */ + for (len = 0;; p++, len++) { - struct MenuSelector *menu = &MenuStruct[pLine[0]-'0']; - - menu->x = (pLine-pNumber); /* xpos is at start of number */ - menu->y = nMenuLine; - /* copy menu text: */ - nLen = findend(pLine); /* length is until cr/lf, null or three spaces */ - - /* max 40 chars including nullterminator - (change struct at top of file if you want more...) */ - if (nLen > MENULINEMAX-1) - nLen = MENULINEMAX-1; - memcpy(menu->Text, pLine, nLen); - menu->Text[nLen] = 0; /* nullTerminate */ + ch = *p; + if (ch == '\0') + return; + ch -= (UBYTE)'0'; + if (ch <= 9) + break; } - nMenuLine++; + + menu = &MenuStruct[ch]; + menu->x = len; /* start position of digit */ + menu->y = nextMenuRow - 1; + + /* copy menu text (up to null or 10+ spaces) */ + len = 0; + do + { + ch = *p; + if (ch == '\0') + break; + menu->text[len] = ch; + p++, len++; + if (ch > ' ') + { + menu->len = len; + spaces = 11; + } + } while (--spaces && len < sizeof menu->text - 1); + menu->text[menu->len] = '\0'; } -STATIC VOID CfgMenuEsc(BYTE * pLine) +STATIC void SelectLine(unsigned i) { - BYTE * check; - for (check = pLine; check[0]; check++) - if (check[0] == '$') check[0] = 27; /* translate $ to ESC */ - printf("%s\n",pLine); + struct MenuSelector *menu = MenuStruct; + do + { + if (menu->len) + { + UBYTE attr = MenuColor; + if (i == 0) /* selected line? */ + /* swap colors and clear blinking attribute */ + attr = ((attr << 4) | (attr >> 4)) & 0x7f; + + /* redraw line */ + ClearScreenArea(attr, menu->x, menu->y, menu->len, 1); + say2("%s", menu->text); + } + menu++, i--; + } while (menu < ENDOF(MenuStruct)); } -STATIC VOID DoMenu(void) +static unsigned show_choices(unsigned choicey) { - iregs r; - int key = -1; - if (Menus == 0) - return; - - InitKernelConfig.SkipConfigSeconds = -1; - - if (MenuColor == -1) - Menus |= 1 << 0; /* '0' Menu always allowed */ + unsigned x; + UBYTE i; - nMenuLine+=2; /* use this to position "select menu" text (ypos): */ - - for (;;) + gotoxy(2, choicey); + say("Enter a choice: ["); + x = 19; /* =strlen(" Enter a choice: [") */ + i = 0; + do { - int i, j; - -RestartInput: - - if (MenuColor != -1) + if (testbit(all_choices, i)) { - SelectLine(MenuSelected); /* select current line. */ - - /* set new cursor position: */ - r.a.b.h = 0x02; - r.b.b.h = 0; - r.d.b.l = 3; - r.d.b.h = nMenuLine; - - init_call_intr(0x10, &r); /* set cursor pos */ + if (i < last_choice) + x++; + printf("%c", (UBYTE)'0' + i); } + i++; + } while (i <= 9); + say("]"); + return x; +} - printf("Select from Menu ["); - - for (i = 0, j = 1; i <= 9; i++, j<<=1) - if (Menus & j) - printf("%c", '0' + i); - printf("], or press [ENTER]"); - - if (MenuColor != -1) - printf(" (Selection=%d) ", MenuSelected); +STATIC VOID DoMenu(void) +{ + unsigned choicey; + say("\n\n\n"); /* make sure there are 3 free lines */ + choicey = screeny() - 2; - if (MenuTimeout >= 0) - printf("- %d \b", MenuTimeout); - else - printf(" \b\b\b\b\b"); + gotoxy(0, screenbottom()); + say2("F5=Bypass startup files F8=Confirm each line of %s/AUTOEXEC.BAT", + configfile); - if (MenuColor != -1) - printf("\r\n\n "); - else - printf(" -"); + for (;;) + { + unsigned key; + UBYTE c; - printf(" Singlestepping (F8) is: %s \r", singleStep ? "ON " : "OFF"); + gotoxy(75, screenbottom()); + say(askCommand & ASK_TRACE ? "[Y]" : "[N]"); - key = GetBiosKey(MenuTimeout >= 0 ? 1 : -1); + if (MenuColor && nextMenuRow + 1 == choicey) + SelectLine(last_choice); /* invert color of selected line */ - if (key == -1) /* timeout, take default */ + if (MenuTimeout >= 0) { - if (MenuTimeout > 0) + show_choices(choicey); + printf(" Time remainig: %d ", MenuTimeout); + + gotoxy(show_choices(choicey), choicey); + key = GetBiosKey(1); /* poll keyboard 1 second */ + if (key == 0) { + if (MenuTimeout == 0) + break; /* timeout, take default */ MenuTimeout--; - goto RestartInput; + continue; } - break; - } - else + MenuTimeout = -1; + clearrow(); /* clear "Time remaining" */ + } - if (key == 0x3f00) /* F5 */ + gotoxy(show_choices(choicey), choicey); + key = GetBiosKey(-1); /* remove key from buffer */ + + if (key == K_F5) /* F5 */ { - SkipAllConfig = TRUE; + askCommand |= ASK_SKIPALL; break; } - if (key == 0x4200) /* F8 */ - { - singleStep = !singleStep; - } - else if(key == 0x4800 && MenuColor != -1) /* arrow up */ - { - if(MenuSelected>=1 && (Menus & (1 << (MenuSelected-1))) ) - { - MenuSelected--; - } - } - else if(key == 0x5000 && MenuColor != -1) /* arrow down */ - { - if(MenuSelected 0 && !testbit(all_choices, --c)); + + else if (key == K_Down || key == K_Right) + while (c < 9 && !testbit(all_choices, ++c)); - if (isnum(key) && (Menus & (1 << (key - '0')))) + else { - MenuSelected = key - '0'; - break; + unsigned k = key; /* hint for compiler optimizer */ + c = (UBYTE)k; + if (c == '\r') /* CR - use current choice */ + break; + c -= (UBYTE)'0'; } - } - printf("\n"); - /* export the current selected config menu */ - sprintf(envp, "CONFIG=%c", MenuSelected+'0'); - envp += 9; - if (MenuColor != -1) - ClearScreen(0x7); + if (testbit(all_choices, c)) + last_choice = c; + } /* for */ + + gotoxy(0, screenbottom()); + clearrow(); /* clear hint line at bottom */ + gotoxy(0, choicey + 2); } -STATIC VOID CfgMenuDefault(BYTE * pLine) +/* Format: MENUDEFAULT [=] menu [, waitsecs] */ +STATIC void CfgMenuDefault(PCStr p) { - COUNT num = 0; - - pLine = skipwh(pLine); - - if ('=' != *pLine) - { - CfgFailure(pLine); - return; - } - pLine = skipwh(pLine + 1); - - /* Format: STACKS = stacks [, stackSize] */ - pLine = GetNumArg(pLine, &num); - MenuSelected = num; - pLine = skipwh(pLine); - - if (*pLine == ',') + if (GetNumArg2(p, MenuTimeout)) { - GetNumArg(++pLine, &MenuTimeout); + last_choice = numarg1; + /*if (last_choice > 10) + last_choice = 10;*/ + MenuTimeout = numarg; } } -STATIC void ClearScreen(unsigned char attr) +/* Format: MENUCOLOR [=] foreground [, background] */ +STATIC void CfgMenuColor(PCStr p) { - /* scroll down (newlines): */ - iregs r; - unsigned char rows; - - /* clear */ - r.a.x = 0x0600; - r.b.b.h = attr; - r.c.x = 0; - r.d.b.l = peekb(0x40, 0x4a) - 1; /* columns */ - rows = peekb(0x40, 0x84); - if (rows == 0) rows = 24; - r.d.b.h = rows; - init_call_intr(0x10, &r); - - /* move cursor to pos 0,0: */ - r.a.b.h = 0x02; /* set cursorpos */ - r.b.b.h = 0; /* displaypage: */ - r.d.x = 0; /* pos 0,0 */ - init_call_intr(0x10, &r); - MenuColor = attr; -} - -/** - MENUCOLOR[=] fg[, bg] -*/ -STATIC void CfgMenuColor(BYTE * pLine) -{ - int num = 0; - unsigned char fg, bg = 0; - - pLine = skipwh(pLine); - - if ('=' == *pLine) - pLine = skipwh(pLine + 1); - - pLine = GetNumArg(pLine, &num); - if (pLine == 0) - return; - fg = (unsigned char)num; - - pLine = skipwh(pLine); - - if (*pLine == ',') + if (GetNumArg2(p, 0)) { - pLine = GetNumArg(skipwh(pLine+1), &num); - if (pLine == 0) - return; - bg = (unsigned char)num; + UBYTE attr = (UBYTE)((numarg << 4) | numarg1); + if (attr == 0) + attr = 0x07; /* white on black */ + MenuColor = attr; } - ClearScreen((bg << 4) | fg); } /********************************************************************************* @@ -2010,606 +1944,231 @@ STATIC void CfgMenuColor(BYTE * pLine) *********************************************************************************/ #define _DATE_MDY 0 /* mm/dd/yy */ -#define _DATE_DMY 1 /* dd.mm.yy */ -#define _DATE_YMD 2 /* yy/mm/dd */ +#define _DATE_DMY 1 /* dd.mm.yy */ +#define _DATE_YMD 2 /* yy/mm/dd */ #define _TIME_12 0 #define _TIME_24 1 struct CountrySpecificInfo specificCountriesSupported[] = { - - /* US */ { - 1, /* = W1 W437 # Country ID & Codepage */ - 437, - _DATE_MDY, /* Date format: 0/1/2: U.S.A./Europe/Japan */ - "$", /* '$' ,'EUR' */ - ",", /* ',' # Thousand's separator */ - ".", /* '.' # Decimal point */ - "/", /* '-' DateSeparator */ - ":", /* ':' TimeSeparator */ - 0, /* = 0 # Currency format (bit array) */ - 2, /* = 2 # Currency precision */ - _TIME_12 /* = 0 # time format: 0/1: 12/24 houres */ - } - - /* Canadian French */ ,{ - 2, /* = W1 W437 # Country ID & Codepage */ - 863, - _DATE_YMD, /* Date format: 0/1/2: U.S.A./Europe/Japan */ - "$", /* '$' ,'EUR' */ - ",", /* ',' # Thousand's separator */ - ".", /* '.' # Decimal point */ - "-", /* '-' DateSeparator */ - ":", /* ':' TimeSeparator */ - 0, /* = 0 # Currency format (bit array) */ - 2, /* = 2 # Currency precision */ - _TIME_24 /* = 0 # time format: 0/1: 12/24 houres */ - } - - /* Latin America */ ,{ - 3, /* = W1 W437 # Country ID & Codepage */ - 850, - _DATE_MDY, /* Date format: 0/1/2: U.S.A./Europe/Japan */ - "$", /* '$' ,'EUR' */ - ",", /* ',' # Thousand's separator */ - ".", /* '.' # Decimal point */ - "/", /* '-' DateSeparator */ - ":", /* ':' TimeSeparator */ - 0, /* = 0 # Currency format (bit array) */ - 2, /* = 2 # Currency precision */ - _TIME_12 /* = 0 # time format: 0/1: 12/24 houres */ - } - - /* Russia - by arkady */ ,{ - 7, /* = W1 W437 # Country ID & Codepage */ - 866, - _DATE_DMY, /* Date format: 0/1/2: U.S.A./Europe/Japan */ - "RUB", /* '$' ,'EUR' */ - /* should be "\xE0", but as no codepage - support exists (yet), better to leave it as 'Rubels' - */ - " ", /* ',' # Thousand's separator */ - ",", /* '.' # Decimal point */ - ".", /* '-' DateSeparator */ - ":", /* ':' TimeSeparator */ - 3, /* Currency format : currency follows, after blank */ - 2, /* = 2 # Currency precision */ - _TIME_24 /* = 0 # time format: 0/1: 12/24 houres */ - } - - /* DUTCH */ ,{ - 31, /* = W1 W437 # Country ID & Codepage */ - 850, - _DATE_DMY, /* Date format: 0/1/2: U.S.A./Europe/Japan */ - "EUR", /* '$' ,'EUR' */ - ".", /* ',' # Thousand's separator */ - ",", /* '.' # Decimal point */ - "-", /* '-' DateSeparator */ - ":", /* ':' TimeSeparator */ - 0, /* = 0 # Currency format (bit array) */ - 2, /* = 2 # Currency precision */ - _TIME_24 /* = 0 # time format: 0/1: 12/24 houres */ - } - - /* Belgium */ ,{ - 32, /* = W1 W437 # Country ID & Codepage */ - 850, - _DATE_DMY, /* Date format: 0/1/2: U.S.A./Europe/Japan */ - "EUR", /* '$' ,'EUR' */ - ".", /* ',' # Thousand's separator */ - ",", /* '.' # Decimal point */ - "-", /* '-' DateSeparator */ - ":", /* ':' TimeSeparator */ - 0, /* = 0 # Currency format (bit array) */ - 2, /* = 2 # Currency precision */ - _TIME_24 /* = 0 # time format: 0/1: 12/24 houres */ - } - - /* France */ ,{ - 33, /* = W1 W437 # Country ID & Codepage */ - 850, - _DATE_DMY, /* Date format: 0/1/2: U.S.A./Europe/Japan */ - "EUR", /* '$' ,'EUR' */ - ".", /* ',' # Thousand's separator */ - ",", /* '.' # Decimal point */ - "-", /* '-' DateSeparator */ - ":", /* ':' TimeSeparator */ - 0, /* = 0 # Currency format (bit array) */ - 2, /* = 2 # Currency precision */ - _TIME_24 /* = 0 # time format: 0/1: 12/24 houres */ - } - - /* Spain */ ,{ - 33, /* = W1 W437 # Country ID & Codepage */ - 850, - _DATE_DMY, /* Date format: 0/1/2: U.S.A./Europe/Japan */ - "EUR", /* '$' ,'EUR' */ - ".", /* ',' # Thousand's separator */ - "'", /* Decimal point - by aitor */ - "-", /* '-' DateSeparator */ - ":", /* ':' TimeSeparator */ - 0, /* = 0 # Currency format (bit array) */ - 2, /* = 2 # Currency precision */ - _TIME_24 /* = 0 # time format: 0/1: 12/24 houres */ - } - - /* Hungary */ ,{ - 36, /* = W1 W437 # Country ID & Codepage */ - 850, - _DATE_DMY, /* Date format: 0/1/2: U.S.A./Europe/Japan */ - "$HU", /* '$' ,'EUR' */ - ".", /* ',' # Thousand's separator */ - ",", /* '.' # Decimal point */ - "-", /* '-' DateSeparator */ - ":", /* ':' TimeSeparator */ - 0, /* = 0 # Currency format (bit array) */ - 2, /* = 2 # Currency precision */ - _TIME_24 /* = 0 # time format: 0/1: 12/24 houres */ - } - - /* Yugoslavia */ ,{ - 38, /* = W1 W437 # Country ID & Codepage */ - 850, - _DATE_DMY, /* Date format: 0/1/2: U.S.A./Europe/Japan */ - "$YU", /* '$' ,'EUR' */ - ".", /* ',' # Thousand's separator */ - ",", /* '.' # Decimal point */ - "-", /* '-' DateSeparator */ - ":", /* ':' TimeSeparator */ - 0, /* = 0 # Currency format (bit array) */ - 2, /* = 2 # Currency precision */ - _TIME_24 /* = 0 # time format: 0/1: 12/24 houres */ - } - - /* Italy */ ,{ - 39, /* = W1 W437 # Country ID & Codepage */ - 850, - _DATE_DMY, /* Date format: 0/1/2: U.S.A./Europe/Japan */ - "EUR", /* '$' ,'EUR' */ - ".", /* ',' # Thousand's separator */ - ",", /* '.' # Decimal point */ - "-", /* '-' DateSeparator */ - ":", /* ':' TimeSeparator */ - 0, /* = 0 # Currency format (bit array) */ - 2, /* = 2 # Currency precision */ - _TIME_24 /* = 0 # time format: 0/1: 12/24 houres */ - } - - /* Switzerland */ ,{ - 41, /* = W1 W437 # Country ID & Codepage */ - 850, - _DATE_DMY, /* Date format: 0/1/2: U.S.A./Europe/Japan */ - "SF", /* '$' ,'EUR' */ - ".", /* ',' # Thousand's separator */ - ",", /* '.' # Decimal point */ - ".", /* '-' DateSeparator */ - ":", /* ':' TimeSeparator */ - 0, /* = 0 # Currency format (bit array) */ - 2, /* = 2 # Currency precision */ - _TIME_24 /* = 0 # time format: 0/1: 12/24 houres */ - } - - /* Czechoslovakia */ ,{ - 42, /* = W1 W437 # Country ID & Codepage */ - 850, - _DATE_YMD, /* Date format: 0/1/2: U.S.A./Europe/Japan */ - "$YU", /* '$' ,'EUR' */ - ".", /* ',' # Thousand's separator */ - ",", /* '.' # Decimal point */ - ".", /* '-' DateSeparator */ - ":", /* ':' TimeSeparator */ - 0, /* = 0 # Currency format (bit array) */ - 2, /* = 2 # Currency precision */ - _TIME_24 /* = 0 # time format: 0/1: 12/24 houres */ - } - - /* UK */ ,{ - 44, /* = W1 W437 # Country ID & Codepage */ - 850, - _DATE_DMY, /* Date format: 0/1/2: U.S.A./Europe/Japan */ - "\x9c", /* Pound sign */ - ".", /* ',' # Thousand's separator */ - ",", /* '.' # Decimal point */ - "/", /* '-' DateSeparator */ - ":", /* ':' TimeSeparator */ - 0, /* = 0 # Currency format (bit array) */ - 2, /* = 2 # Currency precision */ - _TIME_24 /* = 0 # time format: 0/1: 12/24 houres */ - } - - /* Denmark */ ,{ - 45, /* = W1 W437 # Country ID & Codepage */ - 850, - _DATE_DMY, /* Date format: 0/1/2: U.S.A./Europe/Japan */ - "DKK", /* */ - ".", /* ',' # Thousand's separator */ - ",", /* '.' # Decimal point */ - "-", /* '-' DateSeparator */ - ":", /* ':' TimeSeparator */ - 0, /* = 0 # Currency format (bit array) */ - 2, /* = 2 # Currency precision */ - _TIME_24 /* = 0 # time format: 0/1: 12/24 houres */ - } - /* Sweden */ ,{ - 46, /* = W1 W437 # Country ID & Codepage */ - 850, - _DATE_YMD, /* Date format: 0/1/2: U.S.A./Europe/Japan */ - "SEK", /* */ - ",", /* ',' # Thousand's separator */ - ".", /* '.' # Decimal point */ - "-", /* '-' DateSeparator */ - ":", /* ':' TimeSeparator */ - 0, /* = 0 # Currency format (bit array) */ - 2, /* = 2 # Currency precision */ - _TIME_24 /* = 0 # time format: 0/1: 12/24 houres */ - } - - /* Norway */ ,{ - 47, /* = W1 W437 # Country ID & Codepage */ - 850, - _DATE_DMY, /* Date format: 0/1/2: U.S.A./Europe/Japan */ - "NOK", /* */ - ",", /* ',' # Thousand's separator */ - ".", /* '.' # Decimal point */ - ".", /* '-' DateSeparator */ - ":", /* ':' TimeSeparator */ - 0, /* = 0 # Currency format (bit array) */ - 2, /* = 2 # Currency precision */ - _TIME_24 /* = 0 # time format: 0/1: 12/24 houres */ - } - - /* Poland */ ,{ - 48, /* = W1 W437 # Country ID & Codepage */ - 850, - _DATE_YMD, /* Date format: 0/1/2: U.S.A./Europe/Japan */ - "PLN", /* michael tyc: PLN means PoLish New zloty, I think) */ - ",", /* ',' # Thousand's separator */ - ".", /* '.' # Decimal point */ - ".", /* '-' DateSeparator */ - ":", /* ':' TimeSeparator */ - 0, /* = 0 # Currency format (bit array) */ - 2, /* = 2 # Currency precision */ - _TIME_24 /* = 0 # time format: 0/1: 12/24 houres */ - } - - /* GERMAN */ ,{ - 49, /* = W1 W437 # Country ID & Codepage */ - 850, - _DATE_DMY, /* Date format: 0/1/2: U.S.A./Europe/Japan */ - "EUR", /* '$' ,'EUR' */ - ".", /* ',' # Thousand's separator */ - ",", /* '.' # Decimal point */ - ".", /* '-' DateSeparator */ - ":", /* ':' TimeSeparator */ - 1, /* = 0 # Currency format (bit array) */ - 2, /* = 2 # Currency precision */ - _TIME_24 /* = 0 # time format: 0/1: 12/24 houres */ - } - - /* Argentina */ ,{ - 54, /* = W1 W437 # Country ID & Codepage */ - 850, - _DATE_DMY, /* Date format: 0/1/2: U.S.A./Europe/Japan */ - "$ar", /* '$' ,'EUR' */ - ".", /* ',' # Thousand's separator */ - ",", /* '.' # Decimal point */ - "/", /* '-' DateSeparator */ - ":", /* ':' TimeSeparator */ - 1, /* = 0 # Currency format (bit array) */ - 2, /* = 2 # Currency precision */ - _TIME_12 /* = 0 # time format: 0/1: 12/24 houres */ - } - - /* Brazil */ ,{ - 55, /* = W1 W437 # Country ID & Codepage */ - 850, - _DATE_DMY, /* Date format: 0/1/2: U.S.A./Europe/Japan */ - "$ar", /* '$' ,'EUR' */ - ".", /* ',' # Thousand's separator */ - ",", /* '.' # Decimal point */ - "/", /* '-' DateSeparator */ - ":", /* ':' TimeSeparator */ - 1, /* = 0 # Currency format (bit array) */ - 2, /* = 2 # Currency precision */ - _TIME_24 /* = 0 # time format: 0/1: 12/24 houres */ - } - - /* International English */ ,{ - 61, /* = W1 W437 # Country ID & Codepage */ - 850, - _DATE_MDY, /* Date format: 0/1/2: U.S.A./Europe/Japan */ - "$", /* '$' ,'EUR' */ - ".", /* ',' # Thousand's separator */ - ",", /* '.' # Decimal point */ - "/", /* '-' DateSeparator */ - ":", /* ':' TimeSeparator */ - 0, /* = 0 # Currency format (bit array) */ - 2, /* = 2 # Currency precision */ - _TIME_24 /* = 0 # time format: 0/1: 12/24 houres */ - } - - /* Japan - Yuki Mitsui */ ,{ - 81, /* = W1 W437 # Country ID & Codepage */ - 932, - _DATE_YMD, /* Date format: 0/1/2:U.S.A./Europe/Japan */ - "\x81\x8f", /* '$' ,'EUR' */ - ",", /* ',' # Thousand's separator */ - ".", /* '.' # Decimal point */ - "/", /* '-' DateSeparator */ - ":", /* ':' TimeSeparator */ - 0, /* = 0 # Currency format (bit array) */ - 2, /* = 2 # Currency precision */ - _TIME_12 /* = 0 # time format: 0/1: 12/24 houres - */ - } - - /* Portugal */ ,{ - 351, /* = W1 W437 # Country ID & Codepage */ - 850, - _DATE_DMY, /* Date format: 0/1/2: U.S.A./Europe/Japan */ - "EUR", /* '$' ,'EUR' */ - ".", /* ',' # Thousand's separator */ - ",", /* '.' # Decimal point */ - "-", /* '-' DateSeparator */ - ":", /* ':' TimeSeparator */ - 0, /* = 0 # Currency format (bit array) */ - 2, /* = 2 # Currency precision */ - _TIME_24 /* = 0 # time format: 0/1: 12/24 houres */ - } - - /* Finland - by wolf */ ,{ - 358, /* = W1 W437 # Country ID & Codepage */ - 850, - _DATE_DMY, /* Date format: 0/1/2: U.S.A./Europe/Japan */ - "EUR", /* '$' ,'EUR' */ - " ", /* ',' # Thousand's separator */ - ",", /* '.' # Decimal point */ - ".", /* '-' DateSeparator */ - ":", /* ':' TimeSeparator */ - 0x3, /* # Currency format (bit array) */ - 2, /* = 2 # Currency precision */ - _TIME_24 /* = 0 # time format: 0/1: 12/24 hours */ - } - /* Bulgaria - by Luchezar Georgiev */ ,{ - 359, /* = W1 W437 # Country ID & Codepage */ - 855, - _DATE_DMY, /* Date format: 0/1/2: U.S.A./Europe/Japan */ - "BGL", /* '$' ,'EUR' */ - " ", /* ',' # Thousand's separator */ - ",", /* '.' # Decimal point */ - ".", /* '-' DateSeparator */ - ":", /* ':' TimeSeparator */ - 3, /* # Currency format (bit array) */ - 2, /* = 2 # Currency precision */ - _TIME_24 /* = 0 # time format: 0/1: 12/24 hours */ - } - - /* Ukraine - by Oleg Deribas */ ,{ - 380, /* = W380 W848 # Country ID & Codepage */ - 848, - _DATE_DMY, /* Date format: 0/1/2: U.S.A./Europe/Japan */ - "UAH", /* Currency */ - " ", /* ' ' # Thousand's separator */ - ",", /* ',' # Decimal point */ - ".", /* '.' DateSeparator */ - ":", /* ':' TimeSeparator */ - 3, /* = 3 # Currency format (bit array) */ - 2, /* = 2 # Currency precision */ - _TIME_24 /* = 1 # time format: 0/1: 12/24 houres */ - } - -}; - - -/* contributors to above table: - - tom ehlert (GER) - bart oldeman (NL) - wolf (FIN) - Michael H.Tyc (POL) - Oleg Deribas (UKR) - Arkady Belousov (RUS) - Luchezar Georgiev (BUL) - Yuki Mitsui (JAP) - Aitor Santamar­a Merino (SP) -*/ +/* table rewritten by Bernd Blaauw +Country ID : international numbering +Codepage : codepage to use by default +Date format : M = Month, D = Day, Y = Year (4digit); 0=USA, 1=Europe, 2=Japan +Currency : $ = dollar, EUR = EURO (ALT-128), United Kingdom uses the pound sign +Thousands : separator for thousands (1,000,000 bytes; Dutch: 1.000.000 bytes) +Decimals : separator for decimals (2.5KB; Dutch: 2,5KB) +Datesep : Date separator (2/4/2004 or 2-4-2004 for example) +Timesep : usually ":" is used to separate hours, minutes and seconds +Currencyf : Currency format (bit array) +Currencyp : Currency precision +Timeformat : 0=12 hour format (AM/PM), 1=24 hour format (16:12 means 4:12 PM) + + ID CP Date currency 1000 0.1 date time C digit time Locale/Country contributor +------------------------------------------------------------------------------------------------------------- */ +{ 1,437,_DATE_MDY,"$" ,",",".", "/", ":", 0 , 2,_TIME_12}, /* United States */ +{ 2,863,_DATE_YMD,"$" ,",",".", "-", ":", 0 , 2,_TIME_24}, /* Canadian French */ +{ 3,850,_DATE_MDY,"$" ,",",".", "/", ":", 0 , 2,_TIME_12}, /* Latin America */ +{ 7,866,_DATE_DMY,"RUB" ," ",",", ".", ":", 3 , 2,_TIME_24}, /* Russia Arkady V. Belousov */ +{ 31,850,_DATE_DMY,"EUR" ,".",",", "-", ":", 0 , 2,_TIME_24}, /* Dutch Bart Oldeman */ +{ 32,850,_DATE_DMY,"EUR" ,".",",", "-", ":", 0 , 2,_TIME_24}, /* Belgium */ +{ 33,850,_DATE_DMY,"EUR" ,".",",", "-", ":", 0 , 2,_TIME_24}, /* France */ +{ 34,850,_DATE_DMY,"EUR" ,".","'", "-", ":", 0 , 2,_TIME_24}, /* Spain Aitor Santamaria Merino */ +{ 36,850,_DATE_DMY,"$HU" ,".",",", "-", ":", 0 , 2,_TIME_24}, /* Hungary */ +{ 38,850,_DATE_DMY,"$YU" ,".",",", "-", ":", 0 , 2,_TIME_24}, /* Yugoslavia */ +{ 39,850,_DATE_DMY,"EUR" ,".",",", "-", ":", 0 , 2,_TIME_24}, /* Italy */ +{ 41,850,_DATE_DMY,"SF" ,".",",", ".", ":", 0 , 2,_TIME_24}, /* Switserland */ +{ 42,850,_DATE_YMD,"$YU" ,".",",", ".", ":", 0 , 2,_TIME_24}, /* Czech & Slovakia */ +{ 44,850,_DATE_DMY,"\x9c" ,".",",", "/", ":", 0 , 2,_TIME_24}, /* United Kingdom */ +{ 45,850,_DATE_DMY,"DKK" ,".",",", "-", ":", 0 , 2,_TIME_24}, /* Denmark */ +{ 46,850,_DATE_YMD,"SEK" ,",",".", "-", ":", 0 , 2,_TIME_24}, /* Sweden */ +{ 47,850,_DATE_DMY,"NOK" ,",",".", ".", ":", 0 , 2,_TIME_24}, /* Norway */ +{ 48,850,_DATE_YMD,"PLN" ,",",".", ".", ":", 0 , 2,_TIME_24}, /* Poland Michael H.Tyc */ +{ 49,850,_DATE_DMY,"EUR" ,".",",", ".", ":", 1 , 2,_TIME_24}, /* German Tom Ehlert */ +{ 54,850,_DATE_DMY,"$ar" ,".",",", "/", ":", 1 , 2,_TIME_12}, /* Argentina */ +{ 55,850,_DATE_DMY,"$ar" ,".",",", "/", ":", 1 , 2,_TIME_24}, /* Brazil */ +{ 61,850,_DATE_MDY,"$" ,".",",", "/", ":", 0 , 2,_TIME_24}, /* Int. English */ +{ 81,932,_DATE_YMD,"\x81\x8f",",",".", "/", ":", 0 , 2,_TIME_12}, /* Japan Yuki Mitsui */ +{351,850,_DATE_DMY,"EUR" ,".",",", "-", ":", 0 , 2,_TIME_24}, /* Portugal */ +{358,850,_DATE_DMY,"EUR" ," ",",", ".", ":",0x3, 2,_TIME_24}, /* Finland wolf */ +{359,855,_DATE_DMY,"BGL" ," ",",", ".", ":", 3 , 2,_TIME_24}, /* Bulgaria Luchezar Georgiev */ +{380,848,_DATE_DMY,"UAH" ," ",",", ".", ":", 3 , 2,_TIME_24}, /* Ukraine Oleg Deribas */ +}; -STATIC int LoadCountryInfoHardCoded(char *filename, COUNT ctryCode, COUNT codePage) +STATIC void LoadCountryInfoHardCoded(CStr filename, int ccode, int cpage) { struct CountrySpecificInfo *country; - UNREFERENCED_PARAMETER(codePage); + UNREFERENCED_PARAMETER(cpage); UNREFERENCED_PARAMETER(filename); - /* printf("cntry: %u, CP%u, file=\"%s\"\n", ctryCode, codePage, filename); */ - - + /* printf("cntry: %u, CP%u, file=\"%s\"\n", ccode, cpage, filename); */ for (country = specificCountriesSupported; - country < specificCountriesSupported + LENGTH(specificCountriesSupported); + country < ENDOF(specificCountriesSupported); country++) { - if (country->CountryID == ctryCode) + if (country->CountryID == ccode) { int codepagesaved = nlsCountryInfoHardcoded.C.CodePage; - - fmemcpy(&nlsCountryInfoHardcoded.C.CountryID, + fmemcpy(&nlsCountryInfoHardcoded.C, country, min(nlsCountryInfoHardcoded.TableSize, sizeof *country)); - nlsCountryInfoHardcoded.C.CodePage = codepagesaved; - - return 0; + return; } } printf("could not find country info for country ID %u\n" - "current supported countries are ", ctryCode); + "current supported countries are ", ccode); for (country = specificCountriesSupported; - country < specificCountriesSupported + LENGTH(specificCountriesSupported); + country < ENDOF(specificCountriesSupported); country++) { printf("%u ", country->CountryID); } - printf("\n"); - - return 1; + say("\n"); } - /* **************************************************************** -** implementation of INSTALL=NANSI.COM /P /X /BLA +** implementation of INSTALL=NANSI.COM /P /X /BLA */ -int numInstallCmds BSS_INIT(0); -struct instCmds { - char buffer[128]; - int mode; -} InstallCommands[10] BSS_INIT({0}); - -#ifdef DEBUG -#define InstallPrintf(x) printf x -#else -#define InstallPrintf(x) -#endif - -STATIC VOID _CmdInstall(BYTE * pLine,int mode) +STATIC void free(seg_t seg) { - struct instCmds *cmd; - - InstallPrintf(("Installcmd %d:%s\n",numInstallCmds,pLine)); - - if (numInstallCmds > LENGTH(InstallCommands)) - { - printf("Too many Install commands given (%d max)\n",LENGTH(InstallCommands)); - CfgFailure(pLine); - return; - } - cmd = &InstallCommands[numInstallCmds]; - memcpy(cmd->buffer,pLine,127); - cmd->buffer[127] = 0; - cmd->mode = mode; - numInstallCmds++; -} -STATIC VOID CmdInstall(BYTE * pLine) -{ - _CmdInstall(pLine,0); + iregs r; + r.ES = seg; + r.AH = 0x49; /* free memory */ + init_call_intr(0x21, &r); } -STATIC VOID CmdInstallHigh(BYTE * pLine) + +/* set memory allocation strategy */ +STATIC void set_strategy(UBYTE strat) { - _CmdInstall(pLine,0x80); /* load high, if possible */ + iregs r; + r.BL = strat; + r.AX = 0x5801; + init_call_intr(0x21, &r); } -STATIC VOID InstallExec(struct instCmds *icmd) -{ - BYTE filename[128], *args, *d, *cmd = icmd->buffer; +/* Format: INSTALL [=] command */ +/* Format: INSTALLHIGH [=] command */ +STATIC void _CmdInstall(PCStr p, int mode) +{ + CommandTail args; + PStr pf; + unsigned len; exec_blk exb; - InstallPrintf(("installing %s\n",cmd)); - - cmd=skipwh(cmd); - - for (args = cmd, d = filename; ;args++,d++) + for (pf = szBuf;; p++, pf++) { - *d = *args; - if (*d <= 0x020 || *d == '/') + UBYTE ch = *p; + if (ch <= ' ' || ch == '/') break; + *pf = ch; } - *d = 0; - - args--; - *args = strlen(&args[1]); - args[*args+1] = '\r'; - args[*args+2] = 0; + *pf = '\0'; - exb.exec.env_seg = 0; - exb.exec.cmd_line = (CommandTail FAR *) args; - exb.exec.fcb_1 = exb.exec.fcb_2 = (fcb FAR *) 0xfffffffful; + len = strlen(p); + if (len > sizeof args.ctBuffer - 2) + len = sizeof args.ctBuffer - 2; /* trim too long line */ + args.ctCount = (UBYTE)len; + args.ctBuffer[len] = '\r'; + args.ctBuffer[len+1] = 0; + memcpy(args.ctBuffer, p, len); + set_strategy(mode); + exb.exec.env_seg = DOS_PSP + 8; + exb.exec.cmd_line = &args; + /*exb.exec.fcb_1 = exb.exec.fcb_2 = NULL;*/ /* unimportant */ - InstallPrintf(("cmd[%s] args [%u,%s]\n",filename,*args,args+1)); + DebugPrintf(("cmd[%s] args [%u,%s]\n", szBuf, args.ctCount, args.ctBuffer)); - if (init_DosExec(icmd->mode, &exb, filename) != SUCCESS) - { - CfgFailure(cmd); - } -} - -STATIC void free(seg segment) -{ - iregs r; - - r.a.b.h = 0x49; /* free memory */ - r.es = segment; - init_call_intr(0x21, &r); + if (init_DosExec(mode, &exb, szBuf) != SUCCESS) + CfgFailure(p); } -/* set memory allocation strategy */ -STATIC void set_strategy(unsigned char strat) -{ - iregs r; +STATIC void CmdInstall(PCStr p) { _CmdInstall(p, 0); } - r.a.x = 0x5801; - r.b.b.l = strat; - init_call_intr(0x21, &r); -} +STATIC void CmdInstallHigh(PCStr p) { _CmdInstall(p, 0x80); } VOID DoInstall(void) { - int i; - unsigned short installMemory; - struct instCmds *cmd; - - if (numInstallCmds == 0) - return; - - InstallPrintf(("Installing commands now\n")); + seg_t kernel; - /* grab memory for this install code - we KNOW, that we are executing somewhere at top of memory - we need to protect the INIT_CODE from other programs - that will be executing soon + /* grab memory for this install code: + we are executing somewhere at top of memory and need to protect + the INIT_CODE from other programs that will be executing soon */ set_strategy(LAST_FIT); - installMemory = allocmem(((unsigned)_init_end + ebda_size + 15) / 16); + kernel = allocmem(((unsigned)_init_end + ebda_size + 15) / 16); - InstallPrintf(("allocated memory at %x\n",installMemory)); + DebugPrintf(("Installing commands now (kernel at %X)\n", kernel)); + + DoConfig_(); - for (i = 0, cmd = InstallCommands; i < numInstallCmds; i++, cmd++) - { - InstallPrintf(("%d:%s\n",i,cmd->buffer)); - set_strategy(cmd->mode); - InstallExec(cmd); - } set_strategy(FIRST_FIT); - free(installMemory); - - InstallPrintf(("Done with installing commands\n")); - return; + free(kernel); + + DebugPrintf(("Done with installing commands\n")); } -STATIC VOID CmdSet(BYTE *pLine) +/* master_env copied over command line area in + DOS_PSP, thus its size limited to 128 bytes */ +static char master_env[128] BSS_INIT({0}); +static PStr envp = master_env; + +/* Format: SET var = string */ +STATIC void CmdSet(PCStr p) { - pLine = GetStringArg(pLine, szBuf); - pLine = skipwh(pLine); /* scan() stops at the equal sign or space */ - if (*pLine == '=') /* equal sign is required */ + PStr q; + p = skipwh(scanword(p, szBuf)); + if (*p != '=') /* equal sign is required */ { - int size; - strupr(szBuf); /* all environment variables must be uppercase */ - strcat(szBuf, "="); - pLine = skipwh(++pLine); - strcat(szBuf, pLine); /* append the variable value (may include spaces) */ - size = strlen(szBuf); - if (size < master_env + sizeof(master_env) - envp - 1) - { /* must end with two consequtive zeros */ - strcpy(envp, szBuf); - envp += size + 1; /* add next variables starting at the second zero */ + CfgFailure(p); + return; + } + + /* environment variables must be uppercase */ + strcat(strupr(szBuf), "="); + + { + PStr pm = master_env; /* find duplication */ + for (q = pm; pm < envp; q = pm) + { + PCStr v = szBuf; + while (*v == *pm) /* compare variables */ + v++, pm++; + while (*++pm); /* find end of definition */ + pm++; + if (*v == '\0') /* variable found? */ + { + while (pm < envp) + *q++ = *pm++; /* remove duplication */ + break; + } + } /* for */ + } + + p = skipwh(p + 1); + if (*p) /* add new definition? */ + { + size_t sz = strlen(strcat(szBuf, p)) + 1; + + /* environment ends by empty ASCIIZ (one null character) */ + if (sz >= master_env + sizeof master_env - q) + { + CfgFailure(p); + say("Out of environment space\n"); + return; } - else - printf("Master environment is full - can't add \"%s\"\n", szBuf); + strcpy(q, szBuf); + q += sz; } - else - printf("Invalid SET command: \"%s\"\n", szBuf); + + envp = q; + *q = '\0'; /* "add" empty ASCIIZ string */ + fmemcpy(MK_PTR(char, DOS_PSP + 8, 0), master_env, q + 1 - master_env); } diff --git a/kernel/config.h b/kernel/config.h index 50dff682..f9404115 100644 --- a/kernel/config.h +++ b/kernel/config.h @@ -29,26 +29,17 @@ struct config { /* Configuration variables */ UBYTE cfgDosDataUmb; - BYTE cfgBuffers; /* number of buffers in the system */ + BYTE cfgBuffers; /* number of buffers in the system */ UBYTE cfgFiles; /* number of available files */ UBYTE cfgFilesHigh; UBYTE cfgFcbs; /* number of available FCBs */ UBYTE cfgProtFcbs; /* number of protected FCBs */ - BYTE *cfgInit; /* init of command.com */ - BYTE *cfgInitTail; /* command.com's tail */ + char cfgShell[256]; /* SHELL= line */ UBYTE cfgLastdrive; /* last drive */ UBYTE cfgLastdriveHigh; - BYTE cfgStacks; /* number of stacks */ - BYTE cfgStacksHigh; + BYTE cfgStacks; /* number of stacks */ + BYTE cfgStacksHigh; UWORD cfgStackSize; /* stacks size for each stack */ - /* COUNTRY= - * In Pass #1 these information is collected and in PostConfig() - * the NLS package is loaded into memory. -- 2000/06/11 ska - */ - WORD cfgCSYS_cntry; /* country ID to be loaded */ - UWORD cfgCSYS_cp; /* requested codepage; NLS_DEFAULT if default */ - WORD cfgCSYS_memory; /* # of bytes required for the NLS pkg; 0 if none */ - VOID FAR *cfgCSYS_data; /* where the loaded data is for PostConfig() */ UBYTE cfgP_0_startmode; /* load command.com high or not */ unsigned ebda2move; /* value for switches=/E:nnnn */ }; diff --git a/kernel/dsk.c b/kernel/dsk.c index 96368dc5..39acd121 100644 --- a/kernel/dsk.c +++ b/kernel/dsk.c @@ -39,34 +39,33 @@ static BYTE *dskRcsId = #define DebugPrintf(x) #endif -/* #define STATIC */ - -BOOL ASMPASCAL fl_reset(WORD); -COUNT ASMPASCAL fl_diskchanged(WORD); - -COUNT ASMPASCAL fl_format(WORD, WORD, WORD, WORD, WORD, UBYTE FAR *); -COUNT ASMPASCAL fl_read(WORD, WORD, WORD, WORD, WORD, UBYTE FAR *); -COUNT ASMPASCAL fl_write(WORD, WORD, WORD, WORD, WORD, UBYTE FAR *); -COUNT ASMPASCAL fl_verify(WORD, WORD, WORD, WORD, WORD, UBYTE FAR *); -COUNT ASMPASCAL fl_setdisktype(WORD, WORD); -COUNT ASMPASCAL fl_setmediatype(WORD, WORD, WORD); -VOID ASMPASCAL fl_readkey(VOID); -extern COUNT ASMPASCAL fl_lba_ReadWrite(BYTE drive, WORD mode, - struct _bios_LBA_address_packet FAR - * dap_p); +void ASMPASCAL fl_readkey(void); +int ASMPASCAL fl_reset(UBYTE drive); +int ASMPASCAL fl_diskchanged(UBYTE drive); +int ASMPASCAL fl_setdisktype(UBYTE drive, WORD type); +int ASMPASCAL fl_setmediatype(UBYTE drive, WORD tracks, WORD sectors); +int ASMPASCAL fl_read (UBYTE drive, WORD, WORD, WORD, WORD, void FAR *); +int ASMPASCAL fl_write (UBYTE drive, WORD, WORD, WORD, WORD, void FAR *); +int ASMPASCAL fl_verify(UBYTE drive, WORD, WORD, WORD, WORD, void FAR *); +int ASMPASCAL fl_format(UBYTE drive, WORD, WORD, WORD, WORD, void FAR *); +int ASMPASCAL fl_lba_ReadWrite(UBYTE drive, WORD mode, + struct _bios_LBA_address_packet FAR *); #ifdef __WATCOMC__ +#pragma aux (pascal) fl_readkey modify exact [ax] #pragma aux (pascal) fl_reset modify exact [ax dx] #pragma aux (pascal) fl_diskchanged modify exact [ax dx] -#pragma aux (pascal) fl_setdisktype modify exact [ax bx dx] -#pragma aux (pascal) fl_readkey modify exact [ax] +#pragma aux (pascal) fl_setdisktype modify exact [ax dx bx] +#pragma aux (pascal) fl_setmediatype modify exact [ax cx dx bx es] +#pragma aux (pascal) fl_read modify exact [ax cx dx bx es] +#pragma aux (pascal) fl_write modify exact [ax cx dx bx es] +#pragma aux (pascal) fl_format modify exact [ax cx dx bx es] +#pragma aux (pascal) fl_verify modify exact [ax cx dx bx es] #pragma aux (pascal) fl_lba_ReadWrite modify exact [ax dx] #endif STATIC int LBA_Transfer(ddt * pddt, UWORD mode, VOID FAR * buffer, ULONG LBA_address, unsigned total, UWORD * transferred); -#define NENTRY 26 /* total size of dispatch table */ - #define LBA_READ 0x4200 #define LBA_WRITE 0x4300 UWORD LBA_WRITE_VERIFY = 0x4302; @@ -92,74 +91,64 @@ extern struct DynS ASM Dyn; /*TE - array access functions */ ddt *getddt(int dev) { - return &(((ddt *) Dyn.Buffer)[dev]); + return (ddt*)Dyn.Buffer + dev; } -STATIC VOID tmark(ddt *pddt) -{ - pddt->ddt_fh.ddt_lasttime = ReadPCClock(); -} +#define getddt0() ((ddt*)Dyn.Buffer) + +#define tmark(pddt) ((pddt)->ddt_fh.ddt_lasttime = ReadPCClock()) STATIC BOOL tdelay(ddt *pddt, ULONG ticks) { return ReadPCClock() - pddt->ddt_fh.ddt_lasttime >= ticks; } -#define N_PART 4 /* number of partitions per - table partition */ +#define N_PART 4 /* number of partitions per partition table */ #define PARTOFF 0x1be -#ifdef PROTO -typedef WORD dsk_proc(rqptr rq, ddt * pddt); -#else -typedef WORD dsk_proc(); -#endif +typedef WORD dsk_proc(rqptr, ddt*); STATIC dsk_proc mediachk, bldbpb, blockio, IoctlQueblk, Genblkdev, Getlogdev, Setlogdev, blk_Open, blk_Close, - blk_Media, blk_noerr, blk_nondr, blk_error; + blk_Media, blk_noerr, blk_nondr; -STATIC WORD getbpb(ddt * pddt); -#ifdef PROTO +STATIC WORD getbpb(ddt*); STATIC WORD dskerr(COUNT); -#else -STATIC WORD dskerr(); -#endif /* */ /* the function dispatch table */ /* */ -static dsk_proc * const dispatch[NENTRY] = +static dsk_proc * const dispatch [] = { - /* disk init is done in diskinit.c, so this should never be called */ - blk_error, /* Initialize */ - mediachk, /* Media Check */ - bldbpb, /* Build BPB */ - blk_error, /* Ioctl In */ - blockio, /* Input (Read) */ - blk_nondr, /* Non-destructive Read */ - blk_noerr, /* Input Status */ - blk_noerr, /* Input Flush */ - blockio, /* Output (Write) */ - blockio, /* Output with verify */ - blk_noerr, /* Output Status */ - blk_noerr, /* Output Flush */ - blk_error, /* Ioctl Out */ - blk_Open, /* Device Open */ - blk_Close, /* Device Close */ - blk_Media, /* Removable Media */ - blk_noerr, /* Output till busy */ - blk_error, /* undefined */ - blk_error, /* undefined */ - Genblkdev, /* Generic Ioctl Call */ - blk_error, /* undefined */ - blk_error, /* undefined */ - blk_error, /* undefined */ - Getlogdev, /* Get Logical Device */ - Setlogdev, /* Set Logical Device */ - IoctlQueblk /* Ioctl Query */ + /* disk init is done in initdisk.c, so this should never be called */ + NULL, /* 0x00 Initialize */ + mediachk, /* 0x01 Media Check */ + bldbpb, /* 0x02 Build BPB */ + NULL, /* 0x03 Ioctl In */ + blockio, /* 0x04 Input (Read) */ + blk_nondr, /* 0x05 Non-destructive Read */ + blk_noerr, /* 0x06 Input Status */ + blk_noerr, /* 0x07 Input Flush */ + blockio, /* 0x08 Output (Write) */ + blockio, /* 0x09 Output with verify */ + blk_noerr, /* 0x0A Output Status */ + blk_noerr, /* 0x0B Output Flush */ + NULL, /* 0x0C Ioctl Out */ + blk_Open, /* 0x0D Device Open */ + blk_Close, /* 0x0E Device Close */ + blk_Media, /* 0x0F Removable Media */ + blk_noerr, /* 0x10 Output till busy */ + NULL, /* 0x11 undefined */ + NULL, /* 0x12 undefined */ + Genblkdev, /* 0x13 Generic Ioctl Call */ + NULL, /* 0x14 undefined */ + NULL, /* 0x15 undefined */ + NULL, /* 0x16 undefined */ + Getlogdev, /* 0x17 Get Logical Device */ + Setlogdev, /* 0x18 Set Logical Device */ + IoctlQueblk /* 0x19 Ioctl Query */ }; #define hd(x) ((x) & DF_FIXED) @@ -168,61 +157,61 @@ static dsk_proc * const dispatch[NENTRY] = /* F U N C T I O N S --------------------------------------------------- */ /* ----------------------------------------------------------------------- */ -COUNT ASMCFUNC FAR blk_driver(rqptr rp) +int ASMCFUNC FAR blk_driver(rqptr rp) { - if (rp->r_unit >= blk_dev.dh_name[0] && rp->r_command != C_INIT) - return failure(E_UNIT); - if (rp->r_command > NENTRY) + if (rp->r_command >= LENGTH (dispatch)) + return failure(E_FAILURE); /* general failure */ { - return failure(E_FAILURE); /* general failure */ + dsk_proc *const proc = dispatch [rp->r_command]; + if (proc == NULL) + { + rp->r_count = 0; + return failure(E_FAILURE); /* general failure */ + } + if (rp->r_unit >= blk_dev.dh_name[0]) + return failure(E_UNIT); + return proc (rp, getddt(rp->r_unit)); } - else - return ((*dispatch[rp->r_command]) (rp, getddt(rp->r_unit))); } -STATIC char template_string[] = "Remove diskette in drive X:\n"; -#define DRIVE_POS (sizeof(template_string) - 4) +STATIC char template_string[] = + "\nInsert diskette for drive :: and press any key when ready\n\n"; +/* 012345678901234567890123456^ */ +#define DRIVE_POS 27 STATIC WORD play_dj(ddt * pddt) { + UBYTE i; + ddt *pddt2; + + if ((pddt->ddt_descflags & (DF_MULTLOG | DF_CURLOG)) != DF_MULTLOG) + return M_NOT_CHANGED; + /* play the DJ ... */ - if ((pddt->ddt_descflags & (DF_MULTLOG | DF_CURLOG)) == DF_MULTLOG) + pddt2 = getddt0() - 1; + i = blk_dev.dh_name[0] + 1; + do { - int i; - ddt *pddt2 = getddt(0); - for (i = 0; i < blk_dev.dh_name[0]; i++, pddt2++) - { - if (pddt->ddt_driveno == pddt2->ddt_driveno && - (pddt2->ddt_descflags & (DF_MULTLOG | DF_CURLOG)) == - (DF_MULTLOG | DF_CURLOG)) - break; - } - if (i == blk_dev.dh_name[0]) - { - put_string("Error in the DJ mechanism!\n"); /* should not happen! */ - } - else + pddt2++, i--; + if (i == 0) { - template_string[DRIVE_POS] = 'A' + pddt2->ddt_logdriveno; - put_string(template_string); - put_string("Insert"); - template_string[DRIVE_POS] = 'A' + pddt->ddt_logdriveno; - put_string(template_string + 6); - put_string("Press the any key to continue ... \n"); - fl_readkey(); - pddt2->ddt_descflags &= ~DF_CURLOG; - pddt->ddt_descflags |= DF_CURLOG; - pokeb(0, 0x504, pddt->ddt_logdriveno); + put_string("Error in the DJ mechanism!\n"); /* should not happen! */ + return M_CHANGED; } - return M_CHANGED; - } - return M_NOT_CHANGED; + } while (pddt->ddt_driveno != pddt2->ddt_driveno || + (~pddt2->ddt_descflags & (DF_MULTLOG | DF_CURLOG))); + + template_string[DRIVE_POS] = 'A' + pddt->ddt_logdriveno; + put_string(template_string); + fl_readkey(); + pddt2->ddt_descflags &= ~DF_CURLOG; + pddt->ddt_descflags |= DF_CURLOG; + pokeb(0, 0x504, pddt->ddt_logdriveno); + return M_CHANGED; } STATIC WORD diskchange(ddt * pddt) { - COUNT result; - /* if it's a hard drive, media never changes */ if (hd(pddt->ddt_descflags)) return M_NOT_CHANGED; @@ -232,15 +221,18 @@ STATIC WORD diskchange(ddt * pddt) if (pddt->ddt_descflags & DF_CHANGELINE) /* if we can detect a change ... */ { - if ((result = fl_diskchanged(pddt->ddt_driveno)) == 1) + int ret = fl_diskchanged(pddt->ddt_driveno); + if (ret == 1) /* check if it has changed... */ return M_CHANGED; - else if (result == 0) + if (ret == 0) return M_NOT_CHANGED; } /* can not detect or error... */ - return tdelay(pddt, 37ul) ? M_DONT_KNOW : M_NOT_CHANGED; + if (tdelay(pddt, 37)) + return M_DONT_KNOW; + return M_NOT_CHANGED; } STATIC WORD mediachk(rqptr rp, ddt * pddt) @@ -256,19 +248,15 @@ STATIC WORD mediachk(rqptr rp, ddt * pddt) pddt->ddt_descflags &= ~DF_DISKCHANGE; rp->r_mcretcode = M_DONT_KNOW; } - else + else if ((rp->r_mcretcode = diskchange(pddt)) == M_DONT_KNOW) { - rp->r_mcretcode = diskchange(pddt); - if (rp->r_mcretcode == M_DONT_KNOW) - { - /* don't know but can check serial number ... */ - ULONG serialno = pddt->ddt_serialno; - COUNT result = getbpb(pddt); - if (result != 0) - return (result); - if (serialno != pddt->ddt_serialno) - rp->r_mcretcode = M_CHANGED; - } + /* don't know but can check serial number ... */ + ULONG serialno = pddt->ddt_serialno; + int ret = getbpb(pddt); + if (ret) + return ret; + if (serialno != pddt->ddt_serialno) + rp->r_mcretcode = M_CHANGED; } return S_DONE; } @@ -276,13 +264,10 @@ STATIC WORD mediachk(rqptr rp, ddt * pddt) /* * Read Write Sector Zero or Hard Drive Dos Bpb */ -STATIC WORD RWzero(ddt * pddt, UWORD mode) +STATIC int RWzero(ddt * pddt, UWORD mode) { UWORD done; - - return LBA_Transfer(pddt, mode, - (UBYTE FAR *) & DiskTransferBuffer, - pddt->ddt_offset, 1, &done); + return LBA_Transfer(pddt, mode, DiskTransferBuffer, 0, 1, &done); } /* @@ -291,36 +276,32 @@ STATIC WORD RWzero(ddt * pddt, UWORD mode) */ STATIC WORD Getlogdev(rqptr rp, ddt * pddt) { - int i; - ddt *pddt2; - - if (!(pddt->ddt_descflags & DF_MULTLOG)) { - rp->r_unit = 0; - return S_DONE; - } - - pddt2 = getddt(0); - for (i = 0; i < blk_dev.dh_name[0]; i++, pddt2++) + UBYTE unit = 0; + if (pddt->ddt_descflags & DF_MULTLOG) { - if (pddt->ddt_driveno == pddt2->ddt_driveno && - (pddt2->ddt_descflags & (DF_MULTLOG | DF_CURLOG)) == - (DF_MULTLOG | DF_CURLOG)) - break; + ddt *pddt2 = getddt0() - 1; + do + pddt2++, unit++; + while (unit < blk_dev.dh_name[0] && + (pddt->ddt_driveno != pddt2->ddt_driveno || + (~pddt2->ddt_descflags & (DF_MULTLOG | DF_CURLOG)))); } - - rp->r_unit = i+1; + rp->r_unit = unit; return S_DONE; } STATIC WORD Setlogdev(rqptr rp, ddt * pddt) { - unsigned char unit = rp->r_unit; + UBYTE unit = rp->r_unit + 1; Getlogdev(rp, pddt); - if (rp->r_unit == 0) - return S_DONE; - getddt(rp->r_unit - 1)->ddt_descflags &= ~DF_CURLOG; - pddt->ddt_descflags |= DF_CURLOG; - rp->r_unit = unit + 1; + if (rp->r_unit) + { + getddt(rp->r_unit - 1)->ddt_descflags &= ~DF_CURLOG; + pddt->ddt_descflags |= DF_CURLOG; + /* UNDOCUMENTED: MS-DOS sets r_unit field both for */ + /* 0x17 (Getlogdev()) and 0x18 (Setlogdev()) functions. */ + rp->r_unit = unit; + } return S_DONE; } @@ -354,48 +335,42 @@ STATIC WORD blk_Media(rqptr rp, ddt * pddt) if (hd(pddt->ddt_descflags)) return S_BUSY | S_DONE; /* Hard Drive */ - else - return S_DONE; /* Floppy */ + return S_DONE; /* Floppy */ } STATIC WORD getbpb(ddt * pddt) { - ULONG count; - bpb *pbpbarray = &pddt->ddt_bpb; - unsigned secs_per_cyl; - WORD ret; - - /* pddt->ddt_descflags |= DF_NOACCESS; + /* pddt->ddt_descflags |= DF_NOACCESS; * disabled for now - problems with FORMAT ?? */ /* set drive to not accessible and changed */ if (diskchange(pddt) != M_NOT_CHANGED) pddt->ddt_descflags |= DF_DISKCHANGE; - ret = RWzero(pddt, LBA_READ); - if (ret != 0) - return (dskerr(ret)); - - pbpbarray->bpb_nbyte = getword(&DiskTransferBuffer[BT_BPB]); + { + int ret = RWzero(pddt, LBA_READ); + if (ret) + return ret; + } - if (DiskTransferBuffer[0x1fe] != 0x55 - || DiskTransferBuffer[0x1ff] != 0xaa || pbpbarray->bpb_nbyte != 512) + if (getword(DiskTransferBuffer + 0x1fe) != 0xaa55 || + getword(DiskTransferBuffer + BT_BPB) != 512) /* bpb_nbyte */ { /* copy default bpb to be sure that there is no bogus data */ - memcpy(pbpbarray, &pddt->ddt_defbpb, sizeof(bpb)); + memcpy(&pddt->ddt_bpb, &pddt->ddt_defbpb, sizeof pddt->ddt_bpb); return S_DONE; } - pddt->ddt_descflags &= ~DF_NOACCESS; /* set drive to accessible */ + pddt->ddt_descflags &= ~DF_NOACCESS; /* set drive to accessible */ /*TE ~ 200 bytes*/ - memcpy(pbpbarray, &DiskTransferBuffer[BT_BPB], sizeof(bpb)); + memcpy(&pddt->ddt_bpb, DiskTransferBuffer + BT_BPB, sizeof pddt->ddt_bpb); /*?? */ /* 2b is fat16 volume label. if memcmp, then offset 0x36. - if (fstrncmp((BYTE *) & DiskTransferBuffer[0x36], "FAT16",5) == 0 || - fstrncmp((BYTE *) & DiskTransferBuffer[0x36], "FAT12",5) == 0) { + if (memcmp(DiskTransferBuffer + 0x36, "FAT16", 5) == 0 || + memcmp(DiskTransferBuffer + 0x36, "FAT12", 5) == 0) TE: I'm not sure, what the _real_ decision point is, however MSDN 'A_BF_BPB_SectorsPerFAT The number of sectors per FAT. @@ -405,7 +380,7 @@ STATIC WORD getbpb(ddt * pddt) { struct FS_info *fs = (struct FS_info *)&DiskTransferBuffer[0x27]; #ifdef WITHFAT32 - if (pbpbarray->bpb_nfsect == 0) + if (pddt->ddt_bpb.bpb_nfsect == 0) { /* FAT32 boot sector */ fs = (struct FS_info *)&DiskTransferBuffer[0x43]; @@ -417,37 +392,49 @@ STATIC WORD getbpb(ddt * pddt) } #ifdef DSK_DEBUG - printf("BPB_NBYTE = %04x\n", pbpbarray->bpb_nbyte); - printf("BPB_NSECTOR = %02x\n", pbpbarray->bpb_nsector); - printf("BPB_NRESERVED = %04x\n", pbpbarray->bpb_nreserved); - printf("BPB_NFAT = %02x\n", pbpbarray->bpb_nfat); - printf("BPB_NDIRENT = %04x\n", pbpbarray->bpb_ndirent); - printf("BPB_NSIZE = %04x\n", pbpbarray->bpb_nsize); - printf("BPB_MDESC = %02x\n", pbpbarray->bpb_mdesc); - printf("BPB_NFSECT = %04x\n", pbpbarray->bpb_nfsect); + printf("BPB_NBYTE = %04x\n" + "BPB_NSECTOR = %02x\n" + "BPB_NRESERVED = %04x\n" + "BPB_NFAT = %02x\n" + "BPB_NDIRENT = %04x\n" + "BPB_NSIZE = %04x\n" + "BPB_MDESC = %02x\n" + "BPB_NFSECT = %04x\n", + pddt->ddt_bpb.bpb_nbyte, + pddt->ddt_bpb.bpb_nsector, + pddt->ddt_bpb.bpb_nreserved, + pddt->ddt_bpb.bpb_nfat, + pddt->ddt_bpb.bpb_ndirent, + pddt->ddt_bpb.bpb_nsize, + pddt->ddt_bpb.bpb_mdesc, + pddt->ddt_bpb.bpb_nfsect); #endif - count = - pbpbarray->bpb_nsize == 0 ? - pbpbarray->bpb_huge : pbpbarray->bpb_nsize; - secs_per_cyl = pbpbarray->bpb_nheads * pbpbarray->bpb_nsecs; + tmark(pddt); - if (secs_per_cyl == 0) { - tmark(pddt); - return failure(E_FAILURE); - } - /* this field is problematic for partitions > 65535 cylinders, - in general > 512 GiB. However: we are not using it ourselves. */ - pddt->ddt_ncyl = (UWORD)((count + (secs_per_cyl - 1)) / secs_per_cyl); + unsigned secs_per_cyl = pddt->ddt_bpb.bpb_nheads * pddt->ddt_bpb.bpb_nsecs; + if (secs_per_cyl == 0) + return failure(E_FAILURE); - tmark(pddt); + /* this field is problematic for partitions > 65535 cylinders, + in general > 512 GiB. However: we are not using it ourselves. */ + { + unsigned nsize = pddt->ddt_bpb.bpb_nsize; + pddt->ddt_ncyl = (UWORD)(((nsize ? nsize : pddt->ddt_bpb.bpb_huge) - 1) + / secs_per_cyl) + 1; + } + } #ifdef DSK_DEBUG - printf("BPB_NSECS = %04x\n", pbpbarray->bpb_nsecs); - printf("BPB_NHEADS = %04x\n", pbpbarray->bpb_nheads); - printf("BPB_HIDDEN = %08lx\n", pbpbarray->bpb_hidden); - printf("BPB_HUGE = %08lx\n", pbpbarray->bpb_huge); + printf("BPB_NSECS = %04x\n" + "BPB_NHEADS = %04x\n" + "BPB_HIDDEN = %08lx\n" + "BPB_HUGE = %08lx\n", + pddt->ddt_bpb.bpb_nsecs, + pddt->ddt_bpb.bpb_nheads, + pddt->ddt_bpb.bpb_hidden, + pddt->ddt_bpb.bpb_huge); #endif return 0; @@ -455,11 +442,9 @@ STATIC WORD getbpb(ddt * pddt) STATIC WORD bldbpb(rqptr rp, ddt * pddt) { - WORD result; - - if ((result = getbpb(pddt)) != 0) - return result; - + int ret = getbpb(pddt); + if (ret) + return ret; rp->r_bpptr = &pddt->ddt_bpb; return S_DONE; } @@ -469,49 +454,44 @@ STATIC WORD IoctlQueblk(rqptr rp, ddt * pddt) UNREFERENCED_PARAMETER(pddt); #ifdef WITHFAT32 - if (rp->r_cat == 8 || rp->r_cat == 0x48) + if ((UBYTE)(~0x40 & rp->r_cat) != 8 || /* 0x08,0x48 */ #else - if (rp->r_cat == 8) + if (rp->r_cat != 8 || #endif - { - switch (rp->r_fun) - { - case 0x46: - case 0x47: - case 0x60: - case 0x66: - case 0x67: - return S_DONE; - } - } - return failure(E_CMD); + (rp->r_fun != 0x60 && + (UBYTE)(~0x21 & rp->r_fun) != 0x46)) /* 0x46,0x47,0x66,0x67 */ + return failure(E_CMD); + return S_DONE; } STATIC COUNT Genblockio(ddt * pddt, UWORD mode, WORD head, WORD track, WORD sector, WORD count, VOID FAR * buffer) { - UWORD transferred; + UWORD done; - /* apparently sector is ZERO, not ONE based !!! */ + /* apparently here sector is ZERO, not ONE based !!! */ return LBA_Transfer(pddt, mode, buffer, - ((ULONG) track * pddt->ddt_bpb.bpb_nheads + head) * - (ULONG) pddt->ddt_bpb.bpb_nsecs + - pddt->ddt_offset + sector, count, &transferred); + ((ULONG) track * pddt->ddt_bpb.bpb_nheads + + head) * pddt->ddt_bpb.bpb_nsecs + sector, + count, &done); } STATIC WORD Genblkdev(rqptr rp, ddt * pddt) { - int ret; unsigned descflags = pddt->ddt_descflags; #ifdef WITHFAT32 - int extended = 0; + unsigned copy_size = sizeof (bpb); - if (rp->r_cat == 0x48) - extended = 1; - else -#endif + if (rp->r_cat != 0x48) + { + if (rp->r_cat != 8) + return failure(E_CMD); + copy_size = BPB_SIZEOF; + } +#else if (rp->r_cat != 8) return failure(E_CMD); +#endif switch (rp->r_fun) { @@ -521,80 +501,68 @@ STATIC WORD Genblkdev(rqptr rp, ddt * pddt) bpb *pbpb; pddt->ddt_type = gblp->gbio_devtype; - pddt->ddt_descflags = (descflags & ~3) | (gblp->gbio_devattrib & 3) - | (DF_DPCHANGED | DF_REFORMAT); + pddt->ddt_descflags = (descflags & ~3) | + (gblp->gbio_devattrib & 3) | + (DF_DPCHANGED | DF_REFORMAT); pddt->ddt_ncyl = gblp->gbio_ncyl; /* use default dpb or current bpb? */ - pbpb = - (gblp->gbio_spcfunbit & 0x01) == - 0 ? &pddt->ddt_defbpb : &pddt->ddt_bpb; + pbpb = (gblp->gbio_spcfunbit & 1) ? &pddt->ddt_bpb : &pddt->ddt_defbpb; #ifdef WITHFAT32 - fmemcpy(pbpb, &gblp->gbio_bpb, - extended ? sizeof(gblp->gbio_bpb) : BPB_SIZEOF); + fmemcpy(pbpb, &gblp->gbio_bpb, copy_size); #else fmemcpy(pbpb, &gblp->gbio_bpb, sizeof(gblp->gbio_bpb)); #endif - /*pbpb->bpb_nsector = gblp->gbio_nsecs; */ + /*pbpb->bpb_nsector = gblp->gbio_nsecs;*/ break; } case 0x41: /* write track */ { struct gblkrw FAR *rw = rp->r_rw; - ret = Genblockio(pddt, LBA_WRITE, rw->gbrw_head, rw->gbrw_cyl, - rw->gbrw_sector, rw->gbrw_nsecs, rw->gbrw_buffer); - if (ret != 0) - return dskerr(ret); + int ret = Genblockio(pddt, LBA_WRITE, rw->gbrw_head, rw->gbrw_cyl, + rw->gbrw_sector, rw->gbrw_nsecs, rw->gbrw_buffer); + if (ret) + return ret; + break; } - break; case 0x42: /* format/verify track */ { struct gblkfv FAR *fv = rp->r_fv; - COUNT tracks; - struct thst { - UBYTE track, head, sector, type; - } *addrfield, afentry; + int ret; pddt->ddt_descflags &= ~DF_DPCHANGED; if (hd(descflags)) { /* XXX no low-level formatting for hard disks implemented */ - fv->gbfv_spcfunbit = 1; /* "not supported by bios" */ - return S_DONE; + fv->gbfv_spcfunbit = 1; /* "not supported by bios" */ + break; } - if (descflags & DF_DPCHANGED) + + /* first try newer setmediatype function */ + if ((descflags & DF_DPCHANGED) && + (ret = fl_setmediatype(pddt->ddt_driveno, pddt->ddt_ncyl, + pddt->ddt_bpb.bpb_nsecs)) != 0) { - /* first try newer setmediatype function */ - ret = fl_setmediatype(pddt->ddt_driveno, pddt->ddt_ncyl, - pddt->ddt_bpb.bpb_nsecs); if (ret == 0xc) { /* specified tracks, sectors/track not allowed for drive */ fv->gbfv_spcfunbit = 2; - return dskerr(ret); + return failure(E_NOTFND); /*dskerr(0xc)*/ } - else if (ret == 0x80) + if (ret == 0x80 || + (fv->gbfv_spcfunbit & 1) && + (ret = fl_read(pddt->ddt_driveno, 0, 0, 1, 1, + DiskTransferBuffer)) != 0) { - fv->gbfv_spcfunbit = 3; /* no disk in drive */ + fv->gbfv_spcfunbit = 3; /* no disk in drive */ return dskerr(ret); } - else if (ret != 0) - /* otherwise, setdisktype */ + /* otherwise, setdisktype */ { - unsigned char type; - unsigned tracks, secs; - if ((fv->gbfv_spcfunbit & 1) && - (ret = - fl_read(pddt->ddt_driveno, 0, 0, 1, 1, - DiskTransferBuffer)) != 0) - { - fv->gbfv_spcfunbit = 3; /* no disk in drive */ - return dskerr(ret); - } /* type 1: 320/360K disk in 360K drive */ /* type 2: 320/360K disk in 1.2M drive */ - tracks = pddt->ddt_ncyl; - secs = pddt->ddt_bpb.bpb_nsecs; - type = pddt->ddt_type + 1; + unsigned tracks = pddt->ddt_ncyl; + unsigned secs = pddt->ddt_bpb.bpb_nsecs; + UBYTE type = pddt->ddt_type + 1; if (!(tracks == 40 && (secs == 9 || secs == 8) && type < 3)) { /* type 3: 1.2M disk in 1.2M drive */ @@ -607,85 +575,98 @@ STATIC WORD Genblkdev(rqptr rp, ddt * pddt) { /* specified tracks, sectors/track not allowed for drive */ fv->gbfv_spcfunbit = 2; - return dskerr(0xc); + return failure(E_NOTFND); /*dskerr(0xc)*/ } } fl_setdisktype(pddt->ddt_driveno, type); } } if (fv->gbfv_spcfunbit & 1) - return S_DONE; - - afentry.type = 2; /* 512 byte sectors */ - afentry.track = fv->gbfv_cyl; - afentry.head = fv->gbfv_head; - - for (tracks = fv->gbfv_spcfunbit & 2 ? fv->gbfv_ntracks : 1; - tracks > 0; tracks--) { - addrfield = (struct thst *)DiskTransferBuffer; - - if (afentry.track > pddt->ddt_ncyl) - return failure(E_FAILURE); - - for (afentry.sector = 1; - afentry.sector <= pddt->ddt_bpb.bpb_nsecs; afentry.sector++) - memcpy(addrfield++, &afentry, sizeof(afentry)); - - ret = - Genblockio(pddt, LBA_FORMAT, afentry.head, afentry.track, 0, - pddt->ddt_bpb.bpb_nsecs, DiskTransferBuffer); - if (ret != 0) - return dskerr(ret); + fv->gbfv_spcfunbit = 0; /* success */ + break; } - afentry.head++; - if (afentry.head >= pddt->ddt_bpb.bpb_nheads) + { - afentry.head = 0; - afentry.track++; + unsigned cyl = fv->gbfv_cyl; + unsigned head = fv->gbfv_head; + unsigned tracks = fv->gbfv_spcfunbit & 2 ? fv->gbfv_ntracks : 1; + + for (; tracks; tracks--) + { + if (cyl >= pddt->ddt_ncyl) /* ??? remove --avb */ + return failure(E_FAILURE); + { + struct thst { + UBYTE cyl, head, sector, type; + } *addrfield = (struct thst *)DiskTransferBuffer; + unsigned sector = 0; + do + { + sector++; + addrfield->type = 2; /* 512 byte sectors */ + addrfield->cyl = cyl; + addrfield->head = head; + addrfield->sector = sector; + addrfield++; + } while (sector < pddt->ddt_bpb.bpb_nsecs); + } + { + int ret = Genblockio(pddt, LBA_FORMAT, head, cyl, 0, + pddt->ddt_bpb.bpb_nsecs, DiskTransferBuffer); + if (ret) + return ret; + } + if (++head >= pddt->ddt_bpb.bpb_nheads) + { + head = 0; + cyl++; + } + } } - } + fv->gbfv_spcfunbit >>= 1; /* move bit 1 to bit 0 */ + } /* fall through to verify */ case 0x62: /* verify track */ { struct gblkfv FAR *fv = rp->r_fv; - - ret = Genblockio(pddt, LBA_VERIFY, fv->gbfv_head, fv->gbfv_cyl, 0, - (fv->gbfv_spcfunbit ? - fv->gbfv_ntracks * pddt->ddt_defbpb.bpb_nsecs : - pddt->ddt_defbpb.bpb_nsecs), DiskTransferBuffer); - if (ret != 0) - return dskerr(ret); + int ret = Genblockio(pddt, LBA_VERIFY, fv->gbfv_head, fv->gbfv_cyl, 0, + (fv->gbfv_spcfunbit & 1) + ? fv->gbfv_ntracks * pddt->ddt_defbpb.bpb_nsecs + : pddt->ddt_defbpb.bpb_nsecs, + DiskTransferBuffer); + /* !!! ret should be analyzed to fill fv->gbfv_spcfunbit by + 1=function not supported by BIOS + 2=specified tracks, sector/track not allowed for drive + 3=no disk in drive + --avb + */ + if (ret) + return ret; fv->gbfv_spcfunbit = 0; /* success */ + break; } - break; case 0x46: /* set volume serial number */ { - struct Gioc_media FAR *gioc = rp->r_gioc; struct FS_info *fs; - - ret = getbpb(pddt); - if (ret != 0) - return (ret); - - fs = (struct FS_info *)&DiskTransferBuffer - [(pddt->ddt_bpb.bpb_nfsect != 0 ? 0x27 : 0x43)]; - fs->serialno = gioc->ioc_serialno; - pddt->ddt_serialno = fs->serialno; - + int ret = getbpb(pddt); + if (ret) + return ret; + fs = (struct FS_info *)(pddt->ddt_bpb.bpb_nfsect + ? DiskTransferBuffer + 0x27 + : DiskTransferBuffer + 0x43); + pddt->ddt_serialno = fs->serialno = rp->r_gioc->ioc_serialno; ret = RWzero(pddt, LBA_WRITE); - if (ret != 0) - return (dskerr(ret)); + if (ret) + return ret; + break; } - break; case 0x47: /* set access flag */ - { - struct Access_info FAR *ai = rp->r_ai; - pddt->ddt_descflags = (descflags & ~DF_NOACCESS) | - (ai->AI_Flag ? 0 : DF_NOACCESS); - } + pddt->ddt_descflags |= DF_NOACCESS; + if (rp->r_ai->AI_Flag) + pddt->ddt_descflags &= ~DF_NOACCESS; break; case 0x60: /* get device parameters */ { @@ -698,45 +679,39 @@ STATIC WORD Genblkdev(rqptr rp, ddt * pddt) gblp->gbio_media = (pddt->ddt_type == 1) && (pddt->ddt_ncyl == 40); gblp->gbio_ncyl = pddt->ddt_ncyl; /* use default dpb or current bpb? */ - pbpb = - (gblp->gbio_spcfunbit & 0x01) == - 0 ? &pddt->ddt_defbpb : &pddt->ddt_bpb; + pbpb = (gblp->gbio_spcfunbit & 1) ? &pddt->ddt_bpb : &pddt->ddt_defbpb; #ifdef WITHFAT32 - fmemcpy(&gblp->gbio_bpb, pbpb, - extended ? sizeof(gblp->gbio_bpb) : BPB_SIZEOF); + fmemcpy(&gblp->gbio_bpb, pbpb, copy_size); #else fmemcpy(&gblp->gbio_bpb, pbpb, sizeof(gblp->gbio_bpb)); #endif - /*gblp->gbio_nsecs = pbpb->bpb_nsector; */ + /*gblp->gbio_nsecs = pbpb->bpb_nsector;*/ break; } case 0x61: /* read track */ { struct gblkrw FAR *rw = rp->r_rw; - ret = Genblockio(pddt, LBA_READ, rw->gbrw_head, rw->gbrw_cyl, - rw->gbrw_sector, rw->gbrw_nsecs, rw->gbrw_buffer); - if (ret != 0) - return dskerr(ret); + int ret = Genblockio(pddt, LBA_READ, rw->gbrw_head, rw->gbrw_cyl, + rw->gbrw_sector, rw->gbrw_nsecs, rw->gbrw_buffer); + if (ret) + return ret; + break; } - break; case 0x66: /* get volume serial number */ { - struct Gioc_media FAR *gioc = rp->r_gioc; - - ret = getbpb(pddt); - if (ret != 0) - return (ret); + struct Gioc_media FAR *gioc; + int ret = getbpb(pddt); + if (ret) + return ret; + gioc = rp->r_gioc; gioc->ioc_serialno = pddt->ddt_serialno; - fmemcpy(gioc->ioc_volume, pddt->ddt_volume, 11); - fmemcpy(gioc->ioc_fstype, pddt->ddt_fstype, 8); + fmemcpy(gioc->ioc_volume, pddt->ddt_volume, sizeof gioc->ioc_volume); + fmemcpy(gioc->ioc_fstype, pddt->ddt_fstype, sizeof gioc->ioc_fstype); + break; } - break; case 0x67: /* get access flag */ - { - struct Access_info FAR *ai = rp->r_ai; - ai->AI_Flag = descflags & DF_NOACCESS ? 0 : 1; /* bit 9 */ - } + rp->r_ai->AI_Flag = (descflags / DF_NOACCESS) & 1; /* bit 9 */ break; default: return failure(E_CMD); @@ -746,12 +721,8 @@ STATIC WORD Genblkdev(rqptr rp, ddt * pddt) STATIC WORD blockio(rqptr rp, ddt * pddt) { - ULONG start, size; - WORD ret; - UWORD done; - + ULONG start; int action; - bpb *pbpb; switch (rp->r_command) { @@ -773,35 +744,24 @@ STATIC WORD blockio(rqptr rp, ddt * pddt) tmark(pddt); start = (rp->r_start != HUGECOUNT ? rp->r_start : rp->r_huge); - pbpb = hd(pddt->ddt_descflags) ? &pddt->ddt_defbpb : &pddt->ddt_bpb; - size = (pbpb->bpb_nsize ? pbpb->bpb_nsize : pbpb->bpb_huge); - - if (start >= size || start + rp->r_count > size) { - return 0x0408; + const bpb *pbpb = hd(pddt->ddt_descflags) ? &pddt->ddt_defbpb : &pddt->ddt_bpb; + ULONG size = (pbpb->bpb_nsize ? pbpb->bpb_nsize : pbpb->bpb_huge); + if (start >= size || rp->r_count > size - start) + return 0x0408; } - start += pddt->ddt_offset; - - ret = LBA_Transfer(pddt, action, - rp->r_trans, - start, rp->r_count, &done); - rp->r_count = done; - if (ret != 0) { - return dskerr(ret); + UWORD done; + int ret = LBA_Transfer(pddt, action, rp->r_trans, + start, rp->r_count, &done); + rp->r_count = done; + if (ret) + return ret; } return S_DONE; } -STATIC WORD blk_error(rqptr rp, ddt * pddt) -{ - UNREFERENCED_PARAMETER(pddt); - - rp->r_count = 0; - return failure(E_FAILURE); /* general failure */ -} - STATIC WORD blk_noerr(rqptr rp, ddt * pddt) { UNREFERENCED_PARAMETER(rp); @@ -818,13 +778,9 @@ STATIC WORD dskerr(COUNT code) { case 1: /* invalid command - general failure */ if (code & 0x08) - return S_ERROR | E_NOTRDY; /* failure(E_NOTRDY); at least on yhe INT25 route, - 0x8002 is returned */ - else - return failure(E_CMD); - - case 2: /* address mark not found - general failure */ - return failure(E_FAILURE); + return S_ERROR | E_NOTRDY; /* failure(E_NOTRDY); at least on the + INT25 route, 0x8002 is returned */ + return failure(E_CMD); case 3: /* write protect */ return failure(E_WRPRT); @@ -832,14 +788,15 @@ STATIC WORD dskerr(COUNT code) default: if (code & 0x80) /* time-out */ return failure(E_NOTRDY); - else if (code & 0x40) /* seek error */ + if (code & 0x40) /* seek error */ return failure(E_SEEK); - else if (code & 0x10) /* CRC error */ + if (code & 0x10) /* CRC error */ return failure(E_CRC); - else if (code & 0x04) + if (code & 0x04) return failure(E_NOTFND); - else - return failure(E_FAILURE); + + case 2: /* address mark not found - general failure */ + return failure(E_FAILURE); } } @@ -898,42 +855,22 @@ STATIC unsigned DMA_max_transfer(void FAR * buffer, unsigned count) UWORD *transferred sectors actually transferred Read/Write/Write+verify some sectors, using LBA addressing. - - + This function handles all the minor details, including: - retry in case of errors - crossing the 64K DMA boundary - translation to CHS addressing if necessary - - crossing track boundaries (necessary for some BIOS's - + crossing track boundaries (necessary for some BIOS's) High memory doesn't work very well, use internal buffer - write with verify details for LBA - */ STATIC int LBA_Transfer(ddt * pddt, UWORD mode, VOID FAR * buffer, ULONG LBA_address, unsigned totaltodo, UWORD * transferred) { - static struct _bios_LBA_address_packet dap = { - 16, 0, 0, 0, 0, 0, 0 - }; - - unsigned count; - unsigned error_code = 0; - struct CHS chs; - void FAR *transfer_address; - unsigned char driveno = pddt->ddt_driveno; - - int num_retries; - *transferred = 0; - + /* only low-level format floppies for now ! */ if (mode == LBA_FORMAT && hd(pddt->ddt_descflags)) return 0; @@ -943,136 +880,106 @@ STATIC int LBA_Transfer(ddt * pddt, UWORD mode, VOID FAR * buffer, if (!hd(pddt->ddt_descflags)) { - UBYTE FAR *int1e_ptr = (UBYTE FAR *)getvec(0x1e); - unsigned char nsecs = (unsigned char)(pddt->ddt_bpb.bpb_nsecs); - + UBYTE FAR *int1e_ptr = (UBYTE FAR *)getvec(0x1e); + UBYTE nsecs = (UBYTE)pddt->ddt_bpb.bpb_nsecs; if (int1e_ptr[4] != nsecs) { int1e_ptr[4] = nsecs; - fl_reset(driveno); + fl_reset(pddt->ddt_driveno); } } - -/* + + LBA_address += pddt->ddt_offset; +/* if (LBA_address+totaltodo > pddt->total_sectors) { printf("LBA-Transfer error : address overflow = %lu > %lu max\n",LBA_address+totaltodo,driveParam->total_sectors); - return 1; + return failure(E_CMD); // dskerr(1) } */ buffer = adjust_far(buffer); - for (; totaltodo != 0;) + while (totaltodo) { - /* avoid overflowing 64K DMA boundary */ - count = DMA_max_transfer(buffer, totaltodo); + int num_retries; + /* avoid overflowing 64K DMA boundary */ + void FAR *transfer_address = buffer; + unsigned count = DMA_max_transfer(buffer, totaltodo); if (FP_SEG(buffer) >= 0xa000 || count == 0) { transfer_address = DiskTransferBuffer; count = 1; - if ((mode & 0xff00) == (LBA_WRITE & 0xff00)) - { fmemcpy(DiskTransferBuffer, buffer, 512); - } - } - else - { - transfer_address = buffer; } - for (num_retries = 0; num_retries < N_RETRY; num_retries++) + for (num_retries = N_RETRY;;) { - if ((pddt->ddt_descflags & DF_LBA) && mode != LBA_FORMAT) + unsigned error_code; + if (mode != LBA_FORMAT && (pddt->ddt_descflags & DF_LBA)) { + UWORD m; + static struct _bios_LBA_address_packet dap = { + 16, 0, 0, 0, 0, 0, 0 + }; dap.number_of_blocks = count; - dap.buffer_address = transfer_address; - + dap.block_address = LBA_address; dap.block_address_high = 0; /* clear high part */ - dap.block_address = LBA_address; /* clear high part */ - /* Load the registers and call the interrupt. */ - - if ((pddt->ddt_descflags & DF_WRTVERIFY) || mode != LBA_WRITE_VERIFY) - { - error_code = fl_lba_ReadWrite(driveno, mode, &dap); - } - else + m = mode; + if (mode == LBA_WRITE_VERIFY && !(pddt->ddt_descflags & DF_WRTVERIFY)) { /* verify requested, but not supported */ - error_code = - fl_lba_ReadWrite(driveno, LBA_WRITE, &dap); - + error_code = fl_lba_ReadWrite(pddt->ddt_driveno, LBA_WRITE, &dap); if (error_code == 0) { - error_code = - fl_lba_ReadWrite(driveno, LBA_VERIFY, &dap); + m = LBA_VERIFY; + error_code = fl_lba_ReadWrite(pddt->ddt_driveno, m, &dap); } } + else + error_code = fl_lba_ReadWrite(pddt->ddt_driveno, m, &dap); } else { /* transfer data, using old bios functions */ - + struct CHS chs; if (LBA_to_CHS(LBA_address, &chs, pddt)) - return 1; + return failure(E_CMD); /*dskerr(1)*/ /* avoid overflow at end of track */ - - if (chs.Sector + count > (unsigned)pddt->ddt_bpb.bpb_nsecs + 1) - { - count = pddt->ddt_bpb.bpb_nsecs + 1 - chs.Sector; - } + if (count > pddt->ddt_bpb.bpb_nsecs + 1 - chs.Sector) + count = pddt->ddt_bpb.bpb_nsecs + 1 - chs.Sector; error_code = (mode == LBA_READ ? fl_read : mode == LBA_VERIFY ? fl_verify : - mode == - LBA_FORMAT ? fl_format : fl_write) (driveno, - chs.Head, - chs.Cylinder, - chs.Sector, - count, - transfer_address); - + mode == LBA_FORMAT ? fl_format : fl_write) + (pddt->ddt_driveno, chs.Head, chs.Cylinder, + chs.Sector, count, transfer_address); if (error_code == 0 && mode == LBA_WRITE_VERIFY) - { - error_code = fl_verify(driveno, chs.Head, chs.Cylinder, + error_code = fl_verify(pddt->ddt_driveno, chs.Head, chs.Cylinder, chs.Sector, count, transfer_address); - } } if (error_code == 0) break; - fl_reset(driveno); - - } /* end of retries */ - - if (error_code) - { - return error_code; - } + fl_reset(pddt->ddt_driveno); + if (--num_retries == 0) + return dskerr(error_code); + } /* end of retries */ /* copy to user buffer if nesessary */ if (transfer_address == DiskTransferBuffer && (mode & 0xff00) == (LBA_READ & 0xff00)) - { fmemcpy(buffer, DiskTransferBuffer, 512); - } *transferred += count; LBA_address += count; totaltodo -= count; - buffer = adjust_far((char FAR *)buffer + count * 512); + buffer = adjust_far((char FAR *)buffer + count * 512u); } - return (error_code); + return 0; } - -/* - * Revision 1.17 2001/05/13 tomehlert - * Added full support for LBA hard drives - * initcode moved (mostly) to initdisk.c - * lower interface partly redesigned - */ diff --git a/kernel/entry.asm b/kernel/entry.asm index d0610fd8..f7fe4c53 100644 --- a/kernel/entry.asm +++ b/kernel/entry.asm @@ -314,7 +314,7 @@ int21_2: inc byte [_InDOS] or ah,ah jz int21_3 cmp ah,0ch - jle int21_normalentry + jbe int21_normalentry int21_3: call dos_crit_sect diff --git a/kernel/globals.h b/kernel/globals.h index b99f1950..dc16b570 100644 --- a/kernel/globals.h +++ b/kernel/globals.h @@ -235,7 +235,7 @@ Freeman Publishing, Lawrence KS, USA (ISBN 0-87930-436-7).\n\ extern UWORD ASM NetBios; extern BYTE * ASM net_name; extern BYTE ASM net_set_count; -extern BYTE ASM NetDelay, ASM NetRetry; +extern UWORD ASM NetDelay, ASM NetRetry; extern UWORD ASM first_mcb, /* Start of user memory */ ASM uppermem_root; /* Start of umb chain (usually 9fff) */ @@ -360,8 +360,7 @@ extern UWORD ASM f_nodes_cnt; /* number of allocated f_nodes */ /* Process related functions - not under automatic generation. */ /* Typically, these are in ".asm" files. */ -VOID ASMCFUNC FAR cpm_entry(VOID) -/*INRPT FAR handle_break(VOID) */ ; +VOID ASMCFUNC FAR cpm_entry(VOID); COUNT ASMCFUNC CriticalError(COUNT nFlag, COUNT nDrive, COUNT nError, struct dhdr FAR * lpDevice); @@ -371,7 +370,6 @@ VOID ASMCFUNC FAR CharMapSrvc(VOID); VOID ASMCFUNC FAR set_stack(VOID); VOID ASMCFUNC FAR restore_stack(VOID); #endif -/*VOID INRPT FAR handle_break(VOID); */ ULONG ASMPASCAL ReadPCClock(VOID); VOID ASMPASCAL WriteATClock(BYTE *, BYTE, BYTE, BYTE); diff --git a/kernel/init-mod.h b/kernel/init-mod.h index aab74761..c7b3459c 100644 --- a/kernel/init-mod.h +++ b/kernel/init-mod.h @@ -124,36 +124,32 @@ intvec getvec(unsigned char intno); /* config.c */ extern struct config Config; VOID PreConfig(VOID); -VOID PreConfig2(VOID); -VOID DoConfig(int pass); +void DoConfig(void); VOID PostConfig(VOID); VOID configDone(VOID); -VOID FAR * KernelAlloc(size_t nBytes, char type, int mode); -void FAR * KernelAllocPara(size_t nPara, char type, char *name, int mode); -char *strcat(char * d, const char * s); -BYTE * GetStringArg(BYTE * pLine, BYTE * pszString); +#ifdef I86 +void _seg * alignNextPara(CVFP); +#else +#define alignNextPara(x) ((const VOID *)x) +#endif +void _seg * KernelAlloc(size_t nBytes, UBYTE type, int mode); +void _seg * KernelAllocPara(size_t nPara, UBYTE type, CStr name, int mode); void DoInstall(void); -UWORD GetBiosKey(int timeout); +unsigned GetBiosKey(int timeout); /* diskinit.c */ COUNT dsk_init(VOID); /* int2f.asm */ -COUNT ASMPASCAL Umb_Test(void); -COUNT ASMPASCAL UMB_get_largest(void FAR * driverAddress, - UCOUNT * seg, UCOUNT * size); + +int ASMPASCAL UMB_get_largest(CVFP driverAddress, seg_t *, size_t *); #ifdef __WATCOMC__ -#pragma aux (pascal) UMB_get_largest modify exact [ax bx cx dx] +# pragma aux (pascal) UMB_get_largest modify exact [ax bx cx dx] #endif /* inithma.c */ int MoveKernelToHMA(void); -VOID FAR * HMAalloc(COUNT bytesToAllocate); - -/* initoem.c */ -unsigned init_oem(void); -void movebda(size_t bytes, unsigned new_seg); -unsigned ebdasize(void); +VFP HMAalloc(COUNT bytesToAllocate); /* intr.asm */ @@ -164,7 +160,7 @@ int ASMPASCAL close(int fd); int ASMPASCAL dup2(int oldfd, int newfd); seg ASMPASCAL allocmem(UWORD size); void ASMPASCAL init_PSPSet(seg psp_seg); -int ASMPASCAL init_DosExec(int mode, exec_blk * ep, char * lp); +int ASMPASCAL init_DosExec(int mode, exec_blk *, CStr); int ASMPASCAL init_setdrive(int drive); int ASMPASCAL init_switchar(int chr); void ASMPASCAL keycheck(void); @@ -208,15 +204,22 @@ VOID ASMCFUNC FAR int2f_handler(void); VOID ASMCFUNC FAR cpm_entry(void); /* kernel.asm */ -VOID ASMCFUNC FAR init_call_p_0(struct config FAR *Config); /* P_0, actually */ + +void ASMCFUNC FAR init_call_p_0(const struct config FAR *); /* P_0, actually */ +#ifdef __WATCOMC__ +# pragma aux (cdecl) init_call_p_0 aborts +#endif /* main.c */ -VOID ASMCFUNC FreeDOSmain(void); -BOOL init_device(struct dhdr FAR * dhp, char * cmdLine, - COUNT mode, char FAR **top); -VOID init_fatal(BYTE * err_msg); + +void ASMCFUNC FreeDOSmain(void); +BOOL init_device(struct dhdr FAR *, PCStr cmdLine, int mode, VFP *top); +#ifdef __WATCOMC__ +# pragma aux (cdecl) FreeDOSmain aborts +#endif /* prf.c */ + int VA_CDECL init_printf(const char * fmt, ...); int VA_CDECL init_sprintf(char * buff, const char * fmt, ...); @@ -231,12 +234,17 @@ extern UWORD HMAFree; /* first byte in HMA not yet used */ extern unsigned CurrentKernelSegment; extern struct _KernelConfig FAR ASM LowKernelConfig; extern WORD days[2][13]; -extern BYTE FAR *lpTop; +extern VFP lpTop; extern BYTE ASM _ib_start[], ASM _ib_end[], ASM _init_end[]; -extern UWORD ram_top; /* How much ram in Kbytes */ -extern char singleStep; -extern char SkipAllConfig; -extern char master_env[128]; + +enum { ASK_ASK = 0x01, /* ?device= device?= */ + ASK_NOASK = 0x02, /* !files= */ + ASK_TRACE = 0x04, /* F8 processing */ + ASK_SKIPALL = 0x08, /* F5 processing */ + ASK_YESALL = 0x10, /* Esc while trace */ +}; + +extern UBYTE askCommand; extern struct lol FAR *LoL; @@ -312,4 +320,3 @@ ULONG ASMCFUNC FAR MULULUL(ULONG mul1, ULONG mul2); /* MULtiply ULong by ULo ULONG ASMCFUNC FAR DIVULUS(ULONG mul1, UWORD mul2); /* DIVide ULong by UShort */ ULONG ASMCFUNC FAR DIVMODULUS(ULONG mul1, UWORD mul2, UWORD * rem); /* DIVide ULong by UShort */ #endif - diff --git a/kernel/initoem.c b/kernel/initoem.c index d07b3f9a..e69de29b 100644 --- a/kernel/initoem.c +++ b/kernel/initoem.c @@ -1,72 +0,0 @@ -/****************************************************************/ -/* */ -/* initoem.c */ -/* */ -/* OEM Initializattion Functions */ -/* */ -/* Copyright (c) 1995 */ -/* Pasquale J. Villani */ -/* All Rights Reserved */ -/* */ -/* This file is part of DOS-C. */ -/* */ -/* DOS-C is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU General Public License */ -/* as published by the Free Software Foundation; either version */ -/* 2, or (at your option) any later version. */ -/* */ -/* DOS-C is distributed in the hope that it will be useful, but */ -/* WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See */ -/* the GNU General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU General Public */ -/* License along with DOS-C; see the file COPYING. If not, */ -/* write to the Free Software Foundation, 675 Mass Ave, */ -/* Cambridge, MA 02139, USA. */ -/* */ -/****************************************************************/ - -#include "portab.h" -#include "init-mod.h" - -#ifdef VERSION_STRINGS -static BYTE *RcsId = - "$Id$"; -#endif - -#define EBDASEG 0x40e -#define RAMSIZE 0x413 - -unsigned init_oem(void) -{ - iregs r; - init_call_intr(0x12, &r); - return r.a.x; -} - -void movebda(size_t bytes, unsigned new_seg) -{ - unsigned old_seg = peek(0, EBDASEG); - fmemcpy(MK_FP(new_seg, 0), MK_FP(old_seg, 0), bytes); - poke(0, EBDASEG, new_seg); - poke(0, RAMSIZE, ram_top); -} - -unsigned ebdasize(void) -{ - unsigned ebdaseg = peek(0, EBDASEG); - unsigned ramsize = ram_top; - - if (ramsize * 64 == ebdaseg && ramsize < 640 && peek(0, RAMSIZE) == ramsize) - { - unsigned ebdasz = peekb(ebdaseg, 0); - - /* sanity check: is there really no more than 63 KB? - * must be at 640k (all other values never seen and are untested) - */ - if (ebdasz <= 63 && ramsize + ebdasz == 640) - return ebdasz * 1024U; - } - return 0; -} diff --git a/kernel/int2f.asm b/kernel/int2f.asm index 895e378b..73369abf 100644 --- a/kernel/int2f.asm +++ b/kernel/int2f.asm @@ -106,10 +106,9 @@ DriverSysCal: mov di, _Dyn+2 jmp short Int2f?iret - -;*********************************************************** -; internal doscalls INT2F/11xx - handled through C -;*********************************************************** +;********************************************************************** +; internal dos calls INT2F/12xx and INT2F/4A01,4A02 - handled through C +;********************************************************************** IntDosCal: ; set up register frame ;struct int2f12regs diff --git a/kernel/inthndlr.c b/kernel/inthndlr.c index 6cf6ab74..72e577ee 100644 --- a/kernel/inthndlr.c +++ b/kernel/inthndlr.c @@ -1240,13 +1240,12 @@ VOID ASMCFUNC int21_service(iregs FAR * r) case 0x5f: if (lr.AL == 7 || lr.AL == 8) { - struct cds FAR *cdsp; - if (lr.DL >= lastdrive) + struct cds FAR *cdsp = &CDSp[lr.DL]; + if (lr.DL >= lastdrive || FP_OFF(cdsp->cdsDpb) == 0) { rc = DE_INVLDDRV; goto error_exit; } - cdsp = &CDSp[lr.DL]; if (lr.AL == 7) cdsp->cdsFlags |= CDSPHYSDRV; else diff --git a/kernel/intr.asm b/kernel/intr.asm index 895ce627..7318522d 100644 --- a/kernel/intr.asm +++ b/kernel/intr.asm @@ -94,7 +94,9 @@ segment HMA_TEXT -;; COUNT ASMPASCAL res_DosExec(COUNT mode, exec_blk * ep, BYTE * lp) +; +; int ASMPASCAL res_DosExec(int mode, exec_blk * ep, const char * lp); +; global RES_DOSEXEC RES_DOSEXEC: pop es ; ret address @@ -106,12 +108,13 @@ RES_DOSEXEC: push ds pop es ; es = ds int 21h - jc short no_exec_error - xor ax, ax -no_exec_error: + sbb dx,dx ; CF=0? + and ax,dx ; then ax=0, else ax=error code ret -;; UCOUNT ASMPASCAL res_read(int fd, void *buf, UCOUNT count); +; +; unsigned ASMPASCAL res_read(int fd, void *buf, unsigned count); +; global RES_READ RES_READ: pop ax ; ret address @@ -121,23 +124,20 @@ RES_READ: push ax ; ret address mov ah, 3fh int 21h - jnc no_read_error - mov ax, -1 -no_read_error: + sbb dx,dx ; CF=1? + or ax,dx ; then ax=-1, else ax=bytes read ret segment INIT_TEXT ; -; void init_call_intr(nr, rp) -; REG int nr -; REG struct REGPACK *rp +; unsigned ASMPASCAL init_call_intr(int nr, iregs * rp); ; global INIT_CALL_INTR INIT_CALL_INTR: INTR ; -; int init_call_XMScall( (WORD FAR * driverAddress)(), WORD AX, WORD DX) +; int ASMPASCAL init_call_XMScall(void FAR * driverAddress, UWORD ax, UWORD dx); ; ; this calls HIMEM.SYS ; @@ -154,8 +154,10 @@ INIT_CALL_XMSCALL: push es ; driver address ("jmp es:cx") push cx retf - -; void FAR *DetectXMSDriver(VOID) + +; +; void FAR * ASMPASCAL DetectXMSDriver(VOID); +; global DETECTXMSDRIVER DETECTXMSDRIVER: mov ax, 4300h @@ -163,8 +165,8 @@ DETECTXMSDRIVER: cmp al, 80h je detected - xor ax, ax - xor dx, dx + xor ax,ax + cwd ret detected: @@ -179,13 +181,18 @@ detected: pop es ret +; +; void ASMPASCAL keycheck(void); +; global KEYCHECK KEYCHECK: mov ah, 1 int 16h ret -;; int open(const char *pathname, int flags); +; +; int ASMPASCAL open(const char *pathname, int flags); +; global INIT_DOSOPEN INIT_DOSOPEN: ;; init calling DOS through ints: @@ -198,12 +205,14 @@ INIT_DOSOPEN: common_int21: int 21h - jnc common_no_error - mov ax, -1 -common_no_error: + jnc common_ret ; CF=1? + sbb ax,ax ; then ax=-1, else ax unchanged +common_ret: ret -;; int close(int fd); +; +; int ASMPASCAL close(int fd); +; global CLOSE CLOSE: pop ax ; ret address @@ -212,7 +221,9 @@ CLOSE: mov ah, 3eh jmp short common_int21 -;; UCOUNT read(int fd, void *buf, UCOUNT count); +; +; unsigned ASMPASCAL read(int fd, void *buf, unsigned count); +; global READ READ: pop ax ; ret address @@ -223,7 +234,9 @@ READ: mov ah, 3fh jmp short common_int21 -;; int dup2(int oldfd, int newfd); +; +; int ASMPASCAL dup2(int oldfd, int newfd); +; global DUP2 DUP2: pop ax ; ret address @@ -233,7 +246,9 @@ DUP2: mov ah, 46h jmp short common_int21 -;; VOID init_PSPSet(seg psp_seg) +; +; void ASMPASCAL init_PSPSet(seg psp_seg); +; global INIT_PSPSET INIT_PSPSET: pop ax ; ret address @@ -243,7 +258,9 @@ INIT_PSPSET: int 21h ret -;; COUNT init_DosExec(COUNT mode, exec_blk * ep, BYTE * lp) +; +; int ASMPASCAL init_DosExec(int mode, exec_blk * ep, const char * lp); +; global INIT_DOSEXEC INIT_DOSEXEC: pop es ; ret address @@ -255,12 +272,13 @@ INIT_DOSEXEC: push ds pop es ; es = ds int 21h - jc short exec_no_error - xor ax, ax -exec_no_error: + sbb dx,dx ; CF=0? + and ax,dx ; then ax=0, else ax=error code ret -;; int init_setdrive(int drive) +; +; int ASMPASCAL init_setdrive(int drive); +; global INIT_SETDRIVE INIT_SETDRIVE: mov ah, 0x0e @@ -271,7 +289,9 @@ common_dl_int21: int 21h ret -;; int init_switchar(int char) +; +; int ASMPASCAL init_switchar(int chr); +; global INIT_SWITCHAR INIT_SWITCHAR: mov ax, 0x3701 @@ -287,11 +307,13 @@ ALLOCMEM: push ax ; ret address mov ah, 48h int 21h - sbb bx, bx ; carry=1 -> ax=-1 - or ax, bx ; segment + sbb bx,bx ; CF=1? + or ax,bx ; then ax=-1, else ax=segment ret -;; void set_DTA(void far *dta) +; +; void ASMPASCAL set_DTA(void far *dta); +; global SET_DTA SET_DTA: pop ax ; ret address diff --git a/kernel/ioctl.c b/kernel/ioctl.c index bb9a753d..3ad15af1 100644 --- a/kernel/ioctl.c +++ b/kernel/ioctl.c @@ -56,38 +56,55 @@ static BYTE *RcsId = COUNT DosDevIOctl(lregs * r) { - sft FAR *s; - struct dpb FAR *dpbp; - COUNT nMode; - unsigned attr; - unsigned char al = r->AL; - - if (al > 0x11) - return DE_INVLDFUNC; + static UBYTE cmds [] = { + 0, 0, + /* 0x02 */ C_IOCTLIN, + /* 0x03 */ C_IOCTLOUT, + /* 0x04 */ C_IOCTLIN, + /* 0x05 */ C_IOCTLOUT, + /* 0x06 */ C_ISTAT, + /* 0x07 */ C_OSTAT, + /* 0x08 */ C_REMMEDIA, + 0, 0, 0, + /* 0x0c */ C_GENIOCTL, + /* 0x0d */ C_GENIOCTL, + /* 0x0e */ C_GETLDEV, + /* 0x0f */ C_SETLDEV, + /* 0x10 */ C_IOCTLQRY, + /* 0x11 */ C_IOCTLQRY, + }; + static UWORD required_attr [] = { + 0, 0, + /* 0x02 */ ATTR_IOCTL, + /* 0x03 */ ATTR_IOCTL, + /* 0x04 */ ATTR_IOCTL, + /* 0x05 */ ATTR_IOCTL, + 0, 0, + /* 0x08 */ ATTR_EXCALLS, + 0, 0, 0, + /* 0x0c */ ATTR_GENIOCTL, + /* 0x0d */ ATTR_GENIOCTL, + /* 0x0e */ ATTR_GENIOCTL, + /* 0x0f */ ATTR_GENIOCTL, + /* 0x10 */ ATTR_QRYIOCTL, + /* 0x11 */ ATTR_QRYIOCTL, + }; - /* commonly used, shouldn't harm to do front up */ - if (al == 0x0C || al == 0x0D || al >= 0x10) /* generic or query */ - { - CharReqHdr.r_cat = r->CH; /* category (major) code */ - CharReqHdr.r_fun = r->CL; /* function (minor) code */ - CharReqHdr.r_io = MK_FP(r->DS, r->DX); /* parameter block */ - } - else - { - CharReqHdr.r_count = r->CX; - CharReqHdr.r_trans = MK_FP(r->DS, r->DX); - } - CharReqHdr.r_length = sizeof(request); - CharReqHdr.r_status = 0; + sft FAR *s; + struct dhdr FAR *dev; + unsigned attr, flags; + UBYTE cmd; switch (r->AL) { + default: /* 0x12+ */ + return DE_INVLDFUNC; + case 0x0b: - /* skip, it's a special case. */ - NetDelay = r->CX; - if (r->DX) + if (r->DX) /* skip, it's a special case */ NetRetry = r->DX; - break; + NetDelay = r->CX; + return SUCCESS; case 0x00: case 0x01: @@ -98,31 +115,90 @@ COUNT DosDevIOctl(lregs * r) case 0x0a: case 0x0c: case 0x10: - { - unsigned flags; - /* Test that the handle is valid and */ /* get the SFT block that contains the SFT */ - if ((s = get_sft(r->BX)) == (sft FAR *) - 1) + if ((s = get_sft(r->BX)) == (sft FAR *)-1) return DE_INVLDHNDL; - - attr = s->sft_dev->dh_attr; flags = s->sft_flags; + dev = s->sft_dev; + attr = dev->dh_attr; + break; + + case 0x04: + case 0x05: + case 0x08: + case 0x09: + case 0x0d: + case 0x0e: + case 0x0f: + case 0x11: + { + struct dpb FAR *dpbp; +/* + Line below previously returned the deviceheader at r->bl. But, + DOS numbers its drives starting at 1, not 0. A=1, B=2, and so + on. Changed this line so it is now zero-based. --SRM + */ +/* changed to use default drive if drive=0. --JPP */ +/* Fixed it. --JT */ + +#define NDN_HACK +#ifdef NDN_HACK +/* NDN feeds the actual ASCII drive letter to this function */ + UBYTE unit = (r->BL & 0x1f) - 1; +#else + UBYTE unit = r->BL - 1; +#endif + if (unit == 0xff) + unit = default_drive; + CharReqHdr.r_unit = unit; - switch (r->AL) + if ((dpbp = get_dpb(unit)) == NULL) + { + if (r->AL != 0x09) + return DE_INVLDDRV; + attr = ATTR_REMOTE; + } + else { - case 0x00: + dev = dpbp->dpb_device; + attr = dev->dh_attr; + } + } + } /* switch */ + + /* required_attr[] may be zero and in this case attr ignored */ + if (~attr & required_attr [r->AL]) + return DE_INVLDFUNC; + + /* commonly used, shouldn't harm to do front up */ + CharReqHdr.r_command = cmd = cmds [r->AL]; + if (cmd == C_GENIOCTL || cmd == C_IOCTLQRY) + { + CharReqHdr.r_cat = r->CH; /* category (major) code */ + CharReqHdr.r_fun = r->CL; /* function (minor) code */ + CharReqHdr.r_io = MK_FP(r->DS, r->DX); /* parameter block */ + } + else + { + CharReqHdr.r_count = r->CX; + CharReqHdr.r_trans = MK_FP(r->DS, r->DX); + } + CharReqHdr.r_length = sizeof(request); + CharReqHdr.r_status = 0; + + switch (r->AL) + { + case 0x00: /* Get the flags from the SFT */ + r->DX = flags; if (flags & SFT_FDEVICE) - r->AX = (attr & 0xff00) | (flags & 0xff); - else - r->AX = flags; + r->DH = attr >> 8; /* Undocumented result, Ax = Dx seen using Pcwatch */ - r->DX = r->AX; + r->AX = r->DX; break; - case 0x01: - /* sft_flags is a file, return an error because you */ + case 0x01: /* can't set the status of a file. */ if (!(flags & SFT_FDEVICE)) return DE_INVLDFUNC; @@ -132,205 +208,95 @@ COUNT DosDevIOctl(lregs * r) if (r->DH != 0) return DE_INVLDDATA; - /* Undocumented: AL should get the old value */ - r->AL = s->sft_flags_lo; /* Set it to what we got in the DL register from the */ /* user. */ s->sft_flags_lo = SFT_FDEVICE | r->DL; + /* Undocumented: AL should get the old value */ + r->AL = (UBYTE)flags; break; - case 0x02: - nMode = C_IOCTLIN; - goto IoCharCommon; - - case 0x03: - nMode = C_IOCTLOUT; - goto IoCharCommon; - - case 0x06: - if (flags & SFT_FDEVICE) - { - nMode = C_ISTAT; - goto IoCharCommon; - } - r->AL = s->sft_posit >= s->sft_size ? 0 : 0xFF; - break; - - case 0x07: - if (flags & SFT_FDEVICE) - { - nMode = C_OSTAT; - goto IoCharCommon; - } - r->AL = 0; - break; - - case 0x0a: + case 0x0a: r->DX = flags; - r->AX = 0; + r->AX = 0; /* ??? RBIL doesn't says that AX changed --avb */ break; - case 0x0c: - nMode = C_GENIOCTL; - goto IoCharCommon; - - default: /* 0x10 */ - nMode = C_IOCTLQRY; - IoCharCommon: - if ((flags & SFT_FDEVICE) && - ( (r->AL <= 0x03 && (attr & ATTR_IOCTL)) - || r->AL == 0x06 || r->AL == 0x07 - || (r->AL == 0x10 && (attr & ATTR_QRYIOCTL)) - || (r->AL == 0x0c && (attr & ATTR_GENIOCTL)))) + case 0x06: + if (!(flags & SFT_FDEVICE)) { - CharReqHdr.r_unit = 0; - CharReqHdr.r_command = nMode; - execrh((request FAR *) & CharReqHdr, s->sft_dev); - - if (CharReqHdr.r_status & S_ERROR) - { - CritErrCode = (CharReqHdr.r_status & S_MASK) + 0x13; - return DE_DEVICE; - } - - if (r->AL <= 0x03) - r->AX = CharReqHdr.r_count; - else if (r->AL <= 0x07) - r->AX = CharReqHdr.r_status & S_BUSY ? 0000 : 0x00ff; - else /* 0x0c or 0x10 */ - r->AX = CharReqHdr.r_status; + r->AL = s->sft_posit >= s->sft_size ? (UBYTE)0 : (UBYTE)0xFF; break; } - return DE_INVLDFUNC; - } - break; - } - - default: /* block IOCTL: 4, 5, 8, 9, d, e, f, 11 */ - -/* - This line previously returned the deviceheader at r->bl. But, - DOS numbers its drives starting at 1, not 0. A=1, B=2, and so - on. Changed this line so it is now zero-based. - - -SRM - */ -/* JPP - changed to use default drive if drive=0 */ -/* JT Fixed it */ - -#define NDN_HACK -/* NDN feeds the actual ASCII drive letter to this function */ -#ifdef NDN_HACK - CharReqHdr.r_unit = ((r->BL & 0x1f) == 0 ? default_drive : - (r->BL & 0x1f) - 1); -#else - CharReqHdr.r_unit = (r->BL == 0 ? default_drive : r->BL - 1); -#endif - - dpbp = get_dpb(CharReqHdr.r_unit); - if (dpbp) - attr = dpbp->dpb_device->dh_attr; - else if (r->AL != 9) - return DE_INVLDDRV; + /* fall through */ - switch (r->AL) - { - case 0x04: - nMode = C_IOCTLIN; - goto IoBlockCommon; - case 0x05: - nMode = C_IOCTLOUT; - goto IoBlockCommon; - case 0x08: - if (attr & ATTR_EXCALLS) + case 0x07: + if (!(flags & SFT_FDEVICE)) { - nMode = C_REMMEDIA; - goto IoBlockCommon; + r->AL = 0; + break; } - return DE_INVLDFUNC; - case 0x09: + /* fall through */ + + case 0x02: + case 0x03: + case 0x0c: + case 0x10: + if (!(flags & SFT_FDEVICE)) + return DE_INVLDFUNC; + CharReqHdr.r_unit = 0; /* ??? not used for devices --avb */ + goto execrequest; + + case 0x09: { - struct cds FAR *cdsp = get_cds(CharReqHdr.r_unit); - r->AX = S_DONE | S_BUSY; - if (cdsp != NULL && dpbp == NULL) - { - r->DX = ATTR_REMOTE; - } - else - { - if (!dpbp) - { - return DE_INVLDDRV; - } - r->DX = attr; - } + const struct cds FAR *cdsp = get_cds(CharReqHdr.r_unit); + if (cdsp == NULL) + return DE_INVLDDRV; if (cdsp->cdsFlags & CDSSUBST) - { - r->DX |= ATTR_SUBST; - } + attr |= ATTR_SUBST; + r->DX = attr; + r->AX = S_DONE | S_BUSY; /* ??? S_* values only for driver interface; + RBIL doesn't says that AX changed --avb */ break; } - case 0x0d: - nMode = C_GENIOCTL; - goto IoBlockCommon; - case 0x11: - nMode = C_IOCTLQRY; - IoBlockCommon: - if (r->AL == 0x0D && (r->CX & ~(0x486B-0x084A)) == 0x084A) + + case 0x0d: + if ((r->CX & ~0x4021) == 0x084A) { /* 084A/484A, 084B/484B, 086A/486A, 086B/486B */ r->AX = 0; /* (lock/unlock logical/physical volume) */ break; /* simulate success for MS-DOS 7+ SCANDISK etc. --LG */ } - if ((r->AL <= 0x05 && !(attr & ATTR_IOCTL)) - || (r->AL == 0x11 && !(attr & ATTR_QRYIOCTL)) - || (r->AL == 0x0d && !(attr & ATTR_GENIOCTL))) - { - return DE_INVLDFUNC; - } - - CharReqHdr.r_command = nMode; - execrh((request FAR *) & CharReqHdr, dpbp->dpb_device); + /* fall through */ + case 0x04: + case 0x05: + case 0x08: + case 0x11: + execrequest: + execrh(&CharReqHdr, dev); if (CharReqHdr.r_status & S_ERROR) { CritErrCode = (CharReqHdr.r_status & S_MASK) + 0x13; return DE_DEVICE; } - if (r->AL <= 0x05) + + if (r->AL <= 0x05) /* 0x02, 0x03, 0x04, 0x05 */ r->AX = CharReqHdr.r_count; - else if (r->AL == 0x08) - r->AX = (CharReqHdr.r_status & S_BUSY) ? 1 : 0; - else /* 0x0d or 0x11 */ + else if (r->AL <= 0x07) /* 0x06, 0x07 */ + r->AX = (CharReqHdr.r_status & S_BUSY) ? 0000 : 0x00ff; + else if (r->AL == 0x08) /* 0x08 */ + r->AX = (CharReqHdr.r_status / S_BUSY) & 1u; + else /* 0x0c, 0x0d, 0x10, 0x11 */ r->AX = CharReqHdr.r_status; break; - case 0x0e: - nMode = C_GETLDEV; - goto IoLogCommon; - default: /* 0x0f */ - nMode = C_SETLDEV; - IoLogCommon: - if (attr & ATTR_GENIOCTL) + case 0x0e: + default: /* 0x0f */ + execrh(&CharReqHdr, dev); + if (CharReqHdr.r_status & S_ERROR) { - - CharReqHdr.r_command = nMode; - execrh((request FAR *) & CharReqHdr, dpbp->dpb_device); - - if (CharReqHdr.r_status & S_ERROR) - { - CritErrCode = (CharReqHdr.r_status & S_MASK) + 0x13; - return DE_ACCESS; - } - else - { - r->AL = CharReqHdr.r_unit; - return SUCCESS; - } + CritErrCode = (CharReqHdr.r_status & S_MASK) + 0x13; + return DE_ACCESS; } - return DE_INVLDFUNC; - } - break; - } + r->AL = CharReqHdr.r_unit; + } /* switch */ return SUCCESS; } - diff --git a/kernel/main.c b/kernel/main.c index 0e13d42a..cddb2992 100644 --- a/kernel/main.c +++ b/kernel/main.c @@ -45,12 +45,12 @@ static char copyright[] = struct _KernelConfig InitKernelConfig BSS_INIT({0}); -STATIC VOID InitIO(void); +STATIC VOID init_internal_devices(void); STATIC VOID update_dcb(struct dhdr FAR *); STATIC VOID init_kernel(VOID); STATIC VOID signon(VOID); -STATIC VOID kernel(VOID); +STATIC VOID init_shell(VOID); STATIC VOID FsConfig(VOID); STATIC VOID InitPrinters(VOID); STATIC VOID InitSerialPorts(VOID); @@ -69,11 +69,8 @@ __segment DosTextSeg = 0; struct lol FAR *LoL = &DATASTART; -VOID ASMCFUNC FreeDOSmain(void) +void ASMCFUNC FreeDOSmain(void) { - unsigned char drv; - unsigned char FAR *p; - #ifdef _MSC_VER extern FAR prn_dev; DosDataSeg = (__segment) & DATASTART; @@ -89,24 +86,25 @@ VOID ASMCFUNC FreeDOSmain(void) at 50:e0 */ - drv = LoL->BootDrive + 1; - p = MK_FP(0, 0x5e0); - if (fmemcmp(p+2,"CONFIG",6) == 0) /* UPX */ { - fmemcpy(&InitKernelConfig, p+2, sizeof(InitKernelConfig)); + UBYTE drv; + UBYTE FAR *p = MK_PTR(UBYTE, 0, 0x5e2); + if (fmemcmp(p, "CONFIG", 6) == 0) /* UPXed */ + drv = p[-2]; /* boot drive was stored there by stub from exeflat.c */ + else + { + drv = LoL->BootDrive; + p[-2] = drv; /* used by initdisk.c:ReadAllPartitionTables() */ + p = (UBYTE FAR*)&LowKernelConfig; + } - drv = *p + 1; - *(DWORD FAR *)(p+2) = 0; - } - else - { - *p = drv - 1; - fmemcpy(&InitKernelConfig, &LowKernelConfig, sizeof(InitKernelConfig)); - } + drv++; + if (drv > 0x80) + drv = 3; /* C: */ + LoL->BootDrive = drv; - if (drv >= 0x80) - drv = 3; /* C: */ - LoL->BootDrive = drv; + fmemcpy(&InitKernelConfig, p, sizeof InitKernelConfig); + } setup_int_vectors(); @@ -114,22 +112,14 @@ VOID ASMCFUNC FreeDOSmain(void) signon(); init_kernel(); + init_shell(); -#ifdef DEBUG - /* Non-portable message kludge alert! */ - printf("KERNEL: Boot drive = %c\n", 'A' + LoL->BootDrive - 1); -#endif - - DoInstall(); - - kernel(); + init_call_p_0(&Config); /* execute process 0 (the shell) */ } /* InitializeAllBPBs() - or MakeNortonDiskEditorHappy() - it has been determined, that FDOS's BPB tables are initialized, only when used (like DIR H:). at least one known utility (norton DE) seems to access them directly. @@ -149,62 +139,47 @@ void InitializeAllBPBs(VOID) STATIC void PSPInit(void) { - psp far *p = MK_FP(DOS_PSP, 0); + psp _seg *p = MK_SEG_PTR(psp, DOS_PSP); + + fmemset(p, 0, sizeof(psp)); /* Clear out new psp first */ + + /* initialize all entries and exits */ + p->ps_exit = 0x20cd; /* CP/M-like exit point: */ + /* INT 20 opcode */ + /* CP/M-like entry point: */ + p->ps_farcall = 0x9a; /* FAR CALL opcode... */ + p->ps_reentry = MK_FP(0, 0x30 * 4); /* ...entry address */ + p->ps_unix[0] = 0xcd; /* unix style call: */ + p->ps_unix[1] = 0x21; /* INT 21/RETF opcodes */ + p->ps_unix[2] = 0xcb; - /* Clear out new psp first */ - fmemset(p, 0, sizeof(psp)); + /* parent-child relationships */ + /*p->ps_parent = 0;*/ /* parent psp segment */ + p->ps_prevpsp = (VFP)-1l; /* previous psp address */ - /* initialize all entries and exits */ - /* CP/M-like exit point */ - p->ps_exit = 0x20cd; + /* Environment and memory useage parameters */ + /*p->ps_size = 0;*/ /* segment of memory beyond */ + /* memory allocated to program */ + /*p->ps_environ = 0;*/ /* environment paragraph */ - /* CP/M-like entry point - call far to special entry */ - p->ps_farcall = 0x9a; - p->ps_reentry = MK_FP(0, 0x30 * 4); - /* unix style call - 0xcd 0x21 0xcb (int 21, retf) */ - p->ps_unix[0] = 0xcd; - p->ps_unix[1] = 0x21; - p->ps_unix[2] = 0xcb; + /*p->ps_isv22 = NULL;*/ /* terminate handler */ + /*p->ps_isv23 = NULL;*/ /* break handler */ + /*p->ps_isv24 = NULL;*/ /* critical error handler */ - /* Now for parent-child relationships */ - /* parent psp segment */ - p->ps_parent = FP_SEG(p); - /* previous psp pointer */ - p->ps_prevpsp = MK_FP(0xffff,0xffff); - - /* Environment and memory useage parameters */ - /* memory size in paragraphs */ - /* p->ps_size = 0; clear from above */ - /* environment paragraph */ - p->ps_environ = DOS_PSP + 8; - /* terminate address */ - p->ps_isv22 = getvec(0x22); - /* break address */ - p->ps_isv23 = getvec(0x23); - /* critical error address */ - p->ps_isv24 = getvec(0x24); - - /* user stack pointer - int 21 */ - /* p->ps_stack = NULL; clear from above */ - - /* File System parameters */ - /* maximum open files */ - p->ps_maxfiles = 20; - fmemset(p->ps_files, 0xff, 20); - - /* open file table pointer */ - p->ps_filetab = p->ps_files; - - /* first command line argument */ - /* p->ps_fcb1.fcb_drive = 0; already set */ - fmemset(p->ps_fcb1.fcb_fname, ' ', FNAME_SIZE + FEXT_SIZE); - /* second command line argument */ - /* p->ps_fcb2.fcb_drive = 0; already set */ - fmemset(p->ps_fcb2.fcb_fname, ' ', FNAME_SIZE + FEXT_SIZE); - - /* local command line */ - /* p->ps_cmd.ctCount = 0; command tail, already set */ - p->ps_cmd.ctBuffer[0] = 0xd; /* command tail */ + /*p->ps_stack = NULL;*/ /* user stack pointer - int 21 */ + + /* File System parameters */ + p->ps_maxfiles = sizeof p->ps_files; /* size of file table */ + fmemset(p->ps_filetab = p->ps_files, 0xff, sizeof p->ps_files); + + /*p->ps_fcb1.fcb_drive = 0;*/ /* 1st command line argument */ + /*fmemset(p->ps_fcb1.fcb_fname, ' ', FNAME_SIZE + FEXT_SIZE);*/ + /*p->ps_fcb2.fcb_drive = 0;*/ /* 2nd command line argument */ + /*fmemset(p->ps_fcb2.fcb_fname, ' ', FNAME_SIZE + FEXT_SIZE);*/ + + /* this area reused for master environment */ + /*p->ps_cmd.ctCount = 0;*/ /* local command line */ + /*p->ps_cmd.ctBuffer[0] = '\r';*/ /* command tail */ } #ifndef __WATCOMC__ @@ -255,7 +230,7 @@ STATIC void setup_int_vectors(void) for (i = 0x23; i <= 0x3f; i++) setvec(i, empty_handler); - for (pvec = vectors; pvec < vectors + (sizeof vectors/sizeof *pvec); pvec++) + for (pvec = vectors; pvec < ENDOF(vectors); pvec++) setvec(pvec->intno, (intvec)MK_FP(FP_SEG(empty_handler), pvec->handleroff)); pokeb(0, 0x30 * 4, 0xea); pokel(0, 0x30 * 4 + 1, (ULONG)cpm_entry); @@ -272,9 +247,6 @@ STATIC void init_kernel(void) LoL->os_setver_major = LoL->os_major = MAJOR_RELEASE; LoL->os_setver_minor = LoL->os_minor = MINOR_RELEASE; - /* Init oem hook - returns memory size in KB */ - ram_top = init_oem(); - /* move kernel to high conventional RAM, just below the init code */ #ifdef __WATCOMC__ lpTop = MK_FP(_CS, 0); @@ -283,16 +255,17 @@ STATIC void init_kernel(void) #endif MoveKernel(FP_SEG(lpTop)); + /* lpTop should be para-aligned */ lpTop = MK_FP(FP_SEG(lpTop) - 0xfff, 0xfff0); /* Initialize IO subsystem */ - InitIO(); + init_internal_devices(); InitPrinters(); InitSerialPorts(); - init_PSPSet(DOS_PSP); set_DTA(MK_FP(DOS_PSP, 0x80)); PSPInit(); + init_PSPSet(DOS_PSP); Init_clk_driver(); @@ -300,7 +273,6 @@ STATIC void init_kernel(void) /* we can read config.sys later. */ LoL->lastdrive = Config.cfgLastdrive; - /* init_device((struct dhdr FAR *)&blk_dev, NULL, 0, &ram_top); */ blk_dev.dh_name[0] = dsk_init(); PreConfig(); @@ -313,14 +285,7 @@ STATIC void init_kernel(void) FsConfig(); /* Now process CONFIG.SYS */ - DoConfig(0); - DoConfig(1); - - /* initialize near data and MCBs */ - PreConfig2(); - /* and process CONFIG.SYS one last time for device drivers */ - DoConfig(2); - + DoConfig(); /* Close all (device) files */ for (i = 0; i < 20; i++) @@ -331,10 +296,12 @@ STATIC void init_kernel(void) /* Init the file system one more time */ FsConfig(); - + configDone(); InitializeAllBPBs(); + + DoInstall(); } STATIC VOID FsConfig(VOID) @@ -346,21 +313,15 @@ STATIC VOID FsConfig(VOID) for (i = 0; i < LoL->lastdrive; i++) { struct cds FAR *pcds_table = &LoL->CDSp[i]; - fmemcpy(pcds_table->cdsCurrentPath, "A:\\\0", 4); - pcds_table->cdsCurrentPath[0] += i; - - if (i < LoL->nblkdev && (ULONG) dpb != 0xffffffffl) + pcds_table->cdsFlags = 0; + if (i < LoL->nblkdev && (LONG) dpb != -1l) { pcds_table->cdsDpb = dpb; pcds_table->cdsFlags = CDSPHYSDRV; dpb = dpb->dpb_next; } - else - { - pcds_table->cdsFlags = 0; - } pcds_table->cdsStrtClst = 0xffff; pcds_table->cdsParam = 0xffff; pcds_table->cdsStoreUData = 0xffff; @@ -428,135 +389,89 @@ STATIC VOID signon() MAJOR_RELEASE, MINOR_RELEASE, copyright); } -STATIC void kernel() +STATIC void init_shell() { - CommandTail Cmd; - - if (master_env[0] == '\0') /* some shells panic on empty master env. */ - strcpy(master_env, "PATH=."); - fmemcpy(MK_FP(DOS_PSP + 8, 0), master_env, sizeof(master_env)); - - /* process 0 */ - /* Execute command.com from the drive we just booted from */ - memset(Cmd.ctBuffer, 0, sizeof(Cmd.ctBuffer)); - strcpy(Cmd.ctBuffer, Config.cfgInitTail); - - for (Cmd.ctCount = 0; Cmd.ctCount < sizeof(Cmd.ctBuffer); Cmd.ctCount++) - if (Cmd.ctBuffer[Cmd.ctCount] == '\r') - break; - - /* if stepping CONFIG.SYS (F5/F8), tell COMMAND.COM about it */ - - /* 3 for string + 2 for "\r\n" */ - if (Cmd.ctCount < sizeof(Cmd.ctBuffer) - 5) + /* if stepping CONFIG.SYS (F5/F8), tell COMMAND.COM about it */ + /* (insert /D, /Y as first argument) */ + if (askCommand & (ASK_TRACE | ASK_SKIPALL)) { - char *insertString = NULL; + PStr p = Config.cfgShell - 1; /* find end of command name */ - if (singleStep) - insertString = " /Y"; /* single step AUTOEXEC */ + /* too long line -> truncate it to make space for "/Y \0" */ + Config.cfgShell[sizeof Config.cfgShell - 4] = '\0'; - if (SkipAllConfig) - insertString = " /D"; /* disable AUTOEXEC */ + do p++; while ((UBYTE)*p > ' ' && *p != '/'); - if (insertString) - { + if (*p == ' ' || *p == '\t') + p++; /* place option after space */ - /* insert /D, /Y as first argument */ - char *p, *q; - - for (p = Cmd.ctBuffer; p < &Cmd.ctBuffer[Cmd.ctCount]; p++) + { + PStr q = p; + while (*q++); /* find end of command line */ + /* shift tail to right by 3 to make room for option */ + do { - if (*p == ' ' || *p == '\t' || *p == '\r') - { - for (q = &Cmd.ctBuffer[Cmd.ctCount + 1]; q >= p; q--) - q[3] = q[0]; - memcpy(p, insertString, 3); - break; - } - } - /* save buffer -- on the stack it's fine here */ - Config.cfgInitTail = Cmd.ctBuffer; + q--; + q[3] = q[0]; + } while (q > p); } + + p[0] = '/', p[1] = 'Y', p[2] = ' '; /* single step AUTOEXEC */ + if (askCommand & ASK_SKIPALL) + p[1] = 'D'; /* disable AUTOEXEC */ } - init_call_p_0(&Config); /* go execute process 0 (the shell) */ } -/* check for a block device and update device control block */ +/* check for a block device and update device control block */ STATIC VOID update_dcb(struct dhdr FAR * dhp) { - REG COUNT Index; - COUNT nunits = dhp->dh_name[0]; - struct dpb FAR *dpb; + int nunits = dhp->dh_name[0]; + struct dpb FAR *dpb = LoL->DPBp; - if (LoL->nblkdev == 0) - dpb = LoL->DPBp; - else + if (LoL->nblkdev) { - for (dpb = LoL->DPBp; (ULONG) dpb->dpb_next != 0xffffffffl; - dpb = dpb->dpb_next) - ; + while ((LONG) dpb->dpb_next != -1l) + dpb = dpb->dpb_next; dpb = dpb->dpb_next = KernelAlloc(nunits * sizeof(struct dpb), 'E', Config.cfgDosDataUmb); } - for (Index = 0; Index < nunits; Index++) { - dpb->dpb_next = dpb + 1; - dpb->dpb_unit = LoL->nblkdev; - dpb->dpb_subunit = Index; - dpb->dpb_device = dhp; - dpb->dpb_flags = M_CHANGED; - if ((LoL->CDSp != 0) && (LoL->nblkdev < LoL->lastdrive)) + int i = 0; + do { - LoL->CDSp[LoL->nblkdev].cdsDpb = dpb; - LoL->CDSp[LoL->nblkdev].cdsFlags = CDSPHYSDRV; - } - ++dpb; - ++LoL->nblkdev; + dpb->dpb_next = dpb + 1; + dpb->dpb_unit = LoL->nblkdev; + if (LoL->nblkdev < LoL->lastdrive && LoL->CDSp) + { + LoL->CDSp[LoL->nblkdev].cdsDpb = dpb; + LoL->CDSp[LoL->nblkdev].cdsFlags = CDSPHYSDRV; + } + LoL->nblkdev++; + dpb->dpb_subunit = i; + dpb->dpb_device = dhp; + dpb->dpb_flags = M_CHANGED; + dpb++; + i++; + } while (i < nunits); } - (dpb - 1)->dpb_next = (void FAR *)0xFFFFFFFFl; + (dpb - 1)->dpb_next = (VFP)-1l; } -/* If cmdLine is NULL, this is an internal driver */ - -BOOL init_device(struct dhdr FAR * dhp, char *cmdLine, COUNT mode, - char FAR **r_top) +/* If r_top is NULL, this is an internal driver */ +BOOL init_device(struct dhdr FAR * dhp, PCStr cmdLine, int mode, VFP *r_top) { request rq; - char name[8]; - - if (cmdLine) { - char *p, *q, ch; - int i; - - p = q = cmdLine; - for (;;) - { - ch = *p; - if (ch == '\0' || ch == ' ' || ch == '\t') - break; - p++; - if (ch == '\\' || ch == '/' || ch == ':') - q = p; /* remember position after path */ - } - for (i = 0; i < 8; i++) { - ch = '\0'; - if (p != q && *q != '.') - ch = *q++; - /* copy name, without extension */ - name[i] = ch; - } - } rq.r_unit = 0; rq.r_status = 0; rq.r_command = C_INIT; rq.r_length = sizeof(request); - rq.r_endaddr = *r_top; - rq.r_bpbptr = (void FAR *)(cmdLine ? cmdLine : "\n"); + rq.r_endaddr = r_top ? *r_top : lpTop; + rq.r_bpbptr = (VFP)cmdLine; rq.r_firstunit = LoL->nblkdev; - execrh((request FAR *) & rq, dhp); + execrh(&rq, dhp); /* * Added needed Error handle @@ -564,7 +479,7 @@ BOOL init_device(struct dhdr FAR * dhp, char *cmdLine, COUNT mode, if ((rq.r_status & (S_ERROR | S_DONE)) == S_ERROR) return TRUE; - if (cmdLine) + if (r_top) { /* Don't link in device drivers which do not take up memory */ if (rq.r_endaddr == (BYTE FAR *) dhp) @@ -578,8 +493,35 @@ BOOL init_device(struct dhdr FAR * dhp, char *cmdLine, COUNT mode, if (FP_OFF(dhp->dh_next) == 0xffff) { - KernelAllocPara(FP_SEG(rq.r_endaddr) + (FP_OFF(rq.r_endaddr) + 15)/16 - - FP_SEG(dhp), 'D', name, mode); + char name[8]; + PCStr q; + { + UBYTE ch; + PCStr p = cmdLine; + q = p; /* position after path */ + do /* find driver name after path */ + { + ch = *p; + p++; + if (ch == ':' || ch == '\\' || ch == '/') + q = p; + } while (ch > ' '); + } + { + int i = 0; + do /* extract driver name */ + { + UBYTE ch = *q; + if (ch <= ' ' || ch == '.') + ch = '\0'; /* copy name, without extension */ + name[i] = ch; + if (ch == '\0') + break; + i++, q++; + } while (i < sizeof name); + } + KernelAllocPara(FP_SEG(alignNextPara(rq.r_endaddr)) - FP_SEG(dhp), + 'D', name, mode); } /* Another fix for multisegmented device drivers: */ @@ -589,7 +531,7 @@ BOOL init_device(struct dhdr FAR * dhp, char *cmdLine, COUNT mode, /* last INIT call which will then be passed as the end address */ /* for the next INIT call. */ - *r_top = (char FAR *)rq.r_endaddr; + *r_top = rq.r_endaddr; } if (!(dhp->dh_attr & ATTR_CHAR) && (rq.r_nunits != 0)) @@ -606,28 +548,21 @@ BOOL init_device(struct dhdr FAR * dhp, char *cmdLine, COUNT mode, return FALSE; } -STATIC void InitIO(void) +STATIC void init_internal_devices(void) { struct dhdr far *device = &LoL->nul_dev; /* Initialize driver chain */ do { - init_device(device, NULL, 0, &lpTop); + /* ??? is cmdLine "\n" for internal devices required? --avb */ + init_device(device, "\n", 0, NULL); device = device->dh_next; } while (FP_OFF(device) != 0xffff); } -/* issue an internal error message */ -VOID init_fatal(BYTE * err_msg) -{ - printf("\nInternal kernel error - %s\nSystem halted\n", err_msg); - for (;;) ; -} - /* Initialize all printers - this should work. IMHO, this might also be done on first use of printer, as I never liked the noise by a resetting printer, and I usually much more often reset my system, then I print :-) @@ -674,50 +609,43 @@ STATIC VOID InitSerialPorts(VOID) remove the floppy/bootable CD from the drive. user has some seconds to hit ANY key to continue - to boot from floppy/cd, else the system is + to boot from floppy/cd, else the system is booted from HD */ -EmulatedDriveStatus(int drive,char statusOnly) +static int EmulatedDriveStatus(int drive,char statusOnly) { iregs r; char buffer[0x13]; buffer[0] = 0x13; - r.a.b.h = 0x4b; /* bootable CDROM - get status */ - r.a.b.l = statusOnly; - r.d.b.l = (char)drive; - r.si = (int)buffer; - init_call_intr(0x13, &r); - - if (r.flags & 1) - return FALSE; - - return TRUE; + r.AH = 0x4b; /* bootable CDROM - get status */ + r.AL = statusOnly; + r.DL = (char)drive; + r.SI = (int)buffer; + init_call_intr(0x13, &r); + return r.FLAGS & 1; /* carry flag */ } STATIC void CheckContinueBootFromHarddisk(void) { char *bootedFrom = "Floppy/CD"; - iregs r; - int key; - if (InitKernelConfig.BootHarddiskSeconds == 0) + if (InitKernelConfig.BootHarddiskSeconds <= 0) return; if (LoL->BootDrive >= 3) { #if 0 - if (!EmulatedDriveStatus(0x80,1)) + if (EmulatedDriveStatus(0x80,1)) #endif - { /* already booted from HD */ return; - } } - else { + else + { #if 0 - if (!EmulatedDriveStatus(0x00,1)) + if (EmulatedDriveStatus(0x00,1)) #endif bootedFrom = "Floppy"; } @@ -729,34 +657,30 @@ STATIC void CheckContinueBootFromHarddisk(void) " Hit 'H' or wait %d seconds to boot from Harddisk\n", InitKernelConfig.BootHarddiskSeconds, bootedFrom, - InitKernelConfig.BootHarddiskSeconds - ); + InitKernelConfig.BootHarddiskSeconds); - key = GetBiosKey(InitKernelConfig.BootHarddiskSeconds); - - if (key != -1 && (key & 0xff) != 'h' && (key & 0xff) != 'H') + if (GetBiosKey(InitKernelConfig.BootHarddiskSeconds)) { - /* user has hit a key, continue to boot from floppy/CD */ - printf("\n"); - return; + unsigned key = GetBiosKey(-1); /* remove key from buffer */ + if ((UBYTE)key != 'h' && (UBYTE)key != 'H') + /* user has hit a key, continue to boot from floppy/CD */ + return; } /* reboot from harddisk */ EmulatedDriveStatus(0x00,0); EmulatedDriveStatus(0x80,0); - /* now jump and run */ - r.a.x = 0x0201; - r.c.x = 0x0001; - r.d.x = 0x0080; - r.b.x = 0x7c00; - r.es = 0; - - init_call_intr(0x13, &r); - { - void (far *reboot)(void) = (void (far*)(void)) MK_FP(0x0,0x7c00); - - (*reboot)(); + iregs r; + r.AX = 0x0201; + r.CX = 0x0001; + r.DX = 0x0080; + r.BX = 0x7c00; + r.ES = 0; + init_call_intr(0x13, &r); } + + /* now jump and run */ + ((void (far*)(void)) MK_FP(0,0x7c00))(); /* jump to boot sector */ } diff --git a/kernel/makefile b/kernel/makefile index 0b679488..4d7adc4b 100644 --- a/kernel/makefile +++ b/kernel/makefile @@ -1,5 +1,5 @@ # -# Makefile for Borland C++ 3.1 for kernel.sys +# makefile for kernel.sys # # $Id$ # @@ -9,10 +9,12 @@ LIBS=..\lib\device.lib ..\lib\libm.lib HDR=../hdr/ -# *List Macros* +# List Macros ########################################################## # Only 8 files per definition; this is limitation of DOS batch # files (only 9 directly accessible parameters). +# Order of linking is important: first kernel.asm, last INIT code. + OBJS1=kernel.obj entry.obj io.obj console.obj serial.obj printer.obj dsk.obj \ sysclk.obj OBJS2=asmsupt.obj execrh.obj nlssupt.obj procsupt.obj dosidle.obj int2f.obj \ @@ -27,98 +29,87 @@ OBJS7=main.obj config.obj initoem.obj inithma.obj dyninit.obj iprf.obj \ initdisk.obj initclk.obj OBJS=$(OBJS1) $(OBJS2) $(OBJS3) $(OBJS4) $(OBJS5) $(OBJS6) $(OBJS7) -# *Explicit Rules* - -production: ..\bin\$(TARGET).sys +# Explicit Rules ####################################################### -..\bin\$(TARGET).sys: kernel.sys - copy kernel.sys ..\bin - copy kernel.sys ..\bin\$(TARGET).sys - copy kernel.map ..\bin\$(TARGET).map - -kernel.sys: kernel.exe ..\utils\exeflat.exe - $(XUPX) kernel.exe - ..\utils\exeflat kernel.exe kernel.sys 0x60 -S0x10 -S0x8B $(UPXOPT) +all: ..\bin\$(TARGET).sys -kernel.exe: $(TARGET).lnk $(OBJS) $(LIBS) +..\bin\$(TARGET).sys: $(TARGET).lnk $(OBJS) $(LIBS) ..\utils\exeflat.exe $(LINK) @$(TARGET).lnk; - -clobber: clean - -$(RM) kernel.exe kernel.sys status.me - -clean: - -$(RM) *.obj *.bak *.crf *.xrf *.map *.lst *.cod *.err *.lnk + $(XUPX) kernel.exe + ..\utils\exeflat kernel.exe $*.sys 0x60 -S0x10 -S0x8B $(UPXOPT) + copy $*.sys ..\bin\kernel.sys # XXX: This is a very ugly way of linking the kernel, forced upon us by the -# inability of Turbo `make' 2.0 to perform command line redirection. -- ror4 +# inability of Turbo `make' 2.0 to perform command line redirection. --ror4 ECHOTO=..\utils\echoto -$(TARGET).lnk: turboc.cfg makefile ..\mkfiles\generic.mak ..\mkfiles\$(COMPILER).mak - -$(RM) *.lnk - $(ECHOTO) $(TARGET).lnk $(OBJS1)+ - $(ECHOTO) $(TARGET).lnk $(OBJS2)+ - $(ECHOTO) $(TARGET).lnk $(OBJS3)+ - $(ECHOTO) $(TARGET).lnk $(OBJS4)+ - $(ECHOTO) $(TARGET).lnk $(OBJS5)+ - $(ECHOTO) $(TARGET).lnk $(OBJS6)+ - $(ECHOTO) $(TARGET).lnk $(OBJS7) - $(ECHOTO) $(TARGET).lnk kernel.exe - $(ECHOTO) $(TARGET).lnk kernel.map - $(ECHOTO) $(TARGET).lnk $(LIBS) - -# *Individual File Dependencies* -apisupt.obj: apisupt.asm segs.inc $(TARGET).lnk -asmsupt.obj: asmsupt.asm segs.inc $(TARGET).lnk -console.obj: console.asm io.inc $(TARGET).lnk -dosidle.obj: dosidle.asm segs.inc $(TARGET).lnk -entry.obj: entry.asm segs.inc $(HDR)stacks.inc $(TARGET).lnk -execrh.obj: execrh.asm segs.inc $(TARGET).lnk -int2f.obj: int2f.asm segs.inc $(HDR)stacks.inc $(TARGET).lnk -intr.obj: intr.asm segs.inc $(TARGET).lnk -io.obj: io.asm segs.inc $(HDR)stacks.inc $(TARGET).lnk -irqstack.obj: irqstack.asm segs.inc $(TARGET).lnk -kernel.obj: kernel.asm segs.inc ludivmul.inc $(TARGET).lnk -nls_hc.obj: nls_hc.asm segs.inc $(TARGET).lnk -nlssupt.obj: nlssupt.asm segs.inc $(HDR)stacks.inc $(TARGET).lnk -printer.obj: printer.asm io.inc $(TARGET).lnk -procsupt.obj: procsupt.asm segs.inc $(HDR)stacks.inc $(TARGET).lnk -serial.obj: serial.asm io.inc $(TARGET).lnk +$(TARGET).lnk: $(DEPENDS) *.cfg + -$(RM) *.lnk *.obj + $(ECHOTO) $*.lnk $(OBJS1)+ + $(ECHOTO) $*.lnk $(OBJS2)+ + $(ECHOTO) $*.lnk $(OBJS3)+ + $(ECHOTO) $*.lnk $(OBJS4)+ + $(ECHOTO) $*.lnk $(OBJS5)+ + $(ECHOTO) $*.lnk $(OBJS6)+ + $(ECHOTO) $*.lnk $(OBJS7) + $(ECHOTO) $*.lnk kernel + $(ECHOTO) $*.lnk ..\bin\$* + $(ECHOTO) $*.lnk $(LIBS) + +# Individual File Dependencies ######################################### + +apisupt.obj: apisupt.asm segs.inc +asmsupt.obj: asmsupt.asm segs.inc +console.obj: console.asm io.inc +dosidle.obj: dosidle.asm segs.inc +entry.obj: entry.asm segs.inc $(HDR)stacks.inc +execrh.obj: execrh.asm segs.inc +int2f.obj: int2f.asm segs.inc $(HDR)stacks.inc +intr.obj: intr.asm segs.inc +io.obj: io.asm segs.inc $(HDR)stacks.inc +irqstack.obj: irqstack.asm segs.inc +kernel.obj: kernel.asm segs.inc ludivmul.inc +nls_hc.obj: nls_hc.asm segs.inc +nlssupt.obj: nlssupt.asm segs.inc $(HDR)stacks.inc +printer.obj: printer.asm io.inc +procsupt.obj: procsupt.asm segs.inc $(HDR)stacks.inc +serial.obj: serial.asm io.inc HDRS=\ $(HDR)portab.h $(HDR)device.h $(HDR)mcb.h $(HDR)pcb.h \ $(HDR)fat.h $(HDR)fcb.h $(HDR)tail.h $(HDR)time.h $(HDR)process.h \ - $(HDR)dcb.h $(HDR)sft.h $(HDR)cds.h $(HDR)exe.h $(HDR)fnode.h \ - $(HDR)dirmatch.h $(HDR)file.h $(HDR)clock.h $(HDR)kbd.h $(HDR)error.h \ + $(HDR)dcb.h $(HDR)sft.h $(HDR)cds.h $(HDR)exe.h $(HDR)fnode.h \ + $(HDR)dirmatch.h $(HDR)file.h $(HDR)clock.h $(HDR)kbd.h $(HDR)error.h \ $(HDR)version.h dyndata.h HEADERS=$(HDRS) globals.h proto.h INITHEADERS=$(HDRS) init-mod.h init-dat.h -blockio.obj: blockio.c $(HEADERS) $(TARGET).lnk -break.obj: break.c $(HEADERS) $(TARGET).lnk -chario.obj: chario.c $(HEADERS) $(TARGET).lnk -dosfns.obj: dosfns.c $(HEADERS) $(TARGET).lnk -dosnames.obj: dosnames.c $(HEADERS) $(TARGET).lnk -dsk.obj: dsk.c $(HEADERS) $(TARGET).lnk -error.obj: error.c $(HEADERS) $(TARGET).lnk -fatdir.obj: fatdir.c $(HEADERS) $(TARGET).lnk -fatfs.obj: fatfs.c $(HEADERS) $(TARGET).lnk -fattab.obj: fattab.c $(HEADERS) $(TARGET).lnk -fcbfns.obj: fcbfns.c $(HEADERS) $(TARGET).lnk -inthndlr.obj: inthndlr.c $(HEADERS) $(TARGET).lnk -ioctl.obj: ioctl.c $(HEADERS) $(TARGET).lnk -memmgr.obj: memmgr.c $(HEADERS) $(TARGET).lnk -misc.obj: misc.c $(HEADERS) $(TARGET).lnk -lfnapi.obj: lfnapi.c $(HEADERS) $(TARGET).lnk -newstuff.obj: newstuff.c $(HEADERS) $(TARGET).lnk -network.obj: network.c $(HEADERS) $(TARGET).lnk -nls.obj: nls.c $(HEADERS) $(TARGET).lnk -prf.obj: prf.c $(HDR)portab.h $(TARGET).lnk -strings.obj: strings.c $(TARGET).lnk -sysclk.obj: sysclk.c $(HEADERS) $(TARGET).lnk -syspack.obj: syspack.c $(HEADERS) $(TARGET).lnk -systime.obj: systime.c $(HEADERS) $(TARGET).lnk -task.obj: task.c $(HEADERS) $(TARGET).lnk +blockio.obj: blockio.c $(HEADERS) +break.obj: break.c $(HEADERS) +chario.obj: chario.c $(HEADERS) +dosfns.obj: dosfns.c $(HEADERS) +dosnames.obj: dosnames.c $(HEADERS) +dsk.obj: dsk.c $(HEADERS) +error.obj: error.c $(HEADERS) +fatdir.obj: fatdir.c $(HEADERS) +fatfs.obj: fatfs.c $(HEADERS) +fattab.obj: fattab.c $(HEADERS) +fcbfns.obj: fcbfns.c $(HEADERS) +inthndlr.obj: inthndlr.c $(HEADERS) +ioctl.obj: ioctl.c $(HEADERS) +lfnapi.obj: lfnapi.c $(HEADERS) +memmgr.obj: memmgr.c $(HEADERS) +misc.obj: misc.c $(HEADERS) +network.obj: network.c $(HEADERS) +newstuff.obj: newstuff.c $(HEADERS) +nls.obj: nls.c $(HEADERS) +prf.obj: prf.c $(HDR)portab.h +strings.obj: strings.c +sysclk.obj: sysclk.c $(HEADERS) +syspack.obj: syspack.c $(HEADERS) +systime.obj: systime.c $(HEADERS) +task.obj: task.c $(HEADERS) # now the funny stuff :-) # Files in the INIT segment @@ -126,39 +117,49 @@ task.obj: task.c $(HEADERS) $(TARGET).lnk # XXX: Special handling for initialization modules -- this is required because # TC 2.01 cannot handle `#pragma option' like TC 3 can. -- ror4 -config.obj: config.c $(INITHEADERS) $(TARGET).lnk - $(CC) $(INITCFLAGS) $*.c - $(INITPATCH) $*.obj +config.obj: config.c $(INITHEADERS) + $(CC) $(INITCFLAGS) $*.c + $(INITPATCH) $*.obj + +dyninit.obj: dyninit.c $(INITHEADERS) + $(CC) $(INITCFLAGS) $*.c + $(INITPATCH) $*.obj + +initclk.obj: initclk.c $(INITHEADERS) + $(CC) $(INITCFLAGS) $*.c + $(INITPATCH) $*.obj + +initdisk.obj: initdisk.c $(INITHEADERS) + $(CC) $(INITCFLAGS) $*.c + $(INITPATCH) $*.obj -initoem.obj: initoem.c $(INITHEADERS) $(TARGET).lnk - $(CC) $(INITCFLAGS) $*.c - $(INITPATCH) $*.obj +inithma.obj: inithma.c $(INITHEADERS) + $(CC) $(INITCFLAGS) $*.c + $(INITPATCH) $*.obj -main.obj: main.c $(INITHEADERS) $(TARGET).lnk - $(CC) $(INITCFLAGS) $*.c - $(INITPATCH) $*.obj +initoem.obj: initoem.c $(INITHEADERS) + $(CC) $(INITCFLAGS) $*.c + $(INITPATCH) $*.obj -inithma.obj: inithma.c $(INITHEADERS) $(TARGET).lnk - $(CC) $(INITCFLAGS) $*.c - $(INITPATCH) $*.obj +main.obj: main.c $(INITHEADERS) + $(CC) $(INITCFLAGS) $*.c + $(INITPATCH) $*.obj -dyninit.obj: dyninit.c $(INITHEADERS) $(TARGET).lnk - $(CC) $(INITCFLAGS) $*.c - $(INITPATCH) $*.obj +# the string functions for INIT_TEXT -initdisk.obj: initdisk.c $(INITHEADERS) $(TARGET).lnk - $(CC) $(INITCFLAGS) $*.c - $(INITPATCH) $*.obj +iasmsupt.obj: asmsupt.asm + $(NASM) $(NASMFLAGS) -D_INIT asmsupt.asm -o$*.obj -initclk.obj: initclk.c $(INITHEADERS) $(TARGET).lnk - $(CC) $(INITCFLAGS) $*.c - $(INITPATCH) $*.obj +# the printf for INIT_TEXT - yet another special case, this file includes prf.c -#the string functions for INIT_TEXT -iasmsupt.obj: asmsupt.asm $(TARGET).lnk - $(NASM) -D$(COMPILER) -D_INIT $(NASMFLAGS) -f obj -o iasmsupt.obj asmsupt.asm +iprf.obj: iprf.c prf.c $(HDR)portab.h + $(CC) $(INITCFLAGS) $*.c + $(INITPATCH) $*.obj + +######################################################################## + +clean: + -$(RM) *.bak *.cod *.crf *.err *.lnk *.lst *.map *.obj *.xrf -#the printf for INIT_TEXT - yet another special case, this file includes prf.c -iprf.obj: iprf.c prf.c $(HDR)portab.h $(TARGET).lnk - $(CC) $(INITCFLAGS) $*.c - $(INITPATCH) $*.obj +clobber: clean + -$(RM) kernel.exe status.me diff --git a/kernel/msc.cfg b/kernel/msc.cfg new file mode 100644 index 00000000..af2a42c5 --- /dev/null +++ b/kernel/msc.cfg @@ -0,0 +1,5 @@ +-batch -nologo -WX +-Zlp1 +-f- -Osb1V4e -Gsry +-Fc +-I..\hdr diff --git a/kernel/nls.c b/kernel/nls.c index ee5455ab..6810dbe3 100644 --- a/kernel/nls.c +++ b/kernel/nls.c @@ -502,7 +502,7 @@ VOID DosUpFString(char FAR * str) COUNT DosGetData(int subfct, UWORD cp, UWORD cntry, UWORD bufsize, VOID FAR * buf) { - struct nlsPackage FAR *nls; /* NLS package to use to return the info from */ + struct nlsPackage FAR *nls; /* NLS package to use to return the info from */ log(("NLS: GetData(): subfct=%x, cp=%u, cntry=%u, bufsize=%u\n", subfct, cp, cntry, bufsize)); @@ -513,19 +513,21 @@ COUNT DosGetData(int subfct, UWORD cp, UWORD cntry, UWORD bufsize, return DE_INVLDFUNC; /* nls := NLS package of cntry/codepage */ - if ((nls = searchPackage(cp, cntry)) == NULL - || (nls->flags & NLS_FLAG_DIRECT_GETDATA) == 0) + if ((nls = searchPackage(cp, cntry)) != NULL) { - /* If the NLS pkg is not loaded into memory or the - direct-access flag is disabled, the request must - be passed through MUX */ - return (subfct == NLS_DOS_38) - ? mux38(nls->cp, nls->cntry, bufsize, buf) - : mux65(subfct, nls->cp, nls->cntry, bufsize, buf); + /* matching NLS package found */ + if (nls->flags & NLS_FLAG_DIRECT_GETDATA) + /* Direct access to the data */ + return nlsGetData(nls, subfct, buf, bufsize); + cp = nls->cp; + cntry = nls->cntry; } - /* Direct access to the data */ - return nlsGetData(nls, subfct, buf, bufsize); + /* If the NLS pkg is not loaded into memory or the direct-access + flag is disabled, the request must be passed through MUX */ + return (subfct == NLS_DOS_38) + ? mux38(cp, cntry, bufsize, buf) + : mux65(subfct, cp, cntry, bufsize, buf); } /* diff --git a/kernel/procsupt.asm b/kernel/procsupt.asm index 432972c4..6fc3352a 100644 --- a/kernel/procsupt.asm +++ b/kernel/procsupt.asm @@ -47,17 +47,12 @@ segment HMA_TEXT ; ; void exec_user(iregs far *irp, int disable_a20) ; - global _exec_user + global _exec_user _exec_user: - -; PUSH$ALL -; mov ds,[_DGROUP_] -; cld -; -; -; - pop ax ; return address (unused) - +%ifndef WATCOM +; exec_user declared with attribute `aborts' + pop ax ; return address (unused) +%endif pop ax ; irp (user ss:sp) pop dx pop cx ; disable A20? @@ -280,10 +275,13 @@ _spawn_int23: ; prepare to call process 0 (the shell) from P_0() in C - global reloc_call_p_0 + global reloc_call_p_0 reloc_call_p_0: +%ifndef WATCOM +; reloc_call_p_0 declared with attribute `aborts' pop ax ; return address (32-bit, unused) pop ax +%endif pop ax ; fetch parameter 0 (32-bit) from the old stack pop dx mov ds,[cs:_DGROUP_] @@ -293,4 +291,9 @@ reloc_call_p_0: sti push dx ; pass parameter 0 onto the new stack push ax - call _P_0 ; no return, allow parameter fetch from C +%ifndef WATCOM + call _P_0 ; no return, allow parameter fetch from C +%else +; P_0 declared with attribute `aborts' + jmp _P_0 ; no return, allow parameter fetch from C +%endif diff --git a/kernel/proto.h b/kernel/proto.h index 524d5a8e..f72c8981 100644 --- a/kernel/proto.h +++ b/kernel/proto.h @@ -132,9 +132,14 @@ VOID ASMCFUNC DosIdle_int(void); int ParseDosName(const char *, char *, BOOL); /* error.c */ + VOID dump(void); VOID panic(BYTE * s); VOID fatal(BYTE * err_msg); +#ifdef __WATCOMC__ +# pragma aux panic aborts +# pragma aux fatal aborts +#endif /* fatdir.c */ VOID dir_init_fnode(f_node_ptr fnp, CLUSTER dirstart); @@ -225,21 +230,20 @@ void FcbCloseAll(void); UBYTE FcbFindFirstNext(xfcb FAR * lpXfcb, BOOL First); /* intr.asm */ -COUNT ASMPASCAL res_DosExec(COUNT mode, exec_blk * ep, BYTE * lp); -UCOUNT ASMPASCAL res_read(int fd, void *buf, UCOUNT count); + +int ASMPASCAL res_DosExec(int mode, exec_blk *, PCStr); +unsigned ASMPASCAL res_read(int fd, void *buf, unsigned count); #ifdef __WATCOMC__ -#pragma aux (pascal) res_DosExec modify exact [ax bx dx es] -#pragma aux (pascal) res_read modify exact [ax bx cx dx] +# pragma aux (pascal) res_DosExec modify exact [ax bx dx es] +# pragma aux (pascal) res_read modify exact [ax bx cx dx] #endif /* ioctl.c */ COUNT DosDevIOctl(lregs * r); /* memmgr.c */ -seg far2para(VOID FAR * p); -seg long2para(ULONG size); -void FAR *add_far(void FAR * fp, unsigned off); -VOID FAR *adjust_far(const void FAR * fp); + +VFP adjust_far(CVFP); COUNT DosMemAlloc(UWORD size, COUNT mode, seg * para, UWORD * asize); COUNT DosMemLargest(UWORD * size); COUNT DosMemFree(UWORD para); @@ -364,12 +368,16 @@ const UWORD *is_leap_year_monthdays(UWORD year); UWORD DaysFromYearMonthDay(UWORD Year, UWORD Month, UWORD DayOfMonth); /* task.c */ -VOID new_psp(seg para, seg cur_psp); -VOID child_psp(seg para, seg cur_psp, int psize); -VOID return_user(void); + +void new_psp(seg_t para, seg_t cur_psp); +void child_psp(seg_t para, seg_t cur_psp, seg_t beyond); +void return_user(void); COUNT DosExec(COUNT mode, exec_blk FAR * ep, BYTE FAR * lp); ULONG SftGetFsize(int sft_idx); VOID InitPSP(VOID); +#ifdef __WATCOMC__ +# pragma aux return_user aborts +#endif /* newstuff.c */ int SetJFTSize(UWORD nHandles); @@ -391,7 +399,11 @@ UWORD get_machine_name(BYTE FAR * netname); VOID set_machine_name(BYTE FAR * netname, UWORD name_num); /* procsupt.asm */ -VOID ASMCFUNC exec_user(iregs FAR * irp, int disable_a20); + +void ASMCFUNC exec_user(iregs FAR *, int disable_a20); +#ifdef __WATCOMC__ +# pragma aux (cdecl) exec_user aborts +#endif /* new by TE */ @@ -403,5 +415,4 @@ VOID ASMCFUNC exec_user(iregs FAR * irp, int disable_a20); ASSERT_CONST( (BYTE FAR *)x->fcb_ext - (BYTE FAR *)x->fcbname == 8) */ -#define ASSERT_CONST(x) { typedef struct { char _xx[x ? 1 : -1]; } xx ; } - +#define ASSERT_CONST(x) { typedef struct { char _[(x) ? 1 : -1]; } _; } diff --git a/kernel/segs.inc b/kernel/segs.inc index ba6e123a..5e88c19c 100644 --- a/kernel/segs.inc +++ b/kernel/segs.inc @@ -59,8 +59,12 @@ segment _FIXED_DATA class=FDATA align=16 segment _BSS class=BSS align=2 segment _DATA class=DATA align=2 segment _DATAEND class=DATA align=1 -;for WATCOM +%ifdef MSC +segment CONST class=CONST align=2 +%else segment CONST class=DATA align=2 +%endif +;for WATCOM segment CONST2 class=DATA align=2 ;for MSC segment DCONST class=DCONST align=2 diff --git a/kernel/task.c b/kernel/task.c index 2a173bb1..1d5b6bd1 100644 --- a/kernel/task.c +++ b/kernel/task.c @@ -34,8 +34,6 @@ static BYTE *RcsId = "$Id$"; #endif -#define toupper(c) ((c) >= 'a' && (c) <= 'z' ? (c) + ('A' - 'a') : (c)) - #define LOADNGO 0 #define LOAD 1 #define OVERLAY 3 @@ -49,6 +47,7 @@ static BYTE *RcsId = #define ExeHeader (*(exe_header *)(SecPathName + 0)) #define TempExeBlock (*(exec_blk *)(SecPathName + sizeof(exe_header))) #define Shell (SecPathName + sizeof(exe_header) + sizeof(exec_blk)) +#define sizeofShell (sizeof SecPathName - sizeof(exe_header) - sizeof(exec_blk)) #ifdef __TURBOC__ /* this is a Borlandism and doesn't work elsewhere */ #if sizeof(SecPathName) < sizeof(exe_header) + sizeof(exec_blk) + NAMEMAX @@ -56,20 +55,17 @@ static BYTE *RcsId = #endif #endif -#define CHUNK 32256 -#define MAXENV 32768u -#define ENV_KEEPFREE 83 /* keep unallocated by environment variables */ - /* The '65' added to nEnvSize does not cover the additional stuff: - + 2 bytes: number of strings - + 80 bytes: maximum absolute filename - + 1 byte: '\0' - -- 1999/04/21 ska */ +#define CHUNK 32256u /* =8000h-512; this value allows to combine + in one int value negative error codes + and positive read counters + */ +#define MAXENV 32768u /* maximum environment size */ intvec getvec(unsigned char intno) { intvec iv; disable(); - iv = *(intvec FAR *)MK_FP(0,4 * (intno)); + iv = *MK_PTR(intvec, 0, 4 * intno); enable(); return iv; } @@ -77,13 +73,13 @@ intvec getvec(unsigned char intno) void setvec(unsigned char intno, intvec vector) { disable(); - *(intvec FAR *)MK_FP(0,4 * intno) = vector; + *MK_PTR(intvec, 0, 4 * intno) = vector; enable(); } ULONG SftGetFsize(int sft_idx) { - sft FAR *s = idx_to_sft(sft_idx); + const sft FAR *s = idx_to_sft(sft_idx); /* Get the SFT block that contains the SFT */ if (FP_OFF(s) == (size_t) -1) @@ -99,258 +95,243 @@ ULONG SftGetFsize(int sft_idx) return dos_getfsize(s->sft_status); } -STATIC COUNT ChildEnv(exec_blk * exp, UWORD * pChildEnvSeg, char far * pathname) +/* create a new environment for the process */ +STATIC int ChildEnv(seg_t env_seg, seg_t *penv_seg, const char far *path) { - BYTE FAR *pSrc; - BYTE FAR *pDest; - UWORD nEnvSize; - COUNT RetCode; -/* UWORD MaxEnvSize; not used -- 1999/04/21 ska */ - psp FAR *ppsp = MK_FP(cu_psp, 0); - - /* create a new environment for the process */ - /* copy parent's environment if exec.env_seg == 0 */ - - pSrc = exp->exec.env_seg ? - MK_FP(exp->exec.env_seg, 0) : MK_FP(ppsp->ps_environ, 0); + size_t env_sz, path_sz; + int rc; -#if 0 /* Every process requires an environment because of argv[0] - -- 1999/04/21 ska */ - */if (!pSrc) /* no environment to copy */ - { - *pChildEnvSeg = 0; - return SUCCESS; - } -#endif + -- 1999/04/21 ska + */ + + /* make complete pathname */ + if ((rc = truename(path, PriPathName, CDS_MODE_SKIP_PHYSICAL)) < SUCCESS) + return rc; - nEnvSize = 1; - /* This loop had not counted the very last '\0' - -- 1999/04/21 ska */ - if (pSrc) - { /* if no environment is available, one byte is required */ + /* get parent's environment if exec.env_seg == 0 */ + if (env_seg == 0) + env_seg = MK_SEG_PTR(const psp, cu_psp)->ps_environ; - for (nEnvSize = 0;; nEnvSize++) + /* count size of environment */ + path_sz = strlen(PriPathName) + 5; + env_sz = 0; + if (env_seg && *MK_PTR(const char, env_seg, 0)) + { + do { - /* Test env size and abort if greater than max */ - if (nEnvSize >= MAXENV - ENV_KEEPFREE) + env_sz++; + if (env_sz + path_sz > MAXENV) return DE_INVLDENV; - - if (*(UWORD FAR *) (pSrc + nEnvSize) == 0) - break; - } - nEnvSize += 2; /* account for trailing \0\0 */ + } while (*MK_PTR(const UWORD, env_seg, env_sz)); } - /* allocate enough space for env + path */ - if ((RetCode = DosMemAlloc((nEnvSize + ENV_KEEPFREE + 15)/16, - mem_access_mode, pChildEnvSeg, - NULL /*(UWORD FAR *) MaxEnvSize ska */ )) < 0) - return RetCode; - pDest = MK_FP(*pChildEnvSeg + 1, 0); - - /* fill the new env and inform the process of its */ - /* location throught the psp */ - - /* copy the environment */ - if (pSrc) + /* allocate space for env + path */ { - fmemcpy(pDest, pSrc, nEnvSize); - pDest += nEnvSize; + UWORD tmp; + if ((rc = DosMemAlloc((env_sz + path_sz + 15) / 16, + mem_access_mode, penv_seg, &tmp)) != SUCCESS) + return rc; } - else - *pDest++ = '\0'; /* create an empty environment */ - - /* initialize 'extra strings' count */ - *((UWORD FAR *) pDest) = 1; - pDest += sizeof(UWORD) / sizeof(BYTE); - - /* copy complete pathname */ - if ((RetCode = truename(pathname, PriPathName, CDS_MODE_SKIP_PHYSICAL)) < SUCCESS) { - return RetCode; + seg_t dst_seg = *penv_seg + 1; + + /* enviornment contains: + - 0 or more ASCIIZ strings (with variable definitions); + - empty ASCIIZ string (one null character); + - 16-bit counter (usually 1); + - ASCIIZ string with path. + */ + /* UNDOCUMENTED: with none variables before empty ASCIIZ string, + environment should get additional null character (ie. empty + environment contains two null characters). --avb + */ + fmemcpy(MK_SEG_PTR(char, dst_seg), MK_SEG_PTR(const char, env_seg), env_sz); + *MK_PTR(UWORD, dst_seg, env_sz) = 0; + *MK_PTR(UWORD, dst_seg, env_sz + 2) = 1; + fstrcpy(MK_PTR(char, dst_seg, env_sz + 4), PriPathName); } - fstrcpy(pDest, PriPathName); - - /* Theoretically one could either: - + resize the already allocated block to best-fit behind the pathname, or - + generate the filename into a temporary buffer to allocate only the - minimum required environment -- 1999/04/21 ska */ - return SUCCESS; } -/* The following code is 8086 dependant */ -void new_psp(seg para, seg cur_psp) +/* The following code is 8086 dependant */ +void new_psp(seg_t para, seg_t cur_psp) { - psp FAR *p = MK_FP(para, 0); - - fmemcpy(p, MK_FP(cur_psp, 0), sizeof(psp)); - - /* terminate address */ - p->ps_isv22 = getvec(0x22); - /* break address */ - p->ps_isv23 = getvec(0x23); - /* critical error address */ - p->ps_isv24 = getvec(0x24); - /* parent psp segment set to 0 (see RBIL int21/ah=26) */ - p->ps_parent = 0; + psp _seg *p = MK_SEG_PTR(psp, para); + + fmemcpy(p, MK_SEG_PTR(psp, cur_psp), sizeof(psp)); + + /* initialize all entries and exits */ + p->ps_exit = 0x20cd; /* CP/M-like exit point: */ + /* INT 20 opcode */ + /* CP/M-like entry point: */ + p->ps_farcall = 0x9a; /* FAR CALL opcode... */ + p->ps_reentry = MK_FP(0xf01d,0xfef0); /* ...entry address */ + + /* entry address should point to 0:c0 (INT 30 vector), but + low word of ps_reentry should also contain "size of first + segment for .COM file" while preserving the far call; + in MS-DOS this is F01D:FEF0 --avb */ + + p->ps_unix[0] = 0xcd; /* unix style call: */ + p->ps_unix[1] = 0x21; /* INT 21/RETF opcodes */ + p->ps_unix[2] = 0xcb; + + /* parent-child relationships */ + p->ps_prevpsp = (VFP)-1l; /* previous psp address */ + + p->ps_isv22 = getvec(0x22); /* terminate handler */ + p->ps_isv23 = getvec(0x23); /* break handler */ + p->ps_isv24 = getvec(0x24); /* critical error handler */ + + /* File System parameters */ + p->ps_maxfiles = sizeof p->ps_files; /* size of file table */ + p->ps_filetab = p->ps_files; /* file table address */ } -void child_psp(seg para, seg cur_psp, int psize) +/* !!! cur_psp always equal to cu_psp --avb */ +void child_psp(seg_t para, seg_t cur_psp, seg_t beyond) { - psp FAR *p = MK_FP(para, 0); - psp FAR *q = MK_FP(cur_psp, 0); - int i; + psp _seg *p; new_psp(para, cur_psp); + p = MK_SEG_PTR(psp, para); + + /* parent-child relationships */ + p->ps_parent = cu_psp; /* parent psp segment */ + + /* Environment and memory useage parameters */ + p->ps_size = beyond; /* segment of memory beyond */ + /* memory allocated to program */ - /* Now for parent-child relationships */ - /* parent psp segment */ - p->ps_parent = cu_psp; - /* previous psp pointer */ - p->ps_prevpsp = q; - - /* Environment and memory useage parameters */ - /* memory size in paragraphs */ - p->ps_size = psize; - - /* File System parameters */ - /* maximum open files */ - p->ps_maxfiles = 20; - fmemset(p->ps_files, 0xff, 20); - - /* open file table pointer */ - p->ps_filetab = p->ps_files; - - /* clone the file table -- 0xff is unused */ - for (i = 0; i < 20; i++) - if (CloneHandle(i) >= 0) - p->ps_files[i] = q->ps_filetab[i]; - - /* first command line argument */ - p->ps_fcb1.fcb_drive = 0; - fmemset(p->ps_fcb1.fcb_fname, ' ', FNAME_SIZE + FEXT_SIZE); - /* second command line argument */ - p->ps_fcb2.fcb_drive = 0; - fmemset(p->ps_fcb2.fcb_fname, ' ', FNAME_SIZE + FEXT_SIZE); - - /* local command line */ - p->ps_cmd.ctCount = 0; - p->ps_cmd.ctBuffer[0] = 0xd; /* command tail */ + /* File System parameters */ + { + psp _seg *q = MK_SEG_PTR(psp, cur_psp); + int i; + /* clone the file table, 0xff=unused */ + for (i = 0; i < sizeof p->ps_files; i++) + p->ps_files[i] = CloneHandle(i) != SUCCESS ? 0xff : q->ps_filetab[i]; + } } -STATIC UBYTE chkdrv(unsigned drive) /* from FCB: 0 = default, 1 = A:, ... */ +struct cds FAR *get_cds1(unsigned drv) { - if (drive) - drive--; /* 0 = A:, 1 = B:, ... */ - else - drive = default_drive; - return get_cds(drive) ? 0 : 0xff; /* return 0 if drive is valid, else 0xff */ + if (drv-- == 0) /* 0 = A:, 1 = B:, ... */ + drv = default_drive; + return get_cds(drv); } -STATIC UWORD patchPSP(UWORD pspseg, UWORD envseg, exec_blk FAR * exb, - BYTE FAR * fnam) +STATIC void makePSP(seg_t pspseg, seg_t envseg, size_t asize, const char FAR * path) { - psp FAR *psp; - mcb FAR *pspmcb; - int i; - BYTE FAR *np; - - pspmcb = MK_FP(pspseg, 0); - ++pspseg; - psp = MK_FP(pspseg, 0); - - /* complete the psp by adding the command line and FCBs */ - fmemcpy(&psp->ps_cmd, exb->exec.cmd_line, sizeof(CommandTail)); - if (FP_OFF(exb->exec.fcb_1) != 0xffff) - { - fmemcpy(&psp->ps_fcb1, exb->exec.fcb_1, 16); - fmemcpy(&psp->ps_fcb2, exb->exec.fcb_2, 16); - } + psp _seg *p = MK_SEG_PTR(psp, pspseg); + mcb _seg *pspmcb = MK_SEG_PTR(mcb, FP_SEG(p) - 1); - /* identify the mcb as this functions' */ - pspmcb->m_psp = pspseg; - /* Patch in environment segment, if present, also adjust its MCB */ - if (envseg) - { - ((mcb FAR *) MK_FP(envseg, 0))->m_psp = pspseg; - envseg++; - } - psp->ps_environ = envseg; + /* identify the mcb as this functions' */ + pspmcb->m_psp = FP_SEG(p); - /* use the file name less extension - left adjusted and */ - np = fnam; - for (;;) + /* copy the file name less extension into MCB */ { - switch (*fnam++) + const char FAR *np; + int i; + for (np = path;;) /* find program name after path */ { - case '\0': - goto set_name; - case ':': - case '/': - case '\\': - np = fnam; + char ch = *path; + if (ch == '\0') + break; + path++; + if (ch == ':' || ch == '\\' || ch == '/') + np = path; /* remember position after path */ } + i = 0; + do /* extract program name */ + { + UBYTE ch = *np; + if (ch == '.' || ch == '\0') + { + pspmcb->m_name[i] = '\0'; + break; + } + if (ch >= 'a' && ch <= 'z') + ch -= (UBYTE)('a' - 'A'); + pspmcb->m_name[i] = ch; /* copy name, without extension */ + i++, np++; + } while (i < 8); } -set_name: - for (i = 0; i < 8 && np[i] != '.' && np[i] != '\0'; i++) + + setvec(0x22, (intvec)MK_FP(user_r->CS, user_r->IP)); + child_psp(FP_SEG(p), cu_psp, FP_SEG(p) + asize); + + /* Patch in env segment, if present, also adjust its MCB */ + if (envseg) { - pspmcb->m_name[i] = toupper(np[i]); + MK_SEG_PTR(mcb, envseg)->m_psp = FP_SEG(p); + envseg++; } - if (i < 8) - pspmcb->m_name[i] = '\0'; - - /* return value: AX value to be passed based on FCB values */ - return chkdrv(psp->ps_fcb1.fcb_drive) | - (chkdrv(psp->ps_fcb2.fcb_drive) << 8); + p->ps_environ = envseg; } -int load_transfer(UWORD ds, exec_blk *exp, UWORD fcbcode, COUNT mode) +static void load_transfer(seg_t ds, exec_blk *ep, int mode) { - psp FAR *p = MK_FP(ds, 0); - psp FAR *q = MK_FP(cu_psp, 0); - - /* Transfer control to the executable */ - p->ps_parent = cu_psp; - p->ps_prevpsp = q; - q->ps_stack = (BYTE FAR *)user_r; + UWORD fcbcode; + psp _seg *p = MK_SEG_PTR(psp, ds); + { + psp _seg *q = MK_SEG_PTR(psp, cu_psp); + p->ps_parent = FP_SEG(q); + p->ps_prevpsp = q; + q->ps_stack = (BYTE FAR *)user_r; + } user_r->FLAGS &= ~FLG_CARRY; - - cu_psp = ds; + + cu_psp = FP_SEG(p); /* process dta */ dta = &p->ps_cmd; - + + /* complete the psp by adding the command line and FCBs */ + /* UNDOCUMENTED: MS-DOS copies sizeof(CommandTail) bytes without + checking memory contents and fixing wrong (>7Fh) length field; + FCBs also copied without checking address validness --avb + */ + fmemcpy(&p->ps_fcb1, ep->exec.fcb_1, 12); /* drive+name+ext */ + fmemcpy(&p->ps_fcb2, ep->exec.fcb_2, 12); + fmemcpy(&p->ps_cmd, ep->exec.cmd_line, sizeof(CommandTail)); + + /* AX value to be passed based on FCB values */ + fcbcode = (get_cds1(p->ps_fcb1.fcb_drive) ? 0 : 0xff) | + (get_cds1(p->ps_fcb2.fcb_drive) ? 0 : 0xff00); + + /* Transfer control to the executable */ if (mode == LOADNGO) { - iregs FAR *irp; - /* build the user area on the stack */ - irp = (iregs FAR *)(exp->exec.stack - sizeof(iregs)); - + iregs FAR *irp = (iregs FAR *)(ep->exec.stack - sizeof(iregs)); + /* start allocating REGs (as in MS-DOS - some demos expect them so --LG) */ /* see http://www.beroset.com/asm/showregs.asm */ - irp->DX = irp->ES = irp->DS = ds; - irp->CS = FP_SEG(exp->exec.start_addr); - irp->SI = irp->IP = FP_OFF(exp->exec.start_addr); - irp->DI = FP_OFF(exp->exec.stack); + irp->AX = + irp->BX = fcbcode; + irp->DX = + irp->ES = + irp->DS = FP_SEG(p); + irp->CS = FP_SEG(ep->exec.start_addr); + irp->SI = + irp->IP = FP_OFF(ep->exec.start_addr); + irp->DI = FP_OFF(ep->exec.stack); irp->BP = 0x91e; /* this is more or less random but some programs expect 0x9 in the high byte of BP!! */ - irp->AX = irp->BX = fcbcode; irp->CX = 0xFF; irp->FLAGS = 0x200; - + if (InDOS) --InDOS; exec_user(irp, 1); - - /* We should never be here - fatal("KERNEL RETURNED!!!"); */ + + /* We should never be here + panic("KERNEL RETURNED!!!"); */ } + /* mode == LOAD */ - exp->exec.stack -= 2; - *((UWORD FAR *)(exp->exec.stack)) = fcbcode; - return SUCCESS; + ep->exec.stack -= sizeof(UWORD); + *(UWORD FAR *)ep->exec.stack = fcbcode; } /* Now find out how many paragraphs are available @@ -413,10 +394,8 @@ STATIC int ExecMemAlloc(UWORD size, seg *para, UWORD *asize) COUNT DosComLoader(BYTE FAR * namep, exec_blk * exp, COUNT mode, COUNT fd) { UWORD mem; - UWORD env, asize = 0; - - { - UWORD com_size; + UWORD env, asize; + UWORD com_size; { ULONG com_size_long = SftGetFsize(fd); /* maximally 64k - 256 bytes stack - @@ -436,20 +415,15 @@ COUNT DosComLoader(BYTE FAR * namep, exec_blk * exp, COUNT mode, COUNT fd) DosUmbLink(1); /* link in UMB's */ } - rc = ChildEnv(exp, &env, namep); - /* COMFILES will always be loaded in largest area. is that true TE */ /* yes, see RBIL, int21/ah=48 -- Bart */ - - if (rc == SUCCESS) - rc = ExecMemLargest(&asize, com_size); - - if (rc == SUCCESS) - /* Allocate our memory and pass back any errors */ - rc = ExecMemAlloc(asize, &mem, &asize); - - if (rc != SUCCESS) - DosMemFree(env); + if ((rc = ChildEnv(exp->exec.env_seg, &env, namep)) == SUCCESS) + { + if ((rc = ExecMemLargest(&asize, com_size)) != SUCCESS || + /* Allocate our memory and pass back any errors */ + (rc = ExecMemAlloc(asize, &mem, &asize)) != SUCCESS) + DosMemFree(env); + } if (mode & 0x80) { @@ -461,46 +435,27 @@ COUNT DosComLoader(BYTE FAR * namep, exec_blk * exp, COUNT mode, COUNT fd) if (rc != SUCCESS) return rc; - ++mem; - } - else - mem = exp->load.load_seg; - } - #ifdef DEBUG printf("DosComLoader. Loading '%S' at %04x\n", namep, mem); #endif - /* Now load the executable */ - { - BYTE FAR *sp; - - if (mode == OVERLAY) /* memory already allocated */ - sp = MK_FP(mem, 0); - else /* test the filesize against the allocated memory */ - sp = MK_FP(mem, sizeof(psp)); - - /* MS DOS always only loads the very first 64KB - sizeof(psp) bytes. - -- 1999/04/21 ska */ + ++mem; + } + /* Now load the executable */ /* rewind to start */ SftSeek(fd, 0, 0); + /* MS DOS always only loads the very first 64KB - sizeof(psp) bytes. + -- 1999/04/21 ska */ /* read everything, but at most 64K - sizeof(PSP) */ - DosRWSft(fd, 0xff00, sp, XFR_READ); + /* !!! should be added check for reading success --avb */ + DosRWSft(fd, 0xff00, mode == OVERLAY /* memory already allocated */ + ? MK_FP(exp->load.load_seg, 0) + : MK_FP(mem, sizeof(psp)), XFR_READ); DosCloseSft(fd, FALSE); - } - if (mode == OVERLAY) - return SUCCESS; - + if (mode != OVERLAY) { - UWORD fcbcode; - psp FAR *p; - - /* point to the PSP so we can build it */ - setvec(0x22, (intvec)MK_FP(user_r->CS, user_r->IP)); - child_psp(mem, cu_psp, mem + asize); - - fcbcode = patchPSP(mem - 1, env, exp, namep); + makePSP(mem, env, asize, namep); /* set asize to end of segment */ if (asize > 0x1000) asize = 0x1000; @@ -510,27 +465,21 @@ COUNT DosComLoader(BYTE FAR * namep, exec_blk * exp, COUNT mode, COUNT fd) /* CP/M compatibility--size of first segment for .COM files while preserving the far call to 0:00c0 + copy in HMA at ffff:00d0 */ - p = MK_FP(mem, 0); - p->ps_reentry = MK_FP(0xc - asize, asize << 4); + MK_SEG_PTR(psp, mem)->ps_reentry = MK_FP(0xc - asize, asize << 4); asize <<= 4; asize += 0x10e; exp->exec.stack = MK_FP(mem, asize); exp->exec.start_addr = MK_FP(mem, 0x100); - *((UWORD FAR *) MK_FP(mem, asize)) = (UWORD) 0; - load_transfer(mem, exp, fcbcode, mode); + *MK_PTR(UWORD, mem, asize) = 0; + load_transfer(mem, exp, mode); } return SUCCESS; } -VOID return_user(void) +void return_user(void) { - psp FAR *p, FAR * q; - REG COUNT i; - iregs FAR *irp; -/* long j;*/ - /* restore parent */ - p = MK_FP(cu_psp, 0); + psp _seg *p = MK_SEG_PTR(psp, cu_psp); /* When process returns - restore the isv */ setvec(0x22, p->ps_isv22); @@ -544,34 +493,31 @@ VOID return_user(void) if (!tsr) { + REG COUNT i; network_redirector(REM_CLOSEALL); for (i = 0; i < p->ps_maxfiles; i++) { DosClose(i); } FcbCloseAll(); - FreeProcessMem(cu_psp); + FreeProcessMem(FP_SEG(p)); } - cu_psp = p->ps_parent; - q = MK_FP(cu_psp, 0); - - irp = (iregs FAR *) q->ps_stack; - - irp->CS = FP_SEG(p->ps_isv22); - irp->IP = FP_OFF(p->ps_isv22); + { + iregs FAR *irp = (iregs FAR *)MK_SEG_PTR(psp, cu_psp = p->ps_parent)->ps_stack; + irp->CS = FP_SEG(p->ps_isv22); + irp->IP = FP_OFF(p->ps_isv22); - if (InDOS) - --InDOS; - exec_user((iregs FAR *) q->ps_stack, 0); + if (InDOS) + --InDOS; + exec_user(irp, 0); + } } COUNT DosExeLoader(BYTE FAR * namep, exec_blk * exp, COUNT mode, COUNT fd) { - UWORD mem, env, start_seg, asize = 0; - UWORD exe_size; - { - UWORD image_size; + UWORD mem, env, start_seg, asize; + UWORD image_size; /* compute image size by removing the offset from the */ /* number pages scaled to bytes plus the remainder and */ @@ -581,10 +527,11 @@ COUNT DosExeLoader(BYTE FAR * namep, exec_blk * exp, COUNT mode, COUNT fd) return DE_INVLDDATA; /* we're not able to get >=1MB in dos memory */ image_size = ExeHeader.exPages * 32 - ExeHeader.exHeaderSize; - /* We should not attempt to allocate - memory if we are overlaying the current process, because the new - process will simply re-use the block we already have allocated. - Jun 11, 2000 - rbc */ + /* We should not attempt to allocate memory if we are overlaying + the current process, because the new process will simply re-use + the block we already have allocated. This was causing execl() to + fail in applications which use it to overlay (replace) the current + exe file with a new one. Jun 11, 2000 --rbc */ if ((mode & 0x7f) != OVERLAY) { @@ -592,10 +539,6 @@ COUNT DosExeLoader(BYTE FAR * namep, exec_blk * exp, COUNT mode, COUNT fd) UBYTE orig_mem_access = mem_access_mode; COUNT rc; - /* and finally add in the psp size */ - image_size += sizeof(psp) / 16; /*TE 03/20/01 */ - exe_size = image_size + ExeHeader.exMinAlloc; - /* Clone the environement and create a memory arena */ if (mode & 0x80) { @@ -603,38 +546,35 @@ COUNT DosExeLoader(BYTE FAR * namep, exec_blk * exp, COUNT mode, COUNT fd) mem_access_mode |= 0x80; } - rc = ChildEnv(exp, &env, namep); - - if (rc == SUCCESS) + if ((rc = ChildEnv(exp->exec.env_seg, &env, namep)) == SUCCESS) + { + image_size += sizeof(psp) / 16; /*TE 03/20/01 */ /* Now find out how many paragraphs are available */ - rc = ExecMemLargest(&asize, exe_size); - - exe_size = image_size + ExeHeader.exMaxAlloc; - /* second test is for overflow (avoiding longs) -- - exMaxAlloc can be high */ - if (exe_size > asize || exe_size < image_size) - exe_size = asize; - - /* TE if ExeHeader.exMinAlloc == ExeHeader.exMaxAlloc == 0, - DOS will allocate the largest possible memory area - and load the image as high as possible into it. - discovered (and after that found in RBIL), when testing NET */ - - if ((ExeHeader.exMinAlloc | ExeHeader.exMaxAlloc) == 0) - exe_size = asize; - - /* Allocate our memory and pass back any errors */ - if (rc == SUCCESS) - rc = ExecMemAlloc(exe_size, &mem, &asize); - - if (rc != SUCCESS) - DosMemFree(env); + if ((rc = ExecMemLargest(&asize, image_size + ExeHeader.exMinAlloc)) == SUCCESS) + { + unsigned max_size = image_size + ExeHeader.exMaxAlloc; + /* second test is for overflow (avoiding longs) -- + exMaxAlloc can be high */ + if (max_size > asize || max_size < image_size || + /* TE if ExeHeader.exMinAlloc == ExeHeader.exMaxAlloc == 0, + DOS will allocate the largest possible memory area + and load the image as high as possible into it. + discovered (and after that found in RBIL), when testing NET */ + (ExeHeader.exMinAlloc | ExeHeader.exMaxAlloc) == 0) + max_size = asize; + /* Allocate our memory and pass back any errors */ + rc = ExecMemAlloc(max_size, &mem, &asize); + } + if (rc != SUCCESS) + DosMemFree(env); + } if (mode & 0x80) { mem_access_mode = orig_mem_access; /* restore old situation */ DosUmbLink(UMBstate); /* restore link state */ } + if (rc != SUCCESS) return rc; @@ -643,20 +583,7 @@ COUNT DosExeLoader(BYTE FAR * namep, exec_blk * exp, COUNT mode, COUNT fd) #ifdef DEBUG printf("DosExeLoader. Loading '%S' at %04x\n", namep, mem); #endif - /* memory found large enough - continue processing */ - ++mem; - -/* /// Added open curly brace and "else" clause. We should not attempt - to allocate memory if we are overlaying the current process, because - the new process will simply re-use the block we already have allocated. - This was causing execl() to fail in applications which use it to - overlay (replace) the current exe file with a new one. - Jun 11, 2000 - rbc */ - } - else /* !!OVERLAY */ - { - mem = exp->load.load_seg; } /* Now load the executable */ @@ -665,75 +592,57 @@ COUNT DosExeLoader(BYTE FAR * namep, exec_blk * exp, COUNT mode, COUNT fd) { if (mode != OVERLAY) { - DosMemFree(--mem); + DosMemFree(mem); DosMemFree(env); } return DE_INVLDDATA; } /* create the start seg for later computations */ - start_seg = mem; - exe_size = image_size; + start_seg = exp->load.load_seg; if (mode != OVERLAY) { - exe_size -= sizeof(psp) / 16; - start_seg += sizeof(psp) / 16; - if (exe_size > 0 && (ExeHeader.exMinAlloc | ExeHeader.exMaxAlloc) == 0) - { - mcb FAR *mp = MK_FP(mem - 1, 0); - + start_seg = mem + 1 + sizeof(psp) / 16; + if ((ExeHeader.exMinAlloc | ExeHeader.exMaxAlloc) == 0) /* then the image should be placed as high as possible */ - start_seg += mp->m_size - image_size; - } + start_seg += MK_SEG_PTR(const mcb, mem)->m_size - image_size; + image_size -= sizeof(psp) / 16; } - } /* read in the image in 32256 chunks */ { - int nBytesRead, toRead = CHUNK; - seg sp = start_seg; - - while (1) + seg_t sp = start_seg; + do { - if (exe_size < CHUNK/16) - toRead = exe_size*16; - nBytesRead = (int)DosRWSft(fd, toRead, MK_FP(sp, 0), XFR_READ); - if (nBytesRead < toRead || exe_size <= CHUNK/16) + int toRead = CHUNK; + if (image_size < CHUNK/16) + { + toRead = image_size*16; + image_size = CHUNK/16; + } + if ((int)DosRWSft(fd, toRead, MK_FP(sp, 0), XFR_READ) < toRead) break; sp += CHUNK/16; - exe_size -= CHUNK/16; - } + } while (image_size -= CHUNK/16); } - { /* relocate the image for new segment */ - COUNT i; - UWORD reloc[2]; - seg FAR *spot; - - SftSeek(fd, ExeHeader.exRelocTable, 0); - for (i = 0; i < ExeHeader.exRelocItems; i++) + /* relocate the image for new segment */ + SftSeek(fd, ExeHeader.exRelocTable, 0); + { + unsigned i; + for (i = ExeHeader.exRelocItems; i; i--) { - if (DosRWSft - (fd, sizeof(reloc), (VOID FAR *) & reloc[0], XFR_READ) != sizeof(reloc)) + UWORD reloc[2]; + if (DosRWSft(fd, sizeof reloc, reloc, XFR_READ) != sizeof reloc) { if (mode != OVERLAY) { - DosMemFree(--mem); + DosMemFree(mem); DosMemFree(env); } return DE_INVLDDATA; } - if (mode == OVERLAY) - { - spot = MK_FP(reloc[1] + mem, reloc[0]); - *spot += exp->load.reloc; - } - else - { - /* spot = MK_FP(reloc[1] + mem + 0x10, reloc[0]); */ - spot = MK_FP(reloc[1] + start_seg, reloc[0]); - *spot += start_seg; - } + *MK_PTR(seg_t, reloc[1] + start_seg, reloc[0]) += start_seg; } } @@ -741,24 +650,17 @@ COUNT DosExeLoader(BYTE FAR * namep, exec_blk * exp, COUNT mode, COUNT fd) DosCloseSft(fd, FALSE); /* exit here for overlay */ - if (mode == OVERLAY) - return SUCCESS; - + if (mode != OVERLAY) { - UWORD fcbcode; - - /* point to the PSP so we can build it */ - setvec(0x22, (intvec)MK_FP(user_r->CS, user_r->IP)); - child_psp(mem, cu_psp, mem + asize); - - fcbcode = patchPSP(mem - 1, env, exp, namep); + mem++; + makePSP(mem, env, asize, namep); exp->exec.stack = MK_FP(ExeHeader.exInitSS + start_seg, ExeHeader.exInitSP); exp->exec.start_addr = MK_FP(ExeHeader.exInitCS + start_seg, ExeHeader.exInitIP); /* Transfer control to the executable */ - load_transfer(mem, exp, fcbcode, mode); + load_transfer(mem, exp, mode); } return SUCCESS; } @@ -786,7 +688,7 @@ COUNT DosExec(COUNT mode, exec_blk FAR * ep, BYTE FAR * lp) return DE_FILENOTFND; } - rc = (int)DosRWSft(fd, sizeof(exe_header), (BYTE FAR *)&ExeHeader, XFR_READ); + rc = (int)DosRWSft(fd, sizeof(exe_header), &ExeHeader, XFR_READ); if (rc == sizeof(exe_header) && (ExeHeader.exSignature == MAGIC || ExeHeader.exSignature == OLD_MAGIC)) @@ -809,44 +711,65 @@ COUNT DosExec(COUNT mode, exec_blk FAR * ep, BYTE FAR * lp) #include "config.h" /* config structure definition */ /* start process 0 (the shell) */ -VOID ASMCFUNC P_0(struct config FAR *Config) +void ASMCFUNC P_0(const struct config FAR *); +#ifdef __WATCOMC__ +# pragma aux (cdecl) P_0 aborts +#endif + +void ASMCFUNC P_0(const struct config FAR *Config) { - BYTE *tailp, *endp; - exec_blk exb; - UBYTE mode = Config->cfgP_0_startmode; - - /* build exec block and save all parameters here as init part will vanish! */ - exb.exec.fcb_1 = exb.exec.fcb_2 = (fcb FAR *)-1L; - exb.exec.env_seg = DOS_PSP + 8; - fstrcpy(Shell, MK_FP(FP_SEG(Config), Config->cfgInit)); - /* join name and tail */ - fstrcpy(Shell + strlen(Shell), MK_FP(FP_SEG(Config), Config->cfgInitTail)); - endp = Shell + strlen(Shell); - - for ( ; ; ) /* endless shell load loop - reboot or shut down to exit it! */ + int mode = Config->cfgP_0_startmode; + + const char FAR *p = MK_PTR(const char, FP_SEG(Config), Config->cfgShell); + PStr endp = Shell; + while ((*endp = *p++) != '\0' && + ++endp < Shell + sizeofShell - 4); /* 4 for 0,ctCount and "\r\0" */ + + for (;;) /* endless shell load loop - reboot or shut down to exit it! */ { - BYTE *p; - /* if there are no parameters, point to end without "\r\n" */ - if((tailp = strchr(Shell,'\t')) == NULL && - (tailp = strchr(Shell, ' ')) == NULL) - tailp = endp - 2; - /* shift tail to right by 2 to make room for '\0', ctCount */ - for (p = endp - 1; p >= tailp; p--) - *(p + 2) = *p; - /* terminate name and tail */ - *tailp = *(endp + 2) = '\0'; - /* ctCount: just past '\0' do not count the "\r\n" */ - exb.exec.cmd_line = (CommandTail *)(tailp + 1); - exb.exec.cmd_line->ctCount = endp - tailp - 2; + PStr tailp = Shell - 1; + + *endp = '\r', endp[1] = '\0'; /* terminate command line */ + endp += 2; + + /* find end of command name */ + do tailp++; while ((UBYTE)*tailp > ' ' && *tailp != '/'); + + /* shift tail to right by 2 to make room for '\0' and ctCount */ + { + PStr p = endp; + do + { + p--; + p[2] = p[0]; + } while (p > tailp); + } + + /* terminate name */ + *tailp = '\0'; + + /* init length of command line tail (ctCount field) */ + tailp++; + *tailp = (UBYTE)(endp - tailp - 1); /* without "\r\0" */ + + { + exec_blk exb; + exb.exec.env_seg = DOS_PSP + 8; + exb.exec.cmd_line = (CommandTail *)tailp; + /*exb.exec.fcb_1 = exb.exec.fcb_2 = NULL;*/ /* unimportant */ + #ifdef DEBUG - printf("Process 0 starting: %s%s\n\n", Shell, tailp + 2); + printf("Process 0 starting: %s%s\n\n", Shell, tailp + 1); #endif - res_DosExec(mode, &exb, Shell); - put_string("Bad or missing Command Interpreter: "); /* failure _or_ exit */ + res_DosExec(mode, &exb, Shell); + } + + /* failure or exit */ + put_string("\nBad or missing Command Interpreter\n" + "Enter the full shell command line:\n"); put_string(Shell); - put_string(tailp + 2); - put_string(" Enter the full shell command line: "); - endp = Shell + res_read(STDIN, Shell, NAMEMAX); - *endp = '\0'; /* terminate string for strchr */ + *endp = '\n'; /* replace "\r\0" by "\n\0" */ + put_string(++tailp); + endp = Shell + res_read(STDIN, Shell, sizeofShell) - 2; /* exclude "\r\n" */ } } diff --git a/kernel/tci.cfg b/kernel/tci.cfg new file mode 100644 index 00000000..946e7946 --- /dev/null +++ b/kernel/tci.cfg @@ -0,0 +1,7 @@ +-zCINIT_TEXT +-zRID +-zTID +-zSI_GROUP +-zDIB +-zBIB +-zGI_GROUP diff --git a/kernel/turboc.cfg b/kernel/turboc.cfg index f07a6c1c..413e8f77 100644 --- a/kernel/turboc.cfg +++ b/kernel/turboc.cfg @@ -1,15 +1,11 @@ --f- --ff- --O --Z -d +-f- -k- --vi- --wpro --weas --wpre --w --g1 --I..\hdr +-O -Z -p --v- -I. -D__STDC__=0 -DKERNEL -DI86 -DPROTO -DASMSUPT +-v- +-w -g1 +-I..\hdr +-DI86 + +-zCHMA_TEXT diff --git a/kernel/vc.cfg b/kernel/vc.cfg new file mode 100644 index 00000000..af2a42c5 --- /dev/null +++ b/kernel/vc.cfg @@ -0,0 +1,5 @@ +-batch -nologo -WX +-Zlp1 +-f- -Osb1V4e -Gsry +-Fc +-I..\hdr diff --git a/kernel/wc.cfg b/kernel/wc.cfg new file mode 100644 index 00000000..53e3092a --- /dev/null +++ b/kernel/wc.cfg @@ -0,0 +1,9 @@ +-e5 -we -wx +-j +-os -s +-r -zgf -zff +-zq -zl -zp1 +-d1 +-I..\hdr + +-ntHMA_TEXT diff --git a/kernel/wci.cfg b/kernel/wci.cfg new file mode 100644 index 00000000..0559116a --- /dev/null +++ b/kernel/wci.cfg @@ -0,0 +1,11 @@ +-e5 -we -wx +-j +-os -s +-r -zgf -zff +-zq -zl -zp1 +-d1 +-I..\hdr + +-ntINIT_TEXT +-gTGROUP +-ndI diff --git a/lib/makefile b/lib/makefile index 91e27928..e93f02e2 100644 --- a/lib/makefile +++ b/lib/makefile @@ -4,21 +4,23 @@ # $Id$ # - !include "../mkfiles/generic.mak" +######################################################################## -libm.lib: $(CLIB) - -$(RM) libm.lib - $(LIBUTIL) $(CLIB) $(MATH_EXTRACT) $(LIBTERM) - $(COMSPEC) /c for %i in (*.obj) do ..\utils\patchobj CODE=LCODE %i - $(LIBUTIL) libm $(MATH_INSERT) $(LIBTERM) - -$(RM) *.OBJ +all: libm.lib +libm.lib: $(CLIB) $(DEPENDS) + -$(RM) $*.lib + $(LIBUTIL) $(CLIB) $(MATH_EXTRACT) $(LIBTERM) + $(COMSPEC) /c for %i in (*.obj) do ..\utils\patchobj CODE=LCODE %i + $(LIBUTIL) $* $(MATH_INSERT) $(LIBTERM) + -$(RM) *.obj -clobber: clean - -$(RM) status.me +######################################################################## clean: - -$(RM) *.obj *.bak libm.lib + -$(RM) *.bak *.cod *.crf *.err *.las *.lst *.map *.obj *.xrf +clobber: clean + -$(RM) libm.lib status.me diff --git a/mkfiles/bc.mak b/mkfiles/bc.mak new file mode 100644 index 00000000..9cb252a3 --- /dev/null +++ b/mkfiles/bc.mak @@ -0,0 +1,10 @@ +# +# BC.MAK - kernel copiler options for Borland C++ +# + +!include "..\mkfiles\tcpp.mak" + +TARGET=KBC + +CC=$(BINPATH)\bcc -c +CL=$(BINPATH)\bcc diff --git a/mkfiles/bc5.mak b/mkfiles/bc5.mak index 64408fd6..0a98b9df 100644 --- a/mkfiles/bc5.mak +++ b/mkfiles/bc5.mak @@ -2,52 +2,9 @@ # BC5.MAK - kernel copiler options for Borland C++ # -# Use these for Borland C++ - -COMPILERPATH=$(BC5_BASE) -COMPILERBIN=$(COMPILERPATH)\bin -CC=$(COMPILERBIN)\bcc -c -CL=$(COMPILERBIN)\bcc -INCLUDEPATH=$(COMPILERPATH)\include -LIBUTIL=$(COMPILERBIN)\tlib -LIBPATH=$(COMPILERPATH)\lib -LIBTERM= -LIBPLUS=+ - -TINY=-lt -CFLAGST=-L$(LIBPATH) -mt -a- -k- -f- -ff- -O -Z -d -CFLAGSC=-L$(LIBPATH) -a- -mc +!include "..\mkfiles\turbocpp.mak" TARGET=KBC -# used for building the library - -CLIB=$(COMPILERPATH)\lib\cs.lib -MATH_EXTRACT=*H_LDIV *H_LLSH *H_LURSH *F_LXMUL -MATH_INSERT=+H_LDIV +H_LLSH +H_LURSH +F_LXMUL - -# -# heavy stuff - building the kernel -# Compiler and Options for Borland C++ -# ------------------------------------ -# -# -zAname ¦ ¦ Code class -# -zBname ¦ ¦ BSS class -# -zCname ¦ ¦ Code segment -# -zDname ¦ ¦ BSS segment -# -zEname ¦ ¦ Far segment -# -zFname ¦ ¦ Far class -# -zGname ¦ ¦ BSS group -# -zHname ¦ ¦ Far group -# -zPname ¦ ¦ Code group -# -zRname ¦ ¦ Data segment -# -zSname ¦ ¦ Data group -# -zTname ¦ ¦ Data class -# -zX ¦«¦ Use default name for "X" - -# -# ALLCFLAGS specified by turbo.cfg and config.mak -# -ALLCFLAGS=$(TARGETOPT) -zCHMA_TEXT $(ALLCFLAGS) -INITCFLAGS=$(ALLCFLAGS) -zCINIT_TEXT -zDIB -zRID -zTID -zBIB -zGI_GROUP -zSI_GROUP -CFLAGS=$(ALLCFLAGS) +CC=$(BINPATH)\bcc -c +CL=$(BINPATH)\bcc diff --git a/mkfiles/generic.mak b/mkfiles/generic.mak index 5e97ea2e..e70533ab 100644 --- a/mkfiles/generic.mak +++ b/mkfiles/generic.mak @@ -1,43 +1,67 @@ # These are generic definitions -#********************************************************************** -#* TARGET : we create a %TARGET%.sys file -#* TARGETOPT : options, handled down to the compiler -#********************************************************************** - -TARGETOPT=-1- +# TARGET : we create a $(TARGET).sys file +!if $(XCPU)0 == 0 +XCPU=86 +!endif +CPUOPT= !if $(XCPU) == 186 -TARGETOPT=-1 +CPUOPT=-1 !endif !if $(XCPU) == 386 -TARGETOPT=-3 +CPUOPT=-3 !endif +!if $(XFAT)0 == 0 +XFAT=32 +!endif !if $(XFAT) == 32 -ALLCFLAGS=$(ALLCFLAGS) -DWITHFAT32 -NASMFLAGS=$(NASMFLAGS) -DWITHFAT32 +ALLCFLAGS=-DWITHFAT32 $(ALLCFLAGS) +NASMFLAGS=-DWITHFAT32 $(NASMFLAGS) !endif -NASM=$(XNASM) -NASMFLAGS = $(NASMFLAGS) -i../hdr/ -DXCPU=$(XCPU) - -LINK=$(XLINK) +NASMFLAGS=-fobj -i../hdr/ -D$(COMPILER) -DXCPU=$(XCPU) $(NASMFLAGS) +BINPATH=$(BASE)\bin +INCLUDEPATH=$(BASE)\include +LIBPATH=$(BASE)\lib INITPATCH=@rem +UPXOPT=-U +!if $(__MAKE__)0 == 0 # NMAKE/WMAKE +!if "$(XUPX)" == "" # TC doesn't supports this +XUPX=rem # NMAKE doesn't supports @ in macro +UPXOPT= +!endif +!else # TC/BC MAKE +!if !$d(XUPX) # NMAKE/WMAKE doesn't supports $d() +XUPX=@rem +UPXOPT= +!endif +!endif + !include "..\mkfiles\$(COMPILER).mak" TARGET=$(TARGET)$(XCPU)$(XFAT) +INITCFLAGS=$(INITCFLAGS) $(ALLCFLAGS) +CFLAGS=$(CFLAGS) $(ALLCFLAGS) RM=..\utils\rmfiles +DEPENDS=makefile ..\*.bat ..\mkfiles\*.* + +# Implicit Rules ####################################################### + +.asm.obj: + $(NASM) $(NASMFLAGS) $< -.asm.obj : - $(NASM) -D$(COMPILER) $(NASMFLAGS) -f obj $*.asm +.c.obj: + $(CC) $(CFLAGS) $< -# *Implicit Rules* -.c.obj : - $(CC) $(CFLAGS) $*.c +.cpp.obj: + $(CC) $(CFLAGS) $< -.cpp.obj : - $(CC) $(CFLAGS) $*.cpp +.c.com: + $(CL) $(CFLAGST) $< +.c.exe: + $(CL) $(CFLAGSC) $< diff --git a/mkfiles/msc.mak b/mkfiles/msc.mak new file mode 100644 index 00000000..3c8945c1 --- /dev/null +++ b/mkfiles/msc.mak @@ -0,0 +1,31 @@ +# +# MSC.MAK - kernel copiler options for MS VC 1.5x (MS CL 8.x) +# + +TARGET=KMS + +CC=$(BINPATH)\cl -batch -nologo -c +CL=$(BINPATH)\cl -batch -nologo + +# used for building the library + +CLIB=$(LIBPATH)\slibce.lib +MATH_EXTRACT=*aflmul *aFlshl *aFNauldi *aFulrem *aFulshr *aFuldiv *aFlrem *aFldiv *aFNaulsh +MATH_INSERT =+aflmul +aFlshl +aFNauldi +aFulrem +aFulshr +aFuldiv +aFlrem +aFldiv +aFNaulsh + +# + +!if $(XCPU) == 186 +CPUOPT=-G1 +!endif +!if $(XCPU) == 386 +CPUOPT=-G3 +!endif + +ALLCFLAGS=@msc.cfg -I$(INCLUDEPATH) $(CPUOPT) $(ALLCFLAGS) +INITCFLAGS=-NTINIT_TEXT +CFLAGS =-NTHMA_TEXT +INITPATCH=..\utils\patchobj _DATA=IDATA DATA=ID BSS=ID DGROUP=I_GROUP CONST=IC + +CFLAGST=-I..\hdr -I$(INCLUDEPATH) /Fm /AT /Os /Zp1 +CFLAGSC=-I..\hdr -I$(INCLUDEPATH) /Fm /AL /Os /Zp1 diff --git a/mkfiles/mscl8.mak b/mkfiles/mscl8.mak index cd5c53b2..a398c4de 100644 --- a/mkfiles/mscl8.mak +++ b/mkfiles/mscl8.mak @@ -1,47 +1,31 @@ # -# MSCL8.MAK - kernel copiler options for MS CL8 = MSVC1.52 +# MSCL8.MAK - kernel copiler options for MS CL8 = MS VC 1.52 # -# Use these for MSCV 1.52 -COMPILERPATH=$(MS_BASE) -COMPILERBIN=$(COMPILERPATH)\bin -INCLUDEPATH=$(COMPILERPATH)\include -CC=$(COMPILERBIN)\cl -c -CL=$(COMPILERBIN)\cl -TINY= -CFLAGST=/Fm /AT /Os /Zp1 -CFLAGSC=/Fm /AL /Os /Zp1 -LIBPATH=$(COMPILERPATH)\lib -LIB=$(COMPILERPATH)\lib -INCLUDE=$(COMPILERPATH)\include -LIBUTIL=$(COMPILERBIN)\lib /nologo -LIBPLUS=+ -LIBTERM=; -INCLUDE=$(COMPILERPATH)\include -LIB=$(COMPILERPATH)\lib +TARGET=KMS + +CC=$(BINPATH)\cl -batch -nologo -c +CL=$(BINPATH)\cl -batch -nologo # used for building the library -CLIB=$(COMPILERPATH)\lib\slibce.lib -MATH_EXTRACT=*aflmul *aFlshl *aFNauldi *aFulrem *aFulshr *aFuldiv *aFlrem *aFldiv -MATH_INSERT= +aflmul +aFlshl +aFNauldi +aFulrem +aFulshr +aFuldiv +aFlrem +aFldiv +CLIB=$(LIBPATH)\slibce.lib +MATH_EXTRACT=*aflmul *aFlshl *aFNauldi *aFulrem *aFulshr *aFuldiv *aFlrem *aFldiv *aFNaulsh +MATH_INSERT =+aflmul +aFlshl +aFNauldi +aFulrem +aFulshr +aFuldiv +aFlrem +aFldiv +aFNaulsh -TARGETOPT= -!if $(XCPU) == 186 -TARGETOPT=-G1 +# + +!if $(XCPU) == 186 +CPUOPT=-G1 !endif !if $(XCPU) == 386 -TARGETOPT=-G3 +CPUOPT=-G3 !endif -TARGET=KMS - -# -# heavy stuff - building - - -ALLCFLAGS=-I..\hdr $(TARGETOPT) $(ALLCFLAGS) -nologo -Zl -Fc -WX -Gr -f- -Os -Gs -Ob1 -OV4 -Gy -Oe -Zp1 +ALLCFLAGS=@vc.cfg -I$(INCLUDEPATH) $(CPUOPT) $(ALLCFLAGS) +INITCFLAGS=-NTINIT_TEXT +CFLAGS =-NTHMA_TEXT +INITPATCH=..\utils\patchobj _DATA=IDATA DATA=ID BSS=ID DGROUP=I_GROUP CONST=IC -INITCFLAGS=$(ALLCFLAGS) -NTINIT_TEXT -CFLAGS=$(ALLCFLAGS) -NTHMA_TEXT -INITPATCH = ..\utils\patchobj _DATA=IDATA DATA=ID BSS=ID DGROUP=I_GROUP CONST=IC +CFLAGST=-I..\hdr -I$(INCLUDEPATH) /Fm /AT /Os /Zp1 +CFLAGSC=-I..\hdr -I$(INCLUDEPATH) /Fm /AL /Os /Zp1 diff --git a/mkfiles/tc.mak b/mkfiles/tc.mak new file mode 100644 index 00000000..856b65fe --- /dev/null +++ b/mkfiles/tc.mak @@ -0,0 +1,16 @@ +# +# TC.MAK - kernel copiler options for Turbo C 2.01 +# + +BINPATH=$(BASE) + +!include "..\mkfiles\tcpp.mak" + +TARGET=KTC + +MATH_EXTRACT=*LDIV *LXMUL *LURSH *LLSH *LRSH +MATH_INSERT =+LDIV +LXMUL +LURSH +LLSH +LRSH + +# TCC doesn't support responce file + +INITCFLAGS=-zCINIT_TEXT -zRID -zTID -zSI_GROUP -zDIB -zBIB -zGI_GROUP diff --git a/mkfiles/tc2.mak b/mkfiles/tc2.mak index c5e52130..1d5c32c3 100644 --- a/mkfiles/tc2.mak +++ b/mkfiles/tc2.mak @@ -1,53 +1,16 @@ # -# TURBOC.MAK - kernel copiler options for TURBOC +# TC2.MAK - kernel copiler options for Turbo C 2.01 # -# Use these for Turbo C 2.01 +BINPATH=$(BASE) -COMPILERPATH=$(TC2_BASE) -COMPILERBIN=$(COMPILERPATH) -CC=$(COMPILERBIN)\tcc -c -CL=$(COMPILERBIN)\tcc -INCLUDEPATH=$(COMPILERPATH)\include -LIBUTIL=$(COMPILERBIN)\tlib -LIBPATH=$(COMPILERPATH)\lib -LIBTERM= -LIBPLUS=+ - -TINY=-lt -CFLAGST=-L$(LIBPATH) -mt -a- -k- -f- -ff- -O -Z -d -w -CFLAGSC=-L$(LIBPATH) -a- -mc +!include "..\mkfiles\turbocpp.mak" TARGET=KTC -# used for building the library - -CLIB=$(COMPILERPATH)\lib\cs.lib MATH_EXTRACT=*LDIV *LXMUL *LURSH *LLSH *LRSH -MATH_INSERT=+LDIV +LXMUL +LURSH +LLSH +LRSH +MATH_INSERT =+LDIV +LXMUL +LURSH +LLSH +LRSH -# -# heavy stuff - building the kernel -# Compiler and Options for Borland C++ -# ------------------------------------ -# -# -zAname ¦ ¦ Code class -# -zBname ¦ ¦ BSS class -# -zCname ¦ ¦ Code segment -# -zDname ¦ ¦ BSS segment -# -zEname ¦ ¦ Far segment -# -zFname ¦ ¦ Far class -# -zGname ¦ ¦ BSS group -# -zHname ¦ ¦ Far group -# -zPname ¦ ¦ Code group -# -zRname ¦ ¦ Data segment -# -zSname ¦ ¦ Data group -# -zTname ¦ ¦ Data class -# -zX ¦«¦ Use default name for "X" +# TCC 2.0 doesn't support responce file -# -# ALLCFLAGS specified by turbo.cfg and config.mak -# -ALLCFLAGS=$(TARGETOPT) -zCHMA_TEXT $(ALLCFLAGS) -INITCFLAGS=$(ALLCFLAGS) -zCINIT_TEXT -zDIB -zRID -zTID -zBIB -zGI_GROUP -zSI_GROUP -CFLAGS=$(ALLCFLAGS) +INITCFLAGS=-zCINIT_TEXT -zRID -zTID -zSI_GROUP -zDIB -zBIB -zGI_GROUP diff --git a/mkfiles/tc3.mak b/mkfiles/tc3.mak index 1ac6986e..a387fe54 100644 --- a/mkfiles/tc3.mak +++ b/mkfiles/tc3.mak @@ -1,53 +1,7 @@ # -# TC3.MAK - kernel copiler options for Turbo C 3.0 +# TC3.MAK - kernel copiler options for Turbo C++ 3.0 # -# Use these for Turbo C 3.0 - -COMPILERPATH=$(TC3_BASE) -COMPILERBIN=$(COMPILERPATH)\bin -CC=$(COMPILERBIN)\tcc -c -CL=$(COMPILERBIN)\tcc -INCLUDEPATH=$(COMPILERPATH)\include -LIBUTIL=$(COMPILERBIN)\tlib -LIBPATH=$(COMPILERPATH)\lib -LIBTERM= -LIBPLUS=+ - -TINY=-lt -CFLAGST=-L$(LIBPATH) -mt -a- -k- -f- -ff- -O -Z -d -CFLAGSC=-L$(LIBPATH) -a- -mc +!include "..\mkfiles\turbocpp.mak" TARGET=KT3 - -# used for building the library - -CLIB=$(COMPILERPATH)\lib\cs.lib -MATH_EXTRACT=*H_LDIV *H_LLSH *H_LURSH *F_LXMUL -MATH_INSERT=+H_LDIV +H_LLSH +H_LURSH +F_LXMUL - -# -# heavy stuff - building the kernel -# Compiler and Options for Borland C++ -# ------------------------------------ -# -# -zAname ¦ ¦ Code class -# -zBname ¦ ¦ BSS class -# -zCname ¦ ¦ Code segment -# -zDname ¦ ¦ BSS segment -# -zEname ¦ ¦ Far segment -# -zFname ¦ ¦ Far class -# -zGname ¦ ¦ BSS group -# -zHname ¦ ¦ Far group -# -zPname ¦ ¦ Code group -# -zRname ¦ ¦ Data segment -# -zSname ¦ ¦ Data group -# -zTname ¦ ¦ Data class -# -zX ¦«¦ Use default name for "X" - -# -# ALLCFLAGS specified by turbo.cfg and config.mak -# -ALLCFLAGS=$(TARGETOPT) -zCHMA_TEXT $(ALLCFLAGS) -INITCFLAGS=$(ALLCFLAGS) -zCINIT_TEXT -zDIB -zRID -zTID -zBIB -zGI_GROUP -zSI_GROUP -CFLAGS=$(ALLCFLAGS) diff --git a/mkfiles/tcpp.mak b/mkfiles/tcpp.mak new file mode 100644 index 00000000..e3afc341 --- /dev/null +++ b/mkfiles/tcpp.mak @@ -0,0 +1,42 @@ +# +# TCPP.MAK - kernel copiler options for Turbo C++ 1.01 +# + +TARGET=KTP + +CC=$(BINPATH)\tcc -c +CL=$(BINPATH)\tcc + +# used for building the library + +CLIB=$(LIBPATH)\cs.lib +MATH_EXTRACT=*H_LDIV *H_LLSH *H_LURSH *F_LXMUL +MATH_INSERT =+H_LDIV +H_LLSH +H_LURSH +F_LXMUL + +# +# Compiler options for Turbo/Borland C +# ------------------------------------ +# +# -zAname ¦ ¦ Code class +# -zBname ¦ ¦ BSS class +# -zCname ¦ ¦ Code segment +# -zDname ¦ ¦ BSS segment +# -zEname ¦ ¦ Far segment +# -zFname ¦ ¦ Far class +# -zGname ¦ ¦ BSS group +# -zHname ¦ ¦ Far group +# -zPname ¦ ¦ Code group +# -zRname ¦ ¦ Data segment +# -zSname ¦ ¦ Data group +# -zTname ¦ ¦ Data class +# -zX ¦«¦ Use default name for "X" + +# +# Common options specified in turboc.cfg instead ALLCFLAGS +# + +ALLCFLAGS=-I..\hdr;$(INCLUDEPATH) $(CPUOPT) $(ALLCFLAGS) +INITCFLAGS=@tci.cfg + +CFLAGST=-I..\hdr;$(INCLUDEPATH) -L$(LIBPATH) -mt -lt +CFLAGSC=-I..\hdr;$(INCLUDEPATH) -L$(LIBPATH) -mc diff --git a/mkfiles/tcpp3.mak b/mkfiles/tcpp3.mak new file mode 100644 index 00000000..c1a448b6 --- /dev/null +++ b/mkfiles/tcpp3.mak @@ -0,0 +1,7 @@ +# +# TCPP3.MAK - kernel copiler options for Turbo C++ 3.0 +# + +!include "..\mkfiles\tcpp.mak" + +TARGET=KT3 diff --git a/mkfiles/turbocpp.mak b/mkfiles/turbocpp.mak index db331184..0522de09 100644 --- a/mkfiles/turbocpp.mak +++ b/mkfiles/turbocpp.mak @@ -1,34 +1,20 @@ # -# TURBOCPP.MAK - kernel copiler options for TCPP 1.01 +# TURBOCPP.MAK - kernel copiler options for Turbo C++ 1.01 # -# Use these for Turbo CPP 1.01 - -COMPILERPATH=$(TP1_BASE) -COMPILERBIN=$(COMPILERPATH)\bin -CC=$(COMPILERBIN)\tcc -c -CL=$(COMPILERBIN)\tcc -INCLUDEPATH=$(COMPILERPATH)\include -LIBUTIL=$(COMPILERBIN)\tlib -LIBPATH=$(COMPILERPATH)\lib -LIBTERM= -LIBPLUS=+ - -TINY=-lt -CFLAGST=-L$(LIBPATH) -mt -a- -k- -f- -ff- -O -Z -d -CFLAGSC=-L$(LIBPATH) -a- -mc - TARGET=KTP +CC=$(BINPATH)\tcc -c +CL=$(BINPATH)\tcc + # used for building the library -CLIB=$(COMPILERPATH)\lib\cs.lib +CLIB=$(LIBPATH)\cs.lib MATH_EXTRACT=*H_LDIV *H_LLSH *H_LURSH *F_LXMUL -MATH_INSERT=+H_LDIV +H_LLSH +H_LURSH +F_LXMUL +MATH_INSERT =+H_LDIV +H_LLSH +H_LURSH +F_LXMUL # -# heavy stuff - building the kernel -# Compiler and Options for Borland C++ +# Compiler options for Turbo/Borland C # ------------------------------------ # # -zAname ¦ ¦ Code class @@ -46,8 +32,12 @@ MATH_INSERT=+H_LDIV +H_LLSH +H_LURSH +F_LXMUL # -zX ¦«¦ Use default name for "X" # -# ALLCFLAGS specified by turbo.cfg and config.mak +# Common options specified in turboc.cfg instead ALLCFLAGS # -ALLCFLAGS=$(TARGETOPT) -zCHMA_TEXT $(ALLCFLAGS) -INITCFLAGS=$(ALLCFLAGS) -zCINIT_TEXT -zDIB -zRID -zTID -zBIB -zGI_GROUP -zSI_GROUP -CFLAGS=$(ALLCFLAGS) + +ALLCFLAGS=-I..\hdr;$(INCLUDEPATH) $(CPUOPT) $(ALLCFLAGS) +INITCFLAGS=@..\mkfiles\tci.cfg +CFLAGS =-zCHMA_TEXT + +CFLAGST=-I..\hdr;$(INCLUDEPATH) -L$(LIBPATH) -mt -lt # -ff- +CFLAGSC=-I..\hdr;$(INCLUDEPATH) -L$(LIBPATH) -mc diff --git a/mkfiles/watcom.mak b/mkfiles/watcom.mak index 77a26151..95cda19c 100644 --- a/mkfiles/watcom.mak +++ b/mkfiles/watcom.mak @@ -1,67 +1,50 @@ # -# WATCOM.MAK - kernel copiler options for WATCOM C 11.0c +# WATCOM.MAK - kernel copiler options for WATCOM C/OpenWatcom # -# Use these for WATCOM 11.0c -COMPILERPATH=$(WATCOM) -CC=*wcc -CL=wcl -INCLUDEPATH=$(COMPILERPATH)\H -INCLUDE=$(COMPILERPATH)\h -EDPATH=$(COMPILERPATH)\EDDAT - -!if $(XCPU) != 186 -!if $(XCPU) != 386 -TARGETOPT=-0 -!endif -!endif - -LIBPATH=$(COMPILERPATH)\lib286 -LIBUTIL=wlib -q -LIBPLUS= -LIBTERM= - -TINY=-mt -CFLAGST=-zq-zp1-os-s-we-e3-wx -CFLAGSC=-mc-zq-zp1-os-s-we-e3-wx - TARGET=KWC -# used for building the library +BINPATH=$(BASE)\binw +INCLUDEPATH=$(BASE)\h +LIBPATH=$(BASE)\lib286 -CLIB=$(COMPILERPATH)\lib286\dos\clibm.lib +CC=$(BINPATH)\wcc +CL=$(BINPATH)\wcl -# we use our own ones, which override these ones when linking. -# +# used for building the library +CLIB=$(LIBPATH)\dos\clibm.lib MATH_EXTRACT=*i4m -MATH_INSERT=+i4m - +MATH_INSERT =+i4m # -# heavy stuff - building +# Compiler options for Watcom +# --------------------------- # # -e= set limit on number of error messages +# -w= set warning level number +# -we treat all warnings as errors +# -zq operate quietly +# +# -j change char default from unsigned to signed # -ms small memory model (small code/small data) -# -j change char default from unsigned to signed -#-nc= set code class name -#-nd= set data segment name -#-nm= set module name -#-nt= set name of text segment -# -g= set code group name # -os -> favor code size over execution time in optimizations -# -s remove stack overflow checks -# -w= set warning level number -# -we treat all warnings as errors +# -s remove stack overflow checks # -ze enable extensions (i.e., near, far, export, etc.) # -zl remove default library information # -zp= pack structure members with alignment {1,2,4,8,16} -# -zq operate quietly # -# -3 optimization for 386 - given in CONFIG.MAK, not here +# -3 optimization for 386 - given in $(CPUOPT) +# -g= set code group name +# -nc= set code class name +# -nd= set data segment name +# -nm= set module name +# -nt= set name of text segment # -ALLCFLAGS=-I..\hdr $(TARGETOPT) $(ALLCFLAGS)-zq-os-s-e5-j-zl-zp1-wx-we-zgf-zff-r -INITCFLAGS=$(ALLCFLAGS)-ntINIT_TEXT-gTGROUP-ndI -CFLAGS=$(ALLCFLAGS)-ntHMA_TEXT +ALLCFLAGS=-I$(INCLUDEPATH) $(CPUOPT)$(ALLCFLAGS) +INITCFLAGS=@wci.cfg +CFLAGS =@wc.cfg +CFLAGST=-I..\hdr;$(INCLUDEPATH) -e3-we-wx-zq-os-s-zp1-mt +CFLAGSC=-I..\hdr;$(INCLUDEPATH) -e3-we-wx-zq-os-s-zp1-mc diff --git a/sys/fdkrncfg.c b/sys/fdkrncfg.c index 941e1961..36648bdc 100644 --- a/sys/fdkrncfg.c +++ b/sys/fdkrncfg.c @@ -50,7 +50,7 @@ unsigned long lseek(int fildes, unsigned long offset, int whence); #define FAR far #include "kconfig.h" -KernelConfig cfg = { 0 }; +KernelConfig cfg; /* static memory zeroed automatically */ typedef unsigned char byte; typedef signed char sbyte; diff --git a/sys/makefile b/sys/makefile index ed4aad9e..d2324f0d 100644 --- a/sys/makefile +++ b/sys/makefile @@ -6,55 +6,36 @@ !include "../mkfiles/generic.mak" -CFLAGS = -I$(INCLUDEPATH) -I..\hdr -DFORSYS -DWITHFAT32 $(CFLAGST) -NASMFLAGS = -DSYS=1 +SYS_C=sys.c fdkrncfg.c ..\kernel\prf.c talloc.c +DEPENDS=$(DEPENDS) *.cfg -# *List Macros* +######################################################################## -SYS_EXE_dependencies = \ - sys.obj \ - fdkrncfg.obj \ - prf.obj \ - talloc.obj +all: bin2c.com ..\bin\sys.com -# *Explicit Rules* -production: bin2c.com ..\bin\sys.com +bin2c.com: bin2c.c $(DEPENDS) -bin2c.com: bin2c.c - $(CL) $(CFLAGS) $(TINY) bin2c.c +fat12com.h: ..\boot\fat12.bin bin2c.com + bin2c ..\boot\fat12.bin $*.h $* -..\bin\sys.com: sys.com - copy sys.com ..\bin - -fat12com.h: ..\boot\fat12com.bin bin2c.com - .\bin2c ..\boot\fat12com.bin fat12com.h fat12com - -fat16com.h: ..\boot\fat16com.bin bin2c.com - .\bin2c ..\boot\fat16com.bin fat16com.h fat16com +fat16com.h: ..\boot\fat16.bin bin2c.com + bin2c ..\boot\fat16.bin $*.h $* fat32chs.h: ..\boot\fat32chs.bin bin2c.com - .\bin2c ..\boot\fat32chs.bin fat32chs.h fat32chs + bin2c ..\boot\$*.bin $*.h $* fat32lba.h: ..\boot\fat32lba.bin bin2c.com - .\bin2c ..\boot\fat32lba.bin fat32lba.h fat32lba - -prf.obj: ..\kernel\prf.c - $(CC) $(CFLAGS) ..\kernel\prf.c - -fdkrncfg.obj: fdkrncfg.c ..\hdr\kconfig.h + bin2c ..\boot\$*.bin $*.h $* -talloc.obj: talloc.c - -sys.com: $(SYS_EXE_dependencies) - $(CL) $(CFLAGST) $(TINY) $(SYS_EXE_dependencies) +..\bin\sys.com: $(SYS_C) ..\hdr\*.h fat12com.h fat16com.h fat32chs.h fat32lba.h + $(CL) $(CFLAGST) -DFORSYS -DWITHFAT32 $(SYS_C) + copy sys.com ..\bin + del sys.com -clobber: clean - -$(RM) bin2c.com sys.com fat*.h +######################################################################## clean: - -$(RM) *.obj *.bak *.crf *.xrf *.map *.lst *.las *.cod *.err status.me - -# *Individual File Dependencies* -sys.obj: sys.c ..\hdr\portab.h ..\hdr\device.h fat12com.h fat16com.h fat32chs.h fat32lba.h - $(CC) $(CFLAGS) $*.c + -$(RM) *.bak *.cod *.crf *.err *.las *.lst *.map *.obj *.xrf +clobber: clean + -$(RM) bin2c.com fat*.h status.me diff --git a/sys/turboc.cfg b/sys/turboc.cfg new file mode 100644 index 00000000..84faa4cc --- /dev/null +++ b/sys/turboc.cfg @@ -0,0 +1,7 @@ +-d +-f- +-k- +-O -Z +-v- +-w -g1 +-I..\hdr diff --git a/utils/echoto.bat b/utils/echoto.bat index 31758d9e..f3fe60db 100755 --- a/utils/echoto.bat +++ b/utils/echoto.bat @@ -1 +1 @@ -@echo %2 %3 %4 %5 %6 %7 %8 %9 >> %1 \ No newline at end of file +@echo %2 %3 %4 %5 %6 %7 %8 %9>>%1 \ No newline at end of file diff --git a/utils/exeflat.c b/utils/exeflat.c index 91dde711..e0b822cb 100644 --- a/utils/exeflat.c +++ b/utils/exeflat.c @@ -52,8 +52,6 @@ large portions copied from task.c #define BUFSIZE 32768u -#define LENGTH(x) (sizeof(x)/sizeof(x[0])) - typedef struct { UWORD off, seg; } farptr; @@ -260,7 +258,7 @@ int main(int argc, char **argv) } /* this assumes <= 0xfe00 code in kernel */ - *(short *)&JumpBehindCode[0x1e] += size; + *(short *)&JumpBehindCode[0x1e] += (short)size; fwrite(JumpBehindCode, 1, 0x20, dest); } @@ -282,31 +280,33 @@ int main(int argc, char **argv) if (UPX) { /* UPX trailer */ - /* hand assembled - so this remains ANSI C ;-) */ - static char trailer[] = { /* shift down everything by sizeof JumpBehindCode */ - 0xE8, 0x00, 0x00, /* call 103 */ - 0x59, /* pop cx */ - 0x0E, /* push cs */ - 0x1F, /* pop ds */ - 0x8c, 0xc8, /* mov ax,cs */ - 0x48, /* dec ax */ - 0x48, /* dec ax */ - 0x8e, 0xc0, /* mov es,ax */ - 0x31, 0xFF, /* xor di,di */ - 0xBE, 0x00, 0x00, /* mov si,0x00 */ - 0xFC, /* cld */ - 0xF3, 0xA4, /* rep movsb */ - 0x26, 0x88, 0x1e, 0x00, 0x00, /* mov es:[0],bl */ - 0xB8, 0x00, 0x00, /* mov ax,0000h */ - 0x8E, 0xD0, /* mov ss,ax */ - 0xBC, 0x00, 0x00, /* mov sp,0000h */ - 0x31, 0xC0, /* xor ax,ax */ - 0x50, /* push ax */ - 0xC3 /* ret */ + /* hand assembled - so this remains ANSI C ;-) */ + /* move kernel down to place CONFIG-block, which added above, + at 0x5e:0 instead 0x60:0 and store there boot drive number + from BL; kernel.asm will then check presence of additional + CONFIG-block at this address. */ + static char trailer[] = { + 0x0E, /* 0 push cs */ + 0x1F, /* 1 pop ds ; =0x60 */ + 0xBF,0x5E,0x00, /* 2 mov di,0x5E */ + 0x8E,0xC7, /* 5 mov es,di */ + 0xFC, /* 7 cld */ + 0x33,0xFF, /* 8 xor di,di */ + 0x93, /* 10 xchg ax,bx ; mov al,bl */ + 0xAA, /* 11 stosb ; mov [es:0],al */ + 0x8B,0xF7, /* 12 mov si,di */ + 0xB9,0x00,0x00, /* 14 mov cx,offset trailer */ + 0xF3,0xA4, /* 17 rep movsb */ + 0xBF,0x00,0x00, /* 19 mov di,... */ + 0x8E,0xD7, /* 22 mov ss,di */ + 0xBC,0x00,0x00, /* 24 mov sp,... */ + 0x33,0xFF, /* 27 xor di,di */ + 0xFF,0xE7, /* 29 jmp di ; jmp 0 */ }; - *(short *)&trailer[26] = start_seg + header.exInitSS; - *(short *)&trailer[31] = header.exInitSP; - fwrite(trailer, 1, sizeof(trailer), dest); + *(short *)&trailer[15] = (short)size + 0x20; + *(short *)&trailer[20] = start_seg + header.exInitSS; + *(short *)&trailer[25] = header.exInitSP; + fwrite(trailer, 1, sizeof trailer, dest); } fclose(dest); printf("\nProcessed %d relocations, %d not shown\n", diff --git a/utils/makefile b/utils/makefile index 7be6ec76..5a26e97a 100644 --- a/utils/makefile +++ b/utils/makefile @@ -1,19 +1,19 @@ !include "../mkfiles/generic.mak" -CFLAGS = -I$(INCLUDEPATH) -I..\hdr +DEPENDS=$(DEPENDS) *.cfg -production: patchobj.com exeflat.exe +######################################################################## -patchobj.com: patchobj.c - $(CL) $(CFLAGST) $(TINY) $(CFLAGS) patchobj.c +all: patchobj.com exeflat.exe -exeflat.exe: exeflat.c ../hdr/exe.h - $(CL) $(CFLAGSC) $(CFLAGS) exeflat.c +patchobj.com: patchobj.c $(DEPENDS) +exeflat.exe: exeflat.c ../hdr/exe.h $(DEPENDS) -clobber: clean +######################################################################## clean: - $(RM) *.obj *.bak *.crf *.xrf *.map *.lst *.las *.cod *.err status.me - $(RM) exeflat.exe patchobj.com + -$(RM) *.bak *.cod *.crf *.err *.las *.lst *.map *.obj *.xrf +clobber: clean + -$(RM) patchobj.com exeflat.exe status.me diff --git a/utils/rmfiles.bat b/utils/rmfiles.bat index a4a052e9..e2423fdc 100644 --- a/utils/rmfiles.bat +++ b/utils/rmfiles.bat @@ -7,4 +7,3 @@ shift goto loop_commandline :done_with_commandline - diff --git a/utils/turboc.cfg b/utils/turboc.cfg new file mode 100644 index 00000000..84faa4cc --- /dev/null +++ b/utils/turboc.cfg @@ -0,0 +1,7 @@ +-d +-f- +-k- +-O -Z +-v- +-w -g1 +-I..\hdr diff --git a/utils/wlinker.bat b/utils/wlinker.bat index 9d25845e..30d39ebb 100755 --- a/utils/wlinker.bat +++ b/utils/wlinker.bat @@ -1,4 +1,4 @@ @echo off -ms2wlink %1 %2 %3 %4 %5 %6 %7 %8 %9 ,,,, > kernel.lnk -echo op map,statics,verbose >> kernel.lnk -call wlink @kernel.lnk +%BASE%\binw\ms2wlink %1 %2 %3 %4 %5 %6 %7 %8 %9>kernel.lnk +echo op map,statics,verbose,eliminate,vfremoval>>kernel.lnk +%BASE%\binw\wlink @kernel.lnk From b0c98dd5533918fcced809a9cab246a2bd2ca3a4 Mon Sep 17 00:00:00 2001 From: Kenneth J Davis Date: Fri, 9 Jul 2004 02:48:58 +0000 Subject: [PATCH 550/671] update history with changes from Lucho's NEWS file git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/branches/UNSTABLE@989 6ac86273-5f31-0410-b378-82cca8765d1b --- docs/history.txt | 275 +++++++++++++++++++++++++++++++++++++++++++++++ mkfiles/tci.cfg | 1 + 2 files changed, 276 insertions(+) create mode 100644 mkfiles/tci.cfg diff --git a/docs/history.txt b/docs/history.txt index f028d193..a5a8e703 100644 --- a/docs/history.txt +++ b/docs/history.txt @@ -1,3 +1,278 @@ +2004 July 8 - UNSTABLE branch +-------- Jeremy Davis (jeremyd@computer.org) ++ Changes Arkady + * UTILS\PROTO.BAT, UTILS\INDENT, KERNEL\NLS_LOAD.C, KERNEL\KERNEL.CFG: removed. + + * all batch files now check if environment is enough; this prevents wrong + actions in case of small environment. + * *.BAT: %MAKE% now called through CALL; this allows to place into PATH + batch file instead utility itself. + * BUILDALL.BAT: removed ambiguous ONERROR variable. + * BUILDALL.BAT: added ">NUL" for DELs. + * CLOBBER.BAT now uses CLEAN.BAT for its job; this eases to update cleaning + code because no code duplication. + * CONFIG.B: XNASM replaced by NASM, XLINK by LINK, MS_BASE by MSC_BASE. + * CONFIG.B: added possibility to define librarian. + * CONFIG.B: added "MAKER -S" as choice for MAKE. + * DEFAULT.BAT renamed to DEFAULTS.BAT, for all "call " added + suffix .BAT; this solves compatability problem with 4DOS (where DEFAULT + is a built-in command). + * DEFAULTS.BAT: added variable BASE. + + * all MAKEFILEs now look similar. + * some makefiles renamed: BC5->BC, TURBOCPP->TCPP, TC3->TCPP3, MSCL8->MSC. + * MKFILES\*.MAK: removed space after "=" in macro definitions; this makes + command lines shorter. + * common definitions from makefiles moved to MKFILES\GENERIC.MAK + (directories) and CONFIG.B/DEFAULTS.BAT (LINK, NASM, LIBUTIL, etc). + * MKFILES\GENERIC.MAK: XCPU=86 and XFAT=32 are defined here, if environment + doesn't contains these variables; this allows to reduce environment. + * MKFILES\GENERIC.MAK: ALLCFLAGS and NASMFLAGS placed after all options + (this allows to redefine some options in config.bat); for watcom.mak + this also adds space after ALLCFLAGS (which is required, if ALLCFLAGS + ends by option like -I). + * MKFILES\GENERIC.MAK: NASMFLAGS now includes -f and -D$(COMPILER) options. + * MKFILES\TCPP.MAK: -zC option moved from ALLCFLAGS into CFLAGS (this + eliminates option duplication in INITCFLAGS and reduces command line + length). ALLCFLAGS now includes -I..\hdr;$(INCLUDEPATH) option (this + allows to reuse compiler headers (for example, limits.h), but own time.h + anyway "overloads" compiler's header). + * MKFILES\TC2.MAK, MKFILES\TCPP3.MAK, MKFILES\BC.MAK: reused contents of + MKFILES\TCPP.MAK through "!include". + * MKFILES\WATCOM.MAK: removed INCLUDE and EDPATH macroses. + * MKFILES\WATCOM.MAK: added option -d1 (to allow make listings with sources). + + * added KERNEL\TCI.CFG, which allows noticeably reduce size of INITCFLAGS + definition in MKFILES\TCPP.MAK; options for other compilers also moved + from command line to consequent KERNEL\*.CFG files. + + * KERNEL\MAKEFILE: $(TARGET).lnk rule now removes *.obj (this allows to + remove explicit dependency for $(TARGET).lnk for all other rules). + * KERNEL\TURBOC.CFG: removed redefinition of __STDC__. + + * "production" target replaced by "all" to eliminate warning from NMAKE. + * DEVICE\MAKEFILE: device.lib now created directly in ..\lib directory + without intermediate copy. + * added SYS\TURBOC.CFG and UTILS\TURBOC.CFG. + * SYS\MAKEFILE, UTILS\MAKEFILE: reused implicit rules from MKFILES\GENERIC.MAK. + + * fdkrncfg.c + - fix: eliminated warning "Initialization is only partially bracketed". + * exeflat.c + - removed duplicated definition for macro LENGTH(). + * floppy.asm + - prototypes fixed and syncronized with dsk.c. + - fixed wrong comments, more and better comments. + - bugfix: when fl_lba_ReadWrite() converted to ASMPASCAL (and `ret' replaced + by `ret 8'), "ret_AH" was remained as label for this tail (whereas other + functions use plain `ret'); now ret_AH moved into another function. + * procsupt.asm + - exec_user(), reloc_call_p_0(): added "%ifndef WATCOM/%endif" around + popping return address, because exec_user() and init_call_p_0() now + declared with `aborts' attribute for Watcom. + * entry.asm + - fix: was used signed comparision instead unsigned. + * int2f.asm + - fixed wrong comment. + * intr.asm + - wrong prototypes fixed and syncronized with *.h headers. + - small code cleanup (removed jumps) and optimizations, more comments. + * break.c + - removed extraneous variable assignment. + * dsk.c + - bugfix: blk_driver(): should be checked ">= NENTRY", not "> NENTRY". + - bugfix: Getlogdev(): in case of no DF_CURLOG flag is set, in rp->r_unit + now returned last+1 (equal to blk_dev.dh_name[0]) unit (was last+2). + - Setlogdev(): added comment about undocumented behavior. + - bugfix: Genblkdev(): + - formatting loop (0x42 function) rewritten: instead formating many tracks, + was formated one track many times (because afentry.head++ outside loop); + - now checked "afentry.track >= pddt->ddt_ncyl" (instead ">"); + - now gbfv_spcfunbit cleared at ; + - not fixed: there remained two returns without setting gbfv_spcfunbit; + - verification (0x62) now check only bit 0 of gbfv_spcfunbit; + - not fixed: verification should set gbfv_spcfunbit in case of errors. + + - removed remained excerpt from history.txt at the end. + - removed all references to PROTO macro name. + - small source cleanup (expressions simplified, extraneous casts removed). + - small code cleanup and optimization for diskchange(), mediachk(), + blk_Media(), bldbpb(), IoctlQueblk(), blockio() and dskerr(). + - many variables (like `ret') moved deeply (by adding curly braces) - for + BC this noticeably decreases stack usage. + - getddt(0) and tmark are now macros. + - blk_error() removed, consequent dispatch[] entries contains NULL and they + checked by blk_driver() before calling getddt() and dispatch[] item. + - getbpb(): removed extraneous stack variable; instead (x+y-1)/y for roundup + used (x-1)/y+1 expression; printf sequences joined into one printf. + - LBA_Transfer() now converts error code through dskerr() by itself; + .ddt_offset field added to LBA_address also inside LBA_Transfer(). + * initdisk.c + - small code optimization. + - added `const' modifier into castings. + - `bootdrv' variable inlined. + * ioctl.c + - 3 nested switch splitted into 2 switch (1st prepares parameters for + 2nd, which calls execrh()). + - device attribute word checked through table lookup. + - CharReqHdr.r_command computed through table lookup. + - removed all goto, except one. + * memmgr.c + - joinMCBs(): check that mcb is valid now before check that mcb is free. + - all "(uppermem_link & 1)" replaced by "uppermem_link", because + DosUmbLink() stores there only 0 and 1. + * nls.c + - bugfix: (Eduardo Casino, Steffen Kaiser) DosGetData(): NULL pointer was + addressed when searchPackage returns NULL. + * globals.h + - bugfix: NetRetry and NetDelay are UWORD, not UBYTE values. + * init-mod.h + - cleaned prototype for function from intr.asm. + - init_fatal() described (for Watcom) as non-returned functions. + * proto.h + - fatal() and panic() described (for Watcom) as non-returned functions; + this improves code generation. + - cleaned prototypes for functions from intr.asm. + - removed prototypes for nonexisting functions. + - added brackets around parameters of macro. + * config.c + - source: added types PStr and PCStr to ease using string pointers. + - source: for iregs members used predefined names like BH (instead b.b.h). + - source: instead `seg' type used `seg_t'. + - source: HMAState values now `enum'; for UmbState values now also given + names through `enum'. + + - added testbit() macro to make source more readable (and code shorter). + - parameter of all command processing functions (like CfgMenu()) now have + `const' modifier. + - far pointers with zero offset now decalred with `_seg' modifier, MK_FP() + replaced by MK_SEG_PTR() macro: this makes more understandable source and + noticeably enhances code for BC. + - added gotoxy() and clearScreenArea() to incapsulate screen manipulations. + - GetNumArg(): returns value in global storage; added GetNumArg1() and + GetNumArg2(), which does all check for command line syntax for other + command processing functions. + + - bugfix: umb_init() was not checks that new UMB completely inside "hole" + and its size is greater than 2 paragraphs; now borders outside of holes + are trimmed. + - bugfix: umb_init(): when joining adjacent UMBs, umb_base_seg, umb_start + and umb_max was not adjusted if they equal to start of next joined block. + - fix: umb_init(): when joining adjacent UMBs, UMB_top was not adjusted if + it equal to end of previous block; this forces to use only part of given + UMB when loading drivers. + - bugfix: umb_init(): umb_start+UMB_top was point end addres when loading + drivers and initialized to end of (first, largest) block, but this was + overlap link MCB for next UMB if umb_start was not the furthest UMB. + - bugfix: umb_init(): when joining next adjacent UMB to new block, size of + joined block was maked greater than required by 1. + - bugfix: umb_init(): when new UMB is beyond of previous furthest block + (umb_max) and first byte in last paragraph of umb_max block contains 'M', + prev_mcb() was walk after umb_max. + - bugfix: umb_init(): when EMM386 joins A000 area to base memory, it updates + 0:413 BIOS variable, but umb_init() was use older value (from ram_top + variable) when adjusts base MCB and thus destroys MCBs chain. + + - bugfix: GetBiosKey() was wrongly handles timeout==0. + - fix: ClearScreen(): screen width at 0:44A is a word, not byte. + - fix: GetStringArg() was uses scan(), which skips some nonwhitspaces; + now replaced by scanword(). + - bugfix: AlignParagraph(): "overflow" on 32-bit targets not makes zero + value, so 0x1000 should be assigned, not added to uSegVal. + - fix: PreConfig2(): to argument of AlignParagraph() was added extra 0x0f, + this captures extra paragraph before first MCB. + - fix: sysVersion(): VERSION= now works properly by setting version for + INT21/30, not for INT21/3306. + - bugfix: _CmdInstall(): "numInstallCmds > LENGTH" - should be ">=". + - bugfix: InstallExec() was call CfgFailure(), but it called after config + file processing, when szLine buffer always contains last line/garbage. + + - fix: WriteMenuLine(): blink attribute for selected line in menu now cleared. + - fix: DoConfig(): config lines in error messages now counted from 1 (not 0). + - bugfix: DoConfig(): when reading config, EOF (0x1A) was accepted as '\n'. + - fix: DoConfig(): lines with alone sequences like "?" now diagnosed. + - fix: DoConfig(): errors for unknown commands now printed only after menu. + - fix: DoConfig(): in ECHO and EECHO arguments leading spaces now preserved. + - CfgFailure(): message about error in config now same, as in MS-DOS6. + - CfgFailure(): message now contains real config name (instead "CONFIG.SYS"). + - fix: CfgFailure(): "^" in error messages now shows proper position. + + - all pressed before menu keys (if any, but except F5/F8) now preserved in + keyboard buffer. + - config now parsed in 5 passes: SWITCHES=/F/N and MENUCOLOR/MENUDEFAULT + before menu, SHELL/SET/INSTALL after DEVICE (unlike MS-DOS6, which process + SETs before INSTALLs and thus can't redefine variables between INSTALL). + - screen now cleared (when MENUCOLOR present) before all MENU lines; after + menu screen not cleared. + - DoMenu(): now, when MENU lines are longer than screen width or them are + more, than screen height, menu lines highlighting disabled. + - menu selection shown only if there is more than one choice (in "123?" + prefixes), but CONFIG=n will be defined if even one choice is present. + - CONFIG= now not defined if F5 pressed in menu. + - DoMenu(): menu now looks more like MS-DOS6 (same words, hint at bottom). + - DoMenu(): choice 0 now not allowed if it not present in "123?". + - DoMenu(): in menu now allowed to press Left and Right keys; Esc in menu + now ignored; digit pressing not finish selection. + - when tracing, Esc now turns off asks for all following lines, including + lines with "?", and assumes "Y" for all; F8 now behaves similar to Esc. + - removed extraneous COMMAND verb. + - added BUFFERSHIGH verb (for compatability with MS-DOS6; currently dummy). + - SWITCHES=/E now handled after menu and may be asked/traced. + - (E)ECHO now executed without asking and tracing. + - DeviceHigh(): DEVICEHIGH= now reloads driver into low memory without + error messages about UMB (as in MS-DOS6). + - environment for INSTALL= now includes previous SETs. + - fix: CmdSet(): with SET environment variables now may be redefined and + removed ("V="). + + ? LoadDevice() uppercases command line for driver. Wrong? + * main.c + - fix: FreeDOSmain(): "drv >= 0x80" - should be ">". + - PSPinit(): DOS_PSP.ps_environ and ps_parent now set to zero. + - kernel(): "PATH=." now not placed into empty environment (because bug with + copying empty env in task.c:ChildEnv() is fixed). + - kernel(): now "/D" or "/Y" option inserted even if command line is too + long (by trimming command line tail). + - fix: CheckContinueBootFromHarddisk(): "InitKernelConfig.BootHarddiskSeconds == 0" - + should by "<=". + * task.c + ! P_0(): old shell command line stored in SecPathName buffer and, thus, will + be overwritten by DOS rename function with argument, longer than 50 bytes. + + - fix: new_psp(): as in MS-DOS6, ps_parent now not changed; ps_exit, ps_unix, + ps_farcall, ps_reentry, ps_prevpsp, ps_maxfiles, ps_filetab and ps_files + are initialized. + - fix: new_psp(): ps_reentry now have same value, as in MS-DOS6. + - fix: child_psp(): as in MS-DOS6, ps_fcb* and ps_cmd now not changed, + ps_prevpsp is set to -1 (from new_psp()). + - bugfix: ChildEnv(): empty environment now processed correctly. + - bugfix: ChildEnv(): DosMemAlloc() was called with NULL for `asize', but + asize not always checked inside DosMemAlloc() for NULL before dereference. + - fix: ChildEnv(): for environment now allocated memory not more, than + required to store path after environment (was always 80 extra bytes). + - patchPSP(): as in MS-DOS6, FCB addresses in exec block now don't checked + and copied only 12 bytes (drive+name+ext). + - DosComLoader()/DosExeLoader(): if childEnv() failed, then `env' contains + garbage and DosMemFree(env) now not called. + - bugfix: P_0() was copy argument of SHELL line into Shell buffer without + checking length of source (note: max length of SHELL argument is a 74 + bytes, because Shell=SecPathName+50 and sizeof SecPathName=128). + - P_0(): now supported command line without space between command and + options (starting from '/'). ++ Changes Bernd, Aitor, & Arkady + * config.c + - source: (Bernd) the codepage table rewritten into a smaller layout. + - bugfix: (Bernd, Aitor) country ID for Spain set to 34 (instead 33). ++ Changes Lucho + * exeflat.c + - fix: eliminated warning by explicit cast. + - reduced trailer, added to UPXed kernel. + * segs.inc + - fix: for MSVC CONST segment should be class CONST, not DATA. + * dsk.c + - play_dj() now says same words as MS-DOS6. +*** Sync - Stable Build 2035 *** + 2004 May 30 - Build 2035 -------- Bart Oldeman (bart@dosemu.org) + Changes Lucho + Tom diff --git a/mkfiles/tci.cfg b/mkfiles/tci.cfg new file mode 100644 index 00000000..0be5d1ab --- /dev/null +++ b/mkfiles/tci.cfg @@ -0,0 +1 @@ +-zCINIT_TEXT -zRID -zTID -zSI_GROUP -zDIB -zBIB -zGI_GROUP From a097825f6b2266994c09e7ef4c5d093513ea9fe3 Mon Sep 17 00:00:00 2001 From: Kenneth J Davis Date: Sun, 11 Jul 2004 07:28:13 +0000 Subject: [PATCH 551/671] remove unused make files git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/branches/UNSTABLE@990 6ac86273-5f31-0410-b378-82cca8765d1b --- mkfiles/bc5.mak | 10 ---------- mkfiles/mscl8.mak | 31 ------------------------------- mkfiles/tc2.mak | 16 ---------------- mkfiles/tc3.mak | 7 ------- mkfiles/turbocpp.mak | 43 ------------------------------------------- 5 files changed, 107 deletions(-) delete mode 100644 mkfiles/bc5.mak delete mode 100644 mkfiles/mscl8.mak delete mode 100644 mkfiles/tc2.mak delete mode 100644 mkfiles/tc3.mak delete mode 100644 mkfiles/turbocpp.mak diff --git a/mkfiles/bc5.mak b/mkfiles/bc5.mak deleted file mode 100644 index 0a98b9df..00000000 --- a/mkfiles/bc5.mak +++ /dev/null @@ -1,10 +0,0 @@ -# -# BC5.MAK - kernel copiler options for Borland C++ -# - -!include "..\mkfiles\turbocpp.mak" - -TARGET=KBC - -CC=$(BINPATH)\bcc -c -CL=$(BINPATH)\bcc diff --git a/mkfiles/mscl8.mak b/mkfiles/mscl8.mak deleted file mode 100644 index a398c4de..00000000 --- a/mkfiles/mscl8.mak +++ /dev/null @@ -1,31 +0,0 @@ -# -# MSCL8.MAK - kernel copiler options for MS CL8 = MS VC 1.52 -# - -TARGET=KMS - -CC=$(BINPATH)\cl -batch -nologo -c -CL=$(BINPATH)\cl -batch -nologo - -# used for building the library - -CLIB=$(LIBPATH)\slibce.lib -MATH_EXTRACT=*aflmul *aFlshl *aFNauldi *aFulrem *aFulshr *aFuldiv *aFlrem *aFldiv *aFNaulsh -MATH_INSERT =+aflmul +aFlshl +aFNauldi +aFulrem +aFulshr +aFuldiv +aFlrem +aFldiv +aFNaulsh - -# - -!if $(XCPU) == 186 -CPUOPT=-G1 -!endif -!if $(XCPU) == 386 -CPUOPT=-G3 -!endif - -ALLCFLAGS=@vc.cfg -I$(INCLUDEPATH) $(CPUOPT) $(ALLCFLAGS) -INITCFLAGS=-NTINIT_TEXT -CFLAGS =-NTHMA_TEXT -INITPATCH=..\utils\patchobj _DATA=IDATA DATA=ID BSS=ID DGROUP=I_GROUP CONST=IC - -CFLAGST=-I..\hdr -I$(INCLUDEPATH) /Fm /AT /Os /Zp1 -CFLAGSC=-I..\hdr -I$(INCLUDEPATH) /Fm /AL /Os /Zp1 diff --git a/mkfiles/tc2.mak b/mkfiles/tc2.mak deleted file mode 100644 index 1d5c32c3..00000000 --- a/mkfiles/tc2.mak +++ /dev/null @@ -1,16 +0,0 @@ -# -# TC2.MAK - kernel copiler options for Turbo C 2.01 -# - -BINPATH=$(BASE) - -!include "..\mkfiles\turbocpp.mak" - -TARGET=KTC - -MATH_EXTRACT=*LDIV *LXMUL *LURSH *LLSH *LRSH -MATH_INSERT =+LDIV +LXMUL +LURSH +LLSH +LRSH - -# TCC 2.0 doesn't support responce file - -INITCFLAGS=-zCINIT_TEXT -zRID -zTID -zSI_GROUP -zDIB -zBIB -zGI_GROUP diff --git a/mkfiles/tc3.mak b/mkfiles/tc3.mak deleted file mode 100644 index a387fe54..00000000 --- a/mkfiles/tc3.mak +++ /dev/null @@ -1,7 +0,0 @@ -# -# TC3.MAK - kernel copiler options for Turbo C++ 3.0 -# - -!include "..\mkfiles\turbocpp.mak" - -TARGET=KT3 diff --git a/mkfiles/turbocpp.mak b/mkfiles/turbocpp.mak deleted file mode 100644 index 0522de09..00000000 --- a/mkfiles/turbocpp.mak +++ /dev/null @@ -1,43 +0,0 @@ -# -# TURBOCPP.MAK - kernel copiler options for Turbo C++ 1.01 -# - -TARGET=KTP - -CC=$(BINPATH)\tcc -c -CL=$(BINPATH)\tcc - -# used for building the library - -CLIB=$(LIBPATH)\cs.lib -MATH_EXTRACT=*H_LDIV *H_LLSH *H_LURSH *F_LXMUL -MATH_INSERT =+H_LDIV +H_LLSH +H_LURSH +F_LXMUL - -# -# Compiler options for Turbo/Borland C -# ------------------------------------ -# -# -zAname ¦ ¦ Code class -# -zBname ¦ ¦ BSS class -# -zCname ¦ ¦ Code segment -# -zDname ¦ ¦ BSS segment -# -zEname ¦ ¦ Far segment -# -zFname ¦ ¦ Far class -# -zGname ¦ ¦ BSS group -# -zHname ¦ ¦ Far group -# -zPname ¦ ¦ Code group -# -zRname ¦ ¦ Data segment -# -zSname ¦ ¦ Data group -# -zTname ¦ ¦ Data class -# -zX ¦«¦ Use default name for "X" - -# -# Common options specified in turboc.cfg instead ALLCFLAGS -# - -ALLCFLAGS=-I..\hdr;$(INCLUDEPATH) $(CPUOPT) $(ALLCFLAGS) -INITCFLAGS=@..\mkfiles\tci.cfg -CFLAGS =-zCHMA_TEXT - -CFLAGST=-I..\hdr;$(INCLUDEPATH) -L$(LIBPATH) -mt -lt # -ff- -CFLAGSC=-I..\hdr;$(INCLUDEPATH) -L$(LIBPATH) -mc From 640ab403e298cbda43fc52b23e0903d569eb4d1d Mon Sep 17 00:00:00 2001 From: Kenneth J Davis Date: Sun, 11 Jul 2004 08:36:25 +0000 Subject: [PATCH 552/671] from Arkady: actually remove indicated files, readd filelist, fix co_m_piler typo, from Tom: improve behaviour on failed FindFirst call and return to app not DOS git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/branches/UNSTABLE@991 6ac86273-5f31-0410-b378-82cca8765d1b --- build.bat | 1 + docs/history.txt | 9 ++- filelist | 155 +++++++++++++++++++++++++++++++++++++++++++++ hdr/version.h | 4 +- kernel/inthndlr.c | 7 ++ kernel/kernel.cfg | 14 ---- kernel/main.c | 23 +++++-- kernel/nls_load.c | 51 --------------- mkfiles/bc.mak | 2 +- mkfiles/msc.mak | 2 +- mkfiles/tc.mak | 2 +- mkfiles/tci.cfg | 1 - mkfiles/tcpp.mak | 2 +- mkfiles/tcpp3.mak | 2 +- mkfiles/watcom.mak | 2 +- 15 files changed, 197 insertions(+), 80 deletions(-) create mode 100644 filelist delete mode 100644 kernel/kernel.cfg delete mode 100644 kernel/nls_load.c delete mode 100644 mkfiles/tci.cfg diff --git a/build.bat b/build.bat index 29eba7a7..07841c5e 100644 --- a/build.bat +++ b/build.bat @@ -111,6 +111,7 @@ goto end :abort-cd cd .. :noenv +echo Unable to set necessary environment variables! :abort echo Compilation was aborted! diff --git a/docs/history.txt b/docs/history.txt index a5a8e703..f6477f81 100644 --- a/docs/history.txt +++ b/docs/history.txt @@ -1,7 +1,12 @@ 2004 July 8 - UNSTABLE branch -------- Jeremy Davis (jeremyd@computer.org) ++ Changes Tom + * inthndlr.c + - improve handling of case where eg. FindFirst(I:\*.*) fails, causes Int24, + and application chooses to pop stack returning to self and does NOT return + to DOS; so fnode[0] never freed and errormode not set back to 0 until exit() + Changes Arkady - * UTILS\PROTO.BAT, UTILS\INDENT, KERNEL\NLS_LOAD.C, KERNEL\KERNEL.CFG: removed. + * UTILS\PROTO.BAT, KERNEL\NLS_LOAD.C, KERNEL\KERNEL.CFG: removed. * all batch files now check if environment is enough; this prevents wrong actions in case of small environment. @@ -22,7 +27,7 @@ * all MAKEFILEs now look similar. * some makefiles renamed: BC5->BC, TURBOCPP->TCPP, TC3->TCPP3, MSCL8->MSC. * MKFILES\*.MAK: removed space after "=" in macro definitions; this makes - command lines shorter. + command lines shorter. Typo fix, copiler->compiler * common definitions from makefiles moved to MKFILES\GENERIC.MAK (directories) and CONFIG.B/DEFAULTS.BAT (LINK, NASM, LIBUTIL, etc). * MKFILES\GENERIC.MAK: XCPU=86 and XFAT=32 are defined here, if environment diff --git a/filelist b/filelist new file mode 100644 index 00000000..def97df8 --- /dev/null +++ b/filelist @@ -0,0 +1,155 @@ +*/*/build.bat +*/*/buildall.bat +*/*/clean.bat +*/*/clobber.bat +*/*/config.b +*/*/defaults.bat +*/*/filelist +*/*/makefile +*/*/bin/autoexec.bat +*/*/bin/config.sys +*/*/bin/install.bat +*/*/boot/boot.asm +*/*/boot/boot32.asm +*/*/boot/boot32lb.asm +*/*/boot/makefile +*/*/docs/bugs.txt +*/*/docs/build.txt +*/*/docs/config.txt +*/*/docs/contrib.txt +*/*/docs/copying +*/*/docs/fdkernel.lsm +*/*/docs/history.txt +*/*/docs/intfns.txt +*/*/docs/lfnapi.txt +*/*/docs/mkboot.txt +*/*/docs/nls.txt +*/*/docs/readme.cvs +*/*/docs/readme.txt +*/*/docs/sys.txt +*/*/drivers/floppy.asm +*/*/drivers/makefile +*/*/drivers/rdpcclk.asm +*/*/drivers/wratclk.asm +*/*/drivers/wrpcclk.asm +*/*/hdr/algnbyte.h +*/*/hdr/algndflt.h +*/*/hdr/buffer.h +*/*/hdr/cds.h +*/*/hdr/clock.h +*/*/hdr/date.h +*/*/hdr/dcb.h +*/*/hdr/device.h +*/*/hdr/dirmatch.h +*/*/hdr/error.h +*/*/hdr/exe.h +*/*/hdr/fat.h +*/*/hdr/fcb.h +*/*/hdr/file.h +*/*/hdr/fnode.h +*/*/hdr/kbd.h +*/*/hdr/kconfig.h +*/*/hdr/lol.h +*/*/hdr/mcb.h +*/*/hdr/network.h +*/*/hdr/nls.h +*/*/hdr/pcb.h +*/*/hdr/portab.h +*/*/hdr/process.h +*/*/hdr/sft.h +*/*/hdr/stacks.inc +*/*/hdr/tail.h +*/*/hdr/time.h +*/*/hdr/version.h +*/*/hdr/xstructs.h +*/*/kernel/nls/001-437.hc +*/*/kernel/nls/001-437.unf +*/*/kernel/nls/001-437.up +*/*/kernel/nls/049-850.hc +*/*/kernel/nls/049-850.unf +*/*/kernel/nls/049-850.up +*/*/kernel/nls/files +*/*/kernel/apisupt.asm +*/*/kernel/asmsupt.asm +*/*/kernel/blockio.c +*/*/kernel/break.c +*/*/kernel/chario.c +*/*/kernel/config.c +*/*/kernel/config.h +*/*/kernel/console.asm +*/*/kernel/dosfns.c +*/*/kernel/dosidle.asm +*/*/kernel/dosnames.c +*/*/kernel/dsk.c +*/*/kernel/dyndata.h +*/*/kernel/dyninit.c +*/*/kernel/entry.asm +*/*/kernel/error.c +*/*/kernel/execrh.asm +*/*/kernel/fatdir.c +*/*/kernel/fatfs.c +*/*/kernel/fattab.c +*/*/kernel/fcbfns.c +*/*/kernel/globals.h +*/*/kernel/init-dat.h +*/*/kernel/init-mod.h +*/*/kernel/initclk.c +*/*/kernel/initdisk.c +*/*/kernel/inithma.c +*/*/kernel/initoem.c +*/*/kernel/int2f.asm +*/*/kernel/inthndlr.c +*/*/kernel/intr.asm +*/*/kernel/makefile +*/*/kernel/io.asm +*/*/kernel/io.inc +*/*/kernel/ioctl.c +*/*/kernel/iprf.c +*/*/kernel/irqstack.asm +*/*/kernel/kernel.asm +*/*/kernel/lfnapi.c +*/*/kernel/ludivmul.inc +*/*/kernel/main.c +*/*/kernel/memmgr.c +*/*/kernel/misc.c +*/*/kernel/network.c +*/*/kernel/newstuff.c +*/*/kernel/nls.c +*/*/kernel/nls_hc.asm +*/*/kernel/nlssupt.asm +*/*/kernel/prf.c +*/*/kernel/printer.asm +*/*/kernel/procsupt.asm +*/*/kernel/proto.h +*/*/kernel/segs.inc +*/*/kernel/serial.asm +*/*/kernel/strings.c +*/*/kernel/sysclk.c +*/*/kernel/syspack.c +*/*/kernel/systime.c +*/*/kernel/task.c +*/*/kernel/tci.cfg +*/*/kernel/turboc.cfg +*/*/kernel/msc.cfg +*/*/kernel/wc.cfg +*/*/kernel/wci.cfg +*/*/lib/makefile +*/*/mkfiles/generic.mak +*/*/mkfiles/bc.mak +*/*/mkfiles/tc.mak +*/*/mkfiles/tcpp.mak +*/*/mkfiles/tcpp3.mak +*/*/mkfiles/msc.mak +*/*/mkfiles/watcom.mak +*/*/sys/fdkrncfg.c +*/*/sys/bin2c.c +*/*/sys/makefile +*/*/sys/sys.c +*/*/sys/talloc.c +*/*/utils/echoto.bat +*/*/utils/exeflat.c +*/*/utils/makefile +*/*/utils/patchobj.c +*/*/utils/relocinf.c +*/*/utils/rmfiles.bat +*/*/utils/wlinker.bat diff --git a/hdr/version.h b/hdr/version.h index 008deeb7..f6a118de 100644 --- a/hdr/version.h +++ b/hdr/version.h @@ -49,6 +49,6 @@ static BYTE *date_hRcsId = #define REVISION_MINOR 1 #define REVISION_SEQ 35 #define BUILD "2035a" -#define SUB_BUILD "" +#define SUB_BUILD "-UNSTABLE" #define KERNEL_VERSION_STRING "1.1.35a" /*#REVISION_MAJOR "." #REVISION_MINOR "." #REVISION_SEQ */ -#define KERNEL_BUILD_STRING "2035a" /*#BUILD SUB_BUILD */ +#define KERNEL_BUILD_STRING "2035a-UNSTABLE" /*#BUILD SUB_BUILD */ diff --git a/kernel/inthndlr.c b/kernel/inthndlr.c index 72e577ee..11999aae 100644 --- a/kernel/inthndlr.c +++ b/kernel/inthndlr.c @@ -414,6 +414,13 @@ VOID ASMCFUNC int21_service(iregs FAR * r) } /* Clear carry by default for these functions */ + /* see PATCH TE 5 jul 04 explanation at end */ + if (ErrorMode && lr.AH > 0x0c && lr.AH != 0x30 && lr.AH != 0x59) + { + ErrorMode = 0; + fnode[0].f_count = 0; /* don't panic - THEY ARE unused !! */ + fnode[1].f_count = 0; + } /* Check for Ctrl-Break */ if (break_ena || (lr.AH >= 1 && lr.AH <= 5) || (lr.AH >= 8 && lr.AH <= 0x0b)) diff --git a/kernel/kernel.cfg b/kernel/kernel.cfg deleted file mode 100644 index 38d5ef57..00000000 --- a/kernel/kernel.cfg +++ /dev/null @@ -1,14 +0,0 @@ --1- --f- --ff- --O --Z --d --k- --vi- --w --wpro --weas --wpre --I..\hdr --v -X- -I. -D__STDC__=0 -DTSC -DDEBUG -DKERNEL -DI86 -DPROTO -DSHWR -DASMSUPT diff --git a/kernel/main.c b/kernel/main.c index cddb2992..9d453e85 100644 --- a/kernel/main.c +++ b/kernel/main.c @@ -90,17 +90,32 @@ void ASMCFUNC FreeDOSmain(void) UBYTE drv; UBYTE FAR *p = MK_PTR(UBYTE, 0, 0x5e2); if (fmemcmp(p, "CONFIG", 6) == 0) /* UPXed */ - drv = p[-2]; /* boot drive was stored there by stub from exeflat.c */ + drv = p[-2]; /* stored there by stub from exeflat.c */ + + /* !!! stub, added by exeflat.c for UPXed kernel, should store + boot drive# in the CONFIG-block, not outside (below) it. --avb */ + else { drv = LoL->BootDrive; - p[-2] = drv; /* used by initdisk.c:ReadAllPartitionTables() */ + + /* !!! kernel.asm should store boot drive# from BL into + LowKernelConfig instead LoL->BootDrive. --avb */ + + p[-2] = drv; /* used in initdisk.c */ + + /* !!! initdisk.c:ReadAllPartitionTables() should get boot drive# + from InitKernelConfig, not at fixed address 0:5e0. --avb */ + p = (UBYTE FAR*)&LowKernelConfig; } - drv++; + /* !!! boot drive# should be get from InitKernelConfig after + copying there FAR memory (from 0:5e0 or LowKernelConfig). --avb */ + + drv++; /* A:=1, B:=2 */ if (drv > 0x80) - drv = 3; /* C: */ + drv = 3; /* C: */ LoL->BootDrive = drv; fmemcpy(&InitKernelConfig, p, sizeof InitKernelConfig); diff --git a/kernel/nls_load.c b/kernel/nls_load.c deleted file mode 100644 index 0a4fa655..00000000 --- a/kernel/nls_load.c +++ /dev/null @@ -1,51 +0,0 @@ -/****************************************************************/ -/* */ -/* nls_load.c */ -/* FreeDOS */ -/* */ -/* National Languge Support functions and data structures */ -/* Load an entry from FreeDOS COUNTRY.SYS file. */ -/* */ -/* Copyright (c) 2000 */ -/* Steffen Kaiser */ -/* All Rights Reserved */ -/* */ -/* This file is part of FreeDOS. */ -/* */ -/* DOS-C is free software; you can redistribute it and/or */ -/* modify it under the terms of the GNU General Public License */ -/* as published by the Free Software Foundation; either version */ -/* 2, or (at your option) any later version. */ -/* */ -/* DOS-C is distributed in the hope that it will be useful, but */ -/* WITHOUT ANY WARRANTY; without even the implied warranty of */ -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See */ -/* the GNU General Public License for more details. */ -/* */ -/* You should have received a copy of the GNU General Public */ -/* License along with DOS-C; see the file COPYING. If not, */ -/* write to the Free Software Foundation, 675 Mass Ave, */ -/* Cambridge, MA 02139, USA. */ -/****************************************************************/ - -#include "portab.h" -#include "init-mod.h" - -#ifdef VERSION_STRINGS -static BYTE *RcsId = - "$Id$"; -#endif - -/** Setup the environment for shared source NLS_LOAD.SRC **/ -/**ska obsoleted #define cfgMemory Config.cfgCSYS_memory */ -/**ska obsoleted #define cfgFilename Config.cfgCSYS_fnam */ -#define cfgFilename nlsInfo.fname /* char FAR * */ -/**ska obsoleted #define cfgCountry Config.cfgCSYS_cntry */ -/**ska obsoleted #define cfgCodepage Config.cfgCSYS_cp */ -#define cfgData Config.cfgCSYS_data /* struct nlsCSys_loadPackage FAR * */ -#define getMem(bytes) KernelAlloc(bytes) -#define openSYSFile(filename) open(filename, 0) /* read-only, binary */ -#define nlsStartOfChain nlsInfo.chain -#define upCaseFct CharMapSrvc - -#include "nls_load.src" diff --git a/mkfiles/bc.mak b/mkfiles/bc.mak index 9cb252a3..51d0cbd5 100644 --- a/mkfiles/bc.mak +++ b/mkfiles/bc.mak @@ -1,5 +1,5 @@ # -# BC.MAK - kernel copiler options for Borland C++ +# BC.MAK - kernel compiler options for Borland C++ # !include "..\mkfiles\tcpp.mak" diff --git a/mkfiles/msc.mak b/mkfiles/msc.mak index 3c8945c1..a3044e14 100644 --- a/mkfiles/msc.mak +++ b/mkfiles/msc.mak @@ -1,5 +1,5 @@ # -# MSC.MAK - kernel copiler options for MS VC 1.5x (MS CL 8.x) +# MSC.MAK - kernel compiler options for MS VC 1.5x (MS CL 8.x) # TARGET=KMS diff --git a/mkfiles/tc.mak b/mkfiles/tc.mak index 856b65fe..05fa52fa 100644 --- a/mkfiles/tc.mak +++ b/mkfiles/tc.mak @@ -1,5 +1,5 @@ # -# TC.MAK - kernel copiler options for Turbo C 2.01 +# TC.MAK - kernel compiler options for Turbo C 2.01 # BINPATH=$(BASE) diff --git a/mkfiles/tci.cfg b/mkfiles/tci.cfg deleted file mode 100644 index 0be5d1ab..00000000 --- a/mkfiles/tci.cfg +++ /dev/null @@ -1 +0,0 @@ --zCINIT_TEXT -zRID -zTID -zSI_GROUP -zDIB -zBIB -zGI_GROUP diff --git a/mkfiles/tcpp.mak b/mkfiles/tcpp.mak index e3afc341..643fd151 100644 --- a/mkfiles/tcpp.mak +++ b/mkfiles/tcpp.mak @@ -1,5 +1,5 @@ # -# TCPP.MAK - kernel copiler options for Turbo C++ 1.01 +# TCPP.MAK - kernel compiler options for Turbo C++ 1.01 # TARGET=KTP diff --git a/mkfiles/tcpp3.mak b/mkfiles/tcpp3.mak index c1a448b6..1df46c6b 100644 --- a/mkfiles/tcpp3.mak +++ b/mkfiles/tcpp3.mak @@ -1,5 +1,5 @@ # -# TCPP3.MAK - kernel copiler options for Turbo C++ 3.0 +# TCPP3.MAK - kernel compiler options for Turbo C++ 3.0 # !include "..\mkfiles\tcpp.mak" diff --git a/mkfiles/watcom.mak b/mkfiles/watcom.mak index 95cda19c..23671fe8 100644 --- a/mkfiles/watcom.mak +++ b/mkfiles/watcom.mak @@ -1,5 +1,5 @@ # -# WATCOM.MAK - kernel copiler options for WATCOM C/OpenWatcom +# WATCOM.MAK - kernel compiler options for WATCOM C/OpenWatcom # TARGET=KWC From f4ab00c556ef8f5aaf77e3691ba63bcc2b022640 Mon Sep 17 00:00:00 2001 From: Kenneth J Davis Date: Sun, 25 Jul 2004 09:55:58 +0000 Subject: [PATCH 553/671] patches from Arkady, Lucho, and Bart -- see history.txt for details git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/branches/UNSTABLE@1009 6ac86273-5f31-0410-b378-82cca8765d1b --- boot/boot.asm | 165 +++++++++++------------------ build.bat | 12 ++- config.b | 1 + defaults.bat | 1 + docs/config.txt | 246 +++++++++++++++++++++++++++++++++++++------- docs/contrib.txt | 2 +- docs/history.txt | 26 +++++ drivers/makefile | 2 +- filelist | 2 + hdr/dcb.h | 5 +- hdr/device.h | 2 +- hdr/dirmatch.h | 29 ++---- kernel/dosfns.c | 112 ++++++++------------ kernel/dsk.c | 40 ++++--- kernel/int2f.asm | 2 + kernel/inthndlr.c | 109 ++++++++++---------- kernel/ioctl.c | 20 ++-- kernel/ludivmul.inc | 192 +++++++++++++++++++--------------- kernel/main.c | 12 ++- kernel/nls.c | 10 +- kernel/proto.h | 8 +- kernel/task.c | 2 +- kernel/vc.cfg | 5 - sys/fdkrncfg.c | 4 - sys/sys.c | 21 ++-- 25 files changed, 603 insertions(+), 427 deletions(-) delete mode 100644 kernel/vc.cfg diff --git a/boot/boot.asm b/boot/boot.asm index af2c527e..fac35f12 100644 --- a/boot/boot.asm +++ b/boot/boot.asm @@ -91,50 +91,6 @@ Entry: jmp short real_start ;%define StoreSI bp+3h ;temp store -; To save space, functions that are just called once are -; implemented as macros instead. Four bytes are saved by -; avoiding the call / ret instructions. - - -; GETDRIVEPARMS: Calculate start of some disk areas. -; - -%macro GETDRIVEPARMS 0 - mov si, word [nHidden] - mov di, word [nHidden+2] - add si, word [bsResSectors] - adc di, byte 0 ; DI:SI = first FAT sector - - mov word [fat_start], si - mov word [fat_start+2], di - - mov al, [bsFATs] - cbw - mul word [sectPerFat] ; DX:AX = total number of FAT sectors - - add si, ax - adc di, dx ; DI:SI = first root directory sector - mov word [root_dir_start], si - mov word [root_dir_start+2], di - - ; Calculate how many sectors the root directory occupies. - mov bx, [bsBytesPerSec] - mov cl, 5 ; divide BX by 32 - shr bx, cl ; BX = directory entries per sector - - mov ax, [bsRootDirEnts] - xor dx, dx - div bx - - mov word [RootDirSecs], ax ; AX = sectors per root directory - - add si, ax - adc di, byte 0 ; DI:SI = first data sector - - mov [data_start], si - mov [data_start+2], di -%endmacro - ;----------------------------------------------------------------------- times 0x3E-$+$$ db 0 @@ -216,10 +172,42 @@ dont_use_dl: ; no, rely on [drive] written by SYS mov LBA_SIZE, 10h mov LBA_SECNUM,1 ; initialise LBA packet constants - call print - db "FreeDOS",0 - GETDRIVEPARMS +; GETDRIVEPARMS: Calculate start of some disk areas. +; + mov si, word [nHidden] + mov di, word [nHidden+2] + add si, word [bsResSectors] + adc di, byte 0 ; DI:SI = first FAT sector + + mov word [fat_start], si + mov word [fat_start+2], di + + mov al, [bsFATs] + cbw + mul word [sectPerFat] ; DX:AX = total number of FAT sectors + + add si, ax + adc di, dx ; DI:SI = first root directory sector + mov word [root_dir_start], si + mov word [root_dir_start+2], di + + ; Calculate how many sectors the root directory occupies. + mov bx, [bsBytesPerSec] + mov cl, 5 ; divide BX by 32 + shr bx, cl ; BX = directory entries per sector + + mov ax, [bsRootDirEnts] + xor dx, dx + div bx + + mov word [RootDirSecs], ax ; AX = sectors per root directory + + add si, ax + adc di, byte 0 ; DI:SI = first data sector + + mov [data_start], si + mov [data_start+2], di ; FINDFILE: Searches for the file in the root directory. @@ -235,8 +223,6 @@ dont_use_dl: ; no, rely on [drive] written by SYS mov di, word [RootDirSecs] les bx, [loadsegoff_60] ; es:bx = 60:0 call readDisk - jc jmp_boot_error - les di, [loadsegoff_60] ; es:di = 60:0 @@ -258,10 +244,6 @@ next_entry: mov cx, 11 ffDone: push ax ; store first cluster number -; call print -; db " FAT",0 - - ; GETFATCHAIN: ; @@ -271,20 +253,16 @@ ffDone: ; ; The file must fit in conventional memory, so it can't be larger than ; 640 kb. The sector size must be at least 512 bytes, so the FAT chain -; can't be larger than around 3 kb. +; can't be larger than 2.5 KB (655360 / 512 * 2 = 2560). ; ; Call with: AX = first cluster in chain - ; Load the complete FAT into memory. The FAT can't be larger - ; than 128 kb, so it should fit in the temporary buffer. - les bx, [loadsegoff_60] ; es:bx=60:0 mov di, [sectPerFat] mov ax, word [fat_start] mov dx, word [fat_start+2] call readDisk pop ax ; restore first cluster number -jmp_boot_error: jc boot_error ; Set ES:DI to the temporary storage for the FAT chain. push ds @@ -342,9 +320,6 @@ finished: ; Mark end of FAT chain with 0, so we have a single push cs pop ds - ;call print - ;db " Kernel",0 ; "KERNEL" - ; loadFile: Loads the file into memory, one cluster at a time. @@ -353,10 +328,12 @@ finished: ; Mark end of FAT chain with 0, so we have a single mov si, FATBUF ; set DS:SI to the FAT chain cluster_next: lodsw ; AX = next cluster to read - or ax, ax ; if EOF... - je boot_success ; ...boot was successful + or ax, ax ; EOF? + jne load_next ; no, continue + mov bl,dl ; drive (left from readDisk) + jmp far [loadsegoff_60] ; yes, pass control to kernel - dec ax ; cluster numbers start with 2 +load_next: dec ax ; cluster numbers start with 2 dec ax mov di, word [bsSecPerClust] @@ -365,35 +342,26 @@ cluster_next: lodsw ; AX = next cluster to read add ax, [data_start] adc dx, [data_start+2] ; DX:AX = first sector to read call readDisk - jnc cluster_next - - -boot_error: call print - db " err",0 + jmp short cluster_next - xor ah,ah - int 0x16 ; wait for a key - int 0x19 ; reboot the machine - -boot_success: - ;call print - ;db " GO! ",0 - mov bl, [drive] - jmp far [loadsegoff_60] +; shows text after the call to this function. +show: pop si + lodsb ; get character + push si ; stack up potential return address + mov ah,0x0E ; show character + int 0x10 ; via "TTY" mode + cmp al,'.' ; end of string? + jne show ; until done + ret -; prints text after call to this function. +boot_error: call show + db "Error! Hit a key to reboot." -print_1char: - xor bx, bx ; video page 0 - mov ah, 0x0E ; else print it - int 0x10 ; via TTY mode -print: pop si ; this is the first character -print1: lodsb ; get token - push si ; stack up potential return address - cmp al, 0 ; end of string? - jne print_1char ; until done - ret ; and jump to it + xor ah,ah + int 0x13 ; reset floppy + int 0x16 ; wait for a key + int 0x19 ; reboot the machine ; readDisk: Reads a number of sectors into memory. @@ -401,7 +369,6 @@ print1: lodsb ; get token ; Call with: DX:AX = 32-bit DOS sector number ; DI = number of sectors to read ; ES:BX = destination buffer -; ES must be 64k aligned (1000h, 2000h etc). ; ; Returns: CF set on error ; ES:BX points one byte after the last byte read. @@ -413,6 +380,8 @@ readDisk: push si mov word [LBA_SEG],es mov word [LBA_OFF],bx + call show + db "." read_next: ;******************** LBA_READ ******************************* @@ -487,25 +456,15 @@ read_normal_BIOS: xchg ch, cl ; set cyl no low 8 bits ror cl, 1 ; move track high bits into ror cl, 1 ; bits 7-6 (assumes top = 0) - mov al, byte [sectPerTrack] - sub al, ah ; al has # of sectors left - inc ah ; sector offset from 1 or cl, ah ; merge sector into cylinder + inc cx ; make sector 1-based (1-63) les bx,[LBA_OFF] mov ax, 0x0201 do_int13_read: mov dl, [drive] int 0x13 - -read_finished: - jnc read_ok ; jump if no error - xor ah, ah ; else, reset floppy - int 0x13 -read_next_chained: - jmp short read_next ; read the same sector again - -read_ok: + jc boot_error ; exit on error mov ax, word [bsBytesPerSec] div byte[LBA_PACKET] ; luckily 16 !! add word [LBA_SEG], ax @@ -513,7 +472,7 @@ read_ok: add LBA_SECTOR_0, byte 1 adc LBA_SECTOR_16, byte 0 ; DX:AX = next sector to read dec di ; if there is anything left to read, - jnz read_next_chained ; continue + jnz read_next ; continue mov es,word [LBA_SEG] ; clear carry: unnecessary since adc clears it diff --git a/build.bat b/build.bat index 07841c5e..61f0cb5d 100644 --- a/build.bat +++ b/build.bat @@ -4,7 +4,7 @@ :- $Id$ :----------------------------------------------------------------------- -:- Syntax: BUILD [-r] [fat32|fat16] [msc|wc|tc|tcpp] [86|186|386] +:- Syntax: BUILD [-r] [fat32|fat16] [msc|wc|tc|tcpp] [86|186|386] [debug] [lfnapi] :- option case is significant !! :----------------------------------------------------------------------- @@ -39,6 +39,9 @@ if "%1" == "86" set XCPU=86 if "%1" == "186" set XCPU=186 if "%1" == "386" set XCPU=386 +if "%1" == "debug" set ALLCFLAGS=%ALLCFLAGS% -DDEBUG +if "%1" == "lfnapi" set ALLCFLAGS=%ALLCFLAGS% -DWITHLFNAPI + shift if not "%1" == "" goto loop_commandline @@ -108,10 +111,13 @@ goto end :----------------------------------------------------------------------- -:abort-cd -cd .. :noenv echo Unable to set necessary environment variables! +goto abort + +:abort-cd +cd .. + :abort echo Compilation was aborted! diff --git a/config.b b/config.b index 5f089180..e17b41cf 100644 --- a/config.b +++ b/config.b @@ -109,6 +109,7 @@ set XUPX=upx --8086 --best :----------------------------------------------------------------------- :- select default target: CPU type (default is 86) and :- what FAT system (default is 32) to support +:- NOTE: Turbo C doesn't support 386 CPU. ::set XCPU=86 ::set XCPU=186 diff --git a/defaults.bat b/defaults.bat index 2abde5e0..6b711e35 100644 --- a/defaults.bat +++ b/defaults.bat @@ -80,6 +80,7 @@ set MAKE= set XUPX= set XCPU= set XFAT= +set ALLCFLAGS= if not "%OLDPATH%" == "" set PATH=%OLDPATH% set OLDPATH= diff --git a/docs/config.txt b/docs/config.txt index 3bd6b1ed..8e98016f 100644 --- a/docs/config.txt +++ b/docs/config.txt @@ -1,51 +1,220 @@ -Advanced - FreeDOS specific - CONFIG.SYS processing - -a new command DOSDATA=UMB -DOSDATA=UMB loads some FreeDOS specific stuff in Upper Memory Blocks, -like the RAM that FILESHIGH, LASTDRIVEHIGH, and STACKSHIGH occupy - -a new command ECHO -ECHO does ECHO its argument (surprised ?-) and is executed at -the time the DEVICE= lines are executed. -use it similarly to - - ECHO loading driver 1 - device=Driver1.sys - ECHO driver1 successfully loaded - -a new command called EECHO is also available, for echo-ing ANSI Escape Sequences -(redefines keyboard input for example). - - -an undocumented command SCREEN=xx -SCREEN= switches into videomode xxx (INT10/11xx/000) -useful - SCREEN=0x11 -- 28 lines - SCREEN=0x12 -- 43/50 lines (on EGA/VGA) - - - -the following advanced config.sys processing options are available: +Configuring your DOS system for use: +------------------------------------ +When booting DOS, you will find it only supports a subset of +the devices available on many computers. To support additional +devices and advanced features, device specific driver and +memory resident software most be loaded. This allows the +kernel to be easily extended to support hardware not presently +available and take better advantage of installed hardware +without wasting resources on computers lacking it. This +software is generally loaded during the kernel initialization +phase, with details describing what to load expressed in the +file CONFIG.SYS. The FreeDOS kernel will first look for a +file named FDCONFIG.SYS, should it exist, it will will be used +instead of CONFIG.SYS; this allows the FreeDOS kernel to coexist +and be configured differently than another DOS kernel. There +are additional options available to adjust other aspects of the +kernels behaviour. Note: some options listed below are FreeDOS +specific and will not work when using other/older DOS kernels. +Below is list of all documented FreeDOS config.sys supported +options; additional undocumented options may exist but are not +meant for normal usage. + + +BREAK +Usage: break=on|off +Set extended Control-C/Control-Break checking to on [default] or off. +When set to on, the kernel will perform the check (and invoke current +handler if pressed) prior to most int 21h calls. When set to off, +the kernel only performs the check on I/O calls using standard streams. +e.g. break=off + +BUFFERS +BUFFERSHIGH +Usage: buffers=nn[,n] where nn is in range 1-99 & n is in range 1-8 +Memory buffers used by the kernel; primary[,secondary] +The secondary buffer option is available for compatibility with +other DOS kernels, but is ignored by the FreeDOS kernel. +e.g. buffers=20 + +COUNTRY +Usage: country=nnn[,[mmm][,[d:][path]file]] +Only limited country=nnn support is presently available. +Enables/sets international features of DOS +nnn is country code (001==US) +mmm is code page (437 is default, 850 is updated form, 1252 for Windows) +[drive][path]file specifies file with country specific data +e.g. country=001,850,C:\FDOS\BIN\COUNTRY.SYS + +DEVICE +Usage: device=[d:][path]file [options] +Load the device driver specified by d:path\file (into conventional +[low 640KB] memory). The options are for the driver itself; refer +to documentation that came with your particular device for supported +options and their usage. +e.g. device=himem.sys + +DEVICEHIGH +Usage: devicehigh=[d:][path]file [options] +This is just like device= statement, except it attempts to load +the device driver into high memory first (failing that it should +load it in conventional memory). +Note: The order you load devices may have a large impact on amount +of free memory available. In general try to load large (in memory +usage) programs into high memory first. +Important: You should have a high memory manager such as FDXMS or +Himem installed (prior device=FDXMS.SYS or device=HIMEM.SYS) before +using this option. +e.g. devicehigh=atapicdd.sys /D:FDCD0001 + +DOS +Usage: dos=high|low,umb|noumb +Indicates whether the kernel should try to load itself into +high memory or only conventional (low), and whether to link +upper memory blocks in with normal memory or not. +Note: only one set need be given, ie dos=high and dos=noumb are ok. +Important: if you specify dos=high[,umb|noumb] then you must also +load a high memory manager (first), ie FDXMS or HIMEM +e.g. dos=high,umb +or dos=low,noumb + +DOSDATA +Usage: dosdata=umb +Try to load kernel data into Upper Memory Blocks; effectively +same as using the HIGH variant of kernel parameters, +such as fileshigh, lastdrivehigh, and stackshigh (does not +effect drivers loaded using device= or install=). +e.g. dosdata=umb + +ECHO +Usage: ECHO Message to be displayed to user. +ECHO displays (echos) its arguments to the console during +config.sys processing when device drivers are loaded (when +DEVICE= lines are executed). +e.g. + ECHO loading driver 1 + device=Driver1.sys + ECHO driver1 successfully loaded + +EECHO +Usage: EECHO Message with ANSI Escape Sequence +EECHO allows for echo-ing ANSI Escape Sequences +(redefines keyboard input for example). Use a dollar sign ($) +to represent the ANSI Escape character. Note: requires an +ansi driver loaded prior to use. + +FCBS +Usage: fcbs=nnn +where nnn is in range 1-255 +Sets the number of File Control Blocks to reserve room for. +As file control blocks have been replaced by file handles +(see files) most applications will not need this value adjusted. +e.g. fcbs=4 + +FILES +FILESHIGH +Usage: files=nnn +where nnn is in range 8-255 (default 8) +Specifies how many files allowed open at once (reserves +memory necessary to support opening this many files). +Note: there are other restrictions, so a given program + may not be able to actually open this many +A good number is 20, though some programs suggest/require +30, 40, or even 255 +e.g. files=20 + +INSTALL +INSTALLHIGH +Usage: install=[d:][path]file [options] +Load the program specified by d:path\file. Generally used to +load TSR (terminate and stay resident) programs with a minimal +environment block. The options are for the program itself; refer +to documentation that came with your particular software for +supported options and usage. +e.g. install=nansi.com + +LASTDRIVE +LASTDRIVEHIGH +Usage: lastdrive=x +where x is last drive letter available for use; A-Z +e.g. lastdrive=z + +NUMLOCK +Usage: numlock=on|off +Set the keyboard number lock to on or off. +e.g. numlock=off + +REM +Usage: rem Your remarks! +This provides the ability to place comments within the configuration +file. The text following the rem until the end of the line is +reached are ignored. This may also be used to temporarily disable +loading a particular device or other option. + +SCREEN +Usage: screen=xx +Switches into videomode xxx (INT10/11xx/000) +where xx should be 0x11 for 28 lines or 0x12 for 43/50 (EGA/VGA) lines + +SET +Usage: set ENVVAR=value +Sets the environment variable to provided value. +e.g. set HOME=C:\home\me + +SHELL +SHELLHIGH +Usage: shell=[d:][path]file [options] +Indicates the shell to use; often used to alter COMMAND.COM's behavior. +Note: it is command.com that processes AUTOEXEC.BAT; by using the +shell option, you can get command.com to process a differently named +file (such as FDAUTO.BAT for coexisting with another DOS using different +configuration options) or run a completely different command interpreter +such as 4DOS or a (unix) sh variant. +e.g. shell=C:\COMMAND.COM /E:256 /P + +STACKS +STACKSHIGH +Usage: stacks=nn,nnn +where nn is in range 0,8-64 and nnn is in range 32-512 +Changes number of stacks available +nn is number of different stacks and nnn is size in bytes of each one +e.g. stacks=16,256 + +SWITCHAR +Usage: switchar=c +Sets the default switchar to character c. Where c is a single character +that is used to indicate a command line parameter is an option switch. +The default is a forward slash (/). Note: This simply sets the value +returned by a get switchar query, it will not effect programs that use +hardcoded switch characters. +e.g. switchar=- + +VERSION +Usage: version=x.y +FreeDOS specific command to specify what DOS version to report. +e.g. version=6.2 + + + +Advanced - FreeDOS specific CONFIG.SYS menu processing: +------------------------------------------------------- normal FILES=20 DEVICE=MyNetWorkDriver.sys '?' - ALWAYS ask if a single line shall be executed - FILES=20 ?DEVICE=MyNetWorkDriver.sys '!' - NEVER ask if a single line shall be executed, even if single stepping - !FILES=20 !DOS=HIGH,UMB !BUFFERS=30 DEVICE=MyNetWorkDriver.sys - configuration management - you may compose several configurations, using following special commands: @@ -66,8 +235,11 @@ MENUDEFAULT=0,1 ( configuration 0, wait 1 second) 2? device=MyNetworkDriver.SYS -Although this is definitively worse then MSDOS menuing possibilities, -IMHO it's better then nothing. +Although this is different than MSDOS menuing possibilities, it +allows for selecting from multiple options during bootup while +remaining simple. It, however, does not allow for multi-level +menuing based configuration schemes. + It's also possible to combine menu options, to avoid writing thing every time again. @@ -165,11 +337,7 @@ MENUDEFAULT=1,10 ( configuration 1, wait 10 seconds) 4? ECHO You selected menu #4 - - - - - 2002-11-28 - Tom Ehlert 2003-07-15 - Bernd Blaauw -2003-09-18 - Bart Oldeman \ No newline at end of file +2003-09-18 - Bart Oldeman +2004-07-24 - Jeremy Davis diff --git a/docs/contrib.txt b/docs/contrib.txt index f5fede2e..15a25702 100644 --- a/docs/contrib.txt +++ b/docs/contrib.txt @@ -1,6 +1,6 @@ These are the known contributors of the FreeDOS kernel. If you have contributed in any way to the kernel, but are not on this list, -please email me at bart@dosemu.org so I can add you to the list! +please email the current kernel maintainer so we can add you to the list! Thanks to all the following for contributing to the FreeDOS kernel: diff --git a/docs/history.txt b/docs/history.txt index f6477f81..ea88b53b 100644 --- a/docs/history.txt +++ b/docs/history.txt @@ -1,5 +1,8 @@ 2004 July 8 - UNSTABLE branch -------- Jeremy Davis (jeremyd@computer.org) ++ Changes Bart + * int2f.asm + - bugfix: call_nls: DI register was not preserved + Changes Tom * inthndlr.c - improve handling of case where eg. FindFirst(I:\*.*) fails, causes Int24, @@ -264,6 +267,16 @@ bytes, because Shell=SecPathName+50 and sizeof SecPathName=128). - P_0(): now supported command line without space between command and options (starting from '/'). + * dosfns.c + - common code from DosFindFirst() and DosFindNext() moved to pop_dmp() + - optimization for SftSeek() + * ludivmul.inc + - bugfix: division of long numbers in LDIVMODU macro (used for Watcom) + was wrong. Example: 100000h%8000Fh was gives 0FFFF1h instead 7_FFF1h. + - shorter code. + * inthndlr.c + - fix: INT21/3301 now returns in DL low bit of input value (as in MS-DOS). + - callerARG1 declared as xreg instead UWORD. + Changes Bernd, Aitor, & Arkady * config.c - source: (Bernd) the codepage table rewritten into a smaller layout. @@ -276,6 +289,19 @@ - fix: for MSVC CONST segment should be class CONST, not DATA. * dsk.c - play_dj() now says same words as MS-DOS6. + * boot.asm + - optimize and make more user friendly instead of retrying endlessly + * sys.c + - change OEM Name field to FRDOS4.1 per Eric Auer for better compatibility. + * ludivmul.inc + - 32-bit division code for 386-enabled Watcom kernel. + * inthndlr.c + - fix: for INT21/5F07 and 5F08, before changing bit CDSPHYSDRV, + MS-DOS checks if physical device associated with drive letter. Without + this check MS-FORMAT under FreeDOS was destroys RAMDISK. + + Changes Jeremy + * config.txt + - update to include all CONFIG.SYS options (except ANYDOS) *** Sync - Stable Build 2035 *** 2004 May 30 - Build 2035 diff --git a/drivers/makefile b/drivers/makefile index 978f380e..91348342 100644 --- a/drivers/makefile +++ b/drivers/makefile @@ -17,7 +17,7 @@ all: ..\lib\device.lib -$(RM) $*.lib $(LIBUTIL) $(LIBFLAGS) $* $(LIBOBJS) $(LIBTERM) -$(OBJS): $(DEPENDS) +$(OBJS): $(DEPENDS) ../kernel/segs.inc ######################################################################## diff --git a/filelist b/filelist index def97df8..b6c5735b 100644 --- a/filelist +++ b/filelist @@ -146,6 +146,7 @@ */*/sys/makefile */*/sys/sys.c */*/sys/talloc.c +*/*/sys/turboc.cfg */*/utils/echoto.bat */*/utils/exeflat.c */*/utils/makefile @@ -153,3 +154,4 @@ */*/utils/relocinf.c */*/utils/rmfiles.bat */*/utils/wlinker.bat +*/*/utils/turboc.cfg diff --git a/hdr/dcb.h b/hdr/dcb.h index 32031e37..13bbec04 100644 --- a/hdr/dcb.h +++ b/hdr/dcb.h @@ -80,8 +80,8 @@ struct dpb { ULONG dpb_xdata; ULONG dpb_xsize; /* # of clusters+1 on media */ ULONG dpb_xfatsize; /* # of sectors / FAT */ - ULONG dpb_xrootclst; /* starting cluster of root dir */ - ULONG dpb_xcluster; /* cluster # of first free */ + CLUSTER dpb_xrootclst; /* starting cluster of root dir */ + CLUSTER dpb_xcluster; /* cluster # of first free */ /* -1 if not known */ #endif }; @@ -89,4 +89,3 @@ struct dpb { #define UNKNCLUSTER 0x0000 /* see RBIL INT 21/AH=52 entry */ #define XUNKNCLSTFREE 0xffffffffl /* unknown for DOS */ #define UNKNCLSTFREE 0xffff /* unknown for DOS */ - diff --git a/hdr/device.h b/hdr/device.h index a01bae54..2708a609 100644 --- a/hdr/device.h +++ b/hdr/device.h @@ -174,7 +174,7 @@ typedef struct { /* bits 6-4: reserved (0) */ /* bits 3-0: active FAT number */ UWORD bpb_xfsversion; /* filesystem version */ - ULONG bpb_xrootclst; /* starting cluster of root dir */ + CLUSTER bpb_xrootclst; /* starting cluster of root dir */ UWORD bpb_xfsinfosec; /* FS info sector number, */ /* 0xFFFF if unknown */ UWORD bpb_xbackupsec; /* backup boot sector number */ diff --git a/hdr/dirmatch.h b/hdr/dirmatch.h index c5878270..44c53271 100644 --- a/hdr/dirmatch.h +++ b/hdr/dirmatch.h @@ -38,32 +38,25 @@ static BYTE *dirmatch_hRcsId = typedef struct { UBYTE dm_drive; BYTE dm_name_pat[FNAME_SIZE + FEXT_SIZE]; - BYTE dm_attr_srch; + BYTE dm_attr_srch; /* !!! should be UBYTE --avb */ UWORD dm_entry; -#ifdef WITHFAT32 - ULONG dm_dircluster; -#else - UWORD dm_dircluster; + CLUSTER dm_dircluster; +#ifndef WITHFAT32 UWORD reserved; #endif struct { - BITS /* directory has been modified */ - f_dmod:1; - BITS /* directory is the root */ - f_droot:1; - BITS /* fnode is new and needs fill */ - f_dnew:1; - BITS /* fnode is assigned to dir */ - f_ddir:1; - BITS /* filler to avoid a bad bug (feature?) in */ - f_filler:12; /* TC 2.01 */ + BITS f_dmod:1; /* directory has been modified */ + BITS f_droot:1; /* directory is the root */ + BITS f_dnew:1; /* fnode is new and needs fill */ + BITS f_ddir:1; /* fnode is assigned to dir */ + BITS f_filler:12; /* filler to avoid a bad bug */ + /* (feature?) in TC 2.01 */ } dm_flags; /* file flags */ - BYTE dm_attr_fnd; /* found file attribute */ + UBYTE dm_attr_fnd; /* found file attribute */ time dm_time; /* file time */ date dm_date; /* file date */ - LONG dm_size; /* file size */ + ULONG dm_size; /* file size */ BYTE dm_name[FNAME_SIZE + FEXT_SIZE + 2]; /* file name */ } dmatch; - diff --git a/kernel/dosfns.c b/kernel/dosfns.c index ca4639b9..5135d4d7 100644 --- a/kernel/dosfns.c +++ b/kernel/dosfns.c @@ -308,22 +308,27 @@ long DosRWSft(int sft_idx, size_t n, void FAR * bp, int mode) } } -COUNT SftSeek(int sft_idx, LONG new_pos, COUNT mode) +COUNT SftSeek(int sft_idx, LONG new_pos, unsigned mode) { sft FAR *s = idx_to_sft(sft_idx); if (FP_OFF(s) == (size_t) -1) return DE_INVLDHNDL; /* Test for invalid mode */ - if (mode < 0 || mode > 2) + if (mode > SEEK_END) /* 2 */ return DE_INVLDFUNC; lpCurSft = s; if (s->sft_flags & SFT_FSHARED) { + /* SEEK_SET handled below (s->sft_posit=new_pos) */ + if (mode == SEEK_CUR) + { + new_pos += s->sft_posit; + } /* seek from end of file */ - if (mode == 2) + else if (mode == SEEK_END) { /* * RB list has it as Note: @@ -336,41 +341,24 @@ COUNT SftSeek(int sft_idx, LONG new_pos, COUNT mode) * Mfs.c looks for these mode bits set, so here is my best guess.;^) */ if (s->sft_mode & (O_DENYREAD | O_DENYNONE)) - s->sft_posit = remote_lseek(s, new_pos); + new_pos = remote_lseek(s, new_pos); else - s->sft_posit = s->sft_size + new_pos; - return SUCCESS; - } - if (mode == 0) - { - s->sft_posit = new_pos; - return SUCCESS; + new_pos += s->sft_size; } - if (mode == 1) - { - s->sft_posit += new_pos; - return SUCCESS; - } - return DE_INVLDFUNC; } - /* Do special return for character devices */ - if (s->sft_flags & SFT_FDEVICE) + else if (s->sft_flags & SFT_FDEVICE) { - s->sft_posit = 0l; - return SUCCESS; + new_pos = 0; } else { - LONG result = dos_lseek(s->sft_status, new_pos, mode); - if (result < 0l) - return (int)result; - else - { - s->sft_posit = result; - return SUCCESS; - } + if ((new_pos = dos_lseek(s->sft_status, new_pos, mode)) < 0) + return (int)new_pos; } + + s->sft_posit = new_pos; + return SUCCESS; } ULONG DosSeek(unsigned hndl, LONG new_pos, COUNT mode) @@ -1018,22 +1006,26 @@ COUNT DosChangeDir(BYTE FAR * s) return SUCCESS; } -STATIC VOID pop_dmp(dmatch FAR * dmp) +STATIC int pop_dmp(int rc, dmatch FAR * save_dta) { - dmp->dm_attr_fnd = (BYTE) SearchDir.dir_attrib; - dmp->dm_time = SearchDir.dir_time; - dmp->dm_date = SearchDir.dir_date; - dmp->dm_size = (LONG) SearchDir.dir_size; - ConvertName83ToNameSZ(dmp->dm_name, (BYTE FAR *) SearchDir.dir_name); + dta = save_dta; + if (rc == SUCCESS) + { + fmemcpy(save_dta, &sda_tmp_dm, 21 /*offsetof(save_dta->dm_attr_fnd)*/ ); + save_dta->dm_attr_fnd = SearchDir.dir_attrib; + save_dta->dm_time = SearchDir.dir_time; + save_dta->dm_date = SearchDir.dir_date; + save_dta->dm_size = SearchDir.dir_size; + ConvertName83ToNameSZ(save_dta->dm_name, SearchDir.dir_name); + } + return rc; } -COUNT DosFindFirst(UCOUNT attr, BYTE FAR * name) +COUNT DosFindFirst(UCOUNT attr, const char FAR * name) { - int rc; - register dmatch FAR *dmp = dta; - - rc = truename(name, PriPathName, - CDS_MODE_CHECK_DEV_PATH | CDS_MODE_ALLOW_WILDCARDS); + dmatch FAR *save_dta = dta; + int rc = truename(name, PriPathName, + CDS_MODE_CHECK_DEV_PATH | CDS_MODE_ALLOW_WILDCARDS); if (rc < SUCCESS) return rc; @@ -1065,32 +1057,26 @@ COUNT DosFindFirst(UCOUNT attr, BYTE FAR * name) SearchDir.dir_attrib = D_DEVICE; SearchDir.dir_time = dos_gettime(); SearchDir.dir_date = dos_getdate(); - p = (char *)FP_OFF(get_root(PriPathName)); - memset(SearchDir.dir_name, ' ', FNAME_SIZE + FEXT_SIZE); + p = (const char *)get_root(PriPathName); for (i = 0; i < FNAME_SIZE && *p && *p != '.'; i++) SearchDir.dir_name[i] = *p++; + for (; i < FNAME_SIZE + FEXT_SIZE; i++) + SearchDir.dir_name[i] = ' '; rc = SUCCESS; /* /// End of additions. - Ron Cemer ; heavily edited - Bart Oldeman */ } else rc = dos_findfirst(attr, PriPathName); - dta = dmp; - if (rc == SUCCESS) - { - fmemcpy(dta, &sda_tmp_dm, 21); - pop_dmp(dmp); - } - return rc; + return pop_dmp(rc, save_dta); } COUNT DosFindNext(void) { - COUNT rc; - register dmatch FAR *dmp = dta; + dmatch FAR *save_dta = dta; - /* findnext will always fail on a device name device name or volume id */ - if (dmp->dm_attr_fnd & (D_DEVICE | D_VOLID)) + /* findnext will always fail on a device name or volume id */ + if (save_dta->dm_attr_fnd & (D_DEVICE | D_VOLID)) return DE_NFILES; /* @@ -1111,21 +1097,13 @@ COUNT DosFindNext(void) * (12h, DE_NFILES) */ #if 0 - printf("findnext: %d\n", dmp->dm_drive); + printf("findnext: %d\n", save_dta->dm_drive); #endif - fmemcpy(&sda_tmp_dm, dmp, 21); + fmemcpy(dta = &sda_tmp_dm, save_dta, 21 /*offsetof(save_dta->dm_attr_fnd)*/ ); memset(&SearchDir, 0, sizeof(struct dirent)); - dta = &sda_tmp_dm; - rc = (sda_tmp_dm.dm_drive & 0x80) ? - network_redirector_fp(REM_FINDNEXT, &sda_tmp_dm) : dos_findnext(); - - dta = dmp; - if (rc == SUCCESS) - { - fmemcpy(dmp, &sda_tmp_dm, 21); - pop_dmp(dmp); - } - return rc; + return pop_dmp(sda_tmp_dm.dm_drive & 0x80 + ? network_redirector_fp(REM_FINDNEXT, &sda_tmp_dm) + : dos_findnext(), save_dta); } COUNT DosGetFtime(COUNT hndl, date * dp, time * tp) diff --git a/kernel/dsk.c b/kernel/dsk.c index 39acd121..2b65b243 100644 --- a/kernel/dsk.c +++ b/kernel/dsk.c @@ -711,7 +711,7 @@ STATIC WORD Genblkdev(rqptr rp, ddt * pddt) break; } case 0x67: /* get access flag */ - rp->r_ai->AI_Flag = (descflags / DF_NOACCESS) & 1; /* bit 9 */ + rp->r_ai->AI_Flag = (UBYTE)~(descflags / DF_NOACCESS) & 1; /* bit 9 */ break; default: return failure(E_CMD); @@ -804,32 +804,22 @@ STATIC WORD dskerr(COUNT code) translate LBA sectors into CHS addressing */ -STATIC int LBA_to_CHS(ULONG LBA_address, struct CHS *chs, const ddt * pddt) +STATIC void LBA_to_CHS(ULONG LBA_address, struct CHS *chs, const ddt * pddt) { /* we need the defbpb values since those are taken from the BIOS, not from some random boot sector, except when we're dealing with a floppy */ - const bpb *pbpb = hd(pddt->ddt_descflags) ? &pddt->ddt_defbpb : &pddt->ddt_bpb; - unsigned hs = pbpb->bpb_nsecs * pbpb->bpb_nheads; - unsigned hsrem = (unsigned)(LBA_address % hs); - - LBA_address /= hs; - - if (LBA_address > 1023ul) + const bpb *p = hd(pddt->ddt_descflags) ? &pddt->ddt_defbpb : &pddt->ddt_bpb; + unsigned hs = p->bpb_nsecs * p->bpb_nheads; + chs->Cylinder = 0xffffu; + if (hs > hiword(LBA_address)) /* LBA_address < hs * 0x10000ul */ { -#ifdef DEBUG - printf("LBA-Transfer error : cylinder %lu > 1023\n", LBA_address); -#else - put_string("LBA-Transfer error : cylinder > 1023\n"); -#endif - return 1; + chs->Cylinder = (unsigned)(LBA_address / hs); + hs = (unsigned)(LBA_address % hs); + chs->Head = hs / p->bpb_nsecs; + chs->Sector = hs % p->bpb_nsecs + 1; } - - chs->Cylinder = (UWORD)LBA_address; - chs->Head = hsrem / pbpb->bpb_nsecs; - chs->Sector = hsrem % pbpb->bpb_nsecs + 1; - return 0; } /* Test for 64K boundary crossing and return count small */ @@ -945,8 +935,16 @@ STATIC int LBA_Transfer(ddt * pddt, UWORD mode, VOID FAR * buffer, else { /* transfer data, using old bios functions */ struct CHS chs; - if (LBA_to_CHS(LBA_address, &chs, pddt)) + LBA_to_CHS(LBA_address, &chs, pddt); + if (chs.Cylinder > 1023u) + { +#ifdef DEBUG + printf("IO error: cylinder (%u) > 1023\n", chs.Cylinder); +#else + put_string("IO error: cylinder > 1023\n"); +#endif return failure(E_CMD); /*dskerr(1)*/ + } /* avoid overflow at end of track */ if (count > pddt->ddt_bpb.bpb_nsecs + 1 - chs.Sector) diff --git a/kernel/int2f.asm b/kernel/int2f.asm index 73369abf..e88c388b 100644 --- a/kernel/int2f.asm +++ b/kernel/int2f.asm @@ -411,6 +411,7 @@ _call_nls: push bp mov bp, sp push si + push di mov al, [bp + 4] ; subfct mov ah, 0x14 mov si, [bp + 6] ; nlsinfo @@ -427,6 +428,7 @@ _call_nls: jz nostore mov [bp], bx nostore: + pop di pop si pop bp ret diff --git a/kernel/inthndlr.c b/kernel/inthndlr.c index 11999aae..752c4f03 100644 --- a/kernel/inthndlr.c +++ b/kernel/inthndlr.c @@ -74,21 +74,18 @@ VOID ASMCFUNC int21_syscall(iregs FAR * irp) setvec(irp->AL, (intvec)MK_FP(irp->DS, irp->DX)); break; - /* DosVars - get/set dos variables */ - case 0x33: + case 0x33: /* DosVars - get/set dos variables */ switch (irp->AL) { - /* Get Ctrl-C flag */ - case 0x00: - irp->DL = break_ena; - break; - - /* Set Ctrl-C flag */ - case 0x01: + case 0x01: /* Set Ctrl-C flag */ break_ena = irp->DL & 1; + /* fall through so DL only low bit (as in MS-DOS) */ + + case 0x00: /* Get Ctrl-C flag */ + irp->DL = break_ena; break; - case 0x02: /* andrew schulman: get/set extended control break */ + case 0x02: /* andrew schulman: get/set extended control break */ { UBYTE tmp = break_ena; break_ena = irp->DL & 1; @@ -1247,31 +1244,31 @@ VOID ASMCFUNC int21_service(iregs FAR * r) case 0x5f: if (lr.AL == 7 || lr.AL == 8) { - struct cds FAR *cdsp = &CDSp[lr.DL]; - if (lr.DL >= lastdrive || FP_OFF(cdsp->cdsDpb) == 0) + if (lr.DL < lastdrive) { - rc = DE_INVLDDRV; - goto error_exit; + struct cds FAR *cdsp = CDSp + lr.DL; + if (FP_OFF(cdsp->cdsDpb)) /* letter of physical drive? */ + { + cdsp->cdsFlags &= ~CDSPHYSDRV; + if (lr.AL == 7) + cdsp->cdsFlags |= CDSPHYSDRV; + break; + } } - if (lr.AL == 7) - cdsp->cdsFlags |= CDSPHYSDRV; - else - cdsp->cdsFlags &= ~CDSPHYSDRV; + rc = DE_INVLDDRV; + goto error_exit; } - else + + rc = -(int)network_redirector_mx(REM_DOREDIRECT, &lr, (void *)Int21AX); + /* the remote function manipulates *r directly !, + so we should not copy lr to r here */ + r->AX = rc; + if (rc != SUCCESS) { - rc = (int)network_redirector_mx(REM_DOREDIRECT, &lr, (void *)Int21AX); - /* the remote function manipulates *r directly !, - so we should not copy lr to r here */ - if (rc != SUCCESS) - { - CritErrCode = -rc; /* Maybe set */ - SET_CARRY_FLAG(); - } - r->AX = -rc; - goto real_exit; + SET_CARRY_FLAG(); + CritErrCode = rc; /* Maybe set */ } - break; + goto real_exit; case 0x60: /* TRUENAME */ rc = DosTruename(MK_FP(lr.DS, lr.SI), adjust_far(FP_ES_DI)); @@ -1633,9 +1630,10 @@ STATIC VOID StartTrace(VOID) } #endif -/* this function is called from an assembler wrapper function - and serves the internal dos calls - int2f/12xx and int2f/4a01,4a02. +/* this function is called from an assembler wrapper function and + serves the internal dos calls - int2f/12xx and int2f/4a01,4a02 */ + struct int2f12regs { #ifdef I386 #ifdef __WATCOMC__ @@ -1654,7 +1652,7 @@ struct int2f12regs { UWORD di, si, bp; xreg b, d, c, a; UWORD ip, cs, flags; - UWORD callerARG1; /* used if called from INT2F/12 */ + xreg callerARG1; /* used if called from INT2F/12 */ }; /* WARNING: modifications in `r' are used outside of int2F_12_handler() @@ -1694,12 +1692,12 @@ VOID ASMCFUNC int2F_12_handler(struct int2f12regs r) r.DS = FP_SEG(&nul_dev); break; - case 0x06: /* invoke critical error */ - - /* code, drive number, error, device header */ - r.AL = CriticalError(r.callerARG1 >> 8, - (r.callerARG1 & (EFLG_CHAR << 8)) ? 0 : - r.callerARG1 & 0xff, r.DI, MK_FP(r.BP, r.SI)); + case 0x06: /* invoke critical error */ + /* code, drive number, error, device header */ + r.AL = CriticalError(r.callerARG1.b.h, + (r.callerARG1.b.h & EFLG_CHAR) + ? 0 : r.callerARG1.b.l, + r.DI, MK_FP(r.BP, r.SI)); break; case 0x08: /* decrease SFT reference count */ @@ -1757,18 +1755,15 @@ VOID ASMCFUNC int2F_12_handler(struct int2f12regs r) break; } - case 0x12: /* get length of asciiz string */ - + case 0x12: /* get length of asciiz string */ r.CX = fstrlen(MK_FP(r.ES, r.DI)) + 1; - break; - case 0x13: - /* uppercase character */ - /* for now, ASCII only because nls.c cannot handle DS!=SS */ - r.AL = (unsigned char)r.callerARG1; - if (r.AL >= 'a' && r.AL <= 'z') - r.AL -= 'a' - 'A'; + case 0x13: /* uppercase character */ + /* for now, ASCII only because nls.c cannot handle DS!=SS */ + r.AL = r.callerARG1.b.l; + if (_islower(r.AL)) + r.AL -= (UBYTE)('a' - 'A'); break; case 0x16: @@ -1805,10 +1800,9 @@ VOID ASMCFUNC int2F_12_handler(struct int2f12regs r) ; ; probable use: get sizeof(CDSentry) */ - { - struct cds FAR *cdsp = get_cds(r.callerARG1 & 0xff); - - if (cdsp == NULL) + { + const struct cds FAR *cdsp; + if ((cdsp = get_cds(r.callerARG1.b.l)) == NULL) { r.FLAGS |= FLG_CARRY; break; @@ -1817,7 +1811,7 @@ VOID ASMCFUNC int2F_12_handler(struct int2f12regs r) r.SI = FP_OFF(cdsp); r.FLAGS &= ~FLG_CARRY; break; - } + } case 0x18: /* get caller's registers */ @@ -1880,6 +1874,15 @@ VOID ASMCFUNC int2F_12_handler(struct int2f12regs r) r.FLAGS &= ~FLG_CARRY; break; + /* 0x26-0x29 & 0x2B, internal functions necessary for NLSFUNC */ + case 0x26: /* Open File */ + case 0x27: /* Close File */ + case 0x28: /* Move File Pointer */ + case 0x29: /* Read From File */ + case 0x2B: /* IOctl */ + r.FLAGS |= FLG_CARRY; /* Not implemented yet! */ + break; + case 0x2c: /* added by James Tabor For Zip Drives Return Null Device Pointer */ /* by UDOS+RBIL: get header of SECOND device driver in device chain, diff --git a/kernel/ioctl.c b/kernel/ioctl.c index 3ad15af1..63b56742 100644 --- a/kernel/ioctl.c +++ b/kernel/ioctl.c @@ -124,11 +124,20 @@ COUNT DosDevIOctl(lregs * r) attr = dev->dh_attr; break; + case 0x0d: + /* NOTE: CX checked before check if get_dpb()->dpb_device->dh_attr + contains ATTR_GENIOCTL bit set + */ + if ((r->CX & ~0x4021) == 0x084A) + { /* 084A/484A, 084B/484B, 086A/486A, 086B/486B */ + r->AX = 0; /* (lock/unlock logical/physical volume) */ + return SUCCESS; /* simulate success for MS-DOS 7+ SCANDISK etc. --LG */ + } + case 0x04: case 0x05: case 0x08: case 0x09: - case 0x0d: case 0x0e: case 0x0f: case 0x11: @@ -258,17 +267,10 @@ COUNT DosDevIOctl(lregs * r) break; } - case 0x0d: - if ((r->CX & ~0x4021) == 0x084A) - { /* 084A/484A, 084B/484B, 086A/486A, 086B/486B */ - r->AX = 0; /* (lock/unlock logical/physical volume) */ - break; /* simulate success for MS-DOS 7+ SCANDISK etc. --LG */ - } - /* fall through */ - case 0x04: case 0x05: case 0x08: + case 0x0d: case 0x11: execrequest: execrh(&CharReqHdr, dev); diff --git a/kernel/ludivmul.inc b/kernel/ludivmul.inc index decf7792..966d2715 100644 --- a/kernel/ludivmul.inc +++ b/kernel/ludivmul.inc @@ -1,21 +1,26 @@ -; this one adapted from elks, http://elks.sourceforge.net -; multiply cx:bx * dx:ax, result in dx:ax +; this one adapted from elks, http://elks.sourceforge.net +; multiply cx:bx * dx:ax, result in dx:ax +; optimized by Arkady Belousov: +; dx:ax * cx:bx +; = xh:xl * yh:yl +; = xh:xl*yh*w + xh:xl*yl +; = [xh*yh*w*w +] (xl*yh + xh*yl)*w + xl*yl %macro LMULU 0 - push si - push cx - mov si, ax ; save _ax in si - mov ax, bx ; cx:ax = _cx:_bx - mul dx ; dx:ax = _bx*_dx (forget dx) - xchg cx, ax ; cx = low(_dx*_bx) - mul si ; dx:ax = _cx*_ax (forget dx) - add cx, ax ; cx = low(_cx*_ax + _dx*_bx) - mov ax, si ; restore _ax - mul bx ; dx:ax = _bx*_ax - add dx, cx ; dx = high(_bx*_ax)+low(_cx*_ax + _dx*_bx) - pop cx - pop si + push cx + push si + xchg si,ax ; si=xl (XCHG instead MOV) + xchg ax,dx ; ax=xh (XCHG instead MOV) + mul bx ; dx:ax=xh*yl (forget dx) + xchg cx,ax ; cx=low(xh*yl), ax=yh + mul si ; dx:ax=xl*yh (forget dx) + add cx,ax ; cx=low(xl*yh+xh*yl) + xchg ax,si ; ax=xl (XCHG instead MOV) + mul bx ; dx:ax=xl*yl + add dx,cx + pop si + pop cx ret %endmacro @@ -25,86 +30,111 @@ %macro LDIVMODU 0 ; this one is adapted from an assembly gem: ; gem writer: Norbert Juffa, norbert.juffa@amd.com - ; Dividing 64-bit unsigned integers Assembler / 80386 - -; Here is a division routine for dividing two 64-bit unsigned integers. -; I derived it by modifying some old -; 16-bit code for dividing 32-bit integers that I did several years ago for a -; Turbo-Pascal replacement library. -; If a 64-bit signed integer division is needed, appropriate shell code for -; this routine can easily be written. -; ; (adapted back to 32-bit by Bart Oldeman ;-)) -; -; __U4D divides two unsigned long numbers, the dividend and the divisor +; ...bugfixed and optimized by Arkady Belousov. + +; This macro divides two unsigned long numbers, the dividend and the divisor ; resulting in a quotient and a remainder. ; ; input: -; dx:ax = dividend -; cx:bx = divisor -; +; dx:ax = dividend (x=xh:xl) +; cx:bx = divisor (y=yh:yl) ; output: -; dx:ax = quotient of division of dividend by divisor -; cx:bx = remainder of division of dividend by divisor -; +; dx:ax = quotient of division of dividend by divisor (q=x/y) +; cx:bx = remainder of division of dividend by divisor (r=x%y) ; destroys: ; flags ; +%if XCPU < 386 + + jcxz %%div3216 ; cx=0 -> divisor < 2^16 + + push si ; save temp + push di ; variables + + push dx ; save + push ax ; dividend x + mov si,bx ; si=yl + mov di,cx ; di:si=cx:bx=y + +%%shift_loop: + shr dx,1 ; shift both + rcr ax,1 ; divisor and + shr cx,1 ; and dividend + rcr bx,1 ; right by 1 bit (rcr preserves ZF) + jnz %%shift_loop ; until zero in cx (divisor < 2^16) + div bx ; ax=quotient q, di:si=y - test cx, cx ; divisor > 2^32-1 ? - jnz %%big_divisor ; yes, divisor > 32^32-1 - cmp dx, bx ; only one division needed ? (ecx = 0) - jb %%one_div ; yes, one division sufficient + mov cx,ax ; cx=q + mul di ; dx:ax=q*yh (forget dx) + xchg bx,ax ; bx=low(q*yh) (XCHG instead MOV) + mov ax,cx ; ax=q + mul si ; dx:ax=q*yl + add dx,bx ; dx:ax=q*y, cx=q + pop bx ; bx=xl + sub bx,ax ; bx=xl-low(q*y) + xchg ax,cx ; ax=q (XCHG instead MOV) + pop cx ; cx=xh + sbb cx,dx ; cx:bx=x-q*y=remainder r, ax=q - xchg cx, ax ; save dividend-lo in cx, ax=0 - xchg ax, dx ; get dividend-hi in ax, dx=0 - div bx ; quotient-hi in eax - xchg ax, cx ; cx = quotient-hi, ax =dividend-lo + jae %%div_done ; if remainder < 0 + add bx,si + adc cx,di ; correct remainder (r+=y) + dec ax ; and quotient (q-=1) +%%div_done: + xor dx,dx ; dx:ax=0:q=q -%%one_div: - div bx ; ax = quotient-lo - mov bx, dx ; bx = remainder-lo - mov dx, cx ; dx = quotient-hi(quotient in dx:ax) - xor cx, cx ; cx = remainder-hi (rem. in cx:bx) + pop di ; restore temp + pop si ; variables ret -%%big_divisor: - push si ; save temp - push di ; variables - push dx ; save - push ax ; dividend - mov si, bx ; divisor now in - mov di, cx ; di:bx and cx:si -%%shift_loop: - shr dx, 1 ; shift both - rcr ax, 1 ; divisor and - shr di, 1 ; and dividend - rcr bx, 1 ; right by 1 bit - jnz %%shift_loop ; loop if di non-zero (rcr does not touch ZF) - mov di, cx ; restore original divisor (di:si) - div bx ; compute quotient - pop bx ; get dividend lo-word - mov cx, ax ; save quotient - mul di ; quotient * divisor hi-word (low only) - xchg ax, di ; save in di - mov ax, cx ; ax=quotient - mul si ; quotient * divisor lo-word - add dx, di ; dx:ax = quotient * divisor - sub bx, ax ; dividend-lo - (quot.*divisor)-lo - mov ax, cx ; get quotient - pop cx ; restore dividend hi-word - sbb cx, dx ; subtract divisor * quot. from dividend - sbb dx, dx ; 0 if remainder > 0, else FFFFFFFFh - and si, dx ; nothing to add - and di, dx ; back if remainder positive - add bx, si ; correct remaider - adc cx, di ; and quotient if - add ax, dx ; necessary - xor dx, dx ; clear hi-word of quot (ax<=FFFFFFFFh) - pop di ; restore temp - pop si ; variables +; dx:ax=x, bx=y, cx=0 +; x=xh:xl=xh*w+xl=[xh/y]*y*w+xh%y*w+xl=[xh/y]*y*w+xt +; w=2^16, xh=x/w, xl=x%w, xt=xh%y*w+xl +; remainder = x%y = xt%y +; quotient = [x/y] = [xh/y]*w+xt/y + +%%div3216: + cmp dx,bx ; xh < y ? + jb %%one_div ; yes, one division sufficient + + xchg cx,ax ; ax=0, cx=xl + xchg ax,dx ; dx:ax=0:xh, cx=xl + div bx ; ax=xh/y, dx=xh%y, cx=xl + xchg ax,cx ; dx:ax=xh%y*w+xl=xt, cx=xh/y + +%%one_div: + div bx ; ax=xt/y, dx=xt%d=x%d, cx=xh/y + mov bx,dx ; bx=x%d + mov dx,cx ; dx:ax=xh/y*w+xt/y=x/y + xor cx,cx ; cx:bx=x%d ret -%endmacro \ No newline at end of file +%else ; XCPU >= 386 (Svilen Stoianov and Luchezar Georgiev, Varna, Bulgaria) + + push eax ; save eax.high + pop ax + push edx ; save edx.high + push ax + pop eax ; eax=x + push ecx ; save ecx.high + push bx + pop ecx ; ecx=y + + xor edx,edx + div ecx ; eax=q, edx=r + + push edx + pop bx + pop ecx ; restore ecx.high, cx:bx=r + push eax + pop ax + pop edx ; restore edx.high, dx:ax=q + push ax + pop eax ; restore eax.high + ret + +%endif +%endmacro diff --git a/kernel/main.c b/kernel/main.c index 9d453e85..42628594 100644 --- a/kernel/main.c +++ b/kernel/main.c @@ -195,6 +195,12 @@ STATIC void PSPInit(void) /* this area reused for master environment */ /*p->ps_cmd.ctCount = 0;*/ /* local command line */ /*p->ps_cmd.ctBuffer[0] = '\r';*/ /* command tail */ + + /* !!! dirty hack: because bug in old FreeCOM, which wrongly + process empty environment in MS-DOS style, garbage empty + environment by dummy variable: --avb + */ + fmemcpy(&p->ps_cmd, "PATH=.", 6/*strlen("PATH=.")*/); } #ifndef __WATCOMC__ @@ -328,8 +334,10 @@ STATIC VOID FsConfig(VOID) for (i = 0; i < LoL->lastdrive; i++) { struct cds FAR *pcds_table = &LoL->CDSp[i]; - fmemcpy(pcds_table->cdsCurrentPath, "A:\\\0", 4); - pcds_table->cdsCurrentPath[0] += i; + pcds_table->cdsCurrentPath[0] = 'A' + i; + pcds_table->cdsCurrentPath[1] = ':'; + pcds_table->cdsCurrentPath[2] = '\\'; + pcds_table->cdsCurrentPath[3] = '\0'; pcds_table->cdsFlags = 0; if (i < LoL->nblkdev && (LONG) dpb != -1l) { diff --git a/kernel/nls.c b/kernel/nls.c index 6810dbe3..8e6f0c1b 100644 --- a/kernel/nls.c +++ b/kernel/nls.c @@ -122,8 +122,14 @@ COUNT muxLoadPkg(UWORD cp, UWORD cntry) /* make sure the NLSFUNC ID is updated */ #error "NLS_FREEDOS_NLSFUNC_VERSION == NLS_FREEDOS_NLSFUNC_ID" #endif - if (muxGo(0, 0, NLS_FREEDOS_NLSFUNC_VERSION, 0, NLS_FREEDOS_NLSFUNC_ID, 0, - (UWORD *)&id) != 0x14ff) + /* Install check must pass the FreeDOS NLSFUNC version as codepage (cp) and + the FreeDOS NLSFUNC ID as buffer size (bufsize). If they match the + version in NLSFUNC, on return it will set BX (cp on entry) to FreeDOS + NLSFUNC ID. If not NULL, call_nls will set *id = BX on return. + Note: &id should be the pointer offset addressable via SS (SS:BP == &id) + */ + if (muxGo(NLSFUNC_INSTALL_CHECK, 0, NLS_FREEDOS_NLSFUNC_VERSION, + 0, NLS_FREEDOS_NLSFUNC_ID, 0, (UWORD *)&id) != 0x14ff) return DE_FILENOTFND; /* No NLSFUNC --> no load */ if (id != NLS_FREEDOS_NLSFUNC_ID) /* FreeDOS NLSFUNC will return */ return DE_INVLDACC; /* This magic number */ diff --git a/kernel/proto.h b/kernel/proto.h index f72c8981..8ed745a2 100644 --- a/kernel/proto.h +++ b/kernel/proto.h @@ -77,11 +77,14 @@ long cooked_write(struct dhdr FAR **pdev, size_t n, char FAR *bp); sft FAR *get_sft(UCOUNT); /* dosfns.c */ +#define SEEK_SET 0 +#define SEEK_CUR 1 +#define SEEK_END 2 const char FAR *get_root(const char FAR *); BOOL check_break(void); UCOUNT GenericReadSft(sft far * sftp, UCOUNT n, void FAR * bp, COUNT * err, BOOL force_binary); -COUNT SftSeek(int sft_idx, LONG new_pos, COUNT mode); +COUNT SftSeek(int sft_idx, LONG new_pos, unsigned mode); /*COUNT DosRead(COUNT hndl, UCOUNT n, BYTE FAR * bp, COUNT FAR * err); */ void BinarySftIO(int sft_idx, void *bp, int mode); #define BinaryIO(hndl, bp, mode) BinarySftIO(get_sft_idx(hndl), bp, mode) @@ -101,7 +104,7 @@ BOOL DosGetFree(UBYTE drive, UWORD * spc, UWORD * navc, UWORD * bps, UWORD * nc); COUNT DosGetCuDir(UBYTE drive, BYTE FAR * s); COUNT DosChangeDir(BYTE FAR * s); -COUNT DosFindFirst(UCOUNT attr, BYTE FAR * name); +COUNT DosFindFirst(UCOUNT attr, const char FAR * name); COUNT DosFindNext(void); COUNT DosGetFtime(COUNT hndl, date * dp, time * tp); COUNT DosSetFtimeSft(int sft_idx, date dp, time tp); @@ -374,7 +377,6 @@ void child_psp(seg_t para, seg_t cur_psp, seg_t beyond); void return_user(void); COUNT DosExec(COUNT mode, exec_blk FAR * ep, BYTE FAR * lp); ULONG SftGetFsize(int sft_idx); -VOID InitPSP(VOID); #ifdef __WATCOMC__ # pragma aux return_user aborts #endif diff --git a/kernel/task.c b/kernel/task.c index 1d5b6bd1..4e578d19 100644 --- a/kernel/task.c +++ b/kernel/task.c @@ -303,7 +303,7 @@ static void load_transfer(seg_t ds, exec_blk *ep, int mode) if (mode == LOADNGO) { /* build the user area on the stack */ - iregs FAR *irp = (iregs FAR *)(ep->exec.stack - sizeof(iregs)); + iregs FAR *irp = (iregs FAR *)ep->exec.stack - 1; /* start allocating REGs (as in MS-DOS - some demos expect them so --LG) */ /* see http://www.beroset.com/asm/showregs.asm */ diff --git a/kernel/vc.cfg b/kernel/vc.cfg deleted file mode 100644 index af2a42c5..00000000 --- a/kernel/vc.cfg +++ /dev/null @@ -1,5 +0,0 @@ --batch -nologo -WX --Zlp1 --f- -Osb1V4e -Gsry --Fc --I..\hdr diff --git a/sys/fdkrncfg.c b/sys/fdkrncfg.c index 36648bdc..55daef2f 100644 --- a/sys/fdkrncfg.c +++ b/sys/fdkrncfg.c @@ -59,10 +59,6 @@ typedef signed short sword; typedef unsigned long dword; typedef signed long sdword; -/* These structures need to be byte packed, if your compiler - does not do this by default, add the appropriate command, - such as #pragma pack(1) here, protected with #ifdefs of course. -*/ /* Displays command line syntax */ void showUsage(void) diff --git a/sys/sys.c b/sys/sys.c index ee402fe2..5d301408 100644 --- a/sys/sys.c +++ b/sys/sys.c @@ -29,7 +29,7 @@ #define DEBUG /* #define DDEBUG */ -#define SYS_VERSION "v3.2" +#define SYS_VERSION "v3.3" #include #include @@ -483,13 +483,13 @@ void truename(char far *dest, const char *src); "int 0x21" \ parm [es di] [si]; -int generic_block_ioctl(unsigned char drive, unsigned cx, unsigned char *par); +int generic_block_ioctl(unsigned drive, unsigned cx, unsigned char *par); #pragma aux generic_block_ioctl = \ "mov ax, 0x440d" \ "int 0x21" \ "sbb ax, ax" \ value [ax] \ - parm [bl] [cx] [dx]; + parm [bx] [cx] [dx]; /* BH must be 0 for lock! */ #else @@ -541,14 +541,14 @@ void reset_drive(int DosDrive) intdos(®s, ®s); } /* reset_drive */ -int generic_block_ioctl(unsigned char drive, unsigned cx, unsigned char *par) +int generic_block_ioctl(unsigned drive, unsigned cx, unsigned char *par) { union REGS regs; regs.x.ax = 0x440d; regs.x.cx = cx; regs.x.dx = (unsigned)par; - regs.h.bl = drive + 1; + regs.x.bx = drive; /* BH must be 0 for lock! */ intdos(®s, ®s); return regs.x.cflag; } /* generic_block_ioctl */ @@ -692,7 +692,7 @@ void put_boot(int drive, char *bsFile, char *kernel_name, int load_seg, int both #endif /* lock drive */ - generic_block_ioctl((unsigned char)drive + 1, 0x84a, NULL); + generic_block_ioctl(drive + 1, 0x84a, NULL); reset_drive(drive); /* suggestion: allow reading from a boot sector or image file here */ @@ -752,7 +752,7 @@ void put_boot(int drive, char *bsFile, char *kernel_name, int load_seg, int both printf("FAT type: FAT32\n"); /* get default bpb (but not for floppies) */ if (drive >= 2 && - generic_block_ioctl((unsigned char)drive + 1, 0x4860, default_bpb) == 0) + generic_block_ioctl(drive + 1, 0x4860, default_bpb) == 0) correct_bpb((struct bootsectortype *)(default_bpb + 7 - 11), bs); #ifdef WITHFAT32 /* copy one of the FAT32 boot sectors */ @@ -767,7 +767,7 @@ void put_boot(int drive, char *bsFile, char *kernel_name, int load_seg, int both { /* copy the FAT12/16 CHS+LBA boot sector */ printf("FAT type: FAT1%c\n", fs + '0' - 10); if (drive >= 2 && - generic_block_ioctl((unsigned char)drive + 1, 0x860, default_bpb) == 0) + generic_block_ioctl(drive + 1, 0x860, default_bpb) == 0) correct_bpb((struct bootsectortype *)(default_bpb + 7 - 11), bs); memcpy(newboot, fs == FAT16 ? fat16com : fat12com, SEC_SIZE); } @@ -782,7 +782,8 @@ void put_boot(int drive, char *bsFile, char *kernel_name, int load_seg, int both bs = (struct bootsectortype *)&newboot; - memcpy(bs->OemName, "FreeDOS ", 8); + /* originally OemName was "FreeDOS", changed for better compatibility */ + memcpy(bs->OemName, "FRDOS4.1", 8); #ifdef WITHFAT32 if (fs == FAT32) @@ -893,7 +894,7 @@ void put_boot(int drive, char *bsFile, char *kernel_name, int load_seg, int both reset_drive(drive); /* unlock_drive */ - generic_block_ioctl((unsigned char)drive + 1, 0x86a, NULL); + generic_block_ioctl(drive + 1, 0x86a, NULL); } /* put_boot */ From 03fc88df3e4363d29af9be1bce6ea1f3b1f149b1 Mon Sep 17 00:00:00 2001 From: Kenneth J Davis Date: Tue, 10 Aug 2004 20:21:01 +0000 Subject: [PATCH 554/671] Lucho's fix to use start_seg-2 instead of hard coded 0x60-2 in UPX trailer git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/branches/UNSTABLE@1014 6ac86273-5f31-0410-b378-82cca8765d1b --- utils/exeflat.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/utils/exeflat.c b/utils/exeflat.c index e0b822cb..b24404ab 100644 --- a/utils/exeflat.c +++ b/utils/exeflat.c @@ -94,6 +94,9 @@ int main(int argc, char **argv) short silentSegments[20], silentcount = 0, silentdone = 0; int UPX = FALSE; + /* if no arguments provided, show usage and exit */ + if (argc < 4) usage(); + /* do optional argument processing here */ for (i = 4; i < argc; i++) { @@ -282,13 +285,14 @@ int main(int argc, char **argv) /* UPX trailer */ /* hand assembled - so this remains ANSI C ;-) */ /* move kernel down to place CONFIG-block, which added above, - at 0x5e:0 instead 0x60:0 and store there boot drive number + at start_seg-2:0 (e.g. 0x5e:0) instead of + start_seg:0 (e.g. 0x60:0) and store there boot drive number from BL; kernel.asm will then check presence of additional CONFIG-block at this address. */ static char trailer[] = { 0x0E, /* 0 push cs */ 0x1F, /* 1 pop ds ; =0x60 */ - 0xBF,0x5E,0x00, /* 2 mov di,0x5E */ + 0xBF,0x5E,0x00, /* 2 mov di,start_seg-2 */ 0x8E,0xC7, /* 5 mov es,di */ 0xFC, /* 7 cld */ 0x33,0xFF, /* 8 xor di,di */ @@ -303,6 +307,7 @@ int main(int argc, char **argv) 0x33,0xFF, /* 27 xor di,di */ 0xFF,0xE7, /* 29 jmp di ; jmp 0 */ }; + *(short *)&trailer[3] = start_seg - 2; *(short *)&trailer[15] = (short)size + 0x20; *(short *)&trailer[20] = start_seg + header.exInitSS; *(short *)&trailer[25] = header.exInitSP; From 31a4275854492dc0872cd94f59cf3a92cfaa923a Mon Sep 17 00:00:00 2001 From: Kenneth J Davis Date: Thu, 2 Sep 2004 20:22:05 +0000 Subject: [PATCH 555/671] easier change of kernel load segment, remove need of keypress when linking git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/branches/UNSTABLE@1022 6ac86273-5f31-0410-b378-82cca8765d1b --- build.bat | 12 +++++++++++- defaults.bat | 1 + docs/fdkernel.lsm | 4 ++-- kernel/makefile | 2 +- mkfiles/generic.mak | 4 ++++ utils/wlinker.bat | 2 +- 6 files changed, 20 insertions(+), 5 deletions(-) diff --git a/build.bat b/build.bat index 61f0cb5d..c7a5eb77 100644 --- a/build.bat +++ b/build.bat @@ -4,7 +4,7 @@ :- $Id$ :----------------------------------------------------------------------- -:- Syntax: BUILD [-r] [fat32|fat16] [msc|wc|tc|tcpp] [86|186|386] [debug] [lfnapi] +:- Syntax: BUILD [-r] [fat32|fat16] [msc|wc|tc|tcpp] [86|186|386] [debug] [lfnapi] [/L #] :- option case is significant !! :----------------------------------------------------------------------- @@ -42,6 +42,9 @@ if "%1" == "386" set XCPU=386 if "%1" == "debug" set ALLCFLAGS=%ALLCFLAGS% -DDEBUG if "%1" == "lfnapi" set ALLCFLAGS=%ALLCFLAGS% -DWITHLFNAPI +if "%1" == "/L" goto setLoadSeg + +:nextOption shift if not "%1" == "" goto loop_commandline @@ -111,6 +114,13 @@ goto end :----------------------------------------------------------------------- +:setLoadSeg +shift +if "%1" == "" echo you MUST specify load segment eg 0x60 with /L option +if "%1" == "" goot abort +set LOADSEG=%1 +goto nextOption + :noenv echo Unable to set necessary environment variables! goto abort diff --git a/defaults.bat b/defaults.bat index 6b711e35..7c581f83 100644 --- a/defaults.bat +++ b/defaults.bat @@ -81,6 +81,7 @@ set XUPX= set XCPU= set XFAT= set ALLCFLAGS= +set LOADSEG= if not "%OLDPATH%" == "" set PATH=%OLDPATH% set OLDPATH= diff --git a/docs/fdkernel.lsm b/docs/fdkernel.lsm index d9a21de8..a0fb3e1f 100644 --- a/docs/fdkernel.lsm +++ b/docs/fdkernel.lsm @@ -1,11 +1,11 @@ Begin3 Title: The FreeDOS Kernel -Version: 2.0.35 +Version: 2.0.35a-UNSTABLE Entered-date: 30 May 2004 Description: The FreeDOS Kernel. Keywords: kernel freedos dos msdos Author: (developers) -Maintained-by: bartoldeman@users.sourceforge.net +Maintained-by: jeremyd@computer.org Primary-site: http://freedos.sourceforge.net Original-site: http://www.gcfl.net/pub/FreeDOS/kernel Platforms: dos dosemu diff --git a/kernel/makefile b/kernel/makefile index 4d7adc4b..39806a9f 100644 --- a/kernel/makefile +++ b/kernel/makefile @@ -36,7 +36,7 @@ all: ..\bin\$(TARGET).sys ..\bin\$(TARGET).sys: $(TARGET).lnk $(OBJS) $(LIBS) ..\utils\exeflat.exe $(LINK) @$(TARGET).lnk; $(XUPX) kernel.exe - ..\utils\exeflat kernel.exe $*.sys 0x60 -S0x10 -S0x8B $(UPXOPT) + ..\utils\exeflat kernel.exe $*.sys $(LOADSEG) -S0x10 -S0x8B $(UPXOPT) copy $*.sys ..\bin\kernel.sys # XXX: This is a very ugly way of linking the kernel, forced upon us by the diff --git a/mkfiles/generic.mak b/mkfiles/generic.mak index e70533ab..211404a9 100644 --- a/mkfiles/generic.mak +++ b/mkfiles/generic.mak @@ -28,6 +28,10 @@ INCLUDEPATH=$(BASE)\include LIBPATH=$(BASE)\lib INITPATCH=@rem +!if $(LOADSEG)0 == 0 +LOADSEG=0x60 +!endif + UPXOPT=-U !if $(__MAKE__)0 == 0 # NMAKE/WMAKE !if "$(XUPX)" == "" # TC doesn't supports this diff --git a/utils/wlinker.bat b/utils/wlinker.bat index 30d39ebb..27ae76ad 100755 --- a/utils/wlinker.bat +++ b/utils/wlinker.bat @@ -1,4 +1,4 @@ @echo off -%BASE%\binw\ms2wlink %1 %2 %3 %4 %5 %6 %7 %8 %9>kernel.lnk +%BASE%\binw\ms2wlink %1 %2 %3 %4 %5 %6 %7 %8 %9 ,,,, >kernel.lnk echo op map,statics,verbose,eliminate,vfremoval>>kernel.lnk %BASE%\binw\wlink @kernel.lnk From a6b468389b72632e57567a21e9910f90e7cf53b5 Mon Sep 17 00:00:00 2001 From: Luchezar Georgiev Date: Fri, 3 Sep 2004 09:26:53 +0000 Subject: [PATCH 556/671] COUNTRY.SYS & NLSFUNC support added: Lucho, Eduardo. 32RTM and BRUN45 incompatibilities fixed by Michael. ZIP drive serial numbers now work: bug fix by Lucho. Small clean-ups and optimisations by Lucho & Arkady. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/branches/UNSTABLE@1023 6ac86273-5f31-0410-b378-82cca8765d1b --- bin/autoexec.bat | 4 +- bin/config.sys | 6 +- boot/boot.asm | 94 ++++++++--- docs/contrib.txt | 3 + docs/history.txt | 34 ++++ filelist | 1 + hdr/device.h | 5 +- hdr/portab.h | 4 + kernel/config.c | 194 +++++++++------------- kernel/country.asm | 402 +++++++++++++++++++++++++++++++++++++++++++++ kernel/dosfns.c | 132 +++++++-------- kernel/dyninit.c | 2 + kernel/fattab.c | 28 +--- kernel/fcbfns.c | 54 +++--- kernel/globals.h | 2 +- kernel/init-mod.h | 3 +- kernel/inthndlr.c | 143 ++++++++++------ kernel/intr.asm | 18 ++ kernel/ioctl.c | 40 ++--- kernel/main.c | 65 ++------ kernel/makefile | 27 ++- kernel/nls.c | 30 +++- kernel/proto.h | 22 +-- kernel/task.c | 7 - sys/sys.c | 4 +- utils/exeflat.c | 112 +++++++------ utils/makefile | 1 + 27 files changed, 961 insertions(+), 476 deletions(-) create mode 100644 kernel/country.asm diff --git a/bin/autoexec.bat b/bin/autoexec.bat index 54f3e645..ec624b1d 100644 --- a/bin/autoexec.bat +++ b/bin/autoexec.bat @@ -1,3 +1 @@ -@echo off -echo Welcome to FreeDOS (http://www.freedos.org)! -path=a:\ +@echo Welcome to FreeDOS (http://www.freedos.org)! diff --git a/bin/config.sys b/bin/config.sys index 1810c89d..092bc2b0 100644 --- a/bin/config.sys +++ b/bin/config.sys @@ -1,5 +1 @@ -rem dos=high -rem device=fdxms.sys (or himem.sys) -files=20 -buffers=20 -rem screen=0x12 +; diff --git a/boot/boot.asm b/boot/boot.asm index fac35f12..ee6ff75a 100644 --- a/boot/boot.asm +++ b/boot/boot.asm @@ -30,6 +30,13 @@ ; |BOOT SEC| ; |RELOCATE| ; |--------| 1FE0:7C00 +; |LBA PKT | +; |--------| 1FE0:7BC0 +; |--------| 1FE0:7BA0 +; |BS STACK| +; |--------| +; |4KBRDBUF| used to avoid crossing 64KB DMA boundary +; |--------| 1FE0:63A0 ; | | ; |--------| 1FE0:3000 ; | CLUSTER| @@ -95,24 +102,24 @@ Entry: jmp short real_start times 0x3E-$+$$ db 0 -%define loadsegoff_60 bp+loadseg_off-Entry -%define loadseg_60 bp+loadseg_seg-Entry +; using bp-Entry+loadseg_xxx generates smaller code than using just +; loadseg_xxx, where bp is initialized to Entry, so bp-Entry equals 0 +%define loadsegoff_60 bp-Entry+loadseg_off +%define loadseg_60 bp-Entry+loadseg_seg -;%define LBA_PACKET bp+0x42 -; db 10h ; size of packet -; db 0 ; const -; dw 1 ; number of sectors to read %define LBA_PACKET bp-0x40 -%define LBA_SIZE word [LBA_PACKET] -%define LBA_SECNUM word [LBA_PACKET+2] -%define LBA_OFF LBA_PACKET+4 +%define LBA_SIZE word [LBA_PACKET] ; size of packet, should be 10h +%define LBA_SECNUM word [LBA_PACKET+2] ; number of sectors to read +%define LBA_OFF LBA_PACKET+4 ; buffer to read/write to %define LBA_SEG LBA_PACKET+6 -%define LBA_SECTOR_0 word [LBA_PACKET+8 ] +%define LBA_SECTOR_0 word [LBA_PACKET+8 ] ; LBA starting sector # %define LBA_SECTOR_16 word [LBA_PACKET+10] %define LBA_SECTOR_32 word [LBA_PACKET+12] %define LBA_SECTOR_48 word [LBA_PACKET+14] - +%define READBUF 0x63A0 ; max 4KB buffer (min 2KB stack), == stacktop-0x1800 +%define READADDR_OFF BP-0x60-0x1804 ; pointer within user buffer +%define READADDR_SEG BP-0x60-0x1802 %define PARAMS LBA_PACKET+0x10 %define RootDirSecs PARAMS+0x0 ; # of sectors root dir uses @@ -133,7 +140,7 @@ real_start: cld xor ax, ax mov ds, ax - mov bp, 0x7c00 + mov bp, BASE ; a reset should not be needed here @@ -171,6 +178,8 @@ dont_use_dl: ; no, rely on [drive] written by SYS mov LBA_SIZE, 10h mov LBA_SECNUM,1 ; initialise LBA packet constants + mov word [LBA_SEG],ds + mov word [LBA_OFF],READBUF ; GETDRIVEPARMS: Calculate start of some disk areas. @@ -223,7 +232,7 @@ dont_use_dl: ; no, rely on [drive] written by SYS mov di, word [RootDirSecs] les bx, [loadsegoff_60] ; es:bx = 60:0 call readDisk - les di, [loadsegoff_60] ; es:di = 60:0 + les di, [loadsegoff_60] ; es:di = 60:0 ; Search for KERNEL.SYS file name, and find start cluster. @@ -356,7 +365,8 @@ show: pop si ret boot_error: call show - db "Error! Hit a key to reboot." +; db "Error! Hit a key to reboot." + db "Err." xor ah,ah int 0x13 ; reset floppy @@ -377,8 +387,8 @@ readDisk: push si mov LBA_SECTOR_0,ax mov LBA_SECTOR_16,dx - mov word [LBA_SEG],es - mov word [LBA_OFF],bx + mov word [READADDR_SEG], es + mov word [READADDR_OFF], bx call show db "." @@ -409,7 +419,7 @@ read_next: lea si,[LBA_PACKET] ; setup LBA disk block - mov LBA_SECTOR_32,bx + mov LBA_SECTOR_32,bx ; bx is 0 if extended 13h mode supported mov LBA_SECTOR_48,bx mov ah,042h @@ -459,22 +469,33 @@ read_normal_BIOS: or cl, ah ; merge sector into cylinder inc cx ; make sector 1-based (1-63) - les bx,[LBA_OFF] + les bx,[LBA_OFF] mov ax, 0x0201 do_int13_read: mov dl, [drive] int 0x13 jc boot_error ; exit on error - mov ax, word [bsBytesPerSec] - div byte[LBA_PACKET] ; luckily 16 !! - add word [LBA_SEG], ax + + mov ax, word [bsBytesPerSec] + + push di + mov si,READBUF ; copy read in sector data to + les di,[READADDR_OFF] ; user provided buffer + mov cx, ax +; shr cx, 1 ; convert bytes to word count +; rep movsw + rep movsb + pop di + + shr ax, 4 ; adjust segment pointer by increasing + add word [READADDR_SEG], ax ; by paragraphs read in (per sector) add LBA_SECTOR_0, byte 1 adc LBA_SECTOR_16, byte 0 ; DX:AX = next sector to read dec di ; if there is anything left to read, jnz read_next ; continue - mov es,word [LBA_SEG] + les bx, [READADDR_OFF] ; clear carry: unnecessary since adc clears it pop si ret @@ -484,3 +505,32 @@ do_int13_read: filename db "KERNEL SYS",0,0 sign dw 0xAA55 + +%ifdef DBGPRNNUM +; DEBUG print hex digit routines +PrintLowNibble: ; Prints low nibble of AL, AX is destroyed + and AL, 0Fh ; ignore upper nibble + cmp AL, 09h ; if greater than 9, then don't base on '0', base on 'A' + jbe .printme + add AL, 7 ; convert to character A-F + .printme: + add AL, '0' ; convert to character 0-9 + mov AH,0x0E ; show character + int 0x10 ; via "TTY" mode + retn +PrintAL: ; Prints AL, AX is preserved + push AX ; store value so we can process a nibble at a time + shr AL, 4 ; move upper nibble into lower nibble + call PrintLowNibble + pop AX ; restore for other nibble + push AX ; but save so we can restore original AX + call PrintLowNibble + pop AX ; restore for other nibble + retn +PrintNumber: ; Prints (in Hex) value in AX, AX is preserved + xchg AH, AL ; high byte 1st + call PrintAL + xchg AH, AL ; now low byte + call PrintAL + retn +%endif diff --git a/docs/contrib.txt b/docs/contrib.txt index 15a25702..6f446a57 100644 --- a/docs/contrib.txt +++ b/docs/contrib.txt @@ -4,10 +4,13 @@ please email the current kernel maintainer so we can add you to the list! Thanks to all the following for contributing to the FreeDOS kernel: +Aitor Santamaria (aitor.sm@wanadoo.es) Arkady Belousov (ark@mos.ru) Bart Oldeman (bart@dosemu.org) +Bernd Blaauw (bblaauw@home.nl) Brian Reifsnyder (reifsnyderb@mindspring.com) Charles Dye (raster@highfiber.com) +Eduardo Casino (eduardo@terra.es) Eric Auer (eric@coli.uni-sb.de) Eric Biederman (ebiederm+eric@ccr.net) Eric Luttmann (ecl@users.sourceforge.net) diff --git a/docs/history.txt b/docs/history.txt index ea88b53b..c7c5d7ba 100644 --- a/docs/history.txt +++ b/docs/history.txt @@ -277,6 +277,7 @@ * inthndlr.c - fix: INT21/3301 now returns in DL low bit of input value (as in MS-DOS). - callerARG1 declared as xreg instead UWORD. + * fcbfns.c: FatGetDrvData() and FcbParseFname() optimised + Changes Bernd, Aitor, & Arkady * config.c - source: (Bernd) the codepage table rewritten into a smaller layout. @@ -285,6 +286,8 @@ * exeflat.c - fix: eliminated warning by explicit cast. - reduced trailer, added to UPXed kernel. + - allow processing of files with 0 relocations + - UPX trailer no longer depends on load segment * segs.inc - fix: for MSVC CONST segment should be class CONST, not DATA. * dsk.c @@ -293,15 +296,46 @@ - optimize and make more user friendly instead of retrying endlessly * sys.c - change OEM Name field to FRDOS4.1 per Eric Auer for better compatibility. + - added fat32readwrite int return type, now required by OpenWatcom 1.3 * ludivmul.inc - 32-bit division code for 386-enabled Watcom kernel. * inthndlr.c - fix: for INT21/5F07 and 5F08, before changing bit CDSPHYSDRV, MS-DOS checks if physical device associated with drive letter. Without this check MS-FORMAT under FreeDOS was destroys RAMDISK. + - zero serial number of Int 21h/30h (else buggy 32RTM thrashed stack) + - set AX = ES after Int 21h/4Ah (undocumented but expected by BRUN45) + (the last 2 changes needed to fix bugs discovered by Michael Devore) + - added Int 2Fh/2Fh processing to set DOS version as per MS-DOS 4.0 + * autoexec.bat now single-line for FreeCOM compatibility when EOL=LF + * config.sys: all commands removed as they were close to defaults + * contrib.txt: added Aitor Santamaria, Bernd Blaauw and Eduardo Casino + * country.asm / country.sys support now replaces hard-coded data + * 8 countries added to country.asm: GR, RO, AT, KR, TR, IN, M.East, IL + * dyninit.c: unused function DynFree() commented out + * fattab.c: ISFAT32 function removed (now macro), "wasfree" optimised + * globals.h: __TIME__ removed - no two kernels released on same day + * intr.asm: lseek() added (necessary for COUNTRY.SYS processing) + * ioctl.c: + - r_si/r_di contents added as documented in PC-DOS Technical Update + - r_unit now set to dpb_subunit (allows ZIP disk serial number) + * main.c: + - copyright message cleanup, now shows URL for the full GNU GPL text + - (with Bart) LoL pointer made const (saves some size for Watcom) + - InitializeAllBPBs() kludge removed (no longer needed - verified) + - revision sequence now initialised along with DOS version in LoL + - CheckContinueBootFromHardDisk() function code and text cleaned up + * makefile: object files reordered to gain ~300B packed size + * portab.h: pragma aux default to gain ~800B unpacked size (Watcom) + (the last 2 changes proposed by Bart Oldeman) + + Changes Eduardo + * inthndlr.c: added Int 2Fh/26-29h processing for NLSFUNC (with Lucho) + * nls.c: MuxLoadPkg(), MuxGo() functions modified for NLSFUNC + Changes Jeremy * config.txt - update to include all CONFIG.SYS options (except ANYDOS) + * exeflat.c + - show usage also when number of arguments incorrect *** Sync - Stable Build 2035 *** 2004 May 30 - Build 2035 diff --git a/filelist b/filelist index b6c5735b..7aa7764f 100644 --- a/filelist +++ b/filelist @@ -77,6 +77,7 @@ */*/kernel/config.c */*/kernel/config.h */*/kernel/console.asm +*/*/kernel/country.asm */*/kernel/dosfns.c */*/kernel/dosidle.asm */*/kernel/dosnames.c diff --git a/hdr/device.h b/hdr/device.h index 2708a609..b873badb 100644 --- a/hdr/device.h +++ b/hdr/device.h @@ -374,7 +374,8 @@ typedef struct { struct { UBYTE _r_cat; /* Category code */ UBYTE _r_fun; /* Function code */ - UBYTE unused[4]; /* SI or DI contents or DS:reqhdr */ + UWORD _r_si; /* Contents of SI and DI */ + UWORD _r_di; /* (PC DOS 7 Technical Update, pp 104,105) */ union { struct gblkio FAR *_r_io; @@ -424,6 +425,8 @@ typedef struct { /* generic IOCTL and IOCTL query macros */ #define r_cat _r_x._r_gen._r_cat #define r_fun _r_x._r_gen._r_fun +#define r_si _r_x._r_gen._r_si +#define r_di _r_x._r_gen._r_di #define r_rw _r_x._r_gen._r_par._r_rw #define r_io _r_x._r_gen._r_par._r_io #define r_fv _r_x._r_gen._r_par._r_fv diff --git a/hdr/portab.h b/hdr/portab.h index e551d6c3..19d91d44 100644 --- a/hdr/portab.h +++ b/hdr/portab.h @@ -123,6 +123,10 @@ unsigned short getSS(void); #pragma aux getSS = "mov dx,ss" value [dx] modify exact[dx]; /* enable Possible loss of precision warning for compatibility with Borland */ #pragma enable_message(130) +#if !defined(FORSYS) && !defined(EXEFLAT) +#pragma aux default parm [ax dx cx] modify [ax dx es fs] /* min.unpacked size */ +/* #pragma aux default parm [ax dx] modify [ax bx cx dx es fs]min.packed size */ +#endif #if _M_IX86 >= 300 || defined(M_I386) #define I386 diff --git a/kernel/config.c b/kernel/config.c index 6974e8fd..1e036f67 100644 --- a/kernel/config.c +++ b/kernel/config.c @@ -1152,38 +1152,103 @@ STATIC void Fcbs(PCStr p) * matching the specified code page and country code, and loads * the corresponding information into memory. If code page is 0, * the default code page for the country will be used. - * - * Returns TRUE if successful, FALSE if not. */ -#if 0 STATIC void LoadCountryInfo(CStr filename, int ccode, int cpage) { - say("Sorry, the COUNTRY= statement has been temporarily disabled\n"); - - UNREFERENCED_PARAMETER(cpage); - UNREFERENCED_PARAMETER(ccode); - UNREFERENCED_PARAMETER(filename); - - return FALSE; + /* COUNTRY.SYS file data structures - see RBIL tables 2619-2622 */ + + struct { /* file header */ + char name[8]; /* "\377COUNTRY.SYS" */ + char reserved[11]; + ULONG offset; /* offset of first entry in file */ + } header; + struct { /* entry */ + int length; /* length of entry, not counting this word, = 12 */ + int country; /* country ID */ + int codepage; /* codepage ID */ + int reserved[2]; + ULONG offset; /* offset of country-subfunction-header in file */ + } entry; + struct { /* subfunction header */ + int length; /* length of entry, not counting this word, = 6 */ + int id; /* subfunction ID */ + ULONG offset; /* offset within file of subfunction data entry */ + } subf_hdr; + struct { /* subfunction data */ + char signature[8]; /* \377CTYINFO|UCASE|LCASE|FUCASE|FCHAR|COLLATE|DBCS */ + int length; /* length of following table in bytes */ + } subf_data; + struct CountrySpecificInfo country; + int fd, entries, count, i, j; + + if ((fd = open(filename, 0)) < 0) + { + printf("%s not found\n", filename); + return; + } + if (read(fd, &header, sizeof(header)) < sizeof(header)) + { + printf("Can't read %s\n", filename); + goto ret; + } + if (memcmp(&header.name, "\377COUNTRY", 8)) + { +err:printf("%s has invalid format\n", filename); + goto ret; + } + if (lseek(fd, header.offset) == 0xffffffffL + || read(fd, &entries, sizeof(entries)) < sizeof(entries)) + goto err; + for (i = 0; i < entries; i++) + { + if (read(fd, &entry, sizeof(entry)) < sizeof(entry) || entry.length != 12) + goto err; + if (entry.country != ccode || entry.codepage != cpage && cpage) + continue; + if (lseek(fd, entry.offset) == 0xffffffffL + || read(fd, &count, sizeof(count)) < sizeof(count)) + goto err; + for (j = 0; j < count; j++) + { + if (read(fd, &subf_hdr, sizeof(subf_hdr)) < sizeof(subf_hdr) + || subf_hdr.length != 6) + goto err; + if (subf_hdr.id != 1) + continue; + if (lseek(fd, subf_hdr.offset) == 0xffffffffL + || read(fd, &subf_data, sizeof(subf_data)) < sizeof(subf_data) + || memcmp(&subf_data.signature, "\377CTYINFO", 8)) + goto err; + if (read(fd, &country, sizeof(country)) < sizeof(country)) + goto err; + if (country.CountryID != entry.country + || country.CodePage != entry.codepage && cpage) + continue; + i = nlsCountryInfoHardcoded.C.CodePage; + fmemcpy(&nlsCountryInfoHardcoded.C, &country, + min(sizeof(country), subf_data.length)); + nlsCountryInfoHardcoded.C.CodePage = i; + goto ret; + } + } + printf("couldn't find country info for country ID %u\n", ccode); +ret: + close(fd); } -#endif /* Format: COUNTRY [=] countryCode [, [codePage] [, filename]] */ STATIC void Country(PCStr p) { int ccode; - /*PCStr filename = "";*/ + PCStr filename = "\\COUNTRY.SYS"; p = GetNumArg(p); if (p == NULL) return; ccode = numarg; - /* currently 'implemented' COUNTRY=nnn only */ - -#if 0 - numarg = NLS_DEFAULT; + numarg = 0; p = skipwh(p); if (*p == ',') { @@ -1204,9 +1269,8 @@ STATIC void Country(PCStr p) CfgFailure(p); return; } -#endif - LoadCountryInfoHardCoded(/*filename*/"", ccode, /*numarg*/NLS_DEFAULT); + LoadCountryInfo(filename, ccode, numarg); } /* Format: STACKS [=] stacks [, stackSize] */ @@ -1937,100 +2001,6 @@ STATIC void CfgMenuColor(PCStr p) } } -/********************************************************************************* - National specific things. - this handles only Date/Time/Currency, and NOT codepage things. - Some may consider this a hack, but I like to see 24 Hour support. tom. -*********************************************************************************/ - -#define _DATE_MDY 0 /* mm/dd/yy */ -#define _DATE_DMY 1 /* dd.mm.yy */ -#define _DATE_YMD 2 /* yy/mm/dd */ - -#define _TIME_12 0 -#define _TIME_24 1 - -struct CountrySpecificInfo specificCountriesSupported[] = { - -/* table rewritten by Bernd Blaauw -Country ID : international numbering -Codepage : codepage to use by default -Date format : M = Month, D = Day, Y = Year (4digit); 0=USA, 1=Europe, 2=Japan -Currency : $ = dollar, EUR = EURO (ALT-128), United Kingdom uses the pound sign -Thousands : separator for thousands (1,000,000 bytes; Dutch: 1.000.000 bytes) -Decimals : separator for decimals (2.5KB; Dutch: 2,5KB) -Datesep : Date separator (2/4/2004 or 2-4-2004 for example) -Timesep : usually ":" is used to separate hours, minutes and seconds -Currencyf : Currency format (bit array) -Currencyp : Currency precision -Timeformat : 0=12 hour format (AM/PM), 1=24 hour format (16:12 means 4:12 PM) - - ID CP Date currency 1000 0.1 date time C digit time Locale/Country contributor -------------------------------------------------------------------------------------------------------------- */ -{ 1,437,_DATE_MDY,"$" ,",",".", "/", ":", 0 , 2,_TIME_12}, /* United States */ -{ 2,863,_DATE_YMD,"$" ,",",".", "-", ":", 0 , 2,_TIME_24}, /* Canadian French */ -{ 3,850,_DATE_MDY,"$" ,",",".", "/", ":", 0 , 2,_TIME_12}, /* Latin America */ -{ 7,866,_DATE_DMY,"RUB" ," ",",", ".", ":", 3 , 2,_TIME_24}, /* Russia Arkady V. Belousov */ -{ 31,850,_DATE_DMY,"EUR" ,".",",", "-", ":", 0 , 2,_TIME_24}, /* Dutch Bart Oldeman */ -{ 32,850,_DATE_DMY,"EUR" ,".",",", "-", ":", 0 , 2,_TIME_24}, /* Belgium */ -{ 33,850,_DATE_DMY,"EUR" ,".",",", "-", ":", 0 , 2,_TIME_24}, /* France */ -{ 34,850,_DATE_DMY,"EUR" ,".","'", "-", ":", 0 , 2,_TIME_24}, /* Spain Aitor Santamaria Merino */ -{ 36,850,_DATE_DMY,"$HU" ,".",",", "-", ":", 0 , 2,_TIME_24}, /* Hungary */ -{ 38,850,_DATE_DMY,"$YU" ,".",",", "-", ":", 0 , 2,_TIME_24}, /* Yugoslavia */ -{ 39,850,_DATE_DMY,"EUR" ,".",",", "-", ":", 0 , 2,_TIME_24}, /* Italy */ -{ 41,850,_DATE_DMY,"SF" ,".",",", ".", ":", 0 , 2,_TIME_24}, /* Switserland */ -{ 42,850,_DATE_YMD,"$YU" ,".",",", ".", ":", 0 , 2,_TIME_24}, /* Czech & Slovakia */ -{ 44,850,_DATE_DMY,"\x9c" ,".",",", "/", ":", 0 , 2,_TIME_24}, /* United Kingdom */ -{ 45,850,_DATE_DMY,"DKK" ,".",",", "-", ":", 0 , 2,_TIME_24}, /* Denmark */ -{ 46,850,_DATE_YMD,"SEK" ,",",".", "-", ":", 0 , 2,_TIME_24}, /* Sweden */ -{ 47,850,_DATE_DMY,"NOK" ,",",".", ".", ":", 0 , 2,_TIME_24}, /* Norway */ -{ 48,850,_DATE_YMD,"PLN" ,",",".", ".", ":", 0 , 2,_TIME_24}, /* Poland Michael H.Tyc */ -{ 49,850,_DATE_DMY,"EUR" ,".",",", ".", ":", 1 , 2,_TIME_24}, /* German Tom Ehlert */ -{ 54,850,_DATE_DMY,"$ar" ,".",",", "/", ":", 1 , 2,_TIME_12}, /* Argentina */ -{ 55,850,_DATE_DMY,"$ar" ,".",",", "/", ":", 1 , 2,_TIME_24}, /* Brazil */ -{ 61,850,_DATE_MDY,"$" ,".",",", "/", ":", 0 , 2,_TIME_24}, /* Int. English */ -{ 81,932,_DATE_YMD,"\x81\x8f",",",".", "/", ":", 0 , 2,_TIME_12}, /* Japan Yuki Mitsui */ -{351,850,_DATE_DMY,"EUR" ,".",",", "-", ":", 0 , 2,_TIME_24}, /* Portugal */ -{358,850,_DATE_DMY,"EUR" ," ",",", ".", ":",0x3, 2,_TIME_24}, /* Finland wolf */ -{359,855,_DATE_DMY,"BGL" ," ",",", ".", ":", 3 , 2,_TIME_24}, /* Bulgaria Luchezar Georgiev */ -{380,848,_DATE_DMY,"UAH" ," ",",", ".", ":", 3 , 2,_TIME_24}, /* Ukraine Oleg Deribas */ -}; - -STATIC void LoadCountryInfoHardCoded(CStr filename, int ccode, int cpage) -{ - struct CountrySpecificInfo *country; - UNREFERENCED_PARAMETER(cpage); - UNREFERENCED_PARAMETER(filename); - - /* printf("cntry: %u, CP%u, file=\"%s\"\n", ccode, cpage, filename); */ - - for (country = specificCountriesSupported; - country < ENDOF(specificCountriesSupported); - country++) - { - if (country->CountryID == ccode) - { - int codepagesaved = nlsCountryInfoHardcoded.C.CodePage; - fmemcpy(&nlsCountryInfoHardcoded.C, - country, - min(nlsCountryInfoHardcoded.TableSize, sizeof *country)); - nlsCountryInfoHardcoded.C.CodePage = codepagesaved; - return; - } - } - - printf("could not find country info for country ID %u\n" - "current supported countries are ", ccode); - - for (country = specificCountriesSupported; - country < ENDOF(specificCountriesSupported); - country++) - { - printf("%u ", country->CountryID); - } - say("\n"); -} - /* **************************************************************** ** implementation of INSTALL=NANSI.COM /P /X /BLA */ diff --git a/kernel/country.asm b/kernel/country.asm new file mode 100644 index 00000000..204498c6 --- /dev/null +++ b/kernel/country.asm @@ -0,0 +1,402 @@ +; A rudimentary COUNTRY.SYS for FreeDOS +; Handles only Date/Time/Currency, and NOT codepage things [yet] +; Compatible with COUNTRY.SYS of MS-DOS, PC-DOS, PTS-DOS, OS/2, Win9x, WinNT +; File format described in RBIL tables 2619-2622 +; +; Created as a kernel table by Tom Ehlert +; Reformatted and commented by Bernd Blaauw +; Separated from the kernel by Luchezar Georgiev +; Amended by many contributors (see names below) + +; file header + +db 0FFh,"COUNTRY",0,0,0,0,0,0,0,0,1,0,1 ; reserved and undocumented values +dd ent ; first entry +ent dw 35; number of entries - don't forget to update when adding a new country + +; entries +; (size, country, codepage, reserved(2), offset) + +__us dw 12, 1,437,0,0 + dd _us +__ca dw 12, 2,863,0,0 + dd _ca +__la dw 12, 3,850,0,0 + dd _la +__ru dw 12, 7,866,0,0 + dd _ru +__gr dw 12, 30,869,0,0 + dd _gr +__nl dw 12, 31,850,0,0 + dd _nl +__be dw 12, 32,850,0,0 + dd _be +__fr dw 12, 33,850,0,0 + dd _fr +__es dw 12, 34,850,0,0 + dd _es +__hu dw 12, 36,852,0,0 + dd _hu +__yu dw 12, 38,852,0,0 + dd _yu +__it dw 12, 39,850,0,0 + dd _it +__ro dw 12, 40,852,0,0 + dd _ro +__ch dw 12, 41,850,0,0 + dd _ch +__cz dw 12, 42,852,0,0 + dd _cz +__at dw 12, 43,850,0,0 + dd _at +__uk dw 12, 44,850,0,0 + dd _uk +__dk dw 12, 45,865,0,0 + dd _dk +__se dw 12, 46,850,0,0 + dd _se +__no dw 12, 47,865,0,0 + dd _no +__pl dw 12, 48,852,0,0 + dd _pl +__de dw 12, 49,850,0,0 + dd _de +__ar dw 12, 54,850,0,0 + dd _ar +__br dw 12, 55,850,0,0 + dd _br +__au dw 12, 61,437,0,0 + dd _au +__jp dw 12, 81,932,0,0 + dd _jp +__kr dw 12, 82,934,0,0 + dd _kr +__tk dw 12, 90,850,0,0 + dd _tk +__in dw 12, 91,437,0,0 + dd _in +__pt dw 12,351,860,0,0 + dd _pt +__fi dw 12,358,850,0,0 + dd _fi +__bg dw 12,359,855,0,0 + dd _bg +__ua dw 12,380,848,0,0 + dd _ua +__me dw 12,785,864,0,0 + dd _me +__il dw 12,972,862,0,0 + dd _me + +; subfunction headers (so far only for subfunction 1, "CTYINFO") +; (count, size, id, offset) +; add ofher subfunctions after each one + +_us dw 1,6,1 + dd us +_ca dw 1,6,1 + dd ca +_la dw 1,6,1 + dd la +_ru dw 1,6,1 + dd ru +_gr dw 1,6,1 + dd gr +_nl dw 1,6,1 + dd nl +_be dw 1,6,1 + dd be +_fr dw 1,6,1 + dd fr +_es dw 1,6,1 + dd sn +_hu dw 1,6,1 + dd hu +_yu dw 1,6,1 + dd yu +_it dw 1,6,1 + dd it +_ro dw 1,6,1 + dd ro +_ch dw 1,6,1 + dd sw +_cz dw 1,6,1 + dd cz +_at dw 1,6,1 + dd as +_uk dw 1,6,1 + dd uk +_dk dw 1,6,1 + dd dk +_se dw 1,6,1 + dd se +_no dw 1,6,1 + dd no +_pl dw 1,6,1 + dd pl +_de dw 1,6,1 + dd de +_ar dw 1,6,1 + dd ar +_br dw 1,6,1 + dd br +_au dw 1,6,1 + dd au +_jp dw 1,6,1 + dd np +_kr dw 1,6,1 + dd kr +_tk dw 1,6,1 + dd tk +_in dw 1,6,1 + dd ia +_pt dw 1,6,1 + dd pt +_fi dw 1,6,1 + dd fi +_bg dw 1,6,1 + dd bg +_ua dw 1,6,1 + dd ua +_me dw 1,6,1 + dd me +_il dw 1,6,1 + dd me + +%define MDY 0 ; month/day/year +%define DMY 1 ; day/month/year +%define YMD 2 ; year/month/day + +%define _12 0 ; time as AM/PM +%define _24 1 ; 24-hour format + +; Country ID : international numbering +; Codepage : codepage to use by default +; Date format : M = Month, D = Day, Y = Year (4digit); 0=USA, 1=Europe, 2=Japan +; Currency : $ = dollar, EUR = EURO (ALT-128), UK uses the pound sign +; Thousands : separator for 1000s (1,000,000 bytes; Dutch: 1.000.000 bytes) +; Decimals : separator for decimals (2.5 KB; Dutch: 2,5 KB) +; Datesep : Date separator (2/4/2004 or 2-4-2004 for example) +; Timesep : usually ":" is used to separate hours, minutes and seconds +; Currencyf : Currency format (bit array) +; bit 2 = set if currency symbol replaces decimal point +; bit 1 = number of spaces between value and currency symbol +; bit 0 = 0 if currency symbol precedes value +; 1 if currency symbol follows value +; Currencyp : Currency precision +; Time format : 0=12 hour format (AM/PM), 1=24 hour format (4:12 PM is 16:12) +; +; ID CP DF currency 1000 0.1 DS TS CF Pr TF Country/Locale Contributor +;------------------------------------------------------------------------------ +us db 0FFh,"CTYINFO" + dw 22; length +dw 1,437,MDY + db "$",0,0,0,0 + dw ",",".", "-",":" + db 0,2,_12; United States +ca db 0FFh,"CTYINFO" + dw 22 +dw 2,863,YMD + db "$",0,0,0,0 + dw " ",",", "-",":" + db 3,2,_24; Canadian French +la db 0FFh,"CTYINFO" + dw 22 +dw 3,850,DMY + db "$",0,0,0,0 + dw ",",".", "/",":" + db 0,2,_12; Latin America +ru db 0FFh,"CTYINFO" + dw 22 +dw 7,866,DMY + db "RUB",0,0 + dw " ",",", ".",":" + db 3,2,_24; Russia Arkady V. Belousov +gr db 0FFh,"CTYINFO" + dw 22 +dw 30,869,DMY + db "EYP",0,0 + dw ".",",", "/",":" + db 1,2,_12; Greece +nl db 0FFh,"CTYINFO" + dw 22 +dw 31,850,DMY + db "EUR",0,0 + dw ".",",", "-",":" + db 0,2,_24; Netherlands Bart E. Oldeman +be db 0FFh,"CTYINFO" + dw 22 +dw 32,850,DMY + db "EUR",0,0 + dw ".",",", "/",":" + db 0,2,_24; Belgium +fr db 0FFh,"CTYINFO" + dw 22 +dw 33,850,DMY + db "EUR",0,0 + dw " ",",", ".",":" + db 0,2,_24; France +sn db 0FFh,"CTYINFO" + dw 22 +dw 34,850,DMY + db "EUR",0,0 + dw ".",",", "/",":" + db 0,2,_24; Spain Aitor S. Merino +hu db 0FFh,"CTYINFO" + dw 22 +dw 36,852,YMD + db "Ft",0,0,0 + dw " ",",", ".",":" + db 3,2,_24; Hungary +yu db 0FFh,"CTYINFO" + dw 22 +dw 38,852,YMD + db "Din",0,0 + dw ".",",", "-",":" + db 2,2,_24; Yugoslavia +it db 0FFh,"CTYINFO" + dw 22 +dw 39,850,DMY + db "EUR",0,0 + dw ".",",", "/","." + db 0,2,_24; Italy +ro db 0FFh,"CTYINFO" + dw 22 +dw 40,852,YMD + db "Lei",0,0 + dw ".",",", "-",":" + db 0,2,_24; Romania +sw db 0FFh,"CTYINFO" + dw 22 +dw 41,850,DMY + db "Fr.",0,0 + dw "'",".", ".","," + db 2,2,_24; Switzerland +cz db 0FFh,"CTYINFO" + dw 22 +dw 42,852,YMD + db "KCs",0,0 + dw ".",",", "-",":" + db 2,2,_24; Czechoslovakia +as db 0FFh,"CTYINFO" + dw 22 +dw 43,850,DMY + db "EUR",0,0 + dw ".",",", ".","." + db 0,2,_24; Austria +uk db 0FFh,"CTYINFO" + dw 22 +dw 44,850,DMY + db 9ch,0,0,0,0 + dw ",",".", "/",":" + db 0,2,_24; United Kingdom +dk db 0FFh,"CTYINFO" + dw 22 +dw 45,865,DMY + db "kr",0,0,0 + dw ".",",", "-","." + db 2,2,_24; Denmark +se db 0FFh,"CTYINFO" + dw 22 +dw 46,850,YMD + db "Kr",0,0,0 + dw " ",",", "-","." + db 3,2,_24; Sweden +no db 0FFh,"CTYINFO" + dw 22 +dw 47,865,DMY + db "Kr",0,0,0 + dw ".",",", ".",":" + db 2,2,_24; Norway +pl db 0FFh,"CTYINFO" + dw 22 +dw 48,852,YMD + db "Z",88h,0,0,0 + dw ".",",", "-",":" + db 0,2,_24; Poland Michal H. Tyc +de db 0FFh,"CTYINFO" + dw 22 +dw 49,850,DMY + db "EUR",0,0 + dw ".",",", ".","." + db 1,2,_24; Germany Tom Ehlert +ar db 0FFh,"CTYINFO" + dw 22 +dw 54,850,DMY + db "$",0,0,0,0 + dw ".",",", "/","." + db 0,2,_24; Argentina +br db 0FFh,"CTYINFO" + dw 22 +dw 55,850,DMY + db "Cr$",0,0 + dw ".",",", "/",":" + db 2,2,_24; Brazil +au db 0FFh,"CTYINFO" + dw 22 +dw 61,437,DMY + db "$",0,0,0,0 + dw ",",".", "-",":" + db 0,2,_12; Australia +np db 0FFh,"CTYINFO" + dw 22 +dw 81,932,YMD + db 81h,8fh,0,0,0 + dw ",",".", "-",":" + db 0,0,_24; Japan Yuki Mitsui +kr db 0FFh,"CTYINFO" + dw 22 +dw 82,934,YMD + db 5Ch,0,0,0,0 + dw ",",".", ".",":" + db 0,0,_24; Korea +tk db 0FFh,"CTYINFO" + dw 22 +dw 90,850,DMY + db "TL",0,0,0 + dw ".",",", "/",":" + db 4,2,_24; Turkey +ia db 0FFh,"CTYINFO" + dw 22 +dw 91,437,DMY + db "Rs",0,0,0 + dw ".",",", "/",":" + db 0,2,_24; India +pt db 0FFh,"CTYINFO" + dw 22 +dw 351,860,DMY + db "EUR",0,0 + dw ".",",", "-",":" + db 0,2,_24; Portugal +fi db 0FFh,"CTYINFO" + dw 22 +dw 358,850,DMY + db "EUR",0,0 + dw " ",",", ".","." + db 3,2,_24; Finland Wolf +bg db 0FFh,"CTYINFO" + dw 22 +dw 359,855,DMY + db "BGL",0,0 + dw " ",",", ".","," + db 3,2,_24; Bulgaria Luchezar Georgiev +ua db 0FFh,"CTYINFO" + dw 22 +dw 380,848,DMY + db "UAH",0,0 + dw " ",",", ".",":" + db 3,2,_24; Ukraine Oleg Deribas +me db 0FFh,"CTYINFO" + dw 22 +dw 785,864,DMY + db 0A4h,0,0,0,0 + dw ".",",", "/",":" + db 3,3,_12; Middle East +il db 0FFh,"CTYINFO" + dw 22 +dw 972,862,DMY + db 99h,0,0,0,0 + dw ",",".", " ",":" + db 2,2,_24; Israel + +db "FreeDOS" ; trailing, as recommended by RBIL diff --git a/kernel/dosfns.c b/kernel/dosfns.c index 5135d4d7..7ef142c4 100644 --- a/kernel/dosfns.c +++ b/kernel/dosfns.c @@ -96,6 +96,13 @@ STATIC int remote_lock_unlock(sft FAR *sftp, /* SFT for file */ /* get current directory structure for drive return NULL if the CDS is not valid or the drive is not within range */ +struct cds FAR *get_cds1(unsigned drv) +{ + if (drv-- == 0) /* 0 = A:, 1 = B:, ... */ + drv = default_drive; + return get_cds(drv); +} + struct cds FAR *get_cds(unsigned drive) { struct cds FAR *cdsp; @@ -106,9 +113,9 @@ struct cds FAR *get_cds(unsigned drive) cdsp = &CDSp[drive]; flags = cdsp->cdsFlags; /* Entry is disabled or JOINed drives are accessable by the path only */ - if (!(flags & CDSVALID) || (flags & CDSJOINED) != 0) - return NULL; - if (!(flags & CDSNETWDRV) && cdsp->cdsDpb == NULL) + if ((flags & CDSVALID) == 0 || + (flags & CDSJOINED) != 0 || + (flags & CDSNETWDRV) == 0 && cdsp->cdsDpb == NULL) return NULL; return cdsp; } @@ -308,9 +315,13 @@ long DosRWSft(int sft_idx, size_t n, void FAR * bp, int mode) } } -COUNT SftSeek(int sft_idx, LONG new_pos, unsigned mode) +int SftSeek(int sft_idx, LONG new_pos, unsigned mode) +{ + return _SftSeek(idx_to_sft(sft_idx), new_pos, mode); +} + +int _SftSeek(sft FAR *s, LONG new_pos, unsigned mode) { - sft FAR *s = idx_to_sft(sft_idx); if (FP_OFF(s) == (size_t) -1) return DE_INVLDHNDL; @@ -322,7 +333,6 @@ COUNT SftSeek(int sft_idx, LONG new_pos, unsigned mode) if (s->sft_flags & SFT_FSHARED) { - /* SEEK_SET handled below (s->sft_posit=new_pos) */ if (mode == SEEK_CUR) { new_pos += s->sft_posit; @@ -361,20 +371,6 @@ COUNT SftSeek(int sft_idx, LONG new_pos, unsigned mode) return SUCCESS; } -ULONG DosSeek(unsigned hndl, LONG new_pos, COUNT mode) -{ - int sft_idx = get_sft_idx(hndl); - COUNT result; - - /* Get the SFT block that contains the SFT */ - result = SftSeek(sft_idx, new_pos, mode); - if (result == SUCCESS) - { - return idx_to_sft(sft_idx)->sft_posit; - } - return (ULONG)-1; -} - STATIC long get_free_hndl(void) { psp FAR *p = MK_FP(cu_psp, 0); @@ -764,28 +760,22 @@ COUNT DosClose(COUNT hndl) return ret; } -BOOL DosGetFree(UBYTE drive, UWORD * spc, UWORD * navc, - UWORD * bps, UWORD * nc) +UWORD DosGetFree(UBYTE drive, UWORD * navc, UWORD * bps, UWORD * nc) { /* navc==NULL means: called from FatGetDrvData, fcbfns.c */ struct dpb FAR *dpbp; struct cds FAR *cdsp; - COUNT rg[4]; - - /* next - "log" in the drive */ - drive = (drive == 0 ? default_drive : drive - 1); - - /* first check for valid drive */ - *spc = -1; - cdsp = get_cds(drive); + UWORD spc; - if (cdsp == NULL) - return FALSE; + /* first check for valid drive */ + if ((cdsp = get_cds1(drive)) == NULL) + return -1; if (cdsp->cdsFlags & CDSNETWDRV) { + COUNT rg[4]; if (remote_getfree(cdsp, rg) != SUCCESS) - return FALSE; + return -1; /* for int21/ah=1c: Undoc DOS says, its not supported for @@ -794,21 +784,15 @@ BOOL DosGetFree(UBYTE drive, UWORD * spc, UWORD * navc, the redirector can provide all info - Bart, 2002 Apr 1 */ - if (navc != NULL) - { - *navc = (COUNT) rg[3]; - *spc &= 0xff; /* zero out media ID byte */ - } - - *spc = (COUNT) rg[0]; - *nc = (COUNT) rg[1]; - *bps = (COUNT) rg[2]; - return TRUE; + *bps = rg[2]; + *nc = rg[1]; + if (navc) + *navc = rg[3]; + return rg[0]; } - dpbp = cdsp->cdsDpb; - if (dpbp == NULL) - return FALSE; + if ((dpbp = cdsp->cdsDpb) == NULL) + return -1; if (navc == NULL) { @@ -816,56 +800,60 @@ BOOL DosGetFree(UBYTE drive, UWORD * spc, UWORD * navc, flush_buffers(dpbp->dpb_unit); dpbp->dpb_flags = M_CHANGED; } - if (media_check(dpbp) < 0) - return FALSE; - /* get the data available from dpb */ - *spc = (dpbp->dpb_clsmask + 1); + return -1; + + /* get the data available from dpb */ + spc = dpbp->dpb_clsmask + 1; *bps = dpbp->dpb_secsize; - /* now tell fs to give us free cluster */ - /* count */ #ifdef WITHFAT32 if (ISFAT32(dpbp)) { ULONG cluster_size, ntotal, nfree; - /* we shift ntotal until it is equal to or below 0xfff6 */ cluster_size = (ULONG) dpbp->dpb_secsize << dpbp->dpb_shftcnt; ntotal = dpbp->dpb_xsize - 1; - if (navc != NULL) + /* now tell fs to give us free cluster count */ + if (navc) nfree = dos_free(dpbp); + + /* we shift ntotal until it is equal to or below 0xfff6 */ while (ntotal > FAT_MAGIC16 && cluster_size < 0x8000) { cluster_size <<= 1; - *spc <<= 1; + spc <<= 1; ntotal >>= 1; nfree >>= 1; } - /* get the data available from dpb */ - *nc = ntotal > FAT_MAGIC16 ? FAT_MAGIC16 : (UCOUNT) ntotal; - - /* now tell fs to give us free cluster */ - /* count */ - if (navc != NULL) - *navc = nfree > FAT_MAGIC16 ? FAT_MAGIC16 : (UCOUNT) nfree; - return TRUE; + + *nc = ntotal > FAT_MAGIC16 ? FAT_MAGIC16 : (UWORD) ntotal; + if (navc) + *navc = nfree > FAT_MAGIC16 ? FAT_MAGIC16 : (UWORD) nfree; + return spc; } #endif - /* a passed nc of 0xffff means: skip free; see FatGetDrvData - fcbfns.c */ - if (*nc != 0xffff) - *navc = (COUNT) dos_free(dpbp); + *nc = dpbp->dpb_size - 1; - if (*spc > 64) + /* now tell fs to give us free cluster count */ + if (navc) + *navc = (UWORD) dos_free(dpbp); + if (spc > 64) { /* fake for 64k clusters do confuse some DOS programs, but let others work without overflowing */ - *spc >>= 1; - *navc = ((unsigned)*navc < FAT_MAGIC16 / 2) ? ((unsigned)*navc << 1) : FAT_MAGIC16; - *nc = ((unsigned)*nc < FAT_MAGIC16 / 2) ? ((unsigned)*nc << 1) : FAT_MAGIC16; + spc >>= 1; + if (*nc > FAT_MAGIC16 / 2) + *nc = FAT_MAGIC16; + else + *nc <<= 1; + if (navc) + if (*navc > FAT_MAGIC16 / 2) + *navc = FAT_MAGIC16; + else + *navc <<= 1; } - return TRUE; + return spc; } #ifdef WITHFAT32 diff --git a/kernel/dyninit.c b/kernel/dyninit.c index 46acb1a9..575998ea 100644 --- a/kernel/dyninit.c +++ b/kernel/dyninit.c @@ -82,11 +82,13 @@ void far *DynAlloc(char *what, unsigned num, unsigned size) return now; } +/* void DynFree(void *ptr) { struct DynS far *Dynp = MK_FP(FP_SEG(LoL), FP_OFF(&Dyn)); Dynp->Allocated = (char *)ptr - (char *)Dynp->Buffer; } +*/ void FAR * DynLast() { diff --git a/kernel/fattab.c b/kernel/fattab.c index 6083a65d..f6aafe2a 100644 --- a/kernel/fattab.c +++ b/kernel/fattab.c @@ -44,13 +44,6 @@ static BYTE *RcsId = cluster number rather than overwriting it */ #define READ_CLUSTER 1 -#ifndef ISFAT32 -int ISFAT32(struct dpb FAR * dpbp) -{ - return _ISFAT32(dpbp); -} -#endif - struct buffer FAR *getFATblock(struct dpb FAR * dpbp, CLUSTER clussec) { struct buffer FAR *bp = getblock(clussec, dpbp->dpb_unit); @@ -125,7 +118,7 @@ CLUSTER link_fat(struct dpb FAR * dpbp, CLUSTER Cluster1, struct buffer FAR *bp; unsigned idx; unsigned secdiv; - unsigned char wasfree; + unsigned char wasfree = 0; CLUSTER clussec = Cluster1; CLUSTER max_cluster = dpbp->dpb_size; @@ -207,7 +200,7 @@ CLUSTER link_fat(struct dpb FAR * dpbp, CLUSTER Cluster1, if (bp1 == 0) return 1; /* the only error code possible here */ - if (Cluster2 != READ_CLUSTER) + if ((unsigned)Cluster2 != READ_CLUSTER) bp1->b_flag |= BFR_DIRTY | BFR_VALID; fbp1 = &bp1->b_buffer[0]; @@ -232,11 +225,8 @@ CLUSTER link_fat(struct dpb FAR * dpbp, CLUSTER Cluster1, return LONG_BAD; return cluster; } - - wasfree = 0; if (cluster == FREE) - wasfree = 1; - + wasfree++; cluster = res; } @@ -245,7 +235,7 @@ CLUSTER link_fat(struct dpb FAR * dpbp, CLUSTER Cluster1, cluster2 = (unsigned)Cluster2 & 0x0fff; /* Now pack the value in */ - if ((unsigned)Cluster1 & 0x01) + if (Cluster1 & 0x01) { cluster &= 0x000f; cluster2 <<= 4; @@ -276,9 +266,8 @@ CLUSTER link_fat(struct dpb FAR * dpbp, CLUSTER Cluster1, /* Finally, put the word into the buffer and mark the */ /* buffer as dirty. */ fputword(&bp->b_buffer[idx * 2], (UWORD)Cluster2); - wasfree = 0; if (res == FREE) - wasfree = 1; + wasfree++; } #ifdef WITHFAT32 else if (ISFAT32(dpbp)) @@ -296,9 +285,8 @@ CLUSTER link_fat(struct dpb FAR * dpbp, CLUSTER Cluster1, /* Finally, put the word into the buffer and mark the */ /* buffer as dirty. */ fputlong(&bp->b_buffer[idx * 4], Cluster2); - wasfree = 0; if (res == FREE) - wasfree = 1; + wasfree++; } #endif else @@ -310,9 +298,9 @@ CLUSTER link_fat(struct dpb FAR * dpbp, CLUSTER Cluster1, { int adjust = 0; if (!wasfree) - adjust = 1; + adjust++; else if (Cluster2 != FREE) - adjust = -1; + adjust--; #ifdef WITHFAT32 if (ISFAT32(dpbp) && dpbp->dpb_xnfreeclst != XUNKNCLSTFREE) { diff --git a/kernel/fcbfns.c b/kernel/fcbfns.c index a74795e9..576aec7d 100644 --- a/kernel/fcbfns.c +++ b/kernel/fcbfns.c @@ -50,29 +50,27 @@ STATIC void FcbCalcRec(xfcb FAR * lpXfcb); #define TestCmnSeps(lpFileName) (*lpFileName && strchr(":<|>+=,", *lpFileName) != NULL) #define TestFieldSeps(lpFileName) ((unsigned char)*lpFileName <= ' ' || strchr("/\"[]<>|.", *lpFileName) != NULL) -static dmatch Dmatch; - -BYTE FAR *FatGetDrvData(UBYTE drive, UWORD * spc, UWORD * bps, UWORD * nc) +UBYTE FAR *FatGetDrvData(UBYTE drive, UBYTE * pspc, UWORD * bps, UWORD * nc) { - static BYTE mdb; + /* get the data available from dpb */ + UWORD spc = DosGetFree(drive, NULL, bps, nc); + if ((*pspc = lobyte(spc)) == 0xff) + return NULL; - /* get the data available from dpb */ - if (DosGetFree(drive, spc, NULL, bps, nc)) + if (drive-- == 0) /* 0 = A:, 1 = B:, ... */ + drive = default_drive; + + /* Point to the media desctriptor for this drive */ { - struct dpb FAR *dpbp = get_dpb(drive == 0 ? default_drive : drive - 1); - /* Point to the media desctriptor for this drive */ - if (dpbp == NULL) - { - mdb = *spc >> 8; - *spc &= 0xff; - return &mdb; - } - else - { - return (BYTE FAR *) & (dpbp->dpb_mdb); - } + struct dpb FAR *dpbp; + if ((dpbp = get_dpb(drive)) != NULL) + return &dpbp->dpb_mdb; + } + + { + static UBYTE mdb = 0; + return &mdb; } - return NULL; } #define PARSE_SEP_STOP 0x01 @@ -85,7 +83,7 @@ BYTE FAR *FatGetDrvData(UBYTE drive, UWORD * spc, UWORD * bps, UWORD * nc) #define PARSE_RET_BADDRIVE 0xff #ifndef IPL -UWORD FcbParseFname(int *wTestMode, const BYTE FAR * lpFileName, fcb FAR * lpFcb) +ofs_t FcbParseFname(UBYTE *wTestMode, const char FAR * lpFileName, fcb FAR * lpFcb) { WORD wRetCodeName = FALSE, wRetCodeExt = FALSE; @@ -157,7 +155,9 @@ UWORD FcbParseFname(int *wTestMode, const BYTE FAR * lpFileName, fcb FAR * lpFcb GetNameField(++lpFileName, (BYTE FAR *) lpFcb->fcb_fext, FEXT_SIZE, (BOOL *) & wRetCodeExt); - *wTestMode = (wRetCodeName | wRetCodeExt) ? PARSE_RET_WILD : PARSE_RET_NOWILD; + *wTestMode = PARSE_RET_WILD; + if (!(wRetCodeName | wRetCodeExt)) + *wTestMode = PARSE_RET_NOWILD; return FP_OFF(lpFileName); } @@ -539,13 +539,14 @@ UBYTE FcbRename(xfcb FAR * lpXfcb) else do { /* 'A:' + '.' + '\0' */ - BYTE loc_szBuffer[2 + FNAME_SIZE + 1 + FEXT_SIZE + 1]; + char loc_szBuffer[2 + FNAME_SIZE + 1 + FEXT_SIZE + 1]; fcb LocalFcb; BYTE *pToName; const BYTE FAR *pFromPattern = Dmatch.dm_name; - int i = 0; + int i; - FcbParseFname(&i, pFromPattern, &LocalFcb); + loc_szBuffer [0] = 0; /* dummy place */ + FcbParseFname((UBYTE*)loc_szBuffer, pFromPattern, &LocalFcb); /* Overlay the pattern, skipping '?' */ /* I'm cheating because this assumes that the */ /* struct alignments are on byte boundaries */ @@ -630,6 +631,10 @@ VOID FcbCloseAll() DosCloseSft(idx, FALSE); } +/* TE suggest, that there was not enough space on stack for + Dmatch in FcbFindFirstNext() --avb */ +static dmatch Dmatch; + UBYTE FcbFindFirstNext(xfcb FAR * lpXfcb, BOOL First) { void FAR *orig_dta = dta; @@ -691,4 +696,3 @@ UBYTE FcbFindFirstNext(xfcb FAR * lpXfcb, BOOL First) return FCB_SUCCESS; } #endif - diff --git a/kernel/globals.h b/kernel/globals.h index dc16b570..c8f912a2 100644 --- a/kernel/globals.h +++ b/kernel/globals.h @@ -217,7 +217,7 @@ GLOBAL const BYTE ASM os_release[] = "DOS-C version %d.%d Beta %d [FreeDOS Release] (Build %d).\n" #endif = "FreeDOS kernel version " KERNEL_VERSION_STRING - " (Build " KERNEL_BUILD_STRING ") [" __DATE__ " " __TIME__ "]\n" + " (Build " KERNEL_BUILD_STRING ", " __DATE__ ")\n" #if 0 "For technical information and description of the DOS-C operating system\n\ consult \"FreeDOS Kernel\" by Pat Villani, published by Miller\n\ diff --git a/kernel/init-mod.h b/kernel/init-mod.h index c7b3459c..21026745 100644 --- a/kernel/init-mod.h +++ b/kernel/init-mod.h @@ -158,6 +158,7 @@ unsigned ASMPASCAL read(int fd, void *buf, unsigned count); int ASMPASCAL open(const char *pathname, int flags); int ASMPASCAL close(int fd); int ASMPASCAL dup2(int oldfd, int newfd); +ULONG ASMPASCAL lseek(int fd, long position); seg ASMPASCAL allocmem(UWORD size); void ASMPASCAL init_PSPSet(seg psp_seg); int ASMPASCAL init_DosExec(int mode, exec_blk *, CStr); @@ -246,7 +247,7 @@ enum { ASK_ASK = 0x01, /* ?device= device?= */ extern UBYTE askCommand; -extern struct lol FAR *LoL; +extern struct lol FAR * const LoL; extern struct dhdr DOSTEXTFAR ASM blk_dev; /* Block device (Disk) driver */ diff --git a/kernel/inthndlr.c b/kernel/inthndlr.c index 752c4f03..f2d9f16b 100644 --- a/kernel/inthndlr.c +++ b/kernel/inthndlr.c @@ -411,13 +411,6 @@ VOID ASMCFUNC int21_service(iregs FAR * r) } /* Clear carry by default for these functions */ - /* see PATCH TE 5 jul 04 explanation at end */ - if (ErrorMode && lr.AH > 0x0c && lr.AH != 0x30 && lr.AH != 0x59) - { - ErrorMode = 0; - fnode[0].f_count = 0; /* don't panic - THEY ARE unused !! */ - fnode[1].f_count = 0; - } /* Check for Ctrl-Break */ if (break_ena || (lr.AH >= 1 && lr.AH <= 5) || (lr.AH >= 8 && lr.AH <= 0x0b)) @@ -616,14 +609,12 @@ VOID ASMCFUNC int21_service(iregs FAR * r) /* Get Drive Data */ case 0x1c: - { - BYTE FAR *p; - - p = FatGetDrvData(lr.DL, &lr.AX, &lr.CX, &lr.DX); - lr.DS = FP_SEG(p); - lr.BX = FP_OFF(p); - } + { + UBYTE FAR *p = FatGetDrvData(lr.DL, &lr.AL, &lr.CX, &lr.DX); + lr.DS = FP_SEG(p); + lr.BX = FP_OFF(p); break; + } /* Get default DPB */ /* case 0x1f: see case 0x32 */ @@ -669,9 +660,7 @@ VOID ASMCFUNC int21_service(iregs FAR * r) /* Parse File Name */ case 0x29: - rc = 0; - lr.SI = FcbParseFname(&rc, MK_FP(lr.DS, lr.SI), FP_ES_DI); - lr.AL = rc; + lr.SI = FcbParseFname(&lr.AL, MK_FP(lr.DS, lr.SI), FP_ES_DI); break; /* Get Date */ @@ -709,10 +698,8 @@ VOID ASMCFUNC int21_service(iregs FAR * r) case 0x30: lr.AL = os_setver_major; lr.AH = os_setver_minor; - lr.BH = OEM_ID; - lr.CH = REVISION_MAJOR; /* JPP */ - lr.CL = REVISION_MINOR; - lr.BL = REVISION_SEQ; + lr.BX = (OEM_ID << 8) | REVISION_SEQ; + lr.CX = 0; /* serial number must be 0 or buggy 32RTM thrashes stack! */ if (ReturnAnyDosVersionExpected) { @@ -801,7 +788,7 @@ VOID ASMCFUNC int21_service(iregs FAR * r) /* Dos Get Disk Free Space */ case 0x36: - DosGetFree(lr.DL, &lr.AX, &lr.BX, &lr.CX, &lr.DX); + lr.AX = DosGetFree(lr.DL, &lr.BX, &lr.CX, &lr.DX); break; /* Undocumented Get/Set Switchar */ @@ -900,19 +887,15 @@ VOID ASMCFUNC int21_service(iregs FAR * r) /* Dos Seek */ case 0x42: - if (lr.AL > 2) - goto error_invalid; - lrc = DosSeek(lr.BX, (LONG)((((ULONG) (lr.CX)) << 16) | lr.DX), lr.AL); - if (lrc == -1) - { - lrc = DE_INVLDHNDL; - } - else + { + sft FAR *s = get_sft(lr.BX); + if ((rc = _SftSeek(s, MK_ULONG(lr.CX, lr.DX), lr.AL)) >= SUCCESS) { - lr.DX = (UWORD)(lrc >> 16); - lrc = (UWORD) lrc; + lr.DX = hiword (s->sft_posit); + lr.AX = loword (s->sft_posit); } - goto long_check; + goto short_check; + } /* Get/Set File Attributes */ case 0x43: @@ -1003,6 +986,7 @@ VOID ASMCFUNC int21_service(iregs FAR * r) panic("after 4a: MCB chain corrupted"); goto error_exit; } + lr.AX = lr.ES; /* Undocumented MS-DOS behaviour expected by BRUN45! */ break; /* Load and Execute Program */ @@ -1242,7 +1226,7 @@ VOID ASMCFUNC int21_service(iregs FAR * r) break; case 0x5f: - if (lr.AL == 7 || lr.AL == 8) + if (inrange(UBYTE, lr.AL, 7, 8)) { if (lr.DL < lastdrive) { @@ -1660,6 +1644,9 @@ struct int2f12regs { */ VOID ASMCFUNC int2F_12_handler(struct int2f12regs r) { + COUNT rc; + long lrc; + if (r.AH == 0x4a) { size_t size = 0, offs = 0xffff; @@ -1760,11 +1747,14 @@ VOID ASMCFUNC int2F_12_handler(struct int2f12regs r) break; case 0x13: /* uppercase character */ + { /* for now, ASCII only because nls.c cannot handle DS!=SS */ - r.AL = r.callerARG1.b.l; - if (_islower(r.AL)) - r.AL -= (UBYTE)('a' - 'A'); + UBYTE ch = r.callerARG1.b.l; + if (_islower(ch)) + ch -= (UBYTE)('a' - 'A'); + r.AL = ch; break; + } case 0x16: /* get address of system file table entry - used by NET.EXE @@ -1869,18 +1859,47 @@ VOID ASMCFUNC int2F_12_handler(struct int2f12regs r) r.CX = fstrlen(MK_FP(r.DS, r.SI)) + 1; break; - case 0x2a: /* Set FastOpen but does nothing. */ + case 0x26: /* open file */ + r.FLAGS &= ~FLG_CARRY; + CritErrCode = SUCCESS; + lrc = DosOpen(MK_FP(r.DS, r.DX), O_LEGACY | O_OPEN | r.CL, 0); + goto long_check; + case 0x27: /* close file */ r.FLAGS &= ~FLG_CARRY; - break; + CritErrCode = SUCCESS; + rc = DosClose(r.BX); + goto short_check; + + case 0x28: /* move file pointer */ + /* + * RBIL says: "sets user stack frame pointer to dummy buffer, + * moves BP to AX, performs LSEEK, and restores frame pointer" + * We obviously don't do it like that. Does this do any harm?! --L.G. + */ + r.FLAGS &= ~FLG_CARRY; + CritErrCode = SUCCESS; + if (r.BP < 0x4200 || r.BP > 0x4202) + goto error_invalid; + { + sft FAR *s = get_sft(r.BX); + if ((rc = _SftSeek(s, MK_ULONG(r.CX, r.DX), r.BP & 0xff)) >= SUCCESS) + { + r.DX = hiword (s->sft_posit); + r.AX = loword (s->sft_posit); + } + } + goto short_check; + + case 0x29: /* read from file */ + r.FLAGS &= ~FLG_CARRY; + CritErrCode = SUCCESS; + lrc = DosRead(r.BX, r.CX, MK_FP(r.DS, r.DX)); + goto long_check; - /* 0x26-0x29 & 0x2B, internal functions necessary for NLSFUNC */ - case 0x26: /* Open File */ - case 0x27: /* Close File */ - case 0x28: /* Move File Pointer */ - case 0x29: /* Read From File */ - case 0x2B: /* IOctl */ - r.FLAGS |= FLG_CARRY; /* Not implemented yet! */ + case 0x2a: /* Set FastOpen but does nothing. */ + + r.FLAGS &= ~FLG_CARRY; break; case 0x2c: /* added by James Tabor For Zip Drives @@ -1897,6 +1916,19 @@ VOID ASMCFUNC int2F_12_handler(struct int2f12regs r) doesn't work!! */ break; + case 0x2f: + if (r.DX) + { + os_setver_major = r.DL; + os_setver_minor = r.DH; + } + else + { + os_setver_major = os_major; + os_setver_minor = os_minor; + } + break; + default: if (r.AL <= 0x31) { @@ -1906,6 +1938,25 @@ VOID ASMCFUNC int2F_12_handler(struct int2f12regs r) r.FLAGS |= FLG_CARRY; } } + return; +long_check: + if (lrc >= SUCCESS) + { + r.AX = (UWORD)lrc; + return; + } + rc = (int)lrc; +short_check: + if (rc < SUCCESS) + goto error_exit; + return; +error_invalid: + rc = DE_INVLDFUNC; +error_exit: + r.AX = -rc; + if (CritErrCode == SUCCESS) + CritErrCode = r.AX; /* Maybe set */ + r.FLAGS |= FLG_CARRY; } /* diff --git a/kernel/intr.asm b/kernel/intr.asm index 7318522d..1b966dac 100644 --- a/kernel/intr.asm +++ b/kernel/intr.asm @@ -245,6 +245,24 @@ DUP2: push ax ; ret address mov ah, 46h jmp short common_int21 + +; +; ULONG ASMPASCAL lseek(int fd, long position); +; + global LSEEK +LSEEK: + pop ax ; ret address + pop dx ; position low + pop cx ; position high + pop bx ; fd + push ax ; ret address + mov ax,4200h ; origin: start of file + int 21h + jnc seek_ret ; CF=1? + sbb ax,ax ; then dx:ax = -1, else unchanged + sbb dx,dx +seek_ret: + ret ; ; void ASMPASCAL init_PSPSet(seg psp_seg); diff --git a/kernel/ioctl.c b/kernel/ioctl.c index 63b56742..c5bcb1f1 100644 --- a/kernel/ioctl.c +++ b/kernel/ioctl.c @@ -92,8 +92,9 @@ COUNT DosDevIOctl(lregs * r) sft FAR *s; struct dhdr FAR *dev; + struct dpb FAR *dpbp; unsigned attr, flags; - UBYTE cmd; + UBYTE cmd, unit; switch (r->AL) { @@ -141,8 +142,6 @@ COUNT DosDevIOctl(lregs * r) case 0x0e: case 0x0f: case 0x11: - { - struct dpb FAR *dpbp; /* Line below previously returned the deviceheader at r->bl. But, DOS numbers its drives starting at 1, not 0. A=1, B=2, and so @@ -154,25 +153,23 @@ COUNT DosDevIOctl(lregs * r) #define NDN_HACK #ifdef NDN_HACK /* NDN feeds the actual ASCII drive letter to this function */ - UBYTE unit = (r->BL & 0x1f) - 1; + unit = (r->BL & 0x1f) - 1; #else - UBYTE unit = r->BL - 1; + unit = r->BL - 1; #endif - if (unit == 0xff) - unit = default_drive; - CharReqHdr.r_unit = unit; + if (unit == 0xff) + unit = default_drive; - if ((dpbp = get_dpb(unit)) == NULL) - { - if (r->AL != 0x09) - return DE_INVLDDRV; - attr = ATTR_REMOTE; - } - else - { - dev = dpbp->dpb_device; - attr = dev->dh_attr; - } + if ((dpbp = get_dpb(unit)) == NULL) + { + if (r->AL != 0x09) + return DE_INVLDDRV; + attr = ATTR_REMOTE; + } + else + { + dev = dpbp->dpb_device; + attr = dev->dh_attr; } } /* switch */ @@ -186,6 +183,8 @@ COUNT DosDevIOctl(lregs * r) { CharReqHdr.r_cat = r->CH; /* category (major) code */ CharReqHdr.r_fun = r->CL; /* function (minor) code */ + CharReqHdr.r_si = r->SI; /* contents of SI and DI */ + CharReqHdr.r_di = r->DI; CharReqHdr.r_io = MK_FP(r->DS, r->DX); /* parameter block */ } else @@ -194,6 +193,7 @@ COUNT DosDevIOctl(lregs * r) CharReqHdr.r_trans = MK_FP(r->DS, r->DX); } CharReqHdr.r_length = sizeof(request); + CharReqHdr.r_unit = dpbp->dpb_subunit; CharReqHdr.r_status = 0; switch (r->AL) @@ -256,7 +256,7 @@ COUNT DosDevIOctl(lregs * r) case 0x09: { - const struct cds FAR *cdsp = get_cds(CharReqHdr.r_unit); + const struct cds FAR *cdsp = get_cds(unit); if (cdsp == NULL) return DE_INVLDDRV; if (cdsp->cdsFlags & CDSSUBST) diff --git a/kernel/main.c b/kernel/main.c index 42628594..bd54324a 100644 --- a/kernel/main.c +++ b/kernel/main.c @@ -36,12 +36,12 @@ static BYTE *mainRcsId = "$Id$"; #endif +/* The Holy Copyright Message. Do NOT remove it or you'll be cursed forever! */ + static char copyright[] = - "(C) Copyright 1995-2004 Pasquale J. Villani and The FreeDOS Project.\n" - "All Rights Reserved. This is free software and comes with ABSOLUTELY NO\n" - "WARRANTY; you can redistribute it and/or modify it under the terms of the\n" - "GNU General Public License as published by the Free Software Foundation;\n" - "either version 2, or (at your option) any later version.\n"; +"Copyright 1995-2004 Pasquale J. Villani and The FreeDOS Project.\n" +"This free software has ABSOLUTELY NO WARRANTY and is licensed under\n" +"the GNU General Public License (http://www.gnu.org/licenses/gpl.html)\n\n"; struct _KernelConfig InitKernelConfig BSS_INIT({0}); @@ -67,7 +67,7 @@ __segment DosTextSeg = 0; #endif -struct lol FAR *LoL = &DATASTART; +struct lol FAR * const LoL = &DATASTART; void ASMCFUNC FreeDOSmain(void) { @@ -132,26 +132,6 @@ void ASMCFUNC FreeDOSmain(void) init_call_p_0(&Config); /* execute process 0 (the shell) */ } -/* - InitializeAllBPBs() - or MakeNortonDiskEditorHappy() - it has been determined, that FDOS's BPB tables are initialized, - only when used (like DIR H:). - at least one known utility (norton DE) seems to access them directly. - ok, so we access for all drives, that the stuff gets build -*/ -void InitializeAllBPBs(VOID) -{ - static char filename[] = "A:-@JUNK@-.TMP"; - int drive, fileno; - for (drive = 'C'; drive < 'A' + LoL->nblkdev; drive++) - { - filename[0] = drive; - if ((fileno = open(filename, O_RDONLY)) >= 0) - close(fileno); - } -} - STATIC void PSPInit(void) { psp _seg *p = MK_SEG_PTR(psp, DOS_PSP); @@ -267,6 +247,7 @@ STATIC void init_kernel(void) LoL->os_setver_major = LoL->os_major = MAJOR_RELEASE; LoL->os_setver_minor = LoL->os_minor = MINOR_RELEASE; + LoL->rev_number = REVISION_SEQ; /* move kernel to high conventional RAM, just below the init code */ #ifdef __WATCOMC__ @@ -320,8 +301,6 @@ STATIC void init_kernel(void) configDone(); - InitializeAllBPBs(); - DoInstall(); } @@ -652,34 +631,12 @@ static int EmulatedDriveStatus(int drive,char statusOnly) STATIC void CheckContinueBootFromHarddisk(void) { - char *bootedFrom = "Floppy/CD"; - - if (InitKernelConfig.BootHarddiskSeconds <= 0) + if (InitKernelConfig.BootHarddiskSeconds <= 0 /* feature disabled */ + || LoL->BootDrive >= 3 && EmulatedDriveStatus(0x80,1)) /* booted from HD */ return; - if (LoL->BootDrive >= 3) - { -#if 0 - if (EmulatedDriveStatus(0x80,1)) -#endif - /* already booted from HD */ - return; - } - else - { -#if 0 - if (EmulatedDriveStatus(0x00,1)) -#endif - bootedFrom = "Floppy"; - } - - printf("\n" - "\n" - "\n" - " Hit any key within %d seconds to continue booot from %s\n" - " Hit 'H' or wait %d seconds to boot from Harddisk\n", - InitKernelConfig.BootHarddiskSeconds, - bootedFrom, + printf("\n\nTo boot from hard disk, press 'H' or wait %d seconds\n" + "To boot from floppy/CD, press any other key NOW!\n", InitKernelConfig.BootHarddiskSeconds); if (GetBiosKey(InitKernelConfig.BootHarddiskSeconds)) diff --git a/kernel/makefile b/kernel/makefile index 39806a9f..db79239a 100644 --- a/kernel/makefile +++ b/kernel/makefile @@ -14,24 +14,20 @@ HDR=../hdr/ # files (only 9 directly accessible parameters). # Order of linking is important: first kernel.asm, last INIT code. - -OBJS1=kernel.obj entry.obj io.obj console.obj serial.obj printer.obj dsk.obj \ -sysclk.obj -OBJS2=asmsupt.obj execrh.obj nlssupt.obj procsupt.obj dosidle.obj int2f.obj \ -nls_hc.obj -OBJS3=apisupt.obj intr.obj irqstack.obj blockio.obj chario.obj systime.obj \ -error.obj -OBJS4=break.obj dosfns.obj fatdir.obj fatfs.obj fattab.obj fcbfns.obj \ -inthndlr.obj -OBJS5=ioctl.obj dosnames.obj memmgr.obj task.obj newstuff.obj nls.obj network.obj -OBJS6=prf.obj misc.obj strings.obj syspack.obj lfnapi.obj iasmsupt.obj -OBJS7=main.obj config.obj initoem.obj inithma.obj dyninit.obj iprf.obj \ -initdisk.obj initclk.obj +OBJS1=kernel.obj entry.obj intr.obj irqstack.obj apisupt.obj io.obj console.obj +OBJS2=printer.obj serial.obj dosidle.obj execrh.obj asmsupt.obj int2f.obj \ +nlssupt.obj +OBJS3=nls_hc.obj procsupt.obj dsk.obj error.obj blockio.obj chario.obj break.obj +OBJS4=fatfs.obj fatdir.obj fattab.obj dosfns.obj fcbfns.obj inthndlr.obj +OBJS5=ioctl.obj memmgr.obj task.obj newstuff.obj dosnames.obj nls.obj +OBJS6=prf.obj network.obj sysclk.obj lfnapi.obj systime.obj initclk.obj +OBJS7=initdisk.obj inithma.obj main.obj config.obj iprf.obj dyninit.obj \ +iasmsupt.obj OBJS=$(OBJS1) $(OBJS2) $(OBJS3) $(OBJS4) $(OBJS5) $(OBJS6) $(OBJS7) # Explicit Rules ####################################################### -all: ..\bin\$(TARGET).sys +all: ..\bin\$(TARGET).sys ..\bin\country.sys ..\bin\$(TARGET).sys: $(TARGET).lnk $(OBJS) $(LIBS) ..\utils\exeflat.exe $(LINK) @$(TARGET).lnk; @@ -39,6 +35,9 @@ all: ..\bin\$(TARGET).sys ..\utils\exeflat kernel.exe $*.sys $(LOADSEG) -S0x10 -S0x8B $(UPXOPT) copy $*.sys ..\bin\kernel.sys +..\bin\country.sys: country.asm + $(NASM) -o $*.sys country.asm + # XXX: This is a very ugly way of linking the kernel, forced upon us by the # inability of Turbo `make' 2.0 to perform command line redirection. --ror4 diff --git a/kernel/nls.c b/kernel/nls.c index 8e6f0c1b..768a5250 100644 --- a/kernel/nls.c +++ b/kernel/nls.c @@ -109,7 +109,7 @@ STATIC COUNT muxGo(int subfct, UWORD bp, UWORD cp, UWORD cntry, UWORD bufsize, /* * Call NLSFUNC to load the NLS package */ -COUNT muxLoadPkg(UWORD cp, UWORD cntry) +COUNT muxLoadPkg(int subfct, UWORD cp, UWORD cntry) { UWORD id; /* on stack, call_nls in int2f.asm takes care of this * if DS != SS */ @@ -128,8 +128,8 @@ COUNT muxLoadPkg(UWORD cp, UWORD cntry) NLSFUNC ID. If not NULL, call_nls will set *id = BX on return. Note: &id should be the pointer offset addressable via SS (SS:BP == &id) */ - if (muxGo(NLSFUNC_INSTALL_CHECK, 0, NLS_FREEDOS_NLSFUNC_VERSION, - 0, NLS_FREEDOS_NLSFUNC_ID, 0, (UWORD *)&id) != 0x14ff) + if (muxGo(0, 0, NLS_FREEDOS_NLSFUNC_VERSION, 0, NLS_FREEDOS_NLSFUNC_ID, 0, + (UWORD *)&id) != 0x14ff) return DE_FILENOTFND; /* No NLSFUNC --> no load */ if (id != NLS_FREEDOS_NLSFUNC_ID) /* FreeDOS NLSFUNC will return */ return DE_INVLDACC; /* This magic number */ @@ -137,7 +137,7 @@ COUNT muxLoadPkg(UWORD cp, UWORD cntry) /* OK, the correct NLSFUNC is available --> load pkg */ /* If cp == -1 on entry, NLSFUNC updates cp to the codepage loaded into memory. The system must then change to this one later */ - return muxGo(NLSFUNC_LOAD_PKG, 0, cp, cntry, 0, 0, 0); + return muxGo(subfct, 0, cp, cntry, 0, 0, 0); } STATIC int muxBufGo(int subfct, int bp, UWORD cp, UWORD cntry, @@ -372,16 +372,31 @@ STATIC COUNT nlsSetPackage(struct nlsPackage FAR * nls) return SUCCESS; } STATIC COUNT DosSetPackage(UWORD cp, UWORD cntry) +{ + /* Right now, we do not have codepage change support in kernel, so push + it through the mux in any case. */ + + return muxLoadPkg(NLSFUNC_LOAD_PKG2, cp, cntry); +} + +STATIC COUNT nlsLoadPackage(struct nlsPackage FAR * nls) +{ + + nlsInfo.actPkg = nls; + + return SUCCESS; +} +STATIC COUNT DosLoadPackage(UWORD cp, UWORD cntry) { struct nlsPackage FAR *nls; /* NLS package to use to return the info from */ /* nls := NLS package of cntry/codepage */ if ((nls = searchPackage(cp, cntry)) != NULL) /* OK the NLS pkg is loaded --> activate it */ - return nlsSetPackage(nls); + return nlsLoadPackage(nls); /* not loaded --> invoke NLSFUNC to load it */ - return muxLoadPkg(cp, cntry); + return muxLoadPkg(NLSFUNC_LOAD_PKG, cp, cntry); } STATIC void nlsUpMem(struct nlsPackage FAR * nls, VOID FAR * str, int len) @@ -564,7 +579,7 @@ COUNT DosGetCountryInformation(UWORD cntry, VOID FAR * buf) #ifndef DosSetCountry COUNT DosSetCountry(UWORD cntry) { - return DosSetPackage(NLS_DEFAULT, cntry); + return DosLoadPackage(NLS_DEFAULT, cntry); } #endif @@ -636,6 +651,7 @@ UWORD ASMCFUNC syscall_MUX14(DIRECT_IREGS) /* Does not pass buffer length */ return nlsGetData(nls, CL, MK_FP(ES, DI), 512); case NLSFUNC_LOAD_PKG: + return nlsLoadPackage(nls); case NLSFUNC_LOAD_PKG2: return nlsSetPackage(nls); case NLSFUNC_YESNO: diff --git a/kernel/proto.h b/kernel/proto.h index 8ed745a2..a2aebea4 100644 --- a/kernel/proto.h +++ b/kernel/proto.h @@ -77,11 +77,12 @@ long cooked_write(struct dhdr FAR **pdev, size_t n, char FAR *bp); sft FAR *get_sft(UCOUNT); /* dosfns.c */ -#define SEEK_SET 0 -#define SEEK_CUR 1 -#define SEEK_END 2 + +#define SEEK_SET 0u +#define SEEK_CUR 1u +#define SEEK_END 2u + const char FAR *get_root(const char FAR *); -BOOL check_break(void); UCOUNT GenericReadSft(sft far * sftp, UCOUNT n, void FAR * bp, COUNT * err, BOOL force_binary); COUNT SftSeek(int sft_idx, LONG new_pos, unsigned mode); @@ -91,7 +92,7 @@ void BinarySftIO(int sft_idx, void *bp, int mode); long DosRWSft(int sft_idx, size_t n, void FAR * bp, int mode); #define DosRead(hndl, n, bp) DosRWSft(get_sft_idx(hndl), n, bp, XFR_READ) #define DosWrite(hndl, n, bp) DosRWSft(get_sft_idx(hndl), n, bp, XFR_WRITE) -ULONG DosSeek(unsigned hndl, LONG new_pos, COUNT mode); +int _SftSeek(sft FAR*, LONG new_pos, unsigned mode); long DosOpen(char FAR * fname, unsigned flags, unsigned attrib); COUNT CloneHandle(unsigned hndl); long DosDup(unsigned Handle); @@ -100,8 +101,7 @@ long DosOpenSft(char FAR * fname, unsigned flags, unsigned attrib); COUNT DosClose(COUNT hndl); COUNT DosCloseSft(int sft_idx, BOOL commitonly); #define DosCommit(hndl) DosCloseSft(get_sft_idx(hndl), TRUE) -BOOL DosGetFree(UBYTE drive, UWORD * spc, UWORD * navc, - UWORD * bps, UWORD * nc); +UWORD DosGetFree(UBYTE drive, UWORD * navc, UWORD * bps, UWORD * nc); COUNT DosGetCuDir(UBYTE drive, BYTE FAR * s); COUNT DosChangeDir(BYTE FAR * s); COUNT DosFindFirst(UCOUNT attr, const char FAR * name); @@ -122,7 +122,8 @@ COUNT DosLockUnlock(COUNT hndl, LONG pos, LONG len, COUNT unlock); int idx_to_sft_(int SftIndex); sft FAR *idx_to_sft(int SftIndex); int get_sft_idx(UCOUNT hndl); -struct cds FAR *get_cds(unsigned dsk); +struct cds FAR *get_cds1(unsigned drv); +struct cds FAR *get_cds(unsigned drv); COUNT DosTruename(const char FAR * src, char FAR * dest); /*dosidle.asm */ @@ -212,9 +213,8 @@ int DosCharInput(VOID); VOID DosDirectConsoleIO(iregs FAR * r); VOID DosCharOutput(COUNT c); VOID DosDisplayOutput(COUNT c); -BYTE FAR *FatGetDrvData(UBYTE drive, UWORD * spc, UWORD * bps, - UWORD * nc); -UWORD FcbParseFname(int *wTestMode, const BYTE FAR *lpFileName, fcb FAR * lpFcb); +UBYTE FAR *FatGetDrvData(UBYTE drive, UBYTE * spc, UWORD * bps, UWORD * nc); +ofs_t FcbParseFname(UBYTE *wTestMode, const char FAR * lpFileName, fcb FAR * lpFcb); const BYTE FAR *ParseSkipWh(const BYTE FAR * lpFileName); BOOL TestCmnSeps(BYTE FAR * lpFileName); BOOL TestFieldSeps(BYTE FAR * lpFileName); diff --git a/kernel/task.c b/kernel/task.c index 4e578d19..454328c2 100644 --- a/kernel/task.c +++ b/kernel/task.c @@ -214,13 +214,6 @@ void child_psp(seg_t para, seg_t cur_psp, seg_t beyond) } } -struct cds FAR *get_cds1(unsigned drv) -{ - if (drv-- == 0) /* 0 = A:, 1 = B:, ... */ - drv = default_drive; - return get_cds(drv); -} - STATIC void makePSP(seg_t pspseg, seg_t envseg, size_t asize, const char FAR * path) { psp _seg *p = MK_SEG_PTR(psp, pspseg); diff --git a/sys/sys.c b/sys/sys.c index 5d301408..8f4e9e9e 100644 --- a/sys/sys.c +++ b/sys/sys.c @@ -455,7 +455,7 @@ int abswrite(int DosDrive, int nsects, int foo, void *diskReadPacket); modify [si di] \ value [ax]; -fat32readwrite(int DosDrive, void *diskReadPacket, unsigned intno); +int fat32readwrite(int DosDrive, void *diskReadPacket, unsigned intno); #pragma aux fat32readwrite = \ "mov ax, 0x7305" \ "mov cx, 0xffff" \ @@ -516,7 +516,7 @@ int2526readwrite(DosDrive, diskReadPacket, 0x26) #endif -fat32readwrite(int DosDrive, void *diskReadPacket, unsigned intno) +int fat32readwrite(int DosDrive, void *diskReadPacket, unsigned intno) { union REGS regs; diff --git a/utils/exeflat.c b/utils/exeflat.c index b24404ab..a24b23ec 100644 --- a/utils/exeflat.c +++ b/utils/exeflat.c @@ -191,43 +191,46 @@ int main(int argc, char **argv) return 1; } } - fseek(src, header.exRelocTable, SEEK_SET); - reloc = malloc(header.exRelocItems * sizeof(farptr)); - if (reloc == NULL) + if (header.exRelocTable && header.exRelocItems) { - printf("Allocation error\n"); - return 1; - } - if (fread(reloc, sizeof(farptr), header.exRelocItems, src) != - header.exRelocItems) - { - printf("Source file read error\n"); - return 1; - } - fclose(src); - qsort(reloc, header.exRelocItems, sizeof(reloc[0]), compReloc); - for (i = 0; i < header.exRelocItems; i++) - { - ULONG spot = ((ULONG) reloc[i].seg << 4) + reloc[i].off; - UBYTE *spot0 = &buffers[(size_t)(spot / BUFSIZE)][(size_t)(spot % BUFSIZE)]; - UBYTE *spot1 = &buffers[(size_t)((spot + 1) / BUFSIZE)][(size_t)((spot + 1) % BUFSIZE)]; - UWORD segment = ((UWORD) * spot1 << 8) + *spot0; + fseek(src, header.exRelocTable, SEEK_SET); + reloc = malloc(header.exRelocItems * sizeof(farptr)); + if (reloc == NULL) + { + printf("Allocation error\n"); + return 1; + } + if (fread(reloc, sizeof(farptr), header.exRelocItems, src) != + header.exRelocItems) + { + printf("Source file read error\n"); + return 1; + } + fclose(src); + qsort(reloc, header.exRelocItems, sizeof(reloc[0]), compReloc); + for (i = 0; i < header.exRelocItems; i++) + { + ULONG spot = ((ULONG) reloc[i].seg << 4) + reloc[i].off; + UBYTE *spot0 = &buffers[(size_t)(spot / BUFSIZE)][(size_t)(spot % BUFSIZE)]; + UBYTE *spot1 = &buffers[(size_t)((spot + 1) / BUFSIZE)][(size_t)((spot + 1) % BUFSIZE)]; + UWORD segment = ((UWORD) * spot1 << 8) + *spot0; - for (j = 0; j < silentcount; j++) - if (segment == silentSegments[j]) - { - silentdone++; - goto dontPrint; - } - - printf("relocation at 0x%04x:0x%04x ->%04x\n", reloc[i].seg, - reloc[i].off, segment); - - dontPrint: - - segment += start_seg; - *spot0 = segment & 0xff; - *spot1 = segment >> 8; + for (j = 0; j < silentcount; j++) + if (segment == silentSegments[j]) + { + silentdone++; + goto dontPrint; + } + + printf("relocation at 0x%04x:0x%04x ->%04x\n", reloc[i].seg, + reloc[i].off, segment); + + dontPrint: + + segment += start_seg; + *spot0 = segment & 0xff; + *spot1 = segment >> 8; + } } if (UPX) @@ -292,25 +295,28 @@ int main(int argc, char **argv) static char trailer[] = { 0x0E, /* 0 push cs */ 0x1F, /* 1 pop ds ; =0x60 */ - 0xBF,0x5E,0x00, /* 2 mov di,start_seg-2 */ - 0x8E,0xC7, /* 5 mov es,di */ - 0xFC, /* 7 cld */ - 0x33,0xFF, /* 8 xor di,di */ - 0x93, /* 10 xchg ax,bx ; mov al,bl */ - 0xAA, /* 11 stosb ; mov [es:0],al */ - 0x8B,0xF7, /* 12 mov si,di */ - 0xB9,0x00,0x00, /* 14 mov cx,offset trailer */ - 0xF3,0xA4, /* 17 rep movsb */ - 0xBF,0x00,0x00, /* 19 mov di,... */ - 0x8E,0xD7, /* 22 mov ss,di */ - 0xBC,0x00,0x00, /* 24 mov sp,... */ - 0x33,0xFF, /* 27 xor di,di */ - 0xFF,0xE7, /* 29 jmp di ; jmp 0 */ + 0x8C,0xDF, /* 2 mov di,ds */ + 0x4F, /* 4 dec di */ + 0x4F, /* 5 dec di */ + 0x8E,0xC7, /* 6 mov es,di */ + 0xFC, /* 8 cld */ + 0x33,0xFF, /* 9 xor di,di */ + 0x93, /* 11 xchg ax,bx ; mov al,bl */ + 0xAA, /* 12 stosb ; mov [es:0],al */ + 0x8B,0xF7, /* 13 mov si,di */ + 0xB9,0x00,0x00, /* 15 mov cx,offset trailer */ + 0xF3,0xA4, /* 18 rep movsb */ + 0x1E, /* 20 push ds */ + 0x58, /* 21 pop ax */ + 0x05,0x00,0x00, /* 22 add ax,... */ + 0x8E,0xD0, /* 25 mov ss,ax */ + 0xBC,0x00,0x00, /* 27 mov sp,... */ + 0x31,0xC0, /* 30 xor ax,ax */ + 0xFF,0xE0, /* 32 jmp ax ; jmp 0 */ }; - *(short *)&trailer[3] = start_seg - 2; - *(short *)&trailer[15] = (short)size + 0x20; - *(short *)&trailer[20] = start_seg + header.exInitSS; - *(short *)&trailer[25] = header.exInitSP; + *(short *)&trailer[16] = (short)size + 0x20; + *(short *)&trailer[23] = header.exInitSS; + *(short *)&trailer[28] = header.exInitSP; fwrite(trailer, 1, sizeof trailer, dest); } fclose(dest); diff --git a/utils/makefile b/utils/makefile index 5a26e97a..f29c6aa1 100644 --- a/utils/makefile +++ b/utils/makefile @@ -1,6 +1,7 @@ !include "../mkfiles/generic.mak" DEPENDS=$(DEPENDS) *.cfg +CFLAGSC=$(CFLAGSC) -DEXEFLAT ######################################################################## From dfdf72645bc7f05dc8dbffa009ca45cf3f54fdf6 Mon Sep 17 00:00:00 2001 From: Luchezar Georgiev Date: Sun, 5 Sep 2004 08:58:44 +0000 Subject: [PATCH 557/671] fatfs.c: - zero creation/access stamp on directory entry write as MS-DOS 7.10 - prevent removal or renaming of the current directory of that drive - optimisation and clean-up git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/branches/UNSTABLE@1024 6ac86273-5f31-0410-b378-82cca8765d1b --- docs/history.txt | 4 + kernel/asmsupt.asm | 8 +- kernel/fatfs.c | 198 ++++++++++++++------------------------------- kernel/proto.h | 3 +- 4 files changed, 67 insertions(+), 146 deletions(-) diff --git a/docs/history.txt b/docs/history.txt index c7c5d7ba..bd521637 100644 --- a/docs/history.txt +++ b/docs/history.txt @@ -313,6 +313,10 @@ * country.asm / country.sys support now replaces hard-coded data * 8 countries added to country.asm: GR, RO, AT, KR, TR, IN, M.East, IL * dyninit.c: unused function DynFree() commented out + * fatfs.c: + - zero creation/access stamp on directory entry write as MS-DOS 7.10 + - prevent removal or renaming of the current directory of that drive + - optimisation and clean-up * fattab.c: ISFAT32 function removed (now macro), "wasfree" optimised * globals.h: __TIME__ removed - no two kernels released on same day * intr.asm: lseek() added (necessary for COUNTRY.SYS processing) diff --git a/kernel/asmsupt.asm b/kernel/asmsupt.asm index 92286b3f..ab53290d 100644 --- a/kernel/asmsupt.asm +++ b/kernel/asmsupt.asm @@ -416,13 +416,9 @@ FMEMCHR: mov ax, di jmp short strchr_found1 -%endif - ;********************************************************************** -%if 0 -nix pascal - still untested - global _fstrcmp -_fstrcmp: + global FSTRCMP +FSTRCMP: call pascal_setup ; Get the source pointer, ss diff --git a/kernel/fatfs.c b/kernel/fatfs.c index 764666ab..b4ec5ada 100644 --- a/kernel/fatfs.c +++ b/kernel/fatfs.c @@ -38,7 +38,6 @@ BYTE *RcsId = "$Id$"; /* function prototypes */ /* */ f_node_ptr xlt_fd(COUNT); -COUNT xlt_fnp(f_node_ptr); STATIC void save_far_f_node(f_node_ptr fnp); STATIC f_node_ptr get_near_f_node(void); STATIC f_node_ptr split_path(char *, char *); @@ -51,19 +50,13 @@ STATIC int is_same_file(f_node_ptr fnp1, f_node_ptr fnp2); STATIC void copy_file_changes(f_node_ptr src, f_node_ptr dst); BOOL find_free(f_node_ptr); STATIC int alloc_find_free(f_node_ptr fnp, char *path, char *fcbname); -VOID wipe_out(f_node_ptr); +STATIC VOID wipe_out(f_node_ptr); CLUSTER extend(f_node_ptr); COUNT extend_dir(f_node_ptr); CLUSTER first_fat(f_node_ptr); COUNT map_cluster(f_node_ptr, COUNT); STATIC VOID shrink_file(f_node_ptr fnp); -/* FAT time notation in the form of hhhh hmmm mmmd dddd (d = double second) */ -STATIC time time_encode(struct dostime *t) -{ - return (t->hour << 11) | (t->minute << 5) | (t->second >> 1); -} - #ifdef WITHFAT32 CLUSTER getdstart(struct dpb FAR *dpbp, struct dirent *dentry) { @@ -107,27 +100,19 @@ struct dpb FAR *get_dpb(COUNT dsk) return cdsp->cdsDpb; } -/* initialize all direntry fields except for the name */ +/* initialize directory entry (creation/access stamps 0 as per MS-DOS 7.10) */ STATIC void init_direntry(struct dirent *dentry, unsigned attrib, - CLUSTER cluster) + CLUSTER cluster, char *name) { - struct dostime dt; - - dentry->dir_size = 0l; + memset(dentry, 0, sizeof(struct dirent)); + memcpy(dentry->dir_name, name, FNAME_SIZE + FEXT_SIZE); #ifdef WITHFAT32 dentry->dir_start_high = (UWORD)(cluster >> 16); -#else - dentry->dir_start_high = 0; #endif dentry->dir_start = (UWORD)cluster; - dentry->dir_attrib = attrib; - dentry->dir_case = 0; - DosGetTime(&dt); - dentry->dir_crtimems = dt.hundredth; - if (dt.second & 1) - dentry->dir_crtimems += 100; - dentry->dir_time = dentry->dir_crtime = time_encode(&dt); - dentry->dir_date = dentry->dir_crdate = dentry->dir_accdate = dos_getdate(); + dentry->dir_attrib = (UBYTE)attrib; + dentry->dir_time = dos_gettime(); + dentry->dir_date = dos_getdate(); } /************************************************************************/ @@ -154,7 +139,7 @@ long dos_open(char *path, unsigned flags, unsigned attrib) if ((flags & O_ACCMODE) > 2) return DE_INVLDACC; - /* first split the passed dir into comopnents (i.e. - path to */ + /* next, split the passed dir into components (i.e. - path to */ /* new directory and name of new directory. */ if ((fnp = split_path(path, fcbname)) == NULL) return DE_PATHNOTFND; @@ -206,9 +191,6 @@ long dos_open(char *path, unsigned flags, unsigned attrib) int ret = alloc_find_free(fnp, path, fcbname); if (ret != SUCCESS) return ret; - - /* put the fnode's name into the directory. */ - memcpy(fnp->f_dir.dir_name, fcbname, FNAME_SIZE + FEXT_SIZE); status = S_CREATED; } else @@ -225,7 +207,7 @@ long dos_open(char *path, unsigned flags, unsigned attrib) if (status != S_OPENED) { - init_direntry(&fnp->f_dir, attrib, FREE); + init_direntry(&fnp->f_dir, attrib, FREE, fcbname); fnp->f_flags = F_DMOD | F_DDIR; if (!dir_write(fnp)) { @@ -475,7 +457,7 @@ STATIC void merge_file_changes(f_node_ptr fnp, int collect) f_node which refers to this file. */ if (fnp2->f_mode != RDONLY) { - copy_file_changes(fnp2, fnp); + memcpy(&fnp->f_dir, &fnp2->f_dir, sizeof(struct dirent)); break; } } @@ -484,7 +466,7 @@ STATIC void merge_file_changes(f_node_ptr fnp, int collect) /* We just made changes to this file, so we are distributing these changes to the other f_nodes which refer to this file. */ - copy_file_changes(fnp, fnp2); + memcpy(&fnp2->f_dir, &fnp->f_dir, sizeof(struct dirent)); fmemcpy(&f_nodes[i], fnp2, sizeof(*fnp2)); } } @@ -506,18 +488,6 @@ STATIC int is_same_file(f_node_ptr fnp1, f_node_ptr fnp2) && (fnp1->f_dpb == fnp2->f_dpb); } - /* /// Added - Ron Cemer */ -STATIC void copy_file_changes(f_node_ptr src, f_node_ptr dst) -{ - dst->f_dir.dir_start = src->f_dir.dir_start; -#ifdef WITHFAT32 - dst->f_dir.dir_start_high = src->f_dir.dir_start_high; -#endif - dst->f_dir.dir_size = src->f_dir.dir_size; - dst->f_dir.dir_date = src->f_dir.dir_date; - dst->f_dir.dir_time = src->f_dir.dir_time; -} - STATIC COUNT delete_dir_entry(f_node_ptr fnp) { COUNT rc; @@ -584,38 +554,28 @@ COUNT dos_rmdir(BYTE * path) BOOL found; char fcbname[FNAME_SIZE + FEXT_SIZE]; - /* first split the passed dir into comopnents (i.e. - */ + /* prevent removal of the current directory of that drive */ + register struct cds FAR *cdsp = get_cds(path[0] - 'A'); + if (!fstrcmp(path, cdsp->cdsCurrentPath)) + return DE_RMVCUDIR; + + /* next, split the passed dir into components (i.e. - */ /* path to new directory and name of new directory */ if ((fnp = split_path(path, fcbname)) == NULL) { return DE_PATHNOTFND; } - /* Check that we're not trying to remove the root! */ - if ((path[0] == '\\') && (path[1] == NULL)) - { - dir_close(fnp); - return DE_ACCESS; - } - /* Check that we don't have a duplicate name, so if we */ /* find one, it's an error. */ if (find_fname(fnp, fcbname, D_ALL)) { - /* The only permissable attribute is directory, */ - /* check for any other bit set. If it is, give */ - /* an access error. */ - /* if (fnp->f_dir.dir_attrib & ~D_DIR) */ - - /* directories may have attributes, too. at least my WinNT disk - has many 'archive' directories - we still don't allow RDONLY directories to be deleted TE */ - -/* if (fnp->f_dir.dir_attrib & ~(D_DIR |D_HIDDEN|D_ARCHIVE|D_SYSTEM)) + /* Check if it's really a directory */ + if (!(fnp->f_dir.dir_attrib & D_DIR)) { dir_close(fnp); return DE_ACCESS; - } */ + } /* Check that the directory is empty. Only the */ /* "." and ".." are permissable. */ @@ -628,7 +588,7 @@ COUNT dos_rmdir(BYTE * path) } dir_read(fnp1); - if (fnp1->f_dir.dir_name[0] != '.') + if (fnp1->f_dir.dir_name[0] != '.' || fnp1->f_dir.dir_name[1] != ' ') { dir_close(fnp); return DE_ACCESS; @@ -636,7 +596,7 @@ COUNT dos_rmdir(BYTE * path) fnp1->f_diroff++; dir_read(fnp1); - if (fnp1->f_dir.dir_name[0] != '.') + if (fnp1->f_dir.dir_name[0] != '.' || fnp1->f_dir.dir_name[1] != '.') { dir_close(fnp); return DE_ACCESS; @@ -683,6 +643,11 @@ COUNT dos_rename(BYTE * path1, BYTE * path2, int attrib) COUNT ret; char fcbname[FNAME_SIZE + FEXT_SIZE]; + /* prevent renaming of the current directory of that drive */ + register struct cds FAR *cdsp = get_cds(path1[0] - 'A'); + if (!fstrcmp(path1, cdsp->cdsCurrentPath)) + return DE_RMVCUDIR; + /* first split the passed target into compnents (i.e. - path to */ /* new file name and name of new file name */ if ((fnp2 = split_path(path2, fcbname)) == NULL) @@ -723,19 +688,11 @@ COUNT dos_rename(BYTE * path1, BYTE * path2, int attrib) if ((ret = remove_lfn_entries(fnp1)) < 0) return ret; + memcpy(&fnp2->f_dir, &fnp1->f_dir, sizeof(struct dirent)); + /* put the fnode's name into the directory. */ memcpy(fnp2->f_dir.dir_name, fcbname, FNAME_SIZE + FEXT_SIZE); - /* Set the fnode to the desired mode */ - fnp2->f_dir.dir_size = fnp1->f_dir.dir_size; - fnp2->f_dir.dir_start = fnp1->f_dir.dir_start; -#ifdef WITHFAT32 - fnp2->f_dir.dir_start_high = fnp1->f_dir.dir_start_high; -#endif - fnp2->f_dir.dir_attrib = fnp1->f_dir.dir_attrib; - fnp2->f_dir.dir_time = fnp1->f_dir.dir_time; - fnp2->f_dir.dir_date = fnp1->f_dir.dir_date; - /* The directory has been modified, so set the bit before */ /* closing it, allowing it to be updated. */ fnp1->f_flags = fnp2->f_flags = F_DMOD | F_DDIR; @@ -798,11 +755,9 @@ STATIC VOID wipe_out_clusters(struct dpb FAR * dpbp, CLUSTER st) /* */ STATIC VOID wipe_out(f_node_ptr fnp) { - /* if already free or not valid file, just exit */ - if ((fnp == NULL) || checkdstart(fnp->f_dpb, &fnp->f_dir, FREE)) - return; - - wipe_out_clusters(fnp->f_dpb, getdstart(fnp->f_dpb, &fnp->f_dir)); + /* if not already free and valid file, do it */ + if (fnp && !checkdstart(fnp->f_dpb, &fnp->f_dir, FREE)) + wipe_out_clusters(fnp->f_dpb, getdstart(fnp->f_dpb, &fnp->f_dir)); } STATIC BOOL find_free(f_node_ptr fnp) @@ -863,7 +818,8 @@ date dos_getdate(void) /* First - get the system date set by either the user */ /* on start-up or the CMOS clock */ DosGetDate(&dd); - return DT_ENCODE(dd.month, dd.monthday, dd.year - EPOCH_YEAR); + /* Convert to FAT date format: yyyy yyym mmmd dddd (yyyyyyy=year-1980) */ + return ((dd.year - 1980) << 9) | (dd.month << 5) | dd.monthday; } /* */ @@ -876,7 +832,8 @@ time dos_gettime(void) /* First - get the system time set by either the user */ /* on start-up or the CMOS clock */ DosGetTime(&dt); - return time_encode(&dt); + /* Convert to FAT time format: hhhh hmmm mmmd dddd (d = double second) */ + return (dt.hour << 11) | (dt.minute << 5) | (dt.second >> 1); } /* */ @@ -1105,13 +1062,10 @@ COUNT dos_mkdir(BYTE * dir) return DE_HNDLDSKFULL; } - /* put the fnode's name into the directory. */ - memcpy(fnp->f_dir.dir_name, fcbname, FNAME_SIZE + FEXT_SIZE); - /* Set the fnode to the desired mode */ fnp->f_mode = WRONLY; - init_direntry(&fnp->f_dir, D_DIR, free_fat); + init_direntry(&fnp->f_dir, D_DIR, free_fat, fcbname); fnp->f_flags = F_DMOD | F_DDIR; @@ -1135,9 +1089,7 @@ COUNT dos_mkdir(BYTE * dir) } /* Create the "." entry */ - DirEntBuffer.dir_name[0] = '.'; - memset(DirEntBuffer.dir_name + 1, ' ', FNAME_SIZE + FEXT_SIZE - 1); - init_direntry(&DirEntBuffer, D_DIR, free_fat); + init_direntry(&DirEntBuffer, D_DIR, free_fat, ". "); /* And put it out */ putdirent(&DirEntBuffer, bp->b_buffer); @@ -1407,17 +1359,8 @@ STATIC COUNT dos_extend(f_node_ptr fnp) (UWORD) count : secsize - boff; /* get a buffer to store the block in */ - if ((boff == 0) && (xfr_cnt == secsize)) - { - bp = getblockOver(clus2phys(fnp->f_cluster, fnp->f_dpb) + - sector, fnp->f_dpb->dpb_unit); - - } - else - { - bp = getblock(clus2phys(fnp->f_cluster, fnp->f_dpb) + sector, - fnp->f_dpb->dpb_unit); - } + bp = getblk(clus2phys(fnp->f_cluster, fnp->f_dpb) + sector, + fnp->f_dpb->dpb_unit, boff == 0 && xfr_cnt == secsize); if (bp == NULL) { return DE_BLKINVLD; @@ -1646,38 +1589,31 @@ long rwblock(COUNT fd, VOID FAR * buffer, UCOUNT count, int mode) UCOUNT sectors_to_xfer, sectors_wanted; startoffset = fnp->f_offset; - sectors_wanted = to_xfer; + sectors_wanted = (UCOUNT)(fnp->f_dir.dir_size - fnp->f_offset); /* avoid EOF problems */ - if (mode == XFR_READ && to_xfer > fnp->f_dir.dir_size - fnp->f_offset) - sectors_wanted = (UCOUNT)(fnp->f_dir.dir_size - fnp->f_offset); - + if (mode != XFR_READ || to_xfer <= sectors_wanted) + sectors_wanted = to_xfer; sectors_wanted /= secsize; if (sectors_wanted == 0) goto normal_xfer; - sectors_to_xfer = fnp->f_dpb->dpb_clsmask + 1 - sector; - - sectors_to_xfer = min(sectors_to_xfer, sectors_wanted); + for (sectors_to_xfer = -sector; ; ) + { + sectors_to_xfer += fnp->f_dpb->dpb_clsmask + 1; + sectors_to_xfer = min(sectors_to_xfer, sectors_wanted); + fnp->f_offset = startoffset + sectors_to_xfer * secsize; - fnp->f_offset += sectors_to_xfer * secsize; + if (sectors_to_xfer >= sectors_wanted) + break; - while (sectors_to_xfer < sectors_wanted) - { if (map_cluster(fnp, mode) != SUCCESS) break; if (clus2phys(fnp->f_cluster, fnp->f_dpb) != currentblock + sectors_to_xfer) break; - - sectors_to_xfer += fnp->f_dpb->dpb_clsmask + 1; - - sectors_to_xfer = min(sectors_to_xfer, sectors_wanted); - - fnp->f_offset = startoffset + sectors_to_xfer * secsize; - } xfr_cnt = sectors_to_xfer * secsize; @@ -1797,17 +1733,17 @@ LONG dos_lseek(COUNT fd, LONG foffset, COUNT origin) switch (origin) { /* offset from beginning of file */ - case 0: + case SEEK_SET: fnp->f_offset = (ULONG) foffset; break; /* offset from current location */ - case 1: + case SEEK_CUR: fnp->f_offset += foffset; break; /* offset from eof */ - case 2: + case SEEK_END: fnp->f_offset = fnp->f_dir.dir_size + foffset; break; @@ -1885,20 +1821,9 @@ int dos_cd(char * PathName) f_node_ptr get_near_f_node(void) { f_node_ptr fnp = fnode; - - if (fnp->f_count == 0) - fnp->f_count++; - else - { - fnp++; - if (fnp->f_count == 0) - fnp->f_count++; - else - { - fnp = (f_node_ptr) 0; - panic("more than two near fnodes requested at the same time!\n"); - } - } + if (fnp->f_count && (++fnp)->f_count) + panic("more than two near fnodes requested at the same time!\n"); + fnp->f_count++; return fnp; } @@ -1986,6 +1911,7 @@ COUNT dos_setfattr(BYTE * name, UWORD attrp) /* set attributes that user requested */ fnp->f_dir.dir_attrib |= attrp; /* JPP */ fnp->f_flags |= F_DMOD | F_DDATE; + merge_file_changes(fnp, FALSE); save_far_f_node(fnp); dos_close(fd); return SUCCESS; @@ -2135,7 +2061,7 @@ COUNT media_check(REG struct dpb FAR * dpbp) /* If it definitely changed, don't know (falls through) */ /* or has been changed, rebuild the bpb. */ - case M_CHANGED: + /* case M_CHANGED: */ default: setinvld(dpbp->dpb_unit); ret = rqblockio(C_BLDBPB, dpbp); @@ -2152,12 +2078,6 @@ COUNT media_check(REG struct dpb FAR * dpbp) } } -/* translate the f_node pointer into an fd */ -COUNT xlt_fnp(f_node_ptr fnp) -{ - return fnode_fd[fnp - fnode]; -} - /* allocate a near fnode and copy the far fd fnode to it */ f_node_ptr xlt_fd(int fd) { diff --git a/kernel/proto.h b/kernel/proto.h index a2aebea4..700c4a06 100644 --- a/kernel/proto.h +++ b/kernel/proto.h @@ -196,7 +196,8 @@ COUNT dos_getfattr(BYTE * name); COUNT dos_setfattr(BYTE * name, UWORD attrp); COUNT media_check(REG struct dpb FAR * dpbp); f_node_ptr xlt_fd(COUNT fd); -COUNT xlt_fnp(f_node_ptr fnp); +/* translate the f_node pointer into an fd */ +#define xlt_fnp(fnp) (fnode_fd[(fnp) - fnode]) struct dhdr FAR * select_unit(COUNT drive); /* fattab.c */ From 463535c87da693c647faa3bb6f010bf14fa9a836 Mon Sep 17 00:00:00 2001 From: Kenneth J Davis Date: Mon, 6 Sep 2004 09:41:29 +0000 Subject: [PATCH 558/671] limited support for DR-DOS enhancement project or any OEM DOS using IBMBIO/IBMDOS git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/branches/UNSTABLE@1025 6ac86273-5f31-0410-b378-82cca8765d1b --- sys/sys.c | 174 ++++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 123 insertions(+), 51 deletions(-) diff --git a/sys/sys.c b/sys/sys.c index 8f4e9e9e..e398c739 100644 --- a/sys/sys.c +++ b/sys/sys.c @@ -29,7 +29,7 @@ #define DEBUG /* #define DDEBUG */ -#define SYS_VERSION "v3.3" +#define SYS_VERSION "v3.4" #include #include @@ -161,7 +161,8 @@ BYTE pgm[] = "SYS"; void put_boot(int, char *, char *, int, int); BOOL check_space(COUNT, ULONG); -BOOL copy(COUNT drive, BYTE * srcPath, BYTE * rootPath, BYTE * file); +BOOL get_full_path(BYTE * srcPath, BYTE * rootPath, BYTE * filename, BYTE *source); +BOOL copy(BYTE *source, COUNT drive, BYTE * filename); #define SEC_SIZE 512 #define COPY_SIZE 0x7e00 @@ -240,6 +241,19 @@ struct VerifyBootSectorSize { int FDKrnConfigMain(int argc, char **argv); +/* FreeDOS sys, we default to our kernel and load segment, but + if not found (or explicitly given) support OEM DOS variants + (such as DR-DOS or a FreeDOS kernel mimicing other DOSes). + PC-DOS requires particular steps from the boot loader, which + we do not currently fullfill, so it will not boot and MS-DOS + uses different names, so it also will not work. +*/ +#define FDKERNEL "KERNEL.SYS" +#define OEMKERNEL "IBMBIO.COM" +#define OEMDOS "IBMDOS.COM" +#define FDLOADSEG 0x60 +#define OEMLOADSEG 0x70 + int main(int argc, char **argv) { COUNT drive; /* destination drive */ @@ -249,12 +263,14 @@ int main(int argc, char **argv) unsigned srcDrive; /* source drive */ BYTE srcPath[SYS_MAXPATH]; /* user specified source drive and/or path */ BYTE rootPath[4]; /* alternate source path to try if not '\0' */ + BYTE srcFile[SYS_MAXPATH]; /* full path+name of [kernel] file to copy */ WORD slen; int argno = 0; int bootonly = 0; int both = 0; - char *kernel_name = "KERNEL.SYS"; - int load_segment = 0x60; + char *kernel_name = FDKERNEL; + int load_segment = FDLOADSEG; + int altkern = 0; /* use OEM kernel values instead of FD ones */ printf("FreeDOS System Installer " SYS_VERSION ", " __DATE__ "\n\n"); @@ -274,24 +290,37 @@ int main(int argc, char **argv) { srcarg = argno; } - else if (argp[0] == '/' && toupper(argp[1]) == 'K' && argno + 1 < argc) - { - argno++; - kernel_name = argv[argno]; - } - else if (argp[0] == '/' && toupper(argp[1]) == 'L' && argno + 1 < argc) - { - argno++; - load_segment = (int)strtol(argv[argno], NULL, 16); - } - else if (memicmp(argp, "BOOTONLY", 8) == 0 && !bootonly) - { - bootonly = 1; - } else if (memicmp(argp, "BOTH", 4) == 0 && !both) { both = 1; } + else if (argp[0] == '/') /* optional switch */ + { + argp++; /* skip past the '/' character */ + + if (memicmp(argp, "OEM", 3) == 0) + { + altkern = 1; /* kernel is split into 2 files and update BS name */ + kernel_name = OEMKERNEL; + load_segment = OEMLOADSEG; + } + else if (memicmp(argp, "BOOTONLY", 8) == 0) + { + bootonly = 1; + } + else if (argno + 1 < argc) /* two part options, /SWITCH VALUE */ + { + argno++; + if (toupper(*argp) == 'K') /* set Kernel name */ + { + kernel_name = argv[argno]; + } + else if (toupper(*argp) == 'L') /* set Load segment */ + { + load_segment = (int)strtol(argv[argno], NULL, 16); + } + } + } else if (drivearg != argno) { if (bsFile == NULL) @@ -304,18 +333,20 @@ int main(int argc, char **argv) break; } } - } + } /* for() */ if (drivearg == 0) { printf( - "Usage: %s [source] drive: [bootsect [BOTH]] [BOOTONLY] [/K name] [/L segm]\n" + "Usage: \n" + "%s [source] drive: [bootsect [BOTH]] [/BOOTONLY] [/OEM] [/K name] [/L segm]\n" " source = A:,B:,C:\\KERNEL\\BIN\\,etc., or current directory if not given\n" " drive = A,B,etc.\n" " bootsect = name of 512-byte boot sector file image for drive:\n" " to write to *instead* of real boot sector\n" " BOTH : write to *both* the real boot sector and the image file\n" - " BOOTONLY : do *not* copy kernel / shell, only update boot sector or image\n" + " /BOOTONLY: do *not* copy kernel / shell, only update boot sector or image\n" + " /OEM : indicates kernel is IBMIO.SYS/IBMDOS.SYS loaded at 0x70\n" " /K name : name of kernel to use instead of KERNEL.SYS\n" " /L segm : hex load segment to use instead of 60\n" "%s CONFIG /help\n", pgm, pgm); @@ -368,33 +399,65 @@ int main(int argc, char **argv) else sprintf(rootPath, "%c:\\", 'A' + srcDrive); + + /* unless we are only setting boot sector, verify kernel file exists */ + if (!bootonly) + { + /* if FDKERNEL not found and an explicit kernel name was not specified, + then see if OEM kernel available and switch to it instead. */ + if (!get_full_path(srcPath, rootPath, kernel_name, srcFile) && (kernel_name == FDKERNEL)) + { + if (!get_full_path(srcPath, rootPath, OEMKERNEL, srcFile)) + { + printf("\n%s: failed to find kernel file %s\n", pgm, kernel_name); + exit(1); + } + else /* else OEM kernel found, so switch modes */ + { + altkern = 1; + kernel_name = OEMKERNEL; + load_segment = OEMLOADSEG; + } + } + } + printf("Processing boot sector...\n"); put_boot(drive, bsFile, kernel_name, load_segment, both); if (!bootonly) { - printf("\nCopying %s...\n", kernel_name); - if (!copy(drive, srcPath, rootPath, kernel_name)) + if (!copy(srcFile, drive, kernel_name)) { printf("\n%s: cannot copy \"%s\"\n", pgm, kernel_name); exit(1); } /* copy kernel */ - printf("\nCopying COMMAND.COM...\n"); - if (!copy(drive, srcPath, rootPath, "COMMAND.COM")) + if (altkern) { - char *comspec = getenv("COMSPEC"); - if (comspec != NULL) + if ( (!get_full_path(srcPath, rootPath, OEMDOS, srcFile)) || + (!copy(srcFile, drive, OEMDOS)) ) { - printf("%s: Trying \"%s\"\n", pgm, comspec); - if (!copy(drive, comspec, NULL, "COMMAND.COM")) - comspec = NULL; + printf("\n%s: cannot copy \"%s\"\n", pgm, OEMDOS); + exit(1); } - if (comspec == NULL) + } + + /* copy command.com, 1st try source path, then try %COMSPEC% */ + if (!get_full_path(srcPath, rootPath, "COMMAND.COM", srcFile)) + { + char *comspec = getenv("COMSPEC"); + if ( (comspec == NULL) || + (!get_full_path(comspec, NULL, "COMMAND.COM", srcFile)) ) { - printf("\n%s: cannot copy \"COMMAND.COM\"\n", pgm); - exit(1); + printf("\n%s: failed to find command interpreter (shell) file %s\n", pgm, "COMMAND.COM"); + exit(1); } + printf("%s: Using shell from %COMSPEC% \"%s\"\n", pgm, comspec); + } + if (!copy(srcFile, drive, "COMMAND.COM")) + { + printf("\n%s: cannot copy \"%s\"\n", pgm, "COMMAND.COM"); + exit(1); } /* copy shell */ } @@ -929,41 +992,50 @@ BOOL check_space(COUNT drive, ULONG bytes) } /* check_space */ -BYTE copybuffer[COPY_SIZE]; - -BOOL copy(COUNT drive, BYTE * srcPath, BYTE * rootPath, BYTE * file) +/* returns TRUE if file exists, FALSE otherwise + 1st checks for srcPath + filename, if that does not exist then + will check for rootPath + filename + On failure, source is undefined. source must be >= SYS_MAXPATH bytes + */ +BOOL get_full_path(BYTE * srcPath, BYTE * rootPath, BYTE * filename, BYTE *source) { - static BYTE dest[SYS_MAXPATH], source[SYS_MAXPATH]; - unsigned ret; - int fdin, fdout; - ULONG copied = 0; struct stat fstatbuf; strcpy(source, srcPath); - if (rootPath != NULL) /* trick for comspec */ - strcat(source, file); + if (rootPath != NULL) /* trick for comspec, append filename if srcPath doesn't include it */ + strcat(source, filename); + /* check if file exists in source directory */ if (stat(source, &fstatbuf)) { - printf("%s: \"%s\" not found\n", pgm, source); - + /* not found in source path, so try root of source drive */ if ((rootPath != NULL) && (*rootPath) /* && (errno == ENOENT) */ ) { - sprintf(source, "%s%s", rootPath, file); - printf("%s: Trying \"%s\"\n", pgm, source); + sprintf(source, "%s%s", rootPath, filename); if (stat(source, &fstatbuf)) - { - printf("%s: \"%s\" not found\n", pgm, source); return FALSE; - } } else return FALSE; } + return TRUE; +} /* get_full_path */ + +BYTE copybuffer[COPY_SIZE]; + +/* copies file (path+filename specified by srcFile) to drive:\filename */ +BOOL copy(BYTE *source, COUNT drive, BYTE * filename) +{ + static BYTE dest[SYS_MAXPATH]; + unsigned ret; + int fdin, fdout; + ULONG copied = 0; + + printf("\nCopying %s...\n", source); truename(dest, source); strcpy(source, dest); - sprintf(dest, "%c:\\%s", 'A' + drive, file); + sprintf(dest, "%c:\\%s", 'A' + drive, filename); if (stricmp(source, dest) == 0) { printf("%s: source and destination are identical: skipping \"%s\"\n", @@ -979,7 +1051,7 @@ BOOL copy(COUNT drive, BYTE * srcPath, BYTE * rootPath, BYTE * file) if (!check_space(drive, filelength(fdin))) { - printf("%s: Not enough space to transfer %s\n", pgm, file); + printf("%s: Not enough space to transfer %s\n", pgm, filename); close(fdin); exit(1); } From a9c8174b5daa6d99c5f9308453e3a1ae8b2cf100 Mon Sep 17 00:00:00 2001 From: Luchezar Georgiev Date: Tue, 7 Sep 2004 14:15:49 +0000 Subject: [PATCH 559/671] If no floppy drives present, don't initialise DDT for drive A:. " - Initdisk" no longer shifts text if no FAT partitions found. Converted cdiv() from macro to function; optimise and clean-up. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/branches/UNSTABLE@1026 6ac86273-5f31-0410-b378-82cca8765d1b --- docs/history.txt | 4 ++ kernel/initdisk.c | 161 ++++++++++++++++------------------------------ kernel/memmgr.c | 18 +++--- 3 files changed, 70 insertions(+), 113 deletions(-) diff --git a/docs/history.txt b/docs/history.txt index bd521637..0497765c 100644 --- a/docs/history.txt +++ b/docs/history.txt @@ -319,6 +319,10 @@ - optimisation and clean-up * fattab.c: ISFAT32 function removed (now macro), "wasfree" optimised * globals.h: __TIME__ removed - no two kernels released on same day + * initdisk.c: + - if no floppy drives present, don't initialise DDT for drive A: + - " - Initdisk" no longer shifts text if no FAT partitions found + - converted cdiv() from macro to function; optimise and clean-up * intr.asm: lseek() added (necessary for COUNTRY.SYS processing) * ioctl.c: - r_si/r_di contents added as documented in PC-DOS Technical Update diff --git a/kernel/initdisk.c b/kernel/initdisk.c index d175f6c0..a4430aaf 100644 --- a/kernel/initdisk.c +++ b/kernel/initdisk.c @@ -151,20 +151,12 @@ COUNT nUnits BSS_INIT(0); /* #define DEBUG */ -#define _BETA_ /* messages for initial phase only */ - #if defined(DEBUG) #define DebugPrintf(x) printf x #else #define DebugPrintf(x) #endif -#if defined(_BETA_) -#define BetaPrintf(x) printf x -#else -#define BetaPrintf(x) -#endif - #define LBA_to_CHS init_LBA_to_CHS /* @@ -272,7 +264,7 @@ COUNT init_readdasd(UBYTE drive) regs.a.b.h = 0x15; regs.d.b.l = drive; init_call_intr(0x13, ®s); - if ((regs.flags & 1) == 0) + if ((regs.flags & FLG_CARRY) == 0) switch (regs.a.b.h) { case 2: @@ -316,7 +308,7 @@ COUNT init_getdriveparm(UBYTE drive, bpb * pbpbarray) regs.d.b.l = drive; init_call_intr(0x13, ®s); type = regs.b.b.l - 1; - if (regs.flags & 1) + if (regs.flags & FLG_CARRY) type = 0; /* return 320-360 for XTs */ else if (type > 6) type = 8; /* any odd ball drives get 8&7=0: the 320-360 table */ @@ -340,7 +332,7 @@ COUNT init_getdriveparm(UBYTE drive, bpb * pbpbarray) copied and pasted from dsk.c! */ -void init_LBA_to_CHS(struct CHS *chs, ULONG LBA_address, +void LBA_to_CHS(struct CHS *chs, ULONG LBA_address, struct DriveParamS *driveparam) { unsigned hs = driveparam->chs.Sector * driveparam->chs.Head; @@ -368,7 +360,10 @@ void printCHS(char *title, struct CHS *chs) */ /* Compute ceil(a/b) */ -#define cdiv(a, b) (((a) + (b) - 1) / (b)) +STATIC UWORD cdiv(ULONG a, UWORD b) +{ + return (UWORD)((a + b - 1) / b); +} /* calculates FAT data: code adapted by Bart Oldeman from mkdosfs from the Linux dosfstools: @@ -386,12 +381,16 @@ VOID CalculateFATData(ddt * pddt, ULONG NumSectors, UBYTE FileSystem) /* FAT related items */ defbpb->bpb_nfat = 2; - defbpb->bpb_ndirent = (FileSystem == FAT32 - || FileSystem == FAT32_LBA) ? 0 : 512; - /* normal value of number of entries in root dir */ - defbpb->bpb_nreserved = (FileSystem == FAT32 - || FileSystem == FAT32_LBA) ? 0x20 : 1; - + if (FileSystem == FAT32 || FileSystem == FAT32_LBA) + { + defbpb->bpb_ndirent = 0; + defbpb->bpb_nreserved = 0x20; + } + else + { + defbpb->bpb_ndirent = 512; + defbpb->bpb_nreserved = 1; + } fatdata = NumSectors - cdiv(defbpb->bpb_ndirent * DIRENT_SIZE, defbpb->bpb_nbyte) - defbpb->bpb_nreserved; @@ -418,8 +417,7 @@ VOID CalculateFATData(ddt * pddt, ULONG NumSectors, UBYTE FileSystem) fatdat = 32640; /* The "+2*defbpb->bpb_nsector" is for the reserved first two FAT entries */ fatlength = cdiv(fatdat + 2 * defbpb->bpb_nsector, - defbpb->bpb_nbyte * 2 * defbpb->bpb_nsector / 3 + - defbpb->bpb_nfat); + defbpb->bpb_nbyte * 2 * defbpb->bpb_nsector / 3 + defbpb->bpb_nfat); /* Need to calculate number of clusters, since the unused parts of the * FATS and data area together could make up space for an additional, * not really present cluster. */ @@ -459,9 +457,8 @@ VOID CalculateFATData(ddt * pddt, ULONG NumSectors, UBYTE FileSystem) DebugPrintf(("Trying with %d sectors/cluster:\n", defbpb->bpb_nsector)); - fatlength = (unsigned)cdiv(fatdata + 2 * defbpb->bpb_nsector, - (ULONG)defbpb->bpb_nbyte * defbpb->bpb_nsector / 2 + - defbpb->bpb_nfat); + fatlength = cdiv(fatdata + 2 * defbpb->bpb_nsector, + defbpb->bpb_nbyte * defbpb->bpb_nsector / 2 + defbpb->bpb_nfat); /* Need to calculate number of clusters, since the unused parts of the * FATS and data area together could make up space for an additional, * not really present cluster. */ @@ -516,8 +513,7 @@ VOID CalculateFATData(ddt * pddt, ULONG NumSectors, UBYTE FileSystem) do { fatlength = cdiv(fatdata + 2 * defbpb->bpb_nsector, - (ULONG)defbpb->bpb_nbyte * defbpb->bpb_nsector / 4 + - defbpb->bpb_nfat); + defbpb->bpb_nbyte * defbpb->bpb_nsector / 4 + defbpb->bpb_nfat); /* Need to calculate number of clusters, since the unused parts of the * FATS and data area together could make up space for an additional, * not really present cluster. */ @@ -611,7 +607,6 @@ void DosDefinePartition(struct DriveParamS *driveParam, /* sectors per cluster, sectors per FAT etc. */ CalculateFATData(pddt, pEntry->NumSect, pEntry->FileSystem); - pddt->ddt_serialno = 0x12345678l; /* drive inaccessible until bldbpb successful */ pddt->ddt_descflags |= init_readdasd(pddt->ddt_driveno) | DF_NOACCESS; pddt->ddt_type = 5; @@ -637,7 +632,7 @@ void DosDefinePartition(struct DriveParamS *driveParam, ExtPri = "Ext"; num = extendedPartNo; } - printf("\r%c: HD%d, %s[%2d]", 'A' + nUnits, + printf("%c: HD%d, %s[%2d]", 'A' + nUnits, (driveParam->driveno & 0x7f) + 1, ExtPri, num); printCHS(", CHS= ", &chs); @@ -673,7 +668,7 @@ STATIC int LBA_Get_Drive_Parameters(int drive, struct DriveParamS *driveParam) init_call_intr(0x13, ®s); - if (regs.b.x != 0xaa55 || (regs.flags & 0x01)) + if (regs.b.x != 0xaa55 || (regs.flags & FLG_CARRY)) { goto StandardBios; } @@ -703,7 +698,7 @@ STATIC int LBA_Get_Drive_Parameters(int drive, struct DriveParamS *driveParam) init_call_intr(0x13, ®s); /* error or DMA boundary errors not handled transparently */ - if (regs.flags & 0x01) + if (regs.flags & FLG_CARRY) { goto StandardBios; } @@ -739,7 +734,7 @@ STATIC int LBA_Get_Drive_Parameters(int drive, struct DriveParamS *driveParam) init_call_intr(0x13, ®s); - if (regs.flags & 0x01) + if (regs.flags & FLG_CARRY) goto ErrorReturn; driveParam->chs.Head = (regs.d.x >> 8) + 1; @@ -954,17 +949,12 @@ BOOL ScanForPrimaryPartitions(struct DriveParamS * driveParam, int scan_type, extendedPartNo, i); if (scan_type == SCAN_PRIMARYBOOT || scan_type == SCAN_PRIMARY) - { - return partitionsToIgnore; - } + break; } - return partitionsToIgnore; } -void BIOS_drive_reset(unsigned drive); - -int Read1LBASector(struct DriveParamS *driveParam, unsigned drive, +BOOL Read1LBASector(struct DriveParamS *driveParam, unsigned drive, ULONG LBA_address, void * buffer) { static struct _bios_LBA_address_packet dap = { @@ -1023,11 +1013,11 @@ int Read1LBASector(struct DriveParamS *driveParam, unsigned drive, } /* end of retries */ init_call_intr(0x13, ®s); if ((regs.flags & FLG_CARRY) == 0) - break; - BIOS_drive_reset(driveParam->driveno); + return 0; + regs.a.b.h = 0xD; + init_call_intr(0x13, ®s); /* reset hard disk */ } - - return regs.flags & FLG_CARRY ? 1 : 0; + return 1; } /* Load the Partition Tables and get information on all drives */ @@ -1141,7 +1131,7 @@ int BIOS_nrdrives(void) regs.d.b.l = 0x80; init_call_intr(0x13, ®s); - if (regs.flags & 1) + if (regs.flags & FLG_CARRY) { printf("no hard disks detected\n"); return 0; @@ -1150,16 +1140,6 @@ int BIOS_nrdrives(void) return regs.d.b.l; } -void BIOS_drive_reset(unsigned drive) -{ - iregs regs; - - regs.d.b.l = drive | 0x80; - regs.a.b.h = 0; - - init_call_intr(0x13, ®s); -} - /* thats what MSDN says: @@ -1196,7 +1176,9 @@ The following occurs at startup: MS-DOS checks all installed disk devices, assigning the drive letter A to the first physical floppy disk drive that is found. -If a second physical floppy disk drive is present, it is assigned drive letter B. If it is not present, a logical drive B is created that uses the first physical floppy disk drive. +If a second physical floppy disk drive is present, it is assigned drive +letter B. If it is not present, a logical drive B is created that uses +the first physical floppy disk drive. Regardless of whether a second floppy disk drive is present, MS-DOS then assigns the drive letter C to the primary MS-DOS @@ -1260,20 +1242,29 @@ STATIC void make_ddt (ddt *pddt, int Unit, int driveno, int flags) pddt->ddt_descflags = init_readdasd(driveno) | flags; pddt->ddt_offset = 0; - pddt->ddt_serialno = 0x12345678l; memcpy(&pddt->ddt_bpb, &pddt->ddt_defbpb, sizeof(bpb)); push_ddt(pddt); } -void ReadAllPartitionTables(void) +/* disk initialization: returns number of units */ +COUNT dsk_init() { - UBYTE foundPartitions[MAX_HARD_DRIVE]; - + static UBYTE foundPartitions[MAX_HARD_DRIVE] = {0}; int HardDrive; int nHardDisk; ddt nddt; static iregs regs; + printf(" - InitDisk\r"); + +#ifdef DEBUG + { + regs.a.x = 0x1112; /* select 43 line mode - more space for partinfo */ + regs.b.x = 0; + init_call_intr(0x10, ®s); + } +#endif + /* quick adjustment of diskette parameter table */ fmemcpy(int1e_table, *(char FAR * FAR *)MK_FP(0, 0x1e*4), sizeof(int1e_table)); /* enforce min. 9 sectors per track */ @@ -1283,41 +1274,26 @@ void ReadAllPartitionTables(void) setvec(0x1e, (intvec)int1e_table); /* Setup media info and BPBs arrays for floppies */ - make_ddt(&nddt, 0, 0, 0); - /* - this is a quick patch - see if B: exists - test for A: also, need not exist - */ init_call_intr(0x11, ®s); /* get equipment list */ -/*if ((regs.AL & 1)==0)*//* no floppy drives installed */ - if ((regs.AL & 1) && (regs.AL & 0xc0)) + if (regs.AL & 1) /* at least one floppy drive installed */ { - /* floppy drives installed and a B: drive */ - make_ddt(&nddt, 1, 1, 0); - } - else - { - /* set up the DJ method : multiple logical drives */ - make_ddt(&nddt, 1, 0, DF_MULTLOG); + make_ddt(&nddt, 0, 0, 0); + if (regs.AL & 0xC0) /* more than one floppy */ + make_ddt(&nddt, 1, 1, 0); /* real B: drive */ + else + make_ddt(&nddt, 1, 0, DF_MULTLOG); /* phantom B: drive */ } /* Initial number of disk units */ nUnits = 2; nHardDisk = BIOS_nrdrives(); - if (nHardDisk > LENGTH(foundPartitions)) - nHardDisk = LENGTH(foundPartitions); + if (nHardDisk > MAX_HARD_DRIVE) + nHardDisk = MAX_HARD_DRIVE; DebugPrintf(("DSK init: found %d disk drives\n", nHardDisk)); - /* Reset the drives */ - for (HardDrive = 0; HardDrive < nHardDisk; HardDrive++) - { - BIOS_drive_reset(HardDrive); - foundPartitions[HardDrive] = 0; - } - if (InitKernelConfig.DLASortByDriveNo == 0) { /* printf("Drive Letter Assignment - DOS order\n"); */ @@ -1347,8 +1323,6 @@ void ReadAllPartitionTables(void) } else { - UBYTE bootdrv = peekb(0,0x5e0); - /* printf("Drive Letter Assignment - sorted by drive\n"); */ /* Process primary partition table 1 partition only */ @@ -1356,7 +1330,7 @@ void ReadAllPartitionTables(void) { struct DriveParamS driveParam; if (LBA_Get_Drive_Parameters(HardDrive, &driveParam) && - driveParam.driveno == bootdrv) + driveParam.driveno == peekb(0,0x5e0)) { foundPartitions[HardDrive] = ProcessDisk(SCAN_PRIMARYBOOT, HardDrive, 0); @@ -1383,26 +1357,5 @@ void ReadAllPartitionTables(void) ProcessDisk(SCAN_PRIMARY2, HardDrive, foundPartitions[HardDrive]); } } -} - -/* disk initialization: returns number of units */ -COUNT dsk_init() -{ - printf(" - InitDisk"); - -#ifdef DEBUG - { - iregs regs; - regs.a.x = 0x1112; /* select 43 line mode - more space for partinfo */ - regs.b.x = 0; - init_call_intr(0x10, ®s); - } -#endif - - /* Reset the drives */ - BIOS_drive_reset(0); - - ReadAllPartitionTables(); - return nUnits; } diff --git a/kernel/memmgr.c b/kernel/memmgr.c index 987143fc..ffbb8b4d 100644 --- a/kernel/memmgr.c +++ b/kernel/memmgr.c @@ -59,10 +59,10 @@ STATIC COUNT joinMCBs(seg para) while (p->m_type == MCB_NORMAL) { q = nxtMCB(p); - if (!mcbFree(q)) - break; if (!mcbValid(q)) return DE_MCBDESTRY; + if (!mcbFree(q)) + break; /* join both MCBs */ p->m_type = q->m_type; /* possibly the next MCB is the last one */ p->m_size += q->m_size + 1; /* one for q's MCB itself */ @@ -119,7 +119,7 @@ COUNT DosMemAlloc(UWORD size, COUNT mode, seg *para, UWORD *asize) /* Hack to the Umb Region direct for now. Save time and program space. */ - if ((uppermem_link & 1) && uppermem_root != 0xffff) + if (uppermem_link && uppermem_root != 0xffff) { COUNT tmpmode = (mode == LARGEST ? mem_access_mode : mode); if ((mode != LARGEST || size == 0xffff) && @@ -147,9 +147,9 @@ COUNT DosMemAlloc(UWORD size, COUNT mode, seg *para, UWORD *asize) /* this block has a "match" size, try the rule set */ switch (mode) { - case LAST_FIT: /* search for last possible */ - case LAST_FIT_U: - case LAST_FIT_UO: + /* case LAST_FIT: */ /* search for last possible */ + /* case LAST_FIT_U: */ + /* case LAST_FIT_UO: */ default: foundSeg = p; break; @@ -189,7 +189,7 @@ COUNT DosMemAlloc(UWORD size, COUNT mode, seg *para, UWORD *asize) if (!foundSeg || !foundSeg->m_size) { /* no block to fullfill the request */ if ((mode != LARGEST) && (mode & FIRST_FIT_U) && - (uppermem_link & 1) && uppermem_root != 0xffff) + uppermem_link && uppermem_root != 0xffff) { mode &= ~FIRST_FIT_U; goto searchAgain; @@ -401,7 +401,7 @@ COUNT DosMemCheck(void) COUNT FreeProcessMem(UWORD ps) { mcb FAR *p; - BYTE oldumbstate = uppermem_link & 1; + BYTE oldumbstate = uppermem_link; /* link in upper memory to free those , too */ DosUmbLink(1); @@ -464,7 +464,7 @@ void DosUmbLink(unsigned n) return; p = para2far(first_mcb); - if (n > 1 || (uppermem_link & 1) == n) + if (n > 1 || uppermem_link == n) return; while (FP_SEG(p) != uppermem_root && p->m_type != MCB_LAST) { From 6e7415e7a4b0e99e8daba5781d3f466bae718751 Mon Sep 17 00:00:00 2001 From: Kenneth J Davis Date: Tue, 7 Sep 2004 18:31:41 +0000 Subject: [PATCH 560/671] add optionally compiled in support to sys for PC/MS DOS versions (FAT16 only) git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/branches/UNSTABLE@1027 6ac86273-5f31-0410-b378-82cca8765d1b --- boot/makefile | 8 ++- docs/config.txt | 2 +- filelist | 1 + sys/makefile | 8 ++- sys/sys.c | 148 ++++++++++++++++++++++++++++++++++++++++-------- 5 files changed, 141 insertions(+), 26 deletions(-) diff --git a/boot/makefile b/boot/makefile index a2ee0897..48353514 100644 --- a/boot/makefile +++ b/boot/makefile @@ -8,7 +8,7 @@ ######################################################################## -all: fat12.bin fat16.bin fat32chs.bin fat32lba.bin +all: fat12.bin fat16.bin fat32chs.bin fat32lba.bin oemfat12.bin oemfat16.bin fat12.bin: boot.asm $(DEPENDS) $(NASM) -DISFAT12 boot.asm -o$*.bin @@ -22,6 +22,12 @@ fat32chs.bin: boot32.asm $(DEPENDS) fat32lba.bin: boot32lb.asm $(DEPENDS) $(NASM) boot32lb.asm -o$*.bin +oemfat12.bin: oemboot.asm $(DEPENDS) + $(NASM) -DISFAT12 oemboot.asm -o$*.bin + +oemfat16.bin: oemboot.asm $(DEPENDS) + $(NASM) -DISFAT16 oemboot.asm -o$*.bin + ######################################################################## clean: diff --git a/docs/config.txt b/docs/config.txt index 8e98016f..0ec7d195 100644 --- a/docs/config.txt +++ b/docs/config.txt @@ -14,7 +14,7 @@ file named FDCONFIG.SYS, should it exist, it will will be used instead of CONFIG.SYS; this allows the FreeDOS kernel to coexist and be configured differently than another DOS kernel. There are additional options available to adjust other aspects of the -kernels behaviour. Note: some options listed below are FreeDOS +kernel's behaviour. Note: some options listed below are FreeDOS specific and will not work when using other/older DOS kernels. Below is list of all documented FreeDOS config.sys supported options; additional undocumented options may exist but are not diff --git a/filelist b/filelist index 7aa7764f..e49f924f 100644 --- a/filelist +++ b/filelist @@ -12,6 +12,7 @@ */*/boot/boot.asm */*/boot/boot32.asm */*/boot/boot32lb.asm +*/*/boot/oemboot.asm */*/boot/makefile */*/docs/bugs.txt */*/docs/build.txt diff --git a/sys/makefile b/sys/makefile index d2324f0d..283248ec 100644 --- a/sys/makefile +++ b/sys/makefile @@ -27,7 +27,13 @@ fat32chs.h: ..\boot\fat32chs.bin bin2c.com fat32lba.h: ..\boot\fat32lba.bin bin2c.com bin2c ..\boot\$*.bin $*.h $* -..\bin\sys.com: $(SYS_C) ..\hdr\*.h fat12com.h fat16com.h fat32chs.h fat32lba.h +oemfat12.h: ..\boot\oemfat12.bin bin2c.com + bin2c ..\boot\$*.bin $*.h $* + +oemfat16.h: ..\boot\oemfat16.bin bin2c.com + bin2c ..\boot\$*.bin $*.h $* + +..\bin\sys.com: $(SYS_C) ..\hdr\*.h fat12com.h fat16com.h fat32chs.h fat32lba.h oemfat12.h oemfat16.h $(CL) $(CFLAGST) -DFORSYS -DWITHFAT32 $(SYS_C) copy sys.com ..\bin del sys.com diff --git a/sys/sys.c b/sys/sys.c index e398c739..c9ea94be 100644 --- a/sys/sys.c +++ b/sys/sys.c @@ -28,6 +28,7 @@ #define DEBUG /* #define DDEBUG */ +/* #define WITHOEMCOMPATBS */ /* uncomment for larger sys that support MS/PC DOS */ #define SYS_VERSION "v3.4" @@ -68,13 +69,39 @@ extern int VA_CDECL sprintf(char * buff, const char * fmt, ...); #include "fat32chs.h" #include "fat32lba.h" #endif +#ifdef WITHOEMCOMPATBS +#include "oemfat12.h" +#include "oemfat16.h" +#endif #ifndef __WATCOMC__ #include +/* returns current DOS drive, A=0, B=1,C=2, ... */ +#ifdef __TURBOC__ +#define getcurdrive (unsigned)getdisk +#else +unsigned getcurdrive(void) +{ + union REGS regs; + regs.h.ah = 0x19; + int86(0x21, ®s, ®s); + return regs.h.al; +} +#endif + #else +/* returns current DOS drive, A=0, B=1,C=2, ... */ +unsigned getcurdrive(void); +#pragma aux getcurdrive = \ + "mov ah, 0x19" \ + "int 0x21" \ + "xor ah, ah" \ + value [ax]; + + long filelength(int __handle); #pragma aux filelength = \ "mov ax, 0x4202" \ @@ -159,7 +186,7 @@ char *getenv(const char *name) BYTE pgm[] = "SYS"; -void put_boot(int, char *, char *, int, int); +void put_boot(int, char *, char *, int, int, int); BOOL check_space(COUNT, ULONG); BOOL get_full_path(BYTE * srcPath, BYTE * rootPath, BYTE * filename, BYTE *source); BOOL copy(BYTE *source, COUNT drive, BYTE * filename); @@ -251,9 +278,17 @@ int FDKrnConfigMain(int argc, char **argv); #define FDKERNEL "KERNEL.SYS" #define OEMKERNEL "IBMBIO.COM" #define OEMDOS "IBMDOS.COM" +#define MSKERNEL "IO.SYS" +#define MSDOS "MSDOS.SYS" #define FDLOADSEG 0x60 #define OEMLOADSEG 0x70 +#define NO_OEMKERN 0 /* standard FreeDOS mode */ +#define DR_OEMKERN 1 /* use FreeDOS boot sector, but OEM names */ +#define PC_OEMKERN 2 /* use PC-DOS compatible boot sector and names */ +#define MS_OEMKERN 3 /* use PC-DOS compatible BS with MS names */ + + int main(int argc, char **argv) { COUNT drive; /* destination drive */ @@ -270,7 +305,7 @@ int main(int argc, char **argv) int both = 0; char *kernel_name = FDKERNEL; int load_segment = FDLOADSEG; - int altkern = 0; /* use OEM kernel values instead of FD ones */ + int altkern = NO_OEMKERN; /* use OEM kernel values instead of FD ones */ printf("FreeDOS System Installer " SYS_VERSION ", " __DATE__ "\n\n"); @@ -300,9 +335,43 @@ int main(int argc, char **argv) if (memicmp(argp, "OEM", 3) == 0) { - altkern = 1; /* kernel is split into 2 files and update BS name */ - kernel_name = OEMKERNEL; - load_segment = OEMLOADSEG; + #ifdef WITHOEMCOMPATBS + if (*(argp+3) == ':') + { + argp+=4; /* point to DR/PC/MS that follows */ + if (memicmp(argp, "PC", 2) == 0) + { + altkern = PC_OEMKERN; /* kernel is split into 2 files and update BS name */ + load_segment = OEMLOADSEG; + kernel_name = OEMKERNEL; + } + else if (memicmp(argp, "MS", 2) == 0) + { + altkern = MS_OEMKERN; /* kernel is split into 2 files and update BS name */ + load_segment = OEMLOADSEG; + kernel_name = MSKERNEL; + } + else if (memicmp(argp, "DR", 2) == 0) + { + altkern = DR_OEMKERN; /* kernel is split into 2 files and update BS name */ + load_segment = OEMLOADSEG; + kernel_name = OEMKERNEL; + } + else /* if (memicmp(argp, "FD", 2) == 0) */ + { + altkern = NO_OEMKERN; /* restore defaults */ + load_segment = FDLOADSEG; + kernel_name = FDKERNEL; + } + } + else /* generic support, just change names and load sector */ + #endif + { + altkern = DR_OEMKERN; /* kernel is split into 2 files and update BS name */ + load_segment = OEMLOADSEG; + if (kernel_name == FDKERNEL) /* preserve /K name if on cmd line 1st */ + kernel_name = OEMKERNEL; + } } else if (memicmp(argp, "BOOTONLY", 8) == 0) { @@ -347,6 +416,11 @@ int main(int argc, char **argv) " BOTH : write to *both* the real boot sector and the image file\n" " /BOOTONLY: do *not* copy kernel / shell, only update boot sector or image\n" " /OEM : indicates kernel is IBMIO.SYS/IBMDOS.SYS loaded at 0x70\n" +#ifdef WITHOEMCOMPATBS + " /OEM:DR use IBMBIO.COM/IBMDOS.SYS and FD boot sector (default)\n" + " /OEM:PC use PC-DOS compatible boot sector\n" + " /OEM:MS use PC-DOS compatible boot sector with IO.SYS/MSDOS.SYS\n" +#endif " /K name : name of kernel to use instead of KERNEL.SYS\n" " /L segm : hex load segment to use instead of 60\n" "%s CONFIG /help\n", pgm, pgm); @@ -382,14 +456,7 @@ int main(int argc, char **argv) if ((strlen(srcPath) > 1) && (srcPath[1] == ':')) /* src specifies drive */ srcDrive = toupper(*srcPath) - 'A'; else /* src doesn't specify drive, so assume current drive */ - { -#ifdef __TURBOC__ - srcDrive = (unsigned) getdisk(); -#else - _dos_getdrive(&srcDrive); - srcDrive--; -#endif - } + srcDrive = getcurdrive(); /* Don't try root if src==dst drive or source path given */ if ((drive == srcDrive) @@ -414,7 +481,7 @@ int main(int argc, char **argv) } else /* else OEM kernel found, so switch modes */ { - altkern = 1; + altkern = DR_OEMKERN; kernel_name = OEMKERNEL; load_segment = OEMLOADSEG; } @@ -422,7 +489,7 @@ int main(int argc, char **argv) } printf("Processing boot sector...\n"); - put_boot(drive, bsFile, kernel_name, load_segment, both); + put_boot(drive, bsFile, kernel_name, load_segment, both, altkern); if (!bootonly) { @@ -434,10 +501,15 @@ int main(int argc, char **argv) if (altkern) { - if ( (!get_full_path(srcPath, rootPath, OEMDOS, srcFile)) || - (!copy(srcFile, drive, OEMDOS)) ) + char *dosfn = OEMDOS; + #ifdef WITHOEMCOMPATBS + if (altkern == MS_OEMKERN) dosfn = MSDOS; + #endif + + if ( (!get_full_path(srcPath, rootPath, dosfn, srcFile)) || + (!copy(srcFile, drive, dosfn)) ) { - printf("\n%s: cannot copy \"%s\"\n", pgm, OEMDOS); + printf("\n%s: cannot copy \"%s\"\n", pgm, dosfn); exit(1); } } @@ -452,7 +524,7 @@ int main(int argc, char **argv) printf("\n%s: failed to find command interpreter (shell) file %s\n", pgm, "COMMAND.COM"); exit(1); } - printf("%s: Using shell from %COMSPEC% \"%s\"\n", pgm, comspec); + printf("\n%s: Using shell from %COMSPEC% \"%s\"\n", pgm, comspec); } if (!copy(srcFile, drive, "COMMAND.COM")) { @@ -494,6 +566,7 @@ VOID dump_sector(unsigned char far * sec) #endif + #ifdef __WATCOMC__ int absread(int DosDrive, int nsects, int foo, void *diskReadPacket); @@ -741,7 +814,7 @@ void correct_bpb(struct bootsectortype *default_bpb, oldboot->bsHiddenSecs = default_bpb->bsHiddenSecs; } -void put_boot(int drive, char *bsFile, char *kernel_name, int load_seg, int both) +void put_boot(int drive, char *bsFile, char *kernel_name, int load_seg, int both, int altkern) { #ifdef WITHFAT32 struct bootsectortype32 *bs32; @@ -819,6 +892,15 @@ void put_boot(int drive, char *bsFile, char *kernel_name, int load_seg, int both correct_bpb((struct bootsectortype *)(default_bpb + 7 - 11), bs); #ifdef WITHFAT32 /* copy one of the FAT32 boot sectors */ + #ifdef WITHOEMCOMPATBS + if (altkern >= 2) /* MS or PC compatible BS requested */ + { + printf("%s: FAT32 versions of PC/MS DOS compatible boot sectors\n" + "are not supported [yet].\n"); + exit(1); + } + #endif + memcpy(newboot, haveLBA() ? fat32lba : fat32chs, SEC_SIZE); #else printf("SYS hasn't been compiled with FAT32 support.\n" @@ -832,7 +914,21 @@ void put_boot(int drive, char *bsFile, char *kernel_name, int load_seg, int both if (drive >= 2 && generic_block_ioctl(drive + 1, 0x860, default_bpb) == 0) correct_bpb((struct bootsectortype *)(default_bpb + 7 - 11), bs); - memcpy(newboot, fs == FAT16 ? fat16com : fat12com, SEC_SIZE); + #ifdef WITHOEMCOMPATBS + { + unsigned char * bs; + if (altkern >= 2) + { + printf("Using PC-DOS compatible boot sector.\n"); + bs = (fs == FAT16) ? oemfat16 : oemfat12; + } + else + bs = (fs == FAT16) ? fat16com : fat12com; + memcpy(newboot, bs, SEC_SIZE); + } + #else + memcpy(newboot, fs == FAT16 ? fat16com : fat12com, SEC_SIZE); + #endif } /* Copy disk parameter from old sector to new sector */ @@ -859,7 +955,10 @@ void put_boot(int drive, char *bsFile, char *kernel_name, int load_seg, int both This happens to be offset 0x78 (=0x3c * 2) for FAT32 and offset 0x5c (=0x2e * 2) for FAT16 */ /* i.e. BE CAREFUL WHEN YOU CHANGE THE BOOT SECTORS !!! */ - ((int *)newboot)[0x3C] = load_seg; + #ifdef WITHOEMCOMPATBS + if (altkern < 2) /* PC-DOS compatible bs has fixed load sector */ + #endif + ((int *)newboot)[0x3C] = load_seg; #ifdef DEBUG printf(" FAT starts at sector %lx + %x\n", bs32->bsHiddenSecs, bs32->bsResSectors); @@ -870,7 +969,10 @@ void put_boot(int drive, char *bsFile, char *kernel_name, int load_seg, int both { /* put 0 for A: or B: (force booting from A:), otherwise use DL */ bs->bsDriveNumber = drive < 2 ? 0 : 0xff; - ((int *)newboot)[0x2E] = load_seg; + #ifdef WITHOEMCOMPATBS + if (altkern < 2) /* PC-DOS compatible bs has fixed load sector */ + #endif + ((int *)newboot)[0x2E] = load_seg; } #ifdef DEBUG /* add an option to display this on user request? */ From fce371ba94affbf7f3a622c2e167d06ddf951cdc Mon Sep 17 00:00:00 2001 From: Kenneth J Davis Date: Tue, 7 Sep 2004 19:17:09 +0000 Subject: [PATCH 561/671] pc/ms DOS compatible boot sector git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/branches/UNSTABLE@1028 6ac86273-5f31-0410-b378-82cca8765d1b --- boot/oemboot.asm | 598 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 598 insertions(+) create mode 100644 boot/oemboot.asm diff --git a/boot/oemboot.asm b/boot/oemboot.asm new file mode 100644 index 00000000..f75faa54 --- /dev/null +++ b/boot/oemboot.asm @@ -0,0 +1,598 @@ +; +; File: +; oemboot.asm +; 2004, Kenneth J. Davis +; Copyright (c) 200?, +; Description: +; OEM boot sector for FreeDOS compatible with IBM's (R) PC-DOS, +; and Microsoft's (R) PC-DOS. It may work with OpenDOS/DR-DOS, +; although the standard FreeDOS boot sector works with later +; releases. May work with other versions of DOS that use +; IBMBIO.COM/IBMDOS.COM pair. This boot sector loads only up +; to 58 sectors (29KB) of the kernel (IBMBIO.COM) to 0x70:0 then +; jumps to it. As best I can tell, PC-DOS (and assuming MS-DOS +; behaves similar) expects on entry for: +; ch = media id byte in the boot sector +; dl = BIOS drive booted from (0x00=A:, 0x80=C:, ...) +; ax:bx = the LBA sector of 1st data sector 0x0000:0021 for FAT12 +; ?or? 1st sector of IBMBIO.COM (which is normally 1st data sector) +; it also expects the boot sector (in particular the BPB) +; to still be at 0x0:7C00, the directory entry for IBMBIO.COM +; (generally first entry of first sector of the root directory) +; at 0x50:0 (DOS Data Area). The original boot sector may update +; the floppy disk parameter table (int 1Eh), but we don't so +; may fail for any systems where the changes (???) are needed. +; If the above conditions are not met, then IBMBIO.COM will +; print the not a bootable disk error message. +; +; This boot sector only supports FAT12/FAT16 as PC-DOS +; does not support FAT32 and newer FAT32 capable DOSes +; probably have different boot requirements; also do NOT +; use it to boot the FreeDOS kernel as it expects to be +; fully loaded by boot sector (> 29KB & usually to 0x60:0). +; +; WARNING: PC-DOS has additional requirements, in particular, +; it may expect that IBMBIO.COM and IBMDOS.COM be the 1st +; two entries in the root directory (even before the label) +; and that they occupy the 1st consecutive data sectors. +; Newer releases may support other positions, but still +; generally should occupy consecutive sectors. These conditions +; can usually be met by running sys on a freshly formatted +; and un-label'd disk. +; +; +; Derived From: +; boot.asm +; DOS-C boot +; +; Copyright (c) 1997, 2000-2004 +; Svante Frey, Jim Hall, Jim Tabor, Bart Oldeman, +; Tom Ehlert, Eric Auer, Luchezar Georgiev, Jon Gentle +; and Michal H. Tyc (DR-DOS adaptation, boot26dr.asm) +; All Rights Reserved +; +; This file is part of FreeDOS. +; +; DOS-C is free software; you can redistribute it and/or +; modify it under the terms of the GNU General Public License +; as published by the Free Software Foundation; either version +; 2, or (at your option) any later version. +; +; DOS-C is distributed in the hope that it will be useful, but +; WITHOUT ANY WARRANTY; without even the implied warranty of +; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See +; the GNU General Public License for more details. +; +; You should have received a copy of the GNU General Public +; License along with DOS-C; see the file COPYING. If not, +; write to the Free Software Foundation, 675 Mass Ave, +; Cambridge, MA 02139, USA. +; +; +; +--------+ +; | CLUSTER| +; | LIST | +; |--------| 0000:7F00 +; |LBA PKT | +; |--------| 0000:7E00 (0:BP+200) +; |BOOT SEC| contains BPB +; |ORIGIN | +; |--------| 0000:7C00 (0:BP) +; |STACK | minimal 256 bytes (1/2 sector) +; |- - - - | +; |KERNEL | kernel loaded here (max 58 sectors, 29KB) +; |LOADED | also used as FAT buffer +; |--------| 0070:0000 (0:0700) +; |DOS DA/ | DOS Data Area, +; |ROOT DIR| during boot the 1st sector of root directory +; |--------| 0000:0500 +; |BDA | BIOS Data Area +; +--------+ 0000:0400 +; |IVT | Interrupt Vector Table +; +--------+ 0000:0000 + + +;%define ISFAT12 1 ; only 1 of these should be set, +;%define ISFAT16 1 ; defines which FAT is supported + +%define TRYLBAREAD 1 ; undefine to use only CHS int 13h +;%define LOOPONERR 1 ; if defined on error simply loop forever +;%define SETROOTDIR 1 ; if defined dir entry copied to 0:500 +;%define RETRYALWAYS 1 ; if defined retries read forever +;%define FORCEBIOSDRV 1 ; if defined always use boot drive from BIOS +;%define MSCOMPAT 1 ; sets default filename to MSDOS IO.SYS + +segment .text + +%define BASE 0x7c00 ; boot sector originally at 0x0:BASE +%define LOADSEG 0x0070 ; segment to load kernel at LOADSEG:0 +%define LOADEND 0x07b0 ; limit reads to below this segment + ; LOADSEG+29KB, else data overwritten + +%define FATBUF bp-0x7500 ; offset of temporary buffer for FAT + ; chain 0:FATBUF = 0:0700 = LOADSEG:0 +%define ROOTDIR bp-0x7700 ; offset to buffer for root directory + ; entry of kernel 0:ROOTDIR +%define CLUSTLIST bp+0x0300 ; zero terminated list of clusters + ; that the kernel occupies + +; Some extra variables +; using bp-Entry+variable_name generates smaller code than using just +; variable_name, where bp is initialized to Entry, so bp-Entry equals 0 + +%define LBA_PACKET bp+0x0200 ; immediately after boot sector +%define LBA_SIZE word [LBA_PACKET] ; size of packet, should be 10h +%define LBA_SECNUM word [LBA_PACKET+2] ; number of sectors to read +%define LBA_OFF LBA_PACKET+4 ; buffer to read/write to +%define LBA_SEG LBA_PACKET+6 +%define LBA_SECTOR_0 word [LBA_PACKET+8 ] ; LBA starting sector # +%define LBA_SECTOR_16 word [LBA_PACKET+10] +%define LBA_SECTOR_32 word [LBA_PACKET+12] +%define LBA_SECTOR_48 word [LBA_PACKET+14] + +%define PARAMS LBA_PACKET+0x10 +;%define RootDirSecs PARAMS+0x0 ; # of sectors root dir uses +%define fat_start PARAMS+0x2 ; first FAT sector +;%define root_dir_start PARAMS+0x6 ; first root directory sector +%define data_start PARAMS+0x0a ; first data sector + +;----------------------------------------------------------------------- + + + org BASE + +Entry: jmp short real_start + nop + +; bp is initialized to 7c00h +%define bsOemName bp+0x03 ; OEM label +%define bsBytesPerSec bp+0x0b ; bytes/sector +%define bsSecPerClust bp+0x0d ; sectors/allocation unit +%define bsResSectors bp+0x0e ; # reserved sectors +%define bsFATs bp+0x10 ; # of fats +%define bsRootDirEnts bp+0x11 ; # of root dir entries +%define bsSectors bp+0x13 ; # sectors total in image +%define bsMedia bp+0x15 ; media descrip: fd=2side9sec, etc... +%define sectPerFat bp+0x16 ; # sectors in a fat +%define sectPerTrack bp+0x18 ; # sectors/track +%define nHeads bp+0x1a ; # heads +%define nHidden bp+0x1c ; # hidden sectors +%define nSectorHuge bp+0x20 ; # sectors if > 65536 +%define drive bp+0x24 ; drive number +%define extBoot bp+0x26 ; extended boot signature +%define volid bp+0x27 +%define vollabel bp+0x2b +%define filesys bp+0x36 + + +;----------------------------------------------------------------------- + +; times 0x3E-$+$$ db 0 +; +; Instead of zero-fill, +; initialize BPB with values suitable for a 1440 K floppy +; + db 'IBM 5.0' ; OEM label + dw 512 ; bytes per sector + db 1 ; sectors per cluster + dw 1 ; reserved sectors + db 2 ; number of FATs + dw 224 ; root directory entries + dw 80 * 36 ; total sectors on disk + db 0xF0 ; media descriptor + dw 9 ; sectors per 1 FAT copy + dw 18 ; sectors per track + dw 2 ; number of heads + dd 0 ; hidden sectors + dd 0 ; big total sectors + db 0 ; boot unit + db 0 ; reserved + db 0x29 ; extended boot record id + dd 0x12345678 ; volume serial number + db 'NO NAME '; volume label + db 'FAT12 ' ; filesystem id + +;----------------------------------------------------------------------- +; ENTRY +;----------------------------------------------------------------------- + +real_start: + cli ; disable interrupts until stack ready + cld ; all string operations increment + xor ax, ax ; ensure our segment registers ready + mov ds, ax ; cs=ds=es=ss=0x0000 + mov es, ax + mov ss, ax + mov bp, BASE + lea sp, [bp-2] + + ; a reset should not be needed here +; int 0x13 ; reset drive + +; For compatibility, diskette parameter vector updated. +; lea di [bp+0x3E] ; just use bp for DR-DOS? +; mov bx, 4 * 1eh ; stored at int 1E's vector +; lds si, [bx] ; fetch current int 1eh pointer +; mov cl, 11 ; the parameter table is 11 bytes +; rep movsb ; and copy the parameter block +; mov ds, ax ; restore DS + + sti ; enable interrupts +; +; Some BIOS don't pass drive number in DL, so don't use it if [drive] is known +; +%ifndef FORCEBIOSDRV + cmp byte [drive], 0xff ; impossible number written by SYS + jne dont_use_dl ; was SYS drive: other than A or B? +%endif + mov [drive], dl ; yes, rely on BIOS drive number in DL +dont_use_dl: ; no, rely on [drive] written by SYS + + +; GETDRIVEPARMS: Calculate start of some disk areas. +; + mov si, word [nHidden] + mov di, word [nHidden+2] + add si, word [bsResSectors] + adc di, byte 0 ; DI:SI = first FAT sector + + mov word [fat_start], si + mov word [fat_start+2], di + + mov al, [bsFATs] + cbw + mul word [sectPerFat] ; DX:AX = total number of FAT sectors + + add si, ax + adc di, dx ; DI:SI = first root directory sector + push di ; mov word [root_dir_start+2], di + push si ; mov word [root_dir_start], si + + ; Calculate how many sectors the root directory occupies. + mov bx, [bsBytesPerSec] + mov cl, 5 ; divide BX by 32 + shr bx, cl ; BX = directory entries per sector + + mov ax, [bsRootDirEnts] + xor dx, dx + div bx ; set AX = sectors per root directory + push ax ; mov word [RootDirSecs], ax + + add si, ax + adc di, byte 0 ; DI:SI = first data sector + + mov [data_start], si + mov [data_start+2], di + + +; FINDFILE: Searches for the file in the root directory. +; +; Returns: +; AX = first cluster of file + + ; First, read the root directory into buffer. + ; into the temporary buffer. (max 29KB or overruns stuff) + + pop di ; mov di, word [RootDirSecs] + pop ax ; mov ax, word [root_dir_start] + pop dx ; mov dx, word [root_dir_start+2] + lea bx, [ROOTDIR] ; es:bx = 0:0500 + push es ; save pointer to ROOTDIR + call readDisk + pop es ; restore pointer to ROOTDIR + lea si, [ROOTDIR] ; ds:si = 0:0500 + + + ; Search for kernel file name, and find start cluster. + +next_entry: mov cx, 11 + mov di, filename + push si + repe cmpsb + pop si + mov ax, [si+0x1A]; get cluster number from directory entry + je ffDone + + add si, byte 0x20 ; go to next directory entry + jc near boot_error ; fail if not found and si wraps + cmp byte [si], 0 ; if the first byte of the name is 0, + jnz next_entry ; there are no more files in the directory + +ffDone: + push ax ; store first cluster number + +%ifdef SETROOTDIR + ; copy over this portion of root dir to 0x0:500 for PC-DOS + ; (this may allow IBMBIO.COM to start in any directory entry) + lea di, [ROOTDIR] ; es:di = 0:0500 + mov cx, 0x100 + rep movsw +%endif + + +; GETFATCHAIN: +; +; Reads the FAT chain and stores it in a temporary buffer in the first +; 64 kb. The FAT chain is stored an array of 16-bit cluster numbers, +; ending with 0. +; +; The file must fit in conventional memory, so it can't be larger than +; 640 kb. The sector size must be at least 512 bytes, so the FAT chain +; can't be larger than 2.5 KB (655360 / 512 * 2 = 2560). +; +; Call with: AX = first cluster in chain + + ; Load the complete FAT into memory. The FAT can't be larger + ; than 128 kb + lea bx, [FATBUF] ; es:bx = 0:0700 + mov di, [sectPerFat] + mov ax, word [fat_start] + mov dx, word [fat_start+2] + call readDisk + + ; Set ES:DI to the temporary storage for the FAT chain. + push ds + pop es + lea di, [CLUSTLIST] + ; Set DS:0 to FAT data we loaded + mov ax, LOADSEG + mov ds, ax ; ds:0 = 0x70:0 = 0:FATBUF + + pop ax ; restore first cluster number + push ds ; store LOADSEG + +next_clust: stosw ; store cluster number + mov si, ax ; SI = cluster number + +%ifdef ISFAT12 + ; This is a FAT-12 disk. + +fat_12: add si, si ; multiply cluster number by 3... + add si, ax + shr si, 1 ; ...and divide by 2 + lodsw + + ; If the cluster number was even, the cluster value is now in + ; bits 0-11 of AX. If the cluster number was odd, the cluster + ; value is in bits 4-15, and must be shifted right 4 bits. If + ; the number was odd, CF was set in the last shift instruction. + + jnc fat_even + mov cl, 4 + shr ax, cl + +fat_even: and ah, 0x0f ; mask off the highest 4 bits + cmp ax, 0x0ff8 ; check for EOF + jb next_clust ; continue if not EOF + +%endif +%ifdef ISFAT16 + ; This is a FAT-16 disk. The maximal size of a 16-bit FAT + ; is 128 kb, so it may not fit within a single 64 kb segment. + +fat_16: mov dx, LOADSEG + add si, si ; multiply cluster number by two + jnc first_half ; if overflow... + add dh, 0x10 ; ...add 64 kb to segment value + +first_half: mov ds, dx ; DS:SI = pointer to next cluster + lodsw ; AX = next cluster + + cmp ax, 0xfff8 ; >= FFF8 = 16-bit EOF + jb next_clust ; continue if not EOF +%endif + +finished: ; Mark end of FAT chain with 0, so we have a single + ; EOF marker for both FAT-12 and FAT-16 systems. + + xor ax, ax + stosw + + push cs + pop ds + + +; loadFile: Loads the file into memory, one cluster at a time. + + pop es ; set ES:BX to load address 70:0 + xor bx, bx + + lea si, [CLUSTLIST] ; set DS:SI to the FAT chain + +cluster_next: lodsw ; AX = next cluster to read + or ax, ax ; EOF? + jne load_next ; no, continue + + ; dl set to drive by readDisk + mov ch, [bsMedia] ; ch set to media id + mov ax, [data_start+2] ; ax:bx set to 1st data sector + mov bx, [data_start] ; + jmp LOADSEG:0000 ; yes, pass control to kernel + +load_next: dec ax ; cluster numbers start with 2 + dec ax + + mov di, word [bsSecPerClust] + and di, 0xff ; DI = sectors per cluster + mul di + add ax, [data_start] + adc dx, [data_start+2] ; DX:AX = first sector to read + call readDisk + jmp short cluster_next + + +; shows text after the call to this function. + +show: pop si + lodsb ; get character + push si ; stack up potential return address + mov ah,0x0E ; show character + int 0x10 ; via "TTY" mode + cmp al,'.' ; end of string? + jne show ; until done + ret + +; failed to boot + +boot_error: +%ifdef LOOPONERR +jmp boot_error +%else +call show +; db "Error! Hit a key to reboot." + db "Err." + + xor ah,ah + int 0x13 ; reset floppy + int 0x16 ; wait for a key + int 0x19 ; reboot the machine +%endif + + +; readDisk: Reads a number of sectors into memory. +; +; Call with: DX:AX = 32-bit DOS sector number +; DI = number of sectors to read +; ES:BX = destination buffer +; +; Returns: CF set on error +; ES:BX points one byte after the last byte read. +; Exits early if LBA_SEG == LOADEND. + +readDisk: push si ; preserve cluster # + + mov LBA_SECTOR_0,ax + mov LBA_SECTOR_16,dx + mov word [LBA_SEG], es + mov word [LBA_OFF], bx + + call show + db "." +read_next: + +; initialize constants + mov LBA_SIZE, 10h ; LBA packet is 16 bytes + mov LBA_SECNUM,1 ; reset LBA count if error + +; limit kernel loading to 29KB, preventing stack & boot sector being overwritten + cmp word [LBA_SEG], LOADEND ; skip reading if past the end + je read_skip ; of kernel file buffer + +;******************** LBA_READ ******************************* + + ; check for LBA support + +%ifdef TRYLBAREAD + mov ah,041h ; + mov bx,055aah ; + mov dl, [drive] ; BIOS drive, 0=A:, 80=C: + test dl,dl ; don't use LBA addressing on A: + jz read_normal_BIOS ; might be a (buggy) + ; CDROM-BOOT floppy emulation + int 0x13 + jc read_normal_BIOS + + shr cx,1 ; CX must have 1 bit set + + sbb bx,0aa55h - 1 ; tests for carry (from shr) too! + jne read_normal_BIOS + ; OK, drive seems to support LBA addressing + lea si,[LBA_PACKET] + ; setup LBA disk block + mov LBA_SECTOR_32,bx ; bx is 0 if extended 13h mode supported + mov LBA_SECTOR_48,bx + + + mov ah,042h + jmp short do_int13_read +%endif + + + +read_normal_BIOS: + +;******************** END OF LBA_READ ************************ + mov cx, LBA_SECTOR_0 + mov dx, LBA_SECTOR_16 + + ; + ; translate sector number to BIOS parameters + ; + ; + ; abs = sector offset in track + ; + head * sectPerTrack offset in cylinder + ; + track * sectPerTrack * nHeads offset in platter + ; + mov al, [sectPerTrack] + mul byte [nHeads] + xchg ax, cx + ; cx = nHeads * sectPerTrack <= 255*63 + ; dx:ax = abs + div cx + ; ax = track, dx = sector + head * sectPertrack + xchg ax, dx + ; dx = track, ax = sector + head * sectPertrack + div byte [sectPerTrack] + ; dx = track, al = head, ah = sector + mov cx, dx + ; cx = track, al = head, ah = sector + + ; the following manipulations are necessary in order to + ; properly place parameters into registers. + ; ch = cylinder number low 8 bits + ; cl = 7-6: cylinder high two bits + ; 5-0: sector + mov dh, al ; save head into dh for bios + xchg ch, cl ; set cyl no low 8 bits + ror cl, 1 ; move track high bits into + ror cl, 1 ; bits 7-6 (assumes top = 0) + or cl, ah ; merge sector into cylinder + inc cx ; make sector 1-based (1-63) + + les bx,[LBA_OFF] + mov ax, 0x0201 +do_int13_read: + mov dl, [drive] + int 0x13 + +read_finished: +%ifdef RETRYALWAYS + jnc read_ok ; jump if no error + xor ah, ah ; else, reset floppy + int 0x13 +read_next_chained: + jmp short read_next ; read the same sector again +%else + jc boot_error ; exit on error +%endif + +read_ok: + mov ax, word [bsBytesPerSec] + shr ax, 4 ; adjust segment pointer by increasing + add word [LBA_SEG], ax ; by paragraphs read in (per sector) + + add LBA_SECTOR_0, byte 1 + adc LBA_SECTOR_16, byte 0 ; DX:AX = next sector to read + dec di ; if there is anything left to read, +%ifdef RETRYALWAYS + jnz read_next_chained ; continue +%else + jnz read_next ; continue +%endif + +read_skip: + mov es, word [LBA_SEG] ; load adjusted segment value + ; clear carry: unnecessary since adc clears it + pop si + ret + + times 0x01f1-$+$$ db 0 +%ifdef MSCOMPAT +filename db "IO SYS" +%else +filename db "IBMBIO COM" +%endif + db 0,0 + +sign dw 0xAA55 + From 9584e214f52033a5940f505b44201f063ca968d3 Mon Sep 17 00:00:00 2001 From: Luchezar Georgiev Date: Thu, 9 Sep 2004 12:17:56 +0000 Subject: [PATCH 562/671] Cleanup & optimisation git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/branches/UNSTABLE@1029 6ac86273-5f31-0410-b378-82cca8765d1b --- docs/history.txt | 1 + kernel/blockio.c | 34 +++-------- kernel/chario.c | 137 ++++++++++++++------------------------------- kernel/country.asm | 32 ++++++++++- kernel/fatdir.c | 92 +++++++++--------------------- kernel/init-mod.h | 4 +- kernel/newstuff.c | 35 ++++-------- kernel/prf.c | 103 ++++++++++++---------------------- kernel/proto.h | 11 ++-- 9 files changed, 160 insertions(+), 289 deletions(-) diff --git a/docs/history.txt b/docs/history.txt index 0497765c..a1551be6 100644 --- a/docs/history.txt +++ b/docs/history.txt @@ -334,6 +334,7 @@ - revision sequence now initialised along with DOS version in LoL - CheckContinueBootFromHardDisk() function code and text cleaned up * makefile: object files reordered to gain ~300B packed size + * newstuff.c, fatdir.c, blockio.c, chario.c, prf.c: cleanup & optimise * portab.h: pragma aux default to gain ~800B unpacked size (Watcom) (the last 2 changes proposed by Bart Oldeman) + Changes Eduardo diff --git a/kernel/blockio.c b/kernel/blockio.c index 0c02db14..5dcae2dd 100644 --- a/kernel/blockio.c +++ b/kernel/blockio.c @@ -47,7 +47,7 @@ static BYTE *blockioRcsId = /************************************************************************/ /* #define DISPLAY_GETBLOCK */ -STATIC BOOL flush1(struct buffer FAR * bp); +STATIC VOID flush1(struct buffer FAR * bp); /* this searches the buffer list for the given disk/block. @@ -155,7 +155,7 @@ STATIC struct buffer FAR *searchblock(ULONG blkno, COUNT dsk) return bp; } -BOOL DeleteBlockInBufferCache(ULONG blknolow, ULONG blknohigh, COUNT dsk, int mode) +VOID DeleteBlockInBufferCache(ULONG blknolow, ULONG blknohigh, COUNT dsk, int mode) { struct buffer FAR *bp = firstbuf; @@ -176,8 +176,6 @@ BOOL DeleteBlockInBufferCache(ULONG blknolow, ULONG blknohigh, COUNT dsk, int mo bp = b_next(bp); } while (FP_OFF(bp) != FP_OFF(firstbuf)); - - return FALSE; } #if TOM @@ -226,8 +224,7 @@ struct buffer FAR *getblk(ULONG blkno, COUNT dsk, BOOL overwrite) /* available, and fill it with the desired block */ /* take the buffer that lbp points to and flush it, then read new block. */ - if (!flush1(bp)) - return NULL; + flush1(bp); /* Fill the indicated disk buffer with the current track and sector */ @@ -262,30 +259,23 @@ VOID setinvld(REG COUNT dsk) /* */ /* Flush all buffers for a disk */ /* */ -/* returns: */ -/* TRUE on success */ -/* */ -BOOL flush_buffers(REG COUNT dsk) +VOID flush_buffers(REG COUNT dsk) { struct buffer FAR *bp = firstbuf; - REG BOOL ok = TRUE; - bp = firstbuf; do { if (bp->b_unit == dsk) - if (!flush1(bp)) - ok = FALSE; + flush1(bp); bp = b_next(bp); } while (FP_OFF(bp) != FP_OFF(firstbuf)); - return ok; } /* */ /* Write one disk buffer */ /* */ -STATIC BOOL flush1(struct buffer FAR * bp) +STATIC VOID flush1(struct buffer FAR * bp) { /* All lines with changes on 9/4/00 by BER marked below */ @@ -320,31 +310,23 @@ STATIC BOOL flush1(struct buffer FAR * bp) bp->b_flag &= ~BFR_DIRTY; /* even if error, mark not dirty */ if (result != 0) /* otherwise system has trouble */ bp->b_flag &= ~BFR_VALID; /* continuing. */ - return (TRUE); /* Forced to TRUE...was like this before dskxfer() */ - /* returned error codes...BER */ } /* */ /* Write all disk buffers */ /* */ -BOOL flush(void) +VOID flush(VOID) { REG struct buffer FAR *bp = firstbuf; - REG BOOL ok; - ok = TRUE; do { - if (!flush1(bp)) - ok = FALSE; + flush1(bp); bp->b_flag &= ~BFR_VALID; bp = b_next(bp); } while (FP_OFF(bp) != FP_OFF(firstbuf)); - network_redirector(REM_FLUSHALL); - - return (ok); } /************************************************************************/ diff --git a/kernel/chario.c b/kernel/chario.c index 53fdd1a4..0740ca7a 100644 --- a/kernel/chario.c +++ b/kernel/chario.c @@ -73,7 +73,7 @@ long BinaryCharIO(struct dhdr FAR **pdev, size_t n, void FAR * bp, CharReqHdr.r_count = n; CharReqHdr.r_trans = bp; err = CharRequest(pdev, command); - } while (err == 1); + } while (err > 0); return err == SUCCESS ? (long)CharReqHdr.r_count : err; } @@ -89,10 +89,7 @@ STATIC int CharIO(struct dhdr FAR **pdev, unsigned char ch, unsigned command) /* STATE FUNCTIONS */ -STATIC void CharCmd(struct dhdr FAR **pdev, unsigned command) -{ - while (CharRequest(pdev, command) == 1); -} +#define CharCmd(pdev, command) while (CharRequest(pdev, command) > 0) STATIC int Busy(struct dhdr FAR **pdev) { @@ -138,103 +135,56 @@ int ndread(struct dhdr FAR **pdev) /* OUTPUT FUNCTIONS */ -#ifdef __WATCOMC__ -void fast_put_char(char c); -#pragma aux fast_put_char = "int 29h" parm[al] modify exact [bx] -#else - -/* writes a character in raw mode using int29 for speed */ -STATIC void fast_put_char(unsigned char chr) -{ -#if defined(__TURBOC__) - _AL = chr; - __int__(0x29); -#elif defined(I86) - asm - { - mov al, byte ptr chr; - int 0x29; - } -#endif -} -#endif - void update_scr_pos(unsigned char c, unsigned char count) { - unsigned char scrpos = scr_pos; - if (c == CR) - scrpos = 0; + scr_pos = 0; else if (c == BS) { - if (scrpos > 0) - scrpos--; - } else if (c != LF && c != BELL) { - scrpos += count; - } - scr_pos = scrpos; + if (scr_pos > 0) + scr_pos--; + } else if (c != LF && c != BELL) + scr_pos += count; } STATIC int raw_get_char(struct dhdr FAR **pdev, BOOL check_break); -/* writes a character in cooked mode; maybe with printer echo; - handles TAB expansion */ -STATIC int cooked_write_char(struct dhdr FAR **pdev, - unsigned char c, - unsigned char *fast_counter) -{ - unsigned char count = 1; - - if (c == HT) { - count = 8 - (scr_pos & 7); - c = ' '; - } - update_scr_pos(c, count); - - do { - - /* if not fast then < 0x80; always check - otherwise check every 32 characters */ - if (*fast_counter <= 0x80 && check_handle_break(pdev) == CTL_S) - /* Test for hold char and ctl_c */ - raw_get_char(pdev, TRUE); - *fast_counter += 1; - *fast_counter &= 0x9f; - - if (PrinterEcho) - DosWrite(STDPRN, 1, &c); - if (*fast_counter & 0x80) - { - fast_put_char(c); - } - else - { - int err = CharIO(pdev, c, C_OUTPUT); - if (err < 0) - return err; - } - } while (--count != 0); - return SUCCESS; -} - long cooked_write(struct dhdr FAR **pdev, size_t n, char FAR *bp) { - size_t xfer = 0; - unsigned char fast_counter; + size_t xfer; /* bit 7 means fastcon; low 5 bits count number of characters */ - fast_counter = ((*pdev)->dh_attr & ATTR_FASTCON) << 3; + unsigned char fast_counter = ((*pdev)->dh_attr & ATTR_FASTCON) << 3; for (xfer = 0; xfer < n; xfer++) { int err; - unsigned char c = *bp++; + unsigned char count = 1, c = *bp++; if (c == CTL_Z) break; - - err = cooked_write_char(pdev, c, &fast_counter); - if (err < 0) - return err; + if (c == HT) { + count = 8 - (scr_pos & 7); + c = ' '; + } + update_scr_pos(c, count); + do { + /* if not fast then < 0x80; always check + otherwise check every 32 characters */ + if (fast_counter <= 0x80 && check_handle_break(pdev) == CTL_S) + raw_get_char(pdev, TRUE); /* Test for hold char and ctl_c */ + fast_counter++; + fast_counter &= 0x9f; + if (PrinterEcho) + DosWrite(STDPRN, 1, &c); + if (fast_counter & 0x80) + put_console(c); + else + { + err = CharIO(pdev, c, C_OUTPUT); + if (err < 0) + return err; + } + } while (--count != 0); } return xfer; } @@ -271,16 +221,15 @@ void write_char_stdout(int c) #define iscntrl(c) ((unsigned char)(c) < ' ') /* this is for handling things like ^C, mostly used in echoed input */ -STATIC int echo_char(int c, int sft_idx) +STATIC VOID echo_char(int c, int sft_idx, unsigned i) { - int out = c; if (iscntrl(c) && c != HT && c != LF && c != CR) { write_char('^', sft_idx); - out += '@'; + c += '@'; } - write_char(out, sft_idx); - return c; + write_char(c, sft_idx); + local_buffer[i] = c; } STATIC void destr_bs(int sft_idx) @@ -407,15 +356,13 @@ void read_line(int sft_in, int sft_out, keyboard FAR * kp) write_char(CR, sft_out); write_char(LF, sft_out); } - break; - case CTL_F: break; case RIGHT: case F1: if (stored_pos < stored_size && count < size - 1) - local_buffer[count++] = echo_char(kp->kb_buf[stored_pos++], sft_out); + echo_char(kp->kb_buf[stored_pos++], sft_out, count++); break; case F2: @@ -441,7 +388,7 @@ void read_line(int sft_in, int sft_out, keyboard FAR * kp) if (c != F4) /* not delete */ { while (stored_pos < new_pos && count < size - 1) - local_buffer[count++] = echo_char(kp->kb_buf[stored_pos++], sft_out); + echo_char(kp->kb_buf[stored_pos++], sft_out, count++); } stored_pos = new_pos; break; @@ -513,12 +460,11 @@ void read_line(int sft_in, int sft_out, keyboard FAR * kp) default: if (count < size - 1 || c == CR) - local_buffer[count++] = echo_char(c, sft_out); + echo_char(c, sft_out, count++); else write_char(BELL, sft_out); if (stored_pos < stored_size && !insert) stored_pos++; - break; } first = FALSE; } while (c != CR); @@ -545,7 +491,8 @@ size_t read_line_handle(int sft_idx, size_t n, char FAR * bp) kb_buf.kb_size = LINEBUFSIZECON; } read_line(sft_idx, sft_idx, &kb_buf); - kb_buf.kb_buf[kb_buf.kb_count + 1] = echo_char(LF, sft_idx); + write_char(LF, sft_idx); + kb_buf.kb_buf[kb_buf.kb_count + 1] = LF; inputptr = kb_buf.kb_buf; if (*inputptr == CTL_Z) { diff --git a/kernel/country.asm b/kernel/country.asm index 204498c6..3606da5b 100644 --- a/kernel/country.asm +++ b/kernel/country.asm @@ -12,7 +12,7 @@ db 0FFh,"COUNTRY",0,0,0,0,0,0,0,0,1,0,1 ; reserved and undocumented values dd ent ; first entry -ent dw 35; number of entries - don't forget to update when adding a new country +ent dw 38; number of entries - don't forget to update when adding a new country ; entries ; (size, country, codepage, reserved(2), offset) @@ -65,12 +65,18 @@ __ar dw 12, 54,850,0,0 dd _ar __br dw 12, 55,850,0,0 dd _br +__my dw 12, 60,437,0,0 + dd _my __au dw 12, 61,437,0,0 dd _au +__sg dw 12, 65,437,0,0 + dd _sg __jp dw 12, 81,932,0,0 dd _jp __kr dw 12, 82,934,0,0 dd _kr +__cn dw 12, 86,936,0,0 + dd _cn __tk dw 12, 90,850,0,0 dd _tk __in dw 12, 91,437,0,0 @@ -140,12 +146,18 @@ _ar dw 1,6,1 dd ar _br dw 1,6,1 dd br +_my dw 1,6,1 + dd my _au dw 1,6,1 dd au +_sg dw 1,6,1 + dd sg _jp dw 1,6,1 dd np _kr dw 1,6,1 dd kr +_cn dw 1,6,1 + dd cn _tk dw 1,6,1 dd tk _in dw 1,6,1 @@ -332,12 +344,24 @@ dw 55,850,DMY db "Cr$",0,0 dw ".",",", "/",":" db 2,2,_24; Brazil +my db 0FFh,"CTYINFO" + dw 22 +dw 60,437,DMY + db "$",0,0,0,0 + dw ",",".", "/",":" + db 0,2,_12; Malaysia au db 0FFh,"CTYINFO" dw 22 dw 61,437,DMY db "$",0,0,0,0 dw ",",".", "-",":" db 0,2,_12; Australia +sg db 0FFh,"CTYINFO" + dw 22 +dw 65,437,DMY + db "$",0,0,0,0 + dw ",",".", "/",":" + db 0,2,_12; Singapore np db 0FFh,"CTYINFO" dw 22 dw 81,932,YMD @@ -350,6 +374,12 @@ dw 82,934,YMD db 5Ch,0,0,0,0 dw ",",".", ".",":" db 0,0,_24; Korea +cn db 0FFh,"CTYINFO" + dw 22 +dw 86,936,YMD + db 0A3h,0A4h,0,0,0 + dw ",",".", ".",":" + db 0,2,_12; China tk db 0FFh,"CTYINFO" dw 22 dw 90,850,DMY diff --git a/kernel/fatdir.c b/kernel/fatdir.c index a8368088..12cc5242 100644 --- a/kernel/fatdir.c +++ b/kernel/fatdir.c @@ -486,35 +486,25 @@ COUNT dos_findnext(void) { ++dmp->dm_entry; ++fnp->f_diroff; - if (fnp->f_dir.dir_name[0] != '\0' && fnp->f_dir.dir_name[0] != DELETED - && !(fnp->f_dir.dir_attrib & D_VOLID)) - { - if (fcmp_wild(dmp->dm_name_pat, fnp->f_dir.dir_name, FNAME_SIZE + FEXT_SIZE)) - { - /* + if (fnp->f_dir.dir_name[0] != '\0' && fnp->f_dir.dir_name[0] != DELETED && + !(fnp->f_dir.dir_attrib & D_VOLID) && + fcmp_wild(dmp->dm_name_pat, fnp->f_dir.dir_name, FNAME_SIZE+FEXT_SIZE) && + /* MSD Command.com uses FCB FN 11 & 12 with attrib set to 0x16. Bits 0x21 seem to get set some where in MSD so Rd and Arc - files are returned. - RdOnly + Archive bits are ignored - */ - - /* Test the attribute as the final step */ - if (!(fnp->f_dir.dir_attrib & D_VOLID) && - !(~dmp->dm_attr_srch & (D_DIR | D_SYSTEM | D_HIDDEN) & - fnp->f_dir.dir_attrib)) - { - /* If found, transfer it to the dmatch structure */ - dmp->dm_dircluster = fnp->f_dirstart; - memcpy(&SearchDir, &fnp->f_dir, sizeof(struct dirent)); - /* return the result */ - release_f_node(fnp); - return SUCCESS; - } - } + files are returned. RdOnly + Archive bits are ignored + */ + /* Test the attribute as the final step */ + !(~dmp->dm_attr_srch & (D_DIR|D_SYSTEM|D_HIDDEN) & fnp->f_dir.dir_attrib)) + { + /* If found, transfer it to the dmatch structure */ + dmp->dm_dircluster = fnp->f_dirstart; + memcpy(&SearchDir, &fnp->f_dir, sizeof(struct dirent)); + /* return the result */ + release_f_node(fnp); + return SUCCESS; } } - - #ifdef DEBUG printf("dos_findnext: %11s\n", fnp->f_dir.dir_name); #endif @@ -536,54 +526,22 @@ COUNT dos_findnext(void) void ConvertName83ToNameSZ(BYTE FAR * destSZ, BYTE FAR * srcFCBName) { int loop; - int noExtension = FALSE; - - if (*srcFCBName == '.') - { - noExtension = TRUE; - } fmemcpy(destSZ, srcFCBName, FNAME_SIZE); - - srcFCBName += FNAME_SIZE; - - for (loop = FNAME_SIZE; --loop >= 0;) - { - if (destSZ[loop] != ' ') - break; - } - destSZ += loop + 1; - - if (!noExtension) /* not for ".", ".." */ + for (loop = FNAME_SIZE; --loop >= 0 && destSZ[loop] == ' '; ) + ; + destSZ += ++loop; + if (*srcFCBName != '.') /* not for ".", ".." */ { - - for (loop = FEXT_SIZE; --loop >= 0;) - { - if (srcFCBName[loop] != ' ') - break; - } - if (loop >= 0) + srcFCBName += FNAME_SIZE; + for (loop = FEXT_SIZE; --loop >= 0 && srcFCBName[loop] == ' '; ) + ; + if (++loop > 0) { *destSZ++ = '.'; - fmemcpy(destSZ, srcFCBName, loop + 1); - destSZ += loop + 1; + fmemcpy(destSZ, srcFCBName, loop); + destSZ += loop; } } *destSZ = '\0'; } - -#if 0 -/* - returns the asciiSZ length of a 8.3 filename -*/ - -int FileName83Length(BYTE * filename83) -{ - BYTE buff[13]; - - ConvertName83ToNameSZ(buff, filename83); - - return strlen(buff); -} -#endif - diff --git a/kernel/init-mod.h b/kernel/init-mod.h index 21026745..a8b0693c 100644 --- a/kernel/init-mod.h +++ b/kernel/init-mod.h @@ -221,8 +221,8 @@ BOOL init_device(struct dhdr FAR *, PCStr cmdLine, int mode, VFP *top); /* prf.c */ -int VA_CDECL init_printf(const char * fmt, ...); -int VA_CDECL init_sprintf(char * buff, const char * fmt, ...); +VOID VA_CDECL init_printf(const char * fmt, ...); +VOID VA_CDECL init_sprintf(char * buff, const char * fmt, ...); /* procsupt.asm */ VOID ASMCFUNC FAR got_cbreak(void); diff --git a/kernel/newstuff.c b/kernel/newstuff.c index bc73c9cc..7ef38f14 100644 --- a/kernel/newstuff.c +++ b/kernel/newstuff.c @@ -43,27 +43,20 @@ int SetJFTSize(UWORD nHandles) psp FAR *ppsp = MK_FP(cu_psp, 0); UBYTE FAR *newtab; - if (nHandles <= ppsp->ps_maxfiles) + if (nHandles > ppsp->ps_maxfiles) { - ppsp->ps_maxfiles = nHandles; - return SUCCESS; + if ((DosMemAlloc + ((nHandles + 0xf) >> 4, mem_access_mode, &block, &maxBlock)) < 0) + return DE_NOMEM; + ++block; + newtab = MK_FP(block, 0); + i = ppsp->ps_maxfiles; + /* copy existing part and fill up new part by "no open file" */ + fmemcpy(newtab, ppsp->ps_filetab, i); + fmemset(newtab + i, 0xff, nHandles - i); + ppsp->ps_filetab = newtab; } - - if ((DosMemAlloc - ((nHandles + 0xf) >> 4, mem_access_mode, &block, &maxBlock)) < 0) - return DE_NOMEM; - - ++block; - newtab = MK_FP(block, 0); - - i = ppsp->ps_maxfiles; - /* copy existing part and fill up new part by "no open file" */ - fmemcpy(newtab, ppsp->ps_filetab, i); - fmemset(newtab + i, 0xff, nHandles - i); - ppsp->ps_maxfiles = nHandles; - ppsp->ps_filetab = newtab; - return SUCCESS; } @@ -89,12 +82,6 @@ long DosMkTmp(BYTE FAR * pathname, UWORD attr) for(i = 7; i >= 0; tmp >>= 4, i--) ptmp[i] = ((char)tmp & 0xf) + 'A'; - /* DOS versions: > 5: characters A - P - < 5: hex digits */ - if (os_major < 5) - for (i = 0; i < 8; i++) - ptmp[i] -= (ptmp[i] < 'A' + 10) ? '0' - 'A' : 10; - /* only create new file -- 2001/09/22 ska*/ rc = DosOpen(pathname, O_LEGACY | O_CREAT | O_RDWR, attr); } while (rc == DE_FILEEXISTS && loop++ < 0xfff); diff --git a/kernel/prf.c b/kernel/prf.c index b2fc643c..eb06e5c2 100644 --- a/kernel/prf.c +++ b/kernel/prf.c @@ -36,7 +36,6 @@ #ifdef _INIT #define handle_char init_handle_char #define put_console init_put_console -#define ltob init_ltob #define do_printf init_do_printf #define printf init_printf #define sprintf init_sprintf @@ -132,9 +131,8 @@ typedef char *va_list; static BYTE *charp = 0; STATIC VOID handle_char(COUNT); -STATIC void ltob(LONG, BYTE *, COUNT); STATIC void do_printf(const char *, REG va_list); -int VA_CDECL printf(const char * fmt, ...); +VOID VA_CDECL printf(const char * fmt, ...); /* special handler to switch between sprintf and printf */ STATIC VOID handle_char(COUNT c) @@ -145,57 +143,21 @@ STATIC VOID handle_char(COUNT c) *charp++ = c; } -/* ltob -- convert an long integer to a string in any base (2-16) */ -STATIC void ltob(LONG n, BYTE * s, COUNT base) -{ - ULONG u; - BYTE *p, *q; - int c; - - u = n; - - if (base == -10) /* signals signed conversion */ - { - base = 10; - if (n < 0) - { - u = -n; - *s++ = '-'; - } - } - - p = s; - do - { /* generate digits in reverse order */ - *p++ = "0123456789abcdef"[(UWORD) (u % base)]; - } - while ((u /= base) > 0); - - *p = '\0'; /* terminate the string */ - for (q = s; q < --p; q++) - { /* reverse the digits */ - c = *q; - *q = *p; - *p = c; - } -} - #define LEFT 0 #define RIGHT 1 #define ZEROSFILL 2 #define LONGARG 4 /* printf -- short version of printf to conserve space */ -int VA_CDECL printf(const char *fmt, ...) +VOID VA_CDECL printf(const char *fmt, ...) { va_list arg; va_start(arg, fmt); charp = 0; do_printf(fmt, arg); - return 0; } -int VA_CDECL sprintf(char * buff, const char * fmt, ...) +VOID VA_CDECL sprintf(char * buff, const char * fmt, ...) { va_list arg; @@ -203,15 +165,13 @@ int VA_CDECL sprintf(char * buff, const char * fmt, ...) charp = buff; do_printf(fmt, arg); handle_char('\0'); - return 0; } STATIC void do_printf(CONST BYTE * fmt, va_list arg) { - int base; - BYTE s[11], FAR * p; - int size; - unsigned char flags; + int base, size; + char s[13]; /* long enough for a 32-bit octal number string with sign */ + char flags, FAR *p; for (;*fmt != '\0'; fmt++) { @@ -302,17 +262,33 @@ STATIC void do_printf(CONST BYTE * fmt, va_list arg) lprt: { - long currentArg; + long n; + ULONG u; + BYTE *t = s + sizeof(s) - 1; + if (flags & LONGARG) - currentArg = va_arg(arg, long); + n = va_arg(arg, long); else { - currentArg = va_arg(arg, int); + n = va_arg(arg, int); if (base >= 0) - currentArg = (long)(unsigned)currentArg; + n = (long)(unsigned)n; } - ltob(currentArg, s, base); - p = s; + /* convert a long integer to a string in any base (2-16) */ + u = n; + if (base < 0) /* signals signed conversion */ + { + base = -base; + if (n < 0) + u = -n; + } + *t = '\0'; /* terminate the number string */ + do /* generate digits in reverse order */ + *--t = "0123456789ABCDEF"[(UWORD)u % base]; + while ((u /= base) > 0); + if (n < 0) + *--t = '-'; + p = t; } break; @@ -378,19 +354,15 @@ void hexd(char *title, UBYTE FAR * p, COUNT numBytes) /* put_unsigned -- print unsigned int in base 2--16 */ void put_unsigned(unsigned n, int base, int width) { - char s[6]; - int i; + char s[6]; /* CAUTION: width must be [0..5] and is not checked! */ - for (i = 0; i < width; i++) + s[width] = '\0'; /* terminate the number string */ + while (--width >= 0) { /* generate digits in reverse order */ - s[i] = "0123456789abcdef"[(UWORD) (n % base)]; + s[width] = "0123456789ABCDEF"[n % base]; n /= base; } - - while(i != 0) - { /* print digits in reverse order */ - put_console(s[--i]); - } + put_string(s); } void put_string(const char *s) @@ -408,19 +380,14 @@ void put_string(const char *s) compile like (note -DTEST !) - c:\tc\tcc -DTEST -DI86 -I..\hdr prf.c + c:\tc\tcc -DTEST -DI86 -Ihdr kernel\prf.c - and run. if strings are wrong, the program will wait for the ANYKEY + and run. If strings are wrong, the program will wait for ENTER */ #include #include -void cso(char c) -{ - putchar(c); -} - struct { char *should; char *format; diff --git a/kernel/proto.h b/kernel/proto.h index 700c4a06..515e50ff 100644 --- a/kernel/proto.h +++ b/kernel/proto.h @@ -38,10 +38,10 @@ struct buffer FAR *getblk(ULONG blkno, COUNT dsk, BOOL overwrite); #define getblock(blkno, dsk) getblk(blkno, dsk, FALSE); #define getblockOver(blkno, dsk) getblk(blkno, dsk, TRUE); VOID setinvld(REG COUNT dsk); -BOOL flush_buffers(REG COUNT dsk); -BOOL flush(void); +VOID flush_buffers(REG COUNT dsk); +VOID flush(void); BOOL fill(REG struct buffer FAR * bp, ULONG blkno, COUNT dsk); -BOOL DeleteBlockInBufferCache(ULONG blknolow, ULONG blknohigh, COUNT dsk, int mode); +VOID DeleteBlockInBufferCache(ULONG blknolow, ULONG blknohigh, COUNT dsk, int mode); /* *** Changed on 9/4/00 BER */ UWORD dskxfer(COUNT dsk, ULONG blkno, VOID FAR * buf, UWORD numblocks, COUNT mode); @@ -60,7 +60,6 @@ void handle_break(struct dhdr FAR **pdev, int sft_out); struct dhdr FAR *sft_to_dev(sft FAR *sft); long BinaryCharIO(struct dhdr FAR **pdev, size_t n, void FAR * bp, unsigned command); -int echo_char(int c, int sft_idx); int ndread(struct dhdr FAR **pdev); int StdinBusy(void); void con_flush(struct dhdr FAR **pdev); @@ -295,8 +294,8 @@ UWORD ASMCFUNC syscall_MUX14(DIRECT_IREGS); /* prf.c */ #ifdef DEBUG -int VA_CDECL printf(const char * fmt, ...); -int VA_CDECL sprintf(char * buff, const char * fmt, ...); +VOID VA_CDECL printf(const char * fmt, ...); +VOID VA_CDECL sprintf(char * buff, const char * fmt, ...); #endif VOID hexd(char *title, VOID FAR * p, COUNT numBytes); void put_unsigned(unsigned n, int base, int width); From b3a4a7eda14bcf9ba920bc3a28a12dec3a2d0d5a Mon Sep 17 00:00:00 2001 From: Luchezar Georgiev Date: Thu, 9 Sep 2004 12:29:09 +0000 Subject: [PATCH 563/671] Clobber oem*.h too git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/branches/UNSTABLE@1030 6ac86273-5f31-0410-b378-82cca8765d1b --- sys/makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/makefile b/sys/makefile index 283248ec..93f5799b 100644 --- a/sys/makefile +++ b/sys/makefile @@ -44,4 +44,4 @@ clean: -$(RM) *.bak *.cod *.crf *.err *.las *.lst *.map *.obj *.xrf clobber: clean - -$(RM) bin2c.com fat*.h status.me + -$(RM) bin2c.com fat*.h oem*.h status.me From 6a3380a10a2eed7a8d9e252c24c749eecd91f39d Mon Sep 17 00:00:00 2001 From: Luchezar Georgiev Date: Thu, 9 Sep 2004 14:06:23 +0000 Subject: [PATCH 564/671] Israeli country information was referring to Middle East. Watcom AUX DEFAULT pragma works only for 80386 and above. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/branches/UNSTABLE@1031 6ac86273-5f31-0410-b378-82cca8765d1b --- hdr/portab.h | 2 +- kernel/country.asm | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/hdr/portab.h b/hdr/portab.h index 19d91d44..875d80f2 100644 --- a/hdr/portab.h +++ b/hdr/portab.h @@ -123,7 +123,7 @@ unsigned short getSS(void); #pragma aux getSS = "mov dx,ss" value [dx] modify exact[dx]; /* enable Possible loss of precision warning for compatibility with Borland */ #pragma enable_message(130) -#if !defined(FORSYS) && !defined(EXEFLAT) +#if !defined(FORSYS) && !defined(EXEFLAT) && _M_IX86 >= 300 #pragma aux default parm [ax dx cx] modify [ax dx es fs] /* min.unpacked size */ /* #pragma aux default parm [ax dx] modify [ax bx cx dx es fs]min.packed size */ #endif diff --git a/kernel/country.asm b/kernel/country.asm index 3606da5b..8e3733d5 100644 --- a/kernel/country.asm +++ b/kernel/country.asm @@ -92,7 +92,7 @@ __ua dw 12,380,848,0,0 __me dw 12,785,864,0,0 dd _me __il dw 12,972,862,0,0 - dd _me + dd _il ; subfunction headers (so far only for subfunction 1, "CTYINFO") ; (count, size, id, offset) @@ -173,7 +173,7 @@ _ua dw 1,6,1 _me dw 1,6,1 dd me _il dw 1,6,1 - dd me + dd il %define MDY 0 ; month/day/year %define DMY 1 ; day/month/year From ac6ae249318cadd0b239915aa2bf4850e2d91311 Mon Sep 17 00:00:00 2001 From: Luchezar Georgiev Date: Thu, 9 Sep 2004 19:14:46 +0000 Subject: [PATCH 565/671] Using a macro for country data git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/branches/UNSTABLE@1032 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/country.asm | 288 +++++++++------------------------------------ 1 file changed, 53 insertions(+), 235 deletions(-) diff --git a/kernel/country.asm b/kernel/country.asm index 8e3733d5..ca36be90 100644 --- a/kernel/country.asm +++ b/kernel/country.asm @@ -77,8 +77,8 @@ __kr dw 12, 82,934,0,0 dd _kr __cn dw 12, 86,936,0,0 dd _cn -__tk dw 12, 90,850,0,0 - dd _tk +__tr dw 12, 90,850,0,0 + dd _tr __in dw 12, 91,437,0,0 dd _in __pt dw 12,351,860,0,0 @@ -158,8 +158,8 @@ _kr dw 1,6,1 dd kr _cn dw 1,6,1 dd cn -_tk dw 1,6,1 - dd tk +_tr dw 1,6,1 + dd tr _in dw 1,6,1 dd ia _pt dw 1,6,1 @@ -197,236 +197,54 @@ _il dw 1,6,1 ; 1 if currency symbol follows value ; Currencyp : Currency precision ; Time format : 0=12 hour format (AM/PM), 1=24 hour format (4:12 PM is 16:12) -; -; ID CP DF currency 1000 0.1 DS TS CF Pr TF Country/Locale Contributor -;------------------------------------------------------------------------------ -us db 0FFh,"CTYINFO" + +%macro cnf 15 + db 0FFh,"CTYINFO" dw 22; length -dw 1,437,MDY - db "$",0,0,0,0 - dw ",",".", "-",":" - db 0,2,_12; United States -ca db 0FFh,"CTYINFO" - dw 22 -dw 2,863,YMD - db "$",0,0,0,0 - dw " ",",", "-",":" - db 3,2,_24; Canadian French -la db 0FFh,"CTYINFO" - dw 22 -dw 3,850,DMY - db "$",0,0,0,0 - dw ",",".", "/",":" - db 0,2,_12; Latin America -ru db 0FFh,"CTYINFO" - dw 22 -dw 7,866,DMY - db "RUB",0,0 - dw " ",",", ".",":" - db 3,2,_24; Russia Arkady V. Belousov -gr db 0FFh,"CTYINFO" - dw 22 -dw 30,869,DMY - db "EYP",0,0 - dw ".",",", "/",":" - db 1,2,_12; Greece -nl db 0FFh,"CTYINFO" - dw 22 -dw 31,850,DMY - db "EUR",0,0 - dw ".",",", "-",":" - db 0,2,_24; Netherlands Bart E. Oldeman -be db 0FFh,"CTYINFO" - dw 22 -dw 32,850,DMY - db "EUR",0,0 - dw ".",",", "/",":" - db 0,2,_24; Belgium -fr db 0FFh,"CTYINFO" - dw 22 -dw 33,850,DMY - db "EUR",0,0 - dw " ",",", ".",":" - db 0,2,_24; France -sn db 0FFh,"CTYINFO" - dw 22 -dw 34,850,DMY - db "EUR",0,0 - dw ".",",", "/",":" - db 0,2,_24; Spain Aitor S. Merino -hu db 0FFh,"CTYINFO" - dw 22 -dw 36,852,YMD - db "Ft",0,0,0 - dw " ",",", ".",":" - db 3,2,_24; Hungary -yu db 0FFh,"CTYINFO" - dw 22 -dw 38,852,YMD - db "Din",0,0 - dw ".",",", "-",":" - db 2,2,_24; Yugoslavia -it db 0FFh,"CTYINFO" - dw 22 -dw 39,850,DMY - db "EUR",0,0 - dw ".",",", "/","." - db 0,2,_24; Italy -ro db 0FFh,"CTYINFO" - dw 22 -dw 40,852,YMD - db "Lei",0,0 - dw ".",",", "-",":" - db 0,2,_24; Romania -sw db 0FFh,"CTYINFO" - dw 22 -dw 41,850,DMY - db "Fr.",0,0 - dw "'",".", ".","," - db 2,2,_24; Switzerland -cz db 0FFh,"CTYINFO" - dw 22 -dw 42,852,YMD - db "KCs",0,0 - dw ".",",", "-",":" - db 2,2,_24; Czechoslovakia -as db 0FFh,"CTYINFO" - dw 22 -dw 43,850,DMY - db "EUR",0,0 - dw ".",",", ".","." - db 0,2,_24; Austria -uk db 0FFh,"CTYINFO" - dw 22 -dw 44,850,DMY - db 9ch,0,0,0,0 - dw ",",".", "/",":" - db 0,2,_24; United Kingdom -dk db 0FFh,"CTYINFO" - dw 22 -dw 45,865,DMY - db "kr",0,0,0 - dw ".",",", "-","." - db 2,2,_24; Denmark -se db 0FFh,"CTYINFO" - dw 22 -dw 46,850,YMD - db "Kr",0,0,0 - dw " ",",", "-","." - db 3,2,_24; Sweden -no db 0FFh,"CTYINFO" - dw 22 -dw 47,865,DMY - db "Kr",0,0,0 - dw ".",",", ".",":" - db 2,2,_24; Norway -pl db 0FFh,"CTYINFO" - dw 22 -dw 48,852,YMD - db "Z",88h,0,0,0 - dw ".",",", "-",":" - db 0,2,_24; Poland Michal H. Tyc -de db 0FFh,"CTYINFO" - dw 22 -dw 49,850,DMY - db "EUR",0,0 - dw ".",",", ".","." - db 1,2,_24; Germany Tom Ehlert -ar db 0FFh,"CTYINFO" - dw 22 -dw 54,850,DMY - db "$",0,0,0,0 - dw ".",",", "/","." - db 0,2,_24; Argentina -br db 0FFh,"CTYINFO" - dw 22 -dw 55,850,DMY - db "Cr$",0,0 - dw ".",",", "/",":" - db 2,2,_24; Brazil -my db 0FFh,"CTYINFO" - dw 22 -dw 60,437,DMY - db "$",0,0,0,0 - dw ",",".", "/",":" - db 0,2,_12; Malaysia -au db 0FFh,"CTYINFO" - dw 22 -dw 61,437,DMY - db "$",0,0,0,0 - dw ",",".", "-",":" - db 0,2,_12; Australia -sg db 0FFh,"CTYINFO" - dw 22 -dw 65,437,DMY - db "$",0,0,0,0 - dw ",",".", "/",":" - db 0,2,_12; Singapore -np db 0FFh,"CTYINFO" - dw 22 -dw 81,932,YMD - db 81h,8fh,0,0,0 - dw ",",".", "-",":" - db 0,0,_24; Japan Yuki Mitsui -kr db 0FFh,"CTYINFO" - dw 22 -dw 82,934,YMD - db 5Ch,0,0,0,0 - dw ",",".", ".",":" - db 0,0,_24; Korea -cn db 0FFh,"CTYINFO" - dw 22 -dw 86,936,YMD - db 0A3h,0A4h,0,0,0 - dw ",",".", ".",":" - db 0,2,_12; China -tk db 0FFh,"CTYINFO" - dw 22 -dw 90,850,DMY - db "TL",0,0,0 - dw ".",",", "/",":" - db 4,2,_24; Turkey -ia db 0FFh,"CTYINFO" - dw 22 -dw 91,437,DMY - db "Rs",0,0,0 - dw ".",",", "/",":" - db 0,2,_24; India -pt db 0FFh,"CTYINFO" - dw 22 -dw 351,860,DMY - db "EUR",0,0 - dw ".",",", "-",":" - db 0,2,_24; Portugal -fi db 0FFh,"CTYINFO" - dw 22 -dw 358,850,DMY - db "EUR",0,0 - dw " ",",", ".","." - db 3,2,_24; Finland Wolf -bg db 0FFh,"CTYINFO" - dw 22 -dw 359,855,DMY - db "BGL",0,0 - dw " ",",", ".","," - db 3,2,_24; Bulgaria Luchezar Georgiev -ua db 0FFh,"CTYINFO" - dw 22 -dw 380,848,DMY - db "UAH",0,0 - dw " ",",", ".",":" - db 3,2,_24; Ukraine Oleg Deribas -me db 0FFh,"CTYINFO" - dw 22 -dw 785,864,DMY - db 0A4h,0,0,0,0 - dw ".",",", "/",":" - db 3,3,_12; Middle East -il db 0FFh,"CTYINFO" - dw 22 -dw 972,862,DMY - db 99h,0,0,0,0 - dw ",",".", " ",":" - db 2,2,_24; Israel +dw %1,%2,%3 ; ID,CP,DF + db %4,%5,%6,%7,%8 ; currency + dw %9,%10, %11,%12 ; 1000, 0.1, DS,TS + db %13,%14,%15 ; CF,Pr,TF +%endmacro;| | | | | | | | | | | +; ID CP DF currency 1000 0.1 DS TS CF Pr TF Country Contributor +;------------------------------------------------------------------------------ +us cnf 1,437,MDY,"$", 0,0,0,0,",",".", "-",":",0,2,_12; United States +ca cnf 2,863,YMD,"$", 0,0,0,0," ",",", "-",":",3,2,_24; French Canada +la cnf 3,850,DMY,"$", 0,0,0,0,",",".", "/",":",0,2,_12; Latin America +ru cnf 7,866,DMY,"R","U","B",0,0," ",",", ".",":",3,2,_24; Russia Arkady +gr cnf 30,869,DMY,"E","Y","P",0,0,".",",", "/",":",1,2,_12; Greece +nl cnf 31,850,DMY,"E","U","R",0,0,".",",", "-",":",0,2,_24; Netherlands Bart +be cnf 32,850,DMY,"E","U","R",0,0,".",",", "/",":",0,2,_24; Belgium +fr cnf 33,850,DMY,"E","U","R",0,0," ",",", ".",":",0,2,_24; France +sn cnf 34,850,DMY,"E","U","R",0,0,".",",", "/",":",0,2,_24; Spain Aitor +hu cnf 36,852,YMD,"F","t", 0,0,0," ",",", ".",":",3,2,_24; Hungary +yu cnf 38,852,YMD,"D","i","n",0,0,".",",", "-",":",2,2,_24; Yugoslavia +it cnf 39,850,DMY,"E","U","R",0,0,".",",", "/",".",0,2,_24; Italy +ro cnf 40,852,YMD,"L","e","i",0,0,".",",", "-",":",0,2,_24; Romania +sw cnf 41,850,DMY,"F","r",".",0,0,"'",".", ".",",",2,2,_24; Switzerland +cz cnf 42,852,YMD,"K","C","s",0,0,".",",", "-",":",2,2,_24; Czechoslovakia +as cnf 43,850,DMY,"E","U","R",0,0,".",",", ".",".",0,2,_24; Austria +uk cnf 44,850,DMY,9Ch, 0,0,0,0,",",".", "/",":",0,2,_24; United Kingdom +dk cnf 45,865,DMY,"k","r", 0,0,0,".",",", "-",".",2,2,_24; Denmark +se cnf 46,850,YMD,"K","r", 0,0,0," ",",", "-",".",3,2,_24; Sweden +no cnf 47,865,DMY,"K","r", 0,0,0,".",",", ".",":",2,2,_24; Norway +pl cnf 48,852,YMD,"Z",88h, 0,0,0,".",",", "-",":",0,2,_24; Poland Michal +de cnf 49,850,DMY,"E","U","R",0,0,".",",", ".",".",1,2,_24; Germany Tom +ar cnf 54,850,DMY,"$", 0,0,0,0,".",",", "/",".",0,2,_24; Argentina +br cnf 55,850,DMY,"C","r","$",0,0,".",",", "/",":",2,2,_24; Brazil +my cnf 60,437,DMY,"$", 0,0,0,0,",",".", "/",":",0,2,_12; Malaysia +au cnf 61,437,DMY,"$", 0,0,0,0,",",".", "-",":",0,2,_12; Australia +sg cnf 65,437,DMY,"$", 0,0,0,0,",",".", "/",":",0,2,_12; Singapore +np cnf 81,932,YMD,81h,8fh, 0,0,0,",",".", "-",":",0,0,_24; Japan Yuki +kr cnf 82,934,YMD,5Ch, 0,0,0,0,",",".", ".",":",0,0,_24; Korea +cn cnf 86,936,YMD,0A3h,0A4h,0,0,0,",",".", ".",":",0,2,_12; China +tr cnf 90,850,DMY,"T","L", 0,0,0,".",",", "/",":",4,2,_24; Turkey +ia cnf 91,437,DMY,"R","s", 0,0,0,".",",", "/",":",0,2,_24; India +pt cnf 351,860,DMY,"E","U","R",0,0,".",",", "-",":",0,2,_24; Portugal +fi cnf 358,850,DMY,"E","U","R",0,0," ",",", ".",".",3,2,_24; Finland Wolf +bg cnf 359,855,DMY,"B","G","L",0,0," ",",", ".",",",3,2,_24; Bulgaria Luchezar +ua cnf 380,848,DMY,"U","A","H",0,0," ",",", ".",":",3,2,_24; Ukraine Oleg +me cnf 785,864,DMY,0A4h, 0,0,0,0,".",",", "/",":",3,3,_12; Middle East +il cnf 972,862,DMY,99h, 0,0,0,0,",",".", " ",":",2,2,_24; Israel -db "FreeDOS" ; trailing, as recommended by RBIL +db "FreeDOS" ; Trailing - as recommended by the Ralf Brown Interrupt List From 7aaf2cae377e072f717746517985a4a3ddce14b0 Mon Sep 17 00:00:00 2001 From: Luchezar Georgiev Date: Fri, 10 Sep 2004 07:43:05 +0000 Subject: [PATCH 566/671] Fix warning and typo git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/branches/UNSTABLE@1033 6ac86273-5f31-0410-b378-82cca8765d1b --- sys/sys.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/sys/sys.c b/sys/sys.c index c9ea94be..cb4700c2 100644 --- a/sys/sys.c +++ b/sys/sys.c @@ -415,7 +415,7 @@ int main(int argc, char **argv) " to write to *instead* of real boot sector\n" " BOTH : write to *both* the real boot sector and the image file\n" " /BOOTONLY: do *not* copy kernel / shell, only update boot sector or image\n" - " /OEM : indicates kernel is IBMIO.SYS/IBMDOS.SYS loaded at 0x70\n" + " /OEM : indicates kernel is IBMBIO.COM/IBMDOS.COM loaded at 0x70\n" #ifdef WITHOEMCOMPATBS " /OEM:DR use IBMBIO.COM/IBMDOS.SYS and FD boot sector (default)\n" " /OEM:PC use PC-DOS compatible boot sector\n" @@ -823,6 +823,10 @@ void put_boot(int drive, char *bsFile, char *kernel_name, int load_seg, int both static unsigned char oldboot[SEC_SIZE], newboot[SEC_SIZE]; static unsigned char default_bpb[0x5c]; +#ifndef WITHOEMCOMPATBS + UNREFERENCED_PARAMETER(altkern); +#endif + #ifdef DEBUG printf("Reading old bootsector from drive %c:\n", drive + 'A'); #endif From 6eff2f4bb2c5c2920c4a6e0dc7ffd8cdb5834e93 Mon Sep 17 00:00:00 2001 From: Kenneth J Davis Date: Sat, 11 Sep 2004 13:42:30 +0000 Subject: [PATCH 567/671] correct non8086 division in bootcode, add boot drive option to sys git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/branches/UNSTABLE@1034 6ac86273-5f31-0410-b378-82cca8765d1b --- boot/boot.asm | 13 ++++++++----- sys/sys.c | 41 +++++++++++++++++++++++++++++++++-------- 2 files changed, 41 insertions(+), 13 deletions(-) diff --git a/boot/boot.asm b/boot/boot.asm index ee6ff75a..0e20a717 100644 --- a/boot/boot.asm +++ b/boot/boot.asm @@ -122,7 +122,7 @@ Entry: jmp short real_start %define READADDR_SEG BP-0x60-0x1802 %define PARAMS LBA_PACKET+0x10 -%define RootDirSecs PARAMS+0x0 ; # of sectors root dir uses +;%define RootDirSecs PARAMS+0x0 ; # of sectors root dir uses %define fat_start PARAMS+0x2 ; first FAT sector @@ -210,7 +210,8 @@ dont_use_dl: ; no, rely on [drive] written by SYS xor dx, dx div bx - mov word [RootDirSecs], ax ; AX = sectors per root directory +; mov word [RootDirSecs], ax ; AX = sectors per root directory + push ax add si, ax adc di, byte 0 ; DI:SI = first data sector @@ -229,7 +230,7 @@ dont_use_dl: ; no, rely on [drive] written by SYS mov ax, word [root_dir_start] mov dx, word [root_dir_start+2] - mov di, word [RootDirSecs] + pop di ; mov di, word [RootDirSecs] les bx, [loadsegoff_60] ; es:bx = 60:0 call readDisk les di, [loadsegoff_60] ; es:di = 60:0 @@ -366,7 +367,7 @@ show: pop si boot_error: call show ; db "Error! Hit a key to reboot." - db "Err." + db "Error!." xor ah,ah int 0x13 ; reset floppy @@ -487,7 +488,9 @@ do_int13_read: rep movsb pop di - shr ax, 4 ; adjust segment pointer by increasing +; div byte[LBA_PACKET] ; luckily 16 !! + mov cl, 4 + shr ax, cl ; adjust segment pointer by increasing add word [READADDR_SEG], ax ; by paragraphs read in (per sector) add LBA_SECTOR_0, byte 1 diff --git a/sys/sys.c b/sys/sys.c index cb4700c2..481cf569 100644 --- a/sys/sys.c +++ b/sys/sys.c @@ -186,7 +186,7 @@ char *getenv(const char *name) BYTE pgm[] = "SYS"; -void put_boot(int, char *, char *, int, int, int); +void put_boot(int, char *, char *, int, int, int, int); BOOL check_space(COUNT, ULONG); BOOL get_full_path(BYTE * srcPath, BYTE * rootPath, BYTE * filename, BYTE *source); BOOL copy(BYTE *source, COUNT drive, BYTE * filename); @@ -303,6 +303,7 @@ int main(int argc, char **argv) int argno = 0; int bootonly = 0; int both = 0; + int bootdrive = -1; /* -1 means default processing, else value to use */ char *kernel_name = FDKERNEL; int load_segment = FDLOADSEG; int altkern = NO_OEMKERN; /* use OEM kernel values instead of FD ones */ @@ -388,6 +389,24 @@ int main(int argc, char **argv) { load_segment = (int)strtol(argv[argno], NULL, 16); } + else if (memicmp(argp, "B", 2) == 0) /* set boot drive # */ + { + /* BIOS drive number to put in boot sector, normally this is + 0 for A, 80 for 1st hard drive, 81 2nd hd, etc, and + FF for FreeDOS bootsector will force use of value passed + in DL by BIOS. */ + bootdrive = (BYTE)strtol(argv[argno], NULL, 16); + } + else /* unknown option */ + { + drivearg = 0; + break; + } + } + else /* invalid option or missing value portion */ + { + drivearg = 0; + break; } } else if (drivearg != argno) @@ -396,7 +415,7 @@ int main(int argc, char **argv) { bsFile = argp; } - else + else /* invalid usage */ { drivearg = 0; break; @@ -417,12 +436,13 @@ int main(int argc, char **argv) " /BOOTONLY: do *not* copy kernel / shell, only update boot sector or image\n" " /OEM : indicates kernel is IBMBIO.COM/IBMDOS.COM loaded at 0x70\n" #ifdef WITHOEMCOMPATBS - " /OEM:DR use IBMBIO.COM/IBMDOS.SYS and FD boot sector (default)\n" + " /OEM:DR use IBMBIO.COM/IBMDOS.COM and FD boot sector (default)\n" " /OEM:PC use PC-DOS compatible boot sector\n" " /OEM:MS use PC-DOS compatible boot sector with IO.SYS/MSDOS.SYS\n" #endif " /K name : name of kernel to use instead of KERNEL.SYS\n" " /L segm : hex load segment to use instead of 60\n" + " /B btdrv : hex BIOS # of boot drive, FF=BIOS provided, 0=A:, 80=1st hd,...\n" "%s CONFIG /help\n", pgm, pgm); exit(1); } @@ -489,7 +509,7 @@ int main(int argc, char **argv) } printf("Processing boot sector...\n"); - put_boot(drive, bsFile, kernel_name, load_segment, both, altkern); + put_boot(drive, bsFile, kernel_name, load_segment, both, altkern, bootdrive); if (!bootonly) { @@ -814,7 +834,9 @@ void correct_bpb(struct bootsectortype *default_bpb, oldboot->bsHiddenSecs = default_bpb->bsHiddenSecs; } -void put_boot(int drive, char *bsFile, char *kernel_name, int load_seg, int both, int altkern) +void put_boot(int drive, char *bsFile, + char *kernel_name, int load_seg, int both, + int altkern, int bootdrive) { #ifdef WITHFAT32 struct bootsectortype32 *bs32; @@ -900,7 +922,7 @@ void put_boot(int drive, char *bsFile, char *kernel_name, int load_seg, int both if (altkern >= 2) /* MS or PC compatible BS requested */ { printf("%s: FAT32 versions of PC/MS DOS compatible boot sectors\n" - "are not supported [yet].\n"); + "are not supported [yet].\n", pgm); exit(1); } #endif @@ -948,12 +970,15 @@ void put_boot(int drive, char *bsFile, char *kernel_name, int load_seg, int both /* originally OemName was "FreeDOS", changed for better compatibility */ memcpy(bs->OemName, "FRDOS4.1", 8); + /* allow user to override default of use BIOS provided boot drive # */ + bootdrive = (bootdrive < 0)? (drive < 2 ? 0 : 0xff) : bootdrive; + #ifdef WITHFAT32 if (fs == FAT32) { bs32 = (struct bootsectortype32 *)&newboot; /* put 0 for A: or B: (force booting from A:), otherwise use DL */ - bs32->bsDriveNumber = drive < 2 ? 0 : 0xff; + bs32->bsDriveNumber = bootdrive; /* the location of the "0060" segment portion of the far pointer in the boot sector is just before cont: in boot*.asm. This happens to be offset 0x78 (=0x3c * 2) for FAT32 and @@ -972,7 +997,7 @@ void put_boot(int drive, char *bsFile, char *kernel_name, int load_seg, int both #endif { /* put 0 for A: or B: (force booting from A:), otherwise use DL */ - bs->bsDriveNumber = drive < 2 ? 0 : 0xff; + bs->bsDriveNumber = bootdrive; #ifdef WITHOEMCOMPATBS if (altkern < 2) /* PC-DOS compatible bs has fixed load sector */ #endif From 79720273dcdaa943ec967397b11071964c83fe55 Mon Sep 17 00:00:00 2001 From: Luchezar Georgiev Date: Sat, 11 Sep 2004 15:52:57 +0000 Subject: [PATCH 568/671] break.c: check_handle_break() return type was undefined if no Ctrl-break dosnames.c: macro to function conversion, optimisation and clean-up dyninit.c: "what" passed to the DynAlloc() function only in DEBUG mode inithma.c: InstallVDISK() function inlined, optimised and cleaned up prf.c: fixed long argument bug introduced in the previous optimisation git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/branches/UNSTABLE@1035 6ac86273-5f31-0410-b378-82cca8765d1b --- docs/history.txt | 7 +++-- kernel/break.c | 4 +-- kernel/dosnames.c | 46 +++++++---------------------- kernel/dyndata.h | 6 ++++ kernel/dyninit.c | 8 +++--- kernel/inithma.c | 73 ++++++++++++++++++----------------------------- kernel/prf.c | 20 +++++++------ 7 files changed, 67 insertions(+), 97 deletions(-) diff --git a/docs/history.txt b/docs/history.txt index a1551be6..ce1d18f2 100644 --- a/docs/history.txt +++ b/docs/history.txt @@ -308,11 +308,13 @@ (the last 2 changes needed to fix bugs discovered by Michael Devore) - added Int 2Fh/2Fh processing to set DOS version as per MS-DOS 4.0 * autoexec.bat now single-line for FreeCOM compatibility when EOL=LF + * break.c: check_handle_break() return was undefined if no Ctrl-break * config.sys: all commands removed as they were close to defaults * contrib.txt: added Aitor Santamaria, Bernd Blaauw and Eduardo Casino * country.asm / country.sys support now replaces hard-coded data - * 8 countries added to country.asm: GR, RO, AT, KR, TR, IN, M.East, IL - * dyninit.c: unused function DynFree() commented out + * 11 countries added to country.asm: GR,RO,AT,MA,SG,KR,CN,TR,IN,M.E,IL + * dosnames.c: macro to function conversion, optimisation and clean-up + * dyninit.c: excluded unused DynFree(), "what" passed only on DEBUG * fatfs.c: - zero creation/access stamp on directory entry write as MS-DOS 7.10 - prevent removal or renaming of the current directory of that drive @@ -323,6 +325,7 @@ - if no floppy drives present, don't initialise DDT for drive A: - " - Initdisk" no longer shifts text if no FAT partitions found - converted cdiv() from macro to function; optimise and clean-up + * inithma: InstallVDISK() function inlined, optimised and cleaned up * intr.asm: lseek() added (necessary for COUNTRY.SYS processing) * ioctl.c: - r_si/r_di contents added as documented in PC-DOS Technical Update diff --git a/kernel/break.c b/kernel/break.c index 7ad29633..a8d3218d 100644 --- a/kernel/break.c +++ b/kernel/break.c @@ -53,7 +53,7 @@ unsigned char ctrl_break_pressed(void) unsigned char check_handle_break(struct dhdr FAR **pdev) { - unsigned char c; + unsigned char c = 0; if (ctrl_break_pressed() || (c = (unsigned char)ndread(&syscon)) == CTL_C || *pdev != syscon && (c = (unsigned char)ndread(pdev)) == CTL_C) @@ -76,7 +76,7 @@ unsigned char check_handle_break(struct dhdr FAR **pdev) void handle_break(struct dhdr FAR **pdev, int sft_out) { - char *buf = "^C\r\n"; + static char *buf = "^C\r\n"; CB_FLG &= ~CB_MSK; /* reset the ^Break flag */ con_flush(pdev); diff --git a/kernel/dosnames.c b/kernel/dosnames.c index 0d53d6a0..c474d7df 100644 --- a/kernel/dosnames.c +++ b/kernel/dosnames.c @@ -39,30 +39,10 @@ static BYTE *dosnamesRcsId = const char _DirWildNameChars[] = "*?./\\\"[]:|<>+=;,"; -#define PathSep(c) ((c)=='/'||(c)=='\\') -#define DriveChar(c) (((c)>='A'&&(c)<='Z')||((c)>='a'&&(c)<='z')) -#define DirChar(c) (((unsigned char)(c)) >= ' ' && \ - !strchr(_DirWildNameChars+5, (c))) -#define WildChar(c) (((unsigned char)(c)) >= ' ' && \ - !strchr(_DirWildNameChars+2, (c))) -#define NameChar(c) (((unsigned char)(c)) >= ' ' && \ - !strchr(_DirWildNameChars, (c))) - -VOID XlateLcase(BYTE * szFname, COUNT nChars); -VOID DosTrimPath(BYTE * lpszPathNamep); - -/* Should be converted to a portable version after v1.0 is released. */ -#if 0 -VOID XlateLcase(BYTE * szFname, COUNT nChars) +STATIC BOOL charOK(const char *s, const char c) { - while (nChars--) - { - if (*szFname >= 'a' && *szFname <= 'z') - *szFname -= ('a' - 'A'); - ++szFname; - } + return (UBYTE)c >= ' ' && !strchr(s, c); } -#endif /* MSD durring an FindFirst search string looks like this; @@ -89,18 +69,15 @@ int ParseDosName(const char *filename, char *fcbname, BOOL bAllowWildcards) lpszLclDir = lpszLclFile = filename; filename += 2; - while (DirChar(*filename)) - { - if (*filename == '\\') - lpszLclFile = filename + 1; - ++filename; - } + while (charOK(_DirWildNameChars + 5, *filename)) + if (*filename++ == '\\') + lpszLclFile = filename; nDirCnt = lpszLclFile - lpszLclDir; /* Parse out the file name portion. */ filename = lpszLclFile; - while (bAllowWildcards ? WildChar(*filename) : - NameChar(*filename)) + while (charOK(bAllowWildcards ? _DirWildNameChars + 2 + : _DirWildNameChars, *filename)) { ++nFileCnt; ++filename; @@ -108,12 +85,11 @@ int ParseDosName(const char *filename, char *fcbname, BOOL bAllowWildcards) if (nFileCnt == 0) { - int err = DE_PATHNOTFND; if (bAllowWildcards && *filename == '\0' && (nDirCnt == 3 || filename[-1] != '\\')) /* D:\ or D:\DOS but not D:\DOS\ */ - err = DE_NFILES; - return err; + return DE_NFILES; + return DE_PATHNOTFND; } /* Now we have pointers set to the directory portion and the */ @@ -124,8 +100,8 @@ int ParseDosName(const char *filename, char *fcbname, BOOL bAllowWildcards) lpszLclExt = ++filename; while (*filename) { - if (bAllowWildcards ? WildChar(*filename) : - NameChar(*filename)) + if (charOK(bAllowWildcards ? _DirWildNameChars + 2 + : _DirWildNameChars, *filename)) { ++nExtCnt; ++filename; diff --git a/kernel/dyndata.h b/kernel/dyndata.h index e980a2c4..ff474bfd 100644 --- a/kernel/dyndata.h +++ b/kernel/dyndata.h @@ -9,7 +9,13 @@ moveable and Dyn.Buffer resizable, but not before */ +#ifdef DEBUG void far *DynAlloc(char *what, unsigned num, unsigned size); +#else +void far *_DynAlloc(unsigned num, unsigned size); +#define DynAlloc(what, num, size) (_DynAlloc((num), (size))) +#endif + void far *DynLast(void); void DynFree(void *ptr); diff --git a/kernel/dyninit.c b/kernel/dyninit.c index 575998ea..93500727 100644 --- a/kernel/dyninit.c +++ b/kernel/dyninit.c @@ -54,16 +54,16 @@ extern struct DynS DOSFAR ASM Dyn; extern struct DynS FAR ASM Dyn; #endif +#ifdef DEBUG void far *DynAlloc(char *what, unsigned num, unsigned size) +#else +void far *_DynAlloc(unsigned num, unsigned size) +#endif { void far *now; unsigned total = num * size; struct DynS far *Dynp = MK_FP(FP_SEG(LoL), FP_OFF(&Dyn)); -#ifndef DEBUG - UNREFERENCED_PARAMETER(what); -#endif - if ((ULONG) total + Dynp->Allocated > 0xffff) { printf("PANIC:Dyn %lu\n", (ULONG) total + Dynp->Allocated); diff --git a/kernel/inithma.c b/kernel/inithma.c index 0c68f50f..952d5e2a 100644 --- a/kernel/inithma.c +++ b/kernel/inithma.c @@ -224,12 +224,33 @@ int MoveKernelToHMA() DosLoadedInHMA = TRUE; } - /* - on finalize, will install a VDISK - */ + now protect against HIMEM/FDXMS/... by simulating a VDISK + FDXMS should detect us and not give HMA access to ohers + unfortunately this also disables HIMEM completely - InstallVDISK(); + so: we install this after all drivers have been loaded + */ + { + static struct { /* Boot sector of a RAM-Disk */ + UBYTE dummy1[3]; /* HIMEM.SYS uses 3, but FDXMS uses 2 */ + char Name[5]; + BYTE dummy2[3]; + WORD BpS; + BYTE dummy3[6]; + WORD Sectors; + BYTE dummy4; + } VDISK_BOOT_SECTOR = { + {0xcf,' ',' '}, + {"VDISK"}, + {" "}, 512, + {"FDOS "}, 128, /* 128 * 512 = 64K */ + ' ' + }; + fmemcpy(MK_FP(0xffff, 0x0010), &VDISK_BOOT_SECTOR, + sizeof(VDISK_BOOT_SECTOR)); + *(WORD FAR *) MK_FP(0xffff, 0x002e) = 1024 + 64; + } /* report the fact we are running high through int 21, ax=3306 */ LoL->version_flags |= 0x10; @@ -238,43 +259,6 @@ int MoveKernelToHMA() } -/* - now protect against HIMEM/FDXMS/... by simulating a VDISK - FDXMS should detect us and not give HMA access to ohers - unfortunately this also disables HIMEM completely - - so: we install this after all drivers have been loaded -*/ -STATIC void InstallVDISK(void) -{ - static struct { /* Boot-Sektor of a RAM-Disk */ - UBYTE dummy1[3]; /* HIMEM.SYS uses 3, but FDXMS uses 2 */ - char Name[5]; - BYTE dummy2[3]; - WORD BpS; - BYTE dummy3[6]; - WORD Sektoren; - BYTE dummy4; - } VDISK_BOOT_SEKTOR = { - { - 0xcf, ' ', ' '}, - { - 'V', 'D', 'I', 'S', 'K'}, - { - ' ', ' ', ' '}, 512, - { - 'F', 'D', 'O', 'S', ' ', ' '}, 128, /* 128*512 = 64K */ - ' '}; - - if (!DosLoadedInHMA) - return; - - fmemcpy(MK_FP(0xffff, 0x0010), &VDISK_BOOT_SEKTOR, - sizeof(VDISK_BOOT_SEKTOR)); - - *(WORD FAR *) MK_FP(0xffff, 0x002e) = 1024 + 64; -} - /* this allocates some bytes from the HMA area only available if DOS=HIGH was successful @@ -368,7 +352,8 @@ void MoveKernel(unsigned NewKernelSegment) FP_OFF(_HMARelocationTableStart)) / sizeof(struct RelocationTable)); int3(); - goto errorReturn; + for (;;) + ; } } @@ -402,9 +387,5 @@ void MoveKernel(unsigned NewKernelSegment) } CurrentKernelSegment = NewKernelSegment; - return; - -errorReturn: - for (;;) ; } diff --git a/kernel/prf.c b/kernel/prf.c index eb06e5c2..338d3dad 100644 --- a/kernel/prf.c +++ b/kernel/prf.c @@ -118,7 +118,7 @@ void put_console(int c) } #endif /* DOSEMU */ -#if defined(DEBUG) || defined(FORSYS) || defined(_INIT) +#if defined(DEBUG) || defined(FORSYS) || defined(_INIT) || defined(TEST) #ifndef FORSYS /* copied from bcc (Bruce's C compiler) stdarg.h */ @@ -264,6 +264,7 @@ STATIC void do_printf(CONST BYTE * fmt, va_list arg) { long n; ULONG u; + BOOL minus = FALSE; BYTE *t = s + sizeof(s) - 1; if (flags & LONGARG) @@ -280,13 +281,16 @@ STATIC void do_printf(CONST BYTE * fmt, va_list arg) { base = -base; if (n < 0) + { u = -n; + minus++; + } } *t = '\0'; /* terminate the number string */ do /* generate digits in reverse order */ - *--t = "0123456789ABCDEF"[(UWORD)u % base]; + *--t = "0123456789ABCDEF"[(UWORD)(u % base)]; while ((u /= base) > 0); - if (n < 0) + if (minus) *--t = '-'; p = t; } @@ -380,12 +384,12 @@ void put_string(const char *s) compile like (note -DTEST !) - c:\tc\tcc -DTEST -DI86 -Ihdr kernel\prf.c + c:\tc\tcc -DTEST -Ihdr kernel\prf.c - and run. If strings are wrong, the program will wait for ENTER + and run. If strings are wrong, the program will wait for a key */ -#include +#include #include struct { @@ -470,8 +474,8 @@ void test(char *should, char *format, unsigned lowint, unsigned highint) if (strcmp(b, should)) { - printf("\nhit ENTER\n"); - getchar(); + printf("\nhit a key\n"); + getch(); } } From e90edc941bbef6bbb9224370bc3322c2a634eace Mon Sep 17 00:00:00 2001 From: Kenneth J Davis Date: Sun, 12 Sep 2004 06:42:05 +0000 Subject: [PATCH 569/671] UNSTABLE branch is always kernel revision 'w' for WorkInProgress (to avoid confusion with stable series) git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/branches/UNSTABLE@1038 6ac86273-5f31-0410-b378-82cca8765d1b --- hdr/version.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/hdr/version.h b/hdr/version.h index f6a118de..435ac7e2 100644 --- a/hdr/version.h +++ b/hdr/version.h @@ -48,7 +48,7 @@ static BYTE *date_hRcsId = #define REVISION_MAJOR 1 #define REVISION_MINOR 1 #define REVISION_SEQ 35 -#define BUILD "2035a" -#define SUB_BUILD "-UNSTABLE" -#define KERNEL_VERSION_STRING "1.1.35a" /*#REVISION_MAJOR "." #REVISION_MINOR "." #REVISION_SEQ */ -#define KERNEL_BUILD_STRING "2035a-UNSTABLE" /*#BUILD SUB_BUILD */ +#define BUILD "2035" +#define SUB_BUILD "w-UNSTABLE" /* only use w=WorkInProgress for UNSTABLE branch */ +#define KERNEL_VERSION_STRING "1.1.35w" /*#REVISION_MAJOR "." #REVISION_MINOR "." #REVISION_SEQ */ +#define KERNEL_BUILD_STRING "2035w-UNSTABLE" /*#BUILD SUB_BUILD */ From e0dfeaada1c50485da7bcfe2bc89daeeba34624f Mon Sep 17 00:00:00 2001 From: Luchezar Georgiev Date: Sun, 12 Sep 2004 11:03:35 +0000 Subject: [PATCH 570/671] NLS uppercase/collating and YES/NO tables added git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/branches/UNSTABLE@1039 6ac86273-5f31-0410-b378-82cca8765d1b --- docs/history.txt | 1 + kernel/country.asm | 1317 +++++++++++++++++++++++++++++++++++++------- 2 files changed, 1111 insertions(+), 207 deletions(-) diff --git a/docs/history.txt b/docs/history.txt index ce1d18f2..96e7640f 100644 --- a/docs/history.txt +++ b/docs/history.txt @@ -341,6 +341,7 @@ * portab.h: pragma aux default to gain ~800B unpacked size (Watcom) (the last 2 changes proposed by Bart Oldeman) + Changes Eduardo + * country.asm: added NLS uppercase/collating tables (437,850,857,858) * inthndlr.c: added Int 2Fh/26-29h processing for NLSFUNC (with Lucho) * nls.c: MuxLoadPkg(), MuxGo() functions modified for NLSFUNC + Changes Jeremy diff --git a/kernel/country.asm b/kernel/country.asm index ca36be90..71f4ffb6 100644 --- a/kernel/country.asm +++ b/kernel/country.asm @@ -1,179 +1,659 @@ -; A rudimentary COUNTRY.SYS for FreeDOS -; Handles only Date/Time/Currency, and NOT codepage things [yet] -; Compatible with COUNTRY.SYS of MS-DOS, PC-DOS, PTS-DOS, OS/2, Win9x, WinNT +; File: +; country.asm +; Description: +; The FreeDOS COUNTRY.SYS source code +; +; Copyleft (G) 2004 +; The FreeDOS Project +; +; This file is part of FreeDOS. +; +; FreeDOS is free software; you can redistribute it and/or +; modify it under the terms of the GNU General Public License +; as published by the Free Software Foundation; either +; version 2, or (at your option) any later version. +; +; FreeDOS is distributed in the hope that it will be useful, +; but WITHOUT ANY WARRANTY; without even the implied warranty +; of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +; See the GNU General Public License for more details. +; +; You should have received a copy of the GNU General Public +; License along with FreeDOS; see the file COPYING. If not, +; write to the Free Software Foundation, Inc., +; 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +; or go to http://www.gnu.org/licenses/gpl.html + +; $Id$ + +; This COUNTRY.SYS is compatible with COUNTRY.SYS +; of MS-DOS, PC-DOS, PTS-DOS, OS/2, Win9x, WinNT ; File format described in RBIL tables 2619-2622 ; ; Created as a kernel table by Tom Ehlert ; Reformatted and commented by Bernd Blaauw ; Separated from the kernel by Luchezar Georgiev +; Case/collate tables added by Eduardo Casino +; Yes/No and page 850 table by Steffen Kaiser ; Amended by many contributors (see names below) ; file header db 0FFh,"COUNTRY",0,0,0,0,0,0,0,0,1,0,1 ; reserved and undocumented values -dd ent ; first entry -ent dw 38; number of entries - don't forget to update when adding a new country +dd ent ; first entry +ent dw 63; number of entries - don't forget to update when adding a new country ; entries ; (size, country, codepage, reserved(2), offset) -__us dw 12, 1,437,0,0 - dd _us -__ca dw 12, 2,863,0,0 - dd _ca -__la dw 12, 3,850,0,0 - dd _la -__ru dw 12, 7,866,0,0 - dd _ru -__gr dw 12, 30,869,0,0 - dd _gr -__nl dw 12, 31,850,0,0 - dd _nl -__be dw 12, 32,850,0,0 - dd _be -__fr dw 12, 33,850,0,0 - dd _fr -__es dw 12, 34,850,0,0 - dd _es -__hu dw 12, 36,852,0,0 - dd _hu -__yu dw 12, 38,852,0,0 - dd _yu -__it dw 12, 39,850,0,0 - dd _it -__ro dw 12, 40,852,0,0 - dd _ro -__ch dw 12, 41,850,0,0 - dd _ch -__cz dw 12, 42,852,0,0 - dd _cz -__at dw 12, 43,850,0,0 - dd _at -__uk dw 12, 44,850,0,0 - dd _uk -__dk dw 12, 45,865,0,0 - dd _dk -__se dw 12, 46,850,0,0 - dd _se -__no dw 12, 47,865,0,0 - dd _no -__pl dw 12, 48,852,0,0 - dd _pl -__de dw 12, 49,850,0,0 - dd _de -__ar dw 12, 54,850,0,0 - dd _ar -__br dw 12, 55,850,0,0 - dd _br -__my dw 12, 60,437,0,0 - dd _my -__au dw 12, 61,437,0,0 - dd _au -__sg dw 12, 65,437,0,0 - dd _sg -__jp dw 12, 81,932,0,0 - dd _jp -__kr dw 12, 82,934,0,0 - dd _kr -__cn dw 12, 86,936,0,0 - dd _cn -__tr dw 12, 90,850,0,0 - dd _tr -__in dw 12, 91,437,0,0 - dd _in -__pt dw 12,351,860,0,0 - dd _pt -__fi dw 12,358,850,0,0 - dd _fi -__bg dw 12,359,855,0,0 - dd _bg -__ua dw 12,380,848,0,0 - dd _ua -__me dw 12,785,864,0,0 - dd _me -__il dw 12,972,862,0,0 - dd _il - -; subfunction headers (so far only for subfunction 1, "CTYINFO") +__us_437 dw 12, 1,437,0,0 + dd _us_437 +__us_850 dw 12, 1,850,0,0 + dd _us_850 +__us_858 dw 12, 1,858,0,0 + dd _us_858 +__ca dw 12, 2,863,0,0 + dd _ca +__la_850 dw 12, 3,850,0,0 + dd _la_850 +__la_858 dw 12, 3,858,0,0 + dd _la_858 +__la_437 dw 12, 3,437,0,0 + dd _la_437 +__ru dw 12, 7,866,0,0 + dd _ru +__gr dw 12, 30,869,0,0 + dd _gr +__nl_850 dw 12, 31,850,0,0 + dd _nl_850 +__nl_858 dw 12, 31,858,0,0 + dd _nl_858 +__be_850 dw 12, 32,850,0,0 + dd _be_850 +__be_858 dw 12, 32,858,0,0 + dd _be_858 +__fr_850 dw 12, 33,850,0,0 + dd _fr_850 +__fr_858 dw 12, 33,858,0,0 + dd _fr_858 +__es_850 dw 12, 34,850,0,0 + dd _es_850 +__es_858 dw 12, 34,858,0,0 + dd _es_858 +__es_437 dw 12, 34,437,0,0 + dd _es_437 +__hu dw 12, 36,852,0,0 + dd _hu +__yu dw 12, 38,852,0,0 + dd _yu +__it_850 dw 12, 39,850,0,0 + dd _it_850 +__it_858 dw 12, 39,858,0,0 + dd _it_858 +__ro dw 12, 40,852,0,0 + dd _ro +__ch_850 dw 12, 41,850,0,0 + dd _ch_850 +__ch_858 dw 12, 41,858,0,0 + dd _ch_858 +__cz dw 12, 42,852,0,0 + dd _cz +__at_850 dw 12, 43,850,0,0 + dd _at_850 +__at_858 dw 12, 43,858,0,0 + dd _at_858 +__at_437 dw 12, 43,437,0,0 + dd _at_437 +__uk_850 dw 12, 44,850,0,0 + dd _uk_850 +__uk_858 dw 12, 44,858,0,0 + dd _uk_858 +__uk_437 dw 12, 44,437,0,0 + dd _uk_437 +__dk dw 12, 45,865,0,0 + dd _dk +__se_850 dw 12, 46,850,0,0 + dd _se_850 +__se_858 dw 12, 46,858,0,0 + dd _se_858 +__no dw 12, 47,865,0,0 + dd _no +__pl dw 12, 48,852,0,0 + dd _pl +__de_850 dw 12, 49,850,0,0 + dd _de_850 +__de_858 dw 12, 49,858,0,0 + dd _de_858 +__de_437 dw 12, 49,858,0,0 + dd _de_437 +__ar_850 dw 12, 54,850,0,0 + dd _ar_850 +__ar_858 dw 12, 54,858,0,0 + dd _ar_858 +__ar_437 dw 12, 54,437,0,0 + dd _ar_437 +__br_850 dw 12, 55,850,0,0 + dd _br_850 +__br_858 dw 12, 55,858,0,0 + dd _br_858 +__my dw 12, 60,437,0,0 + dd _my +__au_437 dw 12, 61,437,0,0 + dd _au_437 +__au_850 dw 12, 61,850,0,0 + dd _au_850 +__au_858 dw 12, 61,858,0,0 + dd _au_858 +__sg dw 12, 65,437,0,0 + dd _sg +__jp dw 12, 81,932,0,0 + dd _jp +__kr dw 12, 82,934,0,0 + dd _kr +__cn dw 12, 86,936,0,0 + dd _cn +__tr_857 dw 12, 90,857,0,0 + dd _tr_857 +__tr_850 dw 12, 90,850,0,0 + dd _tr_850 +__in dw 12, 91,437,0,0 + dd _in +__pt dw 12,351,860,0,0 + dd _pt +__fi_850 dw 12,358,850,0,0 + dd _fi_850 +__fi_858 dw 12,358,858,0,0 + dd _fi_858 +__bg dw 12,359,855,0,0 + dd _bg +__ua dw 12,380,848,0,0 + dd _ua +__me dw 12,785,864,0,0 + dd _me +__il dw 12,972,862,0,0 + dd _il + +; subfunction headers ; (count, size, id, offset) ; add ofher subfunctions after each one -_us dw 1,6,1 - dd us -_ca dw 1,6,1 - dd ca -_la dw 1,6,1 - dd la -_ru dw 1,6,1 - dd ru -_gr dw 1,6,1 - dd gr -_nl dw 1,6,1 - dd nl -_be dw 1,6,1 - dd be -_fr dw 1,6,1 - dd fr -_es dw 1,6,1 - dd sn -_hu dw 1,6,1 - dd hu -_yu dw 1,6,1 - dd yu -_it dw 1,6,1 - dd it -_ro dw 1,6,1 - dd ro -_ch dw 1,6,1 - dd sw -_cz dw 1,6,1 - dd cz -_at dw 1,6,1 - dd as -_uk dw 1,6,1 - dd uk -_dk dw 1,6,1 - dd dk -_se dw 1,6,1 - dd se -_no dw 1,6,1 - dd no -_pl dw 1,6,1 - dd pl -_de dw 1,6,1 - dd de -_ar dw 1,6,1 - dd ar -_br dw 1,6,1 - dd br -_my dw 1,6,1 - dd my -_au dw 1,6,1 - dd au -_sg dw 1,6,1 - dd sg -_jp dw 1,6,1 - dd np -_kr dw 1,6,1 - dd kr -_cn dw 1,6,1 - dd cn -_tr dw 1,6,1 - dd tr -_in dw 1,6,1 - dd ia -_pt dw 1,6,1 - dd pt -_fi dw 1,6,1 - dd fi -_bg dw 1,6,1 - dd bg -_ua dw 1,6,1 - dd ua -_me dw 1,6,1 - dd me -_il dw 1,6,1 - dd il +_us_437 dw 7, + dw 6,1 + dd us_437 + dw 6,2 + dd ucase_437 + dw 6,4 + dd ucase_437 + dw 6,5 + dd fchar + dw 6,6 + dd en_collate_437 + dw 6,7 + dd dbcs_empty + dw 6,23 + dd en_yn +_us_850 dw 7, + dw 6,1 + dd us_850 + dw 6,2 + dd ucase_850 + dw 6,4 + dd ucase_850 + dw 6,5 + dd fchar + dw 6,6 + dd en_collate_850 + dw 6,7 + dd dbcs_empty + dw 6,23 + dd en_yn +_us_858 dw 7, + dw 6,1 + dd us_858 + dw 6,2 + dd ucase_850 + dw 6,4 + dd ucase_850 + dw 6,5 + dd fchar + dw 6,6 + dd en_collate_858 + dw 6,7 + dd dbcs_empty + dw 6,23 + dd en_yn +_ca dw 1 + dw 6,1 + dd ca +_la_850 dw 7, + dw 6,1 + dd la_850 + dw 6,2 + dd ucase_850 + dw 6,4 + dd ucase_850 + dw 6,5 + dd fchar + dw 6,6 + dd es_collate_850 + dw 6,7 + dd dbcs_empty + dw 6,23 + dd es_yn +_la_858 dw 7, + dw 6,1 + dd la_858 + dw 6,2 + dd ucase_850 + dw 6,4 + dd ucase_850 + dw 6,5 + dd fchar + dw 6,6 + dd es_collate_858 + dw 6,7 + dd dbcs_empty + dw 6,23 + dd es_yn +_la_437 dw 7, + dw 6,1 + dd la_437 + dw 6,2 + dd ucase_437 + dw 6,4 + dd ucase_437 + dw 6,5 + dd fchar + dw 6,6 + dd es_collate_437 + dw 6,7 + dd dbcs_empty + dw 6,23 + dd es_yn +_ru dw 1 + dw 6,1 + dd ru +_gr dw 1 + dw 6,1 + dd gr +_nl_850 dw 1 + dw 6,1 + dd nl_850 +_nl_858 dw 1 + dw 6,1 + dd nl_858 +_be_850 dw 1 + dw 6,1 + dd be_850 +_be_858 dw 1 + dw 6,1 + dd be_858 +_fr_850 dw 1 + dw 6,1 + dd fr_850 +_fr_858 dw 1 + dw 6,1 + dd fr_858 +_es_850 dw 7, + dw 6,1 + dd es_850 + dw 6,2 + dd ucase_850 + dw 6,4 + dd ucase_850 + dw 6,5 + dd fchar + dw 6,6 + dd es_collate_850 + dw 6,7 + dd dbcs_empty + dw 6,23 + dd es_yn +_es_858 dw 7, + dw 6,1 + dd es_858 + dw 6,2 + dd ucase_850 + dw 6,4 + dd ucase_850 + dw 6,5 + dd fchar + dw 6,6 + dd es_collate_858 + dw 6,7 + dd dbcs_empty + dw 6,23 + dd es_yn +_es_437 dw 7, + dw 6,1 + dd es_437 + dw 6,2 + dd ucase_437 + dw 6,4 + dd ucase_437 + dw 6,5 + dd fchar + dw 6,6 + dd es_collate_437 + dw 6,7 + dd dbcs_empty + dw 6,23 + dd es_yn +_hu dw 1 + dw 6,1 + dd hu +_yu dw 1 + dw 6,1 + dd yu +_it_850 dw 1 + dw 6,1 + dd it_850 +_it_858 dw 1 + dw 6,1 + dd it_858 +_ro dw 1 + dw 6,1 + dd ro +_ch_850 dw 1 + dw 6,1 + dd ch_850 +_ch_858 dw 1 + dw 6,1 + dd ch_858 +_cz dw 1 + dw 6,1 + dd cz +_at_850 dw 7, + dw 6,1 + dd at_850 + dw 6,2 + dd ucase_850 + dw 6,4 + dd ucase_850 + dw 6,5 + dd fchar + dw 6,6 + dd de_collate_850 + dw 6,7 + dd dbcs_empty + dw 6,23 + dd de_yn +_at_858 dw 7, + dw 6,1 + dd at_858 + dw 6,2 + dd ucase_850 + dw 6,4 + dd ucase_850 + dw 6,5 + dd fchar + dw 6,6 + dd de_collate_858 + dw 6,7 + dd dbcs_empty + dw 6,23 + dd de_yn +_at_437 dw 7, + dw 6,1 + dd at_437 + dw 6,2 + dd ucase_437 + dw 6,4 + dd ucase_437 + dw 6,5 + dd fchar + dw 6,6 + dd de_collate_437 + dw 6,7 + dd dbcs_empty + dw 6,23 + dd de_yn +_uk_850 dw 7, + dw 6,1 + dd uk_850 + dw 6,2 + dd ucase_850 + dw 6,4 + dd ucase_850 + dw 6,5 + dd fchar + dw 6,6 + dd en_collate_850 + dw 6,7 + dd dbcs_empty + dw 6,23 + dd en_yn +_uk_858 dw 7, + dw 6,1 + dd uk_858 + dw 6,2 + dd ucase_850 + dw 6,4 + dd ucase_850 + dw 6,5 + dd fchar + dw 6,6 + dd en_collate_858 + dw 6,7 + dd dbcs_empty + dw 6,23 + dd en_yn +_uk_437 dw 7, + dw 6,1 + dd uk_437 + dw 6,2 + dd ucase_437 + dw 6,4 + dd ucase_437 + dw 6,5 + dd fchar + dw 6,6 + dd en_collate_437 + dw 6,7 + dd dbcs_empty + dw 6,23 + dd en_yn +_dk dw 1 + dw 6,1 + dd dk +_se_850 dw 1 + dw 6,1 + dd se_850 +_se_858 dw 1 + dw 6,1 + dd se_858 +_no dw 1 + dw 6,1 + dd no +_pl dw 1 + dw 6,1 + dd pl +_de_850 dw 7, + dw 6,1 + dd de_850 + dw 6,2 + dd ucase_850 + dw 6,4 + dd ucase_850 + dw 6,5 + dd fchar + dw 6,6 + dd de_collate_850 + dw 6,7 + dd dbcs_empty + dw 6,23 + dd de_yn +_de_858 dw 7, + dw 6,1 + dd de_858 + dw 6,2 + dd ucase_850 + dw 6,4 + dd ucase_850 + dw 6,5 + dd fchar + dw 6,6 + dd de_collate_858 + dw 6,7 + dd dbcs_empty + dw 6,23 + dd de_yn +_de_437 dw 7, + dw 6,1 + dd de_437 + dw 6,2 + dd ucase_437 + dw 6,4 + dd ucase_437 + dw 6,5 + dd fchar + dw 6,6 + dd de_collate_437 + dw 6,7 + dd dbcs_empty + dw 6,23 + dd de_yn +_ar_437 dw 7, + dw 6,1 + dd ar_437 + dw 6,2 + dd ucase_437 + dw 6,4 + dd ucase_437 + dw 6,5 + dd fchar + dw 6,6 + dd es_collate_437 + dw 6,7 + dd dbcs_empty + dw 6,23 + dd es_yn +_ar_850 dw 7, + dw 6,1 + dd ar_850 + dw 6,2 + dd ucase_850 + dw 6,4 + dd ucase_850 + dw 6,5 + dd fchar + dw 6,6 + dd es_collate_850 + dw 6,7 + dd dbcs_empty + dw 6,23 + dd es_yn +_ar_858 dw 7, + dw 6,1 + dd ar_858 + dw 6,2 + dd ucase_850 + dw 6,4 + dd ucase_850 + dw 6,5 + dd fchar + dw 6,6 + dd es_collate_858 + dw 6,7 + dd dbcs_empty + dw 6,23 + dd es_yn +_br_850 dw 1 + dw 6,1 + dd br_850 +_br_858 dw 1 + dw 6,1 + dd br_858 +_my dw 1 + dw 6,1 + dd my +_au_437 dw 7, + dw 6,1 + dd au_437 + dw 6,2 + dd ucase_437 + dw 6,4 + dd ucase_437 + dw 6,5 + dd fchar + dw 6,6 + dd en_collate_437 + dw 6,7 + dd dbcs_empty + dw 6,23 + dd en_yn +_au_850 dw 7, + dw 6,1 + dd au_850 + dw 6,2 + dd ucase_850 + dw 6,4 + dd ucase_850 + dw 6,5 + dd fchar + dw 6,6 + dd en_collate_850 + dw 6,7 + dd dbcs_empty + dw 6,23 + dd en_yn +_au_858 dw 7, + dw 6,1 + dd au_858 + dw 6,2 + dd ucase_850 + dw 6,4 + dd ucase_850 + dw 6,5 + dd fchar + dw 6,6 + dd en_collate_858 + dw 6,7 + dd dbcs_empty + dw 6,23 + dd en_yn +_sg dw 1 + dw 6,1 + dd sg +_jp dw 1 + dw 6,1 + dd np +_kr dw 1 + dw 6,1 + dd kr +_cn dw 1 + dw 6,1 + dd cn +_tr_857 dw 1 + dw 6,1 + dd tr_857 +_tr_850 dw 1 + dw 6,1 + dd tr_850 +_in dw 1 + dw 6,1 + dd ia +_pt dw 1 + dw 6,1 + dd pt +_fi_850 dw 1 + dw 6,1 + dd fi_850 +_fi_858 dw 1 + dw 6,1 + dd fi_858 +_bg dw 1 + dw 6,1 + dd bg +_ua dw 1 + dw 6,1 + dd ua +_me dw 1 + dw 6,1 + dd me +_il dw 1 + dw 6,1 + dd il %define MDY 0 ; month/day/year %define DMY 1 ; day/month/year @@ -191,60 +671,483 @@ _il dw 1,6,1 ; Datesep : Date separator (2/4/2004 or 2-4-2004 for example) ; Timesep : usually ":" is used to separate hours, minutes and seconds ; Currencyf : Currency format (bit array) -; bit 2 = set if currency symbol replaces decimal point -; bit 1 = number of spaces between value and currency symbol -; bit 0 = 0 if currency symbol precedes value -; 1 if currency symbol follows value +; bit 2 = set if currency symbol replaces decimal point +; bit 1 = number of spaces between value and currency symbol +; bit 0 = 0 if currency symbol precedes value +; 1 if currency symbol follows value ; Currencyp : Currency precision ; Time format : 0=12 hour format (AM/PM), 1=24 hour format (4:12 PM is 16:12) %macro cnf 15 db 0FFh,"CTYINFO" dw 22; length -dw %1,%2,%3 ; ID,CP,DF - db %4,%5,%6,%7,%8 ; currency - dw %9,%10, %11,%12 ; 1000, 0.1, DS,TS - db %13,%14,%15 ; CF,Pr,TF -%endmacro;| | | | | | | | | | | -; ID CP DF currency 1000 0.1 DS TS CF Pr TF Country Contributor +dw %1,%2,%3 ; ID,CP,DF + db %4,%5,%6,%7,%8 ; currency + dw %9,%10,%11,%12 ; 1000, 0.1, DS,TS + db %13,%14,%15 ; CF,Pr,TF +%endmacro; | | | | | | | | | | | +; ID CP DF currency 1000 0.1 DS TS CF Pr TF Country Contrib +;----------------------------------------------------------------------------- +us_437 cnf 1,437,MDY,"$", 0,0,0,0,",",".","-",":",0,2,_12; United States +us_850 cnf 1,850,MDY,"$", 0,0,0,0,",",".","-",":",0,2,_12; United States +us_858 cnf 1,858,MDY,"$", 0,0,0,0,",",".","-",":",0,2,_12; United States +ca cnf 2,863,YMD,"$", 0,0,0,0," ",",","-",":",3,2,_24; French Canada +la_850 cnf 3,850,DMY,"$", 0,0,0,0,",",".","/",":",0,2,_12; Latin America +la_858 cnf 3,858,DMY,"$", 0,0,0,0,",",".","/",":",0,2,_12; Latin America +la_437 cnf 3,437,DMY,"$", 0,0,0,0,",",".","/",":",0,2,_12; Latin America +ru cnf 7,866,DMY,"R","U","B",0,0," ",",",".",":",3,2,_24; Russia Arkady +gr cnf 30,869,DMY,"E","Y","P",0,0,".",",","/",":",1,2,_12; Greece +nl_850 cnf 31,850,DMY,"E","U","R",0,0,".",",","-",":",0,2,_24; Netherlands Bart +nl_858 cnf 31,858,DMY,0D5h, 0,0,0,0,".",",","-",":",0,2,_24; Netherlands +be_850 cnf 32,850,DMY,"E","U","R",0,0,".",",","/",":",0,2,_24; Belgium +be_858 cnf 32,858,DMY,0D5h, 0,0,0,0,".",",","/",":",0,2,_24; Belgium +fr_850 cnf 33,850,DMY,"E","U","R",0,0," ",",",".",":",0,2,_24; France +fr_858 cnf 33,858,DMY,0D5h, 0,0,0,0," ",",",".",":",0,2,_24; France +es_850 cnf 34,850,DMY,"E","U","R",0,0,".",",","/",":",0,2,_24; Spain Aitor +es_858 cnf 34,858,DMY,0D5h, 0,0,0,0,".",",","/",":",0,2,_24; Spain +es_437 cnf 34,437,DMY,"E","U","R",0,0,".",",","/",":",0,2,_24; Spain +hu cnf 36,852,YMD,"F","t", 0,0,0," ",",",".",":",3,2,_24; Hungary +yu cnf 38,852,YMD,"D","i","n",0,0,".",",","-",":",2,2,_24; Yugoslavia +it_850 cnf 39,850,DMY,"E","U","R",0,0,".",",","/",".",0,2,_24; Italy +it_858 cnf 39,858,DMY,0D5h, 0,0,0,0,".",",","/",".",0,2,_24; Italy +ro cnf 40,852,YMD,"L","e","i",0,0,".",",","-",":",0,2,_24; Romania +ch_850 cnf 41,850,DMY,"F","r",".",0,0,"'",".",".",",",2,2,_24; Switzerland +ch_858 cnf 41,858,DMY,"F","r",".",0,0,"'",".",".",",",2,2,_24; Switzerland +cz cnf 42,852,YMD,"K","C","s",0,0,".",",","-",":",2,2,_24; Czechoslovakia +at_850 cnf 43,850,DMY,"E","U","R",0,0,".",",",".",".",0,2,_24; Austria +at_858 cnf 43,858,DMY,0D5h, 0,0,0,0,".",",",".",".",0,2,_24; Austria +at_437 cnf 43,437,DMY,"E","U","R",0,0,".",",",".",".",0,2,_24; Austria +uk_850 cnf 44,850,DMY,9Ch, 0,0,0,0,",",".","/",":",0,2,_24; United Kingdom +uk_858 cnf 44,858,DMY,9Ch, 0,0,0,0,",",".","/",":",0,2,_24; United Kingdom +uk_437 cnf 44,437,DMY,9Ch, 0,0,0,0,",",".","/",":",0,2,_24; United Kingdom +dk cnf 45,865,DMY,"k","r", 0,0,0,".",",","-",".",2,2,_24; Denmark +se_850 cnf 46,850,YMD,"K","r", 0,0,0," ",",","-",".",3,2,_24; Sweden +se_858 cnf 46,858,YMD,"K","r", 0,0,0," ",",","-",".",3,2,_24; Sweden +no cnf 47,865,DMY,"K","r", 0,0,0,".",",",".",":",2,2,_24; Norway +pl cnf 48,852,YMD,"Z",88h, 0,0,0,".",",","-",":",0,2,_24; Poland Michal +de_850 cnf 49,850,DMY,"E","U","R",0,0,".",",",".",".",1,2,_24; Germany Tom +de_858 cnf 49,850,DMY,0D5h, 0,0,0,0,".",",",".",".",1,2,_24; Germany +de_437 cnf 49,437,DMY,"E","U","R",0,0,".",",",".",".",1,2,_24; Germany +ar_850 cnf 54,850,DMY,"$", 0,0,0,0,".",",","/",".",0,2,_24; Argentina +ar_858 cnf 54,858,DMY,"$", 0,0,0,0,".",",","/",".",0,2,_24; Argentina +ar_437 cnf 54,437,DMY,"$", 0,0,0,0,".",",","/",".",0,2,_24; Argentina +br_850 cnf 55,850,DMY,"C","r","$",0,0,".",",","/",":",2,2,_24; Brazil +br_858 cnf 55,858,DMY,"C","r","$",0,0,".",",","/",":",2,2,_24; Brazil +my cnf 60,437,DMY,"$", 0,0,0,0,",",".","/",":",0,2,_12; Malaysia +au_437 cnf 61,437,DMY,"$", 0,0,0,0,",",".","-",":",0,2,_12; Australia +au_850 cnf 61,850,DMY,"$", 0,0,0,0,",",".","-",":",0,2,_12; Australia +au_858 cnf 61,858,DMY,"$", 0,0,0,0,",",".","-",":",0,2,_12; Australia +sg cnf 65,437,DMY,"$", 0,0,0,0,",",".","/",":",0,2,_12; Singapore +np cnf 81,932,YMD,81h,8fh, 0,0,0,",",".","-",":",0,0,_24; Japan Yuki +kr cnf 82,934,YMD,5Ch, 0,0,0,0,",",".",".",":",0,0,_24; Korea +cn cnf 86,936,YMD,0A3h,0A4h,0,0,0,",",".",".",":",0,2,_12; China +tr_857 cnf 90,857,DMY,"T","L", 0,0,0,".",",","/",":",4,2,_24; Turkey +tr_850 cnf 90,850,DMY,"T","L", 0,0,0,".",",","/",":",4,2,_24; Turkey +ia cnf 91,437,DMY,"R","s", 0,0,0,".",",","/",":",0,2,_24; India +pt cnf 351,860,DMY,"E","U","R",0,0,".",",","-",":",0,2,_24; Portugal +fi_850 cnf 358,850,DMY,"E","U","R",0,0," ",",",".",".",3,2,_24; Finland Wolf +fi_858 cnf 358,858,DMY,0D5h, 0,0,0,0," ",",",".",".",3,2,_24; Finland +bg cnf 359,855,DMY,"B","G","L",0,0," ",",",".",",",3,2,_24; Bulgaria Lucho +ua cnf 380,848,DMY,"U","A","H",0,0," ",",",".",":",3,2,_24; Ukraine Oleg +me cnf 785,864,DMY,0A4h, 0,0,0,0,".",",","/",":",3,3,_12; Middle East +il cnf 972,862,DMY,99h, 0,0,0,0,",","."," ",":",2,2,_24; Israel + +; Uppercase equivalents of chars 80h to FFh +;------------------------------------------------------------------------------ +ucase_437 db 0FFh,"UCASE " ; Same as kernel's harcoded + dw 128 +db 128, 154, 69, 65, 142, 65, 143, 128 +db 69, 69, 69, 73, 73, 73, 142, 143 +db 144, 146, 146, 79, 153, 79, 85, 85 +db 89, 153, 154, 155, 156, 157, 158, 159 +db 65, 73, 79, 85, 165, 165, 166, 167 +db 168, 169, 170, 171, 172, 173, 174, 175 +db 176, 177, 178, 179, 180, 181, 182, 183 +db 184, 185, 186, 187, 188, 189, 190, 191 +db 192, 193, 194, 195, 196, 197, 198, 199 +db 200, 201, 202, 203, 204, 205, 206, 207 +db 208, 209, 210, 211, 212, 213, 214, 215 +db 216, 217, 218, 219, 220, 221, 222, 223 +db 224, 225, 226, 227, 228, 229, 230, 231 +db 232, 233, 234, 235, 236, 237, 238, 239 +db 240, 241, 242, 243, 244, 245, 246, 247 +db 248, 249, 250, 251, 252, 253, 254, 255 + +ucase_850 db 0FFh,"UCASE " ; From Steffen Kaiser's UNF package + dw 128 +db 128, 154, 144, 182, 142, 183, 143, 128 +db 210, 211, 212, 216, 215, 222, 142, 143 +db 144, 146, 146, 226, 153, 227, 234, 235 +db 95, 153, 154, 157, 156, 157, 158, 159 +db 181, 214, 224, 233, 165, 165, 166, 167 +db 168, 169, 170, 171, 172, 173, 174, 175 +db 176, 177, 178, 179, 180, 181, 182, 183 +db 184, 185, 186, 187, 188, 189, 190, 191 +db 192, 193, 194, 195, 196, 197, 199, 199 +db 200, 201, 202, 203, 204, 205, 206, 207 +db 209, 209, 210, 211, 212, 73, 214, 215 +db 216, 217, 218, 219, 220, 221, 222, 223 +db 224, 225, 226, 227, 229, 229, 230, 232 +db 232, 233, 234, 235, 237, 237, 238, 239 +db 240, 241, 242, 243, 244, 245, 246, 247 +db 248, 249, 250, 251, 252, 253, 254, 255 + +; Filename terminator table +;------------------------------------------------------------------------------ +fchar db 0FFh,"FCHAR " ; Same as kernel's hardcoded + dw 22 ; Comments from RBIL +db 142 ; ??? (01h for MS-DOS 3.30-6.00) +db 0 ; lowest permissible character value for filename +db 255 ; highest permissible character value for filename +db 65 ; ??? (00h for MS-DOS 3.30-6.00) +db 0 ; first excluded character in range \ all characters in this +db 32 ; last excluded character in range / range are illegal +db 238 ; ??? (02h for MS-DOS 3.30-6.00) +db 14 ; number of illegal (terminator) characters +; characters which terminate a filename: +db 46, 34, 47, 92, 91, 93, 58, 124 ; ."/\[]:| +db 60, 62, 43, 61, 59, 44 ; <>+=;, + +; Collating sequence ;------------------------------------------------------------------------------ -us cnf 1,437,MDY,"$", 0,0,0,0,",",".", "-",":",0,2,_12; United States -ca cnf 2,863,YMD,"$", 0,0,0,0," ",",", "-",":",3,2,_24; French Canada -la cnf 3,850,DMY,"$", 0,0,0,0,",",".", "/",":",0,2,_12; Latin America -ru cnf 7,866,DMY,"R","U","B",0,0," ",",", ".",":",3,2,_24; Russia Arkady -gr cnf 30,869,DMY,"E","Y","P",0,0,".",",", "/",":",1,2,_12; Greece -nl cnf 31,850,DMY,"E","U","R",0,0,".",",", "-",":",0,2,_24; Netherlands Bart -be cnf 32,850,DMY,"E","U","R",0,0,".",",", "/",":",0,2,_24; Belgium -fr cnf 33,850,DMY,"E","U","R",0,0," ",",", ".",":",0,2,_24; France -sn cnf 34,850,DMY,"E","U","R",0,0,".",",", "/",":",0,2,_24; Spain Aitor -hu cnf 36,852,YMD,"F","t", 0,0,0," ",",", ".",":",3,2,_24; Hungary -yu cnf 38,852,YMD,"D","i","n",0,0,".",",", "-",":",2,2,_24; Yugoslavia -it cnf 39,850,DMY,"E","U","R",0,0,".",",", "/",".",0,2,_24; Italy -ro cnf 40,852,YMD,"L","e","i",0,0,".",",", "-",":",0,2,_24; Romania -sw cnf 41,850,DMY,"F","r",".",0,0,"'",".", ".",",",2,2,_24; Switzerland -cz cnf 42,852,YMD,"K","C","s",0,0,".",",", "-",":",2,2,_24; Czechoslovakia -as cnf 43,850,DMY,"E","U","R",0,0,".",",", ".",".",0,2,_24; Austria -uk cnf 44,850,DMY,9Ch, 0,0,0,0,",",".", "/",":",0,2,_24; United Kingdom -dk cnf 45,865,DMY,"k","r", 0,0,0,".",",", "-",".",2,2,_24; Denmark -se cnf 46,850,YMD,"K","r", 0,0,0," ",",", "-",".",3,2,_24; Sweden -no cnf 47,865,DMY,"K","r", 0,0,0,".",",", ".",":",2,2,_24; Norway -pl cnf 48,852,YMD,"Z",88h, 0,0,0,".",",", "-",":",0,2,_24; Poland Michal -de cnf 49,850,DMY,"E","U","R",0,0,".",",", ".",".",1,2,_24; Germany Tom -ar cnf 54,850,DMY,"$", 0,0,0,0,".",",", "/",".",0,2,_24; Argentina -br cnf 55,850,DMY,"C","r","$",0,0,".",",", "/",":",2,2,_24; Brazil -my cnf 60,437,DMY,"$", 0,0,0,0,",",".", "/",":",0,2,_12; Malaysia -au cnf 61,437,DMY,"$", 0,0,0,0,",",".", "-",":",0,2,_12; Australia -sg cnf 65,437,DMY,"$", 0,0,0,0,",",".", "/",":",0,2,_12; Singapore -np cnf 81,932,YMD,81h,8fh, 0,0,0,",",".", "-",":",0,0,_24; Japan Yuki -kr cnf 82,934,YMD,5Ch, 0,0,0,0,",",".", ".",":",0,0,_24; Korea -cn cnf 86,936,YMD,0A3h,0A4h,0,0,0,",",".", ".",":",0,2,_12; China -tr cnf 90,850,DMY,"T","L", 0,0,0,".",",", "/",":",4,2,_24; Turkey -ia cnf 91,437,DMY,"R","s", 0,0,0,".",",", "/",":",0,2,_24; India -pt cnf 351,860,DMY,"E","U","R",0,0,".",",", "-",":",0,2,_24; Portugal -fi cnf 358,850,DMY,"E","U","R",0,0," ",",", ".",".",3,2,_24; Finland Wolf -bg cnf 359,855,DMY,"B","G","L",0,0," ",",", ".",",",3,2,_24; Bulgaria Luchezar -ua cnf 380,848,DMY,"U","A","H",0,0," ",",", ".",":",3,2,_24; Ukraine Oleg -me cnf 785,864,DMY,0A4h, 0,0,0,0,".",",", "/",":",3,3,_12; Middle East -il cnf 972,862,DMY,99h, 0,0,0,0,",",".", " ",":",2,2,_24; Israel +en_collate_437 db 0FFh,"COLLATE" ; English, CP437 + dw 256 ; Same as kernel's harcoded +db 0, 1, 2, 3, 4, 5, 6, 7 +db 8, 9, 10, 11, 12, 13, 14, 15 +db 16, 17, 18, 19, 20, 21, 22, 23 +db 24, 25, 26, 27, 28, 29, 30, 31 +db 32, 33, 34, 35, 36, 37, 38, 39 +db 40, 41, 42, 43, 44, 45, 46, 47 +db 48, 49, 50, 51, 52, 53, 54, 55 +db 56, 57, 58, 59, 60, 61, 62, 63 +db 64, 65, 66, 67, 68, 69, 70, 71 +db 72, 73, 74, 75, 76, 77, 78, 79 +db 80, 81, 82, 83, 84, 85, 86, 87 +db 88, 89, 90, 91, 92, 93, 94, 95 +db 96, 65, 66, 67, 68, 69, 70, 71 +db 72, 73, 74, 75, 76, 77, 78, 79 +db 80, 81, 82, 83, 84, 85, 86, 87 +db 88, 89, 90, 123, 124, 125, 126, 127 +db 67, 85, 69, 65, 65, 65, 65, 67 +db 69, 69, 69, 73, 73, 73, 65, 65 +db 69, 65, 65, 79, 79, 79, 85, 85 +db 89, 79, 85, 36, 36, 36, 36, 36 +db 65, 73, 79, 85, 78, 78, 166, 167 +db 63, 169, 170, 171, 172, 33, 34, 34 +db 176, 177, 178, 179, 180, 181, 182, 183 +db 184, 185, 186, 187, 188, 189, 190, 191 +db 192, 193, 194, 195, 196, 197, 198, 199 +db 200, 201, 202, 203, 204, 205, 206, 207 +db 208, 209, 210, 211, 212, 213, 214, 215 +db 216, 217, 218, 219, 220, 221, 222, 223 +db 224, 83, 226, 227, 228, 229, 230, 231 +db 232, 233, 234, 235, 236, 237, 238, 239 +db 240, 241, 242, 243, 244, 245, 246, 247 +db 248, 249, 250, 251, 252, 253, 254, 255 + +en_collate_850 db 0FFh,"COLLATE" ; English, CP850 + dw 256 +db 0, 1, 2, 3, 4, 5, 6, 7 +db 8, 9, 10, 11, 12, 13, 14, 15 +db 16, 17, 18, 19, 20, 21, 22, 23 +db 24, 25, 26, 27, 28, 29, 30, 31 +db 32, 33, 34, 35, 36, 37, 38, 39 +db 40, 41, 42, 43, 44, 45, 46, 47 +db 48, 49, 50, 51, 52, 53, 54, 55 +db 56, 57, 58, 59, 60, 61, 62, 63 +db 64, 65, 66, 67, 68, 69, 70, 71 +db 72, 73, 74, 75, 76, 77, 78, 79 +db 80, 81, 82, 83, 84, 85, 86, 87 +db 88, 89, 90, 91, 92, 93, 94, 95 +db 96, 65, 66, 67, 68, 69, 70, 71 +db 72, 73, 74, 75, 76, 77, 78, 79 +db 80, 81, 82, 83, 84, 85, 86, 87 +db 88, 89, 90, 123, 124, 125, 126, 127 +db 67, 85, 69, 65, 65, 65, 65, 67 +db 69, 69, 69, 73, 73, 73, 65, 65 +db 69, 65, 65, 79, 79, 79, 85, 85 +db 89, 79, 85, 36, 36, 36, 36, 36 +db 65, 73, 79, 85, 78, 78, 166, 167 +db 63, 169, 170, 171, 172, 33, 34, 34 +db 176, 177, 178, 179, 180, 65, 65, 65 +db 184, 185, 186, 187, 188, 36, 36, 191 +db 192, 193, 194, 195, 196, 197, 65, 65 +db 200, 201, 202, 203, 204, 205, 206, 36 +db 68, 68, 69, 69, 69, 73, 73, 73 +db 73, 217, 218, 219, 220, 221, 73, 223 +db 79, 83, 79, 79, 79, 79, 230, 231 +db 232, 85, 85, 85, 89, 89, 238, 239 +db 240, 241, 242, 243, 244, 245, 246, 247 +db 248, 249, 250, 49, 51, 50, 254, 255 + +en_collate_858 db 0FFh,"COLLATE" ; English, CP858 + dw 256 +db 0, 1, 2, 3, 4, 5, 6, 7 +db 8, 9, 10, 11, 12, 13, 14, 15 +db 16, 17, 18, 19, 20, 21, 22, 23 +db 24, 25, 26, 27, 28, 29, 30, 31 +db 32, 33, 34, 35, 36, 37, 38, 39 +db 40, 41, 42, 43, 44, 45, 46, 47 +db 48, 49, 50, 51, 52, 53, 54, 55 +db 56, 57, 58, 59, 60, 61, 62, 63 +db 64, 65, 66, 67, 68, 69, 70, 71 +db 72, 73, 74, 75, 76, 77, 78, 79 +db 80, 81, 82, 83, 84, 85, 86, 87 +db 88, 89, 90, 91, 92, 93, 94, 95 +db 96, 65, 66, 67, 68, 69, 70, 71 +db 72, 73, 74, 75, 76, 77, 78, 79 +db 80, 81, 82, 83, 84, 85, 86, 87 +db 88, 89, 90, 123, 124, 125, 126, 127 +db 67, 85, 69, 65, 65, 65, 65, 67 +db 69, 69, 69, 73, 73, 73, 65, 65 +db 69, 65, 65, 79, 79, 79, 85, 85 +db 89, 79, 85, 36, 36, 36, 36, 36 +db 65, 73, 79, 85, 78, 78, 166, 167 +db 63, 169, 170, 171, 172, 33, 34, 34 +db 176, 177, 178, 179, 180, 65, 65, 65 +db 184, 185, 186, 187, 188, 36, 36, 191 +db 192, 193, 194, 195, 196, 197, 65, 65 +db 200, 201, 202, 203, 204, 205, 206, 36 +db 68, 68, 69, 69, 69, 36, 73, 73 +db 73, 217, 218, 219, 220, 221, 73, 223 +db 79, 83, 79, 79, 79, 79, 230, 231 +db 232, 85, 85, 85, 89, 89, 238, 239 +db 240, 241, 242, 243, 244, 245, 246, 247 +db 248, 249, 250, 49, 51, 50, 254, 255 + +es_collate_437 db 0FFh,"COLLATE" ; Spanish, CP437 + dw 256 +db 0, 1, 2, 3, 4, 5, 6, 7 +db 8, 9, 10, 11, 12, 13, 14, 15 +db 16, 17, 18, 19, 20, 21, 22, 23 +db 24, 25, 26, 27, 28, 29, 30, 31 +db 32, 33, 34, 35, 36, 37, 38, 39 +db 40, 41, 42, 43, 44, 45, 46, 47 +db 48, 49, 50, 51, 52, 53, 54, 55 +db 56, 57, 58, 59, 60, 61, 62, 63 +db 64, 65, 66, 67, 69, 70, 71, 72 +db 73, 74, 75, 76, 77, 78, 79, 81 +db 82, 83, 84, 85, 87, 88, 89, 90 +db 91, 92, 93, 94, 95, 96, 97, 98 +db 99, 65, 66, 67, 69, 70, 71, 72 +db 73, 74, 75, 76, 77, 78, 79, 81 +db 82, 83, 84, 85, 87, 88, 89, 90 +db 91, 92, 93, 123, 124, 125, 126, 127 +db 68, 88, 70, 65, 65, 65, 65, 68 +db 70, 70, 70, 74, 74, 74, 65, 65 +db 70, 65, 65, 81, 81, 81, 88, 88 +db 92, 81, 88, 36, 36, 36, 36, 36 +db 65, 74, 81, 88, 80, 80, 65, 81 +db 63, 169, 170, 171, 172, 33, 34, 34 +db 176, 177, 178, 179, 180, 181, 182, 183 +db 184, 185, 186, 187, 188, 189, 190, 191 +db 192, 193, 194, 195, 196, 197, 198, 199 +db 200, 201, 202, 203, 204, 205, 206, 207 +db 208, 209, 210, 211, 212, 213, 214, 215 +db 216, 217, 218, 219, 220, 221, 222, 223 +db 224, 86, 226, 227, 228, 229, 230, 231 +db 232, 233, 234, 235, 236, 237, 238, 239 +db 240, 241, 242, 243, 244, 245, 246, 247 +db 248, 249, 250, 251, 79, 50, 254, 255 + +es_collate_850 db 0FFh,"COLLATE" ; Spanish, CP850 + dw 256 +db 0, 1, 2, 3, 4, 5, 6, 7 +db 8, 9, 10, 11, 12, 13, 14, 15 +db 16, 17, 18, 19, 20, 21, 22, 23 +db 24, 25, 26, 27, 28, 29, 30, 31 +db 32, 33, 34, 35, 36, 37, 38, 39 +db 40, 41, 42, 43, 44, 45, 46, 47 +db 48, 49, 50, 51, 52, 53, 54, 55 +db 56, 57, 58, 59, 60, 61, 62, 63 +db 64, 65, 66, 67, 69, 70, 71, 72 +db 73, 74, 75, 76, 77, 78, 79, 81 +db 82, 83, 84, 85, 87, 88, 89, 90 +db 91, 92, 93, 94, 95, 96, 97, 98 +db 99, 65, 66, 67, 69, 70, 71, 72 +db 73, 74, 75, 76, 77, 78, 79, 81 +db 82, 83, 84, 85, 87, 88, 89, 90 +db 91, 92, 93, 123, 124, 125, 126, 127 +db 68, 87, 70, 65, 65, 65, 65, 68 +db 70, 70, 70, 74, 74, 74, 65, 65 +db 70, 65, 65, 81, 81, 81, 88, 88 +db 92, 81, 88, 81, 36, 81, 158, 36 +db 65, 74, 81, 88, 80, 80, 65, 81 +db 63, 169, 170, 171, 172, 33, 34, 34 +db 176, 177, 178, 179, 180, 65, 65, 65 +db 184, 185, 186, 187, 188, 36, 36, 191 +db 192, 193, 194, 195, 196, 197, 65, 65 +db 200, 201, 202, 203, 204, 205, 206, 36 +db 69, 69, 70, 70, 70, 74, 74, 74 +db 74, 217, 218, 219, 220, 221, 74, 223 +db 81, 86, 81, 81, 81, 81, 230, 231 +db 232, 88, 88, 88, 92, 92, 238, 239 +db 240, 241, 242, 243, 244, 245, 246, 247 +db 248, 249, 250, 49, 51, 50, 254, 255 + +es_collate_858 db 0FFh,"COLLATE" ; Spanish, CP858 + dw 256 +db 0, 1, 2, 3, 4, 5, 6, 7 +db 8, 9, 10, 11, 12, 13, 14, 15 +db 16, 17, 18, 19, 20, 21, 22, 23 +db 24, 25, 26, 27, 28, 29, 30, 31 +db 32, 33, 34, 35, 36, 37, 38, 39 +db 40, 41, 42, 43, 44, 45, 46, 47 +db 48, 49, 50, 51, 52, 53, 54, 55 +db 56, 57, 58, 59, 60, 61, 62, 63 +db 64, 65, 66, 67, 69, 70, 71, 72 +db 73, 74, 75, 76, 77, 78, 79, 81 +db 82, 83, 84, 85, 87, 88, 89, 90 +db 91, 92, 93, 94, 95, 96, 97, 98 +db 99, 65, 66, 67, 69, 70, 71, 72 +db 73, 74, 75, 76, 77, 78, 79, 81 +db 82, 83, 84, 85, 87, 88, 89, 90 +db 91, 92, 93, 123, 124, 125, 126, 127 +db 68, 87, 70, 65, 65, 65, 65, 68 +db 70, 70, 70, 74, 74, 74, 65, 65 +db 70, 65, 65, 81, 81, 81, 88, 88 +db 92, 81, 88, 81, 36, 81, 158, 36 +db 65, 74, 81, 88, 80, 80, 65, 81 +db 63, 169, 170, 171, 172, 33, 34, 34 +db 176, 177, 178, 179, 180, 65, 65, 65 +db 184, 185, 186, 187, 188, 36, 36, 191 +db 192, 193, 194, 195, 196, 197, 65, 65 +db 200, 201, 202, 203, 204, 205, 206, 36 +db 69, 69, 70, 70, 70, 36, 74, 74 +db 74, 217, 218, 219, 220, 221, 74, 223 +db 81, 86, 81, 81, 81, 81, 230, 231 +db 232, 88, 88, 88, 92, 92, 238, 239 +db 240, 241, 242, 243, 244, 245, 246, 247 +db 248, 249, 250, 49, 51, 50, 254, 255 + +de_collate_850 db 0FFh,"COLLATE" ; German CP850 + dw 256 ; From Steffen Kaiser's UNF package +db 0, 1, 2, 3, 4, 5, 6, 7 +db 8, 9, 10, 11, 12, 13, 14, 15 +db 16, 17, 18, 19, 20, 21, 22, 23 +db 24, 25, 26, 27, 28, 29, 30, 31 +db 32, 33, 34, 35, 36, 37, 38, 39 +db 40, 41, 42, 43, 44, 45, 46, 47 +db 48, 49, 50, 51, 52, 53, 54, 55 +db 56, 57, 58, 59, 60, 61, 62, 63 +db 64, 65, 66, 67, 68, 69, 70, 71 +db 72, 73, 74, 75, 76, 77, 78, 79 +db 80, 81, 82, 83, 84, 85, 86, 87 +db 88, 89, 90, 91, 92, 93, 94, 95 +db 96, 65, 66, 67, 68, 69, 70, 71 +db 72, 73, 74, 75, 76, 77, 78, 79 +db 80, 81, 82, 83, 84, 85, 86, 87 +db 88, 89, 90, 123, 124, 125, 126, 127 +db 67, 85, 69, 65, 65, 65, 65, 67 +db 69, 69, 69, 73, 73, 73, 65, 65 +db 69, 65, 65, 79, 79, 79, 85, 85 +db 89, 79, 85, 79, 36, 79, 158, 36 +db 65, 73, 79, 85, 78, 78, 166, 167 +db 63, 169, 170, 171, 172, 33, 34, 34 +db 176, 177, 178, 179, 180, 65, 65, 65 +db 184, 185, 186, 187, 188, 36, 36, 191 +db 192, 193, 194, 195, 196, 197, 65, 65 +db 200, 201, 202, 203, 204, 205, 206, 36 +db 68, 68, 69, 69, 69, 73, 73, 73 +db 73, 217, 218, 219, 220, 221, 73, 223 +db 79, 83, 79, 79, 79, 79, 230, 232 +db 232, 85, 85, 85, 89, 89, 238, 239 +db 240, 241, 242, 243, 244, 245, 246, 247 +db 248, 249, 250, 251, 252, 253, 254, 255 + +de_collate_858 db 0FFh,"COLLATE" ; German CP858 + dw 256 +db 0, 1, 2, 3, 4, 5, 6, 7 +db 8, 9, 10, 11, 12, 13, 14, 15 +db 16, 17, 18, 19, 20, 21, 22, 23 +db 24, 25, 26, 27, 28, 29, 30, 31 +db 32, 33, 34, 35, 36, 37, 38, 39 +db 40, 41, 42, 43, 44, 45, 46, 47 +db 48, 49, 50, 51, 52, 53, 54, 55 +db 56, 57, 58, 59, 60, 61, 62, 63 +db 64, 65, 66, 67, 68, 69, 70, 71 +db 72, 73, 74, 75, 76, 77, 78, 79 +db 80, 81, 82, 83, 84, 85, 86, 87 +db 88, 89, 90, 91, 92, 93, 94, 95 +db 96, 65, 66, 67, 68, 69, 70, 71 +db 72, 73, 74, 75, 76, 77, 78, 79 +db 80, 81, 82, 83, 84, 85, 86, 87 +db 88, 89, 90, 123, 124, 125, 126, 127 +db 67, 85, 69, 65, 65, 65, 65, 67 +db 69, 69, 69, 73, 73, 73, 65, 65 +db 69, 65, 65, 79, 79, 79, 85, 85 +db 89, 79, 85, 79, 36, 79, 158, 36 +db 65, 73, 79, 85, 78, 78, 166, 167 +db 63, 169, 170, 171, 172, 33, 34, 34 +db 176, 177, 178, 179, 180, 65, 65, 65 +db 184, 185, 186, 187, 188, 36, 36, 191 +db 192, 193, 194, 195, 196, 197, 65, 65 +db 200, 201, 202, 203, 204, 205, 206, 36 +db 68, 68, 69, 69, 69, 36, 73, 73 +db 73, 217, 218, 219, 220, 221, 73, 223 +db 79, 83, 79, 79, 79, 79, 230, 232 +db 232, 85, 85, 85, 89, 89, 238, 239 +db 240, 241, 242, 243, 244, 245, 246, 247 +db 248, 249, 250, 251, 252, 253, 254, 255 + +de_collate_437 db 0FFh,"COLLATE" ; German CP437 + dw 256 +db 0, 1, 2, 3, 4, 5, 6, 7 +db 8, 9, 10, 11, 12, 13, 14, 15 +db 16, 17, 18, 19, 20, 21, 22, 23 +db 24, 25, 26, 27, 28, 29, 30, 31 +db 32, 33, 34, 35, 36, 37, 38, 39 +db 40, 41, 42, 43, 44, 45, 46, 47 +db 48, 49, 50, 51, 52, 53, 54, 55 +db 56, 57, 58, 59, 60, 61, 62, 63 +db 64, 65, 66, 67, 68, 69, 70, 71 +db 72, 73, 74, 75, 76, 77, 78, 79 +db 80, 81, 82, 83, 84, 85, 86, 87 +db 88, 89, 90, 91, 92, 93, 94, 95 +db 96, 65, 66, 67, 68, 69, 70, 71 +db 72, 73, 74, 75, 76, 77, 78, 79 +db 80, 81, 82, 83, 84, 85, 86, 87 +db 88, 89, 90, 123, 124, 125, 126, 127 +db 67, 85, 69, 65, 65, 65, 65, 67 +db 69, 69, 69, 73, 73, 73, 65, 65 +db 69, 65, 65, 79, 79, 79, 85, 85 +db 89, 79, 85, 36, 36, 36, 36, 36 +db 65, 73, 79, 85, 78, 78, 166, 167 +db 63, 169, 170, 171, 172, 33, 34, 34 +db 176, 177, 178, 179, 180, 181, 182, 183 +db 184, 185, 186, 187, 188, 189, 190, 191 +db 192, 193, 194, 195, 196, 197, 198, 199 +db 200, 201, 202, 203, 204, 205, 206, 207 +db 208, 209, 210, 211, 212, 213, 214, 215 +db 216, 217, 218, 219, 220, 221, 222, 223 +db 224, 83, 226, 227, 228, 229, 230, 231 +db 232, 233, 234, 235, 236, 237, 238, 239 +db 240, 241, 242, 243, 244, 245, 246, 247 +db 248, 249, 250, 251, 252, 253, 254, 255 + +; Dual Byte Character Sets +; lead-byte ranges +;------------------------------------------------------------------------------ +dbcs_empty db 0FFh,"DBCS " + dw 0 ; Table length + db 0, 0 ; Table terminator (even if length == 0) + +; Yes/No table +; yes_l : Character (single byte) or leadbyte (DBCS) for YES +; yes_h : trailbyte for YES +; no_l : Character (single byte) or leadbyte (DBCS) for NO +; no_h : trailbyte for NO +;------------------------------------------------------------------------------ +es_yn db 0FFh,"YESNO " + dw 4 + db 'S',0,'N',0 ; Spanish + +de_yn db 0FFh,"YESNO " + dw 4 + db 'J',0,'N',0 ; German + +en_yn db 0FFh,"YESNO " + dw 4 + db 'Y',0,'N',0 ; English db "FreeDOS" ; Trailing - as recommended by the Ralf Brown Interrupt List From 6e7cf9632389757b66ab637ded692657f783abcf Mon Sep 17 00:00:00 2001 From: Luchezar Georgiev Date: Sun, 12 Sep 2004 17:47:21 +0000 Subject: [PATCH 571/671] By Eduardo Casino-Almao: adds DBCS support to DOS-65-23 (Determine if a character represents yes/no response) as specified by RBIL, and fixes DOS-63-00 (Get Double Byte Character Set lead-byte table.) It now returns the DBCS table from the active NLS package, not the harcoded one. git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/branches/UNSTABLE@1040 6ac86273-5f31-0410-b378-82cca8765d1b --- docs/history.txt | 25 ++++++++++++++++++- hdr/nls.h | 12 +++++---- kernel/inthndlr.c | 13 +++++++--- kernel/nls.c | 63 ++++++++++++++++++++++++++++++++++++----------- kernel/nls_hc.asm | 2 +- kernel/proto.h | 3 ++- 6 files changed, 92 insertions(+), 26 deletions(-) diff --git a/docs/history.txt b/docs/history.txt index 96e7640f..a36d68d2 100644 --- a/docs/history.txt +++ b/docs/history.txt @@ -342,13 +342,36 @@ (the last 2 changes proposed by Bart Oldeman) + Changes Eduardo * country.asm: added NLS uppercase/collating tables (437,850,857,858) - * inthndlr.c: added Int 2Fh/26-29h processing for NLSFUNC (with Lucho) + * inthndlr.c: + - added Int 2Fh/26-29h processing for NLSFUNC (with Lucho) + - DOS-63-00 returns DBCS table from the active NLS package, not the + harcoded one. + - DOS-65-23: DosYesNo() arg is now DX, not DL. * nls.c: MuxLoadPkg(), MuxGo() functions modified for NLSFUNC + - New macro getTable7() + - New functions nlsIsDBCS() (check if a byte is a dual byte char + leadbyte) and DosGetDBCS() (returns DBCS table from the active NLS + package) + - Add DBCS table to getTable() and fixes references to harcoded + UCASE and FUCASE tables. + - DosYesNo(): arg is now UWORD, not unsigned char. + - nlsYesNo(): Add DBCS support + - syscall_MUX14(): arg of nlsYesNo() is now CX instead of CL. + * nls.h: + - yeschar and nochar are now UWORD instead of UBYTE. + - NLS_FREEDOS_NLSFUNC_VERSION bumped to 0xFD02. + - Add a small comment. + * nls_hc.asm: YesChar and NoChar are now two bytes each. + * proto.h: + - DosYesNo(): Argument is now UWORD (dual byte) + - Add prototype for DosGetDBCS() + Changes Jeremy * config.txt - update to include all CONFIG.SYS options (except ANYDOS) * exeflat.c - show usage also when number of arguments incorrect + < many other changes to be added by Jeremy himself :-> + *** Sync - Stable Build 2035 *** 2004 May 30 - Build 2035 diff --git a/hdr/nls.h b/hdr/nls.h index 2e595cec..2ebfb723 100644 --- a/hdr/nls.h +++ b/hdr/nls.h @@ -269,6 +269,8 @@ * information itself; it is ignored when the user calls DOS-65-0x * to return such pointer. * NLS_REORDER_POINTERS is *enabled* by default. + * UPDATE: With NLS_REORDER_POINTERS, now table 7 (DBCS) is also + * expected to be located at a predictable index. -- eca */ /* Define if some user program possibly modifies the value of the internal @@ -289,7 +291,7 @@ /* What version of nlsInfo and accompanying associations Must be passed to NLSFUNC upon MUX-14-00 to identify the correct kernel to the tools. */ -#define NLS_FREEDOS_NLSFUNC_VERSION 0xFD01 +#define NLS_FREEDOS_NLSFUNC_VERSION 0xFD02 /* Represents a call to DOS-38 within DOS-65 handlers. Current implementation relys on 0x101! */ #define NLS_DOS_38 0x101 @@ -425,8 +427,8 @@ struct nlsPackage { /* the contents of one chain item of the MUX-14 processor does not require them and performs all actions itself, so that the kernel never tries to fetch this information itself. */ - UBYTE yeschar; /* yes / no character DOS-65-23 */ - UBYTE nochar; + UWORD yeschar; /* yes / no character DOS-65-23 */ + UWORD nochar; unsigned numSubfct; /* number of supported sub-functions */ struct nlsPointer nlsPointers[1]; /* grows dynamically */ }; @@ -570,8 +572,8 @@ struct csys_ccDefinition { /* country/codepage reference */ UWORD cntry, cp; is missing int flags; is NLS_FLAG_HARDCODED, if the kernel is to handle the data of its own - UBYTE yeschar; is filled - UBYTE nochar; is filled + UWORD yeschar; is filled + UWORD nochar; is filled unsigned numSubfct; is filled struct nlsPointer nlsPointers[1]; is filled the pointer member is the absolute diff --git a/kernel/inthndlr.c b/kernel/inthndlr.c index f2d9f16b..d2ea990a 100644 --- a/kernel/inthndlr.c +++ b/kernel/inthndlr.c @@ -1288,8 +1288,15 @@ VOID ASMCFUNC int21_service(iregs FAR * r) /* UNDOCUMENTED: Double byte and korean tables */ case 0x63: { - lr.DS = FP_SEG(&nlsDBCSHardcoded); - lr.SI = FP_OFF(&nlsDBCSHardcoded); + VOID FAR *p; + + if (lr.AL == 0) { + p = DosGetDBCS(); + lr.DS = FP_SEG(p); + lr.SI = FP_OFF(p); + } + lr.AL = 0x00; + #if 0 /* not really supported, but will pass. */ lr.AL = 0x00; /*jpp: according to interrupt list */ @@ -1326,7 +1333,7 @@ VOID ASMCFUNC int21_service(iregs FAR * r) DosUpFString(FP_DS_DX); break; case 0x23: /* check Yes/No response */ - lr.AX = DosYesNo(lr.DL); + lr.AX = DosYesNo(lr.DX); break; default: #ifdef NLS_DEBUG diff --git a/kernel/nls.c b/kernel/nls.c index 768a5250..6173d378 100644 --- a/kernel/nls.c +++ b/kernel/nls.c @@ -75,9 +75,11 @@ struct nlsInfoBlock nlsInfo = { #ifdef NLS_REORDER_POINTERS #define getTable2(nls) ((nls)->nlsPointers[0].pointer) #define getTable4(nls) ((nls)->nlsPointers[1].pointer) +#define getTable7(nls) ((nls)->nlsPointers[4].pointer) #else #define getTable2(nls) getTable(2, (nls)) #define getTable4(nls) getTable(4, (nls)) +#define getTable7(nls) getTable(7, (nls)) #define NEED_GET_TABLE #endif /*== both chartables must be 128 bytes long and lower range is @@ -213,12 +215,15 @@ STATIC VOID FAR *getTable(UBYTE subfct, struct nlsPackage FAR * nls) switch (subfct) { case 2: - return &nlsUpHardcodedTable; + return &nlsUpcaseHardcoded; case 4: - return &nlsFnameUpHardcodedTable; + return &nlsFUpcaseHardcoded; /* case 5: return &nlsFnameTermHardcodedTable; */ /* case 6: return &nlsCollHardcodedTable; */ + case 7: + return &nlsDBCSHardcoded; } + return NULL; } #endif @@ -422,18 +427,41 @@ STATIC VOID xUpMem(struct nlsPackage FAR * nls, VOID FAR * str, muxBufGo(NLSFUNC_UPMEM, 0, nls->cp, nls->cntry, len, str); } -STATIC int nlsYesNo(struct nlsPackage FAR * nls, unsigned char ch) +STATIC BOOL nlsIsDBCS(UBYTE ch) +{ + + if (ch < 128) + return FALSE; /* No leadbyte is smaller than that */ + + { + UWORD FAR *t= ((struct nlsDBCS FAR*)getTable7(nlsInfo.actPkg))->dbcsTbl; + + for (; *t != 0; ++t) + if (ch >= (*t & 0xFF) && ch <= (*t >> 8)) + return TRUE; + } + + return FALSE; +} + +STATIC int nlsYesNo(struct nlsPackage FAR * nls, UWORD ch) { - log(("NLS: nlsYesNo(): in ch=%u (%c)\n", ch, ch > 32 ? ch : ' ')); + /* Check if it is a dual byte character */ + if (!nlsIsDBCS(ch & 0xFF)) { + ch &= 0xFF; + log(("NLS: nlsYesNo(): in ch=%u (%c)\n", ch, ch > 32 ? (char)ch : ' ')); + xUpMem(nls, MK_FP(_SS, &ch), 1); /* Upcase character */ + /* Cannot use DosUpChar(), because + maybe: nls != current NLS pkg + However: Upcase character within lowlevel + function to allow a yesNo() function + catched by external MUX-14 handler, which + does NOT upcase character. */ + log(("NLS: nlsYesNo(): upcased ch=%u (%c)\n", ch, ch > 32 ? (char)ch : ' ')); + } + else + log(("NLS: nlsYesNo(): in ch=%u (DBCS)\n", ch)); - xUpMem(nls, MK_FP(_SS, &ch), 1); /* Upcase character */ - /* Cannot use DosUpChar(), because - maybe: nls != current NLS pkg - However: Upcase character within lowlevel - function to allow a yesNo() function - catched by external MUX-14 handler, which - does NOT upcase character. */ - log(("NLS: nlsYesNo(): upcased ch=%u (%c)\n", ch, ch > 32 ? ch : ' ')); if (ch == nls->yeschar) return 1; if (ch == nls->nochar) @@ -445,7 +473,7 @@ STATIC int nlsYesNo(struct nlsPackage FAR * nls, unsigned char ch) ***** DOS API ****************************************************** ********************************************************************/ -BYTE DosYesNo(unsigned char ch) +BYTE DosYesNo(UWORD ch) /* returns: 0: ch == "No", 1: ch == "Yes", 2: ch crap */ { if (nlsInfo.actPkg->flags & NLS_FLAG_DIRECT_YESNO) @@ -490,7 +518,7 @@ VOID DosUpFMem(VOID FAR * str, unsigned len) log(("NLS: DosUpFMem(): len=%u, %04x:%04x=\"", len, FP_SEG(str), FP_OFF(str))); for (c = 0; c < len; ++c) - printf("%c", str[c] > 32 ? str[c] : '.'); + printf("%c", ((char FAR *)str)[c] > 32 ? ((char FAR *)str)[c] : '.'); printf("\"\n"); #endif if (nlsInfo.actPkg->flags & NLS_FLAG_DIRECT_FUPCASE) @@ -605,6 +633,11 @@ COUNT DosSetCodepage(UWORD actCP, UWORD sysCP) return DE_INVLDDATA; } +VOID FAR *DosGetDBCS(void) +{ + return getTable7(nlsInfo.actPkg); +} + /******************************************************************** ***** MUX-14 API *************************************************** ********************************************************************/ @@ -655,7 +688,7 @@ UWORD ASMCFUNC syscall_MUX14(DIRECT_IREGS) case NLSFUNC_LOAD_PKG2: return nlsSetPackage(nls); case NLSFUNC_YESNO: - return nlsYesNo(nls, CL); + return nlsYesNo(nls, CX); case NLSFUNC_UPMEM: nlsUpMem(nls, MK_FP(ES, DI), CX); return SUCCESS; diff --git a/kernel/nls_hc.asm b/kernel/nls_hc.asm index adf04bc9..7acee739 100644 --- a/kernel/nls_hc.asm +++ b/kernel/nls_hc.asm @@ -12,7 +12,7 @@ segment CONST2 GLOBAL _nlsPackageHardcoded _nlsPackageHardcoded: DB 000h, 000h, 000h, 000h, 001h, 000h, 0b5h, 001h - DB 00fh, 000h, 059h, 04eh, 006h, 000h + DB 00fh, 000h, 059h, 000h, 04eh, 000h, 006h, 000h DB 002h DW ?table2, SEG ?table2 DB 004h diff --git a/kernel/proto.h b/kernel/proto.h index 515e50ff..e48266e4 100644 --- a/kernel/proto.h +++ b/kernel/proto.h @@ -271,7 +271,7 @@ COUNT lfn_dir_read(COUNT handle, lfn_inode_ptr lip); COUNT lfn_dir_write(COUNT handle); /* nls.c */ -BYTE DosYesNo(unsigned char ch); +BYTE DosYesNo(UWORD ch); #ifndef DosUpMem VOID DosUpMem(VOID FAR * str, unsigned len); #endif @@ -290,6 +290,7 @@ COUNT DosSetCountry(UWORD cntry); #endif COUNT DosGetCodepage(UWORD * actCP, UWORD * sysCP); COUNT DosSetCodepage(UWORD actCP, UWORD sysCP); +VOID FAR *DosGetDBCS(void); UWORD ASMCFUNC syscall_MUX14(DIRECT_IREGS); /* prf.c */ From 66e2a7d1748a176bb2f6625dc16278a99d1d74dd Mon Sep 17 00:00:00 2001 From: Luchezar Georgiev Date: Mon, 13 Sep 2004 12:09:37 +0000 Subject: [PATCH 572/671] Tom's patch releasing near f-nodes on Int 24 that returns to user git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/branches/UNSTABLE@1041 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/inthndlr.c | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/kernel/inthndlr.c b/kernel/inthndlr.c index d2ea990a..3d0fc012 100644 --- a/kernel/inthndlr.c +++ b/kernel/inthndlr.c @@ -411,7 +411,13 @@ VOID ASMCFUNC int21_service(iregs FAR * r) } /* Clear carry by default for these functions */ - + /* see PATCH TE 5 jul 04 explanation at end */ + if (ErrorMode && lr.AH > 0x0c && lr.AH != 0x30 && lr.AH != 0x59) + { + ErrorMode = 0; + fnode[0].f_count = 0; /* don't panic - THEY ARE unused !! */ + fnode[1].f_count = 0; + } /* Check for Ctrl-Break */ if (break_ena || (lr.AH >= 1 && lr.AH <= 5) || (lr.AH >= 8 && lr.AH <= 0x0b)) check_handle_break(&syscon); @@ -1499,6 +1505,31 @@ VOID ASMCFUNC int21_service(iregs FAR * r) r->ES = lr.ES; real_exit:; + /* PATCH !! TE 5 JUL 04 + what happened: + Application does FindFirst("I:\*.*"); + this fails, and causes Int24 + this sets ErrorMode, and calls Int24 + Application decides NOT to return to DOS, + but instead pop the stack and return to itself + (this is legal; see RBIL/INT 24 description + + a) now the alloc()'ed fnode[0] never gets free()'ed + b) errormode NEVER gets set back to 0 unyil exit() + + I have NO idea how real DOS handles this; + the appended patch cures the worst symptoms + */ + if (fnode[0].f_count != 0 || + fnode[1].f_count != 0 ) + { + if (ErrorMode == 0) + put_string("near_fnodes not 0"); /* panic ?? */ + fnode[0].f_count = 0; /* don't panic - THEY ARE unused !! */ + fnode[1].f_count = 0; + } + /* PATCH !! END TE 5 JUL 04 */ + #ifdef DEBUG if (bDumpRegs) { From 91189d36087100f16b0e41c9359560c82590a768 Mon Sep 17 00:00:00 2001 From: Luchezar Georgiev Date: Tue, 14 Sep 2004 15:02:17 +0000 Subject: [PATCH 573/671] Creation time/date set on create instead of write time/date (set on close) git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/branches/UNSTABLE@1043 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/fatfs.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/kernel/fatfs.c b/kernel/fatfs.c index b4ec5ada..75120fbe 100644 --- a/kernel/fatfs.c +++ b/kernel/fatfs.c @@ -100,7 +100,7 @@ struct dpb FAR *get_dpb(COUNT dsk) return cdsp->cdsDpb; } -/* initialize directory entry (creation/access stamps 0 as per MS-DOS 7.10) */ +/* initialize directory entry */ STATIC void init_direntry(struct dirent *dentry, unsigned attrib, CLUSTER cluster, char *name) { @@ -111,8 +111,8 @@ STATIC void init_direntry(struct dirent *dentry, unsigned attrib, #endif dentry->dir_start = (UWORD)cluster; dentry->dir_attrib = (UBYTE)attrib; - dentry->dir_time = dos_gettime(); - dentry->dir_date = dos_getdate(); + dentry->dir_crtime = dos_gettime(); + dentry->dir_crdate = dos_getdate(); } /************************************************************************/ From 6aad41e7d578b3890230c392bf5772d1a886cb5b Mon Sep 17 00:00:00 2001 From: Luchezar Georgiev Date: Wed, 15 Sep 2004 09:01:28 +0000 Subject: [PATCH 574/671] Fix a typo git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/branches/UNSTABLE@1044 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/config.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/config.c b/kernel/config.c index 1e036f67..ef1e6cdd 100644 --- a/kernel/config.c +++ b/kernel/config.c @@ -1924,7 +1924,7 @@ STATIC VOID DoMenu(void) if (MenuTimeout >= 0) { show_choices(choicey); - printf(" Time remainig: %d ", MenuTimeout); + printf(" Time remaining: %d ", MenuTimeout); gotoxy(show_choices(choicey), choicey); key = GetBiosKey(1); /* poll keyboard 1 second */ From d87c8972fb20a4dbe4bfbb1bedd57d4e2669983a Mon Sep 17 00:00:00 2001 From: Luchezar Georgiev Date: Sun, 19 Sep 2004 17:01:16 +0000 Subject: [PATCH 575/671] fix MKDIR timestamp bug introduced in previous revision git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/branches/UNSTABLE@1048 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/fatfs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/fatfs.c b/kernel/fatfs.c index 75120fbe..fd604d46 100644 --- a/kernel/fatfs.c +++ b/kernel/fatfs.c @@ -111,8 +111,8 @@ STATIC void init_direntry(struct dirent *dentry, unsigned attrib, #endif dentry->dir_start = (UWORD)cluster; dentry->dir_attrib = (UBYTE)attrib; - dentry->dir_crtime = dos_gettime(); - dentry->dir_crdate = dos_getdate(); + dentry->dir_crtime = dentry->dir_time = dos_gettime(); + dentry->dir_crdate = dentry->dir_date = dos_getdate(); } /************************************************************************/ From b5b7fec1a80d62a2afe903ab88c67276c366d741 Mon Sep 17 00:00:00 2001 From: Kenneth J Davis Date: Mon, 20 Sep 2004 09:41:42 +0000 Subject: [PATCH 576/671] include OEM MS/PC boot sector in sys by default git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/branches/UNSTABLE@1050 6ac86273-5f31-0410-b378-82cca8765d1b --- sys/sys.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/sys.c b/sys/sys.c index 481cf569..1afb43d4 100644 --- a/sys/sys.c +++ b/sys/sys.c @@ -28,7 +28,7 @@ #define DEBUG /* #define DDEBUG */ -/* #define WITHOEMCOMPATBS */ /* uncomment for larger sys that support MS/PC DOS */ +#define WITHOEMCOMPATBS /* include support for OEM MS/PC DOS 3.??-6.x */ #define SYS_VERSION "v3.4" From 1e507dae69dcf91fd8c3371637dad80933590fef Mon Sep 17 00:00:00 2001 From: Luchezar Georgiev Date: Wed, 22 Sep 2004 18:41:58 +0000 Subject: [PATCH 577/671] Now can read all COUNTRY.SYS data but LCASE/DBCS/YESNO git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/branches/UNSTABLE@1051 6ac86273-5f31-0410-b378-82cca8765d1b --- hdr/nls.h | 12 ++++---- kernel/config.c | 71 +++++++++++++++++++++++++++++++---------------- kernel/init-mod.h | 8 ------ kernel/nls_hc.asm | 4 +-- 4 files changed, 55 insertions(+), 40 deletions(-) diff --git a/hdr/nls.h b/hdr/nls.h index 2ebfb723..af9763ac 100644 --- a/hdr/nls.h +++ b/hdr/nls.h @@ -478,12 +478,12 @@ struct nlsInfoBlock { /* This block contains all information extern struct nlsInfoBlock nlsInfo; extern struct nlsPackage ASM nlsPackageHardcoded; /* These are the "must have" tables within the hard coded NLS pkg */ -extern struct nlsFnamTerm nlsFnameTermHardcoded; -extern struct nlsDBCS ASM nlsDBCSHardcoded; -extern struct nlsCharTbl nlsUpcaseHardcoded; -extern struct nlsCharTbl nlsFUpcaseHardcoded; -extern struct nlsCharTbl nlsCollHardcoded; -extern struct nlsExtCntryInfo nlsCntryInfoHardcoded; +extern struct nlsFnamTerm FAR ASM nlsFnameTermHardcoded; +extern struct nlsDBCS FAR ASM nlsDBCSHardcoded; +extern struct nlsCharTbl FAR ASM nlsUpcaseHardcoded; +extern struct nlsCharTbl FAR ASM nlsFUpcaseHardcoded; +extern struct nlsCharTbl FAR ASM nlsCollHardcoded; +extern struct nlsExtCntryInfo FAR ASM nlsCntryInfoHardcoded; extern BYTE FAR hcTablesStart[], hcTablesEnd[]; /*********************************************************************** diff --git a/kernel/config.c b/kernel/config.c index ef1e6cdd..a61879b7 100644 --- a/kernel/config.c +++ b/kernel/config.c @@ -1170,17 +1170,32 @@ STATIC void LoadCountryInfo(CStr filename, int ccode, int cpage) int reserved[2]; ULONG offset; /* offset of country-subfunction-header in file */ } entry; - struct { /* subfunction header */ + struct subf_hdr { /* subfunction header */ int length; /* length of entry, not counting this word, = 6 */ int id; /* subfunction ID */ ULONG offset; /* offset within file of subfunction data entry */ - } subf_hdr; - struct { /* subfunction data */ + }; + static struct { /* subfunction data */ char signature[8]; /* \377CTYINFO|UCASE|LCASE|FUCASE|FCHAR|COLLATE|DBCS */ int length; /* length of following table in bytes */ + UBYTE buffer[256]; } subf_data; - struct CountrySpecificInfo country; - int fd, entries, count, i, j; + struct subf_tbl { + char sig[8]; /* signature for each subfunction data */ + void FAR *p; /* pointer to data in nls_hc.asm to be copied to */ + }; + static struct subf_tbl table[8] = { + {"\377 ", NULL}, /* 0, unused */ + {"\377CTYINFO", &nlsCntryInfoHardcoded},/* 1 */ + {"\377UCASE ", &nlsUpcaseHardcoded}, /* 2 */ + {"\377LCASE ", NULL}, /* 3, not supported [yet] */ + {"\377FUCASE ", &nlsFUpcaseHardcoded}, /* 4 */ + {"\377FCHAR ", &nlsFnameTermHardcoded},/* 5 */ + {"\377COLLATE", &nlsCollHardcoded}, /* 6 */ + {"\377DBCS ", &nlsDBCSHardcoded} /* 7, not supported [yet] */ + }; + static struct subf_hdr hdr[8]; + int fd, entries, count, i; if ((fd = open(filename, 0)) < 0) { @@ -1192,7 +1207,7 @@ STATIC void LoadCountryInfo(CStr filename, int ccode, int cpage) printf("Can't read %s\n", filename); goto ret; } - if (memcmp(&header.name, "\377COUNTRY", 8)) + if (memcmp(header.name, "\377COUNTRY", sizeof(header.name))) { err:printf("%s has invalid format\n", filename); goto ret; @@ -1207,30 +1222,38 @@ err:printf("%s has invalid format\n", filename); if (entry.country != ccode || entry.codepage != cpage && cpage) continue; if (lseek(fd, entry.offset) == 0xffffffffL - || read(fd, &count, sizeof(count)) < sizeof(count)) + || read(fd, &count, sizeof(count)) < sizeof(count) + || count > LENGTH(hdr) + || read(fd, &hdr, sizeof(struct subf_hdr) * count) + < sizeof(struct subf_hdr) * count) goto err; - for (j = 0; j < count; j++) + for (i = 0; i < count; i++) { - if (read(fd, &subf_hdr, sizeof(subf_hdr)) < sizeof(subf_hdr) - || subf_hdr.length != 6) + if (hdr[i].length != 6) goto err; - if (subf_hdr.id != 1) + if (hdr[i].id < 1 || hdr[i].id > 6 || hdr[i].id == 3) continue; - if (lseek(fd, subf_hdr.offset) == 0xffffffffL - || read(fd, &subf_data, sizeof(subf_data)) < sizeof(subf_data) - || memcmp(&subf_data.signature, "\377CTYINFO", 8)) + if (lseek(fd, hdr[i].offset) == 0xffffffffL + || read(fd, &subf_data, 10) < 10 + || memcmp(subf_data.signature, table[hdr[i].id].sig, 8) && hdr[i].id == 4 + && memcmp(subf_data.signature, table[2].sig, 8) /* UCASE for FUCASE ^*/ + || read(fd, subf_data.buffer, subf_data.length) < subf_data.length) goto err; - if (read(fd, &country, sizeof(country)) < sizeof(country)) - goto err; - if (country.CountryID != entry.country - || country.CodePage != entry.codepage && cpage) - continue; - i = nlsCountryInfoHardcoded.C.CodePage; - fmemcpy(&nlsCountryInfoHardcoded.C, &country, - min(sizeof(country), subf_data.length)); - nlsCountryInfoHardcoded.C.CodePage = i; - goto ret; + if (hdr[i].id == 1) + { + if (((struct CountrySpecificInfo *)subf_data.buffer)->CountryID + != entry.country + || ((struct CountrySpecificInfo *)subf_data.buffer)->CodePage + != entry.codepage + && cpage) + continue; + subf_data.length = /* MS-DOS "CTYINFO" is up to 38 bytes */ + min(subf_data.length, sizeof(struct CountrySpecificInfo)); + } + fmemcpy((BYTE FAR *)(table[hdr[i].id].p) + 2, subf_data.buffer, + /* skip length ^*/ subf_data.length); } + goto ret; } printf("couldn't find country info for country ID %u\n", ccode); ret: diff --git a/kernel/init-mod.h b/kernel/init-mod.h index a8b0693c..dec5bbe9 100644 --- a/kernel/init-mod.h +++ b/kernel/init-mod.h @@ -263,14 +263,6 @@ extern BYTE DOSFAR _InitTextStart, /* first available byte of ram extern BYTE FAR ASM internal_data[]; extern unsigned char FAR ASM kbdType; -extern struct { - char ThisIsAConstantOne; - short TableSize; - - struct CountrySpecificInfo C; - -} FAR ASM nlsCountryInfoHardcoded; - /* data shared between DSK.C and INITDISK.C */ diff --git a/kernel/nls_hc.asm b/kernel/nls_hc.asm index 7acee739..adaadae6 100644 --- a/kernel/nls_hc.asm +++ b/kernel/nls_hc.asm @@ -23,9 +23,9 @@ _nlsPackageHardcoded: DW ?table6, SEG ?table6 DB 007h DW ?table7, SEG ?table7 - GLOBAL _nlsCountryInfoHardcoded -_nlsCountryInfoHardcoded: DB 001h + GLOBAL _nlsCntryInfoHardcoded +_nlsCntryInfoHardcoded: ?table1: DB 01ch, 000h, 001h, 000h, 0b5h, 001h, 000h, 000h DB 024h, 000h, 000h, 000h, 000h, 02ch, 000h, 02eh From 08e3c61ebc88fcab28567f56ec4d0257061e2f22 Mon Sep 17 00:00:00 2001 From: Luchezar Georgiev Date: Thu, 23 Sep 2004 06:24:28 +0000 Subject: [PATCH 578/671] Fix COUNTRY.SYS error processing logic when UCASE is used as FUCASE git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/branches/UNSTABLE@1052 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/config.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/config.c b/kernel/config.c index a61879b7..f3407fc2 100644 --- a/kernel/config.c +++ b/kernel/config.c @@ -1235,8 +1235,8 @@ err:printf("%s has invalid format\n", filename); continue; if (lseek(fd, hdr[i].offset) == 0xffffffffL || read(fd, &subf_data, 10) < 10 - || memcmp(subf_data.signature, table[hdr[i].id].sig, 8) && hdr[i].id == 4 - && memcmp(subf_data.signature, table[2].sig, 8) /* UCASE for FUCASE ^*/ + || memcmp(subf_data.signature, table[hdr[i].id].sig, 8) && (hdr[i].id !=4 + || memcmp(subf_data.signature, table[2].sig, 8)) /* UCASE for FUCASE ^*/ || read(fd, subf_data.buffer, subf_data.length) < subf_data.length) goto err; if (hdr[i].id == 1) From d9d31322aa799e4dddf2e041e40e52fae9af94eb Mon Sep 17 00:00:00 2001 From: Luchezar Georgiev Date: Thu, 23 Sep 2004 07:43:17 +0000 Subject: [PATCH 579/671] Fix SET PATH=xxx in CONFIG.SYS git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/branches/UNSTABLE@1053 6ac86273-5f31-0410-b378-82cca8765d1b --- docs/history.txt | 3 ++- kernel/config.c | 9 +++++++-- kernel/main.c | 6 ------ 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/docs/history.txt b/docs/history.txt index a36d68d2..d817c004 100644 --- a/docs/history.txt +++ b/docs/history.txt @@ -311,7 +311,7 @@ * break.c: check_handle_break() return was undefined if no Ctrl-break * config.sys: all commands removed as they were close to defaults * contrib.txt: added Aitor Santamaria, Bernd Blaauw and Eduardo Casino - * country.asm / country.sys support now replaces hard-coded data + * country.asm / config.c: COUNTRY.SYS now replaces hard-coded data * 11 countries added to country.asm: GR,RO,AT,MA,SG,KR,CN,TR,IN,M.E,IL * dosnames.c: macro to function conversion, optimisation and clean-up * dyninit.c: excluded unused DynFree(), "what" passed only on DEBUG @@ -336,6 +336,7 @@ - InitializeAllBPBs() kludge removed (no longer needed - verified) - revision sequence now initialised along with DOS version in LoL - CheckContinueBootFromHardDisk() function code and text cleaned up + - "PATH=." now static in config.c ->SET PATH=xxx in CONFIG.SYS works * makefile: object files reordered to gain ~300B packed size * newstuff.c, fatdir.c, blockio.c, chario.c, prf.c: cleanup & optimise * portab.h: pragma aux default to gain ~800B unpacked size (Watcom) diff --git a/kernel/config.c b/kernel/config.c index f3407fc2..1ab5319c 100644 --- a/kernel/config.c +++ b/kernel/config.c @@ -2110,8 +2110,13 @@ VOID DoInstall(void) /* master_env copied over command line area in DOS_PSP, thus its size limited to 128 bytes */ -static char master_env[128] BSS_INIT({0}); -static PStr envp = master_env; +static char master_env[128] = "PATH=."; + + /* !!! dirty hack: because bug in old FreeCOM, which wrongly + process empty environment in MS-DOS style, garbage empty + environment by dummy variable: --avb + */ +static PStr envp = master_env + 7; /* sizeof("PATH=.") + 1 zero */ /* Format: SET var = string */ STATIC void CmdSet(PCStr p) diff --git a/kernel/main.c b/kernel/main.c index bd54324a..714354ec 100644 --- a/kernel/main.c +++ b/kernel/main.c @@ -175,12 +175,6 @@ STATIC void PSPInit(void) /* this area reused for master environment */ /*p->ps_cmd.ctCount = 0;*/ /* local command line */ /*p->ps_cmd.ctBuffer[0] = '\r';*/ /* command tail */ - - /* !!! dirty hack: because bug in old FreeCOM, which wrongly - process empty environment in MS-DOS style, garbage empty - environment by dummy variable: --avb - */ - fmemcpy(&p->ps_cmd, "PATH=.", 6/*strlen("PATH=.")*/); } #ifndef __WATCOMC__ From 003933efdb7dba7541ac0efd50b9e8c109315316 Mon Sep 17 00:00:00 2001 From: Luchezar Georgiev Date: Thu, 23 Sep 2004 13:08:23 +0000 Subject: [PATCH 580/671] Divide hard-coded UCASE and FUCASE tables git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/branches/UNSTABLE@1054 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/nls_hc.asm | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/kernel/nls_hc.asm b/kernel/nls_hc.asm index adaadae6..e59c5a65 100644 --- a/kernel/nls_hc.asm +++ b/kernel/nls_hc.asm @@ -35,12 +35,29 @@ extern _CharMapSrvc:wrt DGROUP DB 02ch, 000h GLOBAL _hcTablesStart _hcTablesStart: - GLOBAL _nlsFUpcaseHardcoded -_nlsFUpcaseHardcoded: -?table4: GLOBAL _nlsUpcaseHardcoded _nlsUpcaseHardcoded: ?table2: + DB 080h, 000h, 080h, 09ah, 045h, 041h, 08eh, 041h + DB 08fh, 080h, 045h, 045h, 045h, 049h, 049h, 049h + DB 08eh, 08fh, 090h, 092h, 092h, 04fh, 099h, 04fh + DB 055h, 055h, 059h, 099h, 09ah, 09bh, 09ch, 09dh + DB 09eh, 09fh, 041h, 049h, 04fh, 055h, 0a5h, 0a5h + DB 0a6h, 0a7h, 0a8h, 0a9h, 0aah, 0abh, 0ach, 0adh + DB 0aeh, 0afh, 0b0h, 0b1h, 0b2h, 0b3h, 0b4h, 0b5h + DB 0b6h, 0b7h, 0b8h, 0b9h, 0bah, 0bbh, 0bch, 0bdh + DB 0beh, 0bfh, 0c0h, 0c1h, 0c2h, 0c3h, 0c4h, 0c5h + DB 0c6h, 0c7h, 0c8h, 0c9h, 0cah, 0cbh, 0cch, 0cdh + DB 0ceh, 0cfh, 0d0h, 0d1h, 0d2h, 0d3h, 0d4h, 0d5h + DB 0d6h, 0d7h, 0d8h, 0d9h, 0dah, 0dbh, 0dch, 0ddh + DB 0deh, 0dfh, 0e0h, 0e1h, 0e2h, 0e3h, 0e4h, 0e5h + DB 0e6h, 0e7h, 0e8h, 0e9h, 0eah, 0ebh, 0ech, 0edh + DB 0eeh, 0efh, 0f0h, 0f1h, 0f2h, 0f3h, 0f4h, 0f5h + DB 0f6h, 0f7h, 0f8h, 0f9h, 0fah, 0fbh, 0fch, 0fdh + DB 0feh, 0ffh + GLOBAL _nlsFUpcaseHardcoded +_nlsFUpcaseHardcoded: +?table4: DB 080h, 000h, 080h, 09ah, 045h, 041h, 08eh, 041h DB 08fh, 080h, 045h, 045h, 045h, 049h, 049h, 049h DB 08eh, 08fh, 090h, 092h, 092h, 04fh, 099h, 04fh From 279107ab8e58cbb7ec84d3aa44b91790c3aedaae Mon Sep 17 00:00:00 2001 From: Luchezar Georgiev Date: Wed, 3 Nov 2004 18:37:16 +0000 Subject: [PATCH 581/671] A much richer updated COUNTRY.SYS by Eduardo git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/branches/UNSTABLE@1061 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/country.asm | 4270 ++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 3917 insertions(+), 353 deletions(-) diff --git a/kernel/country.asm b/kernel/country.asm index 71f4ffb6..af6d8163 100644 --- a/kernel/country.asm +++ b/kernel/country.asm @@ -41,143 +41,346 @@ db 0FFh,"COUNTRY",0,0,0,0,0,0,0,0,1,0,1 ; reserved and undocumented values dd ent ; first entry -ent dw 63; number of entries - don't forget to update when adding a new country +ent dw 162; number of entries - don't forget to update when adding a new country ; entries ; (size, country, codepage, reserved(2), offset) +; Countries 0 - 999 (Standard) +; __us_437 dw 12, 1,437,0,0 dd _us_437 __us_850 dw 12, 1,850,0,0 dd _us_850 __us_858 dw 12, 1,858,0,0 dd _us_858 -__ca dw 12, 2,863,0,0 - dd _ca -__la_850 dw 12, 3,850,0,0 - dd _la_850 +__ca_863 dw 12, 2,863,0,0 + dd _ca_863 +__ca_850 dw 12, 2,850,0,0 + dd _ca_850 +__ca_858 dw 12, 2,858,0,0 + dd _ca_858 __la_858 dw 12, 3,858,0,0 dd _la_858 +__la_850 dw 12, 3,850,0,0 + dd _la_850 __la_437 dw 12, 3,437,0,0 dd _la_437 -__ru dw 12, 7,866,0,0 - dd _ru -__gr dw 12, 30,869,0,0 - dd _gr -__nl_850 dw 12, 31,850,0,0 - dd _nl_850 +__ru_866 dw 12, 7,866,0,0 + dd _ru_866 +__ru_808 dw 12, 7,808,0,0 + dd _ru_808 +__ru_855 dw 12, 7,855,0,0 + dd _ru_855 +__ru_872 dw 12, 7,872,0,0 + dd _ru_872 +__ru_852 dw 12, 7,852,0,0 + dd _ru_852 +__ru_850 dw 12, 7,850,0,0 + dd _ru_850 +__ru_858 dw 12, 7,858,0,0 + dd _ru_858 +__ru_437 dw 12, 7,437,0,0 + dd _ru_437 +__gr_869 dw 12, 30,869,0,0 + dd _gr_869 +__gr_737 dw 12, 30,737,0,0 + dd _gr_737 +__gr_850 dw 12, 30,850,0,0 + dd _gr_850 +__gr_858 dw 12, 30,858,0,0 + dd _gr_858 __nl_858 dw 12, 31,858,0,0 dd _nl_858 -__be_850 dw 12, 32,850,0,0 - dd _be_850 +__nl_850 dw 12, 31,850,0,0 + dd _nl_850 +__nl_437 dw 12, 31,437,0,0 + dd _nl_437 __be_858 dw 12, 32,858,0,0 dd _be_858 -__fr_850 dw 12, 33,850,0,0 - dd _fr_850 +__be_850 dw 12, 32,850,0,0 + dd _be_850 +__be_437 dw 12, 32,437,0,0 + dd _be_437 __fr_858 dw 12, 33,858,0,0 dd _fr_858 -__es_850 dw 12, 34,850,0,0 - dd _es_850 +__fr_850 dw 12, 33,850,0,0 + dd _fr_850 +__fr_437 dw 12, 33,437,0,0 + dd _fr_437 __es_858 dw 12, 34,858,0,0 dd _es_858 +__es_850 dw 12, 34,850,0,0 + dd _es_850 __es_437 dw 12, 34,437,0,0 dd _es_437 -__hu dw 12, 36,852,0,0 - dd _hu -__yu dw 12, 38,852,0,0 - dd _yu -__it_850 dw 12, 39,850,0,0 - dd _it_850 +__hu_852 dw 12, 36,852,0,0 + dd _hu_852 +__hu_850 dw 12, 36,850,0,0 + dd _hu_850 +__hu_858 dw 12, 36,858,0,0 + dd _hu_858 +__yu_852 dw 12, 38,852,0,0 + dd _yu_852 +__yu_855 dw 12, 38,855,0,0 + dd _yu_855 +__yu_872 dw 12, 38,872,0,0 + dd _yu_872 +__yu_858 dw 12, 38,858,0,0 + dd _yu_858 +__yu_850 dw 12, 38,850,0,0 + dd _yu_850 __it_858 dw 12, 39,858,0,0 dd _it_858 -__ro dw 12, 40,852,0,0 - dd _ro -__ch_850 dw 12, 41,850,0,0 - dd _ch_850 +__it_850 dw 12, 39,850,0,0 + dd _it_850 +__it_437 dw 12, 39,437,0,0 + dd _it_437 +__ro_852 dw 12, 40,852,0,0 + dd _ro_852 +__ro_850 dw 12, 40,850,0,0 + dd _ro_850 +__ro_858 dw 12, 40,858,0,0 + dd _ro_858 __ch_858 dw 12, 41,858,0,0 dd _ch_858 -__cz dw 12, 42,852,0,0 - dd _cz -__at_850 dw 12, 43,850,0,0 - dd _at_850 +__ch_850 dw 12, 41,850,0,0 + dd _ch_850 +__ch_437 dw 12, 41,437,0,0 + dd _ch_437 +__cz_852 dw 12, 42,852,0,0 + dd _cz_852 +__cz_850 dw 12, 42,850,0,0 + dd _cz_850 +__cz_858 dw 12, 42,858,0,0 + dd _cz_858 __at_858 dw 12, 43,858,0,0 dd _at_858 +__at_850 dw 12, 43,850,0,0 + dd _at_850 __at_437 dw 12, 43,437,0,0 dd _at_437 -__uk_850 dw 12, 44,850,0,0 - dd _uk_850 __uk_858 dw 12, 44,858,0,0 dd _uk_858 +__uk_850 dw 12, 44,850,0,0 + dd _uk_850 __uk_437 dw 12, 44,437,0,0 dd _uk_437 -__dk dw 12, 45,865,0,0 - dd _dk -__se_850 dw 12, 46,850,0,0 - dd _se_850 +__dk_865 dw 12, 45,865,0,0 + dd _dk_865 +__dk_850 dw 12, 45,850,0,0 + dd _dk_850 +__dk_858 dw 12, 45,858,0,0 + dd _dk_858 __se_858 dw 12, 46,858,0,0 dd _se_858 -__no dw 12, 47,865,0,0 - dd _no -__pl dw 12, 48,852,0,0 - dd _pl -__de_850 dw 12, 49,850,0,0 - dd _de_850 +__se_850 dw 12, 46,850,0,0 + dd _se_850 +__se_437 dw 12, 46,437,0,0 + dd _se_437 +__no_865 dw 12, 47,865,0,0 + dd _no_865 +__no_850 dw 12, 47,850,0,0 + dd _no_850 +__no_858 dw 12, 47,858,0,0 + dd _no_858 +__pl_852 dw 12, 48,852,0,0 + dd _pl_852 +__pl_850 dw 12, 48,850,0,0 + dd _pl_850 +__pl_858 dw 12, 48,858,0,0 + dd _pl_858 __de_858 dw 12, 49,858,0,0 dd _de_858 +__de_850 dw 12, 49,850,0,0 + dd _de_850 __de_437 dw 12, 49,858,0,0 dd _de_437 -__ar_850 dw 12, 54,850,0,0 - dd _ar_850 __ar_858 dw 12, 54,858,0,0 dd _ar_858 +__ar_850 dw 12, 54,850,0,0 + dd _ar_850 __ar_437 dw 12, 54,437,0,0 dd _ar_437 -__br_850 dw 12, 55,850,0,0 - dd _br_850 __br_858 dw 12, 55,858,0,0 dd _br_858 -__my dw 12, 60,437,0,0 - dd _my +__br_850 dw 12, 55,850,0,0 + dd _br_850 +__br_437 dw 12, 55,437,0,0 + dd _br_437 +__my_437 dw 12, 60,437,0,0 + dd _my_437 __au_437 dw 12, 61,437,0,0 dd _au_437 __au_850 dw 12, 61,850,0,0 dd _au_850 __au_858 dw 12, 61,858,0,0 dd _au_858 -__sg dw 12, 65,437,0,0 - dd _sg -__jp dw 12, 81,932,0,0 - dd _jp -__kr dw 12, 82,934,0,0 - dd _kr -__cn dw 12, 86,936,0,0 - dd _cn +__sg_437 dw 12, 65,437,0,0 + dd _sg_437 +__jp_437 dw 12, 81,437,0,0 + dd _jp_437 +__jp_932 dw 12, 81,932,0,0 + dd _jp_932 +__kr_437 dw 12, 82,437,0,0 + dd _kr_437 +__kr_934 dw 12, 82,934,0,0 + dd _kr_934 +__cn_437 dw 12, 86,437,0,0 + dd _cn_437 +__cn_936 dw 12, 86,936,0,0 + dd _cn_936 __tr_857 dw 12, 90,857,0,0 dd _tr_857 __tr_850 dw 12, 90,850,0,0 dd _tr_850 -__in dw 12, 91,437,0,0 - dd _in -__pt dw 12,351,860,0,0 - dd _pt -__fi_850 dw 12,358,850,0,0 - dd _fi_850 +__in_437 dw 12, 91,437,0,0 + dd _in_437 +__pt_860 dw 12,351,860,0,0 + dd _pt_860 +__pt_850 dw 12,351,850,0,0 + dd _pt_850 +__pt_858 dw 12,351,858,0,0 + dd _pt_858 __fi_858 dw 12,358,858,0,0 dd _fi_858 -__bg dw 12,359,855,0,0 - dd _bg -__ua dw 12,380,848,0,0 - dd _ua -__me dw 12,785,864,0,0 - dd _me -__il dw 12,972,862,0,0 - dd _il +__fi_850 dw 12,358,850,0,0 + dd _fi_850 +__fi_437 dw 12,358,437,0,0 + dd _fi_437 +__bg_855 dw 12,359,855,0,0 + dd _bg_855 +__bg_872 dw 12,359,872,0,0 + dd _bg_872 +__bg_850 dw 12,359,850,0,0 + dd _bg_850 +__bg_858 dw 12,359,858,0,0 + dd _bg_858 +__ua_848 dw 12,380,848,0,0 + dd _ua_848 +__ua_1125 dw 12,380,1125,0,0 + dd _ua_1125 +__sr_855 dw 12, 381,855,0,0 ; Serbia and Montenegro, Serbian, Cyrillic + dd _sr_855 +__sr_872 dw 12, 381,872,0,0 + dd _sr_872 +__sr_852 dw 12, 381,852,0,0 ; Serbia and Montenegro, Serbian, Latin + dd _sr_852 +__sr_850 dw 12, 381,850,0,0 + dd _sr_850 +__sr_858 dw 12, 381,858,0,0 + dd _sr_858 +__hr_852 dw 12, 384,852,0,0 ; Croatia, Croatian + dd _hr_852 +__hr_850 dw 12, 384,850,0,0 + dd _hr_850 +__hr_858 dw 12, 384,858,0,0 + dd _hr_858 +__si_852 dw 12, 386,852,0,0 ; Slovenia + dd _si_852 +__si_850 dw 12, 386,850,0,0 + dd _si_850 +__si_858 dw 12, 386,858,0,0 + dd _si_858 +__ba_852 dw 12, 387,852,0,0 ; Bosnia Herzegovina + dd _ba_852 +__ba_850 dw 12, 387,850,0,0 + dd _ba_850 +__ba_858 dw 12, 387,858,0,0 + dd _ba_858 +__ba_855 dw 12, 387,855,0,0 ; Bosnia Herzegovina, Cyrillic + dd _sr_855 +__ba_872 dw 12, 387,872,0,0 + dd _sr_872 +__mk_855 dw 12, 389,855,0,0 ; Macedonia + dd _mk_855 +__mk_872 dw 12, 389,872,0,0 + dd _mk_872 +__mk_850 dw 12, 389,850,0,0 + dd _mk_850 +__mk_858 dw 12, 389,858,0,0 + dd _mk_858 +__me_858 dw 12,785,858,0,0 + dd _me_858 +__me_850 dw 12,785,850,0,0 + dd _me_850 +__me_864 dw 12,785,864,0,0 + dd _me_864 +__il_858 dw 12,972,858,0,0 + dd _il_858 +__il_850 dw 12,972,850,0,0 + dd _il_850 +__il_862 dw 12,972,862,0,0 + dd _il_862 + +; Countries 4x000 - 4x999 (Multilingual) +; +__nl_BE_850 dw 12, 40032,850,0,0 + dd _nl_BE_850 +__nl_BE_858 dw 12, 40032,858,0,0 + dd _nl_BE_858 +__nl_BE_437 dw 12, 40032,437,0,0 + dd _nl_BE_437 +__fr_BE_850 dw 12, 41032,850,0,0 + dd _fr_BE_850 +__fr_BE_858 dw 12, 41032,858,0,0 + dd _fr_BE_858 +__fr_BE_437 dw 12, 41032,437,0,0 + dd _fr_BE_437 +__de_BE_850 dw 12, 42032,850,0,0 + dd _de_BE_850 +__de_BE_858 dw 12, 42032,858,0,0 + dd _de_BE_858 +__de_BE_437 dw 12, 42032,437,0,0 + dd _de_BE_437 +__es_ES_850 dw 12, 40034,850,0,0 + dd _es_ES_850 +__es_ES_858 dw 12, 40034,858,0,0 + dd _es_ES_858 +__es_ES_437 dw 12, 40034,437,0,0 + dd _es_ES_437 +__ca_ES_850 dw 12, 41034,850,0,0 + dd _ca_ES_850 +__ca_ES_858 dw 12, 41034,858,0,0 + dd _ca_ES_858 +__ca_ES_437 dw 12, 41034,437,0,0 + dd _ca_ES_437 +__gl_ES_850 dw 12, 42034,850,0,0 + dd _gl_ES_850 +__gl_ES_858 dw 12, 42034,858,0,0 + dd _gl_ES_858 +__gl_ES_437 dw 12, 42034,437,0,0 + dd _gl_ES_437 +__eu_ES_850 dw 12, 43034,850,0,0 + dd _eu_ES_850 +__eu_ES_858 dw 12, 43034,858,0,0 + dd _eu_ES_858 +__eu_ES_437 dw 12, 43034,437,0,0 + dd _eu_ES_437 +__de_CH_858 dw 12, 40041,858,0,0 + dd _de_CH_858 +__de_CH_850 dw 12, 40041,850,0,0 + dd _de_CH_850 +__de_CH_437 dw 12, 40041,437,0,0 + dd _de_CH_437 +__fr_CH_858 dw 12, 41041,858,0,0 + dd _fr_CH_858 +__fr_CH_850 dw 12, 41041,850,0,0 + dd _fr_CH_850 +__fr_CH_437 dw 12, 41041,437,0,0 + dd _fr_CH_437 +__it_CH_858 dw 12, 42041,858,0,0 + dd _it_CH_858 +__it_CH_850 dw 12, 42041,850,0,0 + dd _it_CH_850 +__it_CH_437 dw 12, 42041,437,0,0 + dd _it_CH_437 ; subfunction headers ; (count, size, id, offset) ; add ofher subfunctions after each one -_us_437 dw 7, +_us_437 dw 7 dw 6,1 dd us_437 dw 6,2 @@ -192,7 +395,7 @@ _us_437 dw 7, dd dbcs_empty dw 6,23 dd en_yn -_us_850 dw 7, +_us_850 dw 7 dw 6,1 dd us_850 dw 6,2 @@ -207,13 +410,13 @@ _us_850 dw 7, dd dbcs_empty dw 6,23 dd en_yn -_us_858 dw 7, +_us_858 dw 7 dw 6,1 dd us_858 dw 6,2 - dd ucase_850 + dd ucase_858 dw 6,4 - dd ucase_850 + dd ucase_858 dw 6,5 dd fchar dw 6,6 @@ -222,27 +425,24 @@ _us_858 dw 7, dd dbcs_empty dw 6,23 dd en_yn -_ca dw 1 - dw 6,1 - dd ca -_la_850 dw 7, +_ca_863 dw 7 dw 6,1 - dd la_850 + dd ca_863 dw 6,2 - dd ucase_850 + dd ucase_863 dw 6,4 - dd ucase_850 + dd ucase_863 dw 6,5 dd fchar dw 6,6 - dd es_collate_850 + dd fr_collate_863 dw 6,7 dd dbcs_empty dw 6,23 - dd es_yn -_la_858 dw 7, + dd fr_yn +_ca_850 dw 7 dw 6,1 - dd la_858 + dd ca_850 dw 6,2 dd ucase_850 dw 6,4 @@ -250,53 +450,29 @@ _la_858 dw 7, dw 6,5 dd fchar dw 6,6 - dd es_collate_858 + dd fr_collate_850 dw 6,7 dd dbcs_empty dw 6,23 - dd es_yn -_la_437 dw 7, + dd fr_yn +_ca_858 dw 7 dw 6,1 - dd la_437 + dd ca_858 dw 6,2 - dd ucase_437 + dd ucase_858 dw 6,4 - dd ucase_437 + dd ucase_858 dw 6,5 dd fchar dw 6,6 - dd es_collate_437 + dd fr_collate_858 dw 6,7 dd dbcs_empty dw 6,23 - dd es_yn -_ru dw 1 - dw 6,1 - dd ru -_gr dw 1 - dw 6,1 - dd gr -_nl_850 dw 1 - dw 6,1 - dd nl_850 -_nl_858 dw 1 - dw 6,1 - dd nl_858 -_be_850 dw 1 - dw 6,1 - dd be_850 -_be_858 dw 1 - dw 6,1 - dd be_858 -_fr_850 dw 1 - dw 6,1 - dd fr_850 -_fr_858 dw 1 - dw 6,1 - dd fr_858 -_es_850 dw 7, + dd fr_yn +_la_850 dw 7 dw 6,1 - dd es_850 + dd la_850 dw 6,2 dd ucase_850 dw 6,4 @@ -309,13 +485,13 @@ _es_850 dw 7, dd dbcs_empty dw 6,23 dd es_yn -_es_858 dw 7, +_la_858 dw 7 dw 6,1 - dd es_858 + dd la_858 dw 6,2 - dd ucase_850 + dd ucase_858 dw 6,4 - dd ucase_850 + dd ucase_858 dw 6,5 dd fchar dw 6,6 @@ -324,9 +500,9 @@ _es_858 dw 7, dd dbcs_empty dw 6,23 dd es_yn -_es_437 dw 7, +_la_437 dw 7 dw 6,1 - dd es_437 + dd la_437 dw 6,2 dd ucase_437 dw 6,4 @@ -339,78 +515,88 @@ _es_437 dw 7, dd dbcs_empty dw 6,23 dd es_yn -_hu dw 1 - dw 6,1 - dd hu -_yu dw 1 - dw 6,1 - dd yu -_it_850 dw 1 - dw 6,1 - dd it_850 -_it_858 dw 1 - dw 6,1 - dd it_858 -_ro dw 1 - dw 6,1 - dd ro -_ch_850 dw 1 +_ru_866 dw 8 dw 6,1 - dd ch_850 -_ch_858 dw 1 - dw 6,1 - dd ch_858 -_cz dw 1 + dd ru_866 + dw 6,2 + dd ucase_866 + dw 6,3 + dd lcase_866 + dw 6,4 + dd ucase_866 + dw 6,5 + dd fchar + dw 6,6 + dd ru_collate_866 + dw 6,7 + dd dbcs_empty + dw 6,23 + dd ru_yn_866 +_ru_808 dw 8 dw 6,1 - dd cz -_at_850 dw 7, + dd ru_808 + dw 6,2 + dd ucase_808 + dw 6,3 + dd lcase_808 + dw 6,4 + dd ucase_808 + dw 6,5 + dd fchar + dw 6,6 + dd ru_collate_808 + dw 6,7 + dd dbcs_empty + dw 6,23 + dd ru_yn_808 +_ru_855 dw 7 dw 6,1 - dd at_850 + dd ru_855 dw 6,2 - dd ucase_850 + dd ucase_855 dw 6,4 - dd ucase_850 + dd ucase_855 dw 6,5 dd fchar dw 6,6 - dd de_collate_850 + dd ru_collate_855 dw 6,7 dd dbcs_empty dw 6,23 - dd de_yn -_at_858 dw 7, + dd ru_yn_855 +_ru_872 dw 7 dw 6,1 - dd at_858 + dd ru_872 dw 6,2 - dd ucase_850 + dd ucase_872 dw 6,4 - dd ucase_850 + dd ucase_872 dw 6,5 dd fchar dw 6,6 - dd de_collate_858 + dd ru_collate_872 dw 6,7 dd dbcs_empty dw 6,23 - dd de_yn -_at_437 dw 7, + dd ru_yn_872 +_ru_852 dw 7 dw 6,1 - dd at_437 + dd ru_852 dw 6,2 - dd ucase_437 + dd ucase_852 dw 6,4 - dd ucase_437 + dd ucase_852 dw 6,5 dd fchar dw 6,6 - dd de_collate_437 + dd ru_collate_852 dw 6,7 dd dbcs_empty dw 6,23 - dd de_yn -_uk_850 dw 7, + dd ru_yn +_ru_850 dw 7 dw 6,1 - dd uk_850 + dd ru_850 dw 6,2 dd ucase_850 dw 6,4 @@ -418,29 +604,29 @@ _uk_850 dw 7, dw 6,5 dd fchar dw 6,6 - dd en_collate_850 + dd ru_collate_850 dw 6,7 dd dbcs_empty dw 6,23 - dd en_yn -_uk_858 dw 7, + dd ru_yn +_ru_858 dw 7 dw 6,1 - dd uk_858 + dd ru_858 dw 6,2 - dd ucase_850 + dd ucase_858 dw 6,4 - dd ucase_850 + dd ucase_858 dw 6,5 dd fchar dw 6,6 - dd en_collate_858 + dd ru_collate_858 dw 6,7 dd dbcs_empty dw 6,23 - dd en_yn -_uk_437 dw 7, + dd ru_yn +_ru_437 dw 7 dw 6,1 - dd uk_437 + dd ru_437 dw 6,2 dd ucase_437 dw 6,4 @@ -448,29 +634,44 @@ _uk_437 dw 7, dw 6,5 dd fchar dw 6,6 - dd en_collate_437 + dd ru_collate_437 dw 6,7 dd dbcs_empty dw 6,23 - dd en_yn -_dk dw 1 - dw 6,1 - dd dk -_se_850 dw 1 - dw 6,1 - dd se_850 -_se_858 dw 1 + dd ru_yn +_gr_869 dw 7 dw 6,1 - dd se_858 -_no dw 1 - dw 6,1 - dd no -_pl dw 1 + dd gr_869 + dw 6,2 + dd ucase_869 + dw 6,4 + dd ucase_869 + dw 6,5 + dd fchar + dw 6,6 + dd gr_collate_869 + dw 6,7 + dd dbcs_empty + dw 6,23 + dd gr_yn_869 +_gr_737 dw 7 dw 6,1 - dd pl -_de_850 dw 7, + dd gr_737 + dw 6,2 + dd ucase_737 + dw 6,4 + dd ucase_737 + dw 6,5 + dd fchar + dw 6,6 + dd gr_collate_737 + dw 6,7 + dd dbcs_empty + dw 6,23 + dd gr_yn_737 +_gr_850 dw 7 dw 6,1 - dd de_850 + dd gr_850 dw 6,2 dd ucase_850 dw 6,4 @@ -478,14 +679,29 @@ _de_850 dw 7, dw 6,5 dd fchar dw 6,6 - dd de_collate_850 + dd gr_collate_850 dw 6,7 dd dbcs_empty dw 6,23 - dd de_yn -_de_858 dw 7, + dd gr_yn +_gr_858 dw 7 dw 6,1 - dd de_858 + dd gr_858 + dw 6,2 + dd ucase_858 + dw 6,4 + dd ucase_858 + dw 6,5 + dd fchar + dw 6,6 + dd gr_collate_858 + dw 6,7 + dd dbcs_empty + dw 6,23 + dd gr_yn +_nl_850 dw 7 + dw 6,1 + dd nl_850 dw 6,2 dd ucase_850 dw 6,4 @@ -493,29 +709,29 @@ _de_858 dw 7, dw 6,5 dd fchar dw 6,6 - dd de_collate_858 + dd nl_collate_850 dw 6,7 dd dbcs_empty dw 6,23 - dd de_yn -_de_437 dw 7, + dd nl_yn +_nl_858 dw 7 dw 6,1 - dd de_437 + dd nl_858 dw 6,2 - dd ucase_437 + dd ucase_858 dw 6,4 - dd ucase_437 + dd ucase_858 dw 6,5 dd fchar dw 6,6 - dd de_collate_437 + dd nl_collate_858 dw 6,7 dd dbcs_empty dw 6,23 - dd de_yn -_ar_437 dw 7, + dd nl_yn +_nl_437 dw 7 dw 6,1 - dd ar_437 + dd nl_437 dw 6,2 dd ucase_437 dw 6,4 @@ -523,14 +739,14 @@ _ar_437 dw 7, dw 6,5 dd fchar dw 6,6 - dd es_collate_437 + dd nl_collate_437 dw 6,7 dd dbcs_empty dw 6,23 - dd es_yn -_ar_850 dw 7, + dd nl_yn +_be_850 dw 7 dw 6,1 - dd ar_850 + dd be_850 dw 6,2 dd ucase_850 dw 6,4 @@ -538,38 +754,29 @@ _ar_850 dw 7, dw 6,5 dd fchar dw 6,6 - dd es_collate_850 + dd be_collate_850 dw 6,7 dd dbcs_empty dw 6,23 - dd es_yn -_ar_858 dw 7, + dd nl_yn +_be_858 dw 7 dw 6,1 - dd ar_858 + dd be_858 dw 6,2 - dd ucase_850 + dd ucase_858 dw 6,4 - dd ucase_850 + dd ucase_858 dw 6,5 dd fchar dw 6,6 - dd es_collate_858 + dd be_collate_858 dw 6,7 dd dbcs_empty dw 6,23 - dd es_yn -_br_850 dw 1 - dw 6,1 - dd br_850 -_br_858 dw 1 - dw 6,1 - dd br_858 -_my dw 1 - dw 6,1 - dd my -_au_437 dw 7, + dd nl_yn +_be_437 dw 7 dw 6,1 - dd au_437 + dd be_437 dw 6,2 dd ucase_437 dw 6,4 @@ -577,14 +784,14 @@ _au_437 dw 7, dw 6,5 dd fchar dw 6,6 - dd en_collate_437 + dd be_collate_437 dw 6,7 dd dbcs_empty dw 6,23 - dd en_yn -_au_850 dw 7, + dd nl_yn +_fr_850 dw 7 dw 6,1 - dd au_850 + dd fr_850 dw 6,2 dd ucase_850 dw 6,4 @@ -592,14 +799,44 @@ _au_850 dw 7, dw 6,5 dd fchar dw 6,6 - dd en_collate_850 + dd fr_collate_850 dw 6,7 dd dbcs_empty dw 6,23 - dd en_yn -_au_858 dw 7, + dd fr_yn +_fr_858 dw 7 dw 6,1 - dd au_858 + dd fr_858 + dw 6,2 + dd ucase_858 + dw 6,4 + dd ucase_858 + dw 6,5 + dd fchar + dw 6,6 + dd fr_collate_858 + dw 6,7 + dd dbcs_empty + dw 6,23 + dd fr_yn +_fr_437 dw 7 + dw 6,1 + dd fr_437 + dw 6,2 + dd ucase_437 + dw 6,4 + dd ucase_437 + dw 6,5 + dd fchar + dw 6,6 + dd fr_collate_437 + dw 6,7 + dd dbcs_empty + dw 6,23 + dd fr_yn +_es_850 dw 7 + dw 6,1 + dd es_850 dw 6,2 dd ucase_850 dw 6,4 @@ -607,53 +844,1980 @@ _au_858 dw 7, dw 6,5 dd fchar dw 6,6 - dd en_collate_858 + dd es_collate_850 dw 6,7 dd dbcs_empty dw 6,23 - dd en_yn -_sg dw 1 - dw 6,1 - dd sg -_jp dw 1 + dd es_yn +_es_858 dw 7 dw 6,1 - dd np -_kr dw 1 + dd es_858 + dw 6,2 + dd ucase_858 + dw 6,4 + dd ucase_858 + dw 6,5 + dd fchar + dw 6,6 + dd es_collate_858 + dw 6,7 + dd dbcs_empty + dw 6,23 + dd es_yn +_es_437 dw 7 dw 6,1 - dd kr -_cn dw 1 + dd es_437 + dw 6,2 + dd ucase_437 + dw 6,4 + dd ucase_437 + dw 6,5 + dd fchar + dw 6,6 + dd es_collate_437 + dw 6,7 + dd dbcs_empty + dw 6,23 + dd es_yn +_hu_852 dw 7 + dw 6,1 + dd hu_852 + dw 6,2 + dd ucase_852 + dw 6,4 + dd ucase_852 + dw 6,5 + dd fchar + dw 6,6 + dd hu_collate_852 + dw 6,7 + dd dbcs_empty + dw 6,23 + dd hu_yn +_hu_850 dw 7 + dw 6,1 + dd hu_850 + dw 6,2 + dd ucase_850 + dw 6,4 + dd ucase_850 + dw 6,5 + dd fchar + dw 6,6 + dd hu_collate_850 + dw 6,7 + dd dbcs_empty + dw 6,23 + dd hu_yn +_hu_858 dw 7 + dw 6,1 + dd hu_850 + dw 6,2 + dd ucase_858 + dw 6,4 + dd ucase_858 + dw 6,5 + dd fchar + dw 6,6 + dd hu_collate_858 + dw 6,7 + dd dbcs_empty + dw 6,23 + dd hu_yn +_yu_852 dw 7 + dw 6,1 + dd yu_852 + dw 6,2 + dd ucase_852 + dw 6,4 + dd ucase_852 + dw 6,5 + dd fchar + dw 6,6 + dd sh_collate_852 + dw 6,7 + dd dbcs_empty + dw 6,23 + dd sh_yn +_yu_855 dw 7 + dw 6,1 + dd yu_855 + dw 6,2 + dd ucase_855 + dw 6,4 + dd ucase_855 + dw 6,5 + dd fchar + dw 6,6 + dd sh_collate_855 + dw 6,7 + dd dbcs_empty + dw 6,23 + dd sh_yn_855 +_yu_872 dw 7 + dw 6,1 + dd yu_872 + dw 6,2 + dd ucase_872 + dw 6,4 + dd ucase_872 + dw 6,5 + dd fchar + dw 6,6 + dd sh_collate_872 + dw 6,7 + dd dbcs_empty + dw 6,23 + dd sh_yn_872 +_yu_850 dw 7 + dw 6,1 + dd yu_850 + dw 6,2 + dd ucase_850 + dw 6,4 + dd ucase_850 + dw 6,5 + dd fchar + dw 6,6 + dd sh_collate_850 + dw 6,7 + dd dbcs_empty + dw 6,23 + dd sh_yn +_yu_858 dw 7 + dw 6,1 + dd yu_858 + dw 6,2 + dd ucase_858 + dw 6,4 + dd ucase_858 + dw 6,5 + dd fchar + dw 6,6 + dd sh_collate_858 + dw 6,7 + dd dbcs_empty + dw 6,23 + dd sh_yn +_it_850 dw 7 + dw 6,1 + dd it_850 + dw 6,2 + dd ucase_850 + dw 6,4 + dd ucase_850 + dw 6,5 + dd fchar + dw 6,6 + dd it_collate_850 + dw 6,7 + dd dbcs_empty + dw 6,23 + dd it_yn +_it_858 dw 7 + dw 6,1 + dd it_858 + dw 6,2 + dd ucase_858 + dw 6,4 + dd ucase_858 + dw 6,5 + dd fchar + dw 6,6 + dd it_collate_858 + dw 6,7 + dd dbcs_empty + dw 6,23 + dd it_yn +_it_437 dw 7 + dw 6,1 + dd it_437 + dw 6,2 + dd ucase_437 + dw 6,4 + dd ucase_437 + dw 6,5 + dd fchar + dw 6,6 + dd it_collate_437 + dw 6,7 + dd dbcs_empty + dw 6,23 + dd it_yn +_ro_852 dw 7 + dw 6,1 + dd ro_852 + dw 6,2 + dd ucase_852 + dw 6,4 + dd ucase_852 + dw 6,5 + dd fchar + dw 6,6 + dd ro_collate_852 + dw 6,7 + dd dbcs_empty + dw 6,23 + dd ro_yn +_ro_850 dw 7 + dw 6,1 + dd ro_850 + dw 6,2 + dd ucase_850 + dw 6,4 + dd ucase_850 + dw 6,5 + dd fchar + dw 6,6 + dd ro_collate_850 + dw 6,7 + dd dbcs_empty + dw 6,23 + dd ro_yn +_ro_858 dw 7 + dw 6,1 + dd ro_858 + dw 6,2 + dd ucase_858 + dw 6,4 + dd ucase_858 + dw 6,5 + dd fchar + dw 6,6 + dd ro_collate_858 + dw 6,7 + dd dbcs_empty + dw 6,23 + dd ro_yn +_ch_850 dw 7 + dw 6,1 + dd ch_850 + dw 6,2 + dd ucase_850 + dw 6,4 + dd ucase_850 + dw 6,5 + dd fchar + dw 6,6 + dd ch_collate_850 + dw 6,7 + dd dbcs_empty + dw 6,23 + dd de_yn +_ch_858 dw 7 + dw 6,1 + dd ch_858 + dw 6,2 + dd ucase_858 + dw 6,4 + dd ucase_858 + dw 6,5 + dd fchar + dw 6,6 + dd ch_collate_858 + dw 6,7 + dd dbcs_empty + dw 6,23 + dd de_yn +_ch_437 dw 7 + dw 6,1 + dd ch_437 + dw 6,2 + dd ucase_437 + dw 6,4 + dd ucase_437 + dw 6,5 + dd fchar + dw 6,6 + dd ch_collate_437 + dw 6,7 + dd dbcs_empty + dw 6,23 + dd de_yn +_cz_852 dw 7 + dw 6,1 + dd cz_852 + dw 6,2 + dd ucase_852 + dw 6,4 + dd ucase_852 + dw 6,5 + dd fchar + dw 6,6 + dd cz_collate_852 + dw 6,7 + dd dbcs_empty + dw 6,23 + dd cz_yn +_cz_850 dw 7 + dw 6,1 + dd cz_850 + dw 6,2 + dd ucase_850 + dw 6,4 + dd ucase_850 + dw 6,5 + dd fchar + dw 6,6 + dd cz_collate_850 + dw 6,7 + dd dbcs_empty + dw 6,23 + dd cz_yn +_cz_858 dw 7 + dw 6,1 + dd cz_858 + dw 6,2 + dd ucase_858 + dw 6,4 + dd ucase_858 + dw 6,5 + dd fchar + dw 6,6 + dd cz_collate_858 + dw 6,7 + dd dbcs_empty + dw 6,23 + dd cz_yn +_at_850 dw 7 + dw 6,1 + dd at_850 + dw 6,2 + dd ucase_850 + dw 6,4 + dd ucase_850 + dw 6,5 + dd fchar + dw 6,6 + dd de_collate_850 + dw 6,7 + dd dbcs_empty + dw 6,23 + dd de_yn +_at_858 dw 7 + dw 6,1 + dd at_858 + dw 6,2 + dd ucase_858 + dw 6,4 + dd ucase_858 + dw 6,5 + dd fchar + dw 6,6 + dd de_collate_858 + dw 6,7 + dd dbcs_empty + dw 6,23 + dd de_yn +_at_437 dw 7 + dw 6,1 + dd at_437 + dw 6,2 + dd ucase_437 + dw 6,4 + dd ucase_437 + dw 6,5 + dd fchar + dw 6,6 + dd de_collate_437 + dw 6,7 + dd dbcs_empty + dw 6,23 + dd de_yn +_uk_850 dw 7 + dw 6,1 + dd uk_850 + dw 6,2 + dd ucase_850 + dw 6,4 + dd ucase_850 + dw 6,5 + dd fchar + dw 6,6 + dd en_collate_850 + dw 6,7 + dd dbcs_empty + dw 6,23 + dd en_yn +_uk_858 dw 7 + dw 6,1 + dd uk_858 + dw 6,2 + dd ucase_858 + dw 6,4 + dd ucase_858 + dw 6,5 + dd fchar + dw 6,6 + dd en_collate_858 + dw 6,7 + dd dbcs_empty + dw 6,23 + dd en_yn +_uk_437 dw 7 + dw 6,1 + dd uk_437 + dw 6,2 + dd ucase_437 + dw 6,4 + dd ucase_437 + dw 6,5 + dd fchar + dw 6,6 + dd en_collate_437 + dw 6,7 + dd dbcs_empty + dw 6,23 + dd en_yn +_dk_865 dw 7 + dw 6,1 + dd dk_865 + dw 6,2 + dd ucase_865 + dw 6,4 + dd ucase_865 + dw 6,5 + dd fchar + dw 6,6 + dd dk_collate_865 + dw 6,7 + dd dbcs_empty + dw 6,23 + dd dk_yn +_dk_850 dw 7 + dw 6,1 + dd dk_850 + dw 6,2 + dd ucase_850 + dw 6,4 + dd ucase_850 + dw 6,5 + dd fchar + dw 6,6 + dd dk_collate_850 + dw 6,7 + dd dbcs_empty + dw 6,23 + dd dk_yn +_dk_858 dw 7 + dw 6,1 + dd dk_858 + dw 6,2 + dd ucase_858 + dw 6,4 + dd ucase_858 + dw 6,5 + dd fchar + dw 6,6 + dd dk_collate_858 + dw 6,7 + dd dbcs_empty + dw 6,23 + dd dk_yn +_se_850 dw 7 + dw 6,1 + dd se_850 + dw 6,2 + dd ucase_850 + dw 6,4 + dd ucase_850 + dw 6,5 + dd fchar + dw 6,6 + dd se_collate_850 + dw 6,7 + dd dbcs_empty + dw 6,23 + dd se_yn +_se_858 dw 7 + dw 6,1 + dd se_858 + dw 6,2 + dd ucase_858 + dw 6,4 + dd ucase_858 + dw 6,5 + dd fchar + dw 6,6 + dd se_collate_858 + dw 6,7 + dd dbcs_empty + dw 6,23 + dd se_yn +_se_437 dw 7 + dw 6,1 + dd se_437 + dw 6,2 + dd ucase_437 + dw 6,4 + dd ucase_437 + dw 6,5 + dd fchar + dw 6,6 + dd se_collate_437 + dw 6,7 + dd dbcs_empty + dw 6,23 + dd se_yn +_no_865 dw 7 + dw 6,1 + dd no_865 + dw 6,2 + dd ucase_865 + dw 6,4 + dd ucase_865 + dw 6,5 + dd fchar + dw 6,6 + dd no_collate_865 + dw 6,7 + dd dbcs_empty + dw 6,23 + dd no_yn +_no_850 dw 7 + dw 6,1 + dd no_850 + dw 6,2 + dd ucase_850 + dw 6,4 + dd ucase_850 + dw 6,5 + dd fchar + dw 6,6 + dd no_collate_850 + dw 6,7 + dd dbcs_empty + dw 6,23 + dd no_yn +_no_858 dw 7 + dw 6,1 + dd no_858 + dw 6,2 + dd ucase_858 + dw 6,4 + dd ucase_858 + dw 6,5 + dd fchar + dw 6,6 + dd no_collate_858 + dw 6,7 + dd dbcs_empty + dw 6,23 + dd no_yn +_pl_852 dw 7 + dw 6,1 + dd pl_852 + dw 6,2 + dd ucase_852 + dw 6,4 + dd ucase_852 + dw 6,5 + dd fchar + dw 6,6 + dd pl_collate_852 + dw 6,7 + dd dbcs_empty + dw 6,23 + dd pl_yn +_pl_850 dw 7 + dw 6,1 + dd pl_850 + dw 6,2 + dd ucase_850 + dw 6,4 + dd ucase_850 + dw 6,5 + dd fchar + dw 6,6 + dd pl_collate_850 + dw 6,7 + dd dbcs_empty + dw 6,23 + dd pl_yn +_pl_858 dw 7 + dw 6,1 + dd pl_858 + dw 6,2 + dd ucase_858 + dw 6,4 + dd ucase_858 + dw 6,5 + dd fchar + dw 6,6 + dd pl_collate_858 + dw 6,7 + dd dbcs_empty + dw 6,23 + dd pl_yn +_de_850 dw 7 + dw 6,1 + dd de_850 + dw 6,2 + dd ucase_850 + dw 6,4 + dd ucase_850 + dw 6,5 + dd fchar + dw 6,6 + dd de_collate_850 + dw 6,7 + dd dbcs_empty + dw 6,23 + dd de_yn +_de_858 dw 7 + dw 6,1 + dd de_858 + dw 6,2 + dd ucase_858 + dw 6,4 + dd ucase_858 + dw 6,5 + dd fchar + dw 6,6 + dd de_collate_858 + dw 6,7 + dd dbcs_empty + dw 6,23 + dd de_yn +_de_437 dw 7 + dw 6,1 + dd de_437 + dw 6,2 + dd ucase_437 + dw 6,4 + dd ucase_437 + dw 6,5 + dd fchar + dw 6,6 + dd de_collate_437 + dw 6,7 + dd dbcs_empty + dw 6,23 + dd de_yn +_ar_437 dw 7 + dw 6,1 + dd ar_437 + dw 6,2 + dd ucase_437 + dw 6,4 + dd ucase_437 + dw 6,5 + dd fchar + dw 6,6 + dd es_collate_437 + dw 6,7 + dd dbcs_empty + dw 6,23 + dd es_yn +_ar_850 dw 7 + dw 6,1 + dd ar_850 + dw 6,2 + dd ucase_850 + dw 6,4 + dd ucase_850 + dw 6,5 + dd fchar + dw 6,6 + dd es_collate_850 + dw 6,7 + dd dbcs_empty + dw 6,23 + dd es_yn +_ar_858 dw 7 + dw 6,1 + dd ar_858 + dw 6,2 + dd ucase_858 + dw 6,4 + dd ucase_858 + dw 6,5 + dd fchar + dw 6,6 + dd es_collate_858 + dw 6,7 + dd dbcs_empty + dw 6,23 + dd es_yn +_br_850 dw 7 + dw 6,1 + dd br_850 + dw 6,2 + dd ucase_850 + dw 6,4 + dd ucase_850 + dw 6,5 + dd fchar + dw 6,6 + dd pt_collate_850 + dw 6,7 + dd dbcs_empty + dw 6,23 + dd pt_yn +_br_858 dw 7 + dw 6,1 + dd br_858 + dw 6,2 + dd ucase_858 + dw 6,4 + dd ucase_858 + dw 6,5 + dd fchar + dw 6,6 + dd pt_collate_858 + dw 6,7 + dd dbcs_empty + dw 6,23 + dd pt_yn +_br_437 dw 7 + dw 6,1 + dd br_437 + dw 6,2 + dd ucase_437 + dw 6,4 + dd ucase_437 + dw 6,5 + dd fchar + dw 6,6 + dd pt_collate_437 + dw 6,7 + dd dbcs_empty + dw 6,23 + dd pt_yn +_my_437 dw 7 + dw 6,1 + dd my_437 + dw 6,2 + dd ucase_437 + dw 6,4 + dd ucase_437 + dw 6,5 + dd fchar + dw 6,6 + dd en_collate_437 + dw 6,7 + dd dbcs_empty + dw 6,23 + dd en_yn +_au_437 dw 7 + dw 6,1 + dd au_437 + dw 6,2 + dd ucase_437 + dw 6,4 + dd ucase_437 + dw 6,5 + dd fchar + dw 6,6 + dd en_collate_437 + dw 6,7 + dd dbcs_empty + dw 6,23 + dd en_yn +_au_850 dw 7 + dw 6,1 + dd au_850 + dw 6,2 + dd ucase_850 + dw 6,4 + dd ucase_850 + dw 6,5 + dd fchar + dw 6,6 + dd en_collate_850 + dw 6,7 + dd dbcs_empty + dw 6,23 + dd en_yn +_au_858 dw 7 + dw 6,1 + dd au_858 + dw 6,2 + dd ucase_858 + dw 6,4 + dd ucase_858 + dw 6,5 + dd fchar + dw 6,6 + dd en_collate_858 + dw 6,7 + dd dbcs_empty + dw 6,23 + dd en_yn +_sg_437 dw 7 + dw 6,1 + dd sg_437 + dw 6,2 + dd ucase_437 + dw 6,4 + dd ucase_437 + dw 6,5 + dd fchar + dw 6,6 + dd en_collate_437 + dw 6,7 + dd dbcs_empty + dw 6,23 + dd en_yn +_jp_437 dw 7 + dw 6,1 + dd jp_437 + dw 6,2 + dd ucase_437 + dw 6,4 + dd ucase_437 + dw 6,5 + dd fchar + dw 6,6 + dd en_collate_437 + dw 6,7 + dd dbcs_empty + dw 6,23 + dd en_yn ; Japanese MS-DOS uses "Y" and "N" - Yuki +_jp_932 dw 7 + dw 6,1 + dd jp_932 + dw 6,2 + dd ucase_932 + dw 6,4 + dd ucase_932 + dw 6,5 + dd fchar + dw 6,6 + dd jp_collate_932 + dw 6,7 + dd jp_dbcs_932 + dw 6,23 + dd en_yn +_kr_437 dw 7 + dw 6,1 + dd kr_437 + dw 6,2 + dd ucase_437 + dw 6,4 + dd ucase_437 + dw 6,5 + dd fchar + dw 6,6 + dd en_collate_437 + dw 6,7 + dd dbcs_empty + dw 6,23 + dd kr_yn +_kr_934 dw 7 + dw 6,1 + dd kr_934 + dw 6,2 + dd ucase_934 + dw 6,4 + dd ucase_934 + dw 6,5 + dd fchar + dw 6,6 + dd kr_collate_934 + dw 6,7 + dd kr_dbcs_934 + dw 6,23 + dd kr_yn +_cn_437 dw 7 + dw 6,1 + dd cn_437 + dw 6,2 + dd ucase_437 + dw 6,4 + dd ucase_437 + dw 6,5 + dd fchar + dw 6,6 + dd en_collate_437 + dw 6,7 + dd dbcs_empty + dw 6,23 + dd cn_yn +_cn_936 dw 7 + dw 6,1 + dd cn_936 + dw 6,2 + dd ucase_936 + dw 6,4 + dd ucase_936 + dw 6,5 + dd fchar + dw 6,6 + dd cn_collate_936 + dw 6,7 + dd cn_dbcs_936 + dw 6,23 + dd cn_yn_936 +_tr_857 dw 7 + dw 6,1 + dd tr_857 + dw 6,2 + dd ucase_857 + dw 6,4 + dd ucase_857 + dw 6,5 + dd fchar + dw 6,6 + dd tr_collate_857 + dw 6,7 + dd dbcs_empty + dw 6,23 + dd tr_yn +_tr_850 dw 7 + dw 6,1 + dd tr_850 + dw 6,2 + dd ucase_850 + dw 6,4 + dd ucase_850 + dw 6,5 + dd fchar + dw 6,6 + dd tr_collate_850 + dw 6,7 + dd dbcs_empty + dw 6,23 + dd tr_yn +_in_437 dw 7 + dw 6,1 + dd in_437 + dw 6,2 + dd ucase_437 + dw 6,4 + dd ucase_437 + dw 6,5 + dd fchar + dw 6,6 + dd en_collate_437 + dw 6,7 + dd dbcs_empty + dw 6,23 + dd en_yn +_pt_860 dw 7 + dw 6,1 + dd pt_860 + dw 6,2 + dd ucase_860 + dw 6,4 + dd ucase_860 + dw 6,5 + dd fchar + dw 6,6 + dd pt_collate_860 + dw 6,7 + dd dbcs_empty + dw 6,23 + dd pt_yn +_pt_850 dw 7 + dw 6,1 + dd pt_850 + dw 6,2 + dd ucase_850 + dw 6,4 + dd ucase_850 + dw 6,5 + dd fchar + dw 6,6 + dd pt_collate_850 + dw 6,7 + dd dbcs_empty + dw 6,23 + dd pt_yn +_pt_858 dw 7 + dw 6,1 + dd pt_858 + dw 6,2 + dd ucase_858 + dw 6,4 + dd ucase_858 + dw 6,5 + dd fchar + dw 6,6 + dd pt_collate_858 + dw 6,7 + dd dbcs_empty + dw 6,23 + dd pt_yn +_fi_850 dw 7 + dw 6,1 + dd fi_850 + dw 6,2 + dd ucase_850 + dw 6,4 + dd ucase_850 + dw 6,5 + dd fchar + dw 6,6 + dd fi_collate_850 + dw 6,7 + dd dbcs_empty + dw 6,23 + dd fi_yn +_fi_858 dw 7 + dw 6,1 + dd fi_858 + dw 6,2 + dd ucase_858 + dw 6,4 + dd ucase_858 + dw 6,5 + dd fchar + dw 6,6 + dd fi_collate_858 + dw 6,7 + dd dbcs_empty + dw 6,23 + dd fi_yn +_fi_437 dw 7 + dw 6,1 + dd fi_437 + dw 6,2 + dd ucase_437 + dw 6,4 + dd ucase_437 + dw 6,5 + dd fchar + dw 6,6 + dd fi_collate_437 + dw 6,7 + dd dbcs_empty + dw 6,23 + dd fi_yn +_bg_855 dw 7 + dw 6,1 + dd bg_855 + dw 6,2 + dd ucase_855 + dw 6,4 + dd ucase_855 + dw 6,5 + dd fchar + dw 6,6 + dd bg_collate_855 + dw 6,7 + dd dbcs_empty + dw 6,23 + dd bg_yn_855 +_bg_872 dw 7 + dw 6,1 + dd bg_872 + dw 6,2 + dd ucase_872 + dw 6,4 + dd ucase_872 + dw 6,5 + dd fchar + dw 6,6 + dd bg_collate_872 + dw 6,7 + dd dbcs_empty + dw 6,23 + dd bg_yn_872 +_bg_850 dw 7 + dw 6,1 + dd bg_850 + dw 6,2 + dd ucase_850 + dw 6,4 + dd ucase_850 + dw 6,5 + dd fchar + dw 6,6 + dd bg_collate_850 + dw 6,7 + dd dbcs_empty + dw 6,23 + dd bg_yn +_bg_858 dw 7 + dw 6,1 + dd bg_858 + dw 6,2 + dd ucase_858 + dw 6,4 + dd ucase_858 + dw 6,5 + dd fchar + dw 6,6 + dd bg_collate_858 + dw 6,7 + dd dbcs_empty + dw 6,23 + dd bg_yn +_ua_848 dw 8 + dw 6,1 + dd ua_848 + dw 6,2 + dd ucase_848 + dw 6,3 + dd lcase_848 + dw 6,4 + dd ucase_848 + dw 6,5 + dd fchar + dw 6,6 + dd ua_collate_848 + dw 6,7 + dd dbcs_empty + dw 6,23 + dd ua_yn_848 +_ua_1125 dw 8 + dw 6,1 + dd ua_1125 + dw 6,2 + dd ucase_1125 + dw 6,3 + dd lcase_1125 + dw 6,4 + dd ucase_1125 + dw 6,5 + dd fchar + dw 6,6 + dd ua_collate_1125 + dw 6,7 + dd dbcs_empty + dw 6,23 + dd ua_yn_1125 +_sr_852 dw 7 + dw 6,1 + dd sr_852 + dw 6,2 + dd ucase_852 + dw 6,4 + dd ucase_852 + dw 6,5 + dd fchar + dw 6,6 + dd sh_collate_852 + dw 6,7 + dd dbcs_empty + dw 6,23 + dd sh_yn +_sr_855 dw 7 + dw 6,1 + dd sr_855 + dw 6,2 + dd ucase_855 + dw 6,4 + dd ucase_855 + dw 6,5 + dd fchar + dw 6,6 + dd sh_collate_855 + dw 6,7 + dd dbcs_empty + dw 6,23 + dd sh_yn_855 +_sr_872 dw 7 + dw 6,1 + dd sr_872 + dw 6,2 + dd ucase_872 + dw 6,4 + dd ucase_872 + dw 6,5 + dd fchar + dw 6,6 + dd sh_collate_872 + dw 6,7 + dd dbcs_empty + dw 6,23 + dd sh_yn_872 +_sr_850 dw 7 + dw 6,1 + dd sr_850 + dw 6,2 + dd ucase_850 + dw 6,4 + dd ucase_850 + dw 6,5 + dd fchar + dw 6,6 + dd sh_collate_850 + dw 6,7 + dd dbcs_empty + dw 6,23 + dd sh_yn +_sr_858 dw 7 + dw 6,1 + dd sr_858 + dw 6,2 + dd ucase_858 + dw 6,4 + dd ucase_858 + dw 6,5 + dd fchar + dw 6,6 + dd sh_collate_858 + dw 6,7 + dd dbcs_empty + dw 6,23 + dd sh_yn +_hr_852 dw 7 + dw 6,1 + dd hr_852 + dw 6,2 + dd ucase_852 + dw 6,4 + dd ucase_852 + dw 6,5 + dd fchar + dw 6,6 + dd hr_collate_852 + dw 6,7 + dd dbcs_empty + dw 6,23 + dd hr_yn +_hr_850 dw 7 + dw 6,1 + dd hr_850 + dw 6,2 + dd ucase_850 + dw 6,4 + dd ucase_850 + dw 6,5 + dd fchar + dw 6,6 + dd hr_collate_850 + dw 6,7 + dd dbcs_empty + dw 6,23 + dd hr_yn +_hr_858 dw 7 + dw 6,1 + dd hr_858 + dw 6,2 + dd ucase_858 + dw 6,4 + dd ucase_858 + dw 6,5 + dd fchar + dw 6,6 + dd hr_collate_858 + dw 6,7 + dd dbcs_empty + dw 6,23 + dd hr_yn +_si_852 dw 7 + dw 6,1 + dd si_852 + dw 6,2 + dd ucase_852 + dw 6,4 + dd ucase_852 + dw 6,5 + dd fchar + dw 6,6 + dd si_collate_852 + dw 6,7 + dd dbcs_empty + dw 6,23 + dd si_yn +_si_850 dw 7 + dw 6,1 + dd si_850 + dw 6,2 + dd ucase_850 + dw 6,4 + dd ucase_850 + dw 6,5 + dd fchar + dw 6,6 + dd si_collate_850 + dw 6,7 + dd dbcs_empty + dw 6,23 + dd si_yn +_si_858 dw 7 + dw 6,1 + dd si_858 + dw 6,2 + dd ucase_858 + dw 6,4 + dd ucase_858 + dw 6,5 + dd fchar + dw 6,6 + dd si_collate_858 + dw 6,7 + dd dbcs_empty + dw 6,23 + dd si_yn +_ba_852 dw 7 + dw 6,1 + dd ba_852 + dw 6,2 + dd ucase_852 + dw 6,4 + dd ucase_852 + dw 6,5 + dd fchar + dw 6,6 + dd sh_collate_852 + dw 6,7 + dd dbcs_empty + dw 6,23 + dd sh_yn +_ba_850 dw 7 + dw 6,1 + dd ba_850 + dw 6,2 + dd ucase_850 + dw 6,4 + dd ucase_850 + dw 6,5 + dd fchar + dw 6,6 + dd sh_collate_850 + dw 6,7 + dd dbcs_empty + dw 6,23 + dd sh_yn +_ba_858 dw 7 + dw 6,1 + dd ba_858 + dw 6,2 + dd ucase_858 + dw 6,4 + dd ucase_858 + dw 6,5 + dd fchar + dw 6,6 + dd sh_collate_858 + dw 6,7 + dd dbcs_empty + dw 6,23 + dd sh_yn +_ba_855 dw 7 + dw 6,1 + dd ba_855 + dw 6,2 + dd ucase_855 + dw 6,4 + dd ucase_855 + dw 6,5 + dd fchar + dw 6,6 + dd sh_collate_855 + dw 6,7 + dd dbcs_empty + dw 6,23 + dd sh_yn_855 +_ba_872 dw 7 + dw 6,1 + dd ba_872 + dw 6,2 + dd ucase_872 + dw 6,4 + dd ucase_872 + dw 6,5 + dd fchar + dw 6,6 + dd sh_collate_872 + dw 6,7 + dd dbcs_empty + dw 6,23 + dd sh_yn_872 +_mk_855 dw 7 + dw 6,1 + dd mk_855 + dw 6,2 + dd ucase_855 + dw 6,4 + dd ucase_855 + dw 6,5 + dd fchar + dw 6,6 + dd mk_collate_855 + dw 6,7 + dd dbcs_empty + dw 6,23 + dd mk_yn_855 +_mk_872 dw 7 + dw 6,1 + dd mk_872 + dw 6,2 + dd ucase_872 + dw 6,4 + dd ucase_872 + dw 6,5 + dd fchar + dw 6,6 + dd mk_collate_872 + dw 6,7 + dd dbcs_empty + dw 6,23 + dd mk_yn_872 +_mk_850 dw 7 + dw 6,1 + dd mk_850 + dw 6,2 + dd ucase_850 + dw 6,4 + dd ucase_850 + dw 6,5 + dd fchar + dw 6,6 + dd mk_collate_850 + dw 6,7 + dd dbcs_empty + dw 6,23 + dd mk_yn +_mk_858 dw 7 + dw 6,1 + dd mk_858 + dw 6,2 + dd ucase_858 + dw 6,4 + dd ucase_858 + dw 6,5 + dd fchar + dw 6,6 + dd mk_collate_858 + dw 6,7 + dd dbcs_empty + dw 6,23 + dd mk_yn +_me_850 dw 7 + dw 6,1 + dd me_850 + dw 6,2 + dd ucase_850 + dw 6,4 + dd ucase_850 + dw 6,5 + dd fchar + dw 6,6 + dd me_collate_850 + dw 6,7 + dd dbcs_empty + dw 6,23 + dd me_yn +_me_858 dw 7 + dw 6,1 + dd me_858 + dw 6,2 + dd ucase_858 + dw 6,4 + dd ucase_858 + dw 6,5 + dd fchar + dw 6,6 + dd me_collate_858 + dw 6,7 + dd dbcs_empty + dw 6,23 + dd me_yn +_me_864 dw 7 + dw 6,1 + dd me_864 + dw 6,2 + dd ucase_864 + dw 6,4 + dd ucase_864 + dw 6,5 + dd fchar + dw 6,6 + dd me_collate_864 + dw 6,7 + dd dbcs_empty + dw 6,23 + dd me_yn_864 +_il_850 dw 7 + dw 6,1 + dd il_850 + dw 6,2 + dd ucase_850 + dw 6,4 + dd ucase_850 + dw 6,5 + dd fchar + dw 6,6 + dd il_collate_850 + dw 6,7 + dd dbcs_empty + dw 6,23 + dd il_yn +_il_858 dw 7 + dw 6,1 + dd il_858 + dw 6,2 + dd ucase_858 + dw 6,4 + dd ucase_858 + dw 6,5 + dd fchar + dw 6,6 + dd il_collate_858 + dw 6,7 + dd dbcs_empty + dw 6,23 + dd il_yn +_il_862 dw 7 + dw 6,1 + dd il_862 + dw 6,2 + dd ucase_862 + dw 6,4 + dd ucase_862 + dw 6,5 + dd fchar + dw 6,6 + dd il_collate_862 + dw 6,7 + dd dbcs_empty + dw 6,23 + dd il_yn_862 +_nl_BE_850 dw 7 + dw 6,1 + dd nl_BE_850 + dw 6,2 + dd ucase_850 + dw 6,4 + dd ucase_850 + dw 6,5 + dd fchar + dw 6,6 + dd nl_collate_850 + dw 6,7 + dd dbcs_empty + dw 6,23 + dd nl_yn +_nl_BE_858 dw 7 + dw 6,1 + dd nl_BE_858 + dw 6,2 + dd ucase_858 + dw 6,4 + dd ucase_858 + dw 6,5 + dd fchar + dw 6,6 + dd nl_collate_858 + dw 6,7 + dd dbcs_empty + dw 6,23 + dd nl_yn +_nl_BE_437 dw 7 + dw 6,1 + dd nl_BE_437 + dw 6,2 + dd ucase_437 + dw 6,4 + dd ucase_437 + dw 6,5 + dd fchar + dw 6,6 + dd nl_collate_437 + dw 6,7 + dd dbcs_empty + dw 6,23 + dd nl_yn +_fr_BE_850 dw 7 + dw 6,1 + dd fr_BE_850 + dw 6,2 + dd ucase_850 + dw 6,4 + dd ucase_850 + dw 6,5 + dd fchar + dw 6,6 + dd fr_collate_850 + dw 6,7 + dd dbcs_empty + dw 6,23 + dd fr_yn +_fr_BE_858 dw 7 + dw 6,1 + dd fr_BE_858 + dw 6,2 + dd ucase_858 + dw 6,4 + dd ucase_858 + dw 6,5 + dd fchar + dw 6,6 + dd fr_collate_858 + dw 6,7 + dd dbcs_empty + dw 6,23 + dd fr_yn +_fr_BE_437 dw 7 + dw 6,1 + dd fr_BE_437 + dw 6,2 + dd ucase_437 + dw 6,4 + dd ucase_437 + dw 6,5 + dd fchar + dw 6,6 + dd fr_collate_437 + dw 6,7 + dd dbcs_empty + dw 6,23 + dd fr_yn +_de_BE_850 dw 7 + dw 6,1 + dd de_BE_850 + dw 6,2 + dd ucase_850 + dw 6,4 + dd ucase_850 + dw 6,5 + dd fchar + dw 6,6 + dd de_collate_850 + dw 6,7 + dd dbcs_empty + dw 6,23 + dd de_yn +_de_BE_858 dw 7 + dw 6,1 + dd de_BE_858 + dw 6,2 + dd ucase_858 + dw 6,4 + dd ucase_858 + dw 6,5 + dd fchar + dw 6,6 + dd de_collate_858 + dw 6,7 + dd dbcs_empty + dw 6,23 + dd de_yn +_de_BE_437 dw 7 + dw 6,1 + dd de_BE_437 + dw 6,2 + dd ucase_437 + dw 6,4 + dd ucase_437 + dw 6,5 + dd fchar + dw 6,6 + dd de_collate_437 + dw 6,7 + dd dbcs_empty + dw 6,23 + dd de_yn +_es_ES_850 dw 7 + dw 6,1 + dd es_ES_850 + dw 6,2 + dd ucase_850 + dw 6,4 + dd ucase_850 + dw 6,5 + dd fchar + dw 6,6 + dd es_collate_850 + dw 6,7 + dd dbcs_empty + dw 6,23 + dd es_yn +_es_ES_858 dw 7 + dw 6,1 + dd es_ES_858 + dw 6,2 + dd ucase_858 + dw 6,4 + dd ucase_858 + dw 6,5 + dd fchar + dw 6,6 + dd es_collate_858 + dw 6,7 + dd dbcs_empty + dw 6,23 + dd es_yn +_es_ES_437 dw 7 + dw 6,1 + dd es_ES_437 + dw 6,2 + dd ucase_437 + dw 6,4 + dd ucase_437 + dw 6,5 + dd fchar + dw 6,6 + dd es_collate_437 + dw 6,7 + dd dbcs_empty + dw 6,23 + dd es_yn +_ca_ES_850 dw 7 + dw 6,1 + dd ca_ES_850 + dw 6,2 + dd ucase_850 + dw 6,4 + dd ucase_850 + dw 6,5 + dd fchar + dw 6,6 + dd ca_collate_850 + dw 6,7 + dd dbcs_empty + dw 6,23 + dd ca_yn +_ca_ES_858 dw 7 + dw 6,1 + dd ca_ES_858 + dw 6,2 + dd ucase_858 + dw 6,4 + dd ucase_858 + dw 6,5 + dd fchar + dw 6,6 + dd ca_collate_858 + dw 6,7 + dd dbcs_empty + dw 6,23 + dd ca_yn +_ca_ES_437 dw 7 + dw 6,1 + dd ca_ES_437 + dw 6,2 + dd ucase_437 + dw 6,4 + dd ucase_437 + dw 6,5 + dd fchar + dw 6,6 + dd ca_collate_437 + dw 6,7 + dd dbcs_empty + dw 6,23 + dd ca_yn +_gl_ES_850 dw 7 + dw 6,1 + dd gl_ES_850 + dw 6,2 + dd ucase_850 + dw 6,4 + dd ucase_850 + dw 6,5 + dd fchar + dw 6,6 + dd gl_collate_850 + dw 6,7 + dd dbcs_empty + dw 6,23 + dd gl_yn +_gl_ES_858 dw 7 + dw 6,1 + dd gl_ES_858 + dw 6,2 + dd ucase_858 + dw 6,4 + dd ucase_858 + dw 6,5 + dd fchar + dw 6,6 + dd gl_collate_858 + dw 6,7 + dd dbcs_empty + dw 6,23 + dd gl_yn +_gl_ES_437 dw 7 + dw 6,1 + dd gl_ES_437 + dw 6,2 + dd ucase_437 + dw 6,4 + dd ucase_437 + dw 6,5 + dd fchar + dw 6,6 + dd gl_collate_437 + dw 6,7 + dd dbcs_empty + dw 6,23 + dd gl_yn +_eu_ES_850 dw 7 dw 6,1 - dd cn -_tr_857 dw 1 + dd eu_ES_850 + dw 6,2 + dd ucase_850 + dw 6,4 + dd ucase_850 + dw 6,5 + dd fchar + dw 6,6 + dd eu_collate_850 + dw 6,7 + dd dbcs_empty + dw 6,23 + dd eu_yn +_eu_ES_858 dw 7 dw 6,1 - dd tr_857 -_tr_850 dw 1 + dd eu_ES_858 + dw 6,2 + dd ucase_858 + dw 6,4 + dd ucase_858 + dw 6,5 + dd fchar + dw 6,6 + dd eu_collate_858 + dw 6,7 + dd dbcs_empty + dw 6,23 + dd eu_yn +_eu_ES_437 dw 7 dw 6,1 - dd tr_850 -_in dw 1 + dd eu_ES_437 + dw 6,2 + dd ucase_437 + dw 6,4 + dd ucase_437 + dw 6,5 + dd fchar + dw 6,6 + dd eu_collate_437 + dw 6,7 + dd dbcs_empty + dw 6,23 + dd eu_yn +_de_CH_850 dw 7 dw 6,1 - dd ia -_pt dw 1 + dd de_CH_850 + dw 6,2 + dd ucase_850 + dw 6,4 + dd ucase_850 + dw 6,5 + dd fchar + dw 6,6 + dd de_collate_850 + dw 6,7 + dd dbcs_empty + dw 6,23 + dd de_yn +_de_CH_858 dw 7 dw 6,1 - dd pt -_fi_850 dw 1 + dd de_CH_858 + dw 6,2 + dd ucase_858 + dw 6,4 + dd ucase_858 + dw 6,5 + dd fchar + dw 6,6 + dd de_collate_858 + dw 6,7 + dd dbcs_empty + dw 6,23 + dd de_yn +_de_CH_437 dw 7 dw 6,1 - dd fi_850 -_fi_858 dw 1 + dd de_CH_437 + dw 6,2 + dd ucase_437 + dw 6,4 + dd ucase_437 + dw 6,5 + dd fchar + dw 6,6 + dd de_collate_437 + dw 6,7 + dd dbcs_empty + dw 6,23 + dd de_yn +_fr_CH_850 dw 7 dw 6,1 - dd fi_858 -_bg dw 1 + dd fr_CH_850 + dw 6,2 + dd ucase_850 + dw 6,4 + dd ucase_850 + dw 6,5 + dd fchar + dw 6,6 + dd fr_collate_850 + dw 6,7 + dd dbcs_empty + dw 6,23 + dd fr_yn +_fr_CH_858 dw 7 + dw 6,1 + dd fr_CH_858 + dw 6,2 + dd ucase_858 + dw 6,4 + dd ucase_858 + dw 6,5 + dd fchar + dw 6,6 + dd fr_collate_858 + dw 6,7 + dd dbcs_empty + dw 6,23 + dd fr_yn +_fr_CH_437 dw 7 dw 6,1 - dd bg -_ua dw 1 + dd fr_CH_437 + dw 6,2 + dd ucase_437 + dw 6,4 + dd ucase_437 + dw 6,5 + dd fchar + dw 6,6 + dd fr_collate_437 + dw 6,7 + dd dbcs_empty + dw 6,23 + dd fr_yn +_it_CH_850 dw 7 dw 6,1 - dd ua -_me dw 1 + dd it_CH_850 + dw 6,2 + dd ucase_850 + dw 6,4 + dd ucase_850 + dw 6,5 + dd fchar + dw 6,6 + dd it_collate_850 + dw 6,7 + dd dbcs_empty + dw 6,23 + dd it_yn +_it_CH_858 dw 7 dw 6,1 - dd me -_il dw 1 + dd it_CH_858 + dw 6,2 + dd ucase_858 + dw 6,4 + dd ucase_858 + dw 6,5 + dd fchar + dw 6,6 + dd it_collate_858 + dw 6,7 + dd dbcs_empty + dw 6,23 + dd it_yn +_it_CH_437 dw 7 dw 6,1 - dd il + dd it_CH_437 + dw 6,2 + dd ucase_437 + dw 6,4 + dd ucase_437 + dw 6,5 + dd fchar + dw 6,6 + dd it_collate_437 + dw 6,7 + dd dbcs_empty + dw 6,23 + dd it_yn %define MDY 0 ; month/day/year %define DMY 1 ; day/month/year @@ -691,40 +2855,74 @@ dw %1,%2,%3 ; ID,CP,DF us_437 cnf 1,437,MDY,"$", 0,0,0,0,",",".","-",":",0,2,_12; United States us_850 cnf 1,850,MDY,"$", 0,0,0,0,",",".","-",":",0,2,_12; United States us_858 cnf 1,858,MDY,"$", 0,0,0,0,",",".","-",":",0,2,_12; United States -ca cnf 2,863,YMD,"$", 0,0,0,0," ",",","-",":",3,2,_24; French Canada +ca_863 cnf 2,863,YMD,"$", 0,0,0,0," ",",","-",":",3,2,_24; Canada-French +ca_850 cnf 2,850,YMD,"$", 0,0,0,0," ",",","-",":",3,2,_24; Canada-French +ca_858 cnf 2,858,YMD,"$", 0,0,0,0," ",",","-",":",3,2,_24; Canada-French la_850 cnf 3,850,DMY,"$", 0,0,0,0,",",".","/",":",0,2,_12; Latin America la_858 cnf 3,858,DMY,"$", 0,0,0,0,",",".","/",":",0,2,_12; Latin America la_437 cnf 3,437,DMY,"$", 0,0,0,0,",",".","/",":",0,2,_12; Latin America -ru cnf 7,866,DMY,"R","U","B",0,0," ",",",".",":",3,2,_24; Russia Arkady -gr cnf 30,869,DMY,"E","Y","P",0,0,".",",","/",":",1,2,_12; Greece +ru_866 cnf 7,866,DMY,0E0h,".", 0,0,0," ",",",".",":",3,2,_24; Russia Arkady +ru_808 cnf 7,808,DMY,0E0h,".", 0,0,0," ",",",".",":",3,2,_24; Russia +ru_855 cnf 7,855,DMY,0E1h,".", 0,0,0," ",",",".",":",3,2,_24; Russia +ru_872 cnf 7,872,DMY,0E1h,".", 0,0,0," ",",",".",":",3,2,_24; Russia +ru_852 cnf 7,852,DMY,"R","U","B",0,0," ",",",".",":",3,2,_24; Russia +ru_850 cnf 7,850,DMY,"R","U","B",0,0," ",",",".",":",3,2,_24; Russia +ru_858 cnf 7,858,DMY,"R","U","B",0,0," ",",",".",":",3,2,_24; Russia +ru_437 cnf 7,437,DMY,"R","U","B",0,0," ",",",".",":",3,2,_24; Russia +gr_869 cnf 30,869,DMY,0A8h,0D1h,0C7h,0,0,".",",","/",":",1,2,_12; Greece +gr_737 cnf 30,737,DMY,84h,93h,90h,0,0,".",",","/",":",1,2,_12; Greece +gr_850 cnf 30,850,DMY,"E","Y","P",0,0,".",",","/",":",1,2,_12; Greece +gr_858 cnf 30,858,DMY,0D5h, 0,0,0,0,".",",","/",":",1,2,_12; Greece nl_850 cnf 31,850,DMY,"E","U","R",0,0,".",",","-",":",0,2,_24; Netherlands Bart nl_858 cnf 31,858,DMY,0D5h, 0,0,0,0,".",",","-",":",0,2,_24; Netherlands +nl_437 cnf 31,437,DMY,"E","U","R",0,0,".",",","-",":",0,2,_24; Netherlands be_850 cnf 32,850,DMY,"E","U","R",0,0,".",",","/",":",0,2,_24; Belgium be_858 cnf 32,858,DMY,0D5h, 0,0,0,0,".",",","/",":",0,2,_24; Belgium +be_437 cnf 32,437,DMY,"E","U","R",0,0,".",",","/",":",0,2,_24; Belgium fr_850 cnf 33,850,DMY,"E","U","R",0,0," ",",",".",":",0,2,_24; France fr_858 cnf 33,858,DMY,0D5h, 0,0,0,0," ",",",".",":",0,2,_24; France +fr_437 cnf 33,437,DMY,"E","U","R",0,0," ",",",".",":",0,2,_24; France es_850 cnf 34,850,DMY,"E","U","R",0,0,".",",","/",":",0,2,_24; Spain Aitor es_858 cnf 34,858,DMY,0D5h, 0,0,0,0,".",",","/",":",0,2,_24; Spain es_437 cnf 34,437,DMY,"E","U","R",0,0,".",",","/",":",0,2,_24; Spain -hu cnf 36,852,YMD,"F","t", 0,0,0," ",",",".",":",3,2,_24; Hungary -yu cnf 38,852,YMD,"D","i","n",0,0,".",",","-",":",2,2,_24; Yugoslavia +hu_852 cnf 36,852,YMD,"F","t", 0,0,0," ",",",".",":",3,2,_24; Hungary +hu_850 cnf 36,850,YMD,"F","t", 0,0,0," ",",",".",":",3,2,_24; Hungary +hu_858 cnf 36,858,YMD,"F","t", 0,0,0," ",",",".",":",3,2,_24; Hungary +yu_852 cnf 38,852,YMD,"D","i","n",0,0,".",",","-",":",2,2,_24; Yugoslavia +yu_855 cnf 38,855,YMD,0A7h,0B7h,0D4h,0,0,".",",","-",":",2,2,_24; Yugoslavia +yu_872 cnf 38,872,YMD,0A7h,0B7h,0D4h,0,0,".",",","-",":",2,2,_24; Yugoslavia +yu_850 cnf 38,850,YMD,"D","i","n",0,0,".",",","-",":",2,2,_24; Yugoslavia +yu_858 cnf 38,858,YMD,"D","i","n",0,0,".",",","-",":",2,2,_24; Yugoslavia it_850 cnf 39,850,DMY,"E","U","R",0,0,".",",","/",".",0,2,_24; Italy it_858 cnf 39,858,DMY,0D5h, 0,0,0,0,".",",","/",".",0,2,_24; Italy -ro cnf 40,852,YMD,"L","e","i",0,0,".",",","-",":",0,2,_24; Romania +it_437 cnf 39,437,DMY,"E","U","R",0,0,".",",","/",".",0,2,_24; Italy +ro_852 cnf 40,852,YMD,"L","e","i",0,0,".",",","-",":",0,2,_24; Romania +ro_850 cnf 40,850,YMD,"L","e","i",0,0,".",",","-",":",0,2,_24; Romania +ro_858 cnf 40,858,YMD,"L","e","i",0,0,".",",","-",":",0,2,_24; Romania ch_850 cnf 41,850,DMY,"F","r",".",0,0,"'",".",".",",",2,2,_24; Switzerland ch_858 cnf 41,858,DMY,"F","r",".",0,0,"'",".",".",",",2,2,_24; Switzerland -cz cnf 42,852,YMD,"K","C","s",0,0,".",",","-",":",2,2,_24; Czechoslovakia +ch_437 cnf 41,437,DMY,"F","r",".",0,0,"'",".",".",",",2,2,_24; Switzerland +cz_852 cnf 42,852,YMD,"K","C","s",0,0,".",",","-",":",2,2,_24; Czechoslovakia +cz_850 cnf 42,850,YMD,"K","C","s",0,0,".",",","-",":",2,2,_24; Czechoslovakia +cz_858 cnf 42,858,YMD,"K","C","s",0,0,".",",","-",":",2,2,_24; Czechoslovakia at_850 cnf 43,850,DMY,"E","U","R",0,0,".",",",".",".",0,2,_24; Austria at_858 cnf 43,858,DMY,0D5h, 0,0,0,0,".",",",".",".",0,2,_24; Austria at_437 cnf 43,437,DMY,"E","U","R",0,0,".",",",".",".",0,2,_24; Austria uk_850 cnf 44,850,DMY,9Ch, 0,0,0,0,",",".","/",":",0,2,_24; United Kingdom uk_858 cnf 44,858,DMY,9Ch, 0,0,0,0,",",".","/",":",0,2,_24; United Kingdom uk_437 cnf 44,437,DMY,9Ch, 0,0,0,0,",",".","/",":",0,2,_24; United Kingdom -dk cnf 45,865,DMY,"k","r", 0,0,0,".",",","-",".",2,2,_24; Denmark +dk_865 cnf 45,865,DMY,"k","r", 0,0,0,".",",","-",".",2,2,_24; Denmark +dk_850 cnf 45,850,DMY,"k","r", 0,0,0,".",",","-",".",2,2,_24; Denmark +dk_858 cnf 45,858,DMY,"k","r", 0,0,0,".",",","-",".",2,2,_24; Denmark se_850 cnf 46,850,YMD,"K","r", 0,0,0," ",",","-",".",3,2,_24; Sweden se_858 cnf 46,858,YMD,"K","r", 0,0,0," ",",","-",".",3,2,_24; Sweden -no cnf 47,865,DMY,"K","r", 0,0,0,".",",",".",":",2,2,_24; Norway -pl cnf 48,852,YMD,"Z",88h, 0,0,0,".",",","-",":",0,2,_24; Poland Michal +se_437 cnf 46,437,YMD,"K","r", 0,0,0," ",",","-",".",3,2,_24; Sweden +no_865 cnf 47,865,DMY,"K","r", 0,0,0,".",",",".",":",2,2,_24; Norway +no_850 cnf 47,850,DMY,"K","r", 0,0,0,".",",",".",":",2,2,_24; Norway +no_858 cnf 47,858,DMY,"K","r", 0,0,0,".",",",".",":",2,2,_24; Norway +pl_852 cnf 48,852,YMD,"Z",88h, 0,0,0,".",",","-",":",0,2,_24; Poland Michal +pl_850 cnf 48,850,YMD,"P","L","N",0,0,".",",","-",":",0,2,_24; Poland +pl_858 cnf 48,858,YMD,"P","L","N",0,0,".",",","-",":",0,2,_24; Poland de_850 cnf 49,850,DMY,"E","U","R",0,0,".",",",".",".",1,2,_24; Germany Tom de_858 cnf 49,850,DMY,0D5h, 0,0,0,0,".",",",".",".",1,2,_24; Germany de_437 cnf 49,437,DMY,"E","U","R",0,0,".",",",".",".",1,2,_24; Germany @@ -733,33 +2931,357 @@ ar_858 cnf 54,858,DMY,"$", 0,0,0,0,".",",","/",".",0,2,_24; Argentina ar_437 cnf 54,437,DMY,"$", 0,0,0,0,".",",","/",".",0,2,_24; Argentina br_850 cnf 55,850,DMY,"C","r","$",0,0,".",",","/",":",2,2,_24; Brazil br_858 cnf 55,858,DMY,"C","r","$",0,0,".",",","/",":",2,2,_24; Brazil -my cnf 60,437,DMY,"$", 0,0,0,0,",",".","/",":",0,2,_12; Malaysia +br_437 cnf 55,437,DMY,"C","r","$",0,0,".",",","/",":",2,2,_24; Brazil +my_437 cnf 60,437,DMY,"$", 0,0,0,0,",",".","/",":",0,2,_12; Malaysia au_437 cnf 61,437,DMY,"$", 0,0,0,0,",",".","-",":",0,2,_12; Australia au_850 cnf 61,850,DMY,"$", 0,0,0,0,",",".","-",":",0,2,_12; Australia au_858 cnf 61,858,DMY,"$", 0,0,0,0,",",".","-",":",0,2,_12; Australia -sg cnf 65,437,DMY,"$", 0,0,0,0,",",".","/",":",0,2,_12; Singapore -np cnf 81,932,YMD,81h,8fh, 0,0,0,",",".","-",":",0,0,_24; Japan Yuki -kr cnf 82,934,YMD,5Ch, 0,0,0,0,",",".",".",":",0,0,_24; Korea -cn cnf 86,936,YMD,0A3h,0A4h,0,0,0,",",".",".",":",0,2,_12; China +sg_437 cnf 65,437,DMY,"$", 0,0,0,0,",",".","/",":",0,2,_12; Singapore +jp_932 cnf 81,932,YMD,5Ch, 0,0,0,0,",",".","-",":",0,0,_24; Japan Yuki +jp_437 cnf 81,437,YMD,9Dh, 0,0,0,0,",",".","-",":",0,0,_24; Japan +kr_934 cnf 82,934,YMD,5Ch, 0,0,0,0,",",".",".",":",0,0,_24; Korea +kr_437 cnf 82,437,YMD,"K","R","W",0,0,",",".",".",":",0,0,_24; Korea +cn_936 cnf 86,936,YMD,5Ch, 0,0,0,0,",",".",".",":",0,2,_12; China +cn_437 cnf 86,437,YMD,9Dh, 0,0,0,0,",",".",".",":",0,2,_12; China tr_857 cnf 90,857,DMY,"T","L", 0,0,0,".",",","/",":",4,2,_24; Turkey tr_850 cnf 90,850,DMY,"T","L", 0,0,0,".",",","/",":",4,2,_24; Turkey -ia cnf 91,437,DMY,"R","s", 0,0,0,".",",","/",":",0,2,_24; India -pt cnf 351,860,DMY,"E","U","R",0,0,".",",","-",":",0,2,_24; Portugal +in_437 cnf 91,437,DMY,"R","s", 0,0,0,".",",","/",":",0,2,_24; India +pt_860 cnf 351,860,DMY,"E","U","R",0,0,".",",","-",":",0,2,_24; Portugal +pt_850 cnf 351,850,DMY,"E","U","R",0,0,".",",","-",":",0,2,_24; Portugal +pt_858 cnf 351,858,DMY,0D5h, 0,0,0,0,".",",","-",":",0,2,_24; Portugal fi_850 cnf 358,850,DMY,"E","U","R",0,0," ",",",".",".",3,2,_24; Finland Wolf fi_858 cnf 358,858,DMY,0D5h, 0,0,0,0," ",",",".",".",3,2,_24; Finland -bg cnf 359,855,DMY,"B","G","L",0,0," ",",",".",",",3,2,_24; Bulgaria Lucho -ua cnf 380,848,DMY,"U","A","H",0,0," ",",",".",":",3,2,_24; Ukraine Oleg -me cnf 785,864,DMY,0A4h, 0,0,0,0,".",",","/",":",3,3,_12; Middle East -il cnf 972,862,DMY,99h, 0,0,0,0,",","."," ",":",2,2,_24; Israel +fi_437 cnf 358,437,DMY,"E","U","R",0,0," ",",",".",".",3,2,_24; +bg_855 cnf 359,855,DMY,0D0h,0EBh,0,0,0," ",",",".",",",3,2,_24; Bulgaria Lucho +bg_872 cnf 359,872,DMY,0D0h,0EBh,0,0,0," ",",",".",",",3,2,_24; Bulgaria Lucho +bg_850 cnf 359,850,DMY,"B","G","L",0,0," ",",",".",",",3,2,_24; Bulgaria +bg_858 cnf 359,858,DMY,"B","G","L",0,0," ",",",".",",",3,2,_24; Bulgaria +ua_848 cnf 380,848,DMY,0A3h,0E0h,0ADh,".",0," ",",",".",":",3,2,_24;Ukraine Oleg +ua_1125 cnf 380,1125,DMY,0A3h,0E0h,0ADh,".",0," ",",",".",":",3,2,_24; Ukraine +sr_855 cnf 381,855,DMY,0A7h,0B7h,0D4h,0,0,".",",",".",":",3,2,_24; Serbia +sr_872 cnf 381,872,DMY,0A7h,0B7h,0D4h,0,0,".",",",".",":",3,2,_24; Serbia +sr_852 cnf 381,852,DMY,"D","i","n",0,0,".",",",".",":",3,2,_24; Serbia +sr_850 cnf 381,850,DMY,"D","i","n",0,0,".",",",".",":",3,2,_24; Serbia +sr_858 cnf 381,858,DMY,"D","i","n",0,0,".",",",".",":",3,2,_24; Serbia +hr_852 cnf 384,852,DMY,"k","n", 0,0,0,".",",",".",".",3,2,_24; Croatia +hr_850 cnf 384,850,DMY,"k","n", 0,0,0,".",",",".",".",3,2,_24; Croatia +hr_858 cnf 384,858,DMY,"k","n", 0,0,0,".",",",".",".",3,2,_24; Croatia +si_852 cnf 386,852,DMY,"S","I","T",0,0,".",",",".",":",3,2,_24; Slovenia +si_850 cnf 386,850,DMY,"S","I","T",0,0,".",",",".",":",3,2,_24; Slovenia +si_858 cnf 386,858,DMY,"S","I","T",0,0,".",",",".",":",3,2,_24; Slovenia +ba_852 cnf 387,852,DMY,"K","M", 0,0,0,".",",",".",".",1,2,_24; Bosnia +ba_850 cnf 387,850,DMY,"K","M", 0,0,0,".",",",".",".",1,2,_24; Bosnia +ba_858 cnf 387,858,DMY,"K","M", 0,0,0,".",",",".",".",1,2,_24; Bosnia +ba_855 cnf 387,855,DMY,"K","M", 0,0,0,".",",",".",":",1,2,_24; Bosnia +ba_872 cnf 387,872,DMY,"K","M", 0,0,0,".",",",".",":",1,2,_24; Bosnia +mk_855 cnf 389,855,DMY,0A7h,0A8h,0D4h,0,0,".",",",".",":",3,2,_24; Macedonia +mk_872 cnf 389,872,DMY,0A7h,0A8h,0D4h,0,0,".",",",".",":",3,2,_24; Macedonia +mk_850 cnf 389,850,DMY,"D","e","n",0,0,".",",",".",":",3,2,_24; Macedonia +mk_858 cnf 389,858,DMY,"D","e","n",0,0,".",",",".",":",3,2,_24; Macedonia +me_864 cnf 785,864,DMY,0A4h, 0,0,0,0,".",",","/",":",1,3,_12; Middle East +me_850 cnf 785,850,DMY,0CFh, 0,0,0,0,".",",","/",":",3,3,_12; Middle East +me_858 cnf 785,858,DMY,0CFh, 0,0,0,0,".",",","/",":",3,3,_12; Middle East +il_862 cnf 972,862,DMY,99h, 0,0,0,0,",","."," ",":",2,2,_24; Israel +il_850 cnf 972,850,DMY,"N","I","S",0,0,",","."," ",":",2,2,_24; Israel +il_858 cnf 972,858,DMY,"N","I","S",0,0,",","."," ",":",2,2,_24; Israel + +es_ES_850 cnf 40034,850,DMY,"E","U","R",0,0,".",",","/",":",0,2,_24; Spain: +es_ES_858 cnf 40034,858,DMY,0D5h, 0,0,0,0,".",",","/",":",0,2,_24; Spanish +es_ES_437 cnf 40034,437,DMY,"E","U","R",0,0,".",",","/",":",0,2,_24 +ca_ES_850 cnf 41034,850,DMY,"E","U","R",0,0,".",",","/",":",0,2,_24; Catalan +ca_ES_858 cnf 41034,858,DMY,0D5h, 0,0,0,0,".",",","/",":",0,2,_24 +ca_ES_437 cnf 41034,437,DMY,"E","U","R",0,0,".",",","/",":",0,2,_24 +gl_ES_850 cnf 42034,850,DMY,"E","U","R",0,0,".",",","/",":",0,2,_24; Gallegan +gl_ES_858 cnf 42034,858,DMY,0D5h, 0,0,0,0,".",",","/",":",0,2,_24 +gl_ES_437 cnf 42034,437,DMY,"E","U","R",0,0,".",",","/",":",0,2,_24 +eu_ES_850 cnf 43034,850,DMY,"E","U","R",0,0,".",",","/",":",0,2,_24; Basque +eu_ES_858 cnf 43034,858,DMY,0D5h, 0,0,0,0,".",",","/",":",0,2,_24 +eu_ES_437 cnf 43034,437,DMY,"E","U","R",0,0,".",",","/",":",0,2,_24 +nl_BE_850 cnf 40032,850,DMY,"E","U","R",0,0,".",",","/",":",0,2,_24; Belgium: +nl_BE_858 cnf 40032,858,DMY,0D5h, 0,0,0,0,".",",","/",":",0,2,_24; Dutch +nl_BE_437 cnf 40032,437,DMY,"E","U","R",0,0,".",",","/",":",0,2,_24 +fr_BE_850 cnf 41032,850,DMY,"E","U","R",0,0,".",",","/",":",0,2,_24; French +fr_BE_858 cnf 41032,858,DMY,0D5h, 0,0,0,0,".",",","/",":",0,2,_24 +fr_BE_437 cnf 41032,437,DMY,"E","U","R",0,0,".",",","/",":",0,2,_24 +de_BE_850 cnf 42032,850,DMY,"E","U","R",0,0,".",",","/",":",0,2,_24; German +de_BE_858 cnf 42032,858,DMY,0D5h, 0,0,0,0,".",",","/",":",0,2,_24 +de_BE_437 cnf 42032,437,DMY,"E","U","R",0,0,".",",","/",":",0,2,_24 +de_CH_850 cnf 40041,850,DMY,"F","r",".",0,0,"'",".",".",",",2,2,_24; Switzerland +de_CH_858 cnf 40041,858,DMY,"F","r",".",0,0,"'",".",".",",",2,2,_24; German +de_CH_437 cnf 40041,437,DMY,"F","r",".",0,0,"'",".",".",",",2,2,_24 +fr_CH_850 cnf 41041,850,DMY,"F","r",".",0,0,"'",".",".",",",2,2,_24; French +fr_CH_858 cnf 41041,858,DMY,"F","r",".",0,0,"'",".",".",",",2,2,_24 +fr_CH_437 cnf 41041,437,DMY,"F","r",".",0,0,"'",".",".",",",2,2,_24 +it_CH_850 cnf 42041,850,DMY,"F","r",".",0,0,"'",".",".",",",2,2,_24; Italian +it_CH_858 cnf 42041,858,DMY,"F","r",".",0,0,"'",".",".",",",2,2,_24 +it_CH_437 cnf 42041,437,DMY,"F","r",".",0,0,"'",".",".",",",2,2,_24 + +; Uppercase equivalents of chars 80h to FFh +;------------------------------------------------------------------------------ +ucase_437 db 0FFh,"UCASE " ; Same as kernel's harcoded + dw 128 +db 128, 154, 69, 65, 142, 65, 143, 128 +db 69, 69, 69, 73, 73, 73, 142, 143 +db 144, 146, 146, 79, 153, 79, 85, 85 +db 89, 153, 154, 155, 156, 157, 158, 159 +db 65, 73, 79, 85, 165, 165, 166, 167 +db 168, 169, 170, 171, 172, 173, 174, 175 +db 176, 177, 178, 179, 180, 181, 182, 183 +db 184, 185, 186, 187, 188, 189, 190, 191 +db 192, 193, 194, 195, 196, 197, 198, 199 +db 200, 201, 202, 203, 204, 205, 206, 207 +db 208, 209, 210, 211, 212, 213, 214, 215 +db 216, 217, 218, 219, 220, 221, 222, 223 +db 224, 225, 226, 227, 228, 229, 230, 231 +db 232, 233, 234, 235, 236, 237, 238, 239 +db 240, 241, 242, 243, 244, 245, 246, 247 +db 248, 249, 250, 251, 252, 253, 254, 255 + +ucase_850 db 0FFh,"UCASE " ; From Steffen Kaiser's UNF package + dw 128 ; small fix: 'ÿ' -> 'Y' -- eca +db 128, 154, 144, 182, 142, 183, 143, 128 +db 210, 211, 212, 216, 215, 222, 142, 143 +db 144, 146, 146, 226, 153, 227, 234, 235 +db 99, 153, 154, 157, 156, 157, 158, 159 +db 181, 214, 224, 233, 165, 165, 166, 167 +db 168, 169, 170, 171, 172, 173, 174, 175 +db 176, 177, 178, 179, 180, 181, 182, 183 +db 184, 185, 186, 187, 188, 189, 190, 191 +db 192, 193, 194, 195, 196, 197, 199, 199 +db 200, 201, 202, 203, 204, 205, 206, 207 +db 209, 209, 210, 211, 212, 73, 214, 215 +db 216, 217, 218, 219, 220, 221, 222, 223 +db 224, 225, 226, 227, 229, 229, 230, 232 +db 232, 233, 234, 235, 237, 237, 238, 239 +db 240, 241, 242, 243, 244, 245, 246, 247 +db 248, 249, 250, 251, 252, 253, 254, 255 + +ucase_858 equ ucase_850 + +ucase_860 db 0FFh,"UCASE " + dw 128 ; Derived from ucase_437 +db 128, 154, 144, 143, 142, 145, 134, 128 +db 137, 137, 146, 139, 140, 152, 142, 143 +db 144, 145, 146, 140, 153, 169, 150, 157 +db 152, 153, 154, 155, 156, 157, 158, 159 +db 134, 139, 159, 150, 165, 165, 166, 167 +db 168, 169, 170, 171, 172, 173, 174, 175 +db 176, 177, 178, 179, 180, 181, 182, 183 +db 184, 185, 186, 187, 188, 189, 190, 191 +db 192, 193, 194, 195, 196, 197, 198, 199 +db 200, 201, 202, 203, 204, 205, 206, 207 +db 208, 209, 210, 211, 212, 213, 214, 215 +db 216, 217, 218, 219, 220, 221, 222, 223 +db 224, 225, 226, 227, 228, 229, 230, 231 +db 232, 233, 234, 235, 236, 237, 238, 239 +db 240, 241, 242, 243, 244, 245, 246, 247 +db 248, 249, 250, 251, 252, 253, 254, 255 + +ucase_857 db 0FFh,"UCASE " ; Turkish. Needs NLSFUNC for proper uppercasing + dw 128 ; of letter "i" (dotted i) +db 128, 154, 144, 182, 142, 183, 143, 128 +db 210, 211, 212, 216, 215, 73, 142, 143 +db 144, 146, 146, 226, 153, 227, 234, 235 +db 152, 153, 154, 157, 156, 157, 158, 158 +db 181, 214, 224, 233, 165, 165, 166, 166 +db 168, 169, 170, 171, 172, 173, 174, 175 +db 176, 177, 178, 179, 180, 181, 182, 183 +db 184, 185, 186, 187, 188, 189, 190, 191 +db 192, 193, 194, 195, 196, 197, 199, 199 +db 200, 201, 202, 203, 204, 205, 206, 207 +db 208, 209, 210, 211, 212, 213, 214, 215 +db 216, 217, 218, 219, 220, 221, 222, 223 +db 224, 225, 226, 227, 229, 229, 230, 231 +db 232, 233, 234, 235, 222, 89, 238, 239 +db 240, 241, 242, 243, 244, 245, 246, 247 +db 248, 249, 250, 251, 252, 253, 254, 255 + +ucase_863 db 0FFh,"UCASE " + dw 128 ; Derived from ucase_437 +db 128, 154, 144, 132, 132, 142, 134, 128 +db 146, 148, 145, 149, 168, 141, 142, 143 +db 144, 145, 146, 153, 148, 149, 158, 157 +db 152, 153, 154, 155, 156, 157, 158, 159 +db 160, 161, 79, 85, 164, 165, 166, 167 +db 168, 169, 170, 171, 172, 173, 174, 175 +db 176, 177, 178, 179, 180, 181, 182, 183 +db 184, 185, 186, 187, 188, 189, 190, 191 +db 192, 193, 194, 195, 196, 197, 198, 199 +db 200, 201, 202, 203, 204, 205, 206, 207 +db 208, 209, 210, 211, 212, 213, 214, 215 +db 216, 217, 218, 219, 220, 221, 222, 223 +db 224, 225, 226, 227, 228, 229, 230, 231 +db 232, 233, 234, 235, 236, 237, 238, 239 +db 240, 241, 242, 243, 244, 245, 246, 247 +db 248, 249, 250, 251, 252, 253, 254, 255 + +ucase_865 db 0FFh,"UCASE " + dw 128 +db 128, 154, 144, 65, 142, 65, 143, 128 +db 69, 69, 69, 73, 73, 73, 142, 143 +db 144, 146, 146, 89, 153, 89, 85, 85 +db 89, 153, 154, 157, 156, 157, 158, 159 +db 65, 73, 79, 85, 165, 165, 166, 167 +db 168, 169, 170, 171, 172, 173, 174, 175 +db 176, 177, 178, 179, 180, 181, 182, 183 +db 184, 185, 186, 187, 188, 189, 190, 191 +db 192, 193, 194, 195, 196, 197, 198, 199 +db 200, 201, 202, 203, 204, 205, 206, 207 +db 208, 209, 210, 211, 212, 213, 214, 215 +db 216, 217, 218, 219, 220, 221, 222, 223 +db 224, 225, 226, 227, 228, 229, 230, 231 +db 232, 233, 234, 235, 236, 237, 238, 239 +db 240, 241, 242, 243, 244, 245, 246, 247 +db 248, 249, 250, 251, 252, 253, 254, 255 + +ucase_866 db 0FFh,"UCASE " + dw 128 +db 128, 129, 130, 131, 132, 133, 134, 135 +db 136, 137, 138, 139, 140, 141, 142, 143 +db 144, 145, 146, 147, 148, 149, 150, 151 +db 152, 153, 154, 155, 156, 157, 158, 159 +db 128, 129, 130, 131, 132, 133, 134, 135 +db 136, 137, 138, 139, 140, 141, 142, 143 +db 176, 177, 178, 179, 180, 181, 182, 183 +db 184, 185, 186, 187, 188, 189, 190, 191 +db 192, 193, 194, 195, 196, 197, 198, 199 +db 200, 201, 202, 203, 204, 205, 206, 207 +db 208, 209, 210, 211, 212, 213, 214, 215 +db 216, 217, 218, 219, 220, 221, 222, 223 +db 144, 145, 146, 147, 148, 149, 150, 151 +db 152, 153, 154, 155, 156, 157, 158, 159 +db 240, 240, 242, 242, 244, 244, 246, 246 +db 248, 249, 250, 251, 252, 253, 254, 255 + +ucase_808 equ ucase_866 + +ucase_852 db 0FFh,"UCASE " + dw 128 +db 128, 154, 144, 182, 142, 222, 143, 128 +db 157, 211, 138, 138, 215, 141, 142, 143 +db 144, 145, 145, 226, 153, 149, 149, 151 +db 151, 153, 154, 155, 155, 157, 158, 172 +db 181, 146, 224, 233, 164, 164, 166, 166 +db 168, 168, 170, 141, 172, 184, 174, 175 +db 176, 177, 178, 179, 180, 181, 182, 183 +db 184, 185, 186, 187, 188, 189, 189, 191 +db 192, 193, 194, 195, 196, 197, 198, 198 +db 200, 201, 202, 203, 204, 205, 206, 207 +db 209, 209, 210, 211, 210, 213, 214, 215 +db 183, 217, 218, 219, 220, 221, 222, 223 +db 224, 225, 226, 227, 227, 213, 230, 230 +db 232, 233, 232, 235, 237, 237, 221, 239 +db 240, 241, 242, 243, 244, 245, 246, 247 +db 248, 249, 250, 235, 252, 252, 254, 255 + +ucase_855 db 0FFh,"UCASE " + dw 128 +db 129, 129, 131, 131, 133, 133, 135, 135 +db 137, 137, 139, 139, 141, 141, 143, 143 +db 145, 145, 147, 147, 149, 149, 151, 151 +db 153, 153, 155, 155, 157, 157, 159, 159 +db 161, 161, 163, 163, 165, 165, 167, 167 +db 169, 169, 171, 171, 173, 173, 174, 175 +db 176, 177, 178, 179, 180, 182, 182, 184 +db 184, 185, 186, 187, 188, 190, 190, 191 +db 192, 193, 194, 195, 196, 197, 199, 199 +db 200, 201, 202, 203, 204, 205, 206, 207 +db 209, 209, 211, 211, 213, 213, 215, 215 +db 221, 217, 218, 219, 220, 221, 224, 223 +db 224, 226, 226, 228, 228, 230, 230, 232 +db 232, 234, 234, 236, 236, 238, 238, 239 +db 240, 242, 242, 244, 244, 246, 246, 248 +db 248, 259, 250, 252, 252, 253, 254, 255 + +ucase_872 equ ucase_855 + +ucase_869 db 0FFh,"UCASE " + dw 128 +db 128, 129, 130, 131, 132, 133, 134, 135 +db 136, 137, 138, 139, 140, 141, 142, 143 +db 144, 145, 146, 147, 148, 149, 150, 151 +db 152, 153, 154, 134, 155, 141, 143, 144 +db 145, 145, 146, 149, 164, 165, 166, 167 +db 168, 169, 170, 171, 172, 173, 174, 175 +db 176, 177, 178, 179, 180, 181, 182, 183 +db 184, 185, 186, 187, 188, 189, 190, 191 +db 192, 193, 194, 195, 196, 197, 198, 199 +db 200, 201, 202, 203, 204, 205, 206, 207 +db 208, 209, 210, 211, 212, 213, 164, 165 +db 166, 217, 218, 219, 220, 167, 168, 223 +db 169, 170, 172, 173, 181, 182, 183, 184 +db 189, 190, 198, 199, 207, 207, 208, 239 +db 240, 241, 209, 210, 211, 245, 212, 247 +db 248, 249, 213, 150, 150, 152, 254, 255 + +ucase_737 db 0FFh,"UCASE " + dw 128 +db 128, 129, 130, 131, 132, 133, 134, 135 +db 136, 137, 138, 139, 140, 141, 142, 143 +db 144, 145, 146, 147, 148, 149, 150, 151 +db 128, 129, 130, 131, 132, 133, 134, 135 +db 136, 137, 138, 139, 140, 141, 142, 143 +db 144, 145, 145, 146, 147, 148, 149, 150 +db 176, 177, 178, 179, 180, 181, 182, 183 +db 184, 185, 186, 187, 188, 189, 190, 191 +db 192, 193, 194, 195, 196, 197, 198, 199 +db 200, 201, 202, 203, 204, 205, 206, 207 +db 208, 209, 210, 211, 212, 213, 214, 215 +db 216, 217, 218, 219, 220, 221, 222, 223 +db 151, 234, 235, 236, 244, 237, 238, 239 +db 245, 240, 234, 235, 236, 237, 238, 239 +db 240, 241, 242, 243, 244, 245, 246, 247 +db 248, 249, 250, 251, 252, 253, 254, 255 + +ucase_932 db 0FFh,"UCASE " + dw 128 +db 128, 129, 130, 131, 132, 133, 134, 135 +db 136, 137, 138, 139, 140, 141, 142, 143 +db 144, 145, 146, 147, 148, 149, 150, 151 +db 152, 153, 154, 155, 156, 157, 158, 159 +db 160, 161, 162, 163, 164, 165, 166, 167 +db 168, 169, 170, 171, 172, 173, 174, 175 +db 176, 177, 178, 179, 180, 181, 182, 183 +db 184, 185, 186, 187, 188, 189, 190, 191 +db 192, 193, 194, 195, 196, 197, 198, 199 +db 200, 201, 202, 203, 204, 205, 206, 207 +db 208, 209, 210, 211, 212, 213, 214, 215 +db 216, 217, 218, 219, 220, 221, 222, 223 +db 224, 225, 226, 227, 228, 229, 230, 231 +db 232, 233, 234, 235, 236, 237, 238, 239 +db 240, 241, 242, 243, 244, 245, 246, 247 +db 248, 249, 250, 251, 252, 253, 254, 255 -; Uppercase equivalents of chars 80h to FFh -;------------------------------------------------------------------------------ -ucase_437 db 0FFh,"UCASE " ; Same as kernel's harcoded +ucase_934 equ ucase_932 +ucase_936 equ ucase_932 + +ucase_848 db 0FFh,"UCASE " + dw 128 +db 128, 129, 130, 131, 132, 133, 134, 135 +db 136, 137, 138, 139, 140, 141, 142, 143 +db 144, 145, 146, 147, 148, 149, 150, 151 +db 152, 153, 154, 155, 156, 157, 158, 159 +db 128, 129, 130, 131, 132, 133, 134, 135 +db 136, 137, 138, 139, 140, 141, 142, 143 +db 176, 177, 178, 179, 180, 181, 182, 183 +db 184, 185, 186, 187, 188, 189, 190, 191 +db 192, 193, 194, 195, 196, 197, 198, 199 +db 200, 201, 202, 203, 204, 205, 206, 207 +db 208, 209, 210, 211, 212, 213, 214, 215 +db 216, 217, 218, 219, 220, 221, 222, 223 +db 144, 145, 146, 147, 148, 149, 150, 151 +db 152, 153, 154, 155, 156, 157, 158, 159 +db 240, 240, 242, 242, 244, 244, 246, 246 +db 248, 248, 250, 251, 252, 253, 254, 255 + +ucase_1125 equ ucase_848 + +ucase_862 db 0FFh,"UCASE " dw 128 -db 128, 154, 69, 65, 142, 65, 143, 128 -db 69, 69, 69, 73, 73, 73, 142, 143 -db 144, 146, 146, 79, 153, 79, 85, 85 -db 89, 153, 154, 155, 156, 157, 158, 159 +db 128, 129, 130, 131, 132, 133, 134, 135 +db 136, 137, 138, 139, 140, 141, 142, 143 +db 144, 145, 146, 147, 148, 149, 150, 151 +db 152, 153, 154, 155, 156, 157, 158, 159 db 65, 73, 79, 85, 165, 165, 166, 167 db 168, 169, 170, 171, 172, 173, 174, 175 db 176, 177, 178, 179, 180, 181, 182, 183 @@ -773,25 +3295,84 @@ db 232, 233, 234, 235, 236, 237, 238, 239 db 240, 241, 242, 243, 244, 245, 246, 247 db 248, 249, 250, 251, 252, 253, 254, 255 -ucase_850 db 0FFh,"UCASE " ; From Steffen Kaiser's UNF package - dw 128 -db 128, 154, 144, 182, 142, 183, 143, 128 -db 210, 211, 212, 216, 215, 222, 142, 143 -db 144, 146, 146, 226, 153, 227, 234, 235 -db 95, 153, 154, 157, 156, 157, 158, 159 -db 181, 214, 224, 233, 165, 165, 166, 167 +ucase_864 equ ucase_932 + +; Lowercase equivalents of chars 00h to FFh +;------------------------------------------------------------------------------ +lcase_866 db 0FFh,"LCASE " + dw 256 +db 0, 1, 2, 3, 4, 5, 6, 7 +db 8, 9, 10, 11, 12, 13, 14, 15 +db 16, 17, 18, 19, 20, 21, 22, 23 +db 24, 25, 26, 27, 28, 29, 30, 31 +db 32, 33, 34, 35, 36, 37, 38, 39 +db 40, 41, 42, 43, 44, 45, 46, 47 +db 48, 49, 50, 51, 52, 53, 54, 55 +db 56, 57, 58, 59, 60, 61, 62, 63 +db 64, 97, 98, 99, 100, 101, 102, 103 +db 104, 105, 106, 107, 108, 109, 110, 111 +db 112, 113, 114, 115, 116, 117, 118, 119 +db 120, 121, 122, 91, 92, 93, 94, 95 +db 96, 97, 98, 99, 100, 101, 102, 103 +db 104, 105, 106, 107, 108, 109, 110, 111 +db 112, 113, 114, 115, 116, 117, 118, 119 +db 120, 121, 122, 123, 124, 125, 126, 127 +db 160, 161, 162, 163, 164, 165, 166, 167 +db 168, 169, 170, 171, 172, 173, 174, 175 +db 224, 225, 226, 227, 228, 229, 230, 231 +db 232, 233, 234, 235, 236, 237, 238, 239 +db 160, 161, 162, 163, 164, 165, 166, 167 db 168, 169, 170, 171, 172, 173, 174, 175 db 176, 177, 178, 179, 180, 181, 182, 183 db 184, 185, 186, 187, 188, 189, 190, 191 -db 192, 193, 194, 195, 196, 197, 199, 199 +db 192, 193, 194, 195, 196, 197, 198, 199 db 200, 201, 202, 203, 204, 205, 206, 207 -db 209, 209, 210, 211, 212, 73, 214, 215 +db 208, 209, 210, 211, 212, 213, 214, 215 db 216, 217, 218, 219, 220, 221, 222, 223 -db 224, 225, 226, 227, 229, 229, 230, 232 -db 232, 233, 234, 235, 237, 237, 238, 239 -db 240, 241, 242, 243, 244, 245, 246, 247 +db 224, 225, 226, 227, 228, 229, 230, 231 +db 232, 233, 234, 235, 236, 237, 238, 239 +db 241, 241, 243, 243, 245, 245, 247, 247 db 248, 249, 250, 251, 252, 253, 254, 255 +lcase_808 equ lcase_866 + +lcase_848 db 0FFh,"LCASE " + dw 256 +db 0, 1, 2, 3, 4, 5, 6, 7 +db 8, 9, 10, 11, 12, 13, 14, 15 +db 16, 17, 18, 19, 20, 21, 22, 23 +db 24, 25, 26, 27, 28, 29, 30, 31 +db 32, 33, 34, 35, 36, 37, 38, 39 +db 40, 41, 42, 43, 44, 45, 46, 47 +db 48, 49, 50, 51, 52, 53, 54, 55 +db 56, 57, 58, 59, 60, 61, 62, 63 +db 64, 97, 98, 99, 100, 101, 102, 103 +db 104, 105, 106, 107, 108, 109, 110, 111 +db 112, 113, 114, 115, 116, 117, 118, 119 +db 120, 121, 122, 91, 92, 93, 94, 95 +db 96, 97, 98, 99, 100, 101, 102, 103 +db 104, 105, 106, 107, 108, 109, 110, 111 +db 112, 113, 114, 115, 116, 117, 118, 119 +db 120, 121, 122, 123, 124, 125, 126, 127 +db 160, 161, 162, 163, 164, 165, 166, 167 +db 168, 169, 170, 171, 172, 173, 174, 175 +db 224, 225, 226, 227, 228, 229, 230, 231 +db 232, 233, 234, 235, 236, 237, 238, 239 +db 160, 161, 162, 163, 164, 165, 166, 167 +db 168, 169, 170, 171, 172, 173, 174, 175 +db 176, 177, 178, 179, 180, 181, 182, 183 +db 184, 185, 186, 187, 188, 189, 190, 191 +db 192, 193, 194, 195, 196, 197, 198, 199 +db 200, 201, 202, 203, 204, 205, 206, 207 +db 208, 209, 210, 211, 212, 213, 214, 215 +db 216, 217, 218, 219, 220, 221, 222, 223 +db 224, 225, 226, 227, 228, 229, 230, 231 +db 232, 233, 234, 235, 236, 237, 238, 239 +db 241, 241, 243, 243, 245, 245, 247, 247 +db 249, 249, 250, 251, 252, 253, 254, 255 + +lcase_1125 equ lcase_848 + ; Filename terminator table ;------------------------------------------------------------------------------ fchar db 0FFh,"FCHAR " ; Same as kernel's hardcoded @@ -983,9 +3564,435 @@ db 74, 217, 218, 219, 220, 221, 74, 223 db 81, 86, 81, 81, 81, 81, 230, 231 db 232, 88, 88, 88, 92, 92, 238, 239 db 240, 241, 242, 243, 244, 245, 246, 247 -db 248, 249, 250, 49, 51, 50, 254, 255 +db 248, 249, 250, 49, 51, 50, 254, 255 + +es_collate_858 db 0FFh,"COLLATE" ; Spanish, CP858 + dw 256 +db 0, 1, 2, 3, 4, 5, 6, 7 +db 8, 9, 10, 11, 12, 13, 14, 15 +db 16, 17, 18, 19, 20, 21, 22, 23 +db 24, 25, 26, 27, 28, 29, 30, 31 +db 32, 33, 34, 35, 36, 37, 38, 39 +db 40, 41, 42, 43, 44, 45, 46, 47 +db 48, 49, 50, 51, 52, 53, 54, 55 +db 56, 57, 58, 59, 60, 61, 62, 63 +db 64, 65, 66, 67, 68, 69, 70, 71 +db 72, 73, 74, 75, 76, 77, 78, 80 +db 81, 82, 83, 84, 85, 86, 87, 88 +db 89, 90, 91, 92, 93, 94, 95, 96 +db 97, 65, 66, 67, 68, 69, 70, 71 +db 72, 73, 74, 75, 76, 77, 78, 80 +db 81, 82, 83, 84, 85, 86, 87, 88 +db 89, 90, 91, 123, 124, 125, 126, 127 +db 68, 86, 69, 65, 65, 65, 65, 68 +db 69, 69, 69, 73, 73, 73, 65, 65 +db 69, 65, 65, 80, 80, 80, 86, 86 +db 90, 80, 86, 80, 36, 80, 158, 36 +db 65, 73, 80, 86, 79, 79, 65, 80 +db 63, 169, 170, 171, 172, 33, 34, 34 +db 176, 177, 178, 179, 180, 65, 65, 65 +db 184, 185, 186, 187, 188, 36, 36, 191 +db 192, 193, 194, 195, 196, 197, 65, 65 +db 200, 201, 202, 203, 204, 205, 206, 36 +db 68, 68, 69, 69, 69, 36, 73, 73 +db 73, 217, 218, 219, 220, 221, 73, 223 +db 80, 225, 80, 80, 80, 80, 230, 231 +db 232, 86, 86, 86, 90, 90, 238, 239 +db 240, 241, 242, 243, 244, 245, 246, 247 +db 248, 249, 250, 49, 51, 50, 254, 255 + +ca_collate_850 equ en_collate_850 ; Catalan, CP850 +ca_collate_858 equ en_collate_858 ; Catalan, CP858 +ca_collate_437 equ en_collate_437 ; Catalan, CP437 +gl_collate_850 equ en_collate_850 ; Gallegan, CP850 +gl_collate_858 equ en_collate_858 ; Gallegan, CP858 +gl_collate_437 equ en_collate_437 ; Gallegan, CP437 +eu_collate_850 equ en_collate_850 ; Basque, CP850 +eu_collate_858 equ en_collate_858 ; Basque, CP858 +eu_collate_437 equ en_collate_437 ; Basque, CP437 + +de_collate_850 equ en_collate_850 ; German, CP850 +de_collate_858 equ en_collate_858 ; German, CP858 +de_collate_437 equ en_collate_437 ; German, CP437 + +pt_collate_860 db 0FFh,"COLLATE" ; Portuguese, CP860 + dw 256 ; Derived from English CP437 +db 0, 1, 2, 3, 4, 5, 6, 7 +db 8, 9, 10, 11, 12, 13, 14, 15 +db 16, 17, 18, 19, 20, 21, 22, 23 +db 24, 25, 26, 27, 28, 29, 30, 31 +db 32, 33, 34, 35, 36, 37, 38, 39 +db 40, 41, 42, 43, 44, 45, 46, 47 +db 48, 49, 50, 51, 52, 53, 54, 55 +db 56, 57, 58, 59, 60, 61, 62, 63 +db 64, 65, 66, 67, 68, 69, 70, 71 +db 72, 73, 74, 75, 76, 77, 78, 79 +db 80, 81, 82, 83, 84, 85, 86, 87 +db 88, 89, 90, 91, 92, 93, 94, 95 +db 96, 65, 66, 67, 68, 69, 70, 71 +db 72, 73, 74, 75, 76, 77, 78, 79 +db 80, 81, 82, 83, 84, 85, 86, 87 +db 88, 89, 90, 123, 124, 125, 126, 127 +db 67, 85, 69, 65, 65, 65, 65, 67 +db 69, 69, 69, 73, 79, 73, 65, 65 +db 69, 65, 69, 79, 79, 79, 85, 85 +db 73, 79, 85, 36, 36, 85, 36, 79 +db 65, 73, 79, 85, 78, 78, 166, 167 +db 63, 79, 170, 171, 172, 33, 34, 34 +db 176, 177, 178, 179, 180, 181, 182, 183 +db 184, 185, 186, 187, 188, 189, 190, 191 +db 192, 193, 194, 195, 196, 197, 198, 199 +db 200, 201, 202, 203, 204, 205, 206, 207 +db 208, 209, 210, 211, 212, 213, 214, 215 +db 216, 217, 218, 219, 220, 221, 222, 223 +db 224, 83, 226, 227, 228, 229, 230, 231 +db 232, 233, 234, 235, 236, 237, 238, 239 +db 240, 241, 242, 243, 244, 245, 246, 247 +db 248, 249, 250, 251, 252, 253, 254, 255 + +pt_collate_850 equ en_collate_850 ; Portuguese CP850 +pt_collate_858 equ en_collate_858 ; Portuguese CP858 +pt_collate_437 equ en_collate_437 ; Portuguese CP437 + + +fr_collate_863 db 0FFh,"COLLATE" ; French, CP863 + dw 256 ; Derived from English CP437 +db 0, 1, 2, 3, 4, 5, 6, 7 +db 8, 9, 10, 11, 12, 13, 14, 15 +db 16, 17, 18, 19, 20, 21, 22, 23 +db 24, 25, 26, 27, 28, 29, 30, 31 +db 32, 33, 34, 35, 36, 37, 38, 39 +db 40, 41, 42, 43, 44, 45, 46, 47 +db 48, 49, 50, 51, 52, 53, 54, 55 +db 56, 57, 58, 59, 60, 61, 62, 63 +db 64, 65, 66, 67, 68, 69, 70, 71 +db 72, 73, 74, 75, 76, 77, 78, 79 +db 80, 81, 82, 83, 84, 85, 86, 87 +db 88, 89, 90, 91, 92, 93, 94, 95 +db 96, 65, 66, 67, 68, 69, 70, 71 +db 72, 73, 74, 75, 76, 77, 78, 79 +db 80, 81, 82, 83, 84, 85, 86, 87 +db 88, 89, 90, 123, 124, 125, 126, 127 +db 67, 85, 69, 65, 65, 65, 134, 67 +db 69, 69, 69, 73, 73, 141, 65, 143 +db 69, 69, 69, 79, 69, 73, 85, 85 +db 36, 79, 85, 36, 36, 85, 85, 36 +db 160, 161, 79, 85, 164, 165, 166, 167 +db 63, 169, 170, 171, 172, 173, 34, 34 +db 176, 177, 178, 179, 180, 181, 182, 183 +db 184, 185, 186, 187, 188, 189, 190, 191 +db 192, 193, 194, 195, 196, 197, 198, 199 +db 200, 201, 202, 203, 204, 205, 206, 207 +db 208, 209, 210, 211, 212, 213, 214, 215 +db 216, 217, 218, 219, 220, 221, 222, 223 +db 224, 83, 226, 227, 228, 229, 230, 231 +db 232, 233, 234, 235, 236, 237, 238, 239 +db 240, 241, 242, 243, 244, 245, 246, 247 +db 248, 249, 250, 251, 252, 253, 254, 255 + +fr_collate_850 equ en_collate_850 ; French, CP850 +fr_collate_858 equ en_collate_858 ; French, CP858 +fr_collate_437 equ en_collate_437 ; French, CP437 + +it_collate_850 equ en_collate_850 ; Italian, CP850 +it_collate_858 equ en_collate_858 ; Italian, CP858 +it_collate_437 equ en_collate_437 ; Italian, CP437 + +nl_collate_850 equ en_collate_850 ; Dutch, CP850 +nl_collate_858 equ en_collate_858 ; Dutch, CP858 +nl_collate_437 equ en_collate_437 ; Dutch, CP437 + +be_collate_850 equ en_collate_850 ; Belgium, CP850 +be_collate_858 equ en_collate_858 ; Belgium, CP858 +be_collate_437 equ en_collate_437 ; Belgium, CP437 + +tr_collate_857 db 0FFh,"COLLATE" ; Turkish, CP857 (with Euro) + dw 256 +db 0, 1, 2, 3, 4, 5, 6, 7 +db 8, 9, 10, 11, 12, 13, 14, 15 +db 16, 17, 18, 19, 20, 21, 22, 23 +db 24, 25, 26, 27, 28, 29, 30, 31 +db 32, 33, 34, 35, 36, 37, 38, 39 +db 40, 41, 42, 43, 44, 45, 46, 47 +db 48, 49, 50, 51, 52, 53, 54, 55 +db 56, 57, 58, 59, 60, 61, 62, 63 +db 64, 65, 66, 67, 69, 70, 71, 72 +db 74, 75, 77, 78, 79, 80, 81, 82 +db 84, 85, 86, 87, 89, 90, 92, 93 +db 94, 95, 96, 97, 98, 99, 100, 101 +db 102, 65, 66, 67, 69, 70, 71, 72 +db 74, 76, 77, 78, 79, 80, 81, 82 +db 84, 85, 86, 87, 89, 90, 92, 93 +db 94, 95, 96, 123, 124, 125, 126, 127 +db 68, 91, 70, 65, 65, 65, 65, 68 +db 70, 70, 70, 76, 76, 75, 65, 65 +db 70, 145, 145, 82, 83, 82, 90, 90 +db 76, 83, 91, 155, 36, 155, 88, 88 +db 65, 76, 82, 90, 81, 81, 73, 73 +db 63, 169, 170, 171, 172, 33, 34, 34 +db 176, 177, 178, 179, 180, 65, 65, 65 +db 184, 185, 186, 187, 188, 36, 36, 191 +db 192, 193, 194, 195, 196, 197, 65, 65 +db 200, 201, 202, 203, 204, 205, 206, 36 +db 82, 65, 70, 70, 70, 36, 76, 76 +db 76, 217, 218, 219, 220, 221, 76, 223 +db 82, 225, 82, 82, 82, 82, 230, 32 +db 232, 90, 90, 90, 76, 95, 238, 239 +db 240, 241, 32, 243, 244, 245, 246, 247 +db 248, 249, 250, 49, 51, 50, 254, 255 + +tr_collate_850 db 0FFh,"COLLATE" ; Turkish, CP850 + dw 256 +db 0, 1, 2, 3, 4, 5, 6, 7 +db 8, 9, 10, 11, 12, 13, 14, 15 +db 16, 17, 18, 19, 20, 21, 22, 23 +db 24, 25, 26, 27, 28, 29, 30, 31 +db 32, 33, 34, 35, 36, 37, 38, 39 +db 40, 41, 42, 43, 44, 45, 46, 47 +db 48, 49, 50, 51, 52, 53, 54, 55 +db 56, 57, 58, 59, 60, 61, 62, 63 +db 64, 65, 66, 67, 69, 70, 71, 72 +db 74, 75, 77, 78, 79, 80, 81, 82 +db 84, 85, 86, 87, 89, 90, 92, 93 +db 94, 95, 96, 97, 98, 99, 100, 101 +db 102, 65, 66, 67, 69, 70, 71, 72 +db 74, 76, 77, 78, 79, 80, 81, 82 +db 84, 85, 86, 87, 89, 90, 92, 93 +db 94, 95, 96, 123, 124, 125, 126, 127 +db 68, 91, 70, 65, 65, 65, 65, 68 +db 70, 70, 70, 76, 76, 76, 65, 65 +db 70, 145, 145, 82, 83, 82, 90, 90 +db 95, 83, 91, 155, 36, 155, 36, 36 +db 65, 76, 82, 90, 81, 81, 65, 82 +db 63, 169, 170, 171, 172, 33, 34, 34 +db 176, 177, 178, 179, 180, 65, 65, 65 +db 184, 185, 186, 187, 188, 36, 36, 191 +db 192, 193, 194, 195, 196, 197, 65, 65 +db 200, 201, 202, 203, 204, 205, 206, 36 +db 209, 209, 70, 70, 70, 75, 76, 76 +db 76, 217, 218, 219, 220, 221, 76, 223 +db 82, 225, 82, 82, 82, 82, 230, 231 +db 231, 90, 90, 90, 95, 95, 238, 239 +db 240, 241, 242, 243, 244, 245, 246, 247 +db 248, 249, 250, 49, 51, 50, 254, 255 + +dk_collate_865 db 0FFh,"COLLATE" ; Danish, CP865 + dw 256 +db 0, 1, 2, 3, 4, 5, 6, 7 +db 8, 9, 10, 11, 12, 13, 14, 15 +db 16, 17, 18, 19, 20, 21, 22, 23 +db 24, 25, 26, 27, 28, 29, 30, 31 +db 32, 33, 34, 35, 36, 37, 38, 39 +db 40, 41, 42, 43, 44, 45, 46, 47 +db 48, 49, 50, 51, 52, 53, 54, 55 +db 56, 57, 58, 59, 60, 61, 62, 63 +db 64, 65, 66, 67, 68, 69, 70, 71 +db 72, 73, 74, 75, 76, 77, 78, 79 +db 80, 81, 82, 83, 84, 85, 86, 86 +db 87, 88, 89, 93, 94, 95, 96, 97 +db 98, 65, 66, 67, 68, 69, 70, 71 +db 72, 73, 74, 75, 76, 77, 78, 79 +db 80, 81, 82, 83, 84, 85, 86, 86 +db 87, 88, 89, 123, 124, 125, 126, 127 +db 67, 85, 69, 65, 65, 65, 92, 67 +db 69, 69, 69, 73, 73, 73, 65, 92 +db 69, 90, 90, 79, 79, 79, 85, 85 +db 88, 79, 85, 91, 36, 91, 36, 36 +db 65, 73, 79, 85, 78, 78, 65, 79 +db 63, 169, 170, 171, 172, 33, 34, 36 +db 176, 177, 178, 179, 180, 181, 182, 183 +db 184, 185, 186, 187, 188, 189, 190, 191 +db 192, 193, 194, 195, 196, 197, 198, 199 +db 200, 201, 202, 203, 204, 205, 206, 207 +db 208, 209, 210, 211, 212, 213, 214, 215 +db 216, 217, 218, 219, 220, 221, 222, 223 +db 224, 83, 226, 227, 228, 229, 230, 231 +db 232, 233, 234, 235, 236, 237, 238, 239 +db 240, 241, 242, 243, 244, 245, 246, 247 +db 248, 249, 250, 251, 78, 50, 254, 255 + +dk_collate_850 db 0FFh,"COLLATE" ; Danish, CP850 + dw 256 +db 0, 1, 2, 3, 4, 5, 6, 7 +db 8, 9, 10, 11, 12, 13, 14, 15 +db 16, 17, 18, 19, 20, 21, 22, 23 +db 24, 25, 26, 27, 28, 29, 30, 31 +db 32, 33, 34, 35, 36, 37, 38, 39 +db 40, 41, 42, 43, 44, 45, 46, 47 +db 48, 49, 50, 51, 52, 53, 54, 55 +db 56, 57, 58, 59, 60, 61, 62, 63 +db 64, 65, 66, 67, 68, 69, 70, 71 +db 72, 73, 74, 75, 76, 77, 78, 79 +db 80, 81, 82, 83, 84, 85, 86, 86 +db 87, 88, 89, 93, 94, 95, 96, 97 +db 98, 65, 66, 67, 68, 69, 70, 71 +db 72, 73, 74, 75, 76, 77, 78, 79 +db 80, 81, 82, 83, 84, 85, 86, 86 +db 87, 88, 89, 123, 124, 125, 126, 127 +db 67, 85, 69, 65, 65, 65, 92, 67 +db 69, 69, 69, 73, 73, 73, 65, 92 +db 69, 90, 90, 79, 79, 79, 85, 85 +db 88, 79, 85, 91, 36, 91, 36, 36 +db 65, 73, 79, 85, 78, 78, 65, 79 +db 63, 169, 170, 171, 172, 33, 34, 34 +db 176, 177, 178, 179, 180, 65, 65, 65 +db 169, 185, 186, 187, 188, 36, 36, 191 +db 192, 193, 194, 195, 196, 197, 65, 65 +db 200, 201, 202, 203, 204, 205, 206, 36 +db 68, 68, 69, 69, 69, 73, 73, 73 +db 73, 217, 218, 219, 220, 221, 73, 223 +db 79, 83, 79, 79, 79, 79, 230, 231 +db 232, 85, 85, 85, 88, 88, 238, 239 +db 240, 241, 242, 243, 244, 245, 246, 247 +db 248, 249, 250, 49, 51, 50, 254, 255 + +dk_collate_858 db 0FFh,"COLLATE" ; Danish, CP858 + dw 256 +db 0, 1, 2, 3, 4, 5, 6, 7 +db 8, 9, 10, 11, 12, 13, 14, 15 +db 16, 17, 18, 19, 20, 21, 22, 23 +db 24, 25, 26, 27, 28, 29, 30, 31 +db 32, 33, 34, 35, 36, 37, 38, 39 +db 40, 41, 42, 43, 44, 45, 46, 47 +db 48, 49, 50, 51, 52, 53, 54, 55 +db 56, 57, 58, 59, 60, 61, 62, 63 +db 64, 65, 66, 67, 68, 69, 70, 71 +db 72, 73, 74, 75, 76, 77, 78, 79 +db 80, 81, 82, 83, 84, 85, 86, 86 +db 87, 88, 89, 93, 94, 95, 96, 97 +db 98, 65, 66, 67, 68, 69, 70, 71 +db 72, 73, 74, 75, 76, 77, 78, 79 +db 80, 81, 82, 83, 84, 85, 86, 86 +db 87, 88, 89, 123, 124, 125, 126, 127 +db 67, 85, 69, 65, 65, 65, 92, 67 +db 69, 69, 69, 73, 73, 73, 65, 92 +db 69, 90, 90, 79, 79, 79, 85, 85 +db 88, 79, 85, 91, 36, 91, 36, 36 +db 65, 73, 79, 85, 78, 78, 65, 79 +db 63, 169, 170, 171, 172, 33, 34, 34 +db 176, 177, 178, 179, 180, 65, 65, 65 +db 169, 185, 186, 187, 188, 36, 36, 191 +db 192, 193, 194, 195, 196, 197, 65, 65 +db 200, 201, 202, 203, 204, 205, 206, 36 +db 68, 68, 69, 69, 69, 36, 73, 73 +db 73, 217, 218, 219, 220, 221, 73, 223 +db 79, 83, 79, 79, 79, 79, 230, 231 +db 232, 85, 85, 85, 88, 88, 238, 239 +db 240, 241, 242, 243, 244, 245, 246, 247 +db 248, 249, 250, 49, 51, 50, 254, 255 + +no_collate_865 equ dk_collate_865 ; Norwegian CP865 +no_collate_850 equ dk_collate_850 ; Norwegian CP850 +no_collate_858 equ dk_collate_858 ; Norwegian CP858 + +ru_collate_866 db 0FFh,"COLLATE" ; Russian, CP866 + dw 256 +db 0, 1, 2, 3, 4, 5, 6, 7 +db 8, 9, 10, 11, 12, 13, 14, 15 +db 16, 17, 18, 19, 20, 21, 22, 23 +db 24, 25, 26, 27, 28, 29, 30, 31 +db 32, 33, 34, 35, 36, 37, 38, 39 +db 40, 41, 42, 43, 44, 45, 46, 47 +db 48, 49, 50, 51, 52, 53, 54, 55 +db 56, 57, 58, 59, 60, 61, 62, 63 +db 64, 65, 66, 67, 68, 69, 70, 71 +db 72, 73, 74, 75, 76, 77, 78, 79 +db 80, 81, 82, 83, 84, 85, 86, 87 +db 88, 89, 90, 91, 92, 93, 94, 95 +db 96, 65, 66, 67, 68, 69, 70, 71 +db 72, 73, 74, 75, 76, 77, 78, 79 +db 80, 81, 82, 83, 84, 85, 86, 87 +db 88, 89, 90, 123, 124, 125, 126, 127 +db 128, 129, 130, 131, 132, 135, 137, 138 +db 140, 143, 145, 146, 148, 149, 151, 152 +db 153, 154, 155, 158, 160, 161, 162, 163 +db 165, 166, 167, 168, 169, 170, 171, 172 +db 128, 129, 130, 131, 132, 135, 137, 138 +db 140, 143, 145, 146, 148, 149, 151, 152 +db 176, 177, 178, 179, 180, 181, 182, 183 +db 184, 185, 186, 187, 188, 189, 190, 191 +db 192, 193, 194, 195, 196, 197, 198, 199 +db 200, 201, 202, 203, 204, 205, 206, 207 +db 208, 209, 210, 211, 212, 213, 214, 215 +db 216, 217, 218, 219, 220, 221, 222, 223 +db 153, 154, 155, 158, 160, 161, 162, 163 +db 165, 166, 167, 168, 169, 170, 171, 172 +db 135, 135, 136, 136, 142, 142, 159, 159 +db 248, 249, 250, 251, 252, 36, 254, 255 + +ru_collate_808 equ ru_collate_866 ; Russian, CP808 + +ru_collate_852 db 0FFh,"COLLATE" ; Russian, CP852 (with Euro) + dw 256 +db 0, 1, 2, 3, 4, 5, 6, 7 +db 8, 9, 10, 11, 12, 13, 14, 15 +db 16, 17, 18, 19, 20, 21, 22, 23 +db 24, 25, 26, 27, 28, 29, 30, 31 +db 32, 33, 34, 35, 36, 37, 38, 39 +db 40, 41, 42, 43, 44, 45, 46, 47 +db 48, 49, 50, 51, 52, 53, 54, 55 +db 56, 57, 58, 59, 60, 61, 62, 63 +db 64, 65, 68, 69, 72, 74, 76, 77 +db 78, 79, 81, 82, 83, 85, 86, 88 +db 92, 93, 94, 96, 100, 102, 105, 106 +db 107, 108, 109, 114, 115, 116, 117, 118 +db 119, 65, 68, 69, 72, 74, 76, 77 +db 78, 79, 81, 82, 83, 85, 86, 88 +db 92, 93, 94, 96, 100, 102, 105, 106 +db 107, 108, 109, 123, 124, 125, 126, 127 +db 69, 103, 74, 65, 65, 102, 71, 69 +db 84, 74, 91, 91, 80, 111, 65, 71 +db 74, 83, 83, 88, 90, 83, 83, 98 +db 98, 90, 103, 101, 101, 84, 36, 70 +db 65, 79, 88, 102, 67, 67, 110, 110 +db 75, 75, 36, 111, 70, 99, 34, 34 +db 176, 177, 178, 179, 180, 65, 65, 74 +db 99, 185, 186, 187, 188, 112, 112, 191 +db 192, 193, 194, 195, 196, 197, 66, 66 +db 200, 201, 202, 203, 204, 205, 206, 36 +db 73, 73, 72, 74, 72, 86, 79, 80 +db 74, 217, 218, 219, 220, 113, 102, 223 +db 88, 225, 88, 87, 87, 86, 97, 97 +db 94, 102, 94, 104, 108, 108, 113, 239 +db 240, 241, 242, 243, 244, 245, 246, 247 +db 248, 249, 250, 104, 95, 95, 254, 255 + +pl_collate_852 db 0FFh,"COLLATE" ; Polish, CP852 (with Euro) + dw 256 +db 0, 1, 2, 3, 4, 5, 6, 7 +db 8, 9, 10, 11, 12, 13, 14, 15 +db 16, 17, 18, 19, 20, 21, 22, 23 +db 24, 25, 26, 27, 28, 29, 30, 31 +db 32, 33, 34, 35, 36, 37, 38, 39 +db 40, 41, 42, 43, 44, 45, 46, 47 +db 48, 49, 50, 51, 52, 53, 54, 55 +db 56, 57, 58, 59, 60, 61, 62, 63 +db 64, 65, 68, 69, 72, 74, 76, 77 +db 78, 79, 81, 82, 83, 85, 86, 88 +db 92, 93, 94, 96, 100, 102, 105, 106 +db 107, 108, 109, 114, 115, 116, 117, 118 +db 119, 65, 68, 69, 72, 74, 76, 77 +db 78, 79, 81, 82, 83, 85, 86, 88 +db 92, 93, 94, 96, 100, 102, 105, 106 +db 107, 108, 109, 123, 124, 125, 126, 127 +db 69, 103, 74, 65, 65, 102, 71, 69 +db 84, 74, 91, 91, 80, 111, 65, 71 +db 74, 83, 83, 88, 90, 83, 83, 98 +db 98, 90, 103, 101, 101, 84, 36, 70 +db 65, 79, 89, 102, 67, 67, 110, 110 +db 75, 75, 36, 111, 70, 99, 34, 34 +db 176, 177, 178, 179, 180, 65, 65, 74 +db 99, 185, 186, 187, 188, 112, 112, 191 +db 192, 193, 194, 195, 196, 197, 66, 66 +db 200, 201, 202, 203, 204, 205, 206, 36 +db 73, 73, 72, 74, 72, 86, 79, 80 +db 74, 217, 218, 219, 220, 113, 102, 223 +db 89, 225, 88, 87, 87, 86, 97, 97 +db 94, 102, 94, 104, 108, 108, 113, 239 +db 240, 241, 242, 243, 244, 245, 246, 247 +db 248, 249, 250, 104, 95, 95, 254, 255 -es_collate_858 db 0FFh,"COLLATE" ; Spanish, CP858 +pl_collate_850 db 0FFh,"COLLATE" ; Polish, CP850 dw 256 db 0, 1, 2, 3, 4, 5, 6, 7 db 8, 9, 10, 11, 12, 13, 14, 15 @@ -995,33 +4002,33 @@ db 32, 33, 34, 35, 36, 37, 38, 39 db 40, 41, 42, 43, 44, 45, 46, 47 db 48, 49, 50, 51, 52, 53, 54, 55 db 56, 57, 58, 59, 60, 61, 62, 63 -db 64, 65, 66, 67, 69, 70, 71, 72 -db 73, 74, 75, 76, 77, 78, 79, 81 -db 82, 83, 84, 85, 87, 88, 89, 90 -db 91, 92, 93, 94, 95, 96, 97, 98 -db 99, 65, 66, 67, 69, 70, 71, 72 -db 73, 74, 75, 76, 77, 78, 79, 81 -db 82, 83, 84, 85, 87, 88, 89, 90 -db 91, 92, 93, 123, 124, 125, 126, 127 -db 68, 87, 70, 65, 65, 65, 65, 68 -db 70, 70, 70, 74, 74, 74, 65, 65 -db 70, 65, 65, 81, 81, 81, 88, 88 -db 92, 81, 88, 81, 36, 81, 158, 36 -db 65, 74, 81, 88, 80, 80, 65, 81 +db 64, 65, 66, 67, 68, 69, 70, 71 +db 72, 73, 74, 75, 76, 77, 78, 79 +db 80, 81, 82, 83, 84, 85, 86, 87 +db 88, 89, 90, 91, 92, 93, 94, 95 +db 96, 65, 66, 67, 68, 69, 70, 71 +db 72, 73, 74, 75, 76, 77, 78, 79 +db 80, 81, 82, 83, 84, 85, 86, 87 +db 88, 89, 90, 123, 124, 125, 126, 127 +db 67, 85, 69, 65, 65, 65, 65, 67 +db 69, 69, 69, 73, 73, 73, 65, 65 +db 69, 65, 65, 79, 79, 79, 85, 85 +db 89, 79, 85, 36, 36, 36, 36, 36 +db 65, 73, 79, 85, 78, 78, 166, 167 db 63, 169, 170, 171, 172, 33, 34, 34 db 176, 177, 178, 179, 180, 65, 65, 65 db 184, 185, 186, 187, 188, 36, 36, 191 db 192, 193, 194, 195, 196, 197, 65, 65 db 200, 201, 202, 203, 204, 205, 206, 36 -db 69, 69, 70, 70, 70, 36, 74, 74 -db 74, 217, 218, 219, 220, 221, 74, 223 -db 81, 86, 81, 81, 81, 81, 230, 231 -db 232, 88, 88, 88, 92, 92, 238, 239 +db 68, 68, 69, 69, 69, 73, 73, 73 +db 73, 217, 218, 219, 220, 221, 73, 223 +db 79, 66, 79, 79, 79, 79, 230, 97 +db 97, 85, 85, 85, 89, 89, 238, 239 db 240, 241, 242, 243, 244, 245, 246, 247 db 248, 249, 250, 49, 51, 50, 254, 255 -de_collate_850 db 0FFh,"COLLATE" ; German CP850 - dw 256 ; From Steffen Kaiser's UNF package +pl_collate_858 db 0FFh,"COLLATE" ; Polish, CP858 + dw 256 db 0, 1, 2, 3, 4, 5, 6, 7 db 8, 9, 10, 11, 12, 13, 14, 15 db 16, 17, 18, 19, 20, 21, 22, 23 @@ -1041,21 +4048,21 @@ db 88, 89, 90, 123, 124, 125, 126, 127 db 67, 85, 69, 65, 65, 65, 65, 67 db 69, 69, 69, 73, 73, 73, 65, 65 db 69, 65, 65, 79, 79, 79, 85, 85 -db 89, 79, 85, 79, 36, 79, 158, 36 +db 89, 79, 85, 36, 36, 36, 36, 36 db 65, 73, 79, 85, 78, 78, 166, 167 db 63, 169, 170, 171, 172, 33, 34, 34 db 176, 177, 178, 179, 180, 65, 65, 65 db 184, 185, 186, 187, 188, 36, 36, 191 db 192, 193, 194, 195, 196, 197, 65, 65 db 200, 201, 202, 203, 204, 205, 206, 36 -db 68, 68, 69, 69, 69, 73, 73, 73 +db 68, 68, 69, 69, 69, 36, 73, 73 db 73, 217, 218, 219, 220, 221, 73, 223 -db 79, 83, 79, 79, 79, 79, 230, 232 -db 232, 85, 85, 85, 89, 89, 238, 239 +db 79, 66, 79, 79, 79, 79, 230, 97 +db 97, 85, 85, 85, 89, 89, 238, 239 db 240, 241, 242, 243, 244, 245, 246, 247 -db 248, 249, 250, 251, 252, 253, 254, 255 +db 248, 249, 250, 49, 51, 50, 254, 255 -de_collate_858 db 0FFh,"COLLATE" ; German CP858 +ru_collate_855 db 0FFh,"COLLATE" ; Russian, CP855 dw 256 db 0, 1, 2, 3, 4, 5, 6, 7 db 8, 9, 10, 11, 12, 13, 14, 15 @@ -1073,24 +4080,393 @@ db 96, 65, 66, 67, 68, 69, 70, 71 db 72, 73, 74, 75, 76, 77, 78, 79 db 80, 81, 82, 83, 84, 85, 86, 87 db 88, 89, 90, 123, 124, 125, 126, 127 -db 67, 85, 69, 65, 65, 65, 65, 67 -db 69, 69, 69, 73, 73, 73, 65, 65 -db 69, 65, 65, 79, 79, 79, 85, 85 -db 89, 79, 85, 79, 36, 79, 158, 36 -db 65, 73, 79, 85, 78, 78, 166, 167 +db 133, 133, 134, 134, 135, 135, 136, 136 +db 139, 139, 141, 141, 142, 142, 144, 144 +db 147, 147, 150, 150, 156, 156, 157, 157 +db 159, 159, 164, 164, 171, 171, 167, 167 +db 128, 128, 129, 129, 162, 162, 132, 132 +db 135, 135, 160, 160, 131, 131, 34, 34 +db 176, 177, 178, 179, 180, 161, 161, 140 +db 140, 185, 186, 187, 188, 143, 143, 191 +db 192, 193, 194, 195, 196, 197, 145, 145 +db 200, 201, 202, 203, 204, 205, 206, 36 +db 146, 146, 148, 148, 149, 149, 151, 151 +db 152, 217, 218, 219, 220, 152, 172, 223 +db 172, 153, 153, 154, 154, 155, 155, 158 +db 158, 137, 137, 130, 130, 169, 169, 239 +db 240, 168, 168, 138, 138, 165, 165, 170 +db 170, 166, 166, 163, 163, 253, 254, 255 + +ru_collate_872 equ ru_collate_855 ; Russian CP872 +ru_collate_850 equ en_collate_850 ; Russian CP850 +ru_collate_858 equ en_collate_858 ; Russian CP858 +ru_collate_437 equ en_collate_437 ; Russian CP437 + +bg_collate_855 equ ru_collate_855 ; Bulgarian, CP855 +bg_collate_872 equ ru_collate_872 ; Bulgarian, CP872 +bg_collate_850 equ en_collate_850 ; Bulgarian CP850 +bg_collate_858 equ en_collate_858 ; Bulgarian CP858 + +gr_collate_869 db 0FFh,"COLLATE" ; Greek, CP869 (with Euro) + dw 256 +db 0, 1, 2, 3, 4, 5, 6, 7 +db 8, 9, 10, 11, 12, 13, 14, 15 +db 16, 17, 18, 19, 20, 21, 22, 23 +db 24, 25, 26, 27, 28, 29, 30, 31 +db 32, 33, 34, 35, 36, 37, 38, 39 +db 40, 41, 42, 43, 44, 45, 46, 47 +db 48, 49, 50, 51, 52, 53, 54, 55 +db 56, 57, 58, 59, 60, 61, 62, 63 +db 64, 117, 118, 119, 120, 121, 122, 123 +db 124, 125, 126, 127, 128, 129, 130, 131 +db 132, 133, 134, 135, 136, 137, 138, 139 +db 140, 141, 142, 65, 66, 67, 68, 69 +db 70, 117, 118, 119, 120, 121, 122, 123 +db 124, 125, 126, 127, 128, 129, 130, 131 +db 132, 133, 134, 135, 136, 137, 138, 139 +db 140, 141, 142, 71, 72, 73, 74, 75 +db 76, 77, 78, 79, 80, 81, 89, 36 +db 88, 83, 84, 85, 86, 93, 87, 95 +db 97, 97, 103, 147, 148, 108, 108, 151 +db 112, 50, 51, 89, 36, 93, 95, 97 +db 97, 97, 103, 108, 89, 90, 91, 92 +db 93, 94, 95, 171, 96, 97, 174, 175 +db 176, 177, 178, 179, 180, 98, 99, 100 +db 101, 185, 186, 187, 188, 102, 103, 191 +db 192, 193, 194, 195, 196, 197, 104, 105 +db 200, 201, 202, 203, 204, 205, 206, 106 +db 107, 108, 109, 110, 111, 112, 89, 90 +db 91, 217, 218, 219, 220, 92, 93, 223 +db 94, 95, 96, 97, 98, 99, 100, 101 +db 102, 103, 104, 105, 106, 106, 107, 113 +db 240, 241, 108, 109, 110, 245, 111, 114 +db 115, 116, 112, 108, 108, 112, 254, 255 + +gr_collate_737 db 0FFh,"COLLATE" ; Greek, CP737 + dw 256 +db 0, 1, 2, 3, 4, 5, 6, 7 +db 8, 9, 10, 11, 12, 13, 14, 15 +db 16, 17, 18, 19, 20, 21, 22, 23 +db 24, 25, 26, 27, 28, 29, 30, 31 +db 32, 33, 34, 35, 36, 37, 38, 39 +db 40, 41, 42, 43, 44, 45, 46, 47 +db 48, 49, 50, 51, 52, 53, 54, 55 +db 56, 57, 58, 59, 60, 61, 62, 63 +db 64, 100, 101, 102, 103, 104, 105, 106 +db 107, 108, 109, 110, 111, 112, 113, 114 +db 115, 116, 117, 118, 119, 120, 121, 122 +db 123, 124, 125, 65, 66, 67, 68, 69 +db 70, 100, 101, 102, 103, 104, 105, 106 +db 107, 108, 109, 110, 111, 112, 113, 114 +db 115, 116, 117, 118, 119, 120, 121, 122 +db 123, 124, 125, 71, 72, 73, 74, 75 +db 76, 77, 78, 79, 80, 81, 82, 83 +db 84, 85, 86, 87, 88, 89, 90, 91 +db 92, 93, 94, 95, 96, 97, 98, 99 +db 76, 77, 78, 79, 80, 81, 82, 83 +db 84, 85, 86, 87, 88, 89, 90, 91 +db 92, 93, 93, 94, 95, 96, 97, 98 +db 176, 177, 178, 179, 180, 181, 182, 183 +db 184, 185, 186, 187, 188, 189, 190, 191 +db 192, 193, 194, 195, 196, 197, 198, 199 +db 200, 201, 202, 203, 204, 205, 206, 207 +db 208, 209, 210, 211, 212, 213, 214, 215 +db 216, 217, 218, 219, 220, 221, 222, 223 +db 99, 76, 80, 82, 84, 84, 90, 95 +db 95, 99, 76, 80, 82, 84, 90, 95 +db 99, 241, 242, 243, 84, 95, 246, 247 +db 248, 249, 250, 251, 252, 253, 254, 255 + +gr_collate_850 equ pl_collate_850 ; Polish, CP850 +gr_collate_858 equ pl_collate_858 ; Polish, CP858 + +hu_collate_852 equ ru_collate_852 ; Hungarian, CP852 +hu_collate_850 equ pl_collate_850 ; Hungarian, CP850 +hu_collate_858 equ gr_collate_858 ; Hungarian, CP858 + +sh_collate_852 equ ru_collate_852 ; Serbo-Croatian, CP852 +sh_collate_855 equ ru_collate_855 ; Serbo-Croatian, CP855 +sh_collate_872 equ ru_collate_872 ; Serbo-Croatian, CP872 +sh_collate_850 equ pl_collate_850 ; Serbo-Croatian, CP850 +sh_collate_858 equ gr_collate_858 ; Serbo-Croatian, CP858 + +ro_collate_852 equ ru_collate_852 ; Romanian, CP852 +ro_collate_850 equ pl_collate_850 ; Romanian, CP850 +ro_collate_858 equ gr_collate_858 ; Romanian, CP858 + +ch_collate_850 equ en_collate_850 ; Switzerland, CP850 +ch_collate_858 equ en_collate_858 ; Switzerland, CP858 +ch_collate_437 equ en_collate_437 ; Switzerland, CP437 + +cz_collate_852 equ ru_collate_852 ; Czech, CP852 +cz_collate_850 equ pl_collate_850 ; Czech, CP850 +cz_collate_858 equ gr_collate_858 ; Czech, CP858 + +se_collate_850 db 0FFh,"COLLATE" ; Swedish, CP850 + dw 256 +db 0, 1, 2, 3, 4, 5, 6, 7 +db 8, 9, 10, 11, 12, 13, 14, 15 +db 16, 17, 18, 19, 20, 21, 22, 23 +db 24, 25, 26, 27, 28, 29, 30, 31 +db 32, 33, 34, 35, 36, 37, 38, 39 +db 40, 41, 42, 43, 44, 45, 46, 47 +db 48, 49, 50, 51, 52, 53, 54, 55 +db 56, 57, 58, 59, 60, 61, 62, 63 +db 64, 65, 66, 67, 68, 69, 70, 71 +db 72, 73, 74, 75, 76, 77, 78, 79 +db 80, 81, 82, 83, 84, 85, 86, 86 +db 87, 88, 89, 93, 94, 95, 96, 97 +db 98, 65, 66, 67, 68, 69, 70, 71 +db 72, 73, 74, 75, 76, 77, 78, 79 +db 80, 81, 82, 83, 84, 85, 86, 86 +db 87, 88, 89, 123, 124, 125, 126, 127 +db 67, 88, 69, 65, 91, 65, 90, 67 +db 69, 69, 69, 73, 73, 73, 91, 90 +db 69, 65, 65, 79, 92, 79, 85, 85 +db 88, 92, 88, 79, 36, 79, 36, 36 +db 65, 73, 79, 85, 78, 78, 65, 79 db 63, 169, 170, 171, 172, 33, 34, 34 db 176, 177, 178, 179, 180, 65, 65, 65 -db 184, 185, 186, 187, 188, 36, 36, 191 +db 169, 185, 186, 187, 188, 36, 36, 191 db 192, 193, 194, 195, 196, 197, 65, 65 db 200, 201, 202, 203, 204, 205, 206, 36 -db 68, 68, 69, 69, 69, 36, 73, 73 +db 68, 68, 69, 69, 69, 73, 73, 73 db 73, 217, 218, 219, 220, 221, 73, 223 -db 79, 83, 79, 79, 79, 79, 230, 232 -db 232, 85, 85, 85, 89, 89, 238, 239 +db 79, 83, 79, 79, 79, 79, 230, 231 +db 232, 85, 85, 85, 88, 88, 238, 239 +db 240, 241, 242, 243, 244, 245, 246, 247 +db 248, 249, 250, 49, 51, 50, 254, 255 + +se_collate_858 db 0FFh,"COLLATE" ; Swedish, CP858 + dw 256 +db 0, 1, 2, 3, 4, 5, 6, 7 +db 8, 9, 10, 11, 12, 13, 14, 15 +db 16, 17, 18, 19, 20, 21, 22, 23 +db 24, 25, 26, 27, 28, 29, 30, 31 +db 32, 33, 34, 35, 36, 37, 38, 39 +db 40, 41, 42, 43, 44, 45, 46, 47 +db 48, 49, 50, 51, 52, 53, 54, 55 +db 56, 57, 58, 59, 60, 61, 62, 63 +db 64, 65, 66, 67, 68, 69, 70, 71 +db 72, 73, 74, 75, 76, 77, 78, 79 +db 80, 81, 82, 83, 84, 85, 86, 86 +db 87, 88, 89, 93, 94, 95, 96, 97 +db 98, 65, 66, 67, 68, 69, 70, 71 +db 72, 73, 74, 75, 76, 77, 78, 79 +db 80, 81, 82, 83, 84, 85, 86, 86 +db 87, 88, 89, 123, 124, 125, 126, 127 +db 67, 88, 69, 65, 91, 65, 90, 67 +db 69, 69, 69, 73, 73, 73, 91, 90 +db 69, 65, 65, 79, 92, 79, 85, 85 +db 88, 92, 88, 79, 36, 79, 36, 36 +db 65, 73, 79, 85, 78, 78, 65, 79 +db 63, 169, 170, 171, 172, 33, 34, 34 +db 176, 177, 178, 179, 180, 65, 65, 65 +db 169, 185, 186, 187, 188, 36, 36, 191 +db 192, 193, 194, 195, 196, 197, 65, 65 +db 200, 201, 202, 203, 204, 205, 206, 36 +db 68, 68, 69, 69, 69, 36, 73, 73 +db 73, 217, 218, 219, 220, 221, 73, 223 +db 79, 83, 79, 79, 79, 79, 230, 231 +db 232, 85, 85, 85, 88, 88, 238, 239 +db 240, 241, 242, 243, 244, 245, 246, 247 +db 248, 249, 250, 49, 51, 50, 254, 255 + +se_collate_437 db 0FFh,"COLLATE" ; Swedish, CP437 + dw 256 +db 0, 1, 2, 3, 4, 5, 6, 7 +db 8, 9, 10, 11, 12, 13, 14, 15 +db 16, 17, 18, 19, 20, 21, 22, 23 +db 24, 25, 26, 27, 28, 29, 30, 31 +db 32, 33, 34, 35, 36, 37, 38, 39 +db 40, 41, 42, 43, 44, 45, 46, 47 +db 48, 49, 50, 51, 52, 53, 54, 55 +db 56, 57, 58, 59, 60, 61, 62, 63 +db 64, 65, 66, 67, 68, 69, 70, 71 +db 72, 73, 74, 75, 76, 77, 78, 79 +db 80, 81, 82, 83, 84, 85, 86, 86 +db 87, 88, 89, 93, 94, 95, 96, 97 +db 98, 65, 66, 67, 68, 69, 70, 71 +db 72, 73, 74, 75, 76, 77, 78, 79 +db 80, 81, 82, 83, 84, 85, 86, 86 +db 87, 88, 89, 123, 124, 125, 126, 127 +db 67, 88, 69, 65, 91, 65, 90, 67 +db 69, 69, 69, 73, 73, 73, 91, 90 +db 69, 65, 65, 79, 92, 79, 85, 85 +db 88, 92, 88, 36, 36, 36, 36, 36 +db 65, 73, 79, 85, 78, 78, 65, 79 +db 63, 169, 170, 171, 172, 33, 34, 34 +db 176, 177, 178, 179, 180, 181, 182, 183 +db 184, 185, 186, 187, 188, 189, 190, 191 +db 192, 193, 194, 195, 196, 197, 198, 199 +db 200, 201, 202, 203, 204, 205, 206, 207 +db 208, 209, 210, 211, 212, 213, 214, 215 +db 216, 217, 218, 219, 220, 221, 222, 223 +db 224, 83, 226, 227, 228, 229, 230, 231 +db 232, 233, 234, 235, 236, 237, 238, 239 +db 240, 241, 242, 243, 244, 245, 246, 247 +db 248, 249, 250, 251, 78, 50, 254, 255 + +fi_collate_850 equ se_collate_850 ; Finnish, CP850 +fi_collate_858 equ se_collate_858 ; Finnish, CP858 +fi_collate_437 equ se_collate_437 ; Finnish, CP437 + +jp_collate_932 db 0FFh,"COLLATE" ; Japanese, CP932 + dw 256 +db 0, 1, 2, 3, 4, 5, 6, 7 +db 8, 9, 10, 11, 12, 13, 14, 15 +db 16, 17, 18, 19, 20, 21, 22, 23 +db 24, 25, 26, 27, 28, 29, 30, 31 +db 32, 33, 34, 35, 36, 37, 38, 39 +db 40, 41, 42, 43, 44, 45, 46, 47 +db 48, 49, 50, 51, 52, 53, 54, 55 +db 56, 57, 58, 59, 60, 61, 62, 63 +db 64, 65, 66, 67, 68, 69, 70, 71 +db 72, 73, 74, 75, 76, 77, 78, 79 +db 80, 81, 82, 83, 84, 85, 86, 87 +db 88, 89, 90, 91, 36, 93, 94, 95 +db 96, 65, 66, 67, 68, 69, 70, 71 +db 72, 73, 74, 75, 76, 77, 78, 79 +db 80, 81, 82, 83, 84, 85, 86, 87 +db 88, 89, 90, 123, 124, 125, 126, 127 +db 128, 183, 184, 185, 186, 187, 188, 189 +db 190, 191, 192, 193, 194, 195, 196, 197 +db 198, 199, 200, 201, 202, 203, 204, 205 +db 206, 207, 208, 209, 210, 211, 212, 213 +db 129, 130, 131, 132, 133, 136, 182, 138 +db 139, 140, 141, 142, 173, 174, 175, 155 +db 137, 138, 139, 140, 141, 142, 143, 144 +db 145, 146, 147, 148, 149, 150, 151, 152 +db 153, 154, 155, 156, 157, 158, 159, 160 +db 161, 162, 163, 164, 165, 166, 167, 168 +db 168, 170, 171, 172, 173, 174, 175, 176 +db 177, 178, 179, 180, 181, 182, 134, 135 +db 224, 225, 226, 227, 228, 229, 230, 231 +db 232, 233, 234, 235, 236, 237, 238, 239 +db 240, 241, 242, 243, 244, 245, 246, 247 +db 248, 249, 250, 251, 252, 253, 254, 255 + +kr_collate_934 db 0FFh,"COLLATE" ; Korean, CP934 + dw 256 +db 0, 1, 2, 3, 4, 5, 6, 7 +db 8, 9, 10, 11, 12, 13, 14, 15 +db 16, 17, 18, 19, 20, 21, 22, 23 +db 24, 25, 26, 27, 28, 29, 30, 31 +db 32, 33, 34, 35, 36, 37, 38, 39 +db 40, 41, 42, 43, 44, 45, 46, 47 +db 48, 49, 50, 51, 52, 53, 54, 55 +db 56, 57, 58, 59, 60, 61, 62, 63 +db 64, 65, 66, 67, 68, 69, 70, 71 +db 72, 73, 74, 75, 76, 77, 78, 79 +db 80, 81, 82, 83, 84, 85, 86, 87 +db 88, 89, 90, 91, 36, 93, 94, 95 +db 96, 65, 66, 67, 68, 69, 70, 71 +db 72, 73, 74, 75, 76, 77, 78, 79 +db 80, 81, 82, 83, 84, 85, 86, 87 +db 88, 89, 90, 123, 124, 125, 126, 127 +db 128, 181, 182, 183, 184, 185, 186, 187 +db 188, 189, 190, 191, 192, 193, 194, 195 +db 196, 197, 198, 199, 200, 201, 202, 203 +db 204, 205, 206, 207, 208, 209, 210, 211 +db 212, 213, 214, 215, 216, 217, 218, 219 +db 220, 221, 222, 223, 224, 225, 226, 227 +db 228, 229, 230, 231, 232, 233, 234, 235 +db 236, 237, 238, 239, 240, 241, 242, 243 +db 129, 130, 131, 172, 132, 173, 174, 133 +db 134, 135, 175, 176, 177, 178, 179, 180 +db 149, 136, 137, 138, 150, 139, 140, 141 +db 142, 143, 144, 145, 146, 147, 148, 244 +db 245, 246, 151, 152, 153, 154, 155, 156 +db 247, 248, 157, 158, 159, 160, 161, 162 +db 249, 250, 163, 164, 165, 166, 167, 168 +db 251, 252, 169, 170, 171, 253, 254, 255 + +cn_collate_936 db 0FFh,"COLLATE" ; Chinese, CP936 + dw 256 +db 0, 1, 2, 3, 4, 5, 6, 7 +db 8, 9, 10, 11, 12, 13, 14, 15 +db 16, 17, 18, 19, 20, 21, 22, 23 +db 24, 25, 26, 27, 28, 29, 30, 31 +db 32, 33, 34, 35, 36, 37, 38, 39 +db 40, 41, 42, 43, 44, 45, 46, 47 +db 48, 49, 50, 51, 52, 53, 54, 55 +db 56, 57, 58, 59, 60, 61, 62, 63 +db 64, 65, 66, 67, 68, 69, 70, 71 +db 72, 73, 74, 75, 76, 77, 78, 79 +db 80, 81, 82, 83, 84, 85, 86, 87 +db 88, 89, 90, 91, 36, 93, 94, 95 +db 96, 65, 66, 67, 68, 69, 70, 71 +db 72, 73, 74, 75, 76, 77, 78, 79 +db 80, 81, 82, 83, 84, 85, 86, 87 +db 88, 89, 90, 123, 124, 125, 126, 127 +db 36, 129, 130, 131, 132, 133, 134, 135 +db 136, 137, 138, 139, 140, 141, 142, 143 +db 144, 145, 146, 147, 148, 149, 150, 151 +db 152, 153, 154, 155, 156, 157, 158, 159 +db 160, 161, 162, 163, 164, 165, 166, 167 +db 168, 169, 170, 171, 172, 173, 174, 175 +db 176, 177, 178, 179, 180, 181, 182, 183 +db 184, 185, 186, 187, 188, 189, 190, 191 +db 192, 193, 194, 195, 196, 197, 198, 199 +db 200, 201, 202, 203, 204, 205, 206, 207 +db 208, 209, 210, 211, 212, 213, 214, 215 +db 216, 217, 218, 219, 220, 221, 222, 223 +db 224, 225, 226, 227, 228, 229, 230, 231 +db 232, 233, 234, 235, 236, 237, 238, 239 db 240, 241, 242, 243, 244, 245, 246, 247 db 248, 249, 250, 251, 252, 253, 254, 255 -de_collate_437 db 0FFh,"COLLATE" ; German CP437 +ua_collate_848 db 0FFh,"COLLATE" ; Ukrainian, CP848 + dw 256 +db 0, 1, 2, 3, 4, 5, 6, 7 +db 8, 9, 10, 11, 12, 13, 14, 15 +db 16, 17, 18, 19, 20, 21, 22, 23 +db 24, 25, 26, 27, 28, 29, 30, 31 +db 32, 33, 34, 35, 36, 37, 38, 39 +db 40, 41, 42, 43, 44, 45, 46, 47 +db 48, 49, 50, 51, 52, 53, 54, 55 +db 56, 57, 58, 59, 60, 61, 62, 63 +db 64, 65, 66, 67, 68, 69, 70, 71 +db 72, 73, 74, 75, 76, 77, 78, 79 +db 80, 81, 82, 83, 84, 85, 86, 87 +db 88, 89, 90, 91, 92, 93, 94, 95 +db 96, 65, 66, 67, 68, 69, 70, 71 +db 72, 73, 74, 75, 76, 77, 78, 79 +db 80, 81, 82, 83, 84, 85, 86, 87 +db 88, 89, 90, 123, 124, 125, 126, 127 +db 128, 129, 130, 131, 133, 135, 137, 138 +db 140, 143, 145, 146, 148, 149, 151, 152 +db 153, 154, 155, 158, 160, 161, 162, 163 +db 165, 166, 167, 168, 169, 170, 171, 172 +db 128, 129, 130, 131, 133, 135, 137, 138 +db 140, 143, 145, 146, 148, 149, 151, 152 +db 176, 177, 178, 179, 180, 181, 182, 183 +db 184, 185, 186, 187, 188, 189, 190, 191 +db 192, 193, 194, 195, 196, 197, 198, 199 +db 200, 201, 201, 203, 204, 205, 206, 207 +db 208, 209, 210, 211, 212, 213, 214, 215 +db 216, 217, 218, 219, 220, 221, 222, 223 +db 153, 154, 155, 158, 160, 161, 162, 163 +db 165, 166, 167, 168, 169, 170, 171, 172 +db 135, 135, 132, 132, 136, 136, 141, 141 +db 142, 142, 250, 251, 252, 36, 254, 255 + +ua_collate_1125 equ ua_collate_848 ; Ukrainian, CP1125 + +hr_collate_852 equ ru_collate_852 ; Croatian, CP852 +hr_collate_850 equ pl_collate_850 ; Croatian, CP850 +hr_collate_858 equ gr_collate_858 ; Croatian, CP858 + +si_collate_852 equ ru_collate_852 ; Slovenian, CP852 +si_collate_850 equ pl_collate_850 ; Slovenian, CP850 +si_collate_858 equ gr_collate_858 ; Slovenian, CP858 + +mk_collate_855 equ ru_collate_855 ; Macedonian, CP855 +mk_collate_872 equ ru_collate_872 ; Macedonian, CP872 +mk_collate_850 equ pl_collate_850 ; Macedonian, CP850 +mk_collate_858 equ gr_collate_858 ; Macedonian, CP858 + +il_collate_862 db 0FFh,"COLLATE" ; Hebrew, CP862 dw 256 db 0, 1, 2, 3, 4, 5, 6, 7 db 8, 9, 10, 11, 12, 13, 14, 15 @@ -1108,10 +4484,10 @@ db 96, 65, 66, 67, 68, 69, 70, 71 db 72, 73, 74, 75, 76, 77, 78, 79 db 80, 81, 82, 83, 84, 85, 86, 87 db 88, 89, 90, 123, 124, 125, 126, 127 -db 67, 85, 69, 65, 65, 65, 65, 67 -db 69, 69, 69, 73, 73, 73, 65, 65 -db 69, 65, 65, 79, 79, 79, 85, 85 -db 89, 79, 85, 36, 36, 36, 36, 36 +db 128, 129, 130, 131, 132, 133, 134, 135 +db 136, 137, 138, 138, 139, 140, 140, 141 +db 141, 142, 143, 144, 144, 145, 145, 146 +db 147, 148, 149, 36, 36, 36, 36, 36 db 65, 73, 79, 85, 78, 78, 166, 167 db 63, 169, 170, 171, 172, 33, 34, 34 db 176, 177, 178, 179, 180, 181, 182, 183 @@ -1125,6 +4501,47 @@ db 232, 233, 234, 235, 236, 237, 238, 239 db 240, 241, 242, 243, 244, 245, 246, 247 db 248, 249, 250, 251, 252, 253, 254, 255 +il_collate_850 equ en_collate_850 +il_collate_858 equ en_collate_858 + +me_collate_864 db 0FFh,"COLLATE" ; Arabic, CP864 + dw 256 +db 0, 1, 2, 3, 4, 5, 6, 7 +db 8, 9, 10, 11, 12, 13, 14, 15 +db 16, 17, 18, 19, 20, 21, 22, 23 +db 24, 25, 26, 27, 28, 29, 30, 31 +db 32, 33, 34, 35, 36, 37, 38, 39 +db 40, 41, 42, 43, 44, 45, 46, 47 +db 48, 49, 50, 51, 52, 53, 54, 55 +db 56, 57, 58, 59, 60, 61, 62, 63 +db 64, 65, 66, 67, 68, 69, 70, 71 +db 72, 73, 74, 75, 76, 77, 78, 79 +db 80, 81, 82, 83, 84, 85, 86, 87 +db 88, 89, 90, 91, 92, 93, 94, 95 +db 96, 65, 66, 67, 68, 69, 70, 71 +db 72, 73, 74, 75, 76, 77, 78, 79 +db 80, 81, 82, 83, 84, 85, 86, 87 +db 88, 89, 90, 123, 124, 125, 126, 127 +db 128, 129, 130, 131, 132, 133, 134, 135 +db 136, 137, 138, 139, 140, 141, 142, 143 +db 144, 145, 146, 147, 148, 149, 150, 151 +db 152, 202, 202, 153, 154, 202, 202, 155 +db 156, 157, 175, 36, 36, 176, 158, 159 +db 179, 180, 182, 183, 160, 184, 185, 186 +db 164, 165, 166, 167, 168, 169, 170, 171 +db 172, 173, 199, 161, 191, 192, 193, 162 +db 36, 174, 175, 176, 177, 197, 178, 179 +db 180, 181, 182, 183, 184, 185, 186, 187 +db 188, 189, 190, 191, 192, 193, 194, 195 +db 196, 197, 198, 219, 220, 221, 222, 197 +db 163, 167, 200, 201, 202, 203, 204, 205 +db 206, 207, 208, 194, 197, 198, 198, 203 +db 209, 209, 204, 205, 205, 207, 208, 198 +db 200, 202, 202, 202, 201, 208, 254, 255 + +me_collate_850 equ en_collate_850 +me_collate_858 equ en_collate_858 + ; Dual Byte Character Sets ; lead-byte ranges ;------------------------------------------------------------------------------ @@ -1132,6 +4549,26 @@ dbcs_empty db 0FFh,"DBCS " dw 0 ; Table length db 0, 0 ; Table terminator (even if length == 0) +; Japan, CP932 +; Source: http://www.microsoft.com/globaldev/reference/dbcs/932.htm +jp_dbcs_932 db 0FFh,"DBCS " + dw 6 + db 081h, 09Fh + db 0E0h, 0FCh + db 000h, 000h + +; Korean, CP934 +kr_dbcs_934 db 0FFh,"DBCS " + dw 4 + db 081h, 0BFh + db 000h, 000h + +; Chinese, CP936 +cn_dbcs_936 db 0FFh,"DBCS " + dw 4 + db 081h, 0FCh + db 000h, 000h + ; Yes/No table ; yes_l : Character (single byte) or leadbyte (DBCS) for YES ; yes_h : trailbyte for YES @@ -1150,4 +4587,131 @@ en_yn db 0FFh,"YESNO " dw 4 db 'Y',0,'N',0 ; English +fr_yn db 0FFh,"YESNO " + dw 4 + db 'O',0,'N',0 ; French + +pt_yn equ es_yn ; Portuguese + +fi_yn db 0FFh,"YESNO " + dw 4 + db 'K',0,'E',0 ; Finnish + + +it_yn equ es_yn ; Italian + +gr_yn db 0FFh,"YESNO " + dw 4 + db 'N',0,'O',0 ; Greek, latin alphabet + +gr_yn_869 db 0FFh,"YESNO " + dw 4 + db 0B8h,0,0BEh,0 ; Greek, codepage 869 + +gr_yn_737 db 0FFh,"YESNO " + dw 4 + db 8Ch,0,8Eh,0 ; Greek, codepage 737 + +nl_yn equ de_yn ; Dutch + +tr_yn db 0FFh,"YESNO " + dw 4 + db 'E',0,'H',0 ; Turkish + +ru_yn_866 db 0FFh,"YESNO " + dw 4 + db 84h,0,8Dh,0 ; Russian CP866 + +ru_yn_808 equ ru_yn_866 + +ru_yn_855 db 0FFh,"YESNO " + dw 4 + db 0A7h,0,0D5h,0 ; Russian CP855 + +ru_yn_872 equ ru_yn_855 + +ru_yn db 0FFh,"YESNO " + dw 4 + db 'D',0,'N',0 ; Russian Latin + +ua_yn_848 equ ru_yn_866 ; Ukrainian +ua_yn_1125 equ ru_yn_866 + +bg_yn_855 equ ru_yn_855 ; Bulgarian CP855 +bg_yn_872 equ ru_yn_872 ; Bulgarian CP872 +bg_yn equ ru_yn ; Bulgarian Latin + +hu_yn db 0FFh,"YESNO " + dw 4 + db 'I',0,'N',0 ; Hungarian + + +sh_yn_855 equ ru_yn_855 ; Serbo-Croatian CP855 +sh_yn_872 equ ru_yn_872 ; Serbo-Croatian CP872 +sh_yn equ ru_yn ; Serbo-Croatian, latin alphabet + +hr_yn equ ru_yn ; Croatian, latin alphabet + +mk_yn_855 equ ru_yn_855 ; Macedonian CP855 +mk_yn_872 equ ru_yn_872 ; Macedonian CP872 +mk_yn equ ru_yn ; Macedonian latin alphabet + +ro_yn equ ru_yn ; Romanian + +cz_yn db 0FFh,"YESNO " + dw 4 + db 'A','0','N',0 ; Czech + +pl_yn db 0FFh,"YESNO " + dw 4 + db 'T','0','N',0 ; Polish + +dk_yn equ de_yn ; Danish + +se_yn equ de_yn ; Swedish + +no_yn equ de_yn ; Norwegian + +si_yn equ ru_yn ; Slovenian + +kr_yn db 0FFh,"YESNO " + dw 4 + db 'Y','0','A',0 ; Korean, latin alphabet (Yeh, Anio) + +kr_yn_934 db 0FFh,"YESNO " + dw 4 + db 0BFh,0B9h,0BEh,0C6h ; Korean, CP934 (Hangul syllables "Ye" and "A") + +cn_yn db 0FFh,"YESNO " + dw 4 + db 'S','0','B',0 ; Chinese (Mandrin), latin alphabet (Shi, Bushi) + +cn_yn_936 db 0FFh,"YESNO " + dw 4 + db 0CAh,0C7h,0B2h,0BBh; Chinese (Mandrin), CP936 + +il_yn db 0FFh,"YESNO " + dw 4 + db 'K','0','L',0 ; Hebrew, latin alphabet (Ken, Lo) + +il_yn_862 db 0FFh,"YESNO " + dw 4 + db 8Bh,'0',8Ch,0 ; Hebrew, CP862 + +me_yn db 0FFh,"YESNO " + dw 4 + db 'N','0','L',0 ; Arabic, latin alphabet (Nam, La) + +me_yn_864 db 0FFh,"YESNO " + dw 4 + db 0F2h,'0',9Dh,0 ; Arabic, CP864 + +ca_yn equ es_yn ; Catalan + +gl_yn equ es_yn ; Gallegan + +eu_yn db 0FFh,"YESNO " + dw 4 + db 'B','0','E',0 ; Basque + db "FreeDOS" ; Trailing - as recommended by the Ralf Brown Interrupt List From b7a86735a25c93e89d8d166b950ddfa71589fb75 Mon Sep 17 00:00:00 2001 From: Luchezar Georgiev Date: Wed, 17 Nov 2004 18:01:54 +0000 Subject: [PATCH 582/671] Bart enhanced EXEFLAT for smaller packed binary; now calls UPX itself git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/branches/UNSTABLE@1063 6ac86273-5f31-0410-b378-82cca8765d1b --- docs/history.txt | 2 + kernel/makefile | 1 - sys/sys.c | 4 +- utils/exeflat.c | 414 ++++++++++++++++++++++++++++++----------------- 4 files changed, 267 insertions(+), 154 deletions(-) diff --git a/docs/history.txt b/docs/history.txt index d817c004..77a60ba1 100644 --- a/docs/history.txt +++ b/docs/history.txt @@ -3,6 +3,8 @@ + Changes Bart * int2f.asm - bugfix: call_nls: DI register was not preserved + * exeflat.c + - new version exploiting better UPX compression for SYS files; calls UPX itself + Changes Tom * inthndlr.c - improve handling of case where eg. FindFirst(I:\*.*) fails, causes Int24, diff --git a/kernel/makefile b/kernel/makefile index db79239a..b1947683 100644 --- a/kernel/makefile +++ b/kernel/makefile @@ -31,7 +31,6 @@ all: ..\bin\$(TARGET).sys ..\bin\country.sys ..\bin\$(TARGET).sys: $(TARGET).lnk $(OBJS) $(LIBS) ..\utils\exeflat.exe $(LINK) @$(TARGET).lnk; - $(XUPX) kernel.exe ..\utils\exeflat kernel.exe $*.sys $(LOADSEG) -S0x10 -S0x8B $(UPXOPT) copy $*.sys ..\bin\kernel.sys diff --git a/sys/sys.c b/sys/sys.c index 1afb43d4..bb7f6669 100644 --- a/sys/sys.c +++ b/sys/sys.c @@ -279,7 +279,7 @@ int FDKrnConfigMain(int argc, char **argv); #define OEMKERNEL "IBMBIO.COM" #define OEMDOS "IBMDOS.COM" #define MSKERNEL "IO.SYS" -#define MSDOS "MSDOS.SYS" +#define MS_DOS "MSDOS.SYS" #define FDLOADSEG 0x60 #define OEMLOADSEG 0x70 @@ -523,7 +523,7 @@ int main(int argc, char **argv) { char *dosfn = OEMDOS; #ifdef WITHOEMCOMPATBS - if (altkern == MS_OEMKERN) dosfn = MSDOS; + if (altkern == MS_OEMKERN) dosfn = MS_DOS; #endif if ( (!get_full_path(srcPath, rootPath, dosfn, srcFile)) || diff --git a/utils/exeflat.c b/utils/exeflat.c index a24b23ec..2c6ddf82 100644 --- a/utils/exeflat.c +++ b/utils/exeflat.c @@ -52,11 +52,13 @@ large portions copied from task.c #define BUFSIZE 32768u +#define KERNEL_START 0x10 /* the kernel code really starts here at 60:10 */ + typedef struct { UWORD off, seg; } farptr; -int compReloc(const void *p1, const void *p2) +static int compReloc(const void *p1, const void *p2) { farptr *r1 = (farptr *) p1; farptr *r2 = (farptr *) p2; @@ -71,7 +73,7 @@ int compReloc(const void *p1, const void *p2) return 0; } -void usage(void) +static void usage(void) { printf("usage: exeflat (src.exe) (dest.sys) (relocation-factor)\n"); printf @@ -80,9 +82,11 @@ void usage(void) exit(1); } -int main(int argc, char **argv) +static exe_header header; + +int exeflat(int UPX, const char *srcfile, const char *dstfile, + const char *start, short *silentSegments, short silentcount) { - exe_header header; int i, j; size_t bufsize; farptr *reloc; @@ -91,69 +95,32 @@ int main(int argc, char **argv) UBYTE **buffers; UBYTE **curbuf; FILE *src, *dest; - short silentSegments[20], silentcount = 0, silentdone = 0; - int UPX = FALSE; + short silentdone = 0; + int compress_sys_file; - /* if no arguments provided, show usage and exit */ - if (argc < 4) usage(); - - /* do optional argument processing here */ - for (i = 4; i < argc; i++) + if ((src = fopen(srcfile, "rb")) == NULL) { - char *argptr = argv[i]; - - if (argptr[0] != '-' && argptr[0] != '/') - usage(); - - argptr++; - - switch (toupper(argptr[0])) - { - case 'U': - UPX = TRUE; - break; - case 'S': - if (silentcount >= LENGTH(silentSegments)) - { - printf("can't handle more then %d silent's\n", - LENGTH(silentSegments)); - exit(1); - } - - silentSegments[silentcount++] = (short)strtol(argptr + 1, NULL, 0); - break; - - default: - usage(); - } - } - - /* arguments left : - infile outfile relocation offset */ - - if ((src = fopen(argv[1], "rb")) == NULL) - { - printf("Source file %s could not be opened\n", argv[1]); - return 1; + printf("Source file %s could not be opened\n", srcfile); + exit(1); } if (fread(&header, sizeof(header), 1, src) != 1) { - printf("Error reading header from %s\n", argv[1]); + printf("Error reading header from %s\n", srcfile); fclose(src); - return 1; + exit(1); } if (header.exSignature != MAGIC) { - printf("Source file %s is not a valid .EXE\n", argv[1]); + printf("Source file %s is not a valid .EXE\n", srcfile); fclose(src); - return 1; + exit(1); } - if ((dest = fopen(argv[2], "wb+")) == NULL) + if ((dest = fopen(dstfile, "wb+")) == NULL) { - printf("Destination file %s could not be created\n", argv[2]); - return 1; + printf("Destination file %s could not be created\n", dstfile); + exit(1); } - start_seg = (UWORD)strtol(argv[3], NULL, 0); + start_seg = (UWORD)strtol(start, NULL, 0); if (header.exExtraBytes == 0) header.exExtraBytes = 0x200; printf("header len = %lu = 0x%lx\n", header.exHeaderSize * 16UL, @@ -171,7 +138,7 @@ int main(int argc, char **argv) if (buffers == NULL) { printf("Allocation error\n"); - return 1; + exit(1); } bufsize = BUFSIZE; for (to_xfer = size, curbuf = buffers; to_xfer > 0; @@ -183,12 +150,12 @@ int main(int argc, char **argv) if (*curbuf == NULL) { printf("Allocation error\n"); - return 1; + exit(1); } if (fread(*curbuf, sizeof(char), bufsize, src) != bufsize) { printf("Source file read error %ld %d\n", to_xfer, bufsize); - return 1; + exit(1); } } if (header.exRelocTable && header.exRelocItems) @@ -198,74 +165,57 @@ int main(int argc, char **argv) if (reloc == NULL) { printf("Allocation error\n"); - return 1; + exit(1); } if (fread(reloc, sizeof(farptr), header.exRelocItems, src) != - header.exRelocItems) + header.exRelocItems) { printf("Source file read error\n"); - return 1; - } - fclose(src); - qsort(reloc, header.exRelocItems, sizeof(reloc[0]), compReloc); - for (i = 0; i < header.exRelocItems; i++) - { - ULONG spot = ((ULONG) reloc[i].seg << 4) + reloc[i].off; - UBYTE *spot0 = &buffers[(size_t)(spot / BUFSIZE)][(size_t)(spot % BUFSIZE)]; - UBYTE *spot1 = &buffers[(size_t)((spot + 1) / BUFSIZE)][(size_t)((spot + 1) % BUFSIZE)]; - UWORD segment = ((UWORD) * spot1 << 8) + *spot0; - - for (j = 0; j < silentcount; j++) - if (segment == silentSegments[j]) - { - silentdone++; - goto dontPrint; - } - - printf("relocation at 0x%04x:0x%04x ->%04x\n", reloc[i].seg, - reloc[i].off, segment); - - dontPrint: - - segment += start_seg; - *spot0 = segment & 0xff; - *spot1 = segment >> 8; + exit(1); } } - - if (UPX) + fclose(src); + qsort(reloc, header.exRelocItems, sizeof(reloc[0]), compReloc); + for (i = 0; i < header.exRelocItems; i++) { - /* UPX HEADER jump $+2+size */ - static char JumpBehindCode[] = { - /* kernel config header - 32 bytes */ - 0xeb, 0x1b, /* jmp short realentry */ - 'C', 'O', 'N', 'F', 'I', 'G', 32 - 2 - 6 - 2 - 3, 0, /* WORD */ - 0, /* DLASortByDriveNo db 0 */ - 1, /* InitDiskShowDriveAssignment db 1 */ - 2, /* SkipConfigSeconds db 2 */ - 0, /* ForceLBA db 0 */ - 1, /* GlobalEnableLBAsupport db 1 */ - 0, /* BootHarddiskSeconds */ - - 'n', 'u', 's', 'e', 'd', /* unused filler bytes */ - 8, 7, 6, 5, 4, 3, 2, 1, - /* real-entry: jump over the 'real' image do the trailer */ - 0xe9, 0, 0 /* 100: jmp 103 */ - }; + ULONG spot = ((ULONG) reloc[i].seg << 4) + reloc[i].off; + UBYTE *spot0 = &buffers[(size_t)(spot / BUFSIZE)][(size_t)(spot % BUFSIZE)]; + UBYTE *spot1 = &buffers[(size_t)((spot + 1) / BUFSIZE)][(size_t)((spot + 1) % BUFSIZE)]; + UWORD segment = ((UWORD) * spot1 << 8) + *spot0; + + for (j = 0; j < silentcount; j++) + if (segment == silentSegments[j]) + { + silentdone++; + goto dontPrint; + } - struct x { - char y[sizeof(JumpBehindCode) == 0x20 ? 1 : -1]; - }; + printf("relocation at 0x%04x:0x%04x ->%04x\n", reloc[i].seg, + reloc[i].off, segment); - if (size >= 0xfe00u) - { - printf("kernel; size too large - must be <= 0xfe00\n"); + dontPrint: + + segment += start_seg; + *spot0 = segment & 0xff; + *spot1 = segment >> 8; + } + + compress_sys_file = size < 0x10000L; + if (UPX && !compress_sys_file) { + /* write header without relocations to file */ + exe_header nheader = header; + nheader.exRelocItems = 0; + nheader.exHeaderSize = 2; + size += 32; + nheader.exPages = (UWORD)(size >> 9); + nheader.exExtraBytes = (UWORD)size & 511; + if (nheader.exExtraBytes) + nheader.exPages++; + if (fwrite(&nheader, sizeof(nheader), 1, dest) != 1) { + printf("Destination file write error\n"); exit(1); } - - /* this assumes <= 0xfe00 code in kernel */ - *(short *)&JumpBehindCode[0x1e] += (short)size; - fwrite(JumpBehindCode, 1, 0x20, dest); + fseek(dest, 32UL, SEEK_SET); } /* write dest file from memory chunks */ @@ -279,48 +229,210 @@ int main(int argc, char **argv) { printf("Destination file write error\n"); - return 1; + exit(1); } + free(*curbuf); } - - if (UPX) - { - /* UPX trailer */ - /* hand assembled - so this remains ANSI C ;-) */ - /* move kernel down to place CONFIG-block, which added above, - at start_seg-2:0 (e.g. 0x5e:0) instead of - start_seg:0 (e.g. 0x60:0) and store there boot drive number - from BL; kernel.asm will then check presence of additional - CONFIG-block at this address. */ - static char trailer[] = { - 0x0E, /* 0 push cs */ - 0x1F, /* 1 pop ds ; =0x60 */ - 0x8C,0xDF, /* 2 mov di,ds */ - 0x4F, /* 4 dec di */ - 0x4F, /* 5 dec di */ - 0x8E,0xC7, /* 6 mov es,di */ - 0xFC, /* 8 cld */ - 0x33,0xFF, /* 9 xor di,di */ - 0x93, /* 11 xchg ax,bx ; mov al,bl */ - 0xAA, /* 12 stosb ; mov [es:0],al */ - 0x8B,0xF7, /* 13 mov si,di */ - 0xB9,0x00,0x00, /* 15 mov cx,offset trailer */ - 0xF3,0xA4, /* 18 rep movsb */ - 0x1E, /* 20 push ds */ - 0x58, /* 21 pop ax */ - 0x05,0x00,0x00, /* 22 add ax,... */ - 0x8E,0xD0, /* 25 mov ss,ax */ - 0xBC,0x00,0x00, /* 27 mov sp,... */ - 0x31,0xC0, /* 30 xor ax,ax */ - 0xFF,0xE0, /* 32 jmp ax ; jmp 0 */ - }; - *(short *)&trailer[16] = (short)size + 0x20; - *(short *)&trailer[23] = header.exInitSS; - *(short *)&trailer[28] = header.exInitSP; - fwrite(trailer, 1, sizeof trailer, dest); + + if (UPX && compress_sys_file) { + /* overwrite first 8 bytes with SYS header */ + UWORD dhdr[4]; + fseek(dest, 0, SEEK_SET); + for (i = 0; i < 3; i++) + dhdr[i] = 0xffff; + /* strategy will jump to us, interrupt never called */ + dhdr[3] = KERNEL_START; + fwrite(dhdr, sizeof(dhdr), 1, dest); } fclose(dest); printf("\nProcessed %d relocations, %d not shown\n", header.exRelocItems, silentdone); + return compress_sys_file; +} + +static void write_header(FILE *dest, size_t size) +{ + /* UPX HEADER jump $+2+size */ + static char JumpBehindCode[] = { + /* kernel config header - 32 bytes */ + 0xeb, 0x1b, /* jmp short realentry */ + 'C', 'O', 'N', 'F', 'I', 'G', 32 - 2 - 6 - 2 - 3, 0, /* WORD */ + 0, /* DLASortByDriveNo db 0 */ + 1, /* InitDiskShowDriveAssignment db 1 */ + 2, /* SkipConfigSeconds db 2 */ + 0, /* ForceLBA db 0 */ + 1, /* GlobalEnableLBAsupport db 1 */ + 0, /* BootHarddiskSeconds */ + + 'n', 'u', 's', 'e', 'd', /* unused filler bytes */ + 8, 7, 6, 5, 4, 3, 2, 1, + /* real-entry: jump over the 'real' image do the trailer */ + 0xe9, 0, 0 /* 100: jmp 103 */ + }; + + struct x { + char y[sizeof(JumpBehindCode) == 0x20 ? 1 : -1]; + }; + + fseek(dest, 0, SEEK_SET); + /* this assumes <= 0xfe00 code in kernel */ + *(short *)&JumpBehindCode[0x1e] += size; + /* the UPX created-header is 32 bytes long */ + fwrite(JumpBehindCode, 1, 0x20, dest); +} + +static void write_trailer(FILE *dest, size_t size, int compress_sys_file) +{ + /* UPX trailer */ + /* hand assembled - so this remains ANSI C ;-) */ + /* well almost: we still need packing and assume little endian ... */ + /* move kernel down to place CONFIG-block, which added above, + at start_seg-2:0 (e.g. 0x5e:0) instead of + start_seg:0 (e.g. 0x60:0) and store there boot drive number + from BL; kernel.asm will then check presence of additional + CONFIG-block at this address. */ + static char trailer[] = { /* shift down everything by sizeof JumpBehindCode */ + 0xB9, 0x00, 0x00, /* 0 mov cx,offset trailer */ + 0x0E, /* 3 push cs */ + 0x1F, /* 4 pop ds (=60) */ + 0x8C, 0xC8, /* 5 mov ax,cs */ + 0x48, /* 7 dec ax */ + 0x48, /* 8 dec ax */ + 0x8E, 0xC0, /* 9 mov es,ax */ + 0x93, /* 11 xchg ax,bx (to get al=bl) */ + 0x31, 0xFF, /* 12 xor di,di */ + 0xFC, /* 14 cld */ + 0xAA, /* 15 stosb (store drive number)*/ + 0x8B, 0xF7, /* 16 mov si,di */ + 0xF3, 0xA4, /* 18 rep movsb */ + 0x1E, /* 20 push ds */ + 0x58, /* 21 pop ax */ + 0x05, 0x00, 0x00, /* 22 add ax,... */ + 0x8E, 0xD0, /* 25 mov ss,ax */ + 0xBC, 0x00, 0x00, /* 27 mov sp,... */ + 0x31, 0xC0, /* 30 xor ax,ax */ + 0xFF, 0xE0 /* 32 jmp ax */ + }; + + *(short *)&trailer[1] = (short)size + 0x20; + *(short *)&trailer[23] = header.exInitSS; + *(short *)&trailer[28] = header.exInitSP; + if (compress_sys_file) + /* replace by jmp word ptr [6]: ff 26 06 00 + (the .SYS strategy handler which will unpack) */ + *(long *)&trailer[30] = 0x000626ffL; + fwrite(trailer, 1, sizeof(trailer), dest); + fclose(dest); +} + +int main(int argc, char **argv) +{ + short silentSegments[20], silentcount = 0; + int compress_sys_file; + char *upx, *tmpexe, *buffer; + char cmdbuf[128]; + int UPX = FALSE; + int i; + FILE *dest; + long size; + + /* if no arguments provided, show usage and exit */ + if (argc < 4) usage(); + + /* do optional argument processing here */ + for (i = 4; i < argc; i++) + { + char *argptr = argv[i]; + + if (argptr[0] != '-' && argptr[0] != '/') + usage(); + + argptr++; + + switch (toupper(argptr[0])) + { + case 'U': + UPX = TRUE; + break; + case 'S': + if (silentcount >= LENGTH(silentSegments)) + { + printf("can't handle more then %d silent's\n", + LENGTH(silentSegments)); + exit(1); + } + + silentSegments[silentcount++] = (short)strtol(argptr + 1, NULL, 0); + break; + + default: + usage(); + } + } + + /* arguments left : + infile outfile relocation offset */ + + compress_sys_file = exeflat(UPX, argv[1], argv[2], argv[3], + silentSegments, silentcount); + if (!UPX) + exit(0); + + /* move kernel.sys tmp$$$$$.exe */ + tmpexe = argv[2]; + if (!compress_sys_file) + { + tmpexe = "tmp$$$$$.exe"; + rename(argv[2], tmpexe); + } + + upx = getenv("XUPX"); + if (upx == NULL) + upx = "UPX"; + +#if !defined(__TURBOC__) + /* upx kernel.exe -o kernel.sys */ + _snprintf(cmdbuf, sizeof cmdbuf, "%s %s", upx, tmpexe); +#else + /* oh well, let's hope for no buffer overflow...*/ + sprintf(cmdbuf, "%s %s", upx, tmpexe); +#endif + + if (system(cmdbuf)) + { + printf("Problems executing %s\n", cmdbuf); + remove(tmpexe); + exit(1); + } + + if (!compress_sys_file) + { + size = exeflat(FALSE, tmpexe, argv[2], argv[3], + silentSegments, silentcount); + remove(tmpexe); + } + /* argv[2] does now contain the final flattened file: just + header and trailer need to be added */ + /* the compressed file has two chunks max */ + + if ((dest = fopen(argv[2], "rb+")) == NULL) + { + printf("Destination file %s could not be opened\n", argv[2]); + exit(1); + } + + buffer = malloc(0xfe01); + + fread(buffer, 0xfe01, 1, dest); + size = ftell(dest); + if (size >= 0xfe00u) + { + printf("kernel; size too large - must be <= 0xfe00\n"); + exit(1); + } + fseek(dest, 0, SEEK_SET); + write_header(dest, (size_t)size); + fwrite(buffer, (size_t)size, 1, dest); + write_trailer(dest, (size_t)size, compress_sys_file); return 0; } From dc550c065ab790506bee47a379ad4df1994e42e6 Mon Sep 17 00:00:00 2001 From: Luchezar Georgiev Date: Thu, 18 Nov 2004 11:16:23 +0000 Subject: [PATCH 583/671] sg git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/branches/UNSTABLE@1064 6ac86273-5f31-0410-b378-82cca8765d1b From 69df2d06f77fe95e43f7a9cf2949b0899da9bc4a Mon Sep 17 00:00:00 2001 From: Luchezar Georgiev Date: Thu, 18 Nov 2004 11:20:04 +0000 Subject: [PATCH 584/671] (Arkady) Remove -U option as Bart's new EXFLAT now uses XUPX variable directly Suppress TC++ 1.01 warnings (BC++ 3/4/5 not affected!) and MSC LIB prompt git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/branches/UNSTABLE@1065 6ac86273-5f31-0410-b378-82cca8765d1b --- hdr/portab.h | 8 ++++++++ kernel/makefile | 2 +- lib/makefile | 4 ++-- mkfiles/generic.mak | 13 ------------- utils/exeflat.c | 13 +++---------- 5 files changed, 14 insertions(+), 26 deletions(-) diff --git a/hdr/portab.h b/hdr/portab.h index 875d80f2..14b398bf 100644 --- a/hdr/portab.h +++ b/hdr/portab.h @@ -66,6 +66,14 @@ static char *portab_hRcsId = #define I86 #define CDECL cdecl #if __TURBOC__ > 0x202 +#if __TURBOC__ < 0x400 /* targeted to TC++ 1.0 which is 0x297 (3.1 is 0x410) */ +#pragma warn -pia /* possibly incorrect assignment */ +#pragma warn -sus /* suspicious pointer conversion */ +/* + * NOTE: The above enable TC++ to build the kernel, but it's not recommended + * for development. Use [Open]Watcom (the best!) or newer Borland compilers! + */ +#endif /* printf callers do the right thing for tc++ 1.01 but not tc 2.01 */ #define VA_CDECL #else diff --git a/kernel/makefile b/kernel/makefile index b1947683..68717a3c 100644 --- a/kernel/makefile +++ b/kernel/makefile @@ -31,7 +31,7 @@ all: ..\bin\$(TARGET).sys ..\bin\country.sys ..\bin\$(TARGET).sys: $(TARGET).lnk $(OBJS) $(LIBS) ..\utils\exeflat.exe $(LINK) @$(TARGET).lnk; - ..\utils\exeflat kernel.exe $*.sys $(LOADSEG) -S0x10 -S0x8B $(UPXOPT) + ..\utils\exeflat kernel.exe $*.sys $(LOADSEG) -S0x10 -S0x8B copy $*.sys ..\bin\kernel.sys ..\bin\country.sys: country.asm diff --git a/lib/makefile b/lib/makefile index e93f02e2..9dbb4de7 100644 --- a/lib/makefile +++ b/lib/makefile @@ -12,9 +12,9 @@ all: libm.lib libm.lib: $(CLIB) $(DEPENDS) -$(RM) $*.lib - $(LIBUTIL) $(CLIB) $(MATH_EXTRACT) $(LIBTERM) + $(LIBUTIL) $(CLIB) $(MATH_EXTRACT)$(LIBTERM) $(COMSPEC) /c for %i in (*.obj) do ..\utils\patchobj CODE=LCODE %i - $(LIBUTIL) $* $(MATH_INSERT) $(LIBTERM) + $(LIBUTIL) $* $(MATH_INSERT)$(LIBTERM) -$(RM) *.obj ######################################################################## diff --git a/mkfiles/generic.mak b/mkfiles/generic.mak index 211404a9..6aae72e1 100644 --- a/mkfiles/generic.mak +++ b/mkfiles/generic.mak @@ -32,19 +32,6 @@ INITPATCH=@rem LOADSEG=0x60 !endif -UPXOPT=-U -!if $(__MAKE__)0 == 0 # NMAKE/WMAKE -!if "$(XUPX)" == "" # TC doesn't supports this -XUPX=rem # NMAKE doesn't supports @ in macro -UPXOPT= -!endif -!else # TC/BC MAKE -!if !$d(XUPX) # NMAKE/WMAKE doesn't supports $d() -XUPX=@rem -UPXOPT= -!endif -!endif - !include "..\mkfiles\$(COMPILER).mak" TARGET=$(TARGET)$(XCPU)$(XFAT) diff --git a/utils/exeflat.c b/utils/exeflat.c index 2c6ddf82..c60a4da2 100644 --- a/utils/exeflat.c +++ b/utils/exeflat.c @@ -331,7 +331,6 @@ int main(int argc, char **argv) int compress_sys_file; char *upx, *tmpexe, *buffer; char cmdbuf[128]; - int UPX = FALSE; int i; FILE *dest; long size; @@ -351,9 +350,6 @@ int main(int argc, char **argv) switch (toupper(argptr[0])) { - case 'U': - UPX = TRUE; - break; case 'S': if (silentcount >= LENGTH(silentSegments)) { @@ -373,9 +369,10 @@ int main(int argc, char **argv) /* arguments left : infile outfile relocation offset */ - compress_sys_file = exeflat(UPX, argv[1], argv[2], argv[3], + upx = getenv("XUPX"); + compress_sys_file = exeflat((int)upx, argv[1], argv[2], argv[3], silentSegments, silentcount); - if (!UPX) + if (upx == NULL) exit(0); /* move kernel.sys tmp$$$$$.exe */ @@ -386,10 +383,6 @@ int main(int argc, char **argv) rename(argv[2], tmpexe); } - upx = getenv("XUPX"); - if (upx == NULL) - upx = "UPX"; - #if !defined(__TURBOC__) /* upx kernel.exe -o kernel.sys */ _snprintf(cmdbuf, sizeof cmdbuf, "%s %s", upx, tmpexe); From 45e35f46cfb38718b2e2005965e6e88165f031dc Mon Sep 17 00:00:00 2001 From: Kenneth J Davis Date: Sun, 21 Nov 2004 13:37:52 +0000 Subject: [PATCH 585/671] from Bart, invoke DOS idle int 28h for int21/ah=6/dl=ff if busy waiting on input git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/branches/UNSTABLE@1066 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/inthndlr.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/kernel/inthndlr.c b/kernel/inthndlr.c index 3d0fc012..d36f0dd4 100644 --- a/kernel/inthndlr.c +++ b/kernel/inthndlr.c @@ -470,8 +470,10 @@ VOID ASMCFUNC int21_service(iregs FAR * r) lr.AL = 0x00; r->FLAGS |= FLG_ZERO; - if (StdinBusy()) + if (StdinBusy()) { + DosIdle_int(); break; + } r->FLAGS &= ~FLG_ZERO; /* fall through */ From b50bf0f0e71723d8563c1cabf4c7ae709215159c Mon Sep 17 00:00:00 2001 From: Luchezar Georgiev Date: Thu, 2 Dec 2004 18:03:35 +0000 Subject: [PATCH 586/671] Fix bug 1819 by setting FAT32 fields of FAT12/16 DPBs on Int21/7302 git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/branches/UNSTABLE@1068 6ac86273-5f31-0410-b378-82cca8765d1b --- docs/history.txt | 3 +++ kernel/inthndlr.c | 12 ++++++++++++ 2 files changed, 15 insertions(+) diff --git a/docs/history.txt b/docs/history.txt index 77a60ba1..cb7a934b 100644 --- a/docs/history.txt +++ b/docs/history.txt @@ -5,6 +5,8 @@ - bugfix: call_nls: DI register was not preserved * exeflat.c - new version exploiting better UPX compression for SYS files; calls UPX itself + * inthndlr.c + - int21/ah=6/dl=ff now calls int28 + Changes Tom * inthndlr.c - improve handling of case where eg. FindFirst(I:\*.*) fails, causes Int24, @@ -309,6 +311,7 @@ - set AX = ES after Int 21h/4Ah (undocumented but expected by BRUN45) (the last 2 changes needed to fix bugs discovered by Michael Devore) - added Int 2Fh/2Fh processing to set DOS version as per MS-DOS 4.0 + - set FAT32 fields of FAT12/16 DPBs on Int21h/7302h. Fixes bug 1819 * autoexec.bat now single-line for FreeCOM compatibility when EOL=LF * break.c: check_handle_break() return was undefined if no Ctrl-break * config.sys: all commands removed as they were close to defaults diff --git a/kernel/inthndlr.c b/kernel/inthndlr.c index d36f0dd4..6a244c18 100644 --- a/kernel/inthndlr.c +++ b/kernel/inthndlr.c @@ -196,6 +196,18 @@ int int21_fat32(lregs *r) xddp = MK_FP(r->ES, r->DI); fmemcpy(&xddp->xdd_dpb, dpb, sizeof(struct dpb)); + if (!ISFAT32(dpb)) + { /* FAT12/16 - set FAT32 fields. This helps DOSLFN 0.33+ */ + xddp->xdd_dpb.dpb_nfreeclst_un.dpb_nfreeclst_st.dpb_nfreeclst_hi = 0; + xddp->xdd_dpb.dpb_xflags = 0; + xddp->xdd_dpb.dpb_xfsinfosec = 0xFFFF; /* unknown */ + xddp->xdd_dpb.dpb_xbackupsec = 0xFFFF; + xddp->xdd_dpb.dpb_xdata = dpb->dpb_data; + xddp->xdd_dpb.dpb_xsize = dpb->dpb_size; + xddp->xdd_dpb.dpb_xfatsize = dpb->dpb_fatsize; + xddp->xdd_dpb.dpb_xrootclst = 0; /* impossible cluster number */ + xddp->xdd_dpb.dpb_xcluster = dpb->dpb_cluster; + } xddp->xdd_dpbsize = sizeof(struct dpb); break; } From 7e1d6fb8a9da91e9171c144566af6e2d4a3a3bb9 Mon Sep 17 00:00:00 2001 From: Luchezar Georgiev Date: Sat, 4 Dec 2004 16:48:44 +0000 Subject: [PATCH 587/671] Replace bug 1819 fix with the better patch of Jason Hood and add his Set Extended Error implementation git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/branches/UNSTABLE@1069 6ac86273-5f31-0410-b378-82cca8765d1b --- docs/contrib.txt | 1 + docs/history.txt | 5 ++++- kernel/inthndlr.c | 42 +++++++++++++++++++++++++++++------------- 3 files changed, 34 insertions(+), 14 deletions(-) diff --git a/docs/contrib.txt b/docs/contrib.txt index 6f446a57..739b7a5a 100644 --- a/docs/contrib.txt +++ b/docs/contrib.txt @@ -16,6 +16,7 @@ Eric Biederman (ebiederm+eric@ccr.net) Eric Luttmann (ecl@users.sourceforge.net) Helmut Fritsch (helmut.fritsch@gcd-hs.de) James Tabor (jimtabor@infohwy.com) +Jason Hood (jadoxa@yahoo.com.au) Jens Horstmeier (Jens.Horstmeier@abg1.siemens.de) Jeremy Davis (jeremyd@computer.org) Jim Hall (jhall@freedos.org) diff --git a/docs/history.txt b/docs/history.txt index cb7a934b..751fb707 100644 --- a/docs/history.txt +++ b/docs/history.txt @@ -286,6 +286,10 @@ * config.c - source: (Bernd) the codepage table rewritten into a smaller layout. - bugfix: (Bernd, Aitor) country ID for Spain set to 34 (instead 33). ++ Changes Jason + * inthndlr.c + - set FAT32 fields of FAT12/16 DPBs on Int21h/7302h. Fixes bug 1819 + - implement Set Extended Error function to help VC 4.99 with DOSLFN + Changes Lucho * exeflat.c - fix: eliminated warning by explicit cast. @@ -311,7 +315,6 @@ - set AX = ES after Int 21h/4Ah (undocumented but expected by BRUN45) (the last 2 changes needed to fix bugs discovered by Michael Devore) - added Int 2Fh/2Fh processing to set DOS version as per MS-DOS 4.0 - - set FAT32 fields of FAT12/16 DPBs on Int21h/7302h. Fixes bug 1819 * autoexec.bat now single-line for FreeCOM compatibility when EOL=LF * break.c: check_handle_break() return was undefined if no Ctrl-break * config.sys: all commands removed as they were close to defaults diff --git a/kernel/inthndlr.c b/kernel/inthndlr.c index 6a244c18..c0fb420f 100644 --- a/kernel/inthndlr.c +++ b/kernel/inthndlr.c @@ -196,19 +196,18 @@ int int21_fat32(lregs *r) xddp = MK_FP(r->ES, r->DI); fmemcpy(&xddp->xdd_dpb, dpb, sizeof(struct dpb)); - if (!ISFAT32(dpb)) - { /* FAT12/16 - set FAT32 fields. This helps DOSLFN 0.33+ */ - xddp->xdd_dpb.dpb_nfreeclst_un.dpb_nfreeclst_st.dpb_nfreeclst_hi = 0; - xddp->xdd_dpb.dpb_xflags = 0; - xddp->xdd_dpb.dpb_xfsinfosec = 0xFFFF; /* unknown */ - xddp->xdd_dpb.dpb_xbackupsec = 0xFFFF; - xddp->xdd_dpb.dpb_xdata = dpb->dpb_data; - xddp->xdd_dpb.dpb_xsize = dpb->dpb_size; + xddp->xdd_dpbsize = sizeof(struct dpb); + + /* if it doesn't look like an extended DPB, fill in those fields */ + if (!ISFAT32(dpb) && dpb->dpb_xsize != dpb->dpb_size) + { + xddp->xdd_dpb.dpb_nfreeclst_un.dpb_nfreeclst_st.dpb_nfreeclst_hi = + (dpb->dpb_nfreeclst == 0xFFFF ? 0xFFFF : 0); + dpb16to32(&xddp->xdd_dpb); xddp->xdd_dpb.dpb_xfatsize = dpb->dpb_fatsize; - xddp->xdd_dpb.dpb_xrootclst = 0; /* impossible cluster number */ - xddp->xdd_dpb.dpb_xcluster = dpb->dpb_cluster; + xddp->xdd_dpb.dpb_xcluster = (dpb->dpb_cluster == 0xFFFF ? + 0xFFFFFFFFuL : dpb->dpb_cluster); } - xddp->xdd_dpbsize = sizeof(struct dpb); break; } /* Get extended free drive space */ @@ -737,6 +736,9 @@ VOID ASMCFUNC int21_service(iregs FAR * r) lr.AL = retp[1]; lr.AH = retp[2]; } +#if TOM /* Disable the much rarer case to save code size. The only MS-DOS + * utility featuring it is DOSKEY, and FreeCom almost replaces it + */ else if (retp[0] == 0x86 && /* xchg al,ah */ retp[1] == 0xc4 && retp[2] == 0x3d && /* cmp ax, xxyy */ (retp[5] == 0x75 || retp[5] == 0x74)) /* je/jne error */ @@ -744,9 +746,8 @@ VOID ASMCFUNC int21_service(iregs FAR * r) lr.AL = retp[4]; lr.AH = retp[3]; } - +#endif } - break; /* Keep Program (Terminate and stay resident) */ @@ -1222,6 +1223,21 @@ VOID ASMCFUNC int21_service(iregs FAR * r) goto error_exit; break; + /* Set Extended Error */ + case 0x0a: + { + lregs er; + fmemcpy(&er, FP_DS_DX, sizeof(er)); + CritErrCode = er.AX; + FP_SEG(CritErrDev) = er.ES; + FP_OFF(CritErrDev) = er.DI; + CritErrLocus = er.CH; + CritErrClass = er.BH; + CritErrAction = er.BL; + CLEAR_CARRY_FLAG(); + break; + } + default: CritErrCode = SUCCESS; goto error_invalid; From a77e3ef3c7b5fd875ef33659d15c17808073f409 Mon Sep 17 00:00:00 2001 From: Luchezar Georgiev Date: Sat, 4 Dec 2004 17:18:23 +0000 Subject: [PATCH 588/671] Forgotten changes for the last patch by Jason git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/branches/UNSTABLE@1070 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/fatfs.c | 19 +++++++++++-------- kernel/proto.h | 1 + 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/kernel/fatfs.c b/kernel/fatfs.c index fd604d46..8e010a31 100644 --- a/kernel/fatfs.c +++ b/kernel/fatfs.c @@ -1919,6 +1919,16 @@ COUNT dos_setfattr(BYTE * name, UWORD attrp) #endif #ifdef WITHFAT32 +VOID dpb16to32(struct dpb FAR *dpbp) +{ + dpbp->dpb_xflags = 0; + dpbp->dpb_xfsinfosec = 0xffff; + dpbp->dpb_xbackupsec = 0xffff; + dpbp->dpb_xrootclst = 0; + dpbp->dpb_xdata = dpbp->dpb_data; + dpbp->dpb_xsize = dpbp->dpb_size; +} + VOID bpb_to_dpb(bpb FAR * bpbp, REG struct dpb FAR * dpbp, BOOL extended) #else VOID bpb_to_dpb(bpb FAR * bpbp, REG struct dpb FAR * dpbp) @@ -1977,14 +1987,7 @@ ckok:; : sbpb.bpb_nfsect; dpbp->dpb_xcluster = UNKNCLUSTER; dpbp->dpb_xnfreeclst = XUNKNCLSTFREE; /* number of free clusters */ - - dpbp->dpb_xflags = 0; - dpbp->dpb_xfsinfosec = 0xffff; - dpbp->dpb_xbackupsec = 0xffff; - dpbp->dpb_xrootclst = 0; - dpbp->dpb_xdata = dpbp->dpb_data; - dpbp->dpb_xsize = dpbp->dpb_size; - + dpb16to32(dpbp); if (ISFAT32(dpbp)) { dpbp->dpb_xflags = sbpb.bpb_xflags; diff --git a/kernel/proto.h b/kernel/proto.h index e48266e4..56b72f2a 100644 --- a/kernel/proto.h +++ b/kernel/proto.h @@ -182,6 +182,7 @@ COUNT dos_write(COUNT fd, const VOID FAR * buffer, UCOUNT count); LONG dos_lseek(COUNT fd, LONG foffset, COUNT origin); CLUSTER dos_free(struct dpb FAR * dpbp); BOOL dir_exists(char * path); +VOID dpb16to32(struct dpb FAR *dpbp); VOID trim_path(BYTE FAR * s); From 7b0a023193239111762428e0e507a40c88212077 Mon Sep 17 00:00:00 2001 From: Luchezar Georgiev Date: Sun, 5 Dec 2004 14:21:00 +0000 Subject: [PATCH 589/671] By Eduardo - update hardcoded country and codepage IDs git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/branches/UNSTABLE@1071 6ac86273-5f31-0410-b378-82cca8765d1b --- docs/history.txt | 1 + hdr/nls.h | 2 +- kernel/config.c | 10 ++++------ 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/docs/history.txt b/docs/history.txt index 751fb707..060911cb 100644 --- a/docs/history.txt +++ b/docs/history.txt @@ -350,6 +350,7 @@ * portab.h: pragma aux default to gain ~800B unpacked size (Watcom) (the last 2 changes proposed by Bart Oldeman) + Changes Eduardo + * config.c: update hardcoded country and codepage IDs * country.asm: added NLS uppercase/collating tables (437,850,857,858) * inthndlr.c: - added Int 2Fh/26-29h processing for NLSFUNC (with Lucho) diff --git a/hdr/nls.h b/hdr/nls.h index af9763ac..1e9e4fa5 100644 --- a/hdr/nls.h +++ b/hdr/nls.h @@ -476,7 +476,7 @@ struct nlsInfoBlock { /* This block contains all information }; extern struct nlsInfoBlock nlsInfo; -extern struct nlsPackage ASM nlsPackageHardcoded; +extern struct nlsPackage FAR ASM nlsPackageHardcoded; /* These are the "must have" tables within the hard coded NLS pkg */ extern struct nlsFnamTerm FAR ASM nlsFnameTermHardcoded; extern struct nlsDBCS FAR ASM nlsDBCSHardcoded; diff --git a/kernel/config.c b/kernel/config.c index 1ab5319c..4541eaf9 100644 --- a/kernel/config.c +++ b/kernel/config.c @@ -1247,6 +1247,8 @@ err:printf("%s has invalid format\n", filename); != entry.codepage && cpage) continue; + nlsPackageHardcoded.cntry = entry.country; + nlsPackageHardcoded.cp = entry.codepage; subf_data.length = /* MS-DOS "CTYINFO" is up to 38 bytes */ min(subf_data.length, sizeof(struct CountrySpecificInfo)); } @@ -1255,7 +1257,7 @@ err:printf("%s has invalid format\n", filename); } goto ret; } - printf("couldn't find country info for country ID %u\n", ccode); + printf("couldn't find info for country ID %u\n", ccode); ret: close(fd); } @@ -1796,11 +1798,7 @@ STATIC void config_init_fnodes(int f_nodes_cnt) */ STATIC void SetAnyDos(PCStr p) { - if (*p) /* garbage at line end? */ - { - CfgFailure(p); - return; - } + UNREFERENCED_PARAMETER(p); ReturnAnyDosVersionExpected = TRUE; } From 89c51f2223c0dcafae05814d52a7377b489b84d9 Mon Sep 17 00:00:00 2001 From: Kenneth J Davis Date: Sun, 19 Dec 2004 19:33:29 +0000 Subject: [PATCH 590/671] rework sys option handling and add some, update sys docs git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/branches/UNSTABLE@1072 6ac86273-5f31-0410-b378-82cca8765d1b --- boot/boot.asm | 9 +- boot/makefile | 12 +- boot/oemboot.asm | 14 +- build.bat | 2 +- defaults.bat | 2 +- docs/history.txt | 10 +- docs/sys.htm | 100 ++++++ docs/sys.txt | 45 ++- kernel/inthndlr.c | 3 +- sys/sys.c | 873 +++++++++++++++++++++++++++++----------------- 10 files changed, 716 insertions(+), 354 deletions(-) create mode 100644 docs/sys.htm diff --git a/boot/boot.asm b/boot/boot.asm index 0e20a717..7367110c 100644 --- a/boot/boot.asm +++ b/boot/boot.asm @@ -169,12 +169,11 @@ cont: lea sp, [bp-0x60] sti ; -; Some BIOS don't pass drive number in DL, so don't use it if [drive] is known +; Note: some BIOS implementations may not correctly pass drive number +; in DL, however we work around this in SYS.COM by NOP'ing out the use of DL +; (formerly we checked for [drive]==0xff; update sys.c if code moves) ; - cmp byte [drive], 0xff ; impossible number written by SYS - jne dont_use_dl ; was SYS drive: other than A or B? - mov [drive], dl ; yes, rely on BIOS drive number in DL -dont_use_dl: ; no, rely on [drive] written by SYS + mov [drive], dl ; rely on BIOS drive number in DL mov LBA_SIZE, 10h mov LBA_SECNUM,1 ; initialise LBA packet constants diff --git a/boot/makefile b/boot/makefile index 48353514..ebb355cd 100644 --- a/boot/makefile +++ b/boot/makefile @@ -11,22 +11,22 @@ all: fat12.bin fat16.bin fat32chs.bin fat32lba.bin oemfat12.bin oemfat16.bin fat12.bin: boot.asm $(DEPENDS) - $(NASM) -DISFAT12 boot.asm -o$*.bin + $(NASM) -DISFAT12 boot.asm -l$*.lst -o$*.bin fat16.bin: boot.asm $(DEPENDS) - $(NASM) -DISFAT16 boot.asm -o$*.bin + $(NASM) -DISFAT16 boot.asm -l$*.lst -o$*.bin fat32chs.bin: boot32.asm $(DEPENDS) - $(NASM) boot32.asm -o$*.bin + $(NASM) boot32.asm -l$*.lst -o$*.bin fat32lba.bin: boot32lb.asm $(DEPENDS) - $(NASM) boot32lb.asm -o$*.bin + $(NASM) boot32lb.asm -l$*.lst -o$*.bin oemfat12.bin: oemboot.asm $(DEPENDS) - $(NASM) -DISFAT12 oemboot.asm -o$*.bin + $(NASM) -DISFAT12 oemboot.asm -l$*.lst -o$*.bin oemfat16.bin: oemboot.asm $(DEPENDS) - $(NASM) -DISFAT16 oemboot.asm -o$*.bin + $(NASM) -DISFAT16 oemboot.asm -l$*.lst -o$*.bin ######################################################################## diff --git a/boot/oemboot.asm b/boot/oemboot.asm index f75faa54..16edb530 100644 --- a/boot/oemboot.asm +++ b/boot/oemboot.asm @@ -73,7 +73,7 @@ ; | CLUSTER| ; | LIST | ; |--------| 0000:7F00 -; |LBA PKT | +; |LBA PKT | ; |--------| 0000:7E00 (0:BP+200) ; |BOOT SEC| contains BPB ; |ORIGIN | @@ -99,7 +99,6 @@ ;%define LOOPONERR 1 ; if defined on error simply loop forever ;%define SETROOTDIR 1 ; if defined dir entry copied to 0:500 ;%define RETRYALWAYS 1 ; if defined retries read forever -;%define FORCEBIOSDRV 1 ; if defined always use boot drive from BIOS ;%define MSCOMPAT 1 ; sets default filename to MSDOS IO.SYS segment .text @@ -219,14 +218,11 @@ real_start: sti ; enable interrupts ; -; Some BIOS don't pass drive number in DL, so don't use it if [drive] is known +; Note: some BIOS implementations may not correctly pass drive number +; in DL, however we work around this in SYS.COM by NOP'ing out the use of DL +; (formerly we checked for [drive]==0xff; update sys.c if code moves) ; -%ifndef FORCEBIOSDRV - cmp byte [drive], 0xff ; impossible number written by SYS - jne dont_use_dl ; was SYS drive: other than A or B? -%endif - mov [drive], dl ; yes, rely on BIOS drive number in DL -dont_use_dl: ; no, rely on [drive] written by SYS + mov [drive], dl ; rely on BIOS drive number in DL ; GETDRIVEPARMS: Calculate start of some disk areas. diff --git a/build.bat b/build.bat index c7a5eb77..48eb8267 100644 --- a/build.bat +++ b/build.bat @@ -132,4 +132,4 @@ cd .. echo Compilation was aborted! :end -defaults.bat clearset +call defaults.bat clearset diff --git a/defaults.bat b/defaults.bat index 7c581f83..7ae08d31 100644 --- a/defaults.bat +++ b/defaults.bat @@ -21,7 +21,7 @@ if not "%LINK%" == "" goto skip_link set LINK=%BASE%\bin\tlink /c/m if "%COMPILER%" == "TC" set LINK=%BASE%\tlink /c/m -if "%COMPILER%" == "WATCOM" set LINK=..\utils\wlinker /nologo +if "%COMPILER%" == "WATCOM" set LINK=call ..\utils\wlinker /nologo if "%COMPILER%" == "MSC" set LINK=%BASE%\bin\link /ONERROR:NOEXE /batch echo Linker is %LINK% diff --git a/docs/history.txt b/docs/history.txt index 060911cb..9318f9de 100644 --- a/docs/history.txt +++ b/docs/history.txt @@ -376,8 +376,14 @@ - DosYesNo(): Argument is now UWORD (dual byte) - Add prototype for DosGetDBCS() + Changes Jeremy - * config.txt - - update to include all CONFIG.SYS options (except ANYDOS) + * config.txt + - update to include all CONFIG.SYS options (except ANYDOS) + * boot.asm + - use static read buffer to avoid crossing 64KB boundary + * oemboot.asm - add [optional] PC/MS DOS compatible boot sector + * sys.c + - incorporate changes from/for DR-DOS enhancement project + - rework option handling, add backup & restore boot sector * exeflat.c - show usage also when number of arguments incorrect < many other changes to be added by Jeremy himself :-> diff --git a/docs/sys.htm b/docs/sys.htm new file mode 100644 index 00000000..d05b8efd --- /dev/null +++ b/docs/sys.htm @@ -0,0 +1,100 @@ + +sys + +

sys

+Copy system files and make a floppy disk or hard disk bootable. +
+  sys [[d:]path] d: [bootsect] [switches]
+
+

Options

+
+  [[d:]path]
+  The (optional) location of the system files.
+  If not given, the current directory is assumed.
+
+  d:
+  The drive to make bootable.
+
+  bootsect
+  The name of file, to which the 512-byte boot sector image
+  will be written.
+  (the drive's real boot sector won't be
+   written to unless BOTH is used.)
+
+Switches (FreeDOS specific):
+
+  /BOTH
+  The new boot sector will be written to the image file
+  and to the actual drive boot sector.
+
+  /BOOTONLY
+  With this option the boot sector (or image) will be updated,
+  but the kernel and command.com will
+  not be copied to the destination.
+
+  /K filename
+  Gives the filename of the kernel file to be copied. This option
+  is only required when the kernel is not called "kernel.sys"
+  Note: when combined with the /L option, allows one to use FreeDOS
+  sys to create a system to boot custom kernels (ie custom OS)
+
+  /L segment
+  The load segent, in hexadecimal, to use. The default is 0x60.
+
+  /B btdrv
+  Sets the BIOS boot drive # (in hex) stored within the boot sector.
+
+  /FORCEDRV
+  Causes the boot sector to only use the btdrv indicated in
+  boot sector.  NOPs the code that normally uses BIOS provided
+  drive # passed at boot time in the DL register.
+
+  /BACKUPBS [path]filename
+  The original boot sector is written to [path]filename prior
+  to overwriting with FreeDOS one.  The filename may refer to any
+  [image or bs] file, if exists only the 1st 512 bytes will be
+  overwritten.
+
+  /RESTORBS [path]filename
+  Restores original boot sector ([path]filename) and exits.
+  The boot sector specified is written with no modifications.
+  The filename may refer to any [image or bs] file, only the 1st
+  512 bytes are used.
+
+  /OEM:DOS
+  Where DOS is one of
+    AUTO - the default, attempts to determine automatically,
+                  checking for FreeDOS, DR-DOS, PC-DOS, then MS-DOS;
+    FD   - FreeDOS mode, setup destination drive to boot
+                  the FreeDOS kernel and copy FreeDOS system files
+                  (default to KERNEL.SYS and load segment of 0x60)
+    DR   - use DR DOS 7+ (including Udo Kuhnt's DR-DOS
+                  Enhanement Project) compatible settings
+                  (use IBMBIO.COM & IBMDOS.COM, and loadseg=0x70)
+    PC   - use PC-DOS (any) compatible settings, including
+                  alternate boot sector (supports FAT12/16 only)
+                  Must be explicitly choosen, AUTO selects DR mode.
+                  (use IBMBIO.COM & IBMDOS.COM, and loadseg=0x70)
+    MS   - use MS-DOS (pre 7) compatible settings, including
+                  alternate boot sector (supports FAT12/16 only)
+                  (use IO.SYS & MSDOS.SYS, and loadseg=0x70)
+    W9x  - use MS-DOS 7+, aka Windows 9x DOS compatible
+                  settings, Win ME unsupported ...
+
+  Note: when attempting to boot older PC/MS DOS versions, even when
+  using the alternate boot sector, one may need to ensure the
+  system files are the 1st two filesystem entries and in consecutive
+  sectors at the beginning of the drive; so for best results when
+  creating a PC/MS DOS boot disk, format the drive first, do NOT
+  create a label, and then run sys on it.  You can then add a label.
+  Newer releases, such as PC-DOS 7.x do not have these limitations.
+
+
+
+
+Copyright © 1998 Jim Hall
+This file is derived from the FreeDOS Spec Command HOWTO. +See the file H2Cpying.txt for copying conditions. +
+ + diff --git a/docs/sys.txt b/docs/sys.txt index d7e15b56..a1958e57 100644 --- a/docs/sys.txt +++ b/docs/sys.txt @@ -1,17 +1,44 @@ -SYS documentation by Jeremy Davis -Updated by Bart Oldeman +FreeDOS SYS 3.5 +documentation by: + Jeremy Davis + Bart Oldeman SYS's standard behavior is very similar (though in my opinion improved) to that of other DOSes. -SYS (no options) should provide a general usage, +SYS /? (or no options) should provide a general usage, and SYS CONFIG /help (or SYS CONFIG /?) should provide usage for the new configuration options. -Admittedly its brief, but it is there. -Below is a more detailed documentation on its -usage (from memory, but I believe it is close to right). -The best documentation (and maybe only) is the -source itself. +The best documentation is the source itself, but +we try to keep this document updated. + + +Usage: +SYS [source] dest: [bootsect] [{option}] + source = A:,B:,C:\KERNEL\BIN\,etc., or current directory if not given + dest = A,B,etc. + bootsect = name of 512-byte boot sector file image for drive: + to write to *instead* of real boot sector + {option} is one or more of the following: + /BOTH : write to *both* the real boot sector and the image file + /BOOTONLY: do *not* copy kernel / shell, only update boot sector or image + /OEM : indicates boot sector, filenames, and load segment to use + /OEM:FD use FreeDOS compatible settings + /OEM:DR use DR DOS 7+ compatible settings (same as /OEM) + /OEM:PC use PC-DOS compatible settings + /OEM:MS use MS-DOS compatible settings + /OEM:W9x use MS Win9x DOS compatible settings + default is /OEM:AUTO, select DOS based on existing files + /K name : name of kernel to use in boot sector instead of KERNEL.SYS + /L segm : hex load segment to use in boot sector instead of 0x60 + /B btdrv : hex BIOS # of boot drive set in bs, 0=A:, 80=1st hd,... + /FORCEDRV: force use of drive # set in bs instead of BIOS boot value + /SKFN filename : set KERNEL.SYS input file and /OEM:FD + /SCFN filename : sets COMMAND.COM input file + /BACKUPBS [path]filename : save current bs before overwriting + /RESTORBS [path]filename : overwrite bs and exit + +SYS CONFIG /help The simplest usage: @@ -27,7 +54,7 @@ be in the root directory of the current drive. Complete form: -SYS [source] dest: [bootsect [BOTH]] +SYS [source] dest: [bootsect [/BOTH]] Here dest is the same as before, but this time you specify where KERNEL.SYS and COMMAND.COM are. diff --git a/kernel/inthndlr.c b/kernel/inthndlr.c index c0fb420f..53c6168a 100644 --- a/kernel/inthndlr.c +++ b/kernel/inthndlr.c @@ -1229,8 +1229,7 @@ VOID ASMCFUNC int21_service(iregs FAR * r) lregs er; fmemcpy(&er, FP_DS_DX, sizeof(er)); CritErrCode = er.AX; - FP_SEG(CritErrDev) = er.ES; - FP_OFF(CritErrDev) = er.DI; + CritErrDev = MK_FP(er.ES, er.DI); CritErrLocus = er.CH; CritErrClass = er.BH; CritErrAction = er.BL; diff --git a/sys/sys.c b/sys/sys.c index bb7f6669..e3b79f90 100644 --- a/sys/sys.c +++ b/sys/sys.c @@ -30,7 +30,7 @@ /* #define DDEBUG */ #define WITHOEMCOMPATBS /* include support for OEM MS/PC DOS 3.??-6.x */ -#define SYS_VERSION "v3.4" +#define SYS_VERSION "v3.5" #include #include @@ -186,11 +186,6 @@ char *getenv(const char *name) BYTE pgm[] = "SYS"; -void put_boot(int, char *, char *, int, int, int, int); -BOOL check_space(COUNT, ULONG); -BOOL get_full_path(BYTE * srcPath, BYTE * rootPath, BYTE * filename, BYTE *source); -BOOL copy(BYTE *source, COUNT drive, BYTE * filename); - #define SEC_SIZE 512 #define COPY_SIZE 0x7e00 @@ -271,285 +266,442 @@ int FDKrnConfigMain(int argc, char **argv); /* FreeDOS sys, we default to our kernel and load segment, but if not found (or explicitly given) support OEM DOS variants (such as DR-DOS or a FreeDOS kernel mimicing other DOSes). - PC-DOS requires particular steps from the boot loader, which - we do not currently fullfill, so it will not boot and MS-DOS - uses different names, so it also will not work. + Note: other (especially older) DOS versions expect the boot + loader to perform particular steps, which we may not do; + older PC/MS DOS variants may work with the OEM compatible + boot sector (optionally included). */ -#define FDKERNEL "KERNEL.SYS" -#define OEMKERNEL "IBMBIO.COM" -#define OEMDOS "IBMDOS.COM" -#define MSKERNEL "IO.SYS" -#define MS_DOS "MSDOS.SYS" -#define FDLOADSEG 0x60 -#define OEMLOADSEG 0x70 +typedef struct DOSBootFiles { + const char * kernel; // filename boot sector loads and chains to + const char * dos; // optional secondary file for OS + WORD loadseg; // segment kernel file expects to start at + BOOL stdbs; // use FD boot sector (T) or oem compat one (F) + LONG minsize; // smallest dos file can be and be valid, 0=existance optional +} DOSBootFiles; +DOSBootFiles bootFiles[] = { + /* Note: This order is the order OEM:AUTO uses to determine DOS flavor. */ + /* FreeDOS */ { "KERNEL.SYS", NULL, 0x60, 1, 0 }, + /* DR-DOS */ { "IBMBIO.COM", "IBMDOS.COM", 0x70, 1, 1 }, +#ifdef WITHOEMCOMPATBS + /* PC-DOS */ { "IBMBIO.COM", "IBMDOS.COM", 0x70, 0, 6138 }, /* pre v7 DR ??? */ + /* MS-DOS */ { "IO.SYS", "MSDOS.SYS", 0x70, 0, 10240 }, +#endif + /* W9x-DOS */ { "IO.SYS", "MSDOS.SYS", 0x70, 1, 0}, +}; +#define DOSFLAVORS (sizeof(bootFiles) / sizeof(*bootFiles)) + +#define OEM_AUTO (-1) /* attempt to guess DOS on source drive */ +#define OEM_FD 0 /* standard FreeDOS mode */ +#define OEM_DR 1 /* use FreeDOS boot sector, but OEM names */ +#define OEM_PC 2 /* use PC-DOS compatible boot sector and names */ +#define OEM_MS 3 /* use PC-DOS compatible BS with MS names */ +#define OEM_W9x 4 /* use FreeDOS boot sector but with MS names */ + +typedef struct SYSOptions { + BYTE srcDrive[SYS_MAXPATH]; /* source drive:[path], root assumed if no path */ + BYTE dstDrive; /* destination drive [STD SYS option] */ + int flavor; /* DOS variant we want to boot, default is AUTO/FD */ + DOSBootFiles kernel; /* file name(s) and relevant data for kernel */ + BYTE defBootDrive; /* value stored in boot sector for drive, eg 0x0=A, 0x80=C */ + BOOL ignoreBIOS; /* true to NOP out boot sector code to get drive# from BIOS */ + BOOL copyFiles; /* true to copy kernel files and command interpreter */ + BOOL writeBS; /* true to write boot sector to drive/partition LBA 0 */ + BYTE *bsFile; /* file name & path to save bs to when saving to file */ + BYTE *bsFileOrig; /* file name & path to save original bs when backing up */ + BYTE *fnKernel; /* optional override to source kernel filename (src only) */ + BYTE *fnCmd; /* optional override to cmd interpreter filename (src & dest) */ +} SYSOptions; + + +void restoreBS(const char *, int); +void put_boot(SYSOptions *opts); +BOOL check_space(COUNT, ULONG); +BOOL copy(const BYTE *source, COUNT drive, const BYTE * filename); -#define NO_OEMKERN 0 /* standard FreeDOS mode */ -#define DR_OEMKERN 1 /* use FreeDOS boot sector, but OEM names */ -#define PC_OEMKERN 2 /* use PC-DOS compatible boot sector and names */ -#define MS_OEMKERN 3 /* use PC-DOS compatible BS with MS names */ +void showHelpAndExit(void) +{ + printf( + "Usage: \n" + "%s [source] drive: [bootsect] [{option}]\n" + " source = A:,B:,C:\\KERNEL\\BIN\\,etc., or current directory if not given\n" + " drive = A,B,etc.\n" + " bootsect = name of 512-byte boot sector file image for drive:\n" + " to write to *instead* of real boot sector\n" + " {option} is one or more of the following:\n" + " /BOTH : write to *both* the real boot sector and the image file\n" + " /BOOTONLY: do *not* copy kernel / shell, only update boot sector or image\n" + " /OEM : indicates boot sector, filenames, and load segment to use\n" + " /OEM:FD use FreeDOS compatible settings\n" + " /OEM:DR use DR DOS 7+ compatible settings (same as /OEM)\n" +#ifdef WITHOEMCOMPATBS + " /OEM:PC use PC-DOS compatible settings\n" + " /OEM:MS use MS-DOS compatible settings\n" +#endif + " /OEM:W9x use MS Win9x DOS compatible settings\n" + " default is /OEM:AUTO, select DOS based on existing files\n" + " /K name : name of kernel to use in boot sector instead of KERNEL.SYS\n" + " /L segm : hex load segment to use in boot sector instead of 60\n" + " /B btdrv : hex BIOS # of boot drive set in bs, 0=A:, 80=1st hd,...\n" + " /FORCEDRV: force use of drive # set in bs instead of BIOS boot value\n" + "%s CONFIG /help\n", pgm, pgm + ); + exit(1); +} -int main(int argc, char **argv) +/* get and validate arguments */ +void initOptions(int argc, char *argv[], SYSOptions *opts) { - COUNT drive; /* destination drive */ - COUNT drivearg = 0; /* drive argument position */ - COUNT srcarg = 0; /* source argument position */ - BYTE *bsFile = NULL; /* user specified destination boot sector */ - unsigned srcDrive; /* source drive */ - BYTE srcPath[SYS_MAXPATH]; /* user specified source drive and/or path */ - BYTE rootPath[4]; /* alternate source path to try if not '\0' */ - BYTE srcFile[SYS_MAXPATH]; /* full path+name of [kernel] file to copy */ - WORD slen; - int argno = 0; - int bootonly = 0; - int both = 0; - int bootdrive = -1; /* -1 means default processing, else value to use */ - char *kernel_name = FDKERNEL; - int load_segment = FDLOADSEG; - int altkern = NO_OEMKERN; /* use OEM kernel values instead of FD ones */ + int argno; + int drivearg = 0; /* drive argument, position of 1st or 2nd non option */ + int srcarg = 0; /* nonzero if optional source argument */ + BYTE srcFile[SYS_MAXPATH]; /* full path+name of [kernel] file [to copy] */ + struct stat fstatbuf; - printf("FreeDOS System Installer " SYS_VERSION ", " __DATE__ "\n\n"); - - if (argc > 1 && memicmp(argv[1], "CONFIG", 6) == 0) - { - exit(FDKrnConfigMain(argc, argv)); - } + /* initialize to defaults */ + memset(opts, 0, sizeof(SYSOptions)); + /* set srcDrive and dstDrive after processing args */ + opts->flavor = OEM_AUTO; /* attempt to detect DOS user wants to boot */ + opts->copyFiles = 1; /* actually copy the kernel and cmd interpreter to dstDrive */ + /* cycle through processing cmd line arguments */ for(argno = 1; argno < argc; argno++) { char *argp = argv[argno]; - if (argp[1] == ':' && argp[2] == '\0' && drivearg <= srcarg) - drivearg = argno; - - if (srcarg == 0) - { - srcarg = argno; - } - else if (memicmp(argp, "BOTH", 4) == 0 && !both) - { - both = 1; - } - else if (argp[0] == '/') /* optional switch */ + if (argp[0] == '/') /* optional switch */ { argp++; /* skip past the '/' character */ - if (memicmp(argp, "OEM", 3) == 0) + /* explicit request for base help/usage */ + if ((*argp == '?') || (memicmp(argp, "HELP", 4) == 0)) + { + showHelpAndExit(); + } + /* write to *both* the real boot sector and the image file */ + else if (memicmp(argp, "BOTH", 4) == 0) + { + opts->writeBS = 1; /* note: if bs file omitted, then same as omitting /BOTH */ + } + /* do *not* copy kernel / shell, only update boot sector or image */ + else if (memicmp(argp, "BOOTONLY", 8) == 0) { - #ifdef WITHOEMCOMPATBS - if (*(argp+3) == ':') + opts->copyFiles = 0; + } + /* indicates compatibility mode, fs, filenames, and load segment to use */ + else if (memicmp(argp, "OEM", 3) == 0) + { + argp += 3; + if (!*argp) + opts->flavor = OEM_DR; + else if (*argp == ':') { - argp+=4; /* point to DR/PC/MS that follows */ - if (memicmp(argp, "PC", 2) == 0) - { - altkern = PC_OEMKERN; /* kernel is split into 2 files and update BS name */ - load_segment = OEMLOADSEG; - kernel_name = OEMKERNEL; - } - else if (memicmp(argp, "MS", 2) == 0) - { - altkern = MS_OEMKERN; /* kernel is split into 2 files and update BS name */ - load_segment = OEMLOADSEG; - kernel_name = MSKERNEL; - } + argp++; /* point to DR/PC/MS that follows */ + if (memicmp(argp, "AUTO", 4) == 0) + opts->flavor = OEM_AUTO; else if (memicmp(argp, "DR", 2) == 0) - { - altkern = DR_OEMKERN; /* kernel is split into 2 files and update BS name */ - load_segment = OEMLOADSEG; - kernel_name = OEMKERNEL; - } + opts->flavor = OEM_DR; +#ifdef WITHOEMCOMPATBS + else if (memicmp(argp, "PC", 2) == 0) + opts->flavor = OEM_PC; + else if (memicmp(argp, "MS", 2) == 0) + opts->flavor = OEM_MS; +#endif + else if (memicmp(argp, "W9", 2) == 0) + opts->flavor = OEM_W9x; else /* if (memicmp(argp, "FD", 2) == 0) */ - { - altkern = NO_OEMKERN; /* restore defaults */ - load_segment = FDLOADSEG; - kernel_name = FDKERNEL; - } + opts->flavor = OEM_FD; } - else /* generic support, just change names and load sector */ - #endif + else { - altkern = DR_OEMKERN; /* kernel is split into 2 files and update BS name */ - load_segment = OEMLOADSEG; - if (kernel_name == FDKERNEL) /* preserve /K name if on cmd line 1st */ - kernel_name = OEMKERNEL; + printf("%s: unknown OEM qualifier %s\n", pgm, argp); + showHelpAndExit(); } } - else if (memicmp(argp, "BOOTONLY", 8) == 0) + /* force use of drive # set in bs instead of BIOS boot value */ + else if (memicmp(argp, "FORCEDRV", 8) == 0) { - bootonly = 1; + opts->ignoreBIOS = 1; } else if (argno + 1 < argc) /* two part options, /SWITCH VALUE */ { argno++; if (toupper(*argp) == 'K') /* set Kernel name */ { - kernel_name = argv[argno]; + opts->kernel.kernel = argv[argno]; } else if (toupper(*argp) == 'L') /* set Load segment */ { - load_segment = (int)strtol(argv[argno], NULL, 16); + opts->kernel.loadseg = (WORD)strtol(argv[argno], NULL, 16); } else if (memicmp(argp, "B", 2) == 0) /* set boot drive # */ { - /* BIOS drive number to put in boot sector, normally this is - 0 for A, 80 for 1st hard drive, 81 2nd hd, etc, and - FF for FreeDOS bootsector will force use of value passed - in DL by BIOS. */ - bootdrive = (BYTE)strtol(argv[argno], NULL, 16); + opts->defBootDrive = (BYTE)strtol(argv[argno], NULL, 16); + } + /* options not documented by showHelpAndExit() */ + else if (memicmp(argp, "SKFN", 4) == 0) /* set KERNEL.SYS input file and /OEM:FD */ + { + opts->flavor = OEM_FD; + opts->fnKernel = argv[argno]; } - else /* unknown option */ + else if (memicmp(argp, "SCFN", 4) == 0) /* sets COMMAND.COM input file */ { - drivearg = 0; - break; + opts->fnCmd = argv[argno]; + } + else if (memicmp(argp, "BACKUPBS", 8) == 0) /* save current bs before overwriting */ + { + opts->bsFileOrig = argv[argno]; + } + else if (memicmp(argp, "RESTORBS", 8) == 0) /* overwrite bs and exit */ + { + if (drivearg) + restoreBS(argv[argno], (BYTE)(toupper(*(argv[drivearg])) - 'A')); + else + printf("%s: unspecified drive, unable to restore boot sector\n", pgm); + exit(1); + } + else + { + printf("%s: unknown option, %s\n", pgm, argv[argno]); + showHelpAndExit(); } } - else /* invalid option or missing value portion */ + else { - drivearg = 0; - break; + printf("%s: unknown option or missing parameter, %s\n", pgm, argv[argno]); + showHelpAndExit(); } } - else if (drivearg != argno) + else if (!drivearg) { - if (bsFile == NULL) - { - bsFile = argp; - } - else /* invalid usage */ - { - drivearg = 0; - break; - } + drivearg = argno; /* either source or destination drive */ + } + else if (!srcarg /* && drivearg */) + { + srcarg = drivearg; /* set source path */ + drivearg = argno; /* set destination drive */ } - } /* for() */ + else if (!opts->bsFile /* && srcarg && drivearg */) + { + opts->bsFile = argv[argno]; + } + else /* if (opts->bsFile && srcarg && drivearg) */ + { + printf("%s: invalid argument %s\n", pgm, argv[argno]); + showHelpAndExit(); + } + } - if (drivearg == 0) + /* if neither BOTH nor a boot sector file specified, then write to boot record */ + if (!opts->bsFile) + opts->writeBS = 1; + + /* set dest path */ + if (!drivearg) + showHelpAndExit(); + opts->dstDrive = (BYTE)(toupper(*(argv[drivearg])) - 'A'); + if (/* (opts->dstDrive < 0) || */ (opts->dstDrive >= 26)) { - printf( - "Usage: \n" - "%s [source] drive: [bootsect [BOTH]] [/BOOTONLY] [/OEM] [/K name] [/L segm]\n" - " source = A:,B:,C:\\KERNEL\\BIN\\,etc., or current directory if not given\n" - " drive = A,B,etc.\n" - " bootsect = name of 512-byte boot sector file image for drive:\n" - " to write to *instead* of real boot sector\n" - " BOTH : write to *both* the real boot sector and the image file\n" - " /BOOTONLY: do *not* copy kernel / shell, only update boot sector or image\n" - " /OEM : indicates kernel is IBMBIO.COM/IBMDOS.COM loaded at 0x70\n" -#ifdef WITHOEMCOMPATBS - " /OEM:DR use IBMBIO.COM/IBMDOS.COM and FD boot sector (default)\n" - " /OEM:PC use PC-DOS compatible boot sector\n" - " /OEM:MS use PC-DOS compatible boot sector with IO.SYS/MSDOS.SYS\n" -#endif - " /K name : name of kernel to use instead of KERNEL.SYS\n" - " /L segm : hex load segment to use instead of 60\n" - " /B btdrv : hex BIOS # of boot drive, FF=BIOS provided, 0=A:, 80=1st hd,...\n" - "%s CONFIG /help\n", pgm, pgm); + printf("%s: drive %c must be A:..Z:\n", pgm, *(argv[drivearg])); exit(1); } - drive = toupper(argv[drivearg][0]) - 'A'; - if (drive < 0 || drive >= 26) + /* set source path, default to current drive */ + sprintf(opts->srcDrive, "%c:", 'A' + getcurdrive()); + if (srcarg) { - printf("%s: drive %c must be A:..Z:\n", pgm, - *argv[(argc == 3 ? 2 : 1)]); - exit(1); + int slen; + /* set source path, reserving room to append filename */ + if ( (argv[drivearg][1] == ':') || (argv[drivearg][1] == '\\') ) + strncpy(opts->srcDrive, argv[drivearg], SYS_MAXPATH-13); + else /* only path provided, append to default drive */ + strncat(opts->srcDrive, argv[srcarg], SYS_MAXPATH-15); + slen = strlen(opts->srcDrive); + /* if path follows drive, ensure ends in a slash, ie X:-->X: or X:.\mypath-->X:.\mypath\ */ + if ((slen>2) && (opts->srcDrive[slen-1] != '\\') && (opts->srcDrive[slen-1] != '/')) + strcat(opts->srcDrive, "\\"); } + /* source path is now in form of just a drive, "X:" + or form of drive + path + directory separator, "X:\path\" or "\\path\" + If just drive we try current path then root, else just indicated path. + */ + + + /* if source and dest are same drive, then source should not be root, + so if is same drive and not explicit path, force only current + Note: actual copy routine prevents overwriting self when src=dst + */ + if ( (opts->dstDrive == (toupper(*(opts->srcDrive))-'A')) && (!opts->srcDrive[2]) ) + strcat(opts->srcDrive, ".\\"); + - srcPath[0] = '\0'; - if (drivearg > srcarg && srcarg) + /* attempt to detect compatibility settings user needs */ + if (opts->flavor == OEM_AUTO) { - strncpy(srcPath, argv[srcarg], SYS_MAXPATH - 12); - /* leave room for COMMAND.COM\0 */ - srcPath[SYS_MAXPATH - 13] = '\0'; - /* make sure srcPath + "file" is a valid path */ - slen = strlen(srcPath); - if ((srcPath[slen - 1] != ':') && - ((srcPath[slen - 1] != '\\') || (srcPath[slen - 1] != '/'))) + /* 1st loop checking current just source path provided */ + for (argno = 0; argno < DOSFLAVORS; argno++) + { + /* look for existing file matching kernel filename */ + sprintf(srcFile, "%s%s", opts->srcDrive, bootFiles[argno].kernel); + if (stat(srcFile, &fstatbuf)) continue; /* if !exists() try again */ + if (!fstatbuf.st_size) continue; /* file must not be empty */ + + /* now check if secondary file exists and of minimal size */ + if (bootFiles[argno].minsize) + { + sprintf(srcFile, "%s%s", opts->srcDrive, bootFiles[argno].dos); + if (stat(srcFile, &fstatbuf)) continue; + if (fstatbuf.st_size < bootFiles[argno].minsize) continue; + } + + /* above criteria succeeded, so default to corresponding DOS */ + opts->flavor = argno; + break; + } + + /* if no match, and source just drive, try root */ + if ( (opts->flavor == OEM_AUTO) && (!opts->srcDrive[2]) ) { - srcPath[slen] = '\\'; - slen++; - srcPath[slen] = '\0'; + for (argno = 0; argno < DOSFLAVORS; argno++) + { + /* look for existing file matching kernel filename */ + sprintf(srcFile, "%s\\%s", opts->srcDrive, bootFiles[argno].kernel); + if (stat(srcFile, &fstatbuf)) continue; /* if !exists() try again */ + if (!fstatbuf.st_size) continue; /* file must not be empty */ + + /* now check if secondary file exists and of minimal size */ + if (bootFiles[argno].minsize) + { + sprintf(srcFile, "%s\\%s", opts->srcDrive, bootFiles[argno].dos); + if (stat(srcFile, &fstatbuf)) continue; + if (fstatbuf.st_size < bootFiles[argno].minsize) continue; + } + + /* above criteria succeeded, so default to corresponding DOS */ + opts->flavor = argno; + strcat(opts->srcDrive, "\\"); /* indicate to use root from now on */ + break; + } } } + /* if unable to determine DOS, assume FreeDOS */ + if (opts->flavor == OEM_AUTO) opts->flavor = OEM_FD; + + /* set compatibility settings not explicitly set */ + if (!opts->kernel.kernel) opts->kernel.kernel = bootFiles[opts->flavor].kernel; + if (!opts->kernel.dos) opts->kernel.dos = bootFiles[opts->flavor].dos; + if (!opts->kernel.loadseg) opts->kernel.loadseg = bootFiles[opts->flavor].loadseg; + opts->kernel.stdbs = bootFiles[opts->flavor].stdbs; + opts->kernel.minsize = bootFiles[opts->flavor].minsize; - /* Get source drive */ - if ((strlen(srcPath) > 1) && (srcPath[1] == ':')) /* src specifies drive */ - srcDrive = toupper(*srcPath) - 'A'; - else /* src doesn't specify drive, so assume current drive */ - srcDrive = getcurdrive(); - - /* Don't try root if src==dst drive or source path given */ - if ((drive == srcDrive) - || (*srcPath - && ((srcPath[1] != ':') || ((srcPath[1] == ':') && srcPath[2])))) - *rootPath = '\0'; - else - sprintf(rootPath, "%c:\\", 'A' + srcDrive); + + /* if destination is floppy (A: or B:) then use drive # stored in boot sector */ + if (opts->dstDrive < 2) + opts->ignoreBIOS = 1; + + /* if bios drive to store in boot sector not set and not floppy set to 1st hd */ + if (!opts->defBootDrive && (opts->dstDrive >= 2)) + opts->defBootDrive = 0x80; /* unless we are only setting boot sector, verify kernel file exists */ - if (!bootonly) + if (opts->copyFiles) { - /* if FDKERNEL not found and an explicit kernel name was not specified, - then see if OEM kernel available and switch to it instead. */ - if (!get_full_path(srcPath, rootPath, kernel_name, srcFile) && (kernel_name == FDKERNEL)) + /* check kernel (primary file) 1st */ + sprintf(srcFile, "%s%s", opts->srcDrive, (opts->fnKernel)?opts->fnKernel:opts->kernel.kernel); + if (stat(srcFile, &fstatbuf)) /* if !exists() */ { - if (!get_full_path(srcPath, rootPath, OEMKERNEL, srcFile)) + /* check root path as well if src is drive only */ + sprintf(srcFile, "%s\\%s", opts->srcDrive, (opts->fnKernel)?opts->fnKernel:opts->kernel.kernel); + if (opts->srcDrive[2] || stat(srcFile, &fstatbuf)) { - printf("\n%s: failed to find kernel file %s\n", pgm, kernel_name); + printf("%s: failed to find kernel file %s\n", pgm, (opts->fnKernel)?opts->fnKernel:opts->kernel.kernel); exit(1); } - else /* else OEM kernel found, so switch modes */ + /* else found, but in root, so force to always use root */ + strcat(opts->srcDrive, "\\"); + } + + /* now check for secondary file */ + if (opts->kernel.dos && opts->kernel.minsize) + { + sprintf(srcFile, "%s%s", opts->srcDrive, opts->kernel.dos); + if (stat(srcFile, &fstatbuf)) { - altkern = DR_OEMKERN; - kernel_name = OEMKERNEL; - load_segment = OEMLOADSEG; + printf("%s: failed to find source file %s\n", pgm, opts->kernel.dos); + exit(1); + } + if (fstatbuf.st_size < opts->kernel.minsize) + { + printf("%s: source file %s appears corrupt, invalid size\n", pgm, opts->kernel.dos); + exit(1); + } + } + + /* lastly check for command interpreter */ + sprintf(srcFile, "%s%s", opts->srcDrive, (opts->fnCmd)?opts->fnCmd:"COMMAND.COM"); + if (stat(srcFile, &fstatbuf)) /* if !exists() */ + { + char *comspec = getenv("COMSPEC"); + if (opts->fnCmd || (comspec == NULL) || stat(comspec, &fstatbuf)) + { + printf("%s: failed to find command interpreter (shell) file %s\n", pgm, (opts->fnCmd)?opts->fnCmd:"COMMAND.COM"); + exit(1); } } } +} + +int main(int argc, char **argv) +{ + SYSOptions opts; /* boot options and other flags */ + BYTE srcFile[SYS_MAXPATH]; /* full path+name of [kernel] file [to copy] */ + + printf("FreeDOS System Installer " SYS_VERSION ", " __DATE__ "\n\n"); + + if (argc > 1 && memicmp(argv[1], "CONFIG", 6) == 0) + { + exit(FDKrnConfigMain(argc, argv)); + } + + initOptions(argc, argv, &opts); printf("Processing boot sector...\n"); - put_boot(drive, bsFile, kernel_name, load_segment, both, altkern, bootdrive); + put_boot(&opts); - if (!bootonly) + if (opts.copyFiles) { - if (!copy(srcFile, drive, kernel_name)) + printf("Now copying system files...\n"); + + sprintf(srcFile, "%s%s", opts.srcDrive, (opts.fnKernel)?opts.fnKernel:opts.kernel.kernel); + if (!copy(srcFile, opts.dstDrive, opts.kernel.kernel)) { - printf("\n%s: cannot copy \"%s\"\n", pgm, kernel_name); + printf("%s: cannot copy \"%s\"\n", pgm, srcFile); exit(1); } /* copy kernel */ - if (altkern) + if (opts.kernel.dos) { - char *dosfn = OEMDOS; - #ifdef WITHOEMCOMPATBS - if (altkern == MS_OEMKERN) dosfn = MS_DOS; - #endif - - if ( (!get_full_path(srcPath, rootPath, dosfn, srcFile)) || - (!copy(srcFile, drive, dosfn)) ) + sprintf(srcFile, "%s%s", opts.srcDrive, opts.kernel.dos); + if (!copy(srcFile, opts.dstDrive, opts.kernel.dos) && opts.kernel.minsize) { - printf("\n%s: cannot copy \"%s\"\n", pgm, dosfn); + printf("%s: cannot copy \"%s\"\n", pgm, srcFile); exit(1); - } + } /* copy secondary file (DOS) */ } /* copy command.com, 1st try source path, then try %COMSPEC% */ - if (!get_full_path(srcPath, rootPath, "COMMAND.COM", srcFile)) + sprintf(srcFile, "%s%s", opts.srcDrive, (opts.fnCmd)?opts.fnCmd:"COMMAND.COM"); + if (!copy(srcFile, opts.dstDrive, "COMMAND.COM")) { char *comspec = getenv("COMSPEC"); - if ( (comspec == NULL) || - (!get_full_path(comspec, NULL, "COMMAND.COM", srcFile)) ) + if (!opts.fnCmd && (comspec != NULL)) + printf("%s: Trying shell from %COMSPEC%=\"%s\"\n", pgm, comspec); + if (opts.fnCmd || (comspec == NULL) || !copy(comspec, opts.dstDrive, "COMMAND.COM")) { - printf("\n%s: failed to find command interpreter (shell) file %s\n", pgm, "COMMAND.COM"); - exit(1); + printf("\n%s: failed to find command interpreter (shell) file %s\n", pgm, (opts.fnCmd)?opts.fnCmd:"COMMAND.COM"); + exit(1); } - printf("\n%s: Using shell from %COMSPEC% \"%s\"\n", pgm, comspec); - } - if (!copy(srcFile, drive, "COMMAND.COM")) - { - printf("\n%s: cannot copy \"%s\"\n", pgm, "COMMAND.COM"); - exit(1); } /* copy shell */ } @@ -834,9 +986,99 @@ void correct_bpb(struct bootsectortype *default_bpb, oldboot->bsHiddenSecs = default_bpb->bsHiddenSecs; } -void put_boot(int drive, char *bsFile, - char *kernel_name, int load_seg, int both, - int altkern, int bootdrive) +/* reads in boot sector (1st SEC_SIZE bytes) from file */ +void readBS(const char *bsFile, BYTE *bootsector) +{ + if (bsFile != NULL) + { + int fd; + +#ifdef DEBUG + printf("reading bootsector from file %s\n", bsFile); +#endif + + /* open boot sector file, it must exists, then overwrite + drive with 1st SEC_SIZE bytes from the [image] file + */ + if ((fd = open(bsFile, O_RDONLY | O_BINARY)) < 0) + { + printf("%s: can't open\"%s\"\nDOS errnum %d", pgm, bsFile, errno); + exit(1); + } + if (read(fd, bootsector, SEC_SIZE) != SEC_SIZE) + { + printf("%s: failed to read %u bytes from %s\n", pgm, SEC_SIZE, bsFile); + close(fd); + exit(1); + } + close(fd); + } +} + +/* write bs in bsFile to drive's boot record unmodified */ +void restoreBS(const char *bsFile, int drive) +{ + unsigned char bootsector[SEC_SIZE]; + + if (bsFile == NULL) + { + printf("%s: missing filename of boot sector to restore\n", pgm); + exit(1); + } + + readBS(bsFile, bootsector); + + /* lock drive */ + generic_block_ioctl(drive + 1, 0x84a, NULL); + + reset_drive(drive); + + /* write bootsector to drive */ + if (MyAbsReadWrite(drive, 1, 0, bootsector, 1) != 0) + { + printf("%s: failed to write boot sector to drive %c:\n", pgm, drive + 'A'); + exit(1); + } + + reset_drive(drive); + + /* unlock_drive */ + generic_block_ioctl(drive + 1, 0x86a, NULL); +} + +/* write bootsector to file bsFile */ +void saveBS(const char *bsFile, BYTE *bootsector) +{ + if (bsFile != NULL) + { + int fd; + +#ifdef DEBUG + printf("writing bootsector to file %s\n", bsFile); +#endif + + /* open boot sector file, create it if not exists, + but don't truncate if exists so we can replace + 1st SEC_SIZE bytes of an image file + */ + if ((fd = open(bsFile, O_WRONLY | O_CREAT | O_BINARY, + S_IREAD | S_IWRITE)) < 0) + { + printf("%s: can't create\"%s\"\nDOS errnum %d", pgm, bsFile, errno); + exit(1); + } + if (write(fd, bootsector, SEC_SIZE) != SEC_SIZE) + { + printf("%s: failed to write %u bytes to %s\n", pgm, SEC_SIZE, bsFile); + close(fd); + /* unlink(bsFile); don't delete in case was image */ + exit(1); + } + close(fd); + } /* if write boot sector file */ +} + +void put_boot(SYSOptions *opts) { #ifdef WITHFAT32 struct bootsectortype32 *bs32; @@ -844,23 +1086,21 @@ void put_boot(int drive, char *bsFile, struct bootsectortype *bs; static unsigned char oldboot[SEC_SIZE], newboot[SEC_SIZE]; static unsigned char default_bpb[0x5c]; - -#ifndef WITHOEMCOMPATBS - UNREFERENCED_PARAMETER(altkern); -#endif + int bsBiosMovOff; /* offset in bs to mov [drive],dl that we NOP out */ #ifdef DEBUG - printf("Reading old bootsector from drive %c:\n", drive + 'A'); + printf("Reading old bootsector from drive %c:\n", opts->dstDrive + 'A'); #endif /* lock drive */ - generic_block_ioctl(drive + 1, 0x84a, NULL); + generic_block_ioctl(opts->dstDrive + 1, 0x84a, NULL); + + reset_drive(opts->dstDrive); - reset_drive(drive); /* suggestion: allow reading from a boot sector or image file here */ - if (MyAbsReadWrite(drive, 1, 0, oldboot, 0) != 0) + if (MyAbsReadWrite(opts->dstDrive, 1, 0, oldboot, 0) != 0) { - printf("can't read old boot sector for drive %c:\n", drive + 'A'); + printf("%s: can't read old boot sector for drive %c:\n", pgm, opts->dstDrive + 'A'); exit(1); } @@ -869,6 +1109,13 @@ void put_boot(int drive, char *bsFile, dump_sector(oldboot); #endif + /* backup original boot sector when requested */ + if (opts->bsFileOrig) + { + printf("Backing up original boot sector to %s\n", opts->bsFileOrig); + saveBS(opts->bsFileOrig, oldboot); + } + bs = (struct bootsectortype *)&oldboot; if (bs->bsBytesPerSec != SEC_SIZE) @@ -913,20 +1160,18 @@ void put_boot(int drive, char *bsFile, { printf("FAT type: FAT32\n"); /* get default bpb (but not for floppies) */ - if (drive >= 2 && - generic_block_ioctl(drive + 1, 0x4860, default_bpb) == 0) + if (opts->dstDrive >= 2 && + generic_block_ioctl(opts->dstDrive + 1, 0x4860, default_bpb) == 0) correct_bpb((struct bootsectortype *)(default_bpb + 7 - 11), bs); #ifdef WITHFAT32 /* copy one of the FAT32 boot sectors */ - #ifdef WITHOEMCOMPATBS - if (altkern >= 2) /* MS or PC compatible BS requested */ + if (!opts->kernel.stdbs) /* MS/PC DOS compatible BS requested */ { printf("%s: FAT32 versions of PC/MS DOS compatible boot sectors\n" - "are not supported [yet].\n", pgm); + "are not supported.\n", pgm); exit(1); } - #endif - + memcpy(newboot, haveLBA() ? fat32lba : fat32chs, SEC_SIZE); #else printf("SYS hasn't been compiled with FAT32 support.\n" @@ -937,24 +1182,17 @@ void put_boot(int drive, char *bsFile, else { /* copy the FAT12/16 CHS+LBA boot sector */ printf("FAT type: FAT1%c\n", fs + '0' - 10); - if (drive >= 2 && - generic_block_ioctl(drive + 1, 0x860, default_bpb) == 0) + if (opts->dstDrive >= 2 && + generic_block_ioctl(opts->dstDrive + 1, 0x860, default_bpb) == 0) correct_bpb((struct bootsectortype *)(default_bpb + 7 - 11), bs); - #ifdef WITHOEMCOMPATBS + + if (opts->kernel.stdbs) { - unsigned char * bs; - if (altkern >= 2) - { - printf("Using PC-DOS compatible boot sector.\n"); - bs = (fs == FAT16) ? oemfat16 : oemfat12; - } - else - bs = (fs == FAT16) ? fat16com : fat12com; - memcpy(newboot, bs, SEC_SIZE); + printf("Using PC-DOS compatible boot sector.\n"); + memcpy(newboot, (fs == FAT16) ? oemfat16 : oemfat12, SEC_SIZE); } - #else - memcpy(newboot, fs == FAT16 ? fat16com : fat12com, SEC_SIZE); - #endif + else + memcpy(newboot, (fs == FAT16) ? fat16com : fat12com, SEC_SIZE); } /* Copy disk parameter from old sector to new sector */ @@ -970,24 +1208,32 @@ void put_boot(int drive, char *bsFile, /* originally OemName was "FreeDOS", changed for better compatibility */ memcpy(bs->OemName, "FRDOS4.1", 8); - /* allow user to override default of use BIOS provided boot drive # */ - bootdrive = (bootdrive < 0)? (drive < 2 ? 0 : 0xff) : bootdrive; - #ifdef WITHFAT32 if (fs == FAT32) { bs32 = (struct bootsectortype32 *)&newboot; - /* put 0 for A: or B: (force booting from A:), otherwise use DL */ - bs32->bsDriveNumber = bootdrive; + bs32->bsDriveNumber = opts->defBootDrive; + /* the location of the "0060" segment portion of the far pointer in the boot sector is just before cont: in boot*.asm. - This happens to be offset 0x78 (=0x3c * 2) for FAT32 and - offset 0x5c (=0x2e * 2) for FAT16 */ - /* i.e. BE CAREFUL WHEN YOU CHANGE THE BOOT SECTORS !!! */ - #ifdef WITHOEMCOMPATBS - if (altkern < 2) /* PC-DOS compatible bs has fixed load sector */ - #endif - ((int *)newboot)[0x3C] = load_seg; + This happens to be offset 0x78 for FAT32 and offset 0x5c for FAT16 + + force use of value stored in bs by NOPping out mov [drive], dl + 0x82: 88h,56h,40h for fat32 chs & lba boot sectors + + i.e. BE CAREFUL WHEN YOU CHANGE THE BOOT SECTORS !!! + */ + if (opts->kernel.stdbs) + { + ((int *)newboot)[0x78/sizeof(int)] = opts->kernel.loadseg; + bsBiosMovOff = 0x82; + } + else /* compatible bs */ + { + printf("%s: INTERNAL ERROR: how did you get here?\n", pgm); + exit(1); + } + #ifdef DEBUG printf(" FAT starts at sector %lx + %x\n", bs32->bsHiddenSecs, bs32->bsResSectors); @@ -996,12 +1242,47 @@ void put_boot(int drive, char *bsFile, else #endif { - /* put 0 for A: or B: (force booting from A:), otherwise use DL */ - bs->bsDriveNumber = bootdrive; - #ifdef WITHOEMCOMPATBS - if (altkern < 2) /* PC-DOS compatible bs has fixed load sector */ - #endif - ((int *)newboot)[0x2E] = load_seg; + + /* establish default BIOS drive # set in boot sector */ + bs->bsDriveNumber = opts->defBootDrive; + + /* the location of the "0060" segment portion of the far pointer + in the boot sector is just before cont: in boot*.asm. + This happens to be offset 0x78 for FAT32 and offset 0x5c for FAT16 + + force use of value stored in bs by NOPping out mov [drive], dl + 0x66: 88h,56h,24h for fat16 and fat12 boot sectors + 0x4F: 88h,56h,24h for oem compatible fat16 and fat12 boot sectors + + i.e. BE CAREFUL WHEN YOU CHANGE THE BOOT SECTORS !!! + */ + if (opts->kernel.stdbs) + { + ((int *)newboot)[0x5c/sizeof(int)] = opts->kernel.loadseg; + bsBiosMovOff = 0x66; + } + else + { + /* load segment hard coded to 0x70 in oem compatible boot sector */ + if (opts->kernel.loadseg != 0x70) + printf("%s: Warning: ignoring load segment, compat bs always uses 0x70!\n"); + bsBiosMovOff = 0x4F; + } + } + + if (opts->ignoreBIOS) + { + if ( ((int *)newboot)[bsBiosMovOff/sizeof(int)] == 0x5688 ) + { + newboot[bsBiosMovOff] = 0x90; /* NOP */ ++bsBiosMovOff; + newboot[bsBiosMovOff] = 0x90; /* NOP */ ++bsBiosMovOff; + newboot[bsBiosMovOff] = 0x90; /* NOP */ ++bsBiosMovOff; + } + else + { + printf("%s : fat boot sector does not match expected layout\n", pgm); + exit(1); + } } #ifdef DEBUG /* add an option to display this on user request? */ @@ -1015,20 +1296,20 @@ void put_boot(int drive, char *bsFile, { int i = 0; memset(&newboot[0x1f1], ' ', 11); - while (kernel_name[i] && kernel_name[i] != '.') + while (opts->kernel.kernel[i] && opts->kernel.kernel[i] != '.') { if (i < 8) - newboot[0x1f1+i] = toupper(kernel_name[i]); + newboot[0x1f1+i] = toupper(opts->kernel.kernel[i]); i++; } - if (kernel_name[i] == '.') + if (opts->kernel.kernel[i] == '.') { /* copy extension */ int j = 0; i++; - while (kernel_name[i+j] && j < 3) + while (opts->kernel.kernel[i+j] && j < 3) { - newboot[0x1f9+j] = toupper(kernel_name[i+j]); + newboot[0x1f9+j] = toupper(opts->kernel.kernel[i+j]); j++; } } @@ -1037,7 +1318,7 @@ void put_boot(int drive, char *bsFile, #ifdef DEBUG /* there's a zero past the kernel name in all boot sectors */ printf("Boot sector kernel name set to %s\n", &newboot[0x1f1]); - printf("Boot sector load segment set to %Xh\n", load_seg); + printf("Boot sector load segment set to %Xh\n", opts->kernel.loadseg); #endif #ifdef DDEBUG @@ -1045,50 +1326,33 @@ void put_boot(int drive, char *bsFile, dump_sector(newboot); #endif - if ((bsFile == NULL) || both) + if (opts->writeBS) { - #ifdef DEBUG - printf("writing new bootsector to drive %c:\n", drive + 'A'); + printf("writing new bootsector to drive %c:\n", opts->dstDrive + 'A'); #endif /* write newboot to a drive */ - if (MyAbsReadWrite(drive, 1, 0, newboot, 1) != 0) + if (MyAbsReadWrite(opts->dstDrive, 1, 0, newboot, 1) != 0) { - printf("Can't write new boot sector to drive %c:\n", drive + 'A'); + printf("Can't write new boot sector to drive %c:\n", opts->dstDrive + 'A'); exit(1); } - } /* if write boot sector */ + } /* if write boot sector to boot record*/ - if (bsFile != NULL) + if (opts->bsFile != NULL) { - int fd; - #ifdef DEBUG - printf("writing new bootsector to file %s\n", bsFile); + printf("writing new bootsector to file %s\n", opts->bsFile); #endif - /* write newboot to bsFile */ - if ((fd = /* suggestion: do not trunc - allows to write to images */ - open(bsFile, O_RDWR | O_TRUNC | O_CREAT | O_BINARY, - S_IREAD | S_IWRITE)) < 0) - { - printf(" %s: can't create\"%s\"\nDOS errnum %d", pgm, bsFile, errno); - exit(1); - } - if (write(fd, newboot, SEC_SIZE) != SEC_SIZE) - { - printf("Can't write %u bytes to %s\n", SEC_SIZE, bsFile); - close(fd); - unlink(bsFile); - exit(1); - } - close(fd); - } /* if write boot sector file */ - reset_drive(drive); + saveBS(opts->bsFile, newboot); + } /* if write boot sector to file*/ + + reset_drive(opts->dstDrive); /* unlock_drive */ - generic_block_ioctl(drive + 1, 0x86a, NULL); + generic_block_ioctl(opts->dstDrive + 1, 0x86a, NULL); } /* put_boot */ @@ -1123,51 +1387,22 @@ BOOL check_space(COUNT drive, ULONG bytes) } /* check_space */ -/* returns TRUE if file exists, FALSE otherwise - 1st checks for srcPath + filename, if that does not exist then - will check for rootPath + filename - On failure, source is undefined. source must be >= SYS_MAXPATH bytes - */ -BOOL get_full_path(BYTE * srcPath, BYTE * rootPath, BYTE * filename, BYTE *source) -{ - struct stat fstatbuf; - - strcpy(source, srcPath); - if (rootPath != NULL) /* trick for comspec, append filename if srcPath doesn't include it */ - strcat(source, filename); - - /* check if file exists in source directory */ - if (stat(source, &fstatbuf)) - { - /* not found in source path, so try root of source drive */ - if ((rootPath != NULL) && (*rootPath) /* && (errno == ENOENT) */ ) - { - sprintf(source, "%s%s", rootPath, filename); - if (stat(source, &fstatbuf)) - return FALSE; - } - else - return FALSE; - } - return TRUE; -} /* get_full_path */ - BYTE copybuffer[COPY_SIZE]; /* copies file (path+filename specified by srcFile) to drive:\filename */ -BOOL copy(BYTE *source, COUNT drive, BYTE * filename) +BOOL copy(const BYTE *source, COUNT drive, const BYTE * filename) { + static BYTE src[SYS_MAXPATH]; static BYTE dest[SYS_MAXPATH]; unsigned ret; int fdin, fdout; ULONG copied = 0; - printf("\nCopying %s...\n", source); + printf("Copying %s...\n", source); - truename(dest, source); - strcpy(source, dest); + truename(src, source); sprintf(dest, "%c:\\%s", 'A' + drive, filename); - if (stricmp(source, dest) == 0) + if (stricmp(src, dest) == 0) { printf("%s: source and destination are identical: skipping \"%s\"\n", pgm, source); From e90387e6ddb591685bbea30515b891db355619f4 Mon Sep 17 00:00:00 2001 From: Kenneth J Davis Date: Sun, 19 Dec 2004 21:35:14 +0000 Subject: [PATCH 591/671] change comments to old C style (oops, TC fix) git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/branches/UNSTABLE@1073 6ac86273-5f31-0410-b378-82cca8765d1b --- sys/sys.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/sys/sys.c b/sys/sys.c index e3b79f90..dfa5b607 100644 --- a/sys/sys.c +++ b/sys/sys.c @@ -272,11 +272,11 @@ int FDKrnConfigMain(int argc, char **argv); boot sector (optionally included). */ typedef struct DOSBootFiles { - const char * kernel; // filename boot sector loads and chains to - const char * dos; // optional secondary file for OS - WORD loadseg; // segment kernel file expects to start at - BOOL stdbs; // use FD boot sector (T) or oem compat one (F) - LONG minsize; // smallest dos file can be and be valid, 0=existance optional + const char * kernel; /* filename boot sector loads and chains to */ + const char * dos; /* optional secondary file for OS */ + WORD loadseg; /* segment kernel file expects to start at */ + BOOL stdbs; /* use FD boot sector (T) or oem compat one (F) */ + LONG minsize; /* smallest dos file can be and be valid, 0=existance optional */ } DOSBootFiles; DOSBootFiles bootFiles[] = { /* Note: This order is the order OEM:AUTO uses to determine DOS flavor. */ From 4de23bcebfe5dd3beb7b76ea71cc78cc1dbce5b1 Mon Sep 17 00:00:00 2001 From: Kenneth J Davis Date: Sun, 19 Dec 2004 22:16:40 +0000 Subject: [PATCH 592/671] handle block drivers that indicate load failure just by returning units = 0 git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/branches/UNSTABLE@1074 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/config.c | 3 ++- kernel/main.c | 12 +++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/kernel/config.c b/kernel/config.c index 4541eaf9..48ea0486 100644 --- a/kernel/config.c +++ b/kernel/config.c @@ -1443,7 +1443,8 @@ STATIC BOOL LoadDevice(PCStr p, VFP top, int mode) do { struct dhdr FAR *dhp = MK_PTR(struct dhdr, base, next); - if ((ret = init_device(dhp, szBuf, mode, &top)) != SUCCESS) + /* init_device returns FALSE on SUCCESS, TRUE otherwise */ + if ((ret = init_device(dhp, szBuf, mode, &top))) break; next = FP_OFF(dhp->dh_next); diff --git a/kernel/main.c b/kernel/main.c index 714354ec..ca2b4d28 100644 --- a/kernel/main.c +++ b/kernel/main.c @@ -478,6 +478,7 @@ BOOL init_device(struct dhdr FAR * dhp, PCStr cmdLine, int mode, VFP *r_top) if (r_top) { /* Don't link in device drivers which do not take up memory */ + /* ie device drivers that fail to load and return top==CS:0 */ if (rq.r_endaddr == (BYTE FAR *) dhp) return TRUE; @@ -530,10 +531,15 @@ BOOL init_device(struct dhdr FAR * dhp, PCStr cmdLine, int mode, VFP *r_top) *r_top = rq.r_endaddr; } - if (!(dhp->dh_attr & ATTR_CHAR) && (rq.r_nunits != 0)) + if (!(dhp->dh_attr & ATTR_CHAR)) /* if block device (not character) */ { - dhp->dh_name[0] = rq.r_nunits; - update_dcb(dhp); + if (rq.r_nunits) /* if unit count is nonzero */ + { + dhp->dh_name[0] = rq.r_nunits; + update_dcb(dhp); + } + else /* returned unit count of 0, indication of load failure */ + return TRUE; } if (dhp->dh_attr & ATTR_CONIN) From fc19c3584f94e6152085ebcb67c1a10d0c244fc5 Mon Sep 17 00:00:00 2001 From: Kenneth J Davis Date: Sun, 19 Dec 2004 22:37:16 +0000 Subject: [PATCH 593/671] fix TC build (remove signed/unsigned mix warning) git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/branches/UNSTABLE@1075 6ac86273-5f31-0410-b378-82cca8765d1b --- docs/history.txt | 2 ++ kernel/config.c | 4 ++-- sys/sys.c | 6 +++--- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/docs/history.txt b/docs/history.txt index 9318f9de..e640cba6 100644 --- a/docs/history.txt +++ b/docs/history.txt @@ -380,6 +380,8 @@ - update to include all CONFIG.SYS options (except ANYDOS) * boot.asm - use static read buffer to avoid crossing 64KB boundary + * main.c + - treat block devices returning 0 units as load failure * oemboot.asm - add [optional] PC/MS DOS compatible boot sector * sys.c - incorporate changes from/for DR-DOS enhancement project diff --git a/kernel/config.c b/kernel/config.c index 48ea0486..a2f6cd47 100644 --- a/kernel/config.c +++ b/kernel/config.c @@ -1444,8 +1444,8 @@ STATIC BOOL LoadDevice(PCStr p, VFP top, int mode) { struct dhdr FAR *dhp = MK_PTR(struct dhdr, base, next); /* init_device returns FALSE on SUCCESS, TRUE otherwise */ - if ((ret = init_device(dhp, szBuf, mode, &top))) - break; + ret = init_device(dhp, szBuf, mode, &top); + if (ret) break; next = FP_OFF(dhp->dh_next); diff --git a/sys/sys.c b/sys/sys.c index dfa5b607..c6ca0b7d 100644 --- a/sys/sys.c +++ b/sys/sys.c @@ -987,7 +987,7 @@ void correct_bpb(struct bootsectortype *default_bpb, } /* reads in boot sector (1st SEC_SIZE bytes) from file */ -void readBS(const char *bsFile, BYTE *bootsector) +void readBS(const char *bsFile, UBYTE *bootsector) { if (bsFile != NULL) { @@ -1018,7 +1018,7 @@ void readBS(const char *bsFile, BYTE *bootsector) /* write bs in bsFile to drive's boot record unmodified */ void restoreBS(const char *bsFile, int drive) { - unsigned char bootsector[SEC_SIZE]; + UBYTE bootsector[SEC_SIZE]; if (bsFile == NULL) { @@ -1047,7 +1047,7 @@ void restoreBS(const char *bsFile, int drive) } /* write bootsector to file bsFile */ -void saveBS(const char *bsFile, BYTE *bootsector) +void saveBS(const char *bsFile, UBYTE *bootsector) { if (bsFile != NULL) { From d3482e2c869159886e41b2679583ec98890813b5 Mon Sep 17 00:00:00 2001 From: Kenneth J Davis Date: Mon, 20 Dec 2004 00:13:32 +0000 Subject: [PATCH 594/671] corrections for prior sys changes git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/branches/UNSTABLE@1076 6ac86273-5f31-0410-b378-82cca8765d1b --- sys/sys.c | 39 ++++++++++++++++++++++++++++----------- 1 file changed, 28 insertions(+), 11 deletions(-) diff --git a/sys/sys.c b/sys/sys.c index c6ca0b7d..e3ea7951 100644 --- a/sys/sys.c +++ b/sys/sys.c @@ -152,12 +152,14 @@ int write(int fd, const void *buf, unsigned count) #define close _dos_close -int stat(const char *file_name, struct stat *buf) +int stat(const char *file_name, struct stat *statbuf) { struct find_t find_tbuf; - UNREFERENCED_PARAMETER(buf); - return _dos_findfirst(file_name, _A_NORMAL | _A_HIDDEN | _A_SYSTEM, &find_tbuf); + int ret = _dos_findfirst(file_name, _A_NORMAL | _A_HIDDEN | _A_SYSTEM, &find_tbuf); + statbuf->st_size = (off_t)find_tbuf.size; + /* statbuf->st_attr = (ULONG)find_tbuf.attrib; */ + return ret; } /* WATCOM's getenv is case-insensitive which wastes a lot of space @@ -297,6 +299,16 @@ DOSBootFiles bootFiles[] = { #define OEM_MS 3 /* use PC-DOS compatible BS with MS names */ #define OEM_W9x 4 /* use FreeDOS boot sector but with MS names */ +CONST char * msgDOS[DOSFLAVORS] = { + "\n", /* In standard FreeDOS mode, don't print anything special */ + "DR DOS (OpenDOS Enhancement Project) mode\n", +#ifdef WITHOEMCOMPATBS + "PC-DOS compatibility mode\n", + "MS-DOS compatibility mode\n", +#endif + "Win9x DOS compatibility mode\n", +}; + typedef struct SYSOptions { BYTE srcDrive[SYS_MAXPATH]; /* source drive:[path], root assumed if no path */ BYTE dstDrive; /* destination drive [STD SYS option] */ @@ -512,8 +524,8 @@ void initOptions(int argc, char *argv[], SYSOptions *opts) { int slen; /* set source path, reserving room to append filename */ - if ( (argv[drivearg][1] == ':') || (argv[drivearg][1] == '\\') ) - strncpy(opts->srcDrive, argv[drivearg], SYS_MAXPATH-13); + if ( (argv[srcarg][1] == ':') /* || ((argv[srcarg][0]=='\\') && (argv[srcarg][1] == '\\'))*/ ) + strncpy(opts->srcDrive, argv[srcarg], SYS_MAXPATH-13); else /* only path provided, append to default drive */ strncat(opts->srcDrive, argv[srcarg], SYS_MAXPATH-15); slen = strlen(opts->srcDrive); @@ -584,9 +596,12 @@ void initOptions(int argc, char *argv[], SYSOptions *opts) } } } + /* if unable to determine DOS, assume FreeDOS */ if (opts->flavor == OEM_AUTO) opts->flavor = OEM_FD; + printf(msgDOS[opts->flavor]); + /* set compatibility settings not explicitly set */ if (!opts->kernel.kernel) opts->kernel.kernel = bootFiles[opts->flavor].kernel; if (!opts->kernel.dos) opts->kernel.dos = bootFiles[opts->flavor].dos; @@ -657,7 +672,7 @@ int main(int argc, char **argv) SYSOptions opts; /* boot options and other flags */ BYTE srcFile[SYS_MAXPATH]; /* full path+name of [kernel] file [to copy] */ - printf("FreeDOS System Installer " SYS_VERSION ", " __DATE__ "\n\n"); + printf("FreeDOS System Installer " SYS_VERSION ", " __DATE__ "\n"); if (argc > 1 && memicmp(argv[1], "CONFIG", 6) == 0) { @@ -1132,7 +1147,7 @@ void put_boot(SYSOptions *opts) ULONG fatSize, totalSectors, dataSectors, clusters; UCOUNT rootDirSectors; - bs32 = (struct bootsectortype32 *)&oldboot; + bs32 = (struct bootsectortype32 *)bs; rootDirSectors = (bs->bsRootDirEnts * DIRENT_SIZE /* 32 */ + bs32->bsBytesPerSec - 1) / bs32->bsBytesPerSec; fatSize = bs32->bsFATsecs ? bs32->bsFATsecs : bs32->bsBigFatSize; @@ -1187,12 +1202,14 @@ void put_boot(SYSOptions *opts) correct_bpb((struct bootsectortype *)(default_bpb + 7 - 11), bs); if (opts->kernel.stdbs) + { + memcpy(newboot, (fs == FAT16) ? fat16com : fat12com, SEC_SIZE); + } + else { - printf("Using PC-DOS compatible boot sector.\n"); + printf("Using OEM (PC/MS-DOS) compatible boot sector.\n"); memcpy(newboot, (fs == FAT16) ? oemfat16 : oemfat12, SEC_SIZE); } - else - memcpy(newboot, (fs == FAT16) ? fat16com : fat12com, SEC_SIZE); } /* Copy disk parameter from old sector to new sector */ @@ -1272,7 +1289,7 @@ void put_boot(SYSOptions *opts) if (opts->ignoreBIOS) { - if ( ((int *)newboot)[bsBiosMovOff/sizeof(int)] == 0x5688 ) + if ( (newboot[bsBiosMovOff]==0x88) && (newboot[bsBiosMovOff+1]==0x56) ) { newboot[bsBiosMovOff] = 0x90; /* NOP */ ++bsBiosMovOff; newboot[bsBiosMovOff] = 0x90; /* NOP */ ++bsBiosMovOff; From 47137fde936d8548ebc460b419e9ddf6a6b4ddf9 Mon Sep 17 00:00:00 2001 From: Kenneth J Davis Date: Wed, 22 Dec 2004 12:11:00 +0000 Subject: [PATCH 595/671] add some debug messages, use master_env even if no SET= in config.sys, cosmetic changes to sys git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/branches/UNSTABLE@1077 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/config.c | 13 +++++++--- kernel/task.c | 67 ++++++++++++++++++++++++++++++++++++++++++++++++- sys/sys.c | 8 +++--- 3 files changed, 80 insertions(+), 8 deletions(-) diff --git a/kernel/config.c b/kernel/config.c index a2f6cd47..439a5ef0 100644 --- a/kernel/config.c +++ b/kernel/config.c @@ -129,6 +129,10 @@ struct config Config = { /* unsigned ebda2move; */ 0, /* value for SWITCHES=/E:nnnn */ }; +/* master_env copied over command line area in + DOS_PSP, thus its size limited to 128 bytes */ +static char master_env[128] = "PATH=."; + STATIC seg_t base_seg BSS_INIT(0); STATIC seg_t umb_base_seg BSS_INIT(0); VFP lpTop BSS_INIT(0); @@ -293,6 +297,9 @@ void PreConfig(void) #ifdef DEBUG printf("Preliminary allocation completed: top at %p\n", lpTop); #endif + + /* initialize environment */ + fmemcpy(MK_PTR(char, DOS_PSP + 8, 0), master_env, sizeof(master_env)); } static void KernelAllocSFT(sfttbl FAR *p, unsigned files, int high) @@ -2066,8 +2073,8 @@ STATIC void _CmdInstall(PCStr p, int mode) if (len > sizeof args.ctBuffer - 2) len = sizeof args.ctBuffer - 2; /* trim too long line */ args.ctCount = (UBYTE)len; - args.ctBuffer[len] = '\r'; - args.ctBuffer[len+1] = 0; + args.ctBuffer[len-2] = '\r'; + args.ctBuffer[len-1] = '\0'; memcpy(args.ctBuffer, p, len); set_strategy(mode); @@ -2109,7 +2116,7 @@ VOID DoInstall(void) /* master_env copied over command line area in DOS_PSP, thus its size limited to 128 bytes */ -static char master_env[128] = "PATH=."; +/* static char master_env[128] = "PATH=."; */ /* !!! dirty hack: because bug in old FreeCOM, which wrongly process empty environment in MS-DOS style, garbage empty diff --git a/kernel/task.c b/kernel/task.c index 454328c2..507b26b4 100644 --- a/kernel/task.c +++ b/kernel/task.c @@ -136,7 +136,7 @@ STATIC int ChildEnv(seg_t env_seg, seg_t *penv_seg, const char far *path) { seg_t dst_seg = *penv_seg + 1; - /* enviornment contains: + /* environment contains: - 0 or more ASCIIZ strings (with variable definitions); - empty ASCIIZ string (one null character); - 16-bit counter (usually 1); @@ -151,6 +151,45 @@ STATIC int ChildEnv(seg_t env_seg, seg_t *penv_seg, const char far *path) *MK_PTR(UWORD, dst_seg, env_sz + 2) = 1; fstrcpy(MK_PTR(char, dst_seg, env_sz + 4), PriPathName); } + +#if DEBUG + { + seg_t dst_seg = *penv_seg + 1; + int i; + + printf("ChildEnv. env seg=0x%02x\n", dst_seg); + if (dst_seg) + { + const char FAR*p = MK_PTR(const char, dst_seg, 0); + /* loop through ASCIIZ env variables */ + if (*p) + while (*p) + { + printf("["); + for (; *p; p++) + if (*p == ' ') printf(""); + else printf("%c", *p); + printf("]\n"); + p++; + } + else + p++; /* even empty env must have 1 ("") ASCIIZ string */ + /* may be followed by empty string (just \0), 16bit count, ASCIIZ argv[0] */ + printf("End of Env marker = 0x%02x (should be 0)\n", *p); + printf("argv[0] present = %u\n", *MK_PTR(UWORD, dst_seg, env_sz + 2)); + p+=3; /* skip 16bit count and point to argv[0] */ + if (*p) + { + for (i = 0; p[i] && (i < 127); i++) + printf("%c", p[i]); + printf("\n"); + } + else + printf("No program name (argv[0]) supplied\n"); + } + } +#endif + return SUCCESS; } @@ -292,6 +331,32 @@ static void load_transfer(seg_t ds, exec_blk *ep, int mode) fcbcode = (get_cds1(p->ps_fcb1.fcb_drive) ? 0 : 0xff) | (get_cds1(p->ps_fcb2.fcb_drive) ? 0 : 0xff00); +#ifdef DEBUG + { + int i, ctCount=ep->exec.cmd_line->ctCount; + /* display full command line */ + if (ctCount > 127) + { + printf("load_transfer. CommantTail=%d count exceeds 127\n", ctCount); + ctCount = 127; + } + printf("load_transfer. CommandTail is:\n"); + /* use loop in case tail not '\0' terminated */ + if (ctCount) + { + for (i=0; i < ctCount; i++) + if (ep->exec.cmd_line->ctBuffer[i] == ' ') + printf(""); + else + printf("%c", ep->exec.cmd_line->ctBuffer[i]); + printf("\n"); + } + else + printf("\n"); + } +#endif + + /* Transfer control to the executable */ if (mode == LOADNGO) { diff --git a/sys/sys.c b/sys/sys.c index e3ea7951..ed55d358 100644 --- a/sys/sys.c +++ b/sys/sys.c @@ -660,7 +660,7 @@ void initOptions(int argc, char *argv[], SYSOptions *opts) char *comspec = getenv("COMSPEC"); if (opts->fnCmd || (comspec == NULL) || stat(comspec, &fstatbuf)) { - printf("%s: failed to find command interpreter (shell) file %s\n", pgm, (opts->fnCmd)?opts->fnCmd:"COMMAND.COM"); + printf("%s: failed to find command interpreter (shell) file %s\n", pgm, srcFile); exit(1); } } @@ -711,7 +711,7 @@ int main(int argc, char **argv) { char *comspec = getenv("COMSPEC"); if (!opts.fnCmd && (comspec != NULL)) - printf("%s: Trying shell from %COMSPEC%=\"%s\"\n", pgm, comspec); + printf("%s: Trying shell from %%COMSPEC%%=\"%s\"\n", pgm, comspec); if (opts.fnCmd || (comspec == NULL) || !copy(comspec, opts.dstDrive, "COMMAND.COM")) { printf("\n%s: failed to find command interpreter (shell) file %s\n", pgm, (opts.fnCmd)?opts.fnCmd:"COMMAND.COM"); @@ -1443,7 +1443,7 @@ BOOL copy(const BYTE *source, COUNT drive, const BYTE * filename) open(dest, O_RDWR | O_TRUNC | O_CREAT | O_BINARY, S_IREAD | S_IWRITE)) < 0) { - printf(" %s: can't create\"%s\"\nDOS errnum %d", pgm, dest, errno); + printf(" %s: can't create\"%s\"\nDOS errnum %d\n", pgm, dest, errno); close(fdin); return FALSE; } @@ -1486,7 +1486,7 @@ BOOL copy(const BYTE *source, COUNT drive, const BYTE * filename) }; #endif - printf("%lu Bytes transferred", copied); + printf("%lu Bytes transferred\n", copied); return TRUE; } /* copy */ From 79be05f804b00463885cdd37d613bf413938d365 Mon Sep 17 00:00:00 2001 From: Luchezar Georgiev Date: Wed, 29 Dec 2004 19:27:31 +0000 Subject: [PATCH 596/671] Remove hack in Int 21h AH=38h, revert bad change in _CmdInstall git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/branches/UNSTABLE@1078 6ac86273-5f31-0410-b378-82cca8765d1b --- docs/history.txt | 1 + kernel/config.c | 4 ++-- kernel/inthndlr.c | 33 +++++++++------------------------ 3 files changed, 12 insertions(+), 26 deletions(-) diff --git a/docs/history.txt b/docs/history.txt index e640cba6..88455059 100644 --- a/docs/history.txt +++ b/docs/history.txt @@ -315,6 +315,7 @@ - set AX = ES after Int 21h/4Ah (undocumented but expected by BRUN45) (the last 2 changes needed to fix bugs discovered by Michael Devore) - added Int 2Fh/2Fh processing to set DOS version as per MS-DOS 4.0 + - optimised Int 21h/AH=38h Get Country Information, removed cntry hack * autoexec.bat now single-line for FreeCOM compatibility when EOL=LF * break.c: check_handle_break() return was undefined if no Ctrl-break * config.sys: all commands removed as they were close to defaults diff --git a/kernel/config.c b/kernel/config.c index 439a5ef0..6a8e6c72 100644 --- a/kernel/config.c +++ b/kernel/config.c @@ -2073,8 +2073,8 @@ STATIC void _CmdInstall(PCStr p, int mode) if (len > sizeof args.ctBuffer - 2) len = sizeof args.ctBuffer - 2; /* trim too long line */ args.ctCount = (UBYTE)len; - args.ctBuffer[len-2] = '\r'; - args.ctBuffer[len-1] = '\0'; + args.ctBuffer[len] = '\r'; + args.ctBuffer[len+1] = '\0'; memcpy(args.ctBuffer, p, len); set_strategy(mode); diff --git a/kernel/inthndlr.c b/kernel/inthndlr.c index 53c6168a..53b55981 100644 --- a/kernel/inthndlr.c +++ b/kernel/inthndlr.c @@ -106,8 +106,8 @@ VOID ASMCFUNC int21_syscall(iregs FAR * irp) irp->DH = version_flags; /* bit3:runs in ROM,bit 4: runs in HMA */ break; - case 0x03: /* DOS 7 does not set AL */ - case 0x07: /* neither here */ + /* case 0x03: */ /* DOS 7 does not set AL */ + /* case 0x07: */ /* neither here */ default: /* set AL=0xFF as error, NOT carry */ irp->AL = 0xff; @@ -124,10 +124,8 @@ VOID ASMCFUNC int21_syscall(iregs FAR * irp) case 0xfd: bDumpRdWrParms = !bDumpRdWrParms; break; -#endif /* Toggle DOS-C syscall trace dump */ -#ifdef DEBUG case 0xfe: bDumpRegs = !bDumpRegs; break; @@ -596,7 +594,6 @@ VOID ASMCFUNC int21_service(iregs FAR * r) default: #ifdef DEBUG printf("Unsupported INT21 AH = 0x%x, AL = 0x%x.\n", lr.AH, lr.AL); -#endif /* Fall through. */ /* CP/M compatibility functions */ @@ -608,6 +605,7 @@ VOID ASMCFUNC int21_service(iregs FAR * r) case 0x61: #endif case 0x6b: +#endif lr.AL = 0; break; @@ -731,10 +729,9 @@ VOID ASMCFUNC int21_service(iregs FAR * r) UBYTE FAR *retp = MK_FP(r->cs, r->ip); if (retp[0] == 0x3d && /* cmp ax, xxyy */ - (retp[3] == 0x75 || retp[3] == 0x74)) /* je/jne error */ + retp[3] == 0x74) /* jne error */ { - lr.AL = retp[1]; - lr.AH = retp[2]; + lr.AX = *(UWORD FAR *)&retp[1]; } #if TOM /* Disable the much rarer case to save code size. The only MS-DOS * utility featuring it is DOSKEY, and FreeCom almost replaces it @@ -836,30 +833,18 @@ VOID ASMCFUNC int21_service(iregs FAR * r) /* Get/Set Country Info */ case 0x38: { - UWORD cntry = lr.AL; - - if (cntry == 0xff) - cntry = lr.BX; + if (lr.AL != 0xff) + lr.BX = lr.AL; if (0xffff == lr.DX) { /* Set Country Code */ - rc = DosSetCountry(cntry); + rc = DosSetCountry(lr.BX); } else { - if (cntry == 0) - cntry--; /* Get Country Information */ - rc = DosGetCountryInformation(cntry, FP_DS_DX); - if (rc >= SUCCESS) - { - /* HACK FIXME */ - if (cntry == (UWORD) - 1) - cntry = 1; - /* END OF HACK */ - lr.AX = lr.BX = cntry; - } + rc = DosGetCountryInformation(lr.BX ? lr.BX : NLS_DEFAULT, FP_DS_DX); } goto short_check; } From c93f67a15bacd1a068c34219095568795829c374 Mon Sep 17 00:00:00 2001 From: Luchezar Georgiev Date: Thu, 30 Dec 2004 15:59:38 +0000 Subject: [PATCH 597/671] Fix Int 21h AH=38h bugs noted by Arkady git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/branches/UNSTABLE@1079 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/inthndlr.c | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/kernel/inthndlr.c b/kernel/inthndlr.c index 53b55981..a709aa80 100644 --- a/kernel/inthndlr.c +++ b/kernel/inthndlr.c @@ -728,8 +728,7 @@ VOID ASMCFUNC int21_service(iregs FAR * r) */ UBYTE FAR *retp = MK_FP(r->cs, r->ip); - if (retp[0] == 0x3d && /* cmp ax, xxyy */ - retp[3] == 0x74) /* jne error */ + if (retp[0] == 0x3d) /* cmp ax, xxyy */ { lr.AX = *(UWORD FAR *)&retp[1]; } @@ -833,18 +832,18 @@ VOID ASMCFUNC int21_service(iregs FAR * r) /* Get/Set Country Info */ case 0x38: { - if (lr.AL != 0xff) - lr.BX = lr.AL; - + UWORD ccode = lr.AL != 0xFF ? lr.AL : lr.BX; if (0xffff == lr.DX) { /* Set Country Code */ - rc = DosSetCountry(lr.BX); + rc = DosSetCountry(ccode); } else { /* Get Country Information */ - rc = DosGetCountryInformation(lr.BX ? lr.BX : NLS_DEFAULT, FP_DS_DX); + rc = DosGetCountryInformation(ccode ? ccode : NLS_DEFAULT, FP_DS_DX); + if (rc >= SUCCESS) + lr.BX = ccode ? ccode : nlsPackageHardcoded.cntry; } goto short_check; } @@ -959,7 +958,6 @@ VOID ASMCFUNC int21_service(iregs FAR * r) DosMemLargest(&lr.BX); if (DosMemCheck() != SUCCESS) panic("MCB chain corrupted"); - goto error_exit; } lr.AX++; /* DosMemAlloc() returns seg of MCB rather than data */ break; @@ -970,7 +968,6 @@ VOID ASMCFUNC int21_service(iregs FAR * r) { if (DosMemCheck() != SUCCESS) panic("MCB chain corrupted"); - goto error_exit; } break; @@ -990,7 +987,6 @@ VOID ASMCFUNC int21_service(iregs FAR * r) #endif if (DosMemCheck() != SUCCESS) panic("after 4a: MCB chain corrupted"); - goto error_exit; } lr.AX = lr.ES; /* Undocumented MS-DOS behaviour expected by BRUN45! */ break; @@ -1118,8 +1114,7 @@ VOID ASMCFUNC int21_service(iregs FAR * r) switch (lr.AL) { case 0x00: - lr.AL = mem_access_mode; - lr.AH = 0; + lr.AX = mem_access_mode; break; case 0x01: @@ -1204,9 +1199,7 @@ VOID ASMCFUNC int21_service(iregs FAR * r) case 0x09: rc = remote_printredir(lr.DX, Int21AX); CLEAR_CARRY_FLAG(); - if (rc != SUCCESS) - goto error_exit; - break; + goto short_check; /* Set Extended Error */ case 0x0a: @@ -1315,7 +1308,8 @@ VOID ASMCFUNC int21_service(iregs FAR * r) lr.DS = FP_SEG(p); lr.SI = FP_OFF(p); } - lr.AL = 0x00; + else + lr.AL = 0; #if 0 /* not really supported, but will pass. */ From 750b471eec31517039ef3074f6673ccc639fcb8d Mon Sep 17 00:00:00 2001 From: Luchezar Georgiev Date: Fri, 31 Dec 2004 12:46:21 +0000 Subject: [PATCH 598/671] To error is human, to forgive divine git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/branches/UNSTABLE@1080 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/inthndlr.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/kernel/inthndlr.c b/kernel/inthndlr.c index a709aa80..67cbc576 100644 --- a/kernel/inthndlr.c +++ b/kernel/inthndlr.c @@ -752,7 +752,6 @@ VOID ASMCFUNC int21_service(iregs FAR * r) return_code = lr.AL | 0x300; tsr = TRUE; return_user(); - break; /* Get default BPB */ case 0x1f: @@ -958,6 +957,7 @@ VOID ASMCFUNC int21_service(iregs FAR * r) DosMemLargest(&lr.BX); if (DosMemCheck() != SUCCESS) panic("MCB chain corrupted"); + goto error_exit; } lr.AX++; /* DosMemAlloc() returns seg of MCB rather than data */ break; @@ -968,6 +968,7 @@ VOID ASMCFUNC int21_service(iregs FAR * r) { if (DosMemCheck() != SUCCESS) panic("MCB chain corrupted"); + goto error_exit; } break; @@ -987,6 +988,7 @@ VOID ASMCFUNC int21_service(iregs FAR * r) #endif if (DosMemCheck() != SUCCESS) panic("after 4a: MCB chain corrupted"); + goto error_exit; } lr.AX = lr.ES; /* Undocumented MS-DOS behaviour expected by BRUN45! */ break; @@ -1025,7 +1027,6 @@ VOID ASMCFUNC int21_service(iregs FAR * r) StartTrace(); #endif return_user(); - break; /* Get Child-program Return Value */ case 0x4d: From a76186391fe90b3a6dcf04ee0e2826264e689d28 Mon Sep 17 00:00:00 2001 From: Luchezar Georgiev Date: Fri, 31 Dec 2004 12:53:05 +0000 Subject: [PATCH 599/671] To err is human, to forgive divine git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/branches/UNSTABLE@1081 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/inthndlr.c | 1 - 1 file changed, 1 deletion(-) diff --git a/kernel/inthndlr.c b/kernel/inthndlr.c index 67cbc576..05eafe29 100644 --- a/kernel/inthndlr.c +++ b/kernel/inthndlr.c @@ -33,7 +33,6 @@ #include "nls.h" #ifdef VERSION_STRINGS -BYTE *RcsId = "$Id$"; #endif From 2c6ba2f90e5e147a568c9c41695f2df30f4f4a3a Mon Sep 17 00:00:00 2001 From: Kenneth J Davis Date: Fri, 31 Dec 2004 21:37:51 +0000 Subject: [PATCH 600/671] use NT OW binaries on NT, add access to more options from build cmd line git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/branches/UNSTABLE@1082 6ac86273-5f31-0410-b378-82cca8765d1b --- build.bat | 37 ++++++++++++++++++++++++++++++++----- buildall.bat | 29 +++++++++++++++++++++++++---- config.b | 24 +++++------------------- defaults.bat | 42 ++++++++++++++++++++++++++++++------------ mkfiles/generic.mak | 7 ++++++- mkfiles/tc.mak | 2 -- mkfiles/watcom.mak | 1 - utils/wlinker.bat | 4 ++-- 8 files changed, 100 insertions(+), 46 deletions(-) diff --git a/build.bat b/build.bat index 48eb8267..27f2c548 100644 --- a/build.bat +++ b/build.bat @@ -3,10 +3,16 @@ :- batch file to build everything :- $Id$ -:----------------------------------------------------------------------- -:- Syntax: BUILD [-r] [fat32|fat16] [msc|wc|tc|tcpp] [86|186|386] [debug] [lfnapi] [/L #] -:- option case is significant !! -:----------------------------------------------------------------------- +if NOT "%1" == "/?" goto start +echo ":-----------------------------------------------------------------------" +echo ":- Syntax: BUILD [-r] [fat32|fat16] [msc|wc|tc|tcpp|bc] [86|186|386] " +echo ":- [debug] [lfnapi] [/L #] [/D value] " +echo ":- option case is significant !! " +echo ":- Note: Open Watcom (wc) is the preferred compiler " +echo ":-----------------------------------------------------------------------" +goto end + +:start set XERROR=1 if "%XERROR%" == "" goto noenv @@ -34,15 +40,18 @@ if "%1" == "msc" set COMPILER=MSC if "%1" == "wc" set COMPILER=WATCOM if "%1" == "tc" set COMPILER=TC if "%1" == "tcpp" set COMPILER=TCPP +if "%1" == "bc" set COMPILER=BC if "%1" == "86" set XCPU=86 if "%1" == "186" set XCPU=186 if "%1" == "386" set XCPU=386 +if "%1" == "x86" goto setCPU if "%1" == "debug" set ALLCFLAGS=%ALLCFLAGS% -DDEBUG if "%1" == "lfnapi" set ALLCFLAGS=%ALLCFLAGS% -DWITHLFNAPI if "%1" == "/L" goto setLoadSeg +if "%1" == "/D" goto setDefine :nextOption shift @@ -92,6 +101,7 @@ echo. cd ..\sys call %MAKE% all if errorlevel 1 goto abort-cd +if NOT "%XUPX%" == "" %XUPX% ..\bin\sys.com echo. echo Process KERNEL +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ @@ -117,10 +127,27 @@ goto end :setLoadSeg shift if "%1" == "" echo you MUST specify load segment eg 0x60 with /L option -if "%1" == "" goot abort +if "%1" == "" goto abort set LOADSEG=%1 goto nextOption +:setCPU +shift +if "%1" == "" echo you MUST specify compiler's cpu cmd line argument, eg -5 +if "%1" == "" goto abort +set XCPU_EX=%1 +goto nextOption + +:setDefine +shift +:- Give extra compiler DEFINE flags here +if "%1" == "" echo you MUST specify value to define with /D option +if "%1" == "" echo such as /D DEBUG : extra DEBUG output +if "%1" == "" echo or /D DOSEMU : printf output goes to dosemu log +if "%1" == "" goto abort +set ALLCFLAGS=%ALLCFLAGS% -D%1 +goto nextOption + :noenv echo Unable to set necessary environment variables! goto abort diff --git a/buildall.bat b/buildall.bat index 9785bb09..548ed33b 100644 --- a/buildall.bat +++ b/buildall.bat @@ -1,10 +1,7 @@ @echo off -:- $Id$ - :---------------------------------------------------------- -:- batch file to build _many_ KERNELS, hope build works. -:- takes 3 minutes on my(TE) Win2K/P700. your milage may vary :-) +:- batch file to build _many_ KERNELS :---------------------------------------------------------- if "%1" == "$SUMMARY" goto summary @@ -36,6 +33,30 @@ if "%XERROR%" == "" call build.bat -r tc 86 fat32 if not "%XERROR%" == "" goto daswarwohlnix :no_tc +:***** TCPP kernels + +if "%TCPP_BASE%" == "" goto no_tcpp + call build.bat -r tcpp 186 fat16 +if "%XERROR%" == "" call build.bat -r tcpp 86 fat16 +if "%XERROR%" == "" call build.bat -r tcpp 186 fat32 +if "%XERROR%" == "" call build.bat -r tcpp 86 fat32 + +if not "%XERROR%" == "" goto daswarwohlnix +:no_tcpp + +:***** BC kernels + +if "%BC_BASE%" == "" goto no_bc + call build.bat -r bc 386 fat16 +if "%XERROR%" == "" call build.bat -r bc 186 fat16 +if "%XERROR%" == "" call build.bat -r bc 86 fat16 +if "%XERROR%" == "" call build.bat -r bc 386 fat32 +if "%XERROR%" == "" call build.bat -r bc 186 fat32 +if "%XERROR%" == "" call build.bat -r bc 86 fat32 + +if not "%XERROR%" == "" goto daswarwohlnix +:no_bc + :***** (Open) Watcom kernels if "%WATCOM%" == "" goto no_wc diff --git a/config.b b/config.b index e17b41cf..84744e00 100644 --- a/config.b +++ b/config.b @@ -22,12 +22,13 @@ set LAST= :- NASM/DJGPP crashes when using protected mode Borland's make. set NASM=c:\bin\nasm16 +::set NASM=c:\bin\nasmw.exe :----------------------------------------------------------------------- :- define COMPILER name here, pick one of them. :- Turbo C 2.01 -set COMPILER=TC +:: set COMPILER=TC :- Turbo C++ 1.01 ::set COMPILER=TCPP :- Turbo C++ 3.0 @@ -37,33 +38,18 @@ set COMPILER=TC :- Microsoft C ::set COMPILER=MSC :- Watcom C -::set COMPILER=WATCOM +set COMPILER=WATCOM :----------------------------------------------------------------------- :- define BASE dir of compiler; :- may be defined for all installed compilers. -set TC_BASE=c:\tc +::set TC_BASE=c:\tc ::set TCPP_BASE=c:\tcpp ::set TCPP3_BASE=c:\tcpp3 ::set BC_BASE=c:\bc ::set MSC_BASE=c:\msc -::set WATCOM=c:\watcom - -:----------------------------------------------------------------------- -:- When compiling executable, compilers search linker through PATH; -:- if some linker not in PATH, uncomment OLDPATH and required SETs PATH. - -::set OLDPATH=%PATH% -::set PATH=%TC_BASE%;%PATH% -::set PATH=%TCPP_BASE%\bin;%PATH% -::set PATH=%TCPP3_BASE%\bin;%PATH% -::set PATH=%BC_BASE%\bin;%PATH% -::set PATH=%MSC_BASE%\bin;%PATH% -::set PATH=%WATCOM%\binw;%PATH% - -:- MSC searches libraries only through LIB variable. -::set LIB=%MSC_BASE%\lib +set WATCOM=c:\watcom :----------------------------------------------------------------------- :- define which linker to use OR it will be determined AUTOMATICALLY. diff --git a/defaults.bat b/defaults.bat index 7ae08d31..13d33132 100644 --- a/defaults.bat +++ b/defaults.bat @@ -17,12 +17,30 @@ if "%BASE%" == "" goto clearset :----------------------------------------------------------------------- +set BINPATH=%BASE%\bin +if "%COMPILER%" == "TC" set BINPATH=%BASE% +if "%COMPILER%" == "WATCOM" set BINPATH=%BASE%\binw +if "%COMPILER%" == "WATCOM" if "%OS%" == "Windows_NT" set BINPATH=%BASE%\binnt + +echo Path to compiler programs (binaries) is %BINPATH% + +:----------------------------------------------------------------------- +:- When compiling executable, compilers may invoke secondary programs +:- such as preprocessor, compiler component, or linker through PATH; + +set OLDPATH=%PATH% +set PATH=%BINPATH%;%PATH% + +:- MSC searches libraries only through LIB variable. +if "%COMPILER%" == "MSC" set LIB=%MSC_BASE%\lib + +:----------------------------------------------------------------------- + if not "%LINK%" == "" goto skip_link -set LINK=%BASE%\bin\tlink /c/m -if "%COMPILER%" == "TC" set LINK=%BASE%\tlink /c/m -if "%COMPILER%" == "WATCOM" set LINK=call ..\utils\wlinker /nologo -if "%COMPILER%" == "MSC" set LINK=%BASE%\bin\link /ONERROR:NOEXE /batch +set LINK=%BINPATH%\tlink /c/m/s/l +if "%COMPILER%" == "WATCOM" set LINK=..\utils\wlinker /nologo +if "%COMPILER%" == "MSC" set LINK=%BINPATH%\link /ONERROR:NOEXE /batch echo Linker is %LINK% @@ -32,11 +50,10 @@ echo Linker is %LINK% if not "%LIBUTIL%" == "" goto skip_lib -set LIBUTIL=%BASE%\bin\tlib +set LIBUTIL=%BINPATH%\tlib set LIBTERM= -if "%COMPILER%" == "TC" set LIBUTIL=%BASE%\tlib -if "%COMPILER%" == "WATCOM" set LIBUTIL=%BASE%\binw\wlib -q -if "%COMPILER%" == "MSC" set LIBUTIL=%BASE%\bin\lib /nologo +if "%COMPILER%" == "WATCOM" set LIBUTIL=%BINPATH%\wlib -q +if "%COMPILER%" == "MSC" set LIBUTIL=%BINPATH%\lib /nologo if "%COMPILER%" == "MSC" set LIBTERM=; echo Librarian is %LIBUTIL% @@ -47,10 +64,9 @@ echo Librarian is %LIBUTIL% if not "%MAKE%" == "" goto skip_make -set MAKE=%BASE%\bin\make -if "%COMPILER%" == "TC" set MAKE=%BASE%\make -if "%COMPILER%" == "WATCOM" set MAKE=%BASE%\binw\wmake /ms /h -if "%COMPILER%" == "MSC" set MAKE=%BASE%\bin\nmake /nologo +set MAKE=%BINPATH%\make +if "%COMPILER%" == "WATCOM" set MAKE=%BINPATH%\wmake /ms /h +if "%COMPILER%" == "MSC" set MAKE=%BINPATH%\nmake /nologo echo Make is %MAKE% @@ -68,6 +84,7 @@ if "%LAST%" == "1" goto end set NASM= set COMPILER= set BASE= +set BINPATH= set TC_BASE= set TCPP_BASE= set TCPP3_BASE= @@ -79,6 +96,7 @@ set LIBTERM= set MAKE= set XUPX= set XCPU= +set XCPU_EX= set XFAT= set ALLCFLAGS= set LOADSEG= diff --git a/mkfiles/generic.mak b/mkfiles/generic.mak index 6aae72e1..9fe65f1a 100644 --- a/mkfiles/generic.mak +++ b/mkfiles/generic.mak @@ -12,6 +12,11 @@ CPUOPT=-1 !if $(XCPU) == 386 CPUOPT=-3 !endif +# extension, if compiler supports it, specify compiler switch in XCPU_EX and set XCPU to 386 +!if $(XCPU_EX)0 != 0 +XCPU=386 +CPUOPT=$(XCPU_EX) +!endif !if $(XFAT)0 == 0 XFAT=32 @@ -23,7 +28,7 @@ NASMFLAGS=-DWITHFAT32 $(NASMFLAGS) NASMFLAGS=-fobj -i../hdr/ -D$(COMPILER) -DXCPU=$(XCPU) $(NASMFLAGS) -BINPATH=$(BASE)\bin +#BINPATH=$(BASE)\bin INCLUDEPATH=$(BASE)\include LIBPATH=$(BASE)\lib INITPATCH=@rem diff --git a/mkfiles/tc.mak b/mkfiles/tc.mak index 05fa52fa..d8bc5c04 100644 --- a/mkfiles/tc.mak +++ b/mkfiles/tc.mak @@ -2,8 +2,6 @@ # TC.MAK - kernel compiler options for Turbo C 2.01 # -BINPATH=$(BASE) - !include "..\mkfiles\tcpp.mak" TARGET=KTC diff --git a/mkfiles/watcom.mak b/mkfiles/watcom.mak index 23671fe8..f771767f 100644 --- a/mkfiles/watcom.mak +++ b/mkfiles/watcom.mak @@ -4,7 +4,6 @@ TARGET=KWC -BINPATH=$(BASE)\binw INCLUDEPATH=$(BASE)\h LIBPATH=$(BASE)\lib286 diff --git a/utils/wlinker.bat b/utils/wlinker.bat index 27ae76ad..7c7ede27 100755 --- a/utils/wlinker.bat +++ b/utils/wlinker.bat @@ -1,4 +1,4 @@ @echo off -%BASE%\binw\ms2wlink %1 %2 %3 %4 %5 %6 %7 %8 %9 ,,,, >kernel.lnk +%BINPATH%\ms2wlink %1 %2 %3 %4 %5 %6 %7 %8 %9 ,,,, >kernel.lnk echo op map,statics,verbose,eliminate,vfremoval>>kernel.lnk -%BASE%\binw\wlink @kernel.lnk +%BINPATH%\wlink @kernel.lnk From ebecfcb6b0fe5f4b296405f65dfc12230559efdb Mon Sep 17 00:00:00 2001 From: Kenneth J Davis Date: Sat, 1 Jan 2005 15:30:56 +0000 Subject: [PATCH 601/671] add dumpbs option to sys git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/branches/UNSTABLE@1083 6ac86273-5f31-0410-b378-82cca8765d1b --- docs/sys.htm | 10 ++++++++++ docs/sys.txt | 1 + sys/sys.c | 45 ++++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 55 insertions(+), 1 deletion(-) diff --git a/docs/sys.htm b/docs/sys.htm index d05b8efd..0b50839b 100644 --- a/docs/sys.htm +++ b/docs/sys.htm @@ -55,6 +55,16 @@

Options

[image or bs] file, if exists only the 1st 512 bytes will be overwritten. + /DUMPBS [path]filename + The original boot sector is written to [path]filename and + then exits. The filename may refer to any [image or bs] file, + if exists only the 1st 512 bytes will be overwritten. + Note: /backupbs is intented to provide a backup of existing + boot sector in case one wishes to restore it later (see /restorbs), + whereas /dumpbs is intended only as a convenient method to + obtain current boot sector (such as for debugging purposes or + alternate installation scenerios). + /RESTORBS [path]filename Restores original boot sector ([path]filename) and exits. The boot sector specified is written with no modifications. diff --git a/docs/sys.txt b/docs/sys.txt index a1958e57..72928696 100644 --- a/docs/sys.txt +++ b/docs/sys.txt @@ -36,6 +36,7 @@ SYS [source] dest: [bootsect] [{option}] /SKFN filename : set KERNEL.SYS input file and /OEM:FD /SCFN filename : sets COMMAND.COM input file /BACKUPBS [path]filename : save current bs before overwriting + /DUMPBS [path]filename : save current bs and exit /RESTORBS [path]filename : overwrite bs and exit SYS CONFIG /help diff --git a/sys/sys.c b/sys/sys.c index ed55d358..1fa7f171 100644 --- a/sys/sys.c +++ b/sys/sys.c @@ -30,7 +30,7 @@ /* #define DDEBUG */ #define WITHOEMCOMPATBS /* include support for OEM MS/PC DOS 3.??-6.x */ -#define SYS_VERSION "v3.5" +#define SYS_VERSION "v3.5a" #include #include @@ -325,6 +325,7 @@ typedef struct SYSOptions { } SYSOptions; +void dumpBS(const char *, int); void restoreBS(const char *, int); void put_boot(SYSOptions *opts); BOOL check_space(COUNT, ULONG); @@ -464,6 +465,14 @@ void initOptions(int argc, char *argv[], SYSOptions *opts) { opts->bsFileOrig = argv[argno]; } + else if (memicmp(argp, "DUMPBS", 6) == 0) /* save current bs and exit */ + { + if (drivearg) + dumpBS(argv[argno], (BYTE)(toupper(*(argv[drivearg])) - 'A')); + else + printf("%s: unspecified drive, unable to obtain boot sector\n", pgm); + exit(1); + } else if (memicmp(argp, "RESTORBS", 8) == 0) /* overwrite bs and exit */ { if (drivearg) @@ -1001,6 +1010,7 @@ void correct_bpb(struct bootsectortype *default_bpb, oldboot->bsHiddenSecs = default_bpb->bsHiddenSecs; } + /* reads in boot sector (1st SEC_SIZE bytes) from file */ void readBS(const char *bsFile, UBYTE *bootsector) { @@ -1093,6 +1103,39 @@ void saveBS(const char *bsFile, UBYTE *bootsector) } /* if write boot sector file */ } +/* write drive's boot record unmodified to bsFile */ +void dumpBS(const char *bsFile, int drive) +{ + UBYTE bootsector[SEC_SIZE]; + + if (bsFile == NULL) + { + printf("%s: missing filename to dump boot sector to\n", pgm); + exit(1); + } + + /* lock drive */ + generic_block_ioctl(drive + 1, 0x84a, NULL); + + reset_drive(drive); + + /* suggestion: allow reading from a boot sector or image file here */ + if (MyAbsReadWrite(drive, 1, 0, bootsector, 0) != 0) + { + printf("%s: failed to read boot sector for drive %c:\n", pgm, drive + 'A'); + exit(1); + } + + reset_drive(drive); + + /* unlock_drive */ + generic_block_ioctl(drive + 1, 0x86a, NULL); + + saveBS(bsFile, bootsector); +} + + + void put_boot(SYSOptions *opts) { #ifdef WITHFAT32 From 51adbac8fd6c2fa4de6f7cf044197510babd6b38 Mon Sep 17 00:00:00 2001 From: Kenneth J Davis Date: Sat, 1 Jan 2005 18:07:03 +0000 Subject: [PATCH 602/671] do not fail on internal driver, corrects bug 1850 fix to work with test case git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/branches/UNSTABLE@1085 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/main.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/kernel/main.c b/kernel/main.c index ca2b4d28..579ace88 100644 --- a/kernel/main.c +++ b/kernel/main.c @@ -482,6 +482,14 @@ BOOL init_device(struct dhdr FAR * dhp, PCStr cmdLine, int mode, VFP *r_top) if (rq.r_endaddr == (BYTE FAR *) dhp) return TRUE; + /* Don't link in block device drivers which indicate no units */ + if (!(dhp->dh_attr & ATTR_CHAR) && !rq.r_nunits) + { + rq.r_endaddr = (BYTE FAR *) dhp; + return TRUE; + } + + /* Fix for multisegmented device drivers: */ /* If there are multiple device drivers in a single driver file, */ /* only the END ADDRESS returned by the last INIT call should be */ @@ -531,15 +539,11 @@ BOOL init_device(struct dhdr FAR * dhp, PCStr cmdLine, int mode, VFP *r_top) *r_top = rq.r_endaddr; } - if (!(dhp->dh_attr & ATTR_CHAR)) /* if block device (not character) */ + /* if block device (not character) and unit count is nonzero */ + if (!(dhp->dh_attr & ATTR_CHAR) && rq.r_nunits) { - if (rq.r_nunits) /* if unit count is nonzero */ - { - dhp->dh_name[0] = rq.r_nunits; - update_dcb(dhp); - } - else /* returned unit count of 0, indication of load failure */ - return TRUE; + dhp->dh_name[0] = rq.r_nunits; + update_dcb(dhp); } if (dhp->dh_attr & ATTR_CONIN) @@ -615,7 +619,7 @@ STATIC VOID InitSerialPorts(VOID) booted from HD */ -static int EmulatedDriveStatus(int drive,char statusOnly) +STATIC int EmulatedDriveStatus(int drive,char statusOnly) { iregs r; char buffer[0x13]; From 784e9b7ef5f18a7143daefe75e24bcd4a58a8396 Mon Sep 17 00:00:00 2001 From: Luchezar Georgiev Date: Tue, 4 Jan 2005 19:05:08 +0000 Subject: [PATCH 603/671] Fix divide error message text git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/branches/UNSTABLE@1086 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/entry.asm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/kernel/entry.asm b/kernel/entry.asm index f7fe4c53..73c096ed 100644 --- a/kernel/entry.asm +++ b/kernel/entry.asm @@ -116,7 +116,7 @@ cpm_error: mov al,0 ; ; interrupt zero divide handler: -; print a message 'Interrupt divide by zero' +; print a message 'Interrupt divide error' ; Terminate the current process ; ; VOID INRPT far @@ -138,12 +138,12 @@ hex_loop: jae hex_loop ret -divide_by_zero_message db 0dh,0ah,'Interrupt divide by zero, stack:',0dh,0ah,0 +divide_error_message db 0dh,0ah,'Interrupt divide error, stack:',0dh,0ah,0 global reloc_call_int0_handler reloc_call_int0_handler: - mov si,divide_by_zero_message + mov si,divide_error_message zero_message_loop: mov al, [cs:si] From 3d60c864e28d7109aa90ce46a84fa1c0c403aab8 Mon Sep 17 00:00:00 2001 From: Luchezar Georgiev Date: Wed, 5 Jan 2005 16:14:59 +0000 Subject: [PATCH 604/671] Put back breaks after return_user as Pat recommends and optimise a bit git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/branches/UNSTABLE@1087 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/inthndlr.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/kernel/inthndlr.c b/kernel/inthndlr.c index 05eafe29..11f31bcf 100644 --- a/kernel/inthndlr.c +++ b/kernel/inthndlr.c @@ -244,12 +244,16 @@ int int21_fat32(lregs *r) { ULONG nfreeclst = xdffp->xdff_f.setdpbcounts.nfreeclst; ULONG cluster = xdffp->xdff_f.setdpbcounts.cluster; + + if (nfreeclst == 1 || cluster == 1) + return DE_INVLDPARM; + if (ISFAT32(dpb)) { if ((dpb->dpb_xfsinfosec == 0xffff && (nfreeclst != 0 || cluster != 0)) - || nfreeclst == 1 || nfreeclst > dpb->dpb_xsize - || cluster == 1 || cluster > dpb->dpb_xsize) + || nfreeclst > dpb->dpb_xsize + || cluster > dpb->dpb_xsize) { return DE_INVLDPARM; } @@ -259,8 +263,8 @@ int int21_fat32(lregs *r) } else { - if ((unsigned)nfreeclst == 1 || (unsigned)nfreeclst > dpb->dpb_size || - (unsigned)cluster == 1 || (unsigned)cluster > dpb->dpb_size) + if ((unsigned)nfreeclst > dpb->dpb_size || + (unsigned)cluster > dpb->dpb_size) { return DE_INVLDPARM; } @@ -411,6 +415,9 @@ VOID ASMCFUNC int21_service(iregs FAR * r) if ((lr.AH >= 0x38 && lr.AH <= 0x4F) || (lr.AH >= 0x56 && lr.AH <= 0x5c) || (lr.AH >= 0x5e && lr.AH <= 0x60) || (lr.AH >= 0x65 && lr.AH <= 0x6a) || +#ifdef WITHFAT32 + lr.AH == 0x73 || +#endif lr.AH == 0x6c) { CLEAR_CARRY_FLAG(); @@ -751,6 +758,7 @@ VOID ASMCFUNC int21_service(iregs FAR * r) return_code = lr.AL | 0x300; tsr = TRUE; return_user(); + break; /* Get default BPB */ case 0x1f: @@ -1026,6 +1034,7 @@ VOID ASMCFUNC int21_service(iregs FAR * r) StartTrace(); #endif return_user(); + break; /* Get Child-program Return Value */ case 0x4d: @@ -1442,8 +1451,6 @@ VOID ASMCFUNC int21_service(iregs FAR * r) /* DOS 7.0+ FAT32 extended functions */ case 0x73: - CLEAR_CARRY_FLAG(); - CritErrCode = SUCCESS; rc = int21_fat32(&lr); goto short_check; #endif @@ -1955,8 +1962,6 @@ VOID ASMCFUNC int2F_12_handler(struct int2f12regs r) r.BX = FP_SEG(nul_dev.dh_next); r.AX = FP_OFF(nul_dev.dh_next); - break; - case 0x2e: /* GET or SET error table addresse - ignored called by MS debug with DS != DOSDS, printf doesn't work!! */ From babd516db46c990064d94930829556a9e1e58ce6 Mon Sep 17 00:00:00 2001 From: Kenneth J Davis Date: Fri, 7 Jan 2005 21:03:00 +0000 Subject: [PATCH 605/671] fix warning to not include garbage chars git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/branches/UNSTABLE@1088 6ac86273-5f31-0410-b378-82cca8765d1b --- sys/sys.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/sys.c b/sys/sys.c index 1fa7f171..1417889d 100644 --- a/sys/sys.c +++ b/sys/sys.c @@ -1325,7 +1325,7 @@ void put_boot(SYSOptions *opts) { /* load segment hard coded to 0x70 in oem compatible boot sector */ if (opts->kernel.loadseg != 0x70) - printf("%s: Warning: ignoring load segment, compat bs always uses 0x70!\n"); + printf("%s: Warning! ignoring load segment, compat bs always uses 0x70!\n", pgm); bsBiosMovOff = 0x4F; } } From fba50f1c195dae984bb8a180a3330594f1f95173 Mon Sep 17 00:00:00 2001 From: Kenneth J Davis Date: Sun, 9 Jan 2005 11:25:44 +0000 Subject: [PATCH 606/671] fix bug 1789 and add some extra debug prints git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/branches/UNSTABLE@1089 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/dsk.c | 13 +++++++++++-- kernel/initdisk.c | 10 +++++++++- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/kernel/dsk.c b/kernel/dsk.c index 2b65b243..e7e03be4 100644 --- a/kernel/dsk.c +++ b/kernel/dsk.c @@ -673,6 +673,8 @@ STATIC WORD Genblkdev(rqptr rp, ddt * pddt) struct gblkio FAR *gblp = rp->r_io; bpb *pbpb; + DebugPrintf(("get params entry: spec=%X, type=%X, devattr=%X\n", gblp->gbio_spcfunbit,pddt->ddt_type,descflags)); + gblp->gbio_devtype = pddt->ddt_type; gblp->gbio_devattrib = descflags & 3; /* 360 kb disk in 1.2 MB drive */ @@ -680,18 +682,25 @@ STATIC WORD Genblkdev(rqptr rp, ddt * pddt) gblp->gbio_ncyl = pddt->ddt_ncyl; /* use default dpb or current bpb? */ pbpb = (gblp->gbio_spcfunbit & 1) ? &pddt->ddt_bpb : &pddt->ddt_defbpb; + /* Note: last 6 bytes of standard BPB may not be copied for + 0x60 when rp->r_cat==8 in some versions of DOS eg MSDOS5,see rbil */ #ifdef WITHFAT32 + if (rp->r_cat == 0x08) copy_size -= 6; fmemcpy(&gblp->gbio_bpb, pbpb, copy_size); #else - fmemcpy(&gblp->gbio_bpb, pbpb, sizeof(gblp->gbio_bpb)); + fmemcpy(&gblp->gbio_bpb, pbpb, sizeof(gblp->gbio_bpb)-6); #endif /*gblp->gbio_nsecs = pbpb->bpb_nsector;*/ + DebugPrintf(("get params dev spec=%X, type=%X, attrib=%X, media=%X, ncyl=%X\n", + gblp->gbio_spcfunbit, gblp->gbio_devtype, gblp->gbio_devattrib, gblp->gbio_media, gblp->gbio_ncyl)); break; } case 0x61: /* read track */ { struct gblkrw FAR *rw = rp->r_rw; - int ret = Genblockio(pddt, LBA_READ, rw->gbrw_head, rw->gbrw_cyl, + int ret; + DebugPrintf(("read track: head=%X, cyl=%X, sect=%X, nsecs=%X\n", rw->gbrw_head, rw->gbrw_cyl,rw->gbrw_sector, rw->gbrw_nsecs)); + /*int*/ ret = Genblockio(pddt, LBA_READ, rw->gbrw_head, rw->gbrw_cyl, rw->gbrw_sector, rw->gbrw_nsecs, rw->gbrw_buffer); if (ret) return ret; diff --git a/kernel/initdisk.c b/kernel/initdisk.c index a4430aaf..9307ad47 100644 --- a/kernel/initdisk.c +++ b/kernel/initdisk.c @@ -306,6 +306,7 @@ COUNT init_getdriveparm(UBYTE drive, bpb * pbpbarray) return 5; regs.a.b.h = 0x08; regs.d.b.l = drive; + /* Note: RBIL suggests setting ES:DI to 0:0 to guard against BIOS bugs */ init_call_intr(0x13, ®s); type = regs.b.b.l - 1; if (regs.flags & FLG_CARRY) @@ -316,6 +317,8 @@ COUNT init_getdriveparm(UBYTE drive, bpb * pbpbarray) type = 4; /* 5 and 4 are both 2.88 MB */ memcpy(pbpbarray, &floppy_bpbs[type & 7], sizeof(floppy_bpb)); + ((bpb *)pbpbarray)->bpb_hidden = 0; /* very important to init to 0, see bug#1789 */ + ((bpb *)pbpbarray)->bpb_huge = 0; if (type == 3) return 7; /* 1.44 MB */ @@ -597,12 +600,17 @@ void DosDefinePartition(struct DriveParamS *driveParam, pddt->ddt_defbpb.bpb_mdesc = 0xf8; pddt->ddt_defbpb.bpb_nheads = driveParam->chs.Head; pddt->ddt_defbpb.bpb_nsecs = driveParam->chs.Sector; - pddt->ddt_defbpb.bpb_nsize = 0; pddt->ddt_defbpb.bpb_hidden = pEntry->RelSect; if (pEntry->NumSect > 0xffff) + { + pddt->ddt_defbpb.bpb_nsize = 0; pddt->ddt_defbpb.bpb_huge = pEntry->NumSect; + } else + { pddt->ddt_defbpb.bpb_nsize = (UWORD) (pEntry->NumSect); + pddt->ddt_defbpb.bpb_huge = 0; + } /* sectors per cluster, sectors per FAT etc. */ CalculateFATData(pddt, pEntry->NumSect, pEntry->FileSystem); From 9de6fccc3e771dda63de4fdedfdeaab4c1709ed4 Mon Sep 17 00:00:00 2001 From: Luchezar Georgiev Date: Sun, 9 Jan 2005 20:36:21 +0000 Subject: [PATCH 607/671] Possible bugfix for Grub git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/branches/UNSTABLE@1091 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/main.c b/kernel/main.c index 579ace88..8e347440 100644 --- a/kernel/main.c +++ b/kernel/main.c @@ -259,9 +259,9 @@ STATIC void init_kernel(void) InitPrinters(); InitSerialPorts(); + init_PSPSet(DOS_PSP); set_DTA(MK_FP(DOS_PSP, 0x80)); PSPInit(); - init_PSPSet(DOS_PSP); Init_clk_driver(); From a0b903cb25d86c1856b68083209de3d9c144684b Mon Sep 17 00:00:00 2001 From: Luchezar Georgiev Date: Tue, 11 Jan 2005 07:20:07 +0000 Subject: [PATCH 608/671] Update copyright year git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/branches/UNSTABLE@1092 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/main.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/kernel/main.c b/kernel/main.c index 8e347440..30f7cdad 100644 --- a/kernel/main.c +++ b/kernel/main.c @@ -39,9 +39,8 @@ static BYTE *mainRcsId = /* The Holy Copyright Message. Do NOT remove it or you'll be cursed forever! */ static char copyright[] = -"Copyright 1995-2004 Pasquale J. Villani and The FreeDOS Project.\n" -"This free software has ABSOLUTELY NO WARRANTY and is licensed under\n" -"the GNU General Public License (http://www.gnu.org/licenses/gpl.html)\n\n"; +"Copyright 1995-2005 Pasquale J. Villani and The FreeDOS Project.\n" +"NO WARRANTY. Licensed under the GNU General Public License version 2.\n\n"; struct _KernelConfig InitKernelConfig BSS_INIT({0}); From 4fda42aafcad110f5b330b8cfbef5057ed4bce33 Mon Sep 17 00:00:00 2001 From: Luchezar Georgiev Date: Tue, 11 Jan 2005 08:56:17 +0000 Subject: [PATCH 609/671] RcsId got somehow deleted - re-add it git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/branches/UNSTABLE@1093 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/inthndlr.c | 1 + 1 file changed, 1 insertion(+) diff --git a/kernel/inthndlr.c b/kernel/inthndlr.c index 11f31bcf..b0943c24 100644 --- a/kernel/inthndlr.c +++ b/kernel/inthndlr.c @@ -33,6 +33,7 @@ #include "nls.h" #ifdef VERSION_STRINGS +BYTE *RcsId = "$Id$"; #endif From 51e7674e84582bee67dbc21c68ba06576f8af33a Mon Sep 17 00:00:00 2001 From: Luchezar Georgiev Date: Tue, 11 Jan 2005 09:10:58 +0000 Subject: [PATCH 610/671] Change divide error message text pursuant to the RBIL git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/branches/UNSTABLE@1094 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/entry.asm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/entry.asm b/kernel/entry.asm index 73c096ed..ff2e724e 100644 --- a/kernel/entry.asm +++ b/kernel/entry.asm @@ -116,7 +116,7 @@ cpm_error: mov al,0 ; ; interrupt zero divide handler: -; print a message 'Interrupt divide error' +; print a message 'Divide error' ; Terminate the current process ; ; VOID INRPT far @@ -138,7 +138,7 @@ hex_loop: jae hex_loop ret -divide_error_message db 0dh,0ah,'Interrupt divide error, stack:',0dh,0ah,0 +divide_error_message db 0dh,0ah,'Divide error, stack:',0dh,0ah,0 global reloc_call_int0_handler reloc_call_int0_handler: From ba36e777f0bd0b1be0dc4410e0c4de84d93d852a Mon Sep 17 00:00:00 2001 From: Kenneth J Davis Date: Sat, 15 Jan 2005 19:33:37 +0000 Subject: [PATCH 611/671] be more restrictive in what we consider a volume label search git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/branches/UNSTABLE@1095 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/fatdir.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/kernel/fatdir.c b/kernel/fatdir.c index 12cc5242..b66ce08d 100644 --- a/kernel/fatdir.c +++ b/kernel/fatdir.c @@ -383,9 +383,15 @@ COUNT dos_findfirst(UCOUNT attr, BYTE * name) /* Special handling - the volume id is only in the root */ /* directory and only searched for once. So we need to open */ /* the root and return only the first entry that contains the */ - /* volume id bit set. */ - if ((attr & (D_VOLID|D_DIR))==D_VOLID) + /* volume id bit set (while ignoring LFN entries). */ + /* RBIL: ignore ReaDONLY and ARCHIVE bits */ + /* For compatibility with bad search requests, only treat as */ + /* volume search if only volume bit set, else ignore it. */ + if ((attr & ~(D_RDONLY | D_ARCHIVE))==D_VOLID) i = 3; + else + attr &= ~D_VOLID; /* ignore volume mask */ + /* Now open this directory so that we can read the */ /* fnode entry and do a match on it. */ @@ -406,7 +412,7 @@ COUNT dos_findfirst(UCOUNT attr, BYTE * name) /* Copy the raw pattern from our data segment to the DTA. */ fmemcpy(dmp->dm_name_pat, SearchDir.dir_name, FNAME_SIZE + FEXT_SIZE); - if ((attr & (D_VOLID|D_DIR))==D_VOLID) + if ((attr & D_VOLID)==D_VOLID) /* search for VOL label ignore RDONLY & ARCHIVE */ { /* Now do the search */ while (dir_read(fnp) == 1) From 3acc1e41de6a00dbac7ab9265f332fbd5b46c4a7 Mon Sep 17 00:00:00 2001 From: Kenneth J Davis Date: Mon, 17 Jan 2005 18:34:10 +0000 Subject: [PATCH 612/671] tc debug build fix git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/branches/UNSTABLE@1096 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/task.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/task.c b/kernel/task.c index 507b26b4..6ab62211 100644 --- a/kernel/task.c +++ b/kernel/task.c @@ -152,7 +152,7 @@ STATIC int ChildEnv(seg_t env_seg, seg_t *penv_seg, const char far *path) fstrcpy(MK_PTR(char, dst_seg, env_sz + 4), PriPathName); } -#if DEBUG +#ifdef DEBUG { seg_t dst_seg = *penv_seg + 1; int i; From 4a2ad74a445c0a954791ed355699d223b10fcac3 Mon Sep 17 00:00:00 2001 From: Kenneth J Davis Date: Sat, 22 Jan 2005 20:45:13 +0000 Subject: [PATCH 613/671] minor build fixes (when features disabled) and merge in Udo's EnhancedDR changes git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/branches/UNSTABLE@1097 6ac86273-5f31-0410-b378-82cca8765d1b --- sys/sys.c | 119 +++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 92 insertions(+), 27 deletions(-) diff --git a/sys/sys.c b/sys/sys.c index 1417889d..fa1b9282 100644 --- a/sys/sys.c +++ b/sys/sys.c @@ -26,11 +26,26 @@ ***************************************************************/ -#define DEBUG -/* #define DDEBUG */ +#define DEBUG /* to display extra information */ +/* #define DDEBUG */ /* to enable display of sector dumps */ #define WITHOEMCOMPATBS /* include support for OEM MS/PC DOS 3.??-6.x */ +#define FDCONFIG /* include support to configure FD kernel */ +/* #define DRSYS */ /* SYS for Enhanced DR-DOS (OpenDOS enhancement Project) */ -#define SYS_VERSION "v3.5a" +#define SYS_VERSION "v3.5b" +#define SYS_NAME "FreeDOS System Installer " + + +#ifdef DRSYS /* set displayed name & drop FD kernel config */ +#undef SYS_NAME +#define SYS_NAME "Enhanced DR-DOS System Installer " +#ifdef FDCONFIG +#undef FDCONFIG +#endif +#ifdef WITHOEMCOMPATBS +#undef WITHOEMCOMPATBS +#endif +#endif #include #include @@ -263,7 +278,9 @@ struct VerifyBootSectorSize { /* (Watcom has a nice warning for this, by the way) */ }; +#ifdef FDCONFIG int FDKrnConfigMain(int argc, char **argv); +#endif /* FreeDOS sys, we default to our kernel and load segment, but if not found (or explicitly given) support OEM DOS variants @@ -280,33 +297,56 @@ typedef struct DOSBootFiles { BOOL stdbs; /* use FD boot sector (T) or oem compat one (F) */ LONG minsize; /* smallest dos file can be and be valid, 0=existance optional */ } DOSBootFiles; +#define FREEDOS_FILES { "KERNEL.SYS", NULL, 0x60, 1, 0 }, DOSBootFiles bootFiles[] = { /* Note: This order is the order OEM:AUTO uses to determine DOS flavor. */ - /* FreeDOS */ { "KERNEL.SYS", NULL, 0x60, 1, 0 }, +#ifndef DRSYS + /* FreeDOS */ FREEDOS_FILES +#endif + /* DR-DOS */ { "DRBIO.SYS", "DRDOS.SYS", 0x70, 1, 1 }, /* DR-DOS */ { "IBMBIO.COM", "IBMDOS.COM", 0x70, 1, 1 }, +#ifdef DRSYS + /* FreeDOS */ FREEDOS_FILES +#endif #ifdef WITHOEMCOMPATBS /* PC-DOS */ { "IBMBIO.COM", "IBMDOS.COM", 0x70, 0, 6138 }, /* pre v7 DR ??? */ /* MS-DOS */ { "IO.SYS", "MSDOS.SYS", 0x70, 0, 10240 }, + /* W9x-DOS */ { "IO.SYS", "MSDOS.SYS", 0x70, 0, 0}, #endif - /* W9x-DOS */ { "IO.SYS", "MSDOS.SYS", 0x70, 1, 0}, }; #define DOSFLAVORS (sizeof(bootFiles) / sizeof(*bootFiles)) +/* associate friendly name with index into bootFiles array */ #define OEM_AUTO (-1) /* attempt to guess DOS on source drive */ +#ifndef DRSYS #define OEM_FD 0 /* standard FreeDOS mode */ -#define OEM_DR 1 /* use FreeDOS boot sector, but OEM names */ -#define OEM_PC 2 /* use PC-DOS compatible boot sector and names */ -#define OEM_MS 3 /* use PC-DOS compatible BS with MS names */ -#define OEM_W9x 4 /* use FreeDOS boot sector but with MS names */ +#define OEM_EDR 1 /* use FreeDOS boot sector, but OEM names */ +#define OEM_DR 2 /* FD boot sector,(Enhanced) DR-DOS names */ +#else +#define OEM_FD 2 /* standard FreeDOS mode */ +#define OEM_EDR 0 /* use FreeDOS boot sector, but OEM names */ +#define OEM_DR 1 /* FD boot sector,(Enhanced) DR-DOS names */ +#endif +#ifdef WITHOEMCOMPATBS +#define OEM_PC 3 /* use PC-DOS compatible boot sector and names */ +#define OEM_MS 4 /* use PC-DOS compatible BS with MS names */ +#define OEM_W9x 5 /* use PC-DOS compatible BS with MS names */ +#endif -CONST char * msgDOS[DOSFLAVORS] = { - "\n", /* In standard FreeDOS mode, don't print anything special */ +CONST char * msgDOS[DOSFLAVORS] = { /* order should match above items */ + "\n", /* In standard FreeDOS/EnhancedDR mode, don't print anything special */ +#ifndef DRSYS + "Enhanced DR DOS (OpenDOS Enhancement Project) mode\n", +#endif "DR DOS (OpenDOS Enhancement Project) mode\n", +#ifdef DRSYS + "\n", /* FreeDOS mode so don't print anything special */ +#endif #ifdef WITHOEMCOMPATBS "PC-DOS compatibility mode\n", "MS-DOS compatibility mode\n", -#endif "Win9x DOS compatibility mode\n", +#endif }; typedef struct SYSOptions { @@ -324,7 +364,6 @@ typedef struct SYSOptions { BYTE *fnCmd; /* optional override to cmd interpreter filename (src & dest) */ } SYSOptions; - void dumpBS(const char *, int); void restoreBS(const char *, int); void put_boot(SYSOptions *opts); @@ -336,7 +375,7 @@ void showHelpAndExit(void) printf( "Usage: \n" "%s [source] drive: [bootsect] [{option}]\n" - " source = A:,B:,C:\\KERNEL\\BIN\\,etc., or current directory if not given\n" + " source = A:,B:,C:\\DOS\\,etc., or current directory if not given\n" " drive = A,B,etc.\n" " bootsect = name of 512-byte boot sector file image for drive:\n" " to write to *instead* of real boot sector\n" @@ -345,18 +384,26 @@ void showHelpAndExit(void) " /BOOTONLY: do *not* copy kernel / shell, only update boot sector or image\n" " /OEM : indicates boot sector, filenames, and load segment to use\n" " /OEM:FD use FreeDOS compatible settings\n" - " /OEM:DR use DR DOS 7+ compatible settings (same as /OEM)\n" + " /OEM:EDR use Enhanced DR DOS 7+ compatible settings\n" + " /OEM:DR use DR DOS 7+ compatible settings\n" #ifdef WITHOEMCOMPATBS " /OEM:PC use PC-DOS compatible settings\n" " /OEM:MS use MS-DOS compatible settings\n" -#endif " /OEM:W9x use MS Win9x DOS compatible settings\n" - " default is /OEM:AUTO, select DOS based on existing files\n" - " /K name : name of kernel to use in boot sector instead of KERNEL.SYS\n" - " /L segm : hex load segment to use in boot sector instead of 60\n" +#endif + " default is /OEM[:AUTO], select DOS based on existing files\n" + " /K name : name of kernel to use in boot sector instead of %s\n" + " /L segm : hex load segment to use in boot sector instead of %02x\n" " /B btdrv : hex BIOS # of boot drive set in bs, 0=A:, 80=1st hd,...\n" " /FORCEDRV: force use of drive # set in bs instead of BIOS boot value\n" - "%s CONFIG /help\n", pgm, pgm +#ifdef FDCONFIG + "%s CONFIG /help\n" +#endif + /*SYS, KERNEL.SYS/DRBIO.SYS 0x60/0x70*/ + , pgm, bootFiles[0].kernel, bootFiles[0].loadseg +#ifdef FDCONFIG + , pgm +#endif ); exit(1); } @@ -406,12 +453,14 @@ void initOptions(int argc, char *argv[], SYSOptions *opts) { argp += 3; if (!*argp) - opts->flavor = OEM_DR; + opts->flavor = OEM_AUTO; else if (*argp == ':') { argp++; /* point to DR/PC/MS that follows */ if (memicmp(argp, "AUTO", 4) == 0) opts->flavor = OEM_AUTO; + else if (memicmp(argp, "EDR", 3) == 0) + opts->flavor = OEM_EDR; else if (memicmp(argp, "DR", 2) == 0) opts->flavor = OEM_DR; #ifdef WITHOEMCOMPATBS @@ -419,11 +468,16 @@ void initOptions(int argc, char *argv[], SYSOptions *opts) opts->flavor = OEM_PC; else if (memicmp(argp, "MS", 2) == 0) opts->flavor = OEM_MS; -#endif else if (memicmp(argp, "W9", 2) == 0) opts->flavor = OEM_W9x; - else /* if (memicmp(argp, "FD", 2) == 0) */ +#endif + else if (memicmp(argp, "FD", 2) == 0) opts->flavor = OEM_FD; + else + { + printf("%s: unknown OEM qualifier %s\n", pgm, argp); + showHelpAndExit(); + } } else { @@ -607,7 +661,12 @@ void initOptions(int argc, char *argv[], SYSOptions *opts) } /* if unable to determine DOS, assume FreeDOS */ - if (opts->flavor == OEM_AUTO) opts->flavor = OEM_FD; + if (opts->flavor == OEM_AUTO) opts->flavor = +#ifdef DRSYS + OEM_EDR; +#else + OEM_FD; +#endif printf(msgDOS[opts->flavor]); @@ -681,12 +740,14 @@ int main(int argc, char **argv) SYSOptions opts; /* boot options and other flags */ BYTE srcFile[SYS_MAXPATH]; /* full path+name of [kernel] file [to copy] */ - printf("FreeDOS System Installer " SYS_VERSION ", " __DATE__ "\n"); + printf(SYS_NAME SYS_VERSION ", " __DATE__ "\n"); +#ifdef FDCONFIG if (argc > 1 && memicmp(argv[1], "CONFIG", 6) == 0) { exit(FDKrnConfigMain(argc, argv)); } +#endif initOptions(argc, argv, &opts); @@ -1245,13 +1306,17 @@ void put_boot(SYSOptions *opts) correct_bpb((struct bootsectortype *)(default_bpb + 7 - 11), bs); if (opts->kernel.stdbs) - { + { memcpy(newboot, (fs == FAT16) ? fat16com : fat12com, SEC_SIZE); - } + } else { +#ifdef WITHOEMCOMPATBS printf("Using OEM (PC/MS-DOS) compatible boot sector.\n"); memcpy(newboot, (fs == FAT16) ? oemfat16 : oemfat12, SEC_SIZE); +#else + printf("Internal Error: no OEM compatible boot sector!\n"); +#endif } } From a7a1b4ff1e5c291cb12da11ce37ef42639606ca8 Mon Sep 17 00:00:00 2001 From: Kenneth J Davis Date: Sat, 29 Jan 2005 20:18:03 +0000 Subject: [PATCH 614/671] new debug macros, simplify selective debug output git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/branches/UNSTABLE@1099 6ac86273-5f31-0410-b378-82cca8765d1b --- hdr/debug.h | 110 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 110 insertions(+) create mode 100644 hdr/debug.h diff --git a/hdr/debug.h b/hdr/debug.h new file mode 100644 index 00000000..f2ef7f36 --- /dev/null +++ b/hdr/debug.h @@ -0,0 +1,110 @@ +/****************************************************************/ +/* */ +/* debug.h */ +/* */ +/* Routines to assist in debugging the kernel */ +/* */ +/* January, 2005 */ +/* */ +/* Copyright (c) 2005 */ +/* FreeDOS kernel dev. */ +/* All Rights Reserved */ +/* */ +/* This file is part of DOS-C. */ +/* */ +/* DOS-C is free software; you can redistribute it and/or */ +/* modify it under the terms of the GNU General Public License */ +/* as published by the Free Software Foundation; either version */ +/* 2, or (at your option) any later version. */ +/* */ +/* DOS-C is distributed in the hope that it will be useful, but */ +/* WITHOUT ANY WARRANTY; without even the implied warranty of */ +/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See */ +/* the GNU General Public License for more details. */ +/* */ +/* You should have received a copy of the GNU General Public */ +/* License along with DOS-C; see the file COPYING. If not, */ +/* write to the Free Software Foundation, 675 Mass Ave, */ +/* Cambridge, MA 02139, USA. */ +/****************************************************************/ + +#ifndef __DEBUG_H +#define __DEBUG_H + +/* #define DEBUG (usually via 'build debug') to + enable debug support. + NOTE: this file included by INIT time code and normal + resident code, so use care for all memory references + */ + + +/* use to limit output to debug builds */ +#ifdef DEBUG +#define DebugPrintf(x) printf x +#else +#define DebugPrintf(x) +#endif + +/* use to disable a chunk of debug output, but + keep around for later use. */ +#define DDebugPrintf(x) + + +/* enable or disable various chunks of debug output */ + +/* show stored IRQ vectors */ +/* #define DEBUGIRQ */ + +/* display output during kernel config processing phase */ +/* #define DEBUGCFG */ +#ifdef DEBUGCFG +#define CfgDbgPrintf(x) printf x +#else +#define CfgDbgPrintf(x) +#endif + +/* display info on various DOS functions (dosfns.c) */ +/* #define DEBUGDOSFNS */ +#ifdef DEBUGDOSFNS +#define DFnsDbgPrintf(x) printf x +#else +#define DFnsDbgPrintf(x) +#endif + +/* extra debug output related to chdir */ +/* #define CHDIR_DEBUG */ + +/* extra debug output related to findfirst */ +/* #define FIND_DEBUG */ + +/* display info on various DOS directory functions (fatdir.c) */ +/* #define DEBUGFATDIR */ +#ifdef DEBUGFATDIR +#define FDirDbgPrintf(x) printf x +#else +#define FDirDbgPrintf(x) +#endif + +/* extra debug output marking sections */ +/* #define DISPLAY_GETBLOCK */ + +/* display info on various FAT handling functions (fatfs.c) */ +/* #define DEBUGFATFS */ +#ifdef DEBUGFATFS +#define FatFSDbgPrintf(x) printf x +#else +#define FatFSDbgPrintf(x) +#endif + + +/* just to be sure printf is declared */ +#if defined(DEBUG) || defined(DEBUGIRQ) || defined(DEBUGCFG) || \ + defined(DEBUGDOSFNS) || defined(CHDIR_DEBUG) || defined(FIND_DEBUG) || \ + defined(DEBUGFATDIR) || defined(DEBUGFATFS) +#ifndef DEBUG_NEED_PRINTF +#define DEBUG_NEED_PRINTF +void printf(const char *, ...); +#endif +#endif + +#endif /* __DEBUG_H */ From 29dc31dfe2c958ae0b371aea2691781d75d9560f Mon Sep 17 00:00:00 2001 From: Kenneth J Davis Date: Sat, 29 Jan 2005 20:20:03 +0000 Subject: [PATCH 615/671] ensure f_nodes.f_count are initialized to 0 (always clear KernelAlloc'd memory), and add some debug messages git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/branches/UNSTABLE@1100 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/config.c | 81 +++++++++++++++++++------------------------------ 1 file changed, 31 insertions(+), 50 deletions(-) diff --git a/kernel/config.c b/kernel/config.c index 6a8e6c72..d773e4aa 100644 --- a/kernel/config.c +++ b/kernel/config.c @@ -30,6 +30,7 @@ #include "portab.h" #include "init-mod.h" #include "dyndata.h" +#include "debug.h" #ifdef VERSION_STRINGS static BYTE *RcsId = @@ -38,12 +39,6 @@ static BYTE *RcsId = #define testbit(v,bit) ((UBYTE)((v) >> (UBYTE)(bit)) & 1) -#ifdef DEBUG -#define DebugPrintf(x) printf x -#else -#define DebugPrintf(x) -#endif - static UBYTE MenuColor BSS_INIT(0); static unsigned screenwidth(void) @@ -249,6 +244,8 @@ enum { UMB_NONE, /* do nothing */ UMB_REQ, /* DOS=UMB detected */ }; +enum {LOC_CONV=0, LOC_HMA=1}; /* dup in global.h */ + static UBYTE HMAState BSS_INIT(HMA_NONE); static UBYTE UmbState BSS_INIT(UMB_NONE); @@ -258,20 +255,15 @@ void PreConfig(void) { /* Initialize the base memory pointers */ -#ifdef DEBUG - { - printf("SDA located at 0x%p\n", internal_data); - } -#endif + CfgDbgPrintf(("SDA located at 0x%p\n", internal_data)); + /* Begin by initializing our system buffers */ -#ifdef DEBUG -/* printf("Preliminary %d buffers allocated at 0x%p\n", Config.cfgBuffers, buffers);*/ -#endif LoL->DPBp = DynAlloc("DPBp", blk_dev.dh_name[0], sizeof(struct dpb)); /* Initialize the file table */ + CfgDbgPrintf(("Initializing fnodes\n")); config_init_fnodes(Config.cfgFiles); LoL->sfthead = MK_PTR(struct sfttbl, FP_SEG(LoL), 0xcc); /* &(LoL->firstsftt) */ @@ -284,19 +276,14 @@ void PreConfig(void) LoL->CDSp = KernelAlloc(sizeof(struct cds) * LoL->lastdrive, 'L', 0); -#ifdef DEBUG - printf("Preliminary:\n f_node 0x%p\n", LoL->f_nodes); -/* printf(" FCB table 0x%p\n",LoL->FCBp);*/ - printf(" sft table 0x%p\n", LoL->sfthead); - printf(" CDS table 0x%p\n", LoL->CDSp); - printf(" DPB table 0x%p\n", LoL->DPBp); -#endif + CfgDbgPrintf(("Preliminary:\n f_node 0x%p\n", LoL->f_nodes)); +/* CfgDbgPrintf((" FCB table 0x%p\n",LoL->FCBp));*/ + CfgDbgPrintf((" CDS table 0x%p\n", LoL->CDSp)); + CfgDbgPrintf((" DPB table 0x%p\n", LoL->DPBp)); /* Done. Now initialize the MCB structure */ /* This next line is 8086 and 80x86 real mode specific */ -#ifdef DEBUG - printf("Preliminary allocation completed: top at %p\n", lpTop); -#endif + CfgDbgPrintf(("Preliminary allocation completed: top at %p\n", lpTop)); /* initialize environment */ fmemcpy(MK_PTR(char, DOS_PSP + 8, 0), master_env, sizeof(master_env)); @@ -379,16 +366,14 @@ void PostConfig(void) LoL->lastdrive = drv; } - DebugPrintf(("starting FAR allocations at %x\n", base_seg)); + CfgDbgPrintf(("starting FAR allocations at %x\n", base_seg)); /* Initialize the file table */ config_init_fnodes(Config.cfgFiles); /* Begin by initializing our system buffers */ /* dma_scratch = (BYTE FAR *) KernelAllocDma(BUFFERSIZE); */ -#ifdef DEBUG - /* printf("DMA scratchpad allocated at 0x%p\n", dma_scratch); */ -#endif + /* CfgDbgPrintf(("DMA scratchpad allocated at 0x%p\n", dma_scratch)); */ config_init_buffers(Config.cfgBuffers); @@ -404,13 +389,10 @@ void PostConfig(void) LoL->CDSp = KernelAlloc(sizeof(struct cds) * LoL->lastdrive, 'L', Config.cfgLastdriveHigh); -#ifdef DEBUG - printf("Final: \n f_node 0x%p\n", LoL->f_nodes); + CfgDbgPrintf(("Final: \n f_node 0x%p\n", LoL->f_nodes)); /* printf(" FCB table 0x%p\n",LoL->FCBp);*/ - printf(" sft table 0x%p\n", LoL->sfthead->sftt_next); - printf(" CDS table 0x%p\n", LoL->CDSp); - printf(" DPB table 0x%p\n", LoL->DPBp); -#endif + CfgDbgPrintf((" CDS table 0x%p\n", LoL->CDSp)); + CfgDbgPrintf((" DPB table 0x%p\n", LoL->DPBp)); if (Config.cfgStacks) { @@ -419,9 +401,9 @@ void PostConfig(void) Config.cfgStacksHigh); init_stacks(stackBase, Config.cfgStacks, Config.cfgStackSize); - DebugPrintf(("Stacks allocated at %p\n", stackBase)); + CfgDbgPrintf(("Stacks allocated at %p\n", stackBase)); } - DebugPrintf(("Allocation completed: top at 0x%x\n", base_seg)); + CfgDbgPrintf(("Allocation completed: top at 0x%x\n", base_seg)); } @@ -433,21 +415,17 @@ VOID configDone(VOID) if (HMAState != HMA_DONE) { -#ifdef DEBUG - size_t hma_paras = (HMAFree + 15) / 16; + register size_t hma_paras = (HMAFree + 15) / 16; seg_t kernel_seg = allocmem(hma_paras); -#else - seg_t kernel_seg = allocmem((HMAFree + 15) / 16); -#endif mcb _seg *p = MK_SEG_PTR(mcb, kernel_seg - 1); p->m_name[0] = 'S'; p->m_name[1] = 'C'; p->m_psp = 8; - DebugPrintf(("HMA not available, moving text to %x\n", kernel_seg)); + CfgDbgPrintf(("HMA not available, moving text to %x\n", kernel_seg)); MoveKernel(kernel_seg); - DebugPrintf(("kernel is low, start alloc at %x\n", + CfgDbgPrintf(("kernel is low, start alloc at %x\n", kernel_seg + hma_paras + 1)); } @@ -616,15 +594,15 @@ static void DoConfig_(void) /*strcpy (configfile, "FDCONFIG.SYS");*/ if ((nFileDesc = open(configfile, 0)) < 0) { - DebugPrintf(("%s not found\n", configfile)); + CfgDbgPrintf(("%s not found\n", configfile)); strcpy (configfile, "CONFIG.SYS"); if ((nFileDesc = open(configfile, 0)) < 0) { - DebugPrintf(("%s not found\n", configfile)); + CfgDbgPrintf(("%s not found\n", configfile)); return; } } - DebugPrintf(("Reading %s...\n", configfile)); + CfgDbgPrintf(("Reading %s...\n", configfile)); /* Read each line into the buffer and then parse the line, */ /* do the table lookup and execute the handler for that */ @@ -1541,11 +1519,14 @@ void _seg * KernelAlloc(size_t nBytes, UBYTE type, int mode) { /* prealloc */ /* note: lpTop is already para-aligned */ - return alignNextPara(lpTop = MK_FP(FP_SEG(lpTop) - nPara, FP_OFF(lpTop))); + p = alignNextPara(lpTop = MK_FP(FP_SEG(lpTop) - nPara, FP_OFF(lpTop))); } - - p = KernelAllocPara(nPara, type, NULL, mode); - fmemset(p, 0, nBytes); + else + { + p = KernelAllocPara(nPara, type, NULL, mode); + } + + fmemset(p, 0x0, nBytes); return p; } From 2fc18e7c335bb3dc968ee74470000ed9facd8a0e Mon Sep 17 00:00:00 2001 From: Kenneth J Davis Date: Sat, 29 Jan 2005 20:21:56 +0000 Subject: [PATCH 616/671] simpler output in case of unpartitioned disks (don't repeat error messages) git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/branches/UNSTABLE@1101 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/initdisk.c | 33 +++++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/kernel/initdisk.c b/kernel/initdisk.c index 9307ad47..4134a085 100644 --- a/kernel/initdisk.c +++ b/kernel/initdisk.c @@ -149,13 +149,7 @@ COUNT nUnits BSS_INIT(0); * CHS or LBA, strengthening its role as a rescue environment. */ -/* #define DEBUG */ - -#if defined(DEBUG) -#define DebugPrintf(x) printf x -#else -#define DebugPrintf(x) -#endif +#include "debug.h" #define LBA_to_CHS init_LBA_to_CHS @@ -1029,6 +1023,15 @@ BOOL Read1LBASector(struct DriveParamS *driveParam, unsigned drive, } /* Load the Partition Tables and get information on all drives */ +/* If scanType != SCAN_EXTENDED then we return with the + lower four bits set (valid partition, drive added) or clear + (unhandled or invalid) for each partition entry in the + partition table, or 0 when scanType == SCAN_EXTENDED. + If we are unable to obtain the disk parameters for drive, + then we return -1 (usually means BIOS returned a count + higher than drives that exists; ISOLINUX may do this and + from RBIL may occur in some BIOSes). + */ int ProcessDisk(int scanType, unsigned drive, int PartitionsToIgnore) { @@ -1047,8 +1050,9 @@ int ProcessDisk(int scanType, unsigned drive, int PartitionsToIgnore) if (!LBA_Get_Drive_Parameters(drive, &driveParam)) { - printf("can't get drive parameters for drive %02x\n", drive); - return PartitionsToIgnore; + if (scanType == SCAN_PRIMARYBOOT) /* only display 1st time through */ + printf("can't get drive parameters for drive %02x\n", drive); + return -1; } RelSectorOffset = 0; /* boot sector */ @@ -1079,7 +1083,10 @@ int ProcessDisk(int scanType, unsigned drive, int PartitionsToIgnore) if (++strangeHardwareLoop < 3) goto strange_restart; - printf("illegal partition table - drive %02x sector %lu\n", drive, + if (scanType == SCAN_PRIMARYBOOT) /* only display 1st time through */ + printf("corrupt or unpartitioned drive %02x\n", drive); + else if (RelSectorOffset /* && (scanType == SCAN_EXTENDED) */) + printf("illegal extended partition table - drive %02x sector %lu\n", drive, RelSectorOffset); return PartitionsToIgnore; } @@ -1316,6 +1323,9 @@ COUNT dsk_init() foundPartitions[HardDrive] = ProcessDisk(SCAN_PRIMARY, HardDrive, 0); } + /* ignore last drive if can't get info about it; can't use anyway */ + if ((nHardDisk>1) && (foundPartitions[nHardDisk-1]==(UBYTE)-1)) + nHardDisk--; /* Process extended partition table */ for (HardDrive = 0; HardDrive < nHardDisk; HardDrive++) @@ -1357,6 +1367,9 @@ COUNT dsk_init() foundPartitions[HardDrive] = ProcessDisk(SCAN_PRIMARY, HardDrive, 0); } + /* ignore last drive if can't get info about it; can't use anyway */ + if ((nHardDisk>1) && (foundPartitions[nHardDisk-1]==(UBYTE)-1)) + nHardDisk--; /* Process extended partition table */ ProcessDisk(SCAN_EXTENDED, HardDrive, 0); From 0bf49a24b749c49a8f0548f71e2597175aef85e3 Mon Sep 17 00:00:00 2001 From: Kenneth J Davis Date: Sat, 29 Jan 2005 20:30:28 +0000 Subject: [PATCH 617/671] add build switch to generate list files from (NASM) assembly source git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/branches/UNSTABLE@1102 6ac86273-5f31-0410-b378-82cca8765d1b --- build.bat | 4 +++- defaults.bat | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/build.bat b/build.bat index 27f2c548..b994671c 100644 --- a/build.bat +++ b/build.bat @@ -6,7 +6,7 @@ if NOT "%1" == "/?" goto start echo ":-----------------------------------------------------------------------" echo ":- Syntax: BUILD [-r] [fat32|fat16] [msc|wc|tc|tcpp|bc] [86|186|386] " -echo ":- [debug] [lfnapi] [/L #] [/D value] " +echo ":- [debug] [lfnapi] [/L #] [/D value] [list] " echo ":- option case is significant !! " echo ":- Note: Open Watcom (wc) is the preferred compiler " echo ":-----------------------------------------------------------------------" @@ -50,6 +50,8 @@ if "%1" == "x86" goto setCPU if "%1" == "debug" set ALLCFLAGS=%ALLCFLAGS% -DDEBUG if "%1" == "lfnapi" set ALLCFLAGS=%ALLCFLAGS% -DWITHLFNAPI +if "%1" == "list" set NASMFLAGS=%NASMFLAGS% -l$*.lst + if "%1" == "/L" goto setLoadSeg if "%1" == "/D" goto setDefine diff --git a/defaults.bat b/defaults.bat index 13d33132..163ac979 100644 --- a/defaults.bat +++ b/defaults.bat @@ -82,6 +82,7 @@ if "%LAST%" == "1" goto end :clearset set NASM= +set NASMFLAGS= set COMPILER= set BASE= set BINPATH= From a56552c0f50b27d6a466358d5e3fd81f622bb535 Mon Sep 17 00:00:00 2001 From: Kenneth J Davis Date: Sat, 29 Jan 2005 20:33:11 +0000 Subject: [PATCH 618/671] just comments and additional debug messages, updated history (little reformating) git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/branches/UNSTABLE@1103 6ac86273-5f31-0410-b378-82cca8765d1b --- docs/history.txt | 47 +++++++++++++++++++++++++++++++-------------- hdr/debug.h | 7 +++++++ hdr/lol.h | 5 ++++- kernel/dosfns.c | 22 ++++++++++++++++++++- kernel/dyninit.c | 7 +------ kernel/fatdir.c | 29 ++++++++++++++++++++++------ kernel/fatfs.c | 43 ++++++++++++++++++++++++++++++++++++++--- kernel/globals.h | 6 ++++++ kernel/inithma.c | 9 +++------ kernel/irqstack.asm | 9 +++++---- kernel/main.c | 34 +++++++++++++++++++++++++++++++- kernel/prf.c | 3 ++- 12 files changed, 178 insertions(+), 43 deletions(-) diff --git a/docs/history.txt b/docs/history.txt index 88455059..432ad6ac 100644 --- a/docs/history.txt +++ b/docs/history.txt @@ -1,12 +1,14 @@ -2004 July 8 - UNSTABLE branch +2005 Jan XX - UNSTABLE (-w) branch -------- Jeremy Davis (jeremyd@computer.org) + Changes Bart - * int2f.asm - - bugfix: call_nls: DI register was not preserved * exeflat.c - new version exploiting better UPX compression for SYS files; calls UPX itself + * int2f.asm + - bugfix: call_nls: DI register was not preserved * inthndlr.c - int21/ah=6/dl=ff now calls int28 + * sys.c + - correct fat32readwrite's prototype to explicitly return int + Changes Tom * inthndlr.c - improve handling of case where eg. FindFirst(I:\*.*) fails, causes Int24, @@ -316,7 +318,7 @@ (the last 2 changes needed to fix bugs discovered by Michael Devore) - added Int 2Fh/2Fh processing to set DOS version as per MS-DOS 4.0 - optimised Int 21h/AH=38h Get Country Information, removed cntry hack - * autoexec.bat now single-line for FreeCOM compatibility when EOL=LF + * autoexec.bat: now single-line for FreeCOM compatibility when EOL=LF * break.c: check_handle_break() return was undefined if no Ctrl-break * config.sys: all commands removed as they were close to defaults * contrib.txt: added Aitor Santamaria, Bernd Blaauw and Eduardo Casino @@ -330,16 +332,16 @@ - optimisation and clean-up * fattab.c: ISFAT32 function removed (now macro), "wasfree" optimised * globals.h: __TIME__ removed - no two kernels released on same day - * initdisk.c: + * initdisk.c - if no floppy drives present, don't initialise DDT for drive A: - " - Initdisk" no longer shifts text if no FAT partitions found - converted cdiv() from macro to function; optimise and clean-up * inithma: InstallVDISK() function inlined, optimised and cleaned up * intr.asm: lseek() added (necessary for COUNTRY.SYS processing) - * ioctl.c: + * ioctl.c - r_si/r_di contents added as documented in PC-DOS Technical Update - r_unit now set to dpb_subunit (allows ZIP disk serial number) - * main.c: + * main.c - copyright message cleanup, now shows URL for the full GNU GPL text - (with Bart) LoL pointer made const (saves some size for Watcom) - InitializeAllBPBs() kludge removed (no longer needed - verified) @@ -353,7 +355,7 @@ + Changes Eduardo * config.c: update hardcoded country and codepage IDs * country.asm: added NLS uppercase/collating tables (437,850,857,858) - * inthndlr.c: + * inthndlr.c - added Int 2Fh/26-29h processing for NLSFUNC (with Lucho) - DOS-63-00 returns DBCS table from the active NLS package, not the harcoded one. @@ -368,27 +370,44 @@ - DosYesNo(): arg is now UWORD, not unsigned char. - nlsYesNo(): Add DBCS support - syscall_MUX14(): arg of nlsYesNo() is now CX instead of CL. - * nls.h: + * nls.h - yeschar and nochar are now UWORD instead of UBYTE. - NLS_FREEDOS_NLSFUNC_VERSION bumped to 0xFD02. - Add a small comment. * nls_hc.asm: YesChar and NoChar are now two bytes each. - * proto.h: + * proto.h - DosYesNo(): Argument is now UWORD (dual byte) - Add prototype for DosGetDBCS() + Changes Jeremy - * config.txt - - update to include all CONFIG.SYS options (except ANYDOS) + * updated build system to use NT OW binaries when building on NT + and add some additional options to build.bat command line + * added debug.h and changed to more easily allow selective DEBUG output * boot.asm - use static read buffer to avoid crossing 64KB boundary + - drop test for drive==0xFF, use sys to NOP use of BIOS provided # + * config.c + - always initialize boot time master environment + - KernelAlloc always 0's returned memory (fixes potential boot + time failure finding/loading CONFIG.SYS) + * config.txt + - update to include all CONFIG.SYS options (except ANYDOS) + * exeflat.c + - show usage also when number of arguments incorrect + * fatdir.c + - be more restrictive in what considered a volume search + * initdisk.c + - set hidden & huge fields in floppy bpb (bugfix 1789) * main.c - treat block devices returning 0 units as load failure * oemboot.asm - add [optional] PC/MS DOS compatible boot sector * sys.c - incorporate changes from/for DR-DOS enhancement project - rework option handling, add backup & restore boot sector - * exeflat.c - - show usage also when number of arguments incorrect + - change boot time drive selection (BIOS provided or one in + boot sector) to be selected as SYS time via NOPing mov [drive],dl + * add sys.txt (documentation) and sys.html (htmlhelp file) + * task.c + - add debug output to see env & cmd line passed to exec'd program < many other changes to be added by Jeremy himself :-> *** Sync - Stable Build 2035 *** diff --git a/hdr/debug.h b/hdr/debug.h index f2ef7f36..d4cf7f1f 100644 --- a/hdr/debug.h +++ b/hdr/debug.h @@ -55,6 +55,13 @@ /* show stored IRQ vectors */ /* #define DEBUGIRQ */ +/* show output related to moving kernel into HMA */ +#ifdef DEBUG +#define HMAInitPrintf(x) printf x +#else +#define HMAInitPrintf(x) +#endif + /* display output during kernel config processing phase */ /* #define DEBUGCFG */ #ifdef DEBUGCFG diff --git a/hdr/lol.h b/hdr/lol.h index b0cb59e9..ff2174bc 100644 --- a/hdr/lol.h +++ b/hdr/lol.h @@ -26,7 +26,8 @@ /* Boston, MA 02111-1307 USA. */ /****************************************************************/ -enum {LOC_CONV=0, LOC_HMA=1}; +#ifndef __LOL_H +#define __LOL_H /* note: we start at DOSDS:0, but the "official" list of lists starts a little later at DOSDS:26 (this is what is returned by int21/ah=52) */ @@ -84,3 +85,5 @@ struct lol { unsigned short f_nodes_cnt; /* 74 number of allocated f_nodes */ char *os_release; /* 76 near pointer to os_release string */ }; + +#endif /* __LOL_H */ diff --git a/kernel/dosfns.c b/kernel/dosfns.c index 7ef142c4..8a8b40a3 100644 --- a/kernel/dosfns.c +++ b/kernel/dosfns.c @@ -27,6 +27,7 @@ /****************************************************************/ #include "portab.h" +#include "debug.h" #ifdef VERSION_STRINGS static BYTE *dosfnsRcsId = @@ -504,11 +505,19 @@ long DosOpenSft(char FAR * fname, unsigned flags, unsigned attrib) result = truename(fname, PriPathName, CDS_MODE_CHECK_DEV_PATH); if (result < SUCCESS) + { + DFnsDbgPrintf(("DosOpenSft: truename failed\n")); return result; + } + else DFnsDbgPrintf(("DosOpenSft: truename succeeded\n")); /* now get a free system file table entry */ if ((sftp = get_free_sft(&sft_idx)) == (sft FAR *) - 1) + { + DFnsDbgPrintf(("DosOpenSft: file table full\n")); return DE_TOOMANY; + } + else DFnsDbgPrintf(("DosOpenSft: obtained sft entry\n")); fmemset(sftp, 0, sizeof(sft)); @@ -519,10 +528,14 @@ long DosOpenSft(char FAR * fname, unsigned flags, unsigned attrib) sftp->sft_shroff = -1; /* /// Added for SHARE - Ron Cemer */ sftp->sft_attrib = attrib = attrib | D_ARCHIVE; + DFnsDbgPrintf(("DosOpenSft: mode=%02X, flags=%02X, attrib=%02X\n", \ + sftp->sft_mode, OpenMode, attrib)); + if (result & IS_NETWORK) { int status; unsigned cmd; + DFnsDbgPrintf(("DosOpenSft: IS_NETWORK\n")); if ((flags & (O_TRUNC | O_CREAT)) == O_CREAT) attrib |= 0x100; @@ -558,6 +571,7 @@ long DosOpenSft(char FAR * fname, unsigned flags, unsigned attrib) /* check the status code returned by the * driver when we tried to open it */ + DFnsDbgPrintf(("DosOpenSft: IS_DEVICE\n")); if (rc < SUCCESS) return rc; return sft_idx; @@ -566,6 +580,7 @@ long DosOpenSft(char FAR * fname, unsigned flags, unsigned attrib) /* /// Added for SHARE. - Ron Cemer */ if (IsShareInstalled()) { + DFnsDbgPrintf(("DosOpenSft: using SHARE\n")); if ((sftp->sft_shroff = share_open_check(PriPathName, cu_psp, flags & 0x03, (flags >> 4) & 0x07)) < 0) @@ -578,9 +593,13 @@ long DosOpenSft(char FAR * fname, unsigned flags, unsigned attrib) /* ... though FCB's are weird :) */ if (!(flags & O_FCB) && (attrib & ~(D_RDONLY | D_HIDDEN | D_SYSTEM | D_ARCHIVE | D_VOLID))) + { + DFnsDbgPrintf(("DosOpenSft: invalid request\n")); return DE_ACCESS; + } result = dos_open(PriPathName, flags, attrib); + DFnsDbgPrintf(("DosOpenSft: dos_open returned %02X\n", result)); if (result >= 0) { int status = (int)(result >> 16); @@ -591,6 +610,7 @@ long DosOpenSft(char FAR * fname, unsigned flags, unsigned attrib) (do not allow to open volume labels/directories) */ if (sftp->sft_attrib & (D_DIR | D_VOLID)) { + DFnsDbgPrintf(("DosOpenSft: closing, invalid attributes DIR|VOLID\n")); dos_close((COUNT)result); return DE_ACCESS; } @@ -603,6 +623,7 @@ long DosOpenSft(char FAR * fname, unsigned flags, unsigned attrib) dos_getftime(sftp->sft_status, (date FAR *) & sftp->sft_date, (time FAR *) & sftp->sft_time); + DFnsDbgPrintf(("DosOpenSft: returning %lu (decimal)\n", (sft_idx | ((long)status << 16)))); return sft_idx | ((long)status << 16); } else @@ -944,7 +965,6 @@ COUNT DosGetCuDir(UBYTE drive, BYTE FAR * s) return SUCCESS; } -#undef CHDIR_DEBUG COUNT DosChangeDir(BYTE FAR * s) { COUNT result; diff --git a/kernel/dyninit.c b/kernel/dyninit.c index 93500727..0461e556 100644 --- a/kernel/dyninit.c +++ b/kernel/dyninit.c @@ -38,12 +38,7 @@ kernel layout: #include "portab.h" #include "init-mod.h" #include "dyndata.h" - -#if defined(DEBUG) -#define DebugPrintf(x) printf x -#else -#define DebugPrintf(x) -#endif +#include "debug.h" /*extern struct DynS FAR Dyn;*/ diff --git a/kernel/fatdir.c b/kernel/fatdir.c index b66ce08d..c7c98dd5 100644 --- a/kernel/fatdir.c +++ b/kernel/fatdir.c @@ -29,6 +29,7 @@ #include "portab.h" #include "globals.h" +#include "debug.h" #ifdef VERSION_STRINGS static BYTE *fatdirRcsId = @@ -62,9 +63,12 @@ f_node_ptr dir_open(register const char *dirname) int i; char fcbname[FNAME_SIZE + FEXT_SIZE]; + FDirDbgPrintf(("dir_open: trying to open %s\n", dirname)); + /* Allocate an fnode if possible - error return (0) if not. */ if ((fnp = get_f_node()) == (f_node_ptr) 0) { + FDirDbgPrintf(("dir_open: failed to get f_node\n")); return (f_node_ptr) 0; } @@ -78,6 +82,7 @@ f_node_ptr dir_open(register const char *dirname) if (media_check(fnp->f_dpb) < 0) { + FDirDbgPrintf(("dir_open: media_check failed\n")); release_f_node(fnp); return (f_node_ptr) 0; } @@ -136,6 +141,7 @@ f_node_ptr dir_open(register const char *dirname) if (!i || !(fnp->f_dir.dir_attrib & D_DIR)) { + FDirDbgPrintf(("dir_open: no match found, returning failure\n")); release_f_node(fnp); return (f_node_ptr) 0; } @@ -146,6 +152,7 @@ f_node_ptr dir_open(register const char *dirname) dir_init_fnode(fnp, getdstart(fnp->f_dpb, &fnp->f_dir)); } } + FDirDbgPrintf(("dir_open: returning, ok\n")); return fnp; } @@ -188,7 +195,10 @@ COUNT dir_read(REG f_node_ptr fnp) /* can't have more than 65535 directory entries */ if (fnp->f_diroff >= 65535U) + { + FDirDbgPrintf(("dir_read: exceed dir entry count\n")); return DE_SEEK; + } /* Determine if we hit the end of the directory. If we have, */ /* bump the offset back to the end and exit. If not, fill the */ @@ -198,7 +208,10 @@ COUNT dir_read(REG f_node_ptr fnp) if (fnp->f_dirstart == 0) { if (fnp->f_diroff >= fnp->f_dpb->dpb_dirents) + { + FDirDbgPrintf(("dir_read: end of dir\n")); return DE_SEEK; + } bp = getblock(fnp->f_diroff / (secsize / DIRENT_SIZE) + fnp->f_dpb->dpb_dirstrt, fnp->f_dpb->dpb_unit); @@ -217,7 +230,10 @@ COUNT dir_read(REG f_node_ptr fnp) printf("dir_read: "); #endif if (map_cluster(fnp, XFR_READ) != SUCCESS) + { + DebugPrintf(("dir_read: map_cluster failed\n")); return DE_SEEK; + } bp = getblock_from_off(fnp, secsize); #ifdef DISPLAY_GETBLOCK @@ -228,7 +244,10 @@ COUNT dir_read(REG f_node_ptr fnp) /* Now that we have the block for our entry, get the */ /* directory entry. */ if (bp == NULL) + { + FDirDbgPrintf(("dir_read: invalid block\n")); return DE_BLKINVLD; + } bp->b_flag &= ~(BFR_DATA | BFR_FAT); bp->b_flag |= BFR_DIR | BFR_VALID; @@ -245,6 +264,7 @@ COUNT dir_read(REG f_node_ptr fnp) /* and for efficiency, stop when we hit the first */ /* unused entry. */ /* either returns 1 or 0 */ + FDirDbgPrintf(("dir_read: dir_name is %11s\n", fnp->f_dir.dir_name)); return (fnp->f_dir.dir_name[0] != '\0'); } @@ -423,9 +443,8 @@ COUNT dos_findfirst(UCOUNT attr, BYTE * name) { dmp->dm_dircluster = fnp->f_dirstart; /* TE */ memcpy(&SearchDir, &fnp->f_dir, sizeof(struct dirent)); -#ifdef DEBUG - printf("dos_findfirst: %11s\n", fnp->f_dir.dir_name); -#endif + FDirDbgPrintf(("dos_findfirst: %11s\n", fnp->f_dir.dir_name)); + dir_close(fnp); return SUCCESS; } @@ -511,9 +530,7 @@ COUNT dos_findnext(void) return SUCCESS; } } -#ifdef DEBUG - printf("dos_findnext: %11s\n", fnp->f_dir.dir_name); -#endif + FDirDbgPrintf(("dos_findnext: %11s\n", fnp->f_dir.dir_name)); /* return the result */ release_f_node(fnp); diff --git a/kernel/fatfs.c b/kernel/fatfs.c index 8e010a31..9012a072 100644 --- a/kernel/fatfs.c +++ b/kernel/fatfs.c @@ -29,6 +29,7 @@ #include "portab.h" #include "globals.h" +#include "debug.h" #ifdef VERSION_STRINGS BYTE *RcsId = "$Id$"; @@ -142,12 +143,16 @@ long dos_open(char *path, unsigned flags, unsigned attrib) /* next, split the passed dir into components (i.e. - path to */ /* new directory and name of new directory. */ if ((fnp = split_path(path, fcbname)) == NULL) + { + FatFSDbgPrintf(("dos_open: splitpath(\"%s\", \"%11s\") failed.\n", path, fcbname)); return DE_PATHNOTFND; + } /* Check that we don't have a duplicate name, so if we */ /* find one, truncate it (O_CREAT). */ if (find_fname(fnp, fcbname, D_ALL | attrib)) { + FatFSDbgPrintf(("dos_open: filename match found\n")); if (flags & O_TRUNC) { /* The only permissable attribute is archive, */ @@ -189,6 +194,7 @@ long dos_open(char *path, unsigned flags, unsigned attrib) else if (flags & O_CREAT) { int ret = alloc_find_free(fnp, path, fcbname); + FatFSDbgPrintf(("dos_open: create\n")); if (ret != SUCCESS) return ret; status = S_CREATED; @@ -198,6 +204,7 @@ long dos_open(char *path, unsigned flags, unsigned attrib) /* open: If we can't find the file, just return a not */ /* found error. */ dir_close(fnp); + FatFSDbgPrintf(("dos_open: file not found\n")); return DE_FILENOTFND; } @@ -312,6 +319,8 @@ f_node_ptr split_path(char * path, char * fcbname) /* Start off by parsing out the components. */ int dirlength = ParseDosName(path, fcbname, FALSE); + FatFSDbgPrintf(("split_path: dirlen=%i, path=\"%s\", fcbname=\"%11s\"\n", \ + dirlength, path, fcbname)); if (dirlength < SUCCESS) return (f_node_ptr) 0; @@ -330,7 +339,7 @@ f_node_ptr split_path(char * path, char * fcbname) #ifdef DEBUG if (get_cds(path[0]-'A')->cdsFlags & CDSNETWDRV) { - printf("split path called for redirected file: `%s'\n", + printf("split path called for redirected file: `%11s'\n", fcbname); return (f_node_ptr) 0; } @@ -349,10 +358,14 @@ f_node_ptr split_path(char * path, char * fcbname) /* note: an invalid fd is indicated by a 0 return */ if (fnp == (f_node_ptr) 0 || fnp->f_count <= 0) { + FatFSDbgPrintf(("split_path: failing, fnp is %sNULL, f_count=%i\n", \ + (fnp==(f_node_ptr)0)?"":"NOT", \ + (fnp==(f_node_ptr)0)?123:fnp->f_count)); dir_close(fnp); return (f_node_ptr) 0; } + FatFSDbgPrintf(("split_path: success\n")); return fnp; } @@ -1817,18 +1830,18 @@ int dos_cd(char * PathName) /* try to allocate a near f_node */ /* (there are just two of them, in the SDA) */ - f_node_ptr get_near_f_node(void) { f_node_ptr fnp = fnode; + DebugPrintf(("get_near_f_node: fnp is %p\n", fnp)); if (fnp->f_count && (++fnp)->f_count) panic("more than two near fnodes requested at the same time!\n"); fnp->f_count++; + DebugPrintf(("got near fnode, fnp->f_count=%i\n", fnp->f_count)); return fnp; } /* Try to allocate an f_node from the available files array */ - f_node_ptr get_f_node(void) { REG int i; @@ -1836,17 +1849,22 @@ f_node_ptr get_f_node(void) if (fnp != (f_node_ptr)0) { + FatFSDbgPrintf(("get_f_node: &f_nodes[0]=%p, f_nodes_cnt=%i\n", (void far *)&f_nodes, f_nodes_cnt)); for (i = 0; i < f_nodes_cnt; i++) { if (f_nodes[i].f_count == 0) { ++f_nodes[i].f_count; fnode_fd[fnp - fnode] = i; + FatFSDbgPrintf(("f_nodes[%i].f_count=%i, fnode_fd[%i]=%i\n", \ + i, f_nodes[i].f_count, (fnp-fnode), i)); return fnp; } } release_near_f_node(fnp); + FatFSDbgPrintf(("get_f_node: failure finding free entry in f_nodes[]\n")); } + else FatFSDbgPrintf(("get_f_node: get_near_fnode() failed, returned NULL\n")); return (f_node_ptr) 0; } @@ -1854,6 +1872,8 @@ VOID release_f_node(f_node_ptr fnp) { struct f_node FAR *fp = &f_nodes[xlt_fnp(fnp)]; + FatFSDbgPrintf(("release_f_node: fp->f_count=%i\n", fp->f_count)); + if (fp->f_count > 0) --fp->f_count; else @@ -2048,28 +2068,37 @@ COUNT media_check(REG struct dpb FAR * dpbp) /* First test if anyone has changed the removable media */ ret = rqblockio(C_MEDIACHK, dpbp); if (ret < SUCCESS) + { + FatFSDbgPrintf(("media_check: failed\n")); return ret; + } switch (MediaReqHdr.r_mcretcode | dpbp->dpb_flags) { case M_NOT_CHANGED: /* It was definitely not changed, so ignore it */ + DebugPrintf(("media_check: no change\n")); return SUCCESS; /* If it is forced or the media may have changed, */ /* rebuild the bpb */ case M_DONT_KNOW: /* hazard: no error checking! */ + DebugPrintf(("media_check: unknown\n")); flush_buffers(dpbp->dpb_unit); /* If it definitely changed, don't know (falls through) */ /* or has been changed, rebuild the bpb. */ /* case M_CHANGED: */ default: + DebugPrintf(("media_check: assumming changed\n")); setinvld(dpbp->dpb_unit); ret = rqblockio(C_BLDBPB, dpbp); if (ret < SUCCESS) + { + DebugPrintf(("media_check: build BPB failed\n")); return ret; + } #ifdef WITHFAT32 /* extend dpb only for internal or FAT32 devices */ bpb_to_dpb(MediaReqHdr.r_bpptr, dpbp, @@ -2077,6 +2106,7 @@ COUNT media_check(REG struct dpb FAR * dpbp) #else bpb_to_dpb(MediaReqHdr.r_bpptr, dpbp); #endif + DebugPrintf(("media_check: returning ok\n")); return SUCCESS; } } @@ -2089,19 +2119,25 @@ f_node_ptr xlt_fd(int fd) /* If the fd was invalid because it was out of range or the */ /* requested file was not open, tell the caller and exit */ /* note: an invalid fd is indicated by a 0 return */ + FatFSDbgPrintf(("xlt_fd: fd(%i) ?< f_nodes_cnt(%i)\n", fd, f_nodes_cnt)); if (fd < f_nodes_cnt) { fnp = get_near_f_node(); if (fnp != (f_node_ptr)0) { fmemcpy(fnp, &f_nodes[fd], sizeof(*fnp)); + FatFSDbgPrintf(("xlt_fd: fnp->f_count=%i, fnp-fnode=%i\n", fnp->f_count, (fnp-fnode))); if (fnp->f_count <= 0) { release_near_f_node(fnp); fnp = (f_node_ptr) 0; } else + { fnode_fd[fnp - fnode] = fd; + FatFSDbgPrintf(("xlt_fd: success\n")); + } } + else FatFSDbgPrintf(("xlt_fd: get_near_f_node failed\n")); } return fnp; } @@ -2109,6 +2145,7 @@ f_node_ptr xlt_fd(int fd) /* copy a near fnode to the corresponding far one and release it */ STATIC void save_far_f_node(f_node_ptr fnp) { + FatFSDbgPrintf(("save_far_f_node: copying near fnode to far one\n")); fmemcpy(&f_nodes[xlt_fnp(fnp)], fnp, sizeof(*fnp)); release_near_f_node(fnp); } diff --git a/kernel/globals.h b/kernel/globals.h index c8f912a2..2696ab8d 100644 --- a/kernel/globals.h +++ b/kernel/globals.h @@ -27,6 +27,9 @@ /* Cambridge, MA 02139, USA. */ /****************************************************************/ +#ifndef __GLOBALS_H +#define __GLOBALS_H + #ifdef VERSION_STRINGS #ifdef MAIN static BYTE *Globals_hRcsId = @@ -422,3 +425,6 @@ GLOBAL BYTE ReturnAnyDosVersionExpected; GLOBAL struct f_node fnode[2]; GLOBAL int fnode_fd[2]; + +#endif /* __GLOBALS_H */ + diff --git a/kernel/inithma.c b/kernel/inithma.c index 952d5e2a..3afc67d3 100644 --- a/kernel/inithma.c +++ b/kernel/inithma.c @@ -65,6 +65,7 @@ #include "portab.h" #include "init-mod.h" +#include "debug.h" #ifdef VERSION_STRINGS static BYTE *RcsId = @@ -90,12 +91,6 @@ void int3() #define int3() #endif -#ifdef DEBUG -#define HMAInitPrintf(x) printf x -#else -#define HMAInitPrintf(x) -#endif - #ifdef DEBUG VOID hdump(BYTE FAR * p) { @@ -295,9 +290,11 @@ void MoveKernel(unsigned NewKernelSegment) unsigned len; unsigned jmpseg = CurrentKernelSegment; + /* on 1st call use original link time (unrelocated) TGROUP segment */ if (CurrentKernelSegment == 0) CurrentKernelSegment = FP_SEG(_HMATextEnd); + /* if already relocated to HMA, then ignore move request */ if (CurrentKernelSegment == 0xffff) return; diff --git a/kernel/irqstack.asm b/kernel/irqstack.asm index 63dc3c7e..fd55d3bc 100644 --- a/kernel/irqstack.asm +++ b/kernel/irqstack.asm @@ -34,7 +34,8 @@ segment _LOWTEXT -old_vectors times 16 dd 0 +global _old_vectors +_old_vectors times 16 dd 0 stack_size dw 0 stack_top dw 0 stack_offs dw 0 @@ -129,7 +130,7 @@ general_irq_service: sub [stack_top], ax pushf - call far word [old_vectors+bx] + call far word [_old_vectors+bx] cli add [stack_top], ax @@ -147,7 +148,7 @@ general_irq_service: iret dont_switch: pushf - call far word [old_vectors+bx] + call far word [_old_vectors+bx] pop ds pop ax pop dx @@ -190,7 +191,7 @@ _init_stacks: mov ax, _LOWTEXT mov es, ax - mov di, old_vectors + mov di, _old_vectors mov si, 8 * 4 mov cx, 10h rep movsw diff --git a/kernel/main.c b/kernel/main.c index 30f7cdad..691ab83f 100644 --- a/kernel/main.c +++ b/kernel/main.c @@ -234,6 +234,23 @@ STATIC void setup_int_vectors(void) setvec(0x29, int29_handler); /* required for printf! */ } +#ifdef DEBUGIRQ +extern short old_vectors; +STATIC void printIRQvectors(void) +{ + int i,c=0; + short FAR *pv = MK_FP(0x70 /* ??? */, (short)&old_vectors); + printf("Original IRQ1-16 Int vectors: %x:%x\n", FP_SEG(pv), FP_OFF(pv)); + for (i = 0; i < 16; i++, pv+=2) + { + printf("(%x)%04X:%04X ", i, *pv, *(pv+1)); + c = (c+1)%6; + if (c==0) printf("\n"); + } + printf("\n"); +} +#endif + STATIC void init_kernel(void) { COUNT i; @@ -243,6 +260,8 @@ STATIC void init_kernel(void) LoL->rev_number = REVISION_SEQ; /* move kernel to high conventional RAM, just below the init code */ + /* Note: kernel.asm actually moves and jumps here, but MoveKernel + must still be called to do the necessary segment fixups */ #ifdef __WATCOMC__ lpTop = MK_FP(_CS, 0); #else @@ -251,6 +270,10 @@ STATIC void init_kernel(void) MoveKernel(FP_SEG(lpTop)); /* lpTop should be para-aligned */ + /* Note: during init time (before our MCB chain established) + KernelAlloc returns a para aligned chunk just below last + chunk allocated, lpTop. I.e. lpTop is top of free conv memory + */ lpTop = MK_FP(FP_SEG(lpTop) - 0xfff, 0xfff0); /* Initialize IO subsystem */ @@ -258,7 +281,7 @@ STATIC void init_kernel(void) InitPrinters(); InitSerialPorts(); - init_PSPSet(DOS_PSP); + init_PSPSet(DOS_PSP); /* LoL->_cu_psp = DOS_PSP; */ set_DTA(MK_FP(DOS_PSP, 0x80)); PSPInit(); @@ -289,6 +312,11 @@ STATIC void init_kernel(void) /* and do final buffer allocation. */ PostConfig(); +#ifdef DEBUGIRQ + /* displayed stored IRQ vectors, should be original values */ + printIRQvectors(); +#endif + /* Init the file system one more time */ FsConfig(); @@ -423,6 +451,10 @@ STATIC VOID update_dcb(struct dhdr FAR * dhp) int nunits = dhp->dh_name[0]; struct dpb FAR *dpb = LoL->DPBp; + /* if we have already chained to at least block driver, + then find last DPB in list, reserve some space in + unused (top of convential) memory, and link it in. + */ if (LoL->nblkdev) { while ((LONG) dpb->dpb_next != -1l) diff --git a/kernel/prf.c b/kernel/prf.c index 338d3dad..cc82ba4f 100644 --- a/kernel/prf.c +++ b/kernel/prf.c @@ -27,6 +27,7 @@ /****************************************************************/ #include "portab.h" +#include "debug.h" #ifdef FORSYS #include @@ -118,7 +119,7 @@ void put_console(int c) } #endif /* DOSEMU */ -#if defined(DEBUG) || defined(FORSYS) || defined(_INIT) || defined(TEST) +#if defined(DEBUG_NEED_PRINTF) || defined(FORSYS) || defined(_INIT) || defined(TEST) #ifndef FORSYS /* copied from bcc (Bruce's C compiler) stdarg.h */ From aa82e451e8dfefe620d1f30987289a30876b0072 Mon Sep 17 00:00:00 2001 From: Kenneth J Davis Date: Sun, 30 Jan 2005 14:05:44 +0000 Subject: [PATCH 619/671] correction (for tc2) git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/branches/UNSTABLE@1104 6ac86273-5f31-0410-b378-82cca8765d1b --- hdr/debug.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hdr/debug.h b/hdr/debug.h index d4cf7f1f..70e6cf56 100644 --- a/hdr/debug.h +++ b/hdr/debug.h @@ -110,7 +110,7 @@ defined(DEBUGFATDIR) || defined(DEBUGFATFS) #ifndef DEBUG_NEED_PRINTF #define DEBUG_NEED_PRINTF -void printf(const char *, ...); +VOID VA_CDECL printf(const char * fmt, ...); #endif #endif From bae20d053366d84e8104ea304300162e87169799 Mon Sep 17 00:00:00 2001 From: Kenneth J Davis Date: Sun, 30 Jan 2005 19:32:09 +0000 Subject: [PATCH 620/671] some of Arkady's suggestions (simplify logic), add comments git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/branches/UNSTABLE@1105 6ac86273-5f31-0410-b378-82cca8765d1b --- defaults.bat | 7 +++++-- kernel/initdisk.c | 14 ++++++-------- kernel/inthndlr.c | 4 ++-- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/defaults.bat b/defaults.bat index 163ac979..3835e3d9 100644 --- a/defaults.bat +++ b/defaults.bat @@ -17,11 +17,13 @@ if "%BASE%" == "" goto clearset :----------------------------------------------------------------------- +if not "%BINPATH%" == "" goto skip_binpath set BINPATH=%BASE%\bin if "%COMPILER%" == "TC" set BINPATH=%BASE% if "%COMPILER%" == "WATCOM" set BINPATH=%BASE%\binw -if "%COMPILER%" == "WATCOM" if "%OS%" == "Windows_NT" set BINPATH=%BASE%\binnt +if "%COMPILER%-%OS%" == "WATCOM-Windows_NT" set BINPATH=%BASE%\binnt +:skip_binpath echo Path to compiler programs (binaries) is %BINPATH% :----------------------------------------------------------------------- @@ -32,7 +34,8 @@ set OLDPATH=%PATH% set PATH=%BINPATH%;%PATH% :- MSC searches libraries only through LIB variable. -if "%COMPILER%" == "MSC" set LIB=%MSC_BASE%\lib +:- If already set then assume preset to include MSC's lib +if "%COMPILER%%LIB%" == "MSC" set LIB=%MSC_BASE%\lib :----------------------------------------------------------------------- diff --git a/kernel/initdisk.c b/kernel/initdisk.c index 4134a085..f756928a 100644 --- a/kernel/initdisk.c +++ b/kernel/initdisk.c @@ -595,15 +595,13 @@ void DosDefinePartition(struct DriveParamS *driveParam, pddt->ddt_defbpb.bpb_nheads = driveParam->chs.Head; pddt->ddt_defbpb.bpb_nsecs = driveParam->chs.Sector; pddt->ddt_defbpb.bpb_hidden = pEntry->RelSect; - if (pEntry->NumSect > 0xffff) - { - pddt->ddt_defbpb.bpb_nsize = 0; - pddt->ddt_defbpb.bpb_huge = pEntry->NumSect; - } - else + + pddt->ddt_defbpb.bpb_nsize = 0; + pddt->ddt_defbpb.bpb_huge = pEntry->NumSect; + if (pEntry->NumSect <= 0xffff) { - pddt->ddt_defbpb.bpb_nsize = (UWORD) (pEntry->NumSect); - pddt->ddt_defbpb.bpb_huge = 0; + pddt->ddt_defbpb.bpb_nsize = loword (pEntry->NumSect); + pddt->ddt_defbpb.bpb_huge = 0; /* may still be set on Win95 */ } /* sectors per cluster, sectors per FAT etc. */ diff --git a/kernel/inthndlr.c b/kernel/inthndlr.c index b0943c24..dd1e6892 100644 --- a/kernel/inthndlr.c +++ b/kernel/inthndlr.c @@ -252,7 +252,7 @@ int int21_fat32(lregs *r) if (ISFAT32(dpb)) { if ((dpb->dpb_xfsinfosec == 0xffff - && (nfreeclst != 0 || cluster != 0)) + && (nfreeclst || cluster)) || nfreeclst > dpb->dpb_xsize || cluster > dpb->dpb_xsize) { @@ -1962,7 +1962,7 @@ VOID ASMCFUNC int2F_12_handler(struct int2f12regs r) omitting the NUL device TE */ r.BX = FP_SEG(nul_dev.dh_next); r.AX = FP_OFF(nul_dev.dh_next); - + /* fall through only to re-use break */ case 0x2e: /* GET or SET error table addresse - ignored called by MS debug with DS != DOSDS, printf doesn't work!! */ From 65d87b42c4831f3836959b8e3413a905eba66332 Mon Sep 17 00:00:00 2001 From: Kenneth J Davis Date: Mon, 31 Jan 2005 04:08:39 +0000 Subject: [PATCH 621/671] additional win 3.x compatibility when WIN31SUPPORT defined (untested) git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/branches/UNSTABLE@1106 6ac86273-5f31-0410-b378-82cca8765d1b --- build.bat | 2 + hdr/lol.h | 23 ++++--- hdr/win.h | 38 +++++++++++ kernel/int2f.asm | 7 +- kernel/inthndlr.c | 168 ++++++++++++++++++++++++++++++++++++++++++++++ kernel/kernel.asm | 55 +++++++++++++-- 6 files changed, 278 insertions(+), 15 deletions(-) create mode 100644 hdr/win.h diff --git a/build.bat b/build.bat index b994671c..1fe62336 100644 --- a/build.bat +++ b/build.bat @@ -146,8 +146,10 @@ shift if "%1" == "" echo you MUST specify value to define with /D option if "%1" == "" echo such as /D DEBUG : extra DEBUG output if "%1" == "" echo or /D DOSEMU : printf output goes to dosemu log +if "%1" == "" echo or /D WIN31SUPPORT : enable Win 3.x hooks if "%1" == "" goto abort set ALLCFLAGS=%ALLCFLAGS% -D%1 +set NASMFLAGS=%NASMFLAGS% -D%1 goto nextOption :noenv diff --git a/hdr/lol.h b/hdr/lol.h index ff2174bc..e9da2ebd 100644 --- a/hdr/lol.h +++ b/hdr/lol.h @@ -75,15 +75,20 @@ struct lol { unsigned short uppermem_root;/* 66 Start of umb chain (usually 9fff) */ unsigned short last_para; /* 68 para: start scanning during memalloc */ /* FreeDOS specific entries */ - unsigned char os_setver_minor;/*6a settable minor DOS version */ - unsigned char os_setver_major;/*6b settable major DOS version */ - unsigned char os_minor; /* 6c minor DOS version */ - unsigned char os_major; /* 6d major DOS version */ - unsigned char rev_number; /* 6e minor DOS version */ - unsigned char version_flags; /* 6f DOS version flags */ - struct f_node FAR *f_nodes; /* 70 pointer to the array */ - unsigned short f_nodes_cnt; /* 74 number of allocated f_nodes */ - char *os_release; /* 76 near pointer to os_release string */ + unsigned char os_minor; /* 6a minor DOS version */ + unsigned char os_major; /* 6b major DOS version */ + unsigned char rev_number; /* 6c minor DOS version */ + unsigned char version_flags; /* 6d DOS version flags */ + struct f_node FAR *f_nodes; /* 6e pointer to the array */ + unsigned short f_nodes_cnt; /* 72 number of allocated f_nodes */ + char *os_release; /* 74 near pointer to os_release string */ +#ifdef WIN31SUPPORT + unsigned short winInstanced; /* WinInit called */ + unsigned long winStartupInfo[4]; + unsigned short instanceTable[5]; +#endif + unsigned char os_setver_minor;/*76/96 settable minor DOS version */ + unsigned char os_setver_major;/*77/97 settable major DOS version */ }; #endif /* __LOL_H */ diff --git a/hdr/win.h b/hdr/win.h new file mode 100644 index 00000000..64f035e7 --- /dev/null +++ b/hdr/win.h @@ -0,0 +1,38 @@ +#ifndef __WINSUPPORT_H +#define __WINSUPPORT_H +#ifdef WIN31SUPPORT /* defined to enable kernel hooks for win3.x compatibility */ + + +extern UWORD winInstanced; /* internal flag marking if Windows is active */ + +/* contains information about data that must be kept for each active DOS + instance, ie data that can NOT be shared between multiple VMs. + */ +struct WinStartupInfo +{ + UWORD winver; /* this structure version, matches Windows version */ + ULONG next; /* far pointer to next WinStartupInfo structure or NULL */ + ULONG vddName; /* far pointer to ASCIIZ pathname of virtual device driver */ + ULONG vddInfo; /* far pointer to vdd reference data or NULL if vddName=NULL */ + ULONG instanceTable; /* far pointer to array of instance data */ +}; +extern struct WinStartupInfo winStartupInfo; + +/* contains a list of offsets relative to DOS data segment of + various internal variables. + */ +struct WinPatchTable +{ + UWORD dosver; /* Note: for FreeDOS this overlaps with os_setver version */ + UWORD OffTempDS; + UWORD OffTempBX; + UWORD OffInDOS; + UWORD OffMachineID; + UWORD OffCritSectPatches; + UWORD OffLastMCBSeg; /* used by Win 3.1 if DOS version 5 or higher */ +}; +extern struct WinPatchTable winPatchTable; + + +#endif /* WIN31SUPPORT */ +#endif /* __WINSUPPORT_H */ diff --git a/kernel/int2f.asm b/kernel/int2f.asm index e88c388b..d28ffc0d 100644 --- a/kernel/int2f.asm +++ b/kernel/int2f.asm @@ -54,10 +54,12 @@ Int2f2: FarTabRetn: retf 2 ; Return far Int2f3: - cmp ah,16h - je FarTabRetn ; Win Hook return fast cmp ah,12h je IntDosCal ; Dos Internal calls + cmp ah,16h + je IntDosCal ; Win (Multitasking) Hook + cmp ah,46h + je IntDosCal ; Win Hook to avoid MCB corruption cmp ax,4a01h je IntDosCal ; Dos Internal calls @@ -108,6 +110,7 @@ DriverSysCal: ;********************************************************************** ; internal dos calls INT2F/12xx and INT2F/4A01,4A02 - handled through C +; also handle Windows' DOS notification hooks ;********************************************************************** IntDosCal: ; set up register frame diff --git a/kernel/inthndlr.c b/kernel/inthndlr.c index dd1e6892..765ea0dc 100644 --- a/kernel/inthndlr.c +++ b/kernel/inthndlr.c @@ -59,6 +59,11 @@ struct HugeSectorBlock { BYTE FAR *buf; }; +#ifdef WIN31SUPPORT +#include "win.h" /* Structures used for Windows compatibility */ +#endif /* WIN31SUPPORT */ + + /* Normal entry. This minimizes user stack usage by avoiding local */ /* variables needed for the rest of the handler. */ /* this here works on the users stack !! and only very few functions @@ -1695,6 +1700,7 @@ struct int2f12regs { /* WARNING: modifications in `r' are used outside of int2F_12_handler() * On input r.AX==0x12xx, 0x4A01 or 0x4A02 + * also handle Windows' DOS notification hooks, r.AH==0x16 */ VOID ASMCFUNC int2F_12_handler(struct int2f12regs r) { @@ -1722,6 +1728,168 @@ VOID ASMCFUNC int2F_12_handler(struct int2f12regs r) r.BX = size; return; } + else if (r.AH == 0x16) /* Window/Multitasking hooks */ + { +#ifdef WIN31SUPPORT /* See "DOS Internals" or RBIL under DOSMGR for details */ + switch (r.AL) + { + /* default: unhandled requests pass through unchanged */ + #if 0 + case 0x03: /* Windows Get Instance Data */ + { + /* This should only be called if AX=1607h/BX=15h is not supported. */ + /* The data returned here corresponds directly with text entries that + can also be in INSTANCE.386 [which in theory means Windows could + be updated to support FD kernel without responding to these?]. + */ + break; + } /* 0x03 */ + #endif + case 0x05: /* Windows Startup Broadcast */ + { + /* After receiving this call we activiate compatibility changes + as DOS 5 does, though can wait until 0x07 subfunc 0x01 + */ + /* on entry: + DX flags, bit 0 is set(=1) for standard mode + DI Windows version#, major# in high byte + CX 0, set on exit to nonzero to fail load request + DS:SI is 0000:0000, for enhanced mode, at most 1 program can + set to memory manager calling point to disable V86 + ES:BX is 0000:0000, set to startup structure + */ + r.CX = 0x0; /* it is ok to load Windows, give it a shot anyway :-) */ + r.es = FP_SEG(&winStartupInfo); + r.BX = FP_OFF(&winStartupInfo); + winStartupInfo.winver = r.di; /* match what caller says it is */ + winInstanced = 1; /* internal flag marking Windows is active */ + break; + } /* 0x05 */ + case 0x06: /* Windows Exit Broadcast */ + { + /* can do nothing or can remove any changes made + specifically for Windows, must preserve DS. + Note: If Windows fatally exits then may not be called. + */ + winInstanced = 0; /* internal flag marking Windows is NOT active */ + break; + } /* 0x06 */ + case 0x07: /* DOSMGR Virtual Device API */ + { + if (r.BX == 0x15) /* VxD id of "DOSMGR" */ + { + switch (r.CX) + { + /* default: unhandled requests pass through unchanged */ + case 0x00: /* query if supported */ + { + r.CX = winInstanced; /* should always be nonzero if Win is active */ + r.DX = FP_SEG(&nul_dev); /* data segment / segment of DOS drivers */ + r.es = FP_SEG(&winPatchTable); /* es:bx points to table of offsets */ + r.BX = FP_OFF(&winPatchTable); + break; + } + case 0x01: /* enable Win support, ie patch DOS */ + { + /* DOS 5+ return with flags unchanged, Windows critical section + needs are handled without need to patch. If this + function does not return successfully windows will + attempt to do the patching itself (very bad idea). + On entry BX is bitflags describing support requested, + and on return DX is set to which we can support. + Note: any we report as unhandled Windows will attempt + to patch kernel to handle, probably not a good idea. + 0001h: enable critical section signals (int 2Ah functions + 80h/81h) to allow re-entering DOS while InDOS. + 0002h: allow nonzero local machine ID, ie different VMs + report different values. + FIXME: does this mean we need to set this or does Windows? + 0004h: split up binary reads to increase int 2Ah function 84h scheduling + / turn Int 21h function 3Fh on STDIN into polling loop + 0008h: notify Windows of halting due to internal stack errors + 0010h: notify Windows of logical drive map change ("Insert disk X:") + */ + r.BX = r.DX; /* sure we support everything asked for, ;-) */ + r.DX = 0xA2AB; /* on succes DS:AX set to A2AB:B97Ch */ + r.AX = 0xB97C; + /* FIXME: do we need to do anything special for FD kernel? */ + break; + } + /* case 0x02 is below so we can reuse it for 0x05 */ + case 0x03: /* get internal structure sizes */ + { + if (r.CX & 0x01) /* size of Current Directory Structure in bytes */ + { + r.DX = 0xA2AB; /* on succes DS:AX set to A2AB:B97Ch */ + r.AX = 0xB97C; + r.CX = sizeof(struct cds); + } + else + r.CX = 0; /* unknown or unsupported structure requested */ + break; + } + case 0x04: /* Get Instancing Exemptions */ + { + /* On exit BX is bit flags denoting data that is instanced + so Windows need not instance it. DOS 5&6 fail with DX=CX=0. + 0001h: Current Directory Structure + 0002h: System File Table and device status of STDOUT + 0004h: device driver chain + 0008h: Swappable Data Area + */ + r.DX = 0xA2AB; /* on succes DS:AX set to A2AB:B97Ch */ + r.AX = 0xB97C; + r.BX = 0x0008; /* our whole data seg is instanced, so + anything within it we assume instanced. */ + break; + } + case 0x05: /* get device driver size */ + { + r.DX = 0; /* we aren't one so return unsupported */ + r.AX = 0; + r.BX = 0; + /* fall through to set CX=0 and exit */ + } + case 0x02: /* disable Win support, ie remove patches */ + { + /* Note: if we do anything special in 'patch DOS', undo it here. + This is only called when Windows exits, can be ignored. + */ + r.CX = 0; /* for compatibility with MS-DOS 5/6 */ + break; + } + } + } + break; + } /* 0x07 */ + } +#endif + return; + } + else if (r.AH == 0x46) /* MS Windows WinOLDAP switching */ + { +#ifdef WIN31SUPPORT /* See "DOS Internals" under DOSMGR or RBIL for details */ + if (r.AL == 0x01) /* save MCB */ + { + /* To prevent corruption when dos=umb where Windows 3.0 standard + writes a sentinel at 9FFEh, DOS 5 will save the MCB marking + end of conventional memory (ie MCB following caller's PSP memory + block [which I assume occupies all of convential memory] into + the DOS data segment. + Note: presumably Win3.1 uses the WinPatchTable.OffLastMCBSeg + when DOS ver > 5 to do this itself. + */ + /* FIXME: Implement this! */ + } + else if (r.AL == 0x02) /* restore MCB */ + { + /* Copy the MCB we previously saved back. */ + /* FIXME: Implement this! */ + } +#endif + return; + } + /* else (r.AH == 0x12) */ switch (r.AL) { diff --git a/kernel/kernel.asm b/kernel/kernel.asm index fe01dd56..d68dc4f5 100644 --- a/kernel/kernel.asm +++ b/kernel/kernel.asm @@ -291,10 +291,13 @@ _CDSp dd 0 ; 0016 Current Directory Structure _FCBp dd 0 ; 001a FCB table pointer global _nprotfcb _nprotfcb dw 0 ; 001e number of protected fcbs + ; unused for DOS 5+, see winPatchTable global _nblkdev _nblkdev db 0 ; 0020 number of block devices + ; should match # of DPBs global _lastdrive _lastdrive db 0 ; 0021 value of last drive + ; ie max logical drives, should match # of CDSs global _nul_dev _nul_dev: ; 0022 device chain root extern _con_dev:wrt LGROUP @@ -348,10 +351,6 @@ _uppermem_root dw 0ffffh ; 0066 dmd_upper_root (usually 9fff) _last_para dw 0 ; 0068 para of last mem search SysVarEnd: ;; FreeDOS specific entries - global _os_setver_minor -_os_setver_minor db 0 - global _os_setver_major -_os_setver_major db 5 global _os_minor _os_minor db 0 global _os_major @@ -368,6 +367,51 @@ _f_nodes_cnt dw 0 extern _os_release os_release dw _os_release +%IFDEF WIN31SUPPORT + global _winStartupInfo, _winInstanced +_winInstanced dw 0 ; set to 1 on WinInit broadcast, 0 on WinExit broadcast +_winStartupInfo: + dw 0 ; structure version (same as windows version) + dd 0 ; next startup info structure, 0:0h marks end + dd 0 ; far pointer to name virtual device file or 0:0h + dd 0 ; far pointer, reference data for virtual device driver + dw instance_table,seg instance_table ; array of instance data +instance_table: ; should include stacks, Win may auto determine SDA region + ; we simply include whole DOS data segment + dw 0, seg _DATASTART ; [?linear?] address of region's base + dw markEndInstanceData wrt seg _DATASTART ; size in bytes + dd 0 ; 0 marks end of table + dw 0 + global _winPatchTable +_winPatchTable: ; returns offsets to various internal variables +%ENDIF ; WIN31SUPPORT + ; os version reported, patch table includes DOS version + ; so we include it here to save duplicate data, but even + ; without WIN31SUPPORT enabled these variables are used. + ; The setver variants are used so we report to Windows + ; editable (fake) DOS version user wanted. + global _os_setver_minor, _os_setver_major +_os_setver_major db 0 +_os_setver_minor db 0 +%IFDEF WIN31SUPPORT + dw dummy ; where DS stored during int21h dispatch + dw dummy ; where BX stored during int21h dispatch + dw _InDOS ; offset of InDOS flag + dw _MachineId ; offset to variable containing MachineID + dw _nprotfcb ; offset of to arrary of offsets to patch + ; NOTE: this points to a null terminated + ; array of offsets of critical section bytes + ; to patch, for now we just point this to + ; an empty table, so to save space we are + ; reusing _nprotfcb as it is unused and + ; can ?safely? be assumed to stay 0 + ; ie we just point to a 0 word to mark end + ; FIXME is uppermem_root correct? or do what should we use? + dw _uppermem_root ; seg of last arena header in conv memory +dummy dw 0 ; +;patch_bytes dw 0 ; mark end of array of offsets of critical section bytes to patch +%ENDIF ; WIN31SUPPORT + ;; The first 5 sft entries appear to have to be at DS:00cc times (0cch - ($ - DATASTART)) db 0 global _firstsftt @@ -695,6 +739,9 @@ segment DYN_DATA global _Dyn _Dyn: DynAllocated dw 0 + +markEndInstanceData: ; mark end of DOS data seg we say needs instancing + segment ID_B global __INIT_DATA_START From f89b8aa8e667d71b21fe9c37b9d319442ec5a651 Mon Sep 17 00:00:00 2001 From: Kenneth J Davis Date: Mon, 31 Jan 2005 06:03:16 +0000 Subject: [PATCH 622/671] rearrange a little so saveDS/saveBX match MS locations (still dummy variables) git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/branches/UNSTABLE@1107 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/kernel.asm | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/kernel/kernel.asm b/kernel/kernel.asm index d68dc4f5..90ff7a63 100644 --- a/kernel/kernel.asm +++ b/kernel/kernel.asm @@ -291,7 +291,7 @@ _CDSp dd 0 ; 0016 Current Directory Structure _FCBp dd 0 ; 001a FCB table pointer global _nprotfcb _nprotfcb dw 0 ; 001e number of protected fcbs - ; unused for DOS 5+, see winPatchTable + ; unused for DOS 5+ global _nblkdev _nblkdev db 0 ; 0020 number of block devices ; should match # of DPBs @@ -394,22 +394,20 @@ _winPatchTable: ; returns offsets to various internal variables _os_setver_major db 0 _os_setver_minor db 0 %IFDEF WIN31SUPPORT - dw dummy ; where DS stored during int21h dispatch - dw dummy ; where BX stored during int21h dispatch - dw _InDOS ; offset of InDOS flag + dw save_DS ; where DS stored during int21h dispatch + dw save_BX ; where BX stored during int21h dispatch + dw _InDOS ; offset of InDOS flag dw _MachineId ; offset to variable containing MachineID - dw _nprotfcb ; offset of to arrary of offsets to patch + dw patch_bytes ; offset of to array of offsets to patch ; NOTE: this points to a null terminated ; array of offsets of critical section bytes ; to patch, for now we just point this to - ; an empty table, so to save space we are - ; reusing _nprotfcb as it is unused and - ; can ?safely? be assumed to stay 0 + ; an empty table, purposely not _CritPatch ; ie we just point to a 0 word to mark end - ; FIXME is uppermem_root correct? or do what should we use? dw _uppermem_root ; seg of last arena header in conv memory -dummy dw 0 ; -;patch_bytes dw 0 ; mark end of array of offsets of critical section bytes to patch + ; this matches MS DOS's location, but + ; do we have the same meaning? +patch_bytes dw 0 ; mark end of array of offsets of critical section bytes to patch %ENDIF ; WIN31SUPPORT ;; The first 5 sft entries appear to have to be at DS:00cc @@ -626,8 +624,13 @@ _current_sft_idx dw 0 ;28A - SFT index for next open global _current_filepos _current_filepos times 2 dw 0 ;2AE - current offset in file - ; Pad to 05f0h - times (2d0h - ($ - _internal_data)) db 0 + ; Pad to 05eah + times (2cah - ($ - _internal_data)) db 0 + ;global _save_BX + ;global _save_DS +save_BX dw 0 ;2CA - unused by FreeDOS, for Win3.x +save_DS dw 0 ; compatibility, match MS's positions + dw 0 global _prev_user_r global prev_int21regs_off global prev_int21regs_seg From f9f2461218bf088c96d0fd569031e2dc8a9e88fa Mon Sep 17 00:00:00 2001 From: Luchezar Georgiev Date: Mon, 31 Jan 2005 19:11:18 +0000 Subject: [PATCH 623/671] Fix os_setver_minor and _os_setver_major order git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/branches/UNSTABLE@1108 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/kernel.asm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/kernel.asm b/kernel/kernel.asm index 90ff7a63..9f241733 100644 --- a/kernel/kernel.asm +++ b/kernel/kernel.asm @@ -391,8 +391,8 @@ _winPatchTable: ; returns offsets to various internal variables ; The setver variants are used so we report to Windows ; editable (fake) DOS version user wanted. global _os_setver_minor, _os_setver_major -_os_setver_major db 0 _os_setver_minor db 0 +_os_setver_major db 0 %IFDEF WIN31SUPPORT dw save_DS ; where DS stored during int21h dispatch dw save_BX ; where BX stored during int21h dispatch From 304aaa1428364ff770929c1d05ca805159301cbc Mon Sep 17 00:00:00 2001 From: Kenneth J Davis Date: Mon, 31 Jan 2005 20:48:32 +0000 Subject: [PATCH 624/671] retry, revert FreeDOS specific variables back to original locations git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/branches/UNSTABLE@1109 6ac86273-5f31-0410-b378-82cca8765d1b --- hdr/lol.h | 19 ++++++++++--------- hdr/win.h | 2 +- kernel/kernel.asm | 22 ++++++++++------------ 3 files changed, 21 insertions(+), 22 deletions(-) diff --git a/hdr/lol.h b/hdr/lol.h index e9da2ebd..e12e539b 100644 --- a/hdr/lol.h +++ b/hdr/lol.h @@ -75,20 +75,21 @@ struct lol { unsigned short uppermem_root;/* 66 Start of umb chain (usually 9fff) */ unsigned short last_para; /* 68 para: start scanning during memalloc */ /* FreeDOS specific entries */ - unsigned char os_minor; /* 6a minor DOS version */ - unsigned char os_major; /* 6b major DOS version */ - unsigned char rev_number; /* 6c minor DOS version */ - unsigned char version_flags; /* 6d DOS version flags */ - struct f_node FAR *f_nodes; /* 6e pointer to the array */ - unsigned short f_nodes_cnt; /* 72 number of allocated f_nodes */ - char *os_release; /* 74 near pointer to os_release string */ + unsigned char os_setver_minor;/*6a settable minor DOS version */ + unsigned char os_setver_major;/*6b settable major DOS version */ + unsigned char os_minor; /* 6c minor DOS version */ + unsigned char os_major; /* 6d major DOS version */ + unsigned char rev_number; /* 6e minor DOS version */ + unsigned char version_flags; /* 6f DOS version flags */ + struct f_node FAR *f_nodes; /* 70 pointer to the array */ + unsigned short f_nodes_cnt; /* 74 number of allocated f_nodes */ + char *os_release; /* 76 near pointer to os_release string */ + /* ANY ITEM BELOW THIS POINT MAY CHANGE */ #ifdef WIN31SUPPORT unsigned short winInstanced; /* WinInit called */ unsigned long winStartupInfo[4]; unsigned short instanceTable[5]; #endif - unsigned char os_setver_minor;/*76/96 settable minor DOS version */ - unsigned char os_setver_major;/*77/97 settable major DOS version */ }; #endif /* __LOL_H */ diff --git a/hdr/win.h b/hdr/win.h index 64f035e7..cde08a5d 100644 --- a/hdr/win.h +++ b/hdr/win.h @@ -23,7 +23,7 @@ extern struct WinStartupInfo winStartupInfo; */ struct WinPatchTable { - UWORD dosver; /* Note: for FreeDOS this overlaps with os_setver version */ + UWORD dosver; UWORD OffTempDS; UWORD OffTempBX; UWORD OffInDOS; diff --git a/kernel/kernel.asm b/kernel/kernel.asm index 9f241733..00e6ce1f 100644 --- a/kernel/kernel.asm +++ b/kernel/kernel.asm @@ -351,6 +351,10 @@ _uppermem_root dw 0ffffh ; 0066 dmd_upper_root (usually 9fff) _last_para dw 0 ; 0068 para of last mem search SysVarEnd: ;; FreeDOS specific entries + global _os_setver_minor +_os_setver_minor db 0 + global _os_setver_major +_os_setver_major db 5 global _os_minor _os_minor db 0 global _os_major @@ -367,6 +371,9 @@ _f_nodes_cnt dw 0 extern _os_release os_release dw _os_release +;; any FreeDOS variable below this point are subject to relocation. +;; variables above should not change (unless necessary) as +;; programs may make use of them (even though they should NOT!) %IFDEF WIN31SUPPORT global _winStartupInfo, _winInstanced _winInstanced dw 0 ; set to 1 on WinInit broadcast, 0 on WinExit broadcast @@ -381,19 +388,11 @@ instance_table: ; should include stacks, Win may auto determine SDA region dw 0, seg _DATASTART ; [?linear?] address of region's base dw markEndInstanceData wrt seg _DATASTART ; size in bytes dd 0 ; 0 marks end of table - dw 0 +patch_bytes: ; mark end of array of offsets of critical section bytes to patch + dw 0 ; and 0 length for end of instance_table entry global _winPatchTable _winPatchTable: ; returns offsets to various internal variables -%ENDIF ; WIN31SUPPORT - ; os version reported, patch table includes DOS version - ; so we include it here to save duplicate data, but even - ; without WIN31SUPPORT enabled these variables are used. - ; The setver variants are used so we report to Windows - ; editable (fake) DOS version user wanted. - global _os_setver_minor, _os_setver_major -_os_setver_minor db 0 -_os_setver_major db 0 -%IFDEF WIN31SUPPORT + dw 0x0006 ; DOS version, major# in low byte, eg. 6.00 dw save_DS ; where DS stored during int21h dispatch dw save_BX ; where BX stored during int21h dispatch dw _InDOS ; offset of InDOS flag @@ -407,7 +406,6 @@ _os_setver_major db 0 dw _uppermem_root ; seg of last arena header in conv memory ; this matches MS DOS's location, but ; do we have the same meaning? -patch_bytes dw 0 ; mark end of array of offsets of critical section bytes to patch %ENDIF ; WIN31SUPPORT ;; The first 5 sft entries appear to have to be at DS:00cc From 30ac4c1a014911bd02b754582d0b8dc728f185a1 Mon Sep 17 00:00:00 2001 From: Luchezar Georgiev Date: Wed, 2 Feb 2005 07:47:34 +0000 Subject: [PATCH 625/671] Suppress spurious warning on 1022 cylinder LBA partition and optimise a bit git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/branches/UNSTABLE@1110 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/initdisk.c | 123 +++++++++++++++++----------------------------- 1 file changed, 45 insertions(+), 78 deletions(-) diff --git a/kernel/initdisk.c b/kernel/initdisk.c index f756928a..113c5350 100644 --- a/kernel/initdisk.c +++ b/kernel/initdisk.c @@ -348,6 +348,13 @@ void printCHS(char *title, struct CHS *chs) printf("%s%4u-%u-%u", title, chs->Cylinder, chs->Head, chs->Sector); } +STATIC VOID printStartEnd(struct CHS *chs, struct CHS *end) +{ + printCHS(" start ", chs); + printCHS(", end ", end); + printf("\n"); +} + /* reason for this modules existence: @@ -807,66 +814,45 @@ BOOL ConvPartTableEntryToIntern(struct PartTableEntry * pEntry, return TRUE; } -BOOL is_suspect(struct CHS *chs, struct CHS *pEntry_chs) +STATIC void warning_suspect(char *partitionName, struct CHS *chs, + struct CHS *pEntry_chs) { - /* Valid entry: - entry == chs || // partition entry equal to computed values - (chs->Cylinder > 1023 && // or LBA partition - (entry->Cylinder == 1023 || - entry->Cylinder == (0x3FF & chs->Cylinder))) - */ - return !((pEntry_chs->Cylinder == chs->Cylinder && - pEntry_chs->Head == chs->Head && - pEntry_chs->Sector == chs->Sector) || - chs->Cylinder > 1023u && - (pEntry_chs->Cylinder == 1023 || - pEntry_chs->Cylinder == (0x3ff & chs->Cylinder))); -} - -void print_warning_suspect(char *partitionName, UBYTE fs, struct CHS *chs, - struct CHS *pEntry_chs) -{ - printf("WARNING: using suspect partition %s FS %02x:", partitionName, fs); - printCHS(" with calculated values ", chs); - printCHS(" instead of ", pEntry_chs); - printf("\n"); - memcpy(pEntry_chs, chs, sizeof(struct CHS)); + if (pEntry_chs->Cylinder != (chs->Cylinder & 0x3FF) + || pEntry_chs->Head != chs->Head + || pEntry_chs->Sector != chs->Sector) + { + printf("WARNING: %s", partitionName); + printCHS(" has CHS=", chs); + printCHS(", not ", pEntry_chs); + printf("\n"); + memcpy(pEntry_chs, chs, sizeof(struct CHS)); + } } -BOOL ScanForPrimaryPartitions(struct DriveParamS * driveParam, int scan_type, +int ScanForPrimaryPartitions(struct DriveParamS * driveParam, int scan_type, struct PartTableEntry * pEntry, ULONG startSector, int partitionsToIgnore, int extendedPartNo) { int i; struct CHS chs, end; ULONG partitionStart; - char partitionName[12]; + char partitionName[28]; for (i = 0; i < 4; i++, pEntry++) { - if (pEntry->FileSystem == 0) - continue; - - if (partitionsToIgnore & (1 << i)) - continue; - - if (IsExtPartition(pEntry->FileSystem)) - continue; - - if (scan_type == SCAN_PRIMARYBOOT && !pEntry->Bootable) + if (pEntry->FileSystem == 0 + || partitionsToIgnore & (1 << i) + || IsExtPartition(pEntry->FileSystem) + || scan_type == SCAN_PRIMARYBOOT && !pEntry->Bootable + || !IsFATPartition(pEntry->FileSystem)) continue; partitionStart = startSector + pEntry->RelSect; - if (!IsFATPartition(pEntry->FileSystem)) - { - continue; - } - - if (extendedPartNo) - sprintf(partitionName, "Ext:%d", extendedPartNo); - else - sprintf(partitionName, "Pri:%d", i + 1); + sprintf(partitionName, "partition %s:%d FS %02x", + extendedPartNo ? "Ext" : "Pri", + extendedPartNo ? extendedPartNo : i + 1, + pEntry->FileSystem); /* some sanity checks, that partition @@ -876,39 +862,25 @@ BOOL ScanForPrimaryPartitions(struct DriveParamS * driveParam, int scan_type, LBA_to_CHS(&end, partitionStart + pEntry->NumSect - 1, driveParam); /* some FDISK's enter for partitions - > 8 GB cyl = 1023, other (cyl&1023) + > 8 GB cyl = 1022 or 1023, other (cyl&1023) */ - - if (is_suspect(&chs, &pEntry->Begin)) + if (!IsLBAPartition(pEntry->FileSystem)) { - print_warning_suspect(partitionName, pEntry->FileSystem, &chs, - &pEntry->Begin); + warning_suspect(partitionName, &chs, &pEntry->Begin); + warning_suspect(partitionName, &end, &pEntry->End); } - - if (is_suspect(&end, &pEntry->End)) + if (pEntry->NumSect == 0) { - if (pEntry->NumSect == 0) - { - printf("Not using partition %s with 0 sectors\n", partitionName); - continue; - } - print_warning_suspect(partitionName, pEntry->FileSystem, &end, - &pEntry->End); + printf("Not using %s with 0 sectors\n", partitionName); + continue; } - if (chs.Cylinder > 1023 || end.Cylinder > 1023) { if (!(driveParam->descflags & DF_LBA)) { - printf - ("can't use LBA partition without LBA support - part %s FS %02x", - partitionName, pEntry->FileSystem); - - printCHS(" start ", &chs); - printCHS(", end ", &end); - printf("\n"); - + printf("Can't use LBA %s without LBA support", partitionName); + printStartEnd(&chs, &end); continue; } @@ -916,13 +888,10 @@ BOOL ScanForPrimaryPartitions(struct DriveParamS * driveParam, int scan_type, && !IsLBAPartition(pEntry->FileSystem)) { printf - ("WARNING: Partition ID does not suggest LBA - part %s FS %02x.\n" + ("WARNING: %s is not LBA\n" "Please run FDISK to correct this - using LBA to access partition.\n", - partitionName, pEntry->FileSystem); - - printCHS(" start ", &chs); - printCHS(", end ", &end); - printf("\n"); + partitionName); + printStartEnd(&chs, &end); pEntry->FileSystem = (pEntry->FileSystem == FAT12 ? FAT12_LBA : pEntry->FileSystem == FAT32 ? FAT32_LBA : /* pEntry->FileSystem == FAT16 ? */ @@ -931,11 +900,9 @@ BOOL ScanForPrimaryPartitions(struct DriveParamS * driveParam, int scan_type, /* else its a diagnostic message only */ #ifdef DEBUG - printf("found and using LBA partition %s FS %02x", - partitionName, pEntry->FileSystem); - printCHS(" start ", &chs); - printCHS(", end ", &end); - printf("\n"); + printf("found and using LBA %s", + partitionName); + printStartEnd(&chs, &end); #endif } From e936a15c6b75298683d4a2404e65ece1608b00d0 Mon Sep 17 00:00:00 2001 From: Luchezar Georgiev Date: Wed, 2 Feb 2005 20:32:37 +0000 Subject: [PATCH 626/671] Include lol.h in makefile header list git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/branches/UNSTABLE@1111 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/makefile b/kernel/makefile index 68717a3c..14159e93 100644 --- a/kernel/makefile +++ b/kernel/makefile @@ -75,7 +75,7 @@ procsupt.obj: procsupt.asm segs.inc $(HDR)stacks.inc serial.obj: serial.asm io.inc HDRS=\ - $(HDR)portab.h $(HDR)device.h $(HDR)mcb.h $(HDR)pcb.h \ + $(HDR)portab.h $(HDR)device.h $(HDR)mcb.h $(HDR)pcb.h $(HDR)lol.h\ $(HDR)fat.h $(HDR)fcb.h $(HDR)tail.h $(HDR)time.h $(HDR)process.h \ $(HDR)dcb.h $(HDR)sft.h $(HDR)cds.h $(HDR)exe.h $(HDR)fnode.h \ $(HDR)dirmatch.h $(HDR)file.h $(HDR)clock.h $(HDR)kbd.h $(HDR)error.h \ From e7880c117f6e46ab690f1e51c9b8ebbd38605079 Mon Sep 17 00:00:00 2001 From: Luchezar Georgiev Date: Sun, 6 Feb 2005 19:00:33 +0000 Subject: [PATCH 627/671] Remove condition checks that are already included in other condition checks git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/branches/UNSTABLE@1112 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/initdisk.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/kernel/initdisk.c b/kernel/initdisk.c index 113c5350..ba92c468 100644 --- a/kernel/initdisk.c +++ b/kernel/initdisk.c @@ -840,9 +840,7 @@ int ScanForPrimaryPartitions(struct DriveParamS * driveParam, int scan_type, for (i = 0; i < 4; i++, pEntry++) { - if (pEntry->FileSystem == 0 - || partitionsToIgnore & (1 << i) - || IsExtPartition(pEntry->FileSystem) + if (partitionsToIgnore & (1 << i) || scan_type == SCAN_PRIMARYBOOT && !pEntry->Bootable || !IsFATPartition(pEntry->FileSystem)) continue; From 10d6282175e4c2c56a4b9fcb81d004d7d6512387 Mon Sep 17 00:00:00 2001 From: Kenneth J Davis Date: Fri, 11 Feb 2005 12:46:06 +0000 Subject: [PATCH 628/671] comment additional, but unused fields in PSP git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/branches/UNSTABLE@1113 6ac86273-5f31-0410-b378-82cca8765d1b --- hdr/process.h | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/hdr/process.h b/hdr/process.h index 2b654d7e..3fca29e3 100644 --- a/hdr/process.h +++ b/hdr/process.h @@ -70,9 +70,9 @@ typedef struct { /* CP/M-like entry point */ UBYTE ps_farcall; /* 05 far call opcode */ VOID(FAR ASMCFUNC * ps_reentry) (void); /* 06 re-entry point */ - intvec ps_isv22, /* 0a terminate address */ - ps_isv23, /* 0e break address */ - ps_isv24; /* 12 critical error address */ + intvec ps_isv22, /* 0a terminate address */ + ps_isv23, /* 0e ctrl-break address */ + ps_isv24; /* 12 critical error address */ UWORD ps_parent; /* 16 parent psp segment */ UBYTE ps_files[20]; /* 18 file table - 0xff is unused */ UWORD ps_environ; /* 2c environment paragraph */ @@ -80,7 +80,14 @@ typedef struct { UWORD ps_maxfiles; /* 32 maximum open files */ UBYTE FAR *ps_filetab; /* 34 open file table pointer */ VOID FAR *ps_prevpsp; /* 38 previous psp pointer */ - BYTE ps_fill2[20]; /* 3c */ + UBYTE ps_fill2; /* 3c unused */ + UBYTE ps_truename; /* 3d [unused] append truename flag int2f/B711h */ + UBYTE ps_netx_taskid[2]; /* 3e [Novell only field] task id */ + UWORD ps_retdosver; /* 40 [unused] version to return on int21/30h */ + UWORD pdb_next; /* 42 [Win only field] PSP chain */ + UBYTE ps_fill2b[4]; /* 44 unused, 4 bytes */ + UBYTE ps_olddos; /* 48 [Win only field] DOS/Win program */ + UBYTE ps_fill2c[7]; /* 49 unused, 7 bytes */ UBYTE ps_unix[3]; /* 50 unix style call - 0xcd 0x21 0xcb */ BYTE ps_fill3[9]; /* 53 */ union { From ed11301d847c82de9d38c2f12f3ffcf5ac31b9ed Mon Sep 17 00:00:00 2001 From: Kenneth J Davis Date: Sat, 12 Feb 2005 06:34:17 +0000 Subject: [PATCH 629/671] convert to native EOLs (not CRNL on unix and CRCRNL on win) git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/branches/UNSTABLE@1114 6ac86273-5f31-0410-b378-82cca8765d1b From 726b3f5af1585389326481dec3515e7cccca6636 Mon Sep 17 00:00:00 2001 From: Kenneth J Davis Date: Sat, 28 May 2005 12:10:29 +0000 Subject: [PATCH 630/671] set backup boot sector on FAT32, add update option, fix oemboot to work with msdos 7+ git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/branches/UNSTABLE@1125 6ac86273-5f31-0410-b378-82cca8765d1b --- boot/oemboot.asm | 128 +++++++++++++++++++++++++++++++++-------------- docs/sys.htm | 12 ++++- docs/sys.txt | 3 +- sys/sys.c | 100 +++++++++++++++++++++++++++--------- 4 files changed, 181 insertions(+), 62 deletions(-) diff --git a/boot/oemboot.asm b/boot/oemboot.asm index 16edb530..a57bdbcc 100644 --- a/boot/oemboot.asm +++ b/boot/oemboot.asm @@ -5,17 +5,20 @@ ; Copyright (c) 200?, ; Description: ; OEM boot sector for FreeDOS compatible with IBM's (R) PC-DOS, -; and Microsoft's (R) PC-DOS. It may work with OpenDOS/DR-DOS, -; although the standard FreeDOS boot sector works with later +; and Microsoft's (R) MS-DOS. It may work with older OpenDOS/DR-DOS, +; although the standard FreeDOS boot sector is needed with ver 7+ ; releases. May work with other versions of DOS that use ; IBMBIO.COM/IBMDOS.COM pair. This boot sector loads only up ; to 58 sectors (29KB) of the kernel (IBMBIO.COM) to 0x70:0 then -; jumps to it. As best I can tell, PC-DOS (and assuming MS-DOS -; behaves similar) expects on entry for: +; jumps to it. As best I can tell, PC-DOS (and MS-DOS up to version +; 6.xx behaves similar) expects on entry for: ; ch = media id byte in the boot sector ; dl = BIOS drive booted from (0x00=A:, 0x80=C:, ...) -; ax:bx = the LBA sector of 1st data sector 0x0000:0021 for FAT12 -; ?or? 1st sector of IBMBIO.COM (which is normally 1st data sector) +; ax:bx = the starting (LBA) sector of cluster 2 (ie the 1st +; data sector, which is 0x0000:0021 for FAT12) +; ?note? IBMBIO.COM/IO.SYS may use ax:bx and cluster # stored +; elsewhere (perhaps dir entry still at 0x50:0) to determine +; starting sector for full loading of kernel file. ; it also expects the boot sector (in particular the BPB) ; to still be at 0x0:7C00, the directory entry for IBMBIO.COM ; (generally first entry of first sector of the root directory) @@ -24,6 +27,26 @@ ; may fail for any systems where the changes (???) are needed. ; If the above conditions are not met, then IBMBIO.COM will ; print the not a bootable disk error message. +; +; For MS-DOS >= 7 (ie Win9x DOS) the following conditions +; must be met: +; bp = 0x7C00, ie offset boot sector loaded at +; [bp-4] = the starting (LBA) sector of cluster 2 (ie the 1st +; data sector [this is the same as ax:bx for earlier versions +; and dx:ax in Win9x boot sector] +; The starting cluster of the kernel file is stored in +; di for FAT 12/16 (where si is a don't care) and si:di +; for FAT 32. +; The values for ax,bx,cx,dx,ds and the stack do not +; seem to be important (used by IO.SYS) and so may be any value +; (though dx:ax=[data_start], cx=0, bx=0x0f00 on FAT12 or +; 0x0700 on FAT32, ds=0, ss:sp=0:7b??) + +; the boot time stack may store the original int1E floppy +; parameter table, otherwise nothing else important seems +; stored there and I am unsure if even this value is used +; beyond boot sector code. + ; ; This boot sector only supports FAT12/FAT16 as PC-DOS ; does not support FAT32 and newer FAT32 capable DOSes @@ -78,29 +101,39 @@ ; |BOOT SEC| contains BPB ; |ORIGIN | ; |--------| 0000:7C00 (0:BP) +; |VARS | only known is 1st data sector (start of cluster 2) +; |--------| 0000:7BFC (DS:[BP-4]) ; |STACK | minimal 256 bytes (1/2 sector) ; |- - - - | ; |KERNEL | kernel loaded here (max 58 sectors, 29KB) ; |LOADED | also used as FAT buffer ; |--------| 0070:0000 (0:0700) ; |DOS DA/ | DOS Data Area, -; |ROOT DIR| during boot the 1st sector of root directory +; |ROOT DIR| during boot contains directory entries ; |--------| 0000:0500 ; |BDA | BIOS Data Area ; +--------+ 0000:0400 ; |IVT | Interrupt Vector Table ; +--------+ 0000:0000 +CPU 8086 ; enable assembler warnings to limit instruction set ;%define ISFAT12 1 ; only 1 of these should be set, ;%define ISFAT16 1 ; defines which FAT is supported %define TRYLBAREAD 1 ; undefine to use only CHS int 13h -;%define LOOPONERR 1 ; if defined on error simply loop forever -;%define SETROOTDIR 1 ; if defined dir entry copied to 0:500 +%define SETROOTDIR 1 ; if defined dir entry copied to 0:500 +%define LOOPONERR 1 ; if defined on error simply loop forever ;%define RETRYALWAYS 1 ; if defined retries read forever +;%define WINBOOT 1 ; use win9x kernel calling conventions (name & jmp addr) ;%define MSCOMPAT 1 ; sets default filename to MSDOS IO.SYS +%ifdef WINBOOT ; if set also change from PC-DOS to +%ifndef MSCOMPAT ; kernel name to MS-DOS kernel name +%define MSCOMPAT +%endif +%endif + segment .text %define BASE 0x7c00 ; boot sector originally at 0x0:BASE @@ -133,7 +166,8 @@ segment .text ;%define RootDirSecs PARAMS+0x0 ; # of sectors root dir uses %define fat_start PARAMS+0x2 ; first FAT sector ;%define root_dir_start PARAMS+0x6 ; first root directory sector -%define data_start PARAMS+0x0a ; first data sector +%define first_cluster PARAMS+0x0a ; starting cluster of kernel file +%define data_start bp-4 ; first data sector (win9x expects here) ;----------------------------------------------------------------------- @@ -203,20 +237,33 @@ real_start: mov es, ax mov ss, ax mov bp, BASE - lea sp, [bp-2] - - ; a reset should not be needed here -; int 0x13 ; reset drive + lea sp, [bp-4] ; for DOS <7 this may be [bp] ; For compatibility, diskette parameter vector updated. -; lea di [bp+0x3E] ; just use bp for DR-DOS? +; lea di [bp+0x3E] ; use 7c3e([bp+3e]) for PC-DOS, +; ;lea di [bp] ; but 7c00([bp]) for DR-DOS 7 bug ; mov bx, 4 * 1eh ; stored at int 1E's vector ; lds si, [bx] ; fetch current int 1eh pointer +; push ds ; store original 1eh pointer at stack top +; push si ; so can restore later if needed +; +; Copy table to new location ; mov cl, 11 ; the parameter table is 11 bytes ; rep movsb ; and copy the parameter block ; mov ds, ax ; restore DS +; +; Note: make desired changes to table here +; +; Update int1E to new location +; mov [bx+2], 0 ; set to 0:bp or 0:bp+3e as appropriate +; mov word [bx], 0x7c3e ; (use 0x7c00 for DR-DOS) sti ; enable interrupts + +; If updated floppy parameter table then must notify BIOS +; Otherwise a reset should not be needed here. +; int 0x13 ; reset drive (AX=0) + ; ; Note: some BIOS implementations may not correctly pass drive number ; in DL, however we work around this in SYS.COM by NOP'ing out the use of DL @@ -290,22 +337,21 @@ next_entry: mov cx, 11 je ffDone add si, byte 0x20 ; go to next directory entry - jc near boot_error ; fail if not found and si wraps + jc boot_error ; fail if not found and si wraps cmp byte [si], 0 ; if the first byte of the name is 0, jnz next_entry ; there are no more files in the directory ffDone: - push ax ; store first cluster number + mov [first_cluster], ax ; store first cluster number %ifdef SETROOTDIR ; copy over this portion of root dir to 0x0:500 for PC-DOS ; (this may allow IBMBIO.COM to start in any directory entry) lea di, [ROOTDIR] ; es:di = 0:0500 - mov cx, 0x100 + mov cx, 32 ; limit to this 1 entry (rest don't matter) rep movsw %endif - ; GETFATCHAIN: ; ; Reads the FAT chain and stores it in a temporary buffer in the first @@ -334,7 +380,7 @@ ffDone: mov ax, LOADSEG mov ds, ax ; ds:0 = 0x70:0 = 0:FATBUF - pop ax ; restore first cluster number + mov ax, [first_cluster] ; restore first cluster number push ds ; store LOADSEG next_clust: stosw ; store cluster number @@ -403,7 +449,30 @@ cluster_next: lodsw ; AX = next cluster to read mov ch, [bsMedia] ; ch set to media id mov ax, [data_start+2] ; ax:bx set to 1st data sector mov bx, [data_start] ; + mov di, [first_cluster] ; set di (si:di on FAT32) to starting cluster # +%ifdef WINBOOT + jmp LOADSEG:0x0200 ; yes, pass control to kernel +%else jmp LOADSEG:0000 ; yes, pass control to kernel +%endif + + +; failed to boot +boot_error: +call show +; db "Error! Hit a key to reboot." + db "):." +%ifdef LOOPONERR +jmp $ +%else + + ; Note: should restore floppy paramater table address at int 0x1E + xor ah,ah + int 0x13 ; reset floppy + int 0x16 ; wait for a key + int 0x19 ; reboot the machine +%endif + load_next: dec ax ; cluster numbers start with 2 dec ax @@ -428,22 +497,6 @@ show: pop si jne show ; until done ret -; failed to boot - -boot_error: -%ifdef LOOPONERR -jmp boot_error -%else -call show -; db "Error! Hit a key to reboot." - db "Err." - - xor ah,ah - int 0x13 ; reset floppy - int 0x16 ; wait for a key - int 0x19 ; reboot the machine -%endif - ; readDisk: Reads a number of sectors into memory. ; @@ -564,7 +617,8 @@ read_next_chained: read_ok: mov ax, word [bsBytesPerSec] - shr ax, 4 ; adjust segment pointer by increasing + mov cl, 4 ; adjust segment pointer by increasing + shr ax, cl add word [LBA_SEG], ax ; by paragraphs read in (per sector) add LBA_SECTOR_0, byte 1 diff --git a/docs/sys.htm b/docs/sys.htm index 0b50839b..949db0ba 100644 --- a/docs/sys.htm +++ b/docs/sys.htm @@ -1,5 +1,5 @@ -sys +sys - FreeDOS system file installer

sys

Copy system files and make a floppy disk or hard disk bootable. @@ -32,6 +32,16 @@

Options

but the kernel and command.com will not be copied to the destination. + /UPDATE + This option is for updating (or changing) your kernel while + leaving your shell alone. Updates the boot sector and copies + the kernel file(s) to the destination. [Allows installing + latest kernel and boot sector without making a copy of your + current COMMAND.COM or other shell first.] Note: for FreeDOS + kernel, an upgrade can also be performed by simply copying + KERNEL.SYS over an existing bootable one (though making a + backup of your current kernel is encouraged). + /K filename Gives the filename of the kernel file to be copied. This option is only required when the kernel is not called "kernel.sys" diff --git a/docs/sys.txt b/docs/sys.txt index 72928696..f5f13f4d 100644 --- a/docs/sys.txt +++ b/docs/sys.txt @@ -1,4 +1,4 @@ -FreeDOS SYS 3.5 +FreeDOS SYS 3.6 documentation by: Jeremy Davis Bart Oldeman @@ -22,6 +22,7 @@ SYS [source] dest: [bootsect] [{option}] {option} is one or more of the following: /BOTH : write to *both* the real boot sector and the image file /BOOTONLY: do *not* copy kernel / shell, only update boot sector or image + /UPDATE : copy kernel and update boot sector (do *not* copy shell) /OEM : indicates boot sector, filenames, and load segment to use /OEM:FD use FreeDOS compatible settings /OEM:DR use DR DOS 7+ compatible settings (same as /OEM) diff --git a/sys/sys.c b/sys/sys.c index fa1b9282..042d7f2a 100644 --- a/sys/sys.c +++ b/sys/sys.c @@ -32,7 +32,7 @@ #define FDCONFIG /* include support to configure FD kernel */ /* #define DRSYS */ /* SYS for Enhanced DR-DOS (OpenDOS enhancement Project) */ -#define SYS_VERSION "v3.5b" +#define SYS_VERSION "v3.6" #define SYS_NAME "FreeDOS System Installer " @@ -293,25 +293,26 @@ int FDKrnConfigMain(int argc, char **argv); typedef struct DOSBootFiles { const char * kernel; /* filename boot sector loads and chains to */ const char * dos; /* optional secondary file for OS */ - WORD loadseg; /* segment kernel file expects to start at */ + WORD loadaddr; /* segment kernel file expects to start at for stdbs */ + /* or offset to jump into kernel for oem compat bs */ BOOL stdbs; /* use FD boot sector (T) or oem compat one (F) */ LONG minsize; /* smallest dos file can be and be valid, 0=existance optional */ } DOSBootFiles; -#define FREEDOS_FILES { "KERNEL.SYS", NULL, 0x60, 1, 0 }, +#define FREEDOS_FILES { "KERNEL.SYS", NULL, 0x60/*:0*/, 1, 0 }, DOSBootFiles bootFiles[] = { /* Note: This order is the order OEM:AUTO uses to determine DOS flavor. */ #ifndef DRSYS /* FreeDOS */ FREEDOS_FILES #endif - /* DR-DOS */ { "DRBIO.SYS", "DRDOS.SYS", 0x70, 1, 1 }, - /* DR-DOS */ { "IBMBIO.COM", "IBMDOS.COM", 0x70, 1, 1 }, + /* DR-DOS */ { "DRBIO.SYS", "DRDOS.SYS", 0x70/*:0*/, 1, 1 }, + /* DR-DOS */ { "IBMBIO.COM", "IBMDOS.COM", 0x70/*:0*/, 1, 1 }, #ifdef DRSYS /* FreeDOS */ FREEDOS_FILES #endif #ifdef WITHOEMCOMPATBS - /* PC-DOS */ { "IBMBIO.COM", "IBMDOS.COM", 0x70, 0, 6138 }, /* pre v7 DR ??? */ - /* MS-DOS */ { "IO.SYS", "MSDOS.SYS", 0x70, 0, 10240 }, - /* W9x-DOS */ { "IO.SYS", "MSDOS.SYS", 0x70, 0, 0}, + /* PC-DOS */ { "IBMBIO.COM", "IBMDOS.COM", /*0x70:*/0x0, 0, 6138 }, /* pre v7 DR ??? */ + /* MS-DOS */ { "IO.SYS", "MSDOS.SYS", /*0x70:*/0x0, 0, 10240 }, + /* W9x-DOS */ { "IO.SYS", "MSDOS.SYS", /*0x70:*/0x0200, 0, 0 }, #endif }; #define DOSFLAVORS (sizeof(bootFiles) / sizeof(*bootFiles)) @@ -356,7 +357,8 @@ typedef struct SYSOptions { DOSBootFiles kernel; /* file name(s) and relevant data for kernel */ BYTE defBootDrive; /* value stored in boot sector for drive, eg 0x0=A, 0x80=C */ BOOL ignoreBIOS; /* true to NOP out boot sector code to get drive# from BIOS */ - BOOL copyFiles; /* true to copy kernel files and command interpreter */ + BOOL copyKernel; /* true to copy kernel files */ + BOOL copyShell; /* true to copy command interpreter */ BOOL writeBS; /* true to write boot sector to drive/partition LBA 0 */ BYTE *bsFile; /* file name & path to save bs to when saving to file */ BYTE *bsFileOrig; /* file name & path to save original bs when backing up */ @@ -382,6 +384,7 @@ void showHelpAndExit(void) " {option} is one or more of the following:\n" " /BOTH : write to *both* the real boot sector and the image file\n" " /BOOTONLY: do *not* copy kernel / shell, only update boot sector or image\n" + " /UPDATE : copy kernel and update boot sector (do *not* copy shell)\n" " /OEM : indicates boot sector, filenames, and load segment to use\n" " /OEM:FD use FreeDOS compatible settings\n" " /OEM:EDR use Enhanced DR DOS 7+ compatible settings\n" @@ -400,7 +403,7 @@ void showHelpAndExit(void) "%s CONFIG /help\n" #endif /*SYS, KERNEL.SYS/DRBIO.SYS 0x60/0x70*/ - , pgm, bootFiles[0].kernel, bootFiles[0].loadseg + , pgm, bootFiles[0].kernel, bootFiles[0].loadaddr #ifdef FDCONFIG , pgm #endif @@ -422,7 +425,8 @@ void initOptions(int argc, char *argv[], SYSOptions *opts) memset(opts, 0, sizeof(SYSOptions)); /* set srcDrive and dstDrive after processing args */ opts->flavor = OEM_AUTO; /* attempt to detect DOS user wants to boot */ - opts->copyFiles = 1; /* actually copy the kernel and cmd interpreter to dstDrive */ + opts->copyKernel = 1; /* actually copy the kernel and cmd interpreter to dstDrive */ + opts->copyShell = 1; /* cycle through processing cmd line arguments */ for(argno = 1; argno < argc; argno++) @@ -446,7 +450,14 @@ void initOptions(int argc, char *argv[], SYSOptions *opts) /* do *not* copy kernel / shell, only update boot sector or image */ else if (memicmp(argp, "BOOTONLY", 8) == 0) { - opts->copyFiles = 0; + opts->copyKernel = 0; + opts->copyShell = 0; + } + /* copy kernel and update boot sector (do *not* copy shell) */ + else if (memicmp(argp, "UPDATE", 8) == 0) + { + opts->copyKernel = 1; + opts->copyShell = 0; } /* indicates compatibility mode, fs, filenames, and load segment to use */ else if (memicmp(argp, "OEM", 3) == 0) @@ -499,7 +510,7 @@ void initOptions(int argc, char *argv[], SYSOptions *opts) } else if (toupper(*argp) == 'L') /* set Load segment */ { - opts->kernel.loadseg = (WORD)strtol(argv[argno], NULL, 16); + opts->kernel.loadaddr = (WORD)strtol(argv[argno], NULL, 16); } else if (memicmp(argp, "B", 2) == 0) /* set boot drive # */ { @@ -673,7 +684,7 @@ void initOptions(int argc, char *argv[], SYSOptions *opts) /* set compatibility settings not explicitly set */ if (!opts->kernel.kernel) opts->kernel.kernel = bootFiles[opts->flavor].kernel; if (!opts->kernel.dos) opts->kernel.dos = bootFiles[opts->flavor].dos; - if (!opts->kernel.loadseg) opts->kernel.loadseg = bootFiles[opts->flavor].loadseg; + if (!opts->kernel.loadaddr) opts->kernel.loadaddr = bootFiles[opts->flavor].loadaddr; opts->kernel.stdbs = bootFiles[opts->flavor].stdbs; opts->kernel.minsize = bootFiles[opts->flavor].minsize; @@ -688,7 +699,7 @@ void initOptions(int argc, char *argv[], SYSOptions *opts) /* unless we are only setting boot sector, verify kernel file exists */ - if (opts->copyFiles) + if (opts->copyKernel) { /* check kernel (primary file) 1st */ sprintf(srcFile, "%s%s", opts->srcDrive, (opts->fnKernel)?opts->fnKernel:opts->kernel.kernel); @@ -720,7 +731,11 @@ void initOptions(int argc, char *argv[], SYSOptions *opts) exit(1); } } + } + /* if updating or only setting bootsector then skip this check */ + if (opts->copyShell) + { /* lastly check for command interpreter */ sprintf(srcFile, "%s%s", opts->srcDrive, (opts->fnCmd)?opts->fnCmd:"COMMAND.COM"); if (stat(srcFile, &fstatbuf)) /* if !exists() */ @@ -754,7 +769,7 @@ int main(int argc, char **argv) printf("Processing boot sector...\n"); put_boot(&opts); - if (opts.copyFiles) + if (opts.copyKernel) { printf("Now copying system files...\n"); @@ -774,7 +789,12 @@ int main(int argc, char **argv) exit(1); } /* copy secondary file (DOS) */ } + } + if (opts.copyShell) + { + printf("Copying shell (command interpreter)...\n"); + /* copy command.com, 1st try source path, then try %COMSPEC% */ sprintf(srcFile, "%s%s", opts.srcDrive, (opts.fnCmd)?opts.fnCmd:"COMMAND.COM"); if (!copy(srcFile, opts.dstDrive, "COMMAND.COM")) @@ -1337,6 +1357,7 @@ void put_boot(SYSOptions *opts) if (fs == FAT32) { bs32 = (struct bootsectortype32 *)&newboot; + if (!bs32->bsBackupBoot) bs32->bsBackupBoot = 0x6; /* ensure set, 6 is MS defined bs size */ bs32->bsDriveNumber = opts->defBootDrive; /* the location of the "0060" segment portion of the far pointer @@ -1350,7 +1371,7 @@ void put_boot(SYSOptions *opts) */ if (opts->kernel.stdbs) { - ((int *)newboot)[0x78/sizeof(int)] = opts->kernel.loadseg; + ((int *)newboot)[0x78/sizeof(int)] = opts->kernel.loadaddr; bsBiosMovOff = 0x82; } else /* compatible bs */ @@ -1374,23 +1395,34 @@ void put_boot(SYSOptions *opts) /* the location of the "0060" segment portion of the far pointer in the boot sector is just before cont: in boot*.asm. This happens to be offset 0x78 for FAT32 and offset 0x5c for FAT16 + The oem boot sectors do not have/need this value for patching. + + the location of the jmp address (patching from + EA00007000 [jmp 0x0070:0000] to EA00207000 [jmp 0x0070:0200]) + 0x11b: for fat12 oem boot sector + 0x118: for fat16 oem boot sector + The standard boot sectors do not have/need this value patched. force use of value stored in bs by NOPping out mov [drive], dl 0x66: 88h,56h,24h for fat16 and fat12 boot sectors 0x4F: 88h,56h,24h for oem compatible fat16 and fat12 boot sectors - + i.e. BE CAREFUL WHEN YOU CHANGE THE BOOT SECTORS !!! */ if (opts->kernel.stdbs) { - ((int *)newboot)[0x5c/sizeof(int)] = opts->kernel.loadseg; + /* this sets the segment we load the kernel to, default is 0x60:0 */ + ((int *)newboot)[0x5c/sizeof(int)] = opts->kernel.loadaddr; bsBiosMovOff = 0x66; } else { - /* load segment hard coded to 0x70 in oem compatible boot sector */ - if (opts->kernel.loadseg != 0x70) - printf("%s: Warning! ignoring load segment, compat bs always uses 0x70!\n", pgm); + /* load segment hard coded to 0x70 in oem compatible boot sector, */ + /* this however changes the offset jumped to default 0x70:0 */ + if (fs == FAT12) + ((int *)newboot)[0x11c/sizeof(int)] = opts->kernel.loadaddr; + else + ((int *)newboot)[0x119/sizeof(int)] = opts->kernel.loadaddr; bsBiosMovOff = 0x4F; } } @@ -1443,7 +1475,10 @@ void put_boot(SYSOptions *opts) #ifdef DEBUG /* there's a zero past the kernel name in all boot sectors */ printf("Boot sector kernel name set to %s\n", &newboot[0x1f1]); - printf("Boot sector load segment set to %Xh\n", opts->kernel.loadseg); + if (opts->kernel.stdbs) + printf("Boot sector kernel load segment set to %X:0h\n", opts->kernel.loadaddr); + else + printf("Boot sector kernel jmp address set to 70:%Xh\n", opts->kernel.loadaddr); #endif #ifdef DDEBUG @@ -1463,6 +1498,25 @@ void put_boot(SYSOptions *opts) printf("Can't write new boot sector to drive %c:\n", opts->dstDrive + 'A'); exit(1); } + + /* for FAT32, we need to update the backup copy as well */ + /* Note: assuming sectors 1-5 & 7-11 (FSINFO+additional boot code) + are properly setup by prior format and need no modification + [technically freespace, etc. should be updated] + */ + if (fs == FAT32) + { + bs32 = (struct bootsectortype32 *)&newboot; +#ifdef DEBUG + printf("writing backup bootsector to sector %d\n", bs32->bsBackupBoot); +#endif + if (MyAbsReadWrite(opts->dstDrive, 1, bs32->bsBackupBoot, newboot, 1) != 0) + { + printf("Can't write backup boot sector to drive %c:\n", opts->dstDrive + 'A'); + exit(1); + } + } + } /* if write boot sector to boot record*/ if (opts->bsFile != NULL) From 31377051e1466e883865f6bda8197d47136a9297 Mon Sep 17 00:00:00 2001 From: Kenneth J Davis Date: Sat, 28 May 2005 17:14:58 +0000 Subject: [PATCH 631/671] better check for valid backup boot sector # and add option to skip setting it git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/branches/UNSTABLE@1126 6ac86273-5f31-0410-b378-82cca8765d1b --- docs/sys.txt | 1 + sys/sys.c | 19 +++++++++++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/docs/sys.txt b/docs/sys.txt index f5f13f4d..4dbc6dac 100644 --- a/docs/sys.txt +++ b/docs/sys.txt @@ -34,6 +34,7 @@ SYS [source] dest: [bootsect] [{option}] /L segm : hex load segment to use in boot sector instead of 0x60 /B btdrv : hex BIOS # of boot drive set in bs, 0=A:, 80=1st hd,... /FORCEDRV: force use of drive # set in bs instead of BIOS boot value + /NOBAKBS : skips copying boot sector to backup bs, FAT32 only else ignored /SKFN filename : set KERNEL.SYS input file and /OEM:FD /SCFN filename : sets COMMAND.COM input file /BACKUPBS [path]filename : save current bs before overwriting diff --git a/sys/sys.c b/sys/sys.c index 042d7f2a..23453236 100644 --- a/sys/sys.c +++ b/sys/sys.c @@ -357,6 +357,7 @@ typedef struct SYSOptions { DOSBootFiles kernel; /* file name(s) and relevant data for kernel */ BYTE defBootDrive; /* value stored in boot sector for drive, eg 0x0=A, 0x80=C */ BOOL ignoreBIOS; /* true to NOP out boot sector code to get drive# from BIOS */ + BOOL skipBakBSCopy; /* true to not copy boot sector to backup boot sector */ BOOL copyKernel; /* true to copy kernel files */ BOOL copyShell; /* true to copy command interpreter */ BOOL writeBS; /* true to write boot sector to drive/partition LBA 0 */ @@ -399,6 +400,7 @@ void showHelpAndExit(void) " /L segm : hex load segment to use in boot sector instead of %02x\n" " /B btdrv : hex BIOS # of boot drive set in bs, 0=A:, 80=1st hd,...\n" " /FORCEDRV: force use of drive # set in bs instead of BIOS boot value\n" + " /NOBAKBS : skips copying boot sector to backup bs, FAT32 only else ignored\n" #ifdef FDCONFIG "%s CONFIG /help\n" #endif @@ -501,6 +503,11 @@ void initOptions(int argc, char *argv[], SYSOptions *opts) { opts->ignoreBIOS = 1; } + /* skips copying boot sector to backup bs, FAT32 only else ignored */ + else if (memicmp(argp, "NOBAKBS", 7) == 0) + { + opts->skipBakBSCopy = 1; + } else if (argno + 1 < argc) /* two part options, /SWITCH VALUE */ { argno++; @@ -1357,7 +1364,14 @@ void put_boot(SYSOptions *opts) if (fs == FAT32) { bs32 = (struct bootsectortype32 *)&newboot; - if (!bs32->bsBackupBoot) bs32->bsBackupBoot = 0x6; /* ensure set, 6 is MS defined bs size */ + /* ensure appears valid, if not then force valid */ + if ((bs32->bsBackupBoot < 1) || (bs32->bsBackupBoot > bs32->bsResSectors)) + { + #ifdef DEBUG + printf("BPB appears to have invalid backup boot sector #, forcing to default.\n"); + #endif + bs32->bsBackupBoot = 0x6; /* ensure set, 6 is MS defined bs size */ + } bs32->bsDriveNumber = opts->defBootDrive; /* the location of the "0060" segment portion of the far pointer @@ -1500,11 +1514,12 @@ void put_boot(SYSOptions *opts) } /* for FAT32, we need to update the backup copy as well */ + /* unless user has asked us not to, eg for better dual boot support */ /* Note: assuming sectors 1-5 & 7-11 (FSINFO+additional boot code) are properly setup by prior format and need no modification [technically freespace, etc. should be updated] */ - if (fs == FAT32) + if ((fs == FAT32) && !opts->skipBakBSCopy) { bs32 = (struct bootsectortype32 *)&newboot; #ifdef DEBUG From e1ed4217a2883224b52ae98f1dd90c5565c1dc76 Mon Sep 17 00:00:00 2001 From: Kenneth J Davis Date: Sun, 10 Jul 2005 02:02:39 +0000 Subject: [PATCH 632/671] IsDevice should not compare filenames against block device driver headers git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/branches/UNSTABLE@1128 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/dosfns.c | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/kernel/dosfns.c b/kernel/dosfns.c index 8a8b40a3..002d3e88 100644 --- a/kernel/dosfns.c +++ b/kernel/dosfns.c @@ -1354,7 +1354,10 @@ COUNT DosLockUnlock(COUNT hndl, LONG pos, LONG len, COUNT unlock) * This seems to work well. */ -/* check for a device */ +/* check for a device + returns device header if match, else returns NULL + can only match character devices (as only they have names) + */ struct dhdr FAR *IsDevice(const char FAR * fname) { struct dhdr FAR *dhp; @@ -1371,15 +1374,35 @@ struct dhdr FAR *IsDevice(const char FAR * fname) { */ +/* BUGFIX: MSCD000<00> should be handled like MSCD000<20> TE + ie the 8 character device name may be padded with spaces ' ' or NULs '\0' + + Note: fname is assumed an ASCIIZ string (ie not padded, unknown length) + but the name in the device header is assumed FNAME_SIZE and padded. KJD +*/ + + + /* check for names that will never be devices to avoid checking all device headers. + only the file name (not path nor extension) need be checked, "" == root or empty name + */ + if ( (*froot == '\0') || + ((*froot=='.') && ((*(froot+1)=='\0') || (*(froot+2)=='\0' && *(froot+1)=='.'))) + ) + { + return NULL; + } + + /* cycle through all device headers checking for match */ for (dhp = (struct dhdr FAR *)&nul_dev; dhp != (struct dhdr FAR *)-1; dhp = dhp->dh_next) { - - /* BUGFIX: MSCD000<00> should be handled like MSCD000<20> TE */ + if (!(dhp->dh_attr & ATTR_CHAR)) /* if this is block device, skip */ + continue; for (i = 0; i < FNAME_SIZE; i++) { unsigned char c1 = (unsigned char)froot[i]; + /* ignore extensions and handle filenames shorter than FNAME_SIZE */ if (c1 == '.' || c1 == '\0') { /* check if remainder of device name consists of spaces or nulls */ @@ -1394,6 +1417,8 @@ struct dhdr FAR *IsDevice(const char FAR * fname) if (DosUpFChar(c1) != DosUpFChar(dhp->dh_name[i])) break; } + + /* if found a match then return device header */ if (i == FNAME_SIZE) return dhp; } From e31b12bcafac949a7a141ed79a5b92e351f4db6f Mon Sep 17 00:00:00 2001 From: Kenneth J Davis Date: Thu, 1 Sep 2005 05:12:44 +0000 Subject: [PATCH 633/671] fix update option (compared too many characters, Lucho) git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/branches/UNSTABLE@1139 6ac86273-5f31-0410-b378-82cca8765d1b --- sys/sys.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sys/sys.c b/sys/sys.c index 23453236..3f4b6a31 100644 --- a/sys/sys.c +++ b/sys/sys.c @@ -32,7 +32,7 @@ #define FDCONFIG /* include support to configure FD kernel */ /* #define DRSYS */ /* SYS for Enhanced DR-DOS (OpenDOS enhancement Project) */ -#define SYS_VERSION "v3.6" +#define SYS_VERSION "v3.6a" #define SYS_NAME "FreeDOS System Installer " @@ -313,6 +313,7 @@ DOSBootFiles bootFiles[] = { /* PC-DOS */ { "IBMBIO.COM", "IBMDOS.COM", /*0x70:*/0x0, 0, 6138 }, /* pre v7 DR ??? */ /* MS-DOS */ { "IO.SYS", "MSDOS.SYS", /*0x70:*/0x0, 0, 10240 }, /* W9x-DOS */ { "IO.SYS", "MSDOS.SYS", /*0x70:*/0x0200, 0, 0 }, + /* Rx-DOS */ { "RXDOSBIO.SYS", "RXDOS.SYS", /*0x70:*/0x0, 0, 1 }, #endif }; #define DOSFLAVORS (sizeof(bootFiles) / sizeof(*bootFiles)) @@ -456,7 +457,7 @@ void initOptions(int argc, char *argv[], SYSOptions *opts) opts->copyShell = 0; } /* copy kernel and update boot sector (do *not* copy shell) */ - else if (memicmp(argp, "UPDATE", 8) == 0) + else if (memicmp(argp, "UPDATE", 6) == 0) { opts->copyKernel = 1; opts->copyShell = 0; From 0217d442c3e180213757d7f8d476b2912fdb70a3 Mon Sep 17 00:00:00 2001 From: Luchezar Georgiev Date: Sun, 18 Sep 2005 06:41:48 +0000 Subject: [PATCH 634/671] Bart Oldeman patch to make device=f:\foo.sys work. String printf optimisation git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/branches/UNSTABLE@1143 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/main.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/kernel/main.c b/kernel/main.c index 691ab83f..bff2b2f5 100644 --- a/kernel/main.c +++ b/kernel/main.c @@ -38,9 +38,9 @@ static BYTE *mainRcsId = /* The Holy Copyright Message. Do NOT remove it or you'll be cursed forever! */ -static char copyright[] = -"Copyright 1995-2005 Pasquale J. Villani and The FreeDOS Project.\n" -"NO WARRANTY. Licensed under the GNU General Public License version 2.\n\n"; +#define COPYRIGHT \ +"Copyright 1995-2005 Pasquale Villani and The FreeDOS Project.\n" \ +"NO WARRANTY. Licensed under the GNU General Public License version 2.\n\n" struct _KernelConfig InitKernelConfig BSS_INIT({0}); @@ -289,7 +289,9 @@ STATIC void init_kernel(void) /* Do first initialization of system variable buffers so that */ /* we can read config.sys later. */ - LoL->lastdrive = Config.cfgLastdrive; + + /* use largest possible value for the initial CDS */ + LoL->lastdrive = 26; blk_dev.dh_name[0] = dsk_init(); @@ -399,7 +401,7 @@ STATIC VOID signon() generate some bullshit error here, as the compiler should be known #endif #if defined (I386) - " - 80386 CPU required" + " - i386 CPU required" #elif defined (I186) " - 80186 CPU required" #endif @@ -407,9 +409,9 @@ STATIC VOID signon() #ifdef WITHFAT32 " - FAT32 support" #endif - "\n\n%s", + "\n\n" COPYRIGHT, MK_FP(FP_SEG(LoL), FP_OFF(LoL->os_release)), - MAJOR_RELEASE, MINOR_RELEASE, copyright); + MAJOR_RELEASE, MINOR_RELEASE); } STATIC void init_shell() From 58c6e2989536317848e72b46972d02243a175465 Mon Sep 17 00:00:00 2001 From: Luchezar Georgiev Date: Mon, 19 Sep 2005 17:43:11 +0000 Subject: [PATCH 635/671] Fix BC 3.1 CONFIG.C compile and SYS Abnormal Program Termination error for BC git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/branches/UNSTABLE@1144 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/config.c | 4 ++-- sys/sys.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/kernel/config.c b/kernel/config.c index d773e4aa..b385e3e3 100644 --- a/kernel/config.c +++ b/kernel/config.c @@ -166,7 +166,7 @@ STATIC BOOL GetNumArg2(PCStr, int default2); static void hintSkipAll(void); static BOOL askSkipLine(void); STATIC char strcasediff(PCStr, PCStr); -STATIC void LoadCountryInfoHardCoded(CStr filename, int ccode, int cpage); +STATIC void LoadCountryInfoHardCoded(PCStr filename, int ccode, int cpage); STATIC void umb_init(void); STATIC void config_init_buffers(int anzBuffers); /* from BLOCKIO.C */ @@ -1139,7 +1139,7 @@ STATIC void Fcbs(PCStr p) * the default code page for the country will be used. */ -STATIC void LoadCountryInfo(CStr filename, int ccode, int cpage) +STATIC void LoadCountryInfo(PCStr filename, int ccode, int cpage) { /* COUNTRY.SYS file data structures - see RBIL tables 2619-2622 */ diff --git a/sys/sys.c b/sys/sys.c index 3f4b6a31..14353e3f 100644 --- a/sys/sys.c +++ b/sys/sys.c @@ -204,7 +204,7 @@ char *getenv(const char *name) BYTE pgm[] = "SYS"; #define SEC_SIZE 512 -#define COPY_SIZE 0x7e00 +#define COPY_SIZE 0x4000 struct bootsectortype { UBYTE bsJump[3]; From da5f4a917fc73ae74fca820966b8d6480d68212b Mon Sep 17 00:00:00 2001 From: Luchezar Georgiev Date: Tue, 20 Sep 2005 10:02:19 +0000 Subject: [PATCH 636/671] History update git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/branches/UNSTABLE@1145 6ac86273-5f31-0410-b378-82cca8765d1b --- docs/history.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/history.txt b/docs/history.txt index 432ad6ac..15d8117e 100644 --- a/docs/history.txt +++ b/docs/history.txt @@ -7,6 +7,8 @@ - bugfix: call_nls: DI register was not preserved * inthndlr.c - int21/ah=6/dl=ff now calls int28 + * main.c + - use largest possible value for the initial CDS (make device=f:\foo.sys work) * sys.c - correct fat32readwrite's prototype to explicitly return int + Changes Tom @@ -307,6 +309,7 @@ * sys.c - change OEM Name field to FRDOS4.1 per Eric Auer for better compatibility. - added fat32readwrite int return type, now required by OpenWatcom 1.3 + - shrank copy buffer to avoid "Abnormal Program Termination" for Borland C. * ludivmul.inc - 32-bit division code for 386-enabled Watcom kernel. * inthndlr.c @@ -320,6 +323,7 @@ - optimised Int 21h/AH=38h Get Country Information, removed cntry hack * autoexec.bat: now single-line for FreeCOM compatibility when EOL=LF * break.c: check_handle_break() return was undefined if no Ctrl-break + * config.c: fix "Suspicious pointer conversion" warning by Borland C 3.1 * config.sys: all commands removed as they were close to defaults * contrib.txt: added Aitor Santamaria, Bernd Blaauw and Eduardo Casino * country.asm / config.c: COUNTRY.SYS now replaces hard-coded data From a82122eec8d80223c63123b11c15f66acb6811ef Mon Sep 17 00:00:00 2001 From: Luchezar Georgiev Date: Sat, 22 Oct 2005 11:14:06 +0000 Subject: [PATCH 637/671] Fix Ctrl-Z bug and retro-optimise a bit git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/branches/UNSTABLE@1146 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/chario.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/kernel/chario.c b/kernel/chario.c index 0740ca7a..9870c7c5 100644 --- a/kernel/chario.c +++ b/kernel/chario.c @@ -89,7 +89,10 @@ STATIC int CharIO(struct dhdr FAR **pdev, unsigned char ch, unsigned command) /* STATE FUNCTIONS */ -#define CharCmd(pdev, command) while (CharRequest(pdev, command) > 0) +STATIC void CharCmd(struct dhdr FAR **pdev, unsigned command) +{ + while (CharRequest(pdev, command) == 1); +} STATIC int Busy(struct dhdr FAR **pdev) { @@ -223,13 +226,13 @@ void write_char_stdout(int c) /* this is for handling things like ^C, mostly used in echoed input */ STATIC VOID echo_char(int c, int sft_idx, unsigned i) { + local_buffer[i] = c; if (iscntrl(c) && c != HT && c != LF && c != CR) { write_char('^', sft_idx); c += '@'; } write_char(c, sft_idx); - local_buffer[i] = c; } STATIC void destr_bs(int sft_idx) From 24f47a5ecc50e6f5583ffd7d213d546830a7cd31 Mon Sep 17 00:00:00 2001 From: Kenneth J Davis Date: Sun, 6 Nov 2005 19:50:35 +0000 Subject: [PATCH 638/671] more win3 support, some comments, upx option to build.bat, misc debug print changes git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/branches/UNSTABLE@1147 6ac86273-5f31-0410-b378-82cca8765d1b --- build.bat | 4 +- config.b | 8 ++- docs/history.txt | 12 +++++ hdr/debug.h | 28 +++++++++-- kernel/dosfns.c | 16 +++++- kernel/entry.asm | 59 +++++++++++++++++++++- kernel/fatfs.c | 4 +- kernel/int2f.asm | 43 ++++++++++++++++ kernel/inthndlr.c | 116 +++++++++++++++++++++++++++++++++++++------- kernel/kernel.asm | 22 +++++++-- mkfiles/generic.mak | 2 +- 11 files changed, 280 insertions(+), 34 deletions(-) diff --git a/build.bat b/build.bat index 1fe62336..d9bd41f5 100644 --- a/build.bat +++ b/build.bat @@ -6,7 +6,7 @@ if NOT "%1" == "/?" goto start echo ":-----------------------------------------------------------------------" echo ":- Syntax: BUILD [-r] [fat32|fat16] [msc|wc|tc|tcpp|bc] [86|186|386] " -echo ":- [debug] [lfnapi] [/L #] [/D value] [list] " +echo ":- [debug] [lfnapi] [/L #] [/D value] [list] [upx] " echo ":- option case is significant !! " echo ":- Note: Open Watcom (wc) is the preferred compiler " echo ":-----------------------------------------------------------------------" @@ -47,6 +47,8 @@ if "%1" == "186" set XCPU=186 if "%1" == "386" set XCPU=386 if "%1" == "x86" goto setCPU +if "%1" == "upx" set XUPX=upx --8086 --best + if "%1" == "debug" set ALLCFLAGS=%ALLCFLAGS% -DDEBUG if "%1" == "lfnapi" set ALLCFLAGS=%ALLCFLAGS% -DWITHLFNAPI diff --git a/config.b b/config.b index 84744e00..ecbd191f 100644 --- a/config.b +++ b/config.b @@ -87,10 +87,15 @@ set WATCOM=c:\watcom ::set MAKE=nmaker /nologo :----------------------------------------------------------------------- +:- This section can still be used if you need special consideration +:- for UPX, such as it is not in your PATH or you do not want +:- 8086 compatible settings, otherwise the recommended use is now +:- to add 'upx' option to the build.bat command line + :- where is UPX and which options to use :- (comment this out if you don't want to use it) -set XUPX=upx --8086 --best +::set XUPX=upx --8086 --best :----------------------------------------------------------------------- :- select default target: CPU type (default is 86) and @@ -107,6 +112,7 @@ set XUPX=upx --8086 --best :- Give extra compiler DEFINE flags here :- such as -DDEBUG : extra DEBUG output :- -DDOSEMU : printf output goes to dosemu log +:- -DWIN31SUPPORT : extra Win3.x API support ::set ALLCFLAGS=-DDEBUG :----------------------------------------------------------------------- diff --git a/docs/history.txt b/docs/history.txt index 15d8117e..3fce9c33 100644 --- a/docs/history.txt +++ b/docs/history.txt @@ -395,12 +395,24 @@ time failure finding/loading CONFIG.SYS) * config.txt - update to include all CONFIG.SYS options (except ANYDOS) + * debug.h + - add additional debug style printfs to enable selective debug output + * entry.asm + - add [conditional compiled] support for OEM handler (int 21h ah>0xf8) + - work towards critical section entry/exit calls for Win3 support * exeflat.c - show usage also when number of arguments incorrect * fatdir.c - be more restrictive in what considered a volume search * initdisk.c - set hidden & huge fields in floppy bpb (bugfix 1789) + * inthndlr.c + - add [conditional compiled] support for Win3 API calls (entry/exit/...) + * int2f.asm + - switch to local stack when Win3 support compiled in, ?unneeded/to be removed? + * kernel.asm + - comment some additional variables + - use some unused spaces for OEMHandler variable and Win3 instancing information * main.c - treat block devices returning 0 units as load failure * oemboot.asm - add [optional] PC/MS DOS compatible boot sector diff --git a/hdr/debug.h b/hdr/debug.h index 70e6cf56..b6edb87f 100644 --- a/hdr/debug.h +++ b/hdr/debug.h @@ -36,8 +36,14 @@ NOTE: this file included by INIT time code and normal resident code, so use care for all memory references */ - - + +/* allow output even in non-debug builds */ +#if 0 +#ifndef DEBUG_NEED_PRINTF +#define DEBUG_NEED_PRINTF +#endif +#endif + /* use to limit output to debug builds */ #ifdef DEBUG #define DebugPrintf(x) printf x @@ -92,9 +98,12 @@ #define FDirDbgPrintf(x) #endif -/* extra debug output marking sections */ +/* extra debug output when transferring I/O chunks of data */ /* #define DISPLAY_GETBLOCK */ +/* extra output during read/write operations */ +/* #define DSK_DEBUG */ + /* display info on various FAT handling functions (fatfs.c) */ /* #define DEBUGFATFS */ #ifdef DEBUGFATFS @@ -103,6 +112,14 @@ #define FatFSDbgPrintf(x) #endif +/* debug truename */ +/* #define DEBUG_TRUENAME */ +#ifdef DEBUG_TRUENAME +#define tn_printf(x) printf x +#else +#define tn_printf(x) +#endif + /* just to be sure printf is declared */ #if defined(DEBUG) || defined(DEBUGIRQ) || defined(DEBUGCFG) || \ @@ -110,8 +127,11 @@ defined(DEBUGFATDIR) || defined(DEBUGFATFS) #ifndef DEBUG_NEED_PRINTF #define DEBUG_NEED_PRINTF -VOID VA_CDECL printf(const char * fmt, ...); #endif #endif +#ifdef DEBUG_NEED_PRINTF +VOID VA_CDECL printf(const char * fmt, ...); +#endif + #endif /* __DEBUG_H */ diff --git a/kernel/dosfns.c b/kernel/dosfns.c index 002d3e88..2fdc86cc 100644 --- a/kernel/dosfns.c +++ b/kernel/dosfns.c @@ -96,10 +96,12 @@ STATIC int remote_lock_unlock(sft FAR *sftp, /* SFT for file */ /* get current directory structure for drive return NULL if the CDS is not valid or the - drive is not within range */ + drive is not within range, on input drv is + 0 for default or 1=A,2=B,... +*/ struct cds FAR *get_cds1(unsigned drv) { - if (drv-- == 0) /* 0 = A:, 1 = B:, ... */ + if (drv-- == 0) /* get default drive or convert to 0 = A:, 1 = B:, ... */ drv = default_drive; return get_cds(drv); } @@ -781,6 +783,16 @@ COUNT DosClose(COUNT hndl) return ret; } +/* get disk free space (in terms of free clusters and cluster size) + input: drive specifies which disk to obtain information about, + where 0=default, 1=A,2=B,... + navc, bps, and nc are pointers to uninitialized variables + used to hold the result, where + navc is count of available [free] clusters + bps is bytes per sector + nc is total number of clusters + returns the number of sectors per cluster or on error -1 + */ UWORD DosGetFree(UBYTE drive, UWORD * navc, UWORD * bps, UWORD * nc) { /* navc==NULL means: called from FatGetDrvData, fcbfns.c */ diff --git a/kernel/entry.asm b/kernel/entry.asm index ff2e724e..1e388353 100644 --- a/kernel/entry.asm +++ b/kernel/entry.asm @@ -206,6 +206,35 @@ reloc_call_int20_handler: ; int21_handler(iregs UserRegs) ; reloc_call_int21_handler: +;%define OEMHANDLER ; enable OEM hook, mostly OEM DOS 2.x, maybe through OEM 6.x +%ifdef OEMHANDLER + extern _OemHook21 + ; When defined and set (!= ffff:ffffh) invoke installed + ; int 21h handler for ah=f9h through ffh + ; with all registers preserved, callee must perform the iret + cmp ah, 0f9h ; if a normal int21 call, proceed + jb skip_oemhndlr ; as quickly as possible + ; we need all registers preserved but also + ; access to the hook address, so we copy locally + ; 1st (while performing check for valid address) + ; then do the jmp + push ds + push dx + mov dx,[cs:_DGROUP_] + mov ds,dx + cmp word [_OemHook21], -1 + je no_oemhndlr + cmp word [_OemHook21+2], -1 + je no_oemhndlr + pop dx + pop ds + jmp far [ds:_OemHook21] ; invoke OEM handler (no return) +;local_hookaddr dd 0 +no_oemhndlr: + pop dx + pop ds +skip_oemhndlr: +%endif ;OEMHANDLER ; ; Create the stack frame for C call. This is done to ; preserve machine state and provide a C structure for @@ -246,7 +275,9 @@ int21_reentry: jne int21_1 int21_user: +%IFNDEF WIN31SUPPORT ; begin critical section call dos_crit_sect +%ENDIF ; NOT WIN31SUPPORT push ss push bp @@ -309,15 +340,30 @@ int21_onerrorstack: jmp short int21_exit_nodec -int21_2: inc byte [_InDOS] +int21_2: +%IFDEF WIN31SUPPORT ; begin critical section + ; should be called as needed, but we just + ; mark the whole int21 api as critical + push ax + mov ax, 8001h ; Enter Critical Section + int 2ah + pop ax +%ENDIF ; WIN31SUPPORT + inc byte [_InDOS] mov cx,_char_api_tos or ah,ah jz int21_3 +%IFDEF WIN31SUPPORT ; testing, this function call crashes + cmp ah,06h + je int21_3 +%ENDIF ; WIN31SUPPORT cmp ah,0ch jbe int21_normalentry int21_3: +%IFNDEF WIN31SUPPORT ; begin critical section call dos_crit_sect +%ENDIF ; NOT WIN31SUPPORT mov cx,_disk_api_tos int21_normalentry: @@ -337,6 +383,17 @@ int21_normalentry: call _int21_service int21_exit: dec byte [_InDOS] +%IFDEF WIN31SUPPORT ; end critical section + call dos_crit_sect ; release all critical sections +%if 0 + ; should be called as needed, but we just + ; mark the whole int21 api as critical + push ax + mov ax, 8101h ; Leave Critical Section + int 2ah + pop ax +%endif +%ENDIF ; WIN31SUPPORT ; ; Recover registers from system call. Registers and flags diff --git a/kernel/fatfs.c b/kernel/fatfs.c index 9012a072..7771657a 100644 --- a/kernel/fatfs.c +++ b/kernel/fatfs.c @@ -1833,11 +1833,11 @@ int dos_cd(char * PathName) f_node_ptr get_near_f_node(void) { f_node_ptr fnp = fnode; - DebugPrintf(("get_near_f_node: fnp is %p\n", fnp)); + DDebugPrintf(("get_near_f_node: fnp is %p\n", fnp)); if (fnp->f_count && (++fnp)->f_count) panic("more than two near fnodes requested at the same time!\n"); fnp->f_count++; - DebugPrintf(("got near fnode, fnp->f_count=%i\n", fnp->f_count)); + DDebugPrintf(("got near fnode, fnp->f_count=%i\n", fnp->f_count)); return fnp; } diff --git a/kernel/int2f.asm b/kernel/int2f.asm index d28ffc0d..465a5cbc 100644 --- a/kernel/int2f.asm +++ b/kernel/int2f.asm @@ -69,6 +69,9 @@ Int2f3: cmp ax,4a33h ; Check DOS version 7 jne Check4Share xor ax,ax ; no undocumented shell strings + xor bx,bx ; RBIL undoc BX = ?? (0h) + ; " DS:DX ASCIIZ shell exe name + ; " DS:SI SHELL= line iret Check4Share: %endif @@ -134,6 +137,28 @@ IntDosCal: cld +%IFDEF WIN31SUPPORT ; switch to local stack, no reentrancy support + extern mux2F_stk_top:wrt DGROUP + cli + ; setup, initialize copy + mov si, sp ; ds:si = ss:sp (user stack) + mov ax, ss + mov ds, ax + mov di, mux2F_stk_top-30 ; es:di = local stack-copied chunk + mov es, [cs:_DGROUP_] ; [-X == -(2*cx below+4) ] + mov cx, 13 ; how many words to copy over + ; setup, store original stack pointer + mov [es:di+28], si ; store ss:sp + mov [es:di+26], ds + ; actually switch to local stack + mov ax, es + mov ss, ax + mov sp, di + ; copy over stack data to local stack + rep movsw + sti +%ENDIF ; WIN31SUPPORT + %if XCPU >= 386 %ifdef WATCOM mov si,fs @@ -156,6 +181,24 @@ IntDosCal: %endif %endif +%IFDEF WIN31SUPPORT ; switch back to user stack + cli + ; setup, initialize copy + mov si, sp ; ds:si = ss:sp (local stack) + mov ax, ss + mov ds, ax + mov di, [ds:si+28] ; restore original ss:sp + mov es, [ds:si+26] + mov cx, 13 ; how many words to copy over + ; actually switch to user stack + mov ax, es + mov ss, ax + mov sp, di + ; copy over stack data to user stack + rep movsw + sti +%ENDIF ; WIN31SUPPORT + pop es pop ds pop di diff --git a/kernel/inthndlr.c b/kernel/inthndlr.c index 765ea0dc..8f23df3c 100644 --- a/kernel/inthndlr.c +++ b/kernel/inthndlr.c @@ -31,6 +31,8 @@ #include "portab.h" #include "globals.h" #include "nls.h" +#include "debug.h" + #ifdef VERSION_STRINGS BYTE *RcsId = @@ -413,7 +415,7 @@ VOID ASMCFUNC int21_service(iregs FAR * r) if (bDumpRegs) { fmemcpy(&error_regs, user_r, sizeof(iregs)); - printf("System call (21h): %02x\n", user_r->AX); + printf("System call (21h): %04x\n", user_r->AX); dump_regs = TRUE; dump(); } @@ -762,6 +764,7 @@ VOID ASMCFUNC int21_service(iregs FAR * r) case 0x31: DosMemChange(cu_psp, lr.DX < 6 ? 6 : lr.DX, 0); return_code = lr.AL | 0x300; + DDebugPrintf(("ErrorLevel kernel returns is %x(==%x|0x300)\n", (unsigned)return_code, (unsigned)lr.AL)); tsr = TRUE; return_user(); break; @@ -1034,6 +1037,7 @@ VOID ASMCFUNC int21_service(iregs FAR * r) rc = 0x100; } return_code = lr.AL | rc; + DDebugPrintf(("ErrorLevel kernel returns is %x\n", (unsigned)return_code)); if (DosMemCheck() != SUCCESS) panic("MCB chain corrupted"); #ifdef TSC @@ -1045,6 +1049,7 @@ VOID ASMCFUNC int21_service(iregs FAR * r) /* Get Child-program Return Value */ case 0x4d: lr.AX = return_code; + DDebugPrintf(("Child ErrorLevel kernel returns is %x(==%x)\n", (unsigned)return_code, (unsigned)lr.AX)); /* needs to be cleared (RBIL) */ return_code = 0; break; @@ -1734,7 +1739,12 @@ VOID ASMCFUNC int2F_12_handler(struct int2f12regs r) switch (r.AL) { /* default: unhandled requests pass through unchanged */ - #if 0 + case 0x0: /* is Windows active */ + case 0x0A: /* identify Windows version */ + { + /* return AX unchanged if Windows not active */ + break; + } /* 0x0, 0x0A */ case 0x03: /* Windows Get Instance Data */ { /* This should only be called if AX=1607h/BX=15h is not supported. */ @@ -1742,12 +1752,12 @@ VOID ASMCFUNC int2F_12_handler(struct int2f12regs r) can also be in INSTANCE.386 [which in theory means Windows could be updated to support FD kernel without responding to these?]. */ + DebugPrintf(("get instance data\n")); break; } /* 0x03 */ - #endif case 0x05: /* Windows Startup Broadcast */ { - /* After receiving this call we activiate compatibility changes + /* After receiving this call we activate compatibility changes as DOS 5 does, though can wait until 0x07 subfunc 0x01 */ /* on entry: @@ -1763,6 +1773,7 @@ VOID ASMCFUNC int2F_12_handler(struct int2f12regs r) r.BX = FP_OFF(&winStartupInfo); winStartupInfo.winver = r.di; /* match what caller says it is */ winInstanced = 1; /* internal flag marking Windows is active */ + DebugPrintf(("Win startup\n")); break; } /* 0x05 */ case 0x06: /* Windows Exit Broadcast */ @@ -1772,10 +1783,12 @@ VOID ASMCFUNC int2F_12_handler(struct int2f12regs r) Note: If Windows fatally exits then may not be called. */ winInstanced = 0; /* internal flag marking Windows is NOT active */ + DebugPrintf(("Win exit\n")); break; } /* 0x06 */ case 0x07: /* DOSMGR Virtual Device API */ { + DebugPrintf(("Vxd:DOSMGR:%x:%x:%x:%x\n",r.AX,r.BX,r.CX,r.DX)); if (r.BX == 0x15) /* VxD id of "DOSMGR" */ { switch (r.CX) @@ -1791,7 +1804,7 @@ VOID ASMCFUNC int2F_12_handler(struct int2f12regs r) } case 0x01: /* enable Win support, ie patch DOS */ { - /* DOS 5+ return with flags unchanged, Windows critical section + /* DOS 5+ return with bitflags unchanged, Windows critical section needs are handled without need to patch. If this function does not return successfully windows will attempt to do the patching itself (very bad idea). @@ -1810,12 +1823,19 @@ VOID ASMCFUNC int2F_12_handler(struct int2f12regs r) 0010h: notify Windows of logical drive map change ("Insert disk X:") */ r.BX = r.DX; /* sure we support everything asked for, ;-) */ - r.DX = 0xA2AB; /* on succes DS:AX set to A2AB:B97Ch */ + r.DX = 0xA2AB; /* on succes DX:AX set to A2AB:B97Ch */ r.AX = 0xB97C; /* FIXME: do we need to do anything special for FD kernel? */ break; } - /* case 0x02 is below so we can reuse it for 0x05 */ + case 0x02: /* disable Win support, ie remove patches */ + { + /* Note: if we do anything special in 'patch DOS', undo it here. + This is only called when Windows exits, can be ignored. + */ + r.CX = 0; /* for compatibility with MS-DOS 5/6 */ + break; + } case 0x03: /* get internal structure sizes */ { if (r.CX & 0x01) /* size of Current Directory Structure in bytes */ @@ -1839,29 +1859,89 @@ VOID ASMCFUNC int2F_12_handler(struct int2f12regs r) */ r.DX = 0xA2AB; /* on succes DS:AX set to A2AB:B97Ch */ r.AX = 0xB97C; - r.BX = 0x0008; /* our whole data seg is instanced, so - anything within it we assume instanced. */ + r.BX = 0; /* a zero here tells Windows to instance everything */ break; } case 0x05: /* get device driver size */ { + /* On entry ES:DI points to possible device driver + if is not one return with AX=BX=CX=DX=0 + else return BX:CX size in bytes allocated to driver + and DX:AX set to A2AB:B97Ch */ + mcb FAR *smcb = MK_PTR(mcb, (r.ES-1), 0); /* para before is possibly submcb segment */ + /* drivers always start a seg:0 (DI==0), so if not then either + not device driver or duplicate (ie device driver file loaded + is of multi-driver variety; multiple device drivers in same file, + whose memory was allocated as a single chunk) + Drivers don't really have a MCB, instead the DOS MCB is broken + up into submcbs, which will have a type of 'D' (or 'E') + So we check that this is primary segment, a device driver, and owner. + */ + if (!r.DI && (smcb->m_type == 'D') && (smcb->m_psp == r.ES)) + { + ULONG size = smcb->m_size * 16ul; + r.BX = hiword(size); + r.CX = loword(size); + r.DX = 0xA2AB; /* on succes DX:AX set to A2AB:B97Ch */ + r.AX = 0xB97C; + break; + } r.DX = 0; /* we aren't one so return unsupported */ r.AX = 0; r.BX = 0; - /* fall through to set CX=0 and exit */ - } - case 0x02: /* disable Win support, ie remove patches */ - { - /* Note: if we do anything special in 'patch DOS', undo it here. - This is only called when Windows exits, can be ignored. - */ - r.CX = 0; /* for compatibility with MS-DOS 5/6 */ + r.CX = 0; break; } } } + DebugPrintf(("Vxd:DOSMGR:%x:%x:%x:%x\n",r.AX,r.BX,r.CX,r.DX)); break; } /* 0x07 */ + case 0x08: /* Windows Init Complete Broadcast */ + { + DebugPrintf(("Init complete\n")); + break; + } /* 0x08 */ + case 0x09: /* Windows Begin Exit Broadcast */ + { + DebugPrintf(("Exit initiated\n")); + break; + } /* 0x09 */ + case 0x0B: /* Win TSR Identify */ + { + DebugPrintf(("TSR identify request.\n")); + break; + } /* 0x0B */ + case 0x80: /* Win Release Time-slice */ + { + /* This function is generally only called in idle loops */ + enable; /* enable interrupts */ + // __emit__(0xf4); /* halt */ + asm hlt; + r.AX = 0; + /* DebugPrintf(("Release Time Slice\n")); */ + break; + } /* 0x80 */ + case 0x81: /* Win3 Begin Critical Section */ + { + DebugPrintf(("Begin CritSect\n")); + break; + } /* 0x81 */ + case 0x82: /* Win3 End Critical Section */ + { + DebugPrintf(("End CritSect\n")); + break; + } /* 0x82 */ + case 0x8F: /* Win4 Close Awareness */ + { + if (r.DH != 0x01) /* query close */ + r.AX = 0x0; + /* else r.AX = 0x168F; don't close -- continue execution */ + break; + } /* 0x8F */ + default: + DebugPrintf(("Win call (int 2Fh/16h): %04x %04x %04x %04x\n", r.AX, r.BX, r.CX, r.DX)); + break; } #endif return; @@ -1874,7 +1954,7 @@ VOID ASMCFUNC int2F_12_handler(struct int2f12regs r) /* To prevent corruption when dos=umb where Windows 3.0 standard writes a sentinel at 9FFEh, DOS 5 will save the MCB marking end of conventional memory (ie MCB following caller's PSP memory - block [which I assume occupies all of convential memory] into + block [which I assume occupies all of conventional memory] into the DOS data segment. Note: presumably Win3.1 uses the WinPatchTable.OffLastMCBSeg when DOS ver > 5 to do this itself. diff --git a/kernel/kernel.asm b/kernel/kernel.asm index 00e6ce1f..19fe35ce 100644 --- a/kernel/kernel.asm +++ b/kernel/kernel.asm @@ -256,11 +256,14 @@ dos_data db 0 global _NetBios _NetBios dw 0 ; NetBios Number - times (26h - 0ch - ($ - DATASTART)) db 0 + times (26h - 12h - ($ - DATASTART)) db 0 ; Globally referenced variables - WARNING: DO NOT CHANGE ORDER ; BECAUSE THEY ARE DOCUMENTED AS UNDOCUMENTED (?) AND HAVE ; MANY MULTIPLEX PROGRAMS AND TSR'S ACCESSING THEM + global _OemHook21 +_OemHook21 dd -1 ;-0012 OEM fn handler (int21/f8h) + dw 0 ;-000e offset from DOS CS of int21 ret global _NetRetry _NetRetry dw 3 ;-000c network retry count global _NetDelay @@ -284,7 +287,8 @@ _clock dd 0 ; 0008 CLOCK$ device _syscon dw _con_dev,seg _con_dev ; 000c console device global _maxbksize _maxbksize dw 512 ; 0010 maximum bytes/sector of any block device - dd 0 ; 0012 pointer to buffers info structure + global _inforecptr +_inforecptr dd 0 ; 0012 pointer to buffers info structure global _CDSp _CDSp dd 0 ; 0016 Current Directory Structure global _FCBp @@ -338,7 +342,7 @@ _bufloc db 0 ; 0053 00=conv 01=HMA _deblock_buf dd 0 ; 0054 deblock buffer times 3 db 0 ; 0058 unknown dw 0 ; 005B unknown - db 0, 0FFh, 0 ; 005D unknown + db 0, 0FFh, 0 ; 005D int24fail,memstrat,a20count global _VgaSet _VgaSet db 0 ; 0060 unknown dw 0 ; 0061 unknown @@ -385,7 +389,8 @@ _winStartupInfo: dw instance_table,seg instance_table ; array of instance data instance_table: ; should include stacks, Win may auto determine SDA region ; we simply include whole DOS data segment - dw 0, seg _DATASTART ; [?linear?] address of region's base + dw seg _DATASTART, 0 ; [?linear?] address of region's base +; dw 0, 0;seg _DATASTART ; [?linear?] address of region's base dw markEndInstanceData wrt seg _DATASTART ; size in bytes dd 0 ; 0 marks end of table patch_bytes: ; mark end of array of offsets of critical section bytes to patch @@ -414,6 +419,8 @@ _winPatchTable: ; returns offsets to various internal variables _firstsftt: dd -1 ; link to next dw 5 ; count + times 5*59 db 0 ; reserve space for the 5 sft entries + db 0 ; pad byte so next value on even boundary ; Some references seem to indicate that this data should start at 01fbh in ; order to maintain 100% MS-DOS compatibility. @@ -717,6 +724,13 @@ blk_stk_top: times 64 dw 0 clk_stk_top: +%IFDEF WIN31SUPPORT +; mux2F private stack + global mux2F_stk_top + times 128 dw 0 +mux2F_stk_top: +%ENDIF ; WIN31SUPPORT + ; Dynamic data: ; member of the DOS DATA GROUP ; and marks definitive end of all used data in kernel data segment diff --git a/mkfiles/generic.mak b/mkfiles/generic.mak index 9fe65f1a..10a78665 100644 --- a/mkfiles/generic.mak +++ b/mkfiles/generic.mak @@ -48,7 +48,7 @@ DEPENDS=makefile ..\*.bat ..\mkfiles\*.* # Implicit Rules ####################################################### .asm.obj: - $(NASM) $(NASMFLAGS) $< + $(NASM) $(NASMFLAGS) -l$*.lst $< .c.obj: $(CC) $(CFLAGS) $< From 630e5c64d75eb5a13b310e95c79f5c9cc4570179 Mon Sep 17 00:00:00 2001 From: Kenneth J Davis Date: Sun, 6 Nov 2005 19:57:54 +0000 Subject: [PATCH 639/671] undo a local only change, build list option is proper way to do this git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/branches/UNSTABLE@1148 6ac86273-5f31-0410-b378-82cca8765d1b --- mkfiles/generic.mak | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mkfiles/generic.mak b/mkfiles/generic.mak index 10a78665..9fe65f1a 100644 --- a/mkfiles/generic.mak +++ b/mkfiles/generic.mak @@ -48,7 +48,7 @@ DEPENDS=makefile ..\*.bat ..\mkfiles\*.* # Implicit Rules ####################################################### .asm.obj: - $(NASM) $(NASMFLAGS) -l$*.lst $< + $(NASM) $(NASMFLAGS) $< .c.obj: $(CC) $(CFLAGS) $< From 23006698f128d49c279613f0368d6aafa8c0a6f9 Mon Sep 17 00:00:00 2001 From: Kenneth J Davis Date: Sun, 20 Nov 2005 16:17:43 +0000 Subject: [PATCH 640/671] add comments about what flags mean git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/branches/UNSTABLE@1150 6ac86273-5f31-0410-b378-82cca8765d1b --- hdr/device.h | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/hdr/device.h b/hdr/device.h index b873badb..4cefb2f8 100644 --- a/hdr/device.h +++ b/hdr/device.h @@ -245,16 +245,16 @@ typedef struct ddtstruct { } ddt; /* description flag bits */ -#define DF_FIXED 0x001 -#define DF_CHANGELINE 0x002 -#define DF_CURBPBLOCK 0x004 -#define DF_SAMESIZE 0x008 -#define DF_MULTLOG 0x010 -#define DF_CURLOG 0x020 -#define DF_DISKCHANGE 0x040 -#define DF_DPCHANGED 0x080 -#define DF_REFORMAT 0x100 -#define DF_NOACCESS 0x200 +#define DF_FIXED 0x001 /* fixed media, ie hard drive */ +#define DF_CHANGELINE 0x002 /* door lock or disk change detection reported as supported */ +#define DF_CURBPBLOCK 0x004 /* current BPB locked ??? */ +#define DF_SAMESIZE 0x008 /* all sectors in a track are the same size */ +#define DF_MULTLOG 0x010 /* physical drive represents multiple logical ones, eg A: & B: */ +#define DF_CURLOG 0x020 /* active (current) logical drive for this physical drive */ +#define DF_DISKCHANGE 0x040 /* disk change was detected */ +#define DF_DPCHANGED 0x080 /* device parameters changed */ +#define DF_REFORMAT 0x100 /* disk formatted so BPB has changed */ +#define DF_NOACCESS 0x200 /* don't allow access (read or write) to fixed media */ /* freedos specific flag bits */ #define DF_LBA 0x400 #define DF_WRTVERIFY 0x800 From db9a0fa419bb919920ff6ab27e0ba0a890fee2e3 Mon Sep 17 00:00:00 2001 From: Kenneth J Davis Date: Sun, 20 Nov 2005 16:20:44 +0000 Subject: [PATCH 641/671] works towards better SS!=DS support, centralized debug macros, some comments git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/branches/UNSTABLE@1151 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/dsk.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/kernel/dsk.c b/kernel/dsk.c index e7e03be4..a3bb21ae 100644 --- a/kernel/dsk.c +++ b/kernel/dsk.c @@ -27,17 +27,13 @@ #include "portab.h" #include "globals.h" #include "dyndata.h" +#include "debug.h" #ifdef VERSION_STRINGS static BYTE *dskRcsId = "$Id$"; #endif -#if defined(DEBUG) -#define DebugPrintf(x) printf x -#else -#define DebugPrintf(x) -#endif void ASMPASCAL fl_readkey(void); int ASMPASCAL fl_reset(UBYTE drive); @@ -64,7 +60,7 @@ int ASMPASCAL fl_lba_ReadWrite(UBYTE drive, WORD mode, #endif STATIC int LBA_Transfer(ddt * pddt, UWORD mode, VOID FAR * buffer, - ULONG LBA_address, unsigned total, UWORD * transferred); + ULONG LBA_address, unsigned total, UWORD FAR * transferred); #define LBA_READ 0x4200 #define LBA_WRITE 0x4300 @@ -223,10 +219,14 @@ STATIC WORD diskchange(ddt * pddt) { int ret = fl_diskchanged(pddt->ddt_driveno); if (ret == 1) + { /* check if it has changed... */ return M_CHANGED; + } if (ret == 0) + { return M_NOT_CHANGED; + } } /* can not detect or error... */ @@ -246,7 +246,7 @@ STATIC WORD mediachk(rqptr rp, ddt * pddt) else if (pddt->ddt_descflags & DF_DISKCHANGE) { pddt->ddt_descflags &= ~DF_DISKCHANGE; - rp->r_mcretcode = M_DONT_KNOW; + rp->r_mcretcode = M_DONT_KNOW; /* media_check() treats as M_CHANGED but tries flushing buffers 1st */ } else if ((rp->r_mcretcode = diskchange(pddt)) == M_DONT_KNOW) { @@ -813,7 +813,7 @@ STATIC WORD dskerr(COUNT code) translate LBA sectors into CHS addressing */ -STATIC void LBA_to_CHS(ULONG LBA_address, struct CHS *chs, const ddt * pddt) +STATIC void LBA_to_CHS(ULONG LBA_address, struct CHS FAR *chs, const ddt * pddt) { /* we need the defbpb values since those are taken from the BIOS, not from some random boot sector, except when @@ -866,7 +866,7 @@ STATIC unsigned DMA_max_transfer(void FAR * buffer, unsigned count) STATIC int LBA_Transfer(ddt * pddt, UWORD mode, VOID FAR * buffer, ULONG LBA_address, unsigned totaltodo, - UWORD * transferred) + UWORD FAR * transferred) { *transferred = 0; From d493dd629fb519a6ed12a53a70e0f25ca6b2847e Mon Sep 17 00:00:00 2001 From: Kenneth J Davis Date: Sun, 20 Nov 2005 16:27:17 +0000 Subject: [PATCH 642/671] add some disabled debug messages git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/branches/UNSTABLE@1152 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/fatfs.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/kernel/fatfs.c b/kernel/fatfs.c index 7771657a..8737555e 100644 --- a/kernel/fatfs.c +++ b/kernel/fatfs.c @@ -1787,7 +1787,8 @@ CLUSTER dos_free(struct dpb FAR * dpbp) } else #endif - if (dpbp->dpb_nfreeclst != UNKNCLSTFREE) + /* only for testing, limit returning cached entry to FAT32, ie always recalc */ + if (/* ISFAT32(dpbp) && */(dpbp->dpb_nfreeclst != UNKNCLSTFREE)) return dpbp->dpb_nfreeclst; for (i = 2; i <= max_cluster; i++) @@ -2066,6 +2067,7 @@ COUNT media_check(REG struct dpb FAR * dpbp) return DE_INVLDDRV; /* First test if anyone has changed the removable media */ + DDebugPrintf(("do media check...\n")); ret = rqblockio(C_MEDIACHK, dpbp); if (ret < SUCCESS) { @@ -2073,25 +2075,26 @@ COUNT media_check(REG struct dpb FAR * dpbp) return ret; } + DDebugPrintf(("mcr=%s, dpb_flags=%04xh\n", (MediaReqHdr.r_mcretcode==1)?"none":"possible", dpbp->dpb_flags)); switch (MediaReqHdr.r_mcretcode | dpbp->dpb_flags) { case M_NOT_CHANGED: /* It was definitely not changed, so ignore it */ - DebugPrintf(("media_check: no change\n")); + DDebugPrintf(("media_check: no change\n")); return SUCCESS; /* If it is forced or the media may have changed, */ /* rebuild the bpb */ case M_DONT_KNOW: /* hazard: no error checking! */ - DebugPrintf(("media_check: unknown\n")); + DDebugPrintf(("media_check: unknown\n")); flush_buffers(dpbp->dpb_unit); /* If it definitely changed, don't know (falls through) */ /* or has been changed, rebuild the bpb. */ /* case M_CHANGED: */ default: - DebugPrintf(("media_check: assumming changed\n")); + DDebugPrintf(("media_check: assumming changed\n")); setinvld(dpbp->dpb_unit); ret = rqblockio(C_BLDBPB, dpbp); if (ret < SUCCESS) @@ -2106,7 +2109,7 @@ COUNT media_check(REG struct dpb FAR * dpbp) #else bpb_to_dpb(MediaReqHdr.r_bpptr, dpbp); #endif - DebugPrintf(("media_check: returning ok\n")); + DDebugPrintf(("media_check: returning ok\n")); return SUCCESS; } } From 9c7fd183f4c3741a8e5eac287499b3809f560d3b Mon Sep 17 00:00:00 2001 From: Kenneth J Davis Date: Sun, 20 Nov 2005 16:39:14 +0000 Subject: [PATCH 643/671] allow printf to work correctly when SS!=DS git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/branches/UNSTABLE@1153 6ac86273-5f31-0410-b378-82cca8765d1b --- hdr/debug.h | 2 +- kernel/init-mod.h | 7 +++++-- kernel/prf.c | 26 +++++++++++++------------- kernel/proto.h | 4 ++-- mkfiles/watcom.mak | 1 + 5 files changed, 22 insertions(+), 18 deletions(-) diff --git a/hdr/debug.h b/hdr/debug.h index b6edb87f..e379763e 100644 --- a/hdr/debug.h +++ b/hdr/debug.h @@ -131,7 +131,7 @@ #endif #ifdef DEBUG_NEED_PRINTF -VOID VA_CDECL printf(const char * fmt, ...); +VOID VA_CDECL printf(const char FAR * fmt, ...); #endif #endif /* __DEBUG_H */ diff --git a/kernel/init-mod.h b/kernel/init-mod.h index dec5bbe9..3eca8484 100644 --- a/kernel/init-mod.h +++ b/kernel/init-mod.h @@ -191,6 +191,8 @@ VOID ASMCFUNC int21_service(iregs far * r); VOID ASMCFUNC FAR int0_handler(void); VOID ASMCFUNC FAR int6_handler(void); VOID ASMCFUNC FAR empty_handler(void); +VOID ASMCFUNC FAR int13_handler(void); +/* VOID ASMCFUNC FAR int19_handler(void); */ VOID ASMCFUNC FAR int20_handler(void); VOID ASMCFUNC FAR int21_handler(void); VOID ASMCFUNC FAR int22_handler(void); @@ -221,8 +223,8 @@ BOOL init_device(struct dhdr FAR *, PCStr cmdLine, int mode, VFP *top); /* prf.c */ -VOID VA_CDECL init_printf(const char * fmt, ...); -VOID VA_CDECL init_sprintf(char * buff, const char * fmt, ...); +VOID VA_CDECL init_printf(const char FAR * fmt, ...); +VOID VA_CDECL init_sprintf(char FAR * buff, const char FAR * fmt, ...); /* procsupt.asm */ VOID ASMCFUNC FAR got_cbreak(void); @@ -253,6 +255,7 @@ extern struct dhdr DOSTEXTFAR ASM blk_dev; /* Block device (Disk) driver extern struct buffer FAR *DOSFAR firstAvailableBuf; /* first 'available' buffer */ extern struct lol ASM FAR DATASTART; +extern intvec ASM FAR SAVEDIVLST; extern BYTE DOSFAR ASM _HMATextAvailable, /* first byte of available CODE area */ FAR ASM _HMATextStart[], /* first byte of HMAable CODE area */ diff --git a/kernel/prf.c b/kernel/prf.c index cc82ba4f..2bfb2dad 100644 --- a/kernel/prf.c +++ b/kernel/prf.c @@ -123,17 +123,17 @@ void put_console(int c) #ifndef FORSYS /* copied from bcc (Bruce's C compiler) stdarg.h */ -typedef char *va_list; -#define va_start(arg, last) ((arg) = (char *) (&(last)+1)) -#define va_arg(arg, type) (((type *)(arg+=sizeof(type)))[-1]) +typedef char FAR *va_list; +#define va_start(arg, last) ((arg) = (va_list) (&(last)+1)) +#define va_arg(arg, type) (((type FAR *)(arg+=sizeof(type)))[-1]) #define va_end(arg) #endif -static BYTE *charp = 0; +static BYTE FAR *charp = 0; STATIC VOID handle_char(COUNT); -STATIC void do_printf(const char *, REG va_list); -VOID VA_CDECL printf(const char * fmt, ...); +STATIC void do_printf(const char FAR *, va_list); +VOID VA_CDECL printf(const char FAR * fmt, ...); /* special handler to switch between sprintf and printf */ STATIC VOID handle_char(COUNT c) @@ -150,7 +150,7 @@ STATIC VOID handle_char(COUNT c) #define LONGARG 4 /* printf -- short version of printf to conserve space */ -VOID VA_CDECL printf(const char *fmt, ...) +VOID VA_CDECL printf(CONST BYTE FAR *fmt, ...) { va_list arg; va_start(arg, fmt); @@ -158,7 +158,7 @@ VOID VA_CDECL printf(const char *fmt, ...) do_printf(fmt, arg); } -VOID VA_CDECL sprintf(char * buff, const char * fmt, ...) +VOID VA_CDECL sprintf(char FAR * buff, CONST BYTE FAR * fmt, ...) { va_list arg; @@ -168,7 +168,7 @@ VOID VA_CDECL sprintf(char * buff, const char * fmt, ...) handle_char('\0'); } -STATIC void do_printf(CONST BYTE * fmt, va_list arg) +STATIC void do_printf(CONST BYTE FAR * fmt, va_list arg) { int base, size; char s[13]; /* long enough for a 32-bit octal number string with sign */ @@ -226,7 +226,7 @@ STATIC void do_printf(CONST BYTE * fmt, va_list arg) case 'p': { UWORD w0 = va_arg(arg, unsigned); - char *tmp = charp; + char FAR *tmp = charp; sprintf(s, "%04x:%04x", va_arg(arg, unsigned), w0); p = s; charp = tmp; @@ -266,7 +266,7 @@ STATIC void do_printf(CONST BYTE * fmt, va_list arg) long n; ULONG u; BOOL minus = FALSE; - BYTE *t = s + sizeof(s) - 1; + BYTE FAR *t = s + sizeof(s) - 1; if (flags & LONGARG) n = va_arg(arg, long); @@ -329,7 +329,7 @@ STATIC void do_printf(CONST BYTE * fmt, va_list arg) #endif #if !defined(FORSYS) && !defined(_INIT) -extern void put_string(const char *); +extern void put_string(const char FAR *); extern void put_unsigned(unsigned, int, int); void hexd(char *title, UBYTE FAR * p, COUNT numBytes) @@ -370,7 +370,7 @@ void put_unsigned(unsigned n, int base, int width) put_string(s); } -void put_string(const char *s) +void put_string(const char FAR *s) { while(*s != '\0') put_console(*s++); diff --git a/kernel/proto.h b/kernel/proto.h index 56b72f2a..41f570b8 100644 --- a/kernel/proto.h +++ b/kernel/proto.h @@ -296,8 +296,8 @@ UWORD ASMCFUNC syscall_MUX14(DIRECT_IREGS); /* prf.c */ #ifdef DEBUG -VOID VA_CDECL printf(const char * fmt, ...); -VOID VA_CDECL sprintf(char * buff, const char * fmt, ...); +VOID VA_CDECL printf(const char FAR* fmt, ...); +VOID VA_CDECL sprintf(char FAR * buff, const char FAR* fmt, ...); #endif VOID hexd(char *title, VOID FAR * p, COUNT numBytes); void put_unsigned(unsigned n, int base, int width); diff --git a/mkfiles/watcom.mak b/mkfiles/watcom.mak index f771767f..772593bc 100644 --- a/mkfiles/watcom.mak +++ b/mkfiles/watcom.mak @@ -32,6 +32,7 @@ MATH_INSERT =+i4m # -ze enable extensions (i.e., near, far, export, etc.) # -zl remove default library information # -zp= pack structure members with alignment {1,2,4,8,16} +# -zu SS!=DGROUP # # -3 optimization for 386 - given in $(CPUOPT) # -g= set code group name From b4d8701d5cb9bb9a97aec6f59bb19b4e4958f290 Mon Sep 17 00:00:00 2001 From: Kenneth J Davis Date: Sun, 20 Nov 2005 16:52:45 +0000 Subject: [PATCH 644/671] initial BIOS disk int 13h wrapper, only passively detects and notes floppy disk change git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/branches/UNSTABLE@1154 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/int2f.asm | 2 + kernel/inthndlr.c | 106 ++++++++++++++++++++++++++++++++++++++++++++-- kernel/kernel.asm | 28 ++++++++++++ kernel/main.c | 79 ++++++++++++++++++++++++++++------ 4 files changed, 198 insertions(+), 17 deletions(-) diff --git a/kernel/int2f.asm b/kernel/int2f.asm index 465a5cbc..75b33331 100644 --- a/kernel/int2f.asm +++ b/kernel/int2f.asm @@ -56,6 +56,8 @@ FarTabRetn: Int2f3: cmp ah,12h je IntDosCal ; Dos Internal calls + cmp ah,13h + je IntDosCal ; Install Int13h Hook cmp ah,16h je IntDosCal ; Win (Multitasking) Hook cmp ah,46h diff --git a/kernel/inthndlr.c b/kernel/inthndlr.c index 8f23df3c..02cf3739 100644 --- a/kernel/inthndlr.c +++ b/kernel/inthndlr.c @@ -41,7 +41,7 @@ BYTE *RcsId = #ifdef TSC STATIC VOID StartTrace(VOID); -static bTraceNext = FALSE; +STATIC bTraceNext = FALSE; #endif #if 0 /* Very suspicious, passing structure by value?? @@ -1703,6 +1703,9 @@ struct int2f12regs { xreg callerARG1; /* used if called from INT2F/12 */ }; +extern intvec BIOSInt13, UserInt13, BIOSInt19; + + /* WARNING: modifications in `r' are used outside of int2F_12_handler() * On input r.AX==0x12xx, 0x4A01 or 0x4A02 * also handle Windows' DOS notification hooks, r.AH==0x16 @@ -1733,6 +1736,17 @@ VOID ASMCFUNC int2F_12_handler(struct int2f12regs r) r.BX = size; return; } + else if (r.AH == 0x13) /* set disk interrupt (13h) handler */ + { + /* set new values for int13h calls, and must return old values */ + register intvec tmp = UserInt13; + UserInt13 = MK_FP(r.ds, r.DX); /* int13h handler to use */ + r.ds = FP_SEG(tmp); r.DX = FP_OFF(tmp); + tmp = BIOSInt13; + BIOSInt13 = MK_FP(r.es, r.BX); /* int13h handler to restore on reboot */ + r.es = FP_SEG(tmp); r.BX = FP_OFF(tmp); + return; + } else if (r.AH == 0x16) /* Window/Multitasking hooks */ { #ifdef WIN31SUPPORT /* See "DOS Internals" or RBIL under DOSMGR for details */ @@ -1915,9 +1929,8 @@ VOID ASMCFUNC int2F_12_handler(struct int2f12regs r) case 0x80: /* Win Release Time-slice */ { /* This function is generally only called in idle loops */ - enable; /* enable interrupts */ - // __emit__(0xf4); /* halt */ - asm hlt; + __emit__(0xfb); /* sti; enable interrupts */ + __emit__(0xf4); /* hlt; halt until interrupt */ r.AX = 0; /* DebugPrintf(("Release Time Slice\n")); */ break; @@ -2259,6 +2272,91 @@ VOID ASMCFUNC int2F_12_handler(struct int2f12regs r) r.FLAGS |= FLG_CARRY; } + +/* how registers pushed on stack prior to calling int wrapper function, + when returns these are then popped off, so any changes to these + will effectively set the returned value in these registers + */ +struct intXXregs { +#ifdef I386 + /* preserved 386+ only registers, compiler specific */ +#endif + UWORD es, ds; + UWORD di, si, bp; + xreg b, d, c, a; + UWORD intreq; /* which interrupt filter request for */ + UWORD flags; /* flags duplicated, one pushed by int call ignored */ + xreg param; + UWORD ip, cs , oflags; + /* top item of int caller's stack, possibly additional params */ +}; + + +/* additional processing for various wrapped/filtered interrupts + WARNING: this function also called during kernel init phase + -- int 13h + filter for BIOS int13h support, only called on int13h error + for ms-dos compatibility this should at minimal + watch for disk-change notification and set internal status + (may be called multiple times in row when BIOS reports same + change multiple times, ie delays clearing disk change status) + TODO: move DMA bounday check from int25/26 to here + Note: use stored user (usually BIOS) hooked int13 handler + -- int 19h + clean up prior to a warm reboot + for ms compatibility this should at a minimal + restore original (or indicated as original) BIOS int13h handler + and any others that may be hooked (including this one) + if himem loaded clear high memory area (clear vdisk signature so himem loads) + */ +VOID ASMCFUNC intXX_filter(struct intXXregs r) +{ + DebugPrintf(("int %02xh filter\n", r.intreq)); + switch(r.intreq) + { + case 0x19: /* reboot via bootstrap */ + { + setvec(0x13, BIOSInt13); + setvec(0x19, BIOSInt19); + + /* clear vdisk signature if kernel loaded in hma */ + if (version_flags & 0x10) + fmemset(MK_FP(0xffff, 0x0010),0,512); + break; + } + case 0x13: /* error with disk handler */ + { + DebugPrintf(("disk error %i [ah=%x] (drive %x)\n", r.a.b.h, r.param.b.h, r.param.b.l)); + DebugPrintf(("bx==(%x) cx==(%x) dx==(%x)\n", r.BX, r.CX, r.DX)); + /* currently just marks floppy as changed on disk change error */ + if ((r.a.b.h == 0x06) && (r.param.b.l < 0x80)) /* diskchange and is it a floppy? */ + { + register int i; + + /* mark floppy as changed */ + for(i=0; i < blk_dev.dh_name[0]; i++) + { + ddt *pddt = getddt(i); + if (pddt->ddt_driveno == r.param.b.l) + { + DebugPrintf(("ddt[%i] match, flags=%04x\n", i, pddt->ddt_descflags)); + if ((pddt->ddt_descflags & DF_CHANGELINE) && /* drive must have changeline support */ + (pddt->ddt_descflags & DF_CURBPBLOCK)) /* and BPB not currently locked (in-use) */ + pddt->ddt_descflags |= DF_DISKCHANGE; + /* or get dpb pointer from ddt and set dpbp->dpb_flags = M_CHANGED; */ + } + } + } + break; + } + default: + DebugPrintf(("INT_ERROR!\n")); + break; + } +} + + + /* * 2000/09/04 Brian Reifsnyder * Modified interrupts 0x25 & 0x26 to return more accurate error codes. diff --git a/kernel/kernel.asm b/kernel/kernel.asm index 19fe35ce..b95cf781 100644 --- a/kernel/kernel.asm +++ b/kernel/kernel.asm @@ -652,6 +652,22 @@ _ext_open_action dw 0 ;2DD - extended open action _ext_open_attrib dw 0 ;2DF - extended open attrib _ext_open_mode dw 0 ;2E1 - extended open mode + + +; these 3 placed here so init code and int wrapper can easily access +; holds pointers to actual disk handler routines and interrupt +; vectors that we try to restore before a warm reboot + global _SAVEDIVLST +_SAVEDIVLST: + ; used by int13 handler and get/set via int 2f/13h + global _BIOSInt13 + global _UserInt13 +_BIOSInt13 dd 0 ; used to restore int13 on reboot (see int19 wrapper) +_UserInt13 dd 0 ; actual disk handler used by kernel + global _BIOSInt19 +_BIOSInt19 dd 0 ; original int19 + + ; Pad to 0620h times (300h - ($ - _internal_data)) db 0 global _szNames @@ -846,6 +862,18 @@ initforceEnableA20: global __HMARelocationTableStart __HMARelocationTableStart: + global _int13_handler + extern reloc_call_int13_handler +_int13_handler: jmp 0:reloc_call_int13_handler + call near forceEnableA20 + +#if 0 + global _int19_handler + extern reloc_call_int19_handler +_int19_handler: jmp 0:reloc_call_int19_handler + call near forceEnableA20 +#endif + global _int2f_handler extern reloc_call_int2f_handler _int2f_handler: jmp 0:reloc_call_int2f_handler diff --git a/kernel/main.c b/kernel/main.c index bff2b2f5..b61a0d8b 100644 --- a/kernel/main.c +++ b/kernel/main.c @@ -30,6 +30,7 @@ #include "portab.h" #include "init-mod.h" #include "dyndata.h" +#include "debug.h" #ifdef VERSION_STRINGS static BYTE *mainRcsId = @@ -48,6 +49,7 @@ STATIC VOID init_internal_devices(void); STATIC VOID update_dcb(struct dhdr FAR *); STATIC VOID init_kernel(VOID); +STATIC VOID do_fixup(VOID); STATIC VOID signon(VOID); STATIC VOID init_shell(VOID); STATIC VOID FsConfig(VOID); @@ -55,6 +57,11 @@ STATIC VOID InitPrinters(VOID); STATIC VOID InitSerialPorts(VOID); STATIC void CheckContinueBootFromHarddisk(void); STATIC void setup_int_vectors(void); +#define setup_fastprint_hook() setvec(0x29, int29_handler) /* required for printf! */ + + +void setvec(unsigned char intno, intvec vector); + #ifdef _MSC_VER BYTE _acrtused = 0; @@ -67,6 +74,7 @@ __segment DosTextSeg = 0; #endif struct lol FAR * const LoL = &DATASTART; +intvec FAR * const savedIVs = &SAVEDIVLST; void ASMCFUNC FreeDOSmain(void) { @@ -120,14 +128,25 @@ void ASMCFUNC FreeDOSmain(void) fmemcpy(&InitKernelConfig, p, sizeof InitKernelConfig); } - setup_int_vectors(); + /* printfs won't work until int29, fast console output hook is installed */ + setup_fastprint_hook(); + /* check if booting from CD before we hook too many interrupts */ CheckContinueBootFromHarddisk(); + /* display copyright info and kernel emulation status */ signon(); + + /* finish initial HMA segment relocation (move up until DOS=HIGH known) */ + do_fixup(); + + /* install DOS API and other interrupt service routines, basic kernel functionality works */ + setup_int_vectors(); + + /* initialize all internal variables, process CONFIG.SYS, load drivers, etc */ init_kernel(); - init_shell(); + init_shell(); init_call_p_0(&Config); /* execute process 0 (the shell) */ } @@ -195,6 +214,30 @@ void setvec(unsigned char intno, intvec vector) } #endif + +/* ensures int vectors we may need to restore are saved */ +STATIC VOID save_int_vectors(VOID) +{ + /* we create far pointers otherwise compiler sets value + in initial data segment (IDATA) which does us no good. + */ + extern intvec BIOSInt13, UserInt13, BIOSInt19; /* in kernel.asm */ + intvec FAR *pBIOSInt13, FAR *pUserInt13, FAR *pBIOSInt19; + + pBIOSInt13 = MK_FP(FP_SEG(savedIVs), FP_OFF(savedIVs)); + pUserInt13 = pBIOSInt13 + 1; + pBIOSInt19 = pBIOSInt13 + 2; + + /* store for later use by our replacement int13handler */ + *pBIOSInt13 = getvec(0x13); /* save original BIOS int 0x13 handler */ + *pUserInt13 = *pBIOSInt13; /* default to it for user int 0x13 handler */ + *pBIOSInt19 = getvec(0x19); /* save reboot handler so we can clean up a little */ + + DDebugPrintf(("\n")); /* force anything printed to start on next line after BS */ + DDebugPrintf(("BIOSInt13(at %p) is %p\n", pBIOSInt13, *pBIOSInt13)); + DDebugPrintf(("BIOSInt19(at %p) is %p\n", pBIOSInt19, *pBIOSInt19)); +} + STATIC void setup_int_vectors(void) { static struct vec @@ -208,20 +251,27 @@ STATIC void setup_int_vectors(void) { 0x1, FP_OFF(empty_handler) }, /* single step */ { 0x3, FP_OFF(empty_handler) }, /* debug breakpoint */ { 0x6, FP_OFF(int6_handler) }, /* invalid opcode */ + { 0x13, FP_OFF(int13_handler) }, /* BIOS disk filter */ +#if 0 + { 0x19, FP_OFF(int19_handler) }, /* BIOS bootstrap loader, vdisk */ +#endif { 0x20, FP_OFF(int20_handler) }, - { 0x21, FP_OFF(int21_handler) }, + { 0x21, FP_OFF(int21_handler) }, /* primary DOS API */ { 0x22, FP_OFF(int22_handler) }, { 0x24, FP_OFF(int24_handler) }, - { 0x25, FP_OFF(low_int25_handler) }, + { 0x25, FP_OFF(low_int25_handler) }, /* DOS abs read/write calls */ { 0x26, FP_OFF(low_int26_handler) }, { 0x27, FP_OFF(int27_handler) }, { 0x28, FP_OFF(int28_handler) }, { 0x2a, FP_OFF(int2a_handler) }, - { 0x2f, FP_OFF(int2f_handler) } + { 0x2f, FP_OFF(int2f_handler) } /* multiplex int */ }; struct vec *pvec; int i; + save_int_vectors(); + + /* install default handlers */ for (i = 0x23; i <= 0x3f; i++) setvec(i, empty_handler); for (pvec = vectors; pvec < ENDOF(vectors); pvec++) @@ -229,7 +279,7 @@ STATIC void setup_int_vectors(void) pokeb(0, 0x30 * 4, 0xea); pokel(0, 0x30 * 4 + 1, (ULONG)cpm_entry); - /* these two are in the device driver area LOWTEXT (0x70) */ + /* handlers for int 0x1b and 0x29 are in the device driver area LOWTEXT (0x70) */ setvec(0x1b, got_cbreak); setvec(0x29, int29_handler); /* required for printf! */ } @@ -251,14 +301,8 @@ STATIC void printIRQvectors(void) } #endif -STATIC void init_kernel(void) +STATIC void do_fixup(void) { - COUNT i; - - LoL->os_setver_major = LoL->os_major = MAJOR_RELEASE; - LoL->os_setver_minor = LoL->os_minor = MINOR_RELEASE; - LoL->rev_number = REVISION_SEQ; - /* move kernel to high conventional RAM, just below the init code */ /* Note: kernel.asm actually moves and jumps here, but MoveKernel must still be called to do the necessary segment fixups */ @@ -275,6 +319,15 @@ STATIC void init_kernel(void) chunk allocated, lpTop. I.e. lpTop is top of free conv memory */ lpTop = MK_FP(FP_SEG(lpTop) - 0xfff, 0xfff0); +} + +STATIC void init_kernel(void) +{ + COUNT i; + + LoL->os_setver_major = LoL->os_major = MAJOR_RELEASE; + LoL->os_setver_minor = LoL->os_minor = MINOR_RELEASE; + LoL->rev_number = REVISION_SEQ; /* Initialize IO subsystem */ init_internal_devices(); From fb6e86f3883d46c6832b12f40b51a4605e6e8860 Mon Sep 17 00:00:00 2001 From: Kenneth J Davis Date: Sun, 20 Nov 2005 16:57:35 +0000 Subject: [PATCH 645/671] assembly glue to wrap misc interrupts with C handler git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/branches/UNSTABLE@1155 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/intwrap.asm | 161 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 161 insertions(+) create mode 100644 kernel/intwrap.asm diff --git a/kernel/intwrap.asm b/kernel/intwrap.asm new file mode 100644 index 00000000..6c642a54 --- /dev/null +++ b/kernel/intwrap.asm @@ -0,0 +1,161 @@ +; +; File: +; intwrap.asm +; Description: +; support for hooking misc interrupts +; BIOS disk interrupt support code +; warm boot support code +; +; Copyright (c) 2005 +; Pasquale J. Villani +; All Rights Reserved +; +; This file is part of DOS-C. +; +; DOS-C is free software; you can redistribute it and/or +; modify it under the terms of the GNU General Public License +; as published by the Free Software Foundation; either version +; 2, or (at your option) any later version. +; +; DOS-C is distributed in the hope that it will be useful, but +; WITHOUT ANY WARRANTY; without even the implied warranty of +; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See +; the GNU General Public License for more details. +; +; You should have received a copy of the GNU General Public +; License along with DOS-C; see the file COPYING. If not, +; write to the Free Software Foundation, 675 Mass Ave, +; Cambridge, MA 02139, USA. +; + + %include "segs.inc" + %include "stacks.inc" + +segment HMA_TEXT + extern _DGROUP_ + + ; defined in kernel.asm + extern _UserInt13 ; actual BIOS int13 disk handler used by kernel + extern _BIOSInt19 ; original int19 (reboot) + + +; receives int 13h request, invokes original handler, +; but passes to C routine in inthndr.c on error +; this lets successful calls proceed with minimal overhead +; while allowing us to handle errors, store disk change, ... + + global reloc_call_int13_handler +reloc_call_int13_handler: + cli ; disable other interrupts for now + stc ; force error unless BIOS clears + push dx ; store BIOS drive # for error handling usage + + push ds ; get segment of kernel DATA + mov ds, [cs:_DGROUP_] + pushf ; simulate int call so returns back here (flags+cs:ip on stack) + call far [ds:_UserInt13] + pop ds ; restore ds + + jc int13err ; test if error, if not return to caller + +int13iret: + inc sp ; clean up stack + inc sp + sti ; ensure int's are renabled + retf 2 ; return to caller leaving flags asis + +int13err: + pushf ; don't mess up flags + + cmp ah, 06h ; disk changed + je int13wrap + + ; add check for other errors here, such as DMA issues + + popf + jmp int13iret ; pass error asis back to user + + +int13wrap: +%IF XCPU < 186 + push ax ; preserve registers, setup stack frame + push bp + mov bp, sp + mov ax, 13h ; want to push 0x13 onto stack + xchg ax, [bp+2] ; so restore pushed ax value and put 0x13 on stack + pop bp ; clean up stack frame (leaving just 0x13 pushed on stack) +%ELSE + push 13h ; the 186+ way to push a constant on the stack +%ENDIF + + ; at this point stack has initial flags, called cs,ip, initial dx, + ; flags returned from int13 call, and value 13h + ; fall through to intWrapCall to invoke C handler + + +; assumes interrupt # and single word param already pushed on stack +; pushes all registers on stack +; calls C handler +; restores registers (replacing value if changed by C code) +; pops int# and param off stack +; returns via iret +intWrapCall: + ; set up register frame + push ax + push cx + push dx + push bx + push bp + push si + push di + push ds + push es + + cld + + Protect386Registers ; ensure 386+ registers possibly modified by kernel safe + + mov ds,[cs:_DGROUP_] + push ds ; mov es, ds + pop es + extern _intXX_filter + call _intXX_filter + + Restore386Registers + + pop es + pop ds + pop di + pop si + pop bp + pop bx + pop dx + pop cx + pop ax + + add sp, 2 ; pop int# off stack + popf ; restore flags + inc sp ; pop param off stack (without altering flags) + inc sp + retf 2 ; iret but ignore pushed flags + + + +#if 0 +; receives int 19h request, resets various int values, +; clears hma if in use, and finally invokes original handler, + + global reloc_call_int19_handler +reloc_call_int19_handler: + + mov ds, [cs:_DGROUP_] + lds ax,[_BIOSInt19] ; iret calls original handler, doesn't return + add sp, 4 ; so pop callers return address off stack + push ds ; and replace with address of original handler + push ax + push ax ; param, ignored + pushf ; flags, ignored + mov ax, 19h ; handler for int 19h + push ax + jmp intWrapCall +#endif From 19d6cbe3fed0ff143cd42884bd0c0f4054114a75 Mon Sep 17 00:00:00 2001 From: Kenneth J Davis Date: Sun, 20 Nov 2005 17:00:36 +0000 Subject: [PATCH 646/671] add new intwrap.asm file git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/branches/UNSTABLE@1156 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/kernel/makefile b/kernel/makefile index 14159e93..28b87d76 100644 --- a/kernel/makefile +++ b/kernel/makefile @@ -16,7 +16,7 @@ HDR=../hdr/ # Order of linking is important: first kernel.asm, last INIT code. OBJS1=kernel.obj entry.obj intr.obj irqstack.obj apisupt.obj io.obj console.obj OBJS2=printer.obj serial.obj dosidle.obj execrh.obj asmsupt.obj int2f.obj \ -nlssupt.obj +nlssupt.obj intwrap.obj OBJS3=nls_hc.obj procsupt.obj dsk.obj error.obj blockio.obj chario.obj break.obj OBJS4=fatfs.obj fatdir.obj fattab.obj dosfns.obj fcbfns.obj inthndlr.obj OBJS5=ioctl.obj memmgr.obj task.obj newstuff.obj dosnames.obj nls.obj @@ -64,6 +64,7 @@ dosidle.obj: dosidle.asm segs.inc entry.obj: entry.asm segs.inc $(HDR)stacks.inc execrh.obj: execrh.asm segs.inc int2f.obj: int2f.asm segs.inc $(HDR)stacks.inc +intwrap.obj: intwrap.asm segs.inc $(HDR)stacks.inc intr.obj: intr.asm segs.inc io.obj: io.asm segs.inc $(HDR)stacks.inc irqstack.obj: irqstack.asm segs.inc From f9f2a082c1474f45ecd9a06e7dd572ace9a2aab1 Mon Sep 17 00:00:00 2001 From: Kenneth J Davis Date: Sun, 20 Nov 2005 19:03:17 +0000 Subject: [PATCH 647/671] cleaner push immediate from Arkady and note big bug to be fixed git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/branches/UNSTABLE@1157 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/intwrap.asm | 11 +++++------ kernel/kernel.asm | 4 ++-- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/kernel/intwrap.asm b/kernel/intwrap.asm index 6c642a54..4f20ad2d 100644 --- a/kernel/intwrap.asm +++ b/kernel/intwrap.asm @@ -50,6 +50,7 @@ reloc_call_int13_handler: stc ; force error unless BIOS clears push dx ; store BIOS drive # for error handling usage +;TODO FIX this alters DS which is used by some subfunctions!!! push ds ; get segment of kernel DATA mov ds, [cs:_DGROUP_] pushf ; simulate int call so returns back here (flags+cs:ip on stack) @@ -61,7 +62,6 @@ reloc_call_int13_handler: int13iret: inc sp ; clean up stack inc sp - sti ; ensure int's are renabled retf 2 ; return to caller leaving flags asis int13err: @@ -78,11 +78,10 @@ int13err: int13wrap: %IF XCPU < 186 - push ax ; preserve registers, setup stack frame + push bp push bp mov bp, sp - mov ax, 13h ; want to push 0x13 onto stack - xchg ax, [bp+2] ; so restore pushed ax value and put 0x13 on stack + mov [bp+2], word 13h ; do the push 0x13 onto stack pop bp ; clean up stack frame (leaving just 0x13 pushed on stack) %ELSE push 13h ; the 186+ way to push a constant on the stack @@ -141,7 +140,7 @@ intWrapCall: -#if 0 +%IF 0 ; receives int 19h request, resets various int values, ; clears hma if in use, and finally invokes original handler, @@ -158,4 +157,4 @@ reloc_call_int19_handler: mov ax, 19h ; handler for int 19h push ax jmp intWrapCall -#endif +%ENDIF diff --git a/kernel/kernel.asm b/kernel/kernel.asm index b95cf781..c2c2f705 100644 --- a/kernel/kernel.asm +++ b/kernel/kernel.asm @@ -867,12 +867,12 @@ __HMARelocationTableStart: _int13_handler: jmp 0:reloc_call_int13_handler call near forceEnableA20 -#if 0 +%IF 0 global _int19_handler extern reloc_call_int19_handler _int19_handler: jmp 0:reloc_call_int19_handler call near forceEnableA20 -#endif +%ENDIF global _int2f_handler extern reloc_call_int2f_handler From 3a8752a5ab4fdde96758c4e514361f28a7f3327a Mon Sep 17 00:00:00 2001 From: Kenneth J Davis Date: Sat, 26 Nov 2005 18:59:53 +0000 Subject: [PATCH 648/671] add/use halt() wrapper for issuing "hlt" asm instruction git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/branches/UNSTABLE@1158 6ac86273-5f31-0410-b378-82cca8765d1b --- hdr/portab.h | 8 ++++++-- kernel/inthndlr.c | 4 ++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/hdr/portab.h b/hdr/portab.h index 14b398bf..7a0dd0ed 100644 --- a/hdr/portab.h +++ b/hdr/portab.h @@ -83,8 +83,9 @@ static char *portab_hRcsId = void __int__(int); #ifndef FORSYS void __emit__(char, ...); -#define disable() __emit__(0xfa) -#define enable() __emit__(0xfb) +#define disable() __emit__(0xfa) /* cli; disable interrupts */ +#define enable() __emit__(0xfb) /* sti; enable interrupts */ +#define halt() __emit__(0xf4) /* hlt; halt until interrupt */ #endif #elif defined (_MSC_VER) @@ -99,6 +100,7 @@ void __emit__(char, ...); #define __int__(intno) asm int intno; #define disable() asm cli #define enable() asm sti +#define halt() asm hlt #define _CS getCS() static unsigned short __inline getCS(void) { @@ -118,6 +120,8 @@ void disable(void); #pragma aux disable = "cli" modify exact []; void enable(void); #pragma aux enable = "sti" modify exact []; +void halt(void); +#pragma aux halt = "hlt" modify exact []; #define asm __asm #define far __far #define CDECL __cdecl diff --git a/kernel/inthndlr.c b/kernel/inthndlr.c index 02cf3739..7af35f5f 100644 --- a/kernel/inthndlr.c +++ b/kernel/inthndlr.c @@ -1929,8 +1929,8 @@ VOID ASMCFUNC int2F_12_handler(struct int2f12regs r) case 0x80: /* Win Release Time-slice */ { /* This function is generally only called in idle loops */ - __emit__(0xfb); /* sti; enable interrupts */ - __emit__(0xf4); /* hlt; halt until interrupt */ + enable(); /* sti; enable interrupts */ + halt(); /* hlt; halt until interrupt */ r.AX = 0; /* DebugPrintf(("Release Time Slice\n")); */ break; From 407014d5fd82ef2e2e4776cd5f7f00e27ad55c2c Mon Sep 17 00:00:00 2001 From: Kenneth J Davis Date: Sat, 26 Nov 2005 19:55:50 +0000 Subject: [PATCH 649/671] fix prototype, add FAR git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/branches/UNSTABLE@1159 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/proto.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/proto.h b/kernel/proto.h index 41f570b8..c66567a5 100644 --- a/kernel/proto.h +++ b/kernel/proto.h @@ -301,7 +301,7 @@ VOID VA_CDECL sprintf(char FAR * buff, const char FAR* fmt, ...); #endif VOID hexd(char *title, VOID FAR * p, COUNT numBytes); void put_unsigned(unsigned n, int base, int width); -void put_string(const char *s); +void put_string(const char FAR *s); void put_console(int); /* strings.c */ From f44334f0e27d2dec991e73ac090b28b1b6f55838 Mon Sep 17 00:00:00 2001 From: Kenneth J Davis Date: Sun, 27 Nov 2005 08:20:33 +0000 Subject: [PATCH 650/671] potential fix for spurious near fnodes!=0 msg with shsufdrv and >2 near fnodes in use for bug 1879 git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/branches/UNSTABLE@1160 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/inthndlr.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/kernel/inthndlr.c b/kernel/inthndlr.c index 7af35f5f..3e1905a8 100644 --- a/kernel/inthndlr.c +++ b/kernel/inthndlr.c @@ -434,10 +434,26 @@ VOID ASMCFUNC int21_service(iregs FAR * r) } /* Clear carry by default for these functions */ - /* see PATCH TE 5 jul 04 explanation at end */ - if (ErrorMode && lr.AH > 0x0c && lr.AH != 0x30 && lr.AH != 0x59) + /* We force clear the near fnodes, + On a normal int21h entry these are unused, so should already + be clear, thus this code is effectively redundant. + However when re-entering int21h, such as a device driver + (e.g. shsufdrv), the fnodes may contain the values of the + in progress call; as long as the driver/tsr causing the + reentrancey saves and restores the SDA across the call then + any changes we do (ie clearing these) should go unnoticed + and if the cause of the reentrancy does not save/restore the + SDA then the caller should expected the unexpected. + Failure to do this will at a minimal result in the extra + output indicating fnodes not 0 (and possibly clearing at end + of call) when the re-entered int21h call completes, but could + result in the re-entered call to fail with no free near fnodes + if both are already in use by the original int21h call (?bug 1879?). + See also PATCH TE 5 jul 04 explanation at end + */ + if (/*ErrorMode && */lr.AH > 0x0c && lr.AH != 0x30 && lr.AH != 0x59) { - ErrorMode = 0; + /*if (ErrorMode)*/ ErrorMode = 0; fnode[0].f_count = 0; /* don't panic - THEY ARE unused !! */ fnode[1].f_count = 0; } From e4b6c0e63ccd43bb04da34c582637a210a596317 Mon Sep 17 00:00:00 2001 From: Kenneth J Davis Date: Wed, 30 Nov 2005 16:36:24 +0000 Subject: [PATCH 651/671] temp fix until int13h entry code cleaned up git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/branches/UNSTABLE@1161 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/main.c b/kernel/main.c index b61a0d8b..28883e8a 100644 --- a/kernel/main.c +++ b/kernel/main.c @@ -251,7 +251,7 @@ STATIC void setup_int_vectors(void) { 0x1, FP_OFF(empty_handler) }, /* single step */ { 0x3, FP_OFF(empty_handler) }, /* debug breakpoint */ { 0x6, FP_OFF(int6_handler) }, /* invalid opcode */ - { 0x13, FP_OFF(int13_handler) }, /* BIOS disk filter */ +/* { 0x13, FP_OFF(int13_handler) }, *//* BIOS disk filter */ #if 0 { 0x19, FP_OFF(int19_handler) }, /* BIOS bootstrap loader, vdisk */ #endif From ed009bd3eb2c3184ac010ff6fc5b5408b9b38a3e Mon Sep 17 00:00:00 2001 From: Kenneth J Davis Date: Wed, 30 Nov 2005 21:59:18 +0000 Subject: [PATCH 652/671] sync printf prototypes (uncorrupt executables) git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/branches/UNSTABLE@1162 6ac86273-5f31-0410-b378-82cca8765d1b --- sys/fdkrncfg.c | 4 ++-- sys/sys.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/sys/fdkrncfg.c b/sys/fdkrncfg.c index 55daef2f..0f37481e 100644 --- a/sys/fdkrncfg.c +++ b/sys/fdkrncfg.c @@ -24,8 +24,8 @@ char KERNEL[] = "KERNEL.SYS"; #include #include "portab.h" -extern int VA_CDECL printf(const char * fmt, ...); -extern int VA_CDECL sprintf(char * buff, const char * fmt, ...); +extern int VA_CDECL printf(const char FAR * fmt, ...); +extern int VA_CDECL sprintf(char FAR * buff, const char FAR * fmt, ...); #ifdef __WATCOMC__ unsigned _dos_close(int handle); diff --git a/sys/sys.c b/sys/sys.c index 14353e3f..dacbf2b1 100644 --- a/sys/sys.c +++ b/sys/sys.c @@ -75,8 +75,8 @@ * #including to make executable MUCH smaller * using [s]printf from prf.c! */ -extern int VA_CDECL printf(const char * fmt, ...); -extern int VA_CDECL sprintf(char * buff, const char * fmt, ...); +extern int VA_CDECL printf(const char FAR * fmt, ...); +extern int VA_CDECL sprintf(char FAR * buff, const char FAR * fmt, ...); #include "fat12com.h" #include "fat16com.h" From bb3351bdd060c6272136a48eb542cd79dfee3382 Mon Sep 17 00:00:00 2001 From: Kenneth J Davis Date: Sat, 10 Dec 2005 02:41:43 +0000 Subject: [PATCH 653/671] add int 2f subfunc 122B and 122D from Eduardo Casino git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/branches/UNSTABLE@1163 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/inthndlr.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/kernel/inthndlr.c b/kernel/inthndlr.c index 3e1905a8..369cae8f 100644 --- a/kernel/inthndlr.c +++ b/kernel/inthndlr.c @@ -2233,12 +2233,40 @@ VOID ASMCFUNC int2F_12_handler(struct int2f12regs r) r.FLAGS &= ~FLG_CARRY; break; + case 0x2b: /* Device I/O Control */ + if (r.BP < 0x4400 || r.BP > 0x44ff) + goto error_invalid; + { + lregs lr; + lr.AX = r.BP; + lr.BX = r.BX; + lr.CX = r.CX; + lr.DX = r.DX; + lr.DI = r.DI; + lr.SI = r.SI; + lr.DS = r.DS; + rc = DosDevIOctl(&lr); /* can set critical error code! */ + } + + if (rc < SUCCESS) + { + r.AX = -rc; + if (rc != DE_DEVICE && rc != DE_ACCESS) + CritErrCode = r.AX; + goto error_carry; + } + break; + case 0x2c: /* added by James Tabor For Zip Drives Return Null Device Pointer */ /* by UDOS+RBIL: get header of SECOND device driver in device chain, omitting the NUL device TE */ r.BX = FP_SEG(nul_dev.dh_next); r.AX = FP_OFF(nul_dev.dh_next); + break; + + case 0x2d: /* Get Extended Error Code */ + r.AX = CritErrCode; /* fall through only to re-use break */ case 0x2e: /* GET or SET error table addresse - ignored called by MS debug with DS != DOSDS, printf @@ -2285,6 +2313,7 @@ VOID ASMCFUNC int2F_12_handler(struct int2f12regs r) r.AX = -rc; if (CritErrCode == SUCCESS) CritErrCode = r.AX; /* Maybe set */ +error_carry: r.FLAGS |= FLG_CARRY; } From 5fc9476d73d10793285de792076e8c617d036cb5 Mon Sep 17 00:00:00 2001 From: Kenneth J Davis Date: Sat, 10 Dec 2005 02:44:36 +0000 Subject: [PATCH 654/671] add info Eduardo's latest patch git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/branches/UNSTABLE@1164 6ac86273-5f31-0410-b378-82cca8765d1b --- docs/history.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/history.txt b/docs/history.txt index 3fce9c33..38043464 100644 --- a/docs/history.txt +++ b/docs/history.txt @@ -364,6 +364,7 @@ - DOS-63-00 returns DBCS table from the active NLS package, not the harcoded one. - DOS-65-23: DosYesNo() arg is now DX, not DL. + - added Int 2Fh/122Bh&122Dh processing for NLSFUNC to work with DISPLAY 1.0 * nls.c: MuxLoadPkg(), MuxGo() functions modified for NLSFUNC - New macro getTable7() - New functions nlsIsDBCS() (check if a byte is a dual byte char From 70e92397bb1bfa2e0df945ee8dad02fb72b76031 Mon Sep 17 00:00:00 2001 From: Kenneth J Davis Date: Sat, 10 Dec 2005 04:15:13 +0000 Subject: [PATCH 655/671] document SWITCHES command, based on descriptions provided from Eric git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/branches/UNSTABLE@1165 6ac86273-5f31-0410-b378-82cca8765d1b --- docs/config.txt | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/docs/config.txt b/docs/config.txt index 0ec7d195..639cbcee 100644 --- a/docs/config.txt +++ b/docs/config.txt @@ -1,3 +1,5 @@ +Title: Config.sys Options + Configuring your DOS system for use: ------------------------------------ When booting DOS, you will find it only supports a subset of @@ -189,6 +191,21 @@ returned by a get switchar query, it will not effect programs that use hardcoded switch characters. e.g. switchar=- +SWITCHES +Usage: switches=/E[:xxx] /F /K /N /W +Adjusts boot time processing behaviour. +/F skips the delay checking for F5/F8 keystroke before processing config.sys + [equivalent to setting kernel config option skipconfigseconds = 0] +/N disables F5/F8 support [equivalent to kernel config skipconfigseconds = -1] +(note: with /F a well timed F5/F8 still works, whereas /N completely disables) +/K forces treating of keyboard as 86 key keyboard +/E enables moving of EBDA (Extended BIOS Data Area), optionally a size in KB + may be specified [xxx, in range of 48-1024] +/W disables Windows 3.0 from loading WINA20.386 from the root directory (used + when \WINA20.386 is moved into a subdirectory, a device line with proper + path must be added to Microsoft (R) Windows' SYSTEM.INI [386Enhanced] + section.) --- Unsupported, though may be ignored for compatibility. + VERSION Usage: version=x.y FreeDOS specific command to specify what DOS version to report. From 0ca4cb94ef9830c748bc6578a199fd1403317917 Mon Sep 17 00:00:00 2001 From: Kenneth J Davis Date: Fri, 16 Dec 2005 09:35:47 +0000 Subject: [PATCH 656/671] FreeDOS share git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/branches/UNSTABLE@1168 6ac86273-5f31-0410-b378-82cca8765d1b --- share/share.c | 701 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 701 insertions(+) create mode 100644 share/share.c diff --git a/share/share.c b/share/share.c new file mode 100644 index 00000000..fde6849a --- /dev/null +++ b/share/share.c @@ -0,0 +1,701 @@ +/* + FreeDOS SHARE + Copyright (c) 2000 Ronald B. Cemer under the GNU GPL + You know the drill. + If not, see www.gnu.org for details. Read it, learn it, BE IT. :-) +*/ + +#include +#include +#include +#include +#include +#include + +#ifndef __TURBOC__ +#error "This software must be compiled with TurboC or TurboC++." +#endif + +#define MUX_INT_NO 0x2f +#define MULTIPLEX_ID 0x10 + +#define FILE_TABLE_MIN 128 +#define FILE_TABLE_MAX 62000 + +#define LOCK_TABLE_MIN 1 +#define LOCK_TABLE_MAX 3800 + + /* Valid values for openmode: */ +#define OPEN_READ_ONLY 0 +#define OPEN_WRITE_ONLY 1 +#define OPEN_READ_WRITE 2 + + /* Valid values for sharemode: */ +#define SHARE_COMPAT 0 +#define SHARE_DENY_ALL 1 +#define SHARE_DENY_WRITE 2 +#define SHARE_DENY_READ 3 +#define SHARE_DENY_NONE 4 + + /* Register structure for an interrupt function. */ +typedef struct { + unsigned bp; + unsigned di; + unsigned si; + unsigned ds; + unsigned es; + unsigned dx; + unsigned cx; + unsigned bx; + unsigned ax; + unsigned ip; + unsigned cs; + unsigned flags; +} intregs_t; + + /* This table determines the action to take when attempting to open + a file. The first array index is the sharing mode of a previous + open on the same file. The second array index is the sharing mode + of the current open attempt on the same file. Action codes are + defined as follows: + 0 = open may proceed + 1 = open fails with error code 05h + 2 = open fails and an INT 24h is generated + 3 = open proceeds if the file is read-only; otherwise fails + with error code (used only in exception table below) + 4 = open proceeds if the file is read-only; otherwise fails + with INT 24H (used only in exception table below) + Exceptions to the rules are handled in the table + below, so this table only covers the general rules. + */ +static unsigned char open_actions[5][5] = { + { 0, 1, 1, 1, 1 }, + { 2, 1, 1, 1, 1 }, + { 2, 1, 1, 1, 1 }, + { 2, 1, 1, 1, 1 }, + { 2, 1, 1, 1, 0 }, +}; + +typedef struct { + unsigned char first_sharemode; + unsigned char first_openmode; + unsigned char current_sharemode; + unsigned char current_openmode; + unsigned char action; +} open_action_exception_t; + +static open_action_exception_t open_exceptions[] = { + { 0, 0, 2, 0, 3 }, + { 2, 0, 0, 0, 4 }, + { 2, 0, 2, 0, 0 }, + { 2, 0, 4, 0, 0 }, + { 3, 0, 2, 1, 0 }, + { 3, 0, 4, 1, 0 }, + { 3, 1, 4, 1, 0 }, + { 3, 2, 4, 1, 0 }, + { 4, 0, 0, 0, 4 }, + { 4, 0, 2, 0, 0 }, + { 4, 0, 2, 1, 0 }, + { 4, 0, 2, 2, 0 }, + { 4, 1, 3, 0, 0 }, + { 4, 1, 3, 1, 0 }, + { 4, 1, 3, 2, 0 }, +}; + + /* One of these exists for each instance of an open file. */ +typedef struct { + char filename[128]; /* fully-qualified filename; "\0" if unused */ + unsigned short psp; /* PSP of process which opened this file */ + unsigned char openmode; /* 0=read-only, 1=write-only, 2=read-write */ + unsigned char sharemode;/* SHARE_COMPAT, etc... */ + unsigned char first_openmode; /* openmode of first open */ + unsigned char first_sharemode; /* sharemode of first open */ +} file_t; + + /* One of these exists for each active lock region. */ +typedef struct { + unsigned char used; /* Non-zero if this entry is used. */ + unsigned long start; /* Beginning offset of locked region */ + unsigned long end; /* Ending offset of locked region */ + unsigned short fileno; /* file_table entry number */ + unsigned short psp; /* PSP of process which owns the lock */ +} lock_t; + +static char progname[9]; +static unsigned int file_table_size_bytes = 2048; +static unsigned int file_table_size = 0; /* # of file_t we can have */ +static file_t *file_table = NULL; +static unsigned int lock_table_size = 20; /* # of lock_t we can have */ +static lock_t *lock_table = NULL; + + /* DOS calls this to see if it's okay to open the file. + Returns a file_table entry number to use (>= 0) if okay + to open. Otherwise returns < 0 and may generate a critical + error. If < 0 is returned, it is the negated error return + code, so DOS simply negates this value and returns it in + AX. */ +static int open_check + (char far *filename,/* far pointer to fully qualified filename */ + unsigned short psp,/* psp segment address of owner process */ + int openmode, /* 0=read-only, 1=write-only, 2=read-write */ + int sharemode); /* SHARE_COMPAT, etc... */ + + /* DOS calls this to record the fact that it has successfully + closed a file, or the fact that the open for this file failed. */ +static void close_file + (int fileno); /* file_table entry number */ + + /* DOS calls this to determine whether it can access (read or + write) a specific section of a file. We call it internally + from lock_unlock (only when locking) to see if any portion + of the requested region is already locked. If psp is zero, + then it matches any psp in the lock table. Otherwise, only + locks which DO NOT belong to psp will be considered. + Returns zero if okay to access or lock (no portion of the + region is already locked). Otherwise returns non-zero and + generates a critical error (if allowcriter is non-zero). + If non-zero is returned, it is the negated return value for + the DOS call. */ +static int access_check + (unsigned short psp,/* psp segment address of owner process */ + int fileno, /* file_table entry number */ + unsigned long ofs, /* offset into file */ + unsigned long len, /* length (in bytes) of region to access */ + int allowcriter); /* allow a critical error to be generated */ + + /* DOS calls this to lock or unlock a specific section of a file. + Returns zero if successfully locked or unlocked. Otherwise + returns non-zero. + If the return value is non-zero, it is the negated error + return code for the DOS 0x5c call. */ +static int lock_unlock + (unsigned short psp,/* psp segment address of owner process */ + int fileno, /* file_table entry number */ + unsigned long ofs, /* offset into file */ + unsigned long len, /* length (in bytes) of region to lock or unlock */ + int unlock); /* non-zero to unlock; zero to lock */ + + /* Multiplex interrupt handler */ + +static void interrupt far (*old_handler2f)() = NULL; + +static void interrupt far handler2f(intregs_t iregs) { + +#define chain_old_handler2f { \ + _BX = iregs.bx; /* Restore BX */ \ + _CX = iregs.ax; /* Save original AX contents into CX */ \ + iregs.ax = FP_SEG((void far *)old_handler2f); /* Set chain segment */ \ + iregs.bx = FP_OFF((void far *)old_handler2f); /* Set chain offset */ \ + _AX = _CX; /* Restore AX */ \ + __emit__(0x5D); /* POP BP */ \ + __emit__(0x5F); /* POP DI */ \ + __emit__(0x5E); /* POP SI */ \ + __emit__(0x1F); /* POP DS */ \ + __emit__(0x07); /* POP ES */ \ + __emit__(0x5A); /* POP DX */ \ + __emit__(0x59); /* POP CX */ \ + __emit__(0xCB); /* RETF */ \ +} + + if (((iregs.ax >> 8) & 0xff) == MULTIPLEX_ID) { + if ((iregs.ax & 0xff) == 0) { + /* Installation check. Return 0xff in AL. */ + iregs.ax |= 0xff; + return; + } + /* These subfuctions are nonstandard, but are highly + unlikely to be used by another multiplex TSR, since + our multiplex Id (0x10) is basically reserved for + SHARE. So we should be able to get away with using + these for our own purposes. */ + /* open_check */ + if ((iregs.ax & 0xff) == 0xa0) { + iregs.ax = open_check + (MK_FP(iregs.ds, iregs.si), + iregs.bx, + iregs.cx, + iregs.dx); + return; + } + /* close_file */ + if ((iregs.ax & 0xff) == 0xa1) { + close_file(iregs.bx); + return; + } + /* access_check (0xa2) */ + /* access_check with critical error (0xa3) */ + if ((iregs.ax & 0xfe) == 0xa2) { + iregs.ax = access_check + (iregs.bx, + iregs.cx, + ( ((((unsigned long)iregs.si)<<16) & 0xffff0000L) | + (((unsigned long)iregs.di) & 0xffffL) ), + ( ((((unsigned long)iregs.es)<<16) & 0xffff0000L) | + (((unsigned long)iregs.dx) & 0xffffL) ), + (iregs.ax & 0x01)); + return; + } + /* lock_unlock lock (0xa4)*/ + /* lock_unlock unlock (0xa5) */ + if ((iregs.ax & 0xfe) == 0xa4) { + iregs.ax = lock_unlock + (iregs.bx, + iregs.cx, + ( ((((unsigned long)iregs.si)<<16) & 0xffff0000L) | + (((unsigned long)iregs.di) & 0xffffL) ), + ( ((((unsigned long)iregs.es)<<16) & 0xffff0000L) | + (((unsigned long)iregs.dx) & 0xffffL) ), + (iregs.ax & 0x01)); + return; + } + } + /* Chain to the next handler. */ + chain_old_handler2f; +} + +static void remove_all_locks(int fileno) { + int i; + lock_t *lptr; + + for (i = 0; i < lock_table_size; i++) { + lptr = &lock_table[i]; + if (lptr->fileno == fileno) lptr->used = 0; + } +} + +static void free_file_table_entry(int fileno) { + file_table[fileno].filename[0] = '\0'; +} + +static int file_is_read_only(char far *filename) { + union REGS regs; + struct SREGS sregs; + + regs.x.ax = 0x4300; + sregs.ds = FP_SEG(filename); + regs.x.dx = FP_OFF(filename); + intdosx(®s, ®s, &sregs); + if (regs.x.cflag) return 0; + return ((regs.h.cl & 0x19) == 0x01); +} + +static int fnmatches(char far *fn1, char far *fn2) { + while (*fn1) { + if (*fn1 != *fn2) return 0; + fn1++; + fn2++; + } + return (*fn1 == *fn2); +} + +static int do_open_check + (int fileno) { /* file_table entry number */ + file_t *p, *fptr = &file_table[fileno]; + int i, j, action = 0, foundexc; + unsigned char current_sharemode = fptr->sharemode; + unsigned char current_openmode = fptr->openmode; + open_action_exception_t *excptr; + + fptr->first_sharemode = fptr->sharemode; + fptr->first_openmode = fptr->openmode; + for (i = 0; i < file_table_size; i++) { + if (i == fileno) continue; + p = &file_table[i]; + if (p->filename[0] == '\0') continue; + if (!fnmatches(p->filename, fptr->filename)) continue; + fptr->first_sharemode = p->first_sharemode; + fptr->first_openmode = p->first_openmode; + /* Look for exceptions to the general rules first. */ + foundexc = 0; + for (j = 0; + j < (sizeof(open_exceptions)/sizeof(open_action_exception_t)); + j++) { + excptr = &open_exceptions[j]; + if ( (excptr->first_sharemode == fptr->first_sharemode) + && (excptr->current_sharemode == current_sharemode) + && (excptr->first_openmode == fptr->first_openmode) + && (excptr->current_openmode == current_openmode) ) { + foundexc = 1; + action = excptr->action; + break; + } + } + /* If no exception to rules, use normal rules. */ + if (!foundexc) + action = open_actions[fptr->first_sharemode][current_sharemode]; + /* Fail appropriately based on action. */ + switch (action) { + case 0: /* proceed with open */ + break; + case 3: /* succeed if file read-only, else fail with error 05h */ + if (file_is_read_only(fptr->filename)) break; + case 1: /* fail with error code 05h */ + free_file_table_entry(fileno); + return -5; + case 4: /* succeed if file read-only, else fail with int 24h */ + if (file_is_read_only(fptr->filename)) break; + case 2: /* fail with int 24h */ + { + union REGS regs; + + regs.h.ah = 0x0e; /* disk I/O; fail allowed; data area */ + regs.h.al = 0; + regs.x.di = 0x0d; /* sharing violation */ + if ( (fptr->filename[0]!='\0') && (fptr->filename[1]==':') ) + regs.h.al = fptr->filename[0]-'A'; + free_file_table_entry(fileno); + int86(0x24, ®s, ®s); + } + return -0x20; /* sharing violation */ + } + break; + } + return fileno; +} + + /* DOS calls this to see if it's okay to open the file. + Returns a file_table entry number to use (>= 0) if okay + to open. Otherwise returns < 0 and may generate a critical + error. If < 0 is returned, it is the negated error return + code, so DOS simply negates this value and returns it in + AX. */ +static int open_check + (char far *filename,/* far pointer to fully qualified filename */ + unsigned short psp,/* psp segment address of owner process */ + int openmode, /* 0=read-only, 1=write-only, 2=read-write */ + int sharemode) { /* SHARE_COMPAT, etc... */ + + int i, fileno = -1; + file_t *fptr; + + /* Whack off unused bits in the share mode + in case we were careless elsewhere. */ + sharemode &= 0x07; + + /* Assume compatibility mode if invalid share mode. */ +/* ??? IS THIS CORRECT ??? */ + if ( (sharemode < SHARE_COMPAT) || (sharemode > SHARE_DENY_NONE) ) + sharemode = SHARE_COMPAT; + + /* Whack off unused bits in the open mode + in case we were careless elsewhere. */ + openmode &= 0x03; + + /* Assume read-only mode if invalid open mode. */ +/* ??? IS THIS CORRECT ??? */ + if ( (openmode < OPEN_READ_ONLY) || (openmode > OPEN_READ_WRITE) ) + openmode = OPEN_READ_ONLY; + + for (i = 0; i < file_table_size; i++) { + if (file_table[i].filename[0] == '\0') { + fileno = i; + break; + } + } + if (fileno == -1) return -1; + fptr = &file_table[fileno]; + + /* Copy the filename into ftpr->filename. */ + for (i = 0; i < sizeof(fptr->filename); i++) { + if ((fptr->filename[i] = filename[i]) == '\0') break; + } + fptr->psp = psp; + fptr->openmode = (unsigned char)openmode; + fptr->sharemode = (unsigned char)sharemode; + /* Do the sharing check and return fileno if + okay, or < 0 (and free the entry) if error. */ + return do_open_check(fileno); +} + + /* DOS calls this to record the fact that it has successfully + closed a file, or the fact that the open for this file failed. */ +static void close_file + (int fileno) { /* file_table entry number */ + + remove_all_locks(fileno); + free_file_table_entry(fileno); +} + + /* DOS calls this to determine whether it can access (read or + write) a specific section of a file. We call it internally + from lock_unlock (only when locking) to see if any portion + of the requested region is already locked. If psp is zero, + then it matches any psp in the lock table. Otherwise, only + locks which DO NOT belong to psp will be considered. + Returns zero if okay to access or lock (no portion of the + region is already locked). Otherwise returns non-zero and + generates a critical error (if allowcriter is non-zero). + If non-zero is returned, it is the negated return value for + the DOS call. */ +static int access_check + (unsigned short psp,/* psp segment address of owner process */ + int fileno, /* file_table entry number */ + unsigned long ofs, /* offset into file */ + unsigned long len, /* length (in bytes) of region to access */ + int allowcriter) { /* allow a critical error to be generated */ + int i; + file_t *fptr = &file_table[fileno]; + char far *filename = fptr->filename; + lock_t *lptr; + unsigned long endofs = ofs + len; + + if (endofs < ofs) { + endofs = 0xffffffffL; + len = endofs-ofs; + } + + if (len < 1L) return 0; + + for (i = 0; i < lock_table_size; i++) { + lptr = &lock_table[i]; + if ( (lptr->used) + && ( (psp == 0) || (lptr->psp != psp) ) + && (fnmatches(filename, file_table[lptr->fileno].filename)) + && ( ( (ofs>=lptr->start) && (ofsend) ) + || ( (endofs>lptr->start) && (endofs<=lptr->end) ) ) ) { + if (allowcriter) { + union REGS regs; + + regs.h.ah = 0x0e; /* disk I/O; fail allowed; data area */ + regs.h.al = 0; + regs.x.di = 0x0e; /* lock violation */ + if ( (fptr->filename[0]!='\0') && (fptr->filename[1]==':') ) + regs.h.al = fptr->filename[0]-'A'; + free_file_table_entry(fileno); + int86(0x24, ®s, ®s); + } + return -0x21; /* lock violation */ + } + } + return 0; +} + + /* DOS calls this to lock or unlock a specific section of a file. + Returns zero if successfully locked or unlocked. Otherwise + returns non-zero. + If the return value is non-zero, it is the negated error + return code for the DOS 0x5c call. */ +static int lock_unlock + (unsigned short psp,/* psp segment address of owner process */ + int fileno, /* file_table entry number */ + unsigned long ofs, /* offset into file */ + unsigned long len, /* length (in bytes) of region to lock or unlock */ + int unlock) { /* non-zero to unlock; zero to lock */ + + int i; + lock_t *lptr; + unsigned long endofs = ofs + len; + + if (endofs < ofs) { + endofs = 0xffffffffL; + len = endofs-ofs; + } + + if (len < 1L) return 0; + + if (unlock) { + for (i = 0; i < lock_table_size; i++) { + lptr = &lock_table[i]; + if ( (lptr->used) + && (lptr->psp == psp) + && (lptr->fileno == fileno) + && (lptr->start == ofs) + && (lptr->end == endofs) ) { + lptr->used = 0; + return 0; + } + /* Not already locked by us; can't unlock. */ + return -(0x21); /* lock violation */ + } + return -(0x24); /* sharing buffer overflow */ + } else { + if (access_check(0, fileno, ofs, len, 0)) { + /* Already locked; can't lock. */ + return -(0x21); /* lock violation */ + } + for (i = 0; i < lock_table_size; i++) { + lptr = &lock_table[i]; + if (!lptr->used) { + lptr->used = 1; + lptr->start = ofs; + lptr->end = ofs+(unsigned long)len; + lptr->fileno = fileno; + lptr->psp = psp; + return 0; + } + } + return -(0x24); /* sharing buffer overflow */ + } +} + + /* Allocate tables and install hooks into the kernel. + If we run out of memory, return non-zero. */ +static int init(void) { + int i; + + file_table_size = file_table_size_bytes/sizeof(file_t); + if ((file_table=malloc(file_table_size_bytes)) == NULL) return 1; + memset(file_table, 0, file_table_size_bytes); + if ((lock_table=malloc(lock_table_size*sizeof(lock_t))) == NULL) return 1; + memset(lock_table, 0, lock_table_size*sizeof(lock_t)); + return 0; +} + +static void usage(void) { + fprintf + (stderr, + "Installs file-sharing and locking " + "capabilities on your hard disk.\n\n" + "%s [/F:space] [/L:locks]\n\n" + " /F:space Allocates file space (in bytes) " + "for file-sharing information.\n" + " /L:locks Sets the number of files that can " + "be locked at one time.\n", + progname); +} + +static void bad_params(void) { + fprintf(stderr,"%s: parameter out of range!\n",progname); +} + +static void out_of_memory(void) { + fprintf(stderr,"%s: out of memory!\n",progname); +} + +int main(int argc, char **argv) { + unsigned short far *usfptr; + unsigned char far *uscptr; + unsigned short top_of_tsr; + int installed = 0; + int i; + + /* Extract program name from argv[0] into progname. */ + if (argv[0] != NULL) { + char *p = argv[0], *p2, c; + int i; + if ( (p[0] != '\0') && (p[1] == ':') ) p += 2; + while ((p2 = strchr(p, '\\')) != NULL) p = p2+1; + p2 = progname; + for (i = 0; i < 8; i++) { + c = p[i]; + if ( (c == '.') || (c == '\0') ) break; + *(p2++) = c; + } + *p2 = '\0'; + } + + /* See if the TSR is already installed. */ + disable(); + if (getvect(MUX_INT_NO) != NULL) { + union REGS regs; + enable(); + regs.h.ah = MULTIPLEX_ID; + regs.h.al = 0; + int86(MUX_INT_NO,®s,®s); + installed = ((regs.x.ax & 0xff) == 0xff); + + } else { + enable(); + } + + /* Process command line arguments. Bail if errors. */ + for (i = 1; i < argc; i++) { + char *arg = argv[i]; + if (arg == NULL) continue; + if (arg[0] != '/') { + usage(); + return 3; + } + arg++; + switch(*arg) { + case '?': + usage(); + return 3; + case 'f': + case 'F': + arg++; + if (*arg != ':') { + usage(); + return 3; + } + arg++; + { + long temp = atol(arg); + if ( (temp < (long)FILE_TABLE_MIN) + || (temp > (long)FILE_TABLE_MAX) ) { + bad_params(); + return 3; + } + file_table_size_bytes = (unsigned int)temp; + } + break; + case 'l': + case 'L': + arg++; + if (*arg != ':') { + usage(); + return 3; + } + arg++; + lock_table_size = atoi(arg); + if ( (lock_table_size < LOCK_TABLE_MIN) + || (lock_table_size > LOCK_TABLE_MAX) ) { + bad_params(); + return 3; + } + break; + } + } + + /* Now try to install. */ + + if (installed) { + fprintf(stderr,"%s is already installed!\n",progname); + return 1; + } + + if (init() != 0) { + out_of_memory(); + return 2; + } + + /* Allocate a single byte. This tells us the size of the TSR. + Free the byte when we know the address. */ + uscptr = (unsigned char far *)malloc(1); + if (uscptr == NULL) { + out_of_memory(); + return 2; + } + top_of_tsr = (FP_SEG(uscptr)+((FP_OFF(uscptr)+15) >> 4)) - _psp; + free((void *)uscptr); + + + /* Hook the interrupt for the handler routine. */ + disable(); + old_handler2f = getvect(MUX_INT_NO); + setvect(MUX_INT_NO,handler2f); + enable(); + + /* Let them know we're installed. */ + fprintf(stdout,"%s installed.\n",progname); + + /* Any access to environment variables must */ + /* be done prior to this point. Here we */ + /* free the environment table to prevent */ + /* wasting that memory. In fact, if the */ + /* TSR were removed from memory and we did */ + /* not do this, we would not be able to */ + /* recover this memory. */ + + FP_SEG(usfptr) = _psp; + FP_OFF(usfptr) = 0x2c; + freemem(*usfptr); + + /* Free the remainder of memory for use by applications. */ + setblock(_psp,top_of_tsr); + + /* Terminate and stay resident. */ + keep(0,top_of_tsr); + return 0; +} + From 92bb87ffafc7be54a225121ec8b6caf59325823f Mon Sep 17 00:00:00 2001 From: Kenneth J Davis Date: Fri, 16 Dec 2005 09:39:43 +0000 Subject: [PATCH 657/671] changes from Eric to reduce TSR footprint and fixes from Michael Devore git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/branches/UNSTABLE@1169 6ac86273-5f31-0410-b378-82cca8765d1b --- share/share.c | 128 ++++++++++++++++++++++++++++++++++---------------- 1 file changed, 88 insertions(+), 40 deletions(-) diff --git a/share/share.c b/share/share.c index fde6849a..0f871054 100644 --- a/share/share.c +++ b/share/share.c @@ -5,22 +5,28 @@ If not, see www.gnu.org for details. Read it, learn it, BE IT. :-) */ -#include -#include -#include -#include -#include -#include +/* #include */ /* (fprintf removed...) */ +/* #include */ /* Not used, using defines below... */ +#include /* write (what else?) */ +#include /* _psp, NULL, malloc, free, atol, atoi */ +#include /* MK_FP, FP_OFF, FP_SEG, int86, intdosx, */ + /* freemem, keep */ +#include /* strchr, strlen, memset */ #ifndef __TURBOC__ #error "This software must be compiled with TurboC or TurboC++." #endif +/* Changed by Eric Auer 5/2004: Squeezing executable size a bit -> */ +/* Replaced fprint(stderr or stdout,...) by write(hand, buf, size) */ +/* Keeps stream stuff and printf stuff outside the file and TSR... */ + + /* ------------- DEFINES ------------- */ #define MUX_INT_NO 0x2f #define MULTIPLEX_ID 0x10 #define FILE_TABLE_MIN 128 -#define FILE_TABLE_MAX 62000 +#define FILE_TABLE_MAX 62000U #define LOCK_TABLE_MIN 1 #define LOCK_TABLE_MAX 3800 @@ -37,6 +43,7 @@ #define SHARE_DENY_READ 3 #define SHARE_DENY_NONE 4 + /* ------------- TYPEDEFS ------------- */ /* Register structure for an interrupt function. */ typedef struct { unsigned bp; @@ -86,6 +93,7 @@ typedef struct { static open_action_exception_t open_exceptions[] = { { 0, 0, 2, 0, 3 }, + { 0, 0, 4, 0, 3 }, /* compatibility-read/deny none-read, MED 08/2004 */ { 2, 0, 0, 0, 4 }, { 2, 0, 2, 0, 0 }, { 2, 0, 4, 0, 0 }, @@ -94,6 +102,8 @@ static open_action_exception_t open_exceptions[] = { { 3, 1, 4, 1, 0 }, { 3, 2, 4, 1, 0 }, { 4, 0, 0, 0, 4 }, + { 4, 0, 0, 1, 0 }, /* deny none-read/compatibility-write */ + { 4, 0, 0, 2, 0 }, /* deny none-read/compatibility-read+write */ { 4, 0, 2, 0, 0 }, { 4, 0, 2, 1, 0 }, { 4, 0, 2, 2, 0 }, @@ -121,6 +131,8 @@ typedef struct { unsigned short psp; /* PSP of process which owns the lock */ } lock_t; + + /* ------------- GLOBALS ------------- */ static char progname[9]; static unsigned int file_table_size_bytes = 2048; static unsigned int file_table_size = 0; /* # of file_t we can have */ @@ -128,6 +140,18 @@ static file_t *file_table = NULL; static unsigned int lock_table_size = 20; /* # of lock_t we can have */ static lock_t *lock_table = NULL; + + /* ------------- PROTOTYPES ------------- */ +/* PRINT added by Eric */ +#define ERR 2 /* handle of stderr */ +#define OUT 1 /* handle of stdout */ +static void PRINT(int handle, char * text); +static void PRINT(int handle, char * text) { + (void)write (handle, text, strlen(text)); + /* return value is -1 error or N bytes_written. Ignored. */ +}; + + /* DOS calls this to see if it's okay to open the file. Returns a file_table entry number to use (>= 0) if okay to open. Otherwise returns < 0 and may generate a critical @@ -179,6 +203,8 @@ static int lock_unlock static void interrupt far (*old_handler2f)() = NULL; + + /* ------------- HOOK ------------- */ static void interrupt far handler2f(intregs_t iregs) { #define chain_old_handler2f { \ @@ -195,7 +221,9 @@ static void interrupt far handler2f(intregs_t iregs) { __emit__(0x5A); /* POP DX */ \ __emit__(0x59); /* POP CX */ \ __emit__(0xCB); /* RETF */ \ -} +} /* This evil trick probably only works with Turbo C!?! */ + /* would have been better to link a NASM handler core: */ + /* nasm -fobj -o foo.obj foo.asm ... */ if (((iregs.ax >> 8) & 0xff) == MULTIPLEX_ID) { if ((iregs.ax & 0xff) == 0) { @@ -267,6 +295,8 @@ static void free_file_table_entry(int fileno) { file_table[fileno].filename[0] = '\0'; } +/* DOS 7 does not have read-only restrictions, MED 08/2004 */ +/* static int file_is_read_only(char far *filename) { union REGS regs; struct SREGS sregs; @@ -278,6 +308,7 @@ static int file_is_read_only(char far *filename) { if (regs.x.cflag) return 0; return ((regs.h.cl & 0x19) == 0x01); } +*/ static int fnmatches(char far *fn1, char far *fn2) { while (*fn1) { @@ -325,15 +356,20 @@ static int do_open_check action = open_actions[fptr->first_sharemode][current_sharemode]; /* Fail appropriately based on action. */ switch (action) { + +/* DOS 7 does not have read-only restrictions, fall through to proceed, MED 08/2004 */ + case 3: + case 4: + case 0: /* proceed with open */ break; - case 3: /* succeed if file read-only, else fail with error 05h */ - if (file_is_read_only(fptr->filename)) break; +/* case 3: */ /* succeed if file read-only, else fail with error 05h */ +/* if (file_is_read_only(fptr->filename)) break; */ case 1: /* fail with error code 05h */ free_file_table_entry(fileno); return -5; - case 4: /* succeed if file read-only, else fail with int 24h */ - if (file_is_read_only(fptr->filename)) break; +/* case 4: */ /* succeed if file read-only, else fail with int 24h */ +/* if (file_is_read_only(fptr->filename)) break; */ case 2: /* fail with int 24h */ { union REGS regs; @@ -528,40 +564,45 @@ static int lock_unlock } } + /* ------------- INIT ------------- */ /* Allocate tables and install hooks into the kernel. If we run out of memory, return non-zero. */ static int init(void) { - int i; + /* int i; */ file_table_size = file_table_size_bytes/sizeof(file_t); - if ((file_table=malloc(file_table_size_bytes)) == NULL) return 1; + if ((file_table=malloc(file_table_size_bytes)) == NULL) + return 1; memset(file_table, 0, file_table_size_bytes); - if ((lock_table=malloc(lock_table_size*sizeof(lock_t))) == NULL) return 1; + if ((lock_table=malloc(lock_table_size*sizeof(lock_t))) == NULL) + return 1; memset(lock_table, 0, lock_table_size*sizeof(lock_t)); return 0; } static void usage(void) { - fprintf - (stderr, + PRINT(ERR, "Installs file-sharing and locking " - "capabilities on your hard disk.\n\n" - "%s [/F:space] [/L:locks]\n\n" + "capabilities on your hard disk.\r\n\r\n"); + PRINT(ERR, progname); + PRINT(ERR, " [/F:space] [/L:locks]\r\n\r\n" " /F:space Allocates file space (in bytes) " - "for file-sharing information.\n" + "for file-sharing information.\r\n" " /L:locks Sets the number of files that can " - "be locked at one time.\n", - progname); + "be locked at one time.\r\n"); } static void bad_params(void) { - fprintf(stderr,"%s: parameter out of range!\n",progname); + PRINT(ERR, progname); + PRINT(ERR, ": parameter out of range!\r\n"); } static void out_of_memory(void) { - fprintf(stderr,"%s: out of memory!\n",progname); + PRINT(ERR, progname); + PRINT(ERR,": out of memory!\r\n"); } + /* ------------- MAIN ------------- */ int main(int argc, char **argv) { unsigned short far *usfptr; unsigned char far *uscptr; @@ -573,30 +614,31 @@ int main(int argc, char **argv) { if (argv[0] != NULL) { char *p = argv[0], *p2, c; int i; - if ( (p[0] != '\0') && (p[1] == ':') ) p += 2; - while ((p2 = strchr(p, '\\')) != NULL) p = p2+1; + if ( (p[0] != '\0') && (p[1] == ':') ) + p += 2; + while ((p2 = strchr(p, '\\')) != NULL) + p = p2+1; p2 = progname; for (i = 0; i < 8; i++) { c = p[i]; - if ( (c == '.') || (c == '\0') ) break; + if ( (c == '.') || (c == '\0') ) + break; *(p2++) = c; } *p2 = '\0'; } /* See if the TSR is already installed. */ - disable(); + /* disable(); */ /* no multitasking, so don't worry */ if (getvect(MUX_INT_NO) != NULL) { union REGS regs; - enable(); + /* enable(); */ regs.h.ah = MULTIPLEX_ID; regs.h.al = 0; int86(MUX_INT_NO,®s,®s); installed = ((regs.x.ax & 0xff) == 0xff); - } else { - enable(); - } + } /* else { enable(); } */ /* Process command line arguments. Bail if errors. */ for (i = 1; i < argc; i++) { @@ -650,7 +692,8 @@ int main(int argc, char **argv) { /* Now try to install. */ if (installed) { - fprintf(stderr,"%s is already installed!\n",progname); + PRINT(ERR, progname); + PRINT(ERR, " is already installed!\r\n"); return 1; } @@ -667,17 +710,19 @@ int main(int argc, char **argv) { return 2; } top_of_tsr = (FP_SEG(uscptr)+((FP_OFF(uscptr)+15) >> 4)) - _psp; + /* resident paras, counting from PSP:0 */ free((void *)uscptr); /* Hook the interrupt for the handler routine. */ - disable(); + /* disable(); */ old_handler2f = getvect(MUX_INT_NO); setvect(MUX_INT_NO,handler2f); - enable(); + /* enable(); */ /* Let them know we're installed. */ - fprintf(stdout,"%s installed.\n",progname); + PRINT(OUT, progname); + PRINT(OUT, " installed.\r\n"); /* Any access to environment variables must */ /* be done prior to this point. Here we */ @@ -687,15 +732,18 @@ int main(int argc, char **argv) { /* not do this, we would not be able to */ /* recover this memory. */ - FP_SEG(usfptr) = _psp; - FP_OFF(usfptr) = 0x2c; - freemem(*usfptr); + usfptr = MK_FP(_psp, 0x2c); /* MK_FP is the counterpart */ + /* of FP_OFF and FP_SEG ... */ + freemem(*usfptr); /* deallocate MCB of ENV segment */ +#if 0 /* Free the remainder of memory for use by applications. */ setblock(_psp,top_of_tsr); + /* resize self: already done by keep() */ +#endif /* Terminate and stay resident. */ - keep(0,top_of_tsr); + keep(0,top_of_tsr); /* size is set to top_of_tsr paragraphs */ return 0; } From d442e92e65fa1c61237e4d3a4187d2135fa5e992 Mon Sep 17 00:00:00 2001 From: Kenneth J Davis Date: Fri, 16 Dec 2005 09:44:36 +0000 Subject: [PATCH 658/671] changes from Japheth (HXDOS) git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/branches/UNSTABLE@1170 6ac86273-5f31-0410-b378-82cca8765d1b --- share/share.c | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/share/share.c b/share/share.c index 0f871054..46777d4d 100644 --- a/share/share.c +++ b/share/share.c @@ -255,11 +255,16 @@ static void interrupt far handler2f(intregs_t iregs) { if ((iregs.ax & 0xfe) == 0xa2) { iregs.ax = access_check (iregs.bx, - iregs.cx, + iregs.cx, +#if 0 ( ((((unsigned long)iregs.si)<<16) & 0xffff0000L) | (((unsigned long)iregs.di) & 0xffffL) ), ( ((((unsigned long)iregs.es)<<16) & 0xffff0000L) | - (((unsigned long)iregs.dx) & 0xffffL) ), + (((unsigned long)iregs.dx) & 0xffffL) ), +#else + ( (((unsigned long)iregs.si)<<16) + iregs.di ), + ( (((unsigned long)iregs.es)<<16) + iregs.dx ), +#endif (iregs.ax & 0x01)); return; } @@ -268,11 +273,16 @@ static void interrupt far handler2f(intregs_t iregs) { if ((iregs.ax & 0xfe) == 0xa4) { iregs.ax = lock_unlock (iregs.bx, - iregs.cx, + iregs.cx, +#if 0 ( ((((unsigned long)iregs.si)<<16) & 0xffff0000L) | - (((unsigned long)iregs.di) & 0xffffL) ), + (((unsigned long)iregs.di) & 0xffffL) ), ( ((((unsigned long)iregs.es)<<16) & 0xffff0000L) | - (((unsigned long)iregs.dx) & 0xffffL) ), + (((unsigned long)iregs.dx) & 0xffffL) ), +#else + ( (((unsigned long)iregs.si)<<16) | ((unsigned long)iregs.di) ), + ( (((unsigned long)iregs.es)<<16) | ((unsigned long)iregs.dx) ), +#endif (iregs.ax & 0x01)); return; } @@ -522,13 +532,16 @@ static int lock_unlock lock_t *lptr; unsigned long endofs = ofs + len; - if (endofs < ofs) { + if (endofs < ofs) { endofs = 0xffffffffL; len = endofs-ofs; } if (len < 1L) return 0; + /* there was a error in the code below preventing any other + than the first locked region to be unlocked (japheth, 09/2005) */ + if (unlock) { for (i = 0; i < lock_table_size; i++) { lptr = &lock_table[i]; @@ -540,10 +553,9 @@ static int lock_unlock lptr->used = 0; return 0; } - /* Not already locked by us; can't unlock. */ - return -(0x21); /* lock violation */ } - return -(0x24); /* sharing buffer overflow */ + /* Not already locked by us; can't unlock. */ + return -(0x21); /* lock violation */ } else { if (access_check(0, fileno, ofs, len, 0)) { /* Already locked; can't lock. */ From 5a5d99f614bff2c6a484b97b40fb8848560556ad Mon Sep 17 00:00:00 2001 From: Kenneth J Davis Date: Fri, 16 Dec 2005 09:46:57 +0000 Subject: [PATCH 659/671] basic usage (help file) git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/branches/UNSTABLE@1171 6ac86273-5f31-0410-b378-82cca8765d1b --- share/share.hlp | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 share/share.hlp diff --git a/share/share.hlp b/share/share.hlp new file mode 100644 index 00000000..dbb7a1eb --- /dev/null +++ b/share/share.hlp @@ -0,0 +1,6 @@ +Installs file-sharing and locking capabilities on your hard disk. + +SHARE [/F:space] [/L:locks] + + /F:space Allocates file space (in bytes) for file-sharing information. + /L:locks Sets the number of files that can be locked at one time. From 439e5f37ddbca321e3fcfb5d5f91e9f691dd7ff8 Mon Sep 17 00:00:00 2001 From: Kenneth J Davis Date: Sat, 24 Dec 2005 09:17:02 +0000 Subject: [PATCH 660/671] correct email address git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/branches/UNSTABLE@1173 6ac86273-5f31-0410-b378-82cca8765d1b --- docs/contrib.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/contrib.txt b/docs/contrib.txt index 739b7a5a..7b9a0be6 100644 --- a/docs/contrib.txt +++ b/docs/contrib.txt @@ -10,7 +10,7 @@ Bart Oldeman (bart@dosemu.org) Bernd Blaauw (bblaauw@home.nl) Brian Reifsnyder (reifsnyderb@mindspring.com) Charles Dye (raster@highfiber.com) -Eduardo Casino (eduardo@terra.es) +Eduardo Casino (casino_e@terra.es) Eric Auer (eric@coli.uni-sb.de) Eric Biederman (ebiederm+eric@ccr.net) Eric Luttmann (ecl@users.sourceforge.net) From ce790904ac2c382f82473270fa331177e6004fac Mon Sep 17 00:00:00 2001 From: Kenneth J Davis Date: Sat, 18 Feb 2006 15:14:57 +0000 Subject: [PATCH 661/671] add option to ease building with extra WIN3.x compatibility stuff git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/branches/UNSTABLE@1174 6ac86273-5f31-0410-b378-82cca8765d1b --- build.bat | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/build.bat b/build.bat index d9bd41f5..5d75ef5d 100644 --- a/build.bat +++ b/build.bat @@ -6,7 +6,7 @@ if NOT "%1" == "/?" goto start echo ":-----------------------------------------------------------------------" echo ":- Syntax: BUILD [-r] [fat32|fat16] [msc|wc|tc|tcpp|bc] [86|186|386] " -echo ":- [debug] [lfnapi] [/L #] [/D value] [list] [upx] " +echo ":- [debug] [lfnapi] [/L #] [/D value] [list] [upx] [win] " echo ":- option case is significant !! " echo ":- Note: Open Watcom (wc) is the preferred compiler " echo ":-----------------------------------------------------------------------" @@ -52,6 +52,9 @@ if "%1" == "upx" set XUPX=upx --8086 --best if "%1" == "debug" set ALLCFLAGS=%ALLCFLAGS% -DDEBUG if "%1" == "lfnapi" set ALLCFLAGS=%ALLCFLAGS% -DWITHLFNAPI +if "%1" == "win" set ALLCFLAGS=%ALLCFLAGS% -DWIN31SUPPORT +if "%1" == "win" set NASMFLAGS=%NASMFLAGS% -DWIN31SUPPORT + if "%1" == "list" set NASMFLAGS=%NASMFLAGS% -l$*.lst if "%1" == "/L" goto setLoadSeg @@ -71,6 +74,8 @@ if "%LAST%" == "" goto noenv :- finally - we are going to compile :----------------------------------------------------------------------- +echo USING OPTIONS of C=[%ALLCFLAGS%] ASM=[%NASMFLAGS%] + echo. echo Process UTILS ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ echo. From 4956d6369c5cac62bf79a7338ddfe2217942f4bd Mon Sep 17 00:00:00 2001 From: Kenneth J Davis Date: Sat, 18 Feb 2006 15:16:39 +0000 Subject: [PATCH 662/671] update URL of bug entry or search site git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/branches/UNSTABLE@1175 6ac86273-5f31-0410-b378-82cca8765d1b --- docs/bugs.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/bugs.txt b/docs/bugs.txt index 62693842..d6e71e18 100644 --- a/docs/bugs.txt +++ b/docs/bugs.txt @@ -1,6 +1,6 @@ The current bug database is available on the web at - http://www.freedos.org/bugs/ + http://www.freedos.org/freedos/bugs/ Thanks! From 87dc4b08d5f082896b879443a5675453294e8f38 Mon Sep 17 00:00:00 2001 From: Kenneth J Davis Date: Sat, 18 Feb 2006 15:19:46 +0000 Subject: [PATCH 663/671] slight cleanup, aid in debug prints going to COM port git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/branches/UNSTABLE@1176 6ac86273-5f31-0410-b378-82cca8765d1b --- hdr/debug.h | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/hdr/debug.h b/hdr/debug.h index e379763e..ae05d67c 100644 --- a/hdr/debug.h +++ b/hdr/debug.h @@ -46,7 +46,11 @@ /* use to limit output to debug builds */ #ifdef DEBUG +#ifdef DEBUG_PRINT_COMPORT +#define DebugPrintf(x) dbgc_printf x +#else #define DebugPrintf(x) printf x +#endif #else #define DebugPrintf(x) #endif @@ -63,7 +67,7 @@ /* show output related to moving kernel into HMA */ #ifdef DEBUG -#define HMAInitPrintf(x) printf x +#define HMAInitPrintf(x) DebugPrintf(x) #else #define HMAInitPrintf(x) #endif @@ -71,7 +75,7 @@ /* display output during kernel config processing phase */ /* #define DEBUGCFG */ #ifdef DEBUGCFG -#define CfgDbgPrintf(x) printf x +#define CfgDbgPrintf(x) DebugPrintf(x) #else #define CfgDbgPrintf(x) #endif @@ -79,7 +83,7 @@ /* display info on various DOS functions (dosfns.c) */ /* #define DEBUGDOSFNS */ #ifdef DEBUGDOSFNS -#define DFnsDbgPrintf(x) printf x +#define DFnsDbgPrintf(x) DebugPrintf(x) #else #define DFnsDbgPrintf(x) #endif @@ -93,7 +97,7 @@ /* display info on various DOS directory functions (fatdir.c) */ /* #define DEBUGFATDIR */ #ifdef DEBUGFATDIR -#define FDirDbgPrintf(x) printf x +#define FDirDbgPrintf(x) DebugPrintf(x) #else #define FDirDbgPrintf(x) #endif @@ -107,7 +111,7 @@ /* display info on various FAT handling functions (fatfs.c) */ /* #define DEBUGFATFS */ #ifdef DEBUGFATFS -#define FatFSDbgPrintf(x) printf x +#define FatFSDbgPrintf(x) DebugPrintf(x) #else #define FatFSDbgPrintf(x) #endif @@ -115,7 +119,7 @@ /* debug truename */ /* #define DEBUG_TRUENAME */ #ifdef DEBUG_TRUENAME -#define tn_printf(x) printf x +#define tn_printf(x) DebugPrintf(x) #else #define tn_printf(x) #endif @@ -131,7 +135,10 @@ #endif #ifdef DEBUG_NEED_PRINTF -VOID VA_CDECL printf(const char FAR * fmt, ...); +VOID VA_CDECL printf(CONST char FAR * fmt, ...); +#ifdef DEBUG_PRINT_COMPORT +VOID VA_CDECL dbgc_printf(CONST char FAR * fmt, ...); +#endif #endif #endif /* __DEBUG_H */ From 1420e23819330b21a791a6b80beb98a685a9c682 Mon Sep 17 00:00:00 2001 From: Kenneth J Davis Date: Sat, 18 Feb 2006 15:23:23 +0000 Subject: [PATCH 664/671] fix read calls to detect error, from Eric Auer (brought to his attention by Brad?) git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/branches/UNSTABLE@1177 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/config.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/kernel/config.c b/kernel/config.c index b385e3e3..bb703385 100644 --- a/kernel/config.c +++ b/kernel/config.c @@ -618,7 +618,8 @@ static void DoConfig_(void) nCfgLine++; for (q = szLine;;) { - if (read(nFileDesc, q, 1) <= 0 || *q == EOF) + /* if EOF already found, error reading, or EOF char read then we're done */ + if (read(nFileDesc, q, 1) != 1 || *q == EOF) { done++; break; @@ -1187,9 +1188,9 @@ STATIC void LoadCountryInfo(PCStr filename, int ccode, int cpage) printf("%s not found\n", filename); return; } - if (read(fd, &header, sizeof(header)) < sizeof(header)) + if (read(fd, &header, sizeof(header)) != sizeof(header)) { - printf("Can't read %s\n", filename); + printf("Error reading %s\n", filename); goto ret; } if (memcmp(header.name, "\377COUNTRY", sizeof(header.name))) @@ -1198,19 +1199,19 @@ err:printf("%s has invalid format\n", filename); goto ret; } if (lseek(fd, header.offset) == 0xffffffffL - || read(fd, &entries, sizeof(entries)) < sizeof(entries)) + || read(fd, &entries, sizeof(entries)) != sizeof(entries)) goto err; for (i = 0; i < entries; i++) { - if (read(fd, &entry, sizeof(entry)) < sizeof(entry) || entry.length != 12) + if (read(fd, &entry, sizeof(entry)) != sizeof(entry) || entry.length != 12) goto err; if (entry.country != ccode || entry.codepage != cpage && cpage) continue; if (lseek(fd, entry.offset) == 0xffffffffL - || read(fd, &count, sizeof(count)) < sizeof(count) + || read(fd, &count, sizeof(count)) != sizeof(count) || count > LENGTH(hdr) || read(fd, &hdr, sizeof(struct subf_hdr) * count) - < sizeof(struct subf_hdr) * count) + != sizeof(struct subf_hdr) * count) goto err; for (i = 0; i < count; i++) { @@ -1219,10 +1220,10 @@ err:printf("%s has invalid format\n", filename); if (hdr[i].id < 1 || hdr[i].id > 6 || hdr[i].id == 3) continue; if (lseek(fd, hdr[i].offset) == 0xffffffffL - || read(fd, &subf_data, 10) < 10 + || read(fd, &subf_data, 10) != 10 || memcmp(subf_data.signature, table[hdr[i].id].sig, 8) && (hdr[i].id !=4 || memcmp(subf_data.signature, table[2].sig, 8)) /* UCASE for FUCASE ^*/ - || read(fd, subf_data.buffer, subf_data.length) < subf_data.length) + || read(fd, subf_data.buffer, subf_data.length) != subf_data.length) goto err; if (hdr[i].id == 1) { From 392fb4148a5ee6a9b7e83470bc056192f03f089e Mon Sep 17 00:00:00 2001 From: Kenneth J Davis Date: Sat, 18 Feb 2006 15:52:19 +0000 Subject: [PATCH 665/671] conditionally compile so debug output sent to COM port (2nd computer) git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/branches/UNSTABLE@1178 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/console.asm | 51 ++++++++++++++++++++++++++++++++++++++++++++++ kernel/newstuff.c | 17 ++++++---------- kernel/prf.c | 26 ++++++++++++++++++++++- kernel/task.c | 39 ++++++++++++++++++----------------- 4 files changed, 102 insertions(+), 31 deletions(-) diff --git a/kernel/console.asm b/kernel/console.asm index e4a99440..cf2fd1a3 100644 --- a/kernel/console.asm +++ b/kernel/console.asm @@ -57,6 +57,11 @@ uScanCode db 0 ; Scan code for con: device global _kbdType _kbdType db 0 ; 00 for 84key, 10h for 102key +%IFDEF DEBUG_PRINT_COMPORT +ASYNC_NEED_INIT db 1 +%ENDIF + + global ConInit ConInit: xor ax,ax @@ -243,12 +248,58 @@ _int29_handler: push di push bp push bx +%IFDEF DEBUG_PRINT_COMPORT + cmp bx, 0xFD05 ; magic value for COM print routine + je .comprint +%ENDIF mov ah,0Eh mov bx,7 int 10h ; write char al, teletype mode +.int29hndlr_ret: pop bx pop bp pop di pop si pop ax iret +%IFDEF DEBUG_PRINT_COMPORT +.comprint: + push dx + mov dx, 1 ; 0=COM1,1=COM2,2=COM3,3=COM4 + + mov ah, [cs:ASYNC_NEED_INIT] + or ah,ah + jz .skip_init + push ax ; preserve char (AL) to print + + ; initialize serial port using BIOS to DOS default + ; of 2400 bps, 8 data bits, 1 stop bit, and no parity + mov ax, 0x00A3 + int 14h ; BIOS initialize serial port + + mov ax, 0x011B ; clear the remote screen (ESC[2J) + int 14h ; BIOS write character to serial port + mov ax, 0x015B ; '[' + int 14h ; BIOS write character to serial port + mov ax, 0x0132 ; '2' + int 14h ; BIOS write character to serial port + mov ax, 0x014A ; 'J' + int 14h ; BIOS write character to serial port + + ; mark initialization complete + mov byte [cs:ASYNC_NEED_INIT], 0 + + pop ax ; restore char to print +.skip_init: + cmp al, 0x0A ; do we need to add a carriage return? + jne .print_it + mov ax, 0x010D ; print as \r\n + int 14h + mov al, 0x0A +.print_it: + mov ah, 0x01 + int 14h ; BIOS write character to serial port + + pop dx + jmp .int29hndlr_ret +%ENDIF ; DEBUG_PRINT_COMPORT diff --git a/kernel/newstuff.c b/kernel/newstuff.c index 7ef38f14..05c9513b 100644 --- a/kernel/newstuff.c +++ b/kernel/newstuff.c @@ -33,6 +33,11 @@ static BYTE *mainRcsId = #include "portab.h" #include "globals.h" +#ifdef DEBUG +#define DEBUG_TRUENAME +#endif +#include "debug.h" + /* TE-TODO: if called repeatedly by same process, last allocation must be freed. if handle count < 20, copy back to PSP @@ -89,10 +94,6 @@ long DosMkTmp(BYTE FAR * pathname, UWORD attr) return rc; } -#ifdef DEBUG -#define DEBUG_TRUENAME -#endif - #define drLetterToNr(dr) ((unsigned char)((dr) - 'A')) /* Convert an uppercased drive letter into the drive index */ #define drNrToLetter(dr) ((dr) + 'A') @@ -218,12 +219,6 @@ long DosMkTmp(BYTE FAR * pathname, UWORD attr) */ -#ifdef DEBUG_TRUENAME -#define tn_printf(x) printf x -#else -#define tn_printf(x) -#endif - #define PNE_WILDCARD 1 #define PNE_DOT 2 @@ -635,7 +630,7 @@ cmdspy report report.out more report.out === Intspy report file: REPORT.OUT 1123: IN: C:\INTRSPY\SPY_INT.BAT [FAIL 0001] -1123: OUT:  +1123: OUT: 1123: orig buffer: C:\INTRSPY\SPY_INT.BAT 1123: IN: int.??? [FAIL 0001] 1123: OUT: C:\INTRSPY diff --git a/kernel/prf.c b/kernel/prf.c index 2bfb2dad..83f051a1 100644 --- a/kernel/prf.c +++ b/kernel/prf.c @@ -93,6 +93,13 @@ void put_console(int c) #ifdef __WATCOMC__ void int29(char c); #pragma aux int29 = "int 0x29" parm [al] modify exact [bx]; + +#ifdef DEBUG_PRINT_COMPORT +void fastComPrint(char c); +#pragma aux fastComPrint = \ + "mov bx, 0xFD05" \ + "int 0x29" parm [al] modify exact [bx]; +#endif #endif void put_console(int c) @@ -108,6 +115,9 @@ void put_console(int c) __int__(0x29); #elif defined(__WATCOMC__) int29(c); +#if defined DEBUG_PRINT_COMPORT + fastComPrint(c); +#endif #elif defined(I86) __asm { @@ -141,6 +151,11 @@ STATIC VOID handle_char(COUNT c) if (charp == 0) put_console(c); else +#ifdef DEBUG_PRINT_COMPORT + if (charp == (BYTE FAR *)-1) + fastComPrint(c); + else +#endif *charp++ = c; } @@ -168,6 +183,16 @@ VOID VA_CDECL sprintf(char FAR * buff, CONST BYTE FAR * fmt, ...) handle_char('\0'); } +#ifdef DEBUG_PRINT_COMPORT +VOID dbgc_printf(CONST BYTE FAR * fmt, ...) +{ + va_list arg; + va_start(arg, fmt); + charp = (BYTE FAR *)-1; + do_printf(fmt, arg); +} +#endif + STATIC void do_printf(CONST BYTE FAR * fmt, va_list arg) { int base, size; @@ -325,7 +350,6 @@ STATIC void do_printf(CONST BYTE FAR * fmt, va_list arg) } va_end(arg); } - #endif #if !defined(FORSYS) && !defined(_INIT) diff --git a/kernel/task.c b/kernel/task.c index 6ab62211..35e37ae9 100644 --- a/kernel/task.c +++ b/kernel/task.c @@ -28,6 +28,7 @@ #include "portab.h" #include "globals.h" +#include "debug.h" #ifdef VERSION_STRINGS static BYTE *RcsId = @@ -157,7 +158,7 @@ STATIC int ChildEnv(seg_t env_seg, seg_t *penv_seg, const char far *path) seg_t dst_seg = *penv_seg + 1; int i; - printf("ChildEnv. env seg=0x%02x\n", dst_seg); + DebugPrintf(("ChildEnv. env seg=0x%02x\n", dst_seg)); if (dst_seg) { const char FAR*p = MK_PTR(const char, dst_seg, 0); @@ -165,27 +166,27 @@ STATIC int ChildEnv(seg_t env_seg, seg_t *penv_seg, const char far *path) if (*p) while (*p) { - printf("["); + DebugPrintf(("[")); for (; *p; p++) - if (*p == ' ') printf(""); - else printf("%c", *p); - printf("]\n"); + if (*p == ' ') DebugPrintf(("")); + else DebugPrintf(("%c", *p)); + DebugPrintf(("]\n")); p++; } else p++; /* even empty env must have 1 ("") ASCIIZ string */ /* may be followed by empty string (just \0), 16bit count, ASCIIZ argv[0] */ - printf("End of Env marker = 0x%02x (should be 0)\n", *p); - printf("argv[0] present = %u\n", *MK_PTR(UWORD, dst_seg, env_sz + 2)); + DebugPrintf(("End of Env marker = 0x%02x (should be 0)\n", *p)); + DebugPrintf(("argv[0] present = %u\n", *MK_PTR(UWORD, dst_seg, env_sz + 2))); p+=3; /* skip 16bit count and point to argv[0] */ if (*p) { for (i = 0; p[i] && (i < 127); i++) - printf("%c", p[i]); - printf("\n"); + DebugPrintf(("%c", p[i])); + DebugPrintf(("\n")); } else - printf("No program name (argv[0]) supplied\n"); + DebugPrintf(("No program name (argv[0]) supplied\n")); } } #endif @@ -337,22 +338,22 @@ static void load_transfer(seg_t ds, exec_blk *ep, int mode) /* display full command line */ if (ctCount > 127) { - printf("load_transfer. CommantTail=%d count exceeds 127\n", ctCount); + DebugPrintf(("load_transfer. CommantTail=%d count exceeds 127\n", ctCount)); ctCount = 127; } - printf("load_transfer. CommandTail is:\n"); + DebugPrintf(("load_transfer. CommandTail is:\n")); /* use loop in case tail not '\0' terminated */ if (ctCount) { for (i=0; i < ctCount; i++) if (ep->exec.cmd_line->ctBuffer[i] == ' ') - printf(""); + DebugPrintf(("")); else - printf("%c", ep->exec.cmd_line->ctBuffer[i]); - printf("\n"); + DebugPrintf(("%c", ep->exec.cmd_line->ctBuffer[i])); + DebugPrintf(("\n")); } else - printf("\n"); + DebugPrintf(("\n")); } #endif @@ -494,7 +495,7 @@ COUNT DosComLoader(BYTE FAR * namep, exec_blk * exp, COUNT mode, COUNT fd) return rc; #ifdef DEBUG - printf("DosComLoader. Loading '%S' at %04x\n", namep, mem); + DebugPrintf(("DosComLoader. Loading '%S' at %04x\n", namep, mem)); #endif ++mem; } @@ -639,7 +640,7 @@ COUNT DosExeLoader(BYTE FAR * namep, exec_blk * exp, COUNT mode, COUNT fd) mode &= 0x7f; /* forget about high loading from now on */ #ifdef DEBUG - printf("DosExeLoader. Loading '%S' at %04x\n", namep, mem); + DebugPrintf(("DosExeLoader. Loading '%S' at %04x\n", namep, mem)); #endif /* memory found large enough - continue processing */ } @@ -817,7 +818,7 @@ void ASMCFUNC P_0(const struct config FAR *Config) /*exb.exec.fcb_1 = exb.exec.fcb_2 = NULL;*/ /* unimportant */ #ifdef DEBUG - printf("Process 0 starting: %s%s\n\n", Shell, tailp + 1); + DebugPrintf(("Process 0 starting: %s%s\n\n", Shell, tailp + 1)); #endif res_DosExec(mode, &exb, Shell); } From 596a8dd0d62de76fc4ff8536d5c86e90eaf1e2f3 Mon Sep 17 00:00:00 2001 From: Kenneth J Davis Date: Thu, 2 Mar 2006 22:29:28 +0000 Subject: [PATCH 666/671] fake floppy ddt so hd access works correctly on floppyless systems, based on suggested fix from Eric git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/branches/UNSTABLE@1179 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/initdisk.c | 45 ++++++++++++++++++++++++++++++++++++++------- 1 file changed, 38 insertions(+), 7 deletions(-) diff --git a/kernel/initdisk.c b/kernel/initdisk.c index ba92c468..5b4523b7 100644 --- a/kernel/initdisk.c +++ b/kernel/initdisk.c @@ -583,7 +583,7 @@ void DosDefinePartition(struct DriveParamS *driveParam, pddt->ddt_driveno = driveParam->driveno; pddt->ddt_logdriveno = nUnits; pddt->ddt_descflags = driveParam->descflags; - /* Turn of LBA if not forced and the partition is within 1023 cyls and of the right type */ + /* Turn off LBA if not forced and the partition is within 1023 cyls and of the right type */ /* the FileSystem type was internally converted to LBA_xxxx if a non-LBA partition above cylinder 1023 was found */ if (!InitKernelConfig.ForceLBA && !ExtLBAForce && !IsLBAPartition(pEntry->FileSystem)) @@ -1101,6 +1101,9 @@ int ProcessDisk(int scanType, unsigned drive, int PartitionsToIgnore) return PartitionsToIgnore; } + +/* query BIOS for number of hard disks + */ int BIOS_nrdrives(void) { iregs regs; @@ -1210,20 +1213,42 @@ I don't know, if I did it right, but I tried to do it that way. TE ***********************************************************************/ -STATIC void make_ddt (ddt *pddt, int Unit, int driveno, int flags) +/* initializes a ddt and stores for later retrieval */ +STATIC void create_ddt(ddt *pddt, int Unit, int driveno, int type, int ncyl, int flags, void *defbpb, int bpbsize) { pddt->ddt_next = MK_FP(0, 0xffff); pddt->ddt_logdriveno = Unit; pddt->ddt_driveno = driveno; - pddt->ddt_type = init_getdriveparm(driveno, &pddt->ddt_defbpb); - pddt->ddt_ncyl = (pddt->ddt_type & 7) ? 80 : 40; - pddt->ddt_descflags = init_readdasd(driveno) | flags; + pddt->ddt_type = type; + pddt->ddt_ncyl = ncyl; + pddt->ddt_descflags = flags; pddt->ddt_offset = 0; - memcpy(&pddt->ddt_bpb, &pddt->ddt_defbpb, sizeof(bpb)); + memcpy(&pddt->ddt_bpb, defbpb, bpbsize); push_ddt(pddt); } +/* initializes a ddt for a drive that is assumed to not exist, + e.g. the fake ddt for floppies (A: & B:) on floppyless systems + */ +#define fake_ddt(pddt, Unit) create_ddt(pddt, Unit, \ + 0xFF, /* usually invalid BIOS drive # */ \ + 0x04, /* 2.88MB floppy, since usually for non-existant floppy */ \ + 80, \ + DF_NOACCESS, \ + &floppy_bpbs[4], sizeof(floppy_bpb) \ +) + +/* initializes ddt for a drive (logical or physical) assumed to exist */ +#define make_ddt(pddt, Unit, driveno, flags) create_ddt(pddt, Unit, \ + driveno, \ + init_getdriveparm(driveno, &(pddt)->ddt_defbpb), \ + ( ((pddt)->ddt_type & 7) ? 80 : 40 ), \ + ( init_readdasd(driveno) | flags ), \ + &(pddt)->ddt_defbpb, sizeof(bpb) \ +) + + /* disk initialization: returns number of units */ COUNT dsk_init() { @@ -1235,7 +1260,7 @@ COUNT dsk_init() printf(" - InitDisk\r"); -#ifdef DEBUG +#if defined DEBUG && !defined DEBUG_PRINT_COMPORT { regs.a.x = 0x1112; /* select 43 line mode - more space for partinfo */ regs.b.x = 0; @@ -1262,6 +1287,11 @@ COUNT dsk_init() else make_ddt(&nddt, 1, 0, DF_MULTLOG); /* phantom B: drive */ } + else + { + fake_ddt(&nddt, 0); + fake_ddt(&nddt, 1); + } /* Initial number of disk units */ nUnits = 2; @@ -1341,5 +1371,6 @@ COUNT dsk_init() ProcessDisk(SCAN_PRIMARY2, HardDrive, foundPartitions[HardDrive]); } } + return nUnits; } From 6b71193debbb1b67772d5ed8d9cd85830ae0987a Mon Sep 17 00:00:00 2001 From: Blair Campbell Date: Fri, 30 Jun 2006 01:40:19 +0000 Subject: [PATCH 667/671] Bumped version to 2037 git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/branches/UNSTABLE@1243 6ac86273-5f31-0410-b378-82cca8765d1b --- hdr/version.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/hdr/version.h b/hdr/version.h index 435ac7e2..47d38f81 100644 --- a/hdr/version.h +++ b/hdr/version.h @@ -47,8 +47,8 @@ static BYTE *date_hRcsId = #define REVISION_MAJOR 1 #define REVISION_MINOR 1 -#define REVISION_SEQ 35 -#define BUILD "2035" +#define REVISION_SEQ 37 +#define BUILD "2037" #define SUB_BUILD "w-UNSTABLE" /* only use w=WorkInProgress for UNSTABLE branch */ -#define KERNEL_VERSION_STRING "1.1.35w" /*#REVISION_MAJOR "." #REVISION_MINOR "." #REVISION_SEQ */ -#define KERNEL_BUILD_STRING "2035w-UNSTABLE" /*#BUILD SUB_BUILD */ +#define KERNEL_VERSION_STRING "1.1.37w" /*#REVISION_MAJOR "." #REVISION_MINOR "." #REVISION_SEQ */ +#define KERNEL_BUILD_STRING "2037w-UNSTABLE" /*#BUILD SUB_BUILD */ From 0b892e8479a03e124f9485ee7a5fa3f5f9a74687 Mon Sep 17 00:00:00 2001 From: Blair Campbell Date: Tue, 25 Jul 2006 02:33:01 +0000 Subject: [PATCH 668/671] Bugfix for certain FAT32 files git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/branches/UNSTABLE@1253 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/fattab.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/fattab.c b/kernel/fattab.c index f6aafe2a..07a02e41 100644 --- a/kernel/fattab.c +++ b/kernel/fattab.c @@ -274,7 +274,7 @@ CLUSTER link_fat(struct dpb FAR * dpbp, CLUSTER Cluster1, { /* form an index so that we can read the block as a */ /* byte array */ - UDWORD res = fgetlong(&bp->b_buffer[idx * 4]); + UDWORD res = fgetlong(&bp->b_buffer[idx * 4]) & LONG_LAST_CLUSTER; if (Cluster2 == READ_CLUSTER) { if (res > LONG_BAD) @@ -284,7 +284,7 @@ CLUSTER link_fat(struct dpb FAR * dpbp, CLUSTER Cluster1, } /* Finally, put the word into the buffer and mark the */ /* buffer as dirty. */ - fputlong(&bp->b_buffer[idx * 4], Cluster2); + fputlong(&bp->b_buffer[idx * 4], Cluster2 & LONG_LAST_CLUSTER); if (res == FREE) wasfree++; } From 3b6ba941b986309ac11982a06172344113c8032b Mon Sep 17 00:00:00 2001 From: Blair Campbell Date: Sun, 20 Aug 2006 06:54:39 +0000 Subject: [PATCH 669/671] Compatibility fix for QB4.0(+?) git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/branches/UNSTABLE@1259 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/memmgr.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/kernel/memmgr.c b/kernel/memmgr.c index ffbb8b4d..e692e799 100644 --- a/kernel/memmgr.c +++ b/kernel/memmgr.c @@ -38,8 +38,10 @@ static BYTE *memmgrRcsId = #define nxtMCB(mcb) nxtMCBsize((mcb), (mcb)->m_size) #define mcbFree(mcb) ((mcb)->m_psp == FREE_PSP) -#define mcbValid(mcb) \ - ((mcb)->m_type == MCB_NORMAL || (mcb)->m_type == MCB_LAST) +#define mcbValid(mcb) ( ((mcb)->m_size != 0xffff) && \ + ((mcb)->m_type == MCB_NORMAL || (mcb)->m_type == MCB_LAST) ) +#define mcbFreeable(mcb) \ + ((mcb)->m_type == MCB_NORMAL || (mcb)->m_type == MCB_LAST) #define para2far(seg) (mcb FAR *)MK_FP((seg) , 0) @@ -67,6 +69,11 @@ STATIC COUNT joinMCBs(seg para) p->m_type = q->m_type; /* possibly the next MCB is the last one */ p->m_size += q->m_size + 1; /* one for q's MCB itself */ q->m_type = 'K'; /* Invalidate the magic number */ +#if 0 /* this spoils QB4's habit to double-free: */ + q->m_type = 'K'; /* Invalidate the magic number (whole MCB) */ +#else + q->m_size = 0xffff; /* mark the now unlinked MCB as "fake" */ +#endif } return SUCCESS; @@ -289,7 +296,7 @@ COUNT DosMemFree(UWORD para) p = para2far(para); /* check for corruption */ - if (!mcbValid(p)) + if (!mcbFreeable(p)) /* does not have to be valid, freeable is enough */ return DE_INVLDMCB; /* Mark the mcb as free so that we can later */ From de81e8170cc0353ebd350e8fa98b1027a2ee00c2 Mon Sep 17 00:00:00 2001 From: Blair Campbell Date: Thu, 24 Aug 2006 06:38:25 +0000 Subject: [PATCH 670/671] Bugfix for country.sys by Eduardo git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/branches/UNSTABLE@1261 6ac86273-5f31-0410-b378-82cca8765d1b --- kernel/country.asm | 345 ++++++++++++++++++++++++--------------------- 1 file changed, 181 insertions(+), 164 deletions(-) diff --git a/kernel/country.asm b/kernel/country.asm index af6d8163..56764529 100644 --- a/kernel/country.asm +++ b/kernel/country.asm @@ -393,7 +393,7 @@ _us_437 dw 7 dd en_collate_437 dw 6,7 dd dbcs_empty - dw 6,23 + dw 6,35 dd en_yn _us_850 dw 7 dw 6,1 @@ -408,7 +408,7 @@ _us_850 dw 7 dd en_collate_850 dw 6,7 dd dbcs_empty - dw 6,23 + dw 6,35 dd en_yn _us_858 dw 7 dw 6,1 @@ -423,7 +423,7 @@ _us_858 dw 7 dd en_collate_858 dw 6,7 dd dbcs_empty - dw 6,23 + dw 6,35 dd en_yn _ca_863 dw 7 dw 6,1 @@ -438,7 +438,7 @@ _ca_863 dw 7 dd fr_collate_863 dw 6,7 dd dbcs_empty - dw 6,23 + dw 6,35 dd fr_yn _ca_850 dw 7 dw 6,1 @@ -453,7 +453,7 @@ _ca_850 dw 7 dd fr_collate_850 dw 6,7 dd dbcs_empty - dw 6,23 + dw 6,35 dd fr_yn _ca_858 dw 7 dw 6,1 @@ -468,7 +468,7 @@ _ca_858 dw 7 dd fr_collate_858 dw 6,7 dd dbcs_empty - dw 6,23 + dw 6,35 dd fr_yn _la_850 dw 7 dw 6,1 @@ -483,7 +483,7 @@ _la_850 dw 7 dd es_collate_850 dw 6,7 dd dbcs_empty - dw 6,23 + dw 6,35 dd es_yn _la_858 dw 7 dw 6,1 @@ -498,7 +498,7 @@ _la_858 dw 7 dd es_collate_858 dw 6,7 dd dbcs_empty - dw 6,23 + dw 6,35 dd es_yn _la_437 dw 7 dw 6,1 @@ -513,7 +513,7 @@ _la_437 dw 7 dd es_collate_437 dw 6,7 dd dbcs_empty - dw 6,23 + dw 6,35 dd es_yn _ru_866 dw 8 dw 6,1 @@ -530,7 +530,7 @@ _ru_866 dw 8 dd ru_collate_866 dw 6,7 dd dbcs_empty - dw 6,23 + dw 6,35 dd ru_yn_866 _ru_808 dw 8 dw 6,1 @@ -547,7 +547,7 @@ _ru_808 dw 8 dd ru_collate_808 dw 6,7 dd dbcs_empty - dw 6,23 + dw 6,35 dd ru_yn_808 _ru_855 dw 7 dw 6,1 @@ -562,7 +562,7 @@ _ru_855 dw 7 dd ru_collate_855 dw 6,7 dd dbcs_empty - dw 6,23 + dw 6,35 dd ru_yn_855 _ru_872 dw 7 dw 6,1 @@ -577,7 +577,7 @@ _ru_872 dw 7 dd ru_collate_872 dw 6,7 dd dbcs_empty - dw 6,23 + dw 6,35 dd ru_yn_872 _ru_852 dw 7 dw 6,1 @@ -592,7 +592,7 @@ _ru_852 dw 7 dd ru_collate_852 dw 6,7 dd dbcs_empty - dw 6,23 + dw 6,35 dd ru_yn _ru_850 dw 7 dw 6,1 @@ -607,7 +607,7 @@ _ru_850 dw 7 dd ru_collate_850 dw 6,7 dd dbcs_empty - dw 6,23 + dw 6,35 dd ru_yn _ru_858 dw 7 dw 6,1 @@ -622,7 +622,7 @@ _ru_858 dw 7 dd ru_collate_858 dw 6,7 dd dbcs_empty - dw 6,23 + dw 6,35 dd ru_yn _ru_437 dw 7 dw 6,1 @@ -637,7 +637,7 @@ _ru_437 dw 7 dd ru_collate_437 dw 6,7 dd dbcs_empty - dw 6,23 + dw 6,35 dd ru_yn _gr_869 dw 7 dw 6,1 @@ -652,7 +652,7 @@ _gr_869 dw 7 dd gr_collate_869 dw 6,7 dd dbcs_empty - dw 6,23 + dw 6,35 dd gr_yn_869 _gr_737 dw 7 dw 6,1 @@ -667,7 +667,7 @@ _gr_737 dw 7 dd gr_collate_737 dw 6,7 dd dbcs_empty - dw 6,23 + dw 6,35 dd gr_yn_737 _gr_850 dw 7 dw 6,1 @@ -682,7 +682,7 @@ _gr_850 dw 7 dd gr_collate_850 dw 6,7 dd dbcs_empty - dw 6,23 + dw 6,35 dd gr_yn _gr_858 dw 7 dw 6,1 @@ -697,7 +697,7 @@ _gr_858 dw 7 dd gr_collate_858 dw 6,7 dd dbcs_empty - dw 6,23 + dw 6,35 dd gr_yn _nl_850 dw 7 dw 6,1 @@ -712,7 +712,7 @@ _nl_850 dw 7 dd nl_collate_850 dw 6,7 dd dbcs_empty - dw 6,23 + dw 6,35 dd nl_yn _nl_858 dw 7 dw 6,1 @@ -727,7 +727,7 @@ _nl_858 dw 7 dd nl_collate_858 dw 6,7 dd dbcs_empty - dw 6,23 + dw 6,35 dd nl_yn _nl_437 dw 7 dw 6,1 @@ -742,7 +742,7 @@ _nl_437 dw 7 dd nl_collate_437 dw 6,7 dd dbcs_empty - dw 6,23 + dw 6,35 dd nl_yn _be_850 dw 7 dw 6,1 @@ -757,7 +757,7 @@ _be_850 dw 7 dd be_collate_850 dw 6,7 dd dbcs_empty - dw 6,23 + dw 6,35 dd nl_yn _be_858 dw 7 dw 6,1 @@ -772,7 +772,7 @@ _be_858 dw 7 dd be_collate_858 dw 6,7 dd dbcs_empty - dw 6,23 + dw 6,35 dd nl_yn _be_437 dw 7 dw 6,1 @@ -787,7 +787,7 @@ _be_437 dw 7 dd be_collate_437 dw 6,7 dd dbcs_empty - dw 6,23 + dw 6,35 dd nl_yn _fr_850 dw 7 dw 6,1 @@ -802,7 +802,7 @@ _fr_850 dw 7 dd fr_collate_850 dw 6,7 dd dbcs_empty - dw 6,23 + dw 6,35 dd fr_yn _fr_858 dw 7 dw 6,1 @@ -817,7 +817,7 @@ _fr_858 dw 7 dd fr_collate_858 dw 6,7 dd dbcs_empty - dw 6,23 + dw 6,35 dd fr_yn _fr_437 dw 7 dw 6,1 @@ -832,7 +832,7 @@ _fr_437 dw 7 dd fr_collate_437 dw 6,7 dd dbcs_empty - dw 6,23 + dw 6,35 dd fr_yn _es_850 dw 7 dw 6,1 @@ -847,7 +847,7 @@ _es_850 dw 7 dd es_collate_850 dw 6,7 dd dbcs_empty - dw 6,23 + dw 6,35 dd es_yn _es_858 dw 7 dw 6,1 @@ -862,7 +862,7 @@ _es_858 dw 7 dd es_collate_858 dw 6,7 dd dbcs_empty - dw 6,23 + dw 6,35 dd es_yn _es_437 dw 7 dw 6,1 @@ -877,7 +877,7 @@ _es_437 dw 7 dd es_collate_437 dw 6,7 dd dbcs_empty - dw 6,23 + dw 6,35 dd es_yn _hu_852 dw 7 dw 6,1 @@ -892,7 +892,7 @@ _hu_852 dw 7 dd hu_collate_852 dw 6,7 dd dbcs_empty - dw 6,23 + dw 6,35 dd hu_yn _hu_850 dw 7 dw 6,1 @@ -907,7 +907,7 @@ _hu_850 dw 7 dd hu_collate_850 dw 6,7 dd dbcs_empty - dw 6,23 + dw 6,35 dd hu_yn _hu_858 dw 7 dw 6,1 @@ -922,7 +922,7 @@ _hu_858 dw 7 dd hu_collate_858 dw 6,7 dd dbcs_empty - dw 6,23 + dw 6,35 dd hu_yn _yu_852 dw 7 dw 6,1 @@ -937,7 +937,7 @@ _yu_852 dw 7 dd sh_collate_852 dw 6,7 dd dbcs_empty - dw 6,23 + dw 6,35 dd sh_yn _yu_855 dw 7 dw 6,1 @@ -952,7 +952,7 @@ _yu_855 dw 7 dd sh_collate_855 dw 6,7 dd dbcs_empty - dw 6,23 + dw 6,35 dd sh_yn_855 _yu_872 dw 7 dw 6,1 @@ -967,7 +967,7 @@ _yu_872 dw 7 dd sh_collate_872 dw 6,7 dd dbcs_empty - dw 6,23 + dw 6,35 dd sh_yn_872 _yu_850 dw 7 dw 6,1 @@ -982,7 +982,7 @@ _yu_850 dw 7 dd sh_collate_850 dw 6,7 dd dbcs_empty - dw 6,23 + dw 6,35 dd sh_yn _yu_858 dw 7 dw 6,1 @@ -997,7 +997,7 @@ _yu_858 dw 7 dd sh_collate_858 dw 6,7 dd dbcs_empty - dw 6,23 + dw 6,35 dd sh_yn _it_850 dw 7 dw 6,1 @@ -1012,7 +1012,7 @@ _it_850 dw 7 dd it_collate_850 dw 6,7 dd dbcs_empty - dw 6,23 + dw 6,35 dd it_yn _it_858 dw 7 dw 6,1 @@ -1027,7 +1027,7 @@ _it_858 dw 7 dd it_collate_858 dw 6,7 dd dbcs_empty - dw 6,23 + dw 6,35 dd it_yn _it_437 dw 7 dw 6,1 @@ -1042,7 +1042,7 @@ _it_437 dw 7 dd it_collate_437 dw 6,7 dd dbcs_empty - dw 6,23 + dw 6,35 dd it_yn _ro_852 dw 7 dw 6,1 @@ -1057,7 +1057,7 @@ _ro_852 dw 7 dd ro_collate_852 dw 6,7 dd dbcs_empty - dw 6,23 + dw 6,35 dd ro_yn _ro_850 dw 7 dw 6,1 @@ -1072,7 +1072,7 @@ _ro_850 dw 7 dd ro_collate_850 dw 6,7 dd dbcs_empty - dw 6,23 + dw 6,35 dd ro_yn _ro_858 dw 7 dw 6,1 @@ -1087,7 +1087,7 @@ _ro_858 dw 7 dd ro_collate_858 dw 6,7 dd dbcs_empty - dw 6,23 + dw 6,35 dd ro_yn _ch_850 dw 7 dw 6,1 @@ -1102,7 +1102,7 @@ _ch_850 dw 7 dd ch_collate_850 dw 6,7 dd dbcs_empty - dw 6,23 + dw 6,35 dd de_yn _ch_858 dw 7 dw 6,1 @@ -1117,7 +1117,7 @@ _ch_858 dw 7 dd ch_collate_858 dw 6,7 dd dbcs_empty - dw 6,23 + dw 6,35 dd de_yn _ch_437 dw 7 dw 6,1 @@ -1132,7 +1132,7 @@ _ch_437 dw 7 dd ch_collate_437 dw 6,7 dd dbcs_empty - dw 6,23 + dw 6,35 dd de_yn _cz_852 dw 7 dw 6,1 @@ -1147,7 +1147,7 @@ _cz_852 dw 7 dd cz_collate_852 dw 6,7 dd dbcs_empty - dw 6,23 + dw 6,35 dd cz_yn _cz_850 dw 7 dw 6,1 @@ -1162,7 +1162,7 @@ _cz_850 dw 7 dd cz_collate_850 dw 6,7 dd dbcs_empty - dw 6,23 + dw 6,35 dd cz_yn _cz_858 dw 7 dw 6,1 @@ -1177,7 +1177,7 @@ _cz_858 dw 7 dd cz_collate_858 dw 6,7 dd dbcs_empty - dw 6,23 + dw 6,35 dd cz_yn _at_850 dw 7 dw 6,1 @@ -1192,7 +1192,7 @@ _at_850 dw 7 dd de_collate_850 dw 6,7 dd dbcs_empty - dw 6,23 + dw 6,35 dd de_yn _at_858 dw 7 dw 6,1 @@ -1207,7 +1207,7 @@ _at_858 dw 7 dd de_collate_858 dw 6,7 dd dbcs_empty - dw 6,23 + dw 6,35 dd de_yn _at_437 dw 7 dw 6,1 @@ -1222,7 +1222,7 @@ _at_437 dw 7 dd de_collate_437 dw 6,7 dd dbcs_empty - dw 6,23 + dw 6,35 dd de_yn _uk_850 dw 7 dw 6,1 @@ -1237,7 +1237,7 @@ _uk_850 dw 7 dd en_collate_850 dw 6,7 dd dbcs_empty - dw 6,23 + dw 6,35 dd en_yn _uk_858 dw 7 dw 6,1 @@ -1252,7 +1252,7 @@ _uk_858 dw 7 dd en_collate_858 dw 6,7 dd dbcs_empty - dw 6,23 + dw 6,35 dd en_yn _uk_437 dw 7 dw 6,1 @@ -1267,7 +1267,7 @@ _uk_437 dw 7 dd en_collate_437 dw 6,7 dd dbcs_empty - dw 6,23 + dw 6,35 dd en_yn _dk_865 dw 7 dw 6,1 @@ -1282,7 +1282,7 @@ _dk_865 dw 7 dd dk_collate_865 dw 6,7 dd dbcs_empty - dw 6,23 + dw 6,35 dd dk_yn _dk_850 dw 7 dw 6,1 @@ -1297,7 +1297,7 @@ _dk_850 dw 7 dd dk_collate_850 dw 6,7 dd dbcs_empty - dw 6,23 + dw 6,35 dd dk_yn _dk_858 dw 7 dw 6,1 @@ -1312,7 +1312,7 @@ _dk_858 dw 7 dd dk_collate_858 dw 6,7 dd dbcs_empty - dw 6,23 + dw 6,35 dd dk_yn _se_850 dw 7 dw 6,1 @@ -1327,7 +1327,7 @@ _se_850 dw 7 dd se_collate_850 dw 6,7 dd dbcs_empty - dw 6,23 + dw 6,35 dd se_yn _se_858 dw 7 dw 6,1 @@ -1342,7 +1342,7 @@ _se_858 dw 7 dd se_collate_858 dw 6,7 dd dbcs_empty - dw 6,23 + dw 6,35 dd se_yn _se_437 dw 7 dw 6,1 @@ -1357,7 +1357,7 @@ _se_437 dw 7 dd se_collate_437 dw 6,7 dd dbcs_empty - dw 6,23 + dw 6,35 dd se_yn _no_865 dw 7 dw 6,1 @@ -1372,7 +1372,7 @@ _no_865 dw 7 dd no_collate_865 dw 6,7 dd dbcs_empty - dw 6,23 + dw 6,35 dd no_yn _no_850 dw 7 dw 6,1 @@ -1387,7 +1387,7 @@ _no_850 dw 7 dd no_collate_850 dw 6,7 dd dbcs_empty - dw 6,23 + dw 6,35 dd no_yn _no_858 dw 7 dw 6,1 @@ -1402,7 +1402,7 @@ _no_858 dw 7 dd no_collate_858 dw 6,7 dd dbcs_empty - dw 6,23 + dw 6,35 dd no_yn _pl_852 dw 7 dw 6,1 @@ -1417,7 +1417,7 @@ _pl_852 dw 7 dd pl_collate_852 dw 6,7 dd dbcs_empty - dw 6,23 + dw 6,35 dd pl_yn _pl_850 dw 7 dw 6,1 @@ -1432,7 +1432,7 @@ _pl_850 dw 7 dd pl_collate_850 dw 6,7 dd dbcs_empty - dw 6,23 + dw 6,35 dd pl_yn _pl_858 dw 7 dw 6,1 @@ -1447,7 +1447,7 @@ _pl_858 dw 7 dd pl_collate_858 dw 6,7 dd dbcs_empty - dw 6,23 + dw 6,35 dd pl_yn _de_850 dw 7 dw 6,1 @@ -1462,7 +1462,7 @@ _de_850 dw 7 dd de_collate_850 dw 6,7 dd dbcs_empty - dw 6,23 + dw 6,35 dd de_yn _de_858 dw 7 dw 6,1 @@ -1477,7 +1477,7 @@ _de_858 dw 7 dd de_collate_858 dw 6,7 dd dbcs_empty - dw 6,23 + dw 6,35 dd de_yn _de_437 dw 7 dw 6,1 @@ -1492,7 +1492,7 @@ _de_437 dw 7 dd de_collate_437 dw 6,7 dd dbcs_empty - dw 6,23 + dw 6,35 dd de_yn _ar_437 dw 7 dw 6,1 @@ -1507,7 +1507,7 @@ _ar_437 dw 7 dd es_collate_437 dw 6,7 dd dbcs_empty - dw 6,23 + dw 6,35 dd es_yn _ar_850 dw 7 dw 6,1 @@ -1522,7 +1522,7 @@ _ar_850 dw 7 dd es_collate_850 dw 6,7 dd dbcs_empty - dw 6,23 + dw 6,35 dd es_yn _ar_858 dw 7 dw 6,1 @@ -1537,7 +1537,7 @@ _ar_858 dw 7 dd es_collate_858 dw 6,7 dd dbcs_empty - dw 6,23 + dw 6,35 dd es_yn _br_850 dw 7 dw 6,1 @@ -1552,7 +1552,7 @@ _br_850 dw 7 dd pt_collate_850 dw 6,7 dd dbcs_empty - dw 6,23 + dw 6,35 dd pt_yn _br_858 dw 7 dw 6,1 @@ -1567,7 +1567,7 @@ _br_858 dw 7 dd pt_collate_858 dw 6,7 dd dbcs_empty - dw 6,23 + dw 6,35 dd pt_yn _br_437 dw 7 dw 6,1 @@ -1582,7 +1582,7 @@ _br_437 dw 7 dd pt_collate_437 dw 6,7 dd dbcs_empty - dw 6,23 + dw 6,35 dd pt_yn _my_437 dw 7 dw 6,1 @@ -1597,7 +1597,7 @@ _my_437 dw 7 dd en_collate_437 dw 6,7 dd dbcs_empty - dw 6,23 + dw 6,35 dd en_yn _au_437 dw 7 dw 6,1 @@ -1612,7 +1612,7 @@ _au_437 dw 7 dd en_collate_437 dw 6,7 dd dbcs_empty - dw 6,23 + dw 6,35 dd en_yn _au_850 dw 7 dw 6,1 @@ -1627,7 +1627,7 @@ _au_850 dw 7 dd en_collate_850 dw 6,7 dd dbcs_empty - dw 6,23 + dw 6,35 dd en_yn _au_858 dw 7 dw 6,1 @@ -1642,7 +1642,7 @@ _au_858 dw 7 dd en_collate_858 dw 6,7 dd dbcs_empty - dw 6,23 + dw 6,35 dd en_yn _sg_437 dw 7 dw 6,1 @@ -1657,7 +1657,7 @@ _sg_437 dw 7 dd en_collate_437 dw 6,7 dd dbcs_empty - dw 6,23 + dw 6,35 dd en_yn _jp_437 dw 7 dw 6,1 @@ -1672,7 +1672,7 @@ _jp_437 dw 7 dd en_collate_437 dw 6,7 dd dbcs_empty - dw 6,23 + dw 6,35 dd en_yn ; Japanese MS-DOS uses "Y" and "N" - Yuki _jp_932 dw 7 dw 6,1 @@ -1687,7 +1687,7 @@ _jp_932 dw 7 dd jp_collate_932 dw 6,7 dd jp_dbcs_932 - dw 6,23 + dw 6,35 dd en_yn _kr_437 dw 7 dw 6,1 @@ -1702,7 +1702,7 @@ _kr_437 dw 7 dd en_collate_437 dw 6,7 dd dbcs_empty - dw 6,23 + dw 6,35 dd kr_yn _kr_934 dw 7 dw 6,1 @@ -1717,7 +1717,7 @@ _kr_934 dw 7 dd kr_collate_934 dw 6,7 dd kr_dbcs_934 - dw 6,23 + dw 6,35 dd kr_yn _cn_437 dw 7 dw 6,1 @@ -1732,7 +1732,7 @@ _cn_437 dw 7 dd en_collate_437 dw 6,7 dd dbcs_empty - dw 6,23 + dw 6,35 dd cn_yn _cn_936 dw 7 dw 6,1 @@ -1747,7 +1747,7 @@ _cn_936 dw 7 dd cn_collate_936 dw 6,7 dd cn_dbcs_936 - dw 6,23 + dw 6,35 dd cn_yn_936 _tr_857 dw 7 dw 6,1 @@ -1762,7 +1762,7 @@ _tr_857 dw 7 dd tr_collate_857 dw 6,7 dd dbcs_empty - dw 6,23 + dw 6,35 dd tr_yn _tr_850 dw 7 dw 6,1 @@ -1777,7 +1777,7 @@ _tr_850 dw 7 dd tr_collate_850 dw 6,7 dd dbcs_empty - dw 6,23 + dw 6,35 dd tr_yn _in_437 dw 7 dw 6,1 @@ -1792,7 +1792,7 @@ _in_437 dw 7 dd en_collate_437 dw 6,7 dd dbcs_empty - dw 6,23 + dw 6,35 dd en_yn _pt_860 dw 7 dw 6,1 @@ -1807,7 +1807,7 @@ _pt_860 dw 7 dd pt_collate_860 dw 6,7 dd dbcs_empty - dw 6,23 + dw 6,35 dd pt_yn _pt_850 dw 7 dw 6,1 @@ -1822,7 +1822,7 @@ _pt_850 dw 7 dd pt_collate_850 dw 6,7 dd dbcs_empty - dw 6,23 + dw 6,35 dd pt_yn _pt_858 dw 7 dw 6,1 @@ -1837,7 +1837,7 @@ _pt_858 dw 7 dd pt_collate_858 dw 6,7 dd dbcs_empty - dw 6,23 + dw 6,35 dd pt_yn _fi_850 dw 7 dw 6,1 @@ -1852,7 +1852,7 @@ _fi_850 dw 7 dd fi_collate_850 dw 6,7 dd dbcs_empty - dw 6,23 + dw 6,35 dd fi_yn _fi_858 dw 7 dw 6,1 @@ -1867,7 +1867,7 @@ _fi_858 dw 7 dd fi_collate_858 dw 6,7 dd dbcs_empty - dw 6,23 + dw 6,35 dd fi_yn _fi_437 dw 7 dw 6,1 @@ -1882,7 +1882,7 @@ _fi_437 dw 7 dd fi_collate_437 dw 6,7 dd dbcs_empty - dw 6,23 + dw 6,35 dd fi_yn _bg_855 dw 7 dw 6,1 @@ -1897,7 +1897,7 @@ _bg_855 dw 7 dd bg_collate_855 dw 6,7 dd dbcs_empty - dw 6,23 + dw 6,35 dd bg_yn_855 _bg_872 dw 7 dw 6,1 @@ -1912,7 +1912,7 @@ _bg_872 dw 7 dd bg_collate_872 dw 6,7 dd dbcs_empty - dw 6,23 + dw 6,35 dd bg_yn_872 _bg_850 dw 7 dw 6,1 @@ -1927,7 +1927,7 @@ _bg_850 dw 7 dd bg_collate_850 dw 6,7 dd dbcs_empty - dw 6,23 + dw 6,35 dd bg_yn _bg_858 dw 7 dw 6,1 @@ -1942,7 +1942,7 @@ _bg_858 dw 7 dd bg_collate_858 dw 6,7 dd dbcs_empty - dw 6,23 + dw 6,35 dd bg_yn _ua_848 dw 8 dw 6,1 @@ -1959,7 +1959,7 @@ _ua_848 dw 8 dd ua_collate_848 dw 6,7 dd dbcs_empty - dw 6,23 + dw 6,35 dd ua_yn_848 _ua_1125 dw 8 dw 6,1 @@ -1976,7 +1976,7 @@ _ua_1125 dw 8 dd ua_collate_1125 dw 6,7 dd dbcs_empty - dw 6,23 + dw 6,35 dd ua_yn_1125 _sr_852 dw 7 dw 6,1 @@ -1991,7 +1991,7 @@ _sr_852 dw 7 dd sh_collate_852 dw 6,7 dd dbcs_empty - dw 6,23 + dw 6,35 dd sh_yn _sr_855 dw 7 dw 6,1 @@ -2006,7 +2006,7 @@ _sr_855 dw 7 dd sh_collate_855 dw 6,7 dd dbcs_empty - dw 6,23 + dw 6,35 dd sh_yn_855 _sr_872 dw 7 dw 6,1 @@ -2021,7 +2021,7 @@ _sr_872 dw 7 dd sh_collate_872 dw 6,7 dd dbcs_empty - dw 6,23 + dw 6,35 dd sh_yn_872 _sr_850 dw 7 dw 6,1 @@ -2036,7 +2036,7 @@ _sr_850 dw 7 dd sh_collate_850 dw 6,7 dd dbcs_empty - dw 6,23 + dw 6,35 dd sh_yn _sr_858 dw 7 dw 6,1 @@ -2051,7 +2051,7 @@ _sr_858 dw 7 dd sh_collate_858 dw 6,7 dd dbcs_empty - dw 6,23 + dw 6,35 dd sh_yn _hr_852 dw 7 dw 6,1 @@ -2066,7 +2066,7 @@ _hr_852 dw 7 dd hr_collate_852 dw 6,7 dd dbcs_empty - dw 6,23 + dw 6,35 dd hr_yn _hr_850 dw 7 dw 6,1 @@ -2081,7 +2081,7 @@ _hr_850 dw 7 dd hr_collate_850 dw 6,7 dd dbcs_empty - dw 6,23 + dw 6,35 dd hr_yn _hr_858 dw 7 dw 6,1 @@ -2096,7 +2096,7 @@ _hr_858 dw 7 dd hr_collate_858 dw 6,7 dd dbcs_empty - dw 6,23 + dw 6,35 dd hr_yn _si_852 dw 7 dw 6,1 @@ -2111,7 +2111,7 @@ _si_852 dw 7 dd si_collate_852 dw 6,7 dd dbcs_empty - dw 6,23 + dw 6,35 dd si_yn _si_850 dw 7 dw 6,1 @@ -2126,7 +2126,7 @@ _si_850 dw 7 dd si_collate_850 dw 6,7 dd dbcs_empty - dw 6,23 + dw 6,35 dd si_yn _si_858 dw 7 dw 6,1 @@ -2141,7 +2141,7 @@ _si_858 dw 7 dd si_collate_858 dw 6,7 dd dbcs_empty - dw 6,23 + dw 6,35 dd si_yn _ba_852 dw 7 dw 6,1 @@ -2156,7 +2156,7 @@ _ba_852 dw 7 dd sh_collate_852 dw 6,7 dd dbcs_empty - dw 6,23 + dw 6,35 dd sh_yn _ba_850 dw 7 dw 6,1 @@ -2171,7 +2171,7 @@ _ba_850 dw 7 dd sh_collate_850 dw 6,7 dd dbcs_empty - dw 6,23 + dw 6,35 dd sh_yn _ba_858 dw 7 dw 6,1 @@ -2186,7 +2186,7 @@ _ba_858 dw 7 dd sh_collate_858 dw 6,7 dd dbcs_empty - dw 6,23 + dw 6,35 dd sh_yn _ba_855 dw 7 dw 6,1 @@ -2201,7 +2201,7 @@ _ba_855 dw 7 dd sh_collate_855 dw 6,7 dd dbcs_empty - dw 6,23 + dw 6,35 dd sh_yn_855 _ba_872 dw 7 dw 6,1 @@ -2216,7 +2216,7 @@ _ba_872 dw 7 dd sh_collate_872 dw 6,7 dd dbcs_empty - dw 6,23 + dw 6,35 dd sh_yn_872 _mk_855 dw 7 dw 6,1 @@ -2231,7 +2231,7 @@ _mk_855 dw 7 dd mk_collate_855 dw 6,7 dd dbcs_empty - dw 6,23 + dw 6,35 dd mk_yn_855 _mk_872 dw 7 dw 6,1 @@ -2246,7 +2246,7 @@ _mk_872 dw 7 dd mk_collate_872 dw 6,7 dd dbcs_empty - dw 6,23 + dw 6,35 dd mk_yn_872 _mk_850 dw 7 dw 6,1 @@ -2261,7 +2261,7 @@ _mk_850 dw 7 dd mk_collate_850 dw 6,7 dd dbcs_empty - dw 6,23 + dw 6,35 dd mk_yn _mk_858 dw 7 dw 6,1 @@ -2276,7 +2276,7 @@ _mk_858 dw 7 dd mk_collate_858 dw 6,7 dd dbcs_empty - dw 6,23 + dw 6,35 dd mk_yn _me_850 dw 7 dw 6,1 @@ -2291,7 +2291,7 @@ _me_850 dw 7 dd me_collate_850 dw 6,7 dd dbcs_empty - dw 6,23 + dw 6,35 dd me_yn _me_858 dw 7 dw 6,1 @@ -2306,7 +2306,7 @@ _me_858 dw 7 dd me_collate_858 dw 6,7 dd dbcs_empty - dw 6,23 + dw 6,35 dd me_yn _me_864 dw 7 dw 6,1 @@ -2321,7 +2321,7 @@ _me_864 dw 7 dd me_collate_864 dw 6,7 dd dbcs_empty - dw 6,23 + dw 6,35 dd me_yn_864 _il_850 dw 7 dw 6,1 @@ -2336,7 +2336,7 @@ _il_850 dw 7 dd il_collate_850 dw 6,7 dd dbcs_empty - dw 6,23 + dw 6,35 dd il_yn _il_858 dw 7 dw 6,1 @@ -2351,7 +2351,7 @@ _il_858 dw 7 dd il_collate_858 dw 6,7 dd dbcs_empty - dw 6,23 + dw 6,35 dd il_yn _il_862 dw 7 dw 6,1 @@ -2366,7 +2366,7 @@ _il_862 dw 7 dd il_collate_862 dw 6,7 dd dbcs_empty - dw 6,23 + dw 6,35 dd il_yn_862 _nl_BE_850 dw 7 dw 6,1 @@ -2381,7 +2381,7 @@ _nl_BE_850 dw 7 dd nl_collate_850 dw 6,7 dd dbcs_empty - dw 6,23 + dw 6,35 dd nl_yn _nl_BE_858 dw 7 dw 6,1 @@ -2396,7 +2396,7 @@ _nl_BE_858 dw 7 dd nl_collate_858 dw 6,7 dd dbcs_empty - dw 6,23 + dw 6,35 dd nl_yn _nl_BE_437 dw 7 dw 6,1 @@ -2411,7 +2411,7 @@ _nl_BE_437 dw 7 dd nl_collate_437 dw 6,7 dd dbcs_empty - dw 6,23 + dw 6,35 dd nl_yn _fr_BE_850 dw 7 dw 6,1 @@ -2426,7 +2426,7 @@ _fr_BE_850 dw 7 dd fr_collate_850 dw 6,7 dd dbcs_empty - dw 6,23 + dw 6,35 dd fr_yn _fr_BE_858 dw 7 dw 6,1 @@ -2441,7 +2441,7 @@ _fr_BE_858 dw 7 dd fr_collate_858 dw 6,7 dd dbcs_empty - dw 6,23 + dw 6,35 dd fr_yn _fr_BE_437 dw 7 dw 6,1 @@ -2456,7 +2456,7 @@ _fr_BE_437 dw 7 dd fr_collate_437 dw 6,7 dd dbcs_empty - dw 6,23 + dw 6,35 dd fr_yn _de_BE_850 dw 7 dw 6,1 @@ -2471,7 +2471,7 @@ _de_BE_850 dw 7 dd de_collate_850 dw 6,7 dd dbcs_empty - dw 6,23 + dw 6,35 dd de_yn _de_BE_858 dw 7 dw 6,1 @@ -2486,7 +2486,7 @@ _de_BE_858 dw 7 dd de_collate_858 dw 6,7 dd dbcs_empty - dw 6,23 + dw 6,35 dd de_yn _de_BE_437 dw 7 dw 6,1 @@ -2501,7 +2501,7 @@ _de_BE_437 dw 7 dd de_collate_437 dw 6,7 dd dbcs_empty - dw 6,23 + dw 6,35 dd de_yn _es_ES_850 dw 7 dw 6,1 @@ -2516,7 +2516,7 @@ _es_ES_850 dw 7 dd es_collate_850 dw 6,7 dd dbcs_empty - dw 6,23 + dw 6,35 dd es_yn _es_ES_858 dw 7 dw 6,1 @@ -2531,7 +2531,7 @@ _es_ES_858 dw 7 dd es_collate_858 dw 6,7 dd dbcs_empty - dw 6,23 + dw 6,35 dd es_yn _es_ES_437 dw 7 dw 6,1 @@ -2546,7 +2546,7 @@ _es_ES_437 dw 7 dd es_collate_437 dw 6,7 dd dbcs_empty - dw 6,23 + dw 6,35 dd es_yn _ca_ES_850 dw 7 dw 6,1 @@ -2561,7 +2561,7 @@ _ca_ES_850 dw 7 dd ca_collate_850 dw 6,7 dd dbcs_empty - dw 6,23 + dw 6,35 dd ca_yn _ca_ES_858 dw 7 dw 6,1 @@ -2576,7 +2576,7 @@ _ca_ES_858 dw 7 dd ca_collate_858 dw 6,7 dd dbcs_empty - dw 6,23 + dw 6,35 dd ca_yn _ca_ES_437 dw 7 dw 6,1 @@ -2591,7 +2591,7 @@ _ca_ES_437 dw 7 dd ca_collate_437 dw 6,7 dd dbcs_empty - dw 6,23 + dw 6,35 dd ca_yn _gl_ES_850 dw 7 dw 6,1 @@ -2606,7 +2606,7 @@ _gl_ES_850 dw 7 dd gl_collate_850 dw 6,7 dd dbcs_empty - dw 6,23 + dw 6,35 dd gl_yn _gl_ES_858 dw 7 dw 6,1 @@ -2621,7 +2621,7 @@ _gl_ES_858 dw 7 dd gl_collate_858 dw 6,7 dd dbcs_empty - dw 6,23 + dw 6,35 dd gl_yn _gl_ES_437 dw 7 dw 6,1 @@ -2636,7 +2636,7 @@ _gl_ES_437 dw 7 dd gl_collate_437 dw 6,7 dd dbcs_empty - dw 6,23 + dw 6,35 dd gl_yn _eu_ES_850 dw 7 dw 6,1 @@ -2651,7 +2651,7 @@ _eu_ES_850 dw 7 dd eu_collate_850 dw 6,7 dd dbcs_empty - dw 6,23 + dw 6,35 dd eu_yn _eu_ES_858 dw 7 dw 6,1 @@ -2666,7 +2666,7 @@ _eu_ES_858 dw 7 dd eu_collate_858 dw 6,7 dd dbcs_empty - dw 6,23 + dw 6,35 dd eu_yn _eu_ES_437 dw 7 dw 6,1 @@ -2681,7 +2681,7 @@ _eu_ES_437 dw 7 dd eu_collate_437 dw 6,7 dd dbcs_empty - dw 6,23 + dw 6,35 dd eu_yn _de_CH_850 dw 7 dw 6,1 @@ -2696,7 +2696,7 @@ _de_CH_850 dw 7 dd de_collate_850 dw 6,7 dd dbcs_empty - dw 6,23 + dw 6,35 dd de_yn _de_CH_858 dw 7 dw 6,1 @@ -2711,7 +2711,7 @@ _de_CH_858 dw 7 dd de_collate_858 dw 6,7 dd dbcs_empty - dw 6,23 + dw 6,35 dd de_yn _de_CH_437 dw 7 dw 6,1 @@ -2726,7 +2726,7 @@ _de_CH_437 dw 7 dd de_collate_437 dw 6,7 dd dbcs_empty - dw 6,23 + dw 6,35 dd de_yn _fr_CH_850 dw 7 dw 6,1 @@ -2741,7 +2741,7 @@ _fr_CH_850 dw 7 dd fr_collate_850 dw 6,7 dd dbcs_empty - dw 6,23 + dw 6,35 dd fr_yn _fr_CH_858 dw 7 dw 6,1 @@ -2756,7 +2756,7 @@ _fr_CH_858 dw 7 dd fr_collate_858 dw 6,7 dd dbcs_empty - dw 6,23 + dw 6,35 dd fr_yn _fr_CH_437 dw 7 dw 6,1 @@ -2771,7 +2771,7 @@ _fr_CH_437 dw 7 dd fr_collate_437 dw 6,7 dd dbcs_empty - dw 6,23 + dw 6,35 dd fr_yn _it_CH_850 dw 7 dw 6,1 @@ -2786,7 +2786,7 @@ _it_CH_850 dw 7 dd it_collate_850 dw 6,7 dd dbcs_empty - dw 6,23 + dw 6,35 dd it_yn _it_CH_858 dw 7 dw 6,1 @@ -2801,7 +2801,7 @@ _it_CH_858 dw 7 dd it_collate_858 dw 6,7 dd dbcs_empty - dw 6,23 + dw 6,35 dd it_yn _it_CH_437 dw 7 dw 6,1 @@ -2816,7 +2816,7 @@ _it_CH_437 dw 7 dd it_collate_437 dw 6,7 dd dbcs_empty - dw 6,23 + dw 6,35 dd it_yn %define MDY 0 ; month/day/year @@ -2991,7 +2991,7 @@ es_ES_437 cnf 40034,437,DMY,"E","U","R",0,0,".",",","/",":",0,2,_24 ca_ES_850 cnf 41034,850,DMY,"E","U","R",0,0,".",",","/",":",0,2,_24; Catalan ca_ES_858 cnf 41034,858,DMY,0D5h, 0,0,0,0,".",",","/",":",0,2,_24 ca_ES_437 cnf 41034,437,DMY,"E","U","R",0,0,".",",","/",":",0,2,_24 -gl_ES_850 cnf 42034,850,DMY,"E","U","R",0,0,".",",","/",":",0,2,_24; Gallegan +gl_ES_850 cnf 42034,850,DMY,"E","U","R",0,0,".",",","/",":",0,2,_24; Galician gl_ES_858 cnf 42034,858,DMY,0D5h, 0,0,0,0,".",",","/",":",0,2,_24 gl_ES_437 cnf 42034,437,DMY,"E","U","R",0,0,".",",","/",":",0,2,_24 eu_ES_850 cnf 43034,850,DMY,"E","U","R",0,0,".",",","/",":",0,2,_24; Basque @@ -3056,7 +3056,24 @@ db 232, 233, 234, 235, 237, 237, 238, 239 db 240, 241, 242, 243, 244, 245, 246, 247 db 248, 249, 250, 251, 252, 253, 254, 255 -ucase_858 equ ucase_850 +ucase_858 db 0FFh,"UCASE " + dw 128 +db 128, 154, 144, 182, 142, 183, 143, 128 +db 210, 211, 212, 216, 215, 222, 142, 143 +db 144, 146, 146, 226, 153, 227, 234, 235 +db 99, 153, 154, 157, 156, 157, 158, 159 +db 181, 214, 224, 233, 165, 165, 166, 167 +db 168, 169, 170, 171, 172, 173, 174, 175 +db 176, 177, 178, 179, 180, 181, 182, 183 +db 184, 185, 186, 187, 188, 189, 190, 191 +db 192, 193, 194, 195, 196, 197, 199, 199 +db 200, 201, 202, 203, 204, 205, 206, 207 +db 209, 209, 210, 211, 212, 213, 214, 215 +db 216, 217, 218, 219, 220, 221, 222, 223 +db 224, 225, 226, 227, 229, 229, 230, 232 +db 232, 233, 234, 235, 237, 237, 238, 239 +db 240, 241, 242, 243, 244, 245, 246, 247 +db 248, 249, 250, 251, 252, 253, 254, 255 ucase_860 db 0FFh,"UCASE " dw 128 ; Derived from ucase_437 From cabdbf0fa97c6da8d9da0e5d4c967cec370ac339 Mon Sep 17 00:00:00 2001 From: Kenneth J Davis Date: Fri, 10 Jul 2009 22:22:43 +0000 Subject: [PATCH 671/671] apply changes made to stable in preparation for merge to stable (OW 1.8 compile fix and improved file copy routine) git-svn-id: https://svn.code.sf.net/p/freedos/svn/kernel/branches/UNSTABLE@1481 6ac86273-5f31-0410-b378-82cca8765d1b --- sys/sys.c | 110 +++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 101 insertions(+), 9 deletions(-) diff --git a/sys/sys.c b/sys/sys.c index dacbf2b1..0c2b1882 100644 --- a/sys/sys.c +++ b/sys/sys.c @@ -32,7 +32,7 @@ #define FDCONFIG /* include support to configure FD kernel */ /* #define DRSYS */ /* SYS for Enhanced DR-DOS (OpenDOS enhancement Project) */ -#define SYS_VERSION "v3.6a" +#define SYS_VERSION "v3.6c" #define SYS_NAME "FreeDOS System Installer " @@ -204,7 +204,7 @@ char *getenv(const char *name) BYTE pgm[] = "SYS"; #define SEC_SIZE 512 -#define COPY_SIZE 0x4000 +#define COPY_SIZE 0x4000 struct bootsectortype { UBYTE bsJump[3]; @@ -604,7 +604,7 @@ void initOptions(int argc, char *argv[], SYSOptions *opts) sprintf(opts->srcDrive, "%c:", 'A' + getcurdrive()); if (srcarg) { - int slen; + int slen; /* set source path, reserving room to append filename */ if ( (argv[srcarg][1] == ':') /* || ((argv[srcarg][0]=='\\') && (argv[srcarg][1] == '\\'))*/ ) strncpy(opts->srcDrive, argv[srcarg], SYS_MAXPATH-13); @@ -900,7 +900,7 @@ void reset_drive(int DosDrive); void truename(char far *dest, const char *src); #pragma aux truename = \ - "mov ah,0x60" \ + "mov ah,0x60" \ "int 0x21" \ parm [es di] [si]; @@ -1019,7 +1019,7 @@ int MyAbsReadWrite(int DosDrive, int count, ULONG sector, void *buffer, unsigned getextdrivespace(void far *drivename, void *buf, unsigned buf_size); #pragma aux getextdrivespace = \ "mov ax, 0x7303" \ - "stc" \ + "stc" \ "int 0x21" \ "sbb ax, ax" \ parm [es dx] [di] [cx] \ @@ -1064,7 +1064,7 @@ BOOL haveLBA(void); /* return TRUE if we have LBA BIOS, FALSE otherwise */ "and cx, 1" \ "xchg cx, ax" \ "quit:" \ - modify [bx cx] \ + modify [bx cx dx] \ value [ax]; #else @@ -1504,7 +1504,7 @@ void put_boot(SYSOptions *opts) if (opts->writeBS) { #ifdef DEBUG - printf("writing new bootsector to drive %c:\n", opts->dstDrive + 'A'); + printf("Writing new bootsector to drive %c:\n", opts->dstDrive + 'A'); #endif /* write newboot to a drive */ @@ -1584,6 +1584,25 @@ BOOL check_space(COUNT drive, ULONG bytes) BYTE copybuffer[COPY_SIZE]; +/* allocate memory from DOS, return 0 on success, nonzero otherwise */ +int alloc_dos_mem(ULONG memsize, UWORD *theseg) +{ +#ifdef __TURBOC__ + if (allocmem((unsigned)((memsize+15)>>4), theseg)==-1) +#else + unsigned dseg; + if (_dos_allocmem((unsigned)((memsize+15)>>4), &dseg)==0) + *theseg = (UWORD)dseg; +#endif + return 0; /* success */ + return -1; /* failed to allocate memory */ +} +#ifdef __TURBOC__ +#define dos_freemem freemem +#else +#define dos_freemem _dos_freemem +#endif + /* copies file (path+filename specified by srcFile) to drive:\filename */ BOOL copy(const BYTE *source, COUNT drive, const BYTE * filename) { @@ -1626,6 +1645,7 @@ BOOL copy(const BYTE *source, COUNT drive, const BYTE * filename) return FALSE; } +#if 0 /* simple copy loop, read chunk then write chunk, repeat until all data copied */ while ((ret = read(fdin, copybuffer, COPY_SIZE)) > 0) { if (write(fdout, copybuffer, ret) != ret) @@ -1633,14 +1653,86 @@ BOOL copy(const BYTE *source, COUNT drive, const BYTE * filename) printf("Can't write %u bytes to %s\n", ret, dest); close(fdout); unlink(dest); - break; + return FALSE; } copied += ret; } + #else /* read in whole file, then write out whole file */ + { + ULONG filesize; + UWORD theseg; + BYTE far *buffer, far *bufptr; + UWORD offs; + unsigned chunk_size; + + /* get length of file to copy, then allocate enough memory for whole file */ + filesize = filelength(fdin); + if (alloc_dos_mem(filesize, &theseg)!=0) + { + printf("Not enough memory to buffer %lu bytes for %s\n", filesize, source); + return NULL; + } + bufptr = buffer = MK_FP(theseg, 0); + + /* read in whole file, a chunk at a time; adjust size of last chunk to match remaining bytes */ + chunk_size = (COPY_SIZE < filesize)?COPY_SIZE:(unsigned)filesize; + while ((ret = read(fdin, copybuffer, chunk_size)) > 0) + { + for (offs = 0; offs < ret; offs++) + { + *bufptr = copybuffer[offs]; + bufptr++; + if (FP_OFF(bufptr) > 0x7777) /* watcom needs this in tiny model */ + { + bufptr = MK_FP(FP_SEG(bufptr)+0x700, FP_OFF(bufptr)-0x7000); + } + } + /* keep track of how much read in, and only read in filesize bytes */ + copied += ret; + chunk_size = (COPY_SIZE < (filesize-copied))?COPY_SIZE:(unsigned)(filesize-copied); + } + + /* write out file, a chunk at a time; adjust size of last chunk to match remaining bytes */ + bufptr = buffer; + copied = 0; + do + { + /* keep track of how much read in, and only read in filesize bytes */ + chunk_size = (COPY_SIZE < (filesize-copied))?COPY_SIZE:(unsigned)(filesize-copied); + copied += chunk_size; + + /* setup chunk of data to be written out */ + for (offs = 0; offs < chunk_size; offs++) + { + copybuffer[offs] = *bufptr; + bufptr++; + if (FP_OFF(bufptr) > 0x7777) /* watcom needs this in tiny model */ + { + bufptr = MK_FP(FP_SEG(bufptr)+0x700, FP_OFF(bufptr)-0x7000); + } + } + + /* write the data to disk, abort on any error */ + if (write(fdout, copybuffer, chunk_size) != chunk_size) + { + printf("Can't write %u bytes to %s\n", ret, dest); + close(fdout); + unlink(dest); + return FALSE; + } + } while (copied < filesize); + + dos_freemem(theseg); + } + #endif { #if defined __WATCOMC__ || defined _MSC_VER /* || defined __BORLANDC__ */ - unsigned short date, time; +#if defined(__WATCOMC__) && __WATCOMC__ < 1280 + unsigned short date, time; +#else + unsigned date, time; +#endif _dos_getftime(fdin, &date, &time); _dos_setftime(fdout, date, time); #elif defined __TURBOC__